import { type DesignImportController, type DesignScreenCaptureSpec } from './designImport.js'; import type { RoutePreviewCache } from './routePreview.js'; import type { FlowSessionRunner, FlowSessions, ResolvedFlowPath } from './flowSessions.js'; import { type InteractiveSessionSurfaces } from './interactiveSessionSurface.js'; import type { ScreenFlowPath } from './screenFlows.js'; import type { EditorStore, PageModel } from './store.js'; import type { EditorDeclarations } from './declarations.js'; /** What the scheduler needs from an editor runtime; `EditorRuntime` satisfies it. */ export interface FlowSessionRuntime { readonly store: EditorStore; readonly host: { readonly appOrigin: string; readonly previewRevision: string; }; readonly previews: RoutePreviewCache; readonly declarations: EditorDeclarations; } /** Applies the active frame's own boot condition to a path-specific session. */ export declare function resolveActivePagePath(declarations: Pick, resolved: ResolvedFlowPath, path: ScreenFlowPath, page: PageModel, appOrigin: string): ResolvedFlowPath; /** Diagnostic counters for the headless debug surface. */ export declare function interactiveSessionScreenId(page: { id: string; interactiveStateId?: string; interactiveOptionId?: string; interactiveOptionIds?: readonly string[]; interactiveStateSelections?: Readonly>; }): string; /** Direct sibling options render through one persistent React document. */ export declare function interactiveSessionSurfaceId(page: { id: string; interactiveStateId?: string; interactiveOptionId?: string; interactiveOptionIds?: readonly string[]; interactiveStateSelections?: Readonly>; interactiveStateUsesDesiredState?: boolean; }): string; export type InteractiveVariantPrefetchOutcome = 'queued' | 'busy' | 'tracked' | 'unavailable'; export interface FlowSessionSchedulerDeps { /** This runtime's warm pool, runner factory, and canonical runner. */ sessions: FlowSessions; /** This runtime's session surfaces; the direct-state handlers go on them. */ surfaces: InteractiveSessionSurfaces; } /** * One editor's flow-session scheduling: the canvas fill, the activation warm, * the viewport and interactive runners with their delivery states, the * direct-state paths, and the counters the debug surface reads. Bound to one * runtime, so it reads that runtime's store, host, and preview cache and * installs its direct-state handlers on that runtime's surfaces. */ export declare function createFlowSessionScheduler(runtime: FlowSessionRuntime, deps: FlowSessionSchedulerDeps): { __flowSchedulerDebug: { calls: number; lastCanvas: string; lastFlows: number; lastCandidates: number; lastQueued: number; }; materializeCanvasFlows: (input: { canvas: string; previewRevision: string; /** * Only paths that deliver one of these screens. The worker-first supply * hands the walking supply exactly the screens the worker could not answer; * without a filter every path on the canvas is a candidate. */ screenIds?: ReadonlySet; }) => number; flowSessionWillDeliverPage: (page: { importPageId?: string; id: string; }) => boolean; warmActiveFrameInstance: (page: PageModel, previewRevision: string) => boolean; __warmingDebug: { requested: number; noPath: number; resolvedNull: number; alreadyWarm: number; queued: number; }; materializePageViewport: (page: PageModel, viewport: { width: number; height: number; }, previewRevision: string) => boolean; viewportSessionWillDeliver: (page: { importPageId?: string; id: string; }, viewport: { width: number; height: number; }) => boolean; subscribeViewportSessions: (listener: () => void) => () => void; prepareInteractiveSessionState: (iframe: HTMLIFrameElement, spec: DesignScreenCaptureSpec, controller?: Pick | null, onStateReady?: () => void) => Promise; __setInteractiveSessionRunnerForTests: (runner: FlowSessionRunner | null) => void; materializePageInteractiveState: (page: PageModel, previewRevision: string, targetCacheKey?: string) => boolean; interactiveSessionWillDeliver: (previews: Pick, page: { id: string; interactiveStateId?: string; interactiveOptionId?: string; interactiveOptionIds?: readonly string[]; interactiveStateSelections?: Readonly>; interactiveStateUsesDesiredState?: boolean; }, targetCacheKey?: string) => boolean; subscribeInteractiveSessions: (listener: () => void) => () => void; interactiveSessionRunnerIsIdle: () => boolean; interactiveSessionTracksVariant: (variantPage: { importPageId?: string; id: string; interactiveStateId?: string; interactiveOptionId?: string; }) => boolean; prefetchPageInteractiveVariant: (variantPage: PageModel, previewRevision: string) => InteractiveVariantPrefetchOutcome; __interactiveSessionDebug: { requested: number; noPath: number; resolvedNull: number; queued: number; /** Base-prefix re-park warming walks queued behind variant deliveries. */ reparkQueued: number; /** Re-parks skipped because a parked base instance already serves the prefix. */ reparkAlreadyParked: number; /** Re-parks skipped because the option adds no steps over the base screen. */ reparkNoExtraSteps: number; }; __debugInteractiveSessionStates: () => Record; __viewportCommitDebug: { requested: number; resolvedNull: number; controllerMissing: number; markerGone: number; editsWon: number; captureNull: number; committed: number; }; __debugViewportSessionStates: () => Record; }; export type FlowSessionScheduler = ReturnType;