@deck.gl/react 9.0.0-beta.10 → 9.0.0-beta.11
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/deckgl.d.ts +7 -11
- package/dist/deckgl.d.ts.map +1 -1
- package/dist/deckgl.js +25 -5
- package/dist/index.cjs +5 -4
- package/dist/index.cjs.map +3 -3
- package/dist/utils/position-children-under-views.d.ts +3 -2
- package/dist/utils/position-children-under-views.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/deckgl.ts +33 -31
- package/src/utils/position-children-under-views.ts +3 -2
package/dist/deckgl.d.ts
CHANGED
|
@@ -2,27 +2,23 @@ import * as React from 'react';
|
|
|
2
2
|
import { Deck } from '@deck.gl/core';
|
|
3
3
|
import { DeckGLRenderCallback } from "./utils/extract-jsx-layers.js";
|
|
4
4
|
import type { DeckGLContextValue } from "./utils/position-children-under-views.js";
|
|
5
|
-
import type { DeckProps } from '@deck.gl/core';
|
|
5
|
+
import type { DeckProps, View } from '@deck.gl/core';
|
|
6
|
+
export type ViewOrViews = View | View[] | null;
|
|
6
7
|
/** DeckGL React component props */
|
|
7
|
-
export type DeckGLProps = Omit<DeckProps
|
|
8
|
+
export type DeckGLProps<ViewsT extends ViewOrViews = null> = Omit<DeckProps<ViewsT>, 'width' | 'height' | 'gl' | 'parent' | 'canvas' | '_customRender'> & {
|
|
8
9
|
Deck?: typeof Deck;
|
|
9
10
|
width?: string | number;
|
|
10
11
|
height?: string | number;
|
|
11
12
|
children?: React.ReactNode | DeckGLRenderCallback;
|
|
13
|
+
ref?: React.Ref<DeckGLRef<ViewsT>>;
|
|
12
14
|
ContextProvider?: React.Context<DeckGLContextValue>['Provider'];
|
|
13
15
|
};
|
|
14
|
-
export type DeckGLRef = {
|
|
15
|
-
deck?: Deck
|
|
16
|
+
export type DeckGLRef<ViewsT extends ViewOrViews = null> = {
|
|
17
|
+
deck?: Deck<ViewsT>;
|
|
16
18
|
pickObject: Deck['pickObject'];
|
|
17
19
|
pickObjects: Deck['pickObjects'];
|
|
18
20
|
pickMultipleObjects: Deck['pickMultipleObjects'];
|
|
19
21
|
};
|
|
20
|
-
declare const DeckGL:
|
|
21
|
-
Deck?: typeof Deck | undefined;
|
|
22
|
-
width?: string | number | undefined;
|
|
23
|
-
height?: string | number | undefined;
|
|
24
|
-
children?: React.ReactNode | DeckGLRenderCallback;
|
|
25
|
-
ContextProvider?: React.Provider<DeckGLContextValue> | undefined;
|
|
26
|
-
} & React.RefAttributes<DeckGLRef>>;
|
|
22
|
+
declare const DeckGL: <ViewsT extends ViewOrViews>(props: DeckGLProps<ViewsT>) => React.ReactElement;
|
|
27
23
|
export default DeckGL;
|
|
28
24
|
//# sourceMappingURL=deckgl.d.ts.map
|
package/dist/deckgl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deckgl.d.ts","sourceRoot":"","sources":["../src/deckgl.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"deckgl.d.ts","sourceRoot":"","sources":["../src/deckgl.ts"],"names":[],"mappings":"AAmBA,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,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;AAsNF,QAAA,MAAM,MAAM,8DAEP,MAAM,YAAY,CAAC;AAExB,eAAe,MAAM,CAAC"}
|
package/dist/deckgl.js
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
import * as React from 'react';
|
|
21
|
+
import { createElement, useRef, useState, useMemo, useEffect, useImperativeHandle } from 'react';
|
|
2
22
|
import { Deck } from '@deck.gl/core';
|
|
3
23
|
import useIsomorphicLayoutEffect from "./utils/use-isomorphic-layout-effect.js";
|
|
4
24
|
import extractJSXLayers from "./utils/extract-jsx-layers.js";
|
|
@@ -48,7 +68,7 @@ function createDeckInstance(thisRef, DeckClass, props) {
|
|
|
48
68
|
});
|
|
49
69
|
return deck;
|
|
50
70
|
}
|
|
51
|
-
|
|
71
|
+
function DeckGLWithRef(props, ref) {
|
|
52
72
|
// A mechanism to force redraw
|
|
53
73
|
const [version, setVersion] = useState(0);
|
|
54
74
|
// A reference to persistent states
|
|
@@ -138,7 +158,7 @@ const DeckGL = forwardRef((props, ref) => {
|
|
|
138
158
|
});
|
|
139
159
|
useImperativeHandle(ref, () => getRefHandles(thisRef), []);
|
|
140
160
|
const currentViewports = thisRef.deck && thisRef.deck.isInitialized ? thisRef.deck.getViewports() : undefined;
|
|
141
|
-
const { ContextProvider, width, height, id, style } = props;
|
|
161
|
+
const { ContextProvider, width = '100%', height = '100%', id, style } = props;
|
|
142
162
|
const { containerStyle, canvasStyle } = useMemo(() => extractStyles({ width, height, style }), [width, height, style]);
|
|
143
163
|
// Props changes may lead to 3 types of updates:
|
|
144
164
|
// 1. Only the WebGL canvas - updated in Deck's render cycle (next animation frame)
|
|
@@ -169,6 +189,6 @@ const DeckGL = forwardRef((props, ref) => {
|
|
|
169
189
|
}
|
|
170
190
|
inRender = false;
|
|
171
191
|
return thisRef.control;
|
|
172
|
-
}
|
|
173
|
-
DeckGL
|
|
192
|
+
}
|
|
193
|
+
const DeckGL = React.forwardRef(DeckGLWithRef);
|
|
174
194
|
export default DeckGL;
|
package/dist/index.cjs
CHANGED
|
@@ -32,6 +32,7 @@ __export(dist_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(dist_exports);
|
|
33
33
|
|
|
34
34
|
// dist/deckgl.js
|
|
35
|
+
var React2 = __toESM(require("react"), 1);
|
|
35
36
|
var import_react5 = require("react");
|
|
36
37
|
var import_core3 = require("@deck.gl/core");
|
|
37
38
|
|
|
@@ -282,7 +283,7 @@ function createDeckInstance(thisRef, DeckClass, props) {
|
|
|
282
283
|
});
|
|
283
284
|
return deck;
|
|
284
285
|
}
|
|
285
|
-
|
|
286
|
+
function DeckGLWithRef(props, ref) {
|
|
286
287
|
const [version, setVersion] = (0, import_react5.useState)(0);
|
|
287
288
|
const _thisRef = (0, import_react5.useRef)({
|
|
288
289
|
control: null,
|
|
@@ -355,7 +356,7 @@ var DeckGL = (0, import_react5.forwardRef)((props, ref) => {
|
|
|
355
356
|
});
|
|
356
357
|
(0, import_react5.useImperativeHandle)(ref, () => getRefHandles(thisRef), []);
|
|
357
358
|
const currentViewports = thisRef.deck && thisRef.deck.isInitialized ? thisRef.deck.getViewports() : void 0;
|
|
358
|
-
const { ContextProvider, width, height, id, style } = props;
|
|
359
|
+
const { ContextProvider, width = "100%", height = "100%", id, style } = props;
|
|
359
360
|
const { containerStyle, canvasStyle } = (0, import_react5.useMemo)(() => extractStyles({ width, height, style }), [width, height, style]);
|
|
360
361
|
if (!thisRef.viewStateUpdateRequested && thisRef.lastRenderedViewports === currentViewports || thisRef.version !== version) {
|
|
361
362
|
thisRef.lastRenderedViewports = currentViewports;
|
|
@@ -375,7 +376,7 @@ var DeckGL = (0, import_react5.forwardRef)((props, ref) => {
|
|
|
375
376
|
}
|
|
376
377
|
inRender = false;
|
|
377
378
|
return thisRef.control;
|
|
378
|
-
}
|
|
379
|
-
DeckGL
|
|
379
|
+
}
|
|
380
|
+
var DeckGL = React2.forwardRef(DeckGLWithRef);
|
|
380
381
|
var deckgl_default = DeckGL;
|
|
381
382
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.js", "deckgl.js", "utils/use-isomorphic-layout-effect.js", "utils/extract-jsx-layers.js", "utils/inherits-from.js", "utils/evaluate-children.js", "utils/position-children-under-views.js", "utils/extract-styles.js"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\nexport { default as DeckGL } from \"./deckgl.js\";\nexport { default } from \"./deckgl.js\";\n", "import { createElement, useRef, useState, useMemo, useEffect, useImperativeHandle, forwardRef } from 'react';\nimport { Deck } from '@deck.gl/core';\nimport useIsomorphicLayoutEffect from \"./utils/use-isomorphic-layout-effect.js\";\nimport extractJSXLayers from \"./utils/extract-jsx-layers.js\";\nimport positionChildrenUnderViews from \"./utils/position-children-under-views.js\";\nimport extractStyles from \"./utils/extract-styles.js\";\nfunction getRefHandles(thisRef) {\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}\nfunction redrawDeck(thisRef) {\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}\nfunction createDeckInstance(thisRef, DeckClass, props) {\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 // 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 }\n else {\n redrawDeck(thisRef);\n }\n }\n });\n return deck;\n}\nconst DeckGL = forwardRef((props, ref) => {\n // A mechanism to force redraw\n const [version, setVersion] = useState(0);\n // A reference to persistent states\n const _thisRef = useRef({\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 // extract any deck.gl layers masquerading as react elements from props.children\n const jsxProps = useMemo(() => extractJSXLayers(props), [props.layers, props.views, props.children]);\n // Callbacks\n let inRender = true;\n const handleViewStateChange = 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 const handleInteractionStateChange = 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 }\n else {\n thisRef.interactionStateUpdateRequested = null;\n props.onInteractionStateChange?.(params);\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 = {\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,\n onViewStateChange: handleViewStateChange,\n onInteractionStateChange: handleInteractionStateChange\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 if (thisRef.deck) {\n thisRef.deck.setProps(forwardProps);\n }\n return forwardProps;\n }, [props]);\n useEffect(() => {\n const DeckClass = props.Deck || Deck;\n thisRef.deck = createDeckInstance(thisRef, DeckClass, {\n ...deckProps,\n parent: containerRef.current,\n canvas: canvasRef.current\n });\n return () => thisRef.deck?.finalize();\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 // Execute deferred callbacks\n const { viewStateUpdateRequested, interactionStateUpdateRequested } = thisRef;\n if (viewStateUpdateRequested) {\n handleViewStateChange(viewStateUpdateRequested);\n }\n if (interactionStateUpdateRequested) {\n handleInteractionStateChange(interactionStateUpdateRequested);\n }\n });\n useImperativeHandle(ref, () => getRefHandles(thisRef), []);\n const currentViewports = thisRef.deck && thisRef.deck.isInitialized ? thisRef.deck.getViewports() : undefined;\n const { ContextProvider, width, height, id, style } = props;\n const { containerStyle, canvasStyle } = useMemo(() => extractStyles({ width, height, style }), [width, height, style]);\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 ((!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 // 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 const canvas = createElement('canvas', {\n key: 'canvas',\n id: id || 'deckgl-overlay',\n ref: canvasRef,\n style: canvasStyle\n });\n // Render deck.gl as the last child\n thisRef.control = createElement('div', { id: `${id || 'deckgl'}-wrapper`, ref: containerRef, style: containerStyle }, [canvas, childrenUnderViews]);\n }\n inRender = false;\n return thisRef.control;\n});\nDeckGL.defaultProps = Deck.defaultProps;\nexport default DeckGL;\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';\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\nexport default useIsomorphicLayoutEffect;\n", "import * as React from 'react';\nimport { createElement } from 'react';\nimport { inheritsFrom } from \"./inherits-from.js\";\nimport { Layer, View } from '@deck.gl/core';\nimport { isComponent } from \"./evaluate-children.js\";\n// recursively wrap render callbacks in `View`\nfunction wrapInView(node) {\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// extracts any deck.gl layers masquerading as react elements from props.children\nexport default function extractJSXLayers({ children, layers = [], views = null }) {\n const reactChildren = []; // extract real react elements (i.e. not deck.gl layers)\n const jsxLayers = []; // extracted layer from react children, will add to deck.gl layer array\n const jsxViews = {};\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 }\n else {\n reactChildren.push(reactElement);\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 }\n else if (reactElement) {\n reactChildren.push(reactElement);\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 }\n else if (views) {\n jsxViews[views.id] = views;\n }\n views = Object.values(jsxViews);\n }\n // Avoid modifying layers array if no JSX layers were found\n layers = jsxLayers.length > 0 ? [...jsxLayers, ...layers] : layers;\n return { layers, children: reactChildren, views };\n}\nfunction createLayer(LayerType, reactProps) {\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", "// Check if one JavaScript class inherits from another\nexport function inheritsFrom(Type, ParentType) {\n while (Type) {\n if (Type === ParentType) {\n return true;\n }\n Type = Object.getPrototypeOf(Type);\n }\n return false;\n}\n", "import { cloneElement } from 'react';\nconst MAP_STYLE = { position: 'absolute', zIndex: -1 };\nexport default function evaluateChildren(children, childProps) {\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 return children;\n}\nexport function isComponent(child) {\n return (child && typeof child === 'object' && 'type' in child) || false;\n}\nfunction isReactMap(child) {\n return child.props?.mapStyle;\n}\nfunction needsDeckGLViewProps(child) {\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", "import { createElement } from 'react';\nimport { View } from '@deck.gl/core';\nimport { inheritsFrom } from \"./inherits-from.js\";\nimport evaluateChildren, { isComponent } from \"./evaluate-children.js\";\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({ children, deck, ContextProvider }) {\n // @ts-expect-error accessing protected property\n const { viewManager } = deck || {};\n if (!viewManager || !viewManager.views.length) {\n return [];\n }\n const views = {};\n const defaultViewId = viewManager.views[0].id;\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 if (isComponent(child) && inheritsFrom(child.type, View)) {\n viewId = child.props.id || defaultViewId;\n viewChildren = child.props.children;\n }\n const viewport = viewManager.getViewport(viewId);\n const viewState = viewManager.getViewState(viewId);\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 if (!views[viewId]) {\n views[viewId] = {\n viewport,\n children: []\n };\n }\n views[viewId].children.push(viewChildren);\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 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 if (ContextProvider) {\n const contextValue = {\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 return viewElement;\n });\n}\n", "const CANVAS_ONLY_STYLES = {\n mixBlendMode: null\n};\nexport default function extractStyles({ width, height, style }) {\n // This styling is enforced for correct positioning with children\n const containerStyle = {\n position: 'absolute',\n zIndex: 0,\n left: 0,\n top: 0,\n width,\n height\n };\n // Fill the container\n const canvasStyle = {\n left: 0,\n top: 0\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 }\n else {\n // apply style to the container, e.g. position/flow settings\n containerStyle[key] = style[key];\n }\n }\n }\n return { containerStyle, canvasStyle };\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;
|
|
6
|
-
"names": ["import_react", "import_core", "import_react", "import_react", "import_react", "import_core"]
|
|
4
|
+
"sourcesContent": ["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\nexport { default as DeckGL } from \"./deckgl.js\";\nexport { default } from \"./deckgl.js\";\n", "// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\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.js\";\nimport extractJSXLayers from \"./utils/extract-jsx-layers.js\";\nimport positionChildrenUnderViews from \"./utils/position-children-under-views.js\";\nimport extractStyles from \"./utils/extract-styles.js\";\nfunction getRefHandles(thisRef) {\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}\nfunction redrawDeck(thisRef) {\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}\nfunction createDeckInstance(thisRef, DeckClass, props) {\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 // 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 }\n else {\n redrawDeck(thisRef);\n }\n }\n });\n return deck;\n}\nfunction DeckGLWithRef(props, ref) {\n // A mechanism to force redraw\n const [version, setVersion] = useState(0);\n // A reference to persistent states\n const _thisRef = useRef({\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 // extract any deck.gl layers masquerading as react elements from props.children\n const jsxProps = useMemo(() => extractJSXLayers(props), [props.layers, props.views, props.children]);\n // Callbacks\n let inRender = true;\n const handleViewStateChange = 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 const handleInteractionStateChange = 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 }\n else {\n thisRef.interactionStateUpdateRequested = null;\n props.onInteractionStateChange?.(params);\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 = {\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,\n onViewStateChange: handleViewStateChange,\n onInteractionStateChange: handleInteractionStateChange\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 if (thisRef.deck) {\n thisRef.deck.setProps(forwardProps);\n }\n return forwardProps;\n }, [props]);\n useEffect(() => {\n const DeckClass = props.Deck || Deck;\n thisRef.deck = createDeckInstance(thisRef, DeckClass, {\n ...deckProps,\n parent: containerRef.current,\n canvas: canvasRef.current\n });\n return () => thisRef.deck?.finalize();\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 // Execute deferred callbacks\n const { viewStateUpdateRequested, interactionStateUpdateRequested } = thisRef;\n if (viewStateUpdateRequested) {\n handleViewStateChange(viewStateUpdateRequested);\n }\n if (interactionStateUpdateRequested) {\n handleInteractionStateChange(interactionStateUpdateRequested);\n }\n });\n useImperativeHandle(ref, () => getRefHandles(thisRef), []);\n const currentViewports = thisRef.deck && thisRef.deck.isInitialized ? thisRef.deck.getViewports() : undefined;\n const { ContextProvider, width = '100%', height = '100%', id, style } = props;\n const { containerStyle, canvasStyle } = useMemo(() => extractStyles({ width, height, style }), [width, height, style]);\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 ((!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 // 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 const canvas = createElement('canvas', {\n key: 'canvas',\n id: id || 'deckgl-overlay',\n ref: canvasRef,\n style: canvasStyle\n });\n // Render deck.gl as the last child\n thisRef.control = createElement('div', { id: `${id || 'deckgl'}-wrapper`, ref: containerRef, style: containerStyle }, [canvas, childrenUnderViews]);\n }\n inRender = false;\n return thisRef.control;\n}\nconst DeckGL = React.forwardRef(DeckGLWithRef);\nexport default DeckGL;\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';\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\nexport default useIsomorphicLayoutEffect;\n", "import * as React from 'react';\nimport { createElement } from 'react';\nimport { inheritsFrom } from \"./inherits-from.js\";\nimport { Layer, View } from '@deck.gl/core';\nimport { isComponent } from \"./evaluate-children.js\";\n// recursively wrap render callbacks in `View`\nfunction wrapInView(node) {\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// extracts any deck.gl layers masquerading as react elements from props.children\nexport default function extractJSXLayers({ children, layers = [], views = null }) {\n const reactChildren = []; // extract real react elements (i.e. not deck.gl layers)\n const jsxLayers = []; // extracted layer from react children, will add to deck.gl layer array\n const jsxViews = {};\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 }\n else {\n reactChildren.push(reactElement);\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 }\n else if (reactElement) {\n reactChildren.push(reactElement);\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 }\n else if (views) {\n jsxViews[views.id] = views;\n }\n views = Object.values(jsxViews);\n }\n // Avoid modifying layers array if no JSX layers were found\n layers = jsxLayers.length > 0 ? [...jsxLayers, ...layers] : layers;\n return { layers, children: reactChildren, views };\n}\nfunction createLayer(LayerType, reactProps) {\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", "// Check if one JavaScript class inherits from another\nexport function inheritsFrom(Type, ParentType) {\n while (Type) {\n if (Type === ParentType) {\n return true;\n }\n Type = Object.getPrototypeOf(Type);\n }\n return false;\n}\n", "import { cloneElement } from 'react';\nconst MAP_STYLE = { position: 'absolute', zIndex: -1 };\nexport default function evaluateChildren(children, childProps) {\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 return children;\n}\nexport function isComponent(child) {\n return (child && typeof child === 'object' && 'type' in child) || false;\n}\nfunction isReactMap(child) {\n return child.props?.mapStyle;\n}\nfunction needsDeckGLViewProps(child) {\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", "import { createElement } from 'react';\nimport { View } from '@deck.gl/core';\nimport { inheritsFrom } from \"./inherits-from.js\";\nimport evaluateChildren, { isComponent } from \"./evaluate-children.js\";\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({ children, deck, ContextProvider }) {\n // @ts-expect-error accessing protected property\n const { viewManager } = deck || {};\n if (!viewManager || !viewManager.views.length) {\n return [];\n }\n const views = {};\n const defaultViewId = viewManager.views[0].id;\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 if (isComponent(child) && inheritsFrom(child.type, View)) {\n viewId = child.props.id || defaultViewId;\n viewChildren = child.props.children;\n }\n const viewport = viewManager.getViewport(viewId);\n const viewState = viewManager.getViewState(viewId);\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 if (!views[viewId]) {\n views[viewId] = {\n viewport,\n children: []\n };\n }\n views[viewId].children.push(viewChildren);\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 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 if (ContextProvider) {\n const contextValue = {\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 return viewElement;\n });\n}\n", "const CANVAS_ONLY_STYLES = {\n mixBlendMode: null\n};\nexport default function extractStyles({ width, height, style }) {\n // This styling is enforced for correct positioning with children\n const containerStyle = {\n position: 'absolute',\n zIndex: 0,\n left: 0,\n top: 0,\n width,\n height\n };\n // Fill the container\n const canvasStyle = {\n left: 0,\n top: 0\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 }\n else {\n // apply style to the container, e.g. position/flow settings\n containerStyle[key] = style[key];\n }\n }\n }\n return { containerStyle, canvasStyle };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmBA,IAAAA,SAAuB;AACvB,IAAAC,gBAAyF;AACzF,IAAAC,eAAqB;;;ACnBrB,mBAA2C;AAC3C,IAAM,4BAA4B,OAAO,WAAW,cAAc,+BAAkB;AACpF,IAAO,uCAAQ;;;ACJf,YAAuB;AACvB,IAAAC,gBAA8B;;;ACAvB,SAAS,aAAa,MAAM,YAAY;AAC3C,SAAO,MAAM;AACT,QAAI,SAAS,YAAY;AACrB,aAAO;AAAA,IACX;AACA,WAAO,OAAO,eAAe,IAAI;AAAA,EACrC;AACA,SAAO;AACX;;;ADNA,kBAA4B;;;AEH5B,IAAAC,gBAA6B;AAC7B,IAAM,YAAY,EAA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,MACnC,KAAK;AAAA,MACL,IAAI,MAAM;AAAA,MACV,KAAK;AAAA,MACL,OAAO;AAAA,IACX,CAAC;AAED,YAAQ,cAAU,6BAAc,OAAO,EAAE,IAAI,GAAG,MAAM,oBAAoB,KAAK,cAAc,OAAO,eAAe,GAAG,CAAC,QAAQ,kBAAkB,CAAC;AAAA,EACtJ;AACA,aAAW;AACX,SAAO,QAAQ;AACnB;AACA,IAAM,SAAe,kBAAW,aAAa;AAC7C,IAAO,iBAAQ;",
|
|
6
|
+
"names": ["React", "import_react", "import_core", "import_react", "import_react", "import_react", "import_core"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import type { ViewOrViews } from "../deckgl.js";
|
|
2
3
|
import type { Deck, DeckProps, Viewport } from '@deck.gl/core';
|
|
3
4
|
import type { EventManager } from 'mjolnir.js';
|
|
4
5
|
export type DeckGLContextValue = {
|
|
@@ -7,9 +8,9 @@ export type DeckGLContextValue = {
|
|
|
7
8
|
eventManager: EventManager;
|
|
8
9
|
onViewStateChange: DeckProps['onViewStateChange'];
|
|
9
10
|
};
|
|
10
|
-
export default function positionChildrenUnderViews({ children, deck, ContextProvider }: {
|
|
11
|
+
export default function positionChildrenUnderViews<ViewsT extends ViewOrViews>({ children, deck, ContextProvider }: {
|
|
11
12
|
children: React.ReactNode[];
|
|
12
|
-
deck?: Deck
|
|
13
|
+
deck?: Deck<ViewsT>;
|
|
13
14
|
ContextProvider?: React.Context<DeckGLContextValue>['Provider'];
|
|
14
15
|
}): React.ReactNode[];
|
|
15
16
|
//# sourceMappingURL=position-children-under-views.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"position-children-under-views.d.ts","sourceRoot":"","sources":["../../src/utils/position-children-under-views.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,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,
|
|
1
|
+
{"version":3,"file":"position-children-under-views.d.ts","sourceRoot":"","sources":["../../src/utils/position-children-under-views.ts"],"names":[],"mappings":"AAAA,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"}
|
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.0.0-beta.
|
|
6
|
+
"version": "9.0.0-beta.11",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -29,8 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"dist",
|
|
32
|
-
"src"
|
|
33
|
-
"typed"
|
|
32
|
+
"src"
|
|
34
33
|
],
|
|
35
34
|
"sideEffects": false,
|
|
36
35
|
"scripts": {},
|
|
@@ -45,5 +44,5 @@
|
|
|
45
44
|
"react": "^18.2.0",
|
|
46
45
|
"react-dom": "^18.2.0"
|
|
47
46
|
},
|
|
48
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "d8a3f5bdb644f85caba9d5c1e74baff8f8a3d439"
|
|
49
48
|
}
|
package/src/deckgl.ts
CHANGED
|
@@ -18,15 +18,7 @@
|
|
|
18
18
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
19
|
// THE SOFTWARE.
|
|
20
20
|
import * as React from 'react';
|
|
21
|
-
import {
|
|
22
|
-
createElement,
|
|
23
|
-
useRef,
|
|
24
|
-
useState,
|
|
25
|
-
useMemo,
|
|
26
|
-
useEffect,
|
|
27
|
-
useImperativeHandle,
|
|
28
|
-
forwardRef
|
|
29
|
-
} from 'react';
|
|
21
|
+
import {createElement, useRef, useState, useMemo, useEffect, useImperativeHandle} from 'react';
|
|
30
22
|
import {Deck} from '@deck.gl/core';
|
|
31
23
|
import useIsomorphicLayoutEffect from './utils/use-isomorphic-layout-effect';
|
|
32
24
|
|
|
@@ -35,11 +27,13 @@ import positionChildrenUnderViews from './utils/position-children-under-views';
|
|
|
35
27
|
import extractStyles from './utils/extract-styles';
|
|
36
28
|
|
|
37
29
|
import type {DeckGLContextValue} from './utils/position-children-under-views';
|
|
38
|
-
import type {DeckProps, Viewport} from '@deck.gl/core';
|
|
30
|
+
import type {DeckProps, View, Viewport} from '@deck.gl/core';
|
|
31
|
+
|
|
32
|
+
export type ViewOrViews = View | View[] | null;
|
|
39
33
|
|
|
40
34
|
/* eslint-disable max-statements, accessor-pairs */
|
|
41
|
-
type DeckInstanceRef = {
|
|
42
|
-
deck?: Deck
|
|
35
|
+
type DeckInstanceRef<ViewsT extends ViewOrViews> = {
|
|
36
|
+
deck?: Deck<ViewsT>;
|
|
43
37
|
redrawReason?: string | null;
|
|
44
38
|
lastRenderedViewports?: Viewport[];
|
|
45
39
|
viewStateUpdateRequested?: any;
|
|
@@ -51,25 +45,28 @@ type DeckInstanceRef = {
|
|
|
51
45
|
|
|
52
46
|
// Remove prop types in the base Deck class that support externally supplied canvas/WebGLContext
|
|
53
47
|
/** DeckGL React component props */
|
|
54
|
-
export type DeckGLProps = Omit<
|
|
55
|
-
DeckProps
|
|
48
|
+
export type DeckGLProps<ViewsT extends ViewOrViews = null> = Omit<
|
|
49
|
+
DeckProps<ViewsT>,
|
|
56
50
|
'width' | 'height' | 'gl' | 'parent' | 'canvas' | '_customRender'
|
|
57
51
|
> & {
|
|
58
52
|
Deck?: typeof Deck;
|
|
59
53
|
width?: string | number;
|
|
60
54
|
height?: string | number;
|
|
61
55
|
children?: React.ReactNode | DeckGLRenderCallback;
|
|
56
|
+
ref?: React.Ref<DeckGLRef<ViewsT>>;
|
|
62
57
|
ContextProvider?: React.Context<DeckGLContextValue>['Provider'];
|
|
63
58
|
};
|
|
64
59
|
|
|
65
|
-
export type DeckGLRef = {
|
|
66
|
-
deck?: Deck
|
|
60
|
+
export type DeckGLRef<ViewsT extends ViewOrViews = null> = {
|
|
61
|
+
deck?: Deck<ViewsT>;
|
|
67
62
|
pickObject: Deck['pickObject'];
|
|
68
63
|
pickObjects: Deck['pickObjects'];
|
|
69
64
|
pickMultipleObjects: Deck['pickMultipleObjects'];
|
|
70
65
|
};
|
|
71
66
|
|
|
72
|
-
function getRefHandles
|
|
67
|
+
function getRefHandles<ViewsT extends ViewOrViews>(
|
|
68
|
+
thisRef: DeckInstanceRef<ViewsT>
|
|
69
|
+
): DeckGLRef<ViewsT> {
|
|
73
70
|
return {
|
|
74
71
|
get deck() {
|
|
75
72
|
return thisRef.deck;
|
|
@@ -81,7 +78,7 @@ function getRefHandles(thisRef: DeckInstanceRef): DeckGLRef {
|
|
|
81
78
|
};
|
|
82
79
|
}
|
|
83
80
|
|
|
84
|
-
function redrawDeck(thisRef: DeckInstanceRef) {
|
|
81
|
+
function redrawDeck(thisRef: DeckInstanceRef<any>) {
|
|
85
82
|
if (thisRef.redrawReason) {
|
|
86
83
|
// Only redraw if we have received a dirty flag
|
|
87
84
|
// @ts-expect-error accessing protected method
|
|
@@ -90,11 +87,11 @@ function redrawDeck(thisRef: DeckInstanceRef) {
|
|
|
90
87
|
}
|
|
91
88
|
}
|
|
92
89
|
|
|
93
|
-
function createDeckInstance(
|
|
94
|
-
thisRef: DeckInstanceRef
|
|
90
|
+
function createDeckInstance<ViewsT extends ViewOrViews>(
|
|
91
|
+
thisRef: DeckInstanceRef<ViewsT>,
|
|
95
92
|
DeckClass: typeof Deck,
|
|
96
|
-
props: DeckProps
|
|
97
|
-
): Deck {
|
|
93
|
+
props: DeckProps<ViewsT>
|
|
94
|
+
): Deck<ViewsT> {
|
|
98
95
|
const deck = new DeckClass({
|
|
99
96
|
...props,
|
|
100
97
|
// The Deck's animation loop is independent from React's render cycle, causing potential
|
|
@@ -120,11 +117,14 @@ function createDeckInstance(
|
|
|
120
117
|
return deck;
|
|
121
118
|
}
|
|
122
119
|
|
|
123
|
-
|
|
120
|
+
function DeckGLWithRef<ViewsT extends ViewOrViews = null>(
|
|
121
|
+
props: DeckGLProps<ViewsT>,
|
|
122
|
+
ref: React.Ref<DeckGLRef<ViewsT>>
|
|
123
|
+
) {
|
|
124
124
|
// A mechanism to force redraw
|
|
125
125
|
const [version, setVersion] = useState(0);
|
|
126
126
|
// A reference to persistent states
|
|
127
|
-
const _thisRef = useRef<DeckInstanceRef
|
|
127
|
+
const _thisRef = useRef<DeckInstanceRef<ViewsT>>({
|
|
128
128
|
control: null,
|
|
129
129
|
version,
|
|
130
130
|
forceUpdate: () => setVersion(v => v + 1)
|
|
@@ -143,7 +143,7 @@ const DeckGL = forwardRef<DeckGLRef, DeckGLProps>((props, ref) => {
|
|
|
143
143
|
// Callbacks
|
|
144
144
|
let inRender = true;
|
|
145
145
|
|
|
146
|
-
const handleViewStateChange: DeckProps['onViewStateChange'] = params => {
|
|
146
|
+
const handleViewStateChange: DeckProps<ViewsT>['onViewStateChange'] = params => {
|
|
147
147
|
if (inRender && props.viewState) {
|
|
148
148
|
// Callback may invoke a state update. Defer callback to after render() to avoid React error
|
|
149
149
|
// In React StrictMode, render is executed twice and useEffect/useLayoutEffect is executed once
|
|
@@ -155,7 +155,7 @@ const DeckGL = forwardRef<DeckGLRef, DeckGLProps>((props, ref) => {
|
|
|
155
155
|
return props.onViewStateChange?.(params);
|
|
156
156
|
};
|
|
157
157
|
|
|
158
|
-
const handleInteractionStateChange: DeckProps['onInteractionStateChange'] = params => {
|
|
158
|
+
const handleInteractionStateChange: DeckProps<ViewsT>['onInteractionStateChange'] = params => {
|
|
159
159
|
if (inRender) {
|
|
160
160
|
// Callback may invoke a state update. Defer callback to after render() to avoid React error
|
|
161
161
|
// In React StrictMode, render is executed twice and useEffect/useLayoutEffect is executed once
|
|
@@ -171,7 +171,7 @@ const DeckGL = forwardRef<DeckGLRef, DeckGLProps>((props, ref) => {
|
|
|
171
171
|
// the next animation frame.
|
|
172
172
|
// Needs to be called both from initial mount, and when new props are received
|
|
173
173
|
const deckProps = useMemo(() => {
|
|
174
|
-
const forwardProps: DeckProps = {
|
|
174
|
+
const forwardProps: DeckProps<ViewsT> = {
|
|
175
175
|
...props,
|
|
176
176
|
// Override user styling props. We will set the canvas style in render()
|
|
177
177
|
style: null,
|
|
@@ -180,7 +180,7 @@ const DeckGL = forwardRef<DeckGLRef, DeckGLProps>((props, ref) => {
|
|
|
180
180
|
parent: containerRef.current,
|
|
181
181
|
canvas: canvasRef.current,
|
|
182
182
|
layers: jsxProps.layers,
|
|
183
|
-
views: jsxProps.views,
|
|
183
|
+
views: jsxProps.views as ViewsT,
|
|
184
184
|
onViewStateChange: handleViewStateChange,
|
|
185
185
|
onInteractionStateChange: handleInteractionStateChange
|
|
186
186
|
};
|
|
@@ -229,7 +229,7 @@ const DeckGL = forwardRef<DeckGLRef, DeckGLProps>((props, ref) => {
|
|
|
229
229
|
const currentViewports =
|
|
230
230
|
thisRef.deck && thisRef.deck.isInitialized ? thisRef.deck.getViewports() : undefined;
|
|
231
231
|
|
|
232
|
-
const {ContextProvider, width, height, id, style} = props;
|
|
232
|
+
const {ContextProvider, width = '100%', height = '100%', id, style} = props;
|
|
233
233
|
|
|
234
234
|
const {containerStyle, canvasStyle} = useMemo(
|
|
235
235
|
() => extractStyles({width, height, style}),
|
|
@@ -274,8 +274,10 @@ const DeckGL = forwardRef<DeckGLRef, DeckGLProps>((props, ref) => {
|
|
|
274
274
|
|
|
275
275
|
inRender = false;
|
|
276
276
|
return thisRef.control;
|
|
277
|
-
}
|
|
277
|
+
}
|
|
278
278
|
|
|
279
|
-
DeckGL
|
|
279
|
+
const DeckGL = React.forwardRef(DeckGLWithRef) as <ViewsT extends ViewOrViews>(
|
|
280
|
+
props: DeckGLProps<ViewsT>
|
|
281
|
+
) => React.ReactElement;
|
|
280
282
|
|
|
281
283
|
export default DeckGL;
|
|
@@ -4,6 +4,7 @@ import {View} from '@deck.gl/core';
|
|
|
4
4
|
import {inheritsFrom} from './inherits-from';
|
|
5
5
|
import evaluateChildren, {isComponent} from './evaluate-children';
|
|
6
6
|
|
|
7
|
+
import type {ViewOrViews} from '../deckgl';
|
|
7
8
|
import type {Deck, DeckProps, Viewport} from '@deck.gl/core';
|
|
8
9
|
import type {EventManager} from 'mjolnir.js';
|
|
9
10
|
|
|
@@ -16,13 +17,13 @@ export type DeckGLContextValue = {
|
|
|
16
17
|
|
|
17
18
|
// Iterate over views and reposition children associated with views
|
|
18
19
|
// TODO - Can we supply a similar function for the non-React case?
|
|
19
|
-
export default function positionChildrenUnderViews({
|
|
20
|
+
export default function positionChildrenUnderViews<ViewsT extends ViewOrViews>({
|
|
20
21
|
children,
|
|
21
22
|
deck,
|
|
22
23
|
ContextProvider
|
|
23
24
|
}: {
|
|
24
25
|
children: React.ReactNode[];
|
|
25
|
-
deck?: Deck
|
|
26
|
+
deck?: Deck<ViewsT>;
|
|
26
27
|
ContextProvider?: React.Context<DeckGLContextValue>['Provider'];
|
|
27
28
|
}): React.ReactNode[] {
|
|
28
29
|
// @ts-expect-error accessing protected property
|