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.
- package/dist/cjs/_virtual/_empty_module_placeholder.js +2 -2
- package/dist/cjs/deploy/prepareSDKConfig.js +152 -2
- package/dist/cjs/nodesdk/nodeEntry.js +109 -0
- package/dist/cjs/package.json.js +190 -14
- package/dist/cjs/plugins/clientAPI/src/clientAPI.js +11 -2
- package/dist/cjs/plugins/dynamicPois/src/dynamicPois.js +218 -21
- package/dist/cjs/plugins/poiDataManager/src/poiDataManager.js +292 -21
- package/dist/cjs/plugins/sdkServer/src/sdkHeadless.js +99 -20
- package/dist/cjs/plugins/sdkServer/src/sdkServer.js +219 -2
- package/dist/cjs/plugins/sdkServer/src/util.js +16 -3
- package/dist/cjs/plugins/searchService/src/poiSearch.js +57 -19
- package/dist/cjs/plugins/searchService/src/searchService.js +246 -21
- package/dist/cjs/plugins/searchService/src/searchTypeahead.js +60 -3
- package/dist/cjs/plugins/searchService/src/utils.js +23 -4
- package/dist/cjs/plugins/venueDataLoader/src/venueDataLoader.js +472 -21
- package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +191 -23
- package/dist/cjs/plugins/wayfinder/src/findRoute.js +147 -19
- package/dist/cjs/plugins/wayfinder/src/minPriorityQueue.js +88 -2
- package/dist/cjs/plugins/wayfinder/src/navGraph.js +393 -5
- package/dist/cjs/plugins/wayfinder/src/navGraphDebug.js +110 -20
- package/dist/cjs/plugins/wayfinder/src/segmentBadges.js +28 -2
- package/dist/cjs/plugins/wayfinder/src/segmentBuilder.js +257 -19
- package/dist/cjs/plugins/wayfinder/src/segmentCategories.js +29 -2
- package/dist/cjs/plugins/wayfinder/src/stepBuilder.js +238 -3
- package/dist/cjs/plugins/wayfinder/src/wayfinder.js +597 -22
- package/dist/cjs/src/app.js +191 -25
- package/dist/cjs/src/configs/postproc-mol-url-parms.js +58 -2
- package/dist/cjs/src/configs/postproc-stateTracking.js +53 -19
- package/dist/cjs/src/controller.js +43 -4
- package/dist/cjs/src/debugTools.js +128 -23
- package/dist/cjs/src/env.js +17 -2
- package/dist/cjs/src/extModules/bustle.js +128 -4
- package/dist/cjs/src/extModules/flexapi/src/help.js +23 -4
- package/dist/cjs/src/extModules/flexapi/src/index.js +65 -4
- package/dist/cjs/src/extModules/flexapi/src/validate.js +133 -5
- package/dist/cjs/src/extModules/geohasher.js +90 -3
- package/dist/cjs/src/extModules/log.js +69 -2
- package/dist/cjs/src/historyManager.js +29 -2
- package/dist/cjs/src/utils/bounds.js +22 -4
- package/dist/cjs/src/utils/buildStructureLookup.js +31 -19
- package/dist/cjs/src/utils/configUtils.js +71 -3
- package/dist/cjs/src/utils/dom.js +48 -5
- package/dist/cjs/src/utils/funcs.js +30 -3
- package/dist/cjs/src/utils/geodesy.js +35 -3
- package/dist/cjs/src/utils/geom.js +209 -27
- package/dist/cjs/src/utils/i18n.js +69 -5
- package/dist/cjs/src/utils/observable.js +73 -2
- package/dist/cjs/src/utils/rand.js +82 -3
- package/dist/nodesdk/nodeEntry.js +1 -0
- package/dist/package.json.js +1 -0
- package/dist/plugins/searchService/src/searchService.js +1 -0
- package/dist/plugins/venueDataLoader/src/venueDataLoader.js +1 -0
- package/dist/plugins/venueDataLoader/src/venueLoadingUtils.js +1 -0
- package/dist/src/app.js +1 -0
- package/package.json +13 -9
- package/.yarnrc.yml +0 -1
- package/config/rollup.config.cjs.js +0 -31
- package/dist/cjs/deploy/nodeEntry.js +0 -20
- package/dist/cjs/src/auth/Auth.js +0 -23
- package/lib/deploy/nodeEntry.js +0 -1
- package/lib/package.json.js +0 -1
- package/lib/plugins/searchService/src/searchService.js +0 -1
- package/lib/plugins/venueDataLoader/src/venueDataLoader.js +0 -1
- package/lib/plugins/venueDataLoader/src/venueLoadingUtils.js +0 -1
- package/lib/src/app.js +0 -1
- package/lib/src/configs/sdkHeadless.json +0 -28
- /package/{lib → dist}/_virtual/_empty_module_placeholder.js +0 -0
- /package/{lib → dist}/deploy/prepareSDKConfig.js +0 -0
- /package/{lib → dist}/plugins/clientAPI/src/clientAPI.js +0 -0
- /package/{lib → dist}/plugins/dynamicPois/src/dynamicPois.js +0 -0
- /package/{lib → dist}/plugins/poiDataManager/src/poiDataManager.js +0 -0
- /package/{lib → dist}/plugins/sdkServer/src/sdkHeadless.js +0 -0
- /package/{lib → dist}/plugins/sdkServer/src/sdkServer.js +0 -0
- /package/{lib → dist}/plugins/sdkServer/src/util.js +0 -0
- /package/{lib → dist}/plugins/searchService/src/poiSearch.js +0 -0
- /package/{lib → dist}/plugins/searchService/src/searchTypeahead.js +0 -0
- /package/{lib → dist}/plugins/searchService/src/utils.js +0 -0
- /package/{lib → dist}/plugins/wayfinder/src/findRoute.js +0 -0
- /package/{lib → dist}/plugins/wayfinder/src/minPriorityQueue.js +0 -0
- /package/{lib → dist}/plugins/wayfinder/src/navGraph.js +0 -0
- /package/{lib → dist}/plugins/wayfinder/src/navGraphDebug.js +0 -0
- /package/{lib → dist}/plugins/wayfinder/src/segmentBadges.js +0 -0
- /package/{lib → dist}/plugins/wayfinder/src/segmentBuilder.js +0 -0
- /package/{lib → dist}/plugins/wayfinder/src/segmentCategories.js +0 -0
- /package/{lib → dist}/plugins/wayfinder/src/stepBuilder.js +0 -0
- /package/{lib → dist}/plugins/wayfinder/src/wayfinder.js +0 -0
- /package/{lib → dist}/src/configs/postproc-mol-url-parms.js +0 -0
- /package/{lib → dist}/src/configs/postproc-stateTracking.js +0 -0
- /package/{lib → dist}/src/configs/sdkHeadless.json.js +0 -0
- /package/{lib → dist}/src/controller.js +0 -0
- /package/{lib → dist}/src/debugTools.js +0 -0
- /package/{lib → dist}/src/env.js +0 -0
- /package/{lib → dist}/src/extModules/bustle.js +0 -0
- /package/{lib → dist}/src/extModules/flexapi/src/help.js +0 -0
- /package/{lib → dist}/src/extModules/flexapi/src/index.js +0 -0
- /package/{lib → dist}/src/extModules/flexapi/src/validate.js +0 -0
- /package/{lib → dist}/src/extModules/geohasher.js +0 -0
- /package/{lib → dist}/src/extModules/log.js +0 -0
- /package/{lib → dist}/src/historyManager.js +0 -0
- /package/{lib → dist}/src/utils/bounds.js +0 -0
- /package/{lib → dist}/src/utils/buildStructureLookup.js +0 -0
- /package/{lib → dist}/src/utils/configUtils.js +0 -0
- /package/{lib → dist}/src/utils/dom.js +0 -0
- /package/{lib → dist}/src/utils/funcs.js +0 -0
- /package/{lib → dist}/src/utils/geodesy.js +0 -0
- /package/{lib → dist}/src/utils/geom.js +0 -0
- /package/{lib → dist}/src/utils/i18n.js +0 -0
- /package/{lib → dist}/src/utils/observable.js +0 -0
- /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
|
|
5
|
+
var R = require('ramda');
|
|
6
6
|
var util = require('./util.js');
|
|
7
7
|
|
|
8
8
|
function _interopNamespace(e) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
26
|
+
var R__namespace = /*#__PURE__*/_interopNamespace(R);
|
|
27
27
|
|
|
28
|
-
const
|
|
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
|
-
|
|
31
|
-
|
|
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
|
|
11
|
+
let removePreviousListener = null;
|
|
12
12
|
|
|
13
|
-
|
|
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
|
|
7
|
+
const getStructures = async app => app.bus.get('venueData/getVenueData').then(vd => vd.structures);
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
3
|
+
var R = require('ramda');
|
|
4
4
|
var utils = require('./utils.js');
|
|
5
5
|
|
|
6
6
|
function _interopNamespace(e) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
24
|
+
var R__namespace = /*#__PURE__*/_interopNamespace(R);
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const DEFAULT_RESULTS_LIMIT = 5000;
|
|
27
27
|
|
|
28
|
-
|
|
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;
|