@snowcone-app/canvas 0.17.0 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CanvasStateV1-C6i6vU6p.js → CanvasStateV1-BG2hEc3-.js} +3 -3
- package/dist/{CanvasStateV1-C6i6vU6p.js.map → CanvasStateV1-BG2hEc3-.js.map} +1 -1
- package/dist/EditorCanvasImpl-DgXvuWXX.js +70 -0
- package/dist/EditorCanvasImpl-DgXvuWXX.js.map +1 -0
- package/dist/EditorContext-CGkfmbgo.js +1178 -0
- package/dist/EditorContext-CGkfmbgo.js.map +1 -0
- package/dist/{ElementFactory-C05JJkRp.js → ElementFactory-CuHSAPfg.js} +1469 -710
- package/dist/ElementFactory-CuHSAPfg.js.map +1 -0
- package/dist/{HybridHistoryManager-Bht98XRv.js → FontAnalyzer-CLv7_msL.js} +2104 -2903
- package/dist/FontAnalyzer-CLv7_msL.js.map +1 -0
- package/dist/{ImportManager-kRYfIX-D.js → ImportManager-C_wBjWaV.js} +147 -147
- package/dist/{ImportManager-kRYfIX-D.js.map → ImportManager-C_wBjWaV.js.map} +1 -1
- package/dist/SnowconeCanvas-wdckG-6O.js +1179 -0
- package/dist/SnowconeCanvas-wdckG-6O.js.map +1 -0
- package/dist/{UnifiedFontService-BAtqqkU4.js → UnifiedFontService-Dsu5cwfT.js} +141 -141
- package/dist/UnifiedFontService-Dsu5cwfT.js.map +1 -0
- package/dist/advanced.mjs +10 -10
- package/dist/components/editor/RootInternals.d.ts +7 -0
- package/dist/components/editor/designStateStore.d.ts +1 -1
- package/dist/components/embed/EmbedRoot.d.ts +23 -0
- package/dist/components/embed/SnowconeCanvas.d.ts +13 -0
- package/dist/components/embed/kernel.d.ts +114 -0
- package/dist/contexts/BoundLayerGuardContext.d.ts +36 -0
- package/dist/core/GroupElement.d.ts +0 -5
- package/dist/core/TextElement.d.ts +8 -3
- package/dist/core/paint-registry.d.ts +42 -0
- package/dist/core/rich-text-layout.d.ts +28 -0
- package/dist/{editorErrors-DbIEtCTt.js → editorErrors-BY4Pdg7a.js} +2 -2
- package/dist/{editorErrors-DbIEtCTt.js.map → editorErrors-BY4Pdg7a.js.map} +1 -1
- package/dist/{embed-Bdj4PKUA.js → embed-32ZVWfmj.js} +209 -200
- package/dist/embed-32ZVWfmj.js.map +1 -0
- package/dist/embed.mjs +21 -22
- package/dist/embed.mjs.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/internals.mjs +93 -93
- package/dist/rendering/element-painters.d.ts +16 -0
- package/dist/rendering/rich-text-renderer.d.ts +3 -28
- package/dist/{template-fields-GOM4MNfq.js → template-fields-Z9x13sjM.js} +32 -33
- package/dist/{template-fields-GOM4MNfq.js.map → template-fields-Z9x13sjM.js.map} +1 -1
- package/dist/testing.mjs +7 -7
- package/dist/transforms/ArchTransform.d.ts +0 -1
- package/dist/transforms/AscendTransform.d.ts +0 -1
- package/dist/transforms/CircleTransform.d.ts +0 -1
- package/dist/transforms/FlagTransform.d.ts +0 -1
- package/dist/transforms/LeanTransform.d.ts +0 -1
- package/dist/transforms/WaveTransform.d.ts +0 -1
- package/dist/{usePieceGuideBundle-CGERAQJl.js → usePieceGuideBundle-C1ipFnZd.js} +2 -2
- package/dist/{usePieceGuideBundle-CGERAQJl.js.map → usePieceGuideBundle-C1ipFnZd.js.map} +1 -1
- package/dist/{validation-DEd6EOCP.js → validation-C795COGQ.js} +4803 -4791
- package/dist/validation-C795COGQ.js.map +1 -0
- package/dist/vendor/ui/primitives/kbd.d.ts +1 -1
- package/dist/workers/export-worker.bundle.string.d.ts +1 -1
- package/package.json +7 -4
- package/dist/EditorCanvasImpl-DkgE5-C2.js +0 -68
- package/dist/EditorCanvasImpl-DkgE5-C2.js.map +0 -1
- package/dist/EditorContext-CyanYzo2.js +0 -1131
- package/dist/EditorContext-CyanYzo2.js.map +0 -1
- package/dist/ElementFactory-C05JJkRp.js.map +0 -1
- package/dist/HybridHistoryManager-Bht98XRv.js.map +0 -1
- package/dist/SnowconeCanvas-C3eZ9PP8.js +0 -1047
- package/dist/SnowconeCanvas-C3eZ9PP8.js.map +0 -1
- package/dist/UnifiedFontService-BAtqqkU4.js.map +0 -1
- package/dist/editorError-DMENTZ-3.js +0 -19
- package/dist/editorError-DMENTZ-3.js.map +0 -1
- package/dist/embed-Bdj4PKUA.js.map +0 -1
- package/dist/validation-DEd6EOCP.js.map +0 -1
package/dist/internals.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { D as
|
|
5
|
-
import { A as Hr, e as Or, C as Fr, S as Lr } from "./CanvasStateV1-
|
|
1
|
+
import { A as w, e as b, C as I, I as R, f as W, R as A, S as E, T as H } from "./ImportManager-C_wBjWaV.js";
|
|
2
|
+
import { r as p } from "./ElementFactory-CuHSAPfg.js";
|
|
3
|
+
import { D as F, E as L, W as X, a as z, b as K, c as Y, d as B, e as _, f as J, g as N, h as V, i as U, j, k as q, l as Q, m as Z, n as $, o as m, p as G, q as x, s as D, t as rr, u as or, v as sr, w as ir, x as er, y as ar, z as nr, A as tr, B as hr } from "./ElementFactory-CuHSAPfg.js";
|
|
4
|
+
import { D as cr, E as fr, H as pr, J as gr, K as lr, L as ur, M as Tr, N as kr, O as Mr, Q as yr, W as vr, U as Cr, V as Sr, X as Pr, c as wr, Y as br, Z as Ir, _ as Rr, $ as Wr, a0 as Ar } from "./FontAnalyzer-CLv7_msL.js";
|
|
5
|
+
import { A as Hr, e as Or, C as Fr, S as Lr } from "./CanvasStateV1-BG2hEc3-.js";
|
|
6
6
|
function y(r, o) {
|
|
7
7
|
return !r.needsCropPixelConversion || r.cropWidth === void 0 ? r : {
|
|
8
8
|
...r,
|
|
@@ -13,11 +13,11 @@ function y(r, o) {
|
|
|
13
13
|
needsCropPixelConversion: !1
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
var
|
|
16
|
+
function v(r, o, c) {
|
|
17
|
+
var a, n;
|
|
18
18
|
r.save(), r.translate(o.x, o.y), o.rotation && r.rotate(-o.rotation * Math.PI / 180);
|
|
19
|
-
let
|
|
20
|
-
if (o.flipHorizontal && (
|
|
19
|
+
let e = 1, h = 1;
|
|
20
|
+
if (o.flipHorizontal && (e = -1), o.flipVertical && (h = -1), (e !== 1 || h !== 1) && r.scale(e, h), o.opacity !== void 0 && o.opacity !== 1 && (r.globalAlpha = o.opacity), o.borderRadius && o.borderRadius > 0) {
|
|
21
21
|
const i = Math.min(
|
|
22
22
|
o.borderRadius / 100 * Math.min(o.width, o.height),
|
|
23
23
|
o.width / 2,
|
|
@@ -37,7 +37,7 @@ function C(r, o, c) {
|
|
|
37
37
|
-o.height / 2,
|
|
38
38
|
o.width,
|
|
39
39
|
o.height
|
|
40
|
-
) : r.drawImage(c, -o.width / 2, -o.height / 2, o.width, o.height), r.restore(), (
|
|
40
|
+
) : r.drawImage(c, -o.width / 2, -o.height / 2, o.width, o.height), r.restore(), (a = o.stroke) != null && a.enabled) {
|
|
41
41
|
const i = ((n = o.knockoutParts) == null ? void 0 : n.stroke) === !0, s = {
|
|
42
42
|
x: o.x,
|
|
43
43
|
y: o.y,
|
|
@@ -78,14 +78,14 @@ function T(r, o) {
|
|
|
78
78
|
const c = document.createElement("canvas");
|
|
79
79
|
return c.width = r, c.height = o, c;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
var
|
|
83
|
-
const c = o.opacity ?? 1,
|
|
84
|
-
c < 1 &&
|
|
81
|
+
function C(r, o) {
|
|
82
|
+
var a;
|
|
83
|
+
const c = o.opacity ?? 1, e = !!((a = o.stroke) != null && a.enabled);
|
|
84
|
+
c < 1 && e ? k(r, o, c) : g(r, o, c);
|
|
85
85
|
}
|
|
86
86
|
function k(r, o, c) {
|
|
87
87
|
var f;
|
|
88
|
-
const
|
|
88
|
+
const e = o.transformData, a = (((f = o.stroke) == null ? void 0 : f.width) || 2) + 2, n = Math.ceil(e.width + a * 2), i = Math.ceil(e.height + a * 2), s = T(n, i), t = s.getContext("2d");
|
|
89
89
|
if (!t) {
|
|
90
90
|
g(r, o, c);
|
|
91
91
|
return;
|
|
@@ -98,133 +98,133 @@ function k(r, o, c) {
|
|
|
98
98
|
g(t, d, 1), r.save(), r.translate(o.x, o.y), o.rotation && r.rotate(-o.rotation * Math.PI / 180), r.globalAlpha = c, r.drawImage(s, -n / 2, -i / 2), r.restore();
|
|
99
99
|
}
|
|
100
100
|
function g(r, o, c) {
|
|
101
|
-
var
|
|
102
|
-
const
|
|
103
|
-
if (r.save(), r.translate(o.x, o.y), o.rotation && r.rotate(-o.rotation * Math.PI / 180), r.globalAlpha = c * h, r.fillStyle =
|
|
101
|
+
var a;
|
|
102
|
+
const e = o.transformData, h = e.fillOpacity ?? 1;
|
|
103
|
+
if (r.save(), r.translate(o.x, o.y), o.rotation && r.rotate(-o.rotation * Math.PI / 180), r.globalAlpha = c * h, r.fillStyle = e.fillColor || "#3b82f6", r.beginPath(), u(r, e), r.fill(), r.restore(), (a = o.stroke) != null && a.enabled) {
|
|
104
104
|
r.save(), r.translate(o.x, o.y), o.rotation && r.rotate(-o.rotation * Math.PI / 180);
|
|
105
105
|
const n = o.stroke;
|
|
106
|
-
r.globalAlpha = c * (n.opacity ?? 1), r.strokeStyle = n.color || "#000000", r.lineWidth = n.width || 2, r.lineCap = n.lineCap || "round", r.lineJoin = n.lineJoin || "round", r.beginPath(), u(r,
|
|
106
|
+
r.globalAlpha = c * (n.opacity ?? 1), r.strokeStyle = n.color || "#000000", r.lineWidth = n.width || 2, r.lineCap = n.lineCap || "round", r.lineJoin = n.lineJoin || "round", r.beginPath(), u(r, e), r.stroke(), r.restore();
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
function u(r, o) {
|
|
110
|
-
const { shapeType: c, width:
|
|
110
|
+
const { shapeType: c, width: e, height: h } = o;
|
|
111
111
|
switch (c) {
|
|
112
112
|
case "rectangle": {
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
115
|
-
const s = Math.min(
|
|
116
|
-
r.roundRect(n, i,
|
|
113
|
+
const a = o.borderRadius || 0, n = -e / 2, i = -h / 2;
|
|
114
|
+
if (a > 0) {
|
|
115
|
+
const s = Math.min(a / 100 * Math.min(e, h), e / 2, h / 2);
|
|
116
|
+
r.roundRect(n, i, e, h, s);
|
|
117
117
|
} else
|
|
118
|
-
r.rect(n, i,
|
|
118
|
+
r.rect(n, i, e, h);
|
|
119
119
|
break;
|
|
120
120
|
}
|
|
121
121
|
case "circle": {
|
|
122
|
-
const
|
|
123
|
-
r.arc(0, 0,
|
|
122
|
+
const a = Math.min(e, h) / 2;
|
|
123
|
+
r.arc(0, 0, a, 0, Math.PI * 2);
|
|
124
124
|
break;
|
|
125
125
|
}
|
|
126
126
|
case "ellipse": {
|
|
127
|
-
r.ellipse(0, 0,
|
|
127
|
+
r.ellipse(0, 0, e / 2, h / 2, 0, 0, Math.PI * 2);
|
|
128
128
|
break;
|
|
129
129
|
}
|
|
130
130
|
case "triangle": {
|
|
131
|
-
const
|
|
132
|
-
r.moveTo(0, -n), r.lineTo(
|
|
131
|
+
const a = e / 2, n = h / 2;
|
|
132
|
+
r.moveTo(0, -n), r.lineTo(a, n), r.lineTo(-a, n), r.closePath();
|
|
133
133
|
break;
|
|
134
134
|
}
|
|
135
135
|
case "polygon": {
|
|
136
|
-
const
|
|
137
|
-
for (let i = 0; i <
|
|
138
|
-
const s = i * 2 * Math.PI /
|
|
136
|
+
const a = o.sides || 5, n = Math.min(e, h) / 2;
|
|
137
|
+
for (let i = 0; i < a; i++) {
|
|
138
|
+
const s = i * 2 * Math.PI / a - Math.PI / 2, t = n * Math.cos(s), d = n * Math.sin(s);
|
|
139
139
|
i === 0 ? r.moveTo(t, d) : r.lineTo(t, d);
|
|
140
140
|
}
|
|
141
141
|
r.closePath();
|
|
142
142
|
break;
|
|
143
143
|
}
|
|
144
144
|
case "star": {
|
|
145
|
-
const
|
|
146
|
-
for (let s = 0; s <
|
|
147
|
-
const t = s * Math.PI /
|
|
145
|
+
const a = o.points || 5, n = Math.min(e, h) / 2, i = n * (o.innerRadius || 0.4);
|
|
146
|
+
for (let s = 0; s < a * 2; s++) {
|
|
147
|
+
const t = s * Math.PI / a - Math.PI / 2, d = s % 2 === 0 ? n : i, f = d * Math.cos(t), l = d * Math.sin(t);
|
|
148
148
|
s === 0 ? r.moveTo(f, l) : r.lineTo(f, l);
|
|
149
149
|
}
|
|
150
150
|
r.closePath();
|
|
151
151
|
break;
|
|
152
152
|
}
|
|
153
153
|
case "line": {
|
|
154
|
-
const
|
|
155
|
-
r.rect(-
|
|
154
|
+
const a = e / 2, n = h / 2;
|
|
155
|
+
r.rect(-a, -n, e, h);
|
|
156
156
|
break;
|
|
157
157
|
}
|
|
158
158
|
default:
|
|
159
|
-
r.rect(-
|
|
159
|
+
r.rect(-e / 2, -h / 2, e, h);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
export {
|
|
163
|
-
|
|
163
|
+
w as AlignmentSnapSystem,
|
|
164
164
|
Hr as AnyElementConfigSchema,
|
|
165
165
|
Or as AnyTransformDataSchema,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
cr as ArchTransform,
|
|
167
|
+
fr as ArtboardManager,
|
|
168
|
+
b as ArtboardRenderer,
|
|
169
|
+
pr as AscendTransform,
|
|
170
170
|
I as CanvasRenderer,
|
|
171
171
|
Fr as CanvasStateV1Schema,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
172
|
+
gr as CircleTransform,
|
|
173
|
+
lr as CustomTransform,
|
|
174
|
+
F as DEFAULT_MAX_BITMAP_DIMENSION,
|
|
175
|
+
ur as ElementStore,
|
|
176
|
+
L as ExportManager,
|
|
177
|
+
Tr as FlagTransform,
|
|
178
|
+
kr as HybridHistoryManager,
|
|
179
179
|
R as ImportManager,
|
|
180
180
|
W as InteractionStateMachine,
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
Mr as LeanTransform,
|
|
182
|
+
yr as LogLevel,
|
|
183
183
|
A as ResizePipeline,
|
|
184
184
|
Lr as SerializedArtboardSchema,
|
|
185
185
|
E as SpacingSystem,
|
|
186
186
|
H as TransformHandles,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
187
|
+
vr as WaveTransform,
|
|
188
|
+
X as WorkerExportManager,
|
|
189
|
+
z as applySpaceLayoutRules,
|
|
190
|
+
K as applyStrokeStyle,
|
|
191
|
+
Y as buildFontString,
|
|
192
|
+
Cr as calculateFixedCornerPosition,
|
|
193
|
+
Sr as calculateResizeHandles,
|
|
194
|
+
Pr as calculateRotationHandlePosition,
|
|
195
|
+
B as clearImageBitmapCache,
|
|
196
|
+
_ as clearMaskCache,
|
|
197
|
+
J as clearRegisteredBitmapKeys,
|
|
198
|
+
N as createCirclePath,
|
|
199
|
+
V as createImagePath,
|
|
200
|
+
wr as createLogger,
|
|
201
|
+
U as createRectPath,
|
|
202
|
+
j as createTextPath,
|
|
203
|
+
q as getFontMetrics,
|
|
204
|
+
Q as getSharedWorkerExportManager,
|
|
205
|
+
br as hitTestCircle,
|
|
206
|
+
Ir as hitTestRect,
|
|
207
|
+
Z as invalidateMaskCache,
|
|
208
|
+
Rr as logger,
|
|
209
|
+
$ as measureTextWidth,
|
|
210
|
+
m as removeFromImageBitmapCache,
|
|
211
|
+
G as renderCustomTransform,
|
|
212
|
+
v as renderImageElement,
|
|
213
213
|
p as renderImageStroke,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
214
|
+
x as renderMultilineText,
|
|
215
|
+
D as renderPathStroke,
|
|
216
|
+
rr as renderRichTextFillOnly,
|
|
217
|
+
C as renderShapeElement,
|
|
218
|
+
or as renderTextElement,
|
|
219
|
+
sr as renderTextFillOnly,
|
|
220
|
+
ir as renderTextStroke,
|
|
221
|
+
er as renderWithKnockout,
|
|
222
|
+
ar as renderWithMasks,
|
|
223
223
|
y as resolveServerCrop,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
224
|
+
Wr as splitRichTextIntoLines,
|
|
225
|
+
nr as terminateSharedWorkerExportManager,
|
|
226
|
+
tr as unregisterElementBitmaps,
|
|
227
|
+
Ar as wrapRichTextSpans,
|
|
228
|
+
hr as wrapText
|
|
229
229
|
};
|
|
230
230
|
//# sourceMappingURL=internals.mjs.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Element painters — the heavy half of the paint registry
|
|
3
|
+
* (`src/core/paint-registry.ts`, P1 element/renderer split).
|
|
4
|
+
*
|
|
5
|
+
* Registers the shared paint functions the element model delegates to at
|
|
6
|
+
* paint time. This module statically imports the paint pipeline
|
|
7
|
+
* (transform-renderer / canvas-renderer), so it must only ever be reachable
|
|
8
|
+
* through renderer-side code: every paint DRIVER (CanvasRenderer,
|
|
9
|
+
* ExportManager, ElementPreviewRenderer) imports it, which keeps the
|
|
10
|
+
* registration a static guarantee of "the renderer is loaded" without the
|
|
11
|
+
* model graph ever touching `src/rendering/*`. CI-gated by
|
|
12
|
+
* scripts/check-import-graph.mjs.
|
|
13
|
+
*/
|
|
14
|
+
/** Idempotent; also runs at module evaluation, so a plain side-effect import
|
|
15
|
+
* (`import './element-painters.js'`) suffices. */
|
|
16
|
+
export declare function installElementPainters(): void;
|
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
import { TextAlign,
|
|
1
|
+
import { TextAlign, RichText } from '../types/index.js';
|
|
2
2
|
import { RenderContext } from './renderer-types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* This function handles character-level formatting correctly by:
|
|
7
|
-
* 1. First merging consecutive spans with the same style
|
|
8
|
-
* 2. Finding word boundaries (spaces) across spans
|
|
9
|
-
* 3. Wrapping at word boundaries, not at span boundaries
|
|
10
|
-
*/
|
|
11
|
-
export declare function wrapRichTextSpans(spans: Array<{
|
|
12
|
-
text: string;
|
|
13
|
-
style: CharacterStyle;
|
|
14
|
-
}>, maxWidth: number, element: {
|
|
15
|
-
fontSize: number;
|
|
16
|
-
fontFamily: string;
|
|
17
|
-
bold?: boolean;
|
|
18
|
-
italic?: boolean;
|
|
19
|
-
}): Array<{
|
|
20
|
-
text: string;
|
|
21
|
-
style: CharacterStyle;
|
|
22
|
-
}[]>;
|
|
23
|
-
/**
|
|
24
|
-
* Split rich text into lines by explicit newlines, preserving span formatting
|
|
25
|
-
*/
|
|
26
|
-
export declare function splitRichTextIntoLines(richText: RichText): Array<{
|
|
27
|
-
text: string;
|
|
28
|
-
style: CharacterStyle;
|
|
29
|
-
}[]>;
|
|
3
|
+
import { splitRichTextIntoLines, wrapRichTextSpans } from '../core/rich-text-layout.js';
|
|
4
|
+
export { splitRichTextIntoLines, wrapRichTextSpans };
|
|
30
5
|
/**
|
|
31
6
|
* Render rich text with per-span styling (fill only, no effects)
|
|
32
7
|
* Supports multi-line text with line breaks and word wrapping
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { useCallback as C, useEffect as et, useMemo as $, useRef as A, useState as _ } from "react";
|
|
2
|
-
import { u as G, c as T, b as H } from "./EditorContext-
|
|
3
|
-
import { c as nt, y as
|
|
4
|
-
import { U as rt } from "./UnifiedFontService-
|
|
5
|
-
import { E as
|
|
6
|
-
import { a as it, o as E, b as h, n as at, l as b, u as L, c as st } from "./CanvasStateV1-C6i6vU6p.js";
|
|
2
|
+
import { u as G, c as T, b as H, g as z } from "./EditorContext-CGkfmbgo.js";
|
|
3
|
+
import { c as nt, y as P, T as B, I as J, z as ot } from "./FontAnalyzer-CLv7_msL.js";
|
|
4
|
+
import { U as rt } from "./UnifiedFontService-Dsu5cwfT.js";
|
|
5
|
+
import { a as it, o as E, b as h, n as at, l as b, u as L, c as st } from "./CanvasStateV1-BG2hEc3-.js";
|
|
7
6
|
const X = nt("useCommands");
|
|
8
|
-
function
|
|
7
|
+
function Bt() {
|
|
9
8
|
const t = G(), {
|
|
10
9
|
undo: e,
|
|
11
10
|
redo: n,
|
|
@@ -45,7 +44,7 @@ function Mt() {
|
|
|
45
44
|
executeCommandBatch: c
|
|
46
45
|
};
|
|
47
46
|
}
|
|
48
|
-
function
|
|
47
|
+
function Mt() {
|
|
49
48
|
const { selectedElement: t } = G();
|
|
50
49
|
return t ?? null;
|
|
51
50
|
}
|
|
@@ -77,7 +76,7 @@ function ht(t, e, n) {
|
|
|
77
76
|
function M(t, e, n, r) {
|
|
78
77
|
et(() => {
|
|
79
78
|
var a;
|
|
80
|
-
if (r || typeof
|
|
79
|
+
if (r || typeof P > "u" || ((a = P.env) == null ? void 0 : a.NODE_ENV) === "production") return;
|
|
81
80
|
const i = `${t}:${e}`;
|
|
82
81
|
if (v.has(i)) return;
|
|
83
82
|
const o = setTimeout(() => {
|
|
@@ -88,7 +87,7 @@ function M(t, e, n, r) {
|
|
|
88
87
|
}
|
|
89
88
|
const dt = () => {
|
|
90
89
|
}, mt = [];
|
|
91
|
-
function
|
|
90
|
+
function Ut(t) {
|
|
92
91
|
const { elementStore: e } = T(), { executeElementUpdate: n } = H(), r = $(() => e.getAllByName(t).filter((a) => a instanceof B), [e, t]), i = C(
|
|
93
92
|
(o) => {
|
|
94
93
|
for (const a of r) {
|
|
@@ -132,7 +131,7 @@ function pt(t, e, n) {
|
|
|
132
131
|
};
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
|
-
function
|
|
134
|
+
function Wt(t, e) {
|
|
136
135
|
const n = (e == null ? void 0 : e.fit) ?? "cover", { elementStore: r, setElements: i } = T(), { executeElementUpdate: o } = H(), a = $(() => r.getAllByName(t).filter((g) => g instanceof J), [r, t]), s = A(/* @__PURE__ */ new Map());
|
|
137
136
|
for (const d of a)
|
|
138
137
|
if (!s.current.has(d.id)) {
|
|
@@ -194,7 +193,7 @@ function bt(t, e, n) {
|
|
|
194
193
|
const r = t.clone(), i = t, o = r;
|
|
195
194
|
return x(i.color, e) && (typeof o.setColor == "function" ? o.setColor(n) : o.color = n), x((a = i.transformData) == null ? void 0 : a.fillColor, e) && (o.transformData = { ...o.transformData, fillColor: n }), x((s = i.transformData) == null ? void 0 : s.strokeColor, e) && (o.transformData = { ...o.transformData, strokeColor: n }), ((l = i.stroke) == null ? void 0 : l.enabled) === !0 && x(i.stroke.color, e) && (o.stroke = { ...o.stroke, color: n }), r;
|
|
196
195
|
}
|
|
197
|
-
function
|
|
196
|
+
function It(t) {
|
|
198
197
|
const { elementStore: e } = T(), { executeElementUpdate: n } = H(), [r, i] = _(() => R(t)), [o, a] = _(t);
|
|
199
198
|
t !== o && (a(t), i(R(t)));
|
|
200
199
|
const s = $(
|
|
@@ -217,7 +216,7 @@ function Yt(t) {
|
|
|
217
216
|
}
|
|
218
217
|
const xt = () => {
|
|
219
218
|
}, wt = [];
|
|
220
|
-
function
|
|
219
|
+
function Yt(t) {
|
|
221
220
|
const { elementStore: e } = T(), { executeElementUpdate: n } = H(), r = $(() => e.getAllByName(t).filter((a) => a instanceof B), [e, t]), i = C(
|
|
222
221
|
(o) => {
|
|
223
222
|
rt.loadGoogleFontByName(o);
|
|
@@ -238,7 +237,7 @@ function _t(t) {
|
|
|
238
237
|
isConnected: !0
|
|
239
238
|
};
|
|
240
239
|
}
|
|
241
|
-
function
|
|
240
|
+
function _t(t) {
|
|
242
241
|
const { elementStore: e } = T();
|
|
243
242
|
return t ? e.getByName(t) ?? null : null;
|
|
244
243
|
}
|
|
@@ -310,7 +309,7 @@ function Tt(t) {
|
|
|
310
309
|
return !n && (e.cropX !== 0 || e.cropY !== 0 || e.cropWidth !== 1 || e.cropHeight !== 1) && (s.cropX = e.cropX, s.cropY = e.cropY, s.cropWidth = e.cropWidth, s.cropHeight = e.cropHeight, s.needsCropPixelConversion = !0), e.flipHorizontal && (s.flipHorizontal = e.flipHorizontal), e.flipVertical && (s.flipVertical = e.flipVertical), e.borderRadius && (s.borderRadius = e.borderRadius), t.opacity !== void 0 && (s.opacity = t.opacity), t.distressEffect && (s.distressEffect = t.distressEffect), ((c = t.masks) == null ? void 0 : c.length) > 0 && (s.masks = t.masks), t.blendMode && (s.blendMode = t.blendMode), t.knockoutParts && (s.knockoutParts = t.knockoutParts), t.stroke && (s.stroke = t.stroke), Q(s);
|
|
311
310
|
}
|
|
312
311
|
const j = "center", Z = Symbol.for("snowcone.canvas.layerToken");
|
|
313
|
-
function
|
|
312
|
+
function zt(t) {
|
|
314
313
|
return typeof t == "object" && t !== null && t[Z] === !0 && typeof t.name == "string" && (t.kind === "text" || t.kind === "image");
|
|
315
314
|
}
|
|
316
315
|
function Nt(t, e) {
|
|
@@ -498,7 +497,7 @@ class U {
|
|
|
498
497
|
const n = this.els.find((i) => i.name === e);
|
|
499
498
|
if (!n) {
|
|
500
499
|
const i = this.layerNamesOfKind("text"), o = this.layerNamesOfKind("image");
|
|
501
|
-
throw new
|
|
500
|
+
throw new z(
|
|
502
501
|
"E_LAYER_NOT_FOUND",
|
|
503
502
|
`no layer "${e}" in this design. Text layers: ${JSON.stringify(i)}; image layers: ${JSON.stringify(o)}. Fix the name, or add the layer first — e.g. design(…).text('…', { name: '${e}' }).`,
|
|
504
503
|
{ layerName: e, validNames: [...i, ...o], textNames: i, imageNames: o, docSlug: "embed-mode" }
|
|
@@ -506,7 +505,7 @@ class U {
|
|
|
506
505
|
}
|
|
507
506
|
const r = O(n);
|
|
508
507
|
if (!r)
|
|
509
|
-
throw new
|
|
508
|
+
throw new z(
|
|
510
509
|
"E_LAYER_WRONG_KIND",
|
|
511
510
|
`layer "${e}" is a ${n.transformType} element — only text and image layers are bindable. Bindable layers: ${JSON.stringify([...this.layerNamesOfKind("text"), ...this.layerNamesOfKind("image")])}.`,
|
|
512
511
|
{ layerName: e, actualType: n.transformType, docSlug: "embed-mode" }
|
|
@@ -569,10 +568,10 @@ class U {
|
|
|
569
568
|
return kt(this.toJSON());
|
|
570
569
|
}
|
|
571
570
|
}
|
|
572
|
-
function
|
|
571
|
+
function Pt(t) {
|
|
573
572
|
return new U(t);
|
|
574
573
|
}
|
|
575
|
-
function
|
|
574
|
+
function Lt(t) {
|
|
576
575
|
return O(t);
|
|
577
576
|
}
|
|
578
577
|
const tt = "personalization", $t = it("type", [
|
|
@@ -607,7 +606,7 @@ const tt = "personalization", $t = it("type", [
|
|
|
607
606
|
group: h().optional()
|
|
608
607
|
})
|
|
609
608
|
]);
|
|
610
|
-
function
|
|
609
|
+
function Xt(t) {
|
|
611
610
|
if (!t || typeof t != "object") return [];
|
|
612
611
|
const e = t[tt];
|
|
613
612
|
if (!Array.isArray(e)) return [];
|
|
@@ -619,25 +618,25 @@ function Kt(t) {
|
|
|
619
618
|
}
|
|
620
619
|
return n;
|
|
621
620
|
}
|
|
622
|
-
function
|
|
621
|
+
function Kt(t, e) {
|
|
623
622
|
return { ...t, [tt]: e };
|
|
624
623
|
}
|
|
625
624
|
export {
|
|
626
625
|
Ct as C,
|
|
627
626
|
U as D,
|
|
628
627
|
tt as T,
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
628
|
+
Bt as a,
|
|
629
|
+
_t as b,
|
|
630
|
+
Yt as c,
|
|
631
|
+
Pt as d,
|
|
632
|
+
Wt as e,
|
|
633
|
+
Mt as f,
|
|
634
|
+
Ut as g,
|
|
635
|
+
zt as i,
|
|
636
|
+
Lt as l,
|
|
637
|
+
Xt as r,
|
|
639
638
|
kt as s,
|
|
640
|
-
|
|
641
|
-
|
|
639
|
+
It as u,
|
|
640
|
+
Kt as w
|
|
642
641
|
};
|
|
643
|
-
//# sourceMappingURL=template-fields-
|
|
642
|
+
//# sourceMappingURL=template-fields-Z9x13sjM.js.map
|