import { type ActionsSink } from './actions-file.js'; import { type AnyFrame, type BootRegistrationsOutcome, type BridgeEngine, type CommandFrame, type DevReloadKind, type HelloFrame, type IncomingLogEvent, type LateReloadRestart, type ReloadAckOutcome, type ReloadFrame, type ReloadRestartOutcome, type ServerFrame } from './contracts.js'; import type { LogsFileWriter } from './logs-file.js'; import { LogRingBuffer } from './ring-buffer.js'; export interface BridgeConnection { readonly id: string; readonly origin?: string; readonly remoteAddress?: string; send(frame: ServerFrame | CommandFrame): boolean; close(code?: number, reason?: string): void; } interface ExecutorAttachInfo { origin?: string; } interface BridgeBrokerOptions { instanceId: string; runId: string; engine?: BridgeEngine; viewerOrigin?: string | null; ring?: LogRingBuffer; file?: LogsFileWriter; allowControl?: boolean; allowEval?: boolean; controlToken?: string; actions?: ActionsSink; authorMode?: boolean; now?: () => number; setTimer?: (fn: () => void, ms: number) => ReturnType; clearTimer?: (handle: ReturnType) => void; onExecutorAttached?: (attached?: ExecutorAttachInfo) => void; onExecutorDetached?: () => void; wakeExecutor?: () => Promise; onReloadApplied?: (kind: string, label?: string) => void; onLateBootRegistration?: (afterMs?: number) => void; readLoadRefusal?: () => string | null; sessionCommand?: BridgeSessionCommand; } type BridgeSessionCommand = 'dev' | 'start' | 'preview'; export { CLOSE_BAD_HELLO, CLOSE_BAD_INSTANCE, CLOSE_CONTROL_UNAVAILABLE, CLOSE_SLOW_CONSUMER, CLOSE_TOKEN_REQUIRED } from './contracts.js'; export declare const RELOAD_ACK_TIMEOUT_MS = 3000; export declare const RELOAD_RESTART_TIMEOUT_MS = 15000; export declare function alreadyRunsLatchedBuild(hello: HelloFrame, frame: ReloadFrame): boolean; export declare class BridgeBroker { private readonly instanceId; private readonly runId; private readonly engine?; private readonly viewerOrigin; private viewerEverConnected; private readonly ring; private readonly file?; private readonly roles; private readonly sessionExtensionOrigins; private readonly allowControl; private readonly allowEval; private readonly controlToken?; private readonly actions?; private readonly authorMode; private readonly now; private readonly setTimer; private readonly clearTimer; private readonly evalGate; private readonly pending; private staleResyncTimes; private producerEverConnected; private readonly sessionStartedAt; private lastUndeliveredWarnKind; private controlPortUnavailable; private readonly onExecutorAttached?; private readonly onExecutorDetached?; private readonly wakeExecutor?; private bootRegistrations; private bootRegistrationsAwaited; private lateBootRegistrationSaid; private readonly bootRegistrationWaiters; private readonly onLateBootRegistration?; private readonly readLoadRefusal?; private readonly executorWaiters; private readonly waking; private readonly onReloadApplied?; private readonly sessionCommand; private producerless; private lastProducerDisconnectedAt; private browserExitedAt; private browserExitHow; private lastStaleHelloAt; private pendingReload?; private replayedTabs; private latchedReloadDelivered?; private readonly ackingProducers; private readonly sessionBuilds; private readonly producerBuilds; private reloadSeq; private reloadAck; private reloadRestart; constructor(options: BridgeBrokerOptions); get consumerCount(): number; get producerCount(): number; get controllerCount(): number; get viewerCount(): number; get pendingCount(): number; onFrame(conn: BridgeConnection, frame: AnyFrame): void; onClose(conn: BridgeConnection): void; private failCommandsOf; private settle; broadcastReload(instruction: { type: DevReloadKind; changedContentScriptEntries?: string[]; label?: string; changedFiles?: string[]; changedScriptFiles?: string[]; refreshedStylesheets?: { file: string; digest: string; }[]; standalonePages?: string[]; build?: string; }): number; runsBuild(build: string): boolean; noteReloadApplied(kind: string, label?: string): void; awaitReloadAck(): Promise; reloadReplayedTabs(): number; private armReloadAck; private onReloadAck; awaitBootRegistrations(timeoutMs: number): Promise; private onBootRegistrations; awaitReloadRestart(): Promise; awaitLateReloadRestart(): Promise; private armReloadRestart; deliverLatchedReload(): Promise; undeliveredReloadWarning(options?: { producerRestartExpected?: boolean; }): string | null; pingProducers(): number; ingestLog(incoming: IncomingLogEvent): void; private allowStaleProducerResync; noteSessionBuild(build: string): void; private compiledBefore; private runsEarlierSessionBuild; private resyncEarlierSessionProducer; private onHello; noteNoBackground(): void; noteControlPortUnavailable(reason?: string | null): void; noteBrowserExited(at: string, how?: string | null): void; private loadRefusal; private absentExecutorError; private absentForNoBackground; private diagnoseExecutorAbsence; isSessionExtensionOrigin(origin: unknown): boolean; private isRemotePeer; private gateEval; private controllerReady; private onCommand; private canWakeExecutor; private wakeThenRoute; private waitForExecutor; private routeCommand; private onResult; private onTimeout; private firstExecutor; private audit; private fanOut; private isReloadReceiver; private countRole; }