@newtone-dev/ui-react-web 0.45.0 → 0.46.1

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 (177) hide show
  1. package/README.md +5 -3
  2. package/dist/app-frame/app-frame.css +57 -0
  3. package/dist/app-frame/app-frame.d.ts +2 -1
  4. package/dist/app-frame/app-frame.d.ts.map +1 -1
  5. package/dist/app-frame/app-frame.js +2 -1
  6. package/dist/app-frame/app-frame.js.map +1 -1
  7. package/dist/app-frame/index.d.ts +1 -1
  8. package/dist/app-frame/index.d.ts.map +1 -1
  9. package/dist/app-frame/launcher/launcher.d.ts.map +1 -1
  10. package/dist/app-frame/launcher/launcher.js +5 -3
  11. package/dist/app-frame/launcher/launcher.js.map +1 -1
  12. package/dist/app-frame/parts.d.ts +22 -1
  13. package/dist/app-frame/parts.d.ts.map +1 -1
  14. package/dist/app-frame/parts.js +15 -2
  15. package/dist/app-frame/parts.js.map +1 -1
  16. package/dist/beside/beside.css +4 -0
  17. package/dist/card-box/card-box.css +8 -2
  18. package/dist/card-box/card-box.d.ts.map +1 -1
  19. package/dist/card-box/card-box.js +1 -1
  20. package/dist/card-box/card-box.js.map +1 -1
  21. package/dist/color/index.d.ts +4 -4
  22. package/dist/color/index.d.ts.map +1 -1
  23. package/dist/color/index.js +17 -15
  24. package/dist/color/index.js.map +1 -1
  25. package/dist/color/oklch.d.ts +6 -27
  26. package/dist/color/oklch.d.ts.map +1 -1
  27. package/dist/color/oklch.js +23 -61
  28. package/dist/color/oklch.js.map +1 -1
  29. package/dist/color/scale.d.ts +3 -18
  30. package/dist/color/scale.d.ts.map +1 -1
  31. package/dist/color/scale.js +13 -70
  32. package/dist/color/scale.js.map +1 -1
  33. package/dist/color/seeds.d.ts +51 -11
  34. package/dist/color/seeds.d.ts.map +1 -1
  35. package/dist/color/seeds.js +127 -41
  36. package/dist/color/seeds.js.map +1 -1
  37. package/dist/curve-field/curve-field.css +280 -0
  38. package/dist/curve-field/curve-field.d.ts +105 -0
  39. package/dist/curve-field/curve-field.d.ts.map +1 -0
  40. package/dist/curve-field/curve-field.js +532 -0
  41. package/dist/curve-field/curve-field.js.map +1 -0
  42. package/dist/curve-field/index.d.ts +3 -0
  43. package/dist/curve-field/index.d.ts.map +1 -0
  44. package/dist/curve-field/index.js +2 -0
  45. package/dist/curve-field/index.js.map +1 -0
  46. package/dist/diagram/diagram.css +63 -0
  47. package/dist/diagram/diagram.d.ts +63 -0
  48. package/dist/diagram/diagram.d.ts.map +1 -0
  49. package/dist/diagram/diagram.js +73 -0
  50. package/dist/diagram/diagram.js.map +1 -0
  51. package/dist/diagram/geometry.d.ts +60 -0
  52. package/dist/diagram/geometry.d.ts.map +1 -0
  53. package/dist/diagram/geometry.js +93 -0
  54. package/dist/diagram/geometry.js.map +1 -0
  55. package/dist/diagram/index.d.ts +7 -0
  56. package/dist/diagram/index.d.ts.map +1 -0
  57. package/dist/diagram/index.js +4 -0
  58. package/dist/diagram/index.js.map +1 -0
  59. package/dist/diagram/layout.d.ts +41 -0
  60. package/dist/diagram/layout.d.ts.map +1 -0
  61. package/dist/diagram/layout.js +157 -0
  62. package/dist/diagram/layout.js.map +1 -0
  63. package/dist/document/document.d.ts +7 -2
  64. package/dist/document/document.d.ts.map +1 -1
  65. package/dist/document/document.js +22 -4
  66. package/dist/document/document.js.map +1 -1
  67. package/dist/dynamic-range/dynamic-range.css +100 -0
  68. package/dist/dynamic-range/dynamic-range.d.ts +27 -0
  69. package/dist/dynamic-range/dynamic-range.d.ts.map +1 -0
  70. package/dist/dynamic-range/dynamic-range.js +20 -0
  71. package/dist/dynamic-range/dynamic-range.js.map +1 -0
  72. package/dist/dynamic-range/index.d.ts +3 -0
  73. package/dist/dynamic-range/index.d.ts.map +1 -0
  74. package/dist/dynamic-range/index.js +2 -0
  75. package/dist/dynamic-range/index.js.map +1 -0
  76. package/dist/file-grid/file-grid.css +65 -0
  77. package/dist/file-grid/file-grid.d.ts +34 -1
  78. package/dist/file-grid/file-grid.d.ts.map +1 -1
  79. package/dist/file-grid/file-grid.js +63 -2
  80. package/dist/file-grid/file-grid.js.map +1 -1
  81. package/dist/file-grid/index.d.ts +2 -2
  82. package/dist/file-grid/index.d.ts.map +1 -1
  83. package/dist/file-grid/index.js +1 -1
  84. package/dist/file-grid/index.js.map +1 -1
  85. package/dist/floating-bar/floating-bar.css +37 -15
  86. package/dist/floating-bar/floating-bar.d.ts +16 -1
  87. package/dist/floating-bar/floating-bar.d.ts.map +1 -1
  88. package/dist/floating-bar/floating-bar.js +58 -15
  89. package/dist/floating-bar/floating-bar.js.map +1 -1
  90. package/dist/floating-bar/index.d.ts +1 -1
  91. package/dist/floating-bar/index.d.ts.map +1 -1
  92. package/dist/identity/identity.d.ts +11 -3
  93. package/dist/identity/identity.d.ts.map +1 -1
  94. package/dist/identity/identity.js +8 -4
  95. package/dist/identity/identity.js.map +1 -1
  96. package/dist/index.d.ts +16 -8
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js +6 -2
  99. package/dist/index.js.map +1 -1
  100. package/dist/inspector/index.d.ts +1 -1
  101. package/dist/inspector/index.d.ts.map +1 -1
  102. package/dist/inspector/inspector.css +199 -6
  103. package/dist/inspector/inspector.d.ts +113 -3
  104. package/dist/inspector/inspector.d.ts.map +1 -1
  105. package/dist/inspector/inspector.js +53 -5
  106. package/dist/inspector/inspector.js.map +1 -1
  107. package/dist/material/material.css +8 -2
  108. package/dist/number-field/number-field.css +13 -0
  109. package/dist/number-field/number-field.d.ts +6 -1
  110. package/dist/number-field/number-field.d.ts.map +1 -1
  111. package/dist/number-field/number-field.js +10 -2
  112. package/dist/number-field/number-field.js.map +1 -1
  113. package/dist/pop-menu/pop-menu.d.ts +3 -0
  114. package/dist/pop-menu/pop-menu.d.ts.map +1 -1
  115. package/dist/pop-menu/pop-menu.js +12 -6
  116. package/dist/pop-menu/pop-menu.js.map +1 -1
  117. package/dist/prompt-field/prompt-field.css +3 -3
  118. package/dist/prompt-field/prompt-field.d.ts +3 -3
  119. package/dist/prompt-field/prompt-field.d.ts.map +1 -1
  120. package/dist/prompt-field/prompt-field.js +10 -4
  121. package/dist/prompt-field/prompt-field.js.map +1 -1
  122. package/dist/seed-contrast-field/index.d.ts +5 -0
  123. package/dist/seed-contrast-field/index.d.ts.map +1 -0
  124. package/dist/seed-contrast-field/index.js +3 -0
  125. package/dist/seed-contrast-field/index.js.map +1 -0
  126. package/dist/seed-contrast-field/seed-contrast-field.css +11 -0
  127. package/dist/{seed-dark-limit-field/seed-dark-limit-field.d.ts → seed-contrast-field/seed-contrast-field.d.ts} +14 -14
  128. package/dist/seed-contrast-field/seed-contrast-field.d.ts.map +1 -0
  129. package/dist/seed-contrast-field/seed-contrast-field.js +18 -0
  130. package/dist/seed-contrast-field/seed-contrast-field.js.map +1 -0
  131. package/dist/seed-contrast-field/seed-contrast-slider.css +112 -0
  132. package/dist/seed-contrast-field/seed-contrast-slider.d.ts +22 -0
  133. package/dist/seed-contrast-field/seed-contrast-slider.d.ts.map +1 -0
  134. package/dist/seed-contrast-field/seed-contrast-slider.js +75 -0
  135. package/dist/seed-contrast-field/seed-contrast-slider.js.map +1 -0
  136. package/dist/seed-steps/index.d.ts +1 -1
  137. package/dist/seed-steps/index.js +1 -1
  138. package/dist/seed-steps/seed-steps.css +1 -1
  139. package/dist/seed-steps/seed-steps.js +1 -1
  140. package/dist/seed-steps/seed-steps.js.map +1 -1
  141. package/dist/shell/shell.css +31 -21
  142. package/dist/split/split.css +8 -5
  143. package/dist/step-list/index.d.ts +1 -1
  144. package/dist/step-list/index.d.ts.map +1 -1
  145. package/dist/step-list/step-list.css +75 -2
  146. package/dist/step-list/step-list.d.ts +121 -11
  147. package/dist/step-list/step-list.d.ts.map +1 -1
  148. package/dist/step-list/step-list.js +203 -37
  149. package/dist/step-list/step-list.js.map +1 -1
  150. package/dist/step-strip/index.d.ts +3 -0
  151. package/dist/step-strip/index.d.ts.map +1 -0
  152. package/dist/step-strip/index.js +2 -0
  153. package/dist/step-strip/index.js.map +1 -0
  154. package/dist/step-strip/step-strip.css +118 -0
  155. package/dist/step-strip/step-strip.d.ts +52 -0
  156. package/dist/step-strip/step-strip.d.ts.map +1 -0
  157. package/dist/step-strip/step-strip.js +47 -0
  158. package/dist/step-strip/step-strip.js.map +1 -0
  159. package/dist/surface/surface.css +112 -0
  160. package/dist/workbench/workbench.css +50 -0
  161. package/dist/workbench/workbench.d.ts +25 -1
  162. package/dist/workbench/workbench.d.ts.map +1 -1
  163. package/dist/workbench/workbench.js +11 -2
  164. package/dist/workbench/workbench.js.map +1 -1
  165. package/package.json +27 -5
  166. package/dist/color/gamut.d.ts +0 -20
  167. package/dist/color/gamut.d.ts.map +0 -1
  168. package/dist/color/gamut.js +0 -72
  169. package/dist/color/gamut.js.map +0 -1
  170. package/dist/seed-dark-limit-field/index.d.ts +0 -3
  171. package/dist/seed-dark-limit-field/index.d.ts.map +0 -1
  172. package/dist/seed-dark-limit-field/index.js +0 -2
  173. package/dist/seed-dark-limit-field/index.js.map +0 -1
  174. package/dist/seed-dark-limit-field/seed-dark-limit-field.css +0 -10
  175. package/dist/seed-dark-limit-field/seed-dark-limit-field.d.ts.map +0 -1
  176. package/dist/seed-dark-limit-field/seed-dark-limit-field.js +0 -18
  177. package/dist/seed-dark-limit-field/seed-dark-limit-field.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"oklch.d.ts","sourceRoot":"","sources":["../../src/color/oklch.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,aAAa,sBACrB,YAAY,EAAE,YAAY,EAAE,YAAY,aACxC,YAAY,EAAE,YAAY,EAAE,YAAY,aACxC,YAAY,EAAE,YAAY,EAAE,YAAY,EACnC,CAAA;AACV,eAAO,MAAM,aAAa,sBACrB,YAAY,EAAE,WAAW,EAAE,CAAC,YAAY,aACxC,YAAY,EAAE,CAAC,WAAW,EAAE,YAAY,aACxC,YAAY,EAAE,YAAY,EAAE,CAAC,WAAW,EACnC,CAAA;AAOV,eAAO,M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AC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,GAAG,MAAM,CASrD;AAMD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG/C"}
