@pixerate/editor 0.140.3 → 0.141.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/canvasPlayback.d.cts +15 -0
- package/dist/agent/canvasPlayback.d.ts +15 -0
- package/dist/agent/index.cjs +144 -23
- package/dist/agent/index.d.cts +1 -0
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.js +125 -4
- package/dist/agent/providers.d.cts +8 -0
- package/dist/agent/providers.d.ts +8 -0
- package/dist/agent/types.d.cts +3 -0
- package/dist/agent/types.d.ts +3 -0
- package/dist/animation/index.cjs +2 -2
- package/dist/animation/index.js +1 -1
- package/dist/animation/presence.d.cts +1 -75
- package/dist/animation/presence.d.ts +1 -75
- package/dist/animation-editor/index.cjs +55 -55
- package/dist/animation-editor/index.js +2 -2
- package/dist/bridge/cli.cjs +3 -3
- package/dist/bridge/cli.js +2 -2
- package/dist/bridge/index.cjs +3 -3
- package/dist/bridge/index.js +2 -2
- package/dist/canvas/index.cjs +336 -646
- package/dist/canvas/index.d.cts +1 -0
- package/dist/canvas/index.d.ts +1 -0
- package/dist/canvas/index.js +44 -354
- package/dist/canvas/playback.d.cts +14 -0
- package/dist/canvas/playback.d.ts +14 -0
- package/dist/chart/index.cjs +7 -7
- package/dist/chart/index.js +1 -1
- package/dist/chunk-6SFREX6H.cjs +406 -0
- package/dist/{chunk-XGOU44RJ.js → chunk-77SG47WT.js} +80 -9
- package/dist/{chunk-2SHFIVC3.js → chunk-DAS7M4RY.js} +1 -1
- package/dist/chunk-DW4CV5H4.js +591 -0
- package/dist/{chunk-UMS6YFA6.js → chunk-EAQ4BGNS.js} +1 -1
- package/dist/{chunk-AGCD3EHB.cjs → chunk-ENIZYNEF.cjs} +7 -7
- package/dist/{chunk-VSR5A22L.cjs → chunk-H6FX45CP.cjs} +35 -35
- package/dist/{chunk-RCUX6CT2.cjs → chunk-HRI3ZMDM.cjs} +110 -39
- package/dist/chunk-MFFE55CS.js +406 -0
- package/dist/{chunk-BSGPXPTW.js → chunk-PEEP2YR7.js} +1 -1
- package/dist/{chunk-RB62U6MS.js → chunk-RFBFTLVN.js} +27 -5
- package/dist/chunk-UBRYHNRU.cjs +591 -0
- package/dist/{chunk-GEY73RUW.cjs → chunk-UJGAA6AK.cjs} +1 -1
- package/dist/{chunk-6UZCFD7Y.js → chunk-VM6JYWXQ.js} +1 -1
- package/dist/{chunk-O3ZU6QIZ.cjs → chunk-XNZWATSB.cjs} +81 -81
- package/dist/{chunk-HDK3T2QS.cjs → chunk-Y4BWZB6J.cjs} +29 -7
- package/dist/commands/index.cjs +37 -1
- package/dist/commands/index.js +36 -0
- package/dist/commands/registry.d.cts +11 -0
- package/dist/commands/registry.d.ts +11 -0
- package/dist/diagram/index.cjs +7 -7
- package/dist/diagram/index.js +1 -1
- package/dist/image-editor/index.cjs +720 -628
- package/dist/image-editor/index.d.cts +1 -0
- package/dist/image-editor/index.d.ts +1 -0
- package/dist/image-editor/index.js +109 -17
- package/dist/image-editor/playback.d.cts +22 -0
- package/dist/image-editor/playback.d.ts +22 -0
- package/dist/paint-editor/index.cjs +13 -13
- package/dist/paint-editor/index.js +3 -3
- package/dist/tools/index.cjs +33 -3
- package/dist/tools/index.d.cts +2 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +32 -2
- package/dist/tools/playback.d.cts +205 -0
- package/dist/tools/playback.d.ts +205 -0
- package/dist/tools/presence.d.cts +82 -0
- package/dist/tools/presence.d.ts +82 -0
- package/dist/tools/registry.d.cts +45 -6
- package/dist/tools/registry.d.ts +45 -6
- package/dist/tools/view.d.cts +2 -4
- package/dist/tools/view.d.ts +2 -4
- package/dist/vector/index.cjs +1159 -1042
- package/dist/vector/index.d.cts +1 -0
- package/dist/vector/index.d.ts +1 -0
- package/dist/vector/index.js +142 -25
- package/dist/vector/playback.d.cts +13 -0
- package/dist/vector/playback.d.ts +13 -0
- package/package.json +1 -1
- package/skills/pixerate-agent-tools/SKILL.md +13 -0
- package/skills/pixerate-canvas/SKILL.md +3 -0
- package/skills/pixerate-image-editor/SKILL.md +2 -2
- package/skills/pixerate-vector/SKILL.md +5 -0
- package/dist/chunk-BTZS3KZY.js +0 -221
- package/dist/chunk-MRD3NXKR.cjs +0 -221
- /package/dist/{chunk-K73HMKQP.js → chunk-PLKIYNJZ.js} +0 -0
- /package/dist/{chunk-LACYURUW.cjs → chunk-TNCWKC5M.cjs} +0 -0
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunkHRI3ZMDMcjs = require('./chunk-HRI3ZMDM.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 = _chunkHRI3ZMDMcjs.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 = _chunkHRI3ZMDMcjs.IDENTITY_MATRIX, closed = c.closed) {
|
|
71
|
+
const pts = _chunkHRI3ZMDMcjs.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 = _chunkRCUX6CT2cjs.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 = _chunkHRI3ZMDMcjs.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 = _chunkHRI3ZMDMcjs.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 = _chunkHRI3ZMDMcjs.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 = _chunkHRI3ZMDMcjs.sortedVectorGradientStops.call(void 0, a);
|
|
471
|
+
let stopsB = _chunkHRI3ZMDMcjs.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 = [..._chunkHRI3ZMDMcjs.expandVectorGradientStops.call(void 0, a), ..._chunkHRI3ZMDMcjs.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 = _chunkHRI3ZMDMcjs.hasExplicitGradientGeometry.call(void 0, a);
|
|
502
|
+
const eb = _chunkHRI3ZMDMcjs.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 = _chunkHRI3ZMDMcjs.vectorGradientPoints.call(void 0, a);
|
|
516
|
+
const pb = _chunkHRI3ZMDMcjs.vectorGradientPoints.call(void 0, b);
|
|
517
517
|
if (pa.units !== pb.units) {
|
|
518
|
-
const src =
|
|
518
|
+
const src = _chunkHRI3ZMDMcjs.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 = _chunkHRI3ZMDMcjs.hasPaint.call(void 0, a);
|
|
539
|
+
const pb = _chunkHRI3ZMDMcjs.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 && _chunkHRI3ZMDMcjs.isVectorGradient.call(void 0, a) ? a : null;
|
|
545
|
+
const gb = pb && _chunkHRI3ZMDMcjs.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 = _chunkHRI3ZMDMcjs.widthProfileAt.call(void 0, a, pos);
|
|
557
|
+
const y = _chunkHRI3ZMDMcjs.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 = _chunkHRI3ZMDMcjs.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 _chunkHRI3ZMDMcjs.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 = _chunkHRI3ZMDMcjs.nodeMatrix.call(void 0, a), mb = _chunkHRI3ZMDMcjs.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 = !_chunkHRI3ZMDMcjs.isIdentityMatrix.call(void 0, ma) || !_chunkHRI3ZMDMcjs.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) : _chunkHRI3ZMDMcjs.IDENTITY_MATRIX;
|
|
638
|
+
const back = rigid ? _chunkHRI3ZMDMcjs.invertMatrix.call(void 0, m) : _chunkHRI3ZMDMcjs.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 = _chunkRCUX6CT2cjs.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 && !_chunkHRI3ZMDMcjs.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 = _chunkHRI3ZMDMcjs.IDENTITY_MATRIX) {
|
|
651
|
+
const m = _chunkHRI3ZMDMcjs.multiplyMatrices.call(void 0, _chunkHRI3ZMDMcjs.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(_chunkHRI3ZMDMcjs.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 = _chunkHRI3ZMDMcjs.unionBounds.call(void 0, pa.map((e) => placedBounds(e.path, e.m)));
|
|
676
|
+
const bb = _chunkHRI3ZMDMcjs.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, _chunkHRI3ZMDMcjs.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, _chunkHRI3ZMDMcjs.IDENTITY_MATRIX, y.m));
|
|
692
692
|
opacities.push([y.opacity, y.opacity]);
|
|
693
693
|
}
|
|
694
694
|
}
|
|
@@ -8714,7 +8714,66 @@ function vectorDocumentToSvg(doc, options = {}) {
|
|
|
8714
8714
|
return out.join(nl);
|
|
8715
8715
|
}
|
|
8716
8716
|
var BOOLEAN_OPERATIONS = ["union", "subtract", "intersect", "exclude"];
|
|
8717
|
-
var TEXT_CONTENT = /* @__PURE__ */ new Set(["text", "tspan", "textPath"]);
|
|
8717
|
+
var TEXT_CONTENT = /* @__PURE__ */ new Set(["text", "tspan", "textPath", "style"]);
|
|
8718
|
+
function parseCssRules(cssText) {
|
|
8719
|
+
const rules = [];
|
|
8720
|
+
const clean2 = cssText.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
8721
|
+
const re = /([^{]+)\{([^}]+)\}/g;
|
|
8722
|
+
let m;
|
|
8723
|
+
while (m = re.exec(clean2)) {
|
|
8724
|
+
const selector = m[1].trim();
|
|
8725
|
+
const body = m[2].trim();
|
|
8726
|
+
const properties = {};
|
|
8727
|
+
for (const decl of body.split(";")) {
|
|
8728
|
+
const i = decl.indexOf(":");
|
|
8729
|
+
if (i > 0) {
|
|
8730
|
+
const prop = decl.slice(0, i).trim().toLowerCase();
|
|
8731
|
+
const val = decl.slice(i + 1).replace(/!important/gi, "").trim();
|
|
8732
|
+
if (prop && val) properties[prop] = val;
|
|
8733
|
+
}
|
|
8734
|
+
}
|
|
8735
|
+
if (Object.keys(properties).length > 0) {
|
|
8736
|
+
rules.push({ selector, properties });
|
|
8737
|
+
}
|
|
8738
|
+
}
|
|
8739
|
+
return rules;
|
|
8740
|
+
}
|
|
8741
|
+
function collectStyleRules(el, rules) {
|
|
8742
|
+
if (el.name === "style") {
|
|
8743
|
+
const rawText = (_nullishCoalesce(el.content, () => ( []))).map((c) => typeof c === "string" ? c : "").join("");
|
|
8744
|
+
rules.push(...parseCssRules(rawText));
|
|
8745
|
+
}
|
|
8746
|
+
for (const child of el.children) {
|
|
8747
|
+
collectStyleRules(child, rules);
|
|
8748
|
+
}
|
|
8749
|
+
}
|
|
8750
|
+
function matchesSelector(el, selector) {
|
|
8751
|
+
const sel = selector.trim();
|
|
8752
|
+
if (!sel) return false;
|
|
8753
|
+
if (sel.includes(",")) {
|
|
8754
|
+
return sel.split(",").some((s) => matchesSelector(el, s));
|
|
8755
|
+
}
|
|
8756
|
+
if (sel.startsWith(".")) {
|
|
8757
|
+
const targetClass = sel.slice(1).trim();
|
|
8758
|
+
const classes = (_nullishCoalesce(el.attrs.class, () => ( ""))).split(/\s+/);
|
|
8759
|
+
return classes.includes(targetClass);
|
|
8760
|
+
}
|
|
8761
|
+
if (sel.startsWith("#")) {
|
|
8762
|
+
const targetId = sel.slice(1).trim();
|
|
8763
|
+
return el.attrs.id === targetId;
|
|
8764
|
+
}
|
|
8765
|
+
if (/^[a-zA-Z_][\w:.-]*$/.test(sel)) {
|
|
8766
|
+
return el.name.toLowerCase() === sel.toLowerCase();
|
|
8767
|
+
}
|
|
8768
|
+
const match = /^([a-zA-Z_][\w:.-]*)\.([a-zA-Z0-9_-]+)$/.exec(sel);
|
|
8769
|
+
if (match) {
|
|
8770
|
+
const [, tag, cls] = match;
|
|
8771
|
+
if (el.name.toLowerCase() !== tag.toLowerCase()) return false;
|
|
8772
|
+
const classes = (_nullishCoalesce(el.attrs.class, () => ( ""))).split(/\s+/);
|
|
8773
|
+
return classes.includes(cls);
|
|
8774
|
+
}
|
|
8775
|
+
return false;
|
|
8776
|
+
}
|
|
8718
8777
|
function parseXml(source) {
|
|
8719
8778
|
const text = source.replace(/<!--[\s\S]*?-->/g, "").replace(/<\?[\s\S]*?\?>/g, "").replace(/<!\[CDATA\[[\s\S]*?\]\]>/g, "").replace(/<!DOCTYPE[^>[]*(\[[\s\S]*?\])?\s*>/gi, "");
|
|
8720
8779
|
const root = { name: "#root", attrs: {}, children: [] };
|
|
@@ -8811,10 +8870,20 @@ var STYLE_KEYS = {
|
|
|
8811
8870
|
"mix-blend-mode": "mixBlendMode",
|
|
8812
8871
|
filter: "filter"
|
|
8813
8872
|
};
|
|
8814
|
-
function readStyle(el, parent) {
|
|
8873
|
+
function readStyle(el, parent, cssRules) {
|
|
8815
8874
|
const { mixBlendMode: _m, filter: _f, ...inherited } = parent;
|
|
8816
8875
|
const out = { ...inherited };
|
|
8817
8876
|
for (const [attr, key] of Object.entries(STYLE_KEYS)) if (el.attrs[attr] !== void 0) out[key] = el.attrs[attr].trim();
|
|
8877
|
+
if (_optionalChain([cssRules, 'optionalAccess', _245 => _245.length])) {
|
|
8878
|
+
for (const rule of cssRules) {
|
|
8879
|
+
if (matchesSelector(el, rule.selector)) {
|
|
8880
|
+
for (const [prop, val] of Object.entries(rule.properties)) {
|
|
8881
|
+
const key = STYLE_KEYS[prop];
|
|
8882
|
+
if (key) out[key] = val;
|
|
8883
|
+
}
|
|
8884
|
+
}
|
|
8885
|
+
}
|
|
8886
|
+
}
|
|
8818
8887
|
for (const decl of (_nullishCoalesce(el.attrs.style, () => ( ""))).split(";")) {
|
|
8819
8888
|
const i = decl.indexOf(":");
|
|
8820
8889
|
if (i < 0) continue;
|
|
@@ -8861,7 +8930,7 @@ function attrOrStyle(el, name) {
|
|
|
8861
8930
|
return el.attrs[name];
|
|
8862
8931
|
}
|
|
8863
8932
|
function urlId(value) {
|
|
8864
|
-
return _nullishCoalesce(_optionalChain([/^url\(\s*['"]?#([^'")\s]+)['"]?\s*\)/, 'access',
|
|
8933
|
+
return _nullishCoalesce(_optionalChain([/^url\(\s*['"]?#([^'")\s]+)['"]?\s*\)/, 'access', _246 => _246.exec, 'call', _247 => _247((_nullishCoalesce(value, () => ( ""))).trim()), 'optionalAccess', _248 => _248[1]]), () => ( null));
|
|
8865
8934
|
}
|
|
8866
8935
|
function clipRulesAsFillRules(el) {
|
|
8867
8936
|
const attrs = { ...el.attrs };
|
|
@@ -8926,9 +8995,9 @@ function resolveGradient(id, raw) {
|
|
|
8926
8995
|
for (let el = first; el && !chain.includes(el) && chain.length < 32; ) {
|
|
8927
8996
|
chain.push(el);
|
|
8928
8997
|
const href = _nullishCoalesce(el.attrs.href, () => ( el.attrs["xlink:href"]));
|
|
8929
|
-
el = _optionalChain([href, 'optionalAccess',
|
|
8998
|
+
el = _optionalChain([href, 'optionalAccess', _249 => _249.startsWith, 'call', _250 => _250("#")]) ? raw.get(href.slice(1)) : void 0;
|
|
8930
8999
|
}
|
|
8931
|
-
const attr = (name) => _optionalChain([chain, 'access',
|
|
9000
|
+
const attr = (name) => _optionalChain([chain, 'access', _251 => _251.find, 'call', _252 => _252((el) => el.attrs[name] !== void 0), 'optionalAccess', _253 => _253.attrs, 'access', _254 => _254[name]]);
|
|
8932
9001
|
const stops = _nullishCoalesce(chain.map(readStops).find((s) => s.length), () => ( []));
|
|
8933
9002
|
if (!stops.length) return null;
|
|
8934
9003
|
const user = attr("gradientUnits") === "userSpaceOnUse";
|
|
@@ -9003,6 +9072,8 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9003
9072
|
usedIds.add(next);
|
|
9004
9073
|
return next;
|
|
9005
9074
|
};
|
|
9075
|
+
const styleRules = [];
|
|
9076
|
+
collectStyleRules(root, styleRules);
|
|
9006
9077
|
const rawGradients = /* @__PURE__ */ new Map();
|
|
9007
9078
|
collectGradients(root, rawGradients);
|
|
9008
9079
|
const rawFilters = /* @__PURE__ */ new Map();
|
|
@@ -9098,7 +9169,7 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9098
9169
|
const stackedPath = (g, _style, m, meta) => {
|
|
9099
9170
|
const fillEl = g.children.find((c) => c.name === "path" && c.attrs["data-vector-part"] === "fill");
|
|
9100
9171
|
const subpaths = fillEl ? shapeOf(fillEl) : null;
|
|
9101
|
-
if (!_optionalChain([subpaths, 'optionalAccess',
|
|
9172
|
+
if (!_optionalChain([subpaths, 'optionalAccess', _255 => _255.length])) return null;
|
|
9102
9173
|
const parse = (v2) => {
|
|
9103
9174
|
try {
|
|
9104
9175
|
return v2 ? JSON.parse(v2) : [];
|
|
@@ -9117,7 +9188,7 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9117
9188
|
const key = (n) => JSON.stringify([n.subpaths, _nullishCoalesce(n.transform, () => ( null)), _nullishCoalesce(n.opacity, () => ( 1)), n.visible !== false, _nullishCoalesce(n.filters, () => ( null)), _nullishCoalesce(n.blendMode, () => ( "normal")), _nullishCoalesce(n.fillRule, () => ( "nonzero")), _nullishCoalesce(n.booleanOperation, () => ( null))]);
|
|
9118
9189
|
for (const n of nodes2) {
|
|
9119
9190
|
const prev = out[out.length - 1];
|
|
9120
|
-
if (_optionalChain([prev, 'optionalAccess',
|
|
9191
|
+
if (_optionalChain([prev, 'optionalAccess', _256 => _256.type]) === "path" && n.type === "path" && key(prev) === key(n)) {
|
|
9121
9192
|
const fills = vectorFills(n);
|
|
9122
9193
|
const strokesBefore = vectorStrokes(prev);
|
|
9123
9194
|
if (!(fills.length && strokesBefore.length)) {
|
|
@@ -9135,9 +9206,9 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9135
9206
|
const part = (name) => g.children.find((c) => c.name === "path" && c.attrs["data-vector-part"] === name);
|
|
9136
9207
|
const fillEl = part("fill");
|
|
9137
9208
|
const subpaths = fillEl ? shapeOf(fillEl) : null;
|
|
9138
|
-
if (!fillEl || !_optionalChain([subpaths, 'optionalAccess',
|
|
9209
|
+
if (!fillEl || !_optionalChain([subpaths, 'optionalAccess', _257 => _257.length])) return null;
|
|
9139
9210
|
const a = g.attrs;
|
|
9140
|
-
const fs = readStyle(fillEl, style);
|
|
9211
|
+
const fs = readStyle(fillEl, style, styleRules);
|
|
9141
9212
|
const strokeEl = part("stroke");
|
|
9142
9213
|
const outlineEl = part("stroke-outline");
|
|
9143
9214
|
const ss = strokeEl ? readStyle(strokeEl, style) : null;
|
|
@@ -9159,7 +9230,7 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9159
9230
|
...meta,
|
|
9160
9231
|
subpaths,
|
|
9161
9232
|
fill: paint(fs.fill),
|
|
9162
|
-
stroke: ss ? paint(ss.stroke) : outlineEl ? paint(readStyle(outlineEl, style).fill) : null,
|
|
9233
|
+
stroke: ss ? paint(ss.stroke) : outlineEl ? paint(readStyle(outlineEl, style, styleRules).fill) : null,
|
|
9163
9234
|
...ss ? strokeStyle(ss) : {},
|
|
9164
9235
|
...fs.fillRule === "evenodd" ? { fillRule: "evenodd" } : {},
|
|
9165
9236
|
strokeWidth: width2,
|
|
@@ -9172,7 +9243,7 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9172
9243
|
...profile.length ? { strokeWidthProfile: profile } : {},
|
|
9173
9244
|
...keptCap ? { strokeLinecap: keptCap } : {},
|
|
9174
9245
|
...keptJoin ? { strokeLinejoin: keptJoin } : {},
|
|
9175
|
-
..._optionalChain([keptDash, 'optionalAccess',
|
|
9246
|
+
..._optionalChain([keptDash, 'optionalAccess', _258 => _258.length]) ? { strokeDasharray: keptDash } : {}
|
|
9176
9247
|
};
|
|
9177
9248
|
return placed(node, m);
|
|
9178
9249
|
};
|
|
@@ -9237,8 +9308,8 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9237
9308
|
} else {
|
|
9238
9309
|
const fill = json2(g.attrs["data-vector-fill"]);
|
|
9239
9310
|
const stroke = json2(g.attrs["data-vector-stroke"]);
|
|
9240
|
-
node.fill = fill == null ? null : _nullishCoalesce(_optionalChain([sanitizeVectorFills, 'call',
|
|
9241
|
-
node.stroke = stroke == null ? null : _nullishCoalesce(_optionalChain([sanitizeVectorFills, 'call',
|
|
9311
|
+
node.fill = fill == null ? null : _nullishCoalesce(_optionalChain([sanitizeVectorFills, 'call', _259 => _259([{ paint: fill }]), 'access', _260 => _260[0], 'optionalAccess', _261 => _261.paint]), () => ( null));
|
|
9312
|
+
node.stroke = stroke == null ? null : _nullishCoalesce(_optionalChain([sanitizeVectorFills, 'call', _262 => _262([{ paint: stroke }]), 'access', _263 => _263[0], 'optionalAccess', _264 => _264.paint]), () => ( null));
|
|
9242
9313
|
const settings = json2(g.attrs["data-vector-stroke-settings"]);
|
|
9243
9314
|
if (settings && typeof settings === "object") {
|
|
9244
9315
|
const strokes = sanitizeVectorStrokes([{ paint: _nullishCoalesce(node.stroke, () => ( "#000")), ...settings }]);
|
|
@@ -9274,8 +9345,8 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9274
9345
|
const anchor = attrOrStyle(el, "text-anchor");
|
|
9275
9346
|
const first0 = (v2) => _nullishCoalesce(numberList(v2)[0], () => ( 0));
|
|
9276
9347
|
const tspan = el.children.find((c) => c.name === "tspan");
|
|
9277
|
-
const x = el.attrs.x !== void 0 ? first0(el.attrs.x) : first0(_optionalChain([tspan, 'optionalAccess',
|
|
9278
|
-
const y = el.attrs.y !== void 0 ? first0(el.attrs.y) : first0(_optionalChain([tspan, 'optionalAccess',
|
|
9348
|
+
const x = el.attrs.x !== void 0 ? first0(el.attrs.x) : first0(_optionalChain([tspan, 'optionalAccess', _265 => _265.attrs, 'access', _266 => _266.x]));
|
|
9349
|
+
const y = el.attrs.y !== void 0 ? first0(el.attrs.y) : first0(_optionalChain([tspan, 'optionalAccess', _267 => _267.attrs, 'access', _268 => _268.y]));
|
|
9279
9350
|
const fillValue = _nullishCoalesce(attrOrStyle(el, "fill"), () => ( style.fill));
|
|
9280
9351
|
let node = {
|
|
9281
9352
|
id: idFor(el),
|
|
@@ -9306,12 +9377,12 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9306
9377
|
if (symbolOfElement.has(el)) return symbolOfElement.get(el);
|
|
9307
9378
|
symbolOfElement.set(el, null);
|
|
9308
9379
|
const own = json2(el.attrs["data-vector-symbol"]);
|
|
9309
|
-
let id = typeof _optionalChain([own, 'optionalAccess',
|
|
9380
|
+
let id = typeof _optionalChain([own, 'optionalAccess', _269 => _269.id]) === "string" && own.id ? own.id : _nullishCoalesce(el.attrs.id, () => ( createId()));
|
|
9310
9381
|
while (usedSymbolIds.has(id)) id = `${id}-${usedSymbolIds.size}`;
|
|
9311
9382
|
usedSymbolIds.add(id);
|
|
9312
|
-
const style = readStyle(el, rootStyle);
|
|
9383
|
+
const style = readStyle(el, rootStyle, styleRules);
|
|
9313
9384
|
const nodes2 = el.name === "symbol" ? visit2(el, style, IDENTITY_MATRIX) : visitOne({ ...el, attrs: { ...el.attrs, transform: "" } }, rootStyle, parseSvgTransform(el.attrs.transform));
|
|
9314
|
-
symbols.push({ id, name: typeof _optionalChain([own, 'optionalAccess',
|
|
9385
|
+
symbols.push({ id, name: typeof _optionalChain([own, 'optionalAccess', _270 => _270.name]) === "string" && own.name ? own.name : _nullishCoalesce(el.attrs.id, () => ( "Symbol")), nodes: nodes2 });
|
|
9315
9386
|
symbolOfElement.set(el, id);
|
|
9316
9387
|
return id;
|
|
9317
9388
|
};
|
|
@@ -9323,13 +9394,13 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9323
9394
|
if (!symbolId) return null;
|
|
9324
9395
|
const own = json2(el.attrs["data-vector-instance"]);
|
|
9325
9396
|
const place2 = multiplyMatrices(translateMatrix(length(el.attrs.x), length(el.attrs.y)), m);
|
|
9326
|
-
const node = { id: idFor(el), type: "instance", ...meta, symbolId, ..._optionalChain([own, 'optionalAccess',
|
|
9397
|
+
const node = { id: idFor(el), type: "instance", ...meta, symbolId, ..._optionalChain([own, 'optionalAccess', _271 => _271.scaleStrokes]) === false ? { scaleStrokes: false } : {}, ..._optionalChain([own, 'optionalAccess', _272 => _272.overrides]) ? { overrides: own.overrides } : {} };
|
|
9327
9398
|
return isIdentityMatrix(place2) ? node : { ...node, transform: place2 };
|
|
9328
9399
|
};
|
|
9329
9400
|
const ownInstance = (g, m, meta) => {
|
|
9330
9401
|
const raw = json2(g.attrs["data-vector-instance"]);
|
|
9331
9402
|
if (!raw || typeof raw.symbolId !== "string") return null;
|
|
9332
|
-
const sym2 = [...byId.values()].find((e) => e.name === "symbol" && _optionalChain([json2, 'call',
|
|
9403
|
+
const sym2 = [...byId.values()].find((e) => e.name === "symbol" && _optionalChain([json2, 'call', _273 => _273(e.attrs["data-vector-symbol"]), 'optionalAccess', _274 => _274.id]) === raw.symbolId);
|
|
9333
9404
|
const symbolId = sym2 ? symbolFor(sym2) : raw.symbolId;
|
|
9334
9405
|
if (!symbolId) return null;
|
|
9335
9406
|
const t = Array.isArray(raw.transform) && raw.transform.length === 6 && raw.transform.every(Number.isFinite) ? raw.transform : IDENTITY_MATRIX;
|
|
@@ -9337,7 +9408,7 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9337
9408
|
const drawn = g.children.find((c) => c.name === "g");
|
|
9338
9409
|
const effects = sanitizeVectorEffects(raw.effects);
|
|
9339
9410
|
const node = {
|
|
9340
|
-
id: _nullishCoalesce(_optionalChain([drawn, 'optionalAccess',
|
|
9411
|
+
id: _nullishCoalesce(_optionalChain([drawn, 'optionalAccess', _275 => _275.attrs, 'access', _276 => _276.id]), () => ( idFor(g))),
|
|
9341
9412
|
type: "instance",
|
|
9342
9413
|
...meta,
|
|
9343
9414
|
symbolId,
|
|
@@ -9346,7 +9417,7 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9346
9417
|
...effects.length ? { effects } : {}
|
|
9347
9418
|
};
|
|
9348
9419
|
if (drawn) {
|
|
9349
|
-
const ds = readStyle(drawn, rootStyle);
|
|
9420
|
+
const ds = readStyle(drawn, rootStyle, styleRules);
|
|
9350
9421
|
const op = drawn.attrs.opacity !== void 0 ? parseFloat(drawn.attrs.opacity) : void 0;
|
|
9351
9422
|
if (op !== void 0 && Number.isFinite(op) && op < 1) node.opacity = op;
|
|
9352
9423
|
const blend = vectorBlendModeFromCss(ds.mixBlendMode);
|
|
@@ -9384,7 +9455,7 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9384
9455
|
resolving.add(id);
|
|
9385
9456
|
const isClip = el.name === "clipPath";
|
|
9386
9457
|
const content = isClip ? clipRulesAsFillRules(el) : el;
|
|
9387
|
-
const inner = visit2(content, readStyle(content, rootStyle), multiplyMatrices(parseSvgTransform(el.attrs.transform), space));
|
|
9458
|
+
const inner = visit2(content, readStyle(content, rootStyle, styleRules), multiplyMatrices(parseSvgTransform(el.attrs.transform), space));
|
|
9388
9459
|
resolving.delete(id);
|
|
9389
9460
|
const strip2 = (n) => n.type !== "group" ? withVectorStrokes(withVectorFills({ ...n, fill: null, stroke: null }, []), []) : { ...n, children: n.children.map(strip2) };
|
|
9390
9461
|
const list = isClip ? inner.map(strip2) : inner;
|
|
@@ -9394,12 +9465,12 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9394
9465
|
const masked = (el, nodes2, m) => {
|
|
9395
9466
|
let out = nodes2;
|
|
9396
9467
|
const clipEl = rawMasks.get(_nullishCoalesce(urlId(attrOrStyle(el, "clip-path")), () => ( "")));
|
|
9397
|
-
if (_optionalChain([clipEl, 'optionalAccess',
|
|
9468
|
+
if (_optionalChain([clipEl, 'optionalAccess', _277 => _277.name]) === "clipPath") {
|
|
9398
9469
|
const source = maskNode(clipEl, m, out, clipEl.attrs.clipPathUnits);
|
|
9399
9470
|
if (source) out = [{ id: idFor({ name: "g", attrs: {}, children: [] }), type: "group", name: "Clip Group", mask: { type: "clip" }, children: [source, ...out] }];
|
|
9400
9471
|
}
|
|
9401
9472
|
const maskEl = rawMasks.get(_nullishCoalesce(urlId(attrOrStyle(el, "mask")), () => ( "")));
|
|
9402
|
-
if (_optionalChain([maskEl, 'optionalAccess',
|
|
9473
|
+
if (_optionalChain([maskEl, 'optionalAccess', _278 => _278.name]) === "mask") {
|
|
9403
9474
|
const source = maskNode(maskEl, m, out, maskEl.attrs.maskContentUnits);
|
|
9404
9475
|
const type = attrOrStyle(maskEl, "mask-type") === "alpha" ? "alpha" : "luminance";
|
|
9405
9476
|
if (source) out = [{ id: idFor({ name: "g", attrs: {}, children: [] }), type: "group", name: "Opacity Mask", mask: { type }, children: [source, ...out] }];
|
|
@@ -9421,19 +9492,19 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9421
9492
|
let sourceEl = part("mask-source");
|
|
9422
9493
|
if (!sourceEl) {
|
|
9423
9494
|
const el = rawMasks.get(_nullishCoalesce(urlId(maskedEl.attrs.mask), () => ( "")));
|
|
9424
|
-
const invert2 = _optionalChain([el, 'optionalAccess',
|
|
9495
|
+
const invert2 = _optionalChain([el, 'optionalAccess', _279 => _279.children, 'access', _280 => _280.find, 'call', _281 => _281((c) => c.name === "g" && c.attrs["data-vector-part"] === "mask-invert")]);
|
|
9425
9496
|
sourceEl = _nullishCoalesce(invert2, () => ( el));
|
|
9426
9497
|
}
|
|
9427
9498
|
const source = sourceEl ? visit2(sourceEl, style, m)[0] : void 0;
|
|
9428
9499
|
let contents = visit2(maskedEl, style, m);
|
|
9429
9500
|
let effects;
|
|
9430
9501
|
const wrapper = contents.length === 1 && contents[0].type === "group" && contents[0].id === `${id}~content` ? contents[0] : null;
|
|
9431
|
-
if (_optionalChain([wrapper, 'optionalAccess',
|
|
9502
|
+
if (_optionalChain([wrapper, 'optionalAccess', _282 => _282.type]) === "group") {
|
|
9432
9503
|
effects = _nullishCoalesce(wrapper.effects, () => ( void 0));
|
|
9433
9504
|
contents = wrapper.children;
|
|
9434
9505
|
}
|
|
9435
9506
|
if (!source) return contents.length ? { id, type: "group", ...meta, children: contents } : null;
|
|
9436
|
-
return { id, type: "group", ...meta, mask, ..._optionalChain([effects, 'optionalAccess',
|
|
9507
|
+
return { id, type: "group", ...meta, mask, ..._optionalChain([effects, 'optionalAccess', _283 => _283.length]) ? { effects } : {}, children: [source, ...contents] };
|
|
9437
9508
|
};
|
|
9438
9509
|
const frameGroup = (g, style, m, meta) => {
|
|
9439
9510
|
const raw = parseJson(g.attrs["data-vector-frame"]);
|
|
@@ -9445,7 +9516,7 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9445
9516
|
const { rigid, residual } = decomposeRigid(m);
|
|
9446
9517
|
const r = _chunkGF2RBSDMcjs.bezierPathBounds.call(void 0, _chunkGF2RBSDMcjs.transformBezierPath.call(void 0, subpathsToBezier(vectorFrameRectPath(frame)), residual));
|
|
9447
9518
|
const back = invertMatrix(rigid);
|
|
9448
|
-
const effects = sanitizeVectorEffects(_optionalChain([raw, 'optionalAccess',
|
|
9519
|
+
const effects = sanitizeVectorEffects(_optionalChain([raw, 'optionalAccess', _284 => _284.effects]));
|
|
9449
9520
|
return {
|
|
9450
9521
|
id,
|
|
9451
9522
|
type: "group",
|
|
@@ -9460,7 +9531,7 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9460
9531
|
const visitOne = (child, style, matrix) => {
|
|
9461
9532
|
const out = [];
|
|
9462
9533
|
const m = multiplyMatrices(parseSvgTransform(child.attrs.transform), matrix);
|
|
9463
|
-
const s = readStyle(child, style);
|
|
9534
|
+
const s = readStyle(child, style, styleRules);
|
|
9464
9535
|
const opacity = child.attrs.opacity !== void 0 ? parseFloat(child.attrs.opacity) : void 0;
|
|
9465
9536
|
const hidden = child.attrs.display === "none" || child.attrs.visibility === "hidden";
|
|
9466
9537
|
const blendMode = vectorBlendModeFromCss(s.mixBlendMode);
|
|
@@ -9561,7 +9632,7 @@ function parseVectorSvg(svg, options = {}) {
|
|
|
9561
9632
|
out.push(node);
|
|
9562
9633
|
return out;
|
|
9563
9634
|
};
|
|
9564
|
-
rootStyle = readStyle(root, rootStyle);
|
|
9635
|
+
rootStyle = readStyle(root, rootStyle, styleRules);
|
|
9565
9636
|
const walkAll = (el) => {
|
|
9566
9637
|
if (el.name === "symbol" && el.attrs["data-vector-symbol"] !== void 0) symbolFor(el);
|
|
9567
9638
|
el.children.forEach(walkAll);
|
|
@@ -9917,13 +9988,13 @@ function hitTestVectorNode(node, p, tolerance = 0, parent = IDENTITY_MATRIX, opt
|
|
|
9917
9988
|
}
|
|
9918
9989
|
if (isVectorMaskGroup(node)) {
|
|
9919
9990
|
const m = multiplyMatrices(nodeMatrix(node), parent);
|
|
9920
|
-
const entered = !!_optionalChain([options, 'access',
|
|
9991
|
+
const entered = !!_optionalChain([options, 'access', _285 => _285.entered, 'optionalAccess', _286 => _286.has, 'call', _287 => _287(node.id)]);
|
|
9921
9992
|
if (!entered && isVectorMaskActive(node) && !vectorMaskContains(node, applyMatrix(invertMatrix(m), p), tolerance)) return false;
|
|
9922
9993
|
const shown = !entered && hasOwnVectorAppearance(node) ? expandVectorAppearance(node).children : node.children;
|
|
9923
9994
|
for (let i = shown.length - 1; i >= 1; i--) if (hitTestVectorNode(shown[i], p, tolerance, m, options)) return true;
|
|
9924
9995
|
return entered && hitTestVectorMaskSource(node, p, tolerance, m, options);
|
|
9925
9996
|
}
|
|
9926
|
-
if (!(node.type === "group" && (!hasOwnVectorAppearance(node) || _optionalChain([options, 'access',
|
|
9997
|
+
if (!(node.type === "group" && (!hasOwnVectorAppearance(node) || _optionalChain([options, 'access', _288 => _288.entered, 'optionalAccess', _289 => _289.has, 'call', _290 => _290(node.id)])))) node = expandVectorAppearance(node);
|
|
9927
9998
|
if (node.type === "group") {
|
|
9928
9999
|
const m = multiplyMatrices(nodeMatrix(node), parent);
|
|
9929
10000
|
return node.children.some((c) => hitTestVectorNode(c, p, tolerance, m, options));
|
|
@@ -9935,7 +10006,7 @@ function hitTestVectorNode(node, p, tolerance = 0, parent = IDENTITY_MATRIX, opt
|
|
|
9935
10006
|
function hitTestVectorMaskSource(group, p, tolerance, m, options) {
|
|
9936
10007
|
const source = group.children[0];
|
|
9937
10008
|
if (source.visible === false) return false;
|
|
9938
|
-
if (_optionalChain([group, 'access',
|
|
10009
|
+
if (_optionalChain([group, 'access', _291 => _291.mask, 'optionalAccess', _292 => _292.type]) !== "clip") return hitTestVectorNode(source, p, tolerance, m, options);
|
|
9939
10010
|
const paths = collectPathNodes(source).filter((n) => n.visible !== false);
|
|
9940
10011
|
const pt2 = [p.x, p.y];
|
|
9941
10012
|
return paths.some((n) => {
|
|
@@ -9984,24 +10055,24 @@ function mapAnchor(a, m) {
|
|
|
9984
10055
|
}
|
|
9985
10056
|
function bakeIntoGeometry(node, m) {
|
|
9986
10057
|
if (isIdentityMatrix(m)) return node;
|
|
9987
|
-
if (_optionalChain([node, 'access',
|
|
10058
|
+
if (_optionalChain([node, 'access', _293 => _293.effects, 'optionalAccess', _294 => _294.length])) node = { ...node, effects: transformVectorEffects(node.effects, m, node) };
|
|
9988
10059
|
if (isVectorFrame(node)) return bakeFrame(node, m);
|
|
9989
10060
|
if (node.type === "group") {
|
|
9990
10061
|
const group = node;
|
|
9991
10062
|
const children = group.children.map((c) => transformVectorNode(c, m));
|
|
9992
10063
|
const sym2 = group.symmetry ? { symmetry: transformVectorSymmetry(group.symmetry, m) } : {};
|
|
9993
|
-
const spine = _optionalChain([group, 'access',
|
|
10064
|
+
const spine = _optionalChain([group, 'access', _295 => _295.blend, 'optionalAccess', _296 => _296.spine]);
|
|
9994
10065
|
if (!spine) return { ...group, ...sym2, children };
|
|
9995
10066
|
const moved = { closed: spine.closed, anchors: spine.anchors.map((a) => mapAnchor(a, m)) };
|
|
9996
10067
|
return { ...group, children, blend: { ...group.blend, spine: moved } };
|
|
9997
10068
|
}
|
|
9998
10069
|
const path = node.type === "text" ? bakeVectorTextGeometry(node, m) : node;
|
|
9999
10070
|
const flips = m[0] * m[3] - m[1] * m[2] < 0;
|
|
10000
|
-
const mirrored = flips && _optionalChain([path, 'access',
|
|
10071
|
+
const mirrored = flips && _optionalChain([path, 'access', _297 => _297.strokeWidthProfile, 'optionalAccess', _298 => _298.length]);
|
|
10001
10072
|
const layer = (l) => ({
|
|
10002
10073
|
...l,
|
|
10003
10074
|
...isVectorGradient(l.paint) || isVectorShadedPaint(l.paint) ? { paint: transformVectorPaint(l.paint, m) } : {},
|
|
10004
|
-
...flips && _optionalChain([l, 'access',
|
|
10075
|
+
...flips && _optionalChain([l, 'access', _299 => _299.strokeWidthProfile, 'optionalAccess', _300 => _300.length]) ? { strokeWidthProfile: mirrorWidthProfile(l.strokeWidthProfile) } : {}
|
|
10005
10076
|
});
|
|
10006
10077
|
return {
|
|
10007
10078
|
...path,
|
|
@@ -10236,7 +10307,7 @@ function roundSubpaths(subpaths, precision = 3) {
|
|
|
10236
10307
|
|
|
10237
10308
|
// src/vector/symmetry.ts
|
|
10238
10309
|
function isVectorSymmetryGroup(node) {
|
|
10239
|
-
return _optionalChain([node, 'optionalAccess',
|
|
10310
|
+
return _optionalChain([node, 'optionalAccess', _301 => _301.type]) === "group" && !!node.symmetry && !node.blend && !node.liveBoolean && !node.mask && !node.frame;
|
|
10240
10311
|
}
|
|
10241
10312
|
var rad = (deg) => deg * Math.PI / 180;
|
|
10242
10313
|
var exact = (v2) => Math.abs(v2) < 1e-12 ? 0 : v2;
|