@deck.gl/jupyter-widget 8.9.0-alpha.5 → 8.9.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@deck.gl/jupyter-widget",
3
3
  "description": "Jupyter widget for rendering deck.gl in a Jupyter notebook",
4
4
  "license": "MIT",
5
- "version": "8.9.0-alpha.5",
5
+ "version": "8.9.0-beta.1",
6
6
  "keywords": [
7
7
  "jupyter",
8
8
  "jupyterlab",
@@ -23,24 +23,24 @@
23
23
  ],
24
24
  "sideEffects": false,
25
25
  "scripts": {
26
- "watch": "webpack --watch",
27
- "build": "webpack -p",
26
+ "watch": "npm run build -- --watch",
27
+ "build": "ocular-bundle ./src/index.js --output=./dist/index.js --globalName= --sourcemap --format=umd --externals=@jupyter-widgets/base",
28
28
  "build:labextension": "npm pack",
29
- "prepublishOnly": "webpack -p"
29
+ "prepublishOnly": "npm run build"
30
30
  },
31
31
  "dependencies": {
32
- "@deck.gl/aggregation-layers": "8.9.0-alpha.5",
33
- "@deck.gl/geo-layers": "8.9.0-alpha.5",
34
- "@deck.gl/google-maps": "8.9.0-alpha.5",
35
- "@deck.gl/json": "8.9.0-alpha.5",
36
- "@deck.gl/layers": "8.9.0-alpha.5",
37
- "@deck.gl/mesh-layers": "8.9.0-alpha.5",
32
+ "@deck.gl/aggregation-layers": "8.9.0-beta.1",
33
+ "@deck.gl/geo-layers": "8.9.0-beta.1",
34
+ "@deck.gl/google-maps": "8.9.0-beta.1",
35
+ "@deck.gl/json": "8.9.0-beta.1",
36
+ "@deck.gl/layers": "8.9.0-beta.1",
37
+ "@deck.gl/mesh-layers": "8.9.0-beta.1",
38
38
  "@jupyter-widgets/base": "^1.1.10 || ^2 || ^3 || ^4",
39
- "@loaders.gl/3d-tiles": "^3.2.10",
40
- "@loaders.gl/core": "^3.2.10",
41
- "@loaders.gl/csv": "^3.2.10",
39
+ "@loaders.gl/3d-tiles": "^3.3.0-alpha.10",
40
+ "@loaders.gl/core": "^3.3.0-alpha.10",
41
+ "@loaders.gl/csv": "^3.3.0-alpha.10",
42
42
  "@luma.gl/constants": "^8.5.16",
43
- "mapbox-gl": "^1.2.1"
43
+ "mapbox-gl": "^1.13.2"
44
44
  },
45
45
  "jupyterlab": {
46
46
  "extension": "src/plugin",
@@ -51,5 +51,5 @@
51
51
  }
52
52
  }
53
53
  },
54
- "gitHead": "36330f8ca588055b11ed8032dc68ced641cb258b"
54
+ "gitHead": "47223d1ea084c3f9b0c9f0f9736682850bb5db85"
55
55
  }
@@ -2,16 +2,10 @@
2
2
  * Pulls together all deck.gl dependencies used
3
3
  * in @deck.gl/jupyter-widget
4
4
  */
5
- const deck = require('../../core/bundle');
6
-
7
- Object.assign(
8
- deck,
9
- require('@deck.gl/layers'),
10
- require('@deck.gl/aggregation-layers'),
11
- require('@deck.gl/geo-layers'),
12
- require('@deck.gl/mesh-layers'),
13
- require('@deck.gl/google-maps'),
14
- require('@deck.gl/json')
15
- );
16
-
17
- module.exports = deck;
5
+ export * from '../../core/bundle';
6
+ export * from '@deck.gl/layers';
7
+ export * from '@deck.gl/aggregation-layers';
8
+ export * from '@deck.gl/geo-layers';
9
+ export * from '@deck.gl/mesh-layers';
10
+ export * from '@deck.gl/google-maps';
11
+ export * from '@deck.gl/json';
package/src/index.js CHANGED
@@ -3,42 +3,40 @@
3
3
  // See https://github.com/jupyter-widgets/widget-ts-cookiecutter/blob/master/%7B%7Bcookiecutter.github_project_name%7D%7D/src/extension.ts
