@wayq/beekon-rn 0.0.1 → 0.0.3

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 (78) hide show
  1. package/BeekonRn.podspec +3 -3
  2. package/README.md +24 -30
  3. package/android/build.gradle +3 -3
  4. package/android/src/main/java/in/wayq/beekonrn/BeekonRnModule.kt +182 -0
  5. package/android/src/main/java/{com → in}/wayq/beekonrn/BeekonRnPackage.kt +1 -1
  6. package/ios/BeekonRn.h +5 -1
  7. package/ios/BeekonRn.mm +15 -25
  8. package/ios/BeekonRn.swift +96 -116
  9. package/ios/Frameworks/BeekonKit.xcframework/_CodeSignature/CodeDirectory +0 -0
  10. package/ios/Frameworks/BeekonKit.xcframework/_CodeSignature/CodeResources +105 -42
  11. package/ios/Frameworks/BeekonKit.xcframework/_CodeSignature/CodeSignature +0 -0
  12. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/BeekonKit +0 -0
  13. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Info.plist +0 -0
  14. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios.abi.json +2427 -0
  15. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  16. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios.swiftinterface +85 -0
  17. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/PrivacyInfo.xcprivacy +1 -1
  18. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/_CodeSignature/CodeResources +36 -3
  19. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/BeekonKit +0 -0
  20. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Info.plist +0 -0
  21. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios-simulator.abi.json +2427 -0
  22. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  23. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +85 -0
  24. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.abi.json +2427 -0
  25. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  26. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +85 -0
  27. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/PrivacyInfo.xcprivacy +1 -1
  28. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/_CodeSignature/CodeResources +69 -3
  29. package/lib/module/NativeBeekonRn.js +2 -2
  30. package/lib/module/NativeBeekonRn.js.map +1 -1
  31. package/lib/module/beekon.js +50 -53
  32. package/lib/module/beekon.js.map +1 -1
  33. package/lib/module/index.js +1 -0
  34. package/lib/module/index.js.map +1 -1
  35. package/lib/module/internal/mappers.js +49 -21
  36. package/lib/module/internal/mappers.js.map +1 -1
  37. package/lib/module/types/config.js +0 -2
  38. package/lib/module/types/error.js +19 -0
  39. package/lib/module/types/error.js.map +1 -0
  40. package/lib/module/types/location.js +2 -0
  41. package/lib/module/types/{position.js.map → location.js.map} +1 -1
  42. package/lib/typescript/src/NativeBeekonRn.d.ts +22 -26
  43. package/lib/typescript/src/NativeBeekonRn.d.ts.map +1 -1
  44. package/lib/typescript/src/beekon.d.ts +29 -42
  45. package/lib/typescript/src/beekon.d.ts.map +1 -1
  46. package/lib/typescript/src/index.d.ts +3 -3
  47. package/lib/typescript/src/index.d.ts.map +1 -1
  48. package/lib/typescript/src/internal/mappers.d.ts +10 -3
  49. package/lib/typescript/src/internal/mappers.d.ts.map +1 -1
  50. package/lib/typescript/src/types/config.d.ts +23 -31
  51. package/lib/typescript/src/types/config.d.ts.map +1 -1
  52. package/lib/typescript/src/types/error.d.ts +14 -0
  53. package/lib/typescript/src/types/error.d.ts.map +1 -0
  54. package/lib/typescript/src/types/location.d.ts +26 -0
  55. package/lib/typescript/src/types/location.d.ts.map +1 -0
  56. package/lib/typescript/src/types/state.d.ts +9 -9
  57. package/lib/typescript/src/types/state.d.ts.map +1 -1
  58. package/package.json +2 -2
  59. package/scripts/fetch-beekonkit.sh +5 -2
  60. package/src/NativeBeekonRn.ts +22 -26
  61. package/src/beekon.ts +58 -56
  62. package/src/index.tsx +3 -3
  63. package/src/internal/mappers.ts +52 -18
  64. package/src/types/config.ts +23 -32
  65. package/src/types/error.ts +22 -0
  66. package/src/types/location.ts +25 -0
  67. package/src/types/state.ts +13 -7
  68. package/android/src/main/java/com/wayq/beekonrn/BeekonRnModule.kt +0 -233
  69. package/ios/Frameworks/BeekonKit.xcframework/_CodeSignature/CodeRequirements-1 +0 -0
  70. package/lib/module/types/position.js +0 -2
  71. package/lib/module/types/preset.js +0 -2
  72. package/lib/module/types/preset.js.map +0 -1
  73. package/lib/typescript/src/types/position.d.ts +0 -24
  74. package/lib/typescript/src/types/position.d.ts.map +0 -1
  75. package/lib/typescript/src/types/preset.d.ts +0 -12
  76. package/lib/typescript/src/types/preset.d.ts.map +0 -1
  77. package/src/types/position.ts +0 -23
  78. package/src/types/preset.ts +0 -11
