@snowcone-app/canvas 0.31.0 → 0.33.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.
Files changed (68) hide show
  1. package/ERROR_CONTRACT.md +11 -0
  2. package/STYLING_CONTRACT.md +5 -3
  3. package/dist/{CanvasRenderer-hpJ05JGO.js → CanvasRenderer-1j-twIbs.js} +443 -431
  4. package/dist/{CanvasRenderer-hpJ05JGO.js.map → CanvasRenderer-1j-twIbs.js.map} +1 -1
  5. package/dist/{CanvasStateV1-jLOibojY.js → CanvasStateV1-BmC1JfPv.js} +810 -802
  6. package/dist/{CanvasStateV1-jLOibojY.js.map → CanvasStateV1-BmC1JfPv.js.map} +1 -1
  7. package/dist/ContextualToolbars-CLDFENZq.js +6532 -0
  8. package/dist/ContextualToolbars-CLDFENZq.js.map +1 -0
  9. package/dist/{EditorCanvasImpl-P2GHPNA3.js → EditorCanvasImpl-XP_t-tNl.js} +7 -7
  10. package/dist/{EditorCanvasImpl-P2GHPNA3.js.map → EditorCanvasImpl-XP_t-tNl.js.map} +1 -1
  11. package/dist/{ExportManager-Bkzzyxgw.js → ExportManager-Ci81K6xA.js} +662 -518
  12. package/dist/ExportManager-Ci81K6xA.js.map +1 -0
  13. package/dist/{FontAnalyzer-BYhwxDhe.js → FontAnalyzer-BrKY6XYn.js} +1256 -1146
  14. package/dist/FontAnalyzer-BrKY6XYn.js.map +1 -0
  15. package/dist/{ImagePanel-CEr0_FYy.js → ImagePanel-ntJBepby.js} +6 -6
  16. package/dist/{ImagePanel-CEr0_FYy.js.map → ImagePanel-ntJBepby.js.map} +1 -1
  17. package/dist/{SnowconeCanvas-Fa0isFpO.js → SnowconeCanvas-wMLBZJ9z.js} +10 -10
  18. package/dist/{SnowconeCanvas-Fa0isFpO.js.map → SnowconeCanvas-wMLBZJ9z.js.map} +1 -1
  19. package/dist/advanced.mjs +14 -14
  20. package/dist/components/ImageToolbar.d.ts +8 -0
  21. package/dist/components/ShapeToolbar.d.ts +8 -0
  22. package/dist/components/TextToolbar.d.ts +5 -1
  23. package/dist/components/toolbars/EmbeddedToolbarLayout.d.ts +6 -0
  24. package/dist/components/toolbars/FloatingPanels.d.ts +10 -0
  25. package/dist/components/toolbars/GroupElementToolbar.d.ts +8 -0
  26. package/dist/components/toolbars/SecondaryPanels.d.ts +37 -1
  27. package/dist/components/toolbars/alignButtons.d.ts +13 -0
  28. package/dist/components/toolbars/index.d.ts +5 -3
  29. package/dist/core/BaseElement.d.ts +2 -1
  30. package/dist/core/shape-fill.d.ts +31 -0
  31. package/dist/{custom-icons-Co4rcW0S.js → custom-icons-DTWtkJ9N.js} +2 -2
  32. package/dist/{custom-icons-Co4rcW0S.js.map → custom-icons-DTWtkJ9N.js.map} +1 -1
  33. package/dist/{design-builder-CBG2hKc8.js → design-builder-BpbYUYtK.js} +55 -55
  34. package/dist/{design-builder-CBG2hKc8.js.map → design-builder-BpbYUYtK.js.map} +1 -1
  35. package/dist/{embed-D4TIzO7g.js → embed-VTcnrkRj.js} +10 -10
  36. package/dist/{embed-D4TIzO7g.js.map → embed-VTcnrkRj.js.map} +1 -1
  37. package/dist/embed.mjs +7 -7
  38. package/dist/errors/editorError.d.ts +7 -0
  39. package/dist/{guards-DgZuwVgu.js → guards-BhaQgJrE.js} +2 -2
  40. package/dist/{guards-DgZuwVgu.js.map → guards-BhaQgJrE.js.map} +1 -1
  41. package/dist/hooks/elementPatch.d.ts +8 -3
  42. package/dist/index.mjs +9 -9
  43. package/dist/internals.mjs +123 -123
  44. package/dist/internals.mjs.map +1 -1
  45. package/dist/rendering/LayerEffectsRenderer.d.ts +24 -0
  46. package/dist/rendering/renderer-types.d.ts +3 -1
  47. package/dist/state/CanvasStateV1.d.ts +17 -0
  48. package/dist/style.css +1 -1
  49. package/dist/{template-fields-CvFcr5zy.js → template-fields-D-2oLhCi.js} +5 -5
  50. package/dist/{template-fields-CvFcr5zy.js.map → template-fields-D-2oLhCi.js.map} +1 -1
  51. package/dist/testing.mjs +3 -3
  52. package/dist/types/index.d.ts +84 -1
  53. package/dist/types/public.d.ts +3 -2
  54. package/dist/{useCommands-bPXY9rCh.js → useCommands-DwnZHUg8.js} +435 -418
  55. package/dist/useCommands-DwnZHUg8.js.map +1 -0
  56. package/dist/{usePieceGuideBundle-Bj98nPk0.js → usePieceGuideBundle-CnSmYrmM.js} +2 -2
  57. package/dist/{usePieceGuideBundle-Bj98nPk0.js.map → usePieceGuideBundle-CnSmYrmM.js.map} +1 -1
  58. package/dist/utils/featureApplied.d.ts +4 -0
  59. package/dist/{validation-CsTlSvJJ.js → validation-CSa86fDE.js} +11 -11
  60. package/dist/{validation-CsTlSvJJ.js.map → validation-CSa86fDE.js.map} +1 -1
  61. package/dist/workers/export-worker.bundle.string.d.ts +1 -1
  62. package/example/package.json +1 -1
  63. package/package.json +1 -1
  64. package/dist/ContextualToolbars-DRbuUE7W.js +0 -6061
  65. package/dist/ContextualToolbars-DRbuUE7W.js.map +0 -1
  66. package/dist/ExportManager-Bkzzyxgw.js.map +0 -1
  67. package/dist/FontAnalyzer-BYhwxDhe.js.map +0 -1
  68. 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-bPXY9rCh.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-D4TIzO7g.js";
