@printine/pod-editor 0.1.19 → 0.1.21

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 (34) hide show
  1. package/README.md +8 -0
  2. package/dist/components/context.d.ts +7 -0
  3. package/dist/components/menus/sca.d.ts +2 -4
  4. package/dist/components/personalization-background.d.ts +6 -0
  5. package/dist/components/personalization-controller.d.ts +2 -0
  6. package/dist/components/personalization-preview.d.ts +5 -0
  7. package/dist/components/personalization-shared.d.ts +3 -0
  8. package/dist/components/preview/real-time/index.d.ts +2 -1
  9. package/dist/components/semi-deisgn-config.d.ts +8 -2
  10. package/dist/{design-BXbmX1Tb.js → design-zuaYzDgn.js} +8687 -8449
  11. package/dist/designer-store-BZFMaojO.js +261 -0
  12. package/dist/engine/constants.js +1 -1
  13. package/dist/engine/editor.js +120 -116
  14. package/dist/engine/events.d.ts +6 -0
  15. package/dist/engine/managers/event.js +1 -1
  16. package/dist/full-designer.js +3 -3
  17. package/dist/i18n/personalization.d.ts +3 -0
  18. package/dist/index.js +6 -6
  19. package/dist/lib/personalization.d.ts +78 -0
  20. package/dist/personalization-preview-D9z7Ketn.js +352 -0
  21. package/dist/pixel-map-CSpWvUYE.js +315 -0
  22. package/dist/{pixi-print-base-CKs4lF7h.js → pixi-print-base-DIvtSF7v.js} +1 -1
  23. package/dist/renderer/pixel-map.d.ts +9 -2
  24. package/dist/{semi-interact-editor-nZVBXXQn.js → semi-interact-editor-DpzQN5ZB.js} +2 -2
  25. package/dist/semi-renderer.js +1 -1
  26. package/dist/state/designer-store.d.ts +2 -0
  27. package/dist/state/designer-store.js +1 -1
  28. package/dist/style.css +1 -1
  29. package/docs/BUYER_PERSONALIZATION.md +137 -0
  30. package/docs/HOST_DATA_CONTRACT.md +1 -1
  31. package/docs/SEMI_RENDERER.md +37 -1
  32. package/package.json +3 -1
  33. package/dist/designer-store-Da9fICz8.js +0 -153
  34. package/dist/pixel-map-BvQ0VU_i.js +0 -199
@@ -4,14 +4,14 @@ import { cloneObject as b, urlToDataURL as E } from "./utils/common.js";
4
4
  import { loadOverlaySvgImage as T, loadImage as B } from "./utils/image.js";
5
5
  import { Loading as Y } from "./utils/loading.js";
6
6
  import { HistoryManager as X } from "./history.js";
7
- import { LAYER_BLACK_LIST as R } from "./constants.js";
7
+ import { LAYER_BLACK_LIST as I } from "./constants.js";
8
8
  import U from "./events.js";
9
9
  import { ImageProcessor as L } from "./processors/image.js";
10
10
  import { TemplateProcessor as W } from "./processors/template.js";
11
11
  import { TextProcessor as D } from "./processors/text.js";
12
12
  import { ResizeManager as _ } from "./managers/resize.js";
13
13
  import { WorkspaceManager as q } from "./managers/workspace.js";