@@ -1,79 +1,66 @@
1
1
  import type { BeekonConfig } from './types/config';
2
2
  import type { BeekonState } from './types/state';
3
- import type { Position } from './types/position';
3
+ import type { Location } from './types/location';
4
4
  /**
5
5
  * Public facade for the Beekon SDK. Mirrors the native APIs:
6
6
  *
7
- * - Android: `com.wayq.beekon.Beekon` (object)
8
- * - iOS: `Beekon.shared` (actor)
7
+ * - Android: `in.wayq.beekon.Beekon` (object)
8
+ * - iOS: `BeekonKit.Beekon.shared` (actor)
9
9
  *
10
- * Lifecycle: `init()` once → `configure(config)` → `start()` → ... →
11
- * `stop()` (idempotent) or `shutdown()` (final teardown). Subscribe to
12
- * `onState` / `onPosition` for live updates; query `history(from, to)` for
13
- * persisted points.
10
+ * Lifecycle: `configure(config)` → `start()` → ... → `stop()` (idempotent).
11
+ * Subscribe to `onState` / `onLocation` for live updates; query
12
+ * `history(from, to)` for persisted fixes.
14
13
  *
15
14
  * **Threading:** Methods are safe to call from any JS context. Subscribers'
16
15
  * callbacks fire on the JS thread.
17
16
  *
18
- * **Persistence invariant:** the SDK persists every gated position natively;
19
- * JS is a passive observer. In background, the JS engine is not guaranteed to
20
- * be alive — for past points, use `history()`.
17
+ * **Persistence invariant:** the SDK persists every gated fix natively; JS is
18
+ * a passive observer. In background, the JS engine is not guaranteed to be
19
+ * alive — for past fixes, use `history()`.
21
20
  */
22
21
  declare class BeekonImpl {
23
22
  /**
24
- * Initialize the SDK. Idempotent; safe to call more than once. Must be
25
- * called once before `configure()`.
23
+ * Set tracking parameters. Optional `start()` falls back to the previously
24
+ * persisted config or the SDK default (30s / 100m) if never configured.
26
25
  *
27
- * Errors:
28
- * - `NO_GMS_AVAILABLE` (Android) Google Play Services missing.
29
- */
30
- init(): Promise<void>;
31
- /**
32
- * Set sampling and platform-specific config. Replaces any previous config.
33
- * Must be called before `start()`.
34
- *
35
- * Errors:
36
- * - `NOT_INITIALISED` — `init()` was not called first.
37
- * - `NOT_CONFIGURED` — Android only, `androidNotification` was missing.
26
+ * While tracking, the new gate values take effect on the next admitted fix
27
+ * without restarting the underlying location subscription.
38
28
  */
39
29
  configure(config: BeekonConfig): Promise<void>;
40
30
  /**
41
- * Begin tracking. Transitions state from `idle` → `starting` → `tracking`.
31
+ * Begin tracking. State transitions to `tracking`.
42
32
  *
43
- * Errors:
44
- * - `PERMISSION_DENIED` — location permission not granted.
45
- * - `LOCATION_SERVICES_DISABLED` (iOS) — system location services off.
46
- * - `SERVICE_FAILED` — native service couldn't start.
33
+ * Throws a `BeekonError` with kind:
34
+ * - `'permissionDenied'` — location permission not granted.
35
+ * - `'locationServicesDisabled'` — system location services off (or GMS
36
+ * unavailable on Android).
47
37
  */
48
38
  start(): Promise<void>;
49
- /** Stop tracking. Idempotent. State `stopped`. */
39
+ /** Stop tracking. Idempotent. State transitions to `stopped(user)`. */
50
40
  stop(): Promise<void>;
51
41
  /**
52
- * Final teardown releases native resources. Most apps don't need this;
53
- * `stop()` is sufficient between sessions.
54
- */
55
- shutdown(): Promise<void>;
56
- /**
57
- * Read persisted positions in the time range [from, to]. Returns positions
58
- * in chronological order. Reads come from the SDK's local storage (Room on
42
+ * Read persisted fixes in the time range [from, to]. Returns fixes in
43
+ * chronological order. Reads come from the SDK's local storage (Room on
59
44
  * Android, GRDB on iOS) — the source of truth even when JS was asleep.
60
45
  *
61
- * Retention: positions older than 7 days OR beyond the most recent 100K are
46
+ * Retention: fixes older than 7 days OR beyond the most recent 100K are
62
47
  * pruned automatically.
48
+ *
49
+ * Throws `BeekonError` with kind `'storageFailure'` on database read failure.
63
50
  */
64
- history(from: Date, to: Date): Promise<Position[]>;
51
+ history(from: Date, to: Date): Promise<Location[]>;
65
52
  /**
66
53
  * Subscribe to state transitions. Returns an unsubscribe function. The
67
54
  * current state is delivered to new subscribers immediately (replay-1
68
- * semantics, matching the native `state` flow).
55
+ * semantics, matching the native `state` flow / AsyncStream).
69
56
  */
70
57
  onState(cb: (s: BeekonState) => void): () => void;
71
58
  /**
72
- * Subscribe to gated positions as they arrive. Returns an unsubscribe
59
+ * Subscribe to gated locations as they arrive. Returns an unsubscribe
73
60
  * function. Broadcast (no replay) — only delivers while the JS engine is
74
- * alive. For points emitted while JS was asleep, use `history()`.
61
+ * alive. For fixes emitted while JS was asleep, use `history()`.
75
62
  */
76
- onPosition(cb: (p: Position) => void): () => void;
63
+ onLocation(cb: (l: Location) => void): () => void;
77
64
  }
