@pixerate/editor 0.262.0 → 0.263.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/animation-editor/index.cjs +60 -60
- package/dist/animation-editor/index.js +4 -4
- package/dist/brushes/index.cjs +52 -52
- package/dist/brushes/index.js +4 -4
- package/dist/{brushstrokeRender-N6UPZSQS.cjs → brushstrokeRender-2GBME4XD.cjs} +13 -13
- package/dist/{brushstrokeRender-25Q5BEY6.js → brushstrokeRender-S5DABANG.js} +3 -3
- package/dist/canvas/index.cjs +15 -14
- package/dist/canvas/index.js +3 -2
- package/dist/canvas/stickers.d.cts +5 -1
- package/dist/canvas/stickers.d.ts +5 -1
- package/dist/{chunk-6NZL24W4.js → chunk-34HIZXFX.js} +1 -1
- package/dist/{chunk-UVZ7RQOE.cjs → chunk-4E6BGHWN.cjs} +1 -1
- package/dist/{chunk-J5UQHWVL.js → chunk-6JL2D5SG.js} +27 -15
- package/dist/{chunk-QAR2N7HZ.js → chunk-6XX7E7O2.js} +1 -1
- package/dist/{chunk-3TQW5MPW.cjs → chunk-73QFSPDG.cjs} +23 -23
- package/dist/{chunk-APX63ILU.js → chunk-ACFSFUQH.js} +31 -0
- package/dist/{chunk-X2EXYY4J.js → chunk-CNLO6E2K.js} +2 -2
- package/dist/{chunk-F7CPSRLN.js → chunk-DOZ6F2K2.js} +12 -4
- package/dist/{chunk-CQVTGBQI.js → chunk-JGI4PZWO.js} +1 -1
- package/dist/{chunk-EHALWBBD.js → chunk-LG6MEEV7.js} +1 -1
- package/dist/{chunk-7AUQ2UJ3.cjs → chunk-LWHUU6A6.cjs} +10 -10
- package/dist/{chunk-JSDND7DF.cjs → chunk-OTN6VB5S.cjs} +32 -1
- package/dist/{chunk-5IW65VQ6.js → chunk-P5343XZO.js} +1 -1
- package/dist/{chunk-AVTPZO4Z.cjs → chunk-PE6YJMQT.cjs} +37 -25
- package/dist/{chunk-D4TE5JNW.js → chunk-QW7LKWKE.js} +1 -1
- package/dist/{chunk-YLUIFXSL.cjs → chunk-TIHW7CUY.cjs} +35 -35
- package/dist/{chunk-PYTJBVW5.cjs → chunk-TILEUVRO.cjs} +31 -31
- package/dist/{chunk-RVGP2XLF.cjs → chunk-XORJ7UZO.cjs} +21 -13
- package/dist/{chunk-43NT242D.cjs → chunk-XQW6R7VW.cjs} +86 -86
- package/dist/{chunk-TZOX7KWV.cjs → chunk-ZBACQHW3.cjs} +8 -8
- package/dist/image-editor/index.cjs +789 -788
- package/dist/image-editor/index.js +7 -6
- package/dist/image-editor/stickers.d.cts +7 -2
- package/dist/image-editor/stickers.d.ts +7 -2
- package/dist/paint-editor/controller.d.cts +7 -2
- package/dist/paint-editor/controller.d.ts +7 -2
- package/dist/paint-editor/index.cjs +576 -523
- package/dist/paint-editor/index.js +99 -46
- package/dist/paint-editor/sticker-art.d.cts +20 -10
- package/dist/paint-editor/sticker-art.d.ts +20 -10
- package/dist/paint-editor/stickers.d.cts +8 -1
- package/dist/paint-editor/stickers.d.ts +8 -1
- package/dist/paint-editor/stroke.d.cts +2 -0
- package/dist/paint-editor/stroke.d.ts +2 -0
- package/dist/stickers/browser.d.cts +10 -3
- package/dist/stickers/browser.d.ts +10 -3
- package/dist/stickers/combine.d.cts +2 -0
- package/dist/stickers/combine.d.ts +2 -0
- package/dist/stickers/conformance.d.cts +1 -1
- package/dist/stickers/conformance.d.ts +1 -1
- package/dist/stickers/errors.d.cts +1 -1
- package/dist/stickers/errors.d.ts +1 -1
- package/dist/stickers/fake.d.cts +4 -2
- package/dist/stickers/fake.d.ts +4 -2
- package/dist/stickers/helpers.d.cts +16 -2
- package/dist/stickers/helpers.d.ts +16 -2
- package/dist/stickers/index.cjs +116 -29
- package/dist/stickers/index.js +106 -19
- package/dist/stickers/tools.d.cts +9 -2
- package/dist/stickers/tools.d.ts +9 -2
- package/dist/stickers/types.d.cts +32 -5
- package/dist/stickers/types.d.ts +32 -5
- package/dist/vector/index.cjs +972 -971
- package/dist/vector/index.js +7 -6
- package/dist/vector/stickers.d.cts +7 -2
- package/dist/vector/stickers.d.ts +7 -2
- package/package.json +1 -1
- package/skills/pixerate-paint-editor/SKILL.md +1 -1
- package/skills/pixerate-stickers/SKILL.md +20 -9
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunkLWHUU6A6cjs = require('./chunk-LWHUU6A6.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -37,7 +37,7 @@ var lerpP = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
|
|
37
37
|
var toP = (v) => [v.x, v.y];
|
|
38
38
|
var mapP = (m, p) => [m[0] * p[0] + m[2] * p[1] + m[4], m[1] * p[0] + m[3] * p[1] + m[5]];
|
|
39
39
|
var curvesOf = (c) => Math.max(0, (c.pts.length - 1) / 3) | 0;
|
|
40
|
-
function subpathToMorphContour(sp, m =
|
|
40
|
+
function subpathToMorphContour(sp, m = _chunkLWHUU6A6cjs.IDENTITY_MATRIX) {
|
|
41
41
|
const n = sp.anchors.length;
|
|
42
42
|
if (!n) return null;
|
|
43
43
|
const first = mapP(m, toP(sp.anchors[0]));
|
|
@@ -67,8 +67,8 @@ function isStraight(p0, p1, p2, p3) {
|
|
|
67
67
|
const u2 = along(p2);
|
|
68
68
|
return off(p1) < tol && off(p2) < tol && u1 >= -1e-9 && u1 <= 1 + 1e-9 && u2 >= -1e-9 && u2 <= 1 + 1e-9;
|
|
69
69
|
}
|
|
70
|
-
function morphContourToSubpath(c, m =
|
|
71
|
-
const pts =
|
|
70
|
+
function morphContourToSubpath(c, m = _chunkLWHUU6A6cjs.IDENTITY_MATRIX, closed = c.closed) {
|
|
71
|
+
const pts = _chunkLWHUU6A6cjs.isIdentityMatrix.call(void 0, m) ? c.pts : c.pts.map((p) => mapP(m, p));
|
|
72
72
|
const curves = curvesOf(c);
|
|
73
73
|
const dropLast = closed && c.closed && curves > 0;
|
|
74
74
|
const count = dropLast ? curves : curves + 1;
|
|
@@ -84,7 +84,7 @@ function morphContourToSubpath(c, m = _chunk7AUQ2UJ3cjs.IDENTITY_MATRIX, closed
|
|
|
84
84
|
anchors[(k + 1) % count].in = { x: p2[0], y: p2[1] };
|
|
85
85
|
}
|
|
86
86
|
for (const a of anchors) {
|
|
87
|
-
const type =
|
|
87
|
+
const type = _chunkLWHUU6A6cjs.inferAnchorType.call(void 0, a);
|
|
88
88
|
if (type !== "corner") a.type = type;
|
|
89
89
|
}
|
|
90
90
|
const isClosed = closed && curves > 0;
|
|
@@ -267,7 +267,7 @@ function bestStart(fixed, free, useShapeContext) {
|
|
|
267
267
|
return best;
|
|
268
268
|
}
|
|
269
269
|
function placeIn(c, from, to) {
|
|
270
|
-
const b =
|
|
270
|
+
const b = _chunkLWHUU6A6cjs.unionBounds.call(void 0, [boundsOfPoints(c.pts)]);
|
|
271
271
|
const p = b ? [b.x + b.width / 2, b.y + b.height / 2] : c.pts[0];
|
|
272
272
|
if (!from || !to) return p;
|
|
273
273
|
const fx = from.width > 0 ? (p[0] - from.x) / from.width : 0.5;
|
|
@@ -456,7 +456,7 @@ function interpolateVectorColor(a, b, t) {
|
|
|
456
456
|
}
|
|
457
457
|
function resampleGradientStops(g, offsets) {
|
|
458
458
|
return offsets.map((offset) => {
|
|
459
|
-
const s =
|
|
459
|
+
const s = _chunkLWHUU6A6cjs.sampleVectorGradient.call(void 0, g, offset);
|
|
460
460
|
return s.opacity < 1 ? { offset, color: s.color, opacity: Math.round(s.opacity * 1e4) / 1e4 } : { offset, color: s.color };
|
|
461
461
|
});
|
|
462
462
|
}
|
|
@@ -467,11 +467,11 @@ function lerpAngle(a, b, t) {
|
|
|
467
467
|
var lerpPoint = (a, b, t) => ({ x: lerpN(a.x, b.x, t), y: lerpN(a.y, b.y, t) });
|
|
468
468
|
var sameColourModel = (a, b) => (_nullishCoalesce(a.interpolation, () => ( "srgb"))) === (_nullishCoalesce(b.interpolation, () => ( "srgb"))) && (_nullishCoalesce(a.smoothness, () => ( 0))) === (_nullishCoalesce(b.smoothness, () => ( 0)));
|
|
469
469
|
function lerpStops(a, b, t) {
|
|
470
|
-
let stopsA =
|
|
471
|
-
let stopsB =
|
|
470
|
+
let stopsA = _chunkLWHUU6A6cjs.sortedVectorGradientStops.call(void 0, a);
|
|
471
|
+
let stopsB = _chunkLWHUU6A6cjs.sortedVectorGradientStops.call(void 0, b);
|
|
472
472
|
const resampled = stopsA.length !== stopsB.length || !sameColourModel(a, b);
|
|
473
473
|
if (resampled) {
|
|
474
|
-
const offs = [...
|
|
474
|
+
const offs = [..._chunkLWHUU6A6cjs.expandVectorGradientStops.call(void 0, a), ..._chunkLWHUU6A6cjs.expandVectorGradientStops.call(void 0, b), ...stopsA, ...stopsB].map((s) => s.offset).filter(Number.isFinite).sort((x, y) => x - y);
|
|
475
475
|
const common = offs.filter((o, i) => i === 0 || o - offs[i - 1] > 1e-4);
|
|
476
476
|
stopsA = resampleGradientStops(a, common);
|
|
477
477
|
stopsB = resampleGradientStops(b, common);
|
|
@@ -498,8 +498,8 @@ function lerpGradient(a, b, t) {
|
|
|
498
498
|
}
|
|
499
499
|
if (near.spread && near.spread !== "pad") out.spread = near.spread;
|
|
500
500
|
if (near.strokeMode && near.strokeMode !== "within") out.strokeMode = near.strokeMode;
|
|
501
|
-
const ea =
|
|
502
|
-
const eb =
|
|
501
|
+
const ea = _chunkLWHUU6A6cjs.hasExplicitGradientGeometry.call(void 0, a);
|
|
502
|
+
const eb = _chunkLWHUU6A6cjs.hasExplicitGradientGeometry.call(void 0, b);
|
|
503
503
|
if (!ea && !eb) {
|
|
504
504
|
if (a.angle !== void 0 || b.angle !== void 0 || a.type === "linear" || a.type === "reflected") {
|
|
505
505
|
const fallback = a.type === "linear" || a.type === "reflected" ? 180 : 90;
|
|
@@ -512,10 +512,10 @@ function lerpGradient(a, b, t) {
|
|
|
512
512
|
}
|
|
513
513
|
return out;
|
|
514
514
|
}
|
|
515
|
-
const pa =
|
|
516
|
-
const pb =
|
|
515
|
+
const pa = _chunkLWHUU6A6cjs.vectorGradientPoints.call(void 0, a);
|
|
516
|
+
const pb = _chunkLWHUU6A6cjs.vectorGradientPoints.call(void 0, b);
|
|
517
517
|
if (pa.units !== pb.units) {
|
|
518
|
-
const src =
|
|
518
|
+
const src = _chunkLWHUU6A6cjs.explicitVectorGradient.call(void 0, near);
|
|
519
519
|
return { ...src, stops: out.stops, ...out.interpolation ? { interpolation: out.interpolation } : {}, ...out.smoothness ? { smoothness: out.smoothness } : {} };
|
|
520
520
|
}
|
|
521
521
|
out.start = lerpPoint(pa.start, pb.start, t);
|
|
@@ -535,14 +535,14 @@ function solidLike(color, like) {
|
|
|
535
535
|
function interpolateVectorPaint(a, b, t) {
|
|
536
536
|
if (t <= 0) return a;
|
|
537
537
|
if (t >= 1) return b;
|
|
538
|
-
const pa =
|
|
539
|
-
const pb =
|
|
538
|
+
const pa = _chunkLWHUU6A6cjs.hasPaint.call(void 0, a);
|
|
539
|
+
const pb = _chunkLWHUU6A6cjs.hasPaint.call(void 0, b);
|
|
540
540
|
if (!pa && !pb) return t < 0.5 ? a : b;
|
|
541
541
|
if (typeof a === "string" && pa && typeof b === "string" && pb) return interpolateVectorColor(a, b, t);
|
|
542
542
|
if (!pa && typeof b === "string") return interpolateVectorColor("transparent", b, t);
|
|
543
543
|
if (!pb && typeof a === "string") return interpolateVectorColor(a, "transparent", t);
|
|
544
|
-
const ga = pa &&
|
|
545
|
-
const gb = pb &&
|
|
544
|
+
const ga = pa && _chunkLWHUU6A6cjs.isVectorGradient.call(void 0, a) ? a : null;
|
|
545
|
+
const gb = pb && _chunkLWHUU6A6cjs.isVectorGradient.call(void 0, b) ? b : null;
|
|
546
546
|
if (ga && gb) return _nullishCoalesce(lerpGradient(ga, gb, t), () => ( (t < 0.5 ? a : b)));
|
|
547
547
|
if (gb) return _nullishCoalesce(lerpGradient(solidLike(pa ? a : null, gb), gb, t), () => ( b));
|
|
548
548
|
if (ga) return _nullishCoalesce(lerpGradient(ga, solidLike(pb ? b : null, ga), t), () => ( a));
|
|
@@ -553,8 +553,8 @@ function interpolateWidthProfiles(a, b, t) {
|
|
|
553
553
|
const at = [..._nullishCoalesce(a, () => ( [])), ..._nullishCoalesce(b, () => ( [])), { t: 0 }, { t: 1 }].map((p) => p.t).sort((x, y) => x - y);
|
|
554
554
|
const ts = at.filter((v, i) => i === 0 || v - at[i - 1] > 1e-6);
|
|
555
555
|
return ts.map((pos) => {
|
|
556
|
-
const x =
|
|
557
|
-
const y =
|
|
556
|
+
const x = _chunkLWHUU6A6cjs.widthProfileAt.call(void 0, a, pos);
|
|
557
|
+
const y = _chunkLWHUU6A6cjs.widthProfileAt.call(void 0, b, pos);
|
|
558
558
|
return { t: pos, left: lerpN(x.left, y.left, t), right: lerpN(x.right, y.right, t) };
|
|
559
559
|
});
|
|
560
560
|
}
|
|
@@ -597,7 +597,7 @@ function reversedStyle(s) {
|
|
|
597
597
|
out.endArrow = s.startArrow;
|
|
598
598
|
out.startArrowScale = s.endArrowScale;
|
|
599
599
|
out.endArrowScale = s.startArrowScale;
|
|
600
|
-
if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile =
|
|
600
|
+
if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile = _chunkLWHUU6A6cjs.reverseWidthProfile.call(void 0, s.strokeWidthProfile);
|
|
601
601
|
for (const k of ["startArrow", "endArrow", "startArrowScale", "endArrowScale"]) if (out[k] === void 0) delete out[k];
|
|
602
602
|
return out;
|
|
603
603
|
}
|
|
@@ -623,19 +623,19 @@ function styleOf(n) {
|
|
|
623
623
|
return out;
|
|
624
624
|
}
|
|
625
625
|
function contoursOf(node, m) {
|
|
626
|
-
return
|
|
626
|
+
return _chunkLWHUU6A6cjs.expandVectorCorners.call(void 0, node.subpaths).map((sp) => subpathToMorphContour(sp, m)).filter((c) => !!c);
|
|
627
627
|
}
|
|
628
|
-
function preparePathMorph(a, b, options, ma =
|
|
628
|
+
function preparePathMorph(a, b, options, ma = _chunkLWHUU6A6cjs.nodeMatrix.call(void 0, a), mb = _chunkLWHUU6A6cjs.nodeMatrix.call(void 0, b)) {
|
|
629
629
|
const corr = correspondMorphContours(contoursOf(a, ma), contoursOf(b, mb), options);
|
|
630
630
|
const sim = procrustes(corr.a, corr.b);
|
|
631
631
|
const styleA = styleOf(a);
|
|
632
632
|
const styleB = corr.reversed ? reversedStyle(styleOf(b)) : styleOf(b);
|
|
633
|
-
const rigid = !
|
|
633
|
+
const rigid = !_chunkLWHUU6A6cjs.isIdentityMatrix.call(void 0, ma) || !_chunkLWHUU6A6cjs.isIdentityMatrix.call(void 0, mb);
|
|
634
634
|
const id = _nullishCoalesce(options.id, () => ( a.id));
|
|
635
635
|
return (t) => {
|
|
636
636
|
const contours = interpolateMorphContours(corr.a, corr.b, t, { linear: options.linear, rigidity: options.rigidity, similarity: sim });
|
|
637
|
-
const m = rigid ? interpolateRigidMatrix(ma, mb, t) :
|
|
638
|
-
const back = rigid ?
|
|
637
|
+
const m = rigid ? interpolateRigidMatrix(ma, mb, t) : _chunkLWHUU6A6cjs.IDENTITY_MATRIX;
|
|
638
|
+
const back = rigid ? _chunkLWHUU6A6cjs.invertMatrix.call(void 0, m) : _chunkLWHUU6A6cjs.IDENTITY_MATRIX;
|
|
639
639
|
const subpaths = contours.map((c, k) => {
|
|
640
640
|
const closed = t <= 0 ? corr.a[k].closed : t >= 1 ? corr.b[k].closed : corr.a[k].closed && corr.b[k].closed;
|
|
641
641
|
return morphContourToSubpath({ closed: corr.a[k].closed && corr.b[k].closed, pts: c.pts }, back, closed);
|
|
@@ -643,14 +643,14 @@ function preparePathMorph(a, b, options, ma = _chunk7AUQ2UJ3cjs.nodeMatrix.call(
|
|
|
643
643
|
const node = { id, type: "path", subpaths, ...interpolateVectorStyle(styleA, styleB, t) };
|
|
644
644
|
const opacity = lerpN(_nullishCoalesce(a.opacity, () => ( 1)), _nullishCoalesce(b.opacity, () => ( 1)), t);
|
|
645
645
|
if (opacity < 1) node.opacity = opacity;
|
|
646
|
-
if (rigid && !
|
|
646
|
+
if (rigid && !_chunkLWHUU6A6cjs.isIdentityMatrix.call(void 0, m)) node.transform = m;
|
|
647
647
|
return node;
|
|
648
648
|
};
|
|
649
649
|
}
|
|
650
|
-
function flattenPaths(node, parent =
|
|
651
|
-
const m =
|
|
650
|
+
function flattenPaths(node, parent = _chunkLWHUU6A6cjs.IDENTITY_MATRIX) {
|
|
651
|
+
const m = _chunkLWHUU6A6cjs.multiplyMatrices.call(void 0, _chunkLWHUU6A6cjs.nodeMatrix.call(void 0, node), parent);
|
|
652
652
|
if (node.type === "path") return [{ path: node, m, opacity: 1 }];
|
|
653
|
-
if (node.type === "text" || node.type === "instance") return flattenPaths(
|
|
653
|
+
if (node.type === "text" || node.type === "instance") return flattenPaths(_chunkLWHUU6A6cjs.expandVectorAppearance.call(void 0, node), parent);
|
|
654
654
|
const o = _nullishCoalesce(node.opacity, () => ( 1));
|
|
655
655
|
return node.children.filter((c) => c.visible !== false).flatMap((c) => flattenPaths(c, m)).map((e) => ({ ...e, opacity: e.opacity * o }));
|
|
656
656
|
}
|
|
@@ -672,8 +672,8 @@ function createVectorMorph(a, b, options = {}) {
|
|
|
672
672
|
}
|
|
673
673
|
const pa = flattenPaths(a);
|
|
674
674
|
const pb = flattenPaths(b);
|
|
675
|
-
const ba =
|
|
676
|
-
const bb =
|
|
675
|
+
const ba = _chunkLWHUU6A6cjs.unionBounds.call(void 0, pa.map((e) => placedBounds(e.path, e.m)));
|
|
676
|
+
const bb = _chunkLWHUU6A6cjs.unionBounds.call(void 0, pb.map((e) => placedBounds(e.path, e.m)));
|
|
677
677
|
const id = _nullishCoalesce(options.id, () => ( a.id));
|
|
678
678
|
const parts = [];
|
|
679
679
|
const opacities = [];
|
|
@@ -685,10 +685,10 @@ function createVectorMorph(a, b, options = {}) {
|
|
|
685
685
|
parts.push(preparePathMorph(x.path, y.path, sub, x.m, y.m));
|
|
686
686
|
opacities.push([x.opacity, y.opacity]);
|
|
687
687
|
} else if (x) {
|
|
688
|
-
parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m,
|
|
688
|
+
parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m, _chunkLWHUU6A6cjs.IDENTITY_MATRIX));
|
|
689
689
|
opacities.push([x.opacity, x.opacity]);
|
|
690
690
|
} else if (y) {
|
|
691
|
-
parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub,
|
|
691
|
+
parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub, _chunkLWHUU6A6cjs.IDENTITY_MATRIX, y.m));
|
|
692
692
|
opacities.push([y.opacity, y.opacity]);
|
|
693
693
|
}
|
|
694
694
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkPE6YJMQTcjs = require('./chunk-PE6YJMQT.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -15,12 +15,12 @@ var _chunkAVTPZO4Zcjs = require('./chunk-AVTPZO4Z.cjs');
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunkZBACQHW3cjs = require('./chunk-ZBACQHW3.cjs');
|
|
19
19
|
|
|
20
20
|
// src/brushes/patch.ts
|
|
21
21
|
var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
22
22
|
var copy = (v) => JSON.parse(JSON.stringify(v));
|
|
23
|
-
var FACETS =
|
|
23
|
+
var FACETS = _chunkZBACQHW3cjs.BRUSH_JSON_SCHEMA.properties;
|
|
24
24
|
var BRUSH_PATCH_PROPERTIES = (() => {
|
|
25
25
|
const { id: _id, name: _name, ...rest } = FACETS;
|
|
26
26
|
const { required: _r, ...tip } = rest.tip;
|
|
@@ -52,17 +52,17 @@ function changedBrushPaths(a, b, path = "") {
|
|
|
52
52
|
// src/brushes/tools.ts
|
|
53
53
|
var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
54
54
|
var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
|
|
55
|
-
var FACETS2 =
|
|
55
|
+
var FACETS2 = _chunkZBACQHW3cjs.BRUSH_JSON_SCHEMA.properties;
|
|
56
56
|
var ID = { type: "string", pattern: String(FACETS2.id.pattern), description: "Brush id from list_brush_presets (lowercase letters, digits and dashes)." };
|
|
57
57
|
var FACET_PROPS = BRUSH_PATCH_PROPERTIES;
|
|
58
|
-
var HOSTS = Object.keys(
|
|
58
|
+
var HOSTS = Object.keys(_chunkZBACQHW3cjs.BRUSH_HOST_PROFILES);
|
|
59
59
|
var copy2 = (v) => JSON.parse(JSON.stringify(v));
|
|
60
60
|
var merge = mergeBrushPatch;
|
|
61
61
|
var changedPaths = changedBrushPaths;
|
|
62
62
|
function summary(entry, profile, withCheck) {
|
|
63
63
|
const b = entry.brush;
|
|
64
|
-
const engine =
|
|
65
|
-
const check = withCheck ?
|
|
64
|
+
const engine = _chunkZBACQHW3cjs.resolveEngine.call(void 0, b);
|
|
65
|
+
const check = withCheck ? _chunkZBACQHW3cjs.checkBrush.call(void 0, b, profile) : null;
|
|
66
66
|
return {
|
|
67
67
|
id: b.id,
|
|
68
68
|
name: b.name,
|
|
@@ -71,7 +71,7 @@ function summary(entry, profile, withCheck) {
|
|
|
71
71
|
...b.medium ? { medium: b.medium } : {},
|
|
72
72
|
...b.variety ? { variety: b.variety } : {},
|
|
73
73
|
...b.tool ? { tool: b.tool } : {},
|
|
74
|
-
category:
|
|
74
|
+
category: _chunkZBACQHW3cjs.resolveCategory.call(void 0, b, engine),
|
|
75
75
|
engine,
|
|
76
76
|
tip: b.tip.shape,
|
|
77
77
|
...b.tip.size !== void 0 ? { size: b.tip.size } : {},
|
|
@@ -85,28 +85,28 @@ function summary(entry, profile, withCheck) {
|
|
|
85
85
|
var refusal = (check, host) => `${host.name} can't use this brush: ${check.issues.filter((i) => i.severity === "error").map((i) => `${i.facet}: ${i.reason} ${i.fix}`).join(" ")} (check_brush lists every issue; nothing was saved.)`;
|
|
86
86
|
var warnings = (check) => check.issues.filter((i) => i.severity === "warning");
|
|
87
87
|
function createBrushLibraryTools(library, options = {}) {
|
|
88
|
-
const profile = _nullishCoalesce(options.profile, () => (
|
|
88
|
+
const profile = _nullishCoalesce(options.profile, () => ( _chunkZBACQHW3cjs.PAINT_PROFILE));
|
|
89
89
|
const hostOf = (id) => {
|
|
90
90
|
if (id === void 0) return profile;
|
|
91
|
-
const p =
|
|
92
|
-
if (!p) throw new (0,
|
|
91
|
+
const p = _chunkZBACQHW3cjs.BRUSH_HOST_PROFILES[id];
|
|
92
|
+
if (!p) throw new (0, _chunkZBACQHW3cjs.BrushLibraryError)("invalid", `No host "${id}"; use one of: ${HOSTS.join(", ")}.`);
|
|
93
93
|
return p;
|
|
94
94
|
};
|
|
95
95
|
const entry = async (id) => {
|
|
96
96
|
const found = await library.get(id);
|
|
97
97
|
if (found) return found;
|
|
98
98
|
const ids = (await library.list()).map((e) => e.brush.id);
|
|
99
|
-
throw new (0,
|
|
99
|
+
throw new (0, _chunkZBACQHW3cjs.BrushLibraryError)("unknown_brush", `No brush "${id}". ${_chunkZBACQHW3cjs.closest.call(void 0, id, ids)}list_brush_presets lists them.`);
|
|
100
100
|
};
|
|
101
101
|
const checkFor = async (brush, p) => {
|
|
102
|
-
const check2 =
|
|
102
|
+
const check2 = _chunkZBACQHW3cjs.checkBrush.call(void 0, brush, p);
|
|
103
103
|
const provider = _optionalChain([options, 'access', _9 => _9.stickers, 'optionalCall', _10 => _10()]);
|
|
104
104
|
if (!provider || brush.tip.shape !== "stamp") return check2;
|
|
105
105
|
const issues = [...check2.issues];
|
|
106
106
|
for (const ref of _nullishCoalesce(brush.tip.stamps, () => ( []))) {
|
|
107
107
|
if (ref.startsWith("editor:")) continue;
|
|
108
108
|
try {
|
|
109
|
-
await
|
|
109
|
+
await _chunkPE6YJMQTcjs.describeStickerRef.call(void 0, provider, ref);
|
|
110
110
|
} catch (e) {
|
|
111
111
|
issues.push({ facet: "tip.stamps", severity: "error", reason: `${p.name} can't load sticker "${ref}": ${e.message}`, fix: "Use a ref from find_stickers, or an editor stamp (editor:star, editor:dot\u2026)." });
|
|
112
112
|
}
|
|
@@ -117,12 +117,12 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
117
117
|
const problems = [];
|
|
118
118
|
let brush;
|
|
119
119
|
try {
|
|
120
|
-
brush =
|
|
120
|
+
brush = _chunkZBACQHW3cjs.normalizeBrushSpec.call(void 0, raw, problems);
|
|
121
121
|
} catch (e) {
|
|
122
|
-
throw new (0,
|
|
122
|
+
throw new (0, _chunkZBACQHW3cjs.BrushLibraryError)("invalid", e.message);
|
|
123
123
|
}
|
|
124
124
|
const check2 = await checkFor(brush, profile);
|
|
125
|
-
if (!check2.ok) throw new (0,
|
|
125
|
+
if (!check2.ok) throw new (0, _chunkZBACQHW3cjs.BrushLibraryError)("invalid", refusal(check2, profile));
|
|
126
126
|
const saved = await library.save(brush, { overwrite });
|
|
127
127
|
return { ...saved, problems, check: check2 };
|
|
128
128
|
};
|
|
@@ -133,10 +133,10 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
133
133
|
inputSchema: {
|
|
134
134
|
type: "object",
|
|
135
135
|
properties: {
|
|
136
|
-
kind: { type: "string", enum: [...
|
|
137
|
-
medium: { type: "string", enum: [...
|
|
136
|
+
kind: { type: "string", enum: [..._chunkZBACQHW3cjs.BRUSH_KINDS], description: "mark (lays a material) or tool (works on paint already down)." },
|
|
137
|
+
medium: { type: "string", enum: [..._chunkZBACQHW3cjs.BRUSH_MEDIA], description: "Marks laying this medium." },
|
|
138
138
|
variety: { type: "string", maxLength: 40, description: "This variety (oil, watercolor, pencil, highlighter\u2026)." },
|
|
139
|
-
tool: { type: "string", enum: [...
|
|
139
|
+
tool: { type: "string", enum: [..._chunkZBACQHW3cjs.BRUSH_TOOLS], description: "Tools that do this." },
|
|
140
140
|
tag: { type: "string", maxLength: 40, description: "Brushes with this tag." },
|
|
141
141
|
text: { type: "string", maxLength: 200, description: "Words in the id, name, description, variety or tags (each word must match the start of one)." },
|
|
142
142
|
source: { type: "string", enum: ["all", "builtin", "user"], description: "all (default), builtin presets only, or user (saved) brushes only." },
|
|
@@ -163,8 +163,8 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
163
163
|
annotations: { title: "Describe a brush", ...READ },
|
|
164
164
|
handler: async ({ id }) => {
|
|
165
165
|
const e = await entry(id);
|
|
166
|
-
const engine =
|
|
167
|
-
return { brush: e.brush, builtin: e.builtin, engine, category:
|
|
166
|
+
const engine = _chunkZBACQHW3cjs.resolveEngine.call(void 0, e.brush);
|
|
167
|
+
return { brush: e.brush, builtin: e.builtin, engine, category: _chunkZBACQHW3cjs.resolveCategory.call(void 0, e.brush, engine), check: await checkFor(e.brush, profile) };
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
170
|
const check = {
|
|
@@ -182,20 +182,20 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
182
182
|
},
|
|
183
183
|
annotations: { title: "Check a brush for a host", ...READ },
|
|
184
184
|
handler: async ({ id, brush, host }) => {
|
|
185
|
-
if (id === void 0 === (brush === void 0)) throw new (0,
|
|
185
|
+
if (id === void 0 === (brush === void 0)) throw new (0, _chunkZBACQHW3cjs.BrushLibraryError)("invalid", "Give either id (a library brush) or brush (a spec), not both or neither.");
|
|
186
186
|
const p = hostOf(host);
|
|
187
187
|
let b;
|
|
188
188
|
const problems = [];
|
|
189
189
|
if (id !== void 0) b = (await entry(id)).brush;
|
|
190
190
|
else {
|
|
191
191
|
try {
|
|
192
|
-
b =
|
|
192
|
+
b = _chunkZBACQHW3cjs.normalizeBrushSpec.call(void 0, brush, problems);
|
|
193
193
|
} catch (e) {
|
|
194
|
-
throw new (0,
|
|
194
|
+
throw new (0, _chunkZBACQHW3cjs.BrushLibraryError)("invalid", e.message);
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
const result = await checkFor(b, p);
|
|
198
|
-
return { host: p.id, ...result, ...problems.length ? { problems } : {}, ...!result.ok ? { degraded:
|
|
198
|
+
return { host: p.id, ...result, ...problems.length ? { problems } : {}, ...!result.ok ? { degraded: _chunkZBACQHW3cjs.degrade.call(void 0, b, p) } : {} };
|
|
199
199
|
}
|
|
200
200
|
};
|
|
201
201
|
const exportTool = {
|
|
@@ -254,12 +254,12 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
254
254
|
},
|
|
255
255
|
annotations: { title: "Save a new brush", ...WRITE },
|
|
256
256
|
handler: async ({ basedOn, ...spec }) => {
|
|
257
|
-
if (library.isBuiltin(spec.id)) throw new (0,
|
|
258
|
-
if (await library.get(spec.id)) throw new (0,
|
|
257
|
+
if (library.isBuiltin(spec.id)) throw new (0, _chunkZBACQHW3cjs.BrushLibraryError)("builtin", `"${spec.id}" is a built-in brush id; pick another id (or basedOn "${spec.id}" with a new id).`);
|
|
258
|
+
if (await library.get(spec.id)) throw new (0, _chunkZBACQHW3cjs.BrushLibraryError)("exists", `A brush "${spec.id}" exists already; pick another id, or change it with update_brush.`);
|
|
259
259
|
const base = basedOn !== void 0 ? (await entry(basedOn)).brush : void 0;
|
|
260
260
|
const raw = base ? merge(base, spec) : spec;
|
|
261
261
|
const saved = await store(raw, false);
|
|
262
|
-
return { id: saved.brush.id, brush: saved.brush, engine:
|
|
262
|
+
return { id: saved.brush.id, brush: saved.brush, engine: _chunkZBACQHW3cjs.resolveEngine.call(void 0, saved.brush), problems: saved.problems, warnings: warnings(saved.check) };
|
|
263
263
|
}
|
|
264
264
|
},
|
|
265
265
|
{
|
|
@@ -280,7 +280,7 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
280
280
|
annotations: { title: "Update a brush", ...WRITE, idempotentHint: true },
|
|
281
281
|
handler: async ({ id, unset, ...patch }) => {
|
|
282
282
|
const e = await entry(id);
|
|
283
|
-
if (e.builtin) throw new (0,
|
|
283
|
+
if (e.builtin) throw new (0, _chunkZBACQHW3cjs.BrushLibraryError)("builtin", `"${id}" is a built-in brush and can't be changed; duplicate_brush makes a copy you can change.`);
|
|
284
284
|
const base = copy2(e.brush);
|
|
285
285
|
for (const k of _nullishCoalesce(unset, () => ( []))) delete base[k];
|
|
286
286
|
const saved = await store(merge(base, { ...patch, id }), true);
|
|
@@ -339,7 +339,7 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
339
339
|
return tools;
|
|
340
340
|
}
|
|
341
341
|
function createBrushLibraryToolProvider(library, options = {}) {
|
|
342
|
-
const profile = _nullishCoalesce(options.profile, () => (
|
|
342
|
+
const profile = _nullishCoalesce(options.profile, () => ( _chunkZBACQHW3cjs.PAINT_PROFILE));
|
|
343
343
|
const tools = createBrushLibraryTools(library, options);
|
|
344
344
|
return {
|
|
345
345
|
id: _nullishCoalesce(options.id, () => ( "brushes")),
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
var _chunkOTN6VB5Scjs = require('./chunk-OTN6VB5S.cjs');
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
var _chunkU67EN7GGcjs = require('./chunk-U67EN7GG.cjs');
|
|
@@ -32,7 +33,7 @@ var HEX = /^#[0-9a-fA-F]{6}$/;
|
|
|
32
33
|
function stampOutline(kind) {
|
|
33
34
|
const n = GRID;
|
|
34
35
|
const f = new Float32Array((n + 1) * (n + 1));
|
|
35
|
-
for (let j = 0; j <= n; j++) for (let i = 0; i <= n; i++) f[j * (n + 1) + i] =
|
|
36
|
+
for (let j = 0; j <= n; j++) for (let i = 0; i <= n; i++) f[j * (n + 1) + i] = _chunkOTN6VB5Scjs.stampCoverage.call(void 0, kind, i / n * 2 - 1, j / n * 2 - 1, SHAPE_SEED) - 0.5;
|
|
36
37
|
const at = (i, j) => f[j * (n + 1) + i];
|
|
37
38
|
const points = /* @__PURE__ */ new Map();
|
|
38
39
|
const point = (key, i0, j0, i1, j1) => {
|
|
@@ -169,7 +170,7 @@ function stampPixels(kind, size, colour) {
|
|
|
169
170
|
for (let y = 0; y < size; y++) {
|
|
170
171
|
for (let x = 0; x < size; x++) {
|
|
171
172
|
let c = 0;
|
|
172
|
-
for (let sy = 0; sy < ss; sy++) for (let sx = 0; sx < ss; sx++) c +=
|
|
173
|
+
for (let sy = 0; sy < ss; sy++) for (let sx = 0; sx < ss; sx++) c += _chunkOTN6VB5Scjs.stampCoverage.call(void 0, kind, (x + (sx + 0.5) / ss) / size * 2 - 1, (y + (sy + 0.5) / ss) / size * 2 - 1, SHAPE_SEED);
|
|
173
174
|
const a = Math.round(c / (ss * ss) * 255);
|
|
174
175
|
if (!a) continue;
|
|
175
176
|
const i = (y * size + x) * 4;
|
|
@@ -191,24 +192,25 @@ function editorStickers() {
|
|
|
191
192
|
return { id: k, name: m.name, category: m.category, tags: m.tags, description: m.description, width: BOX, height: BOX, thumbnail: thumbs.get(k), formats: ["svg", "png"], licence: { ...LICENCE }, tintable: true };
|
|
192
193
|
};
|
|
193
194
|
const kind = (id) => {
|
|
194
|
-
if (!
|
|
195
|
+
if (!_chunkOTN6VB5Scjs.STAMP_KINDS.includes(id)) throw new (0, _chunkU67EN7GGcjs.StickerError)("unknown_sticker", `The editor has no sticker "${id}"; its stickers are ${_chunkOTN6VB5Scjs.STAMP_KINDS.join(", ")}.`);
|
|
195
196
|
return id;
|
|
196
197
|
};
|
|
197
198
|
return {
|
|
198
|
-
id:
|
|
199
|
+
id: _chunkOTN6VB5Scjs.EDITOR_STICKERS_ID,
|
|
199
200
|
name: "Editor stickers",
|
|
200
201
|
version: "1",
|
|
201
202
|
capabilities: { supportsSearch: true, supportsSvg: true, supportsRaster: true, maxSize: 1024 },
|
|
202
|
-
list: (options) =>
|
|
203
|
-
search: (query, options) =>
|
|
203
|
+
list: (options) => _chunkOTN6VB5Scjs.stickerPage.call(void 0, _chunkOTN6VB5Scjs.STAMP_KINDS.map(summary), options),
|
|
204
|
+
search: (query, options) => _chunkOTN6VB5Scjs.stickerPage.call(void 0, _chunkOTN6VB5Scjs.STAMP_KINDS.map(summary), options, query),
|
|
204
205
|
describe(id) {
|
|
205
|
-
if (!
|
|
206
|
+
if (!_chunkOTN6VB5Scjs.STAMP_KINDS.includes(id)) return void 0;
|
|
206
207
|
const k = id;
|
|
207
208
|
return { ...summary(k), silhouette: outline(k), colours: [META[k].colour] };
|
|
208
209
|
},
|
|
209
|
-
categories: () => [...new Set(
|
|
210
|
+
categories: () => [...new Set(_chunkOTN6VB5Scjs.STAMP_KINDS.map((k) => META[k].category))].map((c) => ({ id: c, name: c[0].toUpperCase() + c.slice(1), count: _chunkOTN6VB5Scjs.STAMP_KINDS.filter((k) => META[k].category === c).length })),
|
|
210
211
|
load(id, options = {}) {
|
|
211
212
|
const k = kind(id);
|
|
213
|
+
_chunkOTN6VB5Scjs.checkStickerVariant.call(void 0, { id: k }, options.variant);
|
|
212
214
|
const colour = _nullishCoalesce(options.colour, () => ( META[k].colour));
|
|
213
215
|
if (!HEX.test(colour)) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `colour ${JSON.stringify(colour)} must be #rrggbb.`);
|
|
214
216
|
if (options.format === "png") {
|
|
@@ -229,7 +231,7 @@ var StickerBrowser = (_class = class {
|
|
|
229
231
|
constructor(provider, pageSize = 24) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
230
232
|
this.provider = provider;
|
|
231
233
|
this.pageSize = pageSize;
|
|
232
|
-
this.s = { query: "", category: "", items: [], total: 0, hasMore: false, loading: false, error: null, categories: [], provider: provider().name };
|
|
234
|
+
this.s = { query: "", category: "", collection: "", items: [], total: 0, hasMore: false, loading: false, error: null, categories: [], collections: [], provider: provider().name };
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
|
|
@@ -256,8 +258,9 @@ var StickerBrowser = (_class = class {
|
|
|
256
258
|
this.set({ loading: true, error: null, items: [], total: 0, hasMore: false, provider: p.name });
|
|
257
259
|
try {
|
|
258
260
|
const categories = await _asyncNullishCoalesce(await _optionalChain([p, 'access', _2 => _2.categories, 'optionalCall', _3 => _3()]), async () => ( []));
|
|
261
|
+
const collections = await _asyncNullishCoalesce(await _optionalChain([p, 'access', _4 => _4.listCollections, 'optionalCall', _5 => _5()]), async () => ( []));
|
|
259
262
|
if (run !== this.run) return;
|
|
260
|
-
this.set({ categories });
|
|
263
|
+
this.set({ categories, collections, ...this.s.collection && !collections.some((c) => c.id === this.s.collection) ? { collection: "" } : {} });
|
|
261
264
|
await this.page(run, p, true);
|
|
262
265
|
} catch (e) {
|
|
263
266
|
if (run === this.run) this.set({ loading: false, error: e instanceof Error ? e.message : String(e) });
|
|
@@ -273,6 +276,11 @@ var StickerBrowser = (_class = class {
|
|
|
273
276
|
this.s = { ...this.s, category };
|
|
274
277
|
return this.refresh();
|
|
275
278
|
}
|
|
279
|
+
/** Shows one collection (`''` for all) from the first page. */
|
|
280
|
+
setCollection(collection) {
|
|
281
|
+
this.s = { ...this.s, collection };
|
|
282
|
+
return this.refresh();
|
|
283
|
+
}
|
|
276
284
|
/** Loads the next page onto the list. */
|
|
277
285
|
async more() {
|
|
278
286
|
if (!this.next || this.s.loading) return;
|
|
@@ -285,12 +293,12 @@ var StickerBrowser = (_class = class {
|
|
|
285
293
|
}
|
|
286
294
|
}
|
|
287
295
|
async page(run, p, first) {
|
|
288
|
-
const options = { limit: this.pageSize, ...this.s.category ? { category: this.s.category } : {}, ...!first && this.next ? { after: this.next } : {} };
|
|
296
|
+
const options = { limit: this.pageSize, ...this.s.category ? { category: this.s.category } : {}, ...this.s.collection ? { collection: this.s.collection } : {}, ...!first && this.next ? { after: this.next } : {} };
|
|
289
297
|
const q = this.s.query.trim();
|
|
290
298
|
const res = q && p.capabilities.supportsSearch ? await p.search(q, options) : await p.list(options);
|
|
291
299
|
if (run !== this.run) return;
|
|
292
300
|
this.next = res.next;
|
|
293
|
-
const items = res.items.map((s) => ({ ...s, ref:
|
|
301
|
+
const items = res.items.map((s) => ({ ...s, ref: _chunkOTN6VB5Scjs.stickerRefOf.call(void 0, p, s.id) }));
|
|
294
302
|
this.set({ items: first ? items : [...this.s.items, ...items], total: res.total, hasMore: Boolean(res.next), loading: false });
|
|
295
303
|
}
|
|
296
304
|
}, _class);
|