@newtone-dev/ui-react-web 0.45.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/app-frame/app-frame.css +57 -0
- package/dist/app-frame/app-frame.d.ts +2 -1
- package/dist/app-frame/app-frame.d.ts.map +1 -1
- package/dist/app-frame/app-frame.js +2 -1
- package/dist/app-frame/app-frame.js.map +1 -1
- package/dist/app-frame/index.d.ts +1 -1
- package/dist/app-frame/index.d.ts.map +1 -1
- package/dist/app-frame/launcher/launcher.d.ts.map +1 -1
- package/dist/app-frame/launcher/launcher.js +5 -3
- package/dist/app-frame/launcher/launcher.js.map +1 -1
- package/dist/app-frame/parts.d.ts +22 -1
- package/dist/app-frame/parts.d.ts.map +1 -1
- package/dist/app-frame/parts.js +15 -2
- package/dist/app-frame/parts.js.map +1 -1
- package/dist/beside/beside.css +4 -0
- package/dist/card-box/card-box.css +8 -2
- package/dist/card-box/card-box.d.ts.map +1 -1
- package/dist/card-box/card-box.js +1 -1
- package/dist/card-box/card-box.js.map +1 -1
- package/dist/color/index.d.ts +4 -4
- package/dist/color/index.d.ts.map +1 -1
- package/dist/color/index.js +17 -15
- package/dist/color/index.js.map +1 -1
- package/dist/color/oklch.d.ts +6 -27
- package/dist/color/oklch.d.ts.map +1 -1
- package/dist/color/oklch.js +23 -61
- package/dist/color/oklch.js.map +1 -1
- package/dist/color/scale.d.ts +3 -18
- package/dist/color/scale.d.ts.map +1 -1
- package/dist/color/scale.js +13 -70
- package/dist/color/scale.js.map +1 -1
- package/dist/color/seeds.d.ts +51 -11
- package/dist/color/seeds.d.ts.map +1 -1
- package/dist/color/seeds.js +127 -41
- package/dist/color/seeds.js.map +1 -1
- package/dist/curve-field/curve-field.css +280 -0
- package/dist/curve-field/curve-field.d.ts +105 -0
- package/dist/curve-field/curve-field.d.ts.map +1 -0
- package/dist/curve-field/curve-field.js +532 -0
- package/dist/curve-field/curve-field.js.map +1 -0
- package/dist/curve-field/index.d.ts +3 -0
- package/dist/curve-field/index.d.ts.map +1 -0
- package/dist/curve-field/index.js +2 -0
- package/dist/curve-field/index.js.map +1 -0
- package/dist/diagram/diagram.css +63 -0
- package/dist/diagram/diagram.d.ts +63 -0
- package/dist/diagram/diagram.d.ts.map +1 -0
- package/dist/diagram/diagram.js +73 -0
- package/dist/diagram/diagram.js.map +1 -0
- package/dist/diagram/geometry.d.ts +60 -0
- package/dist/diagram/geometry.d.ts.map +1 -0
- package/dist/diagram/geometry.js +93 -0
- package/dist/diagram/geometry.js.map +1 -0
- package/dist/diagram/index.d.ts +7 -0
- package/dist/diagram/index.d.ts.map +1 -0
- package/dist/diagram/index.js +4 -0
- package/dist/diagram/index.js.map +1 -0
- package/dist/diagram/layout.d.ts +41 -0
- package/dist/diagram/layout.d.ts.map +1 -0
- package/dist/diagram/layout.js +157 -0
- package/dist/diagram/layout.js.map +1 -0
- package/dist/document/document.d.ts +7 -2
- package/dist/document/document.d.ts.map +1 -1
- package/dist/document/document.js +22 -4
- package/dist/document/document.js.map +1 -1
- package/dist/dynamic-range/dynamic-range.css +100 -0
- package/dist/dynamic-range/dynamic-range.d.ts +27 -0
- package/dist/dynamic-range/dynamic-range.d.ts.map +1 -0
- package/dist/dynamic-range/dynamic-range.js +20 -0
- package/dist/dynamic-range/dynamic-range.js.map +1 -0
- package/dist/dynamic-range/index.d.ts +3 -0
- package/dist/dynamic-range/index.d.ts.map +1 -0
- package/dist/dynamic-range/index.js +2 -0
- package/dist/dynamic-range/index.js.map +1 -0
- package/dist/file-grid/file-grid.css +65 -0
- package/dist/file-grid/file-grid.d.ts +34 -1
- package/dist/file-grid/file-grid.d.ts.map +1 -1
- package/dist/file-grid/file-grid.js +63 -2
- package/dist/file-grid/file-grid.js.map +1 -1
- package/dist/file-grid/index.d.ts +2 -2
- package/dist/file-grid/index.d.ts.map +1 -1
- package/dist/file-grid/index.js +1 -1
- package/dist/file-grid/index.js.map +1 -1
- package/dist/floating-bar/floating-bar.css +37 -15
- package/dist/floating-bar/floating-bar.d.ts +16 -1
- package/dist/floating-bar/floating-bar.d.ts.map +1 -1
- package/dist/floating-bar/floating-bar.js +58 -15
- package/dist/floating-bar/floating-bar.js.map +1 -1
- package/dist/floating-bar/index.d.ts +1 -1
- package/dist/floating-bar/index.d.ts.map +1 -1
- package/dist/identity/identity.d.ts +11 -3
- package/dist/identity/identity.d.ts.map +1 -1
- package/dist/identity/identity.js +8 -4
- package/dist/identity/identity.js.map +1 -1
- package/dist/index.d.ts +16 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/inspector/index.d.ts +1 -1
- package/dist/inspector/index.d.ts.map +1 -1
- package/dist/inspector/inspector.css +220 -6
- package/dist/inspector/inspector.d.ts +122 -3
- package/dist/inspector/inspector.d.ts.map +1 -1
- package/dist/inspector/inspector.js +75 -5
- package/dist/inspector/inspector.js.map +1 -1
- package/dist/material/material.css +8 -2
- package/dist/number-field/number-field.css +13 -0
- package/dist/number-field/number-field.d.ts +6 -1
- package/dist/number-field/number-field.d.ts.map +1 -1
- package/dist/number-field/number-field.js +10 -2
- package/dist/number-field/number-field.js.map +1 -1
- package/dist/pop-menu/pop-menu.d.ts +3 -0
- package/dist/pop-menu/pop-menu.d.ts.map +1 -1
- package/dist/pop-menu/pop-menu.js +12 -6
- package/dist/pop-menu/pop-menu.js.map +1 -1
- package/dist/prompt-field/prompt-field.css +3 -3
- package/dist/prompt-field/prompt-field.d.ts +3 -3
- package/dist/prompt-field/prompt-field.d.ts.map +1 -1
- package/dist/prompt-field/prompt-field.js +10 -4
- package/dist/prompt-field/prompt-field.js.map +1 -1
- package/dist/seed-contrast-field/index.d.ts +5 -0
- package/dist/seed-contrast-field/index.d.ts.map +1 -0
- package/dist/seed-contrast-field/index.js +3 -0
- package/dist/seed-contrast-field/index.js.map +1 -0
- package/dist/seed-contrast-field/seed-contrast-field.css +11 -0
- package/dist/{seed-dark-limit-field/seed-dark-limit-field.d.ts → seed-contrast-field/seed-contrast-field.d.ts} +14 -14
- package/dist/seed-contrast-field/seed-contrast-field.d.ts.map +1 -0
- package/dist/seed-contrast-field/seed-contrast-field.js +18 -0
- package/dist/seed-contrast-field/seed-contrast-field.js.map +1 -0
- package/dist/seed-contrast-field/seed-contrast-slider.css +112 -0
- package/dist/seed-contrast-field/seed-contrast-slider.d.ts +22 -0
- package/dist/seed-contrast-field/seed-contrast-slider.d.ts.map +1 -0
- package/dist/seed-contrast-field/seed-contrast-slider.js +75 -0
- package/dist/seed-contrast-field/seed-contrast-slider.js.map +1 -0
- package/dist/seed-steps/index.d.ts +1 -1
- package/dist/seed-steps/index.js +1 -1
- package/dist/seed-steps/seed-steps.css +1 -1
- package/dist/seed-steps/seed-steps.js +1 -1
- package/dist/seed-steps/seed-steps.js.map +1 -1
- package/dist/shell/shell.css +31 -21
- package/dist/split/split.css +8 -5
- package/dist/step-list/index.d.ts +1 -1
- package/dist/step-list/index.d.ts.map +1 -1
- package/dist/step-list/step-list.css +75 -2
- package/dist/step-list/step-list.d.ts +121 -11
- package/dist/step-list/step-list.d.ts.map +1 -1
- package/dist/step-list/step-list.js +203 -37
- package/dist/step-list/step-list.js.map +1 -1
- package/dist/step-strip/index.d.ts +3 -0
- package/dist/step-strip/index.d.ts.map +1 -0
- package/dist/step-strip/index.js +2 -0
- package/dist/step-strip/index.js.map +1 -0
- package/dist/step-strip/step-strip.css +118 -0
- package/dist/step-strip/step-strip.d.ts +52 -0
- package/dist/step-strip/step-strip.d.ts.map +1 -0
- package/dist/step-strip/step-strip.js +47 -0
- package/dist/step-strip/step-strip.js.map +1 -0
- package/dist/surface/surface.css +112 -0
- package/dist/workbench/workbench.css +50 -0
- package/dist/workbench/workbench.d.ts +25 -1
- package/dist/workbench/workbench.d.ts.map +1 -1
- package/dist/workbench/workbench.js +11 -2
- package/dist/workbench/workbench.js.map +1 -1
- package/package.json +27 -5
- package/dist/color/gamut.d.ts +0 -20
- package/dist/color/gamut.d.ts.map +0 -1
- package/dist/color/gamut.js +0 -72
- package/dist/color/gamut.js.map +0 -1
- package/dist/seed-dark-limit-field/index.d.ts +0 -3
- package/dist/seed-dark-limit-field/index.d.ts.map +0 -1
- package/dist/seed-dark-limit-field/index.js +0 -2
- package/dist/seed-dark-limit-field/index.js.map +0 -1
- package/dist/seed-dark-limit-field/seed-dark-limit-field.css +0 -10
- package/dist/seed-dark-limit-field/seed-dark-limit-field.d.ts.map +0 -1
- package/dist/seed-dark-limit-field/seed-dark-limit-field.js +0 -18
- 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":"
|
|
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"}
|
package/dist/color/oklch.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
// The OKLCH colour space
|
|
2
|
-
//
|
|
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
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
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
|
|
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
|
|
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
|
|
64
|
-
|
|
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
|
-
|
|
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
|
package/dist/color/oklch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oklch.js","sourceRoot":"","sources":["../../src/color/oklch.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"oklch.js","sourceRoot":"","sources":["../../src/color/oklch.ts"],"names":[],"mappings":"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"}
|
package/dist/color/scale.d.ts
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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":"
|
|
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"}
|
package/dist/color/scale.js
CHANGED
|
@@ -1,75 +1,18 @@
|
|
|
1
|
-
//
|
|
1
|
+
// The fifty-one steps: Newtone's palette engine itself, not a copy of it.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
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
|
-
|
|
8
|
-
|
|
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
|
package/dist/color/scale.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scale.js","sourceRoot":"","sources":["../../src/color/scale.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"scale.js","sourceRoot":"","sources":["../../src/color/scale.ts"],"names":[],"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"}
|
package/dist/color/seeds.d.ts
CHANGED
|
@@ -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
|
|
13
|
-
* section 1.1: a hue is a whole number of degrees and a saturation carries at most two decimal
|
|
14
|
-
*
|
|
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:
|
|
21
|
-
c:
|
|
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
|
-
*
|
|
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.
|
|
35
|
-
* whatever accepts runtime seeds, because seed.json is the authored
|
|
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
|
-
|
|
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
|
|
1
|
+
{"version":3,"file":"seeds.d.ts","sourceRoot":"","sources":["../../src/color/seeds.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,YAAY,CAAA;AAMxD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,IAAI;IACjB,CAAC,EAAE,SAAS,CAAA;IACZ,CAAC,EAAE,SAAS,CAAA;CACf;AAED,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAE3C,mFAAmF;AACnF,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;AAEpE;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB;AAyID;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE,CA6BpD;AA2BD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC1B,KAAK,EAAE,KAAK,EACZ,IAAI,UAAiB,EACrB,QAAQ,GAAE,YAAiB,GAC5B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA+BxB"}
|
package/dist/color/seeds.js
CHANGED
|
@@ -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 '
|
|
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.
|
|
37
|
-
// the tokens repo, which
|
|
38
|
-
//
|
|
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
|
|
52
|
-
//
|
|
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
|
-
*
|
|
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.
|
|
104
|
-
* whatever accepts runtime seeds, because seed.json is the authored
|
|
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
|
-
|
|
116
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
159
|
-
for (let step = 0; step < STEPS; step++)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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;
|