@deck.gl/react 9.1.0-beta.3 → 9.1.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.
Files changed (43) hide show
  1. package/dist/deckgl.d.ts +1 -1
  2. package/dist/deckgl.d.ts.map +1 -1
  3. package/dist/deckgl.js +1 -0
  4. package/dist/deckgl.js.map +1 -1
  5. package/dist/index.cjs +93 -31
  6. package/dist/index.cjs.map +4 -4
  7. package/dist/index.d.ts +5 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +5 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/utils/deckgl-context.d.ts +12 -0
  12. package/dist/utils/deckgl-context.d.ts.map +1 -0
  13. package/dist/utils/deckgl-context.js +4 -0
  14. package/dist/utils/deckgl-context.js.map +1 -0
  15. package/dist/utils/position-children-under-views.d.ts +2 -8
  16. package/dist/utils/position-children-under-views.d.ts.map +1 -1
  17. package/dist/utils/position-children-under-views.js +18 -17
  18. package/dist/utils/position-children-under-views.js.map +1 -1
  19. package/dist/utils/use-widget.d.ts +5 -0
  20. package/dist/utils/use-widget.d.ts.map +1 -0
  21. package/dist/utils/use-widget.js +32 -0
  22. package/dist/utils/use-widget.js.map +1 -0
  23. package/dist/widgets/compass-widget.d.ts +3 -0
  24. package/dist/widgets/compass-widget.d.ts.map +1 -0
  25. package/dist/widgets/compass-widget.js +7 -0
  26. package/dist/widgets/compass-widget.js.map +1 -0
  27. package/dist/widgets/fullscreen-widget.d.ts +3 -0
  28. package/dist/widgets/fullscreen-widget.d.ts.map +1 -0
  29. package/dist/widgets/fullscreen-widget.js +7 -0
  30. package/dist/widgets/fullscreen-widget.js.map +1 -0
  31. package/dist/widgets/zoom-widget.d.ts +3 -0
  32. package/dist/widgets/zoom-widget.d.ts.map +1 -0
  33. package/dist/widgets/zoom-widget.js +7 -0
  34. package/dist/widgets/zoom-widget.js.map +1 -0
  35. package/package.json +4 -3
  36. package/src/deckgl.ts +2 -1
  37. package/src/index.ts +7 -1
  38. package/src/utils/deckgl-context.ts +15 -0
  39. package/src/utils/position-children-under-views.ts +19 -27
  40. package/src/utils/use-widget.ts +39 -0
  41. package/src/widgets/compass-widget.tsx +8 -0
  42. package/src/widgets/fullscreen-widget.tsx +8 -0
  43. package/src/widgets/zoom-widget.tsx +8 -0
package/dist/deckgl.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { Deck } from '@deck.gl/core';
3
3
  import { DeckGLRenderCallback } from "./utils/extract-jsx-layers.js";
4
- import type { DeckGLContextValue } from "./utils/position-children-under-views.js";
4
+ import type { DeckGLContextValue } from "./utils/deckgl-context.js";
5
5
  import type { DeckProps, View } from '@deck.gl/core';
6
6
  export type ViewOrViews = View | View[] | null;
7
7
  /** DeckGL React component props */
