@reqvire-org/ads 0.5.3 → 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/analysis/owner-analysis-key.mjs +1 -1
- package/dist/analysis/owner-choices.mjs +2 -0
- package/dist/analysis/owner-composition.mjs +14 -1
- package/dist/analysis/owner-source.mjs +13 -6
- package/dist/composed-contrast.mjs +24 -5
- package/dist/construction-output.mjs +6 -4
- package/dist/construction-spec.d.mts +72 -6
- package/dist/construction-spec.mjs +92 -7
- package/dist/design-foundation.mjs +4 -4
- package/dist/lowering-overlaps.mjs +6 -1
- package/dist/lowering-properties.mjs +3 -0
- package/dist/lowering-transitions.mjs +1 -0
- package/dist/ownership-model.mjs +9 -3
- package/dist/platform-features.mjs +6 -0
- package/dist/recipe-macro.d.mts +58 -3
- package/dist/recipe-model.mjs +10 -4
- package/dist/region-lowering.mjs +90 -28
- package/dist/role-vocabulary.d.mts +3 -0
- package/dist/role-vocabulary.mjs +3 -0
- package/dist/showcase/client.bundle.js +25 -25
- package/dist/showcase/http-client.bundle.js +4 -4
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +4 -4
- package/dist/skills/ads-designer/references/recipes.md +16 -2
- package/dist/skills/ads-import/references/recipes.md +16 -2
- package/dist/skills/ads-migrate/SKILL.md +1 -0
- package/dist/skills/ads-migrate/references/0.5.3-to-0.5.4.md +42 -0
- package/dist/skills/ads-port/references/recipes.md +16 -2
- package/docs/CACHING.md +1 -1
- package/docs/CHANGELOG.md +72 -19
- package/docs/LANGUAGE.md +28 -5
- package/docs/MOTION.md +11 -1
- package/docs/PROFILE-KINDS.md +10 -5
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { SyntaxKind, isExportAssignment, isExportDeclaration, isImportDeclaration } from "typescript/ast";
|
|
3
3
|
import { digest } from "../digest.mjs";
|
|
4
4
|
import { memoProgram } from "./context.mjs";
|
|
5
|
-
export const OWNER_ANALYSIS_SCHEMA = "ads-owner-analysis/
|
|
5
|
+
export const OWNER_ANALYSIS_SCHEMA = "ads-owner-analysis/13";
|
|
6
6
|
export function canonical(value) {
|
|
7
7
|
return JSON.stringify(value, (_key, item) => {
|
|
8
8
|
if (item instanceof Map)
|
|
@@ -304,6 +304,8 @@ export async function choiceValues({ program, source, root, validateSpec, fail }
|
|
|
304
304
|
const declared = await type(declaration.name), finite = finiteType(declared);
|
|
305
305
|
if (finite !== null)
|
|
306
306
|
return finite.length > 1;
|
|
307
|
+
if (textDomain(declared) !== null)
|
|
308
|
+
return !0;
|
|
307
309
|
const presence = presenceDomain(declared);
|
|
308
310
|
return presence !== null && presence.opaque && presence.classes.length > 1;
|
|
309
311
|
}
|
|
@@ -532,6 +532,16 @@ export async function compositionFacts(inputs) {
|
|
|
532
532
|
return selected === null ? [] : [{ name: selected.frame, padding: selected.padding }];
|
|
533
533
|
}), frame = framed === null ? void 0 : { name: framed.frame, padding: framed.padding, ...stated.length === 0 ? {} : { states: stated } }, keyline = own?.kind === "grid" ? gridKeylineOf(foundation, own) ?? void 0 : void 0, scope = String(node.getStart(source));
|
|
534
534
|
let surfaces = [], text = null, flow = overlay ? "overlay" : "in", parts = null, grid = null, ownScope = null;
|
|
535
|
+
const pseudoOf = (treatments, treatmentPath, treatmentCalls, textFields) => treatments.flatMap((treatment) => {
|
|
536
|
+
if (treatment.pseudo !== "marker" && treatment.pseudo !== "before" || treatment.surface === null)
|
|
537
|
+
return [];
|
|
538
|
+
const surfacesOf = [
|
|
539
|
+
{ condition: null, surface: treatment.surface, at: at(treatmentCalls, `${treatmentPath}.pseudo.${treatment.pseudo}.surface`, node) },
|
|
540
|
+
...treatment.when.map(([condition, surface]) => ({ condition, surface, at: at(treatmentCalls, `${treatmentPath}.pseudo.${treatment.pseudo}.when.${condition}.surface`, node) }))
|
|
541
|
+
];
|
|
542
|
+
return [{ name: treatment.pseudo, surfaces: surfacesOf, text: textFields, graphic: treatment.pseudo === "marker" && treatment.content === null }];
|
|
543
|
+
});
|
|
544
|
+
let pseudo = [];
|
|
535
545
|
if (part !== null && parent?.parts !== null && parent?.parts !== void 0) {
|
|
536
546
|
const { spec, prefix, calls: partCalls } = parent.parts, partPath = `${prefix}.${part.name}`;
|
|
537
547
|
if (part.surface !== null)
|
|
@@ -539,6 +549,7 @@ export async function compositionFacts(inputs) {
|
|
|
539
549
|
for (const [condition, surface] of part.when)
|
|
540
550
|
surfaces.push({ condition, surface, at: at(partCalls, `${partPath}.when.${condition}.surface`, node) });
|
|
541
551
|
text = textOf(spec, part.name);
|
|
552
|
+
pseudo = pseudoOf(part.pseudo, partPath, partCalls, text);
|
|
542
553
|
parts = part.parts.length === 0 ? null : { spec, list: part.parts, prefix: `${partPath}.parts`, calls: partCalls, scope: parent.parts.scope };
|
|
543
554
|
ownScope = parent.parts.scope;
|
|
544
555
|
}
|
|
@@ -558,6 +569,7 @@ export async function compositionFacts(inputs) {
|
|
|
558
569
|
rootSurfaces.push({ condition, surface, at: at(calls, `recipe.when.${condition}.surface`, node) });
|
|
559
570
|
if (own.layer !== null)
|
|
560
571
|
flow = "layer";
|
|
572
|
+
pseudo = [...pseudo, ...pseudoOf(own.pseudo, "recipe", calls, textOf(own, "&"))];
|
|
561
573
|
parts = own.parts.length === 0 ? null : { spec: own, list: own.parts, prefix: "recipe.parts", calls, scope };
|
|
562
574
|
break;
|
|
563
575
|
}
|
|
@@ -575,7 +587,7 @@ export async function compositionFacts(inputs) {
|
|
|
575
587
|
}
|
|
576
588
|
text = textOf(own, "&") ?? text;
|
|
577
589
|
}
|
|
578
|
-
return { surfaces, text, scope: surfaces.length === 0 ? null : ownScope, flow, parts, grid, frame, keyline };
|
|
590
|
+
return { surfaces, text, scope: surfaces.length === 0 ? null : ownScope, flow, parts, grid, frame, keyline, ...pseudo.length === 0 ? {} : { pseudo } };
|
|
579
591
|
}
|
|
580
592
|
function chainElements(raws) {
|
|
581
593
|
const elements = [];
|
|
@@ -599,6 +611,7 @@ export async function compositionFacts(inputs) {
|
|
|
599
611
|
context: raw.context,
|
|
600
612
|
exempt: raw.exempt,
|
|
601
613
|
...role.frame === void 0 ? {} : { frame: role.frame },
|
|
614
|
+
...role.pseudo === void 0 ? {} : { pseudo: role.pseudo },
|
|
602
615
|
...role.keyline === void 0 ? {} : { keyline: role.keyline }
|
|
603
616
|
});
|
|
604
617
|
parent = role;
|
|
@@ -81,7 +81,7 @@ import {
|
|
|
81
81
|
elementTags,
|
|
82
82
|
parseConstruction,
|
|
83
83
|
CONTROL_TEXT_TAGS,
|
|
84
|
-
|
|
84
|
+
pseudoHosted,
|
|
85
85
|
VECTOR_SHAPES
|
|
86
86
|
} from "../construction-spec.mjs";
|
|
87
87
|
import { recipeDefaults, visualBindingRedundancy } from "../recipe-defaults.mjs";
|
|
@@ -889,14 +889,16 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
|
|
|
889
889
|
hidden.push(within.length === 0 ? { kind: "part", selector } : { kind: "part", selector, within });
|
|
890
890
|
}, parts = declaredParts(parsed.value), declaredMarkers = new Set([...parts.map((part) => part.selector.slice(1)), ...declaredCells(parsed.value).map((cell) => cell.slice(1))]);
|
|
891
891
|
if (parsed.value.kind === "region") {
|
|
892
|
-
const region = parsed.value;
|
|
892
|
+
const region = parsed.value, rootTag = values.tag(opening), rootless = region.pseudo.find((treatment) => !pseudoHosted(treatment.pseudo, rootTag));
|
|
893
|
+
if (rootless !== void 0)
|
|
894
|
+
return fail(opening, { kind: "pseudo-host-unsupported", part: "&", pseudo: rootless.pseudo, element: rootTag });
|
|
893
895
|
await nativeElement(opening, region.element, "&", null, context, resolve);
|
|
894
896
|
if (region.normalize.some(([property, value]) => property === "pointer-events" && value === "none"))
|
|
895
897
|
await pointerTransparent(opening, "&", context, resolve);
|
|
896
898
|
if (region.overflow.kind === "scroll")
|
|
897
899
|
scrollReview(opening, "&", node);
|
|
898
900
|
}
|
|
899
|
-
const matched = new Map([["", opening]]), tinted = new Set(parsed.value.kind === "region" ? surfacedElements(foundation, parsed.value).flatMap((element) => element.visual && (element.surface !== null || element.when.length > 0) ? [element.element] : []) : []), decorative = new Set;
|
|
901
|
+
const matched = new Map([["", opening]]), tinted = new Set(parsed.value.kind === "region" ? surfacedElements(foundation, parsed.value).flatMap((element) => element.visual && (element.surface !== null || element.when.length > 0) ? [element.element] : []) : []), decorative = new Set, margined = new Set;
|
|
900
902
|
let schemed = !1;
|
|
901
903
|
for (const part of parts) {
|
|
902
904
|
if (!/^\.[\w-]+$/.test(part.selector))
|
|
@@ -931,7 +933,10 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
|
|
|
931
933
|
const ariaHidden = attr(match.opening, "aria-hidden");
|
|
932
934
|
if (tinted.has(part.name) && ariaHidden !== void 0 && (ariaHidden.initializer === void 0 || [!0, "true"].includes(await resolve(expression(ariaHidden), context))))
|
|
933
935
|
decorative.add(part.name);
|
|
934
|
-
const element = values.tag(match.opening)
|
|
936
|
+
const element = values.tag(match.opening);
|
|
937
|
+
if (UA_MARGIN_TAGS.includes(element))
|
|
938
|
+
margined.add([...part.within, part.selector].join(" "));
|
|
939
|
+
const hostless = part.pseudo.find((pseudo) => !pseudoHosted(pseudo, element));
|
|
935
940
|
if (hostless !== void 0)
|
|
936
941
|
return fail(match.opening, { kind: "pseudo-host-unsupported", part: part.name, pseudo: hostless, element });
|
|
937
942
|
await nativeElement(match.opening, part.element, part.name, parent, context, resolve);
|
|
@@ -1115,13 +1120,14 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
|
|
|
1115
1120
|
...aligned.size > 0 ? [[...aligned]] : [],
|
|
1116
1121
|
...writesInline ? [scope] : [],
|
|
1117
1122
|
...decorative.size > 0 ? [["decorative", ...decorative]] : [],
|
|
1123
|
+
...margined.size > 0 ? [["margined", ...[...margined].sort()]] : [],
|
|
1118
1124
|
...visuals.size > 1 ? [[...visuals].map(([name, { fact, drawings: drawn }]) => fact.kind === "asset" ? [name, drawn, fact.state, fact.visualProfile, fact.theme.name] : [name, fact.kind])] : []
|
|
1119
1125
|
], paintedBy = (element) => parsed.value.kind === "control" ? hasText ? "text" : "graphic" : element.visual ? decorative.has(element.element) ? "decorative" : "graphic" : "text", key = constructionId(digest(hidden.length > 0 ? [...identity, hidden] : identity));
|
|
1120
1126
|
let owned = styles.get(key);
|
|
1121
1127
|
if (owned === void 0) {
|
|
1122
1128
|
if (styles.size >= choiceLimits.alternatives)
|
|
1123
1129
|
return fail(node, { kind: "choice", problem: { kind: "construction-limit" } });
|
|
1124
|
-
const rootName = `owner_${key.slice(0, 16)}`, input = { visual: visual ?? null, visuals: new Map([...visuals].map(([name, { fact }]) => [name, fact])), hasText, hidden, inherited, aligned, scope }, spec = parsed.value, built = await memoizedConstruction(options.constructions, foundation, [key, scope, drawnRecords(input, root)], (read) => {
|
|
1130
|
+
const rootName = `owner_${key.slice(0, 16)}`, input = { visual: visual ?? null, visuals: new Map([...visuals].map(([name, { fact }]) => [name, fact])), hasText, hidden, inherited, aligned, scope, margined: [...margined].sort() }, spec = parsed.value, built = await memoizedConstruction(options.constructions, foundation, [key, scope, drawnRecords(input, root)], (read) => {
|
|
1125
1131
|
const reviews = [], failed = (failure, at = null) => ({ kind: "failed", failure: { path: at, item: failure }, reviews }), lowered = lower(spec, read, rootName, input);
|
|
1126
1132
|
if (lowered.kind === "err")
|
|
1127
1133
|
return failed(lowered.error);
|
|
@@ -1481,6 +1487,7 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
|
|
|
1481
1487
|
}), artwork = { assets: [...boundAssets].sort(), sets: [...boundSets].sort(), glyphs: macros.glyphs, support: macros.support, uses };
|
|
1482
1488
|
return { source, values, selections, styles, edits, assetEdits, imports, coverage: { constructions: styles.size, coveredLeaves }, publicRows, controls: ownerControls(selections.flatMap((selection) => selection.result.axes)), reviews, artwork, design: ownerDesign([...styles.values()].flatMap((construction) => construction.profiles)) };
|
|
1483
1489
|
}
|
|
1490
|
+
const UA_MARGIN_TAGS = ["p", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "ol", "dl", "dd", "blockquote", "figure", "pre", "hr", "menu"];
|
|
1484
1491
|
function drawnRecords(input, root) {
|
|
1485
1492
|
return [input.visual, ...input.visuals.values()].map((fact) => fact !== null && fact.kind === "asset" ? designValueDigest(fact.asset, root) : null);
|
|
1486
1493
|
}
|
|
@@ -1499,7 +1506,7 @@ function lower(spec, foundation, root, input) {
|
|
|
1499
1506
|
hidden: input.hidden
|
|
1500
1507
|
});
|
|
1501
1508
|
case "region":
|
|
1502
|
-
return lowerRegion(spec, foundation, { root, visual: input.visual, visuals: input.visuals, hidden: input.hidden, scope: input.scope });
|
|
1509
|
+
return lowerRegion(spec, foundation, { root, visual: input.visual, visuals: input.visuals, hidden: input.hidden, scope: input.scope, ...input.margined.length === 0 ? {} : { margined: input.margined } });
|
|
1503
1510
|
case "grid":
|
|
1504
1511
|
return lowerGrid(spec, foundation, { root, hidden: input.hidden, inherited: input.inherited, aligned: input.aligned, scope: input.scope });
|
|
1505
1512
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { selectedProfile, tokenDefinitionContexts } from "./design-foundation.mjs";
|
|
2
|
-
import { inactiveCondition, layeredBackdrop, layeredContrast, opaque, readColor, unshown } from "./paint-contrast.mjs";
|
|
2
|
+
import { inactiveCondition, layeredBackdrop, layeredContrast, NON_TEXT_MINIMUM, opaque, readColor, unshown } from "./paint-contrast.mjs";
|
|
3
3
|
import { describeUnresolved, textMinimum } from "./surface-contrast.mjs";
|
|
4
4
|
import { sectionsDeclared } from "./token-sections.mjs";
|
|
5
5
|
export const NO_COMPOSITION = { positions: [] }, compositionLimits = Object.freeze({ chains: 512, hops: 24, backdrops: 256 });
|
|
@@ -157,7 +157,7 @@ export function composedContrastFindings(inputs) {
|
|
|
157
157
|
}
|
|
158
158
|
return [...distinct.values()];
|
|
159
159
|
}, argsOf = (placement) => placement.content.kind === "placement" && placement.content.spread === null ? placement.content.args : null, origin = (start, certain, run) => {
|
|
160
|
-
const seen = new Set;
|
|
160
|
+
const seen = new Set, reached = new Set;
|
|
161
161
|
let walks = 0, limited = !1;
|
|
162
162
|
run({
|
|
163
163
|
emit: (walk, top) => {
|
|
@@ -175,7 +175,13 @@ export function composedContrastFindings(inputs) {
|
|
|
175
175
|
if (limited)
|
|
176
176
|
note(source(start), `its compositions exceed ${compositionLimits.chains} distinct chains`, FIRST, walk.related);
|
|
177
177
|
},
|
|
178
|
-
limited: () => limited
|
|
178
|
+
limited: () => limited,
|
|
179
|
+
first: (state) => {
|
|
180
|
+
if (reached.has(state))
|
|
181
|
+
return !1;
|
|
182
|
+
reached.add(state);
|
|
183
|
+
return !0;
|
|
184
|
+
}
|
|
179
185
|
});
|
|
180
186
|
}, relatedOf = (point, message) => ({ site: source(point), message }), boundaryAt = (at, component, reason) => ({
|
|
181
187
|
owner: at.file,
|
|
@@ -266,6 +272,8 @@ export function composedContrastFindings(inputs) {
|
|
|
266
272
|
}
|
|
267
273
|
function ascend(frame, walk, mode, steps) {
|
|
268
274
|
const key = componentKey(frame.owner, frame.component);
|
|
275
|
+
if (!steps.first(JSON.stringify([key, frame.props, mode, evaluationKey(walk.elements), [...walk.recursed ?? []].sort()])))
|
|
276
|
+
return;
|
|
269
277
|
if (mode === "data")
|
|
270
278
|
for (const { owner, position } of placementsOf.get(key) ?? []) {
|
|
271
279
|
if (!consistent(argsOf(position), frame.props))
|
|
@@ -353,7 +361,18 @@ export function composedContrastFindings(inputs) {
|
|
|
353
361
|
}
|
|
354
362
|
}
|
|
355
363
|
}
|
|
356
|
-
const contextLabel = (index) => ({ index, label: nameOf(contexts[index]) }), stateOf = (key) => key === null ? null : key.slice(key.lastIndexOf("\x00") + 1);
|
|
364
|
+
const contextLabel = (index) => ({ index, label: nameOf(contexts[index]) }), stateOf = (key) => key === null ? null : key.slice(key.lastIndexOf("\x00") + 1), derived = new Set(chains.map(({ key }) => key));
|
|
365
|
+
for (const { key, chain } of chains.slice())
|
|
366
|
+
chain.elements.forEach((placed, index) => {
|
|
367
|
+
for (const pseudo of placed.fact.pseudo ?? []) {
|
|
368
|
+
const elements = [{ owner: placed.owner, component: placed.component, fact: { ...placed.fact, tag: `::${pseudo.name}`, surfaces: pseudo.surfaces, text: pseudo.text ?? placed.fact.text, pseudo: [] } }, ...chain.elements.slice(index)], derivedKey = JSON.stringify([chain.certain, pseudo.graphic, evaluationKey(elements)]);
|
|
369
|
+
if (derived.has(derivedKey))
|
|
370
|
+
continue;
|
|
371
|
+
derived.add(derivedKey);
|
|
372
|
+
chains.push({ key: derivedKey, chain: { elements, certain: chain.certain, graphic: pseudo.graphic } });
|
|
373
|
+
chainRelated.set(derivedKey, chainRelated.get(key) ?? new Map);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
357
376
|
for (const { key, chain } of chains)
|
|
358
377
|
evaluateChain(chain, [...chainRelated.get(key)?.values() ?? []]);
|
|
359
378
|
function conditionKey(placed, condition) {
|
|
@@ -423,7 +442,7 @@ export function composedContrastFindings(inputs) {
|
|
|
423
442
|
note(siteOf(placed, layer.state.at), describeUnresolved(backdrop.unresolved), contextLabel(index), related);
|
|
424
443
|
continue;
|
|
425
444
|
}
|
|
426
|
-
const minimum = textMinimum(text, context), outcome = layeredContrast(context, value, backdrop.colors, minimum), foreElement = elements[f.element];
|
|
445
|
+
const minimum = chain.graphic === !0 ? NON_TEXT_MINIMUM : textMinimum(text, context), outcome = layeredContrast(context, value, backdrop.colors, minimum), foreElement = elements[f.element];
|
|
427
446
|
if (foreElement === void 0)
|
|
428
447
|
continue;
|
|
429
448
|
switch (outcome.kind) {
|
|
@@ -202,16 +202,18 @@ export function writeEnter(out, profile, selector, enter, base, states, slots, t
|
|
|
202
202
|
out.rule(rule.selector, { ...rule.values }, rule.condition ?? void 0);
|
|
203
203
|
return { group: lowered.value.group, blurred: lowered.value.blurred };
|
|
204
204
|
}
|
|
205
|
-
export const STATE_TEXT_PROPERTIES = ["font-weight", "letter-spacing"];
|
|
205
|
+
export const STATE_TEXT_PROPERTIES = ["font-weight", "letter-spacing", "text-decoration-color", "text-decoration-thickness", "text-underline-offset"];
|
|
206
|
+
const STATE_TEXT_INITIAL = { "text-decoration-color": "currentcolor", "text-decoration-thickness": "auto", "text-underline-offset": "auto" };
|
|
206
207
|
export function writeStateText(out, profile, element, base, texts, selector, reject) {
|
|
207
208
|
for (const { condition, text } of texts) {
|
|
208
|
-
|
|
209
|
+
const fields = profile.of(text, "text"), changed = [...new Set([...Object.keys(base), ...Object.keys(fields)])].filter((property) => base[property] !== fields[property]);
|
|
210
|
+
if (base["font-size"] === void 0 && changed.some((property) => property === "font-weight" || property === "letter-spacing"))
|
|
209
211
|
return reject({ kind: "state-text-unbound", element, profile: text });
|
|
210
|
-
const
|
|
212
|
+
const moved = changed.find((property) => !STATE_TEXT_PROPERTIES.includes(property));
|
|
211
213
|
if (moved !== void 0)
|
|
212
214
|
return reject({ kind: "state-text-field", element, profile: text, property: moved });
|
|
213
215
|
if (changed.length > 0)
|
|
214
|
-
out.rule(selector(condition), Object.fromEntries(changed.map((property) => [property, fields[property] ?? "normal"])));
|
|
216
|
+
out.rule(selector(condition), Object.fromEntries(changed.map((property) => [property, fields[property] ?? STATE_TEXT_INITIAL[property] ?? "normal"])));
|
|
215
217
|
}
|
|
216
218
|
}
|
|
217
219
|
export function writePlays(out, profile, foundation, element, plays, selector, taken, reject) {
|
|
@@ -113,7 +113,7 @@ export interface RootPressState {
|
|
|
113
113
|
readonly path: string;
|
|
114
114
|
}
|
|
115
115
|
/** The paints a surface treatment can transition, as CSS transition properties. */
|
|
116
|
-
export declare const PAINT_CHANNELS: readonly ["background-color", "border-color", "color", "box-shadow", "filter", "backdrop-filter", "opacity"];
|
|
116
|
+
export declare const PAINT_CHANNELS: readonly ["background-color", "border-color", "color", "text-decoration-color", "box-shadow", "filter", "backdrop-filter", "opacity"];
|
|
117
117
|
export type PaintChannel = (typeof PAINT_CHANNELS)[number];
|
|
118
118
|
/** The motion profile that times a transition: the nearest recipe's motion slot, or a named motion profile. */
|
|
119
119
|
export type MotionBinding = {
|
|
@@ -226,16 +226,60 @@ export interface PaintTransition {
|
|
|
226
226
|
* textarea (a colour). `progressValue` is the filled part of a `<progress>` (a background): the part's own
|
|
227
227
|
* surface is its track.
|
|
228
228
|
*/
|
|
229
|
-
export declare const PSEUDO_ELEMENTS: readonly ["placeholder", "progressValue"];
|
|
229
|
+
export declare const PSEUDO_ELEMENTS: readonly ["placeholder", "progressValue", "marker", "before"];
|
|
230
230
|
export type PseudoElement = (typeof PSEUDO_ELEMENTS)[number];
|
|
231
|
-
/**
|
|
231
|
+
/** Elements that never render generated content or a marker: a `before` treatment there would never show. */
|
|
232
|
+
export declare const REPLACED_ELEMENTS: readonly string[];
|
|
233
|
+
/**
|
|
234
|
+
* The elements that have each pseudo-element: a treatment on any other element would never match. A list item's
|
|
235
|
+
* marker is on `li` and `summary` (a disclosure's marker); `before` is on any element that is not replaced.
|
|
236
|
+
*/
|
|
232
237
|
export declare const PSEUDO_HOSTS: {
|
|
233
|
-
readonly [P in PseudoElement]: readonly string[];
|
|
238
|
+
readonly [P in PseudoElement]: readonly string[] | "non-replaced";
|
|
234
239
|
};
|
|
235
|
-
/**
|
|
240
|
+
/** Whether `element` has the pseudo-element `pseudo`. */
|
|
241
|
+
export declare const pseudoHosted: (pseudo: PseudoElement, element: string) => boolean;
|
|
242
|
+
/** The number systems a marker or a counter is written in, and the bullet shapes. */
|
|
243
|
+
export declare const MARKER_STYLES: readonly ["disc", "circle", "square", "none", "decimal", "decimal-leading-zero", "lower-alpha", "upper-alpha", "lower-roman", "upper-roman"];
|
|
244
|
+
export type MarkerStyle = (typeof MARKER_STYLES)[number];
|
|
245
|
+
/** The number systems a counter's generated content may use. */
|
|
246
|
+
export declare const COUNTER_STYLES: readonly ["decimal", "decimal-leading-zero", "lower-alpha", "upper-alpha", "lower-roman", "upper-roman"];
|
|
247
|
+
export type CounterStyle = (typeof COUNTER_STYLES)[number];
|
|
248
|
+
/**
|
|
249
|
+
* Generated content a marker or a `before` pseudo-element shows: a counter's value (`counter`), or every level of
|
|
250
|
+
* a nested counter joined by `separator` (`counters`: 1.1.2), in a number system, between short literals.
|
|
251
|
+
*/
|
|
252
|
+
export interface GeneratedContent {
|
|
253
|
+
readonly kind: "counter" | "counters";
|
|
254
|
+
readonly name: string;
|
|
255
|
+
readonly style: CounterStyle;
|
|
256
|
+
readonly separator: string;
|
|
257
|
+
readonly prefix: string;
|
|
258
|
+
readonly suffix: string;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* A rule between an element's consecutive children (`between: { surface, frame }`): the frame profile's border width
|
|
262
|
+
* and style, painted by the surface's `border-color`, before every child but the first, on the arrangement's axis (a
|
|
263
|
+
* hairline between table rows or settings rows, none after the last).
|
|
264
|
+
*/
|
|
265
|
+
export interface BetweenRule {
|
|
266
|
+
readonly surface: string;
|
|
267
|
+
readonly frame: string;
|
|
268
|
+
}
|
|
269
|
+
/** An element's counters (`counter-reset`, `counter-increment`): where a count starts and what it counts. */
|
|
270
|
+
export interface CounterSpec {
|
|
271
|
+
readonly reset: string | null;
|
|
272
|
+
readonly increment: string | null;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* A pseudo-element's treatment: a colour-only surface (with owner-state treatments) for a placeholder, a progress
|
|
276
|
+
* fill or a marker; a marker's or generated content's weight and numerals (`text`); generated content.
|
|
277
|
+
*/
|
|
236
278
|
export interface PseudoTreatment {
|
|
237
279
|
readonly pseudo: PseudoElement;
|
|
238
|
-
readonly surface: string;
|
|
280
|
+
readonly surface: string | null;
|
|
281
|
+
readonly text: string | null;
|
|
282
|
+
readonly content: GeneratedContent | null;
|
|
239
283
|
readonly when: readonly StateTreatment[];
|
|
240
284
|
}
|
|
241
285
|
export type ControlSpec = ControlCommon & ({
|
|
@@ -661,6 +705,11 @@ export interface RegionPart {
|
|
|
661
705
|
*/
|
|
662
706
|
readonly spaceBefore: SlotBinding | null;
|
|
663
707
|
readonly spaceAfter: SlotBinding | null;
|
|
708
|
+
/**
|
|
709
|
+
* The part's own spacing profile: its `spaceBefore` and `spaceAfter` fields are the part's space before and after
|
|
710
|
+
* it, where a flow needs more distances than one spacing profile's fields (a heading 44 px above, 14 px below).
|
|
711
|
+
*/
|
|
712
|
+
readonly spacing: string | null;
|
|
664
713
|
readonly content: PartContent;
|
|
665
714
|
readonly textEdge: readonly string[];
|
|
666
715
|
readonly textLayout: TextLayout;
|
|
@@ -702,6 +751,15 @@ export interface RegionPart {
|
|
|
702
751
|
readonly sticky: StickySpec | null;
|
|
703
752
|
/** Treatments of the part's pseudo-elements, at most one per pseudo-element. */
|
|
704
753
|
readonly pseudo: readonly PseudoTreatment[];
|
|
754
|
+
/** Where a count starts (`counter-reset`) and what the part counts (`counter-increment`). */
|
|
755
|
+
readonly counter: CounterSpec | null;
|
|
756
|
+
/** A rule between the part's consecutive children (a table body's rows). */
|
|
757
|
+
readonly between: BetweenRule | null;
|
|
758
|
+
/**
|
|
759
|
+
* `presence: "assistive"`: the part is hidden on screen and still read by assistive technology (a table's caption, a
|
|
760
|
+
* skip link's text, an icon-only control's label); `"visible"` otherwise.
|
|
761
|
+
*/
|
|
762
|
+
readonly presence: "visible" | "assistive";
|
|
705
763
|
/** A nested recipe arranging this part's children. */
|
|
706
764
|
readonly arrangement: Arrangement | null;
|
|
707
765
|
readonly parts: readonly RegionPart[];
|
|
@@ -762,6 +820,14 @@ export interface Backdrop {
|
|
|
762
820
|
export interface RegionSpec {
|
|
763
821
|
readonly kind: "region";
|
|
764
822
|
readonly source: JsonObject;
|
|
823
|
+
/** The root's own pseudo-elements: a list item's marker, generated content before the root. */
|
|
824
|
+
readonly pseudo: readonly PseudoTreatment[];
|
|
825
|
+
/** Where a count starts on the root and what the root counts. */
|
|
826
|
+
readonly counter: CounterSpec | null;
|
|
827
|
+
/** A list's marker style at each nesting depth, outermost first. */
|
|
828
|
+
readonly markers: readonly MarkerStyle[];
|
|
829
|
+
/** A rule between the root's consecutive children. */
|
|
830
|
+
readonly between: BetweenRule | null;
|
|
765
831
|
/** `null` for a treatment fragment without a profile. */
|
|
766
832
|
readonly profile: string | null;
|
|
767
833
|
readonly select: Readonly<Record<string, string>>;
|
|
@@ -2,14 +2,17 @@ import { attempt } from "./result.mjs";
|
|
|
2
2
|
import { COLOR_SCHEMES } from "./scheme-switch.mjs";
|
|
3
3
|
import { isJsonObject, isRecord } from "./json.mjs";
|
|
4
4
|
import { conditionParts, parseStateCondition } from "./state-conditions.mjs";
|
|
5
|
-
export const ACCESSIBILITY_BOUNDARIES = ["visible-label", "boundary-on-interaction"], REASON_LENGTH = { min: 20, max: 300 }, PAINT_CHANNELS = ["background-color", "border-color", "color", "box-shadow", "filter", "backdrop-filter", "opacity"], PART_EFFECTS = {
|
|
5
|
+
export const ACCESSIBILITY_BOUNDARIES = ["visible-label", "boundary-on-interaction"], REASON_LENGTH = { min: 20, max: 300 }, PAINT_CHANNELS = ["background-color", "border-color", "color", "text-decoration-color", "box-shadow", "filter", "backdrop-filter", "opacity"], PART_EFFECTS = {
|
|
6
6
|
scale: { channel: "scale", field: "scale" },
|
|
7
7
|
scaleInline: { channel: "scale", field: "scale" },
|
|
8
8
|
scaleBlock: { channel: "scale", field: "scale" },
|
|
9
9
|
translateInline: { channel: "translate", field: "distance" },
|
|
10
10
|
translateBlock: { channel: "translate", field: "distance" },
|
|
11
11
|
rotate: { channel: "rotate", field: "angle" }
|
|
12
|
-
}, scaleValue = (effect, value) => effect === "scale" ? value : effect === "scaleInline" || effect === "scale-inline" ? `${value} 1` : `1 ${value}`, STICKY_EDGES = ["block-start", "block-end"], ENTER_MOVEMENTS = { translate: "distance", translateInline: "distance", scale: "scale", rotate: "angle" }, PSEUDO_ELEMENTS = ["placeholder", "progressValue"
|
|
12
|
+
}, scaleValue = (effect, value) => effect === "scale" ? value : effect === "scaleInline" || effect === "scale-inline" ? `${value} 1` : `1 ${value}`, STICKY_EDGES = ["block-start", "block-end"], ENTER_MOVEMENTS = { translate: "distance", translateInline: "distance", scale: "scale", rotate: "angle" }, PSEUDO_ELEMENTS = ["placeholder", "progressValue", "marker", "before"], 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 = {
|
|
13
16
|
"start-start": "start-start-radius",
|
|
14
17
|
"start-end": "start-end-radius",
|
|
15
18
|
"end-start": "end-start-radius",
|
|
@@ -593,13 +596,79 @@ function enterSpec(value, path, read) {
|
|
|
593
596
|
read.slotless(motion, `${path}.motion`, "motion");
|
|
594
597
|
return { driver: { kind: "first-render" }, surface, movement, motion: { kind: "slot" }, path };
|
|
595
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
|
+
}
|
|
596
660
|
function pseudoTreatments(value, path, read) {
|
|
597
661
|
if (value === void 0)
|
|
598
662
|
return [];
|
|
599
663
|
return Object.entries(read.object(value, path)).map(([name, treatment]) => {
|
|
600
|
-
const at = `${path}.${name}`, pseudo = read.literal(name, at, PSEUDO_ELEMENTS), fields = read.object(treatment, at);
|
|
601
|
-
read.only(fields, at, ["surface", "when"]);
|
|
602
|
-
|
|
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) };
|
|
603
672
|
});
|
|
604
673
|
}
|
|
605
674
|
function frameBorder(value, path, read) {
|
|
@@ -706,7 +775,7 @@ export function normalizedDeclarations(values) {
|
|
|
706
775
|
}
|
|
707
776
|
const isNormalizeField = (key) => Object.hasOwn(NORMALIZE_FIELDS, key);
|
|
708
777
|
export const INTERACTION_FIELDS = ["cursor", "touchAction", "userSelect"];
|
|
709
|
-
const PART_NORMALIZE = [...INTERACTION_FIELDS, "resize"], CONTROL_NORMALIZE = ["borderStyle", "textDecoration", ...INTERACTION_FIELDS], REGION_NORMALIZE = ["margin", "borderStyle", "textDecoration", "pointerEvents", ...INTERACTION_FIELDS];
|
|
778
|
+
const PART_NORMALIZE = [...INTERACTION_FIELDS, "resize", "margin"], CONTROL_NORMALIZE = ["borderStyle", "textDecoration", ...INTERACTION_FIELDS], REGION_NORMALIZE = ["margin", "borderStyle", "textDecoration", "pointerEvents", ...INTERACTION_FIELDS];
|
|
710
779
|
function normalizeValues(values, path, fields, read) {
|
|
711
780
|
read.only(values, path, fields);
|
|
712
781
|
return Object.entries(values).flatMap(([key, value]) => {
|
|
@@ -849,7 +918,7 @@ function partContent(part, path, read) {
|
|
|
849
918
|
return { kind };
|
|
850
919
|
case "component": {
|
|
851
920
|
for (const field of Object.keys(part))
|
|
852
|
-
if (!["kind", "selector", "required", "repeat", "extent", "at", "spaceBefore", "spaceAfter"].includes(field))
|
|
921
|
+
if (!["kind", "selector", "required", "repeat", "extent", "at", "spaceBefore", "spaceAfter", "spacing"].includes(field))
|
|
853
922
|
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.${field}` });
|
|
854
923
|
return { kind };
|
|
855
924
|
}
|
|
@@ -998,6 +1067,10 @@ function regionPart(name, value, read, path, nested) {
|
|
|
998
1067
|
"repeat",
|
|
999
1068
|
"spaceBefore",
|
|
1000
1069
|
"spaceAfter",
|
|
1070
|
+
"counter",
|
|
1071
|
+
"spacing",
|
|
1072
|
+
"between",
|
|
1073
|
+
"presence",
|
|
1001
1074
|
...VISUAL_BINDING_FIELDS,
|
|
1002
1075
|
...nested ? [] : ["measured", "paints"]
|
|
1003
1076
|
]);
|
|
@@ -1024,6 +1097,7 @@ function regionPart(name, value, read, path, nested) {
|
|
|
1024
1097
|
repeat: part.repeat === void 0 ? !1 : read.boolean(part.repeat, `${path}.repeat`),
|
|
1025
1098
|
spaceBefore: part.spaceBefore === void 0 ? null : read.slot(part.spaceBefore, `${path}.spaceBefore`, "spacing"),
|
|
1026
1099
|
spaceAfter: part.spaceAfter === void 0 ? null : read.slot(part.spaceAfter, `${path}.spaceAfter`, "spacing"),
|
|
1100
|
+
spacing: read.optionalString(part.spacing, `${path}.spacing`),
|
|
1027
1101
|
content,
|
|
1028
1102
|
textEdge: part.textEdge === void 0 ? [] : read.strings(part.textEdge, `${path}.textEdge`),
|
|
1029
1103
|
textLayout: textLayout(part, path, read),
|
|
@@ -1054,6 +1128,9 @@ function regionPart(name, value, read, path, nested) {
|
|
|
1054
1128
|
anchorClear: anchorClear(part.anchorClear, `${path}.anchorClear`, read),
|
|
1055
1129
|
scheme: partScheme(part, content, path, read),
|
|
1056
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"]),
|
|
1057
1134
|
arrangement: arranged,
|
|
1058
1135
|
parts: parseParts(part.parts, read, path, !0),
|
|
1059
1136
|
measured: measuredValues(part.measured, `${path}.measured`, read),
|
|
@@ -1162,6 +1239,10 @@ function region(authored, read) {
|
|
|
1162
1239
|
"sticky",
|
|
1163
1240
|
"play",
|
|
1164
1241
|
"at",
|
|
1242
|
+
"pseudo",
|
|
1243
|
+
"counter",
|
|
1244
|
+
"markers",
|
|
1245
|
+
"between",
|
|
1165
1246
|
"parts",
|
|
1166
1247
|
"exposeRows",
|
|
1167
1248
|
"layer",
|
|
@@ -1189,6 +1270,10 @@ function region(authored, read) {
|
|
|
1189
1270
|
return {
|
|
1190
1271
|
kind: "region",
|
|
1191
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),
|
|
1192
1277
|
profile: read.optionalString(spec.profile, "recipe.profile"),
|
|
1193
1278
|
select: Object.fromEntries(spec.select === void 0 ? [] : read.stringRecord(spec.select, "recipe.select")),
|
|
1194
1279
|
arrangement: arrangement(spec, read, "recipe", layout),
|
|
@@ -119,12 +119,12 @@ export function readFoundation(captured, contexts) {
|
|
|
119
119
|
for (const [field, value] of Object.entries(variant.fields)) {
|
|
120
120
|
if (field.startsWith("--")) {
|
|
121
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"] });
|
|
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
124
|
for (const token of references(value)) {
|
|
125
125
|
const role = tokens.get(token)?.role ?? null;
|
|
126
|
-
if (role !==
|
|
127
|
-
return reject({ kind: "token-role", profile: name, field, token, role, expected: [
|
|
126
|
+
if (role !== own)
|
|
127
|
+
return reject({ kind: "token-role", profile: name, field, token, role, expected: [own] });
|
|
128
128
|
}
|
|
129
129
|
continue;
|
|
130
130
|
}
|
|
@@ -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);
|
|
@@ -4,6 +4,7 @@ export const CHANNEL_FIELDS = {
|
|
|
4
4
|
"background-color": ["background"],
|
|
5
5
|
"border-color": ["border-color", "border-block-start-color", "border-block-end-color", "border-inline-start-color", "border-inline-end-color"],
|
|
6
6
|
color: ["color"],
|
|
7
|
+
"text-decoration-color": ["text-decoration-color"],
|
|
7
8
|
"box-shadow": ["box-shadow"],
|
|
8
9
|
opacity: ["opacity"],
|
|
9
10
|
filter: EFFECT_PROPERTY_FIELDS.filter,
|