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.
Files changed (105) hide show
  1. package/README.md +76 -0
  2. package/config/rollup.config.cjs.js +31 -0
  3. package/dist/cjs/_virtual/_empty_module_placeholder.js +5 -0
  4. package/dist/cjs/deploy/nodeEntry.js +15 -0
  5. package/dist/cjs/deploy/prepareSDKConfig.js +9 -0
  6. package/dist/cjs/package.json +1 -0
  7. package/dist/cjs/package.json.js +11 -0
  8. package/dist/cjs/plugins/clientAPI/src/clientAPI.js +9 -0
  9. package/dist/cjs/plugins/dynamicPois/src/dynamicPois.js +33 -0
  10. package/dist/cjs/plugins/poiDataManager/src/poiDataManager.js +36 -0
  11. package/dist/cjs/plugins/sdkServer/src/sdkHeadless.js +31 -0
  12. package/dist/cjs/plugins/sdkServer/src/sdkServer.js +13 -0
  13. package/dist/cjs/plugins/sdkServer/src/util.js +10 -0
  14. package/dist/cjs/plugins/searchService/src/poiSearch.js +28 -0
  15. package/dist/cjs/plugins/searchService/src/searchService.js +37 -0
  16. package/dist/cjs/plugins/searchService/src/searchTypeahead.js +8 -0
  17. package/dist/cjs/plugins/searchService/src/utils.js +13 -0
  18. package/dist/cjs/plugins/venueDataLoader/src/venueDataLoader.js +36 -0
  19. package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +34 -0
  20. package/dist/cjs/plugins/wayfinder/src/findRoute.js +30 -0
  21. package/dist/cjs/plugins/wayfinder/src/minPriorityQueue.js +5 -0
  22. package/dist/cjs/plugins/wayfinder/src/navGraph.js +13 -0
  23. package/dist/cjs/plugins/wayfinder/src/navGraphDebug.js +30 -0
  24. package/dist/cjs/plugins/wayfinder/src/segmentBadges.js +5 -0
  25. package/dist/cjs/plugins/wayfinder/src/segmentBuilder.js +32 -0
  26. package/dist/cjs/plugins/wayfinder/src/segmentCategories.js +5 -0
  27. package/dist/cjs/plugins/wayfinder/src/stepBuilder.js +10 -0
  28. package/dist/cjs/plugins/wayfinder/src/wayfinder.js +40 -0
  29. package/dist/cjs/src/app.js +44 -0
  30. package/dist/cjs/src/auth/Auth.js +23 -0
  31. package/dist/cjs/src/configs/postproc-mol-url-parms.js +9 -0
  32. package/dist/cjs/src/configs/postproc-stateTracking.js +31 -0
  33. package/dist/cjs/src/configs/sdkHeadless.json.js +47 -0
  34. package/dist/cjs/src/controller.js +14 -0
  35. package/dist/cjs/src/debugTools.js +30 -0
  36. package/dist/cjs/src/env.js +7 -0
  37. package/dist/cjs/src/extModules/bustle.js +13 -0
  38. package/dist/cjs/src/extModules/flexapi/src/help.js +9 -0
  39. package/dist/cjs/src/extModules/flexapi/src/index.js +13 -0
  40. package/dist/cjs/src/extModules/flexapi/src/validate.js +10 -0
  41. package/dist/cjs/src/extModules/geohasher.js +8 -0
  42. package/dist/cjs/src/extModules/log.js +7 -0
  43. package/dist/cjs/src/historyManager.js +7 -0
  44. package/dist/cjs/src/utils/bounds.js +10 -0
  45. package/dist/cjs/src/utils/buildStructureLookup.js +29 -0
  46. package/dist/cjs/src/utils/configUtils.js +8 -0
  47. package/dist/cjs/src/utils/dom.js +10 -0
  48. package/dist/cjs/src/utils/funcs.js +15 -0
  49. package/dist/cjs/src/utils/geodesy.js +8 -0
  50. package/dist/cjs/src/utils/geom.js +35 -0
  51. package/dist/cjs/src/utils/i18n.js +14 -0
  52. package/dist/cjs/src/utils/observable.js +5 -0
  53. package/dist/cjs/src/utils/rand.js +8 -0
  54. package/lib/_virtual/_empty_module_placeholder.js +1 -0
  55. package/lib/deploy/nodeEntry.js +1 -58
  56. package/lib/deploy/prepareSDKConfig.js +1 -112
  57. package/lib/package.json.js +1 -143
  58. package/lib/plugins/clientAPI/src/clientAPI.js +1 -14
  59. package/lib/plugins/dynamicPois/src/dynamicPois.js +1 -131
  60. package/lib/plugins/poiDataManager/src/poiDataManager.js +1 -207
  61. package/lib/plugins/sdkServer/src/sdkHeadless.js +1 -53
  62. package/lib/plugins/sdkServer/src/sdkServer.js +1 -211
  63. package/lib/plugins/sdkServer/src/util.js +1 -18
  64. package/lib/plugins/searchService/src/poiSearch.js +1 -39
  65. package/lib/plugins/searchService/src/searchService.js +1 -234
  66. package/lib/plugins/searchService/src/searchTypeahead.js +1 -63
  67. package/lib/plugins/searchService/src/utils.js +1 -30
  68. package/lib/plugins/venueDataLoader/src/venueDataLoader.js +1 -465
  69. package/lib/plugins/venueDataLoader/src/venueLoadingUtils.js +1 -84
  70. package/lib/plugins/wayfinder/src/findRoute.js +1 -134
  71. package/lib/plugins/wayfinder/src/minPriorityQueue.js +1 -89
  72. package/lib/plugins/wayfinder/src/navGraph.js +1 -370
  73. package/lib/plugins/wayfinder/src/navGraphDebug.js +1 -95
  74. package/lib/plugins/wayfinder/src/segmentBadges.js +1 -29
  75. package/lib/plugins/wayfinder/src/segmentBuilder.js +1 -241
  76. package/lib/plugins/wayfinder/src/segmentCategories.js +1 -30
  77. package/lib/plugins/wayfinder/src/stepBuilder.js +1 -236
  78. package/lib/plugins/wayfinder/src/wayfinder.js +1 -452
  79. package/lib/src/app.js +1 -150
  80. package/lib/src/auth/Auth.js +1 -35
  81. package/lib/src/configs/postproc-mol-url-parms.js +1 -58
  82. package/lib/src/configs/postproc-stateTracking.js +1 -40
  83. package/lib/src/configs/sdkHeadless.json.js +1 -42
  84. package/lib/src/controller.js +1 -45
  85. package/lib/src/debugTools.js +1 -108
  86. package/lib/src/env.js +1 -17
  87. package/lib/src/extModules/bustle.js +1 -126
  88. package/lib/src/extModules/flexapi/src/help.js +1 -21
  89. package/lib/src/extModules/flexapi/src/index.js +1 -66
  90. package/lib/src/extModules/flexapi/src/validate.js +1 -131
  91. package/lib/src/extModules/geohasher.js +1 -90
  92. package/lib/src/extModules/log.js +1 -70
  93. package/lib/src/historyManager.js +1 -30
  94. package/lib/src/utils/bounds.js +1 -23
  95. package/lib/src/utils/buildStructureLookup.js +1 -17
  96. package/lib/src/utils/configUtils.js +1 -61
  97. package/lib/src/utils/dom.js +1 -46
  98. package/lib/src/utils/funcs.js +1 -50
  99. package/lib/src/utils/geodesy.js +1 -35
  100. package/lib/src/utils/geom.js +1 -141
  101. package/lib/src/utils/i18n.js +1 -70
  102. package/lib/src/utils/observable.js +1 -76
  103. package/lib/src/utils/rand.js +1 -82
  104. package/package.json +23 -6
  105. package/lib/_virtual/_empty_module_placeholder +0 -3
