@jieyin/editor-sdk 1.1.193 → 1.1.194

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,4 +1,24 @@
1
- class $ {
1
+ function re() {
2
+ try {
3
+ const o = typeof self < "u" && typeof self.location < "u" ? self.location.href : typeof window < "u" ? window.location.href : "";
4
+ if (!o) return "";
5
+ const r = new URL(o).pathname;
6
+ for (const e of ["/sdk-workers/", "/assets/"]) {
7
+ const t = r.indexOf(e);
8
+ if (t >= 0) return r.slice(0, t);
9
+ }
10
+ } catch {
11
+ }
12
+ return "";
13
+ }
14
+ function te() {
15
+ return re();
16
+ }
17
+ function V(o) {
18
+ const r = o.replace(/^\//, ""), e = te();
19
+ return e ? `${e}/${r}` : `/${r}`;
20
+ }
21
+ class _ {
2
22
  static instance;
3
23
  wasmReady = !1;
4
24
  go = null;
@@ -19,7 +39,7 @@ class $ {
19
39
  this.isDebugEnabled() && console.warn(...r);
20
40
  }
21
41
  static getInstance() {
22
- return $.instance || ($.instance = new $()), $.instance;
42
+ return _.instance || (_.instance = new _()), _.instance;
23
43
  }
24
44
  /**
25
45
  * 在 Worker 环境中加载 WASM 模块
@@ -41,20 +61,22 @@ class $ {
41
61
  try {
42
62
  let f = null;
43
63
  if (typeof import.meta < "u" && import.meta.url ? f = import.meta.url : typeof self < "u" && self.location && (f = self.location.href), f) {
44
- const u = new URL(f), d = u.pathname;
45
- if (d.includes("/js/")) {
64
+ const u = new URL(f), w = u.pathname;
65
+ if (w.includes("/js/")) {
46
66
  const m = "../assets/" + c, y = new URL(m, u);
47
- return this.debugLog(`🔍 [WASM] 计算路径: ${c} -> ${y.pathname} (Worker: ${d})`), y.pathname;
48
- } else if (d.includes("/assets/")) {
67
+ return this.debugLog(`🔍 [WASM] 计算路径: ${c} -> ${y.pathname} (Worker: ${w})`), y.pathname;
68
+ } else if (w.includes("/assets/")) {
49
69
  const m = "./" + c, y = new URL(m, u);
50
- return this.debugLog(`🔍 [WASM] 计算路径: ${c} -> ${y.pathname} (Worker: ${d})`), y.pathname;
51
- } else
52
- return this.debugLog(`🔍 [WASM] 使用默认绝对路径: /assets/${c}`), "/assets/" + c;
70
+ return this.debugLog(`🔍 [WASM] 计算路径: ${c} -> ${y.pathname} (Worker: ${w})`), y.pathname;
71
+ } else {
72
+ const m = V(`assets/${c}`);
73
+ return this.debugLog(`🔍 [WASM] 使用 SDK 资源路径: ${m}`), m;
74
+ }
53
75
  }
54
76
  } catch (f) {
55
77
  this.debugWarn("⚠️ 无法计算 WASM 相对路径,使用默认路径:", f);
56
78
  }
57
- return "/assets/" + c;
79
+ return V(`assets/${c}`);
58
80
  }, n = e || t("wasm_exec.js"), s = r || t("perspective.wasm");
59
81
  this.debugLog("🔍 [WASM] 最终使用的路径:", { execUrl: n, moduleUrl: s }), await this.loadWasmExec(n);
60
82
  const i = typeof self < "u" ? self : globalThis;
@@ -62,7 +84,7 @@ class $ {
62
84
  const a = await fetch(s);
63
85
  if (!a.ok)
64
86
  throw new Error(`无法加载 WASM 文件: ${a.status}`);
65
- const w = await a.arrayBuffer(), l = await WebAssembly.instantiate(w, this.go.importObject);
87
+ const d = await a.arrayBuffer(), l = await WebAssembly.instantiate(d, this.go.importObject);
66
88
  this.wasmModule = l.instance, this.go.run(this.wasmModule), this.wasmReady = !0;
67
89
  const h = this.call("wasmInit");
68
90
  if (h && h.success)
@@ -125,8 +147,8 @@ class $ {
125
147
  })
126
148
  })).json();
127
149
  if (!i.success || !i.valid) {
128
- const w = i.error || "License 验证失败";
129
- throw new Error(w);
150
+ const d = i.error || "License 验证失败";
151
+ throw new Error(d);
130
152
  }
131
153
  const a = this.call("wasmVerifyLicense", r);
132
154
  if (!a.success || a.valid !== !0)
@@ -371,24 +393,24 @@ class $ {
371
393
  }
372
394
  }
373
395
  }
374
- let V = !1;
396
+ let X = !1;
375
397
  const A = (...o) => {
376
- V && console.log(...o);
377
- }, Z = (...o) => {
378
- V && console.warn(...o);
398
+ X && console.log(...o);
399
+ }, D = (...o) => {
400
+ X && console.warn(...o);
379
401
  };
380
- let g = null, N = !1, b = null, k = null, U = null, C = null, j = null;
381
- function ee(o) {
382
- k = o.licenseToken, U = o.licenseApiUrl, C = o.deviceId, j = o.domain, self.LICENSE_TOKEN = k, self.LICENSE_API_URL = U, self.DEVICE_ID = C, self.DOMAIN = j, A("✅ [deform.worker] License 信息已接收"), g || (b && !N && (b = null), A("🔄 [deform.worker] 开始初始化 WASM..."), Y().then(() => {
402
+ let g = null, P = !1, b = null, R = null, U = null, C = null, j = null;
403
+ function ne(o) {
404
+ R = o.licenseToken, U = o.licenseApiUrl, C = o.deviceId, j = o.domain, self.LICENSE_TOKEN = R, self.LICENSE_API_URL = U, self.DEVICE_ID = C, self.DOMAIN = j, A("✅ [deform.worker] License 信息已接收"), g || (b && !P && (b = null), A("🔄 [deform.worker] 开始初始化 WASM..."), K().then(() => {
383
405
  A("✅ [deform.worker] WASM 初始化完成");
384
406
  }).catch((r) => {
385
- Z("⚠️ [deform.worker] WASM 初始化失败:", r);
407
+ D("⚠️ [deform.worker] WASM 初始化失败:", r);
386
408
  }));
387
409
  }
388
- async function Y() {
389
- return g ? void 0 : N ? b || Promise.resolve() : k || self.LICENSE_TOKEN ? (N = !0, b = (async () => {
410
+ async function K() {
411
+ return g ? void 0 : P ? b || Promise.resolve() : R || self.LICENSE_TOKEN ? (P = !0, b = (async () => {
390
412
  try {
391
- g = $.getInstance();
413
+ g = _.getInstance();
392
414
  const r = (l) => {
393
415
  const h = self.WASM_URL, c = self.WASM_EXEC_URL;
394
416
  if (l === "perspective.wasm" && h)
@@ -398,23 +420,25 @@ async function Y() {
398
420
  try {
399
421
  let f = null;
400
422
  if (typeof import.meta < "u" && import.meta.url ? f = import.meta.url : typeof self < "u" && self.location && (f = self.location.href), f) {
401
- const u = new URL(f), d = u.pathname;
402
- if (d.includes("/js/")) {
423
+ const u = new URL(f), w = u.pathname;
424
+ if (w.includes("/js/")) {
403
425
  const m = "../assets/" + l, y = new URL(m, u);
404
- return A(`🔍 [deform.worker] 计算路径: ${l} -> ${y.pathname} (Worker: ${d})`), y.pathname;
405
- } else if (d.includes("/assets/")) {
426
+ return A(`🔍 [deform.worker] 计算路径: ${l} -> ${y.pathname} (Worker: ${w})`), y.pathname;
427
+ } else if (w.includes("/assets/")) {
406
428
  const m = "./" + l, y = new URL(m, u);
407
- return A(`🔍 [deform.worker] 计算路径: ${l} -> ${y.pathname} (Worker: ${d})`), y.pathname;
408
- } else
409
- return A(`🔍 [deform.worker] 使用默认绝对路径: /assets/${l}`), "/assets/" + l;
429
+ return A(`🔍 [deform.worker] 计算路径: ${l} -> ${y.pathname} (Worker: ${w})`), y.pathname;
430
+ } else {
431
+ const m = V(`assets/${l}`);
432
+ return A(`🔍 [deform.worker] 使用 SDK 资源路径: ${m}`), m;
433
+ }
410
434
  }
411
435
  } catch (f) {
412
- Z("⚠️ [deform.worker] 无法计算 WASM 相对路径,使用默认路径:", f);
436
+ D("⚠️ [deform.worker] 无法计算 WASM 相对路径,使用默认路径:", f);
413
437
  }
414
- return "/assets/" + l;
438
+ return V(`assets/${l}`);
415
439
  }, e = self.WASM_URL || r("perspective.wasm"), t = self.WASM_EXEC_URL || r("wasm_exec.js");
416
440
  A("🔍 [deform.worker] 最终使用的 WASM 路径:", { wasmUrl: e, wasmExecUrl: t }), await g.load(e, t);
417
- const n = k || self.LICENSE_TOKEN, s = U || self.LICENSE_API_URL, i = C || self.DEVICE_ID, a = j || self.DOMAIN;
441
+ const n = R || self.LICENSE_TOKEN, s = U || self.LICENSE_API_URL, i = C || self.DEVICE_ID, a = j || self.DOMAIN;
418
442
  if (!n)
419
443
  throw new Error("LICENSE_TOKEN 未设置,无法使用 WASM 功能");
420
444
  if (!await g.verifyLicense(n, s))
@@ -423,14 +447,14 @@ async function Y() {
423
447
  } catch (r) {
424
448
  throw console.error("❌ WASM 加载或验证失败:", r), g = null, b = null, r;
425
449
  } finally {
426
- N = !1;
450
+ P = !1;
427
451
  }
428
452
  })(), b) : (A("⏳ [deform.worker] 等待 License Token..."), Promise.resolve());
429
453
  }
430
- function K(o) {
454
+ function q(o) {
431
455
  return "naturalWidth" in o && o.naturalWidth ? { width: o.naturalWidth, height: o.naturalHeight } : "width" in o ? { width: o.width, height: o.height } : { width: 0, height: 0 };
432
456
  }
433
- function re(o, r) {
457
+ function oe(o, r) {
434
458
  if (!o || !o.bounds)
435
459
  throw new Error("Invalid layer data: missing bounds");
436
460
  const e = o.bounds;
@@ -451,17 +475,17 @@ function re(o, r) {
451
475
  (o.transform[7] - e.top) * s
452
476
  ]), i;
453
477
  }
454
- function te(o) {
478
+ function se(o) {
455
479
  return o.error, o;
456
480
  }
457
- function ne(o, r, e) {
481
+ function ie(o, r, e) {
458
482
  if (!o || !r || !e)
459
483
  return "Invalid Parameters";
460
484
  const t = "naturalWidth" in r ? r.naturalWidth : "width" in r ? r.width : 0, n = "naturalHeight" in r ? r.naturalHeight : "height" in r ? r.height : 0;
461
485
  if (!t || !n)
462
486
  return "Image Not Loaded";
463
487
  o.imageSmoothingEnabled = !0, o.imageSmoothingQuality = "high";
464
- let s = null, i = null, a = null, w = null, l = 0, h = 0, c = null, f = "Unknown";
488
+ let s = null, i = null, a = null, d = null, l = 0, h = 0, c = null, f = "Unknown";
465
489
  if (e.size && e.size.width ? (l = e.size.width, h = e.size.height) : e.placedLayer && e.placedLayer.width ? (l = e.placedLayer.width, h = e.placedLayer.height) : e.originalWidth && (l = e.originalWidth, h = e.originalHeight), e.meshPoints && e.meshPoints.length > 0 && (s = e.meshPoints), e.transform && e.transform.length === 8) {
466
490
  const u = e.transform;
467
491
  i = [
@@ -471,47 +495,47 @@ function ne(o, r, e) {
471
495
  { x: u[6], y: u[7] }
472
496
  ];
473
497
  }
474
- return e.quiltSliceX && (a = e.quiltSliceX), e.quiltSliceY && (w = e.quiltSliceY), e.filterList && (c = e.filterList.find((u) => u.type === "puppet" && u.enabled)), l === 0 && a && a.length > 0 && (l = a[a.length - 1]), l === 0 && (l = 1e3), h === 0 && (h = 1e3), c && c.filter && c.filter.puppetShapeList && c.filter.puppetShapeList.length > 0 && i ? (oe(o, r, i, c.filter.puppetShapeList[0]), f = "Puppet Warp") : s && i ? a && w ? (ie(o, r, i, s, a, w, l, h), f = "Quilt Mesh") : s.length === 16 ? (se(o, r, i, s), f = "Std Mesh (16pt)") : (ce(o, r, i, s), f = "Auto-Fit Mesh") : s ? (le(o, r, s), f = "Direct Mesh") : i && (q(o, r, i), f = "Transform Only"), f;
498
+ return e.quiltSliceX && (a = e.quiltSliceX), e.quiltSliceY && (d = e.quiltSliceY), e.filterList && (c = e.filterList.find((u) => u.type === "puppet" && u.enabled)), l === 0 && a && a.length > 0 && (l = a[a.length - 1]), l === 0 && (l = 1e3), h === 0 && (h = 1e3), c && c.filter && c.filter.puppetShapeList && c.filter.puppetShapeList.length > 0 && i ? (ce(o, r, i, c.filter.puppetShapeList[0]), f = "Puppet Warp") : s && i ? a && d ? (le(o, r, i, s, a, d, l, h), f = "Quilt Mesh") : s.length === 16 ? (ae(o, r, i, s), f = "Std Mesh (16pt)") : (fe(o, r, i, s), f = "Auto-Fit Mesh") : s ? (ue(o, r, s), f = "Direct Mesh") : i && (F(o, r, i), f = "Transform Only"), f;
475
499
  }
476
- function oe(o, r, e, t, n, s) {
500
+ function ce(o, r, e, t, n, s) {
477
501
  if (!t.originalVertexArray || !t.deformedVertexArray || !t.indexArray)
478
502
  return;
479
- const i = F(e), a = fe(i);
503
+ const i = Q(e), a = de(i);
480
504
  if (!a) {
481
- q(o, r, e);
505
+ F(o, r, e);
482
506
  return;
483
507
  }
484
- const w = t.originalVertexArray, l = t.deformedVertexArray, h = t.indexArray;
508
+ const d = t.originalVertexArray, l = t.deformedVertexArray, h = t.indexArray;
485
509
  for (let c = 0; c < h.length; c += 3) {
486
- const f = h[c], u = h[c + 1], d = h[c + 2];
487
- if (!w[f] || !w[u] || !w[d]) continue;
488
- const m = w[f], y = w[u], x = w[d], p = G(m.x, m.y, a), E = G(y.x, y.y, a), S = G(x.x, x.y, a), M = K(r), W = { x: p.x * M.width, y: p.y * M.height }, L = { x: E.x * M.width, y: E.y * M.height }, T = { x: S.x * M.width, y: S.y * M.height }, P = l[f], R = l[u], _ = l[d];
489
- J(o, r, W, L, T, P, R, _);
510
+ const f = h[c], u = h[c + 1], w = h[c + 2];
511
+ if (!d[f] || !d[u] || !d[w]) continue;
512
+ const m = d[f], y = d[u], x = d[w], p = Y(m.x, m.y, a), E = Y(y.x, y.y, a), S = Y(x.x, x.y, a), M = q(r), W = { x: p.x * M.width, y: p.y * M.height }, L = { x: E.x * M.width, y: E.y * M.height }, k = { x: S.x * M.width, y: S.y * M.height }, N = l[f], T = l[u], $ = l[w];
513
+ J(o, r, W, L, k, N, T, $);
490
514
  }
491
515
  }
492
- function se(o, r, e, t) {
516
+ function ae(o, r, e, t) {
493
517
  let n = 1 / 0, s = -1 / 0, i = 1 / 0, a = -1 / 0;
494
518
  t.forEach((c) => {
495
519
  n = Math.min(n, c.x), s = Math.max(s, c.x), i = Math.min(i, c.y), a = Math.max(a, c.y);
496
520
  });
497
- const w = s - n, l = a - i;
498
- if (w < 1 || l < 1) {
499
- q(o, r, e);
521
+ const d = s - n, l = a - i;
522
+ if (d < 1 || l < 1) {
523
+ F(o, r, e);
500
524
  return;
501
525
  }
502
526
  const h = t.map((c) => {
503
- const f = (c.x - n) / w, u = (c.y - i) / l;
527
+ const f = (c.x - n) / d, u = (c.y - i) / l;
504
528
  return B(f, u, e);
505
529
  });
506
- X(o, r, h, "bicubic", 4, 40);
530
+ G(o, r, h, "bicubic", 4, 40);
507
531
  }
508
- function ie(o, r, e, t, n, s, i, a) {
509
- const w = F(e);
532
+ function le(o, r, e, t, n, s, i, a) {
533
+ const d = Q(e);
510
534
  let l = 1 / 0, h = -1 / 0, c = 1 / 0, f = -1 / 0;
511
535
  t.forEach((x) => {
512
536
  l = Math.min(l, x.x), h = Math.max(h, x.x), c = Math.min(c, x.y), f = Math.max(f, x.y);
513
537
  });
514
- const u = h - l || 1, d = f - c || 1, m = n.length - 1, y = s.length - 1;
538
+ const u = h - l || 1, w = f - c || 1, m = n.length - 1, y = s.length - 1;
515
539
  for (let x = 0; x < y; x++)
516
540
  for (let p = 0; p < m; p++) {
517
541
  const E = x * 3, S = p * 3, M = [], W = m * 3 + 1;
@@ -526,48 +550,48 @@ function ie(o, r, e, t, n, s, i, a) {
526
550
  }
527
551
  if (M.length < 16) continue;
528
552
  const L = M.map((I) => {
529
- const O = (I.x - l) / u, H = (I.y - c) / d;
530
- return D(O, H, w);
531
- }), T = n[p] / i, P = n[p + 1] / i, R = s[x] / a, _ = s[x + 1] / a;
532
- ae(o, r, L, T, P, R, _);
553
+ const O = (I.x - l) / u, H = (I.y - c) / w;
554
+ return ee(O, H, d);
555
+ }), k = n[p] / i, N = n[p + 1] / i, T = s[x] / a, $ = s[x + 1] / a;
556
+ he(o, r, L, k, N, T, $);
533
557
  }
534
558
  }
535
- function ce(o, r, e, t) {
536
- const n = F(e);
537
- let s = 1 / 0, i = -1 / 0, a = 1 / 0, w = -1 / 0;
559
+ function fe(o, r, e, t) {
560
+ const n = Q(e);
561
+ let s = 1 / 0, i = -1 / 0, a = 1 / 0, d = -1 / 0;
538
562
  t.forEach((u) => {
539
- s = Math.min(s, u.x), i = Math.max(i, u.x), a = Math.min(a, u.y), w = Math.max(w, u.y);
563
+ s = Math.min(s, u.x), i = Math.max(i, u.x), a = Math.min(a, u.y), d = Math.max(d, u.y);
540
564
  });
541
- const l = i - s || 1, h = w - a || 1, c = t.map((u) => {
542
- const d = (u.x - s) / l, m = (u.y - a) / h;
543
- return D(d, m, n);
565
+ const l = i - s || 1, h = d - a || 1, c = t.map((u) => {
566
+ const w = (u.x - s) / l, m = (u.y - a) / h;
567
+ return ee(w, m, n);
544
568
  }), f = Math.floor(Math.sqrt(t.length)) || 4;
545
- X(o, r, c, "grid", f, 40);
569
+ G(o, r, c, "grid", f, 40);
546
570
  }
547
- function ae(o, r, e, t, n, s, i) {
548
- const w = K(r), l = w.width, h = w.height;
571
+ function he(o, r, e, t, n, s, i) {
572
+ const d = q(r), l = d.width, h = d.height;
549
573
  for (let c = 0; c < 20; c++)
550
574
  for (let f = 0; f < 20; f++) {
551
- const u = f / 20, d = c / 20, m = (f + 1) / 20, y = (c + 1) / 20, x = t + u * (n - t), p = t + m * (n - t), E = s + d * (i - s), S = s + y * (i - s), M = { x: x * l, y: E * h }, W = { x: p * l, y: E * h }, L = { x: x * l, y: S * h }, T = { x: p * l, y: S * h }, P = v(u, d, e), R = v(m, d, e), _ = v(u, y, e), I = v(m, y, e);
552
- J(o, r, M, W, L, P, R, _), J(o, r, W, T, L, R, I, _);
575
+ const u = f / 20, w = c / 20, m = (f + 1) / 20, y = (c + 1) / 20, x = t + u * (n - t), p = t + m * (n - t), E = s + w * (i - s), S = s + y * (i - s), M = { x: x * l, y: E * h }, W = { x: p * l, y: E * h }, L = { x: x * l, y: S * h }, k = { x: p * l, y: S * h }, N = v(u, w, e), T = v(m, w, e), $ = v(u, y, e), I = v(m, y, e);
576
+ J(o, r, M, W, L, N, T, $), J(o, r, W, k, L, T, I, $);
553
577
  }
554
578
  }
555
- function q(o, r, e) {
556
- X(o, r, e, "bilinear", 0, 10);
579
+ function F(o, r, e) {
580
+ G(o, r, e, "bilinear", 0, 10);
557
581
  }
558
- function le(o, r, e) {
559
- X(o, r, e, "bicubic", 4, 40);
582
+ function ue(o, r, e) {
583
+ G(o, r, e, "bicubic", 4, 40);
560
584
  }
561
- function X(o, r, e, t, n, s) {
562
- const i = K(r), a = i.width, w = i.height;
585
+ function G(o, r, e, t, n, s) {
586
+ const i = q(r), a = i.width, d = i.height;
563
587
  for (let l = 0; l < s; l++)
564
588
  for (let h = 0; h < s; h++) {
565
- const c = h / s, f = l / s, u = (h + 1) / s, d = (l + 1) / s, m = { x: c * a, y: f * w }, y = { x: u * a, y: f * w }, x = { x: c * a, y: d * w }, p = { x: u * a, y: d * w };
589
+ const c = h / s, f = l / s, u = (h + 1) / s, w = (l + 1) / s, m = { x: c * a, y: f * d }, y = { x: u * a, y: f * d }, x = { x: c * a, y: w * d }, p = { x: u * a, y: w * d };
566
590
  let E, S, M, W;
567
- t === "bicubic" ? (E = v(c, f, e), S = v(u, f, e), M = v(c, d, e), W = v(u, d, e)) : t === "grid" ? (E = z(c, f, e, n), S = z(u, f, e, n), M = z(c, d, e, n), W = z(u, d, e, n)) : (E = B(c, f, e), S = B(u, f, e), M = B(c, d, e), W = B(u, d, e)), J(o, r, m, y, x, E, S, M), J(o, r, y, p, x, S, W, M);
591
+ t === "bicubic" ? (E = v(c, f, e), S = v(u, f, e), M = v(c, w, e), W = v(u, w, e)) : t === "grid" ? (E = z(c, f, e, n), S = z(u, f, e, n), M = z(c, w, e, n), W = z(u, w, e, n)) : (E = B(c, f, e), S = B(u, f, e), M = B(c, w, e), W = B(u, w, e)), J(o, r, m, y, x, E, S, M), J(o, r, y, p, x, S, W, M);
568
592
  }
569
593
  }
570
- function Q(o, r) {
594
+ function Z(o, r) {
571
595
  const e = 1 - r;
572
596
  return o === 0 ? e * e * e : o === 1 ? 3 * e * e * r : o === 2 ? 3 * e * r * r : r * r * r;
573
597
  }
@@ -575,7 +599,7 @@ function v(o, r, e) {
575
599
  let t = 0, n = 0;
576
600
  for (let s = 0; s < 4; s++)
577
601
  for (let i = 0; i < 4; i++) {
578
- const a = Q(s, r) * Q(i, o);
602
+ const a = Z(s, r) * Z(i, o);
579
603
  t += e[s * 4 + i].x * a, n += e[s * 4 + i].y * a;
580
604
  }
581
605
  return { x: t, y: n };
@@ -586,12 +610,12 @@ function B(o, r, e) {
586
610
  }
587
611
  function z(o, r, e, t) {
588
612
  const n = t - 1, s = o * n, i = r * n;
589
- let a = Math.floor(s), w = Math.floor(i);
590
- a >= n && (a = n - 1), w >= n && (w = n - 1), a < 0 && (a = 0), w < 0 && (w = 0);
591
- const l = s - a, h = i - w, c = e[w * t + a], f = e[w * t + (a + 1)], u = e[(w + 1) * t + a], d = e[(w + 1) * t + (a + 1)], m = (1 - l) * (1 - h) * c.x + l * (1 - h) * f.x + l * h * d.x + (1 - l) * h * u.x, y = (1 - l) * (1 - h) * c.y + l * (1 - h) * f.y + l * h * d.y + (1 - l) * h * u.y;
613
+ let a = Math.floor(s), d = Math.floor(i);
614
+ a >= n && (a = n - 1), d >= n && (d = n - 1), a < 0 && (a = 0), d < 0 && (d = 0);
615
+ const l = s - a, h = i - d, c = e[d * t + a], f = e[d * t + (a + 1)], u = e[(d + 1) * t + a], w = e[(d + 1) * t + (a + 1)], m = (1 - l) * (1 - h) * c.x + l * (1 - h) * f.x + l * h * w.x + (1 - l) * h * u.x, y = (1 - l) * (1 - h) * c.y + l * (1 - h) * f.y + l * h * w.y + (1 - l) * h * u.y;
592
616
  return { x: m, y };
593
617
  }
594
- function F(o) {
618
+ function Q(o) {
595
619
  if (!g || !g.isReady())
596
620
  throw new Error("WASM 模块未加载,无法计算透视变换矩阵");
597
621
  try {
@@ -600,7 +624,7 @@ function F(o) {
600
624
  throw new Error(`WASM 计算透视矩阵失败: ${r}`);
601
625
  }
602
626
  }
603
- function fe(o) {
627
+ function de(o) {
604
628
  if (!g || !g.isReady())
605
629
  throw new Error("WASM 模块未加载,无法求逆矩阵");
606
630
  try {
@@ -609,7 +633,7 @@ function fe(o) {
609
633
  throw new Error(`WASM 求逆矩阵失败: ${r}`);
610
634
  }
611
635
  }
612
- function G(o, r, e) {
636
+ function Y(o, r, e) {
613
637
  if (!g || !g.isReady())
614
638
  throw new Error("WASM 模块未加载,无法应用逆透视变换");
615
639
  try {
@@ -618,7 +642,7 @@ function G(o, r, e) {
618
642
  throw new Error(`WASM 应用逆透视变换失败: ${t}`);
619
643
  }
620
644
  }
621
- function D(o, r, e) {
645
+ function ee(o, r, e) {
622
646
  if (!g || !g.isReady())
623
647
  throw new Error("WASM 模块未加载,无法应用透视变换");
624
648
  try {
@@ -629,24 +653,24 @@ function D(o, r, e) {
629
653
  }
630
654
  function J(o, r, e, t, n, s, i, a) {
631
655
  if (!r || "complete" in r && !r.complete || !("naturalWidth" in r ? r.naturalWidth : r.width)) return;
632
- const l = (s.x + i.x + a.x) / 3, h = (s.y + i.y + a.y) / 3, c = 1.65, f = l + (s.x - l) * c, u = h + (s.y - h) * c, d = l + (i.x - l) * c, m = h + (i.y - h) * c, y = l + (a.x - l) * c, x = h + (a.y - h) * c;
633
- o.save(), o.beginPath(), o.moveTo(f, u), o.lineTo(d, m), o.lineTo(y, x), o.closePath(), o.clip();
656
+ const l = (s.x + i.x + a.x) / 3, h = (s.y + i.y + a.y) / 3, c = 1.65, f = l + (s.x - l) * c, u = h + (s.y - h) * c, w = l + (i.x - l) * c, m = h + (i.y - h) * c, y = l + (a.x - l) * c, x = h + (a.y - h) * c;
657
+ o.save(), o.beginPath(), o.moveTo(f, u), o.lineTo(w, m), o.lineTo(y, x), o.closePath(), o.clip();
634
658
  const p = e.x * (n.y - t.y) - t.x * n.y + n.x * t.y + (t.x - n.x) * e.y;
635
659
  if (Math.abs(p) < 1e-3) {
636
660
  o.restore();
637
661
  return;
638
662
  }
639
- const E = -(e.y * (a.x - i.x) - t.y * a.x + n.y * i.x + (t.y - n.y) * s.x) / p, S = (t.y * a.y + e.y * (i.y - a.y) - n.y * i.y + (n.y - t.y) * s.y) / p, M = (e.x * (a.x - i.x) - t.x * a.x + n.x * i.x + (t.x - n.x) * s.x) / p, W = -(t.x * a.y + e.x * (i.y - a.y) - n.x * i.y + (n.x - t.x) * s.y) / p, L = (e.x * (n.y * i.x - t.y * a.x) + e.y * (t.x * a.x - n.x * i.x) + (n.x * t.y - t.x * n.y) * s.x) / p, T = (e.x * (n.y * i.y - t.y * a.y) + e.y * (t.x * a.y - n.x * i.y) + (n.x * t.y - t.x * n.y) * s.y) / p;
640
- o.transform(E, S, M, W, L, T), o.drawImage(r, 0, 0), o.restore();
663
+ const E = -(e.y * (a.x - i.x) - t.y * a.x + n.y * i.x + (t.y - n.y) * s.x) / p, S = (t.y * a.y + e.y * (i.y - a.y) - n.y * i.y + (n.y - t.y) * s.y) / p, M = (e.x * (a.x - i.x) - t.x * a.x + n.x * i.x + (t.x - n.x) * s.x) / p, W = -(t.x * a.y + e.x * (i.y - a.y) - n.x * i.y + (n.x - t.x) * s.y) / p, L = (e.x * (n.y * i.x - t.y * a.x) + e.y * (t.x * a.x - n.x * i.x) + (n.x * t.y - t.x * n.y) * s.x) / p, k = (e.x * (n.y * i.y - t.y * a.y) + e.y * (t.x * a.y - n.x * i.y) + (n.x * t.y - t.x * n.y) * s.y) / p;
664
+ o.transform(E, S, M, W, L, k), o.drawImage(r, 0, 0), o.restore();
641
665
  }
642
666
  A("🚀 [deform.worker] Worker 启动,等待 License Token...");
643
667
  self.onmessage = async (o) => {
644
668
  if (o.data?.type === "SET_DEBUG") {
645
- V = !!o.data?.debugRender, self.__DEBUG_RENDER__ = V;
669
+ X = !!o.data?.debugRender, self.__DEBUG_RENDER__ = X;
646
670
  return;
647
671
  }
648
672
  if (o.data?.type === "SET_LICENSE") {
649
- ee(o.data);
673
+ ne(o.data);
650
674
  return;
651
675
  }
652
676
  const r = o.data, { id: e, designBitmap: t, layerData: n, canvasSize: s } = r;
@@ -675,10 +699,10 @@ self.onmessage = async (o) => {
675
699
  bounds: n.bounds,
676
700
  canvasSize: s
677
701
  }), !g || !g.isReady())
678
- if (k || self.LICENSE_TOKEN) {
702
+ if (R || self.LICENSE_TOKEN) {
679
703
  console.log("🔄 [deform.worker] WASM 未就绪,尝试初始化...");
680
704
  try {
681
- if (N && b && (console.log("⏳ [deform.worker] WASM 正在加载中,等待完成..."), await b), (!g || !g.isReady()) && await Y(), !g || !g.isReady())
705
+ if (P && b && (console.log("⏳ [deform.worker] WASM 正在加载中,等待完成..."), await b), (!g || !g.isReady()) && await K(), !g || !g.isReady())
682
706
  throw new Error("WASM 模块仍未就绪");
683
707
  console.log("✅ [deform.worker] WASM 初始化成功,继续处理任务");
684
708
  } catch (l) {
@@ -697,10 +721,10 @@ self.onmessage = async (o) => {
697
721
  const h = 500, c = 50;
698
722
  let f = null;
699
723
  for (; l < h && !f; )
700
- await new Promise((u) => setTimeout(u, c)), l += c, f = k || self.LICENSE_TOKEN;
724
+ await new Promise((u) => setTimeout(u, c)), l += c, f = R || self.LICENSE_TOKEN;
701
725
  if (f)
702
726
  try {
703
- if (k = f, U = U || self.LICENSE_API_URL, C = C || self.DEVICE_ID, j = j || self.DOMAIN, N && b ? (console.log("⏳ [deform.worker] WASM 正在加载中,等待完成..."), await b) : g || await Y(), !g || !g.isReady())
727
+ if (R = f, U = U || self.LICENSE_API_URL, C = C || self.DEVICE_ID, j = j || self.DOMAIN, P && b ? (console.log("⏳ [deform.worker] WASM 正在加载中,等待完成..."), await b) : g || await K(), !g || !g.isReady())
704
728
  throw new Error("WASM 模块未就绪");
705
729
  console.log("✅ [deform.worker] WASM 初始化成功,继续处理任务");
706
730
  } catch (u) {
@@ -715,19 +739,19 @@ self.onmessage = async (o) => {
715
739
  }
716
740
  else if (!f) {
717
741
  console.error("❌ [deform.worker] 等待超时,License Token 未设置");
718
- const d = performance.now() - i;
742
+ const w = performance.now() - i;
719
743
  self.postMessage({
720
744
  id: e,
721
745
  error: "LICENSE_TOKEN 未设置,无法使用 WASM 功能",
722
- duration: d
746
+ duration: w
723
747
  });
724
748
  return;
725
749
  }
726
750
  }
727
751
  try {
728
- const w = n.bounds;
729
- if (!w || !w.width || !w.height) {
730
- console.error(`[deform worker] ❌ bounds 无效 id=${e}`, w), self.postMessage({
752
+ const d = n.bounds;
753
+ if (!d || !d.width || !d.height) {
754
+ console.error(`[deform worker] ❌ bounds 无效 id=${e}`, d), self.postMessage({
731
755
  id: e,
732
756
  imageBitmap: null,
733
757
  error: "bounds 无效",
@@ -735,14 +759,14 @@ self.onmessage = async (o) => {
735
759
  });
736
760
  return;
737
761
  }
738
- const l = re(n, s);
762
+ const l = oe(n, s);
739
763
  let h, c;
740
764
  if (s && s.width > 0 && s.height > 0)
741
765
  h = s.width, c = s.height;
742
766
  else {
743
767
  const S = n.size || n.placedLayer || {
744
- width: w.width,
745
- height: w.height
768
+ width: d.width,
769
+ height: d.height
746
770
  };
747
771
  h = S.width, c = S.height;
748
772
  }
@@ -752,23 +776,23 @@ self.onmessage = async (o) => {
752
776
  self.postMessage({ id: e, error: "Canvas context unavailable", duration: M });
753
777
  return;
754
778
  }
755
- const d = ne(u, t, l), m = f.transferToImageBitmap(), x = performance.now() - i, p = (/* @__PURE__ */ new Date()).toISOString();
779
+ const w = ie(u, t, l), m = f.transferToImageBitmap(), x = performance.now() - i, p = (/* @__PURE__ */ new Date()).toISOString();
756
780
  A(
757
- `[deform worker] ✅ 结束 id=${e} 时间=${p} 耗时=${Math.round(x)}ms 变形方法=${d}`,
781
+ `[deform worker] ✅ 结束 id=${e} 时间=${p} 耗时=${Math.round(x)}ms 变形方法=${w}`,
758
782
  {
759
783
  width: m.width,
760
784
  height: m.height
761
785
  }
762
786
  ), t.close();
763
- const E = te(
787
+ const E = se(
764
788
  { id: e, imageBitmap: m, duration: x }
765
789
  );
766
790
  self.postMessage(
767
791
  E,
768
792
  E.imageBitmap ? [E.imageBitmap] : []
769
793
  );
770
- } catch (w) {
771
- const h = performance.now() - i, c = w instanceof Error ? w.message : String(w), f = (/* @__PURE__ */ new Date()).toISOString();
794
+ } catch (d) {
795
+ const h = performance.now() - i, c = d instanceof Error ? d.message : String(d), f = (/* @__PURE__ */ new Date()).toISOString();
772
796
  A(
773
797
  `[deform worker] ❌ 错误 id=${e} 时间=${f} 耗时=${Math.round(h)}ms`,
774
798
  c