Skip to content

Commit

Permalink
[Chore]: Technical: Isolate actions (#1948)
Browse files Browse the repository at this point in the history
* Build fix

Signed-off-by: Daria Terekhova <daria.terekhova@actionengine.com>

* Actions isolation

Signed-off-by: Daria Terekhova <daria.terekhova@actionengine.com>

* Imports updated

Signed-off-by: Daria Terekhova <daria.terekhova@actionengine.com>

* Build fix

Signed-off-by: Daria Terekhova <daria.terekhova@actionengine.com>

* Package.json correction

Signed-off-by: Daria Terekhova <daria.terekhova@actionengine.com>

* Review corrections

Signed-off-by: Daria Terekhova <daria.terekhova@actionengine.com>

Signed-off-by: Daria Terekhova <daria.terekhova@actionengine.com>
  • Loading branch information
dariaterekhova-actionengine committed Aug 24, 2022
1 parent f828f69 commit 8ea93d4
Show file tree
Hide file tree
Showing 78 changed files with 317 additions and 199 deletions.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -26,7 +26,8 @@
"./src/layers",
"./src/cloud-providers",
"./src/processors",
"./src/tasks"
"./src/tasks",
"./src/actions"
],
"repository": {
"type": "git",
Expand Down
64 changes: 64 additions & 0 deletions src/actions/babel.config.js
@@ -0,0 +1,64 @@
// 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-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
};
};
47 changes: 47 additions & 0 deletions src/actions/package.json
@@ -0,0 +1,47 @@
{
"name": "@kepler.gl/actions",
"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/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"
],
"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"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions src/actions/index.ts → src/actions/src/index.ts
Expand Up @@ -22,13 +22,21 @@
export * from './actions';

// kepler.gl actions accessible outside component
export * from './action-wrapper';
export * from './vis-state-actions';
export * from './ui-state-actions';
export * from './map-state-actions';
export * from './map-style-actions';
export * from './identity-actions';
export * from './provider-actions';

/* eslint-disable prettier/prettier */
export * as VisStateActions from './vis-state-actions';
export * as MapStateActions from './map-state-actions';
export * as MapStyleActions from './map-style-actions';
export * as UIStateActions from './ui-state-actions';
export * as ProviderActions from './provider-actions';

// Dispatch
export {
_actionFor,
Expand All @@ -41,3 +49,4 @@ export {

export {ACTION_PREFIX} from './action-types';
export {default as ActionTypes} from './action-types';
export {ActionTypes as ProviderActionTypes} from './provider-actions';
File renamed without changes.
File renamed without changes.
Expand Up @@ -20,7 +20,7 @@

import {createAction} from '@reduxjs/toolkit';
import {ACTION_PREFIX} from './action-types';
import {SavedMap} from 'schemas';
import {ExportFileOptions, ExportFileToCloudPayload, OnErrorCallBack, OnSuccessCallBack} from '@kepler.gl/types';
import {MapListItem, Provider} from 'cloud-providers';

// eslint-disable-next-line prettier/prettier
Expand All @@ -40,30 +40,6 @@ export const ActionTypes = assignType({
GET_SAVED_MAPS_ERROR: `${ACTION_PREFIX}GET_SAVED_MAPS_ERROR`
});

/** EXPORT_FILE_TO_CLOUD */
export type MapData = {
map: SavedMap;
thumbnail: Blob | null;
};
export type ExportFileOptions = {
isPublic?: boolean;
overwrite?: boolean;
};
export type OnErrorCallBack = (error: Error) => any;
export type OnSuccessCallBack = (p: {
response: any;
provider: Provider;
options: ExportFileOptions;
}) => any;

export type ExportFileToCloudPayload = {
mapData: MapData;
provider: Provider;
options: ExportFileOptions;
onSuccess?: OnSuccessCallBack;
onError?: OnErrorCallBack;
closeModal?: boolean;
};
/**
* Call provider to upload file to cloud
* @param mapData
Expand Down
File renamed without changes.
Expand Up @@ -1175,6 +1175,7 @@ type FileContent = {
};
export type NextFileBatchUpdaterAction = {
payload: {
/* eslint-disable no-undef */
gen: AsyncGenerator<FileContent>;
fileName: string;
progress?: any;
Expand Down
33 changes: 33 additions & 0 deletions src/actions/tsconfig.production.json
@@ -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": false, //TODO needs to be removed once all isolations are ready
"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/actions": ["actions/src"] //TODO change once all dependencies are isolated
}
},
"include": [
"src"
]
}
2 changes: 1 addition & 1 deletion src/cloud-providers/src/provider.ts
Expand Up @@ -19,7 +19,7 @@
// THE SOFTWARE.