@@ -1 +1 @@
1
- {"version":3,"file":"deckgl.d.ts","sourceRoot":"","sources":["../src/deckgl.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AAGnC,OAAyB,EAAC,oBAAoB,EAAC,sCAAmC;AAIlF,OAAO,KAAK,EAAC,kBAAkB,EAAC,iDAA8C;AAC9E,OAAO,KAAK,EAAC,SAAS,EAAE,IAAI,EAAW,MAAM,eAAe,CAAC;AAE7D,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;AAe/C,mCAAmC;AACnC,MAAM,MAAM,WAAW,CAAC,MAAM,SAAS,WAAW,GAAG,IAAI,IAAI,IAAI,CAC/D,SAAS,CAAC,MAAM,CAAC,EACjB,OAAO,GAAG,QAAQ,GAAG,IAAI,GAAG,QAAQ,GAAG,QAAQ,GAAG,eAAe,CAClE,GAAG;IACF,IAAI,CAAC,EAAE,OAAO,IAAI,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,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OAAO,GAAG,QAAQ,GAAG,IAAI,GAAG,QAAQ,GAAG,QAAQ,GAAG,eAAe,CAClE,GAAG;IACF,IAAI,CAAC,EAAE,OAAO,IAAI,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,oBAAoB,CAAC;IAClD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IACnC,eAAe,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,UAAU,CAAC,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,MAAM,SAAS,WAAW,GAAG,IAAI,IAAI;IACzD,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACpB,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC/B,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACjC,mBAAmB,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC;CAClD,CAAC;AAuNF,QAAA,MAAM,MAAM,EAAsC,CAAC,MAA0B,SAAX,WAAW,EAC3E,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,KACvB,KAAK,CAAC,YAAY,CAAC;AAExB,eAAe,MAAM,CAAC"}
package/dist/deckgl.js CHANGED
@@ -97,6 +97,7 @@ function DeckGLWithRef(props, ref) {
97
97
  // Needs to be called both from initial mount, and when new props are received
98
98
  const deckProps = useMemo(() => {
99
99
  const forwardProps = {
100
+ widgets: [],
100
101
  ...props,
101
102
  // Override user styling props. We will set the canvas style in render()
102
103
  style: null,
@@ -1 +1 @@
1
- {"version":3,"file":"deckgl.js","sourceRoot":"","sources":["../src/deckgl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AA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AAM,EAAE,kBAAkB,CAAC,CAC7B,CAAC;IACJ,CAAC;IAED,QAAQ,GAAG,KAAK,CAAC;IACjB,OAAO,OAAO,CAAC,OAAO,CAAC;AACzB,CAAC;AAED,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,aAAa,CAEtB,CAAC;AAExB,eAAe,MAAM,CAAC"}
package/dist/index.cjs CHANGED
@@ -30,14 +30,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // dist/index.js
31
31
  var dist_exports = {};
32
32
  __export(dist_exports, {
33
+ CompassWidget: () => CompassWidget,
33
34
  DeckGL: () => deckgl_default,
34
- default: () => deckgl_default
35
+ FullscreenWidget: () => FullscreenWidget,
36
+ ZoomWidget: () => ZoomWidget,
37
+ default: () => deckgl_default,
38
+ useWidget: () => useWidget
35
39
  });
36
40
  module.exports = __toCommonJS(dist_exports);
37
41
 
38
42
  // dist/deckgl.js
39
43
  var React2 = __toESM(require("react"), 1);
40
- var import_react5 = require("react");
44
+ var import_react6 = require("react");
41
45
  var import_core3 = require("@deck.gl/core");
42
46
 
43
47
  // dist/utils/use-isomorphic-layout-effect.js
@@ -160,9 +164,15 @@ function createLayer(LayerType, reactProps) {
160
164
  }
161
165
 
162
166
  // dist/utils/position-children-under-views.js
163
- var import_react4 = require("react");
167
+ var import_react5 = require("react");
164
168
  var import_core2 = require("@deck.gl/core");
165
- function positionChildrenUnderViews({ children, deck, ContextProvider }) {
169
+
170
+ // dist/utils/deckgl-context.js
171
+ var import_react4 = require("react");
172
+ var DeckGlContext = (0, import_react4.createContext)();
173
+
174
+ // dist/utils/position-children-under-views.js
175
+ function positionChildrenUnderViews({ children, deck, ContextProvider = DeckGlContext.Provider }) {
166
176
  const { viewManager } = deck || {};
167
177
  if (!viewManager || !viewManager.views.length) {
168
178
  return [];
@@ -209,22 +219,22 @@ function positionChildrenUnderViews({ children, deck, ContextProvider }) {
209
219
  height
210
220
  };
211
221
  const key = `view-${viewId}`;
212
- const viewElement = (0, import_react4.createElement)("div", { key, id: key, style }, ...viewChildren);
213
- if (ContextProvider) {
214
- const contextValue = {
215
- viewport,
216
- // @ts-expect-error accessing protected property
217
- container: deck.canvas.offsetParent,
218
- // @ts-expect-error accessing protected property
219
- eventManager: deck.eventManager,
220
- onViewStateChange: (params) => {
221
- params.viewId = viewId;
222
- deck._onViewStateChange(params);
223
- }
224
- };
225
- return (0, import_react4.createElement)(ContextProvider, { key, value: contextValue }, viewElement);
226
- }
227
- return viewElement;
222
+ const viewElement = (0, import_react5.createElement)("div", { key, id: key, style }, ...viewChildren);
223
+ const contextValue = {
224
+ deck,
225
+ viewport,
226
+ // @ts-expect-error accessing protected property
227
+ container: deck.canvas.offsetParent,
228
+ // @ts-expect-error accessing protected property
229
+ eventManager: deck.eventManager,
230
+ onViewStateChange: (params) => {
231
+ params.viewId = viewId;
232
+ deck._onViewStateChange(params);
233
+ },
234
+ widgets: []
235
+ };
236
+ const providerKey = `view-${viewId}-context`;
237
+ return (0, import_react5.createElement)(ContextProvider, { key: providerKey, value: contextValue }, viewElement);
228
238
  });
229
239
  }
230
240
 
@@ -294,16 +304,16 @@ function createDeckInstance(thisRef, DeckClass, props) {
294
304
  return deck;
295
305
  }
296
306
  function DeckGLWithRef(props, ref) {
297
- const [version, setVersion] = (0, import_react5.useState)(0);
298
- const _thisRef = (0, import_react5.useRef)({
307
+ const [version, setVersion] = (0, import_react6.useState)(0);
308
+ const _thisRef = (0, import_react6.useRef)({
299
309
  control: null,
300
310
  version,
301
311
  forceUpdate: () => setVersion((v) => v + 1)
302
312
  });
303
313
  const thisRef = _thisRef.current;
304
- const containerRef = (0, import_react5.useRef)(null);
305
- const canvasRef = (0, import_react5.useRef)(null);
306
- const jsxProps = (0, import_react5.useMemo)(() => extractJSXLayers(props), [props.layers, props.views, props.children]);
314
+ const containerRef = (0, import_react6.useRef)(null);
315
+ const canvasRef = (0, import_react6.useRef)(null);
316
+ const jsxProps = (0, import_react6.useMemo)(() => extractJSXLayers(props), [props.layers, props.views, props.children]);
307
317
  let inRender = true;
308
318
  const handleViewStateChange = (params) => {
309
319
  var _a;
@@ -323,8 +333,9 @@ function DeckGLWithRef(props, ref) {
323
333
  (_a = props.onInteractionStateChange) == null ? void 0 : _a.call(props, params);
324
334
  }
325
335
  };
326
- const deckProps = (0, import_react5.useMemo)(() => {
336
+ const deckProps = (0, import_react6.useMemo)(() => {
327
337
  const forwardProps = {
338
+ widgets: [],
328
339
  ...props,
329
340
  // Override user styling props. We will set the canvas style in render()
330
341
  style: null,
@@ -343,7 +354,7 @@ function DeckGLWithRef(props, ref) {
343
354
  }
344
355
  return forwardProps;
345
356
  }, [props]);
346
- (0, import_react5.useEffect)(() => {
357
+ (0, import_react6.useEffect)(() => {
347
358
  const DeckClass = props.Deck || import_core3.Deck;
348
359
  thisRef.deck = createDeckInstance(thisRef, DeckClass, {
349
360
  ...deckProps,
@@ -365,10 +376,10 @@ function DeckGLWithRef(props, ref) {
365
376
  handleInteractionStateChange(interactionStateUpdateRequested);
366
377
  }
367
378
  });
368
- (0, import_react5.useImperativeHandle)(ref, () => getRefHandles(thisRef), []);
379
+ (0, import_react6.useImperativeHandle)(ref, () => getRefHandles(thisRef), []);
369
380
  const currentViewports = thisRef.deck && thisRef.deck.isInitialized ? thisRef.deck.getViewports() : void 0;
370
381
  const { ContextProvider, width = "100%", height = "100%", id, style } = props;
371
- const { containerStyle, canvasStyle } = (0, import_react5.useMemo)(() => extractStyles({ width, height, style }), [width, height, style]);
382
+ const { containerStyle, canvasStyle } = (0, import_react6.useMemo)(() => extractStyles({ width, height, style }), [width, height, style]);
372
383
  if (!thisRef.viewStateUpdateRequested && thisRef.lastRenderedViewports === currentViewports || // case 2
373
384
  thisRef.version !== version) {
374
385
  thisRef.lastRenderedViewports = currentViewports;
@@ -378,17 +389,68 @@ function DeckGLWithRef(props, ref) {
378
389
  deck: thisRef.deck,
379
390
  ContextProvider
380
391
  });
381
- const canvas = (0, import_react5.createElement)("canvas", {
392
+ const canvas = (0, import_react6.createElement)("canvas", {
382
393
  key: "canvas",
383
394
  id: id || "deckgl-overlay",
384
395
  ref: canvasRef,
385
396
  style: canvasStyle
386
397
  });
387
- thisRef.control = (0, import_react5.createElement)("div", { id: `${id || "deckgl"}-wrapper`, ref: containerRef, style: containerStyle }, [canvas, childrenUnderViews]);
398
+ thisRef.control = (0, import_react6.createElement)("div", { id: `${id || "deckgl"}-wrapper`, ref: containerRef, style: containerStyle }, [canvas, childrenUnderViews]);
388
399
  }
389
400
  inRender = false;
390
401
  return thisRef.control;
391
402
  }
392
403
  var DeckGL = React2.forwardRef(DeckGLWithRef);
393
404
  var deckgl_default = DeckGL;
405
+
406
+ // dist/widgets/compass-widget.js
407
+ var import_widgets = require("@deck.gl/widgets");
408
+
409
+ // dist/utils/use-widget.js
410
+ var import_react7 = require("react");
411
+ var import_core4 = require("@deck.gl/core");
412
+ function useWidget(WidgetClass, props) {
413
+ const context = (0, import_react7.useContext)(DeckGlContext);
414
+ const { widgets, deck } = context;
415
+ (0, import_react7.useEffect)(() => {
416
+ const internalWidgets = deck == null ? void 0 : deck.props.widgets;
417
+ if ((widgets == null ? void 0 : widgets.length) && (internalWidgets == null ? void 0 : internalWidgets.length) && !(0, import_core4._deepEqual)(internalWidgets, widgets, 1)) {
418
+ import_core4.log.warn('"widgets" prop will be ignored because React widgets are in use.')();
419
+ }
420
+ return () => {
421
+ const index = widgets == null ? void 0 : widgets.indexOf(widget);
422
+ if (index && index !== -1) {
423
+ widgets == null ? void 0 : widgets.splice(index, 1);
424
+ deck == null ? void 0 : deck.setProps({ widgets });
425
+ }
426
+ };
427
+ }, []);
428
+ const widget = (0, import_react7.useMemo)(() => new WidgetClass(props), [WidgetClass]);
429
+ widgets == null ? void 0 : widgets.push(widget);
430
+ widget.setProps(props);
431
+ (0, import_react7.useEffect)(() => {
432
+ deck == null ? void 0 : deck.setProps({ widgets });
433
+ }, [widgets]);
434
+ return widget;
435
+ }
436
+
437
+ // dist/widgets/compass-widget.js
438
+ var CompassWidget = (props = {}) => {
439
+ const widget = useWidget(import_widgets.CompassWidget, props);
440
+ return null;
441
+ };
442
+
443
+ // dist/widgets/fullscreen-widget.js
444
+ var import_widgets2 = require("@deck.gl/widgets");
445
+ var FullscreenWidget = (props = {}) => {
446
+ const widget = useWidget(import_widgets2.FullscreenWidget, props);
447
+ return null;
448
+ };
449
+
450
+ // dist/widgets/zoom-widget.js
451
+ var import_widgets3 = require("@deck.gl/widgets");
452
+ var ZoomWidget = (props = {}) => {
453
+ const widget = useWidget(import_widgets3.ZoomWidget, props);
454
+ return null;
455
+ };
394
456
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/index.ts", "../src/deckgl.ts", "../src/utils/use-isomorphic-layout-effect.ts", "../src/utils/extract-jsx-layers.ts", "../src/utils/inherits-from.ts", "../src/utils/evaluate-children.ts", "../src/utils/position-children-under-views.ts", "../src/utils/extract-styles.ts"],
4
- "sourcesContent": ["// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport {default as DeckGL} from './deckgl';\nexport {default} from './deckgl';\n\n// Types\nexport type {DeckGLContextValue} from './utils/position-children-under-views';\nexport type {DeckGLRef, DeckGLProps} from './deckgl';\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as React from 'react';\nimport {createElement, useRef, useState, useMemo, useEffect, useImperativeHandle} from 'react';\nimport {Deck} from '@deck.gl/core';\nimport useIsomorphicLayoutEffect from './utils/use-isomorphic-layout-effect';\n\nimport extractJSXLayers, {DeckGLRenderCallback} from './utils/extract-jsx-layers';\nimport positionChildrenUnderViews from './utils/position-children-under-views';\nimport extractStyles from './utils/extract-styles';\n\nimport type {DeckGLContextValue} from './utils/position-children-under-views';\nimport type {DeckProps, View, Viewport} from '@deck.gl/core';\n\nexport type ViewOrViews = View | View[] | null;\n\n/* eslint-disable max-statements, accessor-pairs */\ntype DeckInstanceRef<ViewsT extends ViewOrViews> = {\n deck?: Deck<ViewsT>;\n redrawReason?: string | null;\n lastRenderedViewports?: Viewport[];\n viewStateUpdateRequested?: any;\n interactionStateUpdateRequested?: any;\n forceUpdate: () => void;\n version: number;\n control: React.ReactHTMLElement<HTMLElement> | null;\n};\n\n// Remove prop types in the base Deck class that support externally supplied canvas/WebGLContext\n/** DeckGL React component props */\nexport type DeckGLProps<ViewsT extends ViewOrViews = null> = Omit<\n DeckProps<ViewsT>,\n 'width' | 'height' | 'gl' | 'parent' | 'canvas' | '_customRender'\n> & {\n Deck?: typeof Deck;\n width?: string | number;\n height?: string | number;\n children?: React.ReactNode | DeckGLRenderCallback;\n ref?: React.Ref<DeckGLRef<ViewsT>>;\n ContextProvider?: React.Context<DeckGLContextValue>['Provider'];\n};\n\nexport type DeckGLRef<ViewsT extends ViewOrViews = null> = {\n deck?: Deck<ViewsT>;\n pickObject: Deck['pickObject'];\n pickObjects: Deck['pickObjects'];\n pickMultipleObjects: Deck['pickMultipleObjects'];\n};\n\nfunction getRefHandles<ViewsT extends ViewOrViews>(\n thisRef: DeckInstanceRef<ViewsT>\n): DeckGLRef<ViewsT> {\n return {\n get deck() {\n return thisRef.deck;\n },\n // The following method can only be called after ref is available, by which point deck is defined in useEffect\n pickObject: opts => thisRef.deck!.pickObject(opts),\n pickMultipleObjects: opts => thisRef.deck!.pickMultipleObjects(opts),\n pickObjects: opts => thisRef.deck!.pickObjects(opts)\n };\n}\n\nfunction redrawDeck(thisRef: DeckInstanceRef<any>) {\n if (thisRef.redrawReason) {\n // Only redraw if we have received a dirty flag\n // @ts-expect-error accessing protected method\n thisRef.deck._drawLayers(thisRef.redrawReason);\n thisRef.redrawReason = null;\n }\n}\n\nfunction createDeckInstance<ViewsT extends ViewOrViews>(\n thisRef: DeckInstanceRef<ViewsT>,\n DeckClass: typeof Deck,\n props: DeckProps<ViewsT>\n): Deck<ViewsT> {\n const deck = new DeckClass({\n ...props,\n // The Deck's animation loop is independent from React's render cycle, causing potential\n // synchronization issues. We provide this custom render function to make sure that React\n // and Deck update on the same schedule.\n _customRender: redrawReason => {\n // Save the dirty flag for later\n thisRef.redrawReason = redrawReason;\n\n // Viewport/view state is passed to child components as props.\n // If they have changed, we need to trigger a React rerender to update children props.\n const viewports = deck.getViewports();\n if (thisRef.lastRenderedViewports !== viewports) {\n // Viewports have changed, update children props first.\n // This will delay the Deck canvas redraw till after React update (in useLayoutEffect)\n // so that the canvas does not get rendered before the child components update.\n thisRef.forceUpdate();\n } else {\n redrawDeck(thisRef);\n }\n }\n });\n return deck;\n}\n\nfunction DeckGLWithRef<ViewsT extends ViewOrViews = null>(\n props: DeckGLProps<ViewsT>,\n ref: React.Ref<DeckGLRef<ViewsT>>\n) {\n // A mechanism to force redraw\n const [version, setVersion] = useState(0);\n // A reference to persistent states\n const _thisRef = useRef<DeckInstanceRef<ViewsT>>({\n control: null,\n version,\n forceUpdate: () => setVersion(v => v + 1)\n });\n const thisRef = _thisRef.current;\n // DOM refs\n const containerRef = useRef(null);\n const canvasRef = useRef(null);\n\n // extract any deck.gl layers masquerading as react elements from props.children\n const jsxProps = useMemo(\n () => extractJSXLayers(props),\n [props.layers, props.views, props.children]\n );\n\n // Callbacks\n let inRender = true;\n\n const handleViewStateChange: DeckProps<ViewsT>['onViewStateChange'] = params => {\n if (inRender && props.viewState) {\n // Callback may invoke a state update. Defer callback to after render() to avoid React error\n // In React StrictMode, render is executed twice and useEffect/useLayoutEffect is executed once\n // Store deferred parameters in ref so that we can access it in another render\n thisRef.viewStateUpdateRequested = params;\n return null;\n }\n thisRef.viewStateUpdateRequested = null;\n return props.onViewStateChange?.(params);\n };\n\n const handleInteractionStateChange: DeckProps<ViewsT>['onInteractionStateChange'] = params => {\n if (inRender) {\n // Callback may invoke a state update. Defer callback to after render() to avoid React error\n // In React StrictMode, render is executed twice and useEffect/useLayoutEffect is executed once\n // Store deferred parameters in ref so that we can access it in another render\n thisRef.interactionStateUpdateRequested = params;\n } else {\n thisRef.interactionStateUpdateRequested = null;\n props.onInteractionStateChange?.(params);\n }\n };\n\n // Update Deck's props. If Deck needs redraw, this will trigger a call to `_customRender` in\n // the next animation frame.\n // Needs to be called both from initial mount, and when new props are received\n const deckProps = useMemo(() => {\n const forwardProps: DeckProps<ViewsT> = {\n ...props,\n // Override user styling props. We will set the canvas style in render()\n style: null,\n width: '100%',\n height: '100%',\n parent: containerRef.current,\n canvas: canvasRef.current,\n layers: jsxProps.layers,\n views: jsxProps.views as ViewsT,\n onViewStateChange: handleViewStateChange,\n onInteractionStateChange: handleInteractionStateChange\n };\n\n // The defaultValue for _customRender is null, which would overwrite the definition\n // of _customRender. Remove to avoid frequently redeclaring the method here.\n delete forwardProps._customRender;\n\n if (thisRef.deck) {\n thisRef.deck.setProps(forwardProps);\n }\n\n return forwardProps;\n }, [props]);\n\n useEffect(() => {\n const DeckClass = props.Deck || Deck;\n\n thisRef.deck = createDeckInstance(thisRef, DeckClass, {\n ...deckProps,\n parent: containerRef.current,\n canvas: canvasRef.current\n });\n\n return () => thisRef.deck?.finalize();\n }, []);\n\n useIsomorphicLayoutEffect(() => {\n // render has just been called. The children are positioned based on the current view state.\n // Redraw Deck canvas immediately, if necessary, using the current view state, so that it\n // matches the child components.\n redrawDeck(thisRef);\n\n // Execute deferred callbacks\n const {viewStateUpdateRequested, interactionStateUpdateRequested} = thisRef;\n if (viewStateUpdateRequested) {\n handleViewStateChange(viewStateUpdateRequested);\n }\n if (interactionStateUpdateRequested) {\n handleInteractionStateChange(interactionStateUpdateRequested);\n }\n });\n\n useImperativeHandle(ref, () => getRefHandles(thisRef), []);\n\n const currentViewports =\n thisRef.deck && thisRef.deck.isInitialized ? thisRef.deck.getViewports() : undefined;\n\n const {ContextProvider, width = '100%', height = '100%', id, style} = props;\n\n const {containerStyle, canvasStyle} = useMemo(\n () => extractStyles({width, height, style}),\n [width, height, style]\n );\n\n // Props changes may lead to 3 types of updates:\n // 1. Only the WebGL canvas - updated in Deck's render cycle (next animation frame)\n // 2. Only the DOM - updated in React's lifecycle (now)\n // 3. Both the WebGL canvas and the DOM - defer React rerender to next animation frame just\n // before Deck redraw to ensure perfect synchronization & avoid excessive redraw\n // This is because multiple changes may happen to Deck between two frames e.g. transition\n if (\n (!thisRef.viewStateUpdateRequested && thisRef.lastRenderedViewports === currentViewports) || // case 2\n thisRef.version !== version // case 3 just before deck redraws\n ) {\n thisRef.lastRenderedViewports = currentViewports;\n thisRef.version = version;\n\n // Render the background elements (typically react-map-gl instances)\n // using the view descriptors\n const childrenUnderViews = positionChildrenUnderViews({\n children: jsxProps.children,\n deck: thisRef.deck,\n ContextProvider\n });\n\n const canvas = createElement('canvas', {\n key: 'canvas',\n id: id || 'deckgl-overlay',\n ref: canvasRef,\n style: canvasStyle\n });\n\n // Render deck.gl as the last child\n thisRef.control = createElement(\n 'div',\n {id: `${id || 'deckgl'}-wrapper`, ref: containerRef, style: containerStyle},\n [canvas, childrenUnderViews]\n );\n }\n\n inRender = false;\n return thisRef.control;\n}\n\nconst DeckGL = React.forwardRef(DeckGLWithRef) as <ViewsT extends ViewOrViews>(\n props: DeckGLProps<ViewsT>\n) => React.ReactElement;\n\nexport default DeckGL;\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// From https://github.com/streamich/react-use/blob/master/src/useIsomorphicLayoutEffect.ts\n// useLayoutEffect but does not trigger warning in server-side rendering\nimport {useEffect, useLayoutEffect} from 'react';\n\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\nexport default useIsomorphicLayoutEffect;\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as React from 'react';\nimport {createElement} from 'react';\nimport {inheritsFrom} from './inherits-from';\nimport {Layer, View} from '@deck.gl/core';\nimport {isComponent} from './evaluate-children';\nimport type {LayersList, Viewport} from '@deck.gl/core';\n\nexport type DeckGLRenderCallbackArgs = {\n /**\n * the left offset of the current view, in pixels\n */\n x: number;\n /**\n * the top offset of the current view, in pixels\n */\n y: number;\n /**\n * the width of the current view, in pixels\n */\n width: number;\n /**\n * the height of the current view, in pixels\n */\n height: number;\n /**\n * the view state of the current view\n */\n viewState: any;\n /**\n * the `Viewport` instance of the current view\n */\n viewport: Viewport;\n};\n\nexport type DeckGLRenderCallback = (args: DeckGLRenderCallbackArgs) => React.ReactNode;\n\n// recursively wrap render callbacks in `View`\nfunction wrapInView(node: React.ReactNode | DeckGLRenderCallback): React.ReactNode {\n if (typeof node === 'function') {\n // React.Children does not traverse functions.\n // All render callbacks must be protected under a <View>\n // @ts-expect-error View is not a ReactJSXElement constructor. Only used as a temporary wrapper and will be removed in extractJSXLayers\n return createElement(View, {}, node);\n }\n if (Array.isArray(node)) {\n return node.map(wrapInView);\n }\n if (isComponent(node)) {\n if (node.type === React.Fragment) {\n return wrapInView(node.props.children);\n }\n if (inheritsFrom(node.type, View)) {\n return node;\n }\n }\n return node;\n}\n\n// extracts any deck.gl layers masquerading as react elements from props.children\nexport default function extractJSXLayers({\n children,\n layers = [],\n views = null\n}: {\n children?: React.ReactNode | DeckGLRenderCallback;\n layers?: LayersList;\n views?: View | View[] | null;\n}): {\n children: React.ReactNode[];\n layers: LayersList;\n views: View | View[] | null;\n} {\n const reactChildren: React.ReactNode[] = []; // extract real react elements (i.e. not deck.gl layers)\n const jsxLayers: LayersList = []; // extracted layer from react children, will add to deck.gl layer array\n const jsxViews: Record<string, View> = {};\n\n // React.children\n React.Children.forEach(wrapInView(children), reactElement => {\n if (isComponent(reactElement)) {\n // For some reason Children.forEach doesn't filter out `null`s\n const ElementType = reactElement.type;\n if (inheritsFrom(ElementType, Layer)) {\n const layer = createLayer(ElementType, reactElement.props);\n jsxLayers.push(layer);\n } else {\n reactChildren.push(reactElement);\n }\n\n // empty id => default view\n if (inheritsFrom(ElementType, View) && ElementType !== View && reactElement.props.id) {\n // @ts-ignore Cannot instantiate an abstract class (View)\n const view = new ElementType(reactElement.props);\n jsxViews[view.id] = view;\n }\n } else if (reactElement) {\n reactChildren.push(reactElement);\n }\n });\n\n // Avoid modifying views if no JSX views were found\n if (Object.keys(jsxViews).length > 0) {\n // If a view is specified in both views prop and JSX, use the one in views\n if (Array.isArray(views)) {\n views.forEach(view => {\n jsxViews[view.id] = view;\n });\n } else if (views) {\n jsxViews[views.id] = views;\n }\n views = Object.values(jsxViews);\n }\n\n // Avoid modifying layers array if no JSX layers were found\n layers = jsxLayers.length > 0 ? [...jsxLayers, ...layers] : layers;\n\n return {layers, children: reactChildren, views};\n}\n\nfunction createLayer(LayerType: typeof Layer, reactProps: any): Layer {\n const props = {};\n // Layer.defaultProps is treated as ReactElement.defaultProps and merged into react props\n // Remove them\n const defaultProps = LayerType.defaultProps || {};\n for (const key in reactProps) {\n if (defaultProps[key] !== reactProps[key]) {\n props[key] = reactProps[key];\n }\n }\n // @ts-ignore Cannot instantiate an abstract class (Layer)\n return new LayerType(props);\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Check if one JavaScript class inherits from another\nexport function inheritsFrom<T>(Type: any, ParentType: T): Type is T {\n while (Type) {\n if (Type === ParentType) {\n return true;\n }\n Type = Object.getPrototypeOf(Type);\n }\n return false;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as React from 'react';\nimport {cloneElement} from 'react';\n\nconst MAP_STYLE = {position: 'absolute', zIndex: -1};\n\nexport default function evaluateChildren(\n children: React.ReactNode | Function,\n childProps: any\n): React.ReactNode {\n if (typeof children === 'function') {\n return children(childProps);\n }\n if (Array.isArray(children)) {\n return children.map(child => evaluateChildren(child, childProps));\n }\n if (isComponent(children)) {\n // Special treatment for react-map-gl's Map component\n // to support shorthand use case <DeckGL><StaticMap /></DeckGL>\n if (isReactMap(children)) {\n // Place map under the canvas\n childProps.style = MAP_STYLE;\n return cloneElement(children, childProps);\n }\n if (needsDeckGLViewProps(children)) {\n return cloneElement(children, childProps);\n }\n }\n\n return children;\n}\n\nexport function isComponent(child: React.ReactNode): child is React.ReactElement {\n return (child && typeof child === 'object' && 'type' in child) || false;\n}\n\nfunction isReactMap(child: React.ReactElement): boolean {\n return child.props?.mapStyle;\n}\n\nfunction needsDeckGLViewProps(child: React.ReactElement): boolean {\n const componentClass = child.type;\n // @ts-expect-error deckGLViewProps is a custom hack defined on the constructor (nebula.gl)\n return componentClass && componentClass.deckGLViewProps;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as React from 'react';\nimport {createElement} from 'react';\nimport {View} from '@deck.gl/core';\nimport {inheritsFrom} from './inherits-from';\nimport evaluateChildren, {isComponent} from './evaluate-children';\n\nimport type {ViewOrViews} from '../deckgl';\nimport type {Deck, DeckProps, Viewport} from '@deck.gl/core';\nimport type {EventManager} from 'mjolnir.js';\n\nexport type DeckGLContextValue = {\n viewport: Viewport;\n container: HTMLElement;\n eventManager: EventManager;\n onViewStateChange: DeckProps['onViewStateChange'];\n};\n\n// Iterate over views and reposition children associated with views\n// TODO - Can we supply a similar function for the non-React case?\nexport default function positionChildrenUnderViews<ViewsT extends ViewOrViews>({\n children,\n deck,\n ContextProvider\n}: {\n children: React.ReactNode[];\n deck?: Deck<ViewsT>;\n ContextProvider?: React.Context<DeckGLContextValue>['Provider'];\n}): React.ReactNode[] {\n // @ts-expect-error accessing protected property\n const {viewManager} = deck || {};\n\n if (!viewManager || !viewManager.views.length) {\n return [];\n }\n\n const views: Record<\n string,\n {\n viewport: Viewport;\n children: React.ReactNode[];\n }\n > = {};\n const defaultViewId = (viewManager.views[0] as View).id;\n\n // Sort children by view id\n for (const child of children) {\n // Unless child is a View, position / render as part of the default view\n let viewId = defaultViewId;\n let viewChildren = child;\n\n if (isComponent(child) && inheritsFrom(child.type, View)) {\n viewId = child.props.id || defaultViewId;\n viewChildren = child.props.children;\n }\n\n const viewport = viewManager.getViewport(viewId) as Viewport;\n const viewState = viewManager.getViewState(viewId);\n\n // Drop (auto-hide) elements with viewId that are not matched by any current view\n if (viewport) {\n viewState.padding = viewport.padding;\n const {x, y, width, height} = viewport;\n // Resolve potentially relative dimensions using the deck.gl container size\n viewChildren = evaluateChildren(viewChildren, {\n x,\n y,\n width,\n height,\n viewport,\n viewState\n });\n\n if (!views[viewId]) {\n views[viewId] = {\n viewport,\n children: []\n };\n }\n views[viewId].children.push(viewChildren);\n }\n }\n\n // Render views\n return Object.keys(views).map(viewId => {\n const {viewport, children: viewChildren} = views[viewId];\n const {x, y, width, height} = viewport;\n const style = {\n position: 'absolute',\n left: x,\n top: y,\n width,\n height\n };\n\n const key = `view-${viewId}`;\n // If children is passed as an array, React will throw the \"each element in a list needs\n // a key\" warning. Sending each child as separate arguments removes this requirement.\n const viewElement = createElement('div', {key, id: key, style}, ...viewChildren);\n\n if (ContextProvider) {\n const contextValue: DeckGLContextValue = {\n viewport,\n // @ts-expect-error accessing protected property\n container: deck.canvas.offsetParent,\n // @ts-expect-error accessing protected property\n eventManager: deck.eventManager,\n onViewStateChange: params => {\n params.viewId = viewId;\n // @ts-expect-error accessing protected method\n deck._onViewStateChange(params);\n }\n };\n return createElement(ContextProvider, {key, value: contextValue}, viewElement);\n }\n\n return viewElement;\n });\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as React from 'react';\n\nconst CANVAS_ONLY_STYLES = {\n mixBlendMode: null\n};\n\nexport default function extractStyles({\n width,\n height,\n style\n}: {\n width?: string | number;\n height?: string | number;\n style?: Partial<CSSStyleDeclaration> | null;\n}): {\n containerStyle: React.CSSProperties;\n canvasStyle: React.CSSProperties;\n} {\n // This styling is enforced for correct positioning with children\n const containerStyle: React.CSSProperties = {\n position: 'absolute',\n zIndex: 0,\n left: 0,\n top: 0,\n width,\n height\n };\n\n // Fill the container\n const canvasStyle: React.CSSProperties = {\n left: 0,\n top: 0\n };\n\n if (style) {\n for (const key in style) {\n if (key in CANVAS_ONLY_STYLES) {\n // apply style to the canvas, but not deck's children, e.g. mix-blend-mode\n canvasStyle[key] = style[key];\n } else {\n // apply style to the container, e.g. position/flow settings\n containerStyle[key] = style[key];\n }\n }\n }\n\n return {containerStyle, canvasStyle};\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;ACIA,IAAAA,SAAuB;AACvB,IAAAC,gBAAuF;AACvF,IAAAC,eAAmB;;;ACAnB,mBAAyC;AAEzC,IAAM,4BAA4B,OAAO,WAAW,cAAc,+BAAkB;AAEpF,IAAA,uCAAe;;;ACNf,YAAuB;AACvB,IAAAC,gBAA4B;;;ACAtB,SAAU,aAAgB,MAAW,YAAa;AACtD,SAAO,MAAM;AACX,QAAI,SAAS,YAAY;AACvB,aAAO;IACT;AACA,WAAO,OAAO,eAAe,IAAI;EACnC;AACA,SAAO;AACT;;;ADNA,kBAA0B;;;AEF1B,IAAAC,gBAA2B;AAE3B,IAAM,YAAY,EAAC,UAAU,YAAY,QAAQ,GAAE;AAErC,SAAP,iBACL,UACA,YAAe;AAEf,MAAI,OAAO,aAAa,YAAY;AAClC,WAAO,SAAS,UAAU;EAC5B;AACA,MAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,WAAO,SAAS,IAAI,WAAS,iBAAiB,OAAO,UAAU,CAAC;EAClE;AACA,MAAI,YAAY,QAAQ,GAAG;AAGzB,QAAI,WAAW,QAAQ,GAAG;AAExB,iBAAW,QAAQ;AACnB,iBAAO,4BAAa,UAAU,UAAU;IAC1C;AACA,QAAI,qBAAqB,QAAQ,GAAG;AAClC,iBAAO,4BAAa,UAAU,UAAU;IAC1C;EACF;AAEA,SAAO;AACT;AAEM,SAAU,YAAY,OAAsB;AAChD,SAAQ,SAAS,OAAO,UAAU,YAAY,UAAU,SAAU;AACpE;AAEA,SAAS,WAAW,OAAyB;AAvC7C;AAwCE,UAAO,WAAM,UAAN,mBAAa;AACtB;AAEA,SAAS,qBAAqB,OAAyB;AAC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AAI,MAAM;MACV,KAAK;MACL,OAAO;KACR;AAGD,YAAQ,cAAU,6BAChB,OACA,EAAC,IAAI,GAAG,MAAM,oBAAoB,KAAK,cAAc,OAAO,eAAc,GAC1E,CAAC,QAAQ,kBAAkB,CAAC;EAEhC;AAEA,aAAW;AACX,SAAO,QAAQ;AACjB;AAEA,IAAM,SAAe,kBAAW,aAAa;AAI7C,IAAA,iBAAe;",
6
- "names": ["React", "import_react", "import_core", "import_react", "import_react", "import_react", "import_core"]
3
+ "sources": ["../src/index.ts", "../src/deckgl.ts", "../src/utils/use-isomorphic-layout-effect.ts", "../src/utils/extract-jsx-layers.ts", "../src/utils/inherits-from.ts", "../src/utils/evaluate-children.ts", "../src/utils/position-children-under-views.ts", "../src/utils/deckgl-context.ts", "../src/utils/extract-styles.ts", "../src/widgets/compass-widget.tsx", "../src/utils/use-widget.ts", "../src/widgets/fullscreen-widget.tsx", "../src/widgets/zoom-widget.tsx"],
4
+ "sourcesContent": ["// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport {default as DeckGL} from './deckgl';\nexport {default} from './deckgl';\n\n// Widgets\nexport {CompassWidget} from './widgets/compass-widget';\nexport {FullscreenWidget} from './widgets/fullscreen-widget';\nexport {ZoomWidget} from './widgets/zoom-widget';\nexport {useWidget} from './utils/use-widget';\n\n// Types\nexport type {DeckGLContextValue} from './utils/deckgl-context';\nexport type {DeckGLRef, DeckGLProps} from './deckgl';\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as React from 'react';\nimport {createElement, useRef, useState, useMemo, useEffect, useImperativeHandle} from 'react';\nimport {Deck} from '@deck.gl/core';\nimport useIsomorphicLayoutEffect from './utils/use-isomorphic-layout-effect';\n\nimport extractJSXLayers, {DeckGLRenderCallback} from './utils/extract-jsx-layers';\nimport positionChildrenUnderViews from './utils/position-children-under-views';\nimport extractStyles from './utils/extract-styles';\n\nimport type {DeckGLContextValue} from './utils/deckgl-context';\nimport type {DeckProps, View, Viewport} from '@deck.gl/core';\n\nexport type ViewOrViews = View | View[] | null;\n\n/* eslint-disable max-statements, accessor-pairs */\ntype DeckInstanceRef<ViewsT extends ViewOrViews> = {\n deck?: Deck<ViewsT>;\n redrawReason?: string | null;\n lastRenderedViewports?: Viewport[];\n viewStateUpdateRequested?: any;\n interactionStateUpdateRequested?: any;\n forceUpdate: () => void;\n version: number;\n control: React.ReactHTMLElement<HTMLElement> | null;\n};\n\n// Remove prop types in the base Deck class that support externally supplied canvas/WebGLContext\n/** DeckGL React component props */\nexport type DeckGLProps<ViewsT extends ViewOrViews = null> = Omit<\n DeckProps<ViewsT>,\n 'width' | 'height' | 'gl' | 'parent' | 'canvas' | '_customRender'\n> & {\n Deck?: typeof Deck;\n width?: string | number;\n height?: string | number;\n children?: React.ReactNode | DeckGLRenderCallback;\n ref?: React.Ref<DeckGLRef<ViewsT>>;\n ContextProvider?: React.Context<DeckGLContextValue>['Provider'];\n};\n\nexport type DeckGLRef<ViewsT extends ViewOrViews = null> = {\n deck?: Deck<ViewsT>;\n pickObject: Deck['pickObject'];\n pickObjects: Deck['pickObjects'];\n pickMultipleObjects: Deck['pickMultipleObjects'];\n};\n\nfunction getRefHandles<ViewsT extends ViewOrViews>(\n thisRef: DeckInstanceRef<ViewsT>\n): DeckGLRef<ViewsT> {\n return {\n get deck() {\n return thisRef.deck;\n },\n // The following method can only be called after ref is available, by which point deck is defined in useEffect\n pickObject: opts => thisRef.deck!.pickObject(opts),\n pickMultipleObjects: opts => thisRef.deck!.pickMultipleObjects(opts),\n pickObjects: opts => thisRef.deck!.pickObjects(opts)\n };\n}\n\nfunction redrawDeck(thisRef: DeckInstanceRef<any>) {\n if (thisRef.redrawReason) {\n // Only redraw if we have received a dirty flag\n // @ts-expect-error accessing protected method\n thisRef.deck._drawLayers(thisRef.redrawReason);\n thisRef.redrawReason = null;\n }\n}\n\nfunction createDeckInstance<ViewsT extends ViewOrViews>(\n thisRef: DeckInstanceRef<ViewsT>,\n DeckClass: typeof Deck,\n props: DeckProps<ViewsT>\n): Deck<ViewsT> {\n const deck = new DeckClass({\n ...props,\n // The Deck's animation loop is independent from React's render cycle, causing potential\n // synchronization issues. We provide this custom render function to make sure that React\n // and Deck update on the same schedule.\n _customRender: redrawReason => {\n // Save the dirty flag for later\n thisRef.redrawReason = redrawReason;\n\n // Viewport/view state is passed to child components as props.\n // If they have changed, we need to trigger a React rerender to update children props.\n const viewports = deck.getViewports();\n if (thisRef.lastRenderedViewports !== viewports) {\n // Viewports have changed, update children props first.\n // This will delay the Deck canvas redraw till after React update (in useLayoutEffect)\n // so that the canvas does not get rendered before the child components update.\n thisRef.forceUpdate();\n } else {\n redrawDeck(thisRef);\n }\n }\n });\n return deck;\n}\n\nfunction DeckGLWithRef<ViewsT extends ViewOrViews = null>(\n props: DeckGLProps<ViewsT>,\n ref: React.Ref<DeckGLRef<ViewsT>>\n) {\n // A mechanism to force redraw\n const [version, setVersion] = useState(0);\n // A reference to persistent states\n const _thisRef = useRef<DeckInstanceRef<ViewsT>>({\n control: null,\n version,\n forceUpdate: () => setVersion(v => v + 1)\n });\n const thisRef = _thisRef.current;\n // DOM refs\n const containerRef = useRef(null);\n const canvasRef = useRef(null);\n\n // extract any deck.gl layers masquerading as react elements from props.children\n const jsxProps = useMemo(\n () => extractJSXLayers(props),\n [props.layers, props.views, props.children]\n );\n\n // Callbacks\n let inRender = true;\n\n const handleViewStateChange: DeckProps<ViewsT>['onViewStateChange'] = params => {\n if (inRender && props.viewState) {\n // Callback may invoke a state update. Defer callback to after render() to avoid React error\n // In React StrictMode, render is executed twice and useEffect/useLayoutEffect is executed once\n // Store deferred parameters in ref so that we can access it in another render\n thisRef.viewStateUpdateRequested = params;\n return null;\n }\n thisRef.viewStateUpdateRequested = null;\n return props.onViewStateChange?.(params);\n };\n\n const handleInteractionStateChange: DeckProps<ViewsT>['onInteractionStateChange'] = params => {\n if (inRender) {\n // Callback may invoke a state update. Defer callback to after render() to avoid React error\n // In React StrictMode, render is executed twice and useEffect/useLayoutEffect is executed once\n // Store deferred parameters in ref so that we can access it in another render\n thisRef.interactionStateUpdateRequested = params;\n } else {\n thisRef.interactionStateUpdateRequested = null;\n props.onInteractionStateChange?.(params);\n }\n };\n\n // Update Deck's props. If Deck needs redraw, this will trigger a call to `_customRender` in\n // the next animation frame.\n // Needs to be called both from initial mount, and when new props are received\n const deckProps = useMemo(() => {\n const forwardProps: DeckProps<ViewsT> = {\n widgets: [],\n ...props,\n // Override user styling props. We will set the canvas style in render()\n style: null,\n width: '100%',\n height: '100%',\n parent: containerRef.current,\n canvas: canvasRef.current,\n layers: jsxProps.layers,\n views: jsxProps.views as ViewsT,\n onViewStateChange: handleViewStateChange,\n onInteractionStateChange: handleInteractionStateChange\n };\n\n // The defaultValue for _customRender is null, which would overwrite the definition\n // of _customRender. Remove to avoid frequently redeclaring the method here.\n delete forwardProps._customRender;\n\n if (thisRef.deck) {\n thisRef.deck.setProps(forwardProps);\n }\n\n return forwardProps;\n }, [props]);\n\n useEffect(() => {\n const DeckClass = props.Deck || Deck;\n\n thisRef.deck = createDeckInstance(thisRef, DeckClass, {\n ...deckProps,\n parent: containerRef.current,\n canvas: canvasRef.current\n });\n\n return () => thisRef.deck?.finalize();\n }, []);\n\n useIsomorphicLayoutEffect(() => {\n // render has just been called. The children are positioned based on the current view state.\n // Redraw Deck canvas immediately, if necessary, using the current view state, so that it\n // matches the child components.\n redrawDeck(thisRef);\n\n // Execute deferred callbacks\n const {viewStateUpdateRequested, interactionStateUpdateRequested} = thisRef;\n if (viewStateUpdateRequested) {\n handleViewStateChange(viewStateUpdateRequested);\n }\n if (interactionStateUpdateRequested) {\n handleInteractionStateChange(interactionStateUpdateRequested);\n }\n });\n\n useImperativeHandle(ref, () => getRefHandles(thisRef), []);\n\n const currentViewports =\n thisRef.deck && thisRef.deck.isInitialized ? thisRef.deck.getViewports() : undefined;\n\n const {ContextProvider, width = '100%', height = '100%', id, style} = props;\n\n const {containerStyle, canvasStyle} = useMemo(\n () => extractStyles({width, height, style}),\n [width, height, style]\n );\n\n // Props changes may lead to 3 types of updates:\n // 1. Only the WebGL canvas - updated in Deck's render cycle (next animation frame)\n // 2. Only the DOM - updated in React's lifecycle (now)\n // 3. Both the WebGL canvas and the DOM - defer React rerender to next animation frame just\n // before Deck redraw to ensure perfect synchronization & avoid excessive redraw\n // This is because multiple changes may happen to Deck between two frames e.g. transition\n if (\n (!thisRef.viewStateUpdateRequested && thisRef.lastRenderedViewports === currentViewports) || // case 2\n thisRef.version !== version // case 3 just before deck redraws\n ) {\n thisRef.lastRenderedViewports = currentViewports;\n thisRef.version = version;\n\n // Render the background elements (typically react-map-gl instances)\n // using the view descriptors\n const childrenUnderViews = positionChildrenUnderViews({\n children: jsxProps.children,\n deck: thisRef.deck,\n ContextProvider\n });\n\n const canvas = createElement('canvas', {\n key: 'canvas',\n id: id || 'deckgl-overlay',\n ref: canvasRef,\n style: canvasStyle\n });\n\n // Render deck.gl as the last child\n thisRef.control = createElement(\n 'div',\n {id: `${id || 'deckgl'}-wrapper`, ref: containerRef, style: containerStyle},\n [canvas, childrenUnderViews]\n );\n }\n\n inRender = false;\n return thisRef.control;\n}\n\nconst DeckGL = React.forwardRef(DeckGLWithRef) as <ViewsT extends ViewOrViews>(\n props: DeckGLProps<ViewsT>\n) => React.ReactElement;\n\nexport default DeckGL;\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// From https://github.com/streamich/react-use/blob/master/src/useIsomorphicLayoutEffect.ts\n// useLayoutEffect but does not trigger warning in server-side rendering\nimport {useEffect, useLayoutEffect} from 'react';\n\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\nexport default useIsomorphicLayoutEffect;\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as React from 'react';\nimport {createElement} from 'react';\nimport {inheritsFrom} from './inherits-from';\nimport {Layer, View} from '@deck.gl/core';\nimport {isComponent} from './evaluate-children';\nimport type {LayersList, Viewport} from '@deck.gl/core';\n\nexport type DeckGLRenderCallbackArgs = {\n /**\n * the left offset of the current view, in pixels\n */\n x: number;\n /**\n * the top offset of the current view, in pixels\n */\n y: number;\n /**\n * the width of the current view, in pixels\n */\n width: number;\n /**\n * the height of the current view, in pixels\n */\n height: number;\n /**\n * the view state of the current view\n */\n viewState: any;\n /**\n * the `Viewport` instance of the current view\n */\n viewport: Viewport;\n};\n\nexport type DeckGLRenderCallback = (args: DeckGLRenderCallbackArgs) => React.ReactNode;\n\n// recursively wrap render callbacks in `View`\nfunction wrapInView(node: React.ReactNode | DeckGLRenderCallback): React.ReactNode {\n if (typeof node === 'function') {\n // React.Children does not traverse functions.\n // All render callbacks must be protected under a <View>\n // @ts-expect-error View is not a ReactJSXElement constructor. Only used as a temporary wrapper and will be removed in extractJSXLayers\n return createElement(View, {}, node);\n }\n if (Array.isArray(node)) {\n return node.map(wrapInView);\n }\n if (isComponent(node)) {\n if (node.type === React.Fragment) {\n return wrapInView(node.props.children);\n }\n if (inheritsFrom(node.type, View)) {\n return node;\n }\n }\n return node;\n}\n\n// extracts any deck.gl layers masquerading as react elements from props.children\nexport default function extractJSXLayers({\n children,\n layers = [],\n views = null\n}: {\n children?: React.ReactNode | DeckGLRenderCallback;\n layers?: LayersList;\n views?: View | View[] | null;\n}): {\n children: React.ReactNode[];\n layers: LayersList;\n views: View | View[] | null;\n} {\n const reactChildren: React.ReactNode[] = []; // extract real react elements (i.e. not deck.gl layers)\n const jsxLayers: LayersList = []; // extracted layer from react children, will add to deck.gl layer array\n const jsxViews: Record<string, View> = {};\n\n // React.children\n React.Children.forEach(wrapInView(children), reactElement => {\n if (isComponent(reactElement)) {\n // For some reason Children.forEach doesn't filter out `null`s\n const ElementType = reactElement.type;\n if (inheritsFrom(ElementType, Layer)) {\n const layer = createLayer(ElementType, reactElement.props);\n jsxLayers.push(layer);\n } else {\n reactChildren.push(reactElement);\n }\n\n // empty id => default view\n if (inheritsFrom(ElementType, View) && ElementType !== View && reactElement.props.id) {\n // @ts-ignore Cannot instantiate an abstract class (View)\n const view = new ElementType(reactElement.props);\n jsxViews[view.id] = view;\n }\n } else if (reactElement) {\n reactChildren.push(reactElement);\n }\n });\n\n // Avoid modifying views if no JSX views were found\n if (Object.keys(jsxViews).length > 0) {\n // If a view is specified in both views prop and JSX, use the one in views\n if (Array.isArray(views)) {\n views.forEach(view => {\n jsxViews[view.id] = view;\n });\n } else if (views) {\n jsxViews[views.id] = views;\n }\n views = Object.values(jsxViews);\n }\n\n // Avoid modifying layers array if no JSX layers were found\n layers = jsxLayers.length > 0 ? [...jsxLayers, ...layers] : layers;\n\n return {layers, children: reactChildren, views};\n}\n\nfunction createLayer(LayerType: typeof Layer, reactProps: any): Layer {\n const props = {};\n // Layer.defaultProps is treated as ReactElement.defaultProps and merged into react props\n // Remove them\n const defaultProps = LayerType.defaultProps || {};\n for (const key in reactProps) {\n if (defaultProps[key] !== reactProps[key]) {\n props[key] = reactProps[key];\n }\n }\n // @ts-ignore Cannot instantiate an abstract class (Layer)\n return new LayerType(props);\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Check if one JavaScript class inherits from another\nexport function inheritsFrom<T>(Type: any, ParentType: T): Type is T {\n while (Type) {\n if (Type === ParentType) {\n return true;\n }\n Type = Object.getPrototypeOf(Type);\n }\n return false;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as React from 'react';\nimport {cloneElement} from 'react';\n\nconst MAP_STYLE = {position: 'absolute', zIndex: -1};\n\nexport default function evaluateChildren(\n children: React.ReactNode | Function,\n childProps: any\n): React.ReactNode {\n if (typeof children === 'function') {\n return children(childProps);\n }\n if (Array.isArray(children)) {\n return children.map(child => evaluateChildren(child, childProps));\n }\n if (isComponent(children)) {\n // Special treatment for react-map-gl's Map component\n // to support shorthand use case <DeckGL><StaticMap /></DeckGL>\n if (isReactMap(children)) {\n // Place map under the canvas\n childProps.style = MAP_STYLE;\n return cloneElement(children, childProps);\n }\n if (needsDeckGLViewProps(children)) {\n return cloneElement(children, childProps);\n }\n }\n\n return children;\n}\n\nexport function isComponent(child: React.ReactNode): child is React.ReactElement {\n return (child && typeof child === 'object' && 'type' in child) || false;\n}\n\nfunction isReactMap(child: React.ReactElement): boolean {\n return child.props?.mapStyle;\n}\n\nfunction needsDeckGLViewProps(child: React.ReactElement): boolean {\n const componentClass = child.type;\n // @ts-expect-error deckGLViewProps is a custom hack defined on the constructor (nebula.gl)\n return componentClass && componentClass.deckGLViewProps;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as React from 'react';\nimport {createElement} from 'react';\nimport {View} from '@deck.gl/core';\nimport {inheritsFrom} from './inherits-from';\nimport evaluateChildren, {isComponent} from './evaluate-children';\n\nimport type {ViewOrViews} from '../deckgl';\nimport type {Deck, Viewport} from '@deck.gl/core';\nimport {DeckGlContext, type DeckGLContextValue} from './deckgl-context';\n\n// Iterate over views and reposition children associated with views\n// TODO - Can we supply a similar function for the non-React case?\nexport default function positionChildrenUnderViews<ViewsT extends ViewOrViews>({\n children,\n deck,\n ContextProvider = DeckGlContext.Provider\n}: {\n children: React.ReactNode[];\n deck?: Deck<ViewsT>;\n ContextProvider?: React.Context<DeckGLContextValue>['Provider'];\n}): React.ReactNode[] {\n // @ts-expect-error accessing protected property\n const {viewManager} = deck || {};\n\n if (!viewManager || !viewManager.views.length) {\n return [];\n }\n\n const views: Record<\n string,\n {\n viewport: Viewport;\n children: React.ReactNode[];\n }\n > = {};\n const defaultViewId = (viewManager.views[0] as View).id;\n\n // Sort children by view id\n for (const child of children) {\n // Unless child is a View, position / render as part of the default view\n let viewId = defaultViewId;\n let viewChildren = child;\n\n if (isComponent(child) && inheritsFrom(child.type, View)) {\n viewId = child.props.id || defaultViewId;\n viewChildren = child.props.children;\n }\n\n const viewport = viewManager.getViewport(viewId) as Viewport;\n const viewState = viewManager.getViewState(viewId);\n\n // Drop (auto-hide) elements with viewId that are not matched by any current view\n if (viewport) {\n viewState.padding = viewport.padding;\n const {x, y, width, height} = viewport;\n // Resolve potentially relative dimensions using the deck.gl container size\n viewChildren = evaluateChildren(viewChildren, {\n x,\n y,\n width,\n height,\n viewport,\n viewState\n });\n\n if (!views[viewId]) {\n views[viewId] = {\n viewport,\n children: []\n };\n }\n views[viewId].children.push(viewChildren);\n }\n }\n\n // Render views\n return Object.keys(views).map(viewId => {\n const {viewport, children: viewChildren} = views[viewId];\n const {x, y, width, height} = viewport;\n const style = {\n position: 'absolute',\n left: x,\n top: y,\n width,\n height\n };\n\n const key = `view-${viewId}`;\n // If children is passed as an array, React will throw the \"each element in a list needs\n // a key\" warning. Sending each child as separate arguments removes this requirement.\n const viewElement = createElement('div', {key, id: key, style}, ...viewChildren);\n\n const contextValue: DeckGLContextValue = {\n deck,\n viewport,\n // @ts-expect-error accessing protected property\n container: deck.canvas.offsetParent,\n // @ts-expect-error accessing protected property\n eventManager: deck.eventManager,\n onViewStateChange: params => {\n params.viewId = viewId;\n // @ts-expect-error accessing protected method\n deck._onViewStateChange(params);\n },\n widgets: []\n };\n const providerKey = `view-${viewId}-context`;\n return createElement(ContextProvider, {key: providerKey, value: contextValue}, viewElement);\n });\n}\n", "import {createContext} from 'react';\nimport type {EventManager} from 'mjolnir.js';\nimport type {Deck, DeckProps, Viewport, Widget} from '@deck.gl/core';\n\nexport type DeckGLContextValue = {\n viewport: Viewport;\n container: HTMLElement;\n eventManager: EventManager;\n onViewStateChange: DeckProps['onViewStateChange'];\n deck?: Deck<any>;\n widgets?: Widget[];\n};\n\n// @ts-ignore\nexport const DeckGlContext = createContext<DeckGLContextValue>();\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as React from 'react';\n\nconst CANVAS_ONLY_STYLES = {\n mixBlendMode: null\n};\n\nexport default function extractStyles({\n width,\n height,\n style\n}: {\n width?: string | number;\n height?: string | number;\n style?: Partial<CSSStyleDeclaration> | null;\n}): {\n containerStyle: React.CSSProperties;\n canvasStyle: React.CSSProperties;\n} {\n // This styling is enforced for correct positioning with children\n const containerStyle: React.CSSProperties = {\n position: 'absolute',\n zIndex: 0,\n left: 0,\n top: 0,\n width,\n height\n };\n\n // Fill the container\n const canvasStyle: React.CSSProperties = {\n left: 0,\n top: 0\n };\n\n if (style) {\n for (const key in style) {\n if (key in CANVAS_ONLY_STYLES) {\n // apply style to the canvas, but not deck's children, e.g. mix-blend-mode\n canvasStyle[key] = style[key];\n } else {\n // apply style to the container, e.g. position/flow settings\n containerStyle[key] = style[key];\n }\n }\n }\n\n return {containerStyle, canvasStyle};\n}\n", "import {CompassWidget as _CompassWidget} from '@deck.gl/widgets';\nimport type {CompassWidgetProps} from '@deck.gl/widgets';\nimport {useWidget} from '../utils/use-widget';\n\nexport const CompassWidget = (props: CompassWidgetProps = {}) => {\n const widget = useWidget(_CompassWidget, props);\n return null;\n};\n", "import {useContext, useMemo, useEffect} from 'react';\nimport {DeckGlContext} from './deckgl-context';\nimport {log, type Widget, _deepEqual as deepEqual} from '@deck.gl/core';\n\nexport function useWidget<T extends Widget, PropsT extends {}>(\n WidgetClass: {new (props: PropsT): T},\n props: PropsT\n): T {\n const context = useContext(DeckGlContext);\n const {widgets, deck} = context;\n useEffect(() => {\n // warn if the user supplied a pure-js widget, since it will be ignored\n // NOTE: This effect runs once per widget. Context widgets and deck widget props are synced after first effect runs.\n const internalWidgets = deck?.props.widgets;\n if (widgets?.length && internalWidgets?.length && !deepEqual(internalWidgets, widgets, 1)) {\n log.warn('\"widgets\" prop will be ignored because React widgets are in use.')();\n }\n\n return () => {\n // Remove widget from context when it is unmounted\n const index = widgets?.indexOf(widget);\n if (index && index !== -1) {\n widgets?.splice(index, 1);\n deck?.setProps({widgets});\n }\n };\n }, []);\n const widget = useMemo(() => new WidgetClass(props), [WidgetClass]);\n\n // Hook rebuilds widgets on every render: [] then [FirstWidget] then [FirstWidget, SecondWidget]\n widgets?.push(widget);\n widget.setProps(props);\n\n useEffect(() => {\n deck?.setProps({widgets});\n }, [widgets]);\n\n return widget;\n}\n", "import {FullscreenWidget as _FullscreenWidget} from '@deck.gl/widgets';\nimport type {FullscreenWidgetProps} from '@deck.gl/widgets';\nimport {useWidget} from '../utils/use-widget';\n\nexport const FullscreenWidget = (props: FullscreenWidgetProps = {}) => {\n const widget = useWidget(_FullscreenWidget, props);\n return null;\n};\n", "import {ZoomWidget as _ZoomWidget} from '@deck.gl/widgets';\nimport type {ZoomWidgetProps} from '@deck.gl/widgets';\nimport {useWidget} from '../utils/use-widget';\n\nexport const ZoomWidget = (props: ZoomWidgetProps = {}) => {\n const widget = useWidget(_ZoomWidget, props);\n return null;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;ACIA,IAAAA,SAAuB;AACvB,IAAAC,gBAAuF;AACvF,IAAAC,eAAmB;;;ACAnB,mBAAyC;AAEzC,IAAM,4BAA4B,OAAO,WAAW,cAAc,+BAAkB;AAEpF,IAAA,uCAAe;;;ACNf,YAAuB;AACvB,IAAAC,gBAA4B;;;ACAtB,SAAU,aAAgB,MAAW,YAAa;AACtD,SAAO,MAAM;AACX,QAAI,SAAS,YAAY;AACvB,aAAO;IACT;AACA,WAAO,OAAO,eAAe,IAAI;EACnC;AACA,SAAO;AACT;;;ADNA,kBAA0B;;;AEF1B,IAAAC,gBAA2B;AAE3B,IAAM,YAAY,EAAC,UAAU,YAAY,QAAQ,GAAE;AAErC,SAAP,iBACL,UACA,YAAe;AAEf,MAAI,OAAO,aAAa,YAAY;AAClC,WAAO,SAAS,UAAU;EAC5B;AACA,MAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,WAAO,SAAS,IAAI,WAAS,iBAAiB,OAAO,UAAU,CAAC;EAClE;AACA,MAAI,YAAY,QAAQ,GAAG;AAGzB,QAAI,WAAW,QAA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S,uBAAQ,MAAM,IAAI,YAAY,KAAK,GAAG,CAAC,WAAW,CAAC;AAGlE,qCAAS,KAAK;AACd,SAAO,SAAS,KAAK;AAErB,+BAAU,MAAK;AACb,iCAAM,SAAS,EAAC,QAAO;EACzB,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO;AACT;;;ADlCO,IAAM,gBAAgB,CAAC,QAA4B,CAAA,MAAM;AAC9D,QAAM,SAAS,UAAU,eAAAC,eAAgB,KAAK;AAC9C,SAAO;AACT;;;AEPA,IAAAC,kBAAoD;AAI7C,IAAM,mBAAmB,CAAC,QAA+B,CAAA,MAAM;AACpE,QAAM,SAAS,UAAU,gBAAAC,kBAAmB,KAAK;AACjD,SAAO;AACT;;;ACPA,IAAAC,kBAAwC;AAIjC,IAAM,aAAa,CAAC,QAAyB,CAAA,MAAM;AACxD,QAAM,SAAS,UAAU,gBAAAC,YAAa,KAAK;AAC3C,SAAO;AACT;",
6
+ "names": ["React", "import_react", "import_core", "import_react", "import_react", "import_react", "import_core", "import_react", "import_react", "import_core", "deepEqual", "_CompassWidget", "import_widgets", "_FullscreenWidget", "import_widgets", "_ZoomWidget"]
7
7
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  export { default as DeckGL } from "./deckgl.js";
2
2
  export { default } from "./deckgl.js";
3
- export type { DeckGLContextValue } from "./utils/position-children-under-views.js";
3
+ export { CompassWidget } from "./widgets/compass-widget.js";
4
+ export { FullscreenWidget } from "./widgets/fullscreen-widget.js";
5
+ export { ZoomWidget } from "./widgets/zoom-widget.js";
6
+ export { useWidget } from "./utils/use-widget.js";
7
+ export type { DeckGLContextValue } from "./utils/deckgl-context.js";
4
8
  export type { DeckGLRef, DeckGLProps } from "./deckgl.js";
5
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,oBAAiB;AAC3C,OAAO,EAAC,OAAO,EAAC,oBAAiB;AAGjC,YAAY,EAAC,kBAAkB,EAAC,iDAA8C;AAC9E,YAAY,EAAC,SAAS,EAAE,WAAW,EAAC,oBAAiB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,oBAAiB;AAC3C,OAAO,EAAC,OAAO,EAAC,oBAAiB;AAGjC,OAAO,EAAC,aAAa,EAAC,oCAAiC;AACvD,OAAO,EAAC,gBAAgB,EAAC,uCAAoC;AAC7D,OAAO,EAAC,UAAU,EAAC,iCAA8B;AACjD,OAAO,EAAC,SAAS,EAAC,8BAA2B;AAG7C,YAAY,EAAC,kBAAkB,EAAC,kCAA+B;AAC/D,YAAY,EAAC,SAAS,EAAE,WAAW,EAAC,oBAAiB"}
package/dist/index.js CHANGED
@@ -3,4 +3,9 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
  export { default as DeckGL } from "./deckgl.js";
5
5
  export { default } from "./deckgl.js";
6
+ // Widgets
7
+ export { CompassWidget } from "./widgets/compass-widget.js";
8
+ export { FullscreenWidget } from "./widgets/fullscreen-widget.js";
9
+ export { ZoomWidget } from "./widgets/zoom-widget.js";
10
+ export { useWidget } from "./utils/use-widget.js";
6
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,oBAAiB;AAC3C,OAAO,EAAC,OAAO,EAAC,oBAAiB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,oBAAiB;AAC3C,OAAO,EAAC,OAAO,EAAC,oBAAiB;AAEjC,UAAU;AACV,OAAO,EAAC,aAAa,EAAC,oCAAiC;AACvD,OAAO,EAAC,gBAAgB,EAAC,uCAAoC;AAC7D,OAAO,EAAC,UAAU,EAAC,iCAA8B;AACjD,OAAO,EAAC,SAAS,EAAC,8BAA2B"}
@@ -0,0 +1,12 @@
1
+ import type { EventManager } from 'mjolnir.js';
2
+ import type { Deck, DeckProps, Viewport, Widget } from '@deck.gl/core';
3
+ export type DeckGLContextValue = {
4
+ viewport: Viewport;
5
+ container: HTMLElement;
6
+ eventManager: EventManager;
7
+ onViewStateChange: DeckProps['onViewStateChange'];
8
+ deck?: Deck<any>;
9
+ widgets?: Widget[];
10
+ };
11
+ export declare const DeckGlContext: import("react").Context<DeckGLContextValue>;
12
+ //# sourceMappingURL=deckgl-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deckgl-context.d.ts","sourceRoot":"","sources":["../../src/utils/deckgl-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AAErE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,WAAW,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,iBAAiB,EAAE,SAAS,CAAC,mBAAmB,CAAC,CAAC;IAClD,IAAI,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAGF,eAAO,MAAM,aAAa,6CAAsC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { createContext } from 'react';
2
+ // @ts-ignore
3
+ export const DeckGlContext = createContext();
4
+ //# sourceMappingURL=deckgl-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deckgl-context.js","sourceRoot":"","sources":["../../src/utils/deckgl-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAapC,aAAa;AACb,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,EAAsB,CAAC"}
@@ -1,13 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import type { ViewOrViews } from "../deckgl.js";
3
- import type { Deck, DeckProps, Viewport } from '@deck.gl/core';
4
- import type { EventManager } from 'mjolnir.js';
5
- export type DeckGLContextValue = {
6
- viewport: Viewport;
7
- container: HTMLElement;
8
- eventManager: EventManager;
9
- onViewStateChange: DeckProps['onViewStateChange'];
10
- };
3
+ import type { Deck } from '@deck.gl/core';
4
+ import { type DeckGLContextValue } from "./deckgl-context.js";
11
5
  export default function positionChildrenUnderViews<ViewsT extends ViewOrViews>({ children, deck, ContextProvider }: {
12
6
  children: React.ReactNode[];
13
7
  deck?: Deck<ViewsT>;
@@ -1 +1 @@
1
- {"version":3,"file":"position-children-under-views.d.ts","sourceRoot":"","sources":["../../src/utils/position-children-under-views.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAC,WAAW,EAAC,qBAAkB;AAC3C,OAAO,KAAK,EAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,WAAW,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,iBAAiB,EAAE,SAAS,CAAC,mBAAmB,CAAC,CAAC;CACnD,CAAC;AAIF,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAAC,MAAM,SAAS,WAAW,EAAE,EAC7E,QAAQ,EACR,IAAI,EACJ,eAAe,EAChB,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;IAC5B,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACpB,eAAe,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,UAAU,CAAC,CAAC;CACjE,GAAG,KAAK,CAAC,SAAS,EAAE,CA0FpB"}
1
+ {"version":3,"file":"position-children-under-views.d.ts","sourceRoot":"","sources":["../../src/utils/position-children-under-views.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAC,WAAW,EAAC,qBAAkB;AAC3C,OAAO,KAAK,EAAC,IAAI,EAAW,MAAM,eAAe,CAAC;AAClD,OAAO,EAAgB,KAAK,kBAAkB,EAAC,4BAAyB;AAIxE,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAAC,MAAM,SAAS,WAAW,EAAE,EAC7E,QAAQ,EACR,IAAI,EACJ,eAAwC,EACzC,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;IAC5B,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACpB,eAAe,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,UAAU,CAAC,CAAC;CACjE,GAAG,KAAK,CAAC,SAAS,EAAE,CAyFpB"}
@@ -5,9 +5,10 @@ import { createElement } from 'react';
5
5
  import { View } from '@deck.gl/core';
6
6
  import { inheritsFrom } from "./inherits-from.js";
7
7
  import evaluateChildren, { isComponent } from "./evaluate-children.js";
8
+ import { DeckGlContext } from "./deckgl-context.js";
8
9
  // Iterate over views and reposition children associated with views
9
10
  // TODO - Can we supply a similar function for the non-React case?
10
- export default function positionChildrenUnderViews({ children, deck, ContextProvider }) {
11
+ export default function positionChildrenUnderViews({ children, deck, ContextProvider = DeckGlContext.Provider }) {
11
12
  // @ts-expect-error accessing protected property
12
13
  const { viewManager } = deck || {};
13
14
  if (!viewManager || !viewManager.views.length) {
@@ -63,22 +64,22 @@ export default function positionChildrenUnderViews({ children, deck, ContextProv
63
64
  // If children is passed as an array, React will throw the "each element in a list needs
64
65
  // a key" warning. Sending each child as separate arguments removes this requirement.
65
66
  const viewElement = createElement('div', { key, id: key, style }, ...viewChildren);
66
- if (ContextProvider) {
67
- const contextValue = {
68
- viewport,
69
- // @ts-expect-error accessing protected property
70
- container: deck.canvas.offsetParent,
71
- // @ts-expect-error accessing protected property
72
- eventManager: deck.eventManager,
73
- onViewStateChange: params => {
74
- params.viewId = viewId;
75
- // @ts-expect-error accessing protected method
76
- deck._onViewStateChange(params);
77
- }
78
- };
79
- return createElement(ContextProvider, { key, value: contextValue }, viewElement);
80
- }
81
- return viewElement;
67
+ const contextValue = {
68
+ deck,
69
+ viewport,
70
+ // @ts-expect-error accessing protected property
71
+ container: deck.canvas.offsetParent,
72
+ // @ts-expect-error accessing protected property
73
+ eventManager: deck.eventManager,
74
+ onViewStateChange: params => {
75
+ params.viewId = viewId;
76
+ // @ts-expect-error accessing protected method
77
+ deck._onViewStateChange(params);
78
+ },
79
+ widgets: []
80
+ };
81
+ const providerKey = `view-${viewId}-context`;
82
+ return createElement(ContextProvider, { key: providerKey, value: contextValue }, viewElement);
82
83
  });
83
84
  }
84
85
  //# sourceMappingURL=position-children-under-views.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"position-children-under-views.js","sourceRoot":"","sources":["../../src/utils/position-children-under-views.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AACpC,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AACnC,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAC7C,OAAO,gBAAgB,EAAE,EAAC,WAAW,EAAC,+BAA4B;AAalE,mEAAmE;AACnE,kEAAkE;AAClE,MAAM,CAAC,OA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CAAC;YACF,OAAO,aAAa,CAAC,eAAe,EAAE,EAAC,GAAG,EAAE,KAAK,EAAE,YAAY,EAAC,EAAE,WAAW,CAAC,CAAC;QACjF,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"position-children-under-views.js","sourceRoot":"","sources":["../../src/utils/position-children-under-views.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AACpC,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AACnC,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAC7C,OAAO,gBAAgB,EAAE,EAAC,WAAW,EAAC,+BAA4B;AAIlE,OAAO,EAAC,aAAa,EAA0B,4BAAyB;AAExE,mEAAmE;AACnE,kEAAkE;AAClE,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAA6B,EAC7E,QAAQ,EACR,IAAI,EACJ,eAAe,GAAG,aAAa,CAAC,QAAQ,EAKzC;IACC,gDAAgD;IAChD,MAAM,EAAC,WAAW,EAAC,GAAG,IAAI,IAAI,EAAE,CAAC;IAEjC,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAC9C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,KAAK,GAMP,EAAE,CAAC;IACP,MAAM,aAAa,GAAI,WAAW,CAAC,KAAK,CAAC,CAAC,CAAU,CAAC,EAAE,CAAC;IAExD,2BAA2B;IAC3B,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;QAC7B,wEAAwE;QACxE,IAAI,MAAM,GAAG,aAAa,CAAC;QAC3B,IAAI,YAAY,GAAG,KAAK,CAAC;QAEzB,IAAI,WAAW,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CA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C;YACN,KAAK;YACL,MAAM;SACP,CAAC;QAEF,MAAM,GAAG,GAAG,QAAQ,MAAM,EAAE,CAAC;QAC7B,wFAAwF;QACxF,qFAAqF;QACrF,MAAM,WAAW,GAAG,aAAa,CAAC,KAAK,EAAE,EAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAC,EAAE,GAAG,YAAY,CAAC,CAAC;QAEjF,MAAM,YAAY,GAAuB;YACvC,IAAI;YACJ,QAAQ;YACR,gDAAgD;YAChD,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;YACnC,gDAAgD;YAChD,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,iBAAiB,EAAE,MAAM,CAAC,EAAE;gBAC1B,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;gBACvB,8CAA8C;gBAC9C,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;YAClC,CAAC;YACD,OAAO,EAAE,EAAE;SACZ,CAAC;QACF,MAAM,WAAW,GAAG,QAAQ,MAAM,UAAU,CAAC;QAC7C,OAAO,aAAa,CAAC,eAAe,EAAE,EAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAC,EAAE,WAAW,CAAC,CAAC;IAC9F,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { type Widget } from '@deck.gl/core';
2
+ export declare function useWidget<T extends Widget, PropsT extends {}>(WidgetClass: {
3
+ new (props: PropsT): T;
4
+ }, props: PropsT): T;
5
+ //# sourceMappingURL=use-widget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-widget.d.ts","sourceRoot":"","sources":["../../src/utils/use-widget.ts"],"names":[],"mappings":"AAEA,OAAO,EAAM,KAAK,MAAM,EAA0B,MAAM,eAAe,CAAC;AAExE,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,SAAS,EAAE,EAC3D,WAAW,EAAE;IAAC,KAAK,KAAK,EAAE,MAAM,GAAG,CAAC,CAAA;CAAC,EACrC,KAAK,EAAE,MAAM,GACZ,CAAC,CA+BH"}
@@ -0,0 +1,32 @@
1
+ import { useContext, useMemo, useEffect } from 'react';
2
+ import { DeckGlContext } from "./deckgl-context.js";
3
+ import { log, _deepEqual as deepEqual } from '@deck.gl/core';
4
+ export function useWidget(WidgetClass, props) {
5
+ const context = useContext(DeckGlContext);
6
+ const { widgets, deck } = context;
7
+ useEffect(() => {
8
+ // warn if the user supplied a pure-js widget, since it will be ignored
9
+ // NOTE: This effect runs once per widget. Context widgets and deck widget props are synced after first effect runs.
10
+ const internalWidgets = deck?.props.widgets;
11
+ if (widgets?.length && internalWidgets?.length && !deepEqual(internalWidgets, widgets, 1)) {
12
+ log.warn('"widgets" prop will be ignored because React widgets are in use.')();
13
+ }
14
+ return () => {
15
+ // Remove widget from context when it is unmounted
16
+ const index = widgets?.indexOf(widget);
17
+ if (index && index !== -1) {
18
+ widgets?.splice(index, 1);
19
+ deck?.setProps({ widgets });
20
+ }
21
+ };
22
+ }, []);
23
+ const widget = useMemo(() => new WidgetClass(props), [WidgetClass]);
24
+ // Hook rebuilds widgets on every render: [] then [FirstWidget] then [FirstWidget, SecondWidget]
25
+ widgets?.push(widget);
26
+ widget.setProps(props);
27
+ useEffect(() => {
28
+ deck?.setProps({ widgets });
29
+ }, [widgets]);
30
+ return widget;
31
+ }
32
+ //# sourceMappingURL=use-widget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-widget.js","sourceRoot":"","sources":["../../src/utils/use-widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AACrD,OAAO,EAAC,aAAa,EAAC,4BAAyB;AAC/C,OAAO,EAAC,GAAG,EAAe,UAAU,IAAI,SAAS,EAAC,MAAM,eAAe,CAAC;AAExE,MAAM,UAAU,SAAS,CACvB,WAAqC,EACrC,KAAa;IAEb,MAAM,OAAO,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ets';
2
+ export declare const CompassWidget: (props?: CompassWidgetProps) => null;
3
+ //# sourceMappingURL=compass-widget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compass-widget.d.ts","sourceRoot":"","sources":["../../src/widgets/compass-widget.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AAGzD,eAAO,MAAM,aAAa,WAAW,kBAAkB,SAGtD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { CompassWidget as _CompassWidget } from '@deck.gl/widgets';
2
+ import { useWidget } from "../utils/use-widget.js";
3
+ export const CompassWidget = (props = {}) => {
4
+ const widget = useWidget(_CompassWidget, props);
5
+ return null;
6
+ };
7
+ //# sourceMappingURL=compass-widget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compass-widget.js","sourceRoot":"","sources":["../../src/widgets/compass-widget.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,IAAI,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EAAC,SAAS,EAAC,+BAA4B;AAE9C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAA4B,EAAE,EAAE,EAAE;IAC9D,MAAM,MAAM,GAAG,SAAS,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IAChD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { FullscreenWidgetProps } from '@deck.gl/widgets';
2
+ export declare const FullscreenWidget: (props?: FullscreenWidgetProps) => null;
3
+ //# sourceMappingURL=fullscreen-widget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fullscreen-widget.d.ts","sourceRoot":"","sources":["../../src/widgets/fullscreen-widget.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,kBAAkB,CAAC;AAG5D,eAAO,MAAM,gBAAgB,WAAW,qBAAqB,SAG5D,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { FullscreenWidget as _FullscreenWidget } from '@deck.gl/widgets';
2
+ import { useWidget } from "../utils/use-widget.js";
3
+ export const FullscreenWidget = (props = {}) => {
4
+ const widget = useWidget(_FullscreenWidget, props);
5
+ return null;
6
+ };
7
+ //# sourceMappingURL=fullscreen-widget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fullscreen-widget.js","sourceRoot":"","sources":["../../src/widgets/fullscreen-widget.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,IAAI,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAEvE,OAAO,EAAC,SAAS,EAAC,+BAA4B;AAE9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAA+B,EAAE,EAAE,EAAE;IACpE,MAAM,MAAM,GAAG,SAAS,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ZoomWidgetProps } from '@deck.gl/widgets';
2
+ export declare const ZoomWidget: (props?: ZoomWidgetProps) => null;
3
+ //# sourceMappingURL=zoom-widget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zoom-widget.d.ts","sourceRoot":"","sources":["../../src/widgets/zoom-widget.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAGtD,eAAO,MAAM,UAAU,WAAW,eAAe,SAGhD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { ZoomWidget as _ZoomWidget } from '@deck.gl/widgets';
2
+ import { useWidget } from "../utils/use-widget.js";
3
+ export const ZoomWidget = (props = {}) => {
4
+ const widget = useWidget(_ZoomWidget, props);
5
+ return null;
6
+ };
7
+ //# sourceMappingURL=zoom-widget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zoom-widget.js","sourceRoot":"","sources":["../../src/widgets/zoom-widget.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,IAAI,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAC,SAAS,EAAC,+BAA4B;AAE9C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAAyB,EAAE,EAAE,EAAE;IACxD,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "React Components for deck.gl",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
- "version": "9.1.0-beta.3",
6
+ "version": "9.1.1",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -34,7 +34,8 @@
34
34
  "sideEffects": false,
35
35
  "scripts": {},
36
36
  "peerDependencies": {
37
- "@deck.gl/core": "^9.1.0-beta",
37
+ "@deck.gl/core": "^9.1.0",
38
+ "@deck.gl/widgets": "^9.1.0",
38
39
  "react": ">=16.3.0",
39
40
  "react-dom": ">=16.3.0"
40
41
  },
@@ -44,5 +45,5 @@
44
45
  "react": "^18.2.0",
45
46
  "react-dom": "^18.2.0"
46
47
  },
47
- "gitHead": "6625885881202cb753b64c6f2b8ee6f323092075"
48
+ "gitHead": "0f50055847e881ddd72b6b0f081bf8110b9a3a31"
48
49
  }
package/src/deckgl.ts CHANGED
@@ -11,7 +11,7 @@ import extractJSXLayers, {DeckGLRenderCallback} from './utils/extract-jsx-layers
11
11
  import positionChildrenUnderViews from './utils/position-children-under-views';
12
12
  import extractStyles from './utils/extract-styles';
13
13
 
14
- import type {DeckGLContextValue} from './utils/position-children-under-views';
14
+ import type {DeckGLContextValue} from './utils/deckgl-context';
15
15
  import type {DeckProps, View, Viewport} from '@deck.gl/core';
16
16
 
17
17
  export type ViewOrViews = View | View[] | null;
@@ -157,6 +157,7 @@ function DeckGLWithRef<ViewsT extends ViewOrViews = null>(
157
157
  // Needs to be called both from initial mount, and when new props are received
158
158
  const deckProps = useMemo(() => {
159
159
  const forwardProps: DeckProps<ViewsT> = {
160
+ widgets: [],
160
161
  ...props,
161
162
  // Override user styling props. We will set the canvas style in render()
162
163
  style: null,
package/src/index.ts CHANGED
@@ -5,6 +5,12 @@
5
5
  export {default as DeckGL} from './deckgl';
6
6
  export {default} from './deckgl';
7
7
 
8
+ // Widgets
9
+ export {CompassWidget} from './widgets/compass-widget';
10
+ export {FullscreenWidget} from './widgets/fullscreen-widget';
11
+ export {ZoomWidget} from './widgets/zoom-widget';
12
+ export {useWidget} from './utils/use-widget';
13
+
8
14
  // Types
9
- export type {DeckGLContextValue} from './utils/position-children-under-views';
15
+ export type {DeckGLContextValue} from './utils/deckgl-context';
10
16
  export type {DeckGLRef, DeckGLProps} from './deckgl';
@@ -0,0 +1,15 @@
1
+ import {createContext} from 'react';
2
+ import type {EventManager} from 'mjolnir.js';
3
+ import type {Deck, DeckProps, Viewport, Widget} from '@deck.gl/core';
4
+
5
+ export type DeckGLContextValue = {
6
+ viewport: Viewport;
7
+ container: HTMLElement;
8
+ eventManager: EventManager;
9
+ onViewStateChange: DeckProps['onViewStateChange'];
10
+ deck?: Deck<any>;
11
+ widgets?: Widget[];
12
+ };
13
+
14
+ // @ts-ignore
15
+ export const DeckGlContext = createContext<DeckGLContextValue>();
@@ -9,22 +9,15 @@ import {inheritsFrom} from './inherits-from';
9
9
  import evaluateChildren, {isComponent} from './evaluate-children';
10
10
 
11
11
  import type {ViewOrViews} from '../deckgl';
12
- import type {Deck, DeckProps, Viewport} from '@deck.gl/core';
13
- import type {EventManager} from 'mjolnir.js';
14
-
15
- export type DeckGLContextValue = {
16
- viewport: Viewport;
17
- container: HTMLElement;
18
- eventManager: EventManager;
19
- onViewStateChange: DeckProps['onViewStateChange'];
20
- };
12
+ import type {Deck, Viewport} from '@deck.gl/core';
13
+ import {DeckGlContext, type DeckGLContextValue} from './deckgl-context';
21
14
 
22
15
  // Iterate over views and reposition children associated with views
23
16
  // TODO - Can we supply a similar function for the non-React case?
24
17
  export default function positionChildrenUnderViews<ViewsT extends ViewOrViews>({
25
18
  children,
26
19
  deck,
27
- ContextProvider
20
+ ContextProvider = DeckGlContext.Provider
28
21
  }: {
29
22
  children: React.ReactNode[];
30
23
  deck?: Deck<ViewsT>;
@@ -101,22 +94,21 @@ export default function positionChildrenUnderViews<ViewsT extends ViewOrViews>({
101
94
  // a key" warning. Sending each child as separate arguments removes this requirement.
102
95
  const viewElement = createElement('div', {key, id: key, style}, ...viewChildren);
103
96
 
104
- if (ContextProvider) {
105
- const contextValue: DeckGLContextValue = {
106
- viewport,
107
- // @ts-expect-error accessing protected property
108
- container: deck.canvas.offsetParent,
109
- // @ts-expect-error accessing protected property
110
- eventManager: deck.eventManager,
111
- onViewStateChange: params => {
112
- params.viewId = viewId;
113
- // @ts-expect-error accessing protected method
114
- deck._onViewStateChange(params);
115
- }
116
- };
117
- return createElement(ContextProvider, {key, value: contextValue}, viewElement);
118
- }
119
-
120
- return viewElement;
97
+ const contextValue: DeckGLContextValue = {
98
+ deck,
99
+ viewport,
100
+ // @ts-expect-error accessing protected property
101
+ container: deck.canvas.offsetParent,
102
+ // @ts-expect-error accessing protected property
103
+ eventManager: deck.eventManager,
104
+ onViewStateChange: params => {
105
+ params.viewId = viewId;
106
+ // @ts-expect-error accessing protected method
107
+ deck._onViewStateChange(params);
108
+ },
109
+ widgets: []
110
+ };
111
+ const providerKey = `view-${viewId}-context`;
112
+ return createElement(ContextProvider, {key: providerKey, value: contextValue}, viewElement);
121
113
  });
122
114
  }
@@ -0,0 +1,39 @@
1
+ import {useContext, useMemo, useEffect} from 'react';
2
+ import {DeckGlContext} from './deckgl-context';
3
+ import {log, type Widget, _deepEqual as deepEqual} from '@deck.gl/core';
4
+
5
+ export function useWidget<T extends Widget, PropsT extends {}>(
6
+ WidgetClass: {new (props: PropsT): T},
7
+ props: PropsT
8
+ ): T {
9
+ const context = useContext(DeckGlContext);
10
+ const {widgets, deck} = context;
11
+ useEffect(() => {
12
+ // warn if the user supplied a pure-js widget, since it will be ignored
13
+ // NOTE: This effect runs once per widget. Context widgets and deck widget props are synced after first effect runs.
14
+ const internalWidgets = deck?.props.widgets;
15
+ if (widgets?.length && internalWidgets?.length && !deepEqual(internalWidgets, widgets, 1)) {
16
+ log.warn('"widgets" prop will be ignored because React widgets are in use.')();
17
+ }
18
+
19
+ return () => {
20
+ // Remove widget from context when it is unmounted
21
+ const index = widgets?.indexOf(widget);
22
+ if (index && index !== -1) {
23
+ widgets?.splice(index, 1);
24
+ deck?.setProps({widgets});
25
+ }
26
+ };
27
+ }, []);
28
+ const widget = useMemo(() => new WidgetClass(props), [WidgetClass]);
29
+
30
+ // Hook rebuilds widgets on every render: [] then [FirstWidget] then [FirstWidget, SecondWidget]
31
+ widgets?.push(widget);
32
+ widget.setProps(props);
33
+
34
+ useEffect(() => {
35
+ deck?.setProps({widgets});
36
+ }, [widgets]);
37
+
38
+ return widget;
39
+ }
@@ -0,0 +1,8 @@
1
+ import {CompassWidget as _CompassWidget} from '@deck.gl/widgets';
2
+ import type {CompassWidgetProps} from '@deck.gl/widgets';
3
+ import {useWidget} from '../utils/use-widget';
4
+
5
+ export const CompassWidget = (props: CompassWidgetProps = {}) => {
6
+ const widget = useWidget(_CompassWidget, props);
7
+ return null;
8
+ };
@@ -0,0 +1,8 @@
1
+ import {FullscreenWidget as _FullscreenWidget} from '@deck.gl/widgets';
2
+ import type {FullscreenWidgetProps} from '@deck.gl/widgets';
3
+ import {useWidget} from '../utils/use-widget';
4
+
5
+ export const FullscreenWidget = (props: FullscreenWidgetProps = {}) => {
6
+ const widget = useWidget(_FullscreenWidget, props);
7
+ return null;
8
+ };
@@ -0,0 +1,8 @@
1
+ import {ZoomWidget as _ZoomWidget} from '@deck.gl/widgets';
2
+ import type {ZoomWidgetProps} from '@deck.gl/widgets';
3
+ import {useWidget} from '../utils/use-widget';
4
+
5
+ export const ZoomWidget = (props: ZoomWidgetProps = {}) => {
6
+ const widget = useWidget(_ZoomWidget, props);
7
+ return null;
8
+ };