@snowcone-app/canvas 0.17.0 → 0.17.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 (66) hide show
  1. package/dist/{CanvasStateV1-C6i6vU6p.js → CanvasStateV1-BG2hEc3-.js} +3 -3
  2. package/dist/{CanvasStateV1-C6i6vU6p.js.map → CanvasStateV1-BG2hEc3-.js.map} +1 -1
  3. package/dist/EditorCanvasImpl-DgXvuWXX.js +70 -0
  4. package/dist/EditorCanvasImpl-DgXvuWXX.js.map +1 -0
  5. package/dist/EditorContext-CGkfmbgo.js +1178 -0
  6. package/dist/EditorContext-CGkfmbgo.js.map +1 -0
  7. package/dist/{ElementFactory-C05JJkRp.js → ElementFactory-CuHSAPfg.js} +1469 -710
  8. package/dist/ElementFactory-CuHSAPfg.js.map +1 -0
  9. package/dist/{HybridHistoryManager-Bht98XRv.js → FontAnalyzer-CLv7_msL.js} +2104 -2903
  10. package/dist/FontAnalyzer-CLv7_msL.js.map +1 -0
  11. package/dist/{ImportManager-kRYfIX-D.js → ImportManager-C_wBjWaV.js} +147 -147
  12. package/dist/{ImportManager-kRYfIX-D.js.map → ImportManager-C_wBjWaV.js.map} +1 -1
  13. package/dist/SnowconeCanvas-wdckG-6O.js +1179 -0
  14. package/dist/SnowconeCanvas-wdckG-6O.js.map +1 -0
  15. package/dist/{UnifiedFontService-BAtqqkU4.js → UnifiedFontService-Dsu5cwfT.js} +141 -141
  16. package/dist/UnifiedFontService-Dsu5cwfT.js.map +1 -0
  17. package/dist/advanced.mjs +10 -10
  18. package/dist/components/editor/RootInternals.d.ts +7 -0
  19. package/dist/components/editor/designStateStore.d.ts +1 -1
  20. package/dist/components/embed/EmbedRoot.d.ts +23 -0
  21. package/dist/components/embed/SnowconeCanvas.d.ts +13 -0
  22. package/dist/components/embed/kernel.d.ts +114 -0
  23. package/dist/contexts/BoundLayerGuardContext.d.ts +36 -0
  24. package/dist/core/GroupElement.d.ts +0 -5
  25. package/dist/core/TextElement.d.ts +8 -3
  26. package/dist/core/paint-registry.d.ts +42 -0
  27. package/dist/core/rich-text-layout.d.ts +28 -0
  28. package/dist/{editorErrors-DbIEtCTt.js → editorErrors-BY4Pdg7a.js} +2 -2
  29. package/dist/{editorErrors-DbIEtCTt.js.map → editorErrors-BY4Pdg7a.js.map} +1 -1
  30. package/dist/{embed-Bdj4PKUA.js → embed-32ZVWfmj.js} +209 -200
  31. package/dist/embed-32ZVWfmj.js.map +1 -0
  32. package/dist/embed.mjs +21 -22
  33. package/dist/embed.mjs.map +1 -1
  34. package/dist/index.mjs +7 -7
  35. package/dist/internals.mjs +93 -93
  36. package/dist/rendering/element-painters.d.ts +16 -0
  37. package/dist/rendering/rich-text-renderer.d.ts +3 -28
  38. package/dist/{template-fields-GOM4MNfq.js → template-fields-Z9x13sjM.js} +32 -33
  39. package/dist/{template-fields-GOM4MNfq.js.map → template-fields-Z9x13sjM.js.map} +1 -1
  40. package/dist/testing.mjs +7 -7
  41. package/dist/transforms/ArchTransform.d.ts +0 -1
  42. package/dist/transforms/AscendTransform.d.ts +0 -1
  43. package/dist/transforms/CircleTransform.d.ts +0 -1
  44. package/dist/transforms/FlagTransform.d.ts +0 -1
  45. package/dist/transforms/LeanTransform.d.ts +0 -1
  46. package/dist/transforms/WaveTransform.d.ts +0 -1
  47. package/dist/{usePieceGuideBundle-CGERAQJl.js → usePieceGuideBundle-C1ipFnZd.js} +2 -2
  48. package/dist/{usePieceGuideBundle-CGERAQJl.js.map → usePieceGuideBundle-C1ipFnZd.js.map} +1 -1
  49. package/dist/{validation-DEd6EOCP.js → validation-C795COGQ.js} +4803 -4791
  50. package/dist/validation-C795COGQ.js.map +1 -0
  51. package/dist/vendor/ui/primitives/kbd.d.ts +1 -1
  52. package/dist/workers/export-worker.bundle.string.d.ts +1 -1
  53. package/package.json +7 -4
  54. package/dist/EditorCanvasImpl-DkgE5-C2.js +0 -68
  55. package/dist/EditorCanvasImpl-DkgE5-C2.js.map +0 -1
  56. package/dist/EditorContext-CyanYzo2.js +0 -1131
  57. package/dist/EditorContext-CyanYzo2.js.map +0 -1
  58. package/dist/ElementFactory-C05JJkRp.js.map +0 -1
  59. package/dist/HybridHistoryManager-Bht98XRv.js.map +0 -1
  60. package/dist/SnowconeCanvas-C3eZ9PP8.js +0 -1047
  61. package/dist/SnowconeCanvas-C3eZ9PP8.js.map +0 -1
  62. package/dist/UnifiedFontService-BAtqqkU4.js.map +0 -1
  63. package/dist/editorError-DMENTZ-3.js +0 -19
  64. package/dist/editorError-DMENTZ-3.js.map +0 -1
  65. package/dist/embed-Bdj4PKUA.js.map +0 -1
  66. package/dist/validation-DEd6EOCP.js.map +0 -1
