atriusmaps-node-sdk 3.3.31 → 3.3.225

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 (122) hide show
  1. package/README.md +19 -1
  2. package/dist/cjs/_virtual/_empty_module_placeholder.js +2 -2
  3. package/dist/cjs/deploy/prepareSDKConfig.js +152 -2
  4. package/dist/cjs/nodesdk/nodeEntry.js +109 -0
  5. package/dist/cjs/package.json.js +190 -7
  6. package/dist/cjs/plugins/clientAPI/src/clientAPI.js +11 -2
  7. package/dist/cjs/plugins/dynamicPois/src/dynamicPois.js +218 -21
  8. package/dist/cjs/plugins/poiDataManager/src/poiDataManager.js +292 -21
  9. package/dist/cjs/plugins/sdkServer/src/sdkHeadless.js +99 -20
  10. package/dist/cjs/plugins/sdkServer/src/sdkServer.js +219 -2
  11. package/dist/cjs/plugins/sdkServer/src/util.js +16 -3
  12. package/dist/cjs/plugins/searchService/src/poiSearch.js +57 -19
  13. package/dist/cjs/plugins/searchService/src/searchService.js +246 -21
  14. package/dist/cjs/plugins/searchService/src/searchTypeahead.js +60 -3
  15. package/dist/cjs/plugins/searchService/src/utils.js +23 -4
  16. package/dist/cjs/plugins/venueDataLoader/src/venueDataLoader.js +472 -23
  17. package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +191 -23
  18. package/dist/cjs/plugins/wayfinder/src/findRoute.js +147 -19
  19. package/dist/cjs/plugins/wayfinder/src/minPriorityQueue.js +88 -2
  20. package/dist/cjs/plugins/wayfinder/src/navGraph.js +393 -5
  21. package/dist/cjs/plugins/wayfinder/src/navGraphDebug.js +110 -20
  22. package/dist/cjs/plugins/wayfinder/src/segmentBadges.js +28 -2
  23. package/dist/cjs/plugins/wayfinder/src/segmentBuilder.js +257 -19
  24. package/dist/cjs/plugins/wayfinder/src/segmentCategories.js +29 -2
  25. package/dist/cjs/plugins/wayfinder/src/stepBuilder.js +238 -3
  26. package/dist/cjs/plugins/wayfinder/src/wayfinder.js +597 -22
  27. package/dist/cjs/src/app.js +191 -25
  28. package/dist/cjs/src/configs/postproc-mol-url-parms.js +58 -2
  29. package/dist/cjs/src/configs/postproc-stateTracking.js +53 -19
  30. package/dist/cjs/src/controller.js +43 -4
  31. package/dist/cjs/src/debugTools.js +128 -23
  32. package/dist/cjs/src/env.js +17 -2
  33. package/dist/cjs/src/extModules/bustle.js +128 -4
  34. package/dist/cjs/src/extModules/flexapi/src/help.js +23 -4
  35. package/dist/cjs/src/extModules/flexapi/src/index.js +65 -4
  36. package/dist/cjs/src/extModules/flexapi/src/validate.js +133 -5
  37. package/dist/cjs/src/extModules/geohasher.js +90 -3
  38. package/dist/cjs/src/extModules/log.js +69 -2
  39. package/dist/cjs/src/historyManager.js +29 -2
  40. package/dist/cjs/src/utils/bounds.js +22 -4
  41. package/dist/cjs/src/utils/buildStructureLookup.js +31 -19
  42. package/dist/cjs/src/utils/configUtils.js +71 -3
  43. package/dist/cjs/src/utils/dom.js +48 -5
  44. package/dist/cjs/src/utils/funcs.js +30 -7
  45. package/dist/cjs/src/utils/geodesy.js +35 -3
  46. package/dist/cjs/src/utils/geom.js +212 -25
  47. package/dist/cjs/src/utils/i18n.js +69 -5
  48. package/dist/cjs/src/utils/observable.js +73 -2
  49. package/dist/cjs/src/utils/rand.js +82 -3
  50. package/dist/nodesdk/nodeEntry.js +1 -0
  51. package/dist/package.json.js +1 -0
  52. package/dist/plugins/dynamicPois/src/dynamicPois.js +1 -0
  53. package/dist/plugins/sdkServer/src/sdkHeadless.js +1 -0
  54. package/{lib → dist}/plugins/sdkServer/src/sdkServer.js +1 -1
  55. package/dist/plugins/searchService/src/poiSearch.js +1 -0
  56. package/dist/plugins/searchService/src/searchService.js +1 -0
  57. package/dist/plugins/venueDataLoader/src/venueDataLoader.js +1 -0
  58. package/dist/plugins/venueDataLoader/src/venueLoadingUtils.js +1 -0
  59. package/dist/plugins/wayfinder/src/navGraph.js +1 -0
  60. package/{lib → dist}/plugins/wayfinder/src/segmentBuilder.js +1 -1
  61. package/dist/plugins/wayfinder/src/stepBuilder.js +1 -0
  62. package/dist/plugins/wayfinder/src/wayfinder.js +1 -0
  63. package/dist/src/app.js +1 -0
  64. package/dist/src/configs/postproc-mol-url-parms.js +1 -0
  65. package/{lib → dist}/src/configs/sdkHeadless.json.js +1 -1
  66. package/dist/src/extModules/bustle.js +1 -0
  67. package/dist/src/extModules/log.js +1 -0
  68. package/dist/src/utils/funcs.js +1 -0
  69. package/dist/src/utils/geom.js +1 -0
  70. package/dist/src/utils/i18n.js +1 -0
  71. package/package.json +17 -9
  72. package/config/rollup.config.cjs.js +0 -31
  73. package/dist/cjs/deploy/nodeEntry.js +0 -15
  74. package/dist/cjs/src/auth/Auth.js +0 -23
  75. package/lib/deploy/nodeEntry.js +0 -1
  76. package/lib/package.json.js +0 -1
  77. package/lib/plugins/dynamicPois/src/dynamicPois.js +0 -1
  78. package/lib/plugins/sdkServer/src/sdkHeadless.js +0 -1
  79. package/lib/plugins/searchService/src/poiSearch.js +0 -1
  80. package/lib/plugins/searchService/src/searchService.js +0 -1
  81. package/lib/plugins/venueDataLoader/src/venueDataLoader.js +0 -1
  82. package/lib/plugins/venueDataLoader/src/venueLoadingUtils.js +0 -1
  83. package/lib/plugins/wayfinder/src/navGraph.js +0 -1
  84. package/lib/plugins/wayfinder/src/stepBuilder.js +0 -1
  85. package/lib/plugins/wayfinder/src/wayfinder.js +0 -1
  86. package/lib/src/app.js +0 -1
  87. package/lib/src/auth/Auth.js +0 -1
  88. package/lib/src/configs/postproc-mol-url-parms.js +0 -1
  89. package/lib/src/configs/sdkHeadless.json +0 -28
  90. package/lib/src/extModules/bustle.js +0 -1
  91. package/lib/src/extModules/log.js +0 -1
  92. package/lib/src/utils/funcs.js +0 -1
  93. package/lib/src/utils/geom.js +0 -1
  94. package/lib/src/utils/i18n.js +0 -1
  95. /package/{lib → dist}/_virtual/_empty_module_placeholder.js +0 -0
  96. /package/{lib → dist}/deploy/prepareSDKConfig.js +0 -0
  97. /package/{lib → dist}/plugins/clientAPI/src/clientAPI.js +0 -0
  98. /package/{lib → dist}/plugins/poiDataManager/src/poiDataManager.js +0 -0
  99. /package/{lib → dist}/plugins/sdkServer/src/util.js +0 -0
  100. /package/{lib → dist}/plugins/searchService/src/searchTypeahead.js +0 -0
  101. /package/{lib → dist}/plugins/searchService/src/utils.js +0 -0
  102. /package/{lib → dist}/plugins/wayfinder/src/findRoute.js +0 -0
  103. /package/{lib → dist}/plugins/wayfinder/src/minPriorityQueue.js +0 -0
  104. /package/{lib → dist}/plugins/wayfinder/src/navGraphDebug.js +0 -0
  105. /package/{lib → dist}/plugins/wayfinder/src/segmentBadges.js +0 -0
  106. /package/{lib → dist}/plugins/wayfinder/src/segmentCategories.js +0 -0
  107. /package/{lib → dist}/src/configs/postproc-stateTracking.js +0 -0
  108. /package/{lib → dist}/src/controller.js +0 -0
  109. /package/{lib → dist}/src/debugTools.js +0 -0
  110. /package/{lib → dist}/src/env.js +0 -0
  111. /package/{lib → dist}/src/extModules/flexapi/src/help.js +0 -0
  112. /package/{lib → dist}/src/extModules/flexapi/src/index.js +0 -0
  113. /package/{lib → dist}/src/extModules/flexapi/src/validate.js +0 -0
  114. /package/{lib → dist}/src/extModules/geohasher.js +0 -0
  115. /package/{lib → dist}/src/historyManager.js +0 -0
  116. /package/{lib → dist}/src/utils/bounds.js +0 -0
  117. /package/{lib → dist}/src/utils/buildStructureLookup.js +0 -0
  118. /package/{lib → dist}/src/utils/configUtils.js +0 -0
  119. /package/{lib → dist}/src/utils/dom.js +0 -0
  120. /package/{lib → dist}/src/utils/geodesy.js +0 -0
  121. /package/{lib → dist}/src/utils/observable.js +0 -0
  122. /package/{lib → dist}/src/utils/rand.js +0 -0
