@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.
Files changed (312) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +80 -87
  3. package/dist/contrast/contrast.d.ts +16 -0
  4. package/dist/contrast/contrast.js +102 -0
  5. package/dist/core/intent-registry.d.ts +11 -0
  6. package/dist/core/intent-registry.js +70 -0
  7. package/dist/core/oklch.d.ts +16 -0
  8. package/dist/core/oklch.js +56 -0
  9. package/dist/create-palette-kit.d.ts +9 -0
  10. package/dist/create-palette-kit.js +67 -0
  11. package/dist/engine/context/context.d.ts +13 -0
  12. package/dist/engine/context/context.js +37 -0
  13. package/dist/engine/level/curves.d.ts +17 -0
  14. package/dist/engine/level/curves.js +49 -0
  15. package/dist/engine/level/level.d.ts +4 -0
  16. package/dist/engine/level/level.js +13 -0
  17. package/dist/engine/relation/relation.d.ts +105 -0
  18. package/dist/engine/relation/relation.js +137 -0
  19. package/dist/engine/resolve/resolve.d.ts +36 -0
  20. package/dist/engine/resolve/resolve.js +116 -0
  21. package/dist/engine/state/state.d.ts +46 -0
  22. package/dist/engine/state/state.js +68 -0
  23. package/dist/engine/usage/fill.d.ts +9 -0
  24. package/dist/engine/usage/fill.js +9 -0
  25. package/dist/engine/usage/lines.d.ts +9 -0
  26. package/dist/engine/usage/lines.js +9 -0
  27. package/dist/engine/usage/overlays.d.ts +9 -0
  28. package/dist/engine/usage/overlays.js +9 -0
  29. package/dist/engine/usage/strategy.d.ts +56 -0
  30. package/dist/engine/usage/strategy.js +30 -0
  31. package/dist/engine/usage/visualVocabulary.d.ts +9 -0
  32. package/dist/engine/usage/visualVocabulary.js +9 -0
  33. package/dist/export/serialize.d.ts +14 -0
  34. package/dist/export/serialize.js +89 -0
  35. package/dist/export/types.d.ts +37 -0
  36. package/dist/export/types.js +31 -0
  37. package/dist/index.d.ts +3 -3
  38. package/dist/index.js +2 -2
  39. package/dist/operators/convert.d.ts +32 -0
  40. package/dist/operators/convert.js +80 -0
  41. package/dist/presets/presets.d.ts +95 -0
  42. package/dist/presets/presets.js +308 -0
  43. package/dist/types/index.d.ts +111 -187
  44. package/dist/utils/errors/errors.d.ts +17 -0
  45. package/dist/utils/errors/errors.js +22 -0
  46. package/docs/API.md +167 -0
  47. package/docs/Alpha.md +14 -0
  48. package/docs/Architecture.md +56 -0
  49. package/docs/CLI.md +22 -0
  50. package/docs/Concepts.md +73 -0
  51. package/docs/Config.md +144 -0
  52. package/docs/Diagnostics.md +22 -0
  53. package/docs/Exporters.md +33 -0
  54. package/docs/FAQ.md +59 -0
  55. package/docs/Migration.md +61 -0
  56. package/docs/Overlays.md +33 -0
  57. package/docs/README.md +60 -0
  58. package/docs/Text.md +41 -0
  59. package/docs/Tokens.md +42 -0
  60. package/docs/Usage-JSON.md +39 -0
  61. package/docs/Usage-ReactNative.md +63 -0
  62. package/docs/Usage-Web.md +66 -0
  63. package/docs/Validation.md +97 -0
  64. package/docs/Why.md +37 -0
  65. package/docs/_api-surface.md +53 -0
  66. package/docs/snippets/serialize-oklch.md +9 -0
  67. package/docs/spec.md +98 -0
  68. package/package.json +74 -59
  69. package/.codex/skills/color-pipeline-implementer/SKILL.md +0 -23
  70. package/.codex/skills/commit-message-crafter/SKILL.md +0 -63
  71. package/.codex/skills/commit-message-crafter/references/benchmarks.md +0 -20
  72. package/.codex/skills/contrast-solver-helper/SKILL.md +0 -20
  73. package/.codex/skills/exporters-builder/SKILL.md +0 -20
  74. package/.codex/skills/markdownlint-writer/SKILL.md +0 -32
  75. package/.codex/skills/phase-implementation-runbook/SKILL.md +0 -92
  76. package/.codex/skills/type-contract-auditor/SKILL.md +0 -21
  77. package/.github/skills/review-guide/SKILL.md +0 -23
  78. package/.github/skills/review-guide/references/review-guide-v0.3.md +0 -629
  79. package/.markdownlint.json +0 -4
  80. package/AGENTS.md +0 -16
  81. package/biome.json +0 -43
  82. package/dist/cli/args.d.ts +0 -12
  83. package/dist/cli/args.js +0 -56
  84. package/dist/cli/args.test.d.ts +0 -1
  85. package/dist/cli/args.test.js +0 -22
  86. package/dist/cli/codegen/__snapshots__/tokens.test.js.snap +0 -87
  87. package/dist/cli/codegen/tokens.d.ts +0 -12
  88. package/dist/cli/codegen/tokens.js +0 -139
  89. package/dist/cli/codegen/tokens.test.d.ts +0 -1
  90. package/dist/cli/codegen/tokens.test.js +0 -51
  91. package/dist/cli/config.d.ts +0 -40
  92. package/dist/cli/config.js +0 -34
  93. package/dist/cli/validate.d.ts +0 -2
  94. package/dist/cli/validate.js +0 -33
  95. package/dist/cli/validate.test.d.ts +0 -1
  96. package/dist/cli/validate.test.js +0 -40
  97. package/dist/cli.d.ts +0 -2
  98. package/dist/cli.js +0 -148
  99. package/dist/contrast/apca.d.ts +0 -2
  100. package/dist/contrast/apca.js +0 -15
  101. package/dist/contrast/apca.test.d.ts +0 -1
  102. package/dist/contrast/apca.test.js +0 -16
  103. package/dist/contrast/index.d.ts +0 -4
  104. package/dist/contrast/index.js +0 -4
  105. package/dist/contrast/scoring.d.ts +0 -4
  106. package/dist/contrast/scoring.js +0 -31
  107. package/dist/contrast/scoring.test.d.ts +0 -1
  108. package/dist/contrast/scoring.test.js +0 -148
  109. package/dist/contrast/solver.d.ts +0 -13
  110. package/dist/contrast/solver.js +0 -170
  111. package/dist/contrast/solver.test.d.ts +0 -1
  112. package/dist/contrast/solver.test.js +0 -75
  113. package/dist/contrast/types.d.ts +0 -17
  114. package/dist/contrast/types.js +0 -1
  115. package/dist/contrast/utils.d.ts +0 -4
  116. package/dist/contrast/utils.js +0 -18
  117. package/dist/contrast/wcag2.d.ts +0 -3
  118. package/dist/contrast/wcag2.js +0 -19
  119. package/dist/contrast/wcag2.test.d.ts +0 -1
  120. package/dist/contrast/wcag2.test.js +0 -17
  121. package/dist/core/createTheme.d.ts +0 -35
  122. package/dist/core/createTheme.js +0 -24
  123. package/dist/core/dx-helpers.test.d.ts +0 -1
  124. package/dist/core/dx-helpers.test.js +0 -61
  125. package/dist/core/index.d.ts +0 -2
  126. package/dist/core/index.js +0 -2
  127. package/dist/core/onSolid.test.d.ts +0 -1
  128. package/dist/core/onSolid.test.js +0 -118
  129. package/dist/core/qa.v1.test.d.ts +0 -1
  130. package/dist/core/qa.v1.test.js +0 -112
  131. package/dist/core/resolve.d.ts +0 -3
  132. package/dist/core/resolve.js +0 -8
  133. package/dist/core/resolve.test.d.ts +0 -1
  134. package/dist/core/resolve.test.js +0 -89
  135. package/dist/core/resolveMany.d.ts +0 -8
  136. package/dist/core/resolveMany.js +0 -17
  137. package/dist/core/tokenRegistry.d.ts +0 -23
  138. package/dist/core/tokenRegistry.js +0 -83
  139. package/dist/core/tokenRegistry.test.d.ts +0 -1
  140. package/dist/core/tokenRegistry.test.js +0 -133
  141. package/dist/engine/applyOperators.d.ts +0 -3
  142. package/dist/engine/applyOperators.js +0 -23
  143. package/dist/engine/context.d.ts +0 -4
  144. package/dist/engine/context.js +0 -1
  145. package/dist/engine/gamut.d.ts +0 -13
  146. package/dist/engine/gamut.js +0 -101
  147. package/dist/engine/gamut.test.d.ts +0 -1
  148. package/dist/engine/gamut.test.js +0 -23
  149. package/dist/engine/generateScale.d.ts +0 -15
  150. package/dist/engine/generateScale.js +0 -29
  151. package/dist/engine/generateScale.test.d.ts +0 -1
  152. package/dist/engine/generateScale.test.js +0 -32
  153. package/dist/engine/index.d.ts +0 -8
  154. package/dist/engine/index.js +0 -4
  155. package/dist/engine/normalize.d.ts +0 -43
  156. package/dist/engine/normalize.js +0 -403
  157. package/dist/engine/normalize.test.d.ts +0 -1
  158. package/dist/engine/normalize.test.js +0 -136
  159. package/dist/engine/onSolid.d.ts +0 -3
  160. package/dist/engine/onSolid.js +0 -110
  161. package/dist/engine/resolveBaseColor.d.ts +0 -25
  162. package/dist/engine/resolveBaseColor.js +0 -127
  163. package/dist/engine/resolveBaseColor.test.d.ts +0 -1
  164. package/dist/engine/resolveBaseColor.test.js +0 -97
  165. package/dist/export/__snapshots__/exportTheme.test.js.snap +0 -74
  166. package/dist/export/exportTheme.d.ts +0 -47
  167. package/dist/export/exportTheme.js +0 -170
  168. package/dist/export/exportTheme.test.d.ts +0 -1
  169. package/dist/export/exportTheme.test.js +0 -118
  170. package/dist/export/index.d.ts +0 -1
  171. package/dist/export/index.js +0 -1
  172. package/dist/export/serializeColor.d.ts +0 -1
  173. package/dist/export/serializeColor.js +0 -1
  174. package/dist/export/serializeColor.test.d.ts +0 -1
  175. package/dist/export/serializeColor.test.js +0 -54
  176. package/dist/export.d.ts +0 -1
  177. package/dist/export.js +0 -1
  178. package/dist/operators/emphasis.d.ts +0 -3
  179. package/dist/operators/emphasis.js +0 -113
  180. package/dist/operators/emphasis.test.d.ts +0 -1
  181. package/dist/operators/emphasis.test.js +0 -69
  182. package/dist/operators/index.d.ts +0 -3
  183. package/dist/operators/index.js +0 -2
  184. package/dist/operators/state.d.ts +0 -3
  185. package/dist/operators/state.js +0 -102
  186. package/dist/operators/state.test.d.ts +0 -1
  187. package/dist/operators/state.test.js +0 -48
  188. package/dist/operators/types.d.ts +0 -13
  189. package/dist/operators/types.js +0 -1
  190. package/dist/operators/utils.d.ts +0 -16
  191. package/dist/operators/utils.js +0 -23
  192. package/dist/presets/curves.d.ts +0 -28
  193. package/dist/presets/curves.js +0 -145
  194. package/dist/presets/index.d.ts +0 -2
  195. package/dist/presets/index.js +0 -1
  196. package/dist/presets/tokens/index.d.ts +0 -3
  197. package/dist/presets/tokens/index.js +0 -3
  198. package/dist/presets/tokens/minimal-ui.d.ts +0 -6
  199. package/dist/presets/tokens/minimal-ui.js +0 -53
  200. package/dist/presets/tokens/modern-ui.d.ts +0 -5
  201. package/dist/presets/tokens/modern-ui.js +0 -83
  202. package/dist/presets/tokens/presets.test.d.ts +0 -1
  203. package/dist/presets/tokens/presets.test.js +0 -31
  204. package/dist/presets/tokens/radixLike-ui.d.ts +0 -6
  205. package/dist/presets/tokens/radixLike-ui.js +0 -77
  206. package/dist/serialize/index.d.ts +0 -1
  207. package/dist/serialize/index.js +0 -1
  208. package/dist/serialize/normalizeOutput.d.ts +0 -6
  209. package/dist/serialize/normalizeOutput.js +0 -45
  210. package/dist/serialize/serializeColor.d.ts +0 -21
  211. package/dist/serialize/serializeColor.js +0 -178
  212. package/dist/serialize/serializeResolved.test.d.ts +0 -1
  213. package/dist/serialize/serializeResolved.test.js +0 -45
  214. package/dist/serialize.d.ts +0 -1
  215. package/dist/serialize.js +0 -1
  216. package/dist/utils/clamp.d.ts +0 -1
  217. package/dist/utils/clamp.js +0 -1
  218. package/dist/utils/index.d.ts +0 -1
  219. package/dist/utils/index.js +0 -1
  220. package/dist/utils/lerp.d.ts +0 -1
  221. package/dist/utils/lerp.js +0 -1
  222. package/dist/utils/parseColor.d.ts +0 -6
  223. package/dist/utils/parseColor.js +0 -67
  224. package/dist/utils/parseColor.test.d.ts +0 -1
  225. package/dist/utils/parseColor.test.js +0 -51
  226. package/dist/utils/smoothstep.d.ts +0 -1
  227. package/dist/utils/smoothstep.js +0 -5
  228. package/planning/phase-10-review.md +0 -550
  229. package/planning/phase-7-review.md +0 -411
  230. package/planning/phase-8-review.md +0 -669
  231. package/planning/phase-9-review.md +0 -564
  232. package/planning/roadmap-v0.3.md +0 -284
  233. package/planning/spec-serializer-v0.3.md +0 -324
  234. package/planning/spec-v0.3.md +0 -305
  235. package/src/cli/args.test.ts +0 -28
  236. package/src/cli/args.ts +0 -66
  237. package/src/cli/codegen/__snapshots__/tokens.test.ts.snap +0 -87
  238. package/src/cli/codegen/tokens.test.ts +0 -61
  239. package/src/cli/codegen/tokens.ts +0 -191
  240. package/src/cli/config.ts +0 -71
  241. package/src/cli/validate.test.ts +0 -49
  242. package/src/cli/validate.ts +0 -38
  243. package/src/cli.ts +0 -183
  244. package/src/contrast/apca.test.ts +0 -20
  245. package/src/contrast/apca.ts +0 -26
  246. package/src/contrast/index.ts +0 -4
  247. package/src/contrast/scoring.test.ts +0 -188
  248. package/src/contrast/scoring.ts +0 -48
  249. package/src/contrast/solver.test.ts +0 -147
  250. package/src/contrast/solver.ts +0 -235
  251. package/src/contrast/types.ts +0 -20
  252. package/src/contrast/utils.ts +0 -28
  253. package/src/contrast/wcag2.test.ts +0 -21
  254. package/src/contrast/wcag2.ts +0 -24
  255. package/src/core/createTheme.ts +0 -78
  256. package/src/core/dx-helpers.test.ts +0 -82
  257. package/src/core/index.ts +0 -7
  258. package/src/core/onSolid.test.ts +0 -146
  259. package/src/core/qa.v1.test.ts +0 -149
  260. package/src/core/resolve.test.ts +0 -99
  261. package/src/core/resolve.ts +0 -11
  262. package/src/core/resolveMany.ts +0 -22
  263. package/src/core/tokenRegistry.test.ts +0 -153
  264. package/src/core/tokenRegistry.ts +0 -114
  265. package/src/engine/applyOperators.ts +0 -32
  266. package/src/engine/context.ts +0 -8
  267. package/src/engine/gamut.test.ts +0 -30
  268. package/src/engine/gamut.ts +0 -144
  269. package/src/engine/generateScale.test.ts +0 -46
  270. package/src/engine/generateScale.ts +0 -48
  271. package/src/engine/index.ts +0 -8
  272. package/src/engine/normalize.test.ts +0 -222
  273. package/src/engine/normalize.ts +0 -550
  274. package/src/engine/onSolid.ts +0 -178
  275. package/src/engine/resolveBaseColor.test.ts +0 -117
  276. package/src/engine/resolveBaseColor.ts +0 -203
  277. package/src/export/__snapshots__/exportTheme.test.ts.snap +0 -74
  278. package/src/export/exportTheme.test.ts +0 -144
  279. package/src/export/exportTheme.ts +0 -251
  280. package/src/export/index.ts +0 -1
  281. package/src/export/serializeColor.test.ts +0 -73
  282. package/src/export/serializeColor.ts +0 -1
  283. package/src/export.ts +0 -1
  284. package/src/index.ts +0 -3
  285. package/src/operators/emphasis.test.ts +0 -85
  286. package/src/operators/emphasis.ts +0 -132
  287. package/src/operators/index.ts +0 -3
  288. package/src/operators/state.test.ts +0 -66
  289. package/src/operators/state.ts +0 -122
  290. package/src/operators/types.ts +0 -14
  291. package/src/operators/utils.ts +0 -44
  292. package/src/presets/curves.ts +0 -168
  293. package/src/presets/index.ts +0 -2
  294. package/src/presets/tokens/index.ts +0 -3
  295. package/src/presets/tokens/minimal-ui.ts +0 -55
  296. package/src/presets/tokens/modern-ui.ts +0 -85
  297. package/src/presets/tokens/presets.test.ts +0 -46
  298. package/src/presets/tokens/radixLike-ui.ts +0 -79
  299. package/src/serialize/index.ts +0 -1
  300. package/src/serialize/normalizeOutput.ts +0 -63
  301. package/src/serialize/serializeColor.ts +0 -260
  302. package/src/serialize/serializeResolved.test.ts +0 -57
  303. package/src/serialize.ts +0 -1
  304. package/src/types/index.ts +0 -207
  305. package/src/utils/clamp.ts +0 -2
  306. package/src/utils/index.ts +0 -1
  307. package/src/utils/lerp.ts +0 -1
  308. package/src/utils/parseColor.test.ts +0 -66
  309. package/src/utils/parseColor.ts +0 -87
  310. package/src/utils/smoothstep.ts +0 -6
  311. package/tsconfig.build.json +0 -11
  312. package/tsconfig.json +0 -15
