@reqvire-org/ads 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ads-errors.mjs +143 -51
- package/dist/analysis/composition-axes.mjs +48 -0
- package/dist/analysis/construction-memo.mjs +38 -0
- package/dist/analysis/context.mjs +19 -0
- package/dist/analysis/design-reads.mjs +177 -0
- package/dist/analysis/design-usage.mjs +4 -20
- package/dist/analysis/factored-classes.mjs +90 -0
- package/dist/analysis/helpers.mjs +5 -7
- package/dist/analysis/mock-check.mjs +4 -5
- package/dist/analysis/native-project.mjs +12 -0
- package/dist/analysis/owner-accessibility.mjs +4 -4
- package/dist/analysis/owner-analysis-cache.mjs +86 -23
- package/dist/analysis/owner-analysis-key.mjs +42 -10
- package/dist/analysis/owner-choices.mjs +56 -7
- package/dist/analysis/owner-composition.mjs +179 -45
- package/dist/analysis/owner-reuse.mjs +8 -6
- package/dist/analysis/owner-source.mjs +304 -110
- package/dist/analysis/scenario-keys.mjs +10 -7
- package/dist/analysis/service.mjs +50 -3
- package/dist/analysis/standalone.mjs +7 -4
- package/dist/analysis/syntax.mjs +59 -1
- package/dist/analysis/worker-protocol.mjs +14 -2
- package/dist/analysis/worker.mjs +32 -10
- package/dist/architecture-report.mjs +26 -0
- package/dist/asset-view-facts.mjs +16 -2
- package/dist/boundaries.mjs +26 -10
- package/dist/bun-compiler.mjs +2 -2
- package/dist/check-service.mjs +29 -17
- package/dist/check.mjs +13 -6
- package/dist/cli.mjs +1 -1
- package/dist/composed-contrast.mjs +143 -62
- package/dist/composed-keyline.mjs +2 -2
- package/dist/config.mjs +2 -1
- package/dist/construction-output.mjs +9 -3
- package/dist/construction-spec.d.mts +145 -31
- package/dist/construction-spec.mjs +204 -74
- package/dist/corner-overpaint.mjs +20 -7
- package/dist/derived-states.mjs +182 -0
- package/dist/design-foundation.mjs +16 -0
- package/dist/design-inputs.mjs +18 -3
- package/dist/design-system-closure.mjs +12 -7
- package/dist/design-usage.mjs +2 -8
- package/dist/emit/contract.mjs +24 -5
- package/dist/emit/emission.mjs +6 -9
- package/dist/emit/integrity.mjs +8 -2
- package/dist/emit/output-watch.mjs +120 -0
- package/dist/emit/owner-emission-cache.mjs +4 -4
- package/dist/emit/preview-emitter.mjs +4 -2
- package/dist/emit/preview-tree.mjs +1 -1
- package/dist/emit/service.mjs +8 -2
- package/dist/finding-rules.mjs +3 -0
- package/dist/form-states.mjs +8 -0
- package/dist/frame-regions.mjs +29 -9
- package/dist/grid-lowering.mjs +3 -1
- package/dist/hover-geometry.mjs +15 -0
- package/dist/input-digests.mjs +17 -10
- package/dist/linaria/delivery.mjs +2 -0
- package/dist/lowering-enter.mjs +6 -6
- package/dist/lowering-properties.mjs +5 -0
- package/dist/lowering-region-layout.mjs +7 -2
- package/dist/lowering-session.mjs +10 -0
- package/dist/mcp/build-status.mjs +9 -1
- package/dist/mcp/compiler-channel.mjs +11 -4
- package/dist/mcp/mutations.mjs +1 -0
- package/dist/mcp/preview-http.bundle.js +1 -1
- package/dist/mcp/preview-watch.mjs +2 -1
- package/dist/mcp/preview-widget.bundle.js +1 -1
- package/dist/mcp/server-observation.mjs +6 -4
- package/dist/mcp/server-project.mjs +4 -1
- package/dist/motion-model.mjs +1 -1
- package/dist/owner-analysis-check.mjs +23 -6
- package/dist/owner-errors.mjs +6 -3
- package/dist/owner-lowering.mjs +78 -13
- package/dist/owner-scenarios.mjs +6 -23
- package/dist/ownership-model.mjs +24 -8
- package/dist/paint-contrast.mjs +6 -0
- package/dist/placeholder-contrast.mjs +17 -1
- package/dist/platform-features.mjs +10 -1
- package/dist/profile-macro.d.mts +7 -0
- package/dist/profile-view-facts.mjs +1 -1
- package/dist/recipe-macro.d.mts +103 -40
- package/dist/recipe-model.mjs +18 -13
- package/dist/region-lowering.mjs +266 -123
- package/dist/render-audit/layout-shift.page.mjs +24 -0
- package/dist/render-audit/render-states.mjs +122 -1
- package/dist/render-audit/render-states.page.mjs +140 -0
- package/dist/render-audit/worker.mjs +18 -3
- package/dist/render-audit.mjs +114 -1
- package/dist/role-vocabulary.d.mts +9 -0
- package/dist/role-vocabulary.mjs +16 -1
- package/dist/runtime-paint-contrast.mjs +5 -2
- package/dist/scenarios-compiler.mjs +20 -6
- package/dist/showcase/assets-view.mjs +29 -13
- package/dist/showcase/client.bundle.js +50 -50
- package/dist/showcase/http-client.bundle.js +15 -15
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +5 -5
- package/dist/skills/ads-designer/references/accessibility.md +10 -4
- package/dist/skills/ads-designer/references/branding.md +13 -3
- package/dist/skills/ads-designer/references/contracts.md +5 -2
- package/dist/skills/ads-designer/references/design-data.md +13 -7
- package/dist/skills/ads-designer/references/layout.md +12 -4
- package/dist/skills/ads-designer/references/motion.md +11 -2
- package/dist/skills/ads-designer/references/recipes.md +49 -15
- package/dist/skills/ads-import/references/contracts.md +5 -2
- package/dist/skills/ads-import/references/design-data.md +13 -7
- package/dist/skills/ads-import/references/layout.md +12 -4
- package/dist/skills/ads-import/references/recipes.md +49 -15
- package/dist/skills/ads-migrate/SKILL.md +2 -0
- package/dist/skills/ads-migrate/references/0.5.1-to-0.5.2.md +185 -0
- package/dist/skills/ads-migrate/references/0.5.2-to-0.5.3.md +71 -0
- package/dist/skills/ads-port/references/contracts.md +5 -2
- package/dist/skills/ads-port/references/design-data.md +13 -7
- package/dist/skills/ads-port/references/layout.md +12 -4
- package/dist/skills/ads-port/references/recipes.md +49 -15
- package/dist/spatial-model.mjs +2 -2
- package/dist/surface-contrast.mjs +7 -2
- package/dist/surface-effects.mjs +5 -3
- package/dist/target-size.mjs +21 -3
- package/dist/task-cache.mjs +8 -18
- package/dist/validation-checks.mjs +1 -1
- package/docs/ADS.md +9 -3
- package/docs/ARCHITECTURE.md +96 -30
- package/docs/CACHING.md +152 -24
- package/docs/CHANGELOG.md +307 -23
- package/docs/GUIDE.md +109 -20
- package/docs/LANGUAGE.md +262 -117
- package/docs/MCP.md +5 -1
- package/docs/MOTION.md +15 -4
- package/docs/PROFILE-KINDS.md +54 -4
- package/docs/RULES.md +34 -25
- package/docs/TOKEN-ROLES.md +7 -1
- package/package.json +1 -1
- package/dist/analysis/prose-owners.mjs +0 -57
- package/dist/prose-model.d.mts +0 -81
- package/dist/prose-model.mjs +0 -101
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { SyntaxKind, isExportAssignment, isExportDeclaration, isImportDeclaration } from "typescript/ast";
|
|
3
3
|
import { digest } from "../digest.mjs";
|
|
4
4
|
import { memoProgram } from "./context.mjs";
|
|
5
|
-
export const OWNER_ANALYSIS_SCHEMA = "ads-owner-analysis/
|
|
5
|
+
export const OWNER_ANALYSIS_SCHEMA = "ads-owner-analysis/12";
|
|
6
6
|
export function canonical(value) {
|
|
7
7
|
return JSON.stringify(value, (_key, item) => {
|
|
8
8
|
if (item instanceof Map)
|
|
@@ -17,17 +17,19 @@ export function canonical(value) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
const assetDigests = new WeakMap;
|
|
20
|
-
export function assetsDigest(assets) {
|
|
21
|
-
const
|
|
20
|
+
export function assetsDigest(assets, root = "") {
|
|
21
|
+
const byRoot = assetDigests.get(assets) ?? new Map;
|
|
22
|
+
assetDigests.set(assets, byRoot);
|
|
23
|
+
const known = byRoot.get(root);
|
|
22
24
|
if (known !== void 0)
|
|
23
25
|
return known;
|
|
24
|
-
const computed = digest(canonical(assets));
|
|
25
|
-
|
|
26
|
+
const computed = digest(rootRelative(canonical(assets), root));
|
|
27
|
+
byRoot.set(root, computed);
|
|
26
28
|
return computed;
|
|
27
29
|
}
|
|
28
|
-
export function designDigests(captured, assets) {
|
|
30
|
+
export function designDigests(captured, assets, root = "") {
|
|
29
31
|
const under = (folder) => digest([...captured].filter(([name]) => name.startsWith(`${folder}/`)));
|
|
30
|
-
return { profiles: under("profiles"), tokens: under("tokens"), assets: assetsDigest(assets) };
|
|
32
|
+
return { profiles: under("profiles"), tokens: under("tokens"), assets: assetsDigest(assets, root) };
|
|
31
33
|
}
|
|
32
34
|
const AUGMENTATION = /\bdeclare\s+(?:global|module)\b/, exported = (statement) => ("modifiers" in statement) && Array.isArray(statement.modifiers) && statement.modifiers.some((modifier) => modifier.kind === SyntaxKind.ExportKeyword);
|
|
33
35
|
export function declaresGlobally(source) {
|
|
@@ -69,8 +71,6 @@ export function ownerAnalysisKey(facts, graph, owner, barrel, owners, settled, c
|
|
|
69
71
|
contexts: facts.contexts,
|
|
70
72
|
sources: files.map(facts.source),
|
|
71
73
|
globals: facts.globals,
|
|
72
|
-
profiles: facts.design.profiles,
|
|
73
|
-
assets: facts.design.assets,
|
|
74
74
|
rows
|
|
75
75
|
};
|
|
76
76
|
}
|
|
@@ -84,7 +84,39 @@ function closureRows(owner, settled) {
|
|
|
84
84
|
return { kind: "unavailable", owner };
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
export const keyDigest = (key) => digest(canonical(key));
|
|
87
|
+
export const keyDigest = (key) => digest(rootRelative(canonical({ ...key, root: "" }), key.root));
|
|
88
|
+
export function rootRelative(text, root) {
|
|
89
|
+
if (root === "")
|
|
90
|
+
return text;
|
|
91
|
+
const escaped = JSON.stringify(root).slice(1, -1);
|
|
92
|
+
return text.split(escaped).join("<root>");
|
|
93
|
+
}
|
|
94
|
+
export function relocateOutcome(outcome, from, to) {
|
|
95
|
+
if (from === to)
|
|
96
|
+
return outcome;
|
|
97
|
+
const move = (value) => {
|
|
98
|
+
if (typeof value === "string")
|
|
99
|
+
return value === from ? to : value.includes(from) ? value.split(`${from}${path.sep}`).join(`${to}${path.sep}`) : value;
|
|
100
|
+
if (Array.isArray(value)) {
|
|
101
|
+
const items = value.map(move);
|
|
102
|
+
return items.some((item, index) => item !== value[index]) ? items : value;
|
|
103
|
+
}
|
|
104
|
+
if (value instanceof Map) {
|
|
105
|
+
const entries = [...value].map(([key, item]) => [key, item, move(key), move(item)]);
|
|
106
|
+
return entries.some(([key, item, movedKey, movedItem]) => key !== movedKey || item !== movedItem) ? new Map(entries.map(([, , key, item]) => [key, item])) : value;
|
|
107
|
+
}
|
|
108
|
+
if (value instanceof Set) {
|
|
109
|
+
const items = [...value].map((item) => [item, move(item)]);
|
|
110
|
+
return items.some(([item, moved]) => item !== moved) ? new Set(items.map(([, moved]) => moved)) : value;
|
|
111
|
+
}
|
|
112
|
+
if (value !== null && typeof value === "object" && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)) {
|
|
113
|
+
const entries = Object.entries(value).map(([key, item]) => [key, item, move(item)]);
|
|
114
|
+
return entries.some(([, item, moved]) => item !== moved) ? Object.fromEntries(entries.map(([key, , moved]) => [key, moved])) : value;
|
|
115
|
+
}
|
|
116
|
+
return value;
|
|
117
|
+
};
|
|
118
|
+
return move(outcome);
|
|
119
|
+
}
|
|
88
120
|
export function traceTokenReads(foundation) {
|
|
89
121
|
let read = !1;
|
|
90
122
|
const mark = (value) => {
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
isElementAccessExpression,
|
|
13
13
|
isFunctionExpression,
|
|
14
14
|
isIdentifier,
|
|
15
|
+
isJsxOpeningElement,
|
|
16
|
+
isJsxSelfClosingElement,
|
|
15
17
|
isImportDeclaration,
|
|
16
18
|
isNamedImports,
|
|
17
19
|
isNumericLiteral,
|
|
@@ -43,7 +45,21 @@ import {
|
|
|
43
45
|
import { isJsonObject, jsonObject } from "../json.mjs";
|
|
44
46
|
import { combineRecipes, recipe } from "../recipe-model.mjs";
|
|
45
47
|
import { normalizeValueFailure } from "../construction-spec.mjs";
|
|
46
|
-
|
|
48
|
+
function nestedParts(parts, name) {
|
|
49
|
+
const found = [], visit = (declared, top) => {
|
|
50
|
+
if (declared === void 0 || !isJsonObject(declared))
|
|
51
|
+
return;
|
|
52
|
+
for (const [key, part] of Object.entries(declared)) {
|
|
53
|
+
if (!top && key === name)
|
|
54
|
+
found.push(part);
|
|
55
|
+
if (isJsonObject(part))
|
|
56
|
+
visit(part.parts, !1);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
visit(parts, !0);
|
|
60
|
+
return found;
|
|
61
|
+
}
|
|
62
|
+
export const choiceLimits = Object.freeze({ depth: 64, steps: 20000, branches: 16384, alternatives: 4096 }), RECIPE_MODULE = "@reqvire-org/ads/recipe";
|
|
47
63
|
const tagged = (value) => typeof value === "object" && value !== null;
|
|
48
64
|
export function authoredAt(calls, specPath) {
|
|
49
65
|
const keys = specPath.split(".").slice(1);
|
|
@@ -199,7 +215,7 @@ const compiledString = (node) => {
|
|
|
199
215
|
return !0;
|
|
200
216
|
const queries = isElementAccessExpression(read) || isPropertyAccessExpression(read) ? unwrapNode(read.expression) : null;
|
|
201
217
|
return queries !== null && isPropertyAccessExpression(queries) && queries.name.text === "conditionQuery";
|
|
202
|
-
}
|
|
218
|
+
}, ELEMENT_NAME = /^[a-z][a-z0-9]*$/, HEADING_LEVEL = /^h[1-6]$/;
|
|
203
219
|
export async function choiceValues({ program, source, root, validateSpec, fail }) {
|
|
204
220
|
const checker = program.getTypeChecker(), roots = { root, dsRoot: root }, symbols = new Map, types = new Map, specs = new Map, macros = new Map, axes = new Map, touched = new Set, macroCalls = new Map, mutable = new Set, escaped = new Set, traced = sourceValues(program, roots), failIn = (context) => context?.fail ?? fail, incomplete = (context, node, problem) => failIn(context)(node, { kind: "choice", problem }), touch = (declaration, context) => {
|
|
205
221
|
if (context.fail === void 0)
|
|
@@ -284,6 +300,13 @@ export async function choiceValues({ program, source, root, validateSpec, fail }
|
|
|
284
300
|
context.trail?.push([item.id, value]);
|
|
285
301
|
return value;
|
|
286
302
|
};
|
|
303
|
+
async function declaredState(declaration) {
|
|
304
|
+
const declared = await type(declaration.name), finite = finiteType(declared);
|
|
305
|
+
if (finite !== null)
|
|
306
|
+
return finite.length > 1;
|
|
307
|
+
const presence = presenceDomain(declared);
|
|
308
|
+
return presence !== null && presence.opaque && presence.classes.length > 1;
|
|
309
|
+
}
|
|
287
310
|
async function bindingAxis(node, declaration, context) {
|
|
288
311
|
const binding = await symbol(node);
|
|
289
312
|
if (binding === void 0)
|
|
@@ -322,7 +345,8 @@ export async function choiceValues({ program, source, root, validateSpec, fail }
|
|
|
322
345
|
declaration,
|
|
323
346
|
parameter,
|
|
324
347
|
name,
|
|
325
|
-
defaultNode: parameter !== null ? initializer : void 0
|
|
348
|
+
defaultNode: parameter !== null ? initializer : void 0,
|
|
349
|
+
...parameter !== null && name !== null ? { omitted: { value: initial !== void 0 ? defaulted : test === "text" ? "absent" : void 0 } } : {}
|
|
326
350
|
};
|
|
327
351
|
axes.set(binding, item);
|
|
328
352
|
}
|
|
@@ -459,7 +483,10 @@ export async function choiceValues({ program, source, root, validateSpec, fail }
|
|
|
459
483
|
return incomplete(context, node, { kind: "recipe-access-unsupported", key });
|
|
460
484
|
case "parts":
|
|
461
485
|
case "assets": {
|
|
462
|
-
const parts = object.handle.descriptor.spec.parts,
|
|
486
|
+
const parts = object.handle.descriptor.spec.parts, top = parts !== void 0 && isJsonObject(parts) ? parts[key] : void 0, nested = top === void 0 ? nestedParts(parts, key) : [];
|
|
487
|
+
if (nested.length > 1)
|
|
488
|
+
return incomplete(context, node, { kind: "part-ambiguous", name: key });
|
|
489
|
+
const part = top ?? nested[0];
|
|
463
490
|
if (part === void 0)
|
|
464
491
|
return incomplete(context, node, { kind: "part-unknown", name: key });
|
|
465
492
|
return { kind: object.kind === "parts" ? "asset-class" : "asset", handle: object.handle, part, name: key };
|
|
@@ -566,6 +593,11 @@ export async function choiceValues({ program, source, root, validateSpec, fail }
|
|
|
566
593
|
const domain = finiteType(await type(declaration.name));
|
|
567
594
|
if (domain !== null && domain.length > 0 && domain.every((value) => typeof value === "boolean"))
|
|
568
595
|
return bindingAxis(node, declaration, context);
|
|
596
|
+
if (declaration.type !== void 0 && await declaredState(declaration)) {
|
|
597
|
+
const initializer = declaration.initializer, { trail: _, ...outer } = context;
|
|
598
|
+
if ((await attemptAsync((reject) => evaluate(initializer, { ...outer, fail: () => reject(null), memo: new Map }))).kind === "err")
|
|
599
|
+
return bindingAxis(node, declaration, context);
|
|
600
|
+
}
|
|
569
601
|
const result = await evaluate(declaration.initializer, context);
|
|
570
602
|
if (escaped.has(binding) && tagged(result) && (result.kind === "record" || result.kind === "recipe"))
|
|
571
603
|
return incomplete(context, node, { kind: "record-escapes" });
|
|
@@ -821,8 +853,10 @@ export async function choiceValues({ program, source, root, validateSpec, fail }
|
|
|
821
853
|
let branches = 0;
|
|
822
854
|
const leaves = [], selectedAxes = new Map;
|
|
823
855
|
async function visit(assignment) {
|
|
824
|
-
if (++branches > choiceLimits.branches)
|
|
825
|
-
|
|
856
|
+
if (++branches > choiceLimits.branches) {
|
|
857
|
+
const axes = [...selectedAxes.values()].map((axis) => ({ name: axis.name ?? axis.expression, values: axis.domain.length })).sort((a, b) => b.values - a.values || (a.name < b.name ? -1 : 1));
|
|
858
|
+
return failure(node, { kind: "choice", problem: { kind: "branch-limit", limit: choiceLimits.branches, axes } });
|
|
859
|
+
}
|
|
826
860
|
if (!await possible(assignment, [...selectedAxes.values()], tolerant))
|
|
827
861
|
return null;
|
|
828
862
|
const outcome = await attemptAsync((need) => resolve({ assignment, memo: new Map, stack: new Set, budget: { steps: 0 }, depth: 0, need, ...tolerant === void 0 ? {} : { fail: tolerant } }, evaluate));
|
|
@@ -846,7 +880,22 @@ export async function choiceValues({ program, source, root, validateSpec, fail }
|
|
|
846
880
|
return failure(node, { kind: "choice", problem: { kind: "no-reachable-choice" } });
|
|
847
881
|
return { tree, leaves, axes: [...selectedAxes.values()], branches };
|
|
848
882
|
}
|
|
849
|
-
|
|
883
|
+
const tags = new Map;
|
|
884
|
+
for (const opening of [...nodesOfKind(source, SyntaxKind.JsxOpeningElement, isJsxOpeningElement), ...nodesOfKind(source, SyntaxKind.JsxSelfClosingElement, isJsxSelfClosingElement)]) {
|
|
885
|
+
const tagName = opening.tagName;
|
|
886
|
+
if (!isIdentifier(tagName) || !/^[A-Z]/.test(tagName.text))
|
|
887
|
+
continue;
|
|
888
|
+
const declared = (await symbol(tagName))?.valueDeclaration;
|
|
889
|
+
if (!(declared !== void 0 && (isBindingElement(declared) || isParameterDeclaration(declared) || isVariableDeclaration(declared) && declared.initializer !== void 0 && !isArrowFunction(declared.initializer) && !isFunctionExpression(declared.initializer))))
|
|
890
|
+
continue;
|
|
891
|
+
const domain = finiteType(await type(tagName)), names = domain?.filter((value) => typeof value === "string" && ELEMENT_NAME.test(value)) ?? [];
|
|
892
|
+
if (domain === null || names.length === 0 || names.length !== domain.length)
|
|
893
|
+
continue;
|
|
894
|
+
const [first] = names;
|
|
895
|
+
if (first !== void 0 && (names.length === 1 || names.every((name) => HEADING_LEVEL.test(name))))
|
|
896
|
+
tags.set(tagName, first);
|
|
897
|
+
}
|
|
898
|
+
return { source, evaluate, choices, truthy, symbol, touched, macroCalls, tag: (opening) => tags.get(opening.tagName) ?? opening.tagName.getText() };
|
|
850
899
|
}
|
|
851
900
|
function test(axis, value) {
|
|
852
901
|
switch (axis.test) {
|
|
@@ -45,8 +45,9 @@ import { TypeFlags } from "typescript/async";
|
|
|
45
45
|
import { selectedProfile } from "../design-foundation.mjs";
|
|
46
46
|
import { parseConstruction } from "../construction-spec.mjs";
|
|
47
47
|
import { combineRecipes } from "../recipe-model.mjs";
|
|
48
|
+
import { relevantAxes } from "./composition-axes.mjs";
|
|
48
49
|
import { surfacedElements } from "../surface-contrast.mjs";
|
|
49
|
-
import { frameInlinePadding, gridKeylineOf } from "../frame-regions.mjs";
|
|
50
|
+
import { frameInlinePadding, gridKeylineOf, rootFrames } from "../frame-regions.mjs";
|
|
50
51
|
import { attemptAsync } from "../result.mjs";
|
|
51
52
|
import { location, nodesOfKind } from "./native-boundary.mjs";
|
|
52
53
|
import { authoredAt, classItems, mapCallback, nameText, presenceDomain, truthiness } from "./owner-choices.mjs";
|
|
@@ -79,7 +80,7 @@ export async function plainPlacements(root, source, symbol) {
|
|
|
79
80
|
}
|
|
80
81
|
return placements;
|
|
81
82
|
}
|
|
82
|
-
const LEAF_LIMIT = 512, elementOf = (opening) => isJsxOpeningElement(opening) ? opening.parent : opening
|
|
83
|
+
const LEAF_LIMIT = 512, elementOf = (opening) => isJsxOpeningElement(opening) ? opening.parent : opening;
|
|
83
84
|
function expression(attribute) {
|
|
84
85
|
const initializer = attribute?.initializer;
|
|
85
86
|
if (initializer === void 0)
|
|
@@ -91,9 +92,25 @@ const unwrap = (node) => {
|
|
|
91
92
|
while (isParenthesizedExpression(current) || isAsExpression(current) || isSatisfiesExpression(current) || isNonNullExpression(current))
|
|
92
93
|
current = current.expression;
|
|
93
94
|
return current;
|
|
94
|
-
}, isLoop = (node) => isForStatement(node) || isForOfStatement(node) || isForInStatement(node) || isWhileStatement(node) || isDoStatement(node), TRANSPARENT_STATEMENTS = new Set([SyntaxKind.CaseClause, SyntaxKind.DefaultClause, SyntaxKind.CaseBlock, SyntaxKind.SwitchStatement, SyntaxKind.TryStatement, SyntaxKind.CatchClause, SyntaxKind.LabeledStatement]), transparentTag = (tag) => tag === "Fragment" || tag.endsWith(".Fragment") || tag.endsWith(".Provider"), DISABLEABLE = new Set(["button", "fieldset", "input", "select", "textarea", "optgroup", "option"]);
|
|
95
|
+
}, isLoop = (node) => isForStatement(node) || isForOfStatement(node) || isForInStatement(node) || isWhileStatement(node) || isDoStatement(node), TRANSPARENT_STATEMENTS = new Set([SyntaxKind.CaseClause, SyntaxKind.DefaultClause, SyntaxKind.CaseBlock, SyntaxKind.SwitchStatement, SyntaxKind.TryStatement, SyntaxKind.CatchClause, SyntaxKind.LabeledStatement]), transparentTag = (tag) => tag === "Fragment" || tag.endsWith(".Fragment") || tag.endsWith(".Provider"), DISABLEABLE = new Set(["button", "fieldset", "input", "select", "textarea", "optgroup", "option"]), ATTRIBUTE_TEST = /\[([\w-]+)(?:="([^"]*)")?\]/g;
|
|
96
|
+
export function reachableSurfaces(surfaces, attributes) {
|
|
97
|
+
if (attributes === "open")
|
|
98
|
+
return surfaces;
|
|
99
|
+
const holds = (condition) => {
|
|
100
|
+
const positive = condition.replace(/:not\((?:[^()]|\([^()]*\))*\)/g, "");
|
|
101
|
+
for (const [, name, expected] of positive.matchAll(ATTRIBUTE_TEST)) {
|
|
102
|
+
if (name === void 0 || !attributes.has(name))
|
|
103
|
+
continue;
|
|
104
|
+
const rendered = attributes.get(name) ?? null;
|
|
105
|
+
if (rendered === null || expected !== void 0 && rendered !== expected)
|
|
106
|
+
return !1;
|
|
107
|
+
}
|
|
108
|
+
return !0;
|
|
109
|
+
}, kept = surfaces.filter((state) => state.condition === null || holds(state.condition));
|
|
110
|
+
return kept.length === surfaces.length ? surfaces : kept;
|
|
111
|
+
}
|
|
95
112
|
export async function compositionFacts(inputs) {
|
|
96
|
-
const { root, source, values, checker, foundation } = inputs, points = new Map, point = (node) => {
|
|
113
|
+
const { root, source, values, checker, foundation } = inputs, lowercase = (opening) => /^[a-z]/.test(values.tag(opening)), points = new Map, point = (node) => {
|
|
97
114
|
let known = points.get(node);
|
|
98
115
|
if (known === void 0) {
|
|
99
116
|
const at = location(node);
|
|
@@ -103,7 +120,7 @@ export async function compositionFacts(inputs) {
|
|
|
103
120
|
}, tags = new Map, tagOf = (opening) => {
|
|
104
121
|
let known = tags.get(opening);
|
|
105
122
|
if (known === void 0)
|
|
106
|
-
tags.set(opening, known =
|
|
123
|
+
tags.set(opening, known = values.tag(opening));
|
|
107
124
|
return known;
|
|
108
125
|
}, attributes = new Map, attributeOf = (opening, name) => {
|
|
109
126
|
let known = attributes.get(opening);
|
|
@@ -255,7 +272,7 @@ export async function compositionFacts(inputs) {
|
|
|
255
272
|
const opening = parent.openingElement;
|
|
256
273
|
if (lowercase(opening))
|
|
257
274
|
steps.push({ kind: "element", opening });
|
|
258
|
-
else if (!transparentTag(
|
|
275
|
+
else if (!transparentTag(values.tag(opening)))
|
|
259
276
|
steps.push({ kind: "slot", opening, prop: "children" });
|
|
260
277
|
node = parent;
|
|
261
278
|
continue;
|
|
@@ -330,13 +347,51 @@ export async function compositionFacts(inputs) {
|
|
|
330
347
|
return !0;
|
|
331
348
|
const last = isBlock(statement) ? statement.statements.at(-1) : void 0;
|
|
332
349
|
return last !== void 0 && isReturnStatement(last);
|
|
333
|
-
},
|
|
350
|
+
}, reads = new Map, inputKey = (assignment, inputs) => inputs.map((id) => assignment.has(id) ? JSON.stringify(assignment.get(id) ?? null) : "\x01").join("\x00");
|
|
351
|
+
async function byInputs(cache, node, context, compute) {
|
|
352
|
+
const known = cache.get(node) ?? [];
|
|
353
|
+
for (const entry of known) {
|
|
354
|
+
const hit = entry.results.get(inputKey(context.assignment, entry.inputs));
|
|
355
|
+
if (hit !== void 0)
|
|
356
|
+
return hit;
|
|
357
|
+
}
|
|
358
|
+
const inputs = new Set;
|
|
359
|
+
let whole = !1;
|
|
360
|
+
const all = (value) => (whole = !0, value), recording = {
|
|
361
|
+
get: (id) => (inputs.add(id), context.assignment.get(id)),
|
|
362
|
+
has: (id) => (inputs.add(id), context.assignment.has(id)),
|
|
363
|
+
get size() {
|
|
364
|
+
return all(context.assignment.size);
|
|
365
|
+
},
|
|
366
|
+
forEach: (callback, thisArg) => all(context.assignment.forEach(callback, thisArg)),
|
|
367
|
+
entries: () => all(context.assignment.entries()),
|
|
368
|
+
keys: () => all(context.assignment.keys()),
|
|
369
|
+
values: () => all(context.assignment.values()),
|
|
370
|
+
[Symbol.iterator]: () => all(context.assignment[Symbol.iterator]())
|
|
371
|
+
}, result = await compute({ ...context, assignment: recording });
|
|
372
|
+
if (whole)
|
|
373
|
+
return result;
|
|
374
|
+
const listed = [...inputs].sort();
|
|
375
|
+
let entry = known.find((candidate) => candidate.inputs.join("\x00") === listed.join("\x00"));
|
|
376
|
+
if (entry === void 0) {
|
|
377
|
+
known.push(entry = { inputs: listed, results: new Map });
|
|
378
|
+
cache.set(node, known);
|
|
379
|
+
}
|
|
380
|
+
entry.results.set(inputKey(context.assignment, listed), result);
|
|
381
|
+
return result;
|
|
382
|
+
}
|
|
383
|
+
const optional = async (node, context, evaluate) => {
|
|
334
384
|
if (node === void 0)
|
|
335
385
|
return { known: !0, value: void 0 };
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
386
|
+
return byInputs(reads, node, context, async (recorded) => {
|
|
387
|
+
const read = await attemptAsync((reject) => evaluate(node, { ...recorded, fail: () => reject(null) }));
|
|
388
|
+
return read.kind === "ok" ? { known: !0, value: read.value } : { known: !1 };
|
|
389
|
+
});
|
|
390
|
+
}, elements = new Map, holds = (read) => read.known ? truthiness(read.value) : null, truthy = (value) => truthiness(value) === !0;
|
|
391
|
+
function rawElement(opening, context, evaluate) {
|
|
392
|
+
return byInputs(elements, opening, context, (recorded) => readElement(opening, recorded, evaluate));
|
|
393
|
+
}
|
|
394
|
+
async function readElement(opening, context, evaluate) {
|
|
340
395
|
const tag = tagOf(opening), classAttribute = attributeOf(opening, "className");
|
|
341
396
|
let classes = { fragments: [], calls: [], markers: [] };
|
|
342
397
|
if (classAttribute !== void 0) {
|
|
@@ -373,8 +428,36 @@ export async function compositionFacts(inputs) {
|
|
|
373
428
|
if (read.value === void 0 || read.value === null || read.value === !1)
|
|
374
429
|
return null;
|
|
375
430
|
return typeof read.value === "string" ? read.value : "open";
|
|
376
|
-
}, theme = await named("data-theme"), brand = await named("data-brand");
|
|
377
|
-
|
|
431
|
+
}, theme = await named("data-theme"), brand = await named("data-brand"), subtree = theme === "open" || brand === "open" ? "open" : theme === null && brand === null ? null : { theme, brand }, tested = new Set;
|
|
432
|
+
for (const fragment of classes?.fragments ?? [])
|
|
433
|
+
for (const [, name] of JSON.stringify(fragment.spec).matchAll(/\[((?:aria|data)-[\w-]+)/g))
|
|
434
|
+
if (name !== void 0)
|
|
435
|
+
tested.add(name);
|
|
436
|
+
let attributes = new Map;
|
|
437
|
+
for (const property of tested.size === 0 ? [] : opening.attributes.properties) {
|
|
438
|
+
if (isJsxSpreadAttribute(property)) {
|
|
439
|
+
attributes = "open";
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
if (!isJsxAttribute(property))
|
|
443
|
+
continue;
|
|
444
|
+
const name = property.name.getText(source);
|
|
445
|
+
if (!tested.has(name))
|
|
446
|
+
continue;
|
|
447
|
+
if (property.initializer === void 0) {
|
|
448
|
+
attributes.set(name, "true");
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
const read = await optional(expression(property), context, evaluate);
|
|
452
|
+
if (!read.known)
|
|
453
|
+
continue;
|
|
454
|
+
const { value } = read;
|
|
455
|
+
if (value === void 0 || value === null)
|
|
456
|
+
attributes.set(name, null);
|
|
457
|
+
else if (typeof value === "string" || typeof value === "number" || typeof value === "boolean")
|
|
458
|
+
attributes.set(name, String(value));
|
|
459
|
+
}
|
|
460
|
+
return { opening, classes, exempt: hidden ? "hidden" : inactive ? "inactive" : null, context: subtree, attributes };
|
|
378
461
|
}
|
|
379
462
|
async function resolveLeaf(pathed, context, evaluate) {
|
|
380
463
|
const steps = [];
|
|
@@ -444,7 +527,10 @@ export async function compositionFacts(inputs) {
|
|
|
444
527
|
const node = raw.opening;
|
|
445
528
|
if (raw.classes === null)
|
|
446
529
|
return { surfaces: null, text: null, scope: null, flow: "in", parts: null, grid: null, frame: void 0, keyline: void 0 };
|
|
447
|
-
const { markers, calls } = raw.classes, part = parent?.parts?.list.find((candidate) => markers.includes(candidate.selector.slice(1))) ?? null, cell = parent?.grid?.spec.cells.find((candidate) => markers.includes(candidate.selector.slice(1))) ?? null, overlay = cell !== null && [cell.values, ...cell.at.map(([, values]) => values)].some((values) => values.some(([key, value]) => key === "overlay" && value !== "none")), own = constructionOf(raw.classes), framed = own === null ? null : frameInlinePadding(foundation, own),
|
|
530
|
+
const { markers, calls } = raw.classes, part = parent?.parts?.list.find((candidate) => markers.includes(candidate.selector.slice(1))) ?? null, cell = parent?.grid?.spec.cells.find((candidate) => markers.includes(candidate.selector.slice(1))) ?? null, overlay = cell !== null && [cell.values, ...cell.at.map(([, values]) => values)].some((values) => values.some(([key, value]) => key === "overlay" && value !== "none")), own = constructionOf(raw.classes), framed = own === null ? null : frameInlinePadding(foundation, own), stated = framed === null ? [] : rootFrames(own).flatMap((under) => {
|
|
531
|
+
const selected = under === void 0 ? null : frameInlinePadding(foundation, own, under);
|
|
532
|
+
return selected === null ? [] : [{ name: selected.frame, padding: selected.padding }];
|
|
533
|
+
}), frame = framed === null ? void 0 : { name: framed.frame, padding: framed.padding, ...stated.length === 0 ? {} : { states: stated } }, keyline = own?.kind === "grid" ? gridKeylineOf(foundation, own) ?? void 0 : void 0, scope = String(node.getStart(source));
|
|
448
534
|
let surfaces = [], text = null, flow = overlay ? "overlay" : "in", parts = null, grid = null, ownScope = null;
|
|
449
535
|
if (part !== null && parent?.parts !== null && parent?.parts !== void 0) {
|
|
450
536
|
const { spec, prefix, calls: partCalls } = parent.parts, partPath = `${prefix}.${part.name}`;
|
|
@@ -494,15 +580,19 @@ export async function compositionFacts(inputs) {
|
|
|
494
580
|
function chainElements(raws) {
|
|
495
581
|
const elements = [];
|
|
496
582
|
let parent = null;
|
|
583
|
+
const rootAttributes = new Map;
|
|
497
584
|
for (let index = raws.length - 1;index >= 0; index--) {
|
|
498
585
|
const raw = raws[index];
|
|
499
586
|
if (raw === void 0)
|
|
500
587
|
continue;
|
|
501
588
|
const role = roleOf(raw, parent);
|
|
589
|
+
if (role.scope !== null && role.scope === String(raw.opening.getStart(source)))
|
|
590
|
+
rootAttributes.set(role.scope, raw.attributes);
|
|
591
|
+
const tested = role.scope === null ? void 0 : rootAttributes.get(role.scope);
|
|
502
592
|
elements.push({
|
|
503
593
|
tag: tagOf(raw.opening),
|
|
504
594
|
at: point(raw.opening),
|
|
505
|
-
surfaces: role.surfaces,
|
|
595
|
+
surfaces: role.surfaces === null || tested === void 0 ? role.surfaces : reachableSurfaces(role.surfaces, tested),
|
|
506
596
|
scope: role.scope,
|
|
507
597
|
text: role.text,
|
|
508
598
|
flow: role.flow,
|
|
@@ -542,14 +632,14 @@ export async function compositionFacts(inputs) {
|
|
|
542
632
|
const bare = unwrap(value), scalar = isStringLiteral(bare) || isNoSubstitutionTemplateLiteral(bare) ? { known: !0, value: bare.text } : isNumericLiteral(bare) ? { known: !0, value: Number(bare.text) } : bare.kind === SyntaxKind.TrueKeyword ? { known: !0, value: !0 } : bare.kind === SyntaxKind.FalseKeyword ? { known: !0, value: !1 } : bare.kind === SyntaxKind.NullKeyword ? { known: !0, value: null } : isIdentifier(bare) && bare.text === "undefined" ? { known: !0, value: void 0 } : { known: !1, value: void 0 }, renders = /^on[A-Z]/.test(prop) ? [] : await rendersOf(value, fn), forwardedProp = renders.find((item) => item.kind === "forward")?.prop ?? null, text = renders.some((item) => item.kind === "text" && item.certain) ? "text" : forwardedProp !== null ? "forward" : renders.some((item) => item.kind === "text") ? "maybe-text" : "none";
|
|
543
633
|
args.push({ prop, value: scalar.known ? { kind: "literal", value: literal(scalar.value) } : { kind: "open", given: await certainlyGiven(bare) }, text, forwards: text === "forward" ? forwardedProp : null, at: located });
|
|
544
634
|
}
|
|
545
|
-
return { kind: "placement", tag:
|
|
635
|
+
return { kind: "placement", tag: values.tag(opening), target: await targetOf(opening), args, spread };
|
|
546
636
|
}
|
|
547
|
-
const pending = [], insideSvg = (pathed) => pathed.steps.some((step) => step.kind === "element" && ["svg", "style", "script", "template"].includes(step.opening
|
|
637
|
+
const pending = [], insideSvg = (pathed) => pathed.steps.some((step) => step.kind === "element" && ["svg", "style", "script", "template"].includes(values.tag(step.opening))), openings = [
|
|
548
638
|
...nodesOfKind(source, SyntaxKind.JsxOpeningElement, isJsxOpeningElement),
|
|
549
639
|
...nodesOfKind(source, SyntaxKind.JsxSelfClosingElement, isJsxSelfClosingElement)
|
|
550
640
|
].sort((a, b) => a.pos - b.pos);
|
|
551
641
|
for (const opening of openings) {
|
|
552
|
-
if (lowercase(opening) || transparentTag(
|
|
642
|
+
if (lowercase(opening) || transparentTag(values.tag(opening)))
|
|
553
643
|
continue;
|
|
554
644
|
const element = elementOf(opening), pathed = pathOf(element);
|
|
555
645
|
if (insideSvg(pathed))
|
|
@@ -587,7 +677,30 @@ export async function compositionFacts(inputs) {
|
|
|
587
677
|
if (item.opening !== null)
|
|
588
678
|
placementIndex.set(item.opening, index);
|
|
589
679
|
});
|
|
590
|
-
const positions = []
|
|
680
|
+
const positions = [], byPath = new Map, nodeIds = new WeakMap, nodeId = (node) => {
|
|
681
|
+
let known = nodeIds.get(node);
|
|
682
|
+
if (known === void 0)
|
|
683
|
+
nodeIds.set(node, known = nextNode++);
|
|
684
|
+
return known;
|
|
685
|
+
};
|
|
686
|
+
let nextNode = 0;
|
|
687
|
+
const pathSignature = (pathed) => JSON.stringify([
|
|
688
|
+
pathed.steps.map((step) => {
|
|
689
|
+
switch (step.kind) {
|
|
690
|
+
case "element":
|
|
691
|
+
return ["e", nodeId(step.opening)];
|
|
692
|
+
case "slot":
|
|
693
|
+
return ["s", nodeId(step.opening), step.prop];
|
|
694
|
+
case "and":
|
|
695
|
+
return ["a", nodeId(step.left)];
|
|
696
|
+
case "branch":
|
|
697
|
+
return ["b", nodeId(step.condition), step.when];
|
|
698
|
+
case "returns":
|
|
699
|
+
return ["r", step.conditions.map(nodeId)];
|
|
700
|
+
}
|
|
701
|
+
}),
|
|
702
|
+
pathed.end.kind === "root" ? ["root", pathed.end.component, nodeId(pathed.end.fn)] : ["unknown", pathed.end.reason, nodeId(pathed.end.at)]
|
|
703
|
+
]);
|
|
591
704
|
for (const item of pending) {
|
|
592
705
|
const { path: pathed } = item, component = pathed.end.kind === "root" ? pathed.end.component : pathed.end.component;
|
|
593
706
|
if (component === null) {
|
|
@@ -595,42 +708,63 @@ export async function compositionFacts(inputs) {
|
|
|
595
708
|
positions.push({ component: "", content: item.content, at: point(item.at), leaves: { kind: "known", leaves: [{ segments: [{ elements: [], end }], props: [] }] } });
|
|
596
709
|
continue;
|
|
597
710
|
}
|
|
711
|
+
const signature = pathSignature(pathed);
|
|
712
|
+
let shared = byPath.get(signature);
|
|
713
|
+
if (shared === void 0)
|
|
714
|
+
byPath.set(signature, shared = leavesOf(pathed, item.node));
|
|
715
|
+
positions.push({ component, content: item.content, at: point(item.at), leaves: await shared });
|
|
716
|
+
}
|
|
717
|
+
return { positions };
|
|
718
|
+
async function leavesOf(pathed, node) {
|
|
598
719
|
const props = pathed.end.kind === "root" ? propsOf(pathed.end.fn) : null, enumerated = await attemptAsync((reject) => {
|
|
599
720
|
const tolerant = (_node, problem) => reject(problem.kind === "choice" ? problem.problem.kind : problem.kind);
|
|
600
|
-
return values.choices(
|
|
721
|
+
return values.choices(node, (context, evaluate) => resolveLeaf(pathed, context, evaluate), tolerant);
|
|
601
722
|
});
|
|
602
|
-
if (enumerated.kind === "err")
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
}
|
|
606
|
-
const axes = new Map(enumerated.value.axes.map((axis) => [axis.id, axis])), leaves = new Map;
|
|
607
|
-
for (const leaf of enumerated.value.leaves) {
|
|
723
|
+
if (enumerated.kind === "err")
|
|
724
|
+
return enumerated.error === "no-reachable-choice" ? { kind: "known", leaves: [] } : { kind: "limit" };
|
|
725
|
+
const axes = new Map(enumerated.value.axes.map((axis) => [axis.id, axis])), rootEnd = pathed.end.kind === "root" ? { kind: "root" } : { kind: "unknown", reason: pathed.end.reason, at: point(pathed.end.at) }, chains = new Map, built = enumerated.value.leaves.map((leaf) => {
|
|
608
726
|
if (leaf.value.kind === "absent")
|
|
609
|
-
|
|
610
|
-
const
|
|
611
|
-
let
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
continue;
|
|
616
|
-
}
|
|
617
|
-
const index = placementIndex.get(step.opening), end = index === void 0 ? { kind: "unknown", reason: "not-in-place", at: point(step.opening) } : { kind: "slot", placement: index, prop: step.prop };
|
|
618
|
-
segments.push({ elements: chainElements(run), end });
|
|
619
|
-
run = [];
|
|
727
|
+
return { leaf, chain: null };
|
|
728
|
+
const raw = rawSignature(leaf.value.steps);
|
|
729
|
+
let chain = chains.get(raw);
|
|
730
|
+
if (chain === void 0) {
|
|
731
|
+
const segments = segmentsOf(leaf.value.steps, rootEnd);
|
|
732
|
+
chains.set(raw, chain = { segments, text: JSON.stringify(segments) });
|
|
620
733
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
734
|
+
return { leaf, chain };
|
|
735
|
+
}), relevant = relevantAxes(built.map(({ leaf, chain }) => ({ assignment: leaf.assignment, outcome: chain === null ? "absent" : chain.text }))), leaves = new Map;
|
|
736
|
+
for (const { leaf, chain } of built) {
|
|
737
|
+
if (chain === null)
|
|
738
|
+
continue;
|
|
739
|
+
const { segments } = chain, leafProps = [];
|
|
624
740
|
for (const [id, value] of leaf.assignment) {
|
|
625
741
|
const axis = axes.get(id);
|
|
626
|
-
if (axis === void 0 || axis.name === null || props === null || axis.parameter !== props)
|
|
742
|
+
if (!relevant.has(id) || axis === void 0 || axis.name === null || props === null || axis.parameter !== props)
|
|
627
743
|
continue;
|
|
628
|
-
|
|
744
|
+
const omitted = axis.test === "presence" || axis.omitted === void 0 ? {} : { omitted: Object.is(axis.omitted.value, value) };
|
|
745
|
+
leafProps.push({ prop: axis.name, test: axis.test, value: literal(value), ...omitted });
|
|
629
746
|
}
|
|
630
747
|
const fact = { segments, props: leafProps };
|
|
631
|
-
leaves.set(JSON.stringify(
|
|
748
|
+
leaves.set(`${chain.text}\x00${JSON.stringify(leafProps)}`, fact);
|
|
632
749
|
}
|
|
633
|
-
|
|
750
|
+
return leaves.size > LEAF_LIMIT ? { kind: "limit" } : { kind: "known", leaves: [...leaves.values()] };
|
|
751
|
+
}
|
|
752
|
+
function rawSignature(steps) {
|
|
753
|
+
return steps.map((step) => step.kind === "slot" ? `s${objectId(step.opening)}:${step.prop}` : `e${objectId(step.element)}`).join("|");
|
|
754
|
+
}
|
|
755
|
+
function segmentsOf(steps, rootEnd) {
|
|
756
|
+
const segments = [];
|
|
757
|
+
let run = [];
|
|
758
|
+
for (const step of steps) {
|
|
759
|
+
if (step.kind === "element") {
|
|
760
|
+
run.push(step.element);
|
|
761
|
+
continue;
|
|
762
|
+
}
|
|
763
|
+
const index = placementIndex.get(step.opening), end = index === void 0 ? { kind: "unknown", reason: "not-in-place", at: point(step.opening) } : { kind: "slot", placement: index, prop: step.prop };
|
|
764
|
+
segments.push({ elements: chainElements(run), end });
|
|
765
|
+
run = [];
|
|
766
|
+
}
|
|
767
|
+
segments.push({ elements: chainElements(run), end: rootEnd });
|
|
768
|
+
return segments;
|
|
634
769
|
}
|
|
635
|
-
return { positions };
|
|
636
770
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { designReadsMatch, traceDesignReads, wholeDesignDigests } from "./design-reads.mjs";
|
|
2
3
|
import { digest } from "../digest.mjs";
|
|
3
4
|
import { optionalSourceText } from "./helpers.mjs";
|
|
4
5
|
import {
|
|
5
6
|
canonical,
|
|
6
7
|
keyDigest,
|
|
8
|
+
relocateOutcome,
|
|
7
9
|
ownerAnalysisKey,
|
|
8
10
|
programGlobals,
|
|
9
11
|
rowsDigest,
|
|
@@ -37,7 +39,7 @@ async function pass(inputs, program, graph, keys) {
|
|
|
37
39
|
return {
|
|
38
40
|
owner: async ({ name, analyze }) => {
|
|
39
41
|
analyzed.push(name);
|
|
40
|
-
return analyze(inputs.foundation);
|
|
42
|
+
return analyze(inputs.foundation, inputs.assets);
|
|
41
43
|
},
|
|
42
44
|
scenarioStyling: (_file, compute) => obtainScenarioResult(null, inputs.root, void 0, "styling", compute),
|
|
43
45
|
tally
|
|
@@ -58,17 +60,17 @@ async function pass(inputs, program, graph, keys) {
|
|
|
58
60
|
digests.set(file, computed);
|
|
59
61
|
return computed;
|
|
60
62
|
}
|
|
61
|
-
}, rows = new Map, owner = async ({ name, settled, analyze }) => {
|
|
63
|
+
}, whole = wholeDesignDigests(inputs.foundation, inputs.design.assets), rows = new Map, owner = async ({ name, settled, analyze }) => {
|
|
62
64
|
const key = keyDigest(ownerAnalysisKey(facts, graph, name, PUBLIC_BARREL, owners, rowsOf(settled, rows), text));
|
|
63
65
|
keys.set(name, key);
|
|
64
66
|
const obtained = await inputs.cache.obtain({ key, root: inputs.root, tokens: inputs.design.tokens }, async () => {
|
|
65
|
-
const traced = traceTokenReads(inputs.foundation);
|
|
66
|
-
return { outcome: await analyze(
|
|
67
|
-
});
|
|
67
|
+
const traced = traceTokenReads(inputs.foundation), design = traceDesignReads(traced.foundation, inputs.assets, inputs.root, whole);
|
|
68
|
+
return { outcome: await analyze(design.foundation, design.assets), tokens: traced.evidence(), design: design.evidence() };
|
|
69
|
+
}, { relocate: relocateOutcome, accept: (evidence) => evidence !== void 0 && designReadsMatch(evidence, inputs.foundation, inputs.assets, inputs.root, whole) });
|
|
68
70
|
switch (obtained.kind) {
|
|
69
71
|
case "reused":
|
|
70
72
|
reused.push(name);
|
|
71
|
-
if (verifying() && canonical(await analyze(inputs.foundation)) !== canonical(obtained.outcome))
|
|
73
|
+
if (verifying() && canonical(await analyze(inputs.foundation, inputs.assets)) !== canonical(obtained.outcome))
|
|
72
74
|
throw new OwnerReuseMismatch(name);
|
|
73
75
|
break;
|
|
74
76
|
case "analyzed":
|