atriusmaps-node-sdk 3.3.1026 → 3.3.1028
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/sdkServer/src/prepareSDKConfig.js +3 -1
- package/dist/cjs/plugins/venueDataLoader/src/venueDataLoader.js +5 -3
- package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +30 -3
- package/dist/package.json.js +1 -1
- package/dist/plugins/sdkServer/src/prepareSDKConfig.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
|
@@ -45,6 +45,7 @@ function prepareSDKConfig(sc) {
|
|
|
45
45
|
defaultSearchTerms,
|
|
46
46
|
venueId,
|
|
47
47
|
accountId,
|
|
48
|
+
auth,
|
|
48
49
|
poiCategories,
|
|
49
50
|
preserveStateInURL,
|
|
50
51
|
supportURLDeepLinks,
|
|
@@ -91,7 +92,8 @@ function prepareSDKConfig(sc) {
|
|
|
91
92
|
venueDataLoader: {
|
|
92
93
|
dataFetch,
|
|
93
94
|
venueId,
|
|
94
|
-
accountId
|
|
95
|
+
accountId,
|
|
96
|
+
...auth ? { auth } : {}
|
|
95
97
|
},
|
|
96
98
|
sdkServer: {
|
|
97
99
|
headless
|
|
@@ -23,7 +23,6 @@ function _interopNamespaceDefault(e) {
|
|
|
23
23
|
|
|
24
24
|
var R__namespace = /*#__PURE__*/_interopNamespaceDefault(R);
|
|
25
25
|
|
|
26
|
-
const USE_AUTH_WHEN_NOT_PROD_STAGE = false;
|
|
27
26
|
async function create(app, config) {
|
|
28
27
|
const log = app.log.sublog("venueDataLoader");
|
|
29
28
|
let venueDataLoaded = new Zousan();
|
|
@@ -34,10 +33,13 @@ async function create(app, config) {
|
|
|
34
33
|
const getVenueDefForLang = (venueData, lang) => Object.values(venueData.venueList).filter((venueDef) => venueDef.locale === lang).sort((a, b) => countMatchedPrefix(b.id, venueData.id) - countMatchedPrefix(a.id, venueData.id)).at(0);
|
|
35
34
|
const calculateBaseVenueId = (venueData) => getVenueDefForLang(venueData, "en")?.id;
|
|
36
35
|
async function loadVenueData(vConfig, languagesToTry) {
|
|
37
|
-
if (vConfig.assetStage && vConfig.assetStage !== "prod" && location.hostname !== "localhost" && USE_AUTH_WHEN_NOT_PROD_STAGE) ;
|
|
38
36
|
const fetchJson = venueLoadingUtils.createFetchJson();
|
|
39
37
|
const fetchText = venueLoadingUtils.createFetchText();
|
|
40
|
-
const
|
|
38
|
+
const fetchManifestJson = venueLoadingUtils.createFetchManifestJson(
|
|
39
|
+
vConfig.auth,
|
|
40
|
+
() => app.bus.send("venueData/authExpired", { reason: "signedUrlExpired" })
|
|
41
|
+
);
|
|
42
|
+
const venueData = await venueLoadingUtils.getVenueDataFromUrls(vConfig, fetchJson, languagesToTry, fetchManifestJson);
|
|
41
43
|
const { accountId, venueId } = vConfig;
|
|
42
44
|
venueData.assetStage = vConfig.assetStage;
|
|
43
45
|
venueData.defaultOrdinal = venueData.defaultOrdinal || getDefaultOrdinal(venueData);
|
|
@@ -35,17 +35,39 @@ const fetchURL = async (token, url) => {
|
|
|
35
35
|
};
|
|
36
36
|
const createFetchJson = (token) => (url) => fetchURL(token, url).then((response) => response.json());
|
|
37
37
|
const createFetchText = (token) => (url) => fetchURL(token, url).then((response) => response.text());
|
|
38
|
+
const createFetchManifestJson = (auth, onAuthExpired) => async (url) => {
|
|
39
|
+
const response = await fetch(url);
|
|
40
|
+
if (auth?.type === "kiosk" && response.status === 403) {
|
|
41
|
+
await onAuthExpired?.();
|
|
42
|
+
throw new Error("Kiosk signed manifest URL expired");
|
|
43
|
+
}
|
|
44
|
+
return response.json();
|
|
45
|
+
};
|
|
38
46
|
const fetchStyleDoc = (venueId, venueCategory) => {
|
|
39
47
|
const styleUrl = `https://style.maps.atrius.com/v2/style?venueId=${venueId}&category=${venueCategory}`;
|
|
40
48
|
return fetchURL(null, styleUrl).then((response) => response.json()).then((body) => body.data);
|
|
41
49
|
};
|
|
42
50
|
const baseContentUrl = (contentStage) => `https://api.content.locuslabs.com/${contentStage}`;
|
|
43
51
|
const remapContentUrl = (url, category, contentStage, accountId, venueId, key) => {
|
|
52
|
+
if (isSignedUrl(url)) {
|
|
53
|
+
return url;
|
|
54
|
+
}
|
|
44
55
|
if (key === "theme" || key === "style") {
|
|
45
56
|
return `${baseContentUrl(contentStage)}/${category}/${key}/${venueId}/${accountId}/${key}.json`;
|
|
46
57
|
}
|
|
47
58
|
return url.replace(/https:\/\/content.locuslabs.com/gi, baseContentUrl(contentStage));
|
|
48
59
|
};
|
|
60
|
+
const isSignedUrl = (url) => {
|
|
61
|
+
if (typeof url !== "string") {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const searchParams = new URL(url).searchParams;
|
|
66
|
+
return ["Expires", "Signature", "Key-Pair-Id"].every((name) => searchParams.has(name));
|
|
67
|
+
} catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
49
71
|
const remapEachURLForContentStage = (category, files, contentStage, accountId, venueId) => R__namespace.mapObjIndexed((file, key) => remapContentUrl(file, category, contentStage, accountId, venueId, key), files);
|
|
50
72
|
const getContentStage = (vconfig) => {
|
|
51
73
|
const stage = vconfig.deepLinkProps ? vconfig.deepLinkProps.contentStage : null;
|
|
@@ -80,7 +102,7 @@ const findVenueForLocale = (venues, browserLang, currentVenue = null) => {
|
|
|
80
102
|
}
|
|
81
103
|
return null;
|
|
82
104
|
};
|
|
83
|
-
const getVenueDataFromUrls = async (vconfig, fetchJson, languagesToTry) => {
|
|
105
|
+
const getVenueDataFromUrls = async (vconfig, fetchJson, languagesToTry, fetchManifestJson = fetchJson) => {
|
|
84
106
|
const stages = {
|
|
85
107
|
alpha: "alpha-a.locuslabs.com",
|
|
86
108
|
beta: "beta-a.locuslabs.com",
|
|
@@ -92,7 +114,11 @@ const getVenueDataFromUrls = async (vconfig, fetchJson, languagesToTry) => {
|
|
|
92
114
|
const stageUrl = stages[assetStage] || stages.prod;
|
|
93
115
|
const accountUrl = `https://${stageUrl}/accounts/${accountId}`;
|
|
94
116
|
const assetFormat = formatVersion || "v5";
|
|
95
|
-
const
|
|
117
|
+
const usesKioskAuth = vconfig.auth?.type === "kiosk";
|
|
118
|
+
if (usesKioskAuth && (typeof vconfig.auth.signedManifestUrl !== "string" || !vconfig.auth.signedManifestUrl.trim())) {
|
|
119
|
+
throw new Error("Kiosk auth requires a non-empty signedManifestUrl");
|
|
120
|
+
}
|
|
121
|
+
const venueList = !usesKioskAuth && vconfig.dataFetch && globalThis[vconfig.dataFetch] && globalThis[vconfig.dataFetch].getFiles ? await globalThis[vconfig.dataFetch].getFiles(vconfig) : await fetchManifestJson(usesKioskAuth ? vconfig.auth.signedManifestUrl : `${accountUrl}/${assetFormat}.json`);
|
|
96
122
|
const venueCode = venueList[venueId] ? venueList[venueId].venueCode : null;
|
|
97
123
|
if (venueCode) {
|
|
98
124
|
const venuesWithSameVenueCode = Object.values(venueList).filter((v) => v.venueCode === venueCode);
|
|
@@ -110,7 +136,7 @@ const getVenueDataFromUrls = async (vconfig, fetchJson, languagesToTry) => {
|
|
|
110
136
|
throw Error(`Attempt to access venue ${venueId} which is not within venue list: ${Object.keys(venueList)}`);
|
|
111
137
|
}
|
|
112
138
|
const files = venueList[venueId].files;
|
|
113
|
-
const fetchedData = vconfig.dataFetch && globalThis[vconfig.dataFetch] && globalThis[vconfig.dataFetch].getVenueData ? await globalThis[vconfig.dataFetch].getVenueData(vconfig) : await fetchJson(files.venueData);
|
|
139
|
+
const fetchedData = !usesKioskAuth && vconfig.dataFetch && globalThis[vconfig.dataFetch] && globalThis[vconfig.dataFetch].getVenueData ? await globalThis[vconfig.dataFetch].getVenueData(vconfig) : await fetchJson(files.venueData);
|
|
114
140
|
const venueData = fetchedData[venueId];
|
|
115
141
|
if (venueData.tileServerAuthInfo) {
|
|
116
142
|
embellishTilemapVenueData(venueData);
|
|
@@ -177,6 +203,7 @@ const normalizeCoords = (coords, venueBounds) => {
|
|
|
177
203
|
|
|
178
204
|
exports.buildStructures = buildStructures;
|
|
179
205
|
exports.createFetchJson = createFetchJson;
|
|
206
|
+
exports.createFetchManifestJson = createFetchManifestJson;
|
|
180
207
|
exports.createFetchText = createFetchText;
|
|
181
208
|
exports.fetchStyleDoc = fetchStyleDoc;
|
|
182
209
|
exports.findVenueForLocale = findVenueForLocale;
|
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var a="3.3.
|
|
1
|
+
var a="3.3.1028",e={version:a};export{e as default,a as version};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b64DecodeUnicode as e,filterOb as i}from"../../../src/utils/funcs.js";import{setDeepLinksForParms as n}from"../../../src/configs/postproc-mol-url-parms.js";import{setStateFromStateString as o}from"../../../src/configs/postproc-stateTracking.js";const t=(e,i)=>{if(void 0===e)return;const n=e.toString();return n.length>i?n.substring(0,i):n},s=(e,i)=>void 0!==i?{[e]:i}:{},a=e=>{if(!e||"object"!=typeof e)return;const i={};return Object.keys(e).slice(0,10).forEach(n=>{let o=t(n.toString().replaceAll(/[^a-zA-Z0-9_]/g,""),128)??"X";o.match(/^[a-zA-Z]+/)||(o=`X${o}`);let s=e[n];null==s&&(s=""),i[o]=t(String(s),128)??""}),i};function r(e,i,n){Object.keys(e).filter(e=>e.startsWith(`${i}-`)).forEach(i=>{n[i]=e[i]})}function l(l){const{name:c,debug:p,headless:u,theme:d,defaultSearchTerms:g,venueId:h,accountId:m,
|
|
1
|
+
import{b64DecodeUnicode as e,filterOb as i}from"../../../src/utils/funcs.js";import{setDeepLinksForParms as n}from"../../../src/configs/postproc-mol-url-parms.js";import{setStateFromStateString as o}from"../../../src/configs/postproc-stateTracking.js";const t=(e,i)=>{if(void 0===e)return;const n=e.toString();return n.length>i?n.substring(0,i):n},s=(e,i)=>void 0!==i?{[e]:i}:{},a=e=>{if(!e||"object"!=typeof e)return;const i={};return Object.keys(e).slice(0,10).forEach(n=>{let o=t(n.toString().replaceAll(/[^a-zA-Z0-9_]/g,""),128)??"X";o.match(/^[a-zA-Z]+/)||(o=`X${o}`);let s=e[n];null==s&&(s=""),i[o]=t(String(s),128)??""}),i};function r(e,i,n){Object.keys(e).filter(e=>e.startsWith(`${i}-`)).forEach(i=>{n[i]=e[i]})}function l(l){const{name:c,debug:p,headless:u,theme:d,defaultSearchTerms:g,venueId:h,accountId:m,auth:f,poiCategories:S,preserveStateInURL:v,supportURLDeepLinks:k,initState:L,deepLinkParms:P,uiHide:w,renderDiv:A,parentConfig:y,desktopViewMinWidth:V,forceDesktop:b,hostAppId:j,hostAppVersion:D,hostAppProperties:I,logFilter:Z,searchPlaceholder:F,dataFetch:C,engineName:O,dynamicPoisUrlBaseV1:R,plugins:T,analytics2ActiveFlag:U,enablePoiSelection:x,showSurround:M,minZoom:W,maxZoom:z,noLangOptions:B,pinnedLocation:H,pinnedLocationZoom:E,pinnedLocationFocusAtStart:N,pinnedLocationBearing:X,pinnedLocationPitch:$}=l,_=y?[y]:u?["sdkHeadless"]:["sdkVisual"],q={name:c,engineName:O,extends:_,debug:p,logFilter:Z,theme:d,uiHide:w,renderDiv:A,configPostProc:[],plugins:{venueDataLoader:{dataFetch:C,venueId:h,accountId:m,...f?{auth:f}:{}},sdkServer:{headless:u},analytics2:{hostAppId:j?t(j,128):void 0,hostAppVersion:D?t(D,128):void 0,hostAppProperties:a(I)}},uuid:"undefined"!=typeof document&&document.location?document.location.host:"unknown"};if(void 0!==U&&(q.plugins.analytics2={...q.plugins.analytics2,active:U}),u||(q.plugins["online/headerOnline"]={searchPlaceholder:F},q.plugins.mapRenderer={...s("enablePoiSelection",x),surroundConfig:M?{}:null,viewLimits:{...s("maxZoom",z),...s("minZoom",W)}},q.plugins.userMenu={noLangOptions:B},H&&(q.plugins["online/pinnedLocation"]={location:H,zoom:E,focusAtStart:N,bearing:X,pitch:$})),q.plugins.searchService=g?{defaultSearchTerms:g}:{},r(l,"defaultSearchTerms",q.plugins.searchService),_.includes("sdkVisual")&&(q.plugins["online/homeView"]=S?{poiCategories:S}:{},r(l,"poiCategories",q.plugins["online/homeView"])),T&&"object"==typeof T){const e=T;e.draw&&(q.plugins.draw=e.draw),e.flightStatus&&(q.plugins.flightStatus=e.flightStatus,q.plugins["online/flightDetails"]={},q.plugins["online/flightDetailsSearch"]={})}return v&&((q.configPostProc??[]).push("stateTracking"),q.plugins.deepLinking={trackURL:!0}),k&&(q.configPostProc??[]).push("mol-url-parms"),L&&o(q,e(L),!0),P&&n(q,new URLSearchParams(P),!0),void 0!==V&&(q.desktopViewMinWidth=V),b&&(q.desktopViewMinWidth=0),R&&(q.plugins.dynamicPois={urlBaseV1:R}),i((e,i)=>void 0!==i,q)}export{l as default};
|
|
@@ -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
|
|
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,createFetchManifestJson as i}from"./venueLoadingUtils.js";async function d(d,l){const c=d.log.sublog("venueDataLoader");let p=new t,v=new t;const g=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),b=(e,t)=>e.split("").reduce((a,n,s)=>e.substring(0,s+1)===t.substring(0,s+1)?s:a,-1)+1,f=e=>((e,t)=>Object.values(e.venueList).filter(e=>e.locale===t).sort((t,a)=>b(a.id,e.id)-b(t.id,e.id)).at(0))(e,"en")?.id;async function m(t,a){const n=u(),l=o(),c=i(t.auth,()=>d.bus.send("venueData/authExpired",{reason:"signedUrlExpired"})),v=await s(t,n,a,c),{accountId:b,venueId:m}=t;return v.assetStage=t.assetStage,v.defaultOrdinal=v.defaultOrdinal||function(t){const a=g(t),n=Object.values(t.structures).find(e.propEq(a,"id"));return n.levels[n.defaultLevelId].ordinal}(v),v.structures=r(v),v.baseVenueId=f(v),v.getTranslatedContentPath=e=>`https://content.locuslabs.com/${v.category}/${e}/${m}/${b}`,v.fetchJson=n,v.fetchText=l,d.config.debug&&d.env.isBrowser&&(window._venueData=v),v.queueTypes&&(v.securityQueueTypes=(()=>{const e=v.queueTypes.find(e=>"SecurityLane"===e.id);return e?e.subtypes.map(e=>e.id):[]})()),d.bus.send("venueData/venueDataLoaded",{venueData:v}),p.resolve(v),p}function h(e){const t={id:"venueDataLoader"};return e.id!==l.venueId&&(t.vid=e.id),t.lang=d.i18n().language,"prod"!==e.assetStage&&(t.stage=e.assetStage),d.bus.send("deepLinking/notifyState",t),e}d.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 d.bus.send("map/replaceTheme",{theme:n});if(e.metadata&&e.metadata["mapbox:type"])return a=t,void d.bus.send("map/replaceStyle",{styleSrc:a})}var a,n});async function y(e){const t={...e},a=await d.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!==l.copyPOINamesToMap&&(e.properties.text=function(e){let t=e.name;return l.poiMapNameXForm?(Object.keys(l.poiMapNameXForm).filter(t=>((e,t)=>e===t||0===e.indexOf(t+"."))(e.category,t)).forEach(e=>{l.poiMapNameXForm[e].forEach(e=>t=t.replace(new RegExp(e.replace),e.with))}),t):t}(t)):c.warn(`Unknown poi in style: ${e.properties.id}`)})),t}async function D(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,I(e.id,e.features,a.id,a.structures)])),e=>t.all(e),e.andThen(e.fromPairs))(a)}const I=(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)})};d.bus.on("venueData/loadMap",async()=>{p.then(async e=>{const t=e.files.spritesheet,n=e.files.glyphs,{id:s,bounds:r,structures:u,venueCenter:o,venueRadius:i,defaultOrdinal:c}=e,[p,g,b]=await Promise.all([a(e.baseVenueId,e.category),e.fetchJson(e.files.theme),e.venueList[s].mapTokens?Promise.resolve({[s]:[]}):D(e).then(y)]),f={mapFeatures:b,mapStyleSource:p,mapTheme:g,badgesSpriteUrl:t,mapGlyphsUrl:n,structures:u,defaultOrdinal:c,venueBounds:{n:r.ne.lat,s:r.sw.lat,e:r.ne.lng,w:r.sw.lng},venueId:s,venueCenter:o,venueRadius:i,accountId:l.accountId,secure:void 0!==l.auth,tileServerAuthInfo:e.tileServerAuthInfo};v.resolve(f),d.bus.send("venueData/mapDataLoaded",f)})});const w=e=>null==e.shouldDisplay||e.shouldDisplay;d.bus.on("venueData/loadBuildingSelectorData",()=>p.then(async t=>{const a={buildings:t.structures.filter(w).map(e.evolve({levels:e.pipe(e.values,e.sortWith([e.descend(e.prop("ordinal"))]))})),structureOrder:t.structureOrder,selectorOrder:t.selectorOrder};return d.bus.send("venueData/buildingSelectorDataLoaded",a),a})),d.bus.on("venueData/normalizeCoords",({coords:e})=>p.then(t=>n(e,t.bounds)));const S={edges:[],nodes:[]};d.bus.on("venueData/loadNavGraph",async()=>p.then(async e=>{const t={navGraphData:e.files.nav?await e.fetchJson(e.files.nav):S,structures:e.structures};return d.bus.send("venueData/navGraphLoaded",t),t})),d.bus.on("venueData/loadPoiData",async()=>p.then(async e=>{const t=l.useOldDataModel?e.files.poisOld||e.files.pois:e.files.pois||e.files.poisOld;if(t){const a=await e.fetchJson(t);d.bus.send("venueData/poiDataLoaded",{pois:a,structures:e.structures})}})),d.bus.on("venueData/getVenueCenter",async()=>p.then(async e=>({lat:e.venueCenter[0],lng:e.venueCenter[1],ordinal:0}))),d.bus.on("venueData/getContentUrl",({type:e,name:t=""})=>p.then(a=>a.files[e]+t)),d.bus.on("venueData/getFloorIdToNameMap",()=>p.then(e.pipe(e.prop("structures"),e.map(e.prop("levels")),e.chain(e.values),e.map(e.props(["id","name"])),e.fromPairs))),d.bus.on("venueData/getFloorIdName",({floorId:t})=>p.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 O=(t,a)=>()=>p.then(e.pipe(e.prop(t),e.defaultTo(a)));function T(e,t){const a=P(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))}d.bus.on("venueData/getVenueData",()=>p),d.bus.on("venueData/getVenueName",O("name")),d.bus.on("venueData/getVenueCategory",O("category")),d.bus.on("venueData/getVenueTimezone",O("tz")),d.bus.on("venueData/getAccountId",()=>l.accountId),d.bus.on("venueData/getVenueId",O("id")),d.bus.on("venueData/getPositioningSupported",O("positioningSupported")),d.bus.on("venueData/getStructures",O("structures")),d.bus.on("venueData/loadNewVenue",async({venueId:e,accountId:a,assetStage:n=l.assetStage})=>{p.reject(new Error("loadNewVenue called - previous loading ignored")),v.reject(new Error("loadNewVenue called - previous loading ignored")),p=new t,v=new t,m({...l,venueId:e,accountId:a,assetStage:n},[]).then(h)}),d.bus.on("venueData/getPoiImageUrl",({imageName:e,size:t})=>`https://img.locuslabs.com/resize/${l.accountId}/png/transparent/${t}contain/poi/${e}`),d.bus.on("venueData/getDistributionId",()=>p.then(e=>`${e.baseVenueId}-${l.accountId}`)),d.bus.on("venueData/getCustomKeywords",()=>p.then(e=>{const t=l.useOldDataModel&&e.files.searchOld||e.files.search;return e.fetchJson(t)})),d.bus.on("venueData/isGrabEnabled",O("enableGrab")),d.bus.on("venueData/getGrabPoiIds",O("grabPoiIds",[])),d.bus.on("venueData/getAssetsTimestamp",O("version")),d.bus.on("venueData/getTranslatedFloorId",async({floorId:e})=>p.then(t=>T(e,t)));const P=e=>e.structures.reduce((e,t)=>e.concat(Object.keys(t.levels)),[]);d.bus.on("venueData/getQueueTypes",()=>p.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=l.deepLinkProps||{};t.lang&&e.unshift(t.lang);const a=t.vid||l.venueId,n=l.useDynamicUrlParams&&t.stage?t.stage:l.assetStage,s=t.accountId||("alpha"===n?"A1VPTJKREFJWX5":l.accountId);m({...l,venueId:a,accountId:s,assetStage:n},e).then(h)},runTest:async({testRoutine:e,reset:a=!1,venueData:n=null})=>{let s,r;return(a||n)&&(p=new t,v=new t),n&&(p=t.resolve(n)),await e(),p.v&&(s=await p),v.v&&(r=await v),{venueDataObj:s,mapDataObj:r}},internal:{calculateBaseVenueId:f,getDefaultStructureId:g,getTranslatedFloorId:T,setConfigProperty:(e,t)=>{l[e]=t}}}}export{d as create};
|
|
@@ -1 +1 @@
|
|
|
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()),
|
|
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()),o=(e,t)=>async n=>{const s=await fetch(n);if("kiosk"===e?.type&&403===s.status)throw await(t?.()),new Error("Kiosk signed manifest URL expired");return s.json()},r=(e,t)=>n(null,`https://style.maps.atrius.com/v2/style?venueId=${e}&category=${t}`).then(e=>e.json()).then(e=>e.data),l=e=>`https://api.content.locuslabs.com/${e}`,i=e=>{if("string"!=typeof e)return!1;try{const t=new URL(e).searchParams;return["Expires","Signature","Key-Pair-Id"].every(e=>t.has(e))}catch{return!1}},c=(t,n,s,a,o)=>e.mapObjIndexed((e,n)=>((e,t,n,s,a,o)=>i(e)?e:"theme"===o||"style"===o?`${l(n)}/${t}/${o}/${a}/${s}/${o}.json`:e.replace(/https:\/\/content.locuslabs.com/gi,l(n)))(e,t,s,a,o,n),n),u=[["zh-CN","zh-SG","zh-Hans"],["zh-TW","zh-HK","zh-MO","zh-Hant"]],d=e=>{const t=(e=>{const t=u.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]},h=(e,t,n=null)=>{for(const s of d(t)){if(n&&s(n.locale))return n;const t=e.find(e=>s(e.locale));if(t)return t}return null},g=async(e,t,n,s=t)=>{const a={alpha:"alpha-a.locuslabs.com",beta:"beta-a.locuslabs.com",gamma:"gamma-a.locuslabs.com",prod:"a.locuslabs.com"},{assetStage:o,accountId:r,formatVersion:l}=e;let{venueId:i}=e;const u=`https://${a[o]||a.prod}/accounts/${r}`,d=l||"v5",g="kiosk"===e.auth?.type;if(g&&("string"!=typeof e.auth.signedManifestUrl||!e.auth.signedManifestUrl.trim()))throw new Error("Kiosk auth requires a non-empty signedManifestUrl");const f=!g&&e.dataFetch&&globalThis[e.dataFetch]&&globalThis[e.dataFetch].getFiles?await globalThis[e.dataFetch].getFiles(e):await s(g?e.auth.signedManifestUrl:`${u}/${d}.json`),m=f[i]?f[i].venueCode:null;if(m){const t=Object.values(f).filter(e=>e.venueCode===m),s=f[i];for(const a of n){const n=h(t,a,s);if(n){i=n.id,e.venueId=`${i}`;break}}}if(!f[i])throw Error(`Attempt to access venue ${i} which is not within venue list: ${Object.keys(f)}`);const p=f[i].files,b=(!g&&e.dataFetch&&globalThis[e.dataFetch]&&globalThis[e.dataFetch].getVenueData?await globalThis[e.dataFetch].getVenueData(e):await t(p.venueData))[i];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=f;const v=(e=>{const t=e.deepLinkProps?e.deepLinkProps.contentStage:null;return"alpha"===t||"beta"===t||"prod"===t?t:null})(e);return b.files=v?c(b.category,p,v,r,i):p,b},f=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 m=([e,t,...n])=>[t,e,...n],p=(e,t)=>{return!e||!Array.isArray(e)||e.length<1?e:(n=e[0][0],s=t.ne.lng,a=t.sw.lng,n>=Math.min(s,a)&&n<=Math.max(s,a)?e:e.map(m));var n,s,a};export{f as buildStructures,s as createFetchJson,o as createFetchManifestJson,a as createFetchText,r as fetchStyleDoc,h as findVenueForLocale,g as getVenueDataFromUrls,p as normalizeCoords};
|
package/package.json
CHANGED