@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.
- package/README.md +1 -1
- package/dist/deform.worker.js +163 -162
- package/dist/editor-sdk.es.js +5514 -5464
- package/dist/renderWorker.js +1127 -1127
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/assets/index-CtWAvVMB.js +0 -23
- package/dist/assets/index-DWe74PDt.js +0 -12
package/dist/deform.worker.js
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
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
|
|
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
|
-
},
|
|
39
|
-
await this.loadWasmExec(
|
|
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 (
|
|
51
|
-
throw this.wasmReady = !1,
|
|
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,
|
|
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((
|
|
66
|
-
if (!
|
|
67
|
-
throw new Error(`HTTP ${
|
|
68
|
-
const
|
|
69
|
-
return !
|
|
70
|
-
}).then((
|
|
71
|
-
if (
|
|
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
|
|
75
|
-
new Function("self",
|
|
76
|
-
} catch (
|
|
77
|
-
|
|
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((
|
|
80
|
-
|
|
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
|
|
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:
|
|
100
|
-
domain:
|
|
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 (
|
|
112
|
-
throw
|
|
112
|
+
} catch (r) {
|
|
113
|
+
throw r;
|
|
113
114
|
}
|
|
114
115
|
else
|
|
115
116
|
try {
|
|
116
|
-
const
|
|
117
|
-
return
|
|
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,
|
|
170
|
+
applyPerspective(t, e, r) {
|
|
170
171
|
if (!this.wasmReady)
|
|
171
172
|
throw new Error("WASM 未加载");
|
|
172
173
|
try {
|
|
173
|
-
const
|
|
174
|
-
if (!
|
|
175
|
-
throw new Error(
|
|
176
|
-
return { x:
|
|
177
|
-
} catch (
|
|
178
|
-
throw
|
|
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,
|
|
185
|
+
applyInversePerspective(t, e, r) {
|
|
185
186
|
if (!this.wasmReady)
|
|
186
187
|
throw new Error("WASM 未加载");
|
|
187
188
|
try {
|
|
188
|
-
const
|
|
189
|
-
if (!
|
|
190
|
-
throw new Error(
|
|
191
|
-
return { x:
|
|
192
|
-
} catch (
|
|
193
|
-
throw
|
|
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,
|
|
200
|
+
transformPoints(t, e, r = !1) {
|
|
200
201
|
if (!this.wasmReady)
|
|
201
202
|
throw new Error("WASM 未加载");
|
|
202
203
|
try {
|
|
203
|
-
const
|
|
204
|
+
const n = this.call(
|
|
204
205
|
"wasmTransformPoints",
|
|
205
206
|
JSON.stringify(t),
|
|
206
207
|
JSON.stringify(e),
|
|
207
|
-
|
|
208
|
+
r
|
|
208
209
|
);
|
|
209
|
-
if (!
|
|
210
|
-
throw new Error(
|
|
211
|
-
return JSON.parse(
|
|
212
|
-
} catch (
|
|
213
|
-
throw
|
|
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,
|
|
226
|
+
getBicubicPoint(t, e, r) {
|
|
226
227
|
if (!this.wasmReady)
|
|
227
228
|
throw new Error("WASM 未加载");
|
|
228
|
-
if (
|
|
229
|
+
if (r.length !== 16)
|
|
229
230
|
throw new Error("需要恰好 16 个点");
|
|
230
231
|
try {
|
|
231
|
-
const
|
|
232
|
-
if (!
|
|
233
|
-
throw new Error(
|
|
234
|
-
return { x:
|
|
235
|
-
} catch (
|
|
236
|
-
throw
|
|
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,
|
|
243
|
+
getBilinearPoint(t, e, r) {
|
|
243
244
|
if (!this.wasmReady)
|
|
244
245
|
throw new Error("WASM 未加载");
|
|
245
|
-
if (
|
|
246
|
+
if (r.length !== 4)
|
|
246
247
|
throw new Error("需要恰好 4 个点");
|
|
247
248
|
try {
|
|
248
|
-
const
|
|
249
|
-
if (!
|
|
250
|
-
throw new Error(
|
|
251
|
-
return { x:
|
|
252
|
-
} catch (
|
|
253
|
-
throw
|
|
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,
|
|
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(
|
|
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
|
|
282
|
+
const r = this.call(
|
|
282
283
|
"wasmBatchBicubicInterpolation",
|
|
283
284
|
JSON.stringify(t),
|
|
284
285
|
JSON.stringify(e)
|
|
285
286
|
);
|
|
286
|
-
if (!
|
|
287
|
-
throw new Error(
|
|
288
|
-
return
|
|
289
|
-
} catch (
|
|
290
|
-
throw
|
|
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
|
|
303
|
+
const r = this.call(
|
|
303
304
|
"wasmBatchBilinearInterpolation",
|
|
304
305
|
JSON.stringify(t),
|
|
305
306
|
JSON.stringify(e)
|
|
306
307
|
);
|
|
307
|
-
if (!
|
|
308
|
-
throw new Error(
|
|
309
|
-
return
|
|
310
|
-
} catch (
|
|
311
|
-
throw
|
|
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,
|
|
318
|
+
batchArbitraryMeshInterpolation(t, e, r) {
|
|
318
319
|
if (!this.wasmReady)
|
|
319
320
|
throw new Error("WASM 未加载");
|
|
320
321
|
try {
|
|
321
|
-
const
|
|
322
|
+
const n = this.call(
|
|
322
323
|
"wasmBatchArbitraryMeshInterpolation",
|
|
323
324
|
JSON.stringify(t),
|
|
324
325
|
JSON.stringify(e),
|
|
325
|
-
|
|
326
|
+
r
|
|
326
327
|
);
|
|
327
|
-
if (!
|
|
328
|
-
throw new Error(
|
|
329
|
-
return
|
|
330
|
-
} catch (
|
|
331
|
-
throw
|
|
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
|
|
341
|
-
if (!
|
|
341
|
+
const n = (typeof self < "u" ? self : globalThis)[t];
|
|
342
|
+
if (!n)
|
|
342
343
|
throw new Error(`函数不存在: ${t}`);
|
|
343
344
|
try {
|
|
344
|
-
return
|
|
345
|
+
return n(...e);
|
|
345
346
|
} catch (o) {
|
|
346
347
|
throw o;
|
|
347
348
|
}
|
|
348
349
|
}
|
|
349
350
|
};
|
|
350
|
-
|
|
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"),
|
|
384
|
-
await d.load(e,
|
|
385
|
-
const
|
|
386
|
-
if (!
|
|
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(
|
|
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
|
|
407
|
+
const r = s.size || s.placedLayer || {
|
|
407
408
|
width: e.width,
|
|
408
409
|
height: e.height
|
|
409
|
-
},
|
|
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) *
|
|
412
|
+
(s.transform[0] - e.left) * n,
|
|
412
413
|
(s.transform[1] - e.top) * o,
|
|
413
|
-
(s.transform[2] - e.left) *
|
|
414
|
+
(s.transform[2] - e.left) * n,
|
|
414
415
|
(s.transform[3] - e.top) * o,
|
|
415
|
-
(s.transform[4] - e.left) *
|
|
416
|
+
(s.transform[4] - e.left) * n,
|
|
416
417
|
(s.transform[5] - e.top) * o,
|
|
417
|
-
(s.transform[6] - e.left) *
|
|
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
|
|
428
|
-
if (!
|
|
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,
|
|
444
|
-
if (!
|
|
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 =
|
|
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 },
|
|
456
|
-
j(s, t, S,
|
|
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,
|
|
460
|
-
let
|
|
461
|
-
|
|
462
|
-
|
|
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 -
|
|
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 =
|
|
470
|
-
const h = (a.x -
|
|
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,
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
|
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 =
|
|
499
|
-
le(s, t,
|
|
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,
|
|
503
|
-
const
|
|
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
|
-
|
|
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 =
|
|
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,
|
|
511
|
-
}), h = Math.floor(Math.sqrt(
|
|
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,
|
|
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 =
|
|
519
|
-
j(s, t, p, S,
|
|
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,
|
|
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
|
-
|
|
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
|
|
542
|
-
let
|
|
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
|
-
|
|
547
|
+
r += e[o * 4 + u].x * i, n += e[o * 4 + u].y * i;
|
|
547
548
|
}
|
|
548
|
-
return { x:
|
|
549
|
+
return { x: r, y: n };
|
|
549
550
|
}
|
|
550
551
|
function N(s, t, e) {
|
|
551
|
-
const
|
|
552
|
-
return { x:
|
|
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
|
|
555
|
-
const
|
|
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 >=
|
|
558
|
-
const c = o - i, l = u - w, a = e[w *
|
|
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 (
|
|
585
|
-
throw new Error(`WASM 应用逆透视变换失败: ${
|
|
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 (
|
|
594
|
-
throw new Error(`WASM 应用透视变换失败: ${
|
|
594
|
+
} catch (r) {
|
|
595
|
+
throw new Error(`WASM 应用透视变换失败: ${r}`);
|
|
595
596
|
}
|
|
596
597
|
}
|
|
597
|
-
function j(s, t, e,
|
|
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 * (
|
|
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) -
|
|
607
|
-
s.transform(p, S,
|
|
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:
|
|
615
|
-
if (!
|
|
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 (!
|
|
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 =
|
|
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(
|
|
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 =
|
|
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,
|
|
706
|
-
|
|
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
|
);
|