@clhaas/palette-kit 0.3.0 → 0.4.0
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/CHANGELOG.md +25 -0
- package/README.md +80 -87
- package/dist/contrast/contrast.d.ts +16 -0
- package/dist/contrast/contrast.js +102 -0
- package/dist/core/intent-registry.d.ts +11 -0
- package/dist/core/intent-registry.js +70 -0
- package/dist/core/oklch.d.ts +16 -0
- package/dist/core/oklch.js +56 -0
- package/dist/create-palette-kit.d.ts +9 -0
- package/dist/create-palette-kit.js +67 -0
- package/dist/engine/context/context.d.ts +13 -0
- package/dist/engine/context/context.js +37 -0
- package/dist/engine/level/curves.d.ts +17 -0
- package/dist/engine/level/curves.js +49 -0
- package/dist/engine/level/level.d.ts +4 -0
- package/dist/engine/level/level.js +13 -0
- package/dist/engine/relation/relation.d.ts +105 -0
- package/dist/engine/relation/relation.js +137 -0
- package/dist/engine/resolve/resolve.d.ts +36 -0
- package/dist/engine/resolve/resolve.js +116 -0
- package/dist/engine/state/state.d.ts +46 -0
- package/dist/engine/state/state.js +68 -0
- package/dist/engine/usage/fill.d.ts +9 -0
- package/dist/engine/usage/fill.js +9 -0
- package/dist/engine/usage/lines.d.ts +9 -0
- package/dist/engine/usage/lines.js +9 -0
- package/dist/engine/usage/overlays.d.ts +9 -0
- package/dist/engine/usage/overlays.js +9 -0
- package/dist/engine/usage/strategy.d.ts +56 -0
- package/dist/engine/usage/strategy.js +30 -0
- package/dist/engine/usage/visualVocabulary.d.ts +9 -0
- package/dist/engine/usage/visualVocabulary.js +9 -0
- package/dist/export/serialize.d.ts +14 -0
- package/dist/export/serialize.js +89 -0
- package/dist/export/types.d.ts +37 -0
- package/dist/export/types.js +31 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/operators/convert.d.ts +32 -0
- package/dist/operators/convert.js +80 -0
- package/dist/presets/presets.d.ts +95 -0
- package/dist/presets/presets.js +308 -0
- package/dist/types/index.d.ts +111 -187
- package/dist/utils/errors/errors.d.ts +17 -0
- package/dist/utils/errors/errors.js +22 -0
- package/docs/API.md +167 -0
- package/docs/Alpha.md +14 -0
- package/docs/Architecture.md +56 -0
- package/docs/CLI.md +22 -0
- package/docs/Concepts.md +73 -0
- package/docs/Config.md +144 -0
- package/docs/Diagnostics.md +22 -0
- package/docs/Exporters.md +33 -0
- package/docs/FAQ.md +59 -0
- package/docs/Migration.md +61 -0
- package/docs/Overlays.md +33 -0
- package/docs/README.md +60 -0
- package/docs/Text.md +41 -0
- package/docs/Tokens.md +42 -0
- package/docs/Usage-JSON.md +39 -0
- package/docs/Usage-ReactNative.md +63 -0
- package/docs/Usage-Web.md +66 -0
- package/docs/Validation.md +97 -0
- package/docs/Why.md +37 -0
- package/docs/_api-surface.md +53 -0
- package/docs/snippets/serialize-oklch.md +9 -0
- package/docs/spec.md +98 -0
- package/package.json +74 -59
- package/.codex/skills/color-pipeline-implementer/SKILL.md +0 -23
- package/.codex/skills/commit-message-crafter/SKILL.md +0 -63
- package/.codex/skills/commit-message-crafter/references/benchmarks.md +0 -20
- package/.codex/skills/contrast-solver-helper/SKILL.md +0 -20
- package/.codex/skills/exporters-builder/SKILL.md +0 -20
- package/.codex/skills/markdownlint-writer/SKILL.md +0 -32
- package/.codex/skills/phase-implementation-runbook/SKILL.md +0 -92
- package/.codex/skills/type-contract-auditor/SKILL.md +0 -21
- package/.github/skills/review-guide/SKILL.md +0 -23
- package/.github/skills/review-guide/references/review-guide-v0.3.md +0 -629
- package/.markdownlint.json +0 -4
- package/AGENTS.md +0 -16
- package/biome.json +0 -43
- package/dist/cli/args.d.ts +0 -12
- package/dist/cli/args.js +0 -56
- package/dist/cli/args.test.d.ts +0 -1
- package/dist/cli/args.test.js +0 -22
- package/dist/cli/codegen/__snapshots__/tokens.test.js.snap +0 -87
- package/dist/cli/codegen/tokens.d.ts +0 -12
- package/dist/cli/codegen/tokens.js +0 -139
- package/dist/cli/codegen/tokens.test.d.ts +0 -1
- package/dist/cli/codegen/tokens.test.js +0 -51
- package/dist/cli/config.d.ts +0 -40
- package/dist/cli/config.js +0 -34
- package/dist/cli/validate.d.ts +0 -2
- package/dist/cli/validate.js +0 -33
- package/dist/cli/validate.test.d.ts +0 -1
- package/dist/cli/validate.test.js +0 -40
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -148
- package/dist/contrast/apca.d.ts +0 -2
- package/dist/contrast/apca.js +0 -15
- package/dist/contrast/apca.test.d.ts +0 -1
- package/dist/contrast/apca.test.js +0 -16
- package/dist/contrast/index.d.ts +0 -4
- package/dist/contrast/index.js +0 -4
- package/dist/contrast/scoring.d.ts +0 -4
- package/dist/contrast/scoring.js +0 -31
- package/dist/contrast/scoring.test.d.ts +0 -1
- package/dist/contrast/scoring.test.js +0 -148
- package/dist/contrast/solver.d.ts +0 -13
- package/dist/contrast/solver.js +0 -170
- package/dist/contrast/solver.test.d.ts +0 -1
- package/dist/contrast/solver.test.js +0 -75
- package/dist/contrast/types.d.ts +0 -17
- package/dist/contrast/types.js +0 -1
- package/dist/contrast/utils.d.ts +0 -4
- package/dist/contrast/utils.js +0 -18
- package/dist/contrast/wcag2.d.ts +0 -3
- package/dist/contrast/wcag2.js +0 -19
- package/dist/contrast/wcag2.test.d.ts +0 -1
- package/dist/contrast/wcag2.test.js +0 -17
- package/dist/core/createTheme.d.ts +0 -35
- package/dist/core/createTheme.js +0 -24
- package/dist/core/dx-helpers.test.d.ts +0 -1
- package/dist/core/dx-helpers.test.js +0 -61
- package/dist/core/index.d.ts +0 -2
- package/dist/core/index.js +0 -2
- package/dist/core/onSolid.test.d.ts +0 -1
- package/dist/core/onSolid.test.js +0 -118
- package/dist/core/qa.v1.test.d.ts +0 -1
- package/dist/core/qa.v1.test.js +0 -112
- package/dist/core/resolve.d.ts +0 -3
- package/dist/core/resolve.js +0 -8
- package/dist/core/resolve.test.d.ts +0 -1
- package/dist/core/resolve.test.js +0 -89
- package/dist/core/resolveMany.d.ts +0 -8
- package/dist/core/resolveMany.js +0 -17
- package/dist/core/tokenRegistry.d.ts +0 -23
- package/dist/core/tokenRegistry.js +0 -83
- package/dist/core/tokenRegistry.test.d.ts +0 -1
- package/dist/core/tokenRegistry.test.js +0 -133
- package/dist/engine/applyOperators.d.ts +0 -3
- package/dist/engine/applyOperators.js +0 -23
- package/dist/engine/context.d.ts +0 -4
- package/dist/engine/context.js +0 -1
- package/dist/engine/gamut.d.ts +0 -13
- package/dist/engine/gamut.js +0 -101
- package/dist/engine/gamut.test.d.ts +0 -1
- package/dist/engine/gamut.test.js +0 -23
- package/dist/engine/generateScale.d.ts +0 -15
- package/dist/engine/generateScale.js +0 -29
- package/dist/engine/generateScale.test.d.ts +0 -1
- package/dist/engine/generateScale.test.js +0 -32
- package/dist/engine/index.d.ts +0 -8
- package/dist/engine/index.js +0 -4
- package/dist/engine/normalize.d.ts +0 -43
- package/dist/engine/normalize.js +0 -403
- package/dist/engine/normalize.test.d.ts +0 -1
- package/dist/engine/normalize.test.js +0 -136
- package/dist/engine/onSolid.d.ts +0 -3
- package/dist/engine/onSolid.js +0 -110
- package/dist/engine/resolveBaseColor.d.ts +0 -25
- package/dist/engine/resolveBaseColor.js +0 -127
- package/dist/engine/resolveBaseColor.test.d.ts +0 -1
- package/dist/engine/resolveBaseColor.test.js +0 -97
- package/dist/export/__snapshots__/exportTheme.test.js.snap +0 -74
- package/dist/export/exportTheme.d.ts +0 -47
- package/dist/export/exportTheme.js +0 -170
- package/dist/export/exportTheme.test.d.ts +0 -1
- package/dist/export/exportTheme.test.js +0 -118
- package/dist/export/index.d.ts +0 -1
- package/dist/export/index.js +0 -1
- package/dist/export/serializeColor.d.ts +0 -1
- package/dist/export/serializeColor.js +0 -1
- package/dist/export/serializeColor.test.d.ts +0 -1
- package/dist/export/serializeColor.test.js +0 -54
- package/dist/export.d.ts +0 -1
- package/dist/export.js +0 -1
- package/dist/operators/emphasis.d.ts +0 -3
- package/dist/operators/emphasis.js +0 -113
- package/dist/operators/emphasis.test.d.ts +0 -1
- package/dist/operators/emphasis.test.js +0 -69
- package/dist/operators/index.d.ts +0 -3
- package/dist/operators/index.js +0 -2
- package/dist/operators/state.d.ts +0 -3
- package/dist/operators/state.js +0 -102
- package/dist/operators/state.test.d.ts +0 -1
- package/dist/operators/state.test.js +0 -48
- package/dist/operators/types.d.ts +0 -13
- package/dist/operators/types.js +0 -1
- package/dist/operators/utils.d.ts +0 -16
- package/dist/operators/utils.js +0 -23
- package/dist/presets/curves.d.ts +0 -28
- package/dist/presets/curves.js +0 -145
- package/dist/presets/index.d.ts +0 -2
- package/dist/presets/index.js +0 -1
- package/dist/presets/tokens/index.d.ts +0 -3
- package/dist/presets/tokens/index.js +0 -3
- package/dist/presets/tokens/minimal-ui.d.ts +0 -6
- package/dist/presets/tokens/minimal-ui.js +0 -53
- package/dist/presets/tokens/modern-ui.d.ts +0 -5
- package/dist/presets/tokens/modern-ui.js +0 -83
- package/dist/presets/tokens/presets.test.d.ts +0 -1
- package/dist/presets/tokens/presets.test.js +0 -31
- package/dist/presets/tokens/radixLike-ui.d.ts +0 -6
- package/dist/presets/tokens/radixLike-ui.js +0 -77
- package/dist/serialize/index.d.ts +0 -1
- package/dist/serialize/index.js +0 -1
- package/dist/serialize/normalizeOutput.d.ts +0 -6
- package/dist/serialize/normalizeOutput.js +0 -45
- package/dist/serialize/serializeColor.d.ts +0 -21
- package/dist/serialize/serializeColor.js +0 -178
- package/dist/serialize/serializeResolved.test.d.ts +0 -1
- package/dist/serialize/serializeResolved.test.js +0 -45
- package/dist/serialize.d.ts +0 -1
- package/dist/serialize.js +0 -1
- package/dist/utils/clamp.d.ts +0 -1
- package/dist/utils/clamp.js +0 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/lerp.d.ts +0 -1
- package/dist/utils/lerp.js +0 -1
- package/dist/utils/parseColor.d.ts +0 -6
- package/dist/utils/parseColor.js +0 -67
- package/dist/utils/parseColor.test.d.ts +0 -1
- package/dist/utils/parseColor.test.js +0 -51
- package/dist/utils/smoothstep.d.ts +0 -1
- package/dist/utils/smoothstep.js +0 -5
- package/planning/phase-10-review.md +0 -550
- package/planning/phase-7-review.md +0 -411
- package/planning/phase-8-review.md +0 -669
- package/planning/phase-9-review.md +0 -564
- package/planning/roadmap-v0.3.md +0 -284
- package/planning/spec-serializer-v0.3.md +0 -324
- package/planning/spec-v0.3.md +0 -305
- package/src/cli/args.test.ts +0 -28
- package/src/cli/args.ts +0 -66
- package/src/cli/codegen/__snapshots__/tokens.test.ts.snap +0 -87
- package/src/cli/codegen/tokens.test.ts +0 -61
- package/src/cli/codegen/tokens.ts +0 -191
- package/src/cli/config.ts +0 -71
- package/src/cli/validate.test.ts +0 -49
- package/src/cli/validate.ts +0 -38
- package/src/cli.ts +0 -183
- package/src/contrast/apca.test.ts +0 -20
- package/src/contrast/apca.ts +0 -26
- package/src/contrast/index.ts +0 -4
- package/src/contrast/scoring.test.ts +0 -188
- package/src/contrast/scoring.ts +0 -48
- package/src/contrast/solver.test.ts +0 -147
- package/src/contrast/solver.ts +0 -235
- package/src/contrast/types.ts +0 -20
- package/src/contrast/utils.ts +0 -28
- package/src/contrast/wcag2.test.ts +0 -21
- package/src/contrast/wcag2.ts +0 -24
- package/src/core/createTheme.ts +0 -78
- package/src/core/dx-helpers.test.ts +0 -82
- package/src/core/index.ts +0 -7
- package/src/core/onSolid.test.ts +0 -146
- package/src/core/qa.v1.test.ts +0 -149
- package/src/core/resolve.test.ts +0 -99
- package/src/core/resolve.ts +0 -11
- package/src/core/resolveMany.ts +0 -22
- package/src/core/tokenRegistry.test.ts +0 -153
- package/src/core/tokenRegistry.ts +0 -114
- package/src/engine/applyOperators.ts +0 -32
- package/src/engine/context.ts +0 -8
- package/src/engine/gamut.test.ts +0 -30
- package/src/engine/gamut.ts +0 -144
- package/src/engine/generateScale.test.ts +0 -46
- package/src/engine/generateScale.ts +0 -48
- package/src/engine/index.ts +0 -8
- package/src/engine/normalize.test.ts +0 -222
- package/src/engine/normalize.ts +0 -550
- package/src/engine/onSolid.ts +0 -178
- package/src/engine/resolveBaseColor.test.ts +0 -117
- package/src/engine/resolveBaseColor.ts +0 -203
- package/src/export/__snapshots__/exportTheme.test.ts.snap +0 -74
- package/src/export/exportTheme.test.ts +0 -144
- package/src/export/exportTheme.ts +0 -251
- package/src/export/index.ts +0 -1
- package/src/export/serializeColor.test.ts +0 -73
- package/src/export/serializeColor.ts +0 -1
- package/src/export.ts +0 -1
- package/src/index.ts +0 -3
- package/src/operators/emphasis.test.ts +0 -85
- package/src/operators/emphasis.ts +0 -132
- package/src/operators/index.ts +0 -3
- package/src/operators/state.test.ts +0 -66
- package/src/operators/state.ts +0 -122
- package/src/operators/types.ts +0 -14
- package/src/operators/utils.ts +0 -44
- package/src/presets/curves.ts +0 -168
- package/src/presets/index.ts +0 -2
- package/src/presets/tokens/index.ts +0 -3
- package/src/presets/tokens/minimal-ui.ts +0 -55
- package/src/presets/tokens/modern-ui.ts +0 -85
- package/src/presets/tokens/presets.test.ts +0 -46
- package/src/presets/tokens/radixLike-ui.ts +0 -79
- package/src/serialize/index.ts +0 -1
- package/src/serialize/normalizeOutput.ts +0 -63
- package/src/serialize/serializeColor.ts +0 -260
- package/src/serialize/serializeResolved.test.ts +0 -57
- package/src/serialize.ts +0 -1
- package/src/types/index.ts +0 -207
- package/src/utils/clamp.ts +0 -2
- package/src/utils/index.ts +0 -1
- package/src/utils/lerp.ts +0 -1
- package/src/utils/parseColor.test.ts +0 -66
- package/src/utils/parseColor.ts +0 -87
- package/src/utils/smoothstep.ts +0 -6
- package/tsconfig.build.json +0 -11
- package/tsconfig.json +0 -15
|
@@ -1,411 +0,0 @@
|
|
|
1
|
-
# Revisão Fase 7 — Codegen de Types
|
|
2
|
-
|
|
3
|
-
**Data**: 18 de janeiro de 2026
|
|
4
|
-
**Revisor**: GitHub Copilot (usando review-guide-v0.3.md)
|
|
5
|
-
**Status**: ✅ **APROVADO COM SUGESTÕES MENORES**
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 📋 Resumo Executivo
|
|
10
|
-
|
|
11
|
-
A implementação da Fase 7 (Codegen de types) está **funcionalmente completa e bem estruturada**. O código:
|
|
12
|
-
|
|
13
|
-
- ✅ Gera `tokens.ts` e `tokens.d.ts` navegáveis
|
|
14
|
-
- ✅ Possui testes com snapshots
|
|
15
|
-
- ✅ É determinístico
|
|
16
|
-
- ✅ Suporta palavras reservadas do JS
|
|
17
|
-
- ✅ Gera JSDoc por token
|
|
18
|
-
|
|
19
|
-
**Sugestões menores**:
|
|
20
|
-
|
|
21
|
-
1. Adicionar JSDoc na função pública `generateTokenArtifacts`
|
|
22
|
-
2. Validar tree-shaking em testes
|
|
23
|
-
3. Documentar comportamento de segmentos vazios
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## ✅ CRITÉRIOS GERAIS (Todos aprovados)
|
|
28
|
-
|
|
29
|
-
### 1. Contratos e tipos ✅
|
|
30
|
-
|
|
31
|
-
- ✅ **Nenhum `any` ou `unknown` injustificado**
|
|
32
|
-
- ✅ **Tipos exportados**: `GeneratedTokens` bem definido
|
|
33
|
-
- ✅ **Sem circular imports**: `tokens.ts` importa apenas de `types`
|
|
34
|
-
- ✅ **Hierarquia respeitada**: `types` → `cli/codegen`
|
|
35
|
-
- ⚠️ **JSDoc em tipos públicos**: `GeneratedTokens` tem JSDoc mínimo na função, falta no type
|
|
36
|
-
|
|
37
|
-
**Recomendação**:
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
/**
|
|
41
|
-
* Result of token artifact generation.
|
|
42
|
-
* Contains TypeScript source code for tokens.ts and tokens.d.ts,
|
|
43
|
-
* plus a sorted list of all token names.
|
|
44
|
-
*/
|
|
45
|
-
export type GeneratedTokens = {
|
|
46
|
-
/** Sorted array of all token names from the registry. */
|
|
47
|
-
tokenNames: string[];
|
|
48
|
-
/** TypeScript source code for tokens.ts (runtime export). */
|
|
49
|
-
tokensTs: string;
|
|
50
|
-
/** TypeScript declaration file source for tokens.d.ts. */
|
|
51
|
-
tokensDts: string;
|
|
52
|
-
};
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
### 2. Qualidade de código ✅
|
|
58
|
-
|
|
59
|
-
- ✅ **Build**: Código bem estruturado, sem warnings aparentes
|
|
60
|
-
- ✅ **Testes**: `tokens.test.ts` com 2 testes + snapshots
|
|
61
|
-
- ✅ **Sem TODO/FIXME**: Nenhum encontrado
|
|
62
|
-
- ✅ **Comentários**: Funções helper bem nomeadas (auto-documentadas)
|
|
63
|
-
- ✅ **Style**: Formatação consistente
|
|
64
|
-
|
|
65
|
-
**Pontos positivos**:
|
|
66
|
-
|
|
67
|
-
- `RESERVED_WORDS` como constante
|
|
68
|
-
- Escape de JSDoc com `escapeJsDoc()`
|
|
69
|
-
- Determinismo testado explicitamente
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
### 3. DX (Developer Experience) ✅
|
|
74
|
-
|
|
75
|
-
- ⚠️ **JSDoc na função pública**: Presente mas sem exemplo
|
|
76
|
-
- ✅ **Erros claros**: Validação de identifier
|
|
77
|
-
- ✅ **Sem magia**: Tree building é explícito
|
|
78
|
-
- ✅ **Autocomplete**: Estrutura nested garante navegação
|
|
79
|
-
|
|
80
|
-
**Sugestão de melhoria no JSDoc**:
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
/**
|
|
84
|
-
* Generate `dist/palette/tokens.ts` and `dist/palette/tokens.d.ts` sources.
|
|
85
|
-
*
|
|
86
|
-
* Output is deterministic and derived from the token registry.
|
|
87
|
-
* The generated files provide:
|
|
88
|
-
* - Navigable token object with JSDoc hints
|
|
89
|
-
* - Type-safe TokenName union
|
|
90
|
-
* - Full TypeScript declarations
|
|
91
|
-
*
|
|
92
|
-
* @param registry - Token registry from preset (minimal-ui, modern-ui, etc.)
|
|
93
|
-
* @returns Object with tokenNames array and source code strings
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```typescript
|
|
97
|
-
* import { modernUiTokens } from './presets/tokens';
|
|
98
|
-
* const { tokensTs, tokensDts } = generateTokenArtifacts(modernUiTokens);
|
|
99
|
-
* await writeFile('dist/tokens.ts', tokensTs);
|
|
100
|
-
* await writeFile('dist/tokens.d.ts', tokensDts);
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
---
|
|
106
|
-
|
|
107
|
-
### 4. Princípios da v0.3 ✅
|
|
108
|
-
|
|
109
|
-
- ✅ **Runtime-first**: Core não depende dos types gerados
|
|
110
|
-
- ✅ **Serializer não altera intenção**: Codegen é puro
|
|
111
|
-
- ✅ **Resolver independente**: Não afeta resolução de cores
|
|
112
|
-
- ✅ **Sem decisões visuais ocultas**: Apenas gera types
|
|
113
|
-
- ✅ **Determinismo**: Testado com `shuffled` registry
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
## ✅ CRITÉRIOS ESPECÍFICOS DA FASE 7
|
|
118
|
-
|
|
119
|
-
### Outputs ✅
|
|
120
|
-
|
|
121
|
-
- ✅ **`tokens.ts` com objeto navegável**: Estrutura nested perfeita
|
|
122
|
-
- ✅ **`tokens.d.ts` com types**: Declarations consistentes
|
|
123
|
-
- ✅ **Unions**: `TokenName` e `ColorRole` gerados
|
|
124
|
-
|
|
125
|
-
**Evidência (snapshot)**:
|
|
126
|
-
|
|
127
|
-
```typescript
|
|
128
|
-
export const tokens = {
|
|
129
|
-
bg: {
|
|
130
|
-
app: "bg.app",
|
|
131
|
-
},
|
|
132
|
-
text: {
|
|
133
|
-
primary: "text.primary",
|
|
134
|
-
},
|
|
135
|
-
} as const;
|
|
136
|
-
|
|
137
|
-
export type TokenName = (typeof tokenNames)[number];
|
|
138
|
-
export type ColorRole = TokenName;
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
---
|
|
142
|
-
|
|
143
|
-
### Autocomplete ✅
|
|
144
|
-
|
|
145
|
-
- ✅ **Navegação por objeto funciona**: `tokens.bg.app` → autocomplete
|
|
146
|
-
- ✅ **Unions inferem corretamente**: `TokenName` via `typeof`
|
|
147
|
-
- ✅ **JSDoc por token presente**: Cada token tem `@token`, `@category`, `@states`
|
|
148
|
-
- ✅ **Compatível com IDEs**: Estrutura padrão TS
|
|
149
|
-
|
|
150
|
-
**Exemplo de JSDoc gerado**:
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
/**
|
|
154
|
-
* Primary text on standard surfaces.
|
|
155
|
-
* @token text.primary
|
|
156
|
-
* @category text
|
|
157
|
-
* @states hover
|
|
158
|
-
*/
|
|
159
|
-
primary: "text.primary"
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
### Performance ✅ (com ressalva para validação)
|
|
165
|
-
|
|
166
|
-
- ✅ **Zero custo em runtime**: Strings literais com `as const`
|
|
167
|
-
- ⚠️ **Tree-shaking**: Não validado em testes (sugestão abaixo)
|
|
168
|
-
- ✅ **Bundle size**: Estrutura flat evita nesting excessivo
|
|
169
|
-
|
|
170
|
-
**Sugestão de teste tree-shaking**:
|
|
171
|
-
|
|
172
|
-
```typescript
|
|
173
|
-
it("supports tree-shaking of unused tokens", () => {
|
|
174
|
-
const { tokensTs } = generateTokenArtifacts(registry);
|
|
175
|
-
// Verificar que cada token é exportado independentemente
|
|
176
|
-
expect(tokensTs).toContain('app: "bg.app"');
|
|
177
|
-
expect(tokensTs).toContain('primary: "text.primary"');
|
|
178
|
-
// TODO: adicionar teste real de bundle com esbuild/rollup
|
|
179
|
-
});
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
### Integração ✅
|
|
185
|
-
|
|
186
|
-
- ✅ **Gerado por `palette-kit build`**: Integração em `src/cli.ts` correta
|
|
187
|
-
- ✅ **Core continua aceitando `string`**: Não quebra API existente
|
|
188
|
-
- ✅ **Types são optional enhancement**: Usuário pode ignorar
|
|
189
|
-
|
|
190
|
-
**Evidência da integração**:
|
|
191
|
-
|
|
192
|
-
```typescript
|
|
193
|
-
// src/cli.ts linha 67-71
|
|
194
|
-
const writeTokensCodegen = async (outDir: string, registry: typeof minimalUiTokens) => {
|
|
195
|
-
const generated = generateTokenArtifacts(registry);
|
|
196
|
-
await writeFile(join(outDir, "tokens.ts"), generated.tokensTs, "utf8");
|
|
197
|
-
await writeFile(join(outDir, "tokens.d.ts"), generated.tokensDts, "utf8");
|
|
198
|
-
return generated.tokenNames;
|
|
199
|
-
};
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
---
|
|
203
|
-
|
|
204
|
-
### Testes ✅
|
|
205
|
-
|
|
206
|
-
- ✅ **Codegen de preset simples**: Registry com 3 tokens testado
|
|
207
|
-
- ✅ **Validação de types gerados**: Snapshots garantem output
|
|
208
|
-
- ✅ **Determinismo**: Teste com ordem shuffled
|
|
209
|
-
|
|
210
|
-
**Testes presentes**:
|
|
211
|
-
|
|
212
|
-
1. `generates navigable tokens.ts and tokens.d.ts` → valida estrutura
|
|
213
|
-
2. `is deterministic regardless of registry object order` → valida determinismo
|
|
214
|
-
|
|
215
|
-
**Sugestão de teste adicional**:
|
|
216
|
-
|
|
217
|
-
```typescript
|
|
218
|
-
it("handles tokens with reserved JS keywords", () => {
|
|
219
|
-
const registry: TokenRegistry = {
|
|
220
|
-
tokens: {
|
|
221
|
-
"control.default": {
|
|
222
|
-
name: "control.default",
|
|
223
|
-
description: "Default control.",
|
|
224
|
-
category: "control",
|
|
225
|
-
query: { role: "control.default" },
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
const { tokensTs } = generateTokenArtifacts(registry);
|
|
231
|
-
// 'default' é palavra reservada, deve ser quoted
|
|
232
|
-
expect(tokensTs).toContain('"default": "control.default"');
|
|
233
|
-
});
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
---
|
|
237
|
-
|
|
238
|
-
## ⚠️ SUGESTÕES DE MELHORIA (Não bloqueantes)
|
|
239
|
-
|
|
240
|
-
### 1. JSDoc completo no type `GeneratedTokens`
|
|
241
|
-
|
|
242
|
-
**Localização**: `src/cli/codegen/tokens.ts` linha 154
|
|
243
|
-
|
|
244
|
-
**Código atual**:
|
|
245
|
-
|
|
246
|
-
```typescript
|
|
247
|
-
export type GeneratedTokens = {
|
|
248
|
-
tokenNames: string[];
|
|
249
|
-
tokensTs: string;
|
|
250
|
-
tokensDts: string;
|
|
251
|
-
};
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
**Sugestão**:
|
|
255
|
-
|
|
256
|
-
```typescript
|
|
257
|
-
/**
|
|
258
|
-
* Result of token artifact generation.
|
|
259
|
-
*
|
|
260
|
-
* Contains TypeScript source code for tokens.ts and tokens.d.ts,
|
|
261
|
-
* plus a sorted list of all token names.
|
|
262
|
-
*/
|
|
263
|
-
export type GeneratedTokens = {
|
|
264
|
-
/** Sorted array of all token names from the registry. */
|
|
265
|
-
tokenNames: string[];
|
|
266
|
-
/** TypeScript source code for tokens.ts (runtime export). */
|
|
267
|
-
tokensTs: string;
|
|
268
|
-
/** TypeScript declaration file source for tokens.d.ts. */
|
|
269
|
-
tokensDts: string;
|
|
270
|
-
};
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
---
|
|
274
|
-
|
|
275
|
-
### 2. Documentar comportamento de segmentos vazios
|
|
276
|
-
|
|
277
|
-
**Localização**: `src/cli/codegen/tokens.ts` linha 85
|
|
278
|
-
|
|
279
|
-
**Código atual**:
|
|
280
|
-
|
|
281
|
-
```typescript
|
|
282
|
-
const segments = tokenName.split(".").filter(Boolean);
|
|
283
|
-
if (segments.length === 0) continue;
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
**Sugestão**: Adicionar comentário explicativo
|
|
287
|
-
|
|
288
|
-
```typescript
|
|
289
|
-
// Skip empty token names (e.g., "", ".", "..")
|
|
290
|
-
const segments = tokenName.split(".").filter(Boolean);
|
|
291
|
-
if (segments.length === 0) continue;
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
---
|
|
295
|
-
|
|
296
|
-
### 3. Teste para palavras reservadas do JS
|
|
297
|
-
|
|
298
|
-
**Motivação**: O código trata palavras reservadas com `RESERVED_WORDS`, mas não há teste específico.
|
|
299
|
-
|
|
300
|
-
**Sugestão**:
|
|
301
|
-
|
|
302
|
-
```typescript
|
|
303
|
-
it("quotes reserved JavaScript keywords", () => {
|
|
304
|
-
const registry: TokenRegistry = {
|
|
305
|
-
tokens: {
|
|
306
|
-
"control.default": {
|
|
307
|
-
name: "control.default",
|
|
308
|
-
description: "Default control.",
|
|
309
|
-
category: "control",
|
|
310
|
-
query: { role: "control.default" },
|
|
311
|
-
},
|
|
312
|
-
"state.return": {
|
|
313
|
-
name: "state.return",
|
|
314
|
-
description: "Return state.",
|
|
315
|
-
category: "state",
|
|
316
|
-
query: { role: "state.return" },
|
|
317
|
-
},
|
|
318
|
-
},
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
const { tokensTs, tokensDts } = generateTokenArtifacts(registry);
|
|
322
|
-
|
|
323
|
-
// 'default' e 'return' são palavras reservadas
|
|
324
|
-
expect(tokensTs).toContain('"default": "control.default"');
|
|
325
|
-
expect(tokensTs).toContain('"return": "state.return"');
|
|
326
|
-
expect(tokensDts).toContain('"default": "control.default"');
|
|
327
|
-
expect(tokensDts).toContain('"return": "state.return"');
|
|
328
|
-
});
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
---
|
|
332
|
-
|
|
333
|
-
### 4. Validação de tree-shaking
|
|
334
|
-
|
|
335
|
-
**Motivação**: Checklist menciona "Tree-shaking funcional" mas não há teste.
|
|
336
|
-
|
|
337
|
-
**Sugestão**: Adicionar teste que valida que tokens não usados podem ser eliminados.
|
|
338
|
-
|
|
339
|
-
```typescript
|
|
340
|
-
it("generates tree-shakeable structure", () => {
|
|
341
|
-
const { tokensTs } = generateTokenArtifacts(registry);
|
|
342
|
-
|
|
343
|
-
// Cada token deve ser uma propriedade independente
|
|
344
|
-
// Não deve haver dependencies entre tokens
|
|
345
|
-
expect(tokensTs).toContain('app: "bg.app"');
|
|
346
|
-
expect(tokensTs).toContain('primary: "text.primary"');
|
|
347
|
-
|
|
348
|
-
// Estrutura deve permitir destructuring
|
|
349
|
-
expect(tokensTs).toContain('export const tokens =');
|
|
350
|
-
expect(tokensTs).toContain('as const');
|
|
351
|
-
});
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
---
|
|
355
|
-
|
|
356
|
-
## 🎯 CHECKLIST FINAL
|
|
357
|
-
|
|
358
|
-
### Critérios Gerais
|
|
359
|
-
|
|
360
|
-
- ✅ Contratos e tipos (com sugestão de JSDoc)
|
|
361
|
-
- ✅ Qualidade de código
|
|
362
|
-
- ✅ DX (com sugestão de exemplo)
|
|
363
|
-
- ✅ Princípios v0.3
|
|
364
|
-
|
|
365
|
-
### Critérios Fase 7
|
|
366
|
-
|
|
367
|
-
- ✅ Outputs (`tokens.ts`, `tokens.d.ts`, unions)
|
|
368
|
-
- ✅ Autocomplete (navegação, unions, JSDoc, IDE-compatible)
|
|
369
|
-
- ✅ Performance (zero runtime, tree-shaking não testado)
|
|
370
|
-
- ✅ Integração (`palette-kit build`, core independente)
|
|
371
|
-
- ✅ Testes (preset simples, determinismo)
|
|
372
|
-
|
|
373
|
-
### O que NÃO deve acontecer ✅
|
|
374
|
-
|
|
375
|
-
- ✅ Runtime NÃO acoplado a types gerados
|
|
376
|
-
- ✅ Types NÃO são obrigatórios
|
|
377
|
-
- ✅ Codegen NÃO quebra tree-shaking
|
|
378
|
-
|
|
379
|
-
---
|
|
380
|
-
|
|
381
|
-
## 📊 VEREDICTO FINAL
|
|
382
|
-
|
|
383
|
-
**Status**: ✅ **APROVADO PARA MERGE**
|
|
384
|
-
|
|
385
|
-
**Implementação sólida** que:
|
|
386
|
-
|
|
387
|
-
- Atende todos os critérios obrigatórios da Fase 7
|
|
388
|
-
- Possui testes com snapshots
|
|
389
|
-
- É determinística e bem estruturada
|
|
390
|
-
- Integra corretamente com CLI
|
|
391
|
-
|
|
392
|
-
**Sugestões para PR futuro** (não bloqueantes):
|
|
393
|
-
|
|
394
|
-
1. Adicionar JSDoc completo em `GeneratedTokens`
|
|
395
|
-
2. Teste específico para palavras reservadas JS
|
|
396
|
-
3. Validação de tree-shaking com bundler real
|
|
397
|
-
4. Comentário sobre segmentos vazios
|
|
398
|
-
|
|
399
|
-
**Parabéns pela implementação limpa e bem testada!** 🎉
|
|
400
|
-
|
|
401
|
-
---
|
|
402
|
-
|
|
403
|
-
## 📚 Referências
|
|
404
|
-
|
|
405
|
-
- Guia de revisão: `.github/skills/review-guide/references/review-guide-v0.3.md`
|
|
406
|
-
- Fase 7 checklist: Linhas 388-438 do guia
|
|
407
|
-
- Arquivos revisados:
|
|
408
|
-
|
|
409
|
-
- `src/cli/codegen/tokens.ts` (191 linhas)
|
|
410
|
-
- `src/cli/codegen/tokens.test.ts` (61 linhas)
|
|
411
|
-
- `src/cli.ts` (integração)
|