@snowcone-app/canvas 0.31.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ERROR_CONTRACT.md +11 -0
- package/STYLING_CONTRACT.md +3 -3
- package/dist/{CanvasRenderer-hpJ05JGO.js → CanvasRenderer-1j-twIbs.js} +443 -431
- package/dist/{CanvasRenderer-hpJ05JGO.js.map → CanvasRenderer-1j-twIbs.js.map} +1 -1
- package/dist/{CanvasStateV1-jLOibojY.js → CanvasStateV1-BmC1JfPv.js} +810 -802
- package/dist/{CanvasStateV1-jLOibojY.js.map → CanvasStateV1-BmC1JfPv.js.map} +1 -1
- package/dist/ContextualToolbars-BKU8IoAM.js +6474 -0
- package/dist/ContextualToolbars-BKU8IoAM.js.map +1 -0
- package/dist/{EditorCanvasImpl-P2GHPNA3.js → EditorCanvasImpl-4voOsj2k.js} +7 -7
- package/dist/{EditorCanvasImpl-P2GHPNA3.js.map → EditorCanvasImpl-4voOsj2k.js.map} +1 -1
- package/dist/{ExportManager-Bkzzyxgw.js → ExportManager-Ci81K6xA.js} +662 -518
- package/dist/ExportManager-Ci81K6xA.js.map +1 -0
- package/dist/{FontAnalyzer-BYhwxDhe.js → FontAnalyzer-BrKY6XYn.js} +1256 -1146
- package/dist/FontAnalyzer-BrKY6XYn.js.map +1 -0
- package/dist/{ImagePanel-CEr0_FYy.js → ImagePanel-ntJBepby.js} +6 -6
- package/dist/{ImagePanel-CEr0_FYy.js.map → ImagePanel-ntJBepby.js.map} +1 -1
- package/dist/{SnowconeCanvas-Fa0isFpO.js → SnowconeCanvas-CgQdiBXv.js} +10 -10
- package/dist/{SnowconeCanvas-Fa0isFpO.js.map → SnowconeCanvas-CgQdiBXv.js.map} +1 -1
- package/dist/advanced.mjs +14 -14
- package/dist/components/ImageToolbar.d.ts +8 -0
- package/dist/components/ShapeToolbar.d.ts +8 -0
- package/dist/components/TextToolbar.d.ts +5 -1
- package/dist/components/toolbars/EmbeddedToolbarLayout.d.ts +4 -0
- package/dist/components/toolbars/GroupElementToolbar.d.ts +8 -0
- package/dist/components/toolbars/SecondaryPanels.d.ts +24 -1
- package/dist/components/toolbars/index.d.ts +2 -2
- package/dist/core/BaseElement.d.ts +2 -1
- package/dist/core/shape-fill.d.ts +31 -0
- package/dist/{custom-icons-Co4rcW0S.js → custom-icons-DTWtkJ9N.js} +2 -2
- package/dist/{custom-icons-Co4rcW0S.js.map → custom-icons-DTWtkJ9N.js.map} +1 -1
- package/dist/{design-builder-CBG2hKc8.js → design-builder-BpbYUYtK.js} +55 -55
- package/dist/{design-builder-CBG2hKc8.js.map → design-builder-BpbYUYtK.js.map} +1 -1
- package/dist/{embed-D4TIzO7g.js → embed-C69x0jHc.js} +10 -10
- package/dist/{embed-D4TIzO7g.js.map → embed-C69x0jHc.js.map} +1 -1
- package/dist/embed.mjs +7 -7
- package/dist/errors/editorError.d.ts +7 -0
- package/dist/{guards-DgZuwVgu.js → guards-BhaQgJrE.js} +2 -2
- package/dist/{guards-DgZuwVgu.js.map → guards-BhaQgJrE.js.map} +1 -1
- package/dist/hooks/elementPatch.d.ts +8 -3
- package/dist/index.mjs +9 -9
- package/dist/internals.mjs +123 -123
- package/dist/internals.mjs.map +1 -1
- package/dist/rendering/LayerEffectsRenderer.d.ts +24 -0
- package/dist/rendering/renderer-types.d.ts +3 -1
- package/dist/state/CanvasStateV1.d.ts +17 -0
- package/dist/style.css +1 -1
- package/dist/{template-fields-CvFcr5zy.js → template-fields-D-2oLhCi.js} +5 -5
- package/dist/{template-fields-CvFcr5zy.js.map → template-fields-D-2oLhCi.js.map} +1 -1
- package/dist/testing.mjs +3 -3
- package/dist/types/index.d.ts +84 -1
- package/dist/types/public.d.ts +3 -2
- package/dist/{useCommands-bPXY9rCh.js → useCommands-DwnZHUg8.js} +435 -418
- package/dist/useCommands-DwnZHUg8.js.map +1 -0
- package/dist/{usePieceGuideBundle-Bj98nPk0.js → usePieceGuideBundle-CnSmYrmM.js} +2 -2
- package/dist/{usePieceGuideBundle-Bj98nPk0.js.map → usePieceGuideBundle-CnSmYrmM.js.map} +1 -1
- package/dist/utils/featureApplied.d.ts +4 -0
- package/dist/{validation-CsTlSvJJ.js → validation-DyUOjRGa.js} +11 -11
- package/dist/{validation-CsTlSvJJ.js.map → validation-DyUOjRGa.js.map} +1 -1
- package/dist/workers/export-worker.bundle.string.d.ts +1 -1
- package/example/package.json +1 -1
- package/package.json +1 -1
- package/dist/ContextualToolbars-DRbuUE7W.js +0 -6061
- package/dist/ContextualToolbars-DRbuUE7W.js.map +0 -1
- package/dist/ExportManager-Bkzzyxgw.js.map +0 -1
- package/dist/FontAnalyzer-BYhwxDhe.js.map +0 -1
- package/dist/useCommands-bPXY9rCh.js.map +0 -1
package/dist/embed.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as a, a as t, b as r, A as o, F as i, G as n, H as d, J as m, K as u, u as l, d as E, f as c, g as p, h as g } from "./useCommands-
|
|
2
|
-
import { E as S, R as f, a as C, b as T, S as F, c as v, d as y, f as P, p as b, e as B, g as R, h, v as D } from "./embed-
|
|
3
|
-
import { E as L, y as k } from "./FontAnalyzer-
|
|
4
|
-
import { D as A, d as G, j as K, i as M, u as _ } from "./design-builder-
|
|
5
|
-
import { D as z, T as H, r as J, u as N, a as Y, b as q, c as O, d as Q, e as U, w as V } from "./template-fields-
|
|
6
|
-
import { c as X, e as Z, l as $, r as ee } from "./ExportManager-
|
|
7
|
-
import { s as ae } from "./CanvasStateV1-
|
|
1
|
+
import { C as a, a as t, b as r, A as o, F as i, G as n, H as d, J as m, K as u, u as l, d as E, f as c, g as p, h as g } from "./useCommands-DwnZHUg8.js";
|
|
2
|
+
import { E as S, R as f, a as C, b as T, S as F, c as v, d as y, f as P, p as b, e as B, g as R, h, v as D } from "./embed-C69x0jHc.js";
|
|
3
|
+
import { E as L, y as k } from "./FontAnalyzer-BrKY6XYn.js";
|
|
4
|
+
import { D as A, d as G, j as K, i as M, u as _ } from "./design-builder-BpbYUYtK.js";
|
|
5
|
+
import { D as z, T as H, r as J, u as N, a as Y, b as q, c as O, d as Q, e as U, w as V } from "./template-fields-D-2oLhCi.js";
|
|
6
|
+
import { c as X, e as Z, l as $, r as ee } from "./ExportManager-Ci81K6xA.js";
|
|
7
|
+
import { s as ae } from "./CanvasStateV1-BmC1JfPv.js";
|
|
8
8
|
export {
|
|
9
9
|
a as CanvasServicesProvider,
|
|
10
10
|
A as DesignBuilder,
|
|
@@ -68,6 +68,13 @@ export type EditorErrorCode =
|
|
|
68
68
|
* wrong primitive type). The message names the element kind and lists the
|
|
69
69
|
* valid keys for it. Dev AND prod. */
|
|
70
70
|
| 'E_INVALID_PATCH'
|
|
71
|
+
/** A shape `fill` value is not a valid `ShapeFill` union member: unknown
|
|
72
|
+
* `type` (valid: "solid" | "linear" | "radial"), a gradient with fewer
|
|
73
|
+
* than 2 stops, a stop `offset` outside 0..1 (or non-finite), a non-string
|
|
74
|
+
* stop `color`, or a non-finite linear `angle`. Thrown wherever a fill
|
|
75
|
+
* enters the model — `new ShapeElement(...)` and `updateElement` patches.
|
|
76
|
+
* Dev AND prod. */
|
|
77
|
+
| 'E_INVALID_FILL'
|
|
71
78
|
/** `addElement(spec)`: there is no active artboard to add the element to.
|
|
72
79
|
* Create or select an artboard first (`<Editor.Root>` seeds one
|
|
73
80
|
* automatically; with a raw `EditorProvider` use `executeCreateArtboard`).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as n, I as t, P as a, S as s, T as i } from "./FontAnalyzer-
|
|
1
|
+
import { G as n, I as t, P as a, S as s, T as i } from "./FontAnalyzer-BrKY6XYn.js";
|
|
2
2
|
function r(e) {
|
|
3
3
|
return e instanceof i;
|
|
4
4
|
}
|
|
@@ -21,4 +21,4 @@ export {
|
|
|
21
21
|
r as d,
|
|
22
22
|
u as i
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=guards-
|
|
24
|
+
//# sourceMappingURL=guards-BhaQgJrE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards-
|
|
1
|
+
{"version":3,"file":"guards-BhaQgJrE.js","sources":["../src/types/guards.ts"],"sourcesContent":["/**\n * Type guards for EditorElement discrimination\n *\n * These guards use instanceof checks against the concrete element classes,\n * matching the pattern established in EditorContext.tsx. They accept\n * BaseElement | EditorElement | undefined | null for maximum flexibility\n * at call sites.\n */\n\nimport { BaseElement } from '../core/BaseElement.js';\nimport { TextElement } from '../core/TextElement.js';\nimport { ImageElement } from '../core/ImageElement.js';\nimport { GroupElement } from '../core/GroupElement.js';\nimport { ShapeElement } from '../core/ShapeElement.js';\nimport { PathElement } from '../core/PathElement.js';\n\ntype Narrowable = BaseElement | TextElement | ImageElement | GroupElement | ShapeElement | PathElement | undefined | null;\n\n/**\n * Type guard: checks if an element is a TextElement (or any text-based transform subclass).\n *\n * TextElement is the base class for all text transforms (custom, circle, arch, wave, etc.),\n * so this returns true for any text-based element regardless of its specific transformType.\n */\nexport function isTextElement(element: Narrowable): element is TextElement {\n return element instanceof TextElement;\n}\n\n/**\n * Type guard: checks if an element is an ImageElement.\n */\nexport function isImageElement(element: Narrowable): element is ImageElement {\n return element instanceof ImageElement;\n}\n\n/**\n * Type guard: checks if an element is a GroupElement.\n */\nexport function isGroupElement(element: Narrowable): element is GroupElement {\n return element instanceof GroupElement;\n}\n\n/**\n * Type guard: checks if an element is a ShapeElement.\n */\nexport function isShapeElement(element: Narrowable): element is ShapeElement {\n return element instanceof ShapeElement;\n}\n\n/**\n * Type guard: checks if an element is a PathElement.\n */\nexport function isPathElement(element: Narrowable): element is PathElement {\n return element instanceof PathElement;\n}\n"],"names":["isTextElement","element","TextElement","isImageElement","ImageElement","isGroupElement","GroupElement","isShapeElement","ShapeElement","isPathElement","PathElement"],"mappings":";AAwBO,SAASA,EAAcC,GAA6C;AACzE,SAAOA,aAAmBC;AAC5B;AAKO,SAASC,EAAeF,GAA8C;AAC3E,SAAOA,aAAmBG;AAC5B;AAKO,SAASC,EAAeJ,GAA8C;AAC3E,SAAOA,aAAmBK;AAC5B;AAKO,SAASC,EAAeN,GAA8C;AAC3E,SAAOA,aAAmBO;AAC5B;AAKO,SAASC,EAAcR,GAA6C;AACzE,SAAOA,aAAmBS;AAC5B;"}
|
|
@@ -2,7 +2,7 @@ import { LayerToken } from '../design/design-builder.js';
|
|
|
2
2
|
import { EditorElementKind } from '../core/elementGuards.js';
|
|
3
3
|
import { ElementStore } from '../core/ElementStore.js';
|
|
4
4
|
import { EditorElement } from '../contexts/EditorContext.js';
|
|
5
|
-
import {
|
|
5
|
+
import { ImageAdjustments, ShapeFill, TextAlign } from '../types/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* A serializable element patch for {@link UseCommandsReturn.updateElement}.
|
|
8
8
|
*
|
|
@@ -14,7 +14,7 @@ import { TextAlign, ImageAdjustments } from '../types/index.js';
|
|
|
14
14
|
* |---|---|
|
|
15
15
|
* | `x`, `y`, `rotation`, `opacity`, `name`, `visible`, `locked` | every kind |
|
|
16
16
|
* | `text`, `fontSize`, `color`, `fontFamily`, `bold`, `italic`, `textAlign` | text |
|
|
17
|
-
* | `fillColor`, `width`, `height` | shape |
|
|
17
|
+
* | `fillColor`, `fill`, `width`, `height` | shape |
|
|
18
18
|
* | `imageUrl`, `width`, `height`, `adjustments` | image |
|
|
19
19
|
*/
|
|
20
20
|
export interface ElementPatch {
|
|
@@ -46,8 +46,13 @@ export interface ElementPatch {
|
|
|
46
46
|
italic?: boolean;
|
|
47
47
|
/** Text alignment. Text elements only. */
|
|
48
48
|
textAlign?: TextAlign;
|
|
49
|
-
/** Fill color (CSS color). Shape elements only.
|
|
49
|
+
/** Fill color (CSS color). Shape elements only. Also CLEARS any gradient
|
|
50
|
+
* `fill` so the patched color is what actually renders (`fill` wins over
|
|
51
|
+
* `fillColor` otherwise — a silently-overridden patch is a no-op trap). */
|
|
50
52
|
fillColor?: string;
|
|
53
|
+
/** Rich fill (solid or gradient) — `{ type: 'solid' | 'linear' | 'radial', ... }`.
|
|
54
|
+
* Shape elements only. Invalid unions throw `E_INVALID_FILL`. */
|
|
55
|
+
fill?: ShapeFill;
|
|
51
56
|
/** Frame width (> 0). Shape and image elements only. */
|
|
52
57
|
width?: number;
|
|
53
58
|
/** Frame height (> 0). Shape and image elements only. */
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { e as u } from "./useCommands-
|
|
2
|
-
import { C as p, c as x, a as I, b as v, u as A, d as g, f as T, g as B, h as P } from "./useCommands-
|
|
3
|
-
import { E as F, S as L, S as _, u as O, a as R } from "./SnowconeCanvas-
|
|
4
|
-
import { u as m, a as d } from "./design-builder-
|
|
5
|
-
import { C as z, D as w, d as D, s as K } from "./design-builder-
|
|
6
|
-
import { T as V, r as b, u as h, a as U, b as Y, c as Z, d as G, e as H, w as j } from "./template-fields-
|
|
7
|
-
import { A as q, C as J, E as Q, M as W, P as X, r as $, v as ee } from "./validation-
|
|
8
|
-
import { c as ae, e as te, l as oe, r as re } from "./ExportManager-
|
|
1
|
+
import { e as u } from "./useCommands-DwnZHUg8.js";
|
|
2
|
+
import { C as p, c as x, a as I, b as v, u as A, d as g, f as T, g as B, h as P } from "./useCommands-DwnZHUg8.js";
|
|
3
|
+
import { E as F, S as L, S as _, u as O, a as R } from "./SnowconeCanvas-CgQdiBXv.js";
|
|
4
|
+
import { u as m, a as d } from "./design-builder-BpbYUYtK.js";
|
|
5
|
+
import { C as z, D as w, d as D, s as K } from "./design-builder-BpbYUYtK.js";
|
|
6
|
+
import { T as V, r as b, u as h, a as U, b as Y, c as Z, d as G, e as H, w as j } from "./template-fields-D-2oLhCi.js";
|
|
7
|
+
import { A as q, C as J, E as Q, M as W, P as X, r as $, v as ee } from "./validation-DyUOjRGa.js";
|
|
8
|
+
import { c as ae, e as te, l as oe, r as re } from "./ExportManager-Ci81K6xA.js";
|
|
9
9
|
import { c as ie, e as ue } from "./compose-DtQL_oit.js";
|
|
10
|
-
import { d as de, m as Ce, s as Se, v as Ee } from "./CanvasStateV1-
|
|
10
|
+
import { d as de, m as Ce, s as Se, v as Ee } from "./CanvasStateV1-BmC1JfPv.js";
|
|
11
11
|
function E() {
|
|
12
12
|
const { isCanvasReady: e } = m();
|
|
13
13
|
return e;
|
package/dist/internals.mjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { a as M } from "./ExportManager-
|
|
3
|
-
import { D as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { A as
|
|
7
|
-
const
|
|
8
|
-
function
|
|
9
|
-
const { brightness: a, contrast: s, saturation: h } = o, e = a * s,
|
|
1
|
+
import { A as rr, a as or, C as sr, I as er, R as tr, S as nr, T as ar } from "./CanvasRenderer-1j-twIbs.js";
|
|
2
|
+
import { a as M } from "./ExportManager-Ci81K6xA.js";
|
|
3
|
+
import { D as hr, E as cr, I as dr, W as fr, b as ur, d as gr, f as lr, h as pr, i as yr, j as Mr, k as vr, m as Tr, n as kr, o as wr, p as Sr, q as br, s as Cr, t as Pr, u as Ir, v as mr, w as Ar, x as Rr, y as Wr, z as Er, A as Or, B as Hr, C as jr, F as Fr, G as Lr, H as Xr, J as Nr } from "./ExportManager-Ci81K6xA.js";
|
|
4
|
+
import { M as H, N as j, c as F, O as L, Q as X } from "./FontAnalyzer-BrKY6XYn.js";
|
|
5
|
+
import { V as zr, W as Br, X as Kr, Y as Ur, Z as Yr, _ as Jr, $ as Vr, a0 as qr, a1 as Gr, a2 as Qr, a3 as Zr, a4 as $r, a5 as xr, a6 as Dr, a7 as ro, a8 as oo, a9 as so, aa as eo, ab as to } from "./FontAnalyzer-BrKY6XYn.js";
|
|
6
|
+
import { A as ao, e as io, C as ho, S as co } from "./CanvasStateV1-BmC1JfPv.js";
|
|
7
|
+
const N = F("image-adjustments"), v = 1e-3;
|
|
8
|
+
function _(r, o) {
|
|
9
|
+
const { brightness: a, contrast: s, saturation: h } = o, e = a * s, t = 127.5 * (1 - s), f = Math.abs(e - 1) > v || Math.abs(t) > v, i = new Uint8ClampedArray(256);
|
|
10
10
|
if (f)
|
|
11
|
-
for (let g = 0; g < 256; g++) i[g] = g * e +
|
|
12
|
-
const c = Math.abs(h - 1) > v,
|
|
11
|
+
for (let g = 0; g < 256; g++) i[g] = g * e + t;
|
|
12
|
+
const c = Math.abs(h - 1) > v, n = h, d = 0.213 + 0.787 * n, u = 0.715 - 0.715 * n, b = 0.072 - 0.072 * n, C = 0.213 - 0.213 * n, P = 0.715 + 0.285 * n, I = 0.072 - 0.072 * n, m = 0.213 - 0.213 * n, A = 0.715 - 0.715 * n, R = 0.072 + 0.928 * n;
|
|
13
13
|
for (let g = 0; g < r.length; g += 4) {
|
|
14
14
|
let l = r[g], p = r[g + 1], y = r[g + 2];
|
|
15
15
|
if (f && (l = i[l], p = i[p], y = i[y]), c) {
|
|
16
|
-
const W = d * l + u * p + b * y, E =
|
|
16
|
+
const W = d * l + u * p + b * y, E = C * l + P * p + I * y, O = m * l + A * p + R * y;
|
|
17
17
|
l = W, p = E, y = O;
|
|
18
18
|
}
|
|
19
19
|
r[g] = l, r[g + 1] = p, r[g + 2] = y;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
const k = /* @__PURE__ */ new WeakMap(),
|
|
23
|
-
function
|
|
22
|
+
const k = /* @__PURE__ */ new WeakMap(), z = 4;
|
|
23
|
+
function B(r) {
|
|
24
24
|
const o = r.naturalWidth;
|
|
25
25
|
return typeof o == "number" && o > 0 ? o : r.width;
|
|
26
26
|
}
|
|
@@ -28,7 +28,7 @@ function K(r) {
|
|
|
28
28
|
const o = r.naturalHeight;
|
|
29
29
|
return typeof o == "number" && o > 0 ? o : r.height;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function U(r, o) {
|
|
32
32
|
if (typeof OffscreenCanvas < "u")
|
|
33
33
|
return new OffscreenCanvas(r, o);
|
|
34
34
|
if (typeof document < "u") {
|
|
@@ -37,18 +37,18 @@ function B(r, o) {
|
|
|
37
37
|
}
|
|
38
38
|
throw new Error("image-adjustments: no canvas implementation available (no OffscreenCanvas, no DOM)");
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
const a =
|
|
40
|
+
function Y(r, o) {
|
|
41
|
+
const a = B(r), s = K(r);
|
|
42
42
|
if (a <= 0 || s <= 0)
|
|
43
43
|
throw new Error("image-adjustments: source has no pixels (width/height is 0)");
|
|
44
|
-
const h =
|
|
44
|
+
const h = U(a, s), e = h.getContext("2d");
|
|
45
45
|
if (!e)
|
|
46
46
|
throw new Error("image-adjustments: could not acquire a 2d context");
|
|
47
47
|
e.drawImage(r, 0, 0, a, s);
|
|
48
|
-
const
|
|
49
|
-
return
|
|
48
|
+
const t = e.getImageData(0, 0, a, s);
|
|
49
|
+
return _(t.data, o), e.putImageData(t, 0, 0), h;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function S(r, o) {
|
|
52
52
|
if (H(o)) return r;
|
|
53
53
|
const a = j(o);
|
|
54
54
|
let s = k.get(r);
|
|
@@ -57,18 +57,18 @@ function C(r, o) {
|
|
|
57
57
|
return s.delete(a), s.set(a, h), h;
|
|
58
58
|
let e;
|
|
59
59
|
try {
|
|
60
|
-
e =
|
|
61
|
-
} catch (
|
|
62
|
-
|
|
60
|
+
e = Y(r, o);
|
|
61
|
+
} catch (t) {
|
|
62
|
+
N.error("adjustment pixel pass failed — rendering UNADJUSTED source:", t), e = r;
|
|
63
63
|
}
|
|
64
|
-
for (s || (s = /* @__PURE__ */ new Map(), k.set(r, s)), s.set(a, e); s.size >
|
|
65
|
-
const
|
|
66
|
-
s.delete(
|
|
64
|
+
for (s || (s = /* @__PURE__ */ new Map(), k.set(r, s)), s.set(a, e); s.size > z; ) {
|
|
65
|
+
const t = s.keys().next().value;
|
|
66
|
+
s.delete(t);
|
|
67
67
|
}
|
|
68
68
|
return e;
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
function
|
|
70
|
+
L(S);
|
|
71
|
+
function Q(r, o) {
|
|
72
72
|
return !r.needsCropPixelConversion || r.cropWidth === void 0 ? r : {
|
|
73
73
|
...r,
|
|
74
74
|
cropX: (r.cropX ?? 0) * o.width,
|
|
@@ -78,9 +78,9 @@ function G(r, o) {
|
|
|
78
78
|
needsCropPixelConversion: !1
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
var
|
|
83
|
-
const s =
|
|
81
|
+
function Z(r, o, a) {
|
|
82
|
+
var t, f;
|
|
83
|
+
const s = S(
|
|
84
84
|
a,
|
|
85
85
|
o.adjustments
|
|
86
86
|
);
|
|
@@ -93,8 +93,8 @@ function Q(r, o, a) {
|
|
|
93
93
|
o.height / 2
|
|
94
94
|
);
|
|
95
95
|
r.beginPath();
|
|
96
|
-
const c = -o.width / 2,
|
|
97
|
-
r.moveTo(c + i,
|
|
96
|
+
const c = -o.width / 2, n = -o.height / 2, d = o.width, u = o.height;
|
|
97
|
+
r.moveTo(c + i, n), r.lineTo(c + d - i, n), r.arcTo(c + d, n, c + d, n + i, i), r.lineTo(c + d, n + u - i), r.arcTo(c + d, n + u, c + d - i, n + u, i), r.lineTo(c + i, n + u), r.arcTo(c, n + u, c, n + u - i, i), r.lineTo(c, n + i), r.arcTo(c, n, c + i, n, i), r.closePath(), r.clip();
|
|
98
98
|
}
|
|
99
99
|
if (o.cropX !== void 0 && o.cropWidth !== void 0 ? r.drawImage(
|
|
100
100
|
s,
|
|
@@ -106,7 +106,7 @@ function Q(r, o, a) {
|
|
|
106
106
|
-o.height / 2,
|
|
107
107
|
o.width,
|
|
108
108
|
o.height
|
|
109
|
-
) : r.drawImage(s, -o.width / 2, -o.height / 2, o.width, o.height), r.restore(), (
|
|
109
|
+
) : r.drawImage(s, -o.width / 2, -o.height / 2, o.width, o.height), r.restore(), (t = o.stroke) != null && t.enabled) {
|
|
110
110
|
const i = ((f = o.knockoutParts) == null ? void 0 : f.stroke) === !0, c = {
|
|
111
111
|
x: o.x,
|
|
112
112
|
y: o.y,
|
|
@@ -121,12 +121,12 @@ function Q(r, o, a) {
|
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
123
|
if (i) {
|
|
124
|
-
const
|
|
124
|
+
const n = r.canvas;
|
|
125
125
|
let d;
|
|
126
126
|
if (typeof OffscreenCanvas < "u")
|
|
127
|
-
d = new OffscreenCanvas(
|
|
127
|
+
d = new OffscreenCanvas(n.width, n.height);
|
|
128
128
|
else if (typeof document < "u")
|
|
129
|
-
d = document.createElement("canvas"), d.width =
|
|
129
|
+
d = document.createElement("canvas"), d.width = n.width, d.height = n.height;
|
|
130
130
|
else {
|
|
131
131
|
M(r, c);
|
|
132
132
|
return;
|
|
@@ -141,50 +141,50 @@ function Q(r, o, a) {
|
|
|
141
141
|
M(r, c);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function J(r, o) {
|
|
145
145
|
if (typeof OffscreenCanvas < "u")
|
|
146
146
|
return new OffscreenCanvas(r, o);
|
|
147
147
|
const a = document.createElement("canvas");
|
|
148
148
|
return a.width = r, a.height = o, a;
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function $(r, o) {
|
|
151
151
|
var e;
|
|
152
152
|
const a = o.opacity ?? 1, s = !!((e = o.stroke) != null && e.enabled);
|
|
153
|
-
a < 1 && s ?
|
|
153
|
+
a < 1 && s ? V(r, o, a) : T(r, o, a);
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function V(r, o, a) {
|
|
156
156
|
var d;
|
|
157
|
-
const s = o.transformData, e = (((d = o.stroke) == null ? void 0 : d.width) || 2) + 2,
|
|
157
|
+
const s = o.transformData, e = (((d = o.stroke) == null ? void 0 : d.width) || 2) + 2, t = Math.ceil(s.width + e * 2), f = Math.ceil(s.height + e * 2), i = J(t, f), c = i.getContext("2d");
|
|
158
158
|
if (!c) {
|
|
159
159
|
T(r, o, a);
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
|
-
const
|
|
162
|
+
const n = {
|
|
163
163
|
...o,
|
|
164
|
-
x:
|
|
164
|
+
x: t / 2,
|
|
165
165
|
y: f / 2
|
|
166
166
|
};
|
|
167
|
-
T(c,
|
|
167
|
+
T(c, n, 1), r.save(), r.translate(o.x, o.y), o.rotation && r.rotate(-o.rotation * Math.PI / 180), r.globalAlpha = a, r.drawImage(i, -t / 2, -f / 2), r.restore();
|
|
168
168
|
}
|
|
169
169
|
function T(r, o, a) {
|
|
170
170
|
var e;
|
|
171
171
|
const s = o.transformData, h = s.fillOpacity ?? 1;
|
|
172
|
-
if (r.save(), r.translate(o.x, o.y), o.rotation && r.rotate(-o.rotation * Math.PI / 180), r.globalAlpha = a * h, r.fillStyle = s
|
|
172
|
+
if (r.save(), r.translate(o.x, o.y), o.rotation && r.rotate(-o.rotation * Math.PI / 180), r.globalAlpha = a * h, r.fillStyle = X(r, s), r.beginPath(), w(r, s), r.fill(), r.restore(), (e = o.stroke) != null && e.enabled) {
|
|
173
173
|
r.save(), r.translate(o.x, o.y), o.rotation && r.rotate(-o.rotation * Math.PI / 180);
|
|
174
|
-
const
|
|
175
|
-
r.globalAlpha = a * (
|
|
174
|
+
const t = o.stroke;
|
|
175
|
+
r.globalAlpha = a * (t.opacity ?? 1), r.strokeStyle = t.color || "#000000", r.lineWidth = t.width || 2, r.lineCap = t.lineCap || "round", r.lineJoin = t.lineJoin || "round", r.beginPath(), w(r, s), r.stroke(), r.restore();
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
function w(r, o) {
|
|
179
179
|
const { shapeType: a, width: s, height: h } = o;
|
|
180
180
|
switch (a) {
|
|
181
181
|
case "rectangle": {
|
|
182
|
-
const e = o.borderRadius || 0,
|
|
182
|
+
const e = o.borderRadius || 0, t = -s / 2, f = -h / 2;
|
|
183
183
|
if (e > 0) {
|
|
184
184
|
const i = Math.min(e / 100 * Math.min(s, h), s / 2, h / 2);
|
|
185
|
-
r.roundRect(
|
|
185
|
+
r.roundRect(t, f, s, h, i);
|
|
186
186
|
} else
|
|
187
|
-
r.rect(
|
|
187
|
+
r.rect(t, f, s, h);
|
|
188
188
|
break;
|
|
189
189
|
}
|
|
190
190
|
case "circle": {
|
|
@@ -197,31 +197,31 @@ function w(r, o) {
|
|
|
197
197
|
break;
|
|
198
198
|
}
|
|
199
199
|
case "triangle": {
|
|
200
|
-
const e = s / 2,
|
|
201
|
-
r.moveTo(0, -
|
|
200
|
+
const e = s / 2, t = h / 2;
|
|
201
|
+
r.moveTo(0, -t), r.lineTo(e, t), r.lineTo(-e, t), r.closePath();
|
|
202
202
|
break;
|
|
203
203
|
}
|
|
204
204
|
case "polygon": {
|
|
205
|
-
const e = o.sides || 5,
|
|
205
|
+
const e = o.sides || 5, t = Math.min(s, h) / 2;
|
|
206
206
|
for (let f = 0; f < e; f++) {
|
|
207
|
-
const i = f * 2 * Math.PI / e - Math.PI / 2, c =
|
|
208
|
-
f === 0 ? r.moveTo(c,
|
|
207
|
+
const i = f * 2 * Math.PI / e - Math.PI / 2, c = t * Math.cos(i), n = t * Math.sin(i);
|
|
208
|
+
f === 0 ? r.moveTo(c, n) : r.lineTo(c, n);
|
|
209
209
|
}
|
|
210
210
|
r.closePath();
|
|
211
211
|
break;
|
|
212
212
|
}
|
|
213
213
|
case "star": {
|
|
214
|
-
const e = o.points || 5,
|
|
214
|
+
const e = o.points || 5, t = Math.min(s, h) / 2, f = t * (o.innerRadius || 0.4);
|
|
215
215
|
for (let i = 0; i < e * 2; i++) {
|
|
216
|
-
const c = i * Math.PI / e - Math.PI / 2,
|
|
216
|
+
const c = i * Math.PI / e - Math.PI / 2, n = i % 2 === 0 ? t : f, d = n * Math.cos(c), u = n * Math.sin(c);
|
|
217
217
|
i === 0 ? r.moveTo(d, u) : r.lineTo(d, u);
|
|
218
218
|
}
|
|
219
219
|
r.closePath();
|
|
220
220
|
break;
|
|
221
221
|
}
|
|
222
222
|
case "line": {
|
|
223
|
-
const e = s / 2,
|
|
224
|
-
r.rect(-e, -
|
|
223
|
+
const e = s / 2, t = h / 2;
|
|
224
|
+
r.rect(-e, -t, s, h);
|
|
225
225
|
break;
|
|
226
226
|
}
|
|
227
227
|
default:
|
|
@@ -229,71 +229,71 @@ function w(r, o) {
|
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
export {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
232
|
+
rr as AlignmentSnapSystem,
|
|
233
|
+
ao as AnyElementConfigSchema,
|
|
234
|
+
io as AnyTransformDataSchema,
|
|
235
|
+
zr as ArchTransform,
|
|
236
|
+
Br as ArtboardManager,
|
|
237
|
+
or as ArtboardRenderer,
|
|
238
238
|
Kr as AscendTransform,
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
239
|
+
sr as CanvasRenderer,
|
|
240
|
+
ho as CanvasStateV1Schema,
|
|
241
|
+
Ur as CircleTransform,
|
|
242
|
+
Yr as CustomTransform,
|
|
243
|
+
hr as DEFAULT_MAX_BITMAP_DIMENSION,
|
|
244
|
+
Jr as ElementStore,
|
|
245
|
+
cr as ExportManager,
|
|
246
|
+
Vr as FlagTransform,
|
|
247
|
+
qr as HybridHistoryManager,
|
|
248
|
+
dr as ImportManager,
|
|
249
|
+
er as InteractionStateMachine,
|
|
250
|
+
Gr as LeanTransform,
|
|
251
|
+
Qr as LogLevel,
|
|
252
|
+
tr as ResizePipeline,
|
|
253
|
+
co as SerializedArtboardSchema,
|
|
254
254
|
nr as SpacingSystem,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
255
|
+
ar as TransformHandles,
|
|
256
|
+
Zr as WaveTransform,
|
|
257
|
+
fr as WorkerExportManager,
|
|
258
|
+
ur as applySpaceLayoutRules,
|
|
259
|
+
gr as applyStrokeStyle,
|
|
260
|
+
lr as buildFontString,
|
|
261
|
+
$r as calculateFixedCornerPosition,
|
|
262
|
+
xr as calculateResizeHandles,
|
|
263
|
+
Dr as calculateRotationHandlePosition,
|
|
264
|
+
pr as clearImageBitmapCache,
|
|
265
|
+
yr as clearMaskCache,
|
|
266
|
+
Mr as clearRegisteredBitmapKeys,
|
|
267
|
+
vr as createCirclePath,
|
|
268
|
+
Tr as createImagePath,
|
|
269
|
+
F as createLogger,
|
|
270
|
+
kr as createRectPath,
|
|
271
|
+
wr as createTextPath,
|
|
272
|
+
Sr as getFontMetrics,
|
|
273
|
+
br as getSharedWorkerExportManager,
|
|
274
|
+
ro as hitTestCircle,
|
|
275
|
+
oo as hitTestRect,
|
|
276
|
+
Cr as invalidateMaskCache,
|
|
277
|
+
so as logger,
|
|
278
|
+
Pr as measureTextWidth,
|
|
279
|
+
Ir as removeFromImageBitmapCache,
|
|
280
|
+
mr as renderCustomTransform,
|
|
281
|
+
Z as renderImageElement,
|
|
282
282
|
M as renderImageStroke,
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
283
|
+
Ar as renderMultilineText,
|
|
284
|
+
Rr as renderPathStroke,
|
|
285
|
+
Wr as renderRichTextFillOnly,
|
|
286
|
+
$ as renderShapeElement,
|
|
287
|
+
Er as renderTextElement,
|
|
288
|
+
Or as renderTextFillOnly,
|
|
289
|
+
Hr as renderTextStroke,
|
|
290
|
+
jr as renderWithKnockout,
|
|
291
|
+
Fr as renderWithMasks,
|
|
292
|
+
Q as resolveServerCrop,
|
|
293
|
+
eo as splitRichTextIntoLines,
|
|
294
294
|
Lr as terminateSharedWorkerExportManager,
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
295
|
+
Xr as unregisterElementBitmaps,
|
|
296
|
+
to as wrapRichTextSpans,
|
|
297
|
+
Nr as wrapText
|
|
298
298
|
};
|
|
299
299
|
//# sourceMappingURL=internals.mjs.map
|