synthesisui 0.16.387 → 0.16.389

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.
@@ -551,7 +551,7 @@ export async function add(slug, opts) {
551
551
  * A linha diz quantos utilitários do Tailwind ficaram apontando para a decisão dele e quantos
552
552
  * saíram por serem nossos, com os primeiros nomes. Quem lê pode discordar de qualquer um.
553
553
  */
554
- if (aligned.dropped.length > 0) {
554
+ if (aligned.dropped.length > 0 || aligned.own.length > 0) {
555
555
  console.log(line(
556
556
  /**
557
557
  * A LINHA DIZ QUE FICARAM DE FORA - e nao AFIRMA por que, porque ela nao sabe.
@@ -570,7 +570,7 @@ export async function add(slug, opts) {
570
570
  * Entao a linha diz o FATO que ela tem - a classe dele continua significando o que
571
571
  * significa - e nomeia os primeiros, para quem quiser discordar de qualquer um.
572
572
  */
573
- ` ${aligned.kept} Tailwind utilit${aligned.kept === 1 ? "y" : "ies"} now point at your own decisions; ${aligned.dropped.length} were left as ${aligned.dropped.length === 1 ? "it is" : "they are"} (${aligned.dropped.slice(0, 3).join(", ")}${aligned.dropped.length > 3 ? ", …" : ""}) - your classes keep meaning what they mean today.`));
573
+ ` ${aligned.kept} Tailwind utilit${aligned.kept === 1 ? "y" : "ies"} now point at your own decisions${aligned.own.length > 0 ? `; ${aligned.own.length} more name${aligned.own.length === 1 ? "s a utility" : " utilities"} only this system has (${aligned.own.slice(0, 3).join(", ")}${aligned.own.length > 3 ? ", …" : ""}), so they are declared here` : ""}${aligned.dropped.length > 0 ? `; ${aligned.dropped.length} were left as ${aligned.dropped.length === 1 ? "it is" : "they are"} (${aligned.dropped.slice(0, 3).join(", ")}${aligned.dropped.length > 3 ? ", …" : ""}) - your classes keep meaning what they mean today` : ""}.`));
574
574
  }
575
575
  /**
576
576
  * O CICLO RECUSADO É DITO, e não engolido - senão o cliente lê um número menor sem saber por quê.
@@ -6,7 +6,7 @@ import { generateComponentFiles } from "../component-codegen.js";
6
6
  import { readProjectConfig, resolveRegistry } from "../config.js";
7
7
  import { hasInteractiveTemplate, interactiveTemplate, } from "../interactive-templates.js";
8
8
  import { body, section, snippet } from "../output.js";
9
- import { findCollision, reactMajorOf, readInstalledConvention, readInstalledScheme, } from "../project-facts.js";
9
+ import { findCollision, installedThemeVars, reactMajorOf, readInstalledConvention, readInstalledScheme, } from "../project-facts.js";
10
10
  import { fetchComponent, RegistryError } from "../registry.js";
11
11
  import { flavourResolver } from "../styles-flavour.js";
12
12
  import { inTheirTongue, projectTongue, sumSpoken, } from "../their-tongue.js";
@@ -149,11 +149,6 @@ export async function component(slug, name, opts) {
149
149
  * Re-materializing something WE generated is almost always what they meant, so
150
150
  * that keeps going. Shadowing a component of theirs stops and asks.
151
151
  */
152
- const pascalName = res.name
153
- .split(/[^a-zA-Z0-9]+/)
154
- .filter(Boolean)
155
- .map((p) => p[0].toUpperCase() + p.slice(1))
156
- .join("");
157
152
  /**
158
153
  * THEY ALREADY HAVE THIS COMPONENT, and the recipe says where.
159
154
  *
@@ -316,7 +311,7 @@ export async function component(slug, name, opts) {
316
311
  * O ARQUIVO e o EXPORT levam o nome dele; a CLASSE continua sendo a do blueprint. Um
317
312
  * `<CardPreview>` vestindo `.ds-card` está estilizado certo e não faz sombra em nada dele.
318
313
  */
319
- local, await readInstalledScheme(root, slug), tongue);
314
+ local, await readInstalledScheme(root, slug), tongue, await installedThemeVars(root, slug));
320
315
  spoken = said;
321
316
  /**
322
317
  * AS DECLARAÇÕES DO ARQUIVO DELE QUE O INTERPRETADOR NÃO LEU - ver `unread-for-component.ts`.
@@ -3,7 +3,7 @@ import { join } from "node:path";
3
3
  import { generateComponentFiles } from "../component-codegen.js";
4
4
  import { readProjectConfig, resolveRegistry } from "../config.js";
5
5
  import { installedSlugs } from "../installed.js";
6
- import { reactMajorOf, readInstalledConvention, readInstalledScheme, } from "../project-facts.js";
6
+ import { installedThemeVars, reactMajorOf, readInstalledConvention, readInstalledScheme, } from "../project-facts.js";
7
7
  import { postGenerate, RegistryError } from "../registry.js";
8
8
  import { flavourResolver } from "../styles-flavour.js";
9
9
  import { projectTongue } from "../their-tongue.js";
@@ -75,7 +75,7 @@ export async function generate(description, opts) {
75
75
  // project as the stylesheet it has to match.
76
76
  await readInstalledConvention(root, slug), res.name, await readInstalledScheme(root, slug),
77
77
  /** O VOCABULÁRIO DELE - um componente gerado cai no mesmo projeto e fala a mesma língua. */
78
- await projectTongue(root, slug));
78
+ await projectTongue(root, slug), await installedThemeVars(root, slug));
79
79
  for (const file of files) {
80
80
  await writeFile(join(compDir, file.filename), file.code, "utf8");
81
81
  }
@@ -4,7 +4,7 @@ import { generateComponentFiles } from "../component-codegen.js";
4
4
  import { readProjectConfig, resolveRegistry } from "../config.js";
5
5
  import { installedSlugs } from "../installed.js";
6
6
  import { body, section, snippet } from "../output.js";
7
- import { reactMajorOf, readInstalledConvention, readInstalledScheme, } from "../project-facts.js";
7
+ import { installedThemeVars, reactMajorOf, readInstalledConvention, readInstalledScheme, } from "../project-facts.js";
8
8
  import { fetchComponent, postRefit, postSaveComponent, RegistryError, } from "../registry.js";