14
- import { fabric as p } from "fabric";
14
+ import { fabric as f } from "fabric";
15
15
  class se {
16
16
  constructor(t, a, e, r = {}) {
17
17
  this.previewExporting = !1, this.imageCache = /* @__PURE__ */ new Map(), this.overlayCache = /* @__PURE__ */ new Map(), this.destroyed = !1, this.deleteObject = (n) => {
@@ -27,7 +27,7 @@ class se {
27
27
  this.canvas.requestRenderAll();
28
28
  };
29
29
  const s = typeof r == "number" ? { overlayScale: r } : r;
30
- this.canvas = new p.Canvas(t, {
30
+ this.canvas = new f.Canvas(t, {
31
31
  enableRetinaScaling: !0,
32
32
  width: a.width,
33
33
  height: a.height,
@@ -60,44 +60,44 @@ class se {
60
60
  * 统一拦截图片创建:优先从会话缓存复用已加载的 HTMLImageElement,避免视图切换或导出时重复请求远程图片
61
61
  */
62
62
  setupImageCacheInterceptor() {
63
- const t = this.imageCache, a = p.Image.fromURL, e = p.Image.fromObject;
64
- if (p.Image._printineCacheHooked) return;
65
- p.Image._printineCacheHooked = !0;
63
+ const t = this.imageCache, a = f.Image.fromURL, e = f.Image.fromObject;
64
+ if (f.Image._printineCacheHooked) return;
65
+ f.Image._printineCacheHooked = !0;
66
66
  const r = (n) => {
67
67
  if (!n) return null;
68
68
  const i = t.get(n);
69
69
  return i?.element && i.element.complete ? (t.set(n, { ...i, lastUsed: Date.now() }), i.element) : null;
70
70
  };
71
- p.Image.fromURL = function(n, i, c) {
71
+ f.Image.fromURL = function(n, i, c) {
72
72
  const o = { ...c, crossOrigin: "anonymous" }, l = r(n);
73
73
  if (l) {
74
- const f = new p.Image(l, o);
75
- f.originSrc = n, i && i(f);
74
+ const m = new f.Image(l, o);
75
+ m.originSrc = n, i && i(m);
76
76
  return;
77
77
  }
78
78
  return a.call(
79
79
  this,
80
80
  n,
81
- (f) => {
82
- f && (f.originSrc = n), i && i(f);
81
+ (m) => {
82
+ m && (m.originSrc = n), i && i(m);
83
83
  },
84
84
  o
85
85
  );
86
86
  };
87
87
  const s = (n) => !!n && typeof n == "object" && typeof n.set == "function" && typeof n.shouldCache == "function";
88
- p.Image.fromObject = function(n, i) {
88
+ f.Image.fromObject = function(n, i) {
89
89
  const c = n?.originSrc || n?.src, o = r(c);
90
90
  if (o) {
91
- const { clipPath: l, ...f } = n ?? {}, v = new p.Image(o, { ...f });
92
- if (v.originSrc = c, !l || s(l)) {
93
- l && (v.clipPath = l), i?.(v);
91
+ const { clipPath: l, ...m } = n ?? {}, u = new f.Image(o, { ...m });
92
+ if (u.originSrc = c, !l || s(l)) {
93
+ l && (u.clipPath = l), i?.(u);
94
94
  return;
95
95
  }
96
- p.util.enlivenObjects(
96
+ f.util.enlivenObjects(
97
97
  [l],
98
- (u) => {
99
- const [C] = u || [];
100
- C && (v.clipPath = C), i?.(v);
98
+ (w) => {
99
+ const [O] = w || [];
100
+ O && (u.clipPath = O), i?.(u);
101
101
  },
102
102
  ""
103
103
  );
@@ -182,26 +182,26 @@ class se {
182
182
  strokeUniform: !0,
183
183
  objectCaching: !1
184
184
  }), e.render(r);
185
- const i = 6, c = (e.getScaledWidth() + i * 2) / e.getScaledWidth(), o = (e.getScaledHeight() + i * 2) / e.getScaledHeight(), l = e.left ?? 0, f = e.top ?? 0, v = e.scaleX ?? 1, u = e.scaleY ?? 1;
185
+ const i = 6, c = (e.getScaledWidth() + i * 2) / e.getScaledWidth(), o = (e.getScaledHeight() + i * 2) / e.getScaledHeight(), l = e.left ?? 0, m = e.top ?? 0, u = e.scaleX ?? 1, w = e.scaleY ?? 1;
186
186
  e.set({
187
187
  strokeDashArray: [4, 4],
188
188
  stroke: "#C3C3CC",
189
189
  strokeWidth: 1,
190
190
  strokeUniform: !0,
191
- scaleX: v * c,
192
- scaleY: u * o,
191
+ scaleX: u * c,
192
+ scaleY: w * o,
193
193
  left: l - i,
194
- top: f - i
194
+ top: m - i
195
195
  }), e.render(r), e.set({
196
196
  stroke: n.stroke,
197
197
  strokeWidth: n.strokeWidth,
198
198
  strokeDashArray: n.strokeDashArray,
199
199
  fill: n.fill,
200
200
  strokeUniform: n.strokeUniform,
201
- scaleX: v,
202
- scaleY: u,
201
+ scaleX: u,
202
+ scaleY: w,
203
203
  left: l,
204
- top: f
204
+ top: m
205
205
  }), r.restore();
206
206
  }, this.canvas.on("after:render", this.overlayBorderHandler);
207
207
  }
@@ -260,7 +260,7 @@ class se {
260
260
  */
261
261
  async restoreObject(t) {
262
262
  return new Promise((a) => {
263
- p.util.enlivenObjects([t], (e) => a(e), "");
263
+ f.util.enlivenObjects([t], (e) => a(e), "");
264
264
  });
265
265
  }
266
266
  /**
@@ -357,7 +357,7 @@ class se {
357
357
  * 获取当前可选择的对象,不包括背景图、裁剪区域
358
358
  */
359
359
  getLayerList() {
360
- return this.canvas._objects.filter((t) => !R.includes(t.id || ""));
360
+ return this.canvas._objects.filter((t) => !I.includes(t.id || ""));
361
361
  }
362
362
  /**
363
363
  * 设置当前选中的对象
@@ -370,7 +370,7 @@ class se {
370
370
  * 同时选中多个对象
371
371
  */
372
372
  setActiveObjects(t) {
373
- const a = new p.ActiveSelection(t, { canvas: this.canvas });
373
+ const a = new f.ActiveSelection(t, { canvas: this.canvas });
374
374
  this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
375
375
  }
376
376
  /**
@@ -391,7 +391,7 @@ class se {
391
391
  getRenderedObjects() {
392
392
  const { objects: t } = this.canvas.toJSON(X.DEFAULT_SAVE_PROPERTIES), a = this.workspaceManager.dimension;
393
393
  return {
394
- objects: t.filter((e) => !R.includes(e.id || "")),
394
+ objects: t.filter((e) => !I.includes(e.id || "")),
395
395
  workspaceMetadata: {
396
396
  width: a.width,
397
397
  height: a.height,
@@ -431,7 +431,7 @@ class se {
431
431
  async switchView(t, a, e) {
432
432
  if (this.isCanvasReady()) {
433
433
  if (this.canvas.clear(), e && e.objects && e.objects.length)
434
- return p.AdvancedIText = A, await this.textProcessor.preloadFontsFromState(e), this.isCanvasReady() ? new Promise((r) => {
434
+ return f.AdvancedIText = A, await this.textProcessor.preloadFontsFromState(e), this.isCanvasReady() ? new Promise((r) => {
435
435
  this.canvas.loadFromJSON(
436
436
  e,
437
437
  async () => {
@@ -465,7 +465,7 @@ class se {
465
465
  this.canvas.renderAll(), this.events.emit("design:layerChange"), r();
466
466
  },
467
467
  (s, n) => {
468
- s.clipPath && !e.objects.some((i) => i.id === s.clipPath.id) && (delete n.clipPath, p.util.enlivenObjects(
468
+ s.clipPath && !e.objects.some((i) => i.id === s.clipPath.id) && (delete n.clipPath, f.util.enlivenObjects(
469
469
  [s.clipPath],
470
470
  (i) => {
471
471
  const c = i[0];
@@ -486,30 +486,30 @@ class se {
486
486
  const a = this.workspaceManager.dimension, e = Math.min(
487
487
  a.width / t.width,
488
488
  a.height / t.height
489
- ), r = t.centerX, s = t.centerY, n = a.center.x, i = a.center.y, c = Math.abs(n - r), o = Math.abs(i - s), l = Math.abs(e - 1) >= 1e-3, f = c >= 0.1 || o >= 0.1;
490
- if (!l && !f) return;
491
- const v = this.canvas.getObjects(), u = new Set(v), C = /* @__PURE__ */ new Set(), P = (d) => {
492
- const g = d.clipPath;
493
- g && u.has(g) && C.add(g);
489
+ ), r = t.centerX, s = t.centerY, n = a.center.x, i = a.center.y, c = Math.abs(n - r), o = Math.abs(i - s), l = Math.abs(e - 1) >= 1e-3, m = c >= 0.1 || o >= 0.1;
490
+ if (!l && !m) return;
491
+ const u = this.canvas.getObjects(), w = new Set(u), O = /* @__PURE__ */ new Set(), k = (d) => {
492
+ const p = d.clipPath;
493
+ p && w.has(p) && O.add(p);
494
494
  };
495
- v.forEach(P);
496
- const O = (d) => {
497
- const g = (d.left || 0) - r, y = (d.top || 0) - s, w = n + g * e, m = i + y * e;
495
+ u.forEach(k);
496
+ const g = (d) => {
497
+ const p = (d.left || 0) - r, P = (d.top || 0) - s, y = n + p * e, v = i + P * e;
498
498
  d.set({
499
- left: w,
500
- top: m,
499
+ left: y,
500
+ top: v,
501
501
  scaleX: (d.scaleX || 1) * e,
502
502
  scaleY: (d.scaleY || 1) * e
503
503
  }), d.setCoords(), d.dirty = !0;
504
- }, k = /* @__PURE__ */ new Set(), S = (d) => {
505
- !d.selectable && !C.has(d) || (O(d), k.add(d));
504
+ }, C = /* @__PURE__ */ new Set(), S = (d) => {
505
+ !d.selectable && !O.has(d) || (g(d), C.add(d));
506
506
  };
507
- v.forEach(S);
507
+ u.forEach(S);
508
508
  const h = (d) => {
509
- const g = d.clipPath;
510
- g && g.absolutePositioned && !u.has(g) && !k.has(g) && (O(g), k.add(g));
509
+ const p = d.clipPath;
510
+ p && p.absolutePositioned && !w.has(p) && !C.has(p) && (g(p), C.add(p));
511
511
  };
512
- v.forEach(h);
512
+ u.forEach(h);
513
513
  }
514
514
  /**
515
515
  * 计算对象相对于画布的全局变换矩阵(包括父组的影响)
@@ -594,7 +594,7 @@ class se {
594
594
  });
595
595
  const i = this.imageCache.get(n);
596
596
  return i?.element && i.element.complete ? new Promise(async (c) => {
597
- const o = new p.Image(i.element, {
597
+ const o = new f.Image(i.element, {
598
598
  width: t.width,
599
599
  height: t.height,
600
600
  ...a
@@ -619,7 +619,7 @@ class se {
619
619
  */
620
620
  async export(t = !1, a) {
621
621
  const e = this.workspaceManager.dimension, r = this.workspaceManager.printAreaSize?.width ?? e.width, s = this.workspaceManager.printAreaSize?.height ?? e.height, n = window.devicePixelRatio || 1, i = Math.max(r / e.width, s / e.height), c = Math.max(4, Math.min(8, Math.ceil(i * n)));
622
- let o = new p.Rect({
622
+ let o = new f.Rect({
623
623
  left: 0,
624
624
  top: 0,
625
625
  width: e.width,
@@ -632,41 +632,41 @@ class se {
632
632
  top: this.canvas.clipPath.top - e.top,
633
633
  absolutePositioned: !0
634
634
  }));
635
- const l = new p.StaticCanvas(null, {
635
+ const l = new f.StaticCanvas(null, {
636
636
  width: e.width,
637
637
  height: e.height,
638
638
  enableRetinaScaling: !1,
639
639
  backgroundColor: a || "transparent",
640
640
  preserveObjectStacking: !0,
641
641
  clipPath: o
642
- }), f = this.getLayerList();
642
+ }), m = this.getLayerList();
643
643
  (await Promise.all(
644
- f.map(
644
+ m.map(
645
645
  (h) => new Promise((d) => {
646
646
  try {
647
647
  if (h.type === "image") {
648
- const g = h;
649
- let y = {
648
+ const p = h;
649
+ let P = {
650
650
  selectable: !1,
651
651
  evented: !1,
652
652
  flipX: h.flipX || !1,
653
653
  flipY: h.flipY || !1
654
654
  };
655
655
  if (this.isInActiveSelection(h)) {
656
- const w = this.getGlobalTransformMatrix(h), m = p.util.qrDecompose(w);
657
- y = {
658
- ...y,
659
- left: (m.translateX || 0) - (e.left || 0),
660
- top: (m.translateY || 0) - (e.top || 0),
661
- angle: m.angle || 0,
662
- scaleX: m.scaleX || 1,
663
- scaleY: m.scaleY || 1,
656
+ const y = this.getGlobalTransformMatrix(h), v = f.util.qrDecompose(y);
657
+ P = {
658
+ ...P,
659
+ left: (v.translateX || 0) - (e.left || 0),
660
+ top: (v.translateY || 0) - (e.top || 0),
661
+ angle: v.angle || 0,
662
+ scaleX: v.scaleX || 1,
663
+ scaleY: v.scaleY || 1,
664
664
  originX: "center",
665
665
  originY: "center"
666
666
  };
667
667
  } else
668
- y = {
669
- ...y,
668
+ P = {
669
+ ...P,
670
670
  left: h.left - e.left,
671
671
  top: h.top - e.top,
672
672
  angle: h.angle || 0,
@@ -675,39 +675,39 @@ class se {
675
675
  originX: "left",
676
676
  originY: "top"
677
677
  };
678
- this.cloneImageFromCache(g, y).then(async (w) => {
679
- if (w.clipPath) {
680
- const m = w.clipPath;
681
- m.absolutePositioned && m.set({
682
- left: (m.left || 0) - e.left,
683
- top: (m.top || 0) - e.top
678
+ this.cloneImageFromCache(p, P).then(async (y) => {
679
+ if (y.clipPath) {
680
+ const v = y.clipPath;
681
+ v.absolutePositioned && v.set({
682
+ left: (v.left || 0) - e.left,
683
+ top: (v.top || 0) - e.top
684
684
  });
685
685
  }
686
- if (t && w.type === "image")
686
+ if (t && y.type === "image")
687
687
  try {
688
- const m = w, I = m.getSrc() || m.originSrc || "";
689
- if (I) {
690
- const x = await this.getCachedDataURL(I);
691
- m.setSrc(x, () => d(w));
688
+ const v = y, R = v.getSrc() || v.originSrc || "";
689
+ if (R) {
690
+ const x = await this.getCachedDataURL(R);
691
+ v.setSrc(x, () => d(y));
692
692
  return;
693
693
  }
694
694
  } catch {
695
695
  }
696
- d(w);
696
+ d(y);
697
697
  }).catch(() => {
698
698
  d(h);
699
699
  });
700
700
  } else
701
701
  h.cloneAsImage(
702
- (g) => {
702
+ (p) => {
703
703
  if (this.isInActiveSelection(h)) {
704
- const y = this.getGlobalTransformMatrix(h), w = p.util.qrDecompose(y);
705
- g.set({
706
- left: (w.translateX || 0) - (e.left || 0),
707
- top: (w.translateY || 0) - (e.top || 0),
708
- angle: w.angle || 0,
709
- scaleX: (w.scaleX || 1) / c,
710
- scaleY: (w.scaleY || 1) / c,
704
+ const P = this.getGlobalTransformMatrix(h), y = f.util.qrDecompose(P);
705
+ p.set({
706
+ left: (y.translateX || 0) - (e.left || 0),
707
+ top: (y.translateY || 0) - (e.top || 0),
708
+ angle: y.angle || 0,
709
+ scaleX: (y.scaleX || 1) / c,
710
+ scaleY: (y.scaleY || 1) / c,
711
711
  selectable: !1,
712
712
  hasControls: !1,
713
713
  hasBorders: !1,
@@ -715,10 +715,10 @@ class se {
715
715
  originY: "center"
716
716
  });
717
717
  } else {
718
- const y = h.getBoundingRect(!0, !0);
719
- g.set({
720
- left: y.left - e.left,
721
- top: y.top - e.top,
718
+ const P = h.getBoundingRect(!0, !0);
719
+ p.set({
720
+ left: P.left - e.left,
721
+ top: P.top - e.top,
722
722
  scaleX: 1 / c,
723
723
  scaleY: 1 / c,
724
724
  angle: 0,
@@ -729,7 +729,7 @@ class se {
729
729
  originY: "top"
730
730
  });
731
731
  }
732
- d(g);
732
+ d(p);
733
733
  },
734
734
  { multiplier: c }
735
735
  );
@@ -739,25 +739,25 @@ class se {
739
739
  })
740
740
  )
741
741
  )).forEach((h) => l.add(h));
742
- const u = r / e.width, C = s / e.height;
743
- l.setViewportTransform([u, 0, 0, C, 0, 0]), l.renderAll();
744
- const P = 1024;
745
- let O = 1;
746
- (r < P || s < P) && (O = Math.max(1, P / Math.max(r, s)));
747
- let k = "";
742
+ const w = r / e.width, O = s / e.height;
743
+ l.setViewportTransform([w, 0, 0, O, 0, 0]), l.renderAll();
744
+ const k = 1024;
745
+ let g = 1;
746
+ (r < k || s < k) && (g = Math.max(1, k / Math.max(r, s)));
747
+ let C = "";
748
748
  const S = () => l.toDataURL({
749
749
  format: "webp",
750
750
  quality: 0.5,
751
751
  width: r,
752
752
  height: s,
753
- multiplier: O
753
+ multiplier: g
754
754
  });
755
755
  if (window.createImageBitmap && typeof l.toCanvasElement == "function") {
756
- const h = l.toCanvasElement(O, { width: r, height: s });
757
- k = await createImageBitmap(h);
756
+ const h = l.toCanvasElement(g, { width: r, height: s });
757
+ C = await createImageBitmap(h);
758
758
  } else
759
- k = S();
760
- return l.dispose(), k;
759
+ C = S();
760
+ return l.dispose(), C;
761
761
  }
762
762
  /**
763
763
  * Rasterize the current design for real-time product previews without
@@ -771,27 +771,31 @@ class se {
771
771
  const e = this.workspaceManager.dimension, r = this.workspaceManager.printAreaSize?.width ?? e.width, s = this.workspaceManager.printAreaSize?.height ?? e.height;
772
772
  if (!e.width || !e.height || !r || !s)
773
773
  throw new Error("Printable workspace has no dimensions");
774
- const n = Math.max(r, s), i = t / n, c = Math.max(1, Math.round(r * i)), o = Math.max(1, Math.round(s * i)), l = this.canvas.viewportTransform?.slice(), f = this.canvas.overlayImage?.visible, v = this.canvas.backgroundColor, u = this.canvas.getActiveObject(), C = u ? { hasBorders: u.hasBorders, hasControls: u.hasControls } : null;
774
+ const n = Math.max(r, s), i = t / n, c = Math.max(1, Math.round(r * i)), o = Math.max(1, Math.round(s * i)), l = this.canvas.viewportTransform?.slice(), m = this.canvas.overlayImage?.visible, u = this.canvas.backgroundColor, w = this.canvas.getActiveObject(), O = w ? { hasBorders: w.hasBorders, hasControls: w.hasControls } : null, k = this.canvas.getObjects().filter((g) => g.id === "loading" || g.id === "cropRect" || g.id === "cropOverlay").map((g) => ({ object: g, visible: g.visible }));
775
775
  try {
776
- this.previewExporting = !0, this.canvas.overlayImage && (this.canvas.overlayImage.visible = !1), u?.set({ hasBorders: !1, hasControls: !1 }), this.canvas.backgroundColor = a || "transparent", this.canvas.viewportTransform = [1, 0, 0, 1, 0, 0], this.canvas.renderAll();
777
- const P = document.createElement("canvas");
778
- P.width = c, P.height = o;
779
- const O = P.getContext("2d", { alpha: !0 });
780
- if (!O) throw new Error("Could not create preview canvas context");
781
- const k = this.canvas, S = k.getRetinaScaling?.() ?? window.devicePixelRatio ?? 1;
782
- return O.drawImage(
783
- k.lowerCanvasEl,
784
- e.left * S,
785
- e.top * S,
786
- e.width * S,
787
- e.height * S,
776
+ this.previewExporting = !0, this.canvas.overlayImage && (this.canvas.overlayImage.visible = !1), w?.set({ hasBorders: !1, hasControls: !1 }), k.forEach(({ object: d }) => {
777
+ d.visible = !1;
778
+ }), this.canvas.backgroundColor = a || "transparent", this.canvas.viewportTransform = [1, 0, 0, 1, 0, 0], this.canvas.renderAll();
779
+ const g = document.createElement("canvas");
780
+ g.width = c, g.height = o;
781
+ const C = g.getContext("2d", { alpha: !0 });
782
+ if (!C) throw new Error("Could not create preview canvas context");
783
+ const S = this.canvas, h = S.getRetinaScaling?.() ?? window.devicePixelRatio ?? 1;
784
+ return C.drawImage(
785
+ S.lowerCanvasEl,
786
+ e.left * h,
787
+ e.top * h,
788
+ e.width * h,
789
+ e.height * h,
788
790
  0,
789
791
  0,
790
792
  c,
791
793
  o
792
- ), await createImageBitmap(P);
794
+ ), await createImageBitmap(g);
793
795
  } finally {
794
- this.canvas.backgroundColor = v, this.canvas.overlayImage && f !== void 0 && (this.canvas.overlayImage.visible = f), u && C && u.set(C), l && (this.canvas.viewportTransform = l), this.previewExporting = !1, this.isCanvasReady() && this.canvas.requestRenderAll();
796
+ this.canvas.backgroundColor = u, this.canvas.overlayImage && m !== void 0 && (this.canvas.overlayImage.visible = m), w && O && w.set(O), k.forEach(({ object: g, visible: C }) => {
797
+ g.visible = C;
798
+ }), l && (this.canvas.viewportTransform = l), this.previewExporting = !1, this.isCanvasReady() && this.canvas.requestRenderAll();
795
799
  }
796
800
  }
797
801
  }
@@ -25,6 +25,12 @@ export type AppEvents = {
25
25
  extraData?: any;
26
26
  };
27
27
  'design:preview': void;
28
+ 'design:personalizationSettings': {
29
+ id: string;
30
+ placement?: string;
31
+ };
32
+ 'design:personalizationBackgroundSettings': void;
33
+ 'design:buyerPreview': void;
28
34
  'design:editorCommand': 'SELECT_ALL' | 'COPY' | 'PASTE';
29
35
  'search:open': void;
30
36
  };
@@ -5,7 +5,7 @@ import { HistoryManager as D } from "../history.js";
5
5
  import { SnaplineManager as L } from "./snapline.js";
6
6
  import { TextProcessor as T } from "../processors/text.js";
7
7
  import { toVerticalStack as z } from "../utils/common.js";
8
- import { u as R } from "../../designer-store-Da9fICz8.js";
8
+ import { u as R } from "../../designer-store-BZFMaojO.js";
9
9
  import { fabric as x } from "fabric";
10
10
  class V {
11
11
  constructor(t, o) {
@@ -1,14 +1,14 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
- import { c as s } from "./design-BXbmX1Tb.js";
3
+ import { c as s } from "./design-zuaYzDgn.js";
4
4
  import "./engine/events.js";
5
5
  import "zustand/react/shallow";
6
6
  import "./engine/history.js";
7
7
  import "lodash-es/throttle";
8
8
  import "./engine/constants.js";
9
9
  import "./engine/utils/common.js";
10
- import "./pixel-map-BvQ0VU_i.js";
11
- import "./designer-store-Da9fICz8.js";
10
+ import "./pixel-map-CSpWvUYE.js";
11
+ import "./designer-store-BZFMaojO.js";
12
12
  export {
13
13
  s as default
14
14
  };
@@ -0,0 +1,3 @@
1
+ export declare const personalizationMessages: {
2
+ es: Record<string, string>;
3
+ };
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { AdvancedIText as G } from "./engine/fabric.js";
2
- import { a as S, s as f, D as L, b as _, c as C, C as F } from "./design-BXbmX1Tb.js";
3
- import { F as K, S as V, u as X } from "./design-BXbmX1Tb.js";
2
+ import { a as S, s as f, D as L, b as _, c as C, C as F } from "./design-zuaYzDgn.js";
3
+ import { F as K, S as V, u as X } from "./design-zuaYzDgn.js";
4
4
  import { jsx as r, jsxs as R } from "react/jsx-runtime";
5
5
  import { useMemo as b, useEffect as a } from "react";
6
6
  import { DEFAULT_PRINTINE_ASSET_BASE_URL as U, createAssetCenterApiClient as B } from "./api/asset-client.js";
7
- import { s as d } from "./designer-store-Da9fICz8.js";
8
- import { A as $, u as q } from "./designer-store-Da9fICz8.js";
7
+ import { s as d } from "./designer-store-BZFMaojO.js";
8
+ import { A as $, u as q } from "./designer-store-BZFMaojO.js";
9
9
  import { d as y, s as M } from "./config-D2qm60gf.js";
10
- import { P as Q, a as ee } from "./semi-interact-editor-nZVBXXQn.js";
11
- import { P as te } from "./pixel-map-BvQ0VU_i.js";
10
+ import { P as Q, a as ee } from "./semi-interact-editor-DpzQN5ZB.js";
11
+ import { P as te } from "./pixel-map-CSpWvUYE.js";
12
12
  import { CanvasDesigner as ae, renderPlacementPreviews as ne } from "./engine/canvas-designer.js";
13
13
  import { Editor as ie } from "./engine/editor.js";
14
14
  import { HistoryManager as me } from "./engine/history.js";
@@ -0,0 +1,78 @@
1
+ import type { Mockup } from '../contracts/api-design';
2
+ export type PersonalizationKind = 'text' | 'image' | 'svg';
3
+ export type DesignDocuments = Record<string, Record<string, any>>;
4
+ export type PersonalizationConfigs = Record<string, Record<string, any> | undefined>;
5
+ export interface PersonalizationLayer {
6
+ id: string;
7
+ placement: string;
8
+ placementLabel: string;
9
+ kind: PersonalizationKind | null;
10
+ name: string;
11
+ source: string;
12
+ object: Record<string, any>;
13
+ }
14
+ export interface PersonalizationField {
15
+ key: string;
16
+ kind: PersonalizationKind;
17
+ config: Record<string, any>;
18
+ targets: PersonalizationLayer[];
19
+ }
20
+ export declare function personalizationKind(object: Record<string, any>): PersonalizationKind | null;
21
+ export declare function personalizationLayers(data: DesignDocuments, areas: Mockup[]): PersonalizationLayer[];
22
+ /** Only new permissions use these conservative defaults; restored configs are not rewritten. */
23
+ export declare function defaultPersonalizationConfig(kind: PersonalizationKind, name: string): {
24
+ enableColor?: boolean | undefined;
25
+ enableAI?: boolean | undefined;
26
+ backgroundRemove?: boolean | undefined;
27
+ portraitCutout?: boolean | undefined;
28
+ cartoonize?: boolean | undefined;
29
+ stickerOutline?: boolean | undefined;
30
+ maxCount?: string | undefined;
31
+ hintText?: string | undefined;
32
+ enableOptionalFont?: boolean | undefined;
33
+ optionalFontList?: never[] | undefined;
34
+ name: string;
35
+ description: string;
36
+ enableOption: boolean;
37
+ options: never[];
38
+ moveable: boolean;
39
+ };
40
+ /** Shared validation for dialog saves and live inspector changes. Keeps host metadata. */
41
+ export declare function preparePersonalizationConfig(kind: PersonalizationKind, config: Record<string, any>): {
42
+ error: string;
43
+ config: undefined;
44
+ } | {
45
+ config: Record<string, any>;
46
+ error: undefined;
47
+ };
48
+ export declare function updateLinkedPersonalization(configs: PersonalizationConfigs, id: string, config: Record<string, any>): {
49
+ [x: string]: Record<string, any> | undefined;
50
+ };
51
+ /** Disabled rules are kept only in editor memory, never in the saved design payload. */
52
+ export declare function togglePersonalization(configs: PersonalizationConfigs, drafts: PersonalizationConfigs, id: string, defaults: Record<string, any>): {
53
+ configs: {
54
+ [x: string]: Record<string, any> | undefined;
55
+ };
56
+ drafts: {
57
+ [x: string]: Record<string, any> | undefined;
58
+ };
59
+ };
60
+ /** Builds an isolated preview document using the same customConfig fields as saving. */
61
+ export declare function personalizationSnapshot(data: DesignDocuments, configs: PersonalizationConfigs): DesignDocuments;
62
+ export declare function personalizationFields(layers: PersonalizationLayer[]): PersonalizationField[];
63
+ /** Replaces only the explicit targets; fixed layers and other placements retain their state. */
64
+ export declare function patchPersonalizationTargets(data: DesignDocuments, targets: PersonalizationLayer[], patches: Record<string, any>[]): {
65
+ [x: string]: Record<string, any>;
66
+ };
67
+ /** Center-crop to the template box, preserving its position, angle and flipped axes. */
68
+ export declare function personalizationImagePatch(object: Record<string, any>, source: string, width: number, height: number): {
69
+ src: string;
70
+ originSrc: string;
71
+ fullSizeSrc: string;
72
+ width: number;
73
+ height: number;
74
+ cropX: number;
75
+ cropY: number;
76
+ scaleX: number;
77
+ scaleY: number;
78
+ };