Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chore]: Technical: Isolate processors #1857

Merged
merged 4 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"no-inline-comments": 0,
"no-invalid-this": 0,
"no-unused-expressions": 0,
"no-undef": 0,
"camelcase": 0,
"consistent-return": 0,
"comma-dangle": 1
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"./src/constants",
"./src/types",
"./src/deckgl-layers",
"./src/layers"
"./src/layers",
"./src/processors"
],
"repository": {
"type": "git",
Expand Down Expand Up @@ -60,12 +61,12 @@
"analyze:bundle": "webpack --config ./webpack/bundle.js --progress --env.prod",
"check-licence": "uber-licence --dry",
"add-licence": "uber-licence",
"prepublish": "yarn workspaces run prepublish && uber-licence && yarn build && yarn build:umd && yarn build:types",
"prepublish": "yarn workspaces run stab && yarn workspaces run prepublish && uber-licence && yarn build && yarn build:umd && yarn build:types",
"docs": "babel-node ./scripts/documentation.js",
"typedoc": "typedoc --theme markdown --out typedoc --inputFiles ./src/reducers --inputFiles ./src/actions --excludeExternals --excludeNotExported --excludePrivate",
"example-version": "babel-node ./scripts/edit-version.js",
"prettier-all": "prettier --write '{src,examples,test}/**/*.{js,tsx,ts}'",
"lint": "yarn typescript && eslint src/*/src/*.{js,tsx,ts} test webpack examples/*.js examples/**/src/*.{js,tsx,ts} website/*.js website/src --fix",
"lint": "yarn typescript && eslint src/*/src/*.{js,tsx,ts} test webpack examples/*.js examples/**/src/*.{js,tsx,ts} website/*.js website/src --fix",
"lint:css": "stylelint './src/**/*.js'",
"typescript": "tsc --noEmit",
"web": "(yarn && yarn install:web && yarn start:web)",
Expand Down
2 changes: 1 addition & 1 deletion src/actions/vis-state-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// vis-state-reducer
import {default as ActionTypes} from './action-types';
import {AddDataToMapPayload} from '../actions/actions';
import {FileCacheItem} from '../processors/types';
import {FileCacheItem} from '@kepler.gl/processors';
import {Layer, LayerBaseConfig} from '@kepler.gl/layers';
import {Feature, InteractionConfig} from 'reducers/vis-state-updaters';
import {ValueOf, Merge, RGBColor, NestedPartial, LayerVisConfig, ColorUI} from '@kepler.gl/types';
Expand Down
2 changes: 1 addition & 1 deletion src/components/geocoder-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import React, {Component, ComponentType} from 'react';
import styled from 'styled-components';
import {processRowObject} from 'processors';
import {processRowObject} from '@kepler.gl/processors';
import {FlyToInterpolator} from '@deck.gl/core';
import KeplerGlSchema from 'schemas';
import {getCenterAndZoomFromBounds} from 'utils/projection-utils';
Expand Down
3 changes: 2 additions & 1 deletion src/constants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"build": "rm -fr dist && babel src --out-dir dist --source-maps inline --extensions '.ts,.tsx,.js,.jsx' --ignore '**/*.d.ts'",
"build:umd": "webpack --config ./webpack/umd.js --progress --env.prod",
"build:types": "tsc --project ./tsconfig.production.json",
"prepublish": "uber-licence && yarn build && yarn build:umd && yarn build:types"
"prepublish": "uber-licence && yarn build && yarn build:umd && yarn build:types",
"stab": "mkdir -p dist && touch dist/index.js"
},
"files": [
"dist",
Expand Down
3 changes: 2 additions & 1 deletion src/deckgl-layers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"build": "rm -fr dist && babel src --out-dir dist --source-maps inline --extensions '.ts,.tsx,.js,.jsx' --ignore '**/*.d.ts'",
"build:umd": "webpack --config ./webpack/umd.js --progress --env.prod",
"build:types": "tsc --project ./tsconfig.production.json",
"prepublish": "uber-licence && yarn build && yarn build:types"
"prepublish": "uber-licence && yarn build && yarn build:types",
"stab": "mkdir -p dist && touch dist/index.js"
},
"files": [
"dist",
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export * from './actions';
export * from '@kepler.gl/constants';

// Processors
export * from './processors';
export * from '@kepler.gl/processors';

// Components
export * from './components';
Expand Down
17 changes: 9 additions & 8 deletions src/layers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,25 @@
"build": "rm -fr dist && babel src --out-dir dist --source-maps inline --extensions '.ts,.tsx,.js,.jsx' --ignore '**/*.d.ts'",
"build:umd": "webpack --config ./webpack/umd.js --progress --env.prod",
"build:types": "tsc --project ./tsconfig.production.json",
"prepublish": "uber-licence && yarn build && yarn build:types"
"prepublish": "uber-licence && yarn build && yarn build:types",
"stab": "mkdir -p dist && touch dist/index.js"
},
"files": [
"dist",
"umd"
],
"dependencies": {
"@deck.gl/geo-layers": "8.2.0",
"@deck.gl/core": "8.2.0",
"@deck.gl/extensions": "8.2.0",
"@deck.gl/layers": "8.2.0",
"@deck.gl/mesh-layers": "8.2.0",
"@deck.gl/core": "^8.4.11",
"@deck.gl/extensions": "^8.4.11",
"@deck.gl/geo-layers": "^8.4.11",
"@deck.gl/layers": "^8.4.11",
"@deck.gl/mesh-layers": "^8.4.11",
"@kepler.gl/deckgl-layers": "^2.5.5",
"@kepler.gl/layers": "^2.5.5",
"@kepler.gl/constants": "^2.5.5",
"@kepler.gl/types": "^2.5.5",
"@loaders.gl/core": "^2.3.3",
"@loaders.gl/gltf": "^2.3.3",
"@loaders.gl/core": "^2.3.12",
"@loaders.gl/gltf": "^2.3.12",
"@mapbox/geojson-normalize": "0.0.1",
"@turf/bbox": "^6.0.1",
"@types/geojson": "^7946.0.7",
Expand Down
65 changes: 65 additions & 0 deletions src/processors/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright (c) 2022 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

const KeplerPackage = require('./package');

const PRESETS = ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'];
const PLUGINS = [
['@babel/plugin-transform-typescript', {isTSX: true, allowDeclareFields: true}],
'@babel/plugin-transform-modules-commonjs',
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-optional-chaining',
[
'@babel/transform-runtime',
{
regenerator: true
}
],
[
'search-and-replace',
{
rules: [
{
search: '__PACKAGE_VERSION__',
replace: KeplerPackage.version
}
]
}
]
];
const ENV = {
test: {
plugins: ['istanbul']
},
debug: {
sourceMaps: 'inline',
retainLines: true
}
};

module.exports = function babel(api) {
api.cache(true);

return {
presets: PRESETS,
plugins: PLUGINS,
env: ENV
};
};
54 changes: 54 additions & 0 deletions src/processors/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "@kepler.gl/processors",
"author": "Shan He <shan@uber.com>",
"version": "2.5.5",
"description": "kepler.gl constants used by kepler.gl components, actions and reducers",
"license": "MIT",
"main": "dist/index.js",
"types": "dist/processors/src/index.d.ts",
"keywords": [
"babel",
"es6",
"react",
"webgl",
"visualization",
"deck.gl"
],
"repository": {
"type": "git",
"url": "https://github.com/keplergl/kepler.gl.git"
},
"scripts": {
"build": "rm -fr dist && babel src --out-dir dist --source-maps inline --extensions '.ts,.tsx,.js,.jsx' --ignore '**/*.d.ts'",
"build:umd": "webpack --config ./webpack/umd.js --progress --env.prod",
"build:types": "tsc --project ./tsconfig.production.json",
"prepublish": "uber-licence && yarn build && yarn build:types",
"stab": "mkdir -p dist && touch dist/index.js"
},
"files": [
"dist",
"umd"
],
"dependencies": {
"colorbrewer": "^1.5.0",
"d3-scale": "^3.2.3",
"global": "^4.3.0",
"keymirror": "^0.1.1",
"react-map-gl-draw": "0.14.8"
},
"nyc": {
"sourceMap": false,
"instrument": false
},
"engines": {
"node": ">=12.0.0"
},
"maintainers": [
"Shan He <heshan0131@gmail.com>",
"Giuseppe Macri <gmacri@uber.com>"
],
"volta": {
"node": "12.22.0",
"yarn": "1.22.17"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import assert from 'assert';
import {Analyzer, DATA_TYPES as AnalyzerDATA_TYPES} from 'type-analyzer';
import normalize from '@mapbox/geojson-normalize';
import {ALL_FIELD_TYPES, DATASET_FORMATS, GUIDES_FILE_FORMAT_DOC} from '@kepler.gl/constants';
import {notNullorUndefined, parseFieldValue} from 'utils/data-utils';
import KeplerGlSchema, {SavedMap, ParsedDataset} from 'schemas';
import {notNullorUndefined, parseFieldValue} from '../../utils/data-utils';
import KeplerGlSchema, {SavedMap, ParsedDataset} from '../../schemas';
import {LoadedMap} from 'schemas/schema-manager';
import {hasOwnProperty, isPlainObject, toArray} from 'utils/utils';
import {Field} from 'utils/table-utils/kepler-table';
import {DataContainerInterface} from 'utils/table-utils/data-container-interface';
import {hasOwnProperty, isPlainObject, toArray} from '../../utils/utils';
import {Field} from '../../utils/table-utils/kepler-table';
import {DataContainerInterface} from '../../utils/table-utils/data-container-interface';
import {ProcessorResult, RowData} from './types';
import {Feature} from '@nebula.gl/edit-modes';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import {parseInBatches} from '@loaders.gl/core';
import {JSONLoader, _JSONPath} from '@loaders.gl/json';
import {CSVLoader} from '@loaders.gl/csv';
import {processGeojson, processKeplerglJSON, processRowObject} from './data-processor';
import {isPlainObject, generateHashId} from 'utils/utils';
import {isPlainObject, generateHashId} from '../../utils/utils';
import {DATASET_FORMATS} from '@kepler.gl/constants';
import {LoaderObject} from '@loaders.gl/loader-utils';
import {AddDataToMapPayload} from 'actions/actions';
import {AddDataToMapPayload} from '../../actions/actions';
import {FileCacheItem, ValidKeplerGlMap} from './types';
import {Feature} from 'reducers';
import {Feature} from '../../reducers';
import {FeatureCollection} from '@turf/helpers';

const BATCH_TYPE = {
Expand Down Expand Up @@ -59,11 +59,11 @@ export function isGeoJson(json: unknown): json is Feature | FeatureCollection {
}

export function isFeature(json: unknown): json is Feature {
return isPlainObject(json) && json.type === 'Feature' && !!json.geometry;
return isPlainObject(json) && json.type === 'Feature' && Boolean(json.geometry);
}

export function isFeatureCollection(json: unknown): json is FeatureCollection {
return isPlainObject(json) && json.type === 'FeatureCollection' && !!json.features;
return isPlainObject(json) && json.type === 'FeatureCollection' && Boolean(json.features);
}

export function isRowObject(json: any): boolean {
Expand Down
1 change: 1 addition & 0 deletions src/processors/index.ts → src/processors/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@

export * from './data-processor';
export * from './file-handler';
export * from './types';
25 changes: 25 additions & 0 deletions src/processors/src/typedefs/deckgl.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) 2022 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import * as DeckTypings from '@danmarshall/deckgl-typings';

declare module 'deck.gl' {
export namespace DeckTypings {}
}
File renamed without changes.
33 changes: 33 additions & 0 deletions src/processors/tsconfig.production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"compilerOptions": {
"target": "es2020",
"allowJs": false,
"checkJs": false,
"jsx": "react",
"module": "esnext",
"moduleResolution": "node",
"declaration":true,
"emitDeclarationOnly":true,
"noImplicitAny": false,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"outDir": "dist",
"sourceMap": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"strict": true,
"resolveJsonModule": true,
"isolatedModules": true,
"baseUrl": "../../src", //TODO change once all dependencies are isolated
"paths": {
"@kepler.gl/processors": ["processors/src"] //TODO change once all dependencies are isolated
}
},
"include": [
"src"
]
}