atriusmaps-node-sdk 3.3.632 → 3.3.633
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/LICENSE.md +1 -2
- package/README.md +15 -16
- package/dist/cjs/deploy/prepareSDKConfig.js +73 -57
- package/dist/cjs/nodesdk/nodeEntry.js +51 -44
- package/dist/cjs/package.json.js +4 -1
- package/dist/cjs/plugins/clientAPI/src/clientAPI.js +6 -4
- package/dist/cjs/plugins/dynamicPois/src/dynamicPois.js +32 -26
- package/dist/cjs/plugins/dynamicPois/src/processors.js +41 -35
- package/dist/cjs/plugins/poiDataManager/src/poiDataManager.js +102 -95
- package/dist/cjs/plugins/sdkServer/src/sdkHeadless.js +52 -26
- package/dist/cjs/plugins/sdkServer/src/sdkServer.js +86 -66
- package/dist/cjs/plugins/searchService/src/flexsearchExports/lang.js +16 -16
- package/dist/cjs/plugins/searchService/src/flexsearchExports/simple.js +31 -8
- package/dist/cjs/plugins/searchService/src/poiSearch.js +14 -17
- package/dist/cjs/plugins/searchService/src/searchService.js +41 -39
- package/dist/cjs/plugins/searchService/src/searchTypeahead.js +14 -19
- package/dist/cjs/plugins/searchService/src/utils.js +4 -5
- package/dist/cjs/plugins/venueDataLoader/src/venueDataLoader.js +145 -127
- package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +37 -39
- package/dist/cjs/plugins/wayfinder/src/findRoute.js +11 -18
- package/dist/cjs/plugins/wayfinder/src/minPriorityQueue.js +18 -19
- package/dist/cjs/plugins/wayfinder/src/navGraph.js +111 -91
- package/dist/cjs/plugins/wayfinder/src/navGraphDebug.js +19 -16
- package/dist/cjs/plugins/wayfinder/src/segmentBadges.js +1 -1
- package/dist/cjs/plugins/wayfinder/src/segmentBuilder.js +79 -76
- package/dist/cjs/plugins/wayfinder/src/segmentCategories.js +1 -1
- package/dist/cjs/plugins/wayfinder/src/stepBuilder.js +147 -107
- package/dist/cjs/plugins/wayfinder/src/wayfinder.js +178 -148
- package/dist/cjs/src/app.js +64 -44
- package/dist/cjs/src/configs/postproc-mol-url-parms.js +22 -21
- package/dist/cjs/src/configs/postproc-stateTracking.js +5 -8
- package/dist/cjs/src/controller.js +11 -6
- package/dist/cjs/src/debugTools.js +61 -34
- package/dist/cjs/src/env.js +7 -4
- package/dist/cjs/src/extModules/bustle.js +35 -45
- package/dist/cjs/src/extModules/flexapi/src/help.js +16 -8
- package/dist/cjs/src/extModules/flexapi/src/index.js +39 -18
- package/dist/cjs/src/extModules/flexapi/src/validate.js +129 -87
- package/dist/cjs/src/extModules/geohasher.js +7 -7
- package/dist/cjs/src/extModules/log.js +20 -22
- package/dist/cjs/src/historyManager.js +2 -2
- package/dist/cjs/src/utils/bounds.js +6 -6
- package/dist/cjs/src/utils/buildStructureLookup.js +3 -3
- package/dist/cjs/src/utils/configUtils.js +14 -18
- package/dist/cjs/src/utils/dom.js +12 -18
- package/dist/cjs/src/utils/funcs.js +12 -15
- package/dist/cjs/src/utils/geodesy.js +7 -9
- package/dist/cjs/src/utils/geom.js +52 -40
- package/dist/cjs/src/utils/i18n.js +47 -36
- package/dist/cjs/src/utils/location.js +12 -13
- package/dist/cjs/src/utils/observable.js +27 -28
- package/dist/cjs/src/utils/rand.js +9 -10
- package/dist/package.json.js +1 -1
- package/package.json +1 -1
|
@@ -14,28 +14,28 @@ let removePreviousListener = null;
|
|
|
14
14
|
// postMessage and converts them to clientAPI/execute calls..
|
|
15
15
|
// responds by sending messages back through postMessage
|
|
16
16
|
// returns a sendEvent function used for sending events through postMessage as well
|
|
17
|
-
function getBrowserCom
|
|
17
|
+
function getBrowserCom(app) {
|
|
18
18
|
const clean = ob => JSON.parse(JSON.stringify(ob));
|
|
19
19
|
const sendResponse = (payload, clientMsgId) => {
|
|
20
20
|
const ob = {
|
|
21
21
|
payload,
|
|
22
|
-
type: 'LL-server'
|
|
22
|
+
type: 'LL-server',
|
|
23
23
|
};
|
|
24
|
-
if (clientMsgId)
|
|
25
|
-
ob.clientMsgId = clientMsgId;
|
|
24
|
+
if (clientMsgId) ob.clientMsgId = clientMsgId;
|
|
26
25
|
try {
|
|
27
26
|
window.postMessage(ob, '*');
|
|
28
|
-
} catch (e) {
|
|
27
|
+
} catch (e) {
|
|
28
|
+
window.postMessage(clean(ob), '*');
|
|
29
|
+
} // failure to send could be due to non-marshalable object - this helps
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
const sendError = (payload, clientMsgId) => {
|
|
32
33
|
const ob = {
|
|
33
34
|
error: true,
|
|
34
35
|
payload,
|
|
35
|
-
type: 'LL-server'
|
|
36
|
+
type: 'LL-server',
|
|
36
37
|
};
|
|
37
|
-
if (clientMsgId)
|
|
38
|
-
ob.clientMsgId = clientMsgId;
|
|
38
|
+
if (clientMsgId) ob.clientMsgId = clientMsgId;
|
|
39
39
|
window.postMessage(ob, '*');
|
|
40
40
|
};
|
|
41
41
|
|
|
@@ -43,44 +43,44 @@ function getBrowserCom (app) {
|
|
|
43
43
|
const ob = {
|
|
44
44
|
event,
|
|
45
45
|
payload,
|
|
46
|
-
type: 'LL-server'
|
|
46
|
+
type: 'LL-server',
|
|
47
47
|
};
|
|
48
48
|
window.postMessage(ob, '*');
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
function msgHandler
|
|
51
|
+
function msgHandler(e) {
|
|
52
52
|
const d = e.data;
|
|
53
|
-
if (d && d.type === 'LL-client') {
|
|
54
|
-
|
|
53
|
+
if (d && d.type === 'LL-client') {
|
|
54
|
+
// confirm message is from our "client"
|
|
55
|
+
app.bus
|
|
56
|
+
.get('clientAPI/execute', d.payload)
|
|
55
57
|
.then(resOb => sendResponse(resOb, d.msgId))
|
|
56
58
|
.catch(er => {
|
|
57
|
-
if (app.config.debug)
|
|
58
|
-
console.error(er);
|
|
59
|
+
if (app.config.debug) console.error(er);
|
|
59
60
|
sendError(er.message, d.msgId);
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
// Listen for HTML5 postMessage events - these come from SDKClient apps
|
|
65
|
-
if (removePreviousListener)
|
|
66
|
-
removePreviousListener();
|
|
66
|
+
if (removePreviousListener) removePreviousListener();
|
|
67
67
|
window.addEventListener('message', msgHandler);
|
|
68
68
|
removePreviousListener = () => window.removeEventListener('message', msgHandler);
|
|
69
69
|
|
|
70
|
-
return sendEvent
|
|
70
|
+
return sendEvent;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// For node, command sending and response sending is handled via
|
|
74
74
|
// nodeEntry - no postMessage required.
|
|
75
75
|
// sendEvent attaches a hook into app to receive them...
|
|
76
|
-
function getNodeCom
|
|
76
|
+
function getNodeCom(app) {
|
|
77
77
|
const eventListener = observable();
|
|
78
78
|
app.eventListener = eventListener;
|
|
79
79
|
const sendEvent = (event, payload) => eventListener.fire(event, payload);
|
|
80
|
-
return sendEvent
|
|
80
|
+
return sendEvent;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
function registerCustomTypes
|
|
83
|
+
function registerCustomTypes(app) {
|
|
84
84
|
app.bus.send('clientAPI/registerCustomType', {
|
|
85
85
|
name: 'latLngOrdLocation',
|
|
86
86
|
spec: {
|
|
@@ -88,9 +88,9 @@ function registerCustomTypes (app) {
|
|
|
88
88
|
props: [
|
|
89
89
|
{ name: 'lat', type: 'float' },
|
|
90
90
|
{ name: 'lng', type: 'float' },
|
|
91
|
-
{ name: 'ord', type: 'integer' }
|
|
92
|
-
]
|
|
93
|
-
}
|
|
91
|
+
{ name: 'ord', type: 'integer' },
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
app.bus.send('clientAPI/registerCustomType', {
|
|
@@ -100,31 +100,25 @@ function registerCustomTypes (app) {
|
|
|
100
100
|
props: [
|
|
101
101
|
{ name: 'lat', type: 'float' },
|
|
102
102
|
{ name: 'lng', type: 'float' },
|
|
103
|
-
{ name: 'floorId', type: 'string' }
|
|
104
|
-
]
|
|
105
|
-
}
|
|
103
|
+
{ name: 'floorId', type: 'string' },
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
app.bus.send('clientAPI/registerCustomType', {
|
|
109
109
|
name: 'poiIdLocation',
|
|
110
110
|
spec: {
|
|
111
111
|
type: 'object',
|
|
112
|
-
props: [
|
|
113
|
-
|
|
114
|
-
]
|
|
115
|
-
}
|
|
112
|
+
props: [{ name: 'poiId', type: 'integer', min: 0 }],
|
|
113
|
+
},
|
|
116
114
|
});
|
|
117
115
|
|
|
118
116
|
app.bus.send('clientAPI/registerCustomType', {
|
|
119
117
|
name: 'location',
|
|
120
118
|
spec: {
|
|
121
119
|
type: 'multi',
|
|
122
|
-
types: [
|
|
123
|
-
|
|
124
|
-
{ type: 'latLngOrdLocation' },
|
|
125
|
-
{ type: 'latLngFloorLocation' }
|
|
126
|
-
]
|
|
127
|
-
}
|
|
120
|
+
types: [{ type: 'poiIdLocation' }, { type: 'latLngOrdLocation' }, { type: 'latLngFloorLocation' }],
|
|
121
|
+
},
|
|
128
122
|
});
|
|
129
123
|
|
|
130
124
|
app.bus.send('clientAPI/registerCustomType', {
|
|
@@ -134,28 +128,55 @@ function registerCustomTypes (app) {
|
|
|
134
128
|
props: [
|
|
135
129
|
{ name: 'zoom', type: 'float', optional: true },
|
|
136
130
|
{ name: 'pitch', type: 'float', optional: true },
|
|
137
|
-
{ name: 'bearing', type: 'float', optional: true }
|
|
138
|
-
]
|
|
139
|
-
}
|
|
131
|
+
{ name: 'bearing', type: 'float', optional: true },
|
|
132
|
+
],
|
|
133
|
+
},
|
|
140
134
|
});
|
|
141
135
|
}
|
|
142
136
|
|
|
143
|
-
function registerEvents
|
|
137
|
+
function registerEvents(app, sendEvent) {
|
|
144
138
|
app.bus.monitor('map/userMoveStart', async ({ pitch, zoom, bearing }) => {
|
|
145
139
|
const { lat, lng, floorId, ordinal, structureId } = await app.bus.get('map/getMapCenter');
|
|
146
|
-
sendEvent('userMoveStart', {
|
|
140
|
+
sendEvent('userMoveStart', {
|
|
141
|
+
lat,
|
|
142
|
+
lng,
|
|
143
|
+
floorId,
|
|
144
|
+
ord: ordinal,
|
|
145
|
+
structureId,
|
|
146
|
+
pitch,
|
|
147
|
+
zoom,
|
|
148
|
+
bearing,
|
|
149
|
+
});
|
|
147
150
|
});
|
|
148
151
|
|
|
149
152
|
const userMoving = async ({ pitch, zoom, bearing }) => {
|
|
150
153
|
const { lat, lng, floorId, ordinal, structureId } = await app.bus.get('map/getMapCenter');
|
|
151
|
-
sendEvent('userMoving', {
|
|
154
|
+
sendEvent('userMoving', {
|
|
155
|
+
lat,
|
|
156
|
+
lng,
|
|
157
|
+
floorId,
|
|
158
|
+
ord: ordinal,
|
|
159
|
+
structureId,
|
|
160
|
+
pitch,
|
|
161
|
+
zoom,
|
|
162
|
+
bearing,
|
|
163
|
+
});
|
|
152
164
|
};
|
|
153
165
|
|
|
154
166
|
app.bus.monitor('map/userMoving', throttleDebounce.throttle(500, userMoving));
|
|
155
167
|
|
|
156
168
|
app.bus.monitor('map/moveEnd', async ({ pitch, zoom, bearing }) => {
|
|
157
169
|
const { lat, lng, floorId, ordinal, structureId } = await app.bus.get('map/getMapCenter');
|
|
158
|
-
sendEvent('moveEnd', {
|
|
170
|
+
sendEvent('moveEnd', {
|
|
171
|
+
lat,
|
|
172
|
+
lng,
|
|
173
|
+
floorId,
|
|
174
|
+
ord: ordinal,
|
|
175
|
+
structureId,
|
|
176
|
+
pitch,
|
|
177
|
+
zoom,
|
|
178
|
+
bearing,
|
|
179
|
+
});
|
|
159
180
|
});
|
|
160
181
|
|
|
161
182
|
app.bus.monitor('map/floorChanged', ({ structure, floor }) =>
|
|
@@ -164,14 +185,13 @@ function registerEvents (app, sendEvent) {
|
|
|
164
185
|
floorName: floor ? floor.name : null,
|
|
165
186
|
ord: floor ? floor.ordinal : null,
|
|
166
187
|
structureId: structure ? structure.id : null,
|
|
167
|
-
structureName: structure ? structure.name : null
|
|
168
|
-
})
|
|
188
|
+
structureName: structure ? structure.name : null,
|
|
189
|
+
}),
|
|
190
|
+
);
|
|
169
191
|
|
|
170
|
-
app.bus.monitor('map/poiClicked', ({ poi }) =>
|
|
171
|
-
sendEvent('poiSelected', poi));
|
|
192
|
+
app.bus.monitor('map/poiClicked', ({ poi }) => sendEvent('poiSelected', poi));
|
|
172
193
|
|
|
173
|
-
app.bus.monitor('poiDetails/showPoi', ({ poi }) =>
|
|
174
|
-
sendEvent('poiShown', poi));
|
|
194
|
+
app.bus.monitor('poiDetails/showPoi', ({ poi }) => sendEvent('poiShown', poi));
|
|
175
195
|
|
|
176
196
|
app.bus.monitor('map/click', async ({ lat, lng, ord }) => {
|
|
177
197
|
const structures = await app.bus.get('venueData/getStructures');
|
|
@@ -181,10 +201,8 @@ function registerEvents (app, sendEvent) {
|
|
|
181
201
|
});
|
|
182
202
|
}
|
|
183
203
|
|
|
184
|
-
async function create
|
|
185
|
-
const sendEvent = app.env.isBrowser
|
|
186
|
-
? getBrowserCom(app)
|
|
187
|
-
: getNodeCom(app);
|
|
204
|
+
async function create(app, config) {
|
|
205
|
+
const sendEvent = app.env.isBrowser ? getBrowserCom(app) : getNodeCom(app);
|
|
188
206
|
|
|
189
207
|
const init = async () => {
|
|
190
208
|
// Register the Custom Types
|
|
@@ -195,28 +213,30 @@ async function create (app, config) {
|
|
|
195
213
|
sdkHeadless.handleHeadless(app);
|
|
196
214
|
|
|
197
215
|
if (!config.headless) {
|
|
198
|
-
await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('../../../_virtual/_empty_module_placeholder.js')); })
|
|
199
|
-
.
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
});
|
|
216
|
+
await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('../../../_virtual/_empty_module_placeholder.js')); }).then(sdkVisual => {
|
|
217
|
+
sdkVisual.visualCommands.forEach(cdef => app.bus.send('clientAPI/registerCommand', cdef));
|
|
218
|
+
sdkVisual.handleVisual(app, sendEvent);
|
|
219
|
+
});
|
|
203
220
|
}
|
|
204
221
|
|
|
205
222
|
const weReady = async () => {
|
|
206
223
|
await app.bus.send('system/readywhenyouare'); // give other modules a chance to hold us up...
|
|
207
|
-
app.bus
|
|
224
|
+
app.bus
|
|
225
|
+
.get('clientAPI/execute', { command: 'getCommandJSON' })
|
|
208
226
|
.then(commandJSON => sendEvent('ready', { commandJSON }));
|
|
209
227
|
if (!config.headless && app.config.uiHide && app.config.uiHide.sidebar && app.env.isDesktop())
|
|
210
|
-
app.bus.send('map/changePadding', {
|
|
228
|
+
app.bus.send('map/changePadding', {
|
|
229
|
+
padding: { left: 55, right: 55, top: 72, bottom: 22 },
|
|
230
|
+
});
|
|
211
231
|
};
|
|
212
232
|
|
|
213
|
-
if (config.headless)
|
|
233
|
+
if (config.headless)
|
|
234
|
+
// in headless case, we are ready once data is ready
|
|
214
235
|
Promise.all([
|
|
215
236
|
new Promise(resolve => app.bus.monitor('venueData/navGraphLoaded', resolve)),
|
|
216
|
-
new Promise(resolve => app.bus.monitor('venueData/poiDataLoaded', resolve))
|
|
237
|
+
new Promise(resolve => app.bus.monitor('venueData/poiDataLoaded', resolve)),
|
|
217
238
|
]).then(weReady);
|
|
218
|
-
else
|
|
219
|
-
app.bus.on('map/mapReadyToShow', weReady);
|
|
239
|
+
else app.bus.on('map/mapReadyToShow', weReady);
|
|
220
240
|
|
|
221
241
|
app.bus.on('sdkServer/sendEvent', ({ eventName, ...props }) => sendEvent(eventName, props));
|
|
222
242
|
};
|
|
@@ -225,8 +245,8 @@ async function create (app, config) {
|
|
|
225
245
|
registerEvents(app, sendEvent);
|
|
226
246
|
|
|
227
247
|
return {
|
|
228
|
-
init
|
|
229
|
-
}
|
|
248
|
+
init,
|
|
249
|
+
};
|
|
230
250
|
}
|
|
231
251
|
|
|
232
252
|
exports.create = create;
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* @this IndexInterface
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
function pipeline
|
|
13
|
+
function pipeline(str, normalize, split, _collapse) {
|
|
14
14
|
if (str) {
|
|
15
15
|
if (normalize) {
|
|
16
|
-
str = replace(str, /** @type {Array<string|RegExp>} */normalize);
|
|
16
|
+
str = replace(str, /** @type {Array<string|RegExp>} */ normalize);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
if (this.matcher) {
|
|
@@ -29,13 +29,13 @@ function pipeline (str, normalize, split, _collapse) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
if (split || split === '') {
|
|
32
|
-
const words = str.split(/** @type {string|RegExp} */split);
|
|
32
|
+
const words = str.split(/** @type {string|RegExp} */ split);
|
|
33
33
|
|
|
34
|
-
return this.filter ? filter(words, this.filter) : words
|
|
34
|
+
return this.filter ? filter(words, this.filter) : words;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
return str
|
|
38
|
+
return str;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// TODO improve normalize + remove non-delimited chars like in "I'm" + split on whitespace+
|
|
@@ -45,12 +45,12 @@ const regex_whitespace = /[\p{Z}\p{S}\p{P}\p{C}]+/u;
|
|
|
45
45
|
// export const regex_whitespace = /[\s\xA0\u2000-\u200B\u2028\u2029\u3000\ufeff!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]/
|
|
46
46
|
const regex_normalize = /[\u0300-\u036f'-]/gu;
|
|
47
47
|
|
|
48
|
-
function normalize
|
|
48
|
+
function normalize(str) {
|
|
49
49
|
if (str.normalize) {
|
|
50
50
|
str = str.normalize('NFD').replace(regex_normalize, '');
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
return str
|
|
53
|
+
return str;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
@@ -146,16 +146,16 @@ function normalize (str) {
|
|
|
146
146
|
* @returns {string}
|
|
147
147
|
*/
|
|
148
148
|
|
|
149
|
-
function replace
|
|
149
|
+
function replace(str, regexp) {
|
|
150
150
|
for (let i = 0, len = regexp.length; i < len; i += 2) {
|
|
151
151
|
str = str.replace(regexp[i], regexp[i + 1]);
|
|
152
152
|
|
|
153
153
|
if (!str) {
|
|
154
|
-
break
|
|
154
|
+
break;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
return str
|
|
158
|
+
return str;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
/**
|
|
@@ -163,8 +163,8 @@ function replace (str, regexp) {
|
|
|
163
163
|
* @returns {RegExp}
|
|
164
164
|
*/
|
|
165
165
|
|
|
166
|
-
function regex
|
|
167
|
-
return new RegExp(str, 'g')
|
|
166
|
+
function regex(str) {
|
|
167
|
+
return new RegExp(str, 'g');
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
/**
|
|
@@ -173,7 +173,7 @@ function regex (str) {
|
|
|
173
173
|
* @returns {string}
|
|
174
174
|
*/
|
|
175
175
|
|
|
176
|
-
function collapse
|
|
176
|
+
function collapse(string) {
|
|
177
177
|
let final = '';
|
|
178
178
|
let prev = '';
|
|
179
179
|
|
|
@@ -183,11 +183,11 @@ function collapse (string) {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
return final
|
|
186
|
+
return final;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
// TODO using fast-swap
|
|
190
|
-
function filter
|
|
190
|
+
function filter(words, map) {
|
|
191
191
|
const length = words.length;
|
|
192
192
|
const filtered = [];
|
|
193
193
|
|
|
@@ -199,7 +199,7 @@ function filter (words, map) {
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
return filtered
|
|
202
|
+
return filtered;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
// const chars = {a:1, e:1, i:1, o:1, u:1, y:1};
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var lang = require('./lang.js');
|
|
4
4
|
|
|
5
5
|
/* eslint-disable camelcase */
|
|
6
|
-
|
|
7
|
-
// regex_strip = regex("[^a-z0-9 ]"),
|
|
6
|
+
const // regex_whitespace = /\W+/,
|
|
7
|
+
// regex_strip = regex("[^a-z0-9 ]"),
|
|
8
8
|
regex_a = lang.regex('[àáâãäå]');
|
|
9
9
|
const regex_e = lang.regex('[èéêë]');
|
|
10
10
|
const regex_i = lang.regex('[ìíîï]');
|
|
@@ -15,7 +15,27 @@ const regex_n = lang.regex('ñ');
|
|
|
15
15
|
const regex_c = lang.regex('[çc]');
|
|
16
16
|
const regex_s = lang.regex('ß');
|
|
17
17
|
const regex_and = lang.regex(' & ');
|
|
18
|
-
const pairs = [
|
|
18
|
+
const pairs = [
|
|
19
|
+
regex_a,
|
|
20
|
+
'a',
|
|
21
|
+
regex_e,
|
|
22
|
+
'e',
|
|
23
|
+
regex_i,
|
|
24
|
+
'i',
|
|
25
|
+
regex_o,
|
|
26
|
+
'o',
|
|
27
|
+
regex_u,
|
|
28
|
+
'u',
|
|
29
|
+
regex_y,
|
|
30
|
+
'y',
|
|
31
|
+
regex_n,
|
|
32
|
+
'n',
|
|
33
|
+
regex_c,
|
|
34
|
+
'k',
|
|
35
|
+
regex_s,
|
|
36
|
+
's',
|
|
37
|
+
regex_and,
|
|
38
|
+
' and ',
|
|
19
39
|
// regex_whitespace, " "
|
|
20
40
|
// regex_strip, ""
|
|
21
41
|
];
|
|
@@ -25,13 +45,16 @@ const pairs = [regex_a, 'a', regex_e, 'e', regex_i, 'i', regex_o, 'o', regex_u,
|
|
|
25
45
|
* @this IndexInterface
|
|
26
46
|
*/
|
|
27
47
|
|
|
28
|
-
function encode
|
|
48
|
+
function encode(str) {
|
|
29
49
|
str = '' + str;
|
|
30
50
|
|
|
31
|
-
return lang.pipeline.call(
|
|
32
|
-
|
|
33
|
-
/*
|
|
34
|
-
/*
|
|
51
|
+
return lang.pipeline.call(
|
|
52
|
+
this,
|
|
53
|
+
/* string: */ lang.normalize(str).toLowerCase(),
|
|
54
|
+
/* normalize: */ !str.normalize && pairs,
|
|
55
|
+
/* split: */ lang.regex_whitespace,
|
|
56
|
+
false,
|
|
57
|
+
);
|
|
35
58
|
}
|
|
36
59
|
|
|
37
60
|
exports.encode = encode;
|
|
@@ -24,42 +24,39 @@ var R__namespace = /*#__PURE__*/_interopNamespaceDefault(R);
|
|
|
24
24
|
|
|
25
25
|
const DEFAULT_RESULTS_LIMIT = 5000;
|
|
26
26
|
|
|
27
|
-
function createPOISearch
|
|
27
|
+
function createPOISearch(pois, lang) {
|
|
28
28
|
const index = utils.getFlexSearchInstance({ lang });
|
|
29
29
|
|
|
30
30
|
// index.addMatcher({
|
|
31
31
|
// '[\'.,]': ''
|
|
32
32
|
// })
|
|
33
33
|
|
|
34
|
-
prepareIndexEntries(pois)
|
|
35
|
-
.forEach(([id, content]) => index.add(id, content));
|
|
34
|
+
prepareIndexEntries(pois).forEach(([id, content]) => index.add(id, content));
|
|
36
35
|
|
|
37
|
-
function prepareIndexEntries
|
|
38
|
-
return Object.values(pois).map(
|
|
36
|
+
function prepareIndexEntries(pois) {
|
|
37
|
+
return Object.values(pois).map(poi => {
|
|
39
38
|
const { poiId, category = '', name, keywords = [], roomId = '' } = poi;
|
|
40
39
|
const grabTags = R__namespace.path(['dynamicData', 'grab', 'tags'], poi) || [];
|
|
41
|
-
const searchKeywords = keywords
|
|
42
|
-
.filter(R__namespace.prop('isUserSearchable'))
|
|
43
|
-
.map(R__namespace.prop('name'));
|
|
40
|
+
const searchKeywords = keywords.filter(R__namespace.prop('isUserSearchable')).map(R__namespace.prop('name'));
|
|
44
41
|
const content = `${name} ${category.split('.').join(' ')} ${roomId} ${searchKeywords.join(' ')} ${grabTags.join(' ')}`;
|
|
45
|
-
return [Number(poiId), content]
|
|
46
|
-
})
|
|
42
|
+
return [Number(poiId), content];
|
|
43
|
+
});
|
|
47
44
|
}
|
|
48
45
|
|
|
49
|
-
function search
|
|
46
|
+
function search(queryParams) {
|
|
50
47
|
const options = { ...queryParams };
|
|
51
|
-
if (!options.limit)
|
|
48
|
+
if (!options.limit)
|
|
49
|
+
// sometimes limit is NaN or undefined!
|
|
52
50
|
options.limit = DEFAULT_RESULTS_LIMIT;
|
|
53
51
|
const ids = index.search(options);
|
|
54
|
-
return Object.values(R__namespace.pick(ids, pois))
|
|
52
|
+
return Object.values(R__namespace.pick(ids, pois));
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
function updateMultiple
|
|
58
|
-
prepareIndexEntries(pois)
|
|
59
|
-
.forEach(([id, content]) => index.update(id, content));
|
|
55
|
+
function updateMultiple(pois) {
|
|
56
|
+
prepareIndexEntries(pois).forEach(([id, content]) => index.update(id, content));
|
|
60
57
|
}
|
|
61
58
|
|
|
62
|
-
return { search, updateMultiple }
|
|
59
|
+
return { search, updateMultiple };
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
module.exports = createPOISearch;
|