@snowcone-app/canvas 0.42.1 → 0.43.1

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/ERROR_CONTRACT.md +45 -0
  2. package/dist/{CanvasRenderer-Bm7KLh38.js → CanvasRenderer-DnYgiWjt.js} +2 -2
  3. package/dist/{CanvasRenderer-Bm7KLh38.js.map → CanvasRenderer-DnYgiWjt.js.map} +1 -1
  4. package/dist/{CanvasStateV1-DPSSkdyD.js → CanvasStateV1-B51bXTyy.js} +2 -2
  5. package/dist/{CanvasStateV1-DPSSkdyD.js.map → CanvasStateV1-B51bXTyy.js.map} +1 -1
  6. package/dist/{ContextualToolbars-BuWJ3vD8.js → ContextualToolbars-DtlxDatY.js} +4 -4
  7. package/dist/{ContextualToolbars-BuWJ3vD8.js.map → ContextualToolbars-DtlxDatY.js.map} +1 -1
  8. package/dist/{EditorCanvasImpl-CtiIZyyt.js → EditorCanvasImpl-B5IEg9tq.js} +6 -6
  9. package/dist/{EditorCanvasImpl-CtiIZyyt.js.map → EditorCanvasImpl-B5IEg9tq.js.map} +1 -1
  10. package/dist/{ExportManager-DCEgNCL-.js → ExportManager-vAuaoF5Q.js} +1212 -1224
  11. package/dist/{ExportManager-DCEgNCL-.js.map → ExportManager-vAuaoF5Q.js.map} +1 -1
  12. package/dist/FontAnalyzer-D9R2PYsy.js.map +1 -1
  13. package/dist/{ImagePanel-WLkHhuBY.js → ImagePanel-kybrF6yT.js} +3 -3
  14. package/dist/{ImagePanel-WLkHhuBY.js.map → ImagePanel-kybrF6yT.js.map} +1 -1
  15. package/dist/SnowconeCanvas-rAUrO9PR.js +1157 -0
  16. package/dist/SnowconeCanvas-rAUrO9PR.js.map +1 -0
  17. package/dist/advanced.mjs +9 -9
  18. package/dist/api/embed.d.ts +1 -0
  19. package/dist/api/stable.d.ts +1 -0
  20. package/dist/components/embed/SnowconeCanvas.d.ts +13 -0
  21. package/dist/{custom-icons-B3auKmXj.js → custom-icons-Dlfrg3A_.js} +2 -2
  22. package/dist/{custom-icons-B3auKmXj.js.map → custom-icons-Dlfrg3A_.js.map} +1 -1
  23. package/dist/design/template-fields.d.ts +5 -0
  24. package/dist/{embed-hQtKIv0u.js → embed-BXa1jr7S.js} +7 -7
  25. package/dist/{embed-hQtKIv0u.js.map → embed-BXa1jr7S.js.map} +1 -1
  26. package/dist/embed.mjs +5 -5
  27. package/dist/errors/editorError.d.ts +4 -1
  28. package/dist/index.mjs +7 -7
  29. package/dist/internals.mjs +4 -4
  30. package/dist/{template-fields-pasAAplQ.js → template-fields-ZZEdYB5H.js} +44 -43
  31. package/dist/{template-fields-pasAAplQ.js.map → template-fields-ZZEdYB5H.js.map} +1 -1
  32. package/dist/{useCommands-htOtw7w6.js → useCommands-d5UM6Cnc.js} +5 -5
  33. package/dist/{useCommands-htOtw7w6.js.map → useCommands-d5UM6Cnc.js.map} +1 -1
  34. package/dist/utils/ExportManager.d.ts +37 -1
  35. package/dist/utils/printFiles.d.ts +23 -0
  36. package/dist/{validation-m6hAaElF.js → validation-C8qNtk6j.js} +9 -9
  37. package/dist/{validation-m6hAaElF.js.map → validation-C8qNtk6j.js.map} +1 -1
  38. package/example/package.json +1 -1
  39. package/package.json +2 -2
  40. package/dist/SnowconeCanvas-1wc08k_m.js +0 -1098
  41. package/dist/SnowconeCanvas-1wc08k_m.js.map +0 -1