3
- import { E as L, y as k } from "./FontAnalyzer-BYhwxDhe.js";
4
- import { D as A, d as G, j as K, i as M, u as _ } from "./design-builder-CBG2hKc8.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-CvFcr5zy.js";
6
- import { c as X, e as Z, l as $, r as ee } from "./ExportManager-Bkzzyxgw.js";
7
- import { s as ae } from "./CanvasStateV1-jLOibojY.js";
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-VTcnrkRj.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-BYhwxDhe.js";
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-DgZuwVgu.js.map
24
+ //# sourceMappingURL=guards-BhaQgJrE.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"guards-DgZuwVgu.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;"}
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 { TextAlign, ImageAdjustments } from '../types/index.js';
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-bPXY9rCh.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-bPXY9rCh.js";
3
- import { E as F, S as L, S as _, u as O, a as R } from "./SnowconeCanvas-Fa0isFpO.js";
4
- import { u as m, a as d } from "./design-builder-CBG2hKc8.js";
5
- import { C as z, D as w, d as D, s as K } from "./design-builder-CBG2hKc8.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-CvFcr5zy.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-CsTlSvJJ.js";
8
- import { c as ae, e as te, l as oe, r as re } from "./ExportManager-Bkzzyxgw.js";
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-wMLBZJ9z.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-CSa86fDE.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-jLOibojY.js";
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;
@@ -1,26 +1,26 @@
1
- import { A as D, a as rr, C as or, I as sr, R as er, S as nr, T as tr } from "./CanvasRenderer-hpJ05JGO.js";
2
- import { a as M } from "./ExportManager-Bkzzyxgw.js";
3
- import { D as ir, E as hr, I as cr, W as dr, b as fr, d as ur, f as gr, h as lr, i as pr, j as yr, k as Mr, m as vr, n as Tr, o as kr, p as wr, q as Cr, s as br, t as Sr, u as Pr, v as Ir, w as mr, x as Ar, y as Rr, z as Wr, A as Er, B as Or, C as Hr, F as jr, G as Lr, H as Fr, J as Xr } from "./ExportManager-Bkzzyxgw.js";
4
- import { K as H, L as j, c as L, M as F } from "./FontAnalyzer-BYhwxDhe.js";
5
- import { N as _r, O as zr, Q as Kr, V as Br, W as Ur, X as Yr, Y as Jr, Z as Vr, _ as qr, $ as Gr, a0 as Qr, a1 as Zr, a2 as $r, a3 as xr, a4 as Dr, a5 as ro, a6 as oo, a7 as so, a8 as eo } from "./FontAnalyzer-BYhwxDhe.js";
6
- import { A as to, e as ao, C as io, S as ho } from "./CanvasStateV1-jLOibojY.js";
7
- const X = L("image-adjustments"), v = 1e-3;
8
- function N(r, o) {
9
- const { brightness: a, contrast: s, saturation: h } = o, e = a * s, n = 127.5 * (1 - s), f = Math.abs(e - 1) > v || Math.abs(n) > v, i = new Uint8ClampedArray(256);
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 + n;
12
- const c = Math.abs(h - 1) > v, t = h, d = 0.213 + 0.787 * t, u = 0.715 - 0.715 * t, b = 0.072 - 0.072 * t, S = 0.213 - 0.213 * t, P = 0.715 + 0.285 * t, I = 0.072 - 0.072 * t, m = 0.213 - 0.213 * t, A = 0.715 - 0.715 * t, R = 0.072 + 0.928 * t;
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 = S * l + P * p + I * y, O = m * l + A * p + R * y;
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(), _ = 4;
23
- function z(r) {
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 B(r, o) {
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 U(r, o) {
41
- const a = z(r), s = K(r);
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 = B(a, s), e = h.getContext("2d");
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 n = e.getImageData(0, 0, a, s);
49
- return N(n.data, o), e.putImageData(n, 0, 0), h;
48
+ const t = e.getImageData(0, 0, a, s);
49
+ return _(t.data, o), e.putImageData(t, 0, 0), h;
50
50
  }
51
- function C(r, o) {
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 = U(r, o);
61
- } catch (n) {
62
- X.error("adjustment pixel pass failed — rendering UNADJUSTED source:", n), e = r;
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 n = s.keys().next().value;
66
- s.delete(n);
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
- F(C);
71
- function G(r, o) {
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 Q(r, o, a) {
82
- var n, f;
83
- const s = C(
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, t = -o.height / 2, d = o.width, u = o.height;
97
- r.moveTo(c + i, t), r.lineTo(c + d - i, t), r.arcTo(c + d, t, c + d, t + i, i), r.lineTo(c + d, t + u - i), r.arcTo(c + d, t + u, c + d - i, t + u, i), r.lineTo(c + i, t + u), r.arcTo(c, t + u, c, t + u - i, i), r.lineTo(c, t + i), r.arcTo(c, t, c + i, t, i), r.closePath(), r.clip();
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(), (n = o.stroke) != null && n.enabled) {
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 t = r.canvas;
124
+ const n = r.canvas;
125
125
  let d;
126
126
  if (typeof OffscreenCanvas < "u")
127
- d = new OffscreenCanvas(t.width, t.height);
127
+ d = new OffscreenCanvas(n.width, n.height);
128
128
  else if (typeof document < "u")
129
- d = document.createElement("canvas"), d.width = t.width, d.height = t.height;
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 Y(r, o) {
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 Z(r, o) {
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 ? J(r, o, a) : T(r, o, a);
153
+ a < 1 && s ? V(r, o, a) : T(r, o, a);
154
154
  }
155
- function J(r, o, a) {
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, n = Math.ceil(s.width + e * 2), f = Math.ceil(s.height + e * 2), i = Y(n, f), c = i.getContext("2d");
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 t = {
162
+ const n = {
163
163
  ...o,
164
- x: n / 2,
164
+ x: t / 2,
165
165
  y: f / 2
166
166
  };
167
- T(c, t, 1), r.save(), r.translate(o.x, o.y), o.rotation && r.rotate(-o.rotation * Math.PI / 180), r.globalAlpha = a, r.drawImage(i, -n / 2, -f / 2), r.restore();
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.fillColor || "#3b82f6", r.beginPath(), w(r, s), r.fill(), r.restore(), (e = o.stroke) != null && e.enabled) {
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 n = o.stroke;
175
- r.globalAlpha = a * (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(), w(r, s), r.stroke(), r.restore();
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, n = -s / 2, f = -h / 2;
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(n, f, s, h, i);
185
+ r.roundRect(t, f, s, h, i);
186
186
  } else
187
- r.rect(n, f, s, h);
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, n = h / 2;
201
- r.moveTo(0, -n), r.lineTo(e, n), r.lineTo(-e, n), r.closePath();
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, n = Math.min(s, h) / 2;
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 = n * Math.cos(i), t = n * Math.sin(i);
208
- f === 0 ? r.moveTo(c, t) : r.lineTo(c, t);
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, n = Math.min(s, h) / 2, f = n * (o.innerRadius || 0.4);
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, t = i % 2 === 0 ? n : f, d = t * Math.cos(c), u = t * Math.sin(c);
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, n = h / 2;
224
- r.rect(-e, -n, s, h);
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
- D as AlignmentSnapSystem,
233
- to as AnyElementConfigSchema,
234
- ao as AnyTransformDataSchema,
235
- _r as ArchTransform,
236
- zr as ArtboardManager,
237
- rr as ArtboardRenderer,
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
- or as CanvasRenderer,
240
- io as CanvasStateV1Schema,
241
- Br as CircleTransform,
242
- Ur as CustomTransform,
243
- ir as DEFAULT_MAX_BITMAP_DIMENSION,
244
- Yr as ElementStore,
245
- hr as ExportManager,
246
- Jr as FlagTransform,
247
- Vr as HybridHistoryManager,
248
- cr as ImportManager,
249
- sr as InteractionStateMachine,
250
- qr as LeanTransform,
251
- Gr as LogLevel,
252
- er as ResizePipeline,
253
- ho as SerializedArtboardSchema,
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
- tr as TransformHandles,
256
- Qr as WaveTransform,
257
- dr as WorkerExportManager,
258
- fr as applySpaceLayoutRules,
259
- ur as applyStrokeStyle,
260
- gr as buildFontString,
261
- Zr as calculateFixedCornerPosition,
262
- $r as calculateResizeHandles,
263
- xr as calculateRotationHandlePosition,
264
- lr as clearImageBitmapCache,
265
- pr as clearMaskCache,
266
- yr as clearRegisteredBitmapKeys,
267
- Mr as createCirclePath,
268
- vr as createImagePath,
269
- L as createLogger,
270
- Tr as createRectPath,
271
- kr as createTextPath,
272
- wr as getFontMetrics,
273
- Cr as getSharedWorkerExportManager,
274
- Dr as hitTestCircle,
275
- ro as hitTestRect,
276
- br as invalidateMaskCache,
277
- oo as logger,
278
- Sr as measureTextWidth,
279
- Pr as removeFromImageBitmapCache,
280
- Ir as renderCustomTransform,
281
- Q as renderImageElement,
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
- mr as renderMultilineText,
284
- Ar as renderPathStroke,
285
- Rr as renderRichTextFillOnly,
286
- Z as renderShapeElement,
287
- Wr as renderTextElement,
288
- Er as renderTextFillOnly,
289
- Or as renderTextStroke,
290
- Hr as renderWithKnockout,
291
- jr as renderWithMasks,
292
- G as resolveServerCrop,
293
- so as splitRichTextIntoLines,
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
- Fr as unregisterElementBitmaps,
296
- eo as wrapRichTextSpans,
297
- Xr as wrapText
295
+ Xr as unregisterElementBitmaps,
296
+ to as wrapRichTextSpans,
297
+ Nr as wrapText
298
298
  };
299
299
  //# sourceMappingURL=internals.mjs.map