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

Added dom and es2021 libs to tsconfig #2657

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions bindings/kepler.gl-jupyter/js/lib/keplergl/kepler.gl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import {addDataToMap, ActionTypes} from '@kepler.gl/actions';
import {KeplerGlSchema} from '@kepler.gl/schemas';
import document from 'global/document';

import renderRoot from './components/root';
import createAppStore from './store';
Expand Down Expand Up @@ -143,7 +142,9 @@ class KeplerGlJupyter {
data: {
fields: d.fields,
// rows: d.allData
...(d.dataContainer instanceof ArrowDataContainer ? {cols: d.dataContainer._cols} : {rows: d.allData})
...(d.dataContainer instanceof ArrowDataContainer
? {cols: d.dataContainer._cols}
: {rows: d.allData})
}
})),
config,
Expand All @@ -153,12 +154,7 @@ class KeplerGlJupyter {
}
}

export function addDataConfigToKeplerGl({
data: inputData,
config,
options,
store
}) {
export function addDataConfigToKeplerGl({data: inputData, config, options, store}) {
const data = inputData ? dataToDatasets(inputData) : [];
log(data);

Expand Down
7 changes: 1 addition & 6 deletions bindings/kepler.gl-jupyter/js/lib/keplergl/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@
// NOTE: this is only used for exporting html template
import createAppStore from './store';
import renderRoot from './components/root';
import document from 'global/document';
import window from 'global/window';
import {addDataConfigToKeplerGl} from './kepler.gl';

const map = (function initKeplerGl() {
const id = 'keplergl-0';
const store = createAppStore();

const divElmt = document.createElement('div');
divElmt.setAttribute(
'style',
'width: 100vw; height: 100vh; position: absolute'
);
divElmt.setAttribute('style', 'width: 100vw; height: 100vh; position: absolute');
document.body.appendChild(divElmt);

return {
Expand Down
1 change: 0 additions & 1 deletion bindings/kepler.gl-jupyter/js/lib/keplergl/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import {tableFromIPC} from 'apache-arrow';
import {processCsvData, processGeojson, processArrowBatches} from '@kepler.gl/processors';
import log from '../log';
import console from 'global/console';

function handleJuptyerDataFormat(dataEntry) {
// This makes passing data between Jupyter the iframe easier
Expand Down
2 changes: 0 additions & 2 deletions bindings/kepler.gl-jupyter/js/lib/log.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project

import console from 'global/console';

function log(...args) {
if (process.env.NODE_ENV === 'development') {
console.log(...args);
Expand Down
7 changes: 3 additions & 4 deletions examples/custom-map-style/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@

import React from 'react';
import ReactDOM from 'react-dom/client';
import document from 'global/document';
import {Provider} from 'react-redux';
import store from './store.ts';
import App from './app.tsx';
import store from './store';
import App from './app';

const Root = () => (
<Provider store={store}>
<App />
</Provider>
);

const root = ReactDOM.createRoot(document.getElementById('root'));
const root = ReactDOM.createRoot(document.getElementById('root')!);

root.render(<Root />);
1 change: 0 additions & 1 deletion examples/custom-reducer/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import React from 'react';
import ReactDOM from 'react-dom/client';
import document from 'global/document';
import {Provider} from 'react-redux';
import store from './store';
import App from './app';
Expand Down
1 change: 0 additions & 1 deletion examples/custom-reducer/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import {createStore, combineReducers, applyMiddleware, compose} from 'redux';
import keplerGlReducer, {uiStateUpdaters, enhanceReduxMiddleware} from '@kepler.gl/reducers';
import appReducer from './app-reducer';
import window from 'global/window';

const customizedKeplerGlReducer = keplerGlReducer
.initialState({
Expand Down
1 change: 0 additions & 1 deletion examples/custom-theme/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import React, {useEffect, useState} from 'react';
import styled from 'styled-components';
import window from 'global/window';
import {connect} from 'react-redux';
import KeplerGl from '@kepler.gl/components';

Expand Down
1 change: 0 additions & 1 deletion examples/custom-theme/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import React from 'react';
import ReactDOM from 'react-dom/client';
import document from 'global/document';
import {Provider} from 'react-redux';
import store from './store';
import App from './app';
Expand Down
1 change: 0 additions & 1 deletion examples/custom-theme/src/store.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project

import window from 'global/window';
import {combineReducers, createStore, applyMiddleware, compose} from 'redux';
import {enhanceReduxMiddleware} from '@kepler.gl/reducers';

Expand Down
1 change: 0 additions & 1 deletion examples/demo-app/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Copyright contributors to the kepler.gl project

import {push} from 'react-router-redux';
import {fetch} from 'global';

import {loadFiles, toggleModal} from '@kepler.gl/actions';
import {load} from '@loaders.gl/core';
Expand Down
3 changes: 1 addition & 2 deletions examples/demo-app/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import React, {Component} from 'react';
import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer';
import styled, {ThemeProvider} from 'styled-components';
import window from 'global/window';
import {connect} from 'react-redux';

import {theme} from '@kepler.gl/styles';
Expand Down Expand Up @@ -438,4 +437,4 @@ class App extends Component {
const mapStateToProps = state => state;
const dispatchToProps = dispatch => ({dispatch});

export default connect(mapStateToProps, dispatchToProps)(App);
export default React.memo(connect(mapStateToProps, dispatchToProps)(App));
15 changes: 7 additions & 8 deletions examples/demo-app/src/cloud-providers/carto/carto-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Copyright contributors to the kepler.gl project

import {OAuthApp} from '@carto/toolkit';
import Console from 'global/console';
import CartoIcon from './carto-icon';
import {Provider} from '@kepler.gl/cloud-providers';
import {createDataContainer} from '@kepler.gl/utils';
Expand Down Expand Up @@ -343,33 +342,33 @@ export default class CartoProvider extends Provider {

switch (error.message) {
case 'No client ID has been specified':
Console.error('No ClientID set for CARTO provider');
console.error('No ClientID set for CARTO provider');
break;
case 'Cannot set the client ID more than once':
Console.error('CARTO provider already initialized');
console.error('CARTO provider already initialized');
break;
case (error.message.match(/relation "[a-zA-Z0-9_]+" does not exist/) || {}).input:
Console.error('CARTO custom storage is not properly initialized');
console.error('CARTO custom storage is not properly initialized');
message = 'Custom storage is not properly initialized';
break;
case (
error.message.match(/Failed to copy to keplergl_[a-zA-Z0-9_]+: Too many retries/) || {}
).input:
Console.error('CARTO Rate limit exceeded');
console.error('CARTO Rate limit exceeded');
message =
"Failed to upload. You've exceeded the number of datasets allowed with your plan. Consider upgrading your plan.";
break;
case (error.message.match(/[a-zA-Z0-9_\s:]+: DB Quota exceeded/) || {}).input:
Console.error('CARTO DB Quota exceeded');
console.error('CARTO DB Quota exceeded');
message =
"Failed to upload. You've exceeded your account's disk storage limit. Consider upgrading your plan.";
break;
default:
Console.error(`CARTO provider: ${message}`);
console.error(`CARTO provider: ${message}`);
}
} else {
message = 'General error in CARTO provider';
Console.error(message);
console.error(message);
}

// Use 'CARTO' as error code in order to show provider in notifications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

// DROPBOX
import {Dropbox} from 'dropbox';
import window from 'global/window';
import DropboxIcon from './dropbox-icon';
import {MAP_URI} from '../../constants/default-settings';
import {KEPLER_FORMAT, Provider} from '@kepler.gl/cloud-providers';
Expand Down
1 change: 0 additions & 1 deletion examples/demo-app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import React from 'react';
import ReactDOM from 'react-dom/client';
import document from 'global/document';
import {Provider} from 'react-redux';
import {browserHistory, Router, Route} from 'react-router';
import {syncHistoryWithStore} from 'react-router-redux';
Expand Down
1 change: 0 additions & 1 deletion examples/demo-app/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {browserHistory} from 'react-router';
import {enhanceReduxMiddleware} from '@kepler.gl/reducers';
import thunk from 'redux-thunk';
// eslint-disable-next-line no-unused-vars
import window from 'global/window';

import demoReducer from './reducers/index';

Expand Down
1 change: 0 additions & 1 deletion examples/node-app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import React from 'react';
import ReactDOM from 'react-dom/client';
import document from 'global/document';
import {Provider} from 'react-redux';
import store from './store';
import App from './app';
Expand Down
1 change: 0 additions & 1 deletion examples/open-modal/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import React from 'react';
import ReactDOM from 'react-dom/client';
import document from 'global/document';
import {Provider} from 'react-redux';
import store from './store';
import App from './app';
Expand Down
1 change: 0 additions & 1 deletion examples/open-modal/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {createStore, combineReducers, applyMiddleware, compose} from 'redux';
import keplerGlReducer, {enhanceReduxMiddleware} from '@kepler.gl/reducers';

import appReducer from './app-reducer';
import window from 'global/window';

const reducers = combineReducers({
keplerGl: keplerGlReducer,
Expand Down
1 change: 0 additions & 1 deletion examples/replace-component/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import React from 'react';
import ReactDOM from 'react-dom/client';
import document from 'global/document';
import {Provider} from 'react-redux';
import store from './store';
import App from './app';
Expand Down
2 changes: 0 additions & 2 deletions scripts/license-header/bin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import readdirp from 'readdirp';
import minimist from 'minimist';
import {readFileSync} from 'fs';
import process from 'global/process.js';
import console from 'global/console.js';

import LicenseFixer from './license-fixer.mjs';

Expand Down
3 changes: 1 addition & 2 deletions scripts/license-header/license-fixer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// Forked from uber-licence, MIT

import {readFileSync, writeFileSync} from 'fs';
import console from 'global/console.js';

function LicenseFixer(options) {
options = options || {};
Expand Down Expand Up @@ -163,4 +162,4 @@ LicenseFixer.prototype.fixFile = function fixFile(file) {
return true;
};

export default LicenseFixer
export default LicenseFixer
8 changes: 3 additions & 5 deletions scripts/log.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project

const console = require('global/console');

const Colors = {
Reset: '\x1b[0m',
Bright: '\x1b[1m',
Expand All @@ -29,7 +27,7 @@ const Colors = {
BgMagenta: '\x1b[45m',
BgCyan: '\x1b[46m',
BgWhite: '\x1b[47m'
}
};

function log(color) {
return function logWithColor(msg) {
Expand All @@ -42,5 +40,5 @@ module.exports = {
logOk: log(Colors.FgCyan),
logError: log(Colors.FgRed),
logProgress: log(Colors.FgBlue),
logStep: log(Colors.FgMagenta),
}
logStep: log(Colors.FgMagenta)
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

import React, {Component} from 'react';
import {bisectLeft} from 'd3-array';
import {requestAnimationFrame, cancelAnimationFrame} from 'global/window';
import Console from 'global/console';
import {BASE_SPEED, FPS, ANIMATION_WINDOW} from '@kepler.gl/constants';
import {Timeline} from '@kepler.gl/types';

Expand Down Expand Up @@ -84,7 +82,7 @@ function AnimationControllerFactory(): typeof AnimationControllerType {
}
}

_timer = null;
_timer: null | number = null;
_startTime = 0;

_startOrPauseAnimation() {
Expand Down Expand Up @@ -160,7 +158,7 @@ function AnimationControllerFactory(): typeof AnimationControllerType {
// 30*600
const {steps} = this.props;
if (!Array.isArray(steps) || !steps.length) {
Console.warn('animation steps should be an array');
console.warn('animation steps should be an array');
return;
}
// when speed = 1, animation should loop through 600 frames at 60 FPS
Expand Down
5 changes: 2 additions & 3 deletions src/components/src/common/data-table/cell-size.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project

import document from 'global/document';
import {DataContainerInterface, parseFieldValue} from '@kepler.gl/utils';

const MIN_GHOST_CELL_SIZE = 200;
Expand Down Expand Up @@ -60,7 +59,7 @@ export function renderedSize({

const textCanvas = document.createElement('canvas');
document.body.appendChild(textCanvas);
const context = textCanvas.getContext('2d');
const context = textCanvas.getContext('2d')!;
context.font = [fontSize, font].join('px ');

let rowsToSample = [...Array(numRowsToCalculate)].map(() =>
Expand Down Expand Up @@ -95,7 +94,7 @@ export function renderedSize({
const clampedHeaderWidth = clamp(minHeaderWidth, maxHeaderSize, headerWidth);

// cleanup
textCanvas.parentElement.removeChild(textCanvas);
textCanvas.parentElement!.removeChild(textCanvas);

return {
row: clampedRowWidth,
Expand Down
1 change: 0 additions & 1 deletion src/components/src/common/error-boundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Copyright contributors to the kepler.gl project

import React, {ErrorInfo} from 'react';
import console from 'global/console';

interface ErrorBoundaryProps {
children?: React.ReactNode;
Expand Down
7 changes: 2 additions & 5 deletions src/components/src/common/file-uploader/file-drop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* For React 16.8 compatibility
*/
import React, {ReactNode} from 'react';
import window from 'global/window';

export type FileDropProps = {
dropEffect?: 'copy' | 'move' | 'link' | 'none';
Expand All @@ -29,10 +28,8 @@ export type FileDropProps = {
/** @augments React.PureComponent<FileDropProps> */
class FileDrop extends React.PureComponent<FileDropProps> {
static isIE = () =>
window &&
window.navigator &&
((window.navigator.userAgent || []).includes('MSIE') ||
(window.navigator.appVersion || []).includes('Trident/'));
window?.navigator?.userAgent?.includes('MSIE') ||
window?.navigator?.appVersion?.includes('Trident/');

static eventHasFiles = event => {
// In most browsers this is an array, but in IE11 it's an Object :(
Expand Down
Loading
Loading