9
9
  import { flavourResolver } from "../styles-flavour.js";
10
10
  import { projectTongue } from "../their-tongue.js";
@@ -121,7 +121,7 @@ export async function refit(file, opts) {
121
121
  const flavourOf = await flavourResolver(root, config.styles);
122
122
  const { files } = generateComponentFiles(slug, res.name, res.recipe, res.css, saved.version, flavourOf(res.name), await reactMajorOf(root), await readInstalledConvention(root, slug), res.name, await readInstalledScheme(root, slug),
123
123
  /** O VOCABULÁRIO DELE - o `refit` reescreve o componente e não passava pela porta. */
124
- await projectTongue(root, slug));
124
+ await projectTongue(root, slug), await installedThemeVars(root, slug));
125
125
  for (const f of files) {
126
126
  await writeFile(join(compDir, f.filename), f.code, "utf8");
127
127
  }
@@ -8,7 +8,7 @@ import { unsentEvents } from "../doctor/ledger.js";
8
8
  import { diffLocalDocuments, localChangelogMarkdown, } from "../document-diff.js";
9
9
  import { installedBehind, MATERIALISER_SINCE } from "../install-marks.js";
10
10
  import { body, section, snippet } from "../output.js";
11
- import { reactMajorOf, readInstalledConvention, readInstalledScheme, } from "../project-facts.js";
11
+ import { installedThemeVars, reactMajorOf, readInstalledConvention, readInstalledScheme, } from "../project-facts.js";
12
12
  import { fetchChangelog, fetchComponent, fetchDesignSystem, RegistryError, } from "../registry.js";
13
13
  import { flavourResolver } from "../styles-flavour.js";
14
14
  import { projectTongue } from "../their-tongue.js";
