@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.
Files changed (114) hide show
  1. package/dist/ads-errors.mjs +110 -25
  2. package/dist/analysis/composition-axes.mjs +48 -0
  3. package/dist/analysis/construction-memo.mjs +38 -0
  4. package/dist/analysis/context.mjs +19 -0
  5. package/dist/analysis/design-reads.mjs +177 -0
  6. package/dist/analysis/factored-classes.mjs +90 -0
  7. package/dist/analysis/helpers.mjs +5 -7
  8. package/dist/analysis/native-project.mjs +12 -0
  9. package/dist/analysis/owner-analysis-cache.mjs +86 -23
  10. package/dist/analysis/owner-analysis-key.mjs +42 -10
  11. package/dist/analysis/owner-choices.mjs +23 -4
  12. package/dist/analysis/owner-composition.mjs +118 -33
  13. package/dist/analysis/owner-reuse.mjs +8 -6
  14. package/dist/analysis/owner-source.mjs +253 -76
  15. package/dist/analysis/scenario-keys.mjs +10 -7
  16. package/dist/analysis/service.mjs +50 -3
  17. package/dist/analysis/standalone.mjs +7 -4
  18. package/dist/analysis/syntax.mjs +59 -1
  19. package/dist/analysis/worker-protocol.mjs +14 -2
  20. package/dist/analysis/worker.mjs +32 -10
  21. package/dist/architecture-report.mjs +26 -0
  22. package/dist/asset-view-facts.mjs +16 -2
  23. package/dist/boundaries.mjs +26 -10
  24. package/dist/bun-compiler.mjs +2 -2
  25. package/dist/check-service.mjs +29 -17
  26. package/dist/check.mjs +13 -6
  27. package/dist/cli.mjs +1 -1
  28. package/dist/composed-keyline.mjs +2 -2
  29. package/dist/config.mjs +2 -1
  30. package/dist/construction-output.mjs +3 -2
  31. package/dist/construction-spec.d.mts +111 -6
  32. package/dist/construction-spec.mjs +172 -30
  33. package/dist/corner-overpaint.mjs +16 -4
  34. package/dist/derived-states.mjs +182 -0
  35. package/dist/design-inputs.mjs +18 -3
  36. package/dist/design-system-closure.mjs +12 -7
  37. package/dist/emit/contract.mjs +24 -5
  38. package/dist/emit/emission.mjs +6 -4
  39. package/dist/emit/integrity.mjs +8 -2
  40. package/dist/emit/output-watch.mjs +120 -0
  41. package/dist/emit/owner-emission-cache.mjs +4 -4
  42. package/dist/emit/preview-emitter.mjs +4 -2
  43. package/dist/emit/preview-tree.mjs +1 -1
  44. package/dist/emit/service.mjs +8 -2
  45. package/dist/finding-rules.mjs +3 -0
  46. package/dist/form-states.mjs +8 -0
  47. package/dist/frame-regions.mjs +29 -9
  48. package/dist/hover-geometry.mjs +15 -0
  49. package/dist/input-digests.mjs +17 -10
  50. package/dist/linaria/delivery.mjs +2 -0
  51. package/dist/lowering-properties.mjs +5 -0
  52. package/dist/lowering-region-layout.mjs +7 -2
  53. package/dist/mcp/build-status.mjs +9 -1
  54. package/dist/mcp/compiler-channel.mjs +11 -4
  55. package/dist/mcp/mutations.mjs +1 -0
  56. package/dist/mcp/preview-http.bundle.js +1 -1
  57. package/dist/mcp/preview-watch.mjs +2 -1
  58. package/dist/mcp/preview-widget.bundle.js +1 -1
  59. package/dist/motion-model.mjs +1 -1
  60. package/dist/owner-analysis-check.mjs +19 -5
  61. package/dist/owner-errors.mjs +4 -2
  62. package/dist/owner-lowering.mjs +71 -12
  63. package/dist/owner-scenarios.mjs +4 -1
  64. package/dist/ownership-model.mjs +18 -4
  65. package/dist/placeholder-contrast.mjs +17 -1
  66. package/dist/platform-features.mjs +10 -1
  67. package/dist/profile-view-facts.mjs +1 -1
  68. package/dist/recipe-macro.d.mts +72 -13
  69. package/dist/recipe-model.mjs +9 -5
  70. package/dist/region-lowering.mjs +238 -40
  71. package/dist/render-audit/layout-shift.page.mjs +24 -0
  72. package/dist/render-audit/render-states.mjs +122 -1
  73. package/dist/render-audit/render-states.page.mjs +140 -0
  74. package/dist/render-audit/worker.mjs +18 -3
  75. package/dist/render-audit.mjs +114 -1
  76. package/dist/role-vocabulary.d.mts +5 -0
  77. package/dist/role-vocabulary.mjs +12 -1
  78. package/dist/scenarios-compiler.mjs +20 -6
  79. package/dist/showcase/assets-view.mjs +29 -13
  80. package/dist/showcase/client.bundle.js +32 -32
  81. package/dist/showcase/http-client.bundle.js +15 -15
  82. package/dist/showcase/ui/ui.css +1 -1
  83. package/dist/showcase/ui/ui.js +4 -4
  84. package/dist/skills/ads-designer/references/accessibility.md +7 -0
  85. package/dist/skills/ads-designer/references/branding.md +13 -3
  86. package/dist/skills/ads-designer/references/contracts.md +5 -2
  87. package/dist/skills/ads-designer/references/design-data.md +1 -1
  88. package/dist/skills/ads-designer/references/layout.md +5 -1
  89. package/dist/skills/ads-designer/references/motion.md +9 -1
  90. package/dist/skills/ads-designer/references/recipes.md +27 -3
  91. package/dist/skills/ads-import/references/contracts.md +5 -2
  92. package/dist/skills/ads-import/references/design-data.md +1 -1
  93. package/dist/skills/ads-import/references/layout.md +5 -1
  94. package/dist/skills/ads-import/references/recipes.md +27 -3
  95. package/dist/skills/ads-migrate/SKILL.md +1 -0
  96. package/dist/skills/ads-migrate/references/0.5.1-to-0.5.2.md +185 -0
  97. package/dist/skills/ads-port/references/contracts.md +5 -2
  98. package/dist/skills/ads-port/references/design-data.md +1 -1
  99. package/dist/skills/ads-port/references/layout.md +5 -1
  100. package/dist/skills/ads-port/references/recipes.md +27 -3
  101. package/dist/surface-contrast.mjs +1 -0
  102. package/dist/surface-effects.mjs +5 -3
  103. package/dist/task-cache.mjs +8 -18
  104. package/dist/validation-checks.mjs +1 -1
  105. package/docs/ARCHITECTURE.md +63 -7
  106. package/docs/CACHING.md +152 -24
  107. package/docs/CHANGELOG.md +200 -23
  108. package/docs/GUIDE.md +45 -1
  109. package/docs/LANGUAGE.md +146 -8
  110. package/docs/MOTION.md +10 -2
  111. package/docs/PROFILE-KINDS.md +9 -1
  112. package/docs/RULES.md +22 -14
  113. package/docs/TOKEN-ROLES.md +7 -1
  114. package/package.json +1 -1
