@snowcone-app/canvas 0.29.0 → 0.31.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 (92) hide show
  1. package/ERROR_CONTRACT.md +13 -0
  2. package/STYLING_CONTRACT.md +2 -2
  3. package/dist/{CanvasRenderer-_lFoIoz5.js → CanvasRenderer-hpJ05JGO.js} +4 -4
  4. package/dist/{CanvasRenderer-_lFoIoz5.js.map → CanvasRenderer-hpJ05JGO.js.map} +1 -1
  5. package/dist/{CanvasStateV1-BMxr6xb8.js → CanvasStateV1-jLOibojY.js} +876 -844
  6. package/dist/{CanvasStateV1-BMxr6xb8.js.map → CanvasStateV1-jLOibojY.js.map} +1 -1
  7. package/dist/ContextualToolbars-DRbuUE7W.js +6061 -0
  8. package/dist/ContextualToolbars-DRbuUE7W.js.map +1 -0
  9. package/dist/{EditorCanvasImpl-BNz8TPFs.js → EditorCanvasImpl-P2GHPNA3.js} +19 -20
  10. package/dist/{EditorCanvasImpl-BNz8TPFs.js.map → EditorCanvasImpl-P2GHPNA3.js.map} +1 -1
  11. package/dist/{ExportManager-B8Td7uR5.js → ExportManager-Bkzzyxgw.js} +973 -576
  12. package/dist/ExportManager-Bkzzyxgw.js.map +1 -0
  13. package/dist/{FontAnalyzer-D4Sg-P6_.js → FontAnalyzer-BYhwxDhe.js} +542 -477
  14. package/dist/FontAnalyzer-BYhwxDhe.js.map +1 -0
  15. package/dist/{ImagePanel-CN2Bu3hf.js → ImagePanel-CEr0_FYy.js} +38 -38
  16. package/dist/{ImagePanel-CN2Bu3hf.js.map → ImagePanel-CEr0_FYy.js.map} +1 -1
  17. package/dist/SnowconeCanvas-Fa0isFpO.js +1192 -0
  18. package/dist/SnowconeCanvas-Fa0isFpO.js.map +1 -0
  19. package/dist/advanced.mjs +14 -14
  20. package/dist/api/embed.d.ts +2 -0
  21. package/dist/api/stable.d.ts +2 -0
  22. package/dist/components/CanvasContextMenu.d.ts +15 -0
  23. package/dist/components/CanvasEditor/hooks/useCanvasInteraction.d.ts +27 -0
  24. package/dist/components/CanvasEditor.d.ts +8 -0
  25. package/dist/components/ImageToolbar.d.ts +4 -0
  26. package/dist/components/embed/SnowconeCanvas.d.ts +13 -0
  27. package/dist/components/embed/kernel.d.ts +8 -0
  28. package/dist/components/toolbars/EmbeddedToolbarLayout.d.ts +2 -0
  29. package/dist/components/toolbars/SecondaryPanels.d.ts +17 -1
  30. package/dist/components/toolbars/index.d.ts +2 -2
  31. package/dist/components/ui/SliderRow.d.ts +6 -0
  32. package/dist/components/ui/icons.d.ts +2 -0
  33. package/dist/components/ui/toolbar-button.d.ts +2 -2
  34. package/dist/contexts/CanvasServicesContext.d.ts +17 -0
  35. package/dist/contexts/EditorContext.d.ts +7 -0
  36. package/dist/core/image-adjustments.d.ts +32 -0
  37. package/dist/{custom-icons-B5TRC1Ed.js → custom-icons-Co4rcW0S.js} +7 -7
  38. package/dist/{custom-icons-B5TRC1Ed.js.map → custom-icons-Co4rcW0S.js.map} +1 -1
  39. package/dist/design-builder-CBG2hKc8.js +1672 -0
  40. package/dist/design-builder-CBG2hKc8.js.map +1 -0
  41. package/dist/{embed-BTRtoktw.js → embed-D4TIzO7g.js} +20 -20
  42. package/dist/{embed-BTRtoktw.js.map → embed-D4TIzO7g.js.map} +1 -1
  43. package/dist/embed.mjs +51 -46
  44. package/dist/embed.mjs.map +1 -1
  45. package/dist/errors/editorError.d.ts +8 -0
  46. package/dist/{guards-uQtEQJbs.js → guards-DgZuwVgu.js} +2 -2
  47. package/dist/{guards-uQtEQJbs.js.map → guards-DgZuwVgu.js.map} +1 -1
  48. package/dist/hooks/elementPatch.d.ts +7 -2
  49. package/dist/hooks/useKeyboardShortcuts.d.ts +15 -2
  50. package/dist/hooks/useLayers.d.ts +2 -0
  51. package/dist/index.mjs +57 -52
  52. package/dist/index.mjs.map +1 -1
  53. package/dist/internals.mjs +201 -132
  54. package/dist/internals.mjs.map +1 -1
  55. package/dist/rendering/element-painters.d.ts +0 -13
  56. package/dist/rendering/element-serializer.d.ts +3 -1
  57. package/dist/rendering/image-adjustments.d.ts +24 -0
  58. package/dist/rendering/renderer-types.d.ts +8 -1
  59. package/dist/state/CanvasStateV1.d.ts +36 -3
  60. package/dist/state/index.d.ts +2 -2
  61. package/dist/template-fields-CvFcr5zy.js +505 -0
  62. package/dist/template-fields-CvFcr5zy.js.map +1 -0
  63. package/dist/testing.mjs +46 -47
  64. package/dist/testing.mjs.map +1 -1
  65. package/dist/types/index.d.ts +21 -0
  66. package/dist/{UnifiedFontService-CgYnYTj7.js → useCommands-bPXY9rCh.js} +2429 -2145
  67. package/dist/useCommands-bPXY9rCh.js.map +1 -0
  68. package/dist/{usePieceGuideBundle-CTQszfKA.js → usePieceGuideBundle-Bj98nPk0.js} +2 -2
  69. package/dist/{usePieceGuideBundle-CTQszfKA.js.map → usePieceGuideBundle-Bj98nPk0.js.map} +1 -1
  70. package/dist/utils/custom-fonts.d.ts +99 -0
  71. package/dist/utils/featureApplied.d.ts +2 -0
  72. package/dist/validation-CsTlSvJJ.js +8686 -0
  73. package/dist/validation-CsTlSvJJ.js.map +1 -0
  74. package/dist/workers/export-protocol.d.ts +13 -0
  75. package/dist/workers/export-worker.bundle.string.d.ts +1 -1
  76. package/example/package.json +1 -1
  77. package/package.json +1 -1
  78. package/dist/ContextualToolbars-0jWvnQgp.js +0 -5833
  79. package/dist/ContextualToolbars-0jWvnQgp.js.map +0 -1
  80. package/dist/ExportManager-B8Td7uR5.js.map +0 -1
  81. package/dist/FontAnalyzer-D4Sg-P6_.js.map +0 -1
  82. package/dist/SnowconeCanvas-CR_LdRFP.js +0 -1173
  83. package/dist/SnowconeCanvas-CR_LdRFP.js.map +0 -1
  84. package/dist/UnifiedFontService-CgYnYTj7.js.map +0 -1
  85. package/dist/design-builder-COj0zkxu.js +0 -470
  86. package/dist/design-builder-COj0zkxu.js.map +0 -1
  87. package/dist/editorErrors-CCvoKj_P.js +0 -1219
  88. package/dist/editorErrors-CCvoKj_P.js.map +0 -1
  89. package/dist/template-fields-BLRp84Ny.js +0 -716
  90. package/dist/template-fields-BLRp84Ny.js.map +0 -1
  91. package/dist/validation-eCebhplp.js +0 -8402
  92. package/dist/validation-eCebhplp.js.map +0 -1
