atriusmaps-node-sdk 3.3.196 → 3.3.226

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 (109) hide show
  1. package/dist/cjs/_virtual/_empty_module_placeholder.js +2 -2
  2. package/dist/cjs/deploy/prepareSDKConfig.js +152 -2
  3. package/dist/cjs/nodesdk/nodeEntry.js +109 -0
  4. package/dist/cjs/package.json.js +190 -14
  5. package/dist/cjs/plugins/clientAPI/src/clientAPI.js +11 -2
  6. package/dist/cjs/plugins/dynamicPois/src/dynamicPois.js +218 -21
  7. package/dist/cjs/plugins/poiDataManager/src/poiDataManager.js +292 -21
  8. package/dist/cjs/plugins/sdkServer/src/sdkHeadless.js +99 -20
  9. package/dist/cjs/plugins/sdkServer/src/sdkServer.js +219 -2
  10. package/dist/cjs/plugins/sdkServer/src/util.js +16 -3
  11. package/dist/cjs/plugins/searchService/src/poiSearch.js +57 -19
  12. package/dist/cjs/plugins/searchService/src/searchService.js +246 -21
  13. package/dist/cjs/plugins/searchService/src/searchTypeahead.js +60 -3
  14. package/dist/cjs/plugins/searchService/src/utils.js +23 -4
  15. package/dist/cjs/plugins/venueDataLoader/src/venueDataLoader.js +472 -21
  16. package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +191 -23
  17. package/dist/cjs/plugins/wayfinder/src/findRoute.js +147 -19
  18. package/dist/cjs/plugins/wayfinder/src/minPriorityQueue.js +88 -2
  19. package/dist/cjs/plugins/wayfinder/src/navGraph.js +393 -5
  20. package/dist/cjs/plugins/wayfinder/src/navGraphDebug.js +110 -20
  21. package/dist/cjs/plugins/wayfinder/src/segmentBadges.js +28 -2
  22. package/dist/cjs/plugins/wayfinder/src/segmentBuilder.js +257 -19
  23. package/dist/cjs/plugins/wayfinder/src/segmentCategories.js +29 -2
  24. package/dist/cjs/plugins/wayfinder/src/stepBuilder.js +238 -3
  25. package/dist/cjs/plugins/wayfinder/src/wayfinder.js +597 -22
  26. package/dist/cjs/src/app.js +191 -25
  27. package/dist/cjs/src/configs/postproc-mol-url-parms.js +58 -2
  28. package/dist/cjs/src/configs/postproc-stateTracking.js +53 -19
  29. package/dist/cjs/src/controller.js +43 -4
  30. package/dist/cjs/src/debugTools.js +128 -23
  31. package/dist/cjs/src/env.js +17 -2
  32. package/dist/cjs/src/extModules/bustle.js +128 -4
  33. package/dist/cjs/src/extModules/flexapi/src/help.js +23 -4
  34. package/dist/cjs/src/extModules/flexapi/src/index.js +65 -4
  35. package/dist/cjs/src/extModules/flexapi/src/validate.js +133 -5
  36. package/dist/cjs/src/extModules/geohasher.js +90 -3
  37. package/dist/cjs/src/extModules/log.js +69 -2
  38. package/dist/cjs/src/historyManager.js +29 -2
  39. package/dist/cjs/src/utils/bounds.js +22 -4
  40. package/dist/cjs/src/utils/buildStructureLookup.js +31 -19
  41. package/dist/cjs/src/utils/configUtils.js +71 -3
  42. package/dist/cjs/src/utils/dom.js +48 -5
  43. package/dist/cjs/src/utils/funcs.js +30 -3
  44. package/dist/cjs/src/utils/geodesy.js +35 -3
  45. package/dist/cjs/src/utils/geom.js +209 -27
  46. package/dist/cjs/src/utils/i18n.js +69 -5
  47. package/dist/cjs/src/utils/observable.js +73 -2
  48. package/dist/cjs/src/utils/rand.js +82 -3
  49. package/dist/nodesdk/nodeEntry.js +1 -0
  50. package/dist/package.json.js +1 -0
  51. package/dist/plugins/searchService/src/searchService.js +1 -0
  52. package/dist/plugins/venueDataLoader/src/venueDataLoader.js +1 -0
  53. package/dist/plugins/venueDataLoader/src/venueLoadingUtils.js +1 -0
  54. package/dist/src/app.js +1 -0
  55. package/package.json +13 -9
  56. package/.yarnrc.yml +0 -1
  57. package/config/rollup.config.cjs.js +0 -31
  58. package/dist/cjs/deploy/nodeEntry.js +0 -20
  59. package/dist/cjs/src/auth/Auth.js +0 -23
  60. package/lib/deploy/nodeEntry.js +0 -1
  61. package/lib/package.json.js +0 -1
  62. package/lib/plugins/searchService/src/searchService.js +0 -1
  63. package/lib/plugins/venueDataLoader/src/venueDataLoader.js +0 -1
  64. package/lib/plugins/venueDataLoader/src/venueLoadingUtils.js +0 -1
  65. package/lib/src/app.js +0 -1
  66. package/lib/src/configs/sdkHeadless.json +0 -28
  67. /package/{lib → dist}/_virtual/_empty_module_placeholder.js +0 -0
  68. /package/{lib → dist}/deploy/prepareSDKConfig.js +0 -0
  69. /package/{lib → dist}/plugins/clientAPI/src/clientAPI.js +0 -0
  70. /package/{lib → dist}/plugins/dynamicPois/src/dynamicPois.js +0 -0
  71. /package/{lib → dist}/plugins/poiDataManager/src/poiDataManager.js +0 -0
  72. /package/{lib → dist}/plugins/sdkServer/src/sdkHeadless.js +0 -0
  73. /package/{lib → dist}/plugins/sdkServer/src/sdkServer.js +0 -0
  74. /package/{lib → dist}/plugins/sdkServer/src/util.js +0 -0
  75. /package/{lib → dist}/plugins/searchService/src/poiSearch.js +0 -0
  76. /package/{lib → dist}/plugins/searchService/src/searchTypeahead.js +0 -0
  77. /package/{lib → dist}/plugins/searchService/src/utils.js +0 -0
  78. /package/{lib → dist}/plugins/wayfinder/src/findRoute.js +0 -0
  79. /package/{lib → dist}/plugins/wayfinder/src/minPriorityQueue.js +0 -0
  80. /package/{lib → dist}/plugins/wayfinder/src/navGraph.js +0 -0
  81. /package/{lib → dist}/plugins/wayfinder/src/navGraphDebug.js +0 -0
  82. /package/{lib → dist}/plugins/wayfinder/src/segmentBadges.js +0 -0
  83. /package/{lib → dist}/plugins/wayfinder/src/segmentBuilder.js +0 -0
  84. /package/{lib → dist}/plugins/wayfinder/src/segmentCategories.js +0 -0
  85. /package/{lib → dist}/plugins/wayfinder/src/stepBuilder.js +0 -0
  86. /package/{lib → dist}/plugins/wayfinder/src/wayfinder.js +0 -0
  87. /package/{lib → dist}/src/configs/postproc-mol-url-parms.js +0 -0
  88. /package/{lib → dist}/src/configs/postproc-stateTracking.js +0 -0
  89. /package/{lib → dist}/src/configs/sdkHeadless.json.js +0 -0
  90. /package/{lib → dist}/src/controller.js +0 -0
  91. /package/{lib → dist}/src/debugTools.js +0 -0
  92. /package/{lib → dist}/src/env.js +0 -0
  93. /package/{lib → dist}/src/extModules/bustle.js +0 -0
  94. /package/{lib → dist}/src/extModules/flexapi/src/help.js +0 -0
  95. /package/{lib → dist}/src/extModules/flexapi/src/index.js +0 -0
  96. /package/{lib → dist}/src/extModules/flexapi/src/validate.js +0 -0
  97. /package/{lib → dist}/src/extModules/geohasher.js +0 -0
  98. /package/{lib → dist}/src/extModules/log.js +0 -0
  99. /package/{lib → dist}/src/historyManager.js +0 -0
  100. /package/{lib → dist}/src/utils/bounds.js +0 -0
  101. /package/{lib → dist}/src/utils/buildStructureLookup.js +0 -0
  102. /package/{lib → dist}/src/utils/configUtils.js +0 -0
  103. /package/{lib → dist}/src/utils/dom.js +0 -0
  104. /package/{lib → dist}/src/utils/funcs.js +0 -0
  105. /package/{lib → dist}/src/utils/geodesy.js +0 -0
  106. /package/{lib → dist}/src/utils/geom.js +0 -0
  107. /package/{lib → dist}/src/utils/i18n.js +0 -0
  108. /package/{lib → dist}/src/utils/observable.js +0 -0
  109. /package/{lib → dist}/src/utils/rand.js +0 -0