@@ -2,12 +2,136 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var a = require('zousan');
5
+ var Zousan = require('zousan');
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
- var a__default = /*#__PURE__*/_interopDefaultLegacy(a);
9
+ var Zousan__default = /*#__PURE__*/_interopDefaultLegacy(Zousan);
10
10
 
11
- const n=(o,n)=>o.splice(n,1)[0],t=(o,t)=>{let r=0;do{r=o.indexOf(t,r),r>=0&&n(o,r);}while(r>=0);return o};function r(n){const r=n.log?n.log.sublog?n.log.sublog("bustle",{color:"pink"}):n.log:console,e={},s={};function c(o,n){e[o]&&t(e[o],n);}function u(o,n){s[o]&&t(s[o],n);}function l(t,c){return n.trace&&(c||(c={}),c._stack=Error().stack),n.showEvents&&("function"==typeof n.showEvents?n.showEvents(t,c)&&r.info("send with",t," and ",c):r.info("send with",t," and ",c)),new a__default["default"]((u=>a__default["default"].soon(((t,c,u)=>()=>{const l=e[t],f=s[t],i=[];if(l)for(const t of l)try{i.push(t(c));}catch(t){n.reportAllErrors&&r.error(t),n.rejectOnError?i.push(a__default["default"].reject(t)):i.push(t);}const h=a__default["default"].all(i);if(f)for(const o of f)try{o(c,h);}catch(o){n.reportAllErrors&&r.error(o);}u(h);})(t,c,u))))}return {get:(n,t)=>l(n,t).then((t=>1!==t.length?a__default["default"].reject(`${n} event did not return a single result, but ${t.length} results.`):t[0])),moff:u,monitor:function(o,n){return s[o]||(s[o]=[]),s[o].push(n),()=>u(o,n)},off:c,on:function(o,n){return e[o]||(e[o]=[]),e[o].push(n),()=>c(o,n)},send:l}}
11
+ /**
12
+ * Bustle is a highly performant event bus that offers event order guarantees.
13
+ */
12
14
 
