@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.js
CHANGED
|
@@ -1,233 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
BlueDot,
|
|
3
|
+
init_define_process
|
|
4
|
+
} from "./chunk-TPJ6NPMJ.js";
|
|
3
5
|
|
|
4
|
-
//
|
|
5
|
-
|
|
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
|
};
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { BlueDot } from './blue-dot';\nexport type {\n\tBlueDotEvents,\n\tBlueDotEventPayloads,\n\tBlueDotPositionUpdate,\n\tBlueDotStatus,\n\tBlueDotAction,\n\tFollowMode,\n\tFollowCameraOptions,\n\tBlueDotState,\n\tBlueDotPositionProcessor,\n\tBlueDotPositionUpdateWithFloor,\n\tBlueDotUpdateOptions,\n\tGeolocationPositionExtended,\n} from './types';\n"],
|
|
5
|
+
"mappings": ";;;;;;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|