@snowcone-app/canvas 0.40.22 → 0.40.24
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/{CanvasRenderer-BmLEU_Zb.js → CanvasRenderer-JcBrIZ6I.js} +454 -452
- package/dist/{CanvasRenderer-BmLEU_Zb.js.map → CanvasRenderer-JcBrIZ6I.js.map} +1 -1
- package/dist/{CanvasStateV1-DnpfA376.js → CanvasStateV1-BJ5-75NN.js} +3 -3
- package/dist/{CanvasStateV1-DnpfA376.js.map → CanvasStateV1-BJ5-75NN.js.map} +1 -1
- package/dist/{ContextualToolbars-DSJykxdc.js → ContextualToolbars-wmbHxn5a.js} +2058 -1991
- package/dist/{ContextualToolbars-DSJykxdc.js.map → ContextualToolbars-wmbHxn5a.js.map} +1 -1
- package/dist/{EditorCanvasImpl-t5MD0lMB.js → EditorCanvasImpl-CI_mLBGt.js} +8 -8
- package/dist/{EditorCanvasImpl-t5MD0lMB.js.map → EditorCanvasImpl-CI_mLBGt.js.map} +1 -1
- package/dist/{ExportManager-CnUTZrbv.js → ExportManager-CHlByUYV.js} +856 -839
- package/dist/ExportManager-CHlByUYV.js.map +1 -0
- package/dist/{FontAnalyzer-Bjtl4XTH.js → FontAnalyzer-Bj2KrX80.js} +1592 -1530
- package/dist/FontAnalyzer-Bj2KrX80.js.map +1 -0
- package/dist/{ImagePanel-AWQgzuXz.js → ImagePanel-0ZwDDaCy.js} +6 -6
- package/dist/{ImagePanel-AWQgzuXz.js.map → ImagePanel-0ZwDDaCy.js.map} +1 -1
- package/dist/{SnowconeCanvas-BWv3Sd5P.js → SnowconeCanvas-0w0-l9tm.js} +10 -10
- package/dist/{SnowconeCanvas-BWv3Sd5P.js.map → SnowconeCanvas-0w0-l9tm.js.map} +1 -1
- package/dist/advanced.mjs +39 -39
- package/dist/components/toolbars/SecondaryPanels.d.ts +3 -0
- package/dist/core/ImageElement.d.ts +20 -0
- package/dist/core/TextMetrics.d.ts +14 -2
- package/dist/core/masked-crop.d.ts +57 -0
- package/dist/{custom-icons-Bn8_I4kt.js → custom-icons-up58ZbC9.js} +2 -2
- package/dist/{custom-icons-Bn8_I4kt.js.map → custom-icons-up58ZbC9.js.map} +1 -1
- package/dist/{design-builder-B3v5OAQo.js → design-builder-DUEwCUmA.js} +396 -396
- package/dist/{design-builder-B3v5OAQo.js.map → design-builder-DUEwCUmA.js.map} +1 -1
- package/dist/{embed-D6-jVZMw.js → embed-VKMR6QO1.js} +10 -10
- package/dist/{embed-D6-jVZMw.js.map → embed-VKMR6QO1.js.map} +1 -1
- package/dist/embed.mjs +7 -7
- package/dist/{export-worker.bundle.string-DXciOLDt.js → export-worker.bundle.string-C6Zm9Wt-.js} +146 -27
- package/dist/{export-worker.bundle.string-DXciOLDt.js.map → export-worker.bundle.string-C6Zm9Wt-.js.map} +1 -1
- package/dist/{guards-B_Q3pewr.js → guards-CQeF53PN.js} +2 -2
- package/dist/{guards-B_Q3pewr.js.map → guards-CQeF53PN.js.map} +1 -1
- package/dist/index.mjs +9 -9
- package/dist/internals.mjs +6 -6
- package/dist/rendering/MaskRenderer.d.ts +13 -0
- package/dist/{template-fields-B4sJfQjP.js → template-fields-tobyHoMe.js} +5 -5
- package/dist/{template-fields-B4sJfQjP.js.map → template-fields-tobyHoMe.js.map} +1 -1
- package/dist/testing.mjs +3 -3
- package/dist/types/index.d.ts +10 -0
- package/dist/{useCommands-CZHeVauL.js → useCommands-Cm3mDB-l.js} +225 -225
- package/dist/{useCommands-CZHeVauL.js.map → useCommands-Cm3mDB-l.js.map} +1 -1
- package/dist/{usePieceGuideBundle-DsCv7HKy.js → usePieceGuideBundle-BTnUn33k.js} +2 -2
- package/dist/{usePieceGuideBundle-DsCv7HKy.js.map → usePieceGuideBundle-BTnUn33k.js.map} +1 -1
- package/dist/{validation-D9catdeB.js → validation-D4zxugNJ.js} +11 -11
- package/dist/{validation-D9catdeB.js.map → validation-D4zxugNJ.js.map} +1 -1
- package/dist/workers/export-worker.bundle.string.d.ts +1 -1
- package/example/package.json +1 -1
- package/package.json +3 -3
- package/dist/ExportManager-CnUTZrbv.js.map +0 -1
- package/dist/FontAnalyzer-Bjtl4XTH.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { c as j, G as
|
|
2
|
-
let
|
|
3
|
-
function
|
|
4
|
-
|
|
1
|
+
import { c as j, G as Yt, ag as Ve, x as Je, v as Ke, ak as Ee, aS as Vt, ai as Qe, af as x, s as ze, w as Ze, ah as at, aj as Jt, z as te, ax as De, al as xe, aT as J, aU as tr, b as er, aV as Tt, aW as rr, _ as Se, aX as Me, P as nr, S as or, I as At, F as sr, W as ar, f as ir, d as lr, L as cr, C as hr, g as fr, A as ee, $ as dr, a0 as ur, i as gr, t as Ce } from "./FontAnalyzer-Bj2KrX80.js";
|
|
2
|
+
let Pe = null;
|
|
3
|
+
function pr(e) {
|
|
4
|
+
Pe = e;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
return
|
|
6
|
+
function Jn() {
|
|
7
|
+
return Pe;
|
|
8
8
|
}
|
|
9
|
-
const
|
|
9
|
+
const mr = j("TextureManager"), lt = class lt {
|
|
10
10
|
/**
|
|
11
11
|
* Load a texture by ID or URL
|
|
12
12
|
*/
|
|
@@ -20,7 +20,7 @@ const dr = j("TextureManager"), lt = class lt {
|
|
|
20
20
|
s.crossOrigin = "anonymous", s.onload = () => {
|
|
21
21
|
this.cache.set(t, s), this.cache.set(r, s), this.loading.delete(t), this.loading.delete(r), o(s);
|
|
22
22
|
}, s.onerror = () => {
|
|
23
|
-
|
|
23
|
+
mr.error("Failed to load texture:", r), this.loading.delete(t), this.loading.delete(r), i(new Error(`Failed to load texture: ${r}`));
|
|
24
24
|
}, s.src = r;
|
|
25
25
|
});
|
|
26
26
|
return this.loading.set(t, n), r !== t && this.loading.set(r, n), n;
|
|
@@ -97,32 +97,32 @@ lt.cache = /* @__PURE__ */ new Map(), lt.loading = /* @__PURE__ */ new Map(), lt
|
|
|
97
97
|
}
|
|
98
98
|
];
|
|
99
99
|
let D = lt;
|
|
100
|
-
const
|
|
100
|
+
const yr = j("ElementPreviewRenderer"), wr = {
|
|
101
101
|
width: 40,
|
|
102
102
|
height: 40,
|
|
103
103
|
padding: 4,
|
|
104
104
|
backgroundColor: "transparent"
|
|
105
105
|
};
|
|
106
|
-
function
|
|
107
|
-
|
|
108
|
-
const r = { ...
|
|
106
|
+
function kr(e, t = {}) {
|
|
107
|
+
Qt();
|
|
108
|
+
const r = { ...wr, ...t }, n = document.createElement("canvas");
|
|
109
109
|
n.width = r.width, n.height = r.height;
|
|
110
110
|
const o = n.getContext("2d");
|
|
111
111
|
if (!o)
|
|
112
112
|
return "";
|
|
113
113
|
r.backgroundColor !== "transparent" && (o.fillStyle = r.backgroundColor, o.fillRect(0, 0, r.width, r.height)), o.save();
|
|
114
114
|
try {
|
|
115
|
-
e instanceof
|
|
115
|
+
e instanceof Yt ? Tr(o, e, r) : br(o, e, r);
|
|
116
116
|
} catch (i) {
|
|
117
|
-
|
|
117
|
+
yr.warn("Failed to generate preview:", i);
|
|
118
118
|
}
|
|
119
119
|
return o.restore(), n.toDataURL("image/png");
|
|
120
120
|
}
|
|
121
|
-
function
|
|
122
|
-
var
|
|
123
|
-
const n = ((
|
|
121
|
+
function br(e, t, r) {
|
|
122
|
+
var d;
|
|
123
|
+
const n = ((d = t.getBoundingBox) == null ? void 0 : d.call(t)) || { x: 0, y: 0, width: 100, height: 100 }, o = n.width, i = n.height;
|
|
124
124
|
if (o === 0 || i === 0) {
|
|
125
|
-
|
|
125
|
+
re(e, t, r);
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
128
|
const s = r.width - r.padding * 2, l = r.height - r.padding * 2, a = Math.min(
|
|
@@ -130,15 +130,15 @@ function mr(e, t, r) {
|
|
|
130
130
|
l / i,
|
|
131
131
|
1
|
|
132
132
|
// Don't scale up, only down
|
|
133
|
-
), c = o * a, h = i * a,
|
|
134
|
-
e.save(), e.translate(
|
|
133
|
+
), c = o * a, h = i * a, f = r.padding + (s - c) / 2, u = r.padding + (l - h) / 2;
|
|
134
|
+
e.save(), e.translate(f - n.x * a, u - n.y * a), e.scale(a, a), typeof t.render == "function" ? t.render(e, !1, !1) : re(e, t, r), e.restore();
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function re(e, t, r) {
|
|
137
137
|
e.fillStyle = "#888888", e.font = "10px Arial", e.textAlign = "center", e.textBaseline = "middle";
|
|
138
138
|
const n = t.transformType || "Element";
|
|
139
139
|
e.fillText(n, r.width / 2, r.height / 2);
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function Tr(e, t, r) {
|
|
142
142
|
const n = r.width - r.padding * 2, o = r.height - r.padding * 2, i = r.padding, s = r.padding;
|
|
143
143
|
e.fillStyle = "#888888", e.strokeStyle = "#666666", e.lineWidth = 1;
|
|
144
144
|
const l = o * 0.7, a = s + o * 0.3, c = n * 0.4, h = o * 0.2;
|
|
@@ -148,21 +148,21 @@ function yr(e, t, r) {
|
|
|
148
148
|
a + l / 2
|
|
149
149
|
));
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function Kn(e, t, r) {
|
|
152
152
|
var c;
|
|
153
153
|
e.translate(t.x || 0, t.y || 0), e.rotate(-(t.rotation || 0) * Math.PI / 180);
|
|
154
154
|
const n = t, o = n.fontSize || 24, i = n.fontFamily || "Arial", s = n.bold || !1, l = n.italic || !1;
|
|
155
|
-
e.font =
|
|
155
|
+
e.font = Ve(o, i, s, l);
|
|
156
156
|
const a = n.text || "";
|
|
157
157
|
if (t.transformType === "custom") {
|
|
158
|
-
const
|
|
159
|
-
e.rect(-
|
|
158
|
+
const f = ((c = t.transformData) == null ? void 0 : c.width) || 200, u = Je(a, o, i, s, l), d = Math.min(u, f), m = o * 1.2;
|
|
159
|
+
e.rect(-d / 2, -m / 2, d, m);
|
|
160
160
|
} else {
|
|
161
161
|
const h = e.measureText(a).width;
|
|
162
162
|
e.beginPath(), e.moveTo(-h / 2, 0), e.lineTo(h / 2, 0), e.moveTo(-h / 2, -o), e.lineTo(h / 2, -o), e.moveTo(-h / 2, o * 0.2), e.lineTo(h / 2, o * 0.2);
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function vr(e, t) {
|
|
166
166
|
if (!t.transformData) return;
|
|
167
167
|
const { borderRadius: r = 0 } = t.transformData, n = t.transformData.width ?? 100, o = t.transformData.height ?? 100;
|
|
168
168
|
if (e.translate(t.x || 0, t.y || 0), e.rotate(-(t.rotation || 0) * Math.PI / 180), e.beginPath(), r > 0) {
|
|
@@ -171,22 +171,22 @@ function wr(e, t) {
|
|
|
171
171
|
} else
|
|
172
172
|
e.rect(-n / 2, -o / 2, n, o);
|
|
173
173
|
}
|
|
174
|
-
function
|
|
174
|
+
function Qn(e, t, r, n) {
|
|
175
175
|
e.beginPath(), e.arc(t, r, n, 0, Math.PI * 2), e.closePath();
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function zn(e, t, r, n, o) {
|
|
178
178
|
e.beginPath(), e.rect(t, r, n, o), e.closePath();
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function Ie(e, t) {
|
|
181
181
|
e.strokeStyle = t.color, e.lineWidth = t.width, e.lineCap = t.lineCap || "butt", e.lineJoin = t.lineJoin || "miter", t.miterLimit !== void 0 && (e.miterLimit = t.miterLimit), t.dashArray && t.dashArray.length > 0 ? e.setLineDash(t.dashArray) : e.setLineDash([]), t.opacity !== void 0 && (e.globalAlpha = t.opacity);
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function Er(e, t) {
|
|
184
184
|
if (typeof OffscreenCanvas < "u")
|
|
185
185
|
return new OffscreenCanvas(e, t);
|
|
186
186
|
const r = document.createElement("canvas");
|
|
187
187
|
return r.width = e, r.height = t, r;
|
|
188
188
|
}
|
|
189
|
-
function
|
|
189
|
+
function Ae(e, t, r) {
|
|
190
190
|
var a;
|
|
191
191
|
if (!((a = t.stroke) != null && a.enabled)) return;
|
|
192
192
|
const n = t;
|
|
@@ -194,52 +194,52 @@ function Ie(e, t, r) {
|
|
|
194
194
|
const i = (r == null ? void 0 : r.isKnockout) === !0, s = t.stroke.opacity ?? 1;
|
|
195
195
|
if (!i && s < 1)
|
|
196
196
|
try {
|
|
197
|
-
|
|
197
|
+
Sr(e, t, n, r, s);
|
|
198
198
|
} catch {
|
|
199
199
|
it(e, t, n, r, !1);
|
|
200
200
|
}
|
|
201
201
|
else
|
|
202
202
|
it(e, t, n, r, i);
|
|
203
203
|
}
|
|
204
|
-
function
|
|
205
|
-
var
|
|
206
|
-
const i = r.text || "", s = r.fontSize || 24, l = t.stroke.width, a = t.stroke.feather || 0, c = t.transformType === "custom" && ((
|
|
207
|
-
if (g <= 0 ||
|
|
204
|
+
function Sr(e, t, r, n, o) {
|
|
205
|
+
var S, P;
|
|
206
|
+
const i = r.text || "", s = r.fontSize || 24, l = t.stroke.width, a = t.stroke.feather || 0, c = t.transformType === "custom" && ((S = t.transformData) == null ? void 0 : S.width), h = c ? ((P = t.transformData) == null ? void 0 : P.width) ?? 200 : 0, f = c ? h + l * 2 + a * 2 + 40 : s * i.length * 0.7 + l * 2 + a * 2 + 40, u = s * 3 + l * 2 + a * 2 + 40, d = e.getTransform(), m = Math.max(Math.abs(d.a), Math.abs(d.d), 1), g = Math.ceil(f * m / 2) * 2, k = Math.ceil(u * m / 2) * 2;
|
|
207
|
+
if (g <= 0 || k <= 0) {
|
|
208
208
|
it(e, t, r, n, !1);
|
|
209
209
|
return;
|
|
210
210
|
}
|
|
211
|
-
const T =
|
|
211
|
+
const T = Er(g, k), w = T.getContext("2d");
|
|
212
212
|
if (!w) {
|
|
213
213
|
it(e, t, r, n, !1);
|
|
214
214
|
return;
|
|
215
215
|
}
|
|
216
|
-
const b = t.x || 0,
|
|
216
|
+
const b = t.x || 0, p = t.y || 0, y = d.a * b + d.c * p + d.e, C = d.b * b + d.d * p + d.f;
|
|
217
217
|
w.setTransform(
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
g / 2 -
|
|
223
|
-
|
|
218
|
+
d.a,
|
|
219
|
+
d.b,
|
|
220
|
+
d.c,
|
|
221
|
+
d.d,
|
|
222
|
+
g / 2 - y + d.e,
|
|
223
|
+
k / 2 - C + d.f
|
|
224
224
|
);
|
|
225
|
-
const
|
|
226
|
-
t.stroke.opacity = 1, it(w, t, r, n, !1), t.stroke.opacity =
|
|
225
|
+
const M = t.stroke.opacity;
|
|
226
|
+
t.stroke.opacity = 1, it(w, t, r, n, !1), t.stroke.opacity = M, e.save(), e.resetTransform(), e.globalAlpha = o, e.drawImage(
|
|
227
227
|
T,
|
|
228
|
-
Math.round(
|
|
229
|
-
Math.round(
|
|
228
|
+
Math.round(y - g / 2),
|
|
229
|
+
Math.round(C - k / 2)
|
|
230
230
|
), e.restore();
|
|
231
231
|
}
|
|
232
232
|
function it(e, t, r, n, o) {
|
|
233
|
-
var
|
|
233
|
+
var d;
|
|
234
234
|
const i = r.text || "";
|
|
235
235
|
e.save(), n != null && n.positionApplied || (e.translate(t.x || 0, t.y || 0), e.rotate(-(t.rotation || 0) * Math.PI / 180));
|
|
236
236
|
const s = r.fontSize || 24, l = r.fontFamily || "Arial", a = r.bold || !1, c = r.italic || !1, h = r.textAlign || "center";
|
|
237
237
|
e.font = `${c ? "italic " : ""}${a ? "bold " : ""}${s}px ${l}`, e.textAlign = h, e.textBaseline = "alphabetic", o ? (e.strokeStyle = "#000000", e.globalAlpha = 1) : (e.strokeStyle = t.stroke.color, t.stroke.opacity !== void 0 && (e.globalAlpha = t.stroke.opacity)), e.lineWidth = t.stroke.width, e.lineCap = t.stroke.lineCap || "round", e.lineJoin = t.stroke.lineJoin || "round", t.stroke.miterLimit !== void 0 && (e.miterLimit = t.stroke.miterLimit), !o && t.stroke.feather && t.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${t.stroke.feather}px)`);
|
|
238
|
-
const
|
|
239
|
-
if (t.transformType === "custom" && ((
|
|
240
|
-
const
|
|
238
|
+
const f = Ke(s, l, a, c);
|
|
239
|
+
if (t.transformType === "custom" && ((d = t.transformData) == null ? void 0 : d.width)) {
|
|
240
|
+
const m = t.transformData, g = (m == null ? void 0 : m.width) ?? 200, k = g - x * 2, T = r.letterSpacing ?? 0, { lines: w, height: b } = Ee(
|
|
241
241
|
i,
|
|
242
|
-
|
|
242
|
+
k,
|
|
243
243
|
s,
|
|
244
244
|
l,
|
|
245
245
|
a,
|
|
@@ -249,92 +249,92 @@ function it(e, t, r, n, o) {
|
|
|
249
249
|
!0,
|
|
250
250
|
// strict: wrap exactly at maxWidth
|
|
251
251
|
{ letterSpacing: T, lineHeight: r.lineHeight }
|
|
252
|
-
),
|
|
253
|
-
w.forEach((
|
|
254
|
-
const P =
|
|
255
|
-
let A =
|
|
252
|
+
), p = -g / 2, y = -b / 2, C = s * (r.lineHeight ?? Vt);
|
|
253
|
+
w.forEach((M, S) => {
|
|
254
|
+
const P = S === 0, v = S === w.length - 1;
|
|
255
|
+
let A = M;
|
|
256
256
|
if (!P) {
|
|
257
|
-
const R =
|
|
257
|
+
const R = M.match(/^ +/), W = R ? R[0].length : 0;
|
|
258
258
|
W > 0 && (A = A.substring(W));
|
|
259
259
|
}
|
|
260
260
|
if (!v) {
|
|
261
261
|
const R = A.match(/ +$/), W = R ? R[0].length : 0;
|
|
262
262
|
W > 0 && (A = A.substring(0, A.length - W));
|
|
263
263
|
}
|
|
264
|
-
let I =
|
|
265
|
-
h === "center" ? I =
|
|
266
|
-
const E =
|
|
267
|
-
|
|
264
|
+
let I = p + x;
|
|
265
|
+
h === "center" ? I = p + g / 2 : h === "right" && (I = p + g - x);
|
|
266
|
+
const E = y + f.ascent + S * C;
|
|
267
|
+
Qe(e, A, I, E, T);
|
|
268
268
|
});
|
|
269
269
|
} else {
|
|
270
|
-
const
|
|
271
|
-
e.strokeText(i, 0,
|
|
270
|
+
const k = -f.height / 2 + f.ascent;
|
|
271
|
+
e.strokeText(i, 0, k);
|
|
272
272
|
}
|
|
273
273
|
e.restore();
|
|
274
274
|
}
|
|
275
|
-
function
|
|
275
|
+
function Mr(e, t, r) {
|
|
276
276
|
var o;
|
|
277
277
|
if (!((o = t.stroke) != null && o.enabled) || !t.transformData) return;
|
|
278
278
|
const n = (r == null ? void 0 : r.isKnockout) === !0;
|
|
279
|
-
e.save(), n ? (e.strokeStyle = "#000000", e.lineWidth = t.stroke.width, e.lineCap = t.stroke.lineCap || "butt", e.lineJoin = t.stroke.lineJoin || "miter", e.globalAlpha = 1, t.stroke.miterLimit !== void 0 && (e.miterLimit = t.stroke.miterLimit)) :
|
|
279
|
+
e.save(), n ? (e.strokeStyle = "#000000", e.lineWidth = t.stroke.width, e.lineCap = t.stroke.lineCap || "butt", e.lineJoin = t.stroke.lineJoin || "miter", e.globalAlpha = 1, t.stroke.miterLimit !== void 0 && (e.miterLimit = t.stroke.miterLimit)) : Ie(e, t.stroke), !n && t.stroke.feather && t.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${t.stroke.feather}px)`), vr(e, t), e.stroke(), e.restore();
|
|
280
280
|
}
|
|
281
|
-
function
|
|
282
|
-
t.enabled && (e.save(),
|
|
281
|
+
function Zn(e, t, r) {
|
|
282
|
+
t.enabled && (e.save(), Ie(e, t), t.feather && t.feather > 0 && "filter" in e && (e.filter = `blur(${t.feather}px)`), e.beginPath(), r(), e.stroke(), e.restore());
|
|
283
283
|
}
|
|
284
|
-
const
|
|
285
|
-
function
|
|
284
|
+
const ne = j("GlyphRenderer");
|
|
285
|
+
function Cr(e, t, r, n, o, i, s, l = {}) {
|
|
286
286
|
try {
|
|
287
287
|
const a = [];
|
|
288
|
-
Object.entries(s).forEach(([
|
|
289
|
-
T && a.push(
|
|
288
|
+
Object.entries(s).forEach(([k, T]) => {
|
|
289
|
+
T && a.push(k);
|
|
290
290
|
});
|
|
291
291
|
const c = [];
|
|
292
|
-
t.GSUB && t.GSUB.featureList && t.GSUB.featureList.forEach((
|
|
293
|
-
c.push(
|
|
292
|
+
t.GSUB && t.GSUB.featureList && t.GSUB.featureList.forEach((k) => {
|
|
293
|
+
c.push(k.tag);
|
|
294
294
|
});
|
|
295
295
|
const h = {};
|
|
296
|
-
h.ccmp = !0, h.locl = !0, h.kern = !0, a.forEach((
|
|
297
|
-
h[
|
|
296
|
+
h.ccmp = !0, h.locl = !0, h.kern = !0, a.forEach((k) => {
|
|
297
|
+
h[k] = !0;
|
|
298
298
|
}), h.calt && (h.liga = !0, h.init = !0, h.fina = !0);
|
|
299
|
-
const
|
|
300
|
-
let
|
|
301
|
-
|
|
302
|
-
|
|
299
|
+
const f = t.layout(r, h, "latn"), u = i / t.unitsPerEm;
|
|
300
|
+
let d = 0;
|
|
301
|
+
f.glyphs.forEach((k) => {
|
|
302
|
+
d += k.advanceWidth * u;
|
|
303
303
|
});
|
|
304
|
-
let
|
|
305
|
-
l.align === "center" ?
|
|
306
|
-
let g =
|
|
307
|
-
|
|
308
|
-
const w =
|
|
304
|
+
let m = n;
|
|
305
|
+
l.align === "center" ? m = n - d / 2 : l.align === "right" && (m = n - d), e.save(), e.fillStyle = l.color || "#000000";
|
|
306
|
+
let g = m;
|
|
307
|
+
f.glyphs.forEach((k, T) => {
|
|
308
|
+
const w = f.positions[T];
|
|
309
309
|
let b = null;
|
|
310
310
|
try {
|
|
311
|
-
if (
|
|
312
|
-
b =
|
|
313
|
-
else if (
|
|
314
|
-
const
|
|
315
|
-
if (
|
|
316
|
-
b =
|
|
311
|
+
if (k.path && typeof k.path.toPath == "function")
|
|
312
|
+
b = k.path.toPath();
|
|
313
|
+
else if (k.path && typeof k.path.toSVG == "function") {
|
|
314
|
+
const p = k.path.toSVG();
|
|
315
|
+
if (p && /^[MmLlHhVvCcSsQqTtAaZz]/.test(p))
|
|
316
|
+
b = p;
|
|
317
317
|
else {
|
|
318
|
-
const
|
|
319
|
-
b =
|
|
318
|
+
const y = p == null ? void 0 : p.match(/\bd=["']([^"']+)["']/);
|
|
319
|
+
b = y ? y[1] : null;
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
|
-
} catch (
|
|
323
|
-
|
|
322
|
+
} catch (p) {
|
|
323
|
+
ne.warn("Error getting path for glyph:", k.name, p);
|
|
324
324
|
}
|
|
325
325
|
if (b) {
|
|
326
|
-
const
|
|
327
|
-
e.save(), e.translate(g + w.xOffset * u, o + w.yOffset * u), e.scale(u, -u), e.fill(
|
|
326
|
+
const p = new Path2D(b);
|
|
327
|
+
e.save(), e.translate(g + w.xOffset * u, o + w.yOffset * u), e.scale(u, -u), e.fill(p), e.restore();
|
|
328
328
|
}
|
|
329
|
-
g +=
|
|
329
|
+
g += k.advanceWidth * u;
|
|
330
330
|
}), e.restore();
|
|
331
331
|
} catch (a) {
|
|
332
|
-
|
|
332
|
+
ne.error("Error rendering with fontkit:", a), e.fillStyle = l.color || "#000000", e.textAlign = l.align || "left", e.fillText(r, n, o);
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
function
|
|
336
|
-
const c = ((
|
|
337
|
-
for (const T of
|
|
335
|
+
function Pr(e, t, r, n, o, i, s, l = {}) {
|
|
336
|
+
const c = ((k) => {
|
|
337
|
+
for (const T of k) {
|
|
338
338
|
const w = T.codePointAt(0);
|
|
339
339
|
if (w && w >= 983040 && w <= 1048573) return !0;
|
|
340
340
|
}
|
|
@@ -345,56 +345,56 @@ function Er(e, t, r, n, o, i, s, l = {}) {
|
|
|
345
345
|
return;
|
|
346
346
|
}
|
|
347
347
|
const h = /* @__PURE__ */ new Map();
|
|
348
|
-
s && s.forEach((
|
|
349
|
-
h.set(
|
|
348
|
+
s && s.forEach((k) => {
|
|
349
|
+
h.set(k.charIndex, k.glyphIndex);
|
|
350
350
|
});
|
|
351
|
-
const
|
|
352
|
-
let
|
|
353
|
-
u.forEach((
|
|
354
|
-
const w =
|
|
351
|
+
const f = i / t.unitsPerEm, u = Array.from(r);
|
|
352
|
+
let d = 0;
|
|
353
|
+
u.forEach((k, T) => {
|
|
354
|
+
const w = k.codePointAt(0) || 0;
|
|
355
355
|
let b;
|
|
356
356
|
if (w >= 983040 && w <= 1048573)
|
|
357
357
|
b = w - 983040;
|
|
358
358
|
else if (b = h.get(T), b === void 0) {
|
|
359
|
-
const
|
|
360
|
-
b =
|
|
359
|
+
const y = t.glyphForCodePoint(w);
|
|
360
|
+
b = y ? y.id : 0;
|
|
361
361
|
}
|
|
362
|
-
const
|
|
363
|
-
|
|
362
|
+
const p = t.getGlyph(b);
|
|
363
|
+
p && (d += p.advanceWidth * f);
|
|
364
364
|
});
|
|
365
|
-
let
|
|
366
|
-
l.align === "center" ?
|
|
367
|
-
let g =
|
|
368
|
-
u.forEach((
|
|
369
|
-
const w =
|
|
365
|
+
let m = n;
|
|
366
|
+
l.align === "center" ? m = n - d / 2 : l.align === "right" && (m = n - d), e.save(), e.fillStyle = l.color || "#000000";
|
|
367
|
+
let g = m;
|
|
368
|
+
u.forEach((k, T) => {
|
|
369
|
+
const w = k.codePointAt(0) || 0;
|
|
370
370
|
let b;
|
|
371
371
|
if (w >= 983040 && w <= 1048573)
|
|
372
372
|
b = w - 983040;
|
|
373
373
|
else if (b = h.get(T), b === void 0) {
|
|
374
|
-
const
|
|
375
|
-
b =
|
|
374
|
+
const y = t.glyphForCodePoint(w);
|
|
375
|
+
b = y ? y.id : 0;
|
|
376
376
|
}
|
|
377
|
-
const
|
|
378
|
-
if (
|
|
379
|
-
const
|
|
380
|
-
if (
|
|
381
|
-
const
|
|
382
|
-
e.save(), e.translate(g, o), e.scale(
|
|
377
|
+
const p = t.getGlyph(b);
|
|
378
|
+
if (p) {
|
|
379
|
+
const y = p.path.toSVG();
|
|
380
|
+
if (y) {
|
|
381
|
+
const C = new Path2D(y);
|
|
382
|
+
e.save(), e.translate(g, o), e.scale(f, -f), e.fill(C), e.restore();
|
|
383
383
|
}
|
|
384
|
-
g +=
|
|
384
|
+
g += p.advanceWidth * f;
|
|
385
385
|
}
|
|
386
386
|
}), e.restore();
|
|
387
387
|
}
|
|
388
|
-
function
|
|
388
|
+
function Ir(e, t, r, n, o) {
|
|
389
389
|
e.fillStyle = r.color;
|
|
390
|
-
const i = r.textAlign || "center", s = (g) => g.letterSpacing !== void 0 ? g.letterSpacing : r.letterSpacing ?? 0, l =
|
|
390
|
+
const i = r.textAlign || "center", s = (g) => g.letterSpacing !== void 0 ? g.letterSpacing : r.letterSpacing ?? 0, l = ze(t);
|
|
391
391
|
let a, c;
|
|
392
392
|
n !== void 0 && n > 0 && !o ? (a = [], c = [], l.forEach((g) => {
|
|
393
|
-
const
|
|
394
|
-
|
|
393
|
+
const k = Ze(g, n, r);
|
|
394
|
+
k.forEach((T, w) => {
|
|
395
395
|
a.push(T), c.push({
|
|
396
396
|
isParagraphStart: w === 0,
|
|
397
|
-
isParagraphEnd: w ===
|
|
397
|
+
isParagraphEnd: w === k.length - 1
|
|
398
398
|
});
|
|
399
399
|
});
|
|
400
400
|
})) : (a = l, c = l.map(() => ({
|
|
@@ -402,38 +402,38 @@ function Sr(e, t, r, n, o) {
|
|
|
402
402
|
isParagraphEnd: !0
|
|
403
403
|
})));
|
|
404
404
|
const h = [];
|
|
405
|
-
a.forEach((g,
|
|
405
|
+
a.forEach((g, k) => {
|
|
406
406
|
const T = [];
|
|
407
407
|
let w = 0, b = 0;
|
|
408
|
-
const
|
|
408
|
+
const p = c[k].isParagraphStart, y = c[k].isParagraphEnd;
|
|
409
409
|
g.forEach((E) => {
|
|
410
|
-
const R = E.style.fontSize !== void 0 ? E.style.fontSize : r.fontSize, W = E.style.fontFamily !== void 0 ? E.style.fontFamily : r.fontFamily, F = E.style.bold !== void 0 ? E.style.bold : r.bold || !1,
|
|
411
|
-
e.font = q(R, W, F,
|
|
412
|
-
const
|
|
413
|
-
T.push(
|
|
414
|
-
const $ = ht(R, W, F,
|
|
410
|
+
const R = E.style.fontSize !== void 0 ? E.style.fontSize : r.fontSize, W = E.style.fontFamily !== void 0 ? E.style.fontFamily : r.fontFamily, F = E.style.bold !== void 0 ? E.style.bold : r.bold || !1, U = E.style.italic !== void 0 ? E.style.italic : r.italic || !1;
|
|
411
|
+
e.font = q(R, W, F, U);
|
|
412
|
+
const B = at(e.measureText(E.text).width, E.text, s(E.style));
|
|
413
|
+
T.push(B);
|
|
414
|
+
const $ = ht(R, W, F, U);
|
|
415
415
|
w = Math.max(w, $.height), b = Math.max(b, $.ascent);
|
|
416
416
|
});
|
|
417
|
-
const
|
|
417
|
+
const C = g.map((E) => E.text).join(""), M = C.match(/^ +/), S = C.match(/ +$/), P = M ? M[0].length : 0, v = S ? S[0].length : 0;
|
|
418
418
|
let A = 0, I = 0;
|
|
419
419
|
g.forEach((E) => {
|
|
420
|
-
const R = E.style.fontSize !== void 0 ? E.style.fontSize : r.fontSize, W = E.style.fontFamily !== void 0 ? E.style.fontFamily : r.fontFamily, F = E.style.bold !== void 0 ? E.style.bold : r.bold || !1,
|
|
421
|
-
let
|
|
420
|
+
const R = E.style.fontSize !== void 0 ? E.style.fontSize : r.fontSize, W = E.style.fontFamily !== void 0 ? E.style.fontFamily : r.fontFamily, F = E.style.bold !== void 0 ? E.style.bold : r.bold || !1, U = E.style.italic !== void 0 ? E.style.italic : r.italic || !1;
|
|
421
|
+
let B = E.text;
|
|
422
422
|
const $ = I, St = I + E.text.length;
|
|
423
|
-
if (!
|
|
423
|
+
if (!p && P > 0 && $ < P) {
|
|
424
424
|
const L = Math.min(P - $, E.text.length);
|
|
425
|
-
|
|
425
|
+
B = B.substring(L);
|
|
426
426
|
}
|
|
427
|
-
if (!
|
|
428
|
-
const L =
|
|
427
|
+
if (!y && v > 0) {
|
|
428
|
+
const L = C.length - v;
|
|
429
429
|
if (St > L) {
|
|
430
|
-
const G = !
|
|
431
|
-
|
|
430
|
+
const G = !p && P > 0 && $ < P ? Math.min(P - $, E.text.length) : 0, Mt = Math.max(0, L - $ - G);
|
|
431
|
+
B = B.substring(0, Mt);
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
|
-
I += E.text.length,
|
|
435
|
-
e.measureText(
|
|
436
|
-
|
|
434
|
+
I += E.text.length, B.length > 0 && (e.save(), e.font = q(R, W, F, U), A += at(
|
|
435
|
+
e.measureText(B).width,
|
|
436
|
+
B,
|
|
437
437
|
s(E.style)
|
|
438
438
|
), e.restore());
|
|
439
439
|
}), h.push({
|
|
@@ -443,30 +443,30 @@ function Sr(e, t, r, n, o) {
|
|
|
443
443
|
height: w,
|
|
444
444
|
ascent: b,
|
|
445
445
|
spanWidths: T,
|
|
446
|
-
isParagraphStart:
|
|
446
|
+
isParagraphStart: p,
|
|
447
447
|
// Store metadata with line
|
|
448
|
-
isParagraphEnd:
|
|
448
|
+
isParagraphEnd: y
|
|
449
449
|
});
|
|
450
450
|
});
|
|
451
|
-
const
|
|
452
|
-
let
|
|
453
|
-
h.length === 0 ?
|
|
454
|
-
const
|
|
455
|
-
h.forEach((g,
|
|
456
|
-
const { spans: T, width: w, isParagraphStart: b, isParagraphEnd:
|
|
457
|
-
let
|
|
458
|
-
i === "center" ?
|
|
459
|
-
const
|
|
451
|
+
const f = ht(r.fontSize, r.fontFamily, r.bold, r.italic), u = r.fontSize * (r.lineHeight ?? Vt);
|
|
452
|
+
let d;
|
|
453
|
+
h.length === 0 ? d = 0 : h.length === 1 ? d = f.height : d = (h.length - 1) * u + f.height;
|
|
454
|
+
const m = -d / 2;
|
|
455
|
+
h.forEach((g, k) => {
|
|
456
|
+
const { spans: T, width: w, isParagraphStart: b, isParagraphEnd: p } = g;
|
|
457
|
+
let y;
|
|
458
|
+
i === "center" ? y = -w / 2 : i === "right" ? y = n !== void 0 ? n / 2 - w : -w : y = n !== void 0 ? -n / 2 : 0;
|
|
459
|
+
const C = m + f.ascent + k * u, M = T.map((E) => E.text).join(""), S = M.match(/^ +/), P = M.match(/ +$/), v = S ? S[0].length : 0, A = P ? P[0].length : 0;
|
|
460
460
|
let I = 0;
|
|
461
461
|
T.forEach((E) => {
|
|
462
|
-
const R = E.style.fontSize !== void 0 ? E.style.fontSize : r.fontSize, W = E.style.fontFamily !== void 0 ? E.style.fontFamily : r.fontFamily, F = E.style.color !== void 0 ? E.style.color : r.color,
|
|
462
|
+
const R = E.style.fontSize !== void 0 ? E.style.fontSize : r.fontSize, W = E.style.fontFamily !== void 0 ? E.style.fontFamily : r.fontFamily, F = E.style.color !== void 0 ? E.style.color : r.color, U = E.style.bold !== void 0 ? E.style.bold : r.bold || !1, B = E.style.italic !== void 0 ? E.style.italic : r.italic || !1, $ = E.style.underline !== void 0 ? E.style.underline : r.underline || !1, St = E.style.strikethrough !== void 0 ? E.style.strikethrough : r.strikethrough || !1;
|
|
463
463
|
let L = E.text, G = I, Mt = I + E.text.length;
|
|
464
464
|
if (!b && v > 0 && G < v) {
|
|
465
465
|
const Y = Math.min(v - G, E.text.length);
|
|
466
466
|
L = L.substring(Y);
|
|
467
467
|
}
|
|
468
|
-
if (!
|
|
469
|
-
const Y =
|
|
468
|
+
if (!p && A > 0) {
|
|
469
|
+
const Y = M.length - A;
|
|
470
470
|
if (Mt > Y) {
|
|
471
471
|
const nt = !b && v > 0 && G < v ? Math.min(v - G, E.text.length) : 0, V = Math.max(0, Y - G - nt);
|
|
472
472
|
L = L.substring(0, V);
|
|
@@ -474,24 +474,24 @@ function Sr(e, t, r, n, o) {
|
|
|
474
474
|
}
|
|
475
475
|
if (I += E.text.length, L.length > 0) {
|
|
476
476
|
const Y = s(E.style);
|
|
477
|
-
e.font = q(R, W,
|
|
477
|
+
e.font = q(R, W, U, B), e.fillStyle = F, e.textBaseline = "alphabetic", e.textAlign = "left", Jt(e, L, y, C, Y);
|
|
478
478
|
const nt = at(e.measureText(L).width, L, Y);
|
|
479
479
|
if ($) {
|
|
480
|
-
const V =
|
|
481
|
-
e.beginPath(), e.moveTo(
|
|
480
|
+
const V = C + R * 0.1;
|
|
481
|
+
e.beginPath(), e.moveTo(y, V), e.lineTo(y + nt, V), e.lineWidth = Math.max(1, R * 0.05), e.strokeStyle = F, e.stroke();
|
|
482
482
|
}
|
|
483
483
|
if (St) {
|
|
484
|
-
const V =
|
|
485
|
-
e.beginPath(), e.moveTo(
|
|
484
|
+
const V = C - R * 0.25;
|
|
485
|
+
e.beginPath(), e.moveTo(y, V), e.lineTo(y + nt, V), e.lineWidth = Math.max(1, R * 0.05), e.strokeStyle = F, e.stroke();
|
|
486
486
|
}
|
|
487
|
-
|
|
487
|
+
y += nt;
|
|
488
488
|
}
|
|
489
489
|
});
|
|
490
490
|
});
|
|
491
491
|
}
|
|
492
492
|
const Rt = j("canvas-renderer");
|
|
493
493
|
let ut = null;
|
|
494
|
-
function
|
|
494
|
+
function Kt() {
|
|
495
495
|
if (!ut)
|
|
496
496
|
if (typeof OffscreenCanvas < "u")
|
|
497
497
|
ut = new OffscreenCanvas(1, 1).getContext("2d");
|
|
@@ -505,17 +505,17 @@ function q(e, t, r = !1, n = !1) {
|
|
|
505
505
|
const o = [];
|
|
506
506
|
return n && o.push("italic"), r && o.push("bold"), o.push(`${e}px`), o.push(t), o.join(" ");
|
|
507
507
|
}
|
|
508
|
-
function
|
|
509
|
-
const s =
|
|
508
|
+
function oe(e, t, r, n = !1, o = !1, i = 0) {
|
|
509
|
+
const s = Kt();
|
|
510
510
|
return s.font = q(t, r, n, o), at(s.measureText(e).width, e, i);
|
|
511
511
|
}
|
|
512
512
|
function ht(e, t, r = !1, n = !1) {
|
|
513
|
-
const o =
|
|
513
|
+
const o = Kt();
|
|
514
514
|
o.font = q(e, t, r, n);
|
|
515
515
|
const s = o.measureText("ÁÉÍgjpqy"), l = s.actualBoundingBoxAscent || e * 0.8, a = s.actualBoundingBoxDescent || e * 0.2, c = l + a;
|
|
516
516
|
return { ascent: l, descent: a, height: c };
|
|
517
517
|
}
|
|
518
|
-
function
|
|
518
|
+
function Dn(e, t) {
|
|
519
519
|
const r = e.map((o, i) => ({
|
|
520
520
|
isParagraphStart: !t && i === 0,
|
|
521
521
|
isParagraphEnd: !t && i === e.length - 1
|
|
@@ -528,111 +528,111 @@ function Jn(e, t) {
|
|
|
528
528
|
return s || (a = a.replace(/^ +/, "")), l || (a = a.replace(/ +$/, "")), a;
|
|
529
529
|
}).filter((o) => o.length > 0);
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function Ar(e, t) {
|
|
532
532
|
const r = t.fontSize, n = t.fontFamily, o = t.bold || !1, i = t.italic || !1, s = t.textAlign || "center", l = t.text;
|
|
533
533
|
e.font = q(r, n, o, i), e.textAlign = s, e.textBaseline = "alphabetic", e.fillStyle = t.color;
|
|
534
|
-
const a = ht(r, n, o, i),
|
|
535
|
-
|
|
534
|
+
const a = ht(r, n, o, i), f = -a.height / 2 + a.ascent;
|
|
535
|
+
Jt(e, l, 0, f, t.letterSpacing);
|
|
536
536
|
}
|
|
537
|
-
function
|
|
538
|
-
const l =
|
|
537
|
+
function Rr(e, t, r, n, o = !1, i = !1, s) {
|
|
538
|
+
const l = Kt();
|
|
539
539
|
if (l.font = q(r, n, o, i), e.trim().length === 0)
|
|
540
540
|
return [e];
|
|
541
541
|
if (e.includes(`
|
|
542
542
|
`)) {
|
|
543
|
-
const
|
|
543
|
+
const S = e.split(`
|
|
544
544
|
`), P = [];
|
|
545
|
-
for (let v = 0; v <
|
|
546
|
-
const A =
|
|
545
|
+
for (let v = 0; v < S.length; v++) {
|
|
546
|
+
const A = S[v], I = Rr(A, t, r, n, o, i);
|
|
547
547
|
P.push(...I);
|
|
548
548
|
}
|
|
549
549
|
return P;
|
|
550
550
|
}
|
|
551
|
-
const a = e.match(/^\s*/), c = e.match(/\s*$/), h = a ? a[0] : "",
|
|
551
|
+
const a = e.match(/^\s*/), c = e.match(/\s*$/), h = a ? a[0] : "", f = c ? c[0] : "", d = e.substring(h.length, e.length - f.length).split(" ");
|
|
552
552
|
if (s !== void 0 && s > 0) {
|
|
553
553
|
if (s === 1)
|
|
554
|
-
return [h +
|
|
555
|
-
const
|
|
556
|
-
for (let v = 0; v <
|
|
557
|
-
const I =
|
|
558
|
-
v === 0 && v + P >=
|
|
554
|
+
return [h + d.join(" ") + f];
|
|
555
|
+
const S = [], P = Math.ceil(d.length / s);
|
|
556
|
+
for (let v = 0; v < d.length; v += P) {
|
|
557
|
+
const I = d.slice(v, v + P).join(" ");
|
|
558
|
+
v === 0 && v + P >= d.length ? S.push(h + I + f) : v === 0 ? S.push(h + I) : v + P >= d.length ? S.push(I + f) : S.push(I);
|
|
559
559
|
}
|
|
560
|
-
return
|
|
560
|
+
return S;
|
|
561
561
|
}
|
|
562
|
-
const
|
|
563
|
-
if (
|
|
562
|
+
const m = d.join(" "), g = h + m + f, k = l.measureText(g).width, T = t < 200, b = Math.max(20, t * (T ? 0.08 : 0.05));
|
|
563
|
+
if (k <= t + b)
|
|
564
564
|
return [g];
|
|
565
|
-
const
|
|
566
|
-
let
|
|
567
|
-
const
|
|
568
|
-
for (let
|
|
569
|
-
const P =
|
|
570
|
-
l.measureText(v).width > t +
|
|
571
|
-
}
|
|
572
|
-
return
|
|
573
|
-
}
|
|
574
|
-
function
|
|
575
|
-
e.font = q(o, i, h,
|
|
576
|
-
const
|
|
565
|
+
const p = [];
|
|
566
|
+
let y = d[0];
|
|
567
|
+
const M = Math.max(15, t * (T ? 0.05 : 0.03));
|
|
568
|
+
for (let S = 1; S < d.length; S++) {
|
|
569
|
+
const P = d[S], v = y + " " + P;
|
|
570
|
+
l.measureText(v).width > t + M ? (p.push(y), y = P) : y = v;
|
|
571
|
+
}
|
|
572
|
+
return p.push(y), p.length > 0 && (p[0] = h + p[0], p[p.length - 1] = p[p.length - 1] + f), p;
|
|
573
|
+
}
|
|
574
|
+
function xn(e, t, r, n, o, i, s = "left", l = 0, a = 0, c = 1.2, h = !1, f = !1, u = !1, d = !1, m, g) {
|
|
575
|
+
e.font = q(o, i, h, f), e.textBaseline = "alphabetic", e.textAlign = s;
|
|
576
|
+
const k = (v) => {
|
|
577
577
|
for (const A of v) {
|
|
578
578
|
const I = A.codePointAt(0);
|
|
579
579
|
if (I && I >= 983040 && I <= 1048573)
|
|
580
580
|
return !0;
|
|
581
581
|
}
|
|
582
582
|
return !1;
|
|
583
|
-
}, T =
|
|
584
|
-
|
|
585
|
-
`[renderMultilineText] Font ${i} not loaded for fontkit rendering. Text may not render correctly. Has PUA: ${
|
|
586
|
-
),
|
|
583
|
+
}, T = m && Object.values(m).some((v) => v), w = g && g.length > 0, b = t.join(" "), p = k(b), y = T || w || p, C = y ? te.getFontSync(i, h ? 700 : 400) : null;
|
|
584
|
+
y && !C && (Rt.warn(
|
|
585
|
+
`[renderMultilineText] Font ${i} not loaded for fontkit rendering. Text may not render correctly. Has PUA: ${p}, Text: "${b}"`
|
|
586
|
+
), te.loadFont(i, h ? 700 : 400).catch((v) => {
|
|
587
587
|
Rt.error("[renderMultilineText] Error loading font:", v);
|
|
588
588
|
}));
|
|
589
|
-
const
|
|
589
|
+
const M = ht(o, i, h, f), S = o * c;
|
|
590
590
|
let P = 0;
|
|
591
591
|
t.forEach((v, A) => {
|
|
592
592
|
let I = r + a;
|
|
593
593
|
s === "center" ? I = r + l / 2 : s === "right" && (I = r + l - a);
|
|
594
|
-
const E = n +
|
|
595
|
-
const
|
|
596
|
-
return
|
|
594
|
+
const E = n + M.ascent + A * S, R = Array.from(v).length, W = w ? g.filter((F) => {
|
|
595
|
+
const U = F.charIndex - P;
|
|
596
|
+
return U >= 0 && U < R;
|
|
597
597
|
}).map((F) => ({
|
|
598
598
|
...F,
|
|
599
599
|
charIndex: F.charIndex - P
|
|
600
600
|
// Adjust to line-relative index
|
|
601
601
|
})) : [];
|
|
602
|
-
if (
|
|
602
|
+
if (C && (T || W.length > 0 || p) ? W.length > 0 || k(v) ? Pr(e, C, v, I, E, o, W, {
|
|
603
603
|
color: e.fillStyle,
|
|
604
604
|
align: s === "start" || s === "end" ? "left" : s
|
|
605
|
-
}) :
|
|
605
|
+
}) : m && Cr(e, C, v, I, E, o, m, {
|
|
606
606
|
color: e.fillStyle,
|
|
607
607
|
align: s === "start" || s === "end" ? "left" : s
|
|
608
608
|
}) : e.fillText(v, I, E), P += R + 1, u) {
|
|
609
|
-
const F =
|
|
610
|
-
let
|
|
611
|
-
s === "center" ?
|
|
612
|
-
const
|
|
613
|
-
e.beginPath(), e.moveTo(
|
|
609
|
+
const F = oe(v, o, i, h, f);
|
|
610
|
+
let U = I;
|
|
611
|
+
s === "center" ? U = I - F / 2 : s === "right" && (U = I - F);
|
|
612
|
+
const B = E + o * 0.1;
|
|
613
|
+
e.beginPath(), e.moveTo(U, B), e.lineTo(U + F, B), e.lineWidth = Math.max(1, o * 0.05), e.strokeStyle = e.fillStyle, e.stroke();
|
|
614
614
|
}
|
|
615
|
-
if (
|
|
616
|
-
const F =
|
|
617
|
-
let
|
|
618
|
-
s === "center" ?
|
|
619
|
-
const
|
|
620
|
-
e.beginPath(), e.moveTo(
|
|
615
|
+
if (d) {
|
|
616
|
+
const F = oe(v, o, i, h, f);
|
|
617
|
+
let U = I;
|
|
618
|
+
s === "center" ? U = I - F / 2 : s === "right" && (U = I - F);
|
|
619
|
+
const B = E - o * 0.25;
|
|
620
|
+
e.beginPath(), e.moveTo(U, B), e.lineTo(U + F, B), e.lineWidth = Math.max(1, o * 0.05), e.strokeStyle = e.fillStyle, e.stroke();
|
|
621
621
|
}
|
|
622
622
|
});
|
|
623
623
|
}
|
|
624
624
|
function Wt(e, t) {
|
|
625
|
-
|
|
625
|
+
Wr(e, t);
|
|
626
626
|
}
|
|
627
|
-
function
|
|
627
|
+
function Wr(e, t) {
|
|
628
628
|
var o;
|
|
629
|
-
(o = t.stroke) != null && o.enabled &&
|
|
629
|
+
(o = t.stroke) != null && o.enabled && Ae(e, t), e.save(), e.translate(t.x, t.y), e.rotate(-t.rotation * Math.PI / 180);
|
|
630
630
|
const r = t.transformData, n = ((r == null ? void 0 : r.width) ?? 100) - x * 2;
|
|
631
631
|
if (t.richText) {
|
|
632
|
-
const i =
|
|
632
|
+
const i = De.fromJSON(t.richText);
|
|
633
633
|
e.save(), e.translate(0, 0);
|
|
634
634
|
const s = t._lockedLineCount;
|
|
635
|
-
|
|
635
|
+
Ir(
|
|
636
636
|
e,
|
|
637
637
|
i,
|
|
638
638
|
{
|
|
@@ -668,67 +668,67 @@ function Pr(e, t) {
|
|
|
668
668
|
t.fontFamily,
|
|
669
669
|
t.bold,
|
|
670
670
|
t.italic
|
|
671
|
-
), h = -((r == null ? void 0 : r.width) ?? 100) / 2,
|
|
672
|
-
e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSize}px ${t.fontFamily}`, e.textBaseline = "alphabetic", e.textAlign = t.textAlign, l.forEach((
|
|
673
|
-
const g =
|
|
674
|
-
let T =
|
|
671
|
+
), h = -((r == null ? void 0 : r.width) ?? 100) / 2, f = -a / 2, u = t.fontSize * (t.lineHeight ?? Vt);
|
|
672
|
+
e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSize}px ${t.fontFamily}`, e.textBaseline = "alphabetic", e.textAlign = t.textAlign, l.forEach((d, m) => {
|
|
673
|
+
const g = m === 0, k = m === l.length - 1;
|
|
674
|
+
let T = d;
|
|
675
675
|
if (!g) {
|
|
676
|
-
const
|
|
677
|
-
|
|
676
|
+
const p = d.match(/^ +/), y = p ? p[0].length : 0;
|
|
677
|
+
y > 0 && (T = T.substring(y));
|
|
678
678
|
}
|
|
679
|
-
if (!
|
|
680
|
-
const
|
|
681
|
-
|
|
679
|
+
if (!k) {
|
|
680
|
+
const p = T.match(/ +$/), y = p ? p[0].length : 0;
|
|
681
|
+
y > 0 && (T = T.substring(0, T.length - y));
|
|
682
682
|
}
|
|
683
683
|
let w = h + x;
|
|
684
684
|
t.textAlign === "center" ? w = h + ((r == null ? void 0 : r.width) ?? 100) / 2 : t.textAlign === "right" && (w = h + ((r == null ? void 0 : r.width) ?? 100) - x);
|
|
685
|
-
const b =
|
|
686
|
-
if (
|
|
687
|
-
const
|
|
688
|
-
let
|
|
689
|
-
if (t.textAlign === "center" ?
|
|
690
|
-
const
|
|
691
|
-
e.fillRect(
|
|
685
|
+
const b = f + c.ascent + m * u;
|
|
686
|
+
if (Jt(e, T, w, b, s), T.length > 0) {
|
|
687
|
+
const p = at(e.measureText(T).width, T, s);
|
|
688
|
+
let y = w;
|
|
689
|
+
if (t.textAlign === "center" ? y -= p / 2 : t.textAlign === "right" && (y -= p), t.underline) {
|
|
690
|
+
const C = b + t.fontSize * 0.1;
|
|
691
|
+
e.fillRect(y, C, p, Math.max(1, t.fontSize * 0.05));
|
|
692
692
|
}
|
|
693
693
|
if (t.strikethrough) {
|
|
694
|
-
const
|
|
695
|
-
e.fillRect(
|
|
694
|
+
const C = b - c.ascent * 0.4;
|
|
695
|
+
e.fillRect(y, C, p, Math.max(1, t.fontSize * 0.05));
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
698
|
});
|
|
699
699
|
}
|
|
700
700
|
e.restore();
|
|
701
701
|
}
|
|
702
|
-
function
|
|
702
|
+
function to(e, t) {
|
|
703
703
|
var s;
|
|
704
704
|
const r = t.opacity ?? 1, n = !!((s = t.stroke) != null && s.enabled), o = t.type === "custom";
|
|
705
705
|
if (r < 1 && n && o) {
|
|
706
|
-
|
|
706
|
+
Fr(e, t, r);
|
|
707
707
|
return;
|
|
708
708
|
}
|
|
709
709
|
const i = e.globalAlpha;
|
|
710
710
|
r !== 1 && (e.globalAlpha = r), Ft(e, t), e.globalAlpha = i;
|
|
711
711
|
}
|
|
712
|
-
function
|
|
713
|
-
var
|
|
714
|
-
const n = t.transformData, o = t.fontSize || 24, i = ((
|
|
712
|
+
function Fr(e, t, r) {
|
|
713
|
+
var k;
|
|
714
|
+
const n = t.transformData, o = t.fontSize || 24, i = ((k = t.stroke) == null ? void 0 : k.width) || 0, s = ((n == null ? void 0 : n.width) ?? o * t.text.length * 0.7) + i * 2 + 40, l = o * 3 + i * 2 + 40, a = e.getTransform(), c = Math.max(Math.abs(a.a), Math.abs(a.d), 1), h = Math.ceil(s * c), f = Math.ceil(l * c);
|
|
715
715
|
let u;
|
|
716
|
-
typeof OffscreenCanvas < "u" ? u = new OffscreenCanvas(h,
|
|
717
|
-
const
|
|
718
|
-
if (!
|
|
716
|
+
typeof OffscreenCanvas < "u" ? u = new OffscreenCanvas(h, f) : (u = document.createElement("canvas"), u.width = h, u.height = f);
|
|
717
|
+
const d = u.getContext("2d");
|
|
718
|
+
if (!d) {
|
|
719
719
|
const T = e.globalAlpha;
|
|
720
720
|
e.globalAlpha = r, Ft(e, t), e.globalAlpha = T;
|
|
721
721
|
return;
|
|
722
722
|
}
|
|
723
|
-
const
|
|
724
|
-
|
|
723
|
+
const m = a.a * t.x + a.e, g = a.d * t.y + a.f;
|
|
724
|
+
d.setTransform(
|
|
725
725
|
a.a,
|
|
726
726
|
a.b,
|
|
727
727
|
a.c,
|
|
728
728
|
a.d,
|
|
729
|
-
a.e -
|
|
730
|
-
a.f - g +
|
|
731
|
-
), Ft(
|
|
729
|
+
a.e - m + h / 2,
|
|
730
|
+
a.f - g + f / 2
|
|
731
|
+
), Ft(d, t), e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.globalAlpha = r, e.drawImage(u, m - h / 2, g - f / 2), e.restore();
|
|
732
732
|
}
|
|
733
733
|
function Ft(e, t) {
|
|
734
734
|
switch (t.type) {
|
|
@@ -736,28 +736,28 @@ function Ft(e, t) {
|
|
|
736
736
|
Wt(e, t);
|
|
737
737
|
break;
|
|
738
738
|
case "circle":
|
|
739
|
-
|
|
739
|
+
Re(e, t);
|
|
740
740
|
break;
|
|
741
741
|
case "wave":
|
|
742
|
-
|
|
742
|
+
We(e, t);
|
|
743
743
|
break;
|
|
744
744
|
case "arch":
|
|
745
|
-
|
|
745
|
+
Fe(e, t);
|
|
746
746
|
break;
|
|
747
747
|
case "ascend":
|
|
748
|
-
|
|
748
|
+
Ue(e, t);
|
|
749
749
|
break;
|
|
750
750
|
case "lean":
|
|
751
751
|
Be(e, t);
|
|
752
752
|
break;
|
|
753
753
|
case "flag":
|
|
754
|
-
|
|
754
|
+
Oe(e, t);
|
|
755
755
|
break;
|
|
756
756
|
default:
|
|
757
757
|
Rt.warn(`[canvas-renderer] Unsupported transform type: ${t.type}`), Wt(e, t);
|
|
758
758
|
}
|
|
759
759
|
}
|
|
760
|
-
function
|
|
760
|
+
function Ur(e, t) {
|
|
761
761
|
if (typeof OffscreenCanvas < "u")
|
|
762
762
|
return new OffscreenCanvas(e, t);
|
|
763
763
|
const r = document.createElement("canvas");
|
|
@@ -777,43 +777,43 @@ function rt(e, t, r) {
|
|
|
777
777
|
r(e, t);
|
|
778
778
|
return;
|
|
779
779
|
}
|
|
780
|
-
const c = t.fontSize || 24, h = n.width || 0,
|
|
781
|
-
if (
|
|
780
|
+
const c = t.fontSize || 24, h = n.width || 0, f = t.transformData, u = c * t.text.length * 0.7, d = f.width ?? (f.radius ? f.radius * 2 : 0), m = Math.max(d, u), g = (n.feather || 0) * 2, k = h * 4 + g + c + 40, T = m + k, w = f.archHeight ? Math.abs(f.archHeight) * c * 2 : 0, b = f.radius ? f.radius : 0, p = c * 3 + k + w + b, y = e.getTransform(), C = Math.max(Math.abs(y.a), Math.abs(y.d), 1), M = Math.ceil(T * C / 2) * 2, S = Math.ceil(p * C / 2) * 2;
|
|
781
|
+
if (M <= 0 || S <= 0) {
|
|
782
782
|
r(e, t);
|
|
783
783
|
return;
|
|
784
784
|
}
|
|
785
|
-
const P =
|
|
785
|
+
const P = Ur(M, S), v = P.getContext("2d");
|
|
786
786
|
if (!v) {
|
|
787
787
|
r(e, t);
|
|
788
788
|
return;
|
|
789
789
|
}
|
|
790
|
-
const A = t.x || 0, I = t.y || 0, E =
|
|
790
|
+
const A = t.x || 0, I = t.y || 0, E = y.a * A + y.c * I + y.e, R = y.b * A + y.d * I + y.f, W = Math.round(E - M / 2), F = Math.round(R - S / 2);
|
|
791
791
|
if (v.setTransform(
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
792
|
+
y.a,
|
|
793
|
+
y.b,
|
|
794
|
+
y.c,
|
|
795
|
+
y.d,
|
|
796
|
+
M / 2 - E + y.e,
|
|
797
|
+
S / 2 - R + y.f
|
|
798
798
|
), l) {
|
|
799
799
|
v.globalAlpha = 1;
|
|
800
800
|
const $ = n.opacity;
|
|
801
801
|
s && (n.opacity = 1), r(v, t), s && (n.opacity = $), e.save(), e.resetTransform(), e.globalAlpha = i, e.drawImage(P, W, F), e.restore();
|
|
802
802
|
return;
|
|
803
803
|
}
|
|
804
|
-
const
|
|
805
|
-
n.opacity = 1, r(v, t), n.opacity =
|
|
806
|
-
const
|
|
807
|
-
n.enabled = !1, r(e, t), n.enabled =
|
|
804
|
+
const U = n.opacity;
|
|
805
|
+
n.opacity = 1, r(v, t), n.opacity = U;
|
|
806
|
+
const B = n.enabled;
|
|
807
|
+
n.enabled = !1, r(e, t), n.enabled = B, e.save(), e.resetTransform(), e.globalAlpha = o, e.drawImage(
|
|
808
808
|
P,
|
|
809
809
|
W,
|
|
810
810
|
F
|
|
811
811
|
), e.restore();
|
|
812
812
|
}
|
|
813
|
-
function
|
|
814
|
-
rt(e, t,
|
|
813
|
+
function Re(e, t) {
|
|
814
|
+
rt(e, t, Br);
|
|
815
815
|
}
|
|
816
|
-
function
|
|
816
|
+
function Br(e, t) {
|
|
817
817
|
const r = t.transformData;
|
|
818
818
|
e.save(), e.translate(t.x, t.y), e.rotate(-t.rotation * Math.PI / 180), e.scale(r.scale, r.scale);
|
|
819
819
|
const n = t.bold ? "bold" : "normal", o = t.italic ? "italic" : "normal";
|
|
@@ -822,84 +822,84 @@ function Rr(e, t) {
|
|
|
822
822
|
if (r.reverse) {
|
|
823
823
|
let a = Math.PI / 2 + l / (2 * r.radius);
|
|
824
824
|
i.forEach((c, h) => {
|
|
825
|
-
const u = s[h] / r.radius,
|
|
826
|
-
e.save(), e.translate(
|
|
825
|
+
const u = s[h] / r.radius, d = Math.cos(a - u / 2) * r.radius, m = Math.sin(a - u / 2) * r.radius;
|
|
826
|
+
e.save(), e.translate(d, m), e.rotate(a - u / 2 - Math.PI / 2), et(e, c, t.stroke), e.fillText(c, 0, 0), e.restore(), a -= u;
|
|
827
827
|
});
|
|
828
828
|
} else {
|
|
829
829
|
let a = -Math.PI / 2 - l / (2 * r.radius);
|
|
830
830
|
i.forEach((c, h) => {
|
|
831
|
-
const u = s[h] / r.radius,
|
|
832
|
-
e.save(), e.translate(
|
|
831
|
+
const u = s[h] / r.radius, d = Math.cos(a + u / 2) * r.radius, m = Math.sin(a + u / 2) * r.radius;
|
|
832
|
+
e.save(), e.translate(d, m), e.rotate(a + u / 2 + Math.PI / 2), et(e, c, t.stroke), e.fillText(c, 0, 0), e.restore(), a += u;
|
|
833
833
|
});
|
|
834
834
|
}
|
|
835
835
|
e.restore();
|
|
836
836
|
}
|
|
837
|
-
function
|
|
838
|
-
rt(e, t,
|
|
837
|
+
function We(e, t) {
|
|
838
|
+
rt(e, t, Or);
|
|
839
839
|
}
|
|
840
|
-
function
|
|
840
|
+
function Or(e, t) {
|
|
841
841
|
const r = t.transformData;
|
|
842
842
|
e.save(), e.translate(t.x, t.y), e.rotate(-t.rotation * Math.PI / 180), e.font = q(t.fontSize, t.fontFamily, t.bold, t.italic), e.fillStyle = t.color, e.textAlign = "center", e.textBaseline = "middle";
|
|
843
843
|
const n = t.text.split("");
|
|
844
844
|
let i = -n.reduce((s, l) => s + e.measureText(l).width, 0) / 2;
|
|
845
845
|
n.forEach((s) => {
|
|
846
|
-
const l = e.measureText(s).width, a = i + l / 2, c = a / (r.width / 2), h = r.amplitude * t.fontSize * Math.sin(r.frequency * Math.PI * c),
|
|
847
|
-
e.save(), e.translate(a, h), e.transform(1,
|
|
846
|
+
const l = e.measureText(s).width, a = i + l / 2, c = a / (r.width / 2), h = r.amplitude * t.fontSize * Math.sin(r.frequency * Math.PI * c), f = r.amplitude * r.frequency * Math.PI * Math.cos(r.frequency * Math.PI * c);
|
|
847
|
+
e.save(), e.translate(a, h), e.transform(1, f * xe, 0, 1, 0, 0), et(e, s, t.stroke), e.fillText(s, 0, 0), e.restore(), i += l;
|
|
848
848
|
}), e.restore();
|
|
849
849
|
}
|
|
850
|
-
function
|
|
851
|
-
rt(e, t,
|
|
850
|
+
function Fe(e, t) {
|
|
851
|
+
rt(e, t, Lr);
|
|
852
852
|
}
|
|
853
|
-
function
|
|
853
|
+
function Lr(e, t) {
|
|
854
854
|
const r = t.transformData;
|
|
855
855
|
e.save(), e.translate(t.x, t.y), e.rotate(-t.rotation * Math.PI / 180), e.font = q(t.fontSize, t.fontFamily, t.bold, t.italic), e.fillStyle = t.color, e.textAlign = "center", e.textBaseline = "middle";
|
|
856
856
|
const n = t.text.split(""), o = n.reduce((l, a) => l + e.measureText(a).width, 0), i = r.width / 2;
|
|
857
857
|
let s = -o / 2;
|
|
858
858
|
n.forEach((l) => {
|
|
859
|
-
const a = e.measureText(l).width, c = s + a / 2, h = c / i,
|
|
860
|
-
e.save(), e.translate(c,
|
|
859
|
+
const a = e.measureText(l).width, c = s + a / 2, h = c / i, f = (Math.pow(h, 2) - 1) * r.archHeight * t.fontSize, u = 2 * h * r.archHeight;
|
|
860
|
+
e.save(), e.translate(c, f), e.transform(1, u * 0.3, 0, 1, 0, 0), et(e, l, t.stroke), e.fillText(l, 0, 0), e.restore(), s += a;
|
|
861
861
|
}), e.restore();
|
|
862
862
|
}
|
|
863
|
-
function
|
|
864
|
-
rt(e, t,
|
|
863
|
+
function Ue(e, t) {
|
|
864
|
+
rt(e, t, qr);
|
|
865
865
|
}
|
|
866
|
-
function
|
|
866
|
+
function qr(e, t) {
|
|
867
867
|
const r = t.transformData;
|
|
868
868
|
e.save(), e.translate(t.x, t.y), e.rotate(-t.rotation * Math.PI / 180), e.font = q(t.fontSize, t.fontFamily, t.bold, t.italic), e.fillStyle = t.color, e.textAlign = "center", e.textBaseline = "middle";
|
|
869
869
|
const n = t.text.split(""), o = n.reduce((l, a) => l + e.measureText(a).width, 0), i = r.ascendAngle * Math.PI / 180;
|
|
870
870
|
let s = -o / 2;
|
|
871
871
|
n.forEach((l) => {
|
|
872
|
-
const a = e.measureText(l).width, c = s + a / 2, h = c * Math.tan(i),
|
|
873
|
-
e.save(), e.translate(c, h), e.transform(1,
|
|
872
|
+
const a = e.measureText(l).width, c = s + a / 2, h = c * Math.tan(i), f = Math.tan(i);
|
|
873
|
+
e.save(), e.translate(c, h), e.transform(1, f * 1, 0, 1, 0, 0), et(e, l, t.stroke), e.fillText(l, 0, 0), e.restore(), s += a;
|
|
874
874
|
}), e.restore();
|
|
875
875
|
}
|
|
876
876
|
function Be(e, t) {
|
|
877
|
-
rt(e, t,
|
|
877
|
+
rt(e, t, $r);
|
|
878
878
|
}
|
|
879
|
-
function
|
|
879
|
+
function $r(e, t) {
|
|
880
880
|
var o;
|
|
881
881
|
const r = t.transformData;
|
|
882
882
|
e.save(), e.translate(t.x, t.y), e.rotate(-t.rotation * Math.PI / 180);
|
|
883
883
|
const n = -r.leanAmount * Math.PI / 4;
|
|
884
884
|
e.transform(1, 0, Math.tan(n), 1, 0, 0), e.font = q(t.fontSize, t.fontFamily, t.bold, t.italic), e.fillStyle = t.color, e.textAlign = "center", e.textBaseline = "middle", (o = t.stroke) != null && o.enabled && (e.save(), e.strokeStyle = t.stroke.color, e.lineWidth = t.stroke.width, e.lineCap = t.stroke.lineCap || "round", e.lineJoin = t.stroke.lineJoin || "round", t.stroke.opacity !== void 0 && (e.globalAlpha = t.stroke.opacity), e.strokeText(t.text, 0, 0), e.restore()), e.fillText(t.text, 0, 0), e.restore();
|
|
885
885
|
}
|
|
886
|
-
function
|
|
887
|
-
rt(e, t,
|
|
886
|
+
function Oe(e, t) {
|
|
887
|
+
rt(e, t, Hr);
|
|
888
888
|
}
|
|
889
|
-
function
|
|
889
|
+
function Hr(e, t) {
|
|
890
890
|
const r = t.transformData;
|
|
891
891
|
e.save(), e.translate(t.x, t.y), e.rotate(-t.rotation * Math.PI / 180), e.font = q(t.fontSize, t.fontFamily, t.bold, t.italic), e.fillStyle = t.color, e.textAlign = "center", e.textBaseline = "middle";
|
|
892
892
|
const n = t.text.split("");
|
|
893
893
|
let i = -n.reduce((s, l) => s + e.measureText(l).width, 0) / 2;
|
|
894
894
|
n.forEach((s) => {
|
|
895
|
-
const l = e.measureText(s).width, a = i + l / 2, c = a / (r.width / 2), h = Math.abs(c),
|
|
895
|
+
const l = e.measureText(s).width, a = i + l / 2, c = a / (r.width / 2), h = Math.abs(c), f = r.amplitude * h, u = f * t.fontSize * Math.sin(r.frequency * Math.PI * c), d = f * r.frequency * Math.PI * Math.cos(r.frequency * Math.PI * c), m = r.amplitude * Math.sign(c) * Math.sin(r.frequency * Math.PI * c), g = d + m;
|
|
896
896
|
e.save(), e.translate(a, u), e.transform(1, g * 0.3, 0, 1, 0, 0), et(e, s, t.stroke), e.fillText(s, 0, 0), e.restore(), i += l;
|
|
897
897
|
}), e.restore();
|
|
898
898
|
}
|
|
899
899
|
function Q(e) {
|
|
900
900
|
return (t, r) => e(t, r);
|
|
901
901
|
}
|
|
902
|
-
function
|
|
902
|
+
function jr(e, t) {
|
|
903
903
|
e.save();
|
|
904
904
|
const r = e.canvas, n = r.width, o = r.height, i = e.getTransform(), s = [];
|
|
905
905
|
let l = [];
|
|
@@ -914,52 +914,52 @@ function Lr(e, t) {
|
|
|
914
914
|
c.width = n, c.height = o;
|
|
915
915
|
const h = c.getContext("2d");
|
|
916
916
|
if (!h) continue;
|
|
917
|
-
h.setTransform(i), a.content.forEach((
|
|
918
|
-
|
|
917
|
+
h.setTransform(i), a.content.forEach((d) => {
|
|
918
|
+
d.render(h, !1, !1);
|
|
919
919
|
});
|
|
920
|
-
const
|
|
921
|
-
|
|
922
|
-
const u =
|
|
920
|
+
const f = document.createElement("canvas");
|
|
921
|
+
f.width = n, f.height = o;
|
|
922
|
+
const u = f.getContext("2d");
|
|
923
923
|
if (!u) continue;
|
|
924
924
|
if (u.setTransform(i), a.mask.render(u, !1, !1), a.mask.transformType !== "image" && a.mask.transformType !== "shape") {
|
|
925
|
-
const
|
|
926
|
-
u.save(), u.fillStyle = "#FFFFFF", u.fillRect(
|
|
925
|
+
const d = a.mask.getBoundingBox();
|
|
926
|
+
u.save(), u.fillStyle = "#FFFFFF", u.fillRect(d.x, d.y, d.width, d.height), u.restore();
|
|
927
927
|
}
|
|
928
|
-
h.globalCompositeOperation = "destination-in", h.setTransform(1, 0, 0, 1, 0, 0), h.drawImage(
|
|
928
|
+
h.globalCompositeOperation = "destination-in", h.setTransform(1, 0, 0, 1, 0, 0), h.drawImage(f, 0, 0), e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(c, 0, 0), e.setTransform(i);
|
|
929
929
|
}
|
|
930
930
|
e.restore();
|
|
931
931
|
}
|
|
932
|
-
var
|
|
933
|
-
function
|
|
934
|
-
|
|
932
|
+
var se = !1;
|
|
933
|
+
function Qt() {
|
|
934
|
+
se || (se = !0, J("arch", Q(Fe)), J("ascend", Q(Ue)), J("circle", Q(Re)), J("flag", Q(Oe)), J("lean", Q(Be)), J("wave", Q(We)), J(
|
|
935
935
|
"custom",
|
|
936
936
|
(e, t) => Wt(e, t)
|
|
937
|
-
),
|
|
938
|
-
(e, t) =>
|
|
937
|
+
), tr(jr), pr(
|
|
938
|
+
(e, t) => kr(e, t)
|
|
939
939
|
), globalThis.__scElementPaintersInstalled = !0);
|
|
940
940
|
}
|
|
941
|
-
|
|
942
|
-
function
|
|
941
|
+
Qt();
|
|
942
|
+
function zt(e, t, r = {}) {
|
|
943
943
|
const n = r.mode || "both";
|
|
944
944
|
switch (e.save(), e.translate(t.x || 0, t.y || 0), e.rotate(-(t.rotation || 0) * Math.PI / 180), t.transformType) {
|
|
945
945
|
case "image":
|
|
946
|
-
|
|
946
|
+
Nr(e, t, n, r);
|
|
947
947
|
break;
|
|
948
948
|
case "shape":
|
|
949
|
-
|
|
949
|
+
Xr(e, t, n, r);
|
|
950
950
|
break;
|
|
951
951
|
case "group":
|
|
952
952
|
break;
|
|
953
953
|
default:
|
|
954
|
-
|
|
954
|
+
_r(e, t, n, r);
|
|
955
955
|
break;
|
|
956
956
|
}
|
|
957
957
|
e.restore();
|
|
958
958
|
}
|
|
959
|
-
function
|
|
959
|
+
function _r(e, t, r, n) {
|
|
960
960
|
var s;
|
|
961
961
|
const o = t, i = o.text || "";
|
|
962
|
-
i && ((r === "stroke" || r === "both") && ((s = t.stroke) != null && s.enabled) && (e.save(),
|
|
962
|
+
i && ((r === "stroke" || r === "both") && ((s = t.stroke) != null && s.enabled) && (e.save(), Ae(e, t, { ...n.renderingContext, positionApplied: !0 }), e.restore()), (r === "fill" || r === "both") && (e.save(), Ar(e, {
|
|
963
963
|
text: i,
|
|
964
964
|
fontSize: o.fontSize || 24,
|
|
965
965
|
fontFamily: o.fontFamily || "Arial",
|
|
@@ -970,12 +970,12 @@ function qr(e, t, r, n) {
|
|
|
970
970
|
letterSpacing: o.letterSpacing
|
|
971
971
|
}), e.restore()));
|
|
972
972
|
}
|
|
973
|
-
function
|
|
973
|
+
function Nr(e, t, r, n) {
|
|
974
974
|
var i;
|
|
975
975
|
if (!t.transformData) return;
|
|
976
976
|
const o = t.transformData;
|
|
977
977
|
if (r === "fill" || r === "both")
|
|
978
|
-
if (
|
|
978
|
+
if (Kr(e, t), n.loadedImage) {
|
|
979
979
|
e.save(), e.clip();
|
|
980
980
|
const s = o.flipHorizontal ? -1 : 1, l = o.flipVertical ? -1 : 1;
|
|
981
981
|
e.scale(s, l);
|
|
@@ -983,34 +983,34 @@ function $r(e, t, r, n) {
|
|
|
983
983
|
e.drawImage(n.loadedImage, -a / 2, -c / 2, a, c), e.restore();
|
|
984
984
|
} else
|
|
985
985
|
e.fillStyle = "#cccccc", e.fill();
|
|
986
|
-
(r === "stroke" || r === "both") && ((i = t.stroke) != null && i.enabled) && (e.save(),
|
|
986
|
+
(r === "stroke" || r === "both") && ((i = t.stroke) != null && i.enabled) && (e.save(), Mr(e, t, n.renderingContext), e.restore());
|
|
987
987
|
}
|
|
988
|
-
function
|
|
988
|
+
function Xr(e, t, r, n) {
|
|
989
989
|
var s, l;
|
|
990
990
|
if (!t.transformData) return;
|
|
991
991
|
const o = t.transformData, i = ((s = n.renderingContext) == null ? void 0 : s.isKnockout) === !0;
|
|
992
|
-
e.beginPath(),
|
|
992
|
+
e.beginPath(), Le(e, o), (r === "fill" || r === "both") && (e.fillStyle = i ? "#000000" : er(e, o), e.globalAlpha = i ? 1 : o.fillOpacity ?? 1, e.fill()), (r === "stroke" || r === "both") && ((l = t.stroke) != null && l.enabled) && (e.save(), Jr(e, t, n.renderingContext), e.restore());
|
|
993
993
|
}
|
|
994
|
-
function
|
|
994
|
+
function Le(e, t) {
|
|
995
995
|
const { shapeType: r } = t, n = t.width ?? 100, o = t.height ?? 100;
|
|
996
996
|
switch (r) {
|
|
997
997
|
case "rectangle":
|
|
998
|
-
|
|
998
|
+
ae(e, t, n, o);
|
|
999
999
|
break;
|
|
1000
1000
|
case "circle":
|
|
1001
|
-
|
|
1001
|
+
Gr(e, Math.min(n, o) / 2);
|
|
1002
1002
|
break;
|
|
1003
1003
|
case "ellipse":
|
|
1004
|
-
|
|
1004
|
+
Yr(e, n / 2, o / 2);
|
|
1005
1005
|
break;
|
|
1006
1006
|
case "star":
|
|
1007
|
-
|
|
1007
|
+
Vr(e, t, Math.min(n, o) / 2);
|
|
1008
1008
|
break;
|
|
1009
1009
|
default:
|
|
1010
|
-
|
|
1010
|
+
ae(e, t, n, o);
|
|
1011
1011
|
}
|
|
1012
1012
|
}
|
|
1013
|
-
function
|
|
1013
|
+
function ae(e, t, r, n) {
|
|
1014
1014
|
const o = t.borderRadius || 0, i = -r / 2, s = -n / 2;
|
|
1015
1015
|
if (o > 0) {
|
|
1016
1016
|
const l = Math.min(o / 100 * Math.min(r, n), r / 2, n / 2);
|
|
@@ -1018,27 +1018,27 @@ function oe(e, t, r, n) {
|
|
|
1018
1018
|
} else
|
|
1019
1019
|
e.rect(i, s, r, n);
|
|
1020
1020
|
}
|
|
1021
|
-
function
|
|
1021
|
+
function Gr(e, t) {
|
|
1022
1022
|
e.arc(0, 0, t, 0, Math.PI * 2);
|
|
1023
1023
|
}
|
|
1024
|
-
function
|
|
1024
|
+
function Yr(e, t, r) {
|
|
1025
1025
|
e.ellipse(0, 0, t, r, 0, 0, Math.PI * 2);
|
|
1026
1026
|
}
|
|
1027
|
-
function
|
|
1027
|
+
function Vr(e, t, r) {
|
|
1028
1028
|
const n = Math.max(3, Math.min(20, t.points || 5)), o = Math.max(0.1, Math.min(0.9, t.innerRadius || 0.4)), i = r * o, s = Math.PI / n, l = -Math.PI / 2;
|
|
1029
1029
|
for (let a = 0; a < n * 2; a++) {
|
|
1030
|
-
const c = l + s * a, h = a % 2 === 0 ? r : i,
|
|
1031
|
-
a === 0 ? e.moveTo(
|
|
1030
|
+
const c = l + s * a, h = a % 2 === 0 ? r : i, f = Math.cos(c) * h, u = Math.sin(c) * h;
|
|
1031
|
+
a === 0 ? e.moveTo(f, u) : e.lineTo(f, u);
|
|
1032
1032
|
}
|
|
1033
1033
|
e.closePath();
|
|
1034
1034
|
}
|
|
1035
|
-
function
|
|
1035
|
+
function Jr(e, t, r) {
|
|
1036
1036
|
var o;
|
|
1037
1037
|
if (!((o = t.stroke) != null && o.enabled) || !t.transformData) return;
|
|
1038
1038
|
const n = (r == null ? void 0 : r.isKnockout) === !0;
|
|
1039
|
-
e.save(), n ? (e.strokeStyle = "#000000", e.lineWidth = t.stroke.width, e.lineCap = t.stroke.lineCap || "butt", e.lineJoin = t.stroke.lineJoin || "miter", e.globalAlpha = 1) : (e.strokeStyle = t.stroke.color, e.lineWidth = t.stroke.width, e.lineCap = t.stroke.lineCap || "butt", e.lineJoin = t.stroke.lineJoin || "miter", t.stroke.opacity !== void 0 && (e.globalAlpha = t.stroke.opacity)), t.stroke.miterLimit !== void 0 && (e.miterLimit = t.stroke.miterLimit), t.stroke.dashArray && t.stroke.dashArray.length > 0 && e.setLineDash(t.stroke.dashArray), !n && t.stroke.feather && t.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${t.stroke.feather}px)`), e.beginPath(),
|
|
1039
|
+
e.save(), n ? (e.strokeStyle = "#000000", e.lineWidth = t.stroke.width, e.lineCap = t.stroke.lineCap || "butt", e.lineJoin = t.stroke.lineJoin || "miter", e.globalAlpha = 1) : (e.strokeStyle = t.stroke.color, e.lineWidth = t.stroke.width, e.lineCap = t.stroke.lineCap || "butt", e.lineJoin = t.stroke.lineJoin || "miter", t.stroke.opacity !== void 0 && (e.globalAlpha = t.stroke.opacity)), t.stroke.miterLimit !== void 0 && (e.miterLimit = t.stroke.miterLimit), t.stroke.dashArray && t.stroke.dashArray.length > 0 && e.setLineDash(t.stroke.dashArray), !n && t.stroke.feather && t.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${t.stroke.feather}px)`), e.beginPath(), Le(e, t.transformData), e.stroke(), e.restore();
|
|
1040
1040
|
}
|
|
1041
|
-
function
|
|
1041
|
+
function Kr(e, t) {
|
|
1042
1042
|
if (!t.transformData) return;
|
|
1043
1043
|
const { borderRadius: r } = t.transformData, n = t.transformData.width ?? 100, o = t.transformData.height ?? 100, i = -n / 2, s = -o / 2;
|
|
1044
1044
|
if (e.beginPath(), r && r > 0) {
|
|
@@ -1047,7 +1047,7 @@ function Gr(e, t) {
|
|
|
1047
1047
|
} else
|
|
1048
1048
|
e.rect(i, s, n, o);
|
|
1049
1049
|
}
|
|
1050
|
-
function
|
|
1050
|
+
function Ut(e, t, r, n, o, i, s = "destination-out") {
|
|
1051
1051
|
var b;
|
|
1052
1052
|
if (!t.knockoutParts) return;
|
|
1053
1053
|
if (!(t.knockoutParts.fill || t.knockoutParts.stroke)) {
|
|
@@ -1056,23 +1056,23 @@ function Bt(e, t, r, n, o, i, s = "destination-out") {
|
|
|
1056
1056
|
}
|
|
1057
1057
|
const a = e.getTransform();
|
|
1058
1058
|
e.save();
|
|
1059
|
-
const c = t.knockoutParts.scope || "group", h =
|
|
1059
|
+
const c = t.knockoutParts.scope || "group", h = Qr(t, c, r);
|
|
1060
1060
|
if (h.length === 0 && c === "artboard") {
|
|
1061
|
-
|
|
1061
|
+
Zr(e, t, n), e.restore();
|
|
1062
1062
|
return;
|
|
1063
1063
|
}
|
|
1064
1064
|
if (h.length === 0) {
|
|
1065
1065
|
n(e, t), e.restore();
|
|
1066
1066
|
return;
|
|
1067
1067
|
}
|
|
1068
|
-
const
|
|
1068
|
+
const f = e.canvas, d = e.getTransform().a, m = Dr(f.width, f.height), g = m.getContext("2d");
|
|
1069
1069
|
if (!g) return;
|
|
1070
|
-
g.scale(
|
|
1071
|
-
for (const
|
|
1072
|
-
n(g,
|
|
1073
|
-
t.knockoutParts.fill && !t.knockoutParts.stroke && ((b = t.stroke) != null && b.enabled) && (g.save(), Ot(g, t), g.restore()), g.save(), g.globalCompositeOperation = s, t.knockoutParts.fill &&
|
|
1074
|
-
const
|
|
1075
|
-
e.drawImage(
|
|
1070
|
+
g.scale(d, d), o && i && (g.fillStyle = o, g.fillRect(i.x, i.y, i.width, i.height));
|
|
1071
|
+
for (const p of h)
|
|
1072
|
+
n(g, p);
|
|
1073
|
+
t.knockoutParts.fill && !t.knockoutParts.stroke && ((b = t.stroke) != null && b.enabled) && (g.save(), Ot(g, t), g.restore()), g.save(), g.globalCompositeOperation = s, t.knockoutParts.fill && Bt(g, t), t.knockoutParts.stroke && Ot(g, t), g.restore(), t.knockoutParts.fill || (g.save(), Bt(g, t), g.restore());
|
|
1074
|
+
const k = f.width / d, T = f.height / d;
|
|
1075
|
+
e.drawImage(m, 0, 0, k, T), e.restore();
|
|
1076
1076
|
const w = e.getTransform();
|
|
1077
1077
|
(Math.abs(w.a - a.a) > 1e-3 || Math.abs(w.d - a.d) > 1e-3 || Math.abs(w.e - a.e) > 1e-3 || Math.abs(w.f - a.f) > 1e-3) && e.setTransform(
|
|
1078
1078
|
a.a,
|
|
@@ -1083,59 +1083,59 @@ function Bt(e, t, r, n, o, i, s = "destination-out") {
|
|
|
1083
1083
|
a.f
|
|
1084
1084
|
);
|
|
1085
1085
|
}
|
|
1086
|
-
function
|
|
1087
|
-
|
|
1086
|
+
function eo(e, t, r, n, o, i) {
|
|
1087
|
+
Ut(e, t, r, n, o, i, "destination-out");
|
|
1088
1088
|
}
|
|
1089
|
-
function
|
|
1090
|
-
return t === "artboard" ?
|
|
1089
|
+
function Qr(e, t, r) {
|
|
1090
|
+
return t === "artboard" ? qe(e, r) : zr(e, r);
|
|
1091
1091
|
}
|
|
1092
|
-
function
|
|
1092
|
+
function qe(e, t) {
|
|
1093
1093
|
const r = t.findIndex((n) => n.id === e.id);
|
|
1094
1094
|
return r === -1 ? [] : t.slice(0, r);
|
|
1095
1095
|
}
|
|
1096
|
-
function
|
|
1097
|
-
const r =
|
|
1096
|
+
function zr(e, t) {
|
|
1097
|
+
const r = $e(e, t);
|
|
1098
1098
|
if (!r)
|
|
1099
|
-
return
|
|
1099
|
+
return qe(e, t);
|
|
1100
1100
|
if (r.transformType !== "group" || !r.children)
|
|
1101
1101
|
return [];
|
|
1102
1102
|
const n = r.children.findIndex((o) => o.id === e.id);
|
|
1103
1103
|
return n === -1 ? [] : r.children.slice(0, n);
|
|
1104
1104
|
}
|
|
1105
|
-
function
|
|
1105
|
+
function $e(e, t) {
|
|
1106
1106
|
for (const r of t)
|
|
1107
1107
|
if (r.transformType === "group" && r.children) {
|
|
1108
1108
|
if (r.children.some((o) => o.id === e.id))
|
|
1109
1109
|
return r;
|
|
1110
|
-
const n =
|
|
1110
|
+
const n = $e(e, r.children);
|
|
1111
1111
|
if (n)
|
|
1112
1112
|
return n;
|
|
1113
1113
|
}
|
|
1114
1114
|
return null;
|
|
1115
1115
|
}
|
|
1116
|
-
function
|
|
1117
|
-
|
|
1116
|
+
function Bt(e, t, r) {
|
|
1117
|
+
zt(e, t, {
|
|
1118
1118
|
mode: "fill",
|
|
1119
1119
|
renderingContext: { isKnockout: !0 }
|
|
1120
1120
|
});
|
|
1121
1121
|
}
|
|
1122
1122
|
function Ot(e, t) {
|
|
1123
1123
|
var r;
|
|
1124
|
-
(r = t.stroke) != null && r.enabled &&
|
|
1124
|
+
(r = t.stroke) != null && r.enabled && zt(e, t, {
|
|
1125
1125
|
mode: "stroke",
|
|
1126
1126
|
renderingContext: { isKnockout: !0 }
|
|
1127
1127
|
});
|
|
1128
1128
|
}
|
|
1129
|
-
function
|
|
1129
|
+
function Zr(e, t, r) {
|
|
1130
1130
|
var o;
|
|
1131
1131
|
const n = t.knockoutParts;
|
|
1132
1132
|
if (!n) {
|
|
1133
1133
|
r(e, t);
|
|
1134
1134
|
return;
|
|
1135
1135
|
}
|
|
1136
|
-
n.fill || (e.save(),
|
|
1136
|
+
n.fill || (e.save(), Bt(e, t), e.restore()), !n.stroke && ((o = t.stroke) != null && o.enabled) && (e.save(), Ot(e, t), e.restore());
|
|
1137
1137
|
}
|
|
1138
|
-
function
|
|
1138
|
+
function Dr(e, t) {
|
|
1139
1139
|
if (typeof OffscreenCanvas < "u")
|
|
1140
1140
|
return new OffscreenCanvas(e, t);
|
|
1141
1141
|
if (typeof document < "u") {
|
|
@@ -1144,7 +1144,7 @@ function Kr(e, t) {
|
|
|
1144
1144
|
}
|
|
1145
1145
|
throw new Error("No canvas context available");
|
|
1146
1146
|
}
|
|
1147
|
-
function
|
|
1147
|
+
function ie(e, t, r, n, o = 0) {
|
|
1148
1148
|
if (r <= 0 || n <= 0 || e <= 0 || t <= 0)
|
|
1149
1149
|
return { width: e + o, height: t + o };
|
|
1150
1150
|
const i = r / n, s = e / t;
|
|
@@ -1155,27 +1155,27 @@ function se(e, t, r, n, o = 0) {
|
|
|
1155
1155
|
};
|
|
1156
1156
|
}
|
|
1157
1157
|
const ot = 64, Ct = 512;
|
|
1158
|
-
function
|
|
1158
|
+
function xr(e, t) {
|
|
1159
1159
|
e.beginPath(), e.arc(t / 2, t / 2, t * 0.45, 0, Math.PI * 2), e.fill();
|
|
1160
1160
|
}
|
|
1161
|
-
function
|
|
1161
|
+
function tn(e, t) {
|
|
1162
1162
|
const r = t / 2, n = t / 2, o = t * 0.45, i = o * 0.4, s = 5;
|
|
1163
1163
|
e.beginPath();
|
|
1164
1164
|
for (let l = 0; l < s * 2; l++) {
|
|
1165
|
-
const a = -Math.PI / 2 + Math.PI / s * l, c = l % 2 === 0 ? o : i, h = r + Math.cos(a) * c,
|
|
1166
|
-
l === 0 ? e.moveTo(h,
|
|
1165
|
+
const a = -Math.PI / 2 + Math.PI / s * l, c = l % 2 === 0 ? o : i, h = r + Math.cos(a) * c, f = n + Math.sin(a) * c;
|
|
1166
|
+
l === 0 ? e.moveTo(h, f) : e.lineTo(h, f);
|
|
1167
1167
|
}
|
|
1168
1168
|
e.closePath(), e.fill();
|
|
1169
1169
|
}
|
|
1170
|
-
function
|
|
1170
|
+
function en(e, t) {
|
|
1171
1171
|
const r = t / 2, n = t * 0.42;
|
|
1172
1172
|
e.beginPath(), e.moveTo(r, t * 0.82), e.bezierCurveTo(r - n * 1.1, t * 0.6, r - n * 1.3, t * 0.2, r, t * 0.35), e.bezierCurveTo(r + n * 1.3, t * 0.2, r + n * 1.1, t * 0.6, r, t * 0.82), e.closePath(), e.fill();
|
|
1173
1173
|
}
|
|
1174
|
-
function
|
|
1174
|
+
function rn(e, t) {
|
|
1175
1175
|
const r = t / 2, n = t / 2, o = t * 0.4, i = t * 0.48;
|
|
1176
1176
|
e.beginPath(), e.moveTo(r, n - i), e.lineTo(r + o, n), e.lineTo(r, n + i), e.lineTo(r - o, n), e.closePath(), e.fill();
|
|
1177
1177
|
}
|
|
1178
|
-
function
|
|
1178
|
+
function nn(e, t) {
|
|
1179
1179
|
const r = t / 2, n = t / 2, o = t * 0.44;
|
|
1180
1180
|
e.beginPath();
|
|
1181
1181
|
for (let i = 0; i < 6; i++) {
|
|
@@ -1184,11 +1184,11 @@ function xr(e, t) {
|
|
|
1184
1184
|
}
|
|
1185
1185
|
e.closePath(), e.fill();
|
|
1186
1186
|
}
|
|
1187
|
-
function
|
|
1187
|
+
function on(e, t) {
|
|
1188
1188
|
const r = t / 2, n = t * 0.4, o = t * 0.12;
|
|
1189
1189
|
e.beginPath(), e.moveTo(r, o), e.lineTo(r + n, t * 0.25), e.lineTo(r + n, t * 0.55), e.quadraticCurveTo(r + n * 0.3, t * 0.8, r, t * 0.9), e.quadraticCurveTo(r - n * 0.3, t * 0.8, r - n, t * 0.55), e.lineTo(r - n, t * 0.25), e.closePath(), e.fill();
|
|
1190
1190
|
}
|
|
1191
|
-
function
|
|
1191
|
+
function sn(e, t) {
|
|
1192
1192
|
const r = t / 2, n = t / 2;
|
|
1193
1193
|
let o = 42;
|
|
1194
1194
|
const i = () => (o = (o * 16807 + 0) % 2147483647, o / 2147483647);
|
|
@@ -1198,7 +1198,7 @@ function en(e, t) {
|
|
|
1198
1198
|
e.beginPath(), e.arc(r + Math.cos(l) * a, n + Math.sin(l) * a, c, 0, Math.PI * 2), e.fill();
|
|
1199
1199
|
}
|
|
1200
1200
|
}
|
|
1201
|
-
function
|
|
1201
|
+
function an(e, t) {
|
|
1202
1202
|
let r = 123;
|
|
1203
1203
|
const n = () => (r = (r * 16807 + 0) % 2147483647, r / 2147483647), o = t * 0.08, i = 40;
|
|
1204
1204
|
e.beginPath(), e.moveTo(o, o);
|
|
@@ -1220,7 +1220,7 @@ function rn(e, t) {
|
|
|
1220
1220
|
}
|
|
1221
1221
|
e.closePath(), e.fill();
|
|
1222
1222
|
}
|
|
1223
|
-
function
|
|
1223
|
+
function ln(e, t) {
|
|
1224
1224
|
let r = 77;
|
|
1225
1225
|
const n = () => (r = (r * 16807 + 0) % 2147483647, r / 2147483647), o = t * 0.25, i = t * 0.75, s = t * 0.1;
|
|
1226
1226
|
e.beginPath(), e.moveTo(s, o + n() * t * 0.05);
|
|
@@ -1234,110 +1234,117 @@ function nn(e, t) {
|
|
|
1234
1234
|
}
|
|
1235
1235
|
e.closePath(), e.fill();
|
|
1236
1236
|
}
|
|
1237
|
-
function
|
|
1237
|
+
function cn(e, t) {
|
|
1238
1238
|
const r = t / 2, n = t * 0.55;
|
|
1239
1239
|
e.beginPath(), e.arc(r, n, t * 0.2, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(r - t * 0.18, n + t * 0.02, t * 0.15, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(r + t * 0.18, n + t * 0.02, t * 0.16, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(r - t * 0.06, n - t * 0.14, t * 0.14, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(r + t * 0.1, n - t * 0.12, t * 0.12, 0, Math.PI * 2), e.fill();
|
|
1240
1240
|
}
|
|
1241
|
-
const
|
|
1241
|
+
const hn = [
|
|
1242
1242
|
// Geometric
|
|
1243
|
-
{ id: "circle", name: "Circle", description: "Perfect circle", imageUrl: "builtin-mask:circle", thumbnailUrl: "", category: "geometric", draw:
|
|
1244
|
-
{ id: "star", name: "Star", description: "5-pointed star", imageUrl: "builtin-mask:star", thumbnailUrl: "", category: "geometric", draw:
|
|
1245
|
-
{ id: "heart", name: "Heart", description: "Heart shape", imageUrl: "builtin-mask:heart", thumbnailUrl: "", category: "geometric", draw:
|
|
1246
|
-
{ id: "diamond", name: "Diamond", description: "Diamond/rhombus", imageUrl: "builtin-mask:diamond", thumbnailUrl: "", category: "geometric", draw:
|
|
1247
|
-
{ id: "hexagon", name: "Hexagon", description: "Regular hexagon", imageUrl: "builtin-mask:hexagon", thumbnailUrl: "", category: "geometric", draw:
|
|
1248
|
-
{ id: "shield", name: "Shield", description: "Shield/crest shape", imageUrl: "builtin-mask:shield", thumbnailUrl: "", category: "geometric", draw:
|
|
1243
|
+
{ id: "circle", name: "Circle", description: "Perfect circle", imageUrl: "builtin-mask:circle", thumbnailUrl: "", category: "geometric", draw: xr },
|
|
1244
|
+
{ id: "star", name: "Star", description: "5-pointed star", imageUrl: "builtin-mask:star", thumbnailUrl: "", category: "geometric", draw: tn },
|
|
1245
|
+
{ id: "heart", name: "Heart", description: "Heart shape", imageUrl: "builtin-mask:heart", thumbnailUrl: "", category: "geometric", draw: en },
|
|
1246
|
+
{ id: "diamond", name: "Diamond", description: "Diamond/rhombus", imageUrl: "builtin-mask:diamond", thumbnailUrl: "", category: "geometric", draw: rn },
|
|
1247
|
+
{ id: "hexagon", name: "Hexagon", description: "Regular hexagon", imageUrl: "builtin-mask:hexagon", thumbnailUrl: "", category: "geometric", draw: nn },
|
|
1248
|
+
{ id: "shield", name: "Shield", description: "Shield/crest shape", imageUrl: "builtin-mask:shield", thumbnailUrl: "", category: "geometric", draw: on },
|
|
1249
1249
|
// Organic
|
|
1250
|
-
{ id: "splatter", name: "Splatter", description: "Ink splatter", imageUrl: "builtin-mask:splatter", thumbnailUrl: "", category: "organic", draw:
|
|
1251
|
-
{ id: "torn-edge", name: "Torn Edge", description: "Rough torn paper edge", imageUrl: "builtin-mask:torn-edge", thumbnailUrl: "", category: "organic", draw:
|
|
1252
|
-
{ id: "paint-stroke", name: "Paint Stroke", description: "Horizontal brush stroke", imageUrl: "builtin-mask:paint-stroke", thumbnailUrl: "", category: "organic", draw:
|
|
1253
|
-
{ id: "cloud", name: "Cloud", description: "Soft cloud shape", imageUrl: "builtin-mask:cloud", thumbnailUrl: "", category: "organic", draw:
|
|
1250
|
+
{ id: "splatter", name: "Splatter", description: "Ink splatter", imageUrl: "builtin-mask:splatter", thumbnailUrl: "", category: "organic", draw: sn },
|
|
1251
|
+
{ id: "torn-edge", name: "Torn Edge", description: "Rough torn paper edge", imageUrl: "builtin-mask:torn-edge", thumbnailUrl: "", category: "organic", draw: an },
|
|
1252
|
+
{ id: "paint-stroke", name: "Paint Stroke", description: "Horizontal brush stroke", imageUrl: "builtin-mask:paint-stroke", thumbnailUrl: "", category: "organic", draw: ln },
|
|
1253
|
+
{ id: "cloud", name: "Cloud", description: "Soft cloud shape", imageUrl: "builtin-mask:cloud", thumbnailUrl: "", category: "organic", draw: cn }
|
|
1254
1254
|
];
|
|
1255
|
-
let
|
|
1256
|
-
function
|
|
1255
|
+
let le = !1;
|
|
1256
|
+
function ce(e, t) {
|
|
1257
1257
|
if (typeof document > "u") return null;
|
|
1258
1258
|
const r = document.createElement("canvas");
|
|
1259
1259
|
return r.width = e, r.height = t, r;
|
|
1260
1260
|
}
|
|
1261
|
-
function
|
|
1262
|
-
if (typeof document > "u" ||
|
|
1263
|
-
|
|
1261
|
+
function fn() {
|
|
1262
|
+
if (typeof document > "u" || le) return;
|
|
1263
|
+
le = !0;
|
|
1264
1264
|
const e = Tt.getInstance();
|
|
1265
|
-
for (const t of
|
|
1266
|
-
const r =
|
|
1265
|
+
for (const t of hn) {
|
|
1266
|
+
const r = ce(Ct, Ct);
|
|
1267
1267
|
if (!r) continue;
|
|
1268
1268
|
const n = r.getContext("2d");
|
|
1269
1269
|
if (!n) continue;
|
|
1270
1270
|
n.fillStyle = "white", t.draw(n, Ct);
|
|
1271
1271
|
const o = r.toDataURL("image/png"), i = e.acquire(t.imageUrl);
|
|
1272
1272
|
i.crossOrigin = "anonymous", i.src = o;
|
|
1273
|
-
const s =
|
|
1273
|
+
const s = ce(ot, ot);
|
|
1274
1274
|
if (s) {
|
|
1275
1275
|
const l = s.getContext("2d");
|
|
1276
1276
|
l && (l.fillStyle = "#1a1a2e", l.fillRect(0, 0, ot, ot), l.fillStyle = "white", t.draw(l, ot), t.thumbnailUrl = s.toDataURL("image/png"));
|
|
1277
1277
|
}
|
|
1278
1278
|
}
|
|
1279
1279
|
}
|
|
1280
|
-
const
|
|
1281
|
-
function
|
|
1280
|
+
const dn = j("MaskRenderer"), Lt = /* @__PURE__ */ new Map(), un = /* @__PURE__ */ new Map();
|
|
1281
|
+
function ro(e) {
|
|
1282
1282
|
const t = [];
|
|
1283
1283
|
Lt.forEach((r, n) => {
|
|
1284
1284
|
n.startsWith(e) && t.push(n);
|
|
1285
1285
|
}), t.forEach((r) => Lt.delete(r));
|
|
1286
1286
|
}
|
|
1287
|
-
function
|
|
1287
|
+
function no() {
|
|
1288
1288
|
Lt.clear();
|
|
1289
1289
|
}
|
|
1290
|
-
function
|
|
1290
|
+
function he(e, t, r) {
|
|
1291
1291
|
if (!t.masks || t.masks.length === 0) {
|
|
1292
1292
|
r(e);
|
|
1293
1293
|
return;
|
|
1294
1294
|
}
|
|
1295
1295
|
const n = e.canvas, o = pt(n.width, n.height), i = o.getContext("2d");
|
|
1296
1296
|
if (!i) {
|
|
1297
|
-
|
|
1297
|
+
dn.error("[renderWithMasks] Failed to get offscreen context");
|
|
1298
1298
|
return;
|
|
1299
1299
|
}
|
|
1300
1300
|
const s = e.getTransform();
|
|
1301
1301
|
i.setTransform(s), r(i);
|
|
1302
1302
|
for (const l of t.masks)
|
|
1303
|
-
|
|
1303
|
+
gn(i, l, t);
|
|
1304
1304
|
e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(o, 0, 0), e.restore();
|
|
1305
1305
|
}
|
|
1306
|
-
function
|
|
1306
|
+
function gn(e, t, r) {
|
|
1307
1307
|
switch (t.type) {
|
|
1308
1308
|
case "clip":
|
|
1309
|
-
|
|
1309
|
+
pn(e, t, r);
|
|
1310
1310
|
break;
|
|
1311
1311
|
case "alpha":
|
|
1312
|
-
|
|
1312
|
+
mn(e, t, r);
|
|
1313
1313
|
break;
|
|
1314
1314
|
case "luma":
|
|
1315
|
-
|
|
1315
|
+
yn(e, t, r);
|
|
1316
1316
|
break;
|
|
1317
1317
|
case "distress":
|
|
1318
|
-
|
|
1318
|
+
wn(e, t, r);
|
|
1319
1319
|
break;
|
|
1320
1320
|
}
|
|
1321
1321
|
}
|
|
1322
|
-
function
|
|
1322
|
+
function pn(e, t, r) {
|
|
1323
1323
|
e.save(), e.globalCompositeOperation = t.inverted ? "destination-out" : "destination-in", t.opacity !== void 0 && (e.globalAlpha = t.opacity), vt(e, t.maskElement, r), e.restore();
|
|
1324
1324
|
}
|
|
1325
|
-
function
|
|
1326
|
-
e.save(), e.globalCompositeOperation = t.inverted ? "destination-out" : "destination-in", t.opacity !== void 0 && (e.globalAlpha = t.opacity), vt(e, t.maskElement, r), t.feather && t.feather > 0 &&
|
|
1325
|
+
function mn(e, t, r) {
|
|
1326
|
+
e.save(), e.globalCompositeOperation = t.inverted ? "destination-out" : "destination-in", t.opacity !== void 0 && (e.globalAlpha = t.opacity), vt(e, t.maskElement, r), t.feather && t.feather > 0 && He(e, t.feather), e.restore();
|
|
1327
1327
|
}
|
|
1328
|
-
function
|
|
1328
|
+
function yn(e, t, r) {
|
|
1329
1329
|
const n = pt(e.canvas.width, e.canvas.height), o = n.getContext("2d");
|
|
1330
1330
|
if (!o) return;
|
|
1331
1331
|
vt(o, t.maskElement, r);
|
|
1332
1332
|
const i = o.getImageData(0, 0, n.width, n.height), s = i.data;
|
|
1333
1333
|
for (let l = 0; l < s.length; l += 4) {
|
|
1334
|
-
const a = s[l], c = s[l + 1], h = s[l + 2],
|
|
1335
|
-
s[l + 3] = t.inverted ? 255 -
|
|
1334
|
+
const a = s[l], c = s[l + 1], h = s[l + 2], f = 0.299 * a + 0.587 * c + 0.114 * h;
|
|
1335
|
+
s[l + 3] = t.inverted ? 255 - f : f;
|
|
1336
1336
|
}
|
|
1337
1337
|
o.putImageData(i, 0, 0), e.save(), e.globalCompositeOperation = "destination-in", t.opacity !== void 0 && (e.globalAlpha = t.opacity), e.drawImage(n, 0, 0), e.restore();
|
|
1338
1338
|
}
|
|
1339
|
-
function
|
|
1340
|
-
e.save(), e.globalCompositeOperation = t.inverted ? "destination-in" : "destination-out", t.opacity !== void 0 && (e.globalAlpha = t.opacity), vt(e, t.maskElement, r), t.feather && t.feather > 0 &&
|
|
1339
|
+
function wn(e, t, r) {
|
|
1340
|
+
e.save(), e.globalCompositeOperation = t.inverted ? "destination-in" : "destination-out", t.opacity !== void 0 && (e.globalAlpha = t.opacity), vt(e, t.maskElement, r), t.feather && t.feather > 0 && He(e, t.feather), e.restore();
|
|
1341
|
+
}
|
|
1342
|
+
function kn(e) {
|
|
1343
|
+
const t = e.transformData, r = e, n = t && t.type === "image" ? rr(t, Se(e)) : null;
|
|
1344
|
+
return {
|
|
1345
|
+
width: (n == null ? void 0 : n.width) || (t == null ? void 0 : t.width) || r.width || 0,
|
|
1346
|
+
height: (n == null ? void 0 : n.height) || (t == null ? void 0 : t.height) || r.height || 0
|
|
1347
|
+
};
|
|
1341
1348
|
}
|
|
1342
1349
|
function vt(e, t, r) {
|
|
1343
1350
|
const n = r.x || 0, o = r.y || 0, i = t.x || 0, s = t.y || 0, l = {
|
|
@@ -1346,52 +1353,52 @@ function vt(e, t, r) {
|
|
|
1346
1353
|
y: o + s,
|
|
1347
1354
|
// Inherit parent rotation so mask rotates with the element
|
|
1348
1355
|
rotation: (t.rotation || 0) + (r.rotation || 0)
|
|
1349
|
-
}, a = 4,
|
|
1350
|
-
|
|
1356
|
+
}, a = 4, { width: c, height: h } = kn(r), f = t.transformData;
|
|
1357
|
+
c && h && f && (l.transformData = {
|
|
1351
1358
|
...f,
|
|
1352
|
-
width:
|
|
1353
|
-
height:
|
|
1359
|
+
width: c + a,
|
|
1360
|
+
height: h + a
|
|
1354
1361
|
});
|
|
1355
|
-
let
|
|
1362
|
+
let u, d;
|
|
1356
1363
|
if (t.transformType === "image") {
|
|
1357
|
-
const
|
|
1358
|
-
if (
|
|
1364
|
+
const w = t;
|
|
1365
|
+
if (w.imageUrl)
|
|
1359
1366
|
if (typeof document < "u") {
|
|
1360
|
-
|
|
1361
|
-
const
|
|
1362
|
-
|
|
1367
|
+
w.imageUrl.startsWith("builtin-mask:") && fn();
|
|
1368
|
+
const b = Tt.getInstance(), p = b.acquire(w.imageUrl);
|
|
1369
|
+
p.complete && p.naturalWidth > 0 && (u = p), b.release(w.imageUrl);
|
|
1363
1370
|
} else
|
|
1364
|
-
|
|
1371
|
+
d = un.get(w.imageUrl);
|
|
1365
1372
|
}
|
|
1366
|
-
const m = l.transformData,
|
|
1367
|
-
if (
|
|
1373
|
+
const m = l.transformData, g = (f == null ? void 0 : f.width) || 0, k = (f == null ? void 0 : f.height) || 0, T = g > 0 && k > 0 && c > 0 && h > 0 && Math.abs(g / k - c / h) > 1e-3;
|
|
1374
|
+
if (d) {
|
|
1368
1375
|
e.save();
|
|
1369
|
-
const
|
|
1370
|
-
if (e.translate(l.x || 0, l.y || 0), e.rotate(-(l.rotation || 0) * Math.PI / 180),
|
|
1371
|
-
const
|
|
1372
|
-
y,
|
|
1373
|
-
p,
|
|
1374
|
-
T,
|
|
1376
|
+
const w = (m == null ? void 0 : m.width) || d.width, b = (m == null ? void 0 : m.height) || d.height;
|
|
1377
|
+
if (e.translate(l.x || 0, l.y || 0), e.rotate(-(l.rotation || 0) * Math.PI / 180), T) {
|
|
1378
|
+
const p = ie(
|
|
1375
1379
|
w,
|
|
1380
|
+
b,
|
|
1381
|
+
g,
|
|
1382
|
+
k,
|
|
1376
1383
|
0
|
|
1377
1384
|
);
|
|
1378
|
-
e.drawImage(
|
|
1385
|
+
e.drawImage(d, -p.width / 2, -p.height / 2, p.width, p.height);
|
|
1379
1386
|
} else
|
|
1380
|
-
e.drawImage(
|
|
1387
|
+
e.drawImage(d, -w / 2, -b / 2, w, b);
|
|
1381
1388
|
e.restore();
|
|
1382
|
-
} else if (
|
|
1383
|
-
const
|
|
1384
|
-
y,
|
|
1385
|
-
p,
|
|
1386
|
-
T,
|
|
1389
|
+
} else if (T && u) {
|
|
1390
|
+
const w = (m == null ? void 0 : m.width) || c, b = (m == null ? void 0 : m.height) || h, p = ie(
|
|
1387
1391
|
w,
|
|
1392
|
+
b,
|
|
1393
|
+
g,
|
|
1394
|
+
k,
|
|
1388
1395
|
0
|
|
1389
1396
|
);
|
|
1390
|
-
e.save(), e.translate(l.x || 0, l.y || 0), e.rotate(-(l.rotation || 0) * Math.PI / 180), e.drawImage(
|
|
1397
|
+
e.save(), e.translate(l.x || 0, l.y || 0), e.rotate(-(l.rotation || 0) * Math.PI / 180), e.drawImage(u, -p.width / 2, -p.height / 2, p.width, p.height), e.restore();
|
|
1391
1398
|
} else
|
|
1392
|
-
|
|
1399
|
+
zt(e, l, { mode: "both", loadedImage: u });
|
|
1393
1400
|
}
|
|
1394
|
-
function
|
|
1401
|
+
function He(e, t) {
|
|
1395
1402
|
"filter" in e && (e.filter = `blur(${t}px)`);
|
|
1396
1403
|
}
|
|
1397
1404
|
function pt(e, t) {
|
|
@@ -1403,75 +1410,75 @@ function pt(e, t) {
|
|
|
1403
1410
|
}
|
|
1404
1411
|
throw new Error("No canvas context available");
|
|
1405
1412
|
}
|
|
1406
|
-
function
|
|
1413
|
+
function bn(e, t, r, n) {
|
|
1407
1414
|
if (!t.enabled || !t.imageUrl || t.opacity <= 0) return;
|
|
1408
1415
|
const o = Tt.getInstance(), i = o.acquire(t.imageUrl);
|
|
1409
1416
|
if (!i.complete || i.naturalWidth === 0) {
|
|
1410
1417
|
o.release(t.imageUrl);
|
|
1411
1418
|
return;
|
|
1412
1419
|
}
|
|
1413
|
-
const { x: s, y: l, width: a, height: c } = r, h = e.getTransform(),
|
|
1414
|
-
if (g <= 0 ||
|
|
1420
|
+
const { x: s, y: l, width: a, height: c } = r, h = e.getTransform(), f = h.a * s + h.e, u = h.d * l + h.f, d = h.a * a, m = h.d * c, g = Math.ceil(d), k = Math.ceil(m);
|
|
1421
|
+
if (g <= 0 || k <= 0) {
|
|
1415
1422
|
o.release(t.imageUrl);
|
|
1416
1423
|
return;
|
|
1417
1424
|
}
|
|
1418
|
-
const T = pt(g,
|
|
1425
|
+
const T = pt(g, k), w = T.getContext("2d");
|
|
1419
1426
|
if (!w) {
|
|
1420
1427
|
o.release(t.imageUrl);
|
|
1421
1428
|
return;
|
|
1422
1429
|
}
|
|
1423
1430
|
w.drawImage(
|
|
1424
1431
|
e.canvas,
|
|
1425
|
-
d,
|
|
1426
|
-
u,
|
|
1427
1432
|
f,
|
|
1428
|
-
|
|
1433
|
+
u,
|
|
1434
|
+
d,
|
|
1435
|
+
m,
|
|
1429
1436
|
0,
|
|
1430
1437
|
0,
|
|
1431
1438
|
g,
|
|
1432
|
-
|
|
1439
|
+
k
|
|
1433
1440
|
);
|
|
1434
1441
|
let b;
|
|
1435
1442
|
if (t.maskType === "luma" ? b = "destination-in" : b = t.inverted ? "destination-out" : "destination-in", t.maskType === "luma") {
|
|
1436
|
-
const
|
|
1437
|
-
if (
|
|
1438
|
-
|
|
1439
|
-
const
|
|
1440
|
-
for (let
|
|
1441
|
-
const P = 0.299 *
|
|
1442
|
-
|
|
1443
|
+
const p = pt(g, k), y = p.getContext("2d");
|
|
1444
|
+
if (y) {
|
|
1445
|
+
y.drawImage(i, 0, 0, g, k);
|
|
1446
|
+
const C = y.getImageData(0, 0, g, k), M = C.data;
|
|
1447
|
+
for (let S = 0; S < M.length; S += 4) {
|
|
1448
|
+
const P = 0.299 * M[S] + 0.587 * M[S + 1] + 0.114 * M[S + 2];
|
|
1449
|
+
M[S + 3] = t.inverted ? 255 - P : P;
|
|
1443
1450
|
}
|
|
1444
|
-
|
|
1451
|
+
y.putImageData(C, 0, 0), w.globalCompositeOperation = "destination-in", w.globalAlpha = t.opacity / 100, w.drawImage(p, 0, 0);
|
|
1445
1452
|
}
|
|
1446
1453
|
} else
|
|
1447
|
-
w.globalCompositeOperation = b, w.globalAlpha = t.opacity / 100, w.drawImage(i, 0, 0, g,
|
|
1448
|
-
w.globalCompositeOperation = "source-over", w.globalAlpha = 1, e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(
|
|
1454
|
+
w.globalCompositeOperation = b, w.globalAlpha = t.opacity / 100, w.drawImage(i, 0, 0, g, k);
|
|
1455
|
+
w.globalCompositeOperation = "source-over", w.globalAlpha = 1, e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(f, u, d, m), n && (e.fillStyle = n, e.fillRect(f, u, d, m)), e.drawImage(T, f, u), e.restore(), o.release(t.imageUrl);
|
|
1449
1456
|
}
|
|
1450
|
-
function
|
|
1457
|
+
function Tn(e) {
|
|
1451
1458
|
var t;
|
|
1452
|
-
return e ? ((t = e.shadow) == null ? void 0 : t.enabled) === !0 ||
|
|
1459
|
+
return e ? ((t = e.shadow) == null ? void 0 : t.enabled) === !0 || Me(e.blendMode) : !1;
|
|
1453
1460
|
}
|
|
1454
|
-
function
|
|
1461
|
+
function fe(e, t, r) {
|
|
1455
1462
|
var c;
|
|
1456
|
-
if (!
|
|
1463
|
+
if (!Tn(t)) {
|
|
1457
1464
|
r(e);
|
|
1458
1465
|
return;
|
|
1459
1466
|
}
|
|
1460
|
-
const n = (c = t.shadow) != null && c.enabled ? t.shadow : void 0, o =
|
|
1467
|
+
const n = (c = t.shadow) != null && c.enabled ? t.shadow : void 0, o = Me(t.blendMode) ? t.blendMode : void 0, i = e.canvas, s = e.getTransform(), l = En(i.width, i.height), a = l.getContext("2d");
|
|
1461
1468
|
if (!a)
|
|
1462
1469
|
throw new Error(
|
|
1463
1470
|
"[canvas] renderWithLayerEffects: could not acquire a 2D context for the layer-effects raster"
|
|
1464
1471
|
);
|
|
1465
1472
|
if (a.setTransform(s), r(a), e.save(), e.setTransform(1, 0, 0, 1, 0, 0), o && (e.globalCompositeOperation = o), n) {
|
|
1466
|
-
const h = Math.hypot(s.a, s.b) || 1,
|
|
1467
|
-
e.save(), e.globalAlpha = e.globalAlpha *
|
|
1473
|
+
const h = Math.hypot(s.a, s.b) || 1, f = i.width + 1;
|
|
1474
|
+
e.save(), e.globalAlpha = e.globalAlpha * vn(n.opacity ?? 1), e.shadowColor = n.color, e.shadowBlur = n.blur * h, e.shadowOffsetX = n.offsetX * h + f, e.shadowOffsetY = n.offsetY * h, e.drawImage(l, -f, 0), e.restore();
|
|
1468
1475
|
}
|
|
1469
1476
|
e.drawImage(l, 0, 0), e.restore();
|
|
1470
1477
|
}
|
|
1471
|
-
function
|
|
1478
|
+
function vn(e) {
|
|
1472
1479
|
return Math.min(1, Math.max(0, e));
|
|
1473
1480
|
}
|
|
1474
|
-
function
|
|
1481
|
+
function En(e, t) {
|
|
1475
1482
|
if (typeof OffscreenCanvas < "u")
|
|
1476
1483
|
return new OffscreenCanvas(e, t);
|
|
1477
1484
|
if (typeof document < "u") {
|
|
@@ -1480,7 +1487,7 @@ function wn(e, t) {
|
|
|
1480
1487
|
}
|
|
1481
1488
|
throw new Error("No canvas context available");
|
|
1482
1489
|
}
|
|
1483
|
-
class
|
|
1490
|
+
class Sn {
|
|
1484
1491
|
constructor(t = Math.random()) {
|
|
1485
1492
|
this.perm = [];
|
|
1486
1493
|
for (let n = 0; n < 256; n++)
|
|
@@ -1519,23 +1526,23 @@ class kn {
|
|
|
1519
1526
|
}
|
|
1520
1527
|
}
|
|
1521
1528
|
function Pt(e, t, r, n = Date.now()) {
|
|
1522
|
-
const s = Et(e, t).getContext("2d").createImageData(e, t), l = s.data, a = new
|
|
1523
|
-
for (let
|
|
1529
|
+
const s = Et(e, t).getContext("2d").createImageData(e, t), l = s.data, a = new Sn(n), c = 0.02, h = 1 - r / 100;
|
|
1530
|
+
for (let f = 0; f < t; f++)
|
|
1524
1531
|
for (let u = 0; u < e; u++) {
|
|
1525
|
-
const
|
|
1526
|
-
let
|
|
1527
|
-
|
|
1528
|
-
const g = Math.min(u / e, (e - u) / e) * 2,
|
|
1529
|
-
|
|
1530
|
-
const w =
|
|
1531
|
-
l[
|
|
1532
|
+
const d = (f * e + u) * 4;
|
|
1533
|
+
let m = 0;
|
|
1534
|
+
m += a.noise(u * c, f * c) * 0.5, m += a.noise(u * c * 2, f * c * 2) * 0.25, m += a.noise(u * c * 4, f * c * 4) * 0.125, m = (m + 1) / 2;
|
|
1535
|
+
const g = Math.min(u / e, (e - u) / e) * 2, k = Math.min(f / t, (t - f) / t) * 2, T = Math.min(g, k);
|
|
1536
|
+
m *= 0.7 + T * 0.3;
|
|
1537
|
+
const w = m > h ? 255 : 0;
|
|
1538
|
+
l[d] = 255, l[d + 1] = 255, l[d + 2] = 255, l[d + 3] = w;
|
|
1532
1539
|
}
|
|
1533
1540
|
return s;
|
|
1534
1541
|
}
|
|
1535
|
-
function
|
|
1542
|
+
function Mn(e, t, r, n = Date.now()) {
|
|
1536
1543
|
const i = Et(e, t).getContext("2d");
|
|
1537
1544
|
i.clearRect(0, 0, e, t), i.strokeStyle = "#000000", i.lineWidth = 1 + r / 50, i.lineCap = "round";
|
|
1538
|
-
const s =
|
|
1545
|
+
const s = Zt(n), l = Math.floor(r / 100 * 30 + 5);
|
|
1539
1546
|
for (let a = 0; a < l; a++) {
|
|
1540
1547
|
const c = s() * e, h = s() * t;
|
|
1541
1548
|
qt(i, c, h, s() * Math.PI * 2, 50 + s() * 100, s, 0);
|
|
@@ -1555,23 +1562,23 @@ function qt(e, t, r, n, o, i, s) {
|
|
|
1555
1562
|
}
|
|
1556
1563
|
}
|
|
1557
1564
|
function gt(e, t, r, n = Date.now()) {
|
|
1558
|
-
const s = Et(e, t).getContext("2d").createImageData(e, t), l = s.data, a =
|
|
1565
|
+
const s = Et(e, t).getContext("2d").createImageData(e, t), l = s.data, a = Zt(n), c = r / 100 * 0.5;
|
|
1559
1566
|
for (let h = 0; h < t; h++)
|
|
1560
|
-
for (let
|
|
1561
|
-
const u = (h * e +
|
|
1562
|
-
l[u] = 0, l[u + 1] = 0, l[u + 2] = 0, l[u + 3] =
|
|
1567
|
+
for (let f = 0; f < e; f++) {
|
|
1568
|
+
const u = (h * e + f) * 4, m = a() < c ? 255 : 0;
|
|
1569
|
+
l[u] = 0, l[u + 1] = 0, l[u + 2] = 0, l[u + 3] = m;
|
|
1563
1570
|
}
|
|
1564
1571
|
return s;
|
|
1565
1572
|
}
|
|
1566
|
-
function
|
|
1573
|
+
function Cn(e, t, r, n = Date.now()) {
|
|
1567
1574
|
const i = Et(e, t).getContext("2d");
|
|
1568
1575
|
i.fillStyle = "#000000";
|
|
1569
|
-
const s =
|
|
1576
|
+
const s = Zt(n), l = 4 + r / 100 * 6, a = l * 2;
|
|
1570
1577
|
for (let c = 0; c < t; c += a)
|
|
1571
1578
|
for (let h = 0; h < e; h += a)
|
|
1572
1579
|
if (s() < r / 100) {
|
|
1573
|
-
const
|
|
1574
|
-
i.beginPath(), i.arc(h, c,
|
|
1580
|
+
const f = l * (0.5 + s() * 0.5);
|
|
1581
|
+
i.beginPath(), i.arc(h, c, f / 2, 0, Math.PI * 2), i.fill();
|
|
1575
1582
|
}
|
|
1576
1583
|
return i.getImageData(0, 0, e, t);
|
|
1577
1584
|
}
|
|
@@ -1584,7 +1591,7 @@ function Et(e, t) {
|
|
|
1584
1591
|
}
|
|
1585
1592
|
throw new Error("No canvas context available");
|
|
1586
1593
|
}
|
|
1587
|
-
function
|
|
1594
|
+
function Zt(e) {
|
|
1588
1595
|
let t = Math.sin(e++) * 1e4;
|
|
1589
1596
|
return () => (t = Math.sin(e++) * 1e4, t - Math.floor(t));
|
|
1590
1597
|
}
|
|
@@ -1595,13 +1602,13 @@ function $t(e) {
|
|
|
1595
1602
|
t[r] = 255, t[r + 1] = 255, t[r + 2] = 255;
|
|
1596
1603
|
return e;
|
|
1597
1604
|
}
|
|
1598
|
-
function
|
|
1605
|
+
function Pn(e, t) {
|
|
1599
1606
|
const r = e.data, n = t.data;
|
|
1600
1607
|
for (let o = 0; o < r.length; o += 4)
|
|
1601
1608
|
r[o] = 255, r[o + 1] = 255, r[o + 2] = 255, r[o + 3] = Math.min(255, r[o + 3] + n[o + 3]);
|
|
1602
1609
|
return e;
|
|
1603
1610
|
}
|
|
1604
|
-
const
|
|
1611
|
+
const In = [
|
|
1605
1612
|
{
|
|
1606
1613
|
id: "grunge-heavy",
|
|
1607
1614
|
name: "Heavy Grunge",
|
|
@@ -1642,7 +1649,7 @@ const En = [
|
|
|
1642
1649
|
description: "Noise + splatter combined",
|
|
1643
1650
|
generate: (e, t) => {
|
|
1644
1651
|
const r = Pt(e, t, 45, H + 4), n = gt(e, t, 35, H + 5);
|
|
1645
|
-
return
|
|
1652
|
+
return Pn($t(r), $t(n));
|
|
1646
1653
|
}
|
|
1647
1654
|
},
|
|
1648
1655
|
{
|
|
@@ -1651,7 +1658,7 @@ const En = [
|
|
|
1651
1658
|
textureUrl: "builtin:scratches",
|
|
1652
1659
|
thumbnailUrl: "",
|
|
1653
1660
|
description: "Branching crack lines",
|
|
1654
|
-
generate: (e, t) =>
|
|
1661
|
+
generate: (e, t) => Mn(e, t, 55, H + 6)
|
|
1655
1662
|
},
|
|
1656
1663
|
{
|
|
1657
1664
|
id: "halftone",
|
|
@@ -1659,7 +1666,7 @@ const En = [
|
|
|
1659
1666
|
textureUrl: "builtin:halftone",
|
|
1660
1667
|
thumbnailUrl: "",
|
|
1661
1668
|
description: "Dot grid pattern",
|
|
1662
|
-
generate: (e, t) =>
|
|
1669
|
+
generate: (e, t) => Cn(e, t, 55, H + 7)
|
|
1663
1670
|
},
|
|
1664
1671
|
{
|
|
1665
1672
|
id: "spray",
|
|
@@ -1670,25 +1677,25 @@ const En = [
|
|
|
1670
1677
|
generate: (e, t) => gt(e, t, 55, H + 8)
|
|
1671
1678
|
}
|
|
1672
1679
|
];
|
|
1673
|
-
let
|
|
1674
|
-
function
|
|
1680
|
+
let de = !1;
|
|
1681
|
+
function An(e, t) {
|
|
1675
1682
|
if (typeof OffscreenCanvas < "u")
|
|
1676
1683
|
return new OffscreenCanvas(e, t);
|
|
1677
1684
|
const r = document.createElement("canvas");
|
|
1678
1685
|
return r.width = e, r.height = t, r;
|
|
1679
1686
|
}
|
|
1680
|
-
function
|
|
1687
|
+
function ue(e, t) {
|
|
1681
1688
|
if (typeof document > "u") return null;
|
|
1682
1689
|
const r = document.createElement("canvas");
|
|
1683
1690
|
return r.width = e, r.height = t, r;
|
|
1684
1691
|
}
|
|
1685
|
-
function
|
|
1686
|
-
const t =
|
|
1692
|
+
function Rn(e) {
|
|
1693
|
+
const t = ue(e.width, e.height);
|
|
1687
1694
|
if (!t) return "";
|
|
1688
1695
|
const r = t.getContext("2d");
|
|
1689
1696
|
if (!r) return "";
|
|
1690
1697
|
r.putImageData(e, 0, 0);
|
|
1691
|
-
const n =
|
|
1698
|
+
const n = ue(Z, Z);
|
|
1692
1699
|
if (!n) return "";
|
|
1693
1700
|
const o = n.getContext("2d");
|
|
1694
1701
|
if (!o) return "";
|
|
@@ -1700,82 +1707,82 @@ function Mn(e) {
|
|
|
1700
1707
|
}
|
|
1701
1708
|
return o.putImageData(i, 0, 0), n.toDataURL("image/png");
|
|
1702
1709
|
}
|
|
1703
|
-
function
|
|
1704
|
-
if (!
|
|
1705
|
-
|
|
1706
|
-
for (const e of
|
|
1710
|
+
function Wn() {
|
|
1711
|
+
if (!de) {
|
|
1712
|
+
de = !0;
|
|
1713
|
+
for (const e of In) {
|
|
1707
1714
|
const t = e.generate(z, z);
|
|
1708
1715
|
$t(t);
|
|
1709
|
-
const r =
|
|
1710
|
-
n && (n.putImageData(t, 0, 0),
|
|
1716
|
+
const r = An(z, z), n = r.getContext("2d");
|
|
1717
|
+
n && (n.putImageData(t, 0, 0), Fn(e.textureUrl, r, z, z)), typeof document < "u" && (e.thumbnailUrl = Rn(t));
|
|
1711
1718
|
}
|
|
1712
1719
|
}
|
|
1713
1720
|
}
|
|
1714
|
-
const
|
|
1715
|
-
function
|
|
1721
|
+
const N = /* @__PURE__ */ new Set(), X = /* @__PURE__ */ new Map(), mt = /* @__PURE__ */ new Map();
|
|
1722
|
+
function ge(e, t) {
|
|
1716
1723
|
if (typeof OffscreenCanvas < "u")
|
|
1717
1724
|
return new OffscreenCanvas(e, t);
|
|
1718
1725
|
const r = document.createElement("canvas");
|
|
1719
1726
|
return r.width = e, r.height = t, r;
|
|
1720
1727
|
}
|
|
1721
|
-
function
|
|
1728
|
+
function pe(e) {
|
|
1722
1729
|
return e.getContext("2d");
|
|
1723
1730
|
}
|
|
1724
|
-
function
|
|
1725
|
-
const { width: t, height: r } = e, n =
|
|
1731
|
+
function me(e) {
|
|
1732
|
+
const { width: t, height: r } = e, n = ge(t, r), o = pe(n);
|
|
1726
1733
|
if (!o) throw new Error("Failed to get 2d context for temp canvas");
|
|
1727
1734
|
o.drawImage(e, 0, 0);
|
|
1728
1735
|
const i = o.getImageData(0, 0, t, r), s = i.data;
|
|
1729
1736
|
for (let c = 0; c < s.length; c += 4) {
|
|
1730
|
-
const h = s[c],
|
|
1731
|
-
s[c] = 255, s[c + 1] = 255, s[c + 2] = 255, s[c + 3] =
|
|
1737
|
+
const h = s[c], f = s[c + 1], u = s[c + 2], m = 255 - (0.299 * h + 0.587 * f + 0.114 * u);
|
|
1738
|
+
s[c] = 255, s[c + 1] = 255, s[c + 2] = 255, s[c + 3] = m;
|
|
1732
1739
|
}
|
|
1733
|
-
const l =
|
|
1740
|
+
const l = ge(t, r), a = pe(l);
|
|
1734
1741
|
if (!a) throw new Error("Failed to get 2d context for mask canvas");
|
|
1735
1742
|
return a.putImageData(i, 0, 0), { alphaMask: l, width: t, height: r };
|
|
1736
1743
|
}
|
|
1737
|
-
function
|
|
1744
|
+
function je(e) {
|
|
1738
1745
|
const t = X.get(e);
|
|
1739
1746
|
if (t) return t;
|
|
1740
1747
|
if (e.startsWith("builtin:")) {
|
|
1741
|
-
|
|
1748
|
+
Wn();
|
|
1742
1749
|
const r = X.get(e);
|
|
1743
1750
|
return r || null;
|
|
1744
1751
|
}
|
|
1745
|
-
return
|
|
1752
|
+
return N.has(e) || (N.add(e), _e(e)), null;
|
|
1746
1753
|
}
|
|
1747
|
-
function
|
|
1754
|
+
function oo(e) {
|
|
1748
1755
|
return X.has(e) ? Promise.resolve() : new Promise((t) => {
|
|
1749
1756
|
if (X.has(e)) {
|
|
1750
1757
|
t();
|
|
1751
1758
|
return;
|
|
1752
1759
|
}
|
|
1753
1760
|
const r = mt.get(e) || [];
|
|
1754
|
-
r.push(t), mt.set(e, r),
|
|
1761
|
+
r.push(t), mt.set(e, r), N.has(e) || (N.add(e), _e(e));
|
|
1755
1762
|
});
|
|
1756
1763
|
}
|
|
1757
|
-
function
|
|
1764
|
+
function Fn(e, t, r, n) {
|
|
1758
1765
|
X.has(e) || (X.set(e, { alphaMask: t, width: r, height: n }), st(e));
|
|
1759
1766
|
}
|
|
1760
1767
|
function st(e) {
|
|
1761
1768
|
const t = mt.get(e);
|
|
1762
1769
|
t && (t.forEach((r) => r()), mt.delete(e));
|
|
1763
1770
|
}
|
|
1764
|
-
function
|
|
1771
|
+
function _e(e) {
|
|
1765
1772
|
if (typeof document < "u") {
|
|
1766
1773
|
const t = new Image();
|
|
1767
1774
|
t.crossOrigin = "anonymous", t.onload = () => {
|
|
1768
|
-
const r =
|
|
1769
|
-
X.set(e, r),
|
|
1775
|
+
const r = me(t);
|
|
1776
|
+
X.set(e, r), N.delete(e), st(e);
|
|
1770
1777
|
}, t.onerror = () => {
|
|
1771
|
-
|
|
1778
|
+
N.delete(e), st(e);
|
|
1772
1779
|
}, t.src = e;
|
|
1773
1780
|
} else
|
|
1774
1781
|
fetch(e).then((t) => t.blob()).then((t) => createImageBitmap(t)).then((t) => {
|
|
1775
|
-
const r =
|
|
1776
|
-
X.set(e, r),
|
|
1782
|
+
const r = me(t);
|
|
1783
|
+
X.set(e, r), N.delete(e), st(e);
|
|
1777
1784
|
}).catch(() => {
|
|
1778
|
-
|
|
1785
|
+
N.delete(e), st(e);
|
|
1779
1786
|
});
|
|
1780
1787
|
}
|
|
1781
1788
|
function Ne(e, t) {
|
|
@@ -1784,84 +1791,84 @@ function Ne(e, t) {
|
|
|
1784
1791
|
const r = document.createElement("canvas");
|
|
1785
1792
|
return r.width = e, r.height = t, r;
|
|
1786
1793
|
}
|
|
1787
|
-
function
|
|
1794
|
+
function Un(e, t, r, n) {
|
|
1788
1795
|
if (!t.enabled || !t.textureUrl || t.intensity <= 0) return;
|
|
1789
|
-
const o =
|
|
1796
|
+
const o = je(t.textureUrl);
|
|
1790
1797
|
if (!o) return;
|
|
1791
|
-
const { x: i, y: s, width: l, height: a } = r, c = e.getTransform(), h = c.a * i + c.e,
|
|
1792
|
-
if (
|
|
1793
|
-
const
|
|
1798
|
+
const { x: i, y: s, width: l, height: a } = r, c = e.getTransform(), h = c.a * i + c.e, f = c.d * s + c.f, u = c.a * l, d = c.d * a, m = Math.ceil(u), g = Math.ceil(d);
|
|
1799
|
+
if (m <= 0 || g <= 0) return;
|
|
1800
|
+
const k = Ne(m, g), T = k.getContext("2d");
|
|
1794
1801
|
if (!T) return;
|
|
1795
1802
|
T.drawImage(
|
|
1796
1803
|
e.canvas,
|
|
1797
1804
|
h,
|
|
1798
|
-
d,
|
|
1799
|
-
u,
|
|
1800
1805
|
f,
|
|
1806
|
+
u,
|
|
1807
|
+
d,
|
|
1801
1808
|
0,
|
|
1802
1809
|
0,
|
|
1803
|
-
|
|
1810
|
+
m,
|
|
1804
1811
|
g
|
|
1805
1812
|
);
|
|
1806
1813
|
const w = o.alphaMask.getContext("2d");
|
|
1807
1814
|
if (w) {
|
|
1808
|
-
const b = t.intensity / 100,
|
|
1815
|
+
const b = t.intensity / 100, p = w.getImageData(0, 0, o.width, o.height).data, y = o.width, C = o.height, M = T.getImageData(0, 0, m, g), S = M.data;
|
|
1809
1816
|
for (let P = 0; P < g; P++) {
|
|
1810
|
-
const v = Math.floor(P / g *
|
|
1811
|
-
for (let A = 0; A <
|
|
1812
|
-
const I = Math.floor(A /
|
|
1813
|
-
|
|
1817
|
+
const v = Math.floor(P / g * C);
|
|
1818
|
+
for (let A = 0; A < m; A++) {
|
|
1819
|
+
const I = Math.floor(A / m * y), E = p[(v * y + I) * 4 + 3] / 255, R = (P * m + A) * 4;
|
|
1820
|
+
S[R + 3] = Math.round(S[R + 3] * (1 - E * b));
|
|
1814
1821
|
}
|
|
1815
1822
|
}
|
|
1816
|
-
T.putImageData(
|
|
1823
|
+
T.putImageData(M, 0, 0);
|
|
1817
1824
|
} else
|
|
1818
|
-
T.globalCompositeOperation = "destination-out", T.globalAlpha = t.intensity / 100, T.drawImage(o.alphaMask, 0, 0,
|
|
1819
|
-
T.globalAlpha = 1, e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(h,
|
|
1825
|
+
T.globalCompositeOperation = "destination-out", T.globalAlpha = t.intensity / 100, T.drawImage(o.alphaMask, 0, 0, m, g), T.globalCompositeOperation = "source-over";
|
|
1826
|
+
T.globalAlpha = 1, e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(h, f, u, d), n && (e.fillStyle = n, e.fillRect(h, f, u, d)), e.drawImage(k, h, f), e.restore();
|
|
1820
1827
|
}
|
|
1821
|
-
function
|
|
1828
|
+
function ye(e, t, r, n) {
|
|
1822
1829
|
if (!t.enabled || t.style !== "custom" || !t.textureUrl) return;
|
|
1823
|
-
const o =
|
|
1830
|
+
const o = je(t.textureUrl);
|
|
1824
1831
|
if (!o) {
|
|
1825
1832
|
n(e);
|
|
1826
1833
|
return;
|
|
1827
1834
|
}
|
|
1828
|
-
const i = t.textureOpacity ?? t.intensity / 100, s = e.getTransform(), l = Math.sqrt(r.width ** 2 + r.height ** 2), a = (l - r.width) / 2, c = (l - r.height) / 2, h = 20,
|
|
1829
|
-
x: r.x -
|
|
1835
|
+
const i = t.textureOpacity ?? t.intensity / 100, s = e.getTransform(), l = Math.sqrt(r.width ** 2 + r.height ** 2), a = (l - r.width) / 2, c = (l - r.height) / 2, h = 20, f = a + h, u = c + h, d = {
|
|
1836
|
+
x: r.x - f,
|
|
1830
1837
|
y: r.y - u,
|
|
1831
|
-
width: r.width +
|
|
1838
|
+
width: r.width + f * 2,
|
|
1832
1839
|
height: r.height + u * 2
|
|
1833
|
-
},
|
|
1840
|
+
}, m = s.a * d.x + s.e, g = s.d * d.y + s.f, k = s.a * d.width, T = s.d * d.height, w = Math.ceil(k), b = Math.ceil(T);
|
|
1834
1841
|
if (w <= 0 || b <= 0) {
|
|
1835
1842
|
n(e);
|
|
1836
1843
|
return;
|
|
1837
1844
|
}
|
|
1838
|
-
const
|
|
1839
|
-
if (!
|
|
1845
|
+
const p = Ne(w, b), y = p.getContext("2d");
|
|
1846
|
+
if (!y) {
|
|
1840
1847
|
n(e);
|
|
1841
1848
|
return;
|
|
1842
1849
|
}
|
|
1843
|
-
|
|
1850
|
+
y.setTransform(
|
|
1844
1851
|
s.a,
|
|
1845
1852
|
s.b,
|
|
1846
1853
|
s.c,
|
|
1847
1854
|
s.d,
|
|
1848
|
-
s.e -
|
|
1855
|
+
s.e - m,
|
|
1849
1856
|
s.f - g
|
|
1850
|
-
), n(
|
|
1851
|
-
const
|
|
1852
|
-
if (
|
|
1853
|
-
const
|
|
1857
|
+
), n(y), y.setTransform(1, 0, 0, 1, 0, 0);
|
|
1858
|
+
const C = o.alphaMask.getContext("2d");
|
|
1859
|
+
if (C) {
|
|
1860
|
+
const M = C.getImageData(0, 0, o.width, o.height).data, S = o.width, P = o.height, v = y.getImageData(0, 0, w, b), A = v.data;
|
|
1854
1861
|
for (let I = 0; I < b; I++) {
|
|
1855
1862
|
const E = Math.floor(I / b * P);
|
|
1856
1863
|
for (let R = 0; R < w; R++) {
|
|
1857
|
-
const W = Math.floor(R / w *
|
|
1858
|
-
A[
|
|
1864
|
+
const W = Math.floor(R / w * S), F = M[(E * S + W) * 4 + 3] / 255, U = (I * w + R) * 4;
|
|
1865
|
+
A[U + 3] = Math.round(A[U + 3] * (1 - F * i));
|
|
1859
1866
|
}
|
|
1860
1867
|
}
|
|
1861
|
-
|
|
1868
|
+
y.putImageData(v, 0, 0);
|
|
1862
1869
|
} else
|
|
1863
|
-
|
|
1864
|
-
e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(
|
|
1870
|
+
y.globalCompositeOperation = "destination-out", y.globalAlpha = i, y.drawImage(o.alphaMask, 0, 0, w, b), y.globalCompositeOperation = "source-over", y.globalAlpha = 1;
|
|
1871
|
+
e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(p, m, g), e.restore();
|
|
1865
1872
|
}
|
|
1866
1873
|
class yt {
|
|
1867
1874
|
/**
|
|
@@ -1876,33 +1883,33 @@ class yt {
|
|
|
1876
1883
|
const { transformType: r } = t;
|
|
1877
1884
|
switch (r) {
|
|
1878
1885
|
case "custom":
|
|
1879
|
-
return new
|
|
1886
|
+
return new fr(t);
|
|
1880
1887
|
case "distort":
|
|
1881
1888
|
throw new Error("DistortTransform is not yet implemented");
|
|
1882
1889
|
case "circle":
|
|
1883
|
-
return new
|
|
1890
|
+
return new hr(t);
|
|
1884
1891
|
case "lean":
|
|
1885
|
-
return new
|
|
1892
|
+
return new cr(t);
|
|
1886
1893
|
case "arch":
|
|
1887
|
-
return new
|
|
1894
|
+
return new lr(t);
|
|
1888
1895
|
case "ascend":
|
|
1889
|
-
return new
|
|
1896
|
+
return new ir(t);
|
|
1890
1897
|
case "wave":
|
|
1891
|
-
return new
|
|
1898
|
+
return new ar(t);
|
|
1892
1899
|
case "flag":
|
|
1893
|
-
return new
|
|
1900
|
+
return new sr(t);
|
|
1894
1901
|
case "image":
|
|
1895
1902
|
return new At(t);
|
|
1896
1903
|
case "group": {
|
|
1897
1904
|
const o = (t.children || []).map(
|
|
1898
1905
|
(a) => yt.createFromJSON(a)
|
|
1899
|
-
), { children: i, ...s } = t, l = new
|
|
1906
|
+
), { children: i, ...s } = t, l = new Yt(s);
|
|
1900
1907
|
return o.forEach((a) => l.addChild(a)), l;
|
|
1901
1908
|
}
|
|
1902
1909
|
case "shape":
|
|
1903
|
-
return new
|
|
1910
|
+
return new or(t);
|
|
1904
1911
|
case "path":
|
|
1905
|
-
return new
|
|
1912
|
+
return new nr(t);
|
|
1906
1913
|
default:
|
|
1907
1914
|
const n = r;
|
|
1908
1915
|
throw new Error(`Unknown transform type: ${n}`);
|
|
@@ -2116,7 +2123,7 @@ class yt {
|
|
|
2116
2123
|
return this.createFromJSON(r);
|
|
2117
2124
|
}
|
|
2118
2125
|
}
|
|
2119
|
-
const
|
|
2126
|
+
const we = j("ImportManager"), xt = class xt {
|
|
2120
2127
|
/**
|
|
2121
2128
|
* Import workspace from JSON file
|
|
2122
2129
|
*/
|
|
@@ -2131,7 +2138,7 @@ const me = j("ImportManager"), Zt = class Zt {
|
|
|
2131
2138
|
return this.migrateV1Document(n);
|
|
2132
2139
|
const o = [], i = [];
|
|
2133
2140
|
return n.artboards.forEach((s) => {
|
|
2134
|
-
const l =
|
|
2141
|
+
const l = ee.fromJSON({
|
|
2135
2142
|
id: s.id,
|
|
2136
2143
|
name: s.name,
|
|
2137
2144
|
x: s.x,
|
|
@@ -2144,7 +2151,7 @@ const me = j("ImportManager"), Zt = class Zt {
|
|
|
2144
2151
|
try {
|
|
2145
2152
|
return yt.createFromJSON(c);
|
|
2146
2153
|
} catch (h) {
|
|
2147
|
-
return
|
|
2154
|
+
return we.error("Failed to create element:", c, h), null;
|
|
2148
2155
|
}
|
|
2149
2156
|
}).filter((c) => c !== null);
|
|
2150
2157
|
o.push(l), i.push(...a);
|
|
@@ -2167,7 +2174,7 @@ const me = j("ImportManager"), Zt = class Zt {
|
|
|
2167
2174
|
static async migrateV1Document(t) {
|
|
2168
2175
|
var r, n, o;
|
|
2169
2176
|
try {
|
|
2170
|
-
const i = t.elements || [], s = new
|
|
2177
|
+
const i = t.elements || [], s = new ee({
|
|
2171
2178
|
id: "artboard-migrated",
|
|
2172
2179
|
name: "Artboard 1",
|
|
2173
2180
|
x: 0,
|
|
@@ -2179,7 +2186,7 @@ const me = j("ImportManager"), Zt = class Zt {
|
|
|
2179
2186
|
try {
|
|
2180
2187
|
return yt.createFromJSON(a);
|
|
2181
2188
|
} catch (c) {
|
|
2182
|
-
return
|
|
2189
|
+
return we.error("Failed to create element:", a, c), null;
|
|
2183
2190
|
}
|
|
2184
2191
|
}).filter((a) => a !== null);
|
|
2185
2192
|
return l.forEach((a) => {
|
|
@@ -2330,14 +2337,14 @@ const me = j("ImportManager"), Zt = class Zt {
|
|
|
2330
2337
|
await Promise.all(o);
|
|
2331
2338
|
}
|
|
2332
2339
|
};
|
|
2333
|
-
|
|
2334
|
-
let
|
|
2335
|
-
const
|
|
2336
|
-
function
|
|
2337
|
-
const r = t ?
|
|
2340
|
+
xt.SUPPORTED_VERSIONS = ["1.0.0", "2.0.0"];
|
|
2341
|
+
let ke = xt;
|
|
2342
|
+
const be = j("element-serializer"), Xe = 4e3, ft = /* @__PURE__ */ new Set();
|
|
2343
|
+
function Bn(e, t) {
|
|
2344
|
+
const r = t ? On(t) : "no-src";
|
|
2338
2345
|
return `${e}:${r}`;
|
|
2339
2346
|
}
|
|
2340
|
-
function
|
|
2347
|
+
function On(e) {
|
|
2341
2348
|
let t = 0;
|
|
2342
2349
|
for (let r = 0; r < e.length; r++) {
|
|
2343
2350
|
const n = e.charCodeAt(r);
|
|
@@ -2348,17 +2355,17 @@ function Rn(e) {
|
|
|
2348
2355
|
function Ht() {
|
|
2349
2356
|
ft.clear();
|
|
2350
2357
|
}
|
|
2351
|
-
function
|
|
2358
|
+
function Ge(e) {
|
|
2352
2359
|
for (const t of ft)
|
|
2353
2360
|
t.startsWith(`${e}:`) && ft.delete(t);
|
|
2354
2361
|
}
|
|
2355
|
-
function
|
|
2362
|
+
function Ln(e) {
|
|
2356
2363
|
ft.add(e);
|
|
2357
2364
|
}
|
|
2358
|
-
function
|
|
2365
|
+
function qn(e) {
|
|
2359
2366
|
return ft.has(e);
|
|
2360
2367
|
}
|
|
2361
|
-
async function
|
|
2368
|
+
async function $n(e, t = Xe) {
|
|
2362
2369
|
const { naturalWidth: r, naturalHeight: n } = e;
|
|
2363
2370
|
if (r <= t && n <= t)
|
|
2364
2371
|
return createImageBitmap(e);
|
|
@@ -2370,17 +2377,17 @@ async function Bn(e, t = _e) {
|
|
|
2370
2377
|
});
|
|
2371
2378
|
}
|
|
2372
2379
|
let wt = null, kt = null;
|
|
2373
|
-
function
|
|
2380
|
+
function Hn(e, t) {
|
|
2374
2381
|
wt = e, kt = t;
|
|
2375
2382
|
}
|
|
2376
|
-
function
|
|
2383
|
+
function jn() {
|
|
2377
2384
|
wt = null, kt = null;
|
|
2378
2385
|
}
|
|
2379
|
-
function
|
|
2386
|
+
function so() {
|
|
2380
2387
|
Ht(), wt && wt();
|
|
2381
2388
|
}
|
|
2382
|
-
function
|
|
2383
|
-
|
|
2389
|
+
function ao(e) {
|
|
2390
|
+
Ge(e), kt && kt(e);
|
|
2384
2391
|
}
|
|
2385
2392
|
function jt(e, t) {
|
|
2386
2393
|
const r = e;
|
|
@@ -2402,7 +2409,7 @@ function jt(e, t) {
|
|
|
2402
2409
|
for (const n of e.masks)
|
|
2403
2410
|
n.maskElement && jt(n.maskElement, t);
|
|
2404
2411
|
}
|
|
2405
|
-
function
|
|
2412
|
+
function Te(e) {
|
|
2406
2413
|
if (typeof document > "u") return e;
|
|
2407
2414
|
const t = Tt.getInstance();
|
|
2408
2415
|
return e.map((r) => {
|
|
@@ -2420,41 +2427,42 @@ function ke(e) {
|
|
|
2420
2427
|
} : r;
|
|
2421
2428
|
});
|
|
2422
2429
|
}
|
|
2423
|
-
async function
|
|
2430
|
+
async function _t(e, t, r = Xe) {
|
|
2424
2431
|
const n = t.filter((a) => e.hasElementId(a.id)), o = [], i = [], s = /* @__PURE__ */ new Set();
|
|
2425
2432
|
for (const a of n) {
|
|
2433
|
+
if (a.visible === !1) continue;
|
|
2426
2434
|
const c = a.toJSON();
|
|
2427
2435
|
if (jt(c, s), a instanceof At && !a.imageElement) {
|
|
2428
|
-
|
|
2436
|
+
be.warn(`[element-serializer] Skipping image ${a.id}: image not loaded (state: ${a.imageLoadState})`);
|
|
2429
2437
|
continue;
|
|
2430
2438
|
}
|
|
2431
2439
|
if (a instanceof At && a.imageElement)
|
|
2432
2440
|
try {
|
|
2433
|
-
const h =
|
|
2434
|
-
if (!
|
|
2435
|
-
const
|
|
2436
|
-
i.push({ cacheKey: h, bitmap:
|
|
2441
|
+
const h = Bn(a.id, a.imageUrl);
|
|
2442
|
+
if (!qn(h)) {
|
|
2443
|
+
const p = await $n(a.imageElement, r);
|
|
2444
|
+
i.push({ cacheKey: h, bitmap: p }), Ln(h);
|
|
2437
2445
|
}
|
|
2438
|
-
const u = a.transformData || {},
|
|
2446
|
+
const u = a.transformData || {}, d = Se(c), m = dr(u, d), g = u.width * m.cropWidth, k = u.height * m.cropHeight, T = {
|
|
2439
2447
|
id: a.id,
|
|
2440
2448
|
type: "image",
|
|
2441
2449
|
x: a.x,
|
|
2442
2450
|
y: a.y,
|
|
2443
|
-
width:
|
|
2444
|
-
height:
|
|
2451
|
+
width: g,
|
|
2452
|
+
height: k,
|
|
2445
2453
|
rotation: a.rotation || 0,
|
|
2446
2454
|
bitmapCacheKey: h
|
|
2447
2455
|
};
|
|
2448
|
-
if (!
|
|
2449
|
-
const
|
|
2450
|
-
let
|
|
2451
|
-
(
|
|
2456
|
+
if (!ur(m)) {
|
|
2457
|
+
const p = a.imageElement.naturalWidth, y = a.imageElement.naturalHeight;
|
|
2458
|
+
let C = 1;
|
|
2459
|
+
(p > r || y > r) && (C = r / Math.max(p, y)), T.cropX = m.cropX * p * C, T.cropY = m.cropY * y * C, T.cropWidth = m.cropWidth * p * C, T.cropHeight = m.cropHeight * y * C;
|
|
2452
2460
|
}
|
|
2453
|
-
u.flipHorizontal && (
|
|
2454
|
-
const
|
|
2455
|
-
a.distressEffect && (
|
|
2461
|
+
u.flipHorizontal && (T.flipHorizontal = u.flipHorizontal), u.flipVertical && (T.flipVertical = u.flipVertical), u.borderRadius && (T.borderRadius = u.borderRadius), gr(u.adjustments) || (T.adjustments = { ...u.adjustments }), a.opacity !== void 0 && (T.opacity = a.opacity);
|
|
2462
|
+
const b = T;
|
|
2463
|
+
a.distressEffect && (b.distressEffect = { ...a.distressEffect }), c.masks && c.masks.length > 0 && (b.masks = Te(c.masks)), c.blendMode && (b.blendMode = c.blendMode), c.knockoutParts && (b.knockoutParts = c.knockoutParts), c.shadow && (b.shadow = { ...c.shadow }), "getVisualBoundingBox" in a && typeof a.getVisualBoundingBox == "function" ? b._boundingBox = a.getVisualBoundingBox() : "getBoundingBox" in a && typeof a.getBoundingBox == "function" && (b._boundingBox = a.getBoundingBox()), o.push(b);
|
|
2456
2464
|
} catch (h) {
|
|
2457
|
-
|
|
2465
|
+
be.error(`[element-serializer] Failed to create ImageBitmap for ${c.id}:`, h);
|
|
2458
2466
|
}
|
|
2459
2467
|
else {
|
|
2460
2468
|
const h = {
|
|
@@ -2462,7 +2470,16 @@ async function be(e, t, r = _e) {
|
|
|
2462
2470
|
type: c.transformType
|
|
2463
2471
|
// Map transformType to type for worker compatibility
|
|
2464
2472
|
};
|
|
2465
|
-
|
|
2473
|
+
if (a instanceof Yt) {
|
|
2474
|
+
const f = await _t(
|
|
2475
|
+
{ ...e, hasElementId: () => !0 },
|
|
2476
|
+
a.children,
|
|
2477
|
+
r
|
|
2478
|
+
);
|
|
2479
|
+
h.children = f.data.elements, i.push(...f.newBitmaps);
|
|
2480
|
+
for (const u of f.data.fonts) s.add(u);
|
|
2481
|
+
}
|
|
2482
|
+
h.masks && Array.isArray(h.masks) && h.masks.length > 0 && (h.masks = Te(h.masks)), "getVisualBoundingBox" in a && typeof a.getVisualBoundingBox == "function" ? h._boundingBox = a.getVisualBoundingBox() : "getBoundingBox" in a && typeof a.getBoundingBox == "function" && (h._boundingBox = a.getBoundingBox()), o.push(h);
|
|
2466
2483
|
}
|
|
2467
2484
|
}
|
|
2468
2485
|
const l = Array.from(s);
|
|
@@ -2487,7 +2504,7 @@ async function be(e, t, r = _e) {
|
|
|
2487
2504
|
newBitmaps: i
|
|
2488
2505
|
};
|
|
2489
2506
|
}
|
|
2490
|
-
async function
|
|
2507
|
+
async function _n(e, t, r = fetch) {
|
|
2491
2508
|
try {
|
|
2492
2509
|
const n = await r(t.fontFileUrl, { mode: "cors" });
|
|
2493
2510
|
if (!n.ok) return null;
|
|
@@ -2500,10 +2517,10 @@ async function Ln(e, t, r = fetch) {
|
|
|
2500
2517
|
function K(e) {
|
|
2501
2518
|
return e.trim().toLowerCase();
|
|
2502
2519
|
}
|
|
2503
|
-
function
|
|
2520
|
+
function Dt(e) {
|
|
2504
2521
|
return `${K(e.family)}|${e.weight ?? 400}|${e.style ?? "normal"}`;
|
|
2505
2522
|
}
|
|
2506
|
-
class
|
|
2523
|
+
class Nn {
|
|
2507
2524
|
constructor() {
|
|
2508
2525
|
this.fonts = /* @__PURE__ */ new Map(), this.listeners = /* @__PURE__ */ new Set(), this.snapshot = [], this.list = () => this.snapshot, this.subscribe = (t) => (this.listeners.add(t), () => {
|
|
2509
2526
|
this.listeners.delete(t);
|
|
@@ -2516,7 +2533,7 @@ class qn {
|
|
|
2516
2533
|
register(t) {
|
|
2517
2534
|
let r = !1;
|
|
2518
2535
|
for (const n of t) {
|
|
2519
|
-
const o =
|
|
2536
|
+
const o = Dt(n), i = this.fonts.get(o);
|
|
2520
2537
|
i && i.url === n.url && i.family === n.family || (this.fonts.set(o, { ...n }), r = !0);
|
|
2521
2538
|
}
|
|
2522
2539
|
if (r) {
|
|
@@ -2549,13 +2566,13 @@ class qn {
|
|
|
2549
2566
|
for (const t of this.listeners) t();
|
|
2550
2567
|
}
|
|
2551
2568
|
}
|
|
2552
|
-
const Nt = new
|
|
2553
|
-
function
|
|
2569
|
+
const Nt = new Nn();
|
|
2570
|
+
function Xn(e) {
|
|
2554
2571
|
Nt.register(e);
|
|
2555
2572
|
}
|
|
2556
|
-
const
|
|
2557
|
-
async function
|
|
2558
|
-
const r = await
|
|
2573
|
+
const Ye = /* @__PURE__ */ new Set();
|
|
2574
|
+
async function Gn(e, t = {}) {
|
|
2575
|
+
const r = await _n(
|
|
2559
2576
|
e.family,
|
|
2560
2577
|
{
|
|
2561
2578
|
fontFileUrl: e.url,
|
|
@@ -2567,7 +2584,7 @@ async function Hn(e, t = {}) {
|
|
|
2567
2584
|
t.fetchImpl ?? fetch
|
|
2568
2585
|
);
|
|
2569
2586
|
if (!r)
|
|
2570
|
-
throw new
|
|
2587
|
+
throw new Ce(
|
|
2571
2588
|
"E_FONT_LOAD_FAILED",
|
|
2572
2589
|
`Custom font "${e.family}" failed to load from ${e.url}. The URL must serve the font binary over a plain cross-origin GET (CORS). Verify the URL is reachable and sends Access-Control-Allow-Origin, then re-register the font. Custom fonts never fall back silently — the design would render with the wrong typeface.`,
|
|
2573
2590
|
{
|
|
@@ -2578,18 +2595,18 @@ async function Hn(e, t = {}) {
|
|
|
2578
2595
|
}
|
|
2579
2596
|
);
|
|
2580
2597
|
const n = t.fonts ?? (typeof document < "u" ? document.fonts : void 0);
|
|
2581
|
-
return n == null || n.add(r),
|
|
2598
|
+
return n == null || n.add(r), Ye.add(Dt(e)), r;
|
|
2582
2599
|
}
|
|
2583
|
-
async function
|
|
2584
|
-
|
|
2600
|
+
async function io(e, t = {}) {
|
|
2601
|
+
Xn(e);
|
|
2585
2602
|
const { onLoadError: r, ...n } = t;
|
|
2586
2603
|
await Promise.all(
|
|
2587
2604
|
e.map(async (o) => {
|
|
2588
|
-
if (!
|
|
2605
|
+
if (!Ye.has(Dt(o)))
|
|
2589
2606
|
try {
|
|
2590
|
-
await
|
|
2607
|
+
await Gn(o, n);
|
|
2591
2608
|
} catch (i) {
|
|
2592
|
-
if (r && i instanceof
|
|
2609
|
+
if (r && i instanceof Ce) {
|
|
2593
2610
|
r(i, o);
|
|
2594
2611
|
return;
|
|
2595
2612
|
}
|
|
@@ -2599,9 +2616,9 @@ async function ro(e, t = {}) {
|
|
|
2599
2616
|
);
|
|
2600
2617
|
}
|
|
2601
2618
|
const O = j("WorkerExport");
|
|
2602
|
-
let
|
|
2603
|
-
function
|
|
2604
|
-
return It ?? (It = (typeof window > "u" ? Promise.reject(new Error("The export worker runs in a browser page only (no window here).")) : import("./export-worker.bundle.string-
|
|
2619
|
+
let Xt = null, It = null;
|
|
2620
|
+
function Yn() {
|
|
2621
|
+
return It ?? (It = (typeof window > "u" ? Promise.reject(new Error("The export worker runs in a browser page only (no window here).")) : import("./export-worker.bundle.string-C6Zm9Wt-.js")).then((e) => Xt = e.default).catch((e) => {
|
|
2605
2622
|
throw It = null, e;
|
|
2606
2623
|
})), It;
|
|
2607
2624
|
}
|
|
@@ -2679,7 +2696,7 @@ class dt {
|
|
|
2679
2696
|
* Call this when an element is removed or its image source changes.
|
|
2680
2697
|
*/
|
|
2681
2698
|
clearWorkerBitmap(t) {
|
|
2682
|
-
if (
|
|
2699
|
+
if (Ge(t), this.worker && this.isReady) {
|
|
2683
2700
|
const r = {
|
|
2684
2701
|
type: "clear-bitmap",
|
|
2685
2702
|
elementId: t
|
|
@@ -2707,9 +2724,9 @@ class dt {
|
|
|
2707
2724
|
return this.readyPromise;
|
|
2708
2725
|
if (!dt.supportsWorkerExport())
|
|
2709
2726
|
throw new Error("Browser does not support OffscreenCanvas or Web Workers");
|
|
2710
|
-
if (
|
|
2711
|
-
return this.readyPromise = this.startWorker(
|
|
2712
|
-
const t = this.initGeneration, r =
|
|
2727
|
+
if (Xt !== null)
|
|
2728
|
+
return this.readyPromise = this.startWorker(Xt), this.readyPromise;
|
|
2729
|
+
const t = this.initGeneration, r = Yn().then((n) => {
|
|
2713
2730
|
if (t !== this.initGeneration)
|
|
2714
2731
|
throw new Error("Worker terminated");
|
|
2715
2732
|
return this.startWorker(n);
|
|
@@ -2738,7 +2755,7 @@ class dt {
|
|
|
2738
2755
|
const i = setTimeout(() => {
|
|
2739
2756
|
n(new Error("Worker initialization timeout"));
|
|
2740
2757
|
}, 15e3), s = (l) => {
|
|
2741
|
-
l.data.type === "ready" && (clearTimeout(i), this.isReady = !0,
|
|
2758
|
+
l.data.type === "ready" && (clearTimeout(i), this.isReady = !0, Hn(
|
|
2742
2759
|
() => this.clearWorkerBitmapCache(),
|
|
2743
2760
|
(a) => this.clearWorkerBitmap(a)
|
|
2744
2761
|
), r());
|
|
@@ -2815,7 +2832,7 @@ class dt {
|
|
|
2815
2832
|
const { artboard: r, elements: n, config: o } = t;
|
|
2816
2833
|
if ((!this.worker || !this.isReady) && await this.initialize(), !this.worker)
|
|
2817
2834
|
throw new Error("Worker is not initialized");
|
|
2818
|
-
const i = `export-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: l, newBitmaps: a } = await
|
|
2835
|
+
const i = `export-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: l, newBitmaps: a } = await _t(r, n);
|
|
2819
2836
|
a.length > 0 && this.registerBitmapsWithWorker(a);
|
|
2820
2837
|
const c = {
|
|
2821
2838
|
type: "export",
|
|
@@ -2830,10 +2847,10 @@ class dt {
|
|
|
2830
2847
|
scale: o.scale || 1,
|
|
2831
2848
|
format: o.format || "png",
|
|
2832
2849
|
quality: o.quality || 0.95
|
|
2833
|
-
}, h = new Promise((
|
|
2850
|
+
}, h = new Promise((m, g) => {
|
|
2834
2851
|
this.pendingRequests.set(i, {
|
|
2835
2852
|
requestId: i,
|
|
2836
|
-
resolve:
|
|
2853
|
+
resolve: m,
|
|
2837
2854
|
reject: g,
|
|
2838
2855
|
startTime: s,
|
|
2839
2856
|
returnFormat: "dataUrl"
|
|
@@ -2842,14 +2859,14 @@ class dt {
|
|
|
2842
2859
|
}, 3e4);
|
|
2843
2860
|
});
|
|
2844
2861
|
this.worker.postMessage(c);
|
|
2845
|
-
const
|
|
2862
|
+
const f = await h, d = performance.now() - s;
|
|
2846
2863
|
return {
|
|
2847
|
-
dataUrl:
|
|
2848
|
-
artboardId:
|
|
2849
|
-
artboardName:
|
|
2850
|
-
renderTime:
|
|
2851
|
-
totalTime:
|
|
2852
|
-
mainThreadBlockTime:
|
|
2864
|
+
dataUrl: f.dataUrl,
|
|
2865
|
+
artboardId: f.artboardId,
|
|
2866
|
+
artboardName: f.artboardName,
|
|
2867
|
+
renderTime: f.renderTime,
|
|
2868
|
+
totalTime: f.totalTime,
|
|
2869
|
+
mainThreadBlockTime: d
|
|
2853
2870
|
};
|
|
2854
2871
|
}
|
|
2855
2872
|
/**
|
|
@@ -2876,7 +2893,7 @@ class dt {
|
|
|
2876
2893
|
const { artboard: r, elements: n, config: o } = t;
|
|
2877
2894
|
if ((!this.worker || !this.isReady) && await this.initialize(), !this.worker)
|
|
2878
2895
|
throw new Error("Worker is not initialized");
|
|
2879
|
-
const i = `export-blob-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: l, newBitmaps: a } = await
|
|
2896
|
+
const i = `export-blob-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: l, newBitmaps: a } = await _t(r, n);
|
|
2880
2897
|
a.length > 0 && this.registerBitmapsWithWorker(a);
|
|
2881
2898
|
const c = {
|
|
2882
2899
|
type: "export",
|
|
@@ -2890,26 +2907,26 @@ class dt {
|
|
|
2890
2907
|
format: o.format || "png",
|
|
2891
2908
|
quality: o.quality || 0.95,
|
|
2892
2909
|
returnFormat: "blob"
|
|
2893
|
-
}, h = new Promise((g,
|
|
2910
|
+
}, h = new Promise((g, k) => {
|
|
2894
2911
|
this.pendingRequests.set(i, {
|
|
2895
2912
|
requestId: i,
|
|
2896
2913
|
resolve: g,
|
|
2897
|
-
reject:
|
|
2914
|
+
reject: k,
|
|
2898
2915
|
startTime: s,
|
|
2899
2916
|
returnFormat: "blob"
|
|
2900
2917
|
}), setTimeout(() => {
|
|
2901
|
-
this.pendingRequests.has(i) && (this.pendingRequests.delete(i),
|
|
2918
|
+
this.pendingRequests.has(i) && (this.pendingRequests.delete(i), k(new Error("Export request timeout")));
|
|
2902
2919
|
}, 3e4);
|
|
2903
2920
|
});
|
|
2904
2921
|
this.worker.postMessage(c);
|
|
2905
|
-
const
|
|
2922
|
+
const f = await h, d = performance.now() - s;
|
|
2906
2923
|
return {
|
|
2907
|
-
blob: new Blob([
|
|
2908
|
-
artboardId:
|
|
2909
|
-
artboardName:
|
|
2910
|
-
renderTime:
|
|
2911
|
-
totalTime:
|
|
2912
|
-
mainThreadBlockTime:
|
|
2924
|
+
blob: new Blob([f.blobData], { type: f.mimeType }),
|
|
2925
|
+
artboardId: f.artboardId,
|
|
2926
|
+
artboardName: f.artboardName,
|
|
2927
|
+
renderTime: f.renderTime,
|
|
2928
|
+
totalTime: f.totalTime,
|
|
2929
|
+
mainThreadBlockTime: d
|
|
2913
2930
|
};
|
|
2914
2931
|
}
|
|
2915
2932
|
/**
|
|
@@ -2992,7 +3009,7 @@ class dt {
|
|
|
2992
3009
|
r.reject(new Error("Worker terminated")), this.pendingRequests.delete(t);
|
|
2993
3010
|
for (; this.requestQueue.length > 0; )
|
|
2994
3011
|
this.requestQueue.shift().reject(new Error("Worker terminated"));
|
|
2995
|
-
this.worker.terminate(), this.worker = null, this.isReady = !1, this.readyPromise = null, Ht(),
|
|
3012
|
+
this.worker.terminate(), this.worker = null, this.isReady = !1, this.readyPromise = null, Ht(), jn(), this.workerBlobUrl && (URL.revokeObjectURL(this.workerBlobUrl), this.workerBlobUrl = null);
|
|
2996
3013
|
}
|
|
2997
3014
|
}
|
|
2998
3015
|
/**
|
|
@@ -3008,31 +3025,31 @@ class dt {
|
|
|
3008
3025
|
}
|
|
3009
3026
|
}
|
|
3010
3027
|
let tt = null;
|
|
3011
|
-
function
|
|
3028
|
+
function lo() {
|
|
3012
3029
|
return tt || (tt = new dt()), tt;
|
|
3013
3030
|
}
|
|
3014
|
-
function
|
|
3031
|
+
function co() {
|
|
3015
3032
|
tt && (tt.terminate(), tt = null);
|
|
3016
3033
|
}
|
|
3017
|
-
|
|
3018
|
-
const
|
|
3019
|
-
function
|
|
3034
|
+
Qt();
|
|
3035
|
+
const _ = j("Export");
|
|
3036
|
+
function Gt(e, t) {
|
|
3020
3037
|
var r;
|
|
3021
3038
|
if (!(!e || typeof e != "object")) {
|
|
3022
3039
|
if (typeof e.fontFamily == "string" && e.fontFamily.trim() && t.add(e.fontFamily), e.richText && Array.isArray(e.richText.spans))
|
|
3023
3040
|
for (const n of e.richText.spans)
|
|
3024
3041
|
(r = n == null ? void 0 : n.style) != null && r.fontFamily && typeof n.style.fontFamily == "string" && t.add(n.style.fontFamily);
|
|
3025
3042
|
if (Array.isArray(e.children))
|
|
3026
|
-
for (const n of e.children)
|
|
3043
|
+
for (const n of e.children) Gt(n, t);
|
|
3027
3044
|
if (Array.isArray(e.masks))
|
|
3028
3045
|
for (const n of e.masks)
|
|
3029
|
-
n != null && n.maskElement &&
|
|
3046
|
+
n != null && n.maskElement && Gt(n.maskElement, t);
|
|
3030
3047
|
}
|
|
3031
3048
|
}
|
|
3032
|
-
async function
|
|
3049
|
+
async function ve(e) {
|
|
3033
3050
|
if (typeof document > "u" || !document.fonts) return;
|
|
3034
3051
|
const t = /* @__PURE__ */ new Set();
|
|
3035
|
-
for (const n of e)
|
|
3052
|
+
for (const n of e) Gt(n, t);
|
|
3036
3053
|
if (t.size === 0) return;
|
|
3037
3054
|
const r = [];
|
|
3038
3055
|
for (const n of t)
|
|
@@ -3055,7 +3072,7 @@ const ct = class ct {
|
|
|
3055
3072
|
try {
|
|
3056
3073
|
this.workerManager = new dt(), await this.workerManager.initialize();
|
|
3057
3074
|
} catch (t) {
|
|
3058
|
-
|
|
3075
|
+
_.error("Failed to initialize worker:", t), this.workerManager = null;
|
|
3059
3076
|
}
|
|
3060
3077
|
})(), await this.workerInitPromise, this.workerInitPromise = null, this.workerManager) : null;
|
|
3061
3078
|
}
|
|
@@ -3076,7 +3093,7 @@ const ct = class ct {
|
|
|
3076
3093
|
appVersion: "1.0.0"
|
|
3077
3094
|
},
|
|
3078
3095
|
artboards: t.map((h) => {
|
|
3079
|
-
const
|
|
3096
|
+
const f = new Set(h.getElementIds()), u = r.filter((d) => f.has(d.id));
|
|
3080
3097
|
return {
|
|
3081
3098
|
id: h.id,
|
|
3082
3099
|
name: h.name,
|
|
@@ -3085,7 +3102,7 @@ const ct = class ct {
|
|
|
3085
3102
|
width: h.width,
|
|
3086
3103
|
height: h.height,
|
|
3087
3104
|
backgroundColor: h.backgroundColor,
|
|
3088
|
-
elements: u.map((
|
|
3105
|
+
elements: u.map((d) => d.toJSON())
|
|
3089
3106
|
};
|
|
3090
3107
|
}),
|
|
3091
3108
|
activeArtboardId: n.getActiveArtboardId()
|
|
@@ -3104,16 +3121,16 @@ const ct = class ct {
|
|
|
3104
3121
|
transparentBackground: a = !1,
|
|
3105
3122
|
backgroundColor: c = t.backgroundColor,
|
|
3106
3123
|
filename: h,
|
|
3107
|
-
forceMainThread:
|
|
3124
|
+
forceMainThread: f = !1
|
|
3108
3125
|
} = o, u = await this.exportArtboardToDataURL(t, r, n, {
|
|
3109
3126
|
format: i,
|
|
3110
3127
|
quality: s,
|
|
3111
3128
|
scale: l,
|
|
3112
3129
|
transparentBackground: a,
|
|
3113
3130
|
backgroundColor: c,
|
|
3114
|
-
forceMainThread:
|
|
3115
|
-
}),
|
|
3116
|
-
this.downloadBlob(
|
|
3131
|
+
forceMainThread: f
|
|
3132
|
+
}), d = await this.dataUrlToBlob(u), m = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").split("T")[0], g = h || `${t.name}-${m}.${i}`;
|
|
3133
|
+
this.downloadBlob(d, g);
|
|
3117
3134
|
}
|
|
3118
3135
|
/**
|
|
3119
3136
|
* Export artboard to data URL (for preview/testing)
|
|
@@ -3130,17 +3147,17 @@ const ct = class ct {
|
|
|
3130
3147
|
} = o;
|
|
3131
3148
|
if (!h && this.supportsWorkerExport())
|
|
3132
3149
|
try {
|
|
3133
|
-
const
|
|
3134
|
-
if (
|
|
3135
|
-
const u = new Set(t.getElementIds()),
|
|
3136
|
-
return (await
|
|
3150
|
+
const f = await this.getWorkerManager();
|
|
3151
|
+
if (f) {
|
|
3152
|
+
const u = new Set(t.getElementIds()), d = r.filter((g) => u.has(g.id));
|
|
3153
|
+
return (await f.exportArtboardToDataURL(t, d, {
|
|
3137
3154
|
scale: l,
|
|
3138
3155
|
format: i === "jpg" ? "jpeg" : i,
|
|
3139
3156
|
quality: s
|
|
3140
3157
|
})).dataUrl;
|
|
3141
3158
|
}
|
|
3142
|
-
} catch (
|
|
3143
|
-
|
|
3159
|
+
} catch (f) {
|
|
3160
|
+
_.warn("Worker export failed, falling back to main thread:", f);
|
|
3144
3161
|
}
|
|
3145
3162
|
return this.mainThreadExportToDataURL(t, r, n, {
|
|
3146
3163
|
format: i,
|
|
@@ -3166,17 +3183,17 @@ const ct = class ct {
|
|
|
3166
3183
|
} = o;
|
|
3167
3184
|
if (!h && this.supportsWorkerExport())
|
|
3168
3185
|
try {
|
|
3169
|
-
const
|
|
3170
|
-
if (
|
|
3171
|
-
const u = new Set(t.getElementIds()),
|
|
3172
|
-
return (await
|
|
3186
|
+
const f = await this.getWorkerManager();
|
|
3187
|
+
if (f) {
|
|
3188
|
+
const u = new Set(t.getElementIds()), d = r.filter((g) => u.has(g.id));
|
|
3189
|
+
return (await f.exportArtboardToBlob(t, d, {
|
|
3173
3190
|
scale: l,
|
|
3174
3191
|
format: i === "jpg" ? "jpeg" : i,
|
|
3175
3192
|
quality: s
|
|
3176
3193
|
})).blob;
|
|
3177
3194
|
}
|
|
3178
|
-
} catch (
|
|
3179
|
-
|
|
3195
|
+
} catch (f) {
|
|
3196
|
+
_.warn("Worker blob export failed, falling back to main thread:", f);
|
|
3180
3197
|
}
|
|
3181
3198
|
return this.mainThreadExportToBlob(t, r, n, {
|
|
3182
3199
|
format: i,
|
|
@@ -3200,55 +3217,55 @@ const ct = class ct {
|
|
|
3200
3217
|
transparentBackground: a = !1,
|
|
3201
3218
|
backgroundColor: c = t.backgroundColor
|
|
3202
3219
|
} = o;
|
|
3203
|
-
await
|
|
3204
|
-
const h = document.createElement("canvas"),
|
|
3205
|
-
h.width =
|
|
3206
|
-
const
|
|
3207
|
-
if (
|
|
3208
|
-
if (
|
|
3209
|
-
const
|
|
3210
|
-
|
|
3211
|
-
const
|
|
3212
|
-
|
|
3220
|
+
await ve(r);
|
|
3221
|
+
const h = document.createElement("canvas"), f = t.width * l, u = t.height * l;
|
|
3222
|
+
h.width = f, h.height = u;
|
|
3223
|
+
const d = h.getContext("2d");
|
|
3224
|
+
if (d.scale(l, l), !a && t.exportBackground) {
|
|
3225
|
+
if (d.save(), this.applyExportBackgroundClipPath(d, t), t.backgroundType === "texture" && t.backgroundTexture) {
|
|
3226
|
+
const p = D.getTexturePresetColor(t.backgroundTexture);
|
|
3227
|
+
d.fillStyle = p, d.fillRect(0, 0, t.width, t.height);
|
|
3228
|
+
const y = D.getTexture(t.backgroundTexture);
|
|
3229
|
+
y && y.complete && d.drawImage(y, 0, 0, t.width, t.height);
|
|
3213
3230
|
} else
|
|
3214
|
-
|
|
3215
|
-
|
|
3231
|
+
d.fillStyle = c || t.backgroundColor, d.fillRect(0, 0, t.width, t.height);
|
|
3232
|
+
d.restore();
|
|
3216
3233
|
}
|
|
3217
|
-
|
|
3218
|
-
const
|
|
3219
|
-
g.forEach((
|
|
3220
|
-
const T = (
|
|
3221
|
-
if (!
|
|
3222
|
-
const
|
|
3223
|
-
|
|
3224
|
-
}, w = g.map((
|
|
3225
|
-
return g.forEach((
|
|
3226
|
-
var
|
|
3227
|
-
if (
|
|
3228
|
-
const
|
|
3234
|
+
d.save(), d.translate(-t.x, -t.y), this.applyExportClipPath(d, t);
|
|
3235
|
+
const m = new Set(t.getElementIds()), g = r.filter((p) => m.has(p.id)), k = /* @__PURE__ */ new Map();
|
|
3236
|
+
g.forEach((p) => k.set(p.id, p));
|
|
3237
|
+
const T = (p, y) => {
|
|
3238
|
+
if (!y.id) return;
|
|
3239
|
+
const C = k.get(y.id);
|
|
3240
|
+
C && C.render(p, !1);
|
|
3241
|
+
}, w = g.map((p) => p.toJSON()), b = /* @__PURE__ */ new Set();
|
|
3242
|
+
return g.forEach((p, y) => {
|
|
3243
|
+
var C;
|
|
3244
|
+
if (p.blendMode === "knockout" || p.blendMode === "clip") {
|
|
3245
|
+
const M = w[y], S = p.blendMode === "knockout" ? "destination-out" : "destination-in", P = ((C = M.knockoutParts) == null ? void 0 : C.scope) || "group", v = w.findIndex((A) => A.id === M.id);
|
|
3229
3246
|
if (v !== -1 && P === "artboard")
|
|
3230
3247
|
for (let A = 0; A < v; A++) {
|
|
3231
3248
|
const I = w[A].id;
|
|
3232
3249
|
I && b.add(I);
|
|
3233
3250
|
}
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3251
|
+
Ut(
|
|
3252
|
+
d,
|
|
3253
|
+
M,
|
|
3237
3254
|
w,
|
|
3238
3255
|
T,
|
|
3239
3256
|
a || !t.exportBackground ? void 0 : c,
|
|
3240
3257
|
t,
|
|
3241
|
-
|
|
3242
|
-
), b.add(
|
|
3258
|
+
S
|
|
3259
|
+
), b.add(p.id);
|
|
3243
3260
|
}
|
|
3244
|
-
}), g.forEach((
|
|
3245
|
-
b.has(
|
|
3246
|
-
|
|
3261
|
+
}), g.forEach((p, y) => {
|
|
3262
|
+
b.has(p.id) || fe(d, w[y], (C) => {
|
|
3263
|
+
p.render(C, !1);
|
|
3247
3264
|
});
|
|
3248
|
-
}),
|
|
3265
|
+
}), d.restore(), new Promise((p, y) => {
|
|
3249
3266
|
h.toBlob(
|
|
3250
|
-
(
|
|
3251
|
-
|
|
3267
|
+
(C) => {
|
|
3268
|
+
C ? p(C) : y(new Error("Failed to create blob from canvas"));
|
|
3252
3269
|
},
|
|
3253
3270
|
i === "jpg" || i === "jpeg" ? "image/jpeg" : i === "webp" ? "image/webp" : "image/png",
|
|
3254
3271
|
s
|
|
@@ -3262,7 +3279,7 @@ const ct = class ct {
|
|
|
3262
3279
|
* worker), so font readiness matters here even when no fallback occurred.
|
|
3263
3280
|
*/
|
|
3264
3281
|
static async mainThreadExportToDataURL(t, r, n, o = {}) {
|
|
3265
|
-
var
|
|
3282
|
+
var y, C;
|
|
3266
3283
|
const {
|
|
3267
3284
|
format: i = "png",
|
|
3268
3285
|
quality: s = 0.95,
|
|
@@ -3270,81 +3287,81 @@ const ct = class ct {
|
|
|
3270
3287
|
transparentBackground: a = !1,
|
|
3271
3288
|
backgroundColor: c = t.backgroundColor
|
|
3272
3289
|
} = o;
|
|
3273
|
-
await
|
|
3274
|
-
const h = document.createElement("canvas"),
|
|
3275
|
-
h.width =
|
|
3276
|
-
const
|
|
3277
|
-
if (
|
|
3278
|
-
if (
|
|
3279
|
-
const
|
|
3280
|
-
|
|
3281
|
-
const
|
|
3282
|
-
|
|
3290
|
+
await ve(r);
|
|
3291
|
+
const h = document.createElement("canvas"), f = t.width * l, u = t.height * l;
|
|
3292
|
+
h.width = f, h.height = u;
|
|
3293
|
+
const d = h.getContext("2d");
|
|
3294
|
+
if (d.scale(l, l), !a && t.exportBackground) {
|
|
3295
|
+
if (d.save(), this.applyExportBackgroundClipPath(d, t), t.backgroundType === "texture" && t.backgroundTexture) {
|
|
3296
|
+
const M = D.getTexturePresetColor(t.backgroundTexture);
|
|
3297
|
+
d.fillStyle = M, d.fillRect(0, 0, t.width, t.height);
|
|
3298
|
+
const S = D.getTexture(t.backgroundTexture);
|
|
3299
|
+
S && S.complete ? d.drawImage(S, 0, 0, t.width, t.height) : _.warn("Texture not loaded for export:", t.backgroundTexture);
|
|
3283
3300
|
} else
|
|
3284
|
-
|
|
3285
|
-
|
|
3301
|
+
d.fillStyle = c, d.fillRect(0, 0, t.width, t.height);
|
|
3302
|
+
d.restore();
|
|
3286
3303
|
}
|
|
3287
|
-
|
|
3288
|
-
const
|
|
3289
|
-
g.forEach((
|
|
3290
|
-
const T = (
|
|
3291
|
-
if (!
|
|
3292
|
-
const P =
|
|
3293
|
-
P ? P.render(
|
|
3294
|
-
}, w = g.map((
|
|
3295
|
-
g.forEach((
|
|
3304
|
+
d.save(), d.translate(-t.x, -t.y), this.applyExportClipPath(d, t);
|
|
3305
|
+
const m = new Set(t.getElementIds()), g = r.filter((M) => m.has(M.id)), k = /* @__PURE__ */ new Map();
|
|
3306
|
+
g.forEach((M) => k.set(M.id, M));
|
|
3307
|
+
const T = (M, S) => {
|
|
3308
|
+
if (!S.id) return;
|
|
3309
|
+
const P = k.get(S.id);
|
|
3310
|
+
P ? P.render(M, !1) : _.warn("Element not found in map:", S.id);
|
|
3311
|
+
}, w = g.map((M) => M.toJSON()), b = /* @__PURE__ */ new Set();
|
|
3312
|
+
g.forEach((M, S) => {
|
|
3296
3313
|
var P;
|
|
3297
|
-
if (
|
|
3298
|
-
const v = w[
|
|
3314
|
+
if (M.blendMode === "knockout" || M.blendMode === "clip") {
|
|
3315
|
+
const v = w[S], A = M.blendMode === "knockout" ? "destination-out" : "destination-in", I = ((P = v.knockoutParts) == null ? void 0 : P.scope) || "group", E = w.findIndex((R) => R.id === v.id);
|
|
3299
3316
|
if (E !== -1 && I === "artboard")
|
|
3300
3317
|
for (let R = 0; R < E; R++) {
|
|
3301
3318
|
const W = w[R].id;
|
|
3302
3319
|
W && b.add(W);
|
|
3303
3320
|
}
|
|
3304
|
-
|
|
3305
|
-
|
|
3321
|
+
Ut(
|
|
3322
|
+
d,
|
|
3306
3323
|
v,
|
|
3307
3324
|
w,
|
|
3308
3325
|
T,
|
|
3309
3326
|
a || !t.exportBackground ? void 0 : c,
|
|
3310
3327
|
t,
|
|
3311
3328
|
A
|
|
3312
|
-
), b.add(
|
|
3329
|
+
), b.add(M.id);
|
|
3313
3330
|
}
|
|
3314
|
-
}), g.forEach((
|
|
3331
|
+
}), g.forEach((M, S) => {
|
|
3315
3332
|
var P;
|
|
3316
|
-
if (!b.has(
|
|
3317
|
-
const v = w[
|
|
3318
|
-
|
|
3333
|
+
if (!b.has(M.id)) {
|
|
3334
|
+
const v = w[S], A = ((P = v == null ? void 0 : v.distressEffect) == null ? void 0 : P.enabled) && v.distressEffect.style === "custom" && v.distressEffect.textureUrl, I = (v == null ? void 0 : v.masks) && v.masks.length > 0, E = (R) => {
|
|
3335
|
+
M.render(R, !1);
|
|
3319
3336
|
};
|
|
3320
|
-
|
|
3337
|
+
fe(d, v, (R) => {
|
|
3321
3338
|
if (I && A)
|
|
3322
|
-
|
|
3323
|
-
const F =
|
|
3324
|
-
|
|
3339
|
+
he(R, v, (W) => {
|
|
3340
|
+
const F = M.getVisualBoundingBox();
|
|
3341
|
+
ye(W, v.distressEffect, F, E);
|
|
3325
3342
|
});
|
|
3326
3343
|
else if (I)
|
|
3327
|
-
|
|
3344
|
+
he(R, v, E);
|
|
3328
3345
|
else if (A) {
|
|
3329
|
-
const W =
|
|
3330
|
-
|
|
3346
|
+
const W = M.getVisualBoundingBox();
|
|
3347
|
+
ye(R, v.distressEffect, W, E);
|
|
3331
3348
|
} else
|
|
3332
|
-
|
|
3349
|
+
M.render(R, !1);
|
|
3333
3350
|
});
|
|
3334
3351
|
}
|
|
3335
|
-
}), (
|
|
3352
|
+
}), (y = t.distressTexture) != null && y.enabled && Un(d, t.distressTexture, {
|
|
3336
3353
|
x: t.x,
|
|
3337
3354
|
y: t.y,
|
|
3338
3355
|
width: t.width,
|
|
3339
3356
|
height: t.height
|
|
3340
|
-
}), (
|
|
3357
|
+
}), (C = t.imageMask) != null && C.enabled && bn(d, t.imageMask, {
|
|
3341
3358
|
x: t.x,
|
|
3342
3359
|
y: t.y,
|
|
3343
3360
|
width: t.width,
|
|
3344
3361
|
height: t.height
|
|
3345
|
-
}),
|
|
3346
|
-
const
|
|
3347
|
-
return h.toDataURL(
|
|
3362
|
+
}), d.restore();
|
|
3363
|
+
const p = i === "png" ? "image/png" : i === "webp" ? "image/webp" : "image/jpeg";
|
|
3364
|
+
return h.toDataURL(p, s);
|
|
3348
3365
|
}
|
|
3349
3366
|
/**
|
|
3350
3367
|
* Apply clip path for export background (uses 0,0 as origin since background is drawn before translate)
|
|
@@ -3365,7 +3382,7 @@ const ct = class ct {
|
|
|
3365
3382
|
t.clip(a);
|
|
3366
3383
|
return;
|
|
3367
3384
|
} catch (a) {
|
|
3368
|
-
|
|
3385
|
+
_.warn("Invalid SVG path, falling back to rectangle:", a), t.rect(s, l, n, o);
|
|
3369
3386
|
}
|
|
3370
3387
|
t.clip();
|
|
3371
3388
|
}
|
|
@@ -3389,7 +3406,7 @@ const ct = class ct {
|
|
|
3389
3406
|
t.translate(n, o), t.clip(a), t.translate(-n, -o);
|
|
3390
3407
|
return;
|
|
3391
3408
|
} catch (a) {
|
|
3392
|
-
|
|
3409
|
+
_.warn("Invalid SVG path, falling back to rectangle:", a), t.rect(n, o, i, s);
|
|
3393
3410
|
}
|
|
3394
3411
|
t.clip();
|
|
3395
3412
|
}
|
|
@@ -3449,24 +3466,24 @@ const ct = class ct {
|
|
|
3449
3466
|
try {
|
|
3450
3467
|
const c = performance.now(), h = await this.getWorkerManager();
|
|
3451
3468
|
if (h) {
|
|
3452
|
-
const
|
|
3469
|
+
const f = new Set(t.getElementIds()), u = r.filter((k) => f.has(k.id)), d = await h.exportArtboardToDataURL(t, u, {
|
|
3453
3470
|
scale: o.scale || 1,
|
|
3454
3471
|
format: (o.format === "jpg" ? "jpeg" : o.format) || "png",
|
|
3455
3472
|
quality: o.quality || 0.95
|
|
3456
|
-
}),
|
|
3473
|
+
}), m = performance.now() - c, g = l / m;
|
|
3457
3474
|
return {
|
|
3458
3475
|
...a,
|
|
3459
3476
|
worker: {
|
|
3460
|
-
time:
|
|
3461
|
-
dataUrl:
|
|
3462
|
-
mainThreadBlockTime:
|
|
3477
|
+
time: m,
|
|
3478
|
+
dataUrl: d.dataUrl,
|
|
3479
|
+
mainThreadBlockTime: d.mainThreadBlockTime
|
|
3463
3480
|
},
|
|
3464
3481
|
speedup: g,
|
|
3465
3482
|
recommendation: g > 1.2 ? `Worker export is ${g.toFixed(2)}x faster - recommended for continuous export` : g < 0.8 ? `Main thread export is ${(1 / g).toFixed(2)}x faster - worker overhead not worth it for single exports` : "Performance is similar, but worker keeps UI responsive during export"
|
|
3466
3483
|
};
|
|
3467
3484
|
}
|
|
3468
3485
|
} catch (c) {
|
|
3469
|
-
|
|
3486
|
+
_.error("Worker benchmark failed:", c), a.recommendation = "Worker export not available - using main thread export";
|
|
3470
3487
|
}
|
|
3471
3488
|
else
|
|
3472
3489
|
a.recommendation = "Worker export not supported in this browser - using main thread export";
|
|
@@ -3493,15 +3510,15 @@ const ct = class ct {
|
|
|
3493
3510
|
forceMainThread: !l
|
|
3494
3511
|
});
|
|
3495
3512
|
const b = performance.now() - w;
|
|
3496
|
-
a.push(b), l || (c += b), await new Promise((
|
|
3513
|
+
a.push(b), l || (c += b), await new Promise((p) => setTimeout(p, Math.max(0, s - b)));
|
|
3497
3514
|
}
|
|
3498
|
-
const
|
|
3515
|
+
const f = a.length, u = a.reduce((w, b) => w + b, 0) / f, d = Math.min(...a), m = Math.max(...a), g = f / i * 1e3, k = c / i * 100, T = k > 20 ? `Main thread blocked ${k.toFixed(1)}% of the time - STRONGLY recommend worker export` : k > 10 ? `Main thread blocked ${k.toFixed(1)}% of the time - consider worker export` : `Main thread blocked ${k.toFixed(1)}% of the time - performance is acceptable`;
|
|
3499
3516
|
return {
|
|
3500
|
-
totalExports:
|
|
3517
|
+
totalExports: f,
|
|
3501
3518
|
duration: i,
|
|
3502
3519
|
averageTime: u,
|
|
3503
|
-
minTime:
|
|
3504
|
-
maxTime:
|
|
3520
|
+
minTime: d,
|
|
3521
|
+
maxTime: m,
|
|
3505
3522
|
totalMainThreadBlockTime: c,
|
|
3506
3523
|
exportsPerSecond: g,
|
|
3507
3524
|
recommendation: T
|
|
@@ -3578,64 +3595,64 @@ const ct = class ct {
|
|
|
3578
3595
|
};
|
|
3579
3596
|
ct.CURRENT_VERSION = "2.0.0", ct.workerManager = null, ct.workerInitPromise = null;
|
|
3580
3597
|
let bt = ct;
|
|
3581
|
-
const
|
|
3598
|
+
const ho = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3582
3599
|
__proto__: null,
|
|
3583
3600
|
ExportManager: bt,
|
|
3584
3601
|
default: bt
|
|
3585
3602
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3586
3603
|
export {
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3604
|
+
he as A,
|
|
3605
|
+
co as B,
|
|
3606
|
+
Ge as C,
|
|
3607
|
+
Xe as D,
|
|
3591
3608
|
yt as E,
|
|
3592
|
-
|
|
3609
|
+
Rr as F,
|
|
3593
3610
|
Nt as G,
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3611
|
+
io as H,
|
|
3612
|
+
ke as I,
|
|
3613
|
+
Gn as J,
|
|
3614
|
+
Xn as K,
|
|
3615
|
+
Ut as L,
|
|
3616
|
+
fe as M,
|
|
3617
|
+
Un as N,
|
|
3618
|
+
bn as O,
|
|
3619
|
+
Qt as P,
|
|
3620
|
+
ye as Q,
|
|
3621
|
+
Jn as R,
|
|
3622
|
+
Wn as S,
|
|
3606
3623
|
D as T,
|
|
3607
|
-
|
|
3608
|
-
|
|
3624
|
+
In as U,
|
|
3625
|
+
oo as V,
|
|
3609
3626
|
dt as W,
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3627
|
+
fn as X,
|
|
3628
|
+
hn as Y,
|
|
3629
|
+
kr as Z,
|
|
3630
|
+
ho as _,
|
|
3614
3631
|
bt as a,
|
|
3615
|
-
|
|
3616
|
-
|
|
3632
|
+
Dn as b,
|
|
3633
|
+
Ie as c,
|
|
3617
3634
|
q as d,
|
|
3618
|
-
|
|
3619
|
-
|
|
3635
|
+
so as e,
|
|
3636
|
+
no as f,
|
|
3620
3637
|
Ht as g,
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3638
|
+
Qn as h,
|
|
3639
|
+
vr as i,
|
|
3640
|
+
zn as j,
|
|
3641
|
+
Kn as k,
|
|
3625
3642
|
ht as l,
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3643
|
+
lo as m,
|
|
3644
|
+
ro as n,
|
|
3645
|
+
Yn as o,
|
|
3646
|
+
oe as p,
|
|
3647
|
+
ao as q,
|
|
3648
|
+
Mr as r,
|
|
3632
3649
|
Wt as s,
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3650
|
+
xn as t,
|
|
3651
|
+
Zn as u,
|
|
3652
|
+
Ir as v,
|
|
3653
|
+
to as w,
|
|
3654
|
+
Ar as x,
|
|
3655
|
+
Ae as y,
|
|
3656
|
+
eo as z
|
|
3640
3657
|
};
|
|
3641
|
-
//# sourceMappingURL=ExportManager-
|
|
3658
|
+
//# sourceMappingURL=ExportManager-CHlByUYV.js.map
|