mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 10:58:10 +00:00
* 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
33 lines
1.4 KiB
TypeScript
33 lines
1.4 KiB
TypeScript
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
|
||
}
|
||
}
|