react-native-pointr 9.9.0 → 10.1.0

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.
Files changed (41) hide show
  1. package/API_REFERENCE.md +284 -315
  2. package/CHANGELOG.md +42 -0
  3. package/EXTENDING.md +11 -16
  4. package/README.md +14 -14
  5. package/WAYFINDING_EVENTS.md +5 -3
  6. package/android/build.gradle +1 -1
  7. package/android/src/main/java/com/pointr/PTRCoreExtensions.kt +33 -2
  8. package/android/src/main/java/com/pointr/PTRMapWidgetActionType.kt +17 -0
  9. package/android/src/main/java/com/pointr/PTRMapWidgetManager.kt +162 -406
  10. package/android/src/main/java/com/pointr/{PointrModule.kt → PTRNativeLibrary.kt} +150 -32
  11. package/android/src/main/java/com/pointr/{PointrPackage.kt → PTRPackage.kt} +2 -2
  12. package/ios/PTRMapWidgetContainerView.swift +174 -187
  13. package/ios/PTRMapWidgetManager-Bridging.m +12 -64
  14. package/ios/PTRMapWidgetManager.swift +164 -136
  15. package/ios/PTRNativeLibrary-Bridging.m +38 -2
  16. package/ios/PTRNativeLibrary.swift +206 -26
  17. package/package.json +6 -4
  18. package/react-native-pointr.podspec +1 -1
  19. package/src/NativePointrModule.ts +70 -0
  20. package/src/PTRMapWidgetUtils.ts +67 -144
  21. package/src/actions/index.ts +171 -0
  22. package/src/api/MapWidgetApi.ts +8 -8
  23. package/src/api/PointrSdk.ts +50 -91
  24. package/src/components/index.tsx +27 -26
  25. package/src/constants/index.ts +32 -13
  26. package/src/hooks/index.ts +1 -0
  27. package/src/hooks/usePointrGeofences.ts +37 -0
  28. package/src/hooks/usePointrSdk.ts +12 -5
  29. package/src/index.tsx +37 -70
  30. package/src/managers/PTRPoiManager.ts +2 -2
  31. package/src/types/PTRPoi.ts +5 -2
  32. package/src/types/PTRPosition.ts +15 -5
  33. package/src/types/PTRSite.ts +46 -0
  34. package/src/types/PTRWayfindingEvent.ts +11 -7
  35. package/src/types/config.ts +1 -0
  36. package/src/types/events.ts +1 -0
  37. package/src/types/index.ts +4 -0
  38. package/android/src/main/java/com/pointr/PTRMapWidgetCommandType.kt +0 -20
  39. package/src/PTRCommand.ts +0 -153
  40. package/src/api/index.ts +0 -9
  41. package/src/commands/index.ts +0 -275
@@ -21,15 +21,22 @@ export function usePointrSdk(config?: PTRConfiguration) {
21
21
  setIsInitialized(true);
22
22
  setState(pointrSdk.getState());
23
23
 
24
- pointrSdk.start(() => {
25
- setState(PTRState.RUNNING);
26
- setIsStarted(true);
27
- });
24
+ pointrSdk
25
+ .start()
26
+ .then(() => {
27
+ setState(PTRState.RUNNING);
28
+ setIsStarted(true);
29
+ })
30
+ .catch((err: Error) => {
31
+ setState(PTRState.ERROR);
32
+ setError(err);
33
+ });
28
34
  } catch (err) {
29
35
  setError(err as Error);
30
36
  }
31
37
  }
32
- }, [config, isInitialized]);
38
+ // eslint-disable-next-line react-hooks/exhaustive-deps
39
+ }, []);
33
40
 