@@ -1,13 +1,13 @@
1
- import { E as Le, o as Ve, p as Be, C as Fe, q as H, r as J, t as Ue, v as Me, w as je, x as qe, y as ze, g as Ke, e as We } from "./UnifiedFontService-CgYnYTj7.js";
2
- import { y as L } from "./FontAnalyzer-D4Sg-P6_.js";
1
+ import { E as Le, p as Ve, q as Be, C as Fe, r as H, t as J, v as Ue, w as Me, x as je, y as qe, z as ze, h as Ke, e as We } from "./useCommands-bPXY9rCh.js";
2
+ import { E as T, y as be, z as L } from "./FontAnalyzer-BYhwxDhe.js";
3
3
  import { jsx as l, jsxs as N, Fragment as Ge } from "react/jsx-runtime";
4
- import { useContext as He, createContext as Je, useRef as x, useState as C, useMemo as O, useCallback as F, useLayoutEffect as Q, useEffect as $, useSyncExternalStore as z, Component as Qe, forwardRef as be, useId as de, memo as Ye, isValidElement as we } from "react";
4
+ import { useContext as He, createContext as Je, useRef as x, useState as C, useMemo as O, useCallback as F, useLayoutEffect as Q, useEffect as $, useSyncExternalStore as z, Component as Qe, forwardRef as we, useId as de, memo as Ye, isValidElement as Ee } from "react";
5
5
  import { assertVariantSelected as Xe, RenderSession as Ze, createCartDetail as et } from "@snowcone-app/sdk";
