Files
orca/mobile/src/mobile-web-shell/mobile-web-shell-runtime.ts
Neil 19043a3d76 refactor(mobile): organize pairing, session, RPC and host owners (#39846)
* refactor(mobile): give relay and encryption concrete owners

* refactor(mobile): organize session and review feature owners

* refactor(mobile): organize RPC and host ownership

* test(mobile): point render fixtures at concrete owners

* refactor(mobile): use explicit type-only owner imports
2026-11-08 07:19:05 -08:00

33 lines
1.4 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import * as ExpoCrypto from 'expo-crypto'
import { encodeBase64Url } from '../transport/encryption/mobile-session-id-encoding'
import { BRIDGE_READY_RETRY_MAX_MS } from './bridge/bridge-client-init-handshake'
import type { GenerationStore } from './generation-store'
import { processGenerationStore } from './process-generation-store'
import { setForegroundTimer } from './foreground-timer'
// Use 32 random base64url bytes: each mount/remount needs a fresh id for the view’s private origin.
const SESSION_ID_BYTES = 32
// Allow five ready-backoff ceilings before treating a loaded document as silent; startup import failures may prevent every ready attempt.
export const PAGE_READY_DEADLINE_MS = BRIDGE_READY_RETRY_MAX_MS * 5
// Bound local loads the WebView refuses or never commits.
export const DOCUMENT_LOAD_DEADLINE_MS = 20_000
export type MobileWebShellRuntime = {
createStore(): GenerationStore
mintSessionId(): string
now(): number
// Count only foreground time and return cancellation; tests replace this seam instead of waiting on wall time.
setForegroundTimer(run: () => void, delayMs: number): () => void
}
export function createMobileWebShellRuntime(): MobileWebShellRuntime {
return {
createStore: processGenerationStore,
mintSessionId: () => encodeBase64Url(ExpoCrypto.getRandomBytes(SESSION_ID_BYTES)),
now: Date.now,
setForegroundTimer
}
}