therms-device-tracker 1.0.0-rc.1 → 1.0.0-rc.2
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/CHANGELOG.md +15 -0
- package/android/build.gradle +2 -2
- package/build/NativeModule.d.ts.map +1 -1
- package/build/NativeModule.js +7 -2
- package/build/NativeModule.js.map +1 -1
- package/build/ThermsDeviceTrackerModule.web.d.ts +2 -2
- package/build/ThermsDeviceTrackerModule.web.d.ts.map +1 -1
- package/build/ThermsDeviceTrackerModule.web.js +56 -1
- package/build/ThermsDeviceTrackerModule.web.js.map +1 -1
- package/build/ThermsDeviceTrackerModuleSharedObject.d.ts +2 -1
- package/build/ThermsDeviceTrackerModuleSharedObject.d.ts.map +1 -1
- package/build/ThermsDeviceTrackerModuleSharedObject.js +31 -3
- package/build/ThermsDeviceTrackerModuleSharedObject.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js.map +1 -1
- package/ios/ThermsDeviceTracker.podspec +1 -1
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.0.0-rc.2] - 2026-06-18
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- **Critical for web / non-native consumers**: Module failed to load with `SyntaxError: Export 'ThermsTracker' is not defined` (and similar) when doing `import ... from 'therms-device-tracker'` (directly or via `useThermsTracker`, `ThermsDeviceTrackerModule`, etc.) in web bundles (`expo start --web`), Next.js + react-native-web, static exports, or plain Node environments.
|
|
14
|
+
- Root cause was `export { ThermsTracker as ThermsDeviceTrackerModuleSharedObject }` of a `declare class ThermsTracker` (TypeScript-only) in `ThermsDeviceTrackerModuleSharedObject.ts`. The emitted JS contained a bare value re-export of an undefined identifier.
|
|
15
|
+
- Fixed by removing the invalid value re-export, sourcing the legacy alias from the module object (where native injects the real `ThermsTracker` SharedObject class), and making `createThermsTracker` / `useThermsTracker` defensive.
|
|
16
|
+
- `NativeModule` now uses `requireOptionalNativeModule` with fallbacks (`ThermsDeviceTracker` → `ThermsDeviceTrackerModule`) so high-level APIs (ready, events, start/stop, geofencing, sync, etc.) do not hard-throw when the native module is not present.
|
|
17
|
+
- Web implementation now registers under the canonical name `'ThermsDeviceTracker'` and attaches a `WebThermsTracker` stub class so the SharedObject surface is present (properties delegate to existing web module methods for snapshot state).
|
|
18
|
+
- `ThermsTracker` type is now exported from the package root (`export type { ThermsTracker }`).
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- `expo-module.config.json` still declares native-only platforms; web remains a partial stub (no background location, geofencing, motion, etc.). The package is now safely importable and usable for the web geolocation path + event-driven state without crashing bundlers or tests.
|
|
22
|
+
|
|
23
|
+
## [1.0.0-rc.1] (and prior work)
|
|
24
|
+
|
|
10
25
|
### Added
|
|
11
26
|
- Initial scaffold for ThermsDeviceTracker Expo module.
|
|
12
27
|
- Config plugin for permissions and background modes.
|
package/android/build.gradle
CHANGED
|
@@ -4,13 +4,13 @@ plugins {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
group = 'expo.modules.thermsdevicetracker'
|
|
7
|
-
version = '0.
|
|
7
|
+
version = '1.0.0-rc.2'
|
|
8
8
|
|
|
9
9
|
android {
|
|
10
10
|
namespace "expo.modules.thermsdevicetracker"
|
|
11
11
|
defaultConfig {
|
|
12
12
|
versionCode 1
|
|
13
|
-
versionName "0.
|
|
13
|
+
versionName "1.0.0-rc.2"
|
|
14
14
|
}
|
|
15
15
|
lintOptions {
|
|
16
16
|
abortOnError false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeModule.d.ts","sourceRoot":"","sources":["../src/NativeModule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,YAAY,EAAS,QAAQ,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"NativeModule.d.ts","sourceRoot":"","sources":["../src/NativeModule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,YAAY,EAAS,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAyB5E,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,aAAa,CAAa;IAElC,OAAO,CAAC,aAAa;IAMrB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI;IAUxD,kBAAkB;IAaZ,KAAK,CAAC,MAAM,CAAC,EAAE,YAAY;IAS3B,KAAK,CAAC,MAAM,CAAC,EAAE,YAAY;IAS3B,IAAI;IAKV,QAAQ;IAIR,uBAAuB;IAIvB,gBAAgB;IAMhB,WAAW,CAAC,QAAQ,EAAE,QAAQ;IAI9B,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE;IAIlC,cAAc,CAAC,UAAU,EAAE,MAAM;IAIjC,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE;IAItC,YAAY,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAInC,cAAc;IAKd,YAAY;IAKZ,QAAQ;IAIR,gBAAgB;IAIhB,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM;IAI7B,cAAc,CAAC,QAAQ,EAAE,GAAG;IAK5B,aAAa;IAIb,YAAY;IAMZ,SAAS;IAIT,QAAQ;CAGT;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,GAAG,OAgB3C;AAED,eAAO,MAAM,oBAAoB,qBAA4B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,IAAI,YAAY,EAAE,CAAC;AAChD,eAAe,oBAAoB,CAAC"}
|
package/build/NativeModule.js
CHANGED
|
@@ -9,14 +9,19 @@
|
|
|
9
9
|
* - Config normalization / validation
|
|
10
10
|
* - Bridge concerns isolated from the public facade
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
12
|
+
import { requireOptionalNativeModule } from 'expo';
|
|
13
13
|
import { Event } from './ThermsDeviceTracker.types';
|
|
14
14
|
const VALID_EVENT_NAMES = new Set(Object.values(Event));
|
|
15
15
|
let _rawModule = null;
|
|
16
16
|
function getRawModule() {
|
|
17
17
|
if (_rawModule)
|
|
18
18
|
return _rawModule;
|
|
19
|
-
|
|
19
|
+
// Use optional to avoid hard crash on web / environments without the native module.
|
|
20
|
+
// Try the canonical name first, then the web module registration name as fallback.
|
|
21
|
+
_rawModule =
|
|
22
|
+
requireOptionalNativeModule('ThermsDeviceTracker') ??
|
|
23
|
+
requireOptionalNativeModule('ThermsDeviceTrackerModule') ??
|
|
24
|
+
{};
|
|
20
25
|
return _rawModule;
|
|
21
26
|
}
|
|
22
27
|
export class NativeModuleWrapper {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeModule.js","sourceRoot":"","sources":["../src/NativeModule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAE3C,OAAO,EAAgB,KAAK,EAAY,MAAM,6BAA6B,CAAC;AAE5E,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAUxD,IAAI,UAAU,GAAqB,IAAI,CAAC;AAExC,SAAS,YAAY;IACnB,IAAI,UAAU;QAAE,OAAO,UAAU,CAAC;IAClC,UAAU,GAAG,mBAAmB,CAAY,qBAAqB,CAAC,CAAC;IACnE,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,OAAO,mBAAmB;IACtB,aAAa,GAAU,EAAE,CAAC;IAE1B,aAAa,CAAC,KAAa;QACjC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAY,CAAC,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,wCAAwC,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,IAAI,EAAE,CAAC;QACb,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QAC1B,gGAAgG;QAChG,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;YACxB,uEAAuE;QACzE,CAAC;QACD,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,uBAAuB;QAClD,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;IACf,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,mBAAmB,EAAE,CAAC;AAC9D,OAAO,EAAE,oBAAoB,IAAI,YAAY,EAAE,CAAC;AAChD,eAAe,oBAAoB,CAAC","sourcesContent":["/**\n * NativeModule abstraction layer.\n *\n * Inspired by the excellent separation in react-native-background-geolocation's NativeModule.js.\n *\n * Responsibilities:\n * - Wrap the raw Expo native module\n * - Handle event subscriptions with validation and cleanup\n * - Config normalization / validation\n * - Bridge concerns isolated from the public facade\n */\n\nimport { requireNativeModule } from 'expo';\n\nimport { ThermsConfig, Event, Geofence } from './ThermsDeviceTracker.types';\n\nconst VALID_EVENT_NAMES = new Set(Object.values(Event));\n\ntype RawModule = any & {\n ready?: (config?: ThermsConfig) => Promise<any>;\n start?: () => Promise<void>;\n stop?: () => Promise<void>;\n getState?: () => any;\n // ... other raw methods exposed by the Swift/Kotlin module\n};\n\nlet _rawModule: RawModule | null = null;\n\nfunction getRawModule(): RawModule {\n if (_rawModule) return _rawModule;\n _rawModule = requireNativeModule<RawModule>('ThermsDeviceTracker');\n return _rawModule;\n}\n\nexport class NativeModuleWrapper {\n private subscriptions: any[] = [];\n\n private validateEvent(event: string) {\n if (!VALID_EVENT_NAMES.has(event as any)) {\n throw new Error(`[ThermsDeviceTracker] Unknown event '${event}'`);\n }\n }\n\n addListener(event: string, listener: (data: any) => void) {\n this.validateEvent(event);\n const module = getRawModule();\n const sub = (module as any).addListener?.(event, listener);\n if (sub) {\n this.subscriptions.push(sub);\n }\n return sub;\n }\n\n removeAllListeners() {\n this.subscriptions.forEach((sub) => {\n try {\n sub.remove?.();\n } catch {}\n });\n this.subscriptions = [];\n try {\n (getRawModule() as any).removeAllListeners?.();\n } catch {}\n }\n\n // Config + lifecycle (reference style)\n async ready(config?: ThermsConfig) {\n const normalized = normalizeConfig(config);\n const module = getRawModule();\n if (typeof (module as any).ready === 'function') {\n return (module as any).ready(normalized);\n }\n return this.start(normalized);\n }\n\n async start(config?: ThermsConfig) {\n const normalized = normalizeConfig(config);\n const module = getRawModule();\n if (normalized && typeof (module as any).setConfig === 'function') {\n await (module as any).setConfig(normalized);\n }\n return (module as any).startTrackingAsync?.(normalized) || (module as any).start?.();\n }\n\n async stop() {\n const module = getRawModule();\n return (module as any).stopTrackingAsync?.() || (module as any).stop?.();\n }\n\n getState() {\n return (getRawModule() as any).getTrackingStatus?.() || (getRawModule() as any).getState?.();\n }\n\n getCurrentLocationAsync() {\n return (getRawModule() as any).getCurrentLocationAsync?.();\n }\n\n getProviderState() {\n const mod = getRawModule();\n return (mod as any).getProviderState?.() || (mod as any).getTrackingStatus?.();\n }\n\n // Geofencing delegation\n addGeofence(geofence: Geofence) {\n return (getRawModule() as any).addGeofence?.(geofence);\n }\n\n addGeofences(geofences: Geofence[]) {\n return (getRawModule() as any).addGeofences?.(geofences);\n }\n\n removeGeofence(identifier: string) {\n return (getRawModule() as any).removeGeofence?.(identifier);\n }\n\n removeGeofences(identifiers?: string[]) {\n return (getRawModule() as any).removeGeofences?.(identifiers);\n }\n\n getGeofences(): Promise<Geofence[]> {\n return (getRawModule() as any).getGeofences?.();\n }\n\n startGeofences() {\n return (getRawModule() as any).startGeofences?.();\n }\n\n // Persistence\n getLocations() {\n const m = getRawModule() as any;\n return m.getLocations?.() || m.getCurrentSessionHistory?.();\n }\n\n getCount() {\n return (getRawModule() as any).getCount?.();\n }\n\n destroyLocations() {\n return (getRawModule() as any).destroyLocations?.();\n }\n\n destroyLocation(uuid?: string) {\n return (getRawModule() as any).destroyLocation?.(uuid);\n }\n\n insertLocation(location: any) {\n return (getRawModule() as any).insertLocation?.(location);\n }\n\n // Scheduler\n startSchedule() {\n return (getRawModule() as any).startSchedule?.();\n }\n\n stopSchedule() {\n return (getRawModule() as any).stopSchedule?.();\n }\n\n // Background sync (delegation to native impl: SyncManager on iOS, SyncProvider on Android).\n // See ThermsConfig.sync + onSync for details (opt-in, config-driven or explicit start/stopSync).\n startSync() {\n return (getRawModule() as any).startSync?.();\n }\n\n stopSync() {\n return (getRawModule() as any).stopSync?.();\n }\n}\n\n/**\n * Lightweight normalizer for compound config (especially the opt-in `sync` section).\n * Provides early, clear validation and sensible defaults before crossing the bridge.\n * This improves DX and reduces silent fallbacks in native code.\n *\n * Note on sync.interval: platform-enforced mins apply (Android WorkManager >=15min for periodic).\n */\nexport function normalizeConfig(config?: any) {\n if (!config) return config;\n\n const out = { ...config };\n\n if (out.sync) {\n const s = { ...out.sync };\n // url is required for enabled sync (native gracefully handles missing, but we surface it early)\n if (s.enabled && !s.url) {\n // Non-fatal in case someone disables later; native will emit disabled.\n }\n s.batch = s.batch ?? true; // match native default\n out.sync = s;\n }\n\n return out;\n}\n\nexport const NativeModuleInstance = new NativeModuleWrapper();\nexport { NativeModuleInstance as NativeModule };\nexport default NativeModuleInstance;\n"]}
|
|
1
|
+
{"version":3,"file":"NativeModule.js","sourceRoot":"","sources":["../src/NativeModule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,MAAM,CAAC;AAEnD,OAAO,EAAgB,KAAK,EAAY,MAAM,6BAA6B,CAAC;AAE5E,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAUxD,IAAI,UAAU,GAAqB,IAAI,CAAC;AAExC,SAAS,YAAY;IACnB,IA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;IAClD,CAAC;IAED,4FAA4F;IAC5F,iGAAiG;IACjG,SAAS;QACP,OAAQ,YAAY,EAAU,CAAC,SAAS,EAAE,EAAE,CAAC;IAC/C,CAAC;IAED,QAAQ;QACN,OAAQ,YAAY,EAAU,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC9C,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,MAAY;IAC1C,IAAI,CAAC,MAAM;QAAE,OAAO,MAAM,CAAC;IAE3B,MAAM,GAAG,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IAE1B,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;QACb,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QAC1B,gGAAgG;QAChG,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;YACxB,uEAAuE;QACzE,CAAC;QACD,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,uBAAuB;QAClD,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;IACf,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,mBAAmB,EAAE,CAAC;AAC9D,OAAO,EAAE,oBAAoB,IAAI,YAAY,EAAE,CAAC;AAChD,eAAe,oBAAoB,CAAC","sourcesContent":["/**\n * NativeModule abstraction layer.\n *\n * Inspired by the excellent separation in react-native-background-geolocation's NativeModule.js.\n *\n * Responsibilities:\n * - Wrap the raw Expo native module\n * - Handle event subscriptions with validation and cleanup\n * - Config normalization / validation\n * - Bridge concerns isolated from the public facade\n */\n\nimport { requireOptionalNativeModule } from 'expo';\n\nimport { ThermsConfig, Event, Geofence } from './ThermsDeviceTracker.types';\n\nconst VALID_EVENT_NAMES = new Set(Object.values(Event));\n\ntype RawModule = any & {\n ready?: (config?: ThermsConfig) => Promise<any>;\n start?: () => Promise<void>;\n stop?: () => Promise<void>;\n getState?: () => any;\n // ... other raw methods exposed by the Swift/Kotlin module\n};\n\nlet _rawModule: RawModule | null = null;\n\nfunction getRawModule(): RawModule {\n if (_rawModule) return _rawModule;\n // Use optional to avoid hard crash on web / environments without the native module.\n // Try the canonical name first, then the web module registration name as fallback.\n _rawModule =\n requireOptionalNativeModule<RawModule>('ThermsDeviceTracker') ??\n requireOptionalNativeModule<RawModule>('ThermsDeviceTrackerModule') ??\n ({} as RawModule);\n return _rawModule;\n}\n\nexport class NativeModuleWrapper {\n private subscriptions: any[] = [];\n\n private validateEvent(event: string) {\n if (!VALID_EVENT_NAMES.has(event as any)) {\n throw new Error(`[ThermsDeviceTracker] Unknown event '${event}'`);\n }\n }\n\n addListener(event: string, listener: (data: any) => void) {\n this.validateEvent(event);\n const module = getRawModule();\n const sub = (module as any).addListener?.(event, listener);\n if (sub) {\n this.subscriptions.push(sub);\n }\n return sub;\n }\n\n removeAllListeners() {\n this.subscriptions.forEach((sub) => {\n try {\n sub.remove?.();\n } catch {}\n });\n this.subscriptions = [];\n try {\n (getRawModule() as any).removeAllListeners?.();\n } catch {}\n }\n\n // Config + lifecycle (reference style)\n async ready(config?: ThermsConfig) {\n const normalized = normalizeConfig(config);\n const module = getRawModule();\n if (typeof (module as any).ready === 'function') {\n return (module as any).ready(normalized);\n }\n return this.start(normalized);\n }\n\n async start(config?: ThermsConfig) {\n const normalized = normalizeConfig(config);\n const module = getRawModule();\n if (normalized && typeof (module as any).setConfig === 'function') {\n await (module as any).setConfig(normalized);\n }\n return (module as any).startTrackingAsync?.(normalized) || (module as any).start?.();\n }\n\n async stop() {\n const module = getRawModule();\n return (module as any).stopTrackingAsync?.() || (module as any).stop?.();\n }\n\n getState() {\n return (getRawModule() as any).getTrackingStatus?.() || (getRawModule() as any).getState?.();\n }\n\n getCurrentLocationAsync() {\n return (getRawModule() as any).getCurrentLocationAsync?.();\n }\n\n getProviderState() {\n const mod = getRawModule();\n return (mod as any).getProviderState?.() || (mod as any).getTrackingStatus?.();\n }\n\n // Geofencing delegation\n addGeofence(geofence: Geofence) {\n return (getRawModule() as any).addGeofence?.(geofence);\n }\n\n addGeofences(geofences: Geofence[]) {\n return (getRawModule() as any).addGeofences?.(geofences);\n }\n\n removeGeofence(identifier: string) {\n return (getRawModule() as any).removeGeofence?.(identifier);\n }\n\n removeGeofences(identifiers?: string[]) {\n return (getRawModule() as any).removeGeofences?.(identifiers);\n }\n\n getGeofences(): Promise<Geofence[]> {\n return (getRawModule() as any).getGeofences?.();\n }\n\n startGeofences() {\n return (getRawModule() as any).startGeofences?.();\n }\n\n // Persistence\n getLocations() {\n const m = getRawModule() as any;\n return m.getLocations?.() || m.getCurrentSessionHistory?.();\n }\n\n getCount() {\n return (getRawModule() as any).getCount?.();\n }\n\n destroyLocations() {\n return (getRawModule() as any).destroyLocations?.();\n }\n\n destroyLocation(uuid?: string) {\n return (getRawModule() as any).destroyLocation?.(uuid);\n }\n\n insertLocation(location: any) {\n return (getRawModule() as any).insertLocation?.(location);\n }\n\n // Scheduler\n startSchedule() {\n return (getRawModule() as any).startSchedule?.();\n }\n\n stopSchedule() {\n return (getRawModule() as any).stopSchedule?.();\n }\n\n // Background sync (delegation to native impl: SyncManager on iOS, SyncProvider on Android).\n // See ThermsConfig.sync + onSync for details (opt-in, config-driven or explicit start/stopSync).\n startSync() {\n return (getRawModule() as any).startSync?.();\n }\n\n stopSync() {\n return (getRawModule() as any).stopSync?.();\n }\n}\n\n/**\n * Lightweight normalizer for compound config (especially the opt-in `sync` section).\n * Provides early, clear validation and sensible defaults before crossing the bridge.\n * This improves DX and reduces silent fallbacks in native code.\n *\n * Note on sync.interval: platform-enforced mins apply (Android WorkManager >=15min for periodic).\n */\nexport function normalizeConfig(config?: any) {\n if (!config) return config;\n\n const out = { ...config };\n\n if (out.sync) {\n const s = { ...out.sync };\n // url is required for enabled sync (native gracefully handles missing, but we surface it early)\n if (s.enabled && !s.url) {\n // Non-fatal in case someone disables later; native will emit disabled.\n }\n s.batch = s.batch ?? true; // match native default\n out.sync = s;\n }\n\n return out;\n}\n\nexport const NativeModuleInstance = new NativeModuleWrapper();\nexport { NativeModuleInstance as NativeModule };\nexport default NativeModuleInstance;\n"]}
|
|
@@ -42,6 +42,6 @@ declare class ThermsDeviceTrackerModule extends NativeModule<ThermsDeviceTracker
|
|
|
42
42
|
};
|
|
43
43
|
private emitStateChange;
|
|
44
44
|
}
|
|
45
|
-
declare const
|
|
46
|
-
export default
|
|
45
|
+
declare const registered: typeof ThermsDeviceTrackerModule;
|
|
46
|
+
export default registered;
|
|
47
47
|
//# sourceMappingURL=ThermsDeviceTrackerModule.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThermsDeviceTrackerModule.web.d.ts","sourceRoot":"","sources":["../src/ThermsDeviceTrackerModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,YAAY,EAAE,MAAM,MAAM,CAAC;AAEvD,OAAO,EACL,+BAA+B,EAC/B,aAAa,EACb,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,eAAe,EAChB,MAAM,6BAA6B,CAAC;AAErC,cAAM,yBAA0B,SAAQ,YAAY,CAAC,+BAA+B,CAAC;IACnF,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,gBAAgB,CAAuB;IAEzC,mBAAmB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAWlD,uBAAuB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAItD,kBAAkB,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAuC5D,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IASlC,uBAAuB,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAI9D,oBAAoB,IAAI,aAAa,GAAG,IAAI;IAI5C,kBAAkB,IA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M,GAAG,OAAO,CAAC,IAAI,CAAC;IAC9C,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvC,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAC9B,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAO7B,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAC1B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAG7C,gBAAgB;;;;;;IAIhB,OAAO,CAAC,eAAe;CAGxB;AAID,QAAA,MAAM,UAAU,kCAAsE,CAAC;AAmDvF,eAAe,UAAU,CAAC"}
|
|
@@ -128,5 +128,60 @@ class ThermsDeviceTrackerModule extends NativeModule {
|
|
|
128
128
|
this.emit('onTrackingStateChange', this.getTrackingStatus());
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
// Register under the canonical native module name so requireOptionalNativeModule('ThermsDeviceTracker')
|
|
132
|
+
// and high-level APIs work on web.
|
|
133
|
+
const registered = registerWebModule(ThermsDeviceTrackerModule, 'ThermsDeviceTracker');
|
|
134
|
+
// Attach a minimal ThermsTracker stub constructor.
|
|
135
|
+
// This allows `new ThermsDeviceTrackerModule.ThermsTracker()` and useThermsTracker() to return
|
|
136
|
+
// a value with the expected shape. Properties are live snapshots via public getters on the module.
|
|
137
|
+
registered.ThermsTracker = class WebThermsTracker {
|
|
138
|
+
get isTracking() {
|
|
139
|
+
const m = registered;
|
|
140
|
+
try {
|
|
141
|
+
const status = typeof m.getTrackingStatus === 'function' ? m.getTrackingStatus() : null;
|
|
142
|
+
if (status && typeof status.state === 'string') {
|
|
143
|
+
return status.state === 'active';
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch { }
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
get trackingStatus() {
|
|
150
|
+
const m = registered;
|
|
151
|
+
if (typeof m.getTrackingStatus === 'function') {
|
|
152
|
+
try {
|
|
153
|
+
return m.getTrackingStatus();
|
|
154
|
+
}
|
|
155
|
+
catch { }
|
|
156
|
+
}
|
|
157
|
+
return { state: 'inactive', isBackground: false };
|
|
158
|
+
}
|
|
159
|
+
get lastLocation() {
|
|
160
|
+
const m = registered;
|
|
161
|
+
if (typeof m.getLastKnownLocation === 'function') {
|
|
162
|
+
try {
|
|
163
|
+
return m.getLastKnownLocation() ?? undefined;
|
|
164
|
+
}
|
|
165
|
+
catch { }
|
|
166
|
+
}
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
get currentActivity() {
|
|
170
|
+
const m = registered;
|
|
171
|
+
if (typeof m.getCurrentActivity === 'function') {
|
|
172
|
+
try {
|
|
173
|
+
return m.getCurrentActivity() ?? undefined;
|
|
174
|
+
}
|
|
175
|
+
catch { }
|
|
176
|
+
}
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
get sessionStats() {
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
release() {
|
|
183
|
+
// no-op for web stub
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
export default registered;
|
|
132
187
|
//# sourceMappingURL=ThermsDeviceTrackerModule.web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThermsDeviceTrackerModule.web.js","sourceRoot":"","sources":["../src/ThermsDeviceTrackerModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAWvD,MAAM,yBAA0B,SAAQ,YAA6C;IAC3E,OAAO,GAAkB,IAAI,CAAC;IAC9B,UAAU,GAAG,KAAK,CAAC;IACnB,YAAY,GAAyB,IAAI,CAAC;IAC1C,gBAAgB,GAAoB,EAAE,CAAC;IAE/C,KAAK,CAAC,mBAAmB;QACvB,kGAAkG;QAClG,2GAA2G;QAC3G,OAAO;YAC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O,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACzE,CAAC;IAEO,eAAe;QACrB,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAC/D,CAAC;CACF;AAED,eAAe,iBAAiB,CAAC,yBAAyB,EAAE,2BAA2B,CAAC,CAAC","sourcesContent":["import { registerWebModule, NativeModule } from 'expo';\n\nimport {\n ThermsDeviceTrackerModuleEvents,\n LocationPoint,\n ActivityUpdate,\n TrackingStatus,\n PermissionResponse,\n TrackingOptions,\n} from './ThermsDeviceTracker.types';\n\nclass ThermsDeviceTrackerModule extends NativeModule<ThermsDeviceTrackerModuleEvents> {\n private watchId: number | null = null;\n private isTracking = false;\n private lastLocation: LocationPoint | null = null;\n private sessionLocations: LocationPoint[] = [];\n\n async getPermissionsAsync(): Promise<PermissionResponse> {\n // Browser geolocation permission is implicit on first use; no real background/motion distinction.\n // Return full PermissionResponse shape for consistency with native (location + bg + motion + canAskAgain).\n return {\n location: 'undetermined',\n backgroundLocation: 'undetermined',\n motion: 'undetermined',\n canAskAgain: true,\n };\n }\n\n async requestPermissionsAsync(): Promise<PermissionResponse> {\n return this.getPermissionsAsync();\n }\n\n async startTrackingAsync(options?: TrackingOptions): Promise<void> {\n if (!('geolocation' in navigator)) {\n this.emit('onError', { code: 'unavailable', message: 'Geolocation not supported' });\n return;\n }\n this.isTracking = true;\n this.sessionLocations = [];\n this.emitStateChange();\n\n this.watchId = navigator.geolocation.watchPosition(\n (pos) => {\n const point: LocationPoint = {\n latitude: pos.coords.latitude,\n longitude: pos.coords.longitude,\n altitude: pos.coords.altitude ?? undefined,\n accuracy: pos.coords.accuracy ?? undefined,\n speed: pos.coords.speed ?? undefined,\n heading: pos.coords.heading ?? undefined,\n timestamp: pos.timestamp,\n };\n this.lastLocation = point;\n this.sessionLocations.push(point);\n this.emit('onLocationUpdate', point);\n this.emitStateChange();\n },\n (err) => {\n this.emit('onError', { code: 'position_error', message: err.message });\n },\n {\n enableHighAccuracy:\n ((options as any)?.geolocation?.desiredAccuracy ??\n (options as any)?.accuracy ??\n 'balanced') !== 'low',\n maximumAge: 10000,\n timeout: 20000,\n }\n );\n }\n\n async stopTrackingAsync(): Promise<void> {\n if (this.watchId != null) {\n navigator.geolocation.clearWatch(this.watchId);\n this.watchId = null;\n }\n this.isTracking = false;\n this.emitStateChange();\n }\n\n async getCurrentLocationAsync(): Promise<LocationPoint | null> {\n return this.lastLocation;\n }\n\n getLastKnownLocation(): LocationPoint | null {\n return this.lastLocation;\n }\n\n getCurrentActivity(): ActivityUpdate | null {\n // Web: no reliable activity without extra sensors / permissions\n return null;\n }\n\n getTrackingStatus(): TrackingStatus {\n return {\n state: this.isTracking ? 'active' : 'inactive',\n isBackground: false,\n };\n }\n\n async getCurrentSessionHistory() {\n return {\n locations: this.sessionLocations,\n activities: [],\n };\n }\n\n async clearCurrentSessionHistory() {\n this.sessionLocations = [];\n }\n\n // Geofencing stubs (web limited; no native GeofencingClient / CLCircularRegion).\n // Methods match optional signatures in ThermsDeviceTrackerModule.ts + native delegation.\n async addGeofence(_geofence: any): Promise<void> {}\n async addGeofences(_geofences: any[]): Promise<void> {}\n async removeGeofence(_id: string): Promise<void> {}\n async removeGeofences(_ids?: string[]): Promise<void> {}\n async getGeofences(): Promise<any[]> {\n return [];\n }\n async startGeofences(): Promise<void> {}\n\n // Persistence stubs (in-memory only on web; no SharedPreferences/UserDefaults backing).\n async getLocations(): Promise<any> {\n return { locations: this.sessionLocations, activities: [] };\n }\n async getCount(): Promise<number> {\n return this.sessionLocations.length;\n }\n async destroyLocations(): Promise<void> {\n this.sessionLocations = [];\n }\n async destroyLocation(_uuid?: string): Promise<void> {}\n async insertLocation(loc: any): Promise<void> {\n if (loc) this.sessionLocations.push(loc);\n }\n\n // Scheduler stubs (no-op; Android uses Handler timer demo, iOS ScheduleManager).\n async startSchedule(): Promise<void> {}\n async stopSchedule(): Promise<void> {}\n\n // Background sync stubs (no-op on web; no WorkManager / URLSession bg HTTP).\n // - Use ThermsDeviceTracker.onSync(...) for events (works via NativeModule base on all platforms).\n // - Real impls only on native (SyncManager/SyncProvider); config-driven from ready/start or explicit start/stopSync.\n // - See SyncConfig in ThermsDeviceTracker.types.ts and bg sync notes in ARCHITECTURE.md / native headers.\n // - startSync/stopSync are safe no-ops here; do not emit onSync lifecycle (native-only seam).\n async startSync(): Promise<void> {}\n async stopSync(): Promise<void> {}\n\n // Internal seam for NativeModule.start() (calls setConfig if present before startTrackingAsync).\n // Web ignores sync/etc config (no-op support); options handled in startTrackingAsync.\n async setConfig(_config?: any): Promise<void> {}\n\n // Provider state stub (parity with Android getProviderState / iOS equivalent; used by getProviderState).\n getProviderState() {\n return { enabled: false, status: 'denied', gps: false, network: true };\n }\n\n private emitStateChange() {\n this.emit('onTrackingStateChange', this.getTrackingStatus());\n }\n}\n\nexport default registerWebModule(ThermsDeviceTrackerModule, 'ThermsDeviceTrackerModule');\n"]}
|
|
1
|
+
{"version":3,"file":"ThermsDeviceTrackerModule.web.js","sourceRoot":"","sources":["../src/ThermsDeviceTrackerModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAWvD,MAAM,yBAA0B,SAAQ,YAA6C;IAC3E,OAAO,GAAkB,IAAI,CAAC;IAC9B,UAAU,GAAG,KAAK,CAAC;IACnB,YAAY,GAAyB,IAAI,CAAC;IAC1C,gBAAgB,GAAoB,EAAE,CAAC;IAE/C,KAAK,CAAC,mBAAmB;QACvB,kGAAkG;QAClG,2GAA2G;QAC3G,OAAO;YACL,QAAQ,EAAE,cAAc;YACxB,kBAAkB,EAAE,cAAc;YAClC,MAAM,EAAE,cAAc;YACtB,WAAW,EAAE,IAAI;SAClB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,uBAAuB;QAC3B,OAAO,IAAI,C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,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,eAAe;QACjB,MAAM,CAAC,GAAQ,UAAU,CAAC;QAC1B,IAAI,OAAO,CAAC,CAAC,kBAAkB,KAAK,UAAU,EAAE,CAAC;YAC/C,IAAI,CAAC;gBACH,OAAO,CAAC,CAAC,kBAAkB,EAAE,IAAI,SAAS,CAAC;YAC7C,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QACZ,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,YAAY;QACd,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO;QACL,qBAAqB;IACvB,CAAC;CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { registerWebModule, NativeModule } from 'expo';\n\nimport {\n ThermsDeviceTrackerModuleEvents,\n LocationPoint,\n ActivityUpdate,\n TrackingStatus,\n PermissionResponse,\n TrackingOptions,\n} from './ThermsDeviceTracker.types';\n\nclass ThermsDeviceTrackerModule extends NativeModule<ThermsDeviceTrackerModuleEvents> {\n private watchId: number | null = null;\n private isTracking = false;\n private lastLocation: LocationPoint | null = null;\n private sessionLocations: LocationPoint[] = [];\n\n async getPermissionsAsync(): Promise<PermissionResponse> {\n // Browser geolocation permission is implicit on first use; no real background/motion distinction.\n // Return full PermissionResponse shape for consistency with native (location + bg + motion + canAskAgain).\n return {\n location: 'undetermined',\n backgroundLocation: 'undetermined',\n motion: 'undetermined',\n canAskAgain: true,\n };\n }\n\n async requestPermissionsAsync(): Promise<PermissionResponse> {\n return this.getPermissionsAsync();\n }\n\n async startTrackingAsync(options?: TrackingOptions): Promise<void> {\n if (!('geolocation' in navigator)) {\n this.emit('onError', { code: 'unavailable', message: 'Geolocation not supported' });\n return;\n }\n this.isTracking = true;\n this.sessionLocations = [];\n this.emitStateChange();\n\n this.watchId = navigator.geolocation.watchPosition(\n (pos) => {\n const point: LocationPoint = {\n latitude: pos.coords.latitude,\n longitude: pos.coords.longitude,\n altitude: pos.coords.altitude ?? undefined,\n accuracy: pos.coords.accuracy ?? undefined,\n speed: pos.coords.speed ?? undefined,\n heading: pos.coords.heading ?? undefined,\n timestamp: pos.timestamp,\n };\n this.lastLocation = point;\n this.sessionLocations.push(point);\n this.emit('onLocationUpdate', point);\n this.emitStateChange();\n },\n (err) => {\n this.emit('onError', { code: 'position_error', message: err.message });\n },\n {\n enableHighAccuracy:\n ((options as any)?.geolocation?.desiredAccuracy ??\n (options as any)?.accuracy ??\n 'balanced') !== 'low',\n maximumAge: 10000,\n timeout: 20000,\n }\n );\n }\n\n async stopTrackingAsync(): Promise<void> {\n if (this.watchId != null) {\n navigator.geolocation.clearWatch(this.watchId);\n this.watchId = null;\n }\n this.isTracking = false;\n this.emitStateChange();\n }\n\n async getCurrentLocationAsync(): Promise<LocationPoint | null> {\n return this.lastLocation;\n }\n\n getLastKnownLocation(): LocationPoint | null {\n return this.lastLocation;\n }\n\n getCurrentActivity(): ActivityUpdate | null {\n // Web: no reliable activity without extra sensors / permissions\n return null;\n }\n\n getTrackingStatus(): TrackingStatus {\n return {\n state: this.isTracking ? 'active' : 'inactive',\n isBackground: false,\n };\n }\n\n async getCurrentSessionHistory() {\n return {\n locations: this.sessionLocations,\n activities: [],\n };\n }\n\n async clearCurrentSessionHistory() {\n this.sessionLocations = [];\n }\n\n // Geofencing stubs (web limited; no native GeofencingClient / CLCircularRegion).\n // Methods match optional signatures in ThermsDeviceTrackerModule.ts + native delegation.\n async addGeofence(_geofence: any): Promise<void> {}\n async addGeofences(_geofences: any[]): Promise<void> {}\n async removeGeofence(_id: string): Promise<void> {}\n async removeGeofences(_ids?: string[]): Promise<void> {}\n async getGeofences(): Promise<any[]> {\n return [];\n }\n async startGeofences(): Promise<void> {}\n\n // Persistence stubs (in-memory only on web; no SharedPreferences/UserDefaults backing).\n async getLocations(): Promise<any> {\n return { locations: this.sessionLocations, activities: [] };\n }\n async getCount(): Promise<number> {\n return this.sessionLocations.length;\n }\n async destroyLocations(): Promise<void> {\n this.sessionLocations = [];\n }\n async destroyLocation(_uuid?: string): Promise<void> {}\n async insertLocation(loc: any): Promise<void> {\n if (loc) this.sessionLocations.push(loc);\n }\n\n // Scheduler stubs (no-op; Android uses Handler timer demo, iOS ScheduleManager).\n async startSchedule(): Promise<void> {}\n async stopSchedule(): Promise<void> {}\n\n // Background sync stubs (no-op on web; no WorkManager / URLSession bg HTTP).\n // - Use ThermsDeviceTracker.onSync(...) for events (works via NativeModule base on all platforms).\n // - Real impls only on native (SyncManager/SyncProvider); config-driven from ready/start or explicit start/stopSync.\n // - See SyncConfig in ThermsDeviceTracker.types.ts and bg sync notes in ARCHITECTURE.md / native headers.\n // - startSync/stopSync are safe no-ops here; do not emit onSync lifecycle (native-only seam).\n async startSync(): Promise<void> {}\n async stopSync(): Promise<void> {}\n\n // Internal seam for NativeModule.start() (calls setConfig if present before startTrackingAsync).\n // Web ignores sync/etc config (no-op support); options handled in startTrackingAsync.\n async setConfig(_config?: any): Promise<void> {}\n\n // Provider state stub (parity with Android getProviderState / iOS equivalent; used by getProviderState).\n getProviderState() {\n return { enabled: false, status: 'denied', gps: false, network: true };\n }\n\n private emitStateChange() {\n this.emit('onTrackingStateChange', this.getTrackingStatus());\n }\n}\n\n// Register under the canonical native module name so requireOptionalNativeModule('ThermsDeviceTracker')\n// and high-level APIs work on web.\nconst registered = registerWebModule(ThermsDeviceTrackerModule, 'ThermsDeviceTracker');\n\n// Attach a minimal ThermsTracker stub constructor.\n// This allows `new ThermsDeviceTrackerModule.ThermsTracker()` and useThermsTracker() to return\n// a value with the expected shape. Properties are live snapshots via public getters on the module.\n(registered as any).ThermsTracker = class WebThermsTracker {\n get isTracking() {\n const m: any = registered;\n try {\n const status = typeof m.getTrackingStatus === 'function' ? m.getTrackingStatus() : null;\n if (status && typeof status.state === 'string') {\n return status.state === 'active';\n }\n } catch {}\n return false;\n }\n get trackingStatus() {\n const m: any = registered;\n if (typeof m.getTrackingStatus === 'function') {\n try {\n return m.getTrackingStatus();\n } catch {}\n }\n return { state: 'inactive', isBackground: false };\n }\n get lastLocation() {\n const m: any = registered;\n if (typeof m.getLastKnownLocation === 'function') {\n try {\n return m.getLastKnownLocation() ?? undefined;\n } catch {}\n }\n return undefined;\n }\n get currentActivity() {\n const m: any = registered;\n if (typeof m.getCurrentActivity === 'function') {\n try {\n return m.getCurrentActivity() ?? undefined;\n } catch {}\n }\n return undefined;\n }\n get sessionStats() {\n return undefined;\n }\n release() {\n // no-op for web stub\n }\n};\n\nexport default registered;\n"]}
|
|
@@ -40,7 +40,8 @@ export declare function createThermsTracker(): ThermsTracker;
|
|
|
40
40
|
* All instances share the module's tracking state (intentional facade pattern).
|
|
41
41
|
*/
|
|
42
42
|
export declare function useThermsTracker(): ThermsTracker;
|
|
43
|
-
export
|
|
43
|
+
export declare const ThermsDeviceTrackerModuleSharedObject: typeof ThermsTracker;
|
|
44
|
+
export type { ThermsTracker as ThermsDeviceTrackerModuleSharedObjectType };
|
|
44
45
|
export declare const createThermsDeviceTrackerModuleSharedObject: typeof createThermsTracker;
|
|
45
46
|
export declare const useThermsDeviceTrackerModuleSharedObject: typeof useThermsTracker;
|
|
46
47
|
//# sourceMappingURL=ThermsDeviceTrackerModuleSharedObject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThermsDeviceTrackerModuleSharedObject.d.ts","sourceRoot":"","sources":["../src/ThermsDeviceTrackerModuleSharedObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA4B,MAAM,mBAAmB,CAAC;AAE3E,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAGjG;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,YAAY;IACrD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,YAAY,C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eAAO,MAAM,2CAA2C,4BAAsB,CAAC;AAC/E,eAAO,MAAM,wCAAwC,yBAAmB,CAAC"}
|
|
@@ -5,7 +5,20 @@ import ThermsDeviceTrackerModule from './ThermsDeviceTrackerModule';
|
|
|
5
5
|
* You are responsible for releasing it from memory by calling `release()` when done.
|
|
6
6
|
*/
|
|
7
7
|
export function createThermsTracker() {
|
|
8
|
-
|
|
8
|
+
const Mod = ThermsDeviceTrackerModule;
|
|
9
|
+
const Ctor = Mod && Mod.ThermsTracker;
|
|
10
|
+
if (typeof Ctor === 'function') {
|
|
11
|
+
return new Ctor();
|
|
12
|
+
}
|
|
13
|
+
// Web / non-native fallback stub. Real-time state should be observed via events
|
|
14
|
+
// (onLocationUpdate, onTrackingStateChange, etc). The stub has the documented shape.
|
|
15
|
+
return {
|
|
16
|
+
isTracking: false,
|
|
17
|
+
trackingStatus: { state: 'inactive' },
|
|
18
|
+
lastLocation: undefined,
|
|
19
|
+
currentActivity: undefined,
|
|
20
|
+
sessionStats: undefined,
|
|
21
|
+
};
|
|
9
22
|
}
|
|
10
23
|
/**
|
|
11
24
|
* A hook that creates a ThermsTracker instance and automatically
|
|
@@ -14,11 +27,26 @@ export function createThermsTracker() {
|
|
|
14
27
|
* All instances share the module's tracking state (intentional facade pattern).
|
|
15
28
|
*/
|
|
16
29
|
export function useThermsTracker() {
|
|
17
|
-
|
|
30
|
+
const Mod = ThermsDeviceTrackerModule;
|
|
31
|
+
const Ctor = Mod && Mod.ThermsTracker;
|
|
32
|
+
if (typeof Ctor === 'function') {
|
|
33
|
+
return useReleasingSharedObject(() => new Ctor(), []);
|
|
34
|
+
}
|
|
35
|
+
// Web / non-native stub via the releasing hook (consistent lifecycle surface).
|
|
36
|
+
return useReleasingSharedObject(() => ({
|
|
37
|
+
isTracking: false,
|
|
38
|
+
trackingStatus: { state: 'inactive' },
|
|
39
|
+
lastLocation: undefined,
|
|
40
|
+
currentActivity: undefined,
|
|
41
|
+
sessionStats: undefined,
|
|
42
|
+
}), []);
|
|
18
43
|
}
|
|
19
44
|
// Legacy aliases (to be removed after migration)
|
|
20
45
|
// Note: the "ModuleSharedObject" name is historical; prefer ThermsTracker / useThermsTracker.
|
|
21
|
-
|
|
46
|
+
// Export the constructor from the module (where native injects it) to avoid a
|
|
47
|
+
// value re-export of the `declare class` name which produces invalid JS on web.
|
|
48
|
+
export const ThermsDeviceTrackerModuleSharedObject = ThermsDeviceTrackerModule
|
|
49
|
+
.ThermsTracker;
|
|
22
50
|
export const createThermsDeviceTrackerModuleSharedObject = createThermsTracker;
|
|
23
51
|
export const useThermsDeviceTrackerModuleSharedObject = useThermsTracker;
|
|
24
52
|
//# sourceMappingURL=ThermsDeviceTrackerModuleSharedObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThermsDeviceTrackerModuleSharedObject.js","sourceRoot":"","sources":["../src/ThermsDeviceTrackerModuleSharedObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAG3E,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AA+BpE;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,
|
|
1
|
+
{"version":3,"file":"ThermsDeviceTrackerModuleSharedObject.js","sourceRoot":"","sources":["../src/ThermsDeviceTrackerModuleSharedObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAG3E,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AA+BpE;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,GAAG,GAAQ,yBAAyB,CAAC;IAC3C,MAAM,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC;IACtC,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,OAAO,IAAI,IAAI,EAAE,CAAC;IACpB,CAAC;IACD,gFAAgF;IAChF,qFAAqF;IACrF,OAAO;QACL,UAAU,EAAE,KAAK;QACjB,cAAc,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE;QACrC,YAAY,EAAE,SAAS;QACvB,eAAe,EAAE,SAAS;QAC1B,YAAY,EAAE,SAAS;KACjB,CAAC;AACX,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,GAAG,GAAQ,yBAAyB,CAAC;IAC3C,MAAM,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC;IACtC,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,OAAO,wBAAwB,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,+EAA+E;IAC/E,OAAO,wBAAwB,CAC7B,GAAG,EAAE,CAAC,CAAC;QACL,UAAU,EAAE,KAAK;QACjB,cAAc,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE;QACrC,YAAY,EAAE,SAAS;QACvB,eAAe,EAAE,SAAS;QAC1B,YAAY,EAAE,SAAS;KAChB,CAAA,EACT,EAAE,CACH,CAAC;AACJ,CAAC;AAED,iDAAiD;AACjD,8FAA8F;AAC9F,8EAA8E;AAC9E,gFAAgF;AAChF,MAAM,CAAC,MAAM,qCAAqC,GAAI,yBAAiC;KACpF,aAAqC,CAAC;AAEzC,MAAM,CAAC,MAAM,2CAA2C,GAAG,mBAAmB,CAAC;AAC/E,MAAM,CAAC,MAAM,wCAAwC,GAAG,gBAAgB,CAAC","sourcesContent":["import { SharedObject, useReleasingSharedObject } from 'expo-modules-core';\n\nimport type { LocationPoint, ActivityUpdate, TrackingStatus } from './ThermsDeviceTracker.types';\nimport ThermsDeviceTrackerModule from './ThermsDeviceTrackerModule';\n\n/**\n * ThermsTracker is a lightweight SharedObject handle providing on-demand live access\n * to the module's shared (singleton) tracking state.\n *\n * IMPORTANT: This is NOT a \"stateful independent instance\" per SharedObject docs pattern.\n * - Tracking session state (location, activity, isTracking, stats) is owned by the single\n * ThermsDeviceTracker native module (one CLLocationManager / FusedLocation + session buffers).\n * - All ThermsTracker instances (from `new` or the hook) proxy / reflect the same underlying state.\n * - This is intentional: the module exposes a single tracking session, matching real-world\n * device tracking semantics (you don't run multiple independent trackers in one app process).\n * - Properties are read live when accessed from JS (polling snapshots); use events (via useEvent\n * or ThermsDeviceTracker.onXXX) for push updates and re-renders.\n *\n * The handle enables `useReleasingSharedObject` lifecycle + a clean `tracker.xxx` API surface.\n * Keep the public surface: isTracking, trackingStatus, lastLocation, currentActivity, sessionStats.\n */\nexport declare class ThermsTracker extends SharedObject {\n readonly isTracking: boolean;\n readonly trackingStatus: TrackingStatus;\n readonly lastLocation?: LocationPoint;\n readonly currentActivity?: ActivityUpdate;\n readonly sessionStats?: {\n startTime: number;\n pointCount: number;\n totalSteps?: number;\n totalDistance?: number;\n };\n}\n\n/**\n * Creates a new ThermsTracker instance (lightweight handle to shared module state).\n * You are responsible for releasing it from memory by calling `release()` when done.\n */\nexport function createThermsTracker(): ThermsTracker {\n const Mod: any = ThermsDeviceTrackerModule;\n const Ctor = Mod && Mod.ThermsTracker;\n if (typeof Ctor === 'function') {\n return new Ctor();\n }\n // Web / non-native fallback stub. Real-time state should be observed via events\n // (onLocationUpdate, onTrackingStateChange, etc). The stub has the documented shape.\n return {\n isTracking: false,\n trackingStatus: { state: 'inactive' },\n lastLocation: undefined,\n currentActivity: undefined,\n sessionStats: undefined,\n } as any;\n}\n\n/**\n * A hook that creates a ThermsTracker instance and automatically\n * releases it when the component unmounts.\n *\n * All instances share the module's tracking state (intentional facade pattern).\n */\nexport function useThermsTracker(): ThermsTracker {\n const Mod: any = ThermsDeviceTrackerModule;\n const Ctor = Mod && Mod.ThermsTracker;\n if (typeof Ctor === 'function') {\n return useReleasingSharedObject(() => new Ctor(), []);\n }\n // Web / non-native stub via the releasing hook (consistent lifecycle surface).\n return useReleasingSharedObject(\n () => ({\n isTracking: false,\n trackingStatus: { state: 'inactive' },\n lastLocation: undefined,\n currentActivity: undefined,\n sessionStats: undefined,\n } as any),\n []\n );\n}\n\n// Legacy aliases (to be removed after migration)\n// Note: the \"ModuleSharedObject\" name is historical; prefer ThermsTracker / useThermsTracker.\n// Export the constructor from the module (where native injects it) to avoid a\n// value re-export of the `declare class` name which produces invalid JS on web.\nexport const ThermsDeviceTrackerModuleSharedObject = (ThermsDeviceTrackerModule as any)\n .ThermsTracker as typeof ThermsTracker;\nexport type { ThermsTracker as ThermsDeviceTrackerModuleSharedObjectType };\nexport const createThermsDeviceTrackerModuleSharedObject = createThermsTracker;\nexport const useThermsDeviceTrackerModuleSharedObject = useThermsTracker;\n"]}
|
package/build/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { useThermsTracker } from './ThermsDeviceTrackerModuleSharedObject';
|
|
|
14
14
|
export { default as ThermsDeviceTrackerModule } from './ThermsDeviceTrackerModule';
|
|
15
15
|
export * from './ThermsDeviceTracker.types';
|
|
16
16
|
export { useThermsTracker } from './ThermsDeviceTrackerModuleSharedObject';
|
|
17
|
+
export type { ThermsTracker } from './ThermsDeviceTrackerModuleSharedObject';
|
|
17
18
|
export { Logger } from './Logger';
|
|
18
19
|
export { deviceSettings, DeviceSettings } from './DeviceSettings';
|
|
19
20
|
export declare const EVENT_LOCATION: "onLocationUpdate";
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EACL,YAAY,EAEZ,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,QAAQ,EACR,aAAa,EACb,SAAS,EAGV,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAG3E,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACnF,cAAc,6BAA6B,CAAC;AAC5C,OA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,gBAAgB,GAAG,gBAAgB,CAAC;AAEtE,wDAAwD;AACxD,MAAM,mBAAmB,GAAG,wBAAwB,CAAC;AAErD,eAAe,mBAAmB,CAAC;AAEnC,2DAA2D;AAC3D,OAAO,EAAE,wBAAwB,EAAE,CAAC","sourcesContent":["/**\n * ThermsDeviceTracker - Main facade\n *\n * Architecture inspired by the excellent design in react-native-background-geolocation:\n * - Clean static facade with named events and constants\n * - Delegation to NativeModule abstraction\n * - Compound config\n * - ready() as primary initialization point\n *\n * Goal: readable, discoverable API with great DX and separation of concerns.\n */\n\nimport { NativeModule } from './NativeModule'; // re-exported as alias\nimport {\n ThermsConfig,\n Event,\n LocationPoint,\n MotionChangeEvent,\n ActivityUpdate,\n ProviderChangeEvent,\n Geofence,\n GeofenceEvent,\n SyncEvent,\n DesiredAccuracy,\n ActivityTypeEnum,\n} from './ThermsDeviceTracker.types';\nimport ThermsDeviceTrackerModule from './ThermsDeviceTrackerModule';\nimport { useThermsTracker } from './ThermsDeviceTrackerModuleSharedObject';\n\n// Re-export raw module for advanced use / backward compat\nexport { default as ThermsDeviceTrackerModule } from './ThermsDeviceTrackerModule';\nexport * from './ThermsDeviceTracker.types';\nexport { useThermsTracker } from './ThermsDeviceTrackerModuleSharedObject';\nexport { Logger } from './Logger';\nexport { deviceSettings, DeviceSettings } from './DeviceSettings';\n\n// Event constants (reference-style)\nexport const EVENT_LOCATION = Event.Location;\nexport const EVENT_MOTION_CHANGE = Event.MotionChange;\nexport const EVENT_ACTIVITY_CHANGE = Event.ActivityChange;\nexport const EVENT_PEDOMETER = Event.Pedometer;\nexport const EVENT_TRACKING_STATE_CHANGE = Event.TrackingStateChange;\nexport const EVENT_PROVIDER_CHANGE = Event.ProviderChange;\nexport const EVENT_GEOFENCE = Event.Geofence;\nexport const EVENT_GEOFENCES_CHANGE = Event.GeofencesChange;\nexport const EVENT_SCHEDULE = Event.Schedule;\nexport const EVENT_SYNC = Event.Sync;\nexport const EVENT_ERROR = Event.Error;\n\n// Enum namespaces (highly discoverable, like the reference)\nexport const LogLevel = {\n Off: 0,\n Error: 1,\n Warning: 2,\n Info: 3,\n Debug: 4,\n Verbose: 5,\n};\n\n// DesiredAccuracy and ActivityTypeEnum are re-exported via `export * from './ThermsDeviceTracker.types'` above\n\n/**\n * Main exported API - modeled after high-quality reference libraries.\n */\nclass ThermsDeviceTrackerClass {\n // Static event names for easy reference\n static get EVENT_LOCATION() {\n return EVENT_LOCATION;\n }\n static get EVENT_MOTION_CHANGE() {\n return EVENT_MOTION_CHANGE;\n }\n static get EVENT_ACTIVITY_CHANGE() {\n return EVENT_ACTIVITY_CHANGE;\n }\n static get EVENT_ERROR() {\n return EVENT_ERROR;\n }\n static get EVENT_PROVIDER_CHANGE() {\n return EVENT_PROVIDER_CHANGE;\n }\n static get EVENT_GEOFENCE() {\n return EVENT_GEOFENCE;\n }\n static get EVENT_GEOFENCES_CHANGE() {\n return EVENT_GEOFENCES_CHANGE;\n }\n static get EVENT_SCHEDULE() {\n return EVENT_SCHEDULE;\n }\n static get EVENT_SYNC() {\n return EVENT_SYNC;\n }\n\n // Enums available via named imports from the package (DesiredAccuracy, ActivityTypeEnum)\n\n /**\n * Primary initialization method (strongly recommended pattern from reference).\n * Register listeners *before* calling ready().\n */\n static async ready(config?: ThermsConfig) {\n return NativeModule.ready(config);\n }\n\n static async start(config?: ThermsConfig) {\n return NativeModule.start(config);\n }\n\n static async stop() {\n return NativeModule.stop();\n }\n\n static getState() {\n return NativeModule.getState();\n }\n\n // High-level event listeners (excellent DX)\n static onLocation(success: (location: LocationPoint) => void, failure?: (error: any) => void) {\n return NativeModule.addListener(EVENT_LOCATION as any, success);\n }\n\n static onMotionChange(callback: (event: MotionChangeEvent) => void) {\n return NativeModule.addListener(EVENT_MOTION_CHANGE as any, callback);\n }\n\n static onActivityChange(callback: (activity: ActivityUpdate) => void) {\n return NativeModule.addListener(Event.ActivityChange as any, callback);\n }\n\n static onError(callback: (error: any) => void) {\n return NativeModule.addListener(EVENT_ERROR as any, callback);\n }\n\n static onProviderChange(callback: (event: ProviderChangeEvent) => void) {\n return NativeModule.addListener(EVENT_PROVIDER_CHANGE as any, callback);\n }\n\n static onGeofence(callback: (event: GeofenceEvent) => void) {\n return NativeModule.addListener(EVENT_GEOFENCE as any, callback);\n }\n\n static onGeofencesChange(callback: (event: { on: Geofence[]; off: Geofence[] }) => void) {\n return NativeModule.addListener(EVENT_GEOFENCES_CHANGE as any, callback);\n }\n\n static onSchedule(callback: (event: any) => void) {\n return NativeModule.addListener(EVENT_SCHEDULE as any, callback);\n }\n\n static onSync(callback: (event: SyncEvent) => void) {\n return NativeModule.addListener(EVENT_SYNC as any, callback);\n }\n\n static getProviderState() {\n return (NativeModule as any).getProviderState?.() || (NativeModule as any).getState?.();\n }\n\n // Forward permissions and legacy tracking methods to support documented + example usage\n static async getPermissionsAsync() {\n const mod = ThermsDeviceTrackerModule as any;\n return mod.getPermissionsAsync\n ? mod.getPermissionsAsync()\n : { status: 'undetermined', canAskAgain: true };\n }\n\n static async requestPermissionsAsync(options?: { background?: boolean }) {\n const mod = ThermsDeviceTrackerModule as any;\n return mod.requestPermissionsAsync\n ? mod.requestPermissionsAsync(options)\n : { status: 'granted' };\n }\n\n static async startTrackingAsync(options?: any) {\n const mod = ThermsDeviceTrackerModule as any;\n return mod.startTrackingAsync ? mod.startTrackingAsync(options) : this.start(options);\n }\n\n static async stopTrackingAsync() {\n const mod = ThermsDeviceTrackerModule as any;\n return mod.stopTrackingAsync ? mod.stopTrackingAsync() : this.stop();\n }\n\n static async getCurrentSessionHistory() {\n const mod = ThermsDeviceTrackerModule as any;\n return mod.getCurrentSessionHistory\n ? mod.getCurrentSessionHistory()\n : (NativeModule as any).getCurrentSessionHistory?.() || { locations: [], activities: [] };\n }\n\n // Geofencing (reference API)\n static addGeofence(geofence: Geofence) {\n return (NativeModule as any).addGeofence?.(geofence);\n }\n\n static addGeofences(geofences: Geofence[]) {\n return (NativeModule as any).addGeofences?.(geofences);\n }\n\n static removeGeofence(identifier: string) {\n return (NativeModule as any).removeGeofence?.(identifier);\n }\n\n static removeGeofences(identifiers?: string[]) {\n return (NativeModule as any).removeGeofences?.(identifiers);\n }\n\n static getGeofences(): Promise<Geofence[]> {\n return (NativeModule as any).getGeofences?.() || Promise.resolve([]);\n }\n\n static startGeofences() {\n return (NativeModule as any).startGeofences?.();\n }\n\n // Persistence (reference: getLocations, destroyLocations, insert for test)\n static getLocations() {\n return (\n (NativeModule as any).getLocations?.() || (NativeModule as any).getCurrentSessionHistory?.()\n );\n }\n\n static getCount() {\n return (NativeModule as any).getCount?.() || Promise.resolve(0);\n }\n\n static destroyLocations() {\n return (NativeModule as any).destroyLocations?.();\n }\n\n static destroyLocation(uuid?: string) {\n return (NativeModule as any).destroyLocation?.(uuid);\n }\n\n static insertLocation(location: LocationPoint | Record<string, any>) {\n return (NativeModule as any).insertLocation?.(location);\n }\n\n // Scheduler\n static startSchedule() {\n return (NativeModule as any).startSchedule?.();\n }\n\n static stopSchedule() {\n return (NativeModule as any).stopSchedule?.();\n }\n\n // Background sync (opt-in native HTTP via SyncManager/SyncProvider; config-driven primary, explicit for parity with schedule).\n // Use ThermsDeviceTracker.onSync(...) to receive events (callback seam from native).\n static startSync() {\n return (NativeModule as any).startSync?.();\n }\n\n static stopSync() {\n return (NativeModule as any).stopSync?.();\n }\n\n static removeAllListeners() {\n NativeModule.removeAllListeners();\n }\n\n // Convenience access to live state via SharedObject\n static get useThermsTracker() {\n return useThermsTracker;\n }\n\n // Raw module escape hatch (for advanced use)\n static get raw(): any {\n return ThermsDeviceTrackerModule;\n }\n}\n\n// Attach discoverable enum namespaces on the default export class (ThermsDeviceTracker.DesiredAccuracy)\n(ThermsDeviceTrackerClass as any).DesiredAccuracy = DesiredAccuracy;\n(ThermsDeviceTrackerClass as any).ActivityTypeEnum = ActivityTypeEnum;\n\n// Default export as the main class (like the reference)\nconst ThermsDeviceTracker = ThermsDeviceTrackerClass;\n\nexport default ThermsDeviceTracker;\n\n// Also export the class and instance style for flexibility\nexport { ThermsDeviceTrackerClass };\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC,CAAC,uBAAuB;AACtE,OAAO,EAEL,KAAK,EAQL,eAAe,EACf,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,0DAA0D;AAC1D,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACnF,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElE,oCAAoC;AACpC,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC,QAAQ,CAAC;AAC7C,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC,YAAY,CAAC;AACtD,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC,cAAc,CAAC;AAC1D,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,SAAS,CAAC;AAC/C,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,CAAC,mBAAmB,CAAC;AACrE,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC,cAAc,CAAC;AAC1D,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC,QAAQ,CAAC;AAC7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC,eAAe,CAAC;AAC5D,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC,QAAQ,CAAC;AAC7C,M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eAAe,CAAC,IAAa;QAClC,OAAQ,YAAoB,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,QAA6C;QACjE,OAAQ,YAAoB,CAAC,cAAc,EAAE,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;IAED,YAAY;IACZ,MAAM,CAAC,aAAa;QAClB,OAAQ,YAAoB,CAAC,aAAa,EAAE,EAAE,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,YAAY;QACjB,OAAQ,YAAoB,CAAC,YAAY,EAAE,EAAE,CAAC;IAChD,CAAC;IAED,+HAA+H;IAC/H,qFAAqF;IACrF,MAAM,CAAC,SAAS;QACd,OAAQ,YAAoB,CAAC,SAAS,EAAE,EAAE,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,QAAQ;QACb,OAAQ,YAAoB,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,kBAAkB;QACvB,YAAY,CAAC,kBAAkB,EAAE,CAAC;IACpC,CAAC;IAED,oDAAoD;IACpD,MAAM,KAAK,gBAAgB;QACzB,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,6CAA6C;IAC7C,MAAM,KAAK,GAAG;QACZ,OAAO,yBAAyB,CAAC;IACnC,CAAC;CACF;AAED,wGAAwG;AACvG,wBAAgC,CAAC,eAAe,GAAG,eAAe,CAAC;AACnE,wBAAgC,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;AAEtE,wDAAwD;AACxD,MAAM,mBAAmB,GAAG,wBAAwB,CAAC;AAErD,eAAe,mBAAmB,CAAC;AAEnC,2DAA2D;AAC3D,OAAO,EAAE,wBAAwB,EAAE,CAAC","sourcesContent":["/**\n * ThermsDeviceTracker - Main facade\n *\n * Architecture inspired by the excellent design in react-native-background-geolocation:\n * - Clean static facade with named events and constants\n * - Delegation to NativeModule abstraction\n * - Compound config\n * - ready() as primary initialization point\n *\n * Goal: readable, discoverable API with great DX and separation of concerns.\n */\n\nimport { NativeModule } from './NativeModule'; // re-exported as alias\nimport {\n ThermsConfig,\n Event,\n LocationPoint,\n MotionChangeEvent,\n ActivityUpdate,\n ProviderChangeEvent,\n Geofence,\n GeofenceEvent,\n SyncEvent,\n DesiredAccuracy,\n ActivityTypeEnum,\n} from './ThermsDeviceTracker.types';\nimport ThermsDeviceTrackerModule from './ThermsDeviceTrackerModule';\nimport { useThermsTracker } from './ThermsDeviceTrackerModuleSharedObject';\n\n// Re-export raw module for advanced use / backward compat\nexport { default as ThermsDeviceTrackerModule } from './ThermsDeviceTrackerModule';\nexport * from './ThermsDeviceTracker.types';\nexport { useThermsTracker } from './ThermsDeviceTrackerModuleSharedObject';\nexport type { ThermsTracker } from './ThermsDeviceTrackerModuleSharedObject';\nexport { Logger } from './Logger';\nexport { deviceSettings, DeviceSettings } from './DeviceSettings';\n\n// Event constants (reference-style)\nexport const EVENT_LOCATION = Event.Location;\nexport const EVENT_MOTION_CHANGE = Event.MotionChange;\nexport const EVENT_ACTIVITY_CHANGE = Event.ActivityChange;\nexport const EVENT_PEDOMETER = Event.Pedometer;\nexport const EVENT_TRACKING_STATE_CHANGE = Event.TrackingStateChange;\nexport const EVENT_PROVIDER_CHANGE = Event.ProviderChange;\nexport const EVENT_GEOFENCE = Event.Geofence;\nexport const EVENT_GEOFENCES_CHANGE = Event.GeofencesChange;\nexport const EVENT_SCHEDULE = Event.Schedule;\nexport const EVENT_SYNC = Event.Sync;\nexport const EVENT_ERROR = Event.Error;\n\n// Enum namespaces (highly discoverable, like the reference)\nexport const LogLevel = {\n Off: 0,\n Error: 1,\n Warning: 2,\n Info: 3,\n Debug: 4,\n Verbose: 5,\n};\n\n// DesiredAccuracy and ActivityTypeEnum are re-exported via `export * from './ThermsDeviceTracker.types'` above\n\n/**\n * Main exported API - modeled after high-quality reference libraries.\n */\nclass ThermsDeviceTrackerClass {\n // Static event names for easy reference\n static get EVENT_LOCATION() {\n return EVENT_LOCATION;\n }\n static get EVENT_MOTION_CHANGE() {\n return EVENT_MOTION_CHANGE;\n }\n static get EVENT_ACTIVITY_CHANGE() {\n return EVENT_ACTIVITY_CHANGE;\n }\n static get EVENT_ERROR() {\n return EVENT_ERROR;\n }\n static get EVENT_PROVIDER_CHANGE() {\n return EVENT_PROVIDER_CHANGE;\n }\n static get EVENT_GEOFENCE() {\n return EVENT_GEOFENCE;\n }\n static get EVENT_GEOFENCES_CHANGE() {\n return EVENT_GEOFENCES_CHANGE;\n }\n static get EVENT_SCHEDULE() {\n return EVENT_SCHEDULE;\n }\n static get EVENT_SYNC() {\n return EVENT_SYNC;\n }\n\n // Enums available via named imports from the package (DesiredAccuracy, ActivityTypeEnum)\n\n /**\n * Primary initialization method (strongly recommended pattern from reference).\n * Register listeners *before* calling ready().\n */\n static async ready(config?: ThermsConfig) {\n return NativeModule.ready(config);\n }\n\n static async start(config?: ThermsConfig) {\n return NativeModule.start(config);\n }\n\n static async stop() {\n return NativeModule.stop();\n }\n\n static getState() {\n return NativeModule.getState();\n }\n\n // High-level event listeners (excellent DX)\n static onLocation(success: (location: LocationPoint) => void, failure?: (error: any) => void) {\n return NativeModule.addListener(EVENT_LOCATION as any, success);\n }\n\n static onMotionChange(callback: (event: MotionChangeEvent) => void) {\n return NativeModule.addListener(EVENT_MOTION_CHANGE as any, callback);\n }\n\n static onActivityChange(callback: (activity: ActivityUpdate) => void) {\n return NativeModule.addListener(Event.ActivityChange as any, callback);\n }\n\n static onError(callback: (error: any) => void) {\n return NativeModule.addListener(EVENT_ERROR as any, callback);\n }\n\n static onProviderChange(callback: (event: ProviderChangeEvent) => void) {\n return NativeModule.addListener(EVENT_PROVIDER_CHANGE as any, callback);\n }\n\n static onGeofence(callback: (event: GeofenceEvent) => void) {\n return NativeModule.addListener(EVENT_GEOFENCE as any, callback);\n }\n\n static onGeofencesChange(callback: (event: { on: Geofence[]; off: Geofence[] }) => void) {\n return NativeModule.addListener(EVENT_GEOFENCES_CHANGE as any, callback);\n }\n\n static onSchedule(callback: (event: any) => void) {\n return NativeModule.addListener(EVENT_SCHEDULE as any, callback);\n }\n\n static onSync(callback: (event: SyncEvent) => void) {\n return NativeModule.addListener(EVENT_SYNC as any, callback);\n }\n\n static getProviderState() {\n return (NativeModule as any).getProviderState?.() || (NativeModule as any).getState?.();\n }\n\n // Forward permissions and legacy tracking methods to support documented + example usage\n static async getPermissionsAsync() {\n const mod = ThermsDeviceTrackerModule as any;\n return mod.getPermissionsAsync\n ? mod.getPermissionsAsync()\n : { status: 'undetermined', canAskAgain: true };\n }\n\n static async requestPermissionsAsync(options?: { background?: boolean }) {\n const mod = ThermsDeviceTrackerModule as any;\n return mod.requestPermissionsAsync\n ? mod.requestPermissionsAsync(options)\n : { status: 'granted' };\n }\n\n static async startTrackingAsync(options?: any) {\n const mod = ThermsDeviceTrackerModule as any;\n return mod.startTrackingAsync ? mod.startTrackingAsync(options) : this.start(options);\n }\n\n static async stopTrackingAsync() {\n const mod = ThermsDeviceTrackerModule as any;\n return mod.stopTrackingAsync ? mod.stopTrackingAsync() : this.stop();\n }\n\n static async getCurrentSessionHistory() {\n const mod = ThermsDeviceTrackerModule as any;\n return mod.getCurrentSessionHistory\n ? mod.getCurrentSessionHistory()\n : (NativeModule as any).getCurrentSessionHistory?.() || { locations: [], activities: [] };\n }\n\n // Geofencing (reference API)\n static addGeofence(geofence: Geofence) {\n return (NativeModule as any).addGeofence?.(geofence);\n }\n\n static addGeofences(geofences: Geofence[]) {\n return (NativeModule as any).addGeofences?.(geofences);\n }\n\n static removeGeofence(identifier: string) {\n return (NativeModule as any).removeGeofence?.(identifier);\n }\n\n static removeGeofences(identifiers?: string[]) {\n return (NativeModule as any).removeGeofences?.(identifiers);\n }\n\n static getGeofences(): Promise<Geofence[]> {\n return (NativeModule as any).getGeofences?.() || Promise.resolve([]);\n }\n\n static startGeofences() {\n return (NativeModule as any).startGeofences?.();\n }\n\n // Persistence (reference: getLocations, destroyLocations, insert for test)\n static getLocations() {\n return (\n (NativeModule as any).getLocations?.() || (NativeModule as any).getCurrentSessionHistory?.()\n );\n }\n\n static getCount() {\n return (NativeModule as any).getCount?.() || Promise.resolve(0);\n }\n\n static destroyLocations() {\n return (NativeModule as any).destroyLocations?.();\n }\n\n static destroyLocation(uuid?: string) {\n return (NativeModule as any).destroyLocation?.(uuid);\n }\n\n static insertLocation(location: LocationPoint | Record<string, any>) {\n return (NativeModule as any).insertLocation?.(location);\n }\n\n // Scheduler\n static startSchedule() {\n return (NativeModule as any).startSchedule?.();\n }\n\n static stopSchedule() {\n return (NativeModule as any).stopSchedule?.();\n }\n\n // Background sync (opt-in native HTTP via SyncManager/SyncProvider; config-driven primary, explicit for parity with schedule).\n // Use ThermsDeviceTracker.onSync(...) to receive events (callback seam from native).\n static startSync() {\n return (NativeModule as any).startSync?.();\n }\n\n static stopSync() {\n return (NativeModule as any).stopSync?.();\n }\n\n static removeAllListeners() {\n NativeModule.removeAllListeners();\n }\n\n // Convenience access to live state via SharedObject\n static get useThermsTracker() {\n return useThermsTracker;\n }\n\n // Raw module escape hatch (for advanced use)\n static get raw(): any {\n return ThermsDeviceTrackerModule;\n }\n}\n\n// Attach discoverable enum namespaces on the default export class (ThermsDeviceTracker.DesiredAccuracy)\n(ThermsDeviceTrackerClass as any).DesiredAccuracy = DesiredAccuracy;\n(ThermsDeviceTrackerClass as any).ActivityTypeEnum = ActivityTypeEnum;\n\n// Default export as the main class (like the reference)\nconst ThermsDeviceTracker = ThermsDeviceTrackerClass;\n\nexport default ThermsDeviceTracker;\n\n// Also export the class and instance style for flexibility\nexport { ThermsDeviceTrackerClass };\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Pod::Spec.new do |s|
|
|
2
2
|
s.name = 'ThermsDeviceTracker'
|
|
3
|
-
s.version = '1.0.0'
|
|
3
|
+
s.version = '1.0.0-rc.2'
|
|
4
4
|
s.summary = 'Device physical activity and geolocation tracking for THERMS'
|
|
5
5
|
s.description = 'Expo native module providing unified access to location updates, physical activity recognition (walking/running/etc), and pedometer data with foreground and background support.'
|
|
6
6
|
s.author = 'Cory Robinson <cory@therms.io>'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "therms-device-tracker",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
4
|
"description": "THERMS software expo app device physical activity and geo location tracking",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -39,7 +39,10 @@
|
|
|
39
39
|
"therms-device-tracker",
|
|
40
40
|
"ThermsDeviceTracker"
|
|
41
41
|
],
|
|
42
|
-
"repository":
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://www.therms.io"
|
|
45
|
+
},
|
|
43
46
|
"bugs": {
|
|
44
47
|
"url": "https://www.therms.io/issues"
|
|
45
48
|
},
|