@jetprint/editor-sdk 1.0.5 → 1.0.6

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.
@@ -101,6 +101,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
101
101
  type: BooleanConstructor;
102
102
  default: boolean;
103
103
  };
104
+ /** 「查看大图」预览(单图大图 / theme1 mockup 画廊)打开时为 true:隐藏选中悬浮键,避免叠在大图上 */
105
+ previewOverlayOpen: {
106
+ type: BooleanConstructor;
107
+ default: boolean;
108
+ };
104
109
  /** default 主题标尺:Fabric 实例(由 Editor 传入) */
105
110
  getFabricCanvas: {
106
111
  type: PropType<() => FabricCanvas | null>;
@@ -205,6 +210,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
205
210
  type: BooleanConstructor;
206
211
  default: boolean;
207
212
  };
213
+ /** 「查看大图」预览(单图大图 / theme1 mockup 画廊)打开时为 true:隐藏选中悬浮键,避免叠在大图上 */
214
+ previewOverlayOpen: {
215
+ type: BooleanConstructor;
216
+ default: boolean;
217
+ };
208
218
  /** default 主题标尺:Fabric 实例(由 Editor 传入) */
209
219
  getFabricCanvas: {
210
220
  type: PropType<() => FabricCanvas | null>;
@@ -249,5 +259,6 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
249
259
  copying: boolean;
250
260
  loadingDesign: boolean;
251
261
  modeSwitchDisabled: boolean;
262
+ previewOverlayOpen: boolean;
252
263
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
253
264
  export default _default;
@@ -142,7 +142,13 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
142
142
  * 给定尺码/颜色集合,返回每张成品效果图 { size, color, index(模板序号), blob }。
143
143
  */
144
144
  renderEffectImages: {
145
- type: PropType<(sizes: string[], colors: string[]) => Promise<Array<{
145
+ type: PropType<(sizes: string[], colors: string[], onImage?: (img: {
146
+ size: string;
147
+ color: string;
148
+ index: number;
149
+ name?: string;
150
+ blob: Blob;
151
+ }) => void) => Promise<Array<{
146
152
  size: string;
147
153
  color: string;
148
154
  index: number;
@@ -175,6 +181,7 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
175
181
  "toggle-preview-render-mode": (...args: any[]) => void;
176
182
  "request-save-design": (...args: any[]) => void;
177
183
  "request-add-to-cart": (...args: any[]) => void;
184
+ "preview-overlay-change": (...args: any[]) => void;
178
185
  "update:theme1LayersExpanded": (value: boolean) => void;
179
186
  "update:theme1PreviewExpanded": (value: boolean) => void;
180
187
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
@@ -306,7 +313,13 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
306
313
  * 给定尺码/颜色集合,返回每张成品效果图 { size, color, index(模板序号), blob }。
307
314
  */
308
315
  renderEffectImages: {
309
- type: PropType<(sizes: string[], colors: string[]) => Promise<Array<{
316
+ type: PropType<(sizes: string[], colors: string[], onImage?: (img: {
317
+ size: string;
318
+ color: string;
319
+ index: number;
320
+ name?: string;
321
+ blob: Blob;
322
+ }) => void) => Promise<Array<{
310
323
  size: string;
311
324
  color: string;
312
325
  index: number;
@@ -331,6 +344,7 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
331
344
  "onToggle-preview-render-mode"?: ((...args: any[]) => any) | undefined;
332
345
  "onRequest-save-design"?: ((...args: any[]) => any) | undefined;
333
346
  "onRequest-add-to-cart"?: ((...args: any[]) => any) | undefined;
347
+ "onPreview-overlay-change"?: ((...args: any[]) => any) | undefined;
334
348
  "onUpdate:theme1LayersExpanded"?: ((value: boolean) => any) | undefined;
335
349
  "onUpdate:theme1PreviewExpanded"?: ((value: boolean) => any) | undefined;
336
350
  }>, {
@@ -363,7 +377,13 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
363
377
  liveWebglInternalRenderSize: number;
364
378
  designedSizes: string[];
365
379
  isPerSizeDesign: boolean;
366
- renderEffectImages: (sizes: string[], colors: string[]) => Promise<Array<{
380
+ renderEffectImages: (sizes: string[], colors: string[], onImage?: (img: {
381
+ size: string;
382
+ color: string;
383
+ index: number;
384
+ name?: string;
385
+ blob: Blob;
386
+ }) => void) => Promise<Array<{
367
387
  size: string;
368
388
  color: string;
369
389
  index: number;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * approach B 生产图拼贴(SDK 自包含渲染器内部层):把每分片印刷位图按 productJson 槽位 cover 拼成生产图。
3
+ * 移植自手工镜像 editor-preview.html 的 composeProductionImageToBlob(非 fabricDirect 分支)——拼贴层本就稳定无 bug,
4
+ * 喂入的是真实 SDK 渲染的分片位图。按分片 name 映射(回退 id),不依赖 guideline 中转。
5
+ */
6
+ export interface FabricScreenshotItem {
7
+ id: number | string;
8
+ name?: string;
9
+ blob: Blob;
10
+ }
11
+ export interface PartBounds {
12
+ left: number;
13
+ top: number;
14
+ width: number;
15
+ height: number;
16
+ }
17
+ export interface SplitChild {
18
+ id: number;
19
+ name: string;
20
+ bounds: PartBounds;
21
+ }
22
+ export interface ComposeResult {
23
+ blob: Blob;
24
+ canvasWidth: number;
25
+ canvasHeight: number;
26
+ drawn: string[];
27
+ skipped: string[];
28
+ }
29
+ export declare function getSplitChildrenWithBounds(layerList: any[], layerName?: string): SplitChild[];
30
+ /**
31
+ * @param fabricScreenshotList 每分片印刷位图({id,name,blob})
32
+ * @param productJson 生产图布局:{ canvasWidth, canvasHeight?, layerList(含 split 分组 bounds) }
33
+ */
34
+ export declare function composeProductionImage(fabricScreenshotList: FabricScreenshotItem[], productJson: any, format?: 'png' | 'jpeg'): Promise<ComposeResult>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 无头生产图渲染 —— 独立打包入口(自包含:内联 Fabric,不含 Vue/编辑器)。
3
+ *
4
+ * 构建产物 `dist/headless.global.js` 暴露 `window.generateProductionImage`,供 Go 切图服务的无头 host 页
5
+ * 在 chromedp 中加载调用:
6
+ * window.generateProductionImage({ fabricJson, productJson, fileToken, size, imageFormat }) → Promise<Blob>
7
+ *
8
+ * 是 @jetprint/editor-sdk 包的一部分(随 SDK 版本同步),Go 侧 `npm i @jetprint/editor-sdk` 后 go:embed 此文件即可。
9
+ */
10
+ import { generateProductionImage, type GenerateProductionImageInput } from './productionRender';
11
+ declare global {
12
+ interface Window {
13
+ generateProductionImage?: (input: GenerateProductionImageInput) => Promise<Blob>;
14
+ }
15
+ }
16
+ export { generateProductionImage };
17
+ export type { GenerateProductionImageInput };
@@ -0,0 +1,47 @@
1
+ import { type FabricScreenshotItem } from './composeProductionImage';
2
+ export interface GenerateProductionImageInput {
3
+ /** 保存的画布 JSON:URL 字符串 或 已解析对象 */
4
+ fabricJson: string | Record<string, unknown>;
5
+ /** 生产图布局 JSON:URL 字符串 或 已解析对象 */
6
+ productJson: string | Record<string, unknown>;
7
+ /** 资源访问 token(拼到 img.r480.cn 等资源 URL) */
8
+ fileToken?: string;
9
+ /** 要渲染的尺码(多尺码必传;旧单尺码/COMMON 可空) */
10
+ size?: string;
11
+ /** 输出格式,默认 png */
12
+ imageFormat?: 'png' | 'jpeg';
13
+ /**
14
+ * 调试:整稿还原模式(复用旧 ?fabric_direct=1 链路)。true 时每分片只做 fabric 还原,
15
+ * 跳过刀模 MASK 与裁切,按分片画布原样拼贴 —— 用于在切图前核对图层还原是否正确。
16
+ */
17
+ fabricDirect?: boolean;
18
+ }
19
+ /** 一个待渲染分片:设计状态 + 该分片保存时画布尺寸 + 刀模/引导信息 */
20
+ export interface DiecutPieceRenderTask {
21
+ /** 分片 groupId(与 productJson 槽位按 name/id 对应) */
22
+ groupId: string;
23
+ name: string;
24
+ /** 该分片的设计状态(fabric stateMap entry:{version, objects, ...}) */
25
+ state: Record<string, unknown>;
26
+ /** 该分片保存时的画布逻辑宽高(新格式每分片自带;旧格式回退顶层/默认) */
27
+ savedCanvasW: number;
28
+ savedCanvasH: number;
29
+ /** 该分片对应的刀模资源(MASK / DOTTED_LINE 等,含 url/width/height) */
30
+ resources: any[];
31
+ /** 该尺码刀模模板的 guideline(PSD 结构,含 split 分片 bounds),用于裁切几何 */
32
+ guideline: any;
33
+ }
34
+ /**
35
+ * 解析 fabricJson 并按 size 取该尺码各分片的渲染任务。兼容新/旧格式:
36
+ * - stateMap 键:新=`${groupId}::${size}` 复合键;旧=裸 `${groupId}`(单尺码)。
37
+ * - 每分片画布尺寸:新=entry.designCanvasSize/Height;旧=回退顶层 designCanvasSize/Height,再回退默认。
38
+ * - data[]:按 size 取该尺码的刀模模板(含内联 guideline 与 resources);旧=default/COMMON。
39
+ */
40
+ export declare function resolveSizePieceTasks(fabric: any, mode: 'COMPLETE' | 'SPLIT', size?: string): DiecutPieceRenderTask[];
41
+ /**
42
+ * 每个分片离屏还原 → 应用刀模 mask → 裁切 → 印刷位图。复用 SDK 真实渲染核心(PatternLayer)+ 每分片画布尺寸(免缩放)。
43
+ * 注:当前为 SPLIT 单片路径(每 task=一分片)。COMPLETE 单稿→多分片裁切为下一步。
44
+ */
45
+ export declare function renderDiecutPieceBitmaps(tasks: DiecutPieceRenderTask[], fileToken?: string, restoreOnly?: boolean): Promise<FabricScreenshotItem[]>;
46
+ /** 自包含生产图:解析 → 每分片渲染 → productJson 拼贴。 */
47
+ export declare function generateProductionImage(input: GenerateProductionImageInput): Promise<Blob>;
@@ -42,15 +42,15 @@ type EditorProps = {
42
42
  /** 左侧栏额外 Tab(竖条 + 内容区由宿主传入 Vue 组件) */
43
43
  customSidebarTabs?: CustomSidebarTabDef[];
44
44
  };
45
- declare var __VLS_21: {}, __VLS_27: {}, __VLS_134: {}, __VLS_140: {};
45
+ declare var __VLS_21: {}, __VLS_27: {}, __VLS_135: {}, __VLS_141: {};
46
46
  type __VLS_Slots = {} & {
47
47
  'topbar-left'?: (props: typeof __VLS_21) => any;
48
48
  } & {
49
49
  'topbar-right'?: (props: typeof __VLS_27) => any;
50
50
  } & {
51
- 'topbar-left'?: (props: typeof __VLS_134) => any;
51
+ 'topbar-left'?: (props: typeof __VLS_135) => any;
52
52
  } & {
53
- 'topbar-right'?: (props: typeof __VLS_140) => any;
53
+ 'topbar-right'?: (props: typeof __VLS_141) => any;
54
54
  };
55
55
  declare const __VLS_component: import("vue").DefineComponent<EditorProps, {
56
56
  renderAllTemplates: () => Promise<Array<{
@@ -66,7 +66,13 @@ declare const __VLS_component: import("vue").DefineComponent<EditorProps, {
66
66
  color: string;
67
67
  bundle: any;
68
68
  }>>;
69
- renderEffectImagesForSizesColors: (sizes?: string[], colors?: string[]) => Promise<Array<{
69
+ renderEffectImagesForSizesColors: (sizes?: string[], colors?: string[], onImage?: (img: {
70
+ size: string;
71
+ color: string;
72
+ index: number;
73
+ name?: string;
74
+ blob: Blob;
75
+ }) => void) => Promise<Array<{
70
76
  size: string;
71
77
  color: string;
72
78
  index: number;