@reqvire-org/ads 0.5.1 → 0.5.2
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 +110 -25
- 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/factored-classes.mjs +90 -0
- package/dist/analysis/helpers.mjs +5 -7
- package/dist/analysis/native-project.mjs +12 -0
- package/dist/analysis/owner-analysis-cache.mjs +86 -23
- package/dist/analysis/owner-analysis-key.mjs +42 -10
- package/dist/analysis/owner-choices.mjs +23 -4
- package/dist/analysis/owner-composition.mjs +118 -33
- package/dist/analysis/owner-reuse.mjs +8 -6
- package/dist/analysis/owner-source.mjs +253 -76
- 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-keyline.mjs +2 -2
- package/dist/config.mjs +2 -1
- package/dist/construction-output.mjs +3 -2
- package/dist/construction-spec.d.mts +111 -6
- package/dist/construction-spec.mjs +172 -30
- package/dist/corner-overpaint.mjs +16 -4
- package/dist/derived-states.mjs +182 -0
- package/dist/design-inputs.mjs +18 -3
- package/dist/design-system-closure.mjs +12 -7
- package/dist/emit/contract.mjs +24 -5
- package/dist/emit/emission.mjs +6 -4
- 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/hover-geometry.mjs +15 -0
- package/dist/input-digests.mjs +17 -10
- package/dist/linaria/delivery.mjs +2 -0
- package/dist/lowering-properties.mjs +5 -0
- package/dist/lowering-region-layout.mjs +7 -2
- 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/motion-model.mjs +1 -1
- package/dist/owner-analysis-check.mjs +19 -5
- package/dist/owner-errors.mjs +4 -2
- package/dist/owner-lowering.mjs +71 -12
- package/dist/owner-scenarios.mjs +4 -1
- package/dist/ownership-model.mjs +18 -4
- package/dist/placeholder-contrast.mjs +17 -1
- package/dist/platform-features.mjs +10 -1
- package/dist/profile-view-facts.mjs +1 -1
- package/dist/recipe-macro.d.mts +72 -13
- package/dist/recipe-model.mjs +9 -5
- package/dist/region-lowering.mjs +238 -40
- 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 +5 -0
- package/dist/role-vocabulary.mjs +12 -1
- package/dist/scenarios-compiler.mjs +20 -6
- package/dist/showcase/assets-view.mjs +29 -13
- package/dist/showcase/client.bundle.js +32 -32
- package/dist/showcase/http-client.bundle.js +15 -15
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +4 -4
- package/dist/skills/ads-designer/references/accessibility.md +7 -0
- 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 +1 -1
- package/dist/skills/ads-designer/references/layout.md +5 -1
- package/dist/skills/ads-designer/references/motion.md +9 -1
- package/dist/skills/ads-designer/references/recipes.md +27 -3
- package/dist/skills/ads-import/references/contracts.md +5 -2
- package/dist/skills/ads-import/references/design-data.md +1 -1
- package/dist/skills/ads-import/references/layout.md +5 -1
- package/dist/skills/ads-import/references/recipes.md +27 -3
- package/dist/skills/ads-migrate/SKILL.md +1 -0
- package/dist/skills/ads-migrate/references/0.5.1-to-0.5.2.md +185 -0
- package/dist/skills/ads-port/references/contracts.md +5 -2
- package/dist/skills/ads-port/references/design-data.md +1 -1
- package/dist/skills/ads-port/references/layout.md +5 -1
- package/dist/skills/ads-port/references/recipes.md +27 -3
- package/dist/surface-contrast.mjs +1 -0
- package/dist/surface-effects.mjs +5 -3
- package/dist/task-cache.mjs +8 -18
- package/dist/validation-checks.mjs +1 -1
- package/docs/ARCHITECTURE.md +63 -7
- package/docs/CACHING.md +152 -24
- package/docs/CHANGELOG.md +200 -23
- package/docs/GUIDE.md +45 -1
- package/docs/LANGUAGE.md +146 -8
- package/docs/MOTION.md +10 -2
- package/docs/PROFILE-KINDS.md +9 -1
- package/docs/RULES.md +22 -14
- package/docs/TOKEN-ROLES.md +7 -1
- package/package.json +1 -1
|
@@ -268,6 +268,7 @@ export function visualPart(asset, visual, state, theme, reject) {
|
|
|
268
268
|
const size = visual.size ?? reject({ kind: "profile-field-missing", profile: "visual", field: "size" }), drawing = model(selectAsset(asset, theme, size, state), reject), intrinsic = asset.paint === "intrinsic", [, , width, height] = drawing.box, [x, y] = drawing.center, ratio = width / height, factors = { block: 1 + 2 * Math.abs(y), inline: ratio * (1 + 2 * Math.abs(x)) }, extent = `calc(${size} * ${factors.block})`;
|
|
269
269
|
return {
|
|
270
270
|
drawing,
|
|
271
|
+
size,
|
|
271
272
|
extent,
|
|
272
273
|
factors,
|
|
273
274
|
element: intrinsic ? "img" : "svg",
|
|
@@ -293,9 +294,9 @@ export function visualPart(asset, visual, state, theme, reject) {
|
|
|
293
294
|
}
|
|
294
295
|
export function coverArtwork(asset, visual, state, theme, reject) {
|
|
295
296
|
const drawing = model(selectAsset(asset, theme, visual.size ?? "", state), reject);
|
|
296
|
-
return { drawing, element: "img", source: `data:image/svg+xml,${encodeURIComponent(drawing.text)}` };
|
|
297
|
+
return { drawing, size: null, element: "img", source: `data:image/svg+xml,${encodeURIComponent(drawing.text)}` };
|
|
297
298
|
}
|
|
298
|
-
export const placed = (geometry) => ({ drawing: geometry.drawing, element: geometry.element, source: geometry.source }), LINE_BOX = "1lh";
|
|
299
|
+
export const placed = (geometry) => ({ drawing: geometry.drawing, size: geometry.size, element: geometry.element, source: geometry.source }), LINE_BOX = "1lh";
|
|
299
300
|
export function controlBox(frame, envelope, field, reject) {
|
|
300
301
|
const insets = controlFrameInsets(frame);
|
|
301
302
|
if (insets.kind === "err")
|
|
@@ -74,11 +74,13 @@ export interface TextPart {
|
|
|
74
74
|
readonly required: boolean;
|
|
75
75
|
readonly textEdge: readonly string[];
|
|
76
76
|
readonly wrap: ControlLabelWrap;
|
|
77
|
+
/** How the label's lines sit in its box (`text-align`): it shows once the label wraps or the control is wider than it. */
|
|
78
|
+
readonly align: TextAlign | null;
|
|
77
79
|
}
|
|
78
80
|
/** A state effect on a control's visual part, bound to the motion profile. */
|
|
79
81
|
/** A control's artwork effect under an owner state. The three scales are one channel: whole, or one axis only (a blink). */
|
|
80
82
|
export type GlyphEffect = {
|
|
81
|
-
readonly effect: "scale" | "scale-inline" | "scale-block" | "translate-inline";
|
|
83
|
+
readonly effect: "scale" | "scale-inline" | "scale-block" | "translate-inline" | "rotate";
|
|
82
84
|
readonly field: string;
|
|
83
85
|
};
|
|
84
86
|
export interface GlyphPart {
|
|
@@ -141,11 +143,15 @@ export declare const PART_EFFECTS: {
|
|
|
141
143
|
readonly channel: "translate";
|
|
142
144
|
readonly field: "distance";
|
|
143
145
|
};
|
|
146
|
+
readonly rotate: {
|
|
147
|
+
readonly channel: "rotate";
|
|
148
|
+
readonly field: "angle";
|
|
149
|
+
};
|
|
144
150
|
};
|
|
145
151
|
/** A scale effect's value on its axis: the whole element, or one axis with the other at rest. */
|
|
146
152
|
export declare const scaleValue: (effect: "scale" | "scaleInline" | "scaleBlock" | "scale-inline" | "scale-block", value: string) => string;
|
|
147
153
|
export type PartEffectName = keyof typeof PART_EFFECTS;
|
|
148
|
-
export type PartChannel = "translate" | "scale";
|
|
154
|
+
export type PartChannel = "translate" | "scale" | "rotate";
|
|
149
155
|
/**
|
|
150
156
|
* A region part's motion under owner states: a card whose arrow slides, or whose picture grows, while
|
|
151
157
|
* the card is hovered. `transition` lists the channels that animate (an effect whose channel is not
|
|
@@ -213,8 +219,12 @@ export interface PaintTransition {
|
|
|
213
219
|
readonly channels: readonly PaintChannel[];
|
|
214
220
|
readonly motion: MotionBinding;
|
|
215
221
|
}
|
|
216
|
-
/**
|
|
217
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Pseudo-elements an owned part may treat. `placeholder` is the native placeholder text of an input or
|
|
224
|
+
* textarea (a colour). `progressValue` is the filled part of a `<progress>` (a background): the part's own
|
|
225
|
+
* surface is its track.
|
|
226
|
+
*/
|
|
227
|
+
export declare const PSEUDO_ELEMENTS: readonly ["placeholder", "progressValue"];
|
|
218
228
|
export type PseudoElement = (typeof PSEUDO_ELEMENTS)[number];
|
|
219
229
|
/** The elements that have each pseudo-element: a treatment on any other element would never match. */
|
|
220
230
|
export declare const PSEUDO_HOSTS: {
|
|
@@ -264,9 +274,30 @@ interface ControlCommon {
|
|
|
264
274
|
readonly textWhen: readonly StateText[];
|
|
265
275
|
/** The control's own text profile, replacing its profile's text slot; `null`: the slot's. */
|
|
266
276
|
readonly text: string | null;
|
|
267
|
-
|
|
277
|
+
/** `null` for a control that renders no text of its own (a switch, whose label is beside it). */
|
|
278
|
+
readonly label: TextPart | null;
|
|
268
279
|
/** `null` for a text-only control. */
|
|
269
280
|
readonly glyph: GlyphPart | null;
|
|
281
|
+
/** The control's decorative boxes (a switch's knob), in authored order. */
|
|
282
|
+
readonly decor: readonly DecorPart[];
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* A decorative box of a control: an empty element with a frame profile's box and a surface, hidden from
|
|
286
|
+
* assistive technology, that shows the control's state by its paint or position (a switch's knob, a
|
|
287
|
+
* radio's dot). `effects` move it under owner states; a move is the state's shape, so reduced motion keeps
|
|
288
|
+
* it and drops only its animation.
|
|
289
|
+
*/
|
|
290
|
+
export interface DecorPart {
|
|
291
|
+
readonly kind: "box";
|
|
292
|
+
readonly name: string;
|
|
293
|
+
readonly selector: string;
|
|
294
|
+
readonly required: boolean;
|
|
295
|
+
/** The frame profile that sizes and shapes the box. */
|
|
296
|
+
readonly box: string;
|
|
297
|
+
readonly surface: string | null;
|
|
298
|
+
readonly when: readonly (readonly [condition: string, surface: string | null, effects: readonly GlyphEffect[]])[];
|
|
299
|
+
/** The channels that animate (`translate`, `scale`), each with an effect in some `when` entry. */
|
|
300
|
+
readonly transition: readonly ("translate" | "scale")[];
|
|
270
301
|
}
|
|
271
302
|
/** A declared continuous rotation of standalone artwork under one condition. */
|
|
272
303
|
export interface ContinuousEffect {
|
|
@@ -288,6 +319,8 @@ export interface ArtworkSpec {
|
|
|
288
319
|
readonly source: JsonObject;
|
|
289
320
|
readonly align: string;
|
|
290
321
|
readonly part: ArtworkPart;
|
|
322
|
+
/** A colour-only surface: the colour a foreground drawing takes (an icon's own quiet tone); `null`: its container's. */
|
|
323
|
+
readonly surface: string | null;
|
|
291
324
|
}
|
|
292
325
|
/**
|
|
293
326
|
* `native` keeps the element's own display: a treatment or frame without an
|
|
@@ -308,13 +341,31 @@ export interface ProseElement {
|
|
|
308
341
|
readonly frame: string | null;
|
|
309
342
|
readonly when: readonly StateTreatment[];
|
|
310
343
|
readonly spaceBefore: SlotBinding | null;
|
|
344
|
+
/** The space between a block and whatever follows it, in place of the rhythm (a heading closer to its text); the larger of it and the next block's own `spaceBefore`. */
|
|
345
|
+
readonly spaceAfter: SlotBinding | null;
|
|
311
346
|
readonly indent: SlotBinding | null;
|
|
312
347
|
readonly marker: string | null;
|
|
313
|
-
|
|
348
|
+
/** Where a jump to the block lands (a heading with an id). */
|
|
349
|
+
readonly anchorClear: SlotBinding | null;
|
|
350
|
+
/** A text profile whose weight an item's marker takes (bold numbers and bullets). */
|
|
351
|
+
readonly markerText: string | null;
|
|
352
|
+
/** An unordered list's marker shape at each depth of nesting, outermost first; deeper lists keep the last. */
|
|
353
|
+
readonly markers: readonly ProseMarker[];
|
|
354
|
+
}
|
|
355
|
+
export declare const PROSE_MARKERS: readonly ["disc", "circle", "square"];
|
|
356
|
+
export type ProseMarker = (typeof PROSE_MARKERS)[number];
|
|
314
357
|
/** `layout: "prose"`: the space between blocks and the elements the recipe styles, in authored order. */
|
|
315
358
|
export interface ProseSpec {
|
|
316
359
|
readonly rhythm: SlotBinding | null;
|
|
317
360
|
readonly elements: readonly ProseElement[];
|
|
361
|
+
/**
|
|
362
|
+
* `elements.component`: the space around a component placed directly among the blocks (a callout, a code
|
|
363
|
+
* block with its own owner). Its design is its owner's; only the space the flow gives it is prose's.
|
|
364
|
+
*/
|
|
365
|
+
readonly component: {
|
|
366
|
+
readonly spaceBefore: SlotBinding | null;
|
|
367
|
+
readonly spaceAfter: SlotBinding | null;
|
|
368
|
+
} | null;
|
|
318
369
|
}
|
|
319
370
|
/** The scroll-snap axis and strictness a scrolling element declares (`scroll-snap-type`), on logical axes: they follow the writing mode, as `overflow` does. */
|
|
320
371
|
export declare const SNAP_TYPES: readonly ["inline mandatory", "inline proximity", "block mandatory", "block proximity", "both mandatory", "both proximity"];
|
|
@@ -332,12 +383,46 @@ export interface Snap {
|
|
|
332
383
|
readonly align: SnapAlign;
|
|
333
384
|
}
|
|
334
385
|
/** How an element arranges its children. */
|
|
386
|
+
/** Later neighbours paint over earlier ones (DOM order). */
|
|
387
|
+
export interface OverlapSpec {
|
|
388
|
+
readonly by: SlotBinding;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Geometry an element takes under one owner state: another frame profile (sizes, insets, radius, border
|
|
392
|
+
* widths), another spacing profile (the arrangement's gap and overlap are read from it), and for a part
|
|
393
|
+
* whether it is collapsed. Each is a whole profile, lowered and checked as the base one is.
|
|
394
|
+
*/
|
|
395
|
+
export interface StateGeometry {
|
|
396
|
+
readonly condition: string;
|
|
397
|
+
readonly frame: string | null;
|
|
398
|
+
readonly spacing: string | null;
|
|
399
|
+
/** A part only: `null` leaves the part as it is at rest. */
|
|
400
|
+
readonly collapsed: boolean | null;
|
|
401
|
+
readonly path: string;
|
|
402
|
+
}
|
|
403
|
+
/** The geometry that animates between states, as closed channels, timed by a motion profile. */
|
|
404
|
+
/**
|
|
405
|
+
* `overlap` is the element's own start margin where an overlapping arrangement places it: the arrangement
|
|
406
|
+
* decides the value, the element animates its change (a face in a pile that spreads).
|
|
407
|
+
*/
|
|
408
|
+
export declare const GEOMETRY_CHANNELS: readonly ["size", "inset", "gap", "radius", "border-width", "overlap"];
|
|
409
|
+
export type GeometryChannel = (typeof GEOMETRY_CHANNELS)[number];
|
|
410
|
+
export interface GeometryTransition {
|
|
411
|
+
readonly channels: readonly GeometryChannel[];
|
|
412
|
+
readonly motion: MotionBinding;
|
|
413
|
+
readonly path: string;
|
|
414
|
+
}
|
|
335
415
|
export interface Arrangement {
|
|
336
416
|
readonly layout: RegionLayout;
|
|
337
417
|
readonly align: string | null;
|
|
338
418
|
readonly justify: string | null;
|
|
339
419
|
readonly wrap: boolean;
|
|
340
420
|
readonly gap: SlotBinding | null;
|
|
421
|
+
/**
|
|
422
|
+
* `overlap`: neighbours overlap by a spacing value instead of being separated by one (a pile of faces, a
|
|
423
|
+
* stack of cards). Real layout: the row is as wide as what it shows. Never beside `gap`.
|
|
424
|
+
*/
|
|
425
|
+
readonly overlap: OverlapSpec | null;
|
|
341
426
|
/** `null` when the element does not snap its children. */
|
|
342
427
|
readonly snap: Snap | null;
|
|
343
428
|
}
|
|
@@ -559,6 +644,21 @@ export interface RuntimePaint {
|
|
|
559
644
|
export interface RegionPart {
|
|
560
645
|
readonly name: string;
|
|
561
646
|
readonly selector: string;
|
|
647
|
+
/** `anchorClear`: where a jump to this element lands below the scroll container's top edge. */
|
|
648
|
+
readonly anchorClear: SlotBinding | null;
|
|
649
|
+
/** The geometry the part takes under owner states. */
|
|
650
|
+
readonly geometryWhen: readonly StateGeometry[];
|
|
651
|
+
readonly geometryTransition: GeometryTransition | null;
|
|
652
|
+
/**
|
|
653
|
+
* `collapsed: true`: the part takes no room on its parent's main axis, is transparent, and is hidden from
|
|
654
|
+
* assistive technology and focus; a `when` entry may open it (`collapsed: false`) or close an open one.
|
|
655
|
+
*/
|
|
656
|
+
readonly collapsed: boolean;
|
|
657
|
+
/**
|
|
658
|
+
* `focus: { of: "<sibling part>" }`: this part is the drawn stand-in of a native control beside it (the box
|
|
659
|
+
* of a checkbox whose `<input>` is hidden) and shows the focus indicator while that control has keyboard focus.
|
|
660
|
+
*/
|
|
661
|
+
readonly focusOf: string | null;
|
|
562
662
|
readonly required: boolean;
|
|
563
663
|
readonly content: PartContent;
|
|
564
664
|
readonly textEdge: readonly string[];
|
|
@@ -688,6 +788,11 @@ export interface RegionSpec {
|
|
|
688
788
|
readonly frameAt: FrameCondition | null;
|
|
689
789
|
/** The elements a prose root styles; `null` for every other layout. */
|
|
690
790
|
readonly prose: ProseSpec | null;
|
|
791
|
+
/** Where a jump to the root lands; never on a top-layer root, which is not in the page's flow. */
|
|
792
|
+
readonly anchorClear: SlotBinding | null;
|
|
793
|
+
/** The geometry the root takes under owner states; never on a top-layer root. */
|
|
794
|
+
readonly geometryWhen: readonly StateGeometry[];
|
|
795
|
+
readonly geometryTransition: GeometryTransition | null;
|
|
691
796
|
/** The root's entrance; never on a top-layer root, whose layer motion is its entrance. */
|
|
692
797
|
readonly enter: EnterSpec | null;
|
|
693
798
|
/** The root stays at an edge of its scrolling container; never on a top-layer root, which the top layer places. */
|
|
@@ -8,8 +8,9 @@ export const ACCESSIBILITY_BOUNDARIES = ["visible-label", "boundary-on-interacti
|
|
|
8
8
|
scaleInline: { channel: "scale", field: "scale" },
|
|
9
9
|
scaleBlock: { channel: "scale", field: "scale" },
|
|
10
10
|
translateInline: { channel: "translate", field: "distance" },
|
|
11
|
-
translateBlock: { channel: "translate", field: "distance" }
|
|
12
|
-
|
|
11
|
+
translateBlock: { channel: "translate", field: "distance" },
|
|
12
|
+
rotate: { channel: "rotate", field: "angle" }
|
|
13
|
+
}, scaleValue = (effect, value) => effect === "scale" ? value : effect === "scaleInline" || effect === "scale-inline" ? `${value} 1` : `1 ${value}`, STICKY_EDGES = ["block-start", "block-end"], ENTER_MOVEMENTS = { translate: "distance", scale: "scale", rotate: "angle" }, PSEUDO_ELEMENTS = ["placeholder", "progressValue"], PSEUDO_HOSTS = { placeholder: ["input", "textarea"], progressValue: ["progress"] }, PROSE_MARKERS = ["disc", "circle", "square"], 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"], 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
14
|
export function elementTags(element) {
|
|
14
15
|
switch (element.kind) {
|
|
15
16
|
case "iframe":
|
|
@@ -59,7 +60,7 @@ export function parseConstruction(spec) {
|
|
|
59
60
|
export function declaredParts(spec) {
|
|
60
61
|
switch (spec.kind) {
|
|
61
62
|
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));
|
|
63
|
+
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
64
|
case "artwork":
|
|
64
65
|
return [{ ...plainPart, name: spec.part.name, path: `recipe.parts.${spec.part.name}`, selector: spec.part.selector, required: spec.part.required, kind: "visual" }];
|
|
65
66
|
case "region":
|
|
@@ -209,9 +210,9 @@ function reader(construction, reject, partStates) {
|
|
|
209
210
|
}
|
|
210
211
|
function control(spec, read) {
|
|
211
212
|
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
|
|
213
|
+
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;
|
|
214
|
+
if (texts.length > 1 || visuals.length > 1 || parts.length !== texts.length + visuals.length + boxes.length || parts.length === 0)
|
|
215
|
+
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
216
|
const common = {
|
|
216
217
|
kind: "control",
|
|
217
218
|
source: spec,
|
|
@@ -228,8 +229,9 @@ function control(spec, read) {
|
|
|
228
229
|
plays: rootStates.plays,
|
|
229
230
|
textWhen: rootStates.texts,
|
|
230
231
|
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)
|
|
232
|
+
label: text === void 0 ? null : textPart(text[0], text[1], read),
|
|
233
|
+
glyph: visual === void 0 ? null : glyphPart(visual[0], visual[1], read),
|
|
234
|
+
decor: boxes.map(([name, part]) => decorPart(name, part, read))
|
|
233
235
|
};
|
|
234
236
|
if (spec.layout === void 0) {
|
|
235
237
|
for (const field of ["align", "justify"])
|
|
@@ -247,16 +249,46 @@ function control(spec, read) {
|
|
|
247
249
|
return { ...common, layout, align: read.string(spec.align, "recipe.align") };
|
|
248
250
|
}
|
|
249
251
|
}
|
|
252
|
+
function decorPart(name, value, read) {
|
|
253
|
+
const path = `recipe.parts.${name}`, part = read.object(value, path);
|
|
254
|
+
read.only(part, path, ["selector", "required", "frame", "surface", "when", "transition"]);
|
|
255
|
+
const frame = read.object(part.frame, `${path}.frame`);
|
|
256
|
+
read.only(frame, `${path}.frame`, ["profile"]);
|
|
257
|
+
const effectNames = ["scale", "scaleInline", "scaleBlock", "translateInline"], when = Object.entries(part.when === void 0 ? {} : read.object(part.when, `${path}.when`)).map(([condition, treatment]) => {
|
|
258
|
+
const at = `${path}.when.${condition}`, fields = read.object(treatment, at);
|
|
259
|
+
read.only(fields, at, ["surface", ...effectNames]);
|
|
260
|
+
const effects = effectNames.filter((effect) => fields[effect] !== void 0).map((effect) => ({
|
|
261
|
+
effect: { scale: "scale", scaleInline: "scale-inline", scaleBlock: "scale-block", translateInline: "translate-inline" }[effect],
|
|
262
|
+
field: read.slot(fields[effect], `${at}.${effect}`, "motion").field
|
|
263
|
+
}));
|
|
264
|
+
if (fields.surface === void 0 && effects.length === 0)
|
|
265
|
+
read.invalid(at, "a `surface`, a motion effect (`translateInline`, `scale`, `scaleInline`, `scaleBlock`), or both");
|
|
266
|
+
return [read.condition(condition, `${path}.when`), read.optionalString(fields.surface, `${at}.surface`), effects];
|
|
267
|
+
}), 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")));
|
|
268
|
+
if (new Set(transition).size !== transition.length || transition.some((channel) => !moved.has(channel)))
|
|
269
|
+
read.invalid(`${path}.transition`, "distinct channels (`translate`, `scale`), each with an effect in some `when` entry");
|
|
270
|
+
return {
|
|
271
|
+
kind: "box",
|
|
272
|
+
name,
|
|
273
|
+
selector: read.string(part.selector, `${path}.selector`),
|
|
274
|
+
required: read.boolean(part.required, `${path}.required`),
|
|
275
|
+
box: read.string(frame.profile, `${path}.frame.profile`),
|
|
276
|
+
surface: read.optionalString(part.surface, `${path}.surface`),
|
|
277
|
+
when,
|
|
278
|
+
transition
|
|
279
|
+
};
|
|
280
|
+
}
|
|
250
281
|
function textPart(name, value, read) {
|
|
251
282
|
const path = `recipe.parts.${name}`, part = read.object(value, path);
|
|
252
|
-
read.only(part, path, ["kind", "selector", "required", "textEdge", "wrap"]);
|
|
283
|
+
read.only(part, path, ["kind", "selector", "required", "textEdge", "wrap", "textAlign"]);
|
|
253
284
|
return {
|
|
254
285
|
kind: "text",
|
|
255
286
|
name,
|
|
256
287
|
selector: read.string(part.selector, `${path}.selector`),
|
|
257
288
|
required: read.boolean(part.required, `${path}.required`),
|
|
258
289
|
textEdge: part.textEdge === void 0 ? [] : read.strings(part.textEdge, `${path}.textEdge`),
|
|
259
|
-
wrap: controlLabelWrap(part.wrap, `${path}.wrap`, read)
|
|
290
|
+
wrap: controlLabelWrap(part.wrap, `${path}.wrap`, read),
|
|
291
|
+
align: part.textAlign === void 0 ? null : read.literal(part.textAlign, `${path}.textAlign`, TEXT_ALIGNS)
|
|
260
292
|
};
|
|
261
293
|
}
|
|
262
294
|
function controlLabelWrap(wrap, path, read) {
|
|
@@ -287,15 +319,15 @@ function glyphPart(name, value, read) {
|
|
|
287
319
|
return [
|
|
288
320
|
read.condition(condition, `${path}.when`),
|
|
289
321
|
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 };
|
|
322
|
+
const { field } = read.slot(binding, `${at}.${effect}`, "motion"), kind = read.literal(effect, `${at}.${effect}`, ["scale", "scaleInline", "scaleBlock", "translateInline", "rotate"]);
|
|
323
|
+
return { effect: { scale: "scale", scaleInline: "scale-inline", scaleBlock: "scale-block", translateInline: "translate-inline", rotate: "rotate" }[kind], field };
|
|
292
324
|
})
|
|
293
325
|
];
|
|
294
326
|
})
|
|
295
327
|
};
|
|
296
328
|
}
|
|
297
329
|
function artwork(spec, read) {
|
|
298
|
-
read.only(spec, "recipe", ["layout", "align", "parts"]);
|
|
330
|
+
read.only(spec, "recipe", ["layout", "align", "parts", "surface"]);
|
|
299
331
|
read.literal(spec.layout, "recipe.layout", ["inline"]);
|
|
300
332
|
const parts = Object.entries(read.object(spec.parts, "recipe.parts")), [entry] = parts;
|
|
301
333
|
if (parts.length !== 1 || entry === void 0)
|
|
@@ -314,6 +346,7 @@ function artwork(spec, read) {
|
|
|
314
346
|
return {
|
|
315
347
|
kind: "artwork",
|
|
316
348
|
source: spec,
|
|
349
|
+
surface: read.optionalString(spec.surface, "recipe.surface"),
|
|
317
350
|
align: read.optionalString(spec.align, "recipe.align") ?? "center",
|
|
318
351
|
part: {
|
|
319
352
|
kind: "visual",
|
|
@@ -337,9 +370,30 @@ function proseSpec(spec, read) {
|
|
|
337
370
|
for (const field of ["parts", "gap", "rowGap", "align", "justify", "wrap", "exposeRows", "snap", "extent", "layer"])
|
|
338
371
|
if (spec[field] !== void 0)
|
|
339
372
|
read.reject({ kind: "field-unsupported", construction: "region", path: `recipe.${field}` });
|
|
340
|
-
const
|
|
373
|
+
const declaredElements = spec.elements === void 0 ? {} : read.object(spec.elements, "recipe.elements");
|
|
374
|
+
let component = null;
|
|
375
|
+
if (declaredElements.component !== void 0) {
|
|
376
|
+
const path = "recipe.elements.component", declared = read.object(declaredElements.component, path);
|
|
377
|
+
read.only(declared, path, ["spaceBefore", "spaceAfter"]);
|
|
378
|
+
if (declared.spaceBefore === void 0 && declared.spaceAfter === void 0)
|
|
379
|
+
read.invalid(path, "a `spaceBefore`, a `spaceAfter` or both");
|
|
380
|
+
const space = (field) => declared[field] === void 0 ? null : read.slot(declared[field], `${path}.${field}`, "spacing");
|
|
381
|
+
component = { spaceBefore: space("spaceBefore"), spaceAfter: space("spaceAfter") };
|
|
382
|
+
}
|
|
383
|
+
const elements = Object.entries(declaredElements).filter(([key]) => key !== "component").map(([key, value]) => {
|
|
341
384
|
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"]);
|
|
385
|
+
read.only(element, path, ["text", "surface", "frame", "when", "spaceBefore", "spaceAfter", "indent", "marker", "markerText", "markers", "anchorClear"]);
|
|
386
|
+
if (element.anchorClear !== void 0 && !PROSE_BLOCKS.includes(name))
|
|
387
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.anchorClear` });
|
|
388
|
+
if (element.spaceAfter !== void 0 && !PROSE_BLOCKS.includes(name))
|
|
389
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.spaceAfter` });
|
|
390
|
+
if (element.markerText !== void 0 && name !== "item")
|
|
391
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.markerText` });
|
|
392
|
+
if (element.markers !== void 0 && name !== "list")
|
|
393
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.markers` });
|
|
394
|
+
const markers = element.markers === void 0 ? [] : read.strings(element.markers, `${path}.markers`).map((shape) => read.literal(shape, `${path}.markers`, PROSE_MARKERS));
|
|
395
|
+
if (element.markers !== void 0 && (markers.length === 0 || markers.length > 3))
|
|
396
|
+
read.invalid(`${path}.markers`, "one to three marker shapes, outermost list first");
|
|
343
397
|
if (element.spaceBefore !== void 0 && !PROSE_BLOCKS.includes(name))
|
|
344
398
|
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.spaceBefore` });
|
|
345
399
|
if (element.indent !== void 0 && name !== "list")
|
|
@@ -355,10 +409,14 @@ function proseSpec(spec, read) {
|
|
|
355
409
|
when: treatments(element.when, `${path}.when`, read),
|
|
356
410
|
spaceBefore: element.spaceBefore === void 0 ? null : read.slot(element.spaceBefore, `${path}.spaceBefore`, "spacing"),
|
|
357
411
|
indent: element.indent === void 0 ? null : read.slot(element.indent, `${path}.indent`, "spacing"),
|
|
358
|
-
marker: read.optionalString(element.marker, `${path}.marker`)
|
|
412
|
+
marker: read.optionalString(element.marker, `${path}.marker`),
|
|
413
|
+
spaceAfter: element.spaceAfter === void 0 ? null : read.slot(element.spaceAfter, `${path}.spaceAfter`, "spacing"),
|
|
414
|
+
markerText: read.optionalString(element.markerText, `${path}.markerText`),
|
|
415
|
+
anchorClear: anchorClear(element.anchorClear, `${path}.anchorClear`, read),
|
|
416
|
+
markers
|
|
359
417
|
};
|
|
360
418
|
});
|
|
361
|
-
return { rhythm: spec.rhythm === void 0 ? null : read.slot(spec.rhythm, "recipe.rhythm", "spacing"), elements };
|
|
419
|
+
return { rhythm: spec.rhythm === void 0 ? null : read.slot(spec.rhythm, "recipe.rhythm", "spacing"), elements, component };
|
|
362
420
|
}
|
|
363
421
|
export const ROOT_EXTENTS = ["content", "container"];
|
|
364
422
|
function rootExtent(value, layout, layer, read) {
|
|
@@ -381,9 +439,58 @@ function arrangement(spec, read, path, layout) {
|
|
|
381
439
|
justify: read.optionalString(spec.justify, `${path}.justify`),
|
|
382
440
|
wrap: read.boolean(spec.wrap, `${path}.wrap`),
|
|
383
441
|
gap: gap === void 0 ? null : read.slot(gap, `${path}.gap`, "spacing"),
|
|
442
|
+
overlap: overlapSpec(spec, read, path, layout),
|
|
384
443
|
snap: snap(spec.snap, `${path}.snap`, read)
|
|
385
444
|
};
|
|
386
445
|
}
|
|
446
|
+
function overlapSpec(spec, read, path, layout) {
|
|
447
|
+
const declared = spec.overlap;
|
|
448
|
+
if (declared === void 0)
|
|
449
|
+
return null;
|
|
450
|
+
if (layout !== "inline" && layout !== "stack")
|
|
451
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.overlap` });
|
|
452
|
+
for (const field of ["gap", "rowGap", "wrap"])
|
|
453
|
+
if (spec[field] !== void 0 && spec[field] !== !1)
|
|
454
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.${field}` });
|
|
455
|
+
const by = read.slot(declared, `${path}.overlap`, "spacing");
|
|
456
|
+
read.literal(by.field, `${path}.overlap.field`, ["overlap"]);
|
|
457
|
+
return { by };
|
|
458
|
+
}
|
|
459
|
+
function geometryStates(value, path, read, part) {
|
|
460
|
+
const states = [];
|
|
461
|
+
for (const [condition, declared] of Object.entries(value === void 0 ? {} : read.object(value, path))) {
|
|
462
|
+
const at = `${path}.${condition}`, fields = read.object(declared, at);
|
|
463
|
+
if (fields.frame === void 0 && fields.spacing === void 0 && fields.collapsed === void 0)
|
|
464
|
+
continue;
|
|
465
|
+
if (!part && fields.collapsed !== void 0)
|
|
466
|
+
read.reject({ kind: "field-unsupported", construction: "region", path: `${at}.collapsed` });
|
|
467
|
+
let frame = null;
|
|
468
|
+
if (fields.frame !== void 0) {
|
|
469
|
+
const selected = read.object(fields.frame, `${at}.frame`);
|
|
470
|
+
read.only(selected, `${at}.frame`, ["profile"]);
|
|
471
|
+
frame = read.string(selected.profile, `${at}.frame.profile`);
|
|
472
|
+
}
|
|
473
|
+
const collapsed = fields.collapsed;
|
|
474
|
+
if (collapsed !== void 0 && typeof collapsed !== "boolean")
|
|
475
|
+
read.invalid(`${at}.collapsed`, "boolean");
|
|
476
|
+
states.push({ condition, frame, spacing: read.optionalString(fields.spacing, `${at}.spacing`), collapsed: typeof collapsed === "boolean" ? collapsed : null, path: at });
|
|
477
|
+
}
|
|
478
|
+
return states;
|
|
479
|
+
}
|
|
480
|
+
function geometryTransition(value, path, read) {
|
|
481
|
+
if (value === void 0)
|
|
482
|
+
return null;
|
|
483
|
+
const declared = read.object(value, path);
|
|
484
|
+
read.only(declared, path, ["channels", "motion"]);
|
|
485
|
+
const channels = read.strings(declared.channels, `${path}.channels`).map((channel) => read.literal(channel, `${path}.channels`, GEOMETRY_CHANNELS));
|
|
486
|
+
if (channels.length === 0 || new Set(channels).size !== channels.length)
|
|
487
|
+
read.invalid(`${path}.channels`, "distinct geometry channels (`size`, `inset`, `gap`, `radius`, `border-width`, `overlap`)");
|
|
488
|
+
const motion = declared.motion;
|
|
489
|
+
if (typeof motion === "string")
|
|
490
|
+
return { channels, motion: { kind: "profile", name: motion }, path };
|
|
491
|
+
read.slotless(motion, `${path}.motion`, "motion");
|
|
492
|
+
return { channels, motion: { kind: "slot" }, path };
|
|
493
|
+
}
|
|
387
494
|
function snap(value, path, read) {
|
|
388
495
|
if (value === void 0)
|
|
389
496
|
return null;
|
|
@@ -400,12 +507,13 @@ function textBinding(value, path, read) {
|
|
|
400
507
|
read.only(binding, path, ["slot"]);
|
|
401
508
|
return { kind: "slot", slot: read.string(binding.slot, `${path}.slot`) };
|
|
402
509
|
}
|
|
403
|
-
function rootWhen(spec, read) {
|
|
510
|
+
function rootWhen(spec, read, geometry = !1) {
|
|
404
511
|
const when = [], texts = [], pressed = [], plays = spec.play === void 0 ? [] : [playSpec(spec.play, null, "recipe.play", read)];
|
|
405
512
|
for (const [condition, treatment] of spec.when === void 0 ? [] : Object.entries(read.object(spec.when, "recipe.when"))) {
|
|
406
513
|
const at = `recipe.when.${condition}`, fields = read.object(treatment, at);
|
|
407
|
-
read.only(fields, at, ["surface", "scale", "play", "text"]);
|
|
408
|
-
|
|
514
|
+
read.only(fields, at, ["surface", "scale", "play", "text", ...geometry ? ["frame", "spacing"] : []]);
|
|
515
|
+
const shaped = geometry && (fields.frame !== void 0 || fields.spacing !== void 0);
|
|
516
|
+
if (fields.surface === void 0 && fields.scale === void 0 && fields.play === void 0 && fields.text === void 0 && !shaped)
|
|
409
517
|
read.invalid(at, "a `surface`, a `scale` endpoint, a `play`, a `text`, or several");
|
|
410
518
|
const state = read.condition(condition, "recipe.when");
|
|
411
519
|
if (fields.text !== void 0)
|
|
@@ -461,8 +569,8 @@ function partStates(part, path, read) {
|
|
|
461
569
|
const treatments = [], texts = [], plays = [], moved = [], names = Object.keys(PART_EFFECTS);
|
|
462
570
|
for (const [condition, declared] of Object.entries(part.when === void 0 ? {} : read.object(part.when, `${path}.when`))) {
|
|
463
571
|
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`);
|
|
572
|
+
read.only(fields, at, ["surface", "play", "text", "frame", "spacing", "collapsed", ...names]);
|
|
573
|
+
const shaped = fields.frame !== void 0 || fields.spacing !== void 0 || fields.collapsed !== void 0, state = read.condition(condition, `${path}.when`);
|
|
466
574
|
if (fields.text !== void 0)
|
|
467
575
|
texts.push({ condition: state, text: read.string(fields.text, `${at}.text`), path: `${at}.text` });
|
|
468
576
|
const effects = names.filter((name) => fields[name] !== void 0);
|
|
@@ -470,8 +578,8 @@ function partStates(part, path, read) {
|
|
|
470
578
|
read.literal(read.slot(fields[name], `${at}.${name}`, "motion").field, `${at}.${name}.field`, [PART_EFFECTS[name].field]);
|
|
471
579
|
if (fields.play !== void 0)
|
|
472
580
|
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");
|
|
581
|
+
if (fields.surface === void 0 && effects.length === 0 && fields.play === void 0 && fields.text === void 0 && !shaped)
|
|
582
|
+
read.invalid(at, "a `surface`, a motion effect (`scale`, `scaleInline`, `scaleBlock`, `translateInline`, `translateBlock`, `rotate`), a `play`, or several");
|
|
475
583
|
if (effects.filter((name) => PART_EFFECTS[name].channel === "scale").length > 1)
|
|
476
584
|
read.invalid(at, "one of `scale`, `scaleInline` and `scaleBlock`");
|
|
477
585
|
if (fields.surface !== void 0)
|
|
@@ -479,9 +587,9 @@ function partStates(part, path, read) {
|
|
|
479
587
|
if (effects.length > 0)
|
|
480
588
|
moved.push([state, effects]);
|
|
481
589
|
}
|
|
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)));
|
|
590
|
+
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
591
|
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");
|
|
592
|
+
read.invalid(`${path}.transition`, "distinct channels (`translate`, `scale`, `rotate`), each with an effect in some `when` entry");
|
|
485
593
|
const declared = part.motion;
|
|
486
594
|
if (moved.length === 0) {
|
|
487
595
|
if (declared !== void 0)
|
|
@@ -922,6 +1030,10 @@ function regionPart(name, value, read, path, nested) {
|
|
|
922
1030
|
"media",
|
|
923
1031
|
"stroke",
|
|
924
1032
|
"accessibility",
|
|
1033
|
+
"focus",
|
|
1034
|
+
"anchorClear",
|
|
1035
|
+
"collapsed",
|
|
1036
|
+
"geometryTransition",
|
|
925
1037
|
...VISUAL_BINDING_FIELDS,
|
|
926
1038
|
...nested ? [] : ["measured", "paints"]
|
|
927
1039
|
]);
|
|
@@ -938,7 +1050,7 @@ function regionPart(name, value, read, path, nested) {
|
|
|
938
1050
|
let arranged = null;
|
|
939
1051
|
if (part.recipe !== void 0) {
|
|
940
1052
|
const recipe = read.object(part.recipe, `${path}.recipe`);
|
|
941
|
-
read.only(recipe, `${path}.recipe`, ["layout", "gap", "rowGap", "align", "justify", "wrap", "snap"]);
|
|
1053
|
+
read.only(recipe, `${path}.recipe`, ["layout", "gap", "rowGap", "overlap", "align", "justify", "wrap", "snap"]);
|
|
942
1054
|
arranged = arrangement(recipe, read, `${path}.recipe`, read.literal(recipe.layout, `${path}.recipe.layout`, REGION_LAYOUTS));
|
|
943
1055
|
}
|
|
944
1056
|
return {
|
|
@@ -959,6 +1071,9 @@ function regionPart(name, value, read, path, nested) {
|
|
|
959
1071
|
accessibility: accessibilityDeclaration(part.accessibility, part.frame !== void 0 && boxed === null, `${path}.accessibility`, read),
|
|
960
1072
|
when: states.treatments,
|
|
961
1073
|
textWhen: states.texts,
|
|
1074
|
+
geometryWhen: geometryStates(part.when, `${path}.when`, read, !0),
|
|
1075
|
+
geometryTransition: geometryTransition(part.geometryTransition, `${path}.geometryTransition`, read),
|
|
1076
|
+
collapsed: part.collapsed === void 0 ? !1 : read.boolean(part.collapsed, `${path}.collapsed`),
|
|
962
1077
|
effects: states.effects,
|
|
963
1078
|
plays: [...part.play === void 0 ? [] : [playSpec(part.play, null, `${path}.play`, read)], ...states.plays],
|
|
964
1079
|
normalize: normalized.values,
|
|
@@ -967,6 +1082,8 @@ function regionPart(name, value, read, path, nested) {
|
|
|
967
1082
|
enter: enterSpec(part.enter, `${path}.enter`, read),
|
|
968
1083
|
sticky: stickySpec(part.sticky, `${path}.sticky`, read),
|
|
969
1084
|
outset: outsetSpec(part.outset, `${path}.outset`, read),
|
|
1085
|
+
focusOf: focusSource(part.focus, `${path}.focus`, read),
|
|
1086
|
+
anchorClear: anchorClear(part.anchorClear, `${path}.anchorClear`, read),
|
|
970
1087
|
scheme: partScheme(part, content, path, read),
|
|
971
1088
|
pseudo: pseudoTreatments(part.pseudo, `${path}.pseudo`, read),
|
|
972
1089
|
arrangement: arranged,
|
|
@@ -975,10 +1092,29 @@ function regionPart(name, value, read, path, nested) {
|
|
|
975
1092
|
paints: runtimePaints(part.paints, `${path}.paints`, read)
|
|
976
1093
|
};
|
|
977
1094
|
}
|
|
1095
|
+
function anchorClear(value, path, read) {
|
|
1096
|
+
if (value === void 0)
|
|
1097
|
+
return null;
|
|
1098
|
+
const binding = read.object(value, path);
|
|
1099
|
+
read.only(binding, path, ["slot", "field"]);
|
|
1100
|
+
const slot = read.literal(binding.slot, `${path}.slot`, ["layer", "spacing"]);
|
|
1101
|
+
return { slot, field: read.literal(binding.field, `${path}.field`, [slot === "layer" ? "clearBlockStart" : "anchorGap"]) };
|
|
1102
|
+
}
|
|
1103
|
+
function focusSource(value, path, read) {
|
|
1104
|
+
if (value === void 0)
|
|
1105
|
+
return null;
|
|
1106
|
+
const declared = read.object(value, path);
|
|
1107
|
+
read.only(declared, path, ["of"]);
|
|
1108
|
+
return read.string(declared.of, `${path}.of`);
|
|
1109
|
+
}
|
|
978
1110
|
function parseParts(value, read, path, nested) {
|
|
979
1111
|
if (value === void 0)
|
|
980
1112
|
return [];
|
|
981
|
-
const parts = Object.entries(read.object(value, `${path}.parts`)).map(([name, part]) => regionPart(name, part, read, `${path}.parts.${name}`, nested))
|
|
1113
|
+
const parts = Object.entries(read.object(value, `${path}.parts`)).map(([name, part]) => regionPart(name, part, read, `${path}.parts.${name}`, nested));
|
|
1114
|
+
for (const part of parts)
|
|
1115
|
+
if (part.focusOf !== null && (part.focusOf === part.name || !parts.some((other) => other.name === part.focusOf)))
|
|
1116
|
+
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)");
|
|
1117
|
+
const schemed = parts.filter((part) => part.scheme !== null);
|
|
982
1118
|
for (const scheme of schemed.length === 0 ? [] : COLOR_SCHEMES) {
|
|
983
1119
|
const [first, second] = schemed.filter((part) => part.scheme === scheme), at = second ?? first ?? schemed[0];
|
|
984
1120
|
if (first === void 0 || second !== void 0)
|
|
@@ -1054,7 +1190,10 @@ function region(authored, read) {
|
|
|
1054
1190
|
"measured",
|
|
1055
1191
|
"paints",
|
|
1056
1192
|
"snap",
|
|
1057
|
-
"extent"
|
|
1193
|
+
"extent",
|
|
1194
|
+
"anchorClear",
|
|
1195
|
+
"overlap",
|
|
1196
|
+
"geometryTransition"
|
|
1058
1197
|
]);
|
|
1059
1198
|
const layout = spec.layout === void 0 ? "native" : read.literal(spec.layout, "recipe.layout", ROOT_LAYOUTS);
|
|
1060
1199
|
if (layout !== "prose") {
|
|
@@ -1066,7 +1205,7 @@ function region(authored, read) {
|
|
|
1066
1205
|
uniqueMeasured(measured, parts, read);
|
|
1067
1206
|
const paints = runtimePaints(spec.paints, "recipe.paints", read);
|
|
1068
1207
|
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);
|
|
1208
|
+
const exposeRows = spec.exposeRows === void 0 ? [] : read.strings(spec.exposeRows, "recipe.exposeRows"), rootStates = rootWhen(spec, read, !0), layer = layerSpec(spec.layer, read);
|
|
1070
1209
|
if (layer !== null && rootStates.pressedAt !== null)
|
|
1071
1210
|
read.reject({ kind: "field-unsupported", construction: "region", path: rootStates.pressedAt });
|
|
1072
1211
|
for (const row of exposeRows)
|
|
@@ -1092,7 +1231,10 @@ function region(authored, read) {
|
|
|
1092
1231
|
paintTransition: paintTransition(spec.paintTransition, "recipe.paintTransition", read),
|
|
1093
1232
|
enter: layer !== null && spec.enter !== void 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.enter" }) : enterSpec(spec.enter, "recipe.enter", read),
|
|
1094
1233
|
prose,
|
|
1234
|
+
anchorClear: layer !== null && spec.anchorClear !== void 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.anchorClear" }) : anchorClear(spec.anchorClear, "recipe.anchorClear", read),
|
|
1095
1235
|
textWhen: rootStates.texts,
|
|
1236
|
+
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),
|
|
1237
|
+
geometryTransition: geometryTransition(spec.geometryTransition, "recipe.geometryTransition", read),
|
|
1096
1238
|
frameAt: frameCondition(spec.at, regionFrame(spec.frame, read), read),
|
|
1097
1239
|
plays: layer !== null && rootStates.plays.length > 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.play" }) : rootStates.plays,
|
|
1098
1240
|
sticky: layer !== null && spec.sticky !== void 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.sticky" }) : stickySpec(spec.sticky, "recipe.sticky", read),
|