@mappedin/dynamic-focus 6.21.0-beta.0 → 6.21.1-beta.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.
@@ -1,2 +1,2 @@
1
- var Xo=Object.defineProperty;var ot=r=>{throw TypeError(r)};var Tt=(r,t,e)=>t in r?Xo(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t)=>Xo(r,"name",{value:t,configurable:!0});var y=(r,t,e)=>Tt(r,typeof t!="symbol"?t+"":t,e),Mo=(r,t,e)=>t.has(r)||ot("Cannot "+e);var o=(r,t,e)=>(Mo(r,t,"read from private field"),e?e.call(r):t.get(r)),c=(r,t,e)=>t.has(r)?ot("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),d=(r,t,e,i)=>(Mo(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),F=(r,t,e)=>(Mo(r,t,"access private method"),e);var S={env:{NODE_ENV:"production",npm_package_version:"6.21.0-beta.0"}};var eo={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},io=.2,Zo=.4;var xo="[MappedinJS]";function Lo(r="",{prefix:t=xo}={}){let e=`${t}${r?`-${r}`:""}`,i=a((s,n)=>{if(typeof window<"u"&&window.rnDebug){let f=n.map(m=>m instanceof Error&&m.stack?`${m.message}
1
+ var Xo=Object.defineProperty;var ot=r=>{throw TypeError(r)};var Tt=(r,t,e)=>t in r?Xo(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t)=>Xo(r,"name",{value:t,configurable:!0});var y=(r,t,e)=>Tt(r,typeof t!="symbol"?t+"":t,e),Mo=(r,t,e)=>t.has(r)||ot("Cannot "+e);var o=(r,t,e)=>(Mo(r,t,"read from private field"),e?e.call(r):t.get(r)),c=(r,t,e)=>t.has(r)?ot("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),d=(r,t,e,i)=>(Mo(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),F=(r,t,e)=>(Mo(r,t,"access private method"),e);var S={env:{NODE_ENV:"production",npm_package_version:"6.21.1-beta.0"}};var eo={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},io=.2,Zo=.4;var xo="[MappedinJS]";function Lo(r="",{prefix:t=xo}={}){let e=`${t}${r?`-${r}`:""}`,i=a((s,n)=>{if(typeof window<"u"&&window.rnDebug){let f=n.map(m=>m instanceof Error&&m.stack?`${m.message}
2
2
  ${m.stack}`:m);window.rnDebug(`${r} ${s}: ${f.join(" ")}`)}},"rnDebug");return{logState:S.env.NODE_ENV==="test"?3:0,log(...s){this.logState<=0&&(console.log(e,...s),i("log",s))},warn(...s){this.logState<=1&&(console.warn(e,...s),i("warn",s))},error(...s){this.logState<=2&&(console.error(e,...s),i("error",s))},assert(...s){console.assert(...s)},time(s){console.time(s)},timeEnd(s){console.timeEnd(s)},setLevel(s){0<=s&&s<=3&&(this.logState=s)}}}a(Lo,"createLogger");var wt=Lo();var W=wt;var I=Lo("",{prefix:"[DynamicFocus]"});var tt=a((r,t={})=>{let e={initialVisibility:t.initialVisibility??"indoor-first",debug:t.debug??!1},i=Ot(r,e);if(i===void 0)return I.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:eo.indoorZoomThreshold,outdoorZoomThreshold:eo.outdoorZoomThreshold};let s=i+Zo,n=i+io;return e.initialVisibility==="indoor-first"&&(s=i-io,n=i-Zo),{indoorZoomThreshold:s,outdoorZoomThreshold:n}},"calculateZoomThresholds");function Ot(r,t){let i=r.getMapData().getByType("floor-stack").filter(f=>f.type!=="Outdoor"),s=1/0,n;for(let f of i){let m=r.Camera.getFocusOnTransform(f).zoomLevel??1/0;m<s&&(s=m,n=f)}if(s!==1/0)return t.debug&&n&&r.Camera.getFocusOnTransform(n,{debugColor:"blue"}),s}a(Ot,"getDefaultZoomLevel");import{Floor as Rt,getMultiFloorState as Ut}from"@mappedin/mappedin-js";function et(r,t){if(r==null||t==null)return r===t;if(r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==t[e])return!1;return!0}a(et,"arraysEqual");var _o=class _o{_subscribers={};_abortController=new AbortController;get signal(){return this._abortController.signal}publish(t,e){!this._subscribers||!this._subscribers[t]||this.signal.aborted||this._subscribers[t].forEach(function(i){typeof i=="function"&&i(e)})}onAbort(t){this.signal.addEventListener("abort",()=>t(),{once:!0})}on(t,e,i){let s=i?.signal;if(s?.aborted||this._abortController&&this._abortController.signal.aborted)return()=>{};this._subscribers||(this._subscribers={}),this._subscribers[t]=this._subscribers[t]||[],this._subscribers[t].push(e);let n=a(()=>{this.off(t,e)},"cleanup");return s&&s.addEventListener("abort",n,{once:!0}),n}off(t,e){if(!this._subscribers||this._subscribers[t]==null||this.signal.aborted)return;let i=this._subscribers[t].indexOf(e);i!==-1&&this._subscribers[t].splice(i,1)}destroy(){this.signal.aborted||(this._subscribers={},this._abortController.abort())}};a(_o,"PubSub");var To=_o;import{Facade as Vt,Floor as It,FloorStack as At}from"@mappedin/mappedin-js";var A,so,C,w,T,k,H,K,No=class No{constructor(t,e){y(this,"__type","building");c(this,A);c(this,so,new Map);c(this,C,new Map);c(this,w,[]);c(this,T);c(this,k);y(this,"defaultFloor");y(this,"activeFloor");y(this,"excluded",!1);y(this,"floorsAltitudesMap",new Map);y(this,"aboveGroundFloors",[]);c(this,H);c(this,K);d(this,A,t),d(this,so,new Map(t.floors.map(n=>[n.id,n]))),d(this,C,new Map(t.floors.map(n=>[n.elevation,n]))),d(this,w,Array.from(o(this,C).values()).sort((n,f)=>n.elevation-f.elevation));let i=t.defaultFloor;if(!i)throw new Error(`Building created for floor stack "${t.id}" with no resolvable default floor`);this.defaultFloor=i,this.activeFloor=this.defaultFloor,d(this,T,e),this.aboveGroundFloors=o(this,w).filter(n=>n.elevation>=0);let s=t.facade?.spaces.map(n=>o(this,T).getState(n)).sort((n,f)=>n.altitude-f.altitude);if(s&&s.length===this.aboveGroundFloors.length)for(let n in this.aboveGroundFloors){let f=this.aboveGroundFloors[n],m=s[n];this.floorsAltitudesMap.set(f.elevation,{altitude:m.altitude,visualHeight:m.height})}}get id(){return o(this,A).id}get name(){return o(this,A).name}get floors(){return o(this,A).floors}get floorStack(){return o(this,A)}get facade(){return o(this,A).facade}get isCurrentFloorStack(){return this.id===o(this,T).currentFloorStack.id}get isIndoor(){let t=o(this,T).getState(this.facade);return this.isCurrentFloorStack||t?.visible===!1&&t?.opacity===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,H)==null&&d(this,H,Math.max(...o(this,C).keys())),o(this,H)}get minElevation(){return o(this,K)==null&&d(this,K,Math.min(...o(this,C).keys())),o(this,K)}has(t){return It.is(t)?o(this,so).has(t.id):At.is(t)?t.id===o(this,A).id:Vt.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return o(this,C).get(t)}getNearestFloorByElevation(t){let e=this.getFloorByElevation(t);if(e)return e;if(t>=0){if(t>this.maxElevation)return o(this,w)[o(this,w).length-1];for(let i=o(this,w).length-1;i>=0;i--){let s=o(this,w)[i];if(s.elevation<=t)return s}}else{if(t<this.minElevation)return o(this,w)[0];for(let i of o(this,w))if(i.elevation>=t)return i}}getHighestFloor(){return o(this,w)[o(this,w).length-1]}cancelAnimation(){o(this,k)&&(o(this,k).animation.cancel(),d(this,k,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,k)?.state||o(this,T).getState(this.facade);if(!i||!t||i?.opacity===t.opacity&&i?.visible===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:s,visible:n}=t;if(o(this,T).updateState(this.facade,{visible:!0}),s!==void 0){d(this,k,{animation:o(this,T).animateState(this.facade,{opacity:s},{duration:e.duration}),state:t});let f=await o(this,k).animation;if(d(this,k,void 0),f.result==="cancelled")return f}return n===!1&&o(this,T).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,A).floors.forEach(t=>{o(this,T).updateState(t,{visible:t.id===o(this,T).currentFloor.id})}),this.has(o(this,T).currentFloor)||o(this,T).updateState(this.facade,{visible:!0,opacity:1})}};A=new WeakMap,so=new WeakMap,C=new WeakMap,w=new WeakMap,T=new WeakMap,k=new WeakMap,H=new WeakMap,K=new WeakMap,a(No,"Building");var vo=No;function it(r,t,e){return r>=t?"in-range":r<=e?"out-of-range":"transition"}a(it,"getZoomState");function wo(r,t,e){if(r.__type==="outdoors"&&"floor"in r)return r.floor;let i=r;if(i.excluded)return i.activeFloor;switch(t){case"lock-elevation":return i.getFloorByElevation(e);case"nearest-elevation":return i.getNearestFloorByElevation(e);case"active-floor":return i.activeFloor;default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(wo,"getFloorToShow");function Bt(r,t,e,i){return i?{facade:r,state:{type:"facade",visible:!1,opacity:0}}:t?{facade:r,state:{type:"facade",visible:!1,opacity:0}}:e?{facade:r,state:{type:"facade",visible:!0,opacity:.2}}:{facade:r,state:{type:"facade",visible:!0,opacity:1}}}a(Bt,"getFacadeState");function kt(r,t,e){return{outdoorOpacity:"initial",floorStates:r.floors.map(i=>{let n=i.id===t.id&&e;return{floor:i,state:{type:"floor",visible:n,geometry:{visible:n},labels:{enabled:n},markers:{enabled:n},footprint:{visible:!1},occlusion:{enabled:!1}}}})}}a(kt,"getSingleBuildingState");function st(r,t){if(!t.includes("lock-elevation"))return"initial";for(let e of r)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}a(st,"getOutdoorOpacity");function rt(r,t,e){switch(e){case"in-range":return r[0]?.canSetFloor?r[0]:void 0;case"out-of-range":return t;case"transition":default:return}}a(rt,"getSetFloorTargetFromZoomState");function nt(r){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:s,mode:n,elevation:f,floorIdsInNavigation:m,floorStackIdsInNavigation:h,multiFloorView:g,getMultiFloorState:j,dynamicBuildingInteriors:V,isolateBelowGroundView:q,currentElevation:bo,forceInteriorsVisible:to,getFloorStackAltitudeData:yo}=r,So=new Map,Bo=q&&bo<0&&s==="in-range";for(let b of t){let Jo=e.has(b.id),Eo=Bo&&b.minElevation>=0,bt=Eo?!1:Jo,ko=Eo?!1:Co({building:b,currentFloor:i,inRange:s==="in-range",inFocus:Jo,mode:n,elevation:f,inNavigation:h.includes(b.id),dynamicBuildingInteriors:V,forceInteriorsVisible:to}),Do=i.floorStack.id===b.id?b.activeFloor:wo(b,n,f),yt=g?.enabled?j(b.floors,Do||b.activeFloor,m,yo?.(b.id)??b.floorsAltitudesMap,{color:g?.footprintColor,spacesOpenToBelowEnabled:g?.spacesOpenToBelowEnabled,spacesOpenToBelowVisualEffectEnabled:g?.spacesOpenToBelowVisualEffectEnabled,spacesOpenToBelowVisualEffectDarkenAmount:g?.spacesOpenToBelowVisualEffectDarkenAmount,spacesOpenToBelowVisualEffectDarkenUseDepth:g?.spacesOpenToBelowVisualEffectDarkenUseDepth,spacesOpenToBelowVisualEffectDesaturateAmount:g?.spacesOpenToBelowVisualEffectDesaturateAmount,spacesOpenToBelowVisualEffectDesaturateUseDepth:g?.spacesOpenToBelowVisualEffectDesaturateUseDepth,spacesOpenToBelowVisualEffectWashOutAmount:g?.spacesOpenToBelowVisualEffectWashOutAmount,spacesOpenToBelowVisualEffectWashOutUseDepth:g?.spacesOpenToBelowVisualEffectWashOutUseDepth,opacity:g?.footprintOpacity,outline:g?.footprintOutline}):kt(b.floorStack,Do||b.activeFloor,ko),St=q&&bo<0&&s==="in-range",Et=Bt(b.facade,ko,St,Eo);So.set(b.id,{building:b,showIndoor:ko,floorStackState:yt,facadeState:Et,inFocus:bt,floorToShow:Do,isAboveGroundInIsolation:Eo})}return So}a(nt,"getBuildingStates");function at(r,t){return r.excluded?"none":t?"indoor":"outdoor"}a(at,"getBuildingAnimationType");function Co(r){let{building:t,currentFloor:e,inRange:i,inFocus:s,mode:n,elevation:f,inNavigation:m,dynamicBuildingInteriors:h,forceInteriorsVisible:g}=r;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(g===!0||m===!0)return!0;if(!h)return e.floorStack.type!=="Outdoor";if(!i||!s)return!1;switch(n){case"lock-elevation":return t.getFloorByElevation(f)!=null;default:break}return!0}a(Co,"shouldShowIndoor");function lt(r,t,e){return r!==t&&!e}a(lt,"shouldDeferSetFloor");var ut=["default-floor","active-floor","lock-elevation","nearest-elevation"];import{Floor as Dt,FloorStack as Mt}from"@mappedin/mappedin-js";function dt(r,t,e,i){return(r<t||r>e)&&W.warn(i),Math.min(e,Math.max(t,r))}a(dt,"clampWithWarning");function Go(r,t){return!Dt.is(r)||r?.floorStack==null||!Mt.is(t)?!1:r.floorStack.id!==t.id?(W.warn(`Floor (${r.id}) does not belong to floor stack (${t.id}).`),!1):!0}a(Go,"validateFloorForStack");function Po(r,t,e,i){return dt(r,t,e,`${i} must be between ${t} and ${e}.`)}a(Po,"validateZoomThreshold");var D,Q,ro,Ro,Uo=class Uo{constructor(t,e){c(this,ro);y(this,"__type","outdoors");c(this,D);c(this,Q);d(this,D,t),d(this,Q,e)}get id(){return o(this,D).id}get floorStack(){return o(this,D)}get floor(){return o(this,D).defaultFloor}matchesFloorStack(t){return t===o(this,D)||t===o(this,D).id}show(){F(this,ro,Ro).call(this,!0)}hide(){F(this,ro,Ro).call(this,!1)}destroy(){this.matchesFloorStack(o(this,Q).currentFloorStack)||this.hide()}};D=new WeakMap,Q=new WeakMap,ro=new WeakSet,Ro=a(function(t){for(let e of o(this,D).floors)o(this,Q).updateState(e,{visible:t})},"#setVisible"),a(Uo,"Outdoors");var Oo=Uo;function ct(r,t){let e=r.getByType("floor-stack"),i=e.find(n=>n.type?.toLowerCase()==="outdoor");if(i)return i;let s=e.find(n=>n.facade==null&&!t.has(n.id));return s||(I.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(ct,"getOutdoorFloorStack");function Zt(r,t){return`${t} ${r}`}a(Zt,"formatMessage");var jo=class jo extends Error{constructor(t,e=xo){super(Zt(t,e)),this.name="MappedinError"}};a(jo,"MappedinError");var Vo=jo;var xt=a(r=>r,"linearEase"),Lt=a(r=>r*r,"quadEaseIn"),_t=a(r=>1-Math.cos(r*Math.PI/2),"easeIn"),Nt=a(r=>1-(1-r)*(1-r),"quadEaseOut"),Ct=a(r=>1-Math.pow(1-r,3),"cubicEaseOut"),Gt={linear:xt,"ease-in":Lt,"ease-out":Nt,"ease-in-out":_t,"ease-out-cubic":Ct};function Pt(r,t){let e=0;if(t.length<2)return e;let s=t[0]<t[1]?(n,f)=>n>f:(n,f)=>n<f;for(;e<t.length-1&&s(r,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(Pt,"getInterpolationBreakpoint");function ht(r,t,e,i="ease-in"){if(t.length!==e.length)throw new Vo("Input and output ranges must have the same number of values.");r=Math.max(t[0],Math.min(r,t[t.length-1]));let s=Pt(r,t),n=(r-t[s])/(t[s+1]-t[s]),f=typeof i=="function"?i(n):Gt[i](n);return e[s]+f*(e[s+1]-e[s])}a(ht,"interpolateMulti");var M,no,ao,x,lo,zo=class zo{constructor(t,e,i){y(this,"layers");y(this,"visible");c(this,M);c(this,no,[]);c(this,ao,!1);c(this,x,new Map);y(this,"interpolationFn");c(this,lo,1);this.layers=t,this.visible=e,d(this,M,i)}processLayerGroup(t,e){o(this,ao)||(this.layers.forEach(i=>{let s=t[i];s&&o(this,no).push(...s)}),d(this,ao,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:s,indoorZoomThreshold:n}=e();return ht(i,[s,n],[1,0])}))}setOpacity(t){d(this,lo,t);for(let e of o(this,no))if(e.startsWith("img_")){let i=o(this,M).Image3D.getById(e);if(i){let s=o(this,M).getState(i.image);o(this,x).has(e)||o(this,x).set(e,s?.opacity??1);let n=Math.min(o(this,x).get(e),t);o(this,M).updateState(i.image,{opacity:n})}}else{let i=o(this,M).getMapData()?.getById("space",e);if(!i)continue;let s=o(this,M).getState(i);o(this,x).has(e)||o(this,x).set(e,s?.opacity??1);let n=Math.min(o(this,x).get(e),t);o(this,M).updateState(i,{opacity:n,visible:n>0})}}get opacity(){return o(this,lo)}};M=new WeakMap,no=new WeakMap,ao=new WeakMap,x=new WeakMap,lo=new WeakMap,a(zo,"LayerGroup");var Io=zo;function $o(r,t,e){r.forEach(i=>{if(e?.forceOpacity!==void 0){i.setOpacity(e.forceOpacity),i.visible=e.forceOpacity===1;return}if(i.interpolationFn!=null){let s=i.interpolationFn(t);s!=null&&(i.setOpacity(s),i.visible=s===1)}})}a($o,"runLayerGroupInterpolations");var O,l,G,u,$,z,E,L,Y,_,v,J,uo,co,ho,Z,P,X,N,R,U,p,Yo,mt,qo,Wo,Ho,pt,Ko,fo,mo,po,go,Fo,oo,Ao,gt,Ft,B,Qo=class Qo{constructor(t){c(this,p);c(this,O);c(this,l);c(this,G);c(this,u,eo);c(this,$,[]);c(this,z,new Set);c(this,E,new Map);c(this,L);c(this,Y,!1);c(this,_,!1);c(this,v,0);c(this,J,0);c(this,uo,[]);c(this,co,{});c(this,ho,{});c(this,Z,"transition");c(this,P,"outdoor");c(this,X,[]);c(this,N,!1);c(this,R,[]);c(this,U,null);y(this,"sceneUpdateQueue",Promise.resolve());y(this,"on",a((t,e)=>{o(this,O).on(t,e)},"on"));y(this,"off",a((t,e)=>{o(this,O).off(t,e)},"off"));c(this,fo,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(et(e,this.focusedFacades)&&o(this,P)==="transition"&&!o(this,_))return;d(this,_,!1),d(this,$,[]),o(this,z).clear();let i=o(this,u).isolateBelowGroundView&&o(this,v)<0;if(e.length>0)for(let s of e){let n=o(this,E).get(s.floorStack.id);if(n){if(i&&n.minElevation>=0)continue;o(this,z).add(n.id),o(this,$).push(n)}}o(this,u).autoFocus&&this.focus()},"#handleFacadesInViewChange"));c(this,mo,a(async t=>{if(!this.isEnabled)return;let{floor:e}=t,i=o(this,E).get(e.floorStack.id);i&&(t.reason==="dynamic-focus"&&o(this,u).mode==="active-floor"||(i.activeFloor=e));let s=o(this,u).isolateBelowGroundView&&o(this,v)<0;i?.excluded===!1&&!o(this,L).matchesFloorStack(e.floorStack)&&d(this,v,e.elevation);let n=o(this,u).isolateBelowGroundView&&o(this,v)<0,f=s&&!n;if(o(this,l).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(f?(d(this,_,!0),o(this,l).Camera.updateFacadesInView(),o(this,u).autoFocus||(await o(this,B).call(this,e),o(this,O).publish("focus",{facades:this.focusedFacades}))):(await o(this,B).call(this,e),o(this,O).publish("focus",{facades:this.focusedFacades})));let m=i?.floorsAltitudesMap.get(e.elevation)?.altitude??0;o(this,l).options.multiFloorView!=null&&o(this,l).options.multiFloorView?.enabled&&o(this,l).options.multiFloorView?.updateCameraElevationOnFloorChange&&o(this,l).Camera.elevation!==m&&o(this,l).Camera.animateElevation(m,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));c(this,po,a(()=>{d(this,Y,!0)},"#handleUserInteractionStart"));c(this,go,a(()=>{d(this,Y,!1)},"#handleUserInteractionEnd"));c(this,Fo,a(()=>{o(this,B).call(this)},"#handleGlobalStateChange"));c(this,oo,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=it(e,o(this,u).indoorZoomThreshold,o(this,u).outdoorZoomThreshold);o(this,Z)!==i&&(d(this,Z,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor());let s=(o(this,l).Navigation?.floors?.length??0)>0;$o(o(this,R),e,s?{forceOpacity:0}:void 0)},"#handleCameraChange"));c(this,B,a(async t=>{if(o(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).getGlobalState().multiFloorView,s=o(this,l).options.multiFloorView?{...o(this,l).options.multiFloorView,...i}:o(this,l).options.multiFloorView,n=o(this,l).Navigation?.floors?.map(h=>h.id)||[],f=o(this,l).Navigation?.floorStacks.map(h=>h.id)||[],m=new Promise(async h=>{await this.sceneUpdateQueue;let g=nt({buildings:Array.from(o(this,E).values()),inViewSet:o(this,z),currentFloor:e,zoomState:o(this,Z),mode:o(this,u).mode,elevation:o(this,v),floorIdsInNavigation:n,floorStackIdsInNavigation:f,multiFloorView:s,getMultiFloorState:o(this,u).customMultiFloorVisibilityState??Ut,dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,isolateBelowGroundView:o(this,u).isolateBelowGroundView,currentElevation:o(this,v),forceInteriorsVisible:o(this,u).forceInteriorsVisible,getFloorStackAltitudeData:a(V=>o(this,l).getFloorStackAltitudeData(V),"getFloorStackAltitudeData")}),j=[];await Promise.all(Array.from(g.values()).map(async V=>{let{building:q,showIndoor:bo,floorStackState:to,facadeState:yo,inFocus:So,isAboveGroundInIsolation:Bo}=V;j.push(to);let b=at(q,bo);if(b==="indoor")return F(this,p,gt).call(this,q,to,yo,So);if(b==="outdoor")return F(this,p,Ft).call(this,q,to,yo,f,Bo)})),o(this,l).Outdoor.setOpacity(st(j,o(this,u).mode)),d(this,X,o(this,$).filter(V=>g.get(V.id)?.showIndoor===!0).map(V=>V.facade)),o(this,O).publish("focus",{facades:o(this,X)}),h()});return this.sceneUpdateQueue=m,m},"#applyBuildingStates"));d(this,O,new To),d(this,l,t),I.setLevel(W.logState),d(this,G,o(this,l).getMapData()),d(this,v,o(this,l).currentFloor.elevation),d(this,J,o(this,l).Camera.elevation);for(let e of o(this,G).getByType("facade")){let{floorStack:i}=e;if(i.floors.length===0||i.defaultFloor==null){I.warn(`Skipping building for floor stack "${i.id}" because it has no floors. It will not participate in Dynamic Focus.`);continue}o(this,E).set(i.id,new vo(i,o(this,l)))}F(this,p,pt).call(this),d(this,L,new Oo(ct(o(this,G),o(this,E)),o(this,l))),o(this,l).on("floor-change-start",o(this,mo)),o(this,l).on("camera-change",o(this,oo)),o(this,l).on("facades-in-view-change",o(this,fo)),o(this,l).on("user-interaction-start",o(this,po)),o(this,l).on("user-interaction-end",o(this,go)),o(this,l).on("global-state-change",o(this,Fo))}enable(t){if(o(this,N)){I.warn("enable() called on an already enabled Dynamic Focus instance.");return}d(this,N,!0),o(this,l).manualFloorVisibility=!0,o(this,L).show();let e={...o(this,u),...t};e.autoZoomThresholds&&(t?.autoZoomThresholds&&(t.indoorZoomThreshold!=null||t.outdoorZoomThreshold!=null)&&I.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled."),delete e.indoorZoomThreshold,delete e.outdoorZoomThreshold),this.updateState(e),F(this,p,mt).call(this),o(this,oo).call(this,{zoomLevel:o(this,l).Camera.zoomLevel,center:o(this,l).Camera.center,bearing:o(this,l).Camera.bearing,pitch:o(this,l).Camera.pitch}),o(this,l).Camera.updateFacadesInView()}disable(){if(!o(this,N)){I.warn("disable() called on an already disabled Dynamic Focus instance.");return}d(this,N,!1),o(this,l).manualFloorVisibility=!1}get isEnabled(){return o(this,N)}get isIndoor(){return o(this,P)==="indoor"}get isOutdoor(){return o(this,P)==="outdoor"}get outdoorsFloorStack(){return o(this,L).floorStack}get layers(){return o(this,uo)}get layersBySpaceId(){return o(this,co)}setIndoor(){d(this,P,"indoor"),d(this,Z,"in-range"),F(this,p,Yo).call(this)}setOutdoor(){d(this,P,"outdoor"),d(this,Z,"out-of-range"),F(this,p,Yo).call(this)}get focusedFacades(){return[...o(this,X)]}getState(){return{...o(this,u)}}updateState(t){let e=!1,i=o(this,u).indoorZoomThreshold,s=o(this,u).outdoorZoomThreshold,n=o(this,u).isolateBelowGroundView&&o(this,v)<0,f=!!o(this,u).autoZoomThresholds,m=t.autoZoomThresholds!=null?!!t.autoZoomThresholds:f,h=t;if(m&&(h.indoorZoomThreshold!=null||h.outdoorZoomThreshold!=null)){I.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let{indoorZoomThreshold:g,outdoorZoomThreshold:j,...V}=h;h=V}if(!f&&m?(d(this,U,()=>{if(!o(this,N))return;let g=o(this,u).indoorZoomThreshold,j=o(this,u).outdoorZoomThreshold;F(this,p,Wo).call(this),F(this,p,Ho).call(this,g,j),o(this,B).call(this)}),o(this,l).on("camera-screen-offsets-change",o(this,U))):f&&!m&&F(this,p,qo).call(this),h.indoorZoomThreshold!=null&&(h.indoorZoomThreshold=Po(h.indoorZoomThreshold,h?.outdoorZoomThreshold??o(this,u).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),h.outdoorZoomThreshold!=null&&(h.outdoorZoomThreshold=Po(h.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,h?.indoorZoomThreshold??o(this,u).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),h.mode!=null&&(h.mode=ut.includes(h.mode)?h.mode:"default-floor"),h.autoAdjustFacadeHeights!=null&&(o(this,u).autoAdjustFacadeHeights=h.autoAdjustFacadeHeights),h.dynamicBuildingInteriors!=null&&h.dynamicBuildingInteriors!==o(this,u).dynamicBuildingInteriors&&(e=!0),h.isolateBelowGroundView!=null&&h.isolateBelowGroundView!==o(this,u).isolateBelowGroundView&&(e=!0),h.forceInteriorsVisible!=null&&h.forceInteriorsVisible!==o(this,u).forceInteriorsVisible&&(e=!0),h.showLabelsAndMarkersOnAllVisibleFloors!=null&&h.showLabelsAndMarkersOnAllVisibleFloors!==o(this,u).showLabelsAndMarkersOnAllVisibleFloors&&(e=!0),d(this,u,Object.assign({},o(this,u),Object.fromEntries(Object.entries(h).filter(([,g])=>g!=null)))),m&&h.autoZoomThresholds!==void 0&&(F(this,p,Wo).call(this),e=!0),h.mode!=null&&h.preloadFloors&&F(this,p,Ko).call(this,h.mode),e){let g=o(this,u).isolateBelowGroundView&&o(this,v)<0;n&&!g?(d(this,_,!0),o(this,l).Camera.updateFacadesInView(),o(this,u).autoFocus||o(this,B).call(this)):o(this,B).call(this)}F(this,p,Ho).call(this,i,s)}destroy(){this.disable(),F(this,p,qo).call(this),o(this,l).off("facades-in-view-change",o(this,fo)),o(this,l).off("floor-change-start",o(this,mo)),o(this,l).off("camera-change",o(this,oo)),o(this,l).off("user-interaction-start",o(this,po)),o(this,l).off("user-interaction-end",o(this,go)),o(this,l).off("global-state-change",o(this,Fo)),o(this,E).forEach(t=>t.destroy()),o(this,L).destroy(),o(this,O).destroy(),d(this,R,[])}async focus(t=o(this,u).setFloorOnFocus){if(t)if(lt(o(this,J),o(this,l).Camera.elevation,o(this,Y)))d(this,J,o(this,l).Camera.elevation),d(this,_,!0);else{let e=rt(o(this,$),o(this,L),o(this,Z)),i=e?wo(e,o(this,u).mode,o(this,v)):void 0;i&&i.id!==o(this,l).currentFloor.id&&o(this,l).setFloor(i,{context:"dynamic-focus"})}await o(this,B).call(this),o(this,O).publish("focus",{facades:this.focusedFacades})}preloadFloors(){F(this,p,Ko).call(this,o(this,u).mode)}setDefaultFloorForStack(t,e){if(!Go(e,t))return;let i=o(this,E).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,E).get(t.id),i=t.defaultFloor;e&&i&&(e.defaultFloor=i)}getDefaultFloorForStack(t){return o(this,E).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!Go(e,t))return;let i=o(this,E).get(t.id);i&&(i.activeFloor=e,o(this,B).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let s=o(this,E).get(i.id);s&&(s.excluded=!0)}}include(t){let e=Array.isArray(t)?t:[t];for(let i of e){let s=o(this,E).get(i.id);s&&(s.excluded=!1)}}getCurrentFloorForStack(t){return o(this,E).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};O=new WeakMap,l=new WeakMap,G=new WeakMap,u=new WeakMap,$=new WeakMap,z=new WeakMap,E=new WeakMap,L=new WeakMap,Y=new WeakMap,_=new WeakMap,v=new WeakMap,J=new WeakMap,uo=new WeakMap,co=new WeakMap,ho=new WeakMap,Z=new WeakMap,P=new WeakMap,X=new WeakMap,N=new WeakMap,R=new WeakMap,U=new WeakMap,p=new WeakSet,Yo=a(function(){o(this,u).autoFocus&&(o(this,Y)?this.focus():d(this,_,!0)),o(this,O).publish("state-change")},"#handleViewStateChange"),mt=a(function(){d(this,R,[]);for(let e of o(this,u).dynamicLayers){let i=new Io([e],!0,o(this,l));i.processLayerGroup(o(this,ho),()=>o(this,u)),o(this,R).push(i)}let t=(o(this,l).Navigation?.floors?.length??0)>0;$o(o(this,R),o(this,l).Camera.zoomLevel,t?{forceOpacity:0}:void 0)},"#initializeLayerGroups"),qo=a(function(){o(this,U)&&(o(this,l).off("camera-screen-offsets-change",o(this,U)),d(this,U,null))},"#unsubscribeScreenOffsets"),Wo=a(function(){let t=o(this,u).autoZoomThresholds,e=typeof t=="object"&&t!==null?{...t}:{},{indoorZoomThreshold:i,outdoorZoomThreshold:s}=tt(o(this,l),e);o(this,u).indoorZoomThreshold=i,o(this,u).outdoorZoomThreshold=s,(e.expandMinZoom??!0)&&s<o(this,l).Camera.minZoomLevel&&o(this,l).Camera.setMinZoomLevel(s-io)},"#recalcThresholds"),Ho=a(function(t,e){(o(this,u).indoorZoomThreshold!==t||o(this,u).outdoorZoomThreshold!==e)&&o(this,O).publish("zoom-threshold-change",{indoorZoomThreshold:o(this,u).indoorZoomThreshold,outdoorZoomThreshold:o(this,u).outdoorZoomThreshold})},"#publishThresholdChangeIfNeeded"),pt=a(function(){let t=o(this,G).internal.mvf?.enterprise?.layers??[],e={},i={};t.forEach(s=>{e[s.name]||(e[s.name]=[]),e[s.name].push(...s.spaces.map(({spaceId:n})=>n));for(let{spaceId:n}of s.spaces)i[n]==null&&(i[n]=[]),i[n].push(s.name)}),d(this,uo,t.map(({name:s})=>s)),d(this,co,i),d(this,ho,e)},"#setupLayers"),Ko=a(function(t){let e=[];for(let i of o(this,G).getByType("facade")){let s=o(this,E).get(i.floorStack.id);if(!s)continue;let n=wo(s,t,o(this,v));n!=null&&Rt.is(n)&&e.push(n)}o(this,l).preloadFloors(e)},"#preloadFloors"),fo=new WeakMap,mo=new WeakMap,po=new WeakMap,go=new WeakMap,Fo=new WeakMap,oo=new WeakMap,Ao=a(function(t,e,i,s=!1){t.forEach(n=>{if(n.floor)if(e){let m=i!==void 0&&!s?{...n.state,labels:{...n.state.labels,enabled:n.state.labels.enabled&&i},markers:{...n.state.markers,enabled:n.state.markers.enabled&&i},occlusion:{...n.state.occlusion,enabled:n.state.occlusion.enabled&&i}}:n.state;o(this,l).updateState(n.floor,m)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),gt=a(async function(t,e,i,s){return F(this,p,Ao).call(this,e.floorStates,!0,s,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,u).indoorAnimationOptions)},"#animateIndoorSequence"),Ft=a(async function(t,e,i,s,n){let f=n;f&&F(this,p,Ao).call(this,e.floorStates,!1,void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors);let m=await t.animateFacade(i.state,o(this,u).outdoorAnimationOptions);return m.result==="completed"&&!f&&F(this,p,Ao).call(this,e.floorStates,Co({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,Z)==="in-range",inFocus:o(this,z).has(t.id),mode:o(this,u).mode,elevation:o(this,v),inNavigation:s.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,forceInteriorsVisible:o(this,u).forceInteriorsVisible}),void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),m},"#animateOutdoorSequence"),B=new WeakMap,a(Qo,"DynamicFocus");var ft=Qo;export{a,tt as b,ft as c};
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{b as o,c as t}from"./chunk-FYV4DDUI.js";export{t as DynamicFocus,o as calculateZoomThresholds};
1
+ import{b as o,c as t}from"./chunk-LRA64MBX.js";export{t as DynamicFocus,o as calculateZoomThresholds};
@@ -1 +1 @@
1
- import{a as t,c as a}from"../chunk-FYV4DDUI.js";import{useCallback as y,useState as p,useMemo as F}from"react";import{useMap as l,useMapViewExtension as D}from"@mappedin/react-sdk";function d(){let[,n]=p({});return y(()=>n({}),[])}t(d,"useForceUpdate");function i(){let{mapView:n}=l(),r=d(),{register:o}=D("dynamic-focus",{onRegister:t(()=>{let e=new a(n);return e.on("state-change",r),e},"onRegister"),onDeregister:t(e=>{e.off("state-change",r),e.destroy()},"onDeregister")}),s=o();if(!s)throw new Error("DynamicFocus is not initialized");return F(()=>{let e=new WeakMap;return new Proxy(s,{get(u,m){let c=u[m];return typeof c=="function"?(e.has(c)||e.set(c,c.bind(u)),e.get(c)):c}})},[s])}t(i,"useDynamicFocus");import{useCallback as w,useEffect as E,useRef as k}from"react";function x(n,r){let o=i(),s=k(r);s.current=r;let e=w(u=>{s.current(u)},[]);E(()=>{if(o!=null)return o.on(n,e),()=>{o?.off(n,e)}},[o,n,e])}t(x,"useDynamicFocusEvent");export{i as useDynamicFocus,x as useDynamicFocusEvent};
1
+ import{a as t,c as a}from"../chunk-LRA64MBX.js";import{useCallback as y,useState as p,useMemo as F}from"react";import{useMap as l,useMapViewExtension as D}from"@mappedin/react-sdk";function d(){let[,n]=p({});return y(()=>n({}),[])}t(d,"useForceUpdate");function i(){let{mapView:n}=l(),r=d(),{register:o}=D("dynamic-focus",{onRegister:t(()=>{let e=new a(n);return e.on("state-change",r),e},"onRegister"),onDeregister:t(e=>{e.off("state-change",r),e.destroy()},"onDeregister")}),s=o();if(!s)throw new Error("DynamicFocus is not initialized");return F(()=>{let e=new WeakMap;return new Proxy(s,{get(u,m){let c=u[m];return typeof c=="function"?(e.has(c)||e.set(c,c.bind(u)),e.get(c)):c}})},[s])}t(i,"useDynamicFocus");import{useCallback as w,useEffect as E,useRef as k}from"react";function x(n,r){let o=i(),s=k(r);s.current=r;let e=w(u=>{s.current(u)},[]);E(()=>{if(o!=null)return o.on(n,e),()=>{o?.off(n,e)}},[o,n,e])}t(x,"useDynamicFocusEvent");export{i as useDynamicFocus,x as useDynamicFocusEvent};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mappedin/dynamic-focus",
3
- "version": "6.21.0-beta.0",
3
+ "version": "6.21.1-beta.0",
4
4
  "homepage": "https://developer.mappedin.com/",
5
5
  "private": false,
6
6
  "main": "lib/esm/index.js",
@@ -37,9 +37,9 @@
37
37
  "license": "SEE LICENSE IN LICENSE.txt",
38
38
  "peerDependencies": {
39
39
  "react": ">=16.8.0",
40
- "@mappedin/mappedin-js": "^6.21.0",
41
- "@mappedin/react-sdk": "^6.21.0",
42
- "@mappedin/react-native-sdk": "^6.21.0"
40
+ "@mappedin/mappedin-js": "^6.21.1",
41
+ "@mappedin/react-sdk": "^6.21.1",
42
+ "@mappedin/react-native-sdk": "^6.21.1"
43
43
  },
44
44
  "peerDependenciesMeta": {
45
45
  "@mappedin/react-sdk": {