@mappedin/blue-dot 6.0.1-beta.57 → 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.
@@ -1,18 +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
4
+ // ../blue-dot/@packages/internal/common/extensions
5
+ // ../blue-dot/@packages/internal/common/pubsub
6
+ // ../blue-dot/type-fest
7
+ // ../blue-dot/zod
5
8
  // ../blue-dot/three
6
9
 
7
10
  declare module '@mappedin/blue-dot' {
8
11
  export { BlueDot } from '@mappedin/blue-dot/blue-dot/src/blue-dot';
9
- export type { BlueDotEvents, BlueDotEventPayloads, BlueDotPositionUpdate, BlueDotState, BlueDotAction, FollowMode, FollowCameraOptions, BlueDotOptions, } from '@mappedin/blue-dot/blue-dot/src/types';
12
+ export type { BlueDotEvents, BlueDotEventPayloads, BlueDotPositionUpdate, BlueDotStatus, BlueDotAction, FollowMode, FollowCameraOptions, BlueDotState, BlueDotPositionProcessor, BlueDotPositionUpdateWithFloor, BlueDotUpdateOptions, GeolocationPositionExtended, } from '@mappedin/blue-dot/blue-dot/src/types';
10
13
  }
11
14
 
12
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';
13
19
  import { PubSub } from '@packages/internal/common/pubsub';
14
- import type { MapView } from '@mappedin/mappedin-js';
15
- import type { BlueDotEventPayloads, BlueDotOptions, BlueDotPositionUpdate, BlueDotState, FollowCameraOptions, FollowMode } from '@mappedin/blue-dot/blue-dot/src/types';
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';
16
22
  /**
17
23
  * Show a Blue Dot indicating the device's position on the map.
18
24
  *
@@ -36,45 +42,62 @@ declare module '@mappedin/blue-dot/blue-dot/src/blue-dot' {
36
42
  *
37
43
  * ```
38
44
  */
39
- export class BlueDot {
45
+ export class BlueDot implements MapViewExtension<BlueDotState> {
40
46
  #private;
41
47
  /**
42
48
  * Create a new {@link BlueDot} instance.
43
49
  */
44
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;
45
67
  /**
46
68
  * The current state of the BlueDot. Can be 'hidden', 'active', 'inactive', or 'disabled'.
47
- * Listen for state changes using the 'state-change' event.
69
+ * Listen for state changes using the 'status-change' event.
48
70
  *
49
71
  * @example
50
- * mapView.BlueDot.on('state-change', ({ state }) => {
51
- * if (state === 'active') {
72
+ * mapView.BlueDot.on('status-change', ({ status }) => {
73
+ * if (status === 'active') {
52
74
  * // BlueDot is visible and tracking
53
75
  * }
54
76
  * });
55
77
  */
56
- get state(): BlueDotState;
78
+ get status(): BlueDotStatus;
57
79
  /**
58
80
  * Whether the BlueDot is currently following the user (camera follow mode).
59
81
  */
60
- get following(): boolean;
82
+ get isFollowing(): boolean;
61
83
  /**
62
84
  * The direction the user is facing in degrees from north clockwise.
63
85
  * @see https://developer.mozilla.org/en-US/docs/Web/API/GeolocationCoordinates/heading
64
86
  */
65
- get heading(): number | null | undefined;
87
+ get heading(): GeolocationPosition['coords']['heading'] | undefined;
66
88
  /**
67
89
  * The accuracy of the current position in metres.
68
90
  */
69
- get accuracy(): number | undefined;
91
+ get accuracy(): GeolocationPosition['coords']['accuracy'] | undefined;
70
92
  /**
71
93
  * The coordinate of the current position.
72
94
  */
73
- get coordinate(): import("@mappedin/mappedin-js").Coordinate | undefined;
95
+ get coordinate(): Coordinate | undefined;
96
+ getState: () => ReadonlyDeep<BlueDotState>;
74
97
  /**
75
98
  * The floor the Blue Dot is currently on. If undefined, the Blue Dot will appear on every floor.
76
99
  */
77
- get floor(): import("@mappedin/mappedin-js").Floor | undefined;
100
+ get floor(): Floor | undefined;
78
101
  /**
79
102
  * Enable the Blue Dot. It will be hidden until a position is received either from the browser or by calling {@link BlueDot.update}.
80
103
  * @param options - The options to setup the Blue Dot (see {@link BlueDotOptions}).
@@ -87,19 +110,41 @@ declare module '@mappedin/blue-dot/blue-dot/src/blue-dot' {
87
110
  *
88
111
  * @see See the [BlueDot Guide](https://developer.mappedin.com/web-sdk/blue-dot) for more information.
89
112
  */
90
- enable: (options?: BlueDotOptions) => void;
113
+ enable: (options?: BlueDotUpdateState) => void;
91
114
  /**
92
115
  * Disable the Blue Dot. It will be hidden and no longer update.
93
116
  */
94
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
+ */
95
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
+ */
96
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;
97
142
  /**
98
143
  * Enable or disable the devices's geolocation listener to automatically position the Blue Dot.
99
144
  * If enabled, the device will request permission to access the user's precise location.
100
145
  * @param watch - Whether to enable or disable the listener.
101
146
  */
102
- watchDevicePosition: (watch?: boolean) => void;
147
+ watchDevicePosition: (watch: boolean) => void;
103
148
  /**
104
149
  * Manually override some position properties of the Blue Dot.
105
150
  * Accepts a full GeolocationPosition object or a partial {@link BlueDotPositionUpdate} object.
@@ -112,7 +157,7 @@ declare module '@mappedin/blue-dot/blue-dot/src/blue-dot' {
112
157
  * api.BlueDot.update({ accuracy: 'device', heading: 'device' });
113
158
  * ```
114
159
  */
115
- update: (position: BlueDotPositionUpdate) => void;
160
+ update: (position: GeolocationPositionExtended | BlueDotPositionUpdate | undefined, options?: BlueDotUpdateOptions) => void;
116
161
  /**
117
162
  * Set the camera to follow the BlueDot in various modes. User interaction will cancel following automatically.
118
163
  * @param mode The follow mode ('position-only', 'position-and-heading', 'position-and-path-direction', or false to disable).
@@ -122,13 +167,46 @@ declare module '@mappedin/blue-dot/blue-dot/src/blue-dot' {
122
167
  * mapView.BlueDot.follow('position-and-heading', { zoomLevel: 21, pitch: 45 });
123
168
  */
124
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;
125
200
  destroy: () => void;
126
201
  }
127
202
  }
