@wayq/beekon-rn 0.0.7 → 0.0.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.
- package/BeekonRn.podspec +1 -1
- package/CHANGELOG.md +43 -0
- package/README.md +67 -5
- package/android/build.gradle +3 -2
- package/android/src/main/java/in/wayq/beekonrn/BeekonRnModule.kt +106 -8
- package/ios/BeekonRn.mm +35 -0
- package/ios/BeekonRn.swift +140 -8
- package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/BeekonKit +0 -0
- package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Info.plist +0 -0
- package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios.abi.json +6048 -3656
- package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios.swiftinterface +95 -18
- package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/BeekonKit +0 -0
- package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Info.plist +0 -0
- package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios-simulator.abi.json +6048 -3656
- package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +95 -18
- package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.abi.json +6048 -3656
- package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +95 -18
- package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/_CodeSignature/CodeResources +1 -1
- package/lib/module/NativeBeekonRn.js.map +1 -1
- package/lib/module/beekon.js +97 -1
- package/lib/module/beekon.js.map +1 -1
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal/licenseNudge.js +64 -0
- package/lib/module/internal/licenseNudge.js.map +1 -0
- package/lib/module/internal/mappers.js +56 -8
- package/lib/module/internal/mappers.js.map +1 -1
- package/lib/module/types/config.js +73 -1
- package/lib/module/types/config.js.map +1 -1
- package/lib/module/types/log.js +4 -0
- package/lib/module/types/log.js.map +1 -0
- package/lib/typescript/src/NativeBeekonRn.d.ts +47 -2
- package/lib/typescript/src/NativeBeekonRn.d.ts.map +1 -1
- package/lib/typescript/src/beekon.d.ts +46 -1
- package/lib/typescript/src/beekon.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +4 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/internal/licenseNudge.d.ts +38 -0
- package/lib/typescript/src/internal/licenseNudge.d.ts.map +1 -0
- package/lib/typescript/src/internal/mappers.d.ts +3 -1
- package/lib/typescript/src/internal/mappers.d.ts.map +1 -1
- package/lib/typescript/src/types/config.d.ts +90 -7
- package/lib/typescript/src/types/config.d.ts.map +1 -1
- package/lib/typescript/src/types/enums.d.ts +8 -0
- package/lib/typescript/src/types/enums.d.ts.map +1 -1
- package/lib/typescript/src/types/log.d.ts +22 -0
- package/lib/typescript/src/types/log.d.ts.map +1 -0
- package/lib/typescript/src/types/state.d.ts +4 -1
- package/lib/typescript/src/types/state.d.ts.map +1 -1
- package/package.json +1 -1
- package/scripts/fetch-beekonkit.sh +4 -4
- package/src/NativeBeekonRn.ts +49 -2
- package/src/beekon.ts +100 -1
- package/src/index.tsx +7 -1
- package/src/internal/licenseNudge.ts +80 -0
- package/src/internal/mappers.ts +67 -7
- package/src/types/config.ts +99 -7
- package/src/types/enums.ts +9 -0
- package/src/types/log.ts +22 -0
- package/src/types/state.ts +4 -0
package/ios/BeekonRn.swift
CHANGED
|
@@ -24,6 +24,7 @@ import BeekonKit
|
|
|
24
24
|
private let onSyncStatusCb: (NSDictionary) -> Void
|
|
25
25
|
private let onAuthTokensCb: (NSDictionary) -> Void
|
|
26
26
|
private let onLicenseStatusCb: (NSDictionary) -> Void
|
|
27
|
+
private let onLogCb: (NSDictionary) -> Void
|
|
27
28
|
|
|
28
29
|
private var stateTask: Task<Void, Never>?
|
|
29
30
|
private var locationsTask: Task<Void, Never>?
|
|
@@ -31,11 +32,12 @@ import BeekonKit
|
|
|
31
32
|
private var syncStatusTask: Task<Void, Never>?
|
|
32
33
|
private var authTokensTask: Task<Void, Never>?
|
|
33
34
|
private var licenseStatusTask: Task<Void, Never>?
|
|
35
|
+
private var logsTask: Task<Void, Never>?
|
|
34
36
|
|
|
35
37
|
// Reported to the native verifier via setWrapperInfo (diagnostics only — the
|
|
36
38
|
// verifier consumes only the product). Keep in sync with package.json
|
|
37
39
|
// "version" on release.
|
|
38
|
-
private static let wrapperVersion = "0.0.
|
|
40
|
+
private static let wrapperVersion = "0.0.9"
|
|
39
41
|
|
|
40
42
|
@objc public init(
|
|
41
43
|
onState: @escaping (NSDictionary) -> Void,
|
|
@@ -43,7 +45,8 @@ import BeekonKit
|
|
|
43
45
|
onGeofenceEvent: @escaping (NSDictionary) -> Void,
|
|
44
46
|
onSyncStatus: @escaping (NSDictionary) -> Void,
|
|
45
47
|
onAuthTokens: @escaping (NSDictionary) -> Void,
|
|
46
|
-
onLicenseStatus: @escaping (NSDictionary) -> Void
|
|
48
|
+
onLicenseStatus: @escaping (NSDictionary) -> Void,
|
|
49
|
+
onLog: @escaping (NSDictionary) -> Void
|
|
47
50
|
) {
|
|
48
51
|
// Identify this wrapper to the native verifier (license-format-v1 §11) before
|
|
49
52
|
// any configure() can run — a direct native call (nonisolated static),
|
|
@@ -55,6 +58,7 @@ import BeekonKit
|
|
|
55
58
|
self.onSyncStatusCb = onSyncStatus
|
|
56
59
|
self.onAuthTokensCb = onAuthTokens
|
|
57
60
|
self.onLicenseStatusCb = onLicenseStatus
|
|
61
|
+
self.onLogCb = onLog
|
|
58
62
|
super.init()
|
|
59
63
|
self.stateTask = Task { [weak self] in
|
|
60
64
|
guard let self = self else { return }
|
|
@@ -92,6 +96,12 @@ import BeekonKit
|
|
|
92
96
|
self.onLicenseStatusCb(self.licenseStatusToWire(status))
|
|
93
97
|
}
|
|
94
98
|
}
|
|
99
|
+
self.logsTask = Task { [weak self] in
|
|
100
|
+
guard let self = self else { return }
|
|
101
|
+
for await entry in await Beekon.shared.logs {
|
|
102
|
+
self.onLogCb(self.logEntryToWire(entry))
|
|
103
|
+
}
|
|
104
|
+
}
|
|
95
105
|
}
|
|
96
106
|
|
|
97
107
|
@objc public func invalidate() {
|
|
@@ -101,12 +111,14 @@ import BeekonKit
|
|
|
101
111
|
syncStatusTask?.cancel()
|
|
102
112
|
authTokensTask?.cancel()
|
|
103
113
|
licenseStatusTask?.cancel()
|
|
114
|
+
logsTask?.cancel()
|
|
104
115
|
stateTask = nil
|
|
105
116
|
locationsTask = nil
|
|
106
117
|
geofenceEventsTask = nil
|
|
107
118
|
syncStatusTask = nil
|
|
108
119
|
authTokensTask = nil
|
|
109
120
|
licenseStatusTask = nil
|
|
121
|
+
logsTask = nil
|
|
110
122
|
}
|
|
111
123
|
|
|
112
124
|
/// Register Beekon's background-refresh task and install cold-launch hooks.
|
|
@@ -123,11 +135,22 @@ import BeekonKit
|
|
|
123
135
|
@objc public func configure(
|
|
124
136
|
_ config: NSDictionary,
|
|
125
137
|
resolver resolve: @escaping @Sendable (Any?) -> Void,
|
|
126
|
-
rejecter
|
|
138
|
+
rejecter reject: @escaping @Sendable (String?, String?, Error?) -> Void
|
|
127
139
|
) {
|
|
140
|
+
// GATED on beekon native 0.0.9 (sealed BeekonConfig) — does not compile
|
|
141
|
+
// against the pinned 0.0.8 dep. `wireToConfig` now throws: the cloud arm
|
|
142
|
+
// (`try BeekonConfig.cloud(...)`) raises BeekonError.invalidConfiguration on
|
|
143
|
+
// an empty/invalid projectKey, which we surface via the existing reject path.
|
|
144
|
+
//
|
|
128
145
|
// Convert the non-Sendable NSDictionary to a Sendable BeekonConfig before
|
|
129
146
|
// crossing into the Task closure.
|
|
130
|
-
let cfg
|
|
147
|
+
let cfg: BeekonConfig
|
|
148
|
+
do {
|
|
149
|
+
cfg = try wireToConfig(config)
|
|
150
|
+
} catch {
|
|
151
|
+
reject(errorCode(error), error.localizedDescription, error)
|
|
152
|
+
return
|
|
153
|
+
}
|
|
131
154
|
Task {
|
|
132
155
|
await Beekon.shared.configure(cfg)
|
|
133
156
|
resolve(nil)
|
|
@@ -322,9 +345,96 @@ import BeekonKit
|
|
|
322
345
|
}
|
|
323
346
|
}
|
|
324
347
|
|
|
348
|
+
// MARK: - Diagnostic logs (spec diagnostics/log-format-v1)
|
|
349
|
+
|
|
350
|
+
@objc public func getLogFromMs(
|
|
351
|
+
_ fromMs: Double,
|
|
352
|
+
toMs: Double,
|
|
353
|
+
resolver resolve: @escaping @Sendable (Any?) -> Void,
|
|
354
|
+
rejecter reject: @escaping @Sendable (String?, String?, Error?) -> Void
|
|
355
|
+
) {
|
|
356
|
+
Task { [weak self] in
|
|
357
|
+
guard let self = self else { return }
|
|
358
|
+
do {
|
|
359
|
+
let from = Date(timeIntervalSince1970: fromMs / 1000.0)
|
|
360
|
+
let to = Date(timeIntervalSince1970: toMs / 1000.0)
|
|
361
|
+
let entries = try await Beekon.shared.getLog(from: from, to: to)
|
|
362
|
+
resolve(entries.map { self.logEntryToWire($0) })
|
|
363
|
+
} catch {
|
|
364
|
+
reject(self.errorCode(error), error.localizedDescription, error)
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
@objc public func exportLogWithResolver(
|
|
370
|
+
_ resolve: @escaping @Sendable (Any?) -> Void,
|
|
371
|
+
rejecter reject: @escaping @Sendable (String?, String?, Error?) -> Void
|
|
372
|
+
) {
|
|
373
|
+
Task { [weak self] in
|
|
374
|
+
guard let self = self else { return }
|
|
375
|
+
do {
|
|
376
|
+
resolve(try await Beekon.shared.exportLog())
|
|
377
|
+
} catch {
|
|
378
|
+
reject(self.errorCode(error), error.localizedDescription, error)
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
@objc public func clearLogWithResolver(
|
|
384
|
+
_ resolve: @escaping @Sendable (Any?) -> Void,
|
|
385
|
+
rejecter reject: @escaping @Sendable (String?, String?, Error?) -> Void
|
|
386
|
+
) {
|
|
387
|
+
Task { [weak self] in
|
|
388
|
+
guard let self = self else { return }
|
|
389
|
+
do {
|
|
390
|
+
try await Beekon.shared.clearLog()
|
|
391
|
+
resolve(nil)
|
|
392
|
+
} catch {
|
|
393
|
+
reject(self.errorCode(error), error.localizedDescription, error)
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
@objc public func setLogLevel(
|
|
399
|
+
_ level: String,
|
|
400
|
+
resolver resolve: @escaping @Sendable (Any?) -> Void,
|
|
401
|
+
rejecter _: @escaping @Sendable (String?, String?, Error?) -> Void
|
|
402
|
+
) {
|
|
403
|
+
// setLogLevel is nonisolated on the actor — callable synchronously.
|
|
404
|
+
Beekon.shared.setLogLevel(logLevelFromWire(level))
|
|
405
|
+
resolve(nil)
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
@objc public func logWithLevel(
|
|
409
|
+
_ level: String,
|
|
410
|
+
message: String,
|
|
411
|
+
resolver resolve: @escaping @Sendable (Any?) -> Void,
|
|
412
|
+
rejecter _: @escaping @Sendable (String?, String?, Error?) -> Void
|
|
413
|
+
) {
|
|
414
|
+
Beekon.shared.log(logLevelFromWire(level), message)
|
|
415
|
+
resolve(nil)
|
|
416
|
+
}
|
|
417
|
+
|
|
325
418
|
// MARK: - Mappers: wire (NSDictionary/NSArray) → Beekon
|
|
326
419
|
|
|
327
|
-
|
|
420
|
+
// GATED on beekon native 0.0.9 (sealed BeekonConfig) — does not compile against
|
|
421
|
+
// the pinned 0.0.8 dep (the flat BeekonConfig(...) init). Switches on the wire
|
|
422
|
+
// `mode` (cloud-mode-v1 §2) to build the matching sealed arm. The cloud factory
|
|
423
|
+
// is throwing (`try BeekonConfig.cloud(...)`): an empty/invalid projectKey
|
|
424
|
+
// raises BeekonError.invalidConfiguration, propagated to configure()'s reject.
|
|
425
|
+
// iOS has NO `notification`, so the cloud arm omits it.
|
|
426
|
+
private func wireToConfig(_ d: NSDictionary) throws -> BeekonConfig {
|
|
427
|
+
if d["mode"] as? String == "cloud" {
|
|
428
|
+
let projectKey = (d["projectKey"] as? String) ?? ""
|
|
429
|
+
// Omitted endpoint → the baked-in Beekon Cloud default.
|
|
430
|
+
let endpoint = (d["endpoint"] as? String) ?? "https://api.getbeekon.com"
|
|
431
|
+
return try BeekonConfig.cloud(
|
|
432
|
+
projectKey: projectKey,
|
|
433
|
+
endpoint: endpoint,
|
|
434
|
+
logLevel: logLevelFromWire(d["logLevel"] as? String)
|
|
435
|
+
)
|
|
436
|
+
}
|
|
437
|
+
|
|
328
438
|
let minTime =
|
|
329
439
|
(d["minTimeBetweenLocationsSeconds"] as? NSNumber)?.doubleValue ?? 30
|
|
330
440
|
let minDist =
|
|
@@ -343,6 +453,7 @@ import BeekonKit
|
|
|
343
453
|
headers: entriesToDict((s["headers"] as? NSArray) ?? []),
|
|
344
454
|
intervalSeconds: (s["intervalSeconds"] as? NSNumber)?.doubleValue ?? 300,
|
|
345
455
|
batchSize: (s["batchSize"] as? NSNumber)?.intValue ?? 100,
|
|
456
|
+
syncThreshold: (s["syncThreshold"] as? NSNumber)?.intValue ?? 0,
|
|
346
457
|
auth: auth
|
|
347
458
|
)
|
|
348
459
|
} else {
|
|
@@ -352,8 +463,9 @@ import BeekonKit
|
|
|
352
463
|
}
|
|
353
464
|
}
|
|
354
465
|
|
|
355
|
-
// `notification` is Android-only — iOS ignores it
|
|
356
|
-
|
|
466
|
+
// `notification` is Android-only — iOS ignores it (the selfManaged factory
|
|
467
|
+
// takes no notification parameter on iOS).
|
|
468
|
+
return BeekonConfig.selfManaged(
|
|
357
469
|
minTimeBetweenLocationsSeconds: minTime,
|
|
358
470
|
minDistanceBetweenLocationsMeters: minDist,
|
|
359
471
|
accuracyMode: accuracyModeFromWire(d["accuracyMode"] as? String),
|
|
@@ -363,7 +475,8 @@ import BeekonKit
|
|
|
363
475
|
sync: sync,
|
|
364
476
|
// Passed through verbatim; nil/blank means unset — the SDK falls through to
|
|
365
477
|
// the Info.plist value, then evaluation (license-format-v1 §9).
|
|
366
|
-
licenseKey: d["licenseKey"] as? String
|
|
478
|
+
licenseKey: d["licenseKey"] as? String,
|
|
479
|
+
logLevel: logLevelFromWire(d["logLevel"] as? String)
|
|
367
480
|
)
|
|
368
481
|
}
|
|
369
482
|
|
|
@@ -471,6 +584,16 @@ import BeekonKit
|
|
|
471
584
|
]
|
|
472
585
|
}
|
|
473
586
|
|
|
587
|
+
private func logEntryToWire(_ e: LogEntry) -> NSDictionary {
|
|
588
|
+
return [
|
|
589
|
+
"id": e.id,
|
|
590
|
+
"timestampMs": e.timestamp.timeIntervalSince1970 * 1000.0,
|
|
591
|
+
"level": e.level.rawValue,
|
|
592
|
+
"category": e.category,
|
|
593
|
+
"message": e.message,
|
|
594
|
+
]
|
|
595
|
+
}
|
|
596
|
+
|
|
474
597
|
private func stateToWire(_ s: BeekonState) -> NSDictionary {
|
|
475
598
|
switch s {
|
|
476
599
|
case .idle:
|
|
@@ -590,12 +713,21 @@ import BeekonKit
|
|
|
590
713
|
}
|
|
591
714
|
}
|
|
592
715
|
|
|
716
|
+
// Wire token (LogLevel.rawValue, lowercase) -> LogLevel; unknown defaults to .info.
|
|
717
|
+
private func logLevelFromWire(_ s: String?) -> LogLevel {
|
|
718
|
+
LogLevel(rawValue: s ?? "") ?? .info
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
// GATED on beekon native 0.0.9 (StopReason.cloudModeUnavailable) — the new case
|
|
722
|
+
// does not exist on the pinned 0.0.8 dep. (Non-frozen enum, so the existing
|
|
723
|
+
// `@unknown default` already keeps this compiling either way.)
|
|
593
724
|
private func stopReasonToWire(_ r: StopReason) -> String {
|
|
594
725
|
switch r {
|
|
595
726
|
case .user: return "user"
|
|
596
727
|
case .permissionDenied: return "permissionDenied"
|
|
597
728
|
case .locationServicesDisabled: return "locationServicesDisabled"
|
|
598
729
|
case .locationUnavailable: return "locationUnavailable"
|
|
730
|
+
case .cloudModeUnavailable: return "cloudModeUnavailable"
|
|
599
731
|
case .system: return "system"
|
|
600
732
|
@unknown default: return "system"
|
|
601
733
|
}
|
|
Binary file
|