import {Upload} from 'components/common/icons';
import {MapData, ExportFileOptions} from 'actions/provider-actions';
import {MapData, ExportFileOptions} from '@kepler.gl/types';
import {ComponentType} from 'react';

export type Millisecond = number;
Expand Down
3 changes: 1 addition & 2 deletions src/components/container.tsx
Expand Up @@ -24,9 +24,8 @@ import memoize from 'lodash.memoize';
import {console as Console} from 'global/window';
import {injector, provideRecipesToInjector, flattenDeps} from './injector';
import KeplerGlFactory from './kepler-gl';
import {forwardTo} from 'actions/action-wrapper';

import {registerEntry, deleteEntry, renameEntry} from 'actions/identity-actions';
import {registerEntry, deleteEntry, renameEntry, forwardTo} from '@kepler.gl/actions';
import {notNullorUndefined} from '@kepler.gl/utils';
import {KeplerGlState} from 'reducers/core';

Expand Down
2 changes: 1 addition & 1 deletion src/components/filters/types.ts
Expand Up @@ -14,7 +14,7 @@ import {
setFilterPlot,
toggleFilterAnimation,
updateFilterAnimationSpeed
} from 'actions';
} from '@kepler.gl/actions';
import {Datasets} from 'reducers/table-utils/kepler-table';

