@doorstepai/dropoff-sdk 2.2.7 → 2.2.9

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 (48) hide show
  1. package/README.md +78 -10
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/doorstepai/dropoffsdk/DoorstepAIModule.kt +54 -6
  4. package/android/src/main/java/com/doorstepai/dropoffsdk/DoorstepEmbedViewManager.kt +63 -0
  5. package/android/src/main/java/com/doorstepai/dropoffsdk/HostForegroundServiceWaiter.kt +98 -0
  6. package/ios/DoorstepAI.mm +10 -0
  7. package/ios/DoorstepAI.swift +50 -6
  8. package/ios/DoorstepDropoffSDK.xcframework/Info.plist +5 -5
  9. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/DoorstepDropoffSDK +0 -0
  10. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.abi.json +12846 -6562
  11. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +142 -9
  12. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  13. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.swiftinterface +142 -9
  14. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/_CodeSignature/CodeResources +10 -10
  15. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/DWARF/DoorstepDropoffSDK +0 -0
  16. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/DoorstepDropoffSDK.yml +5069 -3867
  17. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/DoorstepDropoffSDK +0 -0
  18. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +12846 -6562
  19. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +142 -9
  20. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  21. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +142 -9
  22. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +12846 -6562
  23. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +142 -9
  24. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  25. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +142 -9
  26. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/_CodeSignature/CodeResources +20 -20
  27. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/DWARF/DoorstepDropoffSDK +0 -0
  28. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/DoorstepDropoffSDK.yml +5064 -3862
  29. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/DoorstepDropoffSDK.yml +5032 -3836
  30. package/ios/DoorstepEmbedViewManager.mm +9 -0
  31. package/ios/DoorstepEmbedViewManager.swift +46 -5
  32. package/lib/module/DoorstepAI.js +49 -2
  33. package/lib/module/DoorstepAI.js.map +1 -1
  34. package/lib/module/DoorstepEmbedView.js +23 -1
  35. package/lib/module/DoorstepEmbedView.js.map +1 -1
  36. package/lib/module/index.js.map +1 -1
  37. package/lib/typescript/embed-preload.example.d.ts +25 -0
  38. package/lib/typescript/embed-preload.example.d.ts.map +1 -0
  39. package/lib/typescript/src/DoorstepAI.d.ts +39 -8
  40. package/lib/typescript/src/DoorstepAI.d.ts.map +1 -1
  41. package/lib/typescript/src/DoorstepEmbedView.d.ts +34 -3
  42. package/lib/typescript/src/DoorstepEmbedView.d.ts.map +1 -1
  43. package/lib/typescript/src/index.d.ts +2 -2
  44. package/lib/typescript/src/index.d.ts.map +1 -1
  45. package/package.json +1 -1
  46. package/src/DoorstepAI.tsx +88 -7
  47. package/src/DoorstepEmbedView.tsx +64 -9
  48. package/src/index.tsx +3 -0
