react-three-map 0.0.0 → 0.0.2

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 (78) hide show
  1. package/README.md +17 -7
  2. package/dist/cjs/main.js.js +1 -0
  3. package/dist/es/main.js.mjs +5 -0
  4. package/dist/es/main.js.mjs.map +1 -0
  5. package/dist/es/main.js10.mjs +40 -0
  6. package/dist/es/main.js10.mjs.map +1 -0
  7. package/dist/es/main.js11.mjs +13 -0
  8. package/dist/es/main.js11.mjs.map +1 -0
  9. package/dist/es/main.js12.mjs +13 -0
  10. package/dist/es/main.js12.mjs.map +1 -0
  11. package/dist/es/main.js13.mjs +31 -0
  12. package/dist/es/main.js13.mjs.map +1 -0
  13. package/dist/es/main.js14.mjs +13 -0
  14. package/dist/es/main.js14.mjs.map +1 -0
  15. package/dist/es/main.js15.mjs +15 -0
  16. package/dist/es/main.js15.mjs.map +1 -0
  17. package/dist/es/main.js16.mjs +14 -0
  18. package/dist/es/main.js16.mjs.map +1 -0
  19. package/dist/es/main.js17.mjs +56 -0
  20. package/dist/es/main.js17.mjs.map +1 -0
  21. package/dist/es/main.js18.mjs +9 -0
  22. package/dist/es/main.js18.mjs.map +1 -0
  23. package/dist/es/main.js19.mjs +320 -0
  24. package/dist/es/main.js19.mjs.map +1 -0
  25. package/dist/es/main.js2.mjs +40 -0
  26. package/dist/es/main.js2.mjs.map +1 -0
  27. package/dist/es/main.js20.mjs +72 -0
  28. package/dist/es/main.js20.mjs.map +1 -0
  29. package/dist/es/main.js21.mjs +6 -0
  30. package/dist/es/main.js21.mjs.map +1 -0
  31. package/dist/es/main.js22.mjs +19 -0
  32. package/dist/es/main.js22.mjs.map +1 -0
  33. package/dist/es/main.js23.mjs +14 -0
  34. package/dist/es/main.js23.mjs.map +1 -0
  35. package/dist/es/main.js24.mjs +34 -0
  36. package/dist/es/main.js24.mjs.map +1 -0
  37. package/dist/es/main.js25.mjs +15 -0
  38. package/dist/es/main.js25.mjs.map +1 -0
  39. package/dist/es/main.js26.mjs +8 -0
  40. package/dist/es/main.js26.mjs.map +1 -0
  41. package/dist/es/main.js27.mjs +41 -0
  42. package/dist/es/main.js27.mjs.map +1 -0
  43. package/dist/es/main.js28.mjs +26 -0
  44. package/dist/es/main.js28.mjs.map +1 -0
  45. package/dist/es/main.js3.mjs +21 -0
  46. package/dist/es/main.js3.mjs.map +1 -0
  47. package/dist/es/main.js4.mjs +11 -0
  48. package/dist/es/main.js4.mjs.map +1 -0
  49. package/dist/es/main.js5.mjs +53 -0
  50. package/dist/es/main.js5.mjs.map +1 -0
  51. package/dist/es/main.js6.mjs +16 -0
  52. package/dist/es/main.js6.mjs.map +1 -0
  53. package/dist/es/main.js7.mjs +62 -0
  54. package/dist/es/main.js7.mjs.map +1 -0
  55. package/dist/es/main.js8.mjs +58 -0
  56. package/dist/es/main.js8.mjs.map +1 -0
  57. package/dist/es/main.js9.mjs +49 -0
  58. package/dist/es/main.js9.mjs.map +1 -0
  59. package/dist/es/vite.svg +1 -0
  60. package/index.html +13 -0
  61. package/package.json +16 -15
  62. package/src/canvas/canvas.tsx +49 -0
  63. package/src/canvas/coords-to-matrix.ts +19 -0
  64. package/src/canvas/create-events.ts +73 -0
  65. package/src/canvas/state-ref.ts +9 -0
  66. package/src/canvas/use-function.ts +10 -0
  67. package/src/canvas/use-on-add.ts +67 -0
  68. package/src/canvas/use-render.ts +27 -0
  69. package/src/main.ts +1 -0
  70. package/src/stories/canvas.stories.tsx +28 -0
  71. package/src/stories/my-scene.tsx +83 -0
  72. package/src/stories/no-map.stories.tsx +12 -0
  73. package/src/vite-env.d.ts +1 -0
  74. package/tsconfig.json +25 -0
  75. package/tsconfig.node.json +10 -0
  76. package/dist/my-lib.es.js +0 -1538
  77. package/dist/my-lib.umd.js +0 -27
  78. /package/dist/{vite.svg → cjs/vite.svg} +0 -0
package/README.md CHANGED
@@ -3,9 +3,14 @@
3
3
  ⚠️ **Alpha Warning: This library is currently in its alpha phase. While functional, it's still under active development and may have bugs. Please use with caution in production and feel free to report any issues you encounter. Thank you for your understanding!**
4
4
 
5
5
 
6
- React Three Map seamlessly integrates three.js with Mapbox, allowing you to bring the power of 3D rendering to your maps.
6
+ React Three Map seamlessly integrates three.js with MapLibre and Mapbox using React, allowing you to bring the power of 3D rendering to your maps in a declarative manner.
7
+
7
8
  This package offers a Three layer that allows you to use `@react-three/fiber` within `react-map-gl` and is compatible with both Mapbox and Maplibre.
8
9
 
10
+ ## Examples
11
+
12
+ Check out our [stories](https://rodrigohamuy.github.io/react-three-map) to see it in action.
13
+
9
14
  ## Installation
10
15
 
11
16
  You can install React Three Map via npm:
@@ -17,21 +22,23 @@ npm install react-three-map
17
22
 
18
23
  ## Getting Started
19
24
 
20
- Just add `<Canvas>` inside the map and start using R3F as usual :)
25
+ Just add `<Canvas>` inside the map and start using R3F as usual. That easy!
21
26
 
22
27
  ```jsx
23
- import { ReactMapGL, StaticMap } from 'react-map-gl';
28
+ import Map from 'react-map-gl/maplibre';
24
29
  import { Canvas } from 'react-three-map';
25
30
 
26
- <ReactMapGL {...viewport} >
27
- <Canvas>
31
+ ...
32
+
33
+ <Map initialViewState={{ latitude: 51, longitude: 0, zoom: 22 }}>
34
+ <Canvas latitude={51} longitude={0}>
28
35
  {/* Use react-three-fiber as usual in here */}
29
36
  <mesh>
30
37
  <boxBufferGeometry attach="geometry" args={[1, 1, 1]} />
31
38
  <meshStandardMaterial attach="material" color="orange" />
32
39
  </mesh>
33
40
  </Canvas>
34
- </ReactMapGL>
41
+ </Map>
35
42
  ...
36
43
  ```
37
44
 
@@ -64,4 +71,7 @@ We hope that you enjoy using React Three Map as much as we enjoyed building it.
64
71
  - [ ] Add stencil buffers to occlude from the map.
65
72
  - [ ] Fully decompose the projection matrix into all the Camera properties required.
66
73
  - [ ] Support post processing.
