@mkbabb/value.js 0.4.5 → 0.4.6
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/src/easing.d.ts +112 -0
- package/dist/src/index.d.ts +29 -0
- package/dist/src/math.d.ts +9 -0
- package/dist/src/parsing/color.d.ts +26 -0
- package/dist/src/parsing/index.d.ts +31 -0
- package/dist/src/parsing/math.d.ts +28 -0
- package/dist/src/parsing/units.d.ts +18 -0
- package/dist/src/parsing/utils.d.ts +24 -0
- package/dist/src/transform/decompose.d.ts +61 -0
- package/dist/src/units/color/colorFilter.d.ts +7 -0
- package/dist/src/units/color/constants.d.ts +992 -0
- package/dist/src/units/color/gamut.d.ts +60 -0
- package/dist/src/units/color/index.d.ts +171 -0
- package/dist/src/units/color/matrix.d.ts +28 -0
- package/dist/src/units/color/normalize.d.ts +10 -0
- package/dist/src/units/color/utils.d.ts +77 -0
- package/dist/src/units/constants.d.ts +33 -0
- package/dist/src/units/index.d.ts +51 -0
- package/dist/src/units/normalize.d.ts +9 -0
- package/dist/src/units/utils.d.ts +17 -0
- package/dist/src/utils.d.ts +28 -0
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Analytical sRGB gamut mapping based on Bjorn Ottosson's ok_color.h
|
|
3
|
+
* https://bottosson.github.io/posts/gamutclipping/
|
|
4
|
+
*
|
|
5
|
+
* Strategy: adaptive L0 (alpha=0.05) — deterministic, zero-iteration,
|
|
6
|
+
* perceptually correct in OKLab with exact hue preservation.
|
|
7
|
+
*
|
|
8
|
+
* MIT License — Copyright (c) 2021 Bjorn Ottosson
|
|
9
|
+
*/
|
|
10
|
+
export declare const DELTA_E_OK_JND = 0.02;
|
|
11
|
+
export declare function deltaEOK(L1: number, a1: number, b1: number, L2: number, a2: number, b2: number): number;
|
|
12
|
+
/**
|
|
13
|
+
* Direct OKLab→linear sRGB conversion (no XYZ intermediate).
|
|
14
|
+
* L ∈ [0,1], a,b ∈ [-0.4,0.4] (raw OKLab, NOT normalized).
|
|
15
|
+
*/
|
|
16
|
+
export declare function oklabToLinearSRGB(L: number, a: number, b: number): [number, number, number];
|
|
17
|
+
/** Check if linear sRGB values are within the [0,1]³ gamut. */
|
|
18
|
+
export declare function isInSRGBGamut(r: number, g: number, b: number): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Compute the maximum saturation S = C/L for a given hue direction (a_, b_)
|
|
21
|
+
* where a_² + b_² ≈ 1. Uses a polynomial initial guess refined by one
|
|
22
|
+
* Halley's method step for cubic convergence.
|
|
23
|
+
*/
|
|
24
|
+
export declare function computeMaxSaturation(a_: number, b_: number): number;
|
|
25
|
+
/**
|
|
26
|
+
* Find the cusp (L_cusp, C_cusp) — the point of maximum chroma on the
|
|
27
|
+
* gamut boundary for a given hue direction.
|
|
28
|
+
*/
|
|
29
|
+
export declare function findCusp(a_: number, b_: number): {
|
|
30
|
+
L: number;
|
|
31
|
+
C: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Find the parameter t where the ray from (L0, 0) through (L1, C1)
|
|
35
|
+
* intersects the sRGB gamut boundary. Returns t ∈ [0,1].
|
|
36
|
+
*
|
|
37
|
+
* Lower half uses closed-form; upper half uses one Halley's method step.
|
|
38
|
+
*/
|
|
39
|
+
export declare function findGamutIntersection(a_: number, b_: number, L1: number, C1: number, L0: number, cusp: {
|
|
40
|
+
L: number;
|
|
41
|
+
C: number;
|
|
42
|
+
}): number;
|
|
43
|
+
/**
|
|
44
|
+
* Core gamut mapping in raw OKLab space.
|
|
45
|
+
* Adaptive L0 strategy (alpha=0.05) — preserves hue exactly.
|
|
46
|
+
*
|
|
47
|
+
* Input/output: raw OKLab (L ∈ [0,1], a,b ∈ [-0.4,0.4]).
|
|
48
|
+
* Returns the mapped (L, a, b) tuple.
|
|
49
|
+
*/
|
|
50
|
+
export declare function gamutMapOKLab(L: number, a: number, b: number): [number, number, number];
|
|
51
|
+
/**
|
|
52
|
+
* Convert sRGB (possibly out-of-gamut) to raw OKLab.
|
|
53
|
+
* Uses the direct linear sRGB → LMS path.
|
|
54
|
+
*/
|
|
55
|
+
export declare function srgbToOKLab(r: number, g: number, b: number): [number, number, number];
|
|
56
|
+
/**
|
|
57
|
+
* Map an sRGB color (components may be outside [0,1]) to in-gamut sRGB.
|
|
58
|
+
* Returns clamped sRGB [0,1]³.
|
|
59
|
+
*/
|
|
60
|
+
export declare function gamutMapSRGB(r: number, g: number, b: number): [number, number, number];
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { ColorSpace, WhitePoint } from './constants';
|
|
2
|
+
export declare abstract class Color<T = number> {
|
|
3
|
+
readonly colorSpace: ColorSpace;
|
|
4
|
+
alpha: T;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
protected components: Map<string, T>;
|
|
7
|
+
constructor(colorSpace: ColorSpace, alpha?: T);
|
|
8
|
+
toString(): string;
|
|
9
|
+
toFormattedString(digits?: number): string;
|
|
10
|
+
valueOf(): T[];
|
|
11
|
+
toJSON(): Record<string, T>;
|
|
12
|
+
clone(): this;
|
|
13
|
+
keys(): string[];
|
|
14
|
+
values(): T[];
|
|
15
|
+
entries(): [string, T][];
|
|
16
|
+
protected getComponent(key: string): T | undefined;
|
|
17
|
+
protected setComponent(key: string, value: T): void;
|
|
18
|
+
}
|
|
19
|
+
declare class WhitePointColor<T = number> extends Color<T> {
|
|
20
|
+
whitePoint: WhitePoint;
|
|
21
|
+
constructor(colorSpace: ColorSpace, alpha: T, whitePoint: WhitePoint);
|
|
22
|
+
}
|
|
23
|
+
export declare class RGBColor<T = number> extends Color<T> {
|
|
24
|
+
constructor(r: T, g: T, b: T, alpha?: T);
|
|
25
|
+
get r(): T;
|
|
26
|
+
set r(value: T);
|
|
27
|
+
get g(): T;
|
|
28
|
+
set g(value: T);
|
|
29
|
+
get b(): T;
|
|
30
|
+
set b(value: T);
|
|
31
|
+
}
|
|
32
|
+
export declare class HSLColor<T = number> extends Color<T> {
|
|
33
|
+
constructor(h: T, s: T, l: T, alpha?: T);
|
|
34
|
+
get h(): T;
|
|
35
|
+
set h(value: T);
|
|
36
|
+
get s(): T;
|
|
37
|
+
set s(value: T);
|
|
38
|
+
get l(): T;
|
|
39
|
+
set l(value: T);
|
|
40
|
+
}
|
|
41
|
+
export declare class HSVColor<T = number> extends Color<T> {
|
|
42
|
+
constructor(h: T, s: T, v: T, alpha?: T);
|
|
43
|
+
get h(): T;
|
|
44
|
+
set h(value: T);
|
|
45
|
+
get s(): T;
|
|
46
|
+
set s(value: T);
|
|
47
|
+
get v(): T;
|
|
48
|
+
set v(value: T);
|
|
49
|
+
}
|
|
50
|
+
export declare class HWBColor<T = number> extends Color<T> {
|
|
51
|
+
constructor(h: T, w: T, b: T, alpha?: T);
|
|
52
|
+
get h(): T;
|
|
53
|
+
set h(value: T);
|
|
54
|
+
get w(): T;
|
|
55
|
+
set w(value: T);
|
|
56
|
+
get b(): T;
|
|
57
|
+
set b(value: T);
|
|
58
|
+
}
|
|
59
|
+
export declare class LABColor<T = number> extends WhitePointColor<T> {
|
|
60
|
+
constructor(l: T, a: T, b: T, alpha?: T);
|
|
61
|
+
get l(): T;
|
|
62
|
+
set l(value: T);
|
|
63
|
+
get a(): T;
|
|
64
|
+
set a(value: T);
|
|
65
|
+
get b(): T;
|
|
66
|
+
set b(value: T);
|
|
67
|
+
}
|
|
68
|
+
export declare class LCHColor<T = number> extends Color<T> {
|
|
69
|
+
constructor(l: T, c: T, h: T, alpha?: T);
|
|
70
|
+
get l(): T;
|
|
71
|
+
set l(value: T);
|
|
72
|
+
get c(): T;
|
|
73
|
+
set c(value: T);
|
|
74
|
+
get h(): T;
|
|
75
|
+
set h(value: T);
|
|
76
|
+
}
|
|
77
|
+
export declare class OKLABColor<T = number> extends WhitePointColor<T> {
|
|
78
|
+
constructor(l: T, a: T, b: T, alpha?: T);
|
|
79
|
+
get l(): T;
|
|
80
|
+
set l(value: T);
|
|
81
|
+
get a(): T;
|
|
82
|
+
set a(value: T);
|
|
83
|
+
get b(): T;
|
|
84
|
+
set b(value: T);
|
|
85
|
+
}
|
|
86
|
+
export declare class OKLCHColor<T = number> extends Color<T> {
|
|
87
|
+
constructor(l: T, c: T, h: T, alpha?: T);
|
|
88
|
+
get l(): T;
|
|
89
|
+
set l(value: T);
|
|
90
|
+
get c(): T;
|
|
91
|
+
set c(value: T);
|
|
92
|
+
get h(): T;
|
|
93
|
+
set h(value: T);
|
|
94
|
+
}
|
|
95
|
+
export declare class XYZColor<T = number> extends WhitePointColor<T> {
|
|
96
|
+
constructor(x: T, y: T, z: T, alpha?: T);
|
|
97
|
+
get x(): T;
|
|
98
|
+
set x(value: T);
|
|
99
|
+
get y(): T;
|
|
100
|
+
set y(value: T);
|
|
101
|
+
get z(): T;
|
|
102
|
+
set z(value: T);
|
|
103
|
+
}
|
|
104
|
+
export declare class KelvinColor<T = number> extends Color<T> {
|
|
105
|
+
constructor(kelvin: T, alpha?: T);
|
|
106
|
+
get kelvin(): T;
|
|
107
|
+
set kelvin(value: T);
|
|
108
|
+
}
|
|
109
|
+
export declare class LinearSRGBColor<T = number> extends Color<T> {
|
|
110
|
+
constructor(r: T, g: T, b: T, alpha?: T);
|
|
111
|
+
get r(): T;
|
|
112
|
+
set r(value: T);
|
|
113
|
+
get g(): T;
|
|
114
|
+
set g(value: T);
|
|
115
|
+
get b(): T;
|
|
116
|
+
set b(value: T);
|
|
117
|
+
}
|
|
118
|
+
export declare class DisplayP3Color<T = number> extends Color<T> {
|
|
119
|
+
constructor(r: T, g: T, b: T, alpha?: T);
|
|
120
|
+
get r(): T;
|
|
121
|
+
set r(value: T);
|
|
122
|
+
get g(): T;
|
|
123
|
+
set g(value: T);
|
|
124
|
+
get b(): T;
|
|
125
|
+
set b(value: T);
|
|
126
|
+
}
|
|
127
|
+
export declare class AdobeRGBColor<T = number> extends Color<T> {
|
|
128
|
+
constructor(r: T, g: T, b: T, alpha?: T);
|
|
129
|
+
get r(): T;
|
|
130
|
+
set r(value: T);
|
|
131
|
+
get g(): T;
|
|
132
|
+
set g(value: T);
|
|
133
|
+
get b(): T;
|
|
134
|
+
set b(value: T);
|
|
135
|
+
}
|
|
136
|
+
export declare class ProPhotoRGBColor<T = number> extends Color<T> {
|
|
137
|
+
constructor(r: T, g: T, b: T, alpha?: T);
|
|
138
|
+
get r(): T;
|
|
139
|
+
set r(value: T);
|
|
140
|
+
get g(): T;
|
|
141
|
+
set g(value: T);
|
|
142
|
+
get b(): T;
|
|
143
|
+
set b(value: T);
|
|
144
|
+
}
|
|
145
|
+
export declare class Rec2020Color<T = number> extends Color<T> {
|
|
146
|
+
constructor(r: T, g: T, b: T, alpha?: T);
|
|
147
|
+
get r(): T;
|
|
148
|
+
set r(value: T);
|
|
149
|
+
get g(): T;
|
|
150
|
+
set g(value: T);
|
|
151
|
+
get b(): T;
|
|
152
|
+
set b(value: T);
|
|
153
|
+
}
|
|
154
|
+
export type ColorSpaceMap<T> = {
|
|
155
|
+
rgb: RGBColor<T>;
|
|
156
|
+
hsl: HSLColor<T>;
|
|
157
|
+
hsv: HSVColor<T>;
|
|
158
|
+
hwb: HWBColor<T>;
|
|
159
|
+
lab: LABColor<T>;
|
|
160
|
+
lch: LCHColor<T>;
|
|
161
|
+
oklab: OKLABColor<T>;
|
|
162
|
+
oklch: OKLCHColor<T>;
|
|
163
|
+
kelvin: KelvinColor<T>;
|
|
164
|
+
xyz: XYZColor<T>;
|
|
165
|
+
"srgb-linear": LinearSRGBColor<T>;
|
|
166
|
+
"display-p3": DisplayP3Color<T>;
|
|
167
|
+
"a98-rgb": AdobeRGBColor<T>;
|
|
168
|
+
"prophoto-rgb": ProPhotoRGBColor<T>;
|
|
169
|
+
rec2020: Rec2020Color<T>;
|
|
170
|
+
};
|
|
171
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal 3×3 matrix and 3-element vector math.
|
|
3
|
+
* Replaces gl-matrix dependency — uses native number[] for full f64 precision
|
|
4
|
+
* (gl-matrix uses Float32Array).
|
|
5
|
+
*
|
|
6
|
+
* Mat3 is stored in row-major order:
|
|
7
|
+
* [m00, m01, m02, m10, m11, m12, m20, m21, m22]
|
|
8
|
+
*/
|
|
9
|
+
export type Vec3 = [number, number, number];
|
|
10
|
+
export type Mat3 = [
|
|
11
|
+
number,
|
|
12
|
+
number,
|
|
13
|
+
number,
|
|
14
|
+
number,
|
|
15
|
+
number,
|
|
16
|
+
number,
|
|
17
|
+
number,
|
|
18
|
+
number,
|
|
19
|
+
number
|
|
20
|
+
];
|
|
21
|
+
/** Multiply a Mat3 (row-major) by a Vec3: result = M * v */
|
|
22
|
+
export declare function transformMat3(v: Vec3, m: Mat3): Vec3;
|
|
23
|
+
/** Transpose a Mat3 (row-major → row-major transpose) */
|
|
24
|
+
export declare function transposeMat3(m: Mat3): Mat3;
|
|
25
|
+
/** Multiply two Mat3 matrices (row-major): result = A × B */
|
|
26
|
+
export declare function multiplyMat3(a: Mat3, b: Mat3): Mat3;
|
|
27
|
+
/** Invert a 3×3 matrix via cofactor expansion. Returns the inverse. */
|
|
28
|
+
export declare function invertMat3(m: Mat3): Mat3;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Color, ColorSpaceMap } from '.';
|
|
2
|
+
import { ValueUnit } from '..';
|
|
3
|
+
import { ColorSpace } from './constants';
|
|
4
|
+
import { HueInterpolationMethod } from './utils';
|
|
5
|
+
export type { HueInterpolationMethod };
|
|
6
|
+
export declare const normalizeColorUnitComponent: (v: number, unit: string, colorSpace: ColorSpace, component: string, inverse?: boolean) => ValueUnit<number, string>;
|
|
7
|
+
export declare const normalizeColor: (color: Color<ValueUnit<number> | number>, inverse?: boolean) => Color<ValueUnit<number>>;
|
|
8
|
+
export declare const normalizeColorUnit: (color: ValueUnit<Color<ValueUnit<number>>, "color">, inverse?: boolean, inplace?: boolean) => ValueUnit<Color<ValueUnit<number>>, "color">;
|
|
9
|
+
export declare const colorUnit2: <C extends ColorSpace>(color: ValueUnit<Color<ValueUnit<number>>, "color">, to?: C | null, normalized?: boolean, inverse?: boolean, inplace?: boolean) => ValueUnit<ColorSpaceMap<ValueUnit<number>>[C], "color">;
|
|
10
|
+
export declare const normalizeColorUnits: (a: ValueUnit<Color<ValueUnit<number>>, "color">, b: ValueUnit<Color<ValueUnit<number>>, "color">, to?: ColorSpace, normalized?: boolean, inverse?: boolean, inplace?: boolean, hueMethod?: HueInterpolationMethod) => readonly [ValueUnit<import('.').RGBColor<ValueUnit<number, string | undefined>> | import('.').HSLColor<ValueUnit<number, string | undefined>> | import('.').HSVColor<ValueUnit<number, string | undefined>> | import('.').HWBColor<ValueUnit<number, string | undefined>> | import('.').LABColor<ValueUnit<number, string | undefined>> | import('.').LCHColor<ValueUnit<number, string | undefined>> | import('.').OKLABColor<ValueUnit<number, string | undefined>> | import('.').OKLCHColor<ValueUnit<number, string | undefined>> | import('.').XYZColor<ValueUnit<number, string | undefined>> | import('.').KelvinColor<ValueUnit<number, string | undefined>> | import('.').LinearSRGBColor<ValueUnit<number, string | undefined>> | import('.').DisplayP3Color<ValueUnit<number, string | undefined>> | import('.').AdobeRGBColor<ValueUnit<number, string | undefined>> | import('.').ProPhotoRGBColor<ValueUnit<number, string | undefined>> | import('.').Rec2020Color<ValueUnit<number, string | undefined>>, "color">, ValueUnit<import('.').RGBColor<ValueUnit<number, string | undefined>> | import('.').HSLColor<ValueUnit<number, string | undefined>> | import('.').HSVColor<ValueUnit<number, string | undefined>> | import('.').HWBColor<ValueUnit<number, string | undefined>> | import('.').LABColor<ValueUnit<number, string | undefined>> | import('.').LCHColor<ValueUnit<number, string | undefined>> | import('.').OKLABColor<ValueUnit<number, string | undefined>> | import('.').OKLCHColor<ValueUnit<number, string | undefined>> | import('.').XYZColor<ValueUnit<number, string | undefined>> | import('.').KelvinColor<ValueUnit<number, string | undefined>> | import('.').LinearSRGBColor<ValueUnit<number, string | undefined>> | import('.').DisplayP3Color<ValueUnit<number, string | undefined>> | import('.').AdobeRGBColor<ValueUnit<number, string | undefined>> | import('.').ProPhotoRGBColor<ValueUnit<number, string | undefined>> | import('.').Rec2020Color<ValueUnit<number, string | undefined>>, "color">, HueInterpolationMethod | undefined];
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { AdobeRGBColor, Color, DisplayP3Color, HSLColor, HSVColor, HWBColor, KelvinColor, LABColor, LCHColor, LinearSRGBColor, OKLABColor, OKLCHColor, ProPhotoRGBColor, RGBColor, Rec2020Color, XYZColor, ColorSpaceMap } from '.';
|
|
2
|
+
import { ColorSpace, WhitePoint } from './constants';
|
|
3
|
+
export declare const getFormattedColorSpaceRange: <T extends ColorSpace>(colorSpace: T) => ColorSpaceMap<{
|
|
4
|
+
min: string;
|
|
5
|
+
max: string;
|
|
6
|
+
}>[T];
|
|
7
|
+
export declare const hex2rgb: (hex: string) => RGBColor;
|
|
8
|
+
export declare const rgb2hex: ({ r, g, b, alpha }: RGBColor) => string;
|
|
9
|
+
export declare const kelvin2rgb: ({ kelvin, alpha }: KelvinColor) => RGBColor;
|
|
10
|
+
export declare const rgb2kelvin: ({ r, g, b, alpha }: RGBColor) => KelvinColor;
|
|
11
|
+
export declare const hsv2hsl: ({ h, s, v, alpha }: HSVColor) => HSLColor;
|
|
12
|
+
export declare const hsl2hsv: ({ h, s, l, alpha }: HSLColor) => HSVColor;
|
|
13
|
+
export declare const hwb2hsl: ({ h, w, b, alpha }: HWBColor) => HSLColor;
|
|
14
|
+
export declare const hsl2hwb: ({ h, s, l, alpha }: HSLColor) => HWBColor;
|
|
15
|
+
export declare const rgb2hsl: ({ r, g, b, alpha }: RGBColor) => HSLColor;
|
|
16
|
+
export declare function hsl2rgb({ h, s, l, alpha }: HSLColor): RGBColor;
|
|
17
|
+
export declare function xyz2lab(xyz: XYZColor, toWhitePoint?: WhitePoint): LABColor;
|
|
18
|
+
export declare function lab2xyz(lab: LABColor): XYZColor;
|
|
19
|
+
export declare function srgbToLinear(channel: number): number;
|
|
20
|
+
export declare function linearToSrgb(channel: number): number;
|
|
21
|
+
export declare function rgb2xyz({ r, g, b, alpha }: RGBColor): XYZColor;
|
|
22
|
+
export declare const xyz2rgb: ({ x, y, z, alpha }: XYZColor, correctGamut?: boolean) => RGBColor;
|
|
23
|
+
export declare function lch2lab({ l, c, h, alpha }: LCHColor): LABColor;
|
|
24
|
+
export declare function lab2lch({ l, a, b, alpha }: LABColor): LCHColor;
|
|
25
|
+
export declare function oklab2xyz({ l, a, b, alpha }: OKLABColor): XYZColor;
|
|
26
|
+
export declare function xyz2oklab(xyz: XYZColor): OKLABColor;
|
|
27
|
+
export declare function oklab2lab(oklab: OKLABColor): LABColor;
|
|
28
|
+
export declare function lab2oklab(lab: LABColor): OKLABColor;
|
|
29
|
+
export declare function oklab2oklch({ l, a, b, alpha }: OKLABColor): OKLCHColor;
|
|
30
|
+
export declare function oklch2oklab({ l, c, h, alpha }: OKLCHColor): OKLABColor;
|
|
31
|
+
export declare function oklch2lab(oklch: OKLCHColor): LABColor;
|
|
32
|
+
export declare function lab2oklch(lab: LABColor): OKLCHColor;
|
|
33
|
+
export declare function hsl2xyz(hsl: HSLColor): XYZColor<number>;
|
|
34
|
+
export declare function xyz2hsl(xyz: XYZColor): HSLColor<number>;
|
|
35
|
+
export declare function hsv2xyz(hsv: HSVColor): XYZColor;
|
|
36
|
+
export declare function xyz2hsv(xyz: XYZColor): HSVColor;
|
|
37
|
+
export declare function hwb2xyz(hwb: HWBColor): XYZColor;
|
|
38
|
+
export declare function xyz2hwb(xyz: XYZColor): HWBColor;
|
|
39
|
+
export declare function lch2xyz(lch: LCHColor): XYZColor;
|
|
40
|
+
export declare function xyz2lch(xyz: XYZColor): LCHColor;
|
|
41
|
+
export declare function oklch2xyz(oklch: OKLCHColor): XYZColor;
|
|
42
|
+
export declare function xyz2oklch(xyz: XYZColor): OKLCHColor;
|
|
43
|
+
export declare function kelvin2xyz(kelvin: KelvinColor): XYZColor;
|
|
44
|
+
export declare function xyz2kelvin(xyz: XYZColor): KelvinColor;
|
|
45
|
+
export declare function adobeRgbToLinear(c: number): number;
|
|
46
|
+
export declare function linearToAdobeRgb(c: number): number;
|
|
47
|
+
export declare function proPhotoToLinear(c: number): number;
|
|
48
|
+
export declare function linearToProPhoto(c: number): number;
|
|
49
|
+
export declare function rec2020ToLinear(c: number): number;
|
|
50
|
+
export declare function linearToRec2020(c: number): number;
|
|
51
|
+
export declare function linearSrgb2xyz({ r, g, b, alpha }: LinearSRGBColor): XYZColor;
|
|
52
|
+
export declare function xyz2linearSrgb({ x, y, z, alpha }: XYZColor): LinearSRGBColor;
|
|
53
|
+
export declare function displayP32xyz({ r, g, b, alpha }: DisplayP3Color): XYZColor;
|
|
54
|
+
export declare function xyz2displayP3({ x, y, z, alpha }: XYZColor): DisplayP3Color;
|
|
55
|
+
export declare function adobeRgb2xyz({ r, g, b, alpha }: AdobeRGBColor): XYZColor;
|
|
56
|
+
export declare function xyz2adobeRgb({ x, y, z, alpha }: XYZColor): AdobeRGBColor;
|
|
57
|
+
export declare function proPhoto2xyz({ r, g, b, alpha }: ProPhotoRGBColor): XYZColor;
|
|
58
|
+
export declare function xyz2proPhoto({ x, y, z, alpha }: XYZColor): ProPhotoRGBColor;
|
|
59
|
+
export declare function rec20202xyz({ r, g, b, alpha }: Rec2020Color): XYZColor;
|
|
60
|
+
export declare function xyz2rec2020({ x, y, z, alpha }: XYZColor): Rec2020Color;
|
|
61
|
+
export declare function color2<T, C extends ColorSpace>(color: Color<T>, to: C): Color<T>;
|
|
62
|
+
export { deltaEOK, isInSRGBGamut, DELTA_E_OK_JND } from './gamut';
|
|
63
|
+
export declare function gamutMap<C extends Color>(color: C): C;
|
|
64
|
+
export type HueInterpolationMethod = "shorter" | "longer" | "increasing" | "decreasing";
|
|
65
|
+
export declare const CYLINDRICAL_HUE_COMPONENT: Partial<Record<ColorSpace, string>>;
|
|
66
|
+
/**
|
|
67
|
+
* Interpolate between two hue values using the given method.
|
|
68
|
+
* Hues are in [0, 1] (normalized). Returns an interpolated hue in [0, 1].
|
|
69
|
+
* Handles NaN (CSS `none`): if one hue is NaN, the other's value is used.
|
|
70
|
+
*/
|
|
71
|
+
export declare function interpolateHue(h1: number, h2: number, t: number, method?: HueInterpolationMethod): number;
|
|
72
|
+
/**
|
|
73
|
+
* Mix two colors per CSS color-mix() specification.
|
|
74
|
+
* Both colors should be normalized (components in [0, 1]).
|
|
75
|
+
* Percentages p1, p2 are in [0, 1] (e.g. 0.5 = 50%).
|
|
76
|
+
*/
|
|
77
|
+
export declare function mixColors(col1: Color, col2: Color, p1: number, p2: number, space?: ColorSpace, hueMethod?: HueInterpolationMethod): Color;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const ABSOLUTE_LENGTH_UNITS: readonly ["px", "cm", "mm", "Q", "in", "pc", "pt"];
|
|
2
|
+
export declare const RELATIVE_LENGTH_UNITS: readonly ["em", "ex", "ch", "cap", "ic", "rem", "lh", "rlh", "vw", "vh", "vmin", "vmax", "vb", "vi", "svw", "svh", "svi", "svb", "svmin", "svmax", "lvw", "lvh", "lvi", "lvb", "lvmin", "lvmax", "dvw", "dvh", "dvi", "dvb", "dvmin", "dvmax", "cqw", "cqh", "cqi", "cqb", "cqmin", "cqmax"];
|
|
3
|
+
export declare const LENGTH_UNITS: readonly ["px", "cm", "mm", "Q", "in", "pc", "pt", "em", "ex", "ch", "cap", "ic", "rem", "lh", "rlh", "vw", "vh", "vmin", "vmax", "vb", "vi", "svw", "svh", "svi", "svb", "svmin", "svmax", "lvw", "lvh", "lvi", "lvb", "lvmin", "lvmax", "dvw", "dvh", "dvi", "dvb", "dvmin", "dvmax", "cqw", "cqh", "cqi", "cqb", "cqmin", "cqmax"];
|
|
4
|
+
export declare const TIME_UNITS: readonly ["s", "ms"];
|
|
5
|
+
export declare const ANGLE_UNITS: readonly ["deg", "rad", "grad", "turn"];
|
|
6
|
+
export declare const PERCENTAGE_UNITS: readonly ["%"];
|
|
7
|
+
export declare const FREQUENCY_UNITS: readonly ["Hz", "kHz"];
|
|
8
|
+
export declare const RESOLUTION_UNITS: readonly ["dpi", "dpcm", "dppx"];
|
|
9
|
+
export declare const FLEX_UNITS: readonly ["fr"];
|
|
10
|
+
export declare const COMPUTED_UNITS: readonly ["var", "calc"];
|
|
11
|
+
export declare const STRING_UNITS: readonly ["string"];
|
|
12
|
+
export declare const COLOR_UNITS: readonly ["color"];
|
|
13
|
+
export declare const UNITS: readonly ["px", "cm", "mm", "Q", "in", "pc", "pt", "em", "ex", "ch", "cap", "ic", "rem", "lh", "rlh", "vw", "vh", "vmin", "vmax", "vb", "vi", "svw", "svh", "svi", "svb", "svmin", "svmax", "lvw", "lvh", "lvi", "lvb", "lvmin", "lvmax", "dvw", "dvh", "dvi", "dvb", "dvmin", "dvmax", "cqw", "cqh", "cqi", "cqb", "cqmin", "cqmax", "s", "ms", "deg", "rad", "grad", "turn", "%", "Hz", "kHz", "dpi", "dpcm", "dppx", "fr", "var", "calc", "string", "color", "", undefined];
|
|
14
|
+
export declare const BLACKLISTED_COALESCE_UNITS: readonly ["string", "var", "calc"];
|
|
15
|
+
export interface MatrixValues {
|
|
16
|
+
scaleX: number;
|
|
17
|
+
scaleY: number;
|
|
18
|
+
scaleZ: number;
|
|
19
|
+
skewX: number;
|
|
20
|
+
skewY: number;
|
|
21
|
+
skewZ: number;
|
|
22
|
+
translateX: number;
|
|
23
|
+
translateY: number;
|
|
24
|
+
translateZ: number;
|
|
25
|
+
rotateX: number;
|
|
26
|
+
rotateY: number;
|
|
27
|
+
rotateZ: number;
|
|
28
|
+
perspectiveX: number;
|
|
29
|
+
perspectiveY: number;
|
|
30
|
+
perspectiveZ: number;
|
|
31
|
+
perspectiveW: number;
|
|
32
|
+
}
|
|
33
|
+
export declare const STYLE_NAMES: readonly ["accentColor", "additiveSymbols", "alignContent", "alignItems", "alignSelf", "alignmentBaseline", "all", "anchorName", "animation", "animationComposition", "animationDelay", "animationDirection", "animationDuration", "animationFillMode", "animationIterationCount", "animationName", "animationPlayState", "animationRange", "animationRangeEnd", "animationRangeStart", "animationTimeline", "animationTimingFunction", "appRegion", "appearance", "ascentOverride", "aspectRatio", "backdropFilter", "backfaceVisibility", "background", "backgroundAttachment", "backgroundBlendMode", "backgroundClip", "backgroundColor", "backgroundImage", "backgroundOrigin", "backgroundPosition", "backgroundPositionX", "backgroundPositionY", "backgroundRepeat", "backgroundSize", "basePalette", "baselineShift", "baselineSource", "blockSize", "border", "borderBlock", "borderBlockColor", "borderBlockEnd", "borderBlockEndColor", "borderBlockEndStyle", "borderBlockEndWidth", "borderBlockStart", "borderBlockStartColor", "borderBlockStartStyle", "borderBlockStartWidth", "borderBlockStyle", "borderBlockWidth", "borderBottom", "borderBottomColor", "borderBottomLeftRadius", "borderBottomRightRadius", "borderBottomStyle", "borderBottomWidth", "borderCollapse", "borderColor", "borderEndEndRadius", "borderEndStartRadius", "borderImage", "borderImageOutset", "borderImageRepeat", "borderImageSlice", "borderImageSource", "borderImageWidth", "borderInline", "borderInlineColor", "borderInlineEnd", "borderInlineEndColor", "borderInlineEndStyle", "borderInlineEndWidth", "borderInlineStart", "borderInlineStartColor", "borderInlineStartStyle", "borderInlineStartWidth", "borderInlineStyle", "borderInlineWidth", "borderLeft", "borderLeftColor", "borderLeftStyle", "borderLeftWidth", "borderRadius", "borderRight", "borderRightColor", "borderRightStyle", "borderRightWidth", "borderSpacing", "borderStartEndRadius", "borderStartStartRadius", "borderStyle", "borderTop", "borderTopColor", "borderTopLeftRadius", "borderTopRightRadius", "borderTopStyle", "borderTopWidth", "borderWidth", "bottom", "boxShadow", "boxSizing", "breakAfter", "breakBefore", "breakInside", "bufferedRendering", "captionSide", "caretColor", "clear", "clip", "clipPath", "clipRule", "color", "colorInterpolation", "colorInterpolationFilters", "colorRendering", "colorScheme", "columnCount", "columnFill", "columnGap", "columnRule", "columnRuleColor", "columnRuleStyle", "columnRuleWidth", "columnSpan", "columnWidth", "columns", "contain", "containIntrinsicBlockSize", "containIntrinsicHeight", "containIntrinsicInlineSize", "containIntrinsicSize", "containIntrinsicWidth", "container", "containerName", "containerType", "content", "contentVisibility", "counterIncrement", "counterReset", "counterSet", "cursor", "cx", "cy", "d", "descentOverride", "direction", "display", "dominantBaseline", "emptyCells", "fallback", "fieldSizing", "fill", "fillOpacity", "fillRule", "filter", "flex", "flexBasis", "flexDirection", "flexFlow", "flexGrow", "flexShrink", "flexWrap", "float", "floodColor", "floodOpacity", "font", "fontDisplay", "fontFamily", "fontFeatureSettings", "fontKerning", "fontOpticalSizing", "fontPalette", "fontSize", "fontStretch", "fontStyle", "fontSynthesis", "fontSynthesisSmallCaps", "fontSynthesisStyle", "fontSynthesisWeight", "fontVariant", "fontVariantAlternates", "fontVariantCaps", "fontVariantEastAsian", "fontVariantLigatures", "fontVariantNumeric", "fontVariantPosition", "fontVariationSettings", "fontWeight", "forcedColorAdjust", "gap", "grid", "gridArea", "gridAutoColumns", "gridAutoFlow", "gridAutoRows", "gridColumn", "gridColumnEnd", "gridColumnGap", "gridColumnStart", "gridGap", "gridRow", "gridRowEnd", "gridRowGap", "gridRowStart", "gridTemplate", "gridTemplateAreas", "gridTemplateColumns", "gridTemplateRows", "height", "hyphenateCharacter", "hyphenateLimitChars", "hyphens", "imageOrientation", "imageRendering", "inherits", "initialLetter", "initialValue", "inlineSize", "inset", "insetArea", "insetBlock", "insetBlockEnd", "insetBlockStart", "insetInline", "insetInlineEnd", "insetInlineStart", "isolation", "justifyContent", "justifyItems", "justifySelf", "left", "letterSpacing", "lightingColor", "lineBreak", "lineGapOverride", "lineHeight", "listStyle", "listStyleImage", "listStylePosition", "listStyleType", "margin", "marginBlock", "marginBlockEnd", "marginBlockStart", "marginBottom", "marginInline", "marginInlineEnd", "marginInlineStart", "marginLeft", "marginRight", "marginTop", "marker", "markerEnd", "markerMid", "markerStart", "mask", "maskClip", "maskComposite", "maskImage", "maskMode", "maskOrigin", "maskPosition", "maskRepeat", "maskSize", "maskType", "mathDepth", "mathShift", "mathStyle", "maxBlockSize", "maxHeight", "maxInlineSize", "maxWidth", "minBlockSize", "minHeight", "minInlineSize", "minWidth", "mixBlendMode", "navigation", "negative", "objectFit", "objectPosition", "objectViewBox", "offset", "offsetAnchor", "offsetDistance", "offsetPath", "offsetPosition", "offsetRotate", "opacity", "order", "orphans", "outline", "outlineColor", "outlineOffset", "outlineStyle", "outlineWidth", "overflow", "overflowAnchor", "overflowClipMargin", "overflowWrap", "overflowX", "overflowY", "overlay", "overrideColors", "overscrollBehavior", "overscrollBehaviorBlock", "overscrollBehaviorInline", "overscrollBehaviorX", "overscrollBehaviorY", "pad", "padding", "paddingBlock", "paddingBlockEnd", "paddingBlockStart", "paddingBottom", "paddingInline", "paddingInlineEnd", "paddingInlineStart", "paddingLeft", "paddingRight", "paddingTop", "page", "pageBreakAfter", "pageBreakBefore", "pageBreakInside", "pageOrientation", "paintOrder", "perspective", "perspectiveOrigin", "placeContent", "placeItems", "placeSelf", "pointerEvents", "position", "positionAnchor", "positionTry", "positionTryOptions", "positionTryOrder", "positionVisibility", "prefix", "quotes", "r", "range", "resize", "right", "rotate", "rowGap", "rubyPosition", "rx", "ry", "scale", "scrollBehavior", "scrollMargin", "scrollMarginBlock", "scrollMarginBlockEnd", "scrollMarginBlockStart", "scrollMarginBottom", "scrollMarginInline", "scrollMarginInlineEnd", "scrollMarginInlineStart", "scrollMarginLeft", "scrollMarginRight", "scrollMarginTop", "scrollPadding", "scrollPaddingBlock", "scrollPaddingBlockEnd", "scrollPaddingBlockStart", "scrollPaddingBottom", "scrollPaddingInline", "scrollPaddingInlineEnd", "scrollPaddingInlineStart", "scrollPaddingLeft", "scrollPaddingRight", "scrollPaddingTop", "scrollSnapAlign", "scrollSnapStop", "scrollSnapType", "scrollTimeline", "scrollTimelineAxis", "scrollTimelineName", "scrollbarColor", "scrollbarGutter", "scrollbarWidth", "shapeImageThreshold", "shapeMargin", "shapeOutside", "shapeRendering", "size", "sizeAdjust", "speak", "speakAs", "src", "stopColor", "stopOpacity", "stroke", "strokeDasharray", "strokeDashoffset", "strokeLinecap", "strokeLinejoin", "strokeMiterlimit", "strokeOpacity", "strokeWidth", "suffix", "symbols", "syntax", "system", "tabSize", "tableLayout", "textAlign", "textAlignLast", "textAnchor", "textCombineUpright", "textDecoration", "textDecorationColor", "textDecorationLine", "textDecorationSkipInk", "textDecorationStyle", "textDecorationThickness", "textEmphasis", "textEmphasisColor", "textEmphasisPosition", "textEmphasisStyle", "textIndent", "textOrientation", "textOverflow", "textRendering", "textShadow", "textSizeAdjust", "textSpacingTrim", "textTransform", "textUnderlineOffset", "textUnderlinePosition", "textWrap", "timelineScope", "top", "touchAction", "transform", "transformBox", "transformOrigin", "transformStyle", "transition", "transitionBehavior", "transitionDelay", "transitionDuration", "transitionProperty", "transitionTimingFunction", "translate", "types", "unicodeBidi", "unicodeRange", "userSelect", "vectorEffect", "verticalAlign", "viewTimeline", "viewTimelineAxis", "viewTimelineInset", "viewTimelineName", "viewTransitionClass", "viewTransitionName", "visibility", "webkitAlignContent", "webkitAlignItems", "webkitAlignSelf", "webkitAnimation", "webkitAnimationDelay", "webkitAnimationDirection", "webkitAnimationDuration", "webkitAnimationFillMode", "webkitAnimationIterationCount", "webkitAnimationName", "webkitAnimationPlayState", "webkitAnimationTimingFunction", "webkitAppRegion", "webkitAppearance", "webkitBackfaceVisibility", "webkitBackgroundClip", "webkitBackgroundOrigin", "webkitBackgroundSize", "webkitBorderAfter", "webkitBorderAfterColor", "webkitBorderAfterStyle", "webkitBorderAfterWidth", "webkitBorderBefore", "webkitBorderBeforeColor", "webkitBorderBeforeStyle", "webkitBorderBeforeWidth", "webkitBorderBottomLeftRadius", "webkitBorderBottomRightRadius", "webkitBorderEnd", "webkitBorderEndColor", "webkitBorderEndStyle", "webkitBorderEndWidth", "webkitBorderHorizontalSpacing", "webkitBorderImage", "webkitBorderRadius", "webkitBorderStart", "webkitBorderStartColor", "webkitBorderStartStyle", "webkitBorderStartWidth", "webkitBorderTopLeftRadius", "webkitBorderTopRightRadius", "webkitBorderVerticalSpacing", "webkitBoxAlign", "webkitBoxDecorationBreak", "webkitBoxDirection", "webkitBoxFlex", "webkitBoxOrdinalGroup", "webkitBoxOrient", "webkitBoxPack", "webkitBoxReflect", "webkitBoxShadow", "webkitBoxSizing", "webkitClipPath", "webkitColumnBreakAfter", "webkitColumnBreakBefore", "webkitColumnBreakInside", "webkitColumnCount", "webkitColumnGap", "webkitColumnRule", "webkitColumnRuleColor", "webkitColumnRuleStyle", "webkitColumnRuleWidth", "webkitColumnSpan", "webkitColumnWidth", "webkitColumns", "webkitFilter", "webkitFlex", "webkitFlexBasis", "webkitFlexDirection", "webkitFlexFlow", "webkitFlexGrow", "webkitFlexShrink", "webkitFlexWrap", "webkitFontFeatureSettings", "webkitFontSmoothing", "webkitHyphenateCharacter", "webkitJustifyContent", "webkitLineBreak", "webkitLineClamp", "webkitLocale", "webkitLogicalHeight", "webkitLogicalWidth", "webkitMarginAfter", "webkitMarginBefore", "webkitMarginEnd", "webkitMarginStart", "webkitMask", "webkitMaskBoxImage", "webkitMaskBoxImageOutset", "webkitMaskBoxImageRepeat", "webkitMaskBoxImageSlice", "webkitMaskBoxImageSource", "webkitMaskBoxImageWidth", "webkitMaskClip", "webkitMaskComposite", "webkitMaskImage", "webkitMaskOrigin", "webkitMaskPosition", "webkitMaskPositionX", "webkitMaskPositionY", "webkitMaskRepeat", "webkitMaskSize", "webkitMaxLogicalHeight", "webkitMaxLogicalWidth", "webkitMinLogicalHeight", "webkitMinLogicalWidth", "webkitOpacity", "webkitOrder", "webkitPaddingAfter", "webkitPaddingBefore", "webkitPaddingEnd", "webkitPaddingStart", "webkitPerspective", "webkitPerspectiveOrigin", "webkitPerspectiveOriginX", "webkitPerspectiveOriginY", "webkitPrintColorAdjust", "webkitRtlOrdering", "webkitRubyPosition", "webkitShapeImageThreshold", "webkitShapeMargin", "webkitShapeOutside", "webkitTapHighlightColor", "webkitTextCombine", "webkitTextDecorationsInEffect", "webkitTextEmphasis", "webkitTextEmphasisColor", "webkitTextEmphasisPosition", "webkitTextEmphasisStyle", "webkitTextFillColor", "webkitTextOrientation", "webkitTextSecurity", "webkitTextSizeAdjust", "webkitTextStroke", "webkitTextStrokeColor", "webkitTextStrokeWidth", "webkitTransform", "webkitTransformOrigin", "webkitTransformOriginX", "webkitTransformOriginY", "webkitTransformOriginZ", "webkitTransformStyle", "webkitTransition", "webkitTransitionDelay", "webkitTransitionDuration", "webkitTransitionProperty", "webkitTransitionTimingFunction", "webkitUserDrag", "webkitUserModify", "webkitUserSelect", "webkitWritingMode", "whiteSpace", "whiteSpaceCollapse", "widows", "width", "willChange", "wordBreak", "wordSpacing", "wordWrap", "writingMode", "x", "y", "zIndex", "zoom"];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { UNITS } from './constants';
|
|
2
|
+
export { registerColorNames, clearCustomColorNames, getCustomColorNames } from '../parsing/color';
|
|
3
|
+
export declare class ValueUnit<T = any, U = (typeof UNITS)[number] | string> {
|
|
4
|
+
value: T;
|
|
5
|
+
unit?: U | undefined;
|
|
6
|
+
superType?: string[] | undefined;
|
|
7
|
+
subProperty?: string | undefined;
|
|
8
|
+
property?: string | undefined;
|
|
9
|
+
targets?: HTMLElement[] | undefined;
|
|
10
|
+
constructor(value: T, unit?: U | undefined, superType?: string[] | undefined, subProperty?: string | undefined, property?: string | undefined, targets?: HTMLElement[] | undefined);
|
|
11
|
+
setSubProperty(subProperty: any): void;
|
|
12
|
+
setProperty(property: any): void;
|
|
13
|
+
setTargets(targets: HTMLElement[]): void;
|
|
14
|
+
valueOf(): T;
|
|
15
|
+
setValue(value: T): void;
|
|
16
|
+
toString(): string;
|
|
17
|
+
toJSON(): T;
|
|
18
|
+
toFixed(fractionDigits?: number): string;
|
|
19
|
+
clone(): ValueUnit<T, U>;
|
|
20
|
+
coalesce(right?: ValueUnit, inplace?: boolean): ValueUnit<any, any>;
|
|
21
|
+
}
|
|
22
|
+
export declare class FunctionValue<T = any, N extends string = string> {
|
|
23
|
+
name: N;
|
|
24
|
+
values: Array<ValueUnit<T> | FunctionValue<T>>;
|
|
25
|
+
constructor(name: N, values: Array<ValueUnit<T> | FunctionValue<T>>);
|
|
26
|
+
setSubProperty(subProperty: any): void;
|
|
27
|
+
setProperty(property: any): void;
|
|
28
|
+
setTargets(targets: HTMLElement[]): void;
|
|
29
|
+
setValue(value: T, index?: number): void;
|
|
30
|
+
valueOf(): any[];
|
|
31
|
+
toString(): string;
|
|
32
|
+
toJSON(): Record<string, any[]>;
|
|
33
|
+
clone(): FunctionValue<T>;
|
|
34
|
+
}
|
|
35
|
+
export declare class ValueArray<T = any> extends Array<ValueUnit<T> | FunctionValue<T>> {
|
|
36
|
+
constructor(...args: Array<ValueUnit<T> | FunctionValue<T>>);
|
|
37
|
+
setSubProperty(subProperty: any): void;
|
|
38
|
+
setProperty(property: any): void;
|
|
39
|
+
setTargets(targets: HTMLElement[]): void;
|
|
40
|
+
setValue(value: T, index?: number): void;
|
|
41
|
+
valueOf(): (any[] | T)[];
|
|
42
|
+
toString(): string;
|
|
43
|
+
toJSON(): (Record<string, any[]> | T)[];
|
|
44
|
+
clone(): ValueArray<T>;
|
|
45
|
+
}
|
|
46
|
+
export type InterpolatedVar<T> = {
|
|
47
|
+
start: ValueUnit<T>;
|
|
48
|
+
stop: ValueUnit<T>;
|
|
49
|
+
value: ValueUnit<T>;
|
|
50
|
+
computed: boolean;
|
|
51
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ValueUnit, InterpolatedVar } from '.';
|
|
2
|
+
export declare const getComputedValue: ((value: ValueUnit, target: HTMLElement) => ValueUnit<any, any>) & {
|
|
3
|
+
cache: Map<string, {
|
|
4
|
+
value: ValueUnit<any, any>;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
}>;
|
|
7
|
+
};
|
|
8
|
+
export declare const normalizeNumericUnits: (a: ValueUnit, b: ValueUnit, inplace?: boolean) => [ValueUnit, ValueUnit];
|
|
9
|
+
export declare function normalizeValueUnits(left: ValueUnit, right: ValueUnit): InterpolatedVar<any>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FunctionValue, ValueUnit } from '.';
|
|
2
|
+
import { Color } from './color';
|
|
3
|
+
import { ABSOLUTE_LENGTH_UNITS, ANGLE_UNITS, FREQUENCY_UNITS, PERCENTAGE_UNITS, RELATIVE_LENGTH_UNITS, RESOLUTION_UNITS, STYLE_NAMES, TIME_UNITS, UNITS, MatrixValues } from './constants';
|
|
4
|
+
export declare function isColorUnit(value: ValueUnit<Color<ValueUnit>>): value is ValueUnit<Color<ValueUnit>>;
|
|
5
|
+
export declare const flattenObject: (obj: any) => Record<string, any>;
|
|
6
|
+
export declare const unflattenObject: (flatObj: Record<string, any[]>) => any;
|
|
7
|
+
export declare const unflattenObjectToString: (flatObj: Record<string, any[]>) => Record<string, string>;
|
|
8
|
+
export declare function isCSSStyleName(value: any): value is (typeof STYLE_NAMES)[number];
|
|
9
|
+
export declare const unpackMatrixValues: (value: FunctionValue) => MatrixValues;
|
|
10
|
+
export declare function convertAbsoluteUnitToPixels(value: number, unit: string): number;
|
|
11
|
+
export declare function convertToPixels(value: number, unit: (typeof ABSOLUTE_LENGTH_UNITS)[number] | (typeof RELATIVE_LENGTH_UNITS)[number] | (typeof PERCENTAGE_UNITS)[number], element?: HTMLElement, property?: string): number;
|
|
12
|
+
export declare function convertToMs(value: number, unit: (typeof TIME_UNITS)[number]): number;
|
|
13
|
+
export declare function convertToDegrees(value: number, unit: (typeof ANGLE_UNITS)[number]): number;
|
|
14
|
+
export declare function convertToHz(value: number, unit: (typeof FREQUENCY_UNITS)[number]): number;
|
|
15
|
+
export declare function convertToDPI(value: number, unit: (typeof RESOLUTION_UNITS)[number]): number;
|
|
16
|
+
declare function convert2(value: number, from: (typeof UNITS)[number], to: (typeof UNITS)[number], target?: HTMLElement): number;
|
|
17
|
+
export { convert2 };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const FRAME_RATE: number;
|
|
2
|
+
export declare const isObject: (value: any) => boolean;
|
|
3
|
+
export declare function clone(obj: any): any;
|
|
4
|
+
export declare const arrayEquals: (a: any[], b: any[]) => boolean;
|
|
5
|
+
export declare function sleep(ms: number): Promise<unknown>;
|
|
6
|
+
export declare function waitUntil(condition: () => boolean, delay?: number): Promise<void>;
|
|
7
|
+
export declare function debounce<T extends (...args: any[]) => any>(func: T, wait?: number, immediate?: boolean): ((...args: Parameters<T>) => void) & {
|
|
8
|
+
cancel: () => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function createHash(algorithm: string, data: string): Promise<string>;
|
|
11
|
+
export interface MemoizeOptions<T extends (...args: any[]) => any = (...args: any[]) => any> {
|
|
12
|
+
maxCacheSize?: number;
|
|
13
|
+
ttl?: number;
|
|
14
|
+
keyFn?: (...args: any[]) => string;
|
|
15
|
+
/** When provided, the result is only cached if this returns true. */
|
|
16
|
+
shouldCache?: (result: ReturnType<T>, ...args: Parameters<T>) => boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function memoize<T extends (...args: any[]) => any>(func: T, options?: MemoizeOptions<T>): T & {
|
|
19
|
+
cache: Map<string, {
|
|
20
|
+
value: ReturnType<T>;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
export declare const hyphenToCamelCase: (str: string) => string;
|
|
25
|
+
export declare function camelCaseToHyphen(str: string): string;
|
|
26
|
+
export declare function seekPreviousValue<T>(ix: number, values: T[], pred: (f: T) => boolean): number | undefined;
|
|
27
|
+
export declare function requestAnimationFrame(callback: FrameRequestCallback): number | NodeJS.Timeout;
|
|
28
|
+
export declare function cancelAnimationFrame(handle: number | undefined | null | any): void;
|