@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
package/docs/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Palette Kit v0.4 Documentation
2
+
3
+ This directory documents the current v0.4 branch implementation.
4
+
5
+ The public runtime surface is intentionally small:
6
+
7
+ - `createPaletteKit`
8
+ - `palette.resolve`
9
+ - official resolver preset configs
10
+
11
+ The package root also reexports public TypeScript types. Internal modules,
12
+ serializers, registries, validators, and resolver helpers are not public API.
13
+
14
+ ## Start Here
15
+
16
+ - [API](./API.md)
17
+ - [Configuration](./Config.md)
18
+ - [Concepts](./Concepts.md)
19
+ - [Architecture](./Architecture.md)
20
+ - [Validation](./Validation.md)
21
+ - [FAQ](./FAQ.md)
22
+
23
+ ## Usage
24
+
25
+ - [Usage: Web](./Usage-Web.md)
26
+ - [Usage: React Native](./Usage-ReactNative.md)
27
+ - [Usage: JSON](./Usage-JSON.md)
28
+
29
+ ## Status References
30
+
31
+ - [CLI](./CLI.md)
32
+ - [Exporters](./Exporters.md)
33
+ - [Tokens](./Tokens.md)
34
+ - [Diagnostics](./Diagnostics.md)
35
+ - [Alpha](./Alpha.md)
36
+ - [Overlays](./Overlays.md)
37
+ - [Text](./Text.md)
38
+ - [Why](./Why.md)
39
+
40
+ ## v0.4 Planning References
41
+
42
+ - [v0.4 SPEC](../planning/v0.4/v0.4-palette-kit-spec.md)
43
+ - [Resolver Reference](../planning/v0.4/v0.4-resolver-reference.md)
44
+ - [Output Serialization Contract](../planning/v0.4/v0.4-output-serialization-contract.md)
45
+ - [Testing Strategy and Golden Cases](../planning/v0.4/v0.4-testing-strategy-golden-cases.md)
46
+
47
+ ## Diagrams
48
+
49
+ - [Axes](../planning/v0.4/diagrams/axes.md)
50
+ - [Context](../planning/v0.4/diagrams/context.md)
51
+ - [Relations](../planning/v0.4/diagrams/relations.md)
52
+ - [Resolver Pipeline](../planning/v0.4/diagrams/resolver-pipeline.md)
53
+ - [What Never Happens](../planning/v0.4/diagrams/what-never-happens.md)
54
+
55
+ ## Historical Documents
56
+
57
+ - [Legacy spec](./spec-legacy.md)
58
+
59
+ The legacy spec and manifesto files are historical context. They do not define
60
+ the current v0.4 public API.
package/docs/Text.md ADDED
@@ -0,0 +1,41 @@
1
+ # Text and Visual Vocabulary
2
+
3
+ Text, icons, and similar foreground elements use:
4
+
5
+ ```ts
6
+ usage: "visualVocabulary"
7
+ ```
8
+
9
+ ## Rules
10
+
11
+ `visualVocabulary`:
12
+
13
+ - requires `on`;
14
+ - forbids `level`;
15
+ - resolves from the selected intent and relation target.
16
+
17
+ ```ts
18
+ const surface = palette.resolve({
19
+ usage: "fill",
20
+ intent: "neutral",
21
+ level: 2,
22
+ });
23
+
24
+ const text = palette.resolve({
25
+ usage: "visualVocabulary",
26
+ intent: "brand",
27
+ on: surface,
28
+ });
29
+ ```
30
+
31
+ ## Current Behavior
32
+
33
+ `on` enforces APCA contrast. The default target is Lc 60. APCA is the primary
34
+ metric; WCAG contrast is available as a fallback diagnostic when APCA does not
35
+ produce a usable numeric value.
36
+
37
+ The resolver first adjusts OKLCH lightness while preserving hue. If luminance
38
+ alone is insufficient, it may reduce chroma within the configured limits. If the
39
+ target still cannot be reached, resolution throws.
40
+
41
+ The contrast solver never changes alpha for `visualVocabulary`.
package/docs/Tokens.md ADDED
@@ -0,0 +1,42 @@
1
+ # Tokens
2
+
3
+ Palette Kit v0.4 does not expose a public token registry or token exporter.
4
+
5
+ The current model resolves colors from axes. Applications may store the resolved
6
+ values as tokens if they need build artifacts.
7
+
8
+ ```ts
9
+ const tokens = {
10
+ "surface.default": palette.resolve({
11
+ usage: "fill",
12
+ intent: "neutral",
13
+ level: 2,
14
+ output: "hex",
15
+ }),
16
+ };
17
+ ```
18
+
19
+ ## Important Constraint
20
+
21
+ Palette Kit rejects intent names that encode usage, state, relation, level, or
22
+ visual implementation details. Keep those dimensions in resolver options.
23
+
24
+ Prefer:
25
+
26
+ ```ts
27
+ palette.resolve({
28
+ usage: "fill",
29
+ intent: "brand",
30
+ level: 4,
31
+ state: "hover",
32
+ stateDirection: "increase",
33
+ });
34
+ ```
35
+
36
+ Avoid designing intent names such as:
37
+
38
+ ```text
39
+ brandFillHoverOnDark
40
+ dangerStrong
41
+ successText
42
+ ```
@@ -0,0 +1,39 @@
1
+ # Usage: JSON
2
+
3
+ Palette Kit v0.4 does not expose a public JSON exporter. Build JSON manually
4
+ from `palette.resolve` outputs.
5
+
6
+ ```ts
7
+ import { createPaletteKit } from "@clhaas/palette-kit";
8
+
9
+ const palette = createPaletteKit({
10
+ context: "light",
11
+ intents: {
12
+ brand: { hue: 260, chroma: 0.14 },
13
+ neutral: { hue: 0, chroma: 0 },
14
+ },
15
+ });
16
+
17
+ const tokens = {
18
+ "surface.default": palette.resolve({
19
+ usage: "fill",
20
+ intent: "neutral",
21
+ level: 2,
22
+ output: "hex",
23
+ }),
24
+ "brand.default": palette.resolve({
25
+ usage: "fill",
26
+ intent: "brand",
27
+ level: 4,
28
+ output: "hex",
29
+ }),
30
+ };
31
+
32
+ const json = JSON.stringify(tokens, null, 2);
33
+ ```
34
+
35
+ ## Notes
36
+
37
+ - There is no public exporter subpath in v0.4.
38
+ - `hex` and `rgba` are supported runtime outputs.
39
+ - `oklch`, `oklab`, `srgb`, and `p3` are also supported runtime outputs.
@@ -0,0 +1,63 @@
1
+ # Usage: React Native
2
+
3
+ React Native needs platform-compatible color values. In v0.4, use
4
+ `output: "rgba"` for public runtime output.
5
+
6
+ ```ts
7
+ import { createPaletteKit } from "@clhaas/palette-kit";
8
+
9
+ const palette = createPaletteKit({
10
+ context: "light",
11
+ output: "rgba",
12
+ intents: {
13
+ brand: { hue: 260, chroma: 0.14 },
14
+ neutral: { hue: 0, chroma: 0 },
15
+ },
16
+ });
17
+ ```
18
+
19
+ ## Resolve RGBA
20
+
21
+ ```ts
22
+ const background = palette.resolve({
23
+ usage: "fill",
24
+ intent: "brand",
25
+ level: 4,
26
+ });
27
+ ```
28
+
29
+ `background` has this shape:
30
+
31
+ ```ts
32
+ type RgbaColor = {
33
+ r: number;
34
+ g: number;
35
+ b: number;
36
+ a: number;
37
+ };
38
+ ```
39
+
40
+ Convert it to a React Native string if needed:
41
+
42
+ ```ts
43
+ const rnColor = `rgba(${background.r}, ${background.g}, ${background.b}, ${background.a})`;
44
+ ```
45
+
46
+ ## Resolver Override
47
+
48
+ You can override output per call:
49
+
50
+ ```ts
51
+ const hex = palette.resolve({
52
+ usage: "fill",
53
+ intent: "brand",
54
+ level: 4,
55
+ output: "hex",
56
+ });
57
+ ```
58
+
59
+ ## Notes
60
+
61
+ - Palette Kit does not inspect platform color scheme automatically.
62
+ - Provide `context` or `systemDefaultContext` explicitly.
63
+ - `rgba` is usually the most direct React Native output.
@@ -0,0 +1,66 @@
1
+ # Usage: Web
2
+
3
+ Use `createPaletteKit` from the package root.
4
+
5
+ ```ts
6
+ import { createPaletteKit } from "@clhaas/palette-kit";
7
+
8
+ const palette = createPaletteKit({
9
+ context: "light",
10
+ intents: {
11
+ brand: { hue: 260, chroma: 0.14 },
12
+ neutral: { hue: 0, chroma: 0 },
13
+ },
14
+ });
15
+ ```
16
+
17
+ ## Resolve OKLCH
18
+
19
+ ```ts
20
+ const surface = palette.resolve({
21
+ usage: "fill",
22
+ intent: "neutral",
23
+ level: 2,
24
+ });
25
+ ```
26
+
27
+ The default output is a normalized OKLCH object.
28
+
29
+ ```ts
30
+ surface.space; // "oklch"
31
+ surface.l; // number in 0..100
32
+ surface.c; // number >= 0
33
+ surface.h; // number in [0, 360)
34
+ surface.alpha; // number in 0..1
35
+ ```
36
+
37
+ ## Resolve Hex
38
+
39
+ ```ts
40
+ const background = palette.resolve({
41
+ usage: "fill",
42
+ intent: "brand",
43
+ level: 4,
44
+ output: "hex",
45
+ });
46
+
47
+ document.documentElement.style.setProperty("--brand-bg", background);
48
+ ```
49
+
50
+ ## Resolve Related Text
51
+
52
+ ```ts
53
+ const text = palette.resolve({
54
+ usage: "visualVocabulary",
55
+ intent: "brand",
56
+ on: surface,
57
+ });
58
+ ```
59
+
60
+ `visualVocabulary` requires `on` and forbids `level`.
61
+
62
+ ## Notes
63
+
64
+ - `fill`, `lines`, and `overlays` require `level`.
65
+ - `state !== "default"` requires `stateDirection`.
66
+ - `hex`, `rgba`, `srgb`, and `p3` are available for platform delivery.
@@ -0,0 +1,97 @@
1
+ # Validation
2
+
3
+ This document lists observable validation behavior in the current v0.4 branch.
4
+
5
+ ## Intent Registry
6
+
7
+ Intent names must be flat strings:
8
+
9
+ - not empty
10
+ - no whitespace
11
+ - no `.`
12
+ - no encoded usage, state, relation, level, or visual implementation tokens
13
+
14
+ Intent values must include finite numeric `hue` and `chroma`. Chroma must be
15
+ greater than or equal to `0`.
16
+
17
+ Examples of rejected names include `textIncome`, `incomeHover`,
18
+ `incomeOverlay`, `incomeStrong`, and `redAlert`.
19
+
20
+ Unknown intents throw:
21
+
22
+ ```text
23
+ Unknown intent "<name>". Did you forget to register it in the Intent Registry?
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ Valid usages:
29
+
30
+ - `fill`
31
+ - `visualVocabulary`
32
+ - `lines`
33
+ - `overlays`
34
+
35
+ Unknown usages throw a message listing the valid usages.
36
+
37
+ ## Level
38
+
39
+ Valid levels are integers from `1` to `9`.
40
+
41
+ Level rules:
42
+
43
+ - `fill`, `lines`, and `overlays` require `level`.
44
+ - `visualVocabulary` forbids `level`.
45
+
46
+ ## Relations
47
+
48
+ Only one relation may be provided per resolve call.
49
+
50
+ Relation rules:
51
+
52
+ - `visualVocabulary` requires `on`.
53
+ - `overlays` forbids `on`.
54
+ - `fill` and `lines` allow `on`.
55
+
56
+ Relation targets must be normalized OKLCH colors.
57
+
58
+ ## State
59
+
60
+ Valid states:
61
+
62
+ - `default`
63
+ - `hover`
64
+ - `active`
65
+ - `focus`
66
+ - `selected`
67
+ - `disabled`
68
+
69
+ When `state` is not `default`, `stateDirection` is required.
70
+
71
+ ## Context
72
+
73
+ Valid contexts:
74
+
75
+ - `light`
76
+ - `dark`
77
+
78
+ If resolver context, palette context, and system default context are all absent,
79
+ resolution throws:
80
+
81
+ ```text
82
+ Context could not be resolved. Provide resolverContext, paletteContext, or systemDefaultContext.
83
+ ```
84
+
85
+ ## Output
86
+
87
+ Valid output names:
88
+
89
+ - `oklch`
90
+ - `oklab`
91
+ - `srgb`
92
+ - `p3`
93
+ - `hex`
94
+ - `rgba`
95
+
96
+ Runtime serialization supports all valid output names. RGB-like outputs use
97
+ explicit clip gamut handling.
package/docs/Why.md ADDED
@@ -0,0 +1,37 @@
1
+ # Why
2
+
3
+ Palette Kit exists to make semantic color resolution deterministic without
4
+ forcing applications to maintain large sets of precomposed color tokens.
5
+
6
+ ## Design Direction
7
+
8
+ Instead of names like `brandHoverTextOnDark`, v0.4 separates decisions into
9
+ axes:
10
+
11
+ - intent
12
+ - usage
13
+ - level
14
+ - relation
15
+ - state
16
+ - context
17
+ - output
18
+
19
+ This keeps meaning separate from presentation and environment.
20
+
21
+ ## Current v0.4 Constraints
22
+
23
+ - Public runtime API is `createPaletteKit`.
24
+ - Resolution is internal OKLCH.
25
+ - Context is explicit and never inferred.
26
+ - Level is explicit and never inferred.
27
+ - Output is applied after resolution.
28
+ - `on` enforces APCA contrast explicitly.
29
+ - `hex`, `rgba`, `oklab`, `srgb`, and `p3` are supported delivery formats.
30
+ - Presets and resolver config are explicit public configuration.
31
+ - CLI and exporters are not public.
32
+
33
+ ## Trade-Off
34
+
35
+ The current v0.4 branch favors an auditable API over broad convenience tooling.
36
+ CLI commands, token exporters, and codegen can be added later without changing
37
+ the resolver model.
@@ -0,0 +1,53 @@
1
+ # API Surface Report
2
+
3
+ This report reflects the current v0.4 branch package root.
4
+
5
+ ## Runtime Exports
6
+
7
+ - `createPaletteKit`
8
+ - `defaultResolverConfig`
9
+ - `neutralResolverConfig`
10
+ - `softResolverConfig`
11
+ - `strongResolverConfig`
12
+
13
+ ## Type Exports
14
+
15
+ - `PaletteKitConfig`
16
+ - `PaletteKit`
17
+ - `PaletteResolveOptions`
18
+ - `PaletteResolveOutput`
19
+ - `Usage`
20
+ - `Level`
21
+ - `State`
22
+ - `StateDeltaDirection`
23
+ - `Context`
24
+ - `ColorOutput`
25
+ - `OklchColor`
26
+ - `RgbColor`
27
+ - `RgbaColor`
28
+ - `IntentDefinition`
29
+ - `ResolverPresetName`
30
+ - `ResolverConfig`
31
+ - `RelationParamsConfig`
32
+ - `ChromaConfig`
33
+
34
+ ## Public Package Exports
35
+
36
+ Only the root export is public:
37
+
38
+ ```json
39
+ {
40
+ ".": {
41
+ "types": "./dist/index.d.ts",
42
+ "default": "./dist/index.js"
43
+ }
44
+ }
45
+ ```
46
+
47
+ ## Not Exported
48
+
49
+ - CLI
50
+ - exporter subpaths
51
+ - intent registry helpers
52
+ - internal resolver helpers
53
+ - serializer functions
@@ -0,0 +1,9 @@
1
+ # Serialize OKLCH
2
+
3
+ ```ts
4
+ const toOklch = (c: { l: number; c: number; h: number; alpha?: number }) => {
5
+ const a = c.alpha ?? 1;
6
+ const alphaPart = a < 1 ? ` / ${a}` : "";
7
+ return `oklch(${c.l}% ${c.c} ${c.h}${alphaPart})`;
8
+ };
9
+ ```
package/docs/spec.md ADDED
@@ -0,0 +1,98 @@
1
+ # Palette Kit v0.4 Current Implementation Spec
2
+
3
+ This document summarizes the current v0.4 branch implementation. The complete
4
+ planning specification lives in
5
+ [planning/v0.4/v0.4-palette-kit-spec.md](../planning/v0.4/v0.4-palette-kit-spec.md).
6
+
7
+ ## Public Scope
8
+
9
+ The package root exposes:
10
+
11
+ - `createPaletteKit`
12
+ - `softResolverConfig`
13
+ - `neutralResolverConfig`
14
+ - `strongResolverConfig`
15
+ - `defaultResolverConfig`
16
+ - public TypeScript types
17
+
18
+ The package root does not expose CLI commands, subpath exporters, serializer
19
+ functions, validators, or internal resolver helpers.
20
+
21
+ ## Public Configuration
22
+
23
+ ```ts
24
+ createPaletteKit({
25
+ context: "light",
26
+ output: "oklch",
27
+ intents: {
28
+ brand: { hue: 260, chroma: 0.14 },
29
+ neutral: { hue: 0, chroma: 0 },
30
+ },
31
+ });
32
+ ```
33
+
34
+ The public config supports:
35
+
36
+ - `intents`
37
+ - `context`
38
+ - `systemDefaultContext`
39
+ - `output`
40
+ - `systemDefaultOutput`
41
+ - `preset`
42
+ - `resolverConfig`
43
+
44
+ ## Resolver Axes
45
+
46
+ `palette.resolve` accepts:
47
+
48
+ - `usage`
49
+ - `intent`
50
+ - `level`
51
+ - `on`
52
+ - `over`
53
+ - `under`
54
+ - `state`
55
+ - `stateDirection`
56
+ - `context`
57
+ - `output`
58
+
59
+ The resolver is deterministic and resolves internally in OKLCH.
60
+
61
+ ## Implemented Outputs
62
+
63
+ - `oklch`
64
+ - `oklab`
65
+ - `srgb`
66
+ - `p3`
67
+ - `hex`
68
+ - `rgba`
69
+
70
+ RGB-like outputs use clipped 8-bit channels. `p3` uses Display-P3 conversion
71
+ and the current explicit clip gamut strategy.
72
+
73
+ ## Implemented Guarantees
74
+
75
+ - Same input produces the same output.
76
+ - Output format does not change internal OKLCH resolution.
77
+ - Context is explicit and never inferred.
78
+ - Context affects structural level curves while preserving semantic intent.
79
+ - Level is explicit and never inferred.
80
+ - Non-default state requires `stateDirection`.
81
+ - Forbidden axis combinations throw.
82
+ - `on` enforces APCA contrast with a default Lc 60 target and exposes WCAG as a
83
+ fallback diagnostic.
84
+ - `over` applies configured alpha by level.
85
+ - `under` applies configured alpha and luminance reduction by level.
86
+ - State alpha deltas apply only where alpha is allowed, currently `overlays`.
87
+ - Intent names are semantic-only and cannot encode usage, state, relation,
88
+ level, or visual implementation details.
89
+
90
+ ## Current Limitations
91
+
92
+ - CLI and exporters are not public in v0.4.
93
+
94
+ ## References
95
+
96
+ - [Resolver Reference](../planning/v0.4/v0.4-resolver-reference.md)
97
+ - [Output Serialization Contract](../planning/v0.4/v0.4-output-serialization-contract.md)
98
+ - [Testing Strategy](../planning/v0.4/v0.4-testing-strategy-golden-cases.md)