@littlepress/renderer-web 0.0.0-stage → 1.0.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 (187) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +20 -0
  3. package/README.md +229 -2
  4. package/dist/answer/answerComponents.d.ts +107 -0
  5. package/dist/answer/answerComponents.js +637 -0
  6. package/dist/answer/download.d.ts +63 -0
  7. package/dist/answer/download.js +109 -0
  8. package/dist/answer/downloadExport.d.ts +44 -0
  9. package/dist/answer/downloadExport.js +266 -0
  10. package/dist/answer/hostValues.d.ts +28 -0
  11. package/dist/answer/hostValues.js +379 -0
  12. package/dist/answer/mapComponent.d.ts +6 -0
  13. package/dist/answer/mapComponent.js +213 -0
  14. package/dist/answer/math.d.ts +57 -0
  15. package/dist/answer/math.js +168 -0
  16. package/dist/answer/surfaceStream.d.ts +51 -0
  17. package/dist/answer/surfaceStream.js +260 -0
  18. package/dist/answer/tableLayout.d.ts +42 -0
  19. package/dist/answer/tableLayout.js +89 -0
  20. package/dist/controls/ActionFeedback.d.ts +5 -0
  21. package/dist/controls/ActionFeedback.js +43 -0
  22. package/dist/controls/actionDispatch.d.ts +51 -0
  23. package/dist/controls/actionDispatch.js +211 -0
  24. package/dist/controls/actionOutcome.generated.d.ts +64 -0
  25. package/dist/controls/actionOutcome.generated.js +64 -0
  26. package/dist/controls/calculationPublisher.d.ts +14 -0
  27. package/dist/controls/calculationPublisher.js +6 -0
  28. package/dist/controls/calculations.d.ts +20 -0
  29. package/dist/controls/calculations.generated.d.ts +73 -0
  30. package/dist/controls/calculations.generated.js +85 -0
  31. package/dist/controls/calculations.js +208 -0
  32. package/dist/controls/controlState.d.ts +84 -0
  33. package/dist/controls/controlState.js +256 -0
  34. package/dist/controls/fieldMessages.d.ts +41 -0
  35. package/dist/controls/fieldMessages.js +81 -0
  36. package/dist/controls/fieldValidation.d.ts +19 -0
  37. package/dist/controls/fieldValidation.js +98 -0
  38. package/dist/controls/formComponents.d.ts +23 -0
  39. package/dist/controls/formComponents.js +738 -0
  40. package/dist/controls/formProgress.d.ts +63 -0
  41. package/dist/controls/formProgress.js +122 -0
  42. package/dist/controls/inputDrafts.d.ts +55 -0
  43. package/dist/controls/inputDrafts.js +183 -0
  44. package/dist/controls/inputValidation.d.ts +33 -0
  45. package/dist/controls/inputValidation.js +119 -0
  46. package/dist/controls/localWrites.d.ts +9 -0
  47. package/dist/controls/localWrites.js +29 -0
  48. package/dist/core/A2uiSurface.d.ts +13 -0
  49. package/dist/core/A2uiSurface.js +15 -0
  50. package/dist/core/AtlasIcon.d.ts +18 -0
  51. package/dist/core/AtlasIcon.js +22 -0
  52. package/dist/core/AtlasMedia.d.ts +22 -0
  53. package/dist/core/AtlasMedia.js +45 -0
  54. package/dist/core/Carousel.d.ts +61 -0
  55. package/dist/core/Carousel.js +183 -0
  56. package/dist/core/CoreMedia.d.ts +19 -0
  57. package/dist/core/CoreMedia.js +25 -0
  58. package/dist/core/FoundationA2uiSurface.d.ts +86 -0
  59. package/dist/core/FoundationA2uiSurface.js +440 -0
  60. package/dist/core/ImagePreview.d.ts +42 -0
  61. package/dist/core/ImagePreview.js +73 -0
  62. package/dist/core/LucideIcon.d.ts +19 -0
  63. package/dist/core/LucideIcon.js +42 -0
  64. package/dist/core/SurfaceLink.d.ts +35 -0
  65. package/dist/core/SurfaceLink.js +60 -0
  66. package/dist/core/appearance/aegis.d.ts +49 -0
  67. package/dist/core/appearance/aegis.js +34 -0
  68. package/dist/core/appearance/colour.d.ts +24 -0
  69. package/dist/core/appearance/colour.js +103 -0
  70. package/dist/core/appearance/css.d.ts +17 -0
  71. package/dist/core/appearance/css.js +153 -0
  72. package/dist/core/appearance/presets.generated.d.ts +4 -0
  73. package/dist/core/appearance/presets.generated.js +1184 -0
  74. package/dist/core/appearance/react.d.ts +29 -0
  75. package/dist/core/appearance/react.js +110 -0
  76. package/dist/core/appearance/resolve.d.ts +76 -0
  77. package/dist/core/appearance/resolve.js +127 -0
  78. package/dist/core/appearance/textScale.d.ts +11 -0
  79. package/dist/core/appearance/textScale.js +51 -0
  80. package/dist/core/appearance/theme.d.ts +138 -0
  81. package/dist/core/appearance/theme.js +274 -0
  82. package/dist/core/baseComponents.d.ts +53 -0
  83. package/dist/core/baseComponents.js +480 -0
  84. package/dist/core/binding.d.ts +46 -0
  85. package/dist/core/binding.js +118 -0
  86. package/dist/core/bundle.d.ts +23 -0
  87. package/dist/core/bundle.js +75 -0
  88. package/dist/core/catalog/catalog-index.generated.d.ts +44 -0
  89. package/dist/core/catalog/catalog-index.generated.js +79 -0
  90. package/dist/core/catalog/icons.generated.d.ts +6 -0
  91. package/dist/core/catalog/icons.generated.js +1788 -0
  92. package/dist/core/catalog.d.ts +6 -0
  93. package/dist/core/catalog.generated.d.ts +50 -0
  94. package/dist/core/catalog.generated.js +2174 -0
  95. package/dist/core/catalog.js +8 -0
  96. package/dist/core/chartRows.d.ts +7 -0
  97. package/dist/core/chartRows.js +38 -0
  98. package/dist/core/component-support.d.ts +39 -0
  99. package/dist/core/component-support.js +127 -0
  100. package/dist/core/components/actions.d.ts +4 -0
  101. package/dist/core/components/actions.js +21 -0
  102. package/dist/core/components/cards.d.ts +9 -0
  103. package/dist/core/components/cards.js +227 -0
  104. package/dist/core/components/charts.d.ts +18 -0
  105. package/dist/core/components/charts.js +412 -0
  106. package/dist/core/components/comparisonTable.d.ts +50 -0
  107. package/dist/core/components/comparisonTable.js +89 -0
  108. package/dist/core/components/content.d.ts +13 -0
  109. package/dist/core/components/content.js +108 -0
  110. package/dist/core/components/seriesCharts.d.ts +531 -0
  111. package/dist/core/components/seriesCharts.js +1053 -0
  112. package/dist/core/components/stepFlow.d.ts +7 -0
  113. package/dist/core/components/stepFlow.js +13 -0
  114. package/dist/core/components.full.d.ts +10 -0
  115. package/dist/core/components.full.js +41 -0
  116. package/dist/core/context.d.ts +207 -0
  117. package/dist/core/context.js +172 -0
  118. package/dist/core/coverage.d.ts +30 -0
  119. package/dist/core/coverage.js +93 -0
  120. package/dist/core/foundation.d.ts +21 -0
  121. package/dist/core/foundation.js +22 -0
  122. package/dist/core/fullTheme.d.ts +5 -0
  123. package/dist/core/fullTheme.js +9 -0
  124. package/dist/core/iconNodes.generated.d.ts +7 -0
  125. package/dist/core/iconNodes.generated.js +5 -0
  126. package/dist/core/lucideIcons.d.ts +5 -0
  127. package/dist/core/lucideIcons.js +7 -0
  128. package/dist/core/messages.d.ts +111 -0
  129. package/dist/core/messages.js +134 -0
  130. package/dist/core/pointer.d.ts +17 -0
  131. package/dist/core/pointer.js +104 -0
  132. package/dist/core/registry.d.ts +12 -0
  133. package/dist/core/registry.js +114 -0
  134. package/dist/core/runtime.d.ts +8 -0
  135. package/dist/core/runtime.js +6 -0
  136. package/dist/core/state.d.ts +73 -0
  137. package/dist/core/state.js +274 -0
  138. package/dist/core/surfaceMotion.d.ts +5 -0
  139. package/dist/core/surfaceMotion.js +46 -0
  140. package/dist/core/theme.d.ts +5 -0
  141. package/dist/core/theme.js +7 -0
  142. package/dist/core/useSurfaceImage.d.ts +20 -0
  143. package/dist/core/useSurfaceImage.js +65 -0
  144. package/dist/graph/RelationshipGraph.d.ts +14 -0
  145. package/dist/graph/RelationshipGraph.js +206 -0
  146. package/dist/graph/model.d.ts +20 -0
  147. package/dist/graph/model.js +36 -0
  148. package/dist/graph/program/assets.d.ts +3 -0
  149. package/dist/graph/program/assets.js +3 -0
  150. package/dist/graph/program/bridge.d.ts +6 -0
  151. package/dist/graph/program/bridge.generated.d.ts +136 -0
  152. package/dist/graph/program/bridge.generated.js +1 -0
  153. package/dist/graph/program/bridge.js +24 -0
  154. package/dist/graph/program/bridge.schema.json +717 -0
  155. package/dist/graph/program/bridgeValidator.cjs +2 -0
  156. package/dist/graph/program/bridgeValidator.d.cts +4 -0
  157. package/dist/graph/program/runner.d.ts +1 -0
  158. package/dist/graph/program/runner.html +2193 -0
  159. package/dist/graph/program/runner.js +157 -0
  160. package/dist/graph/program/runtime-manifest.json +1 -0
  161. package/dist/graph/program/view.d.ts +11 -0
  162. package/dist/graph/program/view.js +210 -0
  163. package/dist/graph/program/worker.d.ts +1 -0
  164. package/dist/graph/program/worker.js +2186 -0
  165. package/dist/index.d.ts +20 -0
  166. package/dist/index.js +45 -0
  167. package/dist/internal/dsh.d.ts +4 -0
  168. package/dist/internal/dsh.js +3 -0
  169. package/dist/internal/relationship-graph.d.ts +4 -0
  170. package/dist/internal/relationship-graph.js +7202 -0
  171. package/dist/page/layoutComponents.d.ts +6 -0
  172. package/dist/page/layoutComponents.js +123 -0
  173. package/dist/page/layoutGeometry.d.ts +68 -0
  174. package/dist/page/layoutGeometry.js +174 -0
  175. package/dist/page/pageFormat.d.ts +34 -0
  176. package/dist/page/pageFormat.js +119 -0
  177. package/dist/page/printFit.d.ts +81 -0
  178. package/dist/page/printFit.js +338 -0
  179. package/dist/react/index.d.ts +5 -0
  180. package/dist/react/index.js +2 -0
  181. package/dist/report/locate.d.ts +42 -0
  182. package/dist/report/locate.js +34 -0
  183. package/dist/styles/renderer.css +4580 -0
  184. package/licenses/LUCIDE-LICENSE.txt +43 -0
  185. package/licenses/QUICKJS-EMSCRIPTEN-LICENSE.txt +21 -0
  186. package/licenses/QUICKJS-VARIANT-LICENSE.txt +47 -0
  187. package/package.json +68 -3
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The state a step is drawn with. The renderers draw `done`, `current`, `pending` and
3
+ * `error`; any other value keeps the plain marker. Until 2026-09-23 the component
4
+ * description called a step not yet started `upcoming` while every renderer read
5
+ * `pending`, so a hand-written surface may still carry `upcoming`: it is read as `pending`.
6
+ */
7
+ export declare function stepFlowState(raw: string | null): string | null;
@@ -0,0 +1,13 @@
1
+ /*
2
+ * Step states for BenefitList_StepFlow (S26), free of React so the tests import it
3
+ * directly. Compose (`StepFields.state`) and SwiftUI (`stepFlowState`) apply the same rule.
4
+ */
5
+ /**
6
+ * The state a step is drawn with. The renderers draw `done`, `current`, `pending` and
7
+ * `error`; any other value keeps the plain marker. Until 2026-09-23 the component
8
+ * description called a step not yet started `upcoming` while every renderer read
9
+ * `pending`, so a hand-written surface may still carry `upcoming`: it is read as `pending`.
10
+ */
11
+ export function stepFlowState(raw) {
12
+ return raw === "upcoming" ? "pending" : raw;
13
+ }
@@ -0,0 +1,10 @@
1
+ import type { A2uiJsonObject } from "./foundation.ts";
2
+ import type { RendererRegistry } from "./runtime.tsx";
3
+ /**
4
+ * The single Atlas semantic registry entry.
5
+ *
6
+ * Renderers live with their semantic family. Component identifiers remain the
7
+ * canonical catalog identifiers consumed by Foundation and host applications.
8
+ */
9
+ export declare const semanticRendererRegistry: RendererRegistry;
10
+ export type { A2uiJsonObject };
@@ -0,0 +1,41 @@
1
+ import { renderBodyProse, renderFeatureImage, renderLede, renderArticleHeader, renderMediaGallery, renderNumberedSection, renderPullQuote, renderQuoteWall, renderStoryCover, renderTranscriptExcerpt, } from "./components/content.js";
2
+ import { renderChapterTimeline, renderChecklistCard, renderInsightCard, renderMetricRow, renderSourcesPanel, renderStepFlow, renderTermDeck, } from "./components/cards.js";
3
+ import { renderAreaChart, renderComparisonTable, renderDivergingBarChart, renderPieChart, renderScatterChart, renderRadialBarChart, renderQuadrantMap, renderRadarInsightChart, renderBarChart, renderLineChart, } from "./components/charts.js";
4
+ import { renderShareCta, renderStoryEndCard, } from "./components/actions.js";
5
+ /**
6
+ * The single Atlas semantic registry entry.
7
+ *
8
+ * Renderers live with their semantic family. Component identifiers remain the
9
+ * canonical catalog identifiers consumed by Foundation and host applications.
10
+ */
11
+ export const semanticRendererRegistry = Object.freeze({
12
+ PageHero_ArticleHeader: renderArticleHeader,
13
+ PageHero_StoryCover: renderStoryCover,
14
+ LedeParagraph_EditorialLede: renderLede,
15
+ BodySection_BodyProse: renderBodyProse,
16
+ PullQuote_PullQuote: renderPullQuote,
17
+ EditorialImage_FeatureImage: renderFeatureImage,
18
+ BenefitList_ChecklistCard: renderChecklistCard,
19
+ MetricStrip_MetricRow: renderMetricRow,
20
+ SourcesPanel_Default: renderSourcesPanel,
21
+ LPListRow_ChapterTimeline: renderChapterTimeline,
22
+ CtaBlock_ShareCta: renderShareCta,
23
+ CtaBlock_StoryEndCard: renderStoryEndCard,
24
+ BodySection_NumberedSection: renderNumberedSection,
25
+ BenefitList_TermDeck: renderTermDeck,
26
+ PullQuote_QuoteWall: renderQuoteWall,
27
+ MediaGallery_MediaGallery: renderMediaGallery,
28
+ InsightCard_Default: renderInsightCard,
29
+ TranscriptExcerpt_Default: renderTranscriptExcerpt,
30
+ InsightChart_BarChart: renderBarChart,
31
+ InsightChart_LineChart: renderLineChart,
32
+ InsightChart_AreaChart: renderAreaChart,
33
+ InsightChart_PieChart: renderPieChart,
34
+ InsightChart_ScatterChart: renderScatterChart,
35
+ InsightChart_RadialBarChart: renderRadialBarChart,
36
+ InsightChart_RadarInsightChart: renderRadarInsightChart,
37
+ InsightChart_QuadrantMap: renderQuadrantMap,
38
+ InsightChart_DivergingBarChart: renderDivergingBarChart,
39
+ ComparisonTable_Default: renderComparisonTable,
40
+ BenefitList_StepFlow: renderStepFlow,
41
+ });
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Render-time plumbing shared by every component renderer: the binding context
3
+ * for the row currently being drawn, the action channel, and the guards that
4
+ * keep a malformed component graph from hanging the browser.
5
+ */
6
+ import type { ReactNode } from "react";
7
+ import { type A2uiComponent, type A2uiJsonObject } from "./messages.ts";
8
+ import { type BindingContext, type ValueFunction } from "./binding.ts";
9
+ import type { A2uiSurfaceState } from "./state.ts";
10
+ import { type ActionSession } from "../controls/actionDispatch.ts";
11
+ /** What the host receives when the user triggers a component action. */
12
+ export type ResolvedAction = {
13
+ /** `event` is a Host business action (local or remote); `functionCall` is a catalog client effect. */
14
+ kind: "event" | "functionCall";
15
+ /** Event name, or client function name. */
16
+ name: string;
17
+ /** Event context with bindings resolved, or the function's resolved args. */
18
+ payload: A2uiJsonObject;
19
+ /** LittlePress action policy resolved separately from the business payload. */
20
+ metadata: A2uiJsonObject;
21
+ surfaceId: string | null;
22
+ componentId: string;
23
+ component: string;
24
+ /** Stable identity declared by this component or its nearest row template; never an index. */
25
+ itemId?: string;
26
+ /**
27
+ * Which of a component's several actions this is, when it has more than one of the same
28
+ * kind and name: a link span's path in the props, such as `content/5`.
29
+ */
30
+ actionKey?: string;
31
+ };
32
+ /** A host may complete an action immediately or report asynchronous completion. */
33
+ export type ResolvedActionCallback = (action: ResolvedAction) => void | Promise<void>;
34
+ export type ActionClickHandler = (() => void) & {
35
+ disabled?: boolean;
36
+ pending?: boolean;
37
+ };
38
+ export type A2uiInputValue = string | number | boolean | string[];
39
+ export type A2uiInputChange = {
40
+ surfaceId: string | null;
41
+ componentId: string;
42
+ component: string;
43
+ fieldId: string;
44
+ path: string;
45
+ value: A2uiInputValue;
46
+ valid: boolean;
47
+ errorCode: string | null;
48
+ /** Stable identity of the nearest row, when the rendered field has one. */
49
+ itemId?: string;
50
+ };
51
+ export type A2uiInputChangeHandler = (change: A2uiInputChange) => void;
52
+ /**
53
+ * What a form tells its fields. A field the user has not changed keeps its local message to
54
+ * itself until the form refuses a submit (`showErrors`), so an untouched field is never shown
55
+ * as an error early; its native validity is set all along.
56
+ */
57
+ export type FormFeedback = {
58
+ showErrors: boolean;
59
+ /** Draft keys (`renderedFieldKey`) of the fields the user has changed. */
60
+ touched: ReadonlySet<string>;
61
+ touch: (key: string) => void;
62
+ };
63
+ /**
64
+ * How layout containers materialize. "print" = fixed page in points, absolute
65
+ * slots, plan-driven type scale; "flow" = the same components as one scrolling
66
+ * column, print geometry ignored. Semantic components render identically.
67
+ */
68
+ export type LayoutRenderMode = "print" | "flow";
69
+ export type AegisBlockRenderProps = {
70
+ componentId: string;
71
+ artifact: A2uiJsonObject;
72
+ fallbackText: string;
73
+ maxHeight?: number;
74
+ };
75
+ export type AegisBlockRenderer = (props: AegisBlockRenderProps) => ReactNode;
76
+ /** How a Host's save ended: `cancelled` when the user backed out, which is not an error. */
77
+ export type SaveFileResult = "saved" | "cancelled";
78
+ /**
79
+ * Saves a file an `LPDownload_Default` wrote on the device: its cleaned `name` (with the
80
+ * format's extension), `mime` (`text/csv;charset=utf-8` or `application/json`) and bytes.
81
+ * Resolve with `cancelled` when the user backs out (nothing is shown), with `saved` or nothing
82
+ * once it is saved, and reject when it fails (the button shows an error).
83
+ */
84
+ export type SaveFileHandler = (name: string, mime: string, bytes: Uint8Array) => void | SaveFileResult | Promise<void | SaveFileResult>;
85
+ /** Host-supplied image loader returning a displayable src (e.g. blob/data URL) or null. */
86
+ export type SurfaceImageLoader = (url: string) => Promise<string | null> | string | null;
87
+ export type MapPlace = {
88
+ id: string;
89
+ name: string;
90
+ lat: number;
91
+ lng: number;
92
+ address?: string;
93
+ day?: string | number;
94
+ order?: number;
95
+ url?: string;
96
+ };
97
+ export type MapPlaceGroup = {
98
+ key: string;
99
+ label: string | null;
100
+ places: readonly MapPlace[];
101
+ };
102
+ export type MapAdapterProps = {
103
+ componentId: string;
104
+ title?: string;
105
+ places: readonly MapPlace[];
106
+ groups: readonly MapPlaceGroup[];
107
+ connectRoute: boolean;
108
+ selectedPlaceId: string | null;
109
+ onSelectPlace: (placeId: string | null) => void;
110
+ onOpenUrl?: (place: MapPlace) => void;
111
+ onFail: (reason?: string) => void;
112
+ };
113
+ export type MapAdapterRenderer = (props: MapAdapterProps) => ReactNode;
114
+ export type RenderContext = {
115
+ state: A2uiSurfaceState;
116
+ registry: RendererRegistry;
117
+ componentMetadata?: Readonly<Record<string, {
118
+ printMode?: string;
119
+ }>>;
120
+ binding: BindingContext;
121
+ /** Identity resolved from the nearest row template's itemId binding. */
122
+ itemId?: string;
123
+ /**
124
+ * Inside a composed row: a repeated row whose template is not `lp.list-row` (a model-composed
125
+ * `ui-list` row), including its static descendants. Its layout rules and action identity
126
+ * differ from other content; see `docs/architecture/renderer-visual-contract.md`.
127
+ */
128
+ composedRow?: boolean;
129
+ /** The id of the template component a composed row repeats: only that root may be tappable (R7). */
130
+ composedRowRoot?: string;
131
+ valueFunctions?: Readonly<Record<string, ValueFunction>>;
132
+ onAction: ResolvedActionCallback;
133
+ /** Handles renderer-local actions (`toggleLocalFlag`, `setValue`, `copyText`); returns true when handled. */
134
+ onLocalAction?: (action: ResolvedAction) => boolean;
135
+ /** Optional Host renderer for inline `LPAegisBlock_Default` nodes (keeps Aegis optional). */
136
+ renderAegisBlock?: AegisBlockRenderer;
137
+ /** The Host's save for `LPDownload_Default`; without one the browser downloads the file. */
138
+ saveFile?: SaveFileHandler;
139
+ /** Host-supplied preloaded images keyed by exact HTTPS URL (no network fetches). */
140
+ images?: Readonly<Record<string, string>>;
141
+ /** Optional Host image loader invoked only when interactive and not streaming. */
142
+ imageLoader?: SurfaceImageLoader;
143
+ /** Optional Host map adapter for `LPMap_Default` nodes (SDK ships no vendor map or API key). */
144
+ renderMap?: MapAdapterRenderer;
145
+ /** Component IDs of the first 3 visible Aegis blocks admitted for this surface. */
146
+ admittedAegisBlockIds?: ReadonlySet<string>;
147
+ /** Present only on the explicit-outcome path. */
148
+ actionSession?: ActionSession;
149
+ /** Stable render-tree position from root (e.g. `root/0/1`) so shared templates distinguish each rendered slot. */
150
+ renderPath?: string;
151
+ /** Render locations of ancestors, including their own repeated-row context. */
152
+ actionScopes?: Readonly<Record<string, string>>;
153
+ onInputChange?: A2uiInputChangeHandler;
154
+ /** Set by the enclosing form: which of its fields show their local message yet. */
155
+ form?: FormFeedback;
156
+ /** Fields holding a stale draft (see `reconcileInputDrafts`) keep their values while dependent actions are paused. */
157
+ blockedInputPaths?: ReadonlySet<string>;
158
+ blockedFormKeys?: ReadonlySet<string>;
159
+ /** Resolved by A2uiSurface: explicit prop, else the page's own pageScrollable. */
160
+ layout: LayoutRenderMode;
161
+ depth: number;
162
+ /** Component ids on the current path — a cheap cycle guard. */
163
+ ancestors: readonly string[];
164
+ /**
165
+ * DOM id prefix owned by the mounted surface, used to give locatable headings an id.
166
+ * Null inside repeated rows: a component drawn once per row cannot have one id.
167
+ */
168
+ anchorPrefix?: string | null;
169
+ };
170
+ /** Depth cap. Real surfaces sit at 3-4; anything deeper is a malformed graph. */
171
+ export declare const maxRenderDepth = 32;
172
+ export declare function childContext(context: RenderContext, componentId: string, itemPointer?: string | null, childSlot?: number | string): RenderContext;
173
+ /**
174
+ * Turns a catalog `Action` into a host-facing event.
175
+ *
176
+ * `extraContext` is reserved for renderer-owned interaction metadata that the
177
+ * catalog explicitly defines. Business identity always comes from stable data
178
+ * bindings rather than a row index.
179
+ */
180
+ export declare function resolveAction(action: unknown, component: A2uiComponent, context: RenderContext, extraContext?: A2uiJsonObject, actionKey?: string): ResolvedAction | null;
181
+ /**
182
+ * Pause a form's submit while a field inside it holds a stale draft, and any action that
183
+ * reads such a field. Field validity never pauses anything here: a form's submit stops on
184
+ * the browser's constraint validation, and the Host validates every action payload.
185
+ */
186
+ export declare function actionIsBlocked(action: unknown, component: A2uiComponent, context: RenderContext): boolean;
187
+ export declare function actionHandler(action: unknown, component: A2uiComponent, context: RenderContext, extraContext?: A2uiJsonObject, actionKey?: string): ActionClickHandler | undefined;
188
+ export type FallbackStrategy = "hide" | "replace_with_text" | "render_degraded";
189
+ export type ComponentFallback = {
190
+ strategy: FallbackStrategy;
191
+ text?: string;
192
+ };
193
+ /**
194
+ * Reads the catalog's `fallback` property. A2UI v1.0's `ComponentCommon` has no
195
+ * fallback concept (ADR 0004 gap 2), so it is inlined per component in the
196
+ * catalog extension and honored here.
197
+ */
198
+ export declare function readFallback(component: A2uiComponent): ComponentFallback | null;
199
+ export type ComponentRenderer = (component: A2uiComponent, context: RenderContext) => ReactNode;
200
+ export type RendererRegistry = Readonly<Record<string, ComponentRenderer>>;
201
+ export declare class RendererRegistryCollisionError extends Error {
202
+ readonly componentNames: readonly string[];
203
+ constructor(componentNames: readonly string[]);
204
+ }
205
+ /** Compose independently-owned registries and fail loudly on ambiguous names. */
206
+ export declare function composeRendererRegistries(...registries: readonly RendererRegistry[]): RendererRegistry;
207
+ export declare function knownComponentsForRegistry(registry: RendererRegistry): ReadonlySet<string>;
@@ -0,0 +1,172 @@
1
+ import { isRecord, isDataBinding, isFunctionCall, } from "./messages.js";
2
+ import { readBindingPointer, resolveValue } from "./binding.js";
3
+ import { formKeyOf } from "../controls/inputDrafts.js";
4
+ import { surfaceIsStreaming } from "../controls/actionDispatch.js";
5
+ /** Depth cap. Real surfaces sit at 3-4; anything deeper is a malformed graph. */
6
+ export const maxRenderDepth = 32;
7
+ export function childContext(context, componentId, itemPointer, childSlot) {
8
+ const parentPath = context.renderPath ?? "root";
9
+ return {
10
+ ...context,
11
+ depth: context.depth + 1,
12
+ ancestors: [...context.ancestors, componentId],
13
+ renderPath: `${parentPath}/${childSlot ?? componentId}`,
14
+ binding: itemPointer === undefined ? context.binding : { ...context.binding, itemPointer },
15
+ itemId: itemPointer === undefined ? context.itemId : undefined,
16
+ anchorPrefix: itemPointer === undefined ? context.anchorPrefix : null,
17
+ };
18
+ }
19
+ function resolveContextRecord(value, context) {
20
+ if (!isRecord(value))
21
+ return {};
22
+ const resolved = {};
23
+ for (const [key, entry] of Object.entries(value)) {
24
+ resolved[key] = resolveValue(entry, context.binding, context.valueFunctions);
25
+ }
26
+ return resolved;
27
+ }
28
+ function splitActionContext(resolved, extraContext) {
29
+ const metadata = isRecord(resolved._littlepress) ? resolved._littlepress : {};
30
+ const payload = Object.fromEntries(Object.entries(resolved).filter(([key]) => key !== "_littlepress"));
31
+ return { payload: { ...payload, ...extraContext }, metadata };
32
+ }
33
+ /**
34
+ * Turns a catalog `Action` into a host-facing event.
35
+ *
36
+ * `extraContext` is reserved for renderer-owned interaction metadata that the
37
+ * catalog explicitly defines. Business identity always comes from stable data
38
+ * bindings rather than a row index.
39
+ */
40
+ export function resolveAction(action, component, context, extraContext = {}, actionKey) {
41
+ if (!isRecord(action))
42
+ return null;
43
+ const typed = action;
44
+ const declaredItemId = component.itemId === undefined
45
+ ? context.itemId
46
+ : resolveValue(component.itemId, context.binding, context.valueFunctions);
47
+ const identity = {
48
+ ...(typeof declaredItemId === "string" && declaredItemId.trim() ? { itemId: declaredItemId } : {}),
49
+ ...(actionKey ? { actionKey } : {}),
50
+ };
51
+ if (isRecord(typed.event) && typeof typed.event.name === "string") {
52
+ const { payload, metadata } = splitActionContext(resolveContextRecord(typed.event.context, context), extraContext);
53
+ return {
54
+ kind: "event",
55
+ name: typed.event.name,
56
+ payload,
57
+ metadata,
58
+ surfaceId: context.state.surfaceId,
59
+ componentId: component.id,
60
+ component: component.component,
61
+ ...identity,
62
+ };
63
+ }
64
+ if (isRecord(typed.functionCall) && typeof typed.functionCall.call === "string") {
65
+ const { payload, metadata } = splitActionContext(resolveContextRecord(typed.functionCall.args, context), extraContext);
66
+ return {
67
+ kind: "functionCall",
68
+ name: typed.functionCall.call,
69
+ payload,
70
+ metadata,
71
+ surfaceId: context.state.surfaceId,
72
+ componentId: component.id,
73
+ component: component.component,
74
+ ...identity,
75
+ };
76
+ }
77
+ return null;
78
+ }
79
+ /**
80
+ * Pause a form's submit while a field inside it holds a stale draft, and any action that
81
+ * reads such a field. Field validity never pauses anything here: a form's submit stops on
82
+ * the browser's constraint validation, and the Host validates every action payload.
83
+ */
84
+ export function actionIsBlocked(action, component, context) {
85
+ const paths = context.blockedInputPaths;
86
+ if (["lp.form", "LPForm_Default"].includes(component.component) && context.blockedFormKeys?.has(formKeyOf(component.id, context.itemId)))
87
+ return true;
88
+ if (!isRecord(action) || !paths?.size)
89
+ return false;
90
+ const record = isRecord(action.event) ? action.event.context : isRecord(action.functionCall) ? action.functionCall.args : null;
91
+ if (!isRecord(record))
92
+ return false;
93
+ function readsBlocked(value) {
94
+ if (isDataBinding(value)) {
95
+ const pointer = readBindingPointer(value, context.binding);
96
+ return pointer !== null && [...paths].some(path => pointer === path || path.startsWith(pointer + "/") || pointer.startsWith(path + "/"));
97
+ }
98
+ return isFunctionCall(value) && isRecord(value.args) && Object.values(value.args).some(readsBlocked);
99
+ }
100
+ return Object.entries(record).some(([key, value]) => key !== "_littlepress" && readsBlocked(value));
101
+ }
102
+ const localActionFunctions = new Set(["toggleLocalFlag", "setValue", "copyText"]);
103
+ /** Answer Host events whose row/button affordance is omitted when the Host does not handle them. */
104
+ const optionalHostEvents = new Set(["openFile"]);
105
+ export function actionHandler(action, component, context, extraContext = {}, actionKey) {
106
+ if (actionIsBlocked(action, component, context))
107
+ return undefined;
108
+ const resolved = resolveAction(action, component, context, extraContext, actionKey);
109
+ if (!resolved)
110
+ return undefined;
111
+ const streaming = surfaceIsStreaming(context.state);
112
+ if (resolved.kind === "functionCall" && localActionFunctions.has(resolved.name) && context.onLocalAction) {
113
+ return Object.assign(() => { if (!streaming)
114
+ context.onLocalAction?.(resolved); }, { disabled: streaming, pending: false });
115
+ }
116
+ if (context.actionSession) {
117
+ if (resolved.kind === "event" && optionalHostEvents.has(resolved.name) && !context.actionSession.hostAccepts(resolved)) {
118
+ return undefined;
119
+ }
120
+ const disabled = streaming || context.actionSession.blocked(resolved, context);
121
+ return Object.assign(() => { if (!streaming)
122
+ context.actionSession.dispatch(resolved, context); }, {
123
+ disabled, pending: context.actionSession.pending(resolved, context),
124
+ });
125
+ }
126
+ if (resolved.kind === "event" && optionalHostEvents.has(resolved.name)) {
127
+ return undefined;
128
+ }
129
+ return Object.assign(() => { if (!streaming)
130
+ context.onAction(resolved); }, { disabled: streaming, pending: false });
131
+ }
132
+ /**
133
+ * Reads the catalog's `fallback` property. A2UI v1.0's `ComponentCommon` has no
134
+ * fallback concept (ADR 0004 gap 2), so it is inlined per component in the
135
+ * catalog extension and honored here.
136
+ */
137
+ export function readFallback(component) {
138
+ const value = component.fallback;
139
+ if (!isRecord(value))
140
+ return null;
141
+ const strategy = value.strategy;
142
+ if (strategy !== "hide" && strategy !== "replace_with_text" && strategy !== "render_degraded")
143
+ return null;
144
+ return { strategy, text: typeof value.text === "string" ? value.text : undefined };
145
+ }
146
+ export class RendererRegistryCollisionError extends Error {
147
+ componentNames;
148
+ constructor(componentNames) {
149
+ super(`Renderer registry collision: ${componentNames.join(", ")}`);
150
+ this.name = "RendererRegistryCollisionError";
151
+ this.componentNames = componentNames;
152
+ }
153
+ }
154
+ /** Compose independently-owned registries and fail loudly on ambiguous names. */
155
+ export function composeRendererRegistries(...registries) {
156
+ const composed = {};
157
+ const collisions = new Set();
158
+ for (const registry of registries) {
159
+ for (const [name, renderer] of Object.entries(registry)) {
160
+ if (name in composed)
161
+ collisions.add(name);
162
+ else
163
+ composed[name] = renderer;
164
+ }
165
+ }
166
+ if (collisions.size > 0)
167
+ throw new RendererRegistryCollisionError([...collisions].sort());
168
+ return Object.freeze(composed);
169
+ }
170
+ export function knownComponentsForRegistry(registry) {
171
+ return new Set(Object.keys(registry));
172
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Atlas semantic components rendered by the Web renderer.
3
+ *
4
+ * `react/components.tsx` composes the Atlas semantic groups into one registry.
5
+ * Unknown component names fall through to Foundation's single placeholder,
6
+ * which reports an `unsupported_component` diagnostic instead of crashing.
7
+ */
8
+ import { type RendererArchetype, type RendererCatalogEntry } from "./catalog/catalog-index.generated.ts";
9
+ export type CoverageReason = "spike_fixture" | "shared_example" | "archetype_representative" | "print_calibration";
10
+ export type CoveredComponent = RendererCatalogEntry & {
11
+ reason: CoverageReason;
12
+ /** One line on why this component is in the first batch. */
13
+ note: string;
14
+ };
15
+ export declare const coveredComponents: readonly CoveredComponent[];
16
+ export declare const coveredComponentIds: ReadonlySet<string>;
17
+ export declare function isCoveredComponent(component: string): boolean;
18
+ /** Remaining meta atoms: rendered by the placeholder card until a real surface needs them directly. */
19
+ export declare const uncoveredComponents: readonly RendererCatalogEntry[];
20
+ export type CoverageReport = {
21
+ catalogTotal: number;
22
+ coveredTotal: number;
23
+ uncoveredTotal: number;
24
+ byArchetype: {
25
+ archetype: RendererArchetype;
26
+ covered: number;
27
+ total: number;
28
+ }[];
29
+ };
30
+ export declare function describeCoverage(): CoverageReport;
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Atlas semantic components rendered by the Web renderer.
3
+ *
4
+ * `react/components.tsx` composes the Atlas semantic groups into one registry.
5
+ * Unknown component names fall through to Foundation's single placeholder,
6
+ * which reports an `unsupported_component` diagnostic instead of crashing.
7
+ */
8
+ import { rendererCatalog } from "./catalog/catalog-index.generated.js";
9
+ /** Batch 1. Order is presentation order in the coverage report, not render order. */
10
+ const coverageSeeds = [
11
+ // --- spike fixture ---
12
+ { component: "LPStack_Default", reason: "spike_fixture", note: "根容器与 related 模板栈;固定 children 数组 + {componentId,path} 模板两条路径" },
13
+ { component: "LPCard_Default", reason: "archetype_representative", note: "Widget 容器;tone 与 padding 只走受控枚举,禁止卡片嵌套" },
14
+ { component: "LPGrid_Default", reason: "archetype_representative", note: "Widget 网格;1-3 列与最小内容宽度共同控制响应式降级" },
15
+ { component: "LPIcon_Default", reason: "archetype_representative", note: "受控 Lucide 图标原子;只接收 Atlas 枚举名,不接收远程 SVG" },
16
+ { component: "LPMetaRow_Default", reason: "archetype_representative", note: "图标 + 简短元信息;替代纯文本 AI 摘要行" },
17
+ { component: "LPChip_Default", reason: "archetype_representative", note: "Widget 状态胶囊;文本与语气均来自受控 contract" },
18
+ { component: "LPAsyncState_Default", reason: "archetype_representative", note: "Widget loading/error/empty 聚合状态;骨架与错误提示共享稳定几何" },
19
+ { component: "LPInputField_Default", reason: "archetype_representative", note: "Host-owned 受控输入;常见格式本地提示,最终提交与业务校验仍由宿主负责" },
20
+ { component: "PageHero_ArticleHeader", reason: "spike_fixture", note: "Article title, introduction, byline, and optional audio and share actions" },
21
+ { component: "LedeParagraph_EditorialLede", reason: "spike_fixture", note: "导语段;dropcap 开关" },
22
+ { component: "LPListRow_ChapterTimeline", reason: "spike_fixture", note: "章节时间线;整段列表绑 DynamicValue,行索引由渲染器隐式补进 event context" },
23
+ { component: "PullQuote_PullQuote", reason: "spike_fixture", note: "引文;逐字段绑 /data/quotes/0/*" },
24
+ { component: "LPListRow_Default", reason: "spike_fixture", note: "列表行模板;模板内使用相对指针" },
25
+ { component: "CtaBlock_ShareCta", reason: "spike_fixture", note: "分享 CTA;intent 双色轨" },
26
+ // --- hero archetype ---
27
+ { component: "PageHero_StoryCover", reason: "archetype_representative", note: "hero · 故事封面:三秒法则 kicker + title + start" },
28
+ // --- text_section archetype ---
29
+ { component: "LPText_Default", reason: "archetype_representative", note: "text · 角色化文本:role 即契约,禁任意字号" },
30
+ { component: "LPKicker_Default", reason: "archetype_representative", note: "text · 眉题:accent/plain 双 tone" },
31
+ { component: "BodySection_BodyProse", reason: "archetype_representative", note: "text · 正文段落:paragraphs[] + crosshead" },
32
+ { component: "LPDivider_Default", reason: "archetype_representative", note: "text · 规则线:hair/bold 两档,替代卡片做分区" },
33
+ // --- media archetype ---
34
+ { component: "LPImage_Default", reason: "archetype_representative", note: "media · 图像原子:alt 必填,比例走枚举档" },
35
+ { component: "EditorialImage_FeatureImage", reason: "archetype_representative", note: "media · 特写图:caption + mono credit 紧贴图下" },
36
+ // --- action archetype ---
37
+ { component: "LPButton_Default", reason: "archetype_representative", note: "action · 按钮原子:ink/accent/ghost 三 intent" },
38
+ // --- shared examples ---
39
+ { component: "LPPager_Default", reason: "shared_example", note: "paged_deck 根容器;indicator 圆点 + 逐页滚动" },
40
+ { component: "CtaBlock_StoryEndCard", reason: "shared_example", note: "故事结尾卡;share + replay 双动作" },
41
+ { component: "MetricStrip_MetricRow", reason: "shared_example", note: "data_viz · 指标条:2-4 格,编辑核算的结论" },
42
+ { component: "LPStat_Default", reason: "shared_example", note: "data_viz · 单指标原子:value + unit + caption" },
43
+ { component: "LPProgress_Default", reason: "archetype_representative", note: "data_viz · 确定型进度:typed index/total 绑定与原生 progress semantics" },
44
+ { component: "BenefitList_ChecklistCard", reason: "shared_example", note: "data_viz · 勾选清单变体" },
45
+ { component: "SourcesPanel_Default", reason: "shared_example", note: "card_group · 来源面板:title + url,合规可追溯" },
46
+ // --- N2 layout engine promotions ---
47
+ { component: "BodySection_NumberedSection", reason: "archetype_representative", note: "text · 编号章节:number + kicker + title + body,media_article 正文主力" },
48
+ { component: "BenefitList_TermDeck", reason: "archetype_representative", note: "card_group · 术语卡组:items[{title, body}] 网格" },
49
+ // --- semantic Atlas recipes ---
50
+ { component: "PullQuote_QuoteWall", reason: "print_calibration", note: "rows · 多条引语卡,逐格 clamp 与来源行" },
51
+ { component: "MediaGallery_MediaGallery", reason: "print_calibration", note: "media · 固定高度 gallery,图片 cover 与计数行" },
52
+ { component: "InsightCard_Default", reason: "print_calibration", note: "card_group · 观点卡五种语气共用一套几何" },
53
+ { component: "TranscriptExcerpt_Default", reason: "print_calibration", note: "rows · 时间戳、speaker 与证据摘录" },
54
+ { component: "InsightChart_BarChart", reason: "archetype_representative", note: "data_viz · 1-20 行 × 1-4 系列的分组 / 堆叠柱状;横向与纵向共用一套几何" },
55
+ { component: "InsightChart_LineChart", reason: "archetype_representative", note: "data_viz · 2-12 行 × 1-4 系列折线;每个系列配固定虚线,缺值断开" },
56
+ { component: "InsightChart_AreaChart", reason: "archetype_representative", note: "data_viz · 3-12 行 × 1-3 系列面积;叠加或堆叠,底边平贴基线" },
57
+ { component: "InsightChart_PieChart", reason: "archetype_representative", note: "data_viz · 2-6 个扇区按给定顺序;每项直接写名字和数值,不算占比" },
58
+ { component: "InsightChart_ScatterChart", reason: "archetype_representative", note: "data_viz · 2-50 行 × 1-4 系列散点;数值横轴,每个系列一种颜色和点形" },
59
+ { component: "InsightChart_RadialBarChart", reason: "archetype_representative", note: "data_viz · 1-4 条同心轨道;横向条形图的 8px 底槽绕成圆,弧端直角" },
60
+ { component: "InsightChart_RadarInsightChart", reason: "print_calibration", note: "data_viz · 5-6 轴 × 1-2 系列雷达与语义数据替代" },
61
+ { component: "InsightChart_QuadrantMap", reason: "print_calibration", note: "data_viz · 命名双轴的 2-24 点散点;variant=quadrant 加象限底色" },
62
+ { component: "InsightChart_DivergingBarChart", reason: "print_calibration", note: "data_viz · 左右极与成对数值" },
63
+ { component: "ComparisonTable_Default", reason: "print_calibration", note: "rows · 1-10 列 × 1-50 行的原生表格;行标签列固定,数字列右对齐,可带上期值" },
64
+ { component: "BenefitList_StepFlow", reason: "print_calibration", note: "rows · 2-5 步和当前进度" },
65
+ ];
66
+ const atlasByComponent = new Map(rendererCatalog.map((entry) => [entry.component, entry]));
67
+ export const coveredComponents = coverageSeeds.map((seed) => {
68
+ const entry = atlasByComponent.get(seed.component);
69
+ if (!entry) {
70
+ throw new Error(`Atlas renderer coverage lists "${seed.component}", which is not in the Atlas catalog export. ` +
71
+ "Regenerate src/catalog/catalog-index.generated.ts or fix the coverage list.");
72
+ }
73
+ return { ...entry, reason: seed.reason, note: seed.note };
74
+ });
75
+ export const coveredComponentIds = new Set(coveredComponents.map((entry) => entry.component));
76
+ export function isCoveredComponent(component) {
77
+ return coveredComponentIds.has(component);
78
+ }
79
+ /** Remaining meta atoms: rendered by the placeholder card until a real surface needs them directly. */
80
+ export const uncoveredComponents = rendererCatalog.filter((entry) => !coveredComponentIds.has(entry.component));
81
+ export function describeCoverage() {
82
+ const archetypes = [...new Set(rendererCatalog.map((entry) => entry.archetype))].sort();
83
+ return {
84
+ catalogTotal: rendererCatalog.length,
85
+ coveredTotal: coveredComponents.length,
86
+ uncoveredTotal: uncoveredComponents.length,
87
+ byArchetype: archetypes.map((archetype) => ({
88
+ archetype,
89
+ covered: coveredComponents.filter((entry) => entry.archetype === archetype).length,
90
+ total: rendererCatalog.filter((entry) => entry.archetype === archetype).length,
91
+ })),
92
+ };
93
+ }
@@ -0,0 +1,21 @@
1
+ /** DOM-free A2UI state, binding, local-artifact, and layout runtime. */
2
+ export * from "./messages.ts";
3
+ export * from "./pointer.ts";
4
+ export * from "./binding.ts";
5
+ export * from "./state.ts";
6
+ export * from "./bundle.ts";
7
+ export * from "../answer/surfaceStream.ts";
8
+ export * from "../page/pageFormat.ts";
9
+ export * from "../controls/inputValidation.ts";
10
+ export * from "../controls/fieldValidation.ts";
11
+ export * from "../page/layoutGeometry.ts";
12
+ export * from "./catalog.ts";
13
+ export * from "./theme.ts";
14
+ export * from "./lucideIcons.ts";
15
+ export declare const rendererVersion = "1.0.0";
16
+ /**
17
+ * Advertise only semantics implemented by this installed Web renderer. `list-row-thumbnail`:
18
+ * composed list rows draw side by side; `list-row-tap`: a composed row can be one button
19
+ * (`docs/architecture/renderer-visual-contract.md`).
20
+ */
21
+ export declare const rendererCapabilities: readonly string[];
@@ -0,0 +1,22 @@
1
+ import { calculationSpec } from "../controls/calculations.generated.js";
2
+ /** DOM-free A2UI state, binding, local-artifact, and layout runtime. */
3
+ export * from "./messages.js";
4
+ export * from "./pointer.js";
5
+ export * from "./binding.js";
6
+ export * from "./state.js";
7
+ export * from "./bundle.js";
8
+ export * from "../answer/surfaceStream.js";
9
+ export * from "../page/pageFormat.js";
10
+ export * from "../controls/inputValidation.js";
11
+ export * from "../controls/fieldValidation.js";
12
+ export * from "../page/layoutGeometry.js";
13
+ export * from "./catalog.js";
14
+ export * from "./theme.js";
15
+ export * from "./lucideIcons.js";
16
+ export const rendererVersion = "1.0.0";
17
+ /**
18
+ * Advertise only semantics implemented by this installed Web renderer. `list-row-thumbnail`:
19
+ * composed list rows draw side by side; `list-row-tap`: a composed row can be one button
20
+ * (`docs/architecture/renderer-visual-contract.md`).
21
+ */
22
+ export const rendererCapabilities = Object.freeze([calculationSpec.capability, "list-row-thumbnail", "list-row-tap"]);
@@ -0,0 +1,5 @@
1
+ export declare const rendererStylePacks: readonly ["neutral", "editorial", "minimal", "system", "m3"];
2
+ export type RendererStylePack = (typeof rendererStylePacks)[number];
3
+ export type RendererMode = "light" | "dark" | "system";
4
+ export declare function resolveStylePack(value: unknown): RendererStylePack;
5
+ export declare function resolveRendererMode(value: unknown): RendererMode;
@@ -0,0 +1,9 @@
1
+ export const rendererStylePacks = ["neutral", "editorial", "minimal", "system", "m3"];
2
+ export function resolveStylePack(value) {
3
+ return typeof value === "string" && rendererStylePacks.includes(value)
4
+ ? value
5
+ : "neutral";
6
+ }
7
+ export function resolveRendererMode(value) {
8
+ return value === "light" || value === "dark" || value === "system" ? value : "system";
9
+ }