13
- exports.create = r;
15
+ // Remove element from array at index specified and return the removed element.
16
+ // Source array will then have item removed.
17
+ const arRmAt = (ar, index) => ar.splice(index, 1)[0]; // oh yah, thats intuitive!
18
+
19
+ // Removes the value from the array if it exists. The array is then returned
20
+ const arRm = (ar, value) => {
21
+ let i = 0;
22
+ do {
23
+ i = ar.indexOf(value, i);
24
+ if (i >= 0)
25
+ arRmAt(ar, i);
26
+ } while (i >= 0)
27
+ return ar
28
+ };
29
+
30
+ // This creates a bus instance. When used as a Singleton, you will only call this once
31
+ // for the life of your app. To isolate events (perhaps for performance or security
32
+ // reasons) you can create multple bus instances.
33
+ function create (opts = { }) {
34
+ // If a log option is defined, use it - and if it supports sublogs, instantiate that. If all else fails, use console
35
+ const log = opts.log ? (opts.log.sublog ? opts.log.sublog('bustle', { color: 'pink' }) : opts.log) : console;
36
+
37
+ const ons = { }; // holds your listeners
38
+ const mons = { }; // holds your monitors
39
+
40
+ // subscribes to an event. Your listener will always be called
41
+ // with a single argument. I am considering adding another way
42
+ // to subscribe to events by observing an event and then
43
+ // subscribing to that observer.
44
+ function on (ev, fn) {
45
+ if (!ons[ev])
46
+ ons[ev] = [];
47
+
48
+ ons[ev].push(fn);
49
+
50
+ return () => off(ev, fn)
51
+ }
52
+
53
+ // Similar to "on" but is always called after all normal "on" listeners,
54
+ // and any values returned by a monitor call are ignored (not added to the
55
+ // response). Also, any calls to monitor listeners contains both the message
56
+ // object AND a promise containing the response from the normal listeners.
57
+ function monitor (ev, fn) {
58
+ if (!mons[ev])
59
+ mons[ev] = [];
60
+
61
+ mons[ev].push(fn);
62
+
63
+ return () => moff(ev, fn)
64
+ }
65
+
66
+ function off (ev, fn) {
67
+ if (!ons[ev])
68
+ return
69
+ arRm(ons[ev], fn);
70
+ }
71
+
72
+ function moff (ev, fn) {
73
+ if (!mons[ev])
74
+ return
75
+ arRm(mons[ev], fn);
76
+ }
77
+
78
+ const serve = (ev, ob, done) => () => {
79
+ // const myOns = (ons[ev] || []).concat(ons["*"] ? ons["*"] : [])
80
+ const myOns = ons[ev];
81
+ const myMons = mons[ev];
82
+ const res = [];
83
+ if (myOns) {
84
+ for (const listener of myOns) {
85
+ try {
86
+ res.push(listener(ob));
87
+ } catch (err) {
88
+ if (opts.reportAllErrors)
89
+ log.error(err);
90
+ if (opts.rejectOnError)
91
+ res.push(Zousan__default["default"].reject(err)); // will cause the Zousan.all to reject the send
92
+ else
93
+ res.push(err);
94
+ }
95
+ }
96
+ }
97
+
98
+ const results = Zousan__default["default"].all(res);
99
+
100
+ if (myMons) {
101
+ for (const listener of myMons) {
102
+ try {
103
+ listener(ob, results);
104
+ } catch (err) {
105
+ if (opts.reportAllErrors)
106
+ log.error(err);
107
+ }
108
+ }
109
+ }
110
+
111
+ done(results);
112
+ };
113
+
114
+ // Used when there is a single listener that provides information or a service,
115
+ // a get sends a message to that listener, ensures it gets exactly 1 result,
116
+ // and returns that result.
117
+ const get = (ev, ob) =>
118
+ send(ev, ob).then(res => res.length !== 1
119
+ ? Zousan__default["default"].reject(`${ev} event did not return a single result, but ${res.length} results.`)
120
+ : res[0]);
121
+
122
+ function send (ev, ob) {
123
+ if (opts.trace) { if (!ob) ob = { }; ob._stack = Error().stack; }
124
+ if (opts.showEvents) {
125
+ if (typeof opts.showEvents === 'function') {
126
+ if (opts.showEvents(ev, ob))
127
+ log.info('send with', ev, ' and ', ob);
128
+ } else
129
+ log.info('send with', ev, ' and ', ob);
130
+ }
131
+ return new Zousan__default["default"](resolve => Zousan__default["default"].soon(serve(ev, ob, resolve)))
132
+ }
133
+
134
+ return { get, moff, monitor, off, on, send }
135
+ }
136
+
137
+ exports.create = create;
@@ -2,8 +2,27 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function n(n,o){for(;o.length<n;)o+=" ";return o}const o=()=>n(18,"Command")+"Arguments\n"+n(18,"----------------")+"----------------\n",m=o=>n(18,o.command)+(o.args?o.args.map((n=>`${n.name} {${n.type}} ${n.optional?" (optional)":" (required)"}`)).join(", "):""),r=(n,o)=>n.command>o.command?1:-1,a=n=>n.sort(r).reduce(((n,o)=>`${n}${m(o)}\n`),o());
5
+ function pad (total, str) {
6
+ while (str.length < total) { str += ' '; }
7
+ return str
8
+ }
6
9
 
