@ateam-ai-mobile/expo 0.1.5 → 0.1.7

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 (158) hide show
  1. package/android/build.gradle +16 -0
  2. package/android/src/main/java/expo/modules/adavision/AdaVisionModule.kt +75 -0
  3. package/dist/attachmentCache-DhQTqi2E.d.mts +18 -0
  4. package/dist/attachmentCache-DhQTqi2E.d.ts +18 -0
  5. package/dist/bootstrap.d.mts +95 -0
  6. package/dist/bootstrap.d.ts +95 -0
  7. package/dist/bootstrap.js +2473 -0
  8. package/dist/bootstrap.js.map +1 -0
  9. package/dist/bootstrap.mjs +64 -0
  10. package/dist/bootstrap.mjs.map +1 -0
  11. package/dist/chunk-4BMWVN25.mjs +91 -0
  12. package/dist/chunk-4BMWVN25.mjs.map +1 -0
  13. package/dist/chunk-4XYXJYN5.mjs +1513 -0
  14. package/dist/chunk-4XYXJYN5.mjs.map +1 -0
  15. package/dist/chunk-5HM6UA2K.mjs +571 -0
  16. package/dist/chunk-5HM6UA2K.mjs.map +1 -0
  17. package/dist/chunk-6LXF3JVX.mjs +96 -0
  18. package/dist/chunk-6LXF3JVX.mjs.map +1 -0
  19. package/dist/chunk-FF6ZZZXH.mjs +71 -0
  20. package/dist/chunk-FF6ZZZXH.mjs.map +1 -0
  21. package/dist/chunk-KOXF2FZM.mjs +92 -0
  22. package/dist/chunk-KOXF2FZM.mjs.map +1 -0
  23. package/dist/chunk-L4V7OCJ3.mjs +71 -0
  24. package/dist/chunk-L4V7OCJ3.mjs.map +1 -0
  25. package/dist/chunk-TZXWVYYR.mjs +67 -0
  26. package/dist/chunk-TZXWVYYR.mjs.map +1 -0
  27. package/dist/chunk-VQJPSLHP.mjs +1801 -0
  28. package/dist/chunk-VQJPSLHP.mjs.map +1 -0
  29. package/dist/chunk-WMJKH4XE.mjs +34 -0
  30. package/dist/chunk-WMJKH4XE.mjs.map +1 -0
  31. package/dist/chunk-XQSY6MHP.mjs +213 -0
  32. package/dist/chunk-XQSY6MHP.mjs.map +1 -0
  33. package/dist/createBridge.mjs +2 -0
  34. package/dist/createBridge.mjs.map +1 -1
  35. package/dist/device/createDeviceProvider.d.mts +23 -0
  36. package/dist/device/createDeviceProvider.d.ts +23 -0
  37. package/dist/device/createDeviceProvider.js +967 -0
  38. package/dist/device/createDeviceProvider.js.map +1 -0
  39. package/dist/device/createDeviceProvider.mjs +17 -0
  40. package/dist/device/createDeviceProvider.mjs.map +1 -0
  41. package/dist/device-bridge/collectors/appEngagement.d.mts +10 -0
  42. package/dist/device-bridge/collectors/appEngagement.d.ts +10 -0
  43. package/dist/device-bridge/collectors/appEngagement.js +128 -0
  44. package/dist/device-bridge/collectors/appEngagement.js.map +1 -0
  45. package/dist/device-bridge/collectors/appEngagement.mjs +12 -0
  46. package/dist/device-bridge/collectors/appEngagement.mjs.map +1 -0
  47. package/dist/device-bridge/collectors/health.d.mts +24 -0
  48. package/dist/device-bridge/collectors/health.d.ts +24 -0
  49. package/dist/device-bridge/collectors/health.js +238 -0
  50. package/dist/device-bridge/collectors/health.js.map +1 -0
  51. package/dist/device-bridge/collectors/health.mjs +18 -0
  52. package/dist/device-bridge/collectors/health.mjs.map +1 -0
  53. package/dist/device-bridge/cookies.d.mts +49 -0
  54. package/dist/device-bridge/cookies.d.ts +49 -0
  55. package/dist/device-bridge/cookies.js +90 -0
  56. package/dist/device-bridge/cookies.js.map +1 -0
  57. package/dist/device-bridge/cookies.mjs +14 -0
  58. package/dist/device-bridge/cookies.mjs.map +1 -0
  59. package/dist/device-bridge/index.d.mts +483 -0
  60. package/dist/device-bridge/index.d.ts +483 -0
  61. package/dist/device-bridge/index.js +2084 -0
  62. package/dist/device-bridge/index.js.map +1 -0
  63. package/dist/device-bridge/index.mjs +32 -0
  64. package/dist/device-bridge/index.mjs.map +1 -0
  65. package/dist/device-bridge/nfc.d.mts +30 -0
  66. package/dist/device-bridge/nfc.d.ts +30 -0
  67. package/dist/device-bridge/nfc.js +109 -0
  68. package/dist/device-bridge/nfc.js.map +1 -0
  69. package/dist/device-bridge/nfc.mjs +14 -0
  70. package/dist/device-bridge/nfc.mjs.map +1 -0
  71. package/dist/index.d.mts +493 -18
  72. package/dist/index.d.ts +493 -18
  73. package/dist/index.js +1409 -6
  74. package/dist/index.js.map +1 -1
  75. package/dist/index.mjs +23 -194
  76. package/dist/index.mjs.map +1 -1
  77. package/dist/oauth/expoOAuth.d.mts +18 -0
  78. package/dist/oauth/expoOAuth.d.ts +18 -0
  79. package/dist/oauth/expoOAuth.js +102 -0
  80. package/dist/oauth/expoOAuth.js.map +1 -0
  81. package/dist/oauth/expoOAuth.mjs +8 -0
  82. package/dist/oauth/expoOAuth.mjs.map +1 -0
  83. package/dist/types-BRanJYTn.d.mts +138 -0
  84. package/dist/types-BRanJYTn.d.ts +138 -0
  85. package/dist/vision/index.d.mts +81 -0
  86. package/dist/vision/index.d.ts +81 -0
  87. package/dist/vision/index.js +101 -0
  88. package/dist/vision/index.js.map +1 -0
  89. package/dist/vision/index.mjs +28 -0
  90. package/dist/vision/index.mjs.map +1 -0
  91. package/expo-module.config.json +9 -0
  92. package/ios/AdaVision.podspec +28 -0
  93. package/ios/AdaVisionModule.swift +432 -0
  94. package/ios/Resources/yolov8n-oiv7.mlmodelc/analytics/coremldata.bin +0 -0
  95. package/ios/Resources/yolov8n-oiv7.mlmodelc/coremldata.bin +0 -0
  96. package/ios/Resources/yolov8n-oiv7.mlmodelc/metadata.json +773 -0
  97. package/ios/Resources/yolov8n-oiv7.mlmodelc/model0/analytics/coremldata.bin +0 -0
  98. package/ios/Resources/yolov8n-oiv7.mlmodelc/model0/coremldata.bin +0 -0
  99. package/ios/Resources/yolov8n-oiv7.mlmodelc/model0/model.mil +720 -0
  100. package/ios/Resources/yolov8n-oiv7.mlmodelc/model0/weights/weight.bin +0 -0
  101. package/ios/Resources/yolov8n-oiv7.mlmodelc/model1/coremldata.bin +0 -0
  102. package/package.json +107 -7
  103. package/src/bootstrap.ts +159 -0
  104. package/src/camera/CameraTaskHost.tsx +175 -0
  105. package/src/camera/cameraTasks.ts +129 -0
  106. package/src/device/createDeviceProvider.ts +832 -0
  107. package/src/device-bridge/actions/calendar-actions.ts +217 -0
  108. package/src/device-bridge/actions/dnd.ts +74 -0
  109. package/src/device-bridge/actions/health-actions.ts +58 -0
  110. package/src/device-bridge/actions/index.ts +12 -0
  111. package/src/device-bridge/actions/messaging.ts +74 -0
  112. package/src/device-bridge/actions/navigation.ts +88 -0
  113. package/src/device-bridge/actions/queue-poller.ts +151 -0
  114. package/src/device-bridge/background.ts +137 -0
  115. package/src/device-bridge/biometrics.ts +64 -0
  116. package/src/device-bridge/capabilities.ts +218 -0
  117. package/src/device-bridge/collectors/appEngagement.ts +120 -0
  118. package/src/device-bridge/collectors/battery.ts +83 -0
  119. package/src/device-bridge/collectors/calendar.ts +162 -0
  120. package/src/device-bridge/collectors/camera.ts +27 -0
  121. package/src/device-bridge/collectors/connectivity.ts +60 -0
  122. package/src/device-bridge/collectors/contacts.ts +200 -0
  123. package/src/device-bridge/collectors/health.ts +299 -0
  124. package/src/device-bridge/collectors/index.ts +12 -0
  125. package/src/device-bridge/collectors/location.ts +224 -0
  126. package/src/device-bridge/collectors/mood.ts +141 -0
  127. package/src/device-bridge/collectors/notifications.ts +70 -0
  128. package/src/device-bridge/cookies.ts +89 -0
  129. package/src/device-bridge/dynamic-connector.ts +422 -0
  130. package/src/device-bridge/index.ts +467 -0
  131. package/src/device-bridge/nfc.ts +85 -0
  132. package/src/device-bridge/plugin.ts +71 -0
  133. package/src/device-bridge/relay-client.ts +237 -0
  134. package/src/device-bridge/scanner.ts +42 -0
  135. package/src/device-bridge/sharing.ts +35 -0
  136. package/src/device-bridge/types.ts +326 -0
  137. package/src/device-state/activityClassifier.ts +151 -0
  138. package/src/device-state/activityEngine.ts +252 -0
  139. package/src/device-state/collectors.ts +31 -0
  140. package/src/device-state/domains/activity.ts +93 -0
  141. package/src/device-state/domains/capability.ts +60 -0
  142. package/src/device-state/domains/connectivity.ts +60 -0
  143. package/src/device-state/domains/deviceContext.ts +55 -0
  144. package/src/device-state/domains/interaction.ts +59 -0
  145. package/src/device-state/domains/spatial.ts +283 -0
  146. package/src/device-state/domains/visual.ts +100 -0
  147. package/src/device-state/headingSource.ts +84 -0
  148. package/src/device-state/index.ts +77 -0
  149. package/src/device-state/quality.ts +60 -0
  150. package/src/device-state/replay.ts +220 -0
  151. package/src/device-state/turnDetector.ts +121 -0
  152. package/src/device-state/visualEngine.ts +341 -0
  153. package/src/haptics.ts +4 -0
  154. package/src/index.ts +37 -0
  155. package/src/oauth/expoOAuth.tsx +113 -0
  156. package/src/vision/analysis.js +80 -0
  157. package/src/vision/index.ts +144 -0
  158. package/src/vision/ring.js +35 -0
