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