@pixerate/editor 0.145.0 → 0.147.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +4 -2
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/dist/agent/index.cjs +36 -34
  4. package/dist/agent/index.js +7 -5
  5. package/dist/animation/index.cjs +5 -3
  6. package/dist/animation/index.js +4 -2
  7. package/dist/animation-editor/index.cjs +62 -60
  8. package/dist/animation-editor/index.js +6 -4
  9. package/dist/canvas/index.cjs +36 -34
  10. package/dist/canvas/index.js +19 -17
  11. package/dist/chart/index.cjs +88 -86
  12. package/dist/chart/index.js +7 -5
  13. package/dist/{chunk-WBJ6BG4R.js → chunk-2AQL4JHM.js} +6 -6
  14. package/dist/{chunk-HLMF3E53.cjs → chunk-2WDZI6QD.cjs} +15 -15
  15. package/dist/{chunk-ZNHB5RG6.js → chunk-37RLSNQ3.js} +2 -2
  16. package/dist/{chunk-5WOY52O6.cjs → chunk-4YQKRHMI.cjs} +8 -8
  17. package/dist/chunk-6ONMQ6WF.js +113 -0
  18. package/dist/{chunk-L434J57V.cjs → chunk-6QTON3VW.cjs} +16 -16
  19. package/dist/chunk-AA34BA7G.js +1913 -0
  20. package/dist/{chunk-QX25HWFL.js → chunk-AY65VQSU.js} +1 -1
  21. package/dist/{chunk-ONZJD2OD.cjs → chunk-BROJYMWU.cjs} +57 -153
  22. package/dist/{chunk-YM75DN54.js → chunk-DSZCDNTM.js} +1 -1
  23. package/dist/{chunk-PUR6BZFA.cjs → chunk-DVLMW3GB.cjs} +53 -53
  24. package/dist/{chunk-ALUWD3FG.js → chunk-EIUTJPEL.js} +1 -1
  25. package/dist/{chunk-X65C4DWV.js → chunk-EQ4SF4X4.js} +1 -1
  26. package/dist/{chunk-77SG47WT.js → chunk-FLOGD3QB.js} +1 -1
  27. package/dist/chunk-HRLT5BYO.js +133 -0
  28. package/dist/{chunk-AJSW5GMP.js → chunk-HVQVHUTV.js} +19 -115
  29. package/dist/{chunk-UR37VCIR.cjs → chunk-I4AHLP7F.cjs} +16 -35
  30. package/dist/chunk-IPJ3TEYR.cjs +113 -0
  31. package/dist/chunk-KC7HB5GF.cjs +133 -0
  32. package/dist/chunk-KY3FYKP3.js +52 -0
  33. package/dist/chunk-LEUZ4FRC.cjs +52 -0
  34. package/dist/{chunk-H6FX45CP.cjs → chunk-LIXLD433.cjs} +37 -37
  35. package/dist/{chunk-6GAYGQDC.js → chunk-O5ML2I6O.js} +3 -3
  36. package/dist/{chunk-KI2VBONS.js → chunk-OET45HIR.js} +2 -2
  37. package/dist/{chunk-XNZWATSB.cjs → chunk-QCEQIRJQ.cjs} +85 -85
  38. package/dist/{chunk-HRI3ZMDM.cjs → chunk-RHXW4TA5.cjs} +3 -3
  39. package/dist/{chunk-UUTTJK77.cjs → chunk-SUF6WRXR.cjs} +2 -2
  40. package/dist/{chunk-RN767PO6.js → chunk-SUVZJ2CP.js} +15 -34
  41. package/dist/{chunk-FLUTRPLY.cjs → chunk-TLMRGLQQ.cjs} +16 -16
  42. package/dist/{chunk-DAS7M4RY.js → chunk-UILRJQFD.js} +2 -2
  43. package/dist/chunk-UKCJ43YL.cjs +1913 -0
  44. package/dist/{chunk-XQ33O5BC.cjs → chunk-X35BV5YT.cjs} +44 -44
  45. package/dist/{chunk-6HMEHNWW.cjs → chunk-XTU6QO2W.cjs} +26 -26
  46. package/dist/{chunk-VM6JYWXQ.js → chunk-ZQUANEK4.js} +2 -2
  47. package/dist/cms/index.cjs +5 -3
  48. package/dist/cms/index.js +18 -16
  49. package/dist/color/contrast.d.cts +14 -0
  50. package/dist/color/contrast.d.ts +14 -0
  51. package/dist/color/convert.d.cts +30 -0
  52. package/dist/color/convert.d.ts +30 -0
  53. package/dist/color/dual.d.cts +98 -0
  54. package/dist/color/dual.d.ts +98 -0
  55. package/dist/color/format.d.cts +12 -0
  56. package/dist/color/format.d.ts +12 -0
  57. package/dist/color/gamut.d.cts +12 -0
  58. package/dist/color/gamut.d.ts +12 -0
  59. package/dist/color/harmony.d.cts +22 -0
  60. package/dist/color/harmony.d.ts +22 -0
  61. package/dist/color/index.cjs +115 -0
  62. package/dist/color/index.d.cts +18 -0
  63. package/dist/color/index.d.ts +18 -0
  64. package/dist/color/index.js +115 -0
  65. package/dist/color/mix.d.cts +11 -0
  66. package/dist/color/mix.d.ts +11 -0
  67. package/dist/color/named.d.cts +5 -0
  68. package/dist/color/named.d.ts +5 -0
  69. package/dist/color/parse.d.cts +11 -0
  70. package/dist/color/parse.d.ts +11 -0
  71. package/dist/color/picker.d.cts +52 -0
  72. package/dist/color/picker.d.ts +52 -0
  73. package/dist/color/recent.d.cts +8 -0
  74. package/dist/color/recent.d.ts +8 -0
  75. package/dist/color/tools.d.cts +15 -0
  76. package/dist/color/tools.d.ts +15 -0
  77. package/dist/color/types.d.cts +41 -0
  78. package/dist/color/types.d.ts +41 -0
  79. package/dist/color/vision.d.cts +36 -0
  80. package/dist/color/vision.d.ts +36 -0
  81. package/dist/diagram/editorDocument.d.cts +12 -0
  82. package/dist/diagram/editorDocument.d.ts +12 -0
  83. package/dist/diagram/index.cjs +35 -1
  84. package/dist/diagram/index.d.cts +1 -0
  85. package/dist/diagram/index.d.ts +1 -0
  86. package/dist/diagram/index.js +34 -0
  87. package/dist/export/index.cjs +6 -4
  88. package/dist/export/index.js +5 -3
  89. package/dist/extensions/index.cjs +10 -8
  90. package/dist/extensions/index.js +9 -7
  91. package/dist/gradient/controller.d.cts +109 -0
  92. package/dist/gradient/controller.d.ts +109 -0
  93. package/dist/gradient/editor.d.cts +38 -0
  94. package/dist/gradient/editor.d.ts +38 -0
  95. package/dist/gradient/index.cjs +1549 -0
  96. package/dist/gradient/index.d.cts +5 -0
  97. package/dist/gradient/index.d.ts +5 -0
  98. package/dist/gradient/index.js +1549 -0
  99. package/dist/gradient/model.d.cts +94 -0
  100. package/dist/gradient/model.d.ts +94 -0
  101. package/dist/gradient/tools.d.cts +11 -0
  102. package/dist/gradient/tools.d.ts +11 -0
  103. package/dist/gradient/types.d.cts +44 -0
  104. package/dist/gradient/types.d.ts +44 -0
  105. package/dist/image-editor/index.cjs +649 -647
  106. package/dist/image-editor/index.js +6 -4
  107. package/dist/index.cjs +19 -17
  108. package/dist/index.js +16 -14
  109. package/dist/paint-editor/color.d.cts +3 -13
  110. package/dist/paint-editor/color.d.ts +3 -13
  111. package/dist/paint-editor/index.cjs +23 -68
  112. package/dist/paint-editor/index.js +15 -60
  113. package/dist/persistence/documentStore.d.cts +51 -0
  114. package/dist/persistence/documentStore.d.ts +51 -0
  115. package/dist/persistence/documentTools.d.cts +35 -0
  116. package/dist/persistence/documentTools.d.ts +35 -0
  117. package/dist/persistence/editorAutosave.d.cts +33 -0
  118. package/dist/persistence/editorAutosave.d.ts +33 -0
  119. package/dist/persistence/editorDocument.d.cts +118 -0
  120. package/dist/persistence/editorDocument.d.ts +118 -0
  121. package/dist/persistence/index.cjs +294 -1
  122. package/dist/persistence/index.d.cts +4 -0
  123. package/dist/persistence/index.d.ts +4 -0
  124. package/dist/persistence/index.js +293 -0
  125. package/dist/vector/index.cjs +950 -948
  126. package/dist/vector/index.js +5 -3
  127. package/dist/video-editor/index.cjs +5 -3
  128. package/dist/video-editor/index.js +4 -2
  129. package/package.json +21 -1
  130. package/skills/README.md +1 -0
  131. package/skills/pixerate-agent-tools/SKILL.md +21 -0
  132. package/skills/pixerate-color/SKILL.md +69 -0
  133. package/skills/pixerate-diagram/SKILL.md +13 -0
  134. package/dist/chunk-45VRG4RB.js +0 -65
  135. package/dist/chunk-5FXOR7F2.cjs +0 -65
