atriusmaps-node-sdk 3.3.951 → 3.3.952

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "3.3.951";
5
+ var version = "3.3.952";
6
6
  var pkg = {
7
7
  version: version};
8
8
 
@@ -159,12 +159,14 @@ async function create(app, config) {
159
159
  };
160
160
  app.bus.on("venueData/loadMap", async () => {
161
161
  venueDataLoaded.then(async (venueData) => {
162
- const mapStyleSource = await venueLoadingUtils.fetchStyleDoc(venueData.baseVenueId);
163
- const mapTheme = await venueData.fetchJson(venueData.files.theme);
164
162
  const badgesSpriteUrl = venueData.files.spritesheet;
165
163
  const mapGlyphsUrl = venueData.files.glyphs;
166
164
  const { id, bounds, structures, venueCenter, venueRadius, defaultOrdinal } = venueData;
167
- const mapFeatures = venueData.venueList[id].mapTokens ? { [id]: [] } : await getMapFeatures(venueData).then(copyPOINames);
165
+ const [mapStyleSource, mapTheme, mapFeatures] = await Promise.all([
166
+ venueLoadingUtils.fetchStyleDoc(venueData.baseVenueId),
167
+ venueData.fetchJson(venueData.files.theme),
168
+ venueData.venueList[id].mapTokens ? Promise.resolve({ [id]: [] }) : getMapFeatures(venueData).then(copyPOINames)
169
+ ]);
168
170
  const venueBounds = {
169
171
  n: bounds.ne.lat,
170
172
  s: bounds.sw.lat,
@@ -1 +1 @@
1
- var a="3.3.951",e={version:a};export{e as default,a as version};
1
+ var a="3.3.952",e={version:a};export{e as default,a as version};
@@ -1 +1 @@
1
- import*as e from"ramda";import t from"zousan";import{fetchStyleDoc as a,normalizeCoords as n,getVenueDataFromUrls as s,buildStructures as r,createFetchJson as u,createFetchText as o}from"./venueLoadingUtils.js";async function i(i,d){const l=i.log.sublog("venueDataLoader");let c=new t,p=new t;const v=t=>t.defaultStructureId||e.path(["structureOrder",0],t)||e.path(["selectorOrder",0],t)||e.pipe(e.prop("structures"),Object.values,e.path([0,"id"]))(t),g=(e,t)=>e.split("").reduce((a,n,s)=>e.substring(0,s+1)===t.substring(0,s+1)?s:a,-1)+1,b=e=>((e,t)=>Object.values(e.venueList).filter(e=>e.locale===t).sort((t,a)=>g(a.id,e.id)-g(t.id,e.id)).at(0))(e,"en")?.id;async function f(t,a){t.assetStage&&"prod"!==t.assetStage&&location.hostname;const n=u(),d=o(),l=await s(t,n,a),{accountId:p,venueId:g}=t;return l.assetStage=t.assetStage,l.defaultOrdinal=l.defaultOrdinal||function(t){const a=v(t),n=Object.values(t.structures).find(e.propEq(a,"id"));return n.levels[n.defaultLevelId].ordinal}(l),l.structures=r(l),l.baseVenueId=b(l),l.getTranslatedContentPath=e=>`https://content.locuslabs.com/${l.category}/${e}/${g}/${p}`,l.fetchJson=n,l.fetchText=d,i.config.debug&&i.env.isBrowser&&(window._venueData=l),l.queueTypes&&(l.securityQueueTypes=(()=>{const e=l.queueTypes.find(e=>"SecurityLane"===e.id);return e?e.subtypes.map(e=>e.id):[]})()),i.bus.send("venueData/venueDataLoaded",{venueData:l}),c.resolve(l),c}function m(e){const t={id:"venueDataLoader"};return e.id!==d.venueId&&(t.vid=e.id),t.lang=i.i18n().language,"prod"!==e.assetStage&&(t.stage=e.assetStage),i.bus.send("deepLinking/notifyState",t),e}i.bus.on("debugTools/fileDrop",async({file:e,content:t})=>{if("application/json"===e.type){const e=JSON.parse(t);if(e.basemap&&e["basemap.venue"])return n=JSON.parse(t),void i.bus.send("map/replaceTheme",{theme:n});if(e.metadata&&e.metadata["mapbox:type"])return a=t,void i.bus.send("map/replaceStyle",{styleSrc:a})}var a,n});async function h(e){const t={...e},a=await i.bus.get("poi/getAll");return Object.values(t).forEach(e=>e.filter(e=>"poi"===e.properties.aiLayer&&"Point"===e.geometry.type).forEach(e=>{const t=a[e.properties.id];t?t.mapLabel?e.properties.text=t.mapLabel:!1!==d.copyPOINamesToMap&&(e.properties.text=function(e){let t=e.name;return d.poiMapNameXForm?(Object.keys(d.poiMapNameXForm).filter(t=>((e,t)=>e===t||0===e.indexOf(t+"."))(e.category,t)).forEach(e=>{d.poiMapNameXForm[e].forEach(e=>t=t.replace(new RegExp(e.replace),e.with))}),t):t}(t)):l.warn(`Unknown poi in style: ${e.properties.id}`)})),t}const y=(t,a,n,s)=>{const r=t.replace(/-[^-]*$/,""),u=r===n?"landscape-background":`ordinal: ${s.find(e.hasPath(["levels",t])).levels[t].ordinal}`;return a.map(a=>{var s,o,i;return s="properties",o={venueId:n,structureId:r,ordinalId:u,levelId:t},i=a,a=e.over(e.lensProp(s),t=>e.mergeRight(t||{},o),i),a=e.assoc("id",a.properties.subid,a)})};i.bus.on("venueData/loadMap",async()=>{c.then(async n=>{const s=await a(n.baseVenueId),r=await n.fetchJson(n.files.theme),u=n.files.spritesheet,o=n.files.glyphs,{id:l,bounds:c,structures:v,venueCenter:g,venueRadius:b,defaultOrdinal:f}=n,m=n.venueList[l].mapTokens?{[l]:[]}:await async function(a){return e.pipe(e.prop("structures"),e.map(e.prop("levels")),e.chain(e.keys),e.prepend(a.id),e.map(e=>a.files.geoJson.replace("${geoJsonId}",e)),e.map(a.fetchJson),e.map(e.andThen(e=>[e.id,y(e.id,e.features,a.id,a.structures)])),e=>t.all(e),e.andThen(e.fromPairs))(a)}(n).then(h),D={mapFeatures:m,mapStyleSource:s,mapTheme:r,badgesSpriteUrl:u,mapGlyphsUrl:o,structures:v,defaultOrdinal:f,venueBounds:{n:c.ne.lat,s:c.sw.lat,e:c.ne.lng,w:c.sw.lng},venueId:l,venueCenter:g,venueRadius:b,accountId:d.accountId,secure:void 0!==d.auth,tileServerAuthInfo:n.tileServerAuthInfo};p.resolve(D),i.bus.send("venueData/mapDataLoaded",D)})});const D=e=>null==e.shouldDisplay||e.shouldDisplay;i.bus.on("venueData/loadBuildingSelectorData",()=>c.then(async t=>{const a={buildings:t.structures.filter(D).map(e.evolve({levels:e.pipe(e.values,e.sortWith([e.descend(e.prop("ordinal"))]))})),structureOrder:t.structureOrder,selectorOrder:t.selectorOrder};return i.bus.send("venueData/buildingSelectorDataLoaded",a),a})),i.bus.on("venueData/normalizeCoords",({coords:e})=>c.then(t=>n(e,t.bounds)));const I={edges:[],nodes:[]};i.bus.on("venueData/loadNavGraph",async()=>c.then(async e=>{const t={navGraphData:e.files.nav?await e.fetchJson(e.files.nav):I,structures:e.structures};return i.bus.send("venueData/navGraphLoaded",t),t})),i.bus.on("venueData/loadPoiData",async()=>c.then(async e=>{const t=d.useOldDataModel?e.files.poisOld||e.files.pois:e.files.pois||e.files.poisOld;if(t){const a=await e.fetchJson(t);i.bus.send("venueData/poiDataLoaded",{pois:a,structures:e.structures})}})),i.bus.on("venueData/getVenueCenter",async()=>c.then(async e=>({lat:e.venueCenter[0],lng:e.venueCenter[1],ordinal:0}))),i.bus.on("venueData/getContentUrl",({type:e,name:t=""})=>c.then(a=>a.files[e]+t)),i.bus.on("venueData/getFloorIdToNameMap",()=>c.then(e.pipe(e.prop("structures"),e.map(e.prop("levels")),e.chain(e.values),e.map(e.props(["id","name"])),e.fromPairs))),i.bus.on("venueData/getFloorIdName",({floorId:t})=>c.then(async a=>{const n=e.pipe(e.values,e.find(e.hasPath(["levels",t])))(a.structures);return n?{structureId:n.id,structureName:n.name,floorName:n.levels[t].name}:null}));const w=(t,a)=>()=>c.then(e.pipe(e.prop(t),e.defaultTo(a)));function S(e,t){const a=O(t);if(a.includes(e))return e;const n=e.split("-").slice(1).join("-");return a.find(e=>new RegExp(`${t.baseVenueId}.?.?-${n}`).test(e))}i.bus.on("venueData/getVenueData",()=>c),i.bus.on("venueData/getVenueName",w("name")),i.bus.on("venueData/getVenueCategory",w("category")),i.bus.on("venueData/getVenueTimezone",w("tz")),i.bus.on("venueData/getAccountId",()=>d.accountId),i.bus.on("venueData/getVenueId",w("id")),i.bus.on("venueData/getPositioningSupported",w("positioningSupported")),i.bus.on("venueData/getStructures",w("structures")),i.bus.on("venueData/loadNewVenue",async({venueId:e,accountId:a,assetStage:n=d.assetStage})=>{c.reject(new Error("loadNewVenue called - previous loading ignored")),p.reject(new Error("loadNewVenue called - previous loading ignored")),c=new t,p=new t,f({...d,venueId:e,accountId:a,assetStage:n},[]).then(m)}),i.bus.on("venueData/getPoiImageUrl",({imageName:e,size:t})=>`https://img.locuslabs.com/resize/${d.accountId}/png/transparent/${t}contain/poi/${e}`),i.bus.on("venueData/getDistributionId",()=>c.then(e=>`${e.baseVenueId}-${d.accountId}`)),i.bus.on("venueData/getCustomKeywords",()=>c.then(e=>{const t=d.useOldDataModel&&e.files.searchOld||e.files.search;return e.fetchJson(t)})),i.bus.on("venueData/isGrabEnabled",w("enableGrab")),i.bus.on("venueData/getGrabPoiIds",w("grabPoiIds",[])),i.bus.on("venueData/getAssetsTimestamp",w("version")),i.bus.on("venueData/getTranslatedFloorId",async({floorId:e})=>c.then(t=>S(e,t)));const O=e=>e.structures.reduce((e,t)=>e.concat(Object.keys(t.levels)),[]);i.bus.on("venueData/getQueueTypes",()=>c.then(e=>{const t=["tsapre","clear","globalEntry"];return e.queueTypes?e.queueTypes.reduce((e,a)=>{const{id:n,subtypes:s}=a,r=s.map(e=>{const a=t.includes(e.id)&&`security-logo-${e.id.toLowerCase()}`;return{...e,imageId:a}});return e[n]=r,e},{}):{}}));return{init:async()=>{let e=[];null===new URLSearchParams("undefined"==typeof window?"":window.location.search).get("lang")&&(e="undefined"==typeof window?[]:navigator.languages);const t=d.deepLinkProps||{};t.lang&&e.unshift(t.lang);const a=t.vid||d.venueId,n=d.useDynamicUrlParams&&t.stage?t.stage:d.assetStage,s=t.accountId||("alpha"===n?"A1VPTJKREFJWX5":d.accountId);f({...d,venueId:a,accountId:s,assetStage:n},e).then(m)},runTest:async({testRoutine:e,reset:a=!1,venueData:n=null})=>{let s,r;return(a||n)&&(c=new t,p=new t),n&&(c=t.resolve(n)),await e(),c.v&&(s=await c),p.v&&(r=await p),{venueDataObj:s,mapDataObj:r}},internal:{calculateBaseVenueId:b,getDefaultStructureId:v,getTranslatedFloorId:S,setConfigProperty:(e,t)=>{d[e]=t}}}}export{i as create};
1
+ import*as e from"ramda";import t from"zousan";import{fetchStyleDoc as a,normalizeCoords as n,getVenueDataFromUrls as s,buildStructures as r,createFetchJson as o,createFetchText as u}from"./venueLoadingUtils.js";async function i(i,d){const l=i.log.sublog("venueDataLoader");let c=new t,p=new t;const v=t=>t.defaultStructureId||e.path(["structureOrder",0],t)||e.path(["selectorOrder",0],t)||e.pipe(e.prop("structures"),Object.values,e.path([0,"id"]))(t),g=(e,t)=>e.split("").reduce((a,n,s)=>e.substring(0,s+1)===t.substring(0,s+1)?s:a,-1)+1,b=e=>((e,t)=>Object.values(e.venueList).filter(e=>e.locale===t).sort((t,a)=>g(a.id,e.id)-g(t.id,e.id)).at(0))(e,"en")?.id;async function m(t,a){t.assetStage&&"prod"!==t.assetStage&&location.hostname;const n=o(),d=u(),l=await s(t,n,a),{accountId:p,venueId:g}=t;return l.assetStage=t.assetStage,l.defaultOrdinal=l.defaultOrdinal||function(t){const a=v(t),n=Object.values(t.structures).find(e.propEq(a,"id"));return n.levels[n.defaultLevelId].ordinal}(l),l.structures=r(l),l.baseVenueId=b(l),l.getTranslatedContentPath=e=>`https://content.locuslabs.com/${l.category}/${e}/${g}/${p}`,l.fetchJson=n,l.fetchText=d,i.config.debug&&i.env.isBrowser&&(window._venueData=l),l.queueTypes&&(l.securityQueueTypes=(()=>{const e=l.queueTypes.find(e=>"SecurityLane"===e.id);return e?e.subtypes.map(e=>e.id):[]})()),i.bus.send("venueData/venueDataLoaded",{venueData:l}),c.resolve(l),c}function f(e){const t={id:"venueDataLoader"};return e.id!==d.venueId&&(t.vid=e.id),t.lang=i.i18n().language,"prod"!==e.assetStage&&(t.stage=e.assetStage),i.bus.send("deepLinking/notifyState",t),e}i.bus.on("debugTools/fileDrop",async({file:e,content:t})=>{if("application/json"===e.type){const e=JSON.parse(t);if(e.basemap&&e["basemap.venue"])return n=JSON.parse(t),void i.bus.send("map/replaceTheme",{theme:n});if(e.metadata&&e.metadata["mapbox:type"])return a=t,void i.bus.send("map/replaceStyle",{styleSrc:a})}var a,n});async function h(e){const t={...e},a=await i.bus.get("poi/getAll");return Object.values(t).forEach(e=>e.filter(e=>"poi"===e.properties.aiLayer&&"Point"===e.geometry.type).forEach(e=>{const t=a[e.properties.id];t?t.mapLabel?e.properties.text=t.mapLabel:!1!==d.copyPOINamesToMap&&(e.properties.text=function(e){let t=e.name;return d.poiMapNameXForm?(Object.keys(d.poiMapNameXForm).filter(t=>((e,t)=>e===t||0===e.indexOf(t+"."))(e.category,t)).forEach(e=>{d.poiMapNameXForm[e].forEach(e=>t=t.replace(new RegExp(e.replace),e.with))}),t):t}(t)):l.warn(`Unknown poi in style: ${e.properties.id}`)})),t}async function y(a){return e.pipe(e.prop("structures"),e.map(e.prop("levels")),e.chain(e.keys),e.prepend(a.id),e.map(e=>a.files.geoJson.replace("${geoJsonId}",e)),e.map(a.fetchJson),e.map(e.andThen(e=>[e.id,D(e.id,e.features,a.id,a.structures)])),e=>t.all(e),e.andThen(e.fromPairs))(a)}const D=(t,a,n,s)=>{const r=t.replace(/-[^-]*$/,""),o=r===n?"landscape-background":`ordinal: ${s.find(e.hasPath(["levels",t])).levels[t].ordinal}`;return a.map(a=>{var s,u,i;return s="properties",u={venueId:n,structureId:r,ordinalId:o,levelId:t},i=a,a=e.over(e.lensProp(s),t=>e.mergeRight(t||{},u),i),a=e.assoc("id",a.properties.subid,a)})};i.bus.on("venueData/loadMap",async()=>{c.then(async e=>{const t=e.files.spritesheet,n=e.files.glyphs,{id:s,bounds:r,structures:o,venueCenter:u,venueRadius:l,defaultOrdinal:c}=e,[v,g,b]=await Promise.all([a(e.baseVenueId),e.fetchJson(e.files.theme),e.venueList[s].mapTokens?Promise.resolve({[s]:[]}):y(e).then(h)]),m={mapFeatures:b,mapStyleSource:v,mapTheme:g,badgesSpriteUrl:t,mapGlyphsUrl:n,structures:o,defaultOrdinal:c,venueBounds:{n:r.ne.lat,s:r.sw.lat,e:r.ne.lng,w:r.sw.lng},venueId:s,venueCenter:u,venueRadius:l,accountId:d.accountId,secure:void 0!==d.auth,tileServerAuthInfo:e.tileServerAuthInfo};p.resolve(m),i.bus.send("venueData/mapDataLoaded",m)})});const I=e=>null==e.shouldDisplay||e.shouldDisplay;i.bus.on("venueData/loadBuildingSelectorData",()=>c.then(async t=>{const a={buildings:t.structures.filter(I).map(e.evolve({levels:e.pipe(e.values,e.sortWith([e.descend(e.prop("ordinal"))]))})),structureOrder:t.structureOrder,selectorOrder:t.selectorOrder};return i.bus.send("venueData/buildingSelectorDataLoaded",a),a})),i.bus.on("venueData/normalizeCoords",({coords:e})=>c.then(t=>n(e,t.bounds)));const w={edges:[],nodes:[]};i.bus.on("venueData/loadNavGraph",async()=>c.then(async e=>{const t={navGraphData:e.files.nav?await e.fetchJson(e.files.nav):w,structures:e.structures};return i.bus.send("venueData/navGraphLoaded",t),t})),i.bus.on("venueData/loadPoiData",async()=>c.then(async e=>{const t=d.useOldDataModel?e.files.poisOld||e.files.pois:e.files.pois||e.files.poisOld;if(t){const a=await e.fetchJson(t);i.bus.send("venueData/poiDataLoaded",{pois:a,structures:e.structures})}})),i.bus.on("venueData/getVenueCenter",async()=>c.then(async e=>({lat:e.venueCenter[0],lng:e.venueCenter[1],ordinal:0}))),i.bus.on("venueData/getContentUrl",({type:e,name:t=""})=>c.then(a=>a.files[e]+t)),i.bus.on("venueData/getFloorIdToNameMap",()=>c.then(e.pipe(e.prop("structures"),e.map(e.prop("levels")),e.chain(e.values),e.map(e.props(["id","name"])),e.fromPairs))),i.bus.on("venueData/getFloorIdName",({floorId:t})=>c.then(async a=>{const n=e.pipe(e.values,e.find(e.hasPath(["levels",t])))(a.structures);return n?{structureId:n.id,structureName:n.name,floorName:n.levels[t].name}:null}));const S=(t,a)=>()=>c.then(e.pipe(e.prop(t),e.defaultTo(a)));function O(e,t){const a=T(t);if(a.includes(e))return e;const n=e.split("-").slice(1).join("-");return a.find(e=>new RegExp(`${t.baseVenueId}.?.?-${n}`).test(e))}i.bus.on("venueData/getVenueData",()=>c),i.bus.on("venueData/getVenueName",S("name")),i.bus.on("venueData/getVenueCategory",S("category")),i.bus.on("venueData/getVenueTimezone",S("tz")),i.bus.on("venueData/getAccountId",()=>d.accountId),i.bus.on("venueData/getVenueId",S("id")),i.bus.on("venueData/getPositioningSupported",S("positioningSupported")),i.bus.on("venueData/getStructures",S("structures")),i.bus.on("venueData/loadNewVenue",async({venueId:e,accountId:a,assetStage:n=d.assetStage})=>{c.reject(new Error("loadNewVenue called - previous loading ignored")),p.reject(new Error("loadNewVenue called - previous loading ignored")),c=new t,p=new t,m({...d,venueId:e,accountId:a,assetStage:n},[]).then(f)}),i.bus.on("venueData/getPoiImageUrl",({imageName:e,size:t})=>`https://img.locuslabs.com/resize/${d.accountId}/png/transparent/${t}contain/poi/${e}`),i.bus.on("venueData/getDistributionId",()=>c.then(e=>`${e.baseVenueId}-${d.accountId}`)),i.bus.on("venueData/getCustomKeywords",()=>c.then(e=>{const t=d.useOldDataModel&&e.files.searchOld||e.files.search;return e.fetchJson(t)})),i.bus.on("venueData/isGrabEnabled",S("enableGrab")),i.bus.on("venueData/getGrabPoiIds",S("grabPoiIds",[])),i.bus.on("venueData/getAssetsTimestamp",S("version")),i.bus.on("venueData/getTranslatedFloorId",async({floorId:e})=>c.then(t=>O(e,t)));const T=e=>e.structures.reduce((e,t)=>e.concat(Object.keys(t.levels)),[]);i.bus.on("venueData/getQueueTypes",()=>c.then(e=>{const t=["tsapre","clear","globalEntry"];return e.queueTypes?e.queueTypes.reduce((e,a)=>{const{id:n,subtypes:s}=a,r=s.map(e=>{const a=t.includes(e.id)&&`security-logo-${e.id.toLowerCase()}`;return{...e,imageId:a}});return e[n]=r,e},{}):{}}));return{init:async()=>{let e=[];null===new URLSearchParams("undefined"==typeof window?"":window.location.search).get("lang")&&(e="undefined"==typeof window?[]:navigator.languages);const t=d.deepLinkProps||{};t.lang&&e.unshift(t.lang);const a=t.vid||d.venueId,n=d.useDynamicUrlParams&&t.stage?t.stage:d.assetStage,s=t.accountId||("alpha"===n?"A1VPTJKREFJWX5":d.accountId);m({...d,venueId:a,accountId:s,assetStage:n},e).then(f)},runTest:async({testRoutine:e,reset:a=!1,venueData:n=null})=>{let s,r;return(a||n)&&(c=new t,p=new t),n&&(c=t.resolve(n)),await e(),c.v&&(s=await c),p.v&&(r=await p),{venueDataObj:s,mapDataObj:r}},internal:{calculateBaseVenueId:b,getDefaultStructureId:v,getTranslatedFloorId:O,setConfigProperty:(e,t)=>{d[e]=t}}}}export{i as create};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atriusmaps-node-sdk",
3
- "version": "3.3.951",
3
+ "version": "3.3.952",
4
4
  "description": "This project provides an API to Atrius Personal Wayfinder maps within a Node environment. See the README.md for more information",
5
5
  "keywords": [
6
6
  "map",