@mappedin/blue-dot 6.0.1-beta.56 → 6.0.1-beta.57
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 +122 -0
- package/lib/esm/index.d.ts +0 -40
- package/package.json +20 -18
package/README.md
CHANGED
|
@@ -115,3 +115,125 @@ export type BlueDotOptions = {
|
|
|
115
115
|
debug?: boolean;
|
|
116
116
|
};
|
|
117
117
|
```
|
|
118
|
+
|
|
119
|
+
### React Native
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
import React, { useEffect, useCallback } from 'react';
|
|
123
|
+
import { View, Text, TouchableOpacity } from 'react-native';
|
|
124
|
+
import { MapView, useMapData } from '@mappedin/react-native-sdk';
|
|
125
|
+
import { useBlueDot, useBlueDotEvent } from '@mappedin/blue-dot/rn';
|
|
126
|
+
|
|
127
|
+
function MyComponent() {
|
|
128
|
+
const { mapData } = useMapData({
|
|
129
|
+
key: 'your-api-key',
|
|
130
|
+
secret: 'your-api-secret',
|
|
131
|
+
mapId: 'your-map-id',
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<MapView mapData={mapData}>
|
|
136
|
+
<BlueDotDisplay />
|
|
137
|
+
</MapView>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function BlueDotDisplay() {
|
|
142
|
+
// All methods are async and return Promises
|
|
143
|
+
const {
|
|
144
|
+
isReady,
|
|
145
|
+
isEnabled,
|
|
146
|
+
state,
|
|
147
|
+
position,
|
|
148
|
+
floor,
|
|
149
|
+
following,
|
|
150
|
+
accuracy,
|
|
151
|
+
heading,
|
|
152
|
+
enable,
|
|
153
|
+
disable,
|
|
154
|
+
update,
|
|
155
|
+
follow,
|
|
156
|
+
unfollow,
|
|
157
|
+
} = useBlueDot();
|
|
158
|
+
|
|
159
|
+
// Listen for position updates
|
|
160
|
+
useBlueDotEvent(
|
|
161
|
+
'position-update',
|
|
162
|
+
useCallback(event => {
|
|
163
|
+
console.log('Position updated:', event.coordinate, event.floor);
|
|
164
|
+
}, []),
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
// Listen for state changes
|
|
168
|
+
useBlueDotEvent(
|
|
169
|
+
'state-change',
|
|
170
|
+
useCallback(event => {
|
|
171
|
+
console.log('State changed:', event.state);
|
|
172
|
+
}, []),
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
// Listen for follow mode changes
|
|
176
|
+
useBlueDotEvent(
|
|
177
|
+
'follow-change',
|
|
178
|
+
useCallback(event => {
|
|
179
|
+
console.log('Follow mode:', event.following);
|
|
180
|
+
}, []),
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
if (isReady && !isEnabled) {
|
|
185
|
+
// All methods are async - use await or .then()
|
|
186
|
+
enable({
|
|
187
|
+
radius: 15,
|
|
188
|
+
color: '#ff0000',
|
|
189
|
+
watchDevicePosition: false,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}, [isReady, isEnabled, enable]);
|
|
193
|
+
|
|
194
|
+
const handleUpdatePosition = useCallback(async () => {
|
|
195
|
+
try {
|
|
196
|
+
// Update position manually
|
|
197
|
+
await update({
|
|
198
|
+
latitude: 43.6532,
|
|
199
|
+
longitude: -79.3832,
|
|
200
|
+
accuracy: 5,
|
|
201
|
+
heading: 90,
|
|
202
|
+
floorOrFloorId: floor,
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// Enable follow mode
|
|
206
|
+
await follow('position-and-heading', {
|
|
207
|
+
zoomLevel: 19,
|
|
208
|
+
});
|
|
209
|
+
} catch (error) {
|
|
210
|
+
console.error('Failed to update position:', error);
|
|
211
|
+
}
|
|
212
|
+
}, [update, follow, floor]);
|
|
213
|
+
|
|
214
|
+
return (
|
|
215
|
+
<View>
|
|
216
|
+
<Text>Is Ready: {isReady ? 'Yes' : 'No'}</Text>
|
|
217
|
+
<Text>Is Enabled: {isEnabled ? 'Yes' : 'No'}</Text>
|
|
218
|
+
<Text>State: {state}</Text>
|
|
219
|
+
<Text>Following: {following ? 'Yes' : 'No'}</Text>
|
|
220
|
+
{position && (
|
|
221
|
+
<Text>
|
|
222
|
+
Position: {position.latitude.toFixed(4)}, {position.longitude.toFixed(4)}
|
|
223
|
+
</Text>
|
|
224
|
+
)}
|
|
225
|
+
{accuracy && <Text>Accuracy: {accuracy.toFixed(1)}m</Text>}
|
|
226
|
+
{heading && <Text>Heading: {heading.toFixed(0)}°</Text>}
|
|
227
|
+
<TouchableOpacity onPress={handleUpdatePosition}>
|
|
228
|
+
<Text>Update Position & Follow</Text>
|
|
229
|
+
</TouchableOpacity>
|
|
230
|
+
</View>
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**Key Differences from Vanilla JS:**
|
|
236
|
+
|
|
237
|
+
- **All methods are async**: `enable()`, `disable()`, `update()`, `follow()`, and `unfollow()` return Promises
|
|
238
|
+
- **Rich state**: Hook returns `isReady`, `state`, `position`, `floor`, `following`, `accuracy`, `heading` for real-time updates
|
|
239
|
+
- **Separate event hook**: Use `useBlueDotEvent` for listening to position-update, state-change, and follow-change events
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// ../blue-dot/@packages/internal/common/pubsub
|
|
4
4
|
// ../blue-dot/@mappedin/mappedin-js
|
|
5
5
|
// ../blue-dot/three
|
|
6
|
-
// ../blue-dot/type-fest
|
|
7
6
|
|
|
8
7
|
declare module '@mappedin/blue-dot' {
|
|
9
8
|
export { BlueDot } from '@mappedin/blue-dot/blue-dot/src/blue-dot';
|
|
@@ -336,7 +335,6 @@ declare module '@mappedin/blue-dot/packages/common' {
|
|
|
336
335
|
export { Logger };
|
|
337
336
|
export * from '@mappedin/blue-dot/packages/common/color';
|
|
338
337
|
export * from '@mappedin/blue-dot/packages/common/interpolate';
|
|
339
|
-
export * from '@mappedin/blue-dot/packages/common/type-utils';
|
|
340
338
|
}
|
|
341
339
|
|
|
342
340
|
declare module '@mappedin/blue-dot/packages/common/Mappedin.Logger' {
|
|
@@ -670,44 +668,6 @@ declare module '@mappedin/blue-dot/packages/common/interpolate' {
|
|
|
670
668
|
export function interpolateMulti(value: number, inputRange: number[], outputRange: number[], easeFunc?: EasingCurve | ((t: number) => number)): number;
|
|
671
669
|
}
|
|
672
670
|
|
|
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
671
|
declare module '@mappedin/blue-dot/packages/common/math-utils' {
|
|
712
672
|
/**
|
|
713
673
|
* Clamp a number between lower and upper bounds with a warning
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mappedin/blue-dot",
|
|
3
|
-
"version": "6.0.1-beta.
|
|
3
|
+
"version": "6.0.1-beta.57",
|
|
4
4
|
"homepage": "https://developer.mappedin.com/",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "lib/esm/index.js",
|
|
@@ -33,22 +33,11 @@
|
|
|
33
33
|
"THIRD_PARTY_LICENSES.txt"
|
|
34
34
|
],
|
|
35
35
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
36
|
-
"
|
|
37
|
-
"start": "pnpm build && concurrently \"node scripts/build.mjs --watchChanges\" \"node scripts/start.mjs\"",
|
|
38
|
-
"build:deps": "RN_BUILD=true npx turbo build --filter=@mappedin/blue-dot --ui stream",
|
|
39
|
-
"build": "pnpm clean && tsc -b && node scripts/build.mjs",
|
|
40
|
-
"build:prod": "cross-env NODE_ENV=production pnpm build && pnpm build:rn",
|
|
41
|
-
"build:rn": "cross-env RN_BUILD=true pnpm build",
|
|
42
|
-
"types": "tsc -b",
|
|
43
|
-
"test": "pnpm -w test blue-dot",
|
|
44
|
-
"test:cov": "NODE_ENV=test jest --coverage",
|
|
45
|
-
"clean": "rm -rf lib/** && rm -rf examples/dist/**",
|
|
46
|
-
"docs": "pnpm build && typedoc"
|
|
47
|
-
},
|
|
36
|
+
"dependencies": {},
|
|
48
37
|
"peerDependencies": {
|
|
49
|
-
"
|
|
50
|
-
"@mappedin/
|
|
51
|
-
"react": "
|
|
38
|
+
"react": ">=16.8.0",
|
|
39
|
+
"@mappedin/mappedin-js": "^6.0.0-rc.4",
|
|
40
|
+
"@mappedin/react-native-sdk": "^6.0.0-beta.1"
|
|
52
41
|
},
|
|
53
42
|
"peerDependenciesMeta": {
|
|
54
43
|
"@mappedin/react-native-sdk": {
|
|
@@ -58,8 +47,21 @@
|
|
|
58
47
|
"optional": true
|
|
59
48
|
}
|
|
60
49
|
},
|
|
50
|
+
"devDependencies": {},
|
|
61
51
|
"volta": {
|
|
62
52
|
"extends": "../../package.json"
|
|
63
53
|
},
|
|
64
|
-
"
|
|
65
|
-
|
|
54
|
+
"scripts": {
|
|
55
|
+
"start": "pnpm build && concurrently \"node scripts/build.mjs --watchChanges\" \"node scripts/start.mjs\"",
|
|
56
|
+
"build:deps": "RN_BUILD=true npx turbo build --filter=@mappedin/blue-dot --ui stream",
|
|
57
|
+
"build": "pnpm clean && tsc -b && node scripts/build.mjs",
|
|
58
|
+
"build:prod": "cross-env NODE_ENV=production pnpm build && pnpm build:rn",
|
|
59
|
+
"build:rn": "cross-env RN_BUILD=true pnpm build",
|
|
60
|
+
"types": "tsc -b",
|
|
61
|
+
"version:ci": "pnpm version --no-commit-hooks --no-git-tag-version",
|
|
62
|
+
"test": "pnpm -w test blue-dot",
|
|
63
|
+
"test:cov": "NODE_ENV=test jest --coverage",
|
|
64
|
+
"clean": "rm -rf lib/** && rm -rf examples/dist/**",
|
|
65
|
+
"docs": "pnpm build && typedoc"
|
|
66
|
+
}
|
|
67
|
+
}
|