@ng-native/fabric 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aria-props.d.ts +16 -0
- package/dist/aria-props.js +78 -0
- package/dist/aria-props.js.map +1 -0
- package/dist/color-mix.d.ts +12 -2
- package/dist/color-mix.js +16 -5
- package/dist/color-mix.js.map +1 -1
- package/dist/css.d.ts +160 -5
- package/dist/css.js +842 -87
- package/dist/css.js.map +1 -1
- package/dist/defer-triggers.js +3 -1
- package/dist/defer-triggers.js.map +1 -1
- package/dist/element-styles.d.ts +15 -0
- package/dist/element-styles.js +103 -0
- package/dist/element-styles.js.map +1 -0
- package/dist/engine.d.ts +289 -20
- package/dist/engine.js +1045 -120
- package/dist/engine.js.map +1 -1
- package/dist/font-faces.d.ts +5 -2
- package/dist/font-faces.js +13 -2
- package/dist/font-faces.js.map +1 -1
- package/dist/host.d.ts +7 -0
- package/dist/host.js +7 -0
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/inline-derived-token.d.ts +3 -12
- package/dist/inline-derived-token.js +249 -13
- package/dist/inline-derived-token.js.map +1 -1
- package/dist/inline-token.d.ts +12 -4
- package/dist/inline-token.js +76 -5
- package/dist/inline-token.js.map +1 -1
- package/dist/inline-transform.d.ts +5 -1
- package/dist/inline-transform.js +34 -6
- package/dist/inline-transform.js.map +1 -1
- package/dist/transition.d.ts +15 -4
- package/dist/transition.js +21 -3
- package/dist/transition.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The web's `aria-*` attributes as the props native reads, mapped as React Native's `View.js`
|
|
3
|
+
* maps them before a view's props reach native.
|
|
4
|
+
*
|
|
5
|
+
* An attribute is text, on any element that commits a view: the host of an app's own component
|
|
6
|
+
* has no input to take one, and a label that is dropped fails silently for exactly the people who
|
|
7
|
+
* cannot see that it is missing. A prop the element already has is its own answer and is left:
|
|
8
|
+
* the primitives of `@ng-native/components` take these as inputs and write the props themselves.
|
|
9
|
+
*/
|
|
10
|
+
type Props = Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Writes into `props` what the `aria-*` attributes among `attributes` say, wherever `props` does
|
|
13
|
+
* not say it already.
|
|
14
|
+
*/
|
|
15
|
+
export declare function applyAria(attributes: Props, props: Props): void;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The web's `aria-*` attributes as the props native reads, mapped as React Native's `View.js`
|
|
3
|
+
* maps them before a view's props reach native.
|
|
4
|
+
*
|
|
5
|
+
* An attribute is text, on any element that commits a view: the host of an app's own component
|
|
6
|
+
* has no input to take one, and a label that is dropped fails silently for exactly the people who
|
|
7
|
+
* cannot see that it is missing. A prop the element already has is its own answer and is left:
|
|
8
|
+
* the primitives of `@ng-native/components` take these as inputs and write the props themselves.
|
|
9
|
+
*/
|
|
10
|
+
/** `'true'` and `'false'` as the booleans they say; anything else, `mixed` included, as written. */
|
|
11
|
+
const flag = (value) => value === 'true' || value === '' ? true : value === 'false' ? false : value;
|
|
12
|
+
/** Text as the number it says, and nothing where it says none: `NaN` is no value to send. */
|
|
13
|
+
const number = (value) => {
|
|
14
|
+
if (typeof value !== 'string')
|
|
15
|
+
return value;
|
|
16
|
+
const said = value.trim() === '' ? NaN : Number(value);
|
|
17
|
+
return Number.isFinite(said) ? said : undefined;
|
|
18
|
+
};
|
|
19
|
+
/** The attributes that are one prop each, with how the value is read. */
|
|
20
|
+
const ONE_TO_ONE = {
|
|
21
|
+
'aria-label': ['accessibilityLabel', (value) => value],
|
|
22
|
+
'aria-labelledby': [
|
|
23
|
+
'accessibilityLabelledBy',
|
|
24
|
+
(value) => (typeof value === 'string' ? value.split(/\s*,\s*/) : value),
|
|
25
|
+
],
|
|
26
|
+
'aria-live': ['accessibilityLiveRegion', (value) => (value === 'off' ? 'none' : value)],
|
|
27
|
+
'aria-hidden': ['accessibilityElementsHidden', flag],
|
|
28
|
+
'aria-modal': ['accessibilityViewIsModal', flag],
|
|
29
|
+
};
|
|
30
|
+
/** The attributes gathered into `accessibilityState`, by the key each is there. */
|
|
31
|
+
const STATE = {
|
|
32
|
+
'aria-busy': 'busy',
|
|
33
|
+
'aria-checked': 'checked',
|
|
34
|
+
'aria-disabled': 'disabled',
|
|
35
|
+
'aria-expanded': 'expanded',
|
|
36
|
+
'aria-selected': 'selected',
|
|
37
|
+
};
|
|
38
|
+
/** The attributes gathered into `accessibilityValue`. */
|
|
39
|
+
const VALUE = {
|
|
40
|
+
'aria-valuemax': 'max',
|
|
41
|
+
'aria-valuemin': 'min',
|
|
42
|
+
'aria-valuenow': 'now',
|
|
43
|
+
'aria-valuetext': 'text',
|
|
44
|
+
};
|
|
45
|
+
/** `attributes` gathered into one object by `keys`, or undefined when it has none of them. */
|
|
46
|
+
function gathered(attributes, keys, read) {
|
|
47
|
+
let out;
|
|
48
|
+
for (const attribute of Object.keys(keys)) {
|
|
49
|
+
const value = attributes[attribute];
|
|
50
|
+
const said = value === undefined || value === null ? undefined : read(keys[attribute], value);
|
|
51
|
+
if (said !== undefined)
|
|
52
|
+
(out ??= {})[keys[attribute]] = said;
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Writes into `props` what the `aria-*` attributes among `attributes` say, wherever `props` does
|
|
58
|
+
* not say it already.
|
|
59
|
+
*/
|
|
60
|
+
export function applyAria(attributes, props) {
|
|
61
|
+
for (const attribute of Object.keys(ONE_TO_ONE)) {
|
|
62
|
+
const value = attributes[attribute];
|
|
63
|
+
const [prop, read] = ONE_TO_ONE[attribute];
|
|
64
|
+
if (value !== undefined && value !== null && props[prop] === undefined)
|
|
65
|
+
props[prop] = read(value);
|
|
66
|
+
}
|
|
67
|
+
// As `View.js`: a hidden element takes what is inside it out of the accessibility tree on
|
|
68
|
+
// Android too, which has no prop of its own for that.
|
|
69
|
+
if (flag(attributes['aria-hidden']) === true)
|
|
70
|
+
props['importantForAccessibility'] ??= 'no-hide-descendants';
|
|
71
|
+
const state = gathered(attributes, STATE, (_, value) => flag(value));
|
|
72
|
+
if (state)
|
|
73
|
+
props['accessibilityState'] ??= state;
|
|
74
|
+
const value = gathered(attributes, VALUE, (key, part) => (key === 'text' ? part : number(part)));
|
|
75
|
+
if (value)
|
|
76
|
+
props['accessibilityValue'] ??= value;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=aria-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aria-props.js","sourceRoot":"","sources":["../src/aria-props.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,oGAAoG;AACpG,MAAM,IAAI,GAAG,CAAC,KAAc,EAAW,EAAE,CACvC,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AAE9E,6FAA6F;AAC7F,MAAM,MAAM,GAAG,CAAC,KAAc,EAAW,EAAE;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvD,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC,CAAC;AAEF,yEAAyE;AACzE,MAAM,UAAU,GAEZ;IACF,YAAY,EAAE,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC;IACtD,iBAAiB,EAAE;QACjB,yBAAy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ped as React Native's `View.js`\n * maps them before a view's props reach native.\n *\n * An attribute is text, on any element that commits a view: the host of an app's own component\n * has no input to take one, and a label that is dropped fails silently for exactly the people who\n * cannot see that it is missing. A prop the element already has is its own answer and is left:\n * the primitives of `@ng-native/components` take these as inputs and write the props themselves.\n */\n\ntype Props = Record<string, unknown>;\n\n/** `'true'` and `'false'` as the booleans they say; anything else, `mixed` included, as written. */\nconst flag = (value: unknown): unknown =>\n value === 'true' || value === '' ? true : value === 'false' ? false : value;\n\n/** Text as the number it says, and nothing where it says none: `NaN` is no value to send. */\nconst number = (value: unknown): unknown => {\n if (typeof value !== 'string') return value;\n const said = value.trim() === '' ? NaN : Number(value);\n return Number.isFinite(said) ? said : undefined;\n};\n\n/** The attributes that are one prop each, with how the value is read. */\nconst ONE_TO_ONE: Readonly<\n Record<string, readonly [prop: string, read: (value: unknown) => unknown]>\n> = {\n 'aria-label': ['accessibilityLabel', (value) => value],\n 'aria-labelledby': [\n 'accessibilityLabelledBy',\n (value) => (typeof value === 'string' ? value.split(/\\s*,\\s*/) : value),\n ],\n 'aria-live': ['accessibilityLiveRegion', (value) => (value === 'off' ? 'none' : value)],\n 'aria-hidden': ['accessibilityElementsHidden', flag],\n 'aria-modal': ['accessibilityViewIsModal', flag],\n};\n\n/** The attributes gathered into `accessibilityState`, by the key each is there. */\nconst STATE: Readonly<Record<string, string>> = {\n 'aria-busy': 'busy',\n 'aria-checked': 'checked',\n 'aria-disabled': 'disabled',\n 'aria-expanded': 'expanded',\n 'aria-selected': 'selected',\n};\n\n/** The attributes gathered into `accessibilityValue`. */\nconst VALUE: Readonly<Record<string, string>> = {\n 'aria-valuemax': 'max',\n 'aria-valuemin': 'min',\n 'aria-valuenow': 'now',\n 'aria-valuetext': 'text',\n};\n\n/** `attributes` gathered into one object by `keys`, or undefined when it has none of them. */\nfunction gathered(\n attributes: Props,\n keys: Readonly<Record<string, string>>,\n read: (key: string, value: unknown) => unknown,\n): Props | undefined {\n let out: Props | undefined;\n for (const attribute of Object.keys(keys)) {\n const value = attributes[attribute];\n const said = value === undefined || value === null ? undefined : read(keys[attribute]!, value);\n if (said !== undefined) (out ??= {})[keys[attribute]!] = said;\n }\n return out;\n}\n\n/**\n * Writes into `props` what the `aria-*` attributes among `attributes` say, wherever `props` does\n * not say it already.\n */\nexport function applyAria(attributes: Props, props: Props): void {\n for (const attribute of Object.keys(ONE_TO_ONE)) {\n const value = attributes[attribute];\n const [prop, read] = ONE_TO_ONE[attribute]!;\n if (value !== undefined && value !== null && props[prop] === undefined)\n props[prop] = read(value);\n }\n // As `View.js`: a hidden element takes what is inside it out of the accessibility tree on\n // Android too, which has no prop of its own for that.\n if (flag(attributes['aria-hidden']) === true)\n props['importantForAccessibility'] ??= 'no-hide-descendants';\n const state = gathered(attributes, STATE, (_, value) => flag(value));\n if (state) props['accessibilityState'] ??= state;\n const value = gathered(attributes, VALUE, (key, part) => (key === 'text' ? part : number(part)));\n if (value) props['accessibilityValue'] ??= value;\n}\n"]}
|
package/dist/color-mix.d.ts
CHANGED
|
@@ -7,9 +7,14 @@ export type Vector = [number, number, number];
|
|
|
7
7
|
export declare function into(space: MixSpace, rgb: Vector): Vector;
|
|
8
8
|
/** Back to sRGB, 0 to 1, brought inside the gamut where the space reaches past it. */
|
|
9
9
|
export declare function outOf(space: MixSpace, coords: Vector): Vector;
|
|
10
|
-
/**
|
|
10
|
+
/** A colour's channels, 0 to 255 and unrounded, and its alpha: what one mix hands another. */
|
|
11
|
+
export type Rgba = readonly [r: number, g: number, b: number, alpha: number];
|
|
12
|
+
/**
|
|
13
|
+
* One side of a mix: a colour as native paints it, or the unrounded channels of another mix, and
|
|
14
|
+
* the percentage written beside it.
|
|
15
|
+
*/
|
|
11
16
|
export interface MixSide {
|
|
12
|
-
readonly colour: string;
|
|
17
|
+
readonly colour: string | Rgba;
|
|
13
18
|
readonly percentage?: number;
|
|
14
19
|
}
|
|
15
20
|
/**
|
|
@@ -18,3 +23,8 @@ export interface MixSide {
|
|
|
18
23
|
* two percentages come to zero, which CSS says is not a colour at all.
|
|
19
24
|
*/
|
|
20
25
|
export declare function mixColours(space: MixSpace, a: MixSide, b: MixSide, hue?: HueMethod): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* The same mix, unrounded, for a mix around it to take as one of its sides: CSS works a nested
|
|
28
|
+
* mix out in full and rounds only the colour at the end.
|
|
29
|
+
*/
|
|
30
|
+
export declare function mixChannels(space: MixSpace, a: MixSide, b: MixSide, hue?: HueMethod): Rgba | undefined;
|
package/dist/color-mix.js
CHANGED
|
@@ -241,8 +241,20 @@ const HUE_LIFTS = {
|
|
|
241
241
|
* two percentages come to zero, which CSS says is not a colour at all.
|
|
242
242
|
*/
|
|
243
243
|
export function mixColours(space, a, b, hue = 'shorter') {
|
|
244
|
-
const
|
|
245
|
-
|
|
244
|
+
const mixed = mixChannels(space, a, b, hue);
|
|
245
|
+
if (!mixed)
|
|
246
|
+
return undefined;
|
|
247
|
+
const [r, g, bl] = mixed.map((c) => Math.round(c));
|
|
248
|
+
const opacity = Math.round(mixed[3] * 1000) / 1000;
|
|
249
|
+
return opacity >= 1 ? `rgb(${r}, ${g}, ${bl})` : `rgba(${r}, ${g}, ${bl}, ${opacity})`;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* The same mix, unrounded, for a mix around it to take as one of its sides: CSS works a nested
|
|
253
|
+
* mix out in full and rounds only the colour at the end.
|
|
254
|
+
*/
|
|
255
|
+
export function mixChannels(space, a, b, hue = 'shorter') {
|
|
256
|
+
const first = typeof a.colour === 'string' ? parseColor(a.colour) : a.colour;
|
|
257
|
+
const second = typeof b.colour === 'string' ? parseColor(b.colour) : b.colour;
|
|
246
258
|
const weights = weightsOf(a.percentage, b.percentage);
|
|
247
259
|
if (!first || !second || !weights)
|
|
248
260
|
return undefined;
|
|
@@ -255,9 +267,8 @@ export function mixColours(space, a, b, hue = 'shorter') {
|
|
|
255
267
|
const { t, alphaScale } = weights;
|
|
256
268
|
const alpha = c1.alpha * (1 - t) + c2.alpha * t;
|
|
257
269
|
const mixed = interpolate(c1, c2, t, alpha, hueAt);
|
|
258
|
-
const [r, g, bl] = outOf(space, mixed).map((c) =>
|
|
259
|
-
|
|
260
|
-
return opacity >= 1 ? `rgb(${r}, ${g}, ${bl})` : `rgba(${r}, ${g}, ${bl}, ${opacity})`;
|
|
270
|
+
const [r, g, bl] = outOf(space, mixed).map((c) => c * 255);
|
|
271
|
+
return [r, g, bl, alpha * alphaScale];
|
|
261
272
|
}
|
|
262
273
|
/**
|
|
263
274
|
* CSS Color 5, 2.1: missing percentages take what the other leaves, or half each; the second
|
package/dist/color-mix.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-mix.js","sourceRoot":"","sources":["../src/color-mix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAK7C,MAAM,CAAC,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAW;IAC/D,MAAM;IACN,OAAO;IACP,OAAO;IACP,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;CACN,CAAC,CAAC;AAMH,MAAM,KAAK,GAAG,CAAC,CAAoB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAS,EAAU,EAAE,CAChE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAW,CAAC;AAExD,MAAM,YAAY,GAAa;IAC7B,CAAC,GAAG,EAAE,kBAAkB,EAAE,kBAAkB,CAAC;IAC7C,CAAC,GAAG,EAAE,CAAC,kBAAkB,EAAE,CAAC,kBAAkB,CAAC;IAC/C,CAAC,GAAG,EAAE,CAAC,kBAAkB,EAAE,CAAC,kBAAkB,CAAC;CAChD,CAAC;AACF,MAAM,UAAU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E,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAChC,IAAI,CAAC,KAAK,KAAK;YAAE,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC;QACpE,MAAM,QAAQ,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAE,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAE,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC;QACnF,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC;IAC5C,CAAC,CAAW,CAAC;IACb,IAAI,KAAK,KAAK,SAAS;QAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAE,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IAC5E,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * `color-mix()` worked out on device, for a mix with a token in it.\n *\n * The compiler folds a mix of literal colours at build time (lightningcss does the arithmetic); a\n * mix with a `var()` in it can only be done once the token is known, so it is done here, with CSS\n * Color 4 and 5's own arithmetic: each colour converted into the named space, premultiplied by its\n * alpha, interpolated (a hue the shorter way round), and brought back to the sRGB native paints,\n * inside its gamut by CSS Color 4's chroma reduction rather than a clip.\n *\n * The matrices and the gamut mapping are the ones `@ng-native/metro`'s `color-spaces.cjs` uses to\n * convert a literal colour at build time, copied here because the engine cannot depend on the\n * build step; the tests hold the two to the same answers.\n */\nimport { parseColor } from './transition.ts';\n\n/** The spaces a mix is worked out in: every one the compiler also folds a literal mix in. */\nexport type MixSpace = 'srgb' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'hsl' | 'hwb';\n\nexport const MIX_SPACES: ReadonlySet<string> = new Set<MixSpace>([\n 'srgb',\n 'oklab',\n 'oklch',\n 'lab',\n 'lch',\n 'hsl',\n 'hwb',\n]);\n\nexport type HueMethod = 'shorter' | 'longer' | 'increasing' | 'decreasing';\n\nexport type Vector = [number, number, number];\n\nconst times = (m: readonly Vector[], [x, y, z]: Vector): Vector =>\n m.map(([a, b, c]) => a * x + b * y + c * z) as Vector;\n\nconst OKLAB_TO_LMS: Vector[] = [\n [1.0, 0.3963377773761749, 0.2158037573099136],\n [1.0, -0.1055613458156586, -0.0638541728258133],\n [1.0, -0.0894841775298119, -1.2914855480194092],\n];\nconst LMS_TO_XYZ: Vector[] = [\n [1.2268798758459243, -0.5578149944602171, 0.2813910456659647],\n [-0.0405757452148008, 1.112286803280317, -0.0717110580655164],\n [-0.0763729366746601, -0.4214933324022432, 1.5869240198367816],\n];\nconst XYZ_TO_LMS: Vector[] = [\n [0.819022437996703, 0.3619062600528904, -0.1288737815209879],\n [0.0329836539323885, 0.9292868615863434, 0.0361446663506424],\n [0.0481771893596242, 0.2642395317527308, 0.6335478284694309],\n];\nconst LMS_TO_OKLAB: Vector[] = [\n [0.210454268309314, 0.7936177747023054, -0.0040720430116193],\n [1.9779985324311684, -2.4285922420485799, 0.450593709617411],\n [0.0259040424655478, 0.7827717124575296, -0.8086757549230774],\n];\nconst XYZ_TO_LINEAR_SRGB: Vector[] = [\n [3.2409699419045226, -1.537383177570094, -0.4986107602930034],\n [-0.9692436362808796, 1.8759675015077202, 0.04155505740717559],\n [0.05563007969699366, -0.20397695888897652, 1.0569715142428786],\n];\nconst LINEAR_SRGB_TO_XYZ: Vector[] = [\n [0.41239079926595934, 0.357584339383878, 0.1804807884018343],\n [0.21263900587151027, 0.715168678767756, 0.07219231536073371],\n [0.01933081871559182, 0.11919477979462598, 0.9505321522496607],\n];\n/** Bradford chromatic adaptation between `lab()`'s D50 white and sRGB's D65. */\nconst D50_TO_D65: Vector[] = [\n [0.955473421488075, -0.02309845494876471, 0.06325924320057072],\n [-0.0283697093338637, 1.0099953980813041, 0.021041441191917323],\n [0.012314014864481998, -0.020507649298898964, 1.330365926242124],\n];\nconst D65_TO_D50: Vector[] = [\n [1.0479298208405488, 0.022946793341019088, -0.05019222954313557],\n [0.029627815688159344, 0.990434484573249, -0.01707382502938514],\n [-0.009243058152591178, 0.015055144896577895, 0.7518742899580008],\n];\nconst D50_WHITE: Vector = [0.3457 / 0.3585, 1, (1 - 0.3457 - 0.3585) / 0.3585];\n\nconst encode = (c: number) =>\n Math.sign(c) * (Math.abs(c) > 0.0031308 ? 1.055 * Math.abs(c) ** (1 / 2.4) - 0.055 : 12.92 * c);\nconst decode = (c: number) =>\n Math.sign(c) * (Math.abs(c) > 0.04045 ? ((Math.abs(c) + 0.055) / 1.055) ** 2.4 : c / 12.92);\n\nconst srgbToXyz = (rgb: Vector) => times(LINEAR_SRGB_TO_XYZ, rgb.map(decode) as Vector);\nconst xyzToSrgb = (xyz: Vector) => times(XYZ_TO_LINEAR_SRGB, xyz).map(encode) as Vector;\nconst xyzToOklab = (xyz: Vector) =>\n times(LMS_TO_OKLAB, times(XYZ_TO_LMS, xyz).map(Math.cbrt) as Vector);\nconst oklabToXyz = (lab: Vector) =>\n times(LMS_TO_XYZ, times(OKLAB_TO_LMS, lab).map((c) => c ** 3) as Vector);\n\nconst KAPPA = 24389 / 27;\nconst EPSILON = 216 / 24389;\n\nfunction xyzToLab(xyz: Vector): Vector {\n const [x, y, z] = times(D65_TO_D50, xyz).map((c, i) => c / D50_WHITE[i]!);\n const f = (c: number) => (c > EPSILON ? Math.cbrt(c) : (KAPPA * c + 16) / 116);\n const [fx, fy, fz] = [f(x!), f(y!), f(z!)];\n return [116 * fy - 16, 500 * (fx - fy), 200 * (fy - fz)];\n}\n\nfunction labToXyz([l, a, b]: Vector): Vector {\n const fy = (l + 16) / 116;\n const fx = a / 500 + fy;\n const fz = fy - b / 200;\n const x = fx ** 3 > EPSILON ? fx ** 3 : (116 * fx - 16) / KAPPA;\n const y = l > KAPPA * EPSILON ? fy ** 3 : l / KAPPA;\n const z = fz ** 3 > EPSILON ? fz ** 3 : (116 * fz - 16) / KAPPA;\n return times(D50_TO_D65, [x, y, z].map((c, i) => c * D50_WHITE[i]!) as Vector);\n}\n\n/** Lightness, chroma and hue in degrees, from the rectangular form, and back. */\nconst polar = ([l, a, b]: Vector): Vector => {\n const hue = (Math.atan2(b, a) * 180) / Math.PI;\n return [l, Math.hypot(a, b), hue < 0 ? hue + 360 : hue];\n};\nconst rectangular = ([l, c, h]: Vector): Vector => [\n l,\n c * Math.cos((h * Math.PI) / 180),\n c * Math.sin((h * Math.PI) / 180),\n];\n\nfunction srgbToHsl([r, g, b]: Vector): Vector {\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const l = (max + min) / 2;\n const d = max - min;\n if (d === 0) return [NaN, 0, l];\n const s = l === 0 || l === 1 ? 0 : (max - l) / Math.min(l, 1 - l);\n const h =\n max === r\n ? ((g - b) / d + (g < b ? 6 : 0)) * 60\n : max === g\n ? ((b - r) / d + 2) * 60\n : ((r - g) / d + 4) * 60;\n return [h, s, l];\n}\n\nfunction hslToSrgb([h, s, l]: Vector): Vector {\n const hue = Number.isFinite(h) ? ((h % 360) + 360) % 360 : 0;\n const f = (n: number) => {\n const k = (n + hue / 30) % 12;\n return l - s * Math.min(l, 1 - l) * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n };\n return [f(0), f(8), f(4)];\n}\n\nfunction srgbToHwb(rgb: Vector): Vector {\n const [h] = srgbToHsl(rgb);\n return [h, Math.min(...rgb), 1 - Math.max(...rgb)];\n}\n\nfunction hwbToSrgb([h, w, b]: Vector): Vector {\n if (w + b >= 1) {\n const grey = w / (w + b);\n return [grey, grey, grey];\n }\n return hslToSrgb([h, 1, 0.5]).map((c) => c * (1 - w - b) + w) as Vector;\n}\n\n/** Where the hue sits in each space's coordinates, if it has one. */\nconst HUE_INDEX: Partial<Record<MixSpace, number>> = { oklch: 2, lch: 2, hsl: 0, hwb: 0 };\n\n/** An sRGB colour, channels 0 to 1, in the space's own coordinates. */\nexport function into(space: MixSpace, rgb: Vector): Vector {\n switch (space) {\n case 'srgb':\n return rgb;\n case 'oklab':\n return xyzToOklab(srgbToXyz(rgb));\n case 'oklch':\n return powerless(polar(xyzToOklab(srgbToXyz(rgb))), 0.000004);\n case 'lab':\n return xyzToLab(srgbToXyz(rgb));\n case 'lch':\n return powerless(polar(xyzToLab(srgbToXyz(rgb))), 0.0015);\n case 'hsl':\n return srgbToHsl(rgb);\n case 'hwb':\n return srgbToHwb(rgb);\n }\n}\n\n/** A hue that does not matter, for a colour with no chroma to speak of, is missing, as CSS says. */\nconst powerless = ([l, c, h]: Vector, threshold: number): Vector => [\n l,\n c,\n c <= threshold ? NaN : h,\n];\n\n/** Back to sRGB, 0 to 1, brought inside the gamut where the space reaches past it. */\nexport function outOf(space: MixSpace, coords: Vector): Vector {\n const finite = coords.map((c) => (Number.isFinite(c) ? c : 0)) as Vector;\n switch (space) {\n case 'srgb':\n return clip(finite);\n case 'oklab':\n return gamutMap(finite);\n case 'oklch':\n return gamutMap(rectangular(finite));\n case 'lab':\n return gamutMap(xyzToOklab(labToXyz(finite)));\n case 'lch':\n return gamutMap(xyzToOklab(labToXyz(rectangular(finite))));\n case 'hsl':\n return clip(hslToSrgb(finite));\n case 'hwb':\n return clip(hwbToSrgb(finite));\n }\n}\n\nconst clip = (rgb: Vector) => rgb.map((c) => Math.min(1, Math.max(0, c))) as Vector;\nconst inGamut = (rgb: Vector) => rgb.every((c) => c >= -1e-6 && c <= 1 + 1e-6);\nconst deltaEOK = (a: Vector, b: Vector) => Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);\n\n/** CSS Color 4 section 13.2.2: reduce OKLCh chroma until clipping no longer shows. */\nfunction gamutMap(oklab: Vector): Vector {\n const origin = polar(oklab);\n if (origin[0] >= 1) return [1, 1, 1];\n if (origin[0] <= 0) return [0, 0, 0];\n const srgbOf = (lch: Vector) => xyzToSrgb(oklabToXyz(rectangular(lch)));\n const rgb = srgbOf(origin);\n if (inGamut(rgb)) return clip(rgb);\n\n const JND = 0.02;\n const EPS = 0.0001;\n let clipped = clip(rgb);\n if (deltaEOK(xyzToOklab(srgbToXyz(clipped)), oklab) < JND) return clipped;\n let min = 0;\n let max = origin[1];\n let minInGamut = true;\n while (max - min > EPS) {\n const chroma = (min + max) / 2;\n const current: Vector = [origin[0], chroma, origin[2]];\n const converted = srgbOf(current);\n if (minInGamut && inGamut(converted)) {\n min = chroma;\n continue;\n }\n clipped = clip(converted);\n const error = deltaEOK(xyzToOklab(srgbToXyz(clipped)), rectangular(current));\n if (error < JND) {\n if (JND - error < EPS) return clipped;\n minInGamut = false;\n min = chroma;\n } else {\n max = chroma;\n }\n }\n return clipped;\n}\n\n/** Two hues, one moved by whole turns so that interpolating between them goes the way asked. */\nfunction fixHues(a: number, b: number, method: HueMethod): [number, number] {\n const delta = b - a;\n const lift = HUE_LIFTS[method](delta);\n return lift === 'a' ? [a + 360, b] : lift === 'b' ? [a, b + 360] : [a, b];\n}\n\n/** For each method, which of the two hues takes a whole turn more, given how far apart they are. */\nconst HUE_LIFTS: Record<HueMethod, (delta: number) => 'a' | 'b' | null> = {\n shorter: (delta) => (delta > 180 ? 'a' : delta < -180 ? 'b' : null),\n longer: (delta) => (delta > 0 && delta < 180 ? 'a' : delta > -180 && delta <= 0 ? 'b' : null),\n increasing: (delta) => (delta < 0 ? 'b' : null),\n decreasing: (delta) => (delta > 0 ? 'a' : null),\n};\n\n/** One side of a mix: a colour as native paints it, and the percentage written beside it. */\nexport interface MixSide {\n readonly colour: string;\n readonly percentage?: number;\n}\n\n/**\n * `color-mix(in <space> [<hue> hue], <a> [p%], <b> [q%])`, as the `rgb()` or `rgba()` native\n * reads. Undefined when a side is not a colour it can read - a platform colour, say - or when the\n * two percentages come to zero, which CSS says is not a colour at all.\n */\nexport function mixColours(\n space: MixSpace,\n a: MixSide,\n b: MixSide,\n hue: HueMethod = 'shorter',\n): string | undefined {\n const first = parseColor(a.colour);\n const second = parseColor(b.colour);\n const weights = weightsOf(a.percentage, b.percentage);\n if (!first || !second || !weights) return undefined;\n\n const [c1, c2] = [first, second].map(([r, g, bl, alpha]) => ({\n coords: into(space, [r / 255, g / 255, bl / 255]),\n alpha,\n })) as [Side, Side];\n const hueAt = HUE_INDEX[space];\n alignComponents(c1, c2, hueAt, hue);\n\n const { t, alphaScale } = weights;\n const alpha = c1.alpha * (1 - t) + c2.alpha * t;\n const mixed = interpolate(c1, c2, t, alpha, hueAt);\n const [r, g, bl] = outOf(space, mixed).map((c) => Math.round(c * 255));\n const opacity = Math.round(alpha * alphaScale * 1000) / 1000;\n return opacity >= 1 ? `rgb(${r}, ${g}, ${bl})` : `rgba(${r}, ${g}, ${bl}, ${opacity})`;\n}\n\ninterface Side {\n coords: Vector;\n alpha: number;\n}\n\n/**\n * CSS Color 5, 2.1: missing percentages take what the other leaves, or half each; the second\n * colour's share is `t`, and a pair summing under 100 scales the alpha down.\n */\nfunction weightsOf(p?: number, q?: number): { t: number; alphaScale: number } | null {\n const [first, second] =\n p === undefined && q === undefined\n ? [50, 50]\n : p === undefined\n ? [100 - q!, q!]\n : q === undefined\n ? [p, 100 - p]\n : [p, q];\n const sum = first + second;\n if (sum <= 0) return null;\n return { t: second / sum, alphaScale: sum < 100 ? sum / 100 : 1 };\n}\n\n/** A missing component takes the other colour's, and the hues are set to go the way asked. */\nfunction alignComponents(c1: Side, c2: Side, hueAt: number | undefined, hue: HueMethod): void {\n for (let i = 0; i < 3; i++) {\n if (Number.isNaN(c1.coords[i])) c1.coords[i] = c2.coords[i]!;\n if (Number.isNaN(c2.coords[i])) c2.coords[i] = c1.coords[i]!;\n }\n if (hueAt === undefined) return;\n const [h1, h2] = [c1.coords[hueAt]!, c2.coords[hueAt]!];\n if (Number.isFinite(h1) && Number.isFinite(h2)) {\n [c1.coords[hueAt], c2.coords[hueAt]] = fixHues(h1, h2, hue);\n }\n}\n\n/** Premultiplied by alpha, except the hue, which is an angle and not an amount. */\nfunction interpolate(c1: Side, c2: Side, t: number, alpha: number, hueAt?: number): Vector {\n const mixed = [0, 1, 2].map((i) => {\n if (i === hueAt) return c1.coords[i]! * (1 - t) + c2.coords[i]! * t;\n const premixed = c1.coords[i]! * c1.alpha * (1 - t) + c2.coords[i]! * c2.alpha * t;\n return alpha === 0 ? 0 : premixed / alpha;\n }) as Vector;\n if (hueAt !== undefined) mixed[hueAt] = ((mixed[hueAt]! % 360) + 360) % 360;\n return mixed;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"color-mix.js","sourceRoot":"","sources":["../src/color-mix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAK7C,MAAM,CAAC,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAW;IAC/D,MAAM;IACN,OAAO;IACP,OAAO;IACP,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;CACN,CAAC,CAAC;AAMH,MAAM,KAAK,GAAG,CAAC,CAAoB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAS,EAAU,EAAE,CAChE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAW,CAAC;AAExD,MAAM,YAAY,GAAa;IAC7B,CAAC,GAAG,EAAE,kBAAkB,EAAE,kBAAkB,CAAC;IAC7C,CAAC,GAAG,EAAE,CAAC,kBAAkB,EAAE,CAAC,kBAAkB,CAAC;IAC/C,CAAC,GAAG,EAAE,CAAC,kBAAkB,EAAE,CAAC,kBAAkB,CAAC;CAChD,CAAC;AACF,MAAM,UAAU,GAAa;IAC3B,CAAC,kBAAkB,EAAE,CAAC,kBAAkB,EAAE,k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AAK,CAAC,KAAK,CAAE,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IAC5E,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * `color-mix()` worked out on device, for a mix with a token in it.\n *\n * The compiler folds a mix of literal colours at build time (lightningcss does the arithmetic); a\n * mix with a `var()` in it can only be done once the token is known, so it is done here, with CSS\n * Color 4 and 5's own arithmetic: each colour converted into the named space, premultiplied by its\n * alpha, interpolated (a hue the shorter way round), and brought back to the sRGB native paints,\n * inside its gamut by CSS Color 4's chroma reduction rather than a clip.\n *\n * The matrices and the gamut mapping are the ones `@ng-native/metro`'s `color-spaces.cjs` uses to\n * convert a literal colour at build time, copied here because the engine cannot depend on the\n * build step; the tests hold the two to the same answers.\n */\nimport { parseColor } from './transition.ts';\n\n/** The spaces a mix is worked out in: every one the compiler also folds a literal mix in. */\nexport type MixSpace = 'srgb' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'hsl' | 'hwb';\n\nexport const MIX_SPACES: ReadonlySet<string> = new Set<MixSpace>([\n 'srgb',\n 'oklab',\n 'oklch',\n 'lab',\n 'lch',\n 'hsl',\n 'hwb',\n]);\n\nexport type HueMethod = 'shorter' | 'longer' | 'increasing' | 'decreasing';\n\nexport type Vector = [number, number, number];\n\nconst times = (m: readonly Vector[], [x, y, z]: Vector): Vector =>\n m.map(([a, b, c]) => a * x + b * y + c * z) as Vector;\n\nconst OKLAB_TO_LMS: Vector[] = [\n [1.0, 0.3963377773761749, 0.2158037573099136],\n [1.0, -0.1055613458156586, -0.0638541728258133],\n [1.0, -0.0894841775298119, -1.2914855480194092],\n];\nconst LMS_TO_XYZ: Vector[] = [\n [1.2268798758459243, -0.5578149944602171, 0.2813910456659647],\n [-0.0405757452148008, 1.112286803280317, -0.0717110580655164],\n [-0.0763729366746601, -0.4214933324022432, 1.5869240198367816],\n];\nconst XYZ_TO_LMS: Vector[] = [\n [0.819022437996703, 0.3619062600528904, -0.1288737815209879],\n [0.0329836539323885, 0.9292868615863434, 0.0361446663506424],\n [0.0481771893596242, 0.2642395317527308, 0.6335478284694309],\n];\nconst LMS_TO_OKLAB: Vector[] = [\n [0.210454268309314, 0.7936177747023054, -0.0040720430116193],\n [1.9779985324311684, -2.4285922420485799, 0.450593709617411],\n [0.0259040424655478, 0.7827717124575296, -0.8086757549230774],\n];\nconst XYZ_TO_LINEAR_SRGB: Vector[] = [\n [3.2409699419045226, -1.537383177570094, -0.4986107602930034],\n [-0.9692436362808796, 1.8759675015077202, 0.04155505740717559],\n [0.05563007969699366, -0.20397695888897652, 1.0569715142428786],\n];\nconst LINEAR_SRGB_TO_XYZ: Vector[] = [\n [0.41239079926595934, 0.357584339383878, 0.1804807884018343],\n [0.21263900587151027, 0.715168678767756, 0.07219231536073371],\n [0.01933081871559182, 0.11919477979462598, 0.9505321522496607],\n];\n/** Bradford chromatic adaptation between `lab()`'s D50 white and sRGB's D65. */\nconst D50_TO_D65: Vector[] = [\n [0.955473421488075, -0.02309845494876471, 0.06325924320057072],\n [-0.0283697093338637, 1.0099953980813041, 0.021041441191917323],\n [0.012314014864481998, -0.020507649298898964, 1.330365926242124],\n];\nconst D65_TO_D50: Vector[] = [\n [1.0479298208405488, 0.022946793341019088, -0.05019222954313557],\n [0.029627815688159344, 0.990434484573249, -0.01707382502938514],\n [-0.009243058152591178, 0.015055144896577895, 0.7518742899580008],\n];\nconst D50_WHITE: Vector = [0.3457 / 0.3585, 1, (1 - 0.3457 - 0.3585) / 0.3585];\n\nconst encode = (c: number) =>\n Math.sign(c) * (Math.abs(c) > 0.0031308 ? 1.055 * Math.abs(c) ** (1 / 2.4) - 0.055 : 12.92 * c);\nconst decode = (c: number) =>\n Math.sign(c) * (Math.abs(c) > 0.04045 ? ((Math.abs(c) + 0.055) / 1.055) ** 2.4 : c / 12.92);\n\nconst srgbToXyz = (rgb: Vector) => times(LINEAR_SRGB_TO_XYZ, rgb.map(decode) as Vector);\nconst xyzToSrgb = (xyz: Vector) => times(XYZ_TO_LINEAR_SRGB, xyz).map(encode) as Vector;\nconst xyzToOklab = (xyz: Vector) =>\n times(LMS_TO_OKLAB, times(XYZ_TO_LMS, xyz).map(Math.cbrt) as Vector);\nconst oklabToXyz = (lab: Vector) =>\n times(LMS_TO_XYZ, times(OKLAB_TO_LMS, lab).map((c) => c ** 3) as Vector);\n\nconst KAPPA = 24389 / 27;\nconst EPSILON = 216 / 24389;\n\nfunction xyzToLab(xyz: Vector): Vector {\n const [x, y, z] = times(D65_TO_D50, xyz).map((c, i) => c / D50_WHITE[i]!);\n const f = (c: number) => (c > EPSILON ? Math.cbrt(c) : (KAPPA * c + 16) / 116);\n const [fx, fy, fz] = [f(x!), f(y!), f(z!)];\n return [116 * fy - 16, 500 * (fx - fy), 200 * (fy - fz)];\n}\n\nfunction labToXyz([l, a, b]: Vector): Vector {\n const fy = (l + 16) / 116;\n const fx = a / 500 + fy;\n const fz = fy - b / 200;\n const x = fx ** 3 > EPSILON ? fx ** 3 : (116 * fx - 16) / KAPPA;\n const y = l > KAPPA * EPSILON ? fy ** 3 : l / KAPPA;\n const z = fz ** 3 > EPSILON ? fz ** 3 : (116 * fz - 16) / KAPPA;\n return times(D50_TO_D65, [x, y, z].map((c, i) => c * D50_WHITE[i]!) as Vector);\n}\n\n/** Lightness, chroma and hue in degrees, from the rectangular form, and back. */\nconst polar = ([l, a, b]: Vector): Vector => {\n const hue = (Math.atan2(b, a) * 180) / Math.PI;\n return [l, Math.hypot(a, b), hue < 0 ? hue + 360 : hue];\n};\nconst rectangular = ([l, c, h]: Vector): Vector => [\n l,\n c * Math.cos((h * Math.PI) / 180),\n c * Math.sin((h * Math.PI) / 180),\n];\n\nfunction srgbToHsl([r, g, b]: Vector): Vector {\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const l = (max + min) / 2;\n const d = max - min;\n if (d === 0) return [NaN, 0, l];\n const s = l === 0 || l === 1 ? 0 : (max - l) / Math.min(l, 1 - l);\n const h =\n max === r\n ? ((g - b) / d + (g < b ? 6 : 0)) * 60\n : max === g\n ? ((b - r) / d + 2) * 60\n : ((r - g) / d + 4) * 60;\n return [h, s, l];\n}\n\nfunction hslToSrgb([h, s, l]: Vector): Vector {\n const hue = Number.isFinite(h) ? ((h % 360) + 360) % 360 : 0;\n const f = (n: number) => {\n const k = (n + hue / 30) % 12;\n return l - s * Math.min(l, 1 - l) * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n };\n return [f(0), f(8), f(4)];\n}\n\nfunction srgbToHwb(rgb: Vector): Vector {\n const [h] = srgbToHsl(rgb);\n return [h, Math.min(...rgb), 1 - Math.max(...rgb)];\n}\n\nfunction hwbToSrgb([h, w, b]: Vector): Vector {\n if (w + b >= 1) {\n const grey = w / (w + b);\n return [grey, grey, grey];\n }\n return hslToSrgb([h, 1, 0.5]).map((c) => c * (1 - w - b) + w) as Vector;\n}\n\n/** Where the hue sits in each space's coordinates, if it has one. */\nconst HUE_INDEX: Partial<Record<MixSpace, number>> = { oklch: 2, lch: 2, hsl: 0, hwb: 0 };\n\n/** An sRGB colour, channels 0 to 1, in the space's own coordinates. */\nexport function into(space: MixSpace, rgb: Vector): Vector {\n switch (space) {\n case 'srgb':\n return rgb;\n case 'oklab':\n return xyzToOklab(srgbToXyz(rgb));\n case 'oklch':\n return powerless(polar(xyzToOklab(srgbToXyz(rgb))), 0.000004);\n case 'lab':\n return xyzToLab(srgbToXyz(rgb));\n case 'lch':\n return powerless(polar(xyzToLab(srgbToXyz(rgb))), 0.0015);\n case 'hsl':\n return srgbToHsl(rgb);\n case 'hwb':\n return srgbToHwb(rgb);\n }\n}\n\n/** A hue that does not matter, for a colour with no chroma to speak of, is missing, as CSS says. */\nconst powerless = ([l, c, h]: Vector, threshold: number): Vector => [\n l,\n c,\n c <= threshold ? NaN : h,\n];\n\n/** Back to sRGB, 0 to 1, brought inside the gamut where the space reaches past it. */\nexport function outOf(space: MixSpace, coords: Vector): Vector {\n const finite = coords.map((c) => (Number.isFinite(c) ? c : 0)) as Vector;\n switch (space) {\n case 'srgb':\n return clip(finite);\n case 'oklab':\n return gamutMap(finite);\n case 'oklch':\n return gamutMap(rectangular(finite));\n case 'lab':\n return gamutMap(xyzToOklab(labToXyz(finite)));\n case 'lch':\n return gamutMap(xyzToOklab(labToXyz(rectangular(finite))));\n case 'hsl':\n return clip(hslToSrgb(finite));\n case 'hwb':\n return clip(hwbToSrgb(finite));\n }\n}\n\nconst clip = (rgb: Vector) => rgb.map((c) => Math.min(1, Math.max(0, c))) as Vector;\nconst inGamut = (rgb: Vector) => rgb.every((c) => c >= -1e-6 && c <= 1 + 1e-6);\nconst deltaEOK = (a: Vector, b: Vector) => Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);\n\n/** CSS Color 4 section 13.2.2: reduce OKLCh chroma until clipping no longer shows. */\nfunction gamutMap(oklab: Vector): Vector {\n const origin = polar(oklab);\n if (origin[0] >= 1) return [1, 1, 1];\n if (origin[0] <= 0) return [0, 0, 0];\n const srgbOf = (lch: Vector) => xyzToSrgb(oklabToXyz(rectangular(lch)));\n const rgb = srgbOf(origin);\n if (inGamut(rgb)) return clip(rgb);\n\n const JND = 0.02;\n const EPS = 0.0001;\n let clipped = clip(rgb);\n if (deltaEOK(xyzToOklab(srgbToXyz(clipped)), oklab) < JND) return clipped;\n let min = 0;\n let max = origin[1];\n let minInGamut = true;\n while (max - min > EPS) {\n const chroma = (min + max) / 2;\n const current: Vector = [origin[0], chroma, origin[2]];\n const converted = srgbOf(current);\n if (minInGamut && inGamut(converted)) {\n min = chroma;\n continue;\n }\n clipped = clip(converted);\n const error = deltaEOK(xyzToOklab(srgbToXyz(clipped)), rectangular(current));\n if (error < JND) {\n if (JND - error < EPS) return clipped;\n minInGamut = false;\n min = chroma;\n } else {\n max = chroma;\n }\n }\n return clipped;\n}\n\n/** Two hues, one moved by whole turns so that interpolating between them goes the way asked. */\nfunction fixHues(a: number, b: number, method: HueMethod): [number, number] {\n const delta = b - a;\n const lift = HUE_LIFTS[method](delta);\n return lift === 'a' ? [a + 360, b] : lift === 'b' ? [a, b + 360] : [a, b];\n}\n\n/** For each method, which of the two hues takes a whole turn more, given how far apart they are. */\nconst HUE_LIFTS: Record<HueMethod, (delta: number) => 'a' | 'b' | null> = {\n shorter: (delta) => (delta > 180 ? 'a' : delta < -180 ? 'b' : null),\n longer: (delta) => (delta > 0 && delta < 180 ? 'a' : delta > -180 && delta <= 0 ? 'b' : null),\n increasing: (delta) => (delta < 0 ? 'b' : null),\n decreasing: (delta) => (delta > 0 ? 'a' : null),\n};\n\n/** A colour's channels, 0 to 255 and unrounded, and its alpha: what one mix hands another. */\nexport type Rgba = readonly [r: number, g: number, b: number, alpha: number];\n\n/**\n * One side of a mix: a colour as native paints it, or the unrounded channels of another mix, and\n * the percentage written beside it.\n */\nexport interface MixSide {\n readonly colour: string | Rgba;\n readonly percentage?: number;\n}\n\n/**\n * `color-mix(in <space> [<hue> hue], <a> [p%], <b> [q%])`, as the `rgb()` or `rgba()` native\n * reads. Undefined when a side is not a colour it can read - a platform colour, say - or when the\n * two percentages come to zero, which CSS says is not a colour at all.\n */\nexport function mixColours(\n space: MixSpace,\n a: MixSide,\n b: MixSide,\n hue: HueMethod = 'shorter',\n): string | undefined {\n const mixed = mixChannels(space, a, b, hue);\n if (!mixed) return undefined;\n const [r, g, bl] = mixed.map((c) => Math.round(c));\n const opacity = Math.round(mixed[3] * 1000) / 1000;\n return opacity >= 1 ? `rgb(${r}, ${g}, ${bl})` : `rgba(${r}, ${g}, ${bl}, ${opacity})`;\n}\n\n/**\n * The same mix, unrounded, for a mix around it to take as one of its sides: CSS works a nested\n * mix out in full and rounds only the colour at the end.\n */\nexport function mixChannels(\n space: MixSpace,\n a: MixSide,\n b: MixSide,\n hue: HueMethod = 'shorter',\n): Rgba | undefined {\n const first = typeof a.colour === 'string' ? parseColor(a.colour) : a.colour;\n const second = typeof b.colour === 'string' ? parseColor(b.colour) : b.colour;\n const weights = weightsOf(a.percentage, b.percentage);\n if (!first || !second || !weights) return undefined;\n\n const [c1, c2] = [first, second].map(([r, g, bl, alpha]) => ({\n coords: into(space, [r / 255, g / 255, bl / 255]),\n alpha,\n })) as [Side, Side];\n const hueAt = HUE_INDEX[space];\n alignComponents(c1, c2, hueAt, hue);\n\n const { t, alphaScale } = weights;\n const alpha = c1.alpha * (1 - t) + c2.alpha * t;\n const mixed = interpolate(c1, c2, t, alpha, hueAt);\n const [r, g, bl] = outOf(space, mixed).map((c) => c * 255);\n return [r!, g!, bl!, alpha * alphaScale];\n}\n\ninterface Side {\n coords: Vector;\n alpha: number;\n}\n\n/**\n * CSS Color 5, 2.1: missing percentages take what the other leaves, or half each; the second\n * colour's share is `t`, and a pair summing under 100 scales the alpha down.\n */\nfunction weightsOf(p?: number, q?: number): { t: number; alphaScale: number } | null {\n const [first, second] =\n p === undefined && q === undefined\n ? [50, 50]\n : p === undefined\n ? [100 - q!, q!]\n : q === undefined\n ? [p, 100 - p]\n : [p, q];\n const sum = first + second;\n if (sum <= 0) return null;\n return { t: second / sum, alphaScale: sum < 100 ? sum / 100 : 1 };\n}\n\n/** A missing component takes the other colour's, and the hues are set to go the way asked. */\nfunction alignComponents(c1: Side, c2: Side, hueAt: number | undefined, hue: HueMethod): void {\n for (let i = 0; i < 3; i++) {\n if (Number.isNaN(c1.coords[i])) c1.coords[i] = c2.coords[i]!;\n if (Number.isNaN(c2.coords[i])) c2.coords[i] = c1.coords[i]!;\n }\n if (hueAt === undefined) return;\n const [h1, h2] = [c1.coords[hueAt]!, c2.coords[hueAt]!];\n if (Number.isFinite(h1) && Number.isFinite(h2)) {\n [c1.coords[hueAt], c2.coords[hueAt]] = fixHues(h1, h2, hue);\n }\n}\n\n/** Premultiplied by alpha, except the hue, which is an angle and not an amount. */\nfunction interpolate(c1: Side, c2: Side, t: number, alpha: number, hueAt?: number): Vector {\n const mixed = [0, 1, 2].map((i) => {\n if (i === hueAt) return c1.coords[i]! * (1 - t) + c2.coords[i]! * t;\n const premixed = c1.coords[i]! * c1.alpha * (1 - t) + c2.coords[i]! * c2.alpha * t;\n return alpha === 0 ? 0 : premixed / alpha;\n }) as Vector;\n if (hueAt !== undefined) mixed[hueAt] = ((mixed[hueAt]! % 360) + 360) % 360;\n return mixed;\n}\n"]}
|
package/dist/css.d.ts
CHANGED
|
@@ -59,11 +59,18 @@ export interface StyleRule {
|
|
|
59
59
|
/** Between compounds; length is `compounds.length - 1`. */
|
|
60
60
|
readonly combinators: readonly Combinator[];
|
|
61
61
|
readonly specificity: number;
|
|
62
|
+
/**
|
|
63
|
+
* The cascade layer the rule is in, as its place in its sheet's `layers`, or nothing for a rule
|
|
64
|
+
* in no layer, which beats every layered one whatever their specificity.
|
|
65
|
+
*/
|
|
66
|
+
readonly layer?: number;
|
|
62
67
|
readonly order: number;
|
|
63
68
|
readonly declarations: Readonly<Record<string, unknown>>;
|
|
64
69
|
readonly important?: Readonly<Record<string, unknown>>;
|
|
65
70
|
/** Custom properties this rule defines, pre-converted into every form a use site might want. */
|
|
66
71
|
readonly tokens?: Readonly<Record<string, TokenValue>>;
|
|
72
|
+
/** The names among `tokens` declared `!important`, which beat every plain one. */
|
|
73
|
+
readonly importantTokens?: readonly string[];
|
|
67
74
|
/** Declarations whose value is a `var()`, resolved once the token map is known. */
|
|
68
75
|
readonly deferred?: readonly DeferredDeclaration[];
|
|
69
76
|
/** The media query guarding this rule, if any. */
|
|
@@ -95,7 +102,16 @@ export interface Conditions {
|
|
|
95
102
|
* platform that cannot answer means anyway.
|
|
96
103
|
*/
|
|
97
104
|
readonly reducedMotion?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* The system text size, as a multiplier: `PixelRatio.getFontScale()`. What native text scales
|
|
107
|
+
* by; the engine scales the line box it keeps for a single-line iOS text input by it too.
|
|
108
|
+
* Optional, and 1 when absent. A change reaches that line box when text is measured again
|
|
109
|
+
* (`Engine.remeasureText`), which `watchConditions` does after it.
|
|
110
|
+
*/
|
|
111
|
+
readonly fontScale?: number;
|
|
98
112
|
}
|
|
113
|
+
/** A run of CSS whitespace: spaces, tabs, newlines, carriage returns and form feeds, and no other. */
|
|
114
|
+
export declare const CSS_SPACE: RegExp;
|
|
99
115
|
/** A custom property's value, in each form it can legally take. Absent forms are unusable. */
|
|
100
116
|
export interface TokenValue {
|
|
101
117
|
readonly length?: number | string;
|
|
@@ -160,6 +176,8 @@ export interface TokenValue {
|
|
|
160
176
|
readonly s: HslChannel;
|
|
161
177
|
readonly l: HslChannel;
|
|
162
178
|
readonly alpha?: HslChannel;
|
|
179
|
+
/** Written with commas, whose saturation and lightness are percentages alone. */
|
|
180
|
+
readonly legacy?: true;
|
|
163
181
|
};
|
|
164
182
|
}
|
|
165
183
|
/** One channel of an `hsl()` token: settled at build time, or a token to read at match time. */
|
|
@@ -168,13 +186,15 @@ export type HslChannel = number | {
|
|
|
168
186
|
readonly fallback?: number;
|
|
169
187
|
};
|
|
170
188
|
/** The forms a token can be read in: one per kind of value a use site can need. */
|
|
171
|
-
export type TokenKind = 'length' | 'color' | 'keyword' | 'number' | 'weight' | 'family' | 'lineHeight' | 'shadow' | 'filter' | 'transform' | 'fontVariant' | 'channels' | 'hslChannels' | 'easing' | 'time' | 'animation';
|
|
189
|
+
export type TokenKind = 'length' | 'color' | 'keyword' | 'number' | 'weight' | 'family' | 'lineHeight' | 'shadow' | 'filter' | 'transform' | 'fontVariant' | 'channels' | 'hslChannels' | 'easing' | 'time' | 'animation' | 'display';
|
|
172
190
|
export interface DeferredDeclaration {
|
|
173
191
|
/**
|
|
174
192
|
* The React Native style properties this lands in. Usually one, but a four-sided shorthand is
|
|
175
193
|
* unambiguous given a single-valued token, so `padding: var(--gap)` writes all four.
|
|
176
194
|
*/
|
|
177
195
|
readonly props: readonly string[];
|
|
196
|
+
/** The element a bound declaration is on, by name, for a message about it to say. */
|
|
197
|
+
readonly on?: string;
|
|
178
198
|
/** A `var()` reference. Exactly one of this and `compute` is present. */
|
|
179
199
|
readonly kind?: TokenKind;
|
|
180
200
|
readonly reference?: string;
|
|
@@ -224,6 +244,11 @@ export interface DeferredDeclaration {
|
|
|
224
244
|
readonly scale?: number;
|
|
225
245
|
readonly offset?: number;
|
|
226
246
|
readonly floor?: number;
|
|
247
|
+
/**
|
|
248
|
+
* The reference is multiplied by a length, so it is a number: `calc(var(--n) * 1px)`. Without
|
|
249
|
+
* this it is a length, and a number token is no such thing, as CSS types a calc().
|
|
250
|
+
*/
|
|
251
|
+
readonly number?: true;
|
|
227
252
|
/**
|
|
228
253
|
* A fraction to multiply the resolved colour's alpha by. What
|
|
229
254
|
* `color-mix(in oklab, var(--x) 90%, transparent)` becomes, which is Tailwind's `/90`.
|
|
@@ -246,6 +271,31 @@ export interface DeferredDeclaration {
|
|
|
246
271
|
* somewhere inside it, each marked `{ __defer: compute }`. Filled in where it is used.
|
|
247
272
|
*/
|
|
248
273
|
readonly within?: unknown;
|
|
274
|
+
/** A `border` or a side's line with tokens in it, each given its role where it is used. */
|
|
275
|
+
readonly line?: LineTemplate;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* `border: var(--w) var(--s) var(--c)`: which token is the width, the style or the colour cannot be
|
|
279
|
+
* told at build time, so each is given the role its form says on device. `roles` are those the
|
|
280
|
+
* written parts left open; `props` of the declaration are every longhand, which a line its tokens
|
|
281
|
+
* make nothing of unsets.
|
|
282
|
+
*/
|
|
283
|
+
export interface LineTemplate {
|
|
284
|
+
readonly references: readonly {
|
|
285
|
+
readonly reference: string;
|
|
286
|
+
readonly alternatives?: readonly string[];
|
|
287
|
+
readonly fallback?: TokenValue;
|
|
288
|
+
/** `var(--x,)`: nothing at all when the token is unset. */
|
|
289
|
+
readonly empty?: true;
|
|
290
|
+
/** `calc(var(--w) * 2)`: the arithmetic that makes the token the width, and only that. */
|
|
291
|
+
readonly adjust?: DeferredDeclaration['adjust'];
|
|
292
|
+
}[];
|
|
293
|
+
readonly roles: readonly ('width' | 'style' | 'color')[];
|
|
294
|
+
readonly widths: readonly string[];
|
|
295
|
+
readonly colors: readonly string[];
|
|
296
|
+
/** `color-mix(in srgb, var(--tint) 35%, transparent)`: the colour, written as a function. */
|
|
297
|
+
readonly colour?: unknown;
|
|
298
|
+
readonly style?: string;
|
|
249
299
|
}
|
|
250
300
|
/**
|
|
251
301
|
* A colour a deferred value is made of: settled at build time, a token, or a `color-mix()` of two
|
|
@@ -258,6 +308,13 @@ export type ColourExpression = {
|
|
|
258
308
|
readonly reference: string;
|
|
259
309
|
readonly alternatives?: readonly string[];
|
|
260
310
|
readonly fallback?: string;
|
|
311
|
+
/** A fallback made of other tokens, worked out from the tokens where it is used. */
|
|
312
|
+
readonly fallbackToken?: TokenValue;
|
|
313
|
+
/**
|
|
314
|
+
* A shadow's `var(--x,)` with no colour beside it, which holds the colour or the word
|
|
315
|
+
* `inset`: currentcolor when it is `inset` or unset.
|
|
316
|
+
*/
|
|
317
|
+
readonly orInset?: true;
|
|
261
318
|
} | {
|
|
262
319
|
/** A token of bare channels, as `rgba(var(--channels), <alpha>)` reads it. */
|
|
263
320
|
readonly channels: {
|
|
@@ -317,6 +374,12 @@ export interface GradientTemplate {
|
|
|
317
374
|
}
|
|
318
375
|
export interface StyleSheet {
|
|
319
376
|
readonly rules: readonly StyleRule[];
|
|
377
|
+
/**
|
|
378
|
+
* The sheet's cascade layers, each by its name from the outermost layer in, in the order they
|
|
379
|
+
* were first named. A name that starts with a null is a block with no name, which is a layer
|
|
380
|
+
* no other block can name.
|
|
381
|
+
*/
|
|
382
|
+
readonly layers?: readonly (readonly string[])[];
|
|
320
383
|
/**
|
|
321
384
|
* `@keyframes` by name. Global within a sheet, as they are within a document; the engine keeps
|
|
322
385
|
* one registry across every sheet it sees, so a name defined in a global stylesheet is usable
|
|
@@ -340,6 +403,8 @@ export interface StyleSheet {
|
|
|
340
403
|
readonly family: string;
|
|
341
404
|
readonly source: unknown;
|
|
342
405
|
readonly weight?: number;
|
|
406
|
+
/** The weights a variable font covers, `font-weight: 100 900`, in place of one `weight`. */
|
|
407
|
+
readonly weightRange?: readonly [number, number];
|
|
343
408
|
readonly style?: string;
|
|
344
409
|
}[];
|
|
345
410
|
}
|
|
@@ -386,6 +451,20 @@ export interface StyleTarget {
|
|
|
386
451
|
readonly kind?: string;
|
|
387
452
|
readonly classes: ReadonlySet<string> | null;
|
|
388
453
|
readonly props: Readonly<Record<string, unknown>>;
|
|
454
|
+
/**
|
|
455
|
+
* Whether `props.style` sets a property children inherit, kept by whoever sets the style so the
|
|
456
|
+
* resolver reads the style only where it can matter. Absent is false.
|
|
457
|
+
*/
|
|
458
|
+
readonly inlineInherits?: boolean;
|
|
459
|
+
/**
|
|
460
|
+
* The bound declarations that are a `var()`, `[style.color]="'var(--brand)'"`, as the deferred
|
|
461
|
+
* declarations a rule's would be: settled with the node's tokens, last of its normal ones.
|
|
462
|
+
*/
|
|
463
|
+
readonly boundStyle?: readonly DeferredDeclaration[] | null;
|
|
464
|
+
/** A node the engine made, such as the paragraph around loose text: it only inherits. */
|
|
465
|
+
readonly anonymous?: true;
|
|
466
|
+
/** One of HTML's text elements the engine has styles of its own for, such as `strong`. */
|
|
467
|
+
readonly styled?: true;
|
|
389
468
|
/**
|
|
390
469
|
* The sheet this node's own rules come from, which is the sheet of the component whose renderer
|
|
391
470
|
* created it. Read from the node rather than passed in, because a node's ancestors usually
|
|
@@ -475,6 +554,14 @@ export declare function indexRules(entries: readonly RuleEntry[]): RuleIndex;
|
|
|
475
554
|
* lists are short by construction, which is the entire point of the index.
|
|
476
555
|
*/
|
|
477
556
|
export declare function candidateRules(node: StyleTarget, index: RuleIndex): RuleEntry[];
|
|
557
|
+
/** Whether an inline style sets a property children inherit. Allocates nothing: it runs per set. */
|
|
558
|
+
export declare function setsInherited(style: unknown): boolean;
|
|
559
|
+
/**
|
|
560
|
+
* The inherited properties a node's inline style sets, or null for none. Inline style is the
|
|
561
|
+
* strongest normal declaration on its element, so what it sets is inherited, and read by
|
|
562
|
+
* `color: inherit` and `currentColor`, as a rule's would be.
|
|
563
|
+
*/
|
|
564
|
+
export declare function inlineInherited(style: unknown): Record<string, unknown> | null;
|
|
478
565
|
/**
|
|
479
566
|
* The runtime half of CSS for one engine: the global sheet, the conditions media queries are
|
|
480
567
|
* evaluated against, and the memo that makes resolution cost nodes x rules rather than
|
|
@@ -511,12 +598,33 @@ export declare class StyleResolver {
|
|
|
511
598
|
* selector. Keyed by the creating sheet and then the hosted one, so a component's nodes share a
|
|
512
599
|
* single index.
|
|
513
600
|
*/
|
|
514
|
-
private
|
|
601
|
+
private merged;
|
|
602
|
+
/**
|
|
603
|
+
* Whether any sheet merged so far has a rule in a cascade layer. Until one does, rules are
|
|
604
|
+
* ordered by weight alone and the cascade does not look for layers, which is nearly every app.
|
|
605
|
+
* It stays set once a layered sheet has gone, which costs a look at each cascade and no more.
|
|
606
|
+
*/
|
|
607
|
+
private layered;
|
|
608
|
+
/**
|
|
609
|
+
* Every layer the sheets seen so far have named, in the order each name was first seen, which
|
|
610
|
+
* is the one order a document has for them. A name keeps its place when its sheet is replaced.
|
|
611
|
+
*/
|
|
612
|
+
private readonly layerNames;
|
|
613
|
+
/** Each layered rule's place among them, set when its sheet is first merged. */
|
|
614
|
+
private readonly layerPlaces;
|
|
615
|
+
private readonly layeredSheets;
|
|
616
|
+
private unnamedLayers;
|
|
515
617
|
/**
|
|
516
618
|
* The application-level sheet, if any: the one set of rules allowed to match a node whatever
|
|
517
619
|
* component created it, which is what resets, utility classes and `:root` tokens all need.
|
|
518
620
|
*/
|
|
519
621
|
private readonly globalSheet;
|
|
622
|
+
/**
|
|
623
|
+
* Global sheets added once the engine is running, in the order they came: a
|
|
624
|
+
* `ViewEncapsulation.None` component's, which a browser adds to the document unscoped when the
|
|
625
|
+
* component first renders, after the application's own. See `addGlobalSheet`.
|
|
626
|
+
*/
|
|
627
|
+
private readonly addedSheets;
|
|
520
628
|
/**
|
|
521
629
|
* Custom properties the host supplies rather than the stylesheet: the safe-area insets, and
|
|
522
630
|
* whatever else is a property of the device instead of the design.
|
|
@@ -532,8 +640,25 @@ export declare class StyleResolver {
|
|
|
532
640
|
* Told of a `var()` that names a custom property nothing in scope defines and has no fallback,
|
|
533
641
|
* which is dropped. Set only in development, where it is how the engine says so.
|
|
534
642
|
*/
|
|
535
|
-
onUndefinedToken: ((name: string, props: readonly string[]) => void) | null;
|
|
643
|
+
onUndefinedToken: ((name: string, props: readonly string[], on?: string) => void) | null;
|
|
644
|
+
/**
|
|
645
|
+
* Told of a `display: var()` whose token holds no display native has, `grid` or `table`, which
|
|
646
|
+
* leaves display unset. Set only in development, where it is how the engine says so: the
|
|
647
|
+
* compiler refuses the same value written out, but a token is only known here.
|
|
648
|
+
*/
|
|
649
|
+
onUnreadDisplay: ((name: string, value: string | undefined) => void) | null;
|
|
536
650
|
constructor(globalSheet: StyleSheet | null, conditions: Conditions);
|
|
651
|
+
/**
|
|
652
|
+
* Match `sheet` against every node from now on, as a global sheet, after the application's;
|
|
653
|
+
* false when it already is. Every cached result goes, as on a theme switch: rules that were not
|
|
654
|
+
* there can now match anything. `:host` in it matches nothing, since no node hosts it.
|
|
655
|
+
*
|
|
656
|
+
* With `replacing`, a sheet added before, it takes that one's place, and so its order: a hot
|
|
657
|
+
* swap of the component's CSS edits the sheet where it is.
|
|
658
|
+
*/
|
|
659
|
+
addGlobalSheet(sheet: StyleSheet, replacing?: StyleSheet): boolean;
|
|
660
|
+
/** Stop matching a sheet `addGlobalSheet` added; false when it is not one. */
|
|
661
|
+
removeGlobalSheet(sheet: StyleSheet): boolean;
|
|
537
662
|
setConditions(next: Conditions): void;
|
|
538
663
|
setRootTokens(next: Readonly<Record<string, TokenValue>>): void;
|
|
539
664
|
/**
|
|
@@ -563,7 +688,9 @@ export declare class StyleResolver {
|
|
|
563
688
|
*
|
|
564
689
|
* It still mints a context, because a rule further down may match on one of *its* classes.
|
|
565
690
|
* When there is nothing to inherit either, one shared cache object serves every such node, so
|
|
566
|
-
* an application that writes no CSS allocates nothing per node.
|
|
691
|
+
* an application that writes no CSS allocates nothing per node. Not when there are tokens to
|
|
692
|
+
* carry: the shared object holds none, and the surface root answering with it dropped every
|
|
693
|
+
* token the device had seeded.
|
|
567
694
|
*/
|
|
568
695
|
private unstyled;
|
|
569
696
|
/**
|
|
@@ -581,8 +708,18 @@ export declare class StyleResolver {
|
|
|
581
708
|
* created it. Both carry the bump; the creator comes later and so wins a tie, as the outer
|
|
582
709
|
* document does over `:host` on the web. The sort is stable, so within one sheet source order
|
|
583
710
|
* survives and a later sheet wins equal weight.
|
|
711
|
+
*
|
|
712
|
+
* A sheet added with `addGlobalSheet` comes last, with no bump: a browser adds a None
|
|
713
|
+
* component's CSS when the component first renders, after the styles of the components around
|
|
714
|
+
* it, so it loses to their extra attribute and wins a tie with them.
|
|
584
715
|
*/
|
|
585
716
|
private merge;
|
|
717
|
+
/**
|
|
718
|
+
* Gives each of a sheet's layers its place among every sheet's, the first time the sheet is
|
|
719
|
+
* merged, and each of its layered rules that place. Sheets are merged in the order a document
|
|
720
|
+
* holds them: the app's global sheet, then each component's as it first renders.
|
|
721
|
+
*/
|
|
722
|
+
private placeLayers;
|
|
586
723
|
/**
|
|
587
724
|
* A node's style from the rules it matched, shared with every other node that matched the same
|
|
588
725
|
* rules under the same inherited values and tokens: a list's rows, and what is inside each.
|
|
@@ -626,8 +763,12 @@ export declare class StyleResolver {
|
|
|
626
763
|
private applyDeferred;
|
|
627
764
|
/** One deferred declaration's value, from the tokens in scope and the node's own style. */
|
|
628
765
|
private settled;
|
|
766
|
+
/** A line's longhands from its tokens, with a width in `em` worked out against the font size. */
|
|
767
|
+
private settledLine;
|
|
629
768
|
/** A reference with nothing defined for it and nothing to fall back to. */
|
|
630
769
|
private reportUndefined;
|
|
770
|
+
/** A display token set to a value native has no display for. */
|
|
771
|
+
private reportDisplay;
|
|
631
772
|
/**
|
|
632
773
|
* A structured value with every deferred length and colour inside it settled, or undefined when
|
|
633
774
|
* a colour in it cannot be: a shadow with no colour is not a shadow, as CSS reads it.
|
|
@@ -643,13 +784,27 @@ export declare class StyleResolver {
|
|
|
643
784
|
/** A length relative to the viewport or to the font size in scope. */
|
|
644
785
|
private computed;
|
|
645
786
|
}
|
|
787
|
+
/**
|
|
788
|
+
* A bound declaration whose value is one `var()`, `var(--brand, red)`, as the deferred declaration
|
|
789
|
+
* the compiler writes for the same value in a rule. `token` is the value as a token, which is an
|
|
790
|
+
* alias when it is a `var()`; null for any other.
|
|
791
|
+
*
|
|
792
|
+
* ponytail: the whole value has to be the `var()`. One inside a longer value, `calc()` included,
|
|
793
|
+
* is what the compiler parses at build time and nothing here does; write the sum in a custom
|
|
794
|
+
* property, `[style.--gap]`, and read that in the stylesheet.
|
|
795
|
+
*/
|
|
796
|
+
export declare function boundDeclaration(prop: string, token: TokenValue | undefined, on?: string): DeferredDeclaration | null;
|
|
646
797
|
/** `hsl()` reads a channels token as hue, saturation and lightness; `rgb()` as sRGB. */
|
|
647
798
|
type ChannelSpace = 'rgb' | 'hsl';
|
|
648
799
|
/**
|
|
649
800
|
* Arithmetic with tokens in it, as the compiler leaves it: numbers, token references and
|
|
650
|
-
* `[op, a, b]`, in points, degrees or plain numbers as the slot it fills counts.
|
|
801
|
+
* `[op, a, b]`, in points, degrees or plain numbers as the slot it fills counts. A percentage
|
|
802
|
+
* written where a number is wanted is its fraction, kept apart from a bare number so that what
|
|
803
|
+
* the arithmetic makes is still a percentage (see `calcType`).
|
|
651
804
|
*/
|
|
652
805
|
type CalcExpression = number | {
|
|
806
|
+
readonly percentage: number;
|
|
807
|
+
} | {
|
|
653
808
|
readonly reference: string;
|
|
654
809
|
readonly fallback?: CalcExpression;
|
|
655
810
|
} | readonly ['+' | '-' | '*' | '/' | 'max' | 'min', CalcExpression, CalcExpression];
|