@reqvire-org/ads 0.5.1 → 0.5.3
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.
- package/dist/ads-errors.mjs +143 -51
- package/dist/analysis/composition-axes.mjs +48 -0
- package/dist/analysis/construction-memo.mjs +38 -0
- package/dist/analysis/context.mjs +19 -0
- package/dist/analysis/design-reads.mjs +177 -0
- package/dist/analysis/design-usage.mjs +4 -20
- package/dist/analysis/factored-classes.mjs +90 -0
- package/dist/analysis/helpers.mjs +5 -7
- package/dist/analysis/mock-check.mjs +4 -5
- package/dist/analysis/native-project.mjs +12 -0
- package/dist/analysis/owner-accessibility.mjs +4 -4
- package/dist/analysis/owner-analysis-cache.mjs +86 -23
- package/dist/analysis/owner-analysis-key.mjs +42 -10
- package/dist/analysis/owner-choices.mjs +56 -7
- package/dist/analysis/owner-composition.mjs +179 -45
- package/dist/analysis/owner-reuse.mjs +8 -6
- package/dist/analysis/owner-source.mjs +304 -110
- package/dist/analysis/scenario-keys.mjs +10 -7
- package/dist/analysis/service.mjs +50 -3
- package/dist/analysis/standalone.mjs +7 -4
- package/dist/analysis/syntax.mjs +59 -1
- package/dist/analysis/worker-protocol.mjs +14 -2
- package/dist/analysis/worker.mjs +32 -10
- package/dist/architecture-report.mjs +26 -0
- package/dist/asset-view-facts.mjs +16 -2
- package/dist/boundaries.mjs +26 -10
- package/dist/bun-compiler.mjs +2 -2
- package/dist/check-service.mjs +29 -17
- package/dist/check.mjs +13 -6
- package/dist/cli.mjs +1 -1
- package/dist/composed-contrast.mjs +143 -62
- package/dist/composed-keyline.mjs +2 -2
- package/dist/config.mjs +2 -1
- package/dist/construction-output.mjs +9 -3
- package/dist/construction-spec.d.mts +145 -31
- package/dist/construction-spec.mjs +204 -74
- package/dist/corner-overpaint.mjs +20 -7
- package/dist/derived-states.mjs +182 -0
- package/dist/design-foundation.mjs +16 -0
- package/dist/design-inputs.mjs +18 -3
- package/dist/design-system-closure.mjs +12 -7
- package/dist/design-usage.mjs +2 -8
- package/dist/emit/contract.mjs +24 -5
- package/dist/emit/emission.mjs +6 -9
- package/dist/emit/integrity.mjs +8 -2
- package/dist/emit/output-watch.mjs +120 -0
- package/dist/emit/owner-emission-cache.mjs +4 -4
- package/dist/emit/preview-emitter.mjs +4 -2
- package/dist/emit/preview-tree.mjs +1 -1
- package/dist/emit/service.mjs +8 -2
- package/dist/finding-rules.mjs +3 -0
- package/dist/form-states.mjs +8 -0
- package/dist/frame-regions.mjs +29 -9
- package/dist/grid-lowering.mjs +3 -1
- package/dist/hover-geometry.mjs +15 -0
- package/dist/input-digests.mjs +17 -10
- package/dist/linaria/delivery.mjs +2 -0
- package/dist/lowering-enter.mjs +6 -6
- package/dist/lowering-properties.mjs +5 -0
- package/dist/lowering-region-layout.mjs +7 -2
- package/dist/lowering-session.mjs +10 -0
- package/dist/mcp/build-status.mjs +9 -1
- package/dist/mcp/compiler-channel.mjs +11 -4
- package/dist/mcp/mutations.mjs +1 -0
- package/dist/mcp/preview-http.bundle.js +1 -1
- package/dist/mcp/preview-watch.mjs +2 -1
- package/dist/mcp/preview-widget.bundle.js +1 -1
- package/dist/mcp/server-observation.mjs +6 -4
- package/dist/mcp/server-project.mjs +4 -1
- package/dist/motion-model.mjs +1 -1
- package/dist/owner-analysis-check.mjs +23 -6
- package/dist/owner-errors.mjs +6 -3
- package/dist/owner-lowering.mjs +78 -13
- package/dist/owner-scenarios.mjs +6 -23
- package/dist/ownership-model.mjs +24 -8
- package/dist/paint-contrast.mjs +6 -0
- package/dist/placeholder-contrast.mjs +17 -1
- package/dist/platform-features.mjs +10 -1
- package/dist/profile-macro.d.mts +7 -0
- package/dist/profile-view-facts.mjs +1 -1
- package/dist/recipe-macro.d.mts +103 -40
- package/dist/recipe-model.mjs +18 -13
- package/dist/region-lowering.mjs +266 -123
- package/dist/render-audit/layout-shift.page.mjs +24 -0
- package/dist/render-audit/render-states.mjs +122 -1
- package/dist/render-audit/render-states.page.mjs +140 -0
- package/dist/render-audit/worker.mjs +18 -3
- package/dist/render-audit.mjs +114 -1
- package/dist/role-vocabulary.d.mts +9 -0
- package/dist/role-vocabulary.mjs +16 -1
- package/dist/runtime-paint-contrast.mjs +5 -2
- package/dist/scenarios-compiler.mjs +20 -6
- package/dist/showcase/assets-view.mjs +29 -13
- package/dist/showcase/client.bundle.js +50 -50
- package/dist/showcase/http-client.bundle.js +15 -15
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +5 -5
- package/dist/skills/ads-designer/references/accessibility.md +10 -4
- package/dist/skills/ads-designer/references/branding.md +13 -3
- package/dist/skills/ads-designer/references/contracts.md +5 -2
- package/dist/skills/ads-designer/references/design-data.md +13 -7
- package/dist/skills/ads-designer/references/layout.md +12 -4
- package/dist/skills/ads-designer/references/motion.md +11 -2
- package/dist/skills/ads-designer/references/recipes.md +49 -15
- package/dist/skills/ads-import/references/contracts.md +5 -2
- package/dist/skills/ads-import/references/design-data.md +13 -7
- package/dist/skills/ads-import/references/layout.md +12 -4
- package/dist/skills/ads-import/references/recipes.md +49 -15
- package/dist/skills/ads-migrate/SKILL.md +2 -0
- package/dist/skills/ads-migrate/references/0.5.1-to-0.5.2.md +185 -0
- package/dist/skills/ads-migrate/references/0.5.2-to-0.5.3.md +71 -0
- package/dist/skills/ads-port/references/contracts.md +5 -2
- package/dist/skills/ads-port/references/design-data.md +13 -7
- package/dist/skills/ads-port/references/layout.md +12 -4
- package/dist/skills/ads-port/references/recipes.md +49 -15
- package/dist/spatial-model.mjs +2 -2
- package/dist/surface-contrast.mjs +7 -2
- package/dist/surface-effects.mjs +5 -3
- package/dist/target-size.mjs +21 -3
- package/dist/task-cache.mjs +8 -18
- package/dist/validation-checks.mjs +1 -1
- package/docs/ADS.md +9 -3
- package/docs/ARCHITECTURE.md +96 -30
- package/docs/CACHING.md +152 -24
- package/docs/CHANGELOG.md +307 -23
- package/docs/GUIDE.md +109 -20
- package/docs/LANGUAGE.md +262 -117
- package/docs/MCP.md +5 -1
- package/docs/MOTION.md +15 -4
- package/docs/PROFILE-KINDS.md +54 -4
- package/docs/RULES.md +34 -25
- package/docs/TOKEN-ROLES.md +7 -1
- package/package.json +1 -1
- package/dist/analysis/prose-owners.mjs +0 -57
- package/dist/prose-model.d.mts +0 -81
- package/dist/prose-model.mjs +0 -101
package/dist/recipe-macro.d.mts
CHANGED
|
@@ -18,30 +18,35 @@ export interface Placement {
|
|
|
18
18
|
readonly visible?: boolean;
|
|
19
19
|
readonly at?: Readonly<Record<string, Placement>>;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
/** A grid cell: its placement, and how many times it renders. */
|
|
22
|
+
export interface Cell extends Placement {
|
|
23
|
+
/** `false`: the cell may be absent (an optional notice). Pinned to a `row`, it leaves that row empty when absent (listed for review). */
|
|
24
|
+
readonly required?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The cell renders once per item of a list (`items.map(…)`), any number of times (at least once unless
|
|
27
|
+
* `required: false`). Its instances flow one after another: it auto-places (`start: "auto"`, implied) over
|
|
28
|
+
* its `span`, a number or `"full"`, and states no start line, `end` or `row`.
|
|
29
|
+
*/
|
|
30
|
+
readonly repeat?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export type Layout = "inline" | "stack" | "fluid" | "hybrid" | "fixed" | "flow" | "inherited" | "layered";
|
|
33
|
+
/**
|
|
34
|
+
* Where a jump to an element (a fragment link, `scrollIntoView`) lands below the top of its scroll container:
|
|
35
|
+
* right under the region sticky elements clear (the layer profile's `clearBlockStart`), or at the element's
|
|
36
|
+
* own distance (the spacing profile's `anchorGap`), where it lines up with something beside it.
|
|
37
|
+
*/
|
|
38
|
+
export type AnchorClear = {
|
|
39
|
+
readonly slot: "layer";
|
|
40
|
+
readonly field: "clearBlockStart";
|
|
41
|
+
} | {
|
|
42
|
+
readonly slot: "spacing";
|
|
43
|
+
readonly field: "anchorGap";
|
|
44
|
+
};
|
|
22
45
|
/** A profile field of the nearest recipe's spacing slot. */
|
|
23
46
|
type SpacingField = {
|
|
24
47
|
readonly slot: "spacing";
|
|
25
48
|
readonly field: string;
|
|
26
49
|
};
|
|
27
|
-
/**
|
|
28
|
-
* One element of a prose root (`layout: "prose"`): the profiles its plain markup takes, by name.
|
|
29
|
-
* `spaceBefore` (blocks) replaces the rhythm before it, `indent` (list) is its start inset, `marker`
|
|
30
|
-
* (item) a colour-only surface.
|
|
31
|
-
*/
|
|
32
|
-
export interface ProseElement {
|
|
33
|
-
readonly text?: string;
|
|
34
|
-
readonly surface?: string;
|
|
35
|
-
readonly frame?: string;
|
|
36
|
-
readonly when?: Readonly<Record<string, {
|
|
37
|
-
readonly surface: string;
|
|
38
|
-
}>>;
|
|
39
|
-
readonly spaceBefore?: SpacingField;
|
|
40
|
-
readonly indent?: SpacingField;
|
|
41
|
-
readonly marker?: string;
|
|
42
|
-
}
|
|
43
|
-
/** The elements a prose root styles. */
|
|
44
|
-
export type ProseElementName = "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "list" | "item" | "quote" | "rule" | "pre" | "table" | "headerCell" | "cell" | "figure" | "caption" | "media" | "descriptions" | "term" | "definition" | "link" | "strong" | "emphasis" | "deleted" | "code" | "sub" | "sup" | "kbd" | "mark";
|
|
45
50
|
/** A logical side of the box; it mirrors with the writing direction. */
|
|
46
51
|
export type Side = "block-start" | "block-end" | "inline-start" | "inline-end";
|
|
47
52
|
export type Frame = "control" | "container" | {
|
|
@@ -104,7 +109,8 @@ export interface PaintTransition {
|
|
|
104
109
|
* An entrance: the element starts from `from` on its first render and settles into its own look over
|
|
105
110
|
* `motion`. `from.surface` is a surface profile that states only `opacity` and `blur`; at most one
|
|
106
111
|
* movement, read from the entrance's motion profile (`translate` its `distance` on the block axis,
|
|
107
|
-
* `
|
|
112
|
+
* `translateInline` its `distance` on the inline axis, mirrored right to left, `scale` its `scale`,
|
|
113
|
+
* `rotate` its `angle`).
|
|
108
114
|
*/
|
|
109
115
|
export interface Enter {
|
|
110
116
|
readonly from: {
|
|
@@ -113,6 +119,10 @@ export interface Enter {
|
|
|
113
119
|
readonly slot: "motion";
|
|
114
120
|
readonly field: "distance";
|
|
115
121
|
};
|
|
122
|
+
readonly translateInline?: {
|
|
123
|
+
readonly slot: "motion";
|
|
124
|
+
readonly field: "distance";
|
|
125
|
+
};
|
|
116
126
|
readonly scale?: {
|
|
117
127
|
readonly slot: "motion";
|
|
118
128
|
readonly field: "scale";
|
|
@@ -247,7 +257,8 @@ export interface RecipeSpec {
|
|
|
247
257
|
readonly lines?: 2 | 3;
|
|
248
258
|
readonly overflow?: Overflow;
|
|
249
259
|
/**
|
|
250
|
-
* Part: it fills its parent stack's or inline row's main axis (`fill-both`: also the cross axis).
|
|
260
|
+
* Part: it fills its parent stack's or inline row's main axis (`fill-both`: also the cross axis). A control's text
|
|
261
|
+
* part: `"fill"` takes the room an inline control's other content leaves, so a visual after it stands at the far end.
|
|
251
262
|
* Root of an `inline` row: `"container"` takes the container's width, `"content"` (the default) is as wide as its content.
|
|
252
263
|
*/
|
|
253
264
|
readonly extent?: "fill" | "fill-both" | "content" | "container";
|
|
@@ -269,7 +280,17 @@ export interface RecipeSpec {
|
|
|
269
280
|
readonly bound?: "full" | "system";
|
|
270
281
|
readonly context?: "viewport" | "container";
|
|
271
282
|
readonly exposeRows?: readonly string[];
|
|
272
|
-
|
|
283
|
+
/**
|
|
284
|
+
* A part's content. `"component"`: a public component placed with the part's marker (`className`), as a grid
|
|
285
|
+
* cell is; the part states its placement only (`required`, `repeat`, `extent`, `at`, `spaceBefore`, `spaceAfter`).
|
|
286
|
+
*/
|
|
287
|
+
readonly kind?: "text" | "visual" | "vector" | "component";
|
|
288
|
+
/**
|
|
289
|
+
* In a `stack`: the part's own space before it and after it, in place of the stack's gap (a heading further
|
|
290
|
+
* from what precedes it). Where one part's space after meets the next part's space before, the larger applies.
|
|
291
|
+
*/
|
|
292
|
+
readonly spaceBefore?: SpacingField;
|
|
293
|
+
readonly spaceAfter?: SpacingField;
|
|
273
294
|
readonly selector?: string;
|
|
274
295
|
readonly required?: boolean;
|
|
275
296
|
/** A visual part's binding: one declared asset (name or alias)… */
|
|
@@ -289,20 +310,62 @@ export interface RecipeSpec {
|
|
|
289
310
|
readonly translateBlock?: SlotField;
|
|
290
311
|
readonly scale?: SlotField;
|
|
291
312
|
readonly rotate?: SlotField;
|
|
292
|
-
|
|
313
|
+
/**
|
|
314
|
+
* On a part: `true` renders its element once per item of a list (`tabs.map((tab) => <a className="tab" …/>)`),
|
|
315
|
+
* any number of times, at least once when `required`. Every instance takes the part's construction;
|
|
316
|
+
* consecutive instances are neighbours of their arrangement, so targets are checked against each other.
|
|
317
|
+
* `extent: "fill"` shares the row among them. Not with `drawnBy` or `focus`.
|
|
318
|
+
* In a `when` entry: `"continuous"` repeats a rotation while the state holds.
|
|
319
|
+
*/
|
|
320
|
+
readonly repeat?: boolean | "continuous";
|
|
293
321
|
readonly frame?: Frame;
|
|
294
322
|
/**
|
|
295
323
|
* A text-entry control identified by other visual means than a 3:1 boundary (WCAG 1.4.11), declared on
|
|
296
324
|
* its part with a concrete reason: the boundary contrast error becomes a review item. Human-approved
|
|
297
325
|
* only (ads_accept asks the user, or the showcase approval view); never added silently.
|
|
298
326
|
*/
|
|
327
|
+
/**
|
|
328
|
+
* This part is the drawn stand-in of a native control beside it (the box of a checkbox whose `<input>`
|
|
329
|
+
* is visually hidden): it shows the focus profile's indicator while the named sibling part has keyboard focus.
|
|
330
|
+
*/
|
|
331
|
+
readonly focus?: {
|
|
332
|
+
readonly of: string;
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* A native control (a checkbox's `<input>`) that the named sibling part draws: invisible and taking no room, it
|
|
336
|
+
* lies over that part at its frame's size, so pointer and keyboard still reach it. The drawing part is declared
|
|
337
|
+
* right after it and shows its focus (`focus: { of }`).
|
|
338
|
+
*/
|
|
339
|
+
readonly drawnBy?: string;
|
|
340
|
+
/**
|
|
341
|
+
* Neighbours of an `inline` or `stack` arrangement overlap by the spacing profile's `overlap`, in place of a
|
|
342
|
+
* gap (a pile of faces, a stack of cards). Later neighbours paint over earlier ones.
|
|
343
|
+
*/
|
|
344
|
+
readonly overlap?: {
|
|
345
|
+
readonly slot: "spacing";
|
|
346
|
+
readonly field: "overlap";
|
|
347
|
+
};
|
|
348
|
+
/** In a `when` entry: the spacing profile the element's arrangement reads its gap and overlap from under that state. */
|
|
349
|
+
readonly spacing?: string;
|
|
350
|
+
/** The geometry that animates between the element's states: closed channels, timed by a motion profile. */
|
|
351
|
+
readonly geometryTransition?: {
|
|
352
|
+
readonly channels: readonly ("size" | "inset" | "gap" | "radius" | "border-width" | "overlap")[];
|
|
353
|
+
readonly motion: SlotField | string;
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* A part that takes no room on its parent's main axis, is transparent and is hidden from assistive technology
|
|
357
|
+
* and focus; a `when` entry opens it (`collapsed: false`), or closes an open part.
|
|
358
|
+
*/
|
|
359
|
+
readonly collapsed?: boolean;
|
|
360
|
+
/** Where a jump to this element lands (a section or a block with an id). */
|
|
361
|
+
readonly anchorClear?: AnchorClear;
|
|
299
362
|
readonly accessibility?: {
|
|
300
363
|
readonly boundary: "visible-label" | "boundary-on-interaction";
|
|
301
364
|
readonly reason: string;
|
|
302
365
|
};
|
|
303
366
|
readonly select?: Readonly<Record<string, string>>;
|
|
304
367
|
readonly parts?: Readonly<Record<string, RecipeSpec>>;
|
|
305
|
-
readonly cells?: Readonly<Record<string,
|
|
368
|
+
readonly cells?: Readonly<Record<string, Cell>>;
|
|
306
369
|
/** Grid: placements under named conditions. Part: `{ visible }` under one named condition. */
|
|
307
370
|
readonly at?: Readonly<Record<string, RecipeSpec & Placement>>;
|
|
308
371
|
readonly when?: Readonly<Record<string, RecipeSpec>>;
|
|
@@ -333,10 +396,6 @@ export interface RecipeSpec {
|
|
|
333
396
|
readonly sequence: string;
|
|
334
397
|
readonly order?: number;
|
|
335
398
|
};
|
|
336
|
-
/** A prose root: the space between its blocks, from the spacing slot. */
|
|
337
|
-
readonly rhythm?: SpacingField;
|
|
338
|
-
/** A prose root: the plain elements it styles, wherever they nest in its content. */
|
|
339
|
-
readonly elements?: Readonly<Partial<Record<ProseElementName, ProseElement>>>;
|
|
340
399
|
/**
|
|
341
400
|
* The root or part stays at an edge of its scrolling container while the rest scrolls. `clear:
|
|
342
401
|
* "block-start"` holds it below a region at the top by the layer profile's `clearBlockStart`.
|
|
@@ -349,7 +408,8 @@ export interface RecipeSpec {
|
|
|
349
408
|
readonly enter?: Enter;
|
|
350
409
|
/** Pseudo-element treatments of an `<input>` or `<textarea>` part. */
|
|
351
410
|
readonly pseudo?: {
|
|
352
|
-
readonly placeholder?: PseudoTreatment;
|
|
411
|
+
readonly placeholder?: PseudoTreatment; /** The filled part of a `<progress>`: a surface with a background; the part's own surface is the track. */
|
|
412
|
+
readonly progressValue?: PseudoTreatment;
|
|
353
413
|
};
|
|
354
414
|
/** A top-layer root (recipe root only). */
|
|
355
415
|
readonly layer?: LayerDeclaration;
|
|
@@ -437,18 +497,21 @@ type PartsDeclared<P, Empty> = [keyof P] extends [never] ? Empty : Intersection<
|
|
|
437
497
|
* parts (the names its setters are typed by): `P` infers each part's measured
|
|
438
498
|
* values, `R` each part's paints.
|
|
439
499
|
*/
|
|
440
|
-
export type RuntimeRecipeSpec<M, Q,
|
|
500
|
+
export type RuntimeRecipeSpec<M, Q, T> = Omit<RecipeSpec, "parts"> & {
|
|
441
501
|
readonly measured?: M;
|
|
442
502
|
readonly paints?: Q;
|
|
443
|
-
readonly parts?:
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
503
|
+
readonly parts?: T;
|
|
504
|
+
};
|
|
505
|
+
/** A top-level part as the recipe's setters read it: the part itself, with its runtime declarations. */
|
|
506
|
+
export type RuntimePart = RecipeSpec & {
|
|
507
|
+
readonly measured?: MeasuredDeclarations;
|
|
508
|
+
readonly paints?: PaintDeclarations;
|
|
509
|
+
};
|
|
510
|
+
/** Each part's own `measured` (or `paints`) declarations, by part name. */
|
|
511
|
+
type PartClause<T, Name extends "measured" | "paints", Empty> = {
|
|
512
|
+
readonly [K in keyof T]: T[K] extends {
|
|
513
|
+
readonly [N in Name]: infer D;
|
|
514
|
+
} ? D : Empty;
|
|
452
515
|
};
|
|
453
516
|
/** A bound part's drawing: the selected SVG text (or image URL) of an asset binding. */
|
|
454
517
|
export interface DrawingSource {
|
|
@@ -493,7 +556,7 @@ export interface Recipe<A extends Readonly<Record<string, DrawingSource | SetSou
|
|
|
493
556
|
readonly paints: PaintSetter<Q>;
|
|
494
557
|
}
|
|
495
558
|
export declare function recipe(spec: SetBindingSpec): Recipe<Readonly<Record<string, SetSource>>>;
|
|
496
|
-
export declare function recipe<const M extends MeasuredDeclarations = NoMeasured, const Q extends PaintDeclarations = NoPaints, const
|
|
559
|
+
export declare function recipe<const M extends MeasuredDeclarations = NoMeasured, const Q extends PaintDeclarations = NoPaints, const T extends Readonly<Record<string, RuntimePart>> = Readonly<Record<never, RuntimePart>>>(spec: RuntimeRecipeSpec<M, Q, T>): Recipe<Readonly<Record<string, DrawingSource>>, Declared<M, NoMeasured> & PartsDeclared<PartClause<T, "measured", NoMeasured>, NoMeasured>, Declared<Q, NoPaints> & PartsDeclared<PartClause<T, "paints", NoPaints>, NoPaints>>;
|
|
497
560
|
/** The measured values and runtime paints of every combined recipe. */
|
|
498
561
|
type CombinedMeasured<R extends readonly unknown[]> = Intersection<R[number] extends infer E ? (E extends Recipe<Readonly<Record<string, DrawingSource>>, infer M, unknown> ? M : NoMeasured) : never>;
|
|
499
562
|
type CombinedPaints<R extends readonly unknown[]> = Intersection<R[number] extends infer E ? (E extends Recipe<Readonly<Record<string, DrawingSource>>, unknown, infer Q> ? Q : NoPaints) : never>;
|
package/dist/recipe-model.mjs
CHANGED
|
@@ -48,7 +48,7 @@ function clause(parent, name, params, values) {
|
|
|
48
48
|
}
|
|
49
49
|
const strings = (value) => Array.isArray(value) && value.every((item) => typeof item === "string") ? value : null;
|
|
50
50
|
function buildProfileTree(spec) {
|
|
51
|
-
only(spec, ["name", "kind", "with", "fields", "choices", "breakpoints", "gutters", "conditions", "steps"]);
|
|
51
|
+
only(spec, ["name", "kind", "with", "fields", "choices", "breakpoints", "gutters", "conditions", "steps", "provides"]);
|
|
52
52
|
const { name, kind } = spec;
|
|
53
53
|
check(typeof name === "string" && typeof kind === "string", "Profiles need a string name and kind");
|
|
54
54
|
const inputs = spec.with === void 0 ? [] : strings(spec.with);
|
|
@@ -61,6 +61,13 @@ function buildProfileTree(spec) {
|
|
|
61
61
|
const ratios = fields.ratios;
|
|
62
62
|
if (Array.isArray(ratios))
|
|
63
63
|
fields.ratios = ratios.map((ratio) => Array.isArray(ratio) ? ratio.join(" / ") : modelValue(ratio)).join(", ");
|
|
64
|
+
const provides = spec.provides === void 0 ? {} : object(spec.provides, "Expected provided roles");
|
|
65
|
+
check(Object.keys(provides).length === 0 || kind === "surface", "Only a surface profile provides contextual roles");
|
|
66
|
+
for (const [token, value] of Object.entries(provides)) {
|
|
67
|
+
check(/^--[a-z][\w-]*$/.test(token) && typeof value === "string" && /^--[a-z][\w-]*$/.test(value), `A provided role names a token and the token it reads: ${token}`);
|
|
68
|
+
check(!Object.hasOwn(fields, token), `Duplicate provided role: ${token}`);
|
|
69
|
+
fields[token] = value;
|
|
70
|
+
}
|
|
64
71
|
declarations(node, fields);
|
|
65
72
|
for (const [choiceName, choice] of Object.entries(spec.choices === void 0 ? {} : object(spec.choices, "Expected choices"))) {
|
|
66
73
|
const declared = only(choice, ["default", "options"]), child = clause(node, "ads-choice", choiceName, declared.default ? { default: declared.default } : {});
|
|
@@ -80,16 +87,15 @@ function buildProfileTree(spec) {
|
|
|
80
87
|
required(profileDefinition(node));
|
|
81
88
|
return root;
|
|
82
89
|
}
|
|
83
|
-
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", "
|
|
84
|
-
"ads-part": ["recipe", "when", "frame", "parts", "paintTransition", "pseudo", "at", "measured", "paints", "normalize", "accessibility", "enter", "sticky", "play", "outset"],
|
|
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"],
|
|
85
92
|
"ads-cell": ["at"],
|
|
86
93
|
"ads-at": ["cells", "frame"],
|
|
87
|
-
"ads-when": ["play"],
|
|
88
|
-
"ads-pseudo": ["when"]
|
|
89
|
-
"ads-element": ["when"]
|
|
94
|
+
"ads-when": ["play", "frame"],
|
|
95
|
+
"ads-pseudo": ["when"]
|
|
90
96
|
};
|
|
91
97
|
function body(node, spec) {
|
|
92
|
-
const allowed = node.name === "ads-recipe" ? ["layout", "parts", "cells", "at", "when", "frame", "select", "alignRows", "paintTransition", "snap", ...node.parent?.type === "root" ? ["normalize", "theme", "layer", "measured", "paints", "enter", "sticky", "
|
|
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] ?? [];
|
|
93
99
|
for (const field of Object.keys(spec))
|
|
94
100
|
if (NESTED.has(field))
|
|
95
101
|
check(allowed.includes(field), `Unsupported ${field} in ${node.name}`);
|
|
@@ -108,27 +114,26 @@ function body(node, spec) {
|
|
|
108
114
|
const transition = spec.paintTransition;
|
|
109
115
|
if (transition !== void 0)
|
|
110
116
|
clause(node, "ads-paint-transition", "", only(transition, ["channels", "motion"]));
|
|
117
|
+
if (spec.geometryTransition !== void 0)
|
|
118
|
+
clause(node, "ads-geometry-transition", "", only(spec.geometryTransition, ["channels", "motion"]));
|
|
111
119
|
if (spec.sticky !== void 0)
|
|
112
120
|
clause(node, "ads-sticky", "", only(spec.sticky, ["edge", "clear"]));
|
|
113
121
|
if (spec.outset !== void 0)
|
|
114
122
|
clause(node, "ads-outset", "", only(spec.outset, ["block", "inline"]));
|
|
123
|
+
if (spec.focus !== void 0)
|
|
124
|
+
clause(node, "ads-focus", "", only(spec.focus, ["of"]));
|
|
115
125
|
if (spec.play !== void 0)
|
|
116
126
|
clause(node, "ads-play", "", only(spec.play, ["sequence", "order"]));
|
|
117
127
|
const entrance = spec.enter;
|
|
118
128
|
if (entrance !== void 0) {
|
|
119
129
|
const { from, motion } = only(entrance, ["from", "motion"]);
|
|
120
|
-
clause(node, "ads-enter", "", { ...only(from, ["surface", "translate", "scale", "rotate"]), ...motion === void 0 ? {} : { motion } });
|
|
130
|
+
clause(node, "ads-enter", "", { ...only(from, ["surface", "translate", "translateInline", "scale", "rotate"]), ...motion === void 0 ? {} : { motion } });
|
|
121
131
|
}
|
|
122
132
|
const layer = spec.layer;
|
|
123
133
|
if (layer !== void 0) {
|
|
124
134
|
const { backdrop, corner, ...fields } = only(layer, ["element", "edge", "backdrop", "motion", "modalBelow", "popover", "corner", "clear", "placement"]), nested = (name, value, keys) => value === void 0 ? [] : Object.entries(only(value, keys)).map(([key, item]) => [`${name}${key[0]?.toUpperCase() ?? ""}${key.slice(1)}`, item]);
|
|
125
135
|
clause(node, "ads-layer", "", { ...fields, ...Object.fromEntries([...nested("backdrop", backdrop, ["surface", "dismiss"]), ...nested("corner", corner, ["block", "inline"])]) });
|
|
126
136
|
}
|
|
127
|
-
for (const [name, child] of Object.entries(spec.elements === void 0 ? {} : object(spec.elements, "Invalid elements declaration"))) {
|
|
128
|
-
const { when, ...fields } = only(child, ["text", "surface", "frame", "marker", "spaceBefore", "indent", "when"]), element = clause(node, "ads-element", name, fields);
|
|
129
|
-
for (const [condition, state] of Object.entries(when === void 0 ? {} : object(when, "Invalid when declaration")))
|
|
130
|
-
body(clause(element, "ads-when", condition), object(state, "Invalid when declaration"));
|
|
131
|
-
}
|
|
132
137
|
for (const [field, kind] of [["parts", "part"], ["cells", "cell"], ["at", "at"], ["when", "when"], ["pseudo", "pseudo"]])
|
|
133
138
|
for (const [name, child] of Object.entries(spec[field] === void 0 ? {} : object(spec[field], `Invalid ${field} declaration`)))
|
|
134
139
|
body(clause(node, `ads-${kind}`, name), object(child, `Invalid ${field} declaration`));
|