34
41
  return {
35
42
  sdk: pointrSdk,
package/src/index.tsx CHANGED
@@ -6,8 +6,8 @@ const LINKING_ERROR =
6
6
  '- You rebuilt the app after installing the package\n' +
7
7
  '- You are not using Expo Go\n';
8
8
 
9
- const PTRNativePointrLibrary = NativeModules.PTRNativePointrLibrary
10
- ? NativeModules.PTRNativePointrLibrary
9
+ const PTRNativeLibrary = NativeModules.PTRNativeLibrary
10
+ ? NativeModules.PTRNativeLibrary
11
11
  : new Proxy(
12
12
  {},
13
13
  {
@@ -17,30 +17,26 @@ const PTRNativePointrLibrary = NativeModules.PTRNativePointrLibrary
17
17
  }
18
18
  );
19
19
 
20
- // Export the native library as default (backwards compatibility)
21
- export default PTRNativePointrLibrary;
20
+ // Default export kept for backward compatibility
21
+ export default PTRNativeLibrary;
22
22
 
23
- // ============================================================================
24
- // NEW API - Recommended for new projects
25
- // ============================================================================
26
-
27
- // Core API
23
+ // ─── Core API ──────────────────────────────────────────────────────────────────
28
24
  export { PointrSdk, pointrSdk } from './api/PointrSdk';
29
- export {
30
- executeMapCommand,
31
- } from './api/MapWidgetApi';
25
+ export { executeMapAction } from './api/MapWidgetApi';
32
26
 
33
- // Constants and Enums
27
+ // ─── Constants & Enums ─────────────────────────────────────────────────────────
34
28
  export {
35
29
  PTRLogLevel,
36
30
  PTRState,
37
31
  PTRAnimationType,
38
- PTRCommandType,
32
+ PTRActionType,
39
33
  PTREvents,
40
34
  PTRErrorMessages,
35
+ PTRWayfindingMode,
36
+ PTRWayfindingEventType,
41
37
  } from './constants';
42
38
 
43
- // React Hooks
39
+ // ─── React Hooks ───────────────────────────────────────────────────────────────
44
40
  export {
45
41
  usePointrSdk,
46
42
  usePointrPosition,
@@ -48,39 +44,34 @@ export {
48
44
  usePointrGeofence,
49
45
  usePointrBuildingClick,
50
46
  usePointrSiteClick,
47
+ usePointrGeofences,
51
48
  } from './hooks';
52
49
 
53
- // Components
50
+ // ─── Components ────────────────────────────────────────────────────────────────
54
51
  export { PTRMapWidget } from './components';
55
52
  export type { PTRMapWidgetProps } from './components';
56
53
 
57
- // Commands (new refactored version)
54
+ // ─── Actions ───────────────────────────────────────────────────────────────────
58
55
  export {
59
- PTRCommand,
60
- PTRSiteCommand,
61
- PTRBuildingCommand,
62
- PTRLevelCommand,
63
- PTRPoiCommand,
64
- PTRPathCommand,
65
- PTRStaticPathCommand,
66
- PTRStaticWayfindingCommand,
67
- PTRMarkMyCarLevelCommand,
68
- PTRMarkMyCarSiteCommand,
69
- PTRShowMyCarSiteCommand,
70
- PTRStartAndFocusCommand,
71
- isPTRSiteCommand,
72
- isPTRBuildingCommand,
73
- isPTRLevelCommand,
74
- isPTRPoiCommand,
75
- isPTRPathCommand,
76
- isPTRStaticPathCommand,
77
- } from './commands';
78
-
79
- // Types
56
+ PTRAction,
57
+ PTRFocusMapAction,
58
+ PTRHighlightPoiAction,
59
+ PTRDisplayRouteAction,
60
+ PTRStartWayfindingAction,
61
+ PTRMarkMyCarAction,
62
+ PTRShowMyCarAction,
63
+ PTRFocusCoordinateAction,
64
+ PTRHighlightCategoryAction as PTRCategoryFilterAction,
65
+ } from './actions';
66
+
67
+ // ─── Types ─────────────────────────────────────────────────────────────────────
80
68
  export type {
81
69
  PTRConfiguration,
82
70
  PTRMapWidgetConfiguration,
83
71
  PTRStateCallback,
72
+ } from './types/config';
73
+
74
+ export type {
84
75
  PTRPositionEvent,
85
76
  PTRBuildingClickEvent,
86
77
  PTRSiteClickEvent,
@@ -88,41 +79,18 @@ export type {
88
79
  PTRGeofence,
89
80
  PTRGeofenceNotification,
90
81
  PTRMapCommandResponse,
91
- } from './types';
92
-
93
- export { PTRGeofenceEventType } from './types';
82
+ } from './types/events';
94
83
 
95
- // ============================================================================
96
- // LEGACY API - Maintained for backwards compatibility
97
- // ============================================================================
84
+ export { PTRGeofenceEventType } from './types/events';
98
85
 
99
- // Export POI Manager functions (legacy)
100
- export { getPois } from './managers/PTRPoiManager';
101
-
102
- // Export Map Widget utilities (legacy)
103
- export { showMapWidget } from './PTRMapWidgetUtils';
104
-
105
- // Legacy command exports (still works but new code should use ./commands)
106
- export {
107
- PTRCommandType as LegacyPTRCommandType,
108
- PTRCommand as LegacyPTRCommand,
109
- PTRSiteCommand as LegacyPTRSiteCommand,
110
- PTRBuildingCommand as LegacyPTRBuildingCommand,
111
- PTRLevelCommand as LegacyPTRLevelCommand,
112
- PTRPoiCommand as LegacyPTRPoiCommand,
113
- PTRPathCommand as LegacyPTRPathCommand,
114
- PTRStaticPathCommand as LegacyPTRStaticPathCommand,
115
- PTRStaticWayfindingCommand as LegacyPTRStaticWayfindingCommand,
116
- PTRMarkMyCarLevelCommand as LegacyPTRMarkMyCarLevelCommand,
117
- PTRMarkMyCarSiteCommand as LegacyPTRMarkMyCarSiteCommand,
118
- PTRShowMyCarSiteCommand as LegacyPTRShowMyCarSiteCommand,
119
- PTRStartAndFocusCommand as LegacyPTRStartAndFocusCommand,
120
- } from './PTRCommand';
121
-
122
- // Export all existing types (maintained for backwards compatibility)
123
86
  export type { PTRPoi, PTRPoiAttributes } from './types/PTRPoi';
124
87
  export type { PTRPosition } from './types/PTRPosition';
125
88
  export type { PTRWayfindingEvent } from './types/PTRWayfindingEvent';
89
+ export type {
90
+ PTRSite,
91
+ PTRBuilding,
92
+ PTRLevel,
93
+ } from './types/PTRSite';
126
94
  export type {
127
95
  PTRGeometry,
128
96
  PTRGeoPoint,
@@ -135,5 +103,4 @@ export type {
135
103
  } from './types/PTRGeometry';
136
104
 
137
105
  // Re-export native module reference
138
- export { PTRNativePointrLibrary };
139
-
106
+ export { PTRNativeLibrary };
@@ -1,7 +1,7 @@
1
1
  import { NativeModules } from 'react-native';
2
2
  import { PTRPoi } from '../types/PTRPoi';
3
3
 
4
- const { PTRNativePointrLibrary } = NativeModules;
4
+ const { PTRNativeLibrary } = NativeModules;
5
5
 
6
6
  /**
7
7
  * Get all Points of Interest (POIs) for a specific site
@@ -11,7 +11,7 @@ const { PTRNativePointrLibrary } = NativeModules;
11
11
  */
12
12
  export async function getPois(siteId: string): Promise<PTRPoi[]> {
13
13
  try {
14
- const pois = await PTRNativePointrLibrary.getPois(siteId);
14
+ const pois = await PTRNativeLibrary.getPois(siteId);
15
15
  return pois as PTRPoi[];
16
16
  } catch (error) {
17
17
  console.error('Failed to get POIs:', error);
@@ -35,8 +35,11 @@ export interface PTRPoi {
35
35
  /** Display name of the POI */
36
36
  name: string;
37
37
 
38
- /** POI type code (e.g., "lobby", "room", "building-outline") */
39
- typeCode: string;
38
+ /** Main POI type (e.g., "lobby", "room", "building-outline") */
39
+ mainType: string;
40
+
41
+ /** Optional sub-type for finer classification within the main type */
42
+ subType?: string;
40
43
 
41
44
  /** Geographic position with site, building, and level information */
42
45
  position: PTRPosition;
@@ -4,19 +4,29 @@
4
4
  export interface PTRPosition {
5
5
  /** Latitude */
6
6
  lat: number;
7
-
7
+ /** Latitude (alias for `lat`) */
8
+ latitude?: number;
9
+
8
10
  /** Longitude */
9
11
  lon: number;
10
-
12
+ /** Longitude (alias for `lon`) */
13
+ longitude?: number;
14
+
11
15
  /** Whether the position is valid */
12
16
  isValid: boolean;
13
-
17
+
14
18
  /** Site identifier */
15
19
  sid: string;
16
-
20
+ /** Site identifier (alias for `sid`) */
21
+ siteId?: string;
22
+
17
23
  /** Building identifier */
18
24
  bid: string;
19
-
25
+ /** Building identifier (alias for `bid`) */
26
+ buildingId?: string;
27
+
20
28
  /** Level index */
21
29
  lvl: number;
30
+ /** Level index (alias for `lvl`) */
31
+ levelIndex?: number;
22
32
  }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Site, Building and Level data structures returned by the Pointr SDK
3
+ * @module types/PTRSite
4
+ */
5
+
6
+ /**
7
+ * A floor / level within a building
8
+ */
9
+ export interface PTRLevel {
10
+ /** Internal level identifier */
11
+ readonly identifier: string;
12
+ /** External (customer-facing) level identifier */
13
+ readonly externalIdentifier: string;
14
+ /** Human-readable level name */
15
+ readonly name: string;
16
+ /** Zero-based index of the level */
17
+ readonly index: number;
18
+ }
19
+
20
+ /**
21
+ * A building within a site
22
+ */
23
+ export interface PTRBuilding {
24
+ /** Internal building identifier */
25
+ readonly identifier: string;
26
+ /** External (customer-facing) building identifier */
27
+ readonly externalIdentifier: string;
28
+ /** Human-readable building name */
29
+ readonly name: string;
30
+ /** Levels available in this building */
31
+ readonly levels: PTRLevel[];
32
+ }
33
+
34
+ /**
35
+ * A Pointr site (venue / campus)
36
+ */
37
+ export interface PTRSite {
38
+ /** Internal site identifier */
39
+ readonly identifier: string;
40
+ /** External (customer-facing) site identifier */
41
+ readonly externalIdentifier: string;
42
+ /** Human-readable site name */
43
+ readonly name: string;
44
+ /** Buildings within this site */
45
+ readonly buildings: PTRBuilding[];
46
+ }
@@ -1,18 +1,22 @@
1
1
  import { PTRPoi } from './PTRPoi';
2
+ import { PTRWayfindingEventType } from '../constants';
2
3
 
3
4
  /**
4
5
  * Wayfinding event data structure
5
6
  * Fired during wayfinding operations to track navigation state
6
7
  */
7
8
  export interface PTRWayfindingEvent {
8
- /**
9
- * Event type:
10
- * -1 = Cancelled (user cancelled the navigation)
11
- * 0 = Started (wayfinding navigation has started)
12
- * 1 = Ended (user completed or closed the navigation)
9
+ /**
10
+ * Event type describing the wayfinding lifecycle.
11
+ * Use {@link PTRWayfindingEventType} enum values for comparisons.
12
+ *
13
+ * For backward compatibility the value is the numeric raw value of the enum:
14
+ * -1 = CANCELLED, 0 = STARTED, 1 = ENDED
13
15
  */
14
- type: number;
15
-
16
+ type: PTRWayfindingEventType;
17
+
16
18
  /** Destination Point of Interest */
17
19
  poi: PTRPoi;
18
20
  }
21
+
22
+ export { PTRWayfindingEventType };
@@ -53,5 +53,6 @@ export interface PTRMapWidgetConfiguration {
53
53
 
54
54
  /**
55
55
  * Callback function for SDK state changes
56
+ * @deprecated Use the Promise returned by {@link PTRSdk.start} instead.
56
57
  */
57
58
  export type PTRStateCallback = (state: string) => void;
@@ -104,3 +104,4 @@ export interface PTRMapCommandResponse {
104
104
  /** Error message if command failed */
105
105
  readonly error?: string;
106
106
  }
107
+
@@ -23,6 +23,7 @@ export { PTRGeofenceEventType } from './events';
23
23
  export type { PTRPoi, PTRPoiAttributes } from './PTRPoi';
24
24
  export type { PTRPosition } from './PTRPosition';
25
25
  export type { PTRWayfindingEvent } from './PTRWayfindingEvent';
26
+ export { PTRWayfindingEventType } from './PTRWayfindingEvent';
26
27
  export type {
27
28
  PTRGeometry,
28
29
  PTRGeoPoint,
@@ -33,3 +34,6 @@ export type {
33
34
  PTRGeoMultiPolygon,
34
35
  PTRGeoCircle,
35
36
  } from './PTRGeometry';
37
+
38
+ // Export site / building / level types
39
+ export type { PTRSite, PTRBuilding, PTRLevel } from './PTRSite';
@@ -1,20 +0,0 @@
1
- package com.pointr
2
-
3
- import androidx.annotation.StringDef
4
-
5
- @StringDef(value = [PTRMapWidgetCommandType.SITE, PTRMapWidgetCommandType.BUILDING, PTRMapWidgetCommandType.LEVEL, PTRMapWidgetCommandType.POI, PTRMapWidgetCommandType.PATH, PTRMapWidgetCommandType.STATIC_PATH, PTRMapWidgetCommandType.STATIC_WAYFINDING, PTRMapWidgetCommandType.START_AND_FOCUS])
6
- annotation class PTRMapWidgetCommandType {
7
- companion object {
8
- const val SITE = "site"
9
- const val BUILDING = "building"
10
- const val LEVEL = "level"
11
- const val POI = "poi"
12
- const val PATH = "path"
13
- const val STATIC_PATH = "staticPath"
14
- const val STATIC_WAYFINDING = "staticWayfinding"
15
- const val MARK_MY_CAR_LEVEL = "markMyCarForLevel"
16
- const val MARK_MY_CAR_SITE = "markMyCarForSite"
17
- const val SHOW_MY_CAR_SITE = "showMyCarForSite"
18
- const val START_AND_FOCUS = "startAndFocus"
19
- }
20
- }
package/src/PTRCommand.ts DELETED
@@ -1,153 +0,0 @@
1
- /**
2
- * Command types supported by the Pointr SDK
3
- */
4
- export enum PTRCommandType {
5
- SITE = "site",
6
- BUILDING = "building",
7
- LEVEL = "level",
8
- POI = "poi",
9
- PATH = "path",
10
- STATIC_PATH = "staticPath",
11
- STATIC_WAYFINDING = "staticWayfinding",
12
- MARK_MY_CAR_LEVEL = "markMyCarForLevel",
13
- MARK_MY_CAR_SITE = "markMyCarForSite",
14
- SHOW_MY_CAR_SITE = "showMyCarForSite",
15
- START_AND_FOCUS = "startAndFocus"
16
- }
17
- /**
18
- * Base class for all Pointr SDK commands
19
- * @param type - the command type
20
- */
21
- export abstract class PTRCommand {
22
- constructor(public type: PTRCommandType = PTRCommandType.SITE) { }
23
- }
24
- /**
25
- * Command to show a site
26
- * @param site - the site to show
27
- */
28
- export class PTRSiteCommand extends PTRCommand {
29
- constructor(public site: string) {
30
- super(PTRCommandType.SITE);
31
- }
32
- }
33
- /**
34
- * Command to show a building
35
- * @param site - the site to show
36
- * @param building - the building to show
37
- */
38
- export class PTRBuildingCommand extends PTRCommand {
39
- constructor(public site: string, public building: string) {
40
- super(PTRCommandType.BUILDING);
41
- }
42
- }
43
- /**
44
- * Command to show a level
45
- * @param site - the site to show
46
- * @param building - the building to show
47
- * @param level - the level to show
48
- */
49
- export class PTRLevelCommand extends PTRCommand {
50
- constructor(public site: string, public building: string, public level: number) {
51
- super(PTRCommandType.LEVEL);
52
- }
53
- }
54
- /**
55
- * Command to show a POI
56
- * @param site - the site that has the POI
57
- * @param poi - the POI to show
58
- */
59
- export class PTRPoiCommand extends PTRCommand {
60
- constructor(public site: string, public poi: string) {
61
- super(PTRCommandType.POI);
62
- }
63
- }
64
- /**
65
- * Command to show a path
66
- * @param site - the site that has the POI
67
- * @param poi - the POI to show the path to from the current location
68
- */
69
- export class PTRPathCommand extends PTRCommand {
70
- constructor(public site: string, public poi: string) {
71
- super(PTRCommandType.PATH);
72
- }
73
- }
74
- /**
75
- * Command to show a static path
76
- * @param site - the site that has the POIs
77
- * @param fromPoi - the POI to start the path from
78
- * @param toPoi - the POI to end the path at
79
- */
80
- export class PTRStaticPathCommand extends PTRCommand {
81
- constructor(public site: string, public fromPoi: string, public toPoi: string) {
82
- super(PTRCommandType.STATIC_PATH);
83
- }
84
- }
85
-
86
- /**
87
- * Command to show static wayfinding using PTRMapWidgetStaticWayfindingAction
88
- * @param site - the site that has the POIs
89
- * @param sourcePoi - the source POI location to start the path from
90
- * @param destinationPoi - the destination POI location to end the path at
91
- */
92
- export class PTRStaticWayfindingCommand extends PTRCommand {
93
- constructor(public site: string, public sourcePoi: string, public destinationPoi: string) {
94
- super(PTRCommandType.STATIC_WAYFINDING);
95
- }
96
- }
97
-
98
- /**
99
- * Command to show mark my car details
100
- * @param site - the site to show mark my car details
101
- * @param building - the building to show mark my car details
102
- * @param level - the level to show mark my car details
103
- * @param shouldShowPopup - flag to show popup or not
104
- * @param animationType - animation type to show map loading
105
- */
106
- export class PTRMarkMyCarLevelCommand extends PTRCommand {
107
- constructor(public site: string, public building: string, public level: number, public shouldShowPopup: boolean = true, public animationType: number = 1) {
108
- super(PTRCommandType.MARK_MY_CAR_LEVEL);
109
- }
110
- }
111
-
112
- /**
113
- * Command to show mark my car details
114
- * @param site - the site to show mark my car details
115
- * @param shouldShowPopup - flag to show popup or not
116
- * @param animationType - animation type to show map loading
117
- */
118
- export class PTRMarkMyCarSiteCommand extends PTRCommand {
119
- constructor(public site: string, public shouldShowPopup: boolean = true, public animationType: number = 1) {
120
- super(PTRCommandType.MARK_MY_CAR_SITE);
121
- }
122
- }
123
-
124
- /**
125
- * Command to show my car details
126
- * @param site - the site to show my car details
127
- * @param shouldShowPopup - flag to show popup or not
128
- * @param animationType - animation type to show map loading
129
- */
130
- export class PTRShowMyCarSiteCommand extends PTRCommand {
131
- constructor(public site: string, public shouldShowPopup: boolean = true, public animationType: number = 1) {
132
- super(PTRCommandType.SHOW_MY_CAR_SITE);
133
- }
134
- }
135
-
136
- /**
137
- * Command to start the SDK and focus on a location using an existing PTR command
138
- * This command is not a PTRCommand itself, but wraps SDK initialization with a focus command
139
- * @param clientId - the client ID for SDK initialization
140
- * @param licenseKey - the license key for SDK initialization
141
- * @param baseUrl - the base URL for SDK initialization
142
- * @param logLevel - the log level for SDK initialization
143
- * @param command - the PTR command to execute after SDK initialization (PTRSiteCommand, PTRBuildingCommand, PTRLevelCommand, or PTRPoiCommand)
144
- */
145
- export class PTRStartAndFocusCommand {
146
- constructor(
147
- public clientId: string,
148
- public licenseKey: string,
149
- public baseUrl: string,
150
- public logLevel: number = 4,
151
- public command: PTRSiteCommand | PTRBuildingCommand | PTRLevelCommand | PTRPoiCommand
152
- ) {}
153
- }
package/src/api/index.ts DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * API utilities for the Pointr SDK
3
- * @module api
4
- */
5
-
6
- export { PointrSdk, pointrSdk } from './PointrSdk';
7
- export {
8
- executeMapCommand,
9
- } from './MapWidgetApi';