4
4
  // Entry point for the Jupyter Notebook bundle containing custom Backbone model and view definitions.
5
5
 
6
+ import {MODULE_VERSION, MODULE_NAME} from './version';
7
+ // TODO - this should be placed in a separate module `@deck.gl/playground`
8
+ import {createDeck, updateDeck} from './playground/create-deck';
9
+ import {initPlayground} from './playground';
10
+ import jupyterTransport from './lib/jupyter-transport';
11
+ import JupyterTransportModel from './lib/jupyter-transport-model';
12
+ import JupyterTransportView from './lib/jupyter-transport-view';
13
+
14
+ import * as deckBundle from './deck-bundle';
15
+
6
16
  // Some static assets may be required by the custom widget javascript. The base
7
17
  // url for the notebook is not known at build time and is therefore computed dynamically.
8
18
  const dataBaseUrl = document.body && document.body.getAttribute('data-base-url');
9
19
  if (dataBaseUrl) {
20
+ // @ts-expect-error undefined global property
10
21
  window.__webpack_public_path__ = `${dataBaseUrl}nbextensions/pydeck/nb_extension`;
11
22
  }
12
23
 
13
24
  // Initialize the transport
14
- const {jupyterTransport} = require('./lib/jupyter-transport').default;
15
-
16
- let JupyterTransportModel = null;
17
- let JupyterTransportView = null;
18
- try {
19
- JupyterTransportModel = require('./lib/jupyter-transport-model').default;
20
- JupyterTransportView = require('./lib/jupyter-transport-view').default;
21
- } catch (err) {
22
- // Note: Happens in the to_html() case
23
- }
24
-
25
- const {MODULE_VERSION, MODULE_NAME} = require('./version');
26
25
 
27
- // TODO - this should be placed in a separate module `@deck.gl/playground`
28
- const {createDeck, updateDeck} = require('./playground/create-deck');
29
- const {initPlayground} = require('./playground');
30
26
  initPlayground();
31
27
 
