@deck.gl/jupyter-widget 8.9.0-alpha.2 → 8.9.0-alpha.3
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/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/playground/create-deck.js +19 -10
- package/src/playground/widget-tooltip.js +30 -2
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
|
+
"version": "8.9.0-alpha.3",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"jupyter",
|
|
8
8
|
"jupyterlab",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"prepublishOnly": "webpack -p"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@deck.gl/aggregation-layers": "
|
|
33
|
-
"@deck.gl/geo-layers": "
|
|
34
|
-
"@deck.gl/google-maps": "
|
|
35
|
-
"@deck.gl/json": "
|
|
36
|
-
"@deck.gl/layers": "
|
|
37
|
-
"@deck.gl/mesh-layers": "
|
|
32
|
+
"@deck.gl/aggregation-layers": "8.9.0-alpha.3",
|
|
33
|
+
"@deck.gl/geo-layers": "8.9.0-alpha.3",
|
|
34
|
+
"@deck.gl/google-maps": "8.9.0-alpha.3",
|
|
35
|
+
"@deck.gl/json": "8.9.0-alpha.3",
|
|
36
|
+
"@deck.gl/layers": "8.9.0-alpha.3",
|
|
37
|
+
"@deck.gl/mesh-layers": "8.9.0-alpha.3",
|
|
38
38
|
"@jupyter-widgets/base": "^1.1.10 || ^2 || ^3 || ^4",
|
|
39
39
|
"@loaders.gl/3d-tiles": "^3.2.5",
|
|
40
40
|
"@loaders.gl/core": "^3.2.5",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "1a42362a310b39b5b26d46354d388e2319a90af3"
|
|
55
55
|
}
|
|
@@ -15,19 +15,22 @@ import {addSupportComponents} from '../lib/components/index';
|
|
|
15
15
|
|
|
16
16
|
import * as deck from '../deck-bundle';
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
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
|
+
|
|
21
|
+
function extractElements(library = {}, filter) {
|
|
22
|
+
// Extracts exported elements as a dictionary from a library
|
|
23
|
+
const dict = {};
|
|
24
|
+
const elements = Object.keys(library).filter(filter);
|
|
25
|
+
for (const el of elements) {
|
|
26
|
+
dict[el] = library[el];
|
|
24
27
|
}
|
|
25
|
-
return
|
|
28
|
+
return dict;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
// Handle JSONConverter and loaders configuration
|
|
29
32
|
const jsonConverterConfiguration = {
|
|
30
|
-
classes:
|
|
33
|
+
classes: extractElements(deck, classesFilter),
|
|
31
34
|
// Will be resolved as `<enum-name>.<enum-value>`
|
|
32
35
|
enumerations: {
|
|
33
36
|
COORDINATE_SYSTEM: deck.COORDINATE_SYSTEM,
|
|
@@ -43,7 +46,8 @@ const jsonConverter = new deck.JSONConverter({
|
|
|
43
46
|
|
|
44
47
|
function addModuleToConverter(module, converter) {
|
|
45
48
|
const newConfiguration = {
|
|
46
|
-
classes:
|
|
49
|
+
classes: extractElements(module, classesFilter),
|
|
50
|
+
functions: extractElements(module, functionsFilter)
|
|
47
51
|
};
|
|
48
52
|
converter.mergeConfiguration(newConfiguration);
|
|
49
53
|
}
|
|
@@ -177,10 +181,15 @@ function createDeck({
|
|
|
177
181
|
jsonInput,
|
|
178
182
|
tooltip,
|
|
179
183
|
handleEvent,
|
|
180
|
-
customLibraries
|
|
184
|
+
customLibraries,
|
|
185
|
+
configuration
|
|
181
186
|
}) {
|
|
182
187
|
let deckgl;
|
|
183
188
|
try {
|
|
189
|
+
if (configuration) {
|
|
190
|
+
jsonConverter.mergeConfiguration(configuration);
|
|
191
|
+
}
|
|
192
|
+
|
|
184
193
|
const oldLayers = jsonInput.layers || [];
|
|
185
194
|
const props = jsonConverter.convert(jsonInput);
|
|
186
195
|
|
|
@@ -111,9 +111,37 @@ export function toText(jsonValue) {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
export function substituteIn(template, json) {
|
|
114
|
+
/*
|
|
115
|
+
* Flexible substitution of templates using a json:
|
|
116
|
+
* - if the json contains the key, use [key]
|
|
117
|
+
* - if the json does not contain the key, try ['properties'][key]
|
|
118
|
+
* - if the key contains several keys separated with dots, use them all in a row:
|
|
119
|
+
* e.g. 'a.b.c' will read json['a']['b']['c']
|
|
120
|
+
*/
|
|
121
|
+
let value;
|
|
114
122
|
let output = template;
|
|
115
|
-
|
|
116
|
-
|
|
123
|
+
const propsKey = 'properties';
|
|
124
|
+
const keyPattern = /{[^}]*}/g;
|
|
125
|
+
const cleanKey = k => k.replace(/[{}]/g, '');
|
|
126
|
+
const keys = [...new Set(template.match(keyPattern).map(cleanKey))];
|
|
127
|
+
|
|
128
|
+
for (const key of keys) {
|
|
129
|
+
if (key.includes('.')) {
|
|
130
|
+
value = json;
|
|
131
|
+
const subkeys = key.split('.');
|
|
132
|
+
for (const subkey of subkeys) {
|
|
133
|
+
if (value.hasOwnProperty(subkey)) {
|
|
134
|
+
value = value[subkey];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} else if (json.hasOwnProperty(key)) {
|
|
138
|
+
value = json[key];
|
|
139
|
+
} else if (json[propsKey] && json[propsKey].hasOwnProperty(key)) {
|
|
140
|
+
value = json[propsKey][key];
|
|
141
|
+
}
|
|
142
|
+
if (value) {
|
|
143
|
+
output = output.replaceAll(`{${key}}`, value);
|
|
144
|
+
}
|
|
117
145
|
}
|
|
118
146
|
|
|
119
147
|
return output;
|