package/dist/cms/index.js CHANGED
@@ -5,12 +5,9 @@ import {
5
5
  Clut,
6
6
  CmsError,
7
7
  CmykModel,
8
- D50,
9
- D65_XY,
10
8
  DEFAULT_CMYK_PARAMS,
11
9
  DEFAULT_TRANSFORM_OPTIONS,
12
10
  GamutCheck,
13
- IDENTITY,
14
11
  IDENTITY_CURVE,
15
12
  INTENTS,
16
13
  Lut3d,
@@ -19,19 +16,14 @@ import {
19
16
  Pipeline,
20
17
  SAME_COLORS_MAX_DELTA_E,
21
18
  Transform,
22
- apply,
23
19
  blackPoint,
24
- bradford,
25
20
  builtinProfile,
26
21
  builtinProfileId,
27
22
  cachedTransform,
28
23
  canBeDestination,
29
24
  classSig,
30
25
  cmykProfile,
31
- d50Quantized,
32
26
  defaultProfileFor,
33
- deltaE76,
34
- det,
35
27
  deviceToPcs,
36
28
  encodeProfile,
37
29
  evalCurve,
@@ -40,22 +32,17 @@ import {
40
32
  grayAsRgb,
41
33
  intentCode,
42
34
  intentFromCode,
43
- invert,
44
35
  isIdentityCurve,
45
36
  isMatrixShaper,
46
- labToXyz,
47
37
  linkStages,
48
38
  matrix3,
49
39
  mediaWhite,
50
- mul,
51
40
  paramCount,
52
41
  parseProfile,
53
42
  pcsToDevice,
54
43
  profileChannels,
55
44
  readJpegIcc,
56
45
  readPngIcc,
57
- rgbToXyzMatrix,
58
- s15f16Round,
59
46
  sameColors,
60
47
  sampleCurve,
61
48
  separate,
@@ -66,11 +53,26 @@ import {
66
53
  stageOutputs,
67
54
  supportsIntent,
68
55
  writeJpegIcc,
69
- writePngIcc,
56
+ writePngIcc
57
+ } from "../chunk-HVQVHUTV.js";
58
+ import "../chunk-QGHEDC7B.js";
59
+ import {
60
+ D50,
61
+ D65_XY,
62
+ IDENTITY,
63
+ apply,
64
+ bradford,
65
+ d50Quantized,
66
+ deltaE76,
67
+ det,
68
+ invert,
69
+ labToXyz,
70
+ mul,
71
+ rgbToXyzMatrix,
72
+ s15f16Round,
70
73
  xyToXyz,
71
74
  xyzToLab
72
- } from "../chunk-AJSW5GMP.js";
73
- import "../chunk-QGHEDC7B.js";
75
+ } from "../chunk-6ONMQ6WF.js";
74
76
  export {
75
77
  BUILTIN_COPYRIGHT,
76
78
  BUILTIN_PROFILES,
@@ -0,0 +1,14 @@
1
+ /**
2
+ * WCAG 2 contrast calculations, relative luminance and readability checks.
3
+ */
4
+ import type { Rgba, ContrastLevel } from './types.cjs';
5
+ /** Computes WCAG 2 relative luminance (0 for black, 1 for white). */
6
+ export declare function relativeLuminance(c: Rgba): number;
7
+ /** Computes the WCAG 2 contrast ratio between two colours, from 1 to 21. */
8
+ export declare function contrastRatio(foreground: Rgba, background: Rgba): number;
9
+ /** Returns the WCAG contrast compliance level: 'AAA', 'AA', or 'fail'. */
10
+ export declare function contrastLevel(ratio: number, options?: {
11
+ large?: boolean;
12
+ }): ContrastLevel;
13
+ /** Selects the candidate colour that has the highest contrast ratio against the background. */
14
+ export declare function readableTextColor(background: Rgba, candidates?: readonly Rgba[]): Rgba;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * WCAG 2 contrast calculations, relative luminance and readability checks.
3
+ */
4
+ import type { Rgba, ContrastLevel } from './types.js';
5
+ /** Computes WCAG 2 relative luminance (0 for black, 1 for white). */
6
+ export declare function relativeLuminance(c: Rgba): number;
7
+ /** Computes the WCAG 2 contrast ratio between two colours, from 1 to 21. */
8
+ export declare function contrastRatio(foreground: Rgba, background: Rgba): number;
9
+ /** Returns the WCAG contrast compliance level: 'AAA', 'AA', or 'fail'. */
10
+ export declare function contrastLevel(ratio: number, options?: {
11
+ large?: boolean;
12
+ }): ContrastLevel;
13
+ /** Selects the candidate colour that has the highest contrast ratio against the background. */
14
+ export declare function readableTextColor(background: Rgba, candidates?: readonly Rgba[]): Rgba;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Colour space conversion math: sRGB ↔ linear, HSL, HSV, OKLab, OKLCH and Display P3.
3
+ */
4
+ import type { Rgba, Hsla, Hsva, Oklab, Oklch } from './types.cjs';
5
+ /** Converts an sRGB gamma-encoded channel (0–1 nominally) to linear sRGB, keeping sign. */
6
+ export declare function srgbToLinear(v: number): number;
7
+ /** Converts a linear sRGB channel to sRGB gamma-encoded, keeping sign. */
8
+ export declare function linearToSrgb(v: number): number;
9
+ /** Converts sRGB channels (0–1) to HSL with h in 0–360, s and l in 0–1. */
10
+ export declare function rgbToHsl(rgba: Rgba): Hsla;
11
+ /** Converts HSL with h in 0–360, s and l in 0–1 to sRGB channels (0–1). */
12
+ export declare function hslToRgb(hsla: Hsla): Rgba;
13
+ /** Converts sRGB channels (0–1) to HSV with h in 0–360, s and v in 0–1. */
14
+ export declare function rgbToHsv(rgba: Rgba): Hsva;
15
+ /** Converts HSV with h in 0–360, s and v in 0–1 to sRGB channels (0–1). */
16
+ export declare function hsvToRgb(hsva: Hsva): Rgba;
17
+ /** Converts sRGB channels (0–1) to OKLab. Wide-gamut inputs are unclamped. */
18
+ export declare function rgbToOklab(rgba: Rgba): Oklab;
19
+ /** Converts OKLab to sRGB channels without clamping. */
20
+ export declare function oklabToRgb(lab: Oklab): Rgba;
21
+ /** Converts OKLab to OKLCH with h in degrees 0–360 (0 when c < 1e-6). */
22
+ export declare function oklabToOklch(lab: Oklab): Oklch;
23
+ /** Converts OKLCH with h in degrees to OKLab. */
24
+ export declare function oklchToOklab(lch: Oklch): OklchToOklabResult;
25
+ type OklchToOklabResult = Oklab;
26
+ /** Converts linear sRGB channels to linear Display P3 channels (linear in, linear out). */
27
+ export declare function linearSrgbToDisplayP3(rgb: Rgba): Rgba;
28
+ /** Converts linear Display P3 channels to linear sRGB channels (linear in, linear out). */
29
+ export declare function displayP3ToLinearSrgb(rgb: Rgba): Rgba;
30
+ export {};
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Colour space conversion math: sRGB ↔ linear, HSL, HSV, OKLab, OKLCH and Display P3.
3
+ */
4
+ import type { Rgba, Hsla, Hsva, Oklab, Oklch } from './types.js';
5
+ /** Converts an sRGB gamma-encoded channel (0–1 nominally) to linear sRGB, keeping sign. */
6
+ export declare function srgbToLinear(v: number): number;
7
+ /** Converts a linear sRGB channel to sRGB gamma-encoded, keeping sign. */
8
+ export declare function linearToSrgb(v: number): number;
9
+ /** Converts sRGB channels (0–1) to HSL with h in 0–360, s and l in 0–1. */
10
+ export declare function rgbToHsl(rgba: Rgba): Hsla;
11
+ /** Converts HSL with h in 0–360, s and l in 0–1 to sRGB channels (0–1). */
12
+ export declare function hslToRgb(hsla: Hsla): Rgba;
13
+ /** Converts sRGB channels (0–1) to HSV with h in 0–360, s and v in 0–1. */
14
+ export declare function rgbToHsv(rgba: Rgba): Hsva;
15
+ /** Converts HSV with h in 0–360, s and v in 0–1 to sRGB channels (0–1). */
16
+ export declare function hsvToRgb(hsva: Hsva): Rgba;
17
+ /** Converts sRGB channels (0–1) to OKLab. Wide-gamut inputs are unclamped. */
18
+ export declare function rgbToOklab(rgba: Rgba): Oklab;
19
+ /** Converts OKLab to sRGB channels without clamping. */
20
+ export declare function oklabToRgb(lab: Oklab): Rgba;
21
+ /** Converts OKLab to OKLCH with h in degrees 0–360 (0 when c < 1e-6). */
22
+ export declare function oklabToOklch(lab: Oklab): Oklch;
23
+ /** Converts OKLCH with h in degrees to OKLab. */
24
+ export declare function oklchToOklab(lch: Oklch): OklchToOklabResult;
25
+ type OklchToOklabResult = Oklab;
26
+ /** Converts linear sRGB channels to linear Display P3 channels (linear in, linear out). */
27
+ export declare function linearSrgbToDisplayP3(rgb: Rgba): Rgba;
28
+ /** Converts linear Display P3 channels to linear sRGB channels (linear in, linear out). */
29
+ export declare function displayP3ToLinearSrgb(rgb: Rgba): Rgba;
30
+ export {};
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Dual colours: paired colour values for light mode and dark mode,
3
+ * with CSS light-dark() parsing and generation, contrast checks, and scheme derivation.
4
+ */
5
+ import type { ContrastLevel } from './types.cjs';
6
+ export type ColorScheme = 'light' | 'dark';
7
+ /** A colour for each scheme. Both are any CSS colour; `normalizeDualColor` stores them as hex. */
8
+ export interface DualColor {
9
+ light: string;
10
+ dark: string;
11
+ }
12
+ /** Either a plain colour (the same in both schemes) or a dual colour. */
13
+ export type ColorValue = string | DualColor;
14
+ /** Default surface backgrounds used for scheme derivation and contrast evaluations. */
15
+ export declare const DEFAULT_SCHEME_SURFACES: DualColor;
16
+ /**
17
+ * Returns true if the value is an object with string `light` and `dark` properties.
18
+ */
19
+ export declare function isDualColor(value: unknown): value is DualColor;
20
+ /**
21
+ * Parses a dual colour value.
22
+ *
23
+ * Accepts:
24
+ * - A `DualColor` object `{ light, dark }`
25
+ * - A CSS `light-dark(<light>, <dark>)` string
26
+ * - A plain CSS colour (which resolves to `{ light: c, dark: c }`)
27
+ *
28
+ * Note: `parseColor` returns `null` for `light-dark(...)` because a single Rgba
29
+ * cannot hold two colours. Use `parseDualColor` or `resolveColor` when handling dual colours.
30
+ *
31
+ * Returns `null` if either half cannot be parsed, or if `light-dark()` is nested. Never throws.
32
+ */
33
+ export declare function parseDualColor(input: unknown): DualColor | null;
34
+ /**
35
+ * Parses and normalises a dual colour, converting both halves to lowercase hex.
36
+ */
37
+ export declare function normalizeDualColor(input: unknown): DualColor | null;
38
+ /**
39
+ * Resolves a colour value (plain colour, dual colour object, or light-dark() CSS string)
40
+ * to a normalised hex string for the specified scheme ('light' or 'dark').
41
+ *
42
+ * Use this when drawing to Canvas, SVG presentation attributes, or exporting to formats
43
+ * that do not support CSS `light-dark()`.
44
+ */
45
+ export declare function resolveColor(value: unknown, scheme: ColorScheme): string | null;
46
+ /**
47
+ * Formats a DualColor into CSS syntax: `light-dark(#a, #b)`, or `#a` if both halves are equal.
48
+ */
49
+ export declare function formatDualColor(value: DualColor): string;
50
+ /**
51
+ * Returns true if both halves of the dual colour normalise to the same value.
52
+ */
53
+ export declare function isSameInBothSchemes(value: DualColor): boolean;
54
+ /**
55
+ * Changes one half of a dual colour, returning a normalised DualColor.
56
+ * If given a plain colour, it first expands to a pair of that colour before updating the side.
57
+ */
58
+ export declare function setDualColorSide(value: ColorValue, scheme: ColorScheme, color: string): DualColor;
59
+ /**
60
+ * Derives the opposing scheme half automatically from a given base colour.
61
+ *
62
+ * Options:
63
+ * - `from`: which scheme the input colour belongs to (default `'light'`).
64
+ * - `surfaces`: background surfaces for light and dark schemes. When provided,
65
+ * matches the contrast ratio against the target surface.
66
+ *
67
+ * Throws when `color` or `surfaces` can't be read.
68
+ */
69
+ export declare function deriveDualColor(color: string, options?: {
70
+ from?: ColorScheme;
71
+ surfaces?: DualColor;
72
+ }): DualColor;
73
+ /**
74
+ * Checks contrast compliance of a foreground/background dual colour pair across both modes.
75
+ * Throws when either value can't be read.
76
+ */
77
+ export declare function checkDualColorContrast(foreground: ColorValue, background: ColorValue, options?: {
78
+ large?: boolean;
79
+ }): {
80
+ light: {
81
+ ratio: number;
82
+ level: ContrastLevel;
83
+ };
84
+ dark: {
85
+ ratio: number;
86
+ level: ContrastLevel;
87
+ };
88
+ issues: string[];
89
+ };
90
+ /**
91
+ * Formats a dictionary of dual colours as CSS custom properties according to a strategy.
92
+ * Keys are variable names without `--`. Throws on an invalid name, colour or selector.
93
+ */
94
+ export declare function dualColorsToCss(colors: Record<string, ColorValue>, options?: {
95
+ selector?: string;
96
+ strategy?: 'light-dark' | 'media' | 'class';
97
+ darkSelector?: string;
98
+ }): string;
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Dual colours: paired colour values for light mode and dark mode,
3
+ * with CSS light-dark() parsing and generation, contrast checks, and scheme derivation.
4
+ */
5
+ import type { ContrastLevel } from './types.js';
6
+ export type ColorScheme = 'light' | 'dark';
7
+ /** A colour for each scheme. Both are any CSS colour; `normalizeDualColor` stores them as hex. */
8
+ export interface DualColor {
9
+ light: string;
10
+ dark: string;
11
+ }
12
+ /** Either a plain colour (the same in both schemes) or a dual colour. */
13
+ export type ColorValue = string | DualColor;
14
+ /** Default surface backgrounds used for scheme derivation and contrast evaluations. */
15
+ export declare const DEFAULT_SCHEME_SURFACES: DualColor;
16
+ /**
17
+ * Returns true if the value is an object with string `light` and `dark` properties.
18
+ */
19
+ export declare function isDualColor(value: unknown): value is DualColor;
20
+ /**
21
+ * Parses a dual colour value.
22
+ *
23
+ * Accepts:
24
+ * - A `DualColor` object `{ light, dark }`
25
+ * - A CSS `light-dark(<light>, <dark>)` string
26
+ * - A plain CSS colour (which resolves to `{ light: c, dark: c }`)
27
+ *
28
+ * Note: `parseColor` returns `null` for `light-dark(...)` because a single Rgba
29
+ * cannot hold two colours. Use `parseDualColor` or `resolveColor` when handling dual colours.
30
+ *
31
+ * Returns `null` if either half cannot be parsed, or if `light-dark()` is nested. Never throws.
32
+ */
33
+ export declare function parseDualColor(input: unknown): DualColor | null;
34
+ /**
35
+ * Parses and normalises a dual colour, converting both halves to lowercase hex.
36
+ */
37
+ export declare function normalizeDualColor(input: unknown): DualColor | null;
38
+ /**
39
+ * Resolves a colour value (plain colour, dual colour object, or light-dark() CSS string)
40
+ * to a normalised hex string for the specified scheme ('light' or 'dark').
41
+ *
42
+ * Use this when drawing to Canvas, SVG presentation attributes, or exporting to formats
43
+ * that do not support CSS `light-dark()`.
44
+ */
45
+ export declare function resolveColor(value: unknown, scheme: ColorScheme): string | null;
46
+ /**
47
+ * Formats a DualColor into CSS syntax: `light-dark(#a, #b)`, or `#a` if both halves are equal.
48
+ */
49
+ export declare function formatDualColor(value: DualColor): string;
50
+ /**
51
+ * Returns true if both halves of the dual colour normalise to the same value.
52
+ */
53
+ export declare function isSameInBothSchemes(value: DualColor): boolean;
54
+ /**
55
+ * Changes one half of a dual colour, returning a normalised DualColor.
56
+ * If given a plain colour, it first expands to a pair of that colour before updating the side.
57
+ */
58
+ export declare function setDualColorSide(value: ColorValue, scheme: ColorScheme, color: string): DualColor;
59
+ /**
60
+ * Derives the opposing scheme half automatically from a given base colour.
61
+ *
62
+ * Options:
63
+ * - `from`: which scheme the input colour belongs to (default `'light'`).
64
+ * - `surfaces`: background surfaces for light and dark schemes. When provided,
65
+ * matches the contrast ratio against the target surface.
66
+ *
67
+ * Throws when `color` or `surfaces` can't be read.
68
+ */
69
+ export declare function deriveDualColor(color: string, options?: {
70
+ from?: ColorScheme;
71
+ surfaces?: DualColor;
72
+ }): DualColor;
73
+ /**
74
+ * Checks contrast compliance of a foreground/background dual colour pair across both modes.
75
+ * Throws when either value can't be read.
76
+ */
77
+ export declare function checkDualColorContrast(foreground: ColorValue, background: ColorValue, options?: {
78
+ large?: boolean;
79
+ }): {
80
+ light: {
81
+ ratio: number;
82
+ level: ContrastLevel;
83
+ };
84
+ dark: {
85
+ ratio: number;
86
+ level: ContrastLevel;
87
+ };
88
+ issues: string[];
89
+ };
90
+ /**
91
+ * Formats a dictionary of dual colours as CSS custom properties according to a strategy.
92
+ * Keys are variable names without `--`. Throws on an invalid name, colour or selector.
93
+ */
94
+ export declare function dualColorsToCss(colors: Record<string, ColorValue>, options?: {
95
+ selector?: string;
96
+ strategy?: 'light-dark' | 'media' | 'class';
97
+ darkSelector?: string;
98
+ }): string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Colour formatting to hex, rgb, hsl, oklab, oklch and Display P3 strings.
3
+ */
4
+ import type { Rgba, ColorFormat } from './types.cjs';
5
+ /**
6
+ * Gamut-maps to sRGB if needed, then formats as lowercase `#rrggbb` (or `#rrggbbaa` when alpha < 1).
7
+ */
8
+ export declare function formatHex(c: Rgba): string;
9
+ /** Formats an Rgba value into the specified CSS colour format. */
10
+ export declare function formatColor(c: Rgba, format: ColorFormat): string;
11
+ /** Parses the input and returns it as normalised lowercase hex, or null on failure. */
12
+ export declare function normalizeColor(input: unknown): string | null;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Colour formatting to hex, rgb, hsl, oklab, oklch and Display P3 strings.
3
+ */
4
+ import type { Rgba, ColorFormat } from './types.js';
5
+ /**
6
+ * Gamut-maps to sRGB if needed, then formats as lowercase `#rrggbb` (or `#rrggbbaa` when alpha < 1).
7
+ */
8
+ export declare function formatHex(c: Rgba): string;
9
+ /** Formats an Rgba value into the specified CSS colour format. */
10
+ export declare function formatColor(c: Rgba, format: ColorFormat): string;
11
+ /** Parses the input and returns it as normalised lowercase hex, or null on failure. */
12
+ export declare function normalizeColor(input: unknown): string | null;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Gamut checking and gamut mapping using CSS Color 4 OKLCH chroma binary search.
3
+ */
4
+ import type { Rgba } from './types.cjs';
5
+ /** Checks whether all sRGB channels are within [0, 1] within a tolerance epsilon. */
6
+ export declare function inSrgbGamut(c: Rgba, epsilon?: number): boolean;
7
+ /** Euclidean colour distance in OKLab space. */
8
+ export declare function deltaEOK(a: Rgba, b: Rgba): number;
9
+ /**
10
+ * Maps an out-of-gamut colour into the sRGB gamut using the CSS Color 4 binary search on OKLCH chroma.
11
+ */
12
+ export declare function toSrgbGamut(c: Rgba): Rgba;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Gamut checking and gamut mapping using CSS Color 4 OKLCH chroma binary search.
3
+ */
4
+ import type { Rgba } from './types.js';
5
+ /** Checks whether all sRGB channels are within [0, 1] within a tolerance epsilon. */
6
+ export declare function inSrgbGamut(c: Rgba, epsilon?: number): boolean;
7
+ /** Euclidean colour distance in OKLab space. */
8
+ export declare function deltaEOK(a: Rgba, b: Rgba): number;
9
+ /**
10
+ * Maps an out-of-gamut colour into the sRGB gamut using the CSS Color 4 binary search on OKLCH chroma.
11
+ */
12
+ export declare function toSrgbGamut(c: Rgba): Rgba;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Colour harmonies on the RGB and painter's RYB colour wheels.
3
+ */
4
+ export type ColorWheel = 'ryb' | 'rgb';
5
+ export type HarmonyKind = 'complementary' | 'split-complementary' | 'analogous' | 'triadic' | 'tetradic' | 'square' | 'monochromatic';
6
+ export declare const HARMONY_KINDS: readonly HarmonyKind[];
7
+ export interface HarmonyColor {
8
+ color: string;
9
+ /** Position on the wheel, degrees. */
10
+ angle: number;
11
+ }
12
+ /** Converts a wheel angle in degrees to an RGB hue. */
13
+ export declare function wheelToHue(angle: number, wheel: ColorWheel): number;
14
+ /** Converts an RGB hue in degrees to its angle on the selected wheel. */
15
+ export declare function hueToWheel(hue: number, wheel: ColorWheel): number;
16
+ /**
17
+ * Computes harmony colours around a base hex colour, with the base colour first.
18
+ */
19
+ export declare function colorHarmony(base: string, kind: HarmonyKind, options?: {
20
+ wheel?: ColorWheel;
21
+ spread?: number;
22
+ }): HarmonyColor[];
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Colour harmonies on the RGB and painter's RYB colour wheels.
3
+ */
4
+ export type ColorWheel = 'ryb' | 'rgb';
5
+ export type HarmonyKind = 'complementary' | 'split-complementary' | 'analogous' | 'triadic' | 'tetradic' | 'square' | 'monochromatic';
6
+ export declare const HARMONY_KINDS: readonly HarmonyKind[];
7
+ export interface HarmonyColor {
8
+ color: string;
9
+ /** Position on the wheel, degrees. */
10
+ angle: number;
11
+ }
12
+ /** Converts a wheel angle in degrees to an RGB hue. */
13
+ export declare function wheelToHue(angle: number, wheel: ColorWheel): number;
14
+ /** Converts an RGB hue in degrees to its angle on the selected wheel. */
15
+ export declare function hueToWheel(hue: number, wheel: ColorWheel): number;
16
+ /**
17
+ * Computes harmony colours around a base hex colour, with the base colour first.
18
+ */
19
+ export declare function colorHarmony(base: string, kind: HarmonyKind, options?: {
20
+ wheel?: ColorWheel;
21
+ spread?: number;
22
+ }): HarmonyColor[];
@@ -0,0 +1,115 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+ var _chunkUKCJ43YLcjs = require('../chunk-UKCJ43YL.cjs');
58
+ require('../chunk-IPJ3TEYR.cjs');
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+ exports.DEFAULT_SCHEME_SURFACES = _chunkUKCJ43YLcjs.DEFAULT_SCHEME_SURFACES; exports.HARMONY_KINDS = _chunkUKCJ43YLcjs.HARMONY_KINDS; exports.NAMED_COLORS = _chunkUKCJ43YLcjs.NAMED_COLORS; exports.PICKER_HUE_BACKGROUND = _chunkUKCJ43YLcjs.PICKER_HUE_BACKGROUND; exports.checkDualColorContrast = _chunkUKCJ43YLcjs.checkDualColorContrast; exports.checkPaletteColors = _chunkUKCJ43YLcjs.checkPaletteColors; exports.colorHarmony = _chunkUKCJ43YLcjs.colorHarmony; exports.contrastLevel = _chunkUKCJ43YLcjs.contrastLevel; exports.contrastRatio = _chunkUKCJ43YLcjs.contrastRatio; exports.createColorToolProvider = _chunkUKCJ43YLcjs.createColorToolProvider; exports.deltaEOK = _chunkUKCJ43YLcjs.deltaEOK; exports.deriveDualColor = _chunkUKCJ43YLcjs.deriveDualColor; exports.displayP3ToLinearSrgb = _chunkUKCJ43YLcjs.displayP3ToLinearSrgb; exports.dualColorsToCss = _chunkUKCJ43YLcjs.dualColorsToCss; exports.dualPickerView = _chunkUKCJ43YLcjs.dualPickerView; exports.formatColor = _chunkUKCJ43YLcjs.formatColor; exports.formatDualColor = _chunkUKCJ43YLcjs.formatDualColor; exports.formatHex = _chunkUKCJ43YLcjs.formatHex; exports.hslToRgb = _chunkUKCJ43YLcjs.hslToRgb; exports.hsvToRgb = _chunkUKCJ43YLcjs.hsvToRgb; exports.hueToWheel = _chunkUKCJ43YLcjs.hueToWheel; exports.inSrgbGamut = _chunkUKCJ43YLcjs.inSrgbGamut; exports.isColor = _chunkUKCJ43YLcjs.isColor; exports.isDualColor = _chunkUKCJ43YLcjs.isDualColor; exports.isSameInBothSchemes = _chunkUKCJ43YLcjs.isSameInBothSchemes; exports.linearSrgbToDisplayP3 = _chunkUKCJ43YLcjs.linearSrgbToDisplayP3; exports.linearToSrgb = _chunkUKCJ43YLcjs.linearToSrgb; exports.mixColors = _chunkUKCJ43YLcjs.mixColors; exports.normalizeColor = _chunkUKCJ43YLcjs.normalizeColor; exports.normalizeDualColor = _chunkUKCJ43YLcjs.normalizeDualColor; exports.oklabToOklch = _chunkUKCJ43YLcjs.oklabToOklch; exports.oklabToRgb = _chunkUKCJ43YLcjs.oklabToRgb; exports.oklchToOklab = _chunkUKCJ43YLcjs.oklchToOklab; exports.parseColor = _chunkUKCJ43YLcjs.parseColor; exports.parseDualColor = _chunkUKCJ43YLcjs.parseDualColor; exports.pickerAlphaBackground = _chunkUKCJ43YLcjs.pickerAlphaBackground; exports.pickerAreaBackground = _chunkUKCJ43YLcjs.pickerAreaBackground; exports.pickerKeyStep = _chunkUKCJ43YLcjs.pickerKeyStep; exports.pickerStateFromAlpha = _chunkUKCJ43YLcjs.pickerStateFromAlpha; exports.pickerStateFromArea = _chunkUKCJ43YLcjs.pickerStateFromArea; exports.pickerStateFromColor = _chunkUKCJ43YLcjs.pickerStateFromColor; exports.pickerStateFromHue = _chunkUKCJ43YLcjs.pickerStateFromHue; exports.pickerStateToHex = _chunkUKCJ43YLcjs.pickerStateToHex; exports.pushRecentColor = _chunkUKCJ43YLcjs.pushRecentColor; exports.readableTextColor = _chunkUKCJ43YLcjs.readableTextColor; exports.relativeLuminance = _chunkUKCJ43YLcjs.relativeLuminance; exports.resolveColor = _chunkUKCJ43YLcjs.resolveColor; exports.rgbToHsl = _chunkUKCJ43YLcjs.rgbToHsl; exports.rgbToHsv = _chunkUKCJ43YLcjs.rgbToHsv; exports.rgbToOklab = _chunkUKCJ43YLcjs.rgbToOklab; exports.setDualColorSide = _chunkUKCJ43YLcjs.setDualColorSide; exports.simulateColorVision = _chunkUKCJ43YLcjs.simulateColorVision; exports.srgbToLinear = _chunkUKCJ43YLcjs.srgbToLinear; exports.toSrgbGamut = _chunkUKCJ43YLcjs.toSrgbGamut; exports.wheelToHue = _chunkUKCJ43YLcjs.wheelToHue;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Shared DOM-free colour module: parsing, conversions, gamut mapping, contrast, vision simulation,
3
+ * harmonies, mixing, and recents.
4
+ */
5
+ export * from './types.cjs';
6
+ export * from './convert.cjs';
7
+ export * from './named.cjs';
8
+ export * from './parse.cjs';
9
+ export * from './format.cjs';
10
+ export * from './gamut.cjs';
11
+ export * from './contrast.cjs';
12
+ export * from './vision.cjs';
13
+ export * from './harmony.cjs';
14
+ export * from './mix.cjs';
15
+ export * from './recent.cjs';
16
+ export * from './dual.cjs';
17
+ export * from './tools.cjs';
18
+ export * from './picker.cjs';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Shared DOM-free colour module: parsing, conversions, gamut mapping, contrast, vision simulation,
3
+ * harmonies, mixing, and recents.
4
+ */
5
+ export * from './types.js';
6
+ export * from './convert.js';
7
+ export * from './named.js';
8
+ export * from './parse.js';
9
+ export * from './format.js';
10
+ export * from './gamut.js';
11
+ export * from './contrast.js';
12
+ export * from './vision.js';
13
+ export * from './harmony.js';
14
+ export * from './mix.js';
15
+ export * from './recent.js';
16
+ export * from './dual.js';
17
+ export * from './tools.js';
18
+ export * from './picker.js';