@doorstepai/dropoff-sdk 2.2.8 → 2.2.10

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 (46) hide show
  1. package/README.md +48 -2
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/doorstepai/dropoffsdk/DoorstepAIModule.kt +13 -0
  4. package/android/src/main/java/com/doorstepai/dropoffsdk/DoorstepEmbedViewManager.kt +6 -0
  5. package/android/src/main/java/com/doorstepai/dropoffsdk/HostForegroundServiceWaiter.kt +98 -0
  6. package/ios/DoorstepDropoffSDK.xcframework/Info.plist +5 -5
  7. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/DoorstepDropoffSDK +0 -0
  8. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.abi.json +78 -57
  9. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +1 -1
  10. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  11. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.swiftinterface +1 -1
  12. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/_CodeSignature/CodeResources +10 -10
  13. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/DWARF/DoorstepDropoffSDK +0 -0
  14. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/DoorstepDropoffSDK.yml +4604 -4606
  15. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/DoorstepDropoffSDK +0 -0
  16. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +78 -57
  17. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +1 -1
  18. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  19. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +1 -1
  20. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +78 -57
  21. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +1 -1
  22. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  23. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +1 -1
  24. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/_CodeSignature/CodeResources +20 -20
  25. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/DWARF/DoorstepDropoffSDK +0 -0
  26. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/DoorstepDropoffSDK.yml +4605 -4607
  27. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/DoorstepDropoffSDK.yml +4570 -4572
  28. package/ios/DoorstepEmbedViewManager.mm +1 -0
  29. package/ios/DoorstepEmbedViewManager.swift +5 -0
  30. package/lib/module/DoorstepAI.js +28 -0
  31. package/lib/module/DoorstepAI.js.map +1 -1
  32. package/lib/module/DoorstepEmbedView.js +7 -1
  33. package/lib/module/DoorstepEmbedView.js.map +1 -1
  34. package/lib/module/index.js.map +1 -1
  35. package/lib/typescript/embed-preload.example.d.ts +25 -0
  36. package/lib/typescript/embed-preload.example.d.ts.map +1 -0
  37. package/lib/typescript/src/DoorstepAI.d.ts +14 -1
  38. package/lib/typescript/src/DoorstepAI.d.ts.map +1 -1
  39. package/lib/typescript/src/DoorstepEmbedView.d.ts +8 -1
  40. package/lib/typescript/src/DoorstepEmbedView.d.ts.map +1 -1
  41. package/lib/typescript/src/index.d.ts +1 -1
  42. package/lib/typescript/src/index.d.ts.map +1 -1
  43. package/package.json +1 -1
  44. package/src/DoorstepAI.tsx +46 -0
  45. package/src/DoorstepEmbedView.tsx +17 -2
  46. package/src/index.tsx +1 -0
package/README.md CHANGED
@@ -144,6 +144,7 @@ DoorstepAI.setDoorstepGoApiKey('YOUR_DOORSTEP_GO_API_KEY');
144
144
  deliveryID="delivery-123"
145
145
  inlineHeight={300}
146
146
  expandedHeight={600}
147
+ borderRadius={16}
147
148
  linkAPI="https://api.core.doorstep.ai"
148
149
  baseMap="light"
149
150
  parkingText="95% of drivers parked here"
@@ -151,7 +152,7 @@ DoorstepAI.setDoorstepGoApiKey('YOUR_DOORSTEP_GO_API_KEY');
151
152
  polygonColor="#3291BC"
152
153
  parkingColor="#FF847B"
153
154
  onModeChanged={(mode) => console.log('embed mode', mode)}
154
- onLoading={() => console.log('embed loading')}
155
+ onLoad={() => console.log('embed navigation started')}
155
156
  onSuccess={() => console.log('embed ready')}
156
157
  onError={(message, error) => console.warn(error.code, error.stage, message)}
157
158
  />
@@ -160,10 +161,27 @@ DoorstepAI.setDoorstepGoApiKey('YOUR_DOORSTEP_GO_API_KEY');
160
161
  `DoorstepAI.EmbedView` accepts the same props. `mode` is optional: omit it to let
161
162
  the native expand/collapse control own the mode, or provide it as a controlled
