//#region src/clipboard.d.ts /** * HTML envelope Figma reads when you paste from the system clipboard. * * The wire format stores Figma's comment markers inside data attributes, * matching the HTML Figma writes when copying a node. Keeping the markers out * of top-level comment nodes is important for WebKit: Safari sanitizes * `text/html` clipboard writes and strips comment nodes before they reach the * system pasteboard. * * * */ type FigmaClipboardMeta = { dataType: "scene"; fileKey: string; pasteID: number; }; /** Build the HTML clipboard envelope. No DOM required. */ declare function composeClipboardHtml(base64: string, meta?: FigmaClipboardMeta): string; /** Wrap envelope HTML in a `ClipboardItem` for `navigator.clipboard.write`. */ declare function toClipboardItem(html: string): ClipboardItem; type ParsedClipboardHtml = { /** Raw fig-kiwi envelope bytes, ready for `decodeFigmaData`. */fig: Uint8Array; /** Parsed `(figmeta)` JSON, when present. */ meta: FigmaClipboardMeta | null; }; /** * Extract the fig-kiwi payload (and figmeta, when present) from a clipboard * HTML envelope — ours or one copied straight out of Figma. */ declare function parseClipboardHtml(html: string): ParsedClipboardHtml; //#endregion //#region src/types.d.ts type Field = { name: string; datatype: number; array: boolean; datatype_name: string; }; type TypeDef = { kind: number; kind_name: string; name: string; fields: Record; field_count: number; index: number; }; type Schema = { version: number; types: Array; type_count: number; }; //#endregion //#region src/decoder.d.ts type DecodedFigmaData = { prelude: string; version: number; schema: Schema; /** The decoded root `Message` (e.g. `{ type: "NODE_CHANGES", nodeChanges: [...] }`). */ message: Record; }; /** * Decode a fig-kiwi binary envelope (magic + version + compressed schema + * compressed data, deflate or zstd per chunk) into the root Kiwi `Message`, * using the schema embedded in the payload itself so newer Figma schema * versions decode without a regenerated `schema.json`. */ declare function decodeFigmaData(figBytes: Uint8Array): DecodedFigmaData; //#endregion //#region src/tree.d.ts /** Shared node-tree utilities for decoded Figma clipboard payloads. */ type OracleNode = Record & { guid: { sessionID: number; localID: number; }; parentIndex?: { guid: { sessionID: number; localID: number; }; position: string; }; type?: string; name?: string; }; /** * Depth-first node list per canvas-level frame, children ordered by their * position strings (Figma's fractional indexing sorts lexicographically). * Multi-scene payloads have several canvas-level frames; DOCUMENT/CANVAS * nodes (including Figma's "Internal Only Canvas") never enter the walk. */ declare function treeOrder(changes: Array): Array<{ name: string; nodes: Array; }>; //#endregion //#region src/diff.d.ts type Mismatch = { /** A positional node label (Figma re-ids nodes on paste, so there is no guid). */node: string; field: string; sent: unknown; got: unknown; }; /** * Compare a sent payload against a Figma copy-back payload. Top-level frames * pair by name; nodes within a frame pair by tree order. Returns the list of * structural mismatches (empty when Figma reproduced the payload exactly). */ declare function diffFigmaTrees(sent: Array, got: Array): Array; //#endregion //#region src/encoder.d.ts /** * Encode a Kiwi `Message` into the fig-kiwi binary envelope (magic + version * + deflated schema + deflated data) plus its base64 form. */ declare function encodeFigmaData(message: unknown): { figBytes: Uint8Array; base64: string; size: number; }; //#endregion //#region src/kiwi-reader.d.ts /** Sequential reader for Kiwi-encoded bytes; mirrors `KiwiWriter`. */ declare class KiwiReader { private readonly bytes; private offset; constructor(bytes: Uint8Array); get done(): boolean; byte(): number; bool(): boolean; uint(): number; uint64(): number; int(): number; int64(): number; float(): number; string(): string; rawBytes(length: number): Uint8Array; } //#endregion //#region src/kiwi-writer.d.ts declare class KiwiWriter { chunks: Array; currentSize: number; constructor(); getBytes(): Uint8Array; byte(value: number): void; bool(value: boolean): void; uint(value: number): void; uint64(value: number): void; bytes(data: Uint8Array | ArrayBuffer | Array): void; int(value: number): void; int64(value: number): void; float(value: number): void; string(value: string): void; } //#endregion //#region src/schema.d.ts declare const SCHEMA: Schema; //#endregion //#region src/stack-fields.d.ts /** * Auto-layout (`stack*`) field knowledge shared by the oracle verification * tooling and regression tests. * * Figma omits fields that hold their default value when serializing a copied * node (established empirically via paste round-trips — see * .context/auto-layout/PLAN.md). Comparing payloads therefore requires * normalizing absent fields to these defaults first. */ declare const STACK_FIELD_DEFAULTS: Record; /** All auto-layout fields the oracle workflow tracks, defaults or not. */ declare const TRACKED_STACK_FIELDS: ReadonlySet; //#endregion export { type DecodedFigmaData, type Field, type FigmaClipboardMeta, KiwiReader, KiwiWriter, type Mismatch, type OracleNode, type ParsedClipboardHtml, SCHEMA, STACK_FIELD_DEFAULTS, type Schema, TRACKED_STACK_FIELDS, type TypeDef, composeClipboardHtml, decodeFigmaData, diffFigmaTrees, encodeFigmaData, parseClipboardHtml, toClipboardItem, treeOrder }; //# sourceMappingURL=index.d.mts.map