@reqvire-org/ads 0.5.3 → 0.5.5

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 (98) hide show
  1. package/dist/ads-errors.mjs +105 -8
  2. package/dist/analysis/client-directive.mjs +26 -0
  3. package/dist/analysis/externals.mjs +47 -0
  4. package/dist/analysis/module-graph.mjs +6 -0
  5. package/dist/analysis/owner-analysis-key.mjs +1 -1
  6. package/dist/analysis/owner-choices.mjs +14 -2
  7. package/dist/analysis/owner-composition.mjs +32 -4
  8. package/dist/analysis/owner-source.mjs +121 -17
  9. package/dist/border-paint.mjs +34 -0
  10. package/dist/check.mjs +2 -0
  11. package/dist/composed-contrast.mjs +34 -12
  12. package/dist/construction-output.mjs +58 -31
  13. package/dist/construction-spec.d.mts +111 -15
  14. package/dist/construction-spec.mjs +129 -20
  15. package/dist/corner-overpaint.mjs +3 -1
  16. package/dist/design-foundation.mjs +18 -4
  17. package/dist/emit/owner-emission-cache.mjs +1 -1
  18. package/dist/end-alignment.mjs +69 -0
  19. package/dist/external-macro.d.mts +20 -0
  20. package/dist/external-macro.mjs +12 -0
  21. package/dist/finding-rules.mjs +3 -0
  22. package/dist/forced-colors.mjs +81 -0
  23. package/dist/frame-regions.mjs +2 -2
  24. package/dist/guard/externals.mjs +64 -0
  25. package/dist/guard/run.mjs +9 -5
  26. package/dist/inventories.mjs +1 -1
  27. package/dist/lowering-layer.mjs +38 -4
  28. package/dist/lowering-overlaps.mjs +13 -1
  29. package/dist/lowering-properties.mjs +4 -0
  30. package/dist/lowering-region-layout.mjs +22 -3
  31. package/dist/lowering-session.mjs +1 -1
  32. package/dist/lowering-transitions.mjs +1 -0
  33. package/dist/mcp/preview-http.bundle.js +2 -2
  34. package/dist/mcp/preview-widget.bundle.js +12 -12
  35. package/dist/measured-geometry.mjs +8 -2
  36. package/dist/owner-analysis-check.mjs +190 -11
  37. package/dist/owner-errors.mjs +3 -0
  38. package/dist/owner-lowering.mjs +3 -2
  39. package/dist/ownership-model.mjs +14 -5
  40. package/dist/platform-features.mjs +7 -0
  41. package/dist/preview-bun.mjs +15 -2
  42. package/dist/profile-macro.d.mts +18 -0
  43. package/dist/recipe-macro.d.mts +107 -9
  44. package/dist/recipe-model.mjs +22 -8
  45. package/dist/region-lowering.mjs +204 -49
  46. package/dist/render-audit/axe-run.page.mjs +40 -1
  47. package/dist/render-audit/forced-states.page.mjs +37 -0
  48. package/dist/render-audit/layout-overflow.page.mjs +52 -2
  49. package/dist/render-audit/non-text-contrast.page.mjs +14 -10
  50. package/dist/render-audit/worker.mjs +38 -0
  51. package/dist/render-audit.mjs +42 -5
  52. package/dist/role-vocabulary.d.mts +5 -2
  53. package/dist/role-vocabulary.mjs +6 -3
  54. package/dist/scenario-kit.d.mts +2 -2
  55. package/dist/showcase/assets-view.mjs +12 -47
  56. package/dist/showcase/client.bundle.js +50 -50
  57. package/dist/showcase/http-client.bundle.js +18 -18
  58. package/dist/showcase/token-sample.mjs +2 -2
  59. package/dist/showcase/ui/ui.css +1 -1
  60. package/dist/showcase/ui/ui.js +13 -13
  61. package/dist/skills/ads-designer/references/accessibility.md +21 -1
  62. package/dist/skills/ads-designer/references/branding.md +4 -0
  63. package/dist/skills/ads-designer/references/design-data.md +6 -0
  64. package/dist/skills/ads-designer/references/layers.md +5 -0
  65. package/dist/skills/ads-designer/references/layout.md +8 -1
  66. package/dist/skills/ads-designer/references/recipes.md +52 -2
  67. package/dist/skills/ads-designer/references/runtimes.md +4 -0
  68. package/dist/skills/ads-designer/references/scenarios.md +2 -0
  69. package/dist/skills/ads-import/references/design-data.md +6 -0
  70. package/dist/skills/ads-import/references/layers.md +5 -0
  71. package/dist/skills/ads-import/references/layout.md +8 -1
  72. package/dist/skills/ads-import/references/recipes.md +52 -2
  73. package/dist/skills/ads-import/references/runtimes.md +4 -0
  74. package/dist/skills/ads-import/references/scenarios.md +2 -0
  75. package/dist/skills/ads-migrate/SKILL.md +2 -0
  76. package/dist/skills/ads-migrate/references/0.5.3-to-0.5.4.md +42 -0
  77. package/dist/skills/ads-migrate/references/0.5.4-to-0.5.5.md +61 -0
  78. package/dist/skills/ads-port/references/design-data.md +6 -0
  79. package/dist/skills/ads-port/references/layers.md +5 -0
  80. package/dist/skills/ads-port/references/layout.md +8 -1
  81. package/dist/skills/ads-port/references/recipes.md +52 -2
  82. package/dist/skills/ads-port/references/runtimes.md +4 -0
  83. package/dist/skills/ads-port/references/scenarios.md +2 -0
  84. package/dist/spatial-model.mjs +37 -10
  85. package/dist/system-colors.d.mts +9 -0
  86. package/dist/system-colors.mjs +1 -0
  87. package/dist/target-size.mjs +14 -1
  88. package/dist/tsconfig.declarations.json +1 -0
  89. package/docs/ADS.md +23 -1
  90. package/docs/ASSETS.md +21 -0
  91. package/docs/CACHING.md +1 -1
  92. package/docs/CHANGELOG.md +220 -21
  93. package/docs/GUIDE.md +31 -20
  94. package/docs/LANGUAGE.md +146 -11
  95. package/docs/MOTION.md +11 -1
  96. package/docs/PROFILE-KINDS.md +60 -9
  97. package/docs/RULES.md +21 -8
  98. package/package.json +5 -1