@@ -2,30 +2,109 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var e = require('ramda');
5
+ var R = require('ramda');
6
6
  var util = require('./util.js');
7
7
 
8
8
  function _interopNamespace(e) {
9
- if (e && e.__esModule) return e;
10
- var n = Object.create(null);
11
- if (e) {
12
- Object.keys(e).forEach(function (k) {
13
- if (k !== 'default') {
14
- var d = Object.getOwnPropertyDescriptor(e, k);
15
- Object.defineProperty(n, k, d.get ? d : {
16
- enumerable: true,
17
- get: function () { return e[k]; }
18
- });
19
- }
20
- });
21
- }
22
- n["default"] = e;
23
- return Object.freeze(n);
9
+ if (e && e.__esModule) return e;
10
+ var n = Object.create(null);
11
+ if (e) {
12
+ Object.keys(e).forEach(function (k) {
13
+ if (k !== 'default') {
14
+ var d = Object.getOwnPropertyDescriptor(e, k);
15
+ Object.defineProperty(n, k, d.get ? d : {
16
+ enumerable: true,
17
+ get: function () { return e[k]; }
18
+ });
19
+ }
20
+ });
21
+ }
22
+ n["default"] = e;
23
+ return Object.freeze(n);
24
24
  }
25
25
 
26
- var e__namespace = /*#__PURE__*/_interopNamespace(e);
26
+ var R__namespace = /*#__PURE__*/_interopNamespace(R);
27
27
 
