@snowcone-app/canvas 0.46.11 → 0.46.13
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/ERROR_CONTRACT.md +13 -0
- package/dist/{CanvasRenderer-CLL5V71e.js → CanvasRenderer-CV8fDS6m.js} +2 -2
- package/dist/{CanvasRenderer-CLL5V71e.js.map → CanvasRenderer-CV8fDS6m.js.map} +1 -1
- package/dist/{ContextualToolbars-DnsfOy7x.js → ContextualToolbars-DsQ83_VR.js} +4 -4
- package/dist/{ContextualToolbars-DnsfOy7x.js.map → ContextualToolbars-DsQ83_VR.js.map} +1 -1
- package/dist/{EditorCanvasImpl-DDBa3pvE.js → EditorCanvasImpl-CbKLAe8P.js} +6 -6
- package/dist/{EditorCanvasImpl-DDBa3pvE.js.map → EditorCanvasImpl-CbKLAe8P.js.map} +1 -1
- package/dist/{ExportManager-BR5uca6R.js → ExportManager-Q4GQE68T.js} +381 -376
- package/dist/{ExportManager-BR5uca6R.js.map → ExportManager-Q4GQE68T.js.map} +1 -1
- package/dist/{ImagePanel-Bez-5INu.js → ImagePanel-DNgvLouH.js} +3 -3
- package/dist/{ImagePanel-Bez-5INu.js.map → ImagePanel-DNgvLouH.js.map} +1 -1
- package/dist/{SnowconeCanvas-Cjnp1ztd.js → SnowconeCanvas-Cu3IuAhp.js} +8 -8
- package/dist/{SnowconeCanvas-Cjnp1ztd.js.map → SnowconeCanvas-Cu3IuAhp.js.map} +1 -1
- package/dist/advanced.mjs +10 -10
- package/dist/{compose-CZslfDUm.js → compose-CatWJeVf.js} +3 -3
- package/dist/{compose-CZslfDUm.js.map → compose-CatWJeVf.js.map} +1 -1
- package/dist/{custom-icons-DIqddGX1.js → custom-icons-DP6uSyX-.js} +2 -2
- package/dist/{custom-icons-DIqddGX1.js.map → custom-icons-DP6uSyX-.js.map} +1 -1
- package/dist/{embed-BydDaNDy.js → embed-DobFUit8.js} +6 -6
- package/dist/{embed-BydDaNDy.js.map → embed-DobFUit8.js.map} +1 -1
- package/dist/embed.mjs +4 -4
- package/dist/errors/editorError.d.ts +3 -0
- package/dist/fontAnalysisCache-B2lh7X-_.js.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/internals.mjs +3 -3
- package/dist/{template-fields-cNoo8zDC.js → template-fields-BqGWVbJo.js} +3 -3
- package/dist/{template-fields-cNoo8zDC.js.map → template-fields-BqGWVbJo.js.map} +1 -1
- package/dist/{useCommands-mpsd0_l5.js → useCommands-DHwYOhSp.js} +5 -5
- package/dist/{useCommands-mpsd0_l5.js.map → useCommands-DHwYOhSp.js.map} +1 -1
- package/dist/{validation-DjdrFk2P.js → validation-EoPS9fDC.js} +9 -9
- package/dist/{validation-DjdrFk2P.js.map → validation-EoPS9fDC.js.map} +1 -1
- package/example/package.json +1 -1
- package/package.json +4 -4
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { c as H, G as Je, ae as
|
|
2
|
-
import { imageFrameSize as
|
|
3
|
-
let
|
|
4
|
-
function
|
|
5
|
-
|
|
1
|
+
import { c as H, G as Je, ae as xt, v as Zt, u as er, ai as Pt, aQ as Qe, ag as tr, ad as Z, aR as rr, aS as or, s as nr, w as sr, af as ae, ah as ze, av as ar, aj as ir, aT as K, aU as cr, b as lr, aV as Se, aW as It, P as dr, S as hr, I as We, F as gr, W as fr, f as ur, d as pr, L as mr, C as yr, q as de, g as wr, A as nt } from "./fontAnalysisCache-B2lh7X-_.js";
|
|
2
|
+
import { imageFrameSize as br, hasImageMasks as At, effectiveImageCrop as kr, isFullCrop as vr, isNeutralAdjustments as Tr } from "@snowcone-app/design/wire";
|
|
3
|
+
let Rt = null;
|
|
4
|
+
function Sr(t) {
|
|
5
|
+
Rt = t;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
return
|
|
7
|
+
function ln() {
|
|
8
|
+
return Rt;
|
|
9
9
|
}
|
|
10
|
-
const
|
|
10
|
+
const Fr = H("TextureManager"), ce = class ce {
|
|
11
11
|
/**
|
|
12
12
|
* Load a texture by ID or URL
|
|
13
13
|
*/
|
|
@@ -21,7 +21,7 @@ const Sr = H("TextureManager"), ce = class ce {
|
|
|
21
21
|
s.crossOrigin = "anonymous", s.onload = () => {
|
|
22
22
|
this.cache.set(e, s), this.cache.set(r, s), this.loading.delete(e), this.loading.delete(r), n(s);
|
|
23
23
|
}, s.onerror = () => {
|
|
24
|
-
|
|
24
|
+
Fr.error("Failed to load texture:", r), this.loading.delete(e), this.loading.delete(r), a(new Error(`Failed to load texture: ${r}`));
|
|
25
25
|
}, s.src = r;
|
|
26
26
|
});
|
|
27
27
|
return this.loading.set(e, o), r !== e && this.loading.set(r, o), o;
|
|
@@ -98,28 +98,28 @@ ce.cache = /* @__PURE__ */ new Map(), ce.loading = /* @__PURE__ */ new Map(), ce
|
|
|
98
98
|
}
|
|
99
99
|
];
|
|
100
100
|
let me = ce;
|
|
101
|
-
const
|
|
101
|
+
const Cr = H("ElementPreviewRenderer"), Mr = {
|
|
102
102
|
width: 40,
|
|
103
103
|
height: 40,
|
|
104
104
|
padding: 4,
|
|
105
105
|
backgroundColor: "transparent"
|
|
106
106
|
};
|
|
107
|
-
function
|
|
107
|
+
function Er(t, e = {}) {
|
|
108
108
|
Ze();
|
|
109
|
-
const r = { ...
|
|
109
|
+
const r = { ...Mr, ...e }, o = document.createElement("canvas");
|
|
110
110
|
o.width = r.width, o.height = r.height;
|
|
111
111
|
const n = o.getContext("2d");
|
|
112
112
|
if (!n)
|
|
113
113
|
return "";
|
|
114
114
|
r.backgroundColor !== "transparent" && (n.fillStyle = r.backgroundColor, n.fillRect(0, 0, r.width, r.height)), n.save();
|
|
115
115
|
try {
|
|
116
|
-
t instanceof Je ?
|
|
116
|
+
t instanceof Je ? Ir(n, t, r) : Pr(n, t, r);
|
|
117
117
|
} catch (a) {
|
|
118
|
-
|
|
118
|
+
Cr.warn("Failed to generate preview:", a);
|
|
119
119
|
}
|
|
120
120
|
return n.restore(), o.toDataURL("image/png");
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function Pr(t, e, r) {
|
|
123
123
|
var f;
|
|
124
124
|
const o = ((f = e.getBoundingBox) == null ? void 0 : f.call(e)) || { x: 0, y: 0, width: 100, height: 100 }, n = o.width, a = o.height;
|
|
125
125
|
if (n === 0 || a === 0) {
|
|
@@ -139,7 +139,7 @@ function st(t, e, r) {
|
|
|
139
139
|
const o = e.transformType || "Element";
|
|
140
140
|
t.fillText(o, r.width / 2, r.height / 2);
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function Ir(t, e, r) {
|
|
143
143
|
const o = r.width - r.padding * 2, n = r.height - r.padding * 2, a = r.padding, s = r.padding;
|
|
144
144
|
t.fillStyle = "#888888", t.strokeStyle = "#666666", t.lineWidth = 1;
|
|
145
145
|
const c = n * 0.7, i = s + n * 0.3, l = o * 0.4, d = n * 0.2;
|
|
@@ -149,21 +149,21 @@ function Pr(t, e, r) {
|
|
|
149
149
|
i + c / 2
|
|
150
150
|
));
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function dn(t, e, r) {
|
|
153
153
|
var l;
|
|
154
154
|
t.translate(e.x || 0, e.y || 0), t.rotate(-(e.rotation || 0) * Math.PI / 180);
|
|
155
155
|
const o = e, n = o.fontSize || 24, a = o.fontFamily || "Arial", s = o.bold || !1, c = o.italic || !1;
|
|
156
|
-
t.font =
|
|
156
|
+
t.font = xt(n, a, s, c);
|
|
157
157
|
const i = o.text || "";
|
|
158
158
|
if (e.transformType === "custom") {
|
|
159
|
-
const h = ((l = e.transformData) == null ? void 0 : l.width) || 200, g =
|
|
159
|
+
const h = ((l = e.transformData) == null ? void 0 : l.width) || 200, g = Zt(i, n, a, s, c), f = Math.min(g, h), p = n * 1.2;
|
|
160
160
|
t.rect(-f / 2, -p / 2, f, p);
|
|
161
161
|
} else {
|
|
162
162
|
const d = t.measureText(i).width;
|
|
163
163
|
t.beginPath(), t.moveTo(-d / 2, 0), t.lineTo(d / 2, 0), t.moveTo(-d / 2, -n), t.lineTo(d / 2, -n), t.moveTo(-d / 2, n * 0.2), t.lineTo(d / 2, n * 0.2);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function Ar(t, e) {
|
|
167
167
|
if (!e.transformData) return;
|
|
168
168
|
const { borderRadius: r = 0 } = e.transformData, o = e.transformData.width ?? 100, n = e.transformData.height ?? 100;
|
|
169
169
|
if (t.translate(e.x || 0, e.y || 0), t.rotate(-(e.rotation || 0) * Math.PI / 180), t.beginPath(), r > 0) {
|
|
@@ -172,22 +172,22 @@ function Ir(t, e) {
|
|
|
172
172
|
} else
|
|
173
173
|
t.rect(-o / 2, -n / 2, o, n);
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function hn(t, e, r, o) {
|
|
176
176
|
t.beginPath(), t.arc(e, r, o, 0, Math.PI * 2), t.closePath();
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function gn(t, e, r, o, n) {
|
|
179
179
|
t.beginPath(), t.rect(e, r, o, n), t.closePath();
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function Bt(t, e) {
|
|
182
182
|
t.strokeStyle = e.color, t.lineWidth = e.width, t.lineCap = e.lineCap || "butt", t.lineJoin = e.lineJoin || "miter", e.miterLimit !== void 0 && (t.miterLimit = e.miterLimit), e.dashArray && e.dashArray.length > 0 ? t.setLineDash(e.dashArray) : t.setLineDash([]), e.opacity !== void 0 && (t.globalAlpha = e.opacity);
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function Rr(t, e) {
|
|
185
185
|
if (typeof OffscreenCanvas < "u")
|
|
186
186
|
return new OffscreenCanvas(t, e);
|
|
187
187
|
const r = document.createElement("canvas");
|
|
188
188
|
return r.width = t, r.height = e, r;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function Wt(t, e, r) {
|
|
191
191
|
var i;
|
|
192
192
|
if (!((i = e.stroke) != null && i.enabled)) return;
|
|
193
193
|
const o = e;
|
|
@@ -195,21 +195,21 @@ function Bt(t, e, r) {
|
|
|
195
195
|
const a = (r == null ? void 0 : r.isKnockout) === !0, s = e.stroke.opacity ?? 1;
|
|
196
196
|
if (!a && s < 1)
|
|
197
197
|
try {
|
|
198
|
-
|
|
198
|
+
Br(t, e, o, r, s);
|
|
199
199
|
} catch {
|
|
200
200
|
ie(t, e, o, r, !1);
|
|
201
201
|
}
|
|
202
202
|
else
|
|
203
203
|
ie(t, e, o, r, a);
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function Br(t, e, r, o, n) {
|
|
206
206
|
var E, P;
|
|
207
207
|
const a = r.text || "", s = r.fontSize || 24, c = e.stroke.width, i = e.stroke.feather || 0, l = e.transformType === "custom" && ((E = e.transformData) == null ? void 0 : E.width), d = l ? ((P = e.transformData) == null ? void 0 : P.width) ?? 200 : 0, h = l ? d + c * 2 + i * 2 + 40 : s * a.length * 0.7 + c * 2 + i * 2 + 40, g = s * 3 + c * 2 + i * 2 + 40, f = t.getTransform(), p = Math.max(Math.abs(f.a), Math.abs(f.d), 1), u = Math.ceil(h * p / 2) * 2, y = Math.ceil(g * p / 2) * 2;
|
|
208
208
|
if (u <= 0 || y <= 0) {
|
|
209
209
|
ie(t, e, r, o, !1);
|
|
210
210
|
return;
|
|
211
211
|
}
|
|
212
|
-
const k =
|
|
212
|
+
const k = Rr(u, y), b = k.getContext("2d");
|
|
213
213
|
if (!b) {
|
|
214
214
|
ie(t, e, r, o, !1);
|
|
215
215
|
return;
|
|
@@ -236,9 +236,9 @@ function ie(t, e, r, o, n) {
|
|
|
236
236
|
t.save(), o != null && o.positionApplied || (t.translate(e.x || 0, e.y || 0), t.rotate(-(e.rotation || 0) * Math.PI / 180));
|
|
237
237
|
const s = r.fontSize || 24, c = r.fontFamily || "Arial", i = r.bold || !1, l = r.italic || !1, d = r.textAlign || "center";
|
|
238
238
|
t.font = `${l ? "italic " : ""}${i ? "bold " : ""}${s}px ${c}`, t.textAlign = d, t.textBaseline = "alphabetic", n ? (t.strokeStyle = "#000000", t.globalAlpha = 1) : (t.strokeStyle = e.stroke.color, e.stroke.opacity !== void 0 && (t.globalAlpha = e.stroke.opacity)), t.lineWidth = e.stroke.width, t.lineCap = e.stroke.lineCap || "round", t.lineJoin = e.stroke.lineJoin || "round", e.stroke.miterLimit !== void 0 && (t.miterLimit = e.stroke.miterLimit), !n && e.stroke.feather && e.stroke.feather > 0 && "filter" in t && (t.filter = `blur(${e.stroke.feather}px)`);
|
|
239
|
-
const h =
|
|
239
|
+
const h = er(s, c, i, l);
|
|
240
240
|
if (e.transformType === "custom" && ((f = e.transformData) == null ? void 0 : f.width)) {
|
|
241
|
-
const p = e.transformData, u = (p == null ? void 0 : p.width) ?? 200, y = u - Z * 2, k = r.letterSpacing ?? 0, { lines: b, height: v } =
|
|
241
|
+
const p = e.transformData, u = (p == null ? void 0 : p.width) ?? 200, y = u - Z * 2, k = r.letterSpacing ?? 0, { lines: b, height: v } = Pt(
|
|
242
242
|
a,
|
|
243
243
|
y,
|
|
244
244
|
s,
|
|
@@ -265,7 +265,7 @@ function ie(t, e, r, o, n) {
|
|
|
265
265
|
let M = m + Z;
|
|
266
266
|
d === "center" ? M = m + u / 2 : d === "right" && (M = m + u - Z);
|
|
267
267
|
const T = w + h.ascent + E * F;
|
|
268
|
-
|
|
268
|
+
tr(t, I, M, T, k);
|
|
269
269
|
});
|
|
270
270
|
} else {
|
|
271
271
|
const y = -h.height / 2 + h.ascent;
|
|
@@ -273,16 +273,16 @@ function ie(t, e, r, o, n) {
|
|
|
273
273
|
}
|
|
274
274
|
t.restore();
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function Wr(t, e, r) {
|
|
277
277
|
var n;
|
|
278
278
|
if (!((n = e.stroke) != null && n.enabled) || !e.transformData) return;
|
|
279
279
|
const o = (r == null ? void 0 : r.isKnockout) === !0;
|
|
280
|
-
t.save(), o ? (t.strokeStyle = "#000000", t.lineWidth = e.stroke.width, t.lineCap = e.stroke.lineCap || "butt", t.lineJoin = e.stroke.lineJoin || "miter", t.globalAlpha = 1, e.stroke.miterLimit !== void 0 && (t.miterLimit = e.stroke.miterLimit)) :
|
|
280
|
+
t.save(), o ? (t.strokeStyle = "#000000", t.lineWidth = e.stroke.width, t.lineCap = e.stroke.lineCap || "butt", t.lineJoin = e.stroke.lineJoin || "miter", t.globalAlpha = 1, e.stroke.miterLimit !== void 0 && (t.miterLimit = e.stroke.miterLimit)) : Bt(t, e.stroke), !o && e.stroke.feather && e.stroke.feather > 0 && "filter" in t && (t.filter = `blur(${e.stroke.feather}px)`), Ar(t, e), t.stroke(), t.restore();
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
e.enabled && (t.save(),
|
|
282
|
+
function fn(t, e, r) {
|
|
283
|
+
e.enabled && (t.save(), Bt(t, e), e.feather && e.feather > 0 && "filter" in t && (t.filter = `blur(${e.feather}px)`), t.beginPath(), r(), t.stroke(), t.restore());
|
|
284
284
|
}
|
|
285
|
-
const
|
|
285
|
+
const Ut = [
|
|
286
286
|
// Bold/Display Fonts - Perfect for statements and headlines (49 fonts)
|
|
287
287
|
{
|
|
288
288
|
name: "Bebas Neue",
|
|
@@ -1758,10 +1758,10 @@ const Wt = [
|
|
|
1758
1758
|
description: "Humanist monospace"
|
|
1759
1759
|
}
|
|
1760
1760
|
];
|
|
1761
|
-
function
|
|
1762
|
-
return
|
|
1761
|
+
function un() {
|
|
1762
|
+
return Ut.map((t) => t.name);
|
|
1763
1763
|
}
|
|
1764
|
-
const
|
|
1764
|
+
const pn = {
|
|
1765
1765
|
system: "System Fonts",
|
|
1766
1766
|
display: "Bold & Display",
|
|
1767
1767
|
"sans-serif": "Sans Serif",
|
|
@@ -1774,22 +1774,22 @@ const un = {
|
|
|
1774
1774
|
monospace: "Monospace"
|
|
1775
1775
|
};
|
|
1776
1776
|
let at = null;
|
|
1777
|
-
function
|
|
1778
|
-
return at ?? (at = new Map(
|
|
1777
|
+
function Ur(t) {
|
|
1778
|
+
return at ?? (at = new Map(Ut.filter((e) => {
|
|
1779
1779
|
var r;
|
|
1780
1780
|
return (r = e.weights) == null ? void 0 : r.length;
|
|
1781
1781
|
}).map((e) => [e.name, e.weights]))), at.get(t);
|
|
1782
1782
|
}
|
|
1783
|
-
function
|
|
1784
|
-
const r =
|
|
1783
|
+
function Or(t, e) {
|
|
1784
|
+
const r = Ur(t);
|
|
1785
1785
|
return !r || r.includes(e) ? e : r.reduce((o, n) => Math.abs(n - e) < Math.abs(o - e) ? n : o, r[0]);
|
|
1786
1786
|
}
|
|
1787
1787
|
const N = H("FontAnalyzer");
|
|
1788
1788
|
let Pe = null;
|
|
1789
|
-
async function
|
|
1789
|
+
async function Lr() {
|
|
1790
1790
|
return Pe || (Pe = await import("./browser-module-DFvKXBUE.js")), Pe;
|
|
1791
1791
|
}
|
|
1792
|
-
class
|
|
1792
|
+
class $r {
|
|
1793
1793
|
constructor() {
|
|
1794
1794
|
this.fontCache = /* @__PURE__ */ new Map(), this.failedFonts = /* @__PURE__ */ new Set(), this.CACHE_DURATION = 1e3 * 60 * 30, this.MAX_CACHE_SIZE = 5;
|
|
1795
1795
|
}
|
|
@@ -1809,13 +1809,13 @@ class Lr {
|
|
|
1809
1809
|
* Check if a font is a system font
|
|
1810
1810
|
*/
|
|
1811
1811
|
isSystemFont(e) {
|
|
1812
|
-
return
|
|
1812
|
+
return rr.has(e);
|
|
1813
1813
|
}
|
|
1814
1814
|
/**
|
|
1815
1815
|
* Get Google Fonts API URL for a specific font family
|
|
1816
1816
|
*/
|
|
1817
1817
|
getGoogleFontUrl(e, r = 400) {
|
|
1818
|
-
return `https://fonts.googleapis.com/css2?family=${e.replace(/\s+/g, "+")}:wght@${
|
|
1818
|
+
return `https://fonts.googleapis.com/css2?family=${e.replace(/\s+/g, "+")}:wght@${Or(e, r)}&display=swap`;
|
|
1819
1819
|
}
|
|
1820
1820
|
/**
|
|
1821
1821
|
* Extract actual font file URL from Google Fonts CSS
|
|
@@ -1857,7 +1857,7 @@ class Lr {
|
|
|
1857
1857
|
const s = await fetch(a);
|
|
1858
1858
|
if (!s.ok)
|
|
1859
1859
|
return N.error(`Font fetch failed: ${s.status} ${s.statusText}`), this.failedFonts.add(o), null;
|
|
1860
|
-
const c = await s.arrayBuffer(), i = new Uint8Array(c), d = (await
|
|
1860
|
+
const c = await s.arrayBuffer(), i = new Uint8Array(c), d = (await Lr()).create(i), h = "fonts" in d ? d.fonts[0] : d;
|
|
1861
1861
|
return this.fontCache.set(o, {
|
|
1862
1862
|
font: h,
|
|
1863
1863
|
url: a,
|
|
@@ -2208,10 +2208,10 @@ class Lr {
|
|
|
2208
2208
|
};
|
|
2209
2209
|
}
|
|
2210
2210
|
}
|
|
2211
|
-
const Ue = new
|
|
2212
|
-
|
|
2211
|
+
const Ue = new $r();
|
|
2212
|
+
or((t, e) => Ue.clearCache(t, e));
|
|
2213
2213
|
const it = H("GlyphRenderer");
|
|
2214
|
-
function
|
|
2214
|
+
function qr(t, e, r, o, n, a, s, c = {}) {
|
|
2215
2215
|
try {
|
|
2216
2216
|
const i = [];
|
|
2217
2217
|
Object.entries(s).forEach(([y, k]) => {
|
|
@@ -2261,7 +2261,7 @@ function $r(t, e, r, o, n, a, s, c = {}) {
|
|
|
2261
2261
|
it.error("Error rendering with fontkit:", i), t.fillStyle = c.color || "#000000", t.textAlign = c.align || "left", t.fillText(r, o, n);
|
|
2262
2262
|
}
|
|
2263
2263
|
}
|
|
2264
|
-
function
|
|
2264
|
+
function Hr(t, e, r, o, n, a, s, c = {}) {
|
|
2265
2265
|
const l = ((y) => {
|
|
2266
2266
|
for (const k of y) {
|
|
2267
2267
|
const b = k.codePointAt(0);
|
|
@@ -2314,12 +2314,12 @@ function qr(t, e, r, o, n, a, s, c = {}) {
|
|
|
2314
2314
|
}
|
|
2315
2315
|
}), t.restore();
|
|
2316
2316
|
}
|
|
2317
|
-
function
|
|
2317
|
+
function Gr(t, e, r, o, n) {
|
|
2318
2318
|
t.fillStyle = r.color;
|
|
2319
|
-
const a = r.textAlign || "center", s = (u) => u.letterSpacing !== void 0 ? u.letterSpacing : r.letterSpacing ?? 0, c =
|
|
2319
|
+
const a = r.textAlign || "center", s = (u) => u.letterSpacing !== void 0 ? u.letterSpacing : r.letterSpacing ?? 0, c = nr(e);
|
|
2320
2320
|
let i, l;
|
|
2321
2321
|
o !== void 0 && o > 0 && !n ? (i = [], l = [], c.forEach((u) => {
|
|
2322
|
-
const y =
|
|
2322
|
+
const y = sr(u, o, r);
|
|
2323
2323
|
y.forEach((k, b) => {
|
|
2324
2324
|
i.push(k), l.push({
|
|
2325
2325
|
isParagraphStart: b === 0,
|
|
@@ -2340,7 +2340,7 @@ function Hr(t, e, r, o, n) {
|
|
|
2340
2340
|
t.font = $(A, W, R, B);
|
|
2341
2341
|
const U = ae(t.measureText(T.text).width, T.text, s(T.style));
|
|
2342
2342
|
k.push(U);
|
|
2343
|
-
const q =
|
|
2343
|
+
const q = he(A, W, R, B);
|
|
2344
2344
|
b = Math.max(b, q.height), v = Math.max(v, q.ascent);
|
|
2345
2345
|
});
|
|
2346
2346
|
const F = u.map((T) => T.text).join(""), C = F.match(/^ +/), E = F.match(/ +$/), P = C ? C[0].length : 0, S = E ? E[0].length : 0;
|
|
@@ -2356,7 +2356,7 @@ function Hr(t, e, r, o, n) {
|
|
|
2356
2356
|
if (!w && S > 0) {
|
|
2357
2357
|
const L = F.length - S;
|
|
2358
2358
|
if (Me > L) {
|
|
2359
|
-
const
|
|
2359
|
+
const Y = !m && P > 0 && q < P ? Math.min(P - q, T.text.length) : 0, Ee = Math.max(0, L - q - Y);
|
|
2360
2360
|
U = U.substring(0, Ee);
|
|
2361
2361
|
}
|
|
2362
2362
|
}
|
|
@@ -2377,7 +2377,7 @@ function Hr(t, e, r, o, n) {
|
|
|
2377
2377
|
isParagraphEnd: w
|
|
2378
2378
|
});
|
|
2379
2379
|
});
|
|
2380
|
-
const h =
|
|
2380
|
+
const h = he(r.fontSize, r.fontFamily, r.bold, r.italic), g = r.fontSize * (r.lineHeight ?? Qe);
|
|
2381
2381
|
let f;
|
|
2382
2382
|
d.length === 0 ? f = 0 : d.length === 1 ? f = h.height : f = (d.length - 1) * g + h.height;
|
|
2383
2383
|
const p = -f / 2;
|
|
@@ -2389,22 +2389,22 @@ function Hr(t, e, r, o, n) {
|
|
|
2389
2389
|
let M = 0;
|
|
2390
2390
|
k.forEach((T) => {
|
|
2391
2391
|
const A = T.style.fontSize !== void 0 ? T.style.fontSize : r.fontSize, W = T.style.fontFamily !== void 0 ? T.style.fontFamily : r.fontFamily, R = T.style.color !== void 0 ? T.style.color : r.color, B = T.style.bold !== void 0 ? T.style.bold : r.bold || !1, U = T.style.italic !== void 0 ? T.style.italic : r.italic || !1, q = T.style.underline !== void 0 ? T.style.underline : r.underline || !1, Me = T.style.strikethrough !== void 0 ? T.style.strikethrough : r.strikethrough || !1;
|
|
2392
|
-
let L = T.text,
|
|
2393
|
-
if (!v && S > 0 &&
|
|
2394
|
-
const
|
|
2395
|
-
L = L.substring(
|
|
2392
|
+
let L = T.text, Y = M, Ee = M + T.text.length;
|
|
2393
|
+
if (!v && S > 0 && Y < S) {
|
|
2394
|
+
const V = Math.min(S - Y, T.text.length);
|
|
2395
|
+
L = L.substring(V);
|
|
2396
2396
|
}
|
|
2397
2397
|
if (!m && I > 0) {
|
|
2398
|
-
const
|
|
2399
|
-
if (Ee >
|
|
2400
|
-
const oe = !v && S > 0 &&
|
|
2398
|
+
const V = C.length - I;
|
|
2399
|
+
if (Ee > V) {
|
|
2400
|
+
const oe = !v && S > 0 && Y < S ? Math.min(S - Y, T.text.length) : 0, D = Math.max(0, V - Y - oe);
|
|
2401
2401
|
L = L.substring(0, D);
|
|
2402
2402
|
}
|
|
2403
2403
|
}
|
|
2404
2404
|
if (M += T.text.length, L.length > 0) {
|
|
2405
|
-
const
|
|
2406
|
-
t.font = $(A, W, B, U), t.fillStyle = R, t.textBaseline = "alphabetic", t.textAlign = "left", ze(t, L, w, F,
|
|
2407
|
-
const oe = ae(t.measureText(L).width, L,
|
|
2405
|
+
const V = s(T.style);
|
|
2406
|
+
t.font = $(A, W, B, U), t.fillStyle = R, t.textBaseline = "alphabetic", t.textAlign = "left", ze(t, L, w, F, V);
|
|
2407
|
+
const oe = ae(t.measureText(L).width, L, V);
|
|
2408
2408
|
if (q) {
|
|
2409
2409
|
const D = F + A * 0.1;
|
|
2410
2410
|
t.beginPath(), t.moveTo(w, D), t.lineTo(w + oe, D), t.lineWidth = Math.max(1, A * 0.05), t.strokeStyle = R, t.stroke();
|
|
@@ -2419,16 +2419,16 @@ function Hr(t, e, r, o, n) {
|
|
|
2419
2419
|
});
|
|
2420
2420
|
}
|
|
2421
2421
|
const Oe = H("canvas-renderer");
|
|
2422
|
-
let
|
|
2422
|
+
let ue = null;
|
|
2423
2423
|
function xe() {
|
|
2424
|
-
if (!
|
|
2424
|
+
if (!ue)
|
|
2425
2425
|
if (typeof OffscreenCanvas < "u")
|
|
2426
|
-
|
|
2426
|
+
ue = new OffscreenCanvas(1, 1).getContext("2d");
|
|
2427
2427
|
else if (typeof document < "u")
|
|
2428
|
-
|
|
2428
|
+
ue = document.createElement("canvas").getContext("2d");
|
|
2429
2429
|
else
|
|
2430
2430
|
throw new Error("No canvas context available");
|
|
2431
|
-
return
|
|
2431
|
+
return ue;
|
|
2432
2432
|
}
|
|
2433
2433
|
function $(t, e, r = !1, o = !1) {
|
|
2434
2434
|
const n = [];
|
|
@@ -2438,13 +2438,13 @@ function ct(t, e, r, o = !1, n = !1, a = 0) {
|
|
|
2438
2438
|
const s = xe();
|
|
2439
2439
|
return s.font = $(e, r, o, n), ae(s.measureText(t).width, t, a);
|
|
2440
2440
|
}
|
|
2441
|
-
function
|
|
2441
|
+
function he(t, e, r = !1, o = !1) {
|
|
2442
2442
|
const n = xe();
|
|
2443
2443
|
n.font = $(t, e, r, o);
|
|
2444
2444
|
const s = n.measureText("ÁÉÍgjpqy"), c = s.actualBoundingBoxAscent || t * 0.8, i = s.actualBoundingBoxDescent || t * 0.2, l = c + i;
|
|
2445
2445
|
return { ascent: c, descent: i, height: l };
|
|
2446
2446
|
}
|
|
2447
|
-
function
|
|
2447
|
+
function mn(t, e) {
|
|
2448
2448
|
const r = t.map((n, a) => ({
|
|
2449
2449
|
isParagraphStart: !e && a === 0,
|
|
2450
2450
|
isParagraphEnd: !e && a === t.length - 1
|
|
@@ -2457,13 +2457,13 @@ function pn(t, e) {
|
|
|
2457
2457
|
return s || (i = i.replace(/^ +/, "")), c || (i = i.replace(/ +$/, "")), i;
|
|
2458
2458
|
}).filter((n) => n.length > 0);
|
|
2459
2459
|
}
|
|
2460
|
-
function
|
|
2460
|
+
function Nr(t, e) {
|
|
2461
2461
|
const r = e.fontSize, o = e.fontFamily, n = e.bold || !1, a = e.italic || !1, s = e.textAlign || "center", c = e.text;
|
|
2462
2462
|
t.font = $(r, o, n, a), t.textAlign = s, t.textBaseline = "alphabetic", t.fillStyle = e.color;
|
|
2463
|
-
const i =
|
|
2463
|
+
const i = he(r, o, n, a), h = -i.height / 2 + i.ascent;
|
|
2464
2464
|
ze(t, c, 0, h, e.letterSpacing);
|
|
2465
2465
|
}
|
|
2466
|
-
function
|
|
2466
|
+
function _r(t, e, r, o, n = !1, a = !1, s) {
|
|
2467
2467
|
const c = xe();
|
|
2468
2468
|
if (c.font = $(r, o, n, a), t.trim().length === 0)
|
|
2469
2469
|
return [t];
|
|
@@ -2472,7 +2472,7 @@ function Nr(t, e, r, o, n = !1, a = !1, s) {
|
|
|
2472
2472
|
const E = t.split(`
|
|
2473
2473
|
`), P = [];
|
|
2474
2474
|
for (let S = 0; S < E.length; S++) {
|
|
2475
|
-
const I = E[S], M =
|
|
2475
|
+
const I = E[S], M = _r(I, e, r, o, n, a);
|
|
2476
2476
|
P.push(...M);
|
|
2477
2477
|
}
|
|
2478
2478
|
return P;
|
|
@@ -2500,7 +2500,7 @@ function Nr(t, e, r, o, n = !1, a = !1, s) {
|
|
|
2500
2500
|
}
|
|
2501
2501
|
return m.push(w), m.length > 0 && (m[0] = d + m[0], m[m.length - 1] = m[m.length - 1] + h), m;
|
|
2502
2502
|
}
|
|
2503
|
-
function
|
|
2503
|
+
function yn(t, e, r, o, n, a, s = "left", c = 0, i = 0, l = 1.2, d = !1, h = !1, g = !1, f = !1, p, u) {
|
|
2504
2504
|
t.font = $(n, a, d, h), t.textBaseline = "alphabetic", t.textAlign = s;
|
|
2505
2505
|
const y = (S) => {
|
|
2506
2506
|
for (const I of S) {
|
|
@@ -2515,7 +2515,7 @@ function mn(t, e, r, o, n, a, s = "left", c = 0, i = 0, l = 1.2, d = !1, h = !1,
|
|
|
2515
2515
|
), Ue.loadFont(a, d ? 700 : 400).catch((S) => {
|
|
2516
2516
|
Oe.error("[renderMultilineText] Error loading font:", S);
|
|
2517
2517
|
}));
|
|
2518
|
-
const C =
|
|
2518
|
+
const C = he(n, a, d, h), E = n * l;
|
|
2519
2519
|
let P = 0;
|
|
2520
2520
|
e.forEach((S, I) => {
|
|
2521
2521
|
let M = r + i;
|
|
@@ -2528,10 +2528,10 @@ function mn(t, e, r, o, n, a, s = "left", c = 0, i = 0, l = 1.2, d = !1, h = !1,
|
|
|
2528
2528
|
charIndex: R.charIndex - P
|
|
2529
2529
|
// Adjust to line-relative index
|
|
2530
2530
|
})) : [];
|
|
2531
|
-
if (F && (k || W.length > 0 || m) ? W.length > 0 || y(S) ?
|
|
2531
|
+
if (F && (k || W.length > 0 || m) ? W.length > 0 || y(S) ? Hr(t, F, S, M, T, n, W, {
|
|
2532
2532
|
color: t.fillStyle,
|
|
2533
2533
|
align: s === "start" || s === "end" ? "left" : s
|
|
2534
|
-
}) : p &&
|
|
2534
|
+
}) : p && qr(t, F, S, M, T, n, p, {
|
|
2535
2535
|
color: t.fillStyle,
|
|
2536
2536
|
align: s === "start" || s === "end" ? "left" : s
|
|
2537
2537
|
}) : t.fillText(S, M, T), P += A + 1, g) {
|
|
@@ -2551,17 +2551,17 @@ function mn(t, e, r, o, n, a, s = "left", c = 0, i = 0, l = 1.2, d = !1, h = !1,
|
|
|
2551
2551
|
});
|
|
2552
2552
|
}
|
|
2553
2553
|
function Le(t, e) {
|
|
2554
|
-
|
|
2554
|
+
jr(t, e);
|
|
2555
2555
|
}
|
|
2556
|
-
function
|
|
2556
|
+
function jr(t, e) {
|
|
2557
2557
|
var n;
|
|
2558
|
-
(n = e.stroke) != null && n.enabled &&
|
|
2558
|
+
(n = e.stroke) != null && n.enabled && Wt(t, e), t.save(), t.translate(e.x, e.y), t.rotate(-e.rotation * Math.PI / 180);
|
|
2559
2559
|
const r = e.transformData, o = ((r == null ? void 0 : r.width) ?? 100) - Z * 2;
|
|
2560
2560
|
if (e.richText) {
|
|
2561
|
-
const a =
|
|
2561
|
+
const a = ar.fromJSON(e.richText);
|
|
2562
2562
|
t.save(), t.translate(0, 0);
|
|
2563
2563
|
const s = e._lockedLineCount;
|
|
2564
|
-
|
|
2564
|
+
Gr(
|
|
2565
2565
|
t,
|
|
2566
2566
|
a,
|
|
2567
2567
|
{
|
|
@@ -2581,7 +2581,7 @@ function _r(t, e) {
|
|
|
2581
2581
|
), t.restore();
|
|
2582
2582
|
} else if (e.text) {
|
|
2583
2583
|
t.fillStyle = e.color;
|
|
2584
|
-
const a = e._lockedLineCount, s = e.letterSpacing ?? 0, { lines: c, height: i } =
|
|
2584
|
+
const a = e._lockedLineCount, s = e.letterSpacing ?? 0, { lines: c, height: i } = Pt(
|
|
2585
2585
|
e.text,
|
|
2586
2586
|
o,
|
|
2587
2587
|
e.fontSize,
|
|
@@ -2592,7 +2592,7 @@ function _r(t, e) {
|
|
|
2592
2592
|
!0,
|
|
2593
2593
|
// strict: true
|
|
2594
2594
|
{ letterSpacing: s, lineHeight: e.lineHeight }
|
|
2595
|
-
), l =
|
|
2595
|
+
), l = he(
|
|
2596
2596
|
e.fontSize,
|
|
2597
2597
|
e.fontFamily,
|
|
2598
2598
|
e.bold,
|
|
@@ -2628,17 +2628,17 @@ function _r(t, e) {
|
|
|
2628
2628
|
}
|
|
2629
2629
|
t.restore();
|
|
2630
2630
|
}
|
|
2631
|
-
function
|
|
2631
|
+
function wn(t, e) {
|
|
2632
2632
|
var s;
|
|
2633
2633
|
const r = e.opacity ?? 1, o = !!((s = e.stroke) != null && s.enabled), n = e.type === "custom";
|
|
2634
2634
|
if (r < 1 && o && n) {
|
|
2635
|
-
|
|
2635
|
+
Xr(t, e, r);
|
|
2636
2636
|
return;
|
|
2637
2637
|
}
|
|
2638
2638
|
const a = t.globalAlpha;
|
|
2639
2639
|
r !== 1 && (t.globalAlpha = r), $e(t, e), t.globalAlpha = a;
|
|
2640
2640
|
}
|
|
2641
|
-
function
|
|
2641
|
+
function Xr(t, e, r) {
|
|
2642
2642
|
var y;
|
|
2643
2643
|
const o = e.transformData, n = e.fontSize || 24, a = ((y = e.stroke) == null ? void 0 : y.width) || 0, s = ((o == null ? void 0 : o.width) ?? n * e.text.length * 0.7) + a * 2 + 40, c = n * 3 + a * 2 + 40, i = t.getTransform(), l = Math.max(Math.abs(i.a), Math.abs(i.d), 1), d = Math.ceil(s * l), h = Math.ceil(c * l);
|
|
2644
2644
|
let g;
|
|
@@ -2665,28 +2665,28 @@ function $e(t, e) {
|
|
|
2665
2665
|
Le(t, e);
|
|
2666
2666
|
break;
|
|
2667
2667
|
case "circle":
|
|
2668
|
-
|
|
2668
|
+
Ot(t, e);
|
|
2669
2669
|
break;
|
|
2670
2670
|
case "wave":
|
|
2671
|
-
|
|
2671
|
+
Lt(t, e);
|
|
2672
2672
|
break;
|
|
2673
2673
|
case "arch":
|
|
2674
|
-
|
|
2674
|
+
$t(t, e);
|
|
2675
2675
|
break;
|
|
2676
2676
|
case "ascend":
|
|
2677
|
-
|
|
2677
|
+
qt(t, e);
|
|
2678
2678
|
break;
|
|
2679
2679
|
case "lean":
|
|
2680
|
-
|
|
2680
|
+
Ht(t, e);
|
|
2681
2681
|
break;
|
|
2682
2682
|
case "flag":
|
|
2683
|
-
|
|
2683
|
+
Gt(t, e);
|
|
2684
2684
|
break;
|
|
2685
2685
|
default:
|
|
2686
2686
|
Oe.warn(`[canvas-renderer] Unsupported transform type: ${e.type}`), Le(t, e);
|
|
2687
2687
|
}
|
|
2688
2688
|
}
|
|
2689
|
-
function
|
|
2689
|
+
function Yr(t, e) {
|
|
2690
2690
|
if (typeof OffscreenCanvas < "u")
|
|
2691
2691
|
return new OffscreenCanvas(t, e);
|
|
2692
2692
|
const r = document.createElement("canvas");
|
|
@@ -2711,7 +2711,7 @@ function re(t, e, r) {
|
|
|
2711
2711
|
r(t, e);
|
|
2712
2712
|
return;
|
|
2713
2713
|
}
|
|
2714
|
-
const P =
|
|
2714
|
+
const P = Yr(C, E), S = P.getContext("2d");
|
|
2715
2715
|
if (!S) {
|
|
2716
2716
|
r(t, e);
|
|
2717
2717
|
return;
|
|
@@ -2739,7 +2739,7 @@ function re(t, e, r) {
|
|
|
2739
2739
|
R
|
|
2740
2740
|
), t.restore();
|
|
2741
2741
|
}
|
|
2742
|
-
function
|
|
2742
|
+
function Ot(t, e) {
|
|
2743
2743
|
re(t, e, Vr);
|
|
2744
2744
|
}
|
|
2745
2745
|
function Vr(t, e) {
|
|
@@ -2763,23 +2763,23 @@ function Vr(t, e) {
|
|
|
2763
2763
|
}
|
|
2764
2764
|
t.restore();
|
|
2765
2765
|
}
|
|
2766
|
-
function
|
|
2767
|
-
re(t, e,
|
|
2766
|
+
function Lt(t, e) {
|
|
2767
|
+
re(t, e, Dr);
|
|
2768
2768
|
}
|
|
2769
|
-
function
|
|
2769
|
+
function Dr(t, e) {
|
|
2770
2770
|
const r = e.transformData;
|
|
2771
2771
|
t.save(), t.translate(e.x, e.y), t.rotate(-e.rotation * Math.PI / 180), t.font = $(e.fontSize, e.fontFamily, e.bold, e.italic), t.fillStyle = e.color, t.textAlign = "center", t.textBaseline = "middle";
|
|
2772
2772
|
const o = e.text.split("");
|
|
2773
2773
|
let a = -o.reduce((s, c) => s + t.measureText(c).width, 0) / 2;
|
|
2774
2774
|
o.forEach((s) => {
|
|
2775
2775
|
const c = t.measureText(s).width, i = a + c / 2, l = i / (r.width / 2), d = r.amplitude * e.fontSize * Math.sin(r.frequency * Math.PI * l), h = r.amplitude * r.frequency * Math.PI * Math.cos(r.frequency * Math.PI * l);
|
|
2776
|
-
t.save(), t.translate(i, d), t.transform(1, h *
|
|
2776
|
+
t.save(), t.translate(i, d), t.transform(1, h * ir, 0, 1, 0, 0), te(t, s, e.stroke), t.fillText(s, 0, 0), t.restore(), a += c;
|
|
2777
2777
|
}), t.restore();
|
|
2778
2778
|
}
|
|
2779
|
-
function
|
|
2780
|
-
re(t, e,
|
|
2779
|
+
function $t(t, e) {
|
|
2780
|
+
re(t, e, Kr);
|
|
2781
2781
|
}
|
|
2782
|
-
function
|
|
2782
|
+
function Kr(t, e) {
|
|
2783
2783
|
const r = e.transformData;
|
|
2784
2784
|
t.save(), t.translate(e.x, e.y), t.rotate(-e.rotation * Math.PI / 180), t.font = $(e.fontSize, e.fontFamily, e.bold, e.italic), t.fillStyle = e.color, t.textAlign = "center", t.textBaseline = "middle";
|
|
2785
2785
|
const o = e.text.split(""), n = o.reduce((c, i) => c + t.measureText(i).width, 0), a = r.width / 2;
|
|
@@ -2789,10 +2789,10 @@ function Dr(t, e) {
|
|
|
2789
2789
|
t.save(), t.translate(l, h), t.transform(1, g * 0.3, 0, 1, 0, 0), te(t, c, e.stroke), t.fillText(c, 0, 0), t.restore(), s += i;
|
|
2790
2790
|
}), t.restore();
|
|
2791
2791
|
}
|
|
2792
|
-
function
|
|
2793
|
-
re(t, e,
|
|
2792
|
+
function qt(t, e) {
|
|
2793
|
+
re(t, e, Jr);
|
|
2794
2794
|
}
|
|
2795
|
-
function
|
|
2795
|
+
function Jr(t, e) {
|
|
2796
2796
|
const r = e.transformData;
|
|
2797
2797
|
t.save(), t.translate(e.x, e.y), t.rotate(-e.rotation * Math.PI / 180), t.font = $(e.fontSize, e.fontFamily, e.bold, e.italic), t.fillStyle = e.color, t.textAlign = "center", t.textBaseline = "middle";
|
|
2798
2798
|
const o = e.text.split(""), n = o.reduce((c, i) => c + t.measureText(i).width, 0), a = r.ascendAngle * Math.PI / 180;
|
|
@@ -2802,20 +2802,20 @@ function Kr(t, e) {
|
|
|
2802
2802
|
t.save(), t.translate(l, d), t.transform(1, h * 1, 0, 1, 0, 0), te(t, c, e.stroke), t.fillText(c, 0, 0), t.restore(), s += i;
|
|
2803
2803
|
}), t.restore();
|
|
2804
2804
|
}
|
|
2805
|
-
function
|
|
2806
|
-
re(t, e,
|
|
2805
|
+
function Ht(t, e) {
|
|
2806
|
+
re(t, e, Qr);
|
|
2807
2807
|
}
|
|
2808
|
-
function
|
|
2808
|
+
function Qr(t, e) {
|
|
2809
2809
|
var n;
|
|
2810
2810
|
const r = e.transformData;
|
|
2811
2811
|
t.save(), t.translate(e.x, e.y), t.rotate(-e.rotation * Math.PI / 180);
|
|
2812
2812
|
const o = -r.leanAmount * Math.PI / 4;
|
|
2813
2813
|
t.transform(1, 0, Math.tan(o), 1, 0, 0), t.font = $(e.fontSize, e.fontFamily, e.bold, e.italic), t.fillStyle = e.color, t.textAlign = "center", t.textBaseline = "middle", (n = e.stroke) != null && n.enabled && (t.save(), t.strokeStyle = e.stroke.color, t.lineWidth = e.stroke.width, t.lineCap = e.stroke.lineCap || "round", t.lineJoin = e.stroke.lineJoin || "round", e.stroke.opacity !== void 0 && (t.globalAlpha = e.stroke.opacity), t.strokeText(e.text, 0, 0), t.restore()), t.fillText(e.text, 0, 0), t.restore();
|
|
2814
2814
|
}
|
|
2815
|
-
function
|
|
2816
|
-
re(t, e,
|
|
2815
|
+
function Gt(t, e) {
|
|
2816
|
+
re(t, e, zr);
|
|
2817
2817
|
}
|
|
2818
|
-
function
|
|
2818
|
+
function zr(t, e) {
|
|
2819
2819
|
const r = e.transformData;
|
|
2820
2820
|
t.save(), t.translate(e.x, e.y), t.rotate(-e.rotation * Math.PI / 180), t.font = $(e.fontSize, e.fontFamily, e.bold, e.italic), t.fillStyle = e.color, t.textAlign = "center", t.textBaseline = "middle";
|
|
2821
2821
|
const o = e.text.split("");
|
|
@@ -2828,7 +2828,7 @@ function Qr(t, e) {
|
|
|
2828
2828
|
function Q(t) {
|
|
2829
2829
|
return (e, r) => t(e, r);
|
|
2830
2830
|
}
|
|
2831
|
-
function
|
|
2831
|
+
function xr(t, e) {
|
|
2832
2832
|
t.save();
|
|
2833
2833
|
const r = t.canvas, o = r.width, n = r.height, a = t.getTransform(), s = [];
|
|
2834
2834
|
let c = [];
|
|
@@ -2860,11 +2860,11 @@ function zr(t, e) {
|
|
|
2860
2860
|
}
|
|
2861
2861
|
var lt = !1;
|
|
2862
2862
|
function Ze() {
|
|
2863
|
-
lt || (lt = !0, K("arch", Q(
|
|
2863
|
+
lt || (lt = !0, K("arch", Q($t)), K("ascend", Q(qt)), K("circle", Q(Ot)), K("flag", Q(Gt)), K("lean", Q(Ht)), K("wave", Q(Lt)), K(
|
|
2864
2864
|
"custom",
|
|
2865
2865
|
(t, e) => Le(t, e)
|
|
2866
|
-
),
|
|
2867
|
-
(t, e) =>
|
|
2866
|
+
), cr(xr), Sr(
|
|
2867
|
+
(t, e) => Er(t, e)
|
|
2868
2868
|
), globalThis.__scElementPaintersInstalled = !0);
|
|
2869
2869
|
}
|
|
2870
2870
|
Ze();
|
|
@@ -2872,23 +2872,23 @@ function et(t, e, r = {}) {
|
|
|
2872
2872
|
const o = r.mode || "both";
|
|
2873
2873
|
switch (t.save(), t.translate(e.x || 0, e.y || 0), t.rotate(-(e.rotation || 0) * Math.PI / 180), e.transformType) {
|
|
2874
2874
|
case "image":
|
|
2875
|
-
|
|
2875
|
+
eo(t, e, o, r);
|
|
2876
2876
|
break;
|
|
2877
2877
|
case "shape":
|
|
2878
|
-
|
|
2878
|
+
to(t, e, o, r);
|
|
2879
2879
|
break;
|
|
2880
2880
|
case "group":
|
|
2881
2881
|
break;
|
|
2882
2882
|
default:
|
|
2883
|
-
|
|
2883
|
+
Zr(t, e, o, r);
|
|
2884
2884
|
break;
|
|
2885
2885
|
}
|
|
2886
2886
|
t.restore();
|
|
2887
2887
|
}
|
|
2888
|
-
function
|
|
2888
|
+
function Zr(t, e, r, o) {
|
|
2889
2889
|
var s;
|
|
2890
2890
|
const n = e, a = n.text || "";
|
|
2891
|
-
a && ((r === "stroke" || r === "both") && ((s = e.stroke) != null && s.enabled) && (t.save(),
|
|
2891
|
+
a && ((r === "stroke" || r === "both") && ((s = e.stroke) != null && s.enabled) && (t.save(), Wt(t, e, { ...o.renderingContext, positionApplied: !0 }), t.restore()), (r === "fill" || r === "both") && (t.save(), Nr(t, {
|
|
2892
2892
|
text: a,
|
|
2893
2893
|
fontSize: n.fontSize || 24,
|
|
2894
2894
|
fontFamily: n.fontFamily || "Arial",
|
|
@@ -2899,12 +2899,12 @@ function xr(t, e, r, o) {
|
|
|
2899
2899
|
letterSpacing: n.letterSpacing
|
|
2900
2900
|
}), t.restore()));
|
|
2901
2901
|
}
|
|
2902
|
-
function
|
|
2902
|
+
function eo(t, e, r, o) {
|
|
2903
2903
|
var a;
|
|
2904
2904
|
if (!e.transformData) return;
|
|
2905
2905
|
const n = e.transformData;
|
|
2906
2906
|
if (r === "fill" || r === "both")
|
|
2907
|
-
if (
|
|
2907
|
+
if (ao(t, e), o.loadedImage) {
|
|
2908
2908
|
t.save(), t.clip();
|
|
2909
2909
|
const s = n.flipHorizontal ? -1 : 1, c = n.flipVertical ? -1 : 1;
|
|
2910
2910
|
t.scale(s, c);
|
|
@@ -2912,28 +2912,28 @@ function Zr(t, e, r, o) {
|
|
|
2912
2912
|
t.drawImage(o.loadedImage, -i / 2, -l / 2, i, l), t.restore();
|
|
2913
2913
|
} else
|
|
2914
2914
|
t.fillStyle = "#cccccc", t.fill();
|
|
2915
|
-
(r === "stroke" || r === "both") && ((a = e.stroke) != null && a.enabled) && (t.save(),
|
|
2915
|
+
(r === "stroke" || r === "both") && ((a = e.stroke) != null && a.enabled) && (t.save(), Wr(t, e, o.renderingContext), t.restore());
|
|
2916
2916
|
}
|
|
2917
|
-
function
|
|
2917
|
+
function to(t, e, r, o) {
|
|
2918
2918
|
var s, c;
|
|
2919
2919
|
if (!e.transformData) return;
|
|
2920
2920
|
const n = e.transformData, a = ((s = o.renderingContext) == null ? void 0 : s.isKnockout) === !0;
|
|
2921
|
-
t.beginPath(),
|
|
2921
|
+
t.beginPath(), Nt(t, n), (r === "fill" || r === "both") && (t.fillStyle = a ? "#000000" : lr(t, n), t.globalAlpha = a ? 1 : n.fillOpacity ?? 1, t.fill()), (r === "stroke" || r === "both") && ((c = e.stroke) != null && c.enabled) && (t.save(), so(t, e, o.renderingContext), t.restore());
|
|
2922
2922
|
}
|
|
2923
|
-
function
|
|
2923
|
+
function Nt(t, e) {
|
|
2924
2924
|
const { shapeType: r } = e, o = e.width ?? 100, n = e.height ?? 100;
|
|
2925
2925
|
switch (r) {
|
|
2926
2926
|
case "rectangle":
|
|
2927
2927
|
dt(t, e, o, n);
|
|
2928
2928
|
break;
|
|
2929
2929
|
case "circle":
|
|
2930
|
-
|
|
2930
|
+
ro(t, Math.min(o, n) / 2);
|
|
2931
2931
|
break;
|
|
2932
2932
|
case "ellipse":
|
|
2933
|
-
|
|
2933
|
+
oo(t, o / 2, n / 2);
|
|
2934
2934
|
break;
|
|
2935
2935
|
case "star":
|
|
2936
|
-
|
|
2936
|
+
no(t, e, Math.min(o, n) / 2);
|
|
2937
2937
|
break;
|
|
2938
2938
|
default:
|
|
2939
2939
|
dt(t, e, o, n);
|
|
@@ -2947,13 +2947,13 @@ function dt(t, e, r, o) {
|
|
|
2947
2947
|
} else
|
|
2948
2948
|
t.rect(a, s, r, o);
|
|
2949
2949
|
}
|
|
2950
|
-
function
|
|
2950
|
+
function ro(t, e) {
|
|
2951
2951
|
t.arc(0, 0, e, 0, Math.PI * 2);
|
|
2952
2952
|
}
|
|
2953
|
-
function
|
|
2953
|
+
function oo(t, e, r) {
|
|
2954
2954
|
t.ellipse(0, 0, e, r, 0, 0, Math.PI * 2);
|
|
2955
2955
|
}
|
|
2956
|
-
function
|
|
2956
|
+
function no(t, e, r) {
|
|
2957
2957
|
const o = Math.max(3, Math.min(20, e.points || 5)), n = Math.max(0.1, Math.min(0.9, e.innerRadius || 0.4)), a = r * n, s = Math.PI / o, c = -Math.PI / 2;
|
|
2958
2958
|
for (let i = 0; i < o * 2; i++) {
|
|
2959
2959
|
const l = c + s * i, d = i % 2 === 0 ? r : a, h = Math.cos(l) * d, g = Math.sin(l) * d;
|
|
@@ -2961,13 +2961,13 @@ function oo(t, e, r) {
|
|
|
2961
2961
|
}
|
|
2962
2962
|
t.closePath();
|
|
2963
2963
|
}
|
|
2964
|
-
function
|
|
2964
|
+
function so(t, e, r) {
|
|
2965
2965
|
var n;
|
|
2966
2966
|
if (!((n = e.stroke) != null && n.enabled) || !e.transformData) return;
|
|
2967
2967
|
const o = (r == null ? void 0 : r.isKnockout) === !0;
|
|
2968
|
-
t.save(), o ? (t.strokeStyle = "#000000", t.lineWidth = e.stroke.width, t.lineCap = e.stroke.lineCap || "butt", t.lineJoin = e.stroke.lineJoin || "miter", t.globalAlpha = 1) : (t.strokeStyle = e.stroke.color, t.lineWidth = e.stroke.width, t.lineCap = e.stroke.lineCap || "butt", t.lineJoin = e.stroke.lineJoin || "miter", e.stroke.opacity !== void 0 && (t.globalAlpha = e.stroke.opacity)), e.stroke.miterLimit !== void 0 && (t.miterLimit = e.stroke.miterLimit), e.stroke.dashArray && e.stroke.dashArray.length > 0 && t.setLineDash(e.stroke.dashArray), !o && e.stroke.feather && e.stroke.feather > 0 && "filter" in t && (t.filter = `blur(${e.stroke.feather}px)`), t.beginPath(),
|
|
2968
|
+
t.save(), o ? (t.strokeStyle = "#000000", t.lineWidth = e.stroke.width, t.lineCap = e.stroke.lineCap || "butt", t.lineJoin = e.stroke.lineJoin || "miter", t.globalAlpha = 1) : (t.strokeStyle = e.stroke.color, t.lineWidth = e.stroke.width, t.lineCap = e.stroke.lineCap || "butt", t.lineJoin = e.stroke.lineJoin || "miter", e.stroke.opacity !== void 0 && (t.globalAlpha = e.stroke.opacity)), e.stroke.miterLimit !== void 0 && (t.miterLimit = e.stroke.miterLimit), e.stroke.dashArray && e.stroke.dashArray.length > 0 && t.setLineDash(e.stroke.dashArray), !o && e.stroke.feather && e.stroke.feather > 0 && "filter" in t && (t.filter = `blur(${e.stroke.feather}px)`), t.beginPath(), Nt(t, e.transformData), t.stroke(), t.restore();
|
|
2969
2969
|
}
|
|
2970
|
-
function
|
|
2970
|
+
function ao(t, e) {
|
|
2971
2971
|
if (!e.transformData) return;
|
|
2972
2972
|
const { borderRadius: r } = e.transformData, o = e.transformData.width ?? 100, n = e.transformData.height ?? 100, a = -o / 2, s = -n / 2;
|
|
2973
2973
|
if (t.beginPath(), r && r > 0) {
|
|
@@ -2976,7 +2976,7 @@ function so(t, e) {
|
|
|
2976
2976
|
} else
|
|
2977
2977
|
t.rect(a, s, o, n);
|
|
2978
2978
|
}
|
|
2979
|
-
function
|
|
2979
|
+
function _t(t, e, r, o, n, a, s = "destination-out") {
|
|
2980
2980
|
var v;
|
|
2981
2981
|
if (!e.knockoutParts) return;
|
|
2982
2982
|
if (!(e.knockoutParts.fill || e.knockoutParts.stroke)) {
|
|
@@ -2985,16 +2985,16 @@ function Nt(t, e, r, o, n, a, s = "destination-out") {
|
|
|
2985
2985
|
}
|
|
2986
2986
|
const i = t.getTransform();
|
|
2987
2987
|
t.save();
|
|
2988
|
-
const l = e.knockoutParts.scope || "group", d =
|
|
2988
|
+
const l = e.knockoutParts.scope || "group", d = io(e, l, r);
|
|
2989
2989
|
if (d.length === 0 && l === "artboard") {
|
|
2990
|
-
|
|
2990
|
+
lo(t, e, o), t.restore();
|
|
2991
2991
|
return;
|
|
2992
2992
|
}
|
|
2993
2993
|
if (d.length === 0) {
|
|
2994
2994
|
o(t, e), t.restore();
|
|
2995
2995
|
return;
|
|
2996
2996
|
}
|
|
2997
|
-
const h = t.canvas, f = t.getTransform().a, p =
|
|
2997
|
+
const h = t.canvas, f = t.getTransform().a, p = ho(h.width, h.height), u = p.getContext("2d");
|
|
2998
2998
|
if (!u) return;
|
|
2999
2999
|
u.scale(f, f), n && a && (u.fillStyle = n, u.fillRect(a.x, a.y, a.width, a.height));
|
|
3000
3000
|
for (const m of d)
|
|
@@ -3012,31 +3012,31 @@ function Nt(t, e, r, o, n, a, s = "destination-out") {
|
|
|
3012
3012
|
i.f
|
|
3013
3013
|
);
|
|
3014
3014
|
}
|
|
3015
|
-
function
|
|
3016
|
-
|
|
3015
|
+
function bn(t, e, r, o, n, a) {
|
|
3016
|
+
_t(t, e, r, o, n, a, "destination-out");
|
|
3017
3017
|
}
|
|
3018
|
-
function
|
|
3019
|
-
return e === "artboard" ?
|
|
3018
|
+
function io(t, e, r) {
|
|
3019
|
+
return e === "artboard" ? jt(t, r) : co(t, r);
|
|
3020
3020
|
}
|
|
3021
|
-
function
|
|
3021
|
+
function jt(t, e) {
|
|
3022
3022
|
const r = e.findIndex((o) => o.id === t.id);
|
|
3023
3023
|
return r === -1 ? [] : e.slice(0, r);
|
|
3024
3024
|
}
|
|
3025
|
-
function
|
|
3026
|
-
const r =
|
|
3025
|
+
function co(t, e) {
|
|
3026
|
+
const r = Xt(t, e);
|
|
3027
3027
|
if (!r)
|
|
3028
|
-
return
|
|
3028
|
+
return jt(t, e);
|
|
3029
3029
|
if (r.transformType !== "group" || !r.children)
|
|
3030
3030
|
return [];
|
|
3031
3031
|
const o = r.children.findIndex((n) => n.id === t.id);
|
|
3032
3032
|
return o === -1 ? [] : r.children.slice(0, o);
|
|
3033
3033
|
}
|
|
3034
|
-
function
|
|
3034
|
+
function Xt(t, e) {
|
|
3035
3035
|
for (const r of e)
|
|
3036
3036
|
if (r.transformType === "group" && r.children) {
|
|
3037
3037
|
if (r.children.some((n) => n.id === t.id))
|
|
3038
3038
|
return r;
|
|
3039
|
-
const o =
|
|
3039
|
+
const o = Xt(t, r.children);
|
|
3040
3040
|
if (o)
|
|
3041
3041
|
return o;
|
|
3042
3042
|
}
|
|
@@ -3055,7 +3055,7 @@ function He(t, e) {
|
|
|
3055
3055
|
renderingContext: { isKnockout: !0 }
|
|
3056
3056
|
});
|
|
3057
3057
|
}
|
|
3058
|
-
function
|
|
3058
|
+
function lo(t, e, r) {
|
|
3059
3059
|
var n;
|
|
3060
3060
|
const o = e.knockoutParts;
|
|
3061
3061
|
if (!o) {
|
|
@@ -3064,7 +3064,7 @@ function co(t, e, r) {
|
|
|
3064
3064
|
}
|
|
3065
3065
|
o.fill || (t.save(), qe(t, e), t.restore()), !o.stroke && ((n = e.stroke) != null && n.enabled) && (t.save(), He(t, e), t.restore());
|
|
3066
3066
|
}
|
|
3067
|
-
function
|
|
3067
|
+
function ho(t, e) {
|
|
3068
3068
|
if (typeof OffscreenCanvas < "u")
|
|
3069
3069
|
return new OffscreenCanvas(t, e);
|
|
3070
3070
|
if (typeof document < "u") {
|
|
@@ -3084,10 +3084,10 @@ function ht(t, e, r, o, n = 0) {
|
|
|
3084
3084
|
};
|
|
3085
3085
|
}
|
|
3086
3086
|
const ne = 64, Ie = 512;
|
|
3087
|
-
function
|
|
3087
|
+
function go(t, e) {
|
|
3088
3088
|
t.beginPath(), t.arc(e / 2, e / 2, e * 0.45, 0, Math.PI * 2), t.fill();
|
|
3089
3089
|
}
|
|
3090
|
-
function
|
|
3090
|
+
function fo(t, e) {
|
|
3091
3091
|
const r = e / 2, o = e / 2, n = e * 0.45, a = n * 0.4, s = 5;
|
|
3092
3092
|
t.beginPath();
|
|
3093
3093
|
for (let c = 0; c < s * 2; c++) {
|
|
@@ -3096,15 +3096,15 @@ function go(t, e) {
|
|
|
3096
3096
|
}
|
|
3097
3097
|
t.closePath(), t.fill();
|
|
3098
3098
|
}
|
|
3099
|
-
function
|
|
3099
|
+
function uo(t, e) {
|
|
3100
3100
|
const r = e / 2, o = e * 0.42;
|
|
3101
3101
|
t.beginPath(), t.moveTo(r, e * 0.82), t.bezierCurveTo(r - o * 1.1, e * 0.6, r - o * 1.3, e * 0.2, r, e * 0.35), t.bezierCurveTo(r + o * 1.3, e * 0.2, r + o * 1.1, e * 0.6, r, e * 0.82), t.closePath(), t.fill();
|
|
3102
3102
|
}
|
|
3103
|
-
function
|
|
3103
|
+
function po(t, e) {
|
|
3104
3104
|
const r = e / 2, o = e / 2, n = e * 0.4, a = e * 0.48;
|
|
3105
3105
|
t.beginPath(), t.moveTo(r, o - a), t.lineTo(r + n, o), t.lineTo(r, o + a), t.lineTo(r - n, o), t.closePath(), t.fill();
|
|
3106
3106
|
}
|
|
3107
|
-
function
|
|
3107
|
+
function mo(t, e) {
|
|
3108
3108
|
const r = e / 2, o = e / 2, n = e * 0.44;
|
|
3109
3109
|
t.beginPath();
|
|
3110
3110
|
for (let a = 0; a < 6; a++) {
|
|
@@ -3113,11 +3113,11 @@ function po(t, e) {
|
|
|
3113
3113
|
}
|
|
3114
3114
|
t.closePath(), t.fill();
|
|
3115
3115
|
}
|
|
3116
|
-
function
|
|
3116
|
+
function yo(t, e) {
|
|
3117
3117
|
const r = e / 2, o = e * 0.4, n = e * 0.12;
|
|
3118
3118
|
t.beginPath(), t.moveTo(r, n), t.lineTo(r + o, e * 0.25), t.lineTo(r + o, e * 0.55), t.quadraticCurveTo(r + o * 0.3, e * 0.8, r, e * 0.9), t.quadraticCurveTo(r - o * 0.3, e * 0.8, r - o, e * 0.55), t.lineTo(r - o, e * 0.25), t.closePath(), t.fill();
|
|
3119
3119
|
}
|
|
3120
|
-
function
|
|
3120
|
+
function wo(t, e) {
|
|
3121
3121
|
const r = e / 2, o = e / 2;
|
|
3122
3122
|
let n = 42;
|
|
3123
3123
|
const a = () => (n = (n * 16807 + 0) % 2147483647, n / 2147483647);
|
|
@@ -3127,7 +3127,7 @@ function yo(t, e) {
|
|
|
3127
3127
|
t.beginPath(), t.arc(r + Math.cos(c) * i, o + Math.sin(c) * i, l, 0, Math.PI * 2), t.fill();
|
|
3128
3128
|
}
|
|
3129
3129
|
}
|
|
3130
|
-
function
|
|
3130
|
+
function bo(t, e) {
|
|
3131
3131
|
let r = 123;
|
|
3132
3132
|
const o = () => (r = (r * 16807 + 0) % 2147483647, r / 2147483647), n = e * 0.08, a = 40;
|
|
3133
3133
|
t.beginPath(), t.moveTo(n, n);
|
|
@@ -3149,7 +3149,7 @@ function wo(t, e) {
|
|
|
3149
3149
|
}
|
|
3150
3150
|
t.closePath(), t.fill();
|
|
3151
3151
|
}
|
|
3152
|
-
function
|
|
3152
|
+
function ko(t, e) {
|
|
3153
3153
|
let r = 77;
|
|
3154
3154
|
const o = () => (r = (r * 16807 + 0) % 2147483647, r / 2147483647), n = e * 0.25, a = e * 0.75, s = e * 0.1;
|
|
3155
3155
|
t.beginPath(), t.moveTo(s, n + o() * e * 0.05);
|
|
@@ -3163,23 +3163,23 @@ function bo(t, e) {
|
|
|
3163
3163
|
}
|
|
3164
3164
|
t.closePath(), t.fill();
|
|
3165
3165
|
}
|
|
3166
|
-
function
|
|
3166
|
+
function vo(t, e) {
|
|
3167
3167
|
const r = e / 2, o = e * 0.55;
|
|
3168
3168
|
t.beginPath(), t.arc(r, o, e * 0.2, 0, Math.PI * 2), t.fill(), t.beginPath(), t.arc(r - e * 0.18, o + e * 0.02, e * 0.15, 0, Math.PI * 2), t.fill(), t.beginPath(), t.arc(r + e * 0.18, o + e * 0.02, e * 0.16, 0, Math.PI * 2), t.fill(), t.beginPath(), t.arc(r - e * 0.06, o - e * 0.14, e * 0.14, 0, Math.PI * 2), t.fill(), t.beginPath(), t.arc(r + e * 0.1, o - e * 0.12, e * 0.12, 0, Math.PI * 2), t.fill();
|
|
3169
3169
|
}
|
|
3170
|
-
const
|
|
3170
|
+
const To = [
|
|
3171
3171
|
// Geometric
|
|
3172
|
-
{ id: "circle", name: "Circle", description: "Perfect circle", imageUrl: "builtin-mask:circle", thumbnailUrl: "", category: "geometric", draw:
|
|
3173
|
-
{ id: "star", name: "Star", description: "5-pointed star", imageUrl: "builtin-mask:star", thumbnailUrl: "", category: "geometric", draw:
|
|
3174
|
-
{ id: "heart", name: "Heart", description: "Heart shape", imageUrl: "builtin-mask:heart", thumbnailUrl: "", category: "geometric", draw:
|
|
3175
|
-
{ id: "diamond", name: "Diamond", description: "Diamond/rhombus", imageUrl: "builtin-mask:diamond", thumbnailUrl: "", category: "geometric", draw:
|
|
3176
|
-
{ id: "hexagon", name: "Hexagon", description: "Regular hexagon", imageUrl: "builtin-mask:hexagon", thumbnailUrl: "", category: "geometric", draw:
|
|
3177
|
-
{ id: "shield", name: "Shield", description: "Shield/crest shape", imageUrl: "builtin-mask:shield", thumbnailUrl: "", category: "geometric", draw:
|
|
3172
|
+
{ id: "circle", name: "Circle", description: "Perfect circle", imageUrl: "builtin-mask:circle", thumbnailUrl: "", category: "geometric", draw: go },
|
|
3173
|
+
{ id: "star", name: "Star", description: "5-pointed star", imageUrl: "builtin-mask:star", thumbnailUrl: "", category: "geometric", draw: fo },
|
|
3174
|
+
{ id: "heart", name: "Heart", description: "Heart shape", imageUrl: "builtin-mask:heart", thumbnailUrl: "", category: "geometric", draw: uo },
|
|
3175
|
+
{ id: "diamond", name: "Diamond", description: "Diamond/rhombus", imageUrl: "builtin-mask:diamond", thumbnailUrl: "", category: "geometric", draw: po },
|
|
3176
|
+
{ id: "hexagon", name: "Hexagon", description: "Regular hexagon", imageUrl: "builtin-mask:hexagon", thumbnailUrl: "", category: "geometric", draw: mo },
|
|
3177
|
+
{ id: "shield", name: "Shield", description: "Shield/crest shape", imageUrl: "builtin-mask:shield", thumbnailUrl: "", category: "geometric", draw: yo },
|
|
3178
3178
|
// Organic
|
|
3179
|
-
{ id: "splatter", name: "Splatter", description: "Ink splatter", imageUrl: "builtin-mask:splatter", thumbnailUrl: "", category: "organic", draw:
|
|
3180
|
-
{ id: "torn-edge", name: "Torn Edge", description: "Rough torn paper edge", imageUrl: "builtin-mask:torn-edge", thumbnailUrl: "", category: "organic", draw:
|
|
3181
|
-
{ id: "paint-stroke", name: "Paint Stroke", description: "Horizontal brush stroke", imageUrl: "builtin-mask:paint-stroke", thumbnailUrl: "", category: "organic", draw:
|
|
3182
|
-
{ id: "cloud", name: "Cloud", description: "Soft cloud shape", imageUrl: "builtin-mask:cloud", thumbnailUrl: "", category: "organic", draw:
|
|
3179
|
+
{ id: "splatter", name: "Splatter", description: "Ink splatter", imageUrl: "builtin-mask:splatter", thumbnailUrl: "", category: "organic", draw: wo },
|
|
3180
|
+
{ id: "torn-edge", name: "Torn Edge", description: "Rough torn paper edge", imageUrl: "builtin-mask:torn-edge", thumbnailUrl: "", category: "organic", draw: bo },
|
|
3181
|
+
{ id: "paint-stroke", name: "Paint Stroke", description: "Horizontal brush stroke", imageUrl: "builtin-mask:paint-stroke", thumbnailUrl: "", category: "organic", draw: ko },
|
|
3182
|
+
{ id: "cloud", name: "Cloud", description: "Soft cloud shape", imageUrl: "builtin-mask:cloud", thumbnailUrl: "", category: "organic", draw: vo }
|
|
3183
3183
|
];
|
|
3184
3184
|
let gt = !1;
|
|
3185
3185
|
function ft(t, e) {
|
|
@@ -3187,11 +3187,11 @@ function ft(t, e) {
|
|
|
3187
3187
|
const r = document.createElement("canvas");
|
|
3188
3188
|
return r.width = t, r.height = e, r;
|
|
3189
3189
|
}
|
|
3190
|
-
function
|
|
3190
|
+
function So() {
|
|
3191
3191
|
if (typeof document > "u" || gt) return;
|
|
3192
3192
|
gt = !0;
|
|
3193
3193
|
const t = Se.getInstance();
|
|
3194
|
-
for (const e of
|
|
3194
|
+
for (const e of To) {
|
|
3195
3195
|
const r = ft(Ie, Ie);
|
|
3196
3196
|
if (!r) continue;
|
|
3197
3197
|
const o = r.getContext("2d");
|
|
@@ -3206,14 +3206,14 @@ function To() {
|
|
|
3206
3206
|
}
|
|
3207
3207
|
}
|
|
3208
3208
|
}
|
|
3209
|
-
const
|
|
3210
|
-
function
|
|
3209
|
+
const Fo = H("MaskRenderer"), Ge = /* @__PURE__ */ new Map(), Co = /* @__PURE__ */ new Map();
|
|
3210
|
+
function kn(t) {
|
|
3211
3211
|
const e = [];
|
|
3212
3212
|
Ge.forEach((r, o) => {
|
|
3213
3213
|
o.startsWith(t) && e.push(o);
|
|
3214
3214
|
}), e.forEach((r) => Ge.delete(r));
|
|
3215
3215
|
}
|
|
3216
|
-
function
|
|
3216
|
+
function vn() {
|
|
3217
3217
|
Ge.clear();
|
|
3218
3218
|
}
|
|
3219
3219
|
function ut(t, e, r) {
|
|
@@ -3223,38 +3223,38 @@ function ut(t, e, r) {
|
|
|
3223
3223
|
}
|
|
3224
3224
|
const o = t.canvas, n = ye(o.width, o.height), a = n.getContext("2d");
|
|
3225
3225
|
if (!a) {
|
|
3226
|
-
|
|
3226
|
+
Fo.error("[renderWithMasks] Failed to get offscreen context");
|
|
3227
3227
|
return;
|
|
3228
3228
|
}
|
|
3229
3229
|
const s = t.getTransform();
|
|
3230
3230
|
a.setTransform(s), r(a);
|
|
3231
3231
|
for (const c of e.masks)
|
|
3232
|
-
|
|
3232
|
+
Mo(a, c, e);
|
|
3233
3233
|
t.save(), t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(n, 0, 0), t.restore();
|
|
3234
3234
|
}
|
|
3235
|
-
function
|
|
3235
|
+
function Mo(t, e, r) {
|
|
3236
3236
|
switch (e.type) {
|
|
3237
3237
|
case "clip":
|
|
3238
|
-
|
|
3238
|
+
Eo(t, e, r);
|
|
3239
3239
|
break;
|
|
3240
3240
|
case "alpha":
|
|
3241
|
-
|
|
3241
|
+
Po(t, e, r);
|
|
3242
3242
|
break;
|
|
3243
3243
|
case "luma":
|
|
3244
|
-
|
|
3244
|
+
Io(t, e, r);
|
|
3245
3245
|
break;
|
|
3246
3246
|
case "distress":
|
|
3247
|
-
|
|
3247
|
+
Ao(t, e, r);
|
|
3248
3248
|
break;
|
|
3249
3249
|
}
|
|
3250
3250
|
}
|
|
3251
|
-
function Mo(t, e, r) {
|
|
3252
|
-
t.save(), t.globalCompositeOperation = e.inverted ? "destination-out" : "destination-in", e.opacity !== void 0 && (t.globalAlpha = e.opacity), Fe(t, e.maskElement, r), t.restore();
|
|
3253
|
-
}
|
|
3254
3251
|
function Eo(t, e, r) {
|
|
3255
|
-
t.save(), t.globalCompositeOperation = e.inverted ? "destination-out" : "destination-in", e.opacity !== void 0 && (t.globalAlpha = e.opacity), Fe(t, e.maskElement, r),
|
|
3252
|
+
t.save(), t.globalCompositeOperation = e.inverted ? "destination-out" : "destination-in", e.opacity !== void 0 && (t.globalAlpha = e.opacity), Fe(t, e.maskElement, r), t.restore();
|
|
3256
3253
|
}
|
|
3257
3254
|
function Po(t, e, r) {
|
|
3255
|
+
t.save(), t.globalCompositeOperation = e.inverted ? "destination-out" : "destination-in", e.opacity !== void 0 && (t.globalAlpha = e.opacity), Fe(t, e.maskElement, r), e.feather && e.feather > 0 && Yt(t, e.feather), t.restore();
|
|
3256
|
+
}
|
|
3257
|
+
function Io(t, e, r) {
|
|
3258
3258
|
const o = ye(t.canvas.width, t.canvas.height), n = o.getContext("2d");
|
|
3259
3259
|
if (!n) return;
|
|
3260
3260
|
Fe(n, e.maskElement, r);
|
|
@@ -3265,11 +3265,11 @@ function Po(t, e, r) {
|
|
|
3265
3265
|
}
|
|
3266
3266
|
n.putImageData(a, 0, 0), t.save(), t.globalCompositeOperation = "destination-in", e.opacity !== void 0 && (t.globalAlpha = e.opacity), t.drawImage(o, 0, 0), t.restore();
|
|
3267
3267
|
}
|
|
3268
|
-
function
|
|
3269
|
-
t.save(), t.globalCompositeOperation = e.inverted ? "destination-in" : "destination-out", e.opacity !== void 0 && (t.globalAlpha = e.opacity), Fe(t, e.maskElement, r), e.feather && e.feather > 0 &&
|
|
3268
|
+
function Ao(t, e, r) {
|
|
3269
|
+
t.save(), t.globalCompositeOperation = e.inverted ? "destination-in" : "destination-out", e.opacity !== void 0 && (t.globalAlpha = e.opacity), Fe(t, e.maskElement, r), e.feather && e.feather > 0 && Yt(t, e.feather), t.restore();
|
|
3270
3270
|
}
|
|
3271
|
-
function
|
|
3272
|
-
const e = t.transformData, r = t, o = e && e.type === "image" ?
|
|
3271
|
+
function Ro(t) {
|
|
3272
|
+
const e = t.transformData, r = t, o = e && e.type === "image" ? br(e, At(t)) : null;
|
|
3273
3273
|
return {
|
|
3274
3274
|
width: (o == null ? void 0 : o.width) || (e == null ? void 0 : e.width) || r.width || 0,
|
|
3275
3275
|
height: (o == null ? void 0 : o.height) || (e == null ? void 0 : e.height) || r.height || 0
|
|
@@ -3282,7 +3282,7 @@ function Fe(t, e, r) {
|
|
|
3282
3282
|
y: n + s,
|
|
3283
3283
|
// Inherit parent rotation so mask rotates with the element
|
|
3284
3284
|
rotation: (e.rotation || 0) + (r.rotation || 0)
|
|
3285
|
-
}, i = 4, { width: l, height: d } =
|
|
3285
|
+
}, i = 4, { width: l, height: d } = Ro(r), h = e.transformData;
|
|
3286
3286
|
l && d && h && (c.transformData = {
|
|
3287
3287
|
...h,
|
|
3288
3288
|
width: l + i,
|
|
@@ -3293,11 +3293,11 @@ function Fe(t, e, r) {
|
|
|
3293
3293
|
const b = e;
|
|
3294
3294
|
if (b.imageUrl)
|
|
3295
3295
|
if (typeof document < "u") {
|
|
3296
|
-
b.imageUrl.startsWith("builtin-mask:") &&
|
|
3296
|
+
b.imageUrl.startsWith("builtin-mask:") && So();
|
|
3297
3297
|
const v = Se.getInstance(), m = v.acquire(b.imageUrl);
|
|
3298
3298
|
m.complete && m.naturalWidth > 0 && (g = m), v.release(b.imageUrl);
|
|
3299
3299
|
} else
|
|
3300
|
-
f =
|
|
3300
|
+
f = Co.get(b.imageUrl);
|
|
3301
3301
|
}
|
|
3302
3302
|
const p = c.transformData, u = (h == null ? void 0 : h.width) || 0, y = (h == null ? void 0 : h.height) || 0, k = u > 0 && y > 0 && l > 0 && d > 0 && Math.abs(u / y - l / d) > 1e-3;
|
|
3303
3303
|
if (f) {
|
|
@@ -3327,7 +3327,7 @@ function Fe(t, e, r) {
|
|
|
3327
3327
|
} else
|
|
3328
3328
|
et(t, c, { mode: "both", loadedImage: g });
|
|
3329
3329
|
}
|
|
3330
|
-
function
|
|
3330
|
+
function Yt(t, e) {
|
|
3331
3331
|
"filter" in t && (t.filter = `blur(${e}px)`);
|
|
3332
3332
|
}
|
|
3333
3333
|
function ye(t, e) {
|
|
@@ -3339,7 +3339,7 @@ function ye(t, e) {
|
|
|
3339
3339
|
}
|
|
3340
3340
|
throw new Error("No canvas context available");
|
|
3341
3341
|
}
|
|
3342
|
-
function
|
|
3342
|
+
function Bo(t, e, r, o) {
|
|
3343
3343
|
if (!e.enabled || !e.imageUrl || e.opacity <= 0) return;
|
|
3344
3344
|
const n = Se.getInstance(), a = n.acquire(e.imageUrl);
|
|
3345
3345
|
if (!a.complete || a.naturalWidth === 0) {
|
|
@@ -3383,31 +3383,31 @@ function Ro(t, e, r, o) {
|
|
|
3383
3383
|
b.globalCompositeOperation = v, b.globalAlpha = e.opacity / 100, b.drawImage(a, 0, 0, u, y);
|
|
3384
3384
|
b.globalCompositeOperation = "source-over", b.globalAlpha = 1, t.save(), t.setTransform(1, 0, 0, 1, 0, 0), t.clearRect(h, g, f, p), o && (t.fillStyle = o, t.fillRect(h, g, f, p)), t.drawImage(k, h, g), t.restore(), n.release(e.imageUrl);
|
|
3385
3385
|
}
|
|
3386
|
-
function
|
|
3386
|
+
function Wo(t) {
|
|
3387
3387
|
var e;
|
|
3388
|
-
return t ? ((e = t.shadow) == null ? void 0 : e.enabled) === !0 ||
|
|
3388
|
+
return t ? ((e = t.shadow) == null ? void 0 : e.enabled) === !0 || It(t.blendMode) : !1;
|
|
3389
3389
|
}
|
|
3390
|
-
function
|
|
3390
|
+
function Uo(t, e, r) {
|
|
3391
3391
|
var l;
|
|
3392
|
-
if (!
|
|
3392
|
+
if (!Wo(e)) {
|
|
3393
3393
|
r(t);
|
|
3394
3394
|
return;
|
|
3395
3395
|
}
|
|
3396
|
-
const o = (l = e.shadow) != null && l.enabled ? e.shadow : void 0, n =
|
|
3396
|
+
const o = (l = e.shadow) != null && l.enabled ? e.shadow : void 0, n = It(e.blendMode) ? e.blendMode : void 0, a = t.canvas, s = t.getTransform(), c = Lo(a.width, a.height), i = c.getContext("2d");
|
|
3397
3397
|
if (!i)
|
|
3398
3398
|
throw new Error(
|
|
3399
3399
|
"[canvas] renderWithLayerEffects: could not acquire a 2D context for the layer-effects raster"
|
|
3400
3400
|
);
|
|
3401
3401
|
if (i.setTransform(s), r(i), t.save(), t.setTransform(1, 0, 0, 1, 0, 0), n && (t.globalCompositeOperation = n), o) {
|
|
3402
3402
|
const d = Math.hypot(s.a, s.b) || 1, h = a.width + 1;
|
|
3403
|
-
t.save(), t.globalAlpha = t.globalAlpha *
|
|
3403
|
+
t.save(), t.globalAlpha = t.globalAlpha * Oo(o.opacity ?? 1), t.shadowColor = o.color, t.shadowBlur = o.blur * d, t.shadowOffsetX = o.offsetX * d + h, t.shadowOffsetY = o.offsetY * d, t.drawImage(c, -h, 0), t.restore();
|
|
3404
3404
|
}
|
|
3405
3405
|
t.drawImage(c, 0, 0), t.restore();
|
|
3406
3406
|
}
|
|
3407
|
-
function
|
|
3407
|
+
function Oo(t) {
|
|
3408
3408
|
return Math.min(1, Math.max(0, t));
|
|
3409
3409
|
}
|
|
3410
|
-
function
|
|
3410
|
+
function Lo(t, e) {
|
|
3411
3411
|
if (typeof OffscreenCanvas < "u")
|
|
3412
3412
|
return new OffscreenCanvas(t, e);
|
|
3413
3413
|
if (typeof document < "u") {
|
|
@@ -3416,7 +3416,7 @@ function Oo(t, e) {
|
|
|
3416
3416
|
}
|
|
3417
3417
|
throw new Error("No canvas context available");
|
|
3418
3418
|
}
|
|
3419
|
-
class
|
|
3419
|
+
class $o {
|
|
3420
3420
|
constructor(e = Math.random()) {
|
|
3421
3421
|
this.perm = [];
|
|
3422
3422
|
for (let o = 0; o < 256; o++)
|
|
@@ -3455,7 +3455,7 @@ class Lo {
|
|
|
3455
3455
|
}
|
|
3456
3456
|
}
|
|
3457
3457
|
function Ae(t, e, r, o = Date.now()) {
|
|
3458
|
-
const s = Ce(t, e).getContext("2d").createImageData(t, e), c = s.data, i = new
|
|
3458
|
+
const s = Ce(t, e).getContext("2d").createImageData(t, e), c = s.data, i = new $o(o), l = 0.02, d = 1 - r / 100;
|
|
3459
3459
|
for (let h = 0; h < e; h++)
|
|
3460
3460
|
for (let g = 0; g < t; g++) {
|
|
3461
3461
|
const f = (h * t + g) * 4;
|
|
@@ -3468,7 +3468,7 @@ function Ae(t, e, r, o = Date.now()) {
|
|
|
3468
3468
|
}
|
|
3469
3469
|
return s;
|
|
3470
3470
|
}
|
|
3471
|
-
function
|
|
3471
|
+
function qo(t, e, r, o = Date.now()) {
|
|
3472
3472
|
const a = Ce(t, e).getContext("2d");
|
|
3473
3473
|
a.clearRect(0, 0, t, e), a.strokeStyle = "#000000", a.lineWidth = 1 + r / 50, a.lineCap = "round";
|
|
3474
3474
|
const s = tt(o), c = Math.floor(r / 100 * 30 + 5);
|
|
@@ -3490,7 +3490,7 @@ function Ne(t, e, r, o, n, a, s) {
|
|
|
3490
3490
|
Ne(t, c, i, l, n * 0.6, a, s + 1);
|
|
3491
3491
|
}
|
|
3492
3492
|
}
|
|
3493
|
-
function
|
|
3493
|
+
function pe(t, e, r, o = Date.now()) {
|
|
3494
3494
|
const s = Ce(t, e).getContext("2d").createImageData(t, e), c = s.data, i = tt(o), l = r / 100 * 0.5;
|
|
3495
3495
|
for (let d = 0; d < e; d++)
|
|
3496
3496
|
for (let h = 0; h < t; h++) {
|
|
@@ -3499,7 +3499,7 @@ function ue(t, e, r, o = Date.now()) {
|
|
|
3499
3499
|
}
|
|
3500
3500
|
return s;
|
|
3501
3501
|
}
|
|
3502
|
-
function
|
|
3502
|
+
function Ho(t, e, r, o = Date.now()) {
|
|
3503
3503
|
const a = Ce(t, e).getContext("2d");
|
|
3504
3504
|
a.fillStyle = "#000000";
|
|
3505
3505
|
const s = tt(o), c = 4 + r / 100 * 6, i = c * 2;
|
|
@@ -3531,20 +3531,20 @@ function _e(t) {
|
|
|
3531
3531
|
e[r] = 255, e[r + 1] = 255, e[r + 2] = 255;
|
|
3532
3532
|
return t;
|
|
3533
3533
|
}
|
|
3534
|
-
function
|
|
3534
|
+
function Go(t, e) {
|
|
3535
3535
|
const r = t.data, o = e.data;
|
|
3536
3536
|
for (let n = 0; n < r.length; n += 4)
|
|
3537
3537
|
r[n] = 255, r[n + 1] = 255, r[n + 2] = 255, r[n + 3] = Math.min(255, r[n + 3] + o[n + 3]);
|
|
3538
3538
|
return t;
|
|
3539
3539
|
}
|
|
3540
|
-
const
|
|
3540
|
+
const No = [
|
|
3541
3541
|
{
|
|
3542
3542
|
id: "grunge-heavy",
|
|
3543
3543
|
name: "Heavy Grunge",
|
|
3544
3544
|
textureUrl: "builtin:grunge-heavy",
|
|
3545
3545
|
thumbnailUrl: "",
|
|
3546
3546
|
description: "Dense random splatters",
|
|
3547
|
-
generate: (t, e) =>
|
|
3547
|
+
generate: (t, e) => pe(t, e, 80, G)
|
|
3548
3548
|
},
|
|
3549
3549
|
{
|
|
3550
3550
|
id: "grunge-fine",
|
|
@@ -3552,7 +3552,7 @@ const Go = [
|
|
|
3552
3552
|
textureUrl: "builtin:grunge-fine",
|
|
3553
3553
|
thumbnailUrl: "",
|
|
3554
3554
|
description: "Sparse fine grain",
|
|
3555
|
-
generate: (t, e) =>
|
|
3555
|
+
generate: (t, e) => pe(t, e, 25, G + 1)
|
|
3556
3556
|
},
|
|
3557
3557
|
{
|
|
3558
3558
|
id: "concrete",
|
|
@@ -3577,8 +3577,8 @@ const Go = [
|
|
|
3577
3577
|
thumbnailUrl: "",
|
|
3578
3578
|
description: "Noise + splatter combined",
|
|
3579
3579
|
generate: (t, e) => {
|
|
3580
|
-
const r = Ae(t, e, 45, G + 4), o =
|
|
3581
|
-
return
|
|
3580
|
+
const r = Ae(t, e, 45, G + 4), o = pe(t, e, 35, G + 5);
|
|
3581
|
+
return Go(_e(r), _e(o));
|
|
3582
3582
|
}
|
|
3583
3583
|
},
|
|
3584
3584
|
{
|
|
@@ -3587,7 +3587,7 @@ const Go = [
|
|
|
3587
3587
|
textureUrl: "builtin:scratches",
|
|
3588
3588
|
thumbnailUrl: "",
|
|
3589
3589
|
description: "Branching crack lines",
|
|
3590
|
-
generate: (t, e) =>
|
|
3590
|
+
generate: (t, e) => qo(t, e, 55, G + 6)
|
|
3591
3591
|
},
|
|
3592
3592
|
{
|
|
3593
3593
|
id: "halftone",
|
|
@@ -3595,7 +3595,7 @@ const Go = [
|
|
|
3595
3595
|
textureUrl: "builtin:halftone",
|
|
3596
3596
|
thumbnailUrl: "",
|
|
3597
3597
|
description: "Dot grid pattern",
|
|
3598
|
-
generate: (t, e) =>
|
|
3598
|
+
generate: (t, e) => Ho(t, e, 55, G + 7)
|
|
3599
3599
|
},
|
|
3600
3600
|
{
|
|
3601
3601
|
id: "spray",
|
|
@@ -3603,11 +3603,11 @@ const Go = [
|
|
|
3603
3603
|
textureUrl: "builtin:spray",
|
|
3604
3604
|
thumbnailUrl: "",
|
|
3605
3605
|
description: "Medium random splatter",
|
|
3606
|
-
generate: (t, e) =>
|
|
3606
|
+
generate: (t, e) => pe(t, e, 55, G + 8)
|
|
3607
3607
|
}
|
|
3608
3608
|
];
|
|
3609
3609
|
let pt = !1;
|
|
3610
|
-
function
|
|
3610
|
+
function _o(t, e) {
|
|
3611
3611
|
if (typeof OffscreenCanvas < "u")
|
|
3612
3612
|
return new OffscreenCanvas(t, e);
|
|
3613
3613
|
const r = document.createElement("canvas");
|
|
@@ -3618,7 +3618,7 @@ function mt(t, e) {
|
|
|
3618
3618
|
const r = document.createElement("canvas");
|
|
3619
3619
|
return r.width = t, r.height = e, r;
|
|
3620
3620
|
}
|
|
3621
|
-
function
|
|
3621
|
+
function jo(t) {
|
|
3622
3622
|
const e = mt(t.width, t.height);
|
|
3623
3623
|
if (!e) return "";
|
|
3624
3624
|
const r = e.getContext("2d");
|
|
@@ -3636,14 +3636,14 @@ function _o(t) {
|
|
|
3636
3636
|
}
|
|
3637
3637
|
return n.putImageData(a, 0, 0), o.toDataURL("image/png");
|
|
3638
3638
|
}
|
|
3639
|
-
function
|
|
3639
|
+
function Xo() {
|
|
3640
3640
|
if (!pt) {
|
|
3641
3641
|
pt = !0;
|
|
3642
|
-
for (const t of
|
|
3642
|
+
for (const t of No) {
|
|
3643
3643
|
const e = t.generate(z, z);
|
|
3644
3644
|
_e(e);
|
|
3645
|
-
const r =
|
|
3646
|
-
o && (o.putImageData(e, 0, 0),
|
|
3645
|
+
const r = _o(z, z), o = r.getContext("2d");
|
|
3646
|
+
o && (o.putImageData(e, 0, 0), Yo(t.textureUrl, r, z, z)), typeof document < "u" && (t.thumbnailUrl = jo(e));
|
|
3647
3647
|
}
|
|
3648
3648
|
}
|
|
3649
3649
|
}
|
|
@@ -3674,30 +3674,30 @@ function Vt(t) {
|
|
|
3674
3674
|
const e = X.get(t);
|
|
3675
3675
|
if (e) return e;
|
|
3676
3676
|
if (t.startsWith("builtin:")) {
|
|
3677
|
-
|
|
3677
|
+
Xo();
|
|
3678
3678
|
const r = X.get(t);
|
|
3679
3679
|
return r || null;
|
|
3680
3680
|
}
|
|
3681
|
-
return j.has(t) || (j.add(t),
|
|
3681
|
+
return j.has(t) || (j.add(t), Dt(t)), null;
|
|
3682
3682
|
}
|
|
3683
|
-
function
|
|
3683
|
+
function Tn(t) {
|
|
3684
3684
|
return X.has(t) ? Promise.resolve() : new Promise((e) => {
|
|
3685
3685
|
if (X.has(t)) {
|
|
3686
3686
|
e();
|
|
3687
3687
|
return;
|
|
3688
3688
|
}
|
|
3689
3689
|
const r = we.get(t) || [];
|
|
3690
|
-
r.push(e), we.set(t, r), j.has(t) || (j.add(t),
|
|
3690
|
+
r.push(e), we.set(t, r), j.has(t) || (j.add(t), Dt(t));
|
|
3691
3691
|
});
|
|
3692
3692
|
}
|
|
3693
|
-
function
|
|
3693
|
+
function Yo(t, e, r, o) {
|
|
3694
3694
|
X.has(t) || (X.set(t, { alphaMask: e, width: r, height: o }), se(t));
|
|
3695
3695
|
}
|
|
3696
3696
|
function se(t) {
|
|
3697
3697
|
const e = we.get(t);
|
|
3698
3698
|
e && (e.forEach((r) => r()), we.delete(t));
|
|
3699
3699
|
}
|
|
3700
|
-
function
|
|
3700
|
+
function Dt(t) {
|
|
3701
3701
|
if (typeof document < "u") {
|
|
3702
3702
|
const e = new Image();
|
|
3703
3703
|
e.crossOrigin = "anonymous", e.onload = () => {
|
|
@@ -3714,7 +3714,7 @@ function Yt(t) {
|
|
|
3714
3714
|
j.delete(t), se(t);
|
|
3715
3715
|
});
|
|
3716
3716
|
}
|
|
3717
|
-
function
|
|
3717
|
+
function Kt(t, e) {
|
|
3718
3718
|
if (typeof OffscreenCanvas < "u")
|
|
3719
3719
|
return new OffscreenCanvas(t, e);
|
|
3720
3720
|
const r = document.createElement("canvas");
|
|
@@ -3726,7 +3726,7 @@ function Vo(t, e, r, o) {
|
|
|
3726
3726
|
if (!n) return;
|
|
3727
3727
|
const { x: a, y: s, width: c, height: i } = r, l = t.getTransform(), d = l.a * a + l.e, h = l.d * s + l.f, g = l.a * c, f = l.d * i, p = Math.ceil(g), u = Math.ceil(f);
|
|
3728
3728
|
if (p <= 0 || u <= 0) return;
|
|
3729
|
-
const y =
|
|
3729
|
+
const y = Kt(p, u), k = y.getContext("2d");
|
|
3730
3730
|
if (!k) return;
|
|
3731
3731
|
k.drawImage(
|
|
3732
3732
|
t.canvas,
|
|
@@ -3771,7 +3771,7 @@ function kt(t, e, r, o) {
|
|
|
3771
3771
|
o(t);
|
|
3772
3772
|
return;
|
|
3773
3773
|
}
|
|
3774
|
-
const m =
|
|
3774
|
+
const m = Kt(b, v), w = m.getContext("2d");
|
|
3775
3775
|
if (!w) {
|
|
3776
3776
|
o(t);
|
|
3777
3777
|
return;
|
|
@@ -3799,6 +3799,7 @@ function kt(t, e, r, o) {
|
|
|
3799
3799
|
w.globalCompositeOperation = "destination-out", w.globalAlpha = a, w.drawImage(n.alphaMask, 0, 0, b, v), w.globalCompositeOperation = "source-over", w.globalAlpha = 1;
|
|
3800
3800
|
t.save(), t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(m, p, u), t.restore();
|
|
3801
3801
|
}
|
|
3802
|
+
const vt = ["custom", "circle", "lean", "arch", "ascend", "wave", "flag", "image", "group", "shape", "path"];
|
|
3802
3803
|
class be {
|
|
3803
3804
|
/**
|
|
3804
3805
|
* Create an element instance from a JSON configuration
|
|
@@ -3812,21 +3813,25 @@ class be {
|
|
|
3812
3813
|
const { transformType: r } = e;
|
|
3813
3814
|
switch (r) {
|
|
3814
3815
|
case "custom":
|
|
3815
|
-
return new
|
|
3816
|
+
return new wr(e);
|
|
3816
3817
|
case "distort":
|
|
3817
|
-
throw new
|
|
3818
|
+
throw new de(
|
|
3819
|
+
"E_ELEMENT_TYPE_UNSUPPORTED",
|
|
3820
|
+
"'distort' is not an element type the editor can open: it was never implemented, and the design format (@snowcone-app/design) refuses it. Use a text transform that exists: " + vt.join(", ") + ".",
|
|
3821
|
+
{ received: "distort", validNames: vt }
|
|
3822
|
+
);
|
|
3818
3823
|
case "circle":
|
|
3819
|
-
return new
|
|
3824
|
+
return new yr(e);
|
|
3820
3825
|
case "lean":
|
|
3821
|
-
return new
|
|
3826
|
+
return new mr(e);
|
|
3822
3827
|
case "arch":
|
|
3823
|
-
return new
|
|
3828
|
+
return new pr(e);
|
|
3824
3829
|
case "ascend":
|
|
3825
|
-
return new
|
|
3830
|
+
return new ur(e);
|
|
3826
3831
|
case "wave":
|
|
3827
|
-
return new
|
|
3832
|
+
return new fr(e);
|
|
3828
3833
|
case "flag":
|
|
3829
|
-
return new
|
|
3834
|
+
return new gr(e);
|
|
3830
3835
|
case "image":
|
|
3831
3836
|
return new We(e);
|
|
3832
3837
|
case "group": {
|
|
@@ -3836,9 +3841,9 @@ class be {
|
|
|
3836
3841
|
return n.forEach((i) => c.addChild(i)), c;
|
|
3837
3842
|
}
|
|
3838
3843
|
case "shape":
|
|
3839
|
-
return new
|
|
3844
|
+
return new hr(e);
|
|
3840
3845
|
case "path":
|
|
3841
|
-
return new
|
|
3846
|
+
return new dr(e);
|
|
3842
3847
|
default:
|
|
3843
3848
|
const o = r;
|
|
3844
3849
|
throw new Error(`Unknown transform type: ${o}`);
|
|
@@ -4052,7 +4057,7 @@ class be {
|
|
|
4052
4057
|
return this.createFromJSON(r);
|
|
4053
4058
|
}
|
|
4054
4059
|
}
|
|
4055
|
-
const
|
|
4060
|
+
const Tt = H("ImportManager"), ot = class ot {
|
|
4056
4061
|
/**
|
|
4057
4062
|
* Import workspace from JSON file
|
|
4058
4063
|
*/
|
|
@@ -4080,7 +4085,7 @@ const vt = H("ImportManager"), ot = class ot {
|
|
|
4080
4085
|
try {
|
|
4081
4086
|
return be.createFromJSON(l);
|
|
4082
4087
|
} catch (d) {
|
|
4083
|
-
return
|
|
4088
|
+
return Tt.error("Failed to create element:", l, d), null;
|
|
4084
4089
|
}
|
|
4085
4090
|
}).filter((l) => l !== null);
|
|
4086
4091
|
n.push(c), a.push(...i);
|
|
@@ -4115,7 +4120,7 @@ const vt = H("ImportManager"), ot = class ot {
|
|
|
4115
4120
|
try {
|
|
4116
4121
|
return be.createFromJSON(i);
|
|
4117
4122
|
} catch (l) {
|
|
4118
|
-
return
|
|
4123
|
+
return Tt.error("Failed to create element:", i, l), null;
|
|
4119
4124
|
}
|
|
4120
4125
|
}).filter((i) => i !== null);
|
|
4121
4126
|
return c.forEach((i) => {
|
|
@@ -4267,13 +4272,13 @@ const vt = H("ImportManager"), ot = class ot {
|
|
|
4267
4272
|
}
|
|
4268
4273
|
};
|
|
4269
4274
|
ot.SUPPORTED_VERSIONS = ["1.0.0", "2.0.0"];
|
|
4270
|
-
let
|
|
4271
|
-
const
|
|
4272
|
-
function
|
|
4273
|
-
const r = e ?
|
|
4275
|
+
let St = ot;
|
|
4276
|
+
const Ft = H("element-serializer"), Jt = 4e3, ge = /* @__PURE__ */ new Set();
|
|
4277
|
+
function Do(t, e) {
|
|
4278
|
+
const r = e ? Ko(e) : "no-src";
|
|
4274
4279
|
return `${t}:${r}`;
|
|
4275
4280
|
}
|
|
4276
|
-
function
|
|
4281
|
+
function Ko(t) {
|
|
4277
4282
|
let e = 0;
|
|
4278
4283
|
for (let r = 0; r < t.length; r++) {
|
|
4279
4284
|
const o = t.charCodeAt(r);
|
|
@@ -4282,19 +4287,19 @@ function Do(t) {
|
|
|
4282
4287
|
return e.toString(36);
|
|
4283
4288
|
}
|
|
4284
4289
|
function je() {
|
|
4285
|
-
|
|
4290
|
+
ge.clear();
|
|
4286
4291
|
}
|
|
4287
|
-
function
|
|
4288
|
-
for (const e of
|
|
4289
|
-
e.startsWith(`${t}:`) &&
|
|
4290
|
-
}
|
|
4291
|
-
function Ko(t) {
|
|
4292
|
-
he.add(t);
|
|
4292
|
+
function Qt(t) {
|
|
4293
|
+
for (const e of ge)
|
|
4294
|
+
e.startsWith(`${t}:`) && ge.delete(e);
|
|
4293
4295
|
}
|
|
4294
4296
|
function Jo(t) {
|
|
4295
|
-
|
|
4297
|
+
ge.add(t);
|
|
4296
4298
|
}
|
|
4297
|
-
|
|
4299
|
+
function Qo(t) {
|
|
4300
|
+
return ge.has(t);
|
|
4301
|
+
}
|
|
4302
|
+
async function zo(t, e = Jt) {
|
|
4298
4303
|
const { naturalWidth: r, naturalHeight: o } = t;
|
|
4299
4304
|
if (r <= e && o <= e)
|
|
4300
4305
|
return createImageBitmap(t);
|
|
@@ -4306,17 +4311,17 @@ async function Qo(t, e = Kt) {
|
|
|
4306
4311
|
});
|
|
4307
4312
|
}
|
|
4308
4313
|
let ke = null, ve = null;
|
|
4309
|
-
function
|
|
4314
|
+
function xo(t, e) {
|
|
4310
4315
|
ke = t, ve = e;
|
|
4311
4316
|
}
|
|
4312
|
-
function
|
|
4317
|
+
function Zo() {
|
|
4313
4318
|
ke = null, ve = null;
|
|
4314
4319
|
}
|
|
4315
|
-
function
|
|
4320
|
+
function Sn() {
|
|
4316
4321
|
je(), ke && ke();
|
|
4317
4322
|
}
|
|
4318
|
-
function
|
|
4319
|
-
|
|
4323
|
+
function Fn(t) {
|
|
4324
|
+
Qt(t), ve && ve(t);
|
|
4320
4325
|
}
|
|
4321
4326
|
function Xe(t, e) {
|
|
4322
4327
|
const r = t;
|
|
@@ -4338,7 +4343,7 @@ function Xe(t, e) {
|
|
|
4338
4343
|
for (const o of t.masks)
|
|
4339
4344
|
o.maskElement && Xe(o.maskElement, e);
|
|
4340
4345
|
}
|
|
4341
|
-
function
|
|
4346
|
+
function Ct(t) {
|
|
4342
4347
|
if (typeof document > "u") return t;
|
|
4343
4348
|
const e = Se.getInstance();
|
|
4344
4349
|
return t.map((r) => {
|
|
@@ -4356,23 +4361,23 @@ function Ft(t) {
|
|
|
4356
4361
|
} : r;
|
|
4357
4362
|
});
|
|
4358
4363
|
}
|
|
4359
|
-
async function
|
|
4364
|
+
async function Ye(t, e, r = Jt) {
|
|
4360
4365
|
const o = e.filter((i) => t.hasElementId(i.id)), n = [], a = [], s = /* @__PURE__ */ new Set();
|
|
4361
4366
|
for (const i of o) {
|
|
4362
4367
|
if (i.visible === !1) continue;
|
|
4363
4368
|
const l = i.toJSON();
|
|
4364
4369
|
if (Xe(l, s), i instanceof We && !i.imageElement) {
|
|
4365
|
-
|
|
4370
|
+
Ft.warn(`[element-serializer] Skipping image ${i.id}: image not loaded (state: ${i.imageLoadState})`);
|
|
4366
4371
|
continue;
|
|
4367
4372
|
}
|
|
4368
4373
|
if (i instanceof We && i.imageElement)
|
|
4369
4374
|
try {
|
|
4370
|
-
const d =
|
|
4371
|
-
if (!
|
|
4372
|
-
const m = await
|
|
4373
|
-
a.push({ cacheKey: d, bitmap: m }),
|
|
4375
|
+
const d = Do(i.id, i.imageUrl);
|
|
4376
|
+
if (!Qo(d)) {
|
|
4377
|
+
const m = await zo(i.imageElement, r);
|
|
4378
|
+
a.push({ cacheKey: d, bitmap: m }), Jo(d);
|
|
4374
4379
|
}
|
|
4375
|
-
const g = i.transformData || {}, f =
|
|
4380
|
+
const g = i.transformData || {}, f = At(l), p = kr(g, f), u = g.width * p.cropWidth, y = g.height * p.cropHeight, k = {
|
|
4376
4381
|
id: i.id,
|
|
4377
4382
|
type: "image",
|
|
4378
4383
|
x: i.x,
|
|
@@ -4382,16 +4387,16 @@ async function Ve(t, e, r = Kt) {
|
|
|
4382
4387
|
rotation: i.rotation || 0,
|
|
4383
4388
|
bitmapCacheKey: d
|
|
4384
4389
|
};
|
|
4385
|
-
if (!
|
|
4390
|
+
if (!vr(p)) {
|
|
4386
4391
|
const m = i.imageElement.naturalWidth, w = i.imageElement.naturalHeight;
|
|
4387
4392
|
let F = 1;
|
|
4388
4393
|
(m > r || w > r) && (F = r / Math.max(m, w)), k.cropX = p.cropX * m * F, k.cropY = p.cropY * w * F, k.cropWidth = p.cropWidth * m * F, k.cropHeight = p.cropHeight * w * F;
|
|
4389
4394
|
}
|
|
4390
|
-
g.flipHorizontal && (k.flipHorizontal = g.flipHorizontal), g.flipVertical && (k.flipVertical = g.flipVertical), g.borderRadius && (k.borderRadius = g.borderRadius),
|
|
4395
|
+
g.flipHorizontal && (k.flipHorizontal = g.flipHorizontal), g.flipVertical && (k.flipVertical = g.flipVertical), g.borderRadius && (k.borderRadius = g.borderRadius), Tr(g.adjustments) || (k.adjustments = { ...g.adjustments }), i.opacity !== void 0 && (k.opacity = i.opacity);
|
|
4391
4396
|
const v = k;
|
|
4392
|
-
i.distressEffect && (v.distressEffect = { ...i.distressEffect }), l.masks && l.masks.length > 0 && (v.masks =
|
|
4397
|
+
i.distressEffect && (v.distressEffect = { ...i.distressEffect }), l.masks && l.masks.length > 0 && (v.masks = Ct(l.masks)), l.blendMode && (v.blendMode = l.blendMode), l.knockoutParts && (v.knockoutParts = l.knockoutParts), l.shadow && (v.shadow = { ...l.shadow }), "getVisualBoundingBox" in i && typeof i.getVisualBoundingBox == "function" ? v._boundingBox = i.getVisualBoundingBox() : "getBoundingBox" in i && typeof i.getBoundingBox == "function" && (v._boundingBox = i.getBoundingBox()), n.push(v);
|
|
4393
4398
|
} catch (d) {
|
|
4394
|
-
|
|
4399
|
+
Ft.error(`[element-serializer] Failed to create ImageBitmap for ${l.id}:`, d);
|
|
4395
4400
|
}
|
|
4396
4401
|
else {
|
|
4397
4402
|
const d = {
|
|
@@ -4400,7 +4405,7 @@ async function Ve(t, e, r = Kt) {
|
|
|
4400
4405
|
// Map transformType to type for worker compatibility
|
|
4401
4406
|
};
|
|
4402
4407
|
if (i instanceof Je) {
|
|
4403
|
-
const h = await
|
|
4408
|
+
const h = await Ye(
|
|
4404
4409
|
{ ...t, hasElementId: () => !0 },
|
|
4405
4410
|
i.children,
|
|
4406
4411
|
r
|
|
@@ -4408,7 +4413,7 @@ async function Ve(t, e, r = Kt) {
|
|
|
4408
4413
|
d.children = h.data.elements, a.push(...h.newBitmaps);
|
|
4409
4414
|
for (const g of h.data.fonts) s.add(g);
|
|
4410
4415
|
}
|
|
4411
|
-
d.masks && Array.isArray(d.masks) && d.masks.length > 0 && (d.masks =
|
|
4416
|
+
d.masks && Array.isArray(d.masks) && d.masks.length > 0 && (d.masks = Ct(d.masks)), "getVisualBoundingBox" in i && typeof i.getVisualBoundingBox == "function" ? d._boundingBox = i.getVisualBoundingBox() : "getBoundingBox" in i && typeof i.getBoundingBox == "function" && (d._boundingBox = i.getBoundingBox()), n.push(d);
|
|
4412
4417
|
}
|
|
4413
4418
|
}
|
|
4414
4419
|
const c = Array.from(s);
|
|
@@ -4433,7 +4438,7 @@ async function Ve(t, e, r = Kt) {
|
|
|
4433
4438
|
newBitmaps: a
|
|
4434
4439
|
};
|
|
4435
4440
|
}
|
|
4436
|
-
async function
|
|
4441
|
+
async function en(t, e, r = fetch) {
|
|
4437
4442
|
try {
|
|
4438
4443
|
const o = await r(e.fontFileUrl, { mode: "cors" });
|
|
4439
4444
|
if (!o.ok) return null;
|
|
@@ -4449,7 +4454,7 @@ function J(t) {
|
|
|
4449
4454
|
function rt(t) {
|
|
4450
4455
|
return `${J(t.family)}|${t.weight ?? 400}|${t.style ?? "normal"}`;
|
|
4451
4456
|
}
|
|
4452
|
-
class
|
|
4457
|
+
class tn {
|
|
4453
4458
|
constructor() {
|
|
4454
4459
|
this.fonts = /* @__PURE__ */ new Map(), this.listeners = /* @__PURE__ */ new Set(), this.snapshot = [], this.list = () => this.snapshot, this.subscribe = (e) => (this.listeners.add(e), () => {
|
|
4455
4460
|
this.listeners.delete(e);
|
|
@@ -4495,13 +4500,13 @@ class en {
|
|
|
4495
4500
|
for (const e of this.listeners) e();
|
|
4496
4501
|
}
|
|
4497
4502
|
}
|
|
4498
|
-
const
|
|
4499
|
-
function
|
|
4500
|
-
|
|
4503
|
+
const Ve = new tn();
|
|
4504
|
+
function rn(t) {
|
|
4505
|
+
Ve.register(t);
|
|
4501
4506
|
}
|
|
4502
|
-
const
|
|
4503
|
-
async function
|
|
4504
|
-
const r = await
|
|
4507
|
+
const zt = /* @__PURE__ */ new Set();
|
|
4508
|
+
async function on(t, e = {}) {
|
|
4509
|
+
const r = await en(
|
|
4505
4510
|
t.family,
|
|
4506
4511
|
{
|
|
4507
4512
|
fontFileUrl: t.url,
|
|
@@ -4513,7 +4518,7 @@ async function rn(t, e = {}) {
|
|
|
4513
4518
|
e.fetchImpl ?? fetch
|
|
4514
4519
|
);
|
|
4515
4520
|
if (!r)
|
|
4516
|
-
throw new
|
|
4521
|
+
throw new de(
|
|
4517
4522
|
"E_FONT_LOAD_FAILED",
|
|
4518
4523
|
`Custom font "${t.family}" failed to load from ${t.url}. The URL must serve the font binary over a plain cross-origin GET (CORS). Verify the URL is reachable and sends Access-Control-Allow-Origin, then re-register the font. Custom fonts never fall back silently — the design would render with the wrong typeface.`,
|
|
4519
4524
|
{
|
|
@@ -4524,18 +4529,18 @@ async function rn(t, e = {}) {
|
|
|
4524
4529
|
}
|
|
4525
4530
|
);
|
|
4526
4531
|
const o = e.fonts ?? (typeof document < "u" ? document.fonts : void 0);
|
|
4527
|
-
return o == null || o.add(r),
|
|
4532
|
+
return o == null || o.add(r), zt.add(rt(t)), r;
|
|
4528
4533
|
}
|
|
4529
|
-
async function
|
|
4530
|
-
|
|
4534
|
+
async function Cn(t, e = {}) {
|
|
4535
|
+
rn(t);
|
|
4531
4536
|
const { onLoadError: r, ...o } = e;
|
|
4532
4537
|
await Promise.all(
|
|
4533
4538
|
t.map(async (n) => {
|
|
4534
|
-
if (!
|
|
4539
|
+
if (!zt.has(rt(n)))
|
|
4535
4540
|
try {
|
|
4536
|
-
await
|
|
4541
|
+
await on(n, o);
|
|
4537
4542
|
} catch (a) {
|
|
4538
|
-
if (r && a instanceof
|
|
4543
|
+
if (r && a instanceof de) {
|
|
4539
4544
|
r(a, n);
|
|
4540
4545
|
return;
|
|
4541
4546
|
}
|
|
@@ -4546,12 +4551,12 @@ async function Fn(t, e = {}) {
|
|
|
4546
4551
|
}
|
|
4547
4552
|
const O = H("WorkerExport");
|
|
4548
4553
|
let De = null, Re = null;
|
|
4549
|
-
function
|
|
4554
|
+
function nn() {
|
|
4550
4555
|
return Re ?? (Re = (typeof window > "u" ? Promise.reject(new Error("The export worker runs in a browser page only (no window here).")) : import("./export-worker.bundle.string-DG2f-C1t.js")).then((t) => De = t.default).catch((t) => {
|
|
4551
4556
|
throw Re = null, t;
|
|
4552
4557
|
})), Re;
|
|
4553
4558
|
}
|
|
4554
|
-
class
|
|
4559
|
+
class fe {
|
|
4555
4560
|
constructor() {
|
|
4556
4561
|
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.initGeneration = 0, 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;
|
|
4557
4562
|
}
|
|
@@ -4625,7 +4630,7 @@ class ge {
|
|
|
4625
4630
|
* Call this when an element is removed or its image source changes.
|
|
4626
4631
|
*/
|
|
4627
4632
|
clearWorkerBitmap(e) {
|
|
4628
|
-
if (
|
|
4633
|
+
if (Qt(e), this.worker && this.isReady) {
|
|
4629
4634
|
const r = {
|
|
4630
4635
|
type: "clear-bitmap",
|
|
4631
4636
|
elementId: e
|
|
@@ -4651,11 +4656,11 @@ class ge {
|
|
|
4651
4656
|
return this.readyPromise || Promise.resolve();
|
|
4652
4657
|
if (this.readyPromise)
|
|
4653
4658
|
return this.readyPromise;
|
|
4654
|
-
if (!
|
|
4659
|
+
if (!fe.supportsWorkerExport())
|
|
4655
4660
|
throw new Error("Browser does not support OffscreenCanvas or Web Workers");
|
|
4656
4661
|
if (De !== null)
|
|
4657
4662
|
return this.readyPromise = this.startWorker(De), this.readyPromise;
|
|
4658
|
-
const e = this.initGeneration, r =
|
|
4663
|
+
const e = this.initGeneration, r = nn().then((o) => {
|
|
4659
4664
|
if (e !== this.initGeneration)
|
|
4660
4665
|
throw new Error("Worker terminated");
|
|
4661
4666
|
return this.startWorker(o);
|
|
@@ -4684,7 +4689,7 @@ class ge {
|
|
|
4684
4689
|
const a = setTimeout(() => {
|
|
4685
4690
|
o(new Error("Worker initialization timeout"));
|
|
4686
4691
|
}, 15e3), s = (c) => {
|
|
4687
|
-
c.data.type === "ready" && (clearTimeout(a), this.isReady = !0,
|
|
4692
|
+
c.data.type === "ready" && (clearTimeout(a), this.isReady = !0, xo(
|
|
4688
4693
|
() => this.clearWorkerBitmapCache(),
|
|
4689
4694
|
(i) => this.clearWorkerBitmap(i)
|
|
4690
4695
|
), r());
|
|
@@ -4761,7 +4766,7 @@ class ge {
|
|
|
4761
4766
|
const { artboard: r, elements: o, config: n } = e;
|
|
4762
4767
|
if ((!this.worker || !this.isReady) && await this.initialize(), !this.worker)
|
|
4763
4768
|
throw new Error("Worker is not initialized");
|
|
4764
|
-
const a = `export-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: c, newBitmaps: i } = await
|
|
4769
|
+
const a = `export-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: c, newBitmaps: i } = await Ye(r, o);
|
|
4765
4770
|
i.length > 0 && this.registerBitmapsWithWorker(i);
|
|
4766
4771
|
const l = {
|
|
4767
4772
|
type: "export",
|
|
@@ -4772,7 +4777,7 @@ class ge {
|
|
|
4772
4777
|
// Custom (brand) fonts among the used families — the worker loads
|
|
4773
4778
|
// these from their hosted URL instead of Google Fonts (deterministic
|
|
4774
4779
|
// shadowing; see utils/custom-fonts.ts).
|
|
4775
|
-
customFonts:
|
|
4780
|
+
customFonts: Ve.forFamilies(c.fonts ?? []),
|
|
4776
4781
|
scale: n.scale || 1,
|
|
4777
4782
|
format: n.format || "png",
|
|
4778
4783
|
quality: n.quality || 0.95
|
|
@@ -4822,7 +4827,7 @@ class ge {
|
|
|
4822
4827
|
const { artboard: r, elements: o, config: n } = e;
|
|
4823
4828
|
if ((!this.worker || !this.isReady) && await this.initialize(), !this.worker)
|
|
4824
4829
|
throw new Error("Worker is not initialized");
|
|
4825
|
-
const a = `export-blob-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: c, newBitmaps: i } = await
|
|
4830
|
+
const a = `export-blob-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: c, newBitmaps: i } = await Ye(r, o);
|
|
4826
4831
|
i.length > 0 && this.registerBitmapsWithWorker(i);
|
|
4827
4832
|
const l = {
|
|
4828
4833
|
type: "export",
|
|
@@ -4831,7 +4836,7 @@ class ge {
|
|
|
4831
4836
|
elements: c.elements,
|
|
4832
4837
|
fonts: c.fonts,
|
|
4833
4838
|
// Same custom-font threading as the dataUrl path above.
|
|
4834
|
-
customFonts:
|
|
4839
|
+
customFonts: Ve.forFamilies(c.fonts ?? []),
|
|
4835
4840
|
scale: n.scale || 1,
|
|
4836
4841
|
format: n.format || "png",
|
|
4837
4842
|
quality: n.quality || 0.95,
|
|
@@ -4938,7 +4943,7 @@ class ge {
|
|
|
4938
4943
|
r.reject(new Error("Worker terminated")), this.pendingRequests.delete(e);
|
|
4939
4944
|
for (; this.requestQueue.length > 0; )
|
|
4940
4945
|
this.requestQueue.shift().reject(new Error("Worker terminated"));
|
|
4941
|
-
this.worker.terminate(), this.worker = null, this.isReady = !1, this.readyPromise = null, je(),
|
|
4946
|
+
this.worker.terminate(), this.worker = null, this.isReady = !1, this.readyPromise = null, je(), Zo(), this.workerBlobUrl && (URL.revokeObjectURL(this.workerBlobUrl), this.workerBlobUrl = null);
|
|
4942
4947
|
}
|
|
4943
4948
|
}
|
|
4944
4949
|
/**
|
|
@@ -4954,14 +4959,14 @@ class ge {
|
|
|
4954
4959
|
}
|
|
4955
4960
|
}
|
|
4956
4961
|
let ee = null;
|
|
4957
|
-
function Cn() {
|
|
4958
|
-
return ee || (ee = new ge()), ee;
|
|
4959
|
-
}
|
|
4960
4962
|
function Mn() {
|
|
4963
|
+
return ee || (ee = new fe()), ee;
|
|
4964
|
+
}
|
|
4965
|
+
function En() {
|
|
4961
4966
|
ee && (ee.terminate(), ee = null);
|
|
4962
4967
|
}
|
|
4963
4968
|
Ze();
|
|
4964
|
-
const _ = H("Export"),
|
|
4969
|
+
const _ = H("Export"), Mt = (t) => t === "jpg" || t === "jpeg" ? "image/jpeg" : t === "webp" ? "image/webp" : "image/png", Et = (t, e, r) => new Promise((o) => t.toBlob((n) => o(n), e, r));
|
|
4965
4970
|
function Be(t) {
|
|
4966
4971
|
t.width = 0, t.height = 0;
|
|
4967
4972
|
}
|
|
@@ -4978,7 +4983,7 @@ function Ke(t, e) {
|
|
|
4978
4983
|
o != null && o.maskElement && Ke(o.maskElement, e);
|
|
4979
4984
|
}
|
|
4980
4985
|
}
|
|
4981
|
-
async function
|
|
4986
|
+
async function sn(t) {
|
|
4982
4987
|
if (typeof document > "u" || !document.fonts) return;
|
|
4983
4988
|
const e = /* @__PURE__ */ new Set();
|
|
4984
4989
|
for (const o of t) Ke(o, e);
|
|
@@ -4994,7 +4999,7 @@ const le = class le {
|
|
|
4994
4999
|
* Check if worker export is supported in this browser
|
|
4995
5000
|
*/
|
|
4996
5001
|
static supportsWorkerExport() {
|
|
4997
|
-
return
|
|
5002
|
+
return fe.supportsWorkerExport();
|
|
4998
5003
|
}
|
|
4999
5004
|
/**
|
|
5000
5005
|
* Get or initialize the worker manager
|
|
@@ -5002,7 +5007,7 @@ const le = class le {
|
|
|
5002
5007
|
static async getWorkerManager() {
|
|
5003
5008
|
return this.supportsWorkerExport() ? this.workerManager ? this.workerManager : this.workerInitPromise ? (await this.workerInitPromise, this.workerManager) : (this.workerInitPromise = (async () => {
|
|
5004
5009
|
try {
|
|
5005
|
-
this.workerManager = new
|
|
5010
|
+
this.workerManager = new fe(), await this.workerManager.initialize();
|
|
5006
5011
|
} catch (e) {
|
|
5007
5012
|
_.error("Failed to initialize worker:", e), this.workerManager = null;
|
|
5008
5013
|
}
|
|
@@ -5144,7 +5149,7 @@ const le = class le {
|
|
|
5144
5149
|
static async mainThreadExportToBlob(e, r, o, n = {}) {
|
|
5145
5150
|
const { format: a = "png", quality: s = 0.95 } = n, c = await this.renderOnMainThread(e, r, n);
|
|
5146
5151
|
try {
|
|
5147
|
-
const i = await
|
|
5152
|
+
const i = await Et(c, Mt(a), s);
|
|
5148
5153
|
if (!i) throw new Error("Failed to create blob from canvas");
|
|
5149
5154
|
return i;
|
|
5150
5155
|
} finally {
|
|
@@ -5160,7 +5165,7 @@ const le = class le {
|
|
|
5160
5165
|
static async mainThreadExportToDataURL(e, r, o, n = {}) {
|
|
5161
5166
|
const { format: a = "png", quality: s = 0.95 } = n, c = await this.renderOnMainThread(e, r, n);
|
|
5162
5167
|
try {
|
|
5163
|
-
return c.toDataURL(
|
|
5168
|
+
return c.toDataURL(Mt(a), s);
|
|
5164
5169
|
} finally {
|
|
5165
5170
|
Be(c);
|
|
5166
5171
|
}
|
|
@@ -5177,12 +5182,12 @@ const le = class le {
|
|
|
5177
5182
|
static async exportPrintFile(e, r, o) {
|
|
5178
5183
|
const { scale: n, region: a } = o;
|
|
5179
5184
|
if (!(n > 0) || !Number.isFinite(n))
|
|
5180
|
-
throw new
|
|
5185
|
+
throw new de("E_PRINT_FILE_FAILED", `scale must be a finite number above 0 (got ${n}).`, { artboard: e.name, scale: n });
|
|
5181
5186
|
const s = await this.renderOnMainThread(e, r, { scale: n, transparentBackground: !0 }, a), c = s.width, i = s.height;
|
|
5182
5187
|
try {
|
|
5183
|
-
const l = await
|
|
5188
|
+
const l = await Et(s, "image/png");
|
|
5184
5189
|
if (!l || l.size === 0)
|
|
5185
|
-
throw new
|
|
5190
|
+
throw new de(
|
|
5186
5191
|
"E_PRINT_FILE_FAILED",
|
|
5187
5192
|
`the device could not make the ${c} x ${i} px print file of "${e.name}"${a ? ` (region ${a.id})` : ""}: its canvas was refused. Ask for a smaller scale for this device.`,
|
|
5188
5193
|
{ artboard: e.name, region: a == null ? void 0 : a.id, width: c, height: i, scale: n }
|
|
@@ -5206,7 +5211,7 @@ const le = class le {
|
|
|
5206
5211
|
transparentBackground: s = !1,
|
|
5207
5212
|
backgroundColor: c = e.backgroundColor
|
|
5208
5213
|
} = o, i = r.filter((m) => m.visible !== !1);
|
|
5209
|
-
await
|
|
5214
|
+
await sn(i);
|
|
5210
5215
|
const l = n ?? { x: 0, y: 0, width: e.width, height: e.height }, d = document.createElement("canvas");
|
|
5211
5216
|
d.width = Math.max(1, Math.round(l.width * a)), d.height = Math.max(1, Math.round(l.height * a));
|
|
5212
5217
|
const h = d.getContext("2d");
|
|
@@ -5237,7 +5242,7 @@ const le = class le {
|
|
|
5237
5242
|
const M = y[I].id;
|
|
5238
5243
|
M && k.add(M);
|
|
5239
5244
|
}
|
|
5240
|
-
|
|
5245
|
+
_t(
|
|
5241
5246
|
h,
|
|
5242
5247
|
C,
|
|
5243
5248
|
y,
|
|
@@ -5253,7 +5258,7 @@ const le = class le {
|
|
|
5253
5258
|
const C = y[w], E = ((F = C == null ? void 0 : C.distressEffect) == null ? void 0 : F.enabled) && C.distressEffect.style === "custom" && C.distressEffect.textureUrl, P = (C == null ? void 0 : C.masks) && C.masks.length > 0, S = (I) => {
|
|
5254
5259
|
m.render(I, !1);
|
|
5255
5260
|
};
|
|
5256
|
-
|
|
5261
|
+
Uo(h, C, (I) => {
|
|
5257
5262
|
if (P && E)
|
|
5258
5263
|
ut(I, C, (M) => {
|
|
5259
5264
|
const T = m.getVisualBoundingBox();
|
|
@@ -5273,7 +5278,7 @@ const le = class le {
|
|
|
5273
5278
|
y: e.y,
|
|
5274
5279
|
width: e.width,
|
|
5275
5280
|
height: e.height
|
|
5276
|
-
}), (v = e.imageMask) != null && v.enabled &&
|
|
5281
|
+
}), (v = e.imageMask) != null && v.enabled && Bo(h, e.imageMask, {
|
|
5277
5282
|
x: e.x,
|
|
5278
5283
|
y: e.y,
|
|
5279
5284
|
width: e.width,
|
|
@@ -5512,68 +5517,68 @@ const le = class le {
|
|
|
5512
5517
|
};
|
|
5513
5518
|
le.CURRENT_VERSION = "2.0.0", le.workerManager = null, le.workerInitPromise = null;
|
|
5514
5519
|
let Te = le;
|
|
5515
|
-
const
|
|
5520
|
+
const Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5516
5521
|
__proto__: null,
|
|
5517
5522
|
ExportManager: Te,
|
|
5518
5523
|
default: Te
|
|
5519
5524
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5520
5525
|
export {
|
|
5521
|
-
|
|
5526
|
+
un as $,
|
|
5522
5527
|
ut as A,
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5528
|
+
En as B,
|
|
5529
|
+
Qt as C,
|
|
5530
|
+
Jt as D,
|
|
5526
5531
|
be as E,
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5532
|
+
_r as F,
|
|
5533
|
+
Ve as G,
|
|
5534
|
+
Cn as H,
|
|
5535
|
+
St as I,
|
|
5536
|
+
on as J,
|
|
5537
|
+
rn as K,
|
|
5538
|
+
_t as L,
|
|
5539
|
+
Uo as M,
|
|
5535
5540
|
Vo as N,
|
|
5536
|
-
|
|
5541
|
+
Bo as O,
|
|
5537
5542
|
Ze as P,
|
|
5538
5543
|
kt as Q,
|
|
5539
|
-
|
|
5540
|
-
|
|
5544
|
+
ln as R,
|
|
5545
|
+
Ut as S,
|
|
5541
5546
|
me as T,
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5547
|
+
Xo as U,
|
|
5548
|
+
No as V,
|
|
5549
|
+
fe as W,
|
|
5550
|
+
Tn as X,
|
|
5551
|
+
So as Y,
|
|
5552
|
+
To as Z,
|
|
5553
|
+
pn as _,
|
|
5549
5554
|
Te as a,
|
|
5550
|
-
|
|
5555
|
+
Er as a0,
|
|
5551
5556
|
Ue as a1,
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5557
|
+
Pn as a2,
|
|
5558
|
+
mn as b,
|
|
5559
|
+
Bt as c,
|
|
5555
5560
|
$ as d,
|
|
5556
|
-
|
|
5557
|
-
|
|
5561
|
+
Sn as e,
|
|
5562
|
+
vn as f,
|
|
5558
5563
|
je as g,
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5564
|
+
hn as h,
|
|
5565
|
+
Ar as i,
|
|
5566
|
+
gn as j,
|
|
5567
|
+
dn as k,
|
|
5568
|
+
he as l,
|
|
5569
|
+
Mn as m,
|
|
5570
|
+
kn as n,
|
|
5571
|
+
nn as o,
|
|
5567
5572
|
ct as p,
|
|
5568
|
-
|
|
5569
|
-
|
|
5573
|
+
Fn as q,
|
|
5574
|
+
Wr as r,
|
|
5570
5575
|
Le as s,
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5576
|
+
yn as t,
|
|
5577
|
+
fn as u,
|
|
5578
|
+
Gr as v,
|
|
5579
|
+
wn as w,
|
|
5580
|
+
Nr as x,
|
|
5581
|
+
Wt as y,
|
|
5582
|
+
bn as z
|
|
5578
5583
|
};
|
|
5579
|
-
//# sourceMappingURL=ExportManager-
|
|
5584
|
+
//# sourceMappingURL=ExportManager-Q4GQE68T.js.map
|