export type PolygonFilterProps = {
Expand Down
14 changes: 8 additions & 6 deletions src/components/kepler-gl.tsx
Expand Up @@ -27,13 +27,15 @@ import {connect as keplerGlConnect} from 'connect/keplergl-connect';
import {IntlProvider} from 'react-intl';
import {messages} from '@kepler.gl/localization';
import {RootContext, FeatureFlagsContextProvider, FeatureFlags} from 'components/context';
import {OnErrorCallBack, OnSuccessCallBack} from 'actions/provider-actions';
import {OnErrorCallBack, OnSuccessCallBack} from '@kepler.gl/types';

import * as VisStateActions from 'actions/vis-state-actions';
import * as MapStateActions from 'actions/map-state-actions';
import * as MapStyleActions from 'actions/map-style-actions';
import * as UIStateActions from 'actions/ui-state-actions';
import * as ProviderActions from 'actions/provider-actions';
import {
MapStateActions,
MapStyleActions,
ProviderActions,
UIStateActions,
VisStateActions
} from '@kepler.gl/actions';

type KeplerGlActions = {
visStateActions: typeof VisStateActions;
Expand Down
4 changes: 1 addition & 3 deletions src/components/map-container.tsx
Expand Up @@ -26,9 +26,7 @@ import {createSelector} from 'reselect';
import WebMercatorViewport from 'viewport-mercator-project';
import mapboxgl from 'mapbox-gl';

import * as VisStateActions from 'actions/vis-state-actions';
import * as MapStateActions from 'actions/map-state-actions';
import * as UIStateActions from 'actions/ui-state-actions';
import {VisStateActions, MapStateActions, UIStateActions} from '@kepler.gl/actions';

// components
import MapPopoverFactory from 'components/map/map-popover';
Expand Down
12 changes: 7 additions & 5 deletions src/components/modal-container.tsx
Expand Up @@ -61,13 +61,15 @@ import {

import {getFileFormatNames, getFileExtensions} from 'reducers/vis-state-selectors';
import {MapStyle} from 'reducers';
import {MapState, UiState, OnSuccessCallBack, OnErrorCallBack} from '@kepler.gl/types';
import {MapState, UiState, OnErrorCallBack, OnSuccessCallBack} from '@kepler.gl/types';
import {ProviderState} from 'reducers/provider-state-updaters';

import * as VisStateActions from 'actions/vis-state-actions';
import * as UIStateActions from 'actions/ui-state-actions';
import * as MapStyleActions from 'actions/map-style-actions';
import * as ProviderActions from 'actions/provider-actions';
import {
VisStateActions,
UIStateActions,
MapStyleActions,
ProviderActions
} from '@kepler.gl/actions';
import {ModalDialogProps} from './common/modal';
import {Provider} from 'cloud-providers';
import {findDOMNode} from 'react-dom';
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/export-map-modal/export-html-map.tsx
Expand Up @@ -31,7 +31,7 @@ import {injectIntl} from 'react-intl';
import {FormattedMessage} from '@kepler.gl/localization';
import {IntlShape} from 'react-intl';

import {setUserMapboxAccessToken, setExportHTMLMapMode, ActionHandler} from 'actions';
import {setUserMapboxAccessToken, setExportHTMLMapMode, ActionHandler} from '@kepler.gl/actions';

const ExportMapStyledExportSection = styled(StyledExportSection)`
.disclaimer {
Expand Down
Expand Up @@ -27,7 +27,7 @@ import {StyledExportMapSection} from './components';
import ExportHtmlMapFactory from './export-html-map';
import ExportJsonMapFactory from './export-json-map';
import {FormattedMessage} from '@kepler.gl/localization';
import {ActionHandler, setExportHTMLMapMode, setUserMapboxAccessToken} from 'actions';
import {ActionHandler, setExportHTMLMapMode, setUserMapboxAccessToken} from '@kepler.gl/actions';

interface ExportMapModalFactoryProps {
options?: {format: string};
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/image-modal-container.tsx
Expand Up @@ -22,7 +22,7 @@ import React, {useEffect} from 'react';
import get from 'lodash.get';

import {MAP_THUMBNAIL_DIMENSION, EXPORT_IMG_RATIOS} from '@kepler.gl/constants';
import {SetExportImageSettingUpdaterAction} from 'actions';
import {SetExportImageSettingUpdaterAction} from '@kepler.gl/actions';
import {Provider} from '@kepler.gl/cloud-providers';

/** @typedef {import('./image-modal-container').ImageModalContainerProps} ImageModalContainerProps */
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/provider-modal-container.tsx
Expand Up @@ -20,7 +20,7 @@

import React, {Component} from 'react';
import {Provider} from 'cloud-providers';
import {SetCloudProviderPayload} from 'actions';
import {SetCloudProviderPayload} from '@kepler.gl/actions';

export type ProviderModalContainerProps = {
cloudProviders?: Provider[];
Expand Down
2 changes: 1 addition & 1 deletion src/components/notification-panel.tsx
Expand Up @@ -24,7 +24,7 @@ import styled from 'styled-components';
import NotificationItemFactory from './notification-panel/notification-item';
import {DEFAULT_NOTIFICATION_TOPICS} from '@kepler.gl/constants';
import {Notifications} from '@kepler.gl/types';
import {removeNotification} from 'actions/ui-state-actions';
import {removeNotification} from '@kepler.gl/actions';

const NotificationPanelContent = styled.div`
background: transparent;
Expand Down
2 changes: 1 addition & 1 deletion src/components/notification-panel/notification-item.tsx
Expand Up @@ -22,7 +22,7 @@ import React, {Component} from 'react';
import styled from 'styled-components';
import {Delete, Info, Warning, Checkmark} from 'components/common/icons';
import ReactMarkdown from 'react-markdown';
import {ActionHandler, removeNotification as removeNotificationActions} from 'actions';
import {ActionHandler, removeNotification as removeNotificationActions} from '@kepler.gl/actions';

interface NotificationItemContentProps {
type: string;
Expand Down
6 changes: 5 additions & 1 deletion src/components/plot-container.tsx
Expand Up @@ -37,7 +37,11 @@ import MapsLayoutFactory from './maps-layout';

import {GEOCODER_LAYER_ID, ExportImage} from '@kepler.gl/constants';
import {SplitMap} from '@kepler.gl/types';
import {setExportImageDataUri, setExportImageError, setExportImageSetting} from 'actions';
import {
setExportImageDataUri,
setExportImageError,
setExportImageSetting
} from '@kepler.gl/actions';
import {mapFieldsSelector} from './kepler-gl';

const CLASS_FILTER = ['mapboxgl-control-container', 'attrition-link', 'attrition-logo'];
Expand Down
6 changes: 3 additions & 3 deletions src/components/side-panel/common/types.ts
@@ -1,7 +1,7 @@
import React, {MouseEvent} from 'react';
import {openDeleteModal} from 'actions/ui-state-actions';
import * as VisStateActions from 'actions/vis-state-actions';
import {ActionHandler} from 'actions';
import {openDeleteModal} from '@kepler.gl/actions';
import {VisStateActions} from '@kepler.gl/actions';
import {ActionHandler} from '@kepler.gl/actions';
import KeplerTable, {Datasets} from 'reducers/table-utils/kepler-table';

export type DatasetInfoProps = {
Expand Down

0 comments on commit 8ea93d4

Please sign in to comment.