@@ -1,67 +0,0 @@
1
- import { converter } from "culori";
2
- const hexPattern = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
3
- const toOklch = converter("oklch");
4
- const OKLCH_L_MAX = 100;
5
- const OKLCH_H_MAX = 360;
6
- const MAX_OKLCH_CHROMA = 0.4;
7
- const NEGATIVE_CHROMA_EPSILON = 1e-6;
8
- const toChannel = (hex) => Number.parseInt(hex, 16) / 255;
9
- const normalizeHue = (hue) => ((hue % OKLCH_H_MAX) + OKLCH_H_MAX) % OKLCH_H_MAX;
10
- const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
11
- export function parseColor(input) {
12
- const normalizedInput = input.trim();
13
- if (!hexPattern.test(normalizedInput)) {
14
- throw new Error(`Invalid color input: "${input}"`);
15
- }
16
- const hex = normalizedInput.slice(1);
17
- let r = 0;
18
- let g = 0;
19
- let b = 0;
20
- let alpha = 1;
21
- if (hex.length === 3) {
22
- r = toChannel(`${hex[0]}${hex[0]}`);
23
- g = toChannel(`${hex[1]}${hex[1]}`);
24
- b = toChannel(`${hex[2]}${hex[2]}`);
25
- }
26
- else if (hex.length === 6 || hex.length === 8) {
27
- r = toChannel(hex.slice(0, 2));
28
- g = toChannel(hex.slice(2, 4));
29
- b = toChannel(hex.slice(4, 6));
30
- if (hex.length === 8) {
31
- alpha = toChannel(hex.slice(6, 8));
32
- }
33
- }
34
- else {
35
- throw new Error(`Invalid hex length: "${normalizedInput}"`);
36
- }
37
- const oklchValue = toOklch({ mode: "rgb", r, g, b });
38
- if (!oklchValue) {
39
- throw new Error(`Unable to convert color input: "${normalizedInput}" (r=${r}, g=${g}, b=${b})`);
40
- }
41
- const l = typeof oklchValue.l === "number" && Number.isFinite(oklchValue.l) ? oklchValue.l : 0;
42
- const c = typeof oklchValue.c === "number" && Number.isFinite(oklchValue.c) ? oklchValue.c : 0;
43
- const h = typeof oklchValue.h === "number" && Number.isFinite(oklchValue.h) ? oklchValue.h : 0;
44
- const scaledLightness = l * 100;
45
- if (c < -NEGATIVE_CHROMA_EPSILON) {
46
- throw new Error(`Invalid OKLCH chroma value: ${c} for "${input}"`);
47
- }
48
- const okLch = {
49
- space: "oklch",
50
- channels: [
51
- clamp(scaledLightness, 0, OKLCH_L_MAX),
52
- clamp(Math.max(0, c), 0, MAX_OKLCH_CHROMA),
53
- normalizeHue(h),
54
- ],
55
- alpha,
56
- };
57
- const srgb = {
58
- space: "srgb",
59
- channels: [r, g, b],
60
- alpha,
61
- };
62
- return {
63
- input: normalizedInput,
64
- okLch,
65
- srgb,
66
- };
67
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,51 +0,0 @@
1
- import { describe, expect, it, vi } from "vitest";
2
- import { parseColor } from "./parseColor.js";
3
- describe("parseColor", () => {
4
- it("parses #fff with alpha 1", () => {
5
- const result = parseColor("#fff");
6
- expect(result.input).toBe("#fff");
7
- expect(result.srgb.space).toBe("srgb");
8
- expect(result.srgb.alpha).toBe(1);
9
- expect(result.srgb.channels[0]).toBeCloseTo(1, 6);
10
- expect(result.srgb.channels[1]).toBeCloseTo(1, 6);
11
- expect(result.srgb.channels[2]).toBeCloseTo(1, 6);
12
- });
13
- it("parses #112233", () => {
14
- const result = parseColor("#112233");
15
- expect(result.srgb.channels[0]).toBeCloseTo(0x11 / 255, 6);
16
- expect(result.srgb.channels[1]).toBeCloseTo(0x22 / 255, 6);
17
- expect(result.srgb.channels[2]).toBeCloseTo(0x33 / 255, 6);
18
- expect(result.srgb.alpha).toBe(1);
19
- });
20
- it("parses #11223380 with alpha", () => {
21
- const result = parseColor("#11223380");
22
- expect(result.srgb.alpha).toBeCloseTo(0x80 / 255, 3);
23
- });
24
- it("normalizes okLch channels", () => {
25
- const result = parseColor("#ffffff");
26
- const [l, c, h] = result.okLch.channels;
27
- expect(result.okLch.space).toBe("oklch");
28
- expect(result.okLch.alpha).toBe(1);
29
- expect(l).toBeGreaterThanOrEqual(0);
30
- expect(l).toBeLessThanOrEqual(100);
31
- expect(c).toBeGreaterThanOrEqual(0);
32
- expect(h).toBeGreaterThanOrEqual(0);
33
- expect(h).toBeLessThan(360);
34
- });
35
- it("preserves okLch alpha", () => {
36
- const result = parseColor("#33669980");
37
- expect(result.okLch.alpha).toBeCloseTo(0x80 / 255, 3);
38
- });
39
- it("throws on invalid input", () => {
40
- expect(() => parseColor("#12")).toThrowError(/#12/);
41
- expect(() => parseColor("#GGGGGG")).toThrowError(/#GGGGGG/);
42
- });
43
- it("includes rgb values when conversion fails", async () => {
44
- vi.resetModules();
45
- vi.doMock("culori", () => ({
46
- converter: () => () => undefined,
47
- }));
48
- const { parseColor: mockedParseColor } = await import("./parseColor.js");
49
- expect(() => mockedParseColor("#ffffff")).toThrowError(/r=1, g=1, b=1/);
50
- });
51
- });
@@ -1 +0,0 @@
1
- export declare const smoothstep: (t: number) => number;
@@ -1,5 +0,0 @@
1
- import { clamp } from "./clamp.js";
2
- export const smoothstep = (t) => {
3
- const x = clamp(t, 0, 1);
4
- return x * x * (3 - 2 * x);
5
- };
@@ -1,550 +0,0 @@
1
- # Revisão Fase 10 — QA Final e Release v0.3.0
2
-
3
- **Data**: 18 de janeiro de 2026
4
- **Revisor**: GitHub Copilot (usando review-guide-v0.3.md)
5
- **Status**: ✅ **APROVADO PARA RELEASE**
6
-
7
- ---
8
-
9
- ## 📋 Resumo Executivo
10
-
11
- A implementação da Fase 10 (QA final e release) está **completa e pronta para publicação**. O código:
12
-
13
- - ✅ Todos os 252 testes passando (46 arquivos de teste)
14
- - ✅ Build limpo sem erros TypeScript
15
- - ✅ Changelog completo e bem estruturado
16
- - ✅ Migration guide criado (`docs/Migration.md`)
17
- - ✅ Versão bumped corretamente (0.2.0 → 0.3.0)
18
- - ✅ Roadmap atualizado (todas as tarefas marcadas)
19
-
20
- **Nenhuma correção necessária**. Release v0.3.0 está pronto.
21
-
22
- **Próximos passos sugeridos**:
23
-
24
- 1. Git tag: `git tag v0.3.0`
25
- 2. Dry-run: `npm publish --dry-run`
26
- 3. Publicar: `npm publish`
27
- 4. GitHub release com changelog
28
-
29
- ---
30
-
31
- ## ✅ CRITÉRIOS GERAIS (Todos aprovados)
32
-
33
- ### 1. Contratos e tipos ✅
34
-
35
- - ✅ **Build limpo**: Sem erros TypeScript no workspace
36
- - ✅ **Exports válidos**: Todos os subpaths funcionais
37
- - ✅ **Types resolvidos**: `.d.ts` gerados corretamente
38
-
39
- **Evidência** (build output):
40
-
41
- ```bash
42
- > @clhaas/palette-kit@0.3.0 build
43
- > tsc -p tsconfig.build.json
44
- # ✅ Sem erros
45
- ```
46
-
47
- ---
48
-
49
- ### 2. Qualidade de código ✅
50
-
51
- - ✅ **252 testes passando** em 46 arquivos
52
- - ✅ **Snapshots validados**: exporters, codegen
53
- - ✅ **Sem regressões**: Todos os módulos testados
54
- - ✅ **Coverage abrangente**: core, engine, contrast, export, cli
55
-
56
- **Evidência** (test output):
57
-
58
- ```txt
59
- Test Files 46 passed (46)
60
- Tests 252 passed (252)
61
- Duration 1.45s
62
- ```
63
-
64
- **Distribuição de testes**:
65
-
66
- - Core: 28 tests (resolve, onSolid, dx-helpers, tokenRegistry, qa)
67
- - Engine: 40 tests (normalize, resolveBaseColor, gamut, generateScale)
68
- - Contrast: 25 tests (apca, wcag2, solver, scoring)
69
- - Export: 14 tests (exportTheme, serializeColor, serializeResolved)
70
- - CLI: 9 tests (args, validate, codegen)
71
- - Operators: 14 tests (state, emphasis)
72
- - Presets: 4 tests (token presets)
73
- - Utils: 7 tests (parseColor)
74
-
75
- ---
76
-
77
- ### 3. DX (Developer Experience) ✅
78
-
79
- - ✅ **Autocomplete funcional**: Types exportados corretamente
80
- - ✅ **Go-to-definition**: Subpath imports resolvem
81
- - ✅ **Hover docs**: JSDoc presente
82
- - ✅ **Sem erros**: Workspace limpo
83
-
84
- **Evidência**:
85
-
86
- ```bash
87
- # Nenhum erro no workspace
88
- $ get_errors
89
- > No errors found.
90
- ```
91
-
92
- ---
93
-
94
- ### 4. Documentação ✅
95
-
96
- - ✅ **Changelog atualizado**: v0.3.0 completo
97
- - ✅ **Migration guide criado**: `docs/Migration.md`
98
- - ✅ **README reflete v0.3**: Já atualizado na Fase 9
99
- - ✅ **Exemplos funcionam**: Todos os imports documentados
100
-
101
- ---
102
-
103
- ## ✅ CRITÉRIOS ESPECÍFICOS DA FASE 10
104
-
105
- ### Testes ✅
106
-
107
- #### Todos os testes unitários passam ✅
108
-
109
- **Evidência**: 252/252 testes passando
110
-
111
- **Cobertura por módulo**:
112
-
113
- - ✅ `src/core/*` - 28 tests
114
- - ✅ `src/engine/*` - 40 tests
115
- - ✅ `src/contrast/*` - 25 tests
116
- - ✅ `src/export/*` - 14 tests
117
- - ✅ `src/cli/*` - 9 tests
118
- - ✅ `src/operators/*` - 14 tests
119
- - ✅ `src/presets/*` - 4 tests
120
- - ✅ `src/utils/*` - 7 tests
121
- - ✅ `src/serialize/*` - 3 tests
122
-
123
- #### Snapshots atualizados e validados ✅
124
-
125
- **Evidência**:
126
-
127
- ```txt
128
- ✓ dist/export/exportTheme.test.js (7 tests) 17ms
129
- ✓ src/cli/codegen/tokens.test.ts (2 tests) 10ms
130
- ✓ dist/cli/codegen/tokens.test.js (2 tests) 13ms
131
- ```
132
-
133
- **Snapshots testados**:
134
-
135
- - Export: CSS/JSON output determinístico
136
- - Codegen: tokens.ts/tokens.d.ts estrutura
137
-
138
- #### Testes de integração ✅
139
-
140
- **Evidência**:
141
-
142
- ```txt
143
- ✓ src/presets/tokens/presets.test.ts (2 tests) 15ms
144
- ✓ src/core/qa.v1.test.ts (5 tests) 10ms
145
- ```
146
-
147
- **QA testes**: Validação end-to-end de themes
148
-
149
- #### Performance não regrediu ✅
150
-
151
- **Evidência**:
152
-
153
- ```txt
154
- Duration 1.45s (transform 1.23s, setup 0ms, import 3.75s, tests 413ms)
155
- ```
156
-
157
- **Tempo de execução razoável**: 1.45s para 252 testes (média ~6ms/teste)
158
-
159
- ---
160
-
161
- ### DX validation ✅
162
-
163
- #### Autocomplete funcional em VS Code ✅
164
-
165
- **Evidência**:
166
-
167
- - Types exportados: `dist/index.d.ts`, `dist/export.d.ts`, `dist/serialize.d.ts`, `dist/cli.d.ts`
168
- - Subpath exports com `"types"` definidos
169
- - Build TypeScript sem erros
170
-
171
- #### Hover docs aparecem ✅
172
-
173
- **Evidência**: JSDoc presente em funções públicas
174
-
175
- - `createTheme`: Documentado
176
- - `exportThemeCss`: Documentado
177
- - `serializeResolved`: Documentado
178
-
179
- #### Go-to-definition funciona ✅
180
-
181
- **Evidência**:
182
-
183
- - Source maps disponíveis
184
- - Types mapeados corretamente
185
- - Subpath imports resolvem
186
-
187
- #### Nenhum erro TypeScript no workspace ✅
188
-
189
- **Evidência**:
190
-
191
- ```bash
192
- $ get_errors
193
- > No errors found.
194
- ```
195
-
196
- ---
197
-
198
- ### Documentação ✅
199
-
200
- #### Changelog atualizado ✅
201
-
202
- **Evidência** (`CHANGELOG.md`):
203
-
204
- ```markdown
205
- ## v0.3.0
206
-
207
- ### Breaking changes
208
-
209
- - ESM-only package (`"type": "module"`), no `require()` support.
210
- - Public API is split into subpath exports:
211
- - `@clhaas/palette-kit` (runtime)
212
- - `@clhaas/palette-kit/serialize` (serializer)
213
- - `@clhaas/palette-kit/export` (exporters)
214
- - `@clhaas/palette-kit/cli` and bin `palette-kit` (CLI)
215
- - Exporters are not re-exported from the main entrypoint to keep the runtime lean and tree-shakeable.
216
-
217
- ### Features
218
-
219
- - Public serializer (`serializeColor`, `serializeResolved`, `theme.serialize`) with OKLCH/sRGB/P3 output options.
220
- - Public exporters: `exportThemeCss` (progressive `@supports` fallbacks) and `exportThemeJson` (stable `{ light, dark }` structure).
221
- - Declarative Token Registry + official token presets (`minimal-ui`, `radixLike-ui`, `modern-ui`).
222
- - CLI tooling:
223
- - `palette-kit init` (typed config template)
224
- - `palette-kit build` (deterministic `dist/palette/` artifacts: CSS/JSON/TS + d.ts)
225
- - Strong inference and DX validation improvements (strict vs non-strict behavior, clearer errors).
226
-
227
- ### Migration
228
-
229
- - See `docs/Migration.md` for upgrade notes and updated import paths.
230
- ```
231
-
232
- **Qualidade**:
233
-
234
- - ✅ Breaking changes bem documentados
235
- - ✅ Features listadas claramente
236
- - ✅ Link para migration guide
237
- - ✅ Estrutura clara (Breaking/Features/Migration)
238
-
239
- #### Migration guide completo ✅
240
-
241
- **Evidência** (`docs/Migration.md`):
242
-
243
- ```markdown
244
- # Migration Guide: v0.2 → v0.3
245
-
246
- ## Breaking changes
247
-
248
- ### Exporters moved to a public subpath
249
- import { exportThemeCss } from "@clhaas/palette-kit/export";
250
-
251
- ### Serializer is public via subpath
252
- import { serializeResolved } from "@clhaas/palette-kit/serialize";
253
-
254
- ### CLI is now functional
255
- palette-kit init
256
- palette-kit build
257
-
258
- ## Non-breaking additions
259
-
260
- - Token registry contracts
261
- - Codegen outputs for DX
262
- - Stronger inference and actionable strict-mode validation
263
- ```
264
-
265
- **Qualidade**:
266
-
267
- - ✅ Breaking changes explicados
268
- - ✅ Exemplos de código
269
- - ✅ Non-breaking additions listados
270
- - ✅ Links para documentação adicional
271
-
272
- #### README reflete v0.3 ✅
273
-
274
- **Status**: Já atualizado na Fase 9
275
-
276
- - ✅ Título: "runtime-first color engine"
277
- - ✅ Exemplos de todos os subpaths
278
- - ✅ Seções: Runtime, Serializer, Exporters, CLI
279
-
280
- #### Exemplos funcionam ✅
281
-
282
- **Evidência**: Todos os imports no README são válidos
283
-
284
- ```typescript
285
- import { createTheme } from "@clhaas/palette-kit";
286
- import { serializeResolved } from "@clhaas/palette-kit/serialize";
287
- import { exportThemeCss } from "@clhaas/palette-kit/export";
288
- ```
289
-
290
- **Validação**: Build passa, exports funcionais
291
-
292
- ---
293
-
294
- ### Pre-release ✅
295
-
296
- #### Versão bumped corretamente ✅
297
-
298
- **Evidência** (`package.json`):
299
-
300
- ```json
301
- {
302
- "name": "@clhaas/palette-kit",
303
- "version": "0.3.0", // ← Atualizado de 0.2.0
304
- }
305
- ```
306
-
307
- **Validação**: Segue semver (v0.2.0 → v0.3.0 por breaking changes)
308
-
309
- #### Git tags ⚠️
310
-
311
- **Status**: Não criado ainda (esperado antes do publish)
312
-
313
- **Ação sugerida**:
314
-
315
- ```bash
316
- git tag -a v0.3.0 -m "Release v0.3.0"
317
- git push origin v0.3.0
318
- ```
319
-
320
- #### Build CI verde ⚠️
321
-
322
- **Status**: Não verificável no diff (requer CI/CD pipeline)
323
-
324
- **Validação local**: Build e testes passando ✅
325
-
326
- **Ação sugerida**: Verificar CI/CD antes do publish (se configurado)
327
-
328
- #### Dry-run de publish OK ⚠️
329
-
330
- **Status**: Não executado ainda
331
-
332
- **Ação sugerida**:
333
-
334
- ```bash
335
- npm pack
336
- npm publish --dry-run
337
- ```
338
-
339
- **Expectativa**:
340
-
341
- - Pacote gerado com sucesso
342
- - Nenhum erro de permissão
343
- - Files incluídos corretos (dist/, README, LICENSE, etc.)
344
-
345
- ---
346
-
347
- ### Release ⚠️
348
-
349
- #### Publicado no npm ⚠️
350
-
351
- **Status**: Pendente (ação manual)
352
-
353
- **Ação sugerida**:
354
-
355
- ```bash
356
- npm publish
357
- ```
358
-
359
- #### GitHub release criado ⚠️
360
-
361
- **Status**: Pendente (ação manual)
362
-
363
- **Ação sugerida**: Criar release no GitHub com changelog v0.3.0
364
-
365
- #### Announcement preparado ⚠️
366
-
367
- **Status**: Opcional
368
-
369
- **Sugestão de announcement**:
370
-
371
- ```markdown
372
- # Palette Kit v0.3.0 Released! 🎉
373
-
374
- We're excited to announce v0.3.0 with major improvements:
375
-
376
- ## 🚀 Highlights
377
-
378
- - **Public serializer & exporters**: Build-time CSS/JSON generation
379
- - **CLI tooling**: `palette-kit init` & `palette-kit build`
380
- - **Token registry**: Declarative token definitions with official presets
381
- - **Strong inference**: Better DX with actionable errors
382
-
383
- ## 📦 Breaking Changes
384
-
385
- v0.3 is ESM-only and splits the API into subpaths for better tree-shaking:
386
-
387
- ```ts
388
- import { createTheme } from "@clhaas/palette-kit";
389
- import { exportThemeCss } from "@clhaas/palette-kit/export";
390
- import { serializeResolved } from "@clhaas/palette-kit/serialize";
391
- ```
392
-
393
- ## 📚 Migration
394
-
395
- See [Migration Guide](docs/Migration.md) for upgrade instructions.
396
-
397
- ## 🙏 Thanks
398
-
399
- Thanks to everyone who contributed feedback and testing!
400
-
401
- ---
402
-
403
- ## ✅ VALIDAÇÕES NEGATIVAS
404
-
405
- ### O que NÃO deve acontecer ✅
406
-
407
- - ✅ **Release com testes falhando**: Todos os 252 testes passando
408
- - ✅ **Documentação desatualizada**: Changelog + Migration guide completos
409
- - ✅ **Breaking changes não documentados**: Todos listados e explicados
410
- - ✅ **Versão errada**: 0.3.0 correto (semver)
411
-
412
- ---
413
-
414
- ## 🎯 CHECKLIST FINAL
415
-
416
- ### Testes (Checklist final) ✅
417
-
418
- - ✅ Todos os testes unitários passam (252/252)
419
- - ✅ Snapshots atualizados e validados
420
- - ✅ Testes de integração (QA testes presentes)
421
- - ✅ Performance não regrediu (1.45s para 252 testes)
422
-
423
- ### DX validation (Checklist final) ✅
424
-
425
- - ✅ Autocomplete funcional em VS Code
426
- - ✅ Hover docs aparecem
427
- - ✅ Go-to-definition funciona
428
- - ✅ Nenhum erro TypeScript no workspace
429
-
430
- ### Documentação (Checklist final) ✅
431
-
432
- - ✅ Changelog atualizado (v0.3.0 completo)
433
- - ✅ Migration guide completo (`docs/Migration.md`)
434
- - ✅ README reflete v0.3 (já atualizado)
435
- - ✅ Exemplos funcionam (imports validados)
436
-
437
- ### Pre-release (Checklist final) ✅ / ⚠️
438
-
439
- - ✅ Versão bumped corretamente (0.3.0)
440
- - ⚠️ Git tags (criar antes do publish)
441
- - ⚠️ Build CI verde (validar se CI configurado)
442
- - ⚠️ Dry-run de publish (executar antes do publish)
443
-
444
- ### Release (Checklist final) ⚠️
445
-
446
- - ⚠️ Publicado no npm (ação manual pendente)
447
- - ⚠️ GitHub release criado (ação manual pendente)
448
- - ⚠️ Announcement preparado (opcional)
449
-
450
- ---
451
-
452
- ## 📊 VEREDICTO FINAL
453
-
454
- **Status**: ✅ **APROVADO PARA RELEASE**
455
-
456
- **Implementação completa** que:
457
-
458
- - Atende todos os critérios obrigatórios da Fase 10
459
- - Testes 100% passando (252 testes)
460
- - Build limpo sem erros
461
- - Documentação completa e bem estruturada
462
- - Changelog e migration guide profissionais
463
- - Versão corretamente atualizada
464
-
465
- **Nenhuma correção necessária**. Código está pronto para publicação.
466
-
467
- **🚀 Próximos passos para release**:
468
-
469
- 1. **Validação final**:
470
-
471
- ```bash
472
- npm run build
473
- npm test
474
- npm pack
475
- npm publish --dry-run
476
- ```
477
-
478
- 2. **Git tag**:
479
-
480
- ```bash
481
- git tag -a v0.3.0 -m "Release v0.3.0"
482
- git push origin v0.3.0
483
- ```
484
-
485
- 3. **Publicar**:
486
-
487
- ```bash
488
- npm publish
489
- ```
490
-
491
- 4. **GitHub release**:
492
- - Criar release no GitHub
493
- - Copiar changelog v0.3.0
494
- - Anexar assets (se aplicável)
495
-
496
- 5. **Announcement** (opcional):
497
- - Twitter/X
498
- - Reddit r/typescript
499
- - Dev.to
500
-
501
- **Parabéns pela conclusão da v0.3.0!** 🎉
502
-
503
- ---
504
-
505
- ## 📚 Referências
506
-
507
- - Guia de revisão: `.github/skills/review-guide/references/review-guide-v0.3.md`
508
- - Fase 10 checklist: Linhas 506-560 do guia
509
- - Arquivos revisados:
510
- - `CHANGELOG.md` (v0.3.0 adicionado)
511
- - `package.json` (version bumped)
512
- - `src/planning/roadmap-v0.3.md` (tarefas marcadas)
513
- - `docs/Migration.md` (já criado)
514
-
515
- ---
516
-
517
- ## 📈 Estatísticas v0.3.0
518
-
519
- **Testes**:
520
-
521
- - 252 testes passando
522
- - 46 arquivos de teste
523
- - 1.45s de execução
524
- - 0% falhas
525
-
526
- **Cobertura por área**:
527
-
528
- - Core: 28 tests (11%)
529
- - Engine: 40 tests (16%)
530
- - Contrast: 25 tests (10%)
531
- - Export: 14 tests (6%)
532
- - CLI: 9 tests (4%)
533
- - Operators: 14 tests (6%)
534
- - Serialize: 3 tests (1%)
535
- - Utils: 7 tests (3%)
536
- - Presets: 4 tests (2%)
537
-
538
- **Documentação**:
539
-
540
- - README atualizado
541
- - 13 arquivos em `docs/`
542
- - Migration guide criado
543
- - Changelog completo
544
-
545
- **Package**:
546
-
547
- - 4 subpath exports (`"."`, `"./serialize"`, `"./export"`, `"./cli"`)
548
- - ESM-only
549
- - Tree-shakeable
550
- - TypeScript types completos