@@ -1,3 +1,7 @@
1
+ import { endInsetOf, stackPartsOf } from "../end-alignment.mjs";
2
+ import { borderPaintMissing } from "../border-paint.mjs";
3
+ import { CLIENT_DIRECTIVE, clientNeed, writtenDirective } from "./client-directive.mjs";
4
+ import { forcedBoundaryMissing, forcedStateFillOnly } from "../forced-colors.mjs";
1
5
  import path from "node:path";
2
6
  import {
3
7
  ScriptTarget,
@@ -33,6 +37,7 @@ import {
33
37
  isPropertyAssignment,
34
38
  isReturnStatement,
35
39
  isShorthandPropertyAssignment,
40
+ isNoSubstitutionTemplateLiteral,
36
41
  isStringLiteral,
37
42
  isVariableDeclaration,
38
43
  isVariableDeclarationList,
@@ -81,7 +86,7 @@ import {
81
86
  elementTags,
82
87
  parseConstruction,
83
88
  CONTROL_TEXT_TAGS,
84
- PSEUDO_HOSTS,
89
+ pseudoHosted,
85
90
  VECTOR_SHAPES
86
91
  } from "../construction-spec.mjs";
87
92
  import { recipeDefaults, visualBindingRedundancy } from "../recipe-defaults.mjs";
@@ -94,7 +99,8 @@ import { digest } from "../digest.mjs";
94
99
  import { FOUNDATION_DECLARATION } from "../design-contexts.mjs";
95
100
  import { cornerOverpaint } from "../corner-overpaint.mjs";
96
101
  import { inactiveSurfaceActive, stateContrast, surfacedElements, surfaceUses } from "../surface-contrast.mjs";
97
- import { compositionFacts, plainPlacements } from "./owner-composition.mjs";
102
+ import { componentTarget, compositionFacts, plainPlacements } from "./owner-composition.mjs";
103
+ import { EXTERNAL_MARKER, externalDeclarations } from "./externals.mjs";
98
104
  import { ownerControls } from "./owner-controls.mjs";
99
105
  import { pressScaleReviews } from "../press-scale.mjs";
100
106
  import { nonTextContrast } from "../non-text-contrast.mjs";
@@ -118,6 +124,35 @@ import { frameworkMismatches } from "./framework-imports.mjs";
118
124
  import { CONTROLLER_FOLDER, controllerGateFailures } from "./controller-gates.mjs";
119
125
  import { isDevelopmentModule } from "../development-modules.mjs";
120
126
  import { cssInJsImports, scriptAnimations, ownerStyleWrites, ownerStylesheetImports, plainModuleStyling, scenarioStyling, stylingFailure, unemittedStyling } from "./styling-ownership.mjs";
127
+ function componentRootOf(file, opening) {
128
+ let node = elementOf(opening), fn;
129
+ for (;; ) {
130
+ const parent = node.parent;
131
+ if (parent === void 0)
132
+ return null;
133
+ if (isParenthesizedExpression(parent) || isConditionalExpression(parent) && parent.condition !== node || isBinaryExpression(parent) && parent.right === node && parent.operatorToken.kind === SyntaxKind.AmpersandAmpersandToken) {
134
+ node = parent;
135
+ continue;
136
+ }
137
+ if (isReturnStatement(parent)) {
138
+ fn = parent.parent;
139
+ while (fn !== void 0 && fn.kind !== SyntaxKind.FunctionDeclaration && fn.kind !== SyntaxKind.ArrowFunction && fn.kind !== SyntaxKind.FunctionExpression)
140
+ fn = fn.parent;
141
+ } else if (parent.kind === SyntaxKind.ArrowFunction)
142
+ fn = parent;
143
+ break;
144
+ }
145
+ if (fn === void 0)
146
+ return null;
147
+ if (fn.kind === SyntaxKind.FunctionDeclaration && fn.parent?.kind === SyntaxKind.SourceFile) {
148
+ const declared = fn.name;
149
+ return declared !== void 0 && isIdentifier(declared) ? `${file}#${declared.text}` : null;
150
+ }
151
+ const holder = fn.parent;
152
+ if (holder !== void 0 && isVariableDeclaration(holder) && holder.parent?.parent?.parent?.kind === SyntaxKind.SourceFile && isIdentifier(holder.name))
153
+ return `${file}#${holder.name.text}`;
154
+ return null;
155
+ }
121
156
  export const PUBLIC_BARREL = "index.ts", AMBIENT_DECLARATIONS = "env.d.ts", ownerCompilerOptions = (root, publicAlias, framework) => ({
122
157
  target: ScriptTarget.ESNext,
123
158
  module: ModuleKind.ESNext,
@@ -626,6 +661,13 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
626
661
  review(opening, { kind: "marker-none-unlabelled", part: partName });
627
662
  return;
628
663
  }
664
+ case "document": {
665
+ if (attr(opening, "lang") === void 0)
666
+ return fail(opening, { kind: "document-lang-missing" });
667
+ if (!descendants(opening).some((other) => lowercaseTag(other) && values.tag(other) === "body"))
668
+ return fail(opening, { kind: "part-element-mismatch", part: partName, expected: ["<html> with <body> inside"], actual: "<html> without <body>" });
669
+ return;
670
+ }
629
671
  case "iframe":
630
672
  case "select":
631
673
  case "table":
@@ -887,17 +929,23 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
887
929
  const hidden = attr(opening, "hidden") === void 0 ? [] : [{ kind: "root" }], guardChild = (fact, selector, within = []) => {
888
930
  if (attr(fact.opening, "hidden") !== void 0 && fact.classes.fragments.length === 0)
889
931
  hidden.push(within.length === 0 ? { kind: "part", selector } : { kind: "part", selector, within });
890
- }, parts = declaredParts(parsed.value), declaredMarkers = new Set([...parts.map((part) => part.selector.slice(1)), ...declaredCells(parsed.value).map((cell) => cell.slice(1))]);
932
+ }, native = new Set, parts = declaredParts(parsed.value), declaredMarkers = new Set([...parts.map((part) => part.selector.slice(1)), ...declaredCells(parsed.value).map((cell) => cell.slice(1))]);
891
933
  if (parsed.value.kind === "region") {
892
- const region = parsed.value;
934
+ const region = parsed.value, rootTag = values.tag(opening);
935
+ if (UA_CONTROL_TAGS.includes(rootTag))
936
+ native.add("&");
937
+ const rootless = region.pseudo.find((treatment) => !pseudoHosted(treatment.pseudo, rootTag));
938
+ if (rootless !== void 0)
939
+ return fail(opening, { kind: "pseudo-host-unsupported", part: "&", pseudo: rootless.pseudo, element: rootTag });
893
940
  await nativeElement(opening, region.element, "&", null, context, resolve);
894
941
  if (region.normalize.some(([property, value]) => property === "pointer-events" && value === "none"))
895
942
  await pointerTransparent(opening, "&", context, resolve);
896
943
  if (region.overflow.kind === "scroll")
897
944
  scrollReview(opening, "&", node);
898
945
  }
899
- const matched = new Map([["", opening]]), tinted = new Set(parsed.value.kind === "region" ? surfacedElements(foundation, parsed.value).flatMap((element) => element.visual && (element.surface !== null || element.when.length > 0) ? [element.element] : []) : []), decorative = new Set;
946
+ const matched = new Map([["", opening]]), tinted = new Set(parsed.value.kind === "region" ? surfacedElements(foundation, parsed.value).flatMap((element) => element.visual && (element.surface !== null || element.when.length > 0) ? [element.element] : []) : []), decorative = new Set, margined = new Set;
900
947
  let schemed = !1;
948
+ const schemedBindings = new Map, placedParts = [];
901
949
  for (const part of parts) {
902
950
  if (!/^\.[\w-]+$/.test(part.selector))
903
951
  return fail(node, { kind: "part-selector-unresolved", part: part.name });
@@ -925,13 +973,23 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
925
973
  return fail(node, { kind: "part-missing-or-repeated", part: part.name });
926
974
  if (match === void 0)
927
975
  continue;
928
- if (part.kind === "component")
976
+ if (part.kind === "component") {
977
+ for (const each of matches) {
978
+ const site = location(each.opening);
979
+ placedParts.push({ part: part.name, target: await componentTarget(root, each.opening, values.symbol), at: { line: site.line, column: site.column } });
980
+ }
929
981
  continue;
982
+ }
930
983
  matched.set([...part.within, part.selector].join(" "), match.opening);
931
984
  const ariaHidden = attr(match.opening, "aria-hidden");
932
985
  if (tinted.has(part.name) && ariaHidden !== void 0 && (ariaHidden.initializer === void 0 || [!0, "true"].includes(await resolve(expression(ariaHidden), context))))
933
986
  decorative.add(part.name);
934
- const element = values.tag(match.opening), hostless = part.pseudo.find((pseudo) => !PSEUDO_HOSTS[pseudo].includes(element));
987
+ const element = values.tag(match.opening);
988
+ if (UA_MARGIN_TAGS.includes(element))
989
+ margined.add([...part.within, part.selector].join(" "));
990
+ if (UA_CONTROL_TAGS.includes(element))
991
+ native.add([...part.within, part.selector].join(" "));
992
+ const hostless = part.pseudo.find((pseudo) => !pseudoHosted(pseudo, element));
935
993
  if (hostless !== void 0)
936
994
  return fail(match.opening, { kind: "pseudo-host-unsupported", part: part.name, pseudo: hostless, element });
937
995
  await nativeElement(match.opening, part.element, part.name, parent, context, resolve);
@@ -963,7 +1021,9 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
963
1021
  await pointerTransparent(match.opening, part.name, context, resolve);
964
1022
  if (part.kind !== "visual")
965
1023
  continue;
966
- if (part.scheme !== null) {
1024
+ if (part.scheme !== null && match.classes.bindings.length > 0)
1025
+ schemedBindings.set(part.name, part.scheme);
1026
+ else if (part.scheme !== null) {
967
1027
  if (element !== "img" || match.classes.bindings.length > 0)
968
1028
  return fail(match.opening, { kind: "scheme-image-element", part: part.name, element });
969
1029
  for (const attribute of ["width", "height"])
@@ -997,7 +1057,7 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
997
1057
  visuals.set(part.name, { fact: { kind: "inspected-svg" }, drawings: void 0 });
998
1058
  continue;
999
1059
  }
1000
- if (match.classes.bindings.length === 0 && parsed.value.kind === "region" && values.tag(match.opening) === "img") {
1060
+ if (match.classes.bindings.length === 0 && parsed.value.kind === "region" && ["img", "video"].includes(values.tag(match.opening))) {
1001
1061
  visual ??= { kind: "content-media" };
1002
1062
  visuals.set(part.name, { fact: { kind: "content-media" }, drawings: void 0 });
1003
1063
  continue;
@@ -1011,6 +1071,9 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1011
1071
  const themeName = binding.handle.descriptor.spec.theme ?? "light", theme = themes.find((item) => item.name === themeName);
1012
1072
  if (theme === void 0)
1013
1073
  return fail(match.opening, { kind: "theme-unknown", theme: String(themeName) });
1074
+ const pairScheme = schemedBindings.get(part.name);
1075
+ if (pairScheme !== void 0 && theme.scheme !== pairScheme)
1076
+ return fail(match.opening, { kind: "scheme-image-element", part: part.name, element: `artwork bound for theme ${theme.name}` });
1014
1077
  const bindingSource = async (target) => {
1015
1078
  const selected = await resolve(target, context);
1016
1079
  if (typeof selected !== "object" || selected === null || selected.kind !== "asset-source" || selected.handle.node !== binding.handle.node || selected.name !== binding.name)
@@ -1115,13 +1178,15 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1115
1178
  ...aligned.size > 0 ? [[...aligned]] : [],
1116
1179
  ...writesInline ? [scope] : [],
1117
1180
  ...decorative.size > 0 ? [["decorative", ...decorative]] : [],
1181
+ ...margined.size > 0 ? [["margined", ...[...margined].sort()]] : [],
1182
+ ...native.size > 0 ? [["native", ...[...native].sort()]] : [],
1118
1183
  ...visuals.size > 1 ? [[...visuals].map(([name, { fact, drawings: drawn }]) => fact.kind === "asset" ? [name, drawn, fact.state, fact.visualProfile, fact.theme.name] : [name, fact.kind])] : []
1119
1184
  ], paintedBy = (element) => parsed.value.kind === "control" ? hasText ? "text" : "graphic" : element.visual ? decorative.has(element.element) ? "decorative" : "graphic" : "text", key = constructionId(digest(hidden.length > 0 ? [...identity, hidden] : identity));
1120
1185
  let owned = styles.get(key);
1121
1186
  if (owned === void 0) {
1122
1187
  if (styles.size >= choiceLimits.alternatives)
1123
1188
  return fail(node, { kind: "choice", problem: { kind: "construction-limit" } });
1124
- const rootName = `owner_${key.slice(0, 16)}`, input = { visual: visual ?? null, visuals: new Map([...visuals].map(([name, { fact }]) => [name, fact])), hasText, hidden, inherited, aligned, scope }, spec = parsed.value, built = await memoizedConstruction(options.constructions, foundation, [key, scope, drawnRecords(input, root)], (read) => {
1189
+ const rootName = `owner_${key.slice(0, 16)}`, input = { visual: visual ?? null, visuals: new Map([...visuals].map(([name, { fact }]) => [name, fact])), hasText, hidden, inherited, aligned, scope, margined: [...margined].sort(), native: [...native].sort() }, spec = parsed.value, built = await memoizedConstruction(options.constructions, foundation, [key, scope, drawnRecords(input, root)], (read) => {
1125
1190
  const reviews = [], failed = (failure, at = null) => ({ kind: "failed", failure: { path: at, item: failure }, reviews }), lowered = lower(spec, read, rootName, input);
1126
1191
  if (lowered.kind === "err")
1127
1192
  return failed(lowered.error);
@@ -1141,6 +1206,13 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1141
1206
  const overpaint = cornerOverpaint(read, spec);
1142
1207
  if (overpaint !== null)
1143
1208
  return failed(overpaint, `recipe.parts.${overpaint.part}`);
1209
+ const edgeless = forcedBoundaryMissing(read, spec);
1210
+ if (edgeless !== null)
1211
+ return failed(edgeless, edgeless.element === "&" ? null : `recipe.parts.${edgeless.element}`);
1212
+ for (const filled of forcedStateFillOnly(read, spec))
1213
+ reviews.push({ path: null, item: filled });
1214
+ for (const unpainted of borderPaintMissing(read, spec))
1215
+ reviews.push({ path: unpainted.element === "&" ? null : `recipe.parts.${unpainted.element}`, item: unpainted });
1144
1216
  const painted = runtimePaintContrast(read, spec);
1145
1217
  if (painted.kind === "err")
1146
1218
  return failed(painted.error);
@@ -1154,14 +1226,19 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1154
1226
  surfaceUses: surfaceUses(read, spec, lowered.value.profiles, paintedBy),
1155
1227
  paints: declaredPaints(spec).map((paint) => ({ name: paint.name, property: paintProperty(scope, paint.name), values: paint.values })),
1156
1228
  glyphs: [],
1157
- content: []
1229
+ content: [],
1230
+ placements: [],
1231
+ roots: [],
1232
+ ...spec.kind === "region" && spec.element?.kind === "document" ? { document: !0 } : {},
1233
+ endInset: endInsetOf(read, spec),
1234
+ stackParts: stackPartsOf(read, spec)
1158
1235
  }, reviews };
1159
1236
  }), at = (path) => path === null ? node : authoredAt(classes.calls, path) ?? node;
1160
1237
  for (const noted of built.reviews)
1161
1238
  review(at(noted.path), noted.item);
1162
1239
  if (built.kind === "failed")
1163
1240
  return fail(at(built.failure.path), { kind: "construction", failure: built.failure.item });
1164
- owned = { ...built.owned, origins: [], glyphs: [], content: [] };
1241
+ owned = { ...built.owned, origins: [], glyphs: [], content: [], placements: [], roots: [] };
1165
1242
  styles.set(key, owned);
1166
1243
  }
1167
1244
  if (owned.facts.kind === "region" && owned.facts.exposed !== null)
@@ -1231,6 +1308,12 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1231
1308
  if (!owned.origins.some((origin) => origin.kind === "point" && origin.position.line === at.line && origin.position.column === at.column))
1232
1309
  owned.origins.push({ kind: "point", file: name, position: { line: at.line, column: at.column } });
1233
1310
  const lowered = owned;
1311
+ for (const placement of placedParts)
1312
+ if (!(owned.placements ?? []).some((known) => known.at.line === placement.at.line && known.at.column === placement.at.column))
1313
+ owned.placements?.push(placement);
1314
+ const rootOf = componentRootOf(name, opening);
1315
+ if (rootOf !== null && !(owned.roots ?? []).includes(rootOf))
1316
+ owned.roots?.push(rootOf);
1234
1317
  for (const attribute of await contentAttributes(opening))
1235
1318
  if (!(owned.content ?? []).includes(attribute))
1236
1319
  owned.content?.push(attribute);
@@ -1450,7 +1533,7 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1450
1533
  if (references.has(identifier) || !glyphReads.has(await values.symbol(identifier)))
1451
1534
  continue;
1452
1535
  const declaration = identifier.parent;
1453
- if (declaration !== void 0 && (isBindingElement(declaration) || isParameterDeclaration(declaration)) && declaration.name === identifier)
1536
+ if (declaration !== void 0 && (isBindingElement(declaration) || isParameterDeclaration(declaration) || isVariableDeclaration(declaration)) && declaration.name === identifier)
1454
1537
  continue;
1455
1538
  const passed = identifier.parent?.parent, tag = passed !== void 0 && isJsxAttribute(passed) ? passed.parent.parent : void 0, host = tag !== void 0 && (isJsxOpeningElement(tag) || isJsxSelfClosingElement(tag)) ? tag : null;
1456
1539
  if (!(identifier.parent !== void 0 && isJsxExpression(identifier.parent) && host !== null && !lowercaseTag(host)) && !presenceTest(identifier))
@@ -1466,6 +1549,12 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1466
1549
  if (isImportDeclaration(statement) && isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === RECIPE_MODULE)
1467
1550
  edits.push({ node: statement, text: "" });
1468
1551
  edits.push(...macros.edits);
1552
+ const directive = writtenDirective(source);
1553
+ if (directive !== null) {
1554
+ edits.push({ node: directive, text: "" });
1555
+ if (clientNeed(source) === null && !values.externals.some((external) => external.client))
1556
+ review(directive, { kind: "client-directive-unneeded" });
1557
+ }
1469
1558
  for (const call of values.macroCalls.keys()) {
1470
1559
  if ([...values.macroCalls.keys()].some((other) => other !== call && inside(call, other)))
1471
1560
  continue;
@@ -1478,9 +1567,17 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
1478
1567
  const coveredLeaves = selections.reduce((sum, { result }) => sum + result.leaves.filter((leaf) => leaf.value.kind === "styled").length, 0), [rows] = exposedRows.values(), publicRows = exposedRows.size === 1 && rows !== void 0 ? rows : null, uses = [...artworkUses].sort().map((key) => {
1479
1568
  const [asset = "", size = ""] = key.split("\x00");
1480
1569
  return { asset, size: size === "" ? null : size };
1481
- }), artwork = { assets: [...boundAssets].sort(), sets: [...boundSets].sort(), glyphs: macros.glyphs, support: macros.support, uses };
1570
+ }), artwork = { assets: [...boundAssets].sort(), sets: [...boundSets].sort(), glyphs: macros.glyphs, support: macros.support, uses }, scriptTokens = new Set;
1571
+ for (const literal of [...nodesOfKind(source, SyntaxKind.StringLiteral, isStringLiteral), ...nodesOfKind(source, SyntaxKind.NoSubstitutionTemplateLiteral, isNoSubstitutionTemplateLiteral)])
1572
+ for (const match of literal.text.matchAll(/(?:^|var\()(--[a-z][\w-]*)/g))
1573
+ if (match[1] !== void 0 && foundation.tokens.has(match[1]))
1574
+ scriptTokens.add(match[1]);
1575
+ const [firstStyle] = styles;
1576
+ if (firstStyle !== void 0 && scriptTokens.size > 0)
1577
+ styles.set(firstStyle[0], { ...firstStyle[1], scriptTokens: [...scriptTokens].sort() });
1482
1578
  return { source, values, selections, styles, edits, assetEdits, imports, coverage: { constructions: styles.size, coveredLeaves }, publicRows, controls: ownerControls(selections.flatMap((selection) => selection.result.axes)), reviews, artwork, design: ownerDesign([...styles.values()].flatMap((construction) => construction.profiles)) };
1483
1579
  }
1580
+ const UA_MARGIN_TAGS = ["p", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "ol", "dl", "dd", "blockquote", "figure", "pre", "hr", "menu"], UA_CONTROL_TAGS = ["button", "input", "textarea", "select"];
1484
1581
  function drawnRecords(input, root) {
1485
1582
  return [input.visual, ...input.visuals.values()].map((fact) => fact !== null && fact.kind === "asset" ? designValueDigest(fact.asset, root) : null);
1486
1583
  }
@@ -1499,7 +1596,7 @@ function lower(spec, foundation, root, input) {
1499
1596
  hidden: input.hidden
1500
1597
  });
1501
1598
  case "region":
1502
- return lowerRegion(spec, foundation, { root, visual: input.visual, visuals: input.visuals, hidden: input.hidden, scope: input.scope });
1599
+ return lowerRegion(spec, foundation, { root, visual: input.visual, visuals: input.visuals, hidden: input.hidden, scope: input.scope, ...input.margined.length === 0 ? {} : { margined: input.margined }, ...input.native.length === 0 ? {} : { native: input.native } });
1503
1600
  case "grid":
1504
1601
  return lowerGrid(spec, foundation, { root, hidden: input.hidden, inherited: input.inherited, aligned: input.aligned, scope: input.scope });
1505
1602
  }
@@ -1582,7 +1679,7 @@ function checkedAppIcon(analysis) {
1582
1679
  }
1583
1680
  export const ownerSheetName = (owner) => owner.replace(/\.tsx?$/, ".css");
1584
1681
  export function ownerSheet(owner, styles, css, foundation, sections = !0) {
1585
- const used = new Set([...styles.values()].flatMap((value) => [...value.used])), tokens = tokenCss(foundation, used);
1682
+ const used = new Set([...styles.values()].flatMap((value) => [...value.used, ...value.scriptTokens ?? []])), tokens = tokenCss(foundation, used);
1586
1683
  if (tokens.kind === "err")
1587
1684
  return err({ kind: "token-css", owner, failure: tokens.error });
1588
1685
  const nested = sections ? tokenSectionCss(foundation, tokens.value) : "";
@@ -1591,6 +1688,12 @@ export function ownerSheet(owner, styles, css, foundation, sections = !0) {
1591
1688
  }
1592
1689
  export const ownerDocuments = (owners) => [...owners].flatMap((owner) => [...owner.styles.values()].flatMap((value) => value.documents));
1593
1690
  export function plainModuleSource(name, module) {
1691
+ const externals = externalDeclarations(module.source);
1692
+ if (externals.length > 0)
1693
+ return `${externals.map((item) => `${item.exportName === "default" ? `export { default as ${item.name} }` : item.exportName === item.name ? `export { ${item.name} }` : `export { ${item.exportName} as ${item.name} }`} from ${JSON.stringify(item.from)};
1694
+ ${EXTERNAL_MARKER}${JSON.stringify({ name: item.name, renders: item.renders })} */`).join(`
1695
+ `)}
1696
+ `;
1594
1697
  let text = module.source.text;
1595
1698
  const replacements = [...module.statements.map((node) => ({ node, text: "" })), ...module.edits];
1596
1699
  for (const edit of replacements.sort((a, b) => b.node.getStart(module.source) - a.node.getStart(module.source)))
@@ -1693,7 +1796,8 @@ export async function ownerModuleSource(name, owner, classOf, fail) {
1693
1796
  let emitted = source.text;
1694
1797
  for (const edit of replacements.sort((a, b) => b.start - a.start))
1695
1798
  emitted = emitted.slice(0, edit.start) + edit.text + emitted.slice(edit.end);
1696
- emitted = `import ${JSON.stringify(`./${path.basename(ownerSheetName(name))}`)};
1799
+ emitted = `${clientNeed(source) === null && !values.externals.some((external) => external.client) ? "" : `${CLIENT_DIRECTIVE}
1800
+ `}import ${JSON.stringify(`./${path.basename(ownerSheetName(name))}`)};
1697
1801
  ${owner.imports.join(`
1698
1802
  `)}
1699
1803
  ${emitted}`;
@@ -0,0 +1,34 @@
1
+ import { selectedProfile } from "./design-foundation.mjs";
2
+ const fieldsOf = (foundation, name, kind, select = {}) => {
3
+ if (name === null || name === void 0)
4
+ return null;
5
+ const selected = selectedProfile(foundation, name, select);
6
+ return selected.kind === "ok" && selected.value.kind === kind ? selected.value.fields : null;
7
+ }, PAINTS = ["border-color", "border-inline-start-color", "border-inline-end-color", "border-block-start-color", "border-block-end-color"];
8
+ export function borderPaintMissing(foundation, spec) {
9
+ if (spec.kind !== "region" && spec.kind !== "control")
10
+ return [];
11
+ const composite = spec.profile === null ? null : selectedProfile(foundation, spec.profile, spec.select), slots = composite === null || composite.kind === "err" ? new Map : composite.value.kind === "composite" ? composite.value.fields : new Map([[`${composite.value.kind}-profile`, spec.profile ?? ""]]), found = [], check = (element, frameName, surfaces) => {
12
+ const frame = fieldsOf(foundation, frameName, "frame");
13
+ if (frame === null || frame.get("border-width") === void 0 || frame.get("border-style") === "forced-only")
14
+ return;
15
+ if (!surfaces.some((surface) => {
16
+ const fields = fieldsOf(foundation, surface, "surface");
17
+ return fields !== null && PAINTS.some((paint) => fields.has(paint));
18
+ }))
19
+ found.push({ kind: "border-paint-missing", element, frame: frameName ?? "" });
20
+ };
21
+ if (spec.kind === "control") {
22
+ check("&", slots.get("frame-profile"), [spec.surface, slots.get("surface-profile"), ...spec.when.map(([, surface]) => surface)]);
23
+ return found;
24
+ }
25
+ if (spec.frame !== null)
26
+ check("&", slots.get("frame-profile"), [spec.surface, slots.get("surface-profile"), ...spec.when.map(([, surface]) => surface)]);
27
+ for (const part of spec.parts) {
28
+ const frame = part.box ?? (part.frame !== null ? slots.get("frame-profile") : void 0);
29
+ if (frame === void 0 || frame === null)
30
+ continue;
31
+ check(part.name, frame, [part.surface, ...part.when.map(([, surface]) => surface)]);
32
+ }
33
+ return found;
34
+ }
package/dist/check.mjs CHANGED
@@ -123,6 +123,8 @@ export const checkRules = [
123
123
  "a11y-keyboard",
124
124
  "a11y-target-size",
125
125
  "a11y-target-size-unresolved",
126
+ "a11y-forced-colors",
127
+ "a11y-forced-colors-review",
126
128
  "a11y-non-text-contrast",
127
129
  "surface-contrast",
128
130
  "surface-contrast-unresolved",
@@ -1,5 +1,5 @@
1
1
  import { selectedProfile, tokenDefinitionContexts } from "./design-foundation.mjs";
2
- import { inactiveCondition, layeredBackdrop, layeredContrast, opaque, readColor, unshown } from "./paint-contrast.mjs";
2
+ import { inactiveCondition, layeredBackdrop, layeredContrast, NON_TEXT_MINIMUM, opaque, readColor, unshown } from "./paint-contrast.mjs";
3
3
  import { describeUnresolved, textMinimum } from "./surface-contrast.mjs";
4
4
  import { sectionsDeclared } from "./token-sections.mjs";
5
5
  export const NO_COMPOSITION = { positions: [] }, compositionLimits = Object.freeze({ chains: 512, hops: 24, backdrops: 256 });
@@ -89,14 +89,17 @@ export function composedContrastFindings(inputs) {
89
89
  return [];
90
90
  return [[placed.owner, fact.scope ?? `${fact.at.file}:${fact.at.line}:${fact.at.column}`, fact.tag, fact.surfaces?.map((state) => [state.condition, state.surface]) ?? null, text, fact.flow, fact.context, fact.exempt, placed.boundary?.reason ?? null]];
91
91
  });
92
- }, chainRelated = new Map, chains = [], emit = (walk, certain, top) => {
92
+ }, chainRelated = new Map, chains = [], emit = (walk, certain, top, graphic = !1) => {
93
93
  if (walk.elements.some((placed) => placed.fact.exempt !== null))
94
94
  return null;
95
- const elements = [...walk.elements, top], key = JSON.stringify([certain, evaluationKey(elements)]);
95
+ const [own] = walk.elements;
96
+ if (graphic && (own === void 0 || own.fact.visual !== !0 || (own.fact.surfaces ?? []).length === 0))
97
+ return null;
98
+ const elements = [...walk.elements, top], key = JSON.stringify([certain, graphic, evaluationKey(elements)]);
96
99
  let related = chainRelated.get(key);
97
100
  if (related === void 0) {
98
101
  chainRelated.set(key, related = new Map);
99
- chains.push({ key, chain: { elements, certain } });
102
+ chains.push({ key, chain: { elements, certain, ...graphic ? { graphic } : {} } });
100
103
  }
101
104
  for (const item of walk.related)
102
105
  related.set(siteKey(item.site), item);
@@ -156,8 +159,8 @@ export function composedContrastFindings(inputs) {
156
159
  distinct.set(key, leaf);
157
160
  }
158
161
  return [...distinct.values()];
159
- }, argsOf = (placement) => placement.content.kind === "placement" && placement.content.spread === null ? placement.content.args : null, origin = (start, certain, run) => {
160
- const seen = new Set;
162
+ }, argsOf = (placement) => placement.content.kind === "placement" && placement.content.spread === null ? placement.content.args : null, origin = (start, certain, run, graphic = !1) => {
163
+ const seen = new Set, reached = new Set;
161
164
  let walks = 0, limited = !1;
162
165
  run({
163
166
  emit: (walk, top) => {
@@ -166,7 +169,7 @@ export function composedContrastFindings(inputs) {
166
169
  if (++walks > compositionLimits.chains * 8)
167
170
  limited = !0;
168
171
  else {
169
- const key = emit(walk, certain, top);
172
+ const key = emit(walk, certain, top, graphic);
170
173
  if (key !== null)
171
174
  seen.add(key);
172
175
  if (seen.size > compositionLimits.chains)
@@ -175,7 +178,13 @@ export function composedContrastFindings(inputs) {
175
178
  if (limited)
176
179
  note(source(start), `its compositions exceed ${compositionLimits.chains} distinct chains`, FIRST, walk.related);
177
180
  },
178
- limited: () => limited
181
+ limited: () => limited,
182
+ first: (state) => {
183
+ if (reached.has(state))
184
+ return !1;
185
+ reached.add(state);
186
+ return !0;
187
+ }
179
188
  });
180
189
  }, relatedOf = (point, message) => ({ site: source(point), message }), boundaryAt = (at, component, reason) => ({
181
190
  owner: at.file,
@@ -266,6 +275,8 @@ export function composedContrastFindings(inputs) {
266
275
  }
267
276
  function ascend(frame, walk, mode, steps) {
268
277
  const key = componentKey(frame.owner, frame.component);
278
+ if (!steps.first(JSON.stringify([key, frame.props, mode, evaluationKey(walk.elements), [...walk.recursed ?? []].sort()])))
279
+ return;
269
280
  if (mode === "data")
270
281
  for (const { owner, position } of placementsOf.get(key) ?? []) {
271
282
  if (!consistent(argsOf(position), frame.props))
@@ -307,11 +318,11 @@ export function composedContrastFindings(inputs) {
307
318
  const leaves = leavesOf(position);
308
319
  if (leaves === null)
309
320
  break;
310
- const start = { ...empty, related: [relatedOf(position.at, "the text")] };
321
+ const start = { ...empty, related: [relatedOf(position.at, content.graphic === !0 ? "the artwork" : "the text")] };
311
322
  origin(position.at, content.certain, (steps) => {
312
323
  for (const leaf of leaves)
313
324
  walkFrame({ owner, component: position.component, segments: leaf.segments, index: 0, props: leaf.props }, start, "data", steps);
314
- });
325
+ }, content.graphic === !0);
315
326
  break;
316
327
  }
317
328
  case "forward": {
@@ -353,7 +364,18 @@ export function composedContrastFindings(inputs) {
353
364
  }
354
365
  }
355
366
  }
356
- const contextLabel = (index) => ({ index, label: nameOf(contexts[index]) }), stateOf = (key) => key === null ? null : key.slice(key.lastIndexOf("\x00") + 1);
367
+ const contextLabel = (index) => ({ index, label: nameOf(contexts[index]) }), stateOf = (key) => key === null ? null : key.slice(key.lastIndexOf("\x00") + 1), derived = new Set(chains.map(({ key }) => key));
368
+ for (const { key, chain } of chains.slice())
369
+ chain.elements.forEach((placed, index) => {
370
+ for (const pseudo of placed.fact.pseudo ?? []) {
371
+ const elements = [{ owner: placed.owner, component: placed.component, fact: { ...placed.fact, tag: `::${pseudo.name}`, surfaces: pseudo.surfaces, text: pseudo.text ?? placed.fact.text, pseudo: [] } }, ...chain.elements.slice(index)], derivedKey = JSON.stringify([chain.certain, pseudo.graphic, evaluationKey(elements)]);
372
+ if (derived.has(derivedKey))
373
+ continue;
374
+ derived.add(derivedKey);
375
+ chains.push({ key: derivedKey, chain: { elements, certain: chain.certain, graphic: pseudo.graphic } });
376
+ chainRelated.set(derivedKey, chainRelated.get(key) ?? new Map);
377
+ }
378
+ });
357
379
  for (const { key, chain } of chains)
358
380
  evaluateChain(chain, [...chainRelated.get(key)?.values() ?? []]);
359
381
  function conditionKey(placed, condition) {
@@ -423,7 +445,7 @@ export function composedContrastFindings(inputs) {
423
445
  note(siteOf(placed, layer.state.at), describeUnresolved(backdrop.unresolved), contextLabel(index), related);
424
446
  continue;
425
447
  }
426
- const minimum = textMinimum(text, context), outcome = layeredContrast(context, value, backdrop.colors, minimum), foreElement = elements[f.element];
448
+ const minimum = chain.graphic === !0 ? NON_TEXT_MINIMUM : textMinimum(text, context), outcome = layeredContrast(context, value, backdrop.colors, minimum), foreElement = elements[f.element];
427
449
  if (foreElement === void 0)
428
450
  continue;
429
451
  switch (outcome.kind) {
@@ -3,6 +3,7 @@ import { selectAsset } from "./asset-model.mjs";
3
3
  import { REDUCED_MOTION, paintTransitionRules, transitionSetRules } from "./lowering-transitions.mjs";
4
4
  import { reducedMotionPolicy } from "./lowering-motion.mjs";
5
5
  import { BORDER_STYLE, BORDER_STYLES, INACTIVE_STATE, SURFACE_STATE, TEXT_TRANSFORM, TEXT_TRANSFORMS, sequenceStepTokenRoles } from "./role-vocabulary.mjs";
6
+ import { FORCED_FIELDS, FORCED_ONLY, FORCED_PREFIX } from "./forced-colors.mjs";
6
7
  import { controlFrameInsets } from "./lowering-region-layout.mjs";
7
8
  import { recipeTree } from "./recipe-model.mjs";
8
9
  import { profileReference } from "./profile-model.mjs";
@@ -24,36 +25,55 @@ export function output(root, operation, reject, profile) {
24
25
  for (const token of references(value))
25
26
  if (!owned.has(token))
26
27
  used.add(token);
28
+ }, outRule = (selector, values, condition) => {
29
+ const sided = LOGICAL_SIDE_COLORS.some((property) => values[property] !== void 0), shared = values["border-color"], declarations = effectDeclarations(values).flatMap(([property, value]) => {
30
+ use(value);
31
+ if (sided) {
32
+ if (LOGICAL_SIDE_COLORS.includes(property))
33
+ return [];
34
+ if (property === "border-color")
35
+ return LOGICAL_SIDE_COLORS.map((name) => [name, values[name] ?? value]);
36
+ return [[property, value]];
37
+ }
38
+ return (property === "border-color" ? SIDES.map((side) => `border-${side}-color`) : [property]).map((name) => [name, value]);
39
+ });
40
+ if (sided && shared === void 0)
41
+ for (const name of LOGICAL_SIDE_COLORS) {
42
+ const own = values[name];
43
+ if (own === void 0)
44
+ continue;
45
+ use(own);
46
+ declarations.push([name, own]);
47
+ }
48
+ const conditions = condition === void 0 ? [] : [{ name: condition[0], params: condition[1] }], roles = declarations.filter(([property]) => property.startsWith("--"));
49
+ if (roles.length > 0)
50
+ checked(session.writeProvidedRoles({ selector, conditions, values: roles, important: !1 }));
51
+ const rest = declarations.filter(([property]) => !property.startsWith("--"));
52
+ if (rest.length > 0 || roles.length === 0)
53
+ checked(session.write({ selector, conditions, values: rest, important: !1 }));
27
54
  };
28
55
  return {
29
56
  use,
30
57
  own: (property) => void owned.add(property),
31
- rule: (selector, values, condition) => {
32
- const sided = LOGICAL_SIDE_COLORS.some((property) => values[property] !== void 0), shared = values["border-color"], declarations = effectDeclarations(values).flatMap(([property, value]) => {
33
- use(value);
34
- if (sided) {
35
- if (LOGICAL_SIDE_COLORS.includes(property))
36
- return [];
37
- if (property === "border-color")
38
- return LOGICAL_SIDE_COLORS.map((name) => [name, values[name] ?? value]);
39
- return [[property, value]];
40
- }
41
- return (property === "border-color" ? SIDES.map((side) => `border-${side}-color`) : [property]).map((name) => [name, value]);
42
- });
43
- if (sided && shared === void 0)
44
- for (const name of LOGICAL_SIDE_COLORS) {
45
- const own = values[name];
46
- if (own === void 0)
47
- continue;
48
- use(own);
49
- declarations.push([name, own]);
50
- }
51
- const conditions = condition === void 0 ? [] : [{ name: condition[0], params: condition[1] }], roles = declarations.filter(([property]) => property.startsWith("--"));
52
- if (roles.length > 0)
53
- checked(session.writeProvidedRoles({ selector, conditions, values: roles, important: !1 }));
54
- const rest = declarations.filter(([property]) => !property.startsWith("--"));
55
- if (rest.length > 0 || roles.length === 0)
56
- checked(session.write({ selector, conditions, values: rest, important: !1 }));
58
+ rule: (selector, given, condition) => {
59
+ const forced = Object.entries(given).filter(([property]) => property.startsWith(FORCED_PREFIX)), values = forced.length === 0 ? given : Object.fromEntries(Object.entries(given).filter(([property]) => !property.startsWith(FORCED_PREFIX)));
60
+ if (forced.length > 0) {
61
+ const media = [...condition === void 0 ? [] : [{ name: condition[0], params: condition[1] }], { name: "media", params: "(forced-colors: active)" }], system = forced.flatMap(([field, value]) => {
62
+ const property = FORCED_FIELDS[field];
63
+ return property === "border-color" ? SIDES.map((side) => [`border-${side}-color`, value]) : [[property, value]];
64
+ });
65
+ checked(session.write({ selector, conditions: media, values: [...system, ["forced-color-adjust", "none"]], important: !1 }));
66
+ }
67
+ if (Object.entries(values).some(([property, value]) => /^border(-[a-z]+)?-style$/.test(property) && value === FORCED_ONLY)) {
68
+ const own = {};
69
+ for (const [property, value] of Object.entries(values))
70
+ own[property] = /^border(-[a-z]+)?-style$/.test(property) && value === FORCED_ONLY ? "solid" : value;
71
+ if (!Object.keys(own).some((property) => /^border(-[a-z]+)*-color$/.test(property)))
72
+ for (const side of SIDES)
73
+ own[`border-${side}-color`] = "transparent";
74
+ return outRule(selector, own, condition);
75
+ }
76
+ return outRule(selector, values, condition);
57
77
  },
58
78
  tree: (node) => checked(session.writeTree(node, root)),
59
79
  document: (rule) => session.writeDocument(rule),
@@ -202,16 +222,18 @@ export function writeEnter(out, profile, selector, enter, base, states, slots, t
202
222
  out.rule(rule.selector, { ...rule.values }, rule.condition ?? void 0);
203
223
  return { group: lowered.value.group, blurred: lowered.value.blurred };
204
224
  }
205
- export const STATE_TEXT_PROPERTIES = ["font-weight", "letter-spacing"];
225
+ export const STATE_TEXT_PROPERTIES = ["font-weight", "letter-spacing", "text-decoration-color", "text-decoration-thickness", "text-underline-offset"];
226
+ const STATE_TEXT_INITIAL = { "text-decoration-color": "currentcolor", "text-decoration-thickness": "auto", "text-underline-offset": "auto" };
206
227
  export function writeStateText(out, profile, element, base, texts, selector, reject) {
207
228
  for (const { condition, text } of texts) {
208
- if (base["font-size"] === void 0)
229
+ const fields = profile.of(text, "text"), changed = [...new Set([...Object.keys(base), ...Object.keys(fields)])].filter((property) => base[property] !== fields[property]);
230
+ if (base["font-size"] === void 0 && changed.some((property) => property === "font-weight" || property === "letter-spacing"))
209
231
  return reject({ kind: "state-text-unbound", element, profile: text });
210
- const fields = profile.of(text, "text"), changed = [...new Set([...Object.keys(base), ...Object.keys(fields)])].filter((property) => base[property] !== fields[property]), moved = changed.find((property) => !STATE_TEXT_PROPERTIES.includes(property));
232
+ const moved = changed.find((property) => !STATE_TEXT_PROPERTIES.includes(property));
211
233
  if (moved !== void 0)
212
234
  return reject({ kind: "state-text-field", element, profile: text, property: moved });
213
235
  if (changed.length > 0)
214
- out.rule(selector(condition), Object.fromEntries(changed.map((property) => [property, fields[property] ?? "normal"])));
236
+ out.rule(selector(condition), Object.fromEntries(changed.map((property) => [property, fields[property] ?? STATE_TEXT_INITIAL[property] ?? "normal"])));
215
237
  }
216
238
  }
217
239
  export function writePlays(out, profile, foundation, element, plays, selector, taken, reject) {
@@ -340,7 +362,12 @@ export const frameTarget = (frame, box, field) => ({
340
362
  ...box.insets.blockEnd === box.insets.blockStart ? {} : { insetEnd: box.insets.blockEnd },
341
363
  ...box.insets.inlineEnd === box.insets.inlineStart ? {} : { paddingInlineEnd: box.insets.inlineEnd },
342
364
  ...frame["min-inline-size"] === void 0 ? {} : { minInline: frame["min-inline-size"] }
343
- }), controlBoxValues = (box) => ({
365
+ });
366
+ export function controlInlineExtent(frame, fallback) {
367
+ const size = frame["inline-size"], max = frame["max-inline-size"], minimum = frame["min-inline-size"] ?? (size !== void 0 && max === void 0 ? size : fallback);
368
+ return { ...size === void 0 ? {} : { "inline-size": size }, ...max === void 0 ? {} : { "max-inline-size": max }, ...minimum === null ? {} : { "min-inline-size": minimum } };
369
+ }
370
+ export const controlBoxValues = (box) => ({
344
371
  "min-block-size": box.minBlockSize,
345
372
  "padding-inline-start": box.padding.inlineStart,
346
373
  "padding-inline-end": box.padding.inlineEnd,