@mappedin/react-sdk 6.0.0-rc.1 → 6.0.0-rc.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 (2) hide show
  1. package/lib/esm/index.js +1 -1
  2. package/package.json +2 -2
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- var ue=Object.create;var N=Object.defineProperty,fe=Object.defineProperties,ce=Object.getOwnPropertyDescriptor,le=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertyNames,L=Object.getOwnPropertySymbols,Me=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var H=(e,r,t)=>r in e?N(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,y=(e,r)=>{for(var t in r||(r={}))b.call(r,t)&&H(e,t,r[t]);if(L)for(var t of L(r))z.call(r,t)&&H(e,t,r[t]);return e},v=(e,r)=>fe(e,le(r)),p=(e,r)=>N(e,"name",{value:r,configurable:!0});var $=(e,r)=>{var t={};for(var a in e)b.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&&z.call(e,a)&&(t[a]=e[a]);return t};var ye=(e,r)=>()=>(e&&(r=e(e=0)),r);var he=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var Pe=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of de(r))!b.call(e,o)&&o!==t&&N(e,o,{get:()=>r[o],enumerable:!(a=ce(r,o))||a.enumerable});return e};var U=(e,r,t)=>(t=e!=null?ue(Me(e)):{},Pe(r||!e||!e.__esModule?N(t,"default",{value:e,enumerable:!0}):t,e));var m,n=ye(()=>{m={env:{NODE_ENV:"production",npm_package_version:"6.0.0-rc.1"}}});var A=he((Wt,q)=>{"use strict";n();q.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 we,{createContext as De,useMemo as Se,useState as Ee}from"react";var E=De({getCache:p(()=>{},"getCache"),setCache:p(()=>{},"setCache")});function k({mapData:e,children:r}){let[t,a]=Ee(e?{mapData:e,options:{}}:void 0),o=Se(()=>({getCache:p(()=>t,"getCache"),setCache:a}),[t]);return we.createElement(E.Provider,{value:o},r)}p(k,"MapDataProvider");n();var Y=U(A());import{useCallback as Ve,useContext as Ce,useEffect as B,useRef as Oe,useState as j}from"react";import{getMapData as Le}from"@mappedin/mappedin-js";n();var ge="[MappedinJS]";function Te(e="",{prefix:r=ge}={}){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:m.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(Te,"createLogger");var ve=Te();var V=ve;n();var K=U(A());import{useRef as F}from"react";function d(e,r){let t=F(),a=F();return(0,K.default)(r,a.current)||(t.current=e(),a.current=r),t.current}p(d,"useMemoDeep");function Ne(e){let{getCache:r,setCache:t}=Ce(E),[a,o]=j(void 0),[s,i]=j(!0),[M,u]=j(void 0),D=Oe(0),l=d(()=>e&&v(y({},e),{analytics:y({context:"reactsdk"},e==null?void 0:e.analytics)}),[e]),g=Ve(h=>{let S=++D.current;i(!0),u(void 0),Le(h).then(P=>{D.current===S&&o(P)}).catch(P=>{D.current===S&&(V.error("Failed to fetch MapData",P),u(P))}).finally(()=>{D.current===S&&i(!1)})},[]);return B(()=>{let h=r==null?void 0:r();if(h!=null&&(l==null||h.mapData.mapId===l.mapId&&(0,Y.default)(h.options,l))){o(h.mapData),i(!1),u(void 0);return}if(!l){u(new Error("useMapData requires options if not use within a MapDataProvider or MapView component."));return}g(l)},[g,r,l,a]),B(()=>{let h=r==null?void 0:r();a!=null&&(h==null||h.mapData.mapId===a.mapId)&&(t==null||t({mapData:a,options:l||{}}))},[a,l,r,t]),{mapData:a,isLoading:s,error:M}}p(Ne,"useMapData");n();import{useCallback as Re,useContext as be,useEffect as ke}from"react";function Ae(e,r){let{getCache:t}=be(E),a=Re(o=>r(o),[r]);ke(()=>{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(Ae,"useMapDataEvent");n();import C,{useCallback as je,useEffect as Ie,useMemo as Q,useRef as X,useState as Z,forwardRef as Je,useImperativeHandle as We,createContext as _e}from"react";import{show3dMap as Ge}from"@mappedin/mappedin-js";var f=_e({mapView:void 0}),He={width:"100%",height:"100%",position:"relative"},ze=Je((e,r)=>{let _=e,{mapData:t,options:a,style:o,fallback:s,children:i}=_,M=$(_,["mapData","options","style","fallback","children"]),u=X({}).current,[D,l]=Z(!0),[g,h]=Z(!1),S=X(null),P=Q(()=>t,[t]),W=d(()=>a,[a]);We(r,()=>u.mapView);let se=Q(()=>({mapData:P,mapView:u.mapView}),[P,u.mapView]),O=je(T=>{var G;let x=T||u.mapView;try{(G=x==null?void 0:x.destroy)==null||G.call(x)}catch(me){V.error("Failed to destroy MapView",me)}T||(u.mapView=void 0,h(!1))},[u]);return Ie(()=>{if(!P||!S.current)return;O();let T=!1;return l(!0),Ge(S.current,P,W).then(x=>{T?O(x):(u.mapView=x,h(!0))}).catch(x=>{V.error("Failed to render MapView",x)}).finally(()=>{T||l(!1)}),()=>{T=!0,u.mapView&&O()}},[P,W,u,O]),C.createElement(k,{mapData:P},C.createElement(f.Provider,{value:se},C.createElement("div",y({"data-testid":"mappedin-map",ref:S,style:y(y({},He),o)},M)),D?C.createElement(C.Fragment,null,s):g?i:null))});n();import{useCallback as $e,useContext as Ue,useEffect as qe}from"react";n();var I=class I extends Error{constructor(r){super("".concat(r," must be used within a MapView component."))}};p(I,"MapViewNullError");var c=I;function Fe(e,r){let{mapView:t}=Ue(f),a=$e(o=>r(o),[r]);qe(()=>{if(t==null)throw new c("useMapViewEvent");return t.on(e,a),()=>{t!=null&&t.off(e,a)}},[t,e,r])}p(Fe,"useMapViewEvent");n();import{useContext as Ye,useEffect as Qe,useRef as Xe,forwardRef as Ze,useImperativeHandle as et,useState as tt}from"react";n();import{useEffect as Ke,useRef as Be}from"react";function w(e,r){let t=Be(!0);Ke(()=>{if(t.current){t.current=!1;return}return e()},r)}p(w,"useUpdateEffect");var rt=Ze((e,r)=>{let{mapView:t}=Ye(f),a=Xe(),o=d(()=>e.options,[e.options]),[s,i]=tt(!1);return et(r,()=>a.current,[s]),Qe(()=>{if(t==null)throw new c("Path");let M=t.Paths.add(e.coordinate,o);return M.animation.then(()=>{var u;(u=e.onDrawComplete)==null||u.call(e)}),a.current=M,i(!0),()=>{a.current&&t.Paths.remove(a.current),i(!1)}},[t,e.coordinate]),w(()=>{a.current&&o&&(t==null||t.updateState(a.current,o))},[o]),null});n();import{useContext as at,useEffect as ot}from"react";function nt(e){let{mapView:r}=at(f),t=d(()=>e.options,[e.options]);return ot(()=>{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(nt,"Navigation");n();import{useContext as it,useEffect as pt,useRef as st,forwardRef as mt,useImperativeHandle as ut,useState as ft}from"react";var ct=mt((e,r)=>{let{mapView:t}=it(f),a=st(),o=d(()=>e.style,[e.style]),[s,i]=ft(!1);return ut(r,()=>a.current,[s]),pt(()=>{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]),w(()=>{a.current&&o&&(t==null||t.updateState(a.current,o))},[o]),null});n();import{useContext as lt,useEffect as dt,useRef as Mt,forwardRef as yt,useImperativeHandle as ht,useState as Pt}from"react";var xt=yt((e,r)=>{let{mapView:t}=lt(f),a=Mt(),o=d(()=>e.options,[e.options]),[s,i]=Pt(!1);return ht(r,()=>a.current,[s]),dt(()=>{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]),w(()=>{a.current&&(t==null||t.updateState(a.current,y({position:e.coordinate},o)))},[e.coordinate,o]),null});n();import{useContext as ee}from"react";function wt(){var t;let{mapView:e}=ee(f),{getCache:r}=ee(E);if(!e)throw new c("useMap");return{mapData:((t=r==null?void 0:r())==null?void 0:t.mapData)||e.getMapData(),mapView:e}}p(wt,"useMap");n();import Dt,{useCallback as St,useContext as re,useEffect as ae,useMemo as Et,useRef as R,forwardRef as oe,useImperativeHandle as ne,useState as ie}from"react";import{createPortal as gt}from"react-dom";n();var J=[0,4,6,8,10],te=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],J.map((a,o)=>t.slice(a,o===J.length-1?void 0:J[o+1]).join("")).join("-")},"randomId");var pe=oe((e,r)=>{let{mapView:t}=re(f),a=R(),[o,s]=ie(!1),i=d(()=>e.options,[e.options]);return ne(r,()=>a.current,[o]),ae(()=>{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]),w(()=>{a.current&&i&&(t==null||t.updateState(a.current,i))},[i]),t==null||a.current==null?null:gt(e.children,a.current.contentEl,a.current.id)}),Tt=oe((e,r)=>{let{mapView:t}=re(f),a=R(te()),o=R(),[s,i]=ie(!1),M=R(e.target);ne(r,()=>o.current,[s]);let u=St(l=>{o.current=l||void 0,i(!!l)},[]);ae(()=>{if(t==null)throw new c("Marker");if(o.current&&o.current.target!==e.target){let{duration:l=300,easing:g="linear"}=e;t.Markers.animateTo(o.current,e.target,{duration:l,easing:g})}return()=>{i(!1)}},[t,e.target]);let D=Et(()=>v(y({},e),{duration:void 0,easing:void 0}),[e.duration,e.easing]);return Dt.createElement(pe,v(y({},D),{key:a.current,target:M.current,ref:u}))});n();import{forwardRef as vt,useContext as Vt,useEffect as Ct,useImperativeHandle as Ot,useRef as Lt,useState as Nt}from"react";var Rt=vt((e,r)=>{let{mapView:t}=Vt(f),a=Lt(),[o,s]=Nt(!1),i=d(()=>e.options,[e.options]);return Ot(r,()=>a.current,[o]),Ct(()=>{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]),w(()=>{a.current&&(t==null||t.updateState(a.current,y({text:e.text},i)))},[e.text,i]),null});export{Tt as AnimatedMarker,Rt as Label,k as MapDataProvider,ze as MapView,pe as Marker,xt as Model,nt as Navigation,rt as Path,ct as Shape,wt as useMap,Ne as useMapData,Ae as useMapDataEvent,Fe as useMapViewEvent};
1
+ var fe=Object.create;var L=Object.defineProperty,ce=Object.defineProperties,le=Object.getOwnPropertyDescriptor,de=Object.getOwnPropertyDescriptors,Me=Object.getOwnPropertyNames,R=Object.getOwnPropertySymbols,ye=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var H=(e,r,t)=>r in e?L(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,y=(e,r)=>{for(var t in r||(r={}))b.call(r,t)&&H(e,t,r[t]);if(R)for(var t of R(r))z.call(r,t)&&H(e,t,r[t]);return e},v=(e,r)=>ce(e,de(r)),s=(e,r)=>L(e,"name",{value:r,configurable:!0});var $=(e,r)=>{var t={};for(var a in e)b.call(e,a)&&r.indexOf(a)<0&&(t[a]=e[a]);if(e!=null&&R)for(var a of R(e))r.indexOf(a)<0&&z.call(e,a)&&(t[a]=e[a]);return t};var he=(e,r)=>()=>(e&&(r=e(e=0)),r);var Pe=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var we=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Me(r))!b.call(e,o)&&o!==t&&L(e,o,{get:()=>r[o],enumerable:!(a=le(r,o))||a.enumerable});return e};var U=(e,r,t)=>(t=e!=null?fe(ye(e)):{},we(r||!e||!e.__esModule?L(t,"default",{value:e,enumerable:!0}):t,e));var m,n=he(()=>{m={env:{NODE_ENV:"production",npm_package_version:"6.0.0-rc.2"}}});var A=Pe((_t,F)=>{"use strict";n();F.exports=s(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,p;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(p=Object.keys(r),a=p.length,a!==Object.keys(t).length)return!1;for(o=a;o--!==0;)if(!Object.prototype.hasOwnProperty.call(t,p[o]))return!1;for(o=a;o--!==0;){var i=p[o];if(!e(r[i],t[i]))return!1}return!0}return r!==r&&t!==t},"equal")});n();n();import De,{createContext as Se,useCallback as q,useMemo as Ee,useRef as ge}from"react";var E=Se({getCache:s(()=>{},"getCache"),setCache:s(()=>{},"setCache")});function k({mapData:e,children:r}){let t=ge(e?{mapData:e,options:{}}:void 0),a=q(()=>t.current,[]),o=q(i=>{t.current=i},[]),p=Ee(()=>({getCache:a,setCache:o}),[a,o]);return De.createElement(E.Provider,{value:p},r)}s(k,"MapDataProvider");n();var Q=U(A());import{useCallback as Ce,useContext as Oe,useEffect as Y,useRef as Re,useState as j}from"react";import{getMapData as Le}from"@mappedin/mappedin-js";n();var Te="[MappedinJS]";function ve(e="",{prefix:r=Te}={}){let t="".concat(r).concat(e?"-".concat(e):""),a=s((o,p)=>{if(typeof window<"u"&&window.rnDebug){let i=p.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:m.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)}}}s(ve,"createLogger");var Ve=ve();var V=Ve;n();var B=U(A());import{useRef as K}from"react";function d(e,r){let t=K(),a=K();return(0,B.default)(r,a.current)||(t.current=e(),a.current=r),t.current}s(d,"useMemoDeep");function Ne(e){let{getCache:r,setCache:t}=Oe(E),[a,o]=j(void 0),[p,i]=j(!0),[M,u]=j(void 0),D=Re(0),l=d(()=>e&&v(y({},e),{analytics:y({context:"reactsdk"},e==null?void 0:e.analytics)}),[e]),g=Ce(h=>{let S=++D.current;i(!0),u(void 0),Le(h).then(P=>{D.current===S&&o(P)}).catch(P=>{D.current===S&&(V.error("Failed to fetch MapData",P),u(P))}).finally(()=>{D.current===S&&i(!1)})},[]);return Y(()=>{let h=r==null?void 0:r();if(h!=null&&(l==null||h.mapData.mapId===l.mapId&&(0,Q.default)(h.options,l))){o(h.mapData),i(!1),u(void 0);return}if(!l){u(new Error("useMapData requires options if not use within a MapDataProvider or MapView component."));return}g(l)},[g,r,l]),Y(()=>{let h=r==null?void 0:r();a!=null&&(h==null||h.mapData.mapId===a.mapId)&&(t==null||t({mapData:a,options:l||{}}))},[a,l,r,t]),{mapData:a,isLoading:p,error:M}}s(Ne,"useMapData");n();import{useCallback as be,useContext as ke,useEffect as Ae}from"react";function je(e,r){let{getCache:t}=ke(E),a=be(o=>r(o),[r]);Ae(()=>{var p;let o=(p=t==null?void 0:t())==null?void 0:p.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])}s(je,"useMapDataEvent");n();import C,{useCallback as Ie,useEffect as Je,useMemo as X,useRef as Z,useState as ee,forwardRef as We,useImperativeHandle as _e,createContext as Ge}from"react";import{show3dMap as He}from"@mappedin/mappedin-js";var f=Ge({mapView:void 0}),ze={width:"100%",height:"100%",position:"relative"},$e=We((e,r)=>{let _=e,{mapData:t,options:a,style:o,fallback:p,children:i}=_,M=$(_,["mapData","options","style","fallback","children"]),u=Z({}).current,[D,l]=ee(!0),[g,h]=ee(!1),S=Z(null),P=X(()=>t,[t]),W=d(()=>a,[a]);_e(r,()=>u.mapView);let me=X(()=>({mapData:P,mapView:u.mapView}),[P,u.mapView]),O=Ie(T=>{var G;let w=T||u.mapView;try{(G=w==null?void 0:w.destroy)==null||G.call(w)}catch(ue){V.error("Failed to destroy MapView",ue)}T||(u.mapView=void 0,h(!1))},[u]);return Je(()=>{if(!P||!S.current)return;O();let T=!1;return l(!0),He(S.current,P,W).then(w=>{T?O(w):(u.mapView=w,h(!0))}).catch(w=>{V.error("Failed to render MapView",w)}).finally(()=>{T||l(!1)}),()=>{T=!0,u.mapView&&O()}},[P,W,u,O]),C.createElement(k,{mapData:P},C.createElement(f.Provider,{value:me},C.createElement("div",y({"data-testid":"mappedin-map",ref:S,style:y(y({},ze),o)},M)),D?C.createElement(C.Fragment,null,p):g?i:null))});n();import{useCallback as Ue,useContext as qe,useEffect as Fe}from"react";n();var I=class I extends Error{constructor(r){super("".concat(r," must be used within a MapView component."))}};s(I,"MapViewNullError");var c=I;function Ke(e,r){let{mapView:t}=qe(f),a=Ue(o=>r(o),[r]);Fe(()=>{if(t==null)throw new c("useMapViewEvent");return t.on(e,a),()=>{t!=null&&t.off(e,a)}},[t,e,r])}s(Ke,"useMapViewEvent");n();import{useContext as Qe,useEffect as Xe,useRef as Ze,forwardRef as et,useImperativeHandle as tt,useState as rt}from"react";n();import{useEffect as Be,useRef as Ye}from"react";function x(e,r){let t=Ye(!0);Be(()=>{if(t.current){t.current=!1;return}return e()},r)}s(x,"useUpdateEffect");var at=et((e,r)=>{let{mapView:t}=Qe(f),a=Ze(),o=d(()=>e.options,[e.options]),[p,i]=rt(!1);return tt(r,()=>a.current,[p]),Xe(()=>{if(t==null)throw new c("Path");let M=t.Paths.add(e.coordinate,o);return M.animation.then(()=>{var u;(u=e.onDrawComplete)==null||u.call(e)}),a.current=M,i(!0),()=>{a.current&&t.Paths.remove(a.current),i(!1)}},[t,e.coordinate]),x(()=>{a.current&&o&&(t==null||t.updateState(a.current,o))},[o]),null});n();import{useContext as ot,useEffect as nt}from"react";function it(e){let{mapView:r}=ot(f),t=d(()=>e.options,[e.options]);return nt(()=>{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}s(it,"Navigation");n();import{useContext as pt,useEffect as st,useRef as mt,forwardRef as ut,useImperativeHandle as ft,useState as ct}from"react";var lt=ut((e,r)=>{let{mapView:t}=pt(f),a=mt(),o=d(()=>e.style,[e.style]),[p,i]=ct(!1);return ft(r,()=>a.current,[p]),st(()=>{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]),x(()=>{a.current&&o&&(t==null||t.updateState(a.current,o))},[o]),null});n();import{useContext as dt,useEffect as Mt,useRef as yt,forwardRef as ht,useImperativeHandle as Pt,useState as wt}from"react";var xt=ht((e,r)=>{let{mapView:t}=dt(f),a=yt(),o=d(()=>e.options,[e.options]),[p,i]=wt(!1);return Pt(r,()=>a.current,[p]),Mt(()=>{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]),x(()=>{a.current&&(t==null||t.updateState(a.current,y({position:e.coordinate},o)))},[e.coordinate,o]),null});n();import{useContext as te}from"react";function Dt(){var t;let{mapView:e}=te(f),{getCache:r}=te(E);if(!e)throw new c("useMap");return{mapData:((t=r==null?void 0:r())==null?void 0:t.mapData)||e.getMapData(),mapView:e}}s(Dt,"useMap");n();import St,{useCallback as Et,useContext as ae,useEffect as oe,useMemo as gt,useRef as N,forwardRef as ne,useImperativeHandle as ie,useState as pe}from"react";import{createPortal as Tt}from"react-dom";n();var J=[0,4,6,8,10],re=s(()=>{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],J.map((a,o)=>t.slice(a,o===J.length-1?void 0:J[o+1]).join("")).join("-")},"randomId");var se=ne((e,r)=>{let{mapView:t}=ae(f),a=N(),[o,p]=pe(!1),i=d(()=>e.options,[e.options]);return ie(r,()=>a.current,[o]),oe(()=>{if(t==null)throw new c("Marker");return a.current=t.Markers.add(e.target,"",i),p(!0),()=>{t==null||a.current==null||(t.Markers.remove(a.current),p(!1))}},[t,e.target]),x(()=>{a.current&&i&&(t==null||t.updateState(a.current,i))},[i]),t==null||a.current==null?null:Tt(e.children,a.current.contentEl,a.current.id)}),vt=ne((e,r)=>{let{mapView:t}=ae(f),a=N(re()),o=N(),[p,i]=pe(!1),M=N(e.target);ie(r,()=>o.current,[p]);let u=Et(l=>{o.current=l||void 0,i(!!l)},[]);oe(()=>{if(t==null)throw new c("Marker");if(o.current&&o.current.target!==e.target){let{duration:l=300,easing:g="linear"}=e;t.Markers.animateTo(o.current,e.target,{duration:l,easing:g})}return()=>{i(!1)}},[t,e.target]);let D=gt(()=>v(y({},e),{duration:void 0,easing:void 0}),[e.duration,e.easing]);return St.createElement(se,v(y({},D),{key:a.current,target:M.current,ref:u}))});n();import{forwardRef as Vt,useContext as Ct,useEffect as Ot,useImperativeHandle as Rt,useRef as Lt,useState as Nt}from"react";var bt=Vt((e,r)=>{let{mapView:t}=Ct(f),a=Lt(),[o,p]=Nt(!1),i=d(()=>e.options,[e.options]);return Rt(r,()=>a.current,[o]),Ot(()=>{if(t==null)throw new c("Label");return a.current=t.Labels.add(e.target,e.text,i),p(!0),()=>{t==null||a.current==null||(t.Labels.remove(a.current),p(!1))}},[t,e.target]),x(()=>{a.current&&(t==null||t.updateState(a.current,y({text:e.text},i)))},[e.text,i]),null});export{vt as AnimatedMarker,bt as Label,k as MapDataProvider,$e as MapView,se as Marker,xt as Model,it as Navigation,at as Path,lt as Shape,Dt as useMap,Ne as useMapData,je as useMapDataEvent,Ke as useMapViewEvent};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mappedin/react-sdk",
3
- "version": "6.0.0-rc.1",
3
+ "version": "6.0.0-rc.2",
4
4
  "homepage": "https://developer.mappedin.com/",
5
5
  "private": false,
6
6
  "main": "lib/esm/index.js",
@@ -32,5 +32,5 @@
32
32
  "volta": {
33
33
  "extends": "../../package.json"
34
34
  },
35
- "gitHead": "6f653df01e872470753a4ddfeb213b6e28c50f93"
35
+ "gitHead": "3c5c34f3c679167ed717dea0991fe3d1112e24b6"
36
36
  }