@deck.gl/react 9.0.0-beta.1 → 9.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/deckgl.js +174 -0
  2. package/dist/index.cjs +381 -0
  3. package/dist/index.cjs.map +7 -0
  4. package/dist/index.js +21 -0
  5. package/dist/utils/evaluate-children.js +34 -0
  6. package/dist/utils/extract-jsx-layers.js +84 -0
  7. package/dist/utils/extract-styles.js +32 -0
  8. package/dist/utils/inherits-from.js +10 -0
  9. package/dist/utils/position-children-under-views.js +80 -0
  10. package/dist/{esm/utils → utils}/use-isomorphic-layout-effect.js +2 -1
  11. package/package.json +16 -8
  12. package/dist/es5/deckgl.js +0 -212
  13. package/dist/es5/deckgl.js.map +0 -1
  14. package/dist/es5/index.js +0 -22
  15. package/dist/es5/index.js.map +0 -1
  16. package/dist/es5/utils/evaluate-children.js +0 -59
  17. package/dist/es5/utils/evaluate-children.js.map +0 -1
  18. package/dist/es5/utils/extract-jsx-layers.js +0 -109
  19. package/dist/es5/utils/extract-jsx-layers.js.map +0 -1
  20. package/dist/es5/utils/extract-styles.js +0 -43
  21. package/dist/es5/utils/extract-styles.js.map +0 -1
  22. package/dist/es5/utils/inherits-from.js +0 -19
  23. package/dist/es5/utils/inherits-from.js.map +0 -1
  24. package/dist/es5/utils/position-children-under-views.js +0 -138
  25. package/dist/es5/utils/position-children-under-views.js.map +0 -1
  26. package/dist/es5/utils/use-isomorphic-layout-effect.js +0 -13
  27. package/dist/es5/utils/use-isomorphic-layout-effect.js.map +0 -1
  28. package/dist/esm/deckgl.js +0 -173
  29. package/dist/esm/deckgl.js.map +0 -1
  30. package/dist/esm/index.js +0 -3
  31. package/dist/esm/index.js.map +0 -1
  32. package/dist/esm/utils/evaluate-children.js +0 -42
  33. package/dist/esm/utils/evaluate-children.js.map +0 -1
  34. package/dist/esm/utils/extract-jsx-layers.js +0 -89
  35. package/dist/esm/utils/extract-jsx-layers.js.map +0 -1
  36. package/dist/esm/utils/extract-styles.js +0 -37
  37. package/dist/esm/utils/extract-styles.js.map +0 -1
  38. package/dist/esm/utils/inherits-from.js +0 -12
  39. package/dist/esm/utils/inherits-from.js.map +0 -1
  40. package/dist/esm/utils/position-children-under-views.js +0 -106
  41. package/dist/esm/utils/position-children-under-views.js.map +0 -1
  42. package/dist/esm/utils/use-isomorphic-layout-effect.js.map +0 -1
  43. /package/{typed → dist}/deckgl.d.ts +0 -0
  44. /package/{typed → dist}/deckgl.d.ts.map +0 -0
  45. /package/{typed → dist}/index.d.ts +0 -0
  46. /package/{typed → dist}/index.d.ts.map +0 -0
  47. /package/{typed → dist}/utils/evaluate-children.d.ts +0 -0
  48. /package/{typed → dist}/utils/evaluate-children.d.ts.map +0 -0
  49. /package/{typed → dist}/utils/extract-jsx-layers.d.ts +0 -0
  50. /package/{typed → dist}/utils/extract-jsx-layers.d.ts.map +0 -0
  51. /package/{typed → dist}/utils/extract-styles.d.ts +0 -0
  52. /package/{typed → dist}/utils/extract-styles.d.ts.map +0 -0
  53. /package/{typed → dist}/utils/inherits-from.d.ts +0 -0
  54. /package/{typed → dist}/utils/inherits-from.d.ts.map +0 -0
  55. /package/{typed → dist}/utils/position-children-under-views.d.ts +0 -0
  56. /package/{typed → dist}/utils/position-children-under-views.d.ts.map +0 -0
  57. /package/{typed → dist}/utils/use-isomorphic-layout-effect.d.ts +0 -0
  58. /package/{typed → dist}/utils/use-isomorphic-layout-effect.d.ts.map +0 -0
