atriusmaps-node-sdk 3.3.632 → 3.3.634

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.
Files changed (54) hide show
  1. package/LICENSE.md +1 -2
  2. package/README.md +15 -16
  3. package/dist/cjs/deploy/prepareSDKConfig.js +73 -57
  4. package/dist/cjs/nodesdk/nodeEntry.js +51 -44
  5. package/dist/cjs/package.json.js +4 -1
  6. package/dist/cjs/plugins/clientAPI/src/clientAPI.js +6 -4
  7. package/dist/cjs/plugins/dynamicPois/src/dynamicPois.js +32 -26
  8. package/dist/cjs/plugins/dynamicPois/src/processors.js +41 -35
  9. package/dist/cjs/plugins/poiDataManager/src/poiDataManager.js +102 -95
  10. package/dist/cjs/plugins/sdkServer/src/sdkHeadless.js +52 -26
  11. package/dist/cjs/plugins/sdkServer/src/sdkServer.js +86 -66
  12. package/dist/cjs/plugins/searchService/src/flexsearchExports/lang.js +16 -16
  13. package/dist/cjs/plugins/searchService/src/flexsearchExports/simple.js +31 -8
  14. package/dist/cjs/plugins/searchService/src/poiSearch.js +14 -17
  15. package/dist/cjs/plugins/searchService/src/searchService.js +41 -39
  16. package/dist/cjs/plugins/searchService/src/searchTypeahead.js +14 -19
  17. package/dist/cjs/plugins/searchService/src/utils.js +4 -5
  18. package/dist/cjs/plugins/venueDataLoader/src/venueDataLoader.js +145 -127
  19. package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +37 -39
  20. package/dist/cjs/plugins/wayfinder/src/findRoute.js +11 -18
  21. package/dist/cjs/plugins/wayfinder/src/minPriorityQueue.js +18 -19
  22. package/dist/cjs/plugins/wayfinder/src/navGraph.js +111 -91
  23. package/dist/cjs/plugins/wayfinder/src/navGraphDebug.js +19 -16
  24. package/dist/cjs/plugins/wayfinder/src/segmentBadges.js +1 -1
  25. package/dist/cjs/plugins/wayfinder/src/segmentBuilder.js +79 -76
  26. package/dist/cjs/plugins/wayfinder/src/segmentCategories.js +1 -1
  27. package/dist/cjs/plugins/wayfinder/src/stepBuilder.js +147 -107
  28. package/dist/cjs/plugins/wayfinder/src/wayfinder.js +178 -148
  29. package/dist/cjs/src/app.js +64 -44
  30. package/dist/cjs/src/configs/postproc-mol-url-parms.js +22 -21
  31. package/dist/cjs/src/configs/postproc-stateTracking.js +5 -8
  32. package/dist/cjs/src/controller.js +11 -6
  33. package/dist/cjs/src/debugTools.js +61 -34
  34. package/dist/cjs/src/env.js +7 -4
  35. package/dist/cjs/src/extModules/bustle.js +35 -45
  36. package/dist/cjs/src/extModules/flexapi/src/help.js +16 -8
  37. package/dist/cjs/src/extModules/flexapi/src/index.js +39 -18
  38. package/dist/cjs/src/extModules/flexapi/src/validate.js +129 -87
  39. package/dist/cjs/src/extModules/geohasher.js +7 -7
  40. package/dist/cjs/src/extModules/log.js +20 -22
  41. package/dist/cjs/src/historyManager.js +2 -2
  42. package/dist/cjs/src/utils/bounds.js +6 -6
  43. package/dist/cjs/src/utils/buildStructureLookup.js +3 -3
  44. package/dist/cjs/src/utils/configUtils.js +14 -18
  45. package/dist/cjs/src/utils/dom.js +12 -18
  46. package/dist/cjs/src/utils/funcs.js +12 -15
  47. package/dist/cjs/src/utils/geodesy.js +7 -9
  48. package/dist/cjs/src/utils/geom.js +52 -40
  49. package/dist/cjs/src/utils/i18n.js +47 -36
  50. package/dist/cjs/src/utils/location.js +12 -13
  51. package/dist/cjs/src/utils/observable.js +27 -28
  52. package/dist/cjs/src/utils/rand.js +9 -10
  53. package/dist/package.json.js +1 -1
  54. package/package.json +1 -1
