@snowcone-app/canvas 0.33.1 → 0.35.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 (50) hide show
  1. package/dist/{CanvasRenderer-1j-twIbs.js → CanvasRenderer-BHBCxI-B.js} +4 -4
  2. package/dist/{CanvasRenderer-1j-twIbs.js.map → CanvasRenderer-BHBCxI-B.js.map} +1 -1
  3. package/dist/{CanvasStateV1-BmC1JfPv.js → CanvasStateV1-BoG8ld4D.js} +3 -3
  4. package/dist/{CanvasStateV1-BmC1JfPv.js.map → CanvasStateV1-BoG8ld4D.js.map} +1 -1
  5. package/dist/{ContextualToolbars-BrllZJTn.js → ContextualToolbars-TCO7dzu6.js} +6 -6
  6. package/dist/{ContextualToolbars-BrllZJTn.js.map → ContextualToolbars-TCO7dzu6.js.map} +1 -1
  7. package/dist/{EditorCanvasImpl-BiNG1dIj.js → EditorCanvasImpl-Dl75xnjk.js} +7 -7
  8. package/dist/{EditorCanvasImpl-BiNG1dIj.js.map → EditorCanvasImpl-Dl75xnjk.js.map} +1 -1
  9. package/dist/{ExportManager-Ci81K6xA.js → ExportManager-D1PAlOiE.js} +2 -2
  10. package/dist/{ExportManager-Ci81K6xA.js.map → ExportManager-D1PAlOiE.js.map} +1 -1
  11. package/dist/{FontAnalyzer-BrKY6XYn.js → FontAnalyzer-CEYA_6fY.js} +476 -439
  12. package/dist/FontAnalyzer-CEYA_6fY.js.map +1 -0
  13. package/dist/ImagePanel-Duh1AMdF.js +984 -0
  14. package/dist/ImagePanel-Duh1AMdF.js.map +1 -0
  15. package/dist/{SnowconeCanvas-DjQFFTDh.js → SnowconeCanvas-h8cfofsO.js} +296 -292
  16. package/dist/{SnowconeCanvas-DjQFFTDh.js.map → SnowconeCanvas-h8cfofsO.js.map} +1 -1
  17. package/dist/advanced.mjs +14 -14
  18. package/dist/api/stable.d.ts +1 -0
  19. package/dist/components/ImageBrowserDrawer.d.ts +4 -1
  20. package/dist/components/embed/SnowconeCanvas.d.ts +9 -0
  21. package/dist/contexts/CanvasServicesContext.d.ts +17 -1
  22. package/dist/core/ImageElement.d.ts +6 -0
  23. package/dist/core/ImageLoadEvents.d.ts +33 -0
  24. package/dist/{custom-icons-QEBlxVyq.js → custom-icons-DYIOjjXt.js} +2 -2
  25. package/dist/{custom-icons-QEBlxVyq.js.map → custom-icons-DYIOjjXt.js.map} +1 -1
  26. package/dist/{design-builder-D4izkvlb.js → design-builder-CqgTpp9B.js} +2 -2
  27. package/dist/{design-builder-D4izkvlb.js.map → design-builder-CqgTpp9B.js.map} +1 -1
  28. package/dist/{embed-C6kwN09N.js → embed-p_FskJ1G.js} +10 -10
  29. package/dist/{embed-C6kwN09N.js.map → embed-p_FskJ1G.js.map} +1 -1
  30. package/dist/embed.mjs +7 -7
  31. package/dist/{guards-BhaQgJrE.js → guards-DldCuuJq.js} +2 -2
  32. package/dist/{guards-BhaQgJrE.js.map → guards-DldCuuJq.js.map} +1 -1
  33. package/dist/index.mjs +9 -9
  34. package/dist/internals.mjs +6 -6
  35. package/dist/services/imageSearch.d.ts +24 -0
  36. package/dist/style.css +1 -1
  37. package/dist/{template-fields-xVQZRXvc.js → template-fields-jgE6czak.js} +5 -5
  38. package/dist/{template-fields-xVQZRXvc.js.map → template-fields-jgE6czak.js.map} +1 -1
  39. package/dist/testing.mjs +3 -3
  40. package/dist/{useCommands-DmewMc5w.js → useCommands-D16Tq-B-.js} +517 -499
  41. package/dist/{useCommands-DmewMc5w.js.map → useCommands-D16Tq-B-.js.map} +1 -1
  42. package/dist/{usePieceGuideBundle-CnSmYrmM.js → usePieceGuideBundle-BUQKb0Ja.js} +2 -2
  43. package/dist/{usePieceGuideBundle-CnSmYrmM.js.map → usePieceGuideBundle-BUQKb0Ja.js.map} +1 -1
  44. package/dist/{validation-CA6cMSOX.js → validation-8QF2gWih.js} +11 -11
  45. package/dist/{validation-CA6cMSOX.js.map → validation-8QF2gWih.js.map} +1 -1
  46. package/example/package.json +1 -1
  47. package/package.json +1 -1
  48. package/dist/FontAnalyzer-BrKY6XYn.js.map +0 -1
  49. package/dist/ImagePanel-Ckpc6QqR.js +0 -951
  50. package/dist/ImagePanel-Ckpc6QqR.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-DmewMc5w.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-C6kwN09N.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-D4izkvlb.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-xVQZRXvc.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";
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-D16Tq-B-.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-p_FskJ1G.js";
3
+ import { E as L, y as k } from "./FontAnalyzer-CEYA_6fY.js";
4
+ import { D as A, d as G, j as K, i as M, u as _ } from "./design-builder-CqgTpp9B.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-jgE6czak.js";
6
+ import { c as X, e as Z, l as $, r as ee } from "./ExportManager-D1PAlOiE.js";
7
+ import { s as ae } from "./CanvasStateV1-BoG8ld4D.js";
8
8
  export {
9
9
  a as CanvasServicesProvider,
10
10
  A as DesignBuilder,
@@ -1,4 +1,4 @@
1
- import { G as n, I as t, P as a, S as s, T as i } from "./FontAnalyzer-BrKY6XYn.js";
1
+ import { G as n, I as t, P as a, S as s, T as i } from "./FontAnalyzer-CEYA_6fY.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-BhaQgJrE.js.map
24
+ //# sourceMappingURL=guards-DldCuuJq.js.map
@@ -1 +1 @@
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;"}
1
+ {"version":3,"file":"guards-DldCuuJq.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;"}
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
- import { e as u } from "./useCommands-DmewMc5w.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-DmewMc5w.js";
3
- import { E as F, S as L, S as _, u as O, a as R } from "./SnowconeCanvas-DjQFFTDh.js";
4
- import { u as m, a as d } from "./design-builder-D4izkvlb.js";
5
- import { C as z, D as w, d as D, s as K } from "./design-builder-D4izkvlb.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-xVQZRXvc.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-CA6cMSOX.js";
8
- import { c as ae, e as te, l as oe, r as re } from "./ExportManager-Ci81K6xA.js";
1
+ import { e as u } from "./useCommands-D16Tq-B-.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-D16Tq-B-.js";
3
+ import { E as F, S as L, S as _, u as O, a as R } from "./SnowconeCanvas-h8cfofsO.js";
4
+ import { u as m, a as d } from "./design-builder-CqgTpp9B.js";
5
+ import { C as z, D as w, d as D, s as K } from "./design-builder-CqgTpp9B.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-jgE6czak.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-8QF2gWih.js";
8
+ import { c as ae, e as te, l as oe, r as re } from "./ExportManager-D1PAlOiE.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-BmC1JfPv.js";
10
+ import { d as de, m as Ce, s as Se, v as Ee } from "./CanvasStateV1-BoG8ld4D.js";
11
11
  function E() {
12
12
  const { isCanvasReady: e } = m();
13
13
  return e;
@@ -1,9 +1,9 @@
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";
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-BHBCxI-B.js";
2
+ import { a as M } from "./ExportManager-D1PAlOiE.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-D1PAlOiE.js";
4
+ import { M as H, N as j, c as F, O as L, Q as X } from "./FontAnalyzer-CEYA_6fY.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-CEYA_6fY.js";
6
+ import { A as ao, e as io, C as ho, S as co } from "./CanvasStateV1-BoG8ld4D.js";
7
7
  const N = F("image-adjustments"), v = 1e-3;
8
8
  function _(r, o) {
9
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);
@@ -123,6 +123,16 @@ export interface GenerateResponse {
123
123
  * and spends the per-op budget.
124
124
  */
125
125
  export type BgRemoveProvider = (imageUrl: string) => Promise<string>;
126
+ /**
127
+ * Provider that re-hosts an externally-sourced image (a picked stock photo)
128
+ * into the embedder's own durable storage, returning the durable URL the canvas
129
+ * then places and saves. Usually created from a URL via
130
+ * {@link createProxyIngestImage}; the server behind that URL fetches the image
131
+ * and writes it to (shop-scoped) storage. Returns the input unchanged for
132
+ * sources that have no server-fetchable URL (`data:` / `blob:`) or that are
133
+ * already on a durable origin — see {@link createProxyIngestImage}.
134
+ */
135
+ export type IngestImageProvider = (url: string) => Promise<string>;
126
136
  /**
127
137
  * Provider interface the Image Browser's AI tab consumes. Usually created from
128
138
  * a URL via {@link createProxyGenerate}; the server behind that URL picks the
@@ -159,3 +169,17 @@ export declare function createProxyGenerate(url: string): GenerateProvider;
159
169
  * vendor key lives there and the server spends the per-op budget.
160
170
  */
161
171
  export declare function createProxyBgRemove(url: string): BgRemoveProvider;
172
+ /**
173
+ * Create an {@link IngestImageProvider} backed by a same-origin proxy route
174
+ * (e.g. the www `/api/ingest-image` route).
175
+ *
176
+ * `data:` / `blob:` sources have no server-fetchable URL, so they're returned
177
+ * unchanged — the picked image is still usable, just not re-hosted. Everything
178
+ * else is sent as `{ url }`; the route returns `{ imageUrl }` with the durable
179
+ * hosted URL (it short-circuits and echoes URLs already on the embedder's own
180
+ * origins, so AI-generated / already-durable picks cost nothing).
181
+ *
182
+ * @param url The embedder-hosted route. Host this URL on your server; it writes
183
+ * to your (shop-scoped) storage.
184
+ */
185
+ export declare function createProxyIngestImage(url: string): IngestImageProvider;