import type { ScriptProtocolRequest, ScriptProtocolReply } from './protocol-callbacks.js'; import type { EventContext, HostCapabilities, ScriptErrorInfo, ScriptEvent, SettleResponse } from "./protocol.js"; export { MapCommandQueue } from "./map-commands.js"; export type { ScriptProtocolRequest, ScriptProtocolReply }; export type { EventContext, HostCapabilities, ScriptErrorInfo, ScriptEvent, SettleResponse }; /** 一次接口调用。`name` 为登记名(如 `map.addGeoJSON`),以 `$` 开头的是桥接内部操作(`$preview`、`$apply` 等)。 */ export interface ScriptRequest { id: string; name: string; args: unknown[]; } /** 宿主:执行接口调用并返回结果(可含 `$kind` 引用、`plan` 计划);抛出 `ScriptError` 表示失败。 */ export interface ScriptHost { subscribeDynamicImages?(dispatch: (message: { id: string; batch: unknown; } | { kind: "reconcile" | "contextLost" | "clear"; state?: unknown; }) => void): () => void; replyDynamicImages?(reply: { id: string; result?: unknown; error?: ScriptErrorInfo; }): Promise; call(request: ScriptRequest, signal: AbortSignal): Promise; /** Private callback channel; functions remain in the script worker. */ subscribeProtocols?(dispatch: (message: { request: ScriptProtocolRequest; } | { cancel: string; }) => void): () => void; replyProtocol?(reply: ScriptProtocolReply): Promise; /** 本次任务结束(成功、失败或停止)后释放宿主资源。 */ finish?(): void; /** 此地图真实可用的事件,不以声明代替宿主实现。 */ eventContext?(): EventContext; /** 每次运行建立监听,运行器在成功、失败、停止时取消。 */ subscribeEvents?(dispatch: (events: ScriptEvent[]) => void): () => void; } /** 带错误码的脚本错误。 */ export declare class ScriptError extends Error { readonly code: string; readonly info: ScriptErrorInfo; constructor(info: ScriptErrorInfo); } /** 跨端检查发现的问题。 */ export interface PlatformIssue { line: number; kind: "unsupported-api" | "local-path"; message: string; } export interface RunOptions { /** `gis.capabilities.get()` 返回的宿主能力。 */ capabilities?: Partial; /** 超时(毫秒),默认 60000;超时与停止都以 `CANCELLED` 结束并终止 Worker。 */ timeoutMs?: number; /** 顶层已初始化的持续会话失败;run Promise 此时已返回初始化结果。 */ onSessionError?(error: ScriptError): void; } /** Mutation names come from the same registry used by both runtimes. */ export declare function mapCommandNames(): Promise>; /** 运行前的跨端检查(不运行脚本):调用了网页端没有的接口、写死本地路径等。 */ export declare function checkScript(source: string, platform?: "web" | "mobile" | "desktop"): Promise; /** 网页端可用接口的 TypeScript 声明(供编辑器提示)。 */ export declare function webDeclarations(): Promise; /** 一次性脚本默认在顶层结束后关闭;export const sessionMode='persistent' 显式保留会话。 */ export declare class ScriptRunner { #private; constructor(host: ScriptHost); get running(): boolean; get persistent(): boolean; /** 会话实际关闭的通知;停止以 error.code=CANCELLED 表示,不产生未处理拒绝。 */ get closed(): Promise<{ error?: ScriptError; }>; run(source: string, options?: RunOptions): Promise; /** 有界事件转发。高频视图/进度合并;离散事件溢出显式结束会话。 */ dispatch(events: ScriptEvent[]): void; stop(): void; }