@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.
- package/dist/ads-errors.mjs +105 -8
- package/dist/analysis/client-directive.mjs +26 -0
- package/dist/analysis/externals.mjs +47 -0
- package/dist/analysis/module-graph.mjs +6 -0
- package/dist/analysis/owner-analysis-key.mjs +1 -1
- package/dist/analysis/owner-choices.mjs +14 -2
- package/dist/analysis/owner-composition.mjs +32 -4
- package/dist/analysis/owner-source.mjs +121 -17
- package/dist/border-paint.mjs +34 -0
- package/dist/check.mjs +2 -0
- package/dist/composed-contrast.mjs +34 -12
- package/dist/construction-output.mjs +58 -31
- package/dist/construction-spec.d.mts +111 -15
- package/dist/construction-spec.mjs +129 -20
- package/dist/corner-overpaint.mjs +3 -1
- package/dist/design-foundation.mjs +18 -4
- package/dist/emit/owner-emission-cache.mjs +1 -1
- package/dist/end-alignment.mjs +69 -0
- package/dist/external-macro.d.mts +20 -0
- package/dist/external-macro.mjs +12 -0
- package/dist/finding-rules.mjs +3 -0
- package/dist/forced-colors.mjs +81 -0
- package/dist/frame-regions.mjs +2 -2
- package/dist/guard/externals.mjs +64 -0
- package/dist/guard/run.mjs +9 -5
- package/dist/inventories.mjs +1 -1
- package/dist/lowering-layer.mjs +38 -4
- package/dist/lowering-overlaps.mjs +13 -1
- package/dist/lowering-properties.mjs +4 -0
- package/dist/lowering-region-layout.mjs +22 -3
- package/dist/lowering-session.mjs +1 -1
- package/dist/lowering-transitions.mjs +1 -0
- package/dist/mcp/preview-http.bundle.js +2 -2
- package/dist/mcp/preview-widget.bundle.js +12 -12
- package/dist/measured-geometry.mjs +8 -2
- package/dist/owner-analysis-check.mjs +190 -11
- package/dist/owner-errors.mjs +3 -0
- package/dist/owner-lowering.mjs +3 -2
- package/dist/ownership-model.mjs +14 -5
- package/dist/platform-features.mjs +7 -0
- package/dist/preview-bun.mjs +15 -2
- package/dist/profile-macro.d.mts +18 -0
- package/dist/recipe-macro.d.mts +107 -9
- package/dist/recipe-model.mjs +22 -8
- package/dist/region-lowering.mjs +204 -49
- package/dist/render-audit/axe-run.page.mjs +40 -1
- package/dist/render-audit/forced-states.page.mjs +37 -0
- package/dist/render-audit/layout-overflow.page.mjs +52 -2
- package/dist/render-audit/non-text-contrast.page.mjs +14 -10
- package/dist/render-audit/worker.mjs +38 -0
- package/dist/render-audit.mjs +42 -5
- package/dist/role-vocabulary.d.mts +5 -2
- package/dist/role-vocabulary.mjs +6 -3
- package/dist/scenario-kit.d.mts +2 -2
- package/dist/showcase/assets-view.mjs +12 -47
- package/dist/showcase/client.bundle.js +50 -50
- package/dist/showcase/http-client.bundle.js +18 -18
- package/dist/showcase/token-sample.mjs +2 -2
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +13 -13
- package/dist/skills/ads-designer/references/accessibility.md +21 -1
- package/dist/skills/ads-designer/references/branding.md +4 -0
- package/dist/skills/ads-designer/references/design-data.md +6 -0
- package/dist/skills/ads-designer/references/layers.md +5 -0
- package/dist/skills/ads-designer/references/layout.md +8 -1
- package/dist/skills/ads-designer/references/recipes.md +52 -2
- package/dist/skills/ads-designer/references/runtimes.md +4 -0
- package/dist/skills/ads-designer/references/scenarios.md +2 -0
- package/dist/skills/ads-import/references/design-data.md +6 -0
- package/dist/skills/ads-import/references/layers.md +5 -0
- package/dist/skills/ads-import/references/layout.md +8 -1
- package/dist/skills/ads-import/references/recipes.md +52 -2
- package/dist/skills/ads-import/references/runtimes.md +4 -0
- package/dist/skills/ads-import/references/scenarios.md +2 -0
- package/dist/skills/ads-migrate/SKILL.md +2 -0
- package/dist/skills/ads-migrate/references/0.5.3-to-0.5.4.md +42 -0
- package/dist/skills/ads-migrate/references/0.5.4-to-0.5.5.md +61 -0
- package/dist/skills/ads-port/references/design-data.md +6 -0
- package/dist/skills/ads-port/references/layers.md +5 -0
- package/dist/skills/ads-port/references/layout.md +8 -1
- package/dist/skills/ads-port/references/recipes.md +52 -2
- package/dist/skills/ads-port/references/runtimes.md +4 -0
- package/dist/skills/ads-port/references/scenarios.md +2 -0
- package/dist/spatial-model.mjs +37 -10
- package/dist/system-colors.d.mts +9 -0
- package/dist/system-colors.mjs +1 -0
- package/dist/target-size.mjs +14 -1
- package/dist/tsconfig.declarations.json +1 -0
- package/docs/ADS.md +23 -1
- package/docs/ASSETS.md +21 -0
- package/docs/CACHING.md +1 -1
- package/docs/CHANGELOG.md +220 -21
- package/docs/GUIDE.md +31 -20
- package/docs/LANGUAGE.md +146 -11
- package/docs/MOTION.md +11 -1
- package/docs/PROFILE-KINDS.md +60 -9
- package/docs/RULES.md +21 -8
- package/package.json +5 -1
|
@@ -113,7 +113,7 @@ export interface RootPressState {
|
|
|
113
113
|
readonly path: string;
|
|
114
114
|
}
|
|
115
115
|
/** The paints a surface treatment can transition, as CSS transition properties. */
|
|
116
|
-
export declare const PAINT_CHANNELS: readonly ["background-color", "border-color", "color", "box-shadow", "filter", "backdrop-filter", "opacity"];
|
|
116
|
+
export declare const PAINT_CHANNELS: readonly ["background-color", "border-color", "color", "text-decoration-color", "box-shadow", "filter", "backdrop-filter", "opacity"];
|
|
117
117
|
export type PaintChannel = (typeof PAINT_CHANNELS)[number];
|
|
118
118
|
/** The motion profile that times a transition: the nearest recipe's motion slot, or a named motion profile. */
|
|
119
119
|
export type MotionBinding = {
|
|
@@ -226,16 +226,62 @@ export interface PaintTransition {
|
|
|
226
226
|
* textarea (a colour). `progressValue` is the filled part of a `<progress>` (a background): the part's own
|
|
227
227
|
* surface is its track.
|
|
228
228
|
*/
|
|
229
|
-
export declare const PSEUDO_ELEMENTS: readonly ["placeholder", "progressValue"];
|
|
229
|
+
export declare const PSEUDO_ELEMENTS: readonly ["placeholder", "progressValue", "marker", "before", "sliderTrack", "sliderThumb"];
|
|
230
230
|
export type PseudoElement = (typeof PSEUDO_ELEMENTS)[number];
|
|
231
|
-
/**
|
|
231
|
+
/** Elements that never render generated content or a marker: a `before` treatment there would never show. */
|
|
232
|
+
export declare const REPLACED_ELEMENTS: readonly string[];
|
|
233
|
+
/**
|
|
234
|
+
* The elements that have each pseudo-element: a treatment on any other element would never match. A list item's
|
|
235
|
+
* marker is on `li` and `summary` (a disclosure's marker); `before` is on any element that is not replaced.
|
|
236
|
+
*/
|
|
232
237
|
export declare const PSEUDO_HOSTS: {
|
|
233
|
-
readonly [P in PseudoElement]: readonly string[];
|
|
238
|
+
readonly [P in PseudoElement]: readonly string[] | "non-replaced";
|
|
234
239
|
};
|
|
235
|
-
/**
|
|
240
|
+
/** Whether `element` has the pseudo-element `pseudo`. */
|
|
241
|
+
export declare const pseudoHosted: (pseudo: PseudoElement, element: string) => boolean;
|
|
242
|
+
/** The number systems a marker or a counter is written in, and the bullet shapes. */
|
|
243
|
+
export declare const MARKER_STYLES: readonly ["disc", "circle", "square", "none", "decimal", "decimal-leading-zero", "lower-alpha", "upper-alpha", "lower-roman", "upper-roman"];
|
|
244
|
+
export type MarkerStyle = (typeof MARKER_STYLES)[number];
|
|
245
|
+
/** The number systems a counter's generated content may use. */
|
|
246
|
+
export declare const COUNTER_STYLES: readonly ["decimal", "decimal-leading-zero", "lower-alpha", "upper-alpha", "lower-roman", "upper-roman"];
|
|
247
|
+
export type CounterStyle = (typeof COUNTER_STYLES)[number];
|
|
248
|
+
/**
|
|
249
|
+
* Generated content a marker or a `before` pseudo-element shows: a counter's value (`counter`), or every level of
|
|
250
|
+
* a nested counter joined by `separator` (`counters`: 1.1.2), in a number system, between short literals.
|
|
251
|
+
*/
|
|
252
|
+
export interface GeneratedContent {
|
|
253
|
+
readonly kind: "counter" | "counters";
|
|
254
|
+
readonly name: string;
|
|
255
|
+
readonly style: CounterStyle;
|
|
256
|
+
readonly separator: string;
|
|
257
|
+
readonly prefix: string;
|
|
258
|
+
readonly suffix: string;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* A rule between an element's consecutive children (`between: { surface, frame }`): the frame profile's border width
|
|
262
|
+
* and style, painted by the surface's `border-color`, before every child but the first, on the arrangement's axis (a
|
|
263
|
+
* hairline between table rows or settings rows, none after the last).
|
|
264
|
+
*/
|
|
265
|
+
export interface BetweenRule {
|
|
266
|
+
readonly surface: string;
|
|
267
|
+
readonly frame: string;
|
|
268
|
+
}
|
|
269
|
+
/** An element's counters (`counter-reset`, `counter-increment`): where a count starts and what it counts. */
|
|
270
|
+
export interface CounterSpec {
|
|
271
|
+
readonly reset: string | null;
|
|
272
|
+
readonly increment: string | null;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* A pseudo-element's treatment: a colour-only surface (with owner-state treatments) for a placeholder, a progress
|
|
276
|
+
* fill or a marker; a marker's or generated content's weight and numerals (`text`); generated content.
|
|
277
|
+
*/
|
|
236
278
|
export interface PseudoTreatment {
|
|
237
279
|
readonly pseudo: PseudoElement;
|
|
238
|
-
readonly surface: string;
|
|
280
|
+
readonly surface: string | null;
|
|
281
|
+
/** A range slider's track or thumb: its frame profile (size, radius, border). */
|
|
282
|
+
readonly frame?: string | null;
|
|
283
|
+
readonly text: string | null;
|
|
284
|
+
readonly content: GeneratedContent | null;
|
|
239
285
|
readonly when: readonly StateTreatment[];
|
|
240
286
|
}
|
|
241
287
|
export type ControlSpec = ControlCommon & ({
|
|
@@ -381,6 +427,8 @@ export interface Arrangement {
|
|
|
381
427
|
readonly justify: string | null;
|
|
382
428
|
readonly wrap: boolean;
|
|
383
429
|
readonly gap: SlotBinding | null;
|
|
430
|
+
/** A wrapping row's gap between its lines, where it differs from `gap` between its items; `null`: the same. */
|
|
431
|
+
readonly rowGap?: SlotBinding | null;
|
|
384
432
|
/**
|
|
385
433
|
* `overlap`: neighbours overlap by a spacing value instead of being separated by one (a pile of faces, a
|
|
386
434
|
* stack of cards). Real layout: the row is as wide as what it shows. Never beside `gap`.
|
|
@@ -501,18 +549,25 @@ export type ElementKind = {
|
|
|
501
549
|
readonly type: "search" | "text";
|
|
502
550
|
} | {
|
|
503
551
|
readonly kind: "table";
|
|
504
|
-
}
|
|
552
|
+
}
|
|
553
|
+
/** `align`: where the cell's content sits on the block axis (`vertical-align`); centred unless stated. */
|
|
554
|
+
| {
|
|
505
555
|
readonly kind: "cell";
|
|
506
556
|
readonly header: boolean;
|
|
557
|
+
readonly align: "start" | "center" | "end";
|
|
507
558
|
} | {
|
|
508
559
|
readonly kind: "list";
|
|
509
560
|
}
|
|
561
|
+
/** The page's document: `<html>` with `<body>` inside, on a pattern's root only (one per design system). */
|
|
562
|
+
| {
|
|
563
|
+
readonly kind: "document";
|
|
564
|
+
}
|
|
510
565
|
/** `marker: "none"` removes the disclosure triangle (the compiler issues the vendor pseudo-element rule). */
|
|
511
566
|
| {
|
|
512
567
|
readonly kind: "summary";
|
|
513
568
|
readonly marker: "native" | "none";
|
|
514
569
|
};
|
|
515
|
-
export declare const ELEMENT_NAMES: readonly ["iframe", "select", "search-input", "text-input", "table", "header-cell", "cell", "list", "summary"];
|
|
570
|
+
export declare const ELEMENT_NAMES: readonly ["iframe", "select", "search-input", "text-input", "table", "header-cell", "cell", "list", "summary", "document"];
|
|
516
571
|
export type ElementName = (typeof ELEMENT_NAMES)[number];
|
|
517
572
|
/**
|
|
518
573
|
* How a text part breaks: anywhere (long words wrap), never, truncated with an
|
|
@@ -521,7 +576,7 @@ export type ElementName = (typeof ELEMENT_NAMES)[number];
|
|
|
521
576
|
* prettifying text that is cut off is meaningless, so neither combines with
|
|
522
577
|
* truncation. Browsers without `text-wrap` support wrap normally.
|
|
523
578
|
*/
|
|
524
|
-
export type TextWrap = "anywhere" | "never" | "truncate" | "balance" | "pretty";
|
|
579
|
+
export type TextWrap = "anywhere" | "never" | "truncate" | "balance" | "pretty" | "preserve";
|
|
525
580
|
export declare const TEXT_WRAPS: readonly TextWrap[];
|
|
526
581
|
export type TextAlign = "start" | "center" | "end";
|
|
527
582
|
export declare const TEXT_ALIGNS: readonly TextAlign[];
|
|
@@ -561,7 +616,7 @@ export type PartContent = {
|
|
|
561
616
|
export type StateTreatment = readonly [condition: string, surface: string];
|
|
562
617
|
export type RegionPartContent = PartContent["kind"];
|
|
563
618
|
/** The kinds of value a measured declaration carries: a px length, a px translation (x, y) or a px grid track length. */
|
|
564
|
-
export declare const MEASURED_TYPES: readonly ["length", "transform", "size-track", "position", "intrinsic-size"];
|
|
619
|
+
export declare const MEASURED_TYPES: readonly ["length", "transform", "scale", "size-track", "position", "intrinsic-size"];
|
|
565
620
|
export type MeasuredType = (typeof MEASURED_TYPES)[number];
|
|
566
621
|
/**
|
|
567
622
|
* A geometry value the owner measures or computes at runtime and writes through
|
|
@@ -588,6 +643,17 @@ export type MeasuredValue =
|
|
|
588
643
|
readonly y: number;
|
|
589
644
|
} | null;
|
|
590
645
|
readonly motion: string | null;
|
|
646
|
+
}
|
|
647
|
+
/** A scale per axis (unitless factors): an image that grows from its place into a zoom view, with a measured translation. */
|
|
648
|
+
| {
|
|
649
|
+
readonly type: "scale";
|
|
650
|
+
readonly name: string;
|
|
651
|
+
readonly property: string;
|
|
652
|
+
readonly fallback: {
|
|
653
|
+
readonly x: number;
|
|
654
|
+
readonly y: number;
|
|
655
|
+
} | null;
|
|
656
|
+
readonly motion: string | null;
|
|
591
657
|
} | {
|
|
592
658
|
readonly type: "size-track";
|
|
593
659
|
readonly name: string;
|
|
@@ -661,6 +727,11 @@ export interface RegionPart {
|
|
|
661
727
|
*/
|
|
662
728
|
readonly spaceBefore: SlotBinding | null;
|
|
663
729
|
readonly spaceAfter: SlotBinding | null;
|
|
730
|
+
/**
|
|
731
|
+
* The part's own spacing profile: its `spaceBefore` and `spaceAfter` fields are the part's space before and after
|
|
732
|
+
* it, where a flow needs more distances than one spacing profile's fields (a heading 44 px above, 14 px below).
|
|
733
|
+
*/
|
|
734
|
+
readonly spacing: string | null;
|
|
664
735
|
readonly content: PartContent;
|
|
665
736
|
readonly textEdge: readonly string[];
|
|
666
737
|
readonly textLayout: TextLayout;
|
|
@@ -702,6 +773,15 @@ export interface RegionPart {
|
|
|
702
773
|
readonly sticky: StickySpec | null;
|
|
703
774
|
/** Treatments of the part's pseudo-elements, at most one per pseudo-element. */
|
|
704
775
|
readonly pseudo: readonly PseudoTreatment[];
|
|
776
|
+
/** Where a count starts (`counter-reset`) and what the part counts (`counter-increment`). */
|
|
777
|
+
readonly counter: CounterSpec | null;
|
|
778
|
+
/** A rule between the part's consecutive children (a table body's rows). */
|
|
779
|
+
readonly between: BetweenRule | null;
|
|
780
|
+
/**
|
|
781
|
+
* `presence: "assistive"`: the part is hidden on screen and still read by assistive technology (a table's caption, a
|
|
782
|
+
* skip link's text, an icon-only control's label); `"visible"` otherwise.
|
|
783
|
+
*/
|
|
784
|
+
readonly presence: "visible" | "assistive";
|
|
705
785
|
/** A nested recipe arranging this part's children. */
|
|
706
786
|
readonly arrangement: Arrangement | null;
|
|
707
787
|
readonly parts: readonly RegionPart[];
|
|
@@ -721,11 +801,14 @@ export type LayerSpec = ModalSheet | AnchoredPopover | MeasuredPopover;
|
|
|
721
801
|
export interface ModalSheet {
|
|
722
802
|
readonly kind: "modal-sheet";
|
|
723
803
|
readonly element: "dialog";
|
|
724
|
-
/**
|
|
725
|
-
|
|
804
|
+
/**
|
|
805
|
+
* Inline edge the sheet is attached to (logical, so it mirrors in RTL), or a card's place: `center` in the
|
|
806
|
+
* viewport, or `block-start` (centred inline, the layer profile's margin below the top).
|
|
807
|
+
*/
|
|
808
|
+
readonly edge: "start" | "end" | "center" | "block-start";
|
|
726
809
|
readonly backdrop: Backdrop;
|
|
727
|
-
/**
|
|
728
|
-
readonly motion: "slide" | null;
|
|
810
|
+
/** A sheet travels its own extent from `edge`, a card fades; `null` opens and closes instantly. */
|
|
811
|
+
readonly motion: "slide" | "fade" | null;
|
|
729
812
|
/** Breakpoint tier of the selected spatial profile from which the owner shows its inline alternative; `null` = modal at every size. */
|
|
730
813
|
readonly modalBelow: string | null;
|
|
731
814
|
}
|
|
@@ -762,6 +845,19 @@ export interface Backdrop {
|
|
|
762
845
|
export interface RegionSpec {
|
|
763
846
|
readonly kind: "region";
|
|
764
847
|
readonly source: JsonObject;
|
|
848
|
+
/** The root's own pseudo-elements: a list item's marker, generated content before the root. */
|
|
849
|
+
readonly pseudo: readonly PseudoTreatment[];
|
|
850
|
+
/** Where a count starts on the root and what the root counts. */
|
|
851
|
+
readonly counter: CounterSpec | null;
|
|
852
|
+
/** A list's marker style at each nesting depth, outermost first. */
|
|
853
|
+
readonly markers: readonly MarkerStyle[];
|
|
854
|
+
/** A rule between the root's consecutive children. */
|
|
855
|
+
readonly between: BetweenRule | null;
|
|
856
|
+
/**
|
|
857
|
+
* Loose flow (a list whose items hold paragraphs and code): the root's stack gap is given to its children, and its
|
|
858
|
+
* last part's own space after carries out of it, so what follows starts at the larger of the two.
|
|
859
|
+
*/
|
|
860
|
+
readonly carry: boolean;
|
|
765
861
|
/** `null` for a treatment fragment without a profile. */
|
|
766
862
|
readonly profile: string | null;
|
|
767
863
|
readonly select: Readonly<Record<string, string>>;
|
|
@@ -826,7 +922,7 @@ export interface GridCell {
|
|
|
826
922
|
}
|
|
827
923
|
/** A grid's track system: owned tracks (`hybrid`, `fluid`), auto-filled tiles (`fixed`) or the parent cell's tracks (`inherited`). */
|
|
828
924
|
export type GridMode = "hybrid" | "fluid" | "fixed" | "inherited";
|
|
829
|
-
export declare const GRID_FIELDS: readonly ["columns", "weights", "gutter", "margin", "bound", "rows", "context", "align"];
|
|
925
|
+
export declare const GRID_FIELDS: readonly ["columns", "weights", "gutter", "margin", "bound", "rows", "context", "align", "contentFrom"];
|
|
830
926
|
export type GridField = (typeof GRID_FIELDS)[number];
|
|
831
927
|
/** Cell placements under a named condition of the spatial profile (`narrow-content`), replacing tier placement while it holds. */
|
|
832
928
|
export interface NamedPlacement {
|
|
@@ -2,19 +2,22 @@ import { attempt } from "./result.mjs";
|
|
|
2
2
|
import { COLOR_SCHEMES } from "./scheme-switch.mjs";
|
|
3
3
|
import { isJsonObject, isRecord } from "./json.mjs";
|
|
4
4
|
import { conditionParts, parseStateCondition } from "./state-conditions.mjs";
|
|
5
|
-
export const ACCESSIBILITY_BOUNDARIES = ["visible-label", "boundary-on-interaction"], REASON_LENGTH = { min: 20, max: 300 }, PAINT_CHANNELS = ["background-color", "border-color", "color", "box-shadow", "filter", "backdrop-filter", "opacity"], PART_EFFECTS = {
|
|
5
|
+
export const ACCESSIBILITY_BOUNDARIES = ["visible-label", "boundary-on-interaction"], REASON_LENGTH = { min: 20, max: 300 }, PAINT_CHANNELS = ["background-color", "border-color", "color", "text-decoration-color", "box-shadow", "filter", "backdrop-filter", "opacity"], PART_EFFECTS = {
|
|
6
6
|
scale: { channel: "scale", field: "scale" },
|
|
7
7
|
scaleInline: { channel: "scale", field: "scale" },
|
|
8
8
|
scaleBlock: { channel: "scale", field: "scale" },
|
|
9
9
|
translateInline: { channel: "translate", field: "distance" },
|
|
10
10
|
translateBlock: { channel: "translate", field: "distance" },
|
|
11
11
|
rotate: { channel: "rotate", field: "angle" }
|
|
12
|
-
}, scaleValue = (effect, value) => effect === "scale" ? value : effect === "scaleInline" || effect === "scale-inline" ? `${value} 1` : `1 ${value}`, STICKY_EDGES = ["block-start", "block-end"], ENTER_MOVEMENTS = { translate: "distance", translateInline: "distance", scale: "scale", rotate: "angle" }, PSEUDO_ELEMENTS = ["placeholder", "progressValue"
|
|
12
|
+
}, scaleValue = (effect, value) => effect === "scale" ? value : effect === "scaleInline" || effect === "scale-inline" ? `${value} 1` : `1 ${value}`, STICKY_EDGES = ["block-start", "block-end"], ENTER_MOVEMENTS = { translate: "distance", translateInline: "distance", scale: "scale", rotate: "angle" }, PSEUDO_ELEMENTS = ["placeholder", "progressValue", "marker", "before", "sliderTrack", "sliderThumb"], REPLACED_ELEMENTS = ["img", "input", "select", "textarea", "video", "iframe", "br", "hr", "svg"], PSEUDO_HOSTS = { placeholder: ["input", "textarea"], progressValue: ["progress"], marker: ["li", "summary"], before: "non-replaced", sliderTrack: ["input"], sliderThumb: ["input"] }, pseudoHosted = (pseudo, element) => {
|
|
13
|
+
const hosts = PSEUDO_HOSTS[pseudo];
|
|
14
|
+
return hosts === "non-replaced" ? !REPLACED_ELEMENTS.includes(element) : hosts.includes(element);
|
|
15
|
+
}, MARKER_STYLES = ["disc", "circle", "square", "none", "decimal", "decimal-leading-zero", "lower-alpha", "upper-alpha", "lower-roman", "upper-roman"], COUNTER_STYLES = ["decimal", "decimal-leading-zero", "lower-alpha", "upper-alpha", "lower-roman", "upper-roman"], SNAP_TYPES = ["inline mandatory", "inline proximity", "block mandatory", "block proximity", "both mandatory", "both proximity"], SNAP_ALIGNS = ["start", "center", "end"], GEOMETRY_CHANNELS = ["size", "inset", "gap", "radius", "border-width", "overlap"], FRAME_SIDES = ["block-start", "block-end", "inline-start", "inline-end"], FRAME_CORNERS = ["start-start", "start-end", "end-start", "end-end"], CORNER_RADIUS_FIELDS = {
|
|
13
16
|
"start-start": "start-start-radius",
|
|
14
17
|
"start-end": "start-end-radius",
|
|
15
18
|
"end-start": "end-start-radius",
|
|
16
19
|
"end-end": "end-end-radius"
|
|
17
|
-
}, cornerRadius = (field, corner) => field(CORNER_RADIUS_FIELDS[corner]) ?? field("radius"), OVERFLOW_VALUES = ["clip", "scroll-block", "scroll-inline", "scroll-both"], ELEMENT_NAMES = ["iframe", "select", "search-input", "text-input", "table", "header-cell", "cell", "list", "summary"], TEXT_WRAPS = ["anywhere", "never", "truncate", "balance", "pretty"], TEXT_ALIGNS = ["start", "center", "end"], MEASURED_TYPES = ["length", "transform", "size-track", "position", "intrinsic-size"], GRID_FIELDS = ["columns", "weights", "gutter", "margin", "bound", "rows", "context", "align"];
|
|
20
|
+
}, cornerRadius = (field, corner) => field(CORNER_RADIUS_FIELDS[corner]) ?? field("radius"), OVERFLOW_VALUES = ["clip", "scroll-block", "scroll-inline", "scroll-both"], ELEMENT_NAMES = ["iframe", "select", "search-input", "text-input", "table", "header-cell", "cell", "list", "summary", "document"], TEXT_WRAPS = ["anywhere", "never", "truncate", "balance", "pretty", "preserve"], TEXT_ALIGNS = ["start", "center", "end"], MEASURED_TYPES = ["length", "transform", "scale", "size-track", "position", "intrinsic-size"], GRID_FIELDS = ["columns", "weights", "gutter", "margin", "bound", "rows", "context", "align", "contentFrom"];
|
|
18
21
|
export function elementTags(element) {
|
|
19
22
|
switch (element.kind) {
|
|
20
23
|
case "iframe":
|
|
@@ -27,6 +30,8 @@ export function elementTags(element) {
|
|
|
27
30
|
return [element.header ? "th" : "td"];
|
|
28
31
|
case "list":
|
|
29
32
|
return ["ul", "ol"];
|
|
33
|
+
case "document":
|
|
34
|
+
return ["html"];
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
export const CONTROL_TEXT_TAGS = ["button", "label", "legend", "summary", "select", "option", "input", "textarea"], VECTOR_SHAPES = ["line", "path", "circle", "rect", "polyline"];
|
|
@@ -373,26 +378,29 @@ function artwork(spec, read) {
|
|
|
373
378
|
}
|
|
374
379
|
const REGION_LAYOUTS = ["inline", "stack", "flow", "layered"], ROOT_LAYOUTS = REGION_LAYOUTS;
|
|
375
380
|
export const ROOT_EXTENTS = ["content", "container"];
|
|
376
|
-
function rootExtent(value, layout, layer, read) {
|
|
381
|
+
function rootExtent(value, layout, layer, read, table = !1) {
|
|
377
382
|
if (value === void 0)
|
|
378
383
|
return "content";
|
|
379
|
-
if (layout !== "inline" || layer !== null)
|
|
384
|
+
if (layout !== "inline" && !table || layer !== null)
|
|
380
385
|
return read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.extent" });
|
|
381
386
|
return read.literal(value, "recipe.extent", ROOT_EXTENTS);
|
|
382
387
|
}
|
|
383
388
|
function arrangement(spec, read, path, layout) {
|
|
384
|
-
const gap = spec.gap ?? spec.rowGap;
|
|
389
|
+
const gap = spec.gap ?? spec.rowGap, rowGap = spec.gap !== void 0 && spec.rowGap !== void 0 ? spec.rowGap : void 0;
|
|
385
390
|
if (layout === "layered") {
|
|
386
391
|
for (const field of ["gap", "rowGap", "wrap"])
|
|
387
392
|
if (spec[field] !== void 0)
|
|
388
393
|
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.${field}` });
|
|
389
394
|
}
|
|
395
|
+
if (layout === "layered" && typeof spec.justify === "string" && spec.justify.startsWith("space-"))
|
|
396
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.justify` });
|
|
390
397
|
return {
|
|
391
398
|
layout,
|
|
392
399
|
align: read.optionalString(spec.align, `${path}.align`),
|
|
393
400
|
justify: read.optionalString(spec.justify, `${path}.justify`),
|
|
394
401
|
wrap: read.boolean(spec.wrap, `${path}.wrap`),
|
|
395
402
|
gap: gap === void 0 ? null : read.slot(gap, `${path}.gap`, "spacing"),
|
|
403
|
+
...rowGap === void 0 ? {} : { rowGap: read.slot(rowGap, `${path}.rowGap`, "spacing") },
|
|
396
404
|
overlap: overlapSpec(spec, read, path, layout),
|
|
397
405
|
snap: snap(spec.snap, `${path}.snap`, read)
|
|
398
406
|
};
|
|
@@ -593,13 +601,80 @@ function enterSpec(value, path, read) {
|
|
|
593
601
|
read.slotless(motion, `${path}.motion`, "motion");
|
|
594
602
|
return { driver: { kind: "first-render" }, surface, movement, motion: { kind: "slot" }, path };
|
|
595
603
|
}
|
|
604
|
+
const COUNTER_NAME = /^[a-z][a-z0-9-]*$/, RESERVED_COUNTERS = ["none", "inherit", "initial", "unset", "revert", "revert-layer", "default"];
|
|
605
|
+
function counterName(value, path, read) {
|
|
606
|
+
const name = read.string(value, path);
|
|
607
|
+
if (!COUNTER_NAME.test(name) || RESERVED_COUNTERS.includes(name))
|
|
608
|
+
read.invalid(path, "a counter name: lowercase letters, digits and hyphens, not a CSS keyword");
|
|
609
|
+
return name;
|
|
610
|
+
}
|
|
611
|
+
function contentLiteral(value, path, read, fallback) {
|
|
612
|
+
if (value === void 0)
|
|
613
|
+
return fallback;
|
|
614
|
+
const text = read.string(value, path);
|
|
615
|
+
if (text.length > 4 || !/^[\p{P}\p{S}\p{Zs}]*$/u.test(text))
|
|
616
|
+
read.invalid(path, "at most four punctuation marks or spaces");
|
|
617
|
+
return text;
|
|
618
|
+
}
|
|
619
|
+
function generatedContent(value, path, read) {
|
|
620
|
+
if (value === void 0)
|
|
621
|
+
return null;
|
|
622
|
+
const declared = read.object(value, path);
|
|
623
|
+
read.only(declared, path, ["counter", "counters", "style", "separator", "prefix", "suffix"]);
|
|
624
|
+
const kind = declared.counters !== void 0 ? "counters" : "counter";
|
|
625
|
+
if (declared.counter === void 0 === (declared.counters === void 0))
|
|
626
|
+
read.invalid(path, "one of `counter` (a value) and `counters` (every level, joined by `separator`)");
|
|
627
|
+
if (kind === "counter" && declared.separator !== void 0)
|
|
628
|
+
read.invalid(`${path}.separator`, "omitted with `counter`: one level has nothing to join");
|
|
629
|
+
return {
|
|
630
|
+
kind,
|
|
631
|
+
name: counterName(declared[kind], `${path}.${kind}`, read),
|
|
632
|
+
style: declared.style === void 0 ? "decimal" : read.literal(declared.style, `${path}.style`, COUNTER_STYLES),
|
|
633
|
+
separator: contentLiteral(declared.separator, `${path}.separator`, read, "."),
|
|
634
|
+
prefix: contentLiteral(declared.prefix, `${path}.prefix`, read, ""),
|
|
635
|
+
suffix: contentLiteral(declared.suffix, `${path}.suffix`, read, "")
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
function counterSpec(value, path, read) {
|
|
639
|
+
if (value === void 0)
|
|
640
|
+
return null;
|
|
641
|
+
const declared = read.object(value, path);
|
|
642
|
+
read.only(declared, path, ["reset", "increment"]);
|
|
643
|
+
if (declared.reset === void 0 && declared.increment === void 0)
|
|
644
|
+
read.invalid(path, "a `reset`, an `increment` or both");
|
|
645
|
+
return {
|
|
646
|
+
reset: declared.reset === void 0 ? null : counterName(declared.reset, `${path}.reset`, read),
|
|
647
|
+
increment: declared.increment === void 0 ? null : counterName(declared.increment, `${path}.increment`, read)
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
function betweenRule(value, path, read) {
|
|
651
|
+
if (value === void 0)
|
|
652
|
+
return null;
|
|
653
|
+
const declared = read.object(value, path);
|
|
654
|
+
read.only(declared, path, ["surface", "frame"]);
|
|
655
|
+
return { surface: read.string(declared.surface, `${path}.surface`), frame: read.string(declared.frame, `${path}.frame`) };
|
|
656
|
+
}
|
|
657
|
+
function markerStyles(value, path, read) {
|
|
658
|
+
if (value === void 0)
|
|
659
|
+
return [];
|
|
660
|
+
const styles = read.strings(value, path).map((style) => read.literal(style, path, MARKER_STYLES));
|
|
661
|
+
if (styles.length === 0 || styles.length > 3)
|
|
662
|
+
read.invalid(path, "one to three marker styles, outermost list first");
|
|
663
|
+
return styles;
|
|
664
|
+
}
|
|
596
665
|
function pseudoTreatments(value, path, read) {
|
|
597
666
|
if (value === void 0)
|
|
598
667
|
return [];
|
|
599
668
|
return Object.entries(read.object(value, path)).map(([name, treatment]) => {
|
|
600
|
-
const at = `${path}.${name}`, pseudo = read.literal(name, at, PSEUDO_ELEMENTS), fields = read.object(treatment, at);
|
|
601
|
-
read.only(fields, at, ["surface", "when"]);
|
|
602
|
-
|
|
669
|
+
const at = `${path}.${name}`, pseudo = read.literal(name, at, PSEUDO_ELEMENTS), fields = read.object(treatment, at), generated = pseudo === "marker" || pseudo === "before", slider = pseudo === "sliderTrack" || pseudo === "sliderThumb";
|
|
670
|
+
read.only(fields, at, generated ? ["surface", "text", "content", "when"] : slider ? ["surface", "frame", "when"] : ["surface", "when"]);
|
|
671
|
+
const surface = generated ? read.optionalString(fields.surface, `${at}.surface`) : read.string(fields.surface, `${at}.surface`), text = read.optionalString(fields.text, `${at}.text`), content = generatedContent(fields.content, `${at}.content`, read);
|
|
672
|
+
if (pseudo === "before" && content === null)
|
|
673
|
+
read.invalid(`${at}.content`, "the generated content `before` shows (a counter)");
|
|
674
|
+
if (pseudo === "marker" && surface === null && text === null && content === null)
|
|
675
|
+
read.invalid(at, "a `surface`, a `text`, a `content` or several");
|
|
676
|
+
const frame = slider ? read.string(fields.frame, `${at}.frame`) : null;
|
|
677
|
+
return { pseudo, surface, text, content, ...slider ? { frame } : {}, when: treatments(fields.when, `${at}.when`, read) };
|
|
603
678
|
});
|
|
604
679
|
}
|
|
605
680
|
function frameBorder(value, path, read) {
|
|
@@ -706,7 +781,7 @@ export function normalizedDeclarations(values) {
|
|
|
706
781
|
}
|
|
707
782
|
const isNormalizeField = (key) => Object.hasOwn(NORMALIZE_FIELDS, key);
|
|
708
783
|
export const INTERACTION_FIELDS = ["cursor", "touchAction", "userSelect"];
|
|
709
|
-
const PART_NORMALIZE = [...INTERACTION_FIELDS, "resize"], CONTROL_NORMALIZE = ["borderStyle", "textDecoration", ...INTERACTION_FIELDS], REGION_NORMALIZE = ["margin", "borderStyle", "textDecoration", "pointerEvents", ...INTERACTION_FIELDS];
|
|
784
|
+
const PART_NORMALIZE = [...INTERACTION_FIELDS, "resize", "margin"], CONTROL_NORMALIZE = ["borderStyle", "textDecoration", ...INTERACTION_FIELDS], REGION_NORMALIZE = ["margin", "borderStyle", "textDecoration", "pointerEvents", ...INTERACTION_FIELDS];
|
|
710
785
|
function normalizeValues(values, path, fields, read) {
|
|
711
786
|
read.only(values, path, fields);
|
|
712
787
|
return Object.entries(values).flatMap(([key, value]) => {
|
|
@@ -778,7 +853,9 @@ function overflow(value, path, read) {
|
|
|
778
853
|
return { kind: "scroll", axis: "both" };
|
|
779
854
|
}
|
|
780
855
|
}
|
|
781
|
-
function elementKind(value, marker, path, read) {
|
|
856
|
+
function elementKind(value, marker, path, read, align) {
|
|
857
|
+
if (align !== void 0 && value !== "cell" && value !== "header-cell")
|
|
858
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.align` });
|
|
782
859
|
if (value === void 0) {
|
|
783
860
|
if (marker !== void 0)
|
|
784
861
|
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.marker` });
|
|
@@ -793,14 +870,17 @@ function elementKind(value, marker, path, read) {
|
|
|
793
870
|
case "table":
|
|
794
871
|
case "list":
|
|
795
872
|
return { kind: name };
|
|
873
|
+
case "document":
|
|
874
|
+
if (path !== "recipe")
|
|
875
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.element` });
|
|
876
|
+
return { kind: name };
|
|
796
877
|
case "search-input":
|
|
797
878
|
return { kind: "input", type: "search" };
|
|
798
879
|
case "text-input":
|
|
799
880
|
return { kind: "input", type: "text" };
|
|
800
881
|
case "header-cell":
|
|
801
|
-
return { kind: "cell", header: !0 };
|
|
802
882
|
case "cell":
|
|
803
|
-
return { kind: "cell", header:
|
|
883
|
+
return { kind: "cell", header: name === "header-cell", align: align === void 0 ? "center" : read.literal(align, `${path}.align`, ["start", "center", "end"]) };
|
|
804
884
|
case "summary":
|
|
805
885
|
return { kind: "summary", marker: marker === void 0 ? "native" : read.literal(marker, `${path}.marker`, ["native", "none"]) };
|
|
806
886
|
}
|
|
@@ -849,7 +929,7 @@ function partContent(part, path, read) {
|
|
|
849
929
|
return { kind };
|
|
850
930
|
case "component": {
|
|
851
931
|
for (const field of Object.keys(part))
|
|
852
|
-
if (!["kind", "selector", "required", "repeat", "extent", "at", "spaceBefore", "spaceAfter"].includes(field))
|
|
932
|
+
if (!["kind", "selector", "required", "repeat", "extent", "at", "spaceBefore", "spaceAfter", "spacing"].includes(field))
|
|
853
933
|
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.${field}` });
|
|
854
934
|
return { kind };
|
|
855
935
|
}
|
|
@@ -897,6 +977,15 @@ function measuredValues(value, path, read) {
|
|
|
897
977
|
read.only(offset, `${at}.fallback`, ["x", "y"]);
|
|
898
978
|
return { type, name, property, fallback: { x: pixels(offset.x, `${at}.fallback.x`, read), y: pixels(offset.y, `${at}.fallback.y`, read) }, motion };
|
|
899
979
|
}
|
|
980
|
+
case "scale": {
|
|
981
|
+
read.only(fields, at, ["type", "property", "fallback", "motion"]);
|
|
982
|
+
if (fallback === void 0)
|
|
983
|
+
return { type, name, property, fallback: null, motion };
|
|
984
|
+
const factors = read.object(fallback, `${at}.fallback`);
|
|
985
|
+
read.only(factors, `${at}.fallback`, ["x", "y"]);
|
|
986
|
+
const factor = (value, path) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : read.invalid(path, "a positive scale factor");
|
|
987
|
+
return { type, name, property, fallback: { x: factor(factors.x, `${at}.fallback.x`), y: factor(factors.y, `${at}.fallback.y`) }, motion };
|
|
988
|
+
}
|
|
900
989
|
case "size-track": {
|
|
901
990
|
read.only(fields, at, ["type", "property", "track", "fallback", "motion"]);
|
|
902
991
|
const track = fields.track;
|
|
@@ -987,6 +1076,7 @@ function regionPart(name, value, read, path, nested) {
|
|
|
987
1076
|
"at",
|
|
988
1077
|
"element",
|
|
989
1078
|
"marker",
|
|
1079
|
+
"align",
|
|
990
1080
|
"media",
|
|
991
1081
|
"stroke",
|
|
992
1082
|
"accessibility",
|
|
@@ -998,6 +1088,10 @@ function regionPart(name, value, read, path, nested) {
|
|
|
998
1088
|
"repeat",
|
|
999
1089
|
"spaceBefore",
|
|
1000
1090
|
"spaceAfter",
|
|
1091
|
+
"counter",
|
|
1092
|
+
"spacing",
|
|
1093
|
+
"between",
|
|
1094
|
+
"presence",
|
|
1001
1095
|
...VISUAL_BINDING_FIELDS,
|
|
1002
1096
|
...nested ? [] : ["measured", "paints"]
|
|
1003
1097
|
]);
|
|
@@ -1024,13 +1118,14 @@ function regionPart(name, value, read, path, nested) {
|
|
|
1024
1118
|
repeat: part.repeat === void 0 ? !1 : read.boolean(part.repeat, `${path}.repeat`),
|
|
1025
1119
|
spaceBefore: part.spaceBefore === void 0 ? null : read.slot(part.spaceBefore, `${path}.spaceBefore`, "spacing"),
|
|
1026
1120
|
spaceAfter: part.spaceAfter === void 0 ? null : read.slot(part.spaceAfter, `${path}.spaceAfter`, "spacing"),
|
|
1121
|
+
spacing: read.optionalString(part.spacing, `${path}.spacing`),
|
|
1027
1122
|
content,
|
|
1028
1123
|
textEdge: part.textEdge === void 0 ? [] : read.strings(part.textEdge, `${path}.textEdge`),
|
|
1029
1124
|
textLayout: textLayout(part, path, read),
|
|
1030
1125
|
overflow: overflow(part.overflow, `${path}.overflow`, read),
|
|
1031
1126
|
extent: extent(part.extent, `${path}.extent`, read),
|
|
1032
1127
|
at: partConditions(part.at, `${path}.at`, read),
|
|
1033
|
-
element: elementKind(part.element, part.marker, path, read),
|
|
1128
|
+
element: elementKind(part.element, part.marker, path, read, part.align),
|
|
1034
1129
|
text: textBinding(part.text, `${path}.text`, read),
|
|
1035
1130
|
surface: read.optionalString(part.surface, `${path}.surface`),
|
|
1036
1131
|
frame: boxed === null ? controlFrame(part.frame, `${path}.frame`, read) : null,
|
|
@@ -1054,6 +1149,9 @@ function regionPart(name, value, read, path, nested) {
|
|
|
1054
1149
|
anchorClear: anchorClear(part.anchorClear, `${path}.anchorClear`, read),
|
|
1055
1150
|
scheme: partScheme(part, content, path, read),
|
|
1056
1151
|
pseudo: pseudoTreatments(part.pseudo, `${path}.pseudo`, read),
|
|
1152
|
+
counter: counterSpec(part.counter, `${path}.counter`, read),
|
|
1153
|
+
between: betweenRule(part.between, `${path}.between`, read),
|
|
1154
|
+
presence: part.presence === void 0 ? "visible" : read.literal(part.presence, `${path}.presence`, ["visible", "assistive"]),
|
|
1057
1155
|
arrangement: arranged,
|
|
1058
1156
|
parts: parseParts(part.parts, read, path, !0),
|
|
1059
1157
|
measured: measuredValues(part.measured, `${path}.measured`, read),
|
|
@@ -1162,6 +1260,11 @@ function region(authored, read) {
|
|
|
1162
1260
|
"sticky",
|
|
1163
1261
|
"play",
|
|
1164
1262
|
"at",
|
|
1263
|
+
"pseudo",
|
|
1264
|
+
"counter",
|
|
1265
|
+
"markers",
|
|
1266
|
+
"between",
|
|
1267
|
+
"carry",
|
|
1165
1268
|
"parts",
|
|
1166
1269
|
"exposeRows",
|
|
1167
1270
|
"layer",
|
|
@@ -1189,16 +1292,21 @@ function region(authored, read) {
|
|
|
1189
1292
|
return {
|
|
1190
1293
|
kind: "region",
|
|
1191
1294
|
source: authored,
|
|
1295
|
+
pseudo: pseudoTreatments(spec.pseudo, "recipe.pseudo", read).map((treatment) => treatment.pseudo === "marker" || treatment.pseudo === "before" ? treatment : read.reject({ kind: "field-unsupported", construction: "region", path: `recipe.pseudo.${treatment.pseudo}` })),
|
|
1296
|
+
counter: counterSpec(spec.counter, "recipe.counter", read),
|
|
1297
|
+
markers: markerStyles(spec.markers, "recipe.markers", read),
|
|
1298
|
+
between: betweenRule(spec.between, "recipe.between", read),
|
|
1299
|
+
carry: read.boolean(spec.carry, "recipe.carry"),
|
|
1192
1300
|
profile: read.optionalString(spec.profile, "recipe.profile"),
|
|
1193
1301
|
select: Object.fromEntries(spec.select === void 0 ? [] : read.stringRecord(spec.select, "recipe.select")),
|
|
1194
1302
|
arrangement: arrangement(spec, read, "recipe", layout),
|
|
1195
|
-
extent: rootExtent(spec.extent, layout, layer, read),
|
|
1303
|
+
extent: rootExtent(spec.extent, layout, layer, read, spec.element === "table"),
|
|
1196
1304
|
frame: regionFrame(spec.frame, read),
|
|
1197
1305
|
surface: read.optionalString(spec.surface, "recipe.surface"),
|
|
1198
1306
|
text: textBinding(spec.text, "recipe.text", read),
|
|
1199
1307
|
textAlign: spec.textAlign === void 0 ? null : read.literal(spec.textAlign, "recipe.textAlign", TEXT_ALIGNS),
|
|
1200
1308
|
overflow: overflow(spec.overflow, "recipe.overflow", read),
|
|
1201
|
-
element: elementKind(spec.element, spec.marker, "recipe", read),
|
|
1309
|
+
element: elementKind(spec.element, spec.marker, "recipe", read, spec.element === "cell" || spec.element === "header-cell" ? spec.align : void 0),
|
|
1202
1310
|
normalize: normalized.values,
|
|
1203
1311
|
normalizeWhen: normalized.when,
|
|
1204
1312
|
when: rootStates.when,
|
|
@@ -1219,7 +1327,7 @@ function region(authored, read) {
|
|
|
1219
1327
|
paints
|
|
1220
1328
|
};
|
|
1221
1329
|
}
|
|
1222
|
-
const EDGES = ["start", "end"];
|
|
1330
|
+
const EDGES = ["start", "end"], DIALOG_EDGES = ["start", "end", "center", "block-start"];
|
|
1223
1331
|
function layerSpec(value, read) {
|
|
1224
1332
|
if (value === void 0)
|
|
1225
1333
|
return null;
|
|
@@ -1229,15 +1337,16 @@ function layerSpec(value, read) {
|
|
|
1229
1337
|
read.only(layer, path, ["element", "edge", "backdrop", "motion", "modalBelow"]);
|
|
1230
1338
|
const backdrop = read.object(layer.backdrop, `${path}.backdrop`);
|
|
1231
1339
|
read.only(backdrop, `${path}.backdrop`, ["surface", "dismiss"]);
|
|
1340
|
+
const edge = read.literal(layer.edge, `${path}.edge`, DIALOG_EDGES), card = edge === "center" || edge === "block-start";
|
|
1232
1341
|
return {
|
|
1233
1342
|
kind: "modal-sheet",
|
|
1234
1343
|
element,
|
|
1235
|
-
edge
|
|
1344
|
+
edge,
|
|
1236
1345
|
backdrop: {
|
|
1237
1346
|
surface: read.string(backdrop.surface, `${path}.backdrop.surface`),
|
|
1238
1347
|
dismiss: backdrop.dismiss === void 0 ? "none" : read.literal(backdrop.dismiss, `${path}.backdrop.dismiss`, ["press", "none"])
|
|
1239
1348
|
},
|
|
1240
|
-
motion: layer.motion === void 0 ? null : read.literal(layer.motion, `${path}.motion`, ["slide"]),
|
|
1349
|
+
motion: layer.motion === void 0 ? null : card ? read.literal(layer.motion, `${path}.motion`, ["fade"]) : read.literal(layer.motion, `${path}.motion`, ["slide"]),
|
|
1241
1350
|
modalBelow: read.optionalString(layer.modalBelow, `${path}.modalBelow`)
|
|
1242
1351
|
};
|
|
1243
1352
|
}
|
|
@@ -47,9 +47,11 @@ function overpaintUnder(foundation, spec, under) {
|
|
|
47
47
|
const corners = reached(index);
|
|
48
48
|
if (corners.length === 0)
|
|
49
49
|
continue;
|
|
50
|
-
const box = fieldsOf(foundation, framedUnder(
|
|
50
|
+
const own = part.box ?? (part.frame !== null ? slots.get("frame-profile") ?? null : null), box = fieldsOf(foundation, framedUnder(own, part.geometryWhen, under), "frame");
|
|
51
51
|
if (box !== null && corners.every((corner) => cornerRadius((field) => box.get(field), corner) !== void 0))
|
|
52
52
|
continue;
|
|
53
|
+
if (box?.get("border-width") !== void 0 && box.get("border-style") !== "forced-only")
|
|
54
|
+
return { kind: "corner-overpaint", part: part.name, surface: part.surface ?? "", state: null, corners, under, paint: "border" };
|
|
53
55
|
for (const [state, name] of [[null, part.surface], ...part.when]) {
|
|
54
56
|
const background = fieldsOf(foundation, name, "surface")?.get("background");
|
|
55
57
|
if (name === null || background === void 0)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FORCED_PREFIX, SYSTEM_COLORS } from "./forced-colors.mjs";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import postcss, { CssSyntaxError } from "postcss";
|
|
3
4
|
import { readTokenRegistrations } from "./token-registrations.mjs";
|
|
@@ -119,15 +120,20 @@ export function readFoundation(captured, contexts) {
|
|
|
119
120
|
for (const [field, value] of Object.entries(variant.fields)) {
|
|
120
121
|
if (field.startsWith("--")) {
|
|
121
122
|
const own = tokens.get(field)?.role ?? null;
|
|
122
|
-
if (own !== "paint")
|
|
123
|
-
return reject({ kind: "token-role", profile: name, field, token: field, role: own, expected: ["paint"] });
|
|
123
|
+
if (own !== "paint" && own !== "border-width")
|
|
124
|
+
return reject({ kind: "token-role", profile: name, field, token: field, role: own, expected: ["paint", "border-width"] });
|
|
124
125
|
for (const token of references(value)) {
|
|
125
126
|
const role = tokens.get(token)?.role ?? null;
|
|
126
|
-
if (role !==
|
|
127
|
-
return reject({ kind: "token-role", profile: name, field, token, role, expected: [
|
|
127
|
+
if (role !== own)
|
|
128
|
+
return reject({ kind: "token-role", profile: name, field, token, role, expected: [own] });
|
|
128
129
|
}
|
|
129
130
|
continue;
|
|
130
131
|
}
|
|
132
|
+
if (field.startsWith(FORCED_PREFIX)) {
|
|
133
|
+
if (!SYSTEM_COLORS.includes(value))
|
|
134
|
+
return reject({ kind: "forced-color-invalid", profile: name, field, value });
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
131
137
|
const expected = roles?.[field];
|
|
132
138
|
if (expected === void 0)
|
|
133
139
|
continue;
|
|
@@ -210,6 +216,7 @@ function slotArguments(spec, file, declaration) {
|
|
|
210
216
|
return Object.entries(objectAt(value.select)).map(([choice, option]) => ({ file, declaration, path: [...path, field, "select", choice], profile, reference, choice, option: String(option) }));
|
|
211
217
|
}));
|
|
212
218
|
}
|
|
219
|
+
const DOCUMENT_TEXT_FIELDS = ["font-family", "font-size", "line-height"];
|
|
213
220
|
export function documentProfiles(foundation, references) {
|
|
214
221
|
const fields = (field) => {
|
|
215
222
|
const reference = references[field], profile = selectedProfile(foundation, reference);
|
|
@@ -221,6 +228,9 @@ export function documentProfiles(foundation, references) {
|
|
|
221
228
|
}, text = fields("text");
|
|
222
229
|
if (text.kind === "err")
|
|
223
230
|
return text;
|
|
231
|
+
const missing = DOCUMENT_TEXT_FIELDS.filter((field) => !text.value.has(field));
|
|
232
|
+
if (missing.length > 0)
|
|
233
|
+
return err({ kind: "document-text-incomplete", reference: references.text, missing });
|
|
224
234
|
const surface = fields("surface");
|
|
225
235
|
if (surface.kind === "err")
|
|
226
236
|
return surface;
|
|
@@ -530,6 +540,10 @@ export function describeFoundationFailure(failure) {
|
|
|
530
540
|
return `Wrong role ${failure.profile}.${failure.field}: ${failure.token}`;
|
|
531
541
|
case "provided-role-self":
|
|
532
542
|
return `Profile ${failure.profile} provides ${failure.token} and reads it in ${failure.field}`;
|
|
543
|
+
case "forced-color-invalid":
|
|
544
|
+
return `Profile ${failure.profile} ${failure.field}: ${failure.value} is not a CSS system colour`;
|
|
545
|
+
case "document-text-incomplete":
|
|
546
|
+
return `foundation.ads.ts text: ${failure.reference} states no ${failure.missing.join(", ")}`;
|
|
533
547
|
case "document-profile-kind":
|
|
534
548
|
return `foundation.ads.ts ${failure.field}: ${failure.reference} is a ${failure.actual} profile, not a ${failure.field} profile`;
|
|
535
549
|
}
|
|
@@ -49,4 +49,4 @@ export function outcomeDigest(owner, root) {
|
|
|
49
49
|
outcomeDigests.set(owner, computed);
|
|
50
50
|
return computed;
|
|
51
51
|
}
|
|
52
|
-
export const ownerEmissionKey = (inputs) => digest(["ads-owner-emission/
|
|
52
|
+
export const ownerEmissionKey = (inputs) => digest(["ads-owner-emission/2", inputs.analysisKey, outcomeDigest(inputs.outcome, inputs.root), inputs.classes]);
|