@reqvire-org/ads 0.5.2 → 0.5.4
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 +35 -3
- package/dist/analysis/owner-composition.mjs +75 -13
- package/dist/analysis/owner-source.mjs +64 -40
- package/dist/composed-contrast.mjs +165 -65
- package/dist/construction-output.mjs +12 -5
- package/dist/construction-spec.d.mts +125 -50
- package/dist/construction-spec.mjs +154 -81
- 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-overlaps.mjs +6 -1
- package/dist/lowering-properties.mjs +3 -0
- package/dist/lowering-session.mjs +10 -0
- package/dist/lowering-transitions.mjs +1 -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 +15 -7
- package/dist/paint-contrast.mjs +6 -0
- package/dist/platform-features.mjs +6 -0
- package/dist/profile-macro.d.mts +7 -0
- package/dist/recipe-macro.d.mts +104 -45
- package/dist/recipe-model.mjs +19 -12
- package/dist/region-lowering.mjs +128 -121
- package/dist/role-vocabulary.d.mts +7 -0
- package/dist/role-vocabulary.mjs +7 -0
- package/dist/runtime-paint-contrast.mjs +5 -2
- package/dist/showcase/client.bundle.js +51 -51
- package/dist/showcase/http-client.bundle.js +13 -13
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +6 -6
- 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 +43 -19
- 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 +43 -19
- package/dist/skills/ads-migrate/SKILL.md +2 -0
- package/dist/skills/ads-migrate/references/0.5.2-to-0.5.3.md +71 -0
- package/dist/skills/ads-migrate/references/0.5.3-to-0.5.4.md +42 -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 +43 -19
- 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 +181 -21
- package/docs/GUIDE.md +64 -19
- package/docs/LANGUAGE.md +169 -139
- package/docs/MCP.md +5 -1
- package/docs/MOTION.md +16 -3
- package/docs/PROFILE-KINDS.md +52 -5
- 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,15 +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
|
-
|
|
6
|
-
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 = {
|
|
7
6
|
scale: { channel: "scale", field: "scale" },
|
|
8
7
|
scaleInline: { channel: "scale", field: "scale" },
|
|
9
8
|
scaleBlock: { channel: "scale", field: "scale" },
|
|
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"
|
|
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"], REPLACED_ELEMENTS = ["img", "input", "select", "textarea", "video", "iframe", "br", "hr", "svg"], PSEUDO_HOSTS = { placeholder: ["input", "textarea"], progressValue: ["progress"], marker: ["li", "summary"], before: "non-replaced" }, 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 = {
|
|
16
|
+
"start-start": "start-start-radius",
|
|
17
|
+
"start-end": "start-end-radius",
|
|
18
|
+
"end-start": "end-start-radius",
|
|
19
|
+
"end-end": "end-end-radius"
|
|
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"], 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
21
|
export function elementTags(element) {
|
|
15
22
|
switch (element.kind) {
|
|
16
23
|
case "iframe":
|
|
@@ -69,12 +76,13 @@ export function declaredParts(spec) {
|
|
|
69
76
|
return [];
|
|
70
77
|
}
|
|
71
78
|
}
|
|
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) => [
|
|
79
|
+
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
80
|
{
|
|
74
81
|
name: part.name,
|
|
75
82
|
path: `${parent}.parts.${part.name}`,
|
|
76
83
|
selector: part.selector,
|
|
77
84
|
required: part.required,
|
|
85
|
+
repeat: part.repeat,
|
|
78
86
|
kind: part.content.kind,
|
|
79
87
|
within,
|
|
80
88
|
pseudo: part.pseudo.map((treatment) => treatment.pseudo),
|
|
@@ -280,7 +288,7 @@ function decorPart(name, value, read) {
|
|
|
280
288
|
}
|
|
281
289
|
function textPart(name, value, read) {
|
|
282
290
|
const path = `recipe.parts.${name}`, part = read.object(value, path);
|
|
283
|
-
read.only(part, path, ["kind", "selector", "required", "textEdge", "wrap", "textAlign"]);
|
|
291
|
+
read.only(part, path, ["kind", "selector", "required", "textEdge", "wrap", "textAlign", "extent"]);
|
|
284
292
|
return {
|
|
285
293
|
kind: "text",
|
|
286
294
|
name,
|
|
@@ -288,7 +296,8 @@ function textPart(name, value, read) {
|
|
|
288
296
|
required: read.boolean(part.required, `${path}.required`),
|
|
289
297
|
textEdge: part.textEdge === void 0 ? [] : read.strings(part.textEdge, `${path}.textEdge`),
|
|
290
298
|
wrap: controlLabelWrap(part.wrap, `${path}.wrap`, read),
|
|
291
|
-
align: part.textAlign === void 0 ? null : read.literal(part.textAlign, `${path}.textAlign`, TEXT_ALIGNS)
|
|
299
|
+
align: part.textAlign === void 0 ? null : read.literal(part.textAlign, `${path}.textAlign`, TEXT_ALIGNS),
|
|
300
|
+
extent: part.extent === void 0 ? "content" : read.literal(part.extent, `${path}.extent`, ["content", "fill"])
|
|
292
301
|
};
|
|
293
302
|
}
|
|
294
303
|
function controlLabelWrap(wrap, path, read) {
|
|
@@ -333,7 +342,7 @@ function artwork(spec, read) {
|
|
|
333
342
|
if (parts.length !== 1 || entry === void 0)
|
|
334
343
|
return read.reject({ kind: "parts-unsupported", construction: "artwork", detail: "standalone artwork has exactly one visual part" });
|
|
335
344
|
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"]);
|
|
345
|
+
read.only(part, path, ["kind", "selector", "required", "motion", "transition", "when", "play", ...VISUAL_BINDING_FIELDS]);
|
|
337
346
|
read.literal(part.kind, `${path}.kind`, ["visual"]);
|
|
338
347
|
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
348
|
const fields = read.object(value, `${path}.when.${condition}`);
|
|
@@ -365,59 +374,7 @@ function artwork(spec, read) {
|
|
|
365
374
|
}
|
|
366
375
|
};
|
|
367
376
|
}
|
|
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
|
-
}
|
|
377
|
+
const REGION_LAYOUTS = ["inline", "stack", "flow", "layered"], ROOT_LAYOUTS = REGION_LAYOUTS;
|
|
421
378
|
export const ROOT_EXTENTS = ["content", "container"];
|
|
422
379
|
function rootExtent(value, layout, layer, read) {
|
|
423
380
|
if (value === void 0)
|
|
@@ -632,20 +589,86 @@ function enterSpec(value, path, read) {
|
|
|
632
589
|
read.only(from, `${path}.from`, ["surface", ...Object.keys(ENTER_MOVEMENTS)]);
|
|
633
590
|
const moved = Object.keys(ENTER_MOVEMENTS).filter((kind) => from[kind] !== void 0), surface = read.optionalString(from.surface, `${path}.from.surface`);
|
|
634
591
|
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");
|
|
592
|
+
read.invalid(`${path}.from`, "a starting `surface`, one of `translate`, `translateInline`, `scale` and `rotate`, or both");
|
|
636
593
|
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
594
|
if (typeof motion === "string")
|
|
638
595
|
return { driver: { kind: "first-render" }, surface, movement, motion: { kind: "profile", name: motion }, path };
|
|
639
596
|
read.slotless(motion, `${path}.motion`, "motion");
|
|
640
597
|
return { driver: { kind: "first-render" }, surface, movement, motion: { kind: "slot" }, path };
|
|
641
598
|
}
|
|
599
|
+
const COUNTER_NAME = /^[a-z][a-z0-9-]*$/, RESERVED_COUNTERS = ["none", "inherit", "initial", "unset", "revert", "revert-layer", "default"];
|
|
600
|
+
function counterName(value, path, read) {
|
|
601
|
+
const name = read.string(value, path);
|
|
602
|
+
if (!COUNTER_NAME.test(name) || RESERVED_COUNTERS.includes(name))
|
|
603
|
+
read.invalid(path, "a counter name: lowercase letters, digits and hyphens, not a CSS keyword");
|
|
604
|
+
return name;
|
|
605
|
+
}
|
|
606
|
+
function contentLiteral(value, path, read, fallback) {
|
|
607
|
+
if (value === void 0)
|
|
608
|
+
return fallback;
|
|
609
|
+
const text = read.string(value, path);
|
|
610
|
+
if (text.length > 4 || !/^[\p{P}\p{S}\p{Zs}]*$/u.test(text))
|
|
611
|
+
read.invalid(path, "at most four punctuation marks or spaces");
|
|
612
|
+
return text;
|
|
613
|
+
}
|
|
614
|
+
function generatedContent(value, path, read) {
|
|
615
|
+
if (value === void 0)
|
|
616
|
+
return null;
|
|
617
|
+
const declared = read.object(value, path);
|
|
618
|
+
read.only(declared, path, ["counter", "counters", "style", "separator", "prefix", "suffix"]);
|
|
619
|
+
const kind = declared.counters !== void 0 ? "counters" : "counter";
|
|
620
|
+
if (declared.counter === void 0 === (declared.counters === void 0))
|
|
621
|
+
read.invalid(path, "one of `counter` (a value) and `counters` (every level, joined by `separator`)");
|
|
622
|
+
if (kind === "counter" && declared.separator !== void 0)
|
|
623
|
+
read.invalid(`${path}.separator`, "omitted with `counter`: one level has nothing to join");
|
|
624
|
+
return {
|
|
625
|
+
kind,
|
|
626
|
+
name: counterName(declared[kind], `${path}.${kind}`, read),
|
|
627
|
+
style: declared.style === void 0 ? "decimal" : read.literal(declared.style, `${path}.style`, COUNTER_STYLES),
|
|
628
|
+
separator: contentLiteral(declared.separator, `${path}.separator`, read, "."),
|
|
629
|
+
prefix: contentLiteral(declared.prefix, `${path}.prefix`, read, ""),
|
|
630
|
+
suffix: contentLiteral(declared.suffix, `${path}.suffix`, read, "")
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
function counterSpec(value, path, read) {
|
|
634
|
+
if (value === void 0)
|
|
635
|
+
return null;
|
|
636
|
+
const declared = read.object(value, path);
|
|
637
|
+
read.only(declared, path, ["reset", "increment"]);
|
|
638
|
+
if (declared.reset === void 0 && declared.increment === void 0)
|
|
639
|
+
read.invalid(path, "a `reset`, an `increment` or both");
|
|
640
|
+
return {
|
|
641
|
+
reset: declared.reset === void 0 ? null : counterName(declared.reset, `${path}.reset`, read),
|
|
642
|
+
increment: declared.increment === void 0 ? null : counterName(declared.increment, `${path}.increment`, read)
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
function betweenRule(value, path, read) {
|
|
646
|
+
if (value === void 0)
|
|
647
|
+
return null;
|
|
648
|
+
const declared = read.object(value, path);
|
|
649
|
+
read.only(declared, path, ["surface", "frame"]);
|
|
650
|
+
return { surface: read.string(declared.surface, `${path}.surface`), frame: read.string(declared.frame, `${path}.frame`) };
|
|
651
|
+
}
|
|
652
|
+
function markerStyles(value, path, read) {
|
|
653
|
+
if (value === void 0)
|
|
654
|
+
return [];
|
|
655
|
+
const styles = read.strings(value, path).map((style) => read.literal(style, path, MARKER_STYLES));
|
|
656
|
+
if (styles.length === 0 || styles.length > 3)
|
|
657
|
+
read.invalid(path, "one to three marker styles, outermost list first");
|
|
658
|
+
return styles;
|
|
659
|
+
}
|
|
642
660
|
function pseudoTreatments(value, path, read) {
|
|
643
661
|
if (value === void 0)
|
|
644
662
|
return [];
|
|
645
663
|
return Object.entries(read.object(value, path)).map(([name, treatment]) => {
|
|
646
|
-
const at = `${path}.${name}`, pseudo = read.literal(name, at, PSEUDO_ELEMENTS), fields = read.object(treatment, at);
|
|
647
|
-
read.only(fields, at, ["surface", "when"]);
|
|
648
|
-
|
|
664
|
+
const at = `${path}.${name}`, pseudo = read.literal(name, at, PSEUDO_ELEMENTS), fields = read.object(treatment, at), generated = pseudo === "marker" || pseudo === "before";
|
|
665
|
+
read.only(fields, at, generated ? ["surface", "text", "content", "when"] : ["surface", "when"]);
|
|
666
|
+
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);
|
|
667
|
+
if (pseudo === "before" && content === null)
|
|
668
|
+
read.invalid(`${at}.content`, "the generated content `before` shows (a counter)");
|
|
669
|
+
if (pseudo === "marker" && surface === null && text === null && content === null)
|
|
670
|
+
read.invalid(at, "a `surface`, a `text`, a `content` or several");
|
|
671
|
+
return { pseudo, surface, text, content, when: treatments(fields.when, `${at}.when`, read) };
|
|
649
672
|
});
|
|
650
673
|
}
|
|
651
674
|
function frameBorder(value, path, read) {
|
|
@@ -752,7 +775,7 @@ export function normalizedDeclarations(values) {
|
|
|
752
775
|
}
|
|
753
776
|
const isNormalizeField = (key) => Object.hasOwn(NORMALIZE_FIELDS, key);
|
|
754
777
|
export const INTERACTION_FIELDS = ["cursor", "touchAction", "userSelect"];
|
|
755
|
-
const PART_NORMALIZE = [...INTERACTION_FIELDS, "resize"], CONTROL_NORMALIZE = ["borderStyle", "textDecoration", ...INTERACTION_FIELDS], REGION_NORMALIZE = ["margin", "borderStyle", "textDecoration", "pointerEvents", ...INTERACTION_FIELDS];
|
|
778
|
+
const PART_NORMALIZE = [...INTERACTION_FIELDS, "resize", "margin"], CONTROL_NORMALIZE = ["borderStyle", "textDecoration", ...INTERACTION_FIELDS], REGION_NORMALIZE = ["margin", "borderStyle", "textDecoration", "pointerEvents", ...INTERACTION_FIELDS];
|
|
756
779
|
function normalizeValues(values, path, fields, read) {
|
|
757
780
|
read.only(values, path, fields);
|
|
758
781
|
return Object.entries(values).flatMap(([key, value]) => {
|
|
@@ -884,7 +907,7 @@ function partConditions(value, path, read) {
|
|
|
884
907
|
});
|
|
885
908
|
}
|
|
886
909
|
function partContent(part, path, read) {
|
|
887
|
-
const kind = part.kind === void 0 ? "element" : read.literal(part.kind, `${path}.kind`, ["text", "visual", "vector"]);
|
|
910
|
+
const kind = part.kind === void 0 ? "element" : read.literal(part.kind, `${path}.kind`, ["text", "visual", "vector", "component"]);
|
|
888
911
|
if (kind !== "visual" && part.media !== void 0)
|
|
889
912
|
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.media` });
|
|
890
913
|
if (kind !== "vector" && part.stroke !== void 0)
|
|
@@ -893,6 +916,12 @@ function partContent(part, path, read) {
|
|
|
893
916
|
case "text":
|
|
894
917
|
case "element":
|
|
895
918
|
return { kind };
|
|
919
|
+
case "component": {
|
|
920
|
+
for (const field of Object.keys(part))
|
|
921
|
+
if (!["kind", "selector", "required", "repeat", "extent", "at", "spaceBefore", "spaceAfter", "spacing"].includes(field))
|
|
922
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.${field}` });
|
|
923
|
+
return { kind };
|
|
924
|
+
}
|
|
896
925
|
case "visual":
|
|
897
926
|
return { kind, media: part.media === void 0 ? "bound" : read.literal(part.media, `${path}.media`, ["inspected-svg"]) };
|
|
898
927
|
case "vector": {
|
|
@@ -1031,9 +1060,17 @@ function regionPart(name, value, read, path, nested) {
|
|
|
1031
1060
|
"stroke",
|
|
1032
1061
|
"accessibility",
|
|
1033
1062
|
"focus",
|
|
1063
|
+
"drawnBy",
|
|
1034
1064
|
"anchorClear",
|
|
1035
1065
|
"collapsed",
|
|
1036
1066
|
"geometryTransition",
|
|
1067
|
+
"repeat",
|
|
1068
|
+
"spaceBefore",
|
|
1069
|
+
"spaceAfter",
|
|
1070
|
+
"counter",
|
|
1071
|
+
"spacing",
|
|
1072
|
+
"between",
|
|
1073
|
+
"presence",
|
|
1037
1074
|
...VISUAL_BINDING_FIELDS,
|
|
1038
1075
|
...nested ? [] : ["measured", "paints"]
|
|
1039
1076
|
]);
|
|
@@ -1057,6 +1094,10 @@ function regionPart(name, value, read, path, nested) {
|
|
|
1057
1094
|
name,
|
|
1058
1095
|
selector: read.string(part.selector, `${path}.selector`),
|
|
1059
1096
|
required: read.boolean(part.required, `${path}.required`),
|
|
1097
|
+
repeat: part.repeat === void 0 ? !1 : read.boolean(part.repeat, `${path}.repeat`),
|
|
1098
|
+
spaceBefore: part.spaceBefore === void 0 ? null : read.slot(part.spaceBefore, `${path}.spaceBefore`, "spacing"),
|
|
1099
|
+
spaceAfter: part.spaceAfter === void 0 ? null : read.slot(part.spaceAfter, `${path}.spaceAfter`, "spacing"),
|
|
1100
|
+
spacing: read.optionalString(part.spacing, `${path}.spacing`),
|
|
1060
1101
|
content,
|
|
1061
1102
|
textEdge: part.textEdge === void 0 ? [] : read.strings(part.textEdge, `${path}.textEdge`),
|
|
1062
1103
|
textLayout: textLayout(part, path, read),
|
|
@@ -1083,9 +1124,13 @@ function regionPart(name, value, read, path, nested) {
|
|
|
1083
1124
|
sticky: stickySpec(part.sticky, `${path}.sticky`, read),
|
|
1084
1125
|
outset: outsetSpec(part.outset, `${path}.outset`, read),
|
|
1085
1126
|
focusOf: focusSource(part.focus, `${path}.focus`, read),
|
|
1127
|
+
drawnBy: part.drawnBy === void 0 ? null : read.string(part.drawnBy, `${path}.drawnBy`),
|
|
1086
1128
|
anchorClear: anchorClear(part.anchorClear, `${path}.anchorClear`, read),
|
|
1087
1129
|
scheme: partScheme(part, content, path, read),
|
|
1088
1130
|
pseudo: pseudoTreatments(part.pseudo, `${path}.pseudo`, read),
|
|
1131
|
+
counter: counterSpec(part.counter, `${path}.counter`, read),
|
|
1132
|
+
between: betweenRule(part.between, `${path}.between`, read),
|
|
1133
|
+
presence: part.presence === void 0 ? "visible" : read.literal(part.presence, `${path}.presence`, ["visible", "assistive"]),
|
|
1089
1134
|
arrangement: arranged,
|
|
1090
1135
|
parts: parseParts(part.parts, read, path, !0),
|
|
1091
1136
|
measured: measuredValues(part.measured, `${path}.measured`, read),
|
|
@@ -1114,6 +1159,21 @@ function parseParts(value, read, path, nested) {
|
|
|
1114
1159
|
for (const part of parts)
|
|
1115
1160
|
if (part.focusOf !== null && (part.focusOf === part.name || !parts.some((other) => other.name === part.focusOf)))
|
|
1116
1161
|
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)");
|
|
1162
|
+
for (const part of parts) {
|
|
1163
|
+
if (!part.repeat)
|
|
1164
|
+
continue;
|
|
1165
|
+
if (part.content.kind === "vector")
|
|
1166
|
+
read.invalid(`${path}.parts.${part.name}.repeat`, "omitted on a vector part, which already renders any number of shapes");
|
|
1167
|
+
if (part.drawnBy !== null || part.focusOf !== null || parts.some((other) => other.focusOf === part.name || other.drawnBy === part.name))
|
|
1168
|
+
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");
|
|
1169
|
+
}
|
|
1170
|
+
parts.forEach((part, index) => {
|
|
1171
|
+
if (part.drawnBy === null)
|
|
1172
|
+
return;
|
|
1173
|
+
const drawing = parts[index + 1];
|
|
1174
|
+
if (drawing === void 0 || drawing.name !== part.drawnBy || drawing.focusOf !== part.name)
|
|
1175
|
+
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`);
|
|
1176
|
+
});
|
|
1117
1177
|
const schemed = parts.filter((part) => part.scheme !== null);
|
|
1118
1178
|
for (const scheme of schemed.length === 0 ? [] : COLOR_SCHEMES) {
|
|
1119
1179
|
const [first, second] = schemed.filter((part) => part.scheme === scheme), at = second ?? first ?? schemed[0];
|
|
@@ -1177,10 +1237,12 @@ function region(authored, read) {
|
|
|
1177
1237
|
"paintTransition",
|
|
1178
1238
|
"enter",
|
|
1179
1239
|
"sticky",
|
|
1180
|
-
"elements",
|
|
1181
|
-
"rhythm",
|
|
1182
1240
|
"play",
|
|
1183
1241
|
"at",
|
|
1242
|
+
"pseudo",
|
|
1243
|
+
"counter",
|
|
1244
|
+
"markers",
|
|
1245
|
+
"between",
|
|
1184
1246
|
"parts",
|
|
1185
1247
|
"exposeRows",
|
|
1186
1248
|
"layer",
|
|
@@ -1195,13 +1257,7 @@ function region(authored, read) {
|
|
|
1195
1257
|
"overlap",
|
|
1196
1258
|
"geometryTransition"
|
|
1197
1259
|
]);
|
|
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);
|
|
1260
|
+
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
1261
|
uniqueMeasured(measured, parts, read);
|
|
1206
1262
|
const paints = runtimePaints(spec.paints, "recipe.paints", read);
|
|
1207
1263
|
uniqueNames("paints", paints, parts.map((part) => [part.name, part.paints]), read);
|
|
@@ -1214,6 +1270,10 @@ function region(authored, read) {
|
|
|
1214
1270
|
return {
|
|
1215
1271
|
kind: "region",
|
|
1216
1272
|
source: authored,
|
|
1273
|
+
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}` })),
|
|
1274
|
+
counter: counterSpec(spec.counter, "recipe.counter", read),
|
|
1275
|
+
markers: markerStyles(spec.markers, "recipe.markers", read),
|
|
1276
|
+
between: betweenRule(spec.between, "recipe.between", read),
|
|
1217
1277
|
profile: read.optionalString(spec.profile, "recipe.profile"),
|
|
1218
1278
|
select: Object.fromEntries(spec.select === void 0 ? [] : read.stringRecord(spec.select, "recipe.select")),
|
|
1219
1279
|
arrangement: arrangement(spec, read, "recipe", layout),
|
|
@@ -1230,7 +1290,6 @@ function region(authored, read) {
|
|
|
1230
1290
|
press: rootStates.press,
|
|
1231
1291
|
paintTransition: paintTransition(spec.paintTransition, "recipe.paintTransition", read),
|
|
1232
1292
|
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
1293
|
anchorClear: layer !== null && spec.anchorClear !== void 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.anchorClear" }) : anchorClear(spec.anchorClear, "recipe.anchorClear", read),
|
|
1235
1294
|
textWhen: rootStates.texts,
|
|
1236
1295
|
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 +1352,7 @@ function grid(spec, read) {
|
|
|
1293
1352
|
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
1353
|
if (frame !== null && (frame.kind !== "fields" || frame.container || frame.ratio !== null || frame.border.kind !== "profile"))
|
|
1295
1354
|
read.reject({ kind: "field-unsupported", construction: "grid", path: "recipe.frame" });
|
|
1296
|
-
|
|
1355
|
+
const parsed = {
|
|
1297
1356
|
kind: "grid",
|
|
1298
1357
|
source: spec,
|
|
1299
1358
|
mode,
|
|
@@ -1302,11 +1361,19 @@ function grid(spec, read) {
|
|
|
1302
1361
|
rowGap: spec.rowGap === void 0 ? null : read.slot(spec.rowGap, "recipe.rowGap", "spacing"),
|
|
1303
1362
|
frame,
|
|
1304
1363
|
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);
|
|
1364
|
+
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);
|
|
1365
|
+
if (repeated) {
|
|
1366
|
+
for (const [at, placed] of [[path, own], ...tiers.map(([tier, placed]) => [`${path}.at.${tier}`, placed])])
|
|
1367
|
+
for (const [field, item] of placed)
|
|
1368
|
+
if (field === "start" && item !== "auto" || field === "end" || field === "row" || field === "rowSpan")
|
|
1369
|
+
read.invalid(`${at}.${field}`, 'omitted on a repeated cell: its instances flow one after another (`start: "auto"`), each over its `span`');
|
|
1370
|
+
}
|
|
1306
1371
|
return {
|
|
1307
1372
|
selector,
|
|
1308
|
-
|
|
1309
|
-
|
|
1373
|
+
required: required === void 0 ? !0 : read.boolean(required, `${path}.required`),
|
|
1374
|
+
repeat: repeated,
|
|
1375
|
+
values: repeated && !own.some(([field]) => field === "start") ? [...own, ["start", "auto"]] : own,
|
|
1376
|
+
at: tiers
|
|
1310
1377
|
};
|
|
1311
1378
|
}),
|
|
1312
1379
|
conditions: Object.entries(spec.at === void 0 ? {} : read.object(spec.at, "recipe.at")).map(([condition, value]) => {
|
|
@@ -1316,5 +1383,11 @@ function grid(spec, read) {
|
|
|
1316
1383
|
}),
|
|
1317
1384
|
alignRows: Object.entries(spec.alignRows === void 0 ? {} : read.object(spec.alignRows, "recipe.alignRows")).map(([selector, rows]) => [selector, read.strings(rows, `recipe.alignRows.${selector}`)]),
|
|
1318
1385
|
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
|
-
};
|
|
1386
|
+
}, repeated = new Set(parsed.cells.flatMap((cell) => cell.repeat ? [cell.selector] : []));
|
|
1387
|
+
for (const { condition, cells } of parsed.conditions)
|
|
1388
|
+
for (const [selector, placed] of cells)
|
|
1389
|
+
for (const [field, item] of repeated.has(selector) ? placed : [])
|
|
1390
|
+
if (field === "start" && item !== "auto" || field === "end" || field === "row" || field === "rowSpan")
|
|
1391
|
+
read.invalid(`recipe.at.${condition}.cells.${selector}.${field}`, "omitted on a repeated cell: its instances flow one after another");
|
|
1392
|
+
return parsed;
|
|
1320
1393
|
}
|
|
@@ -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" && own !== "border-width")
|
|
123
|
+
return reject({ kind: "token-role", profile: name, field, token: field, role: own, expected: ["paint", "border-width"] });
|
|
124
|
+
for (const token of references(value)) {
|
|
125
|
+
const role = tokens.get(token)?.role ?? null;
|
|
126
|
+
if (role !== own)
|
|
127
|
+
return reject({ kind: "token-role", profile: name, field, token, role, expected: [own] });
|
|
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
|
}
|
|
@@ -101,7 +101,7 @@ function parseShape(selector) {
|
|
|
101
101
|
}).processSync(selector);
|
|
102
102
|
return shape;
|
|
103
103
|
}
|
|
104
|
-
const childChain = (shape) => shape.combinators.every((combinator) => combinator === ">"), typeOf = (compound) => /^[a-z][\w-]*/i.exec(compound.structure)?.[0].toLowerCase() ?? null, markersOf = (compound) => [...compound.structure.matchAll(/\.([\w-]+)/g)].map((match) => match[1] ?? ""), pseudoElementOf = (compound) => /::([\w-]+)/.exec(compound.structure)?.[1]?.toLowerCase() ?? null;
|
|
104
|
+
const childChain = (shape) => shape.combinators.every((combinator) => combinator === ">"), fixedChain = (shape) => shape.combinators.every((combinator) => combinator === ">" || combinator === "+"), typeOf = (compound) => /^[a-z][\w-]*/i.exec(compound.structure)?.[0].toLowerCase() ?? null, markersOf = (compound) => [...compound.structure.matchAll(/\.([\w-]+)/g)].map((match) => match[1] ?? ""), pseudoElementOf = (compound) => /::([\w-]+)/.exec(compound.structure)?.[1]?.toLowerCase() ?? null;
|
|
105
105
|
function compoundsDiffer(a, b) {
|
|
106
106
|
if (pseudoElementOf(a) !== pseudoElementOf(b))
|
|
107
107
|
return !0;
|
|
@@ -125,6 +125,11 @@ function mayCoincide(a, b) {
|
|
|
125
125
|
return other !== void 0 && compoundsDiffer(compound, other);
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
+
if (fixedChain(a) && a.combinators.length === b.combinators.length && a.combinators.every((combinator, index) => combinator === b.combinators[index]))
|
|
129
|
+
return !a.compounds.some((compound, index) => {
|
|
130
|
+
const other = b.compounds[index];
|
|
131
|
+
return other !== void 0 && compoundsDiffer(compound, other);
|
|
132
|
+
});
|
|
128
133
|
return !compoundsDiffer(lastA, lastB);
|
|
129
134
|
}
|
|
130
135
|
const samePath = (a, b) => a.compounds.length === b.compounds.length && a.combinators.every((combinator, index) => combinator === b.combinators[index]) && a.compounds.every((compound, index) => compound.structure === b.compounds[index]?.structure);
|
|
@@ -67,6 +67,15 @@ export function createLoweringSession(context, operation) {
|
|
|
67
67
|
return err({ kind: "paint", error: channels.error });
|
|
68
68
|
registry = withChannels(registry, slots);
|
|
69
69
|
return write(channels.value);
|
|
70
|
+
}, writeProvidedRoles = (request) => {
|
|
71
|
+
const roles = request.values.map(([property]) => property), reserved = roles.find((property) => !/^--[a-z][\w-]*$/.test(property) || property.startsWith("--ads-") || property.startsWith("--asset-"));
|
|
72
|
+
if (reserved !== void 0)
|
|
73
|
+
return err({ kind: "emission", error: { kind: "unregistered-property", property: reserved, origin } });
|
|
74
|
+
const extended = new Map(registry);
|
|
75
|
+
for (const property of roles)
|
|
76
|
+
extended.set(property, { kind: "independent" });
|
|
77
|
+
registry = extended;
|
|
78
|
+
return write(request);
|
|
70
79
|
}, documents = new Map;
|
|
71
80
|
return {
|
|
72
81
|
write,
|
|
@@ -75,6 +84,7 @@ export function createLoweringSession(context, operation) {
|
|
|
75
84
|
writeContinuousRotation,
|
|
76
85
|
writeKeyframes,
|
|
77
86
|
writePaintChannels,
|
|
87
|
+
writeProvidedRoles,
|
|
78
88
|
writeDocument: (rule) => void documents.set(rule.kind, rule),
|
|
79
89
|
blocks: () => written,
|
|
80
90
|
keyframes: () => [...keyframes.values()],
|