import { type SandboxMap, type SandboxGenerator, type SandboxRegex, type SandboxSet } from "../interp/values.js"; type SnapshotId = number | string; type SerializedUndefinedValue = { kind: "undefined"; }; type SerializedNonFiniteNumber = { kind: "number"; value: "-Infinity" | "Infinity" | "NaN"; }; export type SerializedClosureValue = { kind: "fn"; astNodeId: number; capturedScopeId: SnapshotId; }; export type SerializedGeneratorValue = { kind: "generator"; state: "start"; astNodeId: number; capturedScopeId: SnapshotId; } | { kind: "generator"; state: "suspended"; astNodeId: number; capturedScopeId: SnapshotId; yieldNodeId: number; sent: SerializedSnapshotValue; } | { kind: "generator"; state: "done"; }; export type SerializedPromiseValue = { kind: "promise"; id: SnapshotId; }; export type SerializedReferenceValue = { kind: "ref"; id: number; }; export type SerializedHeapValue = { kind: "array"; items: SerializedSnapshotValue[]; } | { kind: "object"; entries: Record; } | { kind: "map"; entries: Array<[SerializedSnapshotValue, SerializedSnapshotValue]>; } | { kind: "set"; values: SerializedSnapshotValue[]; }; export type SerializedSnapshotValue = boolean | null | number | string | SerializedClosureValue | SerializedGeneratorValue | SerializedNonFiniteNumber | SerializedPromiseValue | SerializedReferenceValue | SerializedUndefinedValue | { kind: "regex"; source: string; flags: string; lastIndex: number; } | SerializedSnapshotValue[] | { [key: string]: SerializedSnapshotValue; }; export type RuntimeClosureValue = { kind: "fn"; astNodeId: number; capturedScopeId: SnapshotId; call?: unknown; }; export type RuntimePromiseValue = { kind: "promise"; id: SnapshotId; promise?: Promise; }; export type RuntimeSnapshotValue = boolean | null | number | string | undefined | RuntimeClosureValue | SandboxGenerator | RuntimePromiseValue | SandboxMap | SandboxRegex | SandboxSet | RuntimeSnapshotValue[] | { [key: string]: RuntimeSnapshotValue; }; export type RuntimeScopeFrame = { id: SnapshotId; parentId?: SnapshotId; bindings: Record; }; export type SerializedScopeFrame = { id: SnapshotId; parentId?: SnapshotId; bindings: Record; }; export type RuntimeCallFrame = { astNodeId: number; scopeId: SnapshotId; awaitingPromiseId?: SnapshotId; }; export type SerializedCallFrame = RuntimeCallFrame; export type RuntimePendingPromise = { id: SnapshotId; promise?: Promise; [key: string]: RuntimeSnapshotValue | Promise | SnapshotId | undefined; }; export type SerializedPendingPromise = { id: SnapshotId; [key: string]: SerializedSnapshotValue | SnapshotId; }; export type SerializeInput = { source: string; currentAstNodeId: number; scopeChain: RuntimeScopeFrame[]; callStack: RuntimeCallFrame[]; pendingPromises: RuntimePendingPromise[]; moduleBindings: Record; }; export type SerializedSnapshot = { sourceHash: string; currentAstNodeId: number; scopeChain: SerializedScopeFrame[]; callStack: SerializedCallFrame[]; pendingPromises: SerializedPendingPromise[]; moduleBindings: Record; heap?: Record; }; export declare class UnsnapshotableValueError extends Error { readonly path: string; constructor(path: string); } export declare function serialize(input: SerializeInput): SerializedSnapshot; export {};