@snowcone-app/canvas 0.21.0 → 0.21.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.
Files changed (41) hide show
  1. package/README.md +7 -2
  2. package/dist/{CanvasRenderer-CwiYq8qg.js → CanvasRenderer-B0szG0Us.js} +45 -44
  3. package/dist/{CanvasRenderer-CwiYq8qg.js.map → CanvasRenderer-B0szG0Us.js.map} +1 -1
  4. package/dist/{CanvasStateV1-BFabcAKC.js → CanvasStateV1-DmZ1Qvvn.js} +38 -38
  5. package/dist/{CanvasStateV1-BFabcAKC.js.map → CanvasStateV1-DmZ1Qvvn.js.map} +1 -1
  6. package/dist/{ContextualToolbars--vTtorNg.js → ContextualToolbars-BYnovWnN.js} +1372 -1422
  7. package/dist/ContextualToolbars-BYnovWnN.js.map +1 -0
  8. package/dist/{EditorCanvasImpl-2ZgIUVpK.js → EditorCanvasImpl-BmLHjXe7.js} +8 -8
  9. package/dist/{EditorCanvasImpl-2ZgIUVpK.js.map → EditorCanvasImpl-BmLHjXe7.js.map} +1 -1
  10. package/dist/{ExportManager-DK7CdI-G.js → ExportManager-DoU4VK6h.js} +603 -498
  11. package/dist/ExportManager-DoU4VK6h.js.map +1 -0
  12. package/dist/{FontAnalyzer-BpsTYowD.js → FontAnalyzer-CwIpgTGd.js} +309 -299
  13. package/dist/{FontAnalyzer-BpsTYowD.js.map → FontAnalyzer-CwIpgTGd.js.map} +1 -1
  14. package/dist/{SnowconeCanvas-DqZicdxK.js → SnowconeCanvas-Bj2773ym.js} +9 -9
  15. package/dist/{SnowconeCanvas-DqZicdxK.js.map → SnowconeCanvas-Bj2773ym.js.map} +1 -1
  16. package/dist/{UnifiedFontService-B1PGVu8O.js → UnifiedFontService-C8gaspRD.js} +812 -816
  17. package/dist/UnifiedFontService-C8gaspRD.js.map +1 -0
  18. package/dist/advanced.mjs +13 -13
  19. package/dist/{design-builder-CPF60RU2.js → design-builder-CT4DHIPe.js} +2 -2
  20. package/dist/{design-builder-CPF60RU2.js.map → design-builder-CT4DHIPe.js.map} +1 -1
  21. package/dist/{editorErrors-CK1RISFa.js → editorErrors-B2mb1sVN.js} +2 -2
  22. package/dist/{editorErrors-CK1RISFa.js.map → editorErrors-B2mb1sVN.js.map} +1 -1
  23. package/dist/{embed-2tp6Ue90.js → embed-pM7ZkFuz.js} +10 -10
  24. package/dist/{embed-2tp6Ue90.js.map → embed-pM7ZkFuz.js.map} +1 -1
  25. package/dist/embed.mjs +6 -6
  26. package/dist/index.mjs +8 -8
  27. package/dist/internals.mjs +11 -11
  28. package/dist/rendering/element-painters.d.ts +4 -2
  29. package/dist/{template-fields-FgImixyv.js → template-fields-BsnHMf1i.js} +6 -6
  30. package/dist/{template-fields-FgImixyv.js.map → template-fields-BsnHMf1i.js.map} +1 -1
  31. package/dist/testing.mjs +4 -4
  32. package/dist/{usePieceGuideBundle-Ctnu5k2D.js → usePieceGuideBundle-CbJJg66S.js} +2 -2
  33. package/dist/{usePieceGuideBundle-Ctnu5k2D.js.map → usePieceGuideBundle-CbJJg66S.js.map} +1 -1
  34. package/dist/{validation-3YEMnKLB.js → validation-DdVeWnlo.js} +9 -9
  35. package/dist/{validation-3YEMnKLB.js.map → validation-DdVeWnlo.js.map} +1 -1
  36. package/example/package.json +1 -1
  37. package/example/src/Widget.tsx +3 -0
  38. package/package.json +3 -2
  39. package/dist/ContextualToolbars--vTtorNg.js.map +0 -1
  40. package/dist/ExportManager-DK7CdI-G.js.map +0 -1
  41. package/dist/UnifiedFontService-B1PGVu8O.js.map +0 -1
package/README.md CHANGED
@@ -36,8 +36,10 @@ npm install @snowcone-app/canvas
36
36
  The fastest path to a working integration. A live product preview, one
