@jieyin/editor-sdk-test 1.1.242 → 1.1.244

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,9 +1,7 @@
1
- class $ {
2
- static instance;
3
- wasmReady = !1;
4
- go = null;
5
- wasmModule = null;
1
+ var te = Object.defineProperty, re = (s, t, e) => t in s ? te(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, z = (s, t, e) => re(s, typeof t != "symbol" ? t + "" : t, e);
2
+ const Z = class P {
6
3
  constructor() {
4
+ z(this, "wasmReady", !1), z(this, "go", null), z(this, "wasmModule", null);
7
5
  }
8
6
  isDebugEnabled() {
9
7
  try {
@@ -12,135 +10,135 @@ class $ {
12
10
  }
13
11
  return !1;
14
12
  }
15
- debugLog(...r) {
16
- this.isDebugEnabled() && console.log(...r);
13
+ debugLog(...t) {
14
+ this.isDebugEnabled();
17
15
  }
18
- debugWarn(...r) {
19
- this.isDebugEnabled() && console.warn(...r);
16
+ debugWarn(...t) {
17
+ this.isDebugEnabled();
20
18
  }
21
19
  static getInstance() {
22
- return $.instance || ($.instance = new $()), $.instance;
20
+ return P.instance || (P.instance = new P()), P.instance;
23
21
  }
24
22
  /**
25
23
  * 在 Worker 环境中加载 WASM 模块
26
24
  * @param wasmUrl WASM 文件路径
27
25
  * @param wasmExecUrl wasm_exec.js 路径
28
26
  */
29
- async load(r, e) {
27
+ async load(t, e) {
30
28
  if (this.wasmReady) {
31
29
  this.debugLog("✅ WASM 已加载,跳过重复加载");
32
30
  return;
33
31
  }
34
32
  try {
35
33
  this.debugLog("🚀 Worker: 加载透视变换 WASM...");
36
- const t = (c) => {
37
- if (e && c === "wasm_exec.js")
34
+ const r = (i) => {
35
+ if (e && i === "wasm_exec.js")
38
36
  return e;
39
- if (r && c === "perspective.wasm")
40
- return r;
37
+ if (t && i === "perspective.wasm")
38
+ return t;
41
39
  try {
42
- let f = null;
43
- 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;
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;
45
43
  if (d.includes("/js/")) {
46
- const m = "../assets/" + c, y = new URL(m, u);
47
- return this.debugLog(`🔍 [WASM] 计算路径: ${c} -> ${y.pathname} (Worker: ${d})`), y.pathname;
44
+ const y = "../assets/" + i, m = new URL(y, f);
45
+ return this.debugLog(`🔍 [WASM] 计算路径: ${i} -> ${m.pathname} (Worker: ${d})`), m.pathname;
48
46
  } else if (d.includes("/assets/")) {
49
- const m = "./" + c, y = new URL(m, u);
50
- return this.debugLog(`🔍 [WASM] 计算路径: ${c} -> ${y.pathname} (Worker: ${d})`), y.pathname;
47
+ const y = "./" + i, m = new URL(y, f);
48
+ return this.debugLog(`🔍 [WASM] 计算路径: ${i} -> ${m.pathname} (Worker: ${d})`), m.pathname;
51
49
  } else
52
- return this.debugLog(`🔍 [WASM] 使用默认绝对路径: /assets/${c}`), "/assets/" + c;
50
+ return this.debugLog(`🔍 [WASM] 使用默认绝对路径: /assets/${i}`), "/assets/" + i;
53
51
  }
54
- } catch (f) {
55
- this.debugWarn("⚠️ 无法计算 WASM 相对路径,使用默认路径:", f);
52
+ } catch (h) {
53
+ this.debugWarn("⚠️ 无法计算 WASM 相对路径,使用默认路径:", h);
56
54
  }
57
- return "/assets/" + c;
58
- }, n = e || t("wasm_exec.js"), s = r || t("perspective.wasm");
59
- this.debugLog("🔍 [WASM] 最终使用的路径:", { execUrl: n, moduleUrl: s }), await this.loadWasmExec(n);
60
- const i = typeof self < "u" ? self : globalThis;
61
- this.go = new i.Go();
62
- const a = await fetch(s);
63
- if (!a.ok)
64
- throw new Error(`无法加载 WASM 文件: ${a.status}`);
65
- const w = await a.arrayBuffer(), l = await WebAssembly.instantiate(w, this.go.importObject);
66
- this.wasmModule = l.instance, this.go.run(this.wasmModule), this.wasmReady = !0;
67
- const h = this.call("wasmInit");
68
- if (h && h.success)
69
- this.debugLog("✅ Worker WASM 加载成功:", h);
55
+ return "/assets/" + i;
56
+ }, n = e || r("wasm_exec.js"), u = t || r("perspective.wasm");
57
+ this.debugLog("🔍 [WASM] 最终使用的路径:", { execUrl: n, moduleUrl: u }), await this.loadWasmExec(n);
58
+ const o = typeof self < "u" ? self : globalThis;
59
+ this.go = new o.Go();
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
+ this.wasmModule = a.instance, this.go.run(this.wasmModule), this.wasmReady = !0;
65
+ const l = this.call("wasmInit");
66
+ if (l && l.success)
67
+ this.debugLog("✅ Worker WASM 加载成功:", l);
70
68
  else
71
69
  throw new Error("WASM 初始化失败");
72
- } catch (t) {
73
- throw console.error("❌ Worker WASM 加载失败:", t), this.wasmReady = !1, t;
70
+ } catch (r) {
71
+ throw this.wasmReady = !1, r;
74
72
  }
75
73
  }
76
74
  /**
77
75
  * 在 Worker 中加载 wasm_exec.js
78
76
  * Module Worker 不支持 importScripts(),仅 Classic Worker 可尝试 importScripts,否则用 fetch + eval
79
77
  */
80
- async loadWasmExec(r) {
81
- return new Promise((e, t) => {
78
+ async loadWasmExec(t) {
79
+ return new Promise((e, r) => {
82
80
  if (!(typeof import.meta < "u" && import.meta.url) && typeof self.importScripts == "function")
83
81
  try {
84
- self.importScripts(r), e();
82
+ self.importScripts(t), e();
85
83
  return;
86
- } catch (s) {
87
- this.debugWarn("⚠️ importScripts 失败,使用 fetch:", s);
84
+ } catch (u) {
85
+ this.debugWarn("⚠️ importScripts 失败,使用 fetch:", u);
88
86
  }
89
- fetch(r).then((s) => {
90
- if (!s.ok)
91
- throw new Error(`HTTP ${s.status}: ${s.statusText} - URL: ${r}`);
92
- const i = s.headers.get("content-type") || "";
93
- return !i.includes("javascript") && !i.includes("text/plain") && this.debugWarn("⚠️ [WASM] 响应 Content-Type 不是 JavaScript:", i), s.text();
94
- }).then((s) => {
95
- if (s.trim().startsWith("<!DOCTYPE") || s.trim().startsWith("<html"))
96
- throw console.error("❌ [WASM] 返回的是 HTML 而不是 JavaScript,可能是 404 错误"), console.error("❌ [WASM] URL:", r), console.error("❌ [WASM] 响应前100字符:", s.substring(0, 100)), new Error(`返回的是 HTML 而不是 JavaScript,可能是 404 错误。URL: ${r}`);
87
+ fetch(t).then((u) => {
88
+ if (!u.ok)
89
+ throw new Error(`HTTP ${u.status}: ${u.statusText} - URL: ${t}`);
90
+ const o = u.headers.get("content-type") || "";
91
+ return !o.includes("javascript") && !o.includes("text/plain") && this.debugWarn("⚠️ [WASM] 响应 Content-Type 不是 JavaScript:", o), u.text();
92
+ }).then((u) => {
93
+ if (u.trim().startsWith("<!DOCTYPE") || u.trim().startsWith("<html"))
94
+ throw new Error(`返回的是 HTML 而不是 JavaScript,可能是 404 错误。URL: ${t}`);
97
95
  try {
98
- const i = typeof self < "u" ? self : globalThis;
99
- new Function("self", s)(i), e();
100
- } catch (i) {
101
- t(new Error(`执行 wasm_exec.js 失败: ${i}`));
96
+ const o = typeof self < "u" ? self : globalThis;
97
+ new Function("self", u)(o), e();
98
+ } catch (o) {
99
+ r(new Error(`执行 wasm_exec.js 失败: ${o}`));
102
100
  }
103
- }).catch((s) => {
104
- console.error("❌ [WASM] 加载 wasm_exec.js 失败:", { url: r, error: s.message }), t(s);
101
+ }).catch((u) => {
102
+ r(u);
105
103
  });
106
104
  });
107
105
  }
108
106
  /**
109
107
  * 验证授权(通过 API)
110
108
  */
111
- async verifyLicense(r, e) {
109
+ async verifyLicense(t, e) {
112
110
  if (!this.wasmReady)
113
111
  return !1;
114
112
  if (e)
115
113
  try {
116
- const t = this.getDeviceID(), n = this.getDomain(), i = await (await fetch(`${e}/jet_license/interface/license/verify`, {
114
+ const r = this.getDeviceID(), n = this.getDomain(), o = await (await fetch(`${e}/jet_license/interface/license/verify`, {
117
115
  method: "POST",
118
116
  headers: {
119
117
  "Content-Type": "application/json"
120
118
  },
121
119
  body: JSON.stringify({
122
- token: r,
123
- deviceId: t,
120
+ token: t,
121
+ deviceId: r,
124
122
  domain: n
125
123
  })
126
124
  })).json();
127
- if (!i.success || !i.valid) {
128
- const w = i.error || "License 验证失败";
125
+ if (!o.success || !o.valid) {
126
+ const w = o.error || "License 验证失败";
129
127
  throw new Error(w);
130
128
  }
131
- const a = this.call("wasmVerifyLicense", r);
132
- if (!a.success || a.valid !== !0)
129
+ const c = this.call("wasmVerifyLicense", t);
130
+ if (!c.success || c.valid !== !0)
133
131
  throw new Error("WASM 验证失败");
134
132
  return !0;
135
- } catch (t) {
136
- throw console.error("License API 验证失败:", t), t;
133
+ } catch (r) {
134
+ throw r;
137
135
  }
138
136
  else
139
137
  try {
140
- const t = this.call("wasmVerifyLicense", r);
141
- return t.success && t.valid === !0;
142
- } catch (t) {
143
- return console.error("License 验证失败:", t), !1;
138
+ const r = this.call("wasmVerifyLicense", t);
139
+ return r.success && r.valid === !0;
140
+ } catch {
141
+ return !1;
144
142
  }
145
143
  }
146
144
  /**
@@ -158,83 +156,83 @@ class $ {
158
156
  /**
159
157
  * 计算透视变换矩阵
160
158
  */
161
- calcPerspectiveMatrix(r) {
159
+ calcPerspectiveMatrix(t) {
162
160
  if (!this.wasmReady)
163
161
  throw new Error("WASM 未加载");
164
- if (r.length !== 4)
162
+ if (t.length !== 4)
165
163
  throw new Error("需要恰好 4 个点");
166
164
  try {
167
- const e = this.call("wasmCalcPerspectiveMatrix", JSON.stringify(r));
165
+ const e = this.call("wasmCalcPerspectiveMatrix", JSON.stringify(t));
168
166
  if (!e.success)
169
167
  throw new Error(e.error || "计算失败");
170
168
  return e.matrix;
171
169
  } catch (e) {
172
- throw console.error("计算透视矩阵失败:", e), e;
170
+ throw e;
173
171
  }
174
172
  }
175
173
  /**
176
174
  * 矩阵求逆
177
175
  */
178
- invertMatrix(r) {
176
+ invertMatrix(t) {
179
177
  if (!this.wasmReady)
180
178
  throw new Error("WASM 未加载");
181
179
  try {
182
- const e = this.call("wasmInvertMatrix", JSON.stringify(r));
180
+ const e = this.call("wasmInvertMatrix", JSON.stringify(t));
183
181
  if (!e.success)
184
182
  throw new Error(e.error || "矩阵求逆失败");
185
183
  return e.matrix;
186
184
  } catch (e) {
187
- throw console.error("矩阵求逆失败:", e), e;
185
+ throw e;
188
186
  }
189
187
  }
190
188
  /**
191
189
  * 应用透视变换到单个点
192
190
  */
193
- applyPerspective(r, e, t) {
191
+ applyPerspective(t, e, r) {
194
192
  if (!this.wasmReady)
195
193
  throw new Error("WASM 未加载");
196
194
  try {
197
- const n = this.call("wasmApplyPerspective", r, e, JSON.stringify(t));
195
+ const n = this.call("wasmApplyPerspective", t, e, JSON.stringify(r));
198
196
  if (!n.success)
199
197
  throw new Error(n.error || "变换失败");
200
198
  return { x: n.x, y: n.y };
201
199
  } catch (n) {
202
- throw console.error("应用透视变换失败:", n), n;
200
+ throw n;
203
201
  }
204
202
  }
205
203
  /**
206
204
  * 应用逆透视变换到单个点
207
205
  */
208
- applyInversePerspective(r, e, t) {
206
+ applyInversePerspective(t, e, r) {
209
207
  if (!this.wasmReady)
210
208
  throw new Error("WASM 未加载");
211
209
  try {
212
- const n = this.call("wasmApplyInversePerspective", r, e, JSON.stringify(t));
210
+ const n = this.call("wasmApplyInversePerspective", t, e, JSON.stringify(r));
213
211
  if (!n.success)
214
212
  throw new Error(n.error || "逆变换失败");
215
213
  return { x: n.x, y: n.y };
216
214
  } catch (n) {
217
- throw console.error("应用逆透视变换失败:", n), n;
215
+ throw n;
218
216
  }
219
217
  }
220
218
  /**
221
219
  * 批量变换点(高性能)
222
220
  */
223
- transformPoints(r, e, t = !1) {
221
+ transformPoints(t, e, r = !1) {
224
222
  if (!this.wasmReady)
225
223
  throw new Error("WASM 未加载");
226
224
  try {
227
225
  const n = this.call(
228
226
  "wasmTransformPoints",
229
- JSON.stringify(r),
227
+ JSON.stringify(t),
230
228
  JSON.stringify(e),
231
- t
229
+ r
232
230
  );
233
231
  if (!n.success)
234
232
  throw new Error(n.error || "批量变换失败");
235
233
  return JSON.parse(n.points);
236
234
  } catch (n) {
237
- throw console.error("批量变换失败:", n), n;
235
+ throw n;
238
236
  }
239
237
  }
240
238
  /**
@@ -246,412 +244,407 @@ class $ {
246
244
  /**
247
245
  * 双三次插值点计算
248
246
  */
249
- getBicubicPoint(r, e, t) {
247
+ getBicubicPoint(t, e, r) {
250
248
  if (!this.wasmReady)
251
249
  throw new Error("WASM 未加载");
252
- if (t.length !== 16)
250
+ if (r.length !== 16)
253
251
  throw new Error("需要恰好 16 个点");
254
252
  try {
255
- const n = this.call("wasmGetBicubicPoint", r, e, JSON.stringify(t));
253
+ const n = this.call("wasmGetBicubicPoint", t, e, JSON.stringify(r));
256
254
  if (!n.success)
257
255
  throw new Error(n.error || "计算失败");
258
256
  return { x: n.x, y: n.y };
259
257
  } catch (n) {
260
- throw console.error("双三次插值计算失败:", n), n;
258
+ throw n;
261
259
  }
262
260
  }
263
261
  /**
264
262
  * 双线性插值点计算
265
263
  */
266
- getBilinearPoint(r, e, t) {
264
+ getBilinearPoint(t, e, r) {
267
265
  if (!this.wasmReady)
268
266
  throw new Error("WASM 未加载");
269
- if (t.length !== 4)
267
+ if (r.length !== 4)
270
268
  throw new Error("需要恰好 4 个点");
271
269
  try {
272
- const n = this.call("wasmGetBilinearPoint", r, e, JSON.stringify(t));
270
+ const n = this.call("wasmGetBilinearPoint", t, e, JSON.stringify(r));
273
271
  if (!n.success)
274
272
  throw new Error(n.error || "计算失败");
275
273
  return { x: n.x, y: n.y };
276
274
  } catch (n) {
277
- throw console.error("双线性插值计算失败:", n), n;
275
+ throw n;
278
276
  }
279
277
  }
280
278
  /**
281
279
  * 任意网格点插值计算
282
280
  */
283
- getArbitraryMeshPoint(r, e, t, n) {
281
+ getArbitraryMeshPoint(t, e, r, n) {
284
282
  if (!this.wasmReady)
285
283
  throw new Error("WASM 未加载");
286
284
  try {
287
- const s = this.call("wasmGetArbitraryMeshPoint", r, e, JSON.stringify(t), n);
288
- if (!s.success)
289
- throw new Error(s.error || "计算失败");
290
- return { x: s.x, y: s.y };
291
- } catch (s) {
292
- throw console.error("任意网格点插值计算失败:", s), s;
285
+ const u = this.call("wasmGetArbitraryMeshPoint", t, e, JSON.stringify(r), n);
286
+ if (!u.success)
287
+ throw new Error(u.error || "计算失败");
288
+ return { x: u.x, y: u.y };
289
+ } catch (u) {
290
+ throw u;
293
291
  }
294
292
  }
295
293
  /**
296
294
  * 批量双三次插值(高性能优化)
297
295
  * 一次性处理多个坐标,避免频繁的 JS/WASM 边界调用
298
296
  */
299
- batchBicubicInterpolation(r, e) {
297
+ batchBicubicInterpolation(t, e) {
300
298
  if (!this.wasmReady)
301
299
  throw new Error("WASM 未加载");
302
300
  if (e.length !== 16)
303
301
  throw new Error("需要恰好 16 个控制点");
304
302
  try {
305
- const t = this.call(
303
+ const r = this.call(
306
304
  "wasmBatchBicubicInterpolation",
307
- JSON.stringify(r),
305
+ JSON.stringify(t),
308
306
  JSON.stringify(e)
309
307
  );
310
- if (!t.success)
311
- throw new Error(t.error || "批量双三次插值失败");
312
- return t.points;
313
- } catch (t) {
314
- throw console.error("批量双三次插值失败:", t), t;
308
+ if (!r.success)
309
+ throw new Error(r.error || "批量双三次插值失败");
310
+ return r.points;
311
+ } catch (r) {
312
+ throw r;
315
313
  }
316
314
  }
317
315
  /**
318
316
  * 批量双线性插值(高性能优化)
319
317
  */
320
- batchBilinearInterpolation(r, e) {
318
+ batchBilinearInterpolation(t, e) {
321
319
  if (!this.wasmReady)
322
320
  throw new Error("WASM 未加载");
323
321
  if (e.length !== 4)
324
322
  throw new Error("需要恰好 4 个控制点");
325
323
  try {
326
- const t = this.call(
324
+ const r = this.call(
327
325
  "wasmBatchBilinearInterpolation",
328
- JSON.stringify(r),
326
+ JSON.stringify(t),
329
327
  JSON.stringify(e)
330
328
  );
331
- if (!t.success)
332
- throw new Error(t.error || "批量双线性插值失败");
333
- return t.points;
334
- } catch (t) {
335
- throw console.error("批量双线性插值失败:", t), t;
329
+ if (!r.success)
330
+ throw new Error(r.error || "批量双线性插值失败");
331
+ return r.points;
332
+ } catch (r) {
333
+ throw r;
336
334
  }
337
335
  }
338
336
  /**
339
337
  * 批量任意网格插值(高性能优化)
340
338
  */
341
- batchArbitraryMeshInterpolation(r, e, t) {
339
+ batchArbitraryMeshInterpolation(t, e, r) {
342
340
  if (!this.wasmReady)
343
341
  throw new Error("WASM 未加载");
344
342
  try {
345
343
  const n = this.call(
346
344
  "wasmBatchArbitraryMeshInterpolation",
347
- JSON.stringify(r),
345
+ JSON.stringify(t),
348
346
  JSON.stringify(e),
349
- t
347
+ r
350
348
  );
351
349
  if (!n.success)
352
350
  throw new Error(n.error || "批量网格插值失败");
353
351
  return n.points;
354
352
  } catch (n) {
355
- throw console.error("批量网格插值失败:", n), n;
353
+ throw n;
356
354
  }
357
355
  }
358
356
  /**
359
357
  * 调用 WASM 函数
360
358
  */
361
- call(r, ...e) {
359
+ call(t, ...e) {
362
360
  if (!this.wasmReady)
363
361
  throw new Error("WASM 未加载");
364
- const n = (typeof self < "u" ? self : globalThis)[r];
362
+ const n = (typeof self < "u" ? self : globalThis)[t];
365
363
  if (!n)
366
- throw new Error(`函数不存在: ${r}`);
364
+ throw new Error(`函数不存在: ${t}`);
367
365
  try {
368
366
  return n(...e);
369
- } catch (s) {
370
- throw console.error(`调用 ${r} 失败:`, s), s;
367
+ } catch (u) {
368
+ throw u;
371
369
  }
372
370
  }
373
- }
374
- let V = !1;
375
- const A = (...o) => {
376
- V && console.log(...o);
377
- }, Z = (...o) => {
378
- V && console.warn(...o);
379
371
  };
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(() => {
383
- A("✅ [deform.worker] WASM 初始化完成");
384
- }).catch((r) => {
385
- Z("⚠️ [deform.worker] WASM 初始化失败:", r);
372
+ z(Z, "instance");
373
+ let ne = Z, H = !1;
374
+ const L = (...s) => {
375
+ }, se = (...s) => {
376
+ };
377
+ let E = null, R = !1, M = null, b = null, O = null, $ = null, U = null;
378
+ function ue(s) {
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
+ }).catch((t) => {
386
381
  }));
387
382
  }
388
- async function Y() {
389
- return g ? void 0 : N ? b || Promise.resolve() : k || self.LICENSE_TOKEN ? (N = !0, b = (async () => {
383
+ async function G() {
384
+ return E ? void 0 : R ? M || Promise.resolve() : b || self.LICENSE_TOKEN ? (R = !0, M = (async () => {
390
385
  try {
391
- g = $.getInstance();
392
- const r = (l) => {
393
- const h = self.WASM_URL, c = self.WASM_EXEC_URL;
394
- if (l === "perspective.wasm" && h)
395
- return h;
396
- if (l === "wasm_exec.js" && c)
397
- return c;
386
+ E = ne.getInstance();
387
+ const t = (a) => {
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;
398
393
  try {
399
- let f = null;
400
- 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;
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;
402
397
  if (d.includes("/js/")) {
403
- const m = "../assets/" + l, y = new URL(m, u);
404
- return A(`🔍 [deform.worker] 计算路径: ${l} -> ${y.pathname} (Worker: ${d})`), y.pathname;
398
+ const y = "../assets/" + a, m = new URL(y, f);
399
+ return L(`🔍 [deform.worker] 计算路径: ${a} -> ${m.pathname} (Worker: ${d})`), m.pathname;
405
400
  } else if (d.includes("/assets/")) {
406
- const m = "./" + l, y = new URL(m, u);
407
- return A(`🔍 [deform.worker] 计算路径: ${l} -> ${y.pathname} (Worker: ${d})`), y.pathname;
401
+ const y = "./" + a, m = new URL(y, f);
402
+ return L(`🔍 [deform.worker] 计算路径: ${a} -> ${m.pathname} (Worker: ${d})`), m.pathname;
408
403
  } else
409
- return A(`🔍 [deform.worker] 使用默认绝对路径: /assets/${l}`), "/assets/" + l;
404
+ return L(`🔍 [deform.worker] 使用默认绝对路径: /assets/${a}`), "/assets/" + a;
410
405
  }
411
- } catch (f) {
412
- Z("⚠️ [deform.worker] 无法计算 WASM 相对路径,使用默认路径:", f);
406
+ } catch (h) {
407
+ se("⚠️ [deform.worker] 无法计算 WASM 相对路径,使用默认路径:", h);
413
408
  }
414
- return "/assets/" + l;
415
- }, e = self.WASM_URL || r("perspective.wasm"), t = self.WASM_EXEC_URL || r("wasm_exec.js");
416
- 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;
409
+ return "/assets/" + a;
410
+ }, e = self.WASM_URL || t("perspective.wasm"), r = self.WASM_EXEC_URL || t("wasm_exec.js");
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;
418
413
  if (!n)
419
414
  throw new Error("LICENSE_TOKEN 未设置,无法使用 WASM 功能");
420
- if (!await g.verifyLicense(n, s))
415
+ if (!await E.verifyLicense(n, u))
421
416
  throw new Error("WASM License 验证失败,无法使用 WASM 功能");
422
- console.log("✅ Worker WASM 模块加载并验证成功");
423
- } catch (r) {
424
- throw console.error("❌ WASM 加载或验证失败:", r), g = null, b = null, r;
417
+ } catch (t) {
418
+ throw E = null, M = null, t;
425
419
  } finally {
426
- N = !1;
420
+ R = !1;
427
421
  }
428
- })(), b) : (A("⏳ [deform.worker] 等待 License Token..."), Promise.resolve());
422
+ })(), M) : Promise.resolve();
429
423
  }
430
- function K(o) {
431
- 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 };
424
+ function Y(s) {
425
+ return "naturalWidth" in s && s.naturalWidth ? { width: s.naturalWidth, height: s.naturalHeight } : "width" in s ? { width: s.width, height: s.height } : { width: 0, height: 0 };
432
426
  }
433
- function re(o, r) {
434
- if (!o || !o.bounds)
427
+ function oe(s, t) {
428
+ if (!s || !s.bounds)
435
429
  throw new Error("Invalid layer data: missing bounds");
436
- const e = o.bounds;
437
- if (r && r.width > 0 && r.height > 0)
438
- return { ...o };
439
- const t = o.size || o.placedLayer || {
430
+ const e = s.bounds;
431
+ if (t && t.width > 0 && t.height > 0)
432
+ return { ...s };
433
+ const r = s.size || s.placedLayer || {
440
434
  width: e.width,
441
435
  height: e.height
442
- }, n = t.width / e.width, s = t.height / e.height, i = { ...o };
443
- return o.transform && o.transform.length === 8 && (i.transform = [
444
- (o.transform[0] - e.left) * n,
445
- (o.transform[1] - e.top) * s,
446
- (o.transform[2] - e.left) * n,
447
- (o.transform[3] - e.top) * s,
448
- (o.transform[4] - e.left) * n,
449
- (o.transform[5] - e.top) * s,
450
- (o.transform[6] - e.left) * n,
451
- (o.transform[7] - e.top) * s
452
- ]), i;
436
+ }, n = r.width / e.width, u = r.height / e.height, o = { ...s };
437
+ return s.transform && s.transform.length === 8 && (o.transform = [
438
+ (s.transform[0] - e.left) * n,
439
+ (s.transform[1] - e.top) * u,
440
+ (s.transform[2] - e.left) * n,
441
+ (s.transform[3] - e.top) * u,
442
+ (s.transform[4] - e.left) * n,
443
+ (s.transform[5] - e.top) * u,
444
+ (s.transform[6] - e.left) * n,
445
+ (s.transform[7] - e.top) * u
446
+ ]), o;
453
447
  }
454
- function te(o) {
455
- return o.error, o;
448
+ function ie(s) {
449
+ return s.error, s;
456
450
  }
457
- function ne(o, r, e) {
458
- if (!o || !r || !e)
451
+ function ce(s, t, e) {
452
+ if (!s || !t || !e)
459
453
  return "Invalid Parameters";
460
- 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
- if (!t || !n)
454
+ 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;
455
+ if (!r || !n)
462
456
  return "Image Not Loaded";
463
- o.imageSmoothingEnabled = !0, o.imageSmoothingQuality = "high";
464
- let s = null, i = null, a = null, w = null, l = 0, h = 0, c = null, f = "Unknown";
465
- 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
- const u = e.transform;
467
- i = [
468
- { x: u[0], y: u[1] },
469
- { x: u[2], y: u[3] },
470
- { x: u[4], y: u[5] },
471
- { x: u[6], y: u[7] }
457
+ s.imageSmoothingEnabled = !0, s.imageSmoothingQuality = "high";
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
+ o = [
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] }
472
466
  ];
473
467
  }
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;
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;
475
469
  }
476
- function oe(o, r, e, t, n, s) {
477
- if (!t.originalVertexArray || !t.deformedVertexArray || !t.indexArray)
470
+ function ae(s, t, e, r, n, u) {
471
+ if (!r.originalVertexArray || !r.deformedVertexArray || !r.indexArray)
478
472
  return;
479
- const i = F(e), a = fe(i);
480
- if (!a) {
481
- q(o, r, e);
473
+ const o = q(e), c = ye(o);
474
+ if (!c) {
475
+ K(s, t, e);
482
476
  return;
483
477
  }
484
- const w = t.originalVertexArray, l = t.deformedVertexArray, h = t.indexArray;
485
- 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, _);
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);
490
484
  }
491
485
  }
492
- function se(o, r, e, t) {
493
- let n = 1 / 0, s = -1 / 0, i = 1 / 0, a = -1 / 0;
494
- t.forEach((c) => {
495
- n = Math.min(n, c.x), s = Math.max(s, c.x), i = Math.min(i, c.y), a = Math.max(a, c.y);
486
+ function le(s, t, e, r) {
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);
496
490
  });
497
- const w = s - n, l = a - i;
498
- if (w < 1 || l < 1) {
499
- q(o, r, e);
491
+ const w = u - n, a = c - o;
492
+ if (w < 1 || a < 1) {
493
+ K(s, t, e);
500
494
  return;
501
495
  }
502
- const h = t.map((c) => {
503
- const f = (c.x - n) / w, u = (c.y - i) / l;
504
- return B(f, u, e);
496
+ const l = r.map((i) => {
497
+ const h = (i.x - n) / w, f = (i.y - o) / a;
498
+ return N(h, f, e);
505
499
  });
506
- X(o, r, h, "bicubic", 4, 40);
500
+ V(s, t, l, "bicubic", 4, 40);
507
501
  }
508
- function ie(o, r, e, t, n, s, i, a) {
509
- const w = F(e);
510
- let l = 1 / 0, h = -1 / 0, c = 1 / 0, f = -1 / 0;
511
- t.forEach((x) => {
512
- l = Math.min(l, x.x), h = Math.max(h, x.x), c = Math.min(c, x.y), f = Math.max(f, x.y);
502
+ function he(s, t, e, r, n, u, o, c) {
503
+ const w = q(e);
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);
513
507
  });
514
- const u = h - l || 1, d = f - c || 1, m = n.length - 1, y = s.length - 1;
515
- for (let x = 0; x < y; x++)
516
- for (let p = 0; p < m; p++) {
517
- const E = x * 3, S = p * 3, M = [], W = m * 3 + 1;
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;
518
512
  try {
519
- for (let I = 0; I < 4; I++)
520
- for (let O = 0; O < 4; O++) {
521
- const H = (E + I) * W + (S + O);
522
- t[H] && M.push(t[H]);
513
+ for (let S = 0; S < 4; S++)
514
+ for (let T = 0; T < 4; T++) {
515
+ const J = (p + S) * D + (x + T);
516
+ r[J] && A.push(r[J]);
523
517
  }
524
518
  } catch {
525
519
  continue;
526
520
  }
527
- if (M.length < 16) continue;
528
- 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, _);
521
+ if (A.length < 16) continue;
522
+ const W = A.map((S) => {
523
+ const T = (S.x - a) / f, J = (S.y - i) / d;
524
+ return ee(T, J, 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);
533
527
  }
534
528
  }
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;
538
- 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);
529
+ function fe(s, t, e, r) {
530
+ const n = q(e);
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);
540
534
  });
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);
544
- }), f = Math.floor(Math.sqrt(t.length)) || 4;
545
- X(o, r, c, "grid", f, 40);
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
+ return ee(d, y, n);
538
+ }), h = Math.floor(Math.sqrt(r.length)) || 4;
539
+ V(s, t, i, "grid", h, 40);
546
540
  }
547
- function ae(o, r, e, t, n, s, i) {
548
- const w = K(r), l = w.width, h = w.height;
549
- for (let c = 0; c < 20; c++)
550
- 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, _);
541
+ function we(s, t, e, r, n, u, o) {
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);
553
547
  }
554
548
  }
555
- function q(o, r, e) {
556
- X(o, r, e, "bilinear", 0, 10);
549
+ function K(s, t, e) {
550
+ V(s, t, e, "bilinear", 0, 10);
557
551
  }
558
- function le(o, r, e) {
559
- X(o, r, e, "bicubic", 4, 40);
552
+ function de(s, t, e) {
553
+ V(s, t, e, "bicubic", 4, 40);
560
554
  }
561
- function X(o, r, e, t, n, s) {
562
- const i = K(r), a = i.width, w = i.height;
563
- for (let l = 0; l < s; l++)
564
- 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 };
566
- 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);
555
+ function V(s, t, e, r, n, u) {
556
+ const o = Y(t), c = o.width, w = o.height;
557
+ for (let a = 0; a < u; a++)
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);
568
562
  }
569
563
  }
570
- function Q(o, r) {
571
- const e = 1 - r;
572
- return o === 0 ? e * e * e : o === 1 ? 3 * e * e * r : o === 2 ? 3 * e * r * r : r * r * r;
564
+ function Q(s, t) {
565
+ const e = 1 - t;
566
+ return s === 0 ? e * e * e : s === 1 ? 3 * e * e * t : s === 2 ? 3 * e * t * t : t * t * t;
573
567
  }
574
- function v(o, r, e) {
575
- let t = 0, n = 0;
576
- for (let s = 0; s < 4; s++)
577
- for (let i = 0; i < 4; i++) {
578
- const a = Q(s, r) * Q(i, o);
579
- t += e[s * 4 + i].x * a, n += e[s * 4 + i].y * a;
568
+ function C(s, t, e) {
569
+ let r = 0, n = 0;
570
+ for (let u = 0; u < 4; u++)
571
+ for (let o = 0; o < 4; o++) {
572
+ const c = Q(u, t) * Q(o, s);
573
+ r += e[u * 4 + o].x * c, n += e[u * 4 + o].y * c;
580
574
  }
581
- return { x: t, y: n };
575
+ return { x: r, y: n };
582
576
  }
583
- function B(o, r, e) {
584
- const t = (1 - o) * (1 - r) * e[0].x + o * (1 - r) * e[1].x + o * r * e[2].x + (1 - o) * r * e[3].x, n = (1 - o) * (1 - r) * e[0].y + o * (1 - r) * e[1].y + o * r * e[2].y + (1 - o) * r * e[3].y;
585
- return { x: t, y: n };
577
+ function N(s, t, e) {
578
+ 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;
579
+ return { x: r, y: n };
586
580
  }
587
- function z(o, r, e, t) {
588
- 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;
592
- return { x: m, y };
581
+ function j(s, t, e, r) {
582
+ const n = r - 1, u = s * n, o = t * n;
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
+ return { x: y, y: m };
593
587
  }
594
- function F(o) {
595
- if (!g || !g.isReady())
588
+ function q(s) {
589
+ if (!E || !E.isReady())
596
590
  throw new Error("WASM 模块未加载,无法计算透视变换矩阵");
597
591
  try {
598
- return g.calcPerspectiveMatrix(o);
599
- } catch (r) {
600
- throw new Error(`WASM 计算透视矩阵失败: ${r}`);
592
+ return E.calcPerspectiveMatrix(s);
593
+ } catch (t) {
594
+ throw new Error(`WASM 计算透视矩阵失败: ${t}`);
601
595
  }
602
596
  }
603
- function fe(o) {
604
- if (!g || !g.isReady())
597
+ function ye(s) {
598
+ if (!E || !E.isReady())
605
599
  throw new Error("WASM 模块未加载,无法求逆矩阵");
606
600
  try {
607
- return g.invertMatrix(o);
608
- } catch (r) {
609
- throw new Error(`WASM 求逆矩阵失败: ${r}`);
601
+ return E.invertMatrix(s);
602
+ } catch (t) {
603
+ throw new Error(`WASM 求逆矩阵失败: ${t}`);
610
604
  }
611
605
  }
612
- function G(o, r, e) {
613
- if (!g || !g.isReady())
606
+ function X(s, t, e) {
607
+ if (!E || !E.isReady())
614
608
  throw new Error("WASM 模块未加载,无法应用逆透视变换");
615
609
  try {
616
- return g.applyInversePerspective(o, r, e);
617
- } catch (t) {
618
- throw new Error(`WASM 应用逆透视变换失败: ${t}`);
610
+ return E.applyInversePerspective(s, t, e);
611
+ } catch (r) {
612
+ throw new Error(`WASM 应用逆透视变换失败: ${r}`);
619
613
  }
620
614
  }
621
- function D(o, r, e) {
622
- if (!g || !g.isReady())
615
+ function ee(s, t, e) {
616
+ if (!E || !E.isReady())
623
617
  throw new Error("WASM 模块未加载,无法应用透视变换");
624
618
  try {
625
- return g.applyPerspective(o, r, e);
626
- } catch (t) {
627
- throw new Error(`WASM 应用透视变换失败: ${t}`);
619
+ return E.applyPerspective(s, t, e);
620
+ } catch (r) {
621
+ throw new Error(`WASM 应用透视变换失败: ${r}`);
628
622
  }
629
623
  }
630
- function J(o, r, e, t, n, s, i, a) {
631
- 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();
634
- const p = e.x * (n.y - t.y) - t.x * n.y + n.x * t.y + (t.x - n.x) * e.y;
635
- if (Math.abs(p) < 1e-3) {
636
- o.restore();
624
+ function k(s, t, e, r, n, u, o, c) {
625
+ if (!t || "complete" in t && !t.complete || !("naturalWidth" in t ? t.naturalWidth : t.width)) return;
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
+ s.restore();
637
631
  return;
638
632
  }
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();
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();
641
635
  }
642
- A("🚀 [deform.worker] Worker 启动,等待 License Token...");
643
- self.onmessage = async (o) => {
644
- if (o.data?.type === "SET_DEBUG") {
645
- V = !!o.data?.debugRender, self.__DEBUG_RENDER__ = V;
636
+ self.onmessage = async (s) => {
637
+ if (s.data?.type === "SET_DEBUG") {
638
+ H = !!s.data?.debugRender, self.__DEBUG_RENDER__ = H;
646
639
  return;
647
640
  }
648
- if (o.data?.type === "SET_LICENSE") {
649
- ee(o.data);
641
+ if (s.data?.type === "SET_LICENSE") {
642
+ ue(s.data);
650
643
  return;
651
644
  }
652
- const r = o.data, { id: e, designBitmap: t, layerData: n, canvasSize: s } = r;
653
- if (!t) {
654
- console.error(`[deform worker] ❌ designBitmap 未定义 id=${e}`), self.postMessage({
645
+ const t = s.data, { id: e, designBitmap: r, layerData: n, canvasSize: u } = t;
646
+ if (!r) {
647
+ self.postMessage({
655
648
  id: e,
656
649
  imageBitmap: null,
657
650
  error: "designBitmap 未定义",
@@ -660,7 +653,7 @@ self.onmessage = async (o) => {
660
653
  return;
661
654
  }
662
655
  if (!n) {
663
- console.error(`[deform worker] ❌ layerData 未定义 id=${e}`), self.postMessage({
656
+ self.postMessage({
664
657
  id: e,
665
658
  imageBitmap: null,
666
659
  error: "layerData 未定义",
@@ -668,54 +661,47 @@ self.onmessage = async (o) => {
668
661
  });
669
662
  return;
670
663
  }
671
- const i = performance.now(), a = (/* @__PURE__ */ new Date()).toISOString();
672
- if (A(`[deform worker] ⏰ 开始 id=${e} 时间=${a}`, {
673
- designBitmap: { width: t.width, height: t.height },
664
+ const o = performance.now(), c = (/* @__PURE__ */ new Date()).toISOString();
665
+ if (L(`[deform worker] ⏰ 开始 id=${e} 时间=${c}`, {
666
+ designBitmap: { width: r.width, height: r.height },
674
667
  size: n.size,
675
668
  bounds: n.bounds,
676
- canvasSize: s
677
- }), !g || !g.isReady())
678
- if (k || self.LICENSE_TOKEN) {
679
- console.log("🔄 [deform.worker] WASM 未就绪,尝试初始化...");
669
+ canvasSize: u
670
+ }), !E || !E.isReady())
671
+ if (b || self.LICENSE_TOKEN)
680
672
  try {
681
- if (N && b && (console.log("⏳ [deform.worker] WASM 正在加载中,等待完成..."), await b), (!g || !g.isReady()) && await Y(), !g || !g.isReady())
673
+ if (R && M && await M, (!E || !E.isReady()) && await G(), !E || !E.isReady())
682
674
  throw new Error("WASM 模块仍未就绪");
683
- console.log("✅ [deform.worker] WASM 初始化成功,继续处理任务");
684
- } catch (l) {
685
- console.error("❌ [deform.worker] WASM 初始化失败:", l);
686
- const c = performance.now() - i;
675
+ } catch (a) {
676
+ const i = performance.now() - o;
687
677
  self.postMessage({
688
678
  id: e,
689
- error: `WASM 初始化失败: ${l.message}`,
690
- duration: c
679
+ error: `WASM 初始化失败: ${a.message}`,
680
+ duration: i
691
681
  });
692
682
  return;
693
683
  }
694
- } else {
695
- console.log("⏳ [deform.worker] 等待 License Token...");
696
- let l = 0;
697
- const h = 500, c = 50;
698
- let f = null;
699
- for (; l < h && !f; )
700
- await new Promise((u) => setTimeout(u, c)), l += c, f = k || self.LICENSE_TOKEN;
701
- if (f)
684
+ else {
685
+ let a = 0;
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)
702
691
  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())
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())
704
693
  throw new Error("WASM 模块未就绪");
705
- console.log("✅ [deform.worker] WASM 初始化成功,继续处理任务");
706
- } catch (u) {
707
- console.error("❌ [deform.worker] WASM 初始化失败:", u);
708
- const m = performance.now() - i;
694
+ } catch (f) {
695
+ const y = performance.now() - o;
709
696
  self.postMessage({
710
697
  id: e,
711
- error: `WASM 初始化失败: ${u.message}`,
712
- duration: m
698
+ error: `WASM 初始化失败: ${f.message}`,
699
+ duration: y
713
700
  });
714
701
  return;
715
702
  }
716
- else if (!f) {
717
- console.error("❌ [deform.worker] 等待超时,License Token 未设置");
718
- const d = performance.now() - i;
703
+ else if (!h) {
704
+ const d = performance.now() - o;
719
705
  self.postMessage({
720
706
  id: e,
721
707
  error: "LICENSE_TOKEN 未设置,无法使用 WASM 功能",
@@ -727,7 +713,7 @@ self.onmessage = async (o) => {
727
713
  try {
728
714
  const w = n.bounds;
729
715
  if (!w || !w.width || !w.height) {
730
- console.error(`[deform worker] ❌ bounds 无效 id=${e}`, w), self.postMessage({
716
+ self.postMessage({
731
717
  id: e,
732
718
  imageBitmap: null,
733
719
  error: "bounds 无效",
@@ -735,43 +721,40 @@ self.onmessage = async (o) => {
735
721
  });
736
722
  return;
737
723
  }
738
- const l = re(n, s);
739
- let h, c;
740
- if (s && s.width > 0 && s.height > 0)
741
- h = s.width, c = s.height;
724
+ const a = oe(n, u);
725
+ let l, i;
726
+ if (u && u.width > 0 && u.height > 0)
727
+ l = u.width, i = u.height;
742
728
  else {
743
- const S = n.size || n.placedLayer || {
729
+ const x = n.size || n.placedLayer || {
744
730
  width: w.width,
745
731
  height: w.height
746
732
  };
747
- h = S.width, c = S.height;
733
+ l = x.width, i = x.height;
748
734
  }
749
- const f = new OffscreenCanvas(h, c), u = f.getContext("2d");
750
- if (!u) {
751
- const M = performance.now() - i;
752
- self.postMessage({ id: e, error: "Canvas context unavailable", duration: M });
735
+ const h = new OffscreenCanvas(l, i), f = h.getContext("2d");
736
+ if (!f) {
737
+ const A = performance.now() - o;
738
+ self.postMessage({ id: e, error: "Canvas context unavailable", duration: A });
753
739
  return;
754
740
  }
755
- const d = ne(u, t, l), m = f.transferToImageBitmap(), x = performance.now() - i, p = (/* @__PURE__ */ new Date()).toISOString();
756
- A(
757
- `[deform worker] ✅ 结束 id=${e} 时间=${p} 耗时=${Math.round(x)}ms 变形方法=${d}`,
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}`,
758
744
  {
759
- width: m.width,
760
- height: m.height
745
+ width: y.width,
746
+ height: y.height
761
747
  }
762
- ), t.close();
763
- const E = te(
764
- { id: e, imageBitmap: m, duration: x }
748
+ ), r.close();
749
+ const p = ie(
750
+ { id: e, imageBitmap: y, duration: F }
765
751
  );
766
752
  self.postMessage(
767
- E,
768
- E.imageBitmap ? [E.imageBitmap] : []
753
+ p,
754
+ p.imageBitmap ? [p.imageBitmap] : []
769
755
  );
770
756
  } catch (w) {
771
- const h = performance.now() - i, c = w instanceof Error ? w.message : String(w), f = (/* @__PURE__ */ new Date()).toISOString();
772
- A(
773
- `[deform worker] ❌ 错误 id=${e} 时间=${f} 耗时=${Math.round(h)}ms`,
774
- c
775
- ), self.postMessage({ id: e, error: c, duration: h });
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 });
776
759
  }
777
760
  };