162
163
  prop. The component defaults its height to the active mode's `inlineHeight` or
163
- `expandedHeight`; an explicit `style.height` overrides that behavior. Keep the
164
+ `expandedHeight`; an explicit `style.height` overrides that behavior.
165
+ `borderRadius` (points/dp, default 0) rounds the native map card itself — use it
166
+ instead of `style.borderRadius`, which does not clip the native map. Keep the
164
167
  view mounted while it is visible, because detaching Android's WebGL-backed map
165
168
  destroys its graphics context.
166
169
 
170
+ For preloading and revealing the same mounted map only after `onSuccess`, see
171
+ [`embed-preload.example.tsx`](./embed-preload.example.tsx). It keeps the native
172
+ view attached at full size with opacity zero while loading, disables touch and
173
+ accessibility while hidden, and handles errors and a bounded preload timeout.
174
+ Use `show={false}` to preload for later, then set it to `true` to reveal once
175
+ ready. Keep its parent mounted and avoid navigation that detaches native screens.
176
+ This retains a live view in memory; it does not download a durable offline map.
177
+
178
+ `onLoad` fires when navigation starts after the signed link is created;
179
+ `onLoading` remains a compatibility alias. `onSuccess` fires when the page reports
180
+ map readiness, so use it to reveal a preloaded map. `onLoad` alone does not mean
181
+ the map is ready. These callbacks require the updated JavaScript package and a
182
+ rebuilt native app on both Android and iOS; an Expo OTA JavaScript update alone
183
+ cannot add missing native callbacks.
184
+
167
185
  The optional `mapStyleToggle`, `gpsRecenterToggle`, `streetViewToggle`, and
168
186
  `expandContractToggle` props default to `true` on both platforms. `endpoint={{lat, lng}}`
169
187
  forwards destination coordinates, `fitGpsOnStart` defaults to `false`, and
