@mappedin/blue-dot 6.0.1-beta.60 → 6.0.1-beta.62
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/lib/esm/chunk-TYUDBRNJ.js +1 -0
- package/lib/esm/index.d.ts +20692 -843
- package/lib/esm/index.js +1 -11
- package/lib/esm/react/index.d.ts +20659 -851
- package/lib/esm/react/index.js +1 -75
- package/lib/rn/blue-dot.d.ts +47 -9
- package/lib/rn/constants.d.ts +1 -0
- package/lib/rn/index-rn.js +5 -316
- package/lib/rn/model-manager.d.ts +2 -2
- package/lib/rn/types.d.ts +13 -1
- package/lib/rn/utils.d.ts +9 -0
- package/package.json +8 -6
- package/lib/blue-dot.iife.js.map +0 -7
- package/lib/esm/chunk-RONFZDXM.js +0 -1560
- package/lib/esm/chunk-RONFZDXM.js.map +0 -7
- package/lib/esm/index.js.map +0 -7
- package/lib/esm/react/index.js.map +0 -7
- package/lib/rn/index-rn.js.map +0 -7
package/lib/esm/react/index.js
CHANGED
|
@@ -1,75 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BlueDot,
|
|
3
|
-
__name,
|
|
4
|
-
init_define_process
|
|
5
|
-
} from "../chunk-RONFZDXM.js";
|
|
6
|
-
|
|
7
|
-
// src/react/index.ts
|
|
8
|
-
init_define_process();
|
|
9
|
-
|
|
10
|
-
// src/react/use-blue-dot.tsx
|
|
11
|
-
init_define_process();
|
|
12
|
-
import { useCallback, useState } from "react";
|
|
13
|
-
import { useMap, useMapViewExtension } from "@mappedin/react-sdk";
|
|
14
|
-
function useForceUpdate() {
|
|
15
|
-
const [, setState] = useState({});
|
|
16
|
-
return useCallback(() => setState({}), []);
|
|
17
|
-
}
|
|
18
|
-
__name(useForceUpdate, "useForceUpdate");
|
|
19
|
-
function useBlueDot() {
|
|
20
|
-
const { mapView } = useMap();
|
|
21
|
-
const forceUpdate = useForceUpdate();
|
|
22
|
-
const { register } = useMapViewExtension("blue-dot", {
|
|
23
|
-
onRegister: /* @__PURE__ */ __name(() => {
|
|
24
|
-
const bd = new BlueDot(mapView);
|
|
25
|
-
bd.on("position-update", forceUpdate);
|
|
26
|
-
bd.on("status-change", forceUpdate);
|
|
27
|
-
bd.on("follow-change", forceUpdate);
|
|
28
|
-
bd.on("error", forceUpdate);
|
|
29
|
-
return bd;
|
|
30
|
-
}, "onRegister"),
|
|
31
|
-
onDeregister: /* @__PURE__ */ __name((bd) => {
|
|
32
|
-
bd.off("position-update", forceUpdate);
|
|
33
|
-
bd.off("status-change", forceUpdate);
|
|
34
|
-
bd.off("follow-change", forceUpdate);
|
|
35
|
-
bd.off("error", forceUpdate);
|
|
36
|
-
bd.destroy();
|
|
37
|
-
}, "onDeregister")
|
|
38
|
-
});
|
|
39
|
-
const blueDot = register();
|
|
40
|
-
if (!blueDot) {
|
|
41
|
-
throw new Error("BlueDot failed to initialize.");
|
|
42
|
-
}
|
|
43
|
-
return blueDot;
|
|
44
|
-
}
|
|
45
|
-
__name(useBlueDot, "useBlueDot");
|
|
46
|
-
|
|
47
|
-
// src/react/use-blue-dot-event.tsx
|
|
48
|
-
init_define_process();
|
|
49
|
-
import { useCallback as useCallback2, useEffect, useRef } from "react";
|
|
50
|
-
function useBlueDotEvent(eventName, callback) {
|
|
51
|
-
const instance = useBlueDot();
|
|
52
|
-
const callbackRef = useRef(callback);
|
|
53
|
-
callbackRef.current = callback;
|
|
54
|
-
const handleCallback = useCallback2((payload) => {
|
|
55
|
-
callbackRef.current(payload);
|
|
56
|
-
}, []);
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
if (instance == null) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
instance.on(eventName, handleCallback);
|
|
62
|
-
return () => {
|
|
63
|
-
if (instance == null) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
instance.off(eventName, handleCallback);
|
|
67
|
-
};
|
|
68
|
-
}, [instance, eventName, handleCallback]);
|
|
69
|
-
}
|
|
70
|
-
__name(useBlueDotEvent, "useBlueDotEvent");
|
|
71
|
-
export {
|
|
72
|
-
useBlueDot,
|
|
73
|
-
useBlueDotEvent
|
|
74
|
-
};
|
|
75
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{a as n,b as u,c as f}from"../chunk-TYUDBRNJ.js";u();u();import{useCallback as c,useState as p}from"react";import{useMap as D,useMapViewExtension as m}from"@mappedin/react-sdk";function B(){let[,t]=p({});return c(()=>t({}),[])}n(B,"useForceUpdate");function l(){let{mapView:t}=D(),o=B(),{register:r}=m("blue-dot",{onRegister:n(()=>{let e=new f(t);return e.on("position-update",o),e.on("status-change",o),e.on("follow-change",o),e.on("error",o),e},"onRegister"),onDeregister:n(e=>{e.off("position-update",o),e.off("status-change",o),e.off("follow-change",o),e.off("error",o),e.destroy()},"onDeregister")}),s=r();if(!s)throw new Error("BlueDot failed to initialize.");return s}n(l,"useBlueDot");u();import{useCallback as d,useEffect as E,useRef as g}from"react";function w(t,o){let r=l(),s=g(o);s.current=o;let e=d(i=>{s.current(i)},[]);E(()=>{if(r!=null)return r.on(t,e),()=>{r!=null&&r.off(t,e)}},[r,t,e])}n(w,"useBlueDotEvent");export{l as useBlueDot,w as useBlueDotEvent};
|
package/lib/rn/blue-dot.d.ts
CHANGED
|
@@ -15,15 +15,15 @@ import type { ReadonlyDeep } from 'type-fest';
|
|
|
15
15
|
* const mapView = await show3dMap(...);
|
|
16
16
|
*
|
|
17
17
|
* // Enable BlueDot
|
|
18
|
-
* new BlueDot(mapView).enable();
|
|
18
|
+
* const blueDot = new BlueDot(mapView).enable();
|
|
19
19
|
*
|
|
20
20
|
* // Option 1: Listen for position updates from the device
|
|
21
|
-
*
|
|
21
|
+
* blueDot.on('position-update', (position) => {
|
|
22
22
|
* console.log('User position:', position);
|
|
23
23
|
* });
|
|
24
24
|
*
|
|
25
25
|
* // Option 2: Update position manually
|
|
26
|
-
*
|
|
26
|
+
* blueDot.update({ latitude, longitude, accuracy, floorOrFloorId });
|
|
27
27
|
*
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
@@ -78,20 +78,28 @@ export declare class BlueDot implements MapViewExtension<BlueDotState> {
|
|
|
78
78
|
* The coordinate of the current position.
|
|
79
79
|
*/
|
|
80
80
|
get coordinate(): Coordinate | undefined;
|
|
81
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Returns the current Blue Dot state.
|
|
83
|
+
*/
|
|
84
|
+
getState(): ReadonlyDeep<BlueDotState>;
|
|
82
85
|
/**
|
|
83
86
|
* The floor the Blue Dot is currently on. If undefined, the Blue Dot will appear on every floor.
|
|
84
87
|
*/
|
|
85
88
|
get floor(): Floor | undefined;
|
|
86
89
|
/**
|
|
87
90
|
* Enable the Blue Dot. It will be hidden until a position is received either from the browser or by calling {@link BlueDot.update}.
|
|
88
|
-
* @param options - The options to setup the Blue Dot (see {@link
|
|
91
|
+
* @param options - The options to setup the Blue Dot (see {@link BlueDotUpdateState}).
|
|
89
92
|
*
|
|
90
93
|
* @example Enable with default options
|
|
91
|
-
*
|
|
92
|
-
*
|
|
94
|
+
* ```ts
|
|
95
|
+
* const blueDot = new BlueDot(mapView);
|
|
96
|
+
* blueDot.enable();
|
|
97
|
+
* ```
|
|
93
98
|
* @example Enable with custom color and accuracy ring
|
|
94
|
-
*
|
|
99
|
+
* ```ts
|
|
100
|
+
* const blueDot = new BlueDot(mapView);
|
|
101
|
+
* blueDot.enable({ color: '#00ff00', accuracyRing: { color: '#00ff00', opacity: 0.2 } });
|
|
102
|
+
* ```
|
|
95
103
|
*
|
|
96
104
|
* @see See the [BlueDot Guide](https://developer.mappedin.com/web-sdk/blue-dot) for more information.
|
|
97
105
|
*/
|
|
@@ -118,21 +126,51 @@ export declare class BlueDot implements MapViewExtension<BlueDotState> {
|
|
|
118
126
|
* @param options - The options to update
|
|
119
127
|
*
|
|
120
128
|
* @example Update color and accuracy ring
|
|
121
|
-
*
|
|
129
|
+
* ```ts
|
|
130
|
+
* const blueDot = new BlueDot(mapView);
|
|
131
|
+
* blueDot.updateState({
|
|
122
132
|
* color: '#ff0000',
|
|
123
133
|
* accuracyRing: { color: '#ff0000', opacity: 0.5 }
|
|
124
134
|
* });
|
|
135
|
+
* ```
|
|
125
136
|
*/
|
|
126
137
|
updateState: (options: BlueDotUpdateState) => void;
|
|
127
138
|
/**
|
|
128
139
|
* Enable or disable the devices's geolocation listener to automatically position the Blue Dot.
|
|
129
140
|
* If enabled, the device will request permission to access the user's precise location.
|
|
141
|
+
*
|
|
142
|
+
* @remarks This will emit a 'position-update' event every time a new position is received.
|
|
143
|
+
*
|
|
130
144
|
* @param watch - Whether to enable or disable the listener.
|
|
131
145
|
*/
|
|
132
146
|
watchDevicePosition: (watch: boolean) => void;
|
|
147
|
+
/**
|
|
148
|
+
* Enable or disable the device orientation listener to automatically update the Blue Dot's heading.
|
|
149
|
+
* This must be enabled in response to a user action such as a tap or click and cannot be enabled automatically.
|
|
150
|
+
*
|
|
151
|
+
* @remarks This will emit a 'device-orientation-update' event every time the device's orientation changes.
|
|
152
|
+
* Device orientation changes will not emit a 'position-update' event.
|
|
153
|
+
*
|
|
154
|
+
* @see https://www.w3.org/TR/orientation-event/#dom-deviceorientationevent-requestpermission
|
|
155
|
+
*
|
|
156
|
+
* @param watch - Whether to enable or disable the listener.
|
|
157
|
+
*
|
|
158
|
+
* @example Enable device orientation listener
|
|
159
|
+
* ```ts
|
|
160
|
+
* const blueDot = new BlueDot(mapView);
|
|
161
|
+
* // Enable device orientation on button click
|
|
162
|
+
* button.addEventListener('click', () => {
|
|
163
|
+
* blueDot.watchDeviceOrientation(true);
|
|
164
|
+
* });
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
watchDeviceOrientation: (watch: boolean) => Promise<void>;
|
|
133
168
|
/**
|
|
134
169
|
* Manually override some position properties of the Blue Dot.
|
|
135
170
|
* Accepts a full GeolocationPosition object or a partial {@link BlueDotPositionUpdate} object.
|
|
171
|
+
*
|
|
172
|
+
* @remarks This will emit a 'position-update' event.
|
|
173
|
+
*
|
|
136
174
|
* @example Manually set the accuracy and heading
|
|
137
175
|
* ```ts
|
|
138
176
|
* api.BlueDot.update({ accuracy: 10, heading: 90 });
|
package/lib/rn/constants.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BlueDotState } from './types';
|
|
2
|
+
export declare const DEVICE_ORIENTATION_DELTA_THRESHOLD = 2;
|
|
2
3
|
export declare const POSITION_ANIMATION_DURATION = 1000;
|
|
3
4
|
export declare const SCALE_ANIMATION_DURATION = 150;
|
|
4
5
|
export declare const ROTATION_ANIMATION_DURATION = 150;
|