@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
@@ -0,0 +1,261 @@
1
+ import { create as h } from "zustand";
2
+ import { HistoryManager as g } from "./engine/history.js";
3
+ import { loadFontFile as b } from "./engine/utils/font.js";
4
+ import { FONT_WEIGHT as v, LAYER_BLACK_LIST as S } from "./engine/constants.js";
5
+ let f = null;
6
+ function z(e) {
7
+ f = e;
8
+ }
9
+ function m() {
10
+ if (!f)
11
+ throw new Error(
12
+ "[printine-designer] Editor asset API client is not ready. Render <PrintineDesigner /> before calling the API."
13
+ );
14
+ return f;
15
+ }
16
+ function l(e) {
17
+ return typeof e == "string" ? e : "";
18
+ }
19
+ function d(e, s) {
20
+ return {
21
+ data: e,
22
+ meta: {
23
+ current_page: s?.page ?? 1,
24
+ last_page: s?.total_pages ?? 1,
25
+ total: s?.total ?? e.length
26
+ }
27
+ };
28
+ }
29
+ function x(e) {
30
+ const s = [];
31
+ for (const t of e) {
32
+ const n = [];
33
+ for (const i of t.variants ?? []) {
34
+ const r = typeof i.weight == "number" ? i.weight : 400, a = i.style === "italic" ? "italic" : "normal", c = `${r}${a === "normal" ? "" : "italic"}`, p = l(i.url);
35
+ p && n.push({
36
+ style: a,
37
+ variant: c,
38
+ weight: r,
39
+ label: v[c] || `${r}`,
40
+ url: p
41
+ });
42
+ }
43
+ const o = l(t.name);
44
+ !o || !n.length || s.push({
45
+ category: "",
46
+ family: o,
47
+ variants: [...new Set(n.map((i) => i.variant ?? `${i.weight}`))],
48
+ files: n
49
+ });
50
+ }
51
+ return s;
52
+ }
53
+ function y(e) {
54
+ const s = l(e.id), t = l(e.asset_url);
55
+ if (!s || !t) return null;
56
+ const n = l(e.thumbnail_url);
57
+ return { id: s, name: l(e.name), url: t, ...n ? { thumbnailUrl: n } : {} };
58
+ }
59
+ function A(e) {
60
+ return y(e);
61
+ }
62
+ const O = {
63
+ async getFontList() {
64
+ const e = await m().get("fonts");
65
+ return x(e.data);
66
+ },
67
+ async getShapeList(e) {
68
+ const { size: s, ...t } = e, n = await m().get("shapes", {
69
+ ...t,
70
+ page: typeof e.page == "number" ? e.page : 1,
71
+ limit: typeof s == "number" ? s : 30
72
+ }), o = n.data.map(y).filter((i) => i !== null);
73
+ return d(o, n.pagination);
74
+ },
75
+ async getClipArtCategories() {
76
+ const s = (await m().get("clipart-categories")).data.map((t) => {
77
+ const n = l(t.id);
78
+ return n ? {
79
+ id: n,
80
+ name: l(t.name),
81
+ clip_arts: (t.cliparts ?? []).map(A).filter((o) => o !== null)
82
+ } : null;
83
+ }).filter((t) => t !== null);
84
+ return d(s);
85
+ }
86
+ };
87
+ function C(e) {
88
+ return String(e.type).includes("i-text") || e.type === "text" ? "text" : e.sourceType === "svg" || e.clip ? "svg" : e.type === "image" ? "image" : null;
89
+ }
90
+ function I(e, s) {
91
+ return s.flatMap((t) => (Array.isArray(e[t.name]?.objects) ? e[t.name].objects : []).filter((n) => n.id != null && !S.includes(String(n.id))).map((n) => ({
92
+ id: String(n.id),
93
+ placement: t.name,
94
+ placementLabel: t.display_name || t.name,
95
+ kind: C(n),
96
+ name: n.name || n.__rawText || n.text || "",
97
+ source: n.src || n.originSrc || "",
98
+ object: n
99
+ })).reverse());
100
+ }
101
+ function P(e, s) {
102
+ return {
103
+ name: s,
104
+ description: "",
105
+ enableOption: !1,
106
+ options: [],
107
+ moveable: !1,
108
+ ...e === "text" ? { maxCount: "", hintText: "", enableOptionalFont: !1, optionalFontList: [], enableColor: !1 } : {},
109
+ ...e === "image" ? { enableAI: !1, backgroundRemove: !1, portraitCutout: !1, cartoonize: !1, stickerOutline: !1 } : {},
110
+ ...e === "svg" ? { enableColor: !0 } : {}
111
+ };
112
+ }
113
+ function K(e, s) {
114
+ const t = (o) => ({ error: o, config: void 0 });
115
+ if (!String(s.name || "").trim()) return t("Field name is required");
116
+ const n = { ...s, name: s.name.trim(), options: (s.options || []).filter((o) => String(o.value || "").trim()) };
117
+ if (s.maxCount !== "" && s.maxCount != null) {
118
+ const o = Number(s.maxCount);
119
+ if (!Number.isInteger(o) || o < 1) return t("Enter a positive whole number for the character limit.");
120
+ n.maxCount = o;
121
+ } else delete n.maxCount;
122
+ return n.enableOption && !n.options.length ? t("Add at least one preset option.") : e === "text" && n.maxCount && n.enableOption && n.options.some((o) => [...o.value].length > n.maxCount) ? t("A preset exceeds the character limit.") : n.enableOptionalFont && !(n.optionalFontList || []).length ? t("Choose at least one optional font.") : e === "svg" && !n.enableColor && !n.moveable ? t("Allow color or placement changes for this vector.") : { config: n, error: void 0 };
123
+ }
124
+ function B(e, s, t) {
125
+ const n = { ...e, [s]: t };
126
+ if (t.syncKey) for (const [o, i] of Object.entries(e))
127
+ i?.syncKey === t.syncKey && (n[o] = { ...t });
128
+ return n;
129
+ }
130
+ function w(e, s, t, n) {
131
+ const o = { ...e };
132
+ if (e[t]) {
133
+ const a = e[t];
134
+ return delete o[t], { configs: o, drafts: { ...s, [t]: a } };
135
+ }
136
+ const i = s[t], r = i?.syncKey ? Object.values(e).find((a) => a?.syncKey === i.syncKey) : void 0;
137
+ return o[t] = { ...r || i || n }, { configs: o, drafts: s };
138
+ }
139
+ function D(e, s) {
140
+ const t = JSON.parse(JSON.stringify(e));
141
+ for (const n of Object.values(t))
142
+ if (Array.isArray(n.objects))
143
+ for (const o of n.objects) {
144
+ const i = s[String(o.id)];
145
+ delete o.customConfig, !(!i || !C(o)) && (o.customConfig = JSON.parse(JSON.stringify(i)), i.moveable || (o.customConfig.originalWidth = (o.width || 0) * Math.abs(o.scaleX ?? 1), o.customConfig.originalHeight = (o.height || 0) * Math.abs(o.scaleY ?? 1)));
146
+ }
147
+ return t;
148
+ }
149
+ function N(e) {
150
+ const s = /* @__PURE__ */ new Map();
151
+ for (const t of e) {
152
+ const n = t.object.customConfig;
153
+ if (!n || !t.kind) continue;
154
+ const o = n.syncKey ? `${t.kind}:sync:${n.syncKey}` : `${t.placement}:${t.id}`, i = s.get(o);
155
+ i ? i.targets.push(t) : s.set(o, { key: o, config: n, kind: t.kind, targets: [t] });
156
+ }
157
+ return [...s.values()];
158
+ }
159
+ function $(e, s, t) {
160
+ const n = { ...e };
161
+ return s.forEach((o, i) => {
162
+ const r = n[o.placement];
163
+ !r || !t[i] || (n[o.placement] = { ...r, objects: r.objects.map((a) => String(a.id) === o.id ? { ...a, ...t[i] } : a) });
164
+ }), n;
165
+ }
166
+ function T(e, s, t, n) {
167
+ const o = (e.width || 1) * Math.abs(e.scaleX ?? 1), i = (e.height || 1) * Math.abs(e.scaleY ?? 1), r = Math.max(o / t, i / n), a = o / r, c = i / r;
168
+ return {
169
+ src: s,
170
+ originSrc: s,
171
+ fullSizeSrc: s,
172
+ width: a,
173
+ height: c,
174
+ cropX: (t - a) / 2,
175
+ cropY: (n - c) / 2,
176
+ scaleX: r * (Math.sign(e.scaleX ?? 1) || 1),
177
+ scaleY: r * (Math.sign(e.scaleY ?? 1) || 1)
178
+ };
179
+ }
180
+ let u = 0;
181
+ const k = h((e, s) => ({
182
+ currentSide: "",
183
+ historyManager: new g(""),
184
+ fontList: [],
185
+ backgroundColor: "",
186
+ colors: [],
187
+ activeObjects: [],
188
+ rendering: !1,
189
+ copiedObjects: null,
190
+ semiCustom: {},
191
+ semiCustomDrafts: {},
192
+ semiCustomBackground: { colors: [], palette: !1, enable: !1 },
193
+ initData: (t, n) => {
194
+ const { getFontList: o, getColors: i } = s();
195
+ o(t), i(n);
196
+ },
197
+ getFontList: async (t) => {
198
+ try {
199
+ e({ fontList: await (t ? t() : O.getFontList()) });
200
+ } catch {
201
+ e({ fontList: [] });
202
+ }
203
+ },
204
+ loadMultipleFont: async (t) => {
205
+ const { fontList: n } = s(), o = t.map((i) => n.find((r) => r.family === i)).filter((i) => !!i);
206
+ await Promise.all(o.map((i) => b(i)));
207
+ },
208
+ getColors: async (t) => {
209
+ const n = ++u;
210
+ e({ colors: [] });
211
+ try {
212
+ const o = t ? await t() : [];
213
+ n === u && e({ colors: Array.isArray(o) ? o.filter((i) => typeof i == "string" && i.trim()) : [] });
214
+ } catch {
215
+ n === u && e({ colors: [] });
216
+ }
217
+ },
218
+ setActiveObjects: (t) => e({ activeObjects: t }),
219
+ setCurrentSide: (t) => e({ currentSide: t }),
220
+ setBackgroundColor: (t) => e({ backgroundColor: t }),
221
+ setHistoryManager: (t) => e({ historyManager: t }),
222
+ setRendering: (t) => e({ rendering: t }),
223
+ setCopiedObjects: (t) => e({ copiedObjects: t }),
224
+ setSemiCustom: (t) => e({ semiCustom: t }),
225
+ setSemiCustomItem: (t, n) => e({ semiCustom: { ...s().semiCustom, [t]: n } }),
226
+ toggleSemiCustomItem: (t, n) => {
227
+ const o = w(s().semiCustom, s().semiCustomDrafts, t, n);
228
+ e({ semiCustom: o.configs, semiCustomDrafts: o.drafts });
229
+ },
230
+ delSemiCustomInfo: (t) => e({ semiCustom: { ...s().semiCustom, [t]: void 0 } }),
231
+ setSemiCustomBackground: (t) => e({ semiCustomBackground: t }),
232
+ setSemiCustomBackgroundItem: (t, n) => e({ semiCustomBackground: { ...s().semiCustomBackground, [t]: n } }),
233
+ reset: () => {
234
+ u += 1, e({
235
+ historyManager: new g(""),
236
+ activeObjects: [],
237
+ backgroundColor: "",
238
+ currentSide: "",
239
+ copiedObjects: null,
240
+ semiCustom: {},
241
+ semiCustomDrafts: {},
242
+ semiCustomBackground: { colors: [], palette: !1, enable: !1 },
243
+ colors: []
244
+ });
245
+ }
246
+ })), E = k;
247
+ export {
248
+ O as A,
249
+ E as a,
250
+ I as b,
251
+ $ as c,
252
+ T as d,
253
+ C as e,
254
+ P as f,
255
+ K as g,
256
+ D as h,
257
+ B as i,
258
+ N as p,
259
+ z as s,
260
+ k as u
261
+ };
@@ -134,7 +134,7 @@ const E = ["cropRect", "cropOverlay", "workspace", "loading", "bg"], F = [0.01,
134
134
  ai: "AI image generator",
135
135
  files: "My files",
136
136
  background: "Background color",
137
- sca: "Custom"
137
+ sca: "Personalization"
138
138
  };
139
139
  export {
140
140
  t as ALIGN_TYPES,