@ateam-ai-mobile/expo 0.1.9 → 0.1.11
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/dist/bootstrap.js +34 -18
- package/dist/bootstrap.js.map +1 -1
- package/dist/bootstrap.mjs +19 -1
- package/dist/bootstrap.mjs.map +1 -1
- package/expo-module.config.json +12 -3
- package/ios/AdaAudioModule.swift +78 -0
- package/ios/AdaVisionModule.swift +3 -0
- package/package.json +4 -4
- package/src/audio/index.ts +23 -0
- package/src/bootstrap.ts +5 -1
package/dist/bootstrap.mjs
CHANGED
|
@@ -25,7 +25,24 @@ import "./chunk-WMJKH4XE.mjs";
|
|
|
25
25
|
// src/bootstrap.ts
|
|
26
26
|
import { initAdas, setAcsReachabilityReporter } from "@ateam-ai-mobile/core";
|
|
27
27
|
import { setDeviceStateProvider, registerNativePlugin, registerPlatformDeviceTools } from "@ateam-ai-mobile/plugin-runtime";
|
|
28
|
-
import { setOAuthProvider, setUIActionNavigator, setPluginWebViewExtraHosts } from "@ateam-ai-mobile/ui";
|
|
28
|
+
import { setOAuthProvider, setUIActionNavigator, setPluginWebViewExtraHosts, setCallAudioProvider } from "@ateam-ai-mobile/ui";
|
|
29
|
+
|
|
30
|
+
// src/audio/index.ts
|
|
31
|
+
import { requireOptionalNativeModule } from "expo-modules-core";
|
|
32
|
+
var native = requireOptionalNativeModule("AdaAudio");
|
|
33
|
+
function createCallAudioProvider() {
|
|
34
|
+
if (!native) return null;
|
|
35
|
+
return {
|
|
36
|
+
beginCall: () => {
|
|
37
|
+
native.beginVoiceCall();
|
|
38
|
+
},
|
|
39
|
+
endCall: () => {
|
|
40
|
+
native.endVoiceCall();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/bootstrap.ts
|
|
29
46
|
function bootstrapExpoAdas(opts) {
|
|
30
47
|
const { attachmentCache } = setupExpoProviders({
|
|
31
48
|
bundleModules: opts.bundleModules,
|
|
@@ -39,6 +56,7 @@ function bootstrapExpoAdas(opts) {
|
|
|
39
56
|
const relay = opts.urls.relay;
|
|
40
57
|
setPluginWebViewExtraHosts(() => relay ? [relay()] : []);
|
|
41
58
|
setOAuthProvider(createExpoOAuthProvider({ googleIosClientId: opts.googleIosClientId }));
|
|
59
|
+
setCallAudioProvider(createCallAudioProvider());
|
|
42
60
|
if (opts.onReachabilityChange) {
|
|
43
61
|
const onReach = opts.onReachabilityChange;
|
|
44
62
|
setAcsReachabilityReporter({ up: () => onReach(true), down: () => onReach(false) });
|
package/dist/bootstrap.mjs.map
CHANGED
|
@@ -1 +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,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strap (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, setCallAudioProvider, type UIActionRoute } from '@ateam-ai-mobile/ui';\nimport { createCallAudioProvider } from './audio';\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 // The voice call's device audio mode (echo cancellation on the loudspeaker).\n setCallAudioProvider(createCallAudioProvider());\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","// Call audio mode for the voice call — see ios/AdaAudioModule.swift for why.\n//\n// requireOptionalNativeModule: on a binary WITHOUT the module (any build before\n// it shipped) this is null and the provider is a no-op, so an OTA carrying this\n// JS can never crash an older binary. Android: no module yet (its WebView echo\n// path is untouched).\nimport { requireOptionalNativeModule } from 'expo-modules-core';\nimport type { CallAudioProvider } from '@ateam-ai-mobile/ui';\n\ninterface AdaAudioNative {\n beginVoiceCall(): boolean;\n endVoiceCall(): boolean;\n}\n\nconst native = requireOptionalNativeModule<AdaAudioNative>('AdaAudio');\n\nexport function createCallAudioProvider(): CallAudioProvider | null {\n if (!native) return null;\n return {\n beginCall: () => { native.beginVoiceCall(); },\n endCall: () => { native.endVoiceCall(); },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAS,UAAU,kCAAuF;AAC1G,SAAS,wBAAwB,sBAAsB,mCAA0D;AACjH,SAAS,kBAAkB,sBAAsB,4BAA4B,4BAAgD;;;AC1B7H,SAAS,mCAAmC;AAQ5C,IAAM,SAAS,4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;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":[]}
|
package/expo-module.config.json
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
"platforms": [
|
|
2
|
+
"platforms": [
|
|
3
|
+
"apple",
|
|
4
|
+
"android"
|
|
5
|
+
],
|
|
3
6
|
"apple": {
|
|
4
|
-
"modules": [
|
|
7
|
+
"modules": [
|
|
8
|
+
"AdaVisionModule",
|
|
9
|
+
"AdaMapsModule",
|
|
10
|
+
"AdaAudioModule"
|
|
11
|
+
]
|
|
5
12
|
},
|
|
6
13
|
"android": {
|
|
7
|
-
"modules": [
|
|
14
|
+
"modules": [
|
|
15
|
+
"expo.modules.adavision.AdaVisionModule"
|
|
16
|
+
]
|
|
8
17
|
}
|
|
9
18
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import AVFoundation
|
|
3
|
+
|
|
4
|
+
// CALL AUDIO MODE for the voice call (2026-10-24).
|
|
5
|
+
//
|
|
6
|
+
// Voice runs WebRTC inside a WKWebView. iOS cancels the speaker's sound out of
|
|
7
|
+
// the microphone only when the app's audio session is in a call mode
|
|
8
|
+
// (playAndRecord + voiceChat). Nothing in the app or the SDK ever set one, so
|
|
9
|
+
// on the loudspeaker the mic heard the AI's own voice: the server's voice
|
|
10
|
+
// activity detection took it for the user and cut the reply (dev call
|
|
11
|
+
// vc_1eca4b708e4b — phantom user turns "Thank you.", "Bye." while the AI spoke;
|
|
12
|
+
// clean on earphones and from a desktop browser).
|
|
13
|
+
//
|
|
14
|
+
// beginVoiceCall() saves the current session setup and switches to the call
|
|
15
|
+
// mode (loudspeaker by default, Bluetooth headsets allowed); endVoiceCall()
|
|
16
|
+
// restores what was there before. Both are idempotent.
|
|
17
|
+
//
|
|
18
|
+
// Lives at ios/ root, so it compiles into the AdaVision pod through that
|
|
19
|
+
// podspec's **/*.swift glob; expo-module.config.json registers the module.
|
|
20
|
+
public class AdaAudioModule: Module {
|
|
21
|
+
private var saved: (category: AVAudioSession.Category, mode: AVAudioSession.Mode, options: AVAudioSession.CategoryOptions)?
|
|
22
|
+
// Bumped by every begin, so a delayed restore retry from an ENDED call can't
|
|
23
|
+
// undo a newer call's mode. The lock covers the retry running on main.
|
|
24
|
+
private var callCount = 0
|
|
25
|
+
private let lock = NSLock()
|
|
26
|
+
|
|
27
|
+
public func definition() -> ModuleDefinition {
|
|
28
|
+
Name("AdaAudio")
|
|
29
|
+
|
|
30
|
+
Function("beginVoiceCall") { () -> Bool in
|
|
31
|
+
let s = AVAudioSession.sharedInstance()
|
|
32
|
+
self.lock.lock(); defer { self.lock.unlock() }
|
|
33
|
+
self.callCount += 1
|
|
34
|
+
if self.saved == nil { self.saved = (s.category, s.mode, s.categoryOptions) }
|
|
35
|
+
do {
|
|
36
|
+
try s.setCategory(.playAndRecord, mode: .voiceChat, options: [.defaultToSpeaker, .allowBluetooth])
|
|
37
|
+
try s.setActive(true)
|
|
38
|
+
return true
|
|
39
|
+
} catch {
|
|
40
|
+
NSLog("[AdaAudio] beginVoiceCall failed: \(error.localizedDescription)")
|
|
41
|
+
return false
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
Function("endVoiceCall") { () -> Bool in
|
|
46
|
+
if self.restore(ifCall: nil) { return true }
|
|
47
|
+
// stop() hangs up the page and ends the mode at once, while the WebView may
|
|
48
|
+
// still hold the mic; iOS can refuse setCategory with audio I/O running.
|
|
49
|
+
// `saved` is kept on failure, so try once more after the page let go —
|
|
50
|
+
// unless a new call has begun since.
|
|
51
|
+
let call = self.currentCall()
|
|
52
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { _ = self.restore(ifCall: call) }
|
|
53
|
+
return false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private func currentCall() -> Int {
|
|
58
|
+
lock.lock(); defer { lock.unlock() }
|
|
59
|
+
return callCount
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/// Put back the setup saved by beginVoiceCall. `saved` is cleared only once
|
|
63
|
+
/// that succeeded, so a refused restore can be retried. `ifCall`: only while
|
|
64
|
+
/// no newer call has begun.
|
|
65
|
+
private func restore(ifCall call: Int?) -> Bool {
|
|
66
|
+
lock.lock(); defer { lock.unlock() }
|
|
67
|
+
if let call = call, call != callCount { return true }
|
|
68
|
+
guard let prev = saved else { return true }
|
|
69
|
+
do {
|
|
70
|
+
try AVAudioSession.sharedInstance().setCategory(prev.category, mode: prev.mode, options: prev.options)
|
|
71
|
+
saved = nil
|
|
72
|
+
return true
|
|
73
|
+
} catch {
|
|
74
|
+
NSLog("[AdaAudio] restore failed: \(error.localizedDescription)")
|
|
75
|
+
return false
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -250,6 +250,9 @@ final class VisionSession: NSObject, AVCaptureVideoDataOutputSampleBufferDelegat
|
|
|
250
250
|
self.lastPublish = 0
|
|
251
251
|
self.generation += 1 // new session → old ids can no longer resolve
|
|
252
252
|
self.session.beginConfiguration()
|
|
253
|
+
// Video only: the camera must never re-configure the app's audio session
|
|
254
|
+
// (a voice call can be running at the same time — see AdaAudioModule).
|
|
255
|
+
self.session.automaticallyConfiguresApplicationAudioSession = false
|
|
253
256
|
self.session.sessionPreset = .medium
|
|
254
257
|
// Back camera only. Offering the front camera would also need the connection
|
|
255
258
|
// mirrored (isVideoMirrored) so boxes match the mirrored view the user sees.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ateam-ai-mobile/expo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Expo-backed providers for the ADAS SDK — haptics, bundle disk cache, attachment cache, device bridge.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"build": "tsup"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@ateam-ai-mobile/core": "0.1.
|
|
13
|
-
"@ateam-ai-mobile/plugin-runtime": "0.1.
|
|
14
|
-
"@ateam-ai-mobile/ui": "0.1.
|
|
12
|
+
"@ateam-ai-mobile/core": "0.1.11",
|
|
13
|
+
"@ateam-ai-mobile/plugin-runtime": "0.1.11",
|
|
14
|
+
"@ateam-ai-mobile/ui": "0.1.11"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@react-native-async-storage/async-storage": "*",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Call audio mode for the voice call — see ios/AdaAudioModule.swift for why.
|
|
2
|
+
//
|
|
3
|
+
// requireOptionalNativeModule: on a binary WITHOUT the module (any build before
|
|
4
|
+
// it shipped) this is null and the provider is a no-op, so an OTA carrying this
|
|
5
|
+
// JS can never crash an older binary. Android: no module yet (its WebView echo
|
|
6
|
+
// path is untouched).
|
|
7
|
+
import { requireOptionalNativeModule } from 'expo-modules-core';
|
|
8
|
+
import type { CallAudioProvider } from '@ateam-ai-mobile/ui';
|
|
9
|
+
|
|
10
|
+
interface AdaAudioNative {
|
|
11
|
+
beginVoiceCall(): boolean;
|
|
12
|
+
endVoiceCall(): boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const native = requireOptionalNativeModule<AdaAudioNative>('AdaAudio');
|
|
16
|
+
|
|
17
|
+
export function createCallAudioProvider(): CallAudioProvider | null {
|
|
18
|
+
if (!native) return null;
|
|
19
|
+
return {
|
|
20
|
+
beginCall: () => { native.beginVoiceCall(); },
|
|
21
|
+
endCall: () => { native.endVoiceCall(); },
|
|
22
|
+
};
|
|
23
|
+
}
|
package/src/bootstrap.ts
CHANGED
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
*/
|
|
31
31
|
import { initAdas, setAcsReachabilityReporter, type TokenProvider, type AdasUser, type AdasSession } from '@ateam-ai-mobile/core';
|
|
32
32
|
import { setDeviceStateProvider, registerNativePlugin, registerPlatformDeviceTools, type RegisteredPlugin } from '@ateam-ai-mobile/plugin-runtime';
|
|
33
|
-
import { setOAuthProvider, setUIActionNavigator, setPluginWebViewExtraHosts, type UIActionRoute } from '@ateam-ai-mobile/ui';
|
|
33
|
+
import { setOAuthProvider, setUIActionNavigator, setPluginWebViewExtraHosts, setCallAudioProvider, type UIActionRoute } from '@ateam-ai-mobile/ui';
|
|
34
|
+
import { createCallAudioProvider } from './audio';
|
|
34
35
|
|
|
35
36
|
import { setupExpoProviders, type ExpoAttachmentCache } from './index';
|
|
36
37
|
import { createDeviceProvider } from './device/createDeviceProvider';
|
|
@@ -115,6 +116,9 @@ export function bootstrapExpoAdas(opts: BootstrapExpoAdasOptions): { attachmentC
|
|
|
115
116
|
// Native OAuth for the relocated auth screens (the ONLY native OAuth wiring).
|
|
116
117
|
setOAuthProvider(createExpoOAuthProvider({ googleIosClientId: opts.googleIosClientId }));
|
|
117
118
|
|
|
119
|
+
// The voice call's device audio mode (echo cancellation on the loudspeaker).
|
|
120
|
+
setCallAudioProvider(createCallAudioProvider());
|
|
121
|
+
|
|
118
122
|
// ACS fetch outcomes feed the host's connectivity banner (any response = up,
|
|
119
123
|
// thrown fetch = down). The host's sink stays host-side (lazy, no load cycle).
|
|
120
124
|
if (opts.onReachabilityChange) {
|