7
- exports.getHelp = m;
8
- exports.getHelpHeader = o;
9
- exports.getHelpList = a;
10
+ const getHelpHeader = () => pad(18, 'Command') + 'Arguments\n' + pad(18, '----------------') + '----------------\n';
11
+
12
+ /**
13
+ * Returns help on the passed command signature
14
+ */
15
+ const getHelp = sig => pad(18, sig.command) +
16
+ (sig.args ? sig.args.map(argob => `${argob.name} {${argob.type}} ${argob.optional ? ' (optional)' : ' (required)'}`).join(', ') : '');
17
+
18
+ const sigsort = (s1, s2) => s1.command > s2.command ? 1 : -1;
19
+ /**
20
+ * Returns help on the passed command signatures
21
+ */
22
+ const getHelpList = sigList => {
23
+ return sigList.sort(sigsort).reduce((ret, sig) => `${ret}${getHelp(sig)}\n`, getHelpHeader())
24
+ };
25
+
26
+ exports.getHelp = getHelp;
27
+ exports.getHelpHeader = getHelpHeader;
28
+ exports.getHelpList = getHelpList;
@@ -1,13 +1,74 @@
1
1
  'use strict';
2
2
 
3
- var a$1 = require('zousan');
3
+ var Zousan = require('zousan');
4
4
  var help = require('./help.js');
5
5
  var validate = require('./validate.js');
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
- var a__default = /*#__PURE__*/_interopDefaultLegacy(a$1);
9
+ var Zousan__default = /*#__PURE__*/_interopDefaultLegacy(Zousan);
10
10
 
11
- const i=/^[-_.0-9a-zA-Z]+$/,s=JSON.stringify;function a(){const a=[],c=()=>a.map((n=>n.sig)),d={},f={customTypes:d,commandDefsList:a};function u(n,o){const r=n.command;if(void 0===r)throw Error(`Invalid command specification in registerCommand: ${s(n)}. No 'command' property specified.`);if(!i.test(r)){throw Error(`Invalid command specification in registerCommand: ${s(n)}. Command name '${r}' not valid.`)}return a.push({sig:n,fn:o}),p}function p(i){return new a__default["default"](((n,a)=>{if(!i)return a(new Error(`No command specified in command object ${s(i)}`));const c=f.commandDefsList.filter((n=>n.sig.command===i.command));if(0===c.length)return a(new Error(`No API command '${i.command}' found.\n${help.getHelpList(f.commandDefsList.map((n=>n.sig)))}`));const d=validate.getSigMatch(f,i);if(!d)return 1===c.length?a(new Error(`Required fields not present in ${s(i)}\n${help.getHelpHeader()}${help.getHelp(c[0].sig)}`)):a(new Error(`Command arguments did not match any required signatures: ${s(i)}\n${help.getHelpList(f.commandDefsList.map((n=>n.sig)))}`));try{validate.validate(f,d.sig,i);}catch(n){return a(n)}n(d.fn(i));}))}return u({command:"help",args:[]},(()=>help.getHelpList(c()))),u({command:"getCommandJSON",args:[]},(()=>({commands:c(),customTypes:d}))),{registerCommand:u,registerCustomType:function(n,o){d[n]=o;},execute:p}}
11
+ const COMMAND_VALIDATION_REGEX = /^[-_.0-9a-zA-Z]+$/;
12
+ const JS = JSON.stringify;
12
13
 
