@jieyin/editor-sdk 1.1.138 → 1.1.180
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.
- package/README.md +154 -267
- package/dist/deform.worker.js +141 -141
- package/dist/editor-sdk.es.js +15902 -8750
- package/dist/renderWorker.js +36116 -1969
- package/dist/style.css +1 -1
- package/package.json +51 -48
package/dist/deform.worker.js
CHANGED
|
@@ -31,40 +31,40 @@ const Z = class P {
|
|
|
31
31
|
}
|
|
32
32
|
try {
|
|
33
33
|
this.debugLog("🚀 Worker: 加载透视变换 WASM...");
|
|
34
|
-
const r = (
|
|
35
|
-
if (e &&
|
|
34
|
+
const r = (i) => {
|
|
35
|
+
if (e && i === "wasm_exec.js")
|
|
36
36
|
return e;
|
|
37
|
-
if (t &&
|
|
37
|
+
if (t && i === "perspective.wasm")
|
|
38
38
|
return t;
|
|
39
39
|
try {
|
|
40
|
-
let
|
|
41
|
-
if (typeof import.meta < "u" && import.meta.url ?
|
|
42
|
-
const
|
|
40
|
+
let h = null;
|
|
41
|
+
if (typeof import.meta < "u" && import.meta.url ? h = import.meta.url : typeof self < "u" && self.location && (h = self.location.href), h) {
|
|
42
|
+
const f = new URL(h), d = f.pathname;
|
|
43
43
|
if (d.includes("/js/")) {
|
|
44
|
-
const y = "../assets/" +
|
|
45
|
-
return this.debugLog(`🔍 [WASM] 计算路径: ${
|
|
44
|
+
const y = "../assets/" + i, m = new URL(y, f);
|
|
45
|
+
return this.debugLog(`🔍 [WASM] 计算路径: ${i} -> ${m.pathname} (Worker: ${d})`), m.pathname;
|
|
46
46
|
} else if (d.includes("/assets/")) {
|
|
47
|
-
const y = "./" +
|
|
48
|
-
return this.debugLog(`🔍 [WASM] 计算路径: ${
|
|
47
|
+
const y = "./" + i, m = new URL(y, f);
|
|
48
|
+
return this.debugLog(`🔍 [WASM] 计算路径: ${i} -> ${m.pathname} (Worker: ${d})`), m.pathname;
|
|
49
49
|
} else
|
|
50
|
-
return this.debugLog(`🔍 [WASM] 使用默认绝对路径: /assets/${
|
|
50
|
+
return this.debugLog(`🔍 [WASM] 使用默认绝对路径: /assets/${i}`), "/assets/" + i;
|
|
51
51
|
}
|
|
52
|
-
} catch (
|
|
53
|
-
this.debugWarn("⚠️ 无法计算 WASM 相对路径,使用默认路径:",
|
|
52
|
+
} catch (h) {
|
|
53
|
+
this.debugWarn("⚠️ 无法计算 WASM 相对路径,使用默认路径:", h);
|
|
54
54
|
}
|
|
55
|
-
return "/assets/" +
|
|
55
|
+
return "/assets/" + i;
|
|
56
56
|
}, n = e || r("wasm_exec.js"), u = t || r("perspective.wasm");
|
|
57
57
|
this.debugLog("🔍 [WASM] 最终使用的路径:", { execUrl: n, moduleUrl: u }), await this.loadWasmExec(n);
|
|
58
58
|
const o = typeof self < "u" ? self : globalThis;
|
|
59
59
|
this.go = new o.Go();
|
|
60
|
-
const
|
|
61
|
-
if (!
|
|
62
|
-
throw new Error(`无法加载 WASM 文件: ${
|
|
63
|
-
const w = await
|
|
60
|
+
const c = await fetch(u);
|
|
61
|
+
if (!c.ok)
|
|
62
|
+
throw new Error(`无法加载 WASM 文件: ${c.status}`);
|
|
63
|
+
const w = await c.arrayBuffer(), a = await WebAssembly.instantiate(w, this.go.importObject);
|
|
64
64
|
this.wasmModule = a.instance, this.go.run(this.wasmModule), this.wasmReady = !0;
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
67
|
-
this.debugLog("✅ Worker WASM 加载成功:",
|
|
65
|
+
const l = this.call("wasmInit");
|
|
66
|
+
if (l && l.success)
|
|
67
|
+
this.debugLog("✅ Worker WASM 加载成功:", l);
|
|
68
68
|
else
|
|
69
69
|
throw new Error("WASM 初始化失败");
|
|
70
70
|
} catch (r) {
|
|
@@ -126,8 +126,8 @@ const Z = class P {
|
|
|
126
126
|
const w = o.error || "License 验证失败";
|
|
127
127
|
throw new Error(w);
|
|
128
128
|
}
|
|
129
|
-
const
|
|
130
|
-
if (!
|
|
129
|
+
const c = this.call("wasmVerifyLicense", t);
|
|
130
|
+
if (!c.success || c.valid !== !0)
|
|
131
131
|
throw new Error("WASM 验证失败");
|
|
132
132
|
return !0;
|
|
133
133
|
} catch (r) {
|
|
@@ -371,45 +371,45 @@ const Z = class P {
|
|
|
371
371
|
};
|
|
372
372
|
z(Z, "instance");
|
|
373
373
|
let ne = Z, H = !1;
|
|
374
|
-
const
|
|
374
|
+
const L = (...s) => {
|
|
375
375
|
}, se = (...s) => {
|
|
376
376
|
};
|
|
377
|
-
let E = null,
|
|
377
|
+
let E = null, R = !1, M = null, b = null, O = null, $ = null, U = null;
|
|
378
378
|
function ue(s) {
|
|
379
|
-
|
|
379
|
+
b = s.licenseToken, O = s.licenseApiUrl, $ = s.deviceId, U = s.domain, self.LICENSE_TOKEN = b, self.LICENSE_API_URL = O, self.DEVICE_ID = $, self.DOMAIN = U, E || (M && !R && (M = null), G().then(() => {
|
|
380
380
|
}).catch((t) => {
|
|
381
381
|
}));
|
|
382
382
|
}
|
|
383
383
|
async function G() {
|
|
384
|
-
return E ? void 0 :
|
|
384
|
+
return E ? void 0 : R ? M || Promise.resolve() : b || self.LICENSE_TOKEN ? (R = !0, M = (async () => {
|
|
385
385
|
try {
|
|
386
386
|
E = ne.getInstance();
|
|
387
387
|
const t = (a) => {
|
|
388
|
-
const
|
|
389
|
-
if (a === "perspective.wasm" &&
|
|
390
|
-
return
|
|
391
|
-
if (a === "wasm_exec.js" &&
|
|
392
|
-
return
|
|
388
|
+
const l = self.WASM_URL, i = self.WASM_EXEC_URL;
|
|
389
|
+
if (a === "perspective.wasm" && l)
|
|
390
|
+
return l;
|
|
391
|
+
if (a === "wasm_exec.js" && i)
|
|
392
|
+
return i;
|
|
393
393
|
try {
|
|
394
|
-
let
|
|
395
|
-
if (typeof import.meta < "u" && import.meta.url ?
|
|
396
|
-
const
|
|
394
|
+
let h = null;
|
|
395
|
+
if (typeof import.meta < "u" && import.meta.url ? h = import.meta.url : typeof self < "u" && self.location && (h = self.location.href), h) {
|
|
396
|
+
const f = new URL(h), d = f.pathname;
|
|
397
397
|
if (d.includes("/js/")) {
|
|
398
|
-
const y = "../assets/" + a, m = new URL(y,
|
|
399
|
-
return
|
|
398
|
+
const y = "../assets/" + a, m = new URL(y, f);
|
|
399
|
+
return L(`🔍 [deform.worker] 计算路径: ${a} -> ${m.pathname} (Worker: ${d})`), m.pathname;
|
|
400
400
|
} else if (d.includes("/assets/")) {
|
|
401
|
-
const y = "./" + a, m = new URL(y,
|
|
402
|
-
return
|
|
401
|
+
const y = "./" + a, m = new URL(y, f);
|
|
402
|
+
return L(`🔍 [deform.worker] 计算路径: ${a} -> ${m.pathname} (Worker: ${d})`), m.pathname;
|
|
403
403
|
} else
|
|
404
|
-
return
|
|
404
|
+
return L(`🔍 [deform.worker] 使用默认绝对路径: /assets/${a}`), "/assets/" + a;
|
|
405
405
|
}
|
|
406
|
-
} catch (
|
|
407
|
-
se("⚠️ [deform.worker] 无法计算 WASM 相对路径,使用默认路径:",
|
|
406
|
+
} catch (h) {
|
|
407
|
+
se("⚠️ [deform.worker] 无法计算 WASM 相对路径,使用默认路径:", h);
|
|
408
408
|
}
|
|
409
409
|
return "/assets/" + a;
|
|
410
410
|
}, e = self.WASM_URL || t("perspective.wasm"), r = self.WASM_EXEC_URL || t("wasm_exec.js");
|
|
411
|
-
|
|
412
|
-
const n =
|
|
411
|
+
L("🔍 [deform.worker] 最终使用的 WASM 路径:", { wasmUrl: e, wasmExecUrl: r }), await E.load(e, r);
|
|
412
|
+
const n = b || self.LICENSE_TOKEN, u = O || self.LICENSE_API_URL, o = $ || self.DEVICE_ID, c = U || self.DOMAIN;
|
|
413
413
|
if (!n)
|
|
414
414
|
throw new Error("LICENSE_TOKEN 未设置,无法使用 WASM 功能");
|
|
415
415
|
if (!await E.verifyLicense(n, u))
|
|
@@ -417,7 +417,7 @@ async function G() {
|
|
|
417
417
|
} catch (t) {
|
|
418
418
|
throw E = null, M = null, t;
|
|
419
419
|
} finally {
|
|
420
|
-
|
|
420
|
+
R = !1;
|
|
421
421
|
}
|
|
422
422
|
})(), M) : Promise.resolve();
|
|
423
423
|
}
|
|
@@ -455,64 +455,64 @@ function ce(s, t, e) {
|
|
|
455
455
|
if (!r || !n)
|
|
456
456
|
return "Image Not Loaded";
|
|
457
457
|
s.imageSmoothingEnabled = !0, s.imageSmoothingQuality = "high";
|
|
458
|
-
let u = null, o = null,
|
|
459
|
-
if (e.size && e.size.width ? (a = e.size.width,
|
|
460
|
-
const
|
|
458
|
+
let u = null, o = null, c = null, w = null, a = 0, l = 0, i = null, h = "Unknown";
|
|
459
|
+
if (e.size && e.size.width ? (a = e.size.width, l = e.size.height) : e.placedLayer && e.placedLayer.width ? (a = e.placedLayer.width, l = e.placedLayer.height) : e.originalWidth && (a = e.originalWidth, l = e.originalHeight), e.meshPoints && e.meshPoints.length > 0 && (u = e.meshPoints), e.transform && e.transform.length === 8) {
|
|
460
|
+
const f = e.transform;
|
|
461
461
|
o = [
|
|
462
|
-
{ x:
|
|
463
|
-
{ x:
|
|
464
|
-
{ x:
|
|
465
|
-
{ x:
|
|
462
|
+
{ x: f[0], y: f[1] },
|
|
463
|
+
{ x: f[2], y: f[3] },
|
|
464
|
+
{ x: f[4], y: f[5] },
|
|
465
|
+
{ x: f[6], y: f[7] }
|
|
466
466
|
];
|
|
467
467
|
}
|
|
468
|
-
return e.quiltSliceX && (
|
|
468
|
+
return e.quiltSliceX && (c = e.quiltSliceX), e.quiltSliceY && (w = e.quiltSliceY), e.filterList && (i = e.filterList.find((f) => f.type === "puppet" && f.enabled)), a === 0 && c && c.length > 0 && (a = c[c.length - 1]), a === 0 && (a = 1e3), l === 0 && (l = 1e3), i && i.filter && i.filter.puppetShapeList && i.filter.puppetShapeList.length > 0 && o ? (ae(s, t, o, i.filter.puppetShapeList[0]), h = "Puppet Warp") : u && o ? c && w ? (he(s, t, o, u, c, w, a, l), h = "Quilt Mesh") : u.length === 16 ? (le(s, t, o, u), h = "Std Mesh (16pt)") : (fe(s, t, o, u), h = "Auto-Fit Mesh") : u ? (de(s, t, u), h = "Direct Mesh") : o && (K(s, t, o), h = "Transform Only"), h;
|
|
469
469
|
}
|
|
470
470
|
function ae(s, t, e, r, n, u) {
|
|
471
471
|
if (!r.originalVertexArray || !r.deformedVertexArray || !r.indexArray)
|
|
472
472
|
return;
|
|
473
|
-
const o = q(e),
|
|
474
|
-
if (!
|
|
473
|
+
const o = q(e), c = ye(o);
|
|
474
|
+
if (!c) {
|
|
475
475
|
K(s, t, e);
|
|
476
476
|
return;
|
|
477
477
|
}
|
|
478
|
-
const w = r.originalVertexArray, a = r.deformedVertexArray,
|
|
479
|
-
for (let
|
|
480
|
-
const
|
|
481
|
-
if (!w[
|
|
482
|
-
const y = w[
|
|
483
|
-
k(s, t, D, W,
|
|
478
|
+
const w = r.originalVertexArray, a = r.deformedVertexArray, l = r.indexArray;
|
|
479
|
+
for (let i = 0; i < l.length; i += 3) {
|
|
480
|
+
const h = l[i], f = l[i + 1], d = l[i + 2];
|
|
481
|
+
if (!w[h] || !w[f] || !w[d]) continue;
|
|
482
|
+
const y = w[h], m = w[f], F = w[d], g = X(y.x, y.y, c), p = X(m.x, m.y, c), x = X(F.x, F.y, c), A = Y(t), D = { x: g.x * A.width, y: g.y * A.height }, W = { x: p.x * A.width, y: p.y * A.height }, B = { x: x.x * A.width, y: x.y * A.height }, _ = a[h], I = a[f], v = a[d];
|
|
483
|
+
k(s, t, D, W, B, _, I, v);
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
486
|
function le(s, t, e, r) {
|
|
487
|
-
let n = 1 / 0, u = -1 / 0, o = 1 / 0,
|
|
488
|
-
r.forEach((
|
|
489
|
-
n = Math.min(n,
|
|
487
|
+
let n = 1 / 0, u = -1 / 0, o = 1 / 0, c = -1 / 0;
|
|
488
|
+
r.forEach((i) => {
|
|
489
|
+
n = Math.min(n, i.x), u = Math.max(u, i.x), o = Math.min(o, i.y), c = Math.max(c, i.y);
|
|
490
490
|
});
|
|
491
|
-
const w = u - n, a =
|
|
491
|
+
const w = u - n, a = c - o;
|
|
492
492
|
if (w < 1 || a < 1) {
|
|
493
493
|
K(s, t, e);
|
|
494
494
|
return;
|
|
495
495
|
}
|
|
496
|
-
const
|
|
497
|
-
const
|
|
498
|
-
return N(
|
|
496
|
+
const l = r.map((i) => {
|
|
497
|
+
const h = (i.x - n) / w, f = (i.y - o) / a;
|
|
498
|
+
return N(h, f, e);
|
|
499
499
|
});
|
|
500
|
-
V(s, t,
|
|
500
|
+
V(s, t, l, "bicubic", 4, 40);
|
|
501
501
|
}
|
|
502
|
-
function he(s, t, e, r, n, u, o,
|
|
502
|
+
function he(s, t, e, r, n, u, o, c) {
|
|
503
503
|
const w = q(e);
|
|
504
|
-
let a = 1 / 0,
|
|
505
|
-
r.forEach((
|
|
506
|
-
a = Math.min(a,
|
|
504
|
+
let a = 1 / 0, l = -1 / 0, i = 1 / 0, h = -1 / 0;
|
|
505
|
+
r.forEach((F) => {
|
|
506
|
+
a = Math.min(a, F.x), l = Math.max(l, F.x), i = Math.min(i, F.y), h = Math.max(h, F.y);
|
|
507
507
|
});
|
|
508
|
-
const
|
|
509
|
-
for (let
|
|
510
|
-
for (let
|
|
511
|
-
const
|
|
508
|
+
const f = l - a || 1, d = h - i || 1, y = n.length - 1, m = u.length - 1;
|
|
509
|
+
for (let F = 0; F < m; F++)
|
|
510
|
+
for (let g = 0; g < y; g++) {
|
|
511
|
+
const p = F * 3, x = g * 3, A = [], D = y * 3 + 1;
|
|
512
512
|
try {
|
|
513
513
|
for (let S = 0; S < 4; S++)
|
|
514
514
|
for (let T = 0; T < 4; T++) {
|
|
515
|
-
const J = (
|
|
515
|
+
const J = (p + S) * D + (x + T);
|
|
516
516
|
r[J] && A.push(r[J]);
|
|
517
517
|
}
|
|
518
518
|
} catch {
|
|
@@ -520,30 +520,30 @@ function he(s, t, e, r, n, u, o, i) {
|
|
|
520
520
|
}
|
|
521
521
|
if (A.length < 16) continue;
|
|
522
522
|
const W = A.map((S) => {
|
|
523
|
-
const T = (S.x - a) /
|
|
523
|
+
const T = (S.x - a) / f, J = (S.y - i) / d;
|
|
524
524
|
return ee(T, J, w);
|
|
525
|
-
}),
|
|
526
|
-
we(s, t, W,
|
|
525
|
+
}), B = n[g] / o, _ = n[g + 1] / o, I = u[F] / c, v = u[F + 1] / c;
|
|
526
|
+
we(s, t, W, B, _, I, v);
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
529
|
function fe(s, t, e, r) {
|
|
530
530
|
const n = q(e);
|
|
531
|
-
let u = 1 / 0, o = -1 / 0,
|
|
532
|
-
r.forEach((
|
|
533
|
-
u = Math.min(u,
|
|
531
|
+
let u = 1 / 0, o = -1 / 0, c = 1 / 0, w = -1 / 0;
|
|
532
|
+
r.forEach((f) => {
|
|
533
|
+
u = Math.min(u, f.x), o = Math.max(o, f.x), c = Math.min(c, f.y), w = Math.max(w, f.y);
|
|
534
534
|
});
|
|
535
|
-
const a = o - u || 1,
|
|
536
|
-
const d = (
|
|
535
|
+
const a = o - u || 1, l = w - c || 1, i = r.map((f) => {
|
|
536
|
+
const d = (f.x - u) / a, y = (f.y - c) / l;
|
|
537
537
|
return ee(d, y, n);
|
|
538
|
-
}),
|
|
539
|
-
V(s, t,
|
|
538
|
+
}), h = Math.floor(Math.sqrt(r.length)) || 4;
|
|
539
|
+
V(s, t, i, "grid", h, 40);
|
|
540
540
|
}
|
|
541
541
|
function we(s, t, e, r, n, u, o) {
|
|
542
|
-
const w = Y(t), a = w.width,
|
|
543
|
-
for (let
|
|
544
|
-
for (let
|
|
545
|
-
const
|
|
546
|
-
k(s, t, A, D, W,
|
|
542
|
+
const w = Y(t), a = w.width, l = w.height;
|
|
543
|
+
for (let i = 0; i < 20; i++)
|
|
544
|
+
for (let h = 0; h < 20; h++) {
|
|
545
|
+
const f = h / 20, d = i / 20, y = (h + 1) / 20, m = (i + 1) / 20, F = r + f * (n - r), g = r + y * (n - r), p = u + d * (o - u), x = u + m * (o - u), A = { x: F * a, y: p * l }, D = { x: g * a, y: p * l }, W = { x: F * a, y: x * l }, B = { x: g * a, y: x * l }, _ = C(f, d, e), I = C(y, d, e), v = C(f, m, e), S = C(y, m, e);
|
|
546
|
+
k(s, t, A, D, W, _, I, v), k(s, t, D, B, W, I, S, v);
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
549
|
function K(s, t, e) {
|
|
@@ -553,24 +553,24 @@ function de(s, t, e) {
|
|
|
553
553
|
V(s, t, e, "bicubic", 4, 40);
|
|
554
554
|
}
|
|
555
555
|
function V(s, t, e, r, n, u) {
|
|
556
|
-
const o = Y(t),
|
|
556
|
+
const o = Y(t), c = o.width, w = o.height;
|
|
557
557
|
for (let a = 0; a < u; a++)
|
|
558
|
-
for (let
|
|
559
|
-
const
|
|
560
|
-
let
|
|
561
|
-
r === "bicubic" ? (
|
|
558
|
+
for (let l = 0; l < u; l++) {
|
|
559
|
+
const i = l / u, h = a / u, f = (l + 1) / u, d = (a + 1) / u, y = { x: i * c, y: h * w }, m = { x: f * c, y: h * w }, F = { x: i * c, y: d * w }, g = { x: f * c, y: d * w };
|
|
560
|
+
let p, x, A, D;
|
|
561
|
+
r === "bicubic" ? (p = C(i, h, e), x = C(f, h, e), A = C(i, d, e), D = C(f, d, e)) : r === "grid" ? (p = j(i, h, e, n), x = j(f, h, e, n), A = j(i, d, e, n), D = j(f, d, e, n)) : (p = N(i, h, e), x = N(f, h, e), A = N(i, d, e), D = N(f, d, e)), k(s, t, y, m, F, p, x, A), k(s, t, m, g, F, x, D, A);
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
564
|
function Q(s, t) {
|
|
565
565
|
const e = 1 - t;
|
|
566
566
|
return s === 0 ? e * e * e : s === 1 ? 3 * e * e * t : s === 2 ? 3 * e * t * t : t * t * t;
|
|
567
567
|
}
|
|
568
|
-
function
|
|
568
|
+
function C(s, t, e) {
|
|
569
569
|
let r = 0, n = 0;
|
|
570
570
|
for (let u = 0; u < 4; u++)
|
|
571
571
|
for (let o = 0; o < 4; o++) {
|
|
572
|
-
const
|
|
573
|
-
r += e[u * 4 + o].x *
|
|
572
|
+
const c = Q(u, t) * Q(o, s);
|
|
573
|
+
r += e[u * 4 + o].x * c, n += e[u * 4 + o].y * c;
|
|
574
574
|
}
|
|
575
575
|
return { x: r, y: n };
|
|
576
576
|
}
|
|
@@ -580,9 +580,9 @@ function N(s, t, e) {
|
|
|
580
580
|
}
|
|
581
581
|
function j(s, t, e, r) {
|
|
582
582
|
const n = r - 1, u = s * n, o = t * n;
|
|
583
|
-
let
|
|
584
|
-
|
|
585
|
-
const a = u -
|
|
583
|
+
let c = Math.floor(u), w = Math.floor(o);
|
|
584
|
+
c >= n && (c = n - 1), w >= n && (w = n - 1), c < 0 && (c = 0), w < 0 && (w = 0);
|
|
585
|
+
const a = u - c, l = o - w, i = e[w * r + c], h = e[w * r + (c + 1)], f = e[(w + 1) * r + c], d = e[(w + 1) * r + (c + 1)], y = (1 - a) * (1 - l) * i.x + a * (1 - l) * h.x + a * l * d.x + (1 - a) * l * f.x, m = (1 - a) * (1 - l) * i.y + a * (1 - l) * h.y + a * l * d.y + (1 - a) * l * f.y;
|
|
586
586
|
return { x: y, y: m };
|
|
587
587
|
}
|
|
588
588
|
function q(s) {
|
|
@@ -621,17 +621,17 @@ function ee(s, t, e) {
|
|
|
621
621
|
throw new Error(`WASM 应用透视变换失败: ${r}`);
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
|
-
function k(s, t, e, r, n, u, o,
|
|
624
|
+
function k(s, t, e, r, n, u, o, c) {
|
|
625
625
|
if (!t || "complete" in t && !t.complete || !("naturalWidth" in t ? t.naturalWidth : t.width)) return;
|
|
626
|
-
const a = (u.x + o.x +
|
|
627
|
-
s.save(), s.beginPath(), s.moveTo(
|
|
628
|
-
const
|
|
629
|
-
if (Math.abs(
|
|
626
|
+
const a = (u.x + o.x + c.x) / 3, l = (u.y + o.y + c.y) / 3, i = 1.65, h = a + (u.x - a) * i, f = l + (u.y - l) * i, d = a + (o.x - a) * i, y = l + (o.y - l) * i, m = a + (c.x - a) * i, F = l + (c.y - l) * i;
|
|
627
|
+
s.save(), s.beginPath(), s.moveTo(h, f), s.lineTo(d, y), s.lineTo(m, F), s.closePath(), s.clip();
|
|
628
|
+
const g = e.x * (n.y - r.y) - r.x * n.y + n.x * r.y + (r.x - n.x) * e.y;
|
|
629
|
+
if (Math.abs(g) < 1e-3) {
|
|
630
630
|
s.restore();
|
|
631
631
|
return;
|
|
632
632
|
}
|
|
633
|
-
const
|
|
634
|
-
s.transform(
|
|
633
|
+
const p = -(e.y * (c.x - o.x) - r.y * c.x + n.y * o.x + (r.y - n.y) * u.x) / g, x = (r.y * c.y + e.y * (o.y - c.y) - n.y * o.y + (n.y - r.y) * u.y) / g, A = (e.x * (c.x - o.x) - r.x * c.x + n.x * o.x + (r.x - n.x) * u.x) / g, D = -(r.x * c.y + e.x * (o.y - c.y) - n.x * o.y + (n.x - r.x) * u.y) / g, W = (e.x * (n.y * o.x - r.y * c.x) + e.y * (r.x * c.x - n.x * o.x) + (n.x * r.y - r.x * n.y) * u.x) / g, B = (e.x * (n.y * o.y - r.y * c.y) + e.y * (r.x * c.y - n.x * o.y) + (n.x * r.y - r.x * n.y) * u.y) / g;
|
|
634
|
+
s.transform(p, x, A, D, W, B), s.drawImage(t, 0, 0), s.restore();
|
|
635
635
|
}
|
|
636
636
|
self.onmessage = async (s) => {
|
|
637
637
|
if (s.data?.type === "SET_DEBUG") {
|
|
@@ -661,46 +661,46 @@ self.onmessage = async (s) => {
|
|
|
661
661
|
});
|
|
662
662
|
return;
|
|
663
663
|
}
|
|
664
|
-
const o = performance.now(),
|
|
665
|
-
if (
|
|
664
|
+
const o = performance.now(), c = (/* @__PURE__ */ new Date()).toISOString();
|
|
665
|
+
if (L(`[deform worker] ⏰ 开始 id=${e} 时间=${c}`, {
|
|
666
666
|
designBitmap: { width: r.width, height: r.height },
|
|
667
667
|
size: n.size,
|
|
668
668
|
bounds: n.bounds,
|
|
669
669
|
canvasSize: u
|
|
670
670
|
}), !E || !E.isReady())
|
|
671
|
-
if (
|
|
671
|
+
if (b || self.LICENSE_TOKEN)
|
|
672
672
|
try {
|
|
673
|
-
if (
|
|
673
|
+
if (R && M && await M, (!E || !E.isReady()) && await G(), !E || !E.isReady())
|
|
674
674
|
throw new Error("WASM 模块仍未就绪");
|
|
675
675
|
} catch (a) {
|
|
676
|
-
const
|
|
676
|
+
const i = performance.now() - o;
|
|
677
677
|
self.postMessage({
|
|
678
678
|
id: e,
|
|
679
679
|
error: `WASM 初始化失败: ${a.message}`,
|
|
680
|
-
duration:
|
|
680
|
+
duration: i
|
|
681
681
|
});
|
|
682
682
|
return;
|
|
683
683
|
}
|
|
684
684
|
else {
|
|
685
685
|
let a = 0;
|
|
686
|
-
const
|
|
687
|
-
let
|
|
688
|
-
for (; a <
|
|
689
|
-
await new Promise((
|
|
690
|
-
if (
|
|
686
|
+
const l = 500, i = 50;
|
|
687
|
+
let h = null;
|
|
688
|
+
for (; a < l && !h; )
|
|
689
|
+
await new Promise((f) => setTimeout(f, i)), a += i, h = b || self.LICENSE_TOKEN;
|
|
690
|
+
if (h)
|
|
691
691
|
try {
|
|
692
|
-
if (
|
|
692
|
+
if (b = h, O = O || self.LICENSE_API_URL, $ = $ || self.DEVICE_ID, U = U || self.DOMAIN, R && M ? await M : E || await G(), !E || !E.isReady())
|
|
693
693
|
throw new Error("WASM 模块未就绪");
|
|
694
|
-
} catch (
|
|
694
|
+
} catch (f) {
|
|
695
695
|
const y = performance.now() - o;
|
|
696
696
|
self.postMessage({
|
|
697
697
|
id: e,
|
|
698
|
-
error: `WASM 初始化失败: ${
|
|
698
|
+
error: `WASM 初始化失败: ${f.message}`,
|
|
699
699
|
duration: y
|
|
700
700
|
});
|
|
701
701
|
return;
|
|
702
702
|
}
|
|
703
|
-
else if (!
|
|
703
|
+
else if (!h) {
|
|
704
704
|
const d = performance.now() - o;
|
|
705
705
|
self.postMessage({
|
|
706
706
|
id: e,
|
|
@@ -722,39 +722,39 @@ self.onmessage = async (s) => {
|
|
|
722
722
|
return;
|
|
723
723
|
}
|
|
724
724
|
const a = oe(n, u);
|
|
725
|
-
let
|
|
725
|
+
let l, i;
|
|
726
726
|
if (u && u.width > 0 && u.height > 0)
|
|
727
|
-
|
|
727
|
+
l = u.width, i = u.height;
|
|
728
728
|
else {
|
|
729
|
-
const
|
|
729
|
+
const x = n.size || n.placedLayer || {
|
|
730
730
|
width: w.width,
|
|
731
731
|
height: w.height
|
|
732
732
|
};
|
|
733
|
-
|
|
733
|
+
l = x.width, i = x.height;
|
|
734
734
|
}
|
|
735
|
-
const
|
|
736
|
-
if (!
|
|
735
|
+
const h = new OffscreenCanvas(l, i), f = h.getContext("2d");
|
|
736
|
+
if (!f) {
|
|
737
737
|
const A = performance.now() - o;
|
|
738
738
|
self.postMessage({ id: e, error: "Canvas context unavailable", duration: A });
|
|
739
739
|
return;
|
|
740
740
|
}
|
|
741
|
-
const d = ce(
|
|
742
|
-
|
|
743
|
-
`[deform worker] ✅ 结束 id=${e} 时间=${
|
|
741
|
+
const d = ce(f, r, a), y = h.transferToImageBitmap(), F = performance.now() - o, g = (/* @__PURE__ */ new Date()).toISOString();
|
|
742
|
+
L(
|
|
743
|
+
`[deform worker] ✅ 结束 id=${e} 时间=${g} 耗时=${Math.round(F)}ms 变形方法=${d}`,
|
|
744
744
|
{
|
|
745
745
|
width: y.width,
|
|
746
746
|
height: y.height
|
|
747
747
|
}
|
|
748
748
|
), r.close();
|
|
749
|
-
const
|
|
750
|
-
{ id: e, imageBitmap: y, duration:
|
|
749
|
+
const p = ie(
|
|
750
|
+
{ id: e, imageBitmap: y, duration: F }
|
|
751
751
|
);
|
|
752
752
|
self.postMessage(
|
|
753
|
-
|
|
754
|
-
|
|
753
|
+
p,
|
|
754
|
+
p.imageBitmap ? [p.imageBitmap] : []
|
|
755
755
|
);
|
|
756
756
|
} catch (w) {
|
|
757
|
-
const
|
|
758
|
-
(/* @__PURE__ */ new Date()).toISOString(), self.postMessage({ id: e, error:
|
|
757
|
+
const l = performance.now() - o, i = w instanceof Error ? w.message : String(w);
|
|
758
|
+
(/* @__PURE__ */ new Date()).toISOString(), self.postMessage({ id: e, error: i, duration: l });
|
|
759
759
|
}
|
|
760
760
|
};
|