@@ -27,23 +27,24 @@ type LatLngObject = {
27
27
  /**
28
28
  * A single stop the SDK should geofence in `startRouteGeofencing`. On geofence
29
29
  * ENTER the SDK auto-starts a delivery session for `deliveryId`; on EXIT it stops
30
- * it (only if `markDropoff` was called for that id — otherwise the per-session
31
- * timeout backstop applies).
30
+ * it according to server-owned `misc.geofence.waitForDropoff` policy.
32
31
  */
33
32
  type DeliveryStop = {
34
33
  deliveryId: string;
35
34
  address: string;
36
35
  latitude: number;
37
36
  longitude: number;
38
- /** Fence radius in meters. Falls back to `RouteGeofenceOptions.defaultRadiusMeters` (250 m). */
37
+ /** Stable stop identity, defaulting to deliveryId in the native SDK. */
38
+ routeStopId?: string;
39
+ /** @deprecated Ignored; the server owns geofence radius. */
39
40
  radiusMeters?: number;
40
41
  customerId?: string;
41
42
  driverId?: string;
42
43
  };
43
44
 
44
45
  /** Route-wide options for `startRouteGeofencing`. */
45
- type RouteGeofenceOptions = {
46
- /** Radius (m) for stops that don't set their own `radiusMeters`. Default 250. */
46
+ type RouteOptions = {
47
+ /** @deprecated Ignored; the server owns geofence radius. */
47
48
  defaultRadiusMeters?: number;
48
49
  /** Per-session safety timeout (s) forwarded to the auto-started delivery. */
49
50
  timeoutSeconds?: number;
@@ -51,8 +52,19 @@ type RouteGeofenceOptions = {
51
52
  autoStopAfterDropoffSeconds?: number;
52
53
  /** Android only. Host owns the foreground service; SDK won't promote its own. Ignored on iOS. */
53
54
  manualForeground?: boolean;
55
+ /** Android only. Maximum age of durable route intent in seconds. */
56
+ maxAgeSeconds?: number;
57
+ /** Optional host business route identifier. */
58
+ clientRouteId?: string;
59
+ /** Optional driver identifier for the whole route. */
60
+ driverId?: string;
61
+ /** Small business metadata; native route options accept string values. */
62
+ metadata?: Record<string, string>;
54
63
  };
55
64
 
65
+ /** @deprecated Use RouteOptions. Kept for existing integrations. */
66
+ type RouteGeofenceOptions = RouteOptions;
67
+
56
68
  type GeofenceSessionEventType = 'STARTED' | 'STOPPED';
57
69
 
58
70
  /** Emitted whenever route geofencing auto-starts or auto-stops a session. */
@@ -80,7 +92,7 @@ type StartDeliveryOptions = {
80
92
  timeoutSeconds?: number;
81
93
  /**
82
94
  * Optional countdown (in seconds) to auto-stop the delivery once
83
- * `markDropoff` is invoked. Survives backgrounding/process death on both
95
+ * `stopDelivery` is invoked. Survives backgrounding/process death on both
84
96
  * platforms (UserDefaults on iOS, AlarmManager on Android).
85
97
  */
86
98
  autoStopAfterDropoffSeconds?: number;
@@ -410,10 +422,55 @@ const SDK_LOG_LEVEL_RAW: Record<SDKLogLevel, number> = {
410
422
  critical: 4,
411
423
  };
412
424
 
425
+ /** Android-only host foreground-service readiness options. */
426
+ type HostForegroundServiceWaitOptions = {
427
+ /** Maximum wait in milliseconds, 0–120000. Default 10000; zero checks once. */
428
+ timeoutMs?: number;
429
+ /** Optional fully qualified service class. Omit to accept any non-Doorstep FGS. */
430
+ serviceClassName?: string;
431
+ };
432
+
413
433
  class DoorstepAIModule {
414
434
  /** Cross-platform native Doorstep Go embed component. */
415
435
  static readonly EmbedView = DoorstepEmbedView;
416
436
 
437
+ /**
438
+ * Android only. Resolves after observing a matching host service in foreground
439
+ * state. Rejects on timeout, query failure, or native-module teardown. This does
440
+ * not start a service or verify location permissions, fixes, or future uptime.
441
+ */
442
+ static async waitForHostForegroundService(
443
+ options: HostForegroundServiceWaitOptions = {}
444
+ ): Promise<void> {
445
+ if (Platform.OS !== 'android') {
446
+ return unsupportedOnThisPlatform(
447
+ 'waitForHostForegroundService',
448
+ 'Android'
449
+ );
450
+ }
451
+ const { timeoutMs = 10_000, serviceClassName } = options;
452
+ if (!Number.isInteger(timeoutMs) || timeoutMs < 0 || timeoutMs > 120_000) {
453
+ throw new Error('timeoutMs must be an integer from 0 to 120000');
454
+ }
455
+ if (
456
+ serviceClassName !== undefined &&
457
+ (typeof serviceClassName !== 'string' || serviceClassName.trim() === '')
458
+ ) {
459
+ throw new Error(
460
+ 'serviceClassName must be a nonempty fully qualified class name'
461
+ );
462
+ }
463
+ if (typeof DoorstepAI?.waitForHostForegroundService !== 'function') {
464
+ throw new Error(
465
+ 'waitForHostForegroundService requires an updated native SDK build'
466
+ );
467
+ }
468
+ await DoorstepAI.waitForHostForegroundService(
469
+ timeoutMs,
470
+ serviceClassName ?? null
471
+ );
472
+ }
473
+
417
474
  static isInitialized = false;
418
475
 
419
476
  static async init(
@@ -1032,7 +1089,7 @@ class DoorstepAIModule {
1032
1089
  */
1033
1090
  static async startRouteGeofencing(
1034
1091
  stops: DeliveryStop[],
1035
- options?: RouteGeofenceOptions
1092
+ options?: RouteOptions
1036
1093
  ): Promise<void> {
1037
1094
  try {
1038
1095
  await DoorstepAI.startRouteGeofencing(stops, options ?? null);
@@ -1071,6 +1128,28 @@ class DoorstepAIModule {
1071
1128
  }
1072
1129
  }
1073
1130
 
1131
+ /** Durable route intent, independent of an active delivery session. */
1132
+ static async isRouteGeofencingActive(): Promise<boolean> {
1133
+ return Boolean(await DoorstepAI.isRouteGeofencingActive());
1134
+ }
1135
+
1136
+ /** Canonical SDK route UUID, or null when no route is active. */
1137
+ static async getActiveRouteId(): Promise<string | null> {
1138
+ return (await DoorstepAI.getActiveRouteId()) ?? null;
1139
+ }
1140
+
1141
+ static async getActiveRouteRevision(): Promise<number | null> {
1142
+ return (await DoorstepAI.getActiveRouteRevision()) ?? null;
1143
+ }
1144
+
1145
+ /** Attach JSON metadata to a delivery before or after its session starts. */
1146
+ static async addMetadata(
1147
+ deliveryId: string,
1148
+ metadata: Record<string, unknown>
1149
+ ): Promise<void> {
1150
+ await DoorstepAI.addMetadata(deliveryId, metadata);
1151
+ }
1152
+
1074
1153
  /**
1075
1154
  * Re-arm route geofencing after a process relaunch if a route was active.
1076
1155
  * Safe no-op when no route is persisted.
@@ -1131,6 +1210,7 @@ class DoorstepAIModule {
1131
1210
 
1132
1211
  export { DoorstepAIModule as DoorstepAI };
1133
1212
  export type {
1213
+ HostForegroundServiceWaitOptions,
1134
1214
  AddressType,
1135
1215
  LatLngObject,
1136
1216
  StartDeliveryOptions,
@@ -1147,6 +1227,7 @@ export type {
1147
1227
  SDKLogLevel,
1148
1228
  DeliveryStop,
1149
1229
  RouteGeofenceOptions,
1230
+ RouteOptions,
1150
1231
  GeofenceSessionEvent,
1151
1232
  GeofenceSessionEventType,
1152
1233
  };
@@ -8,6 +8,19 @@ import {
8
8
 
9
9
  export type DoorstepEmbedMode = 'preview' | 'compact';
10
10
 
11
+ export type DoorstepEmbedError = {
12
+ code:
13
+ | 'INVALID_API_KEY'
14
+ | 'DESTINATION_NOT_MAPPED'
15
+ | 'NETWORK_ERROR'
16
+ | 'INTERNAL_SERVER_ERROR';
17
+ stage: 'linkGeneration' | 'webNavigation' | 'initialization' | 'rendering';
18
+ message: string;
19
+ isRetryable: boolean;
20
+ httpStatusCode?: number;
21
+ requestId?: string;
22
+ };
23
+
11
24
  export type DoorstepEmbedViewProps = ViewProps & {
12
25
  /** Delivery address shown by Doorstep Go. */
13
26
  address: string;
@@ -31,23 +44,39 @@ export type DoorstepEmbedViewProps = ViewProps & {
31
44
  polygonColor?: string;
32
45
  /** Parking overlay color as a CSS-compatible color string. */
33
46
  parkingColor?: string;
34
- /** Called after native UI changes between preview and compact mode. */
47
+ /** Optional destination coordinates, forwarded to the signed embed URL. */
48
+ endpoint?: { lat: number; lng: number };
49
+ /** Show the native map-style selector. Default true. */
50
+ mapStyleToggle?: boolean;
51
+ /** Show the native recenter button. Default true. */
52
+ gpsRecenterToggle?: boolean;
53
+ /** Show the page-owned Street View entry point. Default true. */
54
+ streetViewToggle?: boolean;
55
+ /** Show the native expand/collapse button. Default true. */
56
+ expandContractToggle?: boolean;
57
+ /** Initially fit both GPS and destination. Default false. */
58
+ fitGpsOnStart?: boolean;
59
+ /** Page-readiness timeout in seconds. Default 15. */
60
+ readyTimeoutSeconds?: number;
61
+ /** Called after native or host-driven mode changes. */
35
62
  onModeChanged?: (mode: DoorstepEmbedMode) => void;
63
+ /** Called when page navigation starts after link creation. */
64
+ onLoad?: () => void;
65
+ /** Compatibility alias for onLoad. Called when page navigation starts. */
66
+ onLoading?: () => void;
67
+ /** Called when the page reports readiness. */
68
+ onSuccess?: () => void;
36
69
  /** Called when link minting, navigation, or page loading fails. */
37
- onError?: (message: string) => void;
70
+ onError?: (message: string, error: DoorstepEmbedError) => void;
38
71
  };
39
72
 
40
73
  type ModeChangedEvent = {
41
74
  mode: DoorstepEmbedMode;
42
75
  };
43
76
 
44
- type ErrorEvent = {
45
- message: string;
46
- };
47
-
48
77
  type NativeDoorstepEmbedViewProps = Omit<
49
78
  DoorstepEmbedViewProps,
50
- 'onModeChanged' | 'onError'
79
+ 'onModeChanged' | 'onError' | 'onLoad' | 'onLoading' | 'onSuccess'
51
80
  > & {
52
81
  mode: DoorstepEmbedMode;
53
82
  inlineHeight: number;
@@ -59,7 +88,9 @@ type NativeDoorstepEmbedViewProps = Omit<
59
88
  polygonColor: string;
60
89
  parkingColor: string;
61
90
  onModeChanged?: (event: NativeSyntheticEvent<ModeChangedEvent>) => void;
62
- onError?: (event: NativeSyntheticEvent<ErrorEvent>) => void;
91
+ onLoading?: (event: NativeSyntheticEvent<Record<string, never>>) => void;
92
+ onSuccess?: (event: NativeSyntheticEvent<Record<string, never>>) => void;
93
+ onError?: (event: NativeSyntheticEvent<DoorstepEmbedError>) => void;
63
94
  };
64
95
 
65
96
  const DEFAULT_LINK_API = 'https://api.core.doorstep.ai';
@@ -86,7 +117,17 @@ export function DoorstepEmbedView({
86
117
  markerColor = '#027FB8',
87
118
  polygonColor = '#3291BC',
88
119
  parkingColor = '#FF847B',
120
+ endpoint,
121
+ mapStyleToggle = true,
122
+ gpsRecenterToggle = true,
123
+ streetViewToggle = true,
124
+ expandContractToggle = true,
125
+ fitGpsOnStart = false,
126
+ readyTimeoutSeconds = 15,
89
127
  onModeChanged,
128
+ onLoad,
129
+ onLoading,
130
+ onSuccess,
90
131
  onError,
91
132
  style,
92
133
  ...viewProps
@@ -112,13 +153,27 @@ export function DoorstepEmbedView({
112
153
  markerColor={markerColor}
113
154
  polygonColor={polygonColor}
114
155
  parkingColor={parkingColor}
156
+ endpoint={endpoint}
157
+ mapStyleToggle={mapStyleToggle}
158
+ gpsRecenterToggle={gpsRecenterToggle}
159
+ streetViewToggle={streetViewToggle}
160
+ expandContractToggle={expandContractToggle}
161
+ fitGpsOnStart={fitGpsOnStart}
162
+ readyTimeoutSeconds={readyTimeoutSeconds}
115
163
  style={[styles.container, heightStyle, style]}
116
164
  onModeChanged={(event) => {
117
165
  const nextMode = event.nativeEvent.mode;
118
166
  setUncontrolledMode(nextMode);
119
167
  onModeChanged?.(nextMode);
120
168
  }}
121
- onError={(event) => onError?.(event.nativeEvent.message)}
169
+ onLoading={() => {
170
+ onLoad?.();
171
+ if (onLoading !== onLoad) onLoading?.();
172
+ }}
173
+ onSuccess={() => onSuccess?.()}
174
+ onError={(event) =>
175
+ onError?.(event.nativeEvent.message, event.nativeEvent)
176
+ }
122
177
  />
123
178
  );
124
179
  }
package/src/index.tsx CHANGED
@@ -3,9 +3,11 @@ import { DoorstepAI } from './DoorstepAI';
3
3
  import { DoorstepEmbedView } from './DoorstepEmbedView';
4
4
  export type {
5
5
  DoorstepEmbedMode,
6
+ DoorstepEmbedError,
6
7
  DoorstepEmbedViewProps,
7
8
  } from './DoorstepEmbedView';
8
9
  export type {
10
+ HostForegroundServiceWaitOptions,
9
11
  AddressType,
10
12
  LatLngObject,
11
13
  StartDeliveryOptions,
@@ -22,6 +24,7 @@ export type {
22
24
  SDKLogLevel,
23
25
  DeliveryStop,
24
26
  RouteGeofenceOptions,
27
+ RouteOptions,
25
28
  GeofenceSessionEvent,
26
29
  GeofenceSessionEventType,
27
30
  } from './DoorstepAI';