78
65
  export declare const Beekon: BeekonImpl;
79
66
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"beekon.d.ts","sourceRoot":"","sources":["../../../src/beekon.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAM,UAAU;IACd;;;;;;OAMG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B;;;;;;;OAOG;IACG,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpD;;;;;;;OAOG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,oDAAoD;IAC9C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B;;;;;;;OAOG;IACG,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAKxD;;;;OAIG;IACH,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI;IAKjD;;;;OAIG;IACH,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,IAAI;CAMlD;AAED,eAAO,MAAM,MAAM,YAAmB,CAAC"}
1
+ {"version":3,"file":"beekon.d.ts","sourceRoot":"","sources":["../../../src/beekon.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAQjD;;;;;;;;;;;;;;;;GAgBG;AACH,cAAM,UAAU;IACd;;;;;;OAMG;IACG,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpD;;;;;;;OAOG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5B,uEAAuE;IACjE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B;;;;;;;;;OASG;IACG,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IASxD;;;;OAIG;IACH,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI;IAKjD;;;;OAIG;IACH,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,IAAI;CAMlD;AAED,eAAO,MAAM,MAAM,YAAmB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export { Beekon } from './beekon';
2
2
  export type { BeekonConfig, AndroidNotificationConfig } from './types/config';
3
- export type { Preset } from './types/preset';
4
- export type { BeekonState, PauseReason } from './types/state';
5
- export type { Position } from './types/position';
3
+ export type { BeekonState, StopReason } from './types/state';
4
+ export type { Location } from './types/location';
5
+ export { BeekonError, type BeekonErrorKind } from './types/error';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC9D,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7D,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC"}
@@ -1,8 +1,15 @@
1
1
  import type { BeekonConfig } from '../types/config';
2
2
  import type { BeekonState } from '../types/state';
3
- import type { Position } from '../types/position';
4
- import type { WireConfig, WirePosition, WireState } from '../NativeBeekonRn';
3
+ import type { Location } from '../types/location';
4
+ import type { WireConfig, WireLocation, WireState } from '../NativeBeekonRn';
5
5
  export declare function configToWire(config: BeekonConfig): WireConfig;
6
- export declare function wireToPosition(w: WirePosition): Position;
6
+ export declare function wireToLocation(w: WireLocation): Location;
7
7
  export declare function wireToState(w: WireState): BeekonState;
8
+ /**
9
+ * Re-throw a native promise rejection as a typed `BeekonError`. Native modules
10
+ * encode the kind in the error code string (`PERMISSION_DENIED`,
11
+ * `LOCATION_SERVICES_DISABLED`, `STORAGE_FAILURE`); anything else falls
12
+ * through as the original error.
13
+ */
14
+ export declare function rethrowAsBeekonError(e: unknown): never;
8
15
  //# sourceMappingURL=mappers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../../../../src/internal/mappers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE7E,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAQ7D;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,YAAY,GAAG,QAAQ,CAUxD;AAOD,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,WAAW,CAiBrD"}
1
+ {"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../../../../src/internal/mappers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAK7E,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAM7D;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,YAAY,GAAG,QAAQ,CAUxD;AAeD,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,WAAW,CAYrD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,OAAO,GAAG,KAAK,CAQtD"}
@@ -1,41 +1,33 @@
1
- import type { Preset } from './preset';
2
1
  /**
3
- * Foreground service notification config — required when running on Android
4
- * because Android 8+ requires a persistent notification while a foreground
5
- * service is active. Ignored on iOS.
2
+ * Foreground-service notification overrides. Android-only — required by the
3
+ * platform because every location foreground service must show a persistent
4
+ * notification. All fields are optional; missing values resolve at runtime
5
+ * against the host app's label and icon. Ignored on iOS.
6
6
  */
7
7
  export type AndroidNotificationConfig = {
8
- /** NotificationChannel id (Android 8+). */
9
- channelId: string;
10
- /** User-visible channel display name. */
11
- channelName: string;
12
- /** Foreground notification id. Must be > 0. */
13
- notificationId: number;
14
- /** Notification title shown in the status bar. */
15
- title: string;
16
- /** Notification body text. */
17
- text: string;
8
+ /** Notification title. Defaults to "Location active". */
9
+ title?: string;
10
+ /** Notification body text. Defaults to the host app's label. */
11
+ text?: string;
18
12
  /**
19
- * Drawable resource name for the notification icon (e.g. `ic_notification`).
20
- * Resolved at runtime via `Resources.getIdentifier()` against the host app's
21
- * `res/drawable*` folders. Pass the resource name without extension or
22
- * `R.drawable.` prefix.
13
+ * Drawable resource name (e.g. `ic_notification`) — resolved at runtime via
14
+ * `Resources.getIdentifier()` against the host app's `res/drawable*` folders.
15
+ * Pass the resource name without extension or `R.drawable.` prefix. Defaults
16
+ * to the host app's `applicationInfo.icon`.
23
17
  */
24
- smallIconResName: string;
18
+ smallIconResName?: string;
25
19
  };
20
+ /**
21
+ * Tracking configuration. Two knobs: a minimum time interval and a minimum
22
+ * distance between emitted fixes. A fix is admitted only when **both** gates
23
+ * are satisfied. Pass `0` to disable a gate.
24
+ */
26
25
  export type BeekonConfig = {
27
- /** Sampling preset. Default: `'balanced'`. */
28
- preset?: Preset;
29
- /** Override the preset's distance gate (meters). */
30
- distanceFilterMeters?: number;
31
- /** Override the preset's interval (milliseconds). */
32
- intervalMillis?: number;
33
- /**
34
- * Required when running on Android. Ignored on iOS. The plugin throws
35
- * `NOT_CONFIGURED` if missing on Android.
36
- */
26
+ /** Minimum seconds between admitted fixes. Default: `30`. `0` disables the time gate. */
27
+ intervalSeconds?: number;
28
+ /** Minimum metres between admitted fixes. Default: `100`. `0` disables the distance gate. */
29
+ distanceMeters?: number;
30
+ /** Android-only notification overrides. Ignored on iOS. */
37
31
  androidNotification?: AndroidNotificationConfig;
38
- /** Optional license key. Reserved for future use. */
39
- licenseKey?: string;
40
32
  };
41
33
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,qDAAqD;IACrD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,yBAAyB,CAAC;IAChD,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/types/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,yFAAyF;IACzF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6FAA6F;IAC7F,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,2DAA2D;IAC3D,mBAAmB,CAAC,EAAE,yBAAyB,CAAC;CACjD,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Error kinds thrown from `Beekon.start()` / `Beekon.history()`. Match the
3
+ * native `BeekonError` cases byte-for-byte.
4
+ */
5
+ export type BeekonErrorKind = 'permissionDenied' | 'locationServicesDisabled' | 'storageFailure';
6
+ /**
7
+ * Typed error surfaced from the bridge. The native module rejects promises
8
+ * with the kind encoded as the error code; the facade re-wraps into this.
9
+ */
10
+ export declare class BeekonError extends Error {
11
+ readonly kind: BeekonErrorKind;
12
+ constructor(kind: BeekonErrorKind, message: string);
13
+ }
14
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../src/types/error.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,eAAe,GACvB,kBAAkB,GAClB,0BAA0B,GAC1B,gBAAgB,CAAC;AAErB;;;GAGG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAgB,IAAI,EAAE,eAAe,CAAC;gBAE1B,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM;CAKnD"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * A single location fix as emitted by the native SDK after gating. Fields map
3
+ * 1:1 to `in.wayq.beekon.Location` on Android and `BeekonKit.Location` on iOS.
4
+ *
5
+ * `lat`, `lng`, and `timestamp` are always present. The four optional fields
6
+ * are `null` when the OS did not report a value — the SDK never invents a
7
+ * value to mask absence (e.g. a stationary device returns `bearing === null`,
8
+ * not `0`).
9
+ */
10
+ export type Location = {
11
+ /** Latitude in degrees, WGS-84. */
12
+ lat: number;
13
+ /** Longitude in degrees, WGS-84. */
14
+ lng: number;
15
+ /** Horizontal accuracy in meters (1-sigma); `null` if unreported. */
16
+ accuracy: number | null;
17
+ /** Speed in m/s; `null` if unreported. */
18
+ speed: number | null;
19
+ /** Bearing in degrees `[0, 360)` clockwise from true north; `null` if unreported. */
20
+ bearing: number | null;
21
+ /** Altitude in meters above the WGS-84 ellipsoid; `null` if unreported. */
22
+ altitude: number | null;
23
+ /** Time the OS provider reported this fix (not when JS received it). */
24
+ timestamp: Date;
25
+ };
26
+ //# sourceMappingURL=location.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../../../../src/types/location.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,qEAAqE;IACrE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,qFAAqF;IACrF,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,wEAAwE;IACxE,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC"}
@@ -1,22 +1,22 @@
1
1
  /**
2
- * Why tracking is paused. Names match the native `PauseReason` enum on both
3
- * platforms byte-for-byte.
2
+ * Reason a tracking session ended. Mirrors `StopReason` on both platforms.
3
+ *
4
+ * `'system'` is Android-only — surfaces when the OS terminates the foreground
5
+ * service (memory pressure, force-stop). iOS will never emit `'system'`.
4
6
  */
5
- export type PauseReason = 'permissionRevoked' | 'locationDisabled' | 'unknown';
7
+ export type StopReason = 'user' | 'permissionDenied' | 'locationServicesDisabled' | 'system';
6
8
  /**
7
- * Tracking state. Mirrors the native `BeekonState` sealed hierarchy on both
9
+ * Tracking state. Mirrors the native `BeekonState` sealed type on both
8
10
  * platforms. Use the `kind` field as a discriminator.
11
+ *
12
+ * Lifecycle: `idle → tracking → stopped(reason)`.
9
13
  */
10
14
  export type BeekonState = {
11
15
  kind: 'idle';
12
- } | {
13
- kind: 'starting';
14
16
  } | {
15
17
  kind: 'tracking';
16
- } | {
17
- kind: 'paused';
18
- reason: PauseReason;
19
18
  } | {
20
19
  kind: 'stopped';
20
+ reason: StopReason;
21
21
  };
22
22
  //# sourceMappingURL=state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/types/state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,mBAAmB,GAAG,kBAAkB,GAAG,SAAS,CAAC;AAE/E;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/types/state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,kBAAkB,GAClB,0BAA0B,GAC1B,QAAQ,CAAC;AAEb;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wayq/beekon-rn",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "React Native binding for the Beekon location SDK (Android + iOS).",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -116,7 +116,7 @@
116
116
  "type": "modules",
117
117
  "jsSrcsDir": "src",
118
118
  "android": {
119
- "javaPackageName": "com.wayq.beekonrn"
119
+ "javaPackageName": "in.wayq.beekonrn"
120
120
  }
121
121
  },
122
122
  "prettier": {
@@ -13,9 +13,12 @@
13
13
 
14
14
  set -euo pipefail
15
15
 
16
- VERSION="0.0.1"
16
+ VERSION="0.0.3"
17
17
  URL="https://github.com/wayqteam/beekon-ios-binary/releases/download/v${VERSION}/BeekonKit.xcframework.zip"
18
- EXPECTED_SHA="f7bd79a6d61994977318daa6d722866abd0a61d7d7e5834ab5307df39b6ee60e"
18
+ # TODO(0.0.3): replace with the SHA256 emitted by `scripts/build-xcframework.sh`
19
+ # when the v0.0.3 BeekonKit binary is cut and uploaded. v0.0.3 is the first
20
+ # release with nullable Location fields (accuracy/speed/bearing/altitude).
21
+ EXPECTED_SHA="c2f1990dd7064314deffc4af430839b0c8b7e61851e591c34fb683aed2fff127"
19
22
 
20
23
  ROOT="$(cd "$(dirname "$0")/.." && pwd)"
21
24
  DEST_DIR="${ROOT}/ios/Frameworks"
@@ -5,60 +5,56 @@
5
5
  *
6
6
  * Wire types are flat (primitives + nested flat objects) because Codegen's
7
7
  * TS-to-Kotlin/ObjC type derivation has limited support for unions and
8
- * recursive structures. State variants are encoded as a `type` discriminator
9
- * string with sibling fields nullable per variant.
8
+ * recursive structures. The state variants are encoded as a `type`
9
+ * discriminator string with sibling fields nullable per variant.
10
10
  */
11
11
  import type { CodegenTypes, TurboModule } from 'react-native';
12
12
  import { TurboModuleRegistry } from 'react-native';
13
13
 
14
14
  export type WireAndroidNotification = {
15
- channelId: string;
16
- channelName: string;
17
- notificationId: number;
18
- title: string;
19
- text: string;
20
- smallIconResName: string;
15
+ title?: string;
16
+ text?: string;
17
+ smallIconResName?: string;
21
18
  };
22
19
 
23
20
  export type WireConfig = {
24
- /** One of: 'saver' | 'balanced' | 'precision'. */
25
- preset: string;
26
- distanceFilterMeters?: number;
27
- intervalMillis?: number;
21
+ /** Required at the wire level the TS facade applies defaults (30 / 100). */
22
+ intervalSeconds: number;
23
+ /** Required at the wire level — the TS facade applies defaults (30 / 100). */
24
+ distanceMeters: number;
25
+ /** Android-only. iOS native module ignores. */
28
26
  androidNotification?: WireAndroidNotification;
29
- licenseKey?: string;
30
27
  };
31
28
 
32
- export type WirePosition = {
29
+ export type WireLocation = {
33
30
  lat: number;
34
31
  lng: number;
35
- accuracy: number;
36
- speed: number;
37
- bearing: number;
38
- altitude: number;
39
32
  timestampMs: number;
33
+ /** `null` when the OS did not report a value (e.g. low-confidence fix). */
34
+ accuracy: number | null;
35
+ speed: number | null;
36
+ bearing: number | null;
37
+ altitude: number | null;
40
38
  };
41
39
 
42
40
  export type WireState = {
43
- /** One of: 'idle' | 'starting' | 'tracking' | 'paused' | 'stopped'. */
41
+ /** One of: 'idle' | 'tracking' | 'stopped'. */
44
42
  type: string;
45
43
  /**
46
- * Only populated when `type === 'paused'`. One of:
47
- * 'permissionRevoked' | 'locationDisabled' | 'unknown'.
44
+ * Only populated when `type === 'stopped'`. One of:
45
+ * 'user' | 'permissionDenied' | 'locationServicesDisabled' | 'system'.
48
46
  */
49
- pauseReason?: string;
47
+ stopReason?: string;
50
48
  };
51
49
 
52
50
  export interface Spec extends TurboModule {
53
- initialize(): Promise<void>;
54
51
  configure(config: WireConfig): Promise<void>;
55
52
  start(): Promise<void>;
56
53
  stop(): Promise<void>;
57
- shutdown(): Promise<void>;
58
- history(fromMs: number, toMs: number): Promise<WirePosition[]>;
54
+ history(fromMs: number, toMs: number): Promise<WireLocation[]>;
59
55
 
60
56
  readonly onState: CodegenTypes.EventEmitter<WireState>;
61
- readonly onPosition: CodegenTypes.EventEmitter<WirePosition>;
57
+ readonly onLocation: CodegenTypes.EventEmitter<WireLocation>;
62
58
  }
63
59
 
64
60
  export default TurboModuleRegistry.getEnforcing<Spec>('BeekonRn');
package/src/beekon.ts CHANGED
@@ -1,93 +1,95 @@
1
1
  import NativeBeekon from './NativeBeekonRn';
2
2
  import type { BeekonConfig } from './types/config';
3
3
  import type { BeekonState } from './types/state';
4
- import type { Position } from './types/position';
5
- import { configToWire, wireToPosition, wireToState } from './internal/mappers';
4
+ import type { Location } from './types/location';
5
+ import {
6
+ configToWire,
7
+ wireToLocation,
8
+ wireToState,
9
+ rethrowAsBeekonError,
10
+ } from './internal/mappers';
6
11
 
7
12
  /**
8
13
  * Public facade for the Beekon SDK. Mirrors the native APIs:
9
14
  *
10
- * - Android: `com.wayq.beekon.Beekon` (object)
11
- * - iOS: `Beekon.shared` (actor)
15
+ * - Android: `in.wayq.beekon.Beekon` (object)
16
+ * - iOS: `BeekonKit.Beekon.shared` (actor)
12
17
  *
13
- * Lifecycle: `init()` once → `configure(config)` → `start()` → ... →
14
- * `stop()` (idempotent) or `shutdown()` (final teardown). Subscribe to
15
- * `onState` / `onPosition` for live updates; query `history(from, to)` for
16
- * persisted points.
18
+ * Lifecycle: `configure(config)` → `start()` → ... → `stop()` (idempotent).
19
+ * Subscribe to `onState` / `onLocation` for live updates; query
20
+ * `history(from, to)` for persisted fixes.
17
21
  *
18
22
  * **Threading:** Methods are safe to call from any JS context. Subscribers'
19
23
  * callbacks fire on the JS thread.
20
24
  *
21
- * **Persistence invariant:** the SDK persists every gated position natively;
22
- * JS is a passive observer. In background, the JS engine is not guaranteed to
23
- * be alive — for past points, use `history()`.
25
+ * **Persistence invariant:** the SDK persists every gated fix natively; JS is
26
+ * a passive observer. In background, the JS engine is not guaranteed to be
27
+ * alive — for past fixes, use `history()`.
24
28
  */
25
29
  class BeekonImpl {
26
30
  /**
27
- * Initialize the SDK. Idempotent; safe to call more than once. Must be
28
- * called once before `configure()`.
31
+ * Set tracking parameters. Optional `start()` falls back to the previously
32
+ * persisted config or the SDK default (30s / 100m) if never configured.
29
33
  *
30
- * Errors:
31
- * - `NO_GMS_AVAILABLE` (Android) Google Play Services missing.
32
- */
33
- async init(): Promise<void> {
34
- return NativeBeekon.initialize();
35
- }
36
-
37
- /**
38
- * Set sampling and platform-specific config. Replaces any previous config.
39
- * Must be called before `start()`.
40
- *
41
- * Errors:
42
- * - `NOT_INITIALISED` — `init()` was not called first.
43
- * - `NOT_CONFIGURED` — Android only, `androidNotification` was missing.
34
+ * While tracking, the new gate values take effect on the next admitted fix
35
+ * without restarting the underlying location subscription.
44
36
  */
45
37
  async configure(config: BeekonConfig): Promise<void> {
46
- return NativeBeekon.configure(configToWire(config));
38
+ try {
39
+ await NativeBeekon.configure(configToWire(config));
40
+ } catch (e) {
41
+ rethrowAsBeekonError(e);
42
+ }
47
43
  }
48
44
 
49
45
  /**
50
- * Begin tracking. Transitions state from `idle` → `starting` → `tracking`.
46
+ * Begin tracking. State transitions to `tracking`.
51
47
  *
52
- * Errors:
53
- * - `PERMISSION_DENIED` — location permission not granted.
54
- * - `LOCATION_SERVICES_DISABLED` (iOS) — system location services off.
55
- * - `SERVICE_FAILED` — native service couldn't start.
48
+ * Throws a `BeekonError` with kind:
49
+ * - `'permissionDenied'` — location permission not granted.
50
+ * - `'locationServicesDisabled'` — system location services off (or GMS
51
+ * unavailable on Android).
56
52
  */
57
53
  async start(): Promise<void> {
58
- return NativeBeekon.start();
54
+ try {
55
+ await NativeBeekon.start();
56
+ } catch (e) {
57
+ rethrowAsBeekonError(e);
58
+ }
59
59
  }
60
60
 
61
- /** Stop tracking. Idempotent. State `stopped`. */
61
+ /** Stop tracking. Idempotent. State transitions to `stopped(user)`. */
62
62
  async stop(): Promise<void> {
63
- return NativeBeekon.stop();
63
+ try {
64
+ await NativeBeekon.stop();
65
+ } catch (e) {
66
+ rethrowAsBeekonError(e);
67
+ }
64
68
  }
65
69
 
66
70
  /**
67
- * Final teardown releases native resources. Most apps don't need this;
68
- * `stop()` is sufficient between sessions.
69
- */
70
- async shutdown(): Promise<void> {
71
- return NativeBeekon.shutdown();
72
- }
73
-
74
- /**
75
- * Read persisted positions in the time range [from, to]. Returns positions
76
- * in chronological order. Reads come from the SDK's local storage (Room on
71
+ * Read persisted fixes in the time range [from, to]. Returns fixes in
72
+ * chronological order. Reads come from the SDK's local storage (Room on
77
73
  * Android, GRDB on iOS) — the source of truth even when JS was asleep.
78
74
  *
79
- * Retention: positions older than 7 days OR beyond the most recent 100K are
75
+ * Retention: fixes older than 7 days OR beyond the most recent 100K are
80
76
  * pruned automatically.
77
+ *
78
+ * Throws `BeekonError` with kind `'storageFailure'` on database read failure.
81
79
  */
82
- async history(from: Date, to: Date): Promise<Position[]> {
83
- const wires = await NativeBeekon.history(from.getTime(), to.getTime());
84
- return wires.map(wireToPosition);
80
+ async history(from: Date, to: Date): Promise<Location[]> {
81
+ try {
82
+ const wires = await NativeBeekon.history(from.getTime(), to.getTime());
83
+ return wires.map(wireToLocation);
84
+ } catch (e) {
85
+ rethrowAsBeekonError(e);
86
+ }
85
87
  }
86
88
 
87
89
  /**
88
90
  * Subscribe to state transitions. Returns an unsubscribe function. The
89
91
  * current state is delivered to new subscribers immediately (replay-1
90
- * semantics, matching the native `state` flow).
92
+ * semantics, matching the native `state` flow / AsyncStream).
91
93
  */
92
94
  onState(cb: (s: BeekonState) => void): () => void {
93
95
  const subscription = NativeBeekon.onState((wire) => cb(wireToState(wire)));
@@ -95,13 +97,13 @@ class BeekonImpl {
95
97
  }
96
98
 
97
99
  /**
98
- * Subscribe to gated positions as they arrive. Returns an unsubscribe
100
+ * Subscribe to gated locations as they arrive. Returns an unsubscribe
99
101
  * function. Broadcast (no replay) — only delivers while the JS engine is
100
- * alive. For points emitted while JS was asleep, use `history()`.
102
+ * alive. For fixes emitted while JS was asleep, use `history()`.
101
103
  */
102
- onPosition(cb: (p: Position) => void): () => void {
103
- const subscription = NativeBeekon.onPosition((wire) =>
104
- cb(wireToPosition(wire))
104
+ onLocation(cb: (l: Location) => void): () => void {
105
+ const subscription = NativeBeekon.onLocation((wire) =>
106
+ cb(wireToLocation(wire))
105
107
  );
106
108
  return () => subscription.remove();
107
109
  }
package/src/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  export { Beekon } from './beekon';
2
2
  export type { BeekonConfig, AndroidNotificationConfig } from './types/config';
3
- export type { Preset } from './types/preset';
4
- export type { BeekonState, PauseReason } from './types/state';
5
- export type { Position } from './types/position';
3
+ export type { BeekonState, StopReason } from './types/state';
4
+ export type { Location } from './types/location';
5
+ export { BeekonError, type BeekonErrorKind } from './types/error';