atriusmaps-node-sdk 3.3.898 → 3.3.899

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 (62) hide show
  1. package/dist/cjs/nodesdk/nodeEntry.js +36 -58
  2. package/dist/cjs/package.json.js +8 -4
  3. package/dist/cjs/plugins/clientAPI/src/clientAPI.js +8 -6
  4. package/dist/cjs/plugins/dynamicPois/src/dynamicPois.js +50 -142
  5. package/dist/cjs/plugins/dynamicPois/src/processors.js +31 -53
  6. package/dist/cjs/plugins/flightStatus/src/flightDetailsMapper.js +47 -116
  7. package/dist/cjs/plugins/flightStatus/src/flightStatus.js +48 -82
  8. package/dist/cjs/plugins/flightStatus/src/utils.js +4 -14
  9. package/dist/cjs/plugins/poiDataManager/src/poiDataManager.js +77 -154
  10. package/dist/cjs/plugins/sdkServer/src/prepareSDKConfig.js +45 -76
  11. package/dist/cjs/plugins/sdkServer/src/sdkHeadless.js +70 -79
  12. package/dist/cjs/plugins/sdkServer/src/sdkServer.js +97 -147
  13. package/dist/cjs/plugins/searchService/src/flexsearchExports/lang.js +16 -190
  14. package/dist/cjs/plugins/searchService/src/flexsearchExports/simple.js +28 -35
  15. package/dist/cjs/plugins/searchService/src/poiSearch.js +10 -21
  16. package/dist/cjs/plugins/searchService/src/searchService.js +45 -147
  17. package/dist/cjs/plugins/searchService/src/searchTypeahead.js +17 -28
  18. package/dist/cjs/plugins/searchService/src/utils.js +9 -13
  19. package/dist/cjs/plugins/venueDataLoader/src/venueDataLoader.js +148 -304
  20. package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +47 -126
  21. package/dist/cjs/plugins/wayfinder/src/findRoute.js +6 -73
  22. package/dist/cjs/plugins/wayfinder/src/minPriorityQueue.js +7 -27
  23. package/dist/cjs/plugins/wayfinder/src/navGraph.js +78 -259
  24. package/dist/cjs/plugins/wayfinder/src/navGraphDebug.js +26 -57
  25. package/dist/cjs/plugins/wayfinder/src/segmentBadges.js +25 -25
  26. package/dist/cjs/plugins/wayfinder/src/segmentBuilder.js +50 -133
  27. package/dist/cjs/plugins/wayfinder/src/segmentCategories.js +29 -29
  28. package/dist/cjs/plugins/wayfinder/src/stepBuilder.js +53 -145
  29. package/dist/cjs/plugins/wayfinder/src/wayfinder.js +105 -349
  30. package/dist/cjs/src/app.js +53 -91
  31. package/dist/cjs/src/configs/postproc-mol-url-parms.js +34 -43
  32. package/dist/cjs/src/configs/postproc-stateTracking.js +1 -19
  33. package/dist/cjs/src/controller.js +4 -26
  34. package/dist/cjs/src/debugTools.js +55 -94
  35. package/dist/cjs/src/env.js +8 -19
  36. package/dist/cjs/src/extModules/bustle.js +15 -71
  37. package/dist/cjs/src/extModules/flexapi/src/help.js +7 -22
  38. package/dist/cjs/src/extModules/flexapi/src/index.js +15 -29
  39. package/dist/cjs/src/extModules/flexapi/src/validate.js +45 -93
  40. package/dist/cjs/src/extModules/geohasher.js +13 -31
  41. package/dist/cjs/src/extModules/log.js +18 -29
  42. package/dist/cjs/src/historyManager.js +4 -6
  43. package/dist/cjs/src/utils/bounds.js +2 -4
  44. package/dist/cjs/src/utils/buildStructureLookup.js +7 -7
  45. package/dist/cjs/src/utils/configUtils.js +7 -43
  46. package/dist/cjs/src/utils/date.js +5 -17
  47. package/dist/cjs/src/utils/distance.js +2 -2
  48. package/dist/cjs/src/utils/dom.js +9 -24
  49. package/dist/cjs/src/utils/funcs.js +15 -30
  50. package/dist/cjs/src/utils/geodesy.js +24 -39
  51. package/dist/cjs/src/utils/geom.js +32 -148
  52. package/dist/cjs/src/utils/i18n.js +39 -70
  53. package/dist/cjs/src/utils/isInitialState.js +7 -13
  54. package/dist/cjs/src/utils/location.js +10 -29
  55. package/dist/cjs/src/utils/observable.js +4 -29
  56. package/dist/cjs/src/utils/rand.js +9 -80
  57. package/dist/cjs/utils/constants.js +1 -1
  58. package/dist/package.json.js +1 -1
  59. package/dist/plugins/sdkServer/src/prepareSDKConfig.js +1 -1
  60. package/dist/src/utils/buildStructureLookup.js +1 -1
  61. package/dist/src/utils/date.js +1 -1
  62. package/package.json +1 -1
