@jieyin/editor-sdk 1.1.122 → 1.1.124

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,7 +1,7 @@
1
- var Z = Object.defineProperty, ee = (s, t, e) => t in s ? Z(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, k = (s, t, e) => ee(s, typeof t != "symbol" ? t + "" : t, e);
1
+ var Z = Object.defineProperty, ee = (s, t, e) => t in s ? Z(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, $ = (s, t, e) => ee(s, typeof t != "symbol" ? t + "" : t, e);
2
2
  const q = class T {
3
3
  constructor() {
4
- k(this, "wasmReady", !1), k(this, "go", null), k(this, "wasmModule", null);
4
+ $(this, "wasmReady", !1), $(this, "go", null), $(this, "wasmModule", null);
5
5
  }
6
6
  static getInstance() {
7
7
  return T.instance || (T.instance = new T()), T.instance;
@@ -14,7 +14,7 @@ const q = class T {
14
14
  async load(t, e) {
15
15
  if (!this.wasmReady)
16
16
  try {
17
- const n = (a) => {
17
+ const r = (a) => {
18
18
  if (e && a === "wasm_exec.js")
19
19
  return e;
20
20
  if (t && a === "perspective.wasm")
@@ -35,8 +35,8 @@ const q = class T {
35
35
  } catch {
36
36
  }
37
37
  return "/assets/" + a;
38
- }, r = e || n("wasm_exec.js"), o = t || n("perspective.wasm");
39
- await this.loadWasmExec(r);
38
+ }, n = e || r("wasm_exec.js"), o = t || r("perspective.wasm");
39
+ await this.loadWasmExec(n);
40
40
  const u = typeof self < "u" ? self : globalThis;
41
41
  this.go = new u.Go();
42
42
  const i = await fetch(o);
@@ -47,37 +47,38 @@ const q = class T {
47
47
  const l = this.call("wasmInit");
48
48
  if (!(l && l.success))
49
49
  throw new Error("WASM 初始化失败");
50
- } catch (n) {
51
- throw this.wasmReady = !1, n;
50
+ } catch (r) {
51
+ throw this.wasmReady = !1, r;
52
52
  }
53
53
  }
54
54
  /**
55
55
  * 在 Worker 中加载 wasm_exec.js
56
+ * Module Worker 不支持 importScripts(),仅 Classic Worker 可尝试 importScripts,否则用 fetch + eval
56
57
  */
57
58
  async loadWasmExec(t) {
58
- return new Promise((e, n) => {
59
- if (typeof self.importScripts == "function")
59
+ return new Promise((e, r) => {
60
+ if (!(typeof import.meta < "u" && import.meta.url) && typeof self.importScripts == "function")
60
61
  try {
61
62
  self.importScripts(t), e();
62
63
  return;
63
64
  } catch {
64
65
  }
65
- fetch(t).then((r) => {
66
- if (!r.ok)
67
- throw new Error(`HTTP ${r.status}: ${r.statusText} - URL: ${t}`);
68
- const o = r.headers.get("content-type") || "";
69
- return !o.includes("javascript") && o.includes("text/plain"), r.text();
70
- }).then((r) => {
71
- if (r.trim().startsWith("<!DOCTYPE") || r.trim().startsWith("<html"))
66
+ fetch(t).then((o) => {
67
+ if (!o.ok)
68
+ throw new Error(`HTTP ${o.status}: ${o.statusText} - URL: ${t}`);
69
+ const u = o.headers.get("content-type") || "";
70
+ return !u.includes("javascript") && u.includes("text/plain"), o.text();
71
+ }).then((o) => {
72
+ if (o.trim().startsWith("<!DOCTYPE") || o.trim().startsWith("<html"))
72
73
  throw new Error(`返回的是 HTML 而不是 JavaScript,可能是 404 错误。URL: ${t}`);
73
74
  try {
74
- const o = typeof self < "u" ? self : globalThis;
75
- new Function("self", r)(o), e();
76
- } catch (o) {
77
- n(new Error(`执行 wasm_exec.js 失败: ${o}`));
75
+ const u = typeof self < "u" ? self : globalThis;
76
+ new Function("self", o)(u), e();
77
+ } catch (u) {
78
+ r(new Error(`执行 wasm_exec.js 失败: ${u}`));
78
79
  }
79
- }).catch((r) => {
80
- n(r);
80
+ }).catch((o) => {
81
+ r(o);
81
82
  });
82
83
  });
83
84
  }
@@ -89,15 +90,15 @@ const q = class T {
89
90
  return !1;
90
91
  if (e)
91
92
  try {
92
- const n = this.getDeviceID(), r = this.getDomain(), u = await (await fetch(`${e}/jet_license/interface/license/verify`, {
93
+ const r = this.getDeviceID(), n = this.getDomain(), u = await (await fetch(`${e}/jet_license/interface/license/verify`, {
93
94
  method: "POST",
94
95
  headers: {
95
96
  "Content-Type": "application/json"
96
97
  },
97
98
  body: JSON.stringify({
98
99
  token: t,
99
- deviceId: n,
100
- domain: r
100
+ deviceId: r,
101
+ domain: n
101
102
  })
102
103
  })).json();
103
104
  if (!u.success || !u.valid) {
@@ -108,13 +109,13 @@ const q = class T {
108
109
  if (!i.success || i.valid !== !0)
109
110
  throw new Error("WASM 验证失败");
110
111
  return !0;
111
- } catch (n) {
112
- throw n;
112
+ } catch (r) {
113
+ throw r;
113
114
  }
114
115
  else
115
116
  try {
116
- const n = this.call("wasmVerifyLicense", t);
117
- return n.success && n.valid === !0;
117
+ const r = this.call("wasmVerifyLicense", t);
118
+ return r.success && r.valid === !0;
118
119
  } catch {
119
120
  return !1;
120
121
  }
@@ -166,51 +167,51 @@ const q = class T {
166
167
  /**
167
168
  * 应用透视变换到单个点
168
169
  */
169
- applyPerspective(t, e, n) {
170
+ applyPerspective(t, e, r) {
170
171
  if (!this.wasmReady)
171
172
  throw new Error("WASM 未加载");
172
173
  try {
173
- const r = this.call("wasmApplyPerspective", t, e, JSON.stringify(n));
174
- if (!r.success)
175
- throw new Error(r.error || "变换失败");
176
- return { x: r.x, y: r.y };
177
- } catch (r) {
178
- throw r;
174
+ const n = this.call("wasmApplyPerspective", t, e, JSON.stringify(r));
175
+ if (!n.success)
176
+ throw new Error(n.error || "变换失败");
177
+ return { x: n.x, y: n.y };
178
+ } catch (n) {
179
+ throw n;
179
180
  }
180
181
  }
181
182
  /**
182
183
  * 应用逆透视变换到单个点
183
184
  */
184
- applyInversePerspective(t, e, n) {
185
+ applyInversePerspective(t, e, r) {
185
186
  if (!this.wasmReady)
186
187
  throw new Error("WASM 未加载");
187
188
  try {
188
- const r = this.call("wasmApplyInversePerspective", t, e, JSON.stringify(n));
189
- if (!r.success)
190
- throw new Error(r.error || "逆变换失败");
191
- return { x: r.x, y: r.y };
192
- } catch (r) {
193
- throw r;
189
+ const n = this.call("wasmApplyInversePerspective", t, e, JSON.stringify(r));
190
+ if (!n.success)
191
+ throw new Error(n.error || "逆变换失败");
192
+ return { x: n.x, y: n.y };
193
+ } catch (n) {
194
+ throw n;
194
195
  }
195
196
  }
196
197
  /**
197
198
  * 批量变换点(高性能)
198
199
  */
199
- transformPoints(t, e, n = !1) {
200
+ transformPoints(t, e, r = !1) {
200
201
  if (!this.wasmReady)
201
202
  throw new Error("WASM 未加载");
202
203
  try {
203
- const r = this.call(
204
+ const n = this.call(
204
205
  "wasmTransformPoints",
205
206
  JSON.stringify(t),
206
207
  JSON.stringify(e),
207
- n
208
+ r
208
209
  );
209
- if (!r.success)
210
- throw new Error(r.error || "批量变换失败");
211
- return JSON.parse(r.points);
212
- } catch (r) {
213
- throw r;
210
+ if (!n.success)
211
+ throw new Error(n.error || "批量变换失败");
212
+ return JSON.parse(n.points);
213
+ } catch (n) {
214
+ throw n;
214
215
  }
215
216
  }
216
217
  /**
@@ -222,45 +223,45 @@ const q = class T {
222
223
  /**
223
224
  * 双三次插值点计算
224
225
  */
225
- getBicubicPoint(t, e, n) {
226
+ getBicubicPoint(t, e, r) {
226
227
  if (!this.wasmReady)
227
228
  throw new Error("WASM 未加载");
228
- if (n.length !== 16)
229
+ if (r.length !== 16)
229
230
  throw new Error("需要恰好 16 个点");
230
231
  try {
231
- const r = this.call("wasmGetBicubicPoint", t, e, JSON.stringify(n));
232
- if (!r.success)
233
- throw new Error(r.error || "计算失败");
234
- return { x: r.x, y: r.y };
235
- } catch (r) {
236
- throw r;
232
+ const n = this.call("wasmGetBicubicPoint", t, e, JSON.stringify(r));
233
+ if (!n.success)
234
+ throw new Error(n.error || "计算失败");
235
+ return { x: n.x, y: n.y };
236
+ } catch (n) {
237
+ throw n;
237
238
  }
238
239
  }
239
240
  /**
240
241
  * 双线性插值点计算
241
242
  */
242
- getBilinearPoint(t, e, n) {
243
+ getBilinearPoint(t, e, r) {
243
244
  if (!this.wasmReady)
244
245
  throw new Error("WASM 未加载");
245
- if (n.length !== 4)
246
+ if (r.length !== 4)
246
247
  throw new Error("需要恰好 4 个点");
247
248
  try {
248
- const r = this.call("wasmGetBilinearPoint", t, e, JSON.stringify(n));
249
- if (!r.success)
250
- throw new Error(r.error || "计算失败");
251
- return { x: r.x, y: r.y };
252
- } catch (r) {
253
- throw r;
249
+ const n = this.call("wasmGetBilinearPoint", t, e, JSON.stringify(r));
250
+ if (!n.success)
251
+ throw new Error(n.error || "计算失败");
252
+ return { x: n.x, y: n.y };
253
+ } catch (n) {
254
+ throw n;
254
255
  }
255
256
  }
256
257
  /**
257
258
  * 任意网格点插值计算
258
259
  */
259
- getArbitraryMeshPoint(t, e, n, r) {
260
+ getArbitraryMeshPoint(t, e, r, n) {
260
261
  if (!this.wasmReady)
261
262
  throw new Error("WASM 未加载");
262
263
  try {
263
- const o = this.call("wasmGetArbitraryMeshPoint", t, e, JSON.stringify(n), r);
264
+ const o = this.call("wasmGetArbitraryMeshPoint", t, e, JSON.stringify(r), n);
264
265
  if (!o.success)
265
266
  throw new Error(o.error || "计算失败");
266
267
  return { x: o.x, y: o.y };
@@ -278,16 +279,16 @@ const q = class T {
278
279
  if (e.length !== 16)
279
280
  throw new Error("需要恰好 16 个控制点");
280
281
  try {
281
- const n = this.call(
282
+ const r = this.call(
282
283
  "wasmBatchBicubicInterpolation",
283
284
  JSON.stringify(t),
284
285
  JSON.stringify(e)
285
286
  );
286
- if (!n.success)
287
- throw new Error(n.error || "批量双三次插值失败");
288
- return n.points;
289
- } catch (n) {
290
- throw n;
287
+ if (!r.success)
288
+ throw new Error(r.error || "批量双三次插值失败");
289
+ return r.points;
290
+ } catch (r) {
291
+ throw r;
291
292
  }
292
293
  }
293
294
  /**
@@ -299,36 +300,36 @@ const q = class T {
299
300
  if (e.length !== 4)
300
301
  throw new Error("需要恰好 4 个控制点");
301
302
  try {
302
- const n = this.call(
303
+ const r = this.call(
303
304
  "wasmBatchBilinearInterpolation",
304
305
  JSON.stringify(t),
305
306
  JSON.stringify(e)
306
307
  );
307
- if (!n.success)
308
- throw new Error(n.error || "批量双线性插值失败");
309
- return n.points;
310
- } catch (n) {
311
- throw n;
308
+ if (!r.success)
309
+ throw new Error(r.error || "批量双线性插值失败");
310
+ return r.points;
311
+ } catch (r) {
312
+ throw r;
312
313
  }
313
314
  }
314
315
  /**
315
316
  * 批量任意网格插值(高性能优化)
316
317
  */
317
- batchArbitraryMeshInterpolation(t, e, n) {
318
+ batchArbitraryMeshInterpolation(t, e, r) {
318
319
  if (!this.wasmReady)
319
320
  throw new Error("WASM 未加载");
320
321
  try {
321
- const r = this.call(
322
+ const n = this.call(
322
323
  "wasmBatchArbitraryMeshInterpolation",
323
324
  JSON.stringify(t),
324
325
  JSON.stringify(e),
325
- n
326
+ r
326
327
  );
327
- if (!r.success)
328
- throw new Error(r.error || "批量网格插值失败");
329
- return r.points;
330
- } catch (r) {
331
- throw r;
328
+ if (!n.success)
329
+ throw new Error(n.error || "批量网格插值失败");
330
+ return n.points;
331
+ } catch (n) {
332
+ throw n;
332
333
  }
333
334
  }
334
335
  /**
@@ -337,17 +338,17 @@ const q = class T {
337
338
  call(t, ...e) {
338
339
  if (!this.wasmReady)
339
340
  throw new Error("WASM 未加载");
340
- const r = (typeof self < "u" ? self : globalThis)[t];
341
- if (!r)
341
+ const n = (typeof self < "u" ? self : globalThis)[t];
342
+ if (!n)
342
343
  throw new Error(`函数不存在: ${t}`);
343
344
  try {
344
- return r(...e);
345
+ return n(...e);
345
346
  } catch (o) {
346
347
  throw o;
347
348
  }
348
349
  }
349
350
  };
350
- k(q, "instance");
351
+ $(q, "instance");
351
352
  let te = q, d = null, L = !1, C = null, b = null, _ = null, O = null, U = null;
352
353
  function re(s) {
353
354
  b = s.licenseToken, _ = s.licenseApiUrl, O = s.deviceId, U = s.domain, self.LICENSE_TOKEN = b, self.LICENSE_API_URL = _, self.DEVICE_ID = O, self.DOMAIN = U, d || (C && !L && (C = null), z().then(() => {
@@ -380,12 +381,12 @@ async function z() {
380
381
  } catch {
381
382
  }
382
383
  return "/assets/" + c;
383
- }, e = self.WASM_URL || t("perspective.wasm"), n = self.WASM_EXEC_URL || t("wasm_exec.js");
384
- await d.load(e, n);
385
- const r = b || self.LICENSE_TOKEN, o = _ || self.LICENSE_API_URL, u = O || self.DEVICE_ID, i = U || self.DOMAIN;
386
- if (!r)
384
+ }, e = self.WASM_URL || t("perspective.wasm"), r = self.WASM_EXEC_URL || t("wasm_exec.js");
385
+ await d.load(e, r);
386
+ const n = b || self.LICENSE_TOKEN, o = _ || self.LICENSE_API_URL, u = O || self.DEVICE_ID, i = U || self.DOMAIN;
387
+ if (!n)
387
388
  throw new Error("LICENSE_TOKEN 未设置,无法使用 WASM 功能");
388
- if (!await d.verifyLicense(r, o))
389
+ if (!await d.verifyLicense(n, o))
389
390
  throw new Error("WASM License 验证失败,无法使用 WASM 功能");
390
391
  } catch (t) {
391
392
  throw d = null, C = null, t;
@@ -403,18 +404,18 @@ function ne(s, t) {
403
404
  const e = s.bounds;
404
405
  if (t && t.width > 0 && t.height > 0)
405
406
  return { ...s };
406
- const n = s.size || s.placedLayer || {
407
+ const r = s.size || s.placedLayer || {
407
408
  width: e.width,
408
409
  height: e.height
409
- }, r = n.width / e.width, o = n.height / e.height, u = { ...s };
410
+ }, n = r.width / e.width, o = r.height / e.height, u = { ...s };
410
411
  return s.transform && s.transform.length === 8 && (u.transform = [
411
- (s.transform[0] - e.left) * r,
412
+ (s.transform[0] - e.left) * n,
412
413
  (s.transform[1] - e.top) * o,
413
- (s.transform[2] - e.left) * r,
414
+ (s.transform[2] - e.left) * n,
414
415
  (s.transform[3] - e.top) * o,
415
- (s.transform[4] - e.left) * r,
416
+ (s.transform[4] - e.left) * n,
416
417
  (s.transform[5] - e.top) * o,
417
- (s.transform[6] - e.left) * r,
418
+ (s.transform[6] - e.left) * n,
418
419
  (s.transform[7] - e.top) * o
419
420
  ]), u;
420
421
  }
@@ -424,8 +425,8 @@ function se(s) {
424
425
  function oe(s, t, e) {
425
426
  if (!s || !t || !e)
426
427
  return "Invalid Parameters";
427
- const n = "naturalWidth" in t ? t.naturalWidth : "width" in t ? t.width : 0, r = "naturalHeight" in t ? t.naturalHeight : "height" in t ? t.height : 0;
428
- if (!n || !r)
428
+ const r = "naturalWidth" in t ? t.naturalWidth : "width" in t ? t.width : 0, n = "naturalHeight" in t ? t.naturalHeight : "height" in t ? t.height : 0;
429
+ if (!r || !n)
429
430
  return "Image Not Loaded";
430
431
  s.imageSmoothingEnabled = !0, s.imageSmoothingQuality = "high";
431
432
  let o = null, u = null, i = null, w = null, c = 0, l = 0, a = null, h = "Unknown";
@@ -440,45 +441,45 @@ function oe(s, t, e) {
440
441
  }
441
442
  return e.quiltSliceX && (i = e.quiltSliceX), e.quiltSliceY && (w = e.quiltSliceY), e.filterList && (a = e.filterList.find((f) => f.type === "puppet" && f.enabled)), c === 0 && i && i.length > 0 && (c = i[i.length - 1]), c === 0 && (c = 1e3), l === 0 && (l = 1e3), a && a.filter && a.filter.puppetShapeList && a.filter.puppetShapeList.length > 0 && u ? (ie(s, t, u, a.filter.puppetShapeList[0]), h = "Puppet Warp") : o && u ? i && w ? (ce(s, t, u, o, i, w, c, l), h = "Quilt Mesh") : o.length === 16 ? (ue(s, t, u, o), h = "Std Mesh (16pt)") : (ae(s, t, u, o), h = "Auto-Fit Mesh") : o ? (fe(s, t, o), h = "Direct Mesh") : u && (Y(s, t, u), h = "Transform Only"), h;
442
443
  }
443
- function ie(s, t, e, n, r, o) {
444
- if (!n.originalVertexArray || !n.deformedVertexArray || !n.indexArray)
444
+ function ie(s, t, e, r, n, o) {
445
+ if (!r.originalVertexArray || !r.deformedVertexArray || !r.indexArray)
445
446
  return;
446
447
  const u = G(e), i = he(u);
447
448
  if (!i) {
448
449
  Y(s, t, e);
449
450
  return;
450
451
  }
451
- const w = n.originalVertexArray, c = n.deformedVertexArray, l = n.indexArray;
452
+ const w = r.originalVertexArray, c = r.deformedVertexArray, l = r.indexArray;
452
453
  for (let a = 0; a < l.length; a += 3) {
453
454
  const h = l[a], f = l[a + 1], y = l[a + 2];
454
455
  if (!w[h] || !w[f] || !w[y]) continue;
455
- const m = w[h], A = w[f], E = w[y], g = V(m.x, m.y, i), M = V(A.x, A.y, i), x = V(E.x, E.y, i), p = X(t), S = { x: g.x * p.width, y: g.y * p.height }, F = { x: M.x * p.width, y: M.y * p.height }, D = { x: x.x * p.width, y: x.y * p.height }, B = c[h], v = c[f], P = c[y];
456
- j(s, t, S, F, D, B, v, P);
456
+ const m = w[h], A = w[f], E = w[y], g = V(m.x, m.y, i), M = V(A.x, A.y, i), x = V(E.x, E.y, i), p = X(t), S = { x: g.x * p.width, y: g.y * p.height }, W = { x: M.x * p.width, y: M.y * p.height }, D = { x: x.x * p.width, y: x.y * p.height }, B = c[h], F = c[f], P = c[y];
457
+ j(s, t, S, W, D, B, F, P);
457
458
  }
458
459
  }
459
- function ue(s, t, e, n) {
460
- let r = 1 / 0, o = -1 / 0, u = 1 / 0, i = -1 / 0;
461
- n.forEach((a) => {
462
- r = Math.min(r, a.x), o = Math.max(o, a.x), u = Math.min(u, a.y), i = Math.max(i, a.y);
460
+ function ue(s, t, e, r) {
461
+ let n = 1 / 0, o = -1 / 0, u = 1 / 0, i = -1 / 0;
462
+ r.forEach((a) => {
463
+ n = Math.min(n, a.x), o = Math.max(o, a.x), u = Math.min(u, a.y), i = Math.max(i, a.y);
463
464
  });
464
- const w = o - r, c = i - u;
465
+ const w = o - n, c = i - u;
465
466
  if (w < 1 || c < 1) {
466
467
  Y(s, t, e);
467
468
  return;
468
469
  }
469
- const l = n.map((a) => {
470
- const h = (a.x - r) / w, f = (a.y - u) / c;
470
+ const l = r.map((a) => {
471
+ const h = (a.x - n) / w, f = (a.y - u) / c;
471
472
  return N(h, f, e);
472
473
  });
473
474
  H(s, t, l, "bicubic", 4, 40);
474
475
  }
475
- function ce(s, t, e, n, r, o, u, i) {
476
+ function ce(s, t, e, r, n, o, u, i) {
476
477
  const w = G(e);
477
478
  let c = 1 / 0, l = -1 / 0, a = 1 / 0, h = -1 / 0;
478
- n.forEach((E) => {
479
+ r.forEach((E) => {
479
480
  c = Math.min(c, E.x), l = Math.max(l, E.x), a = Math.min(a, E.y), h = Math.max(h, E.y);
480
481
  });
481
- const f = l - c || 1, y = h - a || 1, m = r.length - 1, A = o.length - 1;
482
+ const f = l - c || 1, y = h - a || 1, m = n.length - 1, A = o.length - 1;
482
483
  for (let E = 0; E < A; E++)
483
484
  for (let g = 0; g < m; g++) {
484
485
  const M = E * 3, x = g * 3, p = [], S = m * 3 + 1;
@@ -486,37 +487,37 @@ function ce(s, t, e, n, r, o, u, i) {
486
487
  for (let I = 0; I < 4; I++)
487
488
  for (let R = 0; R < 4; R++) {
488
489
  const J = (M + I) * S + (x + R);
489
- n[J] && p.push(n[J]);
490
+ r[J] && p.push(r[J]);
490
491
  }
491
492
  } catch {
492
493
  continue;
493
494
  }
494
495
  if (p.length < 16) continue;
495
- const F = p.map((I) => {
496
+ const W = p.map((I) => {
496
497
  const R = (I.x - c) / f, J = (I.y - a) / y;
497
498
  return Q(R, J, w);
498
- }), D = r[g] / u, B = r[g + 1] / u, v = o[E] / i, P = o[E + 1] / i;
499
- le(s, t, F, D, B, v, P);
499
+ }), D = n[g] / u, B = n[g + 1] / u, F = o[E] / i, P = o[E + 1] / i;
500
+ le(s, t, W, D, B, F, P);
500
501
  }
501
502
  }
502
- function ae(s, t, e, n) {
503
- const r = G(e);
503
+ function ae(s, t, e, r) {
504
+ const n = G(e);
504
505
  let o = 1 / 0, u = -1 / 0, i = 1 / 0, w = -1 / 0;
505
- n.forEach((f) => {
506
+ r.forEach((f) => {
506
507
  o = Math.min(o, f.x), u = Math.max(u, f.x), i = Math.min(i, f.y), w = Math.max(w, f.y);
507
508
  });
508
- const c = u - o || 1, l = w - i || 1, a = n.map((f) => {
509
+ const c = u - o || 1, l = w - i || 1, a = r.map((f) => {
509
510
  const y = (f.x - o) / c, m = (f.y - i) / l;
510
- return Q(y, m, r);
511
- }), h = Math.floor(Math.sqrt(n.length)) || 4;
511
+ return Q(y, m, n);
512
+ }), h = Math.floor(Math.sqrt(r.length)) || 4;
512
513
  H(s, t, a, "grid", h, 40);
513
514
  }
514
- function le(s, t, e, n, r, o, u) {
515
+ function le(s, t, e, r, n, o, u) {
515
516
  const w = X(t), c = w.width, l = w.height;
516
517
  for (let a = 0; a < 20; a++)
517
518
  for (let h = 0; h < 20; h++) {
518
- const f = h / 20, y = a / 20, m = (h + 1) / 20, A = (a + 1) / 20, E = n + f * (r - n), g = n + m * (r - n), M = o + y * (u - o), x = o + A * (u - o), p = { x: E * c, y: M * l }, S = { x: g * c, y: M * l }, F = { x: E * c, y: x * l }, D = { x: g * c, y: x * l }, B = W(f, y, e), v = W(m, y, e), P = W(f, A, e), I = W(m, A, e);
519
- j(s, t, p, S, F, B, v, P), j(s, t, S, D, F, v, I, P);
519
+ const f = h / 20, y = a / 20, m = (h + 1) / 20, A = (a + 1) / 20, E = r + f * (n - r), g = r + m * (n - r), M = o + y * (u - o), x = o + A * (u - o), p = { x: E * c, y: M * l }, S = { x: g * c, y: M * l }, W = { x: E * c, y: x * l }, D = { x: g * c, y: x * l }, B = v(f, y, e), F = v(m, y, e), P = v(f, A, e), I = v(m, A, e);
520
+ j(s, t, p, S, W, B, F, P), j(s, t, S, D, W, F, I, P);
520
521
  }
521
522
  }
522
523
  function Y(s, t, e) {
@@ -525,37 +526,37 @@ function Y(s, t, e) {
525
526
  function fe(s, t, e) {
526
527
  H(s, t, e, "bicubic", 4, 40);
527
528
  }
528
- function H(s, t, e, n, r, o) {
529
+ function H(s, t, e, r, n, o) {
529
530
  const u = X(t), i = u.width, w = u.height;
530
531
  for (let c = 0; c < o; c++)
531
532
  for (let l = 0; l < o; l++) {
532
533
  const a = l / o, h = c / o, f = (l + 1) / o, y = (c + 1) / o, m = { x: a * i, y: h * w }, A = { x: f * i, y: h * w }, E = { x: a * i, y: y * w }, g = { x: f * i, y: y * w };
533
534
  let M, x, p, S;
534
- n === "bicubic" ? (M = W(a, h, e), x = W(f, h, e), p = W(a, y, e), S = W(f, y, e)) : n === "grid" ? (M = $(a, h, e, r), x = $(f, h, e, r), p = $(a, y, e, r), S = $(f, y, e, r)) : (M = N(a, h, e), x = N(f, h, e), p = N(a, y, e), S = N(f, y, e)), j(s, t, m, A, E, M, x, p), j(s, t, A, g, E, x, S, p);
535
+ r === "bicubic" ? (M = v(a, h, e), x = v(f, h, e), p = v(a, y, e), S = v(f, y, e)) : r === "grid" ? (M = k(a, h, e, n), x = k(f, h, e, n), p = k(a, y, e, n), S = k(f, y, e, n)) : (M = N(a, h, e), x = N(f, h, e), p = N(a, y, e), S = N(f, y, e)), j(s, t, m, A, E, M, x, p), j(s, t, A, g, E, x, S, p);
535
536
  }
536
537
  }
537
538
  function K(s, t) {
538
539
  const e = 1 - t;
539
540
  return s === 0 ? e * e * e : s === 1 ? 3 * e * e * t : s === 2 ? 3 * e * t * t : t * t * t;
540
541
  }
541
- function W(s, t, e) {
542
- let n = 0, r = 0;
542
+ function v(s, t, e) {
543
+ let r = 0, n = 0;
543
544
  for (let o = 0; o < 4; o++)
544
545
  for (let u = 0; u < 4; u++) {
545
546
  const i = K(o, t) * K(u, s);
546
- n += e[o * 4 + u].x * i, r += e[o * 4 + u].y * i;
547
+ r += e[o * 4 + u].x * i, n += e[o * 4 + u].y * i;
547
548
  }
548
- return { x: n, y: r };
549
+ return { x: r, y: n };
549
550
  }
550
551
  function N(s, t, e) {
551
- const n = (1 - s) * (1 - t) * e[0].x + s * (1 - t) * e[1].x + s * t * e[2].x + (1 - s) * t * e[3].x, r = (1 - s) * (1 - t) * e[0].y + s * (1 - t) * e[1].y + s * t * e[2].y + (1 - s) * t * e[3].y;
552
- return { x: n, y: r };
552
+ const r = (1 - s) * (1 - t) * e[0].x + s * (1 - t) * e[1].x + s * t * e[2].x + (1 - s) * t * e[3].x, n = (1 - s) * (1 - t) * e[0].y + s * (1 - t) * e[1].y + s * t * e[2].y + (1 - s) * t * e[3].y;
553
+ return { x: r, y: n };
553
554
  }
554
- function $(s, t, e, n) {
555
- const r = n - 1, o = s * r, u = t * r;
555
+ function k(s, t, e, r) {
556
+ const n = r - 1, o = s * n, u = t * n;
556
557
  let i = Math.floor(o), w = Math.floor(u);
557
- i >= r && (i = r - 1), w >= r && (w = r - 1), i < 0 && (i = 0), w < 0 && (w = 0);
558
- const c = o - i, l = u - w, a = e[w * n + i], h = e[w * n + (i + 1)], f = e[(w + 1) * n + i], y = e[(w + 1) * n + (i + 1)], m = (1 - c) * (1 - l) * a.x + c * (1 - l) * h.x + c * l * y.x + (1 - c) * l * f.x, A = (1 - c) * (1 - l) * a.y + c * (1 - l) * h.y + c * l * y.y + (1 - c) * l * f.y;
558
+ i >= n && (i = n - 1), w >= n && (w = n - 1), i < 0 && (i = 0), w < 0 && (w = 0);
559
+ const c = o - i, l = u - w, a = e[w * r + i], h = e[w * r + (i + 1)], f = e[(w + 1) * r + i], y = e[(w + 1) * r + (i + 1)], m = (1 - c) * (1 - l) * a.x + c * (1 - l) * h.x + c * l * y.x + (1 - c) * l * f.x, A = (1 - c) * (1 - l) * a.y + c * (1 - l) * h.y + c * l * y.y + (1 - c) * l * f.y;
559
560
  return { x: m, y: A };
560
561
  }
561
562
  function G(s) {
@@ -581,8 +582,8 @@ function V(s, t, e) {
581
582
  throw new Error("WASM 模块未加载,无法应用逆透视变换");
582
583
  try {
583
584
  return d.applyInversePerspective(s, t, e);
584
- } catch (n) {
585
- throw new Error(`WASM 应用逆透视变换失败: ${n}`);
585
+ } catch (r) {
586
+ throw new Error(`WASM 应用逆透视变换失败: ${r}`);
586
587
  }
587
588
  }
588
589
  function Q(s, t, e) {
@@ -590,29 +591,29 @@ function Q(s, t, e) {
590
591
  throw new Error("WASM 模块未加载,无法应用透视变换");
591
592
  try {
592
593
  return d.applyPerspective(s, t, e);
593
- } catch (n) {
594
- throw new Error(`WASM 应用透视变换失败: ${n}`);
594
+ } catch (r) {
595
+ throw new Error(`WASM 应用透视变换失败: ${r}`);
595
596
  }
596
597
  }
597
- function j(s, t, e, n, r, o, u, i) {
598
+ function j(s, t, e, r, n, o, u, i) {
598
599
  if (!t || "complete" in t && !t.complete || !("naturalWidth" in t ? t.naturalWidth : t.width)) return;
599
600
  const c = (o.x + u.x + i.x) / 3, l = (o.y + u.y + i.y) / 3, a = (Math.hypot(o.x - c, o.y - l) + Math.hypot(u.x - c, u.y - l) + Math.hypot(i.x - c, i.y - l)) / 3, f = a > 1 ? (a + 1.65) / a : 1.5, y = c + (o.x - c) * f, m = l + (o.y - l) * f, A = c + (u.x - c) * f, E = l + (u.y - l) * f, g = c + (i.x - c) * f, M = l + (i.y - l) * f;
600
601
  s.save(), s.beginPath(), s.moveTo(y, m), s.lineTo(A, E), s.lineTo(g, M), s.closePath(), s.clip();
601
- const x = e.x * (r.y - n.y) - n.x * r.y + r.x * n.y + (n.x - r.x) * e.y;
602
+ const x = e.x * (n.y - r.y) - r.x * n.y + n.x * r.y + (r.x - n.x) * e.y;
602
603
  if (Math.abs(x) < 1e-3) {
603
604
  s.restore();
604
605
  return;
605
606
  }
606
- const p = -(e.y * (i.x - u.x) - n.y * i.x + r.y * u.x + (n.y - r.y) * o.x) / x, S = (n.y * i.y + e.y * (u.y - i.y) - r.y * u.y + (r.y - n.y) * o.y) / x, F = (e.x * (i.x - u.x) - n.x * i.x + r.x * u.x + (n.x - r.x) * o.x) / x, D = -(n.x * i.y + e.x * (u.y - i.y) - r.x * u.y + (r.x - n.x) * o.y) / x, B = (e.x * (r.y * u.x - n.y * i.x) + e.y * (n.x * i.x - r.x * u.x) + (r.x * n.y - n.x * r.y) * o.x) / x, v = (e.x * (r.y * u.y - n.y * i.y) + e.y * (n.x * i.y - r.x * u.y) + (r.x * n.y - n.x * r.y) * o.y) / x;
607
- s.transform(p, S, F, D, B, v), s.drawImage(t, 0, 0), s.restore();
607
+ const p = -(e.y * (i.x - u.x) - r.y * i.x + n.y * u.x + (r.y - n.y) * o.x) / x, S = (r.y * i.y + e.y * (u.y - i.y) - n.y * u.y + (n.y - r.y) * o.y) / x, W = (e.x * (i.x - u.x) - r.x * i.x + n.x * u.x + (r.x - n.x) * o.x) / x, D = -(r.x * i.y + e.x * (u.y - i.y) - n.x * u.y + (n.x - r.x) * o.y) / x, B = (e.x * (n.y * u.x - r.y * i.x) + e.y * (r.x * i.x - n.x * u.x) + (n.x * r.y - r.x * n.y) * o.x) / x, F = (e.x * (n.y * u.y - r.y * i.y) + e.y * (r.x * i.y - n.x * u.y) + (n.x * r.y - r.x * n.y) * o.y) / x;
608
+ s.transform(p, S, W, D, B, F), s.drawImage(t, 0, 0), s.restore();
608
609
  }
609
610
  self.onmessage = async (s) => {
610
611
  if (s.data?.type === "SET_LICENSE") {
611
612
  re(s.data);
612
613
  return;
613
614
  }
614
- const t = s.data, { id: e, designBitmap: n, layerData: r, canvasSize: o } = t;
615
- if (!n) {
615
+ const t = s.data, { id: e, designBitmap: r, layerData: n, canvasSize: o } = t;
616
+ if (!r) {
616
617
  self.postMessage({
617
618
  id: e,
618
619
  imageBitmap: null,
@@ -621,7 +622,7 @@ self.onmessage = async (s) => {
621
622
  });
622
623
  return;
623
624
  }
624
- if (!r) {
625
+ if (!n) {
625
626
  self.postMessage({
626
627
  id: e,
627
628
  imageBitmap: null,
@@ -675,7 +676,7 @@ self.onmessage = async (s) => {
675
676
  }
676
677
  }
677
678
  try {
678
- const i = r.bounds;
679
+ const i = n.bounds;
679
680
  if (!i || !i.width || !i.height) {
680
681
  self.postMessage({
681
682
  id: e,
@@ -685,12 +686,12 @@ self.onmessage = async (s) => {
685
686
  });
686
687
  return;
687
688
  }
688
- const w = ne(r, o);
689
+ const w = ne(n, o);
689
690
  let c, l;
690
691
  if (o && o.width > 0 && o.height > 0)
691
692
  c = o.width, l = o.height;
692
693
  else {
693
- const M = r.size || r.placedLayer || {
694
+ const M = n.size || n.placedLayer || {
694
695
  width: i.width,
695
696
  height: i.height
696
697
  };
@@ -702,8 +703,8 @@ self.onmessage = async (s) => {
702
703
  self.postMessage({ id: e, error: "Canvas context unavailable", duration: x });
703
704
  return;
704
705
  }
705
- const f = oe(h, n, w), y = a.transferToImageBitmap(), A = performance.now() - u, E = (/* @__PURE__ */ new Date()).toISOString();
706
- n.close();
706
+ const f = oe(h, r, w), y = a.transferToImageBitmap(), A = performance.now() - u, E = (/* @__PURE__ */ new Date()).toISOString();
707
+ r.close();
707
708
  const g = se(
708
709
  { id: e, imageBitmap: y, duration: A }
709
710
  );