atriusmaps-node-sdk 1.0.0 → 3.2.28

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 (105) hide show
  1. package/README.md +76 -0
  2. package/config/rollup.config.cjs.js +31 -0
  3. package/dist/cjs/_virtual/_empty_module_placeholder.js +5 -0
  4. package/dist/cjs/deploy/nodeEntry.js +15 -0
  5. package/dist/cjs/deploy/prepareSDKConfig.js +9 -0
  6. package/dist/cjs/package.json +1 -0
  7. package/dist/cjs/package.json.js +11 -0
  8. package/dist/cjs/plugins/clientAPI/src/clientAPI.js +9 -0
  9. package/dist/cjs/plugins/dynamicPois/src/dynamicPois.js +33 -0
  10. package/dist/cjs/plugins/poiDataManager/src/poiDataManager.js +36 -0
  11. package/dist/cjs/plugins/sdkServer/src/sdkHeadless.js +31 -0
  12. package/dist/cjs/plugins/sdkServer/src/sdkServer.js +13 -0
  13. package/dist/cjs/plugins/sdkServer/src/util.js +10 -0
  14. package/dist/cjs/plugins/searchService/src/poiSearch.js +28 -0
  15. package/dist/cjs/plugins/searchService/src/searchService.js +37 -0
  16. package/dist/cjs/plugins/searchService/src/searchTypeahead.js +8 -0
  17. package/dist/cjs/plugins/searchService/src/utils.js +13 -0
  18. package/dist/cjs/plugins/venueDataLoader/src/venueDataLoader.js +36 -0
  19. package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +34 -0
  20. package/dist/cjs/plugins/wayfinder/src/findRoute.js +30 -0
  21. package/dist/cjs/plugins/wayfinder/src/minPriorityQueue.js +5 -0
  22. package/dist/cjs/plugins/wayfinder/src/navGraph.js +13 -0
  23. package/dist/cjs/plugins/wayfinder/src/navGraphDebug.js +30 -0
  24. package/dist/cjs/plugins/wayfinder/src/segmentBadges.js +5 -0
  25. package/dist/cjs/plugins/wayfinder/src/segmentBuilder.js +32 -0
  26. package/dist/cjs/plugins/wayfinder/src/segmentCategories.js +5 -0
  27. package/dist/cjs/plugins/wayfinder/src/stepBuilder.js +10 -0
  28. package/dist/cjs/plugins/wayfinder/src/wayfinder.js +40 -0
  29. package/dist/cjs/src/app.js +44 -0
  30. package/dist/cjs/src/auth/Auth.js +23 -0
  31. package/dist/cjs/src/configs/postproc-mol-url-parms.js +9 -0
  32. package/dist/cjs/src/configs/postproc-stateTracking.js +31 -0
  33. package/dist/cjs/src/configs/sdkHeadless.json.js +47 -0
  34. package/dist/cjs/src/controller.js +14 -0
  35. package/dist/cjs/src/debugTools.js +30 -0
  36. package/dist/cjs/src/env.js +7 -0
  37. package/dist/cjs/src/extModules/bustle.js +13 -0
  38. package/dist/cjs/src/extModules/flexapi/src/help.js +9 -0
  39. package/dist/cjs/src/extModules/flexapi/src/index.js +13 -0
  40. package/dist/cjs/src/extModules/flexapi/src/validate.js +10 -0
  41. package/dist/cjs/src/extModules/geohasher.js +8 -0
  42. package/dist/cjs/src/extModules/log.js +7 -0
  43. package/dist/cjs/src/historyManager.js +7 -0
  44. package/dist/cjs/src/utils/bounds.js +10 -0
  45. package/dist/cjs/src/utils/buildStructureLookup.js +29 -0
  46. package/dist/cjs/src/utils/configUtils.js +8 -0
  47. package/dist/cjs/src/utils/dom.js +10 -0
  48. package/dist/cjs/src/utils/funcs.js +15 -0
  49. package/dist/cjs/src/utils/geodesy.js +8 -0
  50. package/dist/cjs/src/utils/geom.js +35 -0
  51. package/dist/cjs/src/utils/i18n.js +14 -0
  52. package/dist/cjs/src/utils/observable.js +5 -0
  53. package/dist/cjs/src/utils/rand.js +8 -0
  54. package/lib/_virtual/_empty_module_placeholder.js +1 -0
  55. package/lib/deploy/nodeEntry.js +1 -58
  56. package/lib/deploy/prepareSDKConfig.js +1 -112
  57. package/lib/package.json.js +1 -143
  58. package/lib/plugins/clientAPI/src/clientAPI.js +1 -14
  59. package/lib/plugins/dynamicPois/src/dynamicPois.js +1 -131
  60. package/lib/plugins/poiDataManager/src/poiDataManager.js +1 -207
  61. package/lib/plugins/sdkServer/src/sdkHeadless.js +1 -53
  62. package/lib/plugins/sdkServer/src/sdkServer.js +1 -211
  63. package/lib/plugins/sdkServer/src/util.js +1 -18
  64. package/lib/plugins/searchService/src/poiSearch.js +1 -39
  65. package/lib/plugins/searchService/src/searchService.js +1 -234
  66. package/lib/plugins/searchService/src/searchTypeahead.js +1 -63
  67. package/lib/plugins/searchService/src/utils.js +1 -30
  68. package/lib/plugins/venueDataLoader/src/venueDataLoader.js +1 -465
  69. package/lib/plugins/venueDataLoader/src/venueLoadingUtils.js +1 -84
  70. package/lib/plugins/wayfinder/src/findRoute.js +1 -134
  71. package/lib/plugins/wayfinder/src/minPriorityQueue.js +1 -89
  72. package/lib/plugins/wayfinder/src/navGraph.js +1 -370
  73. package/lib/plugins/wayfinder/src/navGraphDebug.js +1 -95
  74. package/lib/plugins/wayfinder/src/segmentBadges.js +1 -29
  75. package/lib/plugins/wayfinder/src/segmentBuilder.js +1 -241
  76. package/lib/plugins/wayfinder/src/segmentCategories.js +1 -30
  77. package/lib/plugins/wayfinder/src/stepBuilder.js +1 -236
  78. package/lib/plugins/wayfinder/src/wayfinder.js +1 -452
  79. package/lib/src/app.js +1 -150
  80. package/lib/src/auth/Auth.js +1 -35
  81. package/lib/src/configs/postproc-mol-url-parms.js +1 -58
  82. package/lib/src/configs/postproc-stateTracking.js +1 -40
  83. package/lib/src/configs/sdkHeadless.json.js +1 -42
  84. package/lib/src/controller.js +1 -45
  85. package/lib/src/debugTools.js +1 -108
  86. package/lib/src/env.js +1 -17
  87. package/lib/src/extModules/bustle.js +1 -126
  88. package/lib/src/extModules/flexapi/src/help.js +1 -21
  89. package/lib/src/extModules/flexapi/src/index.js +1 -66
  90. package/lib/src/extModules/flexapi/src/validate.js +1 -131
  91. package/lib/src/extModules/geohasher.js +1 -90
  92. package/lib/src/extModules/log.js +1 -70
  93. package/lib/src/historyManager.js +1 -30
  94. package/lib/src/utils/bounds.js +1 -23
  95. package/lib/src/utils/buildStructureLookup.js +1 -17
  96. package/lib/src/utils/configUtils.js +1 -61
  97. package/lib/src/utils/dom.js +1 -46
  98. package/lib/src/utils/funcs.js +1 -50
  99. package/lib/src/utils/geodesy.js +1 -35
  100. package/lib/src/utils/geom.js +1 -141
  101. package/lib/src/utils/i18n.js +1 -70
  102. package/lib/src/utils/observable.js +1 -76
  103. package/lib/src/utils/rand.js +1 -82
  104. package/package.json +23 -6
  105. package/lib/_virtual/_empty_module_placeholder +0 -3