28
- 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:"getDirectionsMultiple",args:[{name:"locations",type:"list",itemType:{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 i(s){s.bus.on("clientAPI/destroy",(async()=>s.destroy())),s.bus.on("clientAPI/getDirections",(async({from:n,to:i,accessible:a,queueTypes:o})=>{const c=await util.locationToEndpoint(s,n),r=await util.locationToEndpoint(s,i),l={requiresAccessibility:!!a};return o&&(l.selectedSecurityLanes={SecurityLane:o}),s.bus.get("wayfinder/getRoute",{fromEndpoint:c,toEndpoint:r,options:l}).then(e__namespace.pick(["distance","time","steps","navline","waypoints"]))})),s.bus.on("clientAPI/getDirectionsMultiple",(async({locations:n,accessible:i,queueTypes:a})=>{const o=await Promise.all(n.map((async e=>util.locationToEndpoint(s,e)))),c={requiresAccessibility:!!i};a&&(c.selectedSecurityLanes={SecurityLane:a});const r=await Promise.all(e__namespace.aperture(2,o).map((async e=>s.bus.get("wayfinder/getRoute",{fromEndpoint:e[0],toEndpoint:e[1],options:c})))),l=e__namespace.map(e__namespace.pick(["distance","time","steps","navline","waypoints"]),r);return {total:{distance:e__namespace.sum(e__namespace.map((e=>e.distance),l)),time:e__namespace.sum(e__namespace.map((e=>e.time),l))},directions:l}})),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",(()=>util.getStructures(s)));const i=e=>"function"!=typeof e;s.bus.on("clientAPI/getVenueData",(async()=>{const t=await s.bus.get("venueData/getVenueData");return e__namespace.filter(i,t)})),s.bus.on("clientAPI/search",(async({term:e,details:t})=>s.bus.get("search/queryAsync",{term:e}).then((n=>{const i=n.map((e=>e.poiId));return s.bus.send("event/search",{referrer:"prog",searchMethod:null,query:e,entities:i}),t?n:i}))));}
28
+ const headlessCommands = [
29
+ { command: 'destroy' },
30
+ {
31
+ command: 'getDirections',
32
+ args: [
33
+ { name: 'from', type: 'location' },
34
+ { name: 'to', type: 'location' },
35
+ { name: 'accessible', type: 'boolean', optional: true },
36
+ { name: 'queueTypes', type: 'list', itemType: { type: 'string' }, optional: true }
37
+ ]
38
+ },
39
+ {
40
+ command: 'getDirectionsMultiple',
41
+ args: [
42
+ { name: 'locations', type: 'list', itemType: { type: 'location' } },
43
+ { name: 'accessible', type: 'boolean', optional: true },
44
+ { name: 'queueTypes', type: 'list', itemType: { type: 'string' }, optional: true }
45
+ ]
46
+ },
47
+ { command: 'getPOIDetails', args: [{ name: 'poiId', type: 'integer', min: 0 }] },
48
+ { command: 'getAllPOIs' },
49
+ { command: 'getStructures' },
50
+ { command: 'getVenueData' },
51
+ {
52
+ command: 'search',
53
+ args: [
54
+ { name: 'term', type: 'string', minLength: 2 },
55
+ { name: 'details', type: 'boolean', optional: true }
56
+ ]
57
+ }
58
+ ];
29
59
 
30
- exports.handleHeadless = i;
31
- exports.headlessCommands = s;
60
+ function handleHeadless (app) {
61
+ app.bus.on('clientAPI/destroy', async () => app.destroy());
62
+
63
+ app.bus.on('clientAPI/getDirections', async ({ from, to, accessible, queueTypes }) => {
64
+ const fromEndpoint = await util.locationToEndpoint(app, from);
65
+ const toEndpoint = await util.locationToEndpoint(app, to);
66
+ const options = { requiresAccessibility: !!accessible };
67
+ if (queueTypes)
68
+ options.selectedSecurityLanes = { SecurityLane: queueTypes };
69
+ return app.bus.get('wayfinder/getRoute', { fromEndpoint, toEndpoint, options })
70
+ .then(R__namespace.pick(['distance', 'time', 'steps', 'navline', 'waypoints']))
71
+ });
72
+
73
+ app.bus.on('clientAPI/getDirectionsMultiple', async ({ locations, accessible, queueTypes }) => {
74
+ const endpoints = await Promise.all(locations.map(async l => util.locationToEndpoint(app, l)));
75
+ const options = { requiresAccessibility: !!accessible };
76
+ if (queueTypes)
77
+ options.selectedSecurityLanes = { SecurityLane: queueTypes };
78
+ const routes = await Promise.all(R__namespace.aperture(2, endpoints).map(async a =>
79
+ app.bus.get('wayfinder/getRoute', { fromEndpoint: a[0], toEndpoint: a[1], options })));
80
+ const directions = R__namespace.map(R__namespace.pick(['distance', 'time', 'steps', 'navline', 'waypoints']), routes);
81
+ return {
82
+ total: {
83
+ distance: R__namespace.sum(R__namespace.map(d => d.distance, directions)),
84
+ time: R__namespace.sum(R__namespace.map(d => d.time, directions))
85
+ },
86
+ directions
87
+ }
88
+ });
89
+
90
+ app.bus.on('clientAPI/getPOIDetails', async ({ poiId }) => app.bus.get('poi/getById', { id: poiId }));
91
+
92
+ app.bus.on('clientAPI/getAllPOIs', async () => app.bus.get('poi/getAll'));
93
+
94
+ app.bus.on('clientAPI/getStructures', () => util.getStructures(app));
95
+
96
+ const isNotFunction = o => typeof o !== 'function';
97
+ app.bus.on('clientAPI/getVenueData', async () => {
98
+ const vd = await app.bus.get('venueData/getVenueData');
99
+ return R__namespace.filter(isNotFunction, vd)
100
+ });
101
+
102
+ app.bus.on('clientAPI/search', async ({ term, details }) => app.bus.get('search/queryAsync', { term }).then(poiList => {
103
+ const poiIdList = poiList.map(poi => poi.poiId);
104
+ app.bus.send('event/search', { referrer: 'prog', searchMethod: null, query: term, entities: poiIdList });
105
+ return details ? poiList : poiIdList
106
+ }));
107
+ }
108
+
109
+ exports.handleHeadless = handleHeadless;
110
+ exports.headlessCommands = headlessCommands;
@@ -8,6 +8,223 @@ var sdkHeadless = require('./sdkHeadless.js');
8
8
 
9
9
  function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, 'default': e }); }
10
10
 
11
- 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=observable();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("poiDetails/showPoi",(({poi:e})=>o("poiShown",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}=geom.getBuildingAndFloorAtPoint(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),sdkHeadless.headlessCommands.forEach((e=>a.bus.send("clientAPI/registerCommand",e))),sdkHeadless.handleHeadless(a),r.headless||await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('../../../_virtual/_empty_module_placeholder.js')); }).then((e=>{e.visualCommands.forEach((e=>a.bus.send("clientAPI/registerCommand",e))),e.handleVisual(a,i);}));const e=async()=>{await a.bus.send("system/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),a.bus.on("sdkServer/sendEvent",(({eventName:e,...t})=>i(e,t)));}}}
11
+ let removePreviousListener = null;
12
12
 
13
- exports.create = r;
13
+ // browser based communication
14
+ // listens for messages passed through
15
+ // postMessage and converts them to clientAPI/execute calls..
16
+ // responds by sending messages back through postMessage
17
+ // returns a sendEvent function used for sending events through postMessage as well
18
+ function getBrowserCom (app) {
19
+ const clean = ob => JSON.parse(JSON.stringify(ob));
20
+ const sendResponse = (payload, clientMsgId) => {
21
+ const ob = {
22
+ payload,
23
+ type: 'LL-server'
24
+ };
25
+ if (clientMsgId)
26
+ ob.clientMsgId = clientMsgId;
27
+ try {
28
+ window.postMessage(ob, '*');
29
+ } catch (e) { window.postMessage(clean(ob), '*'); } // failure to send could be due to non-marshalable object - this helps
30
+ };
31
+
32
+ const sendError = (payload, clientMsgId) => {
33
+ const ob = {
34
+ error: true,
35
+ payload,
36
+ type: 'LL-server'
37
+ };
38
+ if (clientMsgId)
39
+ ob.clientMsgId = clientMsgId;
40
+ window.postMessage(ob, '*');
41
+ };
42
+
43
+ const sendEvent = (event, payload) => {
44
+ const ob = {
45
+ event,
46
+ payload,
47
+ type: 'LL-server'
48
+ };
49
+ window.postMessage(ob, '*');
50
+ };
51
+
52
+ function msgHandler (e) {
53
+ const d = e.data;
54
+ if (d && d.type === 'LL-client') { // confirm message is from our "client"
55
+ app.bus.get('clientAPI/execute', d.payload)
56
+ .then(resOb => sendResponse(resOb, d.msgId))
57
+ .catch(er => {
58
+ if (app.config.debug)
59
+ console.error(er);
60
+ sendError(er.message, d.msgId);
61
+ });
62
+ }
63
+ }
64
+
65
+ // Listen for HTML5 postMessage events - these come from SDKClient apps
66
+ if (removePreviousListener)
67
+ removePreviousListener();
68
+ window.addEventListener('message', msgHandler);
69
+ removePreviousListener = () => window.removeEventListener('message', msgHandler);
70
+
71
+ return sendEvent
72
+ }
73
+
74
+ // For node, command sending and response sending is handled via
75
+ // nodeEntry - no postMessage required.
76
+ // sendEvent attaches a hook into app to receive them...
77
+ function getNodeCom (app) {
78
+ const eventListener = observable();
79
+ app.eventListener = eventListener;
80
+ const sendEvent = (event, payload) => eventListener.fire(event, payload);
81
+ return sendEvent
82
+ }
83
+
84
+ function registerCustomTypes (app) {
85
+ app.bus.send('clientAPI/registerCustomType', {
86
+ name: 'latLngOrdLocation',
87
+ spec: {
88
+ type: 'object',
89
+ props: [
90
+ { name: 'lat', type: 'float' },
91
+ { name: 'lng', type: 'float' },
92
+ { name: 'ord', type: 'integer' }
93
+ ]
94
+ }
95
+ });
96
+
97
+ app.bus.send('clientAPI/registerCustomType', {
98
+ name: 'latLngFloorLocation',
99
+ spec: {
100
+ type: 'object',
101
+ props: [
102
+ { name: 'lat', type: 'float' },
103
+ { name: 'lng', type: 'float' },
104
+ { name: 'floorId', type: 'string' }
105
+ ]
106
+ }
107
+ });
108
+
109
+ app.bus.send('clientAPI/registerCustomType', {
110
+ name: 'poiIdLocation',
111
+ spec: {
112
+ type: 'object',
113
+ props: [
114
+ { name: 'poiId', type: 'integer', min: 0 }
115
+ ]
116
+ }
117
+ });
118
+
119
+ app.bus.send('clientAPI/registerCustomType', {
120
+ name: 'location',
121
+ spec: {
122
+ type: 'multi',
123
+ types: [
124
+ { type: 'poiIdLocation' },
125
+ { type: 'latLngOrdLocation' },
126
+ { type: 'latLngFloorLocation' }
127
+ ]
128
+ }
129
+ });
130
+
131
+ app.bus.send('clientAPI/registerCustomType', {
132
+ name: 'viewSettings',
133
+ spec: {
134
+ type: 'object',
135
+ props: [
136
+ { name: 'zoom', type: 'float', optional: true },
137
+ { name: 'pitch', type: 'float', optional: true },
138
+ { name: 'bearing', type: 'float', optional: true }
139
+ ]
140
+ }
141
+ });
142
+ }
143
+
144
+ function registerEvents (app, sendEvent) {
145
+ app.bus.monitor('map/userMoveStart', async ({ pitch, zoom, bearing }) => {
146
+ const { lat, lng, floorId, ordinal, structureId } = await app.bus.get('map/getMapCenter');
147
+ sendEvent('userMoveStart', { lat, lng, floorId, ord: ordinal, structureId, pitch, zoom, bearing });
148
+ });
149
+
150
+ app.bus.monitor('map/userMoving', async ({ pitch, zoom, bearing }) => {
151
+ const { lat, lng, floorId, ordinal, structureId } = await app.bus.get('map/getMapCenter');
152
+ sendEvent('userMoving', { lat, lng, floorId, ord: ordinal, structureId, pitch, zoom, bearing });
153
+ });
154
+
155
+ app.bus.monitor('map/moveEnd', async ({ pitch, zoom, bearing }) => {
156
+ const { lat, lng, floorId, ordinal, structureId } = await app.bus.get('map/getMapCenter');
157
+ sendEvent('moveEnd', { lat, lng, floorId, ord: ordinal, structureId, pitch, zoom, bearing });
158
+ });
159
+
160
+ app.bus.monitor('map/floorChanged', ({ structure, floor }) =>
161
+ sendEvent('levelChange', {
162
+ floorId: floor ? floor.id : null,
163
+ floorName: floor ? floor.name : null,
164
+ ord: floor ? floor.ordinal : null,
165
+ structureId: structure ? structure.id : null,
166
+ structureName: structure ? structure.name : null
167
+ }));
168
+
169
+ app.bus.monitor('map/poiClicked', ({ poi }) =>
170
+ sendEvent('poiSelected', poi));
171
+
172
+ app.bus.monitor('poiDetails/showPoi', ({ poi }) =>
173
+ sendEvent('poiShown', poi));
174
+
175
+ app.bus.monitor('map/click', async ({ lat, lng, ord }) => {
176
+ const structures = await app.bus.get('venueData/getStructures');
177
+ const { building, floor } = geom.getBuildingAndFloorAtPoint(structures, lat, lng, ord, true);
178
+ sendEvent('mapClicked', { lat, lng, ord, building, floor });
179
+ });
180
+ }
181
+
182
+ async function create (app, config) {
183
+ const sendEvent = app.env.isBrowser
184
+ ? getBrowserCom(app)
185
+ : getNodeCom(app);
186
+
187
+ const init = async () => {
188
+ // Register the Custom Types
189
+ registerCustomTypes(app);
190
+
191
+ // Register our commands
192
+ sdkHeadless.headlessCommands.forEach(cdef => app.bus.send('clientAPI/registerCommand', cdef));
193
+ sdkHeadless.handleHeadless(app);
194
+
195
+ if (!config.headless) {
196
+ await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('../../../_virtual/_empty_module_placeholder.js')); })
197
+ .then(sdkVisual => {
198
+ sdkVisual.visualCommands.forEach(cdef => app.bus.send('clientAPI/registerCommand', cdef));
199
+ sdkVisual.handleVisual(app, sendEvent);
200
+ });
201
+ }
202
+
203
+ const weReady = async () => {
204
+ await app.bus.send('system/readywhenyouare'); // give other modules a chance to hold us up...
205
+ app.bus.get('clientAPI/execute', { command: 'getCommandJSON' })
206
+ .then(commandJSON => sendEvent('ready', { commandJSON }));
207
+ if (!config.headless && app.config.uiHide && app.config.uiHide.sidebar && app.env.isDesktop())
208
+ app.bus.send('map/changePadding', { padding: { left: 55, right: 55, top: 72, bottom: 22 } });
209
+ };
210
+
211
+ if (config.headless) // in headless case, we are ready once data is ready
212
+ Promise.all([
213
+ new Promise(resolve => app.bus.monitor('venueData/navGraphLoaded', resolve)),
214
+ new Promise(resolve => app.bus.monitor('venueData/poiDataLoaded', resolve))
215
+ ]).then(weReady);
216
+ else
217
+ app.bus.on('map/mapReadyToShow', weReady);
218
+
219
+ app.bus.on('sdkServer/sendEvent', ({ eventName, ...props }) => sendEvent(eventName, props));
220
+ };
221
+
222
+ // Register Events
223
+ registerEvents(app, sendEvent);
224
+
225
+ return {
226
+ init
227
+ }
228
+ }
229
+
230
+ exports.create = create;
@@ -4,7 +4,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var geom = require('../../../src/utils/geom.js');
6
6
 
