@worm-vue3-print/core 1.2.2 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -7
- package/dist/browser/index.cjs +2338 -340
- package/dist/browser/index.d.cts +79 -6
- package/dist/browser/index.d.ts +79 -6
- package/dist/browser/index.js +283 -128
- package/dist/{chunk-HLCZHPUF.js → chunk-AKWV6SID.js} +1 -1
- package/dist/chunk-KFRPTLFV.js +3819 -0
- package/dist/client/index.cjs +381 -0
- package/dist/client/index.d.cts +241 -0
- package/dist/client/index.d.ts +241 -0
- package/dist/client/index.js +346 -0
- package/dist/designer/index.cjs +429 -22
- package/dist/designer/index.d.cts +100 -289
- package/dist/designer/index.d.ts +100 -289
- package/dist/designer/index.js +147 -26
- package/dist/dom-executor.iife.global.js +8 -0
- package/dist/driver-Dn_YAzO5.d.cts +935 -0
- package/dist/driver-Dn_YAzO5.d.ts +935 -0
- package/dist/index.cjs +2226 -163
- package/dist/index.d.cts +374 -6
- package/dist/index.d.ts +374 -6
- package/dist/index.js +180 -4
- package/dist/node/index.cjs +41 -0
- package/dist/node/index.d.cts +6 -0
- package/dist/node/index.d.ts +6 -0
- package/dist/node/index.js +10 -0
- package/dist/ports-BvwlA_km.d.ts +102 -0
- package/dist/ports-Cf5sjwls.d.cts +102 -0
- package/package.json +13 -2
- package/dist/chunk-JZIVNXZ7.js +0 -1777
- package/dist/types-BGBAbQD5.d.cts +0 -184
- package/dist/types-BGBAbQD5.d.ts +0 -184
|
@@ -0,0 +1,935 @@
|
|
|
1
|
+
/** 拼版配置(模板级,随模板保存) */
|
|
2
|
+
interface TilingOptions {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
/** 目标纸张(张)预设;缺省 A4。不含 CONTINUOUS */
|
|
5
|
+
sheetPaperSize?: Exclude<PaperSize, 'CONTINUOUS'>;
|
|
6
|
+
/** 目标纸张方向;缺省 portrait。只影响目标纸,不影响标签朝向 */
|
|
7
|
+
sheetOrientation?: 'portrait' | 'landscape';
|
|
8
|
+
/** sheetPaperSize='CUSTOM' 时的纸宽(mm);缺省 210 */
|
|
9
|
+
sheetCustomWidth?: number;
|
|
10
|
+
/** sheetPaperSize='CUSTOM' 时的纸高(mm);缺省 297 */
|
|
11
|
+
sheetCustomHeight?: number;
|
|
12
|
+
/** 目标纸四边留白(mm);与模板 margins(标签内部边距)不是一回事 */
|
|
13
|
+
sheetMargin: {
|
|
14
|
+
top: number;
|
|
15
|
+
right: number;
|
|
16
|
+
bottom: number;
|
|
17
|
+
left: number;
|
|
18
|
+
};
|
|
19
|
+
/** 相邻格横向间距(mm) */
|
|
20
|
+
gapX: number;
|
|
21
|
+
/** 相邻格纵向间距(mm) */
|
|
22
|
+
gapY: number;
|
|
23
|
+
/** 列数(手工指定,必填,≥1 的整数);行数由纸面自动推导 */
|
|
24
|
+
columns: number;
|
|
25
|
+
}
|
|
26
|
+
/** 打开拼版开关时的初值(列数还会按纸面收敛,见设计器 TilingConfig) */
|
|
27
|
+
declare const TILE_DEFAULTS: TilingOptions;
|
|
28
|
+
/**
|
|
29
|
+
* 拼版几何所需的最小模板信息。
|
|
30
|
+
* 刻意不含 elements——布局只依赖纸张与拼版配置,因此设计器侧(元素 id 可选)
|
|
31
|
+
* 与渲染侧(元素 id 必需)两种 TemplateData 都能直接传入。
|
|
32
|
+
*/
|
|
33
|
+
interface TilingTemplateInput {
|
|
34
|
+
paperSize: PaperSize;
|
|
35
|
+
orientation: 'portrait' | 'landscape';
|
|
36
|
+
customWidth?: number;
|
|
37
|
+
customHeight?: number;
|
|
38
|
+
tiling?: TilingOptions;
|
|
39
|
+
}
|
|
40
|
+
type TilingIssueCode = 'COLUMNS_INVALID' | 'COLUMNS_OVERFLOW' | 'SHEET_SIZE_INVALID' | 'LABEL_TOO_TALL' | 'CONTINUOUS_UNSUPPORTED' | 'SHEET_CONTINUOUS';
|
|
41
|
+
interface TilingIssue {
|
|
42
|
+
code: TilingIssueCode;
|
|
43
|
+
message: string;
|
|
44
|
+
}
|
|
45
|
+
interface TilingResolveOptions {
|
|
46
|
+
paperOverride?: {
|
|
47
|
+
width?: number;
|
|
48
|
+
height?: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
interface TileLayout {
|
|
52
|
+
tile: {
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
};
|
|
56
|
+
sheet: {
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
};
|
|
60
|
+
columns: number;
|
|
61
|
+
rows: number;
|
|
62
|
+
perSheet: number;
|
|
63
|
+
/** 本纸最多可放列数;列数超宽时用于提示「最多可放 N 列」 */
|
|
64
|
+
maxColumns: number;
|
|
65
|
+
margin: {
|
|
66
|
+
top: number;
|
|
67
|
+
right: number;
|
|
68
|
+
bottom: number;
|
|
69
|
+
left: number;
|
|
70
|
+
};
|
|
71
|
+
gapX: number;
|
|
72
|
+
gapY: number;
|
|
73
|
+
}
|
|
74
|
+
/** 拼版校验失败(message 与 validateTiling 首条 issue 完全一致) */
|
|
75
|
+
declare class TilingError extends Error {
|
|
76
|
+
readonly code: TilingIssueCode;
|
|
77
|
+
constructor(code: TilingIssueCode, message: string);
|
|
78
|
+
}
|
|
79
|
+
/** 保留一位小数:错误文案里的 mm 值可读性 */
|
|
80
|
+
declare function roundMm(value: number): number;
|
|
81
|
+
/** 配置归一化:缺省字段补 TILE_DEFAULTS,sheetMargin 做深合并 */
|
|
82
|
+
declare function normalizeTilingOptions(t: TilingTemplateInput): TilingOptions;
|
|
83
|
+
/** 目标纸张解析;优先级:paperOverride → CUSTOM 自定义宽高 → 预设 → 缺省 A4 纵向 */
|
|
84
|
+
declare function resolveSheetMm(t: TilingTemplateInput, opts?: TilingResolveOptions): {
|
|
85
|
+
width: number;
|
|
86
|
+
height: number;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* 拼版布局(纯函数)。调用方负责判断 enabled——本函数不做开关判断:
|
|
90
|
+
* 管线在分流后调用、设计器在开关打开时调用。
|
|
91
|
+
* 配置非法时抛 TilingError,message 与 validateTiling 首条 issue 一致。
|
|
92
|
+
*/
|
|
93
|
+
declare function computeTileLayout(t: TilingTemplateInput, opts?: TilingResolveOptions): TileLayout;
|
|
94
|
+
/** 第 index 格的绝对位置(mm);行优先:左→右、上→下 */
|
|
95
|
+
declare function tilePosition(layout: TileLayout, index: number): {
|
|
96
|
+
left: number;
|
|
97
|
+
top: number;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* 本纸最多可放列数(纯几何,**不校验、不抛错**)。
|
|
101
|
+
* 供设计器在「列数已超宽」的非法态下仍能提示「最多可放 N 列」并约束输入上限——
|
|
102
|
+
* 此时 computeTileLayout 会抛错,用不了。
|
|
103
|
+
*/
|
|
104
|
+
declare function computeMaxColumns(t: TilingTemplateInput, opts?: TilingResolveOptions): number;
|
|
105
|
+
/**
|
|
106
|
+
* 拼版配置校验;永不抛错,合法返回 []。
|
|
107
|
+
* 判定顺序:纸面类 → 列数类 → 高度类(设计文档 §9)。
|
|
108
|
+
* 不检查 enabled——由调用方决定是否校验。
|
|
109
|
+
*/
|
|
110
|
+
declare function validateTiling(t: TilingTemplateInput, opts?: TilingResolveOptions): TilingIssue[];
|
|
111
|
+
|
|
112
|
+
/** 模板声明的字体文件:`url` 以 '/' 开头时按渲染端 baseUrl 解析,绝对 URL 原样使用 */
|
|
113
|
+
interface PrintFontFile {
|
|
114
|
+
url: string;
|
|
115
|
+
/** CSS 字重;缺省 400。必须与模板里元素实际使用的字重一致,否则 Chromium 会合成粗体(度量不同) */
|
|
116
|
+
weight?: number;
|
|
117
|
+
/** CSS 字型;缺省 normal */
|
|
118
|
+
style?: 'normal' | 'italic';
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* 模板级字体声明:随模板保存,服务端/客户端/浏览器据此生成同一份 @font-face,
|
|
122
|
+
* 从而不依赖各端系统里装了什么字体。
|
|
123
|
+
*/
|
|
124
|
+
interface PrintFontDeclaration {
|
|
125
|
+
/** CSS 族名,必须与元素 options.fontFamily 的写法一致 */
|
|
126
|
+
family: string;
|
|
127
|
+
/** 设计器下拉里的显示名;缺省用 family */
|
|
128
|
+
label?: string;
|
|
129
|
+
files: readonly PrintFontFile[];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 生成模板声明字体的 @font-face CSS。
|
|
133
|
+
*
|
|
134
|
+
* - `font-display: block`:测量与出图期间绝不能用兜底字体顶上,否则分页按兜底度量算。
|
|
135
|
+
* - 无声明或声明不合法(无族名/无可用 url)时返回空串,调用方可直接拼接。
|
|
136
|
+
*/
|
|
137
|
+
declare function buildFontFaceCss(fonts?: readonly PrintFontDeclaration[]): string;
|
|
138
|
+
/**
|
|
139
|
+
* 全局兜底字体栈,逐字对齐原 css-builder 中 body 的 font-family 输出。
|
|
140
|
+
* 元素是可直接拼接的合法 CSS 片段:需要引号的族名自带引号,
|
|
141
|
+
* 通用族名(sans-serif)绝不能加引号——加了会被解析为字面字体名而失效。
|
|
142
|
+
*/
|
|
143
|
+
declare const FALLBACK_FONT_STACK: readonly string[];
|
|
144
|
+
/**
|
|
145
|
+
* 把 CSS 值转义为可安全放入双引号包裹的内联样式属性(style="...")的形式。
|
|
146
|
+
* 属性值中直接出现 `"` 会提前闭合属性,导致其后的声明整条丢失
|
|
147
|
+
* (实测:`style="font-family:"SimSun", Arial"` 解析后 fontFamily 为空串)。
|
|
148
|
+
*/
|
|
149
|
+
declare function escapeInlineStyleValue(cssValue: string): string;
|
|
150
|
+
/**
|
|
151
|
+
* 生成 CSS font-family 值:显式族名 + 全局兜底栈。
|
|
152
|
+
* - 未设置/空白 → 纯兜底栈
|
|
153
|
+
* - 值已含逗号 → 视为调用方给出的完整栈,原样前置(不整体加引号,否则整串会变成一个字体名)
|
|
154
|
+
* - 其余 → 作为单个族名加引号后前置
|
|
155
|
+
*/
|
|
156
|
+
declare function toFontFamilyStack(family?: string): string;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 纸张尺寸。
|
|
160
|
+
* - DOT_FULL / DOT_HALF / DOT_THIRD:针式打印纸 241 系列全等分 / 二等分 / 三等分;
|
|
161
|
+
* - LABEL_80X60 / LABEL_60X40 / LABEL_40X30:标签纸;
|
|
162
|
+
* - THERMAL_57 / THERMAL_80 / THERMAL_110:小票纸(热敏卷纸,连续纸,出纸高度按内容推导);
|
|
163
|
+
* - CONTINUOUS=连续纸(热敏/标签,设计高度固定 297mm,出纸高度按内容推导,底边距用 margins.bottom)。
|
|
164
|
+
* 连续纸(含小票纸)设计高度仅作画布,方向强制纵向,纸宽可用 customWidth 覆盖。
|
|
165
|
+
*/
|
|
166
|
+
type PaperSize$1 = 'A4' | 'A3' | 'A5' | 'Letter' | 'Legal' | 'DOT_FULL' | 'DOT_HALF' | 'DOT_THIRD' | 'LABEL_80X60' | 'LABEL_60X40' | 'LABEL_40X30' | 'THERMAL_57' | 'THERMAL_80' | 'THERMAL_110' | 'CUSTOM' | 'CONTINUOUS';
|
|
167
|
+
/** 元素所属区域(运行时标记,序列化时剥离;区域元素 left/top 相对所在区域左上角,单位 pt) */
|
|
168
|
+
type ElementZone = 'content' | 'header' | 'footer';
|
|
169
|
+
/** 元素分页属性(非表格元素) */
|
|
170
|
+
interface PaginationConfig$1 {
|
|
171
|
+
pageable: boolean;
|
|
172
|
+
keepWithNext: boolean;
|
|
173
|
+
}
|
|
174
|
+
/** 表格分页配置 */
|
|
175
|
+
interface TablePaginationConfig$1 {
|
|
176
|
+
enabled: boolean;
|
|
177
|
+
}
|
|
178
|
+
/** 新模板数据模型(替代旧 PrintPanel / PrintTemplateJson) */
|
|
179
|
+
interface TemplateData$1 {
|
|
180
|
+
paperSize: PaperSize$1;
|
|
181
|
+
/** 方向(纸张方向)= 当前纸张长宽;切换时直接交换纸张宽高(设计稿内容随之铺在该尺寸上) */
|
|
182
|
+
orientation: 'portrait' | 'landscape';
|
|
183
|
+
/**
|
|
184
|
+
* 出纸旋转角度(整页内容旋转出纸):缺省 0(不旋转)。仅固定纸(非连续纸、非拼版)生效。
|
|
185
|
+
* 0° 纸张不变、内容不旋转;180° 纸张不变、内容翻转;90°/270° 纸张长宽互换以贴合旋转后的内容包围盒,
|
|
186
|
+
* 设计稿内容保持原方向不变,不被拉伸或裁切。
|
|
187
|
+
*/
|
|
188
|
+
outputRotation?: 0 | 90 | 180 | 270;
|
|
189
|
+
margins: {
|
|
190
|
+
top: number;
|
|
191
|
+
right: number;
|
|
192
|
+
bottom: number;
|
|
193
|
+
left: number;
|
|
194
|
+
};
|
|
195
|
+
header: {
|
|
196
|
+
height: number;
|
|
197
|
+
elements: TemplateElement$1[];
|
|
198
|
+
};
|
|
199
|
+
footer: {
|
|
200
|
+
height: number;
|
|
201
|
+
elements: TemplateElement$1[];
|
|
202
|
+
};
|
|
203
|
+
firstPageOverlay: {
|
|
204
|
+
height: number;
|
|
205
|
+
elements: TemplateElement$1[];
|
|
206
|
+
};
|
|
207
|
+
elements: TemplateElement$1[];
|
|
208
|
+
/** 页面名称(多页面模板中用于设计器页签显示;渲染端忽略) */
|
|
209
|
+
name?: string;
|
|
210
|
+
/** 模板级字体声明(由设计器 prop 同步写入):三端据此生成同一份 @font-face */
|
|
211
|
+
fonts?: PrintFontDeclaration[];
|
|
212
|
+
/** 拼版打印配置(模板级);缺省不写 = 不拼版 */
|
|
213
|
+
tiling?: TilingOptions;
|
|
214
|
+
/** 元素坐标单位(新保存模板固定 'mm';旧数据无此字段按 pt 迁移) */
|
|
215
|
+
unit?: 'pt' | 'mm';
|
|
216
|
+
/** 自定义纸张宽度(mm),paperSize='CUSTOM' 时有效;连续纸(含小票纸)时为纸宽,缺省取预设纸宽 */
|
|
217
|
+
customWidth?: number;
|
|
218
|
+
/** 自定义纸张高度(mm),仅 paperSize='CUSTOM' 时有效;连续纸(含小票纸)时仅作设计画布高度(缺省 297,出纸按内容推导) */
|
|
219
|
+
customHeight?: number;
|
|
220
|
+
/** 页面(纸张)背景色;未设置时默认白色 */
|
|
221
|
+
pageBackground?: string;
|
|
222
|
+
/** 水印配置 */
|
|
223
|
+
watermark?: WatermarkOptions;
|
|
224
|
+
/** 手动参考线(设计态辅助,序列化保留,渲染端忽略) */
|
|
225
|
+
guides?: AlignLine[];
|
|
226
|
+
/** 设计背景(定位底图):仅设计画布显示,用于套打对位;预览与打印管线一律忽略 */
|
|
227
|
+
designBackground?: DesignBackground;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* 多页面模板(设计器侧 wrapper):pages 为设计器完整模型 TemplateData。
|
|
231
|
+
* 与主入口 render 管线的同名 MultiPageTemplateData(pages 为简化 TemplateData)有意分离,
|
|
232
|
+
* 两侧运行时代表同一份 JSON({version, pages}),由 canvas 侧经 normalizeTemplate 交给渲染端。
|
|
233
|
+
*/
|
|
234
|
+
interface MultiPageTemplateData$1 {
|
|
235
|
+
version?: 1;
|
|
236
|
+
pages: TemplateData$1[];
|
|
237
|
+
}
|
|
238
|
+
/** 模板元素引用(用于 TemplateData 各区域) */
|
|
239
|
+
type TemplateElement$1 = PrintElementData;
|
|
240
|
+
/** 元素类型 */
|
|
241
|
+
type ElementType = 'text' | 'image' | 'longText' | 'table' | 'hline' | 'vline' | 'rect' | 'oval' | 'barcode' | 'qrcode' | 'html' | 'pageNumber';
|
|
242
|
+
/** 对齐方式 */
|
|
243
|
+
type TextAlign = 'left' | 'center' | 'right';
|
|
244
|
+
/**
|
|
245
|
+
* 文字超出可用空间时的显示形式(文本类元素与表格单元格共用):
|
|
246
|
+
* - `clip`:截断,超出部分不显示;不换行(`wordWrap=false`)时以省略号收尾
|
|
247
|
+
* - `shrink`:自动缩小字号,缩到下限字号仍放不下则退化为截断
|
|
248
|
+
* - `autoHeight`:自适应高度,元素高度 / 表格行高随内容增高
|
|
249
|
+
*
|
|
250
|
+
* 未显式设置时按元素类型取默认值(text=clip、longText=autoHeight、单元格=autoHeight),
|
|
251
|
+
* 与既有渲染行为一致,存量模板不受影响。
|
|
252
|
+
*/
|
|
253
|
+
type TextFit = 'clip' | 'shrink' | 'autoHeight';
|
|
254
|
+
/** 垂直对齐方式(文本类元素,未设置时按顶部处理,与打印端一致) */
|
|
255
|
+
type VerticalAlign = 'top' | 'middle' | 'bottom';
|
|
256
|
+
/** 缩放手柄方向 */
|
|
257
|
+
type ResizePoint = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w';
|
|
258
|
+
/** 设计背景(定位底图):仅设计画布显示,预览/PDF/打印/截图均不输出 */
|
|
259
|
+
interface DesignBackground {
|
|
260
|
+
/** 宿主上传接口返回的完整图片路径,可直接用于 <img src> */
|
|
261
|
+
src: string;
|
|
262
|
+
/** 旋转角度,仅允许 90° 步进;非法值读取时按 0 处理 */
|
|
263
|
+
rotation: 0 | 90 | 180 | 270;
|
|
264
|
+
}
|
|
265
|
+
/** 引导线 */
|
|
266
|
+
interface AlignLine {
|
|
267
|
+
type: 'vertical' | 'horizontal';
|
|
268
|
+
position: number;
|
|
269
|
+
id?: string;
|
|
270
|
+
/** 引导线颜色(区分左/中/右对齐类型) */
|
|
271
|
+
color?: string;
|
|
272
|
+
}
|
|
273
|
+
/** 吸附结果 */
|
|
274
|
+
interface AdsorbResult {
|
|
275
|
+
left: number;
|
|
276
|
+
top: number;
|
|
277
|
+
lines: AlignLine[];
|
|
278
|
+
}
|
|
279
|
+
/** 元素矩形(用于吸附检测) */
|
|
280
|
+
interface ElementRect {
|
|
281
|
+
id: string;
|
|
282
|
+
left: number;
|
|
283
|
+
top: number;
|
|
284
|
+
width: number;
|
|
285
|
+
height: number;
|
|
286
|
+
}
|
|
287
|
+
/** 表格行类型:header 标题 / data 数据(全表唯一) / subtotal 当前页小计(每页末尾) / summary 整表汇总 */
|
|
288
|
+
type TableRowType = 'header' | 'data' | 'subtotal' | 'summary';
|
|
289
|
+
/** 单边边框样式 */
|
|
290
|
+
interface TableCellBorder {
|
|
291
|
+
width: number;
|
|
292
|
+
style: 'solid' | 'dashed' | 'dotted' | 'double' | 'none';
|
|
293
|
+
color: string;
|
|
294
|
+
}
|
|
295
|
+
/** 四边边框 */
|
|
296
|
+
interface TableCellBorders {
|
|
297
|
+
top?: TableCellBorder;
|
|
298
|
+
right?: TableCellBorder;
|
|
299
|
+
bottom?: TableCellBorder;
|
|
300
|
+
left?: TableCellBorder;
|
|
301
|
+
}
|
|
302
|
+
/** 单元格内容类型 */
|
|
303
|
+
type TableCellType = 'text' | 'barcode' | 'qrcode' | 'image';
|
|
304
|
+
/** 单元格 */
|
|
305
|
+
interface TableCell {
|
|
306
|
+
id: string;
|
|
307
|
+
formatter?: string;
|
|
308
|
+
cellType?: TableCellType;
|
|
309
|
+
barcodeType?: string;
|
|
310
|
+
qrCodeLevel?: string;
|
|
311
|
+
showBarcodeText?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* 打印机分辨率(点/英寸,常见 203/300/600),仅 cellType='barcode' 时生效:
|
|
314
|
+
* 条形码尺寸由「条宽 → dpi → 等比缩小」结算(见 render/barcode-dot.ts),
|
|
315
|
+
* 给出本字段时首选尺寸吸附到整数打印点(dpi 优先于条宽的精确毫米值),
|
|
316
|
+
* 单元格可用宽高不足则整体等比缩小,消除热敏出纸「条宽忽宽忽窄」。
|
|
317
|
+
*/
|
|
318
|
+
printerDpi?: number;
|
|
319
|
+
/** 条码模块宽度倍率(2-4),仅 cellType='barcode' 时生效:每模块首选宽度 = 倍率/2 × 0.25mm */
|
|
320
|
+
barWidth?: number;
|
|
321
|
+
/** 条码下方文本字号(相对条高,条高为 30),仅 cellType='barcode' 时生效 */
|
|
322
|
+
barFontSize?: number;
|
|
323
|
+
rowspan?: number;
|
|
324
|
+
colspan?: number;
|
|
325
|
+
merged?: boolean;
|
|
326
|
+
align?: TextAlign;
|
|
327
|
+
valign?: 'top' | 'middle' | 'bottom';
|
|
328
|
+
fontFamily?: string;
|
|
329
|
+
fontSize?: number;
|
|
330
|
+
fontWeight?: string;
|
|
331
|
+
color?: string;
|
|
332
|
+
backgroundColor?: string;
|
|
333
|
+
borders?: TableCellBorders;
|
|
334
|
+
padding?: number;
|
|
335
|
+
wordWrap?: boolean;
|
|
336
|
+
/** 文字溢出显示形式;缺省按「不换行→截断,否则自适应行高」判定 */
|
|
337
|
+
textFit?: TextFit;
|
|
338
|
+
/** 自动缩小(textFit='shrink')的下限字号(pt);缺省 6pt */
|
|
339
|
+
shrinkMinFontSize?: number;
|
|
340
|
+
fit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
|
|
341
|
+
maxWidth?: number;
|
|
342
|
+
maxHeight?: number;
|
|
343
|
+
}
|
|
344
|
+
/** 表格行 */
|
|
345
|
+
interface TableRow {
|
|
346
|
+
id: string;
|
|
347
|
+
type: TableRowType;
|
|
348
|
+
height: number;
|
|
349
|
+
repeatOnPage?: boolean;
|
|
350
|
+
cells: TableCell[];
|
|
351
|
+
}
|
|
352
|
+
/** 单元格选区(r/c 均为 0 基,闭区间) */
|
|
353
|
+
interface TableSelection {
|
|
354
|
+
elementId: string;
|
|
355
|
+
r1: number;
|
|
356
|
+
c1: number;
|
|
357
|
+
r2: number;
|
|
358
|
+
c2: number;
|
|
359
|
+
}
|
|
360
|
+
/** 表格历史字段绑定(兼容存量模板,实际取 fields[0].dataSource) */
|
|
361
|
+
interface ElementFieldBinding {
|
|
362
|
+
text?: string;
|
|
363
|
+
dataSource?: string;
|
|
364
|
+
}
|
|
365
|
+
/** 元素选项(序列化到 JSON) */
|
|
366
|
+
interface ElementOptions {
|
|
367
|
+
left: number;
|
|
368
|
+
top: number;
|
|
369
|
+
width: number;
|
|
370
|
+
height: number;
|
|
371
|
+
/** @deprecated 统一使用 formatter */
|
|
372
|
+
title?: string;
|
|
373
|
+
testData?: string;
|
|
374
|
+
fontSize?: number;
|
|
375
|
+
fontWeight?: string;
|
|
376
|
+
fontFamily?: string;
|
|
377
|
+
color?: string;
|
|
378
|
+
backgroundColor?: string;
|
|
379
|
+
textAlign?: TextAlign;
|
|
380
|
+
verticalAlign?: VerticalAlign;
|
|
381
|
+
lineHeight?: number;
|
|
382
|
+
letterSpacing?: number;
|
|
383
|
+
/** 文字溢出显示形式(text/longText);缺省按元素类型取默认值 */
|
|
384
|
+
textFit?: TextFit;
|
|
385
|
+
/** 自动缩小(textFit='shrink')的下限字号(pt);缺省 6pt */
|
|
386
|
+
shrinkMinFontSize?: number;
|
|
387
|
+
/** 自动换行(text/longText);缺省 true。false 时单行显示,截断形式下以省略号收尾 */
|
|
388
|
+
wordWrap?: boolean;
|
|
389
|
+
fixed?: boolean;
|
|
390
|
+
locked?: boolean;
|
|
391
|
+
/** 元素可见性(图层面板切换) */
|
|
392
|
+
visible?: boolean;
|
|
393
|
+
borderWidth?: number;
|
|
394
|
+
borderStyle?: string;
|
|
395
|
+
borderColor?: string;
|
|
396
|
+
contentPaddingLeft?: number;
|
|
397
|
+
contentPaddingTop?: number;
|
|
398
|
+
contentPaddingRight?: number;
|
|
399
|
+
contentPaddingBottom?: number;
|
|
400
|
+
textDecoration?: string;
|
|
401
|
+
textType?: 'barcode' | 'qrcode';
|
|
402
|
+
barcodeType?: string;
|
|
403
|
+
barWidth?: number;
|
|
404
|
+
barAutoWidth?: string;
|
|
405
|
+
/**
|
|
406
|
+
* 打印机分辨率(点/英寸,常见 203/300/600):条形码尺寸由「条宽 → dpi → 等比缩小」结算
|
|
407
|
+
* (见 render/barcode-dot.ts),给出本字段时首选尺寸吸附到整数打印点,dpi 优先于条宽的
|
|
408
|
+
* 精确毫米值;可用框放不下则整体等比缩小。缺省不启用(按条宽的毫米值落纸)。
|
|
409
|
+
*/
|
|
410
|
+
printerDpi?: number;
|
|
411
|
+
qrCodeLevel?: string;
|
|
412
|
+
src?: string;
|
|
413
|
+
/** 内容缩放模式(image/qrcode):contain | cover | fill | none | scale-down。条形码不接受拉伸——尺寸已由结算确定 */
|
|
414
|
+
fit?: string;
|
|
415
|
+
/** 内容最大宽度(mm,image/barcode/qrcode);缺省不限制 */
|
|
416
|
+
maxWidth?: number;
|
|
417
|
+
/** 内容最大高度(mm,image/barcode/qrcode);缺省不限制 */
|
|
418
|
+
maxHeight?: number;
|
|
419
|
+
hideTitle?: boolean;
|
|
420
|
+
draggable?: boolean;
|
|
421
|
+
axis?: string;
|
|
422
|
+
transform?: number;
|
|
423
|
+
zIndex?: number;
|
|
424
|
+
groupId?: string;
|
|
425
|
+
pagination?: PaginationConfig$1;
|
|
426
|
+
tablePagination?: TablePaginationConfig$1;
|
|
427
|
+
/** @deprecated 静态布局模式已移除,所有表格统一使用动态模式 */
|
|
428
|
+
tableMode?: 'dynamic' | 'static';
|
|
429
|
+
tableRows?: TableRow[];
|
|
430
|
+
tableColWidths?: number[];
|
|
431
|
+
tableDefaultFontSize?: number;
|
|
432
|
+
tableDefaultColor?: string;
|
|
433
|
+
tableDefaultPadding?: number;
|
|
434
|
+
/** 列表数据源路径(data 行迭代的数据数组) */
|
|
435
|
+
dataSource?: string;
|
|
436
|
+
/** @deprecated 兼容存量表格模型;列表数据源优先使用 dataSource */
|
|
437
|
+
fields?: ElementFieldBinding[];
|
|
438
|
+
formatter?: string;
|
|
439
|
+
styler?: string;
|
|
440
|
+
rowStyler?: string;
|
|
441
|
+
longTextIndent?: number;
|
|
442
|
+
leftSpaceRemoved?: boolean;
|
|
443
|
+
lHeight?: number;
|
|
444
|
+
}
|
|
445
|
+
/** 元素类型元数据 */
|
|
446
|
+
interface PrintElementTypeMeta {
|
|
447
|
+
title?: string;
|
|
448
|
+
type: ElementType;
|
|
449
|
+
editable?: boolean;
|
|
450
|
+
formatter?: string;
|
|
451
|
+
styler?: string;
|
|
452
|
+
}
|
|
453
|
+
/** 序列化元素数据 */
|
|
454
|
+
interface PrintElementData {
|
|
455
|
+
id?: string;
|
|
456
|
+
type?: ElementType;
|
|
457
|
+
options: ElementOptions;
|
|
458
|
+
printElementType: PrintElementTypeMeta;
|
|
459
|
+
}
|
|
460
|
+
/** 水印配置 */
|
|
461
|
+
interface WatermarkOptions {
|
|
462
|
+
/** 水印模式:fixed=固定文本,binding=绑定字段 */
|
|
463
|
+
mode?: 'fixed' | 'binding';
|
|
464
|
+
/** 固定文本(mode=fixed 时使用) */
|
|
465
|
+
content?: string;
|
|
466
|
+
/** 绑定字段(mode=binding 时使用) */
|
|
467
|
+
binding?: string;
|
|
468
|
+
/** 测试值(设计态预览使用) */
|
|
469
|
+
testData?: string;
|
|
470
|
+
/** 旋转角度 */
|
|
471
|
+
rotate?: number;
|
|
472
|
+
/** 颜色 */
|
|
473
|
+
color?: string;
|
|
474
|
+
/** 透明度 */
|
|
475
|
+
opacity?: number;
|
|
476
|
+
/** 显示时间戳 */
|
|
477
|
+
timestamp?: boolean;
|
|
478
|
+
/** 时间格式(timestamp=true 时使用,token 支持 YYYY/MM/DD/HH/mm/ss) */
|
|
479
|
+
format?: string;
|
|
480
|
+
/** 平铺瓦片宽度(px,控制水印密度:越小越密,默认 260,下限 140) */
|
|
481
|
+
tileWidth?: number;
|
|
482
|
+
/** 平铺瓦片高度(px,控制水印密度:越小越密,默认 180,下限 100) */
|
|
483
|
+
tileHeight?: number;
|
|
484
|
+
}
|
|
485
|
+
/** 运行时元素(设计器中带状态) */
|
|
486
|
+
interface RuntimeElement {
|
|
487
|
+
id: string;
|
|
488
|
+
options: ElementOptions;
|
|
489
|
+
printElementType: PrintElementTypeMeta;
|
|
490
|
+
selected?: boolean;
|
|
491
|
+
/** 运行时所属区域,序列化时剥离,缺省视为 content */
|
|
492
|
+
zone?: ElementZone;
|
|
493
|
+
}
|
|
494
|
+
/** 业务字段(宿主查询后传入,核心不内置字段字典) */
|
|
495
|
+
interface PrintBusinessField {
|
|
496
|
+
id?: string;
|
|
497
|
+
fieldKey: string;
|
|
498
|
+
fieldLabel: string;
|
|
499
|
+
/** 字段类型;'list' 表示明细列表字段(用于表格数据源选择) */
|
|
500
|
+
fieldType: string;
|
|
501
|
+
sortOrder: number;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* 绑定位置描述(用于属性面板自动渲染绑定控件)
|
|
505
|
+
*/
|
|
506
|
+
interface BindingDescriptor {
|
|
507
|
+
/** 绑定的属性路径(如 'options.formatter'、'options.tableRows[0].cells[0].formatter') */
|
|
508
|
+
targetPath: string;
|
|
509
|
+
/** 显示名称 */
|
|
510
|
+
label: string;
|
|
511
|
+
/** 数据源上下文 */
|
|
512
|
+
dataSource: 'main' | 'list' | 'subtotal' | 'summary';
|
|
513
|
+
/** 绑定的列表字段(仅表格行需要) */
|
|
514
|
+
listField?: string;
|
|
515
|
+
/** 提示文本 */
|
|
516
|
+
placeholder?: string;
|
|
517
|
+
/** 是否允许清空 */
|
|
518
|
+
clearable?: boolean;
|
|
519
|
+
}
|
|
520
|
+
/** 截图请求载荷(设计器叠层对比用) */
|
|
521
|
+
interface ScreenshotRequest {
|
|
522
|
+
templateJson: TemplateData$1;
|
|
523
|
+
printData: Record<string, any>;
|
|
524
|
+
}
|
|
525
|
+
/** 截图适配器:宿主依据模板 + 数据返回 PNG Blob */
|
|
526
|
+
type RequestScreenshotFn = (req: ScreenshotRequest) => Promise<Blob>;
|
|
527
|
+
/** 图片上传适配器:宿主上传文件并返回可访问的图片 URL */
|
|
528
|
+
type UploadImageFn = (file: File) => Promise<string>;
|
|
529
|
+
/**
|
|
530
|
+
* 设计背景图上传适配器(由宿主实现注入)。
|
|
531
|
+
* 入参为用户选择的图片文件;返回值必须是可直接 <img src> 访问的完整图片路径。
|
|
532
|
+
* 与 UploadImageFn 语义独立:不配合 baseUrl,不要求相对路径。
|
|
533
|
+
*/
|
|
534
|
+
type UploadDesignBackgroundFn = (file: File) => Promise<string>;
|
|
535
|
+
|
|
536
|
+
declare const MAX_BATCH_COPIES = 500;
|
|
537
|
+
type PrintDataInput = Record<string, any> | Record<string, any>[];
|
|
538
|
+
type NormalizedPrintData = {
|
|
539
|
+
mode: 'single';
|
|
540
|
+
data: Record<string, any>;
|
|
541
|
+
} | {
|
|
542
|
+
mode: 'batch';
|
|
543
|
+
dataList: Record<string, any>[];
|
|
544
|
+
};
|
|
545
|
+
declare function normalizePrintData(raw: PrintDataInput | undefined): NormalizedPrintData;
|
|
546
|
+
|
|
547
|
+
type PaperSize = 'A4' | 'A3' | 'A5' | 'Letter' | 'Legal' | 'DOT_FULL' | 'DOT_HALF' | 'DOT_THIRD' | 'LABEL_80X60' | 'LABEL_60X40' | 'LABEL_40X30' | 'THERMAL_57' | 'THERMAL_80' | 'THERMAL_110' | 'CUSTOM' | 'CONTINUOUS';
|
|
548
|
+
/** 连续纸纸型:出纸高度按渲染内容推导 */
|
|
549
|
+
type ContinuousPaperSize = 'CONTINUOUS' | 'THERMAL_57' | 'THERMAL_80' | 'THERMAL_110';
|
|
550
|
+
/** 固定尺寸纸型:纸面确定,可作拼版目标纸等需要确定纸面的场景 */
|
|
551
|
+
type SheetPaperSize = Exclude<PaperSize, ContinuousPaperSize>;
|
|
552
|
+
/** 纸张尺寸映射(mm) */
|
|
553
|
+
declare const PAPER_DIMENSIONS: Record<PaperSize, {
|
|
554
|
+
width: number;
|
|
555
|
+
height: number;
|
|
556
|
+
}>;
|
|
557
|
+
/** 纸型是否连续纸(小票纸/热敏卷纸):出纸高度按渲染内容推导 */
|
|
558
|
+
declare function isContinuousPaperSize(paperSize: string): boolean;
|
|
559
|
+
interface TemplateData {
|
|
560
|
+
paperSize: PaperSize;
|
|
561
|
+
orientation: 'portrait' | 'landscape';
|
|
562
|
+
/**
|
|
563
|
+
* 出纸旋转角度(整页内容旋转出纸):缺省 0(不旋转)。仅固定纸(非连续纸、非拼版)生效。
|
|
564
|
+
* 0° 纸张不变、内容不旋转;180° 纸张不变、内容翻转;90°/270° 纸张长宽互换以贴合旋转后的内容包围盒,
|
|
565
|
+
* 设计稿内容保持原方向不变,不被拉伸或裁切。
|
|
566
|
+
*/
|
|
567
|
+
outputRotation?: 0 | 90 | 180 | 270;
|
|
568
|
+
/** 自定义纸张宽度(mm),paperSize='CUSTOM' 时生效;连续纸(含小票纸)时为纸宽,缺省取预设纸宽 */
|
|
569
|
+
customWidth?: number;
|
|
570
|
+
/** 自定义纸张高度(mm),仅 paperSize='CUSTOM' 时生效;连续纸(含小票纸)时仅作设计画布高度(缺省 297,出纸按内容推导) */
|
|
571
|
+
customHeight?: number;
|
|
572
|
+
/** 页面(纸张)背景色;未设置时默认白色 */
|
|
573
|
+
pageBackground?: string;
|
|
574
|
+
/** 水印配置(同 design/WatermarkOptions,渲染端读取其颜色/透明度/角度/密度/绑定) */
|
|
575
|
+
watermark?: WatermarkOptions;
|
|
576
|
+
/** 页面名称(多页面模板中用于设计器页签与错误上下文;渲染端忽略) */
|
|
577
|
+
name?: string;
|
|
578
|
+
/** 模板级字体声明:三端据此生成同一份 @font-face,不依赖各端系统字体 */
|
|
579
|
+
fonts?: PrintFontDeclaration[];
|
|
580
|
+
/** 拼版打印配置(模板级);缺省不写 = 不拼版 */
|
|
581
|
+
tiling?: TilingOptions;
|
|
582
|
+
margins: {
|
|
583
|
+
top: number;
|
|
584
|
+
right: number;
|
|
585
|
+
bottom: number;
|
|
586
|
+
left: number;
|
|
587
|
+
};
|
|
588
|
+
header: {
|
|
589
|
+
height: number;
|
|
590
|
+
elements: TemplateElement[];
|
|
591
|
+
};
|
|
592
|
+
footer: {
|
|
593
|
+
height: number;
|
|
594
|
+
elements: TemplateElement[];
|
|
595
|
+
};
|
|
596
|
+
firstPageOverlay: {
|
|
597
|
+
height: number;
|
|
598
|
+
elements: TemplateElement[];
|
|
599
|
+
};
|
|
600
|
+
elements: TemplateElement[];
|
|
601
|
+
}
|
|
602
|
+
/** 元素分页属性(非表格元素) */
|
|
603
|
+
interface PaginationConfig {
|
|
604
|
+
pageable: boolean;
|
|
605
|
+
keepWithNext: boolean;
|
|
606
|
+
}
|
|
607
|
+
/** 表格分页配置 */
|
|
608
|
+
interface TablePaginationConfig {
|
|
609
|
+
enabled: boolean;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* 模板元素 — print-render 侧的简化视图。
|
|
613
|
+
* 兼容前端 PrintElementData 的 options 嵌套结构,
|
|
614
|
+
* 同时提供扁平访问器方便分页引擎使用。
|
|
615
|
+
*/
|
|
616
|
+
interface TemplateElement {
|
|
617
|
+
id: string;
|
|
618
|
+
type: string;
|
|
619
|
+
/** 元素选项(与前端 ElementOptions 对齐) */
|
|
620
|
+
options: Record<string, any>;
|
|
621
|
+
/** 元素类型元数据(与前端 PrintElementTypeMeta 对齐) */
|
|
622
|
+
printElementType?: {
|
|
623
|
+
type: string;
|
|
624
|
+
title?: string;
|
|
625
|
+
[key: string]: any;
|
|
626
|
+
};
|
|
627
|
+
/** 分页属性(非表格元素) */
|
|
628
|
+
pagination?: PaginationConfig;
|
|
629
|
+
/** 表格分页配置(表格元素) */
|
|
630
|
+
tablePagination?: TablePaginationConfig;
|
|
631
|
+
}
|
|
632
|
+
type RenderRowType = 'header' | 'data' | 'summary' | 'subtotal' | 'static';
|
|
633
|
+
interface RenderCellBorder {
|
|
634
|
+
width: number;
|
|
635
|
+
style: string;
|
|
636
|
+
color: string;
|
|
637
|
+
}
|
|
638
|
+
interface RenderCellBorders {
|
|
639
|
+
top?: RenderCellBorder;
|
|
640
|
+
right?: RenderCellBorder;
|
|
641
|
+
bottom?: RenderCellBorder;
|
|
642
|
+
left?: RenderCellBorder;
|
|
643
|
+
}
|
|
644
|
+
/** 绑定后的单元格:content 已是最终文本(小计行 content 为占位值,真实值按每页数据渲染时求值) */
|
|
645
|
+
interface RenderCell {
|
|
646
|
+
content: string;
|
|
647
|
+
/**
|
|
648
|
+
* 单元格原始 formatter 表达式,渲染阶段重新求值:
|
|
649
|
+
* 小计行以当前页数据行上下文求值;引用了页码(pageIndex / totalPages)的单元格按该页页码求值。
|
|
650
|
+
*/
|
|
651
|
+
rawFormatter?: string;
|
|
652
|
+
/** 内容类型:text(默认)/ barcode / qrcode / image,非 text 时 content 为码值或图片 URL */
|
|
653
|
+
cellType?: string;
|
|
654
|
+
/** 条形码码制(jsbarcode 格式名),仅 cellType='barcode' 时生效 */
|
|
655
|
+
barcodeType?: string;
|
|
656
|
+
/** 二维码纠错级别 L/M/Q/H,仅 cellType='qrcode' 时生效 */
|
|
657
|
+
qrCodeLevel?: string;
|
|
658
|
+
/** 条形码下方是否显示文本,仅 cellType='barcode' 时生效 */
|
|
659
|
+
showBarcodeText?: boolean;
|
|
660
|
+
/** 打印机分辨率(点/英寸),仅 cellType='barcode' 时生效:给出后条码尺寸优先适配打印机点阵 */
|
|
661
|
+
printerDpi?: number;
|
|
662
|
+
/** 图片缩放模式,仅 cellType='image' 时生效 */
|
|
663
|
+
fit?: string;
|
|
664
|
+
/** 图片最大宽度(mm),仅 cellType='image' 时生效 */
|
|
665
|
+
maxWidth?: number;
|
|
666
|
+
/** 图片最大高度(mm),仅 cellType='image' 时生效 */
|
|
667
|
+
maxHeight?: number;
|
|
668
|
+
rowspan: number;
|
|
669
|
+
colspan: number;
|
|
670
|
+
merged: boolean;
|
|
671
|
+
align?: string;
|
|
672
|
+
valign?: string;
|
|
673
|
+
fontSize?: number;
|
|
674
|
+
/** 字体族名;未设置时单元格不输出 font-family,交还 CSS 继承 */
|
|
675
|
+
fontFamily?: string;
|
|
676
|
+
fontWeight?: string;
|
|
677
|
+
color?: string;
|
|
678
|
+
backgroundColor?: string;
|
|
679
|
+
borders?: RenderCellBorders;
|
|
680
|
+
padding?: number;
|
|
681
|
+
wordWrap?: boolean;
|
|
682
|
+
/** 文字溢出显示形式;缺省按「不换行→截断,否则自适应行高」判定 */
|
|
683
|
+
textFit?: string;
|
|
684
|
+
/** 自动缩小(textFit='shrink')的下限字号(pt);缺省 6pt */
|
|
685
|
+
shrinkMinFontSize?: number;
|
|
686
|
+
/** 自动缩小求得的最终字号(pt):测量趟算出后回写,最终趟据此渲染 */
|
|
687
|
+
fittedFontSize?: number;
|
|
688
|
+
}
|
|
689
|
+
/** 绑定后的渲染行,存入 options._renderRows */
|
|
690
|
+
interface RenderRow {
|
|
691
|
+
type: RenderRowType;
|
|
692
|
+
height: number;
|
|
693
|
+
cells: RenderCell[];
|
|
694
|
+
}
|
|
695
|
+
interface CodeRenderOptions {
|
|
696
|
+
/** 条形码码制(jsbarcode 格式名),仅 barcode 类型使用 */
|
|
697
|
+
barcodeType?: string;
|
|
698
|
+
/** 二维码纠错级别 L/M/Q/H,仅 qrcode 类型使用 */
|
|
699
|
+
qrCodeLevel?: string;
|
|
700
|
+
/** 条形码下方是否显示文本 */
|
|
701
|
+
showText?: boolean;
|
|
702
|
+
/** 条码模块宽度倍率;决定每模块的首选物理宽度(倍率/2 × 0.25mm),给 dpi 后吸附到最近整数点 */
|
|
703
|
+
barWidth?: number;
|
|
704
|
+
/** 条码下方文本字号(pt) */
|
|
705
|
+
fontSize?: number;
|
|
706
|
+
/**
|
|
707
|
+
* 打印机分辨率(点/英寸);给出时首选尺寸吸附到「每模块整数个打印点」,dpi 优先于条宽的精确毫米值。
|
|
708
|
+
*/
|
|
709
|
+
printerDpi?: number;
|
|
710
|
+
/** 目标可用宽度(mm):条形码元素框宽或单元格内容区宽,渲染器据此决定是否等比缩小 */
|
|
711
|
+
targetWidthMm?: number;
|
|
712
|
+
/** 目标可用高度(mm):条形码元素框高或单元格内容区高,同上 */
|
|
713
|
+
targetHeightMm?: number;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* 码值 → SVG 字符串渲染器。
|
|
717
|
+
* 三端统一由 core 的 DOM 执行器实现(jsbarcode/qrcode 算法只有一份):
|
|
718
|
+
* 浏览器进程内直调,服务端与桌面客户端注入 IIFE 产物后在页面上下文执行。
|
|
719
|
+
* 码值非法时抛出异常,由调用方降级为文本占位。
|
|
720
|
+
*/
|
|
721
|
+
interface CodeRenderer {
|
|
722
|
+
render(value: string, cellType: 'barcode' | 'qrcode', opts?: CodeRenderOptions): string;
|
|
723
|
+
}
|
|
724
|
+
interface RenderRequest {
|
|
725
|
+
/** 模板 JSON:单模板或 { pages } 多页面模板 */
|
|
726
|
+
templateJson: TemplateData | MultiPageTemplateData;
|
|
727
|
+
/** 业务数据:对象=单份;非空对象数组=批量(数组长度即份数,上限 500) */
|
|
728
|
+
printData?: PrintDataInput;
|
|
729
|
+
/** 服务端对外访问 base URL,用于把 /docfiles/... 等相对路径图片拼接为完整地址 */
|
|
730
|
+
baseUrl?: string;
|
|
731
|
+
/** 相对路径字体基址;缺省回落 `baseUrl`(缺省时二者同域),传空串表示不拼接 */
|
|
732
|
+
fontBaseUrl?: string;
|
|
733
|
+
/** 宿主纸张覆盖(mm):宽/高沿用 print.paperSize 语义,0 或负数视为未提供 */
|
|
734
|
+
paperOverride?: {
|
|
735
|
+
width?: number;
|
|
736
|
+
height?: number;
|
|
737
|
+
};
|
|
738
|
+
/** 连续纸显式纸高(mm)逃生门 */
|
|
739
|
+
paperHeightMm?: number;
|
|
740
|
+
}
|
|
741
|
+
interface MeasuredElement {
|
|
742
|
+
id: string;
|
|
743
|
+
measuredHeight: number;
|
|
744
|
+
/** 表格每行实际高度(mm),仅表格元素有值 */
|
|
745
|
+
measuredRowHeights?: number[];
|
|
746
|
+
/** 重复表头段实际高度(mm)= 前 _repeatHeaderCount 个渲染行高之和,仅表格元素有值 */
|
|
747
|
+
repeatHeaderHeight?: number;
|
|
748
|
+
}
|
|
749
|
+
interface PageLayout {
|
|
750
|
+
pageIndex: number;
|
|
751
|
+
sections: PageSection[];
|
|
752
|
+
/**
|
|
753
|
+
* 本页含「分页预算放不下、被强制留在本页」的内容(首个元素/单元即放不下)。
|
|
754
|
+
* 该场景不产出空白页,但内容可能超出纸面,需由上层(如拼版「每份恰好 1 页」校验)据此阻断。
|
|
755
|
+
*/
|
|
756
|
+
overflow?: boolean;
|
|
757
|
+
}
|
|
758
|
+
interface PageSection {
|
|
759
|
+
elementId: string;
|
|
760
|
+
type: 'element' | 'table-slice' | 'flow-group';
|
|
761
|
+
/** table-slice 专用:渲染行起始索引(含表头行) */
|
|
762
|
+
startRow?: number;
|
|
763
|
+
/** table-slice 专用:渲染行结束索引(不含) */
|
|
764
|
+
endRow?: number;
|
|
765
|
+
/** table-slice 专用:非首片时在切片前重复表头段 */
|
|
766
|
+
repeatHeader?: boolean;
|
|
767
|
+
/** table-slice 专用:本片末尾是否渲染小计行(当前页数据小计,每页重复) */
|
|
768
|
+
subtotal?: boolean;
|
|
769
|
+
/** table-slice 专用:本片末尾是否渲染整表汇总行(总计,仅最后一页) */
|
|
770
|
+
summary?: boolean;
|
|
771
|
+
/** 本节在本页内容区内的实际 top(mm)。发生换页后的内容为 0;缺省回退元素设计 top */
|
|
772
|
+
renderTop?: number;
|
|
773
|
+
/**
|
|
774
|
+
* flow-group 专用:相对容器在本页的实际 top(mm),覆盖元素设计 top。
|
|
775
|
+
* 同页时 = 表格设计 top(容器顶部对齐表格 slice 顶部);
|
|
776
|
+
* 跟随区整体移页时 = 新页内容区顶部(0)。
|
|
777
|
+
*/
|
|
778
|
+
groupTop?: number;
|
|
779
|
+
/** flow-group 专用:跟随区成员元素 id(容器内按文档流渲染) */
|
|
780
|
+
followElementIds?: string[];
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* 获取纸张物理尺寸(考虑方向)。
|
|
784
|
+
* - CUSTOM:宽高取 customWidth/customHeight,缺省回退 A4;
|
|
785
|
+
* - 连续纸(小票纸/热敏卷纸):强制纵向,宽度取 customWidth(缺省取预设纸宽),
|
|
786
|
+
* 高度仅为设计画布高度(取 customHeight,缺省取预设值),出纸高度由内容推导;
|
|
787
|
+
* - 其余预设:取 PAPER_DIMENSIONS,横向时宽高互换。
|
|
788
|
+
* 参数刻意只用纸张相关字段——不需要 elements,故设计器侧与渲染侧模板均可直接传入。
|
|
789
|
+
*/
|
|
790
|
+
declare function getPaperDimensions(template: {
|
|
791
|
+
paperSize: PaperSize;
|
|
792
|
+
orientation: 'portrait' | 'landscape';
|
|
793
|
+
customWidth?: number;
|
|
794
|
+
customHeight?: number;
|
|
795
|
+
}): {
|
|
796
|
+
width: number;
|
|
797
|
+
height: number;
|
|
798
|
+
};
|
|
799
|
+
/** 是否连续纸(热敏/小票/标签卷纸):出纸高度按渲染内容推导 */
|
|
800
|
+
declare function isContinuousPaper(template: {
|
|
801
|
+
paperSize: string;
|
|
802
|
+
}): boolean;
|
|
803
|
+
interface MultiPageTemplateData {
|
|
804
|
+
/** 版本号,缺省 1 */
|
|
805
|
+
version?: 1;
|
|
806
|
+
/** 按打印顺序排列的页面模板,每个都是完整的单页 TemplateData */
|
|
807
|
+
pages: TemplateData[];
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/** 物理尺寸(毫米);三端与协议的公共纸尺寸表示 */
|
|
811
|
+
interface PaperMm {
|
|
812
|
+
width: number;
|
|
813
|
+
height: number;
|
|
814
|
+
}
|
|
815
|
+
/** 测量容器尺寸(CSS 像素);浏览器为 iframe 尺寸,服务端为 page viewport */
|
|
816
|
+
interface ViewportPx {
|
|
817
|
+
width: number;
|
|
818
|
+
height: number;
|
|
819
|
+
}
|
|
820
|
+
/** 纸高来源:config = 模板/宿主给定,derived = 连续纸探针推导 */
|
|
821
|
+
type HeightSource = 'config' | 'derived';
|
|
822
|
+
interface MarginsMm {
|
|
823
|
+
top: number;
|
|
824
|
+
right: number;
|
|
825
|
+
bottom: number;
|
|
826
|
+
left: number;
|
|
827
|
+
}
|
|
828
|
+
/** 出图目标规格:与宿主无关,宿主负责翻译成自己的选项 */
|
|
829
|
+
interface PdfTargetSpec {
|
|
830
|
+
paperMm: PaperMm;
|
|
831
|
+
marginsMm: MarginsMm;
|
|
832
|
+
printBackground: boolean;
|
|
833
|
+
scale: number;
|
|
834
|
+
preferCSSPageSize: boolean;
|
|
835
|
+
}
|
|
836
|
+
interface ScreenshotTargetSpec {
|
|
837
|
+
type: 'png';
|
|
838
|
+
fullPage: boolean;
|
|
839
|
+
omitBackground: boolean;
|
|
840
|
+
}
|
|
841
|
+
/** 宿主回传的原始测量值(CSS px,不做任何业务换算) */
|
|
842
|
+
interface RawMeasurement {
|
|
843
|
+
id: string;
|
|
844
|
+
heightPx: number;
|
|
845
|
+
/** 表格行高(px),仅表格元素有值 */
|
|
846
|
+
rowHeightsPx?: number[];
|
|
847
|
+
}
|
|
848
|
+
/** 一次码值渲染请求;key 为稳定键,用于跨进程映射 */
|
|
849
|
+
interface CodeSpec {
|
|
850
|
+
key: string;
|
|
851
|
+
value: string;
|
|
852
|
+
cellType: 'barcode' | 'qrcode';
|
|
853
|
+
opts: CodeRenderOptions;
|
|
854
|
+
}
|
|
855
|
+
interface PrintJob {
|
|
856
|
+
/** 模板 JSON(设计器 TemplateData 结构兼容;含 { pages } 多页面模板) */
|
|
857
|
+
templateJson: TemplateData | MultiPageTemplateData;
|
|
858
|
+
/** 业务数据:对象=单份;非空对象数组=按数组长度批量合并为一个作业 */
|
|
859
|
+
printData?: PrintDataInput;
|
|
860
|
+
/** 相对路径图片基址 */
|
|
861
|
+
baseUrl?: string;
|
|
862
|
+
/**
|
|
863
|
+
* 相对路径字体基址;缺省回落 `baseUrl`,传空串表示不拼接(浏览器端按文档 origin 解析)。
|
|
864
|
+
* 出图端必须能访问解析后的字体地址,否则声明字体会静默回退到系统字体。
|
|
865
|
+
*/
|
|
866
|
+
fontBaseUrl?: string;
|
|
867
|
+
/** 宿主纸张覆盖(mm);0 或负数视为未提供 */
|
|
868
|
+
paperOverride?: {
|
|
869
|
+
width?: number;
|
|
870
|
+
height?: number;
|
|
871
|
+
};
|
|
872
|
+
/** 连续纸显式纸高逃生门(mm) */
|
|
873
|
+
paperHeightMm?: number;
|
|
874
|
+
/** 单任务总预算(ms),缺省 30000 */
|
|
875
|
+
timeoutMs?: number;
|
|
876
|
+
/** 就绪等待(ms),缺省 5000 */
|
|
877
|
+
readinessMs?: number;
|
|
878
|
+
/** 调用方提供的码值渲染器(浏览器端覆盖语义);提供时跳过多趟收集 */
|
|
879
|
+
codeRenderer?: CodeRenderer;
|
|
880
|
+
}
|
|
881
|
+
interface PreparedDocument {
|
|
882
|
+
html: string;
|
|
883
|
+
pageCount: number;
|
|
884
|
+
paperMm: PaperMm;
|
|
885
|
+
continuous: boolean;
|
|
886
|
+
heightSource: HeightSource;
|
|
887
|
+
pageLayouts: PageLayout[];
|
|
888
|
+
/** 份数:单对象=1,数组=数组长度 */
|
|
889
|
+
copies: number;
|
|
890
|
+
/** 批量时每份的物理纸张尺寸(连续纸各份高度不同);单份无此字段 */
|
|
891
|
+
copyPaperMm?: PaperMm[];
|
|
892
|
+
}
|
|
893
|
+
interface RenderPdfResult {
|
|
894
|
+
pdf: Uint8Array;
|
|
895
|
+
prepared: PreparedDocument;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/** 执行器可被宿主调用的方法名(与 browser/dom-executor.ts 一一对应) */
|
|
899
|
+
type ExecutorMethod = 'waitReady' | 'readMeasurements' | 'readContentBottom' | 'renderCodes' | 'applyTextFit';
|
|
900
|
+
/** 执行器方法的宿主目标种类:window(waitReady)/ document(读 DOM)/ none(纯计算,无首参) */
|
|
901
|
+
type ExecutorTargetKind = 'window' | 'document' | 'none';
|
|
902
|
+
/**
|
|
903
|
+
* 各执行器方法的宿主目标注入方式:宿主据此决定是否补首参。
|
|
904
|
+
* 三端 driver 均按本表装配参数,不得各自假设「非 waitReady 一律传 document」。
|
|
905
|
+
*/
|
|
906
|
+
declare const EXECUTOR_TARGETS: Record<ExecutorMethod, ExecutorTargetKind>;
|
|
907
|
+
/** core 自带的 DOM 执行器产物;宿主负责把它送进页面 */
|
|
908
|
+
interface ExecutorBundle {
|
|
909
|
+
source: string;
|
|
910
|
+
version: string;
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* 单文档槽位原语:只做宿主 I/O,不含任何业务规则(纸张、分页、码制参数均不得出现在实现里)。
|
|
914
|
+
* 工厂返回时该槽位必须已存在一个空白文档(open 只负责调整视口)。
|
|
915
|
+
*/
|
|
916
|
+
interface PageDriver {
|
|
917
|
+
/**
|
|
918
|
+
* 是否需要注入 core 的 DOM 执行器产物;缺省 true。
|
|
919
|
+
* 浏览器 iframe driver 在进程内直调执行器,置 false 即可不传 bundle。
|
|
920
|
+
*/
|
|
921
|
+
requiresExecutor?: boolean;
|
|
922
|
+
open(viewport: ViewportPx): Promise<void>;
|
|
923
|
+
setContent(html: string): Promise<void>;
|
|
924
|
+
/** 同一文档内幂等;文档重建后必须重新注入 */
|
|
925
|
+
injectExecutor(bundle: ExecutorBundle): Promise<void>;
|
|
926
|
+
evaluate<T>(method: ExecutorMethod, args?: unknown[]): Promise<T>;
|
|
927
|
+
pdf?(html: string, spec: PdfTargetSpec): Promise<Uint8Array>;
|
|
928
|
+
screenshot?(html: string, spec: ScreenshotTargetSpec): Promise<Uint8Array>;
|
|
929
|
+
close(): Promise<void>;
|
|
930
|
+
}
|
|
931
|
+
interface DriverFactory {
|
|
932
|
+
createDriver(): Promise<PageDriver>;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
export { type PrintJob as $, type AdsorbResult as A, type BindingDescriptor as B, type CodeRenderer as C, type DriverFactory as D, type ElementOptions as E, type TextAlign as F, type TextFit as G, type UploadImageFn as H, type MeasuredElement as I, type TemplateElement as J, type PaperMm as K, type ViewportPx as L, type MultiPageTemplateData as M, type HeightSource as N, type MarginsMm as O, type PageLayout as P, type PdfTargetSpec as Q, type RawMeasurement as R, type ScreenshotRequest as S, type TemplateData as T, type UploadDesignBackgroundFn as U, type VerticalAlign as V, type WatermarkOptions as W, type ScreenshotTargetSpec as X, type CodeRenderOptions as Y, type ExecutorBundle as Z, type TileLayout as _, type CodeSpec as a, type PreparedDocument as a0, type RenderPdfResult as a1, type PrintFontDeclaration as a2, type ContinuousPaperSize as a3, EXECUTOR_TARGETS as a4, type ExecutorMethod as a5, type ExecutorTargetKind as a6, FALLBACK_FONT_STACK as a7, MAX_BATCH_COPIES as a8, type NormalizedPrintData as a9, resolveSheetMm as aA, roundMm as aB, tilePosition as aC, toFontFamilyStack as aD, validateTiling as aE, PAPER_DIMENSIONS as aa, type PageDriver as ab, type PageSection as ac, type PaperSize as ad, type PrintDataInput as ae, type PrintFontFile as af, type RenderCell as ag, type RenderRequest as ah, type RenderRow as ai, type SheetPaperSize as aj, TILE_DEFAULTS as ak, TilingError as al, type TilingIssue as am, type TilingIssueCode as an, type TilingOptions as ao, type TilingResolveOptions as ap, type TilingTemplateInput as aq, buildFontFaceCss as ar, computeMaxColumns as as, computeTileLayout as at, escapeInlineStyleValue as au, getPaperDimensions as av, isContinuousPaper as aw, isContinuousPaperSize as ax, normalizePrintData as ay, normalizeTilingOptions as az, type TemplateData$1 as b, type TableRow as c, type TableCellBorder as d, type TableCell as e, type TableRowType as f, type ElementType as g, type RuntimeElement as h, type ElementZone as i, type PrintBusinessField as j, type ElementRect as k, type ResizePoint as l, type AlignLine as m, type DesignBackground as n, type ElementFieldBinding as o, type MultiPageTemplateData$1 as p, type PaginationConfig$1 as q, type PaperSize$1 as r, type PrintElementData as s, type PrintElementTypeMeta as t, type RequestScreenshotFn as u, type TableCellBorders as v, type TableCellType as w, type TablePaginationConfig$1 as x, type TableSelection as y, type TemplateElement$1 as z };
|