37
37
  personalized text layer, and a completeness-gated add-to-cart — the full
38
38
  design editor never loads. This file ships in this package at
39
- [`example/src/Widget.tsx`](./example/src/Widget.tsx); copy it and change the
40
- design, the product ids, and the parts.
39
+ [`example/src/Widget.tsx`](./example/src/Widget.tsx) (reading this in the
40
+ monorepo instead of the npm tarball? It lives at
41
+ `packages/canvas/fixtures/no-canvas-widget/` there — `example/` is assembled at
42
+ publish); copy it and change the design, the product ids, and the parts.
41
43
 
42
44
  <!-- canonical-example (verbatim from example/src/Widget.tsx; drift-gated) -->
43
45
 
@@ -60,6 +62,9 @@ const product = {
60
62
  productId: 'BEEB77',
61
63
  mockupIds: ['FV1qjO'],
62
64
  placements: ['Front'],
65
+ // BEEB77 has a COLOR axis (Frame) — a color product REQUIRES variantId, or
66
+ // a live render times out. Read real ids from the catalog with getProduct().
67
+ variantId: 'Pv1sLC',
63
68
  };
64
69
 
65
70
  export function PersonalizationWidget({
@@ -1,5 +1,5 @@
1
- import { V as ee, X as ne, ap as tt, Y as zt, aC as se, aA as oe, at as Vt, az as ie, as as ht, aD as ae, aE as Ft, aF as re, aG as le, c as $t, G as he, I as jt, P as ce, S as de, T as fe, aH as ge, aI as ue, aJ as pe, aK as ye, a3 as qt, $ as Ut, a5 as ft, a0 as Zt, a1 as Ht, a4 as be, a7 as Se, aL as Ot, aM as me, aN as Te, aO as ve, aP as we, aQ as Ce, aR as Q } from "./FontAnalyzer-BpsTYowD.js";
2
- import { T as Bt, a as Me, t as xe, J as Re, y as kt, K as Gt, L as ke, M as Pe } from "./ExportManager-DK7CdI-G.js";
1
+ import { V as ee, X as ne, ar as tt, Y as zt, aE as se, aC as oe, av as Vt, aB as ie, au as ht, aF as ae, aG as Ft, aH as re, aI as le, c as $t, G as he, I as jt, P as ce, S as de, T as fe, aJ as ge, aK as ue, aL as pe, aM as ye, a3 as qt, $ as Ut, a5 as ft, a0 as Zt, a1 as Ht, a4 as be, a7 as Se, aN as Ot, aO as me, aP as Te, aQ as ve, aR as we, aS as Ce, aT as Q } from "./FontAnalyzer-CwIpgTGd.js";
2
+ import { T as Bt, a as Me, u as xe, K as Re, z as kt, L as Gt, M as ke, N as Pe, O as Ae } from "./ExportManager-DoU4VK6h.js";
3
3
  const it = {
4
4
  // Canvas-specific
5
5
  canvas: {
@@ -14,30 +14,30 @@ const it = {
14
14
  spacingLabelFontSize: 11,
15
15
  spacingLabelFontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
16
16
  }
17
- }, Ae = 2, Mt = 6, Ee = 16, Ie = 5, He = 5, Jt = 0.5;
17
+ }, Ee = 2, Mt = 6, Ie = 16, He = 5, Be = 5, Jt = 0.5;
18
18
  function Yt(C) {
19
- return Ae / C;
19
+ return Ee / C;
20
20
  }
21
- function Ge(C) {
21
+ function Ye(C) {
22
22
  return Mt / C;
23
23
  }
24
- function Be(C) {
25
- return Ee / C;
24
+ function Le(C) {
25
+ return Ie / C;
26
26
  }
27
- function Ye(C) {
28
- return [Ie / C, He / C];
27
+ function Xe(C) {
28
+ return [He / C, Be / C];
29
29
  }
30
- function Le(C, t, e, o) {
30
+ function We(C, t, e, o) {
31
31
  C.save();
32
32
  const n = Jt / o;
33
33
  C.translate(t, e), C.scale(n, n), C.strokeStyle = "#000", C.lineWidth = 1.5, C.lineCap = "round", C.lineJoin = "round", C.translate(-12, -12), C.beginPath(), C.moveTo(21, 12), C.arc(12, 12, 9, 0, -Math.PI / 2, !0), C.bezierCurveTo(3.5, 4.5, 4, 6, 3, 8), C.stroke(), C.beginPath(), C.moveTo(3, 3), C.lineTo(3, 8), C.lineTo(8, 8), C.stroke(), C.beginPath(), C.moveTo(3, 12), C.arc(12, 12, 9, Math.PI, Math.PI / 2, !0), C.bezierCurveTo(20.5, 19.5, 20, 18, 21, 16), C.stroke(), C.beginPath(), C.moveTo(16, 16), C.lineTo(21, 16), C.lineTo(21, 21), C.stroke(), C.restore();
34
34
  }
35
- function Xe(C, t, e, o = 1, n = "#3b82f6", s = !1) {
36
- const i = Be(o);
37
- C.save(), C.fillStyle = "#fff", C.strokeStyle = n, C.lineWidth = s ? Yt(o) * 1.25 : Yt(o), C.beginPath(), C.arc(t, e, i, 0, Math.PI * 2), C.fill(), C.stroke(), Le(C, t, e, o), C.restore();
35
+ function Ne(C, t, e, o = 1, n = "#3b82f6", s = !1) {
36
+ const i = Le(o);
37
+ C.save(), C.fillStyle = "#fff", C.strokeStyle = n, C.lineWidth = s ? Yt(o) * 1.25 : Yt(o), C.beginPath(), C.arc(t, e, i, 0, Math.PI * 2), C.fill(), C.stroke(), We(C, t, e, o), C.restore();
38
38
  }
39
39
  const Xt = Mt * 2;
40
- class Ne {
40
+ class Ke {
41
41
  constructor() {
42
42
  this.resizeHandles = [], this.rotationHandle = null, this.elementRotation = 0, this.rotationAnchor = { x: 0, y: 0 };
43
43
  }
@@ -153,7 +153,7 @@ class Ne {
153
153
  );
154
154
  }
155
155
  }
156
- class We {
156
+ class De {
157
157
  /**
158
158
  * Calculate new dimensions and position for a resize operation
159
159
  */
@@ -275,7 +275,7 @@ class We {
275
275
  return n;
276
276
  }
277
277
  }
278
- class De {
278
+ class _e {
279
279
  constructor() {
280
280
  this.hooks = {
281
281
  beforeResize: [],
@@ -330,7 +330,7 @@ class De {
330
330
  */
331
331
  executeResize(t) {
332
332
  const e = this.runHooks("beforeResize", t);
333
- let o = We.calculateResize({
333
+ let o = De.calculateResize({
334
334
  ...e,
335
335
  snapSystem: t.snapSystem
336
336
  });
@@ -345,8 +345,8 @@ class De {
345
345
  return this.runHooks("afterPositionUpdate", o).position;
346
346
  }
347
347
  }
348
- const Ke = new De();
349
- class $e {
348
+ const $e = new _e();
349
+ class je {
350
350
  constructor(t = null) {
351
351
  this.state = "IDLE", this.context = {
352
352
  mode: null,
@@ -882,7 +882,7 @@ function Pt(C, t) {
882
882
  const e = C.transformData;
883
883
  return e && "height" in e ? (e.height = t, !0) : !1;
884
884
  }
885
- class je {
885
+ class qe {
886
886
  constructor(t = {}) {
887
887
  this._extraSnapRects = [], this.snapThreshold = t.snapThreshold || it.canvas.snapThreshold, this.enabled = t.enabled !== !1, this.showGuides = t.showGuides !== !1, this.guides = [], this.activeSnaps = {
888
888
  x: null,
@@ -1512,7 +1512,7 @@ class je {
1512
1512
  return t;
1513
1513
  }
1514
1514
  }
1515
- class qe {
1515
+ class Ue {
1516
1516
  constructor(t = {}) {
1517
1517
  this.lastSnapTarget = null, this.detectionThreshold = t.detectionThreshold || 100, this.minDistance = t.minDistance || 10, this.enabled = t.enabled !== !1, this.showLabels = t.showLabels !== !1, this.indicators = [];
1518
1518
  }
@@ -1944,7 +1944,7 @@ class qe {
1944
1944
  }
1945
1945
  }
1946
1946
  }
1947
- const Lt = $t("ArtboardRenderer"), _e = {
1947
+ const Lt = $t("ArtboardRenderer"), ze = {
1948
1948
  showLabel: !0,
1949
1949
  showBorder: !0,
1950
1950
  borderColor: "",
@@ -1964,7 +1964,7 @@ const Lt = $t("ArtboardRenderer"), _e = {
1964
1964
  };
1965
1965
  class Qt {
1966
1966
  constructor(t = {}) {
1967
- this.options = { ..._e, ...t };
1967
+ this.options = { ...ze, ...t };
1968
1968
  }
1969
1969
  /**
1970
1970
  * Render an artboard
@@ -2155,19 +2155,19 @@ class Qt {
2155
2155
  return !!(this.options.showPreviewBackground && t.previewBackgroundColor && t.previewBackgroundColor !== "transparent");
2156
2156
  }
2157
2157
  }
2158
- function Ue(C) {
2158
+ function Ze(C) {
2159
2159
  return C instanceof fe;
2160
2160
  }
2161
- function ze(C) {
2161
+ function Ve(C) {
2162
2162
  return C instanceof jt;
2163
2163
  }
2164
2164
  function Wt(C) {
2165
2165
  return C instanceof he;
2166
2166
  }
2167
- function Ze(C) {
2167
+ function Je(C) {
2168
2168
  return C instanceof de;
2169
2169
  }
2170
- function Je(C) {
2170
+ function Qe(C) {
2171
2171
  return C instanceof ce;
2172
2172
  }
2173
2173
  class mt {
@@ -2951,7 +2951,8 @@ class Dt {
2951
2951
  }
2952
2952
  }
2953
2953
  }
2954
- const Ve = $t("CanvasRenderer"), K = class K {
2954
+ Ae();
2955
+ const Fe = $t("CanvasRenderer"), K = class K {
2955
2956
  /**
2956
2957
  * Get a pooled offscreen canvas for clipping content, only recreating
2957
2958
  * when dimensions change. Eliminates per-frame canvas allocation.
@@ -2975,7 +2976,7 @@ const Ve = $t("CanvasRenderer"), K = class K {
2975
2976
  e.render(t, o, n);
2976
2977
  } catch (s) {
2977
2978
  const i = s instanceof Error ? s : new Error(String(s));
2978
- Ve.error(`Failed to render element ${e.id}:`, i), K.onRenderError && K.onRenderError({
2979
+ Fe.error(`Failed to render element ${e.id}:`, i), K.onRenderError && K.onRenderError({
2979
2980
  category: "render",
2980
2981
  message: `Failed to render element: ${i.message}`,
2981
2982
  originalError: i,
@@ -3350,7 +3351,7 @@ const Ve = $t("CanvasRenderer"), K = class K {
3350
3351
  const m = t.getTransform().a / b, T = g.x * b * m, v = g.y * b * m;
3351
3352
  t.setTransform(m, 0, 0, m, T, v);
3352
3353
  }
3353
- if (e && ze(e) && e.isCropping)
3354
+ if (e && Ve(e) && e.isCropping)
3354
3355
  o && Dt.renderCropBoxLayer(t, e, o, b);
3355
3356
  else if (!l && n && mt.renderSelectionLayer(t, e, n, b), o && n && mt.renderPositionSizeInfo(t, e, o, n, b), !l && o && n && mt.renderHandlesLayer(
3356
3357
  t,
@@ -3376,22 +3377,22 @@ const Ve = $t("CanvasRenderer"), K = class K {
3376
3377
  K._contentCanvas = null, K._contentCanvasSize = { width: 0, height: 0 }, K._maskCanvas = null, K._maskCanvasSize = { width: 0, height: 0 }, K._cachedElementsRef = null, K._cachedElementConfigs = null, K._cachedElementMap = null, K._knockoutRenderedIds = /* @__PURE__ */ new Set(), K.onRenderError = null;
3377
3378
  let Kt = K;
3378
3379
  export {
3379
- je as A,
3380
+ qe as A,
3380
3381
  Kt as C,
3381
- $e as I,
3382
- De as R,
3383
- qe as S,
3384
- Ne as T,
3385
- ze as a,
3386
- Je as b,
3387
- Ze as c,
3388
- Ue as d,
3382
+ je as I,
3383
+ _e as R,
3384
+ Ue as S,
3385
+ Ke as T,
3386
+ Ve as a,
3387
+ Qe as b,
3388
+ Je as c,
3389
+ Ze as d,
3389
3390
  Qt as e,
3390
- Ye as f,
3391
+ Xe as f,
3391
3392
  Yt as g,
3392
- Ge as h,
3393
+ Ye as h,
3393
3394
  Wt as i,
3394
- Ke as j,
3395
- Xe as r
3395
+ $e as j,
3396
+ Ne as r
3396
3397
  };
3397
- //# sourceMappingURL=CanvasRenderer-CwiYq8qg.js.map
3398
+ //# sourceMappingURL=CanvasRenderer-B0szG0Us.js.map