@reqvire-org/ads 0.5.2 → 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 +33 -26
- package/dist/analysis/design-usage.mjs +4 -20
- package/dist/analysis/mock-check.mjs +4 -5
- package/dist/analysis/owner-accessibility.mjs +4 -4
- package/dist/analysis/owner-analysis-key.mjs +1 -1
- package/dist/analysis/owner-choices.mjs +33 -3
- package/dist/analysis/owner-composition.mjs +61 -12
- package/dist/analysis/owner-source.mjs +52 -35
- package/dist/composed-contrast.mjs +143 -62
- package/dist/construction-output.mjs +6 -1
- package/dist/construction-spec.d.mts +53 -44
- package/dist/construction-spec.mjs +64 -76
- package/dist/corner-overpaint.mjs +5 -4
- package/dist/design-foundation.mjs +16 -0
- package/dist/design-usage.mjs +2 -8
- package/dist/emit/emission.mjs +0 -5
- package/dist/grid-lowering.mjs +3 -1
- package/dist/lowering-enter.mjs +6 -6
- package/dist/lowering-session.mjs +10 -0
- package/dist/mcp/server-observation.mjs +6 -4
- package/dist/mcp/server-project.mjs +4 -1
- package/dist/owner-analysis-check.mjs +4 -1
- package/dist/owner-errors.mjs +2 -1
- package/dist/owner-lowering.mjs +10 -4
- package/dist/owner-scenarios.mjs +2 -22
- package/dist/ownership-model.mjs +7 -5
- package/dist/paint-contrast.mjs +6 -0
- package/dist/profile-macro.d.mts +7 -0
- package/dist/recipe-macro.d.mts +46 -42
- package/dist/recipe-model.mjs +12 -11
- package/dist/region-lowering.mjs +54 -109
- package/dist/role-vocabulary.d.mts +4 -0
- package/dist/role-vocabulary.mjs +4 -0
- package/dist/runtime-paint-contrast.mjs +5 -2
- package/dist/showcase/client.bundle.js +48 -48
- package/dist/showcase/http-client.bundle.js +13 -13
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +5 -5
- package/dist/skills/ads-designer/references/accessibility.md +3 -4
- package/dist/skills/ads-designer/references/design-data.md +12 -6
- package/dist/skills/ads-designer/references/layout.md +7 -3
- package/dist/skills/ads-designer/references/motion.md +2 -1
- package/dist/skills/ads-designer/references/recipes.md +28 -18
- package/dist/skills/ads-import/references/design-data.md +12 -6
- package/dist/skills/ads-import/references/layout.md +7 -3
- package/dist/skills/ads-import/references/recipes.md +28 -18
- package/dist/skills/ads-migrate/SKILL.md +1 -0
- package/dist/skills/ads-migrate/references/0.5.2-to-0.5.3.md +71 -0
- package/dist/skills/ads-port/references/design-data.md +12 -6
- package/dist/skills/ads-port/references/layout.md +7 -3
- package/dist/skills/ads-port/references/recipes.md +28 -18
- package/dist/spatial-model.mjs +2 -2
- package/dist/surface-contrast.mjs +6 -2
- package/dist/target-size.mjs +21 -3
- package/docs/ADS.md +9 -3
- package/docs/ARCHITECTURE.md +33 -23
- package/docs/CACHING.md +1 -1
- package/docs/CHANGELOG.md +128 -21
- package/docs/GUIDE.md +64 -19
- package/docs/LANGUAGE.md +141 -134
- package/docs/MCP.md +5 -1
- package/docs/MOTION.md +5 -2
- package/docs/PROFILE-KINDS.md +46 -4
- package/docs/RULES.md +16 -15
- 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
|
@@ -2,7 +2,6 @@ import { type Result } from "./result.mjs";
|
|
|
2
2
|
import type { ColorScheme } from "./asset-declaration.mjs";
|
|
3
3
|
import { type Json, type JsonObject } from "./json.mjs";
|
|
4
4
|
import { type ConditionProblem } from "./state-conditions.mjs";
|
|
5
|
-
import { type ProseElementName } from "./prose-model.mjs";
|
|
6
5
|
export type ConstructionKind = "control" | "artwork" | "region" | "grid";
|
|
7
6
|
export type SpecFailure = {
|
|
8
7
|
readonly kind: "field-unsupported";
|
|
@@ -76,6 +75,8 @@ export interface TextPart {
|
|
|
76
75
|
readonly wrap: ControlLabelWrap;
|
|
77
76
|
/** How the label's lines sit in its box (`text-align`): it shows once the label wraps or the control is wider than it. */
|
|
78
77
|
readonly align: TextAlign | null;
|
|
78
|
+
/** `fill`: in an inline control the label takes the room the control's other content leaves, so a visual after it sits at the far end. */
|
|
79
|
+
readonly extent: "content" | "fill";
|
|
79
80
|
}
|
|
80
81
|
/** A state effect on a control's visual part, bound to the motion profile. */
|
|
81
82
|
/** A control's artwork effect under an owner state. The three scales are one channel: whole, or one axis only (a blink). */
|
|
@@ -188,6 +189,7 @@ export interface StickySpec {
|
|
|
188
189
|
/** What an entering element moves by: each reads one field of the entrance's motion profile. */
|
|
189
190
|
export declare const ENTER_MOVEMENTS: {
|
|
190
191
|
readonly translate: "distance";
|
|
192
|
+
readonly translateInline: "distance";
|
|
191
193
|
readonly scale: "scale";
|
|
192
194
|
readonly rotate: "angle";
|
|
193
195
|
};
|
|
@@ -200,7 +202,7 @@ export type EnterDriver = {
|
|
|
200
202
|
readonly kind: "first-render";
|
|
201
203
|
};
|
|
202
204
|
/**
|
|
203
|
-
* `enter: { from: { surface?, translate? | scale? | rotate? }, motion }`: the element starts from a
|
|
205
|
+
* `enter: { from: { surface?, translate? | translateInline? | scale? | rotate? }, motion }`: the element starts from a
|
|
204
206
|
* declared look and settles into its own. The starting surface states only `opacity` and `blur`
|
|
205
207
|
* (checked when it lowers); at most one movement, read from the entrance's motion profile.
|
|
206
208
|
*/
|
|
@@ -327,46 +329,7 @@ export interface ArtworkSpec {
|
|
|
327
329
|
* arrangement. `layered` stacks every declared child part in one grid area,
|
|
328
330
|
* painted in DOM order.
|
|
329
331
|
*/
|
|
330
|
-
export type RegionLayout = "native" | "inline" | "stack" | "flow" | "layered"
|
|
331
|
-
/**
|
|
332
|
-
* One element of a prose recipe (./prose-model.mts): the profiles its plain markup takes, by name.
|
|
333
|
-
* `spaceBefore` replaces the rhythm before a block (more space above a heading); `indent` is a
|
|
334
|
-
* list's start inset; `marker` a colour-only surface for a list item's marker.
|
|
335
|
-
*/
|
|
336
|
-
export interface ProseElement {
|
|
337
|
-
readonly name: ProseElementName;
|
|
338
|
-
readonly path: string;
|
|
339
|
-
readonly text: string | null;
|
|
340
|
-
readonly surface: string | null;
|
|
341
|
-
readonly frame: string | null;
|
|
342
|
-
readonly when: readonly StateTreatment[];
|
|
343
|
-
readonly spaceBefore: SlotBinding | null;
|
|
344
|
-
/** The space between a block and whatever follows it, in place of the rhythm (a heading closer to its text); the larger of it and the next block's own `spaceBefore`. */
|
|
345
|
-
readonly spaceAfter: SlotBinding | null;
|
|
346
|
-
readonly indent: SlotBinding | null;
|
|
347
|
-
readonly marker: string | null;
|
|
348
|
-
/** Where a jump to the block lands (a heading with an id). */
|
|
349
|
-
readonly anchorClear: SlotBinding | null;
|
|
350
|
-
/** A text profile whose weight an item's marker takes (bold numbers and bullets). */
|
|
351
|
-
readonly markerText: string | null;
|
|
352
|
-
/** An unordered list's marker shape at each depth of nesting, outermost first; deeper lists keep the last. */
|
|
353
|
-
readonly markers: readonly ProseMarker[];
|
|
354
|
-
}
|
|
355
|
-
export declare const PROSE_MARKERS: readonly ["disc", "circle", "square"];
|
|
356
|
-
export type ProseMarker = (typeof PROSE_MARKERS)[number];
|
|
357
|
-
/** `layout: "prose"`: the space between blocks and the elements the recipe styles, in authored order. */
|
|
358
|
-
export interface ProseSpec {
|
|
359
|
-
readonly rhythm: SlotBinding | null;
|
|
360
|
-
readonly elements: readonly ProseElement[];
|
|
361
|
-
/**
|
|
362
|
-
* `elements.component`: the space around a component placed directly among the blocks (a callout, a code
|
|
363
|
-
* block with its own owner). Its design is its owner's; only the space the flow gives it is prose's.
|
|
364
|
-
*/
|
|
365
|
-
readonly component: {
|
|
366
|
-
readonly spaceBefore: SlotBinding | null;
|
|
367
|
-
readonly spaceAfter: SlotBinding | null;
|
|
368
|
-
} | null;
|
|
369
|
-
}
|
|
332
|
+
export type RegionLayout = "native" | "inline" | "stack" | "flow" | "layered";
|
|
370
333
|
/** The scroll-snap axis and strictness a scrolling element declares (`scroll-snap-type`), on logical axes: they follow the writing mode, as `overflow` does. */
|
|
371
334
|
export declare const SNAP_TYPES: readonly ["inline mandatory", "inline proximity", "block mandatory", "block proximity", "both mandatory", "both proximity"];
|
|
372
335
|
export type SnapType = (typeof SNAP_TYPES)[number];
|
|
@@ -481,6 +444,18 @@ export type RegionFrame =
|
|
|
481
444
|
*/
|
|
482
445
|
export declare const FRAME_CORNERS: readonly ["start-start", "start-end", "end-start", "end-end"];
|
|
483
446
|
export type FrameCorner = (typeof FRAME_CORNERS)[number];
|
|
447
|
+
/**
|
|
448
|
+
* A frame profile's own radius for one corner (`startStartRadius` …): it replaces the profile's `radius`
|
|
449
|
+
* on that corner (a chat bubble's small tail corner). A corner with neither is square.
|
|
450
|
+
*/
|
|
451
|
+
export declare const CORNER_RADIUS_FIELDS: {
|
|
452
|
+
readonly "start-start": "start-start-radius";
|
|
453
|
+
readonly "start-end": "start-end-radius";
|
|
454
|
+
readonly "end-start": "end-start-radius";
|
|
455
|
+
readonly "end-end": "end-end-radius";
|
|
456
|
+
};
|
|
457
|
+
/** The radius a frame's fields give one corner, or `undefined` where it is square. */
|
|
458
|
+
export declare const cornerRadius: (field: (name: string) => string | undefined, corner: FrameCorner) => string | undefined;
|
|
484
459
|
/** A region root's frame under one named condition: other ruled sides, other rounded corners, or both. */
|
|
485
460
|
export interface FrameCondition {
|
|
486
461
|
readonly condition: string;
|
|
@@ -574,6 +549,13 @@ export type PartContent = {
|
|
|
574
549
|
readonly stroke: string;
|
|
575
550
|
} | {
|
|
576
551
|
readonly kind: "element";
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* A public component placed with the part's marker (`<Heading className="ux-article-heading" …/>`), as a grid
|
|
555
|
+
* cell is: its interior is its owner's, so the part takes placement only (its space, extent, visibility).
|
|
556
|
+
*/
|
|
557
|
+
| {
|
|
558
|
+
readonly kind: "component";
|
|
577
559
|
};
|
|
578
560
|
/** A state treatment: an owner condition selecting a surface profile. */
|
|
579
561
|
export type StateTreatment = readonly [condition: string, surface: string];
|
|
@@ -659,7 +641,26 @@ export interface RegionPart {
|
|
|
659
641
|
* of a checkbox whose `<input>` is hidden) and shows the focus indicator while that control has keyboard focus.
|
|
660
642
|
*/
|
|
661
643
|
readonly focusOf: string | null;
|
|
644
|
+
/**
|
|
645
|
+
* `drawnBy: "<sibling part>"`: this part is a native control (a checkbox's `<input>`) that the named part draws.
|
|
646
|
+
* It is invisible and takes no room, laid over that part at its frame's size, so pointer and keyboard still
|
|
647
|
+
* reach the real control. The drawing part follows it and shows its focus (`focus: { of }`).
|
|
648
|
+
*/
|
|
649
|
+
readonly drawnBy: string | null;
|
|
662
650
|
readonly required: boolean;
|
|
651
|
+
/**
|
|
652
|
+
* `repeat: true`: the part's element renders once per item of a list (`tabs.map(…)`), any number of times
|
|
653
|
+
* (at least once when `required`). Every instance takes the part's construction; consecutive instances are
|
|
654
|
+
* neighbours of their arrangement (a target's hit area and spacing are checked against the next one).
|
|
655
|
+
*/
|
|
656
|
+
readonly repeat: boolean;
|
|
657
|
+
/**
|
|
658
|
+
* In a `stack`: the space before this part, in place of the stack's gap (a heading further from what precedes
|
|
659
|
+
* it), and the space between it and whatever follows. Where one part's space after meets the next part's
|
|
660
|
+
* space before, the larger applies. A spacing slot field.
|
|
661
|
+
*/
|
|
662
|
+
readonly spaceBefore: SlotBinding | null;
|
|
663
|
+
readonly spaceAfter: SlotBinding | null;
|
|
663
664
|
readonly content: PartContent;
|
|
664
665
|
readonly textEdge: readonly string[];
|
|
665
666
|
readonly textLayout: TextLayout;
|
|
@@ -786,8 +787,6 @@ export interface RegionSpec {
|
|
|
786
787
|
readonly textWhen: readonly StateText[];
|
|
787
788
|
/** The root's frame under one named condition; `null` when it is the same at every width. */
|
|
788
789
|
readonly frameAt: FrameCondition | null;
|
|
789
|
-
/** The elements a prose root styles; `null` for every other layout. */
|
|
790
|
-
readonly prose: ProseSpec | null;
|
|
791
790
|
/** Where a jump to the root lands; never on a top-layer root, which is not in the page's flow. */
|
|
792
791
|
readonly anchorClear: SlotBinding | null;
|
|
793
792
|
/** The geometry the root takes under owner states; never on a top-layer root. */
|
|
@@ -813,6 +812,14 @@ export type SpatialValue = string | number | boolean | readonly (string | number
|
|
|
813
812
|
export type SpatialValues = readonly (readonly [field: string, value: SpatialValue])[];
|
|
814
813
|
export interface GridCell {
|
|
815
814
|
readonly selector: string;
|
|
815
|
+
/** `required: false`: the cell may be absent (an optional notice); it renders at most once unless repeated. */
|
|
816
|
+
readonly required: boolean;
|
|
817
|
+
/**
|
|
818
|
+
* `repeat: true`: the cell renders once per item of a list, any number of times (at least once when required).
|
|
819
|
+
* Its instances flow one after another: it auto-places at every tier (`start: "auto"`, implied) and takes no
|
|
820
|
+
* row of its own; its span may be `"full"` or a number.
|
|
821
|
+
*/
|
|
822
|
+
readonly repeat: boolean;
|
|
816
823
|
readonly values: SpatialValues;
|
|
817
824
|
/** Breakpoint tier → placement changes from that tier on. */
|
|
818
825
|
readonly at: readonly (readonly [tier: string, values: SpatialValues])[];
|
|
@@ -850,6 +857,8 @@ export interface DeclaredPart {
|
|
|
850
857
|
readonly path: string;
|
|
851
858
|
readonly selector: string;
|
|
852
859
|
readonly required: boolean;
|
|
860
|
+
/** Rendered once per item of a list: any number of instances (see {@link RegionPart.repeat}). */
|
|
861
|
+
readonly repeat: boolean;
|
|
853
862
|
readonly kind: RegionPartContent;
|
|
854
863
|
/** Enclosing declared parts' selectors, outermost first: the part is a child of the last. */
|
|
855
864
|
readonly within: readonly string[];
|
|
@@ -2,7 +2,6 @@ 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
|
-
import { PROSE_BLOCKS, PROSE_ELEMENT_NAMES } from "./prose-model.mjs";
|
|
6
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 = {
|
|
7
6
|
scale: { channel: "scale", field: "scale" },
|
|
8
7
|
scaleInline: { channel: "scale", field: "scale" },
|
|
@@ -10,7 +9,12 @@ export const ACCESSIBILITY_BOUNDARIES = ["visible-label", "boundary-on-interacti
|
|
|
10
9
|
translateInline: { channel: "translate", field: "distance" },
|
|
11
10
|
translateBlock: { channel: "translate", field: "distance" },
|
|
12
11
|
rotate: { channel: "rotate", field: "angle" }
|
|
13
|
-
}, 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", scale: "scale", rotate: "angle" }, PSEUDO_ELEMENTS = ["placeholder", "progressValue"], PSEUDO_HOSTS = { placeholder: ["input", "textarea"], progressValue: ["progress"] },
|
|
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"], PSEUDO_HOSTS = { placeholder: ["input", "textarea"], progressValue: ["progress"] }, 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
|
+
"start-start": "start-start-radius",
|
|
14
|
+
"start-end": "start-end-radius",
|
|
15
|
+
"end-start": "end-start-radius",
|
|
16
|
+
"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"];
|
|
14
18
|
export function elementTags(element) {
|
|
15
19
|
switch (element.kind) {
|
|
16
20
|
case "iframe":
|
|
@@ -69,12 +73,13 @@ export function declaredParts(spec) {
|
|
|
69
73
|
return [];
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
|
-
const plainPart = { within: [], pseudo: [], element: null, media: "bound", truncated: !1, clamped: !1, balanced: !1, scrolls: !1, declaresBoundary: !1, resizes: !1, playsAlways: [], scheme: null }, regionParts = (parts, within, parent) => parts.flatMap((part) => [
|
|
76
|
+
const plainPart = { repeat: !1, within: [], pseudo: [], element: null, media: "bound", truncated: !1, clamped: !1, balanced: !1, scrolls: !1, declaresBoundary: !1, resizes: !1, playsAlways: [], scheme: null }, regionParts = (parts, within, parent) => parts.flatMap((part) => [
|
|
73
77
|
{
|
|
74
78
|
name: part.name,
|
|
75
79
|
path: `${parent}.parts.${part.name}`,
|
|
76
80
|
selector: part.selector,
|
|
77
81
|
required: part.required,
|
|
82
|
+
repeat: part.repeat,
|
|
78
83
|
kind: part.content.kind,
|
|
79
84
|
within,
|
|
80
85
|
pseudo: part.pseudo.map((treatment) => treatment.pseudo),
|
|
@@ -280,7 +285,7 @@ function decorPart(name, value, read) {
|
|
|
280
285
|
}
|
|
281
286
|
function textPart(name, value, read) {
|
|
282
287
|
const path = `recipe.parts.${name}`, part = read.object(value, path);
|
|
283
|
-
read.only(part, path, ["kind", "selector", "required", "textEdge", "wrap", "textAlign"]);
|
|
288
|
+
read.only(part, path, ["kind", "selector", "required", "textEdge", "wrap", "textAlign", "extent"]);
|
|
284
289
|
return {
|
|
285
290
|
kind: "text",
|
|
286
291
|
name,
|
|
@@ -288,7 +293,8 @@ function textPart(name, value, read) {
|
|
|
288
293
|
required: read.boolean(part.required, `${path}.required`),
|
|
289
294
|
textEdge: part.textEdge === void 0 ? [] : read.strings(part.textEdge, `${path}.textEdge`),
|
|
290
295
|
wrap: controlLabelWrap(part.wrap, `${path}.wrap`, read),
|
|
291
|
-
align: part.textAlign === void 0 ? null : read.literal(part.textAlign, `${path}.textAlign`, TEXT_ALIGNS)
|
|
296
|
+
align: part.textAlign === void 0 ? null : read.literal(part.textAlign, `${path}.textAlign`, TEXT_ALIGNS),
|
|
297
|
+
extent: part.extent === void 0 ? "content" : read.literal(part.extent, `${path}.extent`, ["content", "fill"])
|
|
292
298
|
};
|
|
293
299
|
}
|
|
294
300
|
function controlLabelWrap(wrap, path, read) {
|
|
@@ -333,7 +339,7 @@ function artwork(spec, read) {
|
|
|
333
339
|
if (parts.length !== 1 || entry === void 0)
|
|
334
340
|
return read.reject({ kind: "parts-unsupported", construction: "artwork", detail: "standalone artwork has exactly one visual part" });
|
|
335
341
|
const [name, value] = entry, path = `recipe.parts.${name}`, part = read.object(value, path);
|
|
336
|
-
read.only(part, path, ["kind", "selector", "required", "motion", "transition", "when", "play"]);
|
|
342
|
+
read.only(part, path, ["kind", "selector", "required", "motion", "transition", "when", "play", ...VISUAL_BINDING_FIELDS]);
|
|
337
343
|
read.literal(part.kind, `${path}.kind`, ["visual"]);
|
|
338
344
|
const states = part.when === void 0 ? [] : Object.entries(read.object(part.when, `${path}.when`)), plays = part.play === void 0 ? [] : [playSpec(part.play, null, `${path}.play`, read)], effects = states.filter(([condition, value]) => {
|
|
339
345
|
const fields = read.object(value, `${path}.when.${condition}`);
|
|
@@ -365,59 +371,7 @@ function artwork(spec, read) {
|
|
|
365
371
|
}
|
|
366
372
|
};
|
|
367
373
|
}
|
|
368
|
-
const REGION_LAYOUTS = ["inline", "stack", "flow", "layered"], ROOT_LAYOUTS =
|
|
369
|
-
function proseSpec(spec, read) {
|
|
370
|
-
for (const field of ["parts", "gap", "rowGap", "align", "justify", "wrap", "exposeRows", "snap", "extent", "layer"])
|
|
371
|
-
if (spec[field] !== void 0)
|
|
372
|
-
read.reject({ kind: "field-unsupported", construction: "region", path: `recipe.${field}` });
|
|
373
|
-
const declaredElements = spec.elements === void 0 ? {} : read.object(spec.elements, "recipe.elements");
|
|
374
|
-
let component = null;
|
|
375
|
-
if (declaredElements.component !== void 0) {
|
|
376
|
-
const path = "recipe.elements.component", declared = read.object(declaredElements.component, path);
|
|
377
|
-
read.only(declared, path, ["spaceBefore", "spaceAfter"]);
|
|
378
|
-
if (declared.spaceBefore === void 0 && declared.spaceAfter === void 0)
|
|
379
|
-
read.invalid(path, "a `spaceBefore`, a `spaceAfter` or both");
|
|
380
|
-
const space = (field) => declared[field] === void 0 ? null : read.slot(declared[field], `${path}.${field}`, "spacing");
|
|
381
|
-
component = { spaceBefore: space("spaceBefore"), spaceAfter: space("spaceAfter") };
|
|
382
|
-
}
|
|
383
|
-
const elements = Object.entries(declaredElements).filter(([key]) => key !== "component").map(([key, value]) => {
|
|
384
|
-
const path = `recipe.elements.${key}`, name = read.literal(key, path, PROSE_ELEMENT_NAMES), element = read.object(value, path);
|
|
385
|
-
read.only(element, path, ["text", "surface", "frame", "when", "spaceBefore", "spaceAfter", "indent", "marker", "markerText", "markers", "anchorClear"]);
|
|
386
|
-
if (element.anchorClear !== void 0 && !PROSE_BLOCKS.includes(name))
|
|
387
|
-
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.anchorClear` });
|
|
388
|
-
if (element.spaceAfter !== void 0 && !PROSE_BLOCKS.includes(name))
|
|
389
|
-
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.spaceAfter` });
|
|
390
|
-
if (element.markerText !== void 0 && name !== "item")
|
|
391
|
-
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.markerText` });
|
|
392
|
-
if (element.markers !== void 0 && name !== "list")
|
|
393
|
-
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.markers` });
|
|
394
|
-
const markers = element.markers === void 0 ? [] : read.strings(element.markers, `${path}.markers`).map((shape) => read.literal(shape, `${path}.markers`, PROSE_MARKERS));
|
|
395
|
-
if (element.markers !== void 0 && (markers.length === 0 || markers.length > 3))
|
|
396
|
-
read.invalid(`${path}.markers`, "one to three marker shapes, outermost list first");
|
|
397
|
-
if (element.spaceBefore !== void 0 && !PROSE_BLOCKS.includes(name))
|
|
398
|
-
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.spaceBefore` });
|
|
399
|
-
if (element.indent !== void 0 && name !== "list")
|
|
400
|
-
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.indent` });
|
|
401
|
-
if (element.marker !== void 0 && name !== "item")
|
|
402
|
-
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.marker` });
|
|
403
|
-
return {
|
|
404
|
-
name,
|
|
405
|
-
path,
|
|
406
|
-
text: read.optionalString(element.text, `${path}.text`),
|
|
407
|
-
surface: read.optionalString(element.surface, `${path}.surface`),
|
|
408
|
-
frame: read.optionalString(element.frame, `${path}.frame`),
|
|
409
|
-
when: treatments(element.when, `${path}.when`, read),
|
|
410
|
-
spaceBefore: element.spaceBefore === void 0 ? null : read.slot(element.spaceBefore, `${path}.spaceBefore`, "spacing"),
|
|
411
|
-
indent: element.indent === void 0 ? null : read.slot(element.indent, `${path}.indent`, "spacing"),
|
|
412
|
-
marker: read.optionalString(element.marker, `${path}.marker`),
|
|
413
|
-
spaceAfter: element.spaceAfter === void 0 ? null : read.slot(element.spaceAfter, `${path}.spaceAfter`, "spacing"),
|
|
414
|
-
markerText: read.optionalString(element.markerText, `${path}.markerText`),
|
|
415
|
-
anchorClear: anchorClear(element.anchorClear, `${path}.anchorClear`, read),
|
|
416
|
-
markers
|
|
417
|
-
};
|
|
418
|
-
});
|
|
419
|
-
return { rhythm: spec.rhythm === void 0 ? null : read.slot(spec.rhythm, "recipe.rhythm", "spacing"), elements, component };
|
|
420
|
-
}
|
|
374
|
+
const REGION_LAYOUTS = ["inline", "stack", "flow", "layered"], ROOT_LAYOUTS = REGION_LAYOUTS;
|
|
421
375
|
export const ROOT_EXTENTS = ["content", "container"];
|
|
422
376
|
function rootExtent(value, layout, layer, read) {
|
|
423
377
|
if (value === void 0)
|
|
@@ -632,7 +586,7 @@ function enterSpec(value, path, read) {
|
|
|
632
586
|
read.only(from, `${path}.from`, ["surface", ...Object.keys(ENTER_MOVEMENTS)]);
|
|
633
587
|
const moved = Object.keys(ENTER_MOVEMENTS).filter((kind) => from[kind] !== void 0), surface = read.optionalString(from.surface, `${path}.from.surface`);
|
|
634
588
|
if (moved.length > 1 || surface === null && moved.length === 0)
|
|
635
|
-
read.invalid(`${path}.from`, "a starting `surface`, one of `translate`, `scale` and `rotate`, or both");
|
|
589
|
+
read.invalid(`${path}.from`, "a starting `surface`, one of `translate`, `translateInline`, `scale` and `rotate`, or both");
|
|
636
590
|
const [kind] = moved, movement = kind === void 0 ? null : { kind, field: read.literal(read.slot(from[kind], `${path}.from.${kind}`, "motion").field, `${path}.from.${kind}.field`, [ENTER_MOVEMENTS[kind]]) }, motion = declared.motion;
|
|
637
591
|
if (typeof motion === "string")
|
|
638
592
|
return { driver: { kind: "first-render" }, surface, movement, motion: { kind: "profile", name: motion }, path };
|
|
@@ -884,7 +838,7 @@ function partConditions(value, path, read) {
|
|
|
884
838
|
});
|
|
885
839
|
}
|
|
886
840
|
function partContent(part, path, read) {
|
|
887
|
-
const kind = part.kind === void 0 ? "element" : read.literal(part.kind, `${path}.kind`, ["text", "visual", "vector"]);
|
|
841
|
+
const kind = part.kind === void 0 ? "element" : read.literal(part.kind, `${path}.kind`, ["text", "visual", "vector", "component"]);
|
|
888
842
|
if (kind !== "visual" && part.media !== void 0)
|
|
889
843
|
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.media` });
|
|
890
844
|
if (kind !== "vector" && part.stroke !== void 0)
|
|
@@ -893,6 +847,12 @@ function partContent(part, path, read) {
|
|
|
893
847
|
case "text":
|
|
894
848
|
case "element":
|
|
895
849
|
return { kind };
|
|
850
|
+
case "component": {
|
|
851
|
+
for (const field of Object.keys(part))
|
|
852
|
+
if (!["kind", "selector", "required", "repeat", "extent", "at", "spaceBefore", "spaceAfter"].includes(field))
|
|
853
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.${field}` });
|
|
854
|
+
return { kind };
|
|
855
|
+
}
|
|
896
856
|
case "visual":
|
|
897
857
|
return { kind, media: part.media === void 0 ? "bound" : read.literal(part.media, `${path}.media`, ["inspected-svg"]) };
|
|
898
858
|
case "vector": {
|
|
@@ -1031,9 +991,13 @@ function regionPart(name, value, read, path, nested) {
|
|
|
1031
991
|
"stroke",
|
|
1032
992
|
"accessibility",
|
|
1033
993
|
"focus",
|
|
994
|
+
"drawnBy",
|
|
1034
995
|
"anchorClear",
|
|
1035
996
|
"collapsed",
|
|
1036
997
|
"geometryTransition",
|
|
998
|
+
"repeat",
|
|
999
|
+
"spaceBefore",
|
|
1000
|
+
"spaceAfter",
|
|
1037
1001
|
...VISUAL_BINDING_FIELDS,
|
|
1038
1002
|
...nested ? [] : ["measured", "paints"]
|
|
1039
1003
|
]);
|
|
@@ -1057,6 +1021,9 @@ function regionPart(name, value, read, path, nested) {
|
|
|
1057
1021
|
name,
|
|
1058
1022
|
selector: read.string(part.selector, `${path}.selector`),
|
|
1059
1023
|
required: read.boolean(part.required, `${path}.required`),
|
|
1024
|
+
repeat: part.repeat === void 0 ? !1 : read.boolean(part.repeat, `${path}.repeat`),
|
|
1025
|
+
spaceBefore: part.spaceBefore === void 0 ? null : read.slot(part.spaceBefore, `${path}.spaceBefore`, "spacing"),
|
|
1026
|
+
spaceAfter: part.spaceAfter === void 0 ? null : read.slot(part.spaceAfter, `${path}.spaceAfter`, "spacing"),
|
|
1060
1027
|
content,
|
|
1061
1028
|
textEdge: part.textEdge === void 0 ? [] : read.strings(part.textEdge, `${path}.textEdge`),
|
|
1062
1029
|
textLayout: textLayout(part, path, read),
|
|
@@ -1083,6 +1050,7 @@ function regionPart(name, value, read, path, nested) {
|
|
|
1083
1050
|
sticky: stickySpec(part.sticky, `${path}.sticky`, read),
|
|
1084
1051
|
outset: outsetSpec(part.outset, `${path}.outset`, read),
|
|
1085
1052
|
focusOf: focusSource(part.focus, `${path}.focus`, read),
|
|
1053
|
+
drawnBy: part.drawnBy === void 0 ? null : read.string(part.drawnBy, `${path}.drawnBy`),
|
|
1086
1054
|
anchorClear: anchorClear(part.anchorClear, `${path}.anchorClear`, read),
|
|
1087
1055
|
scheme: partScheme(part, content, path, read),
|
|
1088
1056
|
pseudo: pseudoTreatments(part.pseudo, `${path}.pseudo`, read),
|
|
@@ -1114,6 +1082,21 @@ function parseParts(value, read, path, nested) {
|
|
|
1114
1082
|
for (const part of parts)
|
|
1115
1083
|
if (part.focusOf !== null && (part.focusOf === part.name || !parts.some((other) => other.name === part.focusOf)))
|
|
1116
1084
|
return read.invalid(`${path}.parts.${part.name}.focus.of`, "the name of another part of the same parent (the native control this part stands in for)");
|
|
1085
|
+
for (const part of parts) {
|
|
1086
|
+
if (!part.repeat)
|
|
1087
|
+
continue;
|
|
1088
|
+
if (part.content.kind === "vector")
|
|
1089
|
+
read.invalid(`${path}.parts.${part.name}.repeat`, "omitted on a vector part, which already renders any number of shapes");
|
|
1090
|
+
if (part.drawnBy !== null || part.focusOf !== null || parts.some((other) => other.focusOf === part.name || other.drawnBy === part.name))
|
|
1091
|
+
read.invalid(`${path}.parts.${part.name}.repeat`, "omitted on a part paired with another by `drawnBy` or `focus: { of }`: each instance would need its own pair");
|
|
1092
|
+
}
|
|
1093
|
+
parts.forEach((part, index) => {
|
|
1094
|
+
if (part.drawnBy === null)
|
|
1095
|
+
return;
|
|
1096
|
+
const drawing = parts[index + 1];
|
|
1097
|
+
if (drawing === void 0 || drawing.name !== part.drawnBy || drawing.focusOf !== part.name)
|
|
1098
|
+
read.invalid(`${path}.parts.${part.name}.drawnBy`, `the name of the part declared right after it, whose \`focus: { of: "${part.name}" }\` shows this control's keyboard focus`);
|
|
1099
|
+
});
|
|
1117
1100
|
const schemed = parts.filter((part) => part.scheme !== null);
|
|
1118
1101
|
for (const scheme of schemed.length === 0 ? [] : COLOR_SCHEMES) {
|
|
1119
1102
|
const [first, second] = schemed.filter((part) => part.scheme === scheme), at = second ?? first ?? schemed[0];
|
|
@@ -1177,8 +1160,6 @@ function region(authored, read) {
|
|
|
1177
1160
|
"paintTransition",
|
|
1178
1161
|
"enter",
|
|
1179
1162
|
"sticky",
|
|
1180
|
-
"elements",
|
|
1181
|
-
"rhythm",
|
|
1182
1163
|
"play",
|
|
1183
1164
|
"at",
|
|
1184
1165
|
"parts",
|
|
@@ -1195,13 +1176,7 @@ function region(authored, read) {
|
|
|
1195
1176
|
"overlap",
|
|
1196
1177
|
"geometryTransition"
|
|
1197
1178
|
]);
|
|
1198
|
-
const layout = spec.layout === void 0 ? "native" : read.literal(spec.layout, "recipe.layout", ROOT_LAYOUTS);
|
|
1199
|
-
if (layout !== "prose") {
|
|
1200
|
-
for (const field of ["elements", "rhythm"])
|
|
1201
|
-
if (spec[field] !== void 0)
|
|
1202
|
-
read.reject({ kind: "field-unsupported", construction: "region", path: `recipe.${field}` });
|
|
1203
|
-
}
|
|
1204
|
-
const prose = layout === "prose" ? proseSpec(spec, read) : null, normalized = normalization(spec.normalize, "recipe.normalize", REGION_NORMALIZE, REGION_NORMALIZE, "selector", read), parts = parseParts(spec.parts, read, "recipe", !1), measured = measuredValues(spec.measured, "recipe.measured", read);
|
|
1179
|
+
const layout = spec.layout === void 0 ? "native" : read.literal(spec.layout, "recipe.layout", ROOT_LAYOUTS), normalized = normalization(spec.normalize, "recipe.normalize", REGION_NORMALIZE, REGION_NORMALIZE, "selector", read), parts = parseParts(spec.parts, read, "recipe", !1), measured = measuredValues(spec.measured, "recipe.measured", read);
|
|
1205
1180
|
uniqueMeasured(measured, parts, read);
|
|
1206
1181
|
const paints = runtimePaints(spec.paints, "recipe.paints", read);
|
|
1207
1182
|
uniqueNames("paints", paints, parts.map((part) => [part.name, part.paints]), read);
|
|
@@ -1230,7 +1205,6 @@ function region(authored, read) {
|
|
|
1230
1205
|
press: rootStates.press,
|
|
1231
1206
|
paintTransition: paintTransition(spec.paintTransition, "recipe.paintTransition", read),
|
|
1232
1207
|
enter: layer !== null && spec.enter !== void 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.enter" }) : enterSpec(spec.enter, "recipe.enter", read),
|
|
1233
|
-
prose,
|
|
1234
1208
|
anchorClear: layer !== null && spec.anchorClear !== void 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.anchorClear" }) : anchorClear(spec.anchorClear, "recipe.anchorClear", read),
|
|
1235
1209
|
textWhen: rootStates.texts,
|
|
1236
1210
|
geometryWhen: layer !== null && geometryStates(spec.when, "recipe.when", read, !1).length > 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: geometryStates(spec.when, "recipe.when", read, !1)[0]?.path ?? "recipe.when" }) : geometryStates(spec.when, "recipe.when", read, !1),
|
|
@@ -1293,7 +1267,7 @@ function grid(spec, read) {
|
|
|
1293
1267
|
const mode = read.literal(spec.layout, "recipe.layout", GRID_MODES), values = (value, path) => Object.entries(read.object(value, path)).map(([field, item]) => [field, read.spatial(item, `${path}.${field}`)]), frame = regionFrame(spec.frame, read);
|
|
1294
1268
|
if (frame !== null && (frame.kind !== "fields" || frame.container || frame.ratio !== null || frame.border.kind !== "profile"))
|
|
1295
1269
|
read.reject({ kind: "field-unsupported", construction: "grid", path: "recipe.frame" });
|
|
1296
|
-
|
|
1270
|
+
const parsed = {
|
|
1297
1271
|
kind: "grid",
|
|
1298
1272
|
source: spec,
|
|
1299
1273
|
mode,
|
|
@@ -1302,11 +1276,19 @@ function grid(spec, read) {
|
|
|
1302
1276
|
rowGap: spec.rowGap === void 0 ? null : read.slot(spec.rowGap, "recipe.rowGap", "spacing"),
|
|
1303
1277
|
frame,
|
|
1304
1278
|
cells: Object.entries(spec.cells === void 0 ? {} : read.object(spec.cells, "recipe.cells")).map(([selector, value]) => {
|
|
1305
|
-
const path = `recipe.cells.${selector}`, { at, ...cell } = read.object(value, path);
|
|
1279
|
+
const path = `recipe.cells.${selector}`, { at, required, repeat, ...cell } = read.object(value, path), repeated = repeat === void 0 ? !1 : read.boolean(repeat, `${path}.repeat`), tiers = at === void 0 ? [] : Object.entries(read.object(at, `${path}.at`)).map(([tier, fields]) => [tier, values(fields, `${path}.at.${tier}`)]), own = values(cell, path);
|
|
1280
|
+
if (repeated) {
|
|
1281
|
+
for (const [at, placed] of [[path, own], ...tiers.map(([tier, placed]) => [`${path}.at.${tier}`, placed])])
|
|
1282
|
+
for (const [field, item] of placed)
|
|
1283
|
+
if (field === "start" && item !== "auto" || field === "end" || field === "row" || field === "rowSpan")
|
|
1284
|
+
read.invalid(`${at}.${field}`, 'omitted on a repeated cell: its instances flow one after another (`start: "auto"`), each over its `span`');
|
|
1285
|
+
}
|
|
1306
1286
|
return {
|
|
1307
1287
|
selector,
|
|
1308
|
-
|
|
1309
|
-
|
|
1288
|
+
required: required === void 0 ? !0 : read.boolean(required, `${path}.required`),
|
|
1289
|
+
repeat: repeated,
|
|
1290
|
+
values: repeated && !own.some(([field]) => field === "start") ? [...own, ["start", "auto"]] : own,
|
|
1291
|
+
at: tiers
|
|
1310
1292
|
};
|
|
1311
1293
|
}),
|
|
1312
1294
|
conditions: Object.entries(spec.at === void 0 ? {} : read.object(spec.at, "recipe.at")).map(([condition, value]) => {
|
|
@@ -1316,5 +1298,11 @@ function grid(spec, read) {
|
|
|
1316
1298
|
}),
|
|
1317
1299
|
alignRows: Object.entries(spec.alignRows === void 0 ? {} : read.object(spec.alignRows, "recipe.alignRows")).map(([selector, rows]) => [selector, read.strings(rows, `recipe.alignRows.${selector}`)]),
|
|
1318
1300
|
measured: measuredValues(spec.measured, "recipe.measured", read).map((value) => ("motion" in value) && value.motion !== null ? read.reject({ kind: "field-unsupported", construction: "grid", path: `recipe.measured.${value.name}.motion` }) : value)
|
|
1319
|
-
};
|
|
1301
|
+
}, repeated = new Set(parsed.cells.flatMap((cell) => cell.repeat ? [cell.selector] : []));
|
|
1302
|
+
for (const { condition, cells } of parsed.conditions)
|
|
1303
|
+
for (const [selector, placed] of cells)
|
|
1304
|
+
for (const [field, item] of repeated.has(selector) ? placed : [])
|
|
1305
|
+
if (field === "start" && item !== "auto" || field === "end" || field === "row" || field === "rowSpan")
|
|
1306
|
+
read.invalid(`recipe.at.${condition}.cells.${selector}.${field}`, "omitted on a repeated cell: its instances flow one after another");
|
|
1307
|
+
return parsed;
|
|
1320
1308
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FRAME_CORNERS } from "./construction-spec.mjs";
|
|
1
|
+
import { cornerRadius, FRAME_CORNERS } from "./construction-spec.mjs";
|
|
2
2
|
import { selectedProfile, tokenValueContexts } from "./design-foundation.mjs";
|
|
3
3
|
import { readColor } from "./paint-contrast.mjs";
|
|
4
4
|
const fieldsOf = (foundation, name, kind) => {
|
|
@@ -32,11 +32,11 @@ function overpaintUnder(foundation, spec, under) {
|
|
|
32
32
|
if (selected.kind === "err")
|
|
33
33
|
return null;
|
|
34
34
|
const slots = selected.value.fields, frame = fieldsOf(foundation, framedUnder(slots.get("frame-profile"), spec.geometryWhen, under), "frame");
|
|
35
|
-
if (frame === null || !frame.
|
|
35
|
+
if (frame === null || !FRAME_CORNERS.some((corner) => cornerRadius((field) => frame.get(field), corner) !== void 0))
|
|
36
36
|
return null;
|
|
37
37
|
if ((spec.surface ?? slots.get("surface-profile")) === void 0 && !frame.has("border-width"))
|
|
38
38
|
return null;
|
|
39
|
-
const rounded = new Set(spec.frame.corners ?? FRAME_CORNERS), open = (corner) => {
|
|
39
|
+
const rounded = new Set((spec.frame.corners ?? FRAME_CORNERS).filter((corner) => cornerRadius((field) => frame.get(field), corner) !== void 0)), open = (corner) => {
|
|
40
40
|
const [block, inline] = corner.split("-");
|
|
41
41
|
return rounded.has(corner) && !inset(frame, "block", block) && !inset(frame, "inline", inline);
|
|
42
42
|
}, parts = spec.parts.filter((part) => part.outset === null), reached = (index) => {
|
|
@@ -47,7 +47,8 @@ function overpaintUnder(foundation, spec, under) {
|
|
|
47
47
|
const corners = reached(index);
|
|
48
48
|
if (corners.length === 0)
|
|
49
49
|
continue;
|
|
50
|
-
|
|
50
|
+
const box = fieldsOf(foundation, framedUnder(part.box, part.geometryWhen, under), "frame");
|
|
51
|
+
if (box !== null && corners.every((corner) => cornerRadius((field) => box.get(field), corner) !== void 0))
|
|
51
52
|
continue;
|
|
52
53
|
for (const [state, name] of [[null, part.surface], ...part.when]) {
|
|
53
54
|
const background = fieldsOf(foundation, name, "surface")?.get("background");
|
|
@@ -117,9 +117,23 @@ export function readFoundation(captured, contexts) {
|
|
|
117
117
|
const roles = profileTokenRoles[selected.value.kind];
|
|
118
118
|
for (const variant of variants.value)
|
|
119
119
|
for (const [field, value] of Object.entries(variant.fields)) {
|
|
120
|
+
if (field.startsWith("--")) {
|
|
121
|
+
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"] });
|
|
124
|
+
for (const token of references(value)) {
|
|
125
|
+
const role = tokens.get(token)?.role ?? null;
|
|
126
|
+
if (role !== "paint")
|
|
127
|
+
return reject({ kind: "token-role", profile: name, field, token, role, expected: ["paint"] });
|
|
128
|
+
}
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
120
131
|
const expected = roles?.[field];
|
|
121
132
|
if (expected === void 0)
|
|
122
133
|
continue;
|
|
134
|
+
for (const token of references(value))
|
|
135
|
+
if (field !== token && Object.hasOwn(variant.fields, token) && token.startsWith("--"))
|
|
136
|
+
return reject({ kind: "provided-role-self", profile: name, token, field });
|
|
123
137
|
for (const token of references(value)) {
|
|
124
138
|
const role = tokens.get(token)?.role ?? null;
|
|
125
139
|
if (role === null || !expected.includes(role))
|
|
@@ -514,6 +528,8 @@ export function describeFoundationFailure(failure) {
|
|
|
514
528
|
return `Profile ${failure.profile} (${failure.profileKind}) declares unknown field ${failure.field}`;
|
|
515
529
|
case "token-role":
|
|
516
530
|
return `Wrong role ${failure.profile}.${failure.field}: ${failure.token}`;
|
|
531
|
+
case "provided-role-self":
|
|
532
|
+
return `Profile ${failure.profile} provides ${failure.token} and reads it in ${failure.field}`;
|
|
517
533
|
case "document-profile-kind":
|
|
518
534
|
return `foundation.ads.ts ${failure.field}: ${failure.reference} is a ${failure.actual} profile, not a ${failure.field} profile`;
|
|
519
535
|
}
|
package/dist/design-usage.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { isExportDeclaration, isNamedExports, isStringLiteral } from "typescript/ast";
|
|
4
4
|
import { designUsageProblems } from "./analysis/design-usage.mjs";
|
|
5
5
|
import { closeSyntax, parseSource } from "./analysis/syntax.mjs";
|
|
6
|
-
import { PROSE_MANIFEST, parseProseManifest } from "./prose-model.mjs";
|
|
7
6
|
const wording = {
|
|
8
7
|
"design-import": (problem) => [`${problem.specifier} authors design, which belongs to the design system.`, "Declare the design in the design system and import the owner from its public entry."],
|
|
9
8
|
"component-outside-pattern": (problem) => [
|
|
@@ -11,10 +10,6 @@ const wording = {
|
|
|
11
10
|
"Render it inside the pattern that arranges this screen (as its child or in a slot prop); if no pattern does, add one to the design system."
|
|
12
11
|
],
|
|
13
12
|
"local-markup": (problem) => [`<${problem.tag}> is not imported from the design system.`, "Render a design-system owner; an arrangement or element the screen needs belongs in a pattern of the design system."],
|
|
14
|
-
"prose-element-undeclared": (problem) => [
|
|
15
|
-
`<${problem.tag}> is content of ${problem.owner}, whose recipe declares no such element: it is drawn without a design.`,
|
|
16
|
-
`Declare the element in the prose recipe of ${problem.owner} (\`elements\`), or write the content with the elements it declares.`
|
|
17
|
-
],
|
|
18
13
|
"spread-props": () => ["A spread passes props nothing can see.", "Pass each prop explicitly."],
|
|
19
14
|
"design-prop": (problem) => [`${problem.attribute} supplies design from outside the design system.`, "Remove it; choose the treatment through the owner's own props."],
|
|
20
15
|
"imperative-design": (problem) => [`${problem.member} writes styles or creates DOM by hand.`, "Remove the write; render design-system owners with props."],
|
|
@@ -48,7 +43,6 @@ export async function designSystemEntry(publicEntry, entryFile) {
|
|
|
48
43
|
patterns.add(element.name.text);
|
|
49
44
|
}
|
|
50
45
|
}
|
|
51
|
-
|
|
52
|
-
return { publicEntry, patterns, prose };
|
|
46
|
+
return { publicEntry, patterns };
|
|
53
47
|
}
|
|
54
48
|
export const closeDesignUsage = () => closeSyntax();
|
package/dist/emit/emission.mjs
CHANGED
|
@@ -33,8 +33,6 @@ import { encodeEmittedBytes } from "./operation-reply.mjs";
|
|
|
33
33
|
import { preloadedFaces } from "../font-checks.mjs";
|
|
34
34
|
import { ownerEmissionKey, projectEmissionCache } from "./owner-emission-cache.mjs";
|
|
35
35
|
import { moduleProperties, namespacedClasses, namespacedSheet } from "./namespace.mjs";
|
|
36
|
-
import { publicProse } from "../analysis/prose-owners.mjs";
|
|
37
|
-
import { PROSE_MANIFEST, proseManifestText } from "../prose-model.mjs";
|
|
38
36
|
const designSystemFolder = ({ root, dsRoot }) => path.relative(root, dsRoot).split(path.sep).join("/");
|
|
39
37
|
function packageManifest(root) {
|
|
40
38
|
const text = optionalSourceText(path.join(root, "package.json"));
|
|
@@ -134,9 +132,6 @@ export async function revisionEmission(project) {
|
|
|
134
132
|
}
|
|
135
133
|
const fonts = fontEmission(checked.fonts, preloadedFaces(foundation, checked.document, checked.fonts));
|
|
136
134
|
withFontsModule(files, fonts, PUBLIC_BARREL);
|
|
137
|
-
const prose = await publicProse(project.dsRoot);
|
|
138
|
-
if (prose.size > 0)
|
|
139
|
-
files.set(PROSE_MANIFEST, proseManifestText(prose));
|
|
140
135
|
const icon = await timing.timeStage("emit-app-icon", () => appIconEmission(checked.appIcon));
|
|
141
136
|
withAppIconsModule(files, icon, PUBLIC_BARREL);
|
|
142
137
|
files.set(DEPENDENCY_MANIFEST, dependencyManifestText(check.graph, { packageManifest: packageManifest(project.root), framework: project.config.framework }));
|
package/dist/grid-lowering.mjs
CHANGED
|
@@ -83,7 +83,9 @@ export function lowerGrid(spec, foundation, input) {
|
|
|
83
83
|
return reject({ kind: "spatial-clause-unsupported", clause: `condition ${placement.condition} cell ${selector}` });
|
|
84
84
|
const cells = spec.cells.map((cell) => {
|
|
85
85
|
const override = placement.cells.find(([selector]) => selector === cell.selector)?.[1];
|
|
86
|
-
|
|
86
|
+
if (override === void 0)
|
|
87
|
+
return cell;
|
|
88
|
+
return { ...cell, values: cell.repeat && !override.some(([field]) => field === "start") ? [...override, ["start", "auto"]] : override, at: [] };
|
|
87
89
|
});
|
|
88
90
|
return { placement, tree: layoutTree(cells) };
|
|
89
91
|
}), geometry = geometryOf(foundation, geometryTokens, reject), algebra = model(spatialModel(definition, geometry), reject), pristine = { source: source.clone(), alternates: alternates.map(({ placement, tree }) => ({ placement, tree: tree.clone() })) }, tile = spec.mode === "fixed" ? token(field("tile-size")) : null, regionsOf = (base, placed, length) => ({
|
package/dist/lowering-enter.mjs
CHANGED
|
@@ -15,17 +15,17 @@ export function enterRules(input) {
|
|
|
15
15
|
const blurred = fields.blur !== void 0, shadowOf = (surface) => {
|
|
16
16
|
const field = [SHAPE_SHADOW, GROUP_SHADOW].find((name) => surface[name] !== void 0);
|
|
17
17
|
return field === void 0 ? {} : { [field]: surface[field] ?? "" };
|
|
18
|
-
}, effects = (surface) => fields.blur === void 0 ? {} : { blur: fields.blur, ...shadowOf(surface) }, values = { ...fields.opacity === void 0 ? {} : { opacity: fields.opacity }, ...effects(base) };
|
|
19
|
-
if (movement !== null)
|
|
20
|
-
values[
|
|
21
|
-
const repeated = states.flatMap((state) => {
|
|
18
|
+
}, effects = (surface) => fields.blur === void 0 ? {} : { blur: fields.blur, ...shadowOf(surface) }, values = { ...fields.opacity === void 0 ? {} : { opacity: fields.opacity }, ...effects(base) }, property = movement === null ? null : movement.kind === "translateInline" ? "translate" : movement.kind;
|
|
19
|
+
if (movement !== null && property !== null)
|
|
20
|
+
values[property] = movement.kind === "translate" ? `0 ${movement.value}` : movement.kind === "translateInline" ? `${movement.value} 0` : movement.value;
|
|
21
|
+
const mirrored = movement?.kind === "translateInline" ? [{ selector: `${selector}:dir(rtl)`, values: { translate: `calc(${movement.value} * -1) 0` }, condition: STARTING }] : [], repeated = states.flatMap((state) => {
|
|
22
22
|
const own = {
|
|
23
23
|
...fields.opacity !== void 0 && state.fields.opacity !== void 0 ? { opacity: fields.opacity } : {},
|
|
24
24
|
...blurred && ["blur", SHAPE_SHADOW, GROUP_SHADOW].some((field) => state.fields[field] !== void 0) ? effects({ ...shadowOf(base), ...shadowOf(state.fields) }) : {}
|
|
25
25
|
};
|
|
26
26
|
return Object.keys(own).length === 0 ? [] : [{ selector: state.selector, values: own, condition: STARTING }];
|
|
27
|
-
}), properties = [...fields.opacity === void 0 ? [] : ["opacity"], ...blurred ? ["filter"] : [], ...
|
|
27
|
+
}), properties = [...fields.opacity === void 0 ? [] : ["opacity"], ...blurred ? ["filter"] : [], ...property === null ? [] : [property]], conflict = properties.find((property) => taken.includes(property));
|
|
28
28
|
if (conflict !== void 0)
|
|
29
29
|
return err({ kind: "enter-property-conflict", element: selector, property: conflict });
|
|
30
|
-
return ok({ group: { properties, timing }, start: [{ selector, values, condition: STARTING }, ...repeated], blurred });
|
|
30
|
+
return ok({ group: { properties, timing }, start: [{ selector, values, condition: STARTING }, ...mirrored, ...repeated], blurred });
|
|
31
31
|
}
|