13
- module.exports = a;
14
+ function create () {
15
+ const commandDefsList = [];
16
+ const commands = () => commandDefsList.map(cob => cob.sig);
17
+ const customTypes = { };
18
+ const library = { customTypes, commandDefsList };
19
+ const getCommandJSON = () => ({ commands: commands(), customTypes });
20
+
21
+ function registerCommand (sig, fn) {
22
+ const command = sig.command;
23
+ if (command === undefined) { throw Error(`Invalid command specification in registerCommand: ${JS(sig)}. No 'command' property specified.`) }
24
+
25
+ if (!COMMAND_VALIDATION_REGEX.test(command)) {
26
+ const er = Error(`Invalid command specification in registerCommand: ${JS(sig)}. Command name '${command}' not valid.`);
27
+ throw er
28
+ }
29
+
30
+ commandDefsList.push({ sig, fn });
31
+
32
+ return execute
33
+ }
34
+
35
+ function registerCustomType (name, spec) {
36
+ customTypes[name] = spec;
37
+ }
38
+
39
+ function execute (cob) {
40
+ return new Zousan__default["default"]((resolve, reject) => {
41
+ if (!cob) { return reject(new Error(`No command specified in command object ${JS(cob)}`)) }
42
+
43
+ const commandMatches = library.commandDefsList
44
+ .filter(com => com.sig.command === cob.command);
45
+
46
+ if (commandMatches.length === 0) { return reject(new Error(`No API command '${cob.command}' found.\n${help.getHelpList(library.commandDefsList.map(o => o.sig))}`)) }
47
+
48
+ const sigMatch = validate.getSigMatch(library, cob);
49
+
50
+ if (!sigMatch) {
51
+ if (commandMatches.length === 1) { return reject(new Error(`Required fields not present in ${JS(cob)}\n${help.getHelpHeader()}${help.getHelp(commandMatches[0].sig)}`)) } else { return reject(new Error(`Command arguments did not match any required signatures: ${JS(cob)}\n${help.getHelpList(library.commandDefsList.map(o => o.sig))}`)) }
52
+ }
53
+
54
+ // console.log(`command ${JS(cob)} is ${JS(sigMatch.sig)}`)
55
+
56
+ try {
57
+ validate.validate(library, sigMatch.sig, cob); // this will throw an error if invalid
58
+ } catch (e) { return reject(e) }
59
+
60
+ resolve(sigMatch.fn(cob));
61
+ })
62
+ }
63
+
64
+ registerCommand({ command: 'help', args: [] }, () => help.getHelpList(commands()));
65
+ registerCommand({ command: 'getCommandJSON', args: [] }, getCommandJSON);
66
+
67
+ return {
68
+ registerCommand,
69
+ registerCustomType,
70
+ execute
71
+ }
72
+ }
73
+
74
+ module.exports = create;
@@ -2,9 +2,137 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- 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)}));}
5
+ // small helper for showing args
6
+ const SQ = '\''; // single quote
7
+ const sqStr = function (str) { return SQ + str + SQ };
6
8
 
