import type { ParsedOfficeFile } from '../../preview'; import { type OfficeDocumentSession } from '../../session'; import type { PreviewKind } from '../formatDefinitions'; import type { MaterializedPreviewState, OfficeFileViewerPreviewHandle, OfficeFileViewerPreviewState } from '../internalTypes'; import type { RuntimeSink } from '../runtime/types'; import type { ParseProgress } from '../types'; /** 格式族会话适配器创建时使用的共享上下文。 */ export type OfficeSessionAdapterContext = { /** 当前解析的浏览器文件。 */ file: File; /** 当前文件对应的具体预览格式。 */ kind: PreviewKind; /** 当前会话是否允许发送渐进预览。 */ enablePartial: boolean; /** 统一持有取消信号和解析资源的文档会话。 */ documentSession: OfficeDocumentSession; /** 向解析会话订阅者发送加载进度。 */ emitProgress(progress: ParseProgress): void; /** 向预览器发送格式族已经可以展示的快照。 */ emitPartial(preview: OfficeFileViewerPreviewState): void; }; /** 单个格式族向解析会话提供的运行时组装能力。 */ export type OfficeFormatSessionAdapter = { /** 接收主线程或 Worker 输出的统一解析事件。 */ readonly sink: RuntimeSink; /** 完成组装并把文档会话所有权交给最终预览句柄。 */ finish(): Promise; /** 解析失败时保留已经可展示的渐进结果。 */ recoverPartial(): Promise; /** 释放尚未转移给最终模型的格式资源。 */ dispose(): void | Promise; }; /** 动态格式族模块对注册表暴露的创建函数。 */ export type OfficeFormatSessionAdapterFactory = (context: OfficeSessionAdapterContext) => OfficeFormatSessionAdapter; /** 创建与具体格式严格对应的物化预览状态。 */ export declare function createMaterializedPreviewState(context: OfficeSessionAdapterContext, parsed: Parsed): Extract; /** 转移部分结果的资源所有权,并返回不带释放方法的预览快照。 */ export declare function retainMaterializedPreview(context: OfficeSessionAdapterContext, parsed: ParsedOfficeFile): OfficeFileViewerPreviewState; /** 转移完整结果的资源所有权,并创建可幂等释放的最终句柄。 */ export declare function createMaterializedPreviewHandle(context: OfficeSessionAdapterContext, parsed: ParsedOfficeFile): OfficeFileViewerPreviewHandle; type RuntimeSinkOverrides = Partial>; /** 使用统一默认行为补齐格式族不需要处理的运行时事件。 */ export declare function createOfficeFormatRuntimeSink(familyLabel: string, context: OfficeSessionAdapterContext, overrides: RuntimeSinkOverrides): RuntimeSink; export {};