synthesisui 0.16.463 → 0.16.464
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/changed-files.js +26 -1
- package/dist/component-codegen.js +34 -7
- package/dist/install-marks.js +7 -1
- package/package.json +1 -1
package/dist/changed-files.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
|
-
import { readdir, stat } from "node:fs/promises";
|
|
2
|
+
import { readdir, readFile, stat } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
5
|
const run = promisify(execFile);
|
|
@@ -43,8 +43,31 @@ async function isGitRepo(root) {
|
|
|
43
43
|
}));
|
|
44
44
|
return stdout.trim() === "true";
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* O `.gitignore` DA RAIZ, NA FORMA SIMPLES - rodada 4 do refinamento, 27/09. No leigo-4 (sem git) o fim
|
|
48
|
+
* do turno checou o `next-env.d.ts`, que o Next gera e que o `.gitignore` do `create-next-app` já exclui:
|
|
49
|
+
* sem git, ninguém lia aquele arquivo. Cobre nome, `/` na frente (só na raiz), `/` no fim (só pasta) e
|
|
50
|
+
* `*`; a negação (`!`) é ignorada - no pior caso um arquivo que ele quer checado fica de fora, como era
|
|
51
|
+
* antes do conserto de 27/09 para a pasta inteira.
|
|
52
|
+
*/
|
|
53
|
+
async function ignoredBy(root) {
|
|
54
|
+
const text = await readFile(join(root, ".gitignore"), "utf8").catch(() => "");
|
|
55
|
+
const rules = text
|
|
56
|
+
.split("\n")
|
|
57
|
+
.map((l) => l.trim())
|
|
58
|
+
.filter((l) => l && !l.startsWith("#") && !l.startsWith("!"))
|
|
59
|
+
.map((l) => {
|
|
60
|
+
const onlyDir = l.endsWith("/");
|
|
61
|
+
const body = l.replace(/^\//, "").replace(/\/$/, "");
|
|
62
|
+
const anchored = l.startsWith("/") || body.includes("/");
|
|
63
|
+
const glob = body.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]");
|
|
64
|
+
return { onlyDir, re: new RegExp(anchored ? `^${glob}$` : `(^|/)${glob}$`) };
|
|
65
|
+
});
|
|
66
|
+
return (rel, dir) => rules.some((r) => (!r.onlyDir || dir) && r.re.test(rel));
|
|
67
|
+
}
|
|
46
68
|
async function walked(root) {
|
|
47
69
|
const out = [];
|
|
70
|
+
const ignored = await ignoredBy(root);
|
|
48
71
|
const go = async (rel) => {
|
|
49
72
|
if (out.length >= WALK_MAX)
|
|
50
73
|
return;
|
|
@@ -52,6 +75,8 @@ async function walked(root) {
|
|
|
52
75
|
if (entry.name.startsWith(".") || WALK_SKIP.has(entry.name))
|
|
53
76
|
continue;
|
|
54
77
|
const next = rel ? `${rel}/${entry.name}` : entry.name;
|
|
78
|
+
if (ignored(next, entry.isDirectory()))
|
|
79
|
+
continue;
|
|
55
80
|
if (entry.isDirectory())
|
|
56
81
|
await go(next);
|
|
57
82
|
else if (entry.isFile())
|
|
@@ -611,8 +611,11 @@ export class ThemeVocab extends Set {
|
|
|
611
611
|
* O nome que casa vale se o valor também casa - ou se um dos dois lados não tem valor conhecido, que
|
|
612
612
|
* é o comportamento de antes. Sem nome que case, o VALOR acha o nome, mas só quando exatamente uma
|
|
613
613
|
* variável dele o segura: duas seria adivinhar qual das duas ele quis dizer.
|
|
614
|
+
*
|
|
615
|
+
* `prefer` desempata, e só ele: quando o empate inclui a palavra da própria propriedade (`border`
|
|
616
|
+
* numa declaração de borda), é esse o nome. Sem ela no empate, continua sem adivinhar (rodada 4).
|
|
614
617
|
*/
|
|
615
|
-
nameFor(ref, ns, byName) {
|
|
618
|
+
nameFor(ref, ns, byName, prefer = null) {
|
|
616
619
|
const path = /^\{([^}]+)\}$/.exec(ref.trim())?.[1];
|
|
617
620
|
const want = path ? this.dsValues.get(`--ds-${path.replace(/\./g, "-")}`) : undefined;
|
|
618
621
|
if (byName && this.has(`--${ns}-${byName}`)) {
|
|
@@ -625,7 +628,9 @@ export class ThemeVocab extends Set {
|
|
|
625
628
|
const hits = [...this.theirValues]
|
|
626
629
|
.filter(([n, v]) => n.startsWith(`--${ns}-`) && sameValue(v, want))
|
|
627
630
|
.map(([n]) => n.slice(ns.length + 3));
|
|
628
|
-
|
|
631
|
+
if (hits.length === 1)
|
|
632
|
+
return hits[0];
|
|
633
|
+
return prefer && hits.includes(prefer) ? prefer : null;
|
|
629
634
|
}
|
|
630
635
|
}
|
|
631
636
|
const sameValue = (a, b) => a.trim().toLowerCase().replace(/\s+/g, " ") === b.trim().toLowerCase().replace(/\s+/g, " ");
|
|
@@ -644,12 +649,34 @@ const paletteKey = (v) => {
|
|
|
644
649
|
return null;
|
|
645
650
|
return `${m[1]}-${m[2]}`;
|
|
646
651
|
};
|
|
647
|
-
const theirColorKey = (value, themeVars) => {
|
|
652
|
+
const theirColorKey = (value, themeVars, prefer = null) => {
|
|
648
653
|
const key = colorKey(value) ?? (themeVars instanceof ThemeVocab ? paletteKey(value) : null);
|
|
649
654
|
if (themeVars instanceof ThemeVocab)
|
|
650
|
-
return themeVars.nameFor(value, "color", key);
|
|
655
|
+
return themeVars.nameFor(value, "color", key, prefer);
|
|
651
656
|
return key && minted(themeVars, `--color-${key}`) ? key : null;
|
|
652
657
|
};
|
|
658
|
+
/** A palavra da propriedade que desempata dois nomes dele com o mesmo valor - ver `nameFor`. */
|
|
659
|
+
const preferFor = (prop) => (prop.startsWith("border") ? "border" : null);
|
|
660
|
+
/**
|
|
661
|
+
* AS CORES DE DENTRO DE UM VALOR COMPOSTO, NO NOME DELE - rodada 4 do refinamento, 27/09.
|
|
662
|
+
*
|
|
663
|
+
* O gradiente do botão do Gossamer (`linear-gradient(135deg, {color.semantic.accent}, …)`) não tem
|
|
664
|
+
* utilitário e ia inteiro para o arbitrário, onde a cor só achava o nome dele depois de um build: num
|
|
665
|
+
* Next novo saía `#eaa83c` com `--color-accent` declarado. Cada referência de cor é resolvida aqui pela
|
|
666
|
+
* mesma regra do utilitário (`theirColorKey`, que não precisa de build) e vira `var(--color-<nome>)`; a
|
|
667
|
+
* que não tem nome segue para a porta de tradução, que escreve o valor.
|
|
668
|
+
*
|
|
669
|
+
* `null` é "ninguém mediu", e aí nada é trocado: escrever `var(--color-x)` sem saber se ele declara
|
|
670
|
+
* seria uma cor que some.
|
|
671
|
+
*/
|
|
672
|
+
const namedInside = (prop, value, themeVars) => {
|
|
673
|
+
if (themeVars === null)
|
|
674
|
+
return value;
|
|
675
|
+
return value.replace(/\{color\.[a-zA-Z0-9.-]+\}/g, (ref) => {
|
|
676
|
+
const key = theirColorKey(ref, themeVars, preferFor(prop));
|
|
677
|
+
return key ? `var(--color-${key})` : ref;
|
|
678
|
+
});
|
|
679
|
+
};
|
|
653
680
|
/** One declaration → Tailwind classes (pretty when mappable, arbitrary-property
|
|
654
681
|
* otherwise - never dropped). */
|
|
655
682
|
function declToTailwind(prop, value, themeVars) {
|
|
@@ -672,7 +699,7 @@ function declToTailwind(prop, value, themeVars) {
|
|
|
672
699
|
break;
|
|
673
700
|
}
|
|
674
701
|
case "borderColor": {
|
|
675
|
-
const key = theirColorKey(value, themeVars);
|
|
702
|
+
const key = theirColorKey(value, themeVars, "border");
|
|
676
703
|
if (key)
|
|
677
704
|
return [`border-${key}`];
|
|
678
705
|
break;
|
|
@@ -681,7 +708,7 @@ function declToTailwind(prop, value, themeVars) {
|
|
|
681
708
|
// "1px solid {color.semantic.x}" → border + border-<x>
|
|
682
709
|
const m = value.match(/^1px\s+solid\s+(\{[^}]+\})$/);
|
|
683
710
|
if (m) {
|
|
684
|
-
const key = theirColorKey(m[1], themeVars);
|
|
711
|
+
const key = theirColorKey(m[1], themeVars, "border");
|
|
685
712
|
if (key)
|
|
686
713
|
return ["border", `border-${key}`];
|
|
687
714
|
}
|
|
@@ -767,7 +794,7 @@ function declToTailwind(prop, value, themeVars) {
|
|
|
767
794
|
break;
|
|
768
795
|
}
|
|
769
796
|
}
|
|
770
|
-
return [arbitrary(prop, value)];
|
|
797
|
+
return [arbitrary(prop, namedInside(prop, value, themeVars))];
|
|
771
798
|
}
|
|
772
799
|
/**
|
|
773
800
|
* TAILWIND'S OWN WORD FOR A STATE, WHEN IT HAS ONE - and a mechanical rule when it
|
package/dist/install-marks.js
CHANGED
|
@@ -269,7 +269,13 @@
|
|
|
269
269
|
* nome os degraus da paleta que o projeto declara (`{color.coral.700}` -> `bg-coral-700`) - o badge do
|
|
270
270
|
* Zephyr saía com quatro cores cruas (rodada 3 do refinamento).
|
|
271
271
|
*/
|
|
272
|
-
|
|
272
|
+
/**
|
|
273
|
+
* 0.16.463 -> 0.16.464 em 27/09, e o passo 1 dá **SIM**: o gerador que o `upgrade` usa passa a achar o nome
|
|
274
|
+
* dele dentro de um valor composto - o gradiente do botão do Gossamer saía `#eaa83c, #dd4161` com
|
|
275
|
+
* `--color-accent` e `--color-primary` declarados - e a desempatar pela palavra da propriedade numa borda
|
|
276
|
+
* (rodada 4 do refinamento).
|
|
277
|
+
*/
|
|
278
|
+
export const MATERIALISER_SINCE = "0.16.464";
|
|
273
279
|
/**
|
|
274
280
|
* A ÚLTIMA VERSÃO EM QUE O QUE O HOOK RODA MUDOU.
|
|
275
281
|
*
|
package/package.json
CHANGED