@@ -25,7 +25,7 @@ var R__namespace = /*#__PURE__*/_interopNamespaceDefault(R);
25
25
 
26
26
  const USE_AUTH_WHEN_NOT_PROD_STAGE = false; // turning this off for now (per Jessica request)
27
27
 
28
- async function create (app, config) {
28
+ async function create(app, config) {
29
29
  const log = app.log.sublog('venueDataLoader');
30
30
  let venueDataLoaded = new Zousan();
31
31
  let mapDataLoaded = new Zousan();
@@ -39,7 +39,8 @@ async function create (app, config) {
39
39
  const mergeWithProp = (prop, toAdd, o) => R__namespace.over(R__namespace.lensProp(prop), old => R__namespace.mergeRight(old || {}, toAdd), o);
40
40
 
41
41
  // This function counts the number of characters that match at the beginning of two strings.
42
- const countMatchedPrefix = (a, b) => a.split('').reduce((max, _, i) => a.substring(0, i + 1) === b.substring(0, i + 1) ? i : max, -1) + 1;
42
+ const countMatchedPrefix = (a, b) =>
43
+ a.split('').reduce((max, _, i) => (a.substring(0, i + 1) === b.substring(0, i + 1) ? i : max), -1) + 1;
43
44
 
44
45
  // This function returns the venue definition for a specific language. It does this by filtering the venueList for the specified language,
45
46
  // sorting the results by how many characters match at the beginning of the venueId, and
@@ -54,9 +55,14 @@ async function create (app, config) {
54
55
  // We can use the venueList to find the English version of the venue, and then return its ID.
55
56
  const calculateBaseVenueId = venueData => getVenueDefForLang(venueData, 'en')?.id;
56
57
 
57
- async function loadVenueData (vConfig, languagesToTry) {
58
+ async function loadVenueData(vConfig, languagesToTry) {
58
59
  // For all non-production stages, require SSO (if no assetStage defined we default to 'prod')
59
- if (vConfig.assetStage && vConfig.assetStage !== 'prod' && location.hostname !== 'localhost' && USE_AUTH_WHEN_NOT_PROD_STAGE)
60
+ if (
61
+ vConfig.assetStage &&
62
+ vConfig.assetStage !== 'prod' &&
63
+ location.hostname !== 'localhost' &&
64
+ USE_AUTH_WHEN_NOT_PROD_STAGE
65
+ )
60
66
  ;
61
67
 
62
68
  const fetchJson = venueLoadingUtils.createFetchJson();
@@ -71,52 +77,47 @@ async function create (app, config) {
71
77
  venueData.defaultOrdinal = venueData.defaultOrdinal || getDefaultOrdinal(venueData);
72
78
  venueData.structures = venueLoadingUtils.buildStructures(venueData);
73
79
  venueData.baseVenueId = calculateBaseVenueId(venueData);
74
- venueData.getTranslatedContentPath = contentType => `https://content.locuslabs.com/${venueData.category}/${contentType}/${venueId}/${accountId}`;
80
+ venueData.getTranslatedContentPath = contentType =>
81
+ `https://content.locuslabs.com/${venueData.category}/${contentType}/${venueId}/${accountId}`;
75
82
  venueData.fetchJson = fetchJson;
76
83
  venueData.fetchText = fetchText;
77
- if (app.config.debug && app.env.isBrowser)
78
- window._venueData = venueData;
84
+ if (app.config.debug && app.env.isBrowser) window._venueData = venueData;
79
85
 
80
86
  if (venueData.queueTypes)
81
87
  venueData.securityQueueTypes = (() => {
82
88
  const secLane = venueData.queueTypes.find(qt => qt.id === 'SecurityLane');
83
- if (secLane)
84
- return secLane.subtypes.map(t => t.id)
85
- return []
89
+ if (secLane) return secLane.subtypes.map(t => t.id);
90
+ return [];
86
91
  })();
87
92
 
88
93
  app.bus.send('venueData/venueDataLoaded', { venueData });
89
94
 
90
95
  venueDataLoaded.resolve(venueData);
91
- return venueDataLoaded
96
+ return venueDataLoaded;
92
97
  }
93
98
 
94
- function getDefaultOrdinal (venueData) {
99
+ function getDefaultOrdinal(venueData) {
95
100
  const defaultStructureId = getDefaultStructureId(venueData);
96
101
  const defaultStructure = Object.values(venueData.structures).find(R__namespace.propEq(defaultStructureId, 'id'));
97
- return defaultStructure.levels[defaultStructure.defaultLevelId].ordinal
102
+ return defaultStructure.levels[defaultStructure.defaultLevelId].ordinal;
98
103
  }
99
104
 
100
- function notifyState (venueData) {
105
+ function notifyState(venueData) {
101
106
  const state = { id: 'venueDataLoader' };
102
- if (venueData.id !== config.venueId)
103
- state.vid = venueData.id;
107
+ if (venueData.id !== config.venueId) state.vid = venueData.id;
104
108
 
105
109
  state.lang = app.i18n().language;
106
110
 
107
- if (venueData.assetStage !== 'prod')
108
- state.stage = venueData.assetStage;
111
+ if (venueData.assetStage !== 'prod') state.stage = venueData.assetStage;
109
112
  app.bus.send('deepLinking/notifyState', state);
110
- return venueData
113
+ return venueData;
111
114
  }
112
115
 
113
116
  app.bus.on('debugTools/fileDrop', async ({ file, content }) => {
114
117
  if (file.type === 'application/json') {
115
118
  const jsonOb = JSON.parse(content);
116
- if (jsonOb.basemap && jsonOb['basemap.venue'])
117
- return replaceTheme(JSON.parse(content)) // looks like a theme!
118
- if (jsonOb.metadata && jsonOb.metadata['mapbox:type'])
119
- return replaceStyle(content) // looks like a style!
119
+ if (jsonOb.basemap && jsonOb['basemap.venue']) return replaceTheme(JSON.parse(content)); // looks like a theme!
120
+ if (jsonOb.metadata && jsonOb.metadata['mapbox:type']) return replaceStyle(content); // looks like a style!
120
121
  }
121
122
  });
122
123
 
@@ -128,17 +129,16 @@ async function create (app, config) {
128
129
  // withinCategory("eat", "eat.coffee") = false
129
130
  const withinCategory = (c1, c2) => c1 === c2 || c1.indexOf(c2 + '.') === 0;
130
131
 
131
- function poiMapNameXForm (poi) {
132
+ function poiMapNameXForm(poi) {
132
133
  let name = poi.name;
133
- if (!config.poiMapNameXForm)
134
- return name // no transforms for me today, thanks
134
+ if (!config.poiMapNameXForm) return name; // no transforms for me today, thanks
135
135
  Object.keys(config.poiMapNameXForm)
136
136
  .filter(c2 => withinCategory(poi.category, c2))
137
137
  .forEach(c2 => {
138
138
  const xforms = config.poiMapNameXForm[c2]; // an array of xforms
139
139
  xforms.forEach(xform => (name = name.replace(new RegExp(xform.replace), xform.with)));
140
140
  });
141
- return name
141
+ return name;
142
142
  }
143
143
 
144
144
  /*
@@ -147,36 +147,32 @@ async function create (app, config) {
147
147
  to `false` - then we copy the name from poi.name (and then put it through a
148
148
  set of transformations)
149
149
  */
150
- async function copyPOINames (mapFeatures) {
150
+ async function copyPOINames(mapFeatures) {
151
151
  const newMapFeatures = { ...mapFeatures };
152
152
  const pois = await app.bus.get('poi/getAll');
153
153
 
154
- Object.values(newMapFeatures)
155
- .forEach(layerArray =>
156
- layerArray
157
- .filter(f => f.properties.aiLayer === 'poi' && f.geometry.type === 'Point')
158
- .forEach(f => {
159
- const poi = pois[f.properties.id];
160
- if (!poi)
161
- log.warn(`Unknown poi in style: ${f.properties.id}`);
162
- else {
163
- if (poi.mapLabel)
164
- f.properties.text = poi.mapLabel;
165
- else
166
- if (config.copyPOINamesToMap !== false)
167
- f.properties.text = poiMapNameXForm(poi);
168
- }
169
- }));
170
-
171
- return newMapFeatures
154
+ Object.values(newMapFeatures).forEach(layerArray =>
155
+ layerArray
156
+ .filter(f => f.properties.aiLayer === 'poi' && f.geometry.type === 'Point')
157
+ .forEach(f => {
158
+ const poi = pois[f.properties.id];
159
+ if (!poi) log.warn(`Unknown poi in style: ${f.properties.id}`);
160
+ else {
161
+ if (poi.mapLabel) f.properties.text = poi.mapLabel;
162
+ else if (config.copyPOINamesToMap !== false) f.properties.text = poiMapNameXForm(poi);
163
+ }
164
+ }),
165
+ );
166
+
167
+ return newMapFeatures;
172
168
  }
173
169
 
174
170
  // pass in theme object (parsed from theme file)
175
- function replaceTheme (mapThemeSource) {
171
+ function replaceTheme(mapThemeSource) {
176
172
  app.bus.send('map/replaceTheme', { theme: mapThemeSource });
177
173
  }
178
174
 
179
- function replaceStyle (mapStyleSource) {
175
+ function replaceStyle(mapStyleSource) {
180
176
  app.bus.send('map/replaceStyle', { styleSrc: mapStyleSource });
181
177
  }
182
178
 
@@ -185,7 +181,7 @@ async function create (app, config) {
185
181
  * Returns dictionary of source id to list of GeoJson features
186
182
  * @returns {Promise<Object<string, Array.<GeoJson>>>}
187
183
  */
188
- async function getMapFeatures (venueData) {
184
+ async function getMapFeatures(venueData) {
189
185
  return R__namespace.pipe(
190
186
  R__namespace.prop('structures'),
191
187
  R__namespace.map(R__namespace.prop('levels')),
@@ -195,24 +191,29 @@ async function create (app, config) {
195
191
  // eslint-disable-next-line no-template-curly-in-string
196
192
  R__namespace.map(geoJsonId => venueData.files.geoJson.replace('${geoJsonId}', geoJsonId)),
197
193
  R__namespace.map(venueData.fetchJson),
198
- R__namespace.map(R__namespace.andThen(featureJSON =>
199
- [featureJSON.id, enrichFeaturesForLevel(featureJSON.id, featureJSON.features, venueData.id, venueData.structures)])),
194
+ R__namespace.map(
195
+ R__namespace.andThen(featureJSON => [
196
+ featureJSON.id,
197
+ enrichFeaturesForLevel(featureJSON.id, featureJSON.features, venueData.id, venueData.structures),
198
+ ]),
199
+ ),
200
200
  promises => Zousan.all(promises),
201
- R__namespace.andThen(R__namespace.fromPairs)
202
- )(venueData)
201
+ R__namespace.andThen(R__namespace.fromPairs),
202
+ )(venueData);
203
203
  }
204
204
 
205
205
  const enrichFeaturesForLevel = (levelId, features, venueId, structures) => {
206
206
  const structureId = levelId.replace(/-[^-]*$/, '');
207
- const ordinalId = structureId === venueId
208
- ? 'landscape-background'
209
- : `ordinal: ${structures.find(R__namespace.hasPath(['levels', levelId])).levels[levelId].ordinal}`;
210
- const enrichFeature = (feature) => {
211
- feature = mergeWithProp('properties', ({ venueId, structureId, ordinalId, levelId }), feature);
207
+ const ordinalId =
208
+ structureId === venueId
209
+ ? 'landscape-background'
210
+ : `ordinal: ${structures.find(R__namespace.hasPath(['levels', levelId])).levels[levelId].ordinal}`;
211
+ const enrichFeature = feature => {
212
+ feature = mergeWithProp('properties', { venueId, structureId, ordinalId, levelId }, feature);
212
213
  feature = R__namespace.assoc('id', feature.properties.subid, feature);
213
- return feature
214
+ return feature;
214
215
  };
215
- return features.map(enrichFeature)
216
+ return features.map(enrichFeature);
216
217
  };
217
218
 
218
219
  /**
@@ -226,12 +227,14 @@ async function create (app, config) {
226
227
  const badgesSpriteUrl = venueData.files.spritesheet;
227
228
  const mapGlyphsUrl = venueData.files.glyphs;
228
229
  const { id, bounds, structures, venueCenter, venueRadius, defaultOrdinal } = venueData;
229
- const mapFeatures = venueData.venueList[id].mapTokens ? { [id]: [] } : await getMapFeatures(venueData).then(copyPOINames);
230
+ const mapFeatures = venueData.venueList[id].mapTokens
231
+ ? { [id]: [] }
232
+ : await getMapFeatures(venueData).then(copyPOINames);
230
233
  const venueBounds = {
231
234
  n: bounds.ne.lat,
232
235
  s: bounds.sw.lat,
233
236
  e: bounds.ne.lng,
234
- w: bounds.sw.lng
237
+ w: bounds.sw.lng,
235
238
  };
236
239
  const mapData = {
237
240
  mapFeatures,
@@ -247,7 +250,7 @@ async function create (app, config) {
247
250
  venueRadius,
248
251
  accountId: config.accountId,
249
252
  secure: config.auth !== undefined,
250
- tileServerAuthInfo: venueData.tileServerAuthInfo // only defined for tile maps
253
+ tileServerAuthInfo: venueData.tileServerAuthInfo, // only defined for tile maps
251
254
  };
252
255
  mapDataLoaded.resolve(mapData);
253
256
  app.bus.send('venueData/mapDataLoaded', mapData);
@@ -261,11 +264,12 @@ async function create (app, config) {
261
264
  app.bus.on('venueData/loadBuildingSelectorData', () => {
262
265
  return venueDataLoaded.then(async venueData => {
263
266
  // displayable buildings with levels list ordered by ordinal desc.
264
- const buildings = venueData.structures
265
- .filter(shouldDisplayPredicate)
266
- .map(R__namespace.evolve({ // creates copy of structure with modified levels
267
- levels: R__namespace.pipe(R__namespace.values, R__namespace.sortWith([R__namespace.descend(R__namespace.prop('ordinal'))]))
268
- }));
267
+ const buildings = venueData.structures.filter(shouldDisplayPredicate).map(
268
+ R__namespace.evolve({
269
+ // creates copy of structure with modified levels
270
+ levels: R__namespace.pipe(R__namespace.values, R__namespace.sortWith([R__namespace.descend(R__namespace.prop('ordinal'))])),
271
+ }),
272
+ );
269
273
 
270
274
  // todo order buildings using structureOrder and selectorOrder
271
275
  // currently structures ordering is duplicated in level selectors handlers
@@ -273,23 +277,25 @@ async function create (app, config) {
273
277
  const result = {
274
278
  buildings,
275
279
  structureOrder: venueData.structureOrder,
276
- selectorOrder: venueData.selectorOrder
280
+ selectorOrder: venueData.selectorOrder,
277
281
  };
278
282
  app.bus.send('venueData/buildingSelectorDataLoaded', result);
279
- return result
280
- })
283
+ return result;
284
+ });
281
285
  });
282
286
 
283
- app.bus.on('venueData/normalizeCoords', ({ coords }) => venueDataLoaded.then(venueData => venueLoadingUtils.normalizeCoords(coords, venueData.bounds)));
287
+ app.bus.on('venueData/normalizeCoords', ({ coords }) =>
288
+ venueDataLoaded.then(venueData => venueLoadingUtils.normalizeCoords(coords, venueData.bounds)),
289
+ );
284
290
 
285
291
  const noNavInfo = { edges: [], nodes: [] };
286
292
  app.bus.on('venueData/loadNavGraph', async () => {
287
293
  return venueDataLoaded.then(async venueData => {
288
- const navGraphData = venueData.files.nav ? (await venueData.fetchJson(venueData.files.nav)) : noNavInfo;
294
+ const navGraphData = venueData.files.nav ? await venueData.fetchJson(venueData.files.nav) : noNavInfo;
289
295
  const navGraphOb = { navGraphData, structures: venueData.structures };
290
296
  app.bus.send('venueData/navGraphLoaded', navGraphOb);
291
- return navGraphOb
292
- })
297
+ return navGraphOb;
298
+ });
293
299
  });
294
300
 
295
301
  app.bus.on('venueData/loadPoiData', async () => {
@@ -299,38 +305,52 @@ async function create (app, config) {
299
305
  : venueData.files.pois || venueData.files.poisOld;
300
306
  if (poisUrl) {
301
307
  const pois = await venueData.fetchJson(poisUrl);
302
- app.bus.send('venueData/poiDataLoaded', { pois, structures: venueData.structures });
308
+ app.bus.send('venueData/poiDataLoaded', {
309
+ pois,
310
+ structures: venueData.structures,
311
+ });
303
312
  }
304
- })
313
+ });
305
314
  });
306
315
 
307
- app.bus.on('venueData/getVenueCenter', async () => venueDataLoaded.then(async venueData => (
308
- { lat: venueData.venueCenter[0], lng: venueData.venueCenter[1], ordinal: 0 })));
316
+ app.bus.on('venueData/getVenueCenter', async () =>
317
+ venueDataLoaded.then(async venueData => ({
318
+ lat: venueData.venueCenter[0],
319
+ lng: venueData.venueCenter[1],
320
+ ordinal: 0,
321
+ })),
322
+ );
309
323
 
310
324
  app.bus.on('venueData/getContentUrl', ({ type, name = '' }) =>
311
- venueDataLoaded.then(venueData => venueData.files[type] + name));
312
-
313
- app.bus.on('venueData/getFloorIdToNameMap', () => venueDataLoaded.then(R__namespace.pipe(
314
- R__namespace.prop('structures'),
315
- R__namespace.map(R__namespace.prop('levels')), // get levels for each structure
316
- R__namespace.chain(R__namespace.values), // flatten structures levels into single array
317
- R__namespace.map(R__namespace.props(['id', 'name'])), // create pairs [id, name]
318
- R__namespace.fromPairs // create map of 'id' to 'name'
319
- )));
325
+ venueDataLoaded.then(venueData => venueData.files[type] + name),
326
+ );
327
+
328
+ app.bus.on('venueData/getFloorIdToNameMap', () =>
329
+ venueDataLoaded.then(
330
+ R__namespace.pipe(
331
+ R__namespace.prop('structures'),
332
+ R__namespace.map(R__namespace.prop('levels')), // get levels for each structure
333
+ R__namespace.chain(R__namespace.values), // flatten structures levels into single array
334
+ R__namespace.map(R__namespace.props(['id', 'name'])), // create pairs [id, name]
335
+ R__namespace.fromPairs, // create map of 'id' to 'name'
336
+ ),
337
+ ),
338
+ );
320
339
 
321
340
  app.bus.on('venueData/getFloorIdName', ({ floorId }) => {
322
341
  return venueDataLoaded.then(async venueData => {
323
342
  const structure = R__namespace.pipe(R__namespace.values, R__namespace.find(R__namespace.hasPath(['levels', floorId])))(venueData.structures);
324
- if (!structure) return null
343
+ if (!structure) return null;
325
344
  return {
326
345
  structureId: structure.id,
327
346
  structureName: structure.name,
328
- floorName: structure.levels[floorId].name
329
- }
330
- })
347
+ floorName: structure.levels[floorId].name,
348
+ };
349
+ });
331
350
  });
332
351
 
333
- const getVenueDataProp = (propName, defaultValue) => () => venueDataLoaded.then(R__namespace.pipe(R__namespace.prop(propName), R__namespace.defaultTo(defaultValue)));
352
+ const getVenueDataProp = (propName, defaultValue) => () =>
353
+ venueDataLoaded.then(R__namespace.pipe(R__namespace.prop(propName), R__namespace.defaultTo(defaultValue)));
334
354
 
335
355
  app.bus.on('venueData/getVenueData', () => venueDataLoaded);
336
356
 
@@ -350,21 +370,20 @@ async function create (app, config) {
350
370
  mapDataLoaded.reject(new Error('loadNewVenue called - previous loading ignored'));
351
371
  venueDataLoaded = new Zousan();
352
372
  mapDataLoaded = new Zousan();
353
- loadVenueData({ ...config, venueId, accountId, assetStage }, [])
354
- .then(notifyState);
373
+ loadVenueData({ ...config, venueId, accountId, assetStage }, []).then(notifyState);
355
374
  });
356
375
 
357
376
  // returns a full URL to an image hosted on img.locuslabs.com, size has to be a string of format ${width}x${height}
358
377
  app.bus.on('venueData/getPoiImageUrl', ({ imageName, size }) => {
359
- return `https://img.locuslabs.com/resize/${config.accountId}/png/transparent/${size}contain/poi/${imageName}`
378
+ return `https://img.locuslabs.com/resize/${config.accountId}/png/transparent/${size}contain/poi/${imageName}`;
360
379
  });
361
380
 
362
381
  // This is an utility function that returns a unique ID used to distinguish certain, installation/deployment specific parts
363
382
  // for now it uses venueId and accountId and is used to fix collision when storing data in localStorage
364
383
  app.bus.on('venueData/getDistributionId', () => {
365
384
  return venueDataLoaded.then(venueData => {
366
- return `${venueData.baseVenueId}-${config.accountId}`
367
- })
385
+ return `${venueData.baseVenueId}-${config.accountId}`;
386
+ });
368
387
  });
369
388
 
370
389
  app.bus.on('venueData/getCustomKeywords', () =>
@@ -372,8 +391,9 @@ async function create (app, config) {
372
391
  const searchUrl = config.useOldDataModel
373
392
  ? venueData.files.searchOld || venueData.files.search
374
393
  : venueData.files.search;
375
- return venueData.fetchJson(searchUrl)
376
- }));
394
+ return venueData.fetchJson(searchUrl);
395
+ }),
396
+ );
377
397
 
378
398
  app.bus.on('venueData/isGrabEnabled', getVenueDataProp('enableGrab'));
379
399
 
@@ -382,7 +402,8 @@ async function create (app, config) {
382
402
  app.bus.on('venueData/getAssetsTimestamp', getVenueDataProp('version'));
383
403
 
384
404
  app.bus.on('venueData/getTranslatedFloorId', async ({ floorId }) =>
385
- venueDataLoaded.then(venueData => getTranslatedFloorId(floorId, venueData)));
405
+ venueDataLoaded.then(venueData => getTranslatedFloorId(floorId, venueData)),
406
+ );
386
407
 
387
408
  /**
388
409
  * Takes a floorId that may be from the same venue but localized differently
@@ -398,20 +419,20 @@ async function create (app, config) {
398
419
  * @param {Object} venueData - The venue data object containing the baseVenueId and structures.
399
420
  * @returns {string} - The translated floor ID that matches the venue's baseVenue
400
421
  */
401
- function getTranslatedFloorId (floorId, venueData) {
422
+ function getTranslatedFloorId(floorId, venueData) {
402
423
  const allFloorIds = getAllFloorIds(venueData);
403
424
 
404
- if (allFloorIds.includes(floorId))
405
- return floorId // already in this venue
425
+ if (allFloorIds.includes(floorId)) return floorId; // already in this venue
406
426
 
407
427
  const buildingLevel = floorId.split('-').slice(1).join('-'); // get the building-level part of the floorId
408
428
 
409
429
  // find a floor in the current venueData that matches the specified floorId with just an adjustment to the venueId portion in floorId string construct
410
- return allFloorIds.find(fid => new RegExp(`${venueData.baseVenueId}.?.?-${buildingLevel}`).test(fid))
430
+ return allFloorIds.find(fid => new RegExp(`${venueData.baseVenueId}.?.?-${buildingLevel}`).test(fid));
411
431
  }
412
432
 
413
433
  // returns a list of all floor ids in the venue data
414
- const getAllFloorIds = venueData => venueData.structures.reduce((floors, s) => floors.concat(Object.keys(s.levels)), []);
434
+ const getAllFloorIds = venueData =>
435
+ venueData.structures.reduce((floors, s) => floors.concat(Object.keys(s.levels)), []);
415
436
 
416
437
  /**
417
438
  * Returns object with queue types (security and immigration lanes) that are present in the venue defined in venue data.
@@ -437,13 +458,13 @@ async function create (app, config) {
437
458
  const { id, subtypes } = category;
438
459
  const typesWithImages = subtypes.map(type => {
439
460
  const imageId = lanesWithImages.includes(type.id) && `security-logo-${type.id.toLowerCase()}`;
440
- return { ...type, imageId }
461
+ return { ...type, imageId };
441
462
  });
442
463
  obj[id] = typesWithImages;
443
- return obj
444
- }, {})
445
- } else return {}
446
- })
464
+ return obj;
465
+ }, {});
466
+ } else return {};
467
+ });
447
468
  });
448
469
 
449
470
  const runTest = async ({ testRoutine, reset = false, venueData = null }) => {
@@ -451,17 +472,14 @@ async function create (app, config) {
451
472
  venueDataLoaded = new Zousan();
452
473
  mapDataLoaded = new Zousan();
453
474
  }
454
- if (venueData)
455
- venueDataLoaded = Zousan.resolve(venueData);
475
+ if (venueData) venueDataLoaded = Zousan.resolve(venueData);
456
476
 
457
477
  await testRoutine();
458
478
 
459
479
  let venueDataObj, mapDataObj;
460
- if (venueDataLoaded.v)
461
- venueDataObj = await venueDataLoaded;
462
- if (mapDataLoaded.v)
463
- mapDataObj = await mapDataLoaded;
464
- return { venueDataObj, mapDataObj }
480
+ if (venueDataLoaded.v) venueDataObj = await venueDataLoaded;
481
+ if (mapDataLoaded.v) mapDataObj = await mapDataLoaded;
482
+ return { venueDataObj, mapDataObj };
465
483
  };
466
484
 
467
485
  const init = async () => {
@@ -469,18 +487,16 @@ async function create (app, config) {
469
487
  const lang = params.get('lang');
470
488
  // On first load there is no URL param for lang unless a customer has created one on purposed, in which case that languauge will be loaded in the UI and the map. If it is first load and no language is specified by the param, grab the browser's list of preferred languages. We will then try to display a map venue for their preferred languages in order if we have it.
471
489
  let languagesToTry = [];
472
- if (lang === null) { // So if it is first load
490
+ if (lang === null) {
491
+ // So if it is first load
473
492
  languagesToTry = typeof window === 'undefined' ? [] : navigator.languages; // grab languages to use for alternate maps from the browser's list of preffered languages
474
493
  }
475
494
  const deepLinkProps = config.deepLinkProps || {};
476
495
  if (deepLinkProps.lang) languagesToTry.unshift(deepLinkProps.lang);
477
496
  const venueId = deepLinkProps.vid || config.venueId;
478
- const assetStage = config.useDynamicUrlParams && deepLinkProps.stage
479
- ? deepLinkProps.stage
480
- : config.assetStage;
497
+ const assetStage = config.useDynamicUrlParams && deepLinkProps.stage ? deepLinkProps.stage : config.assetStage;
481
498
  const accountId = deepLinkProps.accountId || (assetStage === 'alpha' ? 'A1VPTJKREFJWX5' : config.accountId);
482
- loadVenueData({ ...config, venueId, accountId, assetStage }, languagesToTry)
483
- .then(notifyState);
499
+ loadVenueData({ ...config, venueId, accountId, assetStage }, languagesToTry).then(notifyState);
484
500
  };
485
501
 
486
502
  return {
@@ -490,9 +506,11 @@ async function create (app, config) {
490
506
  calculateBaseVenueId,
491
507
  getDefaultStructureId,
492
508
  getTranslatedFloorId,
493
- setConfigProperty: (key, value) => { config[key] = value; }
494
- }
495
- }
509
+ setConfigProperty: (key, value) => {
510
+ config[key] = value;
511
+ },
512
+ },
513
+ };
496
514
  }
497
515
 
498
516
  exports.create = create;