@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.
- package/README.md +4 -2
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/agent/index.cjs +36 -34
- package/dist/agent/index.js +7 -5
- package/dist/animation/index.cjs +5 -3
- package/dist/animation/index.js +4 -2
- package/dist/animation-editor/index.cjs +62 -60
- package/dist/animation-editor/index.js +6 -4
- package/dist/canvas/index.cjs +36 -34
- package/dist/canvas/index.js +19 -17
- package/dist/chart/index.cjs +88 -86
- package/dist/chart/index.js +7 -5
- package/dist/{chunk-WBJ6BG4R.js → chunk-2AQL4JHM.js} +6 -6
- package/dist/{chunk-HLMF3E53.cjs → chunk-2WDZI6QD.cjs} +15 -15
- package/dist/{chunk-ZNHB5RG6.js → chunk-37RLSNQ3.js} +2 -2
- package/dist/{chunk-5WOY52O6.cjs → chunk-4YQKRHMI.cjs} +8 -8
- package/dist/chunk-6ONMQ6WF.js +113 -0
- package/dist/{chunk-L434J57V.cjs → chunk-6QTON3VW.cjs} +16 -16
- package/dist/chunk-AA34BA7G.js +1913 -0
- package/dist/{chunk-QX25HWFL.js → chunk-AY65VQSU.js} +1 -1
- package/dist/{chunk-ONZJD2OD.cjs → chunk-BROJYMWU.cjs} +57 -153
- package/dist/{chunk-YM75DN54.js → chunk-DSZCDNTM.js} +1 -1
- package/dist/{chunk-PUR6BZFA.cjs → chunk-DVLMW3GB.cjs} +53 -53
- package/dist/{chunk-ALUWD3FG.js → chunk-EIUTJPEL.js} +1 -1
- package/dist/{chunk-X65C4DWV.js → chunk-EQ4SF4X4.js} +1 -1
- package/dist/{chunk-77SG47WT.js → chunk-FLOGD3QB.js} +1 -1
- package/dist/chunk-HRLT5BYO.js +133 -0
- package/dist/{chunk-AJSW5GMP.js → chunk-HVQVHUTV.js} +19 -115
- package/dist/{chunk-UR37VCIR.cjs → chunk-I4AHLP7F.cjs} +16 -35
- package/dist/chunk-IPJ3TEYR.cjs +113 -0
- package/dist/chunk-KC7HB5GF.cjs +133 -0
- package/dist/chunk-KY3FYKP3.js +52 -0
- package/dist/chunk-LEUZ4FRC.cjs +52 -0
- package/dist/{chunk-H6FX45CP.cjs → chunk-LIXLD433.cjs} +37 -37
- package/dist/{chunk-6GAYGQDC.js → chunk-O5ML2I6O.js} +3 -3
- package/dist/{chunk-KI2VBONS.js → chunk-OET45HIR.js} +2 -2
- package/dist/{chunk-XNZWATSB.cjs → chunk-QCEQIRJQ.cjs} +85 -85
- package/dist/{chunk-HRI3ZMDM.cjs → chunk-RHXW4TA5.cjs} +3 -3
- package/dist/{chunk-UUTTJK77.cjs → chunk-SUF6WRXR.cjs} +2 -2
- package/dist/{chunk-RN767PO6.js → chunk-SUVZJ2CP.js} +15 -34
- package/dist/{chunk-FLUTRPLY.cjs → chunk-TLMRGLQQ.cjs} +16 -16
- package/dist/{chunk-DAS7M4RY.js → chunk-UILRJQFD.js} +2 -2
- package/dist/chunk-UKCJ43YL.cjs +1913 -0
- package/dist/{chunk-XQ33O5BC.cjs → chunk-X35BV5YT.cjs} +44 -44
- package/dist/{chunk-6HMEHNWW.cjs → chunk-XTU6QO2W.cjs} +26 -26
- package/dist/{chunk-VM6JYWXQ.js → chunk-ZQUANEK4.js} +2 -2
- package/dist/cms/index.cjs +5 -3
- package/dist/cms/index.js +18 -16
- package/dist/color/contrast.d.cts +14 -0
- package/dist/color/contrast.d.ts +14 -0
- package/dist/color/convert.d.cts +30 -0
- package/dist/color/convert.d.ts +30 -0
- package/dist/color/dual.d.cts +98 -0
- package/dist/color/dual.d.ts +98 -0
- package/dist/color/format.d.cts +12 -0
- package/dist/color/format.d.ts +12 -0
- package/dist/color/gamut.d.cts +12 -0
- package/dist/color/gamut.d.ts +12 -0
- package/dist/color/harmony.d.cts +22 -0
- package/dist/color/harmony.d.ts +22 -0
- package/dist/color/index.cjs +115 -0
- package/dist/color/index.d.cts +18 -0
- package/dist/color/index.d.ts +18 -0
- package/dist/color/index.js +115 -0
- package/dist/color/mix.d.cts +11 -0
- package/dist/color/mix.d.ts +11 -0
- package/dist/color/named.d.cts +5 -0
- package/dist/color/named.d.ts +5 -0
- package/dist/color/parse.d.cts +11 -0
- package/dist/color/parse.d.ts +11 -0
- package/dist/color/picker.d.cts +52 -0
- package/dist/color/picker.d.ts +52 -0
- package/dist/color/recent.d.cts +8 -0
- package/dist/color/recent.d.ts +8 -0
- package/dist/color/tools.d.cts +15 -0
- package/dist/color/tools.d.ts +15 -0
- package/dist/color/types.d.cts +41 -0
- package/dist/color/types.d.ts +41 -0
- package/dist/color/vision.d.cts +36 -0
- package/dist/color/vision.d.ts +36 -0
- package/dist/diagram/editorDocument.d.cts +12 -0
- package/dist/diagram/editorDocument.d.ts +12 -0
- package/dist/diagram/index.cjs +35 -1
- package/dist/diagram/index.d.cts +1 -0
- package/dist/diagram/index.d.ts +1 -0
- package/dist/diagram/index.js +34 -0
- package/dist/export/index.cjs +6 -4
- package/dist/export/index.js +5 -3
- package/dist/extensions/index.cjs +10 -8
- package/dist/extensions/index.js +9 -7
- package/dist/gradient/controller.d.cts +109 -0
- package/dist/gradient/controller.d.ts +109 -0
- package/dist/gradient/editor.d.cts +38 -0
- package/dist/gradient/editor.d.ts +38 -0
- package/dist/gradient/index.cjs +1549 -0
- package/dist/gradient/index.d.cts +5 -0
- package/dist/gradient/index.d.ts +5 -0
- package/dist/gradient/index.js +1549 -0
- package/dist/gradient/model.d.cts +94 -0
- package/dist/gradient/model.d.ts +94 -0
- package/dist/gradient/tools.d.cts +11 -0
- package/dist/gradient/tools.d.ts +11 -0
- package/dist/gradient/types.d.cts +44 -0
- package/dist/gradient/types.d.ts +44 -0
- package/dist/image-editor/index.cjs +649 -647
- package/dist/image-editor/index.js +6 -4
- package/dist/index.cjs +19 -17
- package/dist/index.js +16 -14
- package/dist/paint-editor/color.d.cts +3 -13
- package/dist/paint-editor/color.d.ts +3 -13
- package/dist/paint-editor/index.cjs +23 -68
- package/dist/paint-editor/index.js +15 -60
- package/dist/persistence/documentStore.d.cts +51 -0
- package/dist/persistence/documentStore.d.ts +51 -0
- package/dist/persistence/documentTools.d.cts +35 -0
- package/dist/persistence/documentTools.d.ts +35 -0
- package/dist/persistence/editorAutosave.d.cts +33 -0
- package/dist/persistence/editorAutosave.d.ts +33 -0
- package/dist/persistence/editorDocument.d.cts +118 -0
- package/dist/persistence/editorDocument.d.ts +118 -0
- package/dist/persistence/index.cjs +294 -1
- package/dist/persistence/index.d.cts +4 -0
- package/dist/persistence/index.d.ts +4 -0
- package/dist/persistence/index.js +293 -0
- package/dist/vector/index.cjs +950 -948
- package/dist/vector/index.js +5 -3
- package/dist/video-editor/index.cjs +5 -3
- package/dist/video-editor/index.js +4 -2
- package/package.json +21 -1
- package/skills/README.md +1 -0
- package/skills/pixerate-agent-tools/SKILL.md +21 -0
- package/skills/pixerate-color/SKILL.md +69 -0
- package/skills/pixerate-diagram/SKILL.md +13 -0
- package/dist/chunk-45VRG4RB.js +0 -65
- package/dist/chunk-5FXOR7F2.cjs +0 -65
|
@@ -2,102 +2,21 @@ import {
|
|
|
2
2
|
deflate,
|
|
3
3
|
inflate
|
|
4
4
|
} from "./chunk-QGHEDC7B.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
for (let i = 0; i < 3; i++) for (let j = 0; j < 3; j++) o[i][j] = a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j];
|
|
21
|
-
return o;
|
|
22
|
-
}
|
|
23
|
-
function apply(m, v) {
|
|
24
|
-
return [m[0][0] * v[0] + m[0][1] * v[1] + m[0][2] * v[2], m[1][0] * v[0] + m[1][1] * v[1] + m[1][2] * v[2], m[2][0] * v[0] + m[2][1] * v[1] + m[2][2] * v[2]];
|
|
25
|
-
}
|
|
26
|
-
function det(m) {
|
|
27
|
-
return m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0]) + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
|
|
28
|
-
}
|
|
29
|
-
function invert(m) {
|
|
30
|
-
const d = det(m);
|
|
31
|
-
if (!Number.isFinite(d) || Math.abs(d) < 1e-12) return null;
|
|
32
|
-
const k = 1 / d;
|
|
33
|
-
return [
|
|
34
|
-
[(m[1][1] * m[2][2] - m[1][2] * m[2][1]) * k, (m[0][2] * m[2][1] - m[0][1] * m[2][2]) * k, (m[0][1] * m[1][2] - m[0][2] * m[1][1]) * k],
|
|
35
|
-
[(m[1][2] * m[2][0] - m[1][0] * m[2][2]) * k, (m[0][0] * m[2][2] - m[0][2] * m[2][0]) * k, (m[0][2] * m[1][0] - m[0][0] * m[1][2]) * k],
|
|
36
|
-
[(m[1][0] * m[2][1] - m[1][1] * m[2][0]) * k, (m[0][1] * m[2][0] - m[0][0] * m[2][1]) * k, (m[0][0] * m[1][1] - m[0][1] * m[1][0]) * k]
|
|
37
|
-
];
|
|
38
|
-
}
|
|
39
|
-
function xyToXyz(xy) {
|
|
40
|
-
const [x, y] = xy;
|
|
41
|
-
return [x / y, 1, (1 - x - y) / y];
|
|
42
|
-
}
|
|
43
|
-
var BRADFORD = [
|
|
44
|
-
[0.8951, 0.2664, -0.1614],
|
|
45
|
-
[-0.7502, 1.7135, 0.0367],
|
|
46
|
-
[0.0389, -0.0685, 1.0296]
|
|
47
|
-
];
|
|
48
|
-
function bradford(src, dst) {
|
|
49
|
-
const inv = invert(BRADFORD);
|
|
50
|
-
const s = apply(BRADFORD, src);
|
|
51
|
-
const d = apply(BRADFORD, dst);
|
|
52
|
-
const scale = [
|
|
53
|
-
[d[0] / s[0], 0, 0],
|
|
54
|
-
[0, d[1] / s[1], 0],
|
|
55
|
-
[0, 0, d[2] / s[2]]
|
|
56
|
-
];
|
|
57
|
-
return mul(inv, mul(scale, BRADFORD));
|
|
58
|
-
}
|
|
59
|
-
function rgbToXyzMatrix(r, g, b, white) {
|
|
60
|
-
const xr = xyToXyz(r);
|
|
61
|
-
const xg = xyToXyz(g);
|
|
62
|
-
const xb = xyToXyz(b);
|
|
63
|
-
const m = [
|
|
64
|
-
[xr[0], xg[0], xb[0]],
|
|
65
|
-
[xr[1], xg[1], xb[1]],
|
|
66
|
-
[xr[2], xg[2], xb[2]]
|
|
67
|
-
];
|
|
68
|
-
const inv = invert(m);
|
|
69
|
-
if (!inv) return null;
|
|
70
|
-
const s = apply(inv, white);
|
|
71
|
-
return [
|
|
72
|
-
[m[0][0] * s[0], m[0][1] * s[1], m[0][2] * s[2]],
|
|
73
|
-
[m[1][0] * s[0], m[1][1] * s[1], m[1][2] * s[2]],
|
|
74
|
-
[m[2][0] * s[0], m[2][1] * s[1], m[2][2] * s[2]]
|
|
75
|
-
];
|
|
76
|
-
}
|
|
77
|
-
var EPS = 216 / 24389;
|
|
78
|
-
var KAPPA = 24389 / 27;
|
|
79
|
-
var labF = (t) => t > EPS ? Math.cbrt(t) : (KAPPA * t + 16) / 116;
|
|
80
|
-
var labFinv = (f) => {
|
|
81
|
-
const f3 = f * f * f;
|
|
82
|
-
return f3 > EPS ? f3 : (116 * f - 16) / KAPPA;
|
|
83
|
-
};
|
|
84
|
-
function xyzToLab(xyz, white = D50) {
|
|
85
|
-
const fx = labF(xyz[0] / white[0]);
|
|
86
|
-
const fy = labF(xyz[1] / white[1]);
|
|
87
|
-
const fz = labF(xyz[2] / white[2]);
|
|
88
|
-
return [116 * fy - 16, 500 * (fx - fy), 200 * (fy - fz)];
|
|
89
|
-
}
|
|
90
|
-
function labToXyz(lab, white = D50) {
|
|
91
|
-
const fy = (lab[0] + 16) / 116;
|
|
92
|
-
const fx = fy + lab[1] / 500;
|
|
93
|
-
const fz = fy - lab[2] / 200;
|
|
94
|
-
return [labFinv(fx) * white[0], labFinv(fy) * white[1], labFinv(fz) * white[2]];
|
|
95
|
-
}
|
|
96
|
-
function deltaE76(a, b) {
|
|
97
|
-
return Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
|
|
98
|
-
}
|
|
99
|
-
var s15f16Round = (v) => Math.round(v * 65536) / 65536;
|
|
100
|
-
var d50Quantized = () => [s15f16Round(D50[0]), s15f16Round(D50[1]), s15f16Round(D50[2])];
|
|
5
|
+
import {
|
|
6
|
+
D50,
|
|
7
|
+
D65_XY,
|
|
8
|
+
apply,
|
|
9
|
+
bradford,
|
|
10
|
+
d50Quantized,
|
|
11
|
+
deltaE76,
|
|
12
|
+
invert,
|
|
13
|
+
labToXyz,
|
|
14
|
+
mul,
|
|
15
|
+
rgbToXyzMatrix,
|
|
16
|
+
s15f16Round,
|
|
17
|
+
xyToXyz,
|
|
18
|
+
xyzToLab
|
|
19
|
+
} from "./chunk-6ONMQ6WF.js";
|
|
101
20
|
|
|
102
21
|
// src/cms/curve.ts
|
|
103
22
|
var IDENTITY_CURVE = { type: "identity" };
|
|
@@ -466,8 +385,8 @@ function matrix3(m) {
|
|
|
466
385
|
function stageOutputs(s, n) {
|
|
467
386
|
return s.kind === "matrix" ? s.rows : s.kind === "clut" ? s.clut.outputs : n;
|
|
468
387
|
}
|
|
469
|
-
var
|
|
470
|
-
var
|
|
388
|
+
var EPS = 216 / 24389;
|
|
389
|
+
var KAPPA = 24389 / 27;
|
|
471
390
|
function runStage(s, v, n, tmp, tmpIn, tmpOut) {
|
|
472
391
|
switch (s.kind) {
|
|
473
392
|
case "curves":
|
|
@@ -498,7 +417,7 @@ function runStage(s, v, n, tmp, tmpIn, tmpOut) {
|
|
|
498
417
|
const fz = fy - v[2] / 200;
|
|
499
418
|
const finv = (f) => {
|
|
500
419
|
const f3 = f * f * f;
|
|
501
|
-
return f3 >
|
|
420
|
+
return f3 > EPS ? f3 : (116 * f - 16) / KAPPA;
|
|
502
421
|
};
|
|
503
422
|
v[0] = finv(fx) * D50[0];
|
|
504
423
|
v[1] = finv(fy) * D50[1];
|
|
@@ -506,7 +425,7 @@ function runStage(s, v, n, tmp, tmpIn, tmpOut) {
|
|
|
506
425
|
return 3;
|
|
507
426
|
}
|
|
508
427
|
case "xyz-to-lab": {
|
|
509
|
-
const f = (t) => t >
|
|
428
|
+
const f = (t) => t > EPS ? Math.cbrt(t) : (KAPPA * t + 16) / 116;
|
|
510
429
|
const fx = f(Math.max(0, v[0]) / D50[0]);
|
|
511
430
|
const fy = f(Math.max(0, v[1]) / D50[1]);
|
|
512
431
|
const fz = f(Math.max(0, v[2]) / D50[2]);
|
|
@@ -2500,21 +2419,6 @@ function writeJpegIcc(jpeg, icc) {
|
|
|
2500
2419
|
}
|
|
2501
2420
|
|
|
2502
2421
|
export {
|
|
2503
|
-
D50,
|
|
2504
|
-
D65_XY,
|
|
2505
|
-
IDENTITY,
|
|
2506
|
-
mul,
|
|
2507
|
-
apply,
|
|
2508
|
-
det,
|
|
2509
|
-
invert,
|
|
2510
|
-
xyToXyz,
|
|
2511
|
-
bradford,
|
|
2512
|
-
rgbToXyzMatrix,
|
|
2513
|
-
xyzToLab,
|
|
2514
|
-
labToXyz,
|
|
2515
|
-
deltaE76,
|
|
2516
|
-
s15f16Round,
|
|
2517
|
-
d50Quantized,
|
|
2518
2422
|
IDENTITY_CURVE,
|
|
2519
2423
|
srgbTrc,
|
|
2520
2424
|
gammaCurve,
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkUKCJ43YLcjs = require('./chunk-UKCJ43YL.cjs');
|
|
6
|
+
|
|
7
|
+
// src/chart/color.ts
|
|
2
8
|
var NAMED = {
|
|
3
9
|
black: "#000000",
|
|
4
10
|
white: "#ffffff",
|
|
@@ -53,7 +59,6 @@ function cyclePaletteColor(palette, index) {
|
|
|
53
59
|
return shadeChartColor(base, CHART_PALETTE_SHADES[round]);
|
|
54
60
|
}
|
|
55
61
|
var toLinear = (c) => c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
56
|
-
var fromLinear = (c) => c <= 31308e-7 ? c * 12.92 : 1.055 * Math.pow(c, 1 / 2.4) - 0.055;
|
|
57
62
|
function chartLuminance(rgb) {
|
|
58
63
|
const [r, g, b] = rgb.map(toLinear);
|
|
59
64
|
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
@@ -74,43 +79,19 @@ function chartTextOn(fill, fallback, dark = "#0f172a", light = "#ffffff") {
|
|
|
74
79
|
return darkRatio >= lightRatio ? dark : light;
|
|
75
80
|
}
|
|
76
81
|
function chartRgbToOklab(rgb) {
|
|
77
|
-
const [
|
|
78
|
-
|
|
79
|
-
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
80
|
-
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
81
|
-
return [
|
|
82
|
-
0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
|
|
83
|
-
1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
|
|
84
|
-
0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s
|
|
85
|
-
];
|
|
82
|
+
const lab = _chunkUKCJ43YLcjs.rgbToOklab.call(void 0, { r: rgb[0], g: rgb[1], b: rgb[2], a: 1 });
|
|
83
|
+
return [lab.l, lab.a, lab.b];
|
|
86
84
|
}
|
|
87
85
|
function chartColorDistance(a, b) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
protanopia: [
|
|
94
|
-
[0.152286, 1.052583, -0.204868],
|
|
95
|
-
[0.114503, 0.786281, 0.099216],
|
|
96
|
-
[-3882e-6, -0.048116, 1.051998]
|
|
97
|
-
],
|
|
98
|
-
deuteranopia: [
|
|
99
|
-
[0.367322, 0.860646, -0.227968],
|
|
100
|
-
[0.280085, 0.672501, 0.047413],
|
|
101
|
-
[-0.01182, 0.04294, 0.968881]
|
|
102
|
-
],
|
|
103
|
-
tritanopia: [
|
|
104
|
-
[1.255528, -0.076749, -0.178779],
|
|
105
|
-
[-0.078411, 0.930809, 0.147602],
|
|
106
|
-
[4733e-6, 0.691367, 0.3039]
|
|
107
|
-
]
|
|
108
|
-
};
|
|
86
|
+
return _chunkUKCJ43YLcjs.deltaEOK.call(void 0,
|
|
87
|
+
{ r: a[0], g: a[1], b: a[2], a: 1 },
|
|
88
|
+
{ r: b[0], g: b[1], b: b[2], a: 1 }
|
|
89
|
+
);
|
|
90
|
+
}
|
|
109
91
|
function simulateChartVision(rgb, vision) {
|
|
110
92
|
if (vision === "normal") return rgb;
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
return m.map((row) => fromLinear(Math.max(0, Math.min(1, row[0] * lin[0] + row[1] * lin[1] + row[2] * lin[2]))));
|
|
93
|
+
const c = _chunkUKCJ43YLcjs.simulateColorVision.call(void 0, { r: rgb[0], g: rgb[1], b: rgb[2], a: 1 }, vision);
|
|
94
|
+
return [c.r, c.g, c.b];
|
|
114
95
|
}
|
|
115
96
|
function checkChartColors(colors, options = {}) {
|
|
116
97
|
const surface = _nullishCoalesce(options.surface, () => ( "#ffffff"));
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/cms/math.ts
|
|
2
|
+
var D50 = [0.9642, 1, 0.8249];
|
|
3
|
+
var D65_XY = [0.3127, 0.329];
|
|
4
|
+
var IDENTITY = [
|
|
5
|
+
[1, 0, 0],
|
|
6
|
+
[0, 1, 0],
|
|
7
|
+
[0, 0, 1]
|
|
8
|
+
];
|
|
9
|
+
function mul(a, b) {
|
|
10
|
+
const o = [
|
|
11
|
+
[0, 0, 0],
|
|
12
|
+
[0, 0, 0],
|
|
13
|
+
[0, 0, 0]
|
|
14
|
+
];
|
|
15
|
+
for (let i = 0; i < 3; i++) for (let j = 0; j < 3; j++) o[i][j] = a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j];
|
|
16
|
+
return o;
|
|
17
|
+
}
|
|
18
|
+
function apply(m, v) {
|
|
19
|
+
return [m[0][0] * v[0] + m[0][1] * v[1] + m[0][2] * v[2], m[1][0] * v[0] + m[1][1] * v[1] + m[1][2] * v[2], m[2][0] * v[0] + m[2][1] * v[1] + m[2][2] * v[2]];
|
|
20
|
+
}
|
|
21
|
+
function det(m) {
|
|
22
|
+
return m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0]) + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
|
|
23
|
+
}
|
|
24
|
+
function invert(m) {
|
|
25
|
+
const d = det(m);
|
|
26
|
+
if (!Number.isFinite(d) || Math.abs(d) < 1e-12) return null;
|
|
27
|
+
const k = 1 / d;
|
|
28
|
+
return [
|
|
29
|
+
[(m[1][1] * m[2][2] - m[1][2] * m[2][1]) * k, (m[0][2] * m[2][1] - m[0][1] * m[2][2]) * k, (m[0][1] * m[1][2] - m[0][2] * m[1][1]) * k],
|
|
30
|
+
[(m[1][2] * m[2][0] - m[1][0] * m[2][2]) * k, (m[0][0] * m[2][2] - m[0][2] * m[2][0]) * k, (m[0][2] * m[1][0] - m[0][0] * m[1][2]) * k],
|
|
31
|
+
[(m[1][0] * m[2][1] - m[1][1] * m[2][0]) * k, (m[0][1] * m[2][0] - m[0][0] * m[2][1]) * k, (m[0][0] * m[1][1] - m[0][1] * m[1][0]) * k]
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
function xyToXyz(xy) {
|
|
35
|
+
const [x, y] = xy;
|
|
36
|
+
return [x / y, 1, (1 - x - y) / y];
|
|
37
|
+
}
|
|
38
|
+
var BRADFORD = [
|
|
39
|
+
[0.8951, 0.2664, -0.1614],
|
|
40
|
+
[-0.7502, 1.7135, 0.0367],
|
|
41
|
+
[0.0389, -0.0685, 1.0296]
|
|
42
|
+
];
|
|
43
|
+
function bradford(src, dst) {
|
|
44
|
+
const inv = invert(BRADFORD);
|
|
45
|
+
const s = apply(BRADFORD, src);
|
|
46
|
+
const d = apply(BRADFORD, dst);
|
|
47
|
+
const scale = [
|
|
48
|
+
[d[0] / s[0], 0, 0],
|
|
49
|
+
[0, d[1] / s[1], 0],
|
|
50
|
+
[0, 0, d[2] / s[2]]
|
|
51
|
+
];
|
|
52
|
+
return mul(inv, mul(scale, BRADFORD));
|
|
53
|
+
}
|
|
54
|
+
function rgbToXyzMatrix(r, g, b, white) {
|
|
55
|
+
const xr = xyToXyz(r);
|
|
56
|
+
const xg = xyToXyz(g);
|
|
57
|
+
const xb = xyToXyz(b);
|
|
58
|
+
const m = [
|
|
59
|
+
[xr[0], xg[0], xb[0]],
|
|
60
|
+
[xr[1], xg[1], xb[1]],
|
|
61
|
+
[xr[2], xg[2], xb[2]]
|
|
62
|
+
];
|
|
63
|
+
const inv = invert(m);
|
|
64
|
+
if (!inv) return null;
|
|
65
|
+
const s = apply(inv, white);
|
|
66
|
+
return [
|
|
67
|
+
[m[0][0] * s[0], m[0][1] * s[1], m[0][2] * s[2]],
|
|
68
|
+
[m[1][0] * s[0], m[1][1] * s[1], m[1][2] * s[2]],
|
|
69
|
+
[m[2][0] * s[0], m[2][1] * s[1], m[2][2] * s[2]]
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
var EPS = 216 / 24389;
|
|
73
|
+
var KAPPA = 24389 / 27;
|
|
74
|
+
var labF = (t) => t > EPS ? Math.cbrt(t) : (KAPPA * t + 16) / 116;
|
|
75
|
+
var labFinv = (f) => {
|
|
76
|
+
const f3 = f * f * f;
|
|
77
|
+
return f3 > EPS ? f3 : (116 * f - 16) / KAPPA;
|
|
78
|
+
};
|
|
79
|
+
function xyzToLab(xyz, white = D50) {
|
|
80
|
+
const fx = labF(xyz[0] / white[0]);
|
|
81
|
+
const fy = labF(xyz[1] / white[1]);
|
|
82
|
+
const fz = labF(xyz[2] / white[2]);
|
|
83
|
+
return [116 * fy - 16, 500 * (fx - fy), 200 * (fy - fz)];
|
|
84
|
+
}
|
|
85
|
+
function labToXyz(lab, white = D50) {
|
|
86
|
+
const fy = (lab[0] + 16) / 116;
|
|
87
|
+
const fx = fy + lab[1] / 500;
|
|
88
|
+
const fz = fy - lab[2] / 200;
|
|
89
|
+
return [labFinv(fx) * white[0], labFinv(fy) * white[1], labFinv(fz) * white[2]];
|
|
90
|
+
}
|
|
91
|
+
function deltaE76(a, b) {
|
|
92
|
+
return Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
|
|
93
|
+
}
|
|
94
|
+
var s15f16Round = (v) => Math.round(v * 65536) / 65536;
|
|
95
|
+
var d50Quantized = () => [s15f16Round(D50[0]), s15f16Round(D50[1]), s15f16Round(D50[2])];
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
exports.D50 = D50; exports.D65_XY = D65_XY; exports.IDENTITY = IDENTITY; exports.mul = mul; exports.apply = apply; exports.det = det; exports.invert = invert; exports.xyToXyz = xyToXyz; exports.bradford = bradford; exports.rgbToXyzMatrix = rgbToXyzMatrix; exports.xyzToLab = xyzToLab; exports.labToXyz = labToXyz; exports.deltaE76 = deltaE76; exports.s15f16Round = s15f16Round; exports.d50Quantized = d50Quantized;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkL5OWG2NAcjs = require('./chunk-L5OWG2NA.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunk2BSBFBOAcjs = require('./chunk-2BSBFBOA.cjs');
|
|
8
|
+
|
|
9
|
+
// src/persistence/editorDocument.ts
|
|
10
|
+
var EditorDocumentLoadError = class extends Error {
|
|
11
|
+
/** The `LoadReport` when the input was a file that could not be migrated. */
|
|
12
|
+
|
|
13
|
+
constructor(message, report) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = "EditorDocumentLoadError";
|
|
16
|
+
this.report = report;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var EDITOR_DOCUMENT_FORMAT = "pixerate.editor-document";
|
|
20
|
+
var KIND = /^[a-z][a-z0-9_]*$/;
|
|
21
|
+
function isEditorDocumentFile(value) {
|
|
22
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
23
|
+
const v = value;
|
|
24
|
+
return v.format === EDITOR_DOCUMENT_FORMAT && typeof v.kind === "string" && typeof v.formatVersion === "number" && "document" in v;
|
|
25
|
+
}
|
|
26
|
+
function toEditorDocumentFile(doc, name) {
|
|
27
|
+
return {
|
|
28
|
+
format: EDITOR_DOCUMENT_FORMAT,
|
|
29
|
+
kind: doc.kind,
|
|
30
|
+
formatVersion: doc.formatVersion,
|
|
31
|
+
...name ? { name } : {},
|
|
32
|
+
document: doc.getDocument()
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function serializeEditorDocument(doc, options = {}) {
|
|
36
|
+
return JSON.stringify(toEditorDocumentFile(doc, options.name), null, options.space);
|
|
37
|
+
}
|
|
38
|
+
function parseEditorDocument(text, options = {}) {
|
|
39
|
+
let value;
|
|
40
|
+
try {
|
|
41
|
+
value = _chunk2BSBFBOAcjs.stripPrototypeKeys.call(void 0, JSON.parse(text));
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw new EditorDocumentLoadError(`The file is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
44
|
+
}
|
|
45
|
+
if (!isEditorDocumentFile(value)) {
|
|
46
|
+
throw new EditorDocumentLoadError(`The file is not a saved editor document (expected "format": "${EDITOR_DOCUMENT_FORMAT}").`);
|
|
47
|
+
}
|
|
48
|
+
if (options.kind && value.kind !== options.kind) {
|
|
49
|
+
throw new EditorDocumentLoadError(`The file is a ${value.kind} document, not a ${options.kind} document.`);
|
|
50
|
+
}
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
function defineEditorDocument(spec) {
|
|
54
|
+
if (!KIND.test(spec.kind)) throw new Error(`Editor document kind "${spec.kind}" must match ${KIND}.`);
|
|
55
|
+
const formatVersion = _nullishCoalesce(spec.formatVersion, () => ( 1));
|
|
56
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
57
|
+
let revision = 0;
|
|
58
|
+
let unsubscribe = null;
|
|
59
|
+
let connected = false;
|
|
60
|
+
const connect = () => {
|
|
61
|
+
if (unsubscribe) return;
|
|
62
|
+
if (connected) revision++;
|
|
63
|
+
connected = true;
|
|
64
|
+
unsubscribe = spec.subscribe(() => {
|
|
65
|
+
revision++;
|
|
66
|
+
listeners.forEach((listener) => {
|
|
67
|
+
try {
|
|
68
|
+
listener();
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error(`[${spec.kind} document] Error in change listener:`, error);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
connect();
|
|
76
|
+
const unwrap = (input) => {
|
|
77
|
+
if (!isEditorDocumentFile(input)) return { document: input, report: _chunkL5OWG2NAcjs.createLoadReport.call(void 0, { version: formatVersion }) };
|
|
78
|
+
if (input.kind !== spec.kind) throw new EditorDocumentLoadError(`This is a ${input.kind} document; it cannot be opened in the ${spec.kind} editor.`);
|
|
79
|
+
const steps = Object.fromEntries(
|
|
80
|
+
Object.entries(_nullishCoalesce(spec.migrations, () => ( {}))).map(([v, step]) => [v, (w) => ({ ...w, document: step(w.document) })])
|
|
81
|
+
);
|
|
82
|
+
const { doc, report } = _chunkL5OWG2NAcjs.migrateDocument.call(void 0,
|
|
83
|
+
{ formatVersion: input.formatVersion, document: input.document },
|
|
84
|
+
{ currentVersion: formatVersion, versionKey: "formatVersion", steps }
|
|
85
|
+
);
|
|
86
|
+
if (report.readOnly) throw new EditorDocumentLoadError(`Cannot open the ${spec.kind} document: ${report.readOnly.message}.`, report);
|
|
87
|
+
return { document: doc.document, report };
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
kind: spec.kind,
|
|
91
|
+
formatVersion,
|
|
92
|
+
recordsLoads: spec.recordsLoads !== false,
|
|
93
|
+
getDocument: () => spec.get(),
|
|
94
|
+
loadDocument(input, options = {}) {
|
|
95
|
+
const { document, report } = unwrap(input);
|
|
96
|
+
if (document === void 0 || document === null) throw new EditorDocumentLoadError(`No ${spec.kind} document was given.`);
|
|
97
|
+
try {
|
|
98
|
+
spec.load(document, { history: _nullishCoalesce(options.history, () => ( "reset")) });
|
|
99
|
+
} catch (error) {
|
|
100
|
+
if (error instanceof EditorDocumentLoadError) throw error;
|
|
101
|
+
throw new EditorDocumentLoadError(error instanceof Error ? error.message : String(error));
|
|
102
|
+
}
|
|
103
|
+
return report;
|
|
104
|
+
},
|
|
105
|
+
revision: () => {
|
|
106
|
+
connect();
|
|
107
|
+
return revision;
|
|
108
|
+
},
|
|
109
|
+
subscribe(listener) {
|
|
110
|
+
connect();
|
|
111
|
+
listeners.add(listener);
|
|
112
|
+
return () => {
|
|
113
|
+
listeners.delete(listener);
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
history: spec.history,
|
|
117
|
+
readOnly: () => _nullishCoalesce(_optionalChain([spec, 'access', _ => _.readOnly, 'optionalCall', _2 => _2()]), () => ( false)),
|
|
118
|
+
destroy() {
|
|
119
|
+
_optionalChain([unsubscribe, 'optionalCall', _3 => _3()]);
|
|
120
|
+
unsubscribe = null;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
exports.EditorDocumentLoadError = EditorDocumentLoadError; exports.EDITOR_DOCUMENT_FORMAT = EDITOR_DOCUMENT_FORMAT; exports.isEditorDocumentFile = isEditorDocumentFile; exports.toEditorDocumentFile = toEditorDocumentFile; exports.serializeEditorDocument = serializeEditorDocument; exports.parseEditorDocument = parseEditorDocument; exports.defineEditorDocument = defineEditorDocument;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hexToRgba,
|
|
3
|
+
normalizeTokenColor,
|
|
4
|
+
rgbaToHex
|
|
5
|
+
} from "./chunk-2WPNAGHI.js";
|
|
6
|
+
import {
|
|
7
|
+
oklabToRgb,
|
|
8
|
+
rgbToOklab
|
|
9
|
+
} from "./chunk-AA34BA7G.js";
|
|
10
|
+
|
|
11
|
+
// src/animation/color.ts
|
|
12
|
+
function rgbToOklab2(r, g, b, alpha = 1) {
|
|
13
|
+
const lab = rgbToOklab({ r, g, b, a: alpha });
|
|
14
|
+
return { l: lab.l, a: lab.a, b: lab.b, alpha: lab.alpha };
|
|
15
|
+
}
|
|
16
|
+
function oklabToRgb2(color) {
|
|
17
|
+
const c = oklabToRgb({ l: color.l, a: color.a, b: color.b, alpha: color.alpha });
|
|
18
|
+
const clamp01 = (v) => Math.min(1, Math.max(0, v));
|
|
19
|
+
return {
|
|
20
|
+
r: clamp01(c.r),
|
|
21
|
+
g: clamp01(c.g),
|
|
22
|
+
b: clamp01(c.b),
|
|
23
|
+
a: clamp01(c.a)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function parseOklab(input) {
|
|
27
|
+
const hex = normalizeTokenColor(input);
|
|
28
|
+
if (hex === null) return null;
|
|
29
|
+
const c = hexToRgba(hex);
|
|
30
|
+
return rgbToOklab2(c.r, c.g, c.b, c.a);
|
|
31
|
+
}
|
|
32
|
+
function formatOklab(color) {
|
|
33
|
+
const { r, g, b, a } = oklabToRgb2(color);
|
|
34
|
+
return rgbaToHex(r, g, b, a);
|
|
35
|
+
}
|
|
36
|
+
function mixColorsOklab(from, to, t) {
|
|
37
|
+
const a = parseOklab(from);
|
|
38
|
+
const b = parseOklab(to);
|
|
39
|
+
if (!a || !b) return null;
|
|
40
|
+
const alpha = a.alpha + (b.alpha - a.alpha) * t;
|
|
41
|
+
const premul = (k) => a[k] * a.alpha + (b[k] * b.alpha - a[k] * a.alpha) * t;
|
|
42
|
+
if (alpha <= 1e-9) return formatOklab({ l: a.l + (b.l - a.l) * t, a: 0, b: 0, alpha: 0 });
|
|
43
|
+
return formatOklab({ l: premul("l") / alpha, a: premul("a") / alpha, b: premul("b") / alpha, alpha });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
rgbToOklab2 as rgbToOklab,
|
|
48
|
+
oklabToRgb2 as oklabToRgb,
|
|
49
|
+
parseOklab,
|
|
50
|
+
formatOklab,
|
|
51
|
+
mixColorsOklab
|
|
52
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkA6QWKBJPcjs = require('./chunk-A6QWKBJP.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkUKCJ43YLcjs = require('./chunk-UKCJ43YL.cjs');
|
|
10
|
+
|
|
11
|
+
// src/animation/color.ts
|
|
12
|
+
function rgbToOklab2(r, g, b, alpha = 1) {
|
|
13
|
+
const lab = _chunkUKCJ43YLcjs.rgbToOklab.call(void 0, { r, g, b, a: alpha });
|
|
14
|
+
return { l: lab.l, a: lab.a, b: lab.b, alpha: lab.alpha };
|
|
15
|
+
}
|
|
16
|
+
function oklabToRgb2(color) {
|
|
17
|
+
const c = _chunkUKCJ43YLcjs.oklabToRgb.call(void 0, { l: color.l, a: color.a, b: color.b, alpha: color.alpha });
|
|
18
|
+
const clamp01 = (v) => Math.min(1, Math.max(0, v));
|
|
19
|
+
return {
|
|
20
|
+
r: clamp01(c.r),
|
|
21
|
+
g: clamp01(c.g),
|
|
22
|
+
b: clamp01(c.b),
|
|
23
|
+
a: clamp01(c.a)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function parseOklab(input) {
|
|
27
|
+
const hex = _chunkA6QWKBJPcjs.normalizeTokenColor.call(void 0, input);
|
|
28
|
+
if (hex === null) return null;
|
|
29
|
+
const c = _chunkA6QWKBJPcjs.hexToRgba.call(void 0, hex);
|
|
30
|
+
return rgbToOklab2(c.r, c.g, c.b, c.a);
|
|
31
|
+
}
|
|
32
|
+
function formatOklab(color) {
|
|
33
|
+
const { r, g, b, a } = oklabToRgb2(color);
|
|
34
|
+
return _chunkA6QWKBJPcjs.rgbaToHex.call(void 0, r, g, b, a);
|
|
35
|
+
}
|
|
36
|
+
function mixColorsOklab(from, to, t) {
|
|
37
|
+
const a = parseOklab(from);
|
|
38
|
+
const b = parseOklab(to);
|
|
39
|
+
if (!a || !b) return null;
|
|
40
|
+
const alpha = a.alpha + (b.alpha - a.alpha) * t;
|
|
41
|
+
const premul = (k) => a[k] * a.alpha + (b[k] * b.alpha - a[k] * a.alpha) * t;
|
|
42
|
+
if (alpha <= 1e-9) return formatOklab({ l: a.l + (b.l - a.l) * t, a: 0, b: 0, alpha: 0 });
|
|
43
|
+
return formatOklab({ l: premul("l") / alpha, a: premul("a") / alpha, b: premul("b") / alpha, alpha });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
exports.rgbToOklab = rgbToOklab2; exports.oklabToRgb = oklabToRgb2; exports.parseOklab = parseOklab; exports.formatOklab = formatOklab; exports.mixColorsOklab = mixColorsOklab;
|