atriusmaps-node-sdk 3.3.407 → 3.3.409
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/package.json.js +1 -1
- package/dist/cjs/plugins/searchService/src/searchService.js +1 -9
- package/dist/cjs/src/utils/rand.js +98 -59
- package/dist/package.json.js +1 -1
- package/dist/plugins/searchService/src/searchService.js +1 -1
- package/dist/src/utils/rand.js +1 -1
- package/package.json +1 -1
package/dist/cjs/package.json.js
CHANGED
|
@@ -147,18 +147,10 @@ function create (app, config) {
|
|
|
147
147
|
async function getUniqueRandomCategories (limit) {
|
|
148
148
|
const allCategories = (await app.bus.send('poi/getAllCategories'))[0];
|
|
149
149
|
const uniqueCategories = Array.from(new Set(allCategories));
|
|
150
|
-
const shuffledUniqueCategories =
|
|
150
|
+
const shuffledUniqueCategories = rand.randomizeArray(uniqueCategories);
|
|
151
151
|
return shuffledUniqueCategories.slice(0, limit)
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
function shuffle (a) {
|
|
155
|
-
for (let i = a.length - 1; i > 0; i--) {
|
|
156
|
-
const j = Math.floor(Math.random() * (i + 1));
|
|
157
|
-
[a[i], a[j]] = [a[j], a[i]];
|
|
158
|
-
}
|
|
159
|
-
return a
|
|
160
|
-
}
|
|
161
|
-
|
|
162
154
|
/**
|
|
163
155
|
* Returns list of up to 'limit' unique random navigable POIs.
|
|
164
156
|
*
|
|
@@ -1,85 +1,124 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
// Simple seedable random number generator - NOT cryptographicaly secure!
|
|
4
|
+
function mulberry32 (seed) {
|
|
5
|
+
return function () {
|
|
6
|
+
let t = seed += 0x6D2B79F5;
|
|
7
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
8
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
9
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296
|
|
10
|
+
}
|
|
11
|
+
}
|
|
6
12
|
|
|
7
|
-
|
|
13
|
+
// ONLY use this for making tests deterministic - otherwise its a bad practice
|
|
14
|
+
const isCypress = typeof window !== 'undefined' && window.Cypress;
|
|
15
|
+
const random = isCypress ? mulberry32(12345678) : Math.random;
|
|
8
16
|
|
|
9
17
|
/**
|
|
10
|
-
* Returns a random
|
|
11
|
-
*
|
|
18
|
+
* Returns a random integer between the min and max values. Can also
|
|
19
|
+
* be called with a single value which becomes the max and min is set to 0.
|
|
20
|
+
* @param {integer} min minimum integer value to return (inclusive)
|
|
21
|
+
* @param {integer} max maximum integer value to return (exclusive)
|
|
22
|
+
* @returns random integer between min and max.
|
|
23
|
+
*/
|
|
24
|
+
const rand = (min, max) => {
|
|
25
|
+
if (max == null) {
|
|
26
|
+
max = min;
|
|
27
|
+
min = 0;
|
|
28
|
+
}
|
|
29
|
+
return Math.floor(random() * (max - min) + min)
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns a random list of length `size` with unique integers from 0 to `max` - 1.
|
|
12
34
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
35
|
+
* No number will repeat. If `size > max`, it is clamped to `max`.
|
|
36
|
+
* If `max` is not provided, it defaults to `size`, resulting in a random shuffle of [0..size-1].
|
|
15
37
|
*
|
|
16
|
-
*
|
|
38
|
+
* This is useful for randomly selecting a subset of indices or shuffling a range.
|
|
17
39
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* randomSet(3, 5) = [1, 4, 2]
|
|
40
|
+
* For example:
|
|
41
|
+
* randomSet(3, 5) → [3, 2, 0]
|
|
42
|
+
* randomSet(5) → [1, 4, 0, 3, 2] // full shuffle of 0..4
|
|
22
43
|
*
|
|
23
|
-
* @param size
|
|
24
|
-
* @param max
|
|
25
|
-
* @
|
|
26
|
-
* @return a List of random values from 0 to max-1 with no number repeating
|
|
44
|
+
* @param {number} size - Number of unique values to return
|
|
45
|
+
* @param {number} [max] - Range upper bound (exclusive); defaults to `size`
|
|
46
|
+
* @returns {number[]} An array of unique random integers from 0 to max-1
|
|
27
47
|
*/
|
|
28
|
-
function randomSet (size, max
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
let i;
|
|
32
|
-
|
|
33
|
-
if (!max)
|
|
34
|
-
max = size;
|
|
48
|
+
function randomSet (size, max) {
|
|
49
|
+
if (!max) max = size;
|
|
50
|
+
if (size > max) size = max;
|
|
35
51
|
|
|
36
|
-
|
|
37
|
-
size = max;
|
|
52
|
+
const result = [];
|
|
38
53
|
|
|
39
|
-
|
|
54
|
+
// Threshold for choosing sparse vs dense algorithm
|
|
55
|
+
// If we're selecting less than 30% of the range, collisions are rare
|
|
56
|
+
const SPARSITY_THRESHOLD = 0.3;
|
|
57
|
+
const isSparse = (size / max) < SPARSITY_THRESHOLD;
|
|
40
58
|
|
|
41
|
-
if (
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
59
|
+
if (isSparse) {
|
|
60
|
+
// Sparse strategy: randomly generate values and skip duplicates
|
|
61
|
+
// Fast when the number of needed values is small relative to the range
|
|
62
|
+
const seen = new Set();
|
|
63
|
+
while (result.length < size) {
|
|
64
|
+
const i = rand(max);
|
|
65
|
+
if (!seen.has(i)) {
|
|
66
|
+
seen.add(i);
|
|
67
|
+
result.push(i);
|
|
68
|
+
}
|
|
48
69
|
}
|
|
49
70
|
} else {
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
const source =
|
|
53
|
-
|
|
54
|
-
|
|
71
|
+
// Dense strategy: partial in-place Fisher-Yates shuffle
|
|
72
|
+
// More efficient when selecting a large portion of the range
|
|
73
|
+
const source = Array.from({ length: max }, (_, i) => i);
|
|
74
|
+
|
|
75
|
+
for (let i = 0; i < size; i++) {
|
|
76
|
+
// Select a random index in the shrinking source array
|
|
77
|
+
const index = rand(max - i);
|
|
78
|
+
|
|
79
|
+
// Add the selected value to the result
|
|
80
|
+
result.push(source[index]);
|
|
55
81
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
list.push(source[index]);
|
|
59
|
-
source.splice(index, 1);
|
|
82
|
+
// Move the last unchosen item into the chosen spot to "remove" it
|
|
83
|
+
source[index] = source[max - i - 1];
|
|
60
84
|
}
|
|
61
85
|
}
|
|
62
86
|
|
|
63
|
-
return
|
|
87
|
+
return result
|
|
64
88
|
}
|
|
65
89
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Given a source array and an array of indices, return a new array
|
|
92
|
+
* containing the source elements at the specified indices.
|
|
93
|
+
*
|
|
94
|
+
* @param {Array} array - The source array
|
|
95
|
+
* @param {number[]} map - Array of indices to pull from the source
|
|
96
|
+
* @returns {Array} - Mapped array
|
|
97
|
+
*/
|
|
73
98
|
const getMappedArray = (array, map) => map.map(i => array[i]);
|
|
74
99
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Returns a new array containing the elements of the input array in random order.
|
|
102
|
+
* Original array is not modified.
|
|
103
|
+
*
|
|
104
|
+
* @param {Array} array - The array to shuffle
|
|
105
|
+
* @returns {Array} - A new randomized array
|
|
106
|
+
*/
|
|
107
|
+
const randomizeArray = array => getMappedArray(array, randomSet(array.length));
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Returns a random selection of `num` elements from the array, in random order.
|
|
111
|
+
* Original array is not modified. If `num` is not specified, returns a single random item.
|
|
112
|
+
* If `num > array.length`, it is clamped to the array length.
|
|
113
|
+
*
|
|
114
|
+
* @param {Array} array - The array to sample from
|
|
115
|
+
* @param {number} [num=1] - Number of items to pick
|
|
116
|
+
* @returns {Array} - Randomly selected items
|
|
117
|
+
*/
|
|
118
|
+
const arrayPick = (array, num = 1) =>
|
|
119
|
+
getMappedArray(array, randomSet(num, array.length));
|
|
83
120
|
|
|
84
121
|
exports.arrayPick = arrayPick;
|
|
122
|
+
exports.rand = rand;
|
|
85
123
|
exports.randomSet = randomSet;
|
|
124
|
+
exports.randomizeArray = randomizeArray;
|
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e="web-engine",s="3.3.
|
|
1
|
+
var e="web-engine",s="3.3.409",o="UNLICENSED",t="module",l="src/main.js",r=["demo","deploy","nodesdk","src/extModules/flexapi","services/*","libraries/*"],a={colors:"cat utils/colors1.txt && node utils/processColors.js | pbcopy && cat utils/colors2.txt","cypress:a11y":"APPLITOOLS_IS_DISABLED=true && cypress open --browser chrome --env INPUT_MODALITY='keyboard'","cypress:comp":"APPLITOOLS_IS_DISABLED=true && cypress open --component --browser chrome","cypress:e2e":"APPLITOOLS_IS_DISABLED=true && cypress open --e2e --browser chrome",demo:"cd demo/ && yarn start","e2e:comp":"cypress run --component","e2e:record":"yarn cypress run --env RECORD_MODE=true",e2eSDKTest:"yarn start-server-and-test 'cd ./deploy && yarn buildDev && yarn serveLocal' 8085 'cd ./cypress/e2e/sdk && npx http-server' 8080 'yarn cypress run --spec cypress/e2e/sdk/**'",goProd:"cd deploy && scripts/goProd.sh",goStaging:"deploy/scripts/goStaging.sh",i18nOverrides:"yarn node utils/i18nOverrideCli src/i18n src/i18n-overrides",lint:"eslint .",mod:"demo/startMod.sh",mol:"demo/startMol.sh","mol:build":"demo/startMolBuild.sh",molProd:"cd deploy && yarn buildAndRunMol",prepare:"husky",test:"jest --no-cache --verbose","test-watch":"jest --verbose --watch","test:vitest":"vitest run"},i=["defaults"],n={react:"^18.3.1"},c={"@azure/event-hubs":"^5.12.2","@dnd-kit/core":"^6.3.1","@dnd-kit/modifiers":"^9.0.0","@dnd-kit/sortable":"^10.0.0","@dnd-kit/utilities":"^3.2.2","@locus-labs/mod-badge":"^0.1.102","@locus-labs/mod-default-theme":"^0.0.113","@locus-labs/mod-footer":"^0.0.111","@locus-labs/mod-header":"^0.0.105","@locus-labs/mod-location-marker":"^0.0.104","@locus-labs/mod-map-legend":"^0.0.104","@locus-labs/mod-offscreen-indicator":"^0.0.104","@locus-labs/mod-pin":"^0.0.104","@locus-labs/mod-qr-code-card":"^0.0.104","@locus-labs/mod-qr-code-window":"^0.0.105","@locus-labs/mod-walk-time-matrix":"^0.0.103","@locus-labs/mol-desktop-building-level-selector":"^0.1.119","@locus-labs/mol-desktop-compass":"^0.1.120","@locus-labs/mol-desktop-default-theme":"^0.2.105","@locus-labs/mol-desktop-icon":"^0.1.131","@locus-labs/mol-desktop-logo":"^0.1.101","@locus-labs/mol-desktop-map-nav-button":"^0.1.130","@locus-labs/mol-desktop-tooltip":"^0.3.102","@locus-labs/mol-desktop-zoom-control":"^0.1.141","@locus-labs/mol-mobile-box":"^0.1.115","@locus-labs/mol-mobile-floating-action-button":"^0.0.117","@locus-labs/mol-mobile-icon":"^0.1.118","@locus-labs/mol-mobile-text":"^0.1.116","@locus-labs/mol-mobile-toast":"^0.1.102","@mapbox/mapbox-gl-draw":"^1.5.0","@mapbox/mapbox-gl-draw-static-mode":"^1.0.1","@microsoft/applicationinsights-web":"^3.3.6","@turf/area":"^7.2.0","@turf/bbox-clip":"^7.2.0","@turf/bbox-polygon":"^7.2.0","@turf/circle":"^7.2.0","@turf/helpers":"^7.2.0","@turf/point-to-line-distance":"^7.2.0","@vitejs/plugin-react":"^4.3.4","axe-core":"^4.10.3",browserslist:"^4.24.4","crypto-browserify":"^3.12.1","cypress-axe":"^1.6.0","cypress-multi-reporters":"^2.0.5","cypress-real-events":"^1.14.0","file-loader":"^6.2.0",flexsearch:"^0.7.43","h3-js":"^4.1.0",i18next:"^20.6.1","i18next-browser-languagedetector":"^6.1.1","jest-transform-css":"6.0.2",jsdom:"^25.0.1",jsonschema:"^1.5.0",luxon:"^3.5.0","maplibre-gl":"^4.7.1","mini-css-extract-plugin":"^2.9.2","mocha-junit-reporter":"^2.2.1",mochawesome:"^7.1.3","node-polyfill-webpack-plugin":"^1.1.4","path-browserify":"^1.0.1",polished:"^4.3.1","prop-types":"^15.8.1","query-string":"^9.1.1",ramda:"^0.30.1",react:"^18.3.1","react-compound-slider":"^3.4.0","react-dom":"^18.3.1","react-json-editor-ajrm":"^2.5.14","react-qr-svg":"^2.4.0","react-svg":"^16.3.0","react-virtualized-auto-sizer":"^1.0.25","react-window":"^1.8.11","smoothscroll-polyfill":"^0.4.4","styled-components":"^6.1.15","styled-normalize":"^8.1.1","throttle-debounce":"^5.0.2",trackjs:"^3.10.4","ua-parser-js":"^0.7.40",uuid:"11.1.0",zousan:"^3.0.1","zousan-plus":"^4.0.1"},p={"@applitools/eyes-cypress":"^3.50.3","@babel/core":"^7.26.10","@babel/eslint-parser":"^7.26.10","@babel/plugin-proposal-class-properties":"^7.18.6","@babel/plugin-syntax-dynamic-import":"^7.8.3","@babel/plugin-syntax-import-assertions":"^7.26.0","@babel/plugin-transform-modules-commonjs":"^7.26.3","@babel/plugin-transform-runtime":"^7.26.10","@babel/preset-env":"^7.26.9","@babel/preset-react":"^7.26.3","@testing-library/jest-dom":"^6.6.3","@types/react":"^19.0.10","@types/react-dom":"^19.0.4","@typescript-eslint/eslint-plugin":"^8.26.1","@typescript-eslint/parser":"^8.26.1","babel-jest":"^29.7.0","babel-loader":"^10.0.0","babel-plugin-inline-json-import":"^0.3.2","babel-plugin-module-resolver":"^5.0.2","babel-plugin-styled-components":"^2.1.4","babel-polyfill":"^6.26.0","chai-colors":"^1.0.1","css-loader":"^7.1.2",cypress:"^14.2.0","cypress-browser-permissions":"^1.1.0","cypress-wait-until":"^3.0.2",eslint:"^8.57.1","eslint-config-standard":"^17.1.0","eslint-import-resolver-typescript":"^3.9.1","eslint-plugin-cypress":"^2.15.2","eslint-plugin-import":"^2.31.0","eslint-plugin-jest":"^28.11.0","eslint-plugin-n":"^17.16.2","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^5.2.0","eslint-plugin-react":"^7.37.4","eslint-plugin-standard":"^5.0.0","fetch-mock-jest":"^1.5.1",glob:"^11.0.1",husky:"^9.1.7",jest:"29.7.0","jest-environment-jsdom":"^29.7.0","lint-staged":"^15.5.0","node-fetch":"^2.7.0","null-loader":"^4.0.1",nx:"19.8.14","nx-remotecache-azure":"^19.0.0","start-server-and-test":"^2.0.11",typescript:"^5.8.2",vite:"^4.3.9",vitest:"^2.1.9",webpack:"^5.98.0","webpack-merge":"^6.0.1"},d="yarn@4.7.0",m={node:"20.x"},u={},b={name:e,version:s,private:!0,license:o,type:t,main:l,workspaces:r,scripts:a,"lint-staged":{"*.js":["eslint --fix"]},browserslist:i,resolutions:n,dependencies:c,devDependencies:p,packageManager:d,engines:m,nx:u};export{i as browserslist,b as default,c as dependencies,p as devDependencies,m as engines,o as license,l as main,e as name,u as nx,d as packageManager,n as resolutions,a as scripts,t as type,s as version,r as workspaces};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"ramda";import r from"zousan";import{getLocalized as a}from"../../../src/utils/configUtils.js";import{arrayPick as
|
|
1
|
+
import*as e from"ramda";import r from"zousan";import{getLocalized as a}from"../../../src/utils/configUtils.js";import{randomizeArray as s,arrayPick as t}from"../../../src/utils/rand.js";import n from"./poiSearch.js";import o from"./searchTypeahead.js";function i(i,c){const u={poiSearch:null,typeahead:null,indexesCreated:new r,defaultSearchTerms:null,specialQueryTerms:{}},d=async()=>{const e=await i.bus.get("poi/getAll");u.poiSearch=n(e,i.i18n().language),u.typeahead=o(e,u.poiSearch.search,i.i18n().language),u.defaultSearchTerms=a(c,"defaultSearchTerms",i.i18n().language),u.indexesCreated.resolve()};async function y(){const r=await i.bus.getFirst("user/getPhysicalLocation");if(!r?.floorId)return[];const a=await i.bus.get("poi/getByFloorId",{floorId:r?.floorId}),s=Object.values(e.pickBy((e=>-1===e.category.indexOf("portal")&&"element.door"!==e.category),a)),t=await i.bus.get("wayfinder/addPathTimeMultiple",{pois:s,startLocation:r});return e.sortBy(e.prop("distance"),Object.values(t)).slice(0,50)}i.bus.on("search/queryNearby",(async()=>{const e=await y();return i.bus.send("search/showNearby",{pois:e,term:"Nearby"}),e})),i.bus.on("search/queryNearbyAsync",y),i.bus.on("search/queryCategory",(async({category:e,categoryName:r,searchTerm:a})=>{const s=await u.indexesCreated.then((()=>u.poiSearch.search({query:a||e})));return i.bus.send("search/showCategory",{pois:s,category:e,categoryName:r}),s})),i.bus.on("search/query",(({term:e})=>u.indexesCreated.then((()=>{const r=u.poiSearch.search({query:e});return i.bus.send("search/showSearchResults",{results:r,term:e}),r})))),i.bus.on("search/queryAsync",(({term:e})=>u.indexesCreated.then((()=>u.poiSearch.search({query:e}))))),i.bus.on("search/queryWithSpecial",(({term:e})=>{if(u.specialQueryTerms[e]){const{event:r,params:a}=u.specialQueryTerms[e];return i.bus.send(r,a)}return i.bus.get("search/query",{term:e})})),i.bus.on("search/getDefaultSearchTerms",(async({limit:e=5}={})=>{const r=u.defaultSearchTerms,a=r&&r.length?r:await async function(e){const r=(await i.bus.send("poi/getAllCategories"))[0],a=Array.from(new Set(r));return s(a).slice(0,e)}(e);return i.bus.send("search/showDefaultSearchKeywords",{keywords:a}),a})),i.bus.on("search/getDefaultSearchPois",(async({limit:r=5}={})=>{const a=await i.bus.get("poi/getAll"),s=e.pickBy(((e,r)=>e.isNavigable),a);return t(Object.values(s),r)})),i.bus.on("search/registerSpecialQuery",(({term:e,event:r,params:a,addKeyword:s=!0})=>{u.indexesCreated.then((()=>{s&&u.typeahead.addKeyword(e),u.specialQueryTerms[e]={event:r,params:a}}))})),i.bus.on("search/addKeywords",(({keywords:e})=>u.indexesCreated.then((()=>e.forEach((e=>u.typeahead.addKeyword(e))))))),i.bus.on("search/typeahead",(({term:e,limit:r})=>u.indexesCreated.then((()=>{const{keywords:a,pois:s}=u.typeahead.query(e,r);return{keywords:a,pois:s,term:e}})))),i.bus.on("venueData/loadNewVenue",(()=>{u.indexesCreated=new r,d()})),i.bus.on("poi/setDynamicData",(async({plugin:e,idValuesMap:r})=>{if("grab"!==e)return;const a=Object.keys(r).map((e=>i.bus.get("poi/getById",{id:e})));return Promise.all(a).then((e=>u.indexesCreated.then((()=>u.poiSearch.updateMultiple(e)))))}));return{init:d,runTest:async(e,r)=>(await r(),u)}}export{i as create};
|
package/dist/src/utils/rand.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const t={
|
|
1
|
+
const n="undefined"!=typeof window&&window.Cypress?(t=12345678,function(){let n=t+=1831565813;return n=Math.imul(n^n>>>15,1|n),n^=n+Math.imul(n^n>>>7,61|n),((n^n>>>14)>>>0)/4294967296}):Math.random;var t;const o=(t,o)=>(null==o&&(o=t,t=0),Math.floor(n()*(o-t)+t));function e(n,t){t||(t=n),n>t&&(n=t);const e=[];if(n/t<.3){const r=new Set;for(;e.length<n;){const n=o(t);r.has(n)||(r.add(n),e.push(n))}}else{const r=Array.from({length:t},((n,t)=>t));for(let s=0;s<n;s++){const n=o(t-s);e.push(r[n]),r[n]=r[t-s-1]}}return e}const r=(n,t)=>t.map((t=>n[t])),s=n=>r(n,e(n.length)),l=(n,t=1)=>r(n,e(t,n.length));export{l as arrayPick,o as rand,e as randomSet,s as randomizeArray};
|
package/package.json
CHANGED