@@ -1,207 +1 @@
1
- import * as R from 'ramda';
2
- import Zousan from 'zousan';
3
- import { buildStructuresLookup } from '../../../src/utils/buildStructureLookup.js';
4
- import { debugIsTrue } from '../../../src/utils/configUtils.js';
5
- import { toLang } from '../../../src/utils/i18n.js';
6
-
7
- async function create (app, config) {
8
- const init = () => {
9
- app.bus.send('venueData/loadPoiData');
10
- };
11
-
12
- let poisLoaded = new Zousan();
13
-
14
- const fixPositionInfo = (poi, structuresLookup) => {
15
- const { position } = poi;
16
- const structure = structuresLookup.floorIdToStructure(position.floorId);
17
- if (!structure) {
18
- console.error(`No structure found for floorId: ${position.floorId} for POI ${poi.poiId}`);
19
- return { ...poi }
20
- }
21
- const floor = structuresLookup.floorIdToFloor(position.floorId);
22
- const detailedPosition = {
23
- ...position,
24
- structureName: structure.name,
25
- buildingId: structure.id,
26
- floorName: floor.name,
27
- floorOrdinal: floor.ordinal
28
- };
29
- return { ...poi, position: detailedPosition }
30
- };
31
-
32
- // todo R.map may be enough to update dictionary values
33
- const formatPois = (pois, structuresLookup) => {
34
- return R.pipe(
35
- R.values,
36
- R.map(poi => {
37
- poi.distance = null;
38
- poi.isNavigable = poi.isNavigable === undefined || poi.isNavigable === true; // isNavigable is true as default, and is optional in the POI data
39
- // poi.isNavigable = /^[a-mA-M]+/.test(poi.name) // uncomment for easy testing of isNavigable
40
- if (poi.capacity)
41
- addToRoomInfo(poi, { name: `Seats ${poi.capacity.join('-')}`, svgId: 'number-of-seats' });
42
- if (poi.category.startsWith('meeting'))
43
- addToRoomInfo(poi, { name: app.gt()('poiView:Conference Room'), svgId: 'conference-room' });
44
-
45
- const roomId = getRoomId(poi);
46
- if (roomId)
47
- poi.roomId = roomId;
48
-
49
- return [poi.poiId, fixPositionInfo(poi, structuresLookup)]
50
- }),
51
- R.fromPairs
52
- )(pois)
53
- };
54
-
55
- const addToRoomInfo = (poi, value) => {
56
- if (!poi.roomInfo) {
57
- poi.roomInfo = [];
58
- }
59
- poi.roomInfo.push(value);
60
- };
61
-
62
- const getRoomId = R.pipe(
63
- R.propOr([], 'externalIds'),
64
- R.find(R.propEq('type', 'roomId')),
65
- R.prop('id'),
66
- R.unless(R.isNil, R.tail)
67
- );
68
-
69
- app.bus.on('venueData/poiDataLoaded', ({ pois, structures }) => {
70
- const structuresLookup = buildStructuresLookup(structures);
71
- const formattedPois = formatPois(pois, structuresLookup);
72
- if (debugIsTrue(app, 'pseudoTransPois'))
73
- for (const id in formattedPois)
74
- formattedPois[id] = pseudoTransPoi(formattedPois[id], app.i18n().language);
75
- poisLoaded.resolve(formattedPois);
76
-
77
- if (app.config.debug && app.env.isBrowser)
78
- window._pois = formattedPois;
79
- });
80
-
81
- app.bus.on('poi/getById', async ({ id }) => {
82
- return poisLoaded.then(pois => pois[id]).then(poi => poi && addImages(poi))
83
- });
84
-
85
- app.bus.on('poi/getByFloorId', async ({ floorId }) => poisLoaded.then(
86
- R.pickBy(R.pathEq(['position', 'floorId'], floorId))));
87
-
88
- app.bus.on('poi/getByCategoryId', async ({ categoryId }) => {
89
- // returns true for exact category matches or parent category matches
90
- const categoryMatch = (poi) => poi.category === categoryId || poi.category.startsWith(categoryId + '.');
91
- return poisLoaded.then(R.pickBy(categoryMatch))
92
- });
93
-
94
- app.bus.on('poi/getAll', async () => {
95
- return poisLoaded
96
- });
97
-
98
- const checkpointPath = ['queue', 'primaryQueueId'];
99
- const addOtherSecurityLanesIfNeeded = async poi => {
100
- const primaryCheckpointId = R.path(checkpointPath, poi);
101
-
102
- if (!primaryCheckpointId) return poi
103
-
104
- const queueTypes = await app.bus.get('venueData/getQueueTypes');
105
- const securityPoisMap = await app.bus.get('poi/getByCategoryId', { categoryId: 'security' });
106
- const securityPoisList = Object.values(securityPoisMap);
107
-
108
- poi.queue.otherQueues = prepareOtherSecurityLanes(queueTypes, poi, securityPoisList);
109
- return poi
110
- };
111
-
112
- const prepareOtherSecurityLanes = (queueTypes, currentPoi, securityPois) => {
113
- const queueTypePath = ['queue', 'queueType'];
114
- const queueType = R.path(queueTypePath, currentPoi);
115
- if (!queueType)
116
- return null
117
-
118
- const queueSubtypes = queueTypes[queueType];
119
- const primaryCheckpointId = R.path(checkpointPath, currentPoi);
120
- return securityPois
121
- .filter(R.pathEq(checkpointPath, primaryCheckpointId)) // filter only connected security checkpoints
122
- .filter(poi => poi.poiId !== currentPoi.poiId) // skip current poi
123
- .map(poi => {
124
- const laneId = R.path(['queue', 'queueSubtype'], poi);
125
- const lane = getLaneData(laneId)(queueSubtypes);
126
- return { poiId: poi.poiId, ...lane }
127
- })
128
- };
129
-
130
- const getLaneData = laneId => R.pipe(
131
- R.find(R.propEq('id', laneId)),
132
- R.pick(['displayText', 'imageId'])
133
- );
134
-
135
- /**
136
- * Updates security checkpoint POI with a list of related security checkpoints.
137
- */
138
- app.bus.on('poi/addOtherSecurityLanes', ({ poi }) => addOtherSecurityLanesIfNeeded(poi));
139
-
140
- async function addImages (poi) {
141
- if (!poi) return
142
- if (!R.length(poi.images)) {
143
- poi.images = [];
144
- } else if (!poi.images[0].startsWith('https:')) { // then images are not yet transformed
145
- poi.images = await Zousan.all(
146
- poi.images.map(imageName =>
147
- app.bus.get('venueData/getPoiImageUrl', { imageName, size: '480x320' })));
148
- }
149
- return poi
150
- }
151
-
152
- const getUniqueCategories = R.memoizeWith(R.identity, R.pipe(R.pluck('category'), R.values, R.uniq));
153
- app.bus.on('poi/getAllCategories', async () => poisLoaded.then(getUniqueCategories));
154
-
155
- app.bus.on('venueData/loadNewVenue', () => {
156
- poisLoaded = new Zousan();
157
- init();
158
- });
159
-
160
- // See architectural document at https://docs.google.com/document/d/1NoBAboHR9BiX_vvLef-vp3ButrIQDWYofcTsdilEWvs/edit#
161
- app.bus.on('poi/setDynamicData', ({ plugin, idValuesMap }) => {
162
- poisLoaded
163
- .then(pois => {
164
- for (const poiId in idValuesMap) {
165
- // const dd = { [plugin]: idValuesMap[poiId] }
166
- const dynamicData = pois[poiId].dynamicData || {};
167
- dynamicData[plugin] = { ...idValuesMap[poiId] };
168
- const newPoi = R.mergeRight(pois[poiId], { dynamicData });
169
- pois[poiId] = newPoi;
170
- }
171
- });
172
- });
173
-
174
- const runTest = async (testRoutine) => {
175
- await testRoutine();
176
- return poisLoaded
177
- };
178
-
179
- return {
180
- init,
181
- runTest,
182
- internal: {
183
- addImages,
184
- pseudoTransPoi
185
- }
186
- }
187
- }
188
-
189
- function pseudoTransPoi (poi, lang) {
190
- ['description', 'nearbyLandmark', 'name', 'phone', 'operationHours']
191
- .forEach(p => {
192
- if (poi[p])
193
- poi[p] = toLang(poi[p], lang);
194
- });
195
- if (poi.keywords)
196
- poi.keywords = poi.keywords.map(keyword => {
197
- keyword.name = toLang(keyword.name, lang);
198
- return keyword
199
- });
200
- if (poi.position.floorName)
201
- poi.position.floorName = toLang(poi.position.floorName, lang);
202
- if (poi.position.structureName)
203
- poi.position.structureName = toLang(poi.position.structureName, lang);
204
- return poi
205
- }
206
-
207
- export { create };
1
+ import*as o from"ramda";import e from"zousan";import{buildStructuresLookup as t}from"../../../src/utils/buildStructureLookup.js";import{debugIsTrue as i}from"../../../src/utils/configUtils.js";import{toLang as a}from"../../../src/utils/i18n.js";async function n(a,n){const s=a.log.sublog("poiDataManager"),u=()=>{a.bus.send("venueData/loadPoiData")};let p=new e;const d=(o,e)=>{const{position:t}=o,i=e.floorIdToStructure(t.floorId);if(!i)return s.error(`No structure found for floorId: ${t.floorId} for POI ${o.poiId}`),{...o};const a=e.floorIdToFloor(t.floorId),n={...t,structureName:i.name,buildingId:i.id,floorName:a.name,floorOrdinal:a.ordinal};return{...o,position:n}},c=(o,e)=>{o.roomInfo||(o.roomInfo=[]),o.roomInfo.push(e)},l=o.pipe(o.propOr([],"externalIds"),o.find(o.propEq("type","roomId")),o.prop("id"),o.unless(o.isNil,o.tail));a.bus.on("venueData/poiDataLoaded",(async({pois:e,structures:n})=>{if(e=((e,t)=>o.pipe(o.values,o.map((o=>{o.distance=null,o.isNavigable=void 0===o.isNavigable||!0===o.isNavigable,o.capacity&&c(o,{name:`Seats ${o.capacity.join("-")}`,svgId:"number-of-seats"}),o.category.startsWith("meeting")&&c(o,{name:a.gt()("poiView:Conference Room"),svgId:"conference-room"});const e=l(o);return e&&(o.roomId=e),[o.poiId,d(o,t)]})),o.fromPairs)(e))(e,t(n)),i(a,"pseudoTransPois"))for(const o in e)e[o]=r(e[o],a.i18n().language);e=function(o){const e=[];return Object.values(o).forEach((o=>{try{const t=o.position;t?["buildingId","structureName","floorId","floorName","floorOrdinal","latitude","longitude"].forEach((i=>{null!==t[i]&&void 0!==t[i]||e.push({id:o.poiId,e:`invalid position property: ${i}: ${t[i]}`})})):e.push({poi:o,e:"No position information"})}catch(t){s.error(t),e.push({id:o.poiId,e:t.message})}})),e.length&&(s.warn("badPois:",e),e.forEach((e=>{delete o[e.id]}))),o}(e),await async function(o){for(const e of Object.values(o))await y(e);return o}(e),p.resolve(e),a.config.debug&&a.env.isBrowser&&(window._pois=e),a.config.debug&&async function(o){const e=Date.now(),t=[],i=await a.bus.get("wayfinder/_getNavGraph");Object.values(o).forEach((o=>{try{const e=o.position;i.findClosestNode(e.floorId,e.latitude,e.longitude)||t.push({id:o.poiId,e:"No closest Navgraph Node"})}catch(e){s.error(e),t.push({id:o.poiId,e:e.message})}})),t.length&&s.warn("badPois:",t),s(`Total time for navgraph POI check: ${Date.now()-e}ms`)}(e)})),a.bus.on("poi/getById",(async({id:o})=>p.then((e=>e[o])))),a.bus.on("poi/getByFloorId",(async({floorId:e})=>p.then(o.pickBy(o.pathEq(["position","floorId"],e))))),a.bus.on("poi/getByCategoryId",(async({categoryId:e})=>p.then(o.pickBy((o=>o.category===e||o.category.startsWith(e+".")))))),a.bus.on("poi/getAll",(async()=>p));const f=["queue","primaryQueueId"],m=(e,t,i)=>{const a=o.path(["queue","queueType"],t);if(!a)return null;const n=e[a],r=o.path(f,t);return i.filter(o.pathEq(f,r)).filter((o=>o.poiId!==t.poiId)).map((e=>{const t=o.path(["queue","queueSubtype"],e),i=g(t)(n);return{poiId:e.poiId,...i}}))},g=e=>{return o.pipe(o.find(o.propEq("id",e)),(t=`No queue found with ID: ${e}`,o=>{if(null!=o)return o;throw Error(t)}),o.pick(["displayText","imageId"]));var t};async function y(t){if(!t)return;const i="undefined"==typeof window?1:window.devicePixelRatio||1;return o.length(t.images)?t.images[0].startsWith("https:")||(t.images=await e.all(t.images.map((o=>a.bus.get("venueData/getPoiImageUrl",{imageName:o,size:`${351*i}x${197*i}`}))))):t.images=[],t}a.bus.on("poi/addOtherSecurityLanes",(({poi:e})=>(async e=>{if(!o.path(f,e))return e;const t=await a.bus.get("venueData/getQueueTypes"),i=await a.bus.get("poi/getByCategoryId",{categoryId:"security"}),n=Object.values(i);return e.queue.otherQueues=m(t,e,n),e})(e)));const I=o.memoizeWith(o.identity,o.pipe(o.pluck("category"),o.values,o.uniq));a.bus.on("poi/getAllCategories",(async()=>p.then(I))),a.bus.on("venueData/loadNewVenue",(()=>{p=new e,u()})),a.bus.on("poi/setDynamicData",(({plugin:e,idValuesMap:t})=>{p.then((i=>{for(const a in t){const n=i[a].dynamicData||{};n[e]={...t[a]};const r=o.mergeRight(i[a],{dynamicData:n});i[a]=r}}))}));return{init:u,runTest:async o=>(await o(),p),internal:{addImages:y,pseudoTransPoi:r}}}function r(o,e){return["description","nearbyLandmark","name","phone","operationHours"].forEach((t=>{o[t]&&(o[t]=a(o[t],e))})),o.keywords&&(o.keywords=o.keywords.map((o=>(o.name=a(o.name,e),o)))),o.position.floorName&&(o.position.floorName=a(o.position.floorName,e)),o.position.structureName&&(o.position.structureName=a(o.position.structureName,e)),o}export{n as create};
@@ -1,53 +1 @@
1
- import * as R from 'ramda';
2
- import { locationToEndpoint, getStructures } from './util.js';
3
-
4
- const headlessCommands = [
5
- {
6
- command: 'getDirections',
7
- args: [
8
- { name: 'from', type: 'location' },
9
- { name: 'to', type: 'location' },
10
- { name: 'accessible', type: 'boolean', optional: true }
11
- ]
12
- },
13
- { command: 'getPOIDetails', args: [{ name: 'poiId', type: 'integer', min: 0 }] },
14
- { command: 'getAllPOIs' },
15
- { command: 'getStructures' },
16
- { command: 'getVenueData' },
17
- {
18
- command: 'search',
19
- args: [
20
- { name: 'term', type: 'string', minLength: 2 },
21
- { name: 'details', type: 'boolean', optional: true }
22
- ]
23
- }
24
- ];
25
-
26
- function handleHeadless (app) {
27
- app.bus.on('clientAPI/getDirections', async ({ from, to, accessible }) => {
28
- const fromEndpoint = await locationToEndpoint(app, from);
29
- const toEndpoint = await locationToEndpoint(app, to);
30
- return app.bus.get('wayfinder/getRoute', { fromEndpoint, toEndpoint, options: { requiresAccessibility: accessible } })
31
- .then(R.pick(['distance', 'time', 'steps', 'navline']))
32
- });
33
-
34
- app.bus.on('clientAPI/getPOIDetails', async ({ poiId }) => app.bus.get('poi/getById', { id: poiId }));
35
-
36
- app.bus.on('clientAPI/getAllPOIs', async () => app.bus.get('poi/getAll'));
37
-
38
- app.bus.on('clientAPI/getStructures', () => getStructures(app));
39
-
40
- const isNotFunction = o => typeof o !== 'function';
41
- app.bus.on('clientAPI/getVenueData', async () => {
42
- const vd = await app.bus.get('venueData/getVenueData');
43
- return R.filter(isNotFunction, vd)
44
- });
45
-
46
- app.bus.on('clientAPI/search', async ({ term, details }) => app.bus.get('search/queryAsync', { term }).then(poiList => {
47
- const poiIdList = poiList.map(poi => poi.poiId);
48
- app.bus.send('event/search', { referrer: 'prog', searchMethod: null, query: term, entities: poiIdList });
49
- return details ? poiList : poiIdList
50
- }));
51
- }
52
-
53
- export { handleHeadless, headlessCommands };
1
+ import*as e from"ramda";import{locationToEndpoint as t,getStructures as n}from"./util.js";const s=[{command:"destroy"},{command:"getDirections",args:[{name:"from",type:"location"},{name:"to",type:"location"},{name:"accessible",type:"boolean",optional:!0},{name:"queueTypes",type:"list",itemType:{type:"string"},optional:!0}]},{command:"getPOIDetails",args:[{name:"poiId",type:"integer",min:0}]},{command:"getAllPOIs"},{command:"getStructures"},{command:"getVenueData"},{command:"search",args:[{name:"term",type:"string",minLength:2},{name:"details",type:"boolean",optional:!0}]}];function a(s){s.bus.on("clientAPI/destroy",(async()=>s.destroy())),s.bus.on("clientAPI/getDirections",(async({from:n,to:a,accessible:o,queueTypes:i})=>{const r=await t(s,n),c=await t(s,a),u={requiresAccessibility:!!o};return i&&(u.selectedSecurityLanes={SecurityLane:i}),s.bus.get("wayfinder/getRoute",{fromEndpoint:r,toEndpoint:c,options:u}).then(e.pick(["distance","time","steps","navline"]))})),s.bus.on("clientAPI/getPOIDetails",(async({poiId:e})=>s.bus.get("poi/getById",{id:e}))),s.bus.on("clientAPI/getAllPOIs",(async()=>s.bus.get("poi/getAll"))),s.bus.on("clientAPI/getStructures",(()=>n(s)));const a=e=>"function"!=typeof e;s.bus.on("clientAPI/getVenueData",(async()=>{const t=await s.bus.get("venueData/getVenueData");return e.filter(a,t)})),s.bus.on("clientAPI/search",(async({term:e,details:t})=>s.bus.get("search/queryAsync",{term:e}).then((n=>{const a=n.map((e=>e.poiId));return s.bus.send("event/search",{referrer:"prog",searchMethod:null,query:e,entities:a}),t?n:a}))))}export{a as handleHeadless,s as headlessCommands};
@@ -1,211 +1 @@
1
- import { getBuildingAndFloorAtPoint } from '../../../src/utils/geom.js';
2
- import create$1 from '../../../src/utils/observable.js';
3
- import { headlessCommands, handleHeadless } from './sdkHeadless.js';
4
-
5
- let hasAddedListener = false;
6
-
7
- // browser based communication
8
- // listens for messages passed through
9
- // postMessage and converts them to clientAPI/execute calls..
10
- // responds by sending messages back through postMessage
11
- // returns a sendEvent function used for sending events through postMessage as well
12
- function getBrowserCom (app) {
13
- const sendResponse = (payload, clientMsgId) => {
14
- const ob = {
15
- payload,
16
- type: 'LL-server'
17
- };
18
- if (clientMsgId)
19
- ob.clientMsgId = clientMsgId;
20
- window.postMessage(ob, '*');
21
- };
22
-
23
- const sendError = (payload, clientMsgId) => {
24
- const ob = {
25
- error: true,
26
- payload,
27
- type: 'LL-server'
28
- };
29
- if (clientMsgId)
30
- ob.clientMsgId = clientMsgId;
31
- window.postMessage(ob, '*');
32
- };
33
-
34
- const sendEvent = (event, payload) => {
35
- const ob = {
36
- event,
37
- payload,
38
- type: 'LL-server'
39
- };
40
- window.postMessage(ob, '*');
41
- };
42
-
43
- function msgHandler (e) {
44
- const d = e.data;
45
- if (d && d.type === 'LL-client') { // confirm message is from our "client"
46
- app.bus.get('clientAPI/execute', d.payload)
47
- .then(resOb => sendResponse(resOb, d.msgId))
48
- .catch(er => sendError(er, d.msgId));
49
- }
50
- }
51
-
52
- // Listen for HTML5 postMessage events - these come from SDKClient apps
53
- if (!hasAddedListener) {
54
- window.addEventListener('message', msgHandler, false);
55
- hasAddedListener = true;
56
- }
57
-
58
- return sendEvent
59
- }
60
-
61
- // For node, command sending and response sending is handled via
62
- // nodeEntry - no postMessage required.
63
- // sendEvent attaches a hook into app to receive them...
64
- function getNodeCom (app) {
65
- const eventListener = create$1();
66
- app.eventListener = eventListener;
67
- const sendEvent = (event, payload) => eventListener.fire(event, payload);
68
- return sendEvent
69
- }
70
-
71
- function registerCustomTypes (app) {
72
- app.bus.send('clientAPI/registerCustomType', {
73
- name: 'latLngOrdLocation',
74
- spec: {
75
- type: 'object',
76
- props: [
77
- { name: 'lat', type: 'float' },
78
- { name: 'lng', type: 'float' },
79
- { name: 'ord', type: 'integer' }
80
- ]
81
- }
82
- });
83
-
84
- app.bus.send('clientAPI/registerCustomType', {
85
- name: 'latLngFloorLocation',
86
- spec: {
87
- type: 'object',
88
- props: [
89
- { name: 'lat', type: 'float' },
90
- { name: 'lng', type: 'float' },
91
- { name: 'floorId', type: 'string' }
92
- ]
93
- }
94
- });
95
-
96
- app.bus.send('clientAPI/registerCustomType', {
97
- name: 'poiIdLocation',
98
- spec: {
99
- type: 'object',
100
- props: [
101
- { name: 'poiId', type: 'integer', min: 0 }
102
- ]
103
- }
104
- });
105
-
106
- app.bus.send('clientAPI/registerCustomType', {
107
- name: 'location',
108
- spec: {
109
- type: 'multi',
110
- types: [
111
- { type: 'poiIdLocation' },
112
- { type: 'latLngOrdLocation' },
113
- { type: 'latLngFloorLocation' }
114
- ]
115
- }
116
- });
117
-
118
- app.bus.send('clientAPI/registerCustomType', {
119
- name: 'viewSettings',
120
- spec: {
121
- type: 'object',
122
- props: [
123
- { name: 'zoom', type: 'float', optional: true },
124
- { name: 'pitch', type: 'float', optional: true },
125
- { name: 'bearing', type: 'float', optional: true }
126
- ]
127
- }
128
- });
129
- }
130
-
131
- function registerEvents (app, sendEvent) {
132
- app.bus.monitor('map/userMoveStart', async ({ pitch, zoom, bearing }) => {
133
- const { lat, lng, floorId, ordinal, structureId } = await app.bus.get('map/getMapCenter');
134
- sendEvent('userMoveStart', { lat, lng, floorId, ord: ordinal, structureId, pitch, zoom, bearing });
135
- });
136
-
137
- app.bus.monitor('map/userMoving', async ({ pitch, zoom, bearing }) => {
138
- const { lat, lng, floorId, ordinal, structureId } = await app.bus.get('map/getMapCenter');
139
- sendEvent('userMoving', { lat, lng, floorId, ord: ordinal, structureId, pitch, zoom, bearing });
140
- });
141
-
142
- app.bus.monitor('map/moveEnd', async ({ pitch, zoom, bearing }) => {
143
- const { lat, lng, floorId, ordinal, structureId } = await app.bus.get('map/getMapCenter');
144
- sendEvent('moveEnd', { lat, lng, floorId, ord: ordinal, structureId, pitch, zoom, bearing });
145
- });
146
-
147
- app.bus.monitor('map/floorChanged', ({ structure, floor }) =>
148
- sendEvent('levelChange', {
149
- floorId: floor ? floor.id : null,
150
- floorName: floor ? floor.name : null,
151
- ord: floor ? floor.ordinal : null,
152
- structureId: structure ? structure.id : null,
153
- structureName: structure ? structure.name : null
154
- }));
155
-
156
- app.bus.monitor('map/poiClicked', ({ poi }) =>
157
- sendEvent('poiSelected', poi));
158
-
159
- app.bus.monitor('map/click', async ({ lat, lng, ord }) => {
160
- const structures = await app.bus.get('venueData/getStructures');
161
- const { building, floor } = getBuildingAndFloorAtPoint(structures, lat, lng, ord, true);
162
- sendEvent('mapClicked', { lat, lng, ord, building, floor });
163
- });
164
- }
165
-
166
- async function create (app, config) {
167
- const sendEvent = app.env.isBrowser
168
- ? getBrowserCom(app)
169
- : getNodeCom(app);
170
-
171
- const init = async () => {
172
- // Register the Custom Types
173
- registerCustomTypes(app);
174
-
175
- // Register our commands
176
- headlessCommands.forEach(cdef => app.bus.send('clientAPI/registerCommand', cdef));
177
- handleHeadless(app);
178
-
179
- if (!config.headless) {
180
- await import('../../../_virtual/_empty_module_placeholder')
181
- .then(sdkVisual => {
182
- sdkVisual.visualCommands.forEach(cdef => app.bus.send('clientAPI/registerCommand', cdef));
183
- sdkVisual.handleVisual(app);
184
- });
185
- }
186
-
187
- const weReady = () => {
188
- app.bus.get('clientAPI/execute', { command: 'getCommandJSON' })
189
- .then(commandJSON => sendEvent('ready', { commandJSON }));
190
- if (!config.headless && app.config.uiHide && app.config.uiHide.sidebar && app.env.isDesktop())
191
- app.bus.send('map/changePadding', { padding: { left: 55, right: 55, top: 72, bottom: 22 } });
192
- };
193
-
194
- if (config.headless) // in headless case, we are ready once data is ready
195
- Promise.all([
196
- new Promise(resolve => app.bus.monitor('venueData/navGraphLoaded', resolve)),
197
- new Promise(resolve => app.bus.monitor('venueData/poiDataLoaded', resolve))
198
- ]).then(weReady);
199
- else
200
- app.bus.on('map/mapReadyToShow', weReady);
201
- };
202
-
203
- // Register Events
204
- registerEvents(app, sendEvent);
205
-
206
- return {
207
- init
208
- }
209
- }
210
-
211
- export { create };
1
+ import{getBuildingAndFloorAtPoint as e}from"../../../src/utils/geom.js";import t from"../../../src/utils/observable.js";import{headlessCommands as o,handleHeadless as n}from"./sdkHeadless.js";let a=null;function s(e){const t=(e,t)=>{const o={payload:e,type:"LL-server"};t&&(o.clientMsgId=t);try{window.postMessage(o,"*")}catch(e){window.postMessage((e=>JSON.parse(JSON.stringify(e)))(o),"*")}};function o(o){const n=o.data;n&&"LL-client"===n.type&&e.bus.get("clientAPI/execute",n.payload).then((e=>t(e,n.msgId))).catch((t=>{e.config.debug&&console.error(t),((e,t)=>{const o={error:!0,payload:e,type:"LL-server"};t&&(o.clientMsgId=t),window.postMessage(o,"*")})(t.message,n.msgId)}))}return a&&a(),window.addEventListener("message",o),a=()=>window.removeEventListener("message",o),(e,t)=>{const o={event:e,payload:t,type:"LL-server"};window.postMessage(o,"*")}}async function r(a,r){const i=a.env.isBrowser?s(a):function(e){const o=t();return e.eventListener=o,(e,t)=>o.fire(e,t)}(a);return function(t,o){t.bus.monitor("map/userMoveStart",(async({pitch:e,zoom:n,bearing:a})=>{const{lat:s,lng:r,floorId:i,ordinal:l,structureId:d}=await t.bus.get("map/getMapCenter");o("userMoveStart",{lat:s,lng:r,floorId:i,ord:l,structureId:d,pitch:e,zoom:n,bearing:a})})),t.bus.monitor("map/userMoving",(async({pitch:e,zoom:n,bearing:a})=>{const{lat:s,lng:r,floorId:i,ordinal:l,structureId:d}=await t.bus.get("map/getMapCenter");o("userMoving",{lat:s,lng:r,floorId:i,ord:l,structureId:d,pitch:e,zoom:n,bearing:a})})),t.bus.monitor("map/moveEnd",(async({pitch:e,zoom:n,bearing:a})=>{const{lat:s,lng:r,floorId:i,ordinal:l,structureId:d}=await t.bus.get("map/getMapCenter");o("moveEnd",{lat:s,lng:r,floorId:i,ord:l,structureId:d,pitch:e,zoom:n,bearing:a})})),t.bus.monitor("map/floorChanged",(({structure:e,floor:t})=>o("levelChange",{floorId:t?t.id:null,floorName:t?t.name:null,ord:t?t.ordinal:null,structureId:e?e.id:null,structureName:e?e.name:null}))),t.bus.monitor("map/poiClicked",(({poi:e})=>o("poiSelected",e))),t.bus.monitor("map/click",(async({lat:n,lng:a,ord:s})=>{const r=await t.bus.get("venueData/getStructures"),{building:i,floor:l}=e(r,n,a,s,!0);o("mapClicked",{lat:n,lng:a,ord:s,building:i,floor:l})}))}(a,i),{init:async()=>{!function(e){e.bus.send("clientAPI/registerCustomType",{name:"latLngOrdLocation",spec:{type:"object",props:[{name:"lat",type:"float"},{name:"lng",type:"float"},{name:"ord",type:"integer"}]}}),e.bus.send("clientAPI/registerCustomType",{name:"latLngFloorLocation",spec:{type:"object",props:[{name:"lat",type:"float"},{name:"lng",type:"float"},{name:"floorId",type:"string"}]}}),e.bus.send("clientAPI/registerCustomType",{name:"poiIdLocation",spec:{type:"object",props:[{name:"poiId",type:"integer",min:0}]}}),e.bus.send("clientAPI/registerCustomType",{name:"location",spec:{type:"multi",types:[{type:"poiIdLocation"},{type:"latLngOrdLocation"},{type:"latLngFloorLocation"}]}}),e.bus.send("clientAPI/registerCustomType",{name:"viewSettings",spec:{type:"object",props:[{name:"zoom",type:"float",optional:!0},{name:"pitch",type:"float",optional:!0},{name:"bearing",type:"float",optional:!0}]}})}(a),o.forEach((e=>a.bus.send("clientAPI/registerCommand",e))),n(a),r.headless||await import("../../../_virtual/_empty_module_placeholder.js").then((e=>{e.visualCommands.forEach((e=>a.bus.send("clientAPI/registerCommand",e))),e.handleVisual(a)}));const e=async()=>{await a.bus.send("sdk/readyWhenYouAre"),a.bus.get("clientAPI/execute",{command:"getCommandJSON"}).then((e=>i("ready",{commandJSON:e}))),!r.headless&&a.config.uiHide&&a.config.uiHide.sidebar&&a.env.isDesktop()&&a.bus.send("map/changePadding",{padding:{left:55,right:55,top:72,bottom:22}})};r.headless?Promise.all([new Promise((e=>a.bus.monitor("venueData/navGraphLoaded",e))),new Promise((e=>a.bus.monitor("venueData/poiDataLoaded",e)))]).then(e):a.bus.on("map/mapReadyToShow",e)}}}export{r as create};
@@ -1,18 +1 @@
1
- import { getFloorAt, getFloor } from '../../../src/utils/geom.js';
2
-
3
- const getStructures = async app => app.bus.get('venueData/getVenueData').then(vd => vd.structures);
4
-
5
- async function locationToEndpoint (app, location) {
6
- if (location.poiId)
7
- return app.bus.get('wayfinder/getNavigationEndpoint', { ep: location.poiId })
8
- const { lat, lng, ord, floorId, title = '' } = location;
9
- const structures = await getStructures();
10
- const floor = ord !== undefined ? getFloorAt(structures, lat, lng, ord) : getFloor(structures, floorId);
11
- if (ord !== undefined)
12
- return { lat, lng, ordinal: ord, floorId: floor ? floor.id : null, title }
13
- if (!floor)
14
- throw Error('Call to locationToEndpoint with no ordinal and no floorId (or an invalid one): ' + floorId)
15
- return { lat, lng, floorId, ordinal: floor.ordinal, title }
16
- }
17
-
18
- export { getStructures, locationToEndpoint };
1
+ import{getFloorAt as o,getFloor as t}from"../../../src/utils/geom.js";const n=async o=>o.bus.get("venueData/getVenueData").then((o=>o.structures));async function i(i,r){if(r.poiId)return i.bus.get("wayfinder/getNavigationEndpoint",{ep:r.poiId});const{lat:l,lng:a,ord:e,floorId:d,title:u=""}=r,s=await n(i),f=void 0!==e?o(s,l,a,e):t(s,d);if(void 0!==e)return{lat:l,lng:a,ordinal:e,floorId:f?f.id:null,title:u};if(!f)throw Error("Call to locationToEndpoint with no ordinal and no floorId (or an invalid one): "+d);return{lat:l,lng:a,floorId:d,ordinal:f.ordinal,title:u}}export{n as getStructures,i as locationToEndpoint};
@@ -1,39 +1 @@
1
- import * as R from 'ramda';
2
- import { getFlexSearchInstance } from './utils.js';
3
-
4
- function createPOISearch (pois, lang) {
5
- const index = getFlexSearchInstance({ lang });
6
-
7
- index.addMatcher({
8
- '[\'.,]': ''
9
- });
10
-
11
- prepareIndexEntries(pois)
12
- .forEach(([id, content]) => index.add(id, content));
13
-
14
- function prepareIndexEntries (pois) {
15
- return Object.values(pois).map((poi) => {
16
- const { poiId, category = '', name, keywords = [], roomId = '' } = poi;
17
- const grabTags = R.path(['dynamicData', 'grab', 'tags'], poi) || [];
18
- const searchKeywords = keywords
19
- .filter(R.prop('isUserSearchable'))
20
- .map(R.prop('name'));
21
- const content = `${name} ${category.split('.').join(' ')} ${roomId} ${searchKeywords.join(' ')} ${grabTags.join(' ')}`;
22
- return [Number(poiId), content]
23
- })
24
- }
25
-
26
- function search (queryParams) {
27
- const ids = index.search(queryParams);
28
- return Object.values(R.pick(ids, pois))
29
- }
30
-
31
- function updateMultiple (pois) {
32
- prepareIndexEntries(pois)
33
- .forEach(([id, content]) => index.update(id, content));
34
- }
35
-
36
- return { search, updateMultiple }
37
- }
38
-
39
- export default createPOISearch;
1
+ import*as a from"ramda";import{getFlexSearchInstance as r}from"./utils.js";function t(t,e){const o=r({lang:e});function n(r){return Object.values(r).map((r=>{const{poiId:t,category:e="",name:o,keywords:n=[],roomId:c=""}=r,i=a.path(["dynamicData","grab","tags"],r)||[],p=n.filter(a.prop("isUserSearchable")).map(a.prop("name")),s=`${o} ${e.split(".").join(" ")} ${c} ${p.join(" ")} ${i.join(" ")}`;return[Number(t),s]}))}return o.addMatcher({"['.,]":""}),n(t).forEach((([a,r])=>o.add(a,r))),{search:function(r){const e=o.search(r);return Object.values(a.pick(e,t))},updateMultiple:function(a){n(a).forEach((([a,r])=>o.update(a,r)))}}}export{t as default};