7
- 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?geom.getFloorAt(s,l,a,e):geom.getFloor(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}}
7
+ const getStructures = async app => app.bus.get('venueData/getVenueData').then(vd => vd.structures);
8
8
 
9
- exports.getStructures = n;
10
- exports.locationToEndpoint = i;
9
+ async function locationToEndpoint (app, location) {
10
+ if (location.poiId)
11
+ return app.bus.get('wayfinder/getNavigationEndpoint', { ep: location.poiId })
12
+ const { lat, lng, ord, floorId, title = '' } = location;
13
+ const structures = await getStructures(app);
14
+ const floor = ord !== undefined ? geom.getFloorAt(structures, lat, lng, ord) : geom.getFloor(structures, floorId);
15
+ if (ord !== undefined)
16
+ return { lat, lng, ordinal: ord, floorId: floor ? floor.id : null, title }
17
+ if (!floor)
18
+ throw Error('Call to locationToEndpoint with no ordinal and no floorId (or an invalid one): ' + floorId)
19
+ return { lat, lng, floorId, ordinal: floor.ordinal, title }
20
+ }
21
+
22
+ exports.getStructures = getStructures;
23
+ exports.locationToEndpoint = locationToEndpoint;
@@ -1,28 +1,66 @@
1
1
  'use strict';
