react-native-pointr 10.7.0 → 10.7.1
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/CHANGELOG.md +15 -0
- package/EXTENDING.md +56 -0
- package/android/src/main/java/com/pointr/PTRBridgeKeys.kt +153 -0
- package/android/src/main/java/com/pointr/PTRMapWidgetManager.kt +120 -101
- package/ios/PTRBridgeKeys.swift +110 -0
- package/ios/PTRMapWidgetContainerView.swift +46 -41
- package/ios/PTRMapWidgetManager.swift +14 -11
- package/package.json +1 -1
- package/src/PTRMapWidgetUtils.ts +12 -12
- package/src/actions/index.ts +85 -1
- package/src/components/index.tsx +5 -3
- package/src/constants/bridgeKeys.ts +127 -0
- package/src/constants/index.ts +15 -14
- package/src/index.tsx +12 -0
- package/android/src/main/java/com/pointr/PTRMapWidgetActionType.kt +0 -17
package/src/actions/index.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module commands
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { PTRActionType } from '../constants';
|
|
7
|
+
import { PTRActionType, PTRActionParamKeys as Keys } from '../constants';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Base class for all Pointr SDK actions
|
|
@@ -15,6 +15,18 @@ export abstract class PTRAction {
|
|
|
15
15
|
constructor(type: PTRActionType) {
|
|
16
16
|
this.type = type;
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Payload serialized into the native `action` prop.
|
|
21
|
+
*
|
|
22
|
+
* Keys are taken from {@link PTRActionParamKeys} rather than from the class
|
|
23
|
+
* field names, so a field rename here can never silently stop matching the
|
|
24
|
+
* key Android and iOS read. Undefined values are dropped by JSON.stringify,
|
|
25
|
+
* which the native side relies on to detect optional parameters.
|
|
26
|
+
*/
|
|
27
|
+
toPayload(): Record<string, unknown> {
|
|
28
|
+
return { [Keys.TYPE]: this.type };
|
|
29
|
+
}
|
|
18
30
|
}
|
|
19
31
|
|
|
20
32
|
/**
|
|
@@ -32,6 +44,15 @@ export class PTRFocusMapAction extends PTRAction {
|
|
|
32
44
|
this.building = building;
|
|
33
45
|
this.level = level;
|
|
34
46
|
}
|
|
47
|
+
|
|
48
|
+
override toPayload(): Record<string, unknown> {
|
|
49
|
+
return {
|
|
50
|
+
...super.toPayload(),
|
|
51
|
+
[Keys.SITE]: this.site,
|
|
52
|
+
[Keys.BUILDING]: this.building,
|
|
53
|
+
[Keys.LEVEL]: this.level,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
35
56
|
}
|
|
36
57
|
|
|
37
58
|
/**
|
|
@@ -46,6 +67,14 @@ export class PTRHighlightPoiAction extends PTRAction {
|
|
|
46
67
|
this.site = site;
|
|
47
68
|
this.poi = poi;
|
|
48
69
|
}
|
|
70
|
+
|
|
71
|
+
override toPayload(): Record<string, unknown> {
|
|
72
|
+
return {
|
|
73
|
+
...super.toPayload(),
|
|
74
|
+
[Keys.SITE]: this.site,
|
|
75
|
+
[Keys.POI]: this.poi,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
49
78
|
}
|
|
50
79
|
|
|
51
80
|
/**
|
|
@@ -63,6 +92,15 @@ export class PTRDisplayRouteAction extends PTRAction {
|
|
|
63
92
|
this.fromPoi = fromPoi;
|
|
64
93
|
this.toPoi = toPoi;
|
|
65
94
|
}
|
|
95
|
+
|
|
96
|
+
override toPayload(): Record<string, unknown> {
|
|
97
|
+
return {
|
|
98
|
+
...super.toPayload(),
|
|
99
|
+
[Keys.SITE]: this.site,
|
|
100
|
+
[Keys.FROM_POI]: this.fromPoi,
|
|
101
|
+
[Keys.TO_POI]: this.toPoi,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
66
104
|
}
|
|
67
105
|
|
|
68
106
|
/**
|
|
@@ -77,6 +115,14 @@ export class PTRStartWayfindingAction extends PTRAction {
|
|
|
77
115
|
this.site = site;
|
|
78
116
|
this.poi = poi;
|
|
79
117
|
}
|
|
118
|
+
|
|
119
|
+
override toPayload(): Record<string, unknown> {
|
|
120
|
+
return {
|
|
121
|
+
...super.toPayload(),
|
|
122
|
+
[Keys.SITE]: this.site,
|
|
123
|
+
[Keys.POI]: this.poi,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
80
126
|
}
|
|
81
127
|
|
|
82
128
|
/**
|
|
@@ -105,6 +151,17 @@ export class PTRMarkMyCarAction extends PTRAction {
|
|
|
105
151
|
this.shouldShowPopup = shouldShowPopup;
|
|
106
152
|
this.animationType = animationType;
|
|
107
153
|
}
|
|
154
|
+
|
|
155
|
+
override toPayload(): Record<string, unknown> {
|
|
156
|
+
return {
|
|
157
|
+
...super.toPayload(),
|
|
158
|
+
[Keys.SITE]: this.site,
|
|
159
|
+
[Keys.BUILDING]: this.building,
|
|
160
|
+
[Keys.LEVEL]: this.level,
|
|
161
|
+
[Keys.SHOULD_SHOW_POPUP]: this.shouldShowPopup,
|
|
162
|
+
[Keys.ANIMATION_TYPE]: this.animationType,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
108
165
|
}
|
|
109
166
|
|
|
110
167
|
/**
|
|
@@ -125,6 +182,15 @@ export class PTRShowMyCarAction extends PTRAction {
|
|
|
125
182
|
this.shouldShowPopup = shouldShowPopup;
|
|
126
183
|
this.animationType = animationType;
|
|
127
184
|
}
|
|
185
|
+
|
|
186
|
+
override toPayload(): Record<string, unknown> {
|
|
187
|
+
return {
|
|
188
|
+
...super.toPayload(),
|
|
189
|
+
[Keys.SITE]: this.site,
|
|
190
|
+
[Keys.SHOULD_SHOW_POPUP]: this.shouldShowPopup,
|
|
191
|
+
[Keys.ANIMATION_TYPE]: this.animationType,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
128
194
|
}
|
|
129
195
|
|
|
130
196
|
/**
|
|
@@ -148,6 +214,16 @@ export class PTRFocusCoordinateAction extends PTRAction {
|
|
|
148
214
|
this.longitude = longitude;
|
|
149
215
|
this.levelIndex = levelIndex;
|
|
150
216
|
}
|
|
217
|
+
|
|
218
|
+
override toPayload(): Record<string, unknown> {
|
|
219
|
+
return {
|
|
220
|
+
...super.toPayload(),
|
|
221
|
+
[Keys.SITE]: this.site,
|
|
222
|
+
[Keys.LATITUDE]: this.latitude,
|
|
223
|
+
[Keys.LONGITUDE]: this.longitude,
|
|
224
|
+
[Keys.LEVEL_INDEX]: this.levelIndex,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
151
227
|
}
|
|
152
228
|
|
|
153
229
|
/**
|
|
@@ -168,4 +244,12 @@ export class PTRHighlightCategoryAction extends PTRAction {
|
|
|
168
244
|
this.site = site;
|
|
169
245
|
this.categoryIds = categoryIds;
|
|
170
246
|
}
|
|
247
|
+
|
|
248
|
+
override toPayload(): Record<string, unknown> {
|
|
249
|
+
return {
|
|
250
|
+
...super.toPayload(),
|
|
251
|
+
[Keys.SITE]: this.site,
|
|
252
|
+
[Keys.CATEGORY_IDS]: this.categoryIds,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
171
255
|
}
|
package/src/components/index.tsx
CHANGED
|
@@ -102,11 +102,13 @@ interface NativePTRMapWidgetProps extends PTRMapWidgetProps {}
|
|
|
102
102
|
*/
|
|
103
103
|
/**
|
|
104
104
|
* Serialize a PTRAction to the JSON string expected by the native action prop.
|
|
105
|
+
*
|
|
106
|
+
* The payload keys come from the action's `toPayload()`, which builds them from
|
|
107
|
+
* the shared {@link PTRActionParamKeys} constants — never from the class field
|
|
108
|
+
* names — so the keys always match those Android and iOS read.
|
|
105
109
|
*/
|
|
106
110
|
function serializeCommand(action: PTRAction): string {
|
|
107
|
-
|
|
108
|
-
// Remove the 'type' key duplication from spread then re-add cleanly
|
|
109
|
-
return JSON.stringify(base);
|
|
111
|
+
return JSON.stringify(action.toPayload());
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
export const PTRMapWidget = forwardRef<any, PTRMapWidgetProps>(
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every string that crosses the JS <-> native boundary when an action is sent
|
|
3
|
+
* to the map widget: action type discriminators, `action` / `sdkConfig` payload
|
|
4
|
+
* keys and view-manager command names.
|
|
5
|
+
*
|
|
6
|
+
* Nothing here may be hard-coded anywhere else — a key renamed on one side only
|
|
7
|
+
* fails silently (the native side reads an empty string), so all three sides
|
|
8
|
+
* read them from a constants file:
|
|
9
|
+
*
|
|
10
|
+
* TypeScript src/constants/bridgeKeys.ts (this file)
|
|
11
|
+
* Android android/src/main/java/com/pointr/PTRBridgeKeys.kt
|
|
12
|
+
* iOS ios/PTRBridgeKeys.swift
|
|
13
|
+
*
|
|
14
|
+
* Changing a value here means changing it in the other two files as well.
|
|
15
|
+
*
|
|
16
|
+
* @module constants/bridgeKeys
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Discriminator written to the `type` field of the serialized `action` prop.
|
|
21
|
+
*/
|
|
22
|
+
export enum PTRActionType {
|
|
23
|
+
/** Focus the map on a site, building or level */
|
|
24
|
+
FOCUS_MAP = 'focusMap',
|
|
25
|
+
/** Highlight a single POI */
|
|
26
|
+
HIGHLIGHT_POI = 'highlightPoi',
|
|
27
|
+
/** Draw a static route between two POIs */
|
|
28
|
+
DISPLAY_ROUTE = 'displayRoute',
|
|
29
|
+
/** Start live wayfinding to a destination POI */
|
|
30
|
+
START_WAYFINDING = 'startWayfinding',
|
|
31
|
+
/** Mark the parked car location */
|
|
32
|
+
MARK_MY_CAR = 'markMyCar',
|
|
33
|
+
/** Show the previously marked car location */
|
|
34
|
+
SHOW_MY_CAR = 'showMyCar',
|
|
35
|
+
/** Focus the map on a geographic coordinate */
|
|
36
|
+
FOCUS_COORDINATE = 'focusCoordinate',
|
|
37
|
+
/** Highlight POIs of one or more categories */
|
|
38
|
+
HIGHLIGHT_CATEGORY = 'highlightCategory',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Field names of the JSON payload carried by the `action` view prop.
|
|
43
|
+
* JS writes them, Android and iOS read them back out.
|
|
44
|
+
*/
|
|
45
|
+
export const PTRActionParamKeys = {
|
|
46
|
+
/** Action discriminator — one of {@link PTRActionType} */
|
|
47
|
+
TYPE: 'type',
|
|
48
|
+
/** Site external identifier */
|
|
49
|
+
SITE: 'site',
|
|
50
|
+
/** Building external identifier */
|
|
51
|
+
BUILDING: 'building',
|
|
52
|
+
/** Level index used by focusMap / markMyCar */
|
|
53
|
+
LEVEL: 'level',
|
|
54
|
+
/** POI external identifier — destination for highlightPoi and startWayfinding */
|
|
55
|
+
POI: 'poi',
|
|
56
|
+
/** Source POI external identifier for displayRoute */
|
|
57
|
+
FROM_POI: 'fromPoi',
|
|
58
|
+
/** Destination POI external identifier for displayRoute */
|
|
59
|
+
TO_POI: 'toPoi',
|
|
60
|
+
/** Whether the car popup is shown */
|
|
61
|
+
SHOULD_SHOW_POPUP: 'shouldShowPopup',
|
|
62
|
+
/** Animation applied to the car marker */
|
|
63
|
+
ANIMATION_TYPE: 'animationType',
|
|
64
|
+
/** Latitude for focusCoordinate */
|
|
65
|
+
LATITUDE: 'latitude',
|
|
66
|
+
/** Longitude for focusCoordinate */
|
|
67
|
+
LONGITUDE: 'longitude',
|
|
68
|
+
/** Level index for focusCoordinate */
|
|
69
|
+
LEVEL_INDEX: 'levelIndex',
|
|
70
|
+
/** Category identifiers for highlightCategory */
|
|
71
|
+
CATEGORY_IDS: 'categoryIds',
|
|
72
|
+
} as const;
|
|
73
|
+
|
|
74
|
+
export type PTRActionParamKey =
|
|
75
|
+
(typeof PTRActionParamKeys)[keyof typeof PTRActionParamKeys];
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Field names of the JSON payload carried by the `sdkConfig` view prop.
|
|
79
|
+
*/
|
|
80
|
+
export const PTRSdkConfigKeys = {
|
|
81
|
+
/** Client identifier issued by Pointr */
|
|
82
|
+
CLIENT_ID: 'clientId',
|
|
83
|
+
/** License key issued by Pointr */
|
|
84
|
+
LICENSE_KEY: 'licenseKey',
|
|
85
|
+
/** Base URL of the Pointr environment */
|
|
86
|
+
BASE_URL: 'baseUrl',
|
|
87
|
+
/** Persona identifier applied to the SDK params */
|
|
88
|
+
PERSONA_ID: 'personaId',
|
|
89
|
+
/** Log level ordinal */
|
|
90
|
+
LOG_LEVEL: 'logLevel',
|
|
91
|
+
} as const;
|
|
92
|
+
|
|
93
|
+
export type PTRSdkConfigKey =
|
|
94
|
+
(typeof PTRSdkConfigKeys)[keyof typeof PTRSdkConfigKeys];
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* View-manager command names used by the imperative `executeMapAction` path.
|
|
98
|
+
* JS dispatches them, Android matches them in `receiveCommand` and iOS exports
|
|
99
|
+
* them as `@objc` methods — the names must match on all three sides.
|
|
100
|
+
*/
|
|
101
|
+
export const PTRCommandNames = {
|
|
102
|
+
/** Focus the map on a site */
|
|
103
|
+
FOCUS_SITE: 'site',
|
|
104
|
+
/** Focus the map on a building */
|
|
105
|
+
FOCUS_BUILDING: 'building',
|
|
106
|
+
/** Focus the map on a level */
|
|
107
|
+
FOCUS_LEVEL: 'level',
|
|
108
|
+
/** Highlight a POI */
|
|
109
|
+
HIGHLIGHT_POI: 'poi',
|
|
110
|
+
/** Draw a static route between two POIs */
|
|
111
|
+
DISPLAY_ROUTE: 'displayRoute',
|
|
112
|
+
/** Start live wayfinding */
|
|
113
|
+
START_WAYFINDING: 'startWayfinding',
|
|
114
|
+
/** Mark the car at site level */
|
|
115
|
+
MARK_MY_CAR_FOR_SITE: 'markMyCarForSite',
|
|
116
|
+
/** Mark the car at a specific level */
|
|
117
|
+
MARK_MY_CAR_FOR_LEVEL: 'markMyCarForLevel',
|
|
118
|
+
/** Show the marked car at site level */
|
|
119
|
+
SHOW_MY_CAR_FOR_SITE: 'myCarForSite',
|
|
120
|
+
/** Focus the map on a coordinate */
|
|
121
|
+
FOCUS_COORDINATE: 'coordinate',
|
|
122
|
+
/** Highlight a category */
|
|
123
|
+
HIGHLIGHT_CATEGORY: 'highlightCategory',
|
|
124
|
+
} as const;
|
|
125
|
+
|
|
126
|
+
export type PTRCommandName =
|
|
127
|
+
(typeof PTRCommandNames)[keyof typeof PTRCommandNames];
|
package/src/constants/index.ts
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
3
3
|
* @module constants
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
// Strings shared with the native side (action types, payload keys, command
|
|
7
|
+
// names) live in ./bridgeKeys so that TypeScript, Kotlin and Swift all read
|
|
8
|
+
// them from a constants file instead of repeating literals.
|
|
9
|
+
export {
|
|
10
|
+
PTRActionType,
|
|
11
|
+
PTRActionParamKeys,
|
|
12
|
+
PTRSdkConfigKeys,
|
|
13
|
+
PTRCommandNames,
|
|
14
|
+
} from './bridgeKeys';
|
|
15
|
+
export type {
|
|
16
|
+
PTRActionParamKey,
|
|
17
|
+
PTRSdkConfigKey,
|
|
18
|
+
PTRCommandName,
|
|
19
|
+
} from './bridgeKeys';
|
|
20
|
+
|
|
6
21
|
/**
|
|
7
22
|
* Log levels for the Pointr SDK
|
|
8
23
|
*/
|
|
@@ -73,20 +88,6 @@ export const PTREvents = {
|
|
|
73
88
|
ON_MAP_WIDGET_DID_END_LOADING: 'onMapWidgetDidEndLoading',
|
|
74
89
|
} as const;
|
|
75
90
|
|
|
76
|
-
/**
|
|
77
|
-
* Action types supported by the Pointr SDK
|
|
78
|
-
*/
|
|
79
|
-
export enum PTRActionType {
|
|
80
|
-
FOCUS_MAP = 'focusMap',
|
|
81
|
-
HIGHLIGHT_POI = 'highlightPoi',
|
|
82
|
-
DISPLAY_ROUTE = 'displayRoute',
|
|
83
|
-
START_WAYFINDING = 'startWayfinding',
|
|
84
|
-
MARK_MY_CAR = 'markMyCar',
|
|
85
|
-
SHOW_MY_CAR = 'showMyCar',
|
|
86
|
-
FOCUS_COORDINATE = 'focusCoordinate',
|
|
87
|
-
HIGHLIGHT_CATEGORY = 'highlightCategory',
|
|
88
|
-
}
|
|
89
|
-
|
|
90
91
|
/**
|
|
91
92
|
* Wayfinding mode controlling accessible vs standard routing
|
|
92
93
|
*/
|
package/src/index.tsx
CHANGED
|
@@ -36,6 +36,18 @@ export {
|
|
|
36
36
|
PTRWayfindingEventType,
|
|
37
37
|
} from './constants';
|
|
38
38
|
|
|
39
|
+
// Strings shared with the native side — see src/constants/bridgeKeys.ts
|
|
40
|
+
export {
|
|
41
|
+
PTRActionParamKeys,
|
|
42
|
+
PTRSdkConfigKeys,
|
|
43
|
+
PTRCommandNames,
|
|
44
|
+
} from './constants';
|
|
45
|
+
export type {
|
|
46
|
+
PTRActionParamKey,
|
|
47
|
+
PTRSdkConfigKey,
|
|
48
|
+
PTRCommandName,
|
|
49
|
+
} from './constants';
|
|
50
|
+
|
|
39
51
|
// ─── React Hooks ───────────────────────────────────────────────────────────────
|
|
40
52
|
export {
|
|
41
53
|
usePointrSdk,
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
package com.pointr
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.StringDef
|
|
4
|
-
|
|
5
|
-
@StringDef(value = [PTRMapWidgetActionType.FOCUS_MAP, PTRMapWidgetActionType.HIGHLIGHT_POI, PTRMapWidgetActionType.DISPLAY_ROUTE, PTRMapWidgetActionType.START_WAYFINDING, PTRMapWidgetActionType.MARK_MY_CAR, PTRMapWidgetActionType.SHOW_MY_CAR, PTRMapWidgetActionType.FOCUS_COORDINATE, PTRMapWidgetActionType.HIGHLIGHT_CATEGORY])
|
|
6
|
-
annotation class PTRMapWidgetActionType {
|
|
7
|
-
companion object {
|
|
8
|
-
const val FOCUS_MAP = "focusMap"
|
|
9
|
-
const val HIGHLIGHT_POI = "highlightPoi"
|
|
10
|
-
const val DISPLAY_ROUTE = "displayRoute"
|
|
11
|
-
const val START_WAYFINDING = "startWayfinding"
|
|
12
|
-
const val MARK_MY_CAR = "markMyCar"
|
|
13
|
-
const val SHOW_MY_CAR = "showMyCar"
|
|
14
|
-
const val FOCUS_COORDINATE = "focusCoordinate"
|
|
15
|
-
const val HIGHLIGHT_CATEGORY = "highlightCategory"
|
|
16
|
-
}
|
|
17
|
-
}
|