@de./sdk 1.0.0

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 (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4391 -0
  3. package/dist/allend/Access.d.ts +15 -0
  4. package/dist/allend/Access.js +164 -0
  5. package/dist/allend/Access.js.map +1 -0
  6. package/dist/allend/DAuth/index.d.ts +20 -0
  7. package/dist/allend/DAuth/index.js +92 -0
  8. package/dist/allend/DAuth/index.js.map +1 -0
  9. package/dist/allend/DClient/Client.d.ts +10 -0
  10. package/dist/allend/DClient/Client.js +144 -0
  11. package/dist/allend/DClient/Client.js.map +1 -0
  12. package/dist/allend/DClient/Event.d.ts +18 -0
  13. package/dist/allend/DClient/Event.js +100 -0
  14. package/dist/allend/DClient/Event.js.map +1 -0
  15. package/dist/allend/DClient/Order.d.ts +49 -0
  16. package/dist/allend/DClient/Order.js +601 -0
  17. package/dist/allend/DClient/Order.js.map +1 -0
  18. package/dist/allend/IoTClient.d.ts +29 -0
  19. package/dist/allend/IoTClient.js +59 -0
  20. package/dist/allend/IoTClient.js.map +1 -0
  21. package/dist/allend/MSI/Controls.d.ts +256 -0
  22. package/dist/allend/MSI/Controls.js +763 -0
  23. package/dist/allend/MSI/Controls.js.map +1 -0
  24. package/dist/allend/MSI/Handles.d.ts +88 -0
  25. package/dist/allend/MSI/Handles.js +445 -0
  26. package/dist/allend/MSI/Handles.js.map +1 -0
  27. package/dist/allend/MSI/Plugins.d.ts +22 -0
  28. package/dist/allend/MSI/Plugins.js +38 -0
  29. package/dist/allend/MSI/Plugins.js.map +1 -0
  30. package/dist/allend/MSI/index.d.ts +55 -0
  31. package/dist/allend/MSI/index.js +155 -0
  32. package/dist/allend/MSI/index.js.map +1 -0
  33. package/dist/allend/index.d.ts +12 -0
  34. package/dist/allend/index.js +18 -0
  35. package/dist/allend/index.js.map +1 -0
  36. package/dist/backend/Auth.d.ts +38 -0
  37. package/dist/backend/Auth.js +286 -0
  38. package/dist/backend/Auth.js.map +1 -0
  39. package/dist/baseUrl.d.ts +12 -0
  40. package/dist/baseUrl.js +16 -0
  41. package/dist/baseUrl.js.map +1 -0
  42. package/dist/bundle.js +1 -0
  43. package/dist/index.d.ts +13 -0
  44. package/dist/index.js +20 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/types/access.d.ts +8 -0
  47. package/dist/types/auth.d.ts +27 -0
  48. package/dist/types/index.d.ts +281 -0
  49. package/dist/utils/index.d.ts +5 -0
  50. package/dist/utils/index.js +8 -0
  51. package/dist/utils/index.js.map +1 -0
  52. package/dist/utils/stream.d.ts +20 -0
  53. package/dist/utils/stream.js +63 -0
  54. package/dist/utils/stream.js.map +1 -0
  55. package/package.json +66 -0
  56. package/src/allend/Access.ts +78 -0
  57. package/src/allend/DAuth/index.ts +39 -0
  58. package/src/allend/DClient/Client.ts +76 -0
  59. package/src/allend/DClient/Event.ts +76 -0
  60. package/src/allend/DClient/Order.ts +452 -0
  61. package/src/allend/IoTClient.ts +68 -0
  62. package/src/allend/MSI/Controls.ts +760 -0
  63. package/src/allend/MSI/Handles.ts +387 -0
  64. package/src/allend/MSI/Plugins.ts +52 -0
  65. package/src/allend/MSI/index.ts +160 -0
  66. package/src/allend/index.ts +18 -0
  67. package/src/backend/Auth.ts +201 -0
  68. package/src/baseUrl.ts +13 -0
  69. package/src/index.ts +19 -0
  70. package/src/types/access.d.ts +8 -0
  71. package/src/types/auth.d.ts +27 -0
  72. package/src/types/index.d.ts +281 -0
  73. package/src/utils/index.ts +4 -0
  74. package/src/utils/stream.ts +68 -0
@@ -0,0 +1,763 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var FUNCTION_EVENT_TIMEOUT = 12000, FUNCTION_EVENT_TIMEOUT_MESSAGE = 'Event timeout';
4
+ var Controls = /** @class */ (function () {
5
+ function Controls(chn, options) {
6
+ this.chn = chn;
7
+ this.options = options;
8
+ }
9
+ /**
10
+ * Listen to MSI events
11
+ */
12
+ Controls.prototype.on = function (event, listener) {
13
+ this.chn.on(event, listener);
14
+ };
15
+ /**
16
+ * Remove a listener of MSI events
17
+ */
18
+ Controls.prototype.off = function (event, listener) {
19
+ this.chn.off(event, listener);
20
+ };
21
+ /**
22
+ * Remove all listen of MSI events
23
+ */
24
+ Controls.prototype.removeListeners = function (listener) {
25
+ this.chn.removeListeners(listener);
26
+ };
27
+ /**
28
+ * Refresh access token to remove server
29
+ *
30
+ * @param token - Latest access token
31
+ */
32
+ Controls.prototype.refreshToken = function (token) {
33
+ if (!token)
34
+ return;
35
+ this.options.accessToken = token;
36
+ };
37
+ /**
38
+ * Update map style
39
+ *
40
+ * @param style - Map style ID
41
+ */
42
+ Controls.prototype.setMapStyle = function (style) {
43
+ var _this = this;
44
+ return new Promise(function (resolve, reject) {
45
+ // Set timeout
46
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
47
+ // Set style
48
+ _this.chn.emit('set:map:style', style, function (error) {
49
+ if (error)
50
+ return reject(error);
51
+ clearTimeout(timeout);
52
+ resolve();
53
+ });
54
+ });
55
+ };
56
+ /**
57
+ * @return - User's current GPS location
58
+ */
59
+ Controls.prototype.getCurrentLocation = function () {
60
+ var _this = this;
61
+ return new Promise(function (resolve, reject) {
62
+ // Set timeout
63
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
64
+ // Get current location
65
+ _this.chn.emit('get:current:location', function (error, location) {
66
+ if (error)
67
+ return reject(error);
68
+ clearTimeout(timeout);
69
+ resolve(location);
70
+ });
71
+ });
72
+ };
73
+ /**
74
+ * Pin user's current location on the current active map
75
+ *
76
+ * @return - User's current GPS location coordinates or `null` when it failed
77
+ */
78
+ Controls.prototype.pinCurrentLocation = function () {
79
+ var _this = this;
80
+ return new Promise(function (resolve, reject) {
81
+ // Set timeout
82
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
83
+ // Pin user's current location on the map
84
+ _this.chn.emit('pin:current:location', function (error, location) {
85
+ if (error)
86
+ return reject(error);
87
+ clearTimeout(timeout);
88
+ resolve(location);
89
+ });
90
+ });
91
+ };
92
+ /**
93
+ * Set live location tracking options
94
+ *
95
+ * @param options - User location tracking options
96
+ */
97
+ Controls.prototype.setLiveLocationOptions = function (options) {
98
+ var _this = this;
99
+ return new Promise(function (resolve, reject) {
100
+ // Set timeout
101
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
102
+ // Set live location options
103
+ _this.chn.emit('set:live:options', options, function (error) {
104
+ if (error)
105
+ return reject(error);
106
+ clearTimeout(timeout);
107
+ resolve();
108
+ });
109
+ });
110
+ };
111
+ /**
112
+ * Start tracking user's live location
113
+ */
114
+ Controls.prototype.trackLiveLocation = function () {
115
+ var _this = this;
116
+ return new Promise(function (resolve, reject) {
117
+ // Set timeout
118
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
119
+ // Start live location tracking
120
+ _this.chn.emit('track:live:location', function (error) {
121
+ if (error)
122
+ return reject(error);
123
+ clearTimeout(timeout);
124
+ resolve();
125
+ });
126
+ });
127
+ };
128
+ /**
129
+ * Stop tracking user's live location
130
+ */
131
+ Controls.prototype.untrackLiveLocation = function () {
132
+ var _this = this;
133
+ return new Promise(function (resolve, reject) {
134
+ // Set timeout
135
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
136
+ // Stop live location tracking
137
+ _this.chn.emit('untrack:live:location', function (error) {
138
+ if (error)
139
+ return reject(error);
140
+ clearTimeout(timeout);
141
+ resolve();
142
+ });
143
+ });
144
+ };
145
+ /**
146
+ * Enable drag pick functionality
147
+ *
148
+ * @param location - (Optional) Initial location for drag pick
149
+ */
150
+ Controls.prototype.enableDragPickLocation = function (location) {
151
+ var _this = this;
152
+ return new Promise(function (resolve, reject) {
153
+ // Set timeout
154
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
155
+ // Enable drag pick
156
+ _this.chn.emit('enable:dragpick:location', location, function (error) {
157
+ if (error)
158
+ return reject(error);
159
+ clearTimeout(timeout);
160
+ resolve();
161
+ });
162
+ });
163
+ };
164
+ /**
165
+ * Disable drag pick functionality
166
+ */
167
+ Controls.prototype.disableDragPickLocation = function () {
168
+ var _this = this;
169
+ return new Promise(function (resolve, reject) {
170
+ // Set timeout
171
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
172
+ // Disable drag pick
173
+ _this.chn.emit('disable:dragpick:location', function (error) {
174
+ if (error)
175
+ return reject(error);
176
+ clearTimeout(timeout);
177
+ resolve();
178
+ });
179
+ });
180
+ };
181
+ /**
182
+ * Set drag pick content
183
+ *
184
+ * @param type - Content type for drag pick
185
+ * @param content - Content data for drag pick
186
+ */
187
+ Controls.prototype.setDragPickContent = function (type, content) {
188
+ var _this = this;
189
+ return new Promise(function (resolve, reject) {
190
+ // Set timeout
191
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
192
+ // Set drag pick content
193
+ _this.chn.emit('set:dragpick:content', { type: type, content: content }, function (error) {
194
+ if (error)
195
+ return reject(error);
196
+ clearTimeout(timeout);
197
+ resolve();
198
+ });
199
+ });
200
+ };
201
+ /**
202
+ * Get a location coordinates of placed that matched this name
203
+ *
204
+ * @param name - Place name to resolve
205
+ * @return - Array list of coordinates
206
+ */
207
+ Controls.prototype.resolvePlace = function (name) {
208
+ var _this = this;
209
+ return new Promise(function (resolve, reject) {
210
+ // Set timeout
211
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
212
+ // Get location coordinates from place name
213
+ _this.chn.emit('resolve:place', name, function (error, data) {
214
+ if (error)
215
+ return reject(error);
216
+ clearTimeout(timeout);
217
+ resolve(data);
218
+ });
219
+ });
220
+ };
221
+ /**
222
+ * Get a location details of placed that matched this coordinates
223
+ *
224
+ * @param coords - Coordinates
225
+ * @return - Array list of geocoding data
226
+ */
227
+ Controls.prototype.resolveCoordinates = function (coords) {
228
+ var _this = this;
229
+ return new Promise(function (resolve, reject) {
230
+ // Set timeout
231
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
232
+ // Get location place from coordinates
233
+ _this.chn.emit('resolve:coordinates', coords, function (error, data) {
234
+ if (error)
235
+ return reject(error);
236
+ clearTimeout(timeout);
237
+ resolve(data);
238
+ });
239
+ });
240
+ };
241
+ /**
242
+ * Search a location or places
243
+ *
244
+ * @param input - Place in string
245
+ * @return - Autocompletion list matched places
246
+ */
247
+ Controls.prototype.searchQuery = function (input) {
248
+ var _this = this;
249
+ return new Promise(function (resolve, reject) {
250
+ // Set timeout
251
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
252
+ // Launch search query
253
+ _this.chn.emit('search:query', input, function (error, data) {
254
+ if (error)
255
+ return reject(error);
256
+ clearTimeout(timeout);
257
+ resolve(data);
258
+ });
259
+ });
260
+ };
261
+ /**
262
+ * Select a suggested place by the search
263
+ *
264
+ * @param index - Index of place in suggested list
265
+ * @return - More details of selected place
266
+ */
267
+ Controls.prototype.searchSelect = function (index) {
268
+ var _this = this;
269
+ return new Promise(function (resolve, reject) {
270
+ // Set timeout
271
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
272
+ // Get place's details
273
+ _this.chn.emit('search:select', index, function (error, data) {
274
+ if (error)
275
+ return reject(error);
276
+ clearTimeout(timeout);
277
+ resolve(data);
278
+ });
279
+ });
280
+ };
281
+ /**
282
+ * Show nearby entities around coordinates
283
+ *
284
+ * @param list - Array of entity specifications
285
+ */
286
+ Controls.prototype.showNearby = function (list) {
287
+ var _this = this;
288
+ return new Promise(function (resolve, reject) {
289
+ // Set timeout
290
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
291
+ // Show nearby entities
292
+ _this.chn.emit('show:nearby', list, function (error) {
293
+ if (error)
294
+ return reject(error);
295
+ clearTimeout(timeout);
296
+ resolve();
297
+ });
298
+ });
299
+ };
300
+ /**
301
+ * Remove all displaying nearby entities
302
+ */
303
+ Controls.prototype.removeNearby = function () {
304
+ var _this = this;
305
+ return new Promise(function (resolve, reject) {
306
+ // Set timeout
307
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
308
+ // Remove nearby entities
309
+ _this.chn.emit('remove:nearby', function (error) {
310
+ if (error)
311
+ return reject(error);
312
+ clearTimeout(timeout);
313
+ resolve();
314
+ });
315
+ });
316
+ };
317
+ /**
318
+ * Add a new nearby entity
319
+ *
320
+ * @param entity - Entity specification
321
+ */
322
+ Controls.prototype.addNearbyEntity = function (entity) {
323
+ var _this = this;
324
+ return new Promise(function (resolve, reject) {
325
+ // Set timeout
326
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
327
+ // Add nearby entity
328
+ _this.chn.emit('add:nearby:entity', entity, function (error) {
329
+ if (error)
330
+ return reject(error);
331
+ clearTimeout(timeout);
332
+ resolve();
333
+ });
334
+ });
335
+ };
336
+ /**
337
+ * Update a nearby entity position
338
+ *
339
+ * @param activePosition - Entity ID and new position
340
+ */
341
+ Controls.prototype.moveNearbyEntity = function (activePosition) {
342
+ var _this = this;
343
+ return new Promise(function (resolve, reject) {
344
+ // Set timeout
345
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
346
+ // Move nearby entity
347
+ _this.chn.emit('move:nearby:entity', activePosition, function (error) {
348
+ if (error)
349
+ return reject(error);
350
+ clearTimeout(timeout);
351
+ resolve();
352
+ });
353
+ });
354
+ };
355
+ /**
356
+ * Remove a nearby entity
357
+ *
358
+ * @param id - Entity ID to remove
359
+ */
360
+ Controls.prototype.removeNearbyEntity = function (id) {
361
+ var _this = this;
362
+ return new Promise(function (resolve, reject) {
363
+ // Set timeout
364
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
365
+ // Remove nearby entity
366
+ _this.chn.emit('remove:nearby:entity', id, function (error) {
367
+ if (error)
368
+ return reject(error);
369
+ clearTimeout(timeout);
370
+ resolve();
371
+ });
372
+ });
373
+ };
374
+ /**
375
+ * Set complete route with journey specifications
376
+ *
377
+ * @param journey - Journey specifications including route ID, origin, destination, waypoints, and options
378
+ */
379
+ Controls.prototype.setRoute = function (journey) {
380
+ var _this = this;
381
+ return new Promise(function (resolve, reject) {
382
+ // Set timeout
383
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
384
+ // Set route
385
+ _this.chn.emit('set:route', journey, function (error) {
386
+ if (error)
387
+ return reject(error);
388
+ clearTimeout(timeout);
389
+ resolve();
390
+ });
391
+ });
392
+ };
393
+ /**
394
+ * Set route origin
395
+ *
396
+ * @param routeId - Route identifier
397
+ * @param point - Waypoint specification for origin
398
+ */
399
+ Controls.prototype.setRouteOrigin = function (routeId, point) {
400
+ var _this = this;
401
+ return new Promise(function (resolve, reject) {
402
+ // Set timeout
403
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
404
+ // Set route origin
405
+ _this.chn.emit('set:route:origin', { routeId: routeId, point: point }, function (error) {
406
+ if (error)
407
+ return reject(error);
408
+ clearTimeout(timeout);
409
+ resolve();
410
+ });
411
+ });
412
+ };
413
+ /**
414
+ * Remove route origin
415
+ *
416
+ * @param routeId - Route identifier
417
+ */
418
+ Controls.prototype.removeRouteOrigin = function (routeId) {
419
+ var _this = this;
420
+ return new Promise(function (resolve, reject) {
421
+ // Set timeout
422
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
423
+ // Remove route origin
424
+ _this.chn.emit('remove:route:origin', { routeId: routeId }, function (error) {
425
+ if (error)
426
+ return reject(error);
427
+ clearTimeout(timeout);
428
+ resolve();
429
+ });
430
+ });
431
+ };
432
+ /**
433
+ * Set route destination
434
+ *
435
+ * @param routeId - Route identifier
436
+ * @param point - Waypoint specification for destination
437
+ */
438
+ Controls.prototype.setRouteDestination = function (routeId, point) {
439
+ var _this = this;
440
+ return new Promise(function (resolve, reject) {
441
+ // Set timeout
442
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
443
+ // Set route destination
444
+ _this.chn.emit('set:route:destination', { routeId: routeId, point: point }, function (error) {
445
+ if (error)
446
+ return reject(error);
447
+ clearTimeout(timeout);
448
+ resolve();
449
+ });
450
+ });
451
+ };
452
+ /**
453
+ * Remove route destination
454
+ *
455
+ * @param routeId - Route identifier
456
+ */
457
+ Controls.prototype.removeRouteDestination = function (routeId) {
458
+ var _this = this;
459
+ return new Promise(function (resolve, reject) {
460
+ // Set timeout
461
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
462
+ // Remove route destination
463
+ _this.chn.emit('remove:route:destination', { routeId: routeId }, function (error) {
464
+ if (error)
465
+ return reject(error);
466
+ clearTimeout(timeout);
467
+ resolve();
468
+ });
469
+ });
470
+ };
471
+ /**
472
+ * Add a route waypoint
473
+ *
474
+ * @param routeId - Route identifier
475
+ * @param point - Waypoint specification
476
+ */
477
+ Controls.prototype.addRouteWaypoint = function (routeId, point) {
478
+ var _this = this;
479
+ return new Promise(function (resolve, reject) {
480
+ // Set timeout
481
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
482
+ // Add route waypoint
483
+ _this.chn.emit('add:route:waypoint', { routeId: routeId, point: point }, function (error) {
484
+ if (error)
485
+ return reject(error);
486
+ clearTimeout(timeout);
487
+ resolve();
488
+ });
489
+ });
490
+ };
491
+ /**
492
+ * Update a route waypoint
493
+ *
494
+ * @param routeId - Route identifier
495
+ * @param point - Waypoint specification with index
496
+ */
497
+ Controls.prototype.updateRouteWaypoint = function (routeId, point) {
498
+ var _this = this;
499
+ return new Promise(function (resolve, reject) {
500
+ // Set timeout
501
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
502
+ // Update route waypoint
503
+ _this.chn.emit('update:route:waypoint', { routeId: routeId, point: point }, function (error) {
504
+ if (error)
505
+ return reject(error);
506
+ clearTimeout(timeout);
507
+ resolve();
508
+ });
509
+ });
510
+ };
511
+ /**
512
+ * Remove a route waypoint
513
+ *
514
+ * @param routeId - Route identifier
515
+ * @param index - Waypoint index to remove
516
+ */
517
+ Controls.prototype.removeRouteWaypoint = function (routeId, index) {
518
+ var _this = this;
519
+ return new Promise(function (resolve, reject) {
520
+ // Set timeout
521
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
522
+ // Remove route waypoint
523
+ _this.chn.emit('remove:route:waypoint', { routeId: routeId, index: index }, function (error) {
524
+ if (error)
525
+ return reject(error);
526
+ clearTimeout(timeout);
527
+ resolve();
528
+ });
529
+ });
530
+ };
531
+ /**
532
+ * Fit route bounds
533
+ *
534
+ * @param routeId - Route identifier
535
+ * @param margin - Margin in px
536
+ */
537
+ Controls.prototype.fitRouteBounds = function (routeId, margin) {
538
+ var _this = this;
539
+ return new Promise(function (resolve, reject) {
540
+ // Set timeout
541
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
542
+ _this.chn.emit('fit:route:bounds', { routeId: routeId, margin: margin }, function (error) {
543
+ if (error)
544
+ return reject(error);
545
+ clearTimeout(timeout);
546
+ resolve();
547
+ });
548
+ });
549
+ };
550
+ /**
551
+ * Fit all/many routes bounds
552
+ *
553
+ * @param options - Routes fit bounds options
554
+ */
555
+ Controls.prototype.fitRoutesBounds = function (options) {
556
+ var _this = this;
557
+ return new Promise(function (resolve, reject) {
558
+ // Set timeout
559
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
560
+ _this.chn.emit('fit:routes:bounds', options, function (error) {
561
+ if (error)
562
+ return reject(error);
563
+ clearTimeout(timeout);
564
+ resolve();
565
+ });
566
+ });
567
+ };
568
+ /**
569
+ * Set waypoint caption
570
+ *
571
+ * @param routeId - Route identifier
572
+ * @param id - Waypoint identifier (string or number)
573
+ * @param caption - Caption information to set
574
+ */
575
+ Controls.prototype.setWaypointCaption = function (routeId, id, caption) {
576
+ var _this = this;
577
+ return new Promise(function (resolve, reject) {
578
+ // Set timeout
579
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
580
+ // Set waypoint caption
581
+ _this.chn.emit('set:waypoint:caption', { routeId: routeId, id: id, caption: caption }, function (error) {
582
+ if (error)
583
+ return reject(error);
584
+ clearTimeout(timeout);
585
+ resolve();
586
+ });
587
+ });
588
+ };
589
+ /**
590
+ * Update waypoint caption
591
+ *
592
+ * @param routeId - Route identifier
593
+ * @param id - Waypoint identifier (string or number)
594
+ * @param caption - Caption information to update
595
+ */
596
+ Controls.prototype.updateWaypointCaption = function (routeId, id, caption) {
597
+ var _this = this;
598
+ return new Promise(function (resolve, reject) {
599
+ // Set timeout
600
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
601
+ // Update waypoint caption
602
+ _this.chn.emit('update:waypoint:caption', { routeId: routeId, id: id, caption: caption }, function (error) {
603
+ if (error)
604
+ return reject(error);
605
+ clearTimeout(timeout);
606
+ resolve();
607
+ });
608
+ });
609
+ };
610
+ /**
611
+ * Remove waypoint caption
612
+ *
613
+ * @param routeId - Route identifier
614
+ * @param id - Waypoint identifier (string or number)
615
+ */
616
+ Controls.prototype.removeWaypointCaption = function (routeId, id) {
617
+ var _this = this;
618
+ return new Promise(function (resolve, reject) {
619
+ // Set timeout
620
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
621
+ // Remove waypoint caption
622
+ _this.chn.emit('remove:waypoint:caption', { routeId: routeId, id: id }, function (error) {
623
+ if (error)
624
+ return reject(error);
625
+ clearTimeout(timeout);
626
+ resolve();
627
+ });
628
+ });
629
+ };
630
+ /**
631
+ * Mount navigation route
632
+ *
633
+ * @param routeId - Route identifier for navigation
634
+ */
635
+ Controls.prototype.mountNavigation = function (routeId) {
636
+ var _this = this;
637
+ return new Promise(function (resolve, reject) {
638
+ // Set timeout
639
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
640
+ // Mount navigation
641
+ _this.chn.emit('mount:navigation', routeId, function (error) {
642
+ if (error)
643
+ return reject(error);
644
+ clearTimeout(timeout);
645
+ resolve();
646
+ });
647
+ });
648
+ };
649
+ /**
650
+ * Unmount navigation route
651
+ */
652
+ Controls.prototype.unmountNavigation = function () {
653
+ var _this = this;
654
+ return new Promise(function (resolve, reject) {
655
+ // Set timeout
656
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
657
+ // Unmount navigation
658
+ _this.chn.emit('unmount:navigation', function (error) {
659
+ if (error)
660
+ return reject(error);
661
+ clearTimeout(timeout);
662
+ resolve();
663
+ });
664
+ });
665
+ };
666
+ /**
667
+ * Load navigation direction
668
+ */
669
+ Controls.prototype.loadNavigation = function () {
670
+ var _this = this;
671
+ return new Promise(function (resolve, reject) {
672
+ // Set timeout
673
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
674
+ // Load navigation
675
+ _this.chn.emit('load:navigation', function (error) {
676
+ if (error)
677
+ return reject(error);
678
+ clearTimeout(timeout);
679
+ resolve();
680
+ });
681
+ });
682
+ };
683
+ /**
684
+ * Set initial navigation position
685
+ *
686
+ * @param position - Initial GPS location for navigation
687
+ */
688
+ Controls.prototype.setInitialNavigationPosition = function (position) {
689
+ var _this = this;
690
+ return new Promise(function (resolve, reject) {
691
+ // Set timeout
692
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
693
+ // Set initial navigation position
694
+ _this.chn.emit('initial:navigation:position', position, function (error) {
695
+ if (error)
696
+ return reject(error);
697
+ clearTimeout(timeout);
698
+ resolve();
699
+ });
700
+ });
701
+ };
702
+ /**
703
+ * Navigate to new position
704
+ *
705
+ * @param position - Current GPS location for navigation update
706
+ */
707
+ Controls.prototype.navigate = function (position) {
708
+ var _this = this;
709
+ return new Promise(function (resolve, reject) {
710
+ // Set timeout
711
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
712
+ // Navigate
713
+ _this.chn.emit('navigate:navigation:direction', position, function (error) {
714
+ if (error)
715
+ return reject(error);
716
+ clearTimeout(timeout);
717
+ resolve();
718
+ });
719
+ });
720
+ };
721
+ /**
722
+ * Upsert navigation direction data
723
+ *
724
+ * @param routeId - Route identifier for navigation
725
+ * @param direction - Direction data
726
+ * @param position - (Optional) Current GPS position
727
+ * @params options - Route options
728
+ */
729
+ Controls.prototype.casting = function (routeId, direction, position, options) {
730
+ var _this = this;
731
+ return new Promise(function (resolve, reject) {
732
+ // Set timeout
733
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
734
+ // Casting navigation direction
735
+ _this.chn.emit('casting:navigation:direction', { routeId: routeId, direction: direction, position: position, options: options }, function (error) {
736
+ if (error)
737
+ return reject(error);
738
+ clearTimeout(timeout);
739
+ resolve();
740
+ });
741
+ });
742
+ };
743
+ /**
744
+ * Dismiss navigation
745
+ */
746
+ Controls.prototype.dismissNavigation = function () {
747
+ var _this = this;
748
+ return new Promise(function (resolve, reject) {
749
+ // Set timeout
750
+ var timeout = setTimeout(function () { return reject(FUNCTION_EVENT_TIMEOUT_MESSAGE); }, FUNCTION_EVENT_TIMEOUT);
751
+ // Dismiss navigation
752
+ _this.chn.emit('dismiss:navigation', function (error) {
753
+ if (error)
754
+ return reject(error);
755
+ clearTimeout(timeout);
756
+ resolve();
757
+ });
758
+ });
759
+ };
760
+ return Controls;
761
+ }());
762
+ exports.default = Controls;
763
+ //# sourceMappingURL=Controls.js.map