2
2
 
3
- var e = require('ramda');
3
+ var R = require('ramda');
4
4
  var utils = require('./utils.js');
5
5
 
6
6
  function _interopNamespace(e) {
7
- if (e && e.__esModule) return e;
8
- var n = Object.create(null);
9
- if (e) {
10
- Object.keys(e).forEach(function (k) {
11
- if (k !== 'default') {
12
- var d = Object.getOwnPropertyDescriptor(e, k);
13
- Object.defineProperty(n, k, d.get ? d : {
14
- enumerable: true,
15
- get: function () { return e[k]; }
16
- });
17
- }
18
- });
19
- }
20
- n["default"] = e;
21
- return Object.freeze(n);
7
+ if (e && e.__esModule) return e;
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n["default"] = e;
21
+ return Object.freeze(n);
22
22
  }
23
23
 
24
- var e__namespace = /*#__PURE__*/_interopNamespace(e);
24
+ var R__namespace = /*#__PURE__*/_interopNamespace(R);
25
25
 
26
- function r(r,e){const o=utils.getFlexSearchInstance({lang:e});function n(a){return Object.values(a).map((a=>{const{poiId:r,category:e="",name:o,keywords:n=[],roomId:i=""}=a,c=e__namespace.path(["dynamicData","grab","tags"],a)||[],s=n.filter(e__namespace.prop("isUserSearchable")).map(e__namespace.prop("name")),p=`${o} ${e.split(".").join(" ")} ${i} ${s.join(" ")} ${c.join(" ")}`;return [Number(r),p]}))}return n(r).forEach((([t,a])=>o.add(t,a))),{search:function(a){const e={...a};e.limit||(e.limit=5e3);const n=o.search(e);return Object.values(e__namespace.pick(n,r))},updateMultiple:function(t){n(t).forEach((([t,a])=>o.update(t,a)));}}}
26
+ const DEFAULT_RESULTS_LIMIT = 5000;
27
27
 
