@expofp/floorplan 3.7.17 → 3.9.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.
- package/dist/browser/{Button-CalAncSt.js → Button-D6kSs8oT.js} +5 -5
- package/dist/browser/{CookieConsent-ZygvYtDb.js → CookieConsent-COR-7PnR.js} +7 -7
- package/dist/browser/{Debug-D0iAX94G.js → Debug-hcVDK_6B.js} +7 -7
- package/dist/browser/{Demo-DtZnCrNU.js → Demo-CXfqKcNa.js} +9 -9
- package/dist/browser/{Free-CY2ZgfTi.js → Free-UltUjcsW.js} +9 -9
- package/dist/browser/{Gallery-BJyU80Q8.js → Gallery-Dw_l4-HJ.js} +9 -9
- package/dist/browser/{GpsLoader-C4Az3Ogj.js → GpsLoader-BeUr-tWe.js} +36 -36
- package/dist/browser/{KioskStore-D3xv5iMJ.js → KioskStore-rXGF6ISj.js} +67 -67
- package/dist/browser/{MaplibreAdapter-BI5hr4DA.js → MaplibreAdapter-DBu4xFLx.js} +941 -960
- package/dist/browser/{ModalContainer-CGy7G3W-.js → ModalContainer-CHubcxXg.js} +10 -10
- package/dist/browser/{PermissionNotice-BQl-Eh0U.js → PermissionNotice-Dcyf-h-X.js} +6 -6
- package/dist/browser/{SetKioskMode-puXODfKF.js → SetKioskMode-Dsaeb_7s.js} +11 -11
- package/dist/browser/ShowKiosk-B33TvvNh.js +28 -0
- package/dist/browser/{TouchHand-DjRl3mqw.js → TouchHand-BglJHdqZ.js} +4 -4
- package/dist/browser/{ViewerMenuPanel-DwpOTh1A.js → ViewerMenuPanel-6hwMrGsD.js} +10 -10
- package/dist/browser/{add-debug-secret-listener-0zbOfR23.js → add-debug-secret-listener-CrjDiiDe.js} +1 -1
- package/dist/browser/{boolean-editor-Ct-PRF2J.js → boolean-editor-B8TY5r_7.js} +9 -9
- package/dist/browser/{bootIntercom-CNJJMQLU.js → bootIntercom-BLVUFUo9.js} +2 -2
- package/dist/browser/{browser-Dvk9Y0QP.js → browser-C0ZAqhfq.js} +2 -2
- package/dist/browser/bundle.json +61 -61
- package/dist/browser/{classnames-N7RelmSW.js → classnames-CORO_J9N.js} +2 -2
- package/dist/browser/{client-B3oB_gzf.js → client-B8k3_zlK.js} +4 -4
- package/dist/browser/{components-DCWqd4OH.js → components-Br23UmiD.js} +1857 -1861
- package/dist/browser/{createWayfinding-DCYv9I1K.js → createWayfinding-CywBuuhE.js} +552 -533
- package/dist/browser/{debug-overlay-C1zmn9JP.js → debug-overlay-OnJ9mpi3.js} +10 -10
- package/dist/browser/{debug-ui-Dk4TQW1Q.js → debug-ui-BGxXBqCM.js} +6 -6
- package/dist/browser/{dist-CZ9F3ShM.js → dist-Bwo0bena.js} +5 -5
- package/dist/browser/{dist-Dhhxwn3m.js → dist-DJcDQ9wl.js} +3 -3
- package/dist/browser/{dist-BjWXGdvS.js → dist-DeenbCqa.js} +6 -6
- package/dist/browser/{efp-debug-init-BY441NPw.js → efp-debug-init-D4xpSVxZ.js} +2 -2
- package/dist/browser/{enum-editor-wsFvRjdm.js → enum-editor-BtQ7q_B6.js} +11 -11
- package/dist/browser/{es5--a3vRB-s.js → es5-DyYwMIHo.js} +2 -2
- package/dist/browser/{event-not-found-C08dNiXm.js → event-not-found-DHZml9YG.js} +1 -1
- package/dist/browser/{exports-DnnAyWkZ.js → exports-BSvGPafo.js} +1 -1
- package/dist/browser/{favicon-BUBgyUNE.js → favicon-7eGefoDS.js} +1 -1
- package/dist/browser/{fetch-retry.umd-DqWbcFb6.js → fetch-retry.umd-D4q_0lN2.js} +2 -2
- package/dist/browser/{flex-BJvbUFUw.js → flex-BNMB3s0s.js} +5 -5
- package/dist/browser/{floorplan.loader-DtRqhN7h.js → floorplan.loader-C464BfTl.js} +45 -45
- package/dist/browser/{floorplan.ready-DU_ul7oy.js → floorplan.ready-F-rEW40x.js} +309 -233
- package/dist/browser/{fuse-C1gHDLf6.js → fuse-BOOzXNLy.js} +2 -2
- package/dist/browser/{i18n-GqZrkrT3.js → i18n-CJxFIIru.js} +9 -9
- package/dist/browser/index.js +12 -12
- package/dist/browser/{index.module-ClFPQstA.js → index.module-CkT4oOvs.js} +26 -26
- package/dist/browser/{is-webview-Ubd69hDX.js → is-webview-B86RAuQv.js} +1 -1
- package/dist/browser/{jsx-runtime-CcqjcKRn.js → jsx-runtime-3_7049j-.js} +2 -2
- package/dist/browser/{lib-D-VhTz7u.js → lib-CjZn5G8Q.js} +4 -4
- package/dist/browser/{loadImage-BSgOJpEi.js → loadImage-CV72jhce.js} +5 -5
- package/dist/browser/locales/ar.json +4 -1
- package/dist/browser/locales/da.json +4 -1
- package/dist/browser/locales/de.json +4 -1
- package/dist/browser/locales/es.json +4 -1
- package/dist/browser/locales/fr.json +4 -1
- package/dist/browser/locales/he.json +4 -1
- package/dist/browser/locales/it.json +4 -1
- package/dist/browser/locales/kk.json +4 -1
- package/dist/browser/locales/ko.json +4 -1
- package/dist/browser/locales/mn.json +4 -1
- package/dist/browser/locales/nl.json +4 -1
- package/dist/browser/locales/pl.json +4 -1
- package/dist/browser/locales/pt.json +4 -1
- package/dist/browser/locales/ru.json +4 -1
- package/dist/browser/locales/sv.json +4 -1
- package/dist/browser/locales/th.json +4 -1
- package/dist/browser/locales/tr.json +4 -1
- package/dist/browser/locales/uk.json +4 -1
- package/dist/browser/locales/vi.json +4 -1
- package/dist/browser/locales/zh.json +4 -1
- package/dist/browser/{logDeviceInfo-CqPbQalh.js → logDeviceInfo-CH_mwixN.js} +9 -9
- package/dist/browser/{main-D02oALU5.js → main-DBcClnTP.js} +1 -1
- package/dist/browser/{mobx-9haaaJQN.js → mobx-Cnc_mxKS.js} +8 -8
- package/dist/browser/{particles.min-Cy0_xv2F.js → particles.min-Bdddyoyn.js} +2 -2
- package/dist/browser/{prop-types-CGmwvRRk.js → prop-types-D9saedjy.js} +2 -2
- package/dist/browser/{react-C94g1dWf.js → react-CtAjLpE4.js} +2 -2
- package/dist/browser/{react-dom-VzzznUin.js → react-dom-9Z9grXEI.js} +3 -3
- package/dist/browser/{reset-all-settings-Bs45R4UK.js → reset-all-settings-D2rGLtD9.js} +7 -7
- package/dist/browser/{rolldown-runtime-DDajFMnr.js → rolldown-runtime-6HCGHF5o.js} +1 -1
- package/dist/browser/{settings-item-CTgteXDw.js → settings-item-CmuDoi0N.js} +6 -6
- package/dist/browser/{settings-B89NEO7Z.js → settings-r2jCygEX.js} +2 -2
- package/dist/browser/{store-39MLQcdz.js → store-hsXE5nII.js} +6753 -6669
- package/dist/browser/{string-editor-4uawnaDY.js → string-editor-UncyEsWj.js} +7 -7
- package/dist/browser/{theme-CWzone56.js → theme-DmuulesT.js} +8 -8
- package/dist/browser/{ui-D8Gz1TVh.js → ui-CBeseOX-.js} +8 -8
- package/dist/browser/{useRenderTarget-BSjQ_3rd.js → useRenderTarget-C5lcypnV.js} +4 -4
- package/dist/esm/components/LevelSelector.js +1 -1
- package/dist/esm/components/Map/Map.js +1 -1
- package/dist/esm/components/Map/booth-by-xy.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-booth-badge.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-booth-bg.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-booth-bookmark.d.ts +1 -1
- package/dist/esm/components/Map/drawing/config/config-booth-bookmark.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-booth-border.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-booth-labels-special.d.ts +1 -2
- package/dist/esm/components/Map/drawing/config/config-booth-labels-special.js +2 -2
- package/dist/esm/components/Map/drawing/config/config-booth-labels.d.ts +4 -4
- package/dist/esm/components/Map/drawing/config/config-booth-labels.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-booths.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-load-layer.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-markers.js +1 -1
- package/dist/esm/components/Map/drawing/config/loadBoothsImages.d.ts +10 -4
- package/dist/esm/components/Map/drawing/config/loadBoothsImages.js +1 -1
- package/dist/esm/components/Map/traffic/useBuildRoute.js +5 -5
- package/dist/esm/components/Map/traffic/useManageTraffic.js +1 -1
- package/dist/esm/components/Maplibre/MaplibreAdapter.js +1 -1
- package/dist/esm/components/Maplibre/useCameraReactions.d.ts +2 -2
- package/dist/esm/components/Maplibre/useCameraReactions.js +1 -1
- package/dist/esm/components/Maplibre/useLayerVisibilitySync.d.ts +2 -2
- package/dist/esm/components/Maplibre/useLayerVisibilitySync.js +1 -1
- package/dist/esm/components/Maplibre/utils/geo-config.d.ts +6 -6
- package/dist/esm/components/Maplibre/utils/geo-config.js +1 -1
- package/dist/esm/components/Maplibre/utils/solver.js +1 -1
- package/dist/esm/components/gps/useUserLocationAndHeading.d.ts +1 -1
- package/dist/esm/components/gps/useUserLocationAndHeading.js +1 -1
- package/dist/esm/components/gps/utils.d.ts +1 -1
- package/dist/esm/components/gps/utils.js +1 -1
- package/dist/esm/data/svg.d.ts +4 -4
- package/dist/esm/data/svg.js +1 -1
- package/dist/esm/floorplan.ready.d.ts +39 -2
- package/dist/esm/floorplan.ready.js +1 -1
- package/dist/esm/renderer/engine-core/canvases.d.ts +1 -1
- package/dist/esm/renderer/engine-core/canvases.js +1 -1
- package/dist/esm/renderer/engine-core/defs.d.ts +23 -4
- package/dist/esm/renderer/engine-core/defs.js +3 -3
- package/dist/esm/renderer/engine-core/types.d.ts +13 -2
- package/dist/esm/renderer/engine-core/update-def.d.ts +3 -2
- package/dist/esm/renderer/engine-core/update-def.js +1 -1
- package/dist/esm/renderer/engine-core/utils/rotation.d.ts +13 -1
- package/dist/esm/renderer/index.d.ts +2 -2
- package/dist/esm/renderer/index.js +1 -1
- package/dist/esm/services/routing.js +1 -1
- package/dist/esm/store/BoothStore.d.ts +14 -2
- package/dist/esm/store/BoothStore.js +1 -1
- package/dist/esm/store/LayerStore.d.ts +4 -4
- package/dist/esm/store/LayerStore.js +1 -1
- package/dist/esm/store/RouteStore.d.ts +3 -3
- package/dist/esm/store/RouteStore.js +1 -1
- package/dist/esm/store/UIState.d.ts +6 -7
- package/dist/esm/store/UIState.js +1 -1
- package/dist/esm/store/init/init-booths.js +1 -1
- package/dist/esm/store/init/init-layers.js +1 -1
- package/dist/esm/store/init/init-ui.js +1 -1
- package/dist/esm/store/search-buttons/SearchButtonsFactory.js +1 -1
- package/dist/esm/utils/gps.d.ts +0 -1
- package/dist/esm/utils/gps.js +1 -1
- package/dist/esm/utils/i18n.d.ts +9 -0
- package/dist/esm/utils/i18n.js +1 -1
- package/dist/esm/utils/imageloader.d.ts +1 -3
- package/dist/esm/utils/imageloader.js +1 -1
- package/dist/esm/utils/math.d.ts +0 -1
- package/dist/esm/utils/math.js +1 -1
- package/dist/esm/wayfinding/adapters/boothToEndpoint.d.ts +4 -0
- package/dist/esm/wayfinding/adapters/boothToEndpoint.js +1 -1
- package/dist/esm/wayfinding/core/geometry/projectPointOnSegment.d.ts +7 -6
- package/dist/esm/wayfinding/core/geometry/projectPointOnSegment.js +1 -1
- package/dist/esm/wayfinding/core/graph/graphHelpers.js +1 -1
- package/dist/esm/wayfinding/core/graph/linkCost.js +1 -1
- package/dist/esm/wayfinding/core/graph/pathfinder/aStarPathFinder.js +1 -1
- package/dist/esm/wayfinding/core/index.d.ts +0 -1
- package/dist/esm/wayfinding/core/position/distanceToRoute.d.ts +1 -1
- package/dist/esm/wayfinding/core/position/distanceToRoute.js +1 -1
- package/dist/esm/wayfinding/core/position/gpsThreshold.js +1 -1
- package/dist/esm/wayfinding/core/position/rerouteController.d.ts +1 -1
- package/dist/esm/wayfinding/core/position/rerouteController.js +1 -1
- package/dist/esm/wayfinding/core/position/snapToRoute.js +1 -1
- package/dist/esm/wayfinding/core/rendering/computeTrailPoints.d.ts +2 -2
- package/dist/esm/wayfinding/core/rendering/computeTrailPoints.js +1 -1
- package/dist/esm/wayfinding/core/rendering/normalizeRouteDirection.d.ts +1 -1
- package/dist/esm/wayfinding/core/rendering/normalizeRouteDirection.js +1 -1
- package/dist/esm/wayfinding/core/rendering/routeGeometry.d.ts +4 -8
- package/dist/esm/wayfinding/core/rendering/routeGeometry.js +1 -1
- package/dist/esm/wayfinding/core/routing/getRouteLength.js +1 -1
- package/dist/esm/wayfinding/createWayfinding.js +1 -1
- package/dist/esm/wayfinding/handlers/kioskHandler.js +1 -1
- package/dist/esm/wayfinding/renderer/iconManager.js +1 -1
- package/dist/esm/wayfinding/runtime/createWayfindingRuntime.js +1 -1
- package/dist/esm/wayfinding/runtime/positionView.d.ts +3 -3
- package/dist/esm/wayfinding/runtime/positionView.js +1 -1
- package/dist/esm/wayfinding/runtime/routeUpdate.d.ts +6 -5
- package/dist/esm/wayfinding/runtime/routeUpdate.js +1 -1
- package/dist/esm/wayfinding/runtime/types.d.ts +4 -3
- package/package.json +4 -4
- package/dist/browser/ShowKiosk-78DDAGCM.js +0 -28
- package/dist/esm/components/Map/drawing/config/Rect.d.ts +0 -7
- package/dist/esm/components/Map/drawing/config/Rect.js +0 -1
- package/dist/esm/core/Line.d.ts +0 -12
- package/dist/esm/core/Line.js +0 -1
- package/dist/esm/core/Polygon.d.ts +0 -16
- package/dist/esm/core/Polygon.js +0 -1
- package/dist/esm/core/Rect.d.ts +0 -36
- package/dist/esm/core/Rect.js +0 -1
- package/dist/esm/core/Size.d.ts +0 -7
- package/dist/esm/core/Size.js +0 -1
- package/dist/esm/utils/haversineDistance.d.ts +0 -7
- package/dist/esm/utils/haversineDistance.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{useCallback as
|
|
1
|
+
import{lineIntersection as M}from"@expofp/geometry";import{useCallback as x,useEffect as T,useMemo as _,useRef as P}from"react";import{rectToRenderer as O}from"../../../renderer";import{createCircleCanvas as S,getBounds as b}from"../../../renderer/engine-core/canvases";import{isDefaultScene as U,pickDefaultScene as $}from"../../../renderer/engine-core/defs";import{BUILD_ROUTE_DOTS as K,BUILD_ROUTE_LINES as H}from"./trafficLayers";import{UpdateQueue as B}from"./UpdateQueue";const v=49,C=`hsl(257, 76%, ${v}%)`,Y=`hsl(339.903, 82%, ${v}%)`,J=`hsl(257, 76%, ${Math.round(v*1.82)}%)`,I=4,j=I,R="U",D="R",A="S",N="P";class q{_state=[[]];index=0;pointHashSet=new Set;locked=!1;storageKey="expofp_build_route_state";_selected=0;get points(){return this._state[this.index]}set points(t){this._state.push(t),this.setIndex(),this.save()}setIndex(){this.index=Math.max(this._state.length-1,0)}genPointHash(t){return`${t.x},${t.y}`}add(t){const a=this.genPointHash(t);this.pointHashSet.has(a)||(this.pointHashSet.add(a),this.points=[...this.points,t])}undo(){this.index&&(this._state.pop(),this.setIndex(),this.save(),this.select(this.points.length-1))}execute(t){try{if(this.locked)return;this.locked=!0,t()}finally{requestAnimationFrame(()=>{this.locked=!1})}}log(t,a=12){console.log(`%c${t}`,`color: black; font-size: ${a}px; background: LemonChiffon;`)}instruct(){this.log(`How to Build a Route:
|
|
2
2
|
Add Point: Click on the map.
|
|
3
|
-
Apply Smoothing: Press ${
|
|
4
|
-
Apply Simplification: Press ${
|
|
5
|
-
Undo: Press ${
|
|
3
|
+
Apply Smoothing: Press ${D}.
|
|
4
|
+
Apply Simplification: Press ${A}.
|
|
5
|
+
Undo: Press ${R}.
|
|
6
6
|
Enable/Disable Preview: Press ${N}.
|
|
7
|
-
`,16)}applyChaikinSmoothing(t,a,
|
|
7
|
+
`,16)}applyChaikinSmoothing(t,a,d){let r=[];if(d>=1&&t.length>=2){r=[t[0]];for(let h=1;h<t.length;h++){const e=t[h-1],u=t[h];for(let o=1;o<=d;o++){const n=o/(d+1);r.push({x:e.x+(u.x-e.x)*n,y:e.y+(u.y-e.y)*n})}r.push(u)}}else r=t.slice();for(let h=0;h<a&&!(r.length<2);h++){const e=[{...r[0]}];for(let u=1;u<r.length;u++){const o=r[u-1],n=r[u];e.push({x:.75*o.x+.25*n.x,y:.75*o.y+.25*n.y}),e.push({x:.25*o.x+.75*n.x,y:.25*o.y+.75*n.y})}e.push({...r[r.length-1]}),r=e}return r}applySmoothing(){this.points.length<3||(this.points=this.applyChaikinSmoothing(this.points,1,0),this.select(this.points.length-1))}save(){try{this.points.length?sessionStorage.setItem(this.storageKey,JSON.stringify(this.points)):sessionStorage.removeItem(this.storageKey)}catch(t){console.warn(t)}}restore(){try{const t=sessionStorage.getItem(this.storageKey);if(!t)return;const a=JSON.parse(t);if(!Array.isArray(a))return;a.forEach(d=>this.add(d)),this.select(this.points.length-1)}catch(t){console.warn(t)}}topologyPreservingSimplify(t,a){if(t.length<=2)return t.map(o=>({...o}));const d=(o,n,y)=>{const g=o.x,f=o.y,s=n.x,i=n.y,c=y.x,l=y.y,m=Math.abs((l-i)*g-(c-s)*f+c*i-l*s),p=Math.sqrt((l-i)**2+(c-s)**2);return m/(p||1e-10)},r=(o,n,y,g)=>{const f=M({p0:o,p1:n},{p0:y,p1:g});return f!==null&&f.onLine1&&f.onLine2},h=new Array(t.length).fill(!1);h[0]=h[h.length-1]=!0;const e=[],u=(o,n)=>{if(n<=o+1)return;const y=t[o],g=t[n];let f=0,s=0;for(let i=o+1;i<n;i++){const c=d(t[i],y,g);c>f&&(f=c,s=i)}if(f>a){const i=t[s];let c=!0;for(let l=0;l<e.length-1;l++)if(r(e[l],e[l+1],y,i)||r(e[l],e[l+1],i,g)){c=!1;break}c&&(h[s]=!0,u(o,s),u(s,n))}};return u(0,t.length-1),t.filter((o,n)=>h[n])}applySimplification(){this.points=this.topologyPreservingSimplify(this.points,.5),this.select(this.points.length-1)}get selected(){return this._selected}select(t){this._selected=Math.max(0,Math.min(t,this.points.length-1))}}export function useBuildRoute({enabled:L,rendererService:t}){const a=P(!1),d=P(),r=_(()=>S(I,C),[]),h=_(()=>S(I,Y),[]),e=_(()=>new q,[]),u=P(new B),o=_(()=>{if(!t.scene)return{};const s=t.scene.rootLayer.children,i=s.find(l=>l.name===H),c=s.find(l=>l.name===K);return{linesLayer:i,pointsLayer:c}},[t.scene]),n=x(()=>{if(!t?.renderer||!o||!r||!h)return;const{linesLayer:s,pointsLayer:i}=o;if(!s||!i)return;const c=e.points,l=a.current;l?i.children.length=0:i.children=c.map(({x:p,y:k},w)=>{const E=w==e.selected?h:r;return{source:E,bounds:O(b(p,k,E.width,E.height,d.current))}});const m=[];for(let p=1;p<c.length;p++){const k=c[p-1],w=c[p];m.push({points:[k,w],color:l?C:J,width:j})}m.length?s.children=m:s.children.length=0,u.current.add(()=>t.update(i,s)),e.instruct(),e.log(JSON.stringify(e.points))},[t,e,o,r,h]),y=x(s=>{const i=s.key.toUpperCase();e.execute(()=>{switch(i){case R:s.preventDefault(),e.undo(),a.current=!1,n();break;case D:s.preventDefault(),e.applySmoothing(),a.current=!1,n();break;case A:s.preventDefault(),e.applySimplification(),a.current=!1,n();break;case N:s.preventDefault(),a.current=!a.current,n();break}})},[e,n]),g=x(({ptScale:s,sceneId:i})=>{if(!U(i)||!t?.renderer||!o)return;const{pointsLayer:c}=o;c&&(d.current=s,e.execute(()=>{const l=c.children,m=[];for(const p of l)p.bounds=O(b(p.bounds.center.x,p.bounds.center.y,p.source.width,p.source.height,d.current)),m.push(p);u.current.add(()=>t.update(...m))}))},[t,o,e]),f=x(({data:s})=>{e.execute(()=>{const{point:i}=$(s);e.add({x:i.x,y:i.y}),e.select(e.points.length-1),n()})},[e,n]);T(()=>{const s=t.renderer;if(!(!L||!s))return d.current=t.scale,e.execute(()=>{e.restore(),n()}),s.events.addEventListener("pointer:click",f),s.events.addEventListener("viewport:ptscale",g),window.addEventListener("keyup",y),()=>{window.removeEventListener("keyup",y),s.events.removeEventListener("pointer:click",f),s.events.removeEventListener("viewport:ptscale",g),u.current.destroy()}},[L,t,e,n,f,g,y])}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as
|
|
1
|
+
import{degToRad as It,lineAngle as ut,pointDistance as lt}from"@expofp/geometry";import{useEffect as xt,useRef as L}from"react";import{getBounds as k,rectToRenderer as Y}from"../../../renderer";import{isDefaultScene as Mt}from"../../../renderer/engine-core/defs";import Lt from"../../../tools/base-runtime-url";import{loadImage as bt}from"../../../utils/loadImage";import{createImageCanvas as Ft}from"../drawing/config/canvases";import{getRouteLayerRegex as Rt,getRouteStopLayerRegex as At,TRAFFIC_VEHICLES as Tt}from"./trafficLayers";import{UpdateQueue as Pt}from"./UpdateQueue";const nt=2,vt=nt*3.5,Q=nt*12,dt=Q*.7,_t=8,Ct="transport_locations",Nt=150,ot="#a4aab6",ht=1e3,St=2e4,ft=500;export function useManageTraffic({permission:e,rendererService:n,dataJsonUrl:c,websocketUrl:s}){const t=L(window.devicePixelRatio),r=L(new Map),o=L(new Map),i=L(),w=L(),m=L(performance.now()),x=L(1),y=L(new Pt),F=L(new Map),E=L(),h=L(ht),I=L(new Map),l=L();xt(()=>{let A;async function N(){if(!(!e||!n.scene))try{let f;try{const a=await fetch(c,{method:"GET",headers:{"Content-Type":"application/json"}});if(!a.ok||a.status===204)return;f=await a.json()}catch(a){console.warn("useManageTraffic failed to get JSON",a)}if(!f||f?.disabled||f?.error)return;t.current=gt(n.scale);const Z=new Map(f.routes.map(({id:a,color:p})=>[a,p])),H=n.scene.rootLayer.children,V=new Map;Z.forEach(a=>{V.set(a,Ht({radius:vt,color:a,scale:window.devicePixelRatio}))});const j=Rt(),q=H.filter(a=>j.test(a.name)),B=At(),G=H.filter(a=>B.test(a.name));f.routes.slice(0,q.length).forEach(({id:a,color:p,path:P,stops:W,hiddenPoints:v},d)=>{F.current.set(a,P);const _=q[d];if(_){const C=new Map(v?.map(u=>[rt(u),u])??[]);for(let u=1;u<P.length;u++){const S=P[u-1],D=P[u];C.has(rt(S))||C.has(rt(D))||_.children.push({points:[S,D],color:p,width:nt})}_.children.length&&y.current.add(()=>n.update(_))}const g=G[d];if(g&&W?.length){const C=V.get(p);W.forEach(u=>{g.children.push({source:C,bounds:Y(k(u.x,u.y,C.width,C.height,t.current))})}),g.children.length&&y.current.add(()=>n.update(g))}});const z=H.find(a=>a.name===Tt),J=new Map;E.current=a=>{try{const{ptScale:p,sceneId:P}=Dt(a);if(!Mt(P))return;t.current=gt(p);const W=[];for(const d of G){const _=d.children;for(const g of _)g.bounds=Y(k(g.bounds.center.x,g.bounds.center.y,g.source.width,g.source.height,t.current,g.bounds.rotation)),W.push(g)}const v=[...r.current.values()];for(const d of v)d.bounds=Y(k(d.bounds.center.x,d.bounds.center.y,d.source.width,d.source.height,t.current,d.bounds.rotation));y.current.add(()=>n.update(...W,...v))}catch(p){console.error("ptscale",p)}},n.renderer.events.addEventListener("viewport:ptscale",E.current),A=requestAnimationFrame(()=>{E.current?.(n.scale)}),Z.forEach((a,p)=>{J.set(p,mt({id:p,width:Q,height:Q,color:a,scale:window.devicePixelRatio}))}),J.set(ot,mt({id:"orphan",width:Q,height:Q,color:ot,scale:window.devicePixelRatio}));let U=null;try{const a=await bt(`${Lt}icons/bus-white.svg`);U=Ft(a,dt,dt,window.devicePixelRatio)}catch(a){console.error(a)}w.current=a=>{try{const p=JSON.parse(a.data);if(p.type!==Ct)return;const P=a.timeStamp||performance.now();x.current=Math.round(P-m.current),m.current=P;const W=Math.max(x.current??ft,ft),v=o.current,d=r.current,_=z.children,g=y.current;let C=!1;p.data.forEach(({id:u,x:S,y:D,route_id:st,hidden:yt})=>{if(v.has(u)&&(v.get(u)?.(),v.delete(u)),yt&&d.has(u)&&d.has(X(u))){const R=d.get(u);R.hidden=!0;const b=d.get(X(u));b.hidden=!0,g.add(()=>n.update(R,b));return}if(I.current.set(u,performance.now()),!d.has(u)){const R=J.get(st)||J.get(ot),b={id:u,source:R,bounds:Y(k(S,D,R.width,R.height,t.current,0))};if(d.set(u,b),U){const $=X(u),at={id:$,source:U,bounds:Y(k(S,D,U.width,U.height,t.current,0))};U.setAttribute("id",$),d.set($,at),_.push(b,at)}else _.push(b);C=!0;return}const K=d.get(u),it=d.get(X(u)),Et=K.bounds.center,et=Wt(Et,{x:S,y:D},F.current.get(st));if(et.reduce((R,b,$)=>$===0?R:R+ct(et[$-1],b),0)>=Nt||document.hidden)pt({rendererService:n,updateQueue:g,vehicle:K,vehicleFinery:it,x:S,y:D,scale:t.current,angle:Ot(K.bounds.center,{x:S,y:D})});else{const R=kt(et,W,b=>{pt({rendererService:n,updateQueue:g,vehicle:K,vehicleFinery:it,x:b.x,y:b.y,scale:t.current,angle:b.angle})});v.set(u,R)}}),C&&g.add(()=>n.update(z))}catch(p){console.error("handleSocketMessage",p)}},M(),O(f.config?(Number(f.config.vehicle_inactive_interval)||20)*1e3:St)}catch(f){console.warn(f)}}N();function M(){i.current?.readyState===WebSocket.OPEN||i.current?.readyState===WebSocket.CONNECTING||(i.current=new WebSocket(s),i.current.onmessage=w.current,i.current.onopen=()=>{h.current=ht},i.current.onclose=()=>{if(!navigator.onLine)return;setTimeout(M,h.current);const f=3e4;h.current=Math.min(h.current*2,f)})}function T(){M()}window.addEventListener("online",T);function O(f){clearInterval(l.current),l.current=window.setInterval(()=>{const Z=performance.now(),H=[],V=[];I.current.forEach((j,q)=>{if(Z-j<f)return;const B=r.current.get(q);B&&(B.hidden=!0,V.push(B),H.push(q));const G=X(q),z=r.current.get(G);z&&(z.hidden=!0,V.push(z),H.push(G))}),V.length&&y.current.add(()=>n.update(...V)),H.forEach(j=>I.current.delete(j))},f)}return()=>{E.current&&n.renderer&&n.renderer.events.removeEventListener("viewport:ptscale",E.current),A!==void 0&&cancelAnimationFrame(A),o.current.forEach(f=>f?.()),o.current.clear(),r.current.clear(),y.current.destroy(),window.removeEventListener("online",T),clearInterval(l.current)}},[e,n,c,s])}function gt(e){return Math.min(e||window.devicePixelRatio,_t)}function Dt(e){return typeof e=="number"?{ptScale:e}:e}function Ot(e,n){return ut(e,n)}function Ht({radius:e,scale:n,color:c}){const s=document.createElement("canvas"),t=s.getContext("2d");t.imageSmoothingEnabled=!1;const r=Math.ceil(e*2*n),o=r/2,i=e*.78,w=e*.33;return s.width=r,s.height=r,t.translate(o,o),t.scale(n,n),t.beginPath(),t.arc(0,0,e,0,2*Math.PI),t.fillStyle="#FFFFFF",t.fill(),t.beginPath(),t.arc(0,0,i,0,2*Math.PI),t.fillStyle=c,t.fill(),t.beginPath(),t.arc(0,0,w,0,2*Math.PI),t.fillStyle="#FFFFFF",t.fill(),s}function mt({id:e,width:n,height:c,color:s,scale:t}){const r=2*t,o=n/2*t,i=c*t,w=.6,m=.01,x=i*w,y=i,F=8*t,E=y+r+x/2+F*2,h=o*2+x+r+F*2,I=document.createElement("canvas");I.setAttribute("id",e),I.width=E,I.height=h;const l=I.getContext("2d"),A=E/2,N=h/2;l.save(),l.translate(A,N),l.rotate(-Math.PI/2),l.translate(-A,-N);const M=A,T=N-y/2+o,O=T+x;return l.shadowColor="rgba(16, 24, 40, 0.2)",l.shadowBlur=F/2,l.beginPath(),l.arc(M,T,o,Math.PI,0,!1),l.bezierCurveTo(M+o,T+i*.3,M+m*o,O,M,O),l.bezierCurveTo(M-m*o,O,M-o,T+i*.3,M-o,T),l.closePath(),l.fillStyle=s,l.fill(),l.strokeStyle="#FFFFFF",l.lineWidth=r,l.stroke(),l.restore(),I}function ct(e,n){return lt(e,n)}function X(e){return`${e}_finery`}function pt({rendererService:e,updateQueue:n,vehicle:c,vehicleFinery:s,x:t,y:r,scale:o,angle:i}){c.bounds=Y(k(t,r,c.source.width,c.source.height,o,i)),c.hidden=!1,s?(s.bounds=Y(k(t,r,s.source.width,s.source.height,o,It(e.angle))),s.hidden=!1,n.add(()=>e.update(s,c))):n.add(()=>e.update(c))}function tt(e,n,c){return{x:e.x+(n.x-e.x)*c,y:e.y+(n.y-e.y)*c}}function wt(e,n){let c=1/0,s={index:0,t:0};for(let t=0;t<n.length-1;t++){const r=n[t],o=n[t+1],i=o.x-r.x,w=o.y-r.y,m=i*i+w*w,x=m?((e.x-r.x)*i+(e.y-r.y)*w)/m:0,y=Math.max(0,Math.min(1,x)),F=tt(r,o,y),E=ct(e,F);E<c&&(c=E,s={index:t,t:y})}return s}function Vt(e,n,c){const s=ct(e,n),t=Math.max(2,Math.ceil(s/c)+1),r=[];for(let o=0;o<t;o++){const i=o/(t-1),w=tt(e,n,i);r.push(w)}return r}function Wt(e,n,c){if(!c||!c.length)return Vt(e,n,10);const s=wt(e,c),t=wt(n,c),r=[],o=i=>r.push(i);s.index+1<c.length?o(tt(c[s.index],c[s.index+1],s.t)):o(c[s.index]);for(let i=s.index+1;i<=t.index&&i<c.length;i++)o(c[i]);return t.index+1<c.length?o(tt(c[t.index],c[t.index+1],t.t)):o(c[t.index]),r}function kt(e,n,c,s){if(e.length<2)return()=>{};let t=null,r;const o=[];let i=0;for(let m=0;m<e.length-1;m++){const x=lt(e[m],e[m+1]);o.push(x),i+=x}const w=m=>{t||(t=m);const x=m-t,y=Math.min(x/n,1),F=y*i;let E=0,h=0;for(;h<o.length&&E+o[h]<F;)E+=o[h],h++;h>=o.length&&(h=o.length-1);const I=e[h],l=e[Math.min(h+1,e.length-1)],A=o[h]||0,N=A===0?0:(F-E)/A,M=I.x+(l.x-I.x)*N,T=I.y+(l.y-I.y)*N,O=ut(I,l);c({x:M,y:T,angle:O}),y<1?r=requestAnimationFrame(w):s&&s()};return r=requestAnimationFrame(w),()=>{r&&cancelAnimationFrame(r)}}function rt(e){return`${e.x},${e.y}`}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as V}from"react/jsx-runtime";import J from"color";import{runInAction as W}from"mobx";import{observer as X}from"mobx-react-lite";import{useCallback as
|
|
1
|
+
import{jsx as V}from"react/jsx-runtime";import{degToRad as P}from"@expofp/geometry";import J from"color";import{runInAction as W}from"mobx";import{observer as X}from"mobx-react-lite";import{useCallback as E,useEffect as _,useMemo as d,useRef as p,useState as k}from"react";import{getLayerSvg as H,svgArea as x}from"../../data/svg";import{createSceneDef as K}from"../../renderer";import a,{uiState as g}from"../../store";import M from"../../tools/settings";import Z from"../Map/drawing/config/config-all";import{loadLayersImages as Q}from"../Map/drawing/config/loadBoothsImages";import{useBuildRoute as Y}from"../Map/traffic/useBuildRoute";import{useManageTraffic as q}from"../Map/traffic/useManageTraffic";import ee from"./MaplibreWrapper";import{useCameraReactions as re}from"./useCameraReactions";import{useDimming as oe}from"./useDimming";import{useLayerVisibilitySync as te}from"./useLayerVisibilitySync";import{useRendererEvents as ne}from"./useRendererEvents";import{useWayfindingAndMarkers as ae}from"./useWayfindingAndMarkers";import{deriveGeoConfig as ie,deriveVenueMapBounds as se,getLocalRectGeoBounds as le,getVisibleRectFitPadding as ce,INITIAL_FIT_ZOOM_ADJUSTMENT as fe}from"./utils/geo-config";import{applyMapOptions as I,DEFAULT_MAP_OPTIONS as ue,getTileSource as me,MAP_2D_OPTIONS as de}from"./utils/map-helpers";import{calculateTransformMatrix as pe}from"./utils/solver";const $="routes-api.expofp.com";function B(){W(()=>{a.layerStore.layers.forEach(i=>{i.configured=!1,i.children=[],i.loaded=!1}),a.layerStore.layersLoaded=!1})}function F(i,y){const s=[];for(const c of i.rollRegistry.invoke(y))Array.isArray(c)?s.push(...c):s.push(c);s.length&&i.update(...s)}const ge=X(function({viewMode:y}){const[s,c]=k(null),[T,h]=k(null),e=a.rendererService,D=p(null),l=p(null),R=p(null),L=p(null),r=d(()=>ie(),[]),f=d(()=>r?{center:r.center,bearing:r.bearing,zoom:r.zoom,bounds:le(x,r.gpsConfig),fitPadding:ce(0),zoomAdjustment:fe}:null,[r]),v=d(()=>r?pe(r.gpsConfig,H()?.getAttribute("units")):null,[r]),u=d(()=>({...y==="map2d"?de:ue,maxBounds:r?se(r.gpsConfig):void 0}),[r,y]),O=p(u),j=d(()=>me(),[]),{mapDimAnimatorRef:b,venueDimAnimatorRef:S,handleMapDimLayerReady:z}=oe(l,e);_(()=>{if(!r)return;let n=!1;B();const o=Z(e).then(t=>{if(n)return;const A=J(M.backgroundColor==="none"?"#ebebeb":M.backgroundColor).string(),G=K(t,x,A);c(G)}).catch(t=>{n||console.warn("Maplibre scene configuration failed.",t)}),C=b.current,m=S.current;return()=>{n=!0,B();const t=D.current;o.finally(()=>e.disposeIfCurrent(t)),R.current?.(),R.current=null,D.current=null,l.current=null,L.current=null,h(null),C?.stop(),m?.stop(),g.sceneDefReady=!1}},[r,b,e,S]);const N=E((n,o,C,m)=>{D.current=n,l.current=o,L.current=m,h(n),e.attach(n,C,m),I(o,O.current),b.current?.setTarget(g.dimmed,{immediate:!0}),S.current?.setTarget(g.dimmed,{immediate:!0}),R.current?.();const t=()=>F(e,P(o.getBearing()));o.on("rotate",t),o.on("rotateend",t),R.current=()=>{o.off("rotate",t),o.off("rotateend",t)},Q(e);const A=e.ptScaleRegistry.invoke(e.scale||1);A.length&&e.update(...A),F(e,P(o.getBearing())),a.layerStore.layersLoaded=!0,a.fp.onFpConfigured&&a.fp.onFpConfigured(),g.sceneDefReady=!0,m()},[e,b,S]);_(()=>{O.current=u,I(l.current,u,!0)},[u]),ne(T,e),ae(T,e),te(e,l,r),re(l,r),Y({enabled:a.layerStore.layersLoaded&&g.buildRoute,rendererService:e}),q({permission:a.layerStore.layersLoaded,rendererService:e,dataJsonUrl:`https://${$}/v1/routes?expo=${M.EXPO}`,websocketUrl:`wss://${$}/locations?expo=${M.EXPO}`});const U=E(n=>{console.warn("Maplibre map failed to load; falling back to floorplan mode.",n),a.maplibreStore.deactivateMaplibre()},[]);if(!r||!f||!v||!s)return null;const w=`${f.center.join(",")}:${f.bearing}:${f.zoom}`;return V(ee,{sceneDef:s,geoConfig:f,staticTransform:v,tileSource:j,mapOptions:u,onRendererReady:N,onMapDimLayerReady:z,onMapLoadError:U},w)});export default ge;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Map as MaplibreMap } from 'maplibre-gl';
|
|
2
|
+
import type { RefObject } from 'react';
|
|
3
3
|
import { type GeoConfig } from './utils/geo-config';
|
|
4
4
|
/**
|
|
5
5
|
* Bundles all camera-related MobX reactions: moveToBooths, moveToRect,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import y
|
|
1
|
+
import{Box as y}from"@expofp/geometry";import{svgArea as T}from"../../data/svg";import p,{uiState as i}from"../../store";import{convertLocalToGps as b}from"../../utils/gps";import{useReaction as m}from"../../utils/mobx";import{fitMapToLocalRect as l}from"./utils/geo-config";const s=i;export function useCameraReactions(a,e){m(()=>s.moveToBooths,r=>{const t=a.current;if(!r||!t||!e)return;const o=r.filter(c=>c.rect);if(o.length===0)return;const n=y.fromUnion(...o.map(c=>c.rect));l(t,n,e),s.moveToBooths=null}),m(()=>s.moveToRect,r=>{const t=a.current;!r||!t||!e||(l(t,r,e),s.moveToRect=null)}),m(()=>s.zoomBy,r=>{const t=a.current;!r||!t||(t.flyTo({zoom:t.getZoom()+(r>1?.5:-.5),animate:!0,duration:500}),s.zoomBy=null)}),m(()=>i.moveToLocation,r=>{const t=a.current,o=p.routeStore.currentPosition;if(!r||!t||!o)return;const{lng:n,lat:c}=o,f=typeof n=="number"&&Number.isFinite(n)&&typeof c=="number"&&Number.isFinite(c);let u;if(f)u=[n,c];else{if(!e)return;u=b(o.x,o.y,e.gpsConfig)}t.flyTo({center:u,animate:!0,duration:1e3}),t.once("moveend",()=>{i.moveToLocation=!1})}),m(()=>i.centerMap,r=>{const t=a.current;if(!r||!t||!e)return;if(!(i.list.type==="search"&&!i.list.text)){const n=p.layerStore.rectangle||T;l(t,n,e,{padding:0})}i.centerMap=!1})}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Map as MaplibreMap } from 'maplibre-gl';
|
|
2
2
|
import { type RefObject } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import type { RendererService } from '../../renderer/RendererService';
|
|
4
4
|
import { type GeoConfig } from './utils/geo-config';
|
|
5
5
|
/**
|
|
6
6
|
* Keeps the 3D scene layer visibility in sync with LayerStore.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRef as m}from"react";import s from"../../store";import{useReaction as
|
|
1
|
+
import{useRef as m}from"react";import s from"../../store";import{useReaction as L}from"../../utils/mobx";import{fitMapToLocalRect as b}from"./utils/geo-config";import{collectLayerDefsByName as h}from"./utils/layer-defs";export function useLayerVisibilitySync(f,u,y){const t=m(null),a=m(null);L(()=>s.layerStore.layers.map(e=>`${e.name}:${e.visible?1:0}`),()=>{const e=f.scene;if(!e)return;t.current?.rootLayer!==e.rootLayer&&(t.current={rootLayer:e.rootLayer,defsByName:h(e.rootLayer)});const d=t.current.defsByName,n=[];for(const o of s.layerStore.layers){const c=d.get(o.name);if(c?.length)for(const i of c){const l=!o.visible;i.hidden!==l&&(i.hidden=l,n.push(i))}}n.length&&f.update(...n);const r=s.layerStore.layers.find(o=>o.visible&&!o.frozen&&!o.rootParent&&!o.pathway);if(!r||a.current===r.name)return;a.current=r.name;const p=r.viewbox??r.rect;b(u.current,p??null,y)})}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { Box } from '@expofp/geometry';
|
|
2
|
+
import type { LngLatBoundsLike, Map as MaplibreMap } from 'maplibre-gl';
|
|
3
|
+
import type { GeoConfig as MaplibreGeoConfig } from '../MaplibreWrapper';
|
|
4
|
+
import type { TransformGeoConfig } from './solver';
|
|
5
5
|
export interface GeoConfig extends MaplibreGeoConfig {
|
|
6
6
|
gpsConfig: TransformGeoConfig;
|
|
7
7
|
}
|
|
@@ -19,12 +19,12 @@ export declare const MAP_BOUNDS_PADDING_FACTOR = 3;
|
|
|
19
19
|
export declare const MAP_BOUNDS_MIN_PADDING_DEGREES = 0.02;
|
|
20
20
|
export declare const INITIAL_FIT_ZOOM_ADJUSTMENT = 0.15;
|
|
21
21
|
export declare function deriveVenueMapBounds(config: TransformGeoConfig): LngLatBoundsLike | undefined;
|
|
22
|
-
export declare function getLocalRectGeoBounds(rect:
|
|
22
|
+
export declare function getLocalRectGeoBounds(rect: Box, config: TransformGeoConfig): LngLatBoundsLike;
|
|
23
23
|
export declare function getVisibleRectFitPadding(extraPadding?: number): CameraPaddingOptions;
|
|
24
24
|
/**
|
|
25
25
|
* Derive the geographic configuration from the fpGeo data.
|
|
26
26
|
* Returns null if geo data is not available.
|
|
27
27
|
*/
|
|
28
28
|
export declare function deriveGeoConfig(): GeoConfig | null;
|
|
29
|
-
export declare function fitMapToLocalRect(map: MaplibreMap | null, rect:
|
|
29
|
+
export declare function fitMapToLocalRect(map: MaplibreMap | null, rect: Box | null, geoConfig: GeoConfig | null, options?: FitMapOptions): void;
|
|
30
30
|
//# sourceMappingURL=geo-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fpGeo as
|
|
1
|
+
import{fpGeo as f}from"../../../data/fpGeo";import{svgArea as m}from"../../../data/svg";import{uiState as M}from"../../../store";import{convertLocalToGps as r}from"../../../utils/gps";export const MAP_BOUNDS_PADDING_FACTOR=3,MAP_BOUNDS_MIN_PADDING_DEGREES=.02,INITIAL_FIT_ZOOM_ADJUSTMENT=.15;export function deriveVenueMapBounds(n){const t=[[m.min.x,m.min.y],[m.max.x,m.min.y],[m.max.x,m.max.y],[m.min.x,m.max.y]].map(([s,x])=>r(s,x,n));if(!t.every(([s,x])=>Number.isFinite(s)&&Number.isFinite(x)))return;const i=t.map(([s])=>s),o=t.map(([,s])=>s),a=Math.min(...i),e=Math.max(...i),p=Math.min(...o),c=Math.max(...o),h=Math.max((e-a)*MAP_BOUNDS_PADDING_FACTOR,MAP_BOUNDS_MIN_PADDING_DEGREES),u=Math.max((c-p)*MAP_BOUNDS_PADDING_FACTOR,MAP_BOUNDS_MIN_PADDING_DEGREES);return[[a-h,p-u],[e+h,c+u]]}export function getLocalRectGeoBounds(n,t){const i=[r(n.min.x,n.min.y,t),r(n.max.x,n.min.y,t),r(n.max.x,n.max.y,t),r(n.min.x,n.max.y,t)],o=i.map(([e])=>e),a=i.map(([,e])=>e);return[[Math.min(...o),Math.min(...a)],[Math.max(...o),Math.max(...a)]]}export function getVisibleRectFitPadding(n=0){const t=M.canvasVisibleRectPx,i=M.screenSize;return!t||!i?{top:n,bottom:n,left:n,right:n}:{top:Math.max(0,t.min.y)+n,bottom:Math.max(0,i.height-t.max.y)+n,left:Math.max(0,t.min.x)+n,right:Math.max(0,i.width-t.max.x)+n}}export function deriveGeoConfig(){if(!f?.properties?.config)return null;const n=f.properties.config,t=(n.p0.lng+n.p2.lng)/2,i=(n.p0.lat+n.p2.lat)/2;return{center:[t,i],bearing:n.bearing??0,zoom:16,gpsConfig:n}}export function fitMapToLocalRect(n,t,i,o={}){if(!n||!t||!i||t.size.height===1/0||t.size.width===1/0||t.size.height<=0||t.size.width<=0)return;const a=getLocalRectGeoBounds(t,i.gpsConfig),e=getVisibleRectFitPadding(o.padding??50);n.fitBounds(a,{padding:e,duration:o.duration??1e3,bearing:i.bearing})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MercatorCoordinate as A}from"maplibre-gl";const
|
|
1
|
+
import{bearing as L,destinationPoint as N,haversineDistance as T}from"@expofp/geometry";import{MercatorCoordinate as A}from"maplibre-gl";const I=1e-12,R=3.28084;export function calculateTransformMatrix(n,u){const s=n.p1??S(n),r=[n.p0,s,n.p2],e=[],t=[],a=[];for(const c of r){Z(c),t.push([c.x,c.y]);const i=A.fromLngLat([c.lng,c.lat],0),h=i.meterInMercatorCoordinateUnits();p(i.x),p(i.y),p(h),e.push(h),a.push([i.x,i.y])}const o=[],l=[];for(let c=0;c<3;c++){const[i,h]=t[c],[P,F]=a[c];o.push([i,h,1,0,0,0]),l.push(P),o.push([0,0,0,i,h,1]),l.push(F)}const m=_(o,l),[f,x,b,y,w,E]=m,M=u?.toLowerCase?.().trim()==="ft"?1/R:1,v=e.reduce((c,i)=>c+i,0)/e.length*M,d=[f,y,0,0,x,w,0,0,0,0,v,0,b,E,0,1];if(!d.every(Number.isFinite))throw new Error("Cannot calculate Maplibre transform: geo anchor points produced a non-finite matrix.");return d}function S(n){const u=n.p2.x-n.p0.x,s=n.p2.y-n.p0.y;if(u===0&&s===0)throw new Error("Cannot calculate Maplibre transform: p0 and p2 have identical SVG coordinates.");const r=n.p0.x-s,e=n.p0.y+u,t=T(n.p0,n.p2),a=L(n.p0,n.p2),{lat:o,lng:l}=N(n.p0,t,a+90);return{x:r,y:e,lat:o,lng:l}}function Z(n){p(n.x),p(n.y),p(n.lat),p(n.lng)}function p(n){if(!Number.isFinite(n))throw new Error("Cannot calculate Maplibre transform: geo anchor points contain invalid coordinates.")}function _(n,u){const s=n.length,r=n.map((t,a)=>[...t,u[a]]);for(let t=0;t<s;t++){let a=t;for(let o=t+1;o<s;o++)Math.abs(r[o][t])>Math.abs(r[a][t])&&(a=o);if([r[t],r[a]]=[r[a],r[t]],Math.abs(r[t][t])<I)throw new Error("Cannot calculate Maplibre transform: geo anchor points are collinear or invalid.");for(let o=t+1;o<s;o++){const l=r[o][t]/r[t][t];for(let m=t;m<=s;m++)r[o][m]-=l*r[t][m]}}const e=new Array(s);for(let t=s-1;t>=0;t--){e[t]=r[t][s];for(let a=t+1;a<s;a++)e[t]-=r[t][a]*e[a];e[t]/=r[t][t]}return e}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useCallback as
|
|
1
|
+
import{haversineDistance as v}from"@expofp/geometry";import{useCallback as A,useRef as e}from"react";import O from"../../tools/logger";import{hasMeaningfulChange as H,MOVE_THRESHOLD_M as E,normalizeHeading as L}from"./utils";const _=120,C=3e3,G=360;export function useUserLocationAndHeading(g){const o=e(null),s=e(null),f=e(0),u=e(null),d=e(!1),t=e(null),a=e(!1),l=e(null),h=n=>g(n),m=n=>{const r=Date.now();if(r-f.current<_)return;const i=u.current;if(!t.current){t.current=n,f.current=r,u.current=n,h(n);return}const w=v(t.current,n);let c;a.current?w<=E?(a.current=!1,t.current=n,c={...t.current,heading:n.heading}):(t.current=n,c=n):w>=E?(a.current=!0,t.current=n,l.current=null,c=n):(l.current==null&&(l.current=r),r-l.current>C&&(t.current=n),c={...t.current,heading:n.heading}),!(i&&!H(i,c))&&(f.current=r,u.current=c,h(c))},R=A(n=>{const r=n.webkitCompassHeading??(n.alpha!=null?G-n.alpha:null);if(r==null)return;const i=L(r);s.current!==i&&(s.current=i,u.current&&m({...u.current,heading:i}))},[g]);return{startGeolocation:()=>{o.current==null&&(o.current=navigator.geolocation.watchPosition(n=>{m({lat:n.coords.latitude,lng:n.coords.longitude,heading:s.current})},n=>O.warn("Geolocation watch error:",n),{enableHighAccuracy:!0,maximumAge:0}))},startOrientation:()=>{d.current||(d.current=!0,window.addEventListener("deviceorientation",R,!0))},stopGeolocation:()=>{o.current!=null&&(navigator.geolocation.clearWatch(o.current),o.current=null),t.current=null,a.current=!1},stopOrientation:()=>{d.current=!1,window.removeEventListener("deviceorientation",R,!0)}}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { GpsPosition } from './types';
|
|
2
2
|
export declare const MOVE_THRESHOLD_M = 3;
|
|
3
3
|
export declare function normalizeHeading(heading: number): number;
|
|
4
4
|
export declare function hasMeaningfulChange(prev: GpsPosition, curr: GpsPosition): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{haversineDistance as e}from"
|
|
1
|
+
import{haversineDistance as e}from"@expofp/geometry";export const MOVE_THRESHOLD_M=3;export function normalizeHeading(n){return Math.floor(n)}export function hasMeaningfulChange(n,t){return e(n,t)>=MOVE_THRESHOLD_M?!0:n.heading!==t.heading}
|
package/dist/esm/data/svg.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Box } from '@expofp/geometry';
|
|
2
2
|
import { Layer } from '../store/LayerStore';
|
|
3
|
-
declare const svgViewBox:
|
|
4
|
-
declare let svgArea:
|
|
3
|
+
declare const svgViewBox: Box;
|
|
4
|
+
declare let svgArea: Box;
|
|
5
5
|
declare let floors: {
|
|
6
6
|
name: string | undefined;
|
|
7
|
-
rect:
|
|
7
|
+
rect: Box;
|
|
8
8
|
}[];
|
|
9
9
|
export { floors, svgArea, svgViewBox };
|
|
10
10
|
export declare function getTrianglesFromFpPaths(index: number, suffix: string): number[][][];
|
package/dist/esm/data/svg.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as a from"d3-selection";import{STRING_META_DELIMITER as u}from"../constants";import
|
|
1
|
+
import{Box as w}from"@expofp/geometry";import*as a from"d3-selection";import{STRING_META_DELIMITER as u}from"../constants";import _ from"../tools/logger";import b from"../tools/settings";import{extractMetaFromString as v}from"../utils/extractMetaFromString";import A from".";const r=new Map;function g(e,n=""){if(r.has(n))return r.get(n);const s=new DOMParser().parseFromString(e,"image/svg+xml").documentElement;s.firstChild.tagName==="parsererror"&&_.error("Parsed svg with error: ",c);const t=new Map;return a.select(s).selectAll("style").each(function(){const i=this.textContent,x=/\.([a-z0-9.]+)\s*{[^}]*fill\s*:\s*([^};]+);[^}]*}/gi;let h;for(;(h=x.exec(i))!==null;){const M=h[1],P=h[2];t.set(M,P)}}),a.select(s).selectAll("*[class]").each(function(){const i=this;i.style.fill=t.get(i.className.baseVal)}),S(s),r.set(n,s),s}let c=g(window.__fp);const l=window.__viewbox,d=a.select(c).select("rect#VIEWBOX").node(),p=c.viewBox.baseVal,m=new w(p.x,p.y,p.width,p.height);let f;l?(f=new w(l.x,l.y,l.width,l.height),d?.remove()):d?(f=w.fromSvg(d),d.remove()):f=m.scale(1.1),a.select(c).attr("width",m.size.width),a.select(c).attr("height",m.size.height),_.log("svgArea",f,"svgViewBox",m),b.wayfinding=!!(!A.hideDirections&&window.__wfData);let B=window.__fpLayersMode?a.select(c).selectAll("[data-floor]").nodes().map(e=>(e.remove(),{name:e.dataset.floor,rect:w.fromSvg(e)})).sort():[];export{B as floors,f as svgArea,m as svgViewBox};export function getTrianglesFromFpPaths(e,n){const o=gtePathByIndex(e,n);for(const t of o.positions)t[1]=Math.abs(t[1]),t.length=2;const s=[];for(const t of o.cells)s.push([o.positions[t[0]],o.positions[t[1]],o.positions[t[2]]]);return s}export let gtePathByIndex=(e,n="")=>{try{return window[`__fpPaths${n}`][e]}catch{return window.__fpPaths[e]}},getLayerSvg=(e="")=>typeof e=="string"?r.has(e)?r.get(e):window[`__fp${e}`]?g(window[`__fp${e}`],e):r.get(""):e.rootParent?r.has(e.rootParent.name)?r.get(e.rootParent.name):window[`__fp${e.rootParent.name}`]?g(window[`__fp${e.rootParent.name}`],e.rootParent.name):r.get(""):window[`__fp${e.name}`]?g(window[`__fp${e.name}`],e.name):r.get("");function S(e){a.select(e).selectAll("[id], [data-name]").each(function(){const n=this;let o={};const s=n.getAttribute("data-name");if(s&&s.includes(u)){const{meta:i}=v(s);o={...o,...i}}const t=n.getAttribute("id");if(t&&t.includes(u)){const{meta:i}=v(t);o={...o,...i}}n.setAttribute("data-meta",JSON.stringify(o))})}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Box } from '@expofp/geometry';
|
|
1
2
|
import { createRoot } from 'react-dom/client';
|
|
2
|
-
import Rect from './core/Rect';
|
|
3
3
|
import FloorPlanLoader from './floorplan.loader';
|
|
4
4
|
import { CurrentPosition, MarkersData } from './store/RouteStore';
|
|
5
5
|
import { Visibility } from './store/types';
|
|
@@ -62,7 +62,7 @@ export default class FloorPlanReady extends FloorPlanLoader {
|
|
|
62
62
|
fitBounds(bounds?: Bounds, options?: {
|
|
63
63
|
padding?: number;
|
|
64
64
|
}): void;
|
|
65
|
-
getBoothRect(name: string):
|
|
65
|
+
getBoothRect(name: string): BoothRect;
|
|
66
66
|
convertToGeo(x: number, y: number): [number, number] | never;
|
|
67
67
|
getGeoConfig(): GeoConfig | null;
|
|
68
68
|
unstable_destroy(): void;
|
|
@@ -87,4 +87,41 @@ export default class FloorPlanReady extends FloorPlanLoader {
|
|
|
87
87
|
reset(): void;
|
|
88
88
|
selectAccessibleRoute(waypoints: RouteWaypoint[]): void;
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Backward-compatible return shape of the public `getBoothRect()` API.
|
|
92
|
+
*
|
|
93
|
+
* Internally booth footprints are now `@expofp/geometry` `Box`es, but external
|
|
94
|
+
* SDK consumers of `getBoothRect()` rely on the legacy `core/Rect` instance
|
|
95
|
+
* surface (`x1/y1/x2/y2`, the `cx/cy/w/h` getters, and the full method set).
|
|
96
|
+
* This class reproduces that surface exactly and is built from a `Box`'s
|
|
97
|
+
* `min`/`max` corners at the API boundary. It is intentionally NOT exported, so
|
|
98
|
+
* no other module can import it — the only way to obtain one is `getBoothRect()`.
|
|
99
|
+
*/
|
|
100
|
+
declare class BoothRect {
|
|
101
|
+
x1: number;
|
|
102
|
+
y1: number;
|
|
103
|
+
x2: number;
|
|
104
|
+
y2: number;
|
|
105
|
+
get h(): number;
|
|
106
|
+
get w(): number;
|
|
107
|
+
get cx(): number;
|
|
108
|
+
get cy(): number;
|
|
109
|
+
constructor(x1: number, y1: number, x2: number, y2: number);
|
|
110
|
+
static fromBox(box: Box): BoothRect;
|
|
111
|
+
static fromCxcywh(cx: number, cy: number, w: number, h: number): BoothRect;
|
|
112
|
+
contains(r: BoothRect): boolean;
|
|
113
|
+
intersects(r: BoothRect): boolean;
|
|
114
|
+
getIntersection(r: BoothRect): BoothRect;
|
|
115
|
+
getRotated90(): BoothRect;
|
|
116
|
+
normalize(width: number, height: number): BoothRect;
|
|
117
|
+
withPadding(x: number, y?: number): BoothRect;
|
|
118
|
+
scale(s: number): BoothRect;
|
|
119
|
+
getArea(): number;
|
|
120
|
+
clone(): BoothRect;
|
|
121
|
+
translate(dx: number, dy: number): this;
|
|
122
|
+
equals(r: BoothRect): boolean;
|
|
123
|
+
toString(): string;
|
|
124
|
+
containsPoint(x: number, y: number): boolean;
|
|
125
|
+
}
|
|
126
|
+
export {};
|
|
90
127
|
//# sourceMappingURL=floorplan.ready.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as g,Fragment as L,jsxs as C}from"react/jsx-runtime";import{ErrorBoundary as T}from"@sentry/react";import R from"debug";import{reaction as I}from"mobx";import{createRoot as V}from"react-dom/client";import{install as $}from"resize-observer";import M from"./components/Layout";import{LANG_KEY as _,MAX_ROUTE_WAYPOINTS as d,PATHWAY_KEY as j}from"./constants";import m from"./core/Rect";import{fpGeo as b}from"./data/fpGeo";import z from"./floorplan.loader";import{shouldLoadIntercom as G}from"./intercom";import{BoundsSchema as q,POISelectorsSchema as x,ZoomToOptionsSchema as E}from"./schemas/sdk.schemas";import{applyParameters as N,destroyHistory as Y,initRouting as H}from"./services/routing";import t from"./store";import{destroyUiHandlers as O}from"./store/init/init-ui";import{findBooth as P,Route as w,separateExternalIds as B}from"./store/RouteStore";import{destroyGtag as X,GaEventActions as v,sendEventToGa as F,setConsentSettings as U}from"./tools/gtag";import D from"./tools/report-error";import{resetGlobalVariables as K}from"./tools/reset";import W from"./tools/track-event";import{getStorage as A}from"./utils/entity-storage";import{convertLocalToGps as Q,isValidPointCoords as y}from"./utils/gps";import{getLocales as Z,hasLocale as J}from"./utils/i18n";import{mapEntity as p}from"./utils/mapEntity";import{optimizeWaypointOrder as ee}from"./wayfinding/core/routing/optimizeWaypointOrder";const S=R("efp:api");$();export default class te extends z{root;init(){this.ignoreQuery||H(this.offHistory),W("load"),t.fp=this,U(this.allowConsent),F(v.Load,""),this.root=V(this.renderTarget),this.root.render(g(T,{children:g(M,{offHistory:this.offHistory,allowConsent:this.allowConsent})})),F(v.Rendered,""),I(()=>t.layerStore.layersLoaded,()=>{this.resolveReady(),t.initialized||this.onInit?.(this),t.initialized=!0});const e=G(window.__data);e&&import("./intercom/bootIntercom").then(({bootIntercom:o})=>o(e)).catch(()=>{})}selectBooth(e){if(typeof e!="string"&&!Array.isArray(e)){a("selectBooth","Parameter must be a string or an array of strings.","EFP000000");return}const o=t.boothStore.booths.filter(i=>typeof e=="string"?i.name===e||i.externalId===e:e.includes(i.name)||e.includes(i.externalId));t.selectBooth(o)}selectExhibitor(e){if(typeof e!="string"&&!Array.isArray(e)){a("selectExhibitor","Parameter must be a string or an array of strings.","EFP000100");return}if(!e?.length){t.uiState.menu=!1,t.searchStore.resetSearchBox(),t.uiState.details=null;return}const o=t.exhibitorStore.exhibitors.filter(s=>typeof e=="string"?s.name===e||s.externalId===e:e.includes(s.name)||e.includes(s.externalId));if(!o?.length)return;if(typeof e=="string"){t.selectExhibitor(o[0]),t.moveToList([o[0]]);return}const i=o.flatMap(s=>s.booths.map(r=>r.layer)),{description:n}=i.reduce((s,r)=>(s.freq[r.description]=(s.freq[r.description]||0)+1,s.freq[r.description]>s.maxCount&&(s.maxCount=s.freq[r.description],s.mostFrequent=r),s),{freq:{},mostFrequent:i[0],maxCount:0}).mostFrequent;t.layerStore.updateVisibility(n,!0),t.uiState.menu=!1,t.searchStore.resetSearchBox(),t.uiState.details=null,t.uiState.list={type:"filter",items:o,query:{key:"exhibitors",value:o.map(s=>s.externalId).join(",")}},t.moveToList()}highlightExhibitors(e){Array.isArray(e)||a("highlightExhibitors","Parameter must be an array of strings.","EFP000200"),t.boothStore.highlightedByExternalIds=[],t.exhibitorStore.highlightedByExternalIds=[...e]}highlightBooths(e){Array.isArray(e)||a("highlightBooths","Parameter must be an array of strings.","EFP000300"),t.exhibitorStore.highlightedByExternalIds=[],t.boothStore.highlightedByExternalIds=[...e]}highlightEntities(e){Array.isArray(e)||a("highlightEntities","Parameter must be an array of strings.","EFP000400");const{boothExternalIds:o,exhibitorExternalIds:i}=B(e);t.boothStore.highlightedByExternalIds=[...o],t.exhibitorStore.highlightedByExternalIds=[...i]}selectRoute(e,o){if(Array.isArray(e)){let i=[...e];const n=i.shift(),s=i.pop();if(i.length>d)throw new Error(`The maximum number of waypoints is ${d}.`);if(!n||!s){a("selectRoute","Invalid route format: When providing an array, it must include at least two points: a start and a destination.","EFP000401");return}t.routeStore.selectRoute(new w(f(n),f(s),i.map(f)));return}e||a("selectRoute","At a minimum, the starting point must be passed.","EFP000402"),t.routeStore.selectRoute(new w(f(e),f(o)))}getOptimizedRoutes(e){if(!Array.isArray(e))return a("getOptimizedRoutes","Parameter must be an array.","EFP000500"),[];if(e.length>d)throw new Error(`The maximum number of waypoints is ${d}.`);const o=e.map(f).filter(n=>!!n);if(!o.length)throw new Error("No booths found for the provided waypoints.");const i=new Map;for(const n of o){const s=n.layer?.name??"",r=i.get(s);r?r.push(n):i.set(s,[n])}return Array.from(i.values()).map(n=>({waypoints:ee(n.map(s=>[s.name,{cx:s.rect.cx,cy:s.rect.cy}]))}))}selectCurrentPosition(e,o,i){const n=y(e.x)&&y(e.y),s=y(e.lng)&&y(e.lat);!n&&!s&&a("selectCurrentPosition","A point must be passed. Either (x,y) or (lat,lng) are required.","EFP000600"),t.routeStore.selectCurrentPosition(e,o,i),this.onCurrentPositionChanged?.(e)}setBookmarks(e){(!Array.isArray(e)||!e.length)&&a("setBookmarks","Parameter must be an array.","EFP000700"),e.forEach(o=>{const i=t.exhibitorStore.exhibitors.find(n=>n.name===o.name||n.externalId===o.externalId);i&&(i.bookmarked=o.bookmarked)})}setEntitiesBookmarks(e){if(!Array.isArray(e)||!e.length){a("setEntitiesBookmarks","Parameter must be an array.","EFP000701");return}const o=["exhibitor","event","speaker","booth"],i=e.find(r=>!r.type||!o.includes(r.type));if(i){a("setEntitiesBookmarks",`Invalid entity type: ${i.type}. Must be one of: ${o.join(", ")}.`,"EFP000702");return}const n=A("bookmarked"),s={exhibitor:{existingIds:new Set(n.exhibitors||[]),finder:r=>t.exhibitorStore.findExhibitor(r),replacer:r=>t.exhibitorStore.replaceBookmarked(r)},event:{existingIds:new Set(n.events||[]),finder:r=>t.eventStore.findByNameOrSlug(r),replacer:r=>t.eventStore.replaceBookmarked(r)},speaker:{existingIds:new Set(n.speakers||[]),finder:r=>t.speakerStore.speakers.find(l=>l.name===r||l.externalId===r||l.slug===r),replacer:r=>t.speakerStore.replaceBookmarked(r)},booth:{existingIds:new Set(n.booths||[]),finder:r=>{const l=t.boothStore.findBooth(r);return l?.exhibitors.length===0?l:void 0},replacer:r=>t.boothStore.replaceBookmarked(r)}};e.forEach(r=>{const l=s[r.type],h=r.name||r.externalId||"",c=l.finder(h);c?r.bookmarked?l.existingIds.add(c.id):l.existingIds.delete(c.id):console.warn(`Entity not found: ${r.type} with query "${h}"`)}),Object.values(s).forEach(r=>{r.replacer(Array.from(r.existingIds))})}setEntitiesVisited(e){if(!Array.isArray(e)||!e.length){a("setEntitiesVisited","Parameter must be an array.","EFP000703");return}const o=["exhibitor","event"],i=e.find(r=>!r.type||!o.includes(r.type));if(i){a("setEntitiesVisited",`Invalid entity type: ${i.type}. Must be one of: ${o.join(", ")}.`,"EFP000704");return}const n=A("visited"),s={exhibitor:{existingIds:new Set(n.exhibitors||[]),finder:r=>t.exhibitorStore.findExhibitor(r),replacer:r=>t.exhibitorStore.replaceVisited(r)},event:{existingIds:new Set(n.events||[]),finder:r=>t.eventStore.findByNameOrSlug(r),replacer:r=>t.eventStore.replaceVisited(r)}};e.forEach(r=>{const l=s[r.type],h=r.name||r.externalId||"",c=l.finder(h);c?r.visited?l.existingIds.add(c.id):l.existingIds.delete(c.id):console.warn(`Entity not found: ${r.type} with query "${h}"`)}),Object.values(s).forEach(r=>{r.replacer(Array.from(r.existingIds))})}setMarkers(e){if(!e||!Array.isArray(e.icons)||!Array.isArray(e.markers)){a("setMarkers","Invalid input.","EFP000800");return}t.routeStore.setMarkers(e)}selectMarker(e,o=!0){return typeof e!="string"&&a("selectMarker","The identifier must be passed.","EFP000900"),t.routeStore.selectMarker(e,o)}drawCircles(e){Array.isArray(e)||a("drawCircles","Invalid input.","EFP000A00"),t.uiState.debugCircles=e}checkRoutes(){t.routeStore.checkRoutes()}updateLayerVisibility(e,o){typeof e!="string"&&a("updateLayerVisibility","The layer name (string) must be passed.","EFP000B00"),o||a("updateLayerVisibility","Passing a false value to visible will have no effect.","EFP000B01"),t.layerStore.updateVisibility(e,o)}getCenterCoordinates(){return t.fp.getCenterCoordinates()}exhibitorsList(){return t.exhibitorStore.exhibitors.map(e=>p(e))}boothsList(){return t.boothStore.booths.map(e=>p(e))}categoriesList(){return t.categoryStore.categories.map(e=>p(e))}selectCategory(e){if(e==null||typeof e!="string"){t.searchStore.selectSearch();return}const o=e?.toLowerCase(),i=t.categoryStore.categories.find(({name:n,slug:s})=>n?.toLowerCase()===o||s?.toLowerCase()===o);if(!i){a("selectCategory",`Category ${e} not found.`,"EFP000C01");return}t.selectCategory(i)}applyParameters(e){typeof e!="string"&&a("applyParameters","A query string must be passed.","EFP000D00"),N(e)}getVisibility(){return t.uiState.visibility}setVisibility(e){(typeof e!="object"||!Object.keys(e).length)&&a("setVisibility","The parameter must be passed.","EFP000E00"),t.uiState.setVisibility(e)}findLocation(){t.routeStore.findLocation()}zoomIn(){t.uiState.zoomIn()}zoomOut(){t.uiState.zoomOut()}switchView(){t.maplibreStore.activateMaplibre()}zoomTo(e,o){S("zoomTo called with selectors=%O options=%O",e,o);const i=x.safeParse(e);if(!i.success){a("zoomTo",i.error.message,"EFP001600");return}const n=E.safeParse(o);if(!n.success){a("zoomTo",n.error.message,"EFP001601");return}const s=this.getBounds(e);s&&this.fitBounds(s,o)}getBounds(e){S("getBounds called with selectors=%O",e);const o=x.safeParse(e);if(!o.success){a("getBounds",o.error.message,"EFP001400");return}const i=[];if(e.booths?.forEach(s=>{let r;s.externalId?r=t.boothStore.boothByExternalId.get(s.externalId):s.name&&(r=t.boothStore.boothByName.get(s.name.toLowerCase())),r?.rect&&i.push(r.rect)}),e.exhibitors?.forEach(s=>{let r;s.externalId?r=t.exhibitorStore.exhibitorByExternalId.get(s.externalId):s.name&&(r=t.exhibitorStore.exhibitorByName.get(s.name.toLowerCase())),r?.booths?.forEach(l=>{l.rect&&i.push(l.rect)})}),i.length===0)return;const n=m.fromMultiple(i);return{leftTop:{x:n.x1,y:n.y1},rightBottom:{x:n.x2,y:n.y2}}}fitBounds(e,o){if(S("fitBounds called with bounds=%O options=%O",e,o),!e){t.uiState.fitBounds();return}const i=q.safeParse(e);if(!i.success){a("fitBounds",i.error.message,"EFP001500");return}const n=E.safeParse(o);if(!n.success){a("fitBounds",n.error.message,"EFP001501");return}let s;if(o?.padding){const r=o.padding;s=m.fromX1y1x2y2(e.leftTop.x-r,e.leftTop.y-r,e.rightBottom.x+r,e.rightBottom.y+r)}else s=m.fromX1y1x2y2(e.leftTop.x,e.leftTop.y,e.rightBottom.x,e.rightBottom.y);t.uiState.moveToRect=s}getBoothRect(e){return typeof e!="string"&&a("getBoothRect","A booth name must be passed.","EFP000F00"),P(e)?.rect}convertToGeo(e,o){if(!b?.properties?.config){a("convertToGeo","The coordinates cannot be converted because the GPS configuration is not defined.","EFP001000");return}if(!e||!o){a("convertToGeo","Both coordinates must be passed.","EFP001001");return}return Q(e,o,b.properties.config)}getGeoConfig(){const e=b?.properties?.config;return e?{bearing:e.bearing??0,p0:e.p0,p1:e.p1,p2:e.p2}:null}unstable_destroy(){let e=window.__efpElement.firstChild;K(),window.removeEventListener("__efpStyleLoad",this.efpStyleLoadHandler),window.removeEventListener("error",D),t.maplibreStore.dispose(),Y(),O(),X(),[...document.getElementsByTagName("script")].filter(i=>i.src.indexOf("/fp.svg")>-1||i.src.indexOf("/wf.data.js")>-1||i.src.indexOf("/data.js")>-1).forEach(i=>i.remove()),this.root.unmount(),e.remove()}search(e){return typeof e!="string"&&a("search","A search string must be passed.","EFP001100"),t.fuzzySearchEngineStore.loadEngine().then(()=>(t.searchStore.selectSearch(e),t.uiState.fuzzySearchItems.map(o=>({item:p(o.item),score:o.score}))))}getFloors(){return t.layerStore.floors.map(e=>({name:e.name,shortName:e.shortName,description:e.description,active:e.active,disabled:e.disabled,index:e.index}))}activateFloor(e){if(!e?.name&&e?.index==null){a("activateFloor","Invalid floorId. It must contain either a name or an index.","EFP001200");return}const o=this.getFloors();if(e.name){const i=o.find(n=>n.name===e.name||n.shortName===e.name);if(!i){a("activateFloor",`Floor with name "${e.name}" not found.`,"EFP001201");return}if(i.active)return;this.updateLayerVisibility(i.name,!0);return}if(e.index!==null){const i=o.find(s=>s.index===e.index),n=i?.name;if(!n){a("activateFloor",`Floor at index ${e.index} does not exist.`,"EFP001203");return}if(i.active)return;this.updateLayerVisibility(n,!0);return}}showPathway(e,o){const i=new URLSearchParams;if(i.set(j,e),o?.length){const{boothExternalIds:n,exhibitorExternalIds:s}=B(o);n.length>0&&i.set("booths",n.join(",")),s.length>0&&i.set("exhibitors",s.join(","))}this.applyParameters(i.toString())}showPathwayOnly(e,o){this.activateFloor({name:o}),t.layerStore.showPathWay(e),t.uiState.setPathwayOnlyMode(!0);const i=t.layerStore.findLayer(e),n=t.layerStore.findLayer(o),s=i?.rect||i?.viewbox?i:n;if(s?.rect||s?.viewbox){const r=s.viewbox??s.rect;t.uiState.moveToRect=m.fromX1y1x2y2(r.x1,r.y1,r.x2,r.y2)}}hidePathways(){this.highlightBooths([]),t.layerStore.hidePathways(),t.uiState.setPathwayOnlyMode(!1)}showSearch(){t.selectSearch("")}changeLanguage(e){const o=e?.toLowerCase?.();if(!J(o)){a("changeLanguage",`Language "${e}" was not found. Available languages: ${Z().map(n=>n.id).join(",")}`,"EFP001300");return}const i=new URLSearchParams;i.set(_,o),this.applyParameters(i.toString())}isGpsTrackingEnabled(){return t.routeStore.gpsEnabled}setGpsTrackingEnabled(e){t.routeStore.setGpsTrackingEnabled(e)}deselectCurrentPosition(){t.routeStore.selectCurrentPosition(null,!1)}deselectRoute(){t.routeStore.selectRoute(null),t.routeStore.setOnlyAccessible(!1)}reset(){this.selectBooth(""),this.selectExhibitor(""),this.selectCategory(),this.deselectCurrentPosition(),this.deselectRoute(),this.highlightEntities([]),t.uiState.kioskData&&t.resetCameraFn?t.resetCameraFn?.():this.fitBounds()}selectAccessibleRoute(e){t.routeStore.setOnlyAccessible(!0),this.selectRoute(e)}}function f(u){return typeof u=="string"?P(u):t.routeStore.getNearestBooth(u)}let k=0;function a(u,e,o){const i=`Error calling "${u}" SDK method.`,n=`${e.endsWith(".")?e:e+"."} More information at`;let s="https://js-sdk.expofp.com/api/packages";if(o&&(s+=`#error-${o}`),console.error(`${i} ${n} ${s}`),t.fp.disableRuntimeAlerts)return;t.uiState.setGlobalErrorMessage({title:i,body:C(L,{children:[n," ",g("a",{href:s,target:"_blank",rel:"noreferrer",children:s})]})}),clearTimeout(k);const r=8e3;k=window.setTimeout(()=>{const l=async()=>{t.uiState.globalErrorMessages.length>0&&(t.uiState.popGlobalErrorMessage(),await new Promise(h=>setTimeout(h,r/2)),l())};l()},r)}
|
|
1
|
+
import{jsx as g,Fragment as C,jsxs as T}from"react/jsx-runtime";import{Box as S}from"@expofp/geometry";import{ErrorBoundary as M}from"@sentry/react";import I from"debug";import{reaction as R}from"mobx";import{createRoot as V}from"react-dom/client";import{install as $}from"resize-observer";import z from"./components/Layout";import{LANG_KEY as j,MAX_ROUTE_WAYPOINTS as m,PATHWAY_KEY as G}from"./constants";import{fpGeo as x}from"./data/fpGeo";import q from"./floorplan.loader";import{shouldLoadIntercom as N}from"./intercom";import{BoundsSchema as O,POISelectorsSchema as E,ZoomToOptionsSchema as w}from"./schemas/sdk.schemas";import{applyParameters as _,destroyHistory as Y,initRouting as H}from"./services/routing";import r from"./store";import{destroyUiHandlers as U}from"./store/init/init-ui";import{findBooth as P,Route as v,separateExternalIds as B}from"./store/RouteStore";import{destroyGtag as D,GaEventActions as F,sendEventToGa as A,setConsentSettings as K}from"./tools/gtag";import W from"./tools/report-error";import{resetGlobalVariables as X}from"./tools/reset";import Q from"./tools/track-event";import{getStorage as k}from"./utils/entity-storage";import{convertLocalToGps as Z,isValidPointCoords as y}from"./utils/gps";import{getLocales as J,hasLocale as ee}from"./utils/i18n";import{mapEntity as p}from"./utils/mapEntity";import{optimizeWaypointOrder as te}from"./wayfinding/core/routing/optimizeWaypointOrder";const b=I("efp:api");$();export default class re extends q{root;init(){this.ignoreQuery||H(this.offHistory),Q("load"),r.fp=this,K(this.allowConsent),A(F.Load,""),this.root=V(this.renderTarget),this.root.render(g(M,{children:g(z,{offHistory:this.offHistory,allowConsent:this.allowConsent})})),A(F.Rendered,""),R(()=>r.layerStore.layersLoaded,()=>{this.resolveReady(),r.initialized||this.onInit?.(this),r.initialized=!0});const e=N(window.__data);e&&import("./intercom/bootIntercom").then(({bootIntercom:t})=>t(e)).catch(()=>{})}selectBooth(e){if(typeof e!="string"&&!Array.isArray(e)){a("selectBooth","Parameter must be a string or an array of strings.","EFP000000");return}const t=r.boothStore.booths.filter(i=>typeof e=="string"?i.name===e||i.externalId===e:e.includes(i.name)||e.includes(i.externalId));r.selectBooth(t)}selectExhibitor(e){if(typeof e!="string"&&!Array.isArray(e)){a("selectExhibitor","Parameter must be a string or an array of strings.","EFP000100");return}if(!e?.length){r.uiState.menu=!1,r.searchStore.resetSearchBox(),r.uiState.details=null;return}const t=r.exhibitorStore.exhibitors.filter(o=>typeof e=="string"?o.name===e||o.externalId===e:e.includes(o.name)||e.includes(o.externalId));if(!t?.length)return;if(typeof e=="string"){r.selectExhibitor(t[0]),r.moveToList([t[0]]);return}const i=t.flatMap(o=>o.booths.map(s=>s.layer)),{description:n}=i.reduce((o,s)=>(o.freq[s.description]=(o.freq[s.description]||0)+1,o.freq[s.description]>o.maxCount&&(o.maxCount=o.freq[s.description],o.mostFrequent=s),o),{freq:{},mostFrequent:i[0],maxCount:0}).mostFrequent;r.layerStore.updateVisibility(n,!0),r.uiState.menu=!1,r.searchStore.resetSearchBox(),r.uiState.details=null,r.uiState.list={type:"filter",items:t,query:{key:"exhibitors",value:t.map(o=>o.externalId).join(",")}},r.moveToList()}highlightExhibitors(e){Array.isArray(e)||a("highlightExhibitors","Parameter must be an array of strings.","EFP000200"),r.boothStore.highlightedByExternalIds=[],r.exhibitorStore.highlightedByExternalIds=[...e]}highlightBooths(e){Array.isArray(e)||a("highlightBooths","Parameter must be an array of strings.","EFP000300"),r.exhibitorStore.highlightedByExternalIds=[],r.boothStore.highlightedByExternalIds=[...e]}highlightEntities(e){Array.isArray(e)||a("highlightEntities","Parameter must be an array of strings.","EFP000400");const{boothExternalIds:t,exhibitorExternalIds:i}=B(e);r.boothStore.highlightedByExternalIds=[...t],r.exhibitorStore.highlightedByExternalIds=[...i]}selectRoute(e,t){if(Array.isArray(e)){let i=[...e];const n=i.shift(),o=i.pop();if(i.length>m)throw new Error(`The maximum number of waypoints is ${m}.`);if(!n||!o){a("selectRoute","Invalid route format: When providing an array, it must include at least two points: a start and a destination.","EFP000401");return}r.routeStore.selectRoute(new v(d(n),d(o),i.map(d)));return}e||a("selectRoute","At a minimum, the starting point must be passed.","EFP000402"),r.routeStore.selectRoute(new v(d(e),d(t)))}getOptimizedRoutes(e){if(!Array.isArray(e))return a("getOptimizedRoutes","Parameter must be an array.","EFP000500"),[];if(e.length>m)throw new Error(`The maximum number of waypoints is ${m}.`);const t=e.map(d).filter(n=>!!n);if(!t.length)throw new Error("No booths found for the provided waypoints.");const i=new Map;for(const n of t){const o=n.layer?.name??"",s=i.get(o);s?s.push(n):i.set(o,[n])}return Array.from(i.values()).map(n=>({waypoints:te(n.map(o=>[o.name,{cx:o.rect.center.x,cy:o.rect.center.y}]))}))}selectCurrentPosition(e,t,i){const n=y(e.x)&&y(e.y),o=y(e.lng)&&y(e.lat);!n&&!o&&a("selectCurrentPosition","A point must be passed. Either (x,y) or (lat,lng) are required.","EFP000600"),r.routeStore.selectCurrentPosition(e,t,i),this.onCurrentPositionChanged?.(e)}setBookmarks(e){(!Array.isArray(e)||!e.length)&&a("setBookmarks","Parameter must be an array.","EFP000700"),e.forEach(t=>{const i=r.exhibitorStore.exhibitors.find(n=>n.name===t.name||n.externalId===t.externalId);i&&(i.bookmarked=t.bookmarked)})}setEntitiesBookmarks(e){if(!Array.isArray(e)||!e.length){a("setEntitiesBookmarks","Parameter must be an array.","EFP000701");return}const t=["exhibitor","event","speaker","booth"],i=e.find(s=>!s.type||!t.includes(s.type));if(i){a("setEntitiesBookmarks",`Invalid entity type: ${i.type}. Must be one of: ${t.join(", ")}.`,"EFP000702");return}const n=k("bookmarked"),o={exhibitor:{existingIds:new Set(n.exhibitors||[]),finder:s=>r.exhibitorStore.findExhibitor(s),replacer:s=>r.exhibitorStore.replaceBookmarked(s)},event:{existingIds:new Set(n.events||[]),finder:s=>r.eventStore.findByNameOrSlug(s),replacer:s=>r.eventStore.replaceBookmarked(s)},speaker:{existingIds:new Set(n.speakers||[]),finder:s=>r.speakerStore.speakers.find(h=>h.name===s||h.externalId===s||h.slug===s),replacer:s=>r.speakerStore.replaceBookmarked(s)},booth:{existingIds:new Set(n.booths||[]),finder:s=>{const h=r.boothStore.findBooth(s);return h?.exhibitors.length===0?h:void 0},replacer:s=>r.boothStore.replaceBookmarked(s)}};e.forEach(s=>{const h=o[s.type],c=s.name||s.externalId||"",u=h.finder(c);u?s.bookmarked?h.existingIds.add(u.id):h.existingIds.delete(u.id):console.warn(`Entity not found: ${s.type} with query "${c}"`)}),Object.values(o).forEach(s=>{s.replacer(Array.from(s.existingIds))})}setEntitiesVisited(e){if(!Array.isArray(e)||!e.length){a("setEntitiesVisited","Parameter must be an array.","EFP000703");return}const t=["exhibitor","event"],i=e.find(s=>!s.type||!t.includes(s.type));if(i){a("setEntitiesVisited",`Invalid entity type: ${i.type}. Must be one of: ${t.join(", ")}.`,"EFP000704");return}const n=k("visited"),o={exhibitor:{existingIds:new Set(n.exhibitors||[]),finder:s=>r.exhibitorStore.findExhibitor(s),replacer:s=>r.exhibitorStore.replaceVisited(s)},event:{existingIds:new Set(n.events||[]),finder:s=>r.eventStore.findByNameOrSlug(s),replacer:s=>r.eventStore.replaceVisited(s)}};e.forEach(s=>{const h=o[s.type],c=s.name||s.externalId||"",u=h.finder(c);u?s.visited?h.existingIds.add(u.id):h.existingIds.delete(u.id):console.warn(`Entity not found: ${s.type} with query "${c}"`)}),Object.values(o).forEach(s=>{s.replacer(Array.from(s.existingIds))})}setMarkers(e){if(!e||!Array.isArray(e.icons)||!Array.isArray(e.markers)){a("setMarkers","Invalid input.","EFP000800");return}r.routeStore.setMarkers(e)}selectMarker(e,t=!0){return typeof e!="string"&&a("selectMarker","The identifier must be passed.","EFP000900"),r.routeStore.selectMarker(e,t)}drawCircles(e){Array.isArray(e)||a("drawCircles","Invalid input.","EFP000A00"),r.uiState.debugCircles=e}checkRoutes(){r.routeStore.checkRoutes()}updateLayerVisibility(e,t){typeof e!="string"&&a("updateLayerVisibility","The layer name (string) must be passed.","EFP000B00"),t||a("updateLayerVisibility","Passing a false value to visible will have no effect.","EFP000B01"),r.layerStore.updateVisibility(e,t)}getCenterCoordinates(){return r.fp.getCenterCoordinates()}exhibitorsList(){return r.exhibitorStore.exhibitors.map(e=>p(e))}boothsList(){return r.boothStore.booths.map(e=>p(e))}categoriesList(){return r.categoryStore.categories.map(e=>p(e))}selectCategory(e){if(e==null||typeof e!="string"){r.searchStore.selectSearch();return}const t=e?.toLowerCase(),i=r.categoryStore.categories.find(({name:n,slug:o})=>n?.toLowerCase()===t||o?.toLowerCase()===t);if(!i){a("selectCategory",`Category ${e} not found.`,"EFP000C01");return}r.selectCategory(i)}applyParameters(e){typeof e!="string"&&a("applyParameters","A query string must be passed.","EFP000D00"),_(e)}getVisibility(){return r.uiState.visibility}setVisibility(e){(typeof e!="object"||!Object.keys(e).length)&&a("setVisibility","The parameter must be passed.","EFP000E00"),r.uiState.setVisibility(e)}findLocation(){r.routeStore.findLocation()}zoomIn(){r.uiState.zoomIn()}zoomOut(){r.uiState.zoomOut()}switchView(){r.maplibreStore.activateMaplibre()}zoomTo(e,t){b("zoomTo called with selectors=%O options=%O",e,t);const i=E.safeParse(e);if(!i.success){a("zoomTo",i.error.message,"EFP001600");return}const n=w.safeParse(t);if(!n.success){a("zoomTo",n.error.message,"EFP001601");return}const o=this.getBounds(e);o&&this.fitBounds(o,t)}getBounds(e){b("getBounds called with selectors=%O",e);const t=E.safeParse(e);if(!t.success){a("getBounds",t.error.message,"EFP001400");return}const i=[];if(e.booths?.forEach(o=>{let s;o.externalId?s=r.boothStore.boothByExternalId.get(o.externalId):o.name&&(s=r.boothStore.boothByName.get(o.name.toLowerCase())),s?.rect&&i.push(s.rect)}),e.exhibitors?.forEach(o=>{let s;o.externalId?s=r.exhibitorStore.exhibitorByExternalId.get(o.externalId):o.name&&(s=r.exhibitorStore.exhibitorByName.get(o.name.toLowerCase())),s?.booths?.forEach(h=>{h.rect&&i.push(h.rect)})}),i.length===0)return;const n=S.fromUnion(...i);return{leftTop:{x:n.min.x,y:n.min.y},rightBottom:{x:n.max.x,y:n.max.y}}}fitBounds(e,t){if(b("fitBounds called with bounds=%O options=%O",e,t),!e){r.uiState.fitBounds();return}const i=O.safeParse(e);if(!i.success){a("fitBounds",i.error.message,"EFP001500");return}const n=w.safeParse(t);if(!n.success){a("fitBounds",n.error.message,"EFP001501");return}const o=S.fromMinMax({x:e.leftTop.x,y:e.leftTop.y},{x:e.rightBottom.x,y:e.rightBottom.y});r.uiState.moveToRect=t?.padding?o.expand(t.padding):o}getBoothRect(e){typeof e!="string"&&a("getBoothRect","A booth name must be passed.","EFP000F00");const t=P(e)?.rect;return t?l.fromBox(t):void 0}convertToGeo(e,t){if(!x?.properties?.config){a("convertToGeo","The coordinates cannot be converted because the GPS configuration is not defined.","EFP001000");return}if(!e||!t){a("convertToGeo","Both coordinates must be passed.","EFP001001");return}return Z(e,t,x.properties.config)}getGeoConfig(){const e=x?.properties?.config;return e?{bearing:e.bearing??0,p0:e.p0,p1:e.p1,p2:e.p2}:null}unstable_destroy(){let e=window.__efpElement.firstChild;X(),window.removeEventListener("__efpStyleLoad",this.efpStyleLoadHandler),window.removeEventListener("error",W),r.maplibreStore.dispose(),Y(),U(),D(),[...document.getElementsByTagName("script")].filter(i=>i.src.indexOf("/fp.svg")>-1||i.src.indexOf("/wf.data.js")>-1||i.src.indexOf("/data.js")>-1).forEach(i=>i.remove()),this.root.unmount(),e.remove()}search(e){return typeof e!="string"&&a("search","A search string must be passed.","EFP001100"),r.fuzzySearchEngineStore.loadEngine().then(()=>(r.searchStore.selectSearch(e),r.uiState.fuzzySearchItems.map(t=>({item:p(t.item),score:t.score}))))}getFloors(){return r.layerStore.floors.map(e=>({name:e.name,shortName:e.shortName,description:e.description,active:e.active,disabled:e.disabled,index:e.index}))}activateFloor(e){if(!e?.name&&e?.index==null){a("activateFloor","Invalid floorId. It must contain either a name or an index.","EFP001200");return}const t=this.getFloors();if(e.name){const i=t.find(n=>n.name===e.name||n.shortName===e.name);if(!i){a("activateFloor",`Floor with name "${e.name}" not found.`,"EFP001201");return}if(i.active)return;this.updateLayerVisibility(i.name,!0);return}if(e.index!==null){const i=t.find(o=>o.index===e.index),n=i?.name;if(!n){a("activateFloor",`Floor at index ${e.index} does not exist.`,"EFP001203");return}if(i.active)return;this.updateLayerVisibility(n,!0);return}}showPathway(e,t){const i=new URLSearchParams;if(i.set(G,e),t?.length){const{boothExternalIds:n,exhibitorExternalIds:o}=B(t);n.length>0&&i.set("booths",n.join(",")),o.length>0&&i.set("exhibitors",o.join(","))}this.applyParameters(i.toString())}showPathwayOnly(e,t){this.activateFloor({name:t}),r.layerStore.showPathWay(e),r.uiState.setPathwayOnlyMode(!0);const i=r.layerStore.findLayer(e),n=r.layerStore.findLayer(t),o=i?.rect||i?.viewbox?i:n;if(o?.rect||o?.viewbox){const s=o.viewbox??o.rect;r.uiState.moveToRect=s.clone()}}hidePathways(){this.highlightBooths([]),r.layerStore.hidePathways(),r.uiState.setPathwayOnlyMode(!1)}showSearch(){r.selectSearch("")}changeLanguage(e){const t=e?.toLowerCase?.();if(!ee(t)){a("changeLanguage",`Language "${e}" was not found. Available languages: ${J().map(n=>n.id).join(",")}`,"EFP001300");return}const i=new URLSearchParams;i.set(j,t),this.applyParameters(i.toString())}isGpsTrackingEnabled(){return r.routeStore.gpsEnabled}setGpsTrackingEnabled(e){r.routeStore.setGpsTrackingEnabled(e)}deselectCurrentPosition(){r.routeStore.selectCurrentPosition(null,!1)}deselectRoute(){r.routeStore.selectRoute(null),r.routeStore.setOnlyAccessible(!1)}reset(){this.selectBooth(""),this.selectExhibitor(""),this.selectCategory(),this.deselectCurrentPosition(),this.deselectRoute(),this.highlightEntities([]),r.uiState.kioskData&&r.resetCameraFn?r.resetCameraFn?.():this.fitBounds()}selectAccessibleRoute(e){r.routeStore.setOnlyAccessible(!0),this.selectRoute(e)}}function d(f){return typeof f=="string"?P(f):r.routeStore.getNearestBooth(f)}let L=0;function a(f,e,t){const i=`Error calling "${f}" SDK method.`,n=`${e.endsWith(".")?e:e+"."} More information at`;let o="https://js-sdk.expofp.com/api/packages";if(t&&(o+=`#error-${t}`),console.error(`${i} ${n} ${o}`),r.fp.disableRuntimeAlerts)return;r.uiState.setGlobalErrorMessage({title:i,body:T(C,{children:[n," ",g("a",{href:o,target:"_blank",rel:"noreferrer",children:o})]})}),clearTimeout(L);const s=8e3;L=window.setTimeout(()=>{const h=async()=>{r.uiState.globalErrorMessages.length>0&&(r.uiState.popGlobalErrorMessage(),await new Promise(c=>setTimeout(c,s/2)),h())};h()},s)}class l{x1;y1;x2;y2;get h(){return Math.abs(this.y2-this.y1)}get w(){return Math.abs(this.x2-this.x1)}get cx(){return(this.x1+this.x2)/2}get cy(){return(this.y1+this.y2)/2}constructor(e,t,i,n){if(e>i){const o=e;e=i,i=o}if(t>n){const o=t;t=n,n=o}this.x1=e,this.y1=t,this.x2=i,this.y2=n}static fromBox(e){return new l(e.min.x,e.min.y,e.max.x,e.max.y)}static fromCxcywh(e,t,i,n){return new l(e-i/2,t-n/2,e+i/2,t+n/2)}contains(e){return e.x1>=this.x1&&e.x2<=this.x2&&e.y1>=this.y1&&e.y2<=this.y2}intersects(e){const t=Math.max(this.x1,e.x1),i=Math.min(this.x2,e.x2),n=Math.max(this.y1,e.y1),o=Math.min(this.y2,e.y2);return i>=t&&o>=n}getIntersection(e){const t=Math.max(this.x1,e.x1),i=Math.min(this.x2,e.x2),n=Math.max(this.y1,e.y1),o=Math.min(this.y2,e.y2);return i>=t&&o>=n?new l(t,n,i,o):new l(0,0,0,0)}getRotated90(){return l.fromCxcywh(this.cx,this.cy,this.h,this.w)}normalize(e,t){return new l(this.x1/e,this.y1/t,this.x2/e,this.y2/t)}withPadding(e,t=e){return this.w<e*2||this.h<t*2?this:l.fromCxcywh(this.cx,this.cy,this.w-e*2,this.h-t*2)}scale(e){return new l(this.x1*e,this.y1*e,this.x2*e,this.y2*e)}getArea(){return this.w*this.h}clone(){return new l(this.x1,this.y1,this.x2,this.y2)}translate(e,t){return this.x1+=e,this.x2+=e,this.y1+=t,this.y2+=t,this}equals(e){return e.x1===this.x1&&e.x2===this.x2&&e.y1===this.y1&&e.y2===this.y2}toString(){return this.x1+","+this.y1+","+this.w+","+this.h}containsPoint(e,t){return e>=this.x1&&e<=this.x2&&t>=this.y1&&t<=this.y2}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Rect } from '
|
|
1
|
+
import { Rect } from '@expofp/geometry';
|
|
2
2
|
export declare function createCircleCanvas(radius: number, color: string): HTMLCanvasElement;
|
|
3
3
|
export declare function createBookmarkCanvas(maxSizePx: number, pixelRatio: number): HTMLCanvasElement;
|
|
4
4
|
export declare function getBounds(x: number, y: number, width: number, height: number, scale?: number, rotate?: number): Rect;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Rect as
|
|
1
|
+
import{Rect as d}from"@expofp/geometry";const r=new Map;export function createCircleCanvas(i,n){const c=n.toUpperCase();if(!r.has(c)){const t=document.createElement("canvas"),a=i*2*devicePixelRatio+1*2;t.width=a,t.height=a;const s=t.getContext("2d");s.fillStyle=n,s.beginPath(),s.arc(a/2,a/2,i*devicePixelRatio,0,2*Math.PI),s.fill(),r.set(c,t)}return r.get(c)}const h=new Map;export function createBookmarkCanvas(i,n){const c=i;if(h.has(c))return h.get(c);const t=i,o=t*1.4,a=Math.ceil(t*n),s=Math.ceil(o*n),l=document.createElement("canvas");l.width=a,l.height=s;const e=l.getContext("2d");return e.scale(n,n),e.fillStyle="#fdbf2b",e.strokeStyle="#fff",e.lineWidth=4/n,e.beginPath(),e.moveTo(0,0),e.lineTo(0,o),e.lineTo(t/2,o-t/2),e.lineTo(t,o),e.lineTo(t,0),e.lineTo(0,0),e.fill(),e.stroke(),h.set(c,l),l}export function getBounds(i,n,c,t,o=1,a){const s=c*o,l=t*o;return new d({x:i,y:n},{x:s,y:l},a)}
|
|
@@ -1,8 +1,27 @@
|
|
|
1
|
-
import { ImageDef, ImageSource, LayerDef, LineDef, Polygon, Rect, ShapeDef, TextAlignment, TextDef, TextLineDef, RenderableDefCollection, SceneDef, PointWithinSceneData, Vector2Like } from '@expofp/renderer';
|
|
1
|
+
import { ImageDef, ImageSource, LayerDef, LineDef, Polygon as RendererPolygon, Rect as RendererRect, ShapeDef, TextAlignment, TextDef, TextLineDef, RenderableDefCollection, SceneDef, PointWithinSceneData, Vector2Like } from '@expofp/renderer';
|
|
2
|
+
import { Box, Polygon, Rect } from '@expofp/geometry';
|
|
2
3
|
import { MeshType, Line, TextLines, DefOptions } from './types';
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Converts a geometry {@link Box} (axis-aligned, no rotation) to a renderer
|
|
6
|
+
* {@link RendererRect}. Preserves min/max exactly; rotation is always 0.
|
|
7
|
+
*/
|
|
8
|
+
export declare function boxToRenderer(box: Box): RendererRect;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a geometry {@link Rect} (center + size + rotation + elevation) to a
|
|
11
|
+
* renderer {@link RendererRect}. The renderer Rect is constructed from
|
|
12
|
+
* unrotated min/max corners derived from `center` ± `size/2`; rotation passes
|
|
13
|
+
* through unchanged (both packages share positive = clockwise, y-down).
|
|
14
|
+
*/
|
|
15
|
+
export declare function rectToRenderer(rect: Rect): RendererRect;
|
|
16
|
+
/**
|
|
17
|
+
* Converts a geometry {@link Polygon} to a renderer {@link RendererPolygon}.
|
|
18
|
+
* Vertices are mapped to `{ x, y, z }` triples (z = polygon elevation);
|
|
19
|
+
* indices are passed through unchanged.
|
|
20
|
+
*/
|
|
21
|
+
export declare function polygonToRenderer(polygon: Polygon): RendererPolygon;
|
|
22
|
+
export declare function rectToShapeDef(rect: SVGRectElement, color?: string): ShapeDef;
|
|
4
23
|
export declare function meshToShapeDef(mesh: MeshType, color: string): ShapeDef;
|
|
5
|
-
export declare function createShapeDef(shape:
|
|
24
|
+
export declare function createShapeDef(shape: Box | Rect | Polygon, color?: string): ShapeDef;
|
|
6
25
|
export declare function createImageDef(source: ImageSource, bounds: Rect, options?: DefOptions & {
|
|
7
26
|
origin?: [number, number];
|
|
8
27
|
}): ImageDef;
|
|
@@ -10,7 +29,7 @@ export declare function createTextDef(textLines: TextLineDef[], bounds: Rect, pa
|
|
|
10
29
|
export declare function createTextDefLines(textLines: TextLines, color: string, fontSize: number, fontUrl?: [string, string]): TextLineDef[];
|
|
11
30
|
export declare function createLineDef({ p0, p1 }: Line, color?: string, width?: number): LineDef;
|
|
12
31
|
export declare function createLayerDef(name: string, children: RenderableDefCollection, options?: DefOptions): LayerDef;
|
|
13
|
-
export declare function createSceneDef(layers: LayerDef[], viewboxRect:
|
|
32
|
+
export declare function createSceneDef(layers: LayerDef[], viewboxRect: Box | SVGRectElement, background?: string, memoryLimit?: number): SceneDef;
|
|
14
33
|
export declare function createShapeDot(rect: Rect, color?: string, radius?: number): ImageDef;
|
|
15
34
|
export declare function isDefaultScene(sceneId: string | undefined): boolean;
|
|
16
35
|
export declare function pickDefaultScene(data: PointWithinSceneData[]): PointWithinSceneData;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{Polygon as
|
|
2
|
-
`),fontUrl:r[0]||
|
|
3
|
-
`),fontUrl:r[1]||
|
|
1
|
+
import{Polygon as s,Rect as c}from"@expofp/renderer";import{Box as a,Polygon as d,Rect as x,isBox as u,isPolygon as l,isRect as p}from"@expofp/geometry";import{createCircleCanvas as y}from"./canvases";import{DEFAULT_FONT_LIGHT_URL as w,DEFAULT_FONT_URL as m}from"./fonts";export function boxToRenderer(e){return new c(e.min,e.max,0)}export function rectToRenderer(e){const n=e.size.x/2,t=e.size.y/2,r={x:e.center.x-n,y:e.center.y-t},o={x:e.center.x+n,y:e.center.y+t};return new c(r,o,e.rotation,e.elevation)}export function polygonToRenderer(e){const n=e.elevation,t=e.vertices.map(o=>({x:o.x,y:o.y,z:n})),r=e.indices;return new s(t,r)}export function rectToShapeDef(e,n){return createShapeDef(a.fromSvg(e),n)}export function meshToShapeDef(e,n){if(!e)throw new Error("Create ShapeDef: mesh is not provided");const t=e.positions.map(i=>({x:i[0],y:Math.abs(i[1])})),r=e.cells,o=new d(t,r);return createShapeDef(o,n)}export function createShapeDef(e,n="#000"){let t=e;if(e&&u(e)?t=boxToRenderer(e):e&&p(e)?t=rectToRenderer(e):e&&l(e)&&(t=polygonToRenderer(e)),!t||!(t instanceof s||t instanceof c))throw new Error("Invalid shape definition");return{shape:t,color:n}}export function createImageDef(e,n,t){if(!e)throw new Error("Image source is not provided");const r=rectToRenderer(n);return{source:e,bounds:r,...t}}export function createTextDef(e,n,t,r,o){if(e.length===0)throw new Error("Invalid text lines");const i=rectToRenderer(n);return{lines:e,bounds:i,padding:t,alignment:r,...o}}export function createTextDefLines(e,n,t,r=[void 0,void 0]){const[o,i]=e,f=[{text:o.join(`
|
|
2
|
+
`),fontUrl:r[0]||m,color:n,fontSize:t}];return i.length&&f.push({text:i.join(`
|
|
3
|
+
`),fontUrl:r[1]||w,color:n,fontSize:t}),f}export function createLineDef({p0:e,p1:n},t="#000",r=10){if(!(e?.x&&e.y||n?.x&&n.y))throw new Error("Line data is invalid");return{points:[{x:e.x,y:e.y},{x:n.x,y:n.y}],color:t,width:r}}export function createLayerDef(e,n,t){if(!e)throw new Error("Layer name is required");return n||(n=[]),{name:e,children:n,...t}}export function createSceneDef(e,n,t,r){let o;return n instanceof SVGRectElement?o=c.fromSvg(n):u(n)&&(o=boxToRenderer(n)),{rootLayer:createLayerDef("root",e),background:t,viewbox:o,memoryLimit:r}}export function createShapeDot(e,n="#000",t=1.5){const r=y(t,n),o=new x(e.center,{x:r.width,y:r.height},e.rotation);return createImageDef(r,o)}export function isDefaultScene(e){return e===void 0}export function pickDefaultScene(e){const n=e.find(t=>isDefaultScene(t.sceneId));if(!n)throw new Error("Default scene not found");return n}export function pickDefaultScenePoint(e){const n=e.find(t=>isDefaultScene(t.sceneId));if(!n)throw new Error("Default scene point not found");return n.point}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ImageDef
|
|
1
|
+
import { ImageDef } from '@expofp/renderer';
|
|
2
2
|
export type VerticesType = {
|
|
3
3
|
x: number;
|
|
4
4
|
y: number;
|
|
@@ -32,8 +32,19 @@ export interface PathInfo {
|
|
|
32
32
|
color: string;
|
|
33
33
|
unblinking?: boolean;
|
|
34
34
|
}
|
|
35
|
+
export type ParentRectLike = {
|
|
36
|
+
readonly center: {
|
|
37
|
+
readonly x: number;
|
|
38
|
+
readonly y: number;
|
|
39
|
+
};
|
|
40
|
+
readonly size: {
|
|
41
|
+
readonly x: number;
|
|
42
|
+
readonly y: number;
|
|
43
|
+
};
|
|
44
|
+
readonly rotation: number;
|
|
45
|
+
};
|
|
35
46
|
export interface ImageDefWithParentBounds {
|
|
36
|
-
parentRect?:
|
|
47
|
+
parentRect?: ParentRectLike;
|
|
37
48
|
shape: ImageDef;
|
|
38
49
|
}
|
|
39
50
|
//# sourceMappingURL=types.d.ts.map
|