@reqvire-org/ads 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ads-errors.mjs +143 -51
- package/dist/analysis/composition-axes.mjs +48 -0
- package/dist/analysis/construction-memo.mjs +38 -0
- package/dist/analysis/context.mjs +19 -0
- package/dist/analysis/design-reads.mjs +177 -0
- package/dist/analysis/design-usage.mjs +4 -20
- package/dist/analysis/factored-classes.mjs +90 -0
- package/dist/analysis/helpers.mjs +5 -7
- package/dist/analysis/mock-check.mjs +4 -5
- package/dist/analysis/native-project.mjs +12 -0
- package/dist/analysis/owner-accessibility.mjs +4 -4
- package/dist/analysis/owner-analysis-cache.mjs +86 -23
- package/dist/analysis/owner-analysis-key.mjs +42 -10
- package/dist/analysis/owner-choices.mjs +56 -7
- package/dist/analysis/owner-composition.mjs +179 -45
- package/dist/analysis/owner-reuse.mjs +8 -6
- package/dist/analysis/owner-source.mjs +304 -110
- package/dist/analysis/scenario-keys.mjs +10 -7
- package/dist/analysis/service.mjs +50 -3
- package/dist/analysis/standalone.mjs +7 -4
- package/dist/analysis/syntax.mjs +59 -1
- package/dist/analysis/worker-protocol.mjs +14 -2
- package/dist/analysis/worker.mjs +32 -10
- package/dist/architecture-report.mjs +26 -0
- package/dist/asset-view-facts.mjs +16 -2
- package/dist/boundaries.mjs +26 -10
- package/dist/bun-compiler.mjs +2 -2
- package/dist/check-service.mjs +29 -17
- package/dist/check.mjs +13 -6
- package/dist/cli.mjs +1 -1
- package/dist/composed-contrast.mjs +143 -62
- package/dist/composed-keyline.mjs +2 -2
- package/dist/config.mjs +2 -1
- package/dist/construction-output.mjs +9 -3
- package/dist/construction-spec.d.mts +145 -31
- package/dist/construction-spec.mjs +204 -74
- package/dist/corner-overpaint.mjs +20 -7
- package/dist/derived-states.mjs +182 -0
- package/dist/design-foundation.mjs +16 -0
- package/dist/design-inputs.mjs +18 -3
- package/dist/design-system-closure.mjs +12 -7
- package/dist/design-usage.mjs +2 -8
- package/dist/emit/contract.mjs +24 -5
- package/dist/emit/emission.mjs +6 -9
- package/dist/emit/integrity.mjs +8 -2
- package/dist/emit/output-watch.mjs +120 -0
- package/dist/emit/owner-emission-cache.mjs +4 -4
- package/dist/emit/preview-emitter.mjs +4 -2
- package/dist/emit/preview-tree.mjs +1 -1
- package/dist/emit/service.mjs +8 -2
- package/dist/finding-rules.mjs +3 -0
- package/dist/form-states.mjs +8 -0
- package/dist/frame-regions.mjs +29 -9
- package/dist/grid-lowering.mjs +3 -1
- package/dist/hover-geometry.mjs +15 -0
- package/dist/input-digests.mjs +17 -10
- package/dist/linaria/delivery.mjs +2 -0
- package/dist/lowering-enter.mjs +6 -6
- package/dist/lowering-properties.mjs +5 -0
- package/dist/lowering-region-layout.mjs +7 -2
- package/dist/lowering-session.mjs +10 -0
- package/dist/mcp/build-status.mjs +9 -1
- package/dist/mcp/compiler-channel.mjs +11 -4
- package/dist/mcp/mutations.mjs +1 -0
- package/dist/mcp/preview-http.bundle.js +1 -1
- package/dist/mcp/preview-watch.mjs +2 -1
- package/dist/mcp/preview-widget.bundle.js +1 -1
- package/dist/mcp/server-observation.mjs +6 -4
- package/dist/mcp/server-project.mjs +4 -1
- package/dist/motion-model.mjs +1 -1
- package/dist/owner-analysis-check.mjs +23 -6
- package/dist/owner-errors.mjs +6 -3
- package/dist/owner-lowering.mjs +78 -13
- package/dist/owner-scenarios.mjs +6 -23
- package/dist/ownership-model.mjs +24 -8
- package/dist/paint-contrast.mjs +6 -0
- package/dist/placeholder-contrast.mjs +17 -1
- package/dist/platform-features.mjs +10 -1
- package/dist/profile-macro.d.mts +7 -0
- package/dist/profile-view-facts.mjs +1 -1
- package/dist/recipe-macro.d.mts +103 -40
- package/dist/recipe-model.mjs +18 -13
- package/dist/region-lowering.mjs +266 -123
- package/dist/render-audit/layout-shift.page.mjs +24 -0
- package/dist/render-audit/render-states.mjs +122 -1
- package/dist/render-audit/render-states.page.mjs +140 -0
- package/dist/render-audit/worker.mjs +18 -3
- package/dist/render-audit.mjs +114 -1
- package/dist/role-vocabulary.d.mts +9 -0
- package/dist/role-vocabulary.mjs +16 -1
- package/dist/runtime-paint-contrast.mjs +5 -2
- package/dist/scenarios-compiler.mjs +20 -6
- package/dist/showcase/assets-view.mjs +29 -13
- package/dist/showcase/client.bundle.js +50 -50
- package/dist/showcase/http-client.bundle.js +15 -15
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +5 -5
- package/dist/skills/ads-designer/references/accessibility.md +10 -4
- package/dist/skills/ads-designer/references/branding.md +13 -3
- package/dist/skills/ads-designer/references/contracts.md +5 -2
- package/dist/skills/ads-designer/references/design-data.md +13 -7
- package/dist/skills/ads-designer/references/layout.md +12 -4
- package/dist/skills/ads-designer/references/motion.md +11 -2
- package/dist/skills/ads-designer/references/recipes.md +49 -15
- package/dist/skills/ads-import/references/contracts.md +5 -2
- package/dist/skills/ads-import/references/design-data.md +13 -7
- package/dist/skills/ads-import/references/layout.md +12 -4
- package/dist/skills/ads-import/references/recipes.md +49 -15
- package/dist/skills/ads-migrate/SKILL.md +2 -0
- package/dist/skills/ads-migrate/references/0.5.1-to-0.5.2.md +185 -0
- package/dist/skills/ads-migrate/references/0.5.2-to-0.5.3.md +71 -0
- package/dist/skills/ads-port/references/contracts.md +5 -2
- package/dist/skills/ads-port/references/design-data.md +13 -7
- package/dist/skills/ads-port/references/layout.md +12 -4
- package/dist/skills/ads-port/references/recipes.md +49 -15
- package/dist/spatial-model.mjs +2 -2
- package/dist/surface-contrast.mjs +7 -2
- package/dist/surface-effects.mjs +5 -3
- package/dist/target-size.mjs +21 -3
- package/dist/task-cache.mjs +8 -18
- package/dist/validation-checks.mjs +1 -1
- package/docs/ADS.md +9 -3
- package/docs/ARCHITECTURE.md +96 -30
- package/docs/CACHING.md +152 -24
- package/docs/CHANGELOG.md +307 -23
- package/docs/GUIDE.md +109 -20
- package/docs/LANGUAGE.md +262 -117
- package/docs/MCP.md +5 -1
- package/docs/MOTION.md +15 -4
- package/docs/PROFILE-KINDS.md +54 -4
- package/docs/RULES.md +34 -25
- package/docs/TOKEN-ROLES.md +7 -1
- package/package.json +1 -1
- package/dist/analysis/prose-owners.mjs +0 -57
- package/dist/prose-model.d.mts +0 -81
- package/dist/prose-model.mjs +0 -101
|
@@ -2,14 +2,19 @@ import { attempt } from "./result.mjs";
|
|
|
2
2
|
import { COLOR_SCHEMES } from "./scheme-switch.mjs";
|
|
3
3
|
import { isJsonObject, isRecord } from "./json.mjs";
|
|
4
4
|
import { conditionParts, parseStateCondition } from "./state-conditions.mjs";
|
|
5
|
-
import { PROSE_BLOCKS, PROSE_ELEMENT_NAMES } from "./prose-model.mjs";
|
|
6
5
|
export const ACCESSIBILITY_BOUNDARIES = ["visible-label", "boundary-on-interaction"], REASON_LENGTH = { min: 20, max: 300 }, PAINT_CHANNELS = ["background-color", "border-color", "color", "box-shadow", "filter", "backdrop-filter", "opacity"], PART_EFFECTS = {
|
|
7
6
|
scale: { channel: "scale", field: "scale" },
|
|
8
7
|
scaleInline: { channel: "scale", field: "scale" },
|
|
9
8
|
scaleBlock: { channel: "scale", field: "scale" },
|
|
10
9
|
translateInline: { channel: "translate", field: "distance" },
|
|
11
|
-
translateBlock: { channel: "translate", field: "distance" }
|
|
12
|
-
|
|
10
|
+
translateBlock: { channel: "translate", field: "distance" },
|
|
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"], PSEUDO_HOSTS = { placeholder: ["input", "textarea"], progressValue: ["progress"] }, SNAP_TYPES = ["inline mandatory", "inline proximity", "block mandatory", "block proximity", "both mandatory", "both proximity"], SNAP_ALIGNS = ["start", "center", "end"], GEOMETRY_CHANNELS = ["size", "inset", "gap", "radius", "border-width", "overlap"], FRAME_SIDES = ["block-start", "block-end", "inline-start", "inline-end"], FRAME_CORNERS = ["start-start", "start-end", "end-start", "end-end"], CORNER_RADIUS_FIELDS = {
|
|
13
|
+
"start-start": "start-start-radius",
|
|
14
|
+
"start-end": "start-end-radius",
|
|
15
|
+
"end-start": "end-start-radius",
|
|
16
|
+
"end-end": "end-end-radius"
|
|
17
|
+
}, cornerRadius = (field, corner) => field(CORNER_RADIUS_FIELDS[corner]) ?? field("radius"), OVERFLOW_VALUES = ["clip", "scroll-block", "scroll-inline", "scroll-both"], ELEMENT_NAMES = ["iframe", "select", "search-input", "text-input", "table", "header-cell", "cell", "list", "summary"], TEXT_WRAPS = ["anywhere", "never", "truncate", "balance", "pretty"], TEXT_ALIGNS = ["start", "center", "end"], MEASURED_TYPES = ["length", "transform", "size-track", "position", "intrinsic-size"], GRID_FIELDS = ["columns", "weights", "gutter", "margin", "bound", "rows", "context", "align"];
|
|
13
18
|
export function elementTags(element) {
|
|
14
19
|
switch (element.kind) {
|
|
15
20
|
case "iframe":
|
|
@@ -59,7 +64,7 @@ export function parseConstruction(spec) {
|
|
|
59
64
|
export function declaredParts(spec) {
|
|
60
65
|
switch (spec.kind) {
|
|
61
66
|
case "control":
|
|
62
|
-
return [spec.label, ...spec.glyph === null ? [] : [spec.glyph]].map((part) => ({ ...plainPart, name: part.name, path: `recipe.parts.${part.name}`, selector: part.selector, required: part.required, kind: part.kind })).sort((a, b) => partOrder(spec.source, a.name) - partOrder(spec.source, b.name));
|
|
67
|
+
return [...spec.label === null ? [] : [spec.label], ...spec.glyph === null ? [] : [spec.glyph], ...spec.decor].map((part) => ({ ...plainPart, name: part.name, path: `recipe.parts.${part.name}`, selector: part.selector, required: part.required, kind: part.kind === "box" ? "element" : part.kind })).sort((a, b) => partOrder(spec.source, a.name) - partOrder(spec.source, b.name));
|
|
63
68
|
case "artwork":
|
|
64
69
|
return [{ ...plainPart, name: spec.part.name, path: `recipe.parts.${spec.part.name}`, selector: spec.part.selector, required: spec.part.required, kind: "visual" }];
|
|
65
70
|
case "region":
|
|
@@ -68,12 +73,13 @@ export function declaredParts(spec) {
|
|
|
68
73
|
return [];
|
|
69
74
|
}
|
|
70
75
|
}
|
|
71
|
-
const plainPart = { within: [], pseudo: [], element: null, media: "bound", truncated: !1, clamped: !1, balanced: !1, scrolls: !1, declaresBoundary: !1, resizes: !1, playsAlways: [], scheme: null }, regionParts = (parts, within, parent) => parts.flatMap((part) => [
|
|
76
|
+
const plainPart = { repeat: !1, within: [], pseudo: [], element: null, media: "bound", truncated: !1, clamped: !1, balanced: !1, scrolls: !1, declaresBoundary: !1, resizes: !1, playsAlways: [], scheme: null }, regionParts = (parts, within, parent) => parts.flatMap((part) => [
|
|
72
77
|
{
|
|
73
78
|
name: part.name,
|
|
74
79
|
path: `${parent}.parts.${part.name}`,
|
|
75
80
|
selector: part.selector,
|
|
76
81
|
required: part.required,
|
|
82
|
+
repeat: part.repeat,
|
|
77
83
|
kind: part.content.kind,
|
|
78
84
|
within,
|
|
79
85
|
pseudo: part.pseudo.map((treatment) => treatment.pseudo),
|
|
@@ -209,9 +215,9 @@ function reader(construction, reject, partStates) {
|
|
|
209
215
|
}
|
|
210
216
|
function control(spec, read) {
|
|
211
217
|
read.only(spec, "recipe", ["layout", "profile", "align", "justify", "frame", "parts", "normalize", "select", "surface", "when", "transition", "paintTransition", "enter", "extent", "play", "text"]);
|
|
212
|
-
const normalized = normalization(spec.normalize, "recipe.normalize", CONTROL_NORMALIZE, INTERACTION_FIELDS, "state", read), rootStates = rootWhen(spec, read), parts = Object.entries(read.object(spec.parts, "recipe.parts")), texts = parts.filter(([, part]) => isRecord(part) && part.kind === "text"), visuals = parts.filter(([, part]) => isRecord(part) && part.kind === "visual"), [text] = texts, [visual] = visuals;
|
|
213
|
-
if (texts.length
|
|
214
|
-
return read.reject({ kind: "parts-unsupported", construction: "control", detail: "a control has one text part and
|
|
218
|
+
const normalized = normalization(spec.normalize, "recipe.normalize", CONTROL_NORMALIZE, INTERACTION_FIELDS, "state", read), rootStates = rootWhen(spec, read), parts = Object.entries(read.object(spec.parts, "recipe.parts")), texts = parts.filter(([, part]) => isRecord(part) && part.kind === "text"), visuals = parts.filter(([, part]) => isRecord(part) && part.kind === "visual"), boxes = parts.filter(([, part]) => isRecord(part) && part.kind === void 0), [text] = texts, [visual] = visuals;
|
|
219
|
+
if (texts.length > 1 || visuals.length > 1 || parts.length !== texts.length + visuals.length + boxes.length || parts.length === 0)
|
|
220
|
+
return read.reject({ kind: "parts-unsupported", construction: "control", detail: "a control has at most one text part and one visual part, and any decorative boxes (parts without a kind, each with `frame: { profile }`)" });
|
|
215
221
|
const common = {
|
|
216
222
|
kind: "control",
|
|
217
223
|
source: spec,
|
|
@@ -228,8 +234,9 @@ function control(spec, read) {
|
|
|
228
234
|
plays: rootStates.plays,
|
|
229
235
|
textWhen: rootStates.texts,
|
|
230
236
|
text: read.optionalString(spec.text, "recipe.text"),
|
|
231
|
-
label: textPart(text[0], text[1], read),
|
|
232
|
-
glyph: visual === void 0 ? null : glyphPart(visual[0], visual[1], read)
|
|
237
|
+
label: text === void 0 ? null : textPart(text[0], text[1], read),
|
|
238
|
+
glyph: visual === void 0 ? null : glyphPart(visual[0], visual[1], read),
|
|
239
|
+
decor: boxes.map(([name, part]) => decorPart(name, part, read))
|
|
233
240
|
};
|
|
234
241
|
if (spec.layout === void 0) {
|
|
235
242
|
for (const field of ["align", "justify"])
|
|
@@ -247,16 +254,47 @@ function control(spec, read) {
|
|
|
247
254
|
return { ...common, layout, align: read.string(spec.align, "recipe.align") };
|
|
248
255
|
}
|
|
249
256
|
}
|
|
257
|
+
function decorPart(name, value, read) {
|
|
258
|
+
const path = `recipe.parts.${name}`, part = read.object(value, path);
|
|
259
|
+
read.only(part, path, ["selector", "required", "frame", "surface", "when", "transition"]);
|
|
260
|
+
const frame = read.object(part.frame, `${path}.frame`);
|
|
261
|
+
read.only(frame, `${path}.frame`, ["profile"]);
|
|
262
|
+
const effectNames = ["scale", "scaleInline", "scaleBlock", "translateInline"], when = Object.entries(part.when === void 0 ? {} : read.object(part.when, `${path}.when`)).map(([condition, treatment]) => {
|
|
263
|
+
const at = `${path}.when.${condition}`, fields = read.object(treatment, at);
|
|
264
|
+
read.only(fields, at, ["surface", ...effectNames]);
|
|
265
|
+
const effects = effectNames.filter((effect) => fields[effect] !== void 0).map((effect) => ({
|
|
266
|
+
effect: { scale: "scale", scaleInline: "scale-inline", scaleBlock: "scale-block", translateInline: "translate-inline" }[effect],
|
|
267
|
+
field: read.slot(fields[effect], `${at}.${effect}`, "motion").field
|
|
268
|
+
}));
|
|
269
|
+
if (fields.surface === void 0 && effects.length === 0)
|
|
270
|
+
read.invalid(at, "a `surface`, a motion effect (`translateInline`, `scale`, `scaleInline`, `scaleBlock`), or both");
|
|
271
|
+
return [read.condition(condition, `${path}.when`), read.optionalString(fields.surface, `${at}.surface`), effects];
|
|
272
|
+
}), transition = part.transition === void 0 ? [] : read.strings(part.transition, `${path}.transition`).map((channel) => read.literal(channel, `${path}.transition`, ["translate", "scale"])), moved = new Set(when.flatMap(([, , effects]) => effects.map((effect) => effect.effect === "translate-inline" ? "translate" : "scale")));
|
|
273
|
+
if (new Set(transition).size !== transition.length || transition.some((channel) => !moved.has(channel)))
|
|
274
|
+
read.invalid(`${path}.transition`, "distinct channels (`translate`, `scale`), each with an effect in some `when` entry");
|
|
275
|
+
return {
|
|
276
|
+
kind: "box",
|
|
277
|
+
name,
|
|
278
|
+
selector: read.string(part.selector, `${path}.selector`),
|
|
279
|
+
required: read.boolean(part.required, `${path}.required`),
|
|
280
|
+
box: read.string(frame.profile, `${path}.frame.profile`),
|
|
281
|
+
surface: read.optionalString(part.surface, `${path}.surface`),
|
|
282
|
+
when,
|
|
283
|
+
transition
|
|
284
|
+
};
|
|
285
|
+
}
|
|
250
286
|
function textPart(name, value, read) {
|
|
251
287
|
const path = `recipe.parts.${name}`, part = read.object(value, path);
|
|
252
|
-
read.only(part, path, ["kind", "selector", "required", "textEdge", "wrap"]);
|
|
288
|
+
read.only(part, path, ["kind", "selector", "required", "textEdge", "wrap", "textAlign", "extent"]);
|
|
253
289
|
return {
|
|
254
290
|
kind: "text",
|
|
255
291
|
name,
|
|
256
292
|
selector: read.string(part.selector, `${path}.selector`),
|
|
257
293
|
required: read.boolean(part.required, `${path}.required`),
|
|
258
294
|
textEdge: part.textEdge === void 0 ? [] : read.strings(part.textEdge, `${path}.textEdge`),
|
|
259
|
-
wrap: controlLabelWrap(part.wrap, `${path}.wrap`, read)
|
|
295
|
+
wrap: controlLabelWrap(part.wrap, `${path}.wrap`, read),
|
|
296
|
+
align: part.textAlign === void 0 ? null : read.literal(part.textAlign, `${path}.textAlign`, TEXT_ALIGNS),
|
|
297
|
+
extent: part.extent === void 0 ? "content" : read.literal(part.extent, `${path}.extent`, ["content", "fill"])
|
|
260
298
|
};
|
|
261
299
|
}
|
|
262
300
|
function controlLabelWrap(wrap, path, read) {
|
|
@@ -287,21 +325,21 @@ function glyphPart(name, value, read) {
|
|
|
287
325
|
return [
|
|
288
326
|
read.condition(condition, `${path}.when`),
|
|
289
327
|
Object.entries(read.object(effects, at)).filter(([effect]) => effect !== "play").map(([effect, binding]) => {
|
|
290
|
-
const { field } = read.slot(binding, `${at}.${effect}`, "motion"), kind = read.literal(effect, `${at}.${effect}`, ["scale", "scaleInline", "scaleBlock", "translateInline"]);
|
|
291
|
-
return { effect: { scale: "scale", scaleInline: "scale-inline", scaleBlock: "scale-block", translateInline: "translate-inline" }[kind], field };
|
|
328
|
+
const { field } = read.slot(binding, `${at}.${effect}`, "motion"), kind = read.literal(effect, `${at}.${effect}`, ["scale", "scaleInline", "scaleBlock", "translateInline", "rotate"]);
|
|
329
|
+
return { effect: { scale: "scale", scaleInline: "scale-inline", scaleBlock: "scale-block", translateInline: "translate-inline", rotate: "rotate" }[kind], field };
|
|
292
330
|
})
|
|
293
331
|
];
|
|
294
332
|
})
|
|
295
333
|
};
|
|
296
334
|
}
|
|
297
335
|
function artwork(spec, read) {
|
|
298
|
-
read.only(spec, "recipe", ["layout", "align", "parts"]);
|
|
336
|
+
read.only(spec, "recipe", ["layout", "align", "parts", "surface"]);
|
|
299
337
|
read.literal(spec.layout, "recipe.layout", ["inline"]);
|
|
300
338
|
const parts = Object.entries(read.object(spec.parts, "recipe.parts")), [entry] = parts;
|
|
301
339
|
if (parts.length !== 1 || entry === void 0)
|
|
302
340
|
return read.reject({ kind: "parts-unsupported", construction: "artwork", detail: "standalone artwork has exactly one visual part" });
|
|
303
341
|
const [name, value] = entry, path = `recipe.parts.${name}`, part = read.object(value, path);
|
|
304
|
-
read.only(part, path, ["kind", "selector", "required", "motion", "transition", "when", "play"]);
|
|
342
|
+
read.only(part, path, ["kind", "selector", "required", "motion", "transition", "when", "play", ...VISUAL_BINDING_FIELDS]);
|
|
305
343
|
read.literal(part.kind, `${path}.kind`, ["visual"]);
|
|
306
344
|
const states = part.when === void 0 ? [] : Object.entries(read.object(part.when, `${path}.when`)), plays = part.play === void 0 ? [] : [playSpec(part.play, null, `${path}.play`, read)], effects = states.filter(([condition, value]) => {
|
|
307
345
|
const fields = read.object(value, `${path}.when.${condition}`);
|
|
@@ -314,6 +352,7 @@ function artwork(spec, read) {
|
|
|
314
352
|
return {
|
|
315
353
|
kind: "artwork",
|
|
316
354
|
source: spec,
|
|
355
|
+
surface: read.optionalString(spec.surface, "recipe.surface"),
|
|
317
356
|
align: read.optionalString(spec.align, "recipe.align") ?? "center",
|
|
318
357
|
part: {
|
|
319
358
|
kind: "visual",
|
|
@@ -332,34 +371,7 @@ function artwork(spec, read) {
|
|
|
332
371
|
}
|
|
333
372
|
};
|
|
334
373
|
}
|
|
335
|
-
const REGION_LAYOUTS = ["inline", "stack", "flow", "layered"], ROOT_LAYOUTS =
|
|
336
|
-
function proseSpec(spec, read) {
|
|
337
|
-
for (const field of ["parts", "gap", "rowGap", "align", "justify", "wrap", "exposeRows", "snap", "extent", "layer"])
|
|
338
|
-
if (spec[field] !== void 0)
|
|
339
|
-
read.reject({ kind: "field-unsupported", construction: "region", path: `recipe.${field}` });
|
|
340
|
-
const elements = Object.entries(spec.elements === void 0 ? {} : read.object(spec.elements, "recipe.elements")).map(([key, value]) => {
|
|
341
|
-
const path = `recipe.elements.${key}`, name = read.literal(key, path, PROSE_ELEMENT_NAMES), element = read.object(value, path);
|
|
342
|
-
read.only(element, path, ["text", "surface", "frame", "when", "spaceBefore", "indent", "marker"]);
|
|
343
|
-
if (element.spaceBefore !== void 0 && !PROSE_BLOCKS.includes(name))
|
|
344
|
-
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.spaceBefore` });
|
|
345
|
-
if (element.indent !== void 0 && name !== "list")
|
|
346
|
-
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.indent` });
|
|
347
|
-
if (element.marker !== void 0 && name !== "item")
|
|
348
|
-
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.marker` });
|
|
349
|
-
return {
|
|
350
|
-
name,
|
|
351
|
-
path,
|
|
352
|
-
text: read.optionalString(element.text, `${path}.text`),
|
|
353
|
-
surface: read.optionalString(element.surface, `${path}.surface`),
|
|
354
|
-
frame: read.optionalString(element.frame, `${path}.frame`),
|
|
355
|
-
when: treatments(element.when, `${path}.when`, read),
|
|
356
|
-
spaceBefore: element.spaceBefore === void 0 ? null : read.slot(element.spaceBefore, `${path}.spaceBefore`, "spacing"),
|
|
357
|
-
indent: element.indent === void 0 ? null : read.slot(element.indent, `${path}.indent`, "spacing"),
|
|
358
|
-
marker: read.optionalString(element.marker, `${path}.marker`)
|
|
359
|
-
};
|
|
360
|
-
});
|
|
361
|
-
return { rhythm: spec.rhythm === void 0 ? null : read.slot(spec.rhythm, "recipe.rhythm", "spacing"), elements };
|
|
362
|
-
}
|
|
374
|
+
const REGION_LAYOUTS = ["inline", "stack", "flow", "layered"], ROOT_LAYOUTS = REGION_LAYOUTS;
|
|
363
375
|
export const ROOT_EXTENTS = ["content", "container"];
|
|
364
376
|
function rootExtent(value, layout, layer, read) {
|
|
365
377
|
if (value === void 0)
|
|
@@ -381,9 +393,58 @@ function arrangement(spec, read, path, layout) {
|
|
|
381
393
|
justify: read.optionalString(spec.justify, `${path}.justify`),
|
|
382
394
|
wrap: read.boolean(spec.wrap, `${path}.wrap`),
|
|
383
395
|
gap: gap === void 0 ? null : read.slot(gap, `${path}.gap`, "spacing"),
|
|
396
|
+
overlap: overlapSpec(spec, read, path, layout),
|
|
384
397
|
snap: snap(spec.snap, `${path}.snap`, read)
|
|
385
398
|
};
|
|
386
399
|
}
|
|
400
|
+
function overlapSpec(spec, read, path, layout) {
|
|
401
|
+
const declared = spec.overlap;
|
|
402
|
+
if (declared === void 0)
|
|
403
|
+
return null;
|
|
404
|
+
if (layout !== "inline" && layout !== "stack")
|
|
405
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.overlap` });
|
|
406
|
+
for (const field of ["gap", "rowGap", "wrap"])
|
|
407
|
+
if (spec[field] !== void 0 && spec[field] !== !1)
|
|
408
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.${field}` });
|
|
409
|
+
const by = read.slot(declared, `${path}.overlap`, "spacing");
|
|
410
|
+
read.literal(by.field, `${path}.overlap.field`, ["overlap"]);
|
|
411
|
+
return { by };
|
|
412
|
+
}
|
|
413
|
+
function geometryStates(value, path, read, part) {
|
|
414
|
+
const states = [];
|
|
415
|
+
for (const [condition, declared] of Object.entries(value === void 0 ? {} : read.object(value, path))) {
|
|
416
|
+
const at = `${path}.${condition}`, fields = read.object(declared, at);
|
|
417
|
+
if (fields.frame === void 0 && fields.spacing === void 0 && fields.collapsed === void 0)
|
|
418
|
+
continue;
|
|
419
|
+
if (!part && fields.collapsed !== void 0)
|
|
420
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${at}.collapsed` });
|
|
421
|
+
let frame = null;
|
|
422
|
+
if (fields.frame !== void 0) {
|
|
423
|
+
const selected = read.object(fields.frame, `${at}.frame`);
|
|
424
|
+
read.only(selected, `${at}.frame`, ["profile"]);
|
|
425
|
+
frame = read.string(selected.profile, `${at}.frame.profile`);
|
|
426
|
+
}
|
|
427
|
+
const collapsed = fields.collapsed;
|
|
428
|
+
if (collapsed !== void 0 && typeof collapsed !== "boolean")
|
|
429
|
+
read.invalid(`${at}.collapsed`, "boolean");
|
|
430
|
+
states.push({ condition, frame, spacing: read.optionalString(fields.spacing, `${at}.spacing`), collapsed: typeof collapsed === "boolean" ? collapsed : null, path: at });
|
|
431
|
+
}
|
|
432
|
+
return states;
|
|
433
|
+
}
|
|
434
|
+
function geometryTransition(value, path, read) {
|
|
435
|
+
if (value === void 0)
|
|
436
|
+
return null;
|
|
437
|
+
const declared = read.object(value, path);
|
|
438
|
+
read.only(declared, path, ["channels", "motion"]);
|
|
439
|
+
const channels = read.strings(declared.channels, `${path}.channels`).map((channel) => read.literal(channel, `${path}.channels`, GEOMETRY_CHANNELS));
|
|
440
|
+
if (channels.length === 0 || new Set(channels).size !== channels.length)
|
|
441
|
+
read.invalid(`${path}.channels`, "distinct geometry channels (`size`, `inset`, `gap`, `radius`, `border-width`, `overlap`)");
|
|
442
|
+
const motion = declared.motion;
|
|
443
|
+
if (typeof motion === "string")
|
|
444
|
+
return { channels, motion: { kind: "profile", name: motion }, path };
|
|
445
|
+
read.slotless(motion, `${path}.motion`, "motion");
|
|
446
|
+
return { channels, motion: { kind: "slot" }, path };
|
|
447
|
+
}
|
|
387
448
|
function snap(value, path, read) {
|
|
388
449
|
if (value === void 0)
|
|
389
450
|
return null;
|
|
@@ -400,12 +461,13 @@ function textBinding(value, path, read) {
|
|
|
400
461
|
read.only(binding, path, ["slot"]);
|
|
401
462
|
return { kind: "slot", slot: read.string(binding.slot, `${path}.slot`) };
|
|
402
463
|
}
|
|
403
|
-
function rootWhen(spec, read) {
|
|
464
|
+
function rootWhen(spec, read, geometry = !1) {
|
|
404
465
|
const when = [], texts = [], pressed = [], plays = spec.play === void 0 ? [] : [playSpec(spec.play, null, "recipe.play", read)];
|
|
405
466
|
for (const [condition, treatment] of spec.when === void 0 ? [] : Object.entries(read.object(spec.when, "recipe.when"))) {
|
|
406
467
|
const at = `recipe.when.${condition}`, fields = read.object(treatment, at);
|
|
407
|
-
read.only(fields, at, ["surface", "scale", "play", "text"]);
|
|
408
|
-
|
|
468
|
+
read.only(fields, at, ["surface", "scale", "play", "text", ...geometry ? ["frame", "spacing"] : []]);
|
|
469
|
+
const shaped = geometry && (fields.frame !== void 0 || fields.spacing !== void 0);
|
|
470
|
+
if (fields.surface === void 0 && fields.scale === void 0 && fields.play === void 0 && fields.text === void 0 && !shaped)
|
|
409
471
|
read.invalid(at, "a `surface`, a `scale` endpoint, a `play`, a `text`, or several");
|
|
410
472
|
const state = read.condition(condition, "recipe.when");
|
|
411
473
|
if (fields.text !== void 0)
|
|
@@ -461,8 +523,8 @@ function partStates(part, path, read) {
|
|
|
461
523
|
const treatments = [], texts = [], plays = [], moved = [], names = Object.keys(PART_EFFECTS);
|
|
462
524
|
for (const [condition, declared] of Object.entries(part.when === void 0 ? {} : read.object(part.when, `${path}.when`))) {
|
|
463
525
|
const at = `${path}.when.${condition}`, fields = read.object(declared, at);
|
|
464
|
-
read.only(fields, at, ["surface", "play", "text", ...names]);
|
|
465
|
-
const state = read.condition(condition, `${path}.when`);
|
|
526
|
+
read.only(fields, at, ["surface", "play", "text", "frame", "spacing", "collapsed", ...names]);
|
|
527
|
+
const shaped = fields.frame !== void 0 || fields.spacing !== void 0 || fields.collapsed !== void 0, state = read.condition(condition, `${path}.when`);
|
|
466
528
|
if (fields.text !== void 0)
|
|
467
529
|
texts.push({ condition: state, text: read.string(fields.text, `${at}.text`), path: `${at}.text` });
|
|
468
530
|
const effects = names.filter((name) => fields[name] !== void 0);
|
|
@@ -470,8 +532,8 @@ function partStates(part, path, read) {
|
|
|
470
532
|
read.literal(read.slot(fields[name], `${at}.${name}`, "motion").field, `${at}.${name}.field`, [PART_EFFECTS[name].field]);
|
|
471
533
|
if (fields.play !== void 0)
|
|
472
534
|
plays.push(playSpec(fields.play, state, `${at}.play`, read));
|
|
473
|
-
if (fields.surface === void 0 && effects.length === 0 && fields.play === void 0 && fields.text === void 0)
|
|
474
|
-
read.invalid(at, "a `surface`, a motion effect (`scale`, `scaleInline`, `scaleBlock`, `translateInline`, `translateBlock`), a `play`, or several");
|
|
535
|
+
if (fields.surface === void 0 && effects.length === 0 && fields.play === void 0 && fields.text === void 0 && !shaped)
|
|
536
|
+
read.invalid(at, "a `surface`, a motion effect (`scale`, `scaleInline`, `scaleBlock`, `translateInline`, `translateBlock`, `rotate`), a `play`, or several");
|
|
475
537
|
if (effects.filter((name) => PART_EFFECTS[name].channel === "scale").length > 1)
|
|
476
538
|
read.invalid(at, "one of `scale`, `scaleInline` and `scaleBlock`");
|
|
477
539
|
if (fields.surface !== void 0)
|
|
@@ -479,9 +541,9 @@ function partStates(part, path, read) {
|
|
|
479
541
|
if (effects.length > 0)
|
|
480
542
|
moved.push([state, effects]);
|
|
481
543
|
}
|
|
482
|
-
const transition = part.transition === void 0 ? [] : read.strings(part.transition, `${path}.transition`).map((channel) => read.literal(channel, `${path}.transition`, ["translate", "scale"])), used = new Set(moved.flatMap(([, effects]) => effects.map((name) => PART_EFFECTS[name].channel)));
|
|
544
|
+
const transition = part.transition === void 0 ? [] : read.strings(part.transition, `${path}.transition`).map((channel) => read.literal(channel, `${path}.transition`, ["translate", "scale", "rotate"])), used = new Set(moved.flatMap(([, effects]) => effects.map((name) => PART_EFFECTS[name].channel)));
|
|
483
545
|
if (new Set(transition).size !== transition.length || transition.some((channel) => !used.has(channel)))
|
|
484
|
-
read.invalid(`${path}.transition`, "distinct channels (`translate`, `scale`), each with an effect in some `when` entry");
|
|
546
|
+
read.invalid(`${path}.transition`, "distinct channels (`translate`, `scale`, `rotate`), each with an effect in some `when` entry");
|
|
485
547
|
const declared = part.motion;
|
|
486
548
|
if (moved.length === 0) {
|
|
487
549
|
if (declared !== void 0)
|
|
@@ -524,7 +586,7 @@ function enterSpec(value, path, read) {
|
|
|
524
586
|
read.only(from, `${path}.from`, ["surface", ...Object.keys(ENTER_MOVEMENTS)]);
|
|
525
587
|
const moved = Object.keys(ENTER_MOVEMENTS).filter((kind) => from[kind] !== void 0), surface = read.optionalString(from.surface, `${path}.from.surface`);
|
|
526
588
|
if (moved.length > 1 || surface === null && moved.length === 0)
|
|
527
|
-
read.invalid(`${path}.from`, "a starting `surface`, one of `translate`, `scale` and `rotate`, or both");
|
|
589
|
+
read.invalid(`${path}.from`, "a starting `surface`, one of `translate`, `translateInline`, `scale` and `rotate`, or both");
|
|
528
590
|
const [kind] = moved, movement = kind === void 0 ? null : { kind, field: read.literal(read.slot(from[kind], `${path}.from.${kind}`, "motion").field, `${path}.from.${kind}.field`, [ENTER_MOVEMENTS[kind]]) }, motion = declared.motion;
|
|
529
591
|
if (typeof motion === "string")
|
|
530
592
|
return { driver: { kind: "first-render" }, surface, movement, motion: { kind: "profile", name: motion }, path };
|
|
@@ -776,7 +838,7 @@ function partConditions(value, path, read) {
|
|
|
776
838
|
});
|
|
777
839
|
}
|
|
778
840
|
function partContent(part, path, read) {
|
|
779
|
-
const kind = part.kind === void 0 ? "element" : read.literal(part.kind, `${path}.kind`, ["text", "visual", "vector"]);
|
|
841
|
+
const kind = part.kind === void 0 ? "element" : read.literal(part.kind, `${path}.kind`, ["text", "visual", "vector", "component"]);
|
|
780
842
|
if (kind !== "visual" && part.media !== void 0)
|
|
781
843
|
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.media` });
|
|
782
844
|
if (kind !== "vector" && part.stroke !== void 0)
|
|
@@ -785,6 +847,12 @@ function partContent(part, path, read) {
|
|
|
785
847
|
case "text":
|
|
786
848
|
case "element":
|
|
787
849
|
return { kind };
|
|
850
|
+
case "component": {
|
|
851
|
+
for (const field of Object.keys(part))
|
|
852
|
+
if (!["kind", "selector", "required", "repeat", "extent", "at", "spaceBefore", "spaceAfter"].includes(field))
|
|
853
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.${field}` });
|
|
854
|
+
return { kind };
|
|
855
|
+
}
|
|
788
856
|
case "visual":
|
|
789
857
|
return { kind, media: part.media === void 0 ? "bound" : read.literal(part.media, `${path}.media`, ["inspected-svg"]) };
|
|
790
858
|
case "vector": {
|
|
@@ -922,6 +990,14 @@ function regionPart(name, value, read, path, nested) {
|
|
|
922
990
|
"media",
|
|
923
991
|
"stroke",
|
|
924
992
|
"accessibility",
|
|
993
|
+
"focus",
|
|
994
|
+
"drawnBy",
|
|
995
|
+
"anchorClear",
|
|
996
|
+
"collapsed",
|
|
997
|
+
"geometryTransition",
|
|
998
|
+
"repeat",
|
|
999
|
+
"spaceBefore",
|
|
1000
|
+
"spaceAfter",
|
|
925
1001
|
...VISUAL_BINDING_FIELDS,
|
|
926
1002
|
...nested ? [] : ["measured", "paints"]
|
|
927
1003
|
]);
|
|
@@ -938,13 +1014,16 @@ function regionPart(name, value, read, path, nested) {
|
|
|
938
1014
|
let arranged = null;
|
|
939
1015
|
if (part.recipe !== void 0) {
|
|
940
1016
|
const recipe = read.object(part.recipe, `${path}.recipe`);
|
|
941
|
-
read.only(recipe, `${path}.recipe`, ["layout", "gap", "rowGap", "align", "justify", "wrap", "snap"]);
|
|
1017
|
+
read.only(recipe, `${path}.recipe`, ["layout", "gap", "rowGap", "overlap", "align", "justify", "wrap", "snap"]);
|
|
942
1018
|
arranged = arrangement(recipe, read, `${path}.recipe`, read.literal(recipe.layout, `${path}.recipe.layout`, REGION_LAYOUTS));
|
|
943
1019
|
}
|
|
944
1020
|
return {
|
|
945
1021
|
name,
|
|
946
1022
|
selector: read.string(part.selector, `${path}.selector`),
|
|
947
1023
|
required: read.boolean(part.required, `${path}.required`),
|
|
1024
|
+
repeat: part.repeat === void 0 ? !1 : read.boolean(part.repeat, `${path}.repeat`),
|
|
1025
|
+
spaceBefore: part.spaceBefore === void 0 ? null : read.slot(part.spaceBefore, `${path}.spaceBefore`, "spacing"),
|
|
1026
|
+
spaceAfter: part.spaceAfter === void 0 ? null : read.slot(part.spaceAfter, `${path}.spaceAfter`, "spacing"),
|
|
948
1027
|
content,
|
|
949
1028
|
textEdge: part.textEdge === void 0 ? [] : read.strings(part.textEdge, `${path}.textEdge`),
|
|
950
1029
|
textLayout: textLayout(part, path, read),
|
|
@@ -959,6 +1038,9 @@ function regionPart(name, value, read, path, nested) {
|
|
|
959
1038
|
accessibility: accessibilityDeclaration(part.accessibility, part.frame !== void 0 && boxed === null, `${path}.accessibility`, read),
|
|
960
1039
|
when: states.treatments,
|
|
961
1040
|
textWhen: states.texts,
|
|
1041
|
+
geometryWhen: geometryStates(part.when, `${path}.when`, read, !0),
|
|
1042
|
+
geometryTransition: geometryTransition(part.geometryTransition, `${path}.geometryTransition`, read),
|
|
1043
|
+
collapsed: part.collapsed === void 0 ? !1 : read.boolean(part.collapsed, `${path}.collapsed`),
|
|
962
1044
|
effects: states.effects,
|
|
963
1045
|
plays: [...part.play === void 0 ? [] : [playSpec(part.play, null, `${path}.play`, read)], ...states.plays],
|
|
964
1046
|
normalize: normalized.values,
|
|
@@ -967,6 +1049,9 @@ function regionPart(name, value, read, path, nested) {
|
|
|
967
1049
|
enter: enterSpec(part.enter, `${path}.enter`, read),
|
|
968
1050
|
sticky: stickySpec(part.sticky, `${path}.sticky`, read),
|
|
969
1051
|
outset: outsetSpec(part.outset, `${path}.outset`, read),
|
|
1052
|
+
focusOf: focusSource(part.focus, `${path}.focus`, read),
|
|
1053
|
+
drawnBy: part.drawnBy === void 0 ? null : read.string(part.drawnBy, `${path}.drawnBy`),
|
|
1054
|
+
anchorClear: anchorClear(part.anchorClear, `${path}.anchorClear`, read),
|
|
970
1055
|
scheme: partScheme(part, content, path, read),
|
|
971
1056
|
pseudo: pseudoTreatments(part.pseudo, `${path}.pseudo`, read),
|
|
972
1057
|
arrangement: arranged,
|
|
@@ -975,10 +1060,44 @@ function regionPart(name, value, read, path, nested) {
|
|
|
975
1060
|
paints: runtimePaints(part.paints, `${path}.paints`, read)
|
|
976
1061
|
};
|
|
977
1062
|
}
|
|
1063
|
+
function anchorClear(value, path, read) {
|
|
1064
|
+
if (value === void 0)
|
|
1065
|
+
return null;
|
|
1066
|
+
const binding = read.object(value, path);
|
|
1067
|
+
read.only(binding, path, ["slot", "field"]);
|
|
1068
|
+
const slot = read.literal(binding.slot, `${path}.slot`, ["layer", "spacing"]);
|
|
1069
|
+
return { slot, field: read.literal(binding.field, `${path}.field`, [slot === "layer" ? "clearBlockStart" : "anchorGap"]) };
|
|
1070
|
+
}
|
|
1071
|
+
function focusSource(value, path, read) {
|
|
1072
|
+
if (value === void 0)
|
|
1073
|
+
return null;
|
|
1074
|
+
const declared = read.object(value, path);
|
|
1075
|
+
read.only(declared, path, ["of"]);
|
|
1076
|
+
return read.string(declared.of, `${path}.of`);
|
|
1077
|
+
}
|
|
978
1078
|
function parseParts(value, read, path, nested) {
|
|
979
1079
|
if (value === void 0)
|
|
980
1080
|
return [];
|
|
981
|
-
const parts = Object.entries(read.object(value, `${path}.parts`)).map(([name, part]) => regionPart(name, part, read, `${path}.parts.${name}`, nested))
|
|
1081
|
+
const parts = Object.entries(read.object(value, `${path}.parts`)).map(([name, part]) => regionPart(name, part, read, `${path}.parts.${name}`, nested));
|
|
1082
|
+
for (const part of parts)
|
|
1083
|
+
if (part.focusOf !== null && (part.focusOf === part.name || !parts.some((other) => other.name === part.focusOf)))
|
|
1084
|
+
return read.invalid(`${path}.parts.${part.name}.focus.of`, "the name of another part of the same parent (the native control this part stands in for)");
|
|
1085
|
+
for (const part of parts) {
|
|
1086
|
+
if (!part.repeat)
|
|
1087
|
+
continue;
|
|
1088
|
+
if (part.content.kind === "vector")
|
|
1089
|
+
read.invalid(`${path}.parts.${part.name}.repeat`, "omitted on a vector part, which already renders any number of shapes");
|
|
1090
|
+
if (part.drawnBy !== null || part.focusOf !== null || parts.some((other) => other.focusOf === part.name || other.drawnBy === part.name))
|
|
1091
|
+
read.invalid(`${path}.parts.${part.name}.repeat`, "omitted on a part paired with another by `drawnBy` or `focus: { of }`: each instance would need its own pair");
|
|
1092
|
+
}
|
|
1093
|
+
parts.forEach((part, index) => {
|
|
1094
|
+
if (part.drawnBy === null)
|
|
1095
|
+
return;
|
|
1096
|
+
const drawing = parts[index + 1];
|
|
1097
|
+
if (drawing === void 0 || drawing.name !== part.drawnBy || drawing.focusOf !== part.name)
|
|
1098
|
+
read.invalid(`${path}.parts.${part.name}.drawnBy`, `the name of the part declared right after it, whose \`focus: { of: "${part.name}" }\` shows this control's keyboard focus`);
|
|
1099
|
+
});
|
|
1100
|
+
const schemed = parts.filter((part) => part.scheme !== null);
|
|
982
1101
|
for (const scheme of schemed.length === 0 ? [] : COLOR_SCHEMES) {
|
|
983
1102
|
const [first, second] = schemed.filter((part) => part.scheme === scheme), at = second ?? first ?? schemed[0];
|
|
984
1103
|
if (first === void 0 || second !== void 0)
|
|
@@ -1041,8 +1160,6 @@ function region(authored, read) {
|
|
|
1041
1160
|
"paintTransition",
|
|
1042
1161
|
"enter",
|
|
1043
1162
|
"sticky",
|
|
1044
|
-
"elements",
|
|
1045
|
-
"rhythm",
|
|
1046
1163
|
"play",
|
|
1047
1164
|
"at",
|
|
1048
1165
|
"parts",
|
|
@@ -1054,19 +1171,16 @@ function region(authored, read) {
|
|
|
1054
1171
|
"measured",
|
|
1055
1172
|
"paints",
|
|
1056
1173
|
"snap",
|
|
1057
|
-
"extent"
|
|
1174
|
+
"extent",
|
|
1175
|
+
"anchorClear",
|
|
1176
|
+
"overlap",
|
|
1177
|
+
"geometryTransition"
|
|
1058
1178
|
]);
|
|
1059
|
-
const layout = spec.layout === void 0 ? "native" : read.literal(spec.layout, "recipe.layout", ROOT_LAYOUTS);
|
|
1060
|
-
if (layout !== "prose") {
|
|
1061
|
-
for (const field of ["elements", "rhythm"])
|
|
1062
|
-
if (spec[field] !== void 0)
|
|
1063
|
-
read.reject({ kind: "field-unsupported", construction: "region", path: `recipe.${field}` });
|
|
1064
|
-
}
|
|
1065
|
-
const prose = layout === "prose" ? proseSpec(spec, read) : null, normalized = normalization(spec.normalize, "recipe.normalize", REGION_NORMALIZE, REGION_NORMALIZE, "selector", read), parts = parseParts(spec.parts, read, "recipe", !1), measured = measuredValues(spec.measured, "recipe.measured", read);
|
|
1179
|
+
const layout = spec.layout === void 0 ? "native" : read.literal(spec.layout, "recipe.layout", ROOT_LAYOUTS), normalized = normalization(spec.normalize, "recipe.normalize", REGION_NORMALIZE, REGION_NORMALIZE, "selector", read), parts = parseParts(spec.parts, read, "recipe", !1), measured = measuredValues(spec.measured, "recipe.measured", read);
|
|
1066
1180
|
uniqueMeasured(measured, parts, read);
|
|
1067
1181
|
const paints = runtimePaints(spec.paints, "recipe.paints", read);
|
|
1068
1182
|
uniqueNames("paints", paints, parts.map((part) => [part.name, part.paints]), read);
|
|
1069
|
-
const exposeRows = spec.exposeRows === void 0 ? [] : read.strings(spec.exposeRows, "recipe.exposeRows"), rootStates = rootWhen(spec, read), layer = layerSpec(spec.layer, read);
|
|
1183
|
+
const exposeRows = spec.exposeRows === void 0 ? [] : read.strings(spec.exposeRows, "recipe.exposeRows"), rootStates = rootWhen(spec, read, !0), layer = layerSpec(spec.layer, read);
|
|
1070
1184
|
if (layer !== null && rootStates.pressedAt !== null)
|
|
1071
1185
|
read.reject({ kind: "field-unsupported", construction: "region", path: rootStates.pressedAt });
|
|
1072
1186
|
for (const row of exposeRows)
|
|
@@ -1091,8 +1205,10 @@ function region(authored, read) {
|
|
|
1091
1205
|
press: rootStates.press,
|
|
1092
1206
|
paintTransition: paintTransition(spec.paintTransition, "recipe.paintTransition", read),
|
|
1093
1207
|
enter: layer !== null && spec.enter !== void 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.enter" }) : enterSpec(spec.enter, "recipe.enter", read),
|
|
1094
|
-
|
|
1208
|
+
anchorClear: layer !== null && spec.anchorClear !== void 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.anchorClear" }) : anchorClear(spec.anchorClear, "recipe.anchorClear", read),
|
|
1095
1209
|
textWhen: rootStates.texts,
|
|
1210
|
+
geometryWhen: layer !== null && geometryStates(spec.when, "recipe.when", read, !1).length > 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: geometryStates(spec.when, "recipe.when", read, !1)[0]?.path ?? "recipe.when" }) : geometryStates(spec.when, "recipe.when", read, !1),
|
|
1211
|
+
geometryTransition: geometryTransition(spec.geometryTransition, "recipe.geometryTransition", read),
|
|
1096
1212
|
frameAt: frameCondition(spec.at, regionFrame(spec.frame, read), read),
|
|
1097
1213
|
plays: layer !== null && rootStates.plays.length > 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.play" }) : rootStates.plays,
|
|
1098
1214
|
sticky: layer !== null && spec.sticky !== void 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.sticky" }) : stickySpec(spec.sticky, "recipe.sticky", read),
|
|
@@ -1151,7 +1267,7 @@ function grid(spec, read) {
|
|
|
1151
1267
|
const mode = read.literal(spec.layout, "recipe.layout", GRID_MODES), values = (value, path) => Object.entries(read.object(value, path)).map(([field, item]) => [field, read.spatial(item, `${path}.${field}`)]), frame = regionFrame(spec.frame, read);
|
|
1152
1268
|
if (frame !== null && (frame.kind !== "fields" || frame.container || frame.ratio !== null || frame.border.kind !== "profile"))
|
|
1153
1269
|
read.reject({ kind: "field-unsupported", construction: "grid", path: "recipe.frame" });
|
|
1154
|
-
|
|
1270
|
+
const parsed = {
|
|
1155
1271
|
kind: "grid",
|
|
1156
1272
|
source: spec,
|
|
1157
1273
|
mode,
|
|
@@ -1160,11 +1276,19 @@ function grid(spec, read) {
|
|
|
1160
1276
|
rowGap: spec.rowGap === void 0 ? null : read.slot(spec.rowGap, "recipe.rowGap", "spacing"),
|
|
1161
1277
|
frame,
|
|
1162
1278
|
cells: Object.entries(spec.cells === void 0 ? {} : read.object(spec.cells, "recipe.cells")).map(([selector, value]) => {
|
|
1163
|
-
const path = `recipe.cells.${selector}`, { at, ...cell } = read.object(value, path);
|
|
1279
|
+
const path = `recipe.cells.${selector}`, { at, required, repeat, ...cell } = read.object(value, path), repeated = repeat === void 0 ? !1 : read.boolean(repeat, `${path}.repeat`), tiers = at === void 0 ? [] : Object.entries(read.object(at, `${path}.at`)).map(([tier, fields]) => [tier, values(fields, `${path}.at.${tier}`)]), own = values(cell, path);
|
|
1280
|
+
if (repeated) {
|
|
1281
|
+
for (const [at, placed] of [[path, own], ...tiers.map(([tier, placed]) => [`${path}.at.${tier}`, placed])])
|
|
1282
|
+
for (const [field, item] of placed)
|
|
1283
|
+
if (field === "start" && item !== "auto" || field === "end" || field === "row" || field === "rowSpan")
|
|
1284
|
+
read.invalid(`${at}.${field}`, 'omitted on a repeated cell: its instances flow one after another (`start: "auto"`), each over its `span`');
|
|
1285
|
+
}
|
|
1164
1286
|
return {
|
|
1165
1287
|
selector,
|
|
1166
|
-
|
|
1167
|
-
|
|
1288
|
+
required: required === void 0 ? !0 : read.boolean(required, `${path}.required`),
|
|
1289
|
+
repeat: repeated,
|
|
1290
|
+
values: repeated && !own.some(([field]) => field === "start") ? [...own, ["start", "auto"]] : own,
|
|
1291
|
+
at: tiers
|
|
1168
1292
|
};
|
|
1169
1293
|
}),
|
|
1170
1294
|
conditions: Object.entries(spec.at === void 0 ? {} : read.object(spec.at, "recipe.at")).map(([condition, value]) => {
|
|
@@ -1174,5 +1298,11 @@ function grid(spec, read) {
|
|
|
1174
1298
|
}),
|
|
1175
1299
|
alignRows: Object.entries(spec.alignRows === void 0 ? {} : read.object(spec.alignRows, "recipe.alignRows")).map(([selector, rows]) => [selector, read.strings(rows, `recipe.alignRows.${selector}`)]),
|
|
1176
1300
|
measured: measuredValues(spec.measured, "recipe.measured", read).map((value) => ("motion" in value) && value.motion !== null ? read.reject({ kind: "field-unsupported", construction: "grid", path: `recipe.measured.${value.name}.motion` }) : value)
|
|
1177
|
-
};
|
|
1301
|
+
}, repeated = new Set(parsed.cells.flatMap((cell) => cell.repeat ? [cell.selector] : []));
|
|
1302
|
+
for (const { condition, cells } of parsed.conditions)
|
|
1303
|
+
for (const [selector, placed] of cells)
|
|
1304
|
+
for (const [field, item] of repeated.has(selector) ? placed : [])
|
|
1305
|
+
if (field === "start" && item !== "auto" || field === "end" || field === "row" || field === "rowSpan")
|
|
1306
|
+
read.invalid(`recipe.at.${condition}.cells.${selector}.${field}`, "omitted on a repeated cell: its instances flow one after another");
|
|
1307
|
+
return parsed;
|
|
1178
1308
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FRAME_CORNERS } from "./construction-spec.mjs";
|
|
1
|
+
import { cornerRadius, FRAME_CORNERS } from "./construction-spec.mjs";
|
|
2
2
|
import { selectedProfile, tokenValueContexts } from "./design-foundation.mjs";
|
|
3
3
|
import { readColor } from "./paint-contrast.mjs";
|
|
4
4
|
const fieldsOf = (foundation, name, kind) => {
|
|
@@ -11,7 +11,19 @@ const fieldsOf = (foundation, name, kind) => {
|
|
|
11
11
|
"block-end": ["end-start", "end-end"]
|
|
12
12
|
}, inset = (frame, axis, side) => frame.has("padding") || frame.has(`padding-${axis}`) || frame.has(`padding-${axis}-${side}`);
|
|
13
13
|
export function cornerOverpaint(foundation, spec) {
|
|
14
|
-
if (spec.kind !== "region"
|
|
14
|
+
if (spec.kind !== "region")
|
|
15
|
+
return null;
|
|
16
|
+
const conditions = [...new Set([...spec.geometryWhen, ...spec.parts.flatMap((part) => part.geometryWhen)].flatMap((state) => state.frame === null ? [] : [state.condition]))];
|
|
17
|
+
for (const under of [null, ...conditions]) {
|
|
18
|
+
const found = overpaintUnder(foundation, spec, under);
|
|
19
|
+
if (found !== null)
|
|
20
|
+
return found;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const framedUnder = (own, states, condition) => condition === null ? own : states.find((state) => state.condition === condition && state.frame !== null)?.frame ?? own;
|
|
25
|
+
function overpaintUnder(foundation, spec, under) {
|
|
26
|
+
if (spec.frame === null || spec.overflow.kind !== "visible" || spec.profile === null)
|
|
15
27
|
return null;
|
|
16
28
|
const { layout } = spec.arrangement;
|
|
17
29
|
if (layout !== "stack" && layout !== "layered")
|
|
@@ -19,12 +31,12 @@ export function cornerOverpaint(foundation, spec) {
|
|
|
19
31
|
const selected = selectedProfile(foundation, spec.profile, spec.select);
|
|
20
32
|
if (selected.kind === "err")
|
|
21
33
|
return null;
|
|
22
|
-
const slots = selected.value.fields, frame = fieldsOf(foundation, slots.get("frame-profile"), "frame");
|
|
23
|
-
if (frame === null || !frame.
|
|
34
|
+
const slots = selected.value.fields, frame = fieldsOf(foundation, framedUnder(slots.get("frame-profile"), spec.geometryWhen, under), "frame");
|
|
35
|
+
if (frame === null || !FRAME_CORNERS.some((corner) => cornerRadius((field) => frame.get(field), corner) !== void 0))
|
|
24
36
|
return null;
|
|
25
37
|
if ((spec.surface ?? slots.get("surface-profile")) === void 0 && !frame.has("border-width"))
|
|
26
38
|
return null;
|
|
27
|
-
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) => {
|
|
28
40
|
const [block, inline] = corner.split("-");
|
|
29
41
|
return rounded.has(corner) && !inset(frame, "block", block) && !inset(frame, "inline", inline);
|
|
30
42
|
}, parts = spec.parts.filter((part) => part.outset === null), reached = (index) => {
|
|
@@ -35,7 +47,8 @@ export function cornerOverpaint(foundation, spec) {
|
|
|
35
47
|
const corners = reached(index);
|
|
36
48
|
if (corners.length === 0)
|
|
37
49
|
continue;
|
|
38
|
-
|
|
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))
|
|
39
52
|
continue;
|
|
40
53
|
for (const [state, name] of [[null, part.surface], ...part.when]) {
|
|
41
54
|
const background = fieldsOf(foundation, name, "surface")?.get("background");
|
|
@@ -46,7 +59,7 @@ export function cornerOverpaint(foundation, spec) {
|
|
|
46
59
|
const read = readColor(background, context);
|
|
47
60
|
return read.kind !== "color" || read.rgba[3] > 0;
|
|
48
61
|
}))
|
|
49
|
-
return { kind: "corner-overpaint", part: part.name, surface: name, state, corners };
|
|
62
|
+
return { kind: "corner-overpaint", part: part.name, surface: name, state, corners, under };
|
|
50
63
|
}
|
|
51
64
|
}
|
|
52
65
|
return null;
|