67
- - [ ] Support multiple coordinate transformations using only one ThreeJS renderer.
74
+ - [ ] Support multiple coordinate transformations using only one ThreeJS renderer.
75
+ - [ ] Support `drei` `<Html>` component.
76
+ - [ ] Support MapBox.
77
+ - [ ] Support on demand rendering.
@@ -0,0 +1 @@
1
+ "use strict";var K=Object.create;var j=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty;var te=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of J(t))!ee.call(e,r)&&r!==o&&j(e,r,{get:()=>t[r],enumerable:!(n=Y(t,r))||n.enumerable});return e};var ne=(e,t,o)=>(o=e!=null?K(X(e)):{},te(t||!e||!e.__esModule?j(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react/jsx-runtime"),A=require("@react-three/fiber"),l=require("react"),V=require("react-dom"),w=require("three"),oe=require("maplibre-gl");function G(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const M=G(l),re=G(w),$=M.createContext(null);function ie(){var e;const t=(e=l.useContext($))===null||e===void 0?void 0:e.maps,o=l.useContext(x);return l.useMemo(()=>({...t,current:o==null?void 0:o.map}),[t,o])}function ae(e){const t=e.clone();return t.pixelsToGLUnits=e.pixelsToGLUnits,t}function N(e){return{longitude:e.center.lng,latitude:e.center.lat,zoom:e.zoom,pitch:e.pitch,bearing:e.bearing,padding:e.padding}}function P(e,t){const o=t.viewState||t;let n=!1;if("longitude"in o&&"latitude"in o){const r=e.center;e.center=new r.constructor(o.longitude,o.latitude),n=n||r!==e.center}if("zoom"in o){const r=e.zoom;e.zoom=o.zoom,n=n||r!==e.zoom}if("bearing"in o){const r=e.bearing;e.bearing=o.bearing,n=n||r!==e.bearing}if("pitch"in o){const r=e.pitch;e.pitch=o.pitch,n=n||r!==e.pitch}return o.padding&&!e.isPaddingEqual(o.padding)&&(n=!0,e.padding=o.padding),n}const se=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function F(e){if(!e)return null;if(typeof e=="string"||("toJS"in e&&(e=e.toJS()),!e.layers))return e;const t={};for(const n of e.layers)t[n.id]=n;const o=e.layers.map(n=>{let r=null;"interactive"in n&&(r=Object.assign({},n),delete r.interactive);const i=t[n.ref];if(i){r=r||Object.assign({},n),delete r.ref;for(const a of se)a in i&&(r[a]=i[a])}return r||n});return{...e,layers:o}}function ce(e,t){const o=Array.isArray(e)?e[0]:e?e.x:0,n=Array.isArray(e)?e[1]:e?e.y:0,r=Array.isArray(t)?t[0]:t?t.x:0,i=Array.isArray(t)?t[1]:t?t.y:0;return o===r&&n===i}function y(e,t){if(e===t)return!0;if(!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!y(e[o],t[o]))return!1;return!0}else if(Array.isArray(t))return!1;if(typeof e=="object"&&typeof t=="object"){const o=Object.keys(e),n=Object.keys(t);if(o.length!==n.length)return!1;for(const r of o)if(!t.hasOwnProperty(r)||!y(e[r],t[r]))return!1;return!0}return!1}const I={version:8,sources:{},layers:[]},D={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",click:"onClick",dblclick:"onDblClick",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mouseout:"onMouseOut",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchmove:"onTouchMove",touchcancel:"onTouchCancel"},T={movestart:"onMoveStart",move:"onMove",moveend:"onMoveEnd",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",zoomstart:"onZoomStart",zoom:"onZoom",zoomend:"onZoomEnd",rotatestart:"onRotateStart",rotate:"onRotate",rotateend:"onRotateEnd",pitchstart:"onPitchStart",pitch:"onPitch",pitchend:"onPitchEnd"},U={wheel:"onWheel",boxzoomstart:"onBoxZoomStart",boxzoomend:"onBoxZoomEnd",boxzoomcancel:"onBoxZoomCancel",resize:"onResize",load:"onLoad",render:"onRender",idle:"onIdle",remove:"onRemove",data:"onData",styledata:"onStyleData",sourcedata:"onSourceData",error:"onError"},le=["minZoom","maxZoom","minPitch","maxPitch","maxBounds","projection","renderWorldCopies"],ue=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class L{constructor(t,o,n){this._map=null,this._internalUpdate=!1,this._inRender=!1,this._hoveredFeatures=null,this._deferredEvents={move:!1,zoom:!1,pitch:!1,rotate:!1},this._onEvent=r=>{const i=this.props[U[r.type]];i?i(r):r.type==="error"&&console.error(r.error)},this._onPointerEvent=r=>{(r.type==="mousemove"||r.type==="mouseout")&&this._updateHover(r);const i=this.props[D[r.type]];i&&(this.props.interactiveLayerIds&&r.type!=="mouseover"&&r.type!=="mouseout"&&(r.features=this._hoveredFeatures||this._queryRenderedFeatures(r.point)),i(r),delete r.features)},this._onCameraEvent=r=>{if(!this._internalUpdate){const i=this.props[T[r.type]];i&&i(r)}r.type in this._deferredEvents&&(this._deferredEvents[r.type]=!1)},this._MapClass=t,this.props=o,this._initialize(n)}get map(){return this._map}get transform(){return this._renderTransform}setProps(t){const o=this.props;this.props=t;const n=this._updateSettings(t,o);n&&this._createShadowTransform(this._map);const r=this._updateSize(t),i=this._updateViewState(t,!0);this._updateStyle(t,o),this._updateStyleComponents(t,o),this._updateHandlers(t,o),(n||r||i&&!this._map.isMoving())&&this.redraw()}static reuse(t,o){const n=L.savedMaps.pop();if(!n)return null;const r=n.map,i=r.getContainer();for(o.className=i.className;i.childNodes.length>0;)o.appendChild(i.childNodes[0]);r._container=o;const a=r._resizeObserver;a&&(a.disconnect(),a.observe(o)),n.setProps({...t,styleDiffing:!1}),r.resize();const{initialViewState:s}=t;return s&&(s.bounds?r.fitBounds(s.bounds,{...s.fitBoundsOptions,duration:0}):n._updateViewState(s,!1)),r.isStyleLoaded()?r.fire("load"):r.once("styledata",()=>r.fire("load")),r._update(),n}_initialize(t){const{props:o}=this,{mapStyle:n=I}=o,r={...o,...o.initialViewState,accessToken:o.mapboxAccessToken||fe()||null,container:t,style:F(n)},i=r.initialViewState||r.viewState||r;if(Object.assign(r,{center:[i.longitude||0,i.latitude||0],zoom:i.zoom||0,pitch:i.pitch||0,bearing:i.bearing||0}),o.gl){const f=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=f,o.gl)}const a=new this._MapClass(r);i.padding&&a.setPadding(i.padding),o.cursor&&(a.getCanvas().style.cursor=o.cursor),this._createShadowTransform(a);const s=a._render;a._render=f=>{this._inRender=!0,s.call(a,f),this._inRender=!1};const u=a._renderTaskQueue.run;a._renderTaskQueue.run=f=>{u.call(a._renderTaskQueue,f),this._onBeforeRepaint()},a.on("render",()=>this._onAfterRepaint());const c=a.fire;a.fire=this._fireEvent.bind(this,c),a.on("resize",()=>{this._renderTransform.resize(a.transform.width,a.transform.height)}),a.on("styledata",()=>this._updateStyleComponents(this.props,{})),a.on("sourcedata",()=>this._updateStyleComponents(this.props,{}));for(const f in D)a.on(f,this._onPointerEvent);for(const f in T)a.on(f,this._onCameraEvent);for(const f in U)a.on(f,this._onEvent);this._map=a}recycle(){const o=this.map.getContainer().querySelector("[mapboxgl-children]");o==null||o.remove(),L.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const t=this._map;!this._inRender&&t.style&&(t._frame&&(t._frame.cancel(),t._frame=null),t._render())}_createShadowTransform(t){const o=ae(t.transform);t.painter.transform=o,this._renderTransform=o}_updateSize(t){const{viewState:o}=t;if(o){const n=this._map;if(o.width!==n.transform.width||o.height!==n.transform.height)return n.resize(),!0}return!1}_updateViewState(t,o){if(this._internalUpdate)return!1;const n=this._map,r=this._renderTransform,{zoom:i,pitch:a,bearing:s}=r,u=n.isMoving();u&&(r.cameraElevationReference="sea");const c=P(r,{...N(n.transform),...t});if(u&&(r.cameraElevationReference="ground"),c&&o){const f=this._deferredEvents;f.move=!0,f.zoom||(f.zoom=i!==r.zoom),f.rotate||(f.rotate=s!==r.bearing),f.pitch||(f.pitch=a!==r.pitch)}return u||P(n.transform,t),c}_updateSettings(t,o){const n=this._map;let r=!1;for(const i of le)if(i in t&&!y(t[i],o[i])){r=!0;const a=n[`set${i[0].toUpperCase()}${i.slice(1)}`];a==null||a(t[i])}return r}_updateStyle(t,o){if(t.cursor!==o.cursor&&(this._map.getCanvas().style.cursor=t.cursor),t.mapStyle!==o.mapStyle){const{mapStyle:n=I,styleDiffing:r=!0}=t,i={diff:r};return"localIdeographFontFamily"in t&&(i.localIdeographFontFamily=t.localIdeographFontFamily),this._map.setStyle(F(n),i),!0}return!1}_updateStyleComponents(t,o){const n=this._map;let r=!1;return n.isStyleLoaded()&&("light"in t&&n.setLight&&!y(t.light,o.light)&&(r=!0,n.setLight(t.light)),"fog"in t&&n.setFog&&!y(t.fog,o.fog)&&(r=!0,n.setFog(t.fog)),"terrain"in t&&n.setTerrain&&!y(t.terrain,o.terrain)&&(!t.terrain||n.getSource(t.terrain.source))&&(r=!0,n.setTerrain(t.terrain))),r}_updateHandlers(t,o){var n,r;const i=this._map;let a=!1;for(const s of ue){const u=(n=t[s])!==null&&n!==void 0?n:!0,c=(r=o[s])!==null&&r!==void 0?r:!0;y(u,c)||(a=!0,u?i[s].enable(u):i[s].disable())}return a}_queryRenderedFeatures(t){const o=this._map,{interactiveLayerIds:n=[]}=this.props;try{return o.queryRenderedFeatures(t,{layers:n.filter(o.getLayer.bind(o))})}catch{return[]}}_updateHover(t){var o;const{props:n}=this;if(n.interactiveLayerIds&&(n.onMouseMove||n.onMouseEnter||n.onMouseLeave)){const i=t.type,a=((o=this._hoveredFeatures)===null||o===void 0?void 0:o.length)>0,s=this._queryRenderedFeatures(t.point),u=s.length>0;!u&&a&&(t.type="mouseleave",this._onPointerEvent(t)),this._hoveredFeatures=s,u&&!a&&(t.type="mouseenter",this._onPointerEvent(t)),t.type=i}else this._hoveredFeatures=null}_fireEvent(t,o,n){const r=this._map,i=r.transform,a=typeof o=="string"?o:o.type;return a==="move"&&this._updateViewState(this.props,!1),a in T&&(typeof o=="object"&&(o.viewState=N(i)),this._map.isMoving())?(r.transform=this._renderTransform,t.call(r,o,n),r.transform=i,r):(t.call(r,o,n),r)}_onBeforeRepaint(){const t=this._map;this._internalUpdate=!0;for(const n in this._deferredEvents)this._deferredEvents[n]&&t.fire(n);this._internalUpdate=!1;const o=this._map.transform;this._map.transform=this._renderTransform,this._onAfterRepaint=()=>{this._map.transform=o}}}L.savedMaps=[];function fe(){let e=null;if(typeof location<"u"){const t=/access_token=([^&\/]*)/.exec(location.search);e=t&&t[1]}try{e=e||process.env.MapboxAccessToken}catch{}try{e=e||process.env.REACT_APP_MAPBOX_ACCESS_TOKEN}catch{}return e}const de=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function me(e){if(!e)return null;const t=e.map,o={getMap:()=>t,getCenter:()=>e.transform.center,getZoom:()=>e.transform.zoom,getBearing:()=>e.transform.bearing,getPitch:()=>e.transform.pitch,getPadding:()=>e.transform.padding,getBounds:()=>e.transform.getBounds(),project:n=>{const r=t.transform;t.transform=e.transform;const i=t.project(n);return t.transform=r,i},unproject:n=>{const r=t.transform;t.transform=e.transform;const i=t.unproject(n);return t.transform=r,i},queryTerrainElevation:(n,r)=>{const i=t.transform;t.transform=e.transform;const a=t.queryTerrainElevation(n,r);return t.transform=i,a}};for(const n of he(t))!(n in o)&&!de.includes(n)&&(o[n]=t[n].bind(t));return o}function he(e){const t=new Set;let o=e;for(;o;){for(const n of Object.getOwnPropertyNames(o))n[0]!=="_"&&typeof e[n]=="function"&&n!=="fire"&&n!=="setEventedParent"&&t.add(n);o=Object.getPrototypeOf(o)}return Array.from(t)}const ge=typeof document<"u"?l.useLayoutEffect:l.useEffect,ve=["baseApiUrl","maxParallelImageRequests","workerClass","workerCount","workerUrl"];function ye(e,t){for(const n of ve)n in t&&(e[n]=t[n]);const{RTLTextPlugin:o="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js"}=t;o&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()==="unavailable"&&e.setRTLTextPlugin(o,n=>{n&&console.error(n)},!1)}const x=M.createContext(null);function pe(e,t,o){const n=l.useContext($),[r,i]=l.useState(null),a=l.useRef(),{current:s}=l.useRef({mapLib:null,map:null});l.useEffect(()=>{const f=e.mapLib;let d=!0,g;return Promise.resolve(f||o).then(p=>{if(!d)return;if(!p)throw new Error("Invalid mapLib");const h="Map"in p?p:p.default;if(!h.Map)throw new Error("Invalid mapLib");if(ye(h,e),!h.supported||h.supported(e))e.reuseMaps&&(g=L.reuse(e,a.current)),g||(g=new L(h.Map,e,a.current)),s.map=me(g),s.mapLib=h,i(g),n==null||n.onMapMount(s.map,e.id);else throw new Error("Map is not supported by this browser")}).catch(p=>{const{onError:h}=e;h?h({type:"error",target:null,originalEvent:null,error:p}):console.error(p)}),()=>{d=!1,g&&(n==null||n.onMapUnmount(e.id),e.reuseMaps?g.recycle():g.destroy())}},[]),ge(()=>{r&&r.setProps(e)}),l.useImperativeHandle(t,()=>s.map,[r]);const u=l.useMemo(()=>({position:"relative",width:"100%",height:"100%",...e.style}),[e.style]),c={height:"100%"};return M.createElement("div",{id:e.id,ref:a,style:u},r&&M.createElement(x.Provider,{value:s},M.createElement("div",{"mapboxgl-children":"",style:c},e.children)))}const _e=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function b(e,t){if(!e||!t)return;const o=e.style;for(const n in t){const r=t[n];Number.isFinite(r)&&!_e.test(n)?o[n]=`${r}px`:o[n]=r}}function Ee(e,t){const{map:o,mapLib:n}=l.useContext(x),r=l.useRef({props:e});r.current.props=e;const i=l.useMemo(()=>{let O=!1;M.Children.forEach(e.children,_=>{_&&(O=!0)});const Q={...e,element:O?document.createElement("div"):null},C=new n.Marker(Q);return C.setLngLat([e.longitude,e.latitude]),C.getElement().addEventListener("click",_=>{var v,m;(m=(v=r.current.props).onClick)===null||m===void 0||m.call(v,{type:"click",target:C,originalEvent:_})}),C.on("dragstart",_=>{var v,m;const E=_;E.lngLat=i.getLngLat(),(m=(v=r.current.props).onDragStart)===null||m===void 0||m.call(v,E)}),C.on("drag",_=>{var v,m;const E=_;E.lngLat=i.getLngLat(),(m=(v=r.current.props).onDrag)===null||m===void 0||m.call(v,E)}),C.on("dragend",_=>{var v,m;const E=_;E.lngLat=i.getLngLat(),(m=(v=r.current.props).onDragEnd)===null||m===void 0||m.call(v,E)}),C},[]);l.useEffect(()=>(i.addTo(o.getMap()),()=>{i.remove()}),[]);const{longitude:a,latitude:s,offset:u,style:c,draggable:f=!1,popup:d=null,rotation:g=0,rotationAlignment:p="auto",pitchAlignment:h="auto"}=e;return l.useEffect(()=>{b(i.getElement(),c)},[c]),l.useImperativeHandle(t,()=>i,[]),(i.getLngLat().lng!==a||i.getLngLat().lat!==s)&&i.setLngLat([a,s]),u&&!ce(i.getOffset(),u)&&i.setOffset(u),i.isDraggable()!==f&&i.setDraggable(f),i.getRotation()!==g&&i.setRotation(g),i.getRotationAlignment()!==p&&i.setRotationAlignment(p),i.getPitchAlignment()!==h&&i.setPitchAlignment(h),i.getPopup()!==d&&i.setPopup(d),V.createPortal(e.children,i.getElement())}l.memo(l.forwardRef(Ee));function H(e){return new Set(e?e.trim().split(/\s+/):[])}function Ce(e,t){const{map:o,mapLib:n}=l.useContext(x),r=l.useMemo(()=>document.createElement("div"),[]),i=l.useRef({props:e});i.current.props=e;const a=l.useMemo(()=>{const s={...e},u=new n.Popup(s);return u.setLngLat([e.longitude,e.latitude]),u.once("open",c=>{var f,d;(d=(f=i.current.props).onOpen)===null||d===void 0||d.call(f,c)}),u},[]);if(l.useEffect(()=>{const s=u=>{var c,f;(f=(c=i.current.props).onClose)===null||f===void 0||f.call(c,u)};return a.on("close",s),a.setDOMContent(r).addTo(o.getMap()),()=>{a.off("close",s),a.isOpen()&&a.remove()}},[]),l.useEffect(()=>{b(a.getElement(),e.style)},[e.style]),l.useImperativeHandle(t,()=>a,[]),a.isOpen()&&((a.getLngLat().lng!==e.longitude||a.getLngLat().lat!==e.latitude)&&a.setLngLat([e.longitude,e.latitude]),e.offset&&!y(a.options.offset,e.offset)&&a.setOffset(e.offset),(a.options.anchor!==e.anchor||a.options.maxWidth!==e.maxWidth)&&(a.options.anchor=e.anchor,a.setMaxWidth(e.maxWidth)),a.options.className!==e.className)){const s=H(a.options.className),u=H(e.className);for(const c of s)u.has(c)||a.removeClassName(c);for(const c of u)s.has(c)||a.addClassName(c);a.options.className=e.className}return V.createPortal(e.children,r)}l.memo(l.forwardRef(Ce));function S(e,t,o,n){const r=l.useContext(x),i=l.useMemo(()=>e(r),[]);return l.useEffect(()=>{const a=n||o||t,s=typeof t=="function"&&typeof o=="function"?t:null,u=typeof o=="function"?o:typeof t=="function"?t:null,{map:c}=r;return c.hasControl(i)||(c.addControl(i,a==null?void 0:a.position),s&&s(r)),()=>{u&&u(r),c.hasControl(i)&&c.removeControl(i)}},[]),i}function Me(e){const t=S(({mapLib:o})=>new o.AttributionControl(e),{position:e.position});return l.useEffect(()=>{b(t._container,e.style)},[e.style]),null}l.memo(Me);function be(e){const t=S(({mapLib:o})=>new o.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return l.useEffect(()=>{b(t._controlContainer,e.style)},[e.style]),null}l.memo(be);function Le(e,t){const o=l.useRef({props:e}),n=S(({mapLib:r})=>{const i=new r.GeolocateControl(e),a=i._setupUI;return i._setupUI=s=>{i._container.hasChildNodes()||a(s)},i.on("geolocate",s=>{var u,c;(c=(u=o.current.props).onGeolocate)===null||c===void 0||c.call(u,s)}),i.on("error",s=>{var u,c;(c=(u=o.current.props).onError)===null||c===void 0||c.call(u,s)}),i.on("outofmaxbounds",s=>{var u,c;(c=(u=o.current.props).onOutOfMaxBounds)===null||c===void 0||c.call(u,s)}),i.on("trackuserlocationstart",s=>{var u,c;(c=(u=o.current.props).onTrackUserLocationStart)===null||c===void 0||c.call(u,s)}),i.on("trackuserlocationend",s=>{var u,c;(c=(u=o.current.props).onTrackUserLocationEnd)===null||c===void 0||c.call(u,s)}),i},{position:e.position});return o.current.props=e,l.useImperativeHandle(t,()=>n,[]),l.useEffect(()=>{b(n._container,e.style)},[e.style]),null}l.memo(l.forwardRef(Le));function we(e){const t=S(({mapLib:o})=>new o.NavigationControl(e),{position:e.position});return l.useEffect(()=>{b(t._container,e.style)},[e.style]),null}l.memo(we);function xe(e){const t=S(({mapLib:i})=>new i.ScaleControl(e),{position:e.position}),o=l.useRef(e),n=o.current;o.current=e;const{style:r}=e;return e.maxWidth!==void 0&&e.maxWidth!==n.maxWidth&&(t.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==n.unit&&t.setUnit(e.unit),l.useEffect(()=>{b(t._container,r)},[r]),null}l.memo(xe);function q(e,t){if(!e)throw new Error(t)}function Se(e,t,o,n){if(q(o.id===n.id,"layer id changed"),q(o.type===n.type,"layer type changed"),o.type==="custom"||n.type==="custom")return;const{layout:r={},paint:i={},filter:a,minzoom:s,maxzoom:u,beforeId:c}=o;if(c!==n.beforeId&&e.moveLayer(t,c),r!==n.layout){const f=n.layout||{};for(const d in r)y(r[d],f[d])||e.setLayoutProperty(t,d,r[d]);for(const d in f)r.hasOwnProperty(d)||e.setLayoutProperty(t,d,void 0)}if(i!==n.paint){const f=n.paint||{};for(const d in i)y(i[d],f[d])||e.setPaintProperty(t,d,i[d]);for(const d in f)i.hasOwnProperty(d)||e.setPaintProperty(t,d,void 0)}y(a,n.filter)||e.setFilter(t,a),(s!==n.minzoom||u!==n.maxzoom)&&e.setLayerZoomRange(t,s,u)}function Re(e,t,o){if(e.style&&e.style._loaded&&(!("source"in o)||e.getSource(o.source))){const n={...o,id:t};delete n.beforeId,e.addLayer(n,o.beforeId)}}let Te=0;function ze(e){const t=l.useContext(x).map.getMap(),o=l.useRef(e),[,n]=l.useState(0),r=l.useMemo(()=>e.id||`jsx-layer-${Te++}`,[]);if(l.useEffect(()=>{if(t){const a=()=>n(s=>s+1);return t.on("styledata",a),a(),()=>{t.off("styledata",a),t.style&&t.style._loaded&&t.getLayer(r)&&t.removeLayer(r)}}},[t]),t&&t.style&&t.getLayer(r))try{Se(t,r,e,o.current)}catch(a){console.warn(a)}else Re(t,r,e);return o.current=e,null}function ke(){return ie()}const Ae=import("maplibre-gl");M.forwardRef(function(t,o){return pe(t,o,Ae)});const W=new w.Quaternion,Oe=new w.Euler,Z=new w.Vector3,B=new w.Vector3;function je({longitude:e,latitude:t,altitude:o}){const n=oe.MercatorCoordinate.fromLngLat([e,t],o),r=n.meterInMercatorCoordinateUnits();return Z.set(n.x,n.y,n.z||0),B.set(r,-r,r),W.setFromEuler(Oe.set(-Math.PI*.5,0,0)),new w.Matrix4().compose(Z,W,B)}const z={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function Ne(){return e=>{const{handlePointer:t}=A.createEvents(e);return{priority:1,enabled:!0,compute(o,n){n.size.width=n.gl.domElement.width,n.size.height=n.gl.domElement.height,n.pointer.x=o.offsetX/(n.size.width/window.devicePixelRatio)*2-1,n.pointer.y=1-o.offsetY/(n.size.height/window.devicePixelRatio)*2,n.raycaster.camera=n.camera,n.raycaster.ray.origin.setScalar(0).applyMatrix4(n.camera.projectionMatrixInverse),n.raycaster.ray.direction.set(n.pointer.x,n.pointer.y,1).applyMatrix4(n.camera.projectionMatrixInverse).sub(n.raycaster.ray.origin).normalize()},connected:void 0,handlers:Object.keys(z).reduce((o,n)=>({...o,[n]:t(n)}),{}),update:()=>{var r;const{events:o,internal:n}=e.getState();(r=n.lastEvent)!=null&&r.current&&o.handlers&&o.handlers.onPointerMove(n.lastEvent.current)},connect:o=>{var i;const{set:n,events:r}=e.getState();(i=r.disconnect)==null||i.call(r),n(a=>({events:{...a.events,connected:o}})),Object.entries(r.handlers??[]).forEach(([a,s])=>{const[u,c]=z[a];o.addEventListener(u,s,{passive:c})})},disconnect:()=>{const{set:o,events:n}=e.getState();n.connected&&(Object.entries(n.handlers??[]).forEach(([r,i])=>{if(n&&n.connected instanceof HTMLElement){const[a]=z[r];n.connected.removeEventListener(a,i)}}),o(r=>({events:{...r.events,connected:void 0}})))}}}}const k=e=>{const t=l.useRef(e);return t.current=e,l.useCallback((...o)=>t.current(...o),[])};function Pe(e,t){const[o,n]=l.useState(!1),r=k((a,s)=>{const u=a.getCanvas(),c=A.createRoot(u);c.configure({frameloop:"never",dpr:window.devicePixelRatio,shadows:!0,events:Ne(),...t,gl:{context:s,depth:!0,autoClear:!1,antialias:!0,...t==null?void 0:t.gl},onCreated:f=>{e.current={state:f,map:a,root:c},f.gl.forceContextLoss=()=>{}},camera:{matrixAutoUpdate:!1},size:{width:u.clientWidth,height:u.clientHeight,top:0,left:0,...t==null?void 0:t.size}}),e.current={map:a,root:c},setTimeout(()=>n(!0))}),i=k(()=>{setTimeout(()=>{e.current&&e.current.root.unmount()})});return{onAdd:r,onRemove:i,mounted:o}}function Fe(e,t){const o=ke();return k((r,i)=>{var c;if(!o.current||!((c=t.current)!=null&&c.state))return;const a=t.current.state.camera,s=t.current.state.gl,u=t.current.state.advance;a.projectionMatrix.fromArray(i).multiply(e),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),s.resetState(),u(Date.now()*.001,!0),o.current.triggerRepaint()})}A.extend(re);const Ie=l.memo(({longitude:e,latitude:t,altitude:o=0,children:n,...r})=>{const i=l.useId(),a=l.useRef(),s=l.useMemo(()=>je({latitude:t,longitude:e,altitude:o}),[t,e,o]),{onAdd:u,onRemove:c,mounted:f}=Pe(a,r),d=Fe(s,a);return l.useEffect(()=>{f&&a.current&&a.current.root.render(R.jsx(R.Fragment,{children:n}))},[a,f,n]),R.jsx(ze,{id:i,type:"custom",renderingMode:"3d",onAdd:u,onRemove:c,render:d})});exports.Canvas=Ie;
@@ -0,0 +1,5 @@
1
+ import { Canvas as r } from "./main.js2.mjs";
2
+ export {
3
+ r as Canvas
4
+ };
5
+ //# sourceMappingURL=main.js.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,40 @@
1
+ import { createPortal as h } from "react-dom";
2
+ import { memo as L, forwardRef as v, useContext as C, useMemo as f, useRef as x, useEffect as m, useImperativeHandle as N } from "react";
3
+ import { applyReactStyle as M } from "./main.js23.mjs";
4
+ import { MapContext as O } from "./main.js8.mjs";
5
+ import { deepEqual as y } from "./main.js24.mjs";
6
+ function r(t) {
7
+ return new Set(t ? t.trim().split(/\s+/) : []);
8
+ }
9
+ function E(t, u) {
10
+ const { map: d, mapLib: g } = C(O), c = f(() => document.createElement("div"), []), i = x({ props: t });
11
+ i.current.props = t;
12
+ const e = f(() => {
13
+ const a = { ...t }, o = new g.Popup(a);
14
+ return o.setLngLat([t.longitude, t.latitude]), o.once("open", (n) => {
15
+ var s, l;
16
+ (l = (s = i.current.props).onOpen) === null || l === void 0 || l.call(s, n);
17
+ }), o;
18
+ }, []);
19
+ if (m(() => {
20
+ const a = (o) => {
21
+ var n, s;
22
+ (s = (n = i.current.props).onClose) === null || s === void 0 || s.call(n, o);
23
+ };
24
+ return e.on("close", a), e.setDOMContent(c).addTo(d.getMap()), () => {
25
+ e.off("close", a), e.isOpen() && e.remove();
26
+ };
27
+ }, []), m(() => {
28
+ M(e.getElement(), t.style);
29
+ }, [t.style]), N(u, () => e, []), e.isOpen() && ((e.getLngLat().lng !== t.longitude || e.getLngLat().lat !== t.latitude) && e.setLngLat([t.longitude, t.latitude]), t.offset && !y(e.options.offset, t.offset) && e.setOffset(t.offset), (e.options.anchor !== t.anchor || e.options.maxWidth !== t.maxWidth) && (e.options.anchor = t.anchor, e.setMaxWidth(t.maxWidth)), e.options.className !== t.className)) {
30
+ const a = r(e.options.className), o = r(t.className);
31
+ for (const n of a)
32
+ o.has(n) || e.removeClassName(n);
33
+ for (const n of o)
34
+ a.has(n) || e.addClassName(n);
35
+ e.options.className = t.className;
36
+ }
37
+ return h(t.children, c);
38
+ }
39
+ L(v(E));
40
+ //# sourceMappingURL=main.js10.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js10.mjs","sources":["../../node_modules/react-map-gl/dist/esm/components/popup.js"],"sourcesContent":["import { createPortal } from 'react-dom';\nimport { useImperativeHandle, useEffect, useMemo, useRef, useContext, forwardRef, memo } from 'react';\nimport { applyReactStyle } from '../utils/apply-react-style';\nimport { MapContext } from './map';\nimport { deepEqual } from '../utils/deep-equal';\n// Adapted from https://github.com/mapbox/mapbox-gl-js/blob/v1.13.0/src/ui/popup.js\nfunction getClassList(className) {\n return new Set(className ? className.trim().split(/\\s+/) : []);\n}\n/* eslint-disable complexity,max-statements */\nfunction Popup(props, ref) {\n const { map, mapLib } = useContext(MapContext);\n const container = useMemo(() => {\n return document.createElement('div');\n }, []);\n const thisRef = useRef({ props });\n thisRef.current.props = props;\n const popup = useMemo(() => {\n const options = { ...props };\n const pp = new mapLib.Popup(options);\n pp.setLngLat([props.longitude, props.latitude]);\n pp.once('open', e => {\n var _a, _b;\n (_b = (_a = thisRef.current.props).onOpen) === null || _b === void 0 ? void 0 : _b.call(_a, e);\n });\n return pp;\n }, []);\n useEffect(() => {\n const onClose = e => {\n var _a, _b;\n (_b = (_a = thisRef.current.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a, e);\n };\n popup.on('close', onClose);\n popup.setDOMContent(container).addTo(map.getMap());\n return () => {\n // https://github.com/visgl/react-map-gl/issues/1825\n // onClose should not be fired if the popup is removed by unmounting\n // When using React strict mode, the component is mounted twice.\n // Firing the onClose callback here would be a false signal to remove the component.\n popup.off('close', onClose);\n if (popup.isOpen()) {\n popup.remove();\n }\n };\n }, []);\n useEffect(() => {\n applyReactStyle(popup.getElement(), props.style);\n }, [props.style]);\n useImperativeHandle(ref, () => popup, []);\n if (popup.isOpen()) {\n if (popup.getLngLat().lng !== props.longitude || popup.getLngLat().lat !== props.latitude) {\n popup.setLngLat([props.longitude, props.latitude]);\n }\n if (props.offset && !deepEqual(popup.options.offset, props.offset)) {\n popup.setOffset(props.offset);\n }\n if (popup.options.anchor !== props.anchor || popup.options.maxWidth !== props.maxWidth) {\n popup.options.anchor = props.anchor;\n popup.setMaxWidth(props.maxWidth);\n }\n if (popup.options.className !== props.className) {\n const prevClassList = getClassList(popup.options.className);\n const nextClassList = getClassList(props.className);\n for (const c of prevClassList) {\n if (!nextClassList.has(c)) {\n popup.removeClassName(c);\n }\n }\n for (const c of nextClassList) {\n if (!prevClassList.has(c)) {\n popup.addClassName(c);\n }\n }\n popup.options.className = props.className;\n }\n }\n return createPortal(props.children, container);\n}\nexport default memo(forwardRef(Popup));\n//# sourceMappingURL=popup.js.map"],"names":["getClassList","className","Popup","props","ref","map","mapLib","useContext","MapContext","container","useMemo","thisRef","useRef","popup","options","pp","e","_a","_b","useEffect","onClose","applyReactStyle","useImperativeHandle","deepEqual","prevClassList","nextClassList","c","createPortal","memo","forwardRef"],"mappings":";;;;;AAMA,SAASA,EAAaC,GAAW;AAC7B,SAAO,IAAI,IAAIA,IAAYA,EAAU,KAAM,EAAC,MAAM,KAAK,IAAI,CAAA,CAAE;AACjE;AAEA,SAASC,EAAMC,GAAOC,GAAK;AACvB,QAAM,EAAE,KAAAC,GAAK,QAAAC,EAAQ,IAAGC,EAAWC,CAAU,GACvCC,IAAYC,EAAQ,MACf,SAAS,cAAc,KAAK,GACpC,CAAE,CAAA,GACCC,IAAUC,EAAO,EAAE,OAAAT,EAAO,CAAA;AAChC,EAAAQ,EAAQ,QAAQ,QAAQR;AACxB,QAAMU,IAAQH,EAAQ,MAAM;AACxB,UAAMI,IAAU,EAAE,GAAGX,KACfY,IAAK,IAAIT,EAAO,MAAMQ,CAAO;AACnC,WAAAC,EAAG,UAAU,CAACZ,EAAM,WAAWA,EAAM,QAAQ,CAAC,GAC9CY,EAAG,KAAK,QAAQ,CAAAC,MAAK;AACjB,UAAIC,GAAIC;AACR,OAACA,KAAMD,IAAKN,EAAQ,QAAQ,OAAO,YAAY,QAAQO,MAAO,UAAkBA,EAAG,KAAKD,GAAID,CAAC;AAAA,IACzG,CAAS,GACMD;AAAA,EACV,GAAE,CAAE,CAAA;AAuBL,MAtBAI,EAAU,MAAM;AACZ,UAAMC,IAAU,CAAAJ,MAAK;AACjB,UAAIC,GAAIC;AACR,OAACA,KAAMD,IAAKN,EAAQ,QAAQ,OAAO,aAAa,QAAQO,MAAO,UAAkBA,EAAG,KAAKD,GAAID,CAAC;AAAA,IAC1G;AACQ,WAAAH,EAAM,GAAG,SAASO,CAAO,GACzBP,EAAM,cAAcJ,CAAS,EAAE,MAAMJ,EAAI,OAAM,CAAE,GAC1C,MAAM;AAKT,MAAAQ,EAAM,IAAI,SAASO,CAAO,GACtBP,EAAM,YACNA,EAAM,OAAM;AAAA,IAE5B;AAAA,EACK,GAAE,CAAE,CAAA,GACLM,EAAU,MAAM;AACZ,IAAAE,EAAgBR,EAAM,WAAY,GAAEV,EAAM,KAAK;AAAA,EACvD,GAAO,CAACA,EAAM,KAAK,CAAC,GAChBmB,EAAoBlB,GAAK,MAAMS,GAAO,CAAE,CAAA,GACpCA,EAAM,cACFA,EAAM,YAAY,QAAQV,EAAM,aAAaU,EAAM,UAAW,EAAC,QAAQV,EAAM,aAC7EU,EAAM,UAAU,CAACV,EAAM,WAAWA,EAAM,QAAQ,CAAC,GAEjDA,EAAM,UAAU,CAACoB,EAAUV,EAAM,QAAQ,QAAQV,EAAM,MAAM,KAC7DU,EAAM,UAAUV,EAAM,MAAM,IAE5BU,EAAM,QAAQ,WAAWV,EAAM,UAAUU,EAAM,QAAQ,aAAaV,EAAM,cAC1EU,EAAM,QAAQ,SAASV,EAAM,QAC7BU,EAAM,YAAYV,EAAM,QAAQ,IAEhCU,EAAM,QAAQ,cAAcV,EAAM,YAAW;AAC7C,UAAMqB,IAAgBxB,EAAaa,EAAM,QAAQ,SAAS,GACpDY,IAAgBzB,EAAaG,EAAM,SAAS;AAClD,eAAWuB,KAAKF;AACZ,MAAKC,EAAc,IAAIC,CAAC,KACpBb,EAAM,gBAAgBa,CAAC;AAG/B,eAAWA,KAAKD;AACZ,MAAKD,EAAc,IAAIE,CAAC,KACpBb,EAAM,aAAaa,CAAC;AAG5B,IAAAb,EAAM,QAAQ,YAAYV,EAAM;AAAA;AAGxC,SAAOwB,EAAaxB,EAAM,UAAUM,CAAS;AACjD;AACemB,EAAKC,EAAW3B,CAAK,CAAC;","x_google_ignoreList":[0]}
@@ -0,0 +1,13 @@
1
+ import { memo as i, useEffect as r } from "react";
2
+ import { applyReactStyle as e } from "./main.js23.mjs";
3
+ import l from "./main.js25.mjs";
4
+ function m(t) {
5
+ const o = l(({ mapLib: n }) => new n.AttributionControl(t), {
6
+ position: t.position
7
+ });
8
+ return r(() => {
9
+ e(o._container, t.style);
10
+ }, [t.style]), null;
11
+ }
12
+ i(m);
13
+ //# sourceMappingURL=main.js11.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js11.mjs","sources":["../../node_modules/react-map-gl/dist/esm/components/attribution-control.js"],"sourcesContent":["import { useEffect, memo } from 'react';\nimport { applyReactStyle } from '../utils/apply-react-style';\nimport useControl from './use-control';\nfunction AttributionControl(props) {\n const ctrl = useControl(({ mapLib }) => new mapLib.AttributionControl(props), {\n position: props.position\n });\n useEffect(() => {\n applyReactStyle(ctrl._container, props.style);\n }, [props.style]);\n return null;\n}\nexport default memo(AttributionControl);\n//# sourceMappingURL=attribution-control.js.map"],"names":["AttributionControl","props","ctrl","useControl","mapLib","useEffect","applyReactStyle","memo"],"mappings":";;;AAGA,SAASA,EAAmBC,GAAO;AAC/B,QAAMC,IAAOC,EAAW,CAAC,EAAE,QAAAC,EAAQ,MAAK,IAAIA,EAAO,mBAAmBH,CAAK,GAAG;AAAA,IAC1E,UAAUA,EAAM;AAAA,EACxB,CAAK;AACD,SAAAI,EAAU,MAAM;AACZ,IAAAC,EAAgBJ,EAAK,YAAYD,EAAM,KAAK;AAAA,EACpD,GAAO,CAACA,EAAM,KAAK,CAAC,GACT;AACX;AACeM,EAAKP,CAAkB;","x_google_ignoreList":[0]}
@@ -0,0 +1,13 @@
1
+ import { memo as o, useEffect as l } from "react";
2
+ import { applyReactStyle as r } from "./main.js23.mjs";
3
+ import c from "./main.js25.mjs";
4
+ function i(t) {
5
+ const n = c(({ mapLib: e }) => new e.FullscreenControl({
6
+ container: t.containerId && document.getElementById(t.containerId)
7
+ }), { position: t.position });
8
+ return l(() => {
9
+ r(n._controlContainer, t.style);
10
+ }, [t.style]), null;
11
+ }
12
+ o(i);
13
+ //# sourceMappingURL=main.js12.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js12.mjs","sources":["../../node_modules/react-map-gl/dist/esm/components/fullscreen-control.js"],"sourcesContent":["import { useEffect, memo } from 'react';\nimport { applyReactStyle } from '../utils/apply-react-style';\nimport useControl from './use-control';\nfunction FullscreenControl(props) {\n const ctrl = useControl(({ mapLib }) => new mapLib.FullscreenControl({\n container: props.containerId && document.getElementById(props.containerId)\n }), { position: props.position });\n useEffect(() => {\n applyReactStyle(ctrl._controlContainer, props.style);\n }, [props.style]);\n return null;\n}\nexport default memo(FullscreenControl);\n//# sourceMappingURL=fullscreen-control.js.map"],"names":["FullscreenControl","props","ctrl","useControl","mapLib","useEffect","applyReactStyle","memo"],"mappings":";;;AAGA,SAASA,EAAkBC,GAAO;AAC9B,QAAMC,IAAOC,EAAW,CAAC,EAAE,QAAAC,EAAM,MAAO,IAAIA,EAAO,kBAAkB;AAAA,IACjE,WAAWH,EAAM,eAAe,SAAS,eAAeA,EAAM,WAAW;AAAA,EAC5E,CAAA,GAAG,EAAE,UAAUA,EAAM,SAAU,CAAA;AAChC,SAAAI,EAAU,MAAM;AACZ,IAAAC,EAAgBJ,EAAK,mBAAmBD,EAAM,KAAK;AAAA,EAC3D,GAAO,CAACA,EAAM,KAAK,CAAC,GACT;AACX;AACeM,EAAKP,CAAiB;","x_google_ignoreList":[0]}
@@ -0,0 +1,31 @@
1
+ import { memo as s, forwardRef as d, useRef as v, useImperativeHandle as _, useEffect as f } from "react";
2
+ import { applyReactStyle as p } from "./main.js23.mjs";
3
+ import m from "./main.js25.mjs";
4
+ function b(e, c) {
5
+ const a = v({ props: e }), l = m(({ mapLib: i }) => {
6
+ const n = new i.GeolocateControl(e), u = n._setupUI;
7
+ return n._setupUI = (t) => {
8
+ n._container.hasChildNodes() || u(t);
9
+ }, n.on("geolocate", (t) => {
10
+ var r, o;
11
+ (o = (r = a.current.props).onGeolocate) === null || o === void 0 || o.call(r, t);
12
+ }), n.on("error", (t) => {
13
+ var r, o;
14
+ (o = (r = a.current.props).onError) === null || o === void 0 || o.call(r, t);
15
+ }), n.on("outofmaxbounds", (t) => {
16
+ var r, o;
17
+ (o = (r = a.current.props).onOutOfMaxBounds) === null || o === void 0 || o.call(r, t);
18
+ }), n.on("trackuserlocationstart", (t) => {
19
+ var r, o;
20
+ (o = (r = a.current.props).onTrackUserLocationStart) === null || o === void 0 || o.call(r, t);
21
+ }), n.on("trackuserlocationend", (t) => {
22
+ var r, o;
23
+ (o = (r = a.current.props).onTrackUserLocationEnd) === null || o === void 0 || o.call(r, t);
24
+ }), n;
25
+ }, { position: e.position });
26
+ return a.current.props = e, _(c, () => l, []), f(() => {
27
+ p(l._container, e.style);
28
+ }, [e.style]), null;
29
+ }
30
+ s(d(b));
31
+ //# sourceMappingURL=main.js13.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js13.mjs","sources":["../../node_modules/react-map-gl/dist/esm/components/geolocate-control.js"],"sourcesContent":["import { useImperativeHandle, useRef, useEffect, forwardRef, memo } from 'react';\nimport { applyReactStyle } from '../utils/apply-react-style';\nimport useControl from './use-control';\nfunction GeolocateControl(props, ref) {\n const thisRef = useRef({ props });\n const ctrl = useControl(({ mapLib }) => {\n const gc = new mapLib.GeolocateControl(props);\n // Hack: fix GeolocateControl reuse\n // When using React strict mode, the component is mounted twice.\n // GeolocateControl's UI creation is asynchronous. Removing and adding it back causes the UI to be initialized twice.\n // @ts-expect-error private method\n const setupUI = gc._setupUI;\n // @ts-expect-error private method\n gc._setupUI = args => {\n if (!gc._container.hasChildNodes()) {\n setupUI(args);\n }\n };\n gc.on('geolocate', e => {\n var _a, _b;\n (_b = (_a = thisRef.current.props).onGeolocate) === null || _b === void 0 ? void 0 : _b.call(_a, e);\n });\n gc.on('error', e => {\n var _a, _b;\n (_b = (_a = thisRef.current.props).onError) === null || _b === void 0 ? void 0 : _b.call(_a, e);\n });\n gc.on('outofmaxbounds', e => {\n var _a, _b;\n (_b = (_a = thisRef.current.props).onOutOfMaxBounds) === null || _b === void 0 ? void 0 : _b.call(_a, e);\n });\n gc.on('trackuserlocationstart', e => {\n var _a, _b;\n (_b = (_a = thisRef.current.props).onTrackUserLocationStart) === null || _b === void 0 ? void 0 : _b.call(_a, e);\n });\n gc.on('trackuserlocationend', e => {\n var _a, _b;\n (_b = (_a = thisRef.current.props).onTrackUserLocationEnd) === null || _b === void 0 ? void 0 : _b.call(_a, e);\n });\n return gc;\n }, { position: props.position });\n thisRef.current.props = props;\n useImperativeHandle(ref, () => ctrl, []);\n useEffect(() => {\n applyReactStyle(ctrl._container, props.style);\n }, [props.style]);\n return null;\n}\nexport default memo(forwardRef(GeolocateControl));\n//# sourceMappingURL=geolocate-control.js.map"],"names":["GeolocateControl","props","ref","thisRef","useRef","ctrl","useControl","mapLib","gc","setupUI","args","e","_a","_b","useImperativeHandle","useEffect","applyReactStyle","memo","forwardRef"],"mappings":";;;AAGA,SAASA,EAAiBC,GAAOC,GAAK;AAClC,QAAMC,IAAUC,EAAO,EAAE,OAAAH,EAAO,CAAA,GAC1BI,IAAOC,EAAW,CAAC,EAAE,QAAAC,EAAM,MAAO;AACpC,UAAMC,IAAK,IAAID,EAAO,iBAAiBN,CAAK,GAKtCQ,IAAUD,EAAG;AAEnB,WAAAA,EAAG,WAAW,CAAAE,MAAQ;AAClB,MAAKF,EAAG,WAAW,mBACfC,EAAQC,CAAI;AAAA,IAE5B,GACQF,EAAG,GAAG,aAAa,CAAAG,MAAK;AACpB,UAAIC,GAAIC;AACR,OAACA,KAAMD,IAAKT,EAAQ,QAAQ,OAAO,iBAAiB,QAAQU,MAAO,UAAkBA,EAAG,KAAKD,GAAID,CAAC;AAAA,IAC9G,CAAS,GACDH,EAAG,GAAG,SAAS,CAAAG,MAAK;AAChB,UAAIC,GAAIC;AACR,OAACA,KAAMD,IAAKT,EAAQ,QAAQ,OAAO,aAAa,QAAQU,MAAO,UAAkBA,EAAG,KAAKD,GAAID,CAAC;AAAA,IAC1G,CAAS,GACDH,EAAG,GAAG,kBAAkB,CAAAG,MAAK;AACzB,UAAIC,GAAIC;AACR,OAACA,KAAMD,IAAKT,EAAQ,QAAQ,OAAO,sBAAsB,QAAQU,MAAO,UAAkBA,EAAG,KAAKD,GAAID,CAAC;AAAA,IACnH,CAAS,GACDH,EAAG,GAAG,0BAA0B,CAAAG,MAAK;AACjC,UAAIC,GAAIC;AACR,OAACA,KAAMD,IAAKT,EAAQ,QAAQ,OAAO,8BAA8B,QAAQU,MAAO,UAAkBA,EAAG,KAAKD,GAAID,CAAC;AAAA,IAC3H,CAAS,GACDH,EAAG,GAAG,wBAAwB,CAAAG,MAAK;AAC/B,UAAIC,GAAIC;AACR,OAACA,KAAMD,IAAKT,EAAQ,QAAQ,OAAO,4BAA4B,QAAQU,MAAO,UAAkBA,EAAG,KAAKD,GAAID,CAAC;AAAA,IACzH,CAAS,GACMH;AAAA,EACV,GAAE,EAAE,UAAUP,EAAM,SAAU,CAAA;AAC/B,SAAAE,EAAQ,QAAQ,QAAQF,GACxBa,EAAoBZ,GAAK,MAAMG,GAAM,CAAE,CAAA,GACvCU,EAAU,MAAM;AACZ,IAAAC,EAAgBX,EAAK,YAAYJ,EAAM,KAAK;AAAA,EACpD,GAAO,CAACA,EAAM,KAAK,CAAC,GACT;AACX;AACegB,EAAKC,EAAWlB,CAAgB,CAAC;","x_google_ignoreList":[0]}
@@ -0,0 +1,13 @@
1
+ import { memo as i, useEffect as e } from "react";
2
+ import { applyReactStyle as l } from "./main.js23.mjs";
3
+ import r from "./main.js25.mjs";
4
+ function m(t) {
5
+ const o = r(({ mapLib: n }) => new n.NavigationControl(t), {
6
+ position: t.position
7
+ });
8
+ return e(() => {
9
+ l(o._container, t.style);
10
+ }, [t.style]), null;
11
+ }
12
+ i(m);
13
+ //# sourceMappingURL=main.js14.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js14.mjs","sources":["../../node_modules/react-map-gl/dist/esm/components/navigation-control.js"],"sourcesContent":["import { useEffect, memo } from 'react';\nimport { applyReactStyle } from '../utils/apply-react-style';\nimport useControl from './use-control';\nfunction NavigationControl(props) {\n const ctrl = useControl(({ mapLib }) => new mapLib.NavigationControl(props), {\n position: props.position\n });\n useEffect(() => {\n applyReactStyle(ctrl._container, props.style);\n }, [props.style]);\n return null;\n}\nexport default memo(NavigationControl);\n//# sourceMappingURL=navigation-control.js.map"],"names":["NavigationControl","props","ctrl","useControl","mapLib","useEffect","applyReactStyle","memo"],"mappings":";;;AAGA,SAASA,EAAkBC,GAAO;AAC9B,QAAMC,IAAOC,EAAW,CAAC,EAAE,QAAAC,EAAQ,MAAK,IAAIA,EAAO,kBAAkBH,CAAK,GAAG;AAAA,IACzE,UAAUA,EAAM;AAAA,EACxB,CAAK;AACD,SAAAI,EAAU,MAAM;AACZ,IAAAC,EAAgBJ,EAAK,YAAYD,EAAM,KAAK;AAAA,EACpD,GAAO,CAACA,EAAM,KAAK,CAAC,GACT;AACX;AACeM,EAAKP,CAAiB;","x_google_ignoreList":[0]}
@@ -0,0 +1,15 @@
1
+ import { memo as c, useRef as m, useEffect as f } from "react";
2
+ import { applyReactStyle as l } from "./main.js23.mjs";
3
+ import a from "./main.js25.mjs";
4
+ function r(t) {
5
+ const n = a(({ mapLib: u }) => new u.ScaleControl(t), {
6
+ position: t.position
7
+ }), i = m(t), e = i.current;
8
+ i.current = t;
9
+ const { style: o } = t;
10
+ return t.maxWidth !== void 0 && t.maxWidth !== e.maxWidth && (n.options.maxWidth = t.maxWidth), t.unit !== void 0 && t.unit !== e.unit && n.setUnit(t.unit), f(() => {
11
+ l(n._container, o);
12
+ }, [o]), null;
13
+ }
14
+ c(r);
15
+ //# sourceMappingURL=main.js15.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js15.mjs","sources":["../../node_modules/react-map-gl/dist/esm/components/scale-control.js"],"sourcesContent":["import { useEffect, useRef, memo } from 'react';\nimport { applyReactStyle } from '../utils/apply-react-style';\nimport useControl from './use-control';\nfunction ScaleControl(props) {\n const ctrl = useControl(({ mapLib }) => new mapLib.ScaleControl(props), {\n position: props.position\n });\n const propsRef = useRef(props);\n const prevProps = propsRef.current;\n propsRef.current = props;\n const { style } = props;\n if (props.maxWidth !== undefined && props.maxWidth !== prevProps.maxWidth) {\n ctrl.options.maxWidth = props.maxWidth;\n }\n if (props.unit !== undefined && props.unit !== prevProps.unit) {\n ctrl.setUnit(props.unit);\n }\n useEffect(() => {\n applyReactStyle(ctrl._container, style);\n }, [style]);\n return null;\n}\nexport default memo(ScaleControl);\n//# sourceMappingURL=scale-control.js.map"],"names":["ScaleControl","props","ctrl","useControl","mapLib","propsRef","useRef","prevProps","style","useEffect","applyReactStyle","memo"],"mappings":";;;AAGA,SAASA,EAAaC,GAAO;AACzB,QAAMC,IAAOC,EAAW,CAAC,EAAE,QAAAC,EAAQ,MAAK,IAAIA,EAAO,aAAaH,CAAK,GAAG;AAAA,IACpE,UAAUA,EAAM;AAAA,EACxB,CAAK,GACKI,IAAWC,EAAOL,CAAK,GACvBM,IAAYF,EAAS;AAC3B,EAAAA,EAAS,UAAUJ;AACnB,QAAM,EAAE,OAAAO,EAAO,IAAGP;AAClB,SAAIA,EAAM,aAAa,UAAaA,EAAM,aAAaM,EAAU,aAC7DL,EAAK,QAAQ,WAAWD,EAAM,WAE9BA,EAAM,SAAS,UAAaA,EAAM,SAASM,EAAU,QACrDL,EAAK,QAAQD,EAAM,IAAI,GAE3BQ,EAAU,MAAM;AACZ,IAAAC,EAAgBR,EAAK,YAAYM,CAAK;AAAA,EAC9C,GAAO,CAACA,CAAK,CAAC,GACH;AACX;AACeG,EAAKX,CAAY;","x_google_ignoreList":[0]}
@@ -0,0 +1,14 @@
1
+ import * as e from "react";
2
+ import { useContext as n, useMemo as a } from "react";
3
+ import { MapContext as u } from "./main.js8.mjs";
4
+ const p = e.createContext(null);
5
+ function c() {
6
+ var o;
7
+ const r = (o = n(p)) === null || o === void 0 ? void 0 : o.maps, t = n(u);
8
+ return a(() => ({ ...r, current: t == null ? void 0 : t.map }), [r, t]);
9
+ }
10
+ export {
11
+ p as MountedMapsContext,
12
+ c as useMap
13
+ };
14
+ //# sourceMappingURL=main.js16.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js16.mjs","sources":["../../node_modules/react-map-gl/dist/esm/components/use-map.js"],"sourcesContent":["import * as React from 'react';\nimport { useState, useCallback, useMemo, useContext } from 'react';\nimport { MapContext } from './map';\nexport const MountedMapsContext = React.createContext(null);\nexport const MapProvider = props => {\n const [maps, setMaps] = useState({});\n const onMapMount = useCallback((map, id = 'default') => {\n setMaps(currMaps => {\n if (id === 'current') {\n throw new Error(\"'current' cannot be used as map id\");\n }\n if (currMaps[id]) {\n throw new Error(`Multiple maps with the same id: ${id}`);\n }\n return { ...currMaps, [id]: map };\n });\n }, []);\n const onMapUnmount = useCallback((id = 'default') => {\n setMaps(currMaps => {\n if (currMaps[id]) {\n const nextMaps = { ...currMaps };\n delete nextMaps[id];\n return nextMaps;\n }\n return currMaps;\n });\n }, []);\n return (React.createElement(MountedMapsContext.Provider, { value: {\n maps,\n onMapMount,\n onMapUnmount\n } }, props.children));\n};\nexport function useMap() {\n var _a;\n const maps = (_a = useContext(MountedMapsContext)) === null || _a === void 0 ? void 0 : _a.maps;\n const currentMap = useContext(MapContext);\n const mapsWithCurrent = useMemo(() => {\n return { ...maps, current: currentMap === null || currentMap === void 0 ? void 0 : currentMap.map };\n }, [maps, currentMap]);\n return mapsWithCurrent;\n}\n//# sourceMappingURL=use-map.js.map"],"names":["MountedMapsContext","React","useMap","_a","maps","useContext","currentMap","MapContext","useMemo"],"mappings":";;;AAGY,MAACA,IAAqBC,EAAM,cAAc,IAAI;AA8BnD,SAASC,IAAS;AACrB,MAAIC;AACJ,QAAMC,KAAQD,IAAKE,EAAWL,CAAkB,OAAO,QAAQG,MAAO,SAAS,SAASA,EAAG,MACrFG,IAAaD,EAAWE,CAAU;AAIxC,SAHwBC,EAAQ,OACrB,EAAE,GAAGJ,GAAM,SAASE,KAAe,OAAgC,SAASA,EAAW,IAAG,IAClG,CAACF,GAAME,CAAU,CAAC;AAEzB;","x_google_ignoreList":[0]}
@@ -0,0 +1,56 @@
1
+ import { createEvents as p } from "@react-three/fiber";
2
+ const c = {
3
+ onClick: ["click", !1],
4
+ onContextMenu: ["contextmenu", !1],
5
+ onDoubleClick: ["dblclick", !1],
6
+ onWheel: ["wheel", !0],
7
+ onPointerDown: ["pointerdown", !0],
8
+ onPointerUp: ["pointerup", !0],
9
+ onPointerLeave: ["pointerleave", !0],
10
+ onPointerMove: ["pointermove", !0],
11
+ onPointerCancel: ["pointercancel", !0],
12
+ onLostPointerCapture: ["lostpointercapture", !0]
13
+ };
14
+ function u() {
15
+ return (o) => {
16
+ const { handlePointer: a } = p(o);
17
+ return {
18
+ priority: 1,
19
+ enabled: !0,
20
+ compute(n, e) {
21
+ e.size.width = e.gl.domElement.width, e.size.height = e.gl.domElement.height, e.pointer.x = n.offsetX / (e.size.width / window.devicePixelRatio) * 2 - 1, e.pointer.y = 1 - n.offsetY / (e.size.height / window.devicePixelRatio) * 2, e.raycaster.camera = e.camera, e.raycaster.ray.origin.setScalar(0).applyMatrix4(e.camera.projectionMatrixInverse), e.raycaster.ray.direction.set(e.pointer.x, e.pointer.y, 1).applyMatrix4(e.camera.projectionMatrixInverse).sub(e.raycaster.ray.origin).normalize();
22
+ },
23
+ connected: void 0,
24
+ handlers: Object.keys(c).reduce(
25
+ (n, e) => ({ ...n, [e]: a(e) }),
26
+ {}
27
+ ),
28
+ update: () => {
29
+ var t;
30
+ const { events: n, internal: e } = o.getState();
31
+ (t = e.lastEvent) != null && t.current && n.handlers && n.handlers.onPointerMove(e.lastEvent.current);
32
+ },
33
+ connect: (n) => {
34
+ var i;
35
+ const { set: e, events: t } = o.getState();
36
+ (i = t.disconnect) == null || i.call(t), e((r) => ({ events: { ...r.events, connected: n } })), Object.entries(t.handlers ?? []).forEach(([r, l]) => {
37
+ const [s, d] = c[r];
38
+ n.addEventListener(s, l, { passive: d });
39
+ });
40
+ },
41
+ disconnect: () => {
42
+ const { set: n, events: e } = o.getState();
43
+ e.connected && (Object.entries(e.handlers ?? []).forEach(([t, i]) => {
44
+ if (e && e.connected instanceof HTMLElement) {
45
+ const [r] = c[t];
46
+ e.connected.removeEventListener(r, i);
47
+ }
48
+ }), n((t) => ({ events: { ...t.events, connected: void 0 } })));
49
+ }
50
+ };
51
+ };
52
+ }
53
+ export {
54
+ u as createEvents
55
+ };
56
+ //# sourceMappingURL=main.js17.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js17.mjs","sources":["../../src/canvas/create-events.ts"],"sourcesContent":["import { Events, RenderProps, RootState, createEvents as createFiberEvents } from \"@react-three/fiber\";\nimport { UseBoundStore } from \"zustand\";\n\ntype DomEvent = PointerEvent | MouseEvent | WheelEvent;\n\nconst DOM_EVENTS = {\n onClick: [\"click\", false],\n onContextMenu: [\"contextmenu\", false],\n onDoubleClick: [\"dblclick\", false],\n onWheel: [\"wheel\", true],\n onPointerDown: [\"pointerdown\", true],\n onPointerUp: [\"pointerup\", true],\n onPointerLeave: [\"pointerleave\", true],\n onPointerMove: [\"pointermove\", true],\n onPointerCancel: [\"pointercancel\", true],\n onLostPointerCapture: [\"lostpointercapture\", true],\n} as const;\n\n/** ThreeLayer event manager for MapLibre and Mapbox */\nexport function createEvents() : RenderProps<HTMLCanvasElement>[\"events\"] {\n return (store: UseBoundStore<RootState>) => {\n const { handlePointer } = createFiberEvents(store);\n return {\n priority: 1,\n enabled: true,\n compute(event: DomEvent, state: RootState) {\n state.size.width = state.gl.domElement.width;\n state.size.height = state.gl.domElement.height;\n state.pointer.x = (event.offsetX / (state.size.width / window.devicePixelRatio)) * 2 - 1;\n state.pointer.y = 1 - (event.offsetY / (state.size.height / window.devicePixelRatio)) * 2;\n state.raycaster.camera = state.camera;\n state.raycaster.ray.origin.setScalar(0).applyMatrix4(state.camera.projectionMatrixInverse);\n state.raycaster.ray.direction\n .set(state.pointer.x, state.pointer.y, 1)\n .applyMatrix4(state.camera.projectionMatrixInverse)\n .sub(state.raycaster.ray.origin)\n .normalize();\n },\n connected: undefined,\n handlers: Object.keys(DOM_EVENTS).reduce(\n (acc, key) => ({ ...acc, [key]: handlePointer(key) }),\n {}\n ) as unknown as Events,\n update: () => {\n const { events, internal } = store.getState();\n if (internal.lastEvent?.current && events.handlers) {\n events.handlers.onPointerMove(internal.lastEvent.current);\n }\n },\n connect: (target: HTMLElement) => {\n const { set, events } = store.getState();\n events.disconnect?.();\n set((state) => ({ events: { ...state.events, connected: target } }));\n Object.entries(events.handlers ?? []).forEach(([name, event]) => {\n const [eventName, passive] = DOM_EVENTS[name as keyof typeof DOM_EVENTS];\n target.addEventListener(eventName, event, { passive });\n });\n },\n disconnect: () => {\n const { set, events } = store.getState();\n if (events.connected) {\n Object.entries(events.handlers ?? []).forEach(([name, event]) => {\n if (events && events.connected instanceof HTMLElement) {\n const [eventName] = DOM_EVENTS[name as keyof typeof DOM_EVENTS];\n events.connected.removeEventListener(eventName, event);\n }\n });\n set((state) => ({ events: { ...state.events, connected: undefined } }));\n }\n },\n };\n };\n}\n"],"names":["DOM_EVENTS","createEvents","store","handlePointer","createFiberEvents","event","state","acc","key","events","internal","_a","target","set","name","eventName","passive"],"mappings":";AAKA,MAAMA,IAAa;AAAA,EACjB,SAAS,CAAC,SAAS,EAAK;AAAA,EACxB,eAAe,CAAC,eAAe,EAAK;AAAA,EACpC,eAAe,CAAC,YAAY,EAAK;AAAA,EACjC,SAAS,CAAC,SAAS,EAAI;AAAA,EACvB,eAAe,CAAC,eAAe,EAAI;AAAA,EACnC,aAAa,CAAC,aAAa,EAAI;AAAA,EAC/B,gBAAgB,CAAC,gBAAgB,EAAI;AAAA,EACrC,eAAe,CAAC,eAAe,EAAI;AAAA,EACnC,iBAAiB,CAAC,iBAAiB,EAAI;AAAA,EACvC,sBAAsB,CAAC,sBAAsB,EAAI;AACnD;AAGO,SAASC,IAA0D;AACxE,SAAO,CAACC,MAAoC;AAC1C,UAAM,EAAE,eAAAC,EAAA,IAAkBC,EAAkBF,CAAK;AAC1C,WAAA;AAAA,MACL,UAAU;AAAA,MACV,SAAS;AAAA,MACT,QAAQG,GAAiBC,GAAkB;AACzC,QAAAA,EAAM,KAAK,QAAQA,EAAM,GAAG,WAAW,OACvCA,EAAM,KAAK,SAASA,EAAM,GAAG,WAAW,QAClCA,EAAA,QAAQ,IAAKD,EAAM,WAAWC,EAAM,KAAK,QAAQ,OAAO,oBAAqB,IAAI,GACjFA,EAAA,QAAQ,IAAI,IAAKD,EAAM,WAAWC,EAAM,KAAK,SAAS,OAAO,oBAAqB,GAClFA,EAAA,UAAU,SAASA,EAAM,QACzBA,EAAA,UAAU,IAAI,OAAO,UAAU,CAAC,EAAE,aAAaA,EAAM,OAAO,uBAAuB,GACnFA,EAAA,UAAU,IAAI,UACjB,IAAIA,EAAM,QAAQ,GAAGA,EAAM,QAAQ,GAAG,CAAC,EACvC,aAAaA,EAAM,OAAO,uBAAuB,EACjD,IAAIA,EAAM,UAAU,IAAI,MAAM,EAC9B,UAAU;AAAA,MACf;AAAA,MACA,WAAW;AAAA,MACX,UAAU,OAAO,KAAKN,CAAU,EAAE;AAAA,QAChC,CAACO,GAAKC,OAAS,EAAE,GAAGD,GAAK,CAACC,CAAG,GAAGL,EAAcK,CAAG;QACjD,CAAC;AAAA,MACH;AAAA,MACA,QAAQ,MAAM;;AACZ,cAAM,EAAE,QAAAC,GAAQ,UAAAC,EAAS,IAAIR,EAAM,SAAS;AAC5C,SAAIS,IAAAD,EAAS,cAAT,QAAAC,EAAoB,WAAWF,EAAO,YACxCA,EAAO,SAAS,cAAcC,EAAS,UAAU,OAAO;AAAA,MAE5D;AAAA,MACA,SAAS,CAACE,MAAwB;;AAChC,cAAM,EAAE,KAAAC,GAAK,QAAAJ,EAAO,IAAIP,EAAM,SAAS;AACvC,SAAAS,IAAAF,EAAO,eAAP,QAAAE,EAAA,KAAAF,IACII,EAAA,CAACP,OAAW,EAAE,QAAQ,EAAE,GAAGA,EAAM,QAAQ,WAAWM,EAAO,EAAA,EAAI,GAC5D,OAAA,QAAQH,EAAO,YAAY,CAAA,CAAE,EAAE,QAAQ,CAAC,CAACK,GAAMT,CAAK,MAAM;AAC/D,gBAAM,CAACU,GAAWC,CAAO,IAAIhB,EAAWc,CAA+B;AACvE,UAAAF,EAAO,iBAAiBG,GAAWV,GAAO,EAAE,SAAAW,EAAS,CAAA;AAAA,QAAA,CACtD;AAAA,MACH;AAAA,MACA,YAAY,MAAM;AAChB,cAAM,EAAE,KAAAH,GAAK,QAAAJ,EAAO,IAAIP,EAAM,SAAS;AACvC,QAAIO,EAAO,cACF,OAAA,QAAQA,EAAO,YAAY,CAAA,CAAE,EAAE,QAAQ,CAAC,CAACK,GAAMT,CAAK,MAAM;AAC3D,cAAAI,KAAUA,EAAO,qBAAqB,aAAa;AACrD,kBAAM,CAACM,CAAS,IAAIf,EAAWc,CAA+B;AACvD,YAAAL,EAAA,UAAU,oBAAoBM,GAAWV,CAAK;AAAA;AAAA,QACvD,CACD,GACGQ,EAAA,CAACP,OAAW,EAAE,QAAQ,EAAE,GAAGA,EAAM,QAAQ,WAAW,OAAU,EAAA,EAAI;AAAA,MAE1E;AAAA,IAAA;AAAA,EACF;AAEJ;"}
@@ -0,0 +1,9 @@
1
+ import { useRef as n, useCallback as u } from "react";
2
+ const o = (r) => {
3
+ const e = n(r);
4
+ return e.current = r, u((...t) => e.current(...t), []);
5
+ };
6
+ export {
7
+ o as useFunction
8
+ };
9
+ //# sourceMappingURL=main.js18.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js18.mjs","sources":["../../src/canvas/use-function.ts"],"sourcesContent":["import { useCallback, useRef } from 'react';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const useFunction = <T extends (...args: any[]) => any>(callback: T): T => {\n const callbackRef = useRef(callback);\n callbackRef.current = callback;\n return useCallback((...args: any[]) => {\n return callbackRef.current(...args);\n }, []) as T;\n};\n"],"names":["useFunction","callback","callbackRef","useRef","useCallback","args"],"mappings":";AAGa,MAAAA,IAAc,CAAoCC,MAAmB;AAC1E,QAAAC,IAAcC,EAAOF,CAAQ;AACnC,SAAAC,EAAY,UAAUD,GACfG,EAAY,IAAIC,MACdH,EAAY,QAAQ,GAAGG,CAAI,GACjC,CAAE,CAAA;AACP;"}