6
- import { g as T, i as Ee, B as tt, E as nt, r as rt } from "./editorErrors-CCvoKj_P.js";
7
- import { u as ot, p as it } from "./usePieceGuideBundle-CTQszfKA.js";
8
- import { s as le, i as st } from "./design-builder-COj0zkxu.js";
9
- import { D as at, C as dt, g as lt, e as ct } from "./template-fields-BLRp84Ny.js";
10
- import "./CanvasStateV1-BMxr6xb8.js";
6
+ import { s as le, B as tt, E as nt, r as rt, i as ot } from "./design-builder-CBG2hKc8.js";
7
+ import { u as it, p as st } from "./usePieceGuideBundle-Bj98nPk0.js";
8
+ import { D as at, C as dt, f as lt, d as ct } from "./template-fields-CvFcr5zy.js";
9
+ import "./ExportManager-Bkzzyxgw.js";
10
+ import "./CanvasStateV1-jLOibojY.js";
11
11
  const xe = Je(void 0);
12
12
  function K() {
13
13
  const t = He(xe);
@@ -167,7 +167,7 @@ function gt(t) {
167
167
  return typeof e == "function" ? { getToken: e } : { getToken: () => Promise.resolve(e) };
168
168
  }
169
169
  function Ce({ error: t, onRetry: e }) {
170
- const n = Ee(t) ? t.code : "EDITOR_ERROR";
170
+ const n = be(t) ? t.code : "EDITOR_ERROR";
171
171
  return /* @__PURE__ */ N(
172
172
  "div",
173
173
  {
@@ -230,7 +230,7 @@ class yt extends Qe {
230
230
  }
231
231
  function vt({ reportedError: t, onRetry: e, children: n }) {
232
232
  if (t) {
233
- const r = Ee(t) && t.code === "E_CHUNK_LOAD_FAILED";
233
+ const r = be(t) && t.code === "E_CHUNK_LOAD_FAILED";
234
234
  return /* @__PURE__ */ l(Ce, { error: t, onRetry: r ? e : void 0 });
235
235
  }
236
236
  return /* @__PURE__ */ l(yt, { reportedError: null, onRetry: e, children: n });
@@ -276,10 +276,10 @@ function bt(t) {
276
276
  m.commerce.getVersion,
277
277
  m.commerce.getVersion
278
278
  );
279
- const R = m.commerce.renderVariantId(), _ = ot(R ?? n.variantId ?? n.defaultGvid), D = O(() => {
279
+ const R = m.commerce.renderVariantId(), _ = it(R ?? n.variantId ?? n.defaultGvid), D = O(() => {
280
280
  if (!_) return null;
281
281
  const h = r.toJSON().artboards[0];
282
- return it(_, h) ?? null;
282
+ return st(_, h) ?? null;
283
283
  }, [_, r]), P = x(s), A = x(d), j = x(c);
284
284
  P.current = s, A.current = d, j.current = c;
285
285
  const [ce, _e] = C([]), [Y, W] = C(!0), [ue, X] = C(null), ne = !!("grantUrl" in t && t.grantUrl || "grant" in t && t.grant), re = gt(t), Ae = "grantUrl" in re ? re.grantUrl : "getToken", me = `${n.productId}|${n.mockupIds.join(",")}|${n.variantId ?? ""}`, q = `${e}|${me}|${o}|${ne}`, oe = O(() => {
@@ -460,11 +460,11 @@ function Ie(t) {
460
460
  // wrapper, which had no DOM at all, stays layout-identical).
461
461
  /* @__PURE__ */ l("div", { className: "sc-root", style: { display: "contents" }, "data-sc-part": "root", children: /* @__PURE__ */ l(vt, { reportedError: c, onRetry: () => u(null), children: /* @__PURE__ */ l(bt, { ...t, internals: a, recordAudit: b }) }) });
462
462
  }
463
- let wt = () => import("./EditorCanvasImpl-BNz8TPFs.js").then((t) => t.EditorCanvasImpl);
463
+ let wt = () => import("./EditorCanvasImpl-P2GHPNA3.js").then((t) => t.EditorCanvasImpl);
464
464
  function Oe() {
465
465
  return wt();
466
466
  }
467
- const Et = be(function({ children: e, maxHeight: n, floatingToolbar: r = !0, className: i, style: s }, d) {
467
+ const Et = we(function({ children: e, maxHeight: n, floatingToolbar: r = !0, className: i, style: s }, d) {
468
468
  const c = H("Editor.Canvas");
469
469
  J("Editor.Canvas", { floatingToolbar: r });
470
470
  const u = de();
@@ -663,7 +663,7 @@ function Tt(t, e) {
663
663
  }
664
664
  function $t(t) {
665
665
  if (t === void 0 || t === !0 || t === "dark") return "dark";
666
- if (t === "light" || t === "host-owned" || we(t)) return t;
666
+ if (t === "light" || t === "host-owned" || Ee(t)) return t;
667
667
  throw new T(
668
668
  "E_PREVIEW_NO_LOADER",
669
669
  `Editor.Preview: invalid loadingOverlay value ${JSON.stringify(t)}. A mockup preview always has a render-in-flight treatment (the loader paints over the still-visible previous mockup). Omit the prop for the default rainbow overlay, pass "dark" | "light", pass a custom ReactElement, or declare "host-owned" if the host renders its own indicator off data-sc-preview-state / <Editor.LoadingOverlay>.`,
@@ -680,7 +680,7 @@ function $e({
680
680
  }) {
681
681
  const { mockups: d, error: c, isRendering: u } = K();
682
682
  J("Editor.Preview", { ...t !== void 0 ? { mockupId: t } : {} });
683
- const a = $t(r), p = a === "dark" || a === "light" ? a : null, m = we(a) ? a : null, y = a !== "host-owned", { showOverlay: b, overlayVisible: o, handleExited: g } = Te(
683
+ const a = $t(r), p = a === "dark" || a === "light" ? a : null, m = Ee(a) ? a : null, y = a !== "host-owned", { showOverlay: b, overlayVisible: o, handleExited: g } = Te(
684
684
  y && u
685
685
  ), w = x(/* @__PURE__ */ new Set()), f = t ? d.find((v) => v.mockupId === t && v.imageUrl) : d.find((v) => v.imageUrl), S = (v) => {
686
686
  var P;
@@ -761,7 +761,7 @@ function _t(t) {
761
761
  const { layer: e, optional: n = !1, placeholder: r, className: i, style: s } = t, d = H("Editor.TextField");
762
762
  J("Editor.TextField");
763
763
  const { pushRender: c, throttleMs: u, stateStore: a } = K(), p = de(), m = x(null);
764
- if (!st(e))
764
+ if (!ot(e))
765
765
  throw new T(
766
766
  "E_LAYER_TOKEN_REQUIRED",
767
767
  `the \`layer\` prop must be a token minted by the design — pass layer={design.layer("name")}, not ${typeof e == "string" ? `the bare string "${e}"` : "a plain value"}. Tokens validate the name against the design's layers at mint time.`,
@@ -935,7 +935,7 @@ function Lt({
935
935
  return $(() => {
936
936
  if (!s) return;
937
937
  let u = !1;
938
- return import("./ContextualToolbars-0jWvnQgp.js").then((a) => a.s).then(
938
+ return import("./ContextualToolbars-DRbuUE7W.js").then((a) => a.s).then(
939
939
  (a) => {
940
940
  u || c(() => a.ContextualToolbars);
941
941
  },
@@ -1030,7 +1030,7 @@ const M = {
1030
1030
  function on(t) {
1031
1031
  return /* @__PURE__ */ l(Ie, { ...t, __validation: "warn" });
1032
1032
  }
1033
- const sn = be(
1033
+ const sn = we(
1034
1034
  function(e, n) {
1035
1035
  const { children: r, className: i, style: s, maxHeight: d, ...c } = e, [u, a] = C(null);
1036
1036
  return $(() => {
@@ -1583,4 +1583,4 @@ export {
1583
1583
  K as u,
1584
1584
  ft as v
1585
1585
  };
1586
- //# sourceMappingURL=embed-BTRtoktw.js.map
1586
+ //# sourceMappingURL=embed-D4TIzO7g.js.map