@@ -0,0 +1,64 @@
1
+ import {
2
+ createDeviceState,
3
+ setupExpoProviders
4
+ } from "./chunk-4XYXJYN5.mjs";
5
+ import {
6
+ createDeviceProvider
7
+ } from "./chunk-5HM6UA2K.mjs";
8
+ import "./chunk-TZXWVYYR.mjs";
9
+ import "./chunk-6LXF3JVX.mjs";
10
+ import "./chunk-FF6ZZZXH.mjs";
11
+ import {
12
+ connectivity_exports,
13
+ location_exports
14
+ } from "./chunk-VQJPSLHP.mjs";
15
+ import "./chunk-KOXF2FZM.mjs";
16
+ import "./chunk-XQSY6MHP.mjs";
17
+ import "./chunk-4BMWVN25.mjs";
18
+ import {
19
+ createExpoOAuthProvider
20
+ } from "./chunk-L4V7OCJ3.mjs";
21
+ import "./chunk-WMJKH4XE.mjs";
22
+
23
+ // src/bootstrap.ts
24
+ import { initAdas, setAcsReachabilityReporter } from "@ateam-ai-mobile/core";
25
+ import { setDeviceStateProvider, registerNativePlugin, registerPlatformDeviceTools } from "@ateam-ai-mobile/plugin-runtime";
26
+ import { setOAuthProvider, setUIActionNavigator, setPluginWebViewExtraHosts } from "@ateam-ai-mobile/ui";
27
+ function bootstrapExpoAdas(opts) {
28
+ const { attachmentCache } = setupExpoProviders({
29
+ bundleModules: opts.bundleModules,
30
+ attachmentIndexKey: opts.storageKeys?.attachmentIndex,
31
+ bundleIndexKey: opts.storageKeys?.bundleIndex,
32
+ deviceProvider: createDeviceProvider({ reachabilityUrl: opts.reachabilityUrl })
33
+ });
34
+ for (const plugin of opts.nativePlugins ?? []) {
35
+ for (const id of plugin.ids) registerNativePlugin(id, plugin.resolver);
36
+ }
37
+ const relay = opts.urls.relay;
38
+ setPluginWebViewExtraHosts(() => relay ? [relay()] : []);
39
+ setOAuthProvider(createExpoOAuthProvider({ googleIosClientId: opts.googleIosClientId }));
40
+ if (opts.onReachabilityChange) {
41
+ const onReach = opts.onReachabilityChange;
42
+ setAcsReachabilityReporter({ up: () => onReach(true), down: () => onReach(false) });
43
+ }
44
+ setDeviceStateProvider(
45
+ createDeviceState({ connectivity: connectivity_exports, location: location_exports })
46
+ );
47
+ registerPlatformDeviceTools();
48
+ setUIActionNavigator(opts.navigateToPlugin);
49
+ initAdas({
50
+ coreUrl: opts.urls.core,
51
+ ...opts.urls.voice ? { voiceUrl: opts.urls.voice } : {},
52
+ ...opts.urls.consumerAuth ? { consumerAuthUrl: opts.urls.consumerAuth } : {},
53
+ ...opts.onSession ? { onSession: opts.onSession } : {},
54
+ ...opts.tenant ? { tenant: opts.tenant } : {},
55
+ getUser: opts.getUser,
56
+ tokenProvider: opts.tokenProvider,
57
+ attachmentCache
58
+ });
59
+ return { attachmentCache };
60
+ }
61
+ export {
62
+ bootstrapExpoAdas
63
+ };
64
+ //# sourceMappingURL=bootstrap.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/bootstrap.ts"],"sourcesContent":["/**\n * bootstrapExpoAdas — the single, self-contained SDK bootstrap (R10).\n *\n * The final high-level entry point of the \"fat SDK / thin shell\" arc: it folds\n * the ~15 hand-wired seams the host used to assemble in its own adas.ts into ONE\n * call, so the shell stops manually assembling platform providers/collectors/\n * plugins. Internally it initializes, in the order the migrated code established:\n * the Expo providers (haptics/bundle cache/clipboard/attachment cache + the\n * device-primitive provider), the host-bundled native plugins, the plugin-WebView\n * allow-list, native OAuth, the ACS reachability reporter, the L3 DeviceState\n * engine (with the SDK's OWN collectors — the shell injects none), the plugin/\n * UI-action navigator, and finally the core config+token bridge (initAdas).\n *\n * The API is DERIVED from the host's migrated adas.ts, not invented. Everything\n * the host still owns is passed in as a small values-and-getters bag: endpoint\n * getters (the host owns the dev/prod switch), the identity/token bridge, its\n * branded Google client id, its host-bundled plugin resolvers, the native\n * WebView module from its build, and its router callback.\n *\n * A SUBPATH (`@ateam-ai-mobile/expo/bootstrap`), like /device and /oauth: it\n * statically pulls the optional expo native modules (via createDeviceProvider /\n * the device-state collectors / the OAuth provider), so it must not sit on the\n * package's main entry, which a host without those modules still has to build.\n *\n * The two physical reasoning paths stay DISTINCT and are wired as SEPARATE\n * statements — never a merged bridge: LOCAL (the local tool registry + device\n * state the plugin/voice runtime reads) and SERVER (the relay allow-list here;\n * the DeviceBridge relay runtime itself is started by the host lifecycle, out of\n * this module-load bootstrap's scope).\n */\nimport { initAdas, setAcsReachabilityReporter, type TokenProvider, type AdasUser, type AdasSession } from '@ateam-ai-mobile/core';\nimport { setDeviceStateProvider, registerNativePlugin, registerPlatformDeviceTools, type RegisteredPlugin } from '@ateam-ai-mobile/plugin-runtime';\nimport { setOAuthProvider, setUIActionNavigator, setPluginWebViewExtraHosts, type UIActionRoute } from '@ateam-ai-mobile/ui';\n\nimport { setupExpoProviders, type ExpoAttachmentCache } from './index';\nimport { createDeviceProvider } from './device/createDeviceProvider';\nimport { createDeviceState } from './device-state';\nimport { createExpoOAuthProvider } from './oauth/expoOAuth';\nimport * as deviceConnectivity from './device-bridge/collectors/connectivity';\nimport * as deviceLocation from './device-bridge/collectors/location';\n\n/** A host-bundled native plugin: one lazy resolver registered under one or more ids. */\nexport interface NativePluginRegistration {\n resolver: () => Promise<RegisteredPlugin>;\n ids: string[];\n}\n\nexport interface BootstrapExpoAdasOptions {\n /**\n * Endpoint GETTERS — the host owns the dev/prod env switch, so these are read\n * live on every SDK request (never snapshotted). `core` is required; the rest\n * are optional (voice/consumer-auth features light up when present).\n */\n urls: {\n core: () => string;\n voice?: () => string;\n consumerAuth?: () => string;\n /** Trusted extra host for plugin WebViews (the relay device-bridge auth flows). */\n relay?: () => string;\n };\n /** The host's token bridge — outcome mapping (transient vs auth_failed) owned by the host. */\n tokenProvider: TokenProvider;\n /** Current user projection for chat routing (host reads its auth store). */\n getUser: () => AdasUser | null;\n /** Active tenant getter (signed-in tenant, falling back to the pre-auth pick). */\n tenant?: () => string;\n /** Adopt a freshly-minted session on tenant switch (host persists tenant-first, then logs in). */\n onSession?: (session: AdasSession) => void | Promise<void>;\n /** The host's bundled Google iOS client id, for the join/open-join OAuth path. */\n googleIosClientId?: string;\n /** Host-bundled native plugins (AuthWebView, ConnectionsPanel, …) — lazy resolvers. */\n nativePlugins?: NativePluginRegistration[];\n /** Native modules remote bundles may require() (e.g. react-native-webview) — from the host build. */\n bundleModules?: Record<string, unknown>;\n /** Pre-SDK AsyncStorage keys, so an existing install keeps its warm caches. */\n storageKeys?: { attachmentIndex?: string; bundleIndex?: string };\n /** Connectivity sink — the SDK reports fetch reachability up/down; the host feeds its banner. */\n onReachabilityChange?: (up: boolean) => void;\n /** Open the host's plugin screen for a UI-action chip (the host owns its router). */\n navigateToPlugin: (route: UIActionRoute) => void;\n /**\n * Reachability probe URL for the device-primitive connectivity API. The host\n * passes this EXPLICITLY (typically `${core}/health`) as a load-time snapshot —\n * deliberately NOT derived from `urls.core()`, so a dev/E2E core override does\n * not silently flow into the health probe (the asymmetry the host relied on).\n */\n reachabilityUrl?: string;\n}\n\n/**\n * Wire the entire Expo-backed ADAS platform in one call. Run for its side effect\n * at module load, before the router mounts. Returns the attachment cache so the\n * host can hand it to anything that needs it (initAdas already received it).\n */\nexport function bootstrapExpoAdas(opts: BootstrapExpoAdasOptions): { attachmentCache: ExpoAttachmentCache } {\n // Expo providers + the device-primitive implementation (props.device). The SDK\n // owns createDeviceProvider; the shell injects only its reachability URL.\n const { attachmentCache } = setupExpoProviders({\n bundleModules: opts.bundleModules,\n attachmentIndexKey: opts.storageKeys?.attachmentIndex,\n bundleIndexKey: opts.storageKeys?.bundleIndex,\n deviceProvider: createDeviceProvider({ reachabilityUrl: opts.reachabilityUrl }),\n });\n\n // Host-bundled native plugins: register each lazy resolver under its id aliases.\n for (const plugin of opts.nativePlugins ?? []) {\n for (const id of plugin.ids) registerNativePlugin(id, plugin.resolver);\n }\n\n // Plugin WebViews may navigate to the relay (device-bridge auth flows) —\n // whitelist it alongside core/voice. Getter → live across env switches.\n const relay = opts.urls.relay;\n setPluginWebViewExtraHosts(() => (relay ? [relay()] : []));\n\n // Native OAuth for the relocated auth screens (the ONLY native OAuth wiring).\n setOAuthProvider(createExpoOAuthProvider({ googleIosClientId: opts.googleIosClientId }));\n\n // ACS fetch outcomes feed the host's connectivity banner (any response = up,\n // thrown fetch = down). The host's sink stays host-side (lazy, no load cycle).\n if (opts.onReachabilityChange) {\n const onReach = opts.onReachabilityChange;\n setAcsReachabilityReporter({ up: () => onReach(true), down: () => onReach(false) });\n }\n\n // L3 DeviceState (props.deviceState) — the SEMANTIC layer, wired with the SDK's\n // OWN device-bridge collectors. The shell injects none (the R10 payoff): an\n // undeclared/unimplemented domain returns explicit `unknown`s, never a silent\n // undefined. Kept a SEPARATE statement from the SERVER relay — the two\n // reasoning paths never merge.\n setDeviceStateProvider(\n createDeviceState({ connectivity: deviceConnectivity, location: deviceLocation }),\n );\n\n // LOCAL device tools — register the static, host-owned platform tools\n // (device.echo / device.ping) at load, so the device path answers even before\n // any plugin bundle or sign-in: the platform tier deliberately does not depend\n // on the thing being proved. A tenant's EXTERNAL device tools load on\n // session-authenticated, which the host wires to its auth-session subscription\n // via syncDeviceToolsForSession() — ambient, not voice-triggered.\n registerPlatformDeviceTools();\n\n // Plugin/UI-action chips delegate navigation to the host's router.\n setUIActionNavigator(opts.navigateToPlugin);\n\n // Core config + token bridge. URL getters (not snapshots) so the env switch\n // flows through; identity/token bridge owned by the host.\n initAdas({\n coreUrl: opts.urls.core,\n ...(opts.urls.voice ? { voiceUrl: opts.urls.voice } : {}),\n ...(opts.urls.consumerAuth ? { consumerAuthUrl: opts.urls.consumerAuth } : {}),\n ...(opts.onSession ? { onSession: opts.onSession } : {}),\n ...(opts.tenant ? { tenant: opts.tenant } : {}),\n getUser: opts.getUser,\n tokenProvider: opts.tokenProvider,\n attachmentCache,\n });\n\n return { attachmentCache };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAS,UAAU,kCAAuF;AAC1G,SAAS,wBAAwB,sBAAsB,mCAA0D;AACjH,SAAS,kBAAkB,sBAAsB,kCAAsD;AA8DhG,SAAS,kBAAkB,MAA0E;AAG1G,QAAM,EAAE,gBAAgB,IAAI,mBAAmB;AAAA,IAC7C,eAAe,KAAK;AAAA,IACpB,oBAAoB,KAAK,aAAa;AAAA,IACtC,gBAAgB,KAAK,aAAa;AAAA,IAClC,gBAAgB,qBAAqB,EAAE,iBAAiB,KAAK,gBAAgB,CAAC;AAAA,EAChF,CAAC;AAGD,aAAW,UAAU,KAAK,iBAAiB,CAAC,GAAG;AAC7C,eAAW,MAAM,OAAO,IAAK,sBAAqB,IAAI,OAAO,QAAQ;AAAA,EACvE;AAIA,QAAM,QAAQ,KAAK,KAAK;AACxB,6BAA2B,MAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAE;AAGzD,mBAAiB,wBAAwB,EAAE,mBAAmB,KAAK,kBAAkB,CAAC,CAAC;AAIvF,MAAI,KAAK,sBAAsB;AAC7B,UAAM,UAAU,KAAK;AACrB,+BAA2B,EAAE,IAAI,MAAM,QAAQ,IAAI,GAAG,MAAM,MAAM,QAAQ,KAAK,EAAE,CAAC;AAAA,EACpF;AAOA;AAAA,IACE,kBAAkB,EAAE,cAAc,sBAAoB,UAAU,iBAAe,CAAC;AAAA,EAClF;AAQA,8BAA4B;AAG5B,uBAAqB,KAAK,gBAAgB;AAI1C,WAAS;AAAA,IACP,SAAS,KAAK,KAAK;AAAA,IACnB,GAAI,KAAK,KAAK,QAAQ,EAAE,UAAU,KAAK,KAAK,MAAM,IAAI,CAAC;AAAA,IACvD,GAAI,KAAK,KAAK,eAAe,EAAE,iBAAiB,KAAK,KAAK,aAAa,IAAI,CAAC;AAAA,IAC5E,GAAI,KAAK,YAAY,EAAE,WAAW,KAAK,UAAU,IAAI,CAAC;AAAA,IACtD,GAAI,KAAK,SAAS,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC;AAAA,IAC7C,SAAS,KAAK;AAAA,IACd,eAAe,KAAK;AAAA,IACpB;AAAA,EACF,CAAC;AAED,SAAO,EAAE,gBAAgB;AAC3B;","names":[]}
@@ -0,0 +1,91 @@
1
+ import {
2
+ __esm,
3
+ __export
4
+ } from "./chunk-WMJKH4XE.mjs";
5
+
6
+ // src/device-bridge/nfc.ts
7
+ var nfc_exports = {};
8
+ __export(nfc_exports, {
9
+ isEnabled: () => isEnabled,
10
+ isSupported: () => isSupported,
11
+ readOnce: () => readOnce
12
+ });
13
+ import NfcManager, { NfcTech, Ndef } from "react-native-nfc-manager";
14
+ async function ensureInit() {
15
+ if (_initialized) return true;
16
+ try {
17
+ const supported = await NfcManager.isSupported();
18
+ if (!supported) return false;
19
+ await NfcManager.start();
20
+ _initialized = true;
21
+ return true;
22
+ } catch (e) {
23
+ return false;
24
+ }
25
+ }
26
+ async function isSupported() {
27
+ try {
28
+ return await NfcManager.isSupported();
29
+ } catch {
30
+ return false;
31
+ }
32
+ }
33
+ async function isEnabled() {
34
+ try {
35
+ return await NfcManager.isEnabled();
36
+ } catch {
37
+ return false;
38
+ }
39
+ }
40
+ async function readOnce(timeoutMs = 3e4) {
41
+ const ready = await ensureInit();
42
+ if (!ready) return { ok: false, error: "nfc_unsupported" };
43
+ try {
44
+ const tag = await Promise.race([
45
+ NfcManager.requestTechnology(NfcTech.Ndef).then(() => NfcManager.getTag()),
46
+ new Promise((resolve) => setTimeout(() => resolve(null), timeoutMs))
47
+ ]);
48
+ if (!tag) {
49
+ try {
50
+ await NfcManager.cancelTechnologyRequest();
51
+ } catch {
52
+ }
53
+ return { ok: false, error: "timeout" };
54
+ }
55
+ const records = [];
56
+ if (tag.ndefMessage) {
57
+ for (const r of tag.ndefMessage) {
58
+ try {
59
+ const type = String.fromCharCode(...r.type || []);
60
+ const payload = Ndef.text.decodePayload(r.payload || []);
61
+ records.push({ type, payload: String(payload) });
62
+ } catch {
63
+ }
64
+ }
65
+ }
66
+ const tagId = tag.id ? Array.from(tag.id).map((b) => b.toString(16).padStart(2, "0")).join("") : void 0;
67
+ return { ok: true, tagId, records };
68
+ } catch (e) {
69
+ return { ok: false, error: String(e?.message || e) };
70
+ } finally {
71
+ try {
72
+ await NfcManager.cancelTechnologyRequest();
73
+ } catch {
74
+ }
75
+ }
76
+ }
77
+ var _initialized;
78
+ var init_nfc = __esm({
79
+ "src/device-bridge/nfc.ts"() {
80
+ _initialized = false;
81
+ }
82
+ });
83
+
84
+ export {
85
+ isSupported,
86
+ isEnabled,
87
+ readOnce,
88
+ nfc_exports,
89
+ init_nfc
90
+ };
91
+ //# sourceMappingURL=chunk-4BMWVN25.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/device-bridge/nfc.ts"],"sourcesContent":["/**\n * Device-bridge: NFC\n *\n * Wraps react-native-nfc-manager for:\n * - Reading NFC tags (NDEF, Mifare)\n * - Writing to writable tags\n * - App-triggered tag discovery\n *\n * Use cases: physical-world triggers, inventory lookup, hardware keys,\n * loyalty cards, transit top-up, pairing.\n *\n * iOS: requires \"Near Field Communication Tag Reading\" entitlement in the\n * app's provisioning profile. Android: requires NFC permission in manifest.\n */\n\nimport NfcManager, { NfcTech, Ndef } from 'react-native-nfc-manager';\n\nlet _initialized = false;\n\nasync function ensureInit(): Promise<boolean> {\n if (_initialized) return true;\n try {\n const supported = await NfcManager.isSupported();\n if (!supported) return false;\n await NfcManager.start();\n _initialized = true;\n return true;\n } catch (e) {\n return false;\n }\n}\n\nexport async function isSupported(): Promise<boolean> {\n try { return await NfcManager.isSupported(); } catch { return false; }\n}\n\nexport async function isEnabled(): Promise<boolean> {\n try { return await NfcManager.isEnabled(); } catch { return false; }\n}\n\nexport interface NdefRecord {\n type: string;\n payload: string;\n}\n\nexport interface TagReadResult {\n ok: boolean;\n tagId?: string;\n records?: NdefRecord[];\n error?: string;\n}\n\n/** Wait for the next tag to be scanned, read NDEF records, release, and return. */\nexport async function readOnce(timeoutMs: number = 30_000): Promise<TagReadResult> {\n const ready = await ensureInit();\n if (!ready) return { ok: false, error: 'nfc_unsupported' };\n try {\n const tag = await Promise.race([\n NfcManager.requestTechnology(NfcTech.Ndef).then(() => NfcManager.getTag()),\n new Promise<null>((resolve) => setTimeout(() => resolve(null), timeoutMs)),\n ]);\n if (!tag) {\n try { await NfcManager.cancelTechnologyRequest(); } catch {}\n return { ok: false, error: 'timeout' };\n }\n const records: NdefRecord[] = [];\n if ((tag as any).ndefMessage) {\n for (const r of (tag as any).ndefMessage) {\n try {\n const type = String.fromCharCode(...(r.type || []));\n const payload = Ndef.text.decodePayload(r.payload || []);\n records.push({ type, payload: String(payload) });\n } catch {\n // skip records we can't decode\n }\n }\n }\n const tagId = (tag as any).id ? Array.from((tag as any).id).map((b: any) => b.toString(16).padStart(2, '0')).join('') : undefined;\n return { ok: true, tagId, records };\n } catch (e: any) {\n return { ok: false, error: String(e?.message || e) };\n } finally {\n try { await NfcManager.cancelTechnologyRequest(); } catch {}\n }\n}\n"],"mappings":";;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,OAAO,cAAc,SAAS,YAAY;AAI1C,eAAe,aAA+B;AAC5C,MAAI,aAAc,QAAO;AACzB,MAAI;AACF,UAAM,YAAY,MAAM,WAAW,YAAY;AAC/C,QAAI,CAAC,UAAW,QAAO;AACvB,UAAM,WAAW,MAAM;AACvB,mBAAe;AACf,WAAO;AAAA,EACT,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;AAEA,eAAsB,cAAgC;AACpD,MAAI;AAAE,WAAO,MAAM,WAAW,YAAY;AAAA,EAAG,QAAQ;AAAE,WAAO;AAAA,EAAO;AACvE;AAEA,eAAsB,YAA8B;AAClD,MAAI;AAAE,WAAO,MAAM,WAAW,UAAU;AAAA,EAAG,QAAQ;AAAE,WAAO;AAAA,EAAO;AACrE;AAeA,eAAsB,SAAS,YAAoB,KAAgC;AACjF,QAAM,QAAQ,MAAM,WAAW;AAC/B,MAAI,CAAC,MAAO,QAAO,EAAE,IAAI,OAAO,OAAO,kBAAkB;AACzD,MAAI;AACF,UAAM,MAAM,MAAM,QAAQ,KAAK;AAAA,MAC7B,WAAW,kBAAkB,QAAQ,IAAI,EAAE,KAAK,MAAM,WAAW,OAAO,CAAC;AAAA,MACzE,IAAI,QAAc,CAAC,YAAY,WAAW,MAAM,QAAQ,IAAI,GAAG,SAAS,CAAC;AAAA,IAC3E,CAAC;AACD,QAAI,CAAC,KAAK;AACR,UAAI;AAAE,cAAM,WAAW,wBAAwB;AAAA,MAAG,QAAQ;AAAA,MAAC;AAC3D,aAAO,EAAE,IAAI,OAAO,OAAO,UAAU;AAAA,IACvC;AACA,UAAM,UAAwB,CAAC;AAC/B,QAAK,IAAY,aAAa;AAC5B,iBAAW,KAAM,IAAY,aAAa;AACxC,YAAI;AACF,gBAAM,OAAO,OAAO,aAAa,GAAI,EAAE,QAAQ,CAAC,CAAE;AAClD,gBAAM,UAAU,KAAK,KAAK,cAAc,EAAE,WAAW,CAAC,CAAC;AACvD,kBAAQ,KAAK,EAAE,MAAM,SAAS,OAAO,OAAO,EAAE,CAAC;AAAA,QACjD,QAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF;AACA,UAAM,QAAS,IAAY,KAAK,MAAM,KAAM,IAAY,EAAE,EAAE,IAAI,CAAC,MAAW,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI;AACxH,WAAO,EAAE,IAAI,MAAM,OAAO,QAAQ;AAAA,EACpC,SAAS,GAAQ;AACf,WAAO,EAAE,IAAI,OAAO,OAAO,OAAO,GAAG,WAAW,CAAC,EAAE;AAAA,EACrD,UAAE;AACA,QAAI;AAAE,YAAM,WAAW,wBAAwB;AAAA,IAAG,QAAQ;AAAA,IAAC;AAAA,EAC7D;AACF;AApFA,IAiBI;AAjBJ;AAAA;AAiBA,IAAI,eAAe;AAAA;AAAA;","names":[]}