atriusmaps-node-sdk 1.0.0 → 3.2.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -0
- package/config/rollup.config.cjs.js +31 -0
- package/dist/cjs/_virtual/_empty_module_placeholder.js +5 -0
- package/dist/cjs/deploy/nodeEntry.js +15 -0
- package/dist/cjs/deploy/prepareSDKConfig.js +9 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/package.json.js +11 -0
- package/dist/cjs/plugins/clientAPI/src/clientAPI.js +9 -0
- package/dist/cjs/plugins/dynamicPois/src/dynamicPois.js +33 -0
- package/dist/cjs/plugins/poiDataManager/src/poiDataManager.js +36 -0
- package/dist/cjs/plugins/sdkServer/src/sdkHeadless.js +31 -0
- package/dist/cjs/plugins/sdkServer/src/sdkServer.js +13 -0
- package/dist/cjs/plugins/sdkServer/src/util.js +10 -0
- package/dist/cjs/plugins/searchService/src/poiSearch.js +28 -0
- package/dist/cjs/plugins/searchService/src/searchService.js +37 -0
- package/dist/cjs/plugins/searchService/src/searchTypeahead.js +8 -0
- package/dist/cjs/plugins/searchService/src/utils.js +13 -0
- package/dist/cjs/plugins/venueDataLoader/src/venueDataLoader.js +36 -0
- package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +34 -0
- package/dist/cjs/plugins/wayfinder/src/findRoute.js +30 -0
- package/dist/cjs/plugins/wayfinder/src/minPriorityQueue.js +5 -0
- package/dist/cjs/plugins/wayfinder/src/navGraph.js +13 -0
- package/dist/cjs/plugins/wayfinder/src/navGraphDebug.js +30 -0
- package/dist/cjs/plugins/wayfinder/src/segmentBadges.js +5 -0
- package/dist/cjs/plugins/wayfinder/src/segmentBuilder.js +32 -0
- package/dist/cjs/plugins/wayfinder/src/segmentCategories.js +5 -0
- package/dist/cjs/plugins/wayfinder/src/stepBuilder.js +10 -0
- package/dist/cjs/plugins/wayfinder/src/wayfinder.js +40 -0
- package/dist/cjs/src/app.js +44 -0
- package/dist/cjs/src/auth/Auth.js +23 -0
- package/dist/cjs/src/configs/postproc-mol-url-parms.js +9 -0
- package/dist/cjs/src/configs/postproc-stateTracking.js +31 -0
- package/dist/cjs/src/configs/sdkHeadless.json.js +47 -0
- package/dist/cjs/src/controller.js +14 -0
- package/dist/cjs/src/debugTools.js +30 -0
- package/dist/cjs/src/env.js +7 -0
- package/dist/cjs/src/extModules/bustle.js +13 -0
- package/dist/cjs/src/extModules/flexapi/src/help.js +9 -0
- package/dist/cjs/src/extModules/flexapi/src/index.js +13 -0
- package/dist/cjs/src/extModules/flexapi/src/validate.js +10 -0
- package/dist/cjs/src/extModules/geohasher.js +8 -0
- package/dist/cjs/src/extModules/log.js +7 -0
- package/dist/cjs/src/historyManager.js +7 -0
- package/dist/cjs/src/utils/bounds.js +10 -0
- package/dist/cjs/src/utils/buildStructureLookup.js +29 -0
- package/dist/cjs/src/utils/configUtils.js +8 -0
- package/dist/cjs/src/utils/dom.js +10 -0
- package/dist/cjs/src/utils/funcs.js +15 -0
- package/dist/cjs/src/utils/geodesy.js +8 -0
- package/dist/cjs/src/utils/geom.js +35 -0
- package/dist/cjs/src/utils/i18n.js +14 -0
- package/dist/cjs/src/utils/observable.js +5 -0
- package/dist/cjs/src/utils/rand.js +8 -0
- package/lib/_virtual/_empty_module_placeholder.js +1 -0
- package/lib/deploy/nodeEntry.js +1 -58
- package/lib/deploy/prepareSDKConfig.js +1 -112
- package/lib/package.json.js +1 -143
- package/lib/plugins/clientAPI/src/clientAPI.js +1 -14
- package/lib/plugins/dynamicPois/src/dynamicPois.js +1 -131
- package/lib/plugins/poiDataManager/src/poiDataManager.js +1 -207
- package/lib/plugins/sdkServer/src/sdkHeadless.js +1 -53
- package/lib/plugins/sdkServer/src/sdkServer.js +1 -211
- package/lib/plugins/sdkServer/src/util.js +1 -18
- package/lib/plugins/searchService/src/poiSearch.js +1 -39
- package/lib/plugins/searchService/src/searchService.js +1 -234
- package/lib/plugins/searchService/src/searchTypeahead.js +1 -63
- package/lib/plugins/searchService/src/utils.js +1 -30
- package/lib/plugins/venueDataLoader/src/venueDataLoader.js +1 -465
- package/lib/plugins/venueDataLoader/src/venueLoadingUtils.js +1 -84
- package/lib/plugins/wayfinder/src/findRoute.js +1 -134
- package/lib/plugins/wayfinder/src/minPriorityQueue.js +1 -89
- package/lib/plugins/wayfinder/src/navGraph.js +1 -370
- package/lib/plugins/wayfinder/src/navGraphDebug.js +1 -95
- package/lib/plugins/wayfinder/src/segmentBadges.js +1 -29
- package/lib/plugins/wayfinder/src/segmentBuilder.js +1 -241
- package/lib/plugins/wayfinder/src/segmentCategories.js +1 -30
- package/lib/plugins/wayfinder/src/stepBuilder.js +1 -236
- package/lib/plugins/wayfinder/src/wayfinder.js +1 -452
- package/lib/src/app.js +1 -150
- package/lib/src/auth/Auth.js +1 -35
- package/lib/src/configs/postproc-mol-url-parms.js +1 -58
- package/lib/src/configs/postproc-stateTracking.js +1 -40
- package/lib/src/configs/sdkHeadless.json.js +1 -42
- package/lib/src/controller.js +1 -45
- package/lib/src/debugTools.js +1 -108
- package/lib/src/env.js +1 -17
- package/lib/src/extModules/bustle.js +1 -126
- package/lib/src/extModules/flexapi/src/help.js +1 -21
- package/lib/src/extModules/flexapi/src/index.js +1 -66
- package/lib/src/extModules/flexapi/src/validate.js +1 -131
- package/lib/src/extModules/geohasher.js +1 -90
- package/lib/src/extModules/log.js +1 -70
- package/lib/src/historyManager.js +1 -30
- package/lib/src/utils/bounds.js +1 -23
- package/lib/src/utils/buildStructureLookup.js +1 -17
- package/lib/src/utils/configUtils.js +1 -61
- package/lib/src/utils/dom.js +1 -46
- package/lib/src/utils/funcs.js +1 -50
- package/lib/src/utils/geodesy.js +1 -35
- package/lib/src/utils/geom.js +1 -141
- package/lib/src/utils/i18n.js +1 -70
- package/lib/src/utils/observable.js +1 -76
- package/lib/src/utils/rand.js +1 -82
- package/package.json +23 -6
- package/lib/_virtual/_empty_module_placeholder +0 -3
package/lib/src/utils/geom.js
CHANGED
|
@@ -1,141 +1 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
|
|
3
|
-
// https://stackoverflow.com/questions/22521982/check-if-point-inside-a-polygon
|
|
4
|
-
const pointInPolygon = (point, vs) => {
|
|
5
|
-
const x = point[0];
|
|
6
|
-
const y = point[1];
|
|
7
|
-
|
|
8
|
-
let inside = false;
|
|
9
|
-
for (let i = 0, j = vs.length - 1; i < vs.length; j = i++) {
|
|
10
|
-
const xi = vs[i][0];
|
|
11
|
-
const yi = vs[i][1];
|
|
12
|
-
const xj = vs[j][0];
|
|
13
|
-
const yj = vs[j][1];
|
|
14
|
-
const intersect = ((yi > y) !== (yj > y)) &&
|
|
15
|
-
(x < (xj - xi) * (y - yi) / (yj - yi) + xi);
|
|
16
|
-
if (intersect) {
|
|
17
|
-
inside = !inside;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return inside
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Pass in a buildings array and a lat,lng and this will return the building at that point
|
|
26
|
-
* or undefined if no building exists at that point. This runs very quickly as we very often
|
|
27
|
-
* can skip the slowest path (which runs pointInPolygon). Without preciseFlag we sometimes return
|
|
28
|
-
* a building when the point falls outside it - but won't return a wrong building. In some cases this
|
|
29
|
-
* is actually desired behavior anyway (such as building selector)
|
|
30
|
-
* @param {Array.Object} buildings
|
|
31
|
-
* @param {float} lat latitude of point to check
|
|
32
|
-
* @param {float} lng longitude of point to check
|
|
33
|
-
* @param {boolean} preciseFlag if not true we take a shortcut when a single building falls within bounding box (very common case)
|
|
34
|
-
* @returns {object} building that contains the point passed, or undefined if none
|
|
35
|
-
*/
|
|
36
|
-
function getStructureAtPoint (buildings, lat, lng, preciseFlag) {
|
|
37
|
-
if (!R.length(buildings)) return null
|
|
38
|
-
|
|
39
|
-
buildings = buildings.filter(b => b.shouldDisplay == null || b.shouldDisplay === true);
|
|
40
|
-
|
|
41
|
-
const pointInPolygonCurried = R.curry(pointInPolygon)([lat, lng]);
|
|
42
|
-
|
|
43
|
-
const buildingsWithinBoundingBox = buildings
|
|
44
|
-
.filter(R.compose(pointInPolygonCurried, getBoundsCoords));
|
|
45
|
-
|
|
46
|
-
if (buildingsWithinBoundingBox.length === 0) return null
|
|
47
|
-
if (buildingsWithinBoundingBox.length === 1 && !preciseFlag)
|
|
48
|
-
return R.head(buildingsWithinBoundingBox)
|
|
49
|
-
|
|
50
|
-
const buildingsWithinBoundsPolygon = buildingsWithinBoundingBox
|
|
51
|
-
.filter(R.compose(pointInPolygonCurried, R.prop('boundsPolygon')));
|
|
52
|
-
|
|
53
|
-
if (buildingsWithinBoundsPolygon.length === 1)
|
|
54
|
-
return R.head(buildingsWithinBoundsPolygon)
|
|
55
|
-
|
|
56
|
-
if (buildingsWithinBoundsPolygon.length)
|
|
57
|
-
return findBuildingWithMaxArea(buildingsWithinBoundingBox)
|
|
58
|
-
return null
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const getBoundsCoords = building => {
|
|
62
|
-
const { n, s, e, w } = building.bounds;
|
|
63
|
-
return [[n, e], [n, w], [s, w], [s, e]]
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const calcBuildingArea = currentBuilding => {
|
|
67
|
-
if (!currentBuilding.bounds) return 0
|
|
68
|
-
const { n, s, e, w } = currentBuilding.bounds;
|
|
69
|
-
return Math.abs((n - s) * (e - w))
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const findBuildingWithMaxArea = R.reduce(R.maxBy(calcBuildingArea), {});
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* given a building and ord, return the floor (or undefined if doesn't exist)
|
|
76
|
-
*/
|
|
77
|
-
const ordToFloor = (building, ord) =>
|
|
78
|
-
Object.values(building.levels).reduce((matchedFloor, floor) =>
|
|
79
|
-
floor.ordinal === ord ? floor : matchedFloor, undefined);
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Return the floor based on its ID (pass in buildings array and floorId)
|
|
83
|
-
*/
|
|
84
|
-
const getFloor = (buildings, selectedLevelId) =>
|
|
85
|
-
buildings.reduce((fmatch, building) =>
|
|
86
|
-
Object.values(building.levels).reduce((fmatch, floor) =>
|
|
87
|
-
floor.id === selectedLevelId ? floor : fmatch, null) || fmatch, undefined);
|
|
88
|
-
|
|
89
|
-
function getBuildingAndFloorAtPoint (buildings, lat, lng, ord, preciseFlag) {
|
|
90
|
-
const building = getStructureAtPoint(buildings, lat, lng, preciseFlag);
|
|
91
|
-
const floor = building
|
|
92
|
-
? ordToFloor(building, ord)
|
|
93
|
-
: null;
|
|
94
|
-
return { building, floor }
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const getFloorAt = (buildings, lat, lng, ord, preciseFlag) => getBuildingAndFloorAtPoint(buildings, lat, lng, ord, preciseFlag).floor;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Calculate the points for a bezier cubic curve
|
|
101
|
-
*
|
|
102
|
-
* @param {number} fromX - Starting point x
|
|
103
|
-
* @param {number} fromY - Starting point y
|
|
104
|
-
* @param {number} cpX - Control point x
|
|
105
|
-
* @param {number} cpY - Control point y
|
|
106
|
-
* @param {number} cpX2 - Second Control point x
|
|
107
|
-
* @param {number} cpY2 - Second Control point y
|
|
108
|
-
* @param {number} toX - Destination point x
|
|
109
|
-
* @param {number} toY - Destination point y
|
|
110
|
-
* @return {Object[]} Array of points of the curve
|
|
111
|
-
*/
|
|
112
|
-
function bezierCurveTo (fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY) {
|
|
113
|
-
const n = 20; // controls smoothness of line
|
|
114
|
-
let dt = 0;
|
|
115
|
-
let dt2 = 0;
|
|
116
|
-
let dt3 = 0;
|
|
117
|
-
let t2 = 0;
|
|
118
|
-
let t3 = 0;
|
|
119
|
-
|
|
120
|
-
const path = [{ x: fromX, y: fromY }];
|
|
121
|
-
|
|
122
|
-
for (let i = 1, j = 0; i <= n; ++i) {
|
|
123
|
-
j = i / n;
|
|
124
|
-
|
|
125
|
-
dt = (1 - j);
|
|
126
|
-
dt2 = dt * dt;
|
|
127
|
-
dt3 = dt2 * dt;
|
|
128
|
-
|
|
129
|
-
t2 = j * j;
|
|
130
|
-
t3 = t2 * j;
|
|
131
|
-
|
|
132
|
-
path.push({
|
|
133
|
-
x: (dt3 * fromX) + (3 * dt2 * j * cpX) + (3 * dt * t2 * cpX2) + (t3 * toX),
|
|
134
|
-
y: (dt3 * fromY) + (3 * dt2 * j * cpY) + (3 * dt * t2 * cpY2) + (t3 * toY)
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return path
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export { bezierCurveTo, getBuildingAndFloorAtPoint, getFloor, getFloorAt, getStructureAtPoint, ordToFloor, pointInPolygon };
|
|
1
|
+
import*as n from"ramda";const e=(n,e)=>{const t=n[0],r=n[1];let l=!1;for(let n=0,o=e.length-1;n<e.length;o=n++){const u=e[n][0],s=e[n][1],c=e[o][0],i=e[o][1];s>r!=i>r&&t<(c-u)*(r-s)/(i-s)+u&&(l=!l)}return l};function t(t,l,u,s){if(!n.length(t))return null;t=t.filter((n=>null==n.shouldDisplay||!0===n.shouldDisplay));const c=n.curry(e)([l,u]),i=t.filter(n.compose(c,r));if(0===i.length)return null;if(1===i.length&&!s)return n.head(i);const d=i.filter(n.compose(c,n.prop("boundsPolygon")));return 1===d.length?n.head(d):d.length?o(i):s?null:o(i)}const r=n=>{const{n:e,s:t,e:r,w:l}=n.bounds;return[[e,r],[e,l],[t,l],[t,r]]},l=n=>{if(!n.bounds)return 0;const{n:e,s:t,e:r,w:l}=n.bounds;return Math.abs((e-t)*(r-l))},o=n=>{return n.reduce((e=l,(n,t)=>e(n)<e(t)?n:t));var e},u=(n,e)=>Object.values(n.levels).reduce(((n,t)=>t.ordinal===e?t:n),void 0),s=(n,e)=>n.reduce(((n,t)=>Object.values(t.levels).reduce(((n,t)=>t.id===e?t:n),null)||n),void 0);function c(n,e,r,l,o){const s=t(n,e,r,o);return{building:s,floor:s?u(s,l):null}}const i=(n,e,t,r,l)=>c(n,e,t,r,l).floor;function d(n,e,t,r,l,o,u,s){let c=0,i=0,d=0,f=0,a=0;const h=[{x:n,y:e}];for(let g=1,p=0;g<=20;++g)p=g/20,c=1-p,i=c*c,d=i*c,f=p*p,a=f*p,h.push({x:d*n+3*i*p*t+3*c*f*l+a*u,y:d*e+3*i*p*r+3*c*f*o+a*s});return h}export{d as bezierCurveTo,c as getBuildingAndFloorAtPoint,s as getFloor,i as getFloorAt,t as getStructureAtPoint,u as ordToFloor,e as pointInPolygon};
|
package/lib/src/utils/i18n.js
CHANGED
|
@@ -1,70 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
async function init (langOverride, debugMode) {
|
|
4
|
-
const i18n = i18next.createInstance();
|
|
5
|
-
return i18n
|
|
6
|
-
// .use(dashEmAll)
|
|
7
|
-
// .use(pseudoTrans)
|
|
8
|
-
.init({
|
|
9
|
-
debug: debugMode,
|
|
10
|
-
interpolation: {
|
|
11
|
-
escapeValue: false
|
|
12
|
-
},
|
|
13
|
-
resources: {
|
|
14
|
-
en: {
|
|
15
|
-
translation: {
|
|
16
|
-
'Walk xx minutes to': 'Walk {{count}} minute to',
|
|
17
|
-
'Walk xx minutes to_plural': 'Walk {{count}} minutes to'
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
fallbackLng: 'en',
|
|
22
|
-
// ns: ['common', 'banner', 'common', 'directions', 'failure', 'flights', 'legal', 'navigation', 'poi', 'search', 'security', 'time', 'tooltip'],
|
|
23
|
-
// defaultNS: 'common',
|
|
24
|
-
lng: langOverride, /* , interpolation: {
|
|
25
|
-
escapeValue: true
|
|
26
|
-
} */
|
|
27
|
-
postProcess: ['pseudoTrans']
|
|
28
|
-
})
|
|
29
|
-
.then(() => {
|
|
30
|
-
if (debugMode) {
|
|
31
|
-
i18n.on('missingKey', function (lngs, namespace, key, res) {
|
|
32
|
-
console.error('i18nNext: key not found. Language: ' + i18n.language + ', Key: ' + key + ', namespace: ' + namespace + ', lngs: ', lngs);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// i18n.changeLanguage(lng, callback)
|
|
37
|
-
// i18n.t(key, interpolation)
|
|
38
|
-
|
|
39
|
-
return i18n
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// A postprocessor plugin for i18next that replaces all words with dashes - this helps identify untranslated strings
|
|
44
|
-
// const dashEmAll = {
|
|
45
|
-
// name: 'dashEmAll',
|
|
46
|
-
// type: 'postProcessor',
|
|
47
|
-
// process: (value, key, options, translator) => value.replace(/[^ .-_,]/g, '-')
|
|
48
|
-
// }
|
|
49
|
-
|
|
50
|
-
// const pseudoTrans = {
|
|
51
|
-
// name: 'pseudoTrans',
|
|
52
|
-
// type: 'postProcessor',
|
|
53
|
-
// process: (value, key, options, translator) => toLang(value, translator.language)
|
|
54
|
-
// }
|
|
55
|
-
|
|
56
|
-
const loremIpsum = {
|
|
57
|
-
ar: `بال عن أمام الأخذ البرية. ثم كما وقام شاسعة الجنوبي, أمدها الإمداد عن انه. ٣٠ فكانت والكساد انه. أساسي الشمال الإتفاقية بال أم. زهاء المؤلّفة حين عل, سكان قررت هذه ان, شعار باستخدام ولم مع.
|
|
58
|
-
|
|
59
|
-
دول الأمور الصفحة الأوروبية قد. تم حدى فاتّبع الهجوم, ما أوسع معاملة فعل, خلاف الأوروبية، إيو كل. تُصب واندونيسيا، حين قد. أي حاول حقول وهولندا، هذا, بين عن لهيمنة بالسيطرة.
|
|
60
|
-
|
|
61
|
-
أعمال الإتحاد العمليات من وصل. وقوعها، باستخدام قد أخر, بل حتى علاقة التبرعات. فقد لم الأرض استبدال. حتى الخاسر اقتصادية بـ. أصقاع أعلنت اتفاقية تلك بل, كان إذ بحشد أخرى ليبين. الشتاء، اليابان، مكن أم, به، قد العالم، أوراقهم, بل لعدم لغزو أواخر مكن.
|
|
62
|
-
`,
|
|
63
|
-
ja: '私は場合いよいよある所有らってのの末がしたた。無論結果に圧迫顔もよくその発展ないですまでを決するてみるでしでも発展云いませたから、そうには描いたないたた。機会へ載っない方は別に今をひょろひょろでずまし。むしろ嘉納さんを意味方面そう#「を積んない権力この自分何か記念をというおお尋ねだろででですで、ある今はこれか頼み例があるで、ネルソンさんののの引込のあなたにもっともお努力といと私赤に実建設が起っようにとやかくご附随を描いですましから、どうもとにかく相違に云おでてならますのが行っないませ。'
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const toLang = (str, lang) => lang === 'en' ? str : repl(str, loremIpsum[lang]);
|
|
67
|
-
const repl = (str, r) => str.length < r.length ? r.substring(0, str.length) : r;
|
|
68
|
-
|
|
69
|
-
export default init;
|
|
70
|
-
export { toLang };
|
|
1
|
+
import n from"i18next";async function e(e,t){const a=n.createInstance();return a.init({debug:t,interpolation:{escapeValue:!1},resources:{en:{translation:{"Walk xx minutes to":"Walk {{count}} minute to","Walk xx minutes to_plural":"Walk {{count}} minutes to"}}},fallbackLng:"en",lng:e,postProcess:["pseudoTrans"]}).then((()=>(t&&a.on("missingKey",(function(n,e,t,o){console.error("i18nNext: key not found. Language: "+a.language+", Key: "+t+", namespace: "+e+", lngs: ",n)})),a)))}const t={ar:"بال عن أمام الأخذ البرية. ثم كما وقام شاسعة الجنوبي, أمدها الإمداد عن انه. ٣٠ فكانت والكساد انه. أساسي الشمال الإتفاقية بال أم. زهاء المؤلّفة حين عل, سكان قررت هذه ان, شعار باستخدام ولم مع.\n\nدول الأمور الصفحة الأوروبية قد. تم حدى فاتّبع الهجوم, ما أوسع معاملة فعل, خلاف الأوروبية، إيو كل. تُصب واندونيسيا، حين قد. أي حاول حقول وهولندا، هذا, بين عن لهيمنة بالسيطرة.\n\nأعمال الإتحاد العمليات من وصل. وقوعها، باستخدام قد أخر, بل حتى علاقة التبرعات. فقد لم الأرض استبدال. حتى الخاسر اقتصادية بـ. أصقاع أعلنت اتفاقية تلك بل, كان إذ بحشد أخرى ليبين. الشتاء، اليابان، مكن أم, به، قد العالم، أوراقهم, بل لعدم لغزو أواخر مكن.\n",ja:"私は場合いよいよある所有らってのの末がしたた。無論結果に圧迫顔もよくその発展ないですまでを決するてみるでしでも発展云いませたから、そうには描いたないたた。機会へ載っない方は別に今をひょろひょろでずまし。むしろ嘉納さんを意味方面そう#「を積んない権力この自分何か記念をというおお尋ねだろででですで、ある今はこれか頼み例があるで、ネルソンさんののの引込のあなたにもっともお努力といと私赤に実建設が起っようにとやかくご附随を描いですましから、どうもとにかく相違に云おでてならますのが行っないませ。"},a=(n,e)=>"en"===e?n:o(n,t[e]),o=(n,e)=>n.length<e.length?e.substring(0,n.length):e;export{e as default,a as toLang};
|
|
@@ -1,76 +1 @@
|
|
|
1
|
-
function fire () {
|
|
2
|
-
const ob = this._observers;
|
|
3
|
-
|
|
4
|
-
if (!ob)
|
|
5
|
-
return undefined
|
|
6
|
-
|
|
7
|
-
for (let x = 0; x < ob.length; x++)
|
|
8
|
-
try { ob[x].apply(this, arguments); } catch (err) { console.error(err); }
|
|
9
|
-
|
|
10
|
-
return this
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function observe (cb) {
|
|
14
|
-
if (!this._observers)
|
|
15
|
-
this._observers = [];
|
|
16
|
-
|
|
17
|
-
this._observers.push(cb);
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
detach: detach.bind(this, cb),
|
|
21
|
-
ob: this
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function detach (cb) {
|
|
26
|
-
this._observers.splice(this._observers.indexOf(cb), 1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Returns a new derivitive observer that fires events when the observed object fires iff
|
|
30
|
-
// the event passes the predicate function specified here.
|
|
31
|
-
function filter (fn) {
|
|
32
|
-
const o2 = create();
|
|
33
|
-
|
|
34
|
-
this.observe(function () {
|
|
35
|
-
if (fn.apply(this, arguments))
|
|
36
|
-
o2.fire.apply(o2, arguments);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return o2
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// When first argument denotes an event name, this is a convenience
|
|
43
|
-
// method to filter by that name
|
|
44
|
-
function filterByName (eventName) {
|
|
45
|
-
return filter.call(this, function (name) {
|
|
46
|
-
return eventName === name
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Filters on equivilence of first argument (often the event name) and observes
|
|
51
|
-
// the result - calling the callback function when triggered
|
|
52
|
-
function on (value, cb) {
|
|
53
|
-
return filterByName.call(this, value).observe(cb)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function detachAll () { this._observers = []; }
|
|
57
|
-
|
|
58
|
-
const observable = { detach, detachAll, filter, fire, observe, on };
|
|
59
|
-
|
|
60
|
-
// extend `to` argument with properties from `from`
|
|
61
|
-
// [short version]
|
|
62
|
-
function extend (to, from) {
|
|
63
|
-
for (const prop in from)
|
|
64
|
-
to[prop] = from[prop];
|
|
65
|
-
|
|
66
|
-
return to
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function create (ob) {
|
|
70
|
-
if (ob)
|
|
71
|
-
return extend(ob, observable)
|
|
72
|
-
|
|
73
|
-
return Object.create(observable)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export default create;
|
|
1
|
+
function t(t){this._observers.splice(this._observers.indexOf(t),1)}function e(t){const e=s();return this.observe((function(){t.apply(this,arguments)&&e.fire.apply(e,arguments)})),e}function r(t){return e.call(this,(function(e){return t===e}))}const n={detach:t,filter:e,fire:function(){const t=this._observers;if(t){for(let e=0;e<t.length;e++)try{t[e].apply(this,arguments)}catch(t){console.error(t)}return this}},observe:function(e){return this._observers||(this._observers=[]),this._observers.push(e),{detach:t.bind(this,e),ob:this}},on:function(t,e){return r.call(this,t).observe(e)}};function s(t){return t?function(t,e){for(const r in e)t[r]=e[r];return t}(t,n):Object.create(n)}export{s as default};
|
package/lib/src/utils/rand.js
CHANGED
|
@@ -1,82 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
nextInt: max => Math.floor(Math.random() * max)
|
|
3
|
-
});
|
|
4
|
-
|
|
5
|
-
const defaultRandom = jsRandom();
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Returns a random list of length size of numbers from 0 to max-1, which represents a set of
|
|
9
|
-
* those numbers. i.e. no number will repeat. (size is forced to not be bigger than max)
|
|
10
|
-
*
|
|
11
|
-
* Can be used to choose a random selection from a list of selections. Or if
|
|
12
|
-
* size = max, it becomes a random ordering of a List.
|
|
13
|
-
*
|
|
14
|
-
* NOTE: if the setSize is 0, max will set to 0 and you get an empty List object
|
|
15
|
-
*
|
|
16
|
-
* ForExample:
|
|
17
|
-
* randomSet(3, 5) = [3, 2, 0]
|
|
18
|
-
* randomSet(3, 5) = [1, 0, 3]
|
|
19
|
-
* randomSet(3, 5) = [1, 4, 2]
|
|
20
|
-
*
|
|
21
|
-
* @param size the number of values to return
|
|
22
|
-
* @param max a positive integer
|
|
23
|
-
* @param r an optional Random instance (else one is generated)
|
|
24
|
-
* @return a List of random values from 0 to max-1 with no number repeating
|
|
25
|
-
*/
|
|
26
|
-
function randomSet (size, max, r) {
|
|
27
|
-
r = r || defaultRandom;
|
|
28
|
-
|
|
29
|
-
let i;
|
|
30
|
-
|
|
31
|
-
if (!max)
|
|
32
|
-
max = size;
|
|
33
|
-
|
|
34
|
-
if (size > max)
|
|
35
|
-
size = max;
|
|
36
|
-
|
|
37
|
-
const list = [];
|
|
38
|
-
|
|
39
|
-
if (((max / size) >= 2.0) || (max < 40)) {
|
|
40
|
-
// if the set we are choosing from is considerably bigger than the number we are selecting
|
|
41
|
-
// then let's just grab random values and check to see if they are in our new list yet.
|
|
42
|
-
while (list.length < size) {
|
|
43
|
-
i = r.nextInt(max);
|
|
44
|
-
if (list.indexOf(i) < 0)
|
|
45
|
-
list.push(i);
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
// if the list is to be nearly same size as what we are choosing from, let's build a source
|
|
49
|
-
// list of the numbers and grab from them one at a time.
|
|
50
|
-
const source = [];
|
|
51
|
-
for (i = 0; i < max; i++)
|
|
52
|
-
source.push(i);
|
|
53
|
-
|
|
54
|
-
for (i = 0; i < size; i++) {
|
|
55
|
-
const index = r.nextInt(source.length);
|
|
56
|
-
list.push(source[index]);
|
|
57
|
-
source.splice(index, 1);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return list
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Pass in a source array and a map array of indices, and this returns a new
|
|
65
|
-
// array of the members of the first based on the indices of the second. Useful when
|
|
66
|
-
// used along with randomset above.
|
|
67
|
-
// i.e.
|
|
68
|
-
// a1 = [ "a", "b", "c", "d", "e", "f" ]
|
|
69
|
-
// a2 = [ 2, 3, 5, 4, 0, 1]
|
|
70
|
-
// a3 = getMappedArray(a1, a2) = [ "c", "d", "f", "e", "a", "b" ]
|
|
71
|
-
const getMappedArray = (array, map) => map.map(i => array[i]);
|
|
72
|
-
|
|
73
|
-
// Randomly pick a number of items from an array and return them in an array
|
|
74
|
-
// leaving the original array untouched. If no number is specified, a length
|
|
75
|
-
// of 1 is returned.
|
|
76
|
-
const arrayPick = (array, num) => {
|
|
77
|
-
num = num || 1;
|
|
78
|
-
const map = randomSet(num, array.length);
|
|
79
|
-
return getMappedArray(array, map)
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export { arrayPick, randomSet };
|
|
1
|
+
const t={nextInt:t=>Math.floor(Math.random()*t)};function n(n,e,o){let s;o=o||t,e||(e=n),n>e&&(n=e);const h=[];if(e/n>=2||e<40)for(;h.length<n;)s=o.nextInt(e),h.indexOf(s)<0&&h.push(s);else{const t=[];for(s=0;s<e;s++)t.push(s);for(s=0;s<n;s++){const n=o.nextInt(t.length);h.push(t[n]),t.splice(n,1)}}return h}const e=(t,e)=>((t,n)=>n.map((n=>t[n])))(t,n(e=e||1,t.length));export{e as arrayPick,n as randomSet};
|
package/package.json
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atriusmaps-node-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.2.28",
|
|
4
4
|
"description": "This project provides an API to Atrius Personal Wayfinder maps within a Node environment. See the README.md for more information",
|
|
5
|
-
"module": "lib/deploy/nodeEntry.js",
|
|
6
|
-
"main": "lib/deploy/nodeEntry.js",
|
|
7
|
-
"license": "UNLICENSED",
|
|
8
|
-
"type": "module",
|
|
9
5
|
"keywords": [
|
|
10
6
|
"map",
|
|
11
7
|
"mapping",
|
|
@@ -18,14 +14,35 @@
|
|
|
18
14
|
"atrius",
|
|
19
15
|
"acuitybrands"
|
|
20
16
|
],
|
|
21
|
-
"repository": "https://gitlab.com/locuslabspublic/node-sdk",
|
|
17
|
+
"repository": "https://gitlab.com/locuslabspublic/atriusmaps-node-sdk",
|
|
18
|
+
"license": "UNLICENSED",
|
|
22
19
|
"author": "Glenn Crownover <crownover@locuslabs.com>",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./lib/deploy/nodeEntry.js",
|
|
24
|
+
"require": "./dist/cjs/deploy/nodeEntry.js",
|
|
25
|
+
"default": "./dist/cjs/deploy/nodeEntry.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"main": "./dist/cjs/deploy/nodeEntry.js",
|
|
30
|
+
"module": "./lib/deploy/nodeEntry.js",
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "yarn build:CJS",
|
|
33
|
+
"build:CJS": "rollup -c config/rollup.config.cjs.js"
|
|
34
|
+
},
|
|
23
35
|
"dependencies": {
|
|
24
36
|
"IObject": "^0.6.2",
|
|
37
|
+
"flexsearch": "0.6.32",
|
|
25
38
|
"i18next": "^20.3.4",
|
|
26
39
|
"node-fetch": "^2.6.1",
|
|
27
40
|
"query-string": "^7.0.1",
|
|
28
41
|
"ramda": "^0.27.1",
|
|
29
42
|
"zousan-plus": "^4.0.1"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
46
|
+
"rollup": "^2.59.0"
|
|
30
47
|
}
|
|
31
48
|
}
|