@reqvire-org/ads 0.5.3 → 0.5.5

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 (98) hide show
  1. package/dist/ads-errors.mjs +105 -8
  2. package/dist/analysis/client-directive.mjs +26 -0
  3. package/dist/analysis/externals.mjs +47 -0
  4. package/dist/analysis/module-graph.mjs +6 -0
  5. package/dist/analysis/owner-analysis-key.mjs +1 -1
  6. package/dist/analysis/owner-choices.mjs +14 -2
  7. package/dist/analysis/owner-composition.mjs +32 -4
  8. package/dist/analysis/owner-source.mjs +121 -17
  9. package/dist/border-paint.mjs +34 -0
  10. package/dist/check.mjs +2 -0
  11. package/dist/composed-contrast.mjs +34 -12
  12. package/dist/construction-output.mjs +58 -31
  13. package/dist/construction-spec.d.mts +111 -15
  14. package/dist/construction-spec.mjs +129 -20
  15. package/dist/corner-overpaint.mjs +3 -1
  16. package/dist/design-foundation.mjs +18 -4
  17. package/dist/emit/owner-emission-cache.mjs +1 -1
  18. package/dist/end-alignment.mjs +69 -0
  19. package/dist/external-macro.d.mts +20 -0
  20. package/dist/external-macro.mjs +12 -0
  21. package/dist/finding-rules.mjs +3 -0
  22. package/dist/forced-colors.mjs +81 -0
  23. package/dist/frame-regions.mjs +2 -2
  24. package/dist/guard/externals.mjs +64 -0
  25. package/dist/guard/run.mjs +9 -5
  26. package/dist/inventories.mjs +1 -1
  27. package/dist/lowering-layer.mjs +38 -4
  28. package/dist/lowering-overlaps.mjs +13 -1
  29. package/dist/lowering-properties.mjs +4 -0
  30. package/dist/lowering-region-layout.mjs +22 -3
  31. package/dist/lowering-session.mjs +1 -1
  32. package/dist/lowering-transitions.mjs +1 -0
  33. package/dist/mcp/preview-http.bundle.js +2 -2
  34. package/dist/mcp/preview-widget.bundle.js +12 -12
  35. package/dist/measured-geometry.mjs +8 -2
  36. package/dist/owner-analysis-check.mjs +190 -11
  37. package/dist/owner-errors.mjs +3 -0
  38. package/dist/owner-lowering.mjs +3 -2
  39. package/dist/ownership-model.mjs +14 -5
  40. package/dist/platform-features.mjs +7 -0
  41. package/dist/preview-bun.mjs +15 -2
  42. package/dist/profile-macro.d.mts +18 -0
  43. package/dist/recipe-macro.d.mts +107 -9
  44. package/dist/recipe-model.mjs +22 -8
  45. package/dist/region-lowering.mjs +204 -49
  46. package/dist/render-audit/axe-run.page.mjs +40 -1
  47. package/dist/render-audit/forced-states.page.mjs +37 -0
  48. package/dist/render-audit/layout-overflow.page.mjs +52 -2
  49. package/dist/render-audit/non-text-contrast.page.mjs +14 -10
  50. package/dist/render-audit/worker.mjs +38 -0
  51. package/dist/render-audit.mjs +42 -5
  52. package/dist/role-vocabulary.d.mts +5 -2
  53. package/dist/role-vocabulary.mjs +6 -3
  54. package/dist/scenario-kit.d.mts +2 -2
  55. package/dist/showcase/assets-view.mjs +12 -47
  56. package/dist/showcase/client.bundle.js +50 -50
  57. package/dist/showcase/http-client.bundle.js +18 -18
  58. package/dist/showcase/token-sample.mjs +2 -2
  59. package/dist/showcase/ui/ui.css +1 -1
  60. package/dist/showcase/ui/ui.js +13 -13
  61. package/dist/skills/ads-designer/references/accessibility.md +21 -1
  62. package/dist/skills/ads-designer/references/branding.md +4 -0
  63. package/dist/skills/ads-designer/references/design-data.md +6 -0
  64. package/dist/skills/ads-designer/references/layers.md +5 -0
  65. package/dist/skills/ads-designer/references/layout.md +8 -1
  66. package/dist/skills/ads-designer/references/recipes.md +52 -2
  67. package/dist/skills/ads-designer/references/runtimes.md +4 -0
  68. package/dist/skills/ads-designer/references/scenarios.md +2 -0
  69. package/dist/skills/ads-import/references/design-data.md +6 -0
  70. package/dist/skills/ads-import/references/layers.md +5 -0
  71. package/dist/skills/ads-import/references/layout.md +8 -1
  72. package/dist/skills/ads-import/references/recipes.md +52 -2
  73. package/dist/skills/ads-import/references/runtimes.md +4 -0
  74. package/dist/skills/ads-import/references/scenarios.md +2 -0
  75. package/dist/skills/ads-migrate/SKILL.md +2 -0
  76. package/dist/skills/ads-migrate/references/0.5.3-to-0.5.4.md +42 -0
  77. package/dist/skills/ads-migrate/references/0.5.4-to-0.5.5.md +61 -0
  78. package/dist/skills/ads-port/references/design-data.md +6 -0
  79. package/dist/skills/ads-port/references/layers.md +5 -0
  80. package/dist/skills/ads-port/references/layout.md +8 -1
  81. package/dist/skills/ads-port/references/recipes.md +52 -2
  82. package/dist/skills/ads-port/references/runtimes.md +4 -0
  83. package/dist/skills/ads-port/references/scenarios.md +2 -0
  84. package/dist/spatial-model.mjs +37 -10
  85. package/dist/system-colors.d.mts +9 -0
  86. package/dist/system-colors.mjs +1 -0
  87. package/dist/target-size.mjs +14 -1
  88. package/dist/tsconfig.declarations.json +1 -0
  89. package/docs/ADS.md +23 -1
  90. package/docs/ASSETS.md +21 -0
  91. package/docs/CACHING.md +1 -1
  92. package/docs/CHANGELOG.md +220 -21
  93. package/docs/GUIDE.md +31 -20
  94. package/docs/LANGUAGE.md +146 -11
  95. package/docs/MOTION.md +11 -1
  96. package/docs/PROFILE-KINDS.md +60 -9
  97. package/docs/RULES.md +21 -8
  98. package/package.json +5 -1