package/dist/embed.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { C as a, g as t, h as o, K as r, N as i, O as n, P as d, Q as m, R as u, b as l, a as E, j as c, k as p, l as g } from "./useCommands-htOtw7w6.js";
2
- import { E as x, R as C, a as S, b as T, S as P, c as R, d as b, e as B, f as v, g as y, i as F, h as k, p as h, s as D, j as I, k as K, l as L, v as w } from "./embed-hQtKIv0u.js";
1
+ import { C as a, g as t, h as o, K as r, N as i, O as n, P as d, Q as m, R as u, b as l, a as E, j as c, k as p, l as g } from "./useCommands-d5UM6Cnc.js";
2
+ import { E as x, R as C, a as S, b as T, S as P, c as R, d as b, e as B, f as v, g as y, i as F, h as k, p as h, s as D, j as I, k as K, l as L, v as w } from "./embed-BXa1jr7S.js";
3
3
  import { t as M, Y as j } from "./FontAnalyzer-D9R2PYsy.js";
4
4
  import { D as N, f as Y, n as _, m as z, b as H } from "./design-builder-C8s1r4MF.js";
5
- import { D as O, T as Q, r as V, u as q, a as U, b as W, c as X, d as Z, e as $, w as ee } from "./template-fields-pasAAplQ.js";
6
- import { G as ae, H as te, J as oe, K as re } from "./ExportManager-DCEgNCL-.js";
7
- import { s as ne } from "./CanvasStateV1-DPSSkdyD.js";
5
+ import { D as O, T as Q, r as V, u as q, a as U, b as W, c as X, d as Z, e as $, w as ee } from "./template-fields-ZZEdYB5H.js";
6
+ import { G as ae, H as te, J as oe, K as re } from "./ExportManager-vAuaoF5Q.js";
7
+ import { s as ne } from "./CanvasStateV1-B51bXTyy.js";
8
8
  export {
9
9
  a as CanvasServicesProvider,
10
10
  N as DesignBuilder,
@@ -146,7 +146,10 @@ export type EditorErrorCode =
146
146
  * picked alternative's variant gvids (`validNames`), or the alternative
147
147
  * publishes no variant at all. Every role of a bundle session needs a
148
148
  * variant — the server keys the render on the per-role set. */
149
- | 'E_BUNDLE_VARIANT_NOT_FOUND';
149
+ | 'E_BUNDLE_VARIANT_NOT_FOUND'
150
+ /** `exportPrintFiles`: a print file could not be made — the device refused its canvas (too many pixels for it),
151
+ * or the request named an artboard / region that does not exist (`validNames` lists the artboards). */
152
+ | 'E_PRINT_FILE_FAILED';
150
153
  export interface EditorErrorData {
151
154
  code: EditorErrorCode;
152
155
  /** Slug under https://developers.snowcone.app/ for the violated contract. */
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
- import { e as u } from "./useCommands-htOtw7w6.js";
2
- import { C as c, f as x, g as I, h as v, b as A, a as g, j as T, k as B, l as P } from "./useCommands-htOtw7w6.js";
3
- import { E as F, S as L, S as _, u as O, a as R } from "./SnowconeCanvas-1wc08k_m.js";
1
+ import { e as u } from "./useCommands-d5UM6Cnc.js";
2
+ import { C as c, f as x, g as I, h as v, b as A, a as g, j as T, k as B, l as P } from "./useCommands-d5UM6Cnc.js";
3
+ import { E as F, S as L, S as _, u as O, a as R } from "./SnowconeCanvas-rAUrO9PR.js";
4
4
  import { b as m, e as d } from "./design-builder-C8s1r4MF.js";
5
5
  import { C as z, D as w, f as K, s as D } from "./design-builder-C8s1r4MF.js";
6
- import { T as V, r as b, u as h, a as G, b as H, c as U, d as Y, e as Z, w as j } from "./template-fields-pasAAplQ.js";
7
- import { A as J, C as q, E as Q, M as W, P as X, r as $, v as ee } from "./validation-m6hAaElF.js";
8
- import { G as ae, H as te, J as oe, K as re } from "./ExportManager-DCEgNCL-.js";
6
+ import { T as V, r as b, u as h, a as G, b as H, c as U, d as Y, e as Z, w as j } from "./template-fields-ZZEdYB5H.js";
7
+ import { A as J, C as q, E as Q, M as W, P as X, r as $, v as ee } from "./validation-C8qNtk6j.js";
8
+ import { G as ae, H as te, J as oe, K as re } from "./ExportManager-vAuaoF5Q.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-DPSSkdyD.js";
10
+ import { d as de, m as Ce, s as Se, v as Ee } from "./CanvasStateV1-B51bXTyy.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-Bm7KLh38.js";
2
- import { r as k } from "./ExportManager-DCEgNCL-.js";
3
- import { D as hr, a as cr, I as dr, W as fr, b as gr, c as lr, d as ur, e as pr, f as yr, g as kr, h as vr, i as wr, j as Cr, k as Mr, l as Tr, m as Sr, n as br, o as Pr, p as Ir, q as mr, s as Ar, t as Rr, u as Wr, v as Er, w as Or, x as Hr, y as jr, z as Fr, A as Lr, B as Xr, C as zr, F as Nr } from "./ExportManager-DCEgNCL-.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-DnYgiWjt.js";
2
+ import { r as k } from "./ExportManager-vAuaoF5Q.js";
3
+ import { D as hr, a as cr, I as dr, W as fr, b as gr, c as lr, d as ur, e as pr, f as yr, g as kr, h as vr, i as wr, j as Cr, k as Mr, l as Tr, m as Sr, n as br, o as Pr, p as Ir, q as mr, s as Ar, t as Rr, u as Wr, v as Er, w as Or, x as Hr, y as jr, z as Fr, A as Lr, B as Xr, C as zr, F as Nr } from "./ExportManager-vAuaoF5Q.js";
4
4
  import { i as H, a as j, c as F, r as L, b as X } from "./FontAnalyzer-D9R2PYsy.js";
5
5
  import { d as Br, e as Kr, f as Ur, C as Yr, g as Jr, E as Vr, F as qr, H as Gr, L as Qr, h as Zr, W as $r, j as xr, k as Dr, l as ro, m as oo, n as so, o as eo, s as to, w as no } from "./FontAnalyzer-D9R2PYsy.js";
6
- import { A as io, a as ho, C as co, S as fo } from "./CanvasStateV1-DPSSkdyD.js";
6
+ import { A as io, a as ho, C as co, S as fo } from "./CanvasStateV1-B51bXTyy.js";
7
7
  const z = F("image-adjustments"), v = 1e-3;
8
8
  function N(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);
@@ -1,9 +1,9 @@
1
1
  import { t as v, p as V, T, I as M, z as st } from "./FontAnalyzer-D9R2PYsy.js";
2
2
  import { k as G, b as ot, m as it, u as O, a as B, n as rt } from "./design-builder-C8s1r4MF.js";
3
3
  import { toOptionAttributes as at, toCombinations as ct, getMissingSelections as lt, validateProductSelection as mt, findBestCombination as F, computeDisabledChoices as ft } from "@snowcone-app/sdk";
4
- import { useEffect as ut, useContext as Z, useId as dt, useLayoutEffect as ht, useRef as C, useMemo as A, useCallback as k, useState as q } from "react";
5
- import { E as tt, U as gt } from "./useCommands-htOtw7w6.js";
6
- import { b as pt, o as $, c as f, e as bt, l as h, n as yt, u as z, f as vt } from "./CanvasStateV1-DPSSkdyD.js";
4
+ import { useEffect as ut, useContext as Z, useId as dt, useLayoutEffect as ht, useRef as C, useMemo as k, useCallback as A, useState as q } from "react";
5
+ import { E as tt, U as gt } from "./useCommands-d5UM6Cnc.js";
6
+ import { b as pt, o as $, c as m, e as bt, l as h, n as yt, u as z, f as vt } from "./CanvasStateV1-B51bXTyy.js";
7
7
  function R(s) {
8
8
  return s.text;
9
9
  }
@@ -260,7 +260,7 @@ function Q(s) {
260
260
  function Ot(s, t, e) {
261
261
  const o = `[${X[s]}]`, n = `the binding is dead (isConnected: false, ${xt[s]} is a no-op)`, i = Ct[s], a = e.getAllByName(t);
262
262
  if (a.length > 0) {
263
- const l = [...new Set(a.map(Q))], m = i === "text" ? "image" : "text", N = l.length === 1 && l[0] === m ? ` Bind it with ${X[m]}("${t}") instead.` : "";
263
+ const l = [...new Set(a.map(Q))], f = i === "text" ? "image" : "text", N = l.length === 1 && l[0] === f ? ` Bind it with ${X[f]}("${t}") instead.` : "";
264
264
  return `${o} the layer named "${t}" is ${l.join("/")}, not ${i} — ${n}.${N}`;
265
265
  }
266
266
  const r = e.getAll().filter((l) => l.name).map((l) => `"${l.name}" (${Q(l)})`), c = r.length ? `Named layers on this canvas: ${r.join(", ")}. Check the name for a typo.` : `No element on this canvas has a name — name one via design().${i}(…, { name: '${t}' }) or the element's \`name\` property.`;
@@ -305,11 +305,11 @@ function P(s, t, e) {
305
305
  if (r.length > 0) {
306
306
  const c = e.getAllByName(n);
307
307
  if (c.length === 0) {
308
- const l = r.map((m) => ({ name: m.name, kind: L(m) })).filter((m) => !!m.name && m.kind !== null);
308
+ const l = r.map((f) => ({ name: f.name, kind: L(f) })).filter((f) => !!f.name && f.kind !== null);
309
309
  throw new v(
310
310
  "E_LAYER_NOT_FOUND",
311
- `no layer "${n}" in this Root's document — the token was minted from a different design than the one passed to <Editor.Root design={…}>, or the layer was deleted. Bindable layers here: ${JSON.stringify(l.map((m) => m.name))}.`,
312
- { layerName: n, validNames: l.map((m) => m.name), docSlug: "embed-mode" }
311
+ `no layer "${n}" in this Root's document — the token was minted from a different design than the one passed to <Editor.Root design={…}>, or the layer was deleted. Bindable layers here: ${JSON.stringify(l.map((f) => f.name))}.`,
312
+ { layerName: n, validNames: l.map((f) => f.name), docSlug: "embed-mode" }
313
313
  );
314
314
  }
315
315
  if (!c.some((l) => L(l) === t)) {
@@ -330,7 +330,7 @@ const Dt = () => {
330
330
  function Ht(s) {
331
331
  const { elementStore: t } = O();
332
332
  _("useTextBinding()");
333
- const e = P(s, "text", t), { executeElementUpdate: o } = B(), n = A(() => t.getAllByName(e).filter((r) => r instanceof T), [t, e]), i = k(
333
+ const e = P(s, "text", t), { executeElementUpdate: o } = B(), n = k(() => t.getAllByName(e).filter((r) => r instanceof T), [t, e]), i = A(
334
334
  (a) => {
335
335
  for (const r of n) {
336
336
  const c = r.clone();
@@ -375,7 +375,7 @@ function Bt(s, t, e) {
375
375
  }
376
376
  function Vt(s, t) {
377
377
  _("useImageBinding()");
378
- const e = (t == null ? void 0 : t.fit) ?? "cover", { elementStore: o, setElements: n } = O(), i = P(s, "image", o), { executeElementUpdate: a } = B(), r = A(() => o.getAllByName(i).filter((b) => b instanceof M), [o, i]), c = C(/* @__PURE__ */ new Map());
378
+ const e = (t == null ? void 0 : t.fit) ?? "cover", { elementStore: o, setElements: n } = O(), i = P(s, "image", o), { executeElementUpdate: a } = B(), r = k(() => o.getAllByName(i).filter((b) => b instanceof M), [o, i]), c = C(/* @__PURE__ */ new Map());
379
379
  for (const d of r)
380
380
  if (!c.current.has(d.id)) {
381
381
  const b = d.transformData;
@@ -386,13 +386,13 @@ function Vt(s, t) {
386
386
  }
387
387
  const l = C(r);
388
388
  l.current = r;
389
- const m = C(a);
390
- m.current = a;
389
+ const f = C(a);
390
+ f.current = a;
391
391
  const N = C(n);
392
392
  N.current = n;
393
- const S = k(
393
+ const S = A(
394
394
  (d) => {
395
- const b = l.current, W = m.current;
395
+ const b = l.current, W = f.current;
396
396
  for (const D of b) {
397
397
  const j = c.current.get(D.id);
398
398
  if (!j) continue;
@@ -417,7 +417,7 @@ function Vt(s, t) {
417
417
  isConnected: !0
418
418
  };
419
419
  }
420
- const At = [];
420
+ const kt = [];
421
421
  function I(s) {
422
422
  let t = s.trim().toUpperCase();
423
423
  return t.length === 4 && t.startsWith("#") && (t = "#" + t[1] + t[1] + t[2] + t[2] + t[3] + t[3]), t;
@@ -430,7 +430,7 @@ function et(s, t) {
430
430
  const e = s;
431
431
  return y(e.color, t) || y((o = e.transformData) == null ? void 0 : o.fillColor, t) || y((n = e.transformData) == null ? void 0 : n.strokeColor, t) || ((i = e.stroke) == null ? void 0 : i.enabled) === !0 && y(e.stroke.color, t);
432
432
  }
433
- function kt(s, t, e) {
433
+ function At(s, t, e) {
434
434
  var a, r, c;
435
435
  if (!et(s, t)) return null;
436
436
  const o = s.clone(), n = s, i = o;
@@ -441,15 +441,15 @@ function Gt(s) {
441
441
  _("useColorBinding()");
442
442
  const [n, i] = q(() => I(t)), [a, r] = q(t);
443
443
  t !== a && (r(t), i(I(t)));
444
- const c = A(
445
- () => e.getAll().filter((m) => et(m, n)),
444
+ const c = k(
445
+ () => e.getAll().filter((f) => et(f, n)),
446
446
  [e, n]
447
- ), l = k(
448
- (m) => {
449
- const N = I(m);
447
+ ), l = A(
448
+ (f) => {
449
+ const N = I(f);
450
450
  if (N !== n) {
451
451
  for (const S of e.getAll()) {
452
- const d = kt(S, n, m);
452
+ const d = At(S, n, f);
453
453
  d && o(S, d);
454
454
  }
455
455
  i(N);
@@ -457,14 +457,14 @@ function Gt(s) {
457
457
  },
458
458
  [e, n, o]
459
459
  );
460
- return c.length === 0 ? { color: n, setColor: l, elements: At, isConnected: !1 } : { color: n, setColor: l, elements: c, isConnected: !0 };
460
+ return c.length === 0 ? { color: n, setColor: l, elements: kt, isConnected: !1 } : { color: n, setColor: l, elements: c, isConnected: !0 };
461
461
  }
462
462
  const _t = () => {
463
463
  }, wt = [];
464
464
  function qt(s) {
465
465
  const { elementStore: t } = O();
466
466
  _("useFontBinding()");
467
- const e = P(s, "text", t), { executeElementUpdate: o } = B(), n = A(() => t.getAllByName(e).filter((r) => r instanceof T), [t, e]), i = k(
467
+ const e = P(s, "text", t), { executeElementUpdate: o } = B(), n = k(() => t.getAllByName(e).filter((r) => r instanceof T), [t, e]), i = A(
468
468
  (a) => {
469
469
  gt.loadGoogleFontByName(a);
470
470
  for (const r of n) {
@@ -491,39 +491,40 @@ function zt(s) {
491
491
  const nt = "personalization", Ft = pt("type", [
492
492
  $({
493
493
  type: h("text"),
494
- name: f().min(1),
495
- label: f(),
496
- placeholder: f().optional(),
494
+ name: m().min(1),
495
+ label: m(),
496
+ placeholder: m().optional(),
497
497
  maxLength: yt().int().positive().optional(),
498
498
  fit: h("shrink").optional(),
499
499
  sample: bt().optional(),
500
- artboard: f().min(1).optional(),
501
- group: f().optional()
500
+ stack: m().min(1).optional(),
501
+ artboard: m().min(1).optional(),
502
+ group: m().optional()
502
503
  }),
503
504
  $({
504
505
  type: h("image"),
505
- name: f().min(1),
506
- label: f(),
507
- placeholder: f().optional(),
506
+ name: m().min(1),
507
+ label: m(),
508
+ placeholder: m().optional(),
508
509
  fit: z([h("cover"), h("contain")]).optional(),
509
- artboard: f().min(1).optional(),
510
- group: f().optional()
510
+ artboard: m().min(1).optional(),
511
+ group: m().optional()
511
512
  }),
512
513
  $({
513
514
  type: h("color"),
514
- color: f().min(1),
515
- label: f(),
516
- artboard: f().min(1).optional(),
517
- group: f().optional()
515
+ color: m().min(1),
516
+ label: m(),
517
+ artboard: m().min(1).optional(),
518
+ group: m().optional()
518
519
  }),
519
520
  $({
520
521
  type: h("select"),
521
- name: f().min(1),
522
- label: f(),
522
+ name: m().min(1),
523
+ label: m(),
523
524
  property: z([h("text"), h("imageUrl"), h("fontFamily")]),
524
- options: vt($({ label: f(), value: f() })).min(1),
525
- artboard: f().min(1).optional(),
526
- group: f().optional()
525
+ options: vt($({ label: m(), value: m() })).min(1),
526
+ artboard: m().min(1).optional(),
527
+ group: m().optional()
527
528
  })
528
529
  ]);
529
530
  function Jt(s) {
@@ -555,4 +556,4 @@ export {
555
556
  Gt as u,
556
557
  Xt as w
557
558
  };
558
- //# sourceMappingURL=template-fields-pasAAplQ.js.map
559
+ //# sourceMappingURL=template-fields-ZZEdYB5H.js.map