@mappedin/dynamic-focus 6.24.0-beta.0 → 6.24.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 tt=Object.defineProperty;var et=r=>{throw TypeError(r)};var Ot=(r,t,e)=>t in r?tt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t)=>tt(r,"name",{value:t,configurable:!0});var E=(r,t,e)=>Ot(r,typeof t!="symbol"?t+"":t,e),Zo=(r,t,e)=>t.has(r)||et("Cannot "+e);var o=(r,t,e)=>(Zo(r,t,"read from private field"),e?e.call(r):t.get(r)),d=(r,t,e)=>t.has(r)?et("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),c=(r,t,e,i)=>(Zo(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),F=(r,t,e)=>(Zo(r,t,"access private method"),e);var y={env:{NODE_ENV:"production",npm_package_version:"6.24.
|
|
1
|
+
var tt=Object.defineProperty;var et=r=>{throw TypeError(r)};var Ot=(r,t,e)=>t in r?tt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t)=>tt(r,"name",{value:t,configurable:!0});var E=(r,t,e)=>Ot(r,typeof t!="symbol"?t+"":t,e),Zo=(r,t,e)=>t.has(r)||et("Cannot "+e);var o=(r,t,e)=>(Zo(r,t,"read from private field"),e?e.call(r):t.get(r)),d=(r,t,e)=>t.has(r)?et("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),c=(r,t,e,i)=>(Zo(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),F=(r,t,e)=>(Zo(r,t,"access private method"),e);var y={env:{NODE_ENV:"production",npm_package_version:"6.24.1-beta.0"}};var eo={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},cameraLiftAnimationOptions:{duration:500,easing:"ease-in-out",interruptible:!0},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},io=.2,_o=.4;var No="[MappedinJS]";var At={log:0,debug:0,info:1,warn:2,error:3,silent:4};function It(r){return At[r.toLowerCase()]}a(It,"parseLogLevel");function xo(r="",{prefix:t=No}={}){let e=`${t}${r?`-${r}`:""}`,i=a((s,n)=>{if(typeof window<"u"&&window.rnDebug){let f=n.map(p=>p instanceof Error&&p.stack?`${p.message}
|
|
2
2
|
${p.stack}`:p);window.rnDebug(`${r} ${s}: ${f.join(" ")}`)}},"rnDebug");return{logState:y.env.NODE_ENV==="test"?4:1,debug(...s){this.logState<=0&&(console.debug(e,...s),i("debug",s))},log(...s){this.debug(...s)},info(...s){this.logState<=1&&(console.info(e,...s),i("info",s))},warn(...s){this.logState<=2&&(console.warn(e,...s),i("warn",s))},error(...s){this.logState<=3&&(console.error(e,...s),i("error",s))},assert(...s){console.assert(...s)},time(s){console.time(s)},timeEnd(s){console.timeEnd(s)},setLevel(s){let n=typeof s=="string"?It(s):s;if(n===void 0||!(n>=0&&n<=4)){console.warn(e,`setLevel: unknown log level "${s}"`);return}this.logState=n}}}a(xo,"createLogger");var kt=xo();var q=kt;var V=xo("",{prefix:"[DynamicFocus]"});var it=a((r,t={})=>{let e={initialVisibility:t.initialVisibility??"indoor-first",debug:t.debug??!1},i=Bt(r,e);if(i===void 0)return V.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:eo.indoorZoomThreshold,outdoorZoomThreshold:eo.outdoorZoomThreshold};let s=i+_o,n=i+io;return e.initialVisibility==="indoor-first"&&(s=i-io,n=i-_o),{indoorZoomThreshold:s,outdoorZoomThreshold:n}},"calculateZoomThresholds");function Bt(r,t){let i=r.getMapData().getByType("floor-stack").filter(f=>f.type!=="Outdoor"),s=1/0,n;for(let f of i){let p=r.Camera.getFocusOnTransform(f).zoomLevel??1/0;p<s&&(s=p,n=f)}if(s!==1/0)return t.debug&&n&&r.Camera.getFocusOnTransform(n,{debugColor:"blue"}),s}a(Bt,"getDefaultZoomLevel");import{Floor as Yt,getMultiFloorState as Wt}from"@mappedin/mappedin-js";function st(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(st,"arraysEqual");var Co=class Co{_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(Co,"PubSub");var Eo=Co;import{Facade as Dt,Floor as Lt,FloorStack as Mt}from"@mappedin/mappedin-js";var I,so,C,w,v,B,H,K,Go=class Go{constructor(t,e){E(this,"__type","building");d(this,I);d(this,so,new Map);d(this,C,new Map);d(this,w,[]);d(this,v);d(this,B);E(this,"defaultFloor");E(this,"activeFloor");E(this,"excluded",!1);E(this,"aboveGroundFloors",[]);d(this,H);d(this,K);c(this,I,t),c(this,so,new Map(t.floors.map(s=>[s.id,s]))),c(this,C,new Map(t.floors.map(s=>[s.elevation,s]))),c(this,w,Array.from(o(this,C).values()).sort((s,n)=>s.elevation-n.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,c(this,v,e),this.aboveGroundFloors=o(this,w).filter(s=>s.elevation>=0)}get id(){return o(this,I).id}get name(){return o(this,I).name}get floors(){return o(this,I).floors}get floorStack(){return o(this,I)}get facade(){return o(this,I).facade}get isCurrentFloorStack(){return this.id===o(this,v).currentFloorStack.id}get isIndoor(){let t=o(this,v).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&&c(this,H,Math.max(...o(this,C).keys())),o(this,H)}get minElevation(){return o(this,K)==null&&c(this,K,Math.min(...o(this,C).keys())),o(this,K)}has(t){return Lt.is(t)?o(this,so).has(t.id):Mt.is(t)?t.id===o(this,I).id:Dt.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,B)&&(o(this,B).animation.cancel(),c(this,B,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,B)?.state||o(this,v).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,v).updateState(this.facade,{visible:!0}),s!==void 0){c(this,B,{animation:o(this,v).animateState(this.facade,{opacity:s},{duration:e.duration}),state:t});let f=await o(this,B).animation;if(c(this,B,void 0),f.result==="cancelled")return f}return n===!1&&o(this,v).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,I).floors.forEach(t=>{o(this,v).updateState(t,{visible:t.id===o(this,v).currentFloor.id})}),this.has(o(this,v).currentFloor)||o(this,v).updateState(this.facade,{visible:!0,opacity:1})}};I=new WeakMap,so=new WeakMap,C=new WeakMap,w=new WeakMap,v=new WeakMap,B=new WeakMap,H=new WeakMap,K=new WeakMap,a(Go,"Building");var To=Go;function rt(r,t,e){return r>=t?"in-range":r<=e?"out-of-range":"transition"}a(rt,"getZoomState");function vo(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(vo,"getFloorToShow");function Zt(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(Zt,"getFacadeState");function _t(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(_t,"getSingleBuildingState");function nt(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(nt,"getOutdoorOpacity");function at(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(at,"getSetFloorTargetFromZoomState");function lt(r){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:s,mode:n,elevation:f,floorIdsInNavigation:p,floorStackIdsInNavigation:h,multiFloorView:g,getMultiFloorState:$,dynamicBuildingInteriors:A,isolateBelowGroundView:W,currentElevation:Fo,forceInteriorsVisible:to,getFloorStackAltitudeData:bo}=r,yo=new Map,Do=W&&Fo<0&&s==="in-range";for(let b of t){let ot=e.has(b.id),So=Do&&b.minElevation>=0,Et=So?!1:ot,Lo=So?!1:Ro({building:b,currentFloor:i,inRange:s==="in-range",inFocus:ot,mode:n,elevation:f,inNavigation:h.includes(b.id),dynamicBuildingInteriors:A,forceInteriorsVisible:to}),Mo=i.floorStack.id===b.id?b.activeFloor:vo(b,n,f),Tt=g?.enabled?$(b.floors,Mo||b.activeFloor,p,bo(b.id),{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}):_t(b.floorStack,Mo||b.activeFloor,Lo),vt=W&&Fo<0&&s==="in-range",wt=Zt(b.facade,Lo,vt,So);yo.set(b.id,{building:b,showIndoor:Lo,floorStackState:Tt,facadeState:wt,inFocus:Et,floorToShow:Mo,isAboveGroundInIsolation:So})}return yo}a(lt,"getBuildingStates");function ut(r,t){return r.excluded?"none":t?"indoor":"outdoor"}a(ut,"getBuildingAnimationType");function Ro(r){let{building:t,currentFloor:e,inRange:i,inFocus:s,mode:n,elevation:f,inNavigation:p,dynamicBuildingInteriors:h,forceInteriorsVisible:g}=r;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(g===!0||p===!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(Ro,"shouldShowIndoor");function dt(r,t,e){return r!==t&&!e}a(dt,"shouldDeferSetFloor");var ct=["default-floor","active-floor","lock-elevation","nearest-elevation"];import{Floor as Nt,FloorStack as xt}from"@mappedin/mappedin-js";function ht(r,t,e,i){return(r<t||r>e)&&q.warn(i),Math.min(e,Math.max(t,r))}a(ht,"clampWithWarning");function Po(r,t){return!Nt.is(r)||r?.floorStack==null||!xt.is(t)?!1:r.floorStack.id!==t.id?(q.warn(`Floor (${r.id}) does not belong to floor stack (${t.id}).`),!1):!0}a(Po,"validateFloorForStack");function Uo(r,t,e,i){return ht(r,t,e,`${i} must be between ${t} and ${e}.`)}a(Uo,"validateZoomThreshold");var D,Q,ro,$o,jo=class jo{constructor(t,e){d(this,ro);E(this,"__type","outdoors");d(this,D);d(this,Q);c(this,D,t),c(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,$o).call(this,!0)}hide(){F(this,ro,$o).call(this,!1)}destroy(){this.matchesFloorStack(o(this,Q).currentFloorStack)||this.hide()}};D=new WeakMap,Q=new WeakMap,ro=new WeakSet,$o=a(function(t){for(let e of o(this,D).floors)o(this,Q).updateState(e,{visible:t})},"#setVisible"),a(jo,"Outdoors");var wo=jo;function ft(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||(V.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(ft,"getOutdoorFloorStack");function Ct(r,t){return`${t} ${r}`}a(Ct,"formatMessage");var zo=class zo extends Error{constructor(t,e=No){super(Ct(t,e)),this.name="MappedinError"}};a(zo,"MappedinError");var Oo=zo;var Gt=a(r=>r,"linearEase"),Rt=a(r=>r*r,"quadEaseIn"),Pt=a(r=>1-Math.cos(r*Math.PI/2),"easeIn"),Ut=a(r=>1-(1-r)*(1-r),"quadEaseOut"),$t=a(r=>1-Math.pow(1-r,3),"cubicEaseOut"),jt={linear:Gt,"ease-in":Rt,"ease-out":Ut,"ease-in-out":Pt,"ease-out-cubic":$t};function zt(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(zt,"getInterpolationBreakpoint");function mt(r,t,e,i="ease-in"){if(t.length!==e.length)throw new Oo("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=zt(r,t),n=(r-t[s])/(t[s+1]-t[s]),f=typeof i=="function"?i(n):jt[i](n);return e[s]+f*(e[s+1]-e[s])}a(mt,"interpolateMulti");var L,no,ao,Z,lo,Wo=class Wo{constructor(t,e,i){E(this,"layers");E(this,"visible");d(this,L);d(this,no,[]);d(this,ao,!1);d(this,Z,new Map);E(this,"interpolationFn");d(this,lo,1);this.layers=t,this.visible=e,c(this,L,i)}processLayerGroup(t,e){o(this,ao)||(this.layers.forEach(i=>{let s=t[i];s&&o(this,no).push(...s)}),c(this,ao,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:s,indoorZoomThreshold:n}=e();return mt(i,[s,n],[1,0])}))}setOpacity(t){c(this,lo,t);for(let e of o(this,no))if(e.startsWith("img_")){let i=o(this,L).Image3D.getById(e);if(i){let s=o(this,L).getState(i.image);o(this,Z).has(e)||o(this,Z).set(e,s?.opacity??1);let n=Math.min(o(this,Z).get(e),t);o(this,L).updateState(i.image,{opacity:n})}}else{let i=o(this,L).getMapData()?.getById("space",e);if(!i)continue;let s=o(this,L).getState(i);o(this,Z).has(e)||o(this,Z).set(e,s?.opacity??1);let n=Math.min(o(this,Z).get(e),t);o(this,L).updateState(i,{opacity:n,visible:n>0})}}get opacity(){return o(this,lo)}};L=new WeakMap,no=new WeakMap,ao=new WeakMap,Z=new WeakMap,lo=new WeakMap,a(Wo,"LayerGroup");var Vo=Wo;function Yo(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(Yo,"runLayerGroupInterpolations");var O,l,G,u,j,z,S,_,Y,N,T,J,uo,co,ho,M,R,X,x,P,U,m,qo,gt,Ho,Ko,Qo,Ft,Jo,fo,bt,Io,ko,Bo,mo,po,go,oo,Ao,yt,St,k,Xo=class Xo{constructor(t){d(this,m);d(this,O);d(this,l);d(this,G);d(this,u,eo);d(this,j,[]);d(this,z,new Set);d(this,S,new Map);d(this,_);d(this,Y,!1);d(this,N,!1);d(this,T,0);d(this,J,0);d(this,uo,[]);d(this,co,{});d(this,ho,{});d(this,M,"transition");d(this,R,"outdoor");d(this,X,[]);d(this,x,!1);d(this,P,[]);d(this,U,null);E(this,"sceneUpdateQueue",Promise.resolve());E(this,"on",a((t,e)=>{o(this,O).on(t,e)},"on"));E(this,"off",a((t,e)=>{o(this,O).off(t,e)},"off"));d(this,fo,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(st(e,this.focusedFacades)&&o(this,R)==="transition"&&!o(this,N))return;c(this,N,!1),c(this,j,[]),o(this,z).clear();let i=o(this,u).isolateBelowGroundView&&o(this,T)<0;if(e.length>0)for(let s of e){let n=o(this,S).get(s.floorStack.id);if(n){if(i&&n.minElevation>=0)continue;o(this,z).add(n.id),o(this,j).push(n)}}o(this,u).autoFocus&&this.focus()},"#handleFacadesInViewChange"));d(this,Io,a((t,e)=>{if(!this.isEnabled)return;let i=o(this,S).get(t.floorStack.id);i&&(e.reason==="dynamic-focus"&&o(this,u).mode==="active-floor"||(i.activeFloor=t));let s=o(this,u).isolateBelowGroundView&&o(this,T)<0;i?.excluded===!1&&!o(this,_).matchesFloorStack(t.floorStack)&&c(this,T,t.elevation);let n=o(this,u).isolateBelowGroundView&&o(this,T)<0,f=s&&!n;if(e.reason==="dynamic-focus")return;let p=F(this,m,bt).call(this),h=o(this,ko).call(this,t,e,f,p);if(p)return h;h.catch(g=>{V.error("setFloor override work failed after sync floor-change commit",g)})},"#setFloorHandler"));d(this,ko,a(async(t,e,i,s)=>{if(i){if(c(this,N,!0),o(this,l).Camera.updateFacadesInView(),!o(this,u).autoFocus){if(await o(this,k).call(this,t),!this.isEnabled||e.signal.aborted)return;o(this,O).publish("focus",{facades:this.focusedFacades})}}else{if(await o(this,k).call(this,t),!this.isEnabled||e.signal.aborted)return;o(this,O).publish("focus",{facades:this.focusedFacades})}s&&this.isEnabled&&!e.signal.aborted&&await o(this,Bo).call(this,t)},"#runFloorChangeWork"));d(this,Bo,a(t=>{let e=o(this,l).getFloorStackAltitudeData(t.floorStack).get(t.elevation)?.altitude;if(typeof e=="number"&&o(this,l).Camera.elevation!==e)return o(this,l).Camera.animateElevation(e,o(this,u).cameraLiftAnimationOptions)},"#liftCameraToFloorAltitude"));d(this,mo,a(()=>{c(this,Y,!0)},"#handleUserInteractionStart"));d(this,po,a(()=>{c(this,Y,!1)},"#handleUserInteractionEnd"));d(this,go,a(()=>{o(this,k).call(this)},"#handleGlobalStateChange"));d(this,oo,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=rt(e,o(this,u).indoorZoomThreshold,o(this,u).outdoorZoomThreshold);o(this,M)!==i&&(c(this,M,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor());let s=(o(this,l).Navigation?.floors?.length??0)>0;Yo(o(this,P),e,s?{forceOpacity:0}:void 0)},"#handleCameraChange"));d(this,k,a(async t=>{if(!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)||[],p=new Promise(async h=>{await this.sceneUpdateQueue;let g=lt({buildings:Array.from(o(this,S).values()),inViewSet:o(this,z),currentFloor:e,zoomState:o(this,M),mode:o(this,u).mode,elevation:o(this,T),floorIdsInNavigation:n,floorStackIdsInNavigation:f,multiFloorView:s,getMultiFloorState:o(this,u).customMultiFloorVisibilityState??Wt,dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,isolateBelowGroundView:o(this,u).isolateBelowGroundView,currentElevation:o(this,T),forceInteriorsVisible:o(this,u).forceInteriorsVisible,getFloorStackAltitudeData:a(A=>o(this,l).getFloorStackAltitudeData(A),"getFloorStackAltitudeData")}),$=[];await Promise.all(Array.from(g.values()).map(async A=>{let{building:W,showIndoor:Fo,floorStackState:to,facadeState:bo,inFocus:yo,isAboveGroundInIsolation:Do}=A;$.push(to);let b=ut(W,Fo);if(b==="indoor")return F(this,m,yt).call(this,W,to,bo,yo);if(b==="outdoor")return F(this,m,St).call(this,W,to,bo,f,Do)})),o(this,l).Outdoor.setOpacity(nt($,o(this,u).mode)),c(this,X,o(this,j).filter(A=>g.get(A.id)?.showIndoor===!0).map(A=>A.facade)),o(this,O).publish("focus",{facades:o(this,X)}),h()});return this.sceneUpdateQueue=p,p},"#applyBuildingStates"));c(this,O,new Eo),c(this,l,t),V.setLevel(q.logState),c(this,G,o(this,l).getMapData()),c(this,T,o(this,l).currentFloor.elevation),c(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){V.warn(`Skipping building for floor stack "${i.id}" because it has no floors. It will not participate in Dynamic Focus.`);continue}o(this,S).set(i.id,new To(i,o(this,l)))}F(this,m,Ft).call(this),c(this,_,new wo(ft(o(this,G),o(this,S)),o(this,l))),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,mo)),o(this,l).on("user-interaction-end",o(this,po)),o(this,l).on("global-state-change",o(this,go))}enable(t){if(o(this,x)){V.warn("enable() called on an already enabled Dynamic Focus instance.");return}c(this,x,!0),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(o(this,Io)),o(this,_).show();let e={...o(this,u),...t};e.autoZoomThresholds&&(t?.autoZoomThresholds&&(t.indoorZoomThreshold!=null||t.outdoorZoomThreshold!=null)&&V.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled."),delete e.indoorZoomThreshold,delete e.outdoorZoomThreshold),this.updateState(e),F(this,m,gt).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,x)){V.warn("disable() called on an already disabled Dynamic Focus instance.");return}c(this,x,!1),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(void 0)}get isEnabled(){return o(this,x)}get isIndoor(){return o(this,R)==="indoor"}get isOutdoor(){return o(this,R)==="outdoor"}get outdoorsFloorStack(){return o(this,_).floorStack}get layers(){return o(this,uo)}get layersBySpaceId(){return o(this,co)}setIndoor(){c(this,R,"indoor"),c(this,M,"in-range"),F(this,m,qo).call(this)}setOutdoor(){c(this,R,"outdoor"),c(this,M,"out-of-range"),F(this,m,qo).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,T)<0,f=!!o(this,u).autoZoomThresholds,p=t.autoZoomThresholds!=null?!!t.autoZoomThresholds:f,h=t;if(p&&(h.indoorZoomThreshold!=null||h.outdoorZoomThreshold!=null)){V.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let{indoorZoomThreshold:g,outdoorZoomThreshold:$,...A}=h;h=A}if(!f&&p?(c(this,U,()=>{if(!o(this,x))return;let g=o(this,u).indoorZoomThreshold,$=o(this,u).outdoorZoomThreshold;F(this,m,Ko).call(this),F(this,m,Qo).call(this,g,$),o(this,k).call(this)}),o(this,l).on("camera-screen-offsets-change",o(this,U))):f&&!p&&F(this,m,Ho).call(this),h.indoorZoomThreshold!=null&&(h.indoorZoomThreshold=Uo(h.indoorZoomThreshold,h?.outdoorZoomThreshold??o(this,u).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),h.outdoorZoomThreshold!=null&&(h.outdoorZoomThreshold=Uo(h.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,h?.indoorZoomThreshold??o(this,u).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),h.mode!=null&&(h.mode=ct.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),h.cameraLiftAnimationOptions!=null&&(h={...h,cameraLiftAnimationOptions:{...o(this,u).cameraLiftAnimationOptions,...h.cameraLiftAnimationOptions}}),c(this,u,Object.assign({},o(this,u),Object.fromEntries(Object.entries(h).filter(([,g])=>g!=null)))),p&&h.autoZoomThresholds!==void 0&&(F(this,m,Ko).call(this),e=!0),h.mode!=null&&h.preloadFloors&&F(this,m,Jo).call(this,h.mode),e){let g=o(this,u).isolateBelowGroundView&&o(this,T)<0;n&&!g?(c(this,N,!0),o(this,l).Camera.updateFacadesInView(),o(this,u).autoFocus||o(this,k).call(this)):o(this,k).call(this)}F(this,m,Qo).call(this,i,s)}destroy(){this.disable(),F(this,m,Ho).call(this),o(this,l).off("facades-in-view-change",o(this,fo)),o(this,l).off("camera-change",o(this,oo)),o(this,l).off("user-interaction-start",o(this,mo)),o(this,l).off("user-interaction-end",o(this,po)),o(this,l).off("global-state-change",o(this,go)),o(this,S).forEach(t=>t.destroy()),o(this,_).destroy(),o(this,O).destroy(),c(this,P,[])}async focus(t=o(this,u).setFloorOnFocus){let e;if(t)if(dt(o(this,J),o(this,l).Camera.elevation,o(this,Y)))c(this,J,o(this,l).Camera.elevation),c(this,N,!0);else{let i=at(o(this,j),o(this,_),o(this,M)),s=i?vo(i,o(this,u).mode,o(this,T)):void 0;s&&s.id!==o(this,l).currentFloor.id&&(e=s,o(this,l).setFloor(s,{context:"dynamic-focus"}))}await o(this,k).call(this,e),o(this,O).publish("focus",{facades:this.focusedFacades})}preloadFloors(){F(this,m,Jo).call(this,o(this,u).mode)}setDefaultFloorForStack(t,e){if(!Po(e,t))return;let i=o(this,S).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,S).get(t.id),i=t.defaultFloor;e&&i&&(e.defaultFloor=i)}getDefaultFloorForStack(t){return o(this,S).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!Po(e,t))return;let i=o(this,S).get(t.id);i&&(i.activeFloor=e,o(this,k).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let s=o(this,S).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,S).get(i.id);s&&(s.excluded=!1)}}getCurrentFloorForStack(t){return o(this,S).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};O=new WeakMap,l=new WeakMap,G=new WeakMap,u=new WeakMap,j=new WeakMap,z=new WeakMap,S=new WeakMap,_=new WeakMap,Y=new WeakMap,N=new WeakMap,T=new WeakMap,J=new WeakMap,uo=new WeakMap,co=new WeakMap,ho=new WeakMap,M=new WeakMap,R=new WeakMap,X=new WeakMap,x=new WeakMap,P=new WeakMap,U=new WeakMap,m=new WeakSet,qo=a(function(){o(this,u).autoFocus&&(o(this,Y)?this.focus():c(this,N,!0)),o(this,O).publish("state-change")},"#handleViewStateChange"),gt=a(function(){c(this,P,[]);for(let e of o(this,u).dynamicLayers){let i=new Vo([e],!0,o(this,l));i.processLayerGroup(o(this,ho),()=>o(this,u)),o(this,P).push(i)}let t=(o(this,l).Navigation?.floors?.length??0)>0;Yo(o(this,P),o(this,l).Camera.zoomLevel,t?{forceOpacity:0}:void 0)},"#initializeLayerGroups"),Ho=a(function(){o(this,U)&&(o(this,l).off("camera-screen-offsets-change",o(this,U)),c(this,U,null))},"#unsubscribeScreenOffsets"),Ko=a(function(){let t=o(this,u).autoZoomThresholds,e=typeof t=="object"&&t!==null?{...t}:{},{indoorZoomThreshold:i,outdoorZoomThreshold:s}=it(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"),Qo=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"),Ft=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)}),c(this,uo,t.map(({name:s})=>s)),c(this,co,i),c(this,ho,e)},"#setupLayers"),Jo=a(function(t){let e=[];for(let i of o(this,G).getByType("facade")){let s=o(this,S).get(i.floorStack.id);if(!s)continue;let n=vo(s,t,o(this,T));n!=null&&Yt.is(n)&&e.push(n)}o(this,l).preloadFloors(e)},"#preloadFloors"),fo=new WeakMap,bt=a(function(){let{multiFloorView:t}=o(this,l).options;return!!t?.enabled&&!!t?.updateCameraElevationOnFloorChange},"#shouldAwaitFloorChangeCommit"),Io=new WeakMap,ko=new WeakMap,Bo=new WeakMap,mo=new WeakMap,po=new WeakMap,go=new WeakMap,oo=new WeakMap,Ao=a(function(t,e,i,s=!1){t.forEach(n=>{if(n.floor)if(e){let p=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,p)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),yt=a(async function(t,e,i,s){return F(this,m,Ao).call(this,e.floorStates,!0,s,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,u).indoorAnimationOptions)},"#animateIndoorSequence"),St=a(async function(t,e,i,s,n){let f=n;f&&F(this,m,Ao).call(this,e.floorStates,!1,void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors);let p=await t.animateFacade(i.state,o(this,u).outdoorAnimationOptions);return p.result==="completed"&&!f&&F(this,m,Ao).call(this,e.floorStates,Ro({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,M)==="in-range",inFocus:o(this,z).has(t.id),mode:o(this,u).mode,elevation:o(this,T),inNavigation:s.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,forceInteriorsVisible:o(this,u).forceInteriorsVisible}),void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),p},"#animateOutdoorSequence"),k=new WeakMap,a(Xo,"DynamicFocus");var pt=Xo;export{a,it as b,pt as c};
|
package/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as o,c as t}from"./chunk-
|
|
1
|
+
import{b as o,c as t}from"./chunk-RDXJZTZT.js";export{t as DynamicFocus,o as calculateZoomThresholds};
|
package/lib/esm/react/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t,c as a}from"../chunk-
|
|
1
|
+
import{a as t,c as a}from"../chunk-RDXJZTZT.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.24.
|
|
3
|
+
"version": "6.24.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/
|
|
41
|
-
"@mappedin/
|
|
42
|
-
"@mappedin/react-sdk": "^6.24.
|
|
40
|
+
"@mappedin/mappedin-js": "^6.24.1",
|
|
41
|
+
"@mappedin/react-sdk": "^6.24.1",
|
|
42
|
+
"@mappedin/react-native-sdk": "^6.24.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"@mappedin/react-sdk": {
|