@echothink-ui/layout 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +92 -0
  2. package/dist/index.cjs +1620 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.css +149 -0
  5. package/dist/index.css.map +1 -0
  6. package/dist/index.d.ts +24 -0
  7. package/dist/index.js +1546 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/layout-system/builders.d.ts +13 -0
  10. package/dist/layout-system/index.d.ts +24 -0
  11. package/dist/layout-system/inference/context.d.ts +33 -0
  12. package/dist/layout-system/inference/responsive.d.ts +21 -0
  13. package/dist/layout-system/inference/style.d.ts +15 -0
  14. package/dist/layout-system/page-layouts/index.d.ts +8 -0
  15. package/dist/layout-system/primitives/index.d.ts +6 -0
  16. package/dist/layout-system/regions/index.d.ts +4 -0
  17. package/dist/layout-system/registry/builtins.d.ts +8 -0
  18. package/dist/layout-system/registry/registry.d.ts +20 -0
  19. package/dist/layout-system/renderer/context.d.ts +41 -0
  20. package/dist/layout-system/renderer/region.d.ts +10 -0
  21. package/dist/layout-system/renderer/renderer.d.ts +13 -0
  22. package/dist/layout-system/renderer/root.d.ts +24 -0
  23. package/dist/layout-system/runtime/state.d.ts +17 -0
  24. package/dist/layout-system/runtime/viewport.d.ts +9 -0
  25. package/dist/layout-system/schema/types.d.ts +488 -0
  26. package/dist/layout-system/schema/validate.d.ts +15 -0
  27. package/dist/layout-system/tokens/preset-tokens.d.ts +11 -0
  28. package/package.json +47 -0
  29. package/src/index.tsx +42 -0
  30. package/src/layout-system/__tests__/layout-system.test.tsx +169 -0
  31. package/src/layout-system/builders.ts +46 -0
  32. package/src/layout-system/index.ts +87 -0
  33. package/src/layout-system/inference/context.ts +158 -0
  34. package/src/layout-system/inference/responsive.ts +147 -0
  35. package/src/layout-system/inference/style.ts +128 -0
  36. package/src/layout-system/page-layouts/index.tsx +405 -0
  37. package/src/layout-system/primitives/index.tsx +266 -0
  38. package/src/layout-system/regions/index.tsx +90 -0
  39. package/src/layout-system/registry/builtins.ts +19 -0
  40. package/src/layout-system/registry/registry.ts +47 -0
  41. package/src/layout-system/renderer/context.tsx +89 -0
  42. package/src/layout-system/renderer/region.tsx +34 -0
  43. package/src/layout-system/renderer/renderer.tsx +200 -0
  44. package/src/layout-system/renderer/root.tsx +95 -0
  45. package/src/layout-system/runtime/state.ts +80 -0
  46. package/src/layout-system/runtime/viewport.ts +71 -0
  47. package/src/layout-system/schema/types.ts +706 -0
  48. package/src/layout-system/schema/validate.ts +168 -0
  49. package/src/layout-system/tokens/preset-tokens.ts +77 -0
  50. package/src/styles.css +178 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx","../src/layout-system/schema/validate.ts","../src/layout-system/tokens/preset-tokens.ts","../src/layout-system/inference/style.ts","../src/layout-system/inference/context.ts","../src/layout-system/inference/responsive.ts","../src/layout-system/registry/registry.ts","../src/layout-system/primitives/index.tsx","../src/layout-system/renderer/renderer.tsx","../src/layout-system/renderer/context.tsx","../src/layout-system/runtime/state.ts","../src/layout-system/renderer/region.tsx","../src/layout-system/regions/index.tsx","../src/layout-system/page-layouts/index.tsx","../src/layout-system/registry/builtins.ts","../src/layout-system/runtime/viewport.ts","../src/layout-system/renderer/root.tsx","../src/layout-system/builders.ts"],"sourcesContent":["/**\n * `@echothink-ui/layout` — public API.\n *\n * This package is the LAYOUT SYSTEM (layout-spec.md), not a template collection.\n * The former hard-coded page templates moved to `@echothink-ui/templates`; the\n * former preset-preview helpers are retired. Consumers now build pages as a\n * typed `LayoutNode` AST and render them through `LayoutRoot`.\n */\nimport \"./styles.css\";\n\n// Re-export the style axes for convenience (preset/density/typeScale + StyleScope).\nexport {\n StyleScope,\n defaultStylePreset,\n ethDensityModes,\n ethStylePresetDescriptions,\n ethStylePresetLabels,\n ethStylePresets,\n ethTypeScales,\n} from \"@echothink-ui/style\";\nexport type {\n EthStylePreset,\n EthDensityMode,\n EthTypeScale,\n EthPalette,\n} from \"@echothink-ui/style\";\n\n/**\n * Documented breakpoint contract (rem). CSS media queries can't read custom\n * properties, so these literal values are mirrored in `styles.css` and the\n * viewport observer.\n */\nexport const ethBreakpoints = {\n sm: \"36rem\",\n md: \"48rem\",\n lg: \"64rem\",\n xl: \"80rem\",\n} as const;\nexport type EthBreakpoint = keyof typeof ethBreakpoints;\n\n// The layout system.\nexport * from \"./layout-system/index.js\";\n","/**\n * Layout validation (`layout-spec.md` §16, §20).\n *\n * Hand-written structural + semantic validation that walks a `LayoutNode`\n * against a registry and emits `LayoutDiagnostic[]`. (zod can be layered on top\n * later for untrusted JSON; kept dependency-free here.)\n */\nimport type {\n LayoutDiagnostic,\n LayoutNode,\n NodeAcceptSpec,\n SlotContent,\n SlotDefinition,\n} from \"./types.js\";\nimport type { LayoutRegistry } from \"../registry/registry.js\";\n\nconst DEFAULT_MAX_DEPTH = 8;\n\nfunction acceptsContent(accepts: NodeAcceptSpec[], content: SlotContent): boolean {\n return accepts.some((spec) => {\n switch (content.kind) {\n case \"component\":\n return (\n spec.kind === \"component\" &&\n (!spec.componentTypes || spec.componentTypes.includes(content.component))\n );\n case \"layout\":\n return (\n spec.kind === \"layout\" &&\n (!spec.layoutTypes || spec.layoutTypes.includes(content.layout.type))\n );\n case \"template\":\n return (\n spec.kind === \"template\" &&\n (!spec.templateTypes || spec.templateTypes.includes(content.template))\n );\n case \"fragment\":\n return spec.kind === \"fragment\";\n case \"empty\":\n return spec.kind === \"empty\";\n default:\n return false;\n }\n });\n}\n\nfunction* childLayouts(content: SlotContent): Generator<LayoutNode> {\n if (content.kind === \"layout\") {\n yield content.layout;\n } else if (content.kind === \"fragment\") {\n for (const item of content.items) yield* childLayouts(item);\n }\n}\n\nexport interface ValidateOptions {\n maxDepth?: number;\n}\n\n/** Validate a layout tree, returning diagnostics (empty ⇒ valid). */\nexport function validateLayout(\n root: LayoutNode,\n registry: LayoutRegistry,\n opts: ValidateOptions = {},\n): LayoutDiagnostic[] {\n const diagnostics: LayoutDiagnostic[] = [];\n const maxDepth = opts.maxDepth ?? DEFAULT_MAX_DEPTH;\n const visiting = new Set<string>();\n\n function walk(node: LayoutNode, path: string[], depth: number): void {\n const nodePath = [...path, node.id];\n\n if (depth > maxDepth) {\n diagnostics.push({\n level: \"error\",\n code: \"MAX_DEPTH_EXCEEDED\",\n path: nodePath,\n message: `Layout nesting exceeds maxDepth=${maxDepth}.`,\n });\n return;\n }\n\n if (visiting.has(node.id)) {\n diagnostics.push({\n level: \"error\",\n code: \"CYCLE_DETECTED\",\n path: nodePath,\n message: `Cycle detected at node \"${node.id}\".`,\n });\n return;\n }\n visiting.add(node.id);\n\n const item = registry.get(node.type);\n if (!item) {\n diagnostics.push({\n level: \"error\",\n code: \"UNKNOWN_LAYOUT_TYPE\",\n path: nodePath,\n message: `Unknown layout type \"${node.type}\".`,\n suggestion: `Register \"${node.type}\" or use one of: ${registry.types().slice(0, 8).join(\", \")}…`,\n });\n visiting.delete(node.id);\n return;\n }\n\n const slotByName = new Map<string, SlotDefinition>(\n item.slots.map((s) => [s.name, s]),\n );\n\n // Unknown slots present on the node.\n for (const slotName of Object.keys(node.slots)) {\n if (!slotByName.has(slotName)) {\n diagnostics.push({\n level: \"warning\",\n code: \"UNKNOWN_SLOT\",\n path: [...nodePath, slotName],\n message: `Slot \"${slotName}\" is not declared by \"${node.type}\".`,\n });\n }\n }\n\n // Required slots + accepts + cardinality.\n for (const slot of item.slots) {\n const content = node.slots[slot.name];\n if (content === undefined) {\n if (slot.required && !slot.fallback?.empty) {\n diagnostics.push({\n level: \"error\",\n code: \"SLOT_REQUIRED\",\n path: [...nodePath, slot.name],\n message: `Required slot \"${slot.name}\" of \"${node.type}\" has no content or fallback.`,\n });\n }\n continue;\n }\n if (!acceptsContent(slot.accepts, content)) {\n diagnostics.push({\n level: \"error\",\n code: \"SLOT_ACCEPTS_VIOLATION\",\n path: [...nodePath, slot.name],\n message: `Slot \"${slot.name}\" of \"${node.type}\" does not accept ${content.kind} content.`,\n });\n }\n if (content.kind === \"fragment\" && slot.cardinality?.max && slot.cardinality.max !== \"unbounded\") {\n if (content.items.length > slot.cardinality.max) {\n diagnostics.push({\n level: \"error\",\n code: \"SLOT_CARDINALITY_VIOLATION\",\n path: [...nodePath, slot.name],\n message: `Slot \"${slot.name}\" allows at most ${slot.cardinality.max} items.`,\n });\n }\n }\n for (const child of childLayouts(content)) {\n walk(child, [...nodePath, slot.name], depth + 1);\n }\n }\n\n visiting.delete(node.id);\n }\n\n walk(root, [], 0);\n return diagnostics;\n}\n\nexport function hasErrors(diagnostics: LayoutDiagnostic[]): boolean {\n return diagnostics.some((d) => d.level === \"error\");\n}\n","/**\n * Preset → Tier-2 token map (`layout-spec.md` §13.2).\n *\n * Per TOKEN_CONTRACT.md every value is a Tier-2 `--eth-*` CSS variable; presets\n * override Tier-2, layout never reads raw `--cds-*`. These resolve through the\n * `@echothink-ui/style` preset stylesheets that are already on the page.\n */\nimport type {\n ComponentStyleParams,\n ResolvedLayoutTokens,\n StylePresetTokenMap,\n} from \"../schema/types.js\";\n\nexport const presetTokenMap: StylePresetTokenMap = {\n \"carbon-like\": {\n surface: \"var(--eth-surface, var(--eth-color-surface))\",\n surfaceMuted: \"var(--eth-surface-muted, var(--eth-color-surface-muted))\",\n border: \"var(--eth-border-subtle, var(--eth-color-border))\",\n text: \"var(--eth-text-primary, var(--eth-color-text))\",\n textMuted: \"var(--eth-text-secondary, var(--eth-color-text-secondary))\",\n accent: \"var(--eth-accent, var(--eth-color-accent))\",\n radius: \"var(--eth-radius-sm, 0.125rem)\",\n shadow: \"var(--eth-shadow-none, none)\",\n },\n \"soft-card\": {\n surface: \"var(--eth-surface, var(--eth-color-surface))\",\n surfaceMuted: \"var(--eth-surface-muted, var(--eth-color-surface-muted))\",\n border: \"var(--eth-border-soft, var(--eth-color-border))\",\n text: \"var(--eth-text-primary, var(--eth-color-text))\",\n textMuted: \"var(--eth-text-secondary, var(--eth-color-text-secondary))\",\n accent: \"var(--eth-accent, var(--eth-color-accent))\",\n radius: \"var(--eth-radius-lg, 0.75rem)\",\n shadow: \"var(--eth-shadow-card, 0 1px 2px rgba(15,23,42,0.08))\",\n },\n glass: {\n surface: \"var(--eth-surface-glass, var(--eth-color-surface))\",\n surfaceMuted: \"var(--eth-surface-glass-muted, var(--eth-color-surface-muted))\",\n border: \"var(--eth-border-glass, var(--eth-color-border))\",\n text: \"var(--eth-text-on-glass, var(--eth-color-text))\",\n textMuted: \"var(--eth-text-on-glass-muted, var(--eth-color-text-secondary))\",\n accent: \"var(--eth-accent, var(--eth-color-accent))\",\n radius: \"var(--eth-radius-xl, 1rem)\",\n shadow: \"var(--eth-shadow-floating, 0 8px 32px rgba(15,23,42,0.18))\",\n backdrop: \"blur(16px)\",\n },\n bright: {\n surface: \"var(--eth-surface, var(--eth-color-surface))\",\n surfaceMuted: \"var(--eth-surface-muted, var(--eth-color-surface-muted))\",\n border: \"var(--eth-border-bright, var(--eth-color-border))\",\n text: \"var(--eth-text-primary, var(--eth-color-text))\",\n textMuted: \"var(--eth-text-secondary, var(--eth-color-text-secondary))\",\n accent: \"var(--eth-accent, var(--eth-color-accent))\",\n radius: \"var(--eth-radius-md, 0.5rem)\",\n shadow: \"var(--eth-shadow-sm, 0 1px 2px rgba(15,23,42,0.06))\",\n },\n \"studio-dark\": {\n surface: \"var(--eth-surface-studio, var(--eth-color-surface))\",\n surfaceMuted: \"var(--eth-surface-studio-muted, var(--eth-color-surface-muted))\",\n border: \"var(--eth-border-studio, var(--eth-color-border))\",\n text: \"var(--eth-text-on-dark, var(--eth-color-text))\",\n textMuted: \"var(--eth-text-on-dark-muted, var(--eth-color-text-secondary))\",\n accent: \"var(--eth-accent, var(--eth-color-accent))\",\n radius: \"var(--eth-radius-sm, 0.125rem)\",\n shadow: \"var(--eth-shadow-none, none)\",\n },\n};\n\nconst densityGap: Record<ComponentStyleParams[\"density\"], string> = {\n compact: \"var(--eth-space-sm, 0.5rem)\",\n standard: \"var(--eth-space-md, 0.75rem)\",\n comfortable: \"var(--eth-space-lg, 1rem)\",\n};\n\n/** Resolve the token set for a final `ComponentStyleParams`. */\nexport function resolveTokens(style: ComponentStyleParams): ResolvedLayoutTokens {\n return { ...presetTokenMap[style.preset], gap: densityGap[style.density] };\n}\n","/**\n * Component style inference (`layout-spec.md` §7).\n *\n * Components do NOT pick their own preset/density/typeScale. The engine infers\n * `ComponentStyleParams` from the layout runtime context using a scoring\n * resolver for `preset` plus rule tables for `density` and `typeScale`.\n */\nimport type {\n ComponentDensity,\n ComponentStyleParams,\n ComponentStylePreset,\n ComponentTypeScale,\n StyleInferenceInput,\n} from \"../schema/types.js\";\n\nexport const defaultComponentStyle: ComponentStyleParams = {\n preset: \"carbon-like\",\n palette: \"default\",\n density: \"standard\",\n typeScale: \"standard\",\n};\n\nfunction matches(value: string | undefined, candidates: string[]): boolean {\n if (!value) return false;\n return candidates.some((c) => value === c || value.endsWith(`.${c}`) || value.includes(c));\n}\n\nfunction chooseHighestScore(\n scores: Record<ComponentStylePreset, number>,\n fallback: ComponentStylePreset,\n): ComponentStylePreset {\n let best: ComponentStylePreset = fallback;\n let bestScore = -Infinity;\n // Deterministic: iterate in a fixed key order.\n const order: ComponentStylePreset[] = [\n \"carbon-like\",\n \"soft-card\",\n \"glass\",\n \"bright\",\n \"studio-dark\",\n ];\n for (const key of order) {\n if (scores[key] > bestScore) {\n bestScore = scores[key];\n best = key;\n }\n }\n return bestScore <= 0 ? fallback : best;\n}\n\n/** §7.4 density rules. */\nexport function inferDensity(input: StyleInferenceInput): ComponentDensity {\n if (input.explicit?.density) return input.explicit.density;\n const role = input.slotRole;\n if (input.dataIntensity === \"high\" || input.dataIntensity === \"realtime\") return \"compact\";\n if (\n matches(role, [\"console\", \"timeline\", \"filter\", \"toolbar\", \"navigation\"]) ||\n matches(input.layoutType, [\"DataGridInspector\", \"MonitoringOps\"])\n ) {\n return \"compact\";\n }\n if (input.visualEmphasis === \"expressive\" || input.visualEmphasis === \"immersive\") {\n return \"comfortable\";\n }\n if (matches(role, [\"form\", \"inspector\", \"summary\", \"content\", \"preview\"])) return \"standard\";\n if (input.taskMode === \"wizard\" || input.taskMode === \"copilot\") return \"comfortable\";\n if (input.breakpoint === \"mobile\" && input.parent?.density === \"compact\") return \"standard\";\n return input.parent?.density ?? \"standard\";\n}\n\n/** §7.5 typeScale rules. */\nexport function inferTypeScale(input: StyleInferenceInput): ComponentTypeScale {\n if (input.explicit?.typeScale) return input.explicit.typeScale;\n const role = input.slotRole;\n if (typeof input.containerWidth === \"number\" && input.containerWidth < 360) return \"compact\";\n if (matches(role, [\"toolbar\", \"navigation\", \"console\", \"timeline\"])) return \"compact\";\n if (matches(input.layoutType, [\"DataGridInspector\", \"MonitoringOps\"])) return \"compact\";\n if (input.taskMode === \"wizard\" || matches(role, [\"summary\", \"emptyState\"])) return \"large\";\n if (input.breakpoint === \"mobile\") return \"standard\";\n if (matches(role, [\"form\", \"inspector\", \"content\", \"preview\"])) return \"standard\";\n return input.parent?.typeScale ?? \"standard\";\n}\n\n/** §7.6 scoring preset resolver. */\nexport function inferComponentStyle(input: StyleInferenceInput): ComponentStyleParams {\n const presetScores: Record<ComponentStylePreset, number> = {\n \"carbon-like\": 0,\n \"soft-card\": 0,\n glass: 0,\n bright: 0,\n \"studio-dark\": 0,\n };\n\n if (matches(input.layoutType, [\"AdminShell\", \"DataGridInspector\", \"SettingsConsole\"])) {\n presetScores[\"carbon-like\"] += 4;\n }\n if (matches(input.layoutType, [\"DashboardBento\", \"SearchCatalog\"])) {\n presetScores[\"soft-card\"] += 4;\n }\n if (matches(input.layoutType, [\"SpatialHud\"]) || input.surface === \"floating\") {\n presetScores.glass += 4;\n }\n if (matches(input.layoutType, [\"WizardComposer\"]) || input.taskMode === \"wizard\") {\n presetScores.bright += 4;\n }\n if (\n matches(input.layoutType, [\"Workbench\", \"CanvasInspector\", \"MonitoringOps\", \"Playground\"]) ||\n matches(input.slotRole, [\"console\", \"canvas\", \"timeline\"])\n ) {\n presetScores[\"studio-dark\"] += 4;\n }\n\n // Deep nested form/filter/inspector → bias toward stable carbon.\n if (input.depth >= 2 && matches(input.slotRole, [\"form\", \"filter\", \"inspector\"])) {\n presetScores[\"carbon-like\"] += 2;\n }\n\n const preset =\n input.explicit?.preset ??\n chooseHighestScore(presetScores, input.parent?.preset ?? defaultComponentStyle.preset);\n\n return {\n preset,\n palette: input.explicit?.palette ?? input.parent?.palette ?? \"default\",\n density: inferDensity(input),\n typeScale: inferTypeScale(input),\n };\n}\n","/**\n * Context propagation (`layout-spec.md` §6, §8).\n *\n * Builds the root `LayoutRuntimeContext` and composes a child context for each\n * slot: it derives the child surface/taskMode/etc. and runs `inferComponentStyle`\n * so the descendant components receive consistent, inferred style params.\n */\nimport type {\n ComponentStyleParams,\n ContextPolicy,\n LayoutNode,\n LayoutRuntimeContext,\n LayoutViewport,\n SlotContent,\n SlotDefinition,\n StyleInferenceInput,\n SurfaceRole,\n} from \"../schema/types.js\";\nimport { defaultComponentStyle, inferComponentStyle } from \"./style.js\";\nimport { resolveTokens } from \"../tokens/preset-tokens.js\";\n\nexport const defaultContextPolicy: ContextPolicy = {\n inheritStyle: true,\n inheritDensity: true,\n inheritTypeScale: true,\n inheritSurface: false,\n isolateState: false,\n isolateScroll: true,\n allowComponentOverride: true,\n maxDepth: 8,\n};\n\nexport const defaultViewport: LayoutViewport = {\n breakpoint: \"desktop\",\n width: 1440,\n height: 900,\n pointer: \"fine\",\n colorScheme: \"light\",\n};\n\nexport interface RootContextInput {\n viewport?: Partial<LayoutViewport>;\n surface?: SurfaceRole;\n style?: Partial<ComponentStyleParams>;\n route?: LayoutRuntimeContext[\"route\"];\n permissions?: string[];\n}\n\n/** Build the top-level context an app mounts the renderer with. */\nexport function createRootContext(input: RootContextInput = {}): LayoutRuntimeContext {\n const viewport: LayoutViewport = { ...defaultViewport, ...input.viewport };\n const componentStyle: ComponentStyleParams = {\n ...defaultComponentStyle,\n ...input.style,\n };\n return {\n path: [],\n depth: 0,\n ancestry: [],\n viewport,\n container: { width: viewport.width, height: viewport.height },\n route: input.route,\n surface: input.surface ?? \"app\",\n componentStyle,\n tokens: resolveTokens(componentStyle),\n stateScope: \"session\",\n permissions: input.permissions ? { granted: new Set(input.permissions) } : undefined,\n };\n}\n\nfunction inferChildSurface(\n parent: LayoutRuntimeContext,\n node: LayoutNode,\n slot: SlotDefinition,\n): SurfaceRole {\n return (\n slot.contextTransform?.surface ??\n node.styleIntent?.surface ??\n (parent.surface === \"app\" ? \"page\" : parent.surface)\n );\n}\n\n/** §7.1 — assemble the inference input from parent context + node + slot. */\nexport function buildStyleInferenceInput(args: {\n parent: LayoutRuntimeContext;\n node: LayoutNode;\n slot: SlotDefinition;\n content: SlotContent;\n}): StyleInferenceInput {\n const { parent, node, slot, content } = args;\n const surface = inferChildSurface(parent, node, slot);\n const explicit: Partial<ComponentStyleParams> = {\n ...node.styleIntent,\n ...slot.contextTransform?.styleIntent,\n ...(slot.contextTransform?.densityHint ? { density: slot.contextTransform.densityHint } : {}),\n ...(slot.contextTransform?.typeScaleHint ? { typeScale: slot.contextTransform.typeScaleHint } : {}),\n ...(content.kind === \"component\" ? content.styleOverride : undefined),\n };\n return {\n parent: parent.componentStyle,\n explicit,\n layoutType: node.type,\n layoutTier: node.tier,\n layoutVariant: node.variant,\n surface,\n slotRole: slot.role,\n taskMode: node.styleIntent?.taskMode ?? parent.taskMode,\n dataIntensity: node.styleIntent?.dataIntensity ?? parent.dataIntensity,\n interactionMode: node.styleIntent?.interactionMode ?? parent.interactionMode,\n visualEmphasis: node.styleIntent?.visualEmphasis ?? parent.visualEmphasis,\n depth: parent.depth + 1,\n breakpoint: parent.viewport.breakpoint,\n containerWidth: parent.container.width,\n };\n}\n\n/** §8.1 — compose the child runtime context for a slot. */\nexport function composeLayoutContext(args: {\n parent: LayoutRuntimeContext;\n node: LayoutNode;\n slot: SlotDefinition;\n content: SlotContent;\n}): LayoutRuntimeContext {\n const { parent, node, slot, content } = args;\n const styleInput = buildStyleInferenceInput(args);\n const componentStyle = inferComponentStyle(styleInput);\n const surface = styleInput.surface;\n\n return {\n ...parent,\n path: [...parent.path, node.id, slot.name],\n depth: parent.depth + 1,\n ancestry: [\n ...parent.ancestry,\n {\n id: node.id,\n type: node.type,\n tier: node.tier,\n surface: node.styleIntent?.surface,\n slotRole: slot.role,\n },\n ],\n slot: {\n name: slot.name,\n role: slot.role,\n priority: slot.priority?.value,\n surface: slot.contextTransform?.surface,\n },\n surface,\n taskMode: node.styleIntent?.taskMode ?? parent.taskMode,\n dataIntensity: node.styleIntent?.dataIntensity ?? parent.dataIntensity,\n interactionMode: node.styleIntent?.interactionMode ?? parent.interactionMode,\n visualEmphasis: node.styleIntent?.visualEmphasis ?? parent.visualEmphasis,\n componentStyle,\n tokens: resolveTokens(componentStyle),\n stateScope: node.state?.scope ?? parent.stateScope,\n };\n}\n","/**\n * Responsive physical plan (`layout-spec.md` §10).\n *\n * Maps a logical layout node + its registry slot definitions + the viewport (and\n * optional user collapse/pin state) to a `PhysicalLayoutPlan` describing each\n * slot's placement, visibility and collapse. Page-layout renderers consume the\n * plan so the same AST yields different desktop/tablet/mobile arrangements.\n */\nimport type {\n Breakpoint,\n LayoutNode,\n LayoutRegistryItem,\n LayoutViewport,\n PersistedLayoutState,\n PhysicalLayoutPlan,\n PhysicalRegion,\n SlotDefinition,\n SlotRole,\n} from \"../schema/types.js\";\n\nconst BREAKPOINT_ORDER: Breakpoint[] = [\n \"mobile\",\n \"tablet\",\n \"laptop\",\n \"desktop\",\n \"wide\",\n \"ultra\",\n];\n\nexport function breakpointRank(bp: Breakpoint): number {\n return BREAKPOINT_ORDER.indexOf(bp);\n}\n\nexport function isNarrow(bp: Breakpoint): boolean {\n return breakpointRank(bp) <= breakpointRank(\"tablet\");\n}\n\nconst PLACEMENT_BY_ROLE: Partial<Record<SlotRole, PhysicalRegion[\"placement\"]>> = {\n navigation: \"inline-start\",\n filter: \"inline-start\",\n inspector: \"inline-end\",\n secondary: \"inline-end\",\n toolbar: \"block-start\",\n search: \"block-start\",\n status: \"block-start\",\n console: \"block-end\",\n footer: \"block-end\",\n timeline: \"block-end\",\n summary: \"inline-end\",\n preview: \"inline-end\",\n drawer: \"overlay\",\n modal: \"overlay\",\n overlay: \"overlay\",\n};\n\nfunction placementFor(slot: SlotDefinition): PhysicalRegion[\"placement\"] {\n return PLACEMENT_BY_ROLE[slot.role] ?? \"center\";\n}\n\nexport interface ResolvePlanInput {\n node: LayoutNode;\n item: LayoutRegistryItem;\n viewport: LayoutViewport;\n state?: PersistedLayoutState;\n}\n\n/** Compute the physical plan for a single layout node. */\nexport function resolvePhysicalPlan(input: ResolvePlanInput): PhysicalLayoutPlan {\n const { node, item, viewport, state } = input;\n const narrow = isNarrow(viewport.breakpoint);\n const bpRank = breakpointRank(viewport.breakpoint);\n\n const regions: PhysicalRegion[] = item.slots.map((slot) => {\n const present = node.slots[slot.name] !== undefined;\n const persisted = state?.panels?.[slot.name];\n const placement = placementFor(slot);\n\n let visible = present;\n let collapsed = persisted?.collapsed ?? false;\n let layer: PhysicalRegion[\"layer\"] | undefined;\n let regionPlacement = placement;\n\n // Apply responsive slot policy.\n if (slot.responsive?.hideBelow && bpRank < breakpointRank(slot.responsive.hideBelow)) {\n visible = false;\n }\n if (slot.responsive?.collapseBelow && bpRank < breakpointRank(slot.responsive.collapseBelow)) {\n collapsed = true;\n }\n\n // Apply narrow-screen behavior from slot priority (never drop a required\n // primary/content slot — demote supporting panes to drawers/sheets instead).\n if (narrow && slot.priority) {\n switch (slot.priority.behaviorOnNarrow) {\n case \"collapse\":\n collapsed = true;\n break;\n case \"hide\":\n if (!slot.required) visible = false;\n break;\n case \"move-to-drawer\":\n regionPlacement = \"overlay\";\n layer = \"drawer\";\n break;\n case \"move-to-bottom-sheet\":\n regionPlacement = \"overlay\";\n layer = \"sheet\";\n break;\n case \"route-stack\":\n case \"tabs\":\n case \"keep\":\n default:\n break;\n }\n }\n\n return {\n slot: slot.name,\n placement: regionPlacement,\n visible,\n collapsed,\n mounted: present,\n layer,\n size: persisted?.width\n ? { width: persisted.width }\n : persisted?.height\n ? { height: persisted.height }\n : undefined,\n };\n });\n\n const mode: PhysicalLayoutPlan[\"mode\"] = narrow\n ? regions.some((r) => r.layer === \"drawer\" || r.layer === \"sheet\")\n ? \"drawer-assisted\"\n : \"single-pane\"\n : \"multi-pane\";\n\n return { layoutId: node.id, mode, regions };\n}\n\n/** Convenience: get the region for a slot from a plan. */\nexport function regionFor(\n plan: PhysicalLayoutPlan,\n slot: string,\n): PhysicalRegion | undefined {\n return plan.regions.find((r) => r.slot === slot);\n}\n","/**\n * Layout registry (`layout-spec.md` §9).\n *\n * Maps a layout `type` (e.g. \"PageLayout.Workbench\") to its `LayoutRegistryItem`\n * (slots, renderer, default composition/style intent). The recursive renderer\n * and the validator consult it; it is also the source the builder/copilot read\n * to discover available layouts and their slot contracts.\n */\nimport type { LayoutRegistryItem } from \"../schema/types.js\";\n\nexport class LayoutRegistry {\n private readonly items = new Map<string, LayoutRegistryItem>();\n\n register(item: LayoutRegistryItem): this {\n this.items.set(item.type, item);\n return this;\n }\n\n registerAll(items: readonly LayoutRegistryItem[]): this {\n for (const item of items) this.register(item);\n return this;\n }\n\n get(type: string): LayoutRegistryItem | undefined {\n return this.items.get(type);\n }\n\n has(type: string): boolean {\n return this.items.has(type);\n }\n\n list(): LayoutRegistryItem[] {\n return [...this.items.values()];\n }\n\n types(): string[] {\n return [...this.items.keys()];\n }\n\n byTier(tier: LayoutRegistryItem[\"tier\"]): LayoutRegistryItem[] {\n return this.list().filter((i) => i.tier === tier);\n }\n\n byCategory(category: LayoutRegistryItem[\"category\"]): LayoutRegistryItem[] {\n return this.list().filter((i) => i.category === category);\n }\n}\n","/**\n * Layout primitives (`layout-spec.md` §14, §19): Panel, SplitPane, Tabs, Stepper.\n *\n * Each is a `LayoutRegistryItem` whose renderer arranges the engine-rendered\n * `slots` map. Tabs/Stepper read their `composition` and render inline content\n * via `SlotContentRenderer`, carrying a11y semantics (§12).\n */\nimport * as React from \"react\";\nimport type {\n LayoutRegistryItem,\n LayoutRendererProps,\n ParallelComposition,\n StepperComposition,\n SwitchComposition,\n} from \"../schema/types.js\";\nimport { SlotContentRenderer } from \"../renderer/renderer.js\";\nimport { inlineSlot } from \"../renderer/region.js\";\n\n/* ----------------------------- Panel ----------------------------- */\n\nfunction PanelRenderer({ slots, context }: LayoutRendererProps) {\n return (\n <section\n className=\"eth-ls-panel\"\n style={{\n background: context.tokens.surface,\n border: `1px solid ${context.tokens.border}`,\n borderRadius: context.tokens.radius,\n boxShadow: context.tokens.shadow,\n color: context.tokens.text,\n }}\n >\n {slots.header ? <header className=\"eth-ls-panel__header\">{slots.header}</header> : null}\n <div className=\"eth-ls-panel__body\">{slots.body}</div>\n {slots.footer ? <footer className=\"eth-ls-panel__footer\">{slots.footer}</footer> : null}\n </section>\n );\n}\n\nexport const PanelLayout: LayoutRegistryItem = {\n type: \"Primitive.Panel\",\n displayName: \"Panel\",\n tier: \"primitive\",\n category: \"primitive\",\n description: \"A bounded surface with optional header/body/footer.\",\n slots: [\n { name: \"header\", role: \"toolbar\", accepts: [{ kind: \"component\" }, { kind: \"fragment\" }] },\n {\n name: \"body\",\n role: \"content\",\n required: true,\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }],\n },\n { name: \"footer\", role: \"footer\", accepts: [{ kind: \"component\" }, { kind: \"fragment\" }] },\n ],\n defaultStyleIntent: { surface: \"panel\" },\n renderer: PanelRenderer,\n};\n\n/* --------------------------- SplitPane --------------------------- */\n\nfunction SplitPaneRenderer({ slots, context, composition, variant }: LayoutRendererProps) {\n const orientation = variant === \"vertical\" ? \"vertical\" : \"horizontal\";\n const parallel = composition?.op === \"parallel\" ? (composition as ParallelComposition) : undefined;\n const primaryBasis = parallel?.sizing?.primary?.basis;\n return (\n <div\n className={`eth-ls-split eth-ls-split--${orientation}`}\n style={{\n display: \"grid\",\n gap: parallel?.gapToken ? `var(${parallel.gapToken})` : context.tokens.gap,\n gridTemplateColumns:\n orientation === \"horizontal\"\n ? `${primaryBasis ? cssSize(primaryBasis) : \"1fr\"} 1fr`\n : undefined,\n gridTemplateRows: orientation === \"vertical\" ? `${primaryBasis ? cssSize(primaryBasis) : \"1fr\"} 1fr` : undefined,\n height: \"100%\",\n minHeight: 0,\n }}\n >\n <div className=\"eth-ls-split__pane eth-ls-split__pane--primary\" style={{ minWidth: 0, minHeight: 0 }}>\n {slots.primary}\n </div>\n <div\n className=\"eth-ls-split__pane eth-ls-split__pane--secondary\"\n role=\"separator\"\n aria-orientation={orientation}\n style={{ minWidth: 0, minHeight: 0 }}\n >\n {slots.secondary}\n </div>\n </div>\n );\n}\n\nfunction cssSize(value: number | string): string {\n return typeof value === \"number\" ? `${value}px` : value;\n}\n\nexport const SplitPaneLayout: LayoutRegistryItem = {\n type: \"Primitive.SplitPane\",\n displayName: \"Split Pane\",\n tier: \"primitive\",\n category: \"primitive\",\n description: \"Two resizable panes split horizontally or vertically.\",\n variants: [\n { id: \"horizontal\", label: \"Left / Right\" },\n { id: \"vertical\", label: \"Top / Bottom\" },\n ],\n slots: [\n {\n name: \"primary\",\n role: \"primary\",\n required: true,\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"template\" }, { kind: \"fragment\" }],\n },\n {\n name: \"secondary\",\n role: \"secondary\",\n required: true,\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"template\" }, { kind: \"fragment\" }],\n },\n ],\n defaultComposition: {\n op: \"parallel\",\n axis: \"x\",\n slots: [\"primary\", \"secondary\"],\n sizing: { primary: { basis: \"1fr\", resizable: true }, secondary: { grow: 1 } },\n },\n renderer: SplitPaneRenderer,\n};\n\n/* ----------------------------- Tabs ------------------------------ */\n\nfunction TabsRenderer({ node, context, composition }: LayoutRendererProps) {\n const switchSpec =\n composition?.op === \"switch\" ? (composition as SwitchComposition) : undefined;\n const items = switchSpec?.items ?? [];\n const initial = switchSpec?.activeKey ?? items[0]?.key;\n const [active, setActive] = React.useState<string | undefined>(initial);\n const activeItem = items.find((i) => i.key === active) ?? items[0];\n\n return (\n <div className=\"eth-ls-tabs\" style={{ color: context.tokens.text }}>\n <div className=\"eth-ls-tabs__list\" role=\"tablist\">\n {items.map((item) => {\n const selected = item.key === activeItem?.key;\n return (\n <button\n key={item.key}\n type=\"button\"\n role=\"tab\"\n id={`tab-${node.id}-${item.key}`}\n aria-selected={selected}\n aria-controls={`tabpanel-${node.id}-${item.key}`}\n tabIndex={selected ? 0 : -1}\n className={`eth-ls-tabs__tab${selected ? \" eth-ls-tabs__tab--active\" : \"\"}`}\n onClick={() => setActive(item.key)}\n >\n {item.label}\n </button>\n );\n })}\n </div>\n {activeItem ? (\n <div\n className=\"eth-ls-tabs__panel\"\n role=\"tabpanel\"\n id={`tabpanel-${node.id}-${activeItem.key}`}\n aria-labelledby={`tab-${node.id}-${activeItem.key}`}\n >\n <SlotContentRenderer\n node={node}\n slot={inlineSlot(`tab:${activeItem.key}`, \"content\")}\n content={activeItem.content}\n parentContext={context}\n />\n </div>\n ) : null}\n </div>\n );\n}\n\nexport const TabsLayout: LayoutRegistryItem = {\n type: \"Primitive.Tabs\",\n displayName: \"Tabs\",\n tier: \"primitive\",\n category: \"primitive\",\n description: \"Switch composition rendering one panel at a time with tablist semantics.\",\n slots: [],\n defaultComposition: { op: \"switch\", mode: \"tabs\", items: [] },\n renderer: TabsRenderer,\n};\n\n/* ---------------------------- Stepper ---------------------------- */\n\nfunction StepperRenderer({ node, context, composition }: LayoutRendererProps) {\n const stepper =\n composition?.op === \"stepper\" ? (composition as StepperComposition) : undefined;\n const steps = stepper?.steps ?? [];\n const firstActive = steps.findIndex((s) => s.status === \"active\");\n const [activeIndex, setActiveIndex] = React.useState<number>(firstActive >= 0 ? firstActive : 0);\n const orientation = stepper?.orientation ?? \"horizontal\";\n const activeStep = steps[activeIndex];\n\n return (\n <div\n className={`eth-ls-stepper eth-ls-stepper--${orientation}`}\n style={{ display: \"flex\", flexDirection: orientation === \"vertical\" ? \"row\" : \"column\", gap: context.tokens.gap, color: context.tokens.text }}\n >\n <ol className=\"eth-ls-stepper__steps\" aria-label=\"Steps\">\n {steps.map((step, index) => {\n const current = index === activeIndex;\n return (\n <li\n key={step.id}\n className={`eth-ls-stepper__step eth-ls-stepper__step--${step.status ?? \"pending\"}${current ? \" eth-ls-stepper__step--current\" : \"\"}`}\n aria-current={current ? \"step\" : undefined}\n >\n <button type=\"button\" className=\"eth-ls-stepper__step-button\" onClick={() => setActiveIndex(index)}>\n <span className=\"eth-ls-stepper__index\">{index + 1}</span>\n <span className=\"eth-ls-stepper__label\">{step.label}</span>\n </button>\n </li>\n );\n })}\n </ol>\n {activeStep ? (\n <div className=\"eth-ls-stepper__content\">\n <SlotContentRenderer\n node={node}\n slot={inlineSlot(`step:${activeStep.id}`, \"form\")}\n content={activeStep.content}\n parentContext={context}\n />\n </div>\n ) : null}\n </div>\n );\n}\n\nexport const StepperLayout: LayoutRegistryItem = {\n type: \"Primitive.Stepper\",\n displayName: \"Stepper\",\n tier: \"primitive\",\n category: \"primitive\",\n description: \"Flow-oriented step container with validation/navigation semantics.\",\n variants: [{ id: \"horizontal\" }, { id: \"vertical\" }, { id: \"with-preview\" }],\n slots: [],\n defaultComposition: {\n op: \"stepper\",\n orientation: \"horizontal\",\n stepSlot: \"stepper\",\n contentSlot: \"content\",\n steps: [],\n },\n defaultStyleIntent: { taskMode: \"wizard\", visualEmphasis: \"balanced\" },\n renderer: StepperRenderer,\n};\n\nexport const primitiveLayouts: LayoutRegistryItem[] = [\n PanelLayout,\n SplitPaneLayout,\n TabsLayout,\n StepperLayout,\n];\n","/**\n * Recursive renderer (`layout-spec.md` §8.2).\n *\n * Walks a `LayoutNode`: resolves its registry item, renders each slot's content\n * into a React node under a recomposed child context, computes the physical\n * plan, and hands the pre-rendered `slots` map to the item's renderer.\n *\n * `SlotContentRenderer` is exported so composition renderers (Tabs/Stepper) can\n * render inline `SlotContent` (switch items / stepper steps) with correct child\n * context.\n */\nimport * as React from \"react\";\nimport { StyleScope } from \"@echothink-ui/style\";\nimport type {\n ComponentSlotContent,\n LayoutNode,\n LayoutRuntimeContext,\n SlotContent,\n SlotDefinition,\n} from \"../schema/types.js\";\nimport { composeLayoutContext } from \"../inference/context.js\";\nimport { resolvePhysicalPlan } from \"../inference/responsive.js\";\nimport {\n LayoutContextProvider,\n useLayoutContext,\n useLayoutEngine,\n type LayoutEngine,\n} from \"./context.js\";\n\n/* ------------------------------------------------------------------ *\n * Fallback surfaces for unknown types — never throw at render time.\n * ------------------------------------------------------------------ */\n\nfunction UnknownLayout({ type }: { type: string }) {\n return (\n <div data-ls-unknown-layout={type} className=\"eth-ls-unknown\" role=\"note\">\n Unknown layout type: <code>{type}</code>\n </div>\n );\n}\n\nfunction UnknownComponent({ name }: { name: string }) {\n return (\n <div data-ls-unknown-component={name} className=\"eth-ls-unknown\" role=\"note\">\n Unknown component: <code>{name}</code>\n </div>\n );\n}\n\nfunction EmptySlot({ reason }: { reason?: string }) {\n return (\n <div data-ls-empty={reason ?? \"not-configured\"} className=\"eth-ls-empty\" aria-hidden=\"true\" />\n );\n}\n\n/* ------------------------------------------------------------------ *\n * Component leaf — the style boundary.\n * ------------------------------------------------------------------ */\n\nfunction ComponentRenderer({\n content,\n context,\n}: {\n content: ComponentSlotContent;\n context: LayoutRuntimeContext;\n}) {\n const engine = useLayoutEngine();\n const Component = engine.componentResolver(content.component);\n if (!Component) return <UnknownComponent name={content.component} />;\n const s = context.componentStyle;\n // The StyleScope wrapper is the ONLY place style reaches a component: it sets\n // the preset/palette/density/typeScale classes + data-attrs the `@echothink-ui`\n // components read via the CSS cascade. We intentionally do NOT inject\n // styleParams/layoutContext as props (avoids DOM prop leakage).\n return (\n <StyleScope\n preset={s.preset}\n palette={s.palette}\n density={s.density}\n typeScale={s.typeScale}\n global={false}\n className=\"eth-ls-component\"\n data-ls-component={content.component}\n >\n <Component {...(content.props ?? {})} />\n </StyleScope>\n );\n}\n\n/* ------------------------------------------------------------------ *\n * Render a SlotContent within an already-composed child context.\n * ------------------------------------------------------------------ */\n\nfunction renderContent(\n content: SlotContent,\n context: LayoutRuntimeContext,\n engine: LayoutEngine,\n): React.ReactNode {\n switch (content.kind) {\n case \"component\":\n return <ComponentRenderer content={content} context={context} />;\n case \"layout\":\n return <LayoutRenderer node={content.layout} />;\n case \"template\": {\n const resolved = engine.templateResolver?.(content.template);\n if (!resolved) return <UnknownComponent name={`template:${content.template}`} />;\n return <LayoutRenderer node={resolved} />;\n }\n case \"fragment\": {\n const direction =\n content.composition?.op === \"stack\" && content.composition.direction === \"horizontal\"\n ? \"row\"\n : \"column\";\n return (\n <div className=\"eth-ls-fragment\" style={{ display: \"flex\", flexDirection: direction, gap: context.tokens.gap }}>\n {content.items.map((item, i) => (\n <React.Fragment key={i}>{renderContent(item, context, engine)}</React.Fragment>\n ))}\n </div>\n );\n }\n case \"empty\":\n return <EmptySlot reason={content.reason} />;\n default:\n return null;\n }\n}\n\nexport interface SlotContentRendererProps {\n node: LayoutNode;\n slot: SlotDefinition;\n content: SlotContent;\n /** Context of the layout node that owns the slot. */\n parentContext: LayoutRuntimeContext;\n}\n\n/** Render one slot's content under a freshly composed child context. */\nexport function SlotContentRenderer({\n node,\n slot,\n content,\n parentContext,\n}: SlotContentRendererProps) {\n const engine = useLayoutEngine();\n const childContext = React.useMemo(\n () => composeLayoutContext({ parent: parentContext, node, slot, content }),\n [parentContext, node, slot, content],\n );\n return (\n <LayoutContextProvider value={childContext}>\n {renderContent(content, childContext, engine)}\n </LayoutContextProvider>\n );\n}\n\n/* ------------------------------------------------------------------ *\n * The recursive layout renderer.\n * ------------------------------------------------------------------ */\n\nexport function LayoutRenderer({ node }: { node: LayoutNode }) {\n const parentContext = useLayoutContext();\n const engine = useLayoutEngine();\n const item = engine.registry.get(node.type);\n\n if (!item) return <UnknownLayout type={node.type} />;\n\n const slots: Record<string, React.ReactNode> = {};\n for (const slotDef of item.slots) {\n const content = node.slots[slotDef.name] ?? slotDef.fallback?.empty;\n if (content === undefined) continue;\n slots[slotDef.name] = (\n <SlotContentRenderer\n node={node}\n slot={slotDef}\n content={content}\n parentContext={parentContext}\n />\n );\n }\n\n const plan = resolvePhysicalPlan({\n node,\n item,\n viewport: parentContext.viewport,\n state: engine.stateStore.get(node.id),\n });\n\n const Renderer = item.renderer;\n return (\n <Renderer\n node={node}\n variant={node.variant}\n props={{ ...item.defaultProps, ...node.props }}\n slots={slots}\n context={parentContext}\n composition={node.composition ?? item.defaultComposition}\n plan={plan}\n />\n );\n}\n","/**\n * React contexts for the layout engine.\n *\n * Two contexts:\n * - `LayoutRuntimeContext` — the per-node runtime context (style/surface/depth/\n * tokens) that flows down and is recomposed at each slot boundary.\n * - `LayoutEngine` — the engine config (registry + resolvers + state store +\n * diagnostics sink). Decoupled from any component catalog: the host injects a\n * `componentResolver` and optional `templateResolver`.\n */\nimport * as React from \"react\";\nimport type {\n LayoutDiagnostic,\n LayoutNode,\n LayoutRuntimeContext,\n} from \"../schema/types.js\";\nimport { createRootContext } from \"../inference/context.js\";\nimport { LayoutRegistry } from \"../registry/registry.js\";\nimport type { LayoutStateStore } from \"../runtime/state.js\";\nimport { createMemoryLayoutStateStore } from \"../runtime/state.js\";\n\nexport type ComponentResolver = (\n name: string,\n) => React.ComponentType<Record<string, unknown>> | undefined;\n\nexport type TemplateResolver = (name: string) => LayoutNode | undefined;\n\nexport interface LayoutEngine {\n registry: LayoutRegistry;\n componentResolver: ComponentResolver;\n templateResolver?: TemplateResolver;\n stateStore: LayoutStateStore;\n onDiagnostics?: (diagnostics: LayoutDiagnostic[]) => void;\n}\n\nconst RuntimeContext = React.createContext<LayoutRuntimeContext>(createRootContext());\nconst EngineContext = React.createContext<LayoutEngine | null>(null);\n\nexport function LayoutContextProvider({\n value,\n children,\n}: {\n value: LayoutRuntimeContext;\n children: React.ReactNode;\n}) {\n return <RuntimeContext.Provider value={value}>{children}</RuntimeContext.Provider>;\n}\n\nexport function useLayoutContext(): LayoutRuntimeContext {\n return React.useContext(RuntimeContext);\n}\n\nexport function LayoutEngineProvider({\n value,\n children,\n}: {\n value: LayoutEngine;\n children: React.ReactNode;\n}) {\n return <EngineContext.Provider value={value}>{children}</EngineContext.Provider>;\n}\n\nexport function useLayoutEngine(): LayoutEngine {\n const engine = React.useContext(EngineContext);\n if (!engine) {\n throw new Error(\n \"useLayoutEngine must be used within <LayoutRoot> / <LayoutEngineProvider>.\",\n );\n }\n return engine;\n}\n\nexport interface BuildEngineInput {\n registry: LayoutRegistry;\n componentResolver: ComponentResolver;\n templateResolver?: TemplateResolver;\n stateStore?: LayoutStateStore;\n onDiagnostics?: (diagnostics: LayoutDiagnostic[]) => void;\n}\n\nexport function buildEngine(input: BuildEngineInput): LayoutEngine {\n return {\n registry: input.registry,\n componentResolver: input.componentResolver,\n templateResolver: input.templateResolver,\n stateStore: input.stateStore ?? createMemoryLayoutStateStore(),\n onDiagnostics: input.onDiagnostics,\n };\n}\n","/**\n * Layout state persistence (`layout-spec.md` §11).\n *\n * A minimal pluggable store for per-layout panel state (collapse/pin/width/\n * active tab/split ratio) + style preference. Default is an in-memory +\n * localStorage-backed store; the host can inject its own (e.g. server-synced).\n */\nimport type { PersistedLayoutState } from \"../schema/types.js\";\n\nexport interface LayoutStateStore {\n get(layoutId: string): PersistedLayoutState | undefined;\n set(layoutId: string, state: PersistedLayoutState): void;\n patchPanel(\n layoutId: string,\n slot: string,\n patch: Partial<PersistedLayoutState[\"panels\"][string]>,\n ): PersistedLayoutState;\n}\n\nfunction emptyState(layoutId: string): PersistedLayoutState {\n return {\n schemaVersion: 2,\n layoutId,\n panels: {},\n updatedAt: \"\",\n };\n}\n\n/** In-memory store; optionally mirrors to localStorage when available. */\nexport function createMemoryLayoutStateStore(opts?: {\n persistKey?: string;\n}): LayoutStateStore {\n const cache = new Map<string, PersistedLayoutState>();\n const persistKey = opts?.persistKey;\n\n function load(): void {\n if (!persistKey || typeof localStorage === \"undefined\") return;\n try {\n const raw = localStorage.getItem(persistKey);\n if (!raw) return;\n const parsed = JSON.parse(raw) as Record<string, PersistedLayoutState>;\n for (const [id, st] of Object.entries(parsed)) cache.set(id, st);\n } catch {\n /* ignore corrupt state */\n }\n }\n\n function flush(): void {\n if (!persistKey || typeof localStorage === \"undefined\") return;\n try {\n localStorage.setItem(persistKey, JSON.stringify(Object.fromEntries(cache)));\n } catch {\n /* ignore quota errors */\n }\n }\n\n load();\n\n return {\n get(layoutId) {\n return cache.get(layoutId);\n },\n set(layoutId, state) {\n cache.set(layoutId, state);\n flush();\n },\n patchPanel(layoutId, slot, patch) {\n const current = cache.get(layoutId) ?? emptyState(layoutId);\n const next: PersistedLayoutState = {\n ...current,\n panels: { ...current.panels, [slot]: { ...current.panels[slot], ...patch } },\n // `updatedAt` is set by the caller environment; left as a marker here.\n updatedAt: current.updatedAt || \"pending\",\n };\n cache.set(layoutId, next);\n flush();\n return next;\n },\n };\n}\n","/**\n * Renderer helpers shared by primitive/region/page-layout renderers.\n */\nimport type {\n NodeAcceptSpec,\n PhysicalLayoutPlan,\n SlotDefinition,\n SlotRole,\n} from \"../schema/types.js\";\nimport { regionFor } from \"../inference/responsive.js\";\n\nconst ANY_ACCEPTS: NodeAcceptSpec[] = [\n { kind: \"component\" },\n { kind: \"layout\" },\n { kind: \"template\" },\n { kind: \"fragment\" },\n { kind: \"empty\" },\n];\n\n/** Synthesize a slot definition for composition-embedded content (tabs/steps). */\nexport function inlineSlot(name: string, role: SlotRole = \"content\"): SlotDefinition {\n return { name, role, accepts: ANY_ACCEPTS };\n}\n\n/** Whether a slot's physical region is visible (default true when absent). */\nexport function isVisible(plan: PhysicalLayoutPlan, slot: string): boolean {\n const region = regionFor(plan, slot);\n return region ? region.visible : true;\n}\n\n/** Whether a slot's physical region is collapsed. */\nexport function isCollapsed(plan: PhysicalLayoutPlan, slot: string): boolean {\n return regionFor(plan, slot)?.collapsed ?? false;\n}\n","/**\n * Region layouts (`layout-spec.md` §14, §19): Toolbar, Inspector.\n */\nimport * as React from \"react\";\nimport type { LayoutRegistryItem, LayoutRendererProps } from \"../schema/types.js\";\n\n/* ---------------------------- Toolbar ---------------------------- */\n\nfunction ToolbarRenderer({ slots, context }: LayoutRendererProps) {\n return (\n <div\n className=\"eth-ls-toolbar\"\n role=\"toolbar\"\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: context.tokens.gap,\n background: context.tokens.surfaceMuted,\n borderBottom: `1px solid ${context.tokens.border}`,\n color: context.tokens.text,\n }}\n >\n {slots.start ? <div className=\"eth-ls-toolbar__start\">{slots.start}</div> : null}\n {slots.center ? <div className=\"eth-ls-toolbar__center\" style={{ flex: 1, minWidth: 0 }}>{slots.center}</div> : <div style={{ flex: 1 }} />}\n {slots.end ? <div className=\"eth-ls-toolbar__end\">{slots.end}</div> : null}\n </div>\n );\n}\n\nexport const ToolbarLayout: LayoutRegistryItem = {\n type: \"Region.Toolbar\",\n displayName: \"Toolbar\",\n tier: \"region\",\n category: \"region\",\n description: \"Horizontal toolbar with start/center/end groups and roving focus.\",\n slots: [\n { name: \"start\", role: \"toolbar\", accepts: [{ kind: \"component\" }, { kind: \"fragment\" }] },\n { name: \"center\", role: \"toolbar\", accepts: [{ kind: \"component\" }, { kind: \"fragment\" }] },\n { name: \"end\", role: \"toolbar\", accepts: [{ kind: \"component\" }, { kind: \"fragment\" }] },\n ],\n defaultStyleIntent: { surface: \"region\" },\n renderer: ToolbarRenderer,\n};\n\n/* --------------------------- Inspector --------------------------- */\n\nfunction InspectorRenderer({ slots, context }: LayoutRendererProps) {\n return (\n <aside\n className=\"eth-ls-inspector\"\n aria-label=\"Inspector\"\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n minHeight: 0,\n background: context.tokens.surface,\n borderInlineStart: `1px solid ${context.tokens.border}`,\n color: context.tokens.text,\n }}\n >\n {slots.header ? <header className=\"eth-ls-inspector__header\">{slots.header}</header> : null}\n <div className=\"eth-ls-inspector__body\" style={{ overflow: \"auto\", flex: 1, minHeight: 0 }}>\n {slots.body}\n </div>\n {slots.footer ? <footer className=\"eth-ls-inspector__footer\">{slots.footer}</footer> : null}\n </aside>\n );\n}\n\nexport const InspectorLayout: LayoutRegistryItem = {\n type: \"Region.Inspector\",\n displayName: \"Inspector\",\n tier: \"region\",\n category: \"region\",\n description: \"An inline-end inspector panel with header/body/footer.\",\n slots: [\n { name: \"header\", role: \"toolbar\", accepts: [{ kind: \"component\" }, { kind: \"fragment\" }] },\n {\n name: \"body\",\n role: \"inspector\",\n required: true,\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }],\n },\n { name: \"footer\", role: \"footer\", accepts: [{ kind: \"component\" }, { kind: \"fragment\" }] },\n ],\n defaultStyleIntent: { surface: \"panel\", interactionMode: \"edit\" },\n renderer: InspectorRenderer,\n};\n\nexport const regionLayouts: LayoutRegistryItem[] = [ToolbarLayout, InspectorLayout];\n","/**\n * Page layouts (`layout-spec.md` §14, §19): AdminShell, DataGridInspector,\n * Workbench, WizardComposer, MonitoringOps, CanvasInspector.\n *\n * Each renderer consumes the resolved `plan` so the same AST yields different\n * desktop/tablet/mobile arrangements (collapsed/hidden supporting panes).\n */\nimport * as React from \"react\";\nimport type { LayoutRegistryItem, LayoutRendererProps } from \"../schema/types.js\";\nimport { isVisible, isCollapsed } from \"../renderer/region.js\";\n\nfunction frameStyle(context: LayoutRendererProps[\"context\"]): React.CSSProperties {\n return {\n display: \"grid\",\n height: \"100%\",\n minHeight: 0,\n background: context.tokens.surfaceMuted,\n color: context.tokens.text,\n };\n}\n\n/* --------------------------- AdminShell -------------------------- */\n\nfunction AdminShellRenderer({ slots, context, plan }: LayoutRendererProps) {\n const navVisible = slots.navigation && isVisible(plan, \"navigation\");\n const navCollapsed = isCollapsed(plan, \"navigation\");\n return (\n <div\n className=\"eth-ls-admin-shell\"\n style={{\n ...frameStyle(context),\n gridTemplateRows: \"auto 1fr auto\",\n gridTemplateColumns: navVisible ? `${navCollapsed ? \"3.5rem\" : \"16rem\"} 1fr` : \"1fr\",\n gridTemplateAreas: navVisible\n ? `\"topbar topbar\" \"nav content\" \"footer footer\"`\n : `\"topbar\" \"content\" \"footer\"`,\n }}\n >\n {slots.topbar ? (\n <header className=\"eth-ls-admin-shell__topbar\" style={{ gridArea: \"topbar\" }}>\n {slots.topbar}\n </header>\n ) : null}\n {navVisible ? (\n <nav className=\"eth-ls-admin-shell__nav\" style={{ gridArea: \"nav\", overflow: \"auto\", borderInlineEnd: `1px solid ${context.tokens.border}` }}>\n {slots.navigation}\n </nav>\n ) : null}\n <main className=\"eth-ls-admin-shell__content\" style={{ gridArea: \"content\", overflow: \"auto\", minWidth: 0 }}>\n {slots.content}\n </main>\n {slots.footer ? (\n <footer className=\"eth-ls-admin-shell__footer\" style={{ gridArea: \"footer\", borderBlockStart: `1px solid ${context.tokens.border}` }}>\n {slots.footer}\n </footer>\n ) : null}\n </div>\n );\n}\n\nexport const AdminShellLayout: LayoutRegistryItem = {\n type: \"PageLayout.AdminShell\",\n displayName: \"Admin Shell\",\n tier: \"page\",\n category: \"app-shell\",\n description: \"Enterprise CRUD shell: topbar, navigation rail, content, footer.\",\n slots: [\n { name: \"topbar\", role: \"toolbar\", accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }] },\n {\n name: \"navigation\",\n role: \"navigation\",\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }],\n priority: { value: 40, behaviorOnNarrow: \"move-to-drawer\" },\n responsive: { collapseBelow: \"laptop\" },\n },\n {\n name: \"content\",\n role: \"content\",\n required: true,\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"template\" }, { kind: \"fragment\" }],\n priority: { value: 100, behaviorOnNarrow: \"keep\" },\n },\n { name: \"footer\", role: \"footer\", accepts: [{ kind: \"component\" }, { kind: \"fragment\" }] },\n ],\n defaultStyleIntent: { surface: \"app\", taskMode: \"crud\" },\n renderer: AdminShellRenderer,\n};\n\n/* ----------------------- DataGridInspector ----------------------- */\n\nfunction DataGridInspectorRenderer({ slots, context, plan }: LayoutRendererProps) {\n const inspectorVisible = slots.inspector && isVisible(plan, \"inspector\");\n return (\n <div\n className=\"eth-ls-datagrid\"\n style={{\n ...frameStyle(context),\n gridTemplateRows: \"auto 1fr\",\n gridTemplateColumns: inspectorVisible ? \"1fr minmax(18rem, 24rem)\" : \"1fr\",\n gridTemplateAreas: inspectorVisible ? `\"toolbar toolbar\" \"grid inspector\"` : `\"toolbar\" \"grid\"`,\n }}\n >\n {slots.toolbar ? (\n <div className=\"eth-ls-datagrid__toolbar\" style={{ gridArea: \"toolbar\" }}>{slots.toolbar}</div>\n ) : null}\n <div className=\"eth-ls-datagrid__grid\" style={{ gridArea: \"grid\", overflow: \"auto\", minWidth: 0 }}>\n {slots.grid}\n </div>\n {inspectorVisible ? (\n <div className=\"eth-ls-datagrid__inspector\" style={{ gridArea: \"inspector\", overflow: \"auto\", borderInlineStart: `1px solid ${context.tokens.border}` }}>\n {slots.inspector}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport const DataGridInspectorLayout: LayoutRegistryItem = {\n type: \"PageLayout.DataGridInspector\",\n displayName: \"Data Grid + Inspector\",\n tier: \"page\",\n category: \"page\",\n description: \"High-density grid with a toolbar and an inline-end inspector.\",\n slots: [\n { name: \"toolbar\", role: \"toolbar\", accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }] },\n {\n name: \"grid\",\n role: \"content\",\n required: true,\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }],\n priority: { value: 100, behaviorOnNarrow: \"keep\" },\n },\n {\n name: \"inspector\",\n role: \"inspector\",\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }],\n priority: { value: 50, behaviorOnNarrow: \"move-to-drawer\" },\n },\n ],\n defaultStyleIntent: { surface: \"page\", taskMode: \"crud\", dataIntensity: \"high\" },\n renderer: DataGridInspectorRenderer,\n};\n\n/* ---------------------------- Workbench -------------------------- */\n\nfunction WorkbenchRenderer({ slots, context, plan }: LayoutRendererProps) {\n const explorerVisible = slots.explorer && isVisible(plan, \"explorer\");\n const inspectorVisible = slots.inspector && isVisible(plan, \"inspector\");\n const consoleVisible = slots.console && isVisible(plan, \"console\");\n const cols = [explorerVisible ? \"16rem\" : null, \"1fr\", inspectorVisible ? \"minmax(18rem, 22rem)\" : null]\n .filter(Boolean)\n .join(\" \");\n const areaMid = [explorerVisible ? \"explorer\" : null, \"primary\", inspectorVisible ? \"inspector\" : null]\n .filter(Boolean)\n .join(\" \");\n return (\n <div\n className=\"eth-ls-workbench\"\n style={{\n ...frameStyle(context),\n gridTemplateColumns: cols,\n gridTemplateRows: `auto 1fr ${consoleVisible ? \"minmax(8rem, 16rem)\" : \"0\"}`,\n gridTemplateAreas: `\"${new Array(cols.split(\" \").length).fill(\"toolbar\").join(\" \")}\" \"${areaMid}\" \"${new Array(cols.split(\" \").length).fill(\"console\").join(\" \")}\"`,\n }}\n >\n {slots.toolbar ? <div className=\"eth-ls-workbench__toolbar\" style={{ gridArea: \"toolbar\" }}>{slots.toolbar}</div> : null}\n {explorerVisible ? (\n <nav className=\"eth-ls-workbench__explorer\" style={{ gridArea: \"explorer\", overflow: \"auto\", borderInlineEnd: `1px solid ${context.tokens.border}` }}>\n {slots.explorer}\n </nav>\n ) : null}\n <main className=\"eth-ls-workbench__primary\" style={{ gridArea: \"primary\", overflow: \"auto\", minWidth: 0, minHeight: 0 }}>\n {slots.primary}\n </main>\n {inspectorVisible ? (\n <div className=\"eth-ls-workbench__inspector\" style={{ gridArea: \"inspector\", overflow: \"auto\", borderInlineStart: `1px solid ${context.tokens.border}` }}>\n {slots.inspector}\n </div>\n ) : null}\n {consoleVisible ? (\n <div className=\"eth-ls-workbench__console\" style={{ gridArea: \"console\", overflow: \"auto\", borderBlockStart: `1px solid ${context.tokens.border}` }}>\n {slots.console}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport const WorkbenchLayout: LayoutRegistryItem = {\n type: \"PageLayout.Workbench\",\n displayName: \"Workbench\",\n tier: \"page\",\n category: \"page\",\n description: \"Authoring workbench: toolbar, explorer, primary canvas, inspector, console.\",\n variants: [{ id: \"canvas-primary\" }, { id: \"split-primary\" }],\n slots: [\n { name: \"toolbar\", role: \"toolbar\", accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }] },\n {\n name: \"explorer\",\n role: \"navigation\",\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }],\n priority: { value: 40, behaviorOnNarrow: \"move-to-drawer\" },\n responsive: { collapseBelow: \"laptop\" },\n },\n {\n name: \"primary\",\n role: \"primary\",\n required: true,\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"template\" }, { kind: \"fragment\" }],\n priority: { value: 100, behaviorOnNarrow: \"keep\" },\n },\n {\n name: \"inspector\",\n role: \"inspector\",\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }],\n priority: { value: 50, behaviorOnNarrow: \"move-to-drawer\" },\n },\n {\n name: \"console\",\n role: \"console\",\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }],\n priority: { value: 30, behaviorOnNarrow: \"move-to-bottom-sheet\" },\n },\n ],\n defaultStyleIntent: { surface: \"workspace\", taskMode: \"authoring\", visualEmphasis: \"immersive\" },\n renderer: WorkbenchRenderer,\n};\n\n/* ------------------------- WizardComposer ------------------------ */\n\nfunction WizardComposerRenderer({ slots, context, plan }: LayoutRendererProps) {\n const previewVisible = slots.preview && isVisible(plan, \"preview\");\n return (\n <div\n className=\"eth-ls-wizard\"\n style={{\n ...frameStyle(context),\n gridTemplateColumns: previewVisible ? \"1fr minmax(20rem, 28rem)\" : \"1fr\",\n gridTemplateRows: \"auto 1fr auto\",\n gridTemplateAreas: previewVisible\n ? `\"stepper stepper\" \"content preview\" \"footer footer\"`\n : `\"stepper\" \"content\" \"footer\"`,\n background: context.tokens.surface,\n }}\n >\n {slots.stepper ? <div className=\"eth-ls-wizard__stepper\" style={{ gridArea: \"stepper\" }}>{slots.stepper}</div> : null}\n <main className=\"eth-ls-wizard__content\" style={{ gridArea: \"content\", overflow: \"auto\", minWidth: 0 }}>\n {slots.content}\n </main>\n {previewVisible ? (\n <div className=\"eth-ls-wizard__preview\" style={{ gridArea: \"preview\", overflow: \"auto\", borderInlineStart: `1px solid ${context.tokens.border}` }}>\n {slots.preview}\n </div>\n ) : null}\n {slots.footerActions ? (\n <footer className=\"eth-ls-wizard__footer\" style={{ gridArea: \"footer\", borderBlockStart: `1px solid ${context.tokens.border}` }}>\n {slots.footerActions}\n </footer>\n ) : null}\n </div>\n );\n}\n\nexport const WizardComposerLayout: LayoutRegistryItem = {\n type: \"PageLayout.WizardComposer\",\n displayName: \"Wizard Composer\",\n tier: \"page\",\n category: \"page\",\n description: \"Guided multi-step creation flow with optional live preview.\",\n slots: [\n { name: \"stepper\", role: \"stepper\", accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }] },\n {\n name: \"content\",\n role: \"form\",\n required: true,\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"template\" }, { kind: \"fragment\" }],\n priority: { value: 100, behaviorOnNarrow: \"keep\" },\n },\n {\n name: \"preview\",\n role: \"preview\",\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }],\n priority: { value: 40, behaviorOnNarrow: \"hide\" },\n },\n { name: \"footerActions\", role: \"footer\", accepts: [{ kind: \"component\" }, { kind: \"fragment\" }] },\n ],\n defaultStyleIntent: { surface: \"page\", taskMode: \"wizard\", visualEmphasis: \"balanced\" },\n renderer: WizardComposerRenderer,\n};\n\n/* ------------------------- MonitoringOps ------------------------- */\n\nfunction MonitoringOpsRenderer({ slots, context, plan }: LayoutRendererProps) {\n const consoleVisible = slots.console && isVisible(plan, \"console\");\n return (\n <div\n className=\"eth-ls-monitoring\"\n style={{\n ...frameStyle(context),\n gridTemplateRows: `auto auto 1fr ${consoleVisible ? \"minmax(8rem, 14rem)\" : \"0\"}`,\n gridTemplateAreas: `\"toolbar\" \"metrics\" \"primary\" \"console\"`,\n }}\n >\n {slots.toolbar ? <div className=\"eth-ls-monitoring__toolbar\" style={{ gridArea: \"toolbar\" }}>{slots.toolbar}</div> : null}\n {slots.metrics ? <div className=\"eth-ls-monitoring__metrics\" style={{ gridArea: \"metrics\" }}>{slots.metrics}</div> : null}\n <main className=\"eth-ls-monitoring__primary\" style={{ gridArea: \"primary\", overflow: \"auto\", minHeight: 0 }}>\n {slots.primary}\n </main>\n {consoleVisible ? (\n <div className=\"eth-ls-monitoring__console\" style={{ gridArea: \"console\", overflow: \"auto\", borderBlockStart: `1px solid ${context.tokens.border}` }}>\n {slots.console}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport const MonitoringOpsLayout: LayoutRegistryItem = {\n type: \"PageLayout.MonitoringOps\",\n displayName: \"Monitoring Ops\",\n tier: \"page\",\n category: \"page\",\n description: \"Realtime ops dashboard: toolbar, metric strip, primary view, console.\",\n slots: [\n { name: \"toolbar\", role: \"toolbar\", accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }] },\n { name: \"metrics\", role: \"summary\", accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }] },\n {\n name: \"primary\",\n role: \"content\",\n required: true,\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }],\n priority: { value: 100, behaviorOnNarrow: \"keep\" },\n },\n {\n name: \"console\",\n role: \"console\",\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }],\n priority: { value: 30, behaviorOnNarrow: \"move-to-bottom-sheet\" },\n },\n ],\n defaultStyleIntent: { surface: \"page\", taskMode: \"monitoring\", dataIntensity: \"realtime\" },\n renderer: MonitoringOpsRenderer,\n};\n\n/* ------------------------ CanvasInspector ------------------------ */\n\nfunction CanvasInspectorRenderer({ slots, context, plan }: LayoutRendererProps) {\n const inspectorVisible = slots.inspector && isVisible(plan, \"inspector\");\n return (\n <div\n className=\"eth-ls-canvas\"\n style={{\n ...frameStyle(context),\n gridTemplateRows: \"auto 1fr\",\n gridTemplateColumns: inspectorVisible ? \"1fr minmax(18rem, 24rem)\" : \"1fr\",\n gridTemplateAreas: inspectorVisible ? `\"toolbar toolbar\" \"canvas inspector\"` : `\"toolbar\" \"canvas\"`,\n }}\n >\n {slots.toolbar ? <div className=\"eth-ls-canvas__toolbar\" style={{ gridArea: \"toolbar\" }}>{slots.toolbar}</div> : null}\n <div className=\"eth-ls-canvas__stage\" style={{ gridArea: \"canvas\", overflow: \"hidden\", minWidth: 0, minHeight: 0 }}>\n {slots.canvas}\n </div>\n {inspectorVisible ? (\n <div className=\"eth-ls-canvas__inspector\" style={{ gridArea: \"inspector\", overflow: \"auto\", borderInlineStart: `1px solid ${context.tokens.border}` }}>\n {slots.inspector}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport const CanvasInspectorLayout: LayoutRegistryItem = {\n type: \"PageLayout.CanvasInspector\",\n displayName: \"Canvas + Inspector\",\n tier: \"page\",\n category: \"page\",\n description: \"Full-bleed canvas with a toolbar and inline-end inspector.\",\n slots: [\n { name: \"toolbar\", role: \"toolbar\", accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }] },\n {\n name: \"canvas\",\n role: \"canvas\",\n required: true,\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }],\n priority: { value: 100, behaviorOnNarrow: \"keep\" },\n },\n {\n name: \"inspector\",\n role: \"inspector\",\n accepts: [{ kind: \"component\" }, { kind: \"layout\" }, { kind: \"fragment\" }],\n priority: { value: 50, behaviorOnNarrow: \"move-to-drawer\" },\n },\n ],\n defaultStyleIntent: { surface: \"canvas\", taskMode: \"authoring\", visualEmphasis: \"immersive\" },\n renderer: CanvasInspectorRenderer,\n};\n\nexport const pageLayouts: LayoutRegistryItem[] = [\n AdminShellLayout,\n DataGridInspectorLayout,\n WorkbenchLayout,\n WizardComposerLayout,\n MonitoringOpsLayout,\n CanvasInspectorLayout,\n];\n","/**\n * Builtin layout catalog + default registry factory (`layout-spec.md` §19).\n */\nimport type { LayoutRegistryItem } from \"../schema/types.js\";\nimport { LayoutRegistry } from \"./registry.js\";\nimport { primitiveLayouts } from \"../primitives/index.js\";\nimport { regionLayouts } from \"../regions/index.js\";\nimport { pageLayouts } from \"../page-layouts/index.js\";\n\nexport const builtinLayouts: LayoutRegistryItem[] = [\n ...primitiveLayouts,\n ...regionLayouts,\n ...pageLayouts,\n];\n\n/** A registry preloaded with the MVP builtin layouts. */\nexport function createDefaultLayoutRegistry(): LayoutRegistry {\n return new LayoutRegistry().registerAll(builtinLayouts);\n}\n","/**\n * Viewport observation (`layout-spec.md` §10.1, §17.5).\n *\n * A throttled hook that maps `window` size to a `LayoutViewport` (breakpoint,\n * pointer, color scheme). SSR-safe: returns the provided default until mounted.\n */\nimport * as React from \"react\";\nimport type { Breakpoint, LayoutViewport } from \"../schema/types.js\";\nimport { defaultViewport } from \"../inference/context.js\";\n\n/** rem-based breakpoint thresholds mirrored from `ethBreakpoints` (px @16). */\nconst BREAKPOINTS: Array<{ bp: Breakpoint; minWidth: number }> = [\n { bp: \"ultra\", minWidth: 1920 },\n { bp: \"wide\", minWidth: 1536 },\n { bp: \"desktop\", minWidth: 1280 },\n { bp: \"laptop\", minWidth: 1024 },\n { bp: \"tablet\", minWidth: 768 },\n { bp: \"mobile\", minWidth: 0 },\n];\n\nexport function breakpointForWidth(width: number): Breakpoint {\n for (const { bp, minWidth } of BREAKPOINTS) {\n if (width >= minWidth) return bp;\n }\n return \"mobile\";\n}\n\nfunction readViewport(): LayoutViewport {\n if (typeof window === \"undefined\") return defaultViewport;\n const width = window.innerWidth;\n const height = window.innerHeight;\n const pointer =\n typeof window.matchMedia === \"function\" && window.matchMedia(\"(pointer: coarse)\").matches\n ? \"coarse\"\n : \"fine\";\n const colorScheme =\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-color-scheme: dark)\").matches\n ? \"dark\"\n : \"light\";\n return { breakpoint: breakpointForWidth(width), width, height, pointer, colorScheme };\n}\n\nexport interface UseViewportOptions {\n /** Initial value used before mount / on the server. */\n initial?: LayoutViewport;\n /** Resize debounce in ms. */\n debounceMs?: number;\n}\n\nexport function useViewport(opts: UseViewportOptions = {}): LayoutViewport {\n const { initial = defaultViewport, debounceMs = 120 } = opts;\n const [viewport, setViewport] = React.useState<LayoutViewport>(initial);\n\n React.useEffect(() => {\n if (typeof window === \"undefined\") return undefined;\n setViewport(readViewport());\n let timer: ReturnType<typeof setTimeout> | undefined;\n const onResize = () => {\n if (timer) clearTimeout(timer);\n timer = setTimeout(() => setViewport(readViewport()), debounceMs);\n };\n window.addEventListener(\"resize\", onResize);\n return () => {\n if (timer) clearTimeout(timer);\n window.removeEventListener(\"resize\", onResize);\n };\n }, [debounceMs]);\n\n return viewport;\n}\n","/**\n * `LayoutRoot` — the top-level entry that mounts the layout engine.\n *\n * Wires the registry + resolvers + state store into an engine context, builds\n * the root runtime context (optionally observing the live viewport), validates\n * the tree once, and renders the recursive `LayoutRenderer`.\n */\nimport * as React from \"react\";\nimport type {\n LayoutDiagnostic,\n LayoutNode,\n LayoutViewport,\n} from \"../schema/types.js\";\nimport { createRootContext, type RootContextInput } from \"../inference/context.js\";\nimport { LayoutRegistry } from \"../registry/registry.js\";\nimport { createDefaultLayoutRegistry } from \"../registry/builtins.js\";\nimport type { LayoutStateStore } from \"../runtime/state.js\";\nimport { useViewport } from \"../runtime/viewport.js\";\nimport { validateLayout } from \"../schema/validate.js\";\nimport {\n LayoutContextProvider,\n LayoutEngineProvider,\n buildEngine,\n type ComponentResolver,\n type TemplateResolver,\n} from \"./context.js\";\nimport { LayoutRenderer } from \"./renderer.js\";\n\nexport interface LayoutRootProps {\n /** The layout AST to render. */\n node: LayoutNode;\n /** Resolves component names → React components (host-injected). */\n componentResolver: ComponentResolver;\n /** Resolves template names → layout nodes (host-injected). */\n templateResolver?: TemplateResolver;\n /** Layout registry; defaults to the MVP builtin registry. */\n registry?: LayoutRegistry;\n /** Root context overrides (surface/style/route/permissions/viewport). */\n context?: RootContextInput;\n /** Pluggable panel-state store. */\n stateStore?: LayoutStateStore;\n /** Observe the live viewport and feed it into the root context. Default true. */\n observeViewport?: boolean;\n /** Receives validation diagnostics whenever the tree changes. */\n onDiagnostics?: (diagnostics: LayoutDiagnostic[]) => void;\n}\n\nexport function LayoutRoot({\n node,\n componentResolver,\n templateResolver,\n registry,\n context,\n stateStore,\n observeViewport = true,\n onDiagnostics,\n}: LayoutRootProps) {\n const resolvedRegistry = React.useMemo(\n () => registry ?? createDefaultLayoutRegistry(),\n [registry],\n );\n\n const observed = useViewport({ initial: context?.viewport as LayoutViewport | undefined });\n const viewport = observeViewport ? observed : (context?.viewport as LayoutViewport | undefined);\n\n const rootContext = React.useMemo(\n () => createRootContext({ ...context, viewport }),\n [context, viewport],\n );\n\n const engine = React.useMemo(\n () =>\n buildEngine({\n registry: resolvedRegistry,\n componentResolver,\n templateResolver,\n stateStore,\n onDiagnostics,\n }),\n [resolvedRegistry, componentResolver, templateResolver, stateStore, onDiagnostics],\n );\n\n React.useEffect(() => {\n if (!onDiagnostics) return;\n onDiagnostics(validateLayout(node, resolvedRegistry));\n }, [node, resolvedRegistry, onDiagnostics]);\n\n return (\n <LayoutEngineProvider value={engine}>\n <LayoutContextProvider value={rootContext}>\n <LayoutRenderer node={node} />\n </LayoutContextProvider>\n </LayoutEngineProvider>\n );\n}\n","/**\n * Ergonomic builders for hand-authoring `LayoutNode` ASTs (used by templates\n * and tests). Pure helpers — no runtime behavior.\n */\nimport type {\n ComponentSlotContent,\n EmptySlotContent,\n FragmentSlotContent,\n LayoutNode,\n LayoutSlotContent,\n SlotContent,\n TemplateSlotContent,\n} from \"./schema/types.js\";\n\nexport interface LayoutNodeInput extends Omit<LayoutNode, \"kind\"> {}\n\nexport function layout(input: LayoutNodeInput): LayoutNode {\n return { kind: \"layout\", ...input };\n}\n\nexport function componentSlot(\n component: string,\n props?: Record<string, unknown>,\n styleOverride?: ComponentSlotContent[\"styleOverride\"],\n): ComponentSlotContent {\n return { kind: \"component\", component, props, styleOverride };\n}\n\nexport function layoutSlot(node: LayoutNode): LayoutSlotContent {\n return { kind: \"layout\", layout: node };\n}\n\nexport function templateSlot(template: string, props?: Record<string, unknown>): TemplateSlotContent {\n return { kind: \"template\", template, props };\n}\n\nexport function fragmentSlot(\n items: SlotContent[],\n composition?: FragmentSlotContent[\"composition\"],\n): FragmentSlotContent {\n return { kind: \"fragment\", items, composition };\n}\n\nexport function emptySlot(reason?: EmptySlotContent[\"reason\"]): EmptySlotContent {\n return { kind: \"empty\", reason };\n}\n"],"mappings":";AAWA;AAAA,EACE,cAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACHP,IAAM,oBAAoB;AAE1B,SAAS,eAAe,SAA2B,SAA+B;AAChF,SAAO,QAAQ,KAAK,CAAC,SAAS;AAC5B,YAAQ,QAAQ,MAAM;AAAA,MACpB,KAAK;AACH,eACE,KAAK,SAAS,gBACb,CAAC,KAAK,kBAAkB,KAAK,eAAe,SAAS,QAAQ,SAAS;AAAA,MAE3E,KAAK;AACH,eACE,KAAK,SAAS,aACb,CAAC,KAAK,eAAe,KAAK,YAAY,SAAS,QAAQ,OAAO,IAAI;AAAA,MAEvE,KAAK;AACH,eACE,KAAK,SAAS,eACb,CAAC,KAAK,iBAAiB,KAAK,cAAc,SAAS,QAAQ,QAAQ;AAAA,MAExE,KAAK;AACH,eAAO,KAAK,SAAS;AAAA,MACvB,KAAK;AACH,eAAO,KAAK,SAAS;AAAA,MACvB;AACE,eAAO;AAAA,IACX;AAAA,EACF,CAAC;AACH;AAEA,UAAU,aAAa,SAA6C;AAClE,MAAI,QAAQ,SAAS,UAAU;AAC7B,UAAM,QAAQ;AAAA,EAChB,WAAW,QAAQ,SAAS,YAAY;AACtC,eAAW,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AM,UAAU,QAAQ,KAAK;AACxC;AAEO,SAAS,aAAa,UAAkB,OAAsD;AACnG,SAAO,EAAE,MAAM,YAAY,UAAU,MAAM;AAC7C;AAEO,SAAS,aACd,OACA,aACqB;AACrB,SAAO,EAAE,MAAM,YAAY,OAAO,YAAY;AAChD;AAEO,SAAS,UAAU,QAAuD;AAC/E,SAAO,EAAE,MAAM,SAAS,OAAO;AACjC;;;AjBbO,IAAM,iBAAiB;AAAA,EAC5B,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;","names":["StyleScope","React","React","jsx","jsx","jsxs","jsx","jsxs","jsx","jsxs","React","React","jsx"]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Ergonomic builders for hand-authoring `LayoutNode` ASTs (used by templates
3
+ * and tests). Pure helpers — no runtime behavior.
4
+ */
5
+ import type { ComponentSlotContent, EmptySlotContent, FragmentSlotContent, LayoutNode, LayoutSlotContent, SlotContent, TemplateSlotContent } from "./schema/types.js";
6
+ export interface LayoutNodeInput extends Omit<LayoutNode, "kind"> {
7
+ }
8
+ export declare function layout(input: LayoutNodeInput): LayoutNode;
9
+ export declare function componentSlot(component: string, props?: Record<string, unknown>, styleOverride?: ComponentSlotContent["styleOverride"]): ComponentSlotContent;
10
+ export declare function layoutSlot(node: LayoutNode): LayoutSlotContent;
11
+ export declare function templateSlot(template: string, props?: Record<string, unknown>): TemplateSlotContent;
12
+ export declare function fragmentSlot(items: SlotContent[], composition?: FragmentSlotContent["composition"]): FragmentSlotContent;
13
+ export declare function emptySlot(reason?: EmptySlotContent["reason"]): EmptySlotContent;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * `@echothink-ui/layout` — the layout system (layout-spec.md).
3
+ *
4
+ * A recursive, typed page-structure engine: Typed Layout AST → registry resolve
5
+ * → validation → context inference → responsive physical plan → recursive render.
6
+ */
7
+ export * from "./schema/types.js";
8
+ export { validateLayout, hasErrors } from "./schema/validate.js";
9
+ export type { ValidateOptions } from "./schema/validate.js";
10
+ export { presetTokenMap, resolveTokens } from "./tokens/preset-tokens.js";
11
+ export { inferComponentStyle, inferDensity, inferTypeScale, defaultComponentStyle, } from "./inference/style.js";
12
+ export { composeLayoutContext, buildStyleInferenceInput, createRootContext, defaultContextPolicy, defaultViewport, type RootContextInput, } from "./inference/context.js";
13
+ export { resolvePhysicalPlan, regionFor, breakpointRank, isNarrow, type ResolvePlanInput, } from "./inference/responsive.js";
14
+ export { LayoutRegistry } from "./registry/registry.js";
15
+ export { builtinLayouts, createDefaultLayoutRegistry } from "./registry/builtins.js";
16
+ export { createMemoryLayoutStateStore, type LayoutStateStore, } from "./runtime/state.js";
17
+ export { useViewport, breakpointForWidth, type UseViewportOptions, } from "./runtime/viewport.js";
18
+ export { LayoutRoot, type LayoutRootProps } from "./renderer/root.js";
19
+ export { LayoutRenderer, SlotContentRenderer, type SlotContentRendererProps, } from "./renderer/renderer.js";
20
+ export { LayoutContextProvider, LayoutEngineProvider, useLayoutContext, useLayoutEngine, buildEngine, type ComponentResolver, type TemplateResolver, type LayoutEngine, type BuildEngineInput, } from "./renderer/context.js";
21
+ export { primitiveLayouts } from "./primitives/index.js";
22
+ export { regionLayouts } from "./regions/index.js";
23
+ export { pageLayouts } from "./page-layouts/index.js";
24
+ export { layout, componentSlot, layoutSlot, templateSlot, fragmentSlot, emptySlot, type LayoutNodeInput, } from "./builders.js";
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Context propagation (`layout-spec.md` §6, §8).
3
+ *
4
+ * Builds the root `LayoutRuntimeContext` and composes a child context for each
5
+ * slot: it derives the child surface/taskMode/etc. and runs `inferComponentStyle`
6
+ * so the descendant components receive consistent, inferred style params.
7
+ */
8
+ import type { ComponentStyleParams, ContextPolicy, LayoutNode, LayoutRuntimeContext, LayoutViewport, SlotContent, SlotDefinition, StyleInferenceInput, SurfaceRole } from "../schema/types.js";
9
+ export declare const defaultContextPolicy: ContextPolicy;
10
+ export declare const defaultViewport: LayoutViewport;
11
+ export interface RootContextInput {
12
+ viewport?: Partial<LayoutViewport>;
13
+ surface?: SurfaceRole;
14
+ style?: Partial<ComponentStyleParams>;
15
+ route?: LayoutRuntimeContext["route"];
16
+ permissions?: string[];
17
+ }
18
+ /** Build the top-level context an app mounts the renderer with. */
19
+ export declare function createRootContext(input?: RootContextInput): LayoutRuntimeContext;
20
+ /** §7.1 — assemble the inference input from parent context + node + slot. */
21
+ export declare function buildStyleInferenceInput(args: {
22
+ parent: LayoutRuntimeContext;
23
+ node: LayoutNode;
24
+ slot: SlotDefinition;
25
+ content: SlotContent;
26
+ }): StyleInferenceInput;
27
+ /** §8.1 — compose the child runtime context for a slot. */
28
+ export declare function composeLayoutContext(args: {
29
+ parent: LayoutRuntimeContext;
30
+ node: LayoutNode;
31
+ slot: SlotDefinition;
32
+ content: SlotContent;
33
+ }): LayoutRuntimeContext;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Responsive physical plan (`layout-spec.md` §10).
3
+ *
4
+ * Maps a logical layout node + its registry slot definitions + the viewport (and
5
+ * optional user collapse/pin state) to a `PhysicalLayoutPlan` describing each
6
+ * slot's placement, visibility and collapse. Page-layout renderers consume the
7
+ * plan so the same AST yields different desktop/tablet/mobile arrangements.
8
+ */
9
+ import type { Breakpoint, LayoutNode, LayoutRegistryItem, LayoutViewport, PersistedLayoutState, PhysicalLayoutPlan, PhysicalRegion } from "../schema/types.js";
10
+ export declare function breakpointRank(bp: Breakpoint): number;
11
+ export declare function isNarrow(bp: Breakpoint): boolean;
12
+ export interface ResolvePlanInput {
13
+ node: LayoutNode;
14
+ item: LayoutRegistryItem;
15
+ viewport: LayoutViewport;
16
+ state?: PersistedLayoutState;
17
+ }
18
+ /** Compute the physical plan for a single layout node. */
19
+ export declare function resolvePhysicalPlan(input: ResolvePlanInput): PhysicalLayoutPlan;
20
+ /** Convenience: get the region for a slot from a plan. */
21
+ export declare function regionFor(plan: PhysicalLayoutPlan, slot: string): PhysicalRegion | undefined;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Component style inference (`layout-spec.md` §7).
3
+ *
4
+ * Components do NOT pick their own preset/density/typeScale. The engine infers
5
+ * `ComponentStyleParams` from the layout runtime context using a scoring
6
+ * resolver for `preset` plus rule tables for `density` and `typeScale`.
7
+ */
8
+ import type { ComponentDensity, ComponentStyleParams, ComponentTypeScale, StyleInferenceInput } from "../schema/types.js";
9
+ export declare const defaultComponentStyle: ComponentStyleParams;
10
+ /** §7.4 density rules. */
11
+ export declare function inferDensity(input: StyleInferenceInput): ComponentDensity;
12
+ /** §7.5 typeScale rules. */
13
+ export declare function inferTypeScale(input: StyleInferenceInput): ComponentTypeScale;
14
+ /** §7.6 scoring preset resolver. */
15
+ export declare function inferComponentStyle(input: StyleInferenceInput): ComponentStyleParams;
@@ -0,0 +1,8 @@
1
+ import type { LayoutRegistryItem } from "../schema/types.js";
2
+ export declare const AdminShellLayout: LayoutRegistryItem;
3
+ export declare const DataGridInspectorLayout: LayoutRegistryItem;
4
+ export declare const WorkbenchLayout: LayoutRegistryItem;
5
+ export declare const WizardComposerLayout: LayoutRegistryItem;
6
+ export declare const MonitoringOpsLayout: LayoutRegistryItem;
7
+ export declare const CanvasInspectorLayout: LayoutRegistryItem;
8
+ export declare const pageLayouts: LayoutRegistryItem[];
@@ -0,0 +1,6 @@
1
+ import type { LayoutRegistryItem } from "../schema/types.js";
2
+ export declare const PanelLayout: LayoutRegistryItem;
3
+ export declare const SplitPaneLayout: LayoutRegistryItem;
4
+ export declare const TabsLayout: LayoutRegistryItem;
5
+ export declare const StepperLayout: LayoutRegistryItem;
6
+ export declare const primitiveLayouts: LayoutRegistryItem[];
@@ -0,0 +1,4 @@
1
+ import type { LayoutRegistryItem } from "../schema/types.js";
2
+ export declare const ToolbarLayout: LayoutRegistryItem;
3
+ export declare const InspectorLayout: LayoutRegistryItem;
4
+ export declare const regionLayouts: LayoutRegistryItem[];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Builtin layout catalog + default registry factory (`layout-spec.md` §19).
3
+ */
4
+ import type { LayoutRegistryItem } from "../schema/types.js";
5
+ import { LayoutRegistry } from "./registry.js";
6
+ export declare const builtinLayouts: LayoutRegistryItem[];
7
+ /** A registry preloaded with the MVP builtin layouts. */
8
+ export declare function createDefaultLayoutRegistry(): LayoutRegistry;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Layout registry (`layout-spec.md` §9).
3
+ *
4
+ * Maps a layout `type` (e.g. "PageLayout.Workbench") to its `LayoutRegistryItem`
5
+ * (slots, renderer, default composition/style intent). The recursive renderer
6
+ * and the validator consult it; it is also the source the builder/copilot read
7
+ * to discover available layouts and their slot contracts.
8
+ */
9
+ import type { LayoutRegistryItem } from "../schema/types.js";
10
+ export declare class LayoutRegistry {
11
+ private readonly items;
12
+ register(item: LayoutRegistryItem): this;
13
+ registerAll(items: readonly LayoutRegistryItem[]): this;
14
+ get(type: string): LayoutRegistryItem | undefined;
15
+ has(type: string): boolean;
16
+ list(): LayoutRegistryItem[];
17
+ types(): string[];
18
+ byTier(tier: LayoutRegistryItem["tier"]): LayoutRegistryItem[];
19
+ byCategory(category: LayoutRegistryItem["category"]): LayoutRegistryItem[];
20
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * React contexts for the layout engine.
3
+ *
4
+ * Two contexts:
5
+ * - `LayoutRuntimeContext` — the per-node runtime context (style/surface/depth/
6
+ * tokens) that flows down and is recomposed at each slot boundary.
7
+ * - `LayoutEngine` — the engine config (registry + resolvers + state store +
8
+ * diagnostics sink). Decoupled from any component catalog: the host injects a
9
+ * `componentResolver` and optional `templateResolver`.
10
+ */
11
+ import * as React from "react";
12
+ import type { LayoutDiagnostic, LayoutNode, LayoutRuntimeContext } from "../schema/types.js";
13
+ import { LayoutRegistry } from "../registry/registry.js";
14
+ import type { LayoutStateStore } from "../runtime/state.js";
15
+ export type ComponentResolver = (name: string) => React.ComponentType<Record<string, unknown>> | undefined;
16
+ export type TemplateResolver = (name: string) => LayoutNode | undefined;
17
+ export interface LayoutEngine {
18
+ registry: LayoutRegistry;
19
+ componentResolver: ComponentResolver;
20
+ templateResolver?: TemplateResolver;
21
+ stateStore: LayoutStateStore;
22
+ onDiagnostics?: (diagnostics: LayoutDiagnostic[]) => void;
23
+ }
24
+ export declare function LayoutContextProvider({ value, children, }: {
25
+ value: LayoutRuntimeContext;
26
+ children: React.ReactNode;
27
+ }): import("react/jsx-runtime").JSX.Element;
28
+ export declare function useLayoutContext(): LayoutRuntimeContext;
29
+ export declare function LayoutEngineProvider({ value, children, }: {
30
+ value: LayoutEngine;
31
+ children: React.ReactNode;
32
+ }): import("react/jsx-runtime").JSX.Element;
33
+ export declare function useLayoutEngine(): LayoutEngine;
34
+ export interface BuildEngineInput {
35
+ registry: LayoutRegistry;
36
+ componentResolver: ComponentResolver;
37
+ templateResolver?: TemplateResolver;
38
+ stateStore?: LayoutStateStore;
39
+ onDiagnostics?: (diagnostics: LayoutDiagnostic[]) => void;
40
+ }
41
+ export declare function buildEngine(input: BuildEngineInput): LayoutEngine;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Renderer helpers shared by primitive/region/page-layout renderers.
3
+ */
4
+ import type { PhysicalLayoutPlan, SlotDefinition, SlotRole } from "../schema/types.js";
5
+ /** Synthesize a slot definition for composition-embedded content (tabs/steps). */
6
+ export declare function inlineSlot(name: string, role?: SlotRole): SlotDefinition;
7
+ /** Whether a slot's physical region is visible (default true when absent). */
8
+ export declare function isVisible(plan: PhysicalLayoutPlan, slot: string): boolean;
9
+ /** Whether a slot's physical region is collapsed. */
10
+ export declare function isCollapsed(plan: PhysicalLayoutPlan, slot: string): boolean;
@@ -0,0 +1,13 @@
1
+ import type { LayoutNode, LayoutRuntimeContext, SlotContent, SlotDefinition } from "../schema/types.js";
2
+ export interface SlotContentRendererProps {
3
+ node: LayoutNode;
4
+ slot: SlotDefinition;
5
+ content: SlotContent;
6
+ /** Context of the layout node that owns the slot. */
7
+ parentContext: LayoutRuntimeContext;
8
+ }
9
+ /** Render one slot's content under a freshly composed child context. */
10
+ export declare function SlotContentRenderer({ node, slot, content, parentContext, }: SlotContentRendererProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function LayoutRenderer({ node }: {
12
+ node: LayoutNode;
13
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import type { LayoutDiagnostic, LayoutNode } from "../schema/types.js";
2
+ import { type RootContextInput } from "../inference/context.js";
3
+ import { LayoutRegistry } from "../registry/registry.js";
4
+ import type { LayoutStateStore } from "../runtime/state.js";
5
+ import { type ComponentResolver, type TemplateResolver } from "./context.js";
6
+ export interface LayoutRootProps {
7
+ /** The layout AST to render. */
8
+ node: LayoutNode;
9
+ /** Resolves component names → React components (host-injected). */
10
+ componentResolver: ComponentResolver;
11
+ /** Resolves template names → layout nodes (host-injected). */
12
+ templateResolver?: TemplateResolver;
13
+ /** Layout registry; defaults to the MVP builtin registry. */
14
+ registry?: LayoutRegistry;
15
+ /** Root context overrides (surface/style/route/permissions/viewport). */
16
+ context?: RootContextInput;
17
+ /** Pluggable panel-state store. */
18
+ stateStore?: LayoutStateStore;
19
+ /** Observe the live viewport and feed it into the root context. Default true. */
20
+ observeViewport?: boolean;
21
+ /** Receives validation diagnostics whenever the tree changes. */
22
+ onDiagnostics?: (diagnostics: LayoutDiagnostic[]) => void;
23
+ }
24
+ export declare function LayoutRoot({ node, componentResolver, templateResolver, registry, context, stateStore, observeViewport, onDiagnostics, }: LayoutRootProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Layout state persistence (`layout-spec.md` §11).
3
+ *
4
+ * A minimal pluggable store for per-layout panel state (collapse/pin/width/
5
+ * active tab/split ratio) + style preference. Default is an in-memory +
6
+ * localStorage-backed store; the host can inject its own (e.g. server-synced).
7
+ */
8
+ import type { PersistedLayoutState } from "../schema/types.js";
9
+ export interface LayoutStateStore {
10
+ get(layoutId: string): PersistedLayoutState | undefined;
11
+ set(layoutId: string, state: PersistedLayoutState): void;
12
+ patchPanel(layoutId: string, slot: string, patch: Partial<PersistedLayoutState["panels"][string]>): PersistedLayoutState;
13
+ }
14
+ /** In-memory store; optionally mirrors to localStorage when available. */
15
+ export declare function createMemoryLayoutStateStore(opts?: {
16
+ persistKey?: string;
17
+ }): LayoutStateStore;
@@ -0,0 +1,9 @@
1
+ import type { Breakpoint, LayoutViewport } from "../schema/types.js";
2
+ export declare function breakpointForWidth(width: number): Breakpoint;
3
+ export interface UseViewportOptions {
4
+ /** Initial value used before mount / on the server. */
5
+ initial?: LayoutViewport;
6
+ /** Resize debounce in ms. */
7
+ debounceMs?: number;
8
+ }
9
+ export declare function useViewport(opts?: UseViewportOptions): LayoutViewport;