@@ -1,131 +1 @@
1
- // small helper for showing args
2
- const SQ = '\''; // single quote
3
- const sqStr = function (str) { return SQ + str + SQ };
4
-
5
- function validate (library, sig, cob) {
6
- if (sig.args)
7
- checkTypeList(library.customTypes, sig.args, cob);
8
- }
9
-
10
- function getSigMatch (library, cob) {
11
- const matches = library.commandDefsList
12
- .filter(cd => (cd.sig.command === cob.command) && matchesArgs(cd.sig, cob));
13
- if (matches.length > 1) { throw Error('Command matches multiple signatures!') }
14
- if (matches.length > 0) { return matches[0] }
15
- return null // no matching signature found
16
- }
17
-
18
- // returns true if each of the required arguments in the command
19
- // spec (c) is defined within the command object (o) - else false
20
- function matchesArgs (c, o) {
21
- if (!c.args) { return true } // no args
22
- return c.args.reduce(function (cs, argOb) {
23
- return o[argOb.name] !== undefined || argOb.optional ? cs : false
24
- }, true)
25
- }
26
-
27
- function checkMinMax (name, typeSpec, value) {
28
- if (typeSpec.min !== undefined && value < typeSpec.min) { throw Error('argument ' + sqStr(name) + ' must be at least ' + typeSpec.min + ' but is ' + value) }
29
- if (typeSpec.max !== undefined && value > typeSpec.max) { throw Error('argument ' + sqStr(name) + ' must be at most ' + typeSpec.max + ' but is ' + value) }
30
- }
31
-
32
- /**
33
- * Checks an argument value against that arguments spec. If there are no violations of the argSpec, true is returned.
34
- * If there is a violation, an error is thrown.
35
- * @param {object} customTypes any defined custom types
36
- * @param {object} typeSpec An type spec object which inclues a type and other constraints if applicable
37
- * @param {*} value The JSON value to be checked against this spec
38
- * @return {true|string} returns true if arg is valid, else a string description of the problem
39
- */
40
- function checkType (customTypes, typeSpec, value) {
41
- if (!typeSpec) // if there is no typespec to validate against, any value is ok
42
- return true
43
-
44
- const name = typeSpec.name || '';
45
-
46
- // if type is a reference/custom, grab that type def but allow "optional" override - TODO: consider other overrides (perhaps all but "type"?)
47
- if (customTypes && customTypes[typeSpec.type])
48
- typeSpec = Object.assign({}, customTypes[typeSpec.type], typeSpec, { type: customTypes[typeSpec.type].type });
49
-
50
- if (typeSpec.type === 'integer') {
51
- if (typeof value === 'string')
52
- value = parseInt(value, 10);
53
- if (!Number.isInteger(value))
54
- throw Error('expected integer argument for argument ' + sqStr(name) + ' but received ' + value)
55
- checkMinMax(name, typeSpec, value);
56
- } else
57
- if (typeSpec.type === 'float') {
58
- if (typeof value === 'string')
59
- value = parseFloat(value);
60
- if (!Number.isFinite(value))
61
- throw Error('expected float argument for argument ' + sqStr(name) + ' but received \'' + value + '\'')
62
- checkMinMax(name, typeSpec, value);
63
- } else
64
- if (typeSpec.type === 'string') {
65
- if (typeof value !== 'string')
66
- throw Error(`argument ${sqStr(name)} must be a string but is not (value: ${value})`)
67
- if (typeSpec.minLength && value.length < typeSpec.minLength)
68
- throw Error(`argument ${sqStr(name)} must be a at least ${typeSpec.minLength} characters but is '${value}' (${value.length} chars)`)
69
- if (typeSpec.maxLength && value.length > typeSpec.maxLength)
70
- throw Error(`argument ${sqStr(name)} must be a at most ${typeSpec.maxLength} characters but is '${value}' (${value.length} chars)`)
71
- } else
72
- if (typeSpec.type === 'boolean') {
73
- if (value !== true && value !== false && value !== 'false' && value !== 'true' && value !== 'yes' && value !== 'no') { throw Error('argument ' + sqStr(name) + ' must be a boolean but is type ' + (typeof value) + ' with value of ' + value) }
74
- } else
75
- if (typeSpec.type === 'list') {
76
- if (!Array.isArray(value))
77
- throw Error('argument ' + sqStr(name) + ' must be a list but is not. Value = ' + value)
78
- if (typeSpec.minLength !== undefined && typeSpec.minLength > value.length)
79
- throw Error('argument ' + sqStr(name) + ' must contain at least ' + typeSpec.minLength + ' items but only contains ' + value.length + ' items')
80
- if (typeSpec.maxLength !== undefined && typeSpec.maxLength < value.length)
81
- throw Error('argument ' + sqStr(name) + ' must contain at most ' + typeSpec.maxLength + ' items but contains ' + value.length + ' items')
82
- if (typeSpec.itemType) {
83
- const allItemsValid = value.reduce(function (isValid, curItem) {
84
- try {
85
- checkType(customTypes, typeSpec.itemType, curItem);
86
- } catch (e) { return false }
87
- return isValid
88
- }, true);
89
- if (!allItemsValid) { throw Error(`argument ${sqStr(name)} contains an invalid item(s). All items in the list must be of type: ${JSON.stringify(typeSpec.itemType)} - list: ${JSON.stringify(value)}`) }
90
- }
91
- } else
92
- if (typeSpec.type === 'object') {
93
- if (typeof (value) !== 'object' || Array.isArray(value))
94
- throw Error('argument ' + sqStr(name) + ' must be an object but is not. Value = ' + value)
95
- try {
96
- if (typeSpec.props)
97
- checkTypeList(customTypes, typeSpec.props, value);
98
- } catch (e) {
99
- throw Error('Within ' + name + ', ' + e.message)
100
- }
101
- } else
102
- if (typeSpec.type === 'multi') {
103
- const oneTypeValid = typeSpec.types
104
- .reduce((isValid, curType) => {
105
- try {
106
- checkType(customTypes, curType, value);
107
- } catch (e) { return isValid }
108
- return true
109
- }, false);
110
- if (!oneTypeValid)
111
- throw Error(`Argument ${sqStr(name)} can be of several types, but is not valid for any: ${value}`)
112
- } else
113
- throw Error('type ' + typeSpec.type + ' is an unknown type')
114
-
115
- return true
116
- }
117
-
118
- /**
119
- * Given a value and a typelist, ensure the value abides by the typelist
120
- * @param types custom defined types
121
- * @param typeList A list of types to check
122
- * @param args The properties object to check against
123
- */
124
- function checkTypeList (customTypes, typeList, args) {
125
- typeList.forEach(nextType => {
126
- if (args[nextType.name] !== undefined) { checkType(customTypes, nextType, args[nextType.name]); } else
127
- if (!nextType.optional) { throw Error('you must include a value for ' + nextType.name) }
128
- });
129
- }
130
-
131
- export { checkType, checkTypeList, getSigMatch, validate };
1
+ const t=function(t){return"'"+t+"'"};function e(t,e,r){e.args&&o(t.customTypes,e.args,r)}function r(t,e){const r=t.commandDefsList.filter((t=>t.sig.command===e.command&&function(t,e){if(!t.args)return!0;return t.args.reduce((function(t,r){return!(void 0===e[r.name]&&!r.optional)&&t}),!0)}(t.sig,e)));if(r.length>1)throw Error("Command matches multiple signatures!");return r.length>0?r[0]:null}function n(e,r,n){if(void 0!==r.min&&n<r.min)throw Error("argument "+t(e)+" must be at least "+r.min+" but is "+n);if(void 0!==r.max&&n>r.max)throw Error("argument "+t(e)+" must be at most "+r.max+" but is "+n)}function i(e,r,a){if(!r)return!0;const s=r.name||"";if(e&&e[r.type]&&(r=Object.assign({},e[r.type],r,{type:e[r.type].type})),"integer"===r.type){if("string"==typeof a&&(a=parseInt(a,10)),!Number.isInteger(a))throw Error("expected integer argument for argument "+t(s)+" but received "+a);n(s,r,a)}else if("float"===r.type){if("string"==typeof a&&(a=parseFloat(a)),!Number.isFinite(a))throw Error("expected float argument for argument "+t(s)+" but received '"+a+"'");n(s,r,a)}else if("string"===r.type){if("string"!=typeof a)throw Error(`argument ${t(s)} must be a string but is not (value: ${a})`);if(r.minLength&&a.length<r.minLength)throw Error(`argument ${t(s)} must be a at least ${r.minLength} characters but is '${a}' (${a.length} chars)`);if(r.maxLength&&a.length>r.maxLength)throw Error(`argument ${t(s)} must be a at most ${r.maxLength} characters but is '${a}' (${a.length} chars)`)}else if("boolean"===r.type){if(!0!==a&&!1!==a&&"false"!==a&&"true"!==a&&"yes"!==a&&"no"!==a)throw Error("argument "+t(s)+" must be a boolean but is type "+typeof a+" with value of "+a)}else if("list"===r.type){if(!Array.isArray(a))throw Error("argument "+t(s)+" must be a list but is not. Value = "+a);if(void 0!==r.minLength&&r.minLength>a.length)throw Error("argument "+t(s)+" must contain at least "+r.minLength+" items but only contains "+a.length+" items");if(void 0!==r.maxLength&&r.maxLength<a.length)throw Error("argument "+t(s)+" must contain at most "+r.maxLength+" items but contains "+a.length+" items");if(r.itemType){if(!a.reduce((function(t,n){try{i(e,r.itemType,n)}catch(t){return!1}return t}),!0))throw Error(`argument ${t(s)} contains an invalid item(s). All items in the list must be of type: ${JSON.stringify(r.itemType)} - list: ${JSON.stringify(a)}`)}}else if("object"===r.type){if("object"!=typeof a||Array.isArray(a))throw Error("argument "+t(s)+" must be an object but is not. Value = "+a);try{r.props&&o(e,r.props,a)}catch(t){throw Error("Within "+s+", "+t.message)}}else{if("multi"!==r.type)throw Error("type "+r.type+" is an unknown type");if(!r.types.reduce(((t,r)=>{try{i(e,r,a)}catch(e){return t}return!0}),!1))throw Error(`Argument ${t(s)} can be of several types, but is not valid for any: ${a}`)}return!0}function o(t,e,r){e.forEach((e=>{if(void 0!==r[e.name])i(t,e,r[e.name]);else if(!e.optional)throw Error("you must include a value for "+e.name)}))}export{i as checkType,o as checkTypeList,r as getSigMatch,e as validate};
@@ -1,90 +1 @@
1
- // Ported from https://github.com/JacksonTian/geohasher
2
- // to ESM as it was not bundling properly via Rollup as a CJS
3
-
4
- // Geohash library for Javascript
5
- // (c) 2008 David Troy
6
- // (c) 2010 Chris Williams
7
- // (c) 2013 Jackson Tian
8
- // Distributed under the MIT License
9
-
10
- const BITS = [16, 8, 4, 2, 1];
11
-
12
- const BASE32 = '0123456789bcdefghjkmnpqrstuvwxyz';
13
-
14
- const NEIGHBORS = {
15
- right: { even: 'bc01fg45238967deuvhjyznpkmstqrwx' },
16
- left: { even: '238967debc01fg45kmstqrwxuvhjyznp' },
17
- top: { even: 'p0r21436x8zb9dcf5h7kjnmqesgutwvy' },
18
- bottom: { even: '14365h7k9dcfesgujnmqp0r2twvyx8zb' }
19
- };
20
-
21
- const BORDERS = {
22
- right: { even: 'bcfguvyz' },
23
- left: { even: '0145hjnp' },
24
- top: { even: 'prxz' },
25
- bottom: { even: '028b' }
26
- };
27
-
28
- NEIGHBORS.bottom.odd = NEIGHBORS.left.even;
29
- NEIGHBORS.top.odd = NEIGHBORS.right.even;
30
- NEIGHBORS.left.odd = NEIGHBORS.bottom.even;
31
- NEIGHBORS.right.odd = NEIGHBORS.top.even;
32
-
33
- BORDERS.bottom.odd = BORDERS.left.even;
34
- BORDERS.top.odd = BORDERS.right.even;
35
- BORDERS.left.odd = BORDERS.bottom.even;
36
- BORDERS.right.odd = BORDERS.top.even;
37
-
38
- function calculateAdjacent (srcHash, dir) {
39
- srcHash = srcHash.toLowerCase();
40
- const lastChr = srcHash.charAt(srcHash.length - 1);
41
- const type = (srcHash.length % 2) ? 'odd' : 'even';
42
- let base = srcHash.substring(0, srcHash.length - 1);
43
- if (BORDERS[dir][type].indexOf(lastChr) !== -1) {
44
- base = calculateAdjacent(base, dir);
45
- }
46
- return base + BASE32[NEIGHBORS[dir][type].indexOf(lastChr)]
47
- }
48
-
49
- function encode (latitude, longitude, precision) {
50
- let isEven = 1;
51
- const lat = [-90.0, 90.0];
52
- const lng = [-180.0, 180.0];
53
- let bit = 0;
54
- let ch = 0;
55
- precision = precision || 12;
56
-
57
- let geohash = '';
58
- while (geohash.length < precision) {
59
- let mid;
60
- if (isEven) {
61
- mid = (lng[0] + lng[1]) / 2;
62
- if (longitude > mid) {
63
- ch |= BITS[bit];
64
- lng[0] = mid;
65
- } else {
66
- lng[1] = mid;
67
- }
68
- } else {
69
- mid = (lat[0] + lat[1]) / 2;
70
- if (latitude > mid) {
71
- ch |= BITS[bit];
72
- lat[0] = mid;
73
- } else {
74
- lat[1] = mid;
75
- }
76
- }
77
-
78
- isEven = !isEven;
79
- if (bit < 4) {
80
- bit++;
81
- } else {
82
- geohash += BASE32[ch];
83
- bit = 0;
84
- ch = 0;
85
- }
86
- }
87
- return geohash
88
- }
89
-
90
- export { calculateAdjacent, encode };
1
+ const e=[16,8,4,2,1],t="0123456789bcdefghjkmnpqrstuvwxyz",n={right:{even:"bc01fg45238967deuvhjyznpkmstqrwx"},left:{even:"238967debc01fg45kmstqrwxuvhjyznp"},top:{even:"p0r21436x8zb9dcf5h7kjnmqesgutwvy"},bottom:{even:"14365h7k9dcfesgujnmqp0r2twvyx8zb"}},o={right:{even:"bcfguvyz"},left:{even:"0145hjnp"},top:{even:"prxz"},bottom:{even:"028b"}};function d(e,v){const r=(e=e.toLowerCase()).charAt(e.length-1),f=e.length%2?"odd":"even";let g=e.substring(0,e.length-1);return-1!==o[v][f].indexOf(r)&&(g=d(g,v)),g+t[n[v][f].indexOf(r)]}function v(n,o,d){let v=1;const r=[-90,90],f=[-180,180];let g=0,h=0;d=d||12;let l="";for(;l.length<d;){let d;v?(d=(f[0]+f[1])/2,o>d?(h|=e[g],f[0]=d):f[1]=d):(d=(r[0]+r[1])/2,n>d?(h|=e[g],r[0]=d):r[1]=d),v=!v,g<4?g++:(l+=t[h],g=0,h=0)}return l}n.bottom.odd=n.left.even,n.top.odd=n.right.even,n.left.odd=n.bottom.even,n.right.odd=n.top.even,o.bottom.odd=o.left.even,o.top.odd=o.right.even,o.left.odd=o.bottom.even,o.right.odd=o.top.even;export{d as calculateAdjacent,v as encode};
@@ -1,70 +1 @@
1
- // https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
2
- const nodeColorsOb = {
3
- black: '\x1b[30m',
4
- red: '\x1b[31m',
5
- green: '\x1b[32m',
6
- yellow: '\x1b[33m',
7
- blue: '\x1b[34m',
8
- magenta: '\x1b[35m',
9
- cyan: '\x1b[36m',
10
- white: '\x1b[37m'
11
- };
12
-
13
- function clog (name, options = { }) {
14
- let prefix = name + ': ';
15
- let style = null;
16
-
17
- if (options.color)
18
- if (options.isBrowser) {
19
- prefix = '%c' + prefix;
20
- style = `color: ${options.color}`;
21
- } else {
22
- const cstring = nodeColorsOb[options.color];
23
- if (cstring)
24
- prefix = cstring + prefix;
25
- }
26
-
27
- const trunc = (str, len) => str && str.length > len ? str.substring(0, len) + '...' : str;
28
- const checkPassesFilter = (args, filter) => typeof filter === 'string'
29
- ? args[0].includes(filter)
30
- : filter.test(args[0]);
31
-
32
- function logGen (cmethod) {
33
- return function () {
34
- const isEnabled = options.enabled === undefined ? true : !!options.enabled;
35
- if (isEnabled || cmethod === console.error) {
36
- let args = Array.from(arguments);
37
- if (style)
38
- args.unshift(style);
39
- args.unshift(prefix);
40
- if (options.truncateObjects && cmethod !== console.error)
41
- args = args.map(arg => {
42
- if (typeof arg === 'object')
43
- return trunc(JSON.stringify(arg), parseInt(options.truncateObjects) || 100)
44
- return arg
45
- });
46
- const passesFilter = !options.logFilter || checkPassesFilter(args, options.logFilter);
47
- if (passesFilter || cmethod === console.error)
48
- cmethod.apply(console, args);
49
- }
50
- }
51
- }
52
-
53
- const log = logGen(console.log);
54
- log.info = log;
55
- log.warn = logGen(console.warn);
56
- log.detailed = logGen(console.debug);
57
- log.error = logGen(console.error);
58
-
59
- log.setEnabled = e => { options.enabled = e; };
60
-
61
- return log
62
- }
63
-
64
- function initLog (name, options) {
65
- const log = clog(name, options);
66
- log.sublog = (sublogName, sublogOptions) => initLog(name + '.' + sublogName, Object.assign(Object.create(options), sublogOptions));
67
- return log
68
- }
69
-
70
- export { initLog };
1
+ const e={black:"",red:"",green:"",yellow:"",blue:"",magenta:"",cyan:"",white:""};function o(n,r){const t=function(o,n={}){let r=o+": ",t=null;if(n.color)if(n.isBrowser)r="%c"+r,t=`color: ${n.color}`;else{const o=e[n.color];o&&(r=o+r)}const l=(e,o)=>e&&e.length>o?e.substring(0,o)+"...":e,c=(e,o)=>"string"==typeof o?e[0].includes(o):o.test(e[0]);function s(e){return function(){if(void 0===n.enabled||!!n.enabled||e===console.error){let o=Array.from(arguments);t&&o.unshift(t),o.unshift(r),n.truncateObjects&&e!==console.error&&(o=o.map((e=>"object"==typeof e?l(JSON.stringify(e),parseInt(n.truncateObjects)||100):e))),(!n.logFilter||c(o,n.logFilter)||e===console.error)&&e.apply(console,o)}}}const i=s(console.log);return i.info=i,i.warn=s(console.warn),i.detailed=s(console.debug),i.error=s(console.error),i.setEnabled=e=>{n.enabled=e},i}(n,r);return t.sublog=(e,t)=>o(n+"."+e,Object.assign(Object.create(r),t)),t}export{o as initLog};
@@ -1,30 +1 @@
1
- const initHistoryManager = ({ bus }) => {
2
- const stepStack = [];
3
- bus.on('history/register', ({ viewId, event, params = {} }) => {
4
- stepStack.push({ viewId, event, params });
5
- });
6
- bus.on('history/stepBack', () => {
7
- const layersToHide = [];
8
- const current = stepStack.pop();
9
-
10
- if (!current) return
11
-
12
- layersToHide.push(current.viewId);
13
- for (let i = stepStack.length - 1; i >= 0; --i) {
14
- if (stepStack[i].event === current.event) {
15
- const same = stepStack.pop();
16
- layersToHide.push(same.viewId);
17
- } else {
18
- break
19
- }
20
- }
21
- bus.send('layers/hideMultiple', layersToHide);
22
- const { event, params } = stepStack.pop();
23
- bus.send(event, params);
24
- });
25
- bus.on('history/clean', () => {
26
- stepStack.length = 0;
27
- });
28
- };
29
-
30
- export { initHistoryManager };
1
+ const e=({bus:e})=>{const t=[];e.on("history/register",(({viewId:e,event:s,params:n={}})=>{t.push({viewId:e,event:s,params:n})})),e.on("history/stepBack",(()=>{const s=[],n=t.pop();if(!n)return;s.push(n.viewId);for(let e=t.length-1;e>=0&&t[e].event===n.event;--e){const e=t.pop();s.push(e.viewId)}e.send("layers/hideMultiple",s);const{event:o,params:p}=t.pop();e.send(o,p)})),e.on("history/clean",(()=>{t.length=0}))};export{e as initHistoryManager};
@@ -1,23 +1 @@
1
- import { path, identity, prop } from 'ramda';
2
-
3
- function findBoundsOfWaypoints (waypoints) {
4
- const latitudes = waypoints.map(path(['position', 'lat'])).filter(identity);
5
- const longitudes = waypoints.map(path(['position', 'lng'])).filter(identity);
6
- return findBounds(latitudes, longitudes)
7
- }
8
-
9
- function findBoundsOfCoordinates (coordinates) {
10
- const latitudes = coordinates.map(prop(0)).filter(identity);
11
- const longitudes = coordinates.map(prop(1)).filter(identity);
12
- return findBounds(latitudes, longitudes)
13
- }
14
-
15
- function findBounds (latitudes, longitudes) {
16
- const n = Math.max(...latitudes);
17
- const s = Math.min(...latitudes);
18
- const e = Math.max(...longitudes);
19
- const w = Math.min(...longitudes);
20
- return { n, s, e, w }
21
- }
22
-
23
- export { findBoundsOfCoordinates, findBoundsOfWaypoints };
1
+ import{path as t,identity as n,prop as i}from"ramda";function r(i){return m(i.map(t(["position","lat"])).filter(n),i.map(t(["position","lng"])).filter(n))}function a(t){return m(t.map(i(0)).filter(n),t.map(i(1)).filter(n))}function m(t,n){return{n:Math.max(...t),s:Math.min(...t),e:Math.max(...n),w:Math.min(...n)}}export{a as findBoundsOfCoordinates,r as findBoundsOfWaypoints};
@@ -1,17 +1 @@
1
- import * as R from 'ramda';
2
-
3
- const buildStructuresLookup = (structures) => {
4
- const floors = R.mergeAll(structures.map(R.prop('levels')));
5
- const floorIdToFloor = floorId => floors[floorId];
6
- const floorIdToOrdinal = R.pipe(floorIdToFloor, R.prop('ordinal'));
7
- const floorIdToStructure = floorId => R.find(R.path(['levels', floorId]), structures);
8
- const floorIdToStructureId = R.pipe(floorIdToStructure, R.prop('id'));
9
- return {
10
- floorIdToOrdinal,
11
- floorIdToFloor,
12
- floorIdToStructureId,
13
- floorIdToStructure
14
- }
15
- };
16
-
17
- export { buildStructuresLookup };
1
+ import*as o from"ramda";const r=r=>{const p=o.mergeAll(r.map(o.prop("levels"))),l=o=>p[o],e=p=>o.find(o.path(["levels",p]),r);return{floorIdToOrdinal:o.pipe(l,o.prop("ordinal")),floorIdToFloor:l,floorIdToStructureId:o.pipe(e,o.prop("id")),floorIdToStructure:e}};export{r as buildStructuresLookup};
@@ -1,61 +1 @@
1
- /**
2
- * Follows a localization scheme of checking for named values with locales appended,
3
- * and checking more generally if values not found.
4
- *
5
- * For example, calling getLocalized("foo", "es-MX", "bar") would check the following keys in this order:
6
- * "foo-es-MX"
7
- * "foo-es"
8
- * "foo"
9
- *
10
- * As soon as a value is found, it is returned, else the checks continue. If no value is found from any of these,
11
- * the def value is returned. (If def is undefined, the undefined is returned)
12
- *
13
- * @param {object} config the configuration to inspect
14
- * @param {string} name root key name to look up
15
- * @param {string} lang language code
16
- * @param {any} def default value to return if no value is found through localized checks
17
- */
18
- function getLocalized (config, name, lang, def) {
19
- let key = name;
20
- if (lang)
21
- key += '-' + lang;
22
-
23
- const value = config[key];
24
-
25
- if (value)
26
- return value
27
-
28
- if (lang) {
29
- if (lang.indexOf('-') > 0) // we have sublocales, so strip last one and try again
30
- return getLocalized(config, name, lang.substring(0, lang.indexOf('-')), def)
31
- else // no sublanguage, so next is try the name on its own
32
- return getLocalized(config, name, null, def)
33
- }
34
-
35
- // we are here means we just checked the name (no lang arg) and there was no value found, so
36
- // we simply return the def
37
- return def
38
- }
39
-
40
- // A debug property is considered "true" if:
41
- // The key is defined as a property within the debug object AND
42
- // the value of that key is not "no" or "false" or false (boolean) or undefined or null
43
- // Any other value will be considered true - even 0 and ""
44
- function debugIsTrue (app, key) {
45
- if (!app.config.debug)
46
- return false
47
-
48
- let value = app.config.debug[key];
49
-
50
- if (value === undefined || value === null || value === false)
51
- return false
52
-
53
- if (value === true)
54
- return true
55
-
56
- value = value.toLowerCase ? value.toLowerCase() : value; // lower case it if possible
57
-
58
- return value !== 'no' && value !== 'false'
59
- }
60
-
61
- export { debugIsTrue, getLocalized };
1
+ function n(t,e,o,r){let u=e;o&&(u+="-"+o);const i=t[u];return i||(o?o.indexOf("-")>0?n(t,e,o.substring(0,o.indexOf("-")),r):n(t,e,null,r):r)}function t(n,t){if(!n.config.debug)return!1;let e=n.config.debug[t];return null!=e&&!1!==e&&(!0===e||(e=e.toLowerCase?e.toLowerCase():e,"no"!==e&&"false"!==e))}let e;try{e=Function("return this")()}catch(n){e=window}export{t as debugIsTrue,n as getLocalized,e as global};
@@ -1,46 +1 @@
1
- const $ = (expr, container) => typeof expr === 'string' ? (container || document).querySelector(expr) : expr || null;
2
- const $$ = (expr, container) => Array.prototype.slice.call((container || document).querySelectorAll(expr));
3
-
4
- // adds an element (default: div) defined in eConf to parent element (default: body) - returns element
5
- // i.e.
6
- // const newDiv = ad() = creates a new div, adds to end of page and returns it
7
- // const newDiv = ad({klass: "foo"}) = same as above with class of "foo"
8
- // const newImg = ad({tag: "img", src: "test.png"}, parent: "#top") = image at end of top
9
- function ad (eConf, parent) {
10
- const c = eConf || {};
11
- parent = parent || document.body;
12
-
13
- let tag = 'div';
14
-
15
- if (c.tag)
16
- tag = c.tag;
17
-
18
- const node = document.createElement(tag);
19
-
20
- for (const cc in c) {
21
- if (c[cc] != null) // null or undefined
22
- if (cc === 'klass')
23
- node.setAttribute('class', c.klass);
24
- else if (cc === 'tag')
25
- ; // already swallowed this
26
- else if (cc === 'styles')
27
- setStyles(node, c.styles);
28
- else if (cc === 'text')
29
- node.textContent = c.text;
30
- else if (cc === 'html')
31
- node.innerHTML = c.html;
32
- else
33
- node.setAttribute(cc, c[cc]);
34
- }
35
-
36
- parent.appendChild(node);
37
-
38
- return node
39
- }
40
-
41
- const setStyles = (node, styles) => {
42
- for (const style in styles)
43
- node.style[style] = styles[style];
44
- };
45
-
46
- export { $, $$, ad, setStyles };
1
+ const t=(t,e)=>"string"==typeof t?(e||document).querySelector(t):t||null,e=(t,e)=>Array.prototype.slice.call((e||document).querySelectorAll(t));function n(t,e){const n=t||{};e=e||document.body;let o="div";n.tag&&(o=n.tag);const s=document.createElement(o);for(const t in n)null!=n[t]&&("klass"===t?s.setAttribute("class",n.klass):"tag"===t||("styles"===t?l(s,n.styles):"text"===t?s.textContent=n.text:"html"===t?s.innerHTML=n.html:s.setAttribute(t,n[t])));return e.appendChild(s),s}const l=(t,e)=>{for(const n in e)t.style[n]=e[n]};export{t as $,e as $$,n as ad,l as setStyles};
@@ -1,50 +1 @@
1
- import Zousan from 'zousan';
2
-
3
- // Ensures only a single asynchronous function wrapped in this function runs at a time.
4
- let lastFn = null;
5
- const singleFile = fn => function () {
6
- if (lastFn)
7
- lastFn = lastFn.then(() => fn.apply(null, arguments));
8
- else
9
- lastFn = fn.apply(null, arguments);
10
-
11
- return lastFn
12
- };
13
-
14
- // call a function after a delay with an optional value specified. Can be used
15
- // as HOF or directly as a promise. Cool eh? This allows you to use it in a
16
- // function pipeline, or directly in an await delay, etc.
17
- //
18
- // Usage:
19
- //
20
- // await delay(500) // waits for 500ms - returns undefined
21
- // await delay(500)(123) // waits for 500ms - returns 123
22
- //
23
- // f1().then(delay(800)).then(f2) // delay 800ms, pass result on to f2
24
- // R.pipe(f1, delay(800), f2) // same as above
25
- const delay = ms => {
26
- const r = v => new Zousan(y => setTimeout(y, ms, v));
27
- const z2 = new Zousan(y => setTimeout(y, ms));
28
- r.then = z2.then.bind(z2);
29
- return r
30
- };
31
-
32
- /**
33
- * returns a copy of an object with any (top-level) properties that do not
34
- * return truthy from the specified function stripped. So it works just like
35
- * the Array.filter, but for objects.
36
- * @param {function} fn A filter predicate - will be passed (key,object)
37
- * @param {object} ob The object to filter (top level properties only)
38
- * @returns (object) The newly created object with filtered properties
39
- */
40
- function filterOb (fn, ob) {
41
- const ret = { };
42
- Object.keys(ob)
43
- .forEach(key => {
44
- if (fn(key, ob[key]))
45
- ret[key] = ob[key];
46
- });
47
- return ret
48
- }
49
-
50
- export { delay, filterOb, singleFile };
1
+ import n from"zousan";let t=null;const e=n=>function(){return t=t?t.then((()=>n.apply(null,arguments))):n.apply(null,arguments),t},o=t=>{const e=e=>new n((n=>setTimeout(n,t,e))),o=new n((n=>setTimeout(n,t)));return e.then=o.then.bind(o),e};function u(n,t){const e={};return Object.keys(t).forEach((o=>{n(o,t[o])&&(e[o]=t[o])})),e}export{o as delay,u as filterOb,e as singleFile};
@@ -1,35 +1 @@
1
- /*
2
- This utility module contains a set of functions dealing with "Geodesy" - measurements of
3
- the earth, its surface and related geometry.
4
-
5
- For a more cohesive set of functions, see https://github.com/chrisveness/geodesy
6
- */
7
-
8
- // degrees to radians
9
- const toRadians = d => d * Math.PI / 180;
10
-
11
- /**
12
- * Haversine formula for finding distance between two lat/lng points.
13
- * from https://www.movable-type.co.uk/scripts/latlong.html
14
- * @param {float} lat1 latitutde of point 1
15
- * @param {float} lng1 longitude of point 1
16
- * @param {float} lat2 latitutde of point 2
17
- * @param {float} lng2 longitude of point 2
18
- * @returns number (in meters) between p1 and p2
19
- */
20
- function distance (lat1, lng1, lat2, lng2) {
21
- const R = 6371000; // approx. earth radius (meters)
22
- const φ1 = toRadians(lat1);
23
- const φ2 = toRadians(lat2);
24
- const Δφ = toRadians(lat2 - lat1);
25
- const Δλ = toRadians(lng2 - lng1);
26
-
27
- const a = Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +
28
- Math.cos(φ1) * Math.cos(φ2) *
29
- Math.sin(Δλ / 2) * Math.sin(Δλ / 2);
30
- const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
31
-
32
- return R * c
33
- }
34
-
35
- export { distance, toRadians };
1
+ const t=t=>t*Math.PI/180;function a(a,h,n,s){const M=t(a),o=t(n),c=t(n-a),i=t(s-h),r=Math.sin(c/2)*Math.sin(c/2)+Math.cos(M)*Math.cos(o)*Math.sin(i/2)*Math.sin(i/2);return 6371e3*(2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r)))}export{a as distance,t as toRadians};