synthesisui 0.16.126 → 0.16.128
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/commands/import.js +32 -3
- package/dist/doctor/transcribe.js +37 -3
- package/package.json +1 -1
package/dist/commands/import.js
CHANGED
|
@@ -874,7 +874,23 @@ export async function takeCensus(root, opts) {
|
|
|
874
874
|
* because every declared option now looked used.
|
|
875
875
|
*/
|
|
876
876
|
const declaredBy = new Map(defined.map((d) => [d.name, d]));
|
|
877
|
-
const enriched = inventory.map((
|
|
877
|
+
const enriched = inventory.map((c0) => {
|
|
878
|
+
/**
|
|
879
|
+
* A NAME THIS SCOPE DECLARES IS THEIRS, whoever else imports the same identifier.
|
|
880
|
+
*
|
|
881
|
+
* The usage scan reads imports per FILE, so a name gets the package of the file that
|
|
882
|
+
* imported it. Their `Pill` does `import { Toggle } from "@base-ui/react/toggle"`, and
|
|
883
|
+
* that name collides with the `Toggle` atom they wrote one folder over: the entry came
|
|
884
|
+
* out carrying `from: "@base-ui/react/toggle"`, and `from` is what makes the crosswalk
|
|
885
|
+
* skip a component and `exclusiveContracts` drop it. Their Toggle - 12 declarations, 3
|
|
886
|
+
* parts, `size` and `checked` - was absent from the whole system (test50, dono, 04/08).
|
|
887
|
+
*
|
|
888
|
+
* `defined` is a DEFINITION: a function of theirs that returns JSX. A scope that merely
|
|
889
|
+
* re-exports a library component under the same name is not in it, so a real
|
|
890
|
+
* third-party keeps its package. This is law 14's ordering, one level up: what they
|
|
891
|
+
* declare breaks the tie before the crosswalk is asked.
|
|
892
|
+
*/
|
|
893
|
+
const c = declaredWins(c0, declaredBy.has(c0.name));
|
|
878
894
|
const d = declaredBy.get(c.name);
|
|
879
895
|
const fromVariants = variantAxes.get(c.name);
|
|
880
896
|
if (!d && !fromVariants)
|
|
@@ -1428,12 +1444,12 @@ function sayBrokenRefs(c) {
|
|
|
1428
1444
|
const uses = broken.reduce((n, b) => n + b.count, 0);
|
|
1429
1445
|
console.log("");
|
|
1430
1446
|
console.log(section("These resolve to nothing"));
|
|
1431
|
-
console.log(body(`${uses} reference${uses === 1 ? "" : "s"} to ${broken.length} token${broken.length === 1 ? "" : "s"} your CSS never declares. A ${paint.strong("var()")} with no declaration paints no colour - not a different colour.`));
|
|
1447
|
+
console.log(body(`${uses} reference${uses === 1 ? "" : "s"} to ${broken.length} token${broken.length === 1 ? "" : "s"} your CSS never declares. A ${paint.strong("var()")} with no declaration paints no colour - not a different colour. Where exactly one declared token differs by a namespace, the recipe now uses THAT one, so the look survives; the rest travel as the value you typed.`));
|
|
1432
1448
|
console.log("");
|
|
1433
1449
|
for (const b of broken.slice(0, 8)) {
|
|
1434
1450
|
const where = `${b.count}× in ${b.files} file${b.files === 1 ? "" : "s"}`;
|
|
1435
1451
|
console.log(body(b.meant
|
|
1436
|
-
? `${paint.strong(`var(${b.name})`)} ${paint.faint(where)} - you declare ${paint.strong(b.meant)}
|
|
1452
|
+
? `${paint.strong(`var(${b.name})`)} ${paint.faint(where)} - you declare ${paint.strong(b.meant)}, and that is what the recipe carries. Fix the class and the two agree.`
|
|
1437
1453
|
: `${paint.strong(`var(${b.name})`)} ${paint.faint(`${where}, and nothing close is declared`)}`));
|
|
1438
1454
|
}
|
|
1439
1455
|
if (broken.length > 8) {
|
|
@@ -1901,6 +1917,19 @@ function sayReach(c) {
|
|
|
1901
1917
|
* (a return the scanner did not follow) must say nothing rather than borrow the
|
|
1902
1918
|
* first node's package.
|
|
1903
1919
|
*/
|
|
1920
|
+
/**
|
|
1921
|
+
* A NAME THIS SCOPE DECLARES IS THEIRS - see the call site in `takeCensus` for what it cost.
|
|
1922
|
+
*
|
|
1923
|
+
* Kept as a function so the rule has a name and a test: the usage scan is per FILE, so an
|
|
1924
|
+
* identifier takes the package of whoever imported it, and one of their own components can
|
|
1925
|
+
* shadow one of their own names. `declared` is a DEFINITION of theirs, which is what makes
|
|
1926
|
+
* this a tie-break rather than a preference.
|
|
1927
|
+
*/
|
|
1928
|
+
export function declaredWins(component, declared) {
|
|
1929
|
+
return component.from && declared
|
|
1930
|
+
? { ...component, from: undefined }
|
|
1931
|
+
: component;
|
|
1932
|
+
}
|
|
1904
1933
|
function rootPackage(tag, sketch) {
|
|
1905
1934
|
if (!tag || !/^[A-Z]/.test(tag))
|
|
1906
1935
|
return {};
|
|
@@ -1179,10 +1179,44 @@ function resolveArbitrary(inner, declared) {
|
|
|
1179
1179
|
return /[<>{}@;]/.test(raw) ? null : { value: raw };
|
|
1180
1180
|
}
|
|
1181
1181
|
const name = v[1];
|
|
1182
|
-
if (
|
|
1183
|
-
return { value:
|
|
1184
|
-
|
|
1182
|
+
if (declared.has(name))
|
|
1183
|
+
return { value: tokenRefFor(name), token: name };
|
|
1184
|
+
/**
|
|
1185
|
+
* A `var()` THEY NEVER DECLARED, WHEN THEY DECLARED IT UNDER ITS NAMESPACE.
|
|
1186
|
+
*
|
|
1187
|
+
* `bg-[var(--ocean-200)]` where the theme declares `--color-ocean-200` is their own
|
|
1188
|
+
* defect - Tailwind v4 namespaces the property and they wrote the bare name - and it is
|
|
1189
|
+
* ALSO unambiguous: exactly one declared token differs from it by a namespace. The census
|
|
1190
|
+
* already computes that answer for the report (`brokenRefs.meant`); carrying the broken
|
|
1191
|
+
* name into the recipe instead meant the declaration reached the document and painted
|
|
1192
|
+
* nothing, because `var(--ocean-200)` exists in their stylesheet and in none of ours.
|
|
1193
|
+
*
|
|
1194
|
+
* Measured on his library (test50, dono, 04/08): 6 declarations across 5 components, all
|
|
1195
|
+
* colours, all dead - and invisible to the ref validator, which only ever looks for `{…}`.
|
|
1196
|
+
*
|
|
1197
|
+
* A name that matches NO namespace stays the literal it was: that one is broken in their
|
|
1198
|
+
* repo too, and inventing a target would be the guess. It travels as the value they typed
|
|
1199
|
+
* and is reported by `brokenRefs`.
|
|
1200
|
+
*/
|
|
1201
|
+
const meant = MEANT_NAMESPACES.map((ns) => `--${ns}-${name.slice(2)}`).find((candidate) => declared.has(candidate));
|
|
1202
|
+
if (meant)
|
|
1203
|
+
return { value: tokenRefFor(meant), token: meant };
|
|
1204
|
+
return { value: raw };
|
|
1185
1205
|
}
|
|
1206
|
+
/**
|
|
1207
|
+
* The namespaces a bare name could have been written under, in the order Tailwind v4 uses
|
|
1208
|
+
* them. Mirrors `NAMESPACES` in `broken-refs.ts`, which computes the same answer for the
|
|
1209
|
+
* report - two readers of one fact, and the fact is "exactly one declared token differs
|
|
1210
|
+
* from this by a prefix".
|
|
1211
|
+
*/
|
|
1212
|
+
const MEANT_NAMESPACES = [
|
|
1213
|
+
"color",
|
|
1214
|
+
"spacing",
|
|
1215
|
+
"radius",
|
|
1216
|
+
"shadow",
|
|
1217
|
+
"font",
|
|
1218
|
+
"text",
|
|
1219
|
+
];
|
|
1186
1220
|
/**
|
|
1187
1221
|
* A declared custom property, as a token ref in the document's own namespace.
|
|
1188
1222
|
*
|
package/package.json
CHANGED