@mappedin/react-sdk 6.5.0 → 6.7.0

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.
@@ -5886,6 +5886,37 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5886
5886
 
5887
5887
  -----------
5888
5888
 
5889
+ The following npm package may be included in this product:
5890
+
5891
+ - simplify-js@1.2.4
5892
+
5893
+ This package contains the following license:
5894
+
5895
+ Copyright (c) 2017, Vladimir Agafonkin
5896
+ All rights reserved.
5897
+
5898
+ Redistribution and use in source and binary forms, with or without modification, are
5899
+ permitted provided that the following conditions are met:
5900
+
5901
+ 1. Redistributions of source code must retain the above copyright notice, this list of
5902
+ conditions and the following disclaimer.
5903
+
5904
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list
5905
+ of conditions and the following disclaimer in the documentation and/or other materials
5906
+ provided with the distribution.
5907
+
5908
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
5909
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
5910
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
5911
+ COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
5912
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5913
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5914
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
5915
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
5916
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5917
+
5918
+ -----------
5919
+
5889
5920
  The following npm package may be included in this product:
5890
5921
 
5891
5922
  - @mapbox/geojson-rewind@0.5.2
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- var le=Object.create;var k=Object.defineProperty,Me=Object.defineProperties,xe=Object.getOwnPropertyDescriptor,ye=Object.getOwnPropertyDescriptors,we=Object.getOwnPropertyNames,L=Object.getOwnPropertySymbols,he=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var z=(e,r,t)=>r in e?k(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,y=(e,r)=>{for(var t in r||(r={}))A.call(r,t)&&z(e,t,r[t]);if(L)for(var t of L(r))H.call(r,t)&&z(e,t,r[t]);return e},C=(e,r)=>Me(e,ye(r)),p=(e,r)=>k(e,"name",{value:r,configurable:!0});var U=(e,r)=>{var t={};for(var a in e)A.call(e,a)&&r.indexOf(a)<0&&(t[a]=e[a]);if(e!=null&&L)for(var a of L(e))r.indexOf(a)<0&&H.call(e,a)&&(t[a]=e[a]);return t};var Ee=(e,r)=>()=>(e&&(r=e(e=0)),r);var Pe=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var ge=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of we(r))!A.call(e,o)&&o!==t&&k(e,o,{get:()=>r[o],enumerable:!(a=xe(r,o))||a.enumerable});return e};var q=(e,r,t)=>(t=e!=null?le(he(e)):{},ge(r||!e||!e.__esModule?k(t,"default",{value:e,enumerable:!0}):t,e));var u,n=Ee(()=>{u={env:{NODE_ENV:"production",npm_package_version:"6.5.0"}}});var I=Pe((Ht,K)=>{"use strict";n();K.exports=p(function e(r,t){if(r===t)return!0;if(r&&t&&typeof r=="object"&&typeof t=="object"){if(r.constructor!==t.constructor)return!1;var a,o,s;if(Array.isArray(r)){if(a=r.length,a!=t.length)return!1;for(o=a;o--!==0;)if(!e(r[o],t[o]))return!1;return!0}if(r.constructor===RegExp)return r.source===t.source&&r.flags===t.flags;if(r.valueOf!==Object.prototype.valueOf)return r.valueOf()===t.valueOf();if(r.toString!==Object.prototype.toString)return r.toString()===t.toString();if(s=Object.keys(r),a=s.length,a!==Object.keys(t).length)return!1;for(o=a;o--!==0;)if(!Object.prototype.hasOwnProperty.call(t,s[o]))return!1;for(o=a;o--!==0;){var i=s[o];if(!e(r[i],t[i]))return!1}return!0}return r!==r&&t!==t},"equal")});n();n();import Se,{createContext as Ve,useCallback as F,useMemo as Te,useRef as ve}from"react";var S=Ve({getCache:p(()=>{},"getCache"),setCache:p(()=>{},"setCache")});function j({mapData:e,children:r}){let t=ve(e?{mapData:e,options:{}}:void 0),a=F(()=>t.current,[]),o=F(i=>{t.current=i},[]),s=Te(()=>({getCache:a,setCache:o}),[a,o]);return Se.createElement(S.Provider,{value:s},r)}p(j,"MapDataProvider");n();var X=q(I());import{useCallback as Ne,useContext as Le,useEffect as Q,useRef as ke,useState as J}from"react";import{getMapData as be}from"@mappedin/mappedin-js";n();var Re="[MappedinJS]";function Ce(e="",{prefix:r=Re}={}){let t="".concat(r).concat(e?"-".concat(e):""),a=p((o,s)=>{if(typeof window<"u"&&window.rnDebug){let i=s.map(M=>M instanceof Error&&M.stack?"".concat(M.message,"\n").concat(M.stack):M);window.rnDebug("".concat(e," ").concat(o,": ").concat(i.join(" ")))}},"rnDebug");return{logState:u.env.NODE_ENV==="test"?3:0,log(...o){this.logState<=0&&(console.log(t,...o),a("log",o))},warn(...o){this.logState<=1&&(console.warn(t,...o),a("warn",o))},error(...o){this.logState<=2&&(console.error(t,...o),a("error",o))},assert(...o){console.assert(...o)},time(o){console.time(o)},timeEnd(o){console.timeEnd(o)},setLevel(o){0<=o&&o<=3&&(this.logState=o)}}}p(Ce,"createLogger");var Oe=Ce();var T=Oe;n();var Y=q(I());import{useRef as B}from"react";function l(e,r){let t=B(void 0),a=B(void 0);return(0,Y.default)(r,a.current)||(t.current=e(),a.current=r),t.current}p(l,"useMemoDeep");function Ae(e){let{getCache:r,setCache:t}=Le(S),[a,o]=J(void 0),[s,i]=J(!0),[M,m]=J(void 0),g=ke(0),d=l(()=>e&&C(y({},e),{analytics:y({context:"reactsdk"},e==null?void 0:e.analytics)}),[e]),V=Ne(w=>{let D=++g.current;i(!0),m(void 0),be(w).then(h=>{g.current===D&&o(h)}).catch(h=>{g.current===D&&(T.error("Failed to fetch MapData",h),m(h))}).finally(()=>{g.current===D&&i(!1)})},[]);return Q(()=>{let w=r==null?void 0:r();if(w!=null&&(d==null||w.mapData.mapId===d.mapId&&(0,X.default)(w.options,d))){o(w.mapData),i(!1),m(void 0);return}if(!d){m(new Error("useMapData requires options if not use within a MapDataProvider or MapView component."));return}V(d)},[V,r,d]),Q(()=>{let w=r==null?void 0:r();a!=null&&(w==null||w.mapData.mapId===a.mapId)&&(t==null||t({mapData:a,options:d||{}}))},[a,d,r,t]),{mapData:a,isLoading:s,error:M}}p(Ae,"useMapData");n();import{useCallback as je,useContext as Ie,useEffect as Je}from"react";function We(e,r){let{getCache:t}=Ie(S),a=je(o=>r(o),[r]);Je(()=>{var s;let o=(s=t==null?void 0:t())==null?void 0:s.mapData;if(o==null)throw new Error("useMapDataEvent must be used within a MapDataProvider or MapView component.");return o.on(e,a),()=>{o!=null&&o.off(e,a)}},[t,e,a])}p(We,"useMapDataEvent");n();import O,{useCallback as Z,useEffect as _e,useMemo as ee,useRef as te,useState as re,forwardRef as Ge,useImperativeHandle as $e,createContext as ze}from"react";import{show3dMap as He}from"@mappedin/mappedin-js";var f=ze({mapView:void 0,extensions:{}}),Ue={width:"100%",height:"100%",position:"relative"},qe=Ge((e,r)=>{let $=e,{mapData:t,options:a,style:o,fallback:s,children:i}=$,M=U($,["mapData","options","style","fallback","children"]),m=te({extensions:{}}).current,[g,d]=re(!0),[V,w]=re(!1),D=te(null),h=ee(()=>t,[t]),G=l(()=>a,[a]);$e(r,()=>m.mapView);let ce=ee(()=>({mapView:m.mapView,extensions:m.extensions}),[h,m.mapView,m.extensions]),de=Z(E=>{try{let x=Object.keys(E);for(let v of x){let R=E[v];R&&(R.onDeregister(R.instance),delete E[v])}}catch(x){T.error("Failed to clean up extensions",x)}return{}},[]),N=Z(E=>{var v;let x=E||m.mapView;try{(v=x==null?void 0:x.destroy)==null||v.call(x)}catch(R){T.error("Failed to destroy MapView",R)}E||(m.extensions=de(m.extensions),m.mapView=void 0,w(!1))},[]);return _e(()=>{if(!h||!D.current)return;N();let E=!1;return d(!0),He(D.current,h,G).then(x=>{E?N(x):(m.mapView=x,w(!0))}).catch(x=>{T.error("Failed to render MapView",x)}).finally(()=>{E||d(!1)}),()=>{E=!0,m.mapView&&N()}},[h,G,N]),O.createElement(j,{mapData:h},O.createElement(f.Provider,{value:ce},O.createElement("div",y({"data-testid":"mappedin-map",ref:D,style:y(y({},Ue),o)},M)),g?O.createElement(O.Fragment,null,s):V?i:null))});n();import{useCallback as Fe,useContext as Ke,useEffect as Be}from"react";n();var W=class W extends Error{constructor(r){super("".concat(r," must be used within a MapView component."))}};p(W,"MapViewNullError");var c=W;function Ye(e,r){let{mapView:t}=Ke(f),a=Fe(o=>r(o),[r]);Be(()=>{if(t==null)throw new c("useMapViewEvent");return t.on(e,a),()=>{t!=null&&t.off(e,a)}},[t,e,r])}p(Ye,"useMapViewEvent");n();import{useCallback as ae,useContext as Qe}from"react";function Xe(e,r){let{extensions:t}=Qe(f);if(!(r!=null&&r.onRegister)||!(r!=null&&r.onDeregister))throw new Error("onRegister and onDeregister are required");let a=ae(()=>{let s=t[e],i=s==null?void 0:s.instance;return i||(i=r.onRegister(),t[e]={instance:i,onDeregister:r.onDeregister}),i},[t,e,r.onRegister]),o=ae(()=>{let s=t[e];s&&(s.onDeregister(s.instance),delete t[e])},[t,e,r.onDeregister]);return{register:a,deregister:o}}p(Xe,"useMapViewExtension");n();import{useContext as tt,useEffect as rt,useRef as at,forwardRef as ot,useImperativeHandle as nt,useState as it}from"react";n();import{useEffect as Ze,useRef as et}from"react";function P(e,r){let t=et(!0);Ze(()=>{if(t.current){t.current=!1;return}return e()},r)}p(P,"useUpdateEffect");var st=ot((e,r)=>{let{mapView:t}=tt(f),a=at(void 0),o=l(()=>e.options,[e.options]),[s,i]=it(!1);return nt(r,()=>a.current,[s]),rt(()=>{if(t==null)throw new c("Path");let M=t.Paths.add(e.coordinate,o);return M.animation.then(()=>{var m;(m=e.onDrawComplete)==null||m.call(e)}),a.current=M,i(!0),()=>{a.current&&t.Paths.remove(a.current),i(!1)}},[t,e.coordinate]),P(()=>{a.current&&o&&(t==null||t.updateState(a.current,o))},[o]),null});n();import{useContext as pt,useEffect as mt}from"react";function ut(e){let{mapView:r}=pt(f),t=l(()=>e.options,[e.options]);return mt(()=>{if(r==null)throw new c("Navigation");return r.Navigation.draw(e.directions,t).then(()=>{var a;(a=e.onDrawComplete)==null||a.call(e)}),()=>{r.Navigation.clear()}},[r,e.directions,t]),null}p(ut,"Navigation");n();import{useContext as ft,useEffect as ct,useRef as dt,forwardRef as lt,useImperativeHandle as Mt,useState as xt}from"react";var yt=lt((e,r)=>{let{mapView:t}=ft(f),a=dt(void 0),o=l(()=>e.style,[e.style]),[s,i]=xt(!1);return Mt(r,()=>a.current,[s]),ct(()=>{if(t==null)throw new Error("MapView not initialized");return a.current=t.Shapes.add(e.geometry,e.style,e.floor),i(!0),()=>{t==null||a.current==null||(t.Shapes.remove(a.current),i(!1))}},[t,e.geometry,e.style,e.floor]),P(()=>{a.current&&o&&(t==null||t.updateState(a.current,o))},[o]),null});n();import{useContext as wt,useEffect as ht,useRef as Et,forwardRef as Pt,useImperativeHandle as gt,useState as Dt}from"react";var St=Pt((e,r)=>{let{mapView:t}=wt(f),a=Et(void 0),o=l(()=>e.options,[e.options]),[s,i]=Dt(!1);return gt(r,()=>a.current,[s]),ht(()=>{if(t==null)throw new c("Model");return a.current=t.Models.add(e.coordinate,e.url,o),i(!0),()=>{t==null||a.current==null||(t.Models.remove(a.current),i(!1))}},[t,e.url]),P(()=>{a.current&&(t==null||t.updateState(a.current,y({position:e.coordinate},o)))},[e.coordinate,o]),null});n();import{useContext as oe}from"react";function Vt(){var t;let{mapView:e}=oe(f),{getCache:r}=oe(S);if(!e)throw new c("useMap");return{mapData:((t=r==null?void 0:r())==null?void 0:t.mapData)||e.getMapData(),mapView:e}}p(Vt,"useMap");n();import Tt,{useCallback as vt,useContext as ie,useEffect as se,useMemo as Rt,useRef as b,forwardRef as pe,useImperativeHandle as me,useState as ue}from"react";import{createPortal as Ct}from"react-dom";n();var _=[0,4,6,8,10],ne=p(()=>{let e=new Array(16).fill(0),r=Math.random()*4294967296;for(let a=0;a<e.length;a++)a>0&&(a&3)===0&&(r=Math.random()*4294967296),e[a]=r>>>((a&3)<<3)&255;let t=e.map(a=>a.toString(16).padStart(2,"0"));return t[6]="4"+t[6][1],t[8]=["8","9","a","b"].includes(t[7][0])?t[7]:"a"+t[7][1],_.map((a,o)=>t.slice(a,o===_.length-1?void 0:_[o+1]).join("")).join("-")},"randomId");var fe=pe((e,r)=>{let{mapView:t}=ie(f),a=b(void 0),[o,s]=ue(!1),i=l(()=>e.options,[e.options]);return me(r,()=>a.current,[o]),se(()=>{if(t==null)throw new c("Marker");return a.current=t.Markers.add(e.target,"",i),s(!0),()=>{t==null||a.current==null||(t.Markers.remove(a.current),s(!1))}},[t,e.target]),P(()=>{a.current&&i&&(t==null||t.updateState(a.current,i))},[i]),t==null||a.current==null?null:Ct(e.children,a.current.contentEl,a.current.id)}),Ot=pe((e,r)=>{let{mapView:t}=ie(f),a=b(ne()),o=b(void 0),[s,i]=ue(!1),M=b(e.target);me(r,()=>o.current,[s]);let m=vt(d=>{o.current=d||void 0,i(!!d)},[]);se(()=>{if(t==null)throw new c("Marker");if(o.current&&o.current.target!==e.target){let{duration:d=300,easing:V="linear"}=e;t.Markers.animateTo(o.current,e.target,{duration:d,easing:V})}return()=>{i(!1)}},[t,e.target]);let g=Rt(()=>C(y({},e),{duration:void 0,easing:void 0}),[e.duration,e.easing]);return Tt.createElement(fe,C(y({},g),{key:a.current,target:M.current,ref:m}))});n();import{forwardRef as Nt,useContext as Lt,useEffect as kt,useImperativeHandle as bt,useRef as At,useState as jt}from"react";var It=Nt((e,r)=>{let{mapView:t}=Lt(f),a=At(void 0),[o,s]=jt(!1),i=l(()=>e.options,[e.options]);return bt(r,()=>a.current,[o]),kt(()=>{if(t==null)throw new c("Label");return a.current=t.Labels.add(e.target,e.text,i),s(!0),()=>{t==null||a.current==null||(t.Labels.remove(a.current),s(!1))}},[t,e.target]),P(()=>{a.current&&(t==null||t.updateState(a.current,y({text:e.text},i)))},[e.text,i]),null});export{Ot as AnimatedMarker,It as Label,j as MapDataProvider,qe as MapView,fe as Marker,St as Model,ut as Navigation,st as Path,yt as Shape,Vt as useMap,Ae as useMapData,We as useMapDataEvent,Ye as useMapViewEvent,Xe as useMapViewExtension};
1
+ var le=Object.create;var k=Object.defineProperty,Me=Object.defineProperties,xe=Object.getOwnPropertyDescriptor,ye=Object.getOwnPropertyDescriptors,we=Object.getOwnPropertyNames,L=Object.getOwnPropertySymbols,he=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var z=(e,r,t)=>r in e?k(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,y=(e,r)=>{for(var t in r||(r={}))A.call(r,t)&&z(e,t,r[t]);if(L)for(var t of L(r))H.call(r,t)&&z(e,t,r[t]);return e},C=(e,r)=>Me(e,ye(r)),p=(e,r)=>k(e,"name",{value:r,configurable:!0});var U=(e,r)=>{var t={};for(var a in e)A.call(e,a)&&r.indexOf(a)<0&&(t[a]=e[a]);if(e!=null&&L)for(var a of L(e))r.indexOf(a)<0&&H.call(e,a)&&(t[a]=e[a]);return t};var Ee=(e,r)=>()=>(e&&(r=e(e=0)),r);var Pe=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var ge=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of we(r))!A.call(e,o)&&o!==t&&k(e,o,{get:()=>r[o],enumerable:!(a=xe(r,o))||a.enumerable});return e};var q=(e,r,t)=>(t=e!=null?le(he(e)):{},ge(r||!e||!e.__esModule?k(t,"default",{value:e,enumerable:!0}):t,e));var u,n=Ee(()=>{u={env:{NODE_ENV:"production",npm_package_version:"6.7.0"}}});var I=Pe((Ht,K)=>{"use strict";n();K.exports=p(function e(r,t){if(r===t)return!0;if(r&&t&&typeof r=="object"&&typeof t=="object"){if(r.constructor!==t.constructor)return!1;var a,o,s;if(Array.isArray(r)){if(a=r.length,a!=t.length)return!1;for(o=a;o--!==0;)if(!e(r[o],t[o]))return!1;return!0}if(r.constructor===RegExp)return r.source===t.source&&r.flags===t.flags;if(r.valueOf!==Object.prototype.valueOf)return r.valueOf()===t.valueOf();if(r.toString!==Object.prototype.toString)return r.toString()===t.toString();if(s=Object.keys(r),a=s.length,a!==Object.keys(t).length)return!1;for(o=a;o--!==0;)if(!Object.prototype.hasOwnProperty.call(t,s[o]))return!1;for(o=a;o--!==0;){var i=s[o];if(!e(r[i],t[i]))return!1}return!0}return r!==r&&t!==t},"equal")});n();n();import Se,{createContext as Ve,useCallback as F,useMemo as Te,useRef as ve}from"react";var S=Ve({getCache:p(()=>{},"getCache"),setCache:p(()=>{},"setCache")});function j({mapData:e,children:r}){let t=ve(e?{mapData:e,options:{}}:void 0),a=F(()=>t.current,[]),o=F(i=>{t.current=i},[]),s=Te(()=>({getCache:a,setCache:o}),[a,o]);return Se.createElement(S.Provider,{value:s},r)}p(j,"MapDataProvider");n();var X=q(I());import{useCallback as Ne,useContext as Le,useEffect as Q,useRef as ke,useState as J}from"react";import{getMapData as be}from"@mappedin/mappedin-js";n();var Re="[MappedinJS]";function Ce(e="",{prefix:r=Re}={}){let t="".concat(r).concat(e?"-".concat(e):""),a=p((o,s)=>{if(typeof window<"u"&&window.rnDebug){let i=s.map(M=>M instanceof Error&&M.stack?"".concat(M.message,"\n").concat(M.stack):M);window.rnDebug("".concat(e," ").concat(o,": ").concat(i.join(" ")))}},"rnDebug");return{logState:u.env.NODE_ENV==="test"?3:0,log(...o){this.logState<=0&&(console.log(t,...o),a("log",o))},warn(...o){this.logState<=1&&(console.warn(t,...o),a("warn",o))},error(...o){this.logState<=2&&(console.error(t,...o),a("error",o))},assert(...o){console.assert(...o)},time(o){console.time(o)},timeEnd(o){console.timeEnd(o)},setLevel(o){0<=o&&o<=3&&(this.logState=o)}}}p(Ce,"createLogger");var Oe=Ce();var T=Oe;n();var Y=q(I());import{useRef as B}from"react";function l(e,r){let t=B(void 0),a=B(void 0);return(0,Y.default)(r,a.current)||(t.current=e(),a.current=r),t.current}p(l,"useMemoDeep");function Ae(e){let{getCache:r,setCache:t}=Le(S),[a,o]=J(void 0),[s,i]=J(!0),[M,m]=J(void 0),g=ke(0),d=l(()=>e&&C(y({},e),{analytics:y({context:"reactsdk"},e==null?void 0:e.analytics)}),[e]),V=Ne(w=>{let D=++g.current;i(!0),m(void 0),be(w).then(h=>{g.current===D&&o(h)}).catch(h=>{g.current===D&&(T.error("Failed to fetch MapData",h),m(h))}).finally(()=>{g.current===D&&i(!1)})},[]);return Q(()=>{let w=r==null?void 0:r();if(w!=null&&(d==null||w.mapData.mapId===d.mapId&&(0,X.default)(w.options,d))){o(w.mapData),i(!1),m(void 0);return}if(!d){m(new Error("useMapData requires options if not use within a MapDataProvider or MapView component."));return}V(d)},[V,r,d]),Q(()=>{let w=r==null?void 0:r();a!=null&&(w==null||w.mapData.mapId===a.mapId)&&(t==null||t({mapData:a,options:d||{}}))},[a,d,r,t]),{mapData:a,isLoading:s,error:M}}p(Ae,"useMapData");n();import{useCallback as je,useContext as Ie,useEffect as Je}from"react";function We(e,r){let{getCache:t}=Ie(S),a=je(o=>r(o),[r]);Je(()=>{var s;let o=(s=t==null?void 0:t())==null?void 0:s.mapData;if(o==null)throw new Error("useMapDataEvent must be used within a MapDataProvider or MapView component.");return o.on(e,a),()=>{o!=null&&o.off(e,a)}},[t,e,a])}p(We,"useMapDataEvent");n();import O,{useCallback as Z,useEffect as _e,useMemo as ee,useRef as te,useState as re,forwardRef as Ge,useImperativeHandle as $e,createContext as ze}from"react";import{show3dMap as He}from"@mappedin/mappedin-js";var f=ze({mapView:void 0,extensions:{}}),Ue={width:"100%",height:"100%",position:"relative"},qe=Ge((e,r)=>{let $=e,{mapData:t,options:a,style:o,fallback:s,children:i}=$,M=U($,["mapData","options","style","fallback","children"]),m=te({extensions:{}}).current,[g,d]=re(!0),[V,w]=re(!1),D=te(null),h=ee(()=>t,[t]),G=l(()=>a,[a]);$e(r,()=>m.mapView);let ce=ee(()=>({mapView:m.mapView,extensions:m.extensions}),[h,m.mapView,m.extensions]),de=Z(E=>{try{let x=Object.keys(E);for(let v of x){let R=E[v];R&&(R.onDeregister(R.instance),delete E[v])}}catch(x){T.error("Failed to clean up extensions",x)}return{}},[]),N=Z(E=>{var v;let x=E||m.mapView;try{(v=x==null?void 0:x.destroy)==null||v.call(x)}catch(R){T.error("Failed to destroy MapView",R)}E||(m.extensions=de(m.extensions),m.mapView=void 0,w(!1))},[]);return _e(()=>{if(!h||!D.current)return;N();let E=!1;return d(!0),He(D.current,h,G).then(x=>{E?N(x):(m.mapView=x,w(!0))}).catch(x=>{T.error("Failed to render MapView",x)}).finally(()=>{E||d(!1)}),()=>{E=!0,m.mapView&&N()}},[h,G,N]),O.createElement(j,{mapData:h},O.createElement(f.Provider,{value:ce},O.createElement("div",y({"data-testid":"mappedin-map",ref:D,style:y(y({},Ue),o)},M)),g?O.createElement(O.Fragment,null,s):V?i:null))});n();import{useCallback as Fe,useContext as Ke,useEffect as Be}from"react";n();var W=class W extends Error{constructor(r){super("".concat(r," must be used within a MapView component."))}};p(W,"MapViewNullError");var c=W;function Ye(e,r){let{mapView:t}=Ke(f),a=Fe(o=>r(o),[r]);Be(()=>{if(t==null)throw new c("useMapViewEvent");return t.on(e,a),()=>{t!=null&&t.off(e,a)}},[t,e,r])}p(Ye,"useMapViewEvent");n();import{useCallback as ae,useContext as Qe}from"react";function Xe(e,r){let{extensions:t}=Qe(f);if(!(r!=null&&r.onRegister)||!(r!=null&&r.onDeregister))throw new Error("onRegister and onDeregister are required");let a=ae(()=>{let s=t[e],i=s==null?void 0:s.instance;return i||(i=r.onRegister(),t[e]={instance:i,onDeregister:r.onDeregister}),i},[t,e,r.onRegister]),o=ae(()=>{let s=t[e];s&&(s.onDeregister(s.instance),delete t[e])},[t,e,r.onDeregister]);return{register:a,deregister:o}}p(Xe,"useMapViewExtension");n();import{useContext as tt,useEffect as rt,useRef as at,forwardRef as ot,useImperativeHandle as nt,useState as it}from"react";n();import{useEffect as Ze,useRef as et}from"react";function P(e,r){let t=et(!0);Ze(()=>{if(t.current){t.current=!1;return}return e()},r)}p(P,"useUpdateEffect");var st=ot((e,r)=>{let{mapView:t}=tt(f),a=at(void 0),o=l(()=>e.options,[e.options]),[s,i]=it(!1);return nt(r,()=>a.current,[s]),rt(()=>{if(t==null)throw new c("Path");let M=t.Paths.add(e.coordinate,o);return M.animation.then(()=>{var m;(m=e.onDrawComplete)==null||m.call(e)}),a.current=M,i(!0),()=>{a.current&&t.Paths.remove(a.current),i(!1)}},[t,e.coordinate]),P(()=>{a.current&&o&&(t==null||t.updateState(a.current,o))},[o]),null});n();import{useContext as pt,useEffect as mt}from"react";function ut(e){let{mapView:r}=pt(f),t=l(()=>e.options,[e.options]);return mt(()=>{if(r==null)throw new c("Navigation");return r.Navigation.draw(e.directions,t).then(()=>{var a;(a=e.onDrawComplete)==null||a.call(e)}),()=>{r.Navigation.clear()}},[r,e.directions,t]),null}p(ut,"Navigation");n();import{useContext as ft,useEffect as ct,useRef as dt,forwardRef as lt,useImperativeHandle as Mt,useState as xt}from"react";var yt=lt((e,r)=>{let{mapView:t}=ft(f),a=dt(void 0),o=l(()=>e.style,[e.style]),[s,i]=xt(!1);return Mt(r,()=>a.current,[s]),ct(()=>{if(t==null)throw new Error("MapView not initialized");return a.current=t.Shapes.add(e.geometry,e.style,e.floor),i(!0),()=>{t==null||a.current==null||(t.Shapes.remove(a.current),i(!1))}},[t,e.geometry,e.style,e.floor]),P(()=>{a.current&&o&&(t==null||t.updateState(a.current,o))},[o]),null});n();import{useContext as wt,useEffect as ht,useRef as Et,forwardRef as Pt,useImperativeHandle as gt,useState as Dt}from"react";var St=Pt((e,r)=>{let{mapView:t}=wt(f),a=Et(void 0),o=l(()=>e.options,[e.options]),[s,i]=Dt(!1);return gt(r,()=>a.current,[s]),ht(()=>{if(t==null)throw new c("Model");return a.current=t.Models.add(e.coordinate,e.url,o),i(!0),()=>{t==null||a.current==null||(t.Models.remove(a.current),i(!1))}},[t,e.url]),P(()=>{a.current&&(t==null||t.updateState(a.current,y({position:e.coordinate},o)))},[e.coordinate,o]),null});n();import{useContext as oe}from"react";function Vt(){var t;let{mapView:e}=oe(f),{getCache:r}=oe(S);if(!e)throw new c("useMap");return{mapData:((t=r==null?void 0:r())==null?void 0:t.mapData)||e.getMapData(),mapView:e}}p(Vt,"useMap");n();import Tt,{useCallback as vt,useContext as ie,useEffect as se,useMemo as Rt,useRef as b,forwardRef as pe,useImperativeHandle as me,useState as ue}from"react";import{createPortal as Ct}from"react-dom";n();var _=[0,4,6,8,10],ne=p(()=>{let e=new Array(16).fill(0),r=Math.random()*4294967296;for(let a=0;a<e.length;a++)a>0&&(a&3)===0&&(r=Math.random()*4294967296),e[a]=r>>>((a&3)<<3)&255;let t=e.map(a=>a.toString(16).padStart(2,"0"));return t[6]="4"+t[6][1],t[8]=["8","9","a","b"].includes(t[7][0])?t[7]:"a"+t[7][1],_.map((a,o)=>t.slice(a,o===_.length-1?void 0:_[o+1]).join("")).join("-")},"randomId");var fe=pe((e,r)=>{let{mapView:t}=ie(f),a=b(void 0),[o,s]=ue(!1),i=l(()=>e.options,[e.options]);return me(r,()=>a.current,[o]),se(()=>{if(t==null)throw new c("Marker");return a.current=t.Markers.add(e.target,"",i),s(!0),()=>{t==null||a.current==null||(t.Markers.remove(a.current),s(!1))}},[t,e.target]),P(()=>{a.current&&i&&(t==null||t.updateState(a.current,i))},[i]),t==null||a.current==null?null:Ct(e.children,a.current.contentEl,a.current.id)}),Ot=pe((e,r)=>{let{mapView:t}=ie(f),a=b(ne()),o=b(void 0),[s,i]=ue(!1),M=b(e.target);me(r,()=>o.current,[s]);let m=vt(d=>{o.current=d||void 0,i(!!d)},[]);se(()=>{if(t==null)throw new c("Marker");if(o.current&&o.current.target!==e.target){let{duration:d=300,easing:V="linear"}=e;t.Markers.animateTo(o.current,e.target,{duration:d,easing:V})}return()=>{i(!1)}},[t,e.target]);let g=Rt(()=>C(y({},e),{duration:void 0,easing:void 0}),[e.duration,e.easing]);return Tt.createElement(fe,C(y({},g),{key:a.current,target:M.current,ref:m}))});n();import{forwardRef as Nt,useContext as Lt,useEffect as kt,useImperativeHandle as bt,useRef as At,useState as jt}from"react";var It=Nt((e,r)=>{let{mapView:t}=Lt(f),a=At(void 0),[o,s]=jt(!1),i=l(()=>e.options,[e.options]);return bt(r,()=>a.current,[o]),kt(()=>{if(t==null)throw new c("Label");return a.current=t.Labels.add(e.target,e.text,i),s(!0),()=>{t==null||a.current==null||(t.Labels.remove(a.current),s(!1))}},[t,e.target]),P(()=>{a.current&&(t==null||t.updateState(a.current,y({text:e.text},i)))},[e.text,i]),null});export{Ot as AnimatedMarker,It as Label,j as MapDataProvider,qe as MapView,fe as Marker,St as Model,ut as Navigation,st as Path,yt as Shape,Vt as useMap,Ae as useMapData,We as useMapDataEvent,Ye as useMapViewEvent,Xe as useMapViewExtension};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mappedin/react-sdk",
3
- "version": "6.5.0",
3
+ "version": "6.7.0",
4
4
  "homepage": "https://developer.mappedin.com/",
5
5
  "private": false,
6
6
  "main": "lib/esm/index.js",
@@ -17,7 +17,7 @@
17
17
  "peerDependencies": {
18
18
  "react": ">=16.8.0",
19
19
  "react-dom": ">=16.8.0",
20
- "@mappedin/mappedin-js": "^6.5.0"
20
+ "@mappedin/mappedin-js": "^6.7.0"
21
21
  },
22
22
  "dependencies": {},
23
23
  "devDependencies": {},