@jetprint/editor-sdk 1.0.0

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.
Files changed (149) hide show
  1. package/dist/assets/perspective.wasm +0 -0
  2. package/dist/assets/wasm_exec.js +553 -0
  3. package/dist/components/Editor/assets/editorIcons.d.ts +32 -0
  4. package/dist/components/Editor/components/CanvasSection.vue.d.ts +253 -0
  5. package/dist/components/Editor/components/CanvasZoomToolbar.vue.d.ts +23 -0
  6. package/dist/components/Editor/components/EditorAddToCartDialog.vue.d.ts +28 -0
  7. package/dist/components/Editor/components/EditorDefaultCanvasAxisLines.vue.d.ts +34 -0
  8. package/dist/components/Editor/components/EditorDefaultCanvasRulers.vue.d.ts +44 -0
  9. package/dist/components/Editor/components/EditorIcon.vue.d.ts +7 -0
  10. package/dist/components/Editor/components/EditorSelectionShortcutFab.vue.d.ts +56 -0
  11. package/dist/components/Editor/components/EditorSidebar.vue.d.ts +548 -0
  12. package/dist/components/Editor/components/EditorTopbar.vue.d.ts +363 -0
  13. package/dist/components/Editor/components/EditorTopbarMockupScope.vue.d.ts +12 -0
  14. package/dist/components/Editor/components/GalleryPanel.vue.d.ts +9 -0
  15. package/dist/components/Editor/components/LiveThreePreviewPane.vue.d.ts +30 -0
  16. package/dist/components/Editor/components/PreviewPanel.vue.d.ts +312 -0
  17. package/dist/components/Editor/components/ShortcutSettingsModal.vue.d.ts +11 -0
  18. package/dist/components/Editor/components/SplitPieceHandAlignPanel.vue.d.ts +14 -0
  19. package/dist/components/Editor/components/TemplateModal.vue.d.ts +35 -0
  20. package/dist/components/Editor/components/Theme1AddTextPanel.vue.d.ts +190 -0
  21. package/dist/components/Editor/components/Theme1UploadPanel.vue.d.ts +120 -0
  22. package/dist/components/Editor/composables/index.d.ts +56 -0
  23. package/dist/components/Editor/composables/useCanvasEventWiring.d.ts +40 -0
  24. package/dist/components/Editor/composables/useCanvasHistory.d.ts +18 -0
  25. package/dist/components/Editor/composables/useCanvasManager.d.ts +29 -0
  26. package/dist/components/Editor/composables/useCanvasObjectHelpers.d.ts +34 -0
  27. package/dist/components/Editor/composables/useCanvasStateByDiecut.d.ts +50 -0
  28. package/dist/components/Editor/composables/useCanvasViewport.d.ts +89 -0
  29. package/dist/components/Editor/composables/useClearCanvas.d.ts +32 -0
  30. package/dist/components/Editor/composables/useCompleteScreenshot.d.ts +68 -0
  31. package/dist/components/Editor/composables/useCopyToDiecuts.d.ts +56 -0
  32. package/dist/components/Editor/composables/useDiecutManager.d.ts +46 -0
  33. package/dist/components/Editor/composables/useDiecutScreenshot.d.ts +50 -0
  34. package/dist/components/Editor/composables/useDownloadPng.d.ts +11 -0
  35. package/dist/components/Editor/composables/useEditorReset.d.ts +21 -0
  36. package/dist/components/Editor/composables/useEditorShortcuts.d.ts +80 -0
  37. package/dist/components/Editor/composables/useEditorTopbarContext.d.ts +3 -0
  38. package/dist/components/Editor/composables/useEditorWatchers.d.ts +99 -0
  39. package/dist/components/Editor/composables/useEventHandlers.d.ts +13 -0
  40. package/dist/components/Editor/composables/useFontLoader.d.ts +8 -0
  41. package/dist/components/Editor/composables/useGuideResources.d.ts +38 -0
  42. package/dist/components/Editor/composables/useImageHandler.d.ts +10 -0
  43. package/dist/components/Editor/composables/useLayerOperations.d.ts +52 -0
  44. package/dist/components/Editor/composables/useLayerSync.d.ts +32 -0
  45. package/dist/components/Editor/composables/useLicense.d.ts +11 -0
  46. package/dist/components/Editor/composables/useObjectAdder.d.ts +76 -0
  47. package/dist/components/Editor/composables/usePatternHandler.d.ts +31 -0
  48. package/dist/components/Editor/composables/usePreviewManager.d.ts +240 -0
  49. package/dist/components/Editor/composables/usePreviewRenderer.d.ts +111 -0
  50. package/dist/components/Editor/composables/usePreviewUpdateQueue.d.ts +62 -0
  51. package/dist/components/Editor/composables/useProductData.d.ts +166 -0
  52. package/dist/components/Editor/composables/useSplitPieceHandTool.d.ts +34 -0
  53. package/dist/components/Editor/composables/useTemplateLoader.d.ts +36 -0
  54. package/dist/components/Editor/composables/useTemplateManager.d.ts +48 -0
  55. package/dist/components/Editor/composables/useTextHandler.d.ts +19 -0
  56. package/dist/components/Editor/composables/useToolState.d.ts +101 -0
  57. package/dist/components/Editor/composables/useToolStateSync.d.ts +49 -0
  58. package/dist/components/Editor/composables/useWorkerManager.d.ts +11 -0
  59. package/dist/components/Editor/config/fontConfig.d.ts +8 -0
  60. package/dist/components/Editor/editorCanvasGuides.d.ts +22 -0
  61. package/dist/components/Editor/fabric/PatternLayer.d.ts +104 -0
  62. package/dist/components/Editor/index.vue.d.ts +167 -0
  63. package/dist/components/Editor/liveRender/ThreeRenderViewer.vue.d.ts +31 -0
  64. package/dist/components/Editor/liveRender/dataAdapter.d.ts +2 -0
  65. package/dist/components/Editor/liveRender/prefetch.worker.d.ts +15 -0
  66. package/dist/components/Editor/liveRender/render.worker.d.ts +1 -0
  67. package/dist/components/Editor/liveRender/types.d.ts +130 -0
  68. package/dist/components/Editor/utils/blob.d.ts +5 -0
  69. package/dist/components/Editor/utils/buildSplitPieceDesignClipBlobs.d.ts +75 -0
  70. package/dist/components/Editor/utils/colorLabels.d.ts +6 -0
  71. package/dist/components/Editor/utils/dataBuilders.d.ts +108 -0
  72. package/dist/components/Editor/utils/designRestoreScale.d.ts +42 -0
  73. package/dist/components/Editor/utils/editorShortcutChord.d.ts +9 -0
  74. package/dist/components/Editor/utils/editorShortcutIds.d.ts +2 -0
  75. package/dist/components/Editor/utils/editorShortcutRegistry.d.ts +15 -0
  76. package/dist/components/Editor/utils/editorSizeOptions.d.ts +27 -0
  77. package/dist/components/Editor/utils/fabricMainCanvasSnapshot.d.ts +48 -0
  78. package/dist/components/Editor/utils/fabricRulerMath.d.ts +35 -0
  79. package/dist/components/Editor/utils/fabricScreenshotToBlob.d.ts +7 -0
  80. package/dist/components/Editor/utils/imageLoader.d.ts +10 -0
  81. package/dist/components/Editor/utils/objectUtils.d.ts +11 -0
  82. package/dist/components/Editor/utils/pattern.d.ts +56 -0
  83. package/dist/components/Editor/utils/scaleSplitClassicGridVisual.d.ts +9 -0
  84. package/dist/components/Editor/utils/screenshot.d.ts +8 -0
  85. package/dist/components/Editor/utils/selectionVisual.d.ts +7 -0
  86. package/dist/components/Editor/utils/tintMaskWithColor.d.ts +4 -0
  87. package/dist/components/Editor/utils/uploadLimit.d.ts +4 -0
  88. package/dist/components/Editor/workers/copyDiecuts.worker.d.ts +38 -0
  89. package/dist/components/Editor/workers/maskWorker.d.ts +13 -0
  90. package/dist/components/Editor/workers/renderWorker.d.ts +1 -0
  91. package/dist/components/Editor/workers/zoneScreenshotWorker.d.ts +49 -0
  92. package/dist/composables/useEditorI18n.d.ts +18 -0
  93. package/dist/copyDiecuts.worker.js +67 -0
  94. package/dist/deform.worker.js +760 -0
  95. package/dist/editor-sdk.es.js +73923 -0
  96. package/dist/index.d.ts +446 -0
  97. package/dist/locales/builtin-messages.d.ts +2 -0
  98. package/dist/locales/editor-locales.d.ts +7 -0
  99. package/dist/locales/en.d.ts +5 -0
  100. package/dist/locales/ja-JP.d.ts +5 -0
  101. package/dist/locales/ko-KR.d.ts +5 -0
  102. package/dist/locales/vi-VN.d.ts +5 -0
  103. package/dist/locales/zh.d.ts +5 -0
  104. package/dist/maskWorker.js +51 -0
  105. package/dist/prefetch.worker.js +16 -0
  106. package/dist/render.worker.js +27266 -0
  107. package/dist/renderWorker.js +40368 -0
  108. package/dist/style.css +1 -0
  109. package/dist/types.d.ts +483 -0
  110. package/dist/utils/backgroundRenderer.d.ts +64 -0
  111. package/dist/utils/encryptJson.d.ts +31 -0
  112. package/dist/utils/environment.d.ts +29 -0
  113. package/dist/utils/errorHandler.d.ts +27 -0
  114. package/dist/utils/fileToken.d.ts +18 -0
  115. package/dist/utils/http.d.ts +31 -0
  116. package/dist/utils/jsonFileCache.d.ts +6 -0
  117. package/dist/utils/license/api.d.ts +74 -0
  118. package/dist/utils/license/deviceId.d.ts +25 -0
  119. package/dist/utils/license/index.d.ts +9 -0
  120. package/dist/utils/license/licenseManager.d.ts +63 -0
  121. package/dist/utils/license/licenseStore.d.ts +17 -0
  122. package/dist/utils/license/retry.d.ts +11 -0
  123. package/dist/utils/license/tokenRefresh.d.ts +34 -0
  124. package/dist/utils/mediaBlobCache.d.ts +6 -0
  125. package/dist/utils/protection/encryptedModules.generated.d.ts +27 -0
  126. package/dist/utils/protection/moduleLoader.d.ts +17 -0
  127. package/dist/utils/renderService/blend.d.ts +4 -0
  128. package/dist/utils/renderService/deform.d.ts +21 -0
  129. package/dist/utils/renderService/deform.worker.d.ts +7 -0
  130. package/dist/utils/renderService/image.d.ts +8 -0
  131. package/dist/utils/renderService/index.d.ts +12 -0
  132. package/dist/utils/renderService/mask.d.ts +13 -0
  133. package/dist/utils/renderService/prepareRenderData.d.ts +2 -0
  134. package/dist/utils/renderService/psdConverter.d.ts +6 -0
  135. package/dist/utils/renderService/render.d.ts +14 -0
  136. package/dist/utils/renderService/render.worker.d.ts +17 -0
  137. package/dist/utils/renderService/types.d.ts +236 -0
  138. package/dist/utils/renderService/workerManager.d.ts +33 -0
  139. package/dist/utils/renderedImagesDB.d.ts +61 -0
  140. package/dist/utils/storage.d.ts +27 -0
  141. package/dist/utils/threeRenderService/index.d.ts +6 -0
  142. package/dist/utils/url.d.ts +39 -0
  143. package/dist/utils/workerBase.d.ts +38 -0
  144. package/dist/utils/workerLoader.d.ts +24 -0
  145. package/dist/wasm/index.d.ts +5 -0
  146. package/dist/wasm/perspectiveLoader.d.ts +70 -0
  147. package/dist/wasm/perspectiveLoader.worker.d.ts +116 -0
  148. package/dist/zoneScreenshotWorker.js +82 -0
  149. package/package.json +54 -0