@@ -254,6 +272,34 @@ type RouteOptions = {
254
272
  // RouteGeofenceOptions remains a deprecated alias for source compatibility.
255
273
  ```
256
274
 
275
+ For Android routes using a host-owned location foreground service, start that
276
+ service while the app is visible, then await readiness before starting the route:
277
+
278
+ ```ts
279
+ await Location.startLocationUpdatesAsync(LOCATION_TASK, locationOptions);
280
+ await DoorstepAI.waitForHostForegroundService({
281
+ timeoutMs: 10_000,
282
+ serviceClassName: 'expo.modules.location.services.LocationTaskService',
283
+ });
284
+ await DoorstepAI.startRouteGeofencing(stops, { manualForeground: true });
285
+ ```
286
+
287
+ `waitForHostForegroundService(options?): Promise<void>` is Android-only and
288
+ rejects on iOS. It checks immediately, then every 100 ms using Android's own-app
289
+ running-service query. `timeoutMs` defaults to 10000 and accepts integer values
290
+ from 0 to 120000; zero performs one immediate check. Omit `serviceClassName` to
291
+ accept any foreground service in your app except Doorstep's tracking service.
292
+ For Expo, match its service class as above so unrelated services cannot satisfy
293
+ the wait. Rejections have native codes `HOST_FGS_TIMEOUT`,
294
+ `HOST_FGS_CHECK_FAILED`, or `HOST_FGS_CANCELLED` (module teardown).
295
+ The query is deprecated but still supports inspecting the caller's own services.
296
+
297
+ Success is a snapshot of foreground state, not proof of location-service type,
298
+ permissions, fresh fixes, or future uptime. Keep the host location service alive
299
+ for the entire route. This method does not start a service, initialize tracking,
300
+ or alter `manualForeground`. Updating JavaScript alone is insufficient: rebuild
301
+ the native Android app after updating the SDK.
302
+
257
303
  | method | notes |
258
304
  |---|---|
259
305
  | `startRouteGeofencing(stops, options?): Promise<void>` | Rejects if no stop has a `deliveryId` + coordinates. |
@@ -90,7 +90,7 @@ dependencies {
90
90
  // `onRequestPermissionsResult` to `DoorstepAI.notePermissionRequestResult(...)`
91
91
  // (the only way the SDK can tell a re-askable denial from a permanent one), so
92
92
  // the SDK's types have to be on the host's compile classpath.
93
- api("ai.doorstep.com:doorstepai-dropoff-sdk:2.2.13")
93
+ api("ai.doorstep.com:doorstepai-dropoff-sdk:2.2.16")
94
94
  api "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1"
95
95
  }
96
96
 
@@ -796,6 +796,18 @@ class DoorstepAIModule(private val reactContext: ReactApplicationContext) :
796
796
 
797
797
  // ---- Route geofencing ----
798
798
 
799
+ private val hostForegroundServiceWaiter = HostForegroundServiceWaiter(reactContext)
800
+
801
+ @ReactMethod
802
+ fun waitForHostForegroundService(timeoutMs: Double, serviceClassName: String?, promise: Promise) {
803
+ if (!timeoutMs.isFinite() || timeoutMs < 0 || timeoutMs > 120_000 || timeoutMs % 1.0 != 0.0 ||
804
+ (serviceClassName != null && serviceClassName.isBlank())) {
805
+ promise.reject("INVALID_ARGUMENT", "timeoutMs must be an integer from 0 to 120000; serviceClassName must be nonempty")
806
+ return
807
+ }
808
+ hostForegroundServiceWaiter.waitFor(timeoutMs.toLong(), serviceClassName, promise)
809
+ }
810
+
799
811
  private val moduleScope = CoroutineScope(Dispatchers.Main + SupervisorJob())
800
812
  private var geofenceJob: Job? = null
801
813
 
@@ -923,6 +935,7 @@ class DoorstepAIModule(private val reactContext: ReactApplicationContext) :
923
935
  }
924
936
 
925
937
  override fun invalidate() {
938
+ hostForegroundServiceWaiter.invalidate()
926
939
  if (activeInstance === this) activeInstance = null
927
940
  geofenceJob?.cancel()
928
941
  geofenceJob = null
@@ -114,6 +114,12 @@ class DoorstepEmbedViewManager : SimpleViewManager<DoorstepEmbedView>() {
114
114
  props(view).expandedHeight = value
115
115
  }
116
116
 
117
+ // Not `borderRadius`: that name is React Native's own view style prop.
118
+ @ReactProp(name = "embedBorderRadius", defaultFloat = 0f)
119
+ fun setEmbedBorderRadius(view: DoorstepEmbedView, value: Float) {
120
+ view.borderRadiusDp = value
121
+ }
122
+
117
123
  @ReactProp(name = "baseMap")
118
124
  fun setBaseMap(view: DoorstepEmbedView, value: String?) {
119
125
  props(view).baseMap = value ?: "light"
@@ -0,0 +1,98 @@
1
+ package com.doorstepai.dropoffsdk
2
+
3
+ import android.app.ActivityManager
4
+ import android.content.Context
5
+ import android.os.Handler
6
+ import android.os.Looper
7
+ import android.os.SystemClock
8
+ import com.facebook.react.bridge.Promise
9
+ import java.util.concurrent.atomic.AtomicBoolean
10
+
11
+ /** Queries only this application's services; never starts or promotes a service. */
12
+ internal class HostForegroundServiceWaiter(private val context: Context) {
13
+ private val handler = Handler(Looper.getMainLooper())
14
+ private val invalidated = AtomicBoolean(false)
15
+ // Accessed only on the main thread, including teardown.
16
+ private val pending = mutableSetOf<Wait>()
17
+
18
+ fun waitFor(timeoutMs: Long, serviceClassName: String?, promise: Promise) {
19
+ handler.post {
20
+ if (invalidated.get()) {
21
+ promise.reject("HOST_FGS_CANCELLED", "React Native module was destroyed")
22
+ } else {
23
+ val wait = Wait(SystemClock.elapsedRealtime() + timeoutMs, serviceClassName, promise)
24
+ pending.add(wait)
25
+ wait.run()
26
+ }
27
+ }
28
+ }
29
+
30
+ fun invalidate() {
31
+ invalidated.set(true)
32
+ handler.post {
33
+ pending.toList().forEach { it.cancel() }
34
+ }
35
+ }
36
+
37
+ private fun hostServiceIsForeground(serviceClassName: String?): Boolean {
38
+ val manager = context.getSystemService(Context.ACTIVITY_SERVICE) as? ActivityManager
39
+ ?: throw IllegalStateException("ActivityManager is unavailable")
40
+ @Suppress("DEPRECATION")
41
+ val services = manager.getRunningServices(Int.MAX_VALUE).orEmpty()
42
+ return services.any {
43
+ it.foreground && it.service.packageName == context.packageName &&
44
+ it.service.className != SDK_SERVICE_CLASS &&
45
+ (serviceClassName == null || it.service.className == serviceClassName)
46
+ }
47
+ }
48
+
49
+ private inner class Wait(
50
+ private val deadlineMs: Long,
51
+ private val serviceClassName: String?,
52
+ private val promise: Promise,
53
+ ) : Runnable {
54
+ private var settled = false
55
+
56
+ override fun run() {
57
+ if (settled) return
58
+ if (invalidated.get()) {
59
+ cancel()
60
+ return
61
+ }
62
+ try {
63
+ if (hostServiceIsForeground(serviceClassName)) {
64
+ finish()
65
+ promise.resolve(null)
66
+ return
67
+ }
68
+ val remainingMs = deadlineMs - SystemClock.elapsedRealtime()
69
+ if (remainingMs <= 0) {
70
+ finish()
71
+ promise.reject("HOST_FGS_TIMEOUT", "No matching host foreground service became ready before timeout")
72
+ return
73
+ }
74
+ handler.postDelayed(this, minOf(POLL_INTERVAL_MS, remainingMs))
75
+ } catch (error: Exception) {
76
+ finish()
77
+ promise.reject("HOST_FGS_CHECK_FAILED", "Unable to query host foreground services", error)
78
+ }
79
+ }
80
+
81
+ fun cancel() {
82
+ if (settled) return
83
+ finish()
84
+ promise.reject("HOST_FGS_CANCELLED", "React Native module was destroyed")
85
+ }
86
+
87
+ private fun finish() {
88
+ settled = true
89
+ handler.removeCallbacks(this)
90
+ pending.remove(this)
91
+ }
92
+ }
93
+
94
+ private companion object {
95
+ const val POLL_INTERVAL_MS = 100L
96
+ const val SDK_SERVICE_CLASS = "com.doorstepai.sdks.tracking.internal.TrackingService"
97
+ }
98
+ }
@@ -10,18 +10,15 @@
10
10
  <key>DebugSymbolsPath</key>
11
11
  <string>dSYMs</string>
12
12
  <key>LibraryIdentifier</key>
13
- <string>ios-arm64_x86_64-simulator</string>
13
+ <string>ios-arm64</string>
14
14
  <key>LibraryPath</key>
15
15
  <string>DoorstepDropoffSDK.framework</string>
16
16
  <key>SupportedArchitectures</key>
17
17
  <array>
18
18
  <string>arm64</string>
19
- <string>x86_64</string>
20
19
  </array>
21
20
  <key>SupportedPlatform</key>
22
21
  <string>ios</string>
23
- <key>SupportedPlatformVariant</key>
24
- <string>simulator</string>
25
22
  </dict>
26
23
  <dict>
27
24
  <key>BinaryPath</key>
@@ -29,15 +26,18 @@
29
26
  <key>DebugSymbolsPath</key>
30
27
  <string>dSYMs</string>
31
28
  <key>LibraryIdentifier</key>
32
- <string>ios-arm64</string>
29
+ <string>ios-arm64_x86_64-simulator</string>
33
30
  <key>LibraryPath</key>
34
31
  <string>DoorstepDropoffSDK.framework</string>
35
32
  <key>SupportedArchitectures</key>
36
33
  <array>
37
34
  <string>arm64</string>
35
+ <string>x86_64</string>
38
36
  </array>
39
37
  <key>SupportedPlatform</key>
40
38
  <string>ios</string>
39
+ <key>SupportedPlatformVariant</key>
40
+ <string>simulator</string>
41
41
  </dict>
42
42
  </array>
43
43
  <key>CFBundlePackageType</key>