@mappedin/blue-dot 6.0.1-beta.56 → 6.0.1-beta.58
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.
- package/README.md +124 -0
- package/lib/blue-dot.iife.js.map +4 -4
- package/lib/esm/chunk-TPJ6NPMJ.js +1560 -0
- package/lib/esm/chunk-TPJ6NPMJ.js.map +7 -0
- package/lib/esm/index.d.ts +221 -78
- package/lib/esm/index.js +6 -229
- package/lib/esm/index.js.map +3 -3
- package/lib/esm/react/index.d.ts +877 -0
- package/lib/esm/react/index.js +75 -0
- package/lib/esm/react/index.js.map +7 -0
- package/lib/rn/blue-dot.d.ts +188 -0
- package/lib/rn/constants.d.ts +11 -0
- package/lib/rn/index-rn.js +65 -24
- package/lib/rn/index-rn.js.map +3 -3
- package/lib/rn/model-manager.d.ts +24 -0
- package/lib/rn/rn/use-blue-dot.d.ts +11 -95
- package/lib/rn/schemas.d.ts +22 -0
- package/lib/rn/state-machine.d.ts +2 -0
- package/lib/rn/types.d.ts +80 -21
- package/lib/rn/utils.d.ts +75 -0
- package/package.json +33 -22
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
// Generated by dts-bundle v0.7.3
|
|
2
2
|
// Dependencies for this module:
|
|
3
|
-
// ../blue-dot/@packages/internal/common/pubsub
|
|
4
3
|
// ../blue-dot/@mappedin/mappedin-js
|
|
5
|
-
// ../blue-dot/
|
|
4
|
+
// ../blue-dot/@packages/internal/common/extensions
|
|
5
|
+
// ../blue-dot/@packages/internal/common/pubsub
|
|
6
6
|
// ../blue-dot/type-fest
|
|
7
|
+
// ../blue-dot/zod
|
|
8
|
+
// ../blue-dot/three
|
|
7
9
|
|
|
8
10
|
declare module '@mappedin/blue-dot' {
|
|
9
11
|
export { BlueDot } from '@mappedin/blue-dot/blue-dot/src/blue-dot';
|
|
10
|
-
export type { BlueDotEvents, BlueDotEventPayloads, BlueDotPositionUpdate,
|
|
12
|
+
export type { BlueDotEvents, BlueDotEventPayloads, BlueDotPositionUpdate, BlueDotStatus, BlueDotAction, FollowMode, FollowCameraOptions, BlueDotState, BlueDotPositionProcessor, BlueDotPositionUpdateWithFloor, BlueDotUpdateOptions, GeolocationPositionExtended, } from '@mappedin/blue-dot/blue-dot/src/types';
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
declare module '@mappedin/blue-dot/blue-dot/src/blue-dot' {
|
|
16
|
+
import type { Floor, MapView, Model } from '@mappedin/mappedin-js';
|
|
17
|
+
import { Coordinate } from '@mappedin/mappedin-js';
|
|
18
|
+
import type { MapViewExtension } from '@packages/internal/common/extensions';
|
|
14
19
|
import { PubSub } from '@packages/internal/common/pubsub';
|
|
15
|
-
import type {
|
|
16
|
-
import type {
|
|
20
|
+
import type { BlueDotEventPayloads, BlueDotState, BlueDotPositionProcessor, BlueDotPositionUpdate, BlueDotStatus, BlueDotUpdateOptions, FollowCameraOptions, FollowMode, GeolocationPositionExtended, BlueDotUpdateState } from '@mappedin/blue-dot/blue-dot/src/types';
|
|
21
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
17
22
|
/**
|
|
18
23
|
* Show a Blue Dot indicating the device's position on the map.
|
|
19
24
|
*
|
|
@@ -37,45 +42,62 @@ declare module '@mappedin/blue-dot/blue-dot/src/blue-dot' {
|
|
|
37
42
|
*
|
|
38
43
|
* ```
|
|
39
44
|
*/
|
|
40
|
-
export class BlueDot {
|
|
45
|
+
export class BlueDot implements MapViewExtension<BlueDotState> {
|
|
41
46
|
#private;
|
|
42
47
|
/**
|
|
43
48
|
* Create a new {@link BlueDot} instance.
|
|
44
49
|
*/
|
|
45
50
|
constructor(mapView: MapView);
|
|
51
|
+
/**
|
|
52
|
+
* Get the Model for the BlueDot core element.
|
|
53
|
+
*/
|
|
54
|
+
get dotModel(): Model | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Get the Model for the accuracy ring.
|
|
57
|
+
*/
|
|
58
|
+
get accuracyRingModel(): Model | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Get the Model for the heading cone.
|
|
61
|
+
*/
|
|
62
|
+
get headingConeModel(): Model | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the BlueDot is currently enabled.
|
|
65
|
+
*/
|
|
66
|
+
get isEnabled(): boolean;
|
|
46
67
|
/**
|
|
47
68
|
* The current state of the BlueDot. Can be 'hidden', 'active', 'inactive', or 'disabled'.
|
|
48
|
-
* Listen for state changes using the '
|
|
69
|
+
* Listen for state changes using the 'status-change' event.
|
|
49
70
|
*
|
|
50
71
|
* @example
|
|
51
|
-
* mapView.BlueDot.on('
|
|
52
|
-
* if (
|
|
72
|
+
* mapView.BlueDot.on('status-change', ({ status }) => {
|
|
73
|
+
* if (status === 'active') {
|
|
53
74
|
* // BlueDot is visible and tracking
|
|
54
75
|
* }
|
|
55
76
|
* });
|
|
56
77
|
*/
|
|
57
|
-
get
|
|
78
|
+
get status(): BlueDotStatus;
|
|
58
79
|
/**
|
|
59
80
|
* Whether the BlueDot is currently following the user (camera follow mode).
|
|
60
81
|
*/
|
|
61
|
-
get
|
|
82
|
+
get isFollowing(): boolean;
|
|
62
83
|
/**
|
|
63
84
|
* The direction the user is facing in degrees from north clockwise.
|
|
64
85
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/GeolocationCoordinates/heading
|
|
65
86
|
*/
|
|
66
|
-
get heading():
|
|
87
|
+
get heading(): GeolocationPosition['coords']['heading'] | undefined;
|
|
67
88
|
/**
|
|
68
89
|
* The accuracy of the current position in metres.
|
|
69
90
|
*/
|
|
70
|
-
get accuracy():
|
|
91
|
+
get accuracy(): GeolocationPosition['coords']['accuracy'] | undefined;
|
|
71
92
|
/**
|
|
72
93
|
* The coordinate of the current position.
|
|
73
94
|
*/
|
|
74
|
-
get coordinate():
|
|
95
|
+
get coordinate(): Coordinate | undefined;
|
|
96
|
+
getState: () => ReadonlyDeep<BlueDotState>;
|
|
75
97
|
/**
|
|
76
98
|
* The floor the Blue Dot is currently on. If undefined, the Blue Dot will appear on every floor.
|
|
77
99
|
*/
|
|
78
|
-
get floor():
|
|
100
|
+
get floor(): Floor | undefined;
|
|
79
101
|
/**
|
|
80
102
|
* Enable the Blue Dot. It will be hidden until a position is received either from the browser or by calling {@link BlueDot.update}.
|
|
81
103
|
* @param options - The options to setup the Blue Dot (see {@link BlueDotOptions}).
|
|
@@ -88,19 +110,41 @@ declare module '@mappedin/blue-dot/blue-dot/src/blue-dot' {
|
|
|
88
110
|
*
|
|
89
111
|
* @see See the [BlueDot Guide](https://developer.mappedin.com/web-sdk/blue-dot) for more information.
|
|
90
112
|
*/
|
|
91
|
-
enable: (options?:
|
|
113
|
+
enable: (options?: BlueDotUpdateState) => void;
|
|
92
114
|
/**
|
|
93
115
|
* Disable the Blue Dot. It will be hidden and no longer update.
|
|
94
116
|
*/
|
|
95
117
|
disable: () => void;
|
|
118
|
+
/**
|
|
119
|
+
* Subscribe to a BlueDot event.
|
|
120
|
+
* @param eventName The name of the event to listen for.
|
|
121
|
+
* @param fn The function to call when the event is emitted.
|
|
122
|
+
*/
|
|
96
123
|
on: PubSub<BlueDotEventPayloads>['on'];
|
|
124
|
+
/**
|
|
125
|
+
* Unsubscribe from a BlueDot event.
|
|
126
|
+
* @param eventName The name of the event to unsubscribe from.
|
|
127
|
+
* @param fn The function to unsubscribe from the event.
|
|
128
|
+
*/
|
|
97
129
|
off: PubSub<BlueDotEventPayloads>['off'];
|
|
130
|
+
/**
|
|
131
|
+
* Update the BlueDot state after it has been enabled.
|
|
132
|
+
* This allows overriding previously set values like colors, and other options.
|
|
133
|
+
* @param options - The options to update
|
|
134
|
+
*
|
|
135
|
+
* @example Update color and accuracy ring
|
|
136
|
+
* mapView.BlueDot.updateState({
|
|
137
|
+
* color: '#ff0000',
|
|
138
|
+
* accuracyRing: { color: '#ff0000', opacity: 0.5 }
|
|
139
|
+
* });
|
|
140
|
+
*/
|
|
141
|
+
updateState: (options: BlueDotUpdateState) => void;
|
|
98
142
|
/**
|
|
99
143
|
* Enable or disable the devices's geolocation listener to automatically position the Blue Dot.
|
|
100
144
|
* If enabled, the device will request permission to access the user's precise location.
|
|
101
145
|
* @param watch - Whether to enable or disable the listener.
|
|
102
146
|
*/
|
|
103
|
-
watchDevicePosition: (watch
|
|
147
|
+
watchDevicePosition: (watch: boolean) => void;
|
|
104
148
|
/**
|
|
105
149
|
* Manually override some position properties of the Blue Dot.
|
|
106
150
|
* Accepts a full GeolocationPosition object or a partial {@link BlueDotPositionUpdate} object.
|
|
@@ -113,7 +157,7 @@ declare module '@mappedin/blue-dot/blue-dot/src/blue-dot' {
|
|
|
113
157
|
* api.BlueDot.update({ accuracy: 'device', heading: 'device' });
|
|
114
158
|
* ```
|
|
115
159
|
*/
|
|
116
|
-
update: (position: BlueDotPositionUpdate) => void;
|
|
160
|
+
update: (position: GeolocationPositionExtended | BlueDotPositionUpdate | undefined, options?: BlueDotUpdateOptions) => void;
|
|
117
161
|
/**
|
|
118
162
|
* Set the camera to follow the BlueDot in various modes. User interaction will cancel following automatically.
|
|
119
163
|
* @param mode The follow mode ('position-only', 'position-and-heading', 'position-and-path-direction', or false to disable).
|
|
@@ -123,13 +167,46 @@ declare module '@mappedin/blue-dot/blue-dot/src/blue-dot' {
|
|
|
123
167
|
* mapView.BlueDot.follow('position-and-heading', { zoomLevel: 21, pitch: 45 });
|
|
124
168
|
*/
|
|
125
169
|
follow: (mode: FollowMode, cameraOptions?: FollowCameraOptions) => void;
|
|
170
|
+
/**
|
|
171
|
+
* Set a position processor callback that allows intercepting and modifying device/geolocation position updates before they are applied.
|
|
172
|
+
*
|
|
173
|
+
* **Note**: This processor only applies to automatic position updates from device geolocation.
|
|
174
|
+
* Manual position updates via `update()` method bypass the processor and are applied directly.
|
|
175
|
+
*
|
|
176
|
+
* @param processor - A callback function that receives current state and incoming update. Return undefined to discard the update, or return a modified update object.
|
|
177
|
+
*
|
|
178
|
+
* @example Discard inaccurate positions
|
|
179
|
+
* ```ts
|
|
180
|
+
* blueDot.setPositionProcessor((current, incoming) => {
|
|
181
|
+
* if (incoming.accuracy && incoming.accuracy > 50) {
|
|
182
|
+
* return undefined; // Discard update
|
|
183
|
+
* }
|
|
184
|
+
* return incoming; // Accept update
|
|
185
|
+
* });
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @example Modify incoming positions
|
|
189
|
+
* ```ts
|
|
190
|
+
* blueDot.setPositionProcessor((current, incoming) => {
|
|
191
|
+
* // Apply custom smoothing or validation logic
|
|
192
|
+
* return {
|
|
193
|
+
* ...incoming,
|
|
194
|
+
* accuracy: Math.min(incoming.accuracy || 100, 10) // Cap accuracy
|
|
195
|
+
* };
|
|
196
|
+
* });
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
setPositionProcessor(processor?: BlueDotPositionProcessor): void;
|
|
126
200
|
destroy: () => void;
|
|
127
201
|
}
|
|
128
202
|
}
|
|
129
203
|
|
|
130
204
|
declare module '@mappedin/blue-dot/blue-dot/src/types' {
|
|
131
205
|
import type { Coordinate, Floor } from '@mappedin/mappedin-js';
|
|
206
|
+
import type z from 'zod';
|
|
132
207
|
import type { EasingCurve } from '@mappedin/blue-dot/packages/common';
|
|
208
|
+
import type { positionSchema } from '@mappedin/blue-dot/blue-dot/src/schemas';
|
|
209
|
+
import type { PartialDeep } from 'type-fest';
|
|
133
210
|
export type FollowMode =
|
|
134
211
|
/** Camera position follows the Blue Dot's position. */
|
|
135
212
|
'position-only'
|
|
@@ -178,15 +255,15 @@ declare module '@mappedin/blue-dot/blue-dot/src/types' {
|
|
|
178
255
|
coordinate: Coordinate;
|
|
179
256
|
};
|
|
180
257
|
/**
|
|
181
|
-
* Emitted when the Blue Dot's
|
|
258
|
+
* Emitted when the Blue Dot's status changes.
|
|
182
259
|
*/
|
|
183
|
-
'
|
|
260
|
+
'status-change': {
|
|
184
261
|
/**
|
|
185
|
-
* The new
|
|
262
|
+
* The new status of the Blue Dot.
|
|
186
263
|
*/
|
|
187
|
-
|
|
264
|
+
status: BlueDotStatus;
|
|
188
265
|
/**
|
|
189
|
-
* The action that caused the
|
|
266
|
+
* The action that caused the status change.
|
|
190
267
|
*/
|
|
191
268
|
action: BlueDotAction;
|
|
192
269
|
};
|
|
@@ -216,79 +293,98 @@ declare module '@mappedin/blue-dot/blue-dot/src/types' {
|
|
|
216
293
|
/**
|
|
217
294
|
* Emitted when the user hovers over the Blue Dot.
|
|
218
295
|
*/
|
|
219
|
-
hover:
|
|
296
|
+
hover: {
|
|
297
|
+
coordinate: Coordinate;
|
|
298
|
+
};
|
|
220
299
|
};
|
|
221
300
|
export type BlueDotEvents = keyof BlueDotEventPayloads;
|
|
222
|
-
export type
|
|
301
|
+
export type BlueDotStatus = 'hidden' | 'active' | 'inactive' | 'disabled';
|
|
223
302
|
export type BlueDotAction = 'timeout' | 'error' | 'position-update' | 'enable' | 'disable' | 'initialize';
|
|
224
|
-
export type
|
|
303
|
+
export type BlueDotState = {
|
|
225
304
|
/**
|
|
226
305
|
* The radius of the BlueDot in pixels. The BlueDot will maintain this size clamped to a minimum of 0.35 metres.
|
|
227
306
|
* @default 10
|
|
228
307
|
*/
|
|
229
|
-
radius
|
|
308
|
+
radius: number;
|
|
230
309
|
/**
|
|
231
310
|
* The color of the BlueDot core element.
|
|
232
311
|
* @default #2266ff
|
|
233
312
|
*/
|
|
234
|
-
color
|
|
313
|
+
color: string;
|
|
235
314
|
/**
|
|
236
315
|
* The color of the BlueDot when it has timed out and gone inactive.
|
|
237
316
|
* @default #808080
|
|
238
317
|
*/
|
|
239
|
-
inactiveColor
|
|
318
|
+
inactiveColor: string;
|
|
240
319
|
/**
|
|
241
320
|
* Options for the accuracy ring around the BlueDot.
|
|
242
321
|
*/
|
|
243
|
-
accuracyRing
|
|
322
|
+
accuracyRing: {
|
|
244
323
|
/**
|
|
245
324
|
* The color of the accuracy ring.
|
|
246
325
|
* @default #2266ff
|
|
247
326
|
*/
|
|
248
|
-
color
|
|
327
|
+
color: string;
|
|
249
328
|
/**
|
|
250
329
|
* The opacity of the accuracy ring.
|
|
251
330
|
* @default 0.3
|
|
252
331
|
*/
|
|
253
|
-
opacity
|
|
332
|
+
opacity: number;
|
|
254
333
|
};
|
|
255
334
|
/**
|
|
256
335
|
* Options for the heading directional indicator.
|
|
257
336
|
*/
|
|
258
|
-
heading
|
|
337
|
+
heading: {
|
|
259
338
|
/**
|
|
260
339
|
* The color of the heading cone.
|
|
261
340
|
* @default #2266ff
|
|
262
341
|
*/
|
|
263
|
-
color
|
|
342
|
+
color: string;
|
|
264
343
|
/**
|
|
265
344
|
* The opacity of the heading cone.
|
|
266
345
|
* @default 0.7
|
|
267
346
|
*/
|
|
268
|
-
opacity
|
|
347
|
+
opacity: number;
|
|
348
|
+
/**
|
|
349
|
+
* Whether to display the heading cone when the BlueDot is inactive (timed out).
|
|
350
|
+
* @default false
|
|
351
|
+
*/
|
|
352
|
+
displayWhenInactive: boolean;
|
|
269
353
|
};
|
|
270
354
|
/**
|
|
271
355
|
* The duration of the timeout in milliseconds.
|
|
272
356
|
* If the BlueDot does not receive a position update within this time, it will grey out until a position is received.
|
|
273
357
|
* @default 30000
|
|
274
358
|
*/
|
|
275
|
-
timeout
|
|
359
|
+
timeout: number;
|
|
276
360
|
/**
|
|
277
361
|
* Whether to watch the device's position.
|
|
278
362
|
* @default true
|
|
279
363
|
*/
|
|
280
|
-
watchDevicePosition
|
|
364
|
+
watchDevicePosition: boolean;
|
|
281
365
|
/**
|
|
282
366
|
* Whether to log debug messages.
|
|
283
367
|
* @default false
|
|
284
368
|
*/
|
|
285
|
-
debug
|
|
369
|
+
debug: boolean;
|
|
286
370
|
/**
|
|
287
371
|
* The maximum acceptable accuracy in meters. Position updates with accuracy exceeding this value will be dropped.
|
|
288
372
|
* @default 50
|
|
289
373
|
*/
|
|
290
|
-
accuracyThreshold
|
|
374
|
+
accuracyThreshold: number;
|
|
375
|
+
/**
|
|
376
|
+
* The initial state of the BlueDot when enabled.
|
|
377
|
+
* @default 'hidden'
|
|
378
|
+
*/
|
|
379
|
+
initialState: 'hidden' | 'inactive';
|
|
380
|
+
/**
|
|
381
|
+
* @hidden
|
|
382
|
+
* Whether the BlueDot must remain within the map bounds. Disabling this will disable analytics as well.
|
|
383
|
+
* @default true
|
|
384
|
+
*/
|
|
385
|
+
preventOutOfBounds: boolean;
|
|
291
386
|
};
|
|
387
|
+
export type BlueDotUpdateState = PartialDeep<BlueDotState>;
|
|
292
388
|
/**
|
|
293
389
|
* Position update options for the {@link BlueDot.update} method.
|
|
294
390
|
*/
|
|
@@ -321,6 +417,43 @@ declare module '@mappedin/blue-dot/blue-dot/src/types' {
|
|
|
321
417
|
* Set to `undefined` to disable floor level and show the BlueDot on all floors.
|
|
322
418
|
*/
|
|
323
419
|
floorOrFloorId?: Floor | string | 'device' | undefined;
|
|
420
|
+
/**
|
|
421
|
+
* Timestamp of the position update in milliseconds.
|
|
422
|
+
*/
|
|
423
|
+
timestamp?: number;
|
|
424
|
+
};
|
|
425
|
+
export type BlueDotPositionUpdateWithFloor = Omit<BlueDotPositionUpdate, 'floorOrFloorId'> & {
|
|
426
|
+
floor?: Floor | 'device' | undefined;
|
|
427
|
+
};
|
|
428
|
+
export type ParsedBlueDotPosition = z.infer<typeof positionSchema>;
|
|
429
|
+
export type BlueDotPositionProcessor = (current: BlueDotPositionUpdateWithFloor, incoming: BlueDotPositionUpdateWithFloor) => BlueDotPositionUpdateWithFloor | undefined;
|
|
430
|
+
export type StateTransitions = {
|
|
431
|
+
[Action in BlueDotAction]?: BlueDotStatus;
|
|
432
|
+
};
|
|
433
|
+
export type StateMachine = {
|
|
434
|
+
[State in BlueDotStatus]: {
|
|
435
|
+
actions: StateTransitions;
|
|
436
|
+
};
|
|
437
|
+
};
|
|
438
|
+
/**
|
|
439
|
+
* Options for the BlueDot update method.
|
|
440
|
+
*/
|
|
441
|
+
export type BlueDotUpdateOptions = {
|
|
442
|
+
/**
|
|
443
|
+
* If true, maintains the current state and skips timers and analytics for this update.
|
|
444
|
+
* @default false
|
|
445
|
+
*/
|
|
446
|
+
silent?: boolean;
|
|
447
|
+
/**
|
|
448
|
+
* If true, animates the position change. If false, updates immediately.
|
|
449
|
+
* @default true
|
|
450
|
+
*/
|
|
451
|
+
animate?: boolean;
|
|
452
|
+
};
|
|
453
|
+
export type GeolocationPositionExtended = GeolocationPosition & {
|
|
454
|
+
coords: GeolocationPosition['coords'] & {
|
|
455
|
+
readonly floorLevel?: number;
|
|
456
|
+
};
|
|
324
457
|
};
|
|
325
458
|
}
|
|
326
459
|
|
|
@@ -336,7 +469,31 @@ declare module '@mappedin/blue-dot/packages/common' {
|
|
|
336
469
|
export { Logger };
|
|
337
470
|
export * from '@mappedin/blue-dot/packages/common/color';
|
|
338
471
|
export * from '@mappedin/blue-dot/packages/common/interpolate';
|
|
339
|
-
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
declare module '@mappedin/blue-dot/blue-dot/src/schemas' {
|
|
475
|
+
import z from 'zod';
|
|
476
|
+
export const geolocationPositionSchema: z.ZodObject<{
|
|
477
|
+
coords: z.ZodObject<{
|
|
478
|
+
latitude: z.ZodNumber;
|
|
479
|
+
longitude: z.ZodNumber;
|
|
480
|
+
accuracy: z.ZodNumber;
|
|
481
|
+
altitude: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
482
|
+
altitudeAccuracy: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
483
|
+
heading: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
484
|
+
speed: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
485
|
+
floorLevel: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
486
|
+
}, z.core.$strip>;
|
|
487
|
+
timestamp: z.ZodNumber;
|
|
488
|
+
}, z.core.$strip>;
|
|
489
|
+
export const positionSchema: z.ZodObject<{
|
|
490
|
+
latitude: z.ZodNumber;
|
|
491
|
+
longitude: z.ZodNumber;
|
|
492
|
+
floor: z.ZodOptional<z.ZodAny>;
|
|
493
|
+
accuracy: z.ZodOptional<z.ZodNumber>;
|
|
494
|
+
heading: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
495
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
496
|
+
}, z.core.$strip>;
|
|
340
497
|
}
|
|
341
498
|
|
|
342
499
|
declare module '@mappedin/blue-dot/packages/common/Mappedin.Logger' {
|
|
@@ -449,6 +606,30 @@ declare module '@mappedin/blue-dot/packages/common/utils' {
|
|
|
449
606
|
export { clampWithWarning } from '@mappedin/blue-dot/packages/common/math-utils';
|
|
450
607
|
export { arraysEqual } from '@mappedin/blue-dot/packages/common/array-utils';
|
|
451
608
|
export function isBrowser(): boolean;
|
|
609
|
+
/**
|
|
610
|
+
* Calculates the simple Euclidean distance between two geographic coordinates.
|
|
611
|
+
*
|
|
612
|
+
* This treats longitude and latitude as Cartesian coordinates on a flat plane.
|
|
613
|
+
* It's the fastest distance calculation but least accurate for geographic data.
|
|
614
|
+
* Best used for relative distance comparisons rather than actual measurements.
|
|
615
|
+
*
|
|
616
|
+
* @param point1 - The first point's longitude and latitude as [longitude, latitude].
|
|
617
|
+
* @param point2 - The second point's longitude and latitude as [longitude, latitude].
|
|
618
|
+
* @returns The Euclidean distance between the two points in meters.
|
|
619
|
+
*/
|
|
620
|
+
export function euclideanDistance(point1: Position, point2: Position): number;
|
|
621
|
+
/**
|
|
622
|
+
* Calculates the approximate distance between two geographic coordinates on Earth's surface.
|
|
623
|
+
*
|
|
624
|
+
* This function uses the equirectangular approximation method to compute the distance, which simplifies
|
|
625
|
+
* the math and speeds up calculations, but is less accurate over long distances compared to other methods
|
|
626
|
+
* like the haversine formula.
|
|
627
|
+
*
|
|
628
|
+
* @param point1 - The first point's longitude and latitude as [longitude, latitude].
|
|
629
|
+
* @param point2 - The second point's longitude and latitude as [longitude, latitude].
|
|
630
|
+
* @returns The approximate distance between the two points in meters.
|
|
631
|
+
*/
|
|
632
|
+
export function equirectangularDistance(point1: Position, point2: Position): number;
|
|
452
633
|
}
|
|
453
634
|
|
|
454
635
|
declare module '@mappedin/blue-dot/packages/common/async' {
|
|
@@ -670,44 +851,6 @@ declare module '@mappedin/blue-dot/packages/common/interpolate' {
|
|
|
670
851
|
export function interpolateMulti(value: number, inputRange: number[], outputRange: number[], easeFunc?: EasingCurve | ((t: number) => number)): number;
|
|
671
852
|
}
|
|
672
853
|
|
|
673
|
-
declare module '@mappedin/blue-dot/packages/common/type-utils' {
|
|
674
|
-
import type { SetOptional } from 'type-fest';
|
|
675
|
-
type Primitive = string | number | boolean | null | undefined;
|
|
676
|
-
export type PartialExcept<T, K extends string> = {
|
|
677
|
-
[P in keyof T as P extends K ? P : never]: T[P];
|
|
678
|
-
} & {
|
|
679
|
-
[P in keyof T as P extends K ? never : P]?: T[P] extends Primitive ? T[P] : T[P] extends (infer U)[] ? PartialExcept<U, K>[] : PartialExcept<T[P], K>;
|
|
680
|
-
};
|
|
681
|
-
/**
|
|
682
|
-
* Utility type that extracts nested values matching a specific type with recursion depth limit
|
|
683
|
-
* @example
|
|
684
|
-
* type A = ExtractDeep<{ a: { b: string; c: number; }; d: string; e: number; }, number>;
|
|
685
|
-
* // { a: { c: number; } e: number; }
|
|
686
|
-
*/
|
|
687
|
-
export type ExtractDeep<T, U, Depth extends readonly number[] = []> = Depth['length'] extends 3 ? any : {
|
|
688
|
-
[K in keyof T as T[K] extends U ? K : T[K] extends object | undefined ? ExtractDeep<NonNullable<T[K]>, U, [...Depth, 0]> extends never ? never : K : never]: T[K] extends object | undefined ? undefined extends T[K] ? ExtractDeep<NonNullable<T[K]>, U, [...Depth, 0]> | undefined : ExtractDeep<NonNullable<T[K]>, U, [...Depth, 0]> : T[K] extends U ? T[K] : never;
|
|
689
|
-
};
|
|
690
|
-
/**
|
|
691
|
-
* Utility type that makes all properties of a type required, but allows undefined values
|
|
692
|
-
* to satisfy the required type.
|
|
693
|
-
* https://medium.com/terria/typescript-transforming-optional-properties-to-required-properties-that-may-be-undefined-7482cb4e1585
|
|
694
|
-
* @example
|
|
695
|
-
* type A = Complete<{ a: string; b: number; c: undefined; }>;
|
|
696
|
-
* // { a: string; b: number; c: undefined; }
|
|
697
|
-
*/
|
|
698
|
-
export type Complete<T> = {
|
|
699
|
-
[P in keyof Required<T>]: Pick<T, P> extends Required<Pick<T, P>> ? T[P] : T[P] | undefined;
|
|
700
|
-
};
|
|
701
|
-
/**
|
|
702
|
-
* Utility type that makes all properties required except for the ones specified in the second argument.
|
|
703
|
-
* @example
|
|
704
|
-
* type A = RequiredExcept<{ a: string; b: number; c: undefined; }, 'c'>;
|
|
705
|
-
* // { a: string; b: number; c?: undefined; }
|
|
706
|
-
*/
|
|
707
|
-
export type RequiredExcept<T, K extends keyof T> = SetOptional<Required<T>, K>;
|
|
708
|
-
export {};
|
|
709
|
-
}
|
|
710
|
-
|
|
711
854
|
declare module '@mappedin/blue-dot/packages/common/math-utils' {
|
|
712
855
|
/**
|
|
713
856
|
* Clamp a number between lower and upper bounds with a warning
|