@jieyin/editor-sdk-test 1.1.218 → 1.1.219

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.
@@ -1,45 +1,42 @@
1
- const u = (t, s, n) => {
2
- const e = JSON.parse(JSON.stringify(t));
3
- return e.customData || (e.customData = {}), e.customData.id = s, n !== 1 && (e.scaleX = (e.scaleX ?? 1) * n, e.scaleY = (e.scaleY ?? 1) * n), { cloned: e, nextId: s + 1 };
4
- }, y = (t) => {
5
- const s = t.left ?? 0, n = t.top ?? 0, e = (t.width ?? 0) * (t.scaleX ?? 1), r = (t.height ?? 0) * (t.scaleY ?? 1), c = t.originX ?? "left", i = t.originY ?? "top", f = c === "center" ? e / 2 : c === "right" ? e : 0, l = i === "center" ? r / 2 : i === "bottom" ? r : 0;
6
- return { l: s - f, t: n - l };
7
- }, m = (t, s, n) => {
8
- if (!t.length) return;
9
- let e = 1 / 0, r = 1 / 0, c = -1 / 0, i = -1 / 0;
10
- for (const o of t) {
11
- const { l: p, t: d } = y(o), a = (o.width ?? 0) * (o.scaleX ?? 1), g = (o.height ?? 0) * (o.scaleY ?? 1);
12
- p < e && (e = p), d < r && (r = d), p + a > c && (c = p + a), d + g > i && (i = d + g);
1
+ const g = (n, o, s) => {
2
+ const t = JSON.parse(JSON.stringify(n));
3
+ return t.customData || (t.customData = {}), t.customData.id = o, s !== 1 && (t.scaleX = (t.scaleX ?? 1) * s, t.scaleY = (t.scaleY ?? 1) * s), { cloned: t, nextId: o + 1 };
4
+ }, h = (n, o, s) => {
5
+ if (!n.length) return;
6
+ let t = 1 / 0, l = 1 / 0, c = -1 / 0, r = -1 / 0;
7
+ for (const e of n) {
8
+ const i = e.left ?? 0, f = e.top ?? 0, a = (e.width ?? 0) * (e.scaleX ?? 1), u = (e.height ?? 0) * (e.scaleY ?? 1);
9
+ i < t && (t = i), f < l && (l = f), i + a > c && (c = i + a), f + u > r && (r = f + u);
13
10
  }
14
- const f = s - (e + c) / 2, l = n - (r + i) / 2;
15
- for (const o of t)
16
- o.left = (o.left ?? 0) + f, o.top = (o.top ?? 0) + l;
17
- }, x = (t) => {
18
- const { sourceObjects: s, targetJsonMap: n, objectIndex: e, targetScaleMap: r, canvasCenter: c } = t;
19
- let i = Number.isFinite(e) ? e : 1;
20
- const f = {};
21
- return Object.entries(n || {}).forEach(([l, o]) => {
22
- const p = Array.isArray(o?.objects) ? o.objects : [], d = r?.[l] ?? 1, a = [];
23
- s.forEach((g) => {
24
- const h = u(g, i, d);
25
- a.push(h.cloned), i = h.nextId;
26
- }), c && a.length && m(a, c.x, c.y), f[l] = { ...o, objects: [...p, ...a] };
27
- }), { updates: f, nextObjectIndex: i };
11
+ const d = o - (t + c) / 2, p = s - (l + r) / 2;
12
+ for (const e of n)
13
+ e.left = (e.left ?? 0) + d, e.top = (e.top ?? 0) + p;
14
+ }, m = (n) => {
15
+ const { sourceObjects: o, targetJsonMap: s, objectIndex: t, targetScaleMap: l, canvasCenter: c } = n;
16
+ let r = Number.isFinite(t) ? t : 1;
17
+ const d = {};
18
+ return Object.entries(s || {}).forEach(([p, e]) => {
19
+ const i = Array.isArray(e?.objects) ? e.objects : [], f = l?.[p] ?? 1, a = [];
20
+ o.forEach((u) => {
21
+ const y = g(u, r, f);
22
+ a.push(y.cloned), r = y.nextId;
23
+ }), c && a.length && h(a, c.x, c.y), d[p] = { ...e, objects: [...i, ...a] };
24
+ }), { updates: d, nextObjectIndex: r };
28
25
  };
29
- self.onmessage = (t) => {
30
- const s = t.data;
26
+ self.onmessage = (n) => {
27
+ const o = n.data;
31
28
  try {
32
- const n = x(s);
29
+ const s = m(o);
33
30
  self.postMessage({
34
- id: s.id,
31
+ id: o.id,
35
32
  ok: !0,
36
- data: n
33
+ data: s
37
34
  });
38
- } catch (n) {
35
+ } catch (s) {
39
36
  self.postMessage({
40
- id: s.id,
37
+ id: o.id,
41
38
  ok: !1,
42
- error: n instanceof Error ? n.message : String(n)
39
+ error: s instanceof Error ? s.message : String(s)
43
40
  });
44
41
  }
45
42
  };