@@ -1,8 +1,8 @@
1
- import { jsx as Pe } from "react/jsx-runtime";
2
- import { useMemo as Y, useContext as Ge, createContext as Be, useRef as le, useState as K, useCallback as f, useEffect as be } from "react";
3
- import { u as fe } from "./EditorContext-CyanYzo2.js";
4
- import { G, c as Q, C as ce } from "./HybridHistoryManager-Bht98XRv.js";
5
- import { E as se } from "./ElementFactory-C05JJkRp.js";
1
+ import { useRef as le, useState as K, useCallback as f, useMemo as Y, useEffect as be, useContext as Pe, createContext as Ge } from "react";
2
+ import { u as fe } from "./EditorContext-CGkfmbgo.js";
3
+ import { G, c as Q, C as ce } from "./FontAnalyzer-CLv7_msL.js";
4
+ import { E as se } from "./ElementFactory-CuHSAPfg.js";
5
+ import { jsx as Be } from "react/jsx-runtime";
6
6
  const Ue = {
7
7
  "eos-icons:loading": {
8
8
  body: '<path fill="currentColor" d="M12 2A10 10 0 1 0 22 12A10 10 0 0 0 12 2Zm0 18a8 8 0 1 1 8-8A8 8 0 0 1 12 20Z" opacity=".5"/><path fill="currentColor" d="M20 12h2A10 10 0 0 0 12 2V4A8 8 0 0 1 20 12Z"><animateTransform attributeName="transform" dur="1s" from="0 12 12" repeatCount="indefinite" to="360 12 12" type="rotate"/></path>',
@@ -482,132 +482,27 @@ function lt() {
482
482
  he = !1;
483
483
  }));
484
484
  }