7
- exports.checkType = i;
8
- exports.checkTypeList = o;
9
- exports.getSigMatch = r;
10
- exports.validate = e;
9
+ function validate (library, sig, cob) {
10
+ if (sig.args)
11
+ checkTypeList(library.customTypes, sig.args, cob);
12
+ }
13
+
14
+ function getSigMatch (library, cob) {
15
+ const matches = library.commandDefsList
16
+ .filter(cd => (cd.sig.command === cob.command) && matchesArgs(cd.sig, cob));
17
+ if (matches.length > 1) { throw Error('Command matches multiple signatures!') }
18
+ if (matches.length > 0) { return matches[0] }
19
+ return null // no matching signature found
20
+ }
21
+
22
+ // returns true if each of the required arguments in the command
23
+ // spec (c) is defined within the command object (o) - else false
24
+ function matchesArgs (c, o) {
25
+ if (!c.args) { return true } // no args
26
+ return c.args.reduce(function (cs, argOb) {
27
+ return o[argOb.name] !== undefined || argOb.optional ? cs : false
28
+ }, true)
29
+ }
30
+
31
+ function checkMinMax (name, typeSpec, value) {
32
+ if (typeSpec.min !== undefined && value < typeSpec.min) { throw Error('argument ' + sqStr(name) + ' must be at least ' + typeSpec.min + ' but is ' + value) }
33
+ if (typeSpec.max !== undefined && value > typeSpec.max) { throw Error('argument ' + sqStr(name) + ' must be at most ' + typeSpec.max + ' but is ' + value) }
34
+ }
35
+
36
+ /**
37
+ * Checks an argument value against that arguments spec. If there are no violations of the argSpec, true is returned.
38
+ * If there is a violation, an error is thrown.
39
+ * @param {object} customTypes any defined custom types
40
+ * @param {object} typeSpec An type spec object which inclues a type and other constraints if applicable
41
+ * @param {*} value The JSON value to be checked against this spec
42
+ * @return {true|string} returns true if arg is valid, else a string description of the problem
43
+ */
44
+ function checkType (customTypes, typeSpec, value) {
45
+ if (!typeSpec) // if there is no typespec to validate against, any value is ok
46
+ return true
47
+
48
+ const name = typeSpec.name || '';
49
+
50
+ // if type is a reference/custom, grab that type def but allow "optional" override - TODO: consider other overrides (perhaps all but "type"?)
51
+ if (customTypes && customTypes[typeSpec.type])
52
+ typeSpec = Object.assign({}, customTypes[typeSpec.type], typeSpec, { type: customTypes[typeSpec.type].type });
53
+
54
+ if (typeSpec.type === 'integer') {
55
+ if (typeof value === 'string')
56
+ value = parseInt(value, 10);
57
+ if (!Number.isInteger(value))
58
+ throw Error('expected integer argument for argument ' + sqStr(name) + ' but received ' + value)
59
+ checkMinMax(name, typeSpec, value);
60
+ } else
61
+ if (typeSpec.type === 'float') {
62
+ if (typeof value === 'string')
63
+ value = parseFloat(value);
64
+ if (!Number.isFinite(value))
65
+ throw Error('expected float argument for argument ' + sqStr(name) + ' but received \'' + value + '\'')
66
+ checkMinMax(name, typeSpec, value);
67
+ } else
68
+ if (typeSpec.type === 'string') {
69
+ if (typeof value !== 'string')
70
+ throw Error(`argument ${sqStr(name)} must be a string but is not (value: ${value})`)
71
+ if (typeSpec.minLength && value.length < typeSpec.minLength)
72
+ throw Error(`argument ${sqStr(name)} must be a at least ${typeSpec.minLength} characters but is '${value}' (${value.length} chars)`)
73
+ if (typeSpec.maxLength && value.length > typeSpec.maxLength)
74
+ throw Error(`argument ${sqStr(name)} must be a at most ${typeSpec.maxLength} characters but is '${value}' (${value.length} chars)`)
75
+ } else
76
+ if (typeSpec.type === 'boolean') {
77
+ 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) }
78
+ } else
79
+ if (typeSpec.type === 'list') {
80
+ if (!Array.isArray(value))
81
+ throw Error('argument ' + sqStr(name) + ' must be a list but is not. Value = ' + value)
82
+ if (typeSpec.minLength !== undefined && typeSpec.minLength > value.length)
83
+ throw Error('argument ' + sqStr(name) + ' must contain at least ' + typeSpec.minLength + ' items but only contains ' + value.length + ' items')
84
+ if (typeSpec.maxLength !== undefined && typeSpec.maxLength < value.length)
85
+ throw Error('argument ' + sqStr(name) + ' must contain at most ' + typeSpec.maxLength + ' items but contains ' + value.length + ' items')
86
+ if (typeSpec.itemType) {
87
+ const allItemsValid = value.reduce(function (isValid, curItem) {
88
+ try {
89
+ checkType(customTypes, typeSpec.itemType, curItem);
90
+ } catch (e) { return false }
91
+ return isValid
92
+ }, true);
93
+ 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)}`) }
94
+ }
95
+ } else
96
+ if (typeSpec.type === 'object') {
97
+ if (typeof (value) !== 'object' || Array.isArray(value))
98
+ throw Error('argument ' + sqStr(name) + ' must be an object but is not. Value = ' + value)
99
+ try {
100
+ if (typeSpec.props)
101
+ checkTypeList(customTypes, typeSpec.props, value);
102
+ } catch (e) {
103
+ throw Error('Within ' + name + ', ' + e.message)
104
+ }
105
+ } else
106
+ if (typeSpec.type === 'multi') {
107
+ const oneTypeValid = typeSpec.types
108
+ .reduce((isValid, curType) => {
109
+ try {
110
+ checkType(customTypes, curType, value);
111
+ } catch (e) { return isValid }
112
+ return true
113
+ }, false);
114
+ if (!oneTypeValid)
115
+ throw Error(`Argument ${sqStr(name)} can be of several types, but is not valid for any: ${value}`)
116
+ } else
117
+ throw Error('type ' + typeSpec.type + ' is an unknown type')
118
+
119
+ return true
120
+ }
121
+
122
+ /**
123
+ * Given a value and a typelist, ensure the value abides by the typelist
124
+ * @param types custom defined types
125
+ * @param typeList A list of types to check
126
+ * @param args The properties object to check against
127
+ */
128
+ function checkTypeList (customTypes, typeList, args) {
129
+ typeList.forEach(nextType => {
130
+ if (args[nextType.name] !== undefined) { checkType(customTypes, nextType, args[nextType.name]); } else
131
+ if (!nextType.optional) { throw Error('you must include a value for ' + nextType.name) }
132
+ });
133
+ }
134
+
135
+ exports.checkType = checkType;
136
+ exports.checkTypeList = checkTypeList;
137
+ exports.getSigMatch = getSigMatch;
138
+ exports.validate = validate;
@@ -2,7 +2,94 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- 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;
5
+ // Ported from https://github.com/JacksonTian/geohasher
6
+ // to ESM as it was not bundling properly via Rollup as a CJS
6
7
 
7
- exports.calculateAdjacent = d;
8
- exports.encode = v;
8
+ // Geohash library for Javascript
9
+ // (c) 2008 David Troy
10
+ // (c) 2010 Chris Williams
11
+ // (c) 2013 Jackson Tian
12
+ // Distributed under the MIT License
13
+
14
+ const BITS = [16, 8, 4, 2, 1];
15
+
16
+ const BASE32 = '0123456789bcdefghjkmnpqrstuvwxyz';
17
+
18
+ const NEIGHBORS = {
19
+ right: { even: 'bc01fg45238967deuvhjyznpkmstqrwx' },
20
+ left: { even: '238967debc01fg45kmstqrwxuvhjyznp' },
21
+ top: { even: 'p0r21436x8zb9dcf5h7kjnmqesgutwvy' },
22
+ bottom: { even: '14365h7k9dcfesgujnmqp0r2twvyx8zb' }
23
+ };
24
+
25
+ const BORDERS = {
26
+ right: { even: 'bcfguvyz' },
27
+ left: { even: '0145hjnp' },
28
+ top: { even: 'prxz' },
29
+ bottom: { even: '028b' }
30
+ };
31
+
32
+ NEIGHBORS.bottom.odd = NEIGHBORS.left.even;
33
+ NEIGHBORS.top.odd = NEIGHBORS.right.even;
34
+ NEIGHBORS.left.odd = NEIGHBORS.bottom.even;
35
+ NEIGHBORS.right.odd = NEIGHBORS.top.even;
36
+
37
+ BORDERS.bottom.odd = BORDERS.left.even;
38
+ BORDERS.top.odd = BORDERS.right.even;
39
+ BORDERS.left.odd = BORDERS.bottom.even;
40
+ BORDERS.right.odd = BORDERS.top.even;
41
+
42
+ function calculateAdjacent (srcHash, dir) {
43
+ srcHash = srcHash.toLowerCase();
44
+ const lastChr = srcHash.charAt(srcHash.length - 1);
45
+ const type = (srcHash.length % 2) ? 'odd' : 'even';
46
+ let base = srcHash.substring(0, srcHash.length - 1);
47
+ if (BORDERS[dir][type].indexOf(lastChr) !== -1) {
48
+ base = calculateAdjacent(base, dir);
49
+ }
50
+ return base + BASE32[NEIGHBORS[dir][type].indexOf(lastChr)]
51
+ }
52
+
53
+ function encode (latitude, longitude, precision) {
54
+ let isEven = 1;
55
+ const lat = [-90.0, 90.0];
56
+ const lng = [-180.0, 180.0];
57
+ let bit = 0;
58
+ let ch = 0;
59
+ precision = precision || 12;
60
+
61
+ let geohash = '';
62
+ while (geohash.length < precision) {
63
+ let mid;
64
+ if (isEven) {
65
+ mid = (lng[0] + lng[1]) / 2;
66
+ if (longitude > mid) {
67
+ ch |= BITS[bit];
68
+ lng[0] = mid;
69
+ } else {
70
+ lng[1] = mid;
71
+ }
72
+ } else {
73
+ mid = (lat[0] + lat[1]) / 2;
74
+ if (latitude > mid) {
75
+ ch |= BITS[bit];
76
+ lat[0] = mid;
77
+ } else {
78
+ lat[1] = mid;
79
+ }
80
+ }
81
+
82
+ isEven = !isEven;
83
+ if (bit < 4) {
84
+ bit++;
85
+ } else {
86
+ geohash += BASE32[ch];
87
+ bit = 0;
88
+ ch = 0;
89
+ }
90
+ }
91
+ return geohash
92
+ }
93
+
94
+ exports.calculateAdjacent = calculateAdjacent;
95
+ exports.encode = encode;
@@ -2,6 +2,73 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- 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}
5
+ // https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
6
+ const nodeColorsOb = {
7
+ black: '\x1b[30m',
8
+ red: '\x1b[31m',
9
+ green: '\x1b[32m',
10
+ yellow: '\x1b[33m',
11
+ blue: '\x1b[34m',
12
+ magenta: '\x1b[35m',
13
+ cyan: '\x1b[36m',
14
+ white: '\x1b[37m'
15
+ };
6
16
 
7
- exports.initLog = o;
17
+ function clog (name, options = { }) {
18
+ let prefix = name + ': ';
19
+ let style = null;
20
+
21
+ if (options.color)
22
+ if (options.isBrowser) {
23
+ prefix = '%c' + prefix;
24
+ style = `color: ${options.color}`;
25
+ } else {
26
+ const cstring = nodeColorsOb[options.color];
27
+ if (cstring)
28
+ prefix = cstring + prefix;
29
+ }
30
+
31
+ const trunc = (str, len) => str && str.length > len ? str.substring(0, len) + '...' : str;
32
+ const checkPassesFilter = (args, filter) => typeof filter === 'string'
33
+ ? args[0].includes(filter)
34
+ : filter.test(args[0]);
35
+
36
+ function logGen (cmethod) {
37
+ return function () {
38
+ const isEnabled = options.enabled === undefined ? true : !!options.enabled;
39
+ if (isEnabled || cmethod === console.error) {
40
+ let args = Array.from(arguments);
41
+ if (style)
42
+ args.unshift(style);
43
+ args.unshift(prefix);
44
+ if (options.truncateObjects && cmethod !== console.error)
45
+ args = args.map(arg => {
46
+ if (typeof arg === 'object')
47
+ return trunc(JSON.stringify(arg), parseInt(options.truncateObjects) || 100)
48
+ return arg
49
+ });
50
+ const passesFilter = !options.logFilter || checkPassesFilter(args, options.logFilter);
51
+ if (passesFilter || cmethod === console.error)
52
+ cmethod.apply(console, args);
53
+ }
54
+ }
55
+ }
56
+
57
+ const log = logGen(console.log);
58
+ log.info = log;
59
+ log.warn = logGen(console.warn);
60
+ log.detailed = logGen(console.debug);
61
+ log.error = logGen(console.error);
62
+
63
+ log.setEnabled = e => { options.enabled = e; };
64
+
65
+ return log
66
+ }
67
+
68
+ function initLog (name, options) {
69
+ const log = clog(name, options);
70
+ log.sublog = (sublogName, sublogOptions) => initLog(name + '.' + sublogName, Object.assign(Object.create(options), sublogOptions));
71
+ return log
72
+ }
73
+
74
+ exports.initLog = initLog;
@@ -2,6 +2,33 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- 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;}));};
5
+ const initHistoryManager = ({ bus }) => {
6
+ const stepStack = [];
7
+ bus.on('history/register', ({ viewId, event, params = {} }) => {
8
+ stepStack.push({ viewId, event, params });
9
+ });
10
+ bus.on('history/stepBack', () => {
11
+ const layersToHide = [];
12
+ const current = stepStack.pop();
6
13
 
7
- exports.initHistoryManager = e;
14
+ if (!current) return
15
+
16
+ layersToHide.push(current.viewId);
17
+ for (let i = stepStack.length - 1; i >= 0; --i) {
18
+ if (stepStack[i].event === current.event) {
19
+ const same = stepStack.pop();
20
+ layersToHide.push(same.viewId);
21
+ } else {
22
+ break
23
+ }
24
+ }
25
+ bus.send('layers/hideMultiple', layersToHide);
26
+ const { event, params } = stepStack.pop();
27
+ bus.send(event, params);
28
+ });
29
+ bus.on('history/clean', () => {
30
+ stepStack.length = 0;
31
+ });
32
+ };
33
+
34
+ exports.initHistoryManager = initHistoryManager;
@@ -2,9 +2,27 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var e = require('ramda');
5
+ var R = require('ramda');
6
6
 
7
- function r(i){return m(i.map(e.path(["position","lat"])).filter(e.identity),i.map(e.path(["position","lng"])).filter(e.identity))}function a(t){return m(t.map(e.prop(0)).filter(e.identity),t.map(e.prop(1)).filter(e.identity))}function m(t,n){return {n:Math.max(...t),s:Math.min(...t),e:Math.max(...n),w:Math.min(...n)}}
7
+ function findBoundsOfWaypoints (waypoints) {
8
+ const latitudes = waypoints.map(R.path(['position', 'lat'])).filter(R.identity);
9
+ const longitudes = waypoints.map(R.path(['position', 'lng'])).filter(R.identity);
10
+ return findBounds(latitudes, longitudes)
11
+ }
8
12
 
9
- exports.findBoundsOfCoordinates = a;
10
- exports.findBoundsOfWaypoints = r;
13
+ function findBoundsOfCoordinates (coordinates) {
14
+ const latitudes = coordinates.map(R.prop(0)).filter(R.identity);
15
+ const longitudes = coordinates.map(R.prop(1)).filter(R.identity);
16
+ return findBounds(latitudes, longitudes)
17
+ }
18
+
19
+ function findBounds (latitudes, longitudes) {
20
+ const n = Math.max(...latitudes);
21
+ const s = Math.min(...latitudes);
22
+ const e = Math.max(...longitudes);
23
+ const w = Math.min(...longitudes);
24
+ return { n, s, e, w }
25
+ }
26
+
27
+ exports.findBoundsOfCoordinates = findBoundsOfCoordinates;
28
+ exports.findBoundsOfWaypoints = findBoundsOfWaypoints;