@jetprint/editor-sdk 1.0.4 → 1.0.5

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.
@@ -122,6 +122,35 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
122
122
  type: NumberConstructor;
123
123
  default: number;
124
124
  };
125
+ /** theme1 查看大图:可勾选的具体尺码列表(已去掉 SKU_ALL 等占位) */
126
+ sizeOptions: {
127
+ type: PropType<string[]>;
128
+ default: () => never[];
129
+ };
130
+ /** theme1 查看大图:已设计尺码集合(不在此集合且 isPerSizeDesign 时尺码禁用勾选) */
131
+ designedSizes: {
132
+ type: PropType<string[]>;
133
+ default: () => never[];
134
+ };
135
+ /** theme1 查看大图:是否按尺码区分设计(COMMON 同版共享时为 false,则不禁用任何尺码) */
136
+ isPerSizeDesign: {
137
+ type: BooleanConstructor;
138
+ default: boolean;
139
+ };
140
+ /**
141
+ * theme1 查看大图:批量出图方法(来自 index.vue renderEffectImagesForSizesColors)。
142
+ * 给定尺码/颜色集合,返回每张成品效果图 { size, color, index(模板序号), blob }。
143
+ */
144
+ renderEffectImages: {
145
+ type: PropType<(sizes: string[], colors: string[]) => Promise<Array<{
146
+ size: string;
147
+ color: string;
148
+ index: number;
149
+ name?: string;
150
+ blob: Blob;
151
+ }>>>;
152
+ default: null;
153
+ };
125
154
  theme1LayersExpanded: {
126
155
  type: PropType<boolean>;
127
156
  };
@@ -257,6 +286,35 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
257
286
  type: NumberConstructor;
258
287
  default: number;
259
288
  };
289
+ /** theme1 查看大图:可勾选的具体尺码列表(已去掉 SKU_ALL 等占位) */
290
+ sizeOptions: {
291
+ type: PropType<string[]>;
292
+ default: () => never[];
293
+ };
294
+ /** theme1 查看大图:已设计尺码集合(不在此集合且 isPerSizeDesign 时尺码禁用勾选) */
295
+ designedSizes: {
296
+ type: PropType<string[]>;
297
+ default: () => never[];
298
+ };
299
+ /** theme1 查看大图:是否按尺码区分设计(COMMON 同版共享时为 false,则不禁用任何尺码) */
300
+ isPerSizeDesign: {
301
+ type: BooleanConstructor;
302
+ default: boolean;
303
+ };
304
+ /**
305
+ * theme1 查看大图:批量出图方法(来自 index.vue renderEffectImagesForSizesColors)。
306
+ * 给定尺码/颜色集合,返回每张成品效果图 { size, color, index(模板序号), blob }。
307
+ */
308
+ renderEffectImages: {
309
+ type: PropType<(sizes: string[], colors: string[]) => Promise<Array<{
310
+ size: string;
311
+ color: string;
312
+ index: number;
313
+ name?: string;
314
+ blob: Blob;
315
+ }>>>;
316
+ default: null;
317
+ };
260
318
  theme1LayersExpanded: {
261
319
  type: PropType<boolean>;
262
320
  };
@@ -279,6 +337,7 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
279
337
  selectedColor: string;
280
338
  templateIndex: number;
281
339
  selectedSize: string;
340
+ sizeOptions: string[];
282
341
  colorOptions: string[];
283
342
  colorLabelByValue: Record<string, string>;
284
343
  loadingDesign: boolean;
@@ -302,6 +361,15 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
302
361
  renderInvalidationKey: string | number;
303
362
  useLiveWebglPreview: boolean;
304
363
  liveWebglInternalRenderSize: number;
364
+ designedSizes: string[];
365
+ isPerSizeDesign: boolean;
366
+ renderEffectImages: (sizes: string[], colors: string[]) => Promise<Array<{
367
+ size: string;
368
+ color: string;
369
+ index: number;
370
+ name?: string;
371
+ blob: Blob;
372
+ }>>;
305
373
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
306
374
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
307
375
  export default _default;