485
- async function Ae(e, t) {
486
- try {
487
- const r = await e.json();
488
- if (r && typeof r == "object") {
489
- const i = r;
490
- if (typeof i.error == "string" && i.error) return i.error;
491
- if (typeof i.message == "string" && i.message) return i.message;
492
- }
493
- } catch {
494
- }
495
- return t;
496
- }
497
- function Re(e) {
498
- return {
499
- async search({ query: t, page: r, perPage: i = 30 }) {
500
- const c = new URLSearchParams({
501
- query: t,
502
- page: String(r),
503
- perPage: String(i)
504
- }), a = e.includes("?") ? "&" : "?", l = await fetch(`${e}${a}${c.toString()}`, {
505
- method: "GET",
506
- credentials: "same-origin"
507
- });
508
- if (!l.ok)
509
- throw new Error(await Ae(l, `Image search failed (${l.status})`));
510
- return await l.json();
511
- },
512
- trackSelect(t) {
513
- fetch(e, {
514
- method: "POST",
515
- credentials: "same-origin",
516
- headers: { "Content-Type": "application/json" },
517
- body: JSON.stringify({
518
- action: "track-select",
519
- id: t.id,
520
- source: t.source,
521
- ...t.downloadLocation ? { downloadLocation: t.downloadLocation } : {}
522
- })
523
- }).catch(() => {
524
- });
525
- }
526
- };
527
- }
528
- function Oe(e) {
529
- return {
530
- async generate({ prompt: t, width: r, height: i, numberResults: c }) {
531
- const a = await fetch(e, {
532
- method: "POST",
533
- credentials: "same-origin",
534
- headers: { "Content-Type": "application/json" },
535
- body: JSON.stringify({ prompt: t, width: r, height: i, numberResults: c })
536
- });
537
- if (!a.ok)
538
- throw new Error(await Ae(a, `Image generation failed (${a.status})`));
539
- const l = await a.json();
540
- return { images: l.images ?? (l.imageUrl ? [{ imageUrl: l.imageUrl }] : []) };
541
- }
542
- };
543
- }
544
- function Ne(e) {
545
- const t = "/api/image-proxy?url=";
546
- if (!e || !e.startsWith(t)) return e;
547
- try {
548
- return decodeURIComponent(e.slice(t.length));
549
- } catch {
550
- return e;
551
- }
552
- }
553
- function We(e) {
554
- return async function(r) {
555
- const i = Ne(r);
556
- if (!/^https?:\/\//.test(i))
557
- throw new Error("Background removal isn't available for this image yet");
558
- const c = await fetch(e, {
559
- method: "POST",
560
- credentials: "same-origin",
561
- headers: { "Content-Type": "application/json" },
562
- body: JSON.stringify({ imageUrl: i })
563
- }), a = await c.json().catch(() => null);
564
- if (!c.ok || !(a != null && a.imageUrl))
565
- throw new Error((a == null ? void 0 : a.error) || (a == null ? void 0 : a.message) || `Background removal failed (${c.status})`);
566
- return a.imageUrl;
567
- };
568
- }
569
- const Me = {}, xe = Be(Me);
570
- function at({ services: e, children: t }) {
571
- const r = Y(() => e ? {
572
- imageSearch: e.imageSearch ?? (e.imageSearchUrl ? Re(e.imageSearchUrl) : void 0),
573
- generate: e.generate ?? (e.generateUrl ? Oe(e.generateUrl) : void 0),
574
- vectors: e.vectors,
575
- removeBackground: e.removeBackground ?? (e.bgRemoveUrl ? We(e.bgRemoveUrl) : void 0)
576
- } : Me, [
577
- e == null ? void 0 : e.imageSearch,
578
- e == null ? void 0 : e.imageSearchUrl,
579
- e == null ? void 0 : e.generate,
580
- e == null ? void 0 : e.generateUrl,
581
- e == null ? void 0 : e.vectors,
582
- e == null ? void 0 : e.bgRemoveUrl,
583
- e == null ? void 0 : e.removeBackground
584
- ]);
585
- return /* @__PURE__ */ Pe(xe.Provider, { value: r, children: t });
586
- }
587
- function dt() {
588
- return Ge(xe);
589
- }
590
- const De = Q("ElementPreviewRenderer"), _e = {
485
+ const Re = Q("ElementPreviewRenderer"), Oe = {
591
486
  width: 40,
592
487
  height: 40,
593
488
  padding: 4,
594
489
  backgroundColor: "transparent"
595
490
  };
596
- function Ze(e, t = {}) {
597
- const r = { ..._e, ...t }, i = document.createElement("canvas");
491
+ function Ne(e, t = {}) {
492
+ const r = { ...Oe, ...t }, i = document.createElement("canvas");
598
493
  i.width = r.width, i.height = r.height;
599
494
  const c = i.getContext("2d");
600
495
  if (!c)
601
496
  return "";
602
497
  r.backgroundColor !== "transparent" && (c.fillStyle = r.backgroundColor, c.fillRect(0, 0, r.width, r.height)), c.save();
603
498
  try {
604
- e instanceof G ? Ye(c, e, r) : Je(c, e, r);
499
+ e instanceof G ? De(c, e, r) : We(c, e, r);
605
500
  } catch (a) {
606
- De.warn("Failed to generate preview:", a);
501
+ Re.warn("Failed to generate preview:", a);
607
502
  }
608
503
  return c.restore(), i.toDataURL("image/png");
609
504
  }
610
- function Je(e, t, r) {
505
+ function We(e, t, r) {
611
506
  var j;
612
507
  const i = ((j = t.getBoundingBox) == null ? void 0 : j.call(t)) || { x: 0, y: 0, width: 100, height: 100 }, c = i.width, a = i.height;
613
508
  if (c === 0 || a === 0) {
@@ -627,7 +522,7 @@ function me(e, t, r) {
627
522
  const i = t.transformType || "Element";
628
523
  e.fillText(i, r.width / 2, r.height / 2);
629
524
  }
630
- function Ye(e, t, r) {
525
+ function De(e, t, r) {
631
526
  const i = r.width - r.padding * 2, c = r.height - r.padding * 2, a = r.padding, l = r.padding;
632
527
  e.fillStyle = "#888888", e.strokeStyle = "#666666", e.lineWidth = 1;
633
528
  const S = c * 0.7, h = l + c * 0.3, p = i * 0.4, y = c * 0.2;
@@ -637,10 +532,10 @@ function Ye(e, t, r) {
637
532
  h + S / 2
638
533
  ));
639
534
  }
640
- const M = Q("Layers"), qe = 150;
535
+ const M = Q("Layers"), _e = 150;
641
536
  async function we(e, t = 64, r = "transparent") {
642
537
  try {
643
- return Ze(e, {
538
+ return Ne(e, {
644
539
  width: t,
645
540
  height: t,
646
541
  padding: 8,
@@ -650,7 +545,7 @@ async function we(e, t = 64, r = "transparent") {
650
545
  return M.error("Failed to generate preview:", i), null;
651
546
  }
652
547
  }
653
- function Le(e, t, r, i, c, a = 0, l = null) {
548
+ function Ae(e, t, r, i, c, a = 0, l = null) {
654
549
  return (a > 0 ? e : e.filter((h) => {
655
550
  const p = h.parentId ?? null;
656
551
  return h instanceof G, p === null;
@@ -670,7 +565,7 @@ function Le(e, t, r, i, c, a = 0, l = null) {
670
565
  await c(h.id);
671
566
  }
672
567
  };
673
- return p && h instanceof G && (b.children = Le(
568
+ return p && h instanceof G && (b.children = Ae(
674
569
  h.children,
675
570
  t,
676
571
  r,
@@ -681,13 +576,13 @@ function Le(e, t, r, i, c, a = 0, l = null) {
681
576
  )), b;
682
577
  });
683
578
  }
684
- function Ee(e) {
579
+ function Me(e) {
685
580
  const t = [];
686
581
  for (const r of e)
687
- t.push(r), r.children && t.push(...Ee(r.children));
582
+ t.push(r), r.children && t.push(...Me(r.children));
688
583
  return t;
689
584
  }
690
- function ct(e = {}) {
585
+ function at(e = {}) {
691
586
  var pe;
692
587
  const {
693
588
  artboardId: t,
@@ -718,13 +613,13 @@ function ct(e = {}) {
718
613
  o = o.filter((d) => n.includes(d.id));
719
614
  }
720
615
  return r || (o = o.filter((n) => n.visible !== !1)), o;
721
- }, [l, I, r, p]), F = Y(() => Le(
616
+ }, [l, I, r, p]), F = Y(() => Ae(
722
617
  w,
723
618
  S,
724
619
  h,
725
620
  u.current,
726
621
  ie
727
- ), [w, S, h, ie, g]), v = Y(() => Ee(F), [F]), V = Y(() => v.filter((o) => o.isSelected), [v]), k = f((o, n = !1) => {
622
+ ), [w, S, h, ie, g]), v = Y(() => Me(F), [F]), V = Y(() => v.filter((o) => o.isSelected), [v]), k = f((o, n = !1) => {
728
623
  n ? h.includes(o) ? E(h.filter((d) => d !== o)) : E([...h, o]) : y(o);
729
624
  }, [h, E, y]), z = f((o) => {
730
625
  E(o);
@@ -862,7 +757,7 @@ function ct(e = {}) {
862
757
  if (!a) return;
863
758
  const o = setTimeout(() => {
864
759
  ae();
865
- }, qe);
760
+ }, _e);
866
761
  return () => clearTimeout(o);
867
762
  }, [a, ae]);
868
763
  const je = f(() => {
@@ -979,7 +874,7 @@ function ct(e = {}) {
979
874
  layerCount: v.length
980
875
  };
981
876
  }
982
- const ue = Q("useArtboards"), st = () => {
877
+ const ue = Q("useArtboards"), dt = () => {
983
878
  const {
984
879
  artboards: e,
985
880
  artboardManager: t,
@@ -1071,8 +966,8 @@ const ue = Q("useArtboards"), st = () => {
1071
966
  reorderArtboards: R,
1072
967
  count: e.length
1073
968
  };
1074
- }, Ke = Q("useExport");
1075
- function ht() {
969
+ }, Ze = Q("useExport");
970
+ function ct() {
1076
971
  const {
1077
972
  artboards: e,
1078
973
  artboardManager: t,
@@ -1200,7 +1095,7 @@ function ht() {
1200
1095
  te[W] = re;
1201
1096
  b((W) => ({ ...W, ...te })), U && U(te);
1202
1097
  } catch (T) {
1203
- Ke.error("[useExport] Continuous export error:", T);
1098
+ Ze.error("[useExport] Continuous export error:", T);
1204
1099
  }
1205
1100
  };
1206
1101
  (async () => {
@@ -1225,6 +1120,111 @@ function ht() {
1225
1120
  workerStats: E
1226
1121
  };
1227
1122
  }
1123
+ async function xe(e, t) {
1124
+ try {
1125
+ const r = await e.json();
1126
+ if (r && typeof r == "object") {
1127
+ const i = r;
1128
+ if (typeof i.error == "string" && i.error) return i.error;
1129
+ if (typeof i.message == "string" && i.message) return i.message;
1130
+ }
1131
+ } catch {
1132
+ }
1133
+ return t;
1134
+ }
1135
+ function Je(e) {
1136
+ return {
1137
+ async search({ query: t, page: r, perPage: i = 30 }) {
1138
+ const c = new URLSearchParams({
1139
+ query: t,
1140
+ page: String(r),
1141
+ perPage: String(i)
1142
+ }), a = e.includes("?") ? "&" : "?", l = await fetch(`${e}${a}${c.toString()}`, {
1143
+ method: "GET",
1144
+ credentials: "same-origin"
1145
+ });
1146
+ if (!l.ok)
1147
+ throw new Error(await xe(l, `Image search failed (${l.status})`));
1148
+ return await l.json();
1149
+ },
1150
+ trackSelect(t) {
1151
+ fetch(e, {
1152
+ method: "POST",
1153
+ credentials: "same-origin",
1154
+ headers: { "Content-Type": "application/json" },
1155
+ body: JSON.stringify({
1156
+ action: "track-select",
1157
+ id: t.id,
1158
+ source: t.source,
1159
+ ...t.downloadLocation ? { downloadLocation: t.downloadLocation } : {}
1160
+ })
1161
+ }).catch(() => {
1162
+ });
1163
+ }
1164
+ };
1165
+ }
1166
+ function Ye(e) {
1167
+ return {
1168
+ async generate({ prompt: t, width: r, height: i, numberResults: c }) {
1169
+ const a = await fetch(e, {
1170
+ method: "POST",
1171
+ credentials: "same-origin",
1172
+ headers: { "Content-Type": "application/json" },
1173
+ body: JSON.stringify({ prompt: t, width: r, height: i, numberResults: c })
1174
+ });
1175
+ if (!a.ok)
1176
+ throw new Error(await xe(a, `Image generation failed (${a.status})`));
1177
+ const l = await a.json();
1178
+ return { images: l.images ?? (l.imageUrl ? [{ imageUrl: l.imageUrl }] : []) };
1179
+ }
1180
+ };
1181
+ }
1182
+ function qe(e) {
1183
+ const t = "/api/image-proxy?url=";
1184
+ if (!e || !e.startsWith(t)) return e;
1185
+ try {
1186
+ return decodeURIComponent(e.slice(t.length));
1187
+ } catch {
1188
+ return e;
1189
+ }
1190
+ }
1191
+ function Ke(e) {
1192
+ return async function(r) {
1193
+ const i = qe(r);
1194
+ if (!/^https?:\/\//.test(i))
1195
+ throw new Error("Background removal isn't available for this image yet");
1196
+ const c = await fetch(e, {
1197
+ method: "POST",
1198
+ credentials: "same-origin",
1199
+ headers: { "Content-Type": "application/json" },
1200
+ body: JSON.stringify({ imageUrl: i })
1201
+ }), a = await c.json().catch(() => null);
1202
+ if (!c.ok || !(a != null && a.imageUrl))
1203
+ throw new Error((a == null ? void 0 : a.error) || (a == null ? void 0 : a.message) || `Background removal failed (${c.status})`);
1204
+ return a.imageUrl;
1205
+ };
1206
+ }
1207
+ const Le = {}, Ee = Ge(Le);
1208
+ function st({ services: e, children: t }) {
1209
+ const r = Y(() => e ? {
1210
+ imageSearch: e.imageSearch ?? (e.imageSearchUrl ? Je(e.imageSearchUrl) : void 0),
1211
+ generate: e.generate ?? (e.generateUrl ? Ye(e.generateUrl) : void 0),
1212
+ vectors: e.vectors,
1213
+ removeBackground: e.removeBackground ?? (e.bgRemoveUrl ? Ke(e.bgRemoveUrl) : void 0)
1214
+ } : Le, [
1215
+ e == null ? void 0 : e.imageSearch,
1216
+ e == null ? void 0 : e.imageSearchUrl,
1217
+ e == null ? void 0 : e.generate,
1218
+ e == null ? void 0 : e.generateUrl,
1219
+ e == null ? void 0 : e.vectors,
1220
+ e == null ? void 0 : e.bgRemoveUrl,
1221
+ e == null ? void 0 : e.removeBackground
1222
+ ]);
1223
+ return /* @__PURE__ */ Be(Ee.Provider, { value: r, children: t });
1224
+ }
1225
+ function ht() {
1226
+ return Pe(Ee);
1227
+ }
1228
1228
  const ye = Q("GoogleFontsService");
1229
1229
  let X = [], ne = null;
1230
1230
  async function Xe() {
@@ -1463,16 +1463,16 @@ class et {
1463
1463
  }
1464
1464
  const ut = new et();
1465
1465
  export {
1466
- at as C,
1466
+ st as C,
1467
1467
  ut as U,
1468
- Oe as a,
1469
- Re as b,
1470
- We as c,
1471
- dt as d,
1468
+ Ye as a,
1469
+ Je as b,
1470
+ Ke as c,
1471
+ ht as d,
1472
1472
  lt as e,
1473
- ht as f,
1474
- ct as g,
1475
- Ze as h,
1476
- st as u
1473
+ ct as f,
1474
+ at as g,
1475
+ Ne as h,
1476
+ dt as u
1477
1477
  };
1478
- //# sourceMappingURL=UnifiedFontService-BAtqqkU4.js.map
1478
+ //# sourceMappingURL=UnifiedFontService-Dsu5cwfT.js.map