@deck.gl/react
Version:
React Components for deck.gl
8 lines (7 loc) • 33.6 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../src/index.ts", "../src/deckgl.ts", "../src/utils/use-isomorphic-layout-effect.ts", "../src/utils/extract-jsx-layers.ts", "../src/utils/inherits-from.ts", "../src/utils/evaluate-children.ts", "../src/utils/position-children-under-views.ts", "../src/utils/deckgl-context.ts", "../src/utils/extract-styles.ts", "../src/widgets/compass-widget.tsx", "../src/utils/use-widget.ts", "../src/widgets/fullscreen-widget.tsx", "../src/widgets/zoom-widget.tsx"],
"sourcesContent": ["// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport {default as DeckGL} from './deckgl';\nexport {default} from './deckgl';\n\n// Widgets\nexport {CompassWidget} from './widgets/compass-widget';\nexport {FullscreenWidget} from './widgets/fullscreen-widget';\nexport {ZoomWidget} from './widgets/zoom-widget';\nexport {useWidget} from './utils/use-widget';\n\n// Types\nexport type {DeckGLContextValue} from './utils/deckgl-context';\nexport type {DeckGLRef, DeckGLProps} from './deckgl';\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as React from 'react';\nimport {createElement, useRef, useState, useMemo, useEffect, useImperativeHandle} from 'react';\nimport {Deck} from '@deck.gl/core';\nimport useIsomorphicLayoutEffect from './utils/use-isomorphic-layout-effect';\n\nimport extractJSXLayers, {DeckGLRenderCallback} from './utils/extract-jsx-layers';\nimport positionChildrenUnderViews from './utils/position-children-under-views';\nimport extractStyles from './utils/extract-styles';\n\nimport type {DeckGLContextValue} from './utils/deckgl-context';\nimport type {DeckProps, View, Viewport} from '@deck.gl/core';\n\nexport type ViewOrViews = View | View[] | null;\n\n/* eslint-disable max-statements, accessor-pairs */\ntype DeckInstanceRef<ViewsT extends ViewOrViews> = {\n deck?: Deck<ViewsT>;\n redrawReason?: string | null;\n lastRenderedViewports?: Viewport[];\n viewStateUpdateRequested?: any;\n interactionStateUpdateRequested?: any;\n forceUpdate: () => void;\n version: number;\n control: React.ReactHTMLElement<HTMLElement> | null;\n};\n\n// Remove prop types in the base Deck class that support externally supplied canvas/WebGLContext\n/** DeckGL React component props */\nexport type DeckGLProps<ViewsT extends ViewOrViews = null> = Omit<\n DeckProps<ViewsT>,\n 'width' | 'height' | 'gl' | 'parent' | 'canvas' | '_customRender'\n> & {\n Deck?: typeof Deck;\n width?: string | number;\n height?: string | number;\n children?: React.ReactNode | DeckGLRenderCallback;\n ref?: React.Ref<DeckGLRef<ViewsT>>;\n ContextProvider?: React.Context<DeckGLContextValue>['Provider'];\n};\n\nexport type DeckGLRef<ViewsT extends ViewOrViews = null> = {\n deck?: Deck<ViewsT>;\n pickObject: Deck['pickObject'];\n pickObjects: Deck['pickObjects'];\n pickMultipleObjects: Deck['pickMultipleObjects'];\n};\n\nfunction getRefHandles<ViewsT extends ViewOrViews>(\n thisRef: DeckInstanceRef<ViewsT>\n): DeckGLRef<ViewsT> {\n return {\n get deck() {\n return thisRef.deck;\n },\n // The following method can only be called after ref is available, by which point deck is defined in useEffect\n pickObject: opts => thisRef.deck!.pickObject(opts),\n pickMultipleObjects: opts => thisRef.deck!.pickMultipleObjects(opts),\n pickObjects: opts => thisRef.deck!.pickObjects(opts)\n };\n}\n\nfunction redrawDeck(thisRef: DeckInstanceRef<any>) {\n if (thisRef.redrawReason) {\n // Only redraw if we have received a dirty flag\n // @ts-expect-error accessing protected method\n thisRef.deck._drawLayers(thisRef.redrawReason);\n thisRef.redrawReason = null;\n }\n}\n\nfunction createDeckInstance<ViewsT extends ViewOrViews>(\n thisRef: DeckInstanceRef<ViewsT>,\n DeckClass: typeof Deck,\n props: DeckProps<ViewsT>\n): Deck<ViewsT> {\n const deck = new DeckClass({\n ...props,\n // The Deck's animation loop is independent from React's render cycle, causing potential\n // synchronization issues. We provide this custom render function to make sure that React\n // and Deck update on the same schedule.\n // TODO(ibgreen) - Hack to enable WebGPU as it needs to render quickly to avoid CanvasContext texture from going stale\n _customRender:\n props.deviceProps?.adapters?.[0]?.type === 'webgpu'\n ? undefined\n : redrawReason => {\n // Save the dirty flag for later\n thisRef.redrawReason = redrawReason;\n\n // Viewport/view state is passed to child components as props.\n // If they have changed, we need to trigger a React rerender to update children props.\n const viewports = deck.getViewports();\n if (thisRef.lastRenderedViewports !== viewports) {\n // Viewports have changed, update children props first.\n // This will delay the Deck canvas redraw till after React update (in useLayoutEffect)\n // so that the canvas does not get rendered before the child components update.\n thisRef.forceUpdate();\n } else {\n redrawDeck(thisRef);\n }\n }\n });\n return deck;\n}\n\nfunction DeckGLWithRef<ViewsT extends ViewOrViews = null>(\n props: DeckGLProps<ViewsT>,\n ref: React.Ref<DeckGLRef<ViewsT>>\n) {\n // A mechanism to force redraw\n const [version, setVersion] = useState(0);\n // A reference to persistent states\n const _thisRef = useRef<DeckInstanceRef<ViewsT>>({\n control: null,\n version,\n forceUpdate: () => setVersion(v => v + 1)\n });\n const thisRef = _thisRef.current;\n // DOM refs\n const containerRef = useRef(null);\n const canvasRef = useRef(null);\n\n // extract any deck.gl layers masquerading as react elements from props.children\n const jsxProps = useMemo(\n () => extractJSXLayers(props),\n [props.layers, props.views, props.children]\n );\n\n // Callbacks\n let inRender = true;\n\n const handleViewStateChange: DeckProps<ViewsT>['onViewStateChange'] = params => {\n if (inRender && props.viewState) {\n // Callback may invoke a state update. Defer callback to after render() to avoid React error\n // In React StrictMode, render is executed twice and useEffect/useLayoutEffect is executed once\n // Store deferred parameters in ref so that we can access it in another render\n thisRef.viewStateUpdateRequested = params;\n return null;\n }\n thisRef.viewStateUpdateRequested = null;\n return props.onViewStateChange?.(params);\n };\n\n const handleInteractionStateChange: DeckProps<ViewsT>['onInteractionStateChange'] = params => {\n if (inRender) {\n // Callback may invoke a state update. Defer callback to after render() to avoid React error\n // In React StrictMode, render is executed twice and useEffect/useLayoutEffect is executed once\n // Store deferred parameters in ref so that we can access it in another render\n thisRef.interactionStateUpdateRequested = params;\n } else {\n thisRef.interactionStateUpdateRequested = null;\n props.onInteractionStateChange?.(params);\n }\n };\n\n // Update Deck's props. If Deck needs redraw, this will trigger a call to `_customRender` in\n // the next animation frame.\n // Needs to be called both from initial mount, and when new props are received\n const deckProps = useMemo(() => {\n const forwardProps: DeckProps<ViewsT> = {\n widgets: [],\n ...props,\n // Override user styling props. We will set the canvas style in render()\n style: null,\n width: '100%',\n height: '100%',\n parent: containerRef.current,\n canvas: canvasRef.current,\n layers: jsxProps.layers,\n views: jsxProps.views as ViewsT,\n onViewStateChange: handleViewStateChange,\n onInteractionStateChange: handleInteractionStateChange\n };\n\n // The defaultValue for _customRender is null, which would overwrite the definition\n // of _customRender. Remove to avoid frequently redeclaring the method here.\n delete forwardProps._customRender;\n\n if (thisRef.deck) {\n thisRef.deck.setProps(forwardProps);\n }\n\n return forwardProps;\n }, [props]);\n\n useEffect(() => {\n const DeckClass = props.Deck || Deck;\n\n thisRef.deck = createDeckInstance(thisRef, DeckClass, {\n ...deckProps,\n parent: containerRef.current,\n canvas: canvasRef.current\n });\n\n return () => thisRef.deck?.finalize();\n }, []);\n\n useIsomorphicLayoutEffect(() => {\n // render has just been called. The children are positioned based on the current view state.\n // Redraw Deck canvas immediately, if necessary, using the current view state, so that it\n // matches the child components.\n redrawDeck(thisRef);\n\n // Execute deferred callbacks\n const {viewStateUpdateRequested, interactionStateUpdateRequested} = thisRef;\n if (viewStateUpdateRequested) {\n handleViewStateChange(viewStateUpdateRequested);\n }\n if (interactionStateUpdateRequested) {\n handleInteractionStateChange(interactionStateUpdateRequested);\n }\n });\n\n useImperativeHandle(ref, () => getRefHandles(thisRef), []);\n\n const currentViewports =\n thisRef.deck && thisRef.deck.isInitialized ? thisRef.deck.getViewports() : undefined;\n\n const {ContextProvider, width = '100%', height = '100%', id, style} = props;\n\n const {containerStyle, canvasStyle} = useMemo(\n () => extractStyles({width, height, style}),\n [width, height, style]\n );\n\n // Props changes may lead to 3 types of updates:\n // 1. Only the WebGL canvas - updated in Deck's render cycle (next animation frame)\n // 2. Only the DOM - updated in React's lifecycle (now)\n // 3. Both the WebGL canvas and the DOM - defer React rerender to next animation frame just\n // before Deck redraw to ensure perfect synchronization & avoid excessive redraw\n // This is because multiple changes may happen to Deck between two frames e.g. transition\n if (\n (!thisRef.viewStateUpdateRequested && thisRef.lastRenderedViewports === currentViewports) || // case 2\n thisRef.version !== version // case 3 just before deck redraws\n ) {\n thisRef.lastRenderedViewports = currentViewports;\n thisRef.version = version;\n\n // Render the background elements (typically react-map-gl instances)\n // using the view descriptors\n const childrenUnderViews = positionChildrenUnderViews({\n children: jsxProps.children,\n deck: thisRef.deck,\n ContextProvider\n });\n\n const canvas = createElement('canvas', {\n key: 'canvas',\n id: id || 'deckgl-overlay',\n ref: canvasRef,\n style: canvasStyle\n });\n\n // Render deck.gl as the last child\n thisRef.control = createElement(\n 'div',\n {id: `${id || 'deckgl'}-wrapper`, ref: containerRef, style: containerStyle},\n [canvas, childrenUnderViews]\n );\n }\n\n inRender = false;\n return thisRef.control;\n}\n\nconst DeckGL = React.forwardRef(DeckGLWithRef) as <ViewsT extends ViewOrViews>(\n props: DeckGLProps<ViewsT>\n) => React.ReactElement;\n\nexport default DeckGL;\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// From https://github.com/streamich/react-use/blob/master/src/useIsomorphicLayoutEffect.ts\n// useLayoutEffect but does not trigger warning in server-side rendering\nimport {useEffect, useLayoutEffect} from 'react';\n\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\nexport default useIsomorphicLayoutEffect;\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as React from 'react';\nimport {createElement} from 'react';\nimport {inheritsFrom} from './inherits-from';\nimport {Layer, View} from '@deck.gl/core';\nimport {isComponent} from './evaluate-children';\nimport type {LayersList, Viewport} from '@deck.gl/core';\n\nexport type DeckGLRenderCallbackArgs = {\n /**\n * the left offset of the current view, in pixels\n */\n x: number;\n /**\n * the top offset of the current view, in pixels\n */\n y: number;\n /**\n * the width of the current view, in pixels\n */\n width: number;\n /**\n * the height of the current view, in pixels\n */\n height: number;\n /**\n * the view state of the current view\n */\n viewState: any;\n /**\n * the `Viewport` instance of the current view\n */\n viewport: Viewport;\n};\n\nexport type DeckGLRenderCallback = (args: DeckGLRenderCallbackArgs) => React.ReactNode;\n\n// recursively wrap render callbacks in `View`\nfunction wrapInView(node: React.ReactNode | DeckGLRenderCallback): React.ReactNode {\n if (typeof node === 'function') {\n // React.Children does not traverse functions.\n // All render callbacks must be protected under a <View>\n // @ts-expect-error View is not a ReactJSXElement constructor. Only used as a temporary wrapper and will be removed in extractJSXLayers\n return createElement(View, {}, node);\n }\n if (Array.isArray(node)) {\n return node.map(wrapInView);\n }\n if (isComponent(node)) {\n if (node.type === React.Fragment) {\n return wrapInView(node.props.children);\n }\n if (inheritsFrom(node.type, View)) {\n return node;\n }\n }\n return node;\n}\n\n// extracts any deck.gl layers masquerading as react elements from props.children\nexport default function extractJSXLayers({\n children,\n layers = [],\n views = null\n}: {\n children?: React.ReactNode | DeckGLRenderCallback;\n layers?: LayersList;\n views?: View | View[] | null;\n}): {\n children: React.ReactNode[];\n layers: LayersList;\n views: View | View[] | null;\n} {\n const reactChildren: React.ReactNode[] = []; // extract real react elements (i.e. not deck.gl layers)\n const jsxLayers: LayersList = []; // extracted layer from react children, will add to deck.gl layer array\n const jsxViews: Record<string, View> = {};\n\n // React.children\n React.Children.forEach(wrapInView(children), reactElement => {\n if (isComponent(reactElement)) {\n // For some reason Children.forEach doesn't filter out `null`s\n const ElementType = reactElement.type;\n if (inheritsFrom(ElementType, Layer)) {\n const layer = createLayer(ElementType, reactElement.props);\n jsxLayers.push(layer);\n } else {\n reactChildren.push(reactElement);\n }\n\n // empty id => default view\n if (inheritsFrom(ElementType, View) && ElementType !== View && reactElement.props.id) {\n // @ts-ignore Cannot instantiate an abstract class (View)\n const view = new ElementType(reactElement.props);\n jsxViews[view.id] = view;\n }\n } else if (reactElement) {\n reactChildren.push(reactElement);\n }\n });\n\n // Avoid modifying views if no JSX views were found\n if (Object.keys(jsxViews).length > 0) {\n // If a view is specified in both views prop and JSX, use the one in views\n if (Array.isArray(views)) {\n views.forEach(view => {\n jsxViews[view.id] = view;\n });\n } else if (views) {\n jsxViews[views.id] = views;\n }\n views = Object.values(jsxViews);\n }\n\n // Avoid modifying layers array if no JSX layers were found\n layers = jsxLayers.length > 0 ? [...jsxLayers, ...layers] : layers;\n\n return {layers, children: reactChildren, views};\n}\n\nfunction createLayer(LayerType: typeof Layer, reactProps: any): Layer {\n const props = {};\n // Layer.defaultProps is treated as ReactElement.defaultProps and merged into react props\n // Remove them\n const defaultProps = LayerType.defaultProps || {};\n for (const key in reactProps) {\n if (defaultProps[key] !== reactProps[key]) {\n props[key] = reactProps[key];\n }\n }\n // @ts-ignore Cannot instantiate an abstract class (Layer)\n return new LayerType(props);\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Check if one JavaScript class inherits from another\nexport function inheritsFrom<T>(Type: any, ParentType: T): Type is T {\n while (Type) {\n if (Type === ParentType) {\n return true;\n }\n Type = Object.getPrototypeOf(Type);\n }\n return false;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as React from 'react';\nimport {cloneElement} from 'react';\n\nconst MAP_STYLE = {position: 'absolute', zIndex: -1};\n\nexport default function evaluateChildren(\n children: React.ReactNode | Function,\n childProps: any\n): React.ReactNode {\n if (typeof children === 'function') {\n return children(childProps);\n }\n if (Array.isArray(children)) {\n return children.map(child => evaluateChildren(child, childProps));\n }\n if (isComponent(children)) {\n // Special treatment for react-map-gl's Map component\n // to support shorthand use case <DeckGL><StaticMap /></DeckGL>\n if (isReactMap(children)) {\n // Place map under the canvas\n childProps.style = MAP_STYLE;\n return cloneElement(children, childProps);\n }\n if (needsDeckGLViewProps(children)) {\n return cloneElement(children, childProps);\n }\n }\n\n return children;\n}\n\nexport function isComponent(child: React.ReactNode): child is React.ReactElement {\n return (child && typeof child === 'object' && 'type' in child) || false;\n}\n\nfunction isReactMap(child: React.ReactElement): boolean {\n return child.props?.mapStyle;\n}\n\nfunction needsDeckGLViewProps(child: React.ReactElement): boolean {\n const componentClass = child.type;\n // @ts-expect-error deckGLViewProps is a custom hack defined on the constructor (nebula.gl)\n return componentClass && componentClass.deckGLViewProps;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as React from 'react';\nimport {createElement} from 'react';\nimport {View} from '@deck.gl/core';\nimport {inheritsFrom} from './inherits-from';\nimport evaluateChildren, {isComponent} from './evaluate-children';\n\nimport type {ViewOrViews} from '../deckgl';\nimport type {Deck, Viewport} from '@deck.gl/core';\nimport {DeckGlContext, type DeckGLContextValue} from './deckgl-context';\n\n// Iterate over views and reposition children associated with views\n// TODO - Can we supply a similar function for the non-React case?\nexport default function positionChildrenUnderViews<ViewsT extends ViewOrViews>({\n children,\n deck,\n ContextProvider = DeckGlContext.Provider\n}: {\n children: React.ReactNode[];\n deck?: Deck<ViewsT>;\n ContextProvider?: React.Context<DeckGLContextValue>['Provider'];\n}): React.ReactNode[] {\n // @ts-expect-error accessing protected property\n const {viewManager} = deck || {};\n\n if (!viewManager || !viewManager.views.length) {\n return [];\n }\n\n const views: Record<\n string,\n {\n viewport: Viewport;\n children: React.ReactNode[];\n }\n > = {};\n const defaultViewId = (viewManager.views[0] as View).id;\n\n // Sort children by view id\n for (const child of children) {\n // Unless child is a View, position / render as part of the default view\n let viewId = defaultViewId;\n let viewChildren = child;\n\n if (isComponent(child) && inheritsFrom(child.type, View)) {\n viewId = child.props.id || defaultViewId;\n viewChildren = child.props.children;\n }\n\n const viewport = viewManager.getViewport(viewId) as Viewport;\n const viewState = viewManager.getViewState(viewId);\n\n // Drop (auto-hide) elements with viewId that are not matched by any current view\n if (viewport) {\n viewState.padding = viewport.padding;\n const {x, y, width, height} = viewport;\n // Resolve potentially relative dimensions using the deck.gl container size\n viewChildren = evaluateChildren(viewChildren, {\n x,\n y,\n width,\n height,\n viewport,\n viewState\n });\n\n if (!views[viewId]) {\n views[viewId] = {\n viewport,\n children: []\n };\n }\n views[viewId].children.push(viewChildren);\n }\n }\n\n // Render views\n return Object.keys(views).map(viewId => {\n const {viewport, children: viewChildren} = views[viewId];\n const {x, y, width, height} = viewport;\n const style = {\n position: 'absolute',\n left: x,\n top: y,\n width,\n height\n };\n\n const key = `view-${viewId}`;\n // If children is passed as an array, React will throw the \"each element in a list needs\n // a key\" warning. Sending each child as separate arguments removes this requirement.\n const viewElement = createElement('div', {key, id: key, style}, ...viewChildren);\n\n const contextValue: DeckGLContextValue = {\n deck,\n viewport,\n // @ts-expect-error accessing protected property\n container: deck.canvas.offsetParent,\n // @ts-expect-error accessing protected property\n eventManager: deck.eventManager,\n onViewStateChange: params => {\n params.viewId = viewId;\n // @ts-expect-error accessing protected method\n deck._onViewStateChange(params);\n },\n widgets: []\n };\n const providerKey = `view-${viewId}-context`;\n return createElement(ContextProvider, {key: providerKey, value: contextValue}, viewElement);\n });\n}\n", "import {createContext} from 'react';\nimport type {EventManager} from 'mjolnir.js';\nimport type {Deck, DeckProps, Viewport, Widget} from '@deck.gl/core';\n\nexport type DeckGLContextValue = {\n viewport: Viewport;\n container: HTMLElement;\n eventManager: EventManager;\n onViewStateChange: DeckProps['onViewStateChange'];\n deck?: Deck<any>;\n widgets?: Widget[];\n};\n\n// @ts-ignore\nexport const DeckGlContext = createContext<DeckGLContextValue>();\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as React from 'react';\n\nconst CANVAS_ONLY_STYLES = {\n mixBlendMode: null\n};\n\nexport default function extractStyles({\n width,\n height,\n style\n}: {\n width?: string | number;\n height?: string | number;\n style?: Partial<CSSStyleDeclaration> | null;\n}): {\n containerStyle: React.CSSProperties;\n canvasStyle: React.CSSProperties;\n} {\n // This styling is enforced for correct positioning with children\n const containerStyle: React.CSSProperties = {\n position: 'absolute',\n zIndex: 0,\n left: 0,\n top: 0,\n width,\n height\n };\n\n // Fill the container\n const canvasStyle: React.CSSProperties = {\n left: 0,\n top: 0\n };\n\n if (style) {\n for (const key in style) {\n if (key in CANVAS_ONLY_STYLES) {\n // apply style to the canvas, but not deck's children, e.g. mix-blend-mode\n canvasStyle[key] = style[key];\n } else {\n // apply style to the container, e.g. position/flow settings\n containerStyle[key] = style[key];\n }\n }\n }\n\n return {containerStyle, canvasStyle};\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {CompassWidget as _CompassWidget} from '@deck.gl/widgets';\nimport type {CompassWidgetProps} from '@deck.gl/widgets';\nimport {useWidget} from '../utils/use-widget';\n\nexport const CompassWidget = (props: CompassWidgetProps = {}) => {\n useWidget(_CompassWidget, props);\n return null;\n};\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {useContext, useMemo, useEffect} from 'react';\nimport {DeckGlContext} from './deckgl-context';\nimport {log, type Widget, _deepEqual as deepEqual} from '@deck.gl/core';\n\nexport function useWidget<T extends Widget<PropsT>, PropsT extends {}>(\n WidgetClass: {new (props_: PropsT): T},\n props: PropsT\n): T {\n const context = useContext(DeckGlContext);\n const {widgets, deck} = context;\n useEffect(() => {\n // warn if the user supplied a pure-js widget, since it will be ignored\n // NOTE: This effect runs once per widget. Context widgets and deck widget props are synced after first effect runs.\n const internalWidgets = deck?.props.widgets;\n if (widgets?.length && internalWidgets?.length && !deepEqual(internalWidgets, widgets, 1)) {\n log.warn('\"widgets\" prop will be ignored because React widgets are in use.')();\n }\n\n return () => {\n // Remove widget from context when it is unmounted\n const index = widgets?.indexOf(widget);\n if (index && index !== -1) {\n widgets?.splice(index, 1);\n deck?.setProps({widgets});\n }\n };\n }, []);\n const widget = useMemo(() => new WidgetClass(props), [WidgetClass]);\n\n // Hook rebuilds widgets on every render: [] then [FirstWidget] then [FirstWidget, SecondWidget]\n widgets?.push(widget);\n widget.setProps(props);\n\n useEffect(() => {\n deck?.setProps({widgets});\n }, [widgets]);\n\n return widget;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {FullscreenWidget as _FullscreenWidget} from '@deck.gl/widgets';\nimport type {FullscreenWidgetProps} from '@deck.gl/widgets';\nimport {useWidget} from '../utils/use-widget';\n\nexport const FullscreenWidget = (props: FullscreenWidgetProps = {}) => {\n useWidget(_FullscreenWidget, props);\n return null;\n};\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ZoomWidget as _ZoomWidget} from '@deck.gl/widgets';\nimport type {ZoomWidgetProps} from '@deck.gl/widgets';\nimport {useWidget} from '../utils/use-widget';\n\nexport const ZoomWidget = (props: ZoomWidgetProps = {}) => {\n useWidget(_ZoomWidget, props);\n return null;\n};\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;ACIA,IAAAA,SAAuB;AACvB,IAAAC,gBAAuF;AACvF,IAAAC,eAAmB;;;ACAnB,mBAAyC;AAEzC,IAAM,4BAA4B,OAAO,WAAW,cAAc,+BAAkB;AAEpF,IAAA,uCAAe;;;ACNf,YAAuB;AACvB,IAAAC,gBAA4B;;;ACAtB,SAAU,aAAgB,MAAW,YAAa;AACtD,SAAO,MAAM;AACX,QAAI,SAAS,YAAY;AACvB,aAAO;IACT;AACA,WAAO,OAAO,eAAe,IAAI;EACnC;AACA,SAAO;AACT;;;ADNA,kBAA0B;;;AEF1B,IAAAC,gBAA2B;AAE3B,IAAM,YAAY,EAAC,UAAU,YAAY,QAAQ,GAAE;AAErC,SAAP,iBACL,UACA,YAAe;AAEf,MAAI,OAAO,aAAa,YAAY;AAClC,WAAO,SAAS,UAAU;EAC5B;AACA,MAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,WAAO,SAAS,IAAI,WAAS,iBAAi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AM,QAAQ,mCAAS,QAAQ;AAC/B,UAAI,SAAS,UAAU,IAAI;AACzB,2CAAS,OAAO,OAAO;AACvB,qCAAM,SAAS,EAAC,QAAO;MACzB;IACF;EACF,GAAG,CAAA,CAAE;AACL,QAAM,aAAS,uBAAQ,MAAM,IAAI,YAAY,KAAK,GAAG,CAAC,WAAW,CAAC;AAGlE,qCAAS,KAAK;AACd,SAAO,SAAS,KAAK;AAErB,+BAAU,MAAK;AACb,iCAAM,SAAS,EAAC,QAAO;EACzB,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO;AACT;;;ADlCO,IAAM,gBAAgB,CAAC,QAA4B,CAAA,MAAM;AAC9D,YAAU,eAAAC,eAAgB,KAAK;AAC/B,SAAO;AACT;;;AEPA,IAAAC,kBAAoD;AAI7C,IAAM,mBAAmB,CAAC,QAA+B,CAAA,MAAM;AACpE,YAAU,gBAAAC,kBAAmB,KAAK;AAClC,SAAO;AACT;;;ACPA,IAAAC,kBAAwC;AAIjC,IAAM,aAAa,CAAC,QAAyB,CAAA,MAAM;AACxD,YAAU,gBAAAC,YAAa,KAAK;AAC5B,SAAO;AACT;",
"names": ["React", "import_react", "import_core", "import_react", "import_react", "import_react", "import_core", "import_react", "import_react", "import_core", "deepEqual", "_CompassWidget", "import_widgets", "_FullscreenWidget", "import_widgets", "_ZoomWidget"]
}