1
+ {"version":3,"file":"oklch.d.ts","sourceRoot":"","sources":["../../src/color/oklch.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAA;AAE1D,YAAY,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAA;AAC1D,YAAY,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAA;AAKjE,eAAO,MAAM,aAAa,sBACrB,YAAY,EAAE,YAAY,EAAE,YAAY,aACxC,YAAY,EAAE,YAAY,EAAE,YAAY,aACxC,YAAY,EAAE,YAAY,EAAE,YAAY,EACnC,CAAA;AACV,eAAO,MAAM,aAAa,sBACrB,YAAY,EAAE,WAAW,EAAE,CAAC,YAAY,aACxC,YAAY,EAAE,CAAC,WAAW,EAAE,YAAY,aACxC,YAAY,EAAE,YAAY,EAAE,CAAC,WAAW,EACnC,CAAA;AAEV,MAAM,MAAM,CAAC,GAAG,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAA;AAC9C,MAAM,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAgBjD,yFAAyF;AACzF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAW7C;AAED,mHAAmH;AACnH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,CAGpE;AAED,0GAA0G;AAC1G,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAE/C"}
@@ -1,14 +1,22 @@
1
- // The OKLCH colour space itself: the matrices, the transfer functions, and the two
2
- // conversions that are not on the derivation path.
1
+ // The OKLCH colour space where it is not the engine's: a hex measured in, and the two conversions this library has
2
+ // always published, kept to their call shapes over the engine's own.
3
3
  //
4
- // Split out of one 349-line file on 2026-09-02 so that the invariant in the blueprint's
5
- // section 5 -- "the forward matrices match contract 6.1 exactly" -- and its single
6
- // deliberate exception are checkable by reading forty lines instead of scanning three
7
- // hundred. That is the pain the split answers; the tidiness is a side effect.
4
+ // **The forward matrices, the transfer function and the gamut live in one place since 2026-11-14**: Newtone's palette
5
+ // engine, `@newtone-dev/ui-tokens/engine/vector` (newtone_ui_tokens/compute/vector.mjs), which this library imports
6
+ // live -- Joshua's decision, the HuevOS Core, page palette-engine. Until then this file carried its own full-precision
7
+ // copy of them (contract section 6.1's product, not Ottosson's rounding), held to the engine's bytes by a conformance
8
+ // runner. What is left here is what the engine does not do, and two adapters whose shapes differ from the engine's:
9
+ //
10
+ // hexToOklch section 6.3, the tooling path, with the OTHER matrix pair (below). Not the engine's.
11
+ // oklchToLinearSrgb the engine's channels, as the `[r, g, b]` tuple this library returned; the engine returns
12
+ // `{ r, g, b }`. The same three numbers, checked over 26,775 colours on 2026-11-14.
13
+ // oklchToHex the engine's hex, uppercase, as section 6.7 and everything the tokens repo emits are. The
14
+ // engine's own `oklchToHex` is lowercase and its `createScale` uppercases it, as this does.
8
15
  //
9
16
  // Private to `color/`. What leaves the folder is decided by index.ts.
17
+ import { oklchToHex as engineHex, oklchToLinearSrgb as engineLinearSrgb, } from '@newtone-dev/ui-tokens/engine/vector';
10
18
  // Linear sRGB -> LMS, and LMS' -> OKLab. Section 6.3 only, OFF the derivation path.
11
- // These are Ottosson's published values and are deliberately not the forward pair below:
19
+ // These are Ottosson's published values and are deliberately not the engine's forward pair:
12
20
  // they serve `hexToOklch`, which measures a colour someone picked by eye.
13
21
  export const LMS_FROM_LRGB = [
14
22
  [0.4122214708, 0.5363325363, 0.0514459929],
@@ -20,28 +28,14 @@ export const LAB_FROM_LMSP = [
20
28
  [1.9779984951, -2.428592205, 0.4505937099],
21
29
  [0.0259040371, 0.7827717662, -0.808675766],
22
30
  ];
23
- // ON the derivation path. The two forward matrices are the products of
24
- // (XYZ -> RGB) x (LMS -> XYZ) carried at full double precision, NOT Ottosson's pre-rounded
25
- // publication. About 4% of hexes move by one unit in one channel between the two; nothing
26
- // is visible, and every byte is nonetheless different. Using the published rounding here
27
- // breaks CHARTER.md non-negotiable 4 the moment this is compared with the tokens build.
28
- export const SRGB_R = [4.0765379686154635, -3.3070962248908753, 0.2308224615351424];
29
- export const SRGB_G = [-1.2686058016641382, 2.6097474109021599, -0.3411636310115355];
30
- export const SRGB_B = [-0.004199535952631, -0.7035140435404212, 1.7072021573980527];
31
- export const P3_R = [3.1281105290323121, -2.2570750183548709, 0.1293047884378317];
32
- export const P3_G = [-1.0911281609083134, 2.4132667617599557, -0.3221681708589348];
33
- export const P3_B = [-0.0260136497064853, -0.5080276489512767, 1.5333166822296191];
34
- export const EPSILON = 1e-6;
35
- export const DEG_TO_RAD = Math.PI / 180;
36
31
  const mul = (m, v) => [
37
32
  m[0][0] * v[0] + m[0][1] * v[1] + m[0][2] * v[2],
38
33
  m[1][0] * v[0] + m[1][1] * v[1] + m[1][2] * v[2],
39
34
  m[2][0] * v[0] + m[2][1] * v[1] + m[2][2] * v[2],
40
35
  ];
41
- // Section 6.2. Two different thresholds. Using one for both is the classic bug.
36
+ // Section 6.2's decode, for a hex coming in. Its encode, for a hex going out, is the engine's (inside oklchToHex).
37
+ // Two different thresholds; using one for both is the classic bug.
42
38
  const decode = (x) => (x <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4));
43
- const encode = (x) => (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
44
- export const clamp01 = (x) => Math.max(0, Math.min(1, x));
45
39
  // ---------------------------------------------------------------------------
46
40
  // Section 6.3 -- hex to OKLCH. Tooling only; a seed no longer carries a hex.
47
41
  // ---------------------------------------------------------------------------
@@ -59,45 +53,13 @@ export function hexToOklch(hex) {
59
53
  h += 360;
60
54
  return { l, c: Math.hypot(a, b), h };
61
55
  }
56
+ /** OKLCH to linear sRGB, unclamped: the engine's three channels, as the `[r, g, b]` tuple this library returns. */
62
57
  export function oklchToLinearSrgb(l, c, h) {
63
- const rad = h * DEG_TO_RAD;
64
- const a = c * Math.cos(rad);
65
- const b = c * Math.sin(rad);
66
- const l_ = l + 0.3963377774 * a + 0.2158037573 * b;
67
- const m_ = l - 0.1055613458 * a - 0.0638541728 * b;
68
- const s_ = l - 0.0894841775 * a - 1.291485548 * b;
69
- const lc = l_ * l_ * l_;
70
- const mc = m_ * m_ * m_;
71
- const sc = s_ * s_ * s_;
72
- return [
73
- SRGB_R[0] * lc + SRGB_R[1] * mc + SRGB_R[2] * sc,
74
- SRGB_G[0] * lc + SRGB_G[1] * mc + SRGB_G[2] * sc,
75
- SRGB_B[0] * lc + SRGB_B[1] * mc + SRGB_B[2] * sc,
76
- ];
77
- }
78
- /** Section 6.7, the sRGB half. Uppercase, to match everything the tokens repo emits. */
79
- export function oklchToHex({ l, c, h }) {
80
- return ('#' +
81
- oklchToLinearSrgb(l, c, h)
82
- .map((x) => Math.round(encode(clamp01(x)) * 255))
83
- .map((x) => x.toString(16).padStart(2, '0'))
84
- .join('')
85
- .toUpperCase());
58
+ const { r, g, b } = engineLinearSrgb(l, c, h);
59
+ return [r, g, b];
86
60
  }
87
- // ---------------------------------------------------------------------------
88
- // Section 6.8 -- serialization
89
- // ---------------------------------------------------------------------------
90
- /**
91
- * A number as CSS, rounded to 6 places and NEVER in exponent notation.
92
- *
93
- * The second half is load-bearing and is a workaround for somebody else's bug. esbuild --
94
- * what Vite runs over a production stylesheet -- strips trailing zeros from a number token
95
- * without first separating the mantissa from the exponent, so `4.656612873077393e-10`
96
- * comes out of a minified build as `4.656612873077393e-1`. That is the difference between
97
- * black and a mid grey, it happens only in a production build, and nothing warns.
98
- */
99
- export function cssNumber(value) {
100
- const trimmed = value.toFixed(6).replace(/\.?0+$/, '');
101
- return trimmed === '-0' || trimmed === '' ? '0' : trimmed;
61
+ /** Section 6.7, the sRGB half: the engine's hex, uppercase, to match everything the tokens repo emits. */
62
+ export function oklchToHex(color) {
63
+ return engineHex(color).toUpperCase();
102
64
  }
103
65
  //# sourceMappingURL=oklch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"oklch.js","sourceRoot":"","sources":["../../src/color/oklch.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,mDAAmD;AACnD,EAAE;AACF,wFAAwF;AACxF,mFAAmF;AACnF,sFAAsF;AACtF,8EAA8E;AAC9E,EAAE;AACF,sEAAsE;AAEtE,oFAAoF;AACpF,yFAAyF;AACzF,0EAA0E;AAC1E,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC;IAC1C,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC;IAC1C,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC;CACpC,CAAA;AACV,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,CAAC,YAAY,EAAE,WAAW,EAAE,CAAC,YAAY,CAAC;IAC1C,CAAC,YAAY,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC;IAC1C,CAAC,YAAY,EAAE,YAAY,EAAE,CAAC,WAAW,CAAC;CACpC,CAAA;AAEV,uEAAuE;AACvE,2FAA2F;AAC3F,0FAA0F;AAC1F,yFAAyF;AACzF,wFAAwF;AACxF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,kBAAkB,EAAE,CAAC,kBAAkB,EAAE,kBAAkB,CAAU,CAAA;AAC5F,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,EAAE,CAAC,kBAAkB,CAAU,CAAA;AAC7F,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,EAAE,CAAC,kBAAkB,EAAE,kBAAkB,CAAU,CAAA;AAE5F,MAAM,CAAC,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C,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAA;IAC1C,IAAI,CAAC,GAAG,CAAC;QAAE,CAAC,IAAI,GAAG,CAAA;IACnB,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;AACxC,CAAC;AAED,mHAAmH;AACnH,MAAM,UAAU,iBAAiB,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IAC7D,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAC7C,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;AACpB,CAAC;AAED,0GAA0G;AAC1G,MAAM,UAAU,UAAU,CAAC,KAAY;IACnC,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;AACzC,CAAC"}
@@ -1,20 +1,5 @@
1
- import type { Oklch } from './oklch.js';
2
- /** Fifty-one steps, index 0 to 50. Fixed by section 5.1, not by the colour maths. */
1
+ export { createScale as deriveScale } from '@newtone-dev/ui-tokens/engine';
2
+ export type { PaletteStep, SeedValue } from '@newtone-dev/ui-tokens/engine';
3
+ /** Fifty-one steps, index 0 to 50, at every Contrast: the HuevOS Core, newtone-color rule 2. */
3
4
  export declare const STEPS = 51;
4
- export interface PaletteStep {
5
- oklch: Oklch;
6
- srgb: string;
7
- }
8
- /**
9
- * One palette's fifty-one steps, from a hue and a saturation ratio.
10
- *
11
- * Derived TWICE, not encoded twice: the hex comes off a vector clamped to the sRGB
12
- * ceiling and the OKLCH channels off one at the P3 ceiling. Where a colour fits inside
13
- * sRGB the two agree; where it does not they do not round-trip, and that is section 6.7
14
- * rather than a rounding artefact.
15
- *
16
- * Quantised at 6 places for `l` and `c` -- which is what makes the L* = 0 endpoint round
17
- * to exactly 0 rather than to 4.66e-10 -- and 2 for `h`, a seed input never searched for.
18
- */
19
- export declare function deriveScale(hue: number, chroma: number): PaletteStep[];
20
5
  //# sourceMappingURL=scale.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scale.d.ts","sourceRoot":"","sources":["../../src/color/scale.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAS,MAAM,YAAY,CAAA;AA0C9C,qFAAqF;AACrF,eAAO,MAAM,KAAK,KAAK,CAAA;AAEvB,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,KAAK,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CAgBtE"}
1
+ {"version":3,"file":"scale.d.ts","sourceRoot":"","sources":["../../src/color/scale.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,WAAW,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAC1E,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAE3E,gGAAgG;AAChG,eAAO,MAAM,KAAK,KAAK,CAAA"}
@@ -1,75 +1,18 @@
1
- // CIE L*, the lightness search, and the fifty-one steps.
1
+ // The fifty-one steps: Newtone's palette engine itself, not a copy of it.
2
2
  //
3
- // Contract sections 6.5 and 3. The shape is `L* = 100 - 2 x step`, computed rather than
4
- // tabulated -- see the blueprint's section 5: "the derivation is computed, never tabulated".
3
+ // `deriveScale` IS `createScale` from `@newtone-dev/ui-tokens/engine` (newtone_ui_tokens/compute/scale.mjs), the
4
+ // module the tokens build runs, imported live since 2026-11-14 -- Joshua's decision, the HuevOS Core, page
5
+ // palette-engine. So what a seed may be here is what it may be there: a hue and a chroma, each one number or a curve
6
+ // `{ start, end, curve? }` across the steps (the HuevOS Core, page newtone-color), and `floor` and `ceiling` the two
7
+ // L* ends a seed's Contrast sets (newtone-color rule 4). Left out, they are 0 and 100: the absolute ladder.
8
+ //
9
+ // **This file held the port's lightness search until 2026-11-14, and `gamut.ts` its gamut maths.** Both were deleted
10
+ // that day, after the old `deriveScale(h, c)` and the engine's `createScale(h, c)` gave the same `{ oklch, srgb }`,
11
+ // byte for byte, at every step of 525 seeds (hues every 15 degrees, c from 0 to 1 by 0.05); the hex was uppercase on
12
+ // both sides. The engine changes only when Joshua asks (palette-engine rule 1), and never from here.
5
13
  //
6
14
  // Private to `color/`. What leaves the folder is decided by index.ts.
7
- import { clamp01, oklchToLinearSrgb, oklchToHex } from './oklch.js';
8
- import { colorAt } from './gamut.js';
9
- // ---------------------------------------------------------------------------
10
- // Section 6.5 -- CIE L*, and the lightness search
11
- // ---------------------------------------------------------------------------
12
- const DELTA = 6 / 29;
13
- const DELTA_SQ = DELTA * DELTA;
14
- const DELTA_CU = DELTA * DELTA * DELTA;
15
- function cieLstar({ l, c, h }) {
16
- const [r, g, b] = oklchToLinearSrgb(l, c, h);
17
- const y = 0.2126 * clamp01(r) + 0.7152 * clamp01(g) + 0.0722 * clamp01(b);
18
- // The linear branch is not decoration: without it the curve has infinite slope at zero
19
- // and the search below cannot converge on the last step.
20
- const f = y > DELTA_CU ? Math.cbrt(y) : y / (3 * DELTA_SQ) + 4 / 29;
21
- return 116 * f - 16;
22
- }
23
- /**
24
- * The colour whose CIE L* is `target`, found by bisection on OKLCH lightness.
25
- *
26
- * The colour is rebuilt at every probe, CHROMA INCLUDED: chroma depends on lightness
27
- * through the ceiling, and luminance depends on chroma. Searching on lightness while
28
- * holding chroma fixed converges on the wrong L.
29
- */
30
- function atLstar(hue, chroma, gamut, target) {
31
- let lo = 0;
32
- let hi = 1;
33
- for (let i = 0; i < 30; i++) {
34
- const mid = (lo + hi) / 2;
35
- if (cieLstar(colorAt(hue, chroma, gamut, mid)) < target)
36
- lo = mid;
37
- else
38
- hi = mid;
39
- }
40
- return colorAt(hue, chroma, gamut, (lo + hi) / 2);
41
- }
42
- // ---------------------------------------------------------------------------
43
- // Section 3 -- the palette
44
- // ---------------------------------------------------------------------------
45
- /** Fifty-one steps, index 0 to 50. Fixed by section 5.1, not by the colour maths. */
15
+ export { createScale as deriveScale } from '@newtone-dev/ui-tokens/engine';
16
+ /** Fifty-one steps, index 0 to 50, at every Contrast: the HuevOS Core, newtone-color rule 2. */
46
17
  export const STEPS = 51;
47
- /**
48
- * One palette's fifty-one steps, from a hue and a saturation ratio.
49
- *
50
- * Derived TWICE, not encoded twice: the hex comes off a vector clamped to the sRGB
51
- * ceiling and the OKLCH channels off one at the P3 ceiling. Where a colour fits inside
52
- * sRGB the two agree; where it does not they do not round-trip, and that is section 6.7
53
- * rather than a rounding artefact.
54
- *
55
- * Quantised at 6 places for `l` and `c` -- which is what makes the L* = 0 endpoint round
56
- * to exactly 0 rather than to 4.66e-10 -- and 2 for `h`, a seed input never searched for.
57
- */
58
- export function deriveScale(hue, chroma) {
59
- const out = [];
60
- for (let step = 0; step < STEPS; step++) {
61
- const target = Math.max(0, 100 - step * 2);
62
- const p3 = atLstar(hue, chroma, 'p3', target);
63
- const srgb = atLstar(hue, chroma, 'srgb', target);
64
- out.push({
65
- oklch: {
66
- l: Number(p3.l.toFixed(6)),
67
- c: Number(p3.c.toFixed(6)),
68
- h: Number(p3.h.toFixed(2)),
69
- },
70
- srgb: oklchToHex(srgb),
71
- });
72
- }
73
- return out;
74
- }
75
18
  //# sourceMappingURL=scale.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scale.js","sourceRoot":"","sources":["../../src/color/scale.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,EAAE;AACF,wFAAwF;AACxF,6FAA6F;AAC7F,EAAE;AACF,sEAAsE;AAEtE,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,8EAA8E;AAC9E,kDAAkD;AAClD,8EAA8E;AA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mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,iHAAiH;AACjH,2GAA2G;AAC3G,qHAAqH;AACrH,qHAAqH;AACrH,4GAA4G;AAC5G,EAAE;AACF,qHAAqH;AACrH,oHAAoH;AACpH,qHAAqH;AACrH,qGAAqG;AACrG,EAAE;AACF,sEAAsE;AAEtE,OAAO,EAAE,WAAW,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAG1E,gGAAgG;AAChG,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAA"}
@@ -1,3 +1,4 @@
1
+ import type { SeedValue } from './scale.js';
1
2
  /**
2
3
  * One palette's seed: a hue and a saturation. Shaped exactly like `seed.json`.
3
4
  *
@@ -5,36 +6,75 @@
5
6
  * hue -- not an amount of chroma. It is therefore comparable across palettes, and `c = 1`
6
7
  * is the gamut boundary rather than an error. See contracts/seeds.md section 1.
7
8
  *
9
+ * **Each is one number, the same at every step, or a curve across the steps** (since 2026-11-14; the HuevOS Core,
10
+ * page newtone-color): `{ start, end, curve? }`, the value at step 0 and at step 50, travelling between them in a
11
+ * straight line, or with `curve: [x1, x2]` along the Bézier whose handles sit on its two caps. The type is the
12
+ * engine's own, `SeedValue`, because the engine is what reads it.
13
+ *
8
14
  * There is no lightness, because lightness is a property of the job a colour is doing and
9
15
  * the job is not known until a role asks for it. There is no `key` either: a key selects
10
16
  * which step a role reads, and roles are references resolved at build time.
11
17
  *
12
- * **`h` and `c` are both narrower than `number`, and the narrowing is not here.** contracts/seeds.md
13
- * section 1.1: a hue is a whole number of degrees and a saturation carries at most two decimal
14
- * places. TypeScript cannot say either of those about a `number`, and anything it could say would
15
- * be erased the moment a seed arrives through `JSON.parse` or an identity API -- which is how every
18
+ * **`h` and `c` are both narrower than their types, and the narrowing is not here.** contracts/seeds.md
19
+ * section 1.1: a hue is a whole number of degrees and a saturation carries at most two decimal places, and a curve's
20
+ * `start` and `end` are held to the same. TypeScript cannot say either of those about a `number`, and anything it
21
+ * could say would be erased the moment a seed arrives through `JSON.parse` or an identity API -- which is how every
16
22
  * seed in this house arrives. **So `validateSeeds` below is the type**, and asked to "fix the type"
17
23
  * this is the honest answer: the interface names the fields, the validator names the values.
18
24
  */
19
25
  export interface Seed {
20
- h: number;
21
- c: number;
26
+ h: SeedValue;
27
+ c: SeedValue;
22
28
  }
23
29
  export type SeedGroup = 'system' | 'custom';
24
30
  /** Group, then palette, then the seed. Any subset; what is absent is inherited. */
25
31
  export type Seeds = Partial<Record<SeedGroup, Record<string, Seed>>>;
32
+ /**
33
+ * A seed's Contrast, `contrast: { light, dark }` in seed.json: how far each end of the ladder pulls in from pure white and
34
+ * pure black, each a level from -2 to +2, 0 where left out (the HuevOS Core, newtone-color rule 4). Both read the
35
+ * same way (Joshua 2026-11-14): +2 brighter, -2 darker. The light end's L* is 96 + 2 x light and the dark end's
36
+ * 8 + 4 x dark, so 0 and 0 run from L* 96 to L* 8, and light +2 with dark -2 is the absolute ladder itself, L* 100 to 0.
37
+ */
38
+ export interface SeedContrast {
39
+ light?: number;
40
+ dark?: number;
41
+ }
26
42
  /**
27
43
  * Every way this seed set breaks the contract, as the build's own message strings.
28
44
  *
29
45
  * **Every violation, not the first.** Somebody who has just edited six numbers should not have
30
46
  * to run six times to find six mistakes -- contracts/seeds.md section 7.
31
47
  *
32
- * Two differences from the build, both deliberate. A palette may be ABSENT here: a runtime seed
48
+ * **A curve is checked as the build checks it** (since 2026-11-14): a system palette's `h` and `c`, and a custom
49
+ * palette's `h`, may each be one, and its refusals are the build's seven curve messages, word for word.
50
+ *
51
+ * Four differences from the build, all deliberate. A palette may be ABSENT here: a runtime seed
33
52
  * is a partial override and what it does not name inherits, where seed.json must name
34
- * everything. And a `custom` saturation is REJECTED here: section 7 delegates that one rule to
35
- * whatever accepts runtime seeds, because seed.json is the authored default where the
36
- * saturation is ours and belongs.
53
+ * everything. A `custom` saturation is REJECTED here, a curve as much as a number: section 7
54
+ * delegates that one rule to whatever accepts runtime seeds, because seed.json is the authored
55
+ * default where the saturation is ours and belongs. A `custom` hue is held to its palette's
56
+ * range here and to the circle in the build: section 7 says so, and issue 184 is where the
57
+ * runtime catches up. And a `custom` palette is refused BY NAME when it comes without its
58
+ * saturation, so that no custom palette is ever accepted (since 2026-11-14): the saturation it
59
+ * needs is seed.json's, which no runtime seed carries, so there is nothing to derive it from.
60
+ * Until then the engine itself threw a TypeError on the missing `c`, past a validator that had
61
+ * said yes -- and this function is the type (`Seed` above), so what it accepts must derive.
37
62
  */
38
63
  export declare function validateSeeds(seeds: Seeds): string[];
39
- export declare function seedProperties(seeds: Seeds, wide?: boolean): Record<string, string>;
64
+ /**
65
+ * Turn a set of seeds into the custom properties that re-derive those palettes.
66
+ *
67
+ * Derivation is atomic: a palette named here has all fifty-one steps recomputed, and one
68
+ * not named is untouched, so it inherits from the enclosing scope. That inheritance is
69
+ * CSS's, not ours -- which is why nesting works to any depth for free.
70
+ *
71
+ * **Two ladders per palette, as the build emits them** (since 2026-11-14): the absolute one, L* 100 to 0, as
72
+ * `--newtone-color-<group>-<name>-<step>`, which `fixed()` and ink() reads; and the one `contrast` sets, from its
73
+ * light end down to its dark end, as `--newtone-color-contrast-<group>-<name>-<step>`, which every role reads. `contrast` is
74
+ * the seed's Contrast, 0 and 0 where left out (L* 96 to 8). With light +2 and dark -2 the pulled-in ladder IS the absolute
75
+ * one, the build emits no second group and its roles read the absolute ladder, so nothing more is written here
76
+ * either. Until 2026-11-14 a preview wrote the absolute ladder alone, which the roles no longer read since Range (now Contrast)
77
+ * arrived, so a Style Book or Appearance preview moved a button's ink and not the roles around it.
78
+ */
79
+ export declare function seedProperties(seeds: Seeds, wide?: boolean, contrast?: SeedContrast): Record<string, string>;
40
80
  //# sourceMappingURL=seeds.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"seeds.d.ts","sourceRoot":"","sources":["../../src/color/seeds.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,IAAI;IACjB,CAAC,EAA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E,YAAiB,GAC5B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA+BxB"}
@@ -3,8 +3,13 @@
3
3
  // This is the boundary the rest of the library meets: `Identity` writes what
4
4
  // `seedProperties` returns onto an element, and CSS inherits it down.
5
5
  //
6
+ // The palettes come from Newtone's palette engine itself (scale.ts: `deriveScale` is the engine's `createScale`,
7
+ // imported live from `@newtone-dev/ui-tokens/engine` since 2026-11-14 -- Joshua's decision, the HuevOS Core, page
8
+ // palette-engine). So a seed's `h` and `c` may each be a curve, as in seed.json, and a preview writes the same two
9
+ // ladders the build emits: the absolute one, and the one Contrast sets, which the roles read.
10
+ //
6
11
  // Private to `color/`. What leaves the folder is decided by index.ts.
7
- import { cssNumber } from './oklch.js';
12
+ import { cssNumber } from '@newtone-dev/ui-tokens/engine/vector';
8
13
  import { deriveScale, STEPS } from './scale.js';
9
14
  /**
10
15
  * Whether to write `oklch()` or a hex.
@@ -17,13 +22,6 @@ import { deriveScale, STEPS } from './scale.js';
17
22
  function prefersOklch() {
18
23
  return typeof CSS !== 'undefined' && CSS.supports?.('color', 'oklch(0% 0 0)') === true;
19
24
  }
20
- /**
21
- * Turn a set of seeds into the custom properties that re-derive those palettes.
22
- *
23
- * Derivation is atomic: a palette named here has all fifty-one steps recomputed, and one
24
- * not named is untouched, so it inherits from the enclosing scope. That inheritance is
25
- * CSS's, not ours -- which is why nesting works to any depth for free.
26
- */
27
25
  // ---------------------------------------------------------------------------
28
26
  // The clamps -- contracts/seeds.md sections 3 and 4
29
27
  // ---------------------------------------------------------------------------
@@ -33,9 +31,13 @@ function prefersOklch() {
33
31
  // dull blue.
34
32
  //
35
33
  // Duplicated from build.mjs rather than shared, and that is a real cost stated plainly: two
36
- // copies of fourteen ranges can drift. They cannot be shared without this repo importing from
37
- // the tokens repo, which section 2's "must never import" exists to prevent, or without a third
38
- // package nobody has asked for.
34
+ // copies of fourteen ranges can drift. Until 2026-11-14 they could not be shared without this
35
+ // repo importing from the tokens repo, which the repo blueprint's section 2 ruled out. **Since
36
+ // 2026-11-14 this repo does import from the tokens repo -- the palette engine and nothing else**
37
+ // (Joshua's decision; the HuevOS Core, page palette-engine) -- and the clamps are not the engine's:
38
+ // they live in build.mjs, which is a command rather than a module, and the runtime's custom hue
39
+ // ranges are deliberately not the build's circle until issue 184 is decided. So the tables stay
40
+ // duplicated, guarded as below.
39
41
  //
40
42
  // ~~**Trigger to unify:** the two disagree once.~~ **THAT TRIGGER FIRED ON 2026-09-13 AND THE
41
43
  // ANSWER WAS NO, WHICH IS WHY IT IS REWORDED RATHER THAN DELETED.** The neutral ceiling was raised
@@ -48,8 +50,8 @@ function prefersOklch() {
48
50
  // SO THE DUPLICATION IS GUARDED AND THE TRIGGER WAS NAMING THE WRONG EVENT. What makes two copies
49
51
  // dangerous is drifting UNNOTICED; these cannot, because neither copy is the source -- the contract
50
52
  // is, and a checker executes it against both. A third package to hold fourteen ranges would remove
51
- // a duplication that costs nothing and add a dependency to a repo whose section 2 forbids importing
52
- // from the other one. governance/deferrals/a-trigger-is-a-signal-to-decide-again.md: the trigger
53
+ // a duplication that costs nothing and add a dependency nobody has asked for.
54
+ // governance/deferrals/a-trigger-is-a-signal-to-decide-again.md: the trigger
53
55
  // fires the question, and the question was answered rather than inherited.
54
56
  //
55
57
  // **Trigger to unify, reworded:** the two disagree once AND NOTHING REPORTS IT -- a range reaches a
@@ -92,17 +94,64 @@ const fmt = (v) => (typeof v === 'number' ? String(v) : JSON.stringify(v));
92
94
  // reached for the same wrong form.
93
95
  const isWholeDegree = (n) => Number.isInteger(n);
94
96
  const isTwoDecimals = (n) => typeof n === 'number' && n === Number(n.toFixed(2));
97
+ const hueRange = (r) => ({ bounds: r, text: `[${r[0]}, ${r[1]}]` });
98
+ const chromaRange = (r) => ({
99
+ bounds: r,
100
+ text: `[${r[0].toFixed(3)}, ${r[1].toFixed(3)}]`,
101
+ });
102
+ const HUE_GRAIN = { ok: isWholeDegree, text: 'is not a whole degree' };
103
+ const CHROMA_GRAIN = { ok: isTwoDecimals, text: 'is finer than two decimals' };
104
+ const CURVE_KEYS = ['start', 'end', 'curve'];
105
+ const isPlainObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
106
+ function checkSeedValue(errs, where, v, range, grain) {
107
+ // Range first, granularity as an `else if`. A value that is both out of range and badly
108
+ // grained reports the range only -- the precision of a number nobody should be looking at
109
+ // yet is not the thing to tell them. Same shape as the build's checkKey.
110
+ const one = (path, n) => {
111
+ if (!inRange(n, range.bounds))
112
+ errs.push(`seed ${path} ${fmt(n)} outside ${range.text}`);
113
+ else if (!grain.ok(n))
114
+ errs.push(`seed ${path} ${fmt(n)} ${grain.text}`);
115
+ };
116
+ if (!isPlainObject(v))
117
+ return one(where, v);
118
+ for (const key of Object.keys(v))
119
+ if (!CURVE_KEYS.includes(key))
120
+ errs.push(`seed ${where} has unknown key ${JSON.stringify(key)}`);
121
+ one(`${where}.start`, v.start);
122
+ one(`${where}.end`, v.end);
123
+ if (typeof v.start === 'number' && v.start === v.end)
124
+ errs.push(`seed ${where} starts and ends at ${fmt(v.start)}: write ${fmt(v.start)}`);
125
+ if (v.curve === undefined)
126
+ return;
127
+ const c = v.curve;
128
+ if (!Array.isArray(c) || c.length !== 2 || !c.every((x) => typeof x === 'number' && x >= 0 && x <= 1))
129
+ errs.push(`seed ${where}.curve ${fmt(c)} is not two numbers from 0 to 1`);
130
+ else if (!c.every(isTwoDecimals))
131
+ errs.push(`seed ${where}.curve ${fmt(c)} is finer than two decimals`);
132
+ else if (c[0] === 0 && c[1] === 1)
133
+ errs.push(`seed ${where}.curve ${fmt(c)} sits on its ends: write it without a curve`);
134
+ }
95
135
  /**
96
136
  * Every way this seed set breaks the contract, as the build's own message strings.
97
137
  *
98
138
  * **Every violation, not the first.** Somebody who has just edited six numbers should not have
99
139
  * to run six times to find six mistakes -- contracts/seeds.md section 7.
100
140
  *
101
- * Two differences from the build, both deliberate. A palette may be ABSENT here: a runtime seed
141
+ * **A curve is checked as the build checks it** (since 2026-11-14): a system palette's `h` and `c`, and a custom
142
+ * palette's `h`, may each be one, and its refusals are the build's seven curve messages, word for word.
143
+ *
144
+ * Four differences from the build, all deliberate. A palette may be ABSENT here: a runtime seed
102
145
  * is a partial override and what it does not name inherits, where seed.json must name
103
- * everything. And a `custom` saturation is REJECTED here: section 7 delegates that one rule to
104
- * whatever accepts runtime seeds, because seed.json is the authored default where the
105
- * saturation is ours and belongs.
146
+ * everything. A `custom` saturation is REJECTED here, a curve as much as a number: section 7
147
+ * delegates that one rule to whatever accepts runtime seeds, because seed.json is the authored
148
+ * default where the saturation is ours and belongs. A `custom` hue is held to its palette's
149
+ * range here and to the circle in the build: section 7 says so, and issue 184 is where the
150
+ * runtime catches up. And a `custom` palette is refused BY NAME when it comes without its
151
+ * saturation, so that no custom palette is ever accepted (since 2026-11-14): the saturation it
152
+ * needs is seed.json's, which no runtime seed carries, so there is nothing to derive it from.
153
+ * Until then the engine itself threw a TypeError on the missing `c`, past a validator that had
154
+ * said yes -- and this function is the type (`Seed` above), so what it accepts must derive.
106
155
  */
107
156
  export function validateSeeds(seeds) {
108
157
  const errs = [];
@@ -112,17 +161,8 @@ export function validateSeeds(seeds) {
112
161
  errs.push(`unknown system palette "${name}"`);
113
162
  continue;
114
163
  }
115
- // Range first, granularity as an `else if`. A value that is both out of range and badly
116
- // grained reports the range only -- the precision of a number nobody should be looking at
117
- // yet is not the thing to tell them. Same shape as the build's checkKey.
118
- if (!inRange(seed?.h, rule.h))
119
- errs.push(`seed color.${name}.h ${fmt(seed?.h)} outside [${rule.h[0]}, ${rule.h[1]}]`);
120
- else if (!isWholeDegree(seed?.h))
121
- errs.push(`seed color.${name}.h ${fmt(seed?.h)} is not a whole degree`);
122
- if (!inRange(seed?.c, rule.c))
123
- errs.push(`seed color.${name}.c ${fmt(seed?.c)} outside [${rule.c[0].toFixed(3)}, ${rule.c[1].toFixed(3)}]`);
124
- else if (!isTwoDecimals(seed?.c))
125
- errs.push(`seed color.${name}.c ${fmt(seed?.c)} is finer than two decimals`);
164
+ checkSeedValue(errs, `color.${name}.h`, seed?.h, hueRange(rule.h), HUE_GRAIN);
165
+ checkSeedValue(errs, `color.${name}.c`, seed?.c, chromaRange(rule.c), CHROMA_GRAIN);
126
166
  }
127
167
  for (const [name, seed] of Object.entries(seeds.custom ?? {})) {
128
168
  const range = CUSTOM[name];
@@ -130,38 +170,84 @@ export function validateSeeds(seeds) {
130
170
  errs.push(`unknown custom palette "${name}"`);
131
171
  continue;
132
172
  }
133
- if (!inRange(seed?.h, range))
134
- errs.push(`seed color.custom.${name}.h ${fmt(seed?.h)} outside [${range[0]}, ${range[1]}]`);
135
- else if (!isWholeDegree(seed?.h))
136
- errs.push(`seed color.custom.${name}.h ${fmt(seed?.h)} is not a whole degree`);
173
+ checkSeedValue(errs, `color.custom.${name}.h`, seed?.h, hueRange(range), HUE_GRAIN);
137
174
  // The rule section 7 could not put in the build's list, and said so: a custom palette is
138
175
  // "the group you customise" along ONE axis. Hue is the person's; saturation and key are ours.
139
176
  if (seed?.c !== undefined)
140
177
  errs.push(`seed color.custom.${name}.c may not be seeded`);
178
+ // And without it there is nothing to derive from: ours is seed.json's, which a runtime seed is never handed
179
+ // (issue 184). Refused by name until 184 is settled, never derived into a TypeError inside the engine.
180
+ else
181
+ errs.push(`seed color.custom.${name} cannot be previewed: its c is Newtone's (issue 184)`);
141
182
  }
142
183
  return errs;
143
184
  }
144
- export function seedProperties(seeds, wide = prefersOklch()) {
185
+ // ---------------------------------------------------------------------------
186
+ // Contrast (Range until 2026-11-15) -- the HuevOS Core, newtone-color rule 4; build.mjs's `CONTRAST`
187
+ // ---------------------------------------------------------------------------
188
+ const CONTRAST_LEVELS = [-2, -1, 0, 1, 2];
189
+ const CONTRAST_KEYS = ['light', 'dark'];
190
+ const darkEnd = (level) => 8 + 4 * level;
191
+ const lightEnd = (level) => 96 + 2 * level;
192
+ // build.mjs's validateContrastSeed, message for message: a level that is not one of the five would derive a ladder no
193
+ // build can emit, so it is refused rather than drawn.
194
+ function contrastErrors(contrast) {
195
+ const errs = [];
196
+ if (contrast == null)
197
+ return errs;
198
+ if (typeof contrast !== 'object' || Array.isArray(contrast))
199
+ return ['seed contrast must be an object: light, dark'];
200
+ const ends = contrast;
201
+ for (const key of Object.keys(ends))
202
+ if (!CONTRAST_KEYS.includes(key))
203
+ errs.push(`unknown contrast key ${JSON.stringify(key)}; it is one of: ${CONTRAST_KEYS.join(', ')}`);
204
+ for (const end of CONTRAST_KEYS)
205
+ if (ends[end] !== undefined && !CONTRAST_LEVELS.includes(ends[end]))
206
+ errs.push(`seed contrast.${end} is ${JSON.stringify(ends[end])}; it is one of: ${CONTRAST_LEVELS.join(', ')}`);
207
+ return errs;
208
+ }
209
+ /**
210
+ * Turn a set of seeds into the custom properties that re-derive those palettes.
211
+ *
212
+ * Derivation is atomic: a palette named here has all fifty-one steps recomputed, and one
213
+ * not named is untouched, so it inherits from the enclosing scope. That inheritance is
214
+ * CSS's, not ours -- which is why nesting works to any depth for free.
215
+ *
216
+ * **Two ladders per palette, as the build emits them** (since 2026-11-14): the absolute one, L* 100 to 0, as
217
+ * `--newtone-color-<group>-<name>-<step>`, which `fixed()` and ink() reads; and the one `contrast` sets, from its
218
+ * light end down to its dark end, as `--newtone-color-contrast-<group>-<name>-<step>`, which every role reads. `contrast` is
219
+ * the seed's Contrast, 0 and 0 where left out (L* 96 to 8). With light +2 and dark -2 the pulled-in ladder IS the absolute
220
+ * one, the build emits no second group and its roles read the absolute ladder, so nothing more is written here
221
+ * either. Until 2026-11-14 a preview wrote the absolute ladder alone, which the roles no longer read since Range (now Contrast)
222
+ * arrived, so a Style Book or Appearance preview moved a button's ink and not the roles around it.
223
+ */
224
+ export function seedProperties(seeds, wide = prefersOklch(), contrast = {}) {
145
225
  // Throwing is heavier than the build's exit code and is the deliberate choice: a seed is
146
226
  // authored by a developer and is never user input, and the alternative -- derive anyway and
147
227
  // warn -- is a screen that is subtly wrong beside a console nobody has open. See the repo
148
228
  // blueprint, section 7.
149
- const errs = validateSeeds(seeds);
229
+ const errs = [...validateSeeds(seeds), ...contrastErrors(contrast)];
150
230
  if (errs.length)
151
231
  throw new Error(`invalid seed:\n${errs.join('\n')}`);
232
+ // Contrast's two ends, as the build sets them, and the build's own test for whether there is a second ladder.
233
+ const floor = darkEnd(contrast?.dark ?? 0);
234
+ const ceiling = lightEnd(contrast?.light ?? 0);
235
+ const pulledIn = floor > 0 || ceiling < 100;
236
+ const paint = ({ oklch, srgb }) => wide ? `oklch(${cssNumber(oklch.l * 100)}% ${cssNumber(oklch.c)} ${cssNumber(oklch.h)})` : srgb;
152
237
  const props = {};
153
238
  for (const group of ['system', 'custom']) {
154
239
  const palettes = seeds[group];
155
240
  if (!palettes)
156
241
  continue;
157
242
  for (const [name, seed] of Object.entries(palettes)) {
158
- const scale = deriveScale(seed.h, seed.c);
159
- for (let step = 0; step < STEPS; step++) {
160
- const { oklch, srgb } = scale[step];
161
- props[`--newtone-color-${group}-${name}-${step}`] = wide
162
- ? `oklch(${cssNumber(oklch.l * 100)}% ${cssNumber(oklch.c)} ${cssNumber(oklch.h)})`
163
- : srgb;
164
- }
243
+ const absolute = deriveScale(seed.h, seed.c);
244
+ for (let step = 0; step < STEPS; step++)
245
+ props[`--newtone-color-${group}-${name}-${step}`] = paint(absolute[step]);
246
+ if (!pulledIn)
247
+ continue;
248
+ const within = deriveScale(seed.h, seed.c, floor, ceiling);
249
+ for (let step = 0; step < STEPS; step++)
250
+ props[`--newtone-color-contrast-${group}-${name}-${step}`] = paint(within[step]);
165
251
  }
166
252
  }
167
253
  return props;