package/dist/deckgl.js ADDED
@@ -0,0 +1,174 @@
1
+ import { createElement, useRef, useState, useMemo, useEffect, useImperativeHandle, forwardRef } from 'react';
2
+ import { Deck } from '@deck.gl/core';
3
+ import useIsomorphicLayoutEffect from "./utils/use-isomorphic-layout-effect.js";
4
+ import extractJSXLayers from "./utils/extract-jsx-layers.js";
5
+ import positionChildrenUnderViews from "./utils/position-children-under-views.js";
6
+ import extractStyles from "./utils/extract-styles.js";
7
+ function getRefHandles(thisRef) {
8
+ return {
9
+ get deck() {
10
+ return thisRef.deck;
11
+ },
12
+ // The following method can only be called after ref is available, by which point deck is defined in useEffect
13
+ pickObject: opts => thisRef.deck.pickObject(opts),
14
+ pickMultipleObjects: opts => thisRef.deck.pickMultipleObjects(opts),
15
+ pickObjects: opts => thisRef.deck.pickObjects(opts)
16
+ };
17
+ }
18
+ function redrawDeck(thisRef) {
19
+ if (thisRef.redrawReason) {
20
+ // Only redraw if we have received a dirty flag
21
+ // @ts-expect-error accessing protected method
22
+ thisRef.deck._drawLayers(thisRef.redrawReason);
23
+ thisRef.redrawReason = null;
24
+ }
25
+ }
26
+ function createDeckInstance(thisRef, DeckClass, props) {
27
+ const deck = new DeckClass({
28
+ ...props,
29
+ // The Deck's animation loop is independent from React's render cycle, causing potential
30
+ // synchronization issues. We provide this custom render function to make sure that React
31
+ // and Deck update on the same schedule.
32
+ _customRender: redrawReason => {
33
+ // Save the dirty flag for later
34
+ thisRef.redrawReason = redrawReason;
35
+ // Viewport/view state is passed to child components as props.
36
+ // If they have changed, we need to trigger a React rerender to update children props.
37
+ const viewports = deck.getViewports();
38
+ if (thisRef.lastRenderedViewports !== viewports) {
39
+ // Viewports have changed, update children props first.
40
+ // This will delay the Deck canvas redraw till after React update (in useLayoutEffect)
41
+ // so that the canvas does not get rendered before the child components update.
42
+ thisRef.forceUpdate();
43
+ }
44
+ else {
45
+ redrawDeck(thisRef);
46
+ }
47
+ }
48
+ });
49
+ return deck;
50
+ }
51
+ const DeckGL = forwardRef((props, ref) => {
52
+ // A mechanism to force redraw
53
+ const [version, setVersion] = useState(0);
54
+ // A reference to persistent states
55
+ const _thisRef = useRef({
56
+ control: null,
57
+ version,
58
+ forceUpdate: () => setVersion(v => v + 1)
59
+ });
60
+ const thisRef = _thisRef.current;
61
+ // DOM refs
62
+ const containerRef = useRef(null);
63
+ const canvasRef = useRef(null);
64
+ // extract any deck.gl layers masquerading as react elements from props.children
65
+ const jsxProps = useMemo(() => extractJSXLayers(props), [props.layers, props.views, props.children]);
66
+ // Callbacks
67
+ let inRender = true;
68
+ const handleViewStateChange = params => {
69
+ if (inRender && props.viewState) {
70
+ // Callback may invoke a state update. Defer callback to after render() to avoid React error
71
+ // In React StrictMode, render is executed twice and useEffect/useLayoutEffect is executed once
72
+ // Store deferred parameters in ref so that we can access it in another render
73
+ thisRef.viewStateUpdateRequested = params;
74
+ return null;
75
+ }
76
+ thisRef.viewStateUpdateRequested = null;
77
+ return props.onViewStateChange?.(params);
78
+ };
79
+ const handleInteractionStateChange = params => {
80
+ if (inRender) {
81
+ // Callback may invoke a state update. Defer callback to after render() to avoid React error
82
+ // In React StrictMode, render is executed twice and useEffect/useLayoutEffect is executed once
83
+ // Store deferred parameters in ref so that we can access it in another render
84
+ thisRef.interactionStateUpdateRequested = params;
85
+ }
86
+ else {
87
+ thisRef.interactionStateUpdateRequested = null;
88
+ props.onInteractionStateChange?.(params);
89
+ }
90
+ };
91
+ // Update Deck's props. If Deck needs redraw, this will trigger a call to `_customRender` in
92
+ // the next animation frame.
93
+ // Needs to be called both from initial mount, and when new props are received
94
+ const deckProps = useMemo(() => {
95
+ const forwardProps = {
96
+ ...props,
97
+ // Override user styling props. We will set the canvas style in render()
98
+ style: null,
99
+ width: '100%',
100
+ height: '100%',
101
+ parent: containerRef.current,
102
+ canvas: canvasRef.current,
103
+ layers: jsxProps.layers,
104
+ views: jsxProps.views,
105
+ onViewStateChange: handleViewStateChange,
106
+ onInteractionStateChange: handleInteractionStateChange
107
+ };
108
+ // The defaultValue for _customRender is null, which would overwrite the definition
109
+ // of _customRender. Remove to avoid frequently redeclaring the method here.
110
+ delete forwardProps._customRender;
111
+ if (thisRef.deck) {
112
+ thisRef.deck.setProps(forwardProps);
113
+ }
114
+ return forwardProps;
115
+ }, [props]);
116
+ useEffect(() => {
117
+ const DeckClass = props.Deck || Deck;
118
+ thisRef.deck = createDeckInstance(thisRef, DeckClass, {
119
+ ...deckProps,
120
+ parent: containerRef.current,
121
+ canvas: canvasRef.current
122
+ });
123
+ return () => thisRef.deck?.finalize();
124
+ }, []);
125
+ useIsomorphicLayoutEffect(() => {
126
+ // render has just been called. The children are positioned based on the current view state.
127
+ // Redraw Deck canvas immediately, if necessary, using the current view state, so that it
128
+ // matches the child components.
129
+ redrawDeck(thisRef);
130
+ // Execute deferred callbacks
131
+ const { viewStateUpdateRequested, interactionStateUpdateRequested } = thisRef;
132
+ if (viewStateUpdateRequested) {
133
+ handleViewStateChange(viewStateUpdateRequested);
134
+ }
135
+ if (interactionStateUpdateRequested) {
136
+ handleInteractionStateChange(interactionStateUpdateRequested);
137
+ }
138
+ });
139
+ useImperativeHandle(ref, () => getRefHandles(thisRef), []);
140
+ const currentViewports = thisRef.deck && thisRef.deck.isInitialized ? thisRef.deck.getViewports() : undefined;
141
+ const { ContextProvider, width, height, id, style } = props;
142
+ const { containerStyle, canvasStyle } = useMemo(() => extractStyles({ width, height, style }), [width, height, style]);
143
+ // Props changes may lead to 3 types of updates:
144
+ // 1. Only the WebGL canvas - updated in Deck's render cycle (next animation frame)
145
+ // 2. Only the DOM - updated in React's lifecycle (now)
146
+ // 3. Both the WebGL canvas and the DOM - defer React rerender to next animation frame just
147
+ // before Deck redraw to ensure perfect synchronization & avoid excessive redraw
148
+ // This is because multiple changes may happen to Deck between two frames e.g. transition
149
+ if ((!thisRef.viewStateUpdateRequested && thisRef.lastRenderedViewports === currentViewports) || // case 2
150
+ thisRef.version !== version // case 3 just before deck redraws
151
+ ) {
152
+ thisRef.lastRenderedViewports = currentViewports;
153
+ thisRef.version = version;
154
+ // Render the background elements (typically react-map-gl instances)
155
+ // using the view descriptors
156
+ const childrenUnderViews = positionChildrenUnderViews({
157
+ children: jsxProps.children,
158
+ deck: thisRef.deck,
159
+ ContextProvider
160
+ });
161
+ const canvas = createElement('canvas', {
162
+ key: 'canvas',
163
+ id: id || 'deckgl-overlay',
164
+ ref: canvasRef,
165
+ style: canvasStyle
166
+ });
167
+ // Render deck.gl as the last child
168
+ thisRef.control = createElement('div', { id: `${id || 'deckgl'}-wrapper`, ref: containerRef, style: containerStyle }, [canvas, childrenUnderViews]);
169
+ }
170
+ inRender = false;
171
+ return thisRef.control;
172
+ });
173
+ DeckGL.defaultProps = Deck.defaultProps;
174
+ export default DeckGL;
package/dist/index.cjs ADDED
@@ -0,0 +1,381 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+
26
+ // dist/index.js
27
+ var dist_exports = {};
28
+ __export(dist_exports, {
29
+ DeckGL: () => deckgl_default,
30
+ default: () => deckgl_default
31
+ });
32
+ module.exports = __toCommonJS(dist_exports);
33
+
34
+ // dist/deckgl.js
35
+ var import_react5 = require("react");
36
+ var import_core3 = require("@deck.gl/core");
37
+
38
+ // dist/utils/use-isomorphic-layout-effect.js
39
+ var import_react = require("react");
40
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react.useLayoutEffect : import_react.useEffect;
41
+ var use_isomorphic_layout_effect_default = useIsomorphicLayoutEffect;
42
+
43
+ // dist/utils/extract-jsx-layers.js
44
+ var React = __toESM(require("react"), 1);
45
+ var import_react3 = require("react");
46
+
47
+ // dist/utils/inherits-from.js
48
+ function inheritsFrom(Type, ParentType) {
49
+ while (Type) {
50
+ if (Type === ParentType) {
51
+ return true;
52
+ }
53
+ Type = Object.getPrototypeOf(Type);
54
+ }
55
+ return false;
56
+ }
57
+
58
+ // dist/utils/extract-jsx-layers.js
59
+ var import_core = require("@deck.gl/core");
60
+
61
+ // dist/utils/evaluate-children.js
62
+ var import_react2 = require("react");
63
+ var MAP_STYLE = { position: "absolute", zIndex: -1 };
64
+ function evaluateChildren(children, childProps) {
65
+ if (typeof children === "function") {
66
+ return children(childProps);
67
+ }
68
+ if (Array.isArray(children)) {
69
+ return children.map((child) => evaluateChildren(child, childProps));
70
+ }
71
+ if (isComponent(children)) {
72
+ if (isReactMap(children)) {
73
+ childProps.style = MAP_STYLE;
74
+ return (0, import_react2.cloneElement)(children, childProps);
75
+ }
76
+ if (needsDeckGLViewProps(children)) {
77
+ return (0, import_react2.cloneElement)(children, childProps);
78
+ }
79
+ }
80
+ return children;
81
+ }
82
+ function isComponent(child) {
83
+ return child && typeof child === "object" && "type" in child || false;
84
+ }
85
+ function isReactMap(child) {
86
+ var _a;
87
+ return (_a = child.props) == null ? void 0 : _a.mapStyle;
88
+ }
89
+ function needsDeckGLViewProps(child) {
90
+ const componentClass = child.type;
91
+ return componentClass && componentClass.deckGLViewProps;
92
+ }
93
+
94
+ // dist/utils/extract-jsx-layers.js
95
+ function wrapInView(node) {
96
+ if (typeof node === "function") {
97
+ return (0, import_react3.createElement)(import_core.View, {}, node);
98
+ }
99
+ if (Array.isArray(node)) {
100
+ return node.map(wrapInView);
101
+ }
102
+ if (isComponent(node)) {
103
+ if (node.type === React.Fragment) {
104
+ return wrapInView(node.props.children);
105
+ }
106
+ if (inheritsFrom(node.type, import_core.View)) {
107
+ return node;
108
+ }
109
+ }
110
+ return node;
111
+ }
112
+ function extractJSXLayers({ children, layers = [], views = null }) {
113
+ const reactChildren = [];
114
+ const jsxLayers = [];
115
+ const jsxViews = {};
116
+ React.Children.forEach(wrapInView(children), (reactElement) => {
117
+ if (isComponent(reactElement)) {
118
+ const ElementType = reactElement.type;
119
+ if (inheritsFrom(ElementType, import_core.Layer)) {
120
+ const layer = createLayer(ElementType, reactElement.props);
121
+ jsxLayers.push(layer);
122
+ } else {
123
+ reactChildren.push(reactElement);
124
+ }
125
+ if (inheritsFrom(ElementType, import_core.View) && ElementType !== import_core.View && reactElement.props.id) {
126
+ const view = new ElementType(reactElement.props);
127
+ jsxViews[view.id] = view;
128
+ }
129
+ } else if (reactElement) {
130
+ reactChildren.push(reactElement);
131
+ }
132
+ });
133
+ if (Object.keys(jsxViews).length > 0) {
134
+ if (Array.isArray(views)) {
135
+ views.forEach((view) => {
136
+ jsxViews[view.id] = view;
137
+ });
138
+ } else if (views) {
139
+ jsxViews[views.id] = views;
140
+ }
141
+ views = Object.values(jsxViews);
142
+ }
143
+ layers = jsxLayers.length > 0 ? [...jsxLayers, ...layers] : layers;
144
+ return { layers, children: reactChildren, views };
145
+ }
146
+ function createLayer(LayerType, reactProps) {
147
+ const props = {};
148
+ const defaultProps = LayerType.defaultProps || {};
149
+ for (const key in reactProps) {
150
+ if (defaultProps[key] !== reactProps[key]) {
151
+ props[key] = reactProps[key];
152
+ }
153
+ }
154
+ return new LayerType(props);
155
+ }
156
+
157
+ // dist/utils/position-children-under-views.js
158
+ var import_react4 = require("react");
159
+ var import_core2 = require("@deck.gl/core");
160
+ function positionChildrenUnderViews({ children, deck, ContextProvider }) {
161
+ const { viewManager } = deck || {};
162
+ if (!viewManager || !viewManager.views.length) {
163
+ return [];
164
+ }
165
+ const views = {};
166
+ const defaultViewId = viewManager.views[0].id;
167
+ for (const child of children) {
168
+ let viewId = defaultViewId;
169
+ let viewChildren = child;
170
+ if (isComponent(child) && inheritsFrom(child.type, import_core2.View)) {
171
+ viewId = child.props.id || defaultViewId;
172
+ viewChildren = child.props.children;
173
+ }
174
+ const viewport = viewManager.getViewport(viewId);
175
+ const viewState = viewManager.getViewState(viewId);
176
+ if (viewport) {
177
+ viewState.padding = viewport.padding;
178
+ const { x, y, width, height } = viewport;
179
+ viewChildren = evaluateChildren(viewChildren, {
180
+ x,
181
+ y,
182
+ width,
183
+ height,
184
+ viewport,
185
+ viewState
186
+ });
187
+ if (!views[viewId]) {
188
+ views[viewId] = {
189
+ viewport,
190
+ children: []
191
+ };
192
+ }
193
+ views[viewId].children.push(viewChildren);
194
+ }
195
+ }
196
+ return Object.keys(views).map((viewId) => {
197
+ const { viewport, children: viewChildren } = views[viewId];
198
+ const { x, y, width, height } = viewport;
199
+ const style = {
200
+ position: "absolute",
201
+ left: x,
202
+ top: y,
203
+ width,
204
+ height
205
+ };
206
+ const key = `view-${viewId}`;
207
+ const viewElement = (0, import_react4.createElement)("div", { key, id: key, style }, ...viewChildren);
208
+ if (ContextProvider) {
209
+ const contextValue = {
210
+ viewport,
211
+ container: deck.canvas.offsetParent,
212
+ eventManager: deck.eventManager,
213
+ onViewStateChange: (params) => {
214
+ params.viewId = viewId;
215
+ deck._onViewStateChange(params);
216
+ }
217
+ };
218
+ return (0, import_react4.createElement)(ContextProvider, { key, value: contextValue }, viewElement);
219
+ }
220
+ return viewElement;
221
+ });
222
+ }
223
+
224
+ // dist/utils/extract-styles.js
225
+ var CANVAS_ONLY_STYLES = {
226
+ mixBlendMode: null
227
+ };
228
+ function extractStyles({ width, height, style }) {
229
+ const containerStyle = {
230
+ position: "absolute",
231
+ zIndex: 0,
232
+ left: 0,
233
+ top: 0,
234
+ width,
235
+ height
236
+ };
237
+ const canvasStyle = {
238
+ left: 0,
239
+ top: 0
240
+ };
241
+ if (style) {
242
+ for (const key in style) {
243
+ if (key in CANVAS_ONLY_STYLES) {
244
+ canvasStyle[key] = style[key];
245
+ } else {
246
+ containerStyle[key] = style[key];
247
+ }
248
+ }
249
+ }
250
+ return { containerStyle, canvasStyle };
251
+ }
252
+
253
+ // dist/deckgl.js
254
+ function getRefHandles(thisRef) {
255
+ return {
256
+ get deck() {
257
+ return thisRef.deck;
258
+ },
259
+ pickObject: (opts) => thisRef.deck.pickObject(opts),
260
+ pickMultipleObjects: (opts) => thisRef.deck.pickMultipleObjects(opts),
261
+ pickObjects: (opts) => thisRef.deck.pickObjects(opts)
262
+ };
263
+ }
264
+ function redrawDeck(thisRef) {
265
+ if (thisRef.redrawReason) {
266
+ thisRef.deck._drawLayers(thisRef.redrawReason);
267
+ thisRef.redrawReason = null;
268
+ }
269
+ }
270
+ function createDeckInstance(thisRef, DeckClass, props) {
271
+ const deck = new DeckClass({
272
+ ...props,
273
+ _customRender: (redrawReason) => {
274
+ thisRef.redrawReason = redrawReason;
275
+ const viewports = deck.getViewports();
276
+ if (thisRef.lastRenderedViewports !== viewports) {
277
+ thisRef.forceUpdate();
278
+ } else {
279
+ redrawDeck(thisRef);
280
+ }
281
+ }
282
+ });
283
+ return deck;
284
+ }
285
+ var DeckGL = (0, import_react5.forwardRef)((props, ref) => {
286
+ const [version, setVersion] = (0, import_react5.useState)(0);
287
+ const _thisRef = (0, import_react5.useRef)({
288
+ control: null,
289
+ version,
290
+ forceUpdate: () => setVersion((v) => v + 1)
291
+ });
292
+ const thisRef = _thisRef.current;
293
+ const containerRef = (0, import_react5.useRef)(null);
294
+ const canvasRef = (0, import_react5.useRef)(null);
295
+ const jsxProps = (0, import_react5.useMemo)(() => extractJSXLayers(props), [props.layers, props.views, props.children]);
296
+ let inRender = true;
297
+ const handleViewStateChange = (params) => {
298
+ var _a;
299
+ if (inRender && props.viewState) {
300
+ thisRef.viewStateUpdateRequested = params;
301
+ return null;
302
+ }
303
+ thisRef.viewStateUpdateRequested = null;
304
+ return (_a = props.onViewStateChange) == null ? void 0 : _a.call(props, params);
305
+ };
306
+ const handleInteractionStateChange = (params) => {
307
+ var _a;
308
+ if (inRender) {
309
+ thisRef.interactionStateUpdateRequested = params;
310
+ } else {
311
+ thisRef.interactionStateUpdateRequested = null;
312
+ (_a = props.onInteractionStateChange) == null ? void 0 : _a.call(props, params);
313
+ }
314
+ };
315
+ const deckProps = (0, import_react5.useMemo)(() => {
316
+ const forwardProps = {
317
+ ...props,
318
+ style: null,
319
+ width: "100%",
320
+ height: "100%",
321
+ parent: containerRef.current,
322
+ canvas: canvasRef.current,
323
+ layers: jsxProps.layers,
324
+ views: jsxProps.views,
325
+ onViewStateChange: handleViewStateChange,
326
+ onInteractionStateChange: handleInteractionStateChange
327
+ };
328
+ delete forwardProps._customRender;
329
+ if (thisRef.deck) {
330
+ thisRef.deck.setProps(forwardProps);
331
+ }
332
+ return forwardProps;
333
+ }, [props]);
334
+ (0, import_react5.useEffect)(() => {
335
+ const DeckClass = props.Deck || import_core3.Deck;
336
+ thisRef.deck = createDeckInstance(thisRef, DeckClass, {
337
+ ...deckProps,
338
+ parent: containerRef.current,
339
+ canvas: canvasRef.current
340
+ });
341
+ return () => {
342
+ var _a;
343
+ return (_a = thisRef.deck) == null ? void 0 : _a.finalize();
344
+ };
345
+ }, []);
346
+ use_isomorphic_layout_effect_default(() => {
347
+ redrawDeck(thisRef);
348
+ const { viewStateUpdateRequested, interactionStateUpdateRequested } = thisRef;
349
+ if (viewStateUpdateRequested) {
350
+ handleViewStateChange(viewStateUpdateRequested);
351
+ }
352
+ if (interactionStateUpdateRequested) {
353
+ handleInteractionStateChange(interactionStateUpdateRequested);
354
+ }
355
+ });
356
+ (0, import_react5.useImperativeHandle)(ref, () => getRefHandles(thisRef), []);
357
+ const currentViewports = thisRef.deck && thisRef.deck.isInitialized ? thisRef.deck.getViewports() : void 0;
358
+ const { ContextProvider, width, height, id, style } = props;
359
+ const { containerStyle, canvasStyle } = (0, import_react5.useMemo)(() => extractStyles({ width, height, style }), [width, height, style]);
360
+ if (!thisRef.viewStateUpdateRequested && thisRef.lastRenderedViewports === currentViewports || thisRef.version !== version) {
361
+ thisRef.lastRenderedViewports = currentViewports;
362
+ thisRef.version = version;
363
+ const childrenUnderViews = positionChildrenUnderViews({
364
+ children: jsxProps.children,
365
+ deck: thisRef.deck,
366
+ ContextProvider
367
+ });
368
+ const canvas = (0, import_react5.createElement)("canvas", {
369
+ key: "canvas",
370
+ id: id || "deckgl-overlay",
371
+ ref: canvasRef,
372
+ style: canvasStyle
373
+ });
374
+ thisRef.control = (0, import_react5.createElement)("div", { id: `${id || "deckgl"}-wrapper`, ref: containerRef, style: containerStyle }, [canvas, childrenUnderViews]);
375
+ }
376
+ inRender = false;
377
+ return thisRef.control;
378
+ });
379
+ DeckGL.defaultProps = import_core3.Deck.defaultProps;
380
+ var deckgl_default = DeckGL;
381
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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;;;ACAA,IAAAA,gBAAqG;AACrG,IAAAC,eAAqB;;;ACCrB,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,EAAE,UAAU,YAAY,QAAQ,GAAG;AACtC,SAAR,iBAAkC,UAAU,YAAY;AAC3D,MAAI,OAAO,aAAa,YAAY;AAChC,WAAO,SAAS,UAAU;AAAA,EAC9B;AACA,MAAI,MAAM,QAAQ,QAAQ,GAAG;AACzB,WAAO,SAAS,IAAI,WAAS,iBAAiB,OAAO,UAAU,CAAC;AAAA,EACpE;AACA,MAAI,YAAY,QAAQ,GAAG;AAGvB,QAAI,WAAW,QAAQ,GAAG;AAEtB,iBAAW,QAAQ;AACnB,iBAAO,4BAAa,UAAU,UAAU;AAAA,IAC5C;AACA,QAAI,qBAAqB,QAAQ,GAAG;AAChC,iBAAO,4BAAa,UAAU,UAAU;AAAA,IAC5C;AAAA,EACJ;AACA,SAAO;AACX;AACO,SAAS,YAAY,OAAO;A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AAE,0BAA0B,gCAAgC,IAAI;AACtE,QAAI,0BAA0B;AAC1B,4BAAsB,wBAAwB;AAAA,IAClD;AACA,QAAI,iCAAiC;AACjC,mCAA6B,+BAA+B;AAAA,IAChE;AAAA,EACJ,CAAC;AACD,yCAAoB,KAAK,MAAM,cAAc,OAAO,GAAG,CAAC,CAAC;AACzD,QAAM,mBAAmB,QAAQ,QAAQ,QAAQ,KAAK,gBAAgB,QAAQ,KAAK,aAAa,IAAI;AACpG,QAAM,EAAE,iBAAiB,OAAO,QAAQ,IAAI,MAAM,IAAI;AACtD,QAAM,EAAE,gBAAgB,YAAY,QAAI,uBAAQ,MAAM,cAAc,EAAE,OAAO,QAAQ,MAAM,CAAC,GAAG,CAAC,OAAO,QAAQ,KAAK,CAAC;AAOrH,MAAK,CAAC,QAAQ,4BAA4B,QAAQ,0BAA0B,oBACxE,QAAQ,YAAY,SACtB;AACE,YAAQ,wBAAwB;AAChC,YAAQ,UAAU;AAGlB,UAAM,qBAAqB,2BAA2B;AAAA,MAClD,UAAU,SAAS;AAAA,MACnB,MAAM,QAAQ;AAAA,MACd;AAAA,IACJ,CAAC;AACD,UAAM,aAAS,6BAAc,UAAU;AAAA,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,CAAC;AACD,OAAO,eAAe,kBAAK;AAC3B,IAAO,iBAAQ;",
6
+ "names": ["import_react", "import_core", "import_react", "import_react", "import_react", "import_core"]
7
+ }
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
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
+ export { default as DeckGL } from "./deckgl.js";
21
+ export { default } from "./deckgl.js";
@@ -0,0 +1,34 @@
1
+ import { cloneElement } from 'react';
2
+ const MAP_STYLE = { position: 'absolute', zIndex: -1 };
3
+ export default function evaluateChildren(children, childProps) {
4
+ if (typeof children === 'function') {
5
+ return children(childProps);
6
+ }
7
+ if (Array.isArray(children)) {
8
+ return children.map(child => evaluateChildren(child, childProps));
9
+ }
10
+ if (isComponent(children)) {
11
+ // Special treatment for react-map-gl's Map component
12
+ // to support shorthand use case <DeckGL><StaticMap /></DeckGL>
13
+ if (isReactMap(children)) {
14
+ // Place map under the canvas
15
+ childProps.style = MAP_STYLE;
16
+ return cloneElement(children, childProps);
17
+ }
18
+ if (needsDeckGLViewProps(children)) {
19
+ return cloneElement(children, childProps);
20
+ }
21
+ }
22
+ return children;
23
+ }
24
+ export function isComponent(child) {
25
+ return (child && typeof child === 'object' && 'type' in child) || false;
26
+ }
27
+ function isReactMap(child) {
28
+ return child.props?.mapStyle;
29
+ }
30
+ function needsDeckGLViewProps(child) {
31
+ const componentClass = child.type;
32
+ // @ts-expect-error deckGLViewProps is a custom hack defined on the constructor (nebula.gl)
33
+ return componentClass && componentClass.deckGLViewProps;
34
+ }