@deck.gl/widgets 9.2.0-beta.1 → 9.2.0-beta.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/compass-widget.d.ts +1 -1
- package/dist/compass-widget.d.ts.map +1 -1
- package/dist/compass-widget.js +0 -1
- package/dist/compass-widget.js.map +1 -1
- package/dist/context-menu-widget.d.ts +2 -2
- package/dist/context-menu-widget.d.ts.map +1 -1
- package/dist/context-menu-widget.js +5 -1
- package/dist/context-menu-widget.js.map +1 -1
- package/dist/dist.dev.js +968 -902
- package/dist/fps-widget.d.ts +5 -6
- package/dist/fps-widget.d.ts.map +1 -1
- package/dist/fps-widget.js +13 -14
- package/dist/fps-widget.js.map +1 -1
- package/dist/fullscreen-widget.d.ts +2 -0
- package/dist/fullscreen-widget.d.ts.map +1 -1
- package/dist/fullscreen-widget.js +7 -3
- package/dist/fullscreen-widget.js.map +1 -1
- package/dist/geocoder-widget.d.ts +4 -3
- package/dist/geocoder-widget.d.ts.map +1 -1
- package/dist/geocoder-widget.js +5 -6
- package/dist/geocoder-widget.js.map +1 -1
- package/dist/gimbal-widget.d.ts +7 -5
- package/dist/gimbal-widget.d.ts.map +1 -1
- package/dist/gimbal-widget.js +15 -10
- package/dist/gimbal-widget.js.map +1 -1
- package/dist/index.cjs +687 -670
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/dist/info-widget.d.ts +9 -9
- package/dist/info-widget.d.ts.map +1 -1
- package/dist/info-widget.js +7 -9
- package/dist/info-widget.js.map +1 -1
- package/dist/lib/components/button-group.d.ts +1 -1
- package/dist/lib/components/button-group.d.ts.map +1 -1
- package/dist/lib/components/button-group.js +1 -1
- package/dist/lib/components/button-group.js.map +1 -1
- package/dist/lib/components/grouped-icon-button.d.ts +5 -3
- package/dist/lib/components/grouped-icon-button.d.ts.map +1 -1
- package/dist/lib/components/grouped-icon-button.js +3 -3
- package/dist/lib/components/grouped-icon-button.js.map +1 -1
- package/dist/lib/components/icon-button.d.ts +5 -6
- package/dist/lib/components/icon-button.d.ts.map +1 -1
- package/dist/lib/components/icon-button.js +1 -1
- package/dist/lib/components/icon-button.js.map +1 -1
- package/dist/lib/components/icon-menu.d.ts +2 -2
- package/dist/lib/components/icon-menu.d.ts.map +1 -1
- package/dist/lib/components/icon-menu.js +4 -19
- package/dist/lib/components/icon-menu.js.map +1 -1
- package/dist/lib/components/simple-menu.js +1 -1
- package/dist/lib/components/simple-menu.js.map +1 -1
- package/dist/loading-widget.d.ts +4 -2
- package/dist/loading-widget.d.ts.map +1 -1
- package/dist/loading-widget.js +5 -3
- package/dist/loading-widget.js.map +1 -1
- package/dist/reset-view-widget.d.ts +9 -11
- package/dist/reset-view-widget.d.ts.map +1 -1
- package/dist/reset-view-widget.js +5 -4
- package/dist/reset-view-widget.js.map +1 -1
- package/dist/scale-widget.d.ts +6 -3
- package/dist/scale-widget.d.ts.map +1 -1
- package/dist/scale-widget.js +3 -2
- package/dist/scale-widget.js.map +1 -1
- package/dist/screenshot-widget.d.ts +4 -2
- package/dist/screenshot-widget.d.ts.map +1 -1
- package/dist/screenshot-widget.js +3 -1
- package/dist/screenshot-widget.js.map +1 -1
- package/dist/splitter-widget.d.ts +1 -1
- package/dist/splitter-widget.d.ts.map +1 -1
- package/dist/splitter-widget.js +0 -2
- package/dist/splitter-widget.js.map +1 -1
- package/dist/stats-widget.d.ts +6 -1
- package/dist/stats-widget.d.ts.map +1 -1
- package/dist/stats-widget.js +11 -4
- package/dist/stats-widget.js.map +1 -1
- package/dist/stylesheet.css +53 -35
- package/dist/theme-widget.d.ts +3 -1
- package/dist/theme-widget.d.ts.map +1 -1
- package/dist/theme-widget.js +6 -3
- package/dist/theme-widget.js.map +1 -1
- package/dist/themes.d.ts +10 -0
- package/dist/themes.d.ts.map +1 -1
- package/dist/themes.js +12 -4
- package/dist/themes.js.map +1 -1
- package/dist/timeline-widget.d.ts +10 -32
- package/dist/timeline-widget.d.ts.map +1 -1
- package/dist/timeline-widget.js +6 -2
- package/dist/timeline-widget.js.map +1 -1
- package/dist/view-selector-widget.d.ts +2 -0
- package/dist/view-selector-widget.d.ts.map +1 -1
- package/dist/view-selector-widget.js +15 -14
- package/dist/view-selector-widget.js.map +1 -1
- package/dist/zoom-widget.d.ts +1 -2
- package/dist/zoom-widget.d.ts.map +1 -1
- package/dist/zoom-widget.js +7 -5
- package/dist/zoom-widget.js.map +1 -1
- package/dist.min.js +2 -3
- package/package.json +2 -2
- package/src/compass-widget.tsx +1 -1
- package/src/context-menu-widget.tsx +8 -3
- package/src/fps-widget.tsx +25 -16
- package/src/fullscreen-widget.tsx +9 -3
- package/src/geocoder-widget.tsx +9 -9
- package/src/gimbal-widget.tsx +16 -11
- package/src/index.ts +15 -10
- package/src/info-widget.tsx +17 -17
- package/src/lib/components/button-group.tsx +2 -2
- package/src/lib/components/grouped-icon-button.tsx +9 -6
- package/src/lib/components/icon-button.tsx +5 -6
- package/src/lib/components/icon-menu.tsx +12 -30
- package/src/lib/components/simple-menu.tsx +1 -1
- package/src/loading-widget.tsx +9 -5
- package/src/reset-view-widget.tsx +18 -16
- package/src/scale-widget.tsx +9 -5
- package/src/screenshot-widget.tsx +7 -3
- package/src/splitter-widget.tsx +1 -3
- package/src/stats-widget.tsx +18 -5
- package/src/stylesheet.css +53 -35
- package/src/theme-widget.tsx +9 -4
- package/src/themes.ts +15 -4
- package/src/timeline-widget.tsx +19 -42
- package/src/view-selector-widget.tsx +59 -16
- package/src/zoom-widget.tsx +8 -6
package/dist/index.cjs
CHANGED
|
@@ -63,15 +63,15 @@ var import_preact = require("preact");
|
|
|
63
63
|
// dist/lib/components/button-group.js
|
|
64
64
|
var import_jsx_runtime = require("preact/jsx-runtime");
|
|
65
65
|
var ButtonGroup = (props) => {
|
|
66
|
-
const { children, orientation } = props;
|
|
66
|
+
const { children, orientation = "horizontal" } = props;
|
|
67
67
|
return (0, import_jsx_runtime.jsx)("div", { className: `deck-widget-button-group ${orientation}`, children });
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
// dist/lib/components/grouped-icon-button.js
|
|
71
71
|
var import_jsx_runtime2 = require("preact/jsx-runtime");
|
|
72
72
|
var GroupedIconButton = (props) => {
|
|
73
|
-
const { className, label, onClick } = props;
|
|
74
|
-
return (0, import_jsx_runtime2.jsx)("button", { className: `deck-widget-icon-button ${className
|
|
73
|
+
const { className = "", label, onClick, children } = props;
|
|
74
|
+
return (0, import_jsx_runtime2.jsx)("button", { className: `deck-widget-icon-button ${className}`, type: "button", onClick, title: label, children: children ? children : (0, import_jsx_runtime2.jsx)("div", { className: "deck-widget-icon" }) });
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
// dist/zoom-widget.js
|
|
@@ -80,10 +80,8 @@ var ZoomWidget = class extends import_core.Widget {
|
|
|
80
80
|
super(props, ZoomWidget.defaultProps);
|
|
81
81
|
this.className = "deck-widget-zoom";
|
|
82
82
|
this.placement = "top-left";
|
|
83
|
-
this.viewId = null;
|
|
84
83
|
this.viewports = {};
|
|
85
|
-
this.
|
|
86
|
-
this.placement = props.placement ?? this.placement;
|
|
84
|
+
this.setProps(this.props);
|
|
87
85
|
}
|
|
88
86
|
setProps(props) {
|
|
89
87
|
this.placement = props.placement ?? this.placement;
|
|
@@ -105,7 +103,9 @@ var ZoomWidget = class extends import_core.Widget {
|
|
|
105
103
|
};
|
|
106
104
|
if (this.props.transitionDuration > 0) {
|
|
107
105
|
nextViewState.transitionDuration = this.props.transitionDuration;
|
|
108
|
-
nextViewState.transitionInterpolator = "latitude" in nextViewState ? new import_core.FlyToInterpolator() : new import_core.LinearInterpolator(
|
|
106
|
+
nextViewState.transitionInterpolator = "latitude" in nextViewState ? new import_core.FlyToInterpolator() : new import_core.LinearInterpolator({
|
|
107
|
+
transitionProps: ["zoom"]
|
|
108
|
+
});
|
|
109
109
|
}
|
|
110
110
|
this.setViewState(viewId, nextViewState);
|
|
111
111
|
}
|
|
@@ -132,7 +132,7 @@ ZoomWidget.defaultProps = {
|
|
|
132
132
|
transitionDuration: 200,
|
|
133
133
|
zoomInLabel: "Zoom In",
|
|
134
134
|
zoomOutLabel: "Zoom Out",
|
|
135
|
-
viewId:
|
|
135
|
+
viewId: null
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
// dist/reset-view-widget.js
|
|
@@ -143,7 +143,7 @@ var import_core2 = require("@deck.gl/core");
|
|
|
143
143
|
// dist/lib/components/icon-button.js
|
|
144
144
|
var import_jsx_runtime4 = require("preact/jsx-runtime");
|
|
145
145
|
var IconButton = (props) => {
|
|
146
|
-
const { className, label, onClick, children } = props;
|
|
146
|
+
const { className = "", label, onClick, children } = props;
|
|
147
147
|
return (0, import_jsx_runtime4.jsx)("div", { className: "deck-widget-button", children: (0, import_jsx_runtime4.jsx)("button", { className: `deck-widget-icon-button ${className}`, type: "button", onClick, title: label, children: children ? children : (0, import_jsx_runtime4.jsx)("div", { className: "deck-widget-icon" }) }) });
|
|
148
148
|
};
|
|
149
149
|
|
|
@@ -153,10 +153,11 @@ var ResetViewWidget = class extends import_core2.Widget {
|
|
|
153
153
|
super(props, ResetViewWidget.defaultProps);
|
|
154
154
|
this.className = "deck-widget-reset-view";
|
|
155
155
|
this.placement = "top-left";
|
|
156
|
-
this.
|
|
156
|
+
this.setProps(this.props);
|
|
157
157
|
}
|
|
158
158
|
setProps(props) {
|
|
159
159
|
this.placement = props.placement ?? this.placement;
|
|
160
|
+
this.viewId = props.viewId ?? this.viewId;
|
|
160
161
|
super.setProps(props);
|
|
161
162
|
}
|
|
162
163
|
onRenderHTML(rootElement) {
|
|
@@ -168,9 +169,9 @@ var ResetViewWidget = class extends import_core2.Widget {
|
|
|
168
169
|
this.setViewState(initialViewState);
|
|
169
170
|
}
|
|
170
171
|
setViewState(viewState) {
|
|
171
|
-
const viewId = this.props.viewId ||
|
|
172
|
+
const viewId = this.props.viewId || "default-view";
|
|
172
173
|
const nextViewState = {
|
|
173
|
-
...viewState
|
|
174
|
+
...viewId !== "default-view" ? viewState == null ? void 0 : viewState[viewId] : viewState
|
|
174
175
|
// only works for geospatial?
|
|
175
176
|
// transitionDuration: this.props.transitionDuration,
|
|
176
177
|
// transitionInterpolator: new FlyToInterpolator()
|
|
@@ -184,19 +185,18 @@ ResetViewWidget.defaultProps = {
|
|
|
184
185
|
placement: "top-left",
|
|
185
186
|
label: "Reset View",
|
|
186
187
|
initialViewState: void 0,
|
|
187
|
-
viewId:
|
|
188
|
+
viewId: null
|
|
188
189
|
};
|
|
189
190
|
|
|
190
|
-
// dist/
|
|
191
|
+
// dist/gimbal-widget.js
|
|
191
192
|
var import_jsx_runtime6 = require("preact/jsx-runtime");
|
|
192
193
|
var import_core3 = require("@deck.gl/core");
|
|
193
194
|
var import_preact3 = require("preact");
|
|
194
|
-
var
|
|
195
|
+
var GimbalWidget = class extends import_core3.Widget {
|
|
195
196
|
constructor(props = {}) {
|
|
196
|
-
super(props,
|
|
197
|
-
this.className = "deck-widget-
|
|
197
|
+
super(props, GimbalWidget.defaultProps);
|
|
198
|
+
this.className = "deck-widget-gimbal";
|
|
198
199
|
this.placement = "top-left";
|
|
199
|
-
this.viewId = null;
|
|
200
200
|
this.viewports = {};
|
|
201
201
|
this.setProps(this.props);
|
|
202
202
|
}
|
|
@@ -209,90 +209,30 @@ var CompassWidget = class extends import_core3.Widget {
|
|
|
209
209
|
var _a;
|
|
210
210
|
const viewId = this.viewId || ((_a = Object.values(this.viewports)[0]) == null ? void 0 : _a.id) || "default-view";
|
|
211
211
|
const widgetViewport = this.viewports[viewId];
|
|
212
|
-
const
|
|
213
|
-
const ui = (0, import_jsx_runtime6.jsx)("div", { className: "deck-widget-button", style: { perspective: 100 }, children: (0, import_jsx_runtime6.
|
|
212
|
+
const { rotationOrbit, rotationX } = this.getNormalizedRotation(widgetViewport);
|
|
213
|
+
const ui = (0, import_jsx_runtime6.jsx)("div", { className: "deck-widget-button", style: { perspective: 100, pointerEvents: "auto" }, children: (0, import_jsx_runtime6.jsxs)("button", { type: "button", onClick: () => {
|
|
214
214
|
for (const viewport of Object.values(this.viewports)) {
|
|
215
|
-
this.
|
|
215
|
+
this.resetOrbitView(viewport);
|
|
216
216
|
}
|
|
217
|
-
}, title: this.props.label, style: {
|
|
218
|
-
(0, import_preact3.render)(ui, rootElement);
|
|
219
|
-
}
|
|
220
|
-
onViewportChange(viewport) {
|
|
221
|
-
if (!viewport.equals(this.viewports[viewport.id])) {
|
|
222
|
-
this.viewports[viewport.id] = viewport;
|
|
223
|
-
this.updateHTML();
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
getRotation(viewport) {
|
|
227
|
-
if (viewport instanceof import_core3.WebMercatorViewport) {
|
|
228
|
-
return [-viewport.bearing, viewport.pitch];
|
|
229
|
-
} else if (viewport instanceof import_core3._GlobeViewport) {
|
|
230
|
-
return [0, Math.max(-80, Math.min(80, viewport.latitude))];
|
|
231
|
-
}
|
|
232
|
-
return [0, 0];
|
|
233
|
-
}
|
|
234
|
-
handleCompassReset(viewport) {
|
|
235
|
-
const viewId = this.viewId || viewport.id || "default-view";
|
|
236
|
-
if (viewport instanceof import_core3.WebMercatorViewport) {
|
|
237
|
-
const nextViewState = {
|
|
238
|
-
...viewport,
|
|
239
|
-
bearing: 0,
|
|
240
|
-
...this.getRotation(viewport)[0] === 0 ? { pitch: 0 } : {},
|
|
241
|
-
transitionDuration: this.props.transitionDuration,
|
|
242
|
-
transitionInterpolator: new import_core3.FlyToInterpolator()
|
|
243
|
-
};
|
|
244
|
-
this.deck._onViewStateChange({ viewId, viewState: nextViewState, interactionState: {} });
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
CompassWidget.defaultProps = {
|
|
249
|
-
...import_core3.Widget.defaultProps,
|
|
250
|
-
id: "compass",
|
|
251
|
-
placement: "top-left",
|
|
252
|
-
viewId: null,
|
|
253
|
-
label: "Reset Compass",
|
|
254
|
-
transitionDuration: 200
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
// dist/gimbal-widget.js
|
|
258
|
-
var import_jsx_runtime7 = require("preact/jsx-runtime");
|
|
259
|
-
var import_core4 = require("@deck.gl/core");
|
|
260
|
-
var import_preact4 = require("preact");
|
|
261
|
-
var GimbalWidget = class extends import_core4.Widget {
|
|
262
|
-
constructor(props = {}) {
|
|
263
|
-
super(props, GimbalWidget.defaultProps);
|
|
264
|
-
this.className = "deck-widget-gimbal";
|
|
265
|
-
this.placement = "top-left";
|
|
266
|
-
this.viewId = null;
|
|
267
|
-
this.setProps(this.props);
|
|
268
|
-
}
|
|
269
|
-
setProps(props) {
|
|
270
|
-
this.placement = props.placement ?? this.placement;
|
|
271
|
-
this.viewId = props.viewId ?? this.viewId;
|
|
272
|
-
super.setProps(props);
|
|
273
|
-
}
|
|
274
|
-
onRenderHTML(rootElement) {
|
|
275
|
-
const { rotationOrbit, rotationX } = this.getNormalizedRotation();
|
|
276
|
-
const ui = (0, import_jsx_runtime7.jsx)("div", { className: "deck-widget-button", style: { perspective: 100, pointerEvents: "auto" }, children: (0, import_jsx_runtime7.jsxs)("button", { type: "button", onClick: () => {
|
|
277
|
-
this.resetOrbitView();
|
|
278
|
-
}, title: this.props.label, style: { position: "relative", width: 26, height: 26 }, children: [(0, import_jsx_runtime7.jsx)("svg", { className: "gimbal-outer-ring", width: "100%", height: "100%", viewBox: "0 0 26 26", style: {
|
|
217
|
+
}, title: this.props.label, style: { position: "relative", width: 26, height: 26 }, children: [(0, import_jsx_runtime6.jsx)("svg", { className: "gimbal-outer-ring", width: "100%", height: "100%", viewBox: "0 0 26 26", style: {
|
|
279
218
|
position: "absolute",
|
|
280
219
|
top: 0,
|
|
281
220
|
left: 0,
|
|
282
221
|
transform: `rotateY(${rotationOrbit}deg)`
|
|
283
|
-
}, children: (0,
|
|
222
|
+
}, children: (0, import_jsx_runtime6.jsx)("circle", { cx: "13", cy: "13", r: "10", stroke: "var(--icon-gimbal-outer-color, rgb(68, 92, 204))", strokeWidth: this.props.strokeWidth, fill: "none" }) }), (0, import_jsx_runtime6.jsx)("svg", { className: "gimbal-inner-ring", width: "100%", height: "100%", viewBox: "0 0 26 26", style: {
|
|
284
223
|
position: "absolute",
|
|
285
224
|
top: 0,
|
|
286
225
|
left: 0,
|
|
287
226
|
transform: `rotateX(${rotationX}deg)`
|
|
288
|
-
}, children: (0,
|
|
289
|
-
(0,
|
|
227
|
+
}, children: (0, import_jsx_runtime6.jsx)("circle", { cx: "13", cy: "13", r: "7", stroke: "var(--icon-gimbal-inner-color, rgb(240, 92, 68))", strokeWidth: this.props.strokeWidth, fill: "none" }) })] }) });
|
|
228
|
+
(0, import_preact3.render)(ui, rootElement);
|
|
290
229
|
}
|
|
291
230
|
onViewportChange(viewport) {
|
|
231
|
+
this.viewports[viewport.id] = viewport;
|
|
292
232
|
this.updateHTML();
|
|
293
233
|
}
|
|
294
|
-
resetOrbitView() {
|
|
295
|
-
const viewId = this.getViewId();
|
|
234
|
+
resetOrbitView(viewport) {
|
|
235
|
+
const viewId = this.getViewId(viewport);
|
|
296
236
|
const viewState = this.getViewState(viewId);
|
|
297
237
|
if ("rotationOrbit" in viewState || "rotationX" in viewState) {
|
|
298
238
|
const nextViewState = {
|
|
@@ -300,15 +240,15 @@ var GimbalWidget = class extends import_core4.Widget {
|
|
|
300
240
|
rotationOrbit: 0,
|
|
301
241
|
rotationX: 0,
|
|
302
242
|
transitionDuration: this.props.transitionDuration,
|
|
303
|
-
transitionInterpolator: new
|
|
243
|
+
transitionInterpolator: new import_core3.LinearInterpolator({
|
|
304
244
|
transitionProps: ["rotationOrbit", "rotationX"]
|
|
305
245
|
})
|
|
306
246
|
};
|
|
307
247
|
this.deck._onViewStateChange({ viewId, viewState: nextViewState, interactionState: {} });
|
|
308
248
|
}
|
|
309
249
|
}
|
|
310
|
-
getNormalizedRotation() {
|
|
311
|
-
const viewState = this.getViewState(this.getViewId());
|
|
250
|
+
getNormalizedRotation(viewport) {
|
|
251
|
+
const viewState = this.getViewState(this.getViewId(viewport));
|
|
312
252
|
const [rz, rx] = this.getRotation(viewState);
|
|
313
253
|
const rotationOrbit = normalizeAndClampAngle(rz);
|
|
314
254
|
const rotationX = normalizeAndClampAngle(rx);
|
|
@@ -321,8 +261,8 @@ var GimbalWidget = class extends import_core4.Widget {
|
|
|
321
261
|
return [0, 0];
|
|
322
262
|
}
|
|
323
263
|
// Move to Widget/WidgetManager?
|
|
324
|
-
getViewId() {
|
|
325
|
-
const viewId = this.viewId || "OrbitView";
|
|
264
|
+
getViewId(viewport) {
|
|
265
|
+
const viewId = this.viewId || (viewport == null ? void 0 : viewport.id) || "OrbitView";
|
|
326
266
|
return viewId;
|
|
327
267
|
}
|
|
328
268
|
getViewState(viewId) {
|
|
@@ -340,10 +280,10 @@ var GimbalWidget = class extends import_core4.Widget {
|
|
|
340
280
|
}
|
|
341
281
|
};
|
|
342
282
|
GimbalWidget.defaultProps = {
|
|
343
|
-
...
|
|
283
|
+
...import_core3.Widget.defaultProps,
|
|
344
284
|
id: "gimbal",
|
|
345
285
|
placement: "top-left",
|
|
346
|
-
viewId:
|
|
286
|
+
viewId: null,
|
|
347
287
|
label: "Gimbal",
|
|
348
288
|
strokeWidth: 1.5,
|
|
349
289
|
transitionDuration: 200
|
|
@@ -362,6 +302,72 @@ function normalizeAndClampAngle(angle) {
|
|
|
362
302
|
return normalized;
|
|
363
303
|
}
|
|
364
304
|
|
|
305
|
+
// dist/compass-widget.js
|
|
306
|
+
var import_jsx_runtime7 = require("preact/jsx-runtime");
|
|
307
|
+
var import_core4 = require("@deck.gl/core");
|
|
308
|
+
var import_preact4 = require("preact");
|
|
309
|
+
var CompassWidget = class extends import_core4.Widget {
|
|
310
|
+
constructor(props = {}) {
|
|
311
|
+
super(props, CompassWidget.defaultProps);
|
|
312
|
+
this.className = "deck-widget-compass";
|
|
313
|
+
this.placement = "top-left";
|
|
314
|
+
this.viewports = {};
|
|
315
|
+
this.setProps(this.props);
|
|
316
|
+
}
|
|
317
|
+
setProps(props) {
|
|
318
|
+
this.placement = props.placement ?? this.placement;
|
|
319
|
+
this.viewId = props.viewId ?? this.viewId;
|
|
320
|
+
super.setProps(props);
|
|
321
|
+
}
|
|
322
|
+
onRenderHTML(rootElement) {
|
|
323
|
+
var _a;
|
|
324
|
+
const viewId = this.viewId || ((_a = Object.values(this.viewports)[0]) == null ? void 0 : _a.id) || "default-view";
|
|
325
|
+
const widgetViewport = this.viewports[viewId];
|
|
326
|
+
const [rz, rx] = this.getRotation(widgetViewport);
|
|
327
|
+
const ui = (0, import_jsx_runtime7.jsx)("div", { className: "deck-widget-button", style: { perspective: 100 }, children: (0, import_jsx_runtime7.jsx)("button", { type: "button", onClick: () => {
|
|
328
|
+
for (const viewport of Object.values(this.viewports)) {
|
|
329
|
+
this.handleCompassReset(viewport);
|
|
330
|
+
}
|
|
331
|
+
}, title: this.props.label, style: { transform: `rotateX(${rx}deg)` }, children: (0, import_jsx_runtime7.jsx)("svg", { fill: "none", width: "100%", height: "100%", viewBox: "0 0 26 26", children: (0, import_jsx_runtime7.jsxs)("g", { transform: `rotate(${rz},13,13)`, children: [(0, import_jsx_runtime7.jsx)("path", { d: "M10 13.0001L12.9999 5L15.9997 13.0001H10Z", fill: "var(--icon-compass-north-color, rgb(240, 92, 68))" }), (0, import_jsx_runtime7.jsx)("path", { d: "M16.0002 12.9999L13.0004 21L10.0005 12.9999H16.0002Z", fill: "var(--icon-compass-south-color, rgb(204, 204, 204))" })] }) }) }) });
|
|
332
|
+
(0, import_preact4.render)(ui, rootElement);
|
|
333
|
+
}
|
|
334
|
+
onViewportChange(viewport) {
|
|
335
|
+
if (!viewport.equals(this.viewports[viewport.id])) {
|
|
336
|
+
this.viewports[viewport.id] = viewport;
|
|
337
|
+
this.updateHTML();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
getRotation(viewport) {
|
|
341
|
+
if (viewport instanceof import_core4.WebMercatorViewport) {
|
|
342
|
+
return [-viewport.bearing, viewport.pitch];
|
|
343
|
+
} else if (viewport instanceof import_core4._GlobeViewport) {
|
|
344
|
+
return [0, Math.max(-80, Math.min(80, viewport.latitude))];
|
|
345
|
+
}
|
|
346
|
+
return [0, 0];
|
|
347
|
+
}
|
|
348
|
+
handleCompassReset(viewport) {
|
|
349
|
+
const viewId = this.viewId || viewport.id || "default-view";
|
|
350
|
+
if (viewport instanceof import_core4.WebMercatorViewport) {
|
|
351
|
+
const nextViewState = {
|
|
352
|
+
...viewport,
|
|
353
|
+
bearing: 0,
|
|
354
|
+
...this.getRotation(viewport)[0] === 0 ? { pitch: 0 } : {},
|
|
355
|
+
transitionDuration: this.props.transitionDuration,
|
|
356
|
+
transitionInterpolator: new import_core4.FlyToInterpolator()
|
|
357
|
+
};
|
|
358
|
+
this.deck._onViewStateChange({ viewId, viewState: nextViewState, interactionState: {} });
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
CompassWidget.defaultProps = {
|
|
363
|
+
...import_core4.Widget.defaultProps,
|
|
364
|
+
id: "compass",
|
|
365
|
+
placement: "top-left",
|
|
366
|
+
viewId: null,
|
|
367
|
+
label: "Reset Compass",
|
|
368
|
+
transitionDuration: 200
|
|
369
|
+
};
|
|
370
|
+
|
|
365
371
|
// dist/scale-widget.js
|
|
366
372
|
var import_jsx_runtime8 = require("preact/jsx-runtime");
|
|
367
373
|
var import_preact5 = require("preact");
|
|
@@ -374,10 +380,11 @@ var ScaleWidget = class extends import_core5.Widget {
|
|
|
374
380
|
this.scaleWidth = 10;
|
|
375
381
|
this.scaleValue = 0;
|
|
376
382
|
this.scaleText = "";
|
|
377
|
-
this.
|
|
383
|
+
this.setProps(this.props);
|
|
378
384
|
}
|
|
379
385
|
setProps(props) {
|
|
380
386
|
this.placement = props.placement ?? this.placement;
|
|
387
|
+
this.viewId = props.viewId ?? this.viewId;
|
|
381
388
|
super.setProps(props);
|
|
382
389
|
}
|
|
383
390
|
onRenderHTML(rootElement) {
|
|
@@ -409,7 +416,7 @@ ScaleWidget.defaultProps = {
|
|
|
409
416
|
id: "scale",
|
|
410
417
|
placement: "bottom-left",
|
|
411
418
|
label: "Scale",
|
|
412
|
-
|
|
419
|
+
viewId: null
|
|
413
420
|
};
|
|
414
421
|
function getMetersPerPixel(latitude, zoom) {
|
|
415
422
|
const earthCircumference = 40075016686e-3;
|
|
@@ -730,17 +737,16 @@ var GeocoderWidget = class extends import_core6.Widget {
|
|
|
730
737
|
}
|
|
731
738
|
};
|
|
732
739
|
this.viewports = {};
|
|
733
|
-
this.placement = this.props.placement ?? this.placement;
|
|
734
740
|
this.setProps(this.props);
|
|
735
|
-
this.geocoder = getGeocoder(this.props);
|
|
736
741
|
}
|
|
737
742
|
setProps(props) {
|
|
738
|
-
super.setProps(props);
|
|
739
743
|
this.placement = props.placement ?? this.placement;
|
|
744
|
+
this.viewId = props.viewId ?? this.viewId;
|
|
740
745
|
this.geocoder = getGeocoder(this.props);
|
|
741
746
|
if (this.geocoder.requiresApiKey && !this.props.apiKey) {
|
|
742
747
|
throw new Error(`API key is required for the ${this.geocoder.name} geocoder`);
|
|
743
748
|
}
|
|
749
|
+
super.setProps(props);
|
|
744
750
|
}
|
|
745
751
|
onRenderHTML(rootElement) {
|
|
746
752
|
const menuItems = this.props._geolocation ? [CURRENT_LOCATION2, ...this.geocodeHistory.addressHistory] : [...this.geocodeHistory.addressHistory];
|
|
@@ -793,10 +799,10 @@ var GeocoderWidget = class extends import_core6.Widget {
|
|
|
793
799
|
};
|
|
794
800
|
GeocoderWidget.defaultProps = {
|
|
795
801
|
...import_core6.Widget.defaultProps,
|
|
796
|
-
id: "
|
|
797
|
-
viewId:
|
|
802
|
+
id: "geocoder",
|
|
803
|
+
viewId: null,
|
|
798
804
|
placement: "top-left",
|
|
799
|
-
label: "
|
|
805
|
+
label: "Geocoder",
|
|
800
806
|
transitionDuration: 200,
|
|
801
807
|
geocoder: "coordinates",
|
|
802
808
|
customGeocoder: CoordinatesGeocoder,
|
|
@@ -833,7 +839,7 @@ var FullscreenWidget = class extends import_core8.Widget {
|
|
|
833
839
|
this.className = "deck-widget-fullscreen";
|
|
834
840
|
this.placement = "top-left";
|
|
835
841
|
this.fullscreen = false;
|
|
836
|
-
this.
|
|
842
|
+
this.setProps(this.props);
|
|
837
843
|
}
|
|
838
844
|
onAdd() {
|
|
839
845
|
document.addEventListener("fullscreenchange", this.onFullscreenChange.bind(this));
|
|
@@ -842,10 +848,13 @@ var FullscreenWidget = class extends import_core8.Widget {
|
|
|
842
848
|
document.removeEventListener("fullscreenchange", this.onFullscreenChange.bind(this));
|
|
843
849
|
}
|
|
844
850
|
onRenderHTML(rootElement) {
|
|
845
|
-
(0, import_preact7.render)((0, import_jsx_runtime11.jsx)(IconButton, { onClick:
|
|
851
|
+
(0, import_preact7.render)((0, import_jsx_runtime11.jsx)(IconButton, { onClick: () => {
|
|
852
|
+
this.handleClick().catch((err) => import_core8.log.error(err)());
|
|
853
|
+
}, label: this.fullscreen ? this.props.exitLabel : this.props.enterLabel, className: this.fullscreen ? "deck-widget-fullscreen-exit" : "deck-widget-fullscreen-enter" }), rootElement);
|
|
846
854
|
}
|
|
847
855
|
setProps(props) {
|
|
848
856
|
this.placement = props.placement ?? this.placement;
|
|
857
|
+
this.viewId = props.viewId ?? this.viewId;
|
|
849
858
|
super.setProps(props);
|
|
850
859
|
}
|
|
851
860
|
getContainer() {
|
|
@@ -892,298 +901,212 @@ FullscreenWidget.defaultProps = {
|
|
|
892
901
|
...import_core8.Widget.defaultProps,
|
|
893
902
|
id: "fullscreen",
|
|
894
903
|
placement: "top-left",
|
|
904
|
+
viewId: null,
|
|
895
905
|
enterLabel: "Enter Fullscreen",
|
|
896
906
|
exitLabel: "Exit Fullscreen",
|
|
897
907
|
container: void 0
|
|
898
908
|
};
|
|
899
909
|
|
|
900
|
-
// dist/
|
|
910
|
+
// dist/splitter-widget.js
|
|
901
911
|
var import_jsx_runtime12 = require("preact/jsx-runtime");
|
|
902
912
|
var import_preact8 = require("preact");
|
|
913
|
+
var import_hooks2 = require("preact/hooks");
|
|
903
914
|
var import_core9 = require("@deck.gl/core");
|
|
904
|
-
var
|
|
905
|
-
constructor(props
|
|
906
|
-
super(props,
|
|
907
|
-
this.className = "deck-widget-
|
|
908
|
-
this.placement = "
|
|
909
|
-
this.placement = props.placement ?? this.placement;
|
|
915
|
+
var SplitterWidget = class extends import_core9.Widget {
|
|
916
|
+
constructor(props) {
|
|
917
|
+
super(props, SplitterWidget.defaultProps);
|
|
918
|
+
this.className = "deck-widget-splitter";
|
|
919
|
+
this.placement = "fill";
|
|
910
920
|
}
|
|
911
921
|
setProps(props) {
|
|
912
|
-
this.placement = props.placement ?? this.placement;
|
|
913
922
|
super.setProps(props);
|
|
914
923
|
}
|
|
915
924
|
onRenderHTML(rootElement) {
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
}
|
|
923
|
-
const dataURL = this.captureScreenToDataURL(this.props.imageFormat);
|
|
924
|
-
if (dataURL) {
|
|
925
|
-
this.downloadDataURL(dataURL, this.props.filename);
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
/** @note only captures canvas contents, not HTML DOM or CSS styles */
|
|
929
|
-
captureScreenToDataURL(imageFormat) {
|
|
930
|
-
var _a;
|
|
931
|
-
const canvas = (_a = this.deck) == null ? void 0 : _a.getCanvas();
|
|
932
|
-
return canvas == null ? void 0 : canvas.toDataURL(imageFormat);
|
|
933
|
-
}
|
|
934
|
-
/** Download a data URL */
|
|
935
|
-
downloadDataURL(dataURL, filename) {
|
|
936
|
-
const link = document.createElement("a");
|
|
937
|
-
link.href = dataURL;
|
|
938
|
-
link.download = filename;
|
|
939
|
-
link.click();
|
|
925
|
+
rootElement.style.position = "absolute";
|
|
926
|
+
rootElement.style.top = "0";
|
|
927
|
+
rootElement.style.left = "0";
|
|
928
|
+
rootElement.style.width = "100%";
|
|
929
|
+
rootElement.style.height = "100%";
|
|
930
|
+
rootElement.style.margin = "0px";
|
|
931
|
+
(0, import_preact8.render)((0, import_jsx_runtime12.jsx)(Splitter, { orientation: this.props.orientation, initialSplit: this.props.initialSplit, onChange: this.props.onChange, onDragStart: this.props.onDragStart, onDragEnd: this.props.onDragEnd }), rootElement);
|
|
940
932
|
}
|
|
941
933
|
};
|
|
942
|
-
|
|
934
|
+
SplitterWidget.defaultProps = {
|
|
943
935
|
...import_core9.Widget.defaultProps,
|
|
944
|
-
id: "
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
var import_preact9 = require("preact");
|
|
955
|
-
var import_core10 = require("@deck.gl/core");
|
|
956
|
-
var LoadingWidget = class extends import_core10.Widget {
|
|
957
|
-
constructor(props = {}) {
|
|
958
|
-
super(props, LoadingWidget.defaultProps);
|
|
959
|
-
this.className = "deck-widget-loading";
|
|
960
|
-
this.placement = "top-left";
|
|
961
|
-
this.loading = true;
|
|
962
|
-
this.placement = props.placement ?? this.placement;
|
|
963
|
-
}
|
|
964
|
-
setProps(props) {
|
|
965
|
-
this.placement = props.placement ?? this.placement;
|
|
966
|
-
super.setProps(props);
|
|
967
|
-
}
|
|
968
|
-
onRenderHTML(rootElement) {
|
|
969
|
-
(0, import_preact9.render)(
|
|
970
|
-
// TODO(ibgreen) - this should not be a button, but styling is so nested that it is easier to reuse this component.
|
|
971
|
-
this.loading && (0, import_jsx_runtime13.jsx)(IconButton, { className: "deck-widget-spinner-icon", label: this.props.label, onClick: this.handleClick.bind(this) }),
|
|
972
|
-
rootElement
|
|
973
|
-
);
|
|
974
|
-
}
|
|
975
|
-
onRedraw({ layers }) {
|
|
976
|
-
const loading = !layers.some((layer) => !layer.isLoaded);
|
|
977
|
-
if (loading !== this.loading) {
|
|
978
|
-
this.loading = loading;
|
|
979
|
-
this.updateHTML();
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
// TODO(ibgreen) - this should not be a button, see above.
|
|
983
|
-
handleClick() {
|
|
936
|
+
id: "splitter-widget",
|
|
937
|
+
viewId1: "",
|
|
938
|
+
viewId2: "",
|
|
939
|
+
orientation: "vertical",
|
|
940
|
+
initialSplit: 0.5,
|
|
941
|
+
onChange: () => {
|
|
942
|
+
},
|
|
943
|
+
onDragStart: () => {
|
|
944
|
+
},
|
|
945
|
+
onDragEnd: () => {
|
|
984
946
|
}
|
|
985
947
|
};
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
}
|
|
1007
|
-
super.setProps(props);
|
|
1008
|
-
}
|
|
1009
|
-
onAdd({}) {
|
|
1010
|
-
this._lastFps = this._getFps();
|
|
1011
|
-
this.updateHTML();
|
|
1012
|
-
}
|
|
1013
|
-
onRenderHTML(rootElement) {
|
|
1014
|
-
const fps = this._getFps();
|
|
1015
|
-
rootElement.innerText = `FPS:
|
|
1016
|
-
${fps}`;
|
|
1017
|
-
rootElement.style.backgroundColor = "white";
|
|
1018
|
-
rootElement.style.fontFamily = "monospace";
|
|
1019
|
-
rootElement.style.fontSize = "8px";
|
|
1020
|
-
rootElement.style.fontWeight = "700";
|
|
1021
|
-
}
|
|
1022
|
-
onRedraw({}) {
|
|
1023
|
-
const fps = this._getFps();
|
|
1024
|
-
if (fps !== this._lastFps) {
|
|
1025
|
-
this._lastFps = fps;
|
|
1026
|
-
this.updateHTML();
|
|
948
|
+
function Splitter({ orientation, initialSplit, onChange, onDragStart, onDragEnd }) {
|
|
949
|
+
const [split, setSplit] = (0, import_hooks2.useState)(initialSplit);
|
|
950
|
+
const dragging = (0, import_hooks2.useRef)(false);
|
|
951
|
+
const containerRef = (0, import_hooks2.useRef)(null);
|
|
952
|
+
const handleDragStart = (event) => {
|
|
953
|
+
dragging.current = true;
|
|
954
|
+
onDragStart == null ? void 0 : onDragStart();
|
|
955
|
+
document.addEventListener("mousemove", handleDragging);
|
|
956
|
+
document.addEventListener("mouseup", handleDragEnd);
|
|
957
|
+
event.preventDefault();
|
|
958
|
+
};
|
|
959
|
+
const handleDragging = (event) => {
|
|
960
|
+
if (!dragging.current || !containerRef.current)
|
|
961
|
+
return;
|
|
962
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
963
|
+
let newSplit;
|
|
964
|
+
if (orientation === "vertical") {
|
|
965
|
+
newSplit = (event.clientX - rect.left) / rect.width;
|
|
966
|
+
} else {
|
|
967
|
+
newSplit = (event.clientY - rect.top) / rect.height;
|
|
1027
968
|
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
969
|
+
newSplit = Math.min(Math.max(newSplit, 0.05), 0.95);
|
|
970
|
+
setSplit(newSplit);
|
|
971
|
+
onChange == null ? void 0 : onChange(newSplit);
|
|
972
|
+
};
|
|
973
|
+
const handleDragEnd = (event) => {
|
|
974
|
+
if (!dragging.current)
|
|
975
|
+
return;
|
|
976
|
+
dragging.current = false;
|
|
977
|
+
onDragEnd == null ? void 0 : onDragEnd();
|
|
978
|
+
document.removeEventListener("mousemove", handleDragging);
|
|
979
|
+
document.removeEventListener("mouseup", handleDragEnd);
|
|
980
|
+
};
|
|
981
|
+
const splitterStyle = orientation === "vertical" ? {
|
|
982
|
+
position: "absolute",
|
|
983
|
+
top: 0,
|
|
984
|
+
bottom: 0,
|
|
985
|
+
left: `${split * 100}%`,
|
|
986
|
+
width: "4px",
|
|
987
|
+
cursor: "col-resize",
|
|
988
|
+
background: "#ccc",
|
|
989
|
+
zIndex: 10,
|
|
990
|
+
pointerEvents: "auto",
|
|
991
|
+
boxShadow: "inset -1px 0 0 white, inset 1px 0 0 white"
|
|
992
|
+
} : {
|
|
993
|
+
position: "absolute",
|
|
994
|
+
left: 0,
|
|
995
|
+
right: 0,
|
|
996
|
+
top: `${split * 100}%`,
|
|
997
|
+
height: "4px",
|
|
998
|
+
cursor: "row-resize",
|
|
999
|
+
background: "#ccc",
|
|
1000
|
+
zIndex: 10,
|
|
1001
|
+
pointerEvents: "auto",
|
|
1002
|
+
boxShadow: "inset -1px 0 0 white, inset 1px 0 0 white"
|
|
1003
|
+
};
|
|
1004
|
+
const containerStyle = {
|
|
1005
|
+
position: "absolute",
|
|
1006
|
+
top: 0,
|
|
1007
|
+
left: 0,
|
|
1008
|
+
right: 0,
|
|
1009
|
+
bottom: 0
|
|
1010
|
+
};
|
|
1011
|
+
return (0, import_jsx_runtime12.jsx)("div", { ref: containerRef, style: containerStyle, children: (0, import_jsx_runtime12.jsx)("div", { style: splitterStyle, onMouseDown: handleDragStart }) });
|
|
1012
|
+
}
|
|
1038
1013
|
|
|
1039
|
-
// dist/
|
|
1014
|
+
// dist/view-selector-widget.js
|
|
1040
1015
|
var import_jsx_runtime14 = require("preact/jsx-runtime");
|
|
1041
|
-
var
|
|
1042
|
-
var
|
|
1043
|
-
var import_preact10 = require("preact");
|
|
1016
|
+
var import_preact9 = require("preact");
|
|
1017
|
+
var import_core10 = require("@deck.gl/core");
|
|
1044
1018
|
|
|
1045
|
-
// dist/
|
|
1046
|
-
var
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
"
|
|
1073
|
-
}
|
|
1074
|
-
var LightGlassTheme = {
|
|
1075
|
-
"--widget-margin": "12px",
|
|
1076
|
-
"--button-size": "28px",
|
|
1077
|
-
"--button-corner-radius": "8px",
|
|
1078
|
-
"--button-background": "rgba(255, 255, 255, 0.6)",
|
|
1079
|
-
"--button-stroke": "rgba(255, 255, 255, 0.3)",
|
|
1080
|
-
"--button-inner-stroke": "1px solid rgba(255, 255, 255, 0.6)",
|
|
1081
|
-
"--button-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset",
|
|
1082
|
-
"--button-backdrop-filter": "blur(4px)",
|
|
1083
|
-
"--button-icon-idle": "rgba(97, 97, 102, 1)",
|
|
1084
|
-
"--button-icon-hover": "rgba(24, 24, 26, 1)",
|
|
1085
|
-
"--icon-compass-north-color": "rgb(240, 92, 68)",
|
|
1086
|
-
"--icon-compass-south-color": "rgb(204, 204, 204)"
|
|
1087
|
-
};
|
|
1088
|
-
var DarkGlassTheme = {
|
|
1089
|
-
"--widget-margin": "12px",
|
|
1090
|
-
"--button-size": "28px",
|
|
1091
|
-
"--button-corner-radius": "8px",
|
|
1092
|
-
"--button-background": "rgba(18, 18, 20, 0.75)",
|
|
1093
|
-
"--button-stroke": "rgba(18, 18, 20, 0.30)",
|
|
1094
|
-
"--button-inner-stroke": "1px solid rgba(18, 18, 20, 0.75)",
|
|
1095
|
-
"--button-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset",
|
|
1096
|
-
"--button-backdrop-filter": "blur(4px)",
|
|
1097
|
-
"--button-icon-idle": "rgba(158, 157, 168, 1)",
|
|
1098
|
-
"--button-icon-hover": "rgba(215, 214, 229, 1)",
|
|
1099
|
-
"--icon-compass-north-color": "rgb(240, 92, 68)",
|
|
1100
|
-
"--icon-compass-south-color": "rgb(200, 199, 209)"
|
|
1101
|
-
};
|
|
1019
|
+
// dist/lib/components/icon-menu.js
|
|
1020
|
+
var import_jsx_runtime13 = require("preact/jsx-runtime");
|
|
1021
|
+
var import_hooks3 = require("preact/hooks");
|
|
1022
|
+
function IconMenu(props) {
|
|
1023
|
+
const [menuOpen, setMenuOpen] = (0, import_hooks3.useState)(false);
|
|
1024
|
+
const containerRef = (0, import_hooks3.useRef)(null);
|
|
1025
|
+
const handleClickOutside = (event) => {
|
|
1026
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
1027
|
+
setMenuOpen(false);
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
(0, import_hooks3.useEffect)(() => {
|
|
1031
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
1032
|
+
return () => {
|
|
1033
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
1034
|
+
};
|
|
1035
|
+
}, [containerRef]);
|
|
1036
|
+
const [selectedItem, setSelectedItem] = (0, import_hooks3.useState)(props.initialItem);
|
|
1037
|
+
const handleSelectItem = (item) => {
|
|
1038
|
+
setSelectedItem(item);
|
|
1039
|
+
setMenuOpen(false);
|
|
1040
|
+
props.onItemSelected(item);
|
|
1041
|
+
};
|
|
1042
|
+
const handleButtonClick = () => setMenuOpen(!menuOpen);
|
|
1043
|
+
const selectedMenuItem = props.menuItems.find((item) => item.value === selectedItem);
|
|
1044
|
+
const label = props.label || (selectedMenuItem == null ? void 0 : selectedMenuItem.label) || "";
|
|
1045
|
+
const icon = props.icon || (selectedMenuItem == null ? void 0 : selectedMenuItem.icon);
|
|
1046
|
+
return (0, import_jsx_runtime13.jsxs)("div", { style: { position: "relative", display: "inline-block" }, ref: containerRef, children: [(0, import_jsx_runtime13.jsx)(IconButton, { className: props.className, label, onClick: handleButtonClick, children: icon }), menuOpen && (0, import_jsx_runtime13.jsx)("div", { className: "deck-widget-icon-menu", children: (0, import_jsx_runtime13.jsx)(ButtonGroup, { orientation: "vertical", children: props.menuItems.map((item) => (0, import_jsx_runtime13.jsx)(GroupedIconButton, { label: item.label, onClick: () => handleSelectItem(item.value), children: item.icon }, item.value)) }) })] });
|
|
1047
|
+
}
|
|
1102
1048
|
|
|
1103
|
-
// dist/
|
|
1104
|
-
var
|
|
1049
|
+
// dist/view-selector-widget.js
|
|
1050
|
+
var ViewSelectorWidget = class extends import_core10.Widget {
|
|
1105
1051
|
constructor(props = {}) {
|
|
1106
|
-
super(props,
|
|
1107
|
-
this.className = "deck-widget-
|
|
1052
|
+
super(props, ViewSelectorWidget.defaultProps);
|
|
1053
|
+
this.className = "deck-widget-view-selector";
|
|
1108
1054
|
this.placement = "top-left";
|
|
1109
|
-
this.
|
|
1110
|
-
|
|
1111
|
-
|
|
1055
|
+
this.handleSelectMode = (viewMode) => {
|
|
1056
|
+
this.viewMode = viewMode;
|
|
1057
|
+
this.updateHTML();
|
|
1058
|
+
this.props.onViewModeChange(viewMode);
|
|
1059
|
+
};
|
|
1060
|
+
this.viewMode = this.props.initialViewMode;
|
|
1061
|
+
this.setProps(this.props);
|
|
1112
1062
|
}
|
|
1113
|
-
// eslint-disable-next-line complexity
|
|
1114
1063
|
setProps(props) {
|
|
1115
|
-
const { lightModeTheme, darkModeTheme } = this.props;
|
|
1116
1064
|
this.placement = props.placement ?? this.placement;
|
|
1065
|
+
this.viewId = props.viewId ?? this.viewId;
|
|
1117
1066
|
super.setProps(props);
|
|
1118
|
-
switch (this.themeMode) {
|
|
1119
|
-
case "light":
|
|
1120
|
-
if (props.lightModeTheme && !(0, import_core12._deepEqual)(props.lightModeTheme, lightModeTheme, 1)) {
|
|
1121
|
-
this._setThemeMode("light");
|
|
1122
|
-
}
|
|
1123
|
-
break;
|
|
1124
|
-
case "dark":
|
|
1125
|
-
if (props.darkModeTheme && !(0, import_core12._deepEqual)(props.darkModeTheme, darkModeTheme, 1)) {
|
|
1126
|
-
this._setThemeMode("dark");
|
|
1127
|
-
}
|
|
1128
|
-
break;
|
|
1129
|
-
}
|
|
1130
1067
|
}
|
|
1131
1068
|
onRenderHTML(rootElement) {
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
this._setThemeMode(this.themeMode);
|
|
1137
|
-
}
|
|
1138
|
-
_handleClick() {
|
|
1139
|
-
const newThemeMode = this.themeMode === "dark" ? "light" : "dark";
|
|
1140
|
-
this._setThemeMode(newThemeMode);
|
|
1141
|
-
}
|
|
1142
|
-
_setThemeMode(themeMode) {
|
|
1143
|
-
var _a;
|
|
1144
|
-
this.themeMode = themeMode;
|
|
1145
|
-
const container = (_a = this.rootElement) == null ? void 0 : _a.closest(".deck-widget-container");
|
|
1146
|
-
if (container) {
|
|
1147
|
-
const themeStyle = themeMode === "dark" ? this.props.darkModeTheme : this.props.lightModeTheme;
|
|
1148
|
-
(0, import_core12._applyStyles)(container, themeStyle);
|
|
1149
|
-
const label = this.themeMode === "dark" ? this.props.darkModeLabel : this.props.lightModeLabel;
|
|
1150
|
-
import_core12.log.log(1, `Switched theme to ${label}`, themeStyle);
|
|
1151
|
-
this.updateHTML();
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
/** Read browser preference */
|
|
1155
|
-
_getInitialThemeMode() {
|
|
1156
|
-
const { initialThemeMode } = this.props;
|
|
1157
|
-
return initialThemeMode === "auto" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : initialThemeMode;
|
|
1069
|
+
(0, import_preact9.render)((0, import_jsx_runtime14.jsx)(IconMenu, { className: "deck-widget-view-selector", menuItems: MENU_ITEMS.map((item) => ({
|
|
1070
|
+
...item,
|
|
1071
|
+
icon: item.icon()
|
|
1072
|
+
})), initialItem: this.props.initialViewMode, onItemSelected: this.handleSelectMode }), rootElement);
|
|
1158
1073
|
}
|
|
1159
1074
|
};
|
|
1160
|
-
|
|
1161
|
-
...
|
|
1162
|
-
id: "
|
|
1075
|
+
ViewSelectorWidget.defaultProps = {
|
|
1076
|
+
...import_core10.Widget.defaultProps,
|
|
1077
|
+
id: "view-selector",
|
|
1163
1078
|
placement: "top-left",
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1079
|
+
viewId: null,
|
|
1080
|
+
label: "Split View",
|
|
1081
|
+
initialViewMode: "single",
|
|
1082
|
+
onViewModeChange: () => {
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
var ICON_STYLE = { width: "24px", height: "24px" };
|
|
1086
|
+
var ICONS = {
|
|
1087
|
+
single: () => (0, import_jsx_runtime14.jsx)("svg", { width: "24", height: "24", style: ICON_STYLE, children: (0, import_jsx_runtime14.jsx)("rect", { x: "4", y: "4", width: "16", height: "16", stroke: "var(--button-icon-hover, rgb(24, 24, 26))", fill: "none", strokeWidth: "2" }) }),
|
|
1088
|
+
"split-horizontal": () => (0, import_jsx_runtime14.jsxs)("svg", { width: "24", height: "24", style: ICON_STYLE, children: [(0, import_jsx_runtime14.jsx)("rect", { x: "4", y: "4", width: "16", height: "7", stroke: "var(--button-icon-hover, rgb(24, 24, 26))", fill: "none", strokeWidth: "2" }), (0, import_jsx_runtime14.jsx)("rect", { x: "4", y: "13", width: "16", height: "7", stroke: "var(--button-icon-hover, rgb(24, 24, 26))", fill: "none", strokeWidth: "2" })] }),
|
|
1089
|
+
"split-vertical": () => (0, import_jsx_runtime14.jsxs)("svg", { width: "24", height: "24", style: ICON_STYLE, children: [(0, import_jsx_runtime14.jsx)("rect", { x: "4", y: "4", width: "7", height: "16", stroke: "var(--button-icon-hover, rgb(24, 24, 26))", fill: "none", strokeWidth: "2" }), (0, import_jsx_runtime14.jsx)("rect", { x: "13", y: "4", width: "7", height: "16", stroke: "var(--button-icon-hover, rgb(24, 24, 26))", fill: "none", strokeWidth: "2" })] })
|
|
1169
1090
|
};
|
|
1091
|
+
var MENU_ITEMS = [
|
|
1092
|
+
{ value: "single", icon: ICONS.single, label: "Single View" },
|
|
1093
|
+
{ value: "split-horizontal", icon: ICONS["split-horizontal"], label: "Split Horizontal" },
|
|
1094
|
+
{ value: "split-vertical", icon: ICONS["split-vertical"], label: "Split Vertical" }
|
|
1095
|
+
];
|
|
1170
1096
|
|
|
1171
1097
|
// dist/info-widget.js
|
|
1172
1098
|
var import_jsx_runtime15 = require("preact/jsx-runtime");
|
|
1173
|
-
var
|
|
1174
|
-
var
|
|
1175
|
-
var InfoWidget = class extends
|
|
1099
|
+
var import_core11 = require("@deck.gl/core");
|
|
1100
|
+
var import_preact10 = require("preact");
|
|
1101
|
+
var InfoWidget = class extends import_core11.Widget {
|
|
1176
1102
|
constructor(props) {
|
|
1177
1103
|
super(props, InfoWidget.defaultProps);
|
|
1178
1104
|
this.className = "deck-widget-info";
|
|
1179
1105
|
this.placement = "fill";
|
|
1180
|
-
this.
|
|
1181
|
-
props.position = props.position || [0, 0];
|
|
1182
|
-
props.text = props.text || "";
|
|
1183
|
-
props.visible = props.visible || false;
|
|
1184
|
-
props.minOffset = props.minOffset ?? 0;
|
|
1106
|
+
this.setProps(this.props);
|
|
1185
1107
|
}
|
|
1186
1108
|
setProps(props) {
|
|
1109
|
+
this.viewId = props.viewId ?? this.viewId;
|
|
1187
1110
|
super.setProps(props);
|
|
1188
1111
|
}
|
|
1189
1112
|
onCreateRootElement() {
|
|
@@ -1202,7 +1125,7 @@ var InfoWidget = class extends import_core14.Widget {
|
|
|
1202
1125
|
this.setProps({
|
|
1203
1126
|
visible: tooltip !== null,
|
|
1204
1127
|
...tooltip,
|
|
1205
|
-
style: { zIndex: 1, ...tooltip == null ? void 0 : tooltip.style }
|
|
1128
|
+
style: { zIndex: "1", ...tooltip == null ? void 0 : tooltip.style }
|
|
1206
1129
|
});
|
|
1207
1130
|
}
|
|
1208
1131
|
}
|
|
@@ -1245,7 +1168,7 @@ var InfoWidget = class extends import_core14.Widget {
|
|
|
1245
1168
|
// Include any additional styles
|
|
1246
1169
|
...this.props.style
|
|
1247
1170
|
}, children: this.props.text }), (0, import_jsx_runtime15.jsx)("div", { className: "popup-arrow", style: { position: "absolute", width: "0px", height: "0px" } })] }) : null;
|
|
1248
|
-
(0,
|
|
1171
|
+
(0, import_preact10.render)(ui, rootElement);
|
|
1249
1172
|
requestAnimationFrame(() => {
|
|
1250
1173
|
if (!this.props.visible || !rootElement.firstChild || !this.viewport)
|
|
1251
1174
|
return;
|
|
@@ -1304,11 +1227,11 @@ var InfoWidget = class extends import_core14.Widget {
|
|
|
1304
1227
|
}
|
|
1305
1228
|
};
|
|
1306
1229
|
InfoWidget.defaultProps = {
|
|
1307
|
-
...
|
|
1230
|
+
...import_core11.Widget.defaultProps,
|
|
1231
|
+
id: "info",
|
|
1308
1232
|
position: [0, 0],
|
|
1309
1233
|
text: "",
|
|
1310
1234
|
visible: false,
|
|
1311
|
-
// Set default minOffset if not provided
|
|
1312
1235
|
minOffset: 0,
|
|
1313
1236
|
viewId: null,
|
|
1314
1237
|
mode: "hover",
|
|
@@ -1316,126 +1239,13 @@ InfoWidget.defaultProps = {
|
|
|
1316
1239
|
onClick: void 0
|
|
1317
1240
|
};
|
|
1318
1241
|
|
|
1319
|
-
// dist/stats-widget.js
|
|
1320
|
-
var import_jsx_runtime16 = require("preact/jsx-runtime");
|
|
1321
|
-
var import_core15 = require("@deck.gl/core");
|
|
1322
|
-
var import_core16 = require("@luma.gl/core");
|
|
1323
|
-
var import_preact12 = require("preact");
|
|
1324
|
-
var RIGHT_ARROW = "\u25B6";
|
|
1325
|
-
var DOWN_ARROW = "\u2B07";
|
|
1326
|
-
var DEFAULT_COUNT_FORMATTER = (stat) => `${stat.name}: ${stat.count}`;
|
|
1327
|
-
function formatTime(time) {
|
|
1328
|
-
return time < 1e3 ? `${time.toFixed(2)}ms` : `${(time / 1e3).toFixed(2)}s`;
|
|
1329
|
-
}
|
|
1330
|
-
function formatMemory(bytes) {
|
|
1331
|
-
const mb = bytes / 1e6;
|
|
1332
|
-
return `${mb.toFixed(1)} MB`;
|
|
1333
|
-
}
|
|
1334
|
-
var DEFAULT_FORMATTERS = {
|
|
1335
|
-
count: DEFAULT_COUNT_FORMATTER,
|
|
1336
|
-
averageTime: (stat) => `${stat.name}: ${formatTime(stat.getAverageTime())}`,
|
|
1337
|
-
totalTime: (stat) => `${stat.name}: ${formatTime(stat.time)}`,
|
|
1338
|
-
fps: (stat) => `${stat.name}: ${Math.round(stat.getHz())}fps`,
|
|
1339
|
-
memory: (stat) => `${stat.name}: ${formatMemory(stat.count)}`
|
|
1340
|
-
};
|
|
1341
|
-
var StatsWidget = class extends import_core15.Widget {
|
|
1342
|
-
constructor(props = {}) {
|
|
1343
|
-
super(props, StatsWidget.defaultProps);
|
|
1344
|
-
this.className = "deck-widget-stats";
|
|
1345
|
-
this.placement = "top-left";
|
|
1346
|
-
this._counter = 0;
|
|
1347
|
-
this.collapsed = true;
|
|
1348
|
-
this._toggleCollapsed = () => {
|
|
1349
|
-
this.collapsed = !this.collapsed;
|
|
1350
|
-
this.updateHTML();
|
|
1351
|
-
};
|
|
1352
|
-
this._formatters = { ...DEFAULT_FORMATTERS };
|
|
1353
|
-
this.setProps(props);
|
|
1354
|
-
this._resetOnUpdate = { ...this.props.resetOnUpdate };
|
|
1355
|
-
this._stats = this.props.stats;
|
|
1356
|
-
}
|
|
1357
|
-
setProps(props) {
|
|
1358
|
-
super.setProps(props);
|
|
1359
|
-
this._stats = this._getStats();
|
|
1360
|
-
if (props.formatters) {
|
|
1361
|
-
for (const name in props.formatters) {
|
|
1362
|
-
const f = props.formatters[name];
|
|
1363
|
-
this._formatters[name] = typeof f === "string" ? DEFAULT_FORMATTERS[f] || DEFAULT_COUNT_FORMATTER : f;
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
if (props.resetOnUpdate) {
|
|
1367
|
-
this._resetOnUpdate = { ...props.resetOnUpdate };
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
onAdd() {
|
|
1371
|
-
this._stats = this._getStats();
|
|
1372
|
-
this.updateHTML();
|
|
1373
|
-
}
|
|
1374
|
-
onRenderHTML(rootElement) {
|
|
1375
|
-
const stats = this._stats;
|
|
1376
|
-
const collapsed = this.collapsed;
|
|
1377
|
-
const title = this.props.title || (stats == null ? void 0 : stats.id) || "Stats";
|
|
1378
|
-
const items = [];
|
|
1379
|
-
if (!collapsed && stats) {
|
|
1380
|
-
stats.forEach((stat) => {
|
|
1381
|
-
const lines = this._getLines(stat);
|
|
1382
|
-
if (this._resetOnUpdate && this._resetOnUpdate[stat.name]) {
|
|
1383
|
-
stat.reset();
|
|
1384
|
-
}
|
|
1385
|
-
lines.forEach((line, i) => {
|
|
1386
|
-
items.push((0, import_jsx_runtime16.jsx)("div", { style: { whiteSpace: "pre" }, children: line }, `${stat.name}-${i}`));
|
|
1387
|
-
});
|
|
1388
|
-
});
|
|
1389
|
-
}
|
|
1390
|
-
(0, import_preact12.render)((0, import_jsx_runtime16.jsxs)("div", { className: "deck-widget-stats-container", style: { cursor: "default" }, children: [(0, import_jsx_runtime16.jsxs)("div", { className: "deck-widget-stats-header", style: { cursor: "pointer", pointerEvents: "auto" }, onClick: this._toggleCollapsed, children: [collapsed ? RIGHT_ARROW : DOWN_ARROW, " ", title] }), !collapsed && (0, import_jsx_runtime16.jsx)("div", { className: "deck-widget-stats-content deck-widget-common", children: items })] }), rootElement);
|
|
1391
|
-
}
|
|
1392
|
-
onRedraw() {
|
|
1393
|
-
const framesPerUpdate = Math.max(1, this.props.framesPerUpdate || 1);
|
|
1394
|
-
if (this._counter++ % framesPerUpdate === 0) {
|
|
1395
|
-
console.log("Redrawing stats widget");
|
|
1396
|
-
this.updateHTML();
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
_getStats() {
|
|
1400
|
-
var _a, _b;
|
|
1401
|
-
switch (this.props.type) {
|
|
1402
|
-
case "deck":
|
|
1403
|
-
return (_a = this.deck) == null ? void 0 : _a.stats;
|
|
1404
|
-
case "luma":
|
|
1405
|
-
return Array.from(import_core16.luma.stats.stats.values())[0];
|
|
1406
|
-
case "device":
|
|
1407
|
-
const device = (_b = this.deck) == null ? void 0 : _b.device;
|
|
1408
|
-
const stats = device == null ? void 0 : device.statsManager.stats.values();
|
|
1409
|
-
return stats ? Array.from(stats)[0] : void 0;
|
|
1410
|
-
case "custom":
|
|
1411
|
-
return this.props.stats;
|
|
1412
|
-
default:
|
|
1413
|
-
throw new Error(`Unknown stats type: ${this.props.type}`);
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
_getLines(stat) {
|
|
1417
|
-
const formatter = this._formatters[stat.name] || this._formatters[stat.type || ""] || DEFAULT_COUNT_FORMATTER;
|
|
1418
|
-
return formatter(stat).split("\n");
|
|
1419
|
-
}
|
|
1420
|
-
};
|
|
1421
|
-
StatsWidget.defaultProps = {
|
|
1422
|
-
...import_core15.Widget.defaultProps,
|
|
1423
|
-
type: "deck",
|
|
1424
|
-
stats: void 0,
|
|
1425
|
-
title: "Stats",
|
|
1426
|
-
framesPerUpdate: 1,
|
|
1427
|
-
formatters: {},
|
|
1428
|
-
resetOnUpdate: {},
|
|
1429
|
-
id: "stats"
|
|
1430
|
-
};
|
|
1431
|
-
|
|
1432
1242
|
// dist/context-menu-widget.js
|
|
1433
|
-
var
|
|
1434
|
-
var
|
|
1435
|
-
var
|
|
1243
|
+
var import_jsx_runtime17 = require("preact/jsx-runtime");
|
|
1244
|
+
var import_core12 = require("@deck.gl/core");
|
|
1245
|
+
var import_preact11 = require("preact");
|
|
1436
1246
|
|
|
1437
1247
|
// dist/lib/components/simple-menu.js
|
|
1438
|
-
var
|
|
1248
|
+
var import_jsx_runtime16 = require("preact/jsx-runtime");
|
|
1439
1249
|
var MENU_STYLE = {
|
|
1440
1250
|
position: "absolute",
|
|
1441
1251
|
top: "100%",
|
|
@@ -1443,7 +1253,7 @@ var MENU_STYLE = {
|
|
|
1443
1253
|
background: "white",
|
|
1444
1254
|
border: "1px solid #ccc",
|
|
1445
1255
|
borderRadius: "4px",
|
|
1446
|
-
marginTop: "4px",
|
|
1256
|
+
marginTop: "var(--menu-gap, 4px)",
|
|
1447
1257
|
zIndex: 100
|
|
1448
1258
|
};
|
|
1449
1259
|
var MENU_ITEM_STYLE = {
|
|
@@ -1461,20 +1271,20 @@ var SimpleMenu = (props) => {
|
|
|
1461
1271
|
left: `${position.x}px`,
|
|
1462
1272
|
top: `${position.y}px`
|
|
1463
1273
|
};
|
|
1464
|
-
return (0,
|
|
1274
|
+
return (0, import_jsx_runtime16.jsx)("div", { style: styleOverride, children: menuItems.map(({ key, label }) => (0, import_jsx_runtime16.jsx)("button", { style: { ...MENU_ITEM_STYLE, display: "block" }, onClick: (_) => onItemSelected(key), children: label }, key)) });
|
|
1465
1275
|
};
|
|
1466
1276
|
|
|
1467
1277
|
// dist/context-menu-widget.js
|
|
1468
1278
|
var MOUSE_BUTTON_RIGHT = 2;
|
|
1469
1279
|
var MOUSE_WHICH_RIGHT = 3;
|
|
1470
|
-
var ContextMenuWidget = class extends
|
|
1280
|
+
var ContextMenuWidget = class extends import_core12.Widget {
|
|
1471
1281
|
constructor(props) {
|
|
1472
1282
|
super(props, ContextMenuWidget.defaultProps);
|
|
1473
1283
|
this.className = "deck-widget-context-menu";
|
|
1474
1284
|
this.placement = "fill";
|
|
1475
1285
|
this.pickInfo = null;
|
|
1476
1286
|
this.pickInfo = null;
|
|
1477
|
-
this.setProps(props);
|
|
1287
|
+
this.setProps(this.props);
|
|
1478
1288
|
}
|
|
1479
1289
|
onAdd({ deck }) {
|
|
1480
1290
|
var _a, _b;
|
|
@@ -1494,8 +1304,8 @@ var ContextMenuWidget = class extends import_core17.Widget {
|
|
|
1494
1304
|
}
|
|
1495
1305
|
onRenderHTML(rootElement) {
|
|
1496
1306
|
const { visible, position, menuItems } = this.props;
|
|
1497
|
-
const ui = visible && menuItems.length ? (0,
|
|
1498
|
-
(0,
|
|
1307
|
+
const ui = visible && menuItems.length ? (0, import_jsx_runtime17.jsx)(SimpleMenu, { menuItems, onItemSelected: (key) => this.props.onMenuItemSelected(key, this.pickInfo), position, style: { pointerEvents: "auto" } }) : null;
|
|
1308
|
+
(0, import_preact11.render)(ui, rootElement);
|
|
1499
1309
|
}
|
|
1500
1310
|
handleContextMenu(srcEvent) {
|
|
1501
1311
|
var _a, _b, _c;
|
|
@@ -1522,7 +1332,8 @@ var ContextMenuWidget = class extends import_core17.Widget {
|
|
|
1522
1332
|
}
|
|
1523
1333
|
};
|
|
1524
1334
|
ContextMenuWidget.defaultProps = {
|
|
1525
|
-
...
|
|
1335
|
+
...import_core12.Widget.defaultProps,
|
|
1336
|
+
id: "context",
|
|
1526
1337
|
viewId: null,
|
|
1527
1338
|
visible: false,
|
|
1528
1339
|
position: { x: 0, y: 0 },
|
|
@@ -1532,115 +1343,11 @@ ContextMenuWidget.defaultProps = {
|
|
|
1532
1343
|
onMenuItemSelected: (key, pickInfo) => console.log("Context menu item selected:", key, pickInfo)
|
|
1533
1344
|
};
|
|
1534
1345
|
|
|
1535
|
-
// dist/splitter-widget.js
|
|
1536
|
-
var import_jsx_runtime19 = require("preact/jsx-runtime");
|
|
1537
|
-
var import_preact14 = require("preact");
|
|
1538
|
-
var import_hooks2 = require("preact/hooks");
|
|
1539
|
-
var import_core18 = require("@deck.gl/core");
|
|
1540
|
-
var SplitterWidget = class extends import_core18.Widget {
|
|
1541
|
-
constructor(props) {
|
|
1542
|
-
super(props, SplitterWidget.defaultProps);
|
|
1543
|
-
this.className = "deck-widget-splitter";
|
|
1544
|
-
this.placement = "fill";
|
|
1545
|
-
}
|
|
1546
|
-
setProps(props) {
|
|
1547
|
-
super.setProps(props);
|
|
1548
|
-
}
|
|
1549
|
-
onRenderHTML(rootElement) {
|
|
1550
|
-
rootElement.style.position = "absolute";
|
|
1551
|
-
rootElement.style.top = "0";
|
|
1552
|
-
rootElement.style.left = "0";
|
|
1553
|
-
rootElement.style.width = "100%";
|
|
1554
|
-
rootElement.style.height = "100%";
|
|
1555
|
-
rootElement.style.margin = "0px";
|
|
1556
|
-
(0, import_preact14.render)((0, import_jsx_runtime19.jsx)(Splitter, { orientation: this.props.orientation, initialSplit: this.props.initialSplit, onChange: this.props.onChange, onDragStart: this.props.onDragStart, onDragEnd: this.props.onDragEnd }), rootElement);
|
|
1557
|
-
}
|
|
1558
|
-
};
|
|
1559
|
-
SplitterWidget.defaultProps = {
|
|
1560
|
-
...import_core18.Widget.defaultProps,
|
|
1561
|
-
id: "splitter-widget",
|
|
1562
|
-
viewId1: "",
|
|
1563
|
-
viewId2: "",
|
|
1564
|
-
orientation: "vertical",
|
|
1565
|
-
initialSplit: 0.5,
|
|
1566
|
-
onChange: () => {
|
|
1567
|
-
},
|
|
1568
|
-
onDragStart: () => {
|
|
1569
|
-
},
|
|
1570
|
-
onDragEnd: () => {
|
|
1571
|
-
}
|
|
1572
|
-
};
|
|
1573
|
-
function Splitter({ orientation, initialSplit, onChange, onDragStart, onDragEnd }) {
|
|
1574
|
-
const [split, setSplit] = (0, import_hooks2.useState)(initialSplit);
|
|
1575
|
-
const dragging = (0, import_hooks2.useRef)(false);
|
|
1576
|
-
const containerRef = (0, import_hooks2.useRef)(null);
|
|
1577
|
-
const handleDragStart = (event) => {
|
|
1578
|
-
dragging.current = true;
|
|
1579
|
-
onDragStart == null ? void 0 : onDragStart();
|
|
1580
|
-
document.addEventListener("mousemove", handleDragging);
|
|
1581
|
-
document.addEventListener("mouseup", handleDragEnd);
|
|
1582
|
-
event.preventDefault();
|
|
1583
|
-
};
|
|
1584
|
-
const handleDragging = (event) => {
|
|
1585
|
-
if (!dragging.current || !containerRef.current)
|
|
1586
|
-
return;
|
|
1587
|
-
const rect = containerRef.current.getBoundingClientRect();
|
|
1588
|
-
let newSplit;
|
|
1589
|
-
if (orientation === "vertical") {
|
|
1590
|
-
newSplit = (event.clientX - rect.left) / rect.width;
|
|
1591
|
-
} else {
|
|
1592
|
-
newSplit = (event.clientY - rect.top) / rect.height;
|
|
1593
|
-
}
|
|
1594
|
-
newSplit = Math.min(Math.max(newSplit, 0.05), 0.95);
|
|
1595
|
-
setSplit(newSplit);
|
|
1596
|
-
onChange == null ? void 0 : onChange(newSplit);
|
|
1597
|
-
};
|
|
1598
|
-
const handleDragEnd = (event) => {
|
|
1599
|
-
if (!dragging.current)
|
|
1600
|
-
return;
|
|
1601
|
-
dragging.current = false;
|
|
1602
|
-
onDragEnd == null ? void 0 : onDragEnd();
|
|
1603
|
-
document.removeEventListener("mousemove", handleDragging);
|
|
1604
|
-
document.removeEventListener("mouseup", handleDragEnd);
|
|
1605
|
-
};
|
|
1606
|
-
const splitterStyle = orientation === "vertical" ? {
|
|
1607
|
-
position: "absolute",
|
|
1608
|
-
top: 0,
|
|
1609
|
-
bottom: 0,
|
|
1610
|
-
left: `${split * 100}%`,
|
|
1611
|
-
width: "4px",
|
|
1612
|
-
cursor: "col-resize",
|
|
1613
|
-
background: "#ccc",
|
|
1614
|
-
zIndex: 10,
|
|
1615
|
-
pointerEvents: "auto",
|
|
1616
|
-
boxShadow: "inset -1px 0 0 white, inset 1px 0 0 white"
|
|
1617
|
-
} : {
|
|
1618
|
-
position: "absolute",
|
|
1619
|
-
left: 0,
|
|
1620
|
-
right: 0,
|
|
1621
|
-
top: `${split * 100}%`,
|
|
1622
|
-
height: "4px",
|
|
1623
|
-
cursor: "row-resize",
|
|
1624
|
-
background: "#ccc",
|
|
1625
|
-
zIndex: 10,
|
|
1626
|
-
pointerEvents: "auto",
|
|
1627
|
-
boxShadow: "inset -1px 0 0 white, inset 1px 0 0 white"
|
|
1628
|
-
};
|
|
1629
|
-
const containerStyle = {
|
|
1630
|
-
position: "absolute",
|
|
1631
|
-
top: 0,
|
|
1632
|
-
left: 0,
|
|
1633
|
-
right: 0,
|
|
1634
|
-
bottom: 0
|
|
1635
|
-
};
|
|
1636
|
-
return (0, import_jsx_runtime19.jsx)("div", { ref: containerRef, style: containerStyle, children: (0, import_jsx_runtime19.jsx)("div", { style: splitterStyle, onMouseDown: handleDragStart }) });
|
|
1637
|
-
}
|
|
1638
|
-
|
|
1639
1346
|
// dist/timeline-widget.js
|
|
1640
|
-
var
|
|
1641
|
-
var
|
|
1642
|
-
var
|
|
1643
|
-
var TimelineWidget = class extends
|
|
1347
|
+
var import_jsx_runtime18 = require("preact/jsx-runtime");
|
|
1348
|
+
var import_core13 = require("@deck.gl/core");
|
|
1349
|
+
var import_preact12 = require("preact");
|
|
1350
|
+
var TimelineWidget = class extends import_core13.Widget {
|
|
1644
1351
|
constructor(props = {}) {
|
|
1645
1352
|
super(props, TimelineWidget.defaultProps);
|
|
1646
1353
|
this.id = "timeline";
|
|
@@ -1676,9 +1383,11 @@ var TimelineWidget = class extends import_core19.Widget {
|
|
|
1676
1383
|
}
|
|
1677
1384
|
};
|
|
1678
1385
|
this.currentTime = this.props.initialTime ?? this.props.timeRange[0];
|
|
1386
|
+
this.setProps(this.props);
|
|
1679
1387
|
}
|
|
1680
1388
|
setProps(props) {
|
|
1681
|
-
this.placement = props.placement
|
|
1389
|
+
this.placement = props.placement ?? this.placement;
|
|
1390
|
+
this.viewId = props.viewId ?? this.viewId;
|
|
1682
1391
|
super.setProps(props);
|
|
1683
1392
|
}
|
|
1684
1393
|
onAdd() {
|
|
@@ -1689,7 +1398,7 @@ var TimelineWidget = class extends import_core19.Widget {
|
|
|
1689
1398
|
this.stop();
|
|
1690
1399
|
}
|
|
1691
1400
|
onRenderHTML(rootElement) {
|
|
1692
|
-
(0,
|
|
1401
|
+
(0, import_preact12.render)((0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", alignItems: "center", pointerEvents: "auto" }, children: [(0, import_jsx_runtime18.jsx)(IconButton, { label: this.playing ? "Pause" : "Play", onClick: this.handlePlayPause, children: (0, import_jsx_runtime18.jsx)("div", { className: "text", children: this.playing ? "\u23F8" : "\u25B6" }) }), (0, import_jsx_runtime18.jsx)("input", { type: "range", className: "timeline-slider", min: this.props.timeRange[0], max: this.props.timeRange[1], step: this.props.step, value: this.currentTime, onInput: this.handleSliderChange })] }), rootElement);
|
|
1693
1402
|
}
|
|
1694
1403
|
start() {
|
|
1695
1404
|
this.playing = true;
|
|
@@ -1706,9 +1415,10 @@ var TimelineWidget = class extends import_core19.Widget {
|
|
|
1706
1415
|
}
|
|
1707
1416
|
};
|
|
1708
1417
|
TimelineWidget.defaultProps = {
|
|
1709
|
-
...
|
|
1418
|
+
...import_core13.Widget.defaultProps,
|
|
1710
1419
|
id: "timeline",
|
|
1711
1420
|
placement: "bottom-left",
|
|
1421
|
+
viewId: null,
|
|
1712
1422
|
timeRange: [0, 100],
|
|
1713
1423
|
step: 1,
|
|
1714
1424
|
initialTime: void 0,
|
|
@@ -1717,98 +1427,405 @@ TimelineWidget.defaultProps = {
|
|
|
1717
1427
|
playInterval: 1e3
|
|
1718
1428
|
};
|
|
1719
1429
|
|
|
1720
|
-
// dist/
|
|
1721
|
-
var
|
|
1722
|
-
var
|
|
1723
|
-
var
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
};
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1430
|
+
// dist/screenshot-widget.js
|
|
1431
|
+
var import_jsx_runtime19 = require("preact/jsx-runtime");
|
|
1432
|
+
var import_preact13 = require("preact");
|
|
1433
|
+
var import_core14 = require("@deck.gl/core");
|
|
1434
|
+
var ScreenshotWidget = class extends import_core14.Widget {
|
|
1435
|
+
constructor(props = {}) {
|
|
1436
|
+
super(props, ScreenshotWidget.defaultProps);
|
|
1437
|
+
this.className = "deck-widget-screenshot";
|
|
1438
|
+
this.placement = "top-left";
|
|
1439
|
+
this.setProps(this.props);
|
|
1440
|
+
}
|
|
1441
|
+
setProps(props) {
|
|
1442
|
+
this.placement = props.placement ?? this.placement;
|
|
1443
|
+
this.viewId = props.viewId ?? this.viewId;
|
|
1444
|
+
super.setProps(props);
|
|
1445
|
+
}
|
|
1446
|
+
onRenderHTML(rootElement) {
|
|
1447
|
+
(0, import_preact13.render)((0, import_jsx_runtime19.jsx)(IconButton, { className: "deck-widget-camera", label: this.props.label, onClick: this.handleClick.bind(this) }), rootElement);
|
|
1448
|
+
}
|
|
1449
|
+
handleClick() {
|
|
1450
|
+
if (this.props.onCapture) {
|
|
1451
|
+
this.props.onCapture(this);
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
const dataURL = this.captureScreenToDataURL(this.props.imageFormat);
|
|
1455
|
+
if (dataURL) {
|
|
1456
|
+
this.downloadDataURL(dataURL, this.props.filename);
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
/** @note only captures canvas contents, not HTML DOM or CSS styles */
|
|
1460
|
+
captureScreenToDataURL(imageFormat) {
|
|
1461
|
+
var _a;
|
|
1462
|
+
const canvas = (_a = this.deck) == null ? void 0 : _a.getCanvas();
|
|
1463
|
+
return canvas == null ? void 0 : canvas.toDataURL(imageFormat);
|
|
1464
|
+
}
|
|
1465
|
+
/** Download a data URL */
|
|
1466
|
+
downloadDataURL(dataURL, filename) {
|
|
1467
|
+
const link = document.createElement("a");
|
|
1468
|
+
link.href = dataURL;
|
|
1469
|
+
link.download = filename;
|
|
1470
|
+
link.click();
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1473
|
+
ScreenshotWidget.defaultProps = {
|
|
1474
|
+
...import_core14.Widget.defaultProps,
|
|
1475
|
+
id: "screenshot",
|
|
1476
|
+
placement: "top-left",
|
|
1477
|
+
viewId: null,
|
|
1478
|
+
label: "Screenshot",
|
|
1479
|
+
filename: "screenshot.png",
|
|
1480
|
+
imageFormat: "image/png",
|
|
1481
|
+
onCapture: void 0
|
|
1482
|
+
};
|
|
1771
1483
|
|
|
1772
|
-
// dist/
|
|
1773
|
-
var
|
|
1484
|
+
// dist/theme-widget.js
|
|
1485
|
+
var import_jsx_runtime20 = require("preact/jsx-runtime");
|
|
1486
|
+
var import_core15 = require("@deck.gl/core");
|
|
1487
|
+
var import_core16 = require("@deck.gl/core");
|
|
1488
|
+
var import_preact14 = require("preact");
|
|
1489
|
+
|
|
1490
|
+
// dist/themes.js
|
|
1491
|
+
var LightTheme = {
|
|
1492
|
+
"--widget-margin": "12px",
|
|
1493
|
+
"--button-size": "28px",
|
|
1494
|
+
"--button-corner-radius": "8px",
|
|
1495
|
+
"--button-background": "#fff",
|
|
1496
|
+
"--button-stroke": "rgba(255, 255, 255, 0.3)",
|
|
1497
|
+
"--button-inner-stroke": "unset",
|
|
1498
|
+
"--button-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25)",
|
|
1499
|
+
"--button-backdrop-filter": "unset",
|
|
1500
|
+
"--button-icon-idle": "rgba(97, 97, 102, 1)",
|
|
1501
|
+
"--button-icon-hover": "rgba(24, 24, 26, 1)",
|
|
1502
|
+
"--button-text": "rgb(24, 24, 26, 1)",
|
|
1503
|
+
"--icon-compass-north-color": "rgb(240, 92, 68)",
|
|
1504
|
+
"--icon-compass-south-color": "rgb(204, 204, 204)",
|
|
1505
|
+
"--menu-gap": "4px"
|
|
1506
|
+
};
|
|
1507
|
+
var DarkTheme = {
|
|
1508
|
+
"--widget-margin": "12px",
|
|
1509
|
+
"--button-size": "28px",
|
|
1510
|
+
"--button-corner-radius": "8px",
|
|
1511
|
+
"--button-background": "rgba(18, 18, 20, 1)",
|
|
1512
|
+
"--button-stroke": "rgba(18, 18, 20, 0.30)",
|
|
1513
|
+
"--button-inner-stroke": "unset",
|
|
1514
|
+
"--button-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25)",
|
|
1515
|
+
"--button-backdrop-filter": "unset",
|
|
1516
|
+
"--button-icon-idle": "rgba(158, 157, 168, 1)",
|
|
1517
|
+
"--button-icon-hover": "rgba(215, 214, 229, 1)",
|
|
1518
|
+
"--button-text": "rgb(215, 214, 229, 1)",
|
|
1519
|
+
"--icon-compass-north-color": "rgb(240, 92, 68)",
|
|
1520
|
+
"--icon-compass-south-color": "rgb(200, 199, 209)",
|
|
1521
|
+
"--menu-gap": "4px"
|
|
1522
|
+
};
|
|
1523
|
+
var LightGlassTheme = {
|
|
1524
|
+
"--widget-margin": "12px",
|
|
1525
|
+
"--button-size": "28px",
|
|
1526
|
+
"--button-corner-radius": "8px",
|
|
1527
|
+
"--button-background": "rgba(255, 255, 255, 0.6)",
|
|
1528
|
+
"--button-stroke": "rgba(255, 255, 255, 0.3)",
|
|
1529
|
+
"--button-inner-stroke": "1px solid rgba(255, 255, 255, 0.6)",
|
|
1530
|
+
"--button-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset",
|
|
1531
|
+
"--button-backdrop-filter": "blur(4px)",
|
|
1532
|
+
"--button-icon-idle": "rgba(97, 97, 102, 1)",
|
|
1533
|
+
"--button-icon-hover": "rgba(24, 24, 26, 1)",
|
|
1534
|
+
"--button-text": "rgb(24, 24, 26, 1)",
|
|
1535
|
+
"--icon-compass-north-color": "rgb(240, 92, 68)",
|
|
1536
|
+
"--icon-compass-south-color": "rgb(204, 204, 204)",
|
|
1537
|
+
"--menu-gap": "4px"
|
|
1538
|
+
};
|
|
1539
|
+
var DarkGlassTheme = {
|
|
1540
|
+
"--widget-margin": "12px",
|
|
1541
|
+
"--button-size": "28px",
|
|
1542
|
+
"--button-corner-radius": "8px",
|
|
1543
|
+
"--button-background": "rgba(18, 18, 20, 0.75)",
|
|
1544
|
+
"--button-stroke": "rgba(18, 18, 20, 0.30)",
|
|
1545
|
+
"--button-inner-stroke": "1px solid rgba(18, 18, 20, 0.75)",
|
|
1546
|
+
"--button-shadow": "0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset",
|
|
1547
|
+
"--button-backdrop-filter": "blur(4px)",
|
|
1548
|
+
"--button-icon-idle": "rgba(158, 157, 168, 1)",
|
|
1549
|
+
"--button-icon-hover": "rgba(215, 214, 229, 1)",
|
|
1550
|
+
"--button-text": "rgb(215, 214, 229, 1)",
|
|
1551
|
+
"--icon-compass-north-color": "rgb(240, 92, 68)",
|
|
1552
|
+
"--icon-compass-south-color": "rgb(200, 199, 209)",
|
|
1553
|
+
"--menu-gap": "4px"
|
|
1554
|
+
};
|
|
1555
|
+
|
|
1556
|
+
// dist/theme-widget.js
|
|
1557
|
+
var ThemeWidget = class extends import_core16.Widget {
|
|
1774
1558
|
constructor(props = {}) {
|
|
1775
|
-
super(props,
|
|
1776
|
-
this.className = "deck-widget-
|
|
1559
|
+
super(props, ThemeWidget.defaultProps);
|
|
1560
|
+
this.className = "deck-widget-theme";
|
|
1777
1561
|
this.placement = "top-left";
|
|
1778
|
-
this.
|
|
1779
|
-
|
|
1562
|
+
this.themeMode = "dark";
|
|
1563
|
+
this.themeMode = this._getInitialThemeMode();
|
|
1564
|
+
this.setProps(this.props);
|
|
1565
|
+
}
|
|
1566
|
+
// eslint-disable-next-line complexity
|
|
1567
|
+
setProps(props) {
|
|
1568
|
+
const { lightModeTheme, darkModeTheme } = this.props;
|
|
1569
|
+
this.placement = props.placement ?? this.placement;
|
|
1570
|
+
this.viewId = props.viewId ?? this.viewId;
|
|
1571
|
+
super.setProps(props);
|
|
1572
|
+
switch (this.themeMode) {
|
|
1573
|
+
case "light":
|
|
1574
|
+
if (props.lightModeTheme && !(0, import_core15._deepEqual)(props.lightModeTheme, lightModeTheme, 1)) {
|
|
1575
|
+
this._setThemeMode("light");
|
|
1576
|
+
}
|
|
1577
|
+
break;
|
|
1578
|
+
case "dark":
|
|
1579
|
+
if (props.darkModeTheme && !(0, import_core15._deepEqual)(props.darkModeTheme, darkModeTheme, 1)) {
|
|
1580
|
+
this._setThemeMode("dark");
|
|
1581
|
+
}
|
|
1582
|
+
break;
|
|
1583
|
+
default:
|
|
1584
|
+
import_core15.log.warn(`Invalid theme mode ${this.themeMode}`)();
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
onRenderHTML(rootElement) {
|
|
1588
|
+
const { lightModeLabel, darkModeLabel } = this.props;
|
|
1589
|
+
(0, import_preact14.render)((0, import_jsx_runtime20.jsx)(IconButton, { onClick: this._handleClick.bind(this), label: this.themeMode === "dark" ? darkModeLabel : lightModeLabel, className: this.themeMode === "dark" ? "deck-widget-moon" : "deck-widget-sun" }), rootElement);
|
|
1590
|
+
}
|
|
1591
|
+
onAdd() {
|
|
1592
|
+
this._setThemeMode(this.themeMode);
|
|
1593
|
+
}
|
|
1594
|
+
_handleClick() {
|
|
1595
|
+
const newThemeMode = this.themeMode === "dark" ? "light" : "dark";
|
|
1596
|
+
this._setThemeMode(newThemeMode);
|
|
1597
|
+
}
|
|
1598
|
+
_setThemeMode(themeMode) {
|
|
1599
|
+
var _a;
|
|
1600
|
+
this.themeMode = themeMode;
|
|
1601
|
+
const container = (_a = this.rootElement) == null ? void 0 : _a.closest(".deck-widget-container");
|
|
1602
|
+
if (container) {
|
|
1603
|
+
const themeStyle = themeMode === "dark" ? this.props.darkModeTheme : this.props.lightModeTheme;
|
|
1604
|
+
(0, import_core15._applyStyles)(container, themeStyle);
|
|
1605
|
+
const label = this.themeMode === "dark" ? this.props.darkModeLabel : this.props.lightModeLabel;
|
|
1606
|
+
import_core15.log.log(1, `Switched theme to ${label}`, themeStyle)();
|
|
1780
1607
|
this.updateHTML();
|
|
1781
|
-
}
|
|
1782
|
-
|
|
1783
|
-
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
/** Read browser preference */
|
|
1611
|
+
_getInitialThemeMode() {
|
|
1612
|
+
const { initialThemeMode } = this.props;
|
|
1613
|
+
return initialThemeMode === "auto" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : initialThemeMode;
|
|
1614
|
+
}
|
|
1615
|
+
};
|
|
1616
|
+
ThemeWidget.defaultProps = {
|
|
1617
|
+
...import_core16.Widget.defaultProps,
|
|
1618
|
+
id: "theme",
|
|
1619
|
+
placement: "top-left",
|
|
1620
|
+
viewId: null,
|
|
1621
|
+
lightModeLabel: "Light Mode",
|
|
1622
|
+
lightModeTheme: LightGlassTheme,
|
|
1623
|
+
darkModeLabel: "Dark Mode",
|
|
1624
|
+
darkModeTheme: DarkGlassTheme,
|
|
1625
|
+
initialThemeMode: "auto"
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1628
|
+
// dist/loading-widget.js
|
|
1629
|
+
var import_jsx_runtime21 = require("preact/jsx-runtime");
|
|
1630
|
+
var import_preact15 = require("preact");
|
|
1631
|
+
var import_core17 = require("@deck.gl/core");
|
|
1632
|
+
var LoadingWidget = class extends import_core17.Widget {
|
|
1633
|
+
constructor(props = {}) {
|
|
1634
|
+
super(props, LoadingWidget.defaultProps);
|
|
1635
|
+
this.className = "deck-widget-loading";
|
|
1636
|
+
this.placement = "top-left";
|
|
1637
|
+
this.loading = true;
|
|
1638
|
+
this.setProps(this.props);
|
|
1784
1639
|
}
|
|
1785
1640
|
setProps(props) {
|
|
1641
|
+
this.placement = props.placement ?? this.placement;
|
|
1642
|
+
this.viewId = props.viewId ?? this.viewId;
|
|
1786
1643
|
super.setProps(props);
|
|
1644
|
+
}
|
|
1645
|
+
onRenderHTML(rootElement) {
|
|
1646
|
+
(0, import_preact15.render)(
|
|
1647
|
+
// TODO(ibgreen) - this should not be a button, but styling is so nested that it is easier to reuse this component.
|
|
1648
|
+
this.loading && (0, import_jsx_runtime21.jsx)(IconButton, { className: "deck-widget-spinner", label: this.props.label, onClick: this.handleClick.bind(this) }),
|
|
1649
|
+
rootElement
|
|
1650
|
+
);
|
|
1651
|
+
}
|
|
1652
|
+
onRedraw({ layers }) {
|
|
1653
|
+
const loading = layers.some((layer) => !layer.isLoaded);
|
|
1654
|
+
if (loading !== this.loading) {
|
|
1655
|
+
this.loading = loading;
|
|
1656
|
+
this.updateHTML();
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
// TODO(ibgreen) - this should not be a button, see above.
|
|
1660
|
+
handleClick() {
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
LoadingWidget.defaultProps = {
|
|
1664
|
+
...import_core17.Widget.defaultProps,
|
|
1665
|
+
id: "loading",
|
|
1666
|
+
placement: "top-left",
|
|
1667
|
+
viewId: null,
|
|
1668
|
+
label: "Loading layer data"
|
|
1669
|
+
};
|
|
1670
|
+
|
|
1671
|
+
// dist/fps-widget.js
|
|
1672
|
+
var import_jsx_runtime22 = require("preact/jsx-runtime");
|
|
1673
|
+
var import_core18 = require("@deck.gl/core");
|
|
1674
|
+
var import_preact16 = require("preact");
|
|
1675
|
+
var FpsWidget = class extends import_core18.Widget {
|
|
1676
|
+
constructor(props = {}) {
|
|
1677
|
+
super(props, FpsWidget.defaultProps);
|
|
1678
|
+
this.className = "deck-widget-fps";
|
|
1679
|
+
this.placement = "top-left";
|
|
1680
|
+
this._lastFps = -1;
|
|
1681
|
+
this.setProps(this.props);
|
|
1682
|
+
}
|
|
1683
|
+
setProps(props) {
|
|
1787
1684
|
this.placement = props.placement ?? this.placement;
|
|
1685
|
+
this.viewId = props.viewId ?? this.viewId;
|
|
1686
|
+
super.setProps(props);
|
|
1687
|
+
}
|
|
1688
|
+
onAdd({}) {
|
|
1689
|
+
this._lastFps = this._getFps();
|
|
1690
|
+
requestAnimationFrame(() => this._animate());
|
|
1788
1691
|
}
|
|
1789
1692
|
onRenderHTML(rootElement) {
|
|
1790
|
-
|
|
1693
|
+
const fps = this._getFps();
|
|
1694
|
+
(0, import_preact16.render)((0, import_jsx_runtime22.jsx)(IconButton, { children: (0, import_jsx_runtime22.jsxs)("div", { className: "text", children: ["FPS", (0, import_jsx_runtime22.jsx)("br", {}), fps] }) }), rootElement);
|
|
1695
|
+
}
|
|
1696
|
+
_animate() {
|
|
1697
|
+
const fps = this._getFps();
|
|
1698
|
+
if (this._lastFps !== fps) {
|
|
1699
|
+
this._lastFps = fps;
|
|
1700
|
+
this.updateHTML();
|
|
1701
|
+
}
|
|
1702
|
+
requestAnimationFrame(() => this._animate());
|
|
1703
|
+
}
|
|
1704
|
+
_getFps() {
|
|
1705
|
+
return Math.round(this.deck.metrics.fps ?? 0);
|
|
1791
1706
|
}
|
|
1792
1707
|
};
|
|
1793
|
-
|
|
1794
|
-
...
|
|
1795
|
-
id: "
|
|
1708
|
+
FpsWidget.defaultProps = {
|
|
1709
|
+
...import_core18.Widget.defaultProps,
|
|
1710
|
+
id: "fps",
|
|
1796
1711
|
placement: "top-left",
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1712
|
+
viewId: null
|
|
1713
|
+
};
|
|
1714
|
+
|
|
1715
|
+
// dist/stats-widget.js
|
|
1716
|
+
var import_jsx_runtime23 = require("preact/jsx-runtime");
|
|
1717
|
+
var import_core19 = require("@deck.gl/core");
|
|
1718
|
+
var import_core20 = require("@luma.gl/core");
|
|
1719
|
+
var import_preact17 = require("preact");
|
|
1720
|
+
var RIGHT_ARROW = "\u25B6";
|
|
1721
|
+
var DOWN_ARROW = "\u2B07";
|
|
1722
|
+
var DEFAULT_COUNT_FORMATTER = (stat) => `${stat.name}: ${stat.count}`;
|
|
1723
|
+
function formatTime(time) {
|
|
1724
|
+
return time < 1e3 ? `${time.toFixed(2)}ms` : `${(time / 1e3).toFixed(2)}s`;
|
|
1725
|
+
}
|
|
1726
|
+
function formatMemory(bytes) {
|
|
1727
|
+
const mb = bytes / 1e6;
|
|
1728
|
+
return `${mb.toFixed(1)} MB`;
|
|
1729
|
+
}
|
|
1730
|
+
var DEFAULT_FORMATTERS = {
|
|
1731
|
+
count: DEFAULT_COUNT_FORMATTER,
|
|
1732
|
+
averageTime: (stat) => `${stat.name}: ${formatTime(stat.getAverageTime())}`,
|
|
1733
|
+
totalTime: (stat) => `${stat.name}: ${formatTime(stat.time)}`,
|
|
1734
|
+
fps: (stat) => `${stat.name}: ${Math.round(stat.getHz())}fps`,
|
|
1735
|
+
memory: (stat) => `${stat.name}: ${formatMemory(stat.count)}`
|
|
1736
|
+
};
|
|
1737
|
+
var StatsWidget = class extends import_core19.Widget {
|
|
1738
|
+
constructor(props = {}) {
|
|
1739
|
+
super(props, StatsWidget.defaultProps);
|
|
1740
|
+
this.className = "deck-widget-stats";
|
|
1741
|
+
this.placement = "top-left";
|
|
1742
|
+
this._counter = 0;
|
|
1743
|
+
this.collapsed = true;
|
|
1744
|
+
this._toggleCollapsed = () => {
|
|
1745
|
+
this.collapsed = !this.collapsed;
|
|
1746
|
+
this.updateHTML();
|
|
1747
|
+
};
|
|
1748
|
+
this._formatters = { ...DEFAULT_FORMATTERS };
|
|
1749
|
+
this._resetOnUpdate = { ...this.props.resetOnUpdate };
|
|
1750
|
+
this._stats = this.props.stats;
|
|
1751
|
+
this.setProps(props);
|
|
1752
|
+
}
|
|
1753
|
+
setProps(props) {
|
|
1754
|
+
this.placement = props.placement ?? this.placement;
|
|
1755
|
+
this.viewId = props.viewId ?? this.viewId;
|
|
1756
|
+
this._stats = this._getStats();
|
|
1757
|
+
if (props.formatters) {
|
|
1758
|
+
for (const name in props.formatters) {
|
|
1759
|
+
const f = props.formatters[name];
|
|
1760
|
+
this._formatters[name] = typeof f === "string" ? DEFAULT_FORMATTERS[f] || DEFAULT_COUNT_FORMATTER : f;
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
if (props.resetOnUpdate) {
|
|
1764
|
+
this._resetOnUpdate = { ...props.resetOnUpdate };
|
|
1765
|
+
}
|
|
1766
|
+
super.setProps(props);
|
|
1767
|
+
}
|
|
1768
|
+
onAdd() {
|
|
1769
|
+
this._stats = this._getStats();
|
|
1770
|
+
this.updateHTML();
|
|
1771
|
+
}
|
|
1772
|
+
onRenderHTML(rootElement) {
|
|
1773
|
+
const stats = this._stats;
|
|
1774
|
+
const collapsed = this.collapsed;
|
|
1775
|
+
const title = this.props.title || (stats == null ? void 0 : stats.id) || "Stats";
|
|
1776
|
+
const items = [];
|
|
1777
|
+
if (!collapsed && stats) {
|
|
1778
|
+
stats.forEach((stat) => {
|
|
1779
|
+
const lines = this._getLines(stat);
|
|
1780
|
+
if (this._resetOnUpdate && this._resetOnUpdate[stat.name]) {
|
|
1781
|
+
stat.reset();
|
|
1782
|
+
}
|
|
1783
|
+
lines.forEach((line, i) => {
|
|
1784
|
+
items.push((0, import_jsx_runtime23.jsx)("div", { style: { whiteSpace: "pre" }, children: line }, `${stat.name}-${i}`));
|
|
1785
|
+
});
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1788
|
+
(0, import_preact17.render)((0, import_jsx_runtime23.jsxs)("div", { className: "deck-widget-stats-container", style: { cursor: "default" }, children: [(0, import_jsx_runtime23.jsxs)("div", { className: "deck-widget-stats-header", style: { cursor: "pointer", pointerEvents: "auto" }, onClick: this._toggleCollapsed, children: [collapsed ? RIGHT_ARROW : DOWN_ARROW, " ", title] }), !collapsed && (0, import_jsx_runtime23.jsx)("div", { className: "deck-widget-stats-content", children: items })] }), rootElement);
|
|
1789
|
+
}
|
|
1790
|
+
onRedraw() {
|
|
1791
|
+
const framesPerUpdate = Math.max(1, this.props.framesPerUpdate || 1);
|
|
1792
|
+
if (this._counter++ % framesPerUpdate === 0) {
|
|
1793
|
+
this._stats = this._getStats();
|
|
1794
|
+
this.updateHTML();
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
_getStats() {
|
|
1798
|
+
var _a, _b;
|
|
1799
|
+
switch (this.props.type) {
|
|
1800
|
+
case "deck":
|
|
1801
|
+
return (_a = this.deck) == null ? void 0 : _a.stats;
|
|
1802
|
+
case "luma":
|
|
1803
|
+
return Array.from(import_core20.luma.stats.stats.values())[0];
|
|
1804
|
+
case "device":
|
|
1805
|
+
const device = (_b = this.deck) == null ? void 0 : _b.device;
|
|
1806
|
+
const stats = device == null ? void 0 : device.statsManager.stats.values();
|
|
1807
|
+
return stats ? Array.from(stats)[0] : void 0;
|
|
1808
|
+
case "custom":
|
|
1809
|
+
return this.props.stats;
|
|
1810
|
+
default:
|
|
1811
|
+
throw new Error(`Unknown stats type: ${this.props.type}`);
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
_getLines(stat) {
|
|
1815
|
+
const formatter = this._formatters[stat.name] || this._formatters[stat.type || ""] || DEFAULT_COUNT_FORMATTER;
|
|
1816
|
+
return formatter(stat).split("\n");
|
|
1801
1817
|
}
|
|
1802
1818
|
};
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1819
|
+
StatsWidget.defaultProps = {
|
|
1820
|
+
...import_core19.Widget.defaultProps,
|
|
1821
|
+
type: "deck",
|
|
1822
|
+
placement: "top-left",
|
|
1823
|
+
viewId: null,
|
|
1824
|
+
stats: void 0,
|
|
1825
|
+
title: "Stats",
|
|
1826
|
+
framesPerUpdate: 1,
|
|
1827
|
+
formatters: {},
|
|
1828
|
+
resetOnUpdate: {},
|
|
1829
|
+
id: "stats"
|
|
1808
1830
|
};
|
|
1809
|
-
var MENU_ITEMS = [
|
|
1810
|
-
{ value: "single", icon: ICONS.single, label: "Single View" },
|
|
1811
|
-
{ value: "split-horizontal", icon: ICONS["split-horizontal"], label: "Split Horizontal" },
|
|
1812
|
-
{ value: "split-vertical", icon: ICONS["split-vertical"], label: "Split Vertical" }
|
|
1813
|
-
];
|
|
1814
1831
|
//# sourceMappingURL=index.cjs.map
|