@@ -94,9 +94,9 @@ export interface SnapDeclaration {
94
94
  /** Content beyond the element's box: clipped, or scrolled on the block axis, the inline axis or both. */
95
95
  export type Overflow = "clip" | "scroll-block" | "scroll-inline" | "scroll-both";
96
96
  /** A native element the region or part renders, for its closed normalization. */
97
- export type NativeElement = "iframe" | "select" | "search-input" | "text-input" | "table" | "header-cell" | "cell" | "list" | "summary";
97
+ export type NativeElement = "iframe" | "select" | "search-input" | "text-input" | "table" | "header-cell" | "cell" | "list" | "summary" | "document";
98
98
  /** A paint a surface treatment can transition. */
99
- export type PaintChannel = "background-color" | "border-color" | "color" | "box-shadow" | "filter" | "backdrop-filter" | "opacity";
99
+ export type PaintChannel = "background-color" | "border-color" | "color" | "text-decoration-color" | "box-shadow" | "filter" | "backdrop-filter" | "opacity";
100
100
  /** Paint channels of one element that change between its state surfaces, timed by a motion profile. */
101
101
  export interface PaintTransition {
102
102
  readonly channels: readonly PaintChannel[];
@@ -137,6 +137,39 @@ export interface Enter {
137
137
  readonly slot: "motion";
138
138
  } | string;
139
139
  }
140
+ /** A counter's number system. */
141
+ export type CounterStyle = "decimal" | "decimal-leading-zero" | "lower-alpha" | "upper-alpha" | "lower-roman" | "upper-roman";
142
+ /**
143
+ * Generated content: a counter's value (`counter`), or every level of a nested counter joined by `separator`
144
+ * (`counters`: 1.1.2), in a number system, between short literals (at most four punctuation marks or spaces).
145
+ */
146
+ export type GeneratedContent = {
147
+ readonly counter: string;
148
+ readonly style?: CounterStyle;
149
+ readonly prefix?: string;
150
+ readonly suffix?: string;
151
+ } | {
152
+ readonly counters: string;
153
+ readonly separator?: string;
154
+ readonly style?: CounterStyle;
155
+ readonly prefix?: string;
156
+ readonly suffix?: string;
157
+ };
158
+ /** A marker's or generated content's treatment: a colour-only surface, a text profile of weight and numerals, content. */
159
+ /** A range slider's track or thumb: a surface and a frame profile, with surfaces per owner state. */
160
+ export interface SliderTreatment {
161
+ readonly surface: string;
162
+ readonly frame: string;
163
+ readonly when?: Readonly<Record<string, string>>;
164
+ }
165
+ export interface GeneratedTreatment {
166
+ readonly surface?: string;
167
+ readonly text?: string;
168
+ readonly content?: GeneratedContent;
169
+ readonly when?: Readonly<Record<string, {
170
+ readonly surface: string;
171
+ }>>;
172
+ }
140
173
  /** A colour-only surface on a part's pseudo-element, with owner-state treatments. */
141
174
  export interface PseudoTreatment {
142
175
  readonly surface: ProfileReference;
@@ -147,12 +180,18 @@ export interface PseudoTreatment {
147
180
  /** A root in the browser's top layer: a modal `<dialog>` sheet, a `popover` panel pinned to a viewport corner, or one the owner anchors through measured values. */
148
181
  export type LayerDeclaration = {
149
182
  readonly element: "dialog";
150
- readonly edge: "start" | "end";
183
+ /**
184
+ * A sheet attached to an inline edge (`start`, `end`), or a card: `center` in the viewport, or `block-start`
185
+ * (centred inline, below the top). A card keeps the layer profile's `viewportMargin` from the viewport edges.
186
+ */
187
+ readonly edge: "start" | "end" | "center" | "block-start";
188
+ /** The backdrop's surface: its `background`, and optionally its `backdropBlur` (the page behind, blurred). */
151
189
  readonly backdrop: {
152
190
  readonly surface: string;
153
191
  readonly dismiss?: "press" | "none";
154
192
  };
155
- readonly motion?: "slide";
193
+ /** A sheet slides in from its edge; a card fades in. */
194
+ readonly motion?: "slide" | "fade";
156
195
  /** A breakpoint tier of the recipe's spatial profile; the recipe's `modalQuery` is the range below it. */
157
196
  readonly modalBelow?: string;
158
197
  } | {
@@ -194,6 +233,16 @@ export type MeasuredDeclaration = {
194
233
  };
195
234
  readonly motion?: string;
196
235
  }
236
+ /** A scale factor per axis: with a measured translation, an image grows from its place into a zoom view (FLIP). */
237
+ | {
238
+ readonly type: "scale";
239
+ readonly property: "scale";
240
+ readonly fallback?: {
241
+ readonly x: number;
242
+ readonly y: number;
243
+ };
244
+ readonly motion?: string;
245
+ }
197
246
  /** One track (1-based) of a grid's own track list. */
198
247
  | {
199
248
  readonly type: "size-track";
@@ -243,13 +292,18 @@ export interface RecipeSpec {
243
292
  readonly surface?: ProfileReference | SlotField;
244
293
  readonly motion?: ProfileReference | SlotField;
245
294
  readonly align?: "start" | "center" | "end" | "baseline" | "stretch";
246
- readonly justify?: "start" | "center" | "end";
295
+ /**
296
+ * Main-axis placement. `space-between` (and `space-around`, `space-evenly`) puts the free space between a row's
297
+ * or stack's items: a logo at the start and actions at the end. A wrapping row keeps it on every line.
298
+ */
299
+ readonly justify?: "start" | "center" | "end" | "space-between" | "space-around" | "space-evenly";
247
300
  /**
248
301
  * Root: flex wrapping. Text part: `true`/`"anywhere"` breaks long words, `"never"` keeps one line, `"truncate"` ends it
249
302
  * with an ellipsis (after `lines` lines when set), `"balance"` evens out line lengths (headings, short titles) and
250
303
  * `"pretty"` avoids a lone short word on the last line (body text).
251
304
  */
252
- readonly wrap?: boolean | "anywhere" | "never" | "truncate" | "balance" | "pretty";
305
+ /** `"preserve"`: spaces and line breaks kept, long lines wrapped (code that stays visible at the column's width). */
306
+ readonly wrap?: boolean | "anywhere" | "never" | "truncate" | "balance" | "pretty" | "preserve";
253
307
  readonly textAlign?: "start" | "center" | "end";
254
308
  /** Lines of the part's text profile it always reserves. */
255
309
  readonly reserveLines?: 1 | 2 | 3;
@@ -274,6 +328,12 @@ export interface RecipeSpec {
274
328
  readonly columns?: number;
275
329
  /** A fluid grid with local `columns`: the share of the width each column takes (`[0.85, 1.15]`); every column weighs 1 without it. */
276
330
  readonly weights?: readonly number[];
331
+ /**
332
+ * A fluid grid: from this breakpoint tier up its columns are as wide as their content and the free space lies
333
+ * between them (a footer's link columns); below it the columns share the width as usual, which is where the grid
334
+ * goes when its columns do not fit side by side. Cells there fit their columns by construction.
335
+ */
336
+ readonly contentFrom?: string;
277
337
  readonly rows?: readonly ("auto" | "fill")[];
278
338
  readonly gutter?: string;
279
339
  readonly margin?: "none";
@@ -345,7 +405,11 @@ export interface RecipeSpec {
345
405
  readonly slot: "spacing";
346
406
  readonly field: "overlap";
347
407
  };
348
- /** In a `when` entry: the spacing profile the element's arrangement reads its gap and overlap from under that state. */
408
+ /**
409
+ * On a part in a flow: its own spacing profile, whose `spaceBefore` and `spaceAfter` are the part's space before and
410
+ * after it (a heading 44 px above and 14 px below). In a `when` entry: the spacing profile the element's arrangement
411
+ * reads its gap and overlap from under that state.
412
+ */
349
413
  readonly spacing?: string;
350
414
  /** The geometry that animates between the element's states: closed channels, timed by a motion profile. */
351
415
  readonly geometryTransition?: {
@@ -408,9 +472,43 @@ export interface RecipeSpec {
408
472
  readonly enter?: Enter;
409
473
  /** Pseudo-element treatments of an `<input>` or `<textarea>` part. */
410
474
  readonly pseudo?: {
411
- readonly placeholder?: PseudoTreatment; /** The filled part of a `<progress>`: a surface with a background; the part's own surface is the track. */
475
+ readonly placeholder?: PseudoTreatment;
476
+ /** The filled part of a `<progress>`: a surface with a background; the part's own surface is the track. */
412
477
  readonly progressValue?: PseudoTreatment;
478
+ /** A list item's marker (`li`, `summary`): its colour, its weight and numerals (`text`), and what it shows (`content`). */
479
+ readonly marker?: GeneratedTreatment;
480
+ /** Generated content before the element (a section number): what it shows, in its colour and weight. */
481
+ readonly before?: GeneratedTreatment & {
482
+ readonly content: GeneratedContent;
483
+ };
484
+ /** A range slider's track (`<input type="range">`): its surface (background, border) and frame (block size, radius). */
485
+ readonly sliderTrack?: SliderTreatment;
486
+ /** A range slider's thumb: its surface and frame (inline and block size, radius, border); centred on the track. */
487
+ readonly sliderThumb?: SliderTreatment;
488
+ };
489
+ /** CSS counters: where a count starts (`reset`) and what this element counts (`increment`). `list-item` is the browser's own list counter. */
490
+ readonly counter?: {
491
+ readonly reset?: string;
492
+ readonly increment?: string;
493
+ };
494
+ /**
495
+ * A rule between the element's consecutive children: the frame profile's border width and style, painted by the
496
+ * surface's `borderColor` (a hairline between table rows, none after the last).
497
+ */
498
+ readonly between?: {
499
+ readonly surface: string;
500
+ readonly frame: string;
413
501
  };
502
+ /**
503
+ * Loose flow, on the root: a stack gives its gap to its children, and its last part's own `spaceAfter` carries out
504
+ * of it. On a list and on its item (an item that holds paragraphs and code), the next item starts at the larger of
505
+ * the list's gap and the item's last block's space after.
506
+ */
507
+ readonly carry?: boolean;
508
+ /** On a part: `"assistive"` hides it on screen while assistive technology still reads it (a table caption). */
509
+ readonly presence?: "visible" | "assistive";
510
+ /** A list's marker style at each nesting depth, outermost first; deeper lists keep the last. */
511
+ readonly markers?: readonly ("disc" | "circle" | "square" | "none" | CounterStyle)[];
414
512
  /** A top-layer root (recipe root only). */
415
513
  readonly layer?: LayerDeclaration;
416
514
  }
@@ -423,7 +521,7 @@ export type MeasuredValues<M> = [keyof M] extends [never] ? {
423
521
  readonly [name: string]: never;
424
522
  } : {
425
523
  readonly [K in keyof M]?: M[K] extends {
426
- readonly type: "transform";
524
+ readonly type: "transform" | "scale";
427
525
  } ? {
428
526
  readonly x: number;
429
527
  readonly y: number;
@@ -1,3 +1,4 @@
1
+ import { FORCED_KEYS } from "./system-colors.mjs";
1
2
  import { createHash } from "node:crypto";
2
3
  import postcss from "postcss";
3
4
  import { isJsonObject, isRecord } from "./json.mjs";
@@ -48,7 +49,7 @@ function clause(parent, name, params, values) {
48
49
  }
49
50
  const strings = (value) => Array.isArray(value) && value.every((item) => typeof item === "string") ? value : null;
50
51
  function buildProfileTree(spec) {
51
- only(spec, ["name", "kind", "with", "fields", "choices", "breakpoints", "gutters", "conditions", "steps", "provides"]);
52
+ only(spec, ["name", "kind", "with", "fields", "choices", "breakpoints", "gutters", "conditions", "steps", "provides", "forcedColors"]);
52
53
  const { name, kind } = spec;
53
54
  check(typeof name === "string" && typeof kind === "string", "Profiles need a string name and kind");
54
55
  const inputs = spec.with === void 0 ? [] : strings(spec.with);
@@ -68,6 +69,13 @@ function buildProfileTree(spec) {
68
69
  check(!Object.hasOwn(fields, token), `Duplicate provided role: ${token}`);
69
70
  fields[token] = value;
70
71
  }
72
+ const forced = spec.forcedColors === void 0 ? {} : object(spec.forcedColors, "Expected forced colours");
73
+ check(Object.keys(forced).length === 0 || kind === "surface", "Only a surface profile declares forced colours");
74
+ for (const [key, value] of Object.entries(forced)) {
75
+ const field = FORCED_KEYS[key];
76
+ check(field !== void 0 && typeof value === "string", `Forced colours are background, color and border, each a system colour: ${key}`);
77
+ fields[field] = value;
78
+ }
71
79
  declarations(node, fields);
72
80
  for (const [choiceName, choice] of Object.entries(spec.choices === void 0 ? {} : object(spec.choices, "Expected choices"))) {
73
81
  const declared = only(choice, ["default", "options"]), child = clause(node, "ads-choice", choiceName, declared.default ? { default: declared.default } : {});
@@ -87,20 +95,20 @@ function buildProfileTree(spec) {
87
95
  required(profileDefinition(node));
88
96
  return root;
89
97
  }
90
- const NESTED = new Set(["layout", "parts", "cells", "at", "when", "frame", "select", "alignRows", "recipe", "normalize", "theme", "paintTransition", "pseudo", "layer", "measured", "paints", "snap", "accessibility", "enter", "sticky", "outset", "play", "focus", "geometryTransition"]), NESTED_IN = {
91
- "ads-part": ["recipe", "when", "frame", "parts", "paintTransition", "pseudo", "at", "measured", "paints", "normalize", "accessibility", "enter", "sticky", "play", "outset", "focus", "geometryTransition"],
98
+ const NESTED = new Set(["layout", "parts", "cells", "at", "when", "frame", "select", "alignRows", "recipe", "normalize", "theme", "paintTransition", "pseudo", "layer", "measured", "paints", "snap", "accessibility", "enter", "sticky", "outset", "play", "focus", "geometryTransition", "counter", "content", "between"]), NESTED_IN = {
99
+ "ads-part": ["recipe", "when", "frame", "parts", "paintTransition", "pseudo", "at", "measured", "paints", "normalize", "accessibility", "enter", "sticky", "play", "outset", "focus", "geometryTransition", "counter", "between"],
92
100
  "ads-cell": ["at"],
93
101
  "ads-at": ["cells", "frame"],
94
102
  "ads-when": ["play", "frame"],
95
- "ads-pseudo": ["when"]
103
+ "ads-pseudo": ["when", "content"]
96
104
  };
97
105
  function body(node, spec) {
98
- const allowed = node.name === "ads-recipe" ? ["layout", "parts", "cells", "at", "when", "frame", "select", "alignRows", "paintTransition", "geometryTransition", "snap", ...node.parent?.type === "root" ? ["normalize", "theme", "layer", "measured", "paints", "enter", "sticky", "play"] : []] : NESTED_IN[node.name] ?? [];
106
+ const allowed = node.name === "ads-recipe" ? ["layout", "parts", "cells", "at", "when", "frame", "select", "alignRows", "paintTransition", "geometryTransition", "snap", ...node.parent?.type === "root" ? ["normalize", "theme", "layer", "measured", "paints", "enter", "sticky", "play", "pseudo", "counter", "between"] : []] : NESTED_IN[node.name] ?? [], nestedKey = (key) => NESTED.has(key) && !(node.name === "ads-pseudo" && key === "frame");
99
107
  for (const field of Object.keys(spec))
100
- if (NESTED.has(field))
108
+ if (nestedKey(field))
101
109
  check(allowed.includes(field), `Unsupported ${field} in ${node.name}`);
102
- declarations(node, Object.fromEntries(Object.entries(spec).flatMap(([key, value]) => NESTED.has(key) ? [] : [[key === "state" ? "assetState" : key, value]])));
103
- const declaredFrame = spec.frame;
110
+ declarations(node, Object.fromEntries(Object.entries(spec).flatMap(([key, value]) => nestedKey(key) ? [] : [[key === "state" ? "assetState" : key, value]])));
111
+ const declaredFrame = node.name === "ads-pseudo" ? void 0 : spec.frame;
104
112
  if (declaredFrame !== void 0) {
105
113
  const frame = typeof declaredFrame === "string" ? { kind: declaredFrame } : object(declaredFrame, "Frame needs an operation"), { kind = "", ...fields } = frame;
106
114
  clause(node, "ads-frame", String(kind), Object.keys(fields).length > 0 ? fields : void 0);
@@ -124,6 +132,12 @@ function body(node, spec) {
124
132
  clause(node, "ads-focus", "", only(spec.focus, ["of"]));
125
133
  if (spec.play !== void 0)
126
134
  clause(node, "ads-play", "", only(spec.play, ["sequence", "order"]));
135
+ if (spec.counter !== void 0)
136
+ clause(node, "ads-counter", "", only(spec.counter, ["reset", "increment"]));
137
+ if (spec.between !== void 0)
138
+ clause(node, "ads-between", "", only(spec.between, ["surface", "frame"]));
139
+ if (spec.content !== void 0)
140
+ clause(node, "ads-content", "", only(spec.content, ["counter", "counters", "style", "separator", "prefix", "suffix"]));
127
141
  const entrance = spec.enter;
128
142
  if (entrance !== void 0) {
129
143
  const { from, motion } = only(entrance, ["from", "motion"]);