@@ -0,0 +1,760 @@
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 {
3
+ constructor() {
4
+ z(this, "wasmReady", !1), z(this, "go", null), z(this, "wasmModule", null);
5
+ }
6
+ isDebugEnabled() {
7
+ try {
8
+ return globalThis.__DEBUG_RENDER__ === !0;
9
+ } catch {
10
+ }
11
+ return !1;
12
+ }
13
+ debugLog(...t) {
14
+ this.isDebugEnabled();
15
+ }
16
+ debugWarn(...t) {
17
+ this.isDebugEnabled();
18
+ }
19
+ static getInstance() {
20
+ return P.instance || (P.instance = new P()), P.instance;
21
+ }
22
+ /**
23
+ * 在 Worker 环境中加载 WASM 模块
24
+ * @param wasmUrl WASM 文件路径
25
+ * @param wasmExecUrl wasm_exec.js 路径
26
+ */
27
+ async load(t, e) {
28
+ if (this.wasmReady) {
29
+ this.debugLog("✅ WASM 已加载,跳过重复加载");
30
+ return;
31
+ }
32
+ try {
33
+ this.debugLog("🚀 Worker: 加载透视变换 WASM...");
34
+ const r = (i) => {
35
+ if (e && i === "wasm_exec.js")
36
+ return e;
37
+ if (t && i === "perspective.wasm")
38
+ return t;
39
+ try {
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
+ if (d.includes("/js/")) {
44
+ const y = "../assets/" + i, m = new URL(y, f);
45
+ return this.debugLog(`🔍 [WASM] 计算路径: ${i} -> ${m.pathname} (Worker: ${d})`), m.pathname;
46
+ } else if (d.includes("/assets/")) {
47
+ const y = "./" + i, m = new URL(y, f);
48
+ return this.debugLog(`🔍 [WASM] 计算路径: ${i} -> ${m.pathname} (Worker: ${d})`), m.pathname;
49
+ } else
50
+ return this.debugLog(`🔍 [WASM] 使用默认绝对路径: /assets/${i}`), "/assets/" + i;
51
+ }
52
+ } catch (h) {
53
+ this.debugWarn("⚠️ 无法计算 WASM 相对路径,使用默认路径:", h);
54
+ }
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);
68
+ else
69
+ throw new Error("WASM 初始化失败");
70
+ } catch (r) {
71
+ throw this.wasmReady = !1, r;
72
+ }
73
+ }
74
+ /**
75
+ * 在 Worker 中加载 wasm_exec.js
76
+ * Module Worker 不支持 importScripts(),仅 Classic Worker 可尝试 importScripts,否则用 fetch + eval
77
+ */
78
+ async loadWasmExec(t) {
79
+ return new Promise((e, r) => {
80
+ if (!(typeof import.meta < "u" && import.meta.url) && typeof self.importScripts == "function")
81
+ try {
82
+ self.importScripts(t), e();
83
+ return;
84
+ } catch (u) {
85
+ this.debugWarn("⚠️ importScripts 失败,使用 fetch:", u);
86
+ }
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}`);
95
+ try {
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}`));
100
+ }
101
+ }).catch((u) => {
102
+ r(u);
103
+ });
104
+ });
105
+ }
106
+ /**
107
+ * 验证授权(通过 API)
108
+ */
109
+ async verifyLicense(t, e) {
110
+ if (!this.wasmReady)
111
+ return !1;
112
+ if (e)
113
+ try {
114
+ const r = this.getDeviceID(), n = this.getDomain(), o = await (await fetch(`${e}/jet_license/interface/license/verify`, {
115
+ method: "POST",
116
+ headers: {
117
+ "Content-Type": "application/json"
118
+ },
119
+ body: JSON.stringify({
120
+ token: t,
121
+ deviceId: r,
122
+ domain: n
123
+ })
124
+ })).json();
125
+ if (!o.success || !o.valid) {
126
+ const w = o.error || "License 验证失败";
127
+ throw new Error(w);
128
+ }
129
+ const c = this.call("wasmVerifyLicense", t);
130
+ if (!c.success || c.valid !== !0)
131
+ throw new Error("WASM 验证失败");
132
+ return !0;
133
+ } catch (r) {
134
+ throw r;
135
+ }
136
+ else
137
+ try {
138
+ const r = this.call("wasmVerifyLicense", t);
139
+ return r.success && r.valid === !0;
140
+ } catch {
141
+ return !1;
142
+ }
143
+ }
144
+ /**
145
+ * 获取设备 ID(从全局变量或生成)
146
+ */
147
+ getDeviceID() {
148
+ return typeof self < "u" && self.DEVICE_ID ? self.DEVICE_ID : `worker-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
149
+ }
150
+ /**
151
+ * 获取域名(从全局变量或使用默认值)
152
+ */
153
+ getDomain() {
154
+ return typeof self < "u" && self.DOMAIN ? self.DOMAIN : "localhost";
155
+ }
156
+ /**
157
+ * 计算透视变换矩阵
158
+ */
159
+ calcPerspectiveMatrix(t) {
160
+ if (!this.wasmReady)
161
+ throw new Error("WASM 未加载");
162
+ if (t.length !== 4)
163
+ throw new Error("需要恰好 4 个点");
164
+ try {
165
+ const e = this.call("wasmCalcPerspectiveMatrix", JSON.stringify(t));
166
+ if (!e.success)
167
+ throw new Error(e.error || "计算失败");
168
+ return e.matrix;
169
+ } catch (e) {
170
+ throw e;
171
+ }
172
+ }
173
+ /**
174
+ * 矩阵求逆
175
+ */
176
+ invertMatrix(t) {
177
+ if (!this.wasmReady)
178
+ throw new Error("WASM 未加载");
179
+ try {
180
+ const e = this.call("wasmInvertMatrix", JSON.stringify(t));
181
+ if (!e.success)
182
+ throw new Error(e.error || "矩阵求逆失败");
183
+ return e.matrix;
184
+ } catch (e) {
185
+ throw e;
186
+ }
187
+ }
188
+ /**
189
+ * 应用透视变换到单个点
190
+ */
191
+ applyPerspective(t, e, r) {
192
+ if (!this.wasmReady)
193
+ throw new Error("WASM 未加载");
194
+ try {
195
+ const n = this.call("wasmApplyPerspective", t, e, JSON.stringify(r));
196
+ if (!n.success)
197
+ throw new Error(n.error || "变换失败");
198
+ return { x: n.x, y: n.y };
199
+ } catch (n) {
200
+ throw n;
201
+ }
202
+ }
203
+ /**
204
+ * 应用逆透视变换到单个点
205
+ */
206
+ applyInversePerspective(t, e, r) {
207
+ if (!this.wasmReady)
208
+ throw new Error("WASM 未加载");
209
+ try {
210
+ const n = this.call("wasmApplyInversePerspective", t, e, JSON.stringify(r));
211
+ if (!n.success)
212
+ throw new Error(n.error || "逆变换失败");
213
+ return { x: n.x, y: n.y };
214
+ } catch (n) {
215
+ throw n;
216
+ }
217
+ }
218
+ /**
219
+ * 批量变换点(高性能)
220
+ */
221
+ transformPoints(t, e, r = !1) {
222
+ if (!this.wasmReady)
223
+ throw new Error("WASM 未加载");
224
+ try {
225
+ const n = this.call(
226
+ "wasmTransformPoints",
227
+ JSON.stringify(t),
228
+ JSON.stringify(e),
229
+ r
230
+ );
231
+ if (!n.success)
232
+ throw new Error(n.error || "批量变换失败");
233
+ return JSON.parse(n.points);
234
+ } catch (n) {
235
+ throw n;
236
+ }
237
+ }
238
+ /**
239
+ * 检查 WASM 是否已加载
240
+ */
241
+ isReady() {
242
+ return this.wasmReady;
243
+ }
244
+ /**
245
+ * 双三次插值点计算
246
+ */
247
+ getBicubicPoint(t, e, r) {
248
+ if (!this.wasmReady)
249
+ throw new Error("WASM 未加载");
250
+ if (r.length !== 16)
251
+ throw new Error("需要恰好 16 个点");
252
+ try {
253
+ const n = this.call("wasmGetBicubicPoint", t, e, JSON.stringify(r));
254
+ if (!n.success)
255
+ throw new Error(n.error || "计算失败");
256
+ return { x: n.x, y: n.y };
257
+ } catch (n) {
258
+ throw n;
259
+ }
260
+ }
261
+ /**
262
+ * 双线性插值点计算
263
+ */
264
+ getBilinearPoint(t, e, r) {
265
+ if (!this.wasmReady)
266
+ throw new Error("WASM 未加载");
267
+ if (r.length !== 4)
268
+ throw new Error("需要恰好 4 个点");
269
+ try {
270
+ const n = this.call("wasmGetBilinearPoint", t, e, JSON.stringify(r));
271
+ if (!n.success)
272
+ throw new Error(n.error || "计算失败");
273
+ return { x: n.x, y: n.y };
274
+ } catch (n) {
275
+ throw n;
276
+ }
277
+ }
278
+ /**
279
+ * 任意网格点插值计算
280
+ */
281
+ getArbitraryMeshPoint(t, e, r, n) {
282
+ if (!this.wasmReady)
283
+ throw new Error("WASM 未加载");
284
+ try {
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;
291
+ }
292
+ }
293
+ /**
294
+ * 批量双三次插值(高性能优化)
295
+ * 一次性处理多个坐标,避免频繁的 JS/WASM 边界调用
296
+ */
297
+ batchBicubicInterpolation(t, e) {
298
+ if (!this.wasmReady)
299
+ throw new Error("WASM 未加载");
300
+ if (e.length !== 16)
301
+ throw new Error("需要恰好 16 个控制点");
302
+ try {
303
+ const r = this.call(
304
+ "wasmBatchBicubicInterpolation",
305
+ JSON.stringify(t),
306
+ JSON.stringify(e)
307
+ );
308
+ if (!r.success)
309
+ throw new Error(r.error || "批量双三次插值失败");
310
+ return r.points;
311
+ } catch (r) {
312
+ throw r;
313
+ }
314
+ }
315
+ /**
316
+ * 批量双线性插值(高性能优化)
317
+ */
318
+ batchBilinearInterpolation(t, e) {
319
+ if (!this.wasmReady)
320
+ throw new Error("WASM 未加载");
321
+ if (e.length !== 4)
322
+ throw new Error("需要恰好 4 个控制点");
323
+ try {
324
+ const r = this.call(
325
+ "wasmBatchBilinearInterpolation",
326
+ JSON.stringify(t),
327
+ JSON.stringify(e)
328
+ );
329
+ if (!r.success)
330
+ throw new Error(r.error || "批量双线性插值失败");
331
+ return r.points;
332
+ } catch (r) {
333
+ throw r;
334
+ }
335
+ }
336
+ /**
337
+ * 批量任意网格插值(高性能优化)
338
+ */
339
+ batchArbitraryMeshInterpolation(t, e, r) {
340
+ if (!this.wasmReady)
341
+ throw new Error("WASM 未加载");
342
+ try {
343
+ const n = this.call(
344
+ "wasmBatchArbitraryMeshInterpolation",
345
+ JSON.stringify(t),
346
+ JSON.stringify(e),
347
+ r
348
+ );
349
+ if (!n.success)
350
+ throw new Error(n.error || "批量网格插值失败");
351
+ return n.points;
352
+ } catch (n) {
353
+ throw n;
354
+ }
355
+ }
356
+ /**
357
+ * 调用 WASM 函数
358
+ */
359
+ call(t, ...e) {
360
+ if (!this.wasmReady)
361
+ throw new Error("WASM 未加载");
362
+ const n = (typeof self < "u" ? self : globalThis)[t];
363
+ if (!n)
364
+ throw new Error(`函数不存在: ${t}`);
365
+ try {
366
+ return n(...e);
367
+ } catch (u) {
368
+ throw u;
369
+ }
370
+ }
371
+ };
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) => {
381
+ }));
382
+ }
383
+ async function G() {
384
+ return E ? void 0 : R ? M || Promise.resolve() : b || self.LICENSE_TOKEN ? (R = !0, M = (async () => {
385
+ try {
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;
393
+ try {
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
+ if (d.includes("/js/")) {
398
+ const y = "../assets/" + a, m = new URL(y, f);
399
+ return L(`🔍 [deform.worker] 计算路径: ${a} -> ${m.pathname} (Worker: ${d})`), m.pathname;
400
+ } else if (d.includes("/assets/")) {
401
+ const y = "./" + a, m = new URL(y, f);
402
+ return L(`🔍 [deform.worker] 计算路径: ${a} -> ${m.pathname} (Worker: ${d})`), m.pathname;
403
+ } else
404
+ return L(`🔍 [deform.worker] 使用默认绝对路径: /assets/${a}`), "/assets/" + a;
405
+ }
406
+ } catch (h) {
407
+ se("⚠️ [deform.worker] 无法计算 WASM 相对路径,使用默认路径:", h);
408
+ }
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;
413
+ if (!n)
414
+ throw new Error("LICENSE_TOKEN 未设置,无法使用 WASM 功能");
415
+ if (!await E.verifyLicense(n, u))
416
+ throw new Error("WASM License 验证失败,无法使用 WASM 功能");
417
+ } catch (t) {
418
+ throw E = null, M = null, t;
419
+ } finally {
420
+ R = !1;
421
+ }
422
+ })(), M) : Promise.resolve();
423
+ }
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 };
426
+ }
427
+ function oe(s, t) {
428
+ if (!s || !s.bounds)
429
+ throw new Error("Invalid layer data: missing bounds");
430
+ const e = s.bounds;
431
+ if (t && t.width > 0 && t.height > 0)
432
+ return { ...s };
433
+ const r = s.size || s.placedLayer || {
434
+ width: e.width,
435
+ height: e.height
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;
447
+ }
448
+ function ie(s) {
449
+ return s.error, s;
450
+ }
451
+ function ce(s, t, e) {
452
+ if (!s || !t || !e)
453
+ return "Invalid Parameters";
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)
456
+ return "Image Not Loaded";
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] }
466
+ ];
467
+ }
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
+ }
470
+ function ae(s, t, e, r, n, u) {
471
+ if (!r.originalVertexArray || !r.deformedVertexArray || !r.indexArray)
472
+ return;
473
+ const o = q(e), c = ye(o);
474
+ if (!c) {
475
+ K(s, t, e);
476
+ return;
477
+ }
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
+ }
485
+ }
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);
490
+ });
491
+ const w = u - n, a = c - o;
492
+ if (w < 1 || a < 1) {
493
+ K(s, t, e);
494
+ return;
495
+ }
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
+ });
500
+ V(s, t, l, "bicubic", 4, 40);
501
+ }
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);
507
+ });
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
+ try {
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]);
517
+ }
518
+ } catch {
519
+ continue;
520
+ }
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);
527
+ }
528
+ }
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);
534
+ });
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);
540
+ }
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);
547
+ }
548
+ }
549
+ function K(s, t, e) {
550
+ V(s, t, e, "bilinear", 0, 10);
551
+ }
552
+ function de(s, t, e) {
553
+ V(s, t, e, "bicubic", 4, 40);
554
+ }
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);
562
+ }
563
+ }
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;
567
+ }
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;
574
+ }
575
+ return { x: r, y: n };
576
+ }
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 };
580
+ }
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 };
587
+ }
588
+ function q(s) {
589
+ if (!E || !E.isReady())
590
+ throw new Error("WASM 模块未加载,无法计算透视变换矩阵");
591
+ try {
592
+ return E.calcPerspectiveMatrix(s);
593
+ } catch (t) {
594
+ throw new Error(`WASM 计算透视矩阵失败: ${t}`);
595
+ }
596
+ }
597
+ function ye(s) {
598
+ if (!E || !E.isReady())
599
+ throw new Error("WASM 模块未加载,无法求逆矩阵");
600
+ try {
601
+ return E.invertMatrix(s);
602
+ } catch (t) {
603
+ throw new Error(`WASM 求逆矩阵失败: ${t}`);
604
+ }
605
+ }
606
+ function X(s, t, e) {
607
+ if (!E || !E.isReady())
608
+ throw new Error("WASM 模块未加载,无法应用逆透视变换");
609
+ try {
610
+ return E.applyInversePerspective(s, t, e);
611
+ } catch (r) {
612
+ throw new Error(`WASM 应用逆透视变换失败: ${r}`);
613
+ }
614
+ }
615
+ function ee(s, t, e) {
616
+ if (!E || !E.isReady())
617
+ throw new Error("WASM 模块未加载,无法应用透视变换");
618
+ try {
619
+ return E.applyPerspective(s, t, e);
620
+ } catch (r) {
621
+ throw new Error(`WASM 应用透视变换失败: ${r}`);
622
+ }
623
+ }
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();
631
+ return;
632
+ }
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
+ }
636
+ self.onmessage = async (s) => {
637
+ if (s.data?.type === "SET_DEBUG") {
638
+ H = !!s.data?.debugRender, self.__DEBUG_RENDER__ = H;
639
+ return;
640
+ }
641
+ if (s.data?.type === "SET_LICENSE") {
642
+ ue(s.data);
643
+ return;
644
+ }
645
+ const t = s.data, { id: e, designBitmap: r, layerData: n, canvasSize: u } = t;
646
+ if (!r) {
647
+ self.postMessage({
648
+ id: e,
649
+ imageBitmap: null,
650
+ error: "designBitmap 未定义",
651
+ duration: 0
652
+ });
653
+ return;
654
+ }
655
+ if (!n) {
656
+ self.postMessage({
657
+ id: e,
658
+ imageBitmap: null,
659
+ error: "layerData 未定义",
660
+ duration: 0
661
+ });
662
+ return;
663
+ }
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 },
667
+ size: n.size,
668
+ bounds: n.bounds,
669
+ canvasSize: u
670
+ }), !E || !E.isReady())
671
+ if (b || self.LICENSE_TOKEN)
672
+ try {
673
+ if (R && M && await M, (!E || !E.isReady()) && await G(), !E || !E.isReady())
674
+ throw new Error("WASM 模块仍未就绪");
675
+ } catch (a) {
676
+ const i = performance.now() - o;
677
+ self.postMessage({
678
+ id: e,
679
+ error: `WASM 初始化失败: ${a.message}`,
680
+ duration: i
681
+ });
682
+ return;
683
+ }
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)
691
+ try {
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
+ throw new Error("WASM 模块未就绪");
694
+ } catch (f) {
695
+ const y = performance.now() - o;
696
+ self.postMessage({
697
+ id: e,
698
+ error: `WASM 初始化失败: ${f.message}`,
699
+ duration: y
700
+ });
701
+ return;
702
+ }
703
+ else if (!h) {
704
+ const d = performance.now() - o;
705
+ self.postMessage({
706
+ id: e,
707
+ error: "LICENSE_TOKEN 未设置,无法使用 WASM 功能",
708
+ duration: d
709
+ });
710
+ return;
711
+ }
712
+ }
713
+ try {
714
+ const w = n.bounds;
715
+ if (!w || !w.width || !w.height) {
716
+ self.postMessage({
717
+ id: e,
718
+ imageBitmap: null,
719
+ error: "bounds 无效",
720
+ duration: 0
721
+ });
722
+ return;
723
+ }
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;
728
+ else {
729
+ const x = n.size || n.placedLayer || {
730
+ width: w.width,
731
+ height: w.height
732
+ };
733
+ l = x.width, i = x.height;
734
+ }
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 });
739
+ return;
740
+ }
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
+ {
745
+ width: y.width,
746
+ height: y.height
747
+ }
748
+ ), r.close();
749
+ const p = ie(
750
+ { id: e, imageBitmap: y, duration: F }
751
+ );
752
+ self.postMessage(
753
+ p,
754
+ p.imageBitmap ? [p.imageBitmap] : []
755
+ );
756
+ } catch (w) {
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
+ }
760
+ };