@pixerate/editor 0.237.0 → 0.239.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/index.cjs +40 -39
- package/dist/agent/index.js +9 -8
- package/dist/animation/index.cjs +7 -6
- package/dist/animation/index.js +6 -5
- package/dist/animation-editor/index.cjs +66 -65
- package/dist/animation-editor/index.js +9 -8
- package/dist/{brushstrokeRender-WDTKD54B.cjs → brushstrokeRender-MPOM7BFW.cjs} +7 -5
- package/dist/{brushstrokeRender-MAHOXL7K.js → brushstrokeRender-WB67GMUP.js} +4 -2
- package/dist/canvas/index.cjs +55 -54
- package/dist/canvas/index.js +10 -9
- package/dist/chart/index.cjs +159 -158
- package/dist/chart/index.js +9 -8
- package/dist/{chunk-L6Y7TSQ4.js → chunk-36ZTV7WO.js} +1 -1
- package/dist/{chunk-JVNGCS26.js → chunk-3E36VDMJ.js} +1 -1
- package/dist/{chunk-WRZ6C4TU.cjs → chunk-3R5P3DVY.cjs} +6 -6
- package/dist/{chunk-RUONPPMC.cjs → chunk-44BMJJVA.cjs} +8 -8
- package/dist/{chunk-YBAPT7NL.js → chunk-6ADHGQ73.js} +4 -2
- package/dist/chunk-7AHBW2CQ.cjs +200 -0
- package/dist/{chunk-EUIDTZNQ.cjs → chunk-7PT4RJL5.cjs} +113 -111
- package/dist/{chunk-CU6ANS5L.js → chunk-7YGBSFC6.js} +2 -2
- package/dist/{chunk-ATKKG76G.cjs → chunk-AD7GA3TL.cjs} +23 -23
- package/dist/{chunk-FSLKBQU7.js → chunk-AIS56JOO.js} +3 -3
- package/dist/{chunk-5VQXSS2S.cjs → chunk-BBUE3UJL.cjs} +86 -86
- package/dist/{chunk-7272D3K2.js → chunk-BP6KSGVD.js} +6 -4
- package/dist/{chunk-F6R67I3A.js → chunk-CXXXAZ7H.js} +1 -1
- package/dist/{chunk-5DQPDXOM.cjs → chunk-D2SGV525.cjs} +76 -76
- package/dist/chunk-F67XMVDI.js +200 -0
- package/dist/{chunk-JVSX5QTS.js → chunk-FQVVO5YA.js} +3 -3
- package/dist/{chunk-UXETV2NC.cjs → chunk-GA4EU4P3.cjs} +4 -4
- package/dist/{chunk-UFEDHACQ.js → chunk-GXAK6Q5J.js} +2 -2
- package/dist/{chunk-MHLU6GRJ.js → chunk-JEGJP4OW.js} +7 -196
- package/dist/chunk-KMPM5JM5.js +936 -0
- package/dist/{chunk-GOBOCZZI.js → chunk-LEQKZGQI.js} +1 -1
- package/dist/{chunk-M5GLQQWG.cjs → chunk-LJZRHVZV.cjs} +2 -2
- package/dist/{chunk-N76AMOKE.cjs → chunk-MOW3JMNG.cjs} +42 -42
- package/dist/{chunk-WKMUBATU.js → chunk-N4DFDI73.js} +1 -1
- package/dist/{chunk-GNZI3KYK.cjs → chunk-NKTNLJUJ.cjs} +49 -9
- package/dist/{chunk-TQOL6CF7.js → chunk-PJYG6FCF.js} +49 -9
- package/dist/{chunk-V3L7U63N.cjs → chunk-PP6BXVRL.cjs} +1 -1
- package/dist/{chunk-TFF2GTGN.cjs → chunk-PPFJHTW5.cjs} +24 -22
- package/dist/{chunk-6ZZKRH7R.js → chunk-QARCM66V.js} +3 -3
- package/dist/{chunk-5UEFBM2M.cjs → chunk-RD7RX52G.cjs} +18 -207
- package/dist/{chunk-CDP2AKMA.js → chunk-RV5DKZHU.js} +1 -1
- package/dist/chunk-S6OT6CTS.cjs +936 -0
- package/dist/{chunk-HUAISCUX.cjs → chunk-T7KQEMAE.cjs} +18 -18
- package/dist/{chunk-BQE3Y6ZO.cjs → chunk-THXFU3JB.cjs} +5 -5
- package/dist/{chunk-4ZC5QJE2.cjs → chunk-UTI5IITZ.cjs} +3 -3
- package/dist/{chunk-XSVUNSDJ.js → chunk-UUBO6RB5.js} +1 -1
- package/dist/{chunk-CZWUDFR3.cjs → chunk-UZU6DIZA.cjs} +52 -52
- package/dist/{chunk-M2TPMYJE.js → chunk-V6DT2CDH.js} +1 -1
- package/dist/{chunk-WV5WTOC6.cjs → chunk-W7GRGGBH.cjs} +16 -16
- package/dist/{chunk-23E5GI2U.js → chunk-WGN7AUKB.js} +2 -2
- package/dist/{chunk-YMREOA67.js → chunk-XK4SST43.js} +2 -2
- package/dist/{chunk-SOSBOS5T.cjs → chunk-XWOLPNBW.cjs} +22 -22
- package/dist/{chunk-ILP77UD6.js → chunk-YGQVCQTG.js} +1 -1
- package/dist/{chunk-GXLZZVR5.cjs → chunk-ZXNO3ZOX.cjs} +37 -37
- package/dist/color/index.cjs +6 -4
- package/dist/color/index.js +9 -7
- package/dist/export/index.cjs +8 -7
- package/dist/export/index.js +7 -6
- package/dist/extensions/index.cjs +11 -10
- package/dist/extensions/index.js +10 -9
- package/dist/gradient/index.cjs +104 -813
- package/dist/gradient/index.d.cts +1 -0
- package/dist/gradient/index.d.ts +1 -0
- package/dist/gradient/index.js +87 -796
- package/dist/gradient/sample.d.cts +69 -0
- package/dist/gradient/sample.d.ts +69 -0
- package/dist/image-editor/index.cjs +826 -778
- package/dist/image-editor/index.js +57 -9
- package/dist/index.cjs +17 -16
- package/dist/index.js +11 -10
- package/dist/paint-editor/controller.d.cts +31 -1
- package/dist/paint-editor/controller.d.ts +31 -1
- package/dist/paint-editor/index.cjs +403 -195
- package/dist/paint-editor/index.js +231 -23
- package/dist/paint-editor/sticker-tools.d.cts +1 -1
- package/dist/paint-editor/sticker-tools.d.ts +1 -1
- package/dist/paint-editor/stickers.d.cts +10 -3
- package/dist/paint-editor/stickers.d.ts +10 -3
- package/dist/paint-editor/ui.d.cts +10 -3
- package/dist/paint-editor/ui.d.ts +10 -3
- package/dist/tokens/index.cjs +4 -3
- package/dist/tokens/index.js +3 -2
- package/dist/typography/index.cjs +8 -7
- package/dist/typography/index.js +3 -2
- package/dist/vector/index.cjs +967 -966
- package/dist/vector/index.js +9 -8
- package/dist/video-editor/index.cjs +7 -6
- package/dist/video-editor/index.js +6 -5
- package/package.json +1 -1
- package/skills/pixerate-color/SKILL.md +3 -0
- package/skills/pixerate-image-editor/SKILL.md +1 -0
- package/skills/pixerate-paint-editor/SKILL.md +6 -2
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkPPFJHTW5cjs = require('./chunk-PPFJHTW5.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
var _chunkRD7RX52Gcjs = require('./chunk-RD7RX52G.cjs');
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
|
|
@@ -22,7 +23,8 @@ var _chunkTFF2GTGNcjs = require('./chunk-TFF2GTGN.cjs');
|
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
|
|
27
|
+
var _chunk7AHBW2CQcjs = require('./chunk-7AHBW2CQ.cjs');
|
|
26
28
|
|
|
27
29
|
// src/color/vision.ts
|
|
28
30
|
var CVD = {
|
|
@@ -45,13 +47,13 @@ var CVD = {
|
|
|
45
47
|
var clamp01 = (v) => Math.max(0, Math.min(1, v));
|
|
46
48
|
function simulateColorVision(c, vision) {
|
|
47
49
|
if (vision === "normal") return c;
|
|
48
|
-
const lr =
|
|
49
|
-
const lg =
|
|
50
|
-
const lb =
|
|
50
|
+
const lr = _chunk7AHBW2CQcjs.srgbToLinear.call(void 0, c.r);
|
|
51
|
+
const lg = _chunk7AHBW2CQcjs.srgbToLinear.call(void 0, c.g);
|
|
52
|
+
const lb = _chunk7AHBW2CQcjs.srgbToLinear.call(void 0, c.b);
|
|
51
53
|
const m = CVD[vision];
|
|
52
|
-
const r =
|
|
53
|
-
const g =
|
|
54
|
-
const b =
|
|
54
|
+
const r = _chunk7AHBW2CQcjs.linearToSrgb.call(void 0, clamp01(m[0][0] * lr + m[0][1] * lg + m[0][2] * lb));
|
|
55
|
+
const g = _chunk7AHBW2CQcjs.linearToSrgb.call(void 0, clamp01(m[1][0] * lr + m[1][1] * lg + m[1][2] * lb));
|
|
56
|
+
const b = _chunk7AHBW2CQcjs.linearToSrgb.call(void 0, clamp01(m[2][0] * lr + m[2][1] * lg + m[2][2] * lb));
|
|
55
57
|
return { r, g, b, a: c.a };
|
|
56
58
|
}
|
|
57
59
|
function checkPaletteColors(colors, options = {}) {
|
|
@@ -59,8 +61,8 @@ function checkPaletteColors(colors, options = {}) {
|
|
|
59
61
|
const minDistance = _nullishCoalesce(options.minDistance, () => ( 0.08));
|
|
60
62
|
const minContrast = _nullishCoalesce(options.minContrast, () => ( 1.5));
|
|
61
63
|
const visions = _nullishCoalesce(options.visions, () => ( ["normal", "protanopia", "deuteranopia", "tritanopia"]));
|
|
62
|
-
const parsed = colors.map((c) =>
|
|
63
|
-
const surfaceParsed =
|
|
64
|
+
const parsed = colors.map((c) => _chunkRD7RX52Gcjs.parseColor.call(void 0, c));
|
|
65
|
+
const surfaceParsed = _chunkRD7RX52Gcjs.parseColor.call(void 0, surfaceStr);
|
|
64
66
|
const skipped = colors.filter((_, i) => !parsed[i]);
|
|
65
67
|
const issues = [];
|
|
66
68
|
const closest = {};
|
|
@@ -70,7 +72,7 @@ function checkPaletteColors(colors, options = {}) {
|
|
|
70
72
|
for (let a = 0; a < seen.length; a++) {
|
|
71
73
|
for (let b = a + 1; b < seen.length; b++) {
|
|
72
74
|
if (!seen[a] || !seen[b]) continue;
|
|
73
|
-
const distance =
|
|
75
|
+
const distance = _chunkPPFJHTW5cjs.deltaEOK.call(void 0, seen[a], seen[b]);
|
|
74
76
|
if (!best || distance < best.distance) {
|
|
75
77
|
best = {
|
|
76
78
|
a,
|
|
@@ -94,7 +96,7 @@ function checkPaletteColors(colors, options = {}) {
|
|
|
94
96
|
const contrast = colors.map((_, i) => {
|
|
95
97
|
const c = parsed[i];
|
|
96
98
|
if (!c || !surfaceParsed) return null;
|
|
97
|
-
const ratio =
|
|
99
|
+
const ratio = _chunkRD7RX52Gcjs.contrastRatio.call(void 0, c, surfaceParsed);
|
|
98
100
|
return Math.round(ratio * 100) / 100;
|
|
99
101
|
});
|
|
100
102
|
contrast.forEach((ratio, i) => {
|
|
@@ -155,11 +157,11 @@ function hueToWheel(hue, wheel) {
|
|
|
155
157
|
function colorHarmony(base, kind, options = {}) {
|
|
156
158
|
const wheel = _nullishCoalesce(options.wheel, () => ( "ryb"));
|
|
157
159
|
const rgb = parseHex(base, "base");
|
|
158
|
-
const hsv =
|
|
160
|
+
const hsv = _chunk7AHBW2CQcjs.rgbToHsv.call(void 0, rgb);
|
|
159
161
|
const start = hueToWheel(hsv.h, wheel);
|
|
160
162
|
const at = (angle) => {
|
|
161
163
|
const a = (angle % 360 + 360) % 360;
|
|
162
|
-
return { color: toHex(
|
|
164
|
+
return { color: toHex(_chunk7AHBW2CQcjs.hsvToRgb.call(void 0, { ...hsv, h: wheelToHue(a, wheel) })), angle: Math.round(a * 10) / 10 };
|
|
163
165
|
};
|
|
164
166
|
const spread = _nullishCoalesce(options.spread, () => ( 30));
|
|
165
167
|
const offsets = {
|
|
@@ -171,10 +173,10 @@ function colorHarmony(base, kind, options = {}) {
|
|
|
171
173
|
square: [0, 90, 180, 270]
|
|
172
174
|
};
|
|
173
175
|
if (kind === "monochromatic") {
|
|
174
|
-
const hsl =
|
|
176
|
+
const hsl = _chunk7AHBW2CQcjs.rgbToHsl.call(void 0, rgb);
|
|
175
177
|
const steps = [0, -0.3, -0.15, 0.15, 0.3];
|
|
176
178
|
return steps.map((d) => {
|
|
177
|
-
const c = d === 0 ? rgb :
|
|
179
|
+
const c = d === 0 ? rgb : _chunk7AHBW2CQcjs.hslToRgb.call(void 0, { ...hsl, l: Math.min(0.97, Math.max(0.03, hsl.l + d)) });
|
|
178
180
|
return { color: toHex(c), angle: Math.round(start * 10) / 10 };
|
|
179
181
|
});
|
|
180
182
|
}
|
|
@@ -185,17 +187,17 @@ function colorHarmony(base, kind, options = {}) {
|
|
|
185
187
|
|
|
186
188
|
// src/color/mix.ts
|
|
187
189
|
function mixColors(from, to, t, options = {}) {
|
|
188
|
-
const c1 =
|
|
189
|
-
const c2 =
|
|
190
|
+
const c1 = _chunkRD7RX52Gcjs.parseColor.call(void 0, from);
|
|
191
|
+
const c2 = _chunkRD7RX52Gcjs.parseColor.call(void 0, to);
|
|
190
192
|
if (!c1 || !c2) return null;
|
|
191
193
|
const space = _nullishCoalesce(options.space, () => ( "oklab"));
|
|
192
194
|
const alpha = c1.a + (c2.a - c1.a) * t;
|
|
193
195
|
if (space === "oklab") {
|
|
194
|
-
const lab1 =
|
|
195
|
-
const lab2 =
|
|
196
|
+
const lab1 = _chunk7AHBW2CQcjs.rgbToOklab.call(void 0, c1);
|
|
197
|
+
const lab2 = _chunk7AHBW2CQcjs.rgbToOklab.call(void 0, c2);
|
|
196
198
|
if (alpha <= 1e-9) {
|
|
197
199
|
const lab3 = { l: lab1.l + (lab2.l - lab1.l) * t, a: 0, b: 0, alpha: 0 };
|
|
198
|
-
return
|
|
200
|
+
return _chunkPPFJHTW5cjs.formatHex.call(void 0, _chunk7AHBW2CQcjs.oklabToRgb.call(void 0, lab3));
|
|
199
201
|
}
|
|
200
202
|
const premul = (k) => lab1[k] * lab1.alpha + (lab2[k] * lab2.alpha - lab1[k] * lab1.alpha) * t;
|
|
201
203
|
const lab = {
|
|
@@ -204,11 +206,11 @@ function mixColors(from, to, t, options = {}) {
|
|
|
204
206
|
b: premul("b") / alpha,
|
|
205
207
|
alpha
|
|
206
208
|
};
|
|
207
|
-
return
|
|
209
|
+
return _chunkPPFJHTW5cjs.formatHex.call(void 0, _chunk7AHBW2CQcjs.oklabToRgb.call(void 0, lab));
|
|
208
210
|
}
|
|
209
211
|
if (space === "oklch") {
|
|
210
|
-
const lch1 =
|
|
211
|
-
const lch2 =
|
|
212
|
+
const lch1 = _chunk7AHBW2CQcjs.oklabToOklch.call(void 0, _chunk7AHBW2CQcjs.rgbToOklab.call(void 0, c1));
|
|
213
|
+
const lch2 = _chunk7AHBW2CQcjs.oklabToOklch.call(void 0, _chunk7AHBW2CQcjs.rgbToOklab.call(void 0, c2));
|
|
212
214
|
let h1 = lch1.h;
|
|
213
215
|
let h2 = lch2.h;
|
|
214
216
|
const diff = h2 - h1;
|
|
@@ -217,41 +219,41 @@ function mixColors(from, to, t, options = {}) {
|
|
|
217
219
|
const h = ((h1 + (h2 - h1) * t) % 360 + 360) % 360;
|
|
218
220
|
if (alpha <= 1e-9) {
|
|
219
221
|
const l2 = lch1.l + (lch2.l - lch1.l) * t;
|
|
220
|
-
return
|
|
222
|
+
return _chunkPPFJHTW5cjs.formatHex.call(void 0, _chunk7AHBW2CQcjs.oklabToRgb.call(void 0, _chunk7AHBW2CQcjs.oklchToOklab.call(void 0, { l: l2, c: 0, h: 0, alpha: 0 })));
|
|
221
223
|
}
|
|
222
224
|
const lPremul = lch1.l * lch1.alpha + (lch2.l * lch2.alpha - lch1.l * lch1.alpha) * t;
|
|
223
225
|
const cPremul = lch1.c * lch1.alpha + (lch2.c * lch2.alpha - lch1.c * lch1.alpha) * t;
|
|
224
226
|
const l = lPremul / alpha;
|
|
225
227
|
const c = cPremul / alpha;
|
|
226
|
-
return
|
|
228
|
+
return _chunkPPFJHTW5cjs.formatHex.call(void 0, _chunk7AHBW2CQcjs.oklabToRgb.call(void 0, _chunk7AHBW2CQcjs.oklchToOklab.call(void 0, { l, c, h, alpha })));
|
|
227
229
|
}
|
|
228
230
|
if (space === "srgb-linear") {
|
|
229
|
-
const lr1 =
|
|
230
|
-
const lg1 =
|
|
231
|
-
const lb1 =
|
|
232
|
-
const lr2 =
|
|
233
|
-
const lg2 =
|
|
234
|
-
const lb2 =
|
|
231
|
+
const lr1 = _chunk7AHBW2CQcjs.srgbToLinear.call(void 0, c1.r);
|
|
232
|
+
const lg1 = _chunk7AHBW2CQcjs.srgbToLinear.call(void 0, c1.g);
|
|
233
|
+
const lb1 = _chunk7AHBW2CQcjs.srgbToLinear.call(void 0, c1.b);
|
|
234
|
+
const lr2 = _chunk7AHBW2CQcjs.srgbToLinear.call(void 0, c2.r);
|
|
235
|
+
const lg2 = _chunk7AHBW2CQcjs.srgbToLinear.call(void 0, c2.g);
|
|
236
|
+
const lb2 = _chunk7AHBW2CQcjs.srgbToLinear.call(void 0, c2.b);
|
|
235
237
|
if (alpha <= 1e-9) {
|
|
236
|
-
return
|
|
237
|
-
r:
|
|
238
|
-
g:
|
|
239
|
-
b:
|
|
238
|
+
return _chunkPPFJHTW5cjs.formatHex.call(void 0, {
|
|
239
|
+
r: _chunk7AHBW2CQcjs.linearToSrgb.call(void 0, lr1 + (lr2 - lr1) * t),
|
|
240
|
+
g: _chunk7AHBW2CQcjs.linearToSrgb.call(void 0, lg1 + (lg2 - lg1) * t),
|
|
241
|
+
b: _chunk7AHBW2CQcjs.linearToSrgb.call(void 0, lb1 + (lb2 - lb1) * t),
|
|
240
242
|
a: 0
|
|
241
243
|
});
|
|
242
244
|
}
|
|
243
245
|
const premulR2 = lr1 * c1.a + (lr2 * c2.a - lr1 * c1.a) * t;
|
|
244
246
|
const premulG2 = lg1 * c1.a + (lg2 * c2.a - lg1 * c1.a) * t;
|
|
245
247
|
const premulB2 = lb1 * c1.a + (lb2 * c2.a - lb1 * c1.a) * t;
|
|
246
|
-
return
|
|
247
|
-
r:
|
|
248
|
-
g:
|
|
249
|
-
b:
|
|
248
|
+
return _chunkPPFJHTW5cjs.formatHex.call(void 0, {
|
|
249
|
+
r: _chunk7AHBW2CQcjs.linearToSrgb.call(void 0, premulR2 / alpha),
|
|
250
|
+
g: _chunk7AHBW2CQcjs.linearToSrgb.call(void 0, premulG2 / alpha),
|
|
251
|
+
b: _chunk7AHBW2CQcjs.linearToSrgb.call(void 0, premulB2 / alpha),
|
|
250
252
|
a: alpha
|
|
251
253
|
});
|
|
252
254
|
}
|
|
253
255
|
if (alpha <= 1e-9) {
|
|
254
|
-
return
|
|
256
|
+
return _chunkPPFJHTW5cjs.formatHex.call(void 0, {
|
|
255
257
|
r: c1.r + (c2.r - c1.r) * t,
|
|
256
258
|
g: c1.g + (c2.g - c1.g) * t,
|
|
257
259
|
b: c1.b + (c2.b - c1.b) * t,
|
|
@@ -261,7 +263,7 @@ function mixColors(from, to, t, options = {}) {
|
|
|
261
263
|
const premulR = c1.r * c1.a + (c2.r * c2.a - c1.r * c1.a) * t;
|
|
262
264
|
const premulG = c1.g * c1.a + (c2.g * c2.a - c1.g * c1.a) * t;
|
|
263
265
|
const premulB = c1.b * c1.a + (c2.b * c2.a - c1.b * c1.a) * t;
|
|
264
|
-
return
|
|
266
|
+
return _chunkPPFJHTW5cjs.formatHex.call(void 0, {
|
|
265
267
|
r: premulR / alpha,
|
|
266
268
|
g: premulG / alpha,
|
|
267
269
|
b: premulB / alpha,
|
|
@@ -271,9 +273,9 @@ function mixColors(from, to, t, options = {}) {
|
|
|
271
273
|
|
|
272
274
|
// src/color/recent.ts
|
|
273
275
|
function pushRecentColor(list, color, max = 12) {
|
|
274
|
-
const normal =
|
|
276
|
+
const normal = _chunkPPFJHTW5cjs.normalizeColor.call(void 0, color);
|
|
275
277
|
if (!normal) return list.slice();
|
|
276
|
-
const next = [normal, ...list.filter((c) =>
|
|
278
|
+
const next = [normal, ...list.filter((c) => _chunkPPFJHTW5cjs.normalizeColor.call(void 0, c) !== normal)];
|
|
277
279
|
return next.slice(0, max);
|
|
278
280
|
}
|
|
279
281
|
|
|
@@ -289,7 +291,7 @@ function isDualColor(value) {
|
|
|
289
291
|
function parseDualColor(input) {
|
|
290
292
|
if (input === null || input === void 0) return null;
|
|
291
293
|
if (isDualColor(input)) {
|
|
292
|
-
if (
|
|
294
|
+
if (_chunkRD7RX52Gcjs.parseColor.call(void 0, input.light) === null || _chunkRD7RX52Gcjs.parseColor.call(void 0, input.dark) === null) {
|
|
293
295
|
return null;
|
|
294
296
|
}
|
|
295
297
|
return { light: input.light, dark: input.dark };
|
|
@@ -323,12 +325,12 @@ function parseDualColor(input) {
|
|
|
323
325
|
const lightPart = inner.slice(0, commaIndex).trim();
|
|
324
326
|
const darkPart = inner.slice(commaIndex + 1).trim();
|
|
325
327
|
if (!lightPart || !darkPart) return null;
|
|
326
|
-
if (
|
|
328
|
+
if (_chunkRD7RX52Gcjs.parseColor.call(void 0, lightPart) === null || _chunkRD7RX52Gcjs.parseColor.call(void 0, darkPart) === null) {
|
|
327
329
|
return null;
|
|
328
330
|
}
|
|
329
331
|
return { light: lightPart, dark: darkPart };
|
|
330
332
|
}
|
|
331
|
-
if (
|
|
333
|
+
if (_chunkRD7RX52Gcjs.parseColor.call(void 0, trimmed) !== null) {
|
|
332
334
|
return { light: trimmed, dark: trimmed };
|
|
333
335
|
}
|
|
334
336
|
}
|
|
@@ -337,8 +339,8 @@ function parseDualColor(input) {
|
|
|
337
339
|
function normalizeDualColor(input) {
|
|
338
340
|
const parsed = parseDualColor(input);
|
|
339
341
|
if (!parsed) return null;
|
|
340
|
-
const light =
|
|
341
|
-
const dark =
|
|
342
|
+
const light = _chunkPPFJHTW5cjs.normalizeColor.call(void 0, parsed.light);
|
|
343
|
+
const dark = _chunkPPFJHTW5cjs.normalizeColor.call(void 0, parsed.dark);
|
|
342
344
|
if (!light || !dark) return null;
|
|
343
345
|
return { light, dark };
|
|
344
346
|
}
|
|
@@ -348,22 +350,22 @@ function resolveColor(value, scheme) {
|
|
|
348
350
|
return scheme === "dark" ? normalized.dark : normalized.light;
|
|
349
351
|
}
|
|
350
352
|
function formatDualColor(value) {
|
|
351
|
-
const light = _nullishCoalesce(
|
|
352
|
-
const dark = _nullishCoalesce(
|
|
353
|
+
const light = _nullishCoalesce(_chunkPPFJHTW5cjs.normalizeColor.call(void 0, value.light), () => ( value.light));
|
|
354
|
+
const dark = _nullishCoalesce(_chunkPPFJHTW5cjs.normalizeColor.call(void 0, value.dark), () => ( value.dark));
|
|
353
355
|
if (light === dark) {
|
|
354
356
|
return light;
|
|
355
357
|
}
|
|
356
358
|
return `light-dark(${light}, ${dark})`;
|
|
357
359
|
}
|
|
358
360
|
function isSameInBothSchemes(value) {
|
|
359
|
-
const light =
|
|
360
|
-
const dark =
|
|
361
|
+
const light = _chunkPPFJHTW5cjs.normalizeColor.call(void 0, value.light);
|
|
362
|
+
const dark = _chunkPPFJHTW5cjs.normalizeColor.call(void 0, value.dark);
|
|
361
363
|
if (!light || !dark) return value.light === value.dark;
|
|
362
364
|
return light === dark;
|
|
363
365
|
}
|
|
364
366
|
function setDualColorSide(value, scheme, color) {
|
|
365
367
|
const base = _nullishCoalesce(normalizeDualColor(value), () => ( { light: "#000000", dark: "#000000" }));
|
|
366
|
-
const normColor = _nullishCoalesce(
|
|
368
|
+
const normColor = _nullishCoalesce(_chunkPPFJHTW5cjs.normalizeColor.call(void 0, color), () => ( color));
|
|
367
369
|
return {
|
|
368
370
|
light: scheme === "light" ? normColor : base.light,
|
|
369
371
|
dark: scheme === "dark" ? normColor : base.dark
|
|
@@ -371,35 +373,35 @@ function setDualColorSide(value, scheme, color) {
|
|
|
371
373
|
}
|
|
372
374
|
function deriveDualColor(color, options) {
|
|
373
375
|
const fromScheme = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _2 => _2.from]), () => ( "light"));
|
|
374
|
-
const baseRgba =
|
|
376
|
+
const baseRgba = _chunkRD7RX52Gcjs.parseColor.call(void 0, color);
|
|
375
377
|
if (!baseRgba) {
|
|
376
378
|
throw new Error(`"${String(color)}" is not a colour; pass hex, rgb(), hsl(), oklch() or a CSS colour name.`);
|
|
377
379
|
}
|
|
378
380
|
if (_optionalChain([options, 'optionalAccess', _3 => _3.surfaces]) && !normalizeDualColor(options.surfaces)) {
|
|
379
381
|
throw new Error('The surfaces need a readable light and dark colour, e.g. { light: "#ffffff", dark: "#0b0b0f" }.');
|
|
380
382
|
}
|
|
381
|
-
const baseHex =
|
|
382
|
-
const lab =
|
|
383
|
-
const lch =
|
|
383
|
+
const baseHex = _chunkPPFJHTW5cjs.formatHex.call(void 0, baseRgba);
|
|
384
|
+
const lab = _chunk7AHBW2CQcjs.rgbToOklab.call(void 0, baseRgba);
|
|
385
|
+
const lch = _chunk7AHBW2CQcjs.oklabToOklch.call(void 0, lab);
|
|
384
386
|
const startL = clamp(1.05 - lch.l, 0.12, 0.95);
|
|
385
387
|
const targetC = lch.c * 0.9;
|
|
386
388
|
const targetH = lch.h;
|
|
387
389
|
let derivedHex;
|
|
388
390
|
if (_optionalChain([options, 'optionalAccess', _4 => _4.surfaces])) {
|
|
389
391
|
const surfaces = options.surfaces;
|
|
390
|
-
const fromSurfaceRgba =
|
|
392
|
+
const fromSurfaceRgba = _chunkRD7RX52Gcjs.parseColor.call(void 0, surfaces[fromScheme]);
|
|
391
393
|
const targetScheme = fromScheme === "light" ? "dark" : "light";
|
|
392
|
-
const targetSurfaceRgba =
|
|
393
|
-
const targetRatio =
|
|
394
|
-
const targetSurfaceL =
|
|
394
|
+
const targetSurfaceRgba = _chunkRD7RX52Gcjs.parseColor.call(void 0, surfaces[targetScheme]);
|
|
395
|
+
const targetRatio = _chunkRD7RX52Gcjs.contrastRatio.call(void 0, baseRgba, fromSurfaceRgba);
|
|
396
|
+
const targetSurfaceL = _chunk7AHBW2CQcjs.oklabToOklch.call(void 0, _chunk7AHBW2CQcjs.rgbToOklab.call(void 0, targetSurfaceRgba)).l;
|
|
395
397
|
const preferHigherL = targetSurfaceL < 0.5;
|
|
396
398
|
let bestDiff = Infinity;
|
|
397
399
|
let bestL = startL;
|
|
398
400
|
for (let candL = 0.05; candL <= 0.98; candL += 5e-3) {
|
|
399
|
-
const candRgb =
|
|
400
|
-
|
|
401
|
+
const candRgb = _chunkPPFJHTW5cjs.toSrgbGamut.call(void 0,
|
|
402
|
+
_chunk7AHBW2CQcjs.oklabToRgb.call(void 0, _chunk7AHBW2CQcjs.oklchToOklab.call(void 0, { l: candL, c: targetC, h: targetH, alpha: baseRgba.a }))
|
|
401
403
|
);
|
|
402
|
-
const ratio =
|
|
404
|
+
const ratio = _chunkRD7RX52Gcjs.contrastRatio.call(void 0, candRgb, targetSurfaceRgba);
|
|
403
405
|
const diff = Math.abs(ratio - targetRatio);
|
|
404
406
|
const isBetter = diff < bestDiff - 1e-4 || Math.abs(diff - bestDiff) <= 1e-4 && (preferHigherL ? candL > bestL : candL < bestL);
|
|
405
407
|
if (isBetter) {
|
|
@@ -407,15 +409,15 @@ function deriveDualColor(color, options) {
|
|
|
407
409
|
bestL = candL;
|
|
408
410
|
}
|
|
409
411
|
}
|
|
410
|
-
const finalRgba =
|
|
411
|
-
|
|
412
|
+
const finalRgba = _chunkPPFJHTW5cjs.toSrgbGamut.call(void 0,
|
|
413
|
+
_chunk7AHBW2CQcjs.oklabToRgb.call(void 0, _chunk7AHBW2CQcjs.oklchToOklab.call(void 0, { l: bestL, c: targetC, h: targetH, alpha: baseRgba.a }))
|
|
412
414
|
);
|
|
413
|
-
derivedHex =
|
|
415
|
+
derivedHex = _chunkPPFJHTW5cjs.formatHex.call(void 0, finalRgba);
|
|
414
416
|
} else {
|
|
415
|
-
const finalRgba =
|
|
416
|
-
|
|
417
|
+
const finalRgba = _chunkPPFJHTW5cjs.toSrgbGamut.call(void 0,
|
|
418
|
+
_chunk7AHBW2CQcjs.oklabToRgb.call(void 0, _chunk7AHBW2CQcjs.oklchToOklab.call(void 0, { l: startL, c: targetC, h: targetH, alpha: baseRgba.a }))
|
|
417
419
|
);
|
|
418
|
-
derivedHex =
|
|
420
|
+
derivedHex = _chunkPPFJHTW5cjs.formatHex.call(void 0, finalRgba);
|
|
419
421
|
}
|
|
420
422
|
return fromScheme === "light" ? { light: baseHex, dark: derivedHex } : { light: derivedHex, dark: baseHex };
|
|
421
423
|
}
|
|
@@ -430,14 +432,14 @@ function checkDualColorContrast(foreground, background, options) {
|
|
|
430
432
|
const lightBgHex = bg.light;
|
|
431
433
|
const darkFgHex = fg.dark;
|
|
432
434
|
const darkBgHex = bg.dark;
|
|
433
|
-
const lightFg =
|
|
434
|
-
const lightBg =
|
|
435
|
-
const darkFg =
|
|
436
|
-
const darkBg =
|
|
437
|
-
const lightRatio = Math.round(
|
|
438
|
-
const darkRatio = Math.round(
|
|
439
|
-
const lightLevel =
|
|
440
|
-
const darkLevel =
|
|
435
|
+
const lightFg = _chunkRD7RX52Gcjs.parseColor.call(void 0, lightFgHex);
|
|
436
|
+
const lightBg = _chunkRD7RX52Gcjs.parseColor.call(void 0, lightBgHex);
|
|
437
|
+
const darkFg = _chunkRD7RX52Gcjs.parseColor.call(void 0, darkFgHex);
|
|
438
|
+
const darkBg = _chunkRD7RX52Gcjs.parseColor.call(void 0, darkBgHex);
|
|
439
|
+
const lightRatio = Math.round(_chunkRD7RX52Gcjs.contrastRatio.call(void 0, lightFg, lightBg) * 100) / 100;
|
|
440
|
+
const darkRatio = Math.round(_chunkRD7RX52Gcjs.contrastRatio.call(void 0, darkFg, darkBg) * 100) / 100;
|
|
441
|
+
const lightLevel = _chunkRD7RX52Gcjs.contrastLevel.call(void 0, lightRatio, { large });
|
|
442
|
+
const darkLevel = _chunkRD7RX52Gcjs.contrastLevel.call(void 0, darkRatio, { large });
|
|
441
443
|
const issues = [];
|
|
442
444
|
if (lightLevel === "fail") {
|
|
443
445
|
issues.push(
|
|
@@ -554,7 +556,7 @@ function requireColor(input, name) {
|
|
|
554
556
|
if (typeof input !== "string" || !input.trim()) {
|
|
555
557
|
fail(`"${String(input)}" is not a colour I can read; use hex (#2a4b8d), rgb(), hsl(), oklch() or a CSS colour name.`);
|
|
556
558
|
}
|
|
557
|
-
const parsed =
|
|
559
|
+
const parsed = _chunkRD7RX52Gcjs.parseColor.call(void 0, input);
|
|
558
560
|
if (!parsed) {
|
|
559
561
|
fail(`"${input}" is not a colour I can read; use hex (#2a4b8d), rgb(), hsl(), oklch() or a CSS colour name.`);
|
|
560
562
|
}
|
|
@@ -567,7 +569,7 @@ function requireDualColor(input, name) {
|
|
|
567
569
|
}
|
|
568
570
|
return parsed;
|
|
569
571
|
}
|
|
570
|
-
var findAccessibleLightness = (fg, bg, large) =>
|
|
572
|
+
var findAccessibleLightness = (fg, bg, large) => _chunkPPFJHTW5cjs.suggestAccessibleForeground.call(void 0, fg, bg, { large });
|
|
571
573
|
function createColorToolProvider(options = {}) {
|
|
572
574
|
const id = _nullishCoalesce(options.id, () => ( "color"));
|
|
573
575
|
const namespace = _nullishCoalesce(options.namespace, () => ( "color"));
|
|
@@ -587,18 +589,18 @@ function createColorToolProvider(options = {}) {
|
|
|
587
589
|
handler: (args) => {
|
|
588
590
|
const { color } = args;
|
|
589
591
|
const rgba = requireColor(color, "color");
|
|
590
|
-
const inGamut =
|
|
591
|
-
const mappedRgba = inGamut ? rgba :
|
|
592
|
-
const hsl =
|
|
593
|
-
const oklab =
|
|
594
|
-
const oklch =
|
|
592
|
+
const inGamut = _chunkPPFJHTW5cjs.inSrgbGamut.call(void 0, rgba);
|
|
593
|
+
const mappedRgba = inGamut ? rgba : _chunkPPFJHTW5cjs.toSrgbGamut.call(void 0, rgba);
|
|
594
|
+
const hsl = _chunk7AHBW2CQcjs.rgbToHsl.call(void 0, mappedRgba);
|
|
595
|
+
const oklab = _chunk7AHBW2CQcjs.rgbToOklab.call(void 0, rgba);
|
|
596
|
+
const oklch = _chunk7AHBW2CQcjs.oklabToOklch.call(void 0, oklab);
|
|
595
597
|
const formats = ["hex", "rgb", "hsl", "oklab", "oklch"];
|
|
596
598
|
const css = {};
|
|
597
599
|
for (const f of formats) {
|
|
598
|
-
css[f] =
|
|
600
|
+
css[f] = _chunkPPFJHTW5cjs.formatColor.call(void 0, rgba, f);
|
|
599
601
|
}
|
|
600
602
|
return {
|
|
601
|
-
hex:
|
|
603
|
+
hex: _chunkPPFJHTW5cjs.formatHex.call(void 0, mappedRgba),
|
|
602
604
|
alpha: Math.round(rgba.a * 1e3) / 1e3,
|
|
603
605
|
rgb: {
|
|
604
606
|
r: Math.round(Math.min(1, Math.max(0, mappedRgba.r)) * 255),
|
|
@@ -617,8 +619,8 @@ function createColorToolProvider(options = {}) {
|
|
|
617
619
|
},
|
|
618
620
|
css,
|
|
619
621
|
inSrgbGamut: inGamut,
|
|
620
|
-
...inGamut ? {} : { gamutMappedHex:
|
|
621
|
-
relativeLuminance: Math.round(
|
|
622
|
+
...inGamut ? {} : { gamutMappedHex: _chunkPPFJHTW5cjs.formatHex.call(void 0, mappedRgba) },
|
|
623
|
+
relativeLuminance: Math.round(_chunkRD7RX52Gcjs.relativeLuminance.call(void 0, mappedRgba) * 1e4) / 1e4
|
|
622
624
|
};
|
|
623
625
|
}
|
|
624
626
|
};
|
|
@@ -641,11 +643,11 @@ function createColorToolProvider(options = {}) {
|
|
|
641
643
|
const { foreground, background, large = false } = args;
|
|
642
644
|
const fg = requireColor(foreground, "foreground");
|
|
643
645
|
const bg = requireColor(background, "background");
|
|
644
|
-
const ratio = Math.round(
|
|
645
|
-
const level =
|
|
646
|
+
const ratio = Math.round(_chunkRD7RX52Gcjs.contrastRatio.call(void 0, fg, bg) * 100) / 100;
|
|
647
|
+
const level = _chunkRD7RX52Gcjs.contrastLevel.call(void 0, ratio, { large });
|
|
646
648
|
const passesAA = level === "AA" || level === "AAA";
|
|
647
649
|
const passesAAA = level === "AAA";
|
|
648
|
-
const suggestion = passesAA ? void 0 :
|
|
650
|
+
const suggestion = passesAA ? void 0 : _chunkPPFJHTW5cjs.suggestAccessibleForeground.call(void 0, fg, bg, { large });
|
|
649
651
|
return {
|
|
650
652
|
ratio,
|
|
651
653
|
level,
|
|
@@ -727,7 +729,7 @@ function createColorToolProvider(options = {}) {
|
|
|
727
729
|
handler: (args) => {
|
|
728
730
|
const { base, kind, wheel = "rgb", spread } = args;
|
|
729
731
|
const rgba = requireColor(base, "base");
|
|
730
|
-
const hex =
|
|
732
|
+
const hex = _chunkPPFJHTW5cjs.formatHex.call(void 0, _chunkPPFJHTW5cjs.toSrgbGamut.call(void 0, rgba));
|
|
731
733
|
if (!HARMONY_KINDS.includes(kind)) {
|
|
732
734
|
fail(`Unknown harmony kind "${kind}"; expected one of ${HARMONY_KINDS.join(", ")}.`);
|
|
733
735
|
}
|
|
@@ -832,10 +834,10 @@ function createColorToolProvider(options = {}) {
|
|
|
832
834
|
from,
|
|
833
835
|
surfaces: keepContrast ? resolvedSurfaces : void 0
|
|
834
836
|
});
|
|
835
|
-
const lightSurfaceRgba =
|
|
836
|
-
const darkSurfaceRgba =
|
|
837
|
-
const lightRatio = Math.round(
|
|
838
|
-
const darkRatio = Math.round(
|
|
837
|
+
const lightSurfaceRgba = _chunkRD7RX52Gcjs.parseColor.call(void 0, resolvedSurfaces.light);
|
|
838
|
+
const darkSurfaceRgba = _chunkRD7RX52Gcjs.parseColor.call(void 0, resolvedSurfaces.dark);
|
|
839
|
+
const lightRatio = Math.round(_chunkRD7RX52Gcjs.contrastRatio.call(void 0, _chunkRD7RX52Gcjs.parseColor.call(void 0, derived.light), lightSurfaceRgba) * 100) / 100;
|
|
840
|
+
const darkRatio = Math.round(_chunkRD7RX52Gcjs.contrastRatio.call(void 0, _chunkRD7RX52Gcjs.parseColor.call(void 0, derived.dark), darkSurfaceRgba) * 100) / 100;
|
|
839
841
|
return {
|
|
840
842
|
light: derived.light,
|
|
841
843
|
dark: derived.dark,
|
|
@@ -878,16 +880,16 @@ function createColorToolProvider(options = {}) {
|
|
|
878
880
|
const res = checkDualColorContrast(fg, bg, { large });
|
|
879
881
|
let suggestion;
|
|
880
882
|
if (res.light.level === "fail") {
|
|
881
|
-
const lightFg =
|
|
882
|
-
const lightBg =
|
|
883
|
+
const lightFg = _chunkRD7RX52Gcjs.parseColor.call(void 0, fg.light);
|
|
884
|
+
const lightBg = _chunkRD7RX52Gcjs.parseColor.call(void 0, bg.light);
|
|
883
885
|
const fixed = findAccessibleLightness(lightFg, lightBg, large);
|
|
884
886
|
if (fixed) {
|
|
885
887
|
suggestion = { ..._nullishCoalesce(suggestion, () => ( {})), light: fixed };
|
|
886
888
|
}
|
|
887
889
|
}
|
|
888
890
|
if (res.dark.level === "fail") {
|
|
889
|
-
const darkFg =
|
|
890
|
-
const darkBg =
|
|
891
|
+
const darkFg = _chunkRD7RX52Gcjs.parseColor.call(void 0, fg.dark);
|
|
892
|
+
const darkBg = _chunkRD7RX52Gcjs.parseColor.call(void 0, bg.dark);
|
|
891
893
|
const fixed = findAccessibleLightness(darkFg, darkBg, large);
|
|
892
894
|
if (fixed) {
|
|
893
895
|
suggestion = { ..._nullishCoalesce(suggestion, () => ( {})), dark: fixed };
|
|
@@ -971,13 +973,13 @@ function pickerStateFromColor(input, previous) {
|
|
|
971
973
|
if (typeof input === "object" && "r" in input && "g" in input && "b" in input) {
|
|
972
974
|
rgba = input;
|
|
973
975
|
} else if (typeof input === "string") {
|
|
974
|
-
rgba =
|
|
976
|
+
rgba = _chunkRD7RX52Gcjs.parseColor.call(void 0, input);
|
|
975
977
|
} else {
|
|
976
978
|
return null;
|
|
977
979
|
}
|
|
978
980
|
if (!rgba) return null;
|
|
979
|
-
const clampedRgba =
|
|
980
|
-
const hsva =
|
|
981
|
+
const clampedRgba = _chunkPPFJHTW5cjs.toSrgbGamut.call(void 0, rgba);
|
|
982
|
+
const hsva = _chunk7AHBW2CQcjs.rgbToHsv.call(void 0, clampedRgba);
|
|
981
983
|
let h = hsva.h;
|
|
982
984
|
let s = hsva.s;
|
|
983
985
|
const v = hsva.v;
|
|
@@ -998,13 +1000,13 @@ function pickerStateFromColor(input, previous) {
|
|
|
998
1000
|
};
|
|
999
1001
|
}
|
|
1000
1002
|
function pickerStateToHex(state, forceAlpha = false) {
|
|
1001
|
-
const rgba =
|
|
1003
|
+
const rgba = _chunk7AHBW2CQcjs.hsvToRgb.call(void 0, {
|
|
1002
1004
|
h: state.h,
|
|
1003
1005
|
s: state.s,
|
|
1004
1006
|
v: state.v,
|
|
1005
1007
|
alpha: state.alpha
|
|
1006
1008
|
});
|
|
1007
|
-
const hex =
|
|
1009
|
+
const hex = _chunkPPFJHTW5cjs.formatHex.call(void 0, rgba);
|
|
1008
1010
|
if (forceAlpha && hex.length === 7) {
|
|
1009
1011
|
return hex + "ff";
|
|
1010
1012
|
}
|
|
@@ -1093,13 +1095,13 @@ function pickerKeyStep(state, target, key, shift) {
|
|
|
1093
1095
|
}
|
|
1094
1096
|
}
|
|
1095
1097
|
function pickerAreaBackground(state) {
|
|
1096
|
-
const pureHueRgb =
|
|
1097
|
-
const hueHex =
|
|
1098
|
+
const pureHueRgb = _chunk7AHBW2CQcjs.hsvToRgb.call(void 0, { h: state.h, s: 1, v: 1, alpha: 1 });
|
|
1099
|
+
const hueHex = _chunkPPFJHTW5cjs.formatHex.call(void 0, pureHueRgb);
|
|
1098
1100
|
return `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${hueHex})`;
|
|
1099
1101
|
}
|
|
1100
1102
|
function pickerAlphaBackground(state) {
|
|
1101
|
-
const opaqueRgb =
|
|
1102
|
-
const hex =
|
|
1103
|
+
const opaqueRgb = _chunk7AHBW2CQcjs.hsvToRgb.call(void 0, { h: state.h, s: state.s, v: state.v, alpha: 1 });
|
|
1104
|
+
const hex = _chunkPPFJHTW5cjs.formatHex.call(void 0, opaqueRgb);
|
|
1103
1105
|
return `linear-gradient(to right, transparent, ${hex})`;
|
|
1104
1106
|
}
|
|
1105
1107
|
var PICKER_HUE_BACKGROUND = "linear-gradient(to right, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%)";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BUILTIN_BRUSHES
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PJYG6FCF.js";
|
|
4
4
|
import {
|
|
5
5
|
parseProvenance
|
|
6
6
|
} from "./chunk-M6DNZNVY.js";
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
import {
|
|
52
52
|
oklabToRgb,
|
|
53
53
|
rgbToOklab
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-V6DT2CDH.js";
|
|
55
55
|
import {
|
|
56
56
|
hexToRgba,
|
|
57
57
|
normalizeTokenColor,
|