28
- module.exports = r;
28
+ function createPOISearch (pois, lang) {
29
+ const index = utils.getFlexSearchInstance({ lang });
30
+
31
+ // index.addMatcher({
32
+ // '[\'.,]': ''
33
+ // })
34
+
35
+ prepareIndexEntries(pois)
36
+ .forEach(([id, content]) => index.add(id, content));
37
+
38
+ function prepareIndexEntries (pois) {
39
+ return Object.values(pois).map((poi) => {
40
+ const { poiId, category = '', name, keywords = [], roomId = '' } = poi;
41
+ const grabTags = R__namespace.path(['dynamicData', 'grab', 'tags'], poi) || [];
42
+ const searchKeywords = keywords
43
+ .filter(R__namespace.prop('isUserSearchable'))
44
+ .map(R__namespace.prop('name'));
45
+ const content = `${name} ${category.split('.').join(' ')} ${roomId} ${searchKeywords.join(' ')} ${grabTags.join(' ')}`;
46
+ return [Number(poiId), content]
47
+ })
48
+ }
49
+
50
+ function search (queryParams) {
51
+ const options = { ...queryParams };
52
+ if (!options.limit) // sometimes limit is NaN or undefined!
53
+ options.limit = DEFAULT_RESULTS_LIMIT;
54
+ const ids = index.search(options);
55
+ return Object.values(R__namespace.pick(ids, pois))
56
+ }
57
+
58
+ function updateMultiple (pois) {
59
+ prepareIndexEntries(pois)
60
+ .forEach(([id, content]) => index.update(id, content));
61
+ }
62
+
63
+ return { search, updateMultiple }
64
+ }
65
+
66
+ module.exports = createPOISearch;