import { NativeCommand, NativeNodeId, NativePropValue } from "./native-protocol.js"; import { MindeesError } from "@mindees/core"; //#region src/native-host.d.ts /** A reconstructed host node. */ interface ReferenceHostNode { /** Stable id from the command stream. */ readonly id: NativeNodeId; /** `"root"` (the pre-existing container), `"element"`, or `"text"`. */ readonly kind: 'root' | 'element' | 'text'; /** Element tag (empty for text nodes). */ tag: string; /** Text content (text nodes). */ text: string; /** Applied props (elements). */ props: Record; /** Wired events: eventName → handlerId. */ events: Map; /** Parent, or `null` when detached / the root. */ parent: ReferenceHostNode | null; /** Ordered children. */ children: ReferenceHostNode[]; } /** A reference host that applies a {@link NativeCommand} stream to a model tree. */ interface ReferenceHost { /** Id of the root container. */ readonly rootId: NativeNodeId; /** The root node; its `children` mirror the rendered top-level nodes. */ readonly root: ReferenceHostNode; /** Apply a single command (throws {@link NativeHostError} on a malformed one). */ apply(command: NativeCommand): void; /** Apply a batch in order. */ applyBatch(commands: readonly NativeCommand[]): void; /** Look up a live node by id. */ getNode(id: NativeNodeId): ReferenceHostNode | undefined; /** Number of live (created, not yet disposed) nodes, excluding the root. */ liveNodeCount(): number; /** A compact structural string of the tree (tags + text; inspect props via {@link getNode}). */ serialize(): string; } /** Machine-readable reason a {@link NativeHostError} was thrown. */ type NativeHostErrorCode = 'UNKNOWN_NODE' | 'DUPLICATE_ID' | 'UPDATE_TEXT_NON_TEXT' | 'ALREADY_PARENTED' | 'INDEX_OUT_OF_RANGE' | 'NOT_A_CHILD' | 'DISPOSE_ROOT' | 'UNKNOWN_COMMAND'; /** Thrown when a command stream violates the host contract. Extends {@link MindeesError}. */ declare class NativeHostError extends MindeesError { /** Narrows {@link MindeesError.code} to the host-contract codes. */ readonly code: NativeHostErrorCode; constructor(code: NativeHostErrorCode, message: string); } /** * Create a {@link ReferenceHost}. Wire it to a backend to validate + reconstruct: * * @example * const host = createReferenceHost() * const backend = createNativeCommandBackend({ rootId: host.rootId, onCommand: (c) => host.apply(c) }) * render(MyComponent, {}, backend, backend.root) * host.serialize() // the reconstructed tree */ declare function createReferenceHost(rootId?: NativeNodeId): ReferenceHost; //#endregion export { NativeHostError, NativeHostErrorCode, ReferenceHost, ReferenceHostNode, createReferenceHost }; //# sourceMappingURL=native-host.d.ts.map