import { NodeRegistry } from '../registry'; import { CompactNode, SerializedNodes } from './types'; /** * Rebuilds a page snapshot from a compact page that carries its ids (e.g. `CopilotRequest.page`), so a backend or a * tools server can run `validateProposal` / `applyProposal` without the editor. The inverse of `fromSnapshot`: * `fromSnapshot(toSnapshot(page))` equals `page`. The result is a `Snapshot` in CraftJS `SerializedNodes` shape. * * Every id is kept; a missing, duplicated or prototype-like id throws, naming its path (`page.children[1]`). Each * node gets `type: { resolvedName }`, `isCanvas` from its schema, `props` plus `children: text`, * `displayName = type`, `custom.displayName = label`, `parent` links (`null` for the top node), `hidden: false` and * no linked nodes. An opaque node (unregistered or not writable) becomes an empty leaf: `isCanvas: false`, * `props: {}`, `nodes: []`; only the top node (ROOT) keeps its children, as in `fromSnapshot`. * * Parse the request with `copilotRequestSchema` first: it checks the page's shape and bounds its size and depth. * `toSnapshot` does not check the shape; it only re-checks the depth, without recursion, and throws an Error for a * page deeper than `COPILOT_LIMITS.pageDepth` or with props deeper than `COPILOT_LIMITS.propsDepth` (naming the path) * instead of overflowing the stack. * * Pass `options.registry` to treat extra (consumer) node types as writable; it defaults to the core registry. * * Lock state (`custom.deletable`) is not part of the compact tree, so a proposal that passes here may still remove, * replace or move a node locked on the live page: the editor re-validates on its own snapshot before applying, and * that check is authoritative. */ export declare function toSnapshot(page: CompactNode, options?: { registry?: NodeRegistry; }): SerializedNodes;