@@ -331,6 +331,8 @@ export async function upgrade(asked, opts) {
331
331
  * língua do repositório. Resolvido uma vez para a corrida inteira, como o sabor.
332
332
  */
333
333
  const tongue = await projectTongue(root, slug);
334
+ /** A folha instalada é a MESMA para a corrida inteira - ver `installedThemeVars`. */
335
+ const themeVars = await installedThemeVars(root, slug);
334
336
  for (const entry of entries) {
335
337
  const tsxPath = join(componentsRoot, entry, `${entry}.tsx`);
336
338
  let head = "";
@@ -359,7 +361,7 @@ export async function upgrade(asked, opts) {
359
361
  // Both were missing here, and `upgrade` is the command that REWRITES
360
362
  // components somebody already has: without the convention it would have
361
363
  // taken a working component and stripped its styles.
362
- await reactMajorOf(root), res.classNames ?? (await readInstalledConvention(root, slug)), res.name, await readInstalledScheme(root, slug), tongue);
364
+ await reactMajorOf(root), res.classNames ?? (await readInstalledConvention(root, slug)), res.name, await readInstalledScheme(root, slug), tongue, themeVars);
363
365
  /**
364
366
  * A NOTA DAS DECLARAÇÕES NÃO INTERPRETADAS SOBREVIVE AO UPGRADE.
365
367
  *
@@ -485,9 +485,31 @@ function remToTwScale(value) {
485
485
  const n = Number.parseFloat(m[1]) / 0.25;
486
486
  return Number.isInteger(n) && n >= 0 && n <= 96 ? String(n) : null;
487
487
  }
488
+ /**
489
+ * O UTILITÁRIO NOMEADO SÓ VALE QUANDO A FOLHA INSTALADA O DECLARA - e é isso que decide o VALOR.
490
+ *
491
+ * `rounded-lg` existe em qualquer projeto com Tailwind, então a classe nunca "falta". O que muda é
492
+ * de quem é o valor: quando o `theme.css` que caiu na pasta dele declara `--radius-lg`, a classe
493
+ * pinta o raio DO SISTEMA; quando não declara, ela pinta o default do Tailwind - e o componente
494
+ * mente em silêncio, que é pior que uma classe morta, porque nada na tela parece faltar.
495
+ *
496
+ * A folha não declara por dois motivos, os dois legítimos: a redefinição roubaria uma classe que o
497
+ * app dele já usa (`INV-VOLTA-13`, o alinhamento), ou o compilador não faz ponte para um nome que
498
+ * não está em `meta.ownedNames` (o `--font-body` do codelevel). Nos dois casos a resposta certa é a
499
+ * mesma: emitir o valor arbitrário com `var(--ds-*)`, que resolve sempre dentro de `[data-ds]`.
500
+ *
501
+ * MEDIDO em 07/09 sobre TODOS os componentes das duas populações:
502
+ *
503
+ * codelevel, repo real 58 de 110 utilitários de token (53%) não carregavam o valor dele
504
+ * ember, app novo 34 de 241 (14%)
505
+ *
506
+ * `null` é projeto sem folha instalada - `refit` e `generate` já dizem que nada pinta sem o `add`,
507
+ * e ali o nome legível não custa nada.
508
+ */
509
+ const minted = (themeVars, cssVar) => themeVars === null || themeVars.has(cssVar);
488
510
  /** One declaration → Tailwind classes (pretty when mappable, arbitrary-property
489
511
  * otherwise - never dropped). */
490
- function declToTailwind(prop, value) {
512
+ function declToTailwind(prop, value, themeVars) {
491
513
  const stat = STATIC[prop]?.[value];
492
514
  if (stat)
493
515
  return [stat];
@@ -496,19 +518,19 @@ function declToTailwind(prop, value) {
496
518
  if (value === "transparent")
497
519
  return ["bg-transparent"];
498
520
  const key = colorKey(value);
499
- if (key)
521
+ if (key && minted(themeVars, `--color-${key}`))
500
522
  return [`bg-${key}`];
501
523
  break;
502
524
  }
503
525
  case "color": {
504
526
  const key = colorKey(value);
505
- if (key)
527
+ if (key && minted(themeVars, `--color-${key}`))
506
528
  return [`text-${key}`];
507
529
  break;
508
530
  }
509
531
  case "borderColor": {
510
532
  const key = colorKey(value);
511
- if (key)
533
+ if (key && minted(themeVars, `--color-${key}`))
512
534
  return [`border-${key}`];
513
535
  break;
514
536
  }
@@ -517,25 +539,28 @@ function declToTailwind(prop, value) {
517
539
  const m = value.match(/^1px\s+solid\s+(\{[^}]+\})$/);
518
540
  if (m) {
519
541
  const key = colorKey(m[1]);
520
- if (key)
542
+ if (key && minted(themeVars, `--color-${key}`))
521
543
  return ["border", `border-${key}`];
522
544
  }
523
545
  break;
524
546
  }
525
547
  case "borderRadius": {
526
548
  const key = nsKey(value, "radius");
527
- if (key)
549
+ if (key && minted(themeVars, `--radius-${key}`))
528
550
  return [`rounded-${key}`];
529
551
  break;
530
552
  }
531
553
  case "gap": {
532
554
  const key = nsKey(value, "spacing");
533
- if (key)
555
+ if (key && minted(themeVars, `--spacing-${key}`))
534
556
  return [`gap-${key}`];
535
557
  break;
536
558
  }
537
559
  case "padding": {
538
- const keys = value.split(/\s+/).map((v) => nsKey(v, "spacing"));
560
+ const keys = value
561
+ .split(/\s+/)
562
+ .map((v) => nsKey(v, "spacing"))
563
+ .map((k) => (k && minted(themeVars, `--spacing-${k}`) ? k : null));
539
564
  if (keys.length === 1 && keys[0])
540
565
  return [`p-${keys[0]}`];
541
566
  if (keys.length === 2 && keys[0] && keys[1])
@@ -544,25 +569,25 @@ function declToTailwind(prop, value) {
544
569
  }
545
570
  case "fontSize": {
546
571
  const key = scaleKey(value);
547
- if (key)
572
+ if (key && minted(themeVars, `--text-${key}`))
548
573
  return [`text-${key}`];
549
574
  break;
550
575
  }
551
576
  case "fontFamily": {
552
577
  const key = nsKey(value, "typography.families");
553
- if (key)
578
+ if (key && minted(themeVars, `--font-${key}`))
554
579
  return [`font-${key}`];
555
580
  break;
556
581
  }
557
582
  case "fontWeight": {
558
583
  const key = nsKey(value, "typography.weights");
559
- if (key)
584
+ if (key && minted(themeVars, `--font-weight-${key}`))
560
585
  return [`font-${key}`];
561
586
  break;
562
587
  }
563
588
  case "boxShadow": {
564
589
  const key = nsKey(value, "shadow");
565
- if (key)
590
+ if (key && minted(themeVars, `--shadow-${key}`))
566
591
  return [`shadow-${key}`];
567
592
  break;
568
593
  }
@@ -648,8 +673,8 @@ function twStateVariants(state) {
648
673
  const native = TW_NATIVE.has(word) ? [`${word}:`] : [`data-[${word}]:`];
649
674
  return [...native, ...(TW_ALSO[state] ?? [])];
650
675
  }
651
- function blockToTailwind(block, prefix = "") {
652
- return Object.entries(block).flatMap(([prop, value]) => declToTailwind(prop, value).map((cls) => `${prefix}${cls}`));
676
+ function blockToTailwind(block, themeVars, prefix = "") {
677
+ return Object.entries(block).flatMap(([prop, value]) => declToTailwind(prop, value, themeVars).map((cls) => `${prefix}${cls}`));
653
678
  }
654
679
  /** Every prefix combination one layer needs. A condition that cannot be
655
680
  * expressed returns no combination, and the layer is dropped rather than
@@ -773,23 +798,25 @@ function resolveNode(node, scheme, asRoot) {
773
798
  return { variants, states, conditional };
774
799
  }
775
800
  /** The classes every compound condition contributes, in layer order. */
776
- const conditionalClasses = (resolved) => resolved.conditional.flatMap((c) => blockToTailwind(c.style, c.prefix));
801
+ const conditionalClasses = (resolved, themeVars) => resolved.conditional.flatMap((c) => blockToTailwind(c.style, themeVars, c.prefix));
777
802
  function tailwindClassList(recipe,
778
803
  /** The node's states and compound conditions, already read off its layers. */
779
804
  resolved,
805
+ /** O que a folha instalada declara - ver `minted`. */
806
+ themeVars,
780
807
  /** CSS properties a variant axis owns - see `variantOwnedProps`. */
781
808
  exclude) {
782
809
  const base = exclude
783
810
  ? Object.fromEntries(Object.entries(recipe.base).filter(([prop]) => !exclude.has(prop)))
784
811
  : recipe.base;
785
812
  const classes = [
786
- ...blockToTailwind(base),
813
+ ...blockToTailwind(base, themeVars),
787
814
  // States keep everything: `hover:` and `disabled:` cannot collide with an
788
815
  // unprefixed variant class, so there is nothing to resolve.
789
- ...Object.entries(resolved.states).flatMap(([state, block]) => twStateVariants(state).flatMap((prefix) => blockToTailwind(block, prefix))),
816
+ ...Object.entries(resolved.states).flatMap(([state, block]) => twStateVariants(state).flatMap((prefix) => blockToTailwind(block, themeVars, prefix))),
790
817
  // Compound conditions last: they are the most specific thing the recipe says,
791
818
  // and in utilities the later class is the one a reader expects to win.
792
- ...conditionalClasses(resolved),
819
+ ...conditionalClasses(resolved, themeVars),
793
820
  ];
794
821
  return classes.join(" ");
795
822
  }
@@ -1160,7 +1187,14 @@ function emitTailwindMode(slug, name, recipe, version, props,
1160
1187
  /** The name it takes in THEIR project. The utilities stay the system's. */
1161
1188
  localName = name,
1162
1189
  /** The scheme the document opens in - see `generateComponentFiles`. */
1163
- scheme = "dark") {
1190
+ scheme = "dark",
1191
+ /**
1192
+ * O QUE A FOLHA INSTALADA DECLARA - ver `minted`, e é o que decide de quem é o VALOR.
1193
+ *
1194
+ * `null` mantém o comportamento de sempre: um projeto sem `add` não tem folha nenhuma, e ali o
1195
+ * nome legível não custa nada porque nada pinta de qualquer forma.
1196
+ */
1197
+ themeVars = null) {
1164
1198
  const { tag, attrs, voidEl } = elementFor(name, recipe);
1165
1199
  const el = asElement(tag, attrs, voidEl);
1166
1200
  const axes = rootAxes(recipe);
@@ -1170,13 +1204,13 @@ scheme = "dark") {
1170
1204
  .filter((a) => !a.boolean)
1171
1205
  .map((a) => {
1172
1206
  const entries = a.options
1173
- .map((o) => ` ${JSON.stringify(o)}: ${JSON.stringify(blockToTailwind(resolved.variants[a.key]?.[o] ?? {}).join(" "))},`)
1207
+ .map((o) => ` ${JSON.stringify(o)}: ${JSON.stringify(blockToTailwind(resolved.variants[a.key]?.[o] ?? {}, themeVars).join(" "))},`)
1174
1208
  .join("\n");
1175
1209
  return `const ${a.prop.toUpperCase()}: Record<string, string> = {\n${entries}\n};`;
1176
1210
  });
1177
1211
  const booleanConsts = axes
1178
1212
  .filter((a) => a.boolean)
1179
- .map((a) => `const ${a.prop.toUpperCase()} = ${JSON.stringify(blockToTailwind(resolved.variants[a.key]?.true ?? {}).join(" "))};`);
1213
+ .map((a) => `const ${a.prop.toUpperCase()} = ${JSON.stringify(blockToTailwind(resolved.variants[a.key]?.true ?? {}, themeVars).join(" "))};`);
1180
1214
  // Every property some axis controls leaves BASE, and the base value becomes
1181
1215
  // that axis's default - so exactly one class ever sets it and the prop
1182
1216
  // actually wins.
@@ -1206,7 +1240,7 @@ scheme = "dark") {
1206
1240
  const fromDefault = preset
1207
1241
  ? (resolved.variants[a.key]?.[preset] ?? {})
1208
1242
  : {};
1209
- return JSON.stringify(blockToTailwind({ ...fromBase, ...fromDefault }).join(" "));
1243
+ return JSON.stringify(blockToTailwind({ ...fromBase, ...fromDefault }, themeVars).join(" "));
1210
1244
  };
1211
1245
  const clsParts = [
1212
1246
  "BASE",
@@ -1251,7 +1285,7 @@ ${dataAttrLines(axes)}${axes.length ? "\n" : ""} `;
1251
1285
  import type { ${needsElementType ? `ElementType, ${props}` : props} } from "react";
1252
1286
  import { cn } from "../cn";
1253
1287
 
1254
- const BASE = ${JSON.stringify([needsGroup ? "group" : "", tailwindClassList(recipe, resolved, excluded)].filter(Boolean).join(" "))};
1288
+ const BASE = ${JSON.stringify([needsGroup ? "group" : "", tailwindClassList(recipe, resolved, themeVars, excluded)].filter(Boolean).join(" "))};
1255
1289
  ${[...variantConsts, ...booleanConsts].join("\n")}
1256
1290
 
1257
1291
  type ${comp}Props = ${propsType(axes, tag, props, el.offersAs)};
@@ -1302,9 +1336,9 @@ ${orderedParts
1302
1336
  * status colours of his card were still nowhere.
1303
1337
  */
1304
1338
  const partResolved = resolveNode(part, scheme, false);
1305
- const partVariantClasses = partAxes.flatMap((a) => a.options.flatMap((o) => blockToTailwind(partResolved.variants[a.key]?.[o] ?? {}, `data-[${a.attr}=${o}]:`)));
1339
+ const partVariantClasses = partAxes.flatMap((a) => a.options.flatMap((o) => blockToTailwind(partResolved.variants[a.key]?.[o] ?? {}, themeVars, `data-[${a.attr}=${o}]:`)));
1306
1340
  const partCls = [
1307
- tailwindClassList(part, partResolved),
1341
+ tailwindClassList(part, partResolved, themeVars),
1308
1342
  ...partVariantClasses,
1309
1343
  ]
1310
1344
  .filter(Boolean)
@@ -1398,7 +1432,16 @@ scheme,
1398
1432
  * Aqui a tradução acontece uma vez, sobre os bytes que vão a disco, e `tsc` recusa a meia-chamada
1399
1433
  * de um materializador novo - o mesmo argumento do `scheme` logo acima.
1400
1434
  */
1401
- tongue) {
1435
+ tongue,
1436
+ /**
1437
+ * O QUE A FOLHA INSTALADA DECLARA NO `@theme` - `installedThemeVars(root, slug)`.
1438
+ *
1439
+ * OBRIGATÓRIO, pelo mesmo argumento do `scheme` e do `tongue`: o utilitário nomeado que este
1440
+ * módulo escreve só carrega o valor DO SISTEMA quando a folha que caiu na pasta dele declara a
1441
+ * variável. Sem essa resposta o codegen escreve `rounded-lg` e a classe pinta o default do
1442
+ * Tailwind - o componente mente sem nada faltar na tela. `null` é projeto sem folha instalada.
1443
+ */
1444
+ themeVars) {
1402
1445
  const files = [];
1403
1446
  const props = propsTypeName(reactMajor);
1404
1447
  if (styles === "css") {
@@ -1411,7 +1454,7 @@ tongue) {
1411
1454
  else {
1412
1455
  files.push({
1413
1456
  filename: `${localName}.tsx`,
1414
- code: `${emitTailwindMode(slug, name, recipe, version, props, localName, scheme)}\n`,
1457
+ code: `${emitTailwindMode(slug, name, recipe, version, props, localName, scheme, themeVars)}\n`,
1415
1458
  });
1416
1459
  }
1417
1460
  files.push({
@@ -170,7 +170,7 @@
170
170
  * O que o cliente ganha ao rodar `upgrade`: o agente dele no Codex passa a poder PERGUNTAR ao
171
171
  * sistema, em vez de só receber as regras e adivinhar o resto.
172
172
  */
173
- export const MATERIALISER_SINCE = "0.16.387";
173
+ export const MATERIALISER_SINCE = "0.16.389";
174
174
  /**
175
175
  * A ÚLTIMA VERSÃO EM QUE O QUE O HOOK RODA MUDOU.
176
176
  *
@@ -171,3 +171,43 @@ export async function readInstalledScheme(root, slug) {
171
171
  return "dark";
172
172
  }
173
173
  }
174
+ /**
175
+ * O QUE A FOLHA INSTALADA DECLARA NO `@theme` - a resposta que decide de quem é o VALOR.
176
+ *
177
+ * O QUE O CLIENTE PERCEBE SEM ISTO: o componente sai vestindo `rounded-lg` e `font-mono`, a classe
178
+ * existe em qualquer projeto com Tailwind, e ela pinta o **default do Tailwind** em vez do raio e da
179
+ * fonte do sistema dele. Nada falta na tela - é a mesma peça com os números de outra biblioteca, o
180
+ * que é mais difícil de achar que uma classe morta.
181
+ *
182
+ * A folha deixa de declarar por dois motivos legítimos: o alinhamento tirou a linha para não roubar
183
+ * uma classe que o app dele já usa (`INV-VOLTA-13`), ou o compilador não faz ponte para um nome que
184
+ * não está em `meta.ownedNames`. Os dois se leem no mesmo lugar - o arquivo que caiu na pasta dele -
185
+ * e é por isso que a pergunta é respondida AQUI e não no servidor: só nesta máquina existe a folha
186
+ * que ele realmente tem.
187
+ *
188
+ * MEDIDO em 07/09 sobre todos os componentes: 58 de 110 utilitários de token no `codelevel` (53%) e
189
+ * 34 de 241 no `ember` (14%) não carregavam o valor do sistema.
190
+ *
191
+ * `null` quando não há folha - projeto sem `add`, ou install antigo. Nesse caso nada pinta de
192
+ * qualquer forma, e o `refit`/`generate` já dizem isso.
193
+ */
194
+ export async function installedThemeVars(root, slug) {
195
+ const dir = join(root, "_synthesisui", "ds", slug);
196
+ const version = await pinnedVersion(dir);
197
+ if (!version)
198
+ return null;
199
+ const css = await readFile(join(dir, `v${version}`, "theme.css"), "utf8").catch(() => "");
200
+ if (!css)
201
+ return null;
202
+ /**
203
+ * Só o que está DENTRO de um `@theme` conta - é a única coisa que o Tailwind v4 lê para gerar
204
+ * utilitário. Uma variável no `[data-ds]` do `tokens.css` não gera nada, e foi tratar as duas como
205
+ * iguais que fez o `theme.css` parecer suficiente quando não era.
206
+ */
207
+ const blocks = css.matchAll(/@theme[^{]*\{([\s\S]*?)\n\}/g);
208
+ const declared = new Set();
209
+ for (const block of blocks)
210
+ for (const m of block[1].matchAll(/^\s*(--[a-zA-Z0-9-]+)\s*:/gm))
211
+ declared.add(m[1]);
212
+ return declared;
213
+ }
@@ -0,0 +1,453 @@
1
+ /**
2
+ * O QUE O TAILWIND JÁ DECLARA - e por isso NÃO é uma referência pendurada.
3
+ *
4
+ * O QUE O CLIENTE PERCEBE SEM ISTO. A folha que ele instala o avisava sobre uma variável que
5
+ * funciona: *"--font-sans has no name in this system"*. Ela tem - o `@import "tailwindcss"` do
6
+ * projeto dele a declara, e a regra pinta certo. Um aviso falso no arquivo dele custa mais que
7
+ * aviso nenhum, e a tela de admin cobrava, pelo mesmo motivo, um trabalho que não existe.
8
+ *
9
+ * MEDIDO em 01/09 nos 26 sistemas de produção: 3 variáveis acusadas de penduradas, todas num
10
+ * sistema só - o `codelevel`, que é o único importado de um repositório real. Das três, DUAS
11
+ * (`--font-sans`, `--animate-spin`) são declaradas aqui. A terceira, `--tracking-tightest`, não é -
12
+ * e essa continua sendo apontada, porque ela é genuína: a escala do Tailwind vai até
13
+ * `--tracking-tighter`, e o degrau a mais é uma decisão da escala DELE.
14
+ *
15
+ * ─────────────────────────────────────────────────────────────────────────
16
+ * ESTA LISTA É DERIVADA DO PACOTE, NUNCA ESCRITA À MÃO - `tailwind-theme-vars.spec.ts` a compara
17
+ * com o `@theme` de `node_modules/tailwindcss/theme.css` e reprova quando as duas divergem. Uma
18
+ * lista curada envelheceria em silêncio na primeira versão nova do Tailwind, e o sintoma seria o
19
+ * defeito que ela existe para evitar: um aviso falso na folha do cliente.
20
+ *
21
+ * PROCEDÊNCIA: extraída de `tailwindcss@4.2.1`, 419 nomes. A versão fica em comentário e não em
22
+ * constante de propósito - o que importa é a lista BATER com o pacote instalado, e é isso que o
23
+ * spec compara. Uma constante de versão que só o teste lê é um símbolo que o produto não chama.
24
+ *
25
+ * POR QUE UMA LISTA E NÃO UM PREFIXO: `--tracking-tighter` e `--tracking-tightest` compartilham o
26
+ * prefixo e têm respostas OPOSTAS. É exatamente a distinção que decide, então o nome é o dado.
27
+ *
28
+ * O PRESSUPOSTO, dito em voz alta: o projeto de destino importa o Tailwind. Ele já é o pressuposto
29
+ * de todo o compilador - `CASCADE_LAYERS` são as quatro camadas que `@import "tailwindcss"`
30
+ * declara, e o `theme.css`/`shadcn.css` do payload existem para essa stack.
31
+ */
32
+ /** Toda custom property que o `@theme` padrão do Tailwind declara, incluindo o bloco deprecated. */
33
+ export const TAILWIND_THEME_VARS = new Set([
34
+ "--animate-bounce",
35
+ "--animate-ping",
36
+ "--animate-pulse",
37
+ "--animate-spin",
38
+ "--aspect-video",
39
+ "--blur",
40
+ "--blur-2xl",
41
+ "--blur-3xl",
42
+ "--blur-lg",
43
+ "--blur-md",
44
+ "--blur-sm",
45
+ "--blur-xl",
46
+ "--blur-xs",
47
+ "--breakpoint-2xl",
48
+ "--breakpoint-lg",
49
+ "--breakpoint-md",
50
+ "--breakpoint-sm",
51
+ "--breakpoint-xl",
52
+ "--color-amber-100",
53
+ "--color-amber-200",
54
+ "--color-amber-300",
55
+ "--color-amber-400",
56
+ "--color-amber-50",
57
+ "--color-amber-500",
58
+ "--color-amber-600",
59
+ "--color-amber-700",
60
+ "--color-amber-800",
61
+ "--color-amber-900",
62
+ "--color-amber-950",
63
+ "--color-black",
64
+ "--color-blue-100",
65
+ "--color-blue-200",
66
+ "--color-blue-300",
67
+ "--color-blue-400",
68
+ "--color-blue-50",
69
+ "--color-blue-500",
70
+ "--color-blue-600",
71
+ "--color-blue-700",
72
+ "--color-blue-800",
73
+ "--color-blue-900",
74
+ "--color-blue-950",
75
+ "--color-cyan-100",
76
+ "--color-cyan-200",
77
+ "--color-cyan-300",
78
+ "--color-cyan-400",
79
+ "--color-cyan-50",
80
+ "--color-cyan-500",
81
+ "--color-cyan-600",
82
+ "--color-cyan-700",
83
+ "--color-cyan-800",
84
+ "--color-cyan-900",
85
+ "--color-cyan-950",
86
+ "--color-emerald-100",
87
+ "--color-emerald-200",
88
+ "--color-emerald-300",
89
+ "--color-emerald-400",
90
+ "--color-emerald-50",
91
+ "--color-emerald-500",
92
+ "--color-emerald-600",
93
+ "--color-emerald-700",
94
+ "--color-emerald-800",
95
+ "--color-emerald-900",
96
+ "--color-emerald-950",
97
+ "--color-fuchsia-100",
98
+ "--color-fuchsia-200",
99
+ "--color-fuchsia-300",
100
+ "--color-fuchsia-400",
101
+ "--color-fuchsia-50",
102
+ "--color-fuchsia-500",
103
+ "--color-fuchsia-600",
104
+ "--color-fuchsia-700",
105
+ "--color-fuchsia-800",
106
+ "--color-fuchsia-900",
107
+ "--color-fuchsia-950",
108
+ "--color-gray-100",
109
+ "--color-gray-200",
110
+ "--color-gray-300",
111
+ "--color-gray-400",
112
+ "--color-gray-50",
113
+ "--color-gray-500",
114
+ "--color-gray-600",
115
+ "--color-gray-700",
116
+ "--color-gray-800",
117
+ "--color-gray-900",
118
+ "--color-gray-950",
119
+ "--color-green-100",
120
+ "--color-green-200",
121
+ "--color-green-300",
122
+ "--color-green-400",
123
+ "--color-green-50",
124
+ "--color-green-500",
125
+ "--color-green-600",
126
+ "--color-green-700",
127
+ "--color-green-800",
128
+ "--color-green-900",
129
+ "--color-green-950",
130
+ "--color-indigo-100",
131
+ "--color-indigo-200",
132
+ "--color-indigo-300",
133
+ "--color-indigo-400",
134
+ "--color-indigo-50",
135
+ "--color-indigo-500",
136
+ "--color-indigo-600",
137
+ "--color-indigo-700",
138
+ "--color-indigo-800",
139
+ "--color-indigo-900",
140
+ "--color-indigo-950",
141
+ "--color-lime-100",
142
+ "--color-lime-200",
143
+ "--color-lime-300",
144
+ "--color-lime-400",
145
+ "--color-lime-50",
146
+ "--color-lime-500",
147
+ "--color-lime-600",
148
+ "--color-lime-700",
149
+ "--color-lime-800",
150
+ "--color-lime-900",
151
+ "--color-lime-950",
152
+ "--color-mauve-100",
153
+ "--color-mauve-200",
154
+ "--color-mauve-300",
155
+ "--color-mauve-400",
156
+ "--color-mauve-50",
157
+ "--color-mauve-500",
158
+ "--color-mauve-600",
159
+ "--color-mauve-700",
160
+ "--color-mauve-800",
161
+ "--color-mauve-900",
162
+ "--color-mauve-950",
163
+ "--color-mist-100",
164
+ "--color-mist-200",
165
+ "--color-mist-300",
166
+ "--color-mist-400",
167
+ "--color-mist-50",
168
+ "--color-mist-500",
169
+ "--color-mist-600",
170
+ "--color-mist-700",
171
+ "--color-mist-800",
172
+ "--color-mist-900",
173
+ "--color-mist-950",
174
+ "--color-neutral-100",
175
+ "--color-neutral-200",
176
+ "--color-neutral-300",
177
+ "--color-neutral-400",
178
+ "--color-neutral-50",
179
+ "--color-neutral-500",
180
+ "--color-neutral-600",
181
+ "--color-neutral-700",
182
+ "--color-neutral-800",
183
+ "--color-neutral-900",
184
+ "--color-neutral-950",
185
+ "--color-olive-100",
186
+ "--color-olive-200",
187
+ "--color-olive-300",
188
+ "--color-olive-400",
189
+ "--color-olive-50",
190
+ "--color-olive-500",
191
+ "--color-olive-600",
192
+ "--color-olive-700",
193
+ "--color-olive-800",
194
+ "--color-olive-900",
195
+ "--color-olive-950",
196
+ "--color-orange-100",
197
+ "--color-orange-200",
198
+ "--color-orange-300",
199
+ "--color-orange-400",
200
+ "--color-orange-50",
201
+ "--color-orange-500",
202
+ "--color-orange-600",
203
+ "--color-orange-700",
204
+ "--color-orange-800",
205
+ "--color-orange-900",
206
+ "--color-orange-950",
207
+ "--color-pink-100",
208
+ "--color-pink-200",
209
+ "--color-pink-300",
210
+ "--color-pink-400",
211
+ "--color-pink-50",
212
+ "--color-pink-500",
213
+ "--color-pink-600",
214
+ "--color-pink-700",
215
+ "--color-pink-800",
216
+ "--color-pink-900",
217
+ "--color-pink-950",
218
+ "--color-purple-100",
219
+ "--color-purple-200",
220
+ "--color-purple-300",
221
+ "--color-purple-400",
222
+ "--color-purple-50",
223
+ "--color-purple-500",
224
+ "--color-purple-600",
225
+ "--color-purple-700",
226
+ "--color-purple-800",
227
+ "--color-purple-900",
228
+ "--color-purple-950",
229
+ "--color-red-100",
230
+ "--color-red-200",
231
+ "--color-red-300",
232
+ "--color-red-400",
233
+ "--color-red-50",
234
+ "--color-red-500",
235
+ "--color-red-600",
236
+ "--color-red-700",
237
+ "--color-red-800",
238
+ "--color-red-900",
239
+ "--color-red-950",
240
+ "--color-rose-100",
241
+ "--color-rose-200",
242
+ "--color-rose-300",
243
+ "--color-rose-400",
244
+ "--color-rose-50",
245
+ "--color-rose-500",
246
+ "--color-rose-600",
247
+ "--color-rose-700",
248
+ "--color-rose-800",
249
+ "--color-rose-900",
250
+ "--color-rose-950",
251
+ "--color-sky-100",
252
+ "--color-sky-200",
253
+ "--color-sky-300",
254
+ "--color-sky-400",
255
+ "--color-sky-50",
256
+ "--color-sky-500",
257
+ "--color-sky-600",
258
+ "--color-sky-700",
259
+ "--color-sky-800",
260
+ "--color-sky-900",
261
+ "--color-sky-950",
262
+ "--color-slate-100",
263
+ "--color-slate-200",
264
+ "--color-slate-300",
265
+ "--color-slate-400",
266
+ "--color-slate-50",
267
+ "--color-slate-500",
268
+ "--color-slate-600",
269
+ "--color-slate-700",
270
+ "--color-slate-800",
271
+ "--color-slate-900",
272
+ "--color-slate-950",
273
+ "--color-stone-100",
274
+ "--color-stone-200",
275
+ "--color-stone-300",
276
+ "--color-stone-400",
277
+ "--color-stone-50",
278
+ "--color-stone-500",
279
+ "--color-stone-600",
280
+ "--color-stone-700",
281
+ "--color-stone-800",
282
+ "--color-stone-900",
283
+ "--color-stone-950",
284
+ "--color-taupe-100",
285
+ "--color-taupe-200",
286
+ "--color-taupe-300",
287
+ "--color-taupe-400",
288
+ "--color-taupe-50",
289
+ "--color-taupe-500",
290
+ "--color-taupe-600",
291
+ "--color-taupe-700",
292
+ "--color-taupe-800",
293
+ "--color-taupe-900",
294
+ "--color-taupe-950",
295
+ "--color-teal-100",
296
+ "--color-teal-200",
297
+ "--color-teal-300",
298
+ "--color-teal-400",
299
+ "--color-teal-50",
300
+ "--color-teal-500",
301
+ "--color-teal-600",
302
+ "--color-teal-700",
303
+ "--color-teal-800",
304
+ "--color-teal-900",
305
+ "--color-teal-950",
306
+ "--color-violet-100",
307
+ "--color-violet-200",
308
+ "--color-violet-300",
309
+ "--color-violet-400",
310
+ "--color-violet-50",
311
+ "--color-violet-500",
312
+ "--color-violet-600",
313
+ "--color-violet-700",
314
+ "--color-violet-800",
315
+ "--color-violet-900",
316
+ "--color-violet-950",
317
+ "--color-white",
318
+ "--color-yellow-100",
319
+ "--color-yellow-200",
320
+ "--color-yellow-300",
321
+ "--color-yellow-400",
322
+ "--color-yellow-50",
323
+ "--color-yellow-500",
324
+ "--color-yellow-600",
325
+ "--color-yellow-700",
326
+ "--color-yellow-800",
327
+ "--color-yellow-900",
328
+ "--color-yellow-950",
329
+ "--color-zinc-100",
330
+ "--color-zinc-200",
331
+ "--color-zinc-300",
332
+ "--color-zinc-400",
333
+ "--color-zinc-50",
334
+ "--color-zinc-500",
335
+ "--color-zinc-600",
336
+ "--color-zinc-700",
337
+ "--color-zinc-800",
338
+ "--color-zinc-900",
339
+ "--color-zinc-950",
340
+ "--container-2xl",
341
+ "--container-2xs",
342
+ "--container-3xl",
343
+ "--container-3xs",
344
+ "--container-4xl",
345
+ "--container-5xl",
346
+ "--container-6xl",
347
+ "--container-7xl",
348
+ "--container-lg",
349
+ "--container-md",
350
+ "--container-sm",
351
+ "--container-xl",
352
+ "--container-xs",
353
+ "--default-font-family",
354
+ "--default-font-feature-settings",
355
+ "--default-font-variation-settings",
356
+ "--default-mono-font-family",
357
+ "--default-mono-font-feature-settings",
358
+ "--default-mono-font-variation-settings",
359
+ "--default-transition-duration",
360
+ "--default-transition-timing-function",
361
+ "--drop-shadow",
362
+ "--drop-shadow-2xl",
363
+ "--drop-shadow-lg",
364
+ "--drop-shadow-md",
365
+ "--drop-shadow-sm",
366
+ "--drop-shadow-xl",
367
+ "--drop-shadow-xs",
368
+ "--ease-in",
369
+ "--ease-in-out",
370
+ "--ease-out",
371
+ "--font-mono",
372
+ "--font-sans",
373
+ "--font-serif",
374
+ "--font-weight-black",
375
+ "--font-weight-bold",
376
+ "--font-weight-extrabold",
377
+ "--font-weight-extralight",
378
+ "--font-weight-light",
379
+ "--font-weight-medium",
380
+ "--font-weight-normal",
381
+ "--font-weight-semibold",
382
+ "--font-weight-thin",
383
+ "--inset-shadow-2xs",
384
+ "--inset-shadow-sm",
385
+ "--inset-shadow-xs",
386
+ "--leading-loose",
387
+ "--leading-normal",
388
+ "--leading-relaxed",
389
+ "--leading-snug",
390
+ "--leading-tight",
391
+ "--max-width-prose",
392
+ "--perspective-distant",
393
+ "--perspective-dramatic",
394
+ "--perspective-midrange",
395
+ "--perspective-near",
396
+ "--perspective-normal",
397
+ "--radius",
398
+ "--radius-2xl",
399
+ "--radius-3xl",
400
+ "--radius-4xl",
401
+ "--radius-lg",
402
+ "--radius-md",
403
+ "--radius-sm",
404
+ "--radius-xl",
405
+ "--radius-xs",
406
+ "--shadow",
407
+ "--shadow-2xl",
408
+ "--shadow-2xs",
409
+ "--shadow-inner",
410
+ "--shadow-lg",
411
+ "--shadow-md",
412
+ "--shadow-sm",
413
+ "--shadow-xl",
414
+ "--shadow-xs",
415
+ "--spacing",
416
+ "--text-2xl",
417
+ "--text-2xl--line-height",
418
+ "--text-3xl",
419
+ "--text-3xl--line-height",
420
+ "--text-4xl",
421
+ "--text-4xl--line-height",
422
+ "--text-5xl",
423
+ "--text-5xl--line-height",
424
+ "--text-6xl",
425
+ "--text-6xl--line-height",
426
+ "--text-7xl",
427
+ "--text-7xl--line-height",
428
+ "--text-8xl",
429
+ "--text-8xl--line-height",
430
+ "--text-9xl",
431
+ "--text-9xl--line-height",
432
+ "--text-base",
433
+ "--text-base--line-height",
434
+ "--text-lg",
435
+ "--text-lg--line-height",
436
+ "--text-shadow-2xs",
437
+ "--text-shadow-lg",
438
+ "--text-shadow-md",
439
+ "--text-shadow-sm",
440
+ "--text-shadow-xs",
441
+ "--text-sm",
442
+ "--text-sm--line-height",
443
+ "--text-xl",
444
+ "--text-xl--line-height",
445
+ "--text-xs",
446
+ "--text-xs--line-height",
447
+ "--tracking-normal",
448
+ "--tracking-tight",
449
+ "--tracking-tighter",
450
+ "--tracking-wide",
451
+ "--tracking-wider",
452
+ "--tracking-widest",
453
+ ]);
@@ -1,17 +1,51 @@
1
+ import { TAILWIND_THEME_VARS } from "./tailwind-theme-vars.js";
1
2
  /** `--radius-lg: var(--ds-radius-lg);` - uma redefinição de utilitário do Tailwind pelo nosso token. */
2
3
  const ALIGNMENT = /^([ \t]*)(--[a-zA-Z0-9-]+)(\s*:\s*)var\(\s*(--ds-[a-zA-Z0-9-]+)\s*\)\s*;[ \t]*\n?/gm;
3
4
  export function onlyWhatMatched(css,
4
5
  /** Os nossos tokens que casaram com um nome do código dele - ver `PointedAt.pairs`. */
5
6
  matched) {
6
7
  let kept = 0;
8
+ const own = [];
7
9
  const dropped = [];
8
10
  const out = css.replace(ALIGNMENT, (whole, _indent, tailwind, _sep, ours) => {
9
11
  if (matched.has(ours)) {
10
12
  kept += 1;
11
13
  return whole;
12
14
  }
15
+ /**
16
+ * NÃO HÁ CLASSE DELE PARA PROTEGER QUANDO O NOME É NOSSO - e sem esta linha o utilitário
17
+ * simplesmente não existe.
18
+ *
19
+ * A pergunta que este arquivo faz precisa ser *"esta redefinição ROUBA o significado de uma
20
+ * classe que o app dele já usa?"*, e a resposta está no `@theme` padrão do Tailwind. Para
21
+ * `--radius-xl` ela é sim: `rounded-xl` vale 12px no código dele e a nossa folha o faria
22
+ * valer 28px - o defeito de 23/08, e a exigência do casamento continua valendo ali.
23
+ *
24
+ * Para `--spacing-2xs`, `--color-canvas` ou `--shadow-glow` a resposta é NÃO: o Tailwind não
25
+ * declara nenhum dos três, então não existe classe dele com esse nome e nada é roubado. O que
26
+ * a remoção fazia era apagar a ÚNICA declaração que podia gerar o utilitário - e o Tailwind
27
+ * v4 só gera a partir de `@theme`, nunca das variáveis que o `tokens.css` re-emite dentro de
28
+ * `[data-ds]`.
29
+ *
30
+ * MEDIDO em 07/09, nas duas populações, com o Tailwind 4.3.3 de verdade:
31
+ *
32
+ * codelevel 74 removidas = 24 que colidem + 50 que só existem no sistema
33
+ * ember, app novo 64 removidas = 19 que colidem + 45 que só existem no sistema
34
+ *
35
+ * E o efeito na tela: das 23 classes utilitárias do `button` do ember, 11 dependiam de uma
36
+ * linha removida, e 10 delas NÃO eram geradas - o botão chegava sem padding, sem gap, sem cor
37
+ * de texto, sem sombra e sem a família de fonte.
38
+ *
39
+ * A LISTA É DERIVADA DO PACOTE e vem do gêmeo `tailwind-theme-vars.ts`; um nome que o
40
+ * Tailwind passe a declarar numa versão futura é divergência que o spec do lado do web
41
+ * reprova, e não silêncio.
42
+ */
43
+ if (!TAILWIND_THEME_VARS.has(tailwind)) {
44
+ own.push(tailwind);
45
+ return whole;
46
+ }
13
47
  dropped.push(tailwind);
14
48
  return "";
15
49
  });
16
- return { css: out, kept, dropped: dropped.sort() };
50
+ return { css: out, kept, own: own.sort(), dropped: dropped.sort() };
17
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "synthesisui",
3
- "version": "0.16.387",
3
+ "version": "0.16.389",
4
4
  "description": "Bring SynthesisUI design systems into any project - tokens, typed components, whole pages and an agent-ready CLAUDE.md manifest.",
5
5
  "type": "module",
6
6
  "bin": {