@jetprint/editor-sdk 1.2.3 → 1.2.5
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/dist/components/Editor/components/EditorAddToCartDialog.vue.d.ts +1 -0
- package/dist/components/Editor/components/EditorSidebar.vue.d.ts +35 -0
- package/dist/components/Editor/components/EditorTopbar.vue.d.ts +24 -0
- package/dist/components/Editor/components/EmbroideryStitchPanel.vue.d.ts +9 -0
- package/dist/components/Editor/components/PreviewPanel.vue.d.ts +1 -1
- package/dist/components/Editor/components/Theme1UploadPanel.vue.d.ts +35 -0
- package/dist/components/Editor/composables/useBackgroundRemoval.d.ts +62 -0
- package/dist/components/Editor/composables/useBrushRefine.d.ts +31 -0
- package/dist/components/Editor/composables/useCanvasStateByDiecut.d.ts +8 -0
- package/dist/components/Editor/composables/useCanvasViewport.d.ts +1 -0
- package/dist/components/Editor/composables/useEmbroidery.d.ts +57 -0
- package/dist/components/Editor/composables/usePreviewManager.d.ts +516 -0
- package/dist/components/Editor/composables/usePreviewRenderer.d.ts +2 -0
- package/dist/components/Editor/headless/headlessFontLoader.d.ts +7 -0
- package/dist/components/Editor/index.vue.d.ts +7 -5
- package/dist/components/Editor/liveRender/types.d.ts +4 -0
- package/dist/components/Editor/utils/editorSizeOptions.d.ts +6 -0
- package/dist/components/Editor/utils/embroideryStitch.d.ts +25 -0
- package/dist/components/Editor/utils/pattern.d.ts +1 -1
- package/dist/components/Editor/utils/pillow3dPreview.d.ts +37 -0
- package/dist/components/Editor/workers/embroidery.worker.d.ts +47 -0
- package/dist/editor-sdk.es.js +44069 -40951
- package/dist/index.d.ts +6 -0
- package/dist/style.css +1 -1
- package/dist/types.d.ts +54 -0
- package/dist/utils/backgroundRenderer.d.ts +6 -3
- package/dist/utils/protection/encryptedModules.generated.d.ts +1 -1
- package/dist/utils/renderService/layerEffects.d.ts +148 -0
- package/dist/utils/renderService/types.d.ts +4 -0
- package/dist/utils/renderedImagesDB.d.ts +3 -0
- package/package.json +1 -1
|
@@ -209,6 +209,21 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
209
209
|
type: BooleanConstructor;
|
|
210
210
|
default: boolean;
|
|
211
211
|
};
|
|
212
|
+
/** 当前选中图层是否为图片(控制抠图按钮显示) */
|
|
213
|
+
activeLayerIsImage: {
|
|
214
|
+
type: BooleanConstructor;
|
|
215
|
+
default: boolean;
|
|
216
|
+
};
|
|
217
|
+
/** 抠图处理中:按钮 disabled + 显示 loading */
|
|
218
|
+
removeBgProcessing: {
|
|
219
|
+
type: BooleanConstructor;
|
|
220
|
+
default: boolean;
|
|
221
|
+
};
|
|
222
|
+
/** 是否显示「自动抠图」按钮(默认隐藏;第三方需显式开启) */
|
|
223
|
+
showBackgroundRemove: {
|
|
224
|
+
type: BooleanConstructor;
|
|
225
|
+
default: boolean;
|
|
226
|
+
};
|
|
212
227
|
/** actionId → 快捷键展示文案,用于图层工具 title */
|
|
213
228
|
shortcutKeys: {
|
|
214
229
|
type: PropType<Record<string, string>>;
|
|
@@ -234,6 +249,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
234
249
|
"apply-image-pattern": (...args: any[]) => void;
|
|
235
250
|
"update-image-pattern-scale": (...args: any[]) => void;
|
|
236
251
|
"crop-layer": (...args: any[]) => void;
|
|
252
|
+
"remove-bg-layer": (...args: any[]) => void;
|
|
237
253
|
"update:activeTab": (...args: any[]) => void;
|
|
238
254
|
"update:urlInput": (...args: any[]) => void;
|
|
239
255
|
"update:selectedProductIndex": (...args: any[]) => void;
|
|
@@ -452,6 +468,21 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
452
468
|
type: BooleanConstructor;
|
|
453
469
|
default: boolean;
|
|
454
470
|
};
|
|
471
|
+
/** 当前选中图层是否为图片(控制抠图按钮显示) */
|
|
472
|
+
activeLayerIsImage: {
|
|
473
|
+
type: BooleanConstructor;
|
|
474
|
+
default: boolean;
|
|
475
|
+
};
|
|
476
|
+
/** 抠图处理中:按钮 disabled + 显示 loading */
|
|
477
|
+
removeBgProcessing: {
|
|
478
|
+
type: BooleanConstructor;
|
|
479
|
+
default: boolean;
|
|
480
|
+
};
|
|
481
|
+
/** 是否显示「自动抠图」按钮(默认隐藏;第三方需显式开启) */
|
|
482
|
+
showBackgroundRemove: {
|
|
483
|
+
type: BooleanConstructor;
|
|
484
|
+
default: boolean;
|
|
485
|
+
};
|
|
455
486
|
/** actionId → 快捷键展示文案,用于图层工具 title */
|
|
456
487
|
shortcutKeys: {
|
|
457
488
|
type: PropType<Record<string, string>>;
|
|
@@ -477,6 +508,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
477
508
|
"onApply-image-pattern"?: ((...args: any[]) => any) | undefined;
|
|
478
509
|
"onUpdate-image-pattern-scale"?: ((...args: any[]) => any) | undefined;
|
|
479
510
|
"onCrop-layer"?: ((...args: any[]) => any) | undefined;
|
|
511
|
+
"onRemove-bg-layer"?: ((...args: any[]) => any) | undefined;
|
|
480
512
|
"onUpdate:activeTab"?: ((...args: any[]) => any) | undefined;
|
|
481
513
|
"onUpdate:urlInput"?: ((...args: any[]) => any) | undefined;
|
|
482
514
|
"onUpdate:selectedProductIndex"?: ((...args: any[]) => any) | undefined;
|
|
@@ -532,6 +564,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
532
564
|
imagePatternScale: number;
|
|
533
565
|
imagePatternScaleEnabled: boolean;
|
|
534
566
|
cropMode: boolean;
|
|
567
|
+
activeLayerIsImage: boolean;
|
|
568
|
+
removeBgProcessing: boolean;
|
|
569
|
+
showBackgroundRemove: boolean;
|
|
535
570
|
visibleTabs: string[];
|
|
536
571
|
showNav: boolean;
|
|
537
572
|
productTotal: number;
|
|
@@ -16,6 +16,16 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
16
16
|
type: BooleanConstructor;
|
|
17
17
|
default: boolean;
|
|
18
18
|
};
|
|
19
|
+
/** 特殊设计模式受控值:none|embroidery(刺绣)|pillow3d(异形抱枕),由父组件 specialMode 传入 */
|
|
20
|
+
specialMode: {
|
|
21
|
+
type: StringConstructor;
|
|
22
|
+
default: string;
|
|
23
|
+
};
|
|
24
|
+
/** 是否显示「刺绣 / 异形抱枕」互斥模式开关(default 与 theme1 均可显示) */
|
|
25
|
+
showSpecialMode: {
|
|
26
|
+
type: BooleanConstructor;
|
|
27
|
+
default: boolean;
|
|
28
|
+
};
|
|
19
29
|
colorOptions: {
|
|
20
30
|
type: PropType<string[]>;
|
|
21
31
|
default: () => never[];
|
|
@@ -154,6 +164,7 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
154
164
|
"toggle-grid": (...args: any[]) => void;
|
|
155
165
|
"clear-canvas": (...args: any[]) => void;
|
|
156
166
|
"clear-guides": (...args: any[]) => void;
|
|
167
|
+
"update:special-mode": (...args: any[]) => void;
|
|
157
168
|
"download-png": (...args: any[]) => void;
|
|
158
169
|
"switch-to-gallery": (...args: any[]) => void;
|
|
159
170
|
"open-shortcuts": (...args: any[]) => void;
|
|
@@ -174,6 +185,16 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
174
185
|
type: BooleanConstructor;
|
|
175
186
|
default: boolean;
|
|
176
187
|
};
|
|
188
|
+
/** 特殊设计模式受控值:none|embroidery(刺绣)|pillow3d(异形抱枕),由父组件 specialMode 传入 */
|
|
189
|
+
specialMode: {
|
|
190
|
+
type: StringConstructor;
|
|
191
|
+
default: string;
|
|
192
|
+
};
|
|
193
|
+
/** 是否显示「刺绣 / 异形抱枕」互斥模式开关(default 与 theme1 均可显示) */
|
|
194
|
+
showSpecialMode: {
|
|
195
|
+
type: BooleanConstructor;
|
|
196
|
+
default: boolean;
|
|
197
|
+
};
|
|
177
198
|
colorOptions: {
|
|
178
199
|
type: PropType<string[]>;
|
|
179
200
|
default: () => never[];
|
|
@@ -312,6 +333,7 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
312
333
|
"onToggle-grid"?: ((...args: any[]) => any) | undefined;
|
|
313
334
|
"onClear-canvas"?: ((...args: any[]) => any) | undefined;
|
|
314
335
|
"onClear-guides"?: ((...args: any[]) => any) | undefined;
|
|
336
|
+
"onUpdate:special-mode"?: ((...args: any[]) => any) | undefined;
|
|
315
337
|
"onDownload-png"?: ((...args: any[]) => any) | undefined;
|
|
316
338
|
"onSwitch-to-gallery"?: ((...args: any[]) => any) | undefined;
|
|
317
339
|
"onOpen-shortcuts"?: ((...args: any[]) => any) | undefined;
|
|
@@ -330,6 +352,8 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
330
352
|
sizeOptions: string[];
|
|
331
353
|
colorOptions: string[];
|
|
332
354
|
productName: string;
|
|
355
|
+
specialMode: string;
|
|
356
|
+
showSpecialMode: boolean;
|
|
333
357
|
colorLabelByValue: Record<string, string>;
|
|
334
358
|
multiSku: boolean;
|
|
335
359
|
selectedColors: string[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
/** useEmbroidery() 的返回对象 */
|
|
3
|
+
embroidery: any;
|
|
4
|
+
variant?: 'default' | 'theme1';
|
|
5
|
+
};
|
|
6
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
7
|
+
variant: "default" | "theme1";
|
|
8
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
export default _default;
|
|
@@ -364,6 +364,7 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
364
364
|
sizeOptions: string[];
|
|
365
365
|
colorOptions: string[];
|
|
366
366
|
colorLabelByValue: Record<string, string>;
|
|
367
|
+
variant: "default" | "theme1";
|
|
367
368
|
loadingDesign: boolean;
|
|
368
369
|
renderData: IRenderByJson | null;
|
|
369
370
|
previewTitle: string;
|
|
@@ -378,7 +379,6 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
378
379
|
getAllDiecutFabricData: () => Promise<Record<string, unknown>>;
|
|
379
380
|
usePreviewEffect: boolean;
|
|
380
381
|
showDownloadButton: boolean;
|
|
381
|
-
variant: "default" | "theme1";
|
|
382
382
|
mockupShowSave: boolean;
|
|
383
383
|
mockupShowCart: boolean;
|
|
384
384
|
backgroundRenderPaused: boolean;
|
|
@@ -40,6 +40,21 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
40
40
|
type: BooleanConstructor;
|
|
41
41
|
default: boolean;
|
|
42
42
|
};
|
|
43
|
+
/** 当前选中图层是否为图片(控制抠图按钮显示) */
|
|
44
|
+
activeLayerIsImage: {
|
|
45
|
+
type: BooleanConstructor;
|
|
46
|
+
default: boolean;
|
|
47
|
+
};
|
|
48
|
+
/** 抠图处理中:按钮 disabled + loading */
|
|
49
|
+
removeBgProcessing: {
|
|
50
|
+
type: BooleanConstructor;
|
|
51
|
+
default: boolean;
|
|
52
|
+
};
|
|
53
|
+
/** 是否显示「自动抠图」按钮(默认隐藏;第三方需显式开启) */
|
|
54
|
+
showBackgroundRemove: {
|
|
55
|
+
type: BooleanConstructor;
|
|
56
|
+
default: boolean;
|
|
57
|
+
};
|
|
43
58
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
44
59
|
"move-layer-by-id": (...args: any[]) => void;
|
|
45
60
|
"duplicate-layer": (...args: any[]) => void;
|
|
@@ -52,6 +67,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
52
67
|
"apply-image-pattern": (...args: any[]) => void;
|
|
53
68
|
"update-image-pattern-scale": (...args: any[]) => void;
|
|
54
69
|
"crop-layer": (...args: any[]) => void;
|
|
70
|
+
"remove-bg-layer": (...args: any[]) => void;
|
|
55
71
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
56
72
|
readOnly: {
|
|
57
73
|
type: BooleanConstructor;
|
|
@@ -93,6 +109,21 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
93
109
|
type: BooleanConstructor;
|
|
94
110
|
default: boolean;
|
|
95
111
|
};
|
|
112
|
+
/** 当前选中图层是否为图片(控制抠图按钮显示) */
|
|
113
|
+
activeLayerIsImage: {
|
|
114
|
+
type: BooleanConstructor;
|
|
115
|
+
default: boolean;
|
|
116
|
+
};
|
|
117
|
+
/** 抠图处理中:按钮 disabled + loading */
|
|
118
|
+
removeBgProcessing: {
|
|
119
|
+
type: BooleanConstructor;
|
|
120
|
+
default: boolean;
|
|
121
|
+
};
|
|
122
|
+
/** 是否显示「自动抠图」按钮(默认隐藏;第三方需显式开启) */
|
|
123
|
+
showBackgroundRemove: {
|
|
124
|
+
type: BooleanConstructor;
|
|
125
|
+
default: boolean;
|
|
126
|
+
};
|
|
96
127
|
}>> & Readonly<{
|
|
97
128
|
"onMove-layer-by-id"?: ((...args: any[]) => any) | undefined;
|
|
98
129
|
"onDuplicate-layer"?: ((...args: any[]) => any) | undefined;
|
|
@@ -105,6 +136,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
105
136
|
"onApply-image-pattern"?: ((...args: any[]) => any) | undefined;
|
|
106
137
|
"onUpdate-image-pattern-scale"?: ((...args: any[]) => any) | undefined;
|
|
107
138
|
"onCrop-layer"?: ((...args: any[]) => any) | undefined;
|
|
139
|
+
"onRemove-bg-layer"?: ((...args: any[]) => any) | undefined;
|
|
108
140
|
}>, {
|
|
109
141
|
activeLayerId: string | number | null;
|
|
110
142
|
readOnly: boolean;
|
|
@@ -116,5 +148,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
116
148
|
imagePatternScale: number;
|
|
117
149
|
imagePatternScaleEnabled: boolean;
|
|
118
150
|
cropMode: boolean;
|
|
151
|
+
activeLayerIsImage: boolean;
|
|
152
|
+
removeBgProcessing: boolean;
|
|
153
|
+
showBackgroundRemove: boolean;
|
|
119
154
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
120
155
|
export default _default;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export type RemoveBackgroundProgress = {
|
|
2
|
+
/** 0-1,模型下载阶段;推理阶段 imgly 不再回调 */
|
|
3
|
+
ratio: number;
|
|
4
|
+
/** 'fetch' | 'compute' */
|
|
5
|
+
phase: 'fetch' | 'compute';
|
|
6
|
+
message?: string;
|
|
7
|
+
};
|
|
8
|
+
export interface UseBackgroundRemovalOptions {
|
|
9
|
+
/**
|
|
10
|
+
* 模型/wasm 加载基础路径。默认走 @imgly 官方 CDN(staticimgly.com),
|
|
11
|
+
* 国内可指向本地 public 目录(如 '/imgly/dist/')或自家 OSS。
|
|
12
|
+
* 相对路径会按当前 origin 解析为绝对 URL,确保 imgly 的 `new URL(chunk, publicPath)` 拼接成功。
|
|
13
|
+
*/
|
|
14
|
+
publicPath?: string;
|
|
15
|
+
/**
|
|
16
|
+
* 模型变体(@imgly 1.7.0,与本地自托管 data 配套):'isnet_fp16'(84MB,质量最好) / 'isnet_quint8'(42MB,体积小一半) / 'isnet'。
|
|
17
|
+
* 默认 'isnet_quint8'。
|
|
18
|
+
*/
|
|
19
|
+
model?: 'isnet' | 'isnet_fp16' | 'isnet_quint8';
|
|
20
|
+
/**
|
|
21
|
+
* 客户端模式:@imgly ESM 运行时的加载 URL(默认 jsdelivr CDN)。
|
|
22
|
+
* 关键:通过 `import(/* @vite-ignore */ url)` 运行时加载,**ort 运行时不会被打进 SDK 包**(包体 -125MB)。
|
|
23
|
+
* 自建场景可指向自家 CDN/OSS 上托管的 @imgly ESM 产物。
|
|
24
|
+
*/
|
|
25
|
+
cdnUrl?: string;
|
|
26
|
+
/**
|
|
27
|
+
* 服务端抠图提供者。**传入则用它替代客户端 ONNX 推理**——不加载 @imgly、不跑本地模型,SDK 最轻。
|
|
28
|
+
* 入参为原图 Blob,返回去背景后的图(Blob 或可 fetch 的 URL)。
|
|
29
|
+
*/
|
|
30
|
+
provider?: (input: Blob) => Promise<Blob | string>;
|
|
31
|
+
}
|
|
32
|
+
export type OpaqueBoundingBox = {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
w: number;
|
|
36
|
+
h: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* 扫描透明通道,把图像裁切到 alpha>0 像素的外接矩形。
|
|
40
|
+
* - 全透明:返回 null
|
|
41
|
+
* - bbox 已接近全图:返回 fullSize=true
|
|
42
|
+
*/
|
|
43
|
+
export declare function cropBlobToOpaqueBoundingBox(blob: Blob, alphaThreshold?: number): Promise<{
|
|
44
|
+
blob: Blob;
|
|
45
|
+
bbox: OpaqueBoundingBox;
|
|
46
|
+
fullSize: boolean;
|
|
47
|
+
} | null>;
|
|
48
|
+
export declare function useBackgroundRemoval(options?: UseBackgroundRemovalOptions): {
|
|
49
|
+
isProcessing: import("vue").Ref<boolean, boolean>;
|
|
50
|
+
lastError: import("vue").Ref<string | null, string | null>;
|
|
51
|
+
progress: import("vue").Ref<{
|
|
52
|
+
ratio: number;
|
|
53
|
+
phase: "fetch" | "compute";
|
|
54
|
+
message?: string | undefined;
|
|
55
|
+
} | null, RemoveBackgroundProgress | {
|
|
56
|
+
ratio: number;
|
|
57
|
+
phase: "fetch" | "compute";
|
|
58
|
+
message?: string | undefined;
|
|
59
|
+
} | null>;
|
|
60
|
+
modelLoaded: import("vue").Ref<boolean, boolean>;
|
|
61
|
+
removeBackground: (input: Blob | string) => Promise<Blob | null>;
|
|
62
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type BrushMode = 'erase' | 'restore';
|
|
2
|
+
export interface UseBrushRefineOptions {
|
|
3
|
+
/** Fabric Canvas 实例提供者 */
|
|
4
|
+
getCanvas: () => any | null;
|
|
5
|
+
/**
|
|
6
|
+
* 退出(无论 commit / cancel)时调用,父组件可用于刷新预览等。
|
|
7
|
+
* 第二个参数为本次涂抹的目标 fabric 对象(退出时其 element 已 commit),
|
|
8
|
+
* 供父组件做结果图上传 / savedSrc 持久化(此时内部 targetObj 已清空)。
|
|
9
|
+
*/
|
|
10
|
+
onExit?: (committed: boolean, obj: any | null) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function useBrushRefine(options: UseBrushRefineOptions): {
|
|
13
|
+
isActive: import("vue").Ref<boolean, boolean>;
|
|
14
|
+
brushSize: import("vue").Ref<number, number>;
|
|
15
|
+
brushMode: import("vue").Ref<BrushMode, BrushMode>;
|
|
16
|
+
hasSourceImage: import("vue").Ref<boolean, boolean>;
|
|
17
|
+
strokeEnabled: import("vue").Ref<boolean, boolean>;
|
|
18
|
+
strokeWidth: import("vue").Ref<number, number>;
|
|
19
|
+
strokeGap: import("vue").Ref<number, number>;
|
|
20
|
+
strokeColor: import("vue").Ref<string, string>;
|
|
21
|
+
targetObj: import("vue").ShallowRef<any, any>;
|
|
22
|
+
enter: (obj: any, initElement?: HTMLImageElement | HTMLCanvasElement, srcImage?: HTMLImageElement | HTMLCanvasElement | null) => boolean;
|
|
23
|
+
exit: (commit?: boolean) => Promise<void>;
|
|
24
|
+
undo: () => void;
|
|
25
|
+
setBrushSize: (v: number) => void;
|
|
26
|
+
setBrushMode: (m: BrushMode) => void;
|
|
27
|
+
setStrokeEnabled: (v: boolean) => void;
|
|
28
|
+
setStrokeWidth: (v: number) => void;
|
|
29
|
+
setStrokeGap: (v: number) => void;
|
|
30
|
+
setStrokeColor: (v: string) => void;
|
|
31
|
+
};
|
|
@@ -22,6 +22,14 @@ export interface CanvasStateOptions {
|
|
|
22
22
|
getSelectedSize?: () => string;
|
|
23
23
|
/** 加载 JSON 完成后调用,用于从 customData 重建图案矩形 fill(Fabric 序列化会丢失 Pattern source) */
|
|
24
24
|
afterLoadCanvasJson?: (canvas: any) => void | Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* restore(loadFromJSON)完成、onDone 末尾触发:按存档画布尺寸重算对象坐标到当前画布尺寸。
|
|
27
|
+
* 参数 savedCanvasWidth = 存档时的画布逻辑宽度(state.designCanvasSize)。
|
|
28
|
+
* 根因:存档 json 无原生 width/height,loadFromJSON 不改画布尺寸(画布尺寸由容器决定),
|
|
29
|
+
* 故 objects 的 left/top(存档尺寸下的绝对像素)与「当前容器尺寸」画布不匹配 → 整体平移。
|
|
30
|
+
* 详见 viewport-restore-realign-design.md。
|
|
31
|
+
*/
|
|
32
|
+
onAfterRestore?: (savedCanvasWidth: number) => void | Promise<void>;
|
|
25
33
|
/** 将 HTTP 图片 URL 解析为 blob URL(通过 fetchWithFileToken 加载),用于 loadFromJSON 前预处理 */
|
|
26
34
|
resolveImageUrl?: (url: string) => Promise<string>;
|
|
27
35
|
}
|
|
@@ -70,6 +70,7 @@ export declare function useCanvasViewport(options: CanvasViewportOptions): {
|
|
|
70
70
|
zoomOut: () => void;
|
|
71
71
|
fitCanvas: () => void;
|
|
72
72
|
handleWrapResize: () => void;
|
|
73
|
+
rescaleObjectsFromSavedSize: (savedWidth: number) => void;
|
|
73
74
|
refreshGuideResourcesCentered: () => void;
|
|
74
75
|
setupWindowResize: () => void;
|
|
75
76
|
removeWindowResize: () => void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type StitchKey } from '../utils/embroideryStitch';
|
|
2
|
+
type RGB = [number, number, number];
|
|
3
|
+
export interface EmbroideryRegion {
|
|
4
|
+
id: number;
|
|
5
|
+
clusterIdx: number;
|
|
6
|
+
color: RGB;
|
|
7
|
+
area: number;
|
|
8
|
+
bbox: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
w: number;
|
|
12
|
+
h: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export type EmbroideryStitchKey = StitchKey;
|
|
16
|
+
/** 针法清单(移植自 Ink/Stitch 可纹理化的部分)。 */
|
|
17
|
+
export declare const EMBROIDERY_STITCH_TYPES: ReadonlyArray<{
|
|
18
|
+
key: EmbroideryStitchKey;
|
|
19
|
+
label: string;
|
|
20
|
+
}>;
|
|
21
|
+
export interface UseEmbroideryOptions {
|
|
22
|
+
/** 取 Fabric 画布实例 */
|
|
23
|
+
getCanvas: () => any;
|
|
24
|
+
/** 工作尺寸上限(长边像素),超过则缩放后处理,默认 1000 */
|
|
25
|
+
maxWorkSize?: number;
|
|
26
|
+
}
|
|
27
|
+
export declare function useEmbroidery(options: UseEmbroideryOptions): {
|
|
28
|
+
isActive: import("vue").Ref<boolean, boolean>;
|
|
29
|
+
isProcessing: import("vue").Ref<boolean, boolean>;
|
|
30
|
+
error: import("vue").Ref<string | null, string | null>;
|
|
31
|
+
colorCount: import("vue").Ref<number, number>;
|
|
32
|
+
mergeColorDist: import("vue").Ref<number, number>;
|
|
33
|
+
palette: import("vue").Ref<[number, number, number][], RGB[] | [number, number, number][]>;
|
|
34
|
+
regions: import("vue").ShallowRef<EmbroideryRegion[], EmbroideryRegion[]>;
|
|
35
|
+
regionCount: import("vue").Ref<number, number>;
|
|
36
|
+
regionStitch: import("vue").Ref<Record<number, StitchKey>, Record<number, StitchKey>>;
|
|
37
|
+
regionParams: import("vue").Ref<Record<number, {
|
|
38
|
+
spacing?: number;
|
|
39
|
+
angle?: number;
|
|
40
|
+
}>, Record<number, {
|
|
41
|
+
spacing?: number;
|
|
42
|
+
angle?: number;
|
|
43
|
+
}>>;
|
|
44
|
+
selectedRegionId: import("vue").Ref<number | null, number | null>;
|
|
45
|
+
activate: () => Promise<boolean>;
|
|
46
|
+
deactivate: () => Promise<void>;
|
|
47
|
+
setColorCount: (k: number) => Promise<void>;
|
|
48
|
+
selectRegion: (regionId: number) => void;
|
|
49
|
+
setRegionStitch: (regionId: number, type: EmbroideryStitchKey) => void;
|
|
50
|
+
setRegionParams: (regionId: number, patch: {
|
|
51
|
+
spacing?: number;
|
|
52
|
+
angle?: number;
|
|
53
|
+
}) => void;
|
|
54
|
+
getEmbroideryData: () => Record<string, unknown> | null;
|
|
55
|
+
dispose: () => void;
|
|
56
|
+
};
|
|
57
|
+
export {};
|