@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,274 @@
1
+ /**
2
+ * The theme a Host gives the SDK: explicit values, no style-pack name. `checkTheme` applies the
3
+ * shape and contrast rules of ui-foundation/surface/contracts/schema/appearance.json; `completeTheme`
4
+ * fills every optional value so renderers never guess. See docs/architecture/host-appearance.md §4, §7.
5
+ */
6
+ import { contrastRatio, isHex, isHexAlpha, mix, over, withAlpha } from "./colour.js";
7
+ import { themePresets } from "./presets.generated.js";
8
+ export const themeSchema = "littlepress.theme/1";
9
+ export const requiredColours = [
10
+ "background", "surface", "surfaceVariant", "text", "textVariant", "accent", "onAccent", "outline",
11
+ "positive", "warning", "danger", "info", "series1", "series2", "series3", "series4",
12
+ ];
13
+ export const optionalColours = [
14
+ "highlight", "surfaceDisabled", "textDisabled", "onAccentVariant", "hover", "accentContainer",
15
+ ];
16
+ export const controlColours = [
17
+ "fill", "stroke", "active", "onActive", "tabSurface", "tabActiveSurface", "tabText", "tabActiveText",
18
+ "tabIndicator", "thumbFill",
19
+ ];
20
+ export const typeRoles = [
21
+ "display", "headline", "titleLarge", "titleSmall", "bodyLarge", "bodyMedium", "bodySmall", "labelLarge", "labelSmall",
22
+ ];
23
+ /** Text colour, the colour it sits on. Each pair must reach `minimumContrast` in both modes. */
24
+ export const contrastPairs = [
25
+ ["text", "background"], ["text", "surface"], ["text", "surfaceVariant"],
26
+ ["textVariant", "surface"], ["textVariant", "surfaceVariant"],
27
+ ["accent", "surface"], ["accent", "surfaceVariant"],
28
+ ["onAccent", "accent"],
29
+ ];
30
+ export const minimumContrast = 4.5;
31
+ export const minimumHighContrast = 7;
32
+ const number = (min, max, integer = false) => (value, path, problems) => {
33
+ if (typeof value !== "number" || !Number.isFinite(value) || (integer && !Number.isInteger(value))) {
34
+ problems.push({ path, code: "type" });
35
+ }
36
+ else if (value < min || value > max) {
37
+ problems.push({ path, code: "range" });
38
+ }
39
+ };
40
+ const oneOf = (...values) => (value, path, problems) => {
41
+ if (!values.includes(value))
42
+ problems.push({ path, code: "format" });
43
+ };
44
+ const hex = (value, path, problems) => { if (!isHex(value))
45
+ problems.push({ path, code: "format" }); };
46
+ const hexAlpha = (value, path, problems) => { if (!isHexAlpha(value))
47
+ problems.push({ path, code: "format" }); };
48
+ const text = (max) => (value, path, problems) => {
49
+ if (typeof value !== "string" || value.length === 0 || value.length > max)
50
+ problems.push({ path, code: "format" });
51
+ };
52
+ const boolean = (value, path, problems) => { if (typeof value !== "boolean")
53
+ problems.push({ path, code: "type" }); };
54
+ function object(fields, required = []) {
55
+ return (value, path, problems) => {
56
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
57
+ problems.push({ path, code: "type" });
58
+ return;
59
+ }
60
+ const record = value;
61
+ for (const key of required)
62
+ if (!(key in record))
63
+ problems.push({ path: join(path, key), code: "missing" });
64
+ for (const [key, item] of Object.entries(record)) {
65
+ const rule = fields[key];
66
+ if (!rule)
67
+ problems.push({ path: join(path, key), code: "unknown" });
68
+ else
69
+ rule(item, join(path, key), problems);
70
+ }
71
+ };
72
+ }
73
+ const join = (path, key) => (path ? `${path}.${key}` : key);
74
+ const each = (keys, rule) => Object.fromEntries(keys.map((key) => [key, rule]));
75
+ const shadow = (value, path, problems) => {
76
+ if (!Array.isArray(value) || value.length > 3) {
77
+ problems.push({ path, code: "type" });
78
+ return;
79
+ }
80
+ const layer = object({
81
+ x: number(-16, 16), y: number(-16, 16), blur: number(0, 48), spread: number(-16, 16), color: hexAlpha,
82
+ }, ["x", "y", "blur", "spread", "color"]);
83
+ value.forEach((item, index) => layer(item, `${path}.${index}`, problems));
84
+ };
85
+ const modeValues = object({
86
+ // The page background is the opaque base; every other colour may be translucent and is painted over it.
87
+ color: object({ ...each(requiredColours, hexAlpha), background: hex, ...each(optionalColours, hexAlpha) }, requiredColours),
88
+ highContrastColor: object(each(["textVariant", "accent", "onAccent", "outline"], hex)),
89
+ controlColor: object(each(controlColours, hexAlpha)),
90
+ shadow: object({ card: shadow, controlTab: shadow }),
91
+ }, ["color"]);
92
+ const themeShape = object({
93
+ schema: oneOf(themeSchema),
94
+ id: text(80),
95
+ light: modeValues,
96
+ dark: modeValues,
97
+ font: object(each(["display", "text"], object({ name: text(80), generic: oneOf("sans-serif", "serif") }, ["generic"]))),
98
+ type: object(each(typeRoles, object({
99
+ size: number(10, 72), lineHeight: number(1, 2), weight: number(300, 800, true), font: oneOf("display", "text"),
100
+ }, ["size", "lineHeight", "weight"]))),
101
+ tracking: object(each(["overline", "meta"], number(0, 0.3))),
102
+ space: object(each(["2xs", "xs", "sm", "md", "lg", "xl", "2xl", "blockGap"], number(0, 64))),
103
+ size: object({
104
+ control: number(32, 96), row: number(32, 120), avatar: number(16, 96), icon: number(12, 48), minTouchTarget: number(0, 160),
105
+ }),
106
+ radius: object(each(["control", "surface", "surfaceLarge", "pill"], number(0, 999))),
107
+ controls: object({
108
+ tabs: oneOf("underline", "segmented"),
109
+ tabsFullWidth: boolean,
110
+ fields: oneOf("standard", "filled"),
111
+ markRadius: number(0, 999), trackHeight: number(1, 16), thumbWidth: number(4, 40), thumbHeight: number(4, 40),
112
+ thumbRadius: number(0, 999), tabRadius: number(0, 999), tabTrackPadding: number(0, 8), tabSegmentRadius: number(0, 999),
113
+ tabPaddingX: number(0, 32), tabGap: number(0, 16), tabWeight: number(300, 800, true), tabActiveWeight: number(300, 800, true),
114
+ }),
115
+ }, ["schema", "light", "dark"]);
116
+ /**
117
+ * The required colours as the screen shows them: the surface over the page background, the variant
118
+ * surface over the surface, the accent over the surface, button text over the accent, and every other
119
+ * colour over the surface. Contrast and the derived colours are computed from these.
120
+ */
121
+ export function solidColours(color) {
122
+ const background = color.background;
123
+ const surface = over(color.surface, background);
124
+ const accent = over(color.accent, surface);
125
+ const solid = { background, surface, surfaceVariant: over(color.surfaceVariant, surface), accent, onAccent: over(color.onAccent, accent) };
126
+ for (const name of requiredColours)
127
+ if (!(name in solid))
128
+ solid[name] = over(color[name], surface);
129
+ return solid;
130
+ }
131
+ /** `foreground` as it shows on `background`: translucent text takes the colour beneath it. */
132
+ function shown(color, raw, foreground, background) {
133
+ return foreground === "onAccent" ? color.onAccent : over(raw[foreground], color[background]);
134
+ }
135
+ function contrastProblems(theme) {
136
+ const problems = [];
137
+ for (const mode of ["light", "dark"]) {
138
+ const raw = theme[mode].color;
139
+ const color = solidColours(raw);
140
+ for (const [foreground, background] of contrastPairs) {
141
+ const ratio = contrastRatio(shown(color, raw, foreground, background), color[background]);
142
+ if (ratio < minimumContrast) {
143
+ problems.push({
144
+ path: `${mode}.color.${foreground}`, code: "contrast", against: `${mode}.color.${background}`,
145
+ ratio: Math.round(ratio * 100) / 100, minimum: minimumContrast,
146
+ });
147
+ }
148
+ }
149
+ const high = theme[mode].highContrastColor;
150
+ if (high) {
151
+ const resolved = solidColours({ ...raw, ...high });
152
+ for (const [foreground, background] of contrastPairs) {
153
+ if (!(foreground in high) && !(background in high))
154
+ continue;
155
+ const ratio = contrastRatio(shown(resolved, { ...raw, ...high }, foreground, background), resolved[background]);
156
+ if (ratio < minimumHighContrast) {
157
+ const [own, other] = foreground in high ? [foreground, background] : [background, foreground];
158
+ problems.push({
159
+ path: `${mode}.highContrastColor.${own}`, code: "contrast",
160
+ against: `${mode}.${other in high ? "highContrastColor" : "color"}.${other}`,
161
+ ratio: Math.round(ratio * 100) / 100, minimum: minimumHighContrast,
162
+ });
163
+ }
164
+ }
165
+ }
166
+ }
167
+ return problems;
168
+ }
169
+ /**
170
+ * Every problem with `value` as a theme; an empty list means it is clean. `unknown` (a field this
171
+ * version does not know, for example a token a newer version added) does not stop the theme from
172
+ * being used: Hosts ignore the field and report it as a warning. Every other code refuses the
173
+ * theme. Tools that write themes treat any problem, `unknown` included, as an error.
174
+ */
175
+ export function checkTheme(value) {
176
+ const problems = [];
177
+ themeShape(value, "", problems);
178
+ return problems.some(refusesTheme) ? problems : [...problems, ...contrastProblems(value)];
179
+ }
180
+ /** Whether a problem stops the theme from being used. Only `unknown` does not. */
181
+ export function refusesTheme(problem) {
182
+ return problem.code !== "unknown";
183
+ }
184
+ /** `theme` without the fields `checkTheme` reported as `unknown`, so nothing unknown reaches drawing. */
185
+ export function withoutUnknownFields(theme, problems) {
186
+ const unknown = problems.filter((problem) => problem.code === "unknown");
187
+ if (unknown.length === 0)
188
+ return theme;
189
+ const copy = JSON.parse(JSON.stringify(theme));
190
+ for (const { path } of unknown)
191
+ removeAt(copy, path);
192
+ return copy;
193
+ }
194
+ /**
195
+ * Removes the field `path` names, following the theme's own keys level by level: a key that itself
196
+ * contains dots (`"radius.control"` at the top) is that one key, not the nested `radius.control`.
197
+ */
198
+ function removeAt(node, path) {
199
+ if (!node || typeof node !== "object")
200
+ return false;
201
+ const record = node;
202
+ if (Object.prototype.hasOwnProperty.call(record, path)) {
203
+ delete record[path];
204
+ return true;
205
+ }
206
+ for (const key of Object.keys(record)) {
207
+ if (path.startsWith(`${key}.`) && removeAt(record[key], path.slice(key.length + 1)))
208
+ return true;
209
+ }
210
+ return false;
211
+ }
212
+ /** Control sizes used when a theme draws filled fields or segmented tabs without giving them. */
213
+ const defaultControls = {
214
+ tabs: "underline", tabsFullWidth: false, fields: "standard",
215
+ markRadius: 4, trackHeight: 4, thumbWidth: 18, thumbHeight: 18, thumbRadius: 999, tabRadius: 8,
216
+ tabTrackPadding: 1, tabSegmentRadius: 7, tabPaddingX: 12, tabGap: 0, tabWeight: 400, tabActiveWeight: 600,
217
+ };
218
+ function completeMode(values, mode, controls) {
219
+ const c = values.color;
220
+ const solid = solidColours(c);
221
+ const color = {
222
+ ...c,
223
+ highlight: c.highlight ?? c.series4,
224
+ surfaceDisabled: c.surfaceDisabled ?? mix(solid.text, solid.surface, 0.08),
225
+ textDisabled: c.textDisabled ?? mix(solid.text, solid.surface, 0.45),
226
+ onAccentVariant: c.onAccentVariant ?? mix(solid.onAccent, solid.accent, 0.75),
227
+ hover: c.hover ?? withAlpha(solid.text, 0.06),
228
+ accentContainer: c.accentContainer ?? withAlpha(solid.accent, mode === "light" ? 0.12 : 0.16),
229
+ };
230
+ const given = values.controlColor ?? {};
231
+ const active = given.active ?? c.accent;
232
+ const controlColor = {
233
+ fill: given.fill ?? c.surface,
234
+ stroke: given.stroke ?? c.textVariant,
235
+ active,
236
+ onActive: given.onActive ?? c.onAccent,
237
+ tabSurface: given.tabSurface ?? withAlpha(solid.text, mode === "light" ? 0.05 : 0.06),
238
+ tabActiveSurface: given.tabActiveSurface ?? (mode === "light" ? c.surface : mix(solid.text, solid.surface, 0.14)),
239
+ tabText: given.tabText ?? c.textVariant,
240
+ tabActiveText: given.tabActiveText ?? c.text,
241
+ tabIndicator: given.tabIndicator ?? (controls.tabs === "underline" ? c.accent : "#00000000"),
242
+ thumbFill: given.thumbFill ?? active,
243
+ };
244
+ return {
245
+ color,
246
+ highContrastColor: { ...(values.highContrastColor ?? {}) },
247
+ controlColor,
248
+ shadow: {
249
+ card: values.shadow?.card ?? (mode === "light" ? [{ x: 0, y: 1, blur: 2, spread: 0, color: "#0000000A" }] : []),
250
+ controlTab: values.shadow?.controlTab ?? [{ x: 0, y: 0, blur: 0, spread: 1, color: c.outline }],
251
+ },
252
+ };
253
+ }
254
+ /** Fill every optional value of a checked theme. Absent values come from the default theme or the formulas above. */
255
+ export function completeTheme(theme) {
256
+ const base = themePresets.neutral;
257
+ const controls = { ...defaultControls, ...(theme.controls ?? {}) };
258
+ const type = Object.fromEntries(typeRoles.map((role) => {
259
+ const value = theme.type?.[role] ?? base.type[role];
260
+ return [role, { font: "display", ...value }];
261
+ }));
262
+ return {
263
+ id: theme.id ?? "custom",
264
+ light: completeMode(theme.light, "light", controls),
265
+ dark: completeMode(theme.dark, "dark", controls),
266
+ font: { display: theme.font?.display ?? base.font.display, text: theme.font?.text ?? base.font.text },
267
+ type,
268
+ tracking: { ...base.tracking, ...(theme.tracking ?? {}) },
269
+ space: { ...base.space, ...(theme.space ?? {}) },
270
+ size: { minTouchTarget: 0, ...base.size, ...(theme.size ?? {}) },
271
+ radius: { ...base.radius, ...(theme.radius ?? {}) },
272
+ controls,
273
+ };
274
+ }
@@ -0,0 +1,53 @@
1
+ import type { ReactNode } from "react";
2
+ import { type A2uiComponent, type A2uiJsonObject } from "./messages.ts";
3
+ import { type ComponentRenderer, type RenderContext } from "./context.ts";
4
+ /** The surface language, tolerating the partial contexts some renderers are tested with. */
5
+ export declare function surfaceLocale(context: RenderContext): unknown;
6
+ export declare function text(component: A2uiComponent, key: string, context: RenderContext): string | null;
7
+ export declare function calculationAttributes(component: A2uiComponent, expression: unknown, value: string | null, label: string | null, context: RenderContext, failureMessage?: string): {
8
+ "data-calculation-identity"?: undefined;
9
+ "data-calculation-announcement"?: undefined;
10
+ } | {
11
+ "data-calculation-identity": string;
12
+ "data-calculation-announcement": string;
13
+ };
14
+ export declare function numberValue(component: A2uiComponent, key: string, context: RenderContext): number | null;
15
+ export declare function records(component: A2uiComponent, key: string, context: RenderContext): A2uiJsonObject[];
16
+ export declare function accessibilityLabel(component: A2uiComponent, context: RenderContext): string | undefined;
17
+ export declare function intentClass(value: unknown): string;
18
+ export declare function EmptyComponent({ component }: {
19
+ component: A2uiComponent;
20
+ }): import("react/jsx-runtime").JSX.Element;
21
+ export declare function withFallback(component: A2uiComponent, hasContent: boolean, node: ReactNode): ReactNode;
22
+ export declare function renderChildren(component: A2uiComponent, context: RenderContext): ReactNode[];
23
+ export declare const renderStack: ComponentRenderer;
24
+ export declare const renderCard: ComponentRenderer;
25
+ /** The columns and rows each child of a grid spans, in `children` order: 1 to 4 each, no wider than the grid. */
26
+ export declare function gridItemSpans(component: A2uiComponent, columns: number): {
27
+ columns: number;
28
+ rows: number;
29
+ }[];
30
+ export declare const renderGrid: ComponentRenderer;
31
+ /** A masonry (LPFlow_Default): CSS multi-column layout fills each column in `children` order and
32
+ * balances their heights, the rule Compose and SwiftUI compute; every item is wrapped so it never
33
+ * breaks across columns. A full-width item spans every column. */
34
+ export declare const renderFlow: ComponentRenderer;
35
+ export declare const renderText: ComponentRenderer;
36
+ export declare const renderKicker: ComponentRenderer;
37
+ export declare const renderIcon: ComponentRenderer;
38
+ export declare const renderMetaRow: ComponentRenderer;
39
+ export declare const renderImage: ComponentRenderer;
40
+ export declare const renderChip: ComponentRenderer;
41
+ export declare const renderButton: ComponentRenderer;
42
+ /** `lp.pager` draws a carousel (`Carousel.tsx`); a hidden child is not one of its items. */
43
+ export declare const renderPager: ComponentRenderer;
44
+ export declare const renderListRow: ComponentRenderer;
45
+ export declare const renderDivider: ComponentRenderer;
46
+ export declare const renderStat: ComponentRenderer;
47
+ export declare const renderProgress: ComponentRenderer;
48
+ export declare const renderAvatar: ComponentRenderer;
49
+ export declare const renderMediaFrame: ComponentRenderer;
50
+ export declare const renderActionRow: ComponentRenderer;
51
+ export declare const renderAdContainer: ComponentRenderer;
52
+ export declare const renderChartElements: ComponentRenderer;
53
+ export declare const renderAsyncState: ComponentRenderer;