atriusmaps-node-sdk 3.3.927 → 3.3.928
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/cjs/package.json.js +1 -1
- package/dist/cjs/plugins/venueDataLoader/src/venueDataLoader.js +1 -1
- package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +11 -1
- package/dist/package.json.js +1 -1
- package/dist/plugins/venueDataLoader/src/venueDataLoader.js +1 -1
- package/dist/plugins/venueDataLoader/src/venueLoadingUtils.js +1 -1
- package/package.json +1 -1
package/dist/cjs/package.json.js
CHANGED
|
@@ -159,7 +159,7 @@ 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
|
|
162
|
+
const mapStyleSource = await venueLoadingUtils.fetchStyleDoc(venueData.baseVenueId);
|
|
163
163
|
const mapTheme = await venueData.fetchJson(venueData.files.theme);
|
|
164
164
|
const badgesSpriteUrl = venueData.files.spritesheet;
|
|
165
165
|
const mapGlyphsUrl = venueData.files.glyphs;
|
|
@@ -23,12 +23,20 @@ function _interopNamespaceDefault(e) {
|
|
|
23
23
|
var R__namespace = /*#__PURE__*/_interopNamespaceDefault(R);
|
|
24
24
|
|
|
25
25
|
const fetchURL = async (token, url) => {
|
|
26
|
-
{
|
|
26
|
+
if (token) {
|
|
27
|
+
return fetch(url, {
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: token
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
} else {
|
|
27
33
|
return fetch(url);
|
|
28
34
|
}
|
|
29
35
|
};
|
|
30
36
|
const createFetchJson = (token) => (url) => fetchURL(token, url).then((response) => response.json());
|
|
31
37
|
const createFetchText = (token) => (url) => fetchURL(token, url).then((response) => response.text());
|
|
38
|
+
const STYLE_URL = "https://style.maps.atrius.com/v2/style";
|
|
39
|
+
const fetchStyleDoc = (venueId) => fetchURL(null, `${STYLE_URL}?venueId=${venueId}`).then((response) => response.json()).then((body) => body.data);
|
|
32
40
|
const baseContentUrl = (contentStage) => `https://api.content.locuslabs.com/${contentStage}`;
|
|
33
41
|
const remapContentUrl = (url, category, contentStage, accountId, venueId, key) => {
|
|
34
42
|
if (key === "theme" || key === "style") {
|
|
@@ -165,9 +173,11 @@ const normalizeCoords = (coords, venueBounds) => {
|
|
|
165
173
|
return coords.map(swapFirstTwoItems);
|
|
166
174
|
};
|
|
167
175
|
|
|
176
|
+
exports.STYLE_URL = STYLE_URL;
|
|
168
177
|
exports.buildStructures = buildStructures;
|
|
169
178
|
exports.createFetchJson = createFetchJson;
|
|
170
179
|
exports.createFetchText = createFetchText;
|
|
180
|
+
exports.fetchStyleDoc = fetchStyleDoc;
|
|
171
181
|
exports.findVenueForLocale = findVenueForLocale;
|
|
172
182
|
exports.getVenueDataFromUrls = getVenueDataFromUrls;
|
|
173
183
|
exports.normalizeCoords = normalizeCoords;
|
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var a="3.3.
|
|
1
|
+
var a="3.3.928",e={version:a};export{e as default,a as version};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"ramda";import t from"zousan";import{
|
|
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 +1 @@
|
|
|
1
|
-
import*as e from"ramda";import{findBoundsOfCoordinates as t}from"../../../src/utils/bounds.js";const n=async(e,t)=>fetch(t),s=e=>
|
|
1
|
+
import*as e from"ramda";import{findBoundsOfCoordinates as t}from"../../../src/utils/bounds.js";const n=async(e,t)=>e?fetch(t,{headers:{Authorization:e}}):fetch(t),s=e=>t=>n(e,t).then(e=>e.json()),a=e=>t=>n(e,t).then(e=>e.text()),l="https://style.maps.atrius.com/v2/style",o=e=>n(null,`${l}?venueId=${e}`).then(e=>e.json()).then(e=>e.data),r=e=>`https://api.content.locuslabs.com/${e}`,c=(t,n,s,a,l)=>e.mapObjIndexed((e,n)=>((e,t,n,s,a,l)=>"theme"===l||"style"===l?`${r(n)}/${t}/${l}/${a}/${s}/${l}.json`:e.replace(/https:\/\/content.locuslabs.com/gi,r(n)))(e,t,s,a,l,n),n),i=[["zh-CN","zh-SG","zh-Hans"],["zh-TW","zh-HK","zh-MO","zh-Hant"]],u=e=>{const t=(e=>{const t=i.find(t=>t.includes(e));return t?t.filter(t=>t!==e):[]})(e),n=e.slice(0,2);return[t=>t===e,e=>t.includes(e),e=>e.slice(0,2)===n]},d=(e,t,n=null)=>{for(const s of u(t)){if(n&&s(n.locale))return n;const t=e.find(e=>s(e.locale));if(t)return t}return null},h=async(e,t,n)=>{const s={alpha:"alpha-a.locuslabs.com",beta:"beta-a.locuslabs.com",gamma:"gamma-a.locuslabs.com",prod:"a.locuslabs.com"},{assetStage:a,accountId:l,formatVersion:o}=e;let{venueId:r}=e;const i=`https://${s[a]||s.prod}/accounts/${l}`,u=o||"v5",h=e.dataFetch&&globalThis[e.dataFetch]&&globalThis[e.dataFetch].getFiles?await globalThis[e.dataFetch].getFiles(e):await t(`${i}/${u}.json`),g=h[r]?h[r].venueCode:null;if(g){const t=Object.values(h).filter(e=>e.venueCode===g),s=h[r];for(const a of n){const n=d(t,a,s);if(n){r=n.id,e.venueId=`${r}`;break}}}if(!h[r])throw Error(`Attempt to access venue ${r} which is not within venue list: ${Object.keys(h)}`);const f=h[r].files,b=(e.dataFetch&&globalThis[e.dataFetch]&&globalThis[e.dataFetch].getVenueData?await globalThis[e.dataFetch].getVenueData(e):await t(f.venueData))[r];b.tileServerAuthInfo&&function(e){const t={defaultOrdinal:0,defaultStructureId:"singleBuilding",formatVersion:"v5",structures:{singleBuilding:{name:"singleBuilding",boundsPolygon:[],defaultLevelId:"singleLevel",id:"singleBuilding",levels:{singleLevel:{boundsPolygon:[],clfloor:0,details:"",id:"singleLevel",name:"singleLevel",ordinal:0}}}},structureOrder:["singleBuilding"]};for(const n in t)e[n]=t[n]}(b),b.venueList=h;const m=(e=>{const t=e.deepLinkProps?e.deepLinkProps.contentStage:null;return"alpha"===t||"beta"===t||"prod"===t?t:null})(e);return b.files=m?c(b.category,f,m,l,r):f,b},g=e=>{const{structureOrder:n,structures:s}=e;return n.map(e=>{const n=s[e];Object.values(n.levels).forEach(e=>e.bounds=t(e.boundsPolygon));const a=t(n.boundsPolygon);return{...n,bounds:a}})};const f=([e,t,...n])=>[t,e,...n],b=(e,t)=>{return!e||!Array.isArray(e)||e.length<1?e:(n=e[0][0],s=t.ne.lng,a=t.sw.lng,(n>s?n<=a:e=>a)?e:e.map(f));var n,s,a};export{l as STYLE_URL,g as buildStructures,s as createFetchJson,a as createFetchText,o as fetchStyleDoc,d as findVenueForLocale,h as getVenueDataFromUrls,b as normalizeCoords};
|
package/package.json
CHANGED