import type { ScriptProtocolRequest, ScriptProtocolReply } from './protocol-callbacks.js'; /** 宿主运行时能力(`gis.capabilities.get()`),字段与桌面 `HostCapabilities` 一致。 */ export interface HostCapabilities { platform: "desktop" | "mobile" | "web"; graphics: string | null; computeShaders: boolean; lineAnimation: boolean; gaussianSplats: boolean; localFiles: "any" | "sandbox" | "picker"; corsRestricted: boolean; gdal: boolean; } /** 脚本错误:`code` 与桌面相同(如 `INVALID_ARGUMENT`、`PERMISSION_DENIED`、`CAPABILITY_UNAVAILABLE`、`CANCELLED`)。 */ export interface ScriptErrorInfo { code: string; message: string; retryable?: boolean; details?: Record; /** 参数校验失败时的接口名与参数位置。 */ commandSequence?: number; submittedSequence?: number; argumentApi?: string; argumentPath?: string; } /** 一次结果:`value`(成功)、`error`(失败)或 `progress`(0~1 的进度,不结束操作)。 */ export interface SettleResponse { id: string; value?: unknown; error?: ScriptErrorInfo; progress?: number; } /** 宿主事件,身份与序号由地图宿主提供;target 在脚本端重建。 */ export interface ScriptEvent { type: string; value: unknown; mapInstanceId?: string; sequence?: number; } export interface EventContext { mapInstanceId: string; events: string[]; } export type ToWorker = { type: "dynamic-images"; id: string; batch: unknown; } | { type: "dynamic-images-control"; kind: "reconcile" | "contextLost" | "clear"; state?: unknown; } | { type: "protocol-request"; request: ScriptProtocolRequest; } | { type: "protocol-cancel"; id: string; } | { type: "protocol-replied"; id: string; error?: ScriptErrorInfo; } | { type: "run"; source: string; capabilities: HostCapabilities; eventContext: EventContext; } | { type: "settle"; responses: SettleResponse[]; } | { type: "events"; events: ScriptEvent[]; } | { type: "remove"; events: ScriptEvent[]; }; export type FromWorker = { type: "dynamic-images-reply"; id: string; result?: unknown; error?: ScriptErrorInfo; } | { type: "protocol-reply"; reply: ScriptProtocolReply; } | { type: "request"; id: string; name: string; args: unknown[]; } | { type: "cancel"; id: string; } | { type: "started"; } | { type: "initialized"; value: unknown; keep: string[]; } | { type: "events-applied"; } | { type: "removed"; } | { type: "pulse"; } | { type: "dispose-session"; } | { type: "done"; value: unknown; keep: string[]; } | { type: "failed"; error: ScriptErrorInfo; };