32
- module.exports = {
28
+ // Expose deck
29
+ globalThis.deck = globalThis.deck || {};
30
+ Object.assign(globalThis.deck, deckBundle);
31
+
32
+ export {
33
33
  // Transports
34
34
  jupyterTransport,
35
-
36
35
  // Jupyter Hooks
37
36
  MODULE_VERSION,
38
37
  MODULE_NAME,
39
38
  JupyterTransportModel,
40
39
  JupyterTransportView,
41
-
42
40
  // For to_html()...
43
41
  initPlayground,
44
42
  // TODO - use playground?
@@ -1,56 +1,65 @@
1
- import {DOMWidgetModel} from '@jupyter-widgets/base';
1
+ import * as widgets from '@jupyter-widgets/base';
2
2
  import {MODULE_NAME, MODULE_VERSION} from '../version';
3
3
  import {deserializeMatrix} from './utils/deserialize-matrix';
4
- /**
5
- *
6
- * Note: Variables shared explictly between Python and JavaScript use snake_case
7
- */
8
- export default class JupyterTransportModel extends DOMWidgetModel {
9
- defaults() {
10
- return {
11
- ...super.defaults(),
12
- _model_name: JupyterTransportModel.model_name,
13
- _model_module: JupyterTransportModel.model_module,
14
- _model_module_version: JupyterTransportModel.model_module_version,
15
- _view_name: JupyterTransportModel.view_name,
16
- _view_module: JupyterTransportModel.view_module,
17
- _view_module_version: JupyterTransportModel.view_module_version,
18
- custom_libraries: [],
19
- json_input: null,
20
- mapbox_key: null,
21
- selected_data: [],
22
- data_buffer: null,
23
- tooltip: null,
24
- width: '100%',
25
- height: 500,
26
- js_warning: false
27
- };
28
- }
29
4
 
30
- static get serializers() {
31
- return {
32
- ...DOMWidgetModel.serializers,
33
- // Add any extra serializers here
34
- data_buffer: {deserialize: deserializeMatrix}
35
- };
36
- }
5
+ let JupyterTransportModel = null;
6
+ const DOMWidgetModel = widgets && widgets.DOMWidgetModel;
37
7
 
38
- static get model_name() {
39
- return 'JupyterTransportModel';
40
- }
41
- static get model_module() {
42
- return MODULE_NAME;
43
- }
44
- static get model_module_version() {
45
- return MODULE_VERSION;
46
- }
47
- static get view_name() {
48
- return 'JupyterTransportView';
49
- }
50
- static get view_module() {
51
- return MODULE_NAME;
52
- }
53
- static get view_module_version() {
54
- return MODULE_VERSION;
8
+ if (DOMWidgetModel) {
9
+ /**
10
+ *
11
+ * Note: Variables shared explictly between Python and JavaScript use snake_case
12
+ */
13
+ class Model extends DOMWidgetModel {
14
+ defaults() {
15
+ return {
16
+ ...super.defaults(),
17
+ _model_name: JupyterTransportModel.model_name,
18
+ _model_module: JupyterTransportModel.model_module,
19
+ _model_module_version: JupyterTransportModel.model_module_version,
20
+ _view_name: JupyterTransportModel.view_name,
21
+ _view_module: JupyterTransportModel.view_module,
22
+ _view_module_version: JupyterTransportModel.view_module_version,
23
+ custom_libraries: [],
24
+ json_input: null,
25
+ mapbox_key: null,
26
+ selected_data: [],
27
+ data_buffer: null,
28
+ tooltip: null,
29
+ width: '100%',
30
+ height: 500,
31
+ js_warning: false
32
+ };
33
+ }
34
+
35
+ static get serializers() {
36
+ return {
37
+ ...DOMWidgetModel.serializers,
38
+ // Add any extra serializers here
39
+ data_buffer: {deserialize: deserializeMatrix}
40
+ };
41
+ }
42
+
43
+ static get model_name() {
44
+ return 'JupyterTransportModel';
45
+ }
46
+ static get model_module() {
47
+ return MODULE_NAME;
48
+ }
49
+ static get model_module_version() {
50
+ return MODULE_VERSION;
51
+ }
52
+ static get view_name() {
53
+ return 'JupyterTransportView';
54
+ }
55
+ static get view_module() {
56
+ return MODULE_NAME;
57
+ }
58
+ static get view_module_version() {
59
+ return MODULE_VERSION;
60
+ }
55
61
  }
62
+ JupyterTransportModel = Model;
56
63
  }
64
+
65
+ export default JupyterTransportModel;
@@ -1,56 +1,64 @@
1
- import {DOMWidgetView} from '@jupyter-widgets/base';
1
+ import * as widgets from '@jupyter-widgets/base';
2
2
  import JupyterTransport from './jupyter-transport';
3
3
 
4
- export default class JupyterTransportView extends DOMWidgetView {
5
- initialize() {
6
- this.listenTo(this.model, 'destroy', this.remove);
4
+ let JupyterTransportView = null;
5
+ const DOMWidgetView = widgets && widgets.DOMWidgetView;
7
6
 
8
- // TODO - is there any variable information on the model we can use to
9
- // give an interesting name or id to this instance?
10
- this.transport = new JupyterTransport();
7
+ if (DOMWidgetView) {
8
+ class View extends DOMWidgetView {
9
+ initialize() {
10
+ this.listenTo(this.model, 'destroy', this.remove);
11
11
 
12
- // Expose Jupyter internals to enable work-arounds
13
- this.transport.jupyterModel = this.model;
14
- this.transport.jupyterView = this;
15
- this.transport._initialize();
16
- super.initialize.apply(this, arguments);
17
- }
12
+ // TODO - is there any variable information on the model we can use to
13
+ // give an interesting name or id to this instance?
14
+ this.transport = new JupyterTransport();
18
15
 
19
- remove() {
20
- if (this.transport) {
21
- this.transport._finalize();
22
- this.transport.jupyterModel = null;
23
- this.transport.jupyterView = null;
24
- this.transport = null;
16
+ // Expose Jupyter internals to enable work-arounds
17
+ this.transport.jupyterModel = this.model;
18
+ this.transport.jupyterView = this;
19
+ this.transport._initialize();
20
+ super.initialize.apply(this, arguments);
25
21
  }
26
- }
27
22
 
28
- render() {
29
- super.render();
23
+ remove() {
24
+ if (this.transport) {
25
+ this.transport._finalize();
26
+ this.transport.jupyterModel = null;
27
+ this.transport.jupyterView = null;
28
+ this.transport = null;
29
+ }
30
+ }
30
31
 
31
- this.model.on('change:json_input', this.onJsonChanged.bind(this));
32
- this.model.on('change:data_buffer', this.onDataBufferChanged.bind(this));
32
+ render() {
33
+ super.render();
33
34
 
34
- this.onDataBufferChanged();
35
- }
35
+ this.model.on('change:json_input', this.onJsonChanged.bind(this));
36
+ this.model.on('change:data_buffer', this.onDataBufferChanged.bind(this));
36
37
 
37
- onJsonChanged() {
38
- const json = JSON.parse(this.model.get('json_input'));
39
- this.transport._messageReceived({type: 'json', json});
40
- }
38
+ this.onDataBufferChanged();
39
+ }
41
40
 
42
- onDataBufferChanged() {
43
- const json = this.model.get('json_input');
44
- const dataBuffer = this.model.get('data_buffer');
45
-
46
- if (json && dataBuffer) {
47
- this.transport._messageReceived({
48
- type: 'json-with-binary',
49
- json,
50
- binary: dataBuffer
51
- });
52
- } else {
41
+ onJsonChanged() {
42
+ const json = JSON.parse(this.model.get('json_input'));
53
43
  this.transport._messageReceived({type: 'json', json});
54
44
  }
45
+
46
+ onDataBufferChanged() {
47
+ const json = this.model.get('json_input');
48
+ const dataBuffer = this.model.get('data_buffer');
49
+
50
+ if (json && dataBuffer) {
51
+ this.transport._messageReceived({
52
+ type: 'json-with-binary',
53
+ json,
54
+ binary: dataBuffer
55
+ });
56
+ } else {
57
+ this.transport._messageReceived({type: 'json', json});
58
+ }
59
+ }
55
60
  }
61
+ JupyterTransportView = View;
56
62
  }
63
+
64
+ export default JupyterTransportView;
@@ -13,10 +13,11 @@ import {createGoogleMapsDeckOverlay} from './utils/google-maps-utils';
13
13
 
14
14
  import {addSupportComponents} from '../lib/components/index';
15
15
 
16
+ /* eslint-disable import/namespace */
16
17
  import * as deck from '../deck-bundle';
17
18
 
18
19
  const classesFilter = x => x.charAt(0) === x.charAt(0).toUpperCase();
19
- const functionsFilter = x => x.charAt(0) === x.charAt(0).toLowerCase() && x.charAt(0) != '_';
20
+ const functionsFilter = x => x.charAt(0) === x.charAt(0).toLowerCase() && x.charAt(0) !== '_';
20
21
 
21
22
  function extractElements(library = {}, filter) {
22
23
  // Extracts exported elements as a dictionary from a library
@@ -83,6 +83,7 @@ export function processDataBuffer({binary, convertedJson}) {
83
83
 
84
84
  // Filters circular references on JSON string conversion
85
85
  function filterJsonValue(key, value) {
86
+ // eslint-disable-next-line
86
87
  return value instanceof deckBundle.Layer ? value.id : value;
87
88
  }
88
89
 
@@ -1,4 +1,5 @@
1
1
  /* global window */
2
+ /* eslint-disable import/namespace */
2
3
  import * as deck from '../../deck-bundle';
3
4
 
4
5
  export function createGoogleMapsDeckOverlay({
@@ -1,16 +1,9 @@
1
- /* global process, document */
1
+ /* global document */
2
2
  import {loadCSS} from './css-utils';
3
3
 
4
- // SSR safe import (ensures this file can be imported under Node.js e.g. for tests)
5
- // From https://github.com/mapbox/mapbox-gl-js/issues/4593#issuecomment-546290823
6
- // eslint-disable-next-line no-undef
7
- let mapboxgl;
4
+ import mapboxgl from 'mapbox-gl';
8
5
 
9
- if (process.browser) {
10
- mapboxgl = require('mapbox-gl');
11
- }
12
-
13
- const MAPBOX_CSS_URL = 'https://api.tiles.mapbox.com/mapbox-gl-js/v1.2.1/mapbox-gl.css';
6
+ const MAPBOX_CSS_URL = 'https://api.tiles.mapbox.com/mapbox-gl-js/v1.13.2/mapbox-gl.css';
14
7
 
15
8
  export default mapboxgl;
16
9