import type { SourceFilePlan } from './dist-lib/types/host/sourceFilePlan.js'; import type { WorkspaceStructureGroupLayout, WorkspaceStructureWrapperDeclaration } from './dist-lib/types/workspace/source/contracts.js'; export interface JsxStructureAnchor { nodeId: string; file: string; start: number; end: number; expected: string } export type JsxStructureGroupLayout = WorkspaceStructureGroupLayout; /** * Host declaration for element wrappers. A group with a layout compiles to * `}>` plus one managed block in the * stylesheet; spacing pairs document pixel values with the host's exact CSS spellings. */ export type JsxStructureWrapperContract = WorkspaceStructureWrapperDeclaration; /** The contract and the complete stylesheet bytes matching the JSX source being read. */ export interface JsxStructureWrapperEvidence { contract: JsxStructureWrapperContract; source: string } export type JsxStructureOperation = | { kind: 'reorder'; parentId: string; children: readonly string[] } /** * Index addresses the final list after removing the node from its original parent. * Default preserves the render island. `boundary: 'destination'` explicitly adopts the * destination condition and repetition; same-file references must retain their lexical * symbols, and cross-file moves must be self-contained intrinsic JSX without free values. */ | { kind: 'reparent'; nodeId: string; parentId: string; index: number; boundary?: 'destination' } /** A layout requires the plan's wrapper contract; without one the group is an anonymous fragment. */ | { kind: 'group'; nodeIds: readonly string[]; groupId: string; layout?: JsxStructureGroupLayout } /** Removes an anonymous fragment or a generated wrapper element together with its managed block. */ | { kind: 'ungroup'; nodeId: string }; export interface JsxStructureDiagnostic { code: string; message: string; file?: string; nodeId?: string } export interface JsxStructureSourceNode { nodeId: string; parentId: string | null; children: string[]; kind: 'element' | 'expression' | 'fragment' | 'text'; tagName?: string; /** Only a static string literal is reported; bindings and CSS module expressions are not evaluated. */ className?: string; /** Present only for a generated wrapper element proved against its managed stylesheet block. */ layout?: JsxStructureGroupLayout; wrapper?: { className: string }; runtimePath: number[]; start: number; end: number; } /** Persist alongside the source in the same reviewed file plan; offsets are UTF-16 source positions. */ export interface JsxStructureIdentity { version: 1; file: string; sourceSha256: string; rootId: string; opaqueNodeIds: string[]; anchors: { nodeId: string; start: number; end: number }[]; /** Generated wrapper groups; absent when the island has none. */ wrappers?: { nodeId: string; className: string }[]; } /** Checks the supplied anchor snippets and full AST projection before returning serializable evidence. */ export declare function createJsxStructureIdentity(input: { file: string; source: string; rootId: string; anchors: readonly JsxStructureAnchor[]; opaqueNodeIds?: readonly string[]; /** Required to record wrapper groups; the stylesheet must be the bytes reviewed with this source. */ wrapper?: JsxStructureWrapperEvidence; }): JsxStructureIdentity; /** * Throws on stale bytes, malformed identity, missing nodes or ambiguous ranges. Never guesses IDs. * Recorded wrappers require the wrapper evidence; a wrapper whose element or managed block was * edited by hand fails closed instead of degrading to a plain element. */ export declare function reimportJsxStructureSource(input: { file: string; source: string; identity: JsxStructureIdentity; wrapper?: JsxStructureWrapperEvidence; }): { anchors: JsxStructureAnchor[]; nodes: JsxStructureSourceNode[] }; /** * Throws for invalid source, ambiguous roots, or opaque offsets outside the projected tree. * Runtime paths exclude blank multiline indentation and comment-only expressions. Expressions * that evaluate to false or undefined still occupy one slot; their values are never evaluated. */ export declare function inspectJsxStructureSource(input: { file: string; source: string; rootStart: number; opaqueNodeStarts?: readonly number[]; }): { anchors: JsxStructureAnchor[]; nodes: JsxStructureSourceNode[] }; /** * Pure source compilation; the host audits allowed containers and the complete canonical-document delta. * Expressions move only as complete opaque chunks within one static JSX tree. Rendered text and * standalone comments in an edited parent block ambiguous hierarchy changes. Groups without a layout * are anonymous fragments, which do not provide a DOM box. With a wrapper contract, a group with a * layout emits one intrinsic element and a managed block in the contract stylesheet, which must be * supplied in `files` and allowed for writing. Neither form certifies preservation of component * reconciliation state across a React remount. Props, handlers, and expression source are preserved * without evaluation or fixture substitution. */ export declare function compileJsxStructurePlan(input: { sourceRevision: string; files: readonly { file: string; source: string; sha256: string }[]; anchors: readonly JsxStructureAnchor[]; operations: readonly JsxStructureOperation[]; allowedFiles: readonly string[]; excludedSourcePrefixes?: readonly string[]; wrapper?: JsxStructureWrapperContract; }): { status: 'ready'; payload: SourceFilePlan; anchors: JsxStructureAnchor[] } | { status: 'unchanged'; anchors: JsxStructureAnchor[] } | { status: 'blocked'; diagnostics: JsxStructureDiagnostic[] }; export interface JsxStructureReconciliationInput { file: string; baseline: { sourceRevision: string; source: string; identity: JsxStructureIdentity }; external: { /** May equal the baseline commit for explicitly checked working-copy changes. */ sourceRevision: string; source: string; sha256: string; /** * Complete host-supplied correspondence to the current AST. Retained IDs explicitly mean * the same source-owned nodes; new IDs must be fresh. Core never infers this mapping from * names, positions, snippets, runtime values, or example data. Every range and hash is checked. */ identity: JsxStructureIdentity; }; /** Complete audited draft structure relative to baseline; the host checks other document deltas. */ operations: readonly JsxStructureOperation[]; allowedFiles: readonly string[]; excludedSourcePrefixes?: readonly string[]; /** Required when either identity records wrapper groups or the draft adds one. */ wrapper?: { contract: JsxStructureWrapperContract; baselineSource: string; externalSource: string; externalSha256: string; }; } export interface JsxStructureReconciliationShape { kind: JsxStructureSourceNode['kind']; parentId: string | null; children: string[]; layout: JsxStructureGroupLayout | null; } export interface JsxStructureReconciliationDiagnostic extends JsxStructureDiagnostic { action: 'refresh-source' | 'map-identities' | 'resolve-overlap'; baseline?: JsxStructureReconciliationShape | null; external?: JsxStructureReconciliationShape | null; draft?: JsxStructureReconciliationShape | null; } export interface ReconciledJsxStructureSource { file: string; baselineSourceRevision: string; baselineSourceSha256: string; /** The external revision is retained; the baseline is never silently relabeled. */ sourceRevision: string; externalSourceSha256: string; source: string; /** Persist with the resulting source using a separately reviewed, exact file plan. */ identity: JsxStructureIdentity; /** The contract stylesheet after the merge; present only when wrapper input was supplied. */ stylesheetSource?: string; anchors: JsxStructureAnchor[]; nodes: JsxStructureSourceNode[]; diagnostics: readonly []; } export type JsxStructureReconciliationResult = | (ReconciledJsxStructureSource & { status: 'ready'; payload: SourceFilePlan }) | (ReconciledJsxStructureSource & { status: 'unchanged' }) | { status: 'conflict'; diagnostics: readonly JsxStructureReconciliationDiagnostic[] }; /** * Pure, explicit three-way reconciliation. Disjoint child-list changes merge; overlapping lists, * removals, incompatible boundaries, competing wrapper layouts and ambiguous identities require * explicit conflict resolution. External props and expression bytes survive structure-only edits. * Host source ownership and document/binding validation still apply. A ready plan proves the * latest external bytes only. */ export declare function reconcileJsxStructurePlan(input: JsxStructureReconciliationInput): JsxStructureReconciliationResult; /** * Validate every edit against the original source, compose disjoint text/prop/data ranges, * then move their containing JSX using updated exact anchors. Source proofs always refer * to the original files. Styles compile in an isolated temporary directory; no checkout writes. * A rewrite that consumes an owned JSX boundary is blocked, never rebased by text matching. */ export declare function compileSourceDocumentPlan(input: { sourceRevision: string; files: readonly { file: string; source: string; sha256: string }[]; allowedFiles: readonly string[]; excludedSourcePrefixes?: readonly string[]; visualPayload?: import('./dist-lib/types/editor/inspect.js').InspectApplyPayload; bindingPlan?: import('./dist-lib/types/binding/source.js').BindingSourcePlan; structure?: { anchors: readonly JsxStructureAnchor[]; operations: readonly JsxStructureOperation[]; wrapper?: JsxStructureWrapperContract }; signal?: AbortSignal; }): Promise<{ status: 'ready'; payload: SourceFilePlan; anchors: JsxStructureAnchor[] } | { status: 'unchanged'; anchors: JsxStructureAnchor[] } | { status: 'blocked'; diagnostics: JsxStructureDiagnostic[] }>; /** Maps exact own-source stamps plus captured CSS-module ownership to explicit host style declarations. */ export declare function mapCapturedStyleTargets(input: { document: import('./dist-lib/types/document/contracts.js').DesignDocument; sourceInputs: Readonly>; declarations: readonly { componentFile: string; file: string; className: string; /** Exact module specifier when the host uses an alias; relative imports resolve without this field. */ importPath?: string; /** Text editing targets the sole direct text child; nested or mixed content is not projected. */ target?: 'element' | 'text-content'; field: import('./dist-lib/types/workspace/source/contracts.js').WorkspaceVisualSourceField; property: string; encoding: 'css-length' | 'number' | 'string'; permittedValues?: readonly (string | number)[]; affectedFrames: readonly import('./dist-lib/types/editor/inspect.js').SourceAffectedFrame[]; }[]; }): import('./dist-lib/types/workspace/source/contracts.js').WorkspaceVisualSourceRule[];