synthesisui 0.16.81 → 0.16.82
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 +84 -9
- package/dist/doctor/transcribe.js +0 -17
- package/package.json +1 -1
package/dist/commands/import.js
CHANGED
|
@@ -2,7 +2,7 @@ import { mkdir, readdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import { basename, dirname, join, relative } from "node:path";
|
|
3
3
|
import { resolveAnatomy, resolveFlatParts, safePartName, } from "../anatomy-read.js";
|
|
4
4
|
import { readCredentials, readToken, resolveRegistry, sameRegistry, } from "../config.js";
|
|
5
|
-
import { describeArchitecture, describeChoice, detectArchitectures, } from "../doctor/architecture.js";
|
|
5
|
+
import { architectureRule, describeArchitecture, describeChoice, detectArchitectures, } from "../doctor/architecture.js";
|
|
6
6
|
import { findBrokenRefs } from "../doctor/broken-refs.js";
|
|
7
7
|
import { nestingRules, propRules, readDefinitionProps, readNesting, } from "../doctor/call-sites.js";
|
|
8
8
|
import { describeClassStyle, detectClassStyle, } from "../doctor/class-style.js";
|
|
@@ -16,6 +16,7 @@ import { diagnose, scanSource } from "../doctor/scan.js";
|
|
|
16
16
|
import { parseSchemeBlocks } from "../doctor/scheme-blocks.js";
|
|
17
17
|
import { buildTable } from "../doctor/tokens.js";
|
|
18
18
|
import { rootClasses, rootTag, transcribe, } from "../doctor/transcribe.js";
|
|
19
|
+
import { transcribeVariants } from "../doctor/variant-read.js";
|
|
19
20
|
import { body, paint, section } from "../output.js";
|
|
20
21
|
import { startProgress } from "../progress.js";
|
|
21
22
|
import { detectStack, resolveDeps } from "../stack.js";
|
|
@@ -242,6 +243,8 @@ export async function takeCensus(root, opts) {
|
|
|
242
243
|
const nesting = new Map();
|
|
243
244
|
/** Component → what its own definition names and whether it forwards the rest. */
|
|
244
245
|
const propsOf = new Map();
|
|
246
|
+
/** Component → the axes its own `cva` declares. See `variant-read.ts`. */
|
|
247
|
+
const variantAxes = new Map();
|
|
245
248
|
/**
|
|
246
249
|
* A census over a real monorepo reads 2797 files, and the terminal said nothing for
|
|
247
250
|
* most of it. Twenty silent minutes is indistinguishable from twenty broken ones
|
|
@@ -313,12 +316,45 @@ export async function takeCensus(root, opts) {
|
|
|
313
316
|
// not attempt.
|
|
314
317
|
if (found.length > 0) {
|
|
315
318
|
const t = transcribe(rootClasses(src), declaredValues);
|
|
316
|
-
|
|
319
|
+
/**
|
|
320
|
+
* THE VARIANT STYLES, FOLDED IN.
|
|
321
|
+
*
|
|
322
|
+
* `rootClasses` reads the class string ON the element, which for a component
|
|
323
|
+
* built with `cva` is a call - `className={cn(buttonVariants({ variant }))}` -
|
|
324
|
+
* and carries none of the nine variants' colours. The definition does, in an
|
|
325
|
+
* object literal, and reading it is deterministic (see `variant-read.ts`).
|
|
326
|
+
*
|
|
327
|
+
* Folded here rather than reported separately because this is the one funnel:
|
|
328
|
+
* the reader was computing 23 layers for a real Button and nobody was asking
|
|
329
|
+
* for the result, which is the "valid and unread" failure this pipeline has
|
|
330
|
+
* paid for twice already.
|
|
331
|
+
*/
|
|
332
|
+
const v = transcribeVariants(src, declaredValues);
|
|
333
|
+
const base = { ...v.base.base, ...t.base };
|
|
334
|
+
const states = { ...v.base.states, ...t.states };
|
|
335
|
+
const size = Object.keys(base).length +
|
|
317
336
|
Object.keys(t.dark).length +
|
|
318
|
-
Object.keys(
|
|
337
|
+
Object.keys(states).length +
|
|
338
|
+
v.layers.length;
|
|
319
339
|
const tag = rootTag(src);
|
|
320
340
|
if (size > 0 || tag) {
|
|
321
|
-
looks[found[0].name] =
|
|
341
|
+
looks[found[0].name] = {
|
|
342
|
+
...t,
|
|
343
|
+
base,
|
|
344
|
+
states,
|
|
345
|
+
...(tag ? { rootTag: tag } : {}),
|
|
346
|
+
...(v.layers.length > 0 ? { layers: v.layers } : {}),
|
|
347
|
+
...(Object.keys(v.axes).length > 0 ? { declaredAxes: v.axes } : {}),
|
|
348
|
+
...(Object.keys(v.defaults).length > 0
|
|
349
|
+
? { defaults: v.defaults }
|
|
350
|
+
: {}),
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
// Their variant DEFINITION beats what usage happened to pick, and it is the
|
|
354
|
+
// better source: usage shows what somebody chose, the declaration shows what
|
|
355
|
+
// the author designed.
|
|
356
|
+
if (Object.keys(v.axes).length > 0) {
|
|
357
|
+
variantAxes.set(found[0].name, v.axes);
|
|
322
358
|
}
|
|
323
359
|
}
|
|
324
360
|
}
|
|
@@ -408,12 +444,25 @@ export async function takeCensus(root, opts) {
|
|
|
408
444
|
files: 0,
|
|
409
445
|
props: {
|
|
410
446
|
...Object.fromEntries(Object.entries(d.axes)),
|
|
447
|
+
...Object.fromEntries(Object.entries(variantAxes.get(d.name) ?? {})),
|
|
411
448
|
...Object.fromEntries(d.flags.map((f) => [f, ["true"]])),
|
|
412
449
|
},
|
|
413
450
|
propFiles: {},
|
|
414
451
|
// Their own rung, off the folder. It travels from the DEFINITION because
|
|
415
452
|
// that is the only reading that knows which file the component lives in.
|
|
416
453
|
...(d.tier ? { tier: d.tier } : {}),
|
|
454
|
+
/**
|
|
455
|
+
* The axes, kept BESIDE `props` as well as in it.
|
|
456
|
+
*
|
|
457
|
+
* A library composes nothing, so its components arrive through this branch and
|
|
458
|
+
* `declaredAxes` is where the contract writer looks. Leaving it out meant a
|
|
459
|
+
* Button whose `cva` declares nine variants reported none of them (probe,
|
|
460
|
+
* 01/08) - the styles reached the recipe and the axis names did not.
|
|
461
|
+
*/
|
|
462
|
+
...(Object.keys({ ...d.axes, ...(variantAxes.get(d.name) ?? {}) })
|
|
463
|
+
.length > 0
|
|
464
|
+
? { declaredAxes: { ...d.axes, ...(variantAxes.get(d.name) ?? {}) } }
|
|
465
|
+
: {}),
|
|
417
466
|
}));
|
|
418
467
|
/**
|
|
419
468
|
* A composed component that is ALSO defined keeps its usage and gains the
|
|
@@ -435,13 +484,22 @@ export async function takeCensus(root, opts) {
|
|
|
435
484
|
const declaredBy = new Map(defined.map((d) => [d.name, d]));
|
|
436
485
|
const enriched = inventory.map((c) => {
|
|
437
486
|
const d = declaredBy.get(c.name);
|
|
438
|
-
|
|
487
|
+
const fromVariants = variantAxes.get(c.name);
|
|
488
|
+
if (!d && !fromVariants)
|
|
439
489
|
return c;
|
|
440
|
-
const tier = d
|
|
441
|
-
|
|
490
|
+
const tier = d?.tier ? { tier: d.tier } : {};
|
|
491
|
+
/**
|
|
492
|
+
* THREE SOURCES FOR AN AXIS, and this is their order.
|
|
493
|
+
*
|
|
494
|
+
* The `cva` definition is the strongest: it declares the option AND what the
|
|
495
|
+
* option does. The prop type is next - it declares the closed set. Usage is last,
|
|
496
|
+
* because it shows what somebody happened to pick.
|
|
497
|
+
*/
|
|
498
|
+
const axes = { ...(d?.axes ?? {}), ...(fromVariants ?? {}) };
|
|
499
|
+
if (Object.keys(axes).length === 0) {
|
|
442
500
|
return Object.keys(tier).length > 0 ? { ...c, ...tier } : c;
|
|
443
501
|
}
|
|
444
|
-
return { ...c, declaredAxes:
|
|
502
|
+
return { ...c, declaredAxes: axes, ...tier };
|
|
445
503
|
});
|
|
446
504
|
const scoped = [...enriched, ...fromTypes];
|
|
447
505
|
/**
|
|
@@ -625,8 +683,25 @@ export async function takeCensus(root, opts) {
|
|
|
625
683
|
observed: distinctValues(d),
|
|
626
684
|
...(components.length > 0 ? { components } : {}),
|
|
627
685
|
...(defined.length > 0 ? { defined } : {}),
|
|
686
|
+
/**
|
|
687
|
+
* THE SHAPE, AND THE RULE IT BECOMES.
|
|
688
|
+
*
|
|
689
|
+
* `rule` travels with each one so the platform writes it without owning a second
|
|
690
|
+
* copy of the sentence. The reader picks which architecture has PRIORITY; absent a
|
|
691
|
+
* choice the first is the one, which is the shape holding the most code.
|
|
692
|
+
*
|
|
693
|
+
* Carried rather than only printed: the whole point of the feature is that the
|
|
694
|
+
* chosen shape reaches CLAUDE.md, and a version of this that detected the shape,
|
|
695
|
+
* printed it, and never turned it into a rule is a feature that does nothing (dono,
|
|
696
|
+
* 01/08).
|
|
697
|
+
*/
|
|
628
698
|
...(architectures.length > 0
|
|
629
|
-
? {
|
|
699
|
+
? {
|
|
700
|
+
architectures: architectures.slice(0, 6).map((a) => ({
|
|
701
|
+
...a,
|
|
702
|
+
rule: architectureRule(a),
|
|
703
|
+
})),
|
|
704
|
+
}
|
|
630
705
|
: {}),
|
|
631
706
|
...(skips.length > 0
|
|
632
707
|
? {
|
|
@@ -598,20 +598,3 @@ export function rootClasses(source) {
|
|
|
598
598
|
.flatMap((m) => m[1].split(/\s+/))
|
|
599
599
|
.filter((c) => c.length > 0 && !c.includes("${"));
|
|
600
600
|
}
|
|
601
|
-
/**
|
|
602
|
-
* Transcribe the parts a skill named, using the same reader the root used.
|
|
603
|
-
*
|
|
604
|
-
* `declared` comes from the census itself on the `--census` path, so a run that
|
|
605
|
-
* only sends a file it was handed still resolves their tokens by name.
|
|
606
|
-
*/
|
|
607
|
-
export function transcribeParts(parts, declared) {
|
|
608
|
-
const out = {};
|
|
609
|
-
for (const part of parts) {
|
|
610
|
-
const name = part.name?.trim();
|
|
611
|
-
if (!name || typeof part.classes !== "string")
|
|
612
|
-
continue;
|
|
613
|
-
const t = transcribe(part.classes.split(/\s+/).filter(Boolean), declared);
|
|
614
|
-
out[name] = { base: t.base, dark: t.dark, states: t.states };
|
|
615
|
-
}
|
|
616
|
-
return out;
|
|
617
|
-
}
|
package/package.json
CHANGED