@@ -30,7 +30,7 @@ import { paintContrast } from "./paint-contrast.mjs";
30
30
  import { PROSE_BLOCKS, PROSE_COMPONENT, PROSE_ELEMENTS, PROSE_ELEMENT_NAMES, PROSE_FIRST, proseContents, proseDefaults, proseSelector, proseState } from "./prose-model.mjs";
31
31
  import { textMinimum } from "./surface-contrast.mjs";
32
32
  import { tokenValueContexts } from "./design-foundation.mjs";
33
- import { checkPlaceholderContrast } from "./placeholder-contrast.mjs";
33
+ import { checkPlaceholderContrast, checkProgressContrast } from "./placeholder-contrast.mjs";
34
34
  import { fixedLength, lowerLayer, openState, ownsPlacement } from "./lowering-layer.mjs";
35
35
  import { RATIO_SUFFIX, focalPosition, intrinsicInlineSize, measuredFallback, measuredProperty, measuredWrites, positions } from "./measured-geometry.mjs";
36
36
  import { paintProperty, paintTokens, paintWrites } from "./runtime-paint.mjs";
@@ -44,6 +44,7 @@ import {
44
44
  conditionValues,
45
45
  elementNormalization,
46
46
  extentValues,
47
+ growsWithContent,
47
48
  frameInsets,
48
49
  frameRules,
49
50
  layeredValues,
@@ -89,11 +90,91 @@ function arrangementValues(arrangement, slots, profile, overflow = { kind: "visi
89
90
  const spacingReference = slots["spacing-profile"];
90
91
  if (spacingReference !== void 0) {
91
92
  const spacing = profile.of(spacingReference, "spacing"), field = arrangement.gap === null ? "content-gap" : kebab(arrangement.gap.field);
92
- values[layout === "flow" ? "row-gap" : "gap"] = profile.field(spacing, "spacing", field);
93
+ if (arrangement.overlap === null)
94
+ values[layout === "flow" ? "row-gap" : "gap"] = profile.field(spacing, "spacing", field);
93
95
  } else if (arrangement.gap !== null)
94
96
  profile.field({}, "spacing-profile", kebab(arrangement.gap.field));
95
97
  return values;
96
98
  }
99
+ function overlapValue(arrangement, slots, profile) {
100
+ if (arrangement === null || arrangement.overlap === null)
101
+ return null;
102
+ return profile.field(profile.of(slots["spacing-profile"], "spacing", "overlap"), "spacing", kebab(arrangement.overlap.by.field));
103
+ }
104
+ const OVERLAPPED = "> * + *", overlapMargin = (arrangement) => arrangement.layout === "stack" ? "margin-block-start" : "margin-inline-start";
105
+ function geometryChannel(property) {
106
+ if (/^(?:min-|max-)?(?:inline|block)-size$/.test(property) || property === "grid-template-columns" || property === "grid-template-rows")
107
+ return "size";
108
+ if (property.startsWith("padding-"))
109
+ return "inset";
110
+ if (property === "gap" || property === "row-gap")
111
+ return "gap";
112
+ if (property.includes("radius"))
113
+ return "radius";
114
+ if (/^border-.*width$/.test(property))
115
+ return "border-width";
116
+ return null;
117
+ }
118
+ const collapsedValues = (collapsed, axis) => ({
119
+ [`${axis}-size`]: collapsed ? "0" : "auto",
120
+ opacity: collapsed ? "0" : "1",
121
+ visibility: collapsed ? "hidden" : "visible"
122
+ }), collapsibleValues = (axis) => ({ "flex-grow": "0", "flex-shrink": "0", "flex-basis": "auto", [`min-${axis}-size`]: "0", overflow: "clip", "interpolate-size": "allow-keywords" });
123
+ function writeStateGeometry(path, element, rest, states, transition, frameOf, context) {
124
+ const { out, profile, slots, reject } = context, unsupported = (reason, detail) => reject({ kind: "state-geometry-unsupported", element, reason, detail }), changed = new Set, overlapStates = new Map, gaps = [], restOverlap = overlapValue(rest.arrangement, slots, profile), differing = (base, state) => Object.fromEntries(Object.entries(state).filter(([property, value]) => base[property] !== value));
125
+ for (const state of states) {
126
+ const values = {};
127
+ if (state.frame !== null) {
128
+ if (rest.frame === null)
129
+ return unsupported("frame-missing", state.frame);
130
+ const framed = frameOf(state.frame), dropped = Object.keys(rest.frame).find((property) => framed[property] === void 0);
131
+ if (dropped !== void 0)
132
+ return unsupported("field-dropped", dropped);
133
+ Object.assign(values, differing(rest.frame, framed));
134
+ }
135
+ if (state.spacing !== null && rest.arrangement !== null) {
136
+ const stated = { ...slots, "spacing-profile": state.spacing };
137
+ Object.assign(values, differing(rest.arranged, arrangementValues(rest.arrangement, stated, profile)));
138
+ const overlap = overlapValue(rest.arrangement, stated, profile);
139
+ if (overlap !== null && overlap !== restOverlap) {
140
+ out.rule(`${under(state.condition, path)} ${OVERLAPPED}`, { [overlapMargin(rest.arrangement)]: `calc(-1 * ${overlap})` });
141
+ overlapStates.set(state.condition, `calc(-1 * ${overlap})`);
142
+ }
143
+ }
144
+ if (state.collapsed !== null && rest.collapsed !== null && rest.axis !== null && state.collapsed !== rest.collapsed)
145
+ Object.assign(values, collapsedValues(state.collapsed, rest.axis));
146
+ for (const property of Object.keys(values))
147
+ changed.add(property);
148
+ if (values.gap !== void 0)
149
+ gaps.push(values.gap);
150
+ if (Object.keys(values).length > 0)
151
+ out.rule(under(state.condition, path), values);
152
+ if (state.condition.includes(":hover")) {
153
+ const same = (other) => other.frame === state.frame && other.spacing === state.spacing && other.collapsed === state.collapsed;
154
+ if (!states.some((other) => other !== state && same(other) && !other.condition.includes(":hover") && /:focus|\[/.test(other.condition)))
155
+ return unsupported("hover-only", state.condition);
156
+ }
157
+ }
158
+ const overlapChanges = overlapStates.size > 0, parentOverlap = (group) => restOverlap === null || rest.arrangement === null ? null : { property: overlapMargin(rest.arrangement), base: `calc(-1 * ${restOverlap})`, states: overlapStates, group };
159
+ if (transition === null)
160
+ return { group: null, overlap: parentOverlap(null), gaps };
161
+ const timing = transitionTiming(motionFields(transition.motion, slots, profile), profile, reject), channelOf = (property) => geometryChannel(property);
162
+ for (const channel of transition.channels) {
163
+ if (channel === "overlap")
164
+ continue;
165
+ if (!([...changed].some((property) => channelOf(property) === channel) || channel === "gap" && overlapChanges))
166
+ return unsupported("channel-unused", channel);
167
+ }
168
+ const listed = (property) => {
169
+ const channel = channelOf(property);
170
+ return channel !== null && transition.channels.includes(channel);
171
+ }, fading = [...changed].filter((property) => (property === "opacity" || property === "visibility") && transition.channels.includes("size")), placed = transition.channels.includes("overlap") ? ["margin-inline-start", "margin-block-start"] : [], properties = [...[...changed].filter(listed), ...fading, ...placed];
172
+ return {
173
+ group: properties.length === 0 ? null : { properties, timing },
174
+ overlap: parentOverlap(overlapChanges && transition.channels.includes("gap") && rest.arrangement !== null ? { properties: [overlapMargin(rest.arrangement)], timing } : null),
175
+ gaps
176
+ };
177
+ }
97
178
  const FRAME_FIELDS = [...FRAME_INSET_FIELDS, ...FRAME_SIDE_WIDTH_FIELDS, BORDER_STYLE, "border-width", "radius", "min-block-size", "block-size", "max-block-size", "inline-size", "min-inline-size", "max-inline-size", ...HIT_AREA_FIELDS], isHitAreaField = (field) => HIT_AREA_FIELDS.some((name) => name === field);
98
179
  export function frameValues(frame, profile, reject, sides = { kind: "profile" }) {
99
180
  profile.only(frame, "frame", FRAME_FIELDS);
@@ -196,8 +277,13 @@ function stickyValues(sticky, { profile, slots }) {
196
277
  ...layer["sticky-layer"] === void 0 ? {} : { "z-index": layer["sticky-layer"] }
197
278
  };
198
279
  }
280
+ function anchorClearValues(binding, { profile, slots }) {
281
+ if (binding === null)
282
+ return {};
283
+ return { "scroll-margin-block-start": binding.slot === "layer" ? profile.field(profile.of(slots["layer-profile"], "layer", "anchorClear"), "layer", "clear-block-start") : profile.field(profile.of(slots["spacing-profile"], "spacing", "anchorClear"), "spacing", "anchor-gap") };
284
+ }
199
285
  function lowerProse(prose, root, context) {
200
- const { out, profile, slots, foundation, reject } = context, spacing = (binding) => profile.field(profile.of(slots["spacing-profile"], "spacing", "prose"), "spacing", kebab(binding.field)), rhythm = prose.rhythm === null ? null : spacing(prose.rhythm), declared = new Map(prose.elements.map((element) => [element.name, element])), paints = new Map;
286
+ const { out, profile, slots, foundation, reject } = context, spacing = (binding) => profile.field(profile.of(slots["spacing-profile"], "spacing", "prose"), "spacing", kebab(binding.field)), rhythm = prose.rhythm === null ? null : spacing(prose.rhythm), declared = new Map(prose.elements.map((element) => [element.name, element])), componentBefore = prose.component?.spaceBefore == null ? null : spacing(prose.component.spaceBefore), componentAfter = prose.component?.spaceAfter == null ? null : spacing(prose.component.spaceAfter), following = (level) => ":not(:first-child)".repeat(level), paints = new Map;
201
287
  for (const name of PROSE_ELEMENT_NAMES) {
202
288
  const element = declared.get(name), block = PROSE_BLOCKS.includes(name);
203
289
  if (element === void 0 && (!block || rhythm === null) && Object.keys(proseDefaults(name)).length === 0)
@@ -209,6 +295,7 @@ function lowerProse(prose, root, context) {
209
295
  ...proseDefaults(name),
210
296
  ...block && (before !== null || element !== void 0) ? { "margin-block-start": before ?? "0", "margin-block-end": "0" } : {},
211
297
  ...element?.indent == null ? {} : { "padding-inline-start": spacing(element.indent) },
298
+ ...anchorClearValues(element?.anchorClear ?? null, context),
212
299
  ...text,
213
300
  ...frame,
214
301
  ...surface
@@ -225,6 +312,19 @@ function lowerProse(prose, root, context) {
225
312
  return reject({ kind: "profile-field-unsupported", profile: element.marker, field: other ?? "color", value: other === void 0 ? "" : fields[other] ?? "" });
226
313
  out.rule(`${selector}::marker`, { color: fields.color });
227
314
  }
315
+ if (element?.markerText != null)
316
+ out.rule(`${selector}::marker`, { "font-weight": profile.field(profile.of(element.markerText, "text"), "text", "font-weight") });
317
+ if (element?.spaceAfter != null) {
318
+ const after = spacing(element.spaceAfter);
319
+ out.rule(`${selector} + :not([class])`, { "margin-block-start": after });
320
+ out.rule(`${selector} + [class]${following(1)}`, { "margin-block-start": componentBefore === null ? after : `max(${after}, ${componentBefore})` });
321
+ for (const next of prose.elements)
322
+ if (next.spaceBefore !== null)
323
+ for (const nextTag of PROSE_ELEMENTS[next.name])
324
+ out.rule(`${selector} + ${nextTag}:not([class])`, { "margin-block-start": `max(${after}, ${spacing(next.spaceBefore)})` });
325
+ }
326
+ if (tag === "ul")
327
+ (element?.markers ?? []).forEach((shape, depth) => out.rule(`& ${"ul:not([class]) ".repeat(depth)}ul:not([class])`, { "list-style-type": shape }));
228
328
  }
229
329
  if (element !== void 0)
230
330
  paints.set(name, { paints: [surface, ...states.map(([, fields]) => fields)].map((fields) => ({ color: fields.color ?? null, background: fields.background ?? null })), text });
@@ -232,8 +332,16 @@ function lowerProse(prose, root, context) {
232
332
  if (rhythm !== null || prose.elements.some((element) => element.spaceBefore !== null))
233
333
  for (const selector of PROSE_FIRST)
234
334
  out.rule(selector, { "margin-block-start": "0" });
235
- if (rhythm !== null)
236
- out.rule(PROSE_COMPONENT, { "margin-block-start": rhythm });
335
+ if (componentBefore !== null || rhythm !== null)
336
+ out.rule(PROSE_COMPONENT, { "margin-block-start": componentBefore ?? rhythm ?? "0" });
337
+ if (componentAfter !== null) {
338
+ out.rule(`& > [class] + :not([class])${following(2)}`, { "margin-block-start": componentAfter });
339
+ out.rule(`& > [class] + [class]${following(3)}`, { "margin-block-start": componentBefore === null ? componentAfter : `max(${componentAfter}, ${componentBefore})` });
340
+ for (const next of prose.elements)
341
+ if (next.spaceBefore !== null)
342
+ for (const tag of PROSE_ELEMENTS[next.name])
343
+ out.rule(`& > [class] + ${tag}:not([class])${following(2)}`, { "margin-block-start": `max(${componentAfter}, ${spacing(next.spaceBefore)})` });
344
+ }
237
345
  const base = { color: root.color ?? null, background: root.background ?? null }, colored = [...paints].filter(([, entry]) => entry.paints.some((paint) => paint.color !== null || paint.background !== null));
238
346
  if (colored.length === 0)
239
347
  return;
@@ -269,7 +377,7 @@ function partMotion(path, effects, { out, profile, slots, reject }) {
269
377
  if (effects === null)
270
378
  return null;
271
379
  const motion = motionFields(effects.motion, slots, profile), timing = transitionTiming(motion, profile, reject), channels = new Set(effects.when.flatMap(([, names]) => names.map((name) => PART_EFFECTS[name].channel)));
272
- out.rule(path, { ...channels.has("translate") ? { translate: "0px" } : {}, ...channels.has("scale") ? { scale: "1" } : {} });
380
+ out.rule(path, { ...channels.has("translate") ? { translate: "0px" } : {}, ...channels.has("scale") ? { scale: "1" } : {}, ...channels.has("rotate") ? { rotate: "0deg" } : {} });
273
381
  const distance = () => profile.field(motion, "motion", "distance");
274
382
  for (const [condition, names] of effects.when) {
275
383
  const selector = under(condition, path), inline = names.includes("translateInline"), block = names.includes("translateBlock"), travel = (sign) => block ? `${inline ? sign : "0px"} ${distance()}` : sign, values = {};
@@ -278,6 +386,8 @@ function partMotion(path, effects, { out, profile, slots, reject }) {
278
386
  const scaled = names.find((name) => PART_EFFECTS[name].channel === "scale");
279
387
  if (scaled === "scale" || scaled === "scaleInline" || scaled === "scaleBlock")
280
388
  values.scale = scaleValue(scaled, profile.field(motion, "motion", "scale"));
389
+ if (names.includes("rotate"))
390
+ values.rotate = profile.field(motion, "motion", "angle");
281
391
  out.rule(selector, values);
282
392
  const mirrored = under(`${condition}:dir(rtl)`, path);
283
393
  if (inline)
@@ -313,22 +423,41 @@ function pseudoColor(treatment, surface, profile, reject) {
313
423
  return fields.color ?? reject({ kind: "pseudo-surface-unsupported", pseudo: treatment.pseudo, surface, field: null });
314
424
  }
315
425
  function pseudoRules(part, path, context) {
316
- const { out, profile, reject, foundation } = context;
317
- for (const treatment of part.pseudo) {
318
- const suffix = `::${treatment.pseudo}`, base = pseudoColor(treatment, treatment.surface, profile, reject), states = treatment.when.map(([condition, surface]) => ({ condition, value: pseudoColor(treatment, surface, profile, reject) }));
319
- out.rule(`${path}${suffix}`, { color: base, opacity: "1" });
320
- for (const { condition, value } of states)
321
- out.rule(`${under(condition, path)}${suffix}`, { color: value });
322
- const colors = [{ condition: null, value: base }, ...states];
426
+ const { out, profile, reject, foundation } = context, background = (surface) => surface === null ? null : profile.of(surface, "surface").background ?? null, fills = [{ condition: null, value: background(part.surface) }, ...part.when.map(([condition, surface]) => ({ condition, value: background(surface) }))];
427
+ for (const treatment of part.pseudo)
323
428
  switch (treatment.pseudo) {
324
429
  case "placeholder": {
325
- const background = (surface) => surface === null ? null : profile.of(surface, "surface").background ?? null, fills = [{ condition: null, value: background(part.surface) }, ...part.when.map(([condition, surface]) => ({ condition, value: background(surface) }))], checked = checkPlaceholderContrast(foundation, part.name, colors, fills);
430
+ const suffix = "::placeholder", base = pseudoColor(treatment, treatment.surface, profile, reject), states = treatment.when.map(([condition, surface]) => ({ condition, value: pseudoColor(treatment, surface, profile, reject) }));
431
+ out.rule(`${path}${suffix}`, { color: base, opacity: "1" });
432
+ for (const { condition, value } of states)
433
+ out.rule(`${under(condition, path)}${suffix}`, { color: value });
434
+ const checked = checkPlaceholderContrast(foundation, part.name, [{ condition: null, value: base }, ...states], fills);
435
+ if (checked.kind === "err")
436
+ return reject(checked.error);
437
+ break;
438
+ }
439
+ case "progressValue": {
440
+ const base = pseudoFill(treatment, treatment.surface, profile, reject), states = treatment.when.map(([condition, surface]) => ({ condition, value: pseudoFill(treatment, surface, profile, reject) }));
441
+ out.rule(path, { appearance: "none", "-webkit-appearance": "none", ...part.box === null ? { "border-style": "none" } : {} });
442
+ out.rule(`${path}::-webkit-progress-bar`, { background: "transparent" });
443
+ for (const suffix of PROGRESS_FILLS) {
444
+ out.rule(`${path}${suffix}`, { background: base, "border-radius": "inherit" });
445
+ for (const { condition, value } of states)
446
+ out.rule(`${under(condition, path)}${suffix}`, { background: value });
447
+ }
448
+ const checked = checkProgressContrast(foundation, part.name, [{ condition: null, value: base }, ...states], fills);
326
449
  if (checked.kind === "err")
327
450
  return reject(checked.error);
328
451
  break;
329
452
  }
330
453
  }
331
- }
454
+ }
455
+ const PROGRESS_FILLS = ["::-webkit-progress-value", "::-moz-progress-bar"];
456
+ function pseudoFill(treatment, surface, profile, reject) {
457
+ const fields = profile.of(surface, "surface"), other = Object.keys(fields).find((field) => field !== "background");
458
+ if (other !== void 0)
459
+ return reject({ kind: "pseudo-surface-unsupported", pseudo: treatment.pseudo, surface, field: other });
460
+ return fields.background ?? reject({ kind: "pseudo-surface-unsupported", pseudo: treatment.pseudo, surface, field: null });
332
461
  }
333
462
  const covers = (visual) => visual.fit === "cover", COVER_FILL = { display: "block", "inline-size": "100%", "block-size": "100%", "min-block-size": "0", "object-fit": "cover" };
334
463
  function normalizeElement(spec, name, path, values, provided, context) {
@@ -367,8 +496,20 @@ function lowerVector(part, stroke, path, context) {
367
496
  out.rule(under(condition, path), { ...checked(vectorStateValues(part.name, surface, profile.of(surface, "surface")), reject) });
368
497
  writeConditioned(part, path, {}, context);
369
498
  }
370
- function lowerParts(parts, parent, layout, gap, context) {
371
- const lowered = parts.map((part) => lowerPart(part, parent, layout, context));
499
+ function lowerParts(parts, parent, layout, gap, context, parentGrows = !1, overlapping = null, stateGaps = []) {
500
+ for (const part of parts) {
501
+ const source = part.focusOf === null ? void 0 : parts.find((other) => other.name === part.focusOf);
502
+ if (source === void 0)
503
+ continue;
504
+ const focus = context.profile.of(context.slots["focus-profile"], "focus", part.name);
505
+ context.out.rule(`${parent}:has(> ${source.selector}:focus-visible) > ${part.selector}`, {
506
+ "outline-width": context.profile.field(focus, "focus", "width"),
507
+ "outline-color": context.profile.field(focus, "focus", "color"),
508
+ "outline-offset": context.profile.field(focus, "focus", "offset"),
509
+ "outline-style": "solid"
510
+ });
511
+ }
512
+ const lowered = parts.map((part) => lowerPart(part, parent, layout, context, parentGrows, overlapping));
372
513
  if (layout !== "inline" && layout !== "stack")
373
514
  return;
374
515
  const axes = layout === "inline" ? ["inline"] : ["block"];
@@ -376,20 +517,57 @@ function lowerParts(parts, parent, layout, gap, context) {
376
517
  const second = lowered[index + 1];
377
518
  if (first === null || second === null || second === void 0)
378
519
  return;
520
+ if (overlapping !== null)
521
+ return context.reject({ kind: "state-geometry-unsupported", element: parent === "&" ? "&" : parent, reason: "targets-overlap", detail: `${first.element} and ${second.element}` });
379
522
  for (const axis of axes)
380
- context.neighbours.push({ axis, gap: gap ?? "0px", first, second });
523
+ for (const between of [gap ?? "0px", ...stateGaps])
524
+ context.neighbours.push({ axis, gap: between, first, second });
381
525
  });
382
526
  }
383
- function lowerPart(part, parent, parentLayout, context) {
527
+ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping = null) {
384
528
  const { out, profile, slots, reject } = context, path = `${parent} > ${part.selector}`;
385
529
  if (part.content.kind === "vector") {
386
530
  lowerVector(part, part.content.stroke, path, context);
387
531
  return null;
388
532
  }
389
- const partSurface = part.surface === null ? {} : profile.of(part.surface, "surface"), moving = partMotion(path, part.effects, context), partGroups = [...moving === null ? [] : [moving], ...measuredMotion(part.measured, profile, reject)], moved = part.effects === null ? [] : [...new Set(part.effects.when.flatMap(([, names]) => names.map((name) => PART_EFFECTS[name].channel)))], entering = writeEnter(out, profile, path, part.enter, partSurface, stateSurfaces(path, part.when, profile), slots, [...transitioned(part.paintTransition, partGroups), ...moved], reject);
533
+ const partSurface = part.surface === null ? {} : profile.of(part.surface, "surface"), moving = partMotion(path, part.effects, context), collapsible = part.collapsed || part.geometryWhen.some((state) => state.collapsed !== null), axis = parentLayout === "inline" ? "inline" : parentLayout === "stack" ? "block" : null;
534
+ if (collapsible) {
535
+ if (axis === null)
536
+ return reject({ kind: "state-geometry-unsupported", element: part.name, reason: "collapsed-parent", detail: parentLayout });
537
+ const own = part.box !== null || part.frame !== null ? "a frame" : part.arrangement !== null ? "an arrangement" : part.overflow.kind !== "visible" ? "an overflow" : part.extent.kind === "fill" ? "a filling extent" : null;
538
+ if (own !== null)
539
+ return reject({ kind: "state-geometry-unsupported", element: part.name, reason: "collapsed-box", detail: own });
540
+ }
541
+ const restBox = part.box === null ? null : frameValues(profile.of(part.box, "frame"), profile, reject), partGeometry = writeStateGeometry(path, part.name, {
542
+ frame: restBox,
543
+ arrangement: part.arrangement,
544
+ arranged: part.arrangement === null ? {} : arrangementValues(part.arrangement, slots, profile, part.overflow),
545
+ collapsed: collapsible ? part.collapsed : null,
546
+ axis
547
+ }, part.geometryWhen, part.geometryTransition, (name) => frameValues(profile.of(name, "frame"), profile, reject), context);
548
+ if (partGeometry.overlap !== null)
549
+ out.rule(`${path} ${OVERLAPPED}`, { [partGeometry.overlap.property]: partGeometry.overlap.base });
550
+ if (collapsible && overlapping !== null) {
551
+ const own = `${path}:not(:first-child)`;
552
+ if (part.collapsed)
553
+ out.rule(own, { [overlapping.property]: "0px" });
554
+ for (const state of part.geometryWhen) {
555
+ if (state.collapsed === null)
556
+ continue;
557
+ out.rule(under(state.condition, own), { [overlapping.property]: state.collapsed ? "0px" : overlapping.states.get(state.condition) ?? overlapping.base });
558
+ }
559
+ }
560
+ const partGroups = [
561
+ ...moving === null ? [] : [moving],
562
+ ...measuredMotion(part.measured, profile, reject),
563
+ ...partGeometry.group === null ? [] : [partGeometry.group],
564
+ ...overlapping === null || overlapping.group === null || partGeometry.group?.properties.includes(overlapping.property) === !0 ? [] : [overlapping.group]
565
+ ], moved = part.effects === null ? [] : [...new Set(part.effects.when.flatMap(([, names]) => names.map((name) => PART_EFFECTS[name].channel)))], entering = writeEnter(out, profile, path, part.enter, partSurface, stateSurfaces(path, part.when, profile), slots, [...transitioned(part.paintTransition, partGroups), ...moved], reject);
390
566
  transitionRules(path, part.paintTransition, part.surface === null ? null : { name: part.surface, fields: partSurface }, part.when, context, entering === null ? partGroups : [...partGroups, entering.group]);
391
567
  writePlays(out, profile, context.foundation, part.name, part.plays, path, [...transitioned(part.paintTransition, entering === null ? [] : [entering.group]), ...moved], reject);
392
568
  const values = part.arrangement === null ? {} : { "box-sizing": "border-box", "min-inline-size": "0", ...arrangementValues(part.arrangement, slots, profile, part.overflow) };
569
+ if (collapsible && axis !== null)
570
+ Object.assign(values, collapsibleValues(axis), collapsedValues(part.collapsed, axis));
393
571
  if (part.arrangement?.layout === "layered")
394
572
  checked(checkLayers(part.name, part.parts.length), reject);
395
573
  const text = part.text !== null ? textOf(part.text, slots, profile) : part.content.kind === "text" && slots["text-profile"] !== void 0 ? profile.of(slots["text-profile"], "text") : {};
@@ -400,9 +578,10 @@ function lowerPart(part, parent, parentLayout, context) {
400
578
  checkSurfaceEffects(context.foundation, profile, [part.surface, ...part.when.map(([, name]) => name)], part.content.kind === "visual" ? "visual" : part.overflow.kind === "scroll" ? "scroller" : "container", reject);
401
579
  if (part.surface !== null)
402
580
  Object.assign(values, settled(partSurface, entering?.blurred ?? !1));
403
- Object.assign(values, stickyValues(part.sticky, context));
581
+ Object.assign(values, stickyValues(part.sticky, context), anchorClearValues(part.anchorClear, context));
582
+ const boxFields = part.box === null ? {} : frameValues(profile.of(part.box, "frame"), profile, reject);
404
583
  if (part.box !== null)
405
- Object.assign(values, { "box-sizing": "border-box" }, frameValues(profile.of(part.box, "frame"), profile, reject));
584
+ Object.assign(values, { "box-sizing": "border-box" }, boxFields);
406
585
  let target = null, frameFields = {};
407
586
  if (part.frame !== null) {
408
587
  const lineHeight = profile.field(text, "text", "line-height"), frame = profile.of(slots["frame-profile"], "frame", "control"), box = controlBox(frame, LINE_BOX, profile.field, reject);
@@ -441,38 +620,39 @@ function lowerPart(part, parent, parentLayout, context) {
441
620
  const partSnap = part.arrangement?.snap ?? null, snapped = partSnap === null ? null : checked(snapValues(partSnap, part.overflow, part.name), reject);
442
621
  if (snapped !== null)
443
622
  add(snapped.container, "snap");
444
- add(checked(extentValues(part.extent, parentLayout, part.name), reject), "extent");
623
+ add(checked(extentValues(part.extent, parentLayout, part.name, parentGrows), reject), "extent");
445
624
  if (parentLayout === "layered")
446
625
  add(LAYER, "layer");
447
626
  if (part.outset !== null) {
448
627
  if (parentLayout !== "layered" || part.parts.length > 0 || part.content.kind === "text")
449
628
  return reject({ kind: "outset-unsupported", part: part.name });
450
- const spacing = (binding) => binding === null ? null : profile.field(profile.of(slots["spacing-profile"], "spacing", "outset"), "spacing", kebab(binding.field)), [block, inline] = [spacing(part.outset.block), spacing(part.outset.inline)];
451
- add({ ...block === null ? {} : { "margin-block": `calc(-1 * ${block})` }, ...inline === null ? {} : { "margin-inline": `calc(-1 * ${inline})` } }, "outset");
629
+ const spacing = (binding) => binding === null ? null : profile.field(profile.of(slots["spacing-profile"], "spacing", "outset"), "spacing", kebab(binding.field)), [block, inline] = [spacing(part.outset.block), spacing(part.outset.inline)], share = (value) => context.foundation.tokens.get(/^var\(\s*(--[\w-]+)\s*\)$/.exec(value)?.[1] ?? "")?.role === "box-share", outset = (axis, value) => value === null ? {} : axis === "block" && share(value) ? { "block-size": `calc(100% + 2 * ${value})`, "align-self": "center" } : { [`margin-${axis}`]: `calc(-1 * ${value})` };
630
+ add({ ...outset("block", block), ...outset("inline", inline) }, "outset");
452
631
  }
453
632
  normalizeElement(part, part.name, path, values, provided, context);
454
633
  const twice = part.normalize.find(([property]) => context.rootNormalized.get(path)?.includes(property));
455
634
  if (twice !== void 0)
456
635
  return reject({ kind: "extent-conflict", element: part.name, property: twice[0], providers: ["recipe.normalize.when", "normalize"] });
457
636
  add(normalizedDeclarations(part.normalize), "normalize");
458
- const media = part.measured.some((value) => value.type === "position" || value.type === "intrinsic-size") && part.content.kind === "visual" && context.input.visual?.kind === "content-media" ? covers(profile.of(slots["visual-profile"], "visual", "visual")) ? "cover" : "contain" : null;
637
+ const media = part.measured.some((value) => value.type === "position" || value.type === "intrinsic-size") && part.content.kind === "visual" && visualOf(context.input, part.name)?.kind === "content-media" ? covers(profile.of(slots["visual-profile"], "visual", "visual")) ? "cover" : "contain" : null;
459
638
  Object.assign(values, checked(measuredWrites(context.input.scope, part.measured, part.name, values, part.frame !== null ? supplied(slots, frameFields) : null, media), reject));
460
639
  Object.assign(values, paintValues(part.name, part.paints, "box", [part.surface], part.when, context));
461
640
  writeConditioned(part, path, values, context);
462
641
  const conditioned = conditionedVisual(part, context);
463
- if (part.scheme !== null && context.input.visual?.kind !== "content-media")
642
+ if (part.scheme !== null && visualOf(context.input, part.name)?.kind !== "content-media")
464
643
  return reject({ kind: "scheme-unsupported", part: part.name });
465
644
  if (part.content.kind === "visual")
466
- lowerVisual(path, context, part.measured.find((value) => value.type === "intrinsic-size") ?? null, conditioned, part.scheme);
645
+ lowerVisual(path, context, part.measured.find((value) => value.type === "intrinsic-size") ?? null, conditioned, part.scheme, boxFields, part.name);
467
646
  if (snapped !== null)
468
647
  out.rule(`${path} > *`, { ...snapped.children });
469
648
  stateRules(out, path, part.when, profile, entering?.blurred ?? !1);
470
649
  for (const [condition, normalized] of part.normalizeWhen)
471
650
  out.rule(under(condition, path), normalizedDeclarations(normalized));
472
651
  pseudoRules(part, path, context);
473
- lowerParts(part.parts, path, part.arrangement?.layout ?? "native", values.gap, context);
652
+ lowerParts(part.parts, path, part.arrangement?.layout ?? "native", values.gap, context, growsWithContent(values), partGeometry.overlap, partGeometry.gaps);
474
653
  return target;
475
654
  }
655
+ const visualOf = (input, part) => input.visuals?.get(part) ?? input.visual;
476
656
  function conditionedVisual(part, context) {
477
657
  const { profile, slots, foundation, reject } = context, [condition] = part.at;
478
658
  if (condition === void 0 || condition.visual === null)
@@ -484,8 +664,8 @@ function conditionedVisual(part, context) {
484
664
  return reject({ kind: "condition-unknown", part: part.name, condition: condition.condition, spatial: spatial ?? null });
485
665
  return { part: part.name, condition: condition.condition, profile: condition.visual, query: ["media", conditionQueries(bound).inside] };
486
666
  }
487
- function lowerVisual(path, context, intrinsic, conditioned = null, scheme = null) {
488
- const { out, profile, slots, input, reject } = context, { visual } = input;
667
+ function lowerVisual(path, context, intrinsic, conditioned = null, scheme = null, box = {}, partName = null) {
668
+ const { out, profile, slots, input, reject } = context, inBox = (part) => Object.fromEntries(Object.entries(part).filter(([property]) => !((property === "inline-size" || property === "block-size") && box[property] !== void 0))), visual = partName === null ? input.visual : visualOf(input, partName);
489
669
  if (visual === null)
490
670
  return reject({ kind: "artwork-binding-missing" });
491
671
  if (scheme !== null)
@@ -531,21 +711,25 @@ function lowerVisual(path, context, intrinsic, conditioned = null, scheme = null
531
711
  out.rule(path, { display: "block", "inline-size": "100%", "block-size": "100%", "min-block-size": "0" });
532
712
  out.rule(`${path} > ${artwork.element}`, { ...COVER_FILL, "object-position": focalPosition(artwork.drawing.center) });
533
713
  context.placedArtwork.push(artwork);
714
+ if (partName !== null)
715
+ context.placedByPart.set(partName, artwork);
534
716
  return;
535
717
  }
536
718
  const geometry = visualPart(visual.asset, visualProfile, visual.state, visual.theme, reject);
537
- out.rule(path, geometry.part);
719
+ out.rule(path, inBox(geometry.part));
538
720
  out.rule(`${path} > ${geometry.element}`, geometry.media);
539
721
  if (conditioned !== null && inCondition !== null) {
540
722
  const other = visualPart(visual.asset, inCondition, visual.state, visual.theme, reject);
541
723
  if (other.source !== geometry.source || other.element !== geometry.element)
542
724
  return unsupported("drawing-differs");
543
- out.rule(path, other.part, conditioned.query);
725
+ out.rule(path, inBox(other.part), conditioned.query);
544
726
  out.rule(`${path} > ${other.element}`, other.media, conditioned.query);
545
727
  }
546
728
  if (visual.asset.paint === "slots")
547
729
  out.paint(path.replace(/^& > /, ""), [...visual.asset.slots].map(([slot, value]) => ({ slot, paint: value === "currentColor" ? { kind: "current-color" } : { kind: "token", name: value } })));
548
730
  context.placedArtwork.push(placed(geometry));
731
+ if (partName !== null)
732
+ context.placedByPart.set(partName, placed(geometry));
549
733
  }
550
734
  function layerInput(layer, spec, root, slots, profile, foundation, reject) {
551
735
  if ((slots["surface-profile"] ?? spec.surface) === null)
@@ -618,9 +802,25 @@ export function lowerRegion(spec, foundation, input) {
618
802
  out.own(paintProperty(input.scope, paint.name));
619
803
  for (const token of paintTokens(paints))
620
804
  out.use(`var(${token})`);
621
- const placedArtwork = [], targets = [], neighbours = [], rootNormalized = new Map(spec.normalizeWhen.map(([selector, normalized]) => [selector, normalized.map(([property]) => property)])), coverBox = spec.frame !== null && (spec.frame.kind === "fields" && spec.frame.ratio !== null || slots["frame-profile"] !== void 0 && profile.of(slots["frame-profile"], "frame")["block-size"] !== void 0), context = { out, profile, slots, input, reject, placedArtwork, foundation, targets, neighbours, rootNormalized, coverBox }, surface = slots["surface-profile"] ?? spec.surface;
805
+ const placedArtwork = [], placedByPart = new Map, targets = [], neighbours = [], rootNormalized = new Map(spec.normalizeWhen.map(([selector, normalized]) => [selector, normalized.map(([property]) => property)])), coverBox = spec.frame !== null && (spec.frame.kind === "fields" && spec.frame.ratio !== null || slots["frame-profile"] !== void 0 && profile.of(slots["frame-profile"], "frame")["block-size"] !== void 0), context = { out, profile, slots, input, reject, placedArtwork, placedByPart, foundation, targets, neighbours, rootNormalized, coverBox }, surface = slots["surface-profile"] ?? spec.surface;
622
806
  checkSurfaceEffects(foundation, profile, [slots["surface-profile"], spec.surface, ...spec.when.map(([, name]) => name)], spec.overflow.kind === "scroll" ? "scroller" : "container", reject);
623
- const press = spec.press.when.length === 0 ? null : writeRootPress(out, spec.press, profile.of(slots["motion-profile"], "motion", spec.profile ?? "recipe"), profile, reject), rootSurface = surface === null ? {} : profile.of(surface, "surface"), rootGroups = [...press === null ? [] : [press], ...measuredMotion(spec.measured, profile, reject)], entering = writeEnter(out, profile, "&", spec.enter, rootSurface, stateSurfaces("&", spec.when, profile), slots, transitioned(spec.paintTransition, rootGroups), reject);
807
+ const press = spec.press.when.length === 0 ? null : writeRootPress(out, spec.press, profile.of(slots["motion-profile"], "motion", spec.profile ?? "recipe"), profile, reject), rootSurface = surface === null ? {} : profile.of(surface, "surface"), restFramed = spec.frame === null || spec.frameAt === null || spec.frameAt.corners === null ? spec.frame : { ...spec.frame, corners: spec.frame.corners ?? FRAME_CORNERS }, rootGeometry = writeStateGeometry("&", "&", {
808
+ frame: restFramed === null ? null : regionFrameValues(restFramed, slots, surface, profile, reject).values,
809
+ arrangement: spec.arrangement,
810
+ arranged: spec.arrangement.layout === "native" ? {} : arrangementValues(spec.arrangement, slots, profile, spec.overflow),
811
+ collapsed: null,
812
+ axis: null
813
+ }, spec.geometryWhen, spec.geometryTransition, (name) => {
814
+ if (restFramed === null)
815
+ return {};
816
+ const stated = regionFrameValues(restFramed, { ...slots, "frame-profile": name }, surface, profile, reject);
817
+ if (JSON.stringify(stated.hitArea) !== JSON.stringify(regionFrameValues(restFramed, slots, surface, profile, reject).hitArea))
818
+ return reject({ kind: "state-geometry-unsupported", element: "&", reason: "hit-area", detail: name });
819
+ return stated.values;
820
+ }, { out, profile, slots, reject });
821
+ if (rootGeometry.overlap !== null)
822
+ out.rule(`& ${OVERLAPPED}`, { [rootGeometry.overlap.property]: rootGeometry.overlap.base });
823
+ const rootGroups = [...press === null ? [] : [press], ...measuredMotion(spec.measured, profile, reject), ...rootGeometry.group === null ? [] : [rootGeometry.group]], entering = writeEnter(out, profile, "&", spec.enter, rootSurface, stateSurfaces("&", spec.when, profile), slots, transitioned(spec.paintTransition, rootGroups), reject);
624
824
  transitionRules("&", spec.paintTransition, surface === null ? null : { name: surface, fields: rootSurface }, spec.when, context, entering === null ? rootGroups : [...rootGroups, entering.group]);
625
825
  writePlays(out, profile, foundation, "&", spec.plays, "&", transitioned(spec.paintTransition, entering === null ? rootGroups : [...rootGroups, entering.group]), reject);
626
826
  const { arrangement } = spec, values = arrangement.layout !== "native" || spec.frame !== null ? { "box-sizing": "border-box", "min-inline-size": "0" } : {};
@@ -700,7 +900,7 @@ export function lowerRegion(spec, foundation, input) {
700
900
  if (Object.keys(measured).length > 0)
701
901
  out.rule(openState(layer.kind), measured);
702
902
  } else {
703
- Object.assign(values, stickyValues(spec.sticky, context), checked(measuredWrites(input.scope, spec.measured, "&", values, frameSupplied), reject), rootPaints);
903
+ Object.assign(values, stickyValues(spec.sticky, context), anchorClearValues(spec.anchorClear, context), checked(measuredWrites(input.scope, spec.measured, "&", values, frameSupplied), reject), rootPaints);
704
904
  if (Object.keys(values).length > 0)
705
905
  out.rule("&", { ...settled(values, entering?.blurred ?? !1) });
706
906
  if (spec.normalize.length > 0)
@@ -715,9 +915,7 @@ export function lowerRegion(spec, foundation, input) {
715
915
  if (spec.prose !== null)
716
916
  lowerProse(spec.prose, rootSurface, context);
717
917
  const partLayout = spec.exposeRows.length > 0 ? "grid" : arrangement.layout;
718
- lowerParts(spec.parts, "&", partLayout, values.gap, context);
719
- if (placedArtwork.length > 1)
720
- return reject({ kind: "parts-visual-repeated" });
721
- return out.finish({ kind: "region", artwork: placedArtwork[0] ?? null, exposed, targets: { elements: targets, neighbours } }, input.hidden);
918
+ lowerParts(spec.parts, "&", partLayout, values.gap, context, growsWithContent(values), rootGeometry.overlap, rootGeometry.gaps);
919
+ return out.finish({ kind: "region", artwork: placedArtwork[0] ?? null, artworks: placedByPart, exposed, targets: { elements: targets, neighbours } }, input.hidden);
722
920
  });
723
921
  }
@@ -34,3 +34,27 @@ export async function layoutShift({ nodeLimit }) {
34
34
  }
35
35
  return { value: Math.round(best.value * 1e4) / 1e4, nodes: [...best.nodes].slice(0, nodeLimit) };
36
36
  }
37
+ export async function stateShift({ nodeLimit, quietMs }) {
38
+ if (!PerformanceObserver.supportedEntryTypes?.includes("layout-shift"))
39
+ return null;
40
+ let value = 0;
41
+ const nodes = [], observer = new PerformanceObserver((list) => {
42
+ for (const entry of list.getEntries()) {
43
+ if (entry.hadRecentInput)
44
+ continue;
45
+ value += entry.value;
46
+ for (const source of entry.sources ?? []) {
47
+ const node = source.node;
48
+ if (node instanceof Element && nodes.length < nodeLimit)
49
+ nodes.push(`${node.localName}${node.id ? `#${node.id}` : ""}${node.classList.length ? `.${[...node.classList].slice(0, 2).join(".")}` : ""}`);
50
+ }
51
+ }
52
+ });
53
+ observer.observe({ type: "layout-shift" });
54
+ await new Promise((resolve) => setTimeout(resolve, quietMs));
55
+ for (const entry of observer.takeRecords())
56
+ if (!entry.hadRecentInput)
57
+ value += entry.value;
58
+ observer.disconnect();
59
+ return { value, nodes };
60
+ }