128
203
 
129
204
  declare module '@mappedin/blue-dot/blue-dot/src/types' {
130
205
  import type { Coordinate, Floor } from '@mappedin/mappedin-js';
206
+ import type z from 'zod';
131
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';
132
210
  export type FollowMode =
133
211
  /** Camera position follows the Blue Dot's position. */
134
212
  'position-only'
@@ -177,15 +255,15 @@ declare module '@mappedin/blue-dot/blue-dot/src/types' {
177
255
  coordinate: Coordinate;
178
256
  };
179
257
  /**
180
- * Emitted when the Blue Dot's state changes.
258
+ * Emitted when the Blue Dot's status changes.
181
259
  */
182
- 'state-change': {
260
+ 'status-change': {
183
261
  /**
184
- * The new state of the Blue Dot.
262
+ * The new status of the Blue Dot.
185
263
  */
186
- state: BlueDotState;
264
+ status: BlueDotStatus;
187
265
  /**
188
- * The action that caused the state change.
266
+ * The action that caused the status change.
189
267
  */
190
268
  action: BlueDotAction;
191
269
  };
@@ -215,79 +293,98 @@ declare module '@mappedin/blue-dot/blue-dot/src/types' {
215
293
  /**
216
294
  * Emitted when the user hovers over the Blue Dot.
217
295
  */
218
- hover: undefined;
296
+ hover: {
297
+ coordinate: Coordinate;
298
+ };
219
299
  };
220
300
  export type BlueDotEvents = keyof BlueDotEventPayloads;
221
- export type BlueDotState = 'hidden' | 'active' | 'inactive' | 'disabled';
301
+ export type BlueDotStatus = 'hidden' | 'active' | 'inactive' | 'disabled';
222
302
  export type BlueDotAction = 'timeout' | 'error' | 'position-update' | 'enable' | 'disable' | 'initialize';
223
- export type BlueDotOptions = {
303
+ export type BlueDotState = {
224
304
  /**
225
305
  * The radius of the BlueDot in pixels. The BlueDot will maintain this size clamped to a minimum of 0.35 metres.
226
306
  * @default 10
227
307
  */
228
- radius?: number;
308
+ radius: number;
229
309
  /**
230
310
  * The color of the BlueDot core element.
231
311
  * @default #2266ff
232
312
  */
233
- color?: string;
313
+ color: string;
234
314
  /**
235
315
  * The color of the BlueDot when it has timed out and gone inactive.
236
316
  * @default #808080
237
317
  */
238
- inactiveColor?: string;
318
+ inactiveColor: string;
239
319
  /**
240
320
  * Options for the accuracy ring around the BlueDot.
241
321
  */
242
- accuracyRing?: {
322
+ accuracyRing: {
243
323
  /**
244
324
  * The color of the accuracy ring.
245
325
  * @default #2266ff
246
326
  */
247
- color?: string;
327
+ color: string;
248
328
  /**
249
329
  * The opacity of the accuracy ring.
250
330
  * @default 0.3
251
331
  */
252
- opacity?: number;
332
+ opacity: number;
253
333
  };
254
334
  /**
255
335
  * Options for the heading directional indicator.
256
336
  */
257
- heading?: {
337
+ heading: {
258
338
  /**
259
339
  * The color of the heading cone.
260
340
  * @default #2266ff
261
341
  */
262
- color?: string;
342
+ color: string;
263
343
  /**
264
344
  * The opacity of the heading cone.
265
345
  * @default 0.7
266
346
  */
267
- opacity?: number;
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;
268
353
  };
269
354
  /**
270
355
  * The duration of the timeout in milliseconds.
271
356
  * If the BlueDot does not receive a position update within this time, it will grey out until a position is received.
272
357
  * @default 30000
273
358
  */
274
- timeout?: number;
359
+ timeout: number;
275
360
  /**
276
361
  * Whether to watch the device's position.
277
362
  * @default true
278
363
  */
279
- watchDevicePosition?: boolean;
364
+ watchDevicePosition: boolean;
280
365
  /**
281
366
  * Whether to log debug messages.
282
367
  * @default false
283
368
  */
284
- debug?: boolean;
369
+ debug: boolean;
285
370
  /**
286
371
  * The maximum acceptable accuracy in meters. Position updates with accuracy exceeding this value will be dropped.
287
372
  * @default 50
288
373
  */
289
- accuracyThreshold?: number;
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;
290
386
  };
387
+ export type BlueDotUpdateState = PartialDeep<BlueDotState>;
291
388
  /**
292
389
  * Position update options for the {@link BlueDot.update} method.
293
390
  */
@@ -320,6 +417,43 @@ declare module '@mappedin/blue-dot/blue-dot/src/types' {
320
417
  * Set to `undefined` to disable floor level and show the BlueDot on all floors.
321
418
  */
322
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
+ };
323
457
  };
324
458
  }
325
459
 
@@ -337,6 +471,31 @@ declare module '@mappedin/blue-dot/packages/common' {
337
471
  export * from '@mappedin/blue-dot/packages/common/interpolate';
338
472
  }
339
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>;
497
+ }
498
+
340
499
  declare module '@mappedin/blue-dot/packages/common/Mappedin.Logger' {
341
500
  export const MI_DEBUG_KEY = "mi-debug";
342
501
  export const MI_ERROR_LABEL = "[MappedinJS]";
@@ -447,6 +606,30 @@ declare module '@mappedin/blue-dot/packages/common/utils' {
447
606
  export { clampWithWarning } from '@mappedin/blue-dot/packages/common/math-utils';
448
607
  export { arraysEqual } from '@mappedin/blue-dot/packages/common/array-utils';
449
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;
450
633
  }
451
634
 
452
635
  declare module '@mappedin/blue-dot/packages/common/async' {
package/lib/esm/index.js CHANGED
@@ -1,233 +1,10 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
1
+ import {
2
+ BlueDot,
3
+ init_define_process
4
+ } from "./chunk-TPJ6NPMJ.js";
3
5
 
4
- // ../packages/common/pubsub.ts
5
- var PubSub = class {
6
- static {
7
- __name(this, "PubSub");
8
- }
9
- /**
10
- * @private
11
- * @internal
12
- */
13
- _subscribers = {};
14
- /**
15
- * @private
16
- * @internal
17
- */
18
- _destroyed = false;
19
- /**
20
- * @private
21
- * @internal
22
- */
23
- publish(eventName, data) {
24
- if (!this._subscribers || !this._subscribers[eventName] || this._destroyed) {
25
- return;
26
- }
27
- this._subscribers[eventName].forEach(function(fn) {
28
- if (typeof fn !== "function") {
29
- return;
30
- }
31
- fn(data);
32
- });
33
- }
34
- /**
35
- * Subscribe a function to an event.
36
- *
37
- * @param eventName An event name which, when fired, will call the provided
38
- * function.
39
- * @param fn A callback that gets called when the corresponding event is fired. The
40
- * callback will get passed an argument with a type that's one of event payloads.
41
- * @example
42
- * // Subscribe to the 'click' event
43
- * const handler = (event) => {
44
- * const { coordinate } = event;
45
- * const { latitude, longitude } = coordinate;
46
- * console.log(`Map was clicked at ${latitude}, ${longitude}`);
47
- * };
48
- * map.on('click', handler);
49
- */
50
- on(eventName, fn) {
51
- if (!this._subscribers || this._destroyed) {
52
- this._subscribers = {};
53
- }
54
- this._subscribers[eventName] = this._subscribers[eventName] || [];
55
- this._subscribers[eventName].push(fn);
56
- }
57
- /**
58
- * Unsubscribe a function previously subscribed with {@link on}
59
- *
60
- * @param eventName An event name to which the provided function was previously
61
- * subscribed.
62
- * @param fn A function that was previously passed to {@link on}. The function must
63
- * have the same reference as the function that was subscribed.
64
- * @example
65
- * // Unsubscribe from the 'click' event
66
- * const handler = (event) => {
67
- * console.log('Map was clicked', event);
68
- * };
69
- * map.off('click', handler);
70
- */
71
- off(eventName, fn) {
72
- if (!this._subscribers || this._subscribers[eventName] == null || this._destroyed) {
73
- return;
74
- }
75
- const itemIdx = this._subscribers[eventName].indexOf(fn);
76
- if (itemIdx !== -1) {
77
- this._subscribers[eventName].splice(itemIdx, 1);
78
- }
79
- }
80
- /**
81
- * @private
82
- * @internal
83
- */
84
- destroy() {
85
- this._destroyed = true;
86
- this._subscribers = {};
87
- }
88
- };
89
-
90
- // src/blue-dot.ts
91
- var BlueDot = class {
92
- static {
93
- __name(this, "BlueDot");
94
- }
95
- #pubsub = new PubSub();
96
- #mapView;
97
- /**
98
- * Create a new {@link BlueDot} instance.
99
- */
100
- constructor(mapView) {
101
- this.#mapView = mapView;
102
- this.#mapView.__BlueDot.on("blue-dot-position-error", (e) => {
103
- this.#pubsub.publish("error", e);
104
- });
105
- this.#mapView.__BlueDot.on("blue-dot-position-update", (e) => {
106
- this.#pubsub.publish("position-update", e);
107
- });
108
- this.#mapView.__BlueDot.on("blue-dot-state-change", (e) => {
109
- this.#pubsub.publish("state-change", e);
110
- });
111
- this.#mapView.__BlueDot.on("blue-dot-follow-change", (e) => {
112
- this.#pubsub.publish("follow-change", e);
113
- });
114
- this.#mapView.__BlueDot.on("click", (e) => {
115
- this.#pubsub.publish("click", e);
116
- });
117
- this.#mapView.__BlueDot.on("hover", () => {
118
- this.#pubsub.publish("hover");
119
- });
120
- }
121
- /**
122
- * The current state of the BlueDot. Can be 'hidden', 'active', 'inactive', or 'disabled'.
123
- * Listen for state changes using the 'state-change' event.
124
- *
125
- * @example
126
- * mapView.BlueDot.on('state-change', ({ state }) => {
127
- * if (state === 'active') {
128
- * // BlueDot is visible and tracking
129
- * }
130
- * });
131
- */
132
- get state() {
133
- return this.#mapView.__BlueDot.state;
134
- }
135
- /**
136
- * Whether the BlueDot is currently following the user (camera follow mode).
137
- */
138
- get following() {
139
- return this.#mapView.__BlueDot.following;
140
- }
141
- /**
142
- * The direction the user is facing in degrees from north clockwise.
143
- * @see https://developer.mozilla.org/en-US/docs/Web/API/GeolocationCoordinates/heading
144
- */
145
- get heading() {
146
- return this.#mapView.__BlueDot.heading;
147
- }
148
- /**
149
- * The accuracy of the current position in metres.
150
- */
151
- get accuracy() {
152
- return this.#mapView.__BlueDot.accuracy;
153
- }
154
- /**
155
- * The coordinate of the current position.
156
- */
157
- get coordinate() {
158
- return this.#mapView.__BlueDot.coordinate;
159
- }
160
- /**
161
- * The floor the Blue Dot is currently on. If undefined, the Blue Dot will appear on every floor.
162
- */
163
- get floor() {
164
- return this.#mapView.__BlueDot.floor;
165
- }
166
- /**
167
- * Enable the Blue Dot. It will be hidden until a position is received either from the browser or by calling {@link BlueDot.update}.
168
- * @param options - The options to setup the Blue Dot (see {@link BlueDotOptions}).
169
- *
170
- * @example Enable with default options
171
- * mapView.BlueDot.enable();
172
- *
173
- * @example Enable with custom color and accuracy ring
174
- * mapView.BlueDot.enable({ color: '#00ff00', accuracyRing: { color: '#00ff00', opacity: 0.2 } });
175
- *
176
- * @see See the [BlueDot Guide](https://developer.mappedin.com/web-sdk/blue-dot) for more information.
177
- */
178
- enable = /* @__PURE__ */ __name((options) => {
179
- this.#mapView.__BlueDot.enable(options);
180
- }, "enable");
181
- /**
182
- * Disable the Blue Dot. It will be hidden and no longer update.
183
- */
184
- disable = /* @__PURE__ */ __name(() => {
185
- this.#mapView.__BlueDot.disable();
186
- }, "disable");
187
- on = /* @__PURE__ */ __name((eventName, fn) => {
188
- this.#pubsub.on(eventName, fn);
189
- }, "on");
190
- off = /* @__PURE__ */ __name((eventName, fn) => {
191
- this.#pubsub.off(eventName, fn);
192
- }, "off");
193
- /**
194
- * Enable or disable the devices's geolocation listener to automatically position the Blue Dot.
195
- * If enabled, the device will request permission to access the user's precise location.
196
- * @param watch - Whether to enable or disable the listener.
197
- */
198
- watchDevicePosition = /* @__PURE__ */ __name((watch = true) => {
199
- this.#mapView.__BlueDot.watchDevicePosition(watch);
200
- }, "watchDevicePosition");
201
- /**
202
- * Manually override some position properties of the Blue Dot.
203
- * Accepts a full GeolocationPosition object or a partial {@link BlueDotPositionUpdate} object.
204
- * @example Manually set the accuracy and heading
205
- * ```ts
206
- * api.BlueDot.update({ accuracy: 10, heading: 90 });
207
- * ```
208
- * @example Reset accuracy and heading to device values
209
- * ```ts
210
- * api.BlueDot.update({ accuracy: 'device', heading: 'device' });
211
- * ```
212
- */
213
- update = /* @__PURE__ */ __name((position) => {
214
- this.#mapView.__BlueDot.update(position);
215
- }, "update");
216
- /**
217
- * Set the camera to follow the BlueDot in various modes. User interaction will cancel following automatically.
218
- * @param mode The follow mode ('position-only', 'position-and-heading', 'position-and-path-direction', or false to disable).
219
- * @param cameraOptions Optional camera options (zoom, pitch, etc.).
220
- *
221
- * @example
222
- * mapView.BlueDot.follow('position-and-heading', { zoomLevel: 21, pitch: 45 });
223
- */
224
- follow = /* @__PURE__ */ __name((mode, cameraOptions) => {
225
- this.#mapView.__BlueDot.follow(mode, cameraOptions);
226
- }, "follow");
227
- destroy = /* @__PURE__ */ __name(() => {
228
- this.#pubsub.destroy();
229
- }, "destroy");
230
- };
6
+ // src/index.ts
7
+ init_define_process();
231
8
  export {
232
9
  BlueDot
233
10
  };