@@ -22,6 +22,7 @@ export interface UseCopyToDiecutsOptions {
22
22
  targetJsonMap: Record<string, any>;
23
23
  objectIndex: number;
24
24
  targetScaleMap?: Record<string, number>;
25
+ patternScaleMap?: Record<string, number>;
25
26
  sourceCenter?: {
26
27
  x: number;
27
28
  y: number;
@@ -8,6 +8,8 @@ type CopyDiecutsWorkerRequest = {
8
8
  targetJsonMap: Record<string, any>;
9
9
  objectIndex: number;
10
10
  targetScaleMap?: Record<string, number>;
11
+ /** 平铺专用:每个目标分片的「最长边比例」(源最长边/目标最长边),平铺 rect 的瓦片+cover 按此缩放(物理一致) */
12
+ patternScaleMap?: Record<string, number>;
11
13
  /** 源分片在画布上 contain-fit 矩形中心;与 targetCenterMap 配合按"在分片内的相对位置"映射 */
12
14
  sourceCenter?: Vec2;
13
15
  /** 各目标分片在画布上 contain-fit 矩形中心 */
@@ -20,7 +22,7 @@ type CopyDiecutsWorkerRequest = {
20
22
  * - 缩放保持原 contain-fit 比例换算(scaleFactor)。
21
23
  * - 位置按"在源分片内的相对位置"映射到目标分片对应位置(sourceCenter → targetCenter)。
22
24
  */
23
- declare const cloneForCopy: (obj: any, startId: number, scaleFactor: number, sourceCenter?: Vec2, targetCenter?: Vec2) => {
25
+ declare const cloneForCopy: (obj: any, startId: number, scaleFactor: number, sourceCenter?: Vec2, targetCenter?: Vec2, patternFactor?: number) => {
24
26
  cloned: any;
25
27
  nextId: number;
26
28
  };
@@ -1,67 +1,77 @@
1
- const B = (t, i, s, c, r) => {
2
- const n = JSON.parse(JSON.stringify(t));
3
- n.customData || (n.customData = {}), n.customData.id = i;
4
- const a = C(n), f = (a.minL + a.maxR) / 2, l = (a.minT + a.maxB) / 2, o = !!n.customData?.isPatternRect;
5
- if (s !== 1 && !o && (n.scaleX = (n.scaleX ?? 1) * s, n.scaleY = (n.scaleY ?? 1) * s), c && r) {
6
- const e = C(n), x = (e.minL + e.maxR) / 2, g = (e.minT + e.maxB) / 2, p = r.x + (f - c.x) * s, y = r.y + (l - c.y) * s;
7
- n.left = (n.left ?? 0) + p - x, n.top = (n.top ?? 0) + y - g;
1
+ const D = (e, l, i, o, f, r = 1) => {
2
+ const t = JSON.parse(JSON.stringify(e));
3
+ t.customData || (t.customData = {}), t.customData.id = l;
4
+ const m = T(t), h = (m.minL + m.maxR) / 2, a = (m.minT + m.maxB) / 2, n = !!t.customData?.isPatternRect, p = n ? r : i;
5
+ if (!n)
6
+ i !== 1 && (t.scaleX = (t.scaleX ?? 1) * i, t.scaleY = (t.scaleY ?? 1) * i);
7
+ else if (r !== 1) {
8
+ const s = t.customData;
9
+ Number(s.patternTileWidth) > 0 && (s.patternTileWidth = Number(s.patternTileWidth) * r), Number(s.patternTileHeight) > 0 && (s.patternTileHeight = Number(s.patternTileHeight) * r), Number(t.width) > 0 && (t.width = Number(t.width) * r), Number(t.height) > 0 && (t.height = Number(t.height) * r);
8
10
  }
9
- return { cloned: n, nextId: i + 1 };
10
- }, A = (t) => t === "left" || t === "top" ? -0.5 : t === "center" ? 0 : t === "right" || t === "bottom" ? 0.5 : 0, C = (t) => {
11
- const i = t.left ?? 0, s = t.top ?? 0, c = (t.width ?? 0) * (t.scaleX ?? 1), r = (t.height ?? 0) * (t.scaleY ?? 1), a = (t.angle ?? 0) * Math.PI / 180, f = Math.cos(a), l = Math.sin(a), o = -A(t.originX ?? "left") * c, e = -A(t.originY ?? "top") * r, x = i + o * f - e * l, g = s + o * l + e * f, p = c / 2, y = r / 2, d = [-p, p].flatMap(
12
- (m) => [-y, y].map((M) => ({
13
- x: x + m * f - M * l,
14
- y: g + m * l + M * f
11
+ if (o && f) {
12
+ const s = T(t), d = (s.minL + s.maxR) / 2, y = (s.minT + s.maxB) / 2, g = f.x + (h - o.x) * p, u = f.y + (a - o.y) * p;
13
+ if (t.left = (t.left ?? 0) + g - d, t.top = (t.top ?? 0) + u - y, n && t.customData) {
14
+ const c = t.customData;
15
+ typeof c.patternPhaseX == "number" && (c.patternPhaseX = f.x + (c.patternPhaseX - o.x) * p), typeof c.patternPhaseY == "number" && (c.patternPhaseY = f.y + (c.patternPhaseY - o.y) * p);
16
+ }
17
+ }
18
+ return { cloned: t, nextId: l + 1 };
19
+ }, M = (e) => e === "left" || e === "top" ? -0.5 : e === "center" ? 0 : e === "right" || e === "bottom" ? 0.5 : 0, T = (e) => {
20
+ const l = e.left ?? 0, i = e.top ?? 0, o = (e.width ?? 0) * (e.scaleX ?? 1), f = (e.height ?? 0) * (e.scaleY ?? 1), t = (e.angle ?? 0) * Math.PI / 180, m = Math.cos(t), h = Math.sin(t), a = -M(e.originX ?? "left") * o, n = -M(e.originY ?? "top") * f, p = l + a * m - n * h, s = i + a * h + n * m, d = o / 2, y = f / 2, g = [-d, d].flatMap(
21
+ (x) => [-y, y].map((N) => ({
22
+ x: p + x * m - N * h,
23
+ y: s + x * h + N * m
15
24
  }))
16
25
  );
17
- let h = 1 / 0, u = 1 / 0, b = -1 / 0, I = -1 / 0;
18
- for (const m of d)
19
- m.x < h && (h = m.x), m.y < u && (u = m.y), m.x > b && (b = m.x), m.y > I && (I = m.y);
20
- return { minL: h, minT: u, maxR: b, maxB: I };
21
- }, O = (t, i, s) => {
22
- if (!t.length) return;
23
- let c = 1 / 0, r = 1 / 0, n = -1 / 0, a = -1 / 0;
24
- for (const o of t) {
25
- const e = C(o);
26
- e.minL < c && (c = e.minL), e.minT < r && (r = e.minT), e.maxR > n && (n = e.maxR), e.maxB > a && (a = e.maxB);
26
+ let u = 1 / 0, c = 1 / 0, I = -1 / 0, b = -1 / 0;
27
+ for (const x of g)
28
+ x.x < u && (u = x.x), x.y < c && (c = x.y), x.x > I && (I = x.x), x.y > b && (b = x.y);
29
+ return { minL: u, minT: c, maxR: I, maxB: b };
30
+ }, P = (e, l, i) => {
31
+ if (!e.length) return;
32
+ let o = 1 / 0, f = 1 / 0, r = -1 / 0, t = -1 / 0;
33
+ for (const a of e) {
34
+ const n = T(a);
35
+ n.minL < o && (o = n.minL), n.minT < f && (f = n.minT), n.maxR > r && (r = n.maxR), n.maxB > t && (t = n.maxB);
27
36
  }
28
- const f = i - (c + n) / 2, l = s - (r + a) / 2;
29
- for (const o of t)
30
- o.left = (o.left ?? 0) + f, o.top = (o.top ?? 0) + l;
31
- }, R = (t) => {
37
+ const m = l - (o + r) / 2, h = i - (f + t) / 2;
38
+ for (const a of e)
39
+ a.left = (a.left ?? 0) + m, a.top = (a.top ?? 0) + h;
40
+ }, w = (e) => {
32
41
  const {
33
- sourceObjects: i,
34
- targetJsonMap: s,
35
- objectIndex: c,
36
- targetScaleMap: r,
37
- sourceCenter: n,
38
- targetCenterMap: a,
39
- canvasCenter: f
40
- } = t;
41
- let l = Number.isFinite(c) ? c : 1;
42
- const o = {};
43
- return Object.entries(s || {}).forEach(([e, x]) => {
44
- const g = Array.isArray(x?.objects) ? x.objects : [], p = r?.[e] ?? 1, y = a?.[e], d = [];
45
- i.forEach((h) => {
46
- const u = B(h, l, p, n, y);
47
- d.push(u.cloned), l = u.nextId;
48
- }), (!n || !y) && f && d.length && O(d, f.x, f.y), o[e] = { ...x, objects: [...g, ...d] };
49
- }), { updates: o, nextObjectIndex: l };
42
+ sourceObjects: l,
43
+ targetJsonMap: i,
44
+ objectIndex: o,
45
+ targetScaleMap: f,
46
+ patternScaleMap: r,
47
+ sourceCenter: t,
48
+ targetCenterMap: m,
49
+ canvasCenter: h
50
+ } = e;
51
+ let a = Number.isFinite(o) ? o : 1;
52
+ const n = {};
53
+ return Object.entries(i || {}).forEach(([p, s]) => {
54
+ const d = Array.isArray(s?.objects) ? s.objects : [], y = f?.[p] ?? 1, g = r?.[p] ?? 1, u = m?.[p], c = [];
55
+ l.forEach((I) => {
56
+ const b = D(I, a, y, t, u, g);
57
+ c.push(b.cloned), a = b.nextId;
58
+ }), (!t || !u) && h && c.length && P(c, h.x, h.y), n[p] = { ...s, objects: [...d, ...c] };
59
+ }), { updates: n, nextObjectIndex: a };
50
60
  };
51
- self.onmessage = (t) => {
52
- const i = t.data;
61
+ self.onmessage = (e) => {
62
+ const l = e.data;
53
63
  try {
54
- const s = R(i);
64
+ const i = w(l);
55
65
  self.postMessage({
56
- id: i.id,
66
+ id: l.id,
57
67
  ok: !0,
58
- data: s
68
+ data: i
59
69
  });
60
- } catch (s) {
70
+ } catch (i) {
61
71
  self.postMessage({
62
- id: i.id,
72
+ id: l.id,
63
73
  ok: !1,
64
- error: s instanceof Error ? s.message : String(s)
74
+ error: i instanceof Error ? i.message : String(i)
65
75
  });
66
76
  }
67
77
  };