@snowcone-app/canvas 0.21.1 → 0.21.2
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-CwiYq8qg.js → CanvasRenderer-B0szG0Us.js} +45 -44
- package/dist/{CanvasRenderer-CwiYq8qg.js.map → CanvasRenderer-B0szG0Us.js.map} +1 -1
- package/dist/{CanvasStateV1-BFabcAKC.js → CanvasStateV1-DmZ1Qvvn.js} +38 -38
- package/dist/{CanvasStateV1-BFabcAKC.js.map → CanvasStateV1-DmZ1Qvvn.js.map} +1 -1
- package/dist/{ContextualToolbars--vTtorNg.js → ContextualToolbars-BYnovWnN.js} +1372 -1422
- package/dist/ContextualToolbars-BYnovWnN.js.map +1 -0
- package/dist/{EditorCanvasImpl-2ZgIUVpK.js → EditorCanvasImpl-BmLHjXe7.js} +8 -8
- package/dist/{EditorCanvasImpl-2ZgIUVpK.js.map → EditorCanvasImpl-BmLHjXe7.js.map} +1 -1
- package/dist/{ExportManager-DK7CdI-G.js → ExportManager-DoU4VK6h.js} +603 -498
- package/dist/ExportManager-DoU4VK6h.js.map +1 -0
- package/dist/{FontAnalyzer-BpsTYowD.js → FontAnalyzer-CwIpgTGd.js} +309 -299
- package/dist/{FontAnalyzer-BpsTYowD.js.map → FontAnalyzer-CwIpgTGd.js.map} +1 -1
- package/dist/{SnowconeCanvas-DqZicdxK.js → SnowconeCanvas-Bj2773ym.js} +9 -9
- package/dist/{SnowconeCanvas-DqZicdxK.js.map → SnowconeCanvas-Bj2773ym.js.map} +1 -1
- package/dist/{UnifiedFontService-B1PGVu8O.js → UnifiedFontService-C8gaspRD.js} +812 -816
- package/dist/UnifiedFontService-C8gaspRD.js.map +1 -0
- package/dist/advanced.mjs +13 -13
- package/dist/{design-builder-CPF60RU2.js → design-builder-CT4DHIPe.js} +2 -2
- package/dist/{design-builder-CPF60RU2.js.map → design-builder-CT4DHIPe.js.map} +1 -1
- package/dist/{editorErrors-CK1RISFa.js → editorErrors-B2mb1sVN.js} +2 -2
- package/dist/{editorErrors-CK1RISFa.js.map → editorErrors-B2mb1sVN.js.map} +1 -1
- package/dist/{embed-2tp6Ue90.js → embed-pM7ZkFuz.js} +10 -10
- package/dist/{embed-2tp6Ue90.js.map → embed-pM7ZkFuz.js.map} +1 -1
- package/dist/embed.mjs +6 -6
- package/dist/index.mjs +8 -8
- package/dist/internals.mjs +11 -11
- package/dist/rendering/element-painters.d.ts +4 -2
- package/dist/{template-fields-FgImixyv.js → template-fields-BsnHMf1i.js} +6 -6
- package/dist/{template-fields-FgImixyv.js.map → template-fields-BsnHMf1i.js.map} +1 -1
- package/dist/testing.mjs +4 -4
- package/dist/{usePieceGuideBundle-Ctnu5k2D.js → usePieceGuideBundle-CbJJg66S.js} +2 -2
- package/dist/{usePieceGuideBundle-Ctnu5k2D.js.map → usePieceGuideBundle-CbJJg66S.js.map} +1 -1
- package/dist/{validation-3YEMnKLB.js → validation-DdVeWnlo.js} +9 -9
- package/dist/{validation-3YEMnKLB.js.map → validation-DdVeWnlo.js.map} +1 -1
- package/example/package.json +1 -1
- package/package.json +3 -2
- package/dist/ContextualToolbars--vTtorNg.js.map +0 -1
- package/dist/ExportManager-DK7CdI-G.js.map +0 -1
- package/dist/UnifiedFontService-B1PGVu8O.js.map +0 -1
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import { c as G, a1 as
|
|
2
|
-
|
|
1
|
+
import { c as N, G as pe, a1 as Me, a2 as Oe, a3 as Re, a4 as he, a5 as J, a6 as Ln, $ as Be, a0 as Le, z as Hn, R as Ne, a7 as Ue, a8 as j, a9 as ze, aa as $n, P as We, S as Ge, I as kn, M as He, W as Ve, H as je, D as qe, O as Xe, J as Ye, K as Ke, A as Vn } from "./FontAnalyzer-CwIpgTGd.js";
|
|
2
|
+
let be = null;
|
|
3
|
+
function Je(e) {
|
|
4
|
+
be = e;
|
|
5
|
+
}
|
|
6
|
+
function xa() {
|
|
7
|
+
return be;
|
|
8
|
+
}
|
|
9
|
+
const Ze = N("TextureManager"), sn = class sn {
|
|
3
10
|
/**
|
|
4
11
|
* Load a texture by ID or URL
|
|
5
12
|
*/
|
|
@@ -13,7 +20,7 @@ const Le = G("TextureManager"), an = class an {
|
|
|
13
20
|
s.crossOrigin = "anonymous", s.onload = () => {
|
|
14
21
|
this.cache.set(n, s), this.cache.set(t, s), this.loading.delete(n), this.loading.delete(t), r(s);
|
|
15
22
|
}, s.onerror = () => {
|
|
16
|
-
|
|
23
|
+
Ze.error("Failed to load texture:", t), this.loading.delete(n), this.loading.delete(t), o(new Error(`Failed to load texture: ${t}`));
|
|
17
24
|
}, s.src = t;
|
|
18
25
|
});
|
|
19
26
|
return this.loading.set(n, a), t !== n && this.loading.set(t, a), a;
|
|
@@ -79,7 +86,7 @@ const Le = G("TextureManager"), an = class an {
|
|
|
79
86
|
return (t == null ? void 0 : t.presetColor) || "#ffffff";
|
|
80
87
|
}
|
|
81
88
|
};
|
|
82
|
-
|
|
89
|
+
sn.cache = /* @__PURE__ */ new Map(), sn.loading = /* @__PURE__ */ new Map(), sn.TEXTURES = [
|
|
83
90
|
{
|
|
84
91
|
id: "glass-frame",
|
|
85
92
|
name: "Glass Frame",
|
|
@@ -89,22 +96,73 @@ an.cache = /* @__PURE__ */ new Map(), an.loading = /* @__PURE__ */ new Map(), an
|
|
|
89
96
|
// Light gray
|
|
90
97
|
}
|
|
91
98
|
];
|
|
92
|
-
let
|
|
93
|
-
|
|
99
|
+
let K = sn;
|
|
100
|
+
const Qe = N("ElementPreviewRenderer"), nt = {
|
|
101
|
+
width: 40,
|
|
102
|
+
height: 40,
|
|
103
|
+
padding: 4,
|
|
104
|
+
backgroundColor: "transparent"
|
|
105
|
+
};
|
|
106
|
+
function et(e, n = {}) {
|
|
107
|
+
Un();
|
|
108
|
+
const t = { ...nt, ...n }, a = document.createElement("canvas");
|
|
109
|
+
a.width = t.width, a.height = t.height;
|
|
110
|
+
const r = a.getContext("2d");
|
|
111
|
+
if (!r)
|
|
112
|
+
return "";
|
|
113
|
+
t.backgroundColor !== "transparent" && (r.fillStyle = t.backgroundColor, r.fillRect(0, 0, t.width, t.height)), r.save();
|
|
114
|
+
try {
|
|
115
|
+
e instanceof pe ? at(r, e, t) : tt(r, e, t);
|
|
116
|
+
} catch (o) {
|
|
117
|
+
Qe.warn("Failed to generate preview:", o);
|
|
118
|
+
}
|
|
119
|
+
return r.restore(), a.toDataURL("image/png");
|
|
120
|
+
}
|
|
121
|
+
function tt(e, n, t) {
|
|
122
|
+
var f;
|
|
123
|
+
const a = ((f = n.getBoundingBox) == null ? void 0 : f.call(n)) || { x: 0, y: 0, width: 100, height: 100 }, r = a.width, o = a.height;
|
|
124
|
+
if (r === 0 || o === 0) {
|
|
125
|
+
jn(e, n, t);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const s = t.width - t.padding * 2, c = t.height - t.padding * 2, i = Math.min(
|
|
129
|
+
s / r,
|
|
130
|
+
c / o,
|
|
131
|
+
1
|
|
132
|
+
// Don't scale up, only down
|
|
133
|
+
), l = r * i, d = o * i, u = t.padding + (s - l) / 2, p = t.padding + (c - d) / 2;
|
|
134
|
+
e.save(), e.translate(u - a.x * i, p - a.y * i), e.scale(i, i), typeof n.render == "function" ? n.render(e, !1, !1) : jn(e, n, t), e.restore();
|
|
135
|
+
}
|
|
136
|
+
function jn(e, n, t) {
|
|
137
|
+
e.fillStyle = "#888888", e.font = "10px Arial", e.textAlign = "center", e.textBaseline = "middle";
|
|
138
|
+
const a = n.transformType || "Element";
|
|
139
|
+
e.fillText(a, t.width / 2, t.height / 2);
|
|
140
|
+
}
|
|
141
|
+
function at(e, n, t) {
|
|
142
|
+
const a = t.width - t.padding * 2, r = t.height - t.padding * 2, o = t.padding, s = t.padding;
|
|
143
|
+
e.fillStyle = "#888888", e.strokeStyle = "#666666", e.lineWidth = 1;
|
|
144
|
+
const c = r * 0.7, i = s + r * 0.3, l = a * 0.4, d = r * 0.2;
|
|
145
|
+
e.fillRect(o, i, a, c), e.fillRect(o, i - d, l, d), n.children && n.children.length > 0 && (e.fillStyle = "#FFFFFF", e.font = "bold 10px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText(
|
|
146
|
+
n.children.length.toString(),
|
|
147
|
+
o + a / 2,
|
|
148
|
+
i + c / 2
|
|
149
|
+
));
|
|
150
|
+
}
|
|
151
|
+
function va(e, n, t) {
|
|
94
152
|
var l;
|
|
95
153
|
e.translate(n.x || 0, n.y || 0), e.rotate(-(n.rotation || 0) * Math.PI / 180);
|
|
96
154
|
const a = n, r = a.fontSize || 24, o = a.fontFamily || "Arial", s = a.bold || !1, c = a.italic || !1;
|
|
97
|
-
e.font =
|
|
155
|
+
e.font = Me(r, o, s, c);
|
|
98
156
|
const i = a.text || "";
|
|
99
157
|
if (n.transformType === "custom") {
|
|
100
|
-
const u = ((l = n.transformData) == null ? void 0 : l.width) || 200, p =
|
|
158
|
+
const u = ((l = n.transformData) == null ? void 0 : l.width) || 200, p = Oe(i, r, o, s, c), f = Math.min(p, u), m = r * 1.2;
|
|
101
159
|
e.rect(-f / 2, -m / 2, f, m);
|
|
102
160
|
} else {
|
|
103
161
|
const d = e.measureText(i).width;
|
|
104
162
|
e.beginPath(), e.moveTo(-d / 2, 0), e.lineTo(d / 2, 0), e.moveTo(-d / 2, -r), e.lineTo(d / 2, -r), e.moveTo(-d / 2, r * 0.2), e.lineTo(d / 2, r * 0.2);
|
|
105
163
|
}
|
|
106
164
|
}
|
|
107
|
-
function
|
|
165
|
+
function rt(e, n) {
|
|
108
166
|
if (!n.transformData) return;
|
|
109
167
|
const { borderRadius: t = 0 } = n.transformData, a = n.transformData.width ?? 100, r = n.transformData.height ?? 100;
|
|
110
168
|
if (e.translate(n.x || 0, n.y || 0), e.rotate(-(n.rotation || 0) * Math.PI / 180), e.beginPath(), t > 0) {
|
|
@@ -113,22 +171,22 @@ function Ne(e, n) {
|
|
|
113
171
|
} else
|
|
114
172
|
e.rect(-a / 2, -r / 2, a, r);
|
|
115
173
|
}
|
|
116
|
-
function
|
|
174
|
+
function wa(e, n, t, a) {
|
|
117
175
|
e.beginPath(), e.arc(n, t, a, 0, Math.PI * 2), e.closePath();
|
|
118
176
|
}
|
|
119
|
-
function
|
|
177
|
+
function Sa(e, n, t, a, r) {
|
|
120
178
|
e.beginPath(), e.rect(n, t, a, r), e.closePath();
|
|
121
179
|
}
|
|
122
|
-
function
|
|
180
|
+
function ge(e, n) {
|
|
123
181
|
e.strokeStyle = n.color, e.lineWidth = n.width, e.lineCap = n.lineCap || "butt", e.lineJoin = n.lineJoin || "miter", n.miterLimit !== void 0 && (e.miterLimit = n.miterLimit), n.dashArray && n.dashArray.length > 0 ? e.setLineDash(n.dashArray) : e.setLineDash([]), n.opacity !== void 0 && (e.globalAlpha = n.opacity);
|
|
124
182
|
}
|
|
125
|
-
function
|
|
183
|
+
function st(e, n) {
|
|
126
184
|
if (typeof OffscreenCanvas < "u")
|
|
127
185
|
return new OffscreenCanvas(e, n);
|
|
128
186
|
const t = document.createElement("canvas");
|
|
129
187
|
return t.width = e, t.height = n, t;
|
|
130
188
|
}
|
|
131
|
-
function
|
|
189
|
+
function me(e, n, t) {
|
|
132
190
|
var i;
|
|
133
191
|
if (!((i = n.stroke) != null && i.enabled)) return;
|
|
134
192
|
const a = n;
|
|
@@ -136,23 +194,23 @@ function de(e, n, t) {
|
|
|
136
194
|
const o = (t == null ? void 0 : t.isKnockout) === !0, s = n.stroke.opacity ?? 1;
|
|
137
195
|
if (!o && s < 1)
|
|
138
196
|
try {
|
|
139
|
-
|
|
197
|
+
it(e, n, a, t, s);
|
|
140
198
|
} catch {
|
|
141
|
-
|
|
199
|
+
rn(e, n, a, t, !1);
|
|
142
200
|
}
|
|
143
201
|
else
|
|
144
|
-
|
|
202
|
+
rn(e, n, a, t, o);
|
|
145
203
|
}
|
|
146
|
-
function
|
|
204
|
+
function it(e, n, t, a, r) {
|
|
147
205
|
var C, _;
|
|
148
206
|
const o = t.text || "", s = t.fontSize || 24, c = n.stroke.width, i = n.stroke.feather || 0, l = n.transformType === "custom" && ((C = n.transformData) == null ? void 0 : C.width), d = l ? ((_ = n.transformData) == null ? void 0 : _.width) ?? 200 : 0, u = l ? d + c * 2 + i * 2 + 40 : s * o.length * 0.7 + c * 2 + i * 2 + 40, p = s * 3 + c * 2 + i * 2 + 40, f = e.getTransform(), m = Math.max(Math.abs(f.a), Math.abs(f.d), 1), b = Math.ceil(u * m / 2) * 2, h = Math.ceil(p * m / 2) * 2;
|
|
149
207
|
if (b <= 0 || h <= 0) {
|
|
150
|
-
|
|
208
|
+
rn(e, n, t, a, !1);
|
|
151
209
|
return;
|
|
152
210
|
}
|
|
153
|
-
const S =
|
|
211
|
+
const S = st(b, h), $ = S.getContext("2d");
|
|
154
212
|
if (!$) {
|
|
155
|
-
|
|
213
|
+
rn(e, n, t, a, !1);
|
|
156
214
|
return;
|
|
157
215
|
}
|
|
158
216
|
const v = n.x || 0, g = n.y || 0, y = f.a * v + f.c * g + f.e, k = f.b * v + f.d * g + f.f;
|
|
@@ -165,21 +223,21 @@ function ze(e, n, t, a, r) {
|
|
|
165
223
|
h / 2 - k + f.f
|
|
166
224
|
);
|
|
167
225
|
const T = n.stroke.opacity;
|
|
168
|
-
n.stroke.opacity = 1,
|
|
226
|
+
n.stroke.opacity = 1, rn($, n, t, a, !1), n.stroke.opacity = T, e.save(), e.resetTransform(), e.globalAlpha = r, e.drawImage(
|
|
169
227
|
S,
|
|
170
228
|
Math.round(y - b / 2),
|
|
171
229
|
Math.round(k - h / 2)
|
|
172
230
|
), e.restore();
|
|
173
231
|
}
|
|
174
|
-
function
|
|
232
|
+
function rn(e, n, t, a, r) {
|
|
175
233
|
var f;
|
|
176
234
|
const o = t.text || "";
|
|
177
235
|
e.save(), a != null && a.positionApplied || (e.translate(n.x || 0, n.y || 0), e.rotate(-(n.rotation || 0) * Math.PI / 180));
|
|
178
236
|
const s = t.fontSize || 24, c = t.fontFamily || "Arial", i = t.bold || !1, l = t.italic || !1, d = t.textAlign || "center";
|
|
179
237
|
e.font = `${l ? "italic " : ""}${i ? "bold " : ""}${s}px ${c}`, e.textAlign = d, e.textBaseline = "alphabetic", r ? (e.strokeStyle = "#000000", e.globalAlpha = 1) : (e.strokeStyle = n.stroke.color, n.stroke.opacity !== void 0 && (e.globalAlpha = n.stroke.opacity)), e.lineWidth = n.stroke.width, e.lineCap = n.stroke.lineCap || "round", e.lineJoin = n.stroke.lineJoin || "round", n.stroke.miterLimit !== void 0 && (e.miterLimit = n.stroke.miterLimit), !r && n.stroke.feather && n.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${n.stroke.feather}px)`);
|
|
180
|
-
const u =
|
|
238
|
+
const u = Re(s, c, i, l);
|
|
181
239
|
if (n.transformType === "custom" && ((f = n.transformData) == null ? void 0 : f.width)) {
|
|
182
|
-
const m = n.transformData, b = (m == null ? void 0 : m.width) ?? 200, h = b -
|
|
240
|
+
const m = n.transformData, b = (m == null ? void 0 : m.width) ?? 200, h = b - J * 2, { lines: S, height: $ } = he(
|
|
183
241
|
o,
|
|
184
242
|
h,
|
|
185
243
|
s,
|
|
@@ -190,7 +248,7 @@ function tn(e, n, t, a, r) {
|
|
|
190
248
|
// No locked line count for stroke
|
|
191
249
|
!0
|
|
192
250
|
// strict: wrap exactly at maxWidth
|
|
193
|
-
), v = -b / 2, g = -$ / 2, y = s *
|
|
251
|
+
), v = -b / 2, g = -$ / 2, y = s * Ln;
|
|
194
252
|
S.forEach((k, T) => {
|
|
195
253
|
const C = T === 0, _ = T === S.length - 1;
|
|
196
254
|
let w = k;
|
|
@@ -202,8 +260,8 @@ function tn(e, n, t, a, r) {
|
|
|
202
260
|
const P = w.match(/ +$/), A = P ? P[0].length : 0;
|
|
203
261
|
A > 0 && (w = w.substring(0, w.length - A));
|
|
204
262
|
}
|
|
205
|
-
let E = v +
|
|
206
|
-
d === "center" ? E = v + b / 2 : d === "right" && (E = v + b -
|
|
263
|
+
let E = v + J;
|
|
264
|
+
d === "center" ? E = v + b / 2 : d === "right" && (E = v + b - J);
|
|
207
265
|
const x = g + u.ascent + T * y;
|
|
208
266
|
e.strokeText(w, E, x);
|
|
209
267
|
});
|
|
@@ -213,17 +271,17 @@ function tn(e, n, t, a, r) {
|
|
|
213
271
|
}
|
|
214
272
|
e.restore();
|
|
215
273
|
}
|
|
216
|
-
function
|
|
274
|
+
function ot(e, n, t) {
|
|
217
275
|
var r;
|
|
218
276
|
if (!((r = n.stroke) != null && r.enabled) || !n.transformData) return;
|
|
219
277
|
const a = (t == null ? void 0 : t.isKnockout) === !0;
|
|
220
|
-
e.save(), a ? (e.strokeStyle = "#000000", e.lineWidth = n.stroke.width, e.lineCap = n.stroke.lineCap || "butt", e.lineJoin = n.stroke.lineJoin || "miter", e.globalAlpha = 1, n.stroke.miterLimit !== void 0 && (e.miterLimit = n.stroke.miterLimit)) :
|
|
278
|
+
e.save(), a ? (e.strokeStyle = "#000000", e.lineWidth = n.stroke.width, e.lineCap = n.stroke.lineCap || "butt", e.lineJoin = n.stroke.lineJoin || "miter", e.globalAlpha = 1, n.stroke.miterLimit !== void 0 && (e.miterLimit = n.stroke.miterLimit)) : ge(e, n.stroke), !a && n.stroke.feather && n.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${n.stroke.feather}px)`), rt(e, n), e.stroke(), e.restore();
|
|
221
279
|
}
|
|
222
|
-
function
|
|
223
|
-
n.enabled && (e.save(),
|
|
280
|
+
function Ca(e, n, t) {
|
|
281
|
+
n.enabled && (e.save(), ge(e, n), n.feather && n.feather > 0 && "filter" in e && (e.filter = `blur(${n.feather}px)`), e.beginPath(), t(), e.stroke(), e.restore());
|
|
224
282
|
}
|
|
225
|
-
const
|
|
226
|
-
function
|
|
283
|
+
const qn = N("GlyphRenderer");
|
|
284
|
+
function ct(e, n, t, a, r, o, s, c = {}) {
|
|
227
285
|
try {
|
|
228
286
|
const i = [];
|
|
229
287
|
Object.entries(s).forEach(([h, S]) => {
|
|
@@ -261,7 +319,7 @@ function Ge(e, n, t, a, r, o, s, c = {}) {
|
|
|
261
319
|
}
|
|
262
320
|
}
|
|
263
321
|
} catch (g) {
|
|
264
|
-
|
|
322
|
+
qn.warn("Error getting path for glyph:", h.name, g);
|
|
265
323
|
}
|
|
266
324
|
if (v) {
|
|
267
325
|
const g = new Path2D(v);
|
|
@@ -270,10 +328,10 @@ function Ge(e, n, t, a, r, o, s, c = {}) {
|
|
|
270
328
|
b += h.advanceWidth * p;
|
|
271
329
|
}), e.restore();
|
|
272
330
|
} catch (i) {
|
|
273
|
-
|
|
331
|
+
qn.error("Error rendering with fontkit:", i), e.fillStyle = c.color || "#000000", e.textAlign = c.align || "left", e.fillText(t, a, r);
|
|
274
332
|
}
|
|
275
333
|
}
|
|
276
|
-
function
|
|
334
|
+
function lt(e, n, t, a, r, o, s, c = {}) {
|
|
277
335
|
const l = ((h) => {
|
|
278
336
|
for (const S of h) {
|
|
279
337
|
const $ = S.codePointAt(0);
|
|
@@ -326,12 +384,12 @@ function He(e, n, t, a, r, o, s, c = {}) {
|
|
|
326
384
|
}
|
|
327
385
|
}), e.restore();
|
|
328
386
|
}
|
|
329
|
-
function
|
|
387
|
+
function dt(e, n, t, a, r) {
|
|
330
388
|
e.fillStyle = t.color;
|
|
331
|
-
const o = t.textAlign || "center", s =
|
|
389
|
+
const o = t.textAlign || "center", s = Be(n);
|
|
332
390
|
let c, i;
|
|
333
391
|
a !== void 0 && a > 0 && !r ? (c = [], i = [], s.forEach((m) => {
|
|
334
|
-
const b =
|
|
392
|
+
const b = Le(m, a, t);
|
|
335
393
|
b.forEach((h, S) => {
|
|
336
394
|
c.push(h), i.push({
|
|
337
395
|
isParagraphStart: S === 0,
|
|
@@ -352,7 +410,7 @@ function Ve(e, n, t, a, r) {
|
|
|
352
410
|
e.font = R(P, A, F, D);
|
|
353
411
|
const I = e.measureText(x.text).width;
|
|
354
412
|
h.push(I);
|
|
355
|
-
const M =
|
|
413
|
+
const M = cn(P, A, F, D);
|
|
356
414
|
S = Math.max(S, M.height), $ = Math.max($, M.ascent);
|
|
357
415
|
});
|
|
358
416
|
const y = m.map((x) => x.text).join(""), k = y.match(/^ +/), T = y.match(/ +$/), C = k ? k[0].length : 0, _ = T ? T[0].length : 0;
|
|
@@ -360,16 +418,16 @@ function Ve(e, n, t, a, r) {
|
|
|
360
418
|
m.forEach((x) => {
|
|
361
419
|
const P = x.style.fontSize !== void 0 ? x.style.fontSize : t.fontSize, A = x.style.fontFamily !== void 0 ? x.style.fontFamily : t.fontFamily, F = x.style.bold !== void 0 ? x.style.bold : t.bold || !1, D = x.style.italic !== void 0 ? x.style.italic : t.italic || !1;
|
|
362
420
|
let I = x.text;
|
|
363
|
-
const M = E,
|
|
421
|
+
const M = E, en = E + x.text.length;
|
|
364
422
|
if (!v && C > 0 && M < C) {
|
|
365
423
|
const B = Math.min(C - M, x.text.length);
|
|
366
424
|
I = I.substring(B);
|
|
367
425
|
}
|
|
368
426
|
if (!g && _ > 0) {
|
|
369
427
|
const B = y.length - _;
|
|
370
|
-
if (
|
|
371
|
-
const H = !v && C > 0 && M < C ? Math.min(C - M, x.text.length) : 0,
|
|
372
|
-
I = I.substring(0,
|
|
428
|
+
if (en > B) {
|
|
429
|
+
const H = !v && C > 0 && M < C ? Math.min(C - M, x.text.length) : 0, wn = Math.max(0, B - M - H);
|
|
430
|
+
I = I.substring(0, wn);
|
|
373
431
|
}
|
|
374
432
|
}
|
|
375
433
|
E += x.text.length, I.length > 0 && (e.save(), e.font = R(P, A, F, D), w += e.measureText(I).width, e.restore());
|
|
@@ -385,7 +443,7 @@ function Ve(e, n, t, a, r) {
|
|
|
385
443
|
isParagraphEnd: g
|
|
386
444
|
});
|
|
387
445
|
});
|
|
388
|
-
const d =
|
|
446
|
+
const d = cn(t.fontSize, t.fontFamily, t.bold, t.italic), u = t.fontSize * Ln;
|
|
389
447
|
let p;
|
|
390
448
|
l.length === 0 ? p = 0 : l.length === 1 ? p = d.height : p = (l.length - 1) * u + d.height;
|
|
391
449
|
const f = -p / 2;
|
|
@@ -396,62 +454,62 @@ function Ve(e, n, t, a, r) {
|
|
|
396
454
|
const y = f + d.ascent + b * u, k = h.map((x) => x.text).join(""), T = k.match(/^ +/), C = k.match(/ +$/), _ = T ? T[0].length : 0, w = C ? C[0].length : 0;
|
|
397
455
|
let E = 0;
|
|
398
456
|
h.forEach((x) => {
|
|
399
|
-
const P = x.style.fontSize !== void 0 ? x.style.fontSize : t.fontSize, A = x.style.fontFamily !== void 0 ? x.style.fontFamily : t.fontFamily, F = x.style.color !== void 0 ? x.style.color : t.color, D = x.style.bold !== void 0 ? x.style.bold : t.bold || !1, I = x.style.italic !== void 0 ? x.style.italic : t.italic || !1, M = x.style.underline !== void 0 ? x.style.underline : t.underline || !1,
|
|
400
|
-
let B = x.text, H = E,
|
|
457
|
+
const P = x.style.fontSize !== void 0 ? x.style.fontSize : t.fontSize, A = x.style.fontFamily !== void 0 ? x.style.fontFamily : t.fontFamily, F = x.style.color !== void 0 ? x.style.color : t.color, D = x.style.bold !== void 0 ? x.style.bold : t.bold || !1, I = x.style.italic !== void 0 ? x.style.italic : t.italic || !1, M = x.style.underline !== void 0 ? x.style.underline : t.underline || !1, en = x.style.strikethrough !== void 0 ? x.style.strikethrough : t.strikethrough || !1;
|
|
458
|
+
let B = x.text, H = E, wn = E + x.text.length;
|
|
401
459
|
if (!$ && _ > 0 && H < _) {
|
|
402
|
-
const
|
|
403
|
-
B = B.substring(
|
|
460
|
+
const U = Math.min(_ - H, x.text.length);
|
|
461
|
+
B = B.substring(U);
|
|
404
462
|
}
|
|
405
463
|
if (!v && w > 0) {
|
|
406
|
-
const
|
|
407
|
-
if (
|
|
408
|
-
const V = !$ && _ > 0 && H < _ ? Math.min(_ - H, x.text.length) : 0,
|
|
409
|
-
B = B.substring(0,
|
|
464
|
+
const U = k.length - w;
|
|
465
|
+
if (wn > U) {
|
|
466
|
+
const V = !$ && _ > 0 && H < _ ? Math.min(_ - H, x.text.length) : 0, Fe = Math.max(0, U - H - V);
|
|
467
|
+
B = B.substring(0, Fe);
|
|
410
468
|
}
|
|
411
469
|
}
|
|
412
470
|
if (E += x.text.length, B.length > 0) {
|
|
413
471
|
e.font = R(P, A, D, I), e.fillStyle = F, e.textBaseline = "alphabetic", e.textAlign = "left", e.fillText(B, g, y);
|
|
414
|
-
const
|
|
472
|
+
const U = e.measureText(B).width;
|
|
415
473
|
if (M) {
|
|
416
474
|
const V = y + P * 0.1;
|
|
417
|
-
e.beginPath(), e.moveTo(g, V), e.lineTo(g +
|
|
475
|
+
e.beginPath(), e.moveTo(g, V), e.lineTo(g + U, V), e.lineWidth = Math.max(1, P * 0.05), e.strokeStyle = F, e.stroke();
|
|
418
476
|
}
|
|
419
|
-
if (
|
|
477
|
+
if (en) {
|
|
420
478
|
const V = y - P * 0.25;
|
|
421
|
-
e.beginPath(), e.moveTo(g, V), e.lineTo(g +
|
|
479
|
+
e.beginPath(), e.moveTo(g, V), e.lineTo(g + U, V), e.lineWidth = Math.max(1, P * 0.05), e.strokeStyle = F, e.stroke();
|
|
422
480
|
}
|
|
423
|
-
g +=
|
|
481
|
+
g += U;
|
|
424
482
|
}
|
|
425
483
|
});
|
|
426
484
|
});
|
|
427
485
|
}
|
|
428
|
-
const
|
|
429
|
-
let
|
|
430
|
-
function
|
|
431
|
-
if (!
|
|
486
|
+
const Tn = N("canvas-renderer");
|
|
487
|
+
let fn = null;
|
|
488
|
+
function Nn() {
|
|
489
|
+
if (!fn)
|
|
432
490
|
if (typeof OffscreenCanvas < "u")
|
|
433
|
-
|
|
491
|
+
fn = new OffscreenCanvas(1, 1).getContext("2d");
|
|
434
492
|
else if (typeof document < "u")
|
|
435
|
-
|
|
493
|
+
fn = document.createElement("canvas").getContext("2d");
|
|
436
494
|
else
|
|
437
495
|
throw new Error("No canvas context available");
|
|
438
|
-
return
|
|
496
|
+
return fn;
|
|
439
497
|
}
|
|
440
498
|
function R(e, n, t = !1, a = !1) {
|
|
441
499
|
const r = [];
|
|
442
500
|
return a && r.push("italic"), t && r.push("bold"), r.push(`${e}px`), r.push(n), r.join(" ");
|
|
443
501
|
}
|
|
444
|
-
function
|
|
445
|
-
const o =
|
|
502
|
+
function Xn(e, n, t, a = !1, r = !1) {
|
|
503
|
+
const o = Nn();
|
|
446
504
|
return o.font = R(n, t, a, r), o.measureText(e).width;
|
|
447
505
|
}
|
|
448
|
-
function
|
|
449
|
-
const r =
|
|
506
|
+
function cn(e, n, t = !1, a = !1) {
|
|
507
|
+
const r = Nn();
|
|
450
508
|
r.font = R(e, n, t, a);
|
|
451
509
|
const s = r.measureText("ÁÉÍgjpqy"), c = s.actualBoundingBoxAscent || e * 0.8, i = s.actualBoundingBoxDescent || e * 0.2, l = c + i;
|
|
452
510
|
return { ascent: c, descent: i, height: l };
|
|
453
511
|
}
|
|
454
|
-
function
|
|
512
|
+
function ka(e, n) {
|
|
455
513
|
const t = e.map((r, o) => ({
|
|
456
514
|
isParagraphStart: !n && o === 0,
|
|
457
515
|
isParagraphEnd: !n && o === e.length - 1
|
|
@@ -464,14 +522,14 @@ function da(e, n) {
|
|
|
464
522
|
return s || (i = i.replace(/^ +/, "")), c || (i = i.replace(/ +$/, "")), i;
|
|
465
523
|
}).filter((r) => r.length > 0);
|
|
466
524
|
}
|
|
467
|
-
function
|
|
525
|
+
function ft(e, n) {
|
|
468
526
|
const t = n.fontSize, a = n.fontFamily, r = n.bold || !1, o = n.italic || !1, s = n.textAlign || "center", c = n.text;
|
|
469
527
|
e.font = R(t, a, r, o), e.textAlign = s, e.textBaseline = "alphabetic", e.fillStyle = n.color;
|
|
470
|
-
const i =
|
|
528
|
+
const i = cn(t, a, r, o), u = -i.height / 2 + i.ascent;
|
|
471
529
|
e.fillText(c, 0, u);
|
|
472
530
|
}
|
|
473
|
-
function
|
|
474
|
-
const c =
|
|
531
|
+
function ut(e, n, t, a, r = !1, o = !1, s) {
|
|
532
|
+
const c = Nn();
|
|
475
533
|
if (c.font = R(t, a, r, o), e.trim().length === 0)
|
|
476
534
|
return [e];
|
|
477
535
|
if (e.includes(`
|
|
@@ -479,7 +537,7 @@ function qe(e, n, t, a, r = !1, o = !1, s) {
|
|
|
479
537
|
const C = e.split(`
|
|
480
538
|
`), _ = [];
|
|
481
539
|
for (let w = 0; w < C.length; w++) {
|
|
482
|
-
const E = C[w], x =
|
|
540
|
+
const E = C[w], x = ut(E, n, t, a, r, o);
|
|
483
541
|
_.push(...x);
|
|
484
542
|
}
|
|
485
543
|
return _;
|
|
@@ -507,7 +565,7 @@ function qe(e, n, t, a, r = !1, o = !1, s) {
|
|
|
507
565
|
}
|
|
508
566
|
return g.push(y), g.length > 0 && (g[0] = d + g[0], g[g.length - 1] = g[g.length - 1] + u), g;
|
|
509
567
|
}
|
|
510
|
-
function
|
|
568
|
+
function Ta(e, n, t, a, r, o, s = "left", c = 0, i = 0, l = 1.2, d = !1, u = !1, p = !1, f = !1, m, b) {
|
|
511
569
|
e.font = R(r, o, d, u), e.textBaseline = "alphabetic", e.textAlign = s;
|
|
512
570
|
const h = (w) => {
|
|
513
571
|
for (const E of w) {
|
|
@@ -516,13 +574,13 @@ function fa(e, n, t, a, r, o, s = "left", c = 0, i = 0, l = 1.2, d = !1, u = !1,
|
|
|
516
574
|
return !0;
|
|
517
575
|
}
|
|
518
576
|
return !1;
|
|
519
|
-
}, S = m && Object.values(m).some((w) => w), $ = b && b.length > 0, v = n.join(" "), g = h(v), y = S || $ || g, k = y ?
|
|
520
|
-
y && !k && (
|
|
577
|
+
}, S = m && Object.values(m).some((w) => w), $ = b && b.length > 0, v = n.join(" "), g = h(v), y = S || $ || g, k = y ? Hn.getFontSync(o, d ? 700 : 400) : null;
|
|
578
|
+
y && !k && (Tn.warn(
|
|
521
579
|
`[renderMultilineText] Font ${o} not loaded for fontkit rendering. Text may not render correctly. Has PUA: ${g}, Text: "${v}"`
|
|
522
|
-
),
|
|
523
|
-
|
|
580
|
+
), Hn.loadFont(o, d ? 700 : 400).catch((w) => {
|
|
581
|
+
Tn.error("[renderMultilineText] Error loading font:", w);
|
|
524
582
|
}));
|
|
525
|
-
const T =
|
|
583
|
+
const T = cn(r, o, d, u), C = r * l;
|
|
526
584
|
let _ = 0;
|
|
527
585
|
n.forEach((w, E) => {
|
|
528
586
|
let x = t + i;
|
|
@@ -535,21 +593,21 @@ function fa(e, n, t, a, r, o, s = "left", c = 0, i = 0, l = 1.2, d = !1, u = !1,
|
|
|
535
593
|
charIndex: D.charIndex - _
|
|
536
594
|
// Adjust to line-relative index
|
|
537
595
|
})) : [];
|
|
538
|
-
if (k && (S || F.length > 0 || g) ? F.length > 0 || h(w) ?
|
|
596
|
+
if (k && (S || F.length > 0 || g) ? F.length > 0 || h(w) ? lt(e, k, w, x, P, r, F, {
|
|
539
597
|
color: e.fillStyle,
|
|
540
598
|
align: s === "start" || s === "end" ? "left" : s
|
|
541
|
-
}) : m &&
|
|
599
|
+
}) : m && ct(e, k, w, x, P, r, m, {
|
|
542
600
|
color: e.fillStyle,
|
|
543
601
|
align: s === "start" || s === "end" ? "left" : s
|
|
544
602
|
}) : e.fillText(w, x, P), _ += A + 1, p) {
|
|
545
|
-
const D =
|
|
603
|
+
const D = Xn(w, r, o, d, u);
|
|
546
604
|
let I = x;
|
|
547
605
|
s === "center" ? I = x - D / 2 : s === "right" && (I = x - D);
|
|
548
606
|
const M = P + r * 0.1;
|
|
549
607
|
e.beginPath(), e.moveTo(I, M), e.lineTo(I + D, M), e.lineWidth = Math.max(1, r * 0.05), e.strokeStyle = e.fillStyle, e.stroke();
|
|
550
608
|
}
|
|
551
609
|
if (f) {
|
|
552
|
-
const D =
|
|
610
|
+
const D = Xn(w, r, o, d, u);
|
|
553
611
|
let I = x;
|
|
554
612
|
s === "center" ? I = x - D / 2 : s === "right" && (I = x - D);
|
|
555
613
|
const M = P - r * 0.25;
|
|
@@ -557,18 +615,18 @@ function fa(e, n, t, a, r, o, s = "left", c = 0, i = 0, l = 1.2, d = !1, u = !1,
|
|
|
557
615
|
}
|
|
558
616
|
});
|
|
559
617
|
}
|
|
560
|
-
function
|
|
561
|
-
|
|
618
|
+
function _n(e, n) {
|
|
619
|
+
pt(e, n);
|
|
562
620
|
}
|
|
563
|
-
function
|
|
621
|
+
function pt(e, n) {
|
|
564
622
|
var r;
|
|
565
|
-
(r = n.stroke) != null && r.enabled &&
|
|
566
|
-
const t = n.transformData, a = ((t == null ? void 0 : t.width) ?? 100) -
|
|
623
|
+
(r = n.stroke) != null && r.enabled && me(e, n), e.save(), e.translate(n.x, n.y), e.rotate(-n.rotation * Math.PI / 180);
|
|
624
|
+
const t = n.transformData, a = ((t == null ? void 0 : t.width) ?? 100) - J * 2;
|
|
567
625
|
if (n.richText) {
|
|
568
|
-
const o =
|
|
626
|
+
const o = Ne.fromJSON(n.richText);
|
|
569
627
|
e.save(), e.translate(0, 0);
|
|
570
628
|
const s = n._lockedLineCount;
|
|
571
|
-
|
|
629
|
+
dt(
|
|
572
630
|
e,
|
|
573
631
|
o,
|
|
574
632
|
{
|
|
@@ -586,7 +644,7 @@ function Xe(e, n) {
|
|
|
586
644
|
), e.restore();
|
|
587
645
|
} else if (n.text) {
|
|
588
646
|
e.fillStyle = n.color;
|
|
589
|
-
const o = n._lockedLineCount, { lines: s, height: c } =
|
|
647
|
+
const o = n._lockedLineCount, { lines: s, height: c } = he(
|
|
590
648
|
n.text,
|
|
591
649
|
a,
|
|
592
650
|
n.fontSize,
|
|
@@ -596,12 +654,12 @@ function Xe(e, n) {
|
|
|
596
654
|
o,
|
|
597
655
|
!0
|
|
598
656
|
// strict: true
|
|
599
|
-
), i =
|
|
657
|
+
), i = cn(
|
|
600
658
|
n.fontSize,
|
|
601
659
|
n.fontFamily,
|
|
602
660
|
n.bold,
|
|
603
661
|
n.italic
|
|
604
|
-
), l = -((t == null ? void 0 : t.width) ?? 100) / 2, d = -c / 2, u = n.fontSize *
|
|
662
|
+
), l = -((t == null ? void 0 : t.width) ?? 100) / 2, d = -c / 2, u = n.fontSize * Ln;
|
|
605
663
|
e.font = `${n.italic ? "italic " : ""}${n.bold ? "bold " : ""}${n.fontSize}px ${n.fontFamily}`, e.textBaseline = "alphabetic", e.textAlign = n.textAlign, s.forEach((p, f) => {
|
|
606
664
|
const m = f === 0, b = f === s.length - 1;
|
|
607
665
|
let h = p;
|
|
@@ -613,8 +671,8 @@ function Xe(e, n) {
|
|
|
613
671
|
const v = h.match(/ +$/), g = v ? v[0].length : 0;
|
|
614
672
|
g > 0 && (h = h.substring(0, h.length - g));
|
|
615
673
|
}
|
|
616
|
-
let S = l +
|
|
617
|
-
n.textAlign === "center" ? S = l + ((t == null ? void 0 : t.width) ?? 100) / 2 : n.textAlign === "right" && (S = l + ((t == null ? void 0 : t.width) ?? 100) -
|
|
674
|
+
let S = l + J;
|
|
675
|
+
n.textAlign === "center" ? S = l + ((t == null ? void 0 : t.width) ?? 100) / 2 : n.textAlign === "right" && (S = l + ((t == null ? void 0 : t.width) ?? 100) - J);
|
|
618
676
|
const $ = d + i.ascent + f * u;
|
|
619
677
|
if (e.fillText(h, S, $), h.length > 0) {
|
|
620
678
|
const v = e.measureText(h).width;
|
|
@@ -632,17 +690,17 @@ function Xe(e, n) {
|
|
|
632
690
|
}
|
|
633
691
|
e.restore();
|
|
634
692
|
}
|
|
635
|
-
function
|
|
693
|
+
function _a(e, n) {
|
|
636
694
|
var s;
|
|
637
695
|
const t = n.opacity ?? 1, a = !!((s = n.stroke) != null && s.enabled), r = n.type === "custom";
|
|
638
696
|
if (t < 1 && a && r) {
|
|
639
|
-
|
|
697
|
+
ht(e, n, t);
|
|
640
698
|
return;
|
|
641
699
|
}
|
|
642
700
|
const o = e.globalAlpha;
|
|
643
|
-
t !== 1 && (e.globalAlpha = t),
|
|
701
|
+
t !== 1 && (e.globalAlpha = t), En(e, n), e.globalAlpha = o;
|
|
644
702
|
}
|
|
645
|
-
function
|
|
703
|
+
function ht(e, n, t) {
|
|
646
704
|
var h;
|
|
647
705
|
const a = n.transformData, r = n.fontSize || 24, o = ((h = n.stroke) == null ? void 0 : h.width) || 0, s = ((a == null ? void 0 : a.width) ?? r * n.text.length * 0.7) + o * 2 + 40, c = r * 3 + o * 2 + 40, i = e.getTransform(), l = Math.max(Math.abs(i.a), Math.abs(i.d), 1), d = Math.ceil(s * l), u = Math.ceil(c * l);
|
|
648
706
|
let p;
|
|
@@ -650,7 +708,7 @@ function Ye(e, n, t) {
|
|
|
650
708
|
const f = p.getContext("2d");
|
|
651
709
|
if (!f) {
|
|
652
710
|
const S = e.globalAlpha;
|
|
653
|
-
e.globalAlpha = t,
|
|
711
|
+
e.globalAlpha = t, En(e, n), e.globalAlpha = S;
|
|
654
712
|
return;
|
|
655
713
|
}
|
|
656
714
|
const m = i.a * n.x + i.e, b = i.d * n.y + i.f;
|
|
@@ -661,42 +719,42 @@ function Ye(e, n, t) {
|
|
|
661
719
|
i.d,
|
|
662
720
|
i.e - m + d / 2,
|
|
663
721
|
i.f - b + u / 2
|
|
664
|
-
),
|
|
722
|
+
), En(f, n), e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.globalAlpha = t, e.drawImage(p, m - d / 2, b - u / 2), e.restore();
|
|
665
723
|
}
|
|
666
|
-
function
|
|
724
|
+
function En(e, n) {
|
|
667
725
|
switch (n.type) {
|
|
668
726
|
case "custom":
|
|
669
|
-
|
|
727
|
+
_n(e, n);
|
|
670
728
|
break;
|
|
671
729
|
case "circle":
|
|
672
|
-
|
|
730
|
+
ye(e, n);
|
|
673
731
|
break;
|
|
674
732
|
case "wave":
|
|
675
|
-
|
|
733
|
+
$e(e, n);
|
|
676
734
|
break;
|
|
677
735
|
case "arch":
|
|
678
|
-
|
|
736
|
+
xe(e, n);
|
|
679
737
|
break;
|
|
680
738
|
case "ascend":
|
|
681
|
-
|
|
739
|
+
ve(e, n);
|
|
682
740
|
break;
|
|
683
741
|
case "lean":
|
|
684
|
-
|
|
742
|
+
we(e, n);
|
|
685
743
|
break;
|
|
686
744
|
case "flag":
|
|
687
|
-
|
|
745
|
+
Se(e, n);
|
|
688
746
|
break;
|
|
689
747
|
default:
|
|
690
|
-
|
|
748
|
+
Tn.warn(`[canvas-renderer] Unsupported transform type: ${n.type}`), _n(e, n);
|
|
691
749
|
}
|
|
692
750
|
}
|
|
693
|
-
function
|
|
751
|
+
function bt(e, n) {
|
|
694
752
|
if (typeof OffscreenCanvas < "u")
|
|
695
753
|
return new OffscreenCanvas(e, n);
|
|
696
754
|
const t = document.createElement("canvas");
|
|
697
755
|
return t.width = e, t.height = n, t;
|
|
698
756
|
}
|
|
699
|
-
function
|
|
757
|
+
function Q(e, n, t) {
|
|
700
758
|
if (t != null && t.enabled)
|
|
701
759
|
if (e.strokeStyle = t.color, e.lineWidth = t.width, e.lineCap = t.lineCap || "round", e.lineJoin = t.lineJoin || "round", t.miterLimit !== void 0 && (e.miterLimit = t.miterLimit), t.opacity !== void 0) {
|
|
702
760
|
const a = e.globalAlpha;
|
|
@@ -704,7 +762,7 @@ function J(e, n, t) {
|
|
|
704
762
|
} else
|
|
705
763
|
e.strokeText(n, 0, 0);
|
|
706
764
|
}
|
|
707
|
-
function
|
|
765
|
+
function nn(e, n, t) {
|
|
708
766
|
const a = n.stroke, r = (a == null ? void 0 : a.opacity) ?? 1, o = e.globalAlpha, s = (a == null ? void 0 : a.enabled) && r < 1, c = (a == null ? void 0 : a.enabled) && o < 1;
|
|
709
767
|
if (!(s || c)) {
|
|
710
768
|
t(e, n);
|
|
@@ -715,7 +773,7 @@ function Z(e, n, t) {
|
|
|
715
773
|
t(e, n);
|
|
716
774
|
return;
|
|
717
775
|
}
|
|
718
|
-
const _ =
|
|
776
|
+
const _ = bt(T, C), w = _.getContext("2d");
|
|
719
777
|
if (!w) {
|
|
720
778
|
t(e, n);
|
|
721
779
|
return;
|
|
@@ -730,8 +788,8 @@ function Z(e, n, t) {
|
|
|
730
788
|
C / 2 - A + y.f
|
|
731
789
|
), c) {
|
|
732
790
|
w.globalAlpha = 1;
|
|
733
|
-
const
|
|
734
|
-
s && (a.opacity = 1), t(w, n), s && (a.opacity =
|
|
791
|
+
const en = a.opacity;
|
|
792
|
+
s && (a.opacity = 1), t(w, n), s && (a.opacity = en), e.save(), e.resetTransform(), e.globalAlpha = o, e.drawImage(_, F, D), e.restore();
|
|
735
793
|
return;
|
|
736
794
|
}
|
|
737
795
|
const I = a.opacity;
|
|
@@ -743,10 +801,10 @@ function Z(e, n, t) {
|
|
|
743
801
|
D
|
|
744
802
|
), e.restore();
|
|
745
803
|
}
|
|
746
|
-
function
|
|
747
|
-
|
|
804
|
+
function ye(e, n) {
|
|
805
|
+
nn(e, n, gt);
|
|
748
806
|
}
|
|
749
|
-
function
|
|
807
|
+
function gt(e, n) {
|
|
750
808
|
const t = n.transformData;
|
|
751
809
|
e.save(), e.translate(n.x, n.y), e.rotate(-n.rotation * Math.PI / 180), e.scale(t.scale, t.scale);
|
|
752
810
|
const a = n.bold ? "bold" : "normal", r = n.italic ? "italic" : "normal";
|
|
@@ -756,100 +814,143 @@ function Ze(e, n) {
|
|
|
756
814
|
let i = Math.PI / 2 + c / (2 * t.radius);
|
|
757
815
|
o.forEach((l, d) => {
|
|
758
816
|
const p = s[d] / t.radius, f = Math.cos(i - p / 2) * t.radius, m = Math.sin(i - p / 2) * t.radius;
|
|
759
|
-
e.save(), e.translate(f, m), e.rotate(i - p / 2 - Math.PI / 2),
|
|
817
|
+
e.save(), e.translate(f, m), e.rotate(i - p / 2 - Math.PI / 2), Q(e, l, n.stroke), e.fillText(l, 0, 0), e.restore(), i -= p;
|
|
760
818
|
});
|
|
761
819
|
} else {
|
|
762
820
|
let i = -Math.PI / 2 - c / (2 * t.radius);
|
|
763
821
|
o.forEach((l, d) => {
|
|
764
822
|
const p = s[d] / t.radius, f = Math.cos(i + p / 2) * t.radius, m = Math.sin(i + p / 2) * t.radius;
|
|
765
|
-
e.save(), e.translate(f, m), e.rotate(i + p / 2 + Math.PI / 2),
|
|
823
|
+
e.save(), e.translate(f, m), e.rotate(i + p / 2 + Math.PI / 2), Q(e, l, n.stroke), e.fillText(l, 0, 0), e.restore(), i += p;
|
|
766
824
|
});
|
|
767
825
|
}
|
|
768
826
|
e.restore();
|
|
769
827
|
}
|
|
770
|
-
function
|
|
771
|
-
|
|
828
|
+
function $e(e, n) {
|
|
829
|
+
nn(e, n, mt);
|
|
772
830
|
}
|
|
773
|
-
function
|
|
831
|
+
function mt(e, n) {
|
|
774
832
|
const t = n.transformData;
|
|
775
833
|
e.save(), e.translate(n.x, n.y), e.rotate(-n.rotation * Math.PI / 180), e.font = R(n.fontSize, n.fontFamily, n.bold, n.italic), e.fillStyle = n.color, e.textAlign = "center", e.textBaseline = "middle";
|
|
776
834
|
const a = n.text.split("");
|
|
777
835
|
let o = -a.reduce((s, c) => s + e.measureText(c).width, 0) / 2;
|
|
778
836
|
a.forEach((s) => {
|
|
779
837
|
const c = e.measureText(s).width, i = o + c / 2, l = i / (t.width / 2), d = t.amplitude * n.fontSize * Math.sin(t.frequency * Math.PI * l), u = t.amplitude * t.frequency * Math.PI * Math.cos(t.frequency * Math.PI * l);
|
|
780
|
-
e.save(), e.translate(i, d), e.transform(1, u *
|
|
838
|
+
e.save(), e.translate(i, d), e.transform(1, u * Ue, 0, 1, 0, 0), Q(e, s, n.stroke), e.fillText(s, 0, 0), e.restore(), o += c;
|
|
781
839
|
}), e.restore();
|
|
782
840
|
}
|
|
783
|
-
function
|
|
784
|
-
|
|
841
|
+
function xe(e, n) {
|
|
842
|
+
nn(e, n, yt);
|
|
785
843
|
}
|
|
786
|
-
function
|
|
844
|
+
function yt(e, n) {
|
|
787
845
|
const t = n.transformData;
|
|
788
846
|
e.save(), e.translate(n.x, n.y), e.rotate(-n.rotation * Math.PI / 180), e.font = R(n.fontSize, n.fontFamily, n.bold, n.italic), e.fillStyle = n.color, e.textAlign = "center", e.textBaseline = "middle";
|
|
789
847
|
const a = n.text.split(""), r = a.reduce((c, i) => c + e.measureText(i).width, 0), o = t.width / 2;
|
|
790
848
|
let s = -r / 2;
|
|
791
849
|
a.forEach((c) => {
|
|
792
850
|
const i = e.measureText(c).width, l = s + i / 2, d = l / o, u = (Math.pow(d, 2) - 1) * t.archHeight * n.fontSize, p = 2 * d * t.archHeight;
|
|
793
|
-
e.save(), e.translate(l, u), e.transform(1, p * 0.3, 0, 1, 0, 0),
|
|
851
|
+
e.save(), e.translate(l, u), e.transform(1, p * 0.3, 0, 1, 0, 0), Q(e, c, n.stroke), e.fillText(c, 0, 0), e.restore(), s += i;
|
|
794
852
|
}), e.restore();
|
|
795
853
|
}
|
|
796
|
-
function
|
|
797
|
-
|
|
854
|
+
function ve(e, n) {
|
|
855
|
+
nn(e, n, $t);
|
|
798
856
|
}
|
|
799
|
-
function
|
|
857
|
+
function $t(e, n) {
|
|
800
858
|
const t = n.transformData;
|
|
801
859
|
e.save(), e.translate(n.x, n.y), e.rotate(-n.rotation * Math.PI / 180), e.font = R(n.fontSize, n.fontFamily, n.bold, n.italic), e.fillStyle = n.color, e.textAlign = "center", e.textBaseline = "middle";
|
|
802
860
|
const a = n.text.split(""), r = a.reduce((c, i) => c + e.measureText(i).width, 0), o = t.ascendAngle * Math.PI / 180;
|
|
803
861
|
let s = -r / 2;
|
|
804
862
|
a.forEach((c) => {
|
|
805
863
|
const i = e.measureText(c).width, l = s + i / 2, d = l * Math.tan(o), u = Math.tan(o);
|
|
806
|
-
e.save(), e.translate(l, d), e.transform(1, u * 1, 0, 1, 0, 0),
|
|
864
|
+
e.save(), e.translate(l, d), e.transform(1, u * 1, 0, 1, 0, 0), Q(e, c, n.stroke), e.fillText(c, 0, 0), e.restore(), s += i;
|
|
807
865
|
}), e.restore();
|
|
808
866
|
}
|
|
809
|
-
function
|
|
810
|
-
|
|
867
|
+
function we(e, n) {
|
|
868
|
+
nn(e, n, xt);
|
|
811
869
|
}
|
|
812
|
-
function
|
|
870
|
+
function xt(e, n) {
|
|
813
871
|
var r;
|
|
814
872
|
const t = n.transformData;
|
|
815
873
|
e.save(), e.translate(n.x, n.y), e.rotate(-n.rotation * Math.PI / 180);
|
|
816
874
|
const a = -t.leanAmount * Math.PI / 4;
|
|
817
875
|
e.transform(1, 0, Math.tan(a), 1, 0, 0), e.font = R(n.fontSize, n.fontFamily, n.bold, n.italic), e.fillStyle = n.color, e.textAlign = "center", e.textBaseline = "middle", (r = n.stroke) != null && r.enabled && (e.save(), e.strokeStyle = n.stroke.color, e.lineWidth = n.stroke.width, e.lineCap = n.stroke.lineCap || "round", e.lineJoin = n.stroke.lineJoin || "round", n.stroke.opacity !== void 0 && (e.globalAlpha = n.stroke.opacity), e.strokeText(n.text, 0, 0), e.restore()), e.fillText(n.text, 0, 0), e.restore();
|
|
818
876
|
}
|
|
819
|
-
function
|
|
820
|
-
|
|
877
|
+
function Se(e, n) {
|
|
878
|
+
nn(e, n, vt);
|
|
821
879
|
}
|
|
822
|
-
function
|
|
880
|
+
function vt(e, n) {
|
|
823
881
|
const t = n.transformData;
|
|
824
882
|
e.save(), e.translate(n.x, n.y), e.rotate(-n.rotation * Math.PI / 180), e.font = R(n.fontSize, n.fontFamily, n.bold, n.italic), e.fillStyle = n.color, e.textAlign = "center", e.textBaseline = "middle";
|
|
825
883
|
const a = n.text.split("");
|
|
826
884
|
let o = -a.reduce((s, c) => s + e.measureText(c).width, 0) / 2;
|
|
827
885
|
a.forEach((s) => {
|
|
828
886
|
const c = e.measureText(s).width, i = o + c / 2, l = i / (t.width / 2), d = Math.abs(l), u = t.amplitude * d, p = u * n.fontSize * Math.sin(t.frequency * Math.PI * l), f = u * t.frequency * Math.PI * Math.cos(t.frequency * Math.PI * l), m = t.amplitude * Math.sign(l) * Math.sin(t.frequency * Math.PI * l), b = f + m;
|
|
829
|
-
e.save(), e.translate(i, p), e.transform(1, b * 0.3, 0, 1, 0, 0),
|
|
887
|
+
e.save(), e.translate(i, p), e.transform(1, b * 0.3, 0, 1, 0, 0), Q(e, s, n.stroke), e.fillText(s, 0, 0), e.restore(), o += c;
|
|
830
888
|
}), e.restore();
|
|
831
889
|
}
|
|
832
|
-
function
|
|
890
|
+
function q(e) {
|
|
891
|
+
return (n, t) => e(n, t);
|
|
892
|
+
}
|
|
893
|
+
function wt(e, n) {
|
|
894
|
+
e.save();
|
|
895
|
+
const t = e.canvas, a = t.width, r = t.height, o = e.getTransform(), s = [];
|
|
896
|
+
let c = [];
|
|
897
|
+
for (const i of n)
|
|
898
|
+
i.isClipping ? c.length > 0 ? (s.push({ content: c, mask: i }), c = []) : s.push({ content: [i] }) : c.push(i);
|
|
899
|
+
c.length > 0 && s.push({ content: c });
|
|
900
|
+
for (const i of s)
|
|
901
|
+
if (!i.mask)
|
|
902
|
+
i.content.forEach((l) => l.render(e, !1, !1));
|
|
903
|
+
else {
|
|
904
|
+
const l = document.createElement("canvas");
|
|
905
|
+
l.width = a, l.height = r;
|
|
906
|
+
const d = l.getContext("2d");
|
|
907
|
+
if (!d) continue;
|
|
908
|
+
d.setTransform(o), i.content.forEach((f) => {
|
|
909
|
+
f.render(d, !1, !1);
|
|
910
|
+
});
|
|
911
|
+
const u = document.createElement("canvas");
|
|
912
|
+
u.width = a, u.height = r;
|
|
913
|
+
const p = u.getContext("2d");
|
|
914
|
+
if (!p) continue;
|
|
915
|
+
if (p.setTransform(o), i.mask.render(p, !1, !1), i.mask.transformType !== "image" && i.mask.transformType !== "shape") {
|
|
916
|
+
const f = i.mask.getBoundingBox();
|
|
917
|
+
p.save(), p.fillStyle = "#FFFFFF", p.fillRect(f.x, f.y, f.width, f.height), p.restore();
|
|
918
|
+
}
|
|
919
|
+
d.globalCompositeOperation = "destination-in", d.setTransform(1, 0, 0, 1, 0, 0), d.drawImage(u, 0, 0), e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(l, 0, 0), e.setTransform(o);
|
|
920
|
+
}
|
|
921
|
+
e.restore();
|
|
922
|
+
}
|
|
923
|
+
var Yn = !1;
|
|
924
|
+
function Un() {
|
|
925
|
+
Yn || (Yn = !0, j("arch", q(xe)), j("ascend", q(ve)), j("circle", q(ye)), j("flag", q(Se)), j("lean", q(we)), j("wave", q($e)), j(
|
|
926
|
+
"custom",
|
|
927
|
+
(e, n) => _n(e, n)
|
|
928
|
+
), ze(wt), Je(
|
|
929
|
+
(e, n) => et(e, n)
|
|
930
|
+
), globalThis.__scElementPaintersInstalled = !0);
|
|
931
|
+
}
|
|
932
|
+
Un();
|
|
933
|
+
function zn(e, n, t = {}) {
|
|
833
934
|
const a = t.mode || "both";
|
|
834
935
|
switch (e.save(), e.translate(n.x || 0, n.y || 0), e.rotate(-(n.rotation || 0) * Math.PI / 180), n.transformType) {
|
|
835
936
|
case "image":
|
|
836
|
-
|
|
937
|
+
Ct(e, n, a, t);
|
|
837
938
|
break;
|
|
838
939
|
case "shape":
|
|
839
|
-
|
|
940
|
+
kt(e, n, a, t);
|
|
840
941
|
break;
|
|
841
942
|
case "group":
|
|
842
943
|
break;
|
|
843
944
|
default:
|
|
844
|
-
|
|
945
|
+
St(e, n, a, t);
|
|
845
946
|
break;
|
|
846
947
|
}
|
|
847
948
|
e.restore();
|
|
848
949
|
}
|
|
849
|
-
function
|
|
950
|
+
function St(e, n, t, a) {
|
|
850
951
|
var s;
|
|
851
952
|
const r = n, o = r.text || "";
|
|
852
|
-
o && ((t === "stroke" || t === "both") && ((s = n.stroke) != null && s.enabled) && (e.save(),
|
|
953
|
+
o && ((t === "stroke" || t === "both") && ((s = n.stroke) != null && s.enabled) && (e.save(), me(e, n, { ...a.renderingContext, positionApplied: !0 }), e.restore()), (t === "fill" || t === "both") && (e.save(), ft(e, {
|
|
853
954
|
text: o,
|
|
854
955
|
fontSize: r.fontSize || 24,
|
|
855
956
|
fontFamily: r.fontFamily || "Arial",
|
|
@@ -859,12 +960,12 @@ function lt(e, n, t, a) {
|
|
|
859
960
|
color: r.color || "#000000"
|
|
860
961
|
}), e.restore()));
|
|
861
962
|
}
|
|
862
|
-
function
|
|
963
|
+
function Ct(e, n, t, a) {
|
|
863
964
|
var o;
|
|
864
965
|
if (!n.transformData) return;
|
|
865
966
|
const r = n.transformData;
|
|
866
967
|
if (t === "fill" || t === "both")
|
|
867
|
-
if (
|
|
968
|
+
if (Pt(e, n), a.loadedImage) {
|
|
868
969
|
e.save(), e.clip();
|
|
869
970
|
const s = r.flipHorizontal ? -1 : 1, c = r.flipVertical ? -1 : 1;
|
|
870
971
|
e.scale(s, c);
|
|
@@ -872,34 +973,34 @@ function dt(e, n, t, a) {
|
|
|
872
973
|
e.drawImage(a.loadedImage, -i / 2, -l / 2, i, l), e.restore();
|
|
873
974
|
} else
|
|
874
975
|
e.fillStyle = "#cccccc", e.fill();
|
|
875
|
-
(t === "stroke" || t === "both") && ((o = n.stroke) != null && o.enabled) && (e.save(),
|
|
976
|
+
(t === "stroke" || t === "both") && ((o = n.stroke) != null && o.enabled) && (e.save(), ot(e, n, a.renderingContext), e.restore());
|
|
876
977
|
}
|
|
877
|
-
function
|
|
978
|
+
function kt(e, n, t, a) {
|
|
878
979
|
var s, c;
|
|
879
980
|
if (!n.transformData) return;
|
|
880
981
|
const r = n.transformData, o = ((s = a.renderingContext) == null ? void 0 : s.isKnockout) === !0;
|
|
881
|
-
e.beginPath(),
|
|
982
|
+
e.beginPath(), Ce(e, r), (t === "fill" || t === "both") && (e.fillStyle = o ? "#000000" : r.fillColor || "#3b82f6", e.globalAlpha = o ? 1 : r.fillOpacity ?? 1, e.fill()), (t === "stroke" || t === "both") && ((c = n.stroke) != null && c.enabled) && (e.save(), At(e, n, a.renderingContext), e.restore());
|
|
882
983
|
}
|
|
883
|
-
function
|
|
984
|
+
function Ce(e, n) {
|
|
884
985
|
const { shapeType: t } = n, a = n.width ?? 100, r = n.height ?? 100;
|
|
885
986
|
switch (t) {
|
|
886
987
|
case "rectangle":
|
|
887
|
-
|
|
988
|
+
Kn(e, n, a, r);
|
|
888
989
|
break;
|
|
889
990
|
case "circle":
|
|
890
|
-
|
|
991
|
+
Tt(e, Math.min(a, r) / 2);
|
|
891
992
|
break;
|
|
892
993
|
case "ellipse":
|
|
893
|
-
|
|
994
|
+
_t(e, a / 2, r / 2);
|
|
894
995
|
break;
|
|
895
996
|
case "star":
|
|
896
|
-
|
|
997
|
+
Et(e, n, Math.min(a, r) / 2);
|
|
897
998
|
break;
|
|
898
999
|
default:
|
|
899
|
-
|
|
1000
|
+
Kn(e, n, a, r);
|
|
900
1001
|
}
|
|
901
1002
|
}
|
|
902
|
-
function
|
|
1003
|
+
function Kn(e, n, t, a) {
|
|
903
1004
|
const r = n.borderRadius || 0, o = -t / 2, s = -a / 2;
|
|
904
1005
|
if (r > 0) {
|
|
905
1006
|
const c = Math.min(r / 100 * Math.min(t, a), t / 2, a / 2);
|
|
@@ -907,13 +1008,13 @@ function Vn(e, n, t, a) {
|
|
|
907
1008
|
} else
|
|
908
1009
|
e.rect(o, s, t, a);
|
|
909
1010
|
}
|
|
910
|
-
function
|
|
1011
|
+
function Tt(e, n) {
|
|
911
1012
|
e.arc(0, 0, n, 0, Math.PI * 2);
|
|
912
1013
|
}
|
|
913
|
-
function
|
|
1014
|
+
function _t(e, n, t) {
|
|
914
1015
|
e.ellipse(0, 0, n, t, 0, 0, Math.PI * 2);
|
|
915
1016
|
}
|
|
916
|
-
function
|
|
1017
|
+
function Et(e, n, t) {
|
|
917
1018
|
const a = Math.max(3, Math.min(20, n.points || 5)), r = Math.max(0.1, Math.min(0.9, n.innerRadius || 0.4)), o = t * r, s = Math.PI / a, c = -Math.PI / 2;
|
|
918
1019
|
for (let i = 0; i < a * 2; i++) {
|
|
919
1020
|
const l = c + s * i, d = i % 2 === 0 ? t : o, u = Math.cos(l) * d, p = Math.sin(l) * d;
|
|
@@ -921,13 +1022,13 @@ function ht(e, n, t) {
|
|
|
921
1022
|
}
|
|
922
1023
|
e.closePath();
|
|
923
1024
|
}
|
|
924
|
-
function
|
|
1025
|
+
function At(e, n, t) {
|
|
925
1026
|
var r;
|
|
926
1027
|
if (!((r = n.stroke) != null && r.enabled) || !n.transformData) return;
|
|
927
1028
|
const a = (t == null ? void 0 : t.isKnockout) === !0;
|
|
928
|
-
e.save(), a ? (e.strokeStyle = "#000000", e.lineWidth = n.stroke.width, e.lineCap = n.stroke.lineCap || "butt", e.lineJoin = n.stroke.lineJoin || "miter", e.globalAlpha = 1) : (e.strokeStyle = n.stroke.color, e.lineWidth = n.stroke.width, e.lineCap = n.stroke.lineCap || "butt", e.lineJoin = n.stroke.lineJoin || "miter", n.stroke.opacity !== void 0 && (e.globalAlpha = n.stroke.opacity)), n.stroke.miterLimit !== void 0 && (e.miterLimit = n.stroke.miterLimit), n.stroke.dashArray && n.stroke.dashArray.length > 0 && e.setLineDash(n.stroke.dashArray), !a && n.stroke.feather && n.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${n.stroke.feather}px)`), e.beginPath(),
|
|
1029
|
+
e.save(), a ? (e.strokeStyle = "#000000", e.lineWidth = n.stroke.width, e.lineCap = n.stroke.lineCap || "butt", e.lineJoin = n.stroke.lineJoin || "miter", e.globalAlpha = 1) : (e.strokeStyle = n.stroke.color, e.lineWidth = n.stroke.width, e.lineCap = n.stroke.lineCap || "butt", e.lineJoin = n.stroke.lineJoin || "miter", n.stroke.opacity !== void 0 && (e.globalAlpha = n.stroke.opacity)), n.stroke.miterLimit !== void 0 && (e.miterLimit = n.stroke.miterLimit), n.stroke.dashArray && n.stroke.dashArray.length > 0 && e.setLineDash(n.stroke.dashArray), !a && n.stroke.feather && n.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${n.stroke.feather}px)`), e.beginPath(), Ce(e, n.transformData), e.stroke(), e.restore();
|
|
929
1030
|
}
|
|
930
|
-
function
|
|
1031
|
+
function Pt(e, n) {
|
|
931
1032
|
if (!n.transformData) return;
|
|
932
1033
|
const { borderRadius: t } = n.transformData, a = n.transformData.width ?? 100, r = n.transformData.height ?? 100, o = -a / 2, s = -r / 2;
|
|
933
1034
|
if (e.beginPath(), t && t > 0) {
|
|
@@ -936,7 +1037,7 @@ function gt(e, n) {
|
|
|
936
1037
|
} else
|
|
937
1038
|
e.rect(o, s, a, r);
|
|
938
1039
|
}
|
|
939
|
-
function
|
|
1040
|
+
function An(e, n, t, a, r, o, s = "destination-out") {
|
|
940
1041
|
var v;
|
|
941
1042
|
if (!n.knockoutParts) return;
|
|
942
1043
|
if (!(n.knockoutParts.fill || n.knockoutParts.stroke)) {
|
|
@@ -945,21 +1046,21 @@ function Tn(e, n, t, a, r, o, s = "destination-out") {
|
|
|
945
1046
|
}
|
|
946
1047
|
const i = e.getTransform();
|
|
947
1048
|
e.save();
|
|
948
|
-
const l = n.knockoutParts.scope || "group", d =
|
|
1049
|
+
const l = n.knockoutParts.scope || "group", d = It(n, l, t);
|
|
949
1050
|
if (d.length === 0 && l === "artboard") {
|
|
950
|
-
|
|
1051
|
+
Ft(e, n, a), e.restore();
|
|
951
1052
|
return;
|
|
952
1053
|
}
|
|
953
1054
|
if (d.length === 0) {
|
|
954
1055
|
a(e, n), e.restore();
|
|
955
1056
|
return;
|
|
956
1057
|
}
|
|
957
|
-
const u = e.canvas, f = e.getTransform().a, m =
|
|
1058
|
+
const u = e.canvas, f = e.getTransform().a, m = Mt(u.width, u.height), b = m.getContext("2d");
|
|
958
1059
|
if (!b) return;
|
|
959
1060
|
b.scale(f, f), r && o && (b.fillStyle = r, b.fillRect(o.x, o.y, o.width, o.height));
|
|
960
1061
|
for (const g of d)
|
|
961
1062
|
a(b, g);
|
|
962
|
-
n.knockoutParts.fill && !n.knockoutParts.stroke && ((v = n.stroke) != null && v.enabled) && (b.save(),
|
|
1063
|
+
n.knockoutParts.fill && !n.knockoutParts.stroke && ((v = n.stroke) != null && v.enabled) && (b.save(), In(b, n), b.restore()), b.save(), b.globalCompositeOperation = s, n.knockoutParts.fill && Pn(b, n), n.knockoutParts.stroke && In(b, n), b.restore(), n.knockoutParts.fill || (b.save(), Pn(b, n), b.restore());
|
|
963
1064
|
const h = u.width / f, S = u.height / f;
|
|
964
1065
|
e.drawImage(m, 0, 0, h, S), e.restore();
|
|
965
1066
|
const $ = e.getTransform();
|
|
@@ -972,59 +1073,59 @@ function Tn(e, n, t, a, r, o, s = "destination-out") {
|
|
|
972
1073
|
i.f
|
|
973
1074
|
);
|
|
974
1075
|
}
|
|
975
|
-
function
|
|
976
|
-
|
|
1076
|
+
function Ea(e, n, t, a, r, o) {
|
|
1077
|
+
An(e, n, t, a, r, o, "destination-out");
|
|
977
1078
|
}
|
|
978
|
-
function
|
|
979
|
-
return n === "artboard" ?
|
|
1079
|
+
function It(e, n, t) {
|
|
1080
|
+
return n === "artboard" ? ke(e, t) : Dt(e, t);
|
|
980
1081
|
}
|
|
981
|
-
function
|
|
1082
|
+
function ke(e, n) {
|
|
982
1083
|
const t = n.findIndex((a) => a.id === e.id);
|
|
983
1084
|
return t === -1 ? [] : n.slice(0, t);
|
|
984
1085
|
}
|
|
985
|
-
function
|
|
986
|
-
const t =
|
|
1086
|
+
function Dt(e, n) {
|
|
1087
|
+
const t = Te(e, n);
|
|
987
1088
|
if (!t)
|
|
988
|
-
return
|
|
1089
|
+
return ke(e, n);
|
|
989
1090
|
if (t.transformType !== "group" || !t.children)
|
|
990
1091
|
return [];
|
|
991
1092
|
const a = t.children.findIndex((r) => r.id === e.id);
|
|
992
1093
|
return a === -1 ? [] : t.children.slice(0, a);
|
|
993
1094
|
}
|
|
994
|
-
function
|
|
1095
|
+
function Te(e, n) {
|
|
995
1096
|
for (const t of n)
|
|
996
1097
|
if (t.transformType === "group" && t.children) {
|
|
997
1098
|
if (t.children.some((r) => r.id === e.id))
|
|
998
1099
|
return t;
|
|
999
|
-
const a =
|
|
1100
|
+
const a = Te(e, t.children);
|
|
1000
1101
|
if (a)
|
|
1001
1102
|
return a;
|
|
1002
1103
|
}
|
|
1003
1104
|
return null;
|
|
1004
1105
|
}
|
|
1005
|
-
function
|
|
1006
|
-
|
|
1106
|
+
function Pn(e, n, t) {
|
|
1107
|
+
zn(e, n, {
|
|
1007
1108
|
mode: "fill",
|
|
1008
1109
|
renderingContext: { isKnockout: !0 }
|
|
1009
1110
|
});
|
|
1010
1111
|
}
|
|
1011
|
-
function
|
|
1112
|
+
function In(e, n) {
|
|
1012
1113
|
var t;
|
|
1013
|
-
(t = n.stroke) != null && t.enabled &&
|
|
1114
|
+
(t = n.stroke) != null && t.enabled && zn(e, n, {
|
|
1014
1115
|
mode: "stroke",
|
|
1015
1116
|
renderingContext: { isKnockout: !0 }
|
|
1016
1117
|
});
|
|
1017
1118
|
}
|
|
1018
|
-
function
|
|
1119
|
+
function Ft(e, n, t) {
|
|
1019
1120
|
var r;
|
|
1020
1121
|
const a = n.knockoutParts;
|
|
1021
1122
|
if (!a) {
|
|
1022
1123
|
t(e, n);
|
|
1023
1124
|
return;
|
|
1024
1125
|
}
|
|
1025
|
-
a.fill || (e.save(),
|
|
1126
|
+
a.fill || (e.save(), Pn(e, n), e.restore()), !a.stroke && ((r = n.stroke) != null && r.enabled) && (e.save(), In(e, n), e.restore());
|
|
1026
1127
|
}
|
|
1027
|
-
function
|
|
1128
|
+
function Mt(e, n) {
|
|
1028
1129
|
if (typeof OffscreenCanvas < "u")
|
|
1029
1130
|
return new OffscreenCanvas(e, n);
|
|
1030
1131
|
if (typeof document < "u") {
|
|
@@ -1033,7 +1134,7 @@ function xt(e, n) {
|
|
|
1033
1134
|
}
|
|
1034
1135
|
throw new Error("No canvas context available");
|
|
1035
1136
|
}
|
|
1036
|
-
function
|
|
1137
|
+
function Jn(e, n, t, a, r = 0) {
|
|
1037
1138
|
if (t <= 0 || a <= 0 || e <= 0 || n <= 0)
|
|
1038
1139
|
return { width: e + r, height: n + r };
|
|
1039
1140
|
const o = t / a, s = e / n;
|
|
@@ -1043,11 +1144,11 @@ function jn(e, n, t, a, r = 0) {
|
|
|
1043
1144
|
height: i + r
|
|
1044
1145
|
};
|
|
1045
1146
|
}
|
|
1046
|
-
const
|
|
1047
|
-
function
|
|
1147
|
+
const tn = 64, Sn = 512;
|
|
1148
|
+
function Ot(e, n) {
|
|
1048
1149
|
e.beginPath(), e.arc(n / 2, n / 2, n * 0.45, 0, Math.PI * 2), e.fill();
|
|
1049
1150
|
}
|
|
1050
|
-
function
|
|
1151
|
+
function Rt(e, n) {
|
|
1051
1152
|
const t = n / 2, a = n / 2, r = n * 0.45, o = r * 0.4, s = 5;
|
|
1052
1153
|
e.beginPath();
|
|
1053
1154
|
for (let c = 0; c < s * 2; c++) {
|
|
@@ -1056,15 +1157,15 @@ function wt(e, n) {
|
|
|
1056
1157
|
}
|
|
1057
1158
|
e.closePath(), e.fill();
|
|
1058
1159
|
}
|
|
1059
|
-
function
|
|
1160
|
+
function Bt(e, n) {
|
|
1060
1161
|
const t = n / 2, a = n * 0.42;
|
|
1061
1162
|
e.beginPath(), e.moveTo(t, n * 0.82), e.bezierCurveTo(t - a * 1.1, n * 0.6, t - a * 1.3, n * 0.2, t, n * 0.35), e.bezierCurveTo(t + a * 1.3, n * 0.2, t + a * 1.1, n * 0.6, t, n * 0.82), e.closePath(), e.fill();
|
|
1062
1163
|
}
|
|
1063
|
-
function
|
|
1164
|
+
function Lt(e, n) {
|
|
1064
1165
|
const t = n / 2, a = n / 2, r = n * 0.4, o = n * 0.48;
|
|
1065
1166
|
e.beginPath(), e.moveTo(t, a - o), e.lineTo(t + r, a), e.lineTo(t, a + o), e.lineTo(t - r, a), e.closePath(), e.fill();
|
|
1066
1167
|
}
|
|
1067
|
-
function
|
|
1168
|
+
function Nt(e, n) {
|
|
1068
1169
|
const t = n / 2, a = n / 2, r = n * 0.44;
|
|
1069
1170
|
e.beginPath();
|
|
1070
1171
|
for (let o = 0; o < 6; o++) {
|
|
@@ -1073,11 +1174,11 @@ function kt(e, n) {
|
|
|
1073
1174
|
}
|
|
1074
1175
|
e.closePath(), e.fill();
|
|
1075
1176
|
}
|
|
1076
|
-
function
|
|
1177
|
+
function Ut(e, n) {
|
|
1077
1178
|
const t = n / 2, a = n * 0.4, r = n * 0.12;
|
|
1078
1179
|
e.beginPath(), e.moveTo(t, r), e.lineTo(t + a, n * 0.25), e.lineTo(t + a, n * 0.55), e.quadraticCurveTo(t + a * 0.3, n * 0.8, t, n * 0.9), e.quadraticCurveTo(t - a * 0.3, n * 0.8, t - a, n * 0.55), e.lineTo(t - a, n * 0.25), e.closePath(), e.fill();
|
|
1079
1180
|
}
|
|
1080
|
-
function
|
|
1181
|
+
function zt(e, n) {
|
|
1081
1182
|
const t = n / 2, a = n / 2;
|
|
1082
1183
|
let r = 42;
|
|
1083
1184
|
const o = () => (r = (r * 16807 + 0) % 2147483647, r / 2147483647);
|
|
@@ -1087,7 +1188,7 @@ function _t(e, n) {
|
|
|
1087
1188
|
e.beginPath(), e.arc(t + Math.cos(c) * i, a + Math.sin(c) * i, l, 0, Math.PI * 2), e.fill();
|
|
1088
1189
|
}
|
|
1089
1190
|
}
|
|
1090
|
-
function
|
|
1191
|
+
function Wt(e, n) {
|
|
1091
1192
|
let t = 123;
|
|
1092
1193
|
const a = () => (t = (t * 16807 + 0) % 2147483647, t / 2147483647), r = n * 0.08, o = 40;
|
|
1093
1194
|
e.beginPath(), e.moveTo(r, r);
|
|
@@ -1109,7 +1210,7 @@ function Et(e, n) {
|
|
|
1109
1210
|
}
|
|
1110
1211
|
e.closePath(), e.fill();
|
|
1111
1212
|
}
|
|
1112
|
-
function
|
|
1213
|
+
function Gt(e, n) {
|
|
1113
1214
|
let t = 77;
|
|
1114
1215
|
const a = () => (t = (t * 16807 + 0) % 2147483647, t / 2147483647), r = n * 0.25, o = n * 0.75, s = n * 0.1;
|
|
1115
1216
|
e.beginPath(), e.moveTo(s, r + a() * n * 0.05);
|
|
@@ -1123,101 +1224,101 @@ function At(e, n) {
|
|
|
1123
1224
|
}
|
|
1124
1225
|
e.closePath(), e.fill();
|
|
1125
1226
|
}
|
|
1126
|
-
function
|
|
1227
|
+
function Ht(e, n) {
|
|
1127
1228
|
const t = n / 2, a = n * 0.55;
|
|
1128
1229
|
e.beginPath(), e.arc(t, a, n * 0.2, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(t - n * 0.18, a + n * 0.02, n * 0.15, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(t + n * 0.18, a + n * 0.02, n * 0.16, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(t - n * 0.06, a - n * 0.14, n * 0.14, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(t + n * 0.1, a - n * 0.12, n * 0.12, 0, Math.PI * 2), e.fill();
|
|
1129
1230
|
}
|
|
1130
|
-
const
|
|
1231
|
+
const Vt = [
|
|
1131
1232
|
// Geometric
|
|
1132
|
-
{ id: "circle", name: "Circle", description: "Perfect circle", imageUrl: "builtin-mask:circle", thumbnailUrl: "", category: "geometric", draw:
|
|
1133
|
-
{ id: "star", name: "Star", description: "5-pointed star", imageUrl: "builtin-mask:star", thumbnailUrl: "", category: "geometric", draw:
|
|
1134
|
-
{ id: "heart", name: "Heart", description: "Heart shape", imageUrl: "builtin-mask:heart", thumbnailUrl: "", category: "geometric", draw:
|
|
1135
|
-
{ id: "diamond", name: "Diamond", description: "Diamond/rhombus", imageUrl: "builtin-mask:diamond", thumbnailUrl: "", category: "geometric", draw:
|
|
1136
|
-
{ id: "hexagon", name: "Hexagon", description: "Regular hexagon", imageUrl: "builtin-mask:hexagon", thumbnailUrl: "", category: "geometric", draw:
|
|
1137
|
-
{ id: "shield", name: "Shield", description: "Shield/crest shape", imageUrl: "builtin-mask:shield", thumbnailUrl: "", category: "geometric", draw:
|
|
1233
|
+
{ id: "circle", name: "Circle", description: "Perfect circle", imageUrl: "builtin-mask:circle", thumbnailUrl: "", category: "geometric", draw: Ot },
|
|
1234
|
+
{ id: "star", name: "Star", description: "5-pointed star", imageUrl: "builtin-mask:star", thumbnailUrl: "", category: "geometric", draw: Rt },
|
|
1235
|
+
{ id: "heart", name: "Heart", description: "Heart shape", imageUrl: "builtin-mask:heart", thumbnailUrl: "", category: "geometric", draw: Bt },
|
|
1236
|
+
{ id: "diamond", name: "Diamond", description: "Diamond/rhombus", imageUrl: "builtin-mask:diamond", thumbnailUrl: "", category: "geometric", draw: Lt },
|
|
1237
|
+
{ id: "hexagon", name: "Hexagon", description: "Regular hexagon", imageUrl: "builtin-mask:hexagon", thumbnailUrl: "", category: "geometric", draw: Nt },
|
|
1238
|
+
{ id: "shield", name: "Shield", description: "Shield/crest shape", imageUrl: "builtin-mask:shield", thumbnailUrl: "", category: "geometric", draw: Ut },
|
|
1138
1239
|
// Organic
|
|
1139
|
-
{ id: "splatter", name: "Splatter", description: "Ink splatter", imageUrl: "builtin-mask:splatter", thumbnailUrl: "", category: "organic", draw:
|
|
1140
|
-
{ id: "torn-edge", name: "Torn Edge", description: "Rough torn paper edge", imageUrl: "builtin-mask:torn-edge", thumbnailUrl: "", category: "organic", draw:
|
|
1141
|
-
{ id: "paint-stroke", name: "Paint Stroke", description: "Horizontal brush stroke", imageUrl: "builtin-mask:paint-stroke", thumbnailUrl: "", category: "organic", draw:
|
|
1142
|
-
{ id: "cloud", name: "Cloud", description: "Soft cloud shape", imageUrl: "builtin-mask:cloud", thumbnailUrl: "", category: "organic", draw:
|
|
1240
|
+
{ id: "splatter", name: "Splatter", description: "Ink splatter", imageUrl: "builtin-mask:splatter", thumbnailUrl: "", category: "organic", draw: zt },
|
|
1241
|
+
{ id: "torn-edge", name: "Torn Edge", description: "Rough torn paper edge", imageUrl: "builtin-mask:torn-edge", thumbnailUrl: "", category: "organic", draw: Wt },
|
|
1242
|
+
{ id: "paint-stroke", name: "Paint Stroke", description: "Horizontal brush stroke", imageUrl: "builtin-mask:paint-stroke", thumbnailUrl: "", category: "organic", draw: Gt },
|
|
1243
|
+
{ id: "cloud", name: "Cloud", description: "Soft cloud shape", imageUrl: "builtin-mask:cloud", thumbnailUrl: "", category: "organic", draw: Ht }
|
|
1143
1244
|
];
|
|
1144
|
-
let
|
|
1145
|
-
function
|
|
1245
|
+
let Zn = !1;
|
|
1246
|
+
function Qn(e, n) {
|
|
1146
1247
|
if (typeof document > "u") return null;
|
|
1147
1248
|
const t = document.createElement("canvas");
|
|
1148
1249
|
return t.width = e, t.height = n, t;
|
|
1149
1250
|
}
|
|
1150
|
-
function
|
|
1151
|
-
if (typeof document > "u" ||
|
|
1152
|
-
|
|
1153
|
-
const e =
|
|
1154
|
-
for (const n of
|
|
1155
|
-
const t =
|
|
1251
|
+
function jt() {
|
|
1252
|
+
if (typeof document > "u" || Zn) return;
|
|
1253
|
+
Zn = !0;
|
|
1254
|
+
const e = $n.getInstance();
|
|
1255
|
+
for (const n of Vt) {
|
|
1256
|
+
const t = Qn(Sn, Sn);
|
|
1156
1257
|
if (!t) continue;
|
|
1157
1258
|
const a = t.getContext("2d");
|
|
1158
1259
|
if (!a) continue;
|
|
1159
|
-
a.fillStyle = "white", n.draw(a,
|
|
1260
|
+
a.fillStyle = "white", n.draw(a, Sn);
|
|
1160
1261
|
const r = t.toDataURL("image/png"), o = e.acquire(n.imageUrl);
|
|
1161
1262
|
o.crossOrigin = "anonymous", o.src = r;
|
|
1162
|
-
const s =
|
|
1263
|
+
const s = Qn(tn, tn);
|
|
1163
1264
|
if (s) {
|
|
1164
1265
|
const c = s.getContext("2d");
|
|
1165
|
-
c && (c.fillStyle = "#1a1a2e", c.fillRect(0, 0,
|
|
1266
|
+
c && (c.fillStyle = "#1a1a2e", c.fillRect(0, 0, tn, tn), c.fillStyle = "white", n.draw(c, tn), n.thumbnailUrl = s.toDataURL("image/png"));
|
|
1166
1267
|
}
|
|
1167
1268
|
}
|
|
1168
1269
|
}
|
|
1169
|
-
const
|
|
1170
|
-
function
|
|
1270
|
+
const qt = N("MaskRenderer"), Dn = /* @__PURE__ */ new Map(), Xt = /* @__PURE__ */ new Map();
|
|
1271
|
+
function Aa(e) {
|
|
1171
1272
|
const n = [];
|
|
1172
|
-
|
|
1273
|
+
Dn.forEach((t, a) => {
|
|
1173
1274
|
a.startsWith(e) && n.push(a);
|
|
1174
|
-
}), n.forEach((t) =>
|
|
1275
|
+
}), n.forEach((t) => Dn.delete(t));
|
|
1175
1276
|
}
|
|
1176
|
-
function
|
|
1177
|
-
|
|
1277
|
+
function Pa() {
|
|
1278
|
+
Dn.clear();
|
|
1178
1279
|
}
|
|
1179
|
-
function
|
|
1280
|
+
function ne(e, n, t) {
|
|
1180
1281
|
if (!n.masks || n.masks.length === 0) {
|
|
1181
1282
|
t(e);
|
|
1182
1283
|
return;
|
|
1183
1284
|
}
|
|
1184
|
-
const a = e.canvas, r =
|
|
1285
|
+
const a = e.canvas, r = pn(a.width, a.height), o = r.getContext("2d");
|
|
1185
1286
|
if (!o) {
|
|
1186
|
-
|
|
1287
|
+
qt.error("[renderWithMasks] Failed to get offscreen context");
|
|
1187
1288
|
return;
|
|
1188
1289
|
}
|
|
1189
1290
|
const s = e.getTransform();
|
|
1190
1291
|
o.setTransform(s), t(o);
|
|
1191
1292
|
for (const c of n.masks)
|
|
1192
|
-
|
|
1293
|
+
Yt(o, c, n);
|
|
1193
1294
|
e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(r, 0, 0), e.restore();
|
|
1194
1295
|
}
|
|
1195
|
-
function
|
|
1296
|
+
function Yt(e, n, t) {
|
|
1196
1297
|
switch (n.type) {
|
|
1197
1298
|
case "clip":
|
|
1198
|
-
|
|
1299
|
+
Kt(e, n, t);
|
|
1199
1300
|
break;
|
|
1200
1301
|
case "alpha":
|
|
1201
|
-
|
|
1302
|
+
Jt(e, n, t);
|
|
1202
1303
|
break;
|
|
1203
1304
|
case "luma":
|
|
1204
|
-
|
|
1305
|
+
Zt(e, n, t);
|
|
1205
1306
|
break;
|
|
1206
1307
|
case "distress":
|
|
1207
|
-
|
|
1308
|
+
Qt(e, n, t);
|
|
1208
1309
|
break;
|
|
1209
1310
|
}
|
|
1210
1311
|
}
|
|
1211
|
-
function
|
|
1212
|
-
e.save(), e.globalCompositeOperation = n.inverted ? "destination-out" : "destination-in", n.opacity !== void 0 && (e.globalAlpha = n.opacity),
|
|
1312
|
+
function Kt(e, n, t) {
|
|
1313
|
+
e.save(), e.globalCompositeOperation = n.inverted ? "destination-out" : "destination-in", n.opacity !== void 0 && (e.globalAlpha = n.opacity), xn(e, n.maskElement, t), e.restore();
|
|
1213
1314
|
}
|
|
1214
|
-
function
|
|
1215
|
-
e.save(), e.globalCompositeOperation = n.inverted ? "destination-out" : "destination-in", n.opacity !== void 0 && (e.globalAlpha = n.opacity),
|
|
1315
|
+
function Jt(e, n, t) {
|
|
1316
|
+
e.save(), e.globalCompositeOperation = n.inverted ? "destination-out" : "destination-in", n.opacity !== void 0 && (e.globalAlpha = n.opacity), xn(e, n.maskElement, t), n.feather && n.feather > 0 && _e(e, n.feather), e.restore();
|
|
1216
1317
|
}
|
|
1217
|
-
function
|
|
1218
|
-
const a =
|
|
1318
|
+
function Zt(e, n, t) {
|
|
1319
|
+
const a = pn(e.canvas.width, e.canvas.height), r = a.getContext("2d");
|
|
1219
1320
|
if (!r) return;
|
|
1220
|
-
|
|
1321
|
+
xn(r, n.maskElement, t);
|
|
1221
1322
|
const o = r.getImageData(0, 0, a.width, a.height), s = o.data;
|
|
1222
1323
|
for (let c = 0; c < s.length; c += 4) {
|
|
1223
1324
|
const i = s[c], l = s[c + 1], d = s[c + 2], u = 0.299 * i + 0.587 * l + 0.114 * d;
|
|
@@ -1225,10 +1326,10 @@ function Lt(e, n, t) {
|
|
|
1225
1326
|
}
|
|
1226
1327
|
r.putImageData(o, 0, 0), e.save(), e.globalCompositeOperation = "destination-in", n.opacity !== void 0 && (e.globalAlpha = n.opacity), e.drawImage(a, 0, 0), e.restore();
|
|
1227
1328
|
}
|
|
1228
|
-
function
|
|
1229
|
-
e.save(), e.globalCompositeOperation = n.inverted ? "destination-in" : "destination-out", n.opacity !== void 0 && (e.globalAlpha = n.opacity),
|
|
1329
|
+
function Qt(e, n, t) {
|
|
1330
|
+
e.save(), e.globalCompositeOperation = n.inverted ? "destination-in" : "destination-out", n.opacity !== void 0 && (e.globalAlpha = n.opacity), xn(e, n.maskElement, t), n.feather && n.feather > 0 && _e(e, n.feather), e.restore();
|
|
1230
1331
|
}
|
|
1231
|
-
function
|
|
1332
|
+
function xn(e, n, t) {
|
|
1232
1333
|
const a = t.x || 0, r = t.y || 0, o = n.x || 0, s = n.y || 0, c = {
|
|
1233
1334
|
...n,
|
|
1234
1335
|
x: a + o,
|
|
@@ -1246,18 +1347,18 @@ function yn(e, n, t) {
|
|
|
1246
1347
|
const g = n;
|
|
1247
1348
|
if (g.imageUrl)
|
|
1248
1349
|
if (typeof document < "u") {
|
|
1249
|
-
g.imageUrl.startsWith("builtin-mask:") &&
|
|
1250
|
-
const y =
|
|
1350
|
+
g.imageUrl.startsWith("builtin-mask:") && jt();
|
|
1351
|
+
const y = $n.getInstance(), k = y.acquire(g.imageUrl);
|
|
1251
1352
|
k.complete && k.naturalWidth > 0 && (m = k), y.release(g.imageUrl);
|
|
1252
1353
|
} else
|
|
1253
|
-
b =
|
|
1354
|
+
b = Xt.get(g.imageUrl);
|
|
1254
1355
|
}
|
|
1255
1356
|
const h = c.transformData, S = (f == null ? void 0 : f.width) || 0, $ = (f == null ? void 0 : f.height) || 0, v = S > 0 && $ > 0 && u > 0 && p > 0 && Math.abs(S / $ - u / p) > 1e-3;
|
|
1256
1357
|
if (b) {
|
|
1257
1358
|
e.save();
|
|
1258
1359
|
const g = (h == null ? void 0 : h.width) || b.width, y = (h == null ? void 0 : h.height) || b.height;
|
|
1259
1360
|
if (e.translate(c.x || 0, c.y || 0), e.rotate(-(c.rotation || 0) * Math.PI / 180), v) {
|
|
1260
|
-
const k =
|
|
1361
|
+
const k = Jn(
|
|
1261
1362
|
g,
|
|
1262
1363
|
y,
|
|
1263
1364
|
S,
|
|
@@ -1269,7 +1370,7 @@ function yn(e, n, t) {
|
|
|
1269
1370
|
e.drawImage(b, -g / 2, -y / 2, g, y);
|
|
1270
1371
|
e.restore();
|
|
1271
1372
|
} else if (v && m) {
|
|
1272
|
-
const g = (h == null ? void 0 : h.width) || u, y = (h == null ? void 0 : h.height) || p, k =
|
|
1373
|
+
const g = (h == null ? void 0 : h.width) || u, y = (h == null ? void 0 : h.height) || p, k = Jn(
|
|
1273
1374
|
g,
|
|
1274
1375
|
y,
|
|
1275
1376
|
S,
|
|
@@ -1278,12 +1379,12 @@ function yn(e, n, t) {
|
|
|
1278
1379
|
);
|
|
1279
1380
|
e.save(), e.translate(c.x || 0, c.y || 0), e.rotate(-(c.rotation || 0) * Math.PI / 180), e.drawImage(m, -k.width / 2, -k.height / 2, k.width, k.height), e.restore();
|
|
1280
1381
|
} else
|
|
1281
|
-
|
|
1382
|
+
zn(e, c, { mode: "both", loadedImage: m });
|
|
1282
1383
|
}
|
|
1283
|
-
function
|
|
1384
|
+
function _e(e, n) {
|
|
1284
1385
|
"filter" in e && (e.filter = `blur(${n}px)`);
|
|
1285
1386
|
}
|
|
1286
|
-
function
|
|
1387
|
+
function pn(e, n) {
|
|
1287
1388
|
if (typeof OffscreenCanvas < "u")
|
|
1288
1389
|
return new OffscreenCanvas(e, n);
|
|
1289
1390
|
if (typeof document < "u") {
|
|
@@ -1292,9 +1393,9 @@ function fn(e, n) {
|
|
|
1292
1393
|
}
|
|
1293
1394
|
throw new Error("No canvas context available");
|
|
1294
1395
|
}
|
|
1295
|
-
function
|
|
1396
|
+
function na(e, n, t, a) {
|
|
1296
1397
|
if (!n.enabled || !n.imageUrl || n.opacity <= 0) return;
|
|
1297
|
-
const r =
|
|
1398
|
+
const r = $n.getInstance(), o = r.acquire(n.imageUrl);
|
|
1298
1399
|
if (!o.complete || o.naturalWidth === 0) {
|
|
1299
1400
|
r.release(n.imageUrl);
|
|
1300
1401
|
return;
|
|
@@ -1304,7 +1405,7 @@ function Ut(e, n, t, a) {
|
|
|
1304
1405
|
r.release(n.imageUrl);
|
|
1305
1406
|
return;
|
|
1306
1407
|
}
|
|
1307
|
-
const S =
|
|
1408
|
+
const S = pn(b, h), $ = S.getContext("2d");
|
|
1308
1409
|
if (!$) {
|
|
1309
1410
|
r.release(n.imageUrl);
|
|
1310
1411
|
return;
|
|
@@ -1322,7 +1423,7 @@ function Ut(e, n, t, a) {
|
|
|
1322
1423
|
);
|
|
1323
1424
|
let v;
|
|
1324
1425
|
if (n.maskType === "luma" ? v = "destination-in" : v = n.inverted ? "destination-out" : "destination-in", n.maskType === "luma") {
|
|
1325
|
-
const g =
|
|
1426
|
+
const g = pn(b, h), y = g.getContext("2d");
|
|
1326
1427
|
if (y) {
|
|
1327
1428
|
y.drawImage(o, 0, 0, b, h);
|
|
1328
1429
|
const k = y.getImageData(0, 0, b, h), T = k.data;
|
|
@@ -1336,7 +1437,7 @@ function Ut(e, n, t, a) {
|
|
|
1336
1437
|
$.globalCompositeOperation = v, $.globalAlpha = n.opacity / 100, $.drawImage(o, 0, 0, b, h);
|
|
1337
1438
|
$.globalCompositeOperation = "source-over", $.globalAlpha = 1, e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(u, p, f, m), a && (e.fillStyle = a, e.fillRect(u, p, f, m)), e.drawImage(S, u, p), e.restore(), r.release(n.imageUrl);
|
|
1338
1439
|
}
|
|
1339
|
-
class
|
|
1440
|
+
class ea {
|
|
1340
1441
|
constructor(n = Math.random()) {
|
|
1341
1442
|
this.perm = [];
|
|
1342
1443
|
for (let a = 0; a < 256; a++)
|
|
@@ -1374,8 +1475,8 @@ class zt {
|
|
|
1374
1475
|
);
|
|
1375
1476
|
}
|
|
1376
1477
|
}
|
|
1377
|
-
function
|
|
1378
|
-
const s =
|
|
1478
|
+
function Cn(e, n, t, a = Date.now()) {
|
|
1479
|
+
const s = vn(e, n).getContext("2d").createImageData(e, n), c = s.data, i = new ea(a), l = 0.02, d = 1 - t / 100;
|
|
1379
1480
|
for (let u = 0; u < n; u++)
|
|
1380
1481
|
for (let p = 0; p < e; p++) {
|
|
1381
1482
|
const f = (u * e + p) * 4;
|
|
@@ -1388,30 +1489,30 @@ function wn(e, n, t, a = Date.now()) {
|
|
|
1388
1489
|
}
|
|
1389
1490
|
return s;
|
|
1390
1491
|
}
|
|
1391
|
-
function
|
|
1392
|
-
const o =
|
|
1492
|
+
function ta(e, n, t, a = Date.now()) {
|
|
1493
|
+
const o = vn(e, n).getContext("2d");
|
|
1393
1494
|
o.clearRect(0, 0, e, n), o.strokeStyle = "#000000", o.lineWidth = 1 + t / 50, o.lineCap = "round";
|
|
1394
|
-
const s =
|
|
1495
|
+
const s = Wn(a), c = Math.floor(t / 100 * 30 + 5);
|
|
1395
1496
|
for (let i = 0; i < c; i++) {
|
|
1396
1497
|
const l = s() * e, d = s() * n;
|
|
1397
|
-
|
|
1498
|
+
Fn(o, l, d, s() * Math.PI * 2, 50 + s() * 100, s, 0);
|
|
1398
1499
|
}
|
|
1399
1500
|
return o.getImageData(0, 0, e, n);
|
|
1400
1501
|
}
|
|
1401
|
-
function
|
|
1502
|
+
function Fn(e, n, t, a, r, o, s) {
|
|
1402
1503
|
if (s > 3 || r < 10) return;
|
|
1403
1504
|
const c = n + Math.cos(a) * r, i = t + Math.sin(a) * r;
|
|
1404
1505
|
if (e.beginPath(), e.moveTo(n, t), e.lineTo(c, i), e.stroke(), o() > 0.5) {
|
|
1405
1506
|
const l = a + (o() - 0.5) * Math.PI / 2;
|
|
1406
|
-
|
|
1507
|
+
Fn(e, c, i, l, r * 0.6, o, s + 1);
|
|
1407
1508
|
}
|
|
1408
1509
|
if (o() > 0.7) {
|
|
1409
1510
|
const l = a - (o() - 0.5) * Math.PI / 2;
|
|
1410
|
-
|
|
1511
|
+
Fn(e, c, i, l, r * 0.6, o, s + 1);
|
|
1411
1512
|
}
|
|
1412
1513
|
}
|
|
1413
|
-
function
|
|
1414
|
-
const s =
|
|
1514
|
+
function un(e, n, t, a = Date.now()) {
|
|
1515
|
+
const s = vn(e, n).getContext("2d").createImageData(e, n), c = s.data, i = Wn(a), l = t / 100 * 0.5;
|
|
1415
1516
|
for (let d = 0; d < n; d++)
|
|
1416
1517
|
for (let u = 0; u < e; u++) {
|
|
1417
1518
|
const p = (d * e + u) * 4, m = i() < l ? 255 : 0;
|
|
@@ -1419,10 +1520,10 @@ function dn(e, n, t, a = Date.now()) {
|
|
|
1419
1520
|
}
|
|
1420
1521
|
return s;
|
|
1421
1522
|
}
|
|
1422
|
-
function
|
|
1423
|
-
const o =
|
|
1523
|
+
function aa(e, n, t, a = Date.now()) {
|
|
1524
|
+
const o = vn(e, n).getContext("2d");
|
|
1424
1525
|
o.fillStyle = "#000000";
|
|
1425
|
-
const s =
|
|
1526
|
+
const s = Wn(a), c = 4 + t / 100 * 6, i = c * 2;
|
|
1426
1527
|
for (let l = 0; l < n; l += i)
|
|
1427
1528
|
for (let d = 0; d < e; d += i)
|
|
1428
1529
|
if (s() < t / 100) {
|
|
@@ -1431,7 +1532,7 @@ function Gt(e, n, t, a = Date.now()) {
|
|
|
1431
1532
|
}
|
|
1432
1533
|
return o.getImageData(0, 0, e, n);
|
|
1433
1534
|
}
|
|
1434
|
-
function
|
|
1535
|
+
function vn(e, n) {
|
|
1435
1536
|
if (typeof OffscreenCanvas < "u")
|
|
1436
1537
|
return new OffscreenCanvas(e, n);
|
|
1437
1538
|
if (typeof document < "u") {
|
|
@@ -1440,31 +1541,31 @@ function $n(e, n) {
|
|
|
1440
1541
|
}
|
|
1441
1542
|
throw new Error("No canvas context available");
|
|
1442
1543
|
}
|
|
1443
|
-
function
|
|
1544
|
+
function Wn(e) {
|
|
1444
1545
|
let n = Math.sin(e++) * 1e4;
|
|
1445
1546
|
return () => (n = Math.sin(e++) * 1e4, n - Math.floor(n));
|
|
1446
1547
|
}
|
|
1447
|
-
const L = 42,
|
|
1448
|
-
function
|
|
1548
|
+
const L = 42, X = 512, Y = 64;
|
|
1549
|
+
function Mn(e) {
|
|
1449
1550
|
const n = e.data;
|
|
1450
1551
|
for (let t = 0; t < n.length; t += 4)
|
|
1451
1552
|
n[t] = 255, n[t + 1] = 255, n[t + 2] = 255;
|
|
1452
1553
|
return e;
|
|
1453
1554
|
}
|
|
1454
|
-
function
|
|
1555
|
+
function ra(e, n) {
|
|
1455
1556
|
const t = e.data, a = n.data;
|
|
1456
1557
|
for (let r = 0; r < t.length; r += 4)
|
|
1457
1558
|
t[r] = 255, t[r + 1] = 255, t[r + 2] = 255, t[r + 3] = Math.min(255, t[r + 3] + a[r + 3]);
|
|
1458
1559
|
return e;
|
|
1459
1560
|
}
|
|
1460
|
-
const
|
|
1561
|
+
const sa = [
|
|
1461
1562
|
{
|
|
1462
1563
|
id: "grunge-heavy",
|
|
1463
1564
|
name: "Heavy Grunge",
|
|
1464
1565
|
textureUrl: "builtin:grunge-heavy",
|
|
1465
1566
|
thumbnailUrl: "",
|
|
1466
1567
|
description: "Dense random splatters",
|
|
1467
|
-
generate: (e, n) =>
|
|
1568
|
+
generate: (e, n) => un(e, n, 80, L)
|
|
1468
1569
|
},
|
|
1469
1570
|
{
|
|
1470
1571
|
id: "grunge-fine",
|
|
@@ -1472,7 +1573,7 @@ const Vt = [
|
|
|
1472
1573
|
textureUrl: "builtin:grunge-fine",
|
|
1473
1574
|
thumbnailUrl: "",
|
|
1474
1575
|
description: "Sparse fine grain",
|
|
1475
|
-
generate: (e, n) =>
|
|
1576
|
+
generate: (e, n) => un(e, n, 25, L + 1)
|
|
1476
1577
|
},
|
|
1477
1578
|
{
|
|
1478
1579
|
id: "concrete",
|
|
@@ -1480,7 +1581,7 @@ const Vt = [
|
|
|
1480
1581
|
textureUrl: "builtin:concrete",
|
|
1481
1582
|
thumbnailUrl: "",
|
|
1482
1583
|
description: "Rough surface via Perlin noise",
|
|
1483
|
-
generate: (e, n) =>
|
|
1584
|
+
generate: (e, n) => Cn(e, n, 55, L + 2)
|
|
1484
1585
|
},
|
|
1485
1586
|
{
|
|
1486
1587
|
id: "paper",
|
|
@@ -1488,7 +1589,7 @@ const Vt = [
|
|
|
1488
1589
|
textureUrl: "builtin:paper",
|
|
1489
1590
|
thumbnailUrl: "",
|
|
1490
1591
|
description: "Subtle aging",
|
|
1491
|
-
generate: (e, n) =>
|
|
1592
|
+
generate: (e, n) => Cn(e, n, 20, L + 3)
|
|
1492
1593
|
},
|
|
1493
1594
|
{
|
|
1494
1595
|
id: "rust",
|
|
@@ -1497,8 +1598,8 @@ const Vt = [
|
|
|
1497
1598
|
thumbnailUrl: "",
|
|
1498
1599
|
description: "Noise + splatter combined",
|
|
1499
1600
|
generate: (e, n) => {
|
|
1500
|
-
const t =
|
|
1501
|
-
return
|
|
1601
|
+
const t = Cn(e, n, 45, L + 4), a = un(e, n, 35, L + 5);
|
|
1602
|
+
return ra(Mn(t), Mn(a));
|
|
1502
1603
|
}
|
|
1503
1604
|
},
|
|
1504
1605
|
{
|
|
@@ -1507,7 +1608,7 @@ const Vt = [
|
|
|
1507
1608
|
textureUrl: "builtin:scratches",
|
|
1508
1609
|
thumbnailUrl: "",
|
|
1509
1610
|
description: "Branching crack lines",
|
|
1510
|
-
generate: (e, n) =>
|
|
1611
|
+
generate: (e, n) => ta(e, n, 55, L + 6)
|
|
1511
1612
|
},
|
|
1512
1613
|
{
|
|
1513
1614
|
id: "halftone",
|
|
@@ -1515,7 +1616,7 @@ const Vt = [
|
|
|
1515
1616
|
textureUrl: "builtin:halftone",
|
|
1516
1617
|
thumbnailUrl: "",
|
|
1517
1618
|
description: "Dot grid pattern",
|
|
1518
|
-
generate: (e, n) =>
|
|
1619
|
+
generate: (e, n) => aa(e, n, 55, L + 7)
|
|
1519
1620
|
},
|
|
1520
1621
|
{
|
|
1521
1622
|
id: "spray",
|
|
@@ -1523,62 +1624,62 @@ const Vt = [
|
|
|
1523
1624
|
textureUrl: "builtin:spray",
|
|
1524
1625
|
thumbnailUrl: "",
|
|
1525
1626
|
description: "Medium random splatter",
|
|
1526
|
-
generate: (e, n) =>
|
|
1627
|
+
generate: (e, n) => un(e, n, 55, L + 8)
|
|
1527
1628
|
}
|
|
1528
1629
|
];
|
|
1529
|
-
let
|
|
1530
|
-
function
|
|
1630
|
+
let ee = !1;
|
|
1631
|
+
function ia(e, n) {
|
|
1531
1632
|
if (typeof OffscreenCanvas < "u")
|
|
1532
1633
|
return new OffscreenCanvas(e, n);
|
|
1533
1634
|
const t = document.createElement("canvas");
|
|
1534
1635
|
return t.width = e, t.height = n, t;
|
|
1535
1636
|
}
|
|
1536
|
-
function
|
|
1637
|
+
function te(e, n) {
|
|
1537
1638
|
if (typeof document > "u") return null;
|
|
1538
1639
|
const t = document.createElement("canvas");
|
|
1539
1640
|
return t.width = e, t.height = n, t;
|
|
1540
1641
|
}
|
|
1541
|
-
function
|
|
1542
|
-
const n =
|
|
1642
|
+
function oa(e) {
|
|
1643
|
+
const n = te(e.width, e.height);
|
|
1543
1644
|
if (!n) return "";
|
|
1544
1645
|
const t = n.getContext("2d");
|
|
1545
1646
|
if (!t) return "";
|
|
1546
1647
|
t.putImageData(e, 0, 0);
|
|
1547
|
-
const a =
|
|
1648
|
+
const a = te(Y, Y);
|
|
1548
1649
|
if (!a) return "";
|
|
1549
1650
|
const r = a.getContext("2d");
|
|
1550
1651
|
if (!r) return "";
|
|
1551
|
-
r.drawImage(n, 0, 0, e.width, e.height, 0, 0,
|
|
1552
|
-
const o = r.getImageData(0, 0,
|
|
1652
|
+
r.drawImage(n, 0, 0, e.width, e.height, 0, 0, Y, Y);
|
|
1653
|
+
const o = r.getImageData(0, 0, Y, Y), s = o.data;
|
|
1553
1654
|
for (let c = 0; c < s.length; c += 4) {
|
|
1554
1655
|
const i = s[c + 3], l = 255 - Math.round(i / 255 * 195);
|
|
1555
1656
|
s[c] = l, s[c + 1] = l, s[c + 2] = l, s[c + 3] = 255;
|
|
1556
1657
|
}
|
|
1557
1658
|
return r.putImageData(o, 0, 0), a.toDataURL("image/png");
|
|
1558
1659
|
}
|
|
1559
|
-
function
|
|
1560
|
-
if (!
|
|
1561
|
-
|
|
1562
|
-
for (const e of
|
|
1563
|
-
const n = e.generate(
|
|
1564
|
-
|
|
1565
|
-
const t =
|
|
1566
|
-
a && (a.putImageData(n, 0, 0),
|
|
1660
|
+
function ca() {
|
|
1661
|
+
if (!ee) {
|
|
1662
|
+
ee = !0;
|
|
1663
|
+
for (const e of sa) {
|
|
1664
|
+
const n = e.generate(X, X);
|
|
1665
|
+
Mn(n);
|
|
1666
|
+
const t = ia(X, X), a = t.getContext("2d");
|
|
1667
|
+
a && (a.putImageData(n, 0, 0), la(e.textureUrl, t, X, X)), typeof document < "u" && (e.thumbnailUrl = oa(n));
|
|
1567
1668
|
}
|
|
1568
1669
|
}
|
|
1569
1670
|
}
|
|
1570
|
-
const
|
|
1571
|
-
function
|
|
1671
|
+
const W = /* @__PURE__ */ new Set(), G = /* @__PURE__ */ new Map(), hn = /* @__PURE__ */ new Map();
|
|
1672
|
+
function ae(e, n) {
|
|
1572
1673
|
if (typeof OffscreenCanvas < "u")
|
|
1573
1674
|
return new OffscreenCanvas(e, n);
|
|
1574
1675
|
const t = document.createElement("canvas");
|
|
1575
1676
|
return t.width = e, t.height = n, t;
|
|
1576
1677
|
}
|
|
1577
|
-
function
|
|
1678
|
+
function re(e) {
|
|
1578
1679
|
return e.getContext("2d");
|
|
1579
1680
|
}
|
|
1580
|
-
function
|
|
1581
|
-
const { width: n, height: t } = e, a =
|
|
1681
|
+
function se(e) {
|
|
1682
|
+
const { width: n, height: t } = e, a = ae(n, t), r = re(a);
|
|
1582
1683
|
if (!r) throw new Error("Failed to get 2d context for temp canvas");
|
|
1583
1684
|
r.drawImage(e, 0, 0);
|
|
1584
1685
|
const o = r.getImageData(0, 0, n, t), s = o.data;
|
|
@@ -1586,67 +1687,67 @@ function ne(e) {
|
|
|
1586
1687
|
const d = s[l], u = s[l + 1], p = s[l + 2], m = 255 - (0.299 * d + 0.587 * u + 0.114 * p);
|
|
1587
1688
|
s[l] = 255, s[l + 1] = 255, s[l + 2] = 255, s[l + 3] = m;
|
|
1588
1689
|
}
|
|
1589
|
-
const c =
|
|
1690
|
+
const c = ae(n, t), i = re(c);
|
|
1590
1691
|
if (!i) throw new Error("Failed to get 2d context for mask canvas");
|
|
1591
1692
|
return i.putImageData(o, 0, 0), { alphaMask: c, width: n, height: t };
|
|
1592
1693
|
}
|
|
1593
|
-
function
|
|
1594
|
-
const n =
|
|
1694
|
+
function Ee(e) {
|
|
1695
|
+
const n = G.get(e);
|
|
1595
1696
|
if (n) return n;
|
|
1596
1697
|
if (e.startsWith("builtin:")) {
|
|
1597
|
-
|
|
1598
|
-
const t =
|
|
1698
|
+
ca();
|
|
1699
|
+
const t = G.get(e);
|
|
1599
1700
|
return t || null;
|
|
1600
1701
|
}
|
|
1601
|
-
return
|
|
1702
|
+
return W.has(e) || (W.add(e), Ae(e)), null;
|
|
1602
1703
|
}
|
|
1603
|
-
function
|
|
1604
|
-
return
|
|
1605
|
-
if (
|
|
1704
|
+
function Ia(e) {
|
|
1705
|
+
return G.has(e) ? Promise.resolve() : new Promise((n) => {
|
|
1706
|
+
if (G.has(e)) {
|
|
1606
1707
|
n();
|
|
1607
1708
|
return;
|
|
1608
1709
|
}
|
|
1609
|
-
const t =
|
|
1610
|
-
t.push(n),
|
|
1710
|
+
const t = hn.get(e) || [];
|
|
1711
|
+
t.push(n), hn.set(e, t), W.has(e) || (W.add(e), Ae(e));
|
|
1611
1712
|
});
|
|
1612
1713
|
}
|
|
1613
|
-
function
|
|
1614
|
-
|
|
1714
|
+
function la(e, n, t, a) {
|
|
1715
|
+
G.has(e) || (G.set(e, { alphaMask: n, width: t, height: a }), an(e));
|
|
1615
1716
|
}
|
|
1616
|
-
function
|
|
1617
|
-
const n =
|
|
1618
|
-
n && (n.forEach((t) => t()),
|
|
1717
|
+
function an(e) {
|
|
1718
|
+
const n = hn.get(e);
|
|
1719
|
+
n && (n.forEach((t) => t()), hn.delete(e));
|
|
1619
1720
|
}
|
|
1620
|
-
function
|
|
1721
|
+
function Ae(e) {
|
|
1621
1722
|
if (typeof document < "u") {
|
|
1622
1723
|
const n = new Image();
|
|
1623
1724
|
n.crossOrigin = "anonymous", n.onload = () => {
|
|
1624
|
-
const t =
|
|
1625
|
-
|
|
1725
|
+
const t = se(n);
|
|
1726
|
+
G.set(e, t), W.delete(e), an(e);
|
|
1626
1727
|
}, n.onerror = () => {
|
|
1627
|
-
|
|
1728
|
+
W.delete(e), an(e);
|
|
1628
1729
|
}, n.src = e;
|
|
1629
1730
|
} else
|
|
1630
1731
|
fetch(e).then((n) => n.blob()).then((n) => createImageBitmap(n)).then((n) => {
|
|
1631
|
-
const t =
|
|
1632
|
-
|
|
1732
|
+
const t = se(n);
|
|
1733
|
+
G.set(e, t), W.delete(e), an(e);
|
|
1633
1734
|
}).catch(() => {
|
|
1634
|
-
|
|
1735
|
+
W.delete(e), an(e);
|
|
1635
1736
|
});
|
|
1636
1737
|
}
|
|
1637
|
-
function
|
|
1738
|
+
function Pe(e, n) {
|
|
1638
1739
|
if (typeof OffscreenCanvas < "u")
|
|
1639
1740
|
return new OffscreenCanvas(e, n);
|
|
1640
1741
|
const t = document.createElement("canvas");
|
|
1641
1742
|
return t.width = e, t.height = n, t;
|
|
1642
1743
|
}
|
|
1643
|
-
function
|
|
1744
|
+
function da(e, n, t, a) {
|
|
1644
1745
|
if (!n.enabled || !n.textureUrl || n.intensity <= 0) return;
|
|
1645
|
-
const r =
|
|
1746
|
+
const r = Ee(n.textureUrl);
|
|
1646
1747
|
if (!r) return;
|
|
1647
1748
|
const { x: o, y: s, width: c, height: i } = t, l = e.getTransform(), d = l.a * o + l.e, u = l.d * s + l.f, p = l.a * c, f = l.d * i, m = Math.ceil(p), b = Math.ceil(f);
|
|
1648
1749
|
if (m <= 0 || b <= 0) return;
|
|
1649
|
-
const h =
|
|
1750
|
+
const h = Pe(m, b), S = h.getContext("2d");
|
|
1650
1751
|
if (!S) return;
|
|
1651
1752
|
S.drawImage(
|
|
1652
1753
|
e.canvas,
|
|
@@ -1674,9 +1775,9 @@ function Kt(e, n, t, a) {
|
|
|
1674
1775
|
S.globalCompositeOperation = "destination-out", S.globalAlpha = n.intensity / 100, S.drawImage(r.alphaMask, 0, 0, m, b), S.globalCompositeOperation = "source-over";
|
|
1675
1776
|
S.globalAlpha = 1, e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(d, u, p, f), a && (e.fillStyle = a, e.fillRect(d, u, p, f)), e.drawImage(h, d, u), e.restore();
|
|
1676
1777
|
}
|
|
1677
|
-
function
|
|
1778
|
+
function ie(e, n, t, a) {
|
|
1678
1779
|
if (!n.enabled || n.style !== "custom" || !n.textureUrl) return;
|
|
1679
|
-
const r =
|
|
1780
|
+
const r = Ee(n.textureUrl);
|
|
1680
1781
|
if (!r) {
|
|
1681
1782
|
a(e);
|
|
1682
1783
|
return;
|
|
@@ -1691,7 +1792,7 @@ function ee(e, n, t, a) {
|
|
|
1691
1792
|
a(e);
|
|
1692
1793
|
return;
|
|
1693
1794
|
}
|
|
1694
|
-
const g =
|
|
1795
|
+
const g = Pe($, v), y = g.getContext("2d");
|
|
1695
1796
|
if (!y) {
|
|
1696
1797
|
a(e);
|
|
1697
1798
|
return;
|
|
@@ -1719,7 +1820,7 @@ function ee(e, n, t, a) {
|
|
|
1719
1820
|
y.globalCompositeOperation = "destination-out", y.globalAlpha = o, y.drawImage(r.alphaMask, 0, 0, $, v), y.globalCompositeOperation = "source-over", y.globalAlpha = 1;
|
|
1720
1821
|
e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(g, m, b), e.restore();
|
|
1721
1822
|
}
|
|
1722
|
-
class
|
|
1823
|
+
class bn {
|
|
1723
1824
|
/**
|
|
1724
1825
|
* Create an element instance from a JSON configuration
|
|
1725
1826
|
* TypeScript ensures all transform types are handled
|
|
@@ -1732,27 +1833,27 @@ class pn {
|
|
|
1732
1833
|
const { transformType: t } = n;
|
|
1733
1834
|
switch (t) {
|
|
1734
1835
|
case "custom":
|
|
1735
|
-
return new
|
|
1836
|
+
return new Ke(n);
|
|
1736
1837
|
case "distort":
|
|
1737
1838
|
throw new Error("DistortTransform is not yet implemented");
|
|
1738
1839
|
case "circle":
|
|
1739
|
-
return new
|
|
1840
|
+
return new Ye(n);
|
|
1740
1841
|
case "lean":
|
|
1741
|
-
return new
|
|
1842
|
+
return new Xe(n);
|
|
1742
1843
|
case "arch":
|
|
1743
|
-
return new
|
|
1844
|
+
return new qe(n);
|
|
1744
1845
|
case "ascend":
|
|
1745
|
-
return new
|
|
1846
|
+
return new je(n);
|
|
1746
1847
|
case "wave":
|
|
1747
|
-
return new
|
|
1848
|
+
return new Ve(n);
|
|
1748
1849
|
case "flag":
|
|
1749
|
-
return new
|
|
1850
|
+
return new He(n);
|
|
1750
1851
|
case "image":
|
|
1751
|
-
return new
|
|
1852
|
+
return new kn(n);
|
|
1752
1853
|
case "group":
|
|
1753
1854
|
const a = (n.children || []).map(
|
|
1754
|
-
(s) =>
|
|
1755
|
-
), r = new
|
|
1855
|
+
(s) => bn.createFromJSON(s)
|
|
1856
|
+
), r = new pe({
|
|
1756
1857
|
id: n.id,
|
|
1757
1858
|
x: n.x,
|
|
1758
1859
|
y: n.y,
|
|
@@ -1760,9 +1861,9 @@ class pn {
|
|
|
1760
1861
|
});
|
|
1761
1862
|
return a.forEach((s) => r.addChild(s)), r;
|
|
1762
1863
|
case "shape":
|
|
1763
|
-
return new
|
|
1864
|
+
return new Ge(n);
|
|
1764
1865
|
case "path":
|
|
1765
|
-
return new
|
|
1866
|
+
return new We(n);
|
|
1766
1867
|
default:
|
|
1767
1868
|
const o = t;
|
|
1768
1869
|
throw new Error(`Unknown transform type: ${o}`);
|
|
@@ -1976,7 +2077,7 @@ class pn {
|
|
|
1976
2077
|
return this.createFromJSON(t);
|
|
1977
2078
|
}
|
|
1978
2079
|
}
|
|
1979
|
-
const
|
|
2080
|
+
const oe = N("ImportManager"), Gn = class Gn {
|
|
1980
2081
|
/**
|
|
1981
2082
|
* Import workspace from JSON file
|
|
1982
2083
|
*/
|
|
@@ -1991,7 +2092,7 @@ const te = G("ImportManager"), Nn = class Nn {
|
|
|
1991
2092
|
return this.migrateV1Document(a);
|
|
1992
2093
|
const r = [], o = [];
|
|
1993
2094
|
return a.artboards.forEach((s) => {
|
|
1994
|
-
const c =
|
|
2095
|
+
const c = Vn.fromJSON({
|
|
1995
2096
|
id: s.id,
|
|
1996
2097
|
name: s.name,
|
|
1997
2098
|
x: s.x,
|
|
@@ -2002,9 +2103,9 @@ const te = G("ImportManager"), Nn = class Nn {
|
|
|
2002
2103
|
elementIds: s.elements.map((l) => l.id || "")
|
|
2003
2104
|
}), i = s.elements.map((l) => {
|
|
2004
2105
|
try {
|
|
2005
|
-
return
|
|
2106
|
+
return bn.createFromJSON(l);
|
|
2006
2107
|
} catch (d) {
|
|
2007
|
-
return
|
|
2108
|
+
return oe.error("Failed to create element:", l, d), null;
|
|
2008
2109
|
}
|
|
2009
2110
|
}).filter((l) => l !== null);
|
|
2010
2111
|
r.push(c), o.push(...i);
|
|
@@ -2027,7 +2128,7 @@ const te = G("ImportManager"), Nn = class Nn {
|
|
|
2027
2128
|
static async migrateV1Document(n) {
|
|
2028
2129
|
var t, a, r;
|
|
2029
2130
|
try {
|
|
2030
|
-
const o = n.elements || [], s = new
|
|
2131
|
+
const o = n.elements || [], s = new Vn({
|
|
2031
2132
|
id: "artboard-migrated",
|
|
2032
2133
|
name: "Artboard 1",
|
|
2033
2134
|
x: 0,
|
|
@@ -2037,9 +2138,9 @@ const te = G("ImportManager"), Nn = class Nn {
|
|
|
2037
2138
|
backgroundColor: ((r = n.canvas) == null ? void 0 : r.backgroundColor) || "#ffffff"
|
|
2038
2139
|
}), c = o.map((i) => {
|
|
2039
2140
|
try {
|
|
2040
|
-
return
|
|
2141
|
+
return bn.createFromJSON(i);
|
|
2041
2142
|
} catch (l) {
|
|
2042
|
-
return
|
|
2143
|
+
return oe.error("Failed to create element:", i, l), null;
|
|
2043
2144
|
}
|
|
2044
2145
|
}).filter((i) => i !== null);
|
|
2045
2146
|
return c.forEach((i) => {
|
|
@@ -2190,14 +2291,14 @@ const te = G("ImportManager"), Nn = class Nn {
|
|
|
2190
2291
|
await Promise.all(r);
|
|
2191
2292
|
}
|
|
2192
2293
|
};
|
|
2193
|
-
|
|
2194
|
-
let
|
|
2195
|
-
const
|
|
2196
|
-
function
|
|
2197
|
-
const t = n ?
|
|
2294
|
+
Gn.SUPPORTED_VERSIONS = ["1.0.0", "2.0.0"];
|
|
2295
|
+
let ce = Gn;
|
|
2296
|
+
const le = N("element-serializer"), Ie = 4e3, ln = /* @__PURE__ */ new Set();
|
|
2297
|
+
function fa(e, n) {
|
|
2298
|
+
const t = n ? ua(n) : "no-src";
|
|
2198
2299
|
return `${e}:${t}`;
|
|
2199
2300
|
}
|
|
2200
|
-
function
|
|
2301
|
+
function ua(e) {
|
|
2201
2302
|
let n = 0;
|
|
2202
2303
|
for (let t = 0; t < e.length; t++) {
|
|
2203
2304
|
const a = e.charCodeAt(t);
|
|
@@ -2205,20 +2306,20 @@ function Zt(e) {
|
|
|
2205
2306
|
}
|
|
2206
2307
|
return n.toString(36);
|
|
2207
2308
|
}
|
|
2208
|
-
function
|
|
2209
|
-
|
|
2309
|
+
function On() {
|
|
2310
|
+
ln.clear();
|
|
2210
2311
|
}
|
|
2211
|
-
function
|
|
2212
|
-
for (const n of
|
|
2213
|
-
n.startsWith(`${e}:`) &&
|
|
2312
|
+
function De(e) {
|
|
2313
|
+
for (const n of ln)
|
|
2314
|
+
n.startsWith(`${e}:`) && ln.delete(n);
|
|
2214
2315
|
}
|
|
2215
|
-
function
|
|
2216
|
-
|
|
2316
|
+
function pa(e) {
|
|
2317
|
+
ln.add(e);
|
|
2217
2318
|
}
|
|
2218
|
-
function
|
|
2219
|
-
return
|
|
2319
|
+
function ha(e) {
|
|
2320
|
+
return ln.has(e);
|
|
2220
2321
|
}
|
|
2221
|
-
async function
|
|
2322
|
+
async function ba(e, n = Ie) {
|
|
2222
2323
|
const { naturalWidth: t, naturalHeight: a } = e;
|
|
2223
2324
|
if (t <= n && a <= n)
|
|
2224
2325
|
return createImageBitmap(e);
|
|
@@ -2229,20 +2330,20 @@ async function ea(e, n = ye) {
|
|
|
2229
2330
|
resizeQuality: "high"
|
|
2230
2331
|
});
|
|
2231
2332
|
}
|
|
2232
|
-
let
|
|
2233
|
-
function
|
|
2234
|
-
|
|
2235
|
-
}
|
|
2236
|
-
function aa() {
|
|
2237
|
-
hn = null, bn = null;
|
|
2333
|
+
let gn = null, mn = null;
|
|
2334
|
+
function ga(e, n) {
|
|
2335
|
+
gn = e, mn = n;
|
|
2238
2336
|
}
|
|
2239
2337
|
function ma() {
|
|
2240
|
-
|
|
2338
|
+
gn = null, mn = null;
|
|
2241
2339
|
}
|
|
2242
|
-
function
|
|
2243
|
-
|
|
2340
|
+
function Da() {
|
|
2341
|
+
On(), gn && gn();
|
|
2244
2342
|
}
|
|
2245
|
-
function
|
|
2343
|
+
function Fa(e) {
|
|
2344
|
+
De(e), mn && mn(e);
|
|
2345
|
+
}
|
|
2346
|
+
function Rn(e, n) {
|
|
2246
2347
|
const t = e;
|
|
2247
2348
|
if (typeof t.fontFamily == "string" && n.add(t.fontFamily), t.richText && typeof t.richText == "object") {
|
|
2248
2349
|
const a = t.richText;
|
|
@@ -2257,14 +2358,14 @@ function Fn(e, n) {
|
|
|
2257
2358
|
}
|
|
2258
2359
|
if (t.children && Array.isArray(t.children))
|
|
2259
2360
|
for (const a of t.children)
|
|
2260
|
-
|
|
2361
|
+
Rn(a, n);
|
|
2261
2362
|
if (e.masks && Array.isArray(e.masks))
|
|
2262
2363
|
for (const a of e.masks)
|
|
2263
|
-
a.maskElement &&
|
|
2364
|
+
a.maskElement && Rn(a.maskElement, n);
|
|
2264
2365
|
}
|
|
2265
|
-
function
|
|
2366
|
+
function de(e) {
|
|
2266
2367
|
if (typeof document > "u") return e;
|
|
2267
|
-
const n =
|
|
2368
|
+
const n = $n.getInstance();
|
|
2268
2369
|
return e.map((t) => {
|
|
2269
2370
|
if (!(t != null && t.maskElement) || t.maskElement.transformType !== "image") return t;
|
|
2270
2371
|
const a = t.maskElement.imageUrl;
|
|
@@ -2280,20 +2381,20 @@ function se(e) {
|
|
|
2280
2381
|
} : t;
|
|
2281
2382
|
});
|
|
2282
2383
|
}
|
|
2283
|
-
async function
|
|
2384
|
+
async function fe(e, n, t = Ie) {
|
|
2284
2385
|
const a = n.filter((i) => e.hasElementId(i.id)), r = [], o = [], s = /* @__PURE__ */ new Set();
|
|
2285
2386
|
for (const i of a) {
|
|
2286
2387
|
const l = i.toJSON();
|
|
2287
|
-
if (
|
|
2288
|
-
|
|
2388
|
+
if (Rn(l, s), i instanceof kn && !i.imageElement) {
|
|
2389
|
+
le.warn(`[element-serializer] Skipping image ${i.id}: image not loaded (state: ${i.imageLoadState})`);
|
|
2289
2390
|
continue;
|
|
2290
2391
|
}
|
|
2291
|
-
if (i instanceof
|
|
2392
|
+
if (i instanceof kn && i.imageElement)
|
|
2292
2393
|
try {
|
|
2293
|
-
const d =
|
|
2294
|
-
if (!
|
|
2295
|
-
const v = await
|
|
2296
|
-
o.push({ cacheKey: d, bitmap: v }),
|
|
2394
|
+
const d = fa(i.id, i.imageUrl);
|
|
2395
|
+
if (!ha(d)) {
|
|
2396
|
+
const v = await ba(i.imageElement, t);
|
|
2397
|
+
o.push({ cacheKey: d, bitmap: v }), pa(d);
|
|
2297
2398
|
}
|
|
2298
2399
|
const p = i.transformData || {}, f = l.masks && l.masks.length > 0, m = f ? p.width : p.width * (p.cropWidth ?? 1), b = f ? p.height : p.height * (p.cropHeight ?? 1), h = {
|
|
2299
2400
|
id: i.id,
|
|
@@ -2312,9 +2413,9 @@ async function ie(e, n, t = ye) {
|
|
|
2312
2413
|
}
|
|
2313
2414
|
p.flipHorizontal && (h.flipHorizontal = p.flipHorizontal), p.flipVertical && (h.flipVertical = p.flipVertical), p.borderRadius && (h.borderRadius = p.borderRadius), i.opacity !== void 0 && (h.opacity = i.opacity);
|
|
2314
2415
|
const $ = h;
|
|
2315
|
-
i.distressEffect && ($.distressEffect = { ...i.distressEffect }), l.masks && l.masks.length > 0 && ($.masks =
|
|
2416
|
+
i.distressEffect && ($.distressEffect = { ...i.distressEffect }), l.masks && l.masks.length > 0 && ($.masks = de(l.masks)), l.blendMode && ($.blendMode = l.blendMode), l.knockoutParts && ($.knockoutParts = l.knockoutParts), "getVisualBoundingBox" in i && typeof i.getVisualBoundingBox == "function" ? $._boundingBox = i.getVisualBoundingBox() : "getBoundingBox" in i && typeof i.getBoundingBox == "function" && ($._boundingBox = i.getBoundingBox()), r.push($);
|
|
2316
2417
|
} catch (d) {
|
|
2317
|
-
|
|
2418
|
+
le.error(`[element-serializer] Failed to create ImageBitmap for ${l.id}:`, d);
|
|
2318
2419
|
}
|
|
2319
2420
|
else {
|
|
2320
2421
|
const d = {
|
|
@@ -2322,7 +2423,7 @@ async function ie(e, n, t = ye) {
|
|
|
2322
2423
|
type: l.transformType
|
|
2323
2424
|
// Map transformType to type for worker compatibility
|
|
2324
2425
|
};
|
|
2325
|
-
d.masks && Array.isArray(d.masks) && d.masks.length > 0 && (d.masks =
|
|
2426
|
+
d.masks && Array.isArray(d.masks) && d.masks.length > 0 && (d.masks = de(d.masks)), "getVisualBoundingBox" in i && typeof i.getVisualBoundingBox == "function" ? d._boundingBox = i.getVisualBoundingBox() : "getBoundingBox" in i && typeof i.getBoundingBox == "function" && (d._boundingBox = i.getBoundingBox()), r.push(d);
|
|
2326
2427
|
}
|
|
2327
2428
|
}
|
|
2328
2429
|
const c = Array.from(s);
|
|
@@ -2347,7 +2448,7 @@ async function ie(e, n, t = ye) {
|
|
|
2347
2448
|
newBitmaps: o
|
|
2348
2449
|
};
|
|
2349
2450
|
}
|
|
2350
|
-
const
|
|
2451
|
+
const ya = `"use strict";
|
|
2351
2452
|
(() => {
|
|
2352
2453
|
var __create = Object.create;
|
|
2353
2454
|
var __defProp = Object.defineProperty;
|
|
@@ -26217,8 +26318,8 @@ const ra = `"use strict";
|
|
|
26217
26318
|
console.error("[Export Worker] Unhandled promise rejection:", event.reason);
|
|
26218
26319
|
};
|
|
26219
26320
|
})();
|
|
26220
|
-
`, O =
|
|
26221
|
-
class
|
|
26321
|
+
`, O = N("WorkerExport");
|
|
26322
|
+
class dn {
|
|
26222
26323
|
constructor() {
|
|
26223
26324
|
this.worker = null, this.workerBlobUrl = null, this.pendingRequests = /* @__PURE__ */ new Map(), this.requestQueue = [], this.blobRequestQueue = [], this.isProcessingQueue = !1, this.isReady = !1, this.readyPromise = null, this.requestIdCounter = 0, this.workerCrashCount = 0, this.MAX_CRASHES_BEFORE_FALLBACK = 3, this.lastCrashTime = 0, this.CRASH_RESET_TIMEOUT = 6e4, this.progressListeners = /* @__PURE__ */ new Set(), this.idleTimeout = null, this.IDLE_TIMEOUT_MS = 3e4;
|
|
26224
26325
|
}
|
|
@@ -26280,7 +26381,7 @@ class cn {
|
|
|
26280
26381
|
* Call this when exiting editor mode to free memory.
|
|
26281
26382
|
*/
|
|
26282
26383
|
clearWorkerBitmapCache() {
|
|
26283
|
-
if (
|
|
26384
|
+
if (On(), this.worker && this.isReady) {
|
|
26284
26385
|
const n = {
|
|
26285
26386
|
type: "clear-all-bitmaps"
|
|
26286
26387
|
};
|
|
@@ -26292,7 +26393,7 @@ class cn {
|
|
|
26292
26393
|
* Call this when an element is removed or its image source changes.
|
|
26293
26394
|
*/
|
|
26294
26395
|
clearWorkerBitmap(n) {
|
|
26295
|
-
if (
|
|
26396
|
+
if (De(n), this.worker && this.isReady) {
|
|
26296
26397
|
const t = {
|
|
26297
26398
|
type: "clear-bitmap",
|
|
26298
26399
|
elementId: n
|
|
@@ -26316,13 +26417,13 @@ class cn {
|
|
|
26316
26417
|
async initialize() {
|
|
26317
26418
|
if (this.worker)
|
|
26318
26419
|
return this.readyPromise || Promise.resolve();
|
|
26319
|
-
if (!
|
|
26420
|
+
if (!dn.supportsWorkerExport())
|
|
26320
26421
|
throw new Error("Browser does not support OffscreenCanvas or Web Workers");
|
|
26321
26422
|
return this.readyPromise = new Promise((n, t) => {
|
|
26322
26423
|
try {
|
|
26323
26424
|
let a;
|
|
26324
26425
|
try {
|
|
26325
|
-
const s = new Blob([
|
|
26426
|
+
const s = new Blob([ya], { type: "application/javascript" });
|
|
26326
26427
|
a = URL.createObjectURL(s), this.workerBlobUrl = a;
|
|
26327
26428
|
} catch (s) {
|
|
26328
26429
|
O.error("Failed to create worker blob:", s), t(new Error(`Worker creation failed: ${s instanceof Error ? s.message : String(s)}`));
|
|
@@ -26336,7 +26437,7 @@ class cn {
|
|
|
26336
26437
|
const r = setTimeout(() => {
|
|
26337
26438
|
t(new Error("Worker initialization timeout"));
|
|
26338
26439
|
}, 15e3), o = (s) => {
|
|
26339
|
-
s.data.type === "ready" && (clearTimeout(r), this.isReady = !0,
|
|
26440
|
+
s.data.type === "ready" && (clearTimeout(r), this.isReady = !0, ga(
|
|
26340
26441
|
() => this.clearWorkerBitmapCache(),
|
|
26341
26442
|
(c) => this.clearWorkerBitmap(c)
|
|
26342
26443
|
), n());
|
|
@@ -26413,7 +26514,7 @@ class cn {
|
|
|
26413
26514
|
const { artboard: t, elements: a, config: r } = n;
|
|
26414
26515
|
if ((!this.worker || !this.isReady) && await this.initialize(), !this.worker)
|
|
26415
26516
|
throw new Error("Worker is not initialized");
|
|
26416
|
-
const o = `export-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: c, newBitmaps: i } = await
|
|
26517
|
+
const o = `export-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: c, newBitmaps: i } = await fe(t, a);
|
|
26417
26518
|
i.length > 0 && this.registerBitmapsWithWorker(i);
|
|
26418
26519
|
const l = {
|
|
26419
26520
|
type: "export",
|
|
@@ -26470,7 +26571,7 @@ class cn {
|
|
|
26470
26571
|
const { artboard: t, elements: a, config: r } = n;
|
|
26471
26572
|
if ((!this.worker || !this.isReady) && await this.initialize(), !this.worker)
|
|
26472
26573
|
throw new Error("Worker is not initialized");
|
|
26473
|
-
const o = `export-blob-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: c, newBitmaps: i } = await
|
|
26574
|
+
const o = `export-blob-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: c, newBitmaps: i } = await fe(t, a);
|
|
26474
26575
|
i.length > 0 && this.registerBitmapsWithWorker(i);
|
|
26475
26576
|
const l = {
|
|
26476
26577
|
type: "export",
|
|
@@ -26584,7 +26685,7 @@ class cn {
|
|
|
26584
26685
|
t.reject(new Error("Worker terminated")), this.pendingRequests.delete(n);
|
|
26585
26686
|
for (; this.requestQueue.length > 0; )
|
|
26586
26687
|
this.requestQueue.shift().reject(new Error("Worker terminated"));
|
|
26587
|
-
this.worker.terminate(), this.worker = null, this.isReady = !1, this.readyPromise = null,
|
|
26688
|
+
this.worker.terminate(), this.worker = null, this.isReady = !1, this.readyPromise = null, On(), ma(), this.workerBlobUrl && (URL.revokeObjectURL(this.workerBlobUrl), this.workerBlobUrl = null);
|
|
26588
26689
|
}
|
|
26589
26690
|
}
|
|
26590
26691
|
/**
|
|
@@ -26599,31 +26700,32 @@ class cn {
|
|
|
26599
26700
|
};
|
|
26600
26701
|
}
|
|
26601
26702
|
}
|
|
26602
|
-
let
|
|
26603
|
-
function
|
|
26604
|
-
return
|
|
26703
|
+
let Z = null;
|
|
26704
|
+
function Ma() {
|
|
26705
|
+
return Z || (Z = new dn()), Z;
|
|
26605
26706
|
}
|
|
26606
|
-
function
|
|
26607
|
-
|
|
26707
|
+
function Oa() {
|
|
26708
|
+
Z && (Z.terminate(), Z = null);
|
|
26608
26709
|
}
|
|
26609
|
-
|
|
26610
|
-
|
|
26710
|
+
Un();
|
|
26711
|
+
const z = N("Export");
|
|
26712
|
+
function Bn(e, n) {
|
|
26611
26713
|
var t;
|
|
26612
26714
|
if (!(!e || typeof e != "object")) {
|
|
26613
26715
|
if (typeof e.fontFamily == "string" && e.fontFamily.trim() && n.add(e.fontFamily), e.richText && Array.isArray(e.richText.spans))
|
|
26614
26716
|
for (const a of e.richText.spans)
|
|
26615
26717
|
(t = a == null ? void 0 : a.style) != null && t.fontFamily && typeof a.style.fontFamily == "string" && n.add(a.style.fontFamily);
|
|
26616
26718
|
if (Array.isArray(e.children))
|
|
26617
|
-
for (const a of e.children)
|
|
26719
|
+
for (const a of e.children) Bn(a, n);
|
|
26618
26720
|
if (Array.isArray(e.masks))
|
|
26619
26721
|
for (const a of e.masks)
|
|
26620
|
-
a != null && a.maskElement &&
|
|
26722
|
+
a != null && a.maskElement && Bn(a.maskElement, n);
|
|
26621
26723
|
}
|
|
26622
26724
|
}
|
|
26623
|
-
async function
|
|
26725
|
+
async function ue(e) {
|
|
26624
26726
|
if (typeof document > "u" || !document.fonts) return;
|
|
26625
26727
|
const n = /* @__PURE__ */ new Set();
|
|
26626
|
-
for (const a of e)
|
|
26728
|
+
for (const a of e) Bn(a, n);
|
|
26627
26729
|
if (n.size === 0) return;
|
|
26628
26730
|
const t = [];
|
|
26629
26731
|
for (const a of n)
|
|
@@ -26631,12 +26733,12 @@ async function oe(e) {
|
|
|
26631
26733
|
}));
|
|
26632
26734
|
await Promise.all(t), document.fonts.ready && await document.fonts.ready;
|
|
26633
26735
|
}
|
|
26634
|
-
const
|
|
26736
|
+
const on = class on {
|
|
26635
26737
|
/**
|
|
26636
26738
|
* Check if worker export is supported in this browser
|
|
26637
26739
|
*/
|
|
26638
26740
|
static supportsWorkerExport() {
|
|
26639
|
-
return
|
|
26741
|
+
return dn.supportsWorkerExport();
|
|
26640
26742
|
}
|
|
26641
26743
|
/**
|
|
26642
26744
|
* Get or initialize the worker manager
|
|
@@ -26644,9 +26746,9 @@ const rn = class rn {
|
|
|
26644
26746
|
static async getWorkerManager() {
|
|
26645
26747
|
return this.supportsWorkerExport() ? this.workerManager ? this.workerManager : this.workerInitPromise ? (await this.workerInitPromise, this.workerManager) : (this.workerInitPromise = (async () => {
|
|
26646
26748
|
try {
|
|
26647
|
-
this.workerManager = new
|
|
26749
|
+
this.workerManager = new dn(), await this.workerManager.initialize();
|
|
26648
26750
|
} catch (n) {
|
|
26649
|
-
|
|
26751
|
+
z.error("Failed to initialize worker:", n), this.workerManager = null;
|
|
26650
26752
|
}
|
|
26651
26753
|
})(), await this.workerInitPromise, this.workerInitPromise = null, this.workerManager) : null;
|
|
26652
26754
|
}
|
|
@@ -26731,7 +26833,7 @@ const rn = class rn {
|
|
|
26731
26833
|
})).dataUrl;
|
|
26732
26834
|
}
|
|
26733
26835
|
} catch (u) {
|
|
26734
|
-
|
|
26836
|
+
z.warn("Worker export failed, falling back to main thread:", u);
|
|
26735
26837
|
}
|
|
26736
26838
|
return this.mainThreadExportToDataURL(n, t, a, {
|
|
26737
26839
|
format: o,
|
|
@@ -26767,7 +26869,7 @@ const rn = class rn {
|
|
|
26767
26869
|
})).blob;
|
|
26768
26870
|
}
|
|
26769
26871
|
} catch (u) {
|
|
26770
|
-
|
|
26872
|
+
z.warn("Worker blob export failed, falling back to main thread:", u);
|
|
26771
26873
|
}
|
|
26772
26874
|
return this.mainThreadExportToBlob(n, t, a, {
|
|
26773
26875
|
format: o,
|
|
@@ -26791,15 +26893,15 @@ const rn = class rn {
|
|
|
26791
26893
|
transparentBackground: i = !1,
|
|
26792
26894
|
backgroundColor: l = n.backgroundColor
|
|
26793
26895
|
} = r;
|
|
26794
|
-
await
|
|
26896
|
+
await ue(t);
|
|
26795
26897
|
const d = document.createElement("canvas"), u = n.width * c, p = n.height * c;
|
|
26796
26898
|
d.width = u, d.height = p;
|
|
26797
26899
|
const f = d.getContext("2d");
|
|
26798
26900
|
if (f.scale(c, c), !i && n.exportBackground) {
|
|
26799
26901
|
if (f.save(), this.applyExportBackgroundClipPath(f, n), n.backgroundType === "texture" && n.backgroundTexture) {
|
|
26800
|
-
const g =
|
|
26902
|
+
const g = K.getTexturePresetColor(n.backgroundTexture);
|
|
26801
26903
|
f.fillStyle = g, f.fillRect(0, 0, n.width, n.height);
|
|
26802
|
-
const y =
|
|
26904
|
+
const y = K.getTexture(n.backgroundTexture);
|
|
26803
26905
|
y && y.complete && f.drawImage(y, 0, 0, n.width, n.height);
|
|
26804
26906
|
} else
|
|
26805
26907
|
f.fillStyle = l || n.backgroundColor, f.fillRect(0, 0, n.width, n.height);
|
|
@@ -26822,7 +26924,7 @@ const rn = class rn {
|
|
|
26822
26924
|
const x = $[E].id;
|
|
26823
26925
|
x && v.add(x);
|
|
26824
26926
|
}
|
|
26825
|
-
|
|
26927
|
+
An(
|
|
26826
26928
|
f,
|
|
26827
26929
|
T,
|
|
26828
26930
|
$,
|
|
@@ -26859,16 +26961,16 @@ const rn = class rn {
|
|
|
26859
26961
|
transparentBackground: i = !1,
|
|
26860
26962
|
backgroundColor: l = n.backgroundColor
|
|
26861
26963
|
} = r;
|
|
26862
|
-
await
|
|
26964
|
+
await ue(t);
|
|
26863
26965
|
const d = document.createElement("canvas"), u = n.width * c, p = n.height * c;
|
|
26864
26966
|
d.width = u, d.height = p;
|
|
26865
26967
|
const f = d.getContext("2d");
|
|
26866
26968
|
if (f.scale(c, c), !i && n.exportBackground) {
|
|
26867
26969
|
if (f.save(), this.applyExportBackgroundClipPath(f, n), n.backgroundType === "texture" && n.backgroundTexture) {
|
|
26868
|
-
const T =
|
|
26970
|
+
const T = K.getTexturePresetColor(n.backgroundTexture);
|
|
26869
26971
|
f.fillStyle = T, f.fillRect(0, 0, n.width, n.height);
|
|
26870
|
-
const C =
|
|
26871
|
-
C && C.complete ? f.drawImage(C, 0, 0, n.width, n.height) :
|
|
26972
|
+
const C = K.getTexture(n.backgroundTexture);
|
|
26973
|
+
C && C.complete ? f.drawImage(C, 0, 0, n.width, n.height) : z.warn("Texture not loaded for export:", n.backgroundTexture);
|
|
26872
26974
|
} else
|
|
26873
26975
|
f.fillStyle = l, f.fillRect(0, 0, n.width, n.height);
|
|
26874
26976
|
f.restore();
|
|
@@ -26879,7 +26981,7 @@ const rn = class rn {
|
|
|
26879
26981
|
const S = (T, C) => {
|
|
26880
26982
|
if (!C.id) return;
|
|
26881
26983
|
const _ = h.get(C.id);
|
|
26882
|
-
_ ? _.render(T, !1) :
|
|
26984
|
+
_ ? _.render(T, !1) : z.warn("Element not found in map:", C.id);
|
|
26883
26985
|
}, $ = b.map((T) => T.toJSON()), v = /* @__PURE__ */ new Set();
|
|
26884
26986
|
b.forEach((T, C) => {
|
|
26885
26987
|
var _;
|
|
@@ -26890,7 +26992,7 @@ const rn = class rn {
|
|
|
26890
26992
|
const F = $[A].id;
|
|
26891
26993
|
F && v.add(F);
|
|
26892
26994
|
}
|
|
26893
|
-
|
|
26995
|
+
An(
|
|
26894
26996
|
f,
|
|
26895
26997
|
w,
|
|
26896
26998
|
$,
|
|
@@ -26907,24 +27009,24 @@ const rn = class rn {
|
|
|
26907
27009
|
T.render(A, !1);
|
|
26908
27010
|
};
|
|
26909
27011
|
if (x && E)
|
|
26910
|
-
|
|
27012
|
+
ne(f, w, (A) => {
|
|
26911
27013
|
const F = T.getVisualBoundingBox();
|
|
26912
|
-
|
|
27014
|
+
ie(A, w.distressEffect, F, P);
|
|
26913
27015
|
});
|
|
26914
27016
|
else if (x)
|
|
26915
|
-
|
|
27017
|
+
ne(f, w, P);
|
|
26916
27018
|
else if (E) {
|
|
26917
27019
|
const A = T.getVisualBoundingBox();
|
|
26918
|
-
|
|
27020
|
+
ie(f, w.distressEffect, A, P);
|
|
26919
27021
|
} else
|
|
26920
27022
|
T.render(f, !1);
|
|
26921
27023
|
}
|
|
26922
|
-
}), (y = n.distressTexture) != null && y.enabled &&
|
|
27024
|
+
}), (y = n.distressTexture) != null && y.enabled && da(f, n.distressTexture, {
|
|
26923
27025
|
x: n.x,
|
|
26924
27026
|
y: n.y,
|
|
26925
27027
|
width: n.width,
|
|
26926
27028
|
height: n.height
|
|
26927
|
-
}), (k = n.imageMask) != null && k.enabled &&
|
|
27029
|
+
}), (k = n.imageMask) != null && k.enabled && na(f, n.imageMask, {
|
|
26928
27030
|
x: n.x,
|
|
26929
27031
|
y: n.y,
|
|
26930
27032
|
width: n.width,
|
|
@@ -26952,7 +27054,7 @@ const rn = class rn {
|
|
|
26952
27054
|
n.clip(i);
|
|
26953
27055
|
return;
|
|
26954
27056
|
} catch (i) {
|
|
26955
|
-
|
|
27057
|
+
z.warn("Invalid SVG path, falling back to rectangle:", i), n.rect(s, c, a, r);
|
|
26956
27058
|
}
|
|
26957
27059
|
n.clip();
|
|
26958
27060
|
}
|
|
@@ -26976,7 +27078,7 @@ const rn = class rn {
|
|
|
26976
27078
|
n.translate(a, r), n.clip(i), n.translate(-a, -r);
|
|
26977
27079
|
return;
|
|
26978
27080
|
} catch (i) {
|
|
26979
|
-
|
|
27081
|
+
z.warn("Invalid SVG path, falling back to rectangle:", i), n.rect(a, r, o, s);
|
|
26980
27082
|
}
|
|
26981
27083
|
n.clip();
|
|
26982
27084
|
}
|
|
@@ -27053,7 +27155,7 @@ const rn = class rn {
|
|
|
27053
27155
|
};
|
|
27054
27156
|
}
|
|
27055
27157
|
} catch (l) {
|
|
27056
|
-
|
|
27158
|
+
z.error("Worker benchmark failed:", l), i.recommendation = "Worker export not available - using main thread export";
|
|
27057
27159
|
}
|
|
27058
27160
|
else
|
|
27059
27161
|
i.recommendation = "Worker export not supported in this browser - using main thread export";
|
|
@@ -27163,57 +27265,60 @@ const rn = class rn {
|
|
|
27163
27265
|
return "previewBackgroundColor" in t && delete t.previewBackgroundColor, t;
|
|
27164
27266
|
}
|
|
27165
27267
|
};
|
|
27166
|
-
|
|
27167
|
-
let
|
|
27168
|
-
const
|
|
27268
|
+
on.CURRENT_VERSION = "2.0.0", on.workerManager = null, on.workerInitPromise = null;
|
|
27269
|
+
let yn = on;
|
|
27270
|
+
const Ra = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
27169
27271
|
__proto__: null,
|
|
27170
|
-
ExportManager:
|
|
27171
|
-
default:
|
|
27272
|
+
ExportManager: yn,
|
|
27273
|
+
default: yn
|
|
27172
27274
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
27173
27275
|
export {
|
|
27174
|
-
|
|
27175
|
-
|
|
27176
|
-
|
|
27177
|
-
|
|
27178
|
-
|
|
27179
|
-
|
|
27180
|
-
|
|
27181
|
-
|
|
27182
|
-
|
|
27183
|
-
|
|
27184
|
-
|
|
27185
|
-
|
|
27186
|
-
|
|
27187
|
-
|
|
27188
|
-
|
|
27189
|
-
|
|
27190
|
-
|
|
27191
|
-
|
|
27192
|
-
|
|
27193
|
-
|
|
27276
|
+
Oa as A,
|
|
27277
|
+
De as B,
|
|
27278
|
+
ut as C,
|
|
27279
|
+
Ie as D,
|
|
27280
|
+
yn as E,
|
|
27281
|
+
bn as F,
|
|
27282
|
+
ca as G,
|
|
27283
|
+
sa as H,
|
|
27284
|
+
ce as I,
|
|
27285
|
+
Ia as J,
|
|
27286
|
+
An as K,
|
|
27287
|
+
ie as L,
|
|
27288
|
+
da as M,
|
|
27289
|
+
na as N,
|
|
27290
|
+
Un as O,
|
|
27291
|
+
jt as P,
|
|
27292
|
+
Vt as Q,
|
|
27293
|
+
et as R,
|
|
27294
|
+
Ra as S,
|
|
27295
|
+
K as T,
|
|
27296
|
+
dn as W,
|
|
27297
|
+
ka as a,
|
|
27298
|
+
ge as b,
|
|
27194
27299
|
R as c,
|
|
27195
|
-
|
|
27196
|
-
|
|
27197
|
-
|
|
27198
|
-
|
|
27199
|
-
|
|
27200
|
-
|
|
27201
|
-
|
|
27202
|
-
|
|
27203
|
-
|
|
27204
|
-
|
|
27205
|
-
|
|
27206
|
-
|
|
27207
|
-
|
|
27208
|
-
|
|
27209
|
-
|
|
27210
|
-
|
|
27211
|
-
|
|
27212
|
-
|
|
27213
|
-
|
|
27214
|
-
|
|
27215
|
-
|
|
27216
|
-
|
|
27217
|
-
|
|
27300
|
+
Da as d,
|
|
27301
|
+
Pa as e,
|
|
27302
|
+
On as f,
|
|
27303
|
+
xa as g,
|
|
27304
|
+
wa as h,
|
|
27305
|
+
rt as i,
|
|
27306
|
+
Sa as j,
|
|
27307
|
+
va as k,
|
|
27308
|
+
cn as l,
|
|
27309
|
+
Ma as m,
|
|
27310
|
+
Aa as n,
|
|
27311
|
+
Xn as o,
|
|
27312
|
+
Fa as p,
|
|
27313
|
+
_n as q,
|
|
27314
|
+
ot as r,
|
|
27315
|
+
Ta as s,
|
|
27316
|
+
Ca as t,
|
|
27317
|
+
dt as u,
|
|
27318
|
+
_a as v,
|
|
27319
|
+
ft as w,
|
|
27320
|
+
me as x,
|
|
27321
|
+
Ea as y,
|
|
27322
|
+
ne as z
|
|
27218
27323
|
};
|
|
27219
|
-
//# sourceMappingURL=ExportManager-
|
|
27324
|
+
//# sourceMappingURL=ExportManager-DoU4VK6h.js.map
|