@@ -24,167 +24,128 @@ function _interopNamespaceDefault(e) {
24
24
 
25
25
  var R__namespace = /*#__PURE__*/_interopNamespaceDefault(R);
26
26
 
27
- if (typeof window !== 'undefined') {
27
+ if (typeof window !== "undefined") {
28
28
  window.R = R__namespace;
29
- } // helps use Rambda in console... probably don't want to do this once we integrate with customer content
30
-
31
- // NOTE:
32
- // The exported functions from this module all get placed into the app.debug (accessable from console via _app.debug) and bound to
33
- // the app instance. So the `this` context will contain the app instance when these are run. This allows you to access objects like
34
- // the bus via `this.bus` or configuration via `this.config`
35
- // Update: these are now also available in MoL by searching for `debug:<funcname>` - such as `debug:showIcons`
36
-
29
+ }
37
30
  const showIcons = () => {
38
- dom.$('#mapRenderDiv').innerHTML =
39
- '<style> div { display: inline-block; text-align: center; border: 1px solid lightblue; }</style>' +
40
- dom.$$('svg symbol')
41
- .map(e => `<div><svg><use xlink:href="#${e.id}"/></svg><br/>${e.id}</div>`)
42
- .join('');
31
+ dom.$("#mapRenderDiv").innerHTML = "<style> div { display: inline-block; text-align: center; border: 1px solid lightblue; }</style>" + dom.$$("svg symbol").map((e) => `<div><svg><use xlink:href="#${e.id}"/></svg><br/>${e.id}</div>`).join("");
43
32
  };
44
-
45
33
  function poisByCategory() {
46
- return this.bus
47
- .send('poi/getAll')
48
- .then(r => r[0])
49
- .then(p => Object.values(p))
50
- .then(R__namespace.groupBy(o => o.category));
34
+ return this.bus.send("poi/getAll").then((r) => r[0]).then((p) => Object.values(p)).then(R__namespace.groupBy((o) => o.category));
51
35
  }
52
-
53
- const highlightNodes = () =>
54
- dom.ad(
55
- {
56
- tag: 'style',
57
- html: '* { background-color: rgba(255,0,0,.2); } * * { background-color: rgba(0,255,0,.2); } * * * { background-color: rgba(0,0,255,.2); } * * * * { background-color: rgba(255,0,255,.2); } * * * * * { background-color: rgba(0,255,255,.2); } * * * * * * { background-color: rgba(255,255,0,.2); } * * * * * * * { background-color: rgba(255,0,0,.2); } * * * * * * * * { background-color: rgba(0,255,0,.2); } * * * * * * * * * { background-color: rgba(0,0,255,.2); }',
58
- },
59
- dom.$('head'),
60
- );
61
-
36
+ const highlightNodes = () => dom.ad(
37
+ {
38
+ tag: "style",
39
+ html: "* { background-color: rgba(255,0,0,.2); } * * { background-color: rgba(0,255,0,.2); } * * * { background-color: rgba(0,0,255,.2); } * * * * { background-color: rgba(255,0,255,.2); } * * * * * { background-color: rgba(0,255,255,.2); } * * * * * * { background-color: rgba(255,255,0,.2); } * * * * * * * { background-color: rgba(255,0,0,.2); } * * * * * * * * { background-color: rgba(0,255,0,.2); } * * * * * * * * * { background-color: rgba(0,0,255,.2); }"
40
+ },
41
+ dom.$("head")
42
+ );
62
43
  function getPoiById(id) {
63
- return this.bus.send('poi/getById', { id }).then(r => r[0]);
44
+ return this.bus.send("poi/getById", { id }).then((r) => r[0]);
64
45
  }
65
-
66
46
  async function showOrphaned() {
67
- const navGraph = await this.bus.get('wayfinder/_getNavGraph');
47
+ const navGraph = await this.bus.get("wayfinder/_getNavGraph");
68
48
  const oob = navGraphDebug.orphanTest(navGraph._nodes);
69
- this.bus.send('map/showOrphanedGraphNodes', { orphanedNodes: oob.orphaned });
49
+ this.bus.send("map/showOrphanedGraphNodes", { orphanedNodes: oob.orphaned });
70
50
  }
71
-
72
51
  async function showgraph() {
73
- const navGraph = await this.bus.get('wayfinder/getNavGraphFeatures');
74
- this.bus.send('map/showNavGraphFeatures', { navGraph });
75
- monitorDebugFeaturesReset('map/resetNavGraphFeatures', this.bus);
52
+ const navGraph = await this.bus.get("wayfinder/getNavGraphFeatures");
53
+ this.bus.send("map/showNavGraphFeatures", { navGraph });
54
+ monitorDebugFeaturesReset("map/resetNavGraphFeatures", this.bus);
76
55
  }
77
-
78
56
  async function bounds() {
79
- const venueCenter = await this.bus.get('venueData/getVenueCenter');
80
- const { venueRadius, bounds } = await this.bus.get('venueData/getVenueData');
81
- this.bus.send('map/showVenueBounds', { venueCenter, venueRadius, bounds });
82
- monitorDebugFeaturesReset('map/resetVenueBounds', this.bus);
57
+ const venueCenter = await this.bus.get("venueData/getVenueCenter");
58
+ const { venueRadius, bounds: bounds2 } = await this.bus.get("venueData/getVenueData");
59
+ this.bus.send("map/showVenueBounds", { venueCenter, venueRadius, bounds: bounds2 });
60
+ monitorDebugFeaturesReset("map/resetVenueBounds", this.bus);
83
61
  }
84
-
85
62
  async function buildingBounds(nameFilter) {
86
- this.bus.send('map/showBuildingBounds', { nameFilter });
87
- monitorDebugFeaturesReset('map/resetVenueBounds', this.bus);
63
+ this.bus.send("map/showBuildingBounds", { nameFilter });
64
+ monitorDebugFeaturesReset("map/resetVenueBounds", this.bus);
88
65
  showCenter.apply(this);
89
66
  }
90
-
91
67
  async function floorBounds(nameFilter) {
92
68
  const bus = this.bus;
93
- bus.send('map/showFloorBounds', { nameFilter });
94
-
95
- monitorDebugFeaturesReset('map/resetVenueBounds', bus);
96
-
97
- const unsubFloorChanges = bus.monitor('map/floorChanged', () => bus.send('map/showFloorBounds', { nameFilter }));
69
+ bus.send("map/showFloorBounds", { nameFilter });
70
+ monitorDebugFeaturesReset("map/resetVenueBounds", bus);
71
+ const unsubFloorChanges = bus.monitor("map/floorChanged", () => bus.send("map/showFloorBounds", { nameFilter }));
98
72
  onNextSearchClear(unsubFloorChanges, bus);
99
73
  showCenter.apply(this);
100
74
  }
101
-
102
75
  async function padding() {
103
- this.bus.send('map/togglePadding');
104
- monitorDebugFeaturesReset('map/togglePadding', this.bus);
76
+ this.bus.send("map/togglePadding");
77
+ monitorDebugFeaturesReset("map/togglePadding", this.bus);
105
78
  }
106
-
107
79
  const monitorDebugFeaturesReset = (resetEventName, bus) => onNextSearchClear(() => bus.send(resetEventName), bus);
108
-
109
80
  const onNextSearchClear = (fn, bus) => {
110
- const unsubscribe = bus.monitor('homeview/performSearch', ({ term }) => {
81
+ const unsubscribe = bus.monitor("homeview/performSearch", ({ term }) => {
111
82
  if (!term) {
112
83
  fn();
113
84
  unsubscribe();
114
85
  }
115
86
  });
116
87
  };
117
-
118
88
  async function showCenter() {
119
- const padding = await this.bus.get('map/getPadding');
120
- const leftAdj = (padding.left - padding.right) / 2; // how much to adjust left from true center to account for padding
121
- const topAdj = (padding.top - padding.bottom) / 2; // how much to adjust top from true center to account for padding
89
+ const padding2 = await this.bus.get("map/getPadding");
90
+ const leftAdj = (padding2.left - padding2.right) / 2;
91
+ const topAdj = (padding2.top - padding2.bottom) / 2;
122
92
  const crosshair = dom.ad(
123
93
  {
124
94
  html: `<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><path stroke="#fF000080" stroke-width="2" d="M0 50h45M55 50h45M50 0v45M50 55v45"/></svg>`,
125
95
  styles: {
126
- position: 'absolute',
127
- 'inset-inline-start': '50%',
128
- top: '50%',
129
- 'margin-inline-start': -50 + leftAdj + 'px',
130
- 'margin-top': -50 + topAdj + 'px',
131
- },
96
+ position: "absolute",
97
+ "inset-inline-start": "50%",
98
+ top: "50%",
99
+ "margin-inline-start": -50 + leftAdj + "px",
100
+ "margin-top": -50 + topAdj + "px"
101
+ }
132
102
  },
133
- dom.$('.maplibregl-map'),
103
+ dom.$(".maplibregl-map")
134
104
  );
135
105
  onNextSearchClear(() => dom.del(crosshair), this.bus);
136
106
  }
137
-
138
107
  function dndGo() {
139
108
  const bus = this.bus;
140
109
  const toggleActive = (e, indicateDragVisual) => {
141
110
  e.preventDefault();
142
111
  if (indicateDragVisual) {
143
- e.target.classList.add('dragover');
112
+ e.target.classList.add("dragover");
144
113
  } else {
145
- e.target.classList.remove('dragover');
114
+ e.target.classList.remove("dragover");
146
115
  }
147
116
  };
148
-
149
117
  const handlers = {
150
- drop: async function (e) {
118
+ drop: async function(e) {
151
119
  toggleActive(e, false);
152
-
153
- // Load the file into the player
154
120
  for (const file of e.dataTransfer.files) {
155
121
  const filename = file.name;
156
- if (file.type === 'application/json' || file.type.startsWith('text/')) {
122
+ if (file.type === "application/json" || file.type.startsWith("text/")) {
157
123
  const reader = new FileReader();
158
- reader.onload = funcs.singleFile(async e =>
159
- bus.send(`debugTools/fileDrop`, {
124
+ reader.onload = funcs.singleFile(
125
+ async (e2) => bus.send(`debugTools/fileDrop`, {
160
126
  file,
161
127
  filename,
162
- content: e.target.result,
163
- }),
128
+ content: e2.target.result
129
+ })
164
130
  );
165
131
  reader.readAsText(file);
166
132
  }
167
133
  }
168
134
  },
169
-
170
135
  // Drag-over event
171
- dragover: function (e) {
136
+ dragover: function(e) {
172
137
  toggleActive(e, true);
173
138
  },
174
-
175
139
  // Drag-leave event
176
- dragleave: function (e) {
140
+ dragleave: function(e) {
177
141
  toggleActive(e, false);
178
- },
179
- }; // end of handlers def
180
-
181
- Object.keys(handlers).forEach(function (event) {
142
+ }
143
+ };
144
+ Object.keys(handlers).forEach(function(event) {
182
145
  document.body.addEventListener(event, handlers[event]);
183
146
  });
184
-
185
- console.log('DnD Listeners installed');
186
- } // end of function installDragNDrop
187
-
147
+ console.log("DnD Listeners installed");
148
+ }
188
149
  var debugTools = {
189
150
  bounds,
190
151
  buildingBounds,
@@ -198,7 +159,7 @@ var debugTools = {
198
159
  showCenter,
199
160
  showgraph,
200
161
  showIcons,
201
- showOrphaned,
162
+ showOrphaned
202
163
  };
203
164
 
204
165
  module.exports = debugTools;
@@ -1,24 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  function buildEnv(app) {
4
- const desktopViewMinWidth = app.config.desktopViewMinWidth || 0; // default to desktop view for all sizes
5
- const isBrowser = typeof window !== 'undefined';
6
-
7
- // supportsTouch doesn't mean user PREFERS touch - touch laptops exist
8
- const supportsTouch = isBrowser && ('ontouchstart' in window || navigator.maxTouchPoints > 0);
9
-
10
- // I'd like to move from a single dimension (isMobile vs isDesktop) to a more
11
- // nuanced approach separately considering narrow, touch, mobile (meaning moves
12
- // around), etc. Our UI is generally based on the narrow width of the map
13
- // container, so lets continue using that for isMobile for now...
4
+ const desktopViewMinWidth = app.config.desktopViewMinWidth || 0;
5
+ const isBrowser = typeof window !== "undefined";
6
+ const supportsTouch = isBrowser && ("ontouchstart" in window || navigator.maxTouchPoints > 0);
14
7
  const isNarrow = () => isBrowser && innerWidth < desktopViewMinWidth;
15
8
  const isMobile = () => isNarrow();
16
9
  const isMobileReflow = () => isMobile() && innerHeight < 360;
17
10
  const isVeryNarrow = () => isMobile() && innerWidth < 320;
18
11
  const isDesktop = () => isBrowser && !isNarrow();
19
-
20
- const isLocalhost = () => location.host.startsWith('localhost') || location.host.startsWith('127.0.0.1');
21
-
12
+ const isLocalhost = () => location.host.startsWith("localhost") || location.host.startsWith("127.0.0.1");
22
13
  const env = {
23
14
  isBrowser,
24
15
  isMobile,
@@ -26,19 +17,17 @@ function buildEnv(app) {
26
17
  isVeryNarrow,
27
18
  isLocalhost,
28
19
  isDesktop,
29
- supportsTouch,
20
+ supportsTouch
30
21
  };
31
-
32
22
  if (isBrowser) {
33
- window.addEventListener('resize', () => {
34
- app.bus.send('env/resize', {
23
+ window.addEventListener("resize", () => {
24
+ app.bus.send("env/resize", {
35
25
  isMobile: env.isMobile(),
36
26
  isMobileReflow: env.isMobileReflow(),
37
- isVeryNarrow: env.isVeryNarrow(),
27
+ isVeryNarrow: env.isVeryNarrow()
38
28
  });
39
29
  });
40
30
  }
41
-
42
31
  return env;
43
32
  }
44
33
 
@@ -2,27 +2,16 @@
2
2
 
3
3
  var Zousan = require('zousan');
4
4
 
5
- /**
6
- * Bustle is a highly performant event bus that offers event order guarantees.
7
- */
8
-
9
-
10
5
  const bustleResponseComparitor = (r1, r2) => {
11
- if (r1.responseOrder == null) // null or undefined
12
- {
6
+ if (r1.responseOrder == null) {
13
7
  return r2.responseOrder == null ? 0 : 1;
14
- } // any order is higher pri than none
8
+ }
15
9
  if (r2.responseOrder == null) {
16
10
  return -1;
17
11
  }
18
12
  return r1.responseOrder - r2.responseOrder;
19
13
  };
20
-
21
- // Remove element from array at index specified and return the removed element.
22
- // Source array will then have item removed.
23
- const arRmAt = (ar, index) => ar.splice(index, 1)[0]; // oh yah, thats intuitive!
24
-
25
- // Removes the value from the array if it exists. The array is then returned
14
+ const arRmAt = (ar, index) => ar.splice(index, 1)[0];
26
15
  const arRm = (ar, value) => {
27
16
  let i = 0;
28
17
  do {
@@ -33,47 +22,25 @@ const arRm = (ar, value) => {
33
22
  } while (i >= 0);
34
23
  return ar;
35
24
  };
36
-
37
- // This creates a bus instance. When used as a Singleton, you will only call this once
38
- // for the life of your app. To isolate events (perhaps for performance or security
39
- // reasons) you can create multple bus instances.
40
25
  function create(opts = {}) {
41
- // If a log option is defined, use it - and if it supports sublogs, instantiate that. If all else fails, use console
42
- const log = opts.log ? (opts.log.sublog ? opts.log.sublog('bustle', { color: 'pink' }) : opts.log) : console;
43
-
44
- const ons = {}; // holds your listeners
45
- const mons = {}; // holds your monitors
46
-
47
- // subscribes to an event. Your listener will always be called
48
- // with a single argument. I am considering adding another way
49
- // to subscribe to events by observing an event and then
50
- // subscribing to that observer.
26
+ const log = opts.log ? opts.log.sublog ? opts.log.sublog("bustle", { color: "pink" }) : opts.log : console;
27
+ const ons = {};
28
+ const mons = {};
51
29
  function on(ev, fn) {
52
30
  if (!ons[ev]) {
53
31
  ons[ev] = [];
54
32
  }
55
-
56
33
  ons[ev].push(fn);
57
-
58
34
  return () => off(ev, fn);
59
35
  }
60
-
61
- // Similar to "on" but is always called after all normal "on" listeners,
62
- // and any values returned by a monitor call are ignored (not added to the
63
- // response). Also, any calls to monitor listeners contains both the message
64
- // object AND a promise containing the response from the normal listeners.
65
36
  function monitor(ev, fn) {
66
37
  if (!mons[ev]) {
67
38
  mons[ev] = [];
68
39
  }
69
-
70
40
  mons[ev].push(fn);
71
-
72
41
  return () => moff(ev, fn);
73
42
  }
74
-
75
43
  function off(ev, fn) {
76
- // run ASAP but not immediate, in case it removes in its own function
77
44
  Zousan.soon(() => {
78
45
  if (!ons[ev]) {
79
46
  return;
@@ -81,9 +48,7 @@ function create(opts = {}) {
81
48
  arRm(ons[ev], fn);
82
49
  });
83
50
  }
84
-
85
51
  function moff(ev, fn) {
86
- // run ASAP but not immediate, in case it removes in its own function
87
52
  Zousan.soon(() => {
88
53
  if (!mons[ev]) {
89
54
  return;
@@ -91,9 +56,7 @@ function create(opts = {}) {
91
56
  arRm(mons[ev], fn);
92
57
  });
93
58
  }
94
-
95
59
  const serve = (ev, ob, done) => () => {
96
- // const myOns = (ons[ev] || []).concat(ons["*"] ? ons["*"] : [])
97
60
  const myOns = ons[ev];
98
61
  const myMons = mons[ev];
99
62
  const res = [];
@@ -107,16 +70,13 @@ function create(opts = {}) {
107
70
  }
108
71
  if (opts.rejectOnError) {
109
72
  res.push(Zousan.reject(err));
110
- } // will cause the Zousan.all to reject the send
111
- else {
73
+ } else {
112
74
  res.push(err);
113
75
  }
114
76
  }
115
77
  }
116
78
  }
117
-
118
79
  const results = Zousan.all(res);
119
-
120
80
  if (myMons) {
121
81
  for (const listener of myMons) {
122
82
  try {
@@ -128,40 +88,24 @@ function create(opts = {}) {
128
88
  }
129
89
  }
130
90
  }
131
-
132
91
  done(results);
133
92
  };
134
-
135
- // Used when there is a single listener that provides information or a service,
136
- // a get sends a message to that listener, ensures it gets exactly 1 result,
137
- // and returns that result. If there are 0 or more than 1 listener, the returned
138
- // promise is rejected
139
- const get = (ev, ob) =>
140
- send(ev, ob).then(res =>
141
- res.length !== 1
142
- ? Zousan.reject(`${ev} event did not return a single result, but ${res.length} results.`)
143
- : res[0],
144
- );
145
-
146
- // Allows for any number of listeners to exist - but extracts the first one
147
- // and returns it. If there are NO listeners, undefined is returned. The promise
148
- // is never rejected.
149
- const getFirst = (ev, ob) =>
150
- send(ev, ob).then(res => (res.length >= 1 ? res.sort(bustleResponseComparitor)[0] : undefined));
151
-
93
+ const get = (ev, ob) => send(ev, ob).then(
94
+ (res) => res.length !== 1 ? Zousan.reject(`${ev} event did not return a single result, but ${res.length} results.`) : res[0]
95
+ );
96
+ const getFirst = (ev, ob) => send(ev, ob).then((res) => res.length >= 1 ? res.sort(bustleResponseComparitor)[0] : void 0);
152
97
  function send(ev, ob) {
153
98
  if (opts.showEvents) {
154
- if (typeof opts.showEvents === 'function') {
99
+ if (typeof opts.showEvents === "function") {
155
100
  if (opts.showEvents(ev, ob)) {
156
- log.info('send with', ev, ' and ', ob);
101
+ log.info("send with", ev, " and ", ob);
157
102
  }
158
103
  } else {
159
- log.info('send with', ev, ' and ', ob);
104
+ log.info("send with", ev, " and ", ob);
160
105
  }
161
106
  }
162
- return new Zousan(resolve => Zousan.soon(serve(ev, ob, resolve)));
107
+ return new Zousan((resolve) => Zousan.soon(serve(ev, ob, resolve)));
163
108
  }
164
-
165
109
  return { get, getFirst, moff, monitor, off, on, send };
166
110
  }
167
111
 
@@ -2,31 +2,16 @@
2
2
 
3
3
  function pad(total, str) {
4
4
  while (str.length < total) {
5
- str += ' ';
5
+ str += " ";
6
6
  }
7
7
  return str;
8
8
  }
9
-
10
- const getHelpHeader = () =>
11
- pad(18, 'Command') + 'Arguments\n' + pad(18, '----------------') + '----------------\n';
12
-
13
- /**
14
- * Returns help on the passed command signature
15
- */
16
- const getHelp = sig =>
17
- pad(18, sig.command) +
18
- (sig.args
19
- ? sig.args
20
- .map(argob => `${argob.name} {${argob.type}} ${argob.optional ? ' (optional)' : ' (required)'}`)
21
- .join(', ')
22
- : '');
23
-
24
- const sigsort = (s1, s2) => (s1.command > s2.command ? 1 : -1);
25
- /**
26
- * Returns help on the passed command signatures
27
- */
28
- const getHelpList = sigList => {
29
- return sigList.sort(sigsort).reduce((ret, sig) => `${ret}${getHelp(sig)}\n`, getHelpHeader());
9
+ const getHelpHeader = () => pad(18, "Command") + "Arguments\n" + pad(18, "----------------") + "----------------\n";
10
+ const getHelp = (sig) => pad(18, sig.command) + (sig.args ? sig.args.map((argob) => `${argob.name} {${argob.type}} ${argob.optional ? " (optional)" : " (required)"}`).join(", ") : "");
11
+ const sigsort = (s1, s2) => s1.command > s2.command ? 1 : -1;
12
+ const getHelpList = (sigList) => {
13
+ return sigList.sort(sigsort).reduce((ret, sig) => `${ret}${getHelp(sig)}
14
+ `, getHelpHeader());
30
15
  };
31
16
 
32
17
  exports.getHelp = getHelp;
@@ -6,85 +6,71 @@ var validate = require('./validate.js');
6
6
 
7
7
  const COMMAND_VALIDATION_REGEX = /^[-_.0-9a-zA-Z]+$/;
8
8
  const JS = JSON.stringify;
9
-
10
9
  function create() {
11
10
  const commandDefsList = [];
12
- const commands = () => commandDefsList.map(cob => cob.sig);
11
+ const commands = () => commandDefsList.map((cob) => cob.sig);
13
12
  const customTypes = {};
14
13
  const library = { customTypes, commandDefsList };
15
14
  const getCommandJSON = () => ({ commands: commands(), customTypes });
16
-
17
15
  function registerCommand(sig, fn) {
18
16
  const command = sig.command;
19
- if (command === undefined) {
17
+ if (command === void 0) {
20
18
  throw Error(`Invalid command specification in registerCommand: ${JS(sig)}. No 'command' property specified.`);
21
19
  }
22
-
23
20
  if (!COMMAND_VALIDATION_REGEX.test(command)) {
24
21
  const er = Error(
25
- `Invalid command specification in registerCommand: ${JS(sig)}. Command name '${command}' not valid.`,
22
+ `Invalid command specification in registerCommand: ${JS(sig)}. Command name '${command}' not valid.`
26
23
  );
27
24
  throw er;
28
25
  }
29
-
30
26
  commandDefsList.push({ sig, fn });
31
-
32
27
  return execute;
33
28
  }
34
-
35
29
  function registerCustomType(name, spec) {
36
30
  customTypes[name] = spec;
37
31
  }
38
-
39
32
  function execute(cob) {
40
33
  return new Zousan((resolve, reject) => {
41
34
  if (!cob) {
42
35
  return reject(new Error(`No command specified in command object ${JS(cob)}`));
43
36
  }
44
-
45
- const commandMatches = library.commandDefsList.filter(com => com.sig.command === cob.command);
46
-
37
+ const commandMatches = library.commandDefsList.filter((com) => com.sig.command === cob.command);
47
38
  if (commandMatches.length === 0) {
48
39
  return reject(
49
- new Error(`No API command '${cob.command}' found.\n${help.getHelpList(library.commandDefsList.map(o => o.sig))}`),
40
+ new Error(`No API command '${cob.command}' found.
41
+ ${help.getHelpList(library.commandDefsList.map((o) => o.sig))}`)
50
42
  );
51
43
  }
52
-
53
44
  const sigMatch = validate.getSigMatch(library, cob);
54
-
55
45
  if (!sigMatch) {
56
46
  if (commandMatches.length === 1) {
57
47
  return reject(
58
- new Error(`Required fields not present in ${JS(cob)}\n${help.getHelpHeader()}${help.getHelp(commandMatches[0].sig)}`),
48
+ new Error(`Required fields not present in ${JS(cob)}
49
+ ${help.getHelpHeader()}${help.getHelp(commandMatches[0].sig)}`)
59
50
  );
60
51
  } else {
61
52
  return reject(
62
53
  new Error(
63
- `Command arguments did not match any required signatures: ${JS(cob)}\n${help.getHelpList(library.commandDefsList.map(o => o.sig))}`,
64
- ),
54
+ `Command arguments did not match any required signatures: ${JS(cob)}
55
+ ${help.getHelpList(library.commandDefsList.map((o) => o.sig))}`
56
+ )
65
57
  );
66
58
  }
67
59
  }
68
-
69
- // console.log(`command ${JS(cob)} is ${JS(sigMatch.sig)}`)
70
-
71
60
  try {
72
- validate.validate(library, sigMatch.sig, cob); // this will throw an error if invalid
61
+ validate.validate(library, sigMatch.sig, cob);
73
62
  } catch (e) {
74
63
  return reject(e);
75
64
  }
76
-
77
65
  resolve(sigMatch.fn(cob));
78
66
  });
79
67
  }
80
-
81
- registerCommand({ command: 'help', args: [] }, () => help.getHelpList(commands()));
82
- registerCommand({ command: 'getCommandJSON', args: [] }, getCommandJSON);
83
-
68
+ registerCommand({ command: "help", args: [] }, () => help.getHelpList(commands()));
69
+ registerCommand({ command: "getCommandJSON", args: [] }, getCommandJSON);
84
70
  return {
85
71
  registerCommand,
86
72
  registerCustomType,
87
- execute,
73
+ execute
88
74
  };
89
75
  }
90
76