@worm-vue3-print/core 1.2.0 → 1.2.2

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/index.d.cts CHANGED
@@ -1,3 +1,6 @@
1
+ import { T as TemplateData, C as CodeRenderer, P as PageLayout, M as MeasuredElement, a as TemplateElement } from './types-BGBAbQD5.cjs';
2
+ export { b as CodeRenderOptions, c as PAPER_DIMENSIONS, d as PageSection, e as PaperSize, R as RenderCell, f as RenderRequest, g as RenderRow, h as getPaperDimensions } from './types-BGBAbQD5.cjs';
3
+
1
4
  type TokenType = 'num' | 'str' | 'bool' | 'ident' | 'punc';
2
5
  interface Token {
3
6
  type: TokenType;
@@ -126,189 +129,6 @@ declare const systemVars: {
126
129
  printTime: () => number;
127
130
  };
128
131
 
129
- type PaperSize = 'A4' | 'A3' | 'A5' | 'Letter' | 'Legal' | 'CUSTOM';
130
- /** 纸张尺寸映射(mm) */
131
- declare const PAPER_DIMENSIONS: Record<PaperSize, {
132
- width: number;
133
- height: number;
134
- }>;
135
- interface TemplateData {
136
- paperSize: PaperSize;
137
- orientation: 'portrait' | 'landscape';
138
- /** 自定义纸张宽度(mm),仅 paperSize='CUSTOM' 时生效 */
139
- customWidth?: number;
140
- /** 自定义纸张高度(mm),仅 paperSize='CUSTOM' 时生效 */
141
- customHeight?: number;
142
- /** 页面(纸张)背景色;未设置时默认白色 */
143
- pageBackground?: string;
144
- margins: {
145
- top: number;
146
- right: number;
147
- bottom: number;
148
- left: number;
149
- };
150
- header: {
151
- height: number;
152
- elements: TemplateElement[];
153
- };
154
- footer: {
155
- height: number;
156
- elements: TemplateElement[];
157
- };
158
- firstPageOverlay: {
159
- height: number;
160
- elements: TemplateElement[];
161
- };
162
- elements: TemplateElement[];
163
- }
164
- /** 元素分页属性(非表格元素) */
165
- interface PaginationConfig {
166
- pageable: boolean;
167
- keepWithNext: boolean;
168
- }
169
- /** 表格分页配置 */
170
- interface TablePaginationConfig {
171
- enabled: boolean;
172
- }
173
- /**
174
- * 模板元素 — print-render 侧的简化视图。
175
- * 兼容前端 PrintElementData 的 options 嵌套结构,
176
- * 同时提供扁平访问器方便分页引擎使用。
177
- */
178
- interface TemplateElement {
179
- id: string;
180
- type: string;
181
- /** 元素选项(与前端 ElementOptions 对齐) */
182
- options: Record<string, any>;
183
- /** 元素类型元数据(与前端 PrintElementTypeMeta 对齐) */
184
- printElementType?: {
185
- type: string;
186
- title?: string;
187
- [key: string]: any;
188
- };
189
- /** 分页属性(非表格元素) */
190
- pagination?: PaginationConfig;
191
- /** 表格分页配置(表格元素) */
192
- tablePagination?: TablePaginationConfig;
193
- }
194
- type RenderRowType = 'header' | 'data' | 'summary' | 'subtotal' | 'static';
195
- interface RenderCellBorder {
196
- width: number;
197
- style: string;
198
- color: string;
199
- }
200
- interface RenderCellBorders {
201
- top?: RenderCellBorder;
202
- right?: RenderCellBorder;
203
- bottom?: RenderCellBorder;
204
- left?: RenderCellBorder;
205
- }
206
- /** 绑定后的单元格:content 已是最终文本(小计行 content 为占位值,真实值按每页数据渲染时求值) */
207
- interface RenderCell {
208
- content: string;
209
- /** 小计行专用:单元格原始 formatter 表达式,渲染阶段以当前页数据行上下文求值 */
210
- rawFormatter?: string;
211
- /** 内容类型:text(默认)/ barcode / qrcode / image,非 text 时 content 为码值或图片 URL */
212
- cellType?: string;
213
- /** 条形码码制(jsbarcode 格式名),仅 cellType='barcode' 时生效 */
214
- barcodeType?: string;
215
- /** 二维码纠错级别 L/M/Q/H,仅 cellType='qrcode' 时生效 */
216
- qrCodeLevel?: string;
217
- /** 条形码下方是否显示文本,仅 cellType='barcode' 时生效 */
218
- showBarcodeText?: boolean;
219
- /** 图片缩放模式,仅 cellType='image' 时生效 */
220
- fit?: string;
221
- /** 图片最大宽度(mm),仅 cellType='image' 时生效 */
222
- maxWidth?: number;
223
- /** 图片最大高度(mm),仅 cellType='image' 时生效 */
224
- maxHeight?: number;
225
- rowspan: number;
226
- colspan: number;
227
- merged: boolean;
228
- align?: string;
229
- valign?: string;
230
- fontSize?: number;
231
- fontWeight?: string;
232
- color?: string;
233
- backgroundColor?: string;
234
- borders?: RenderCellBorders;
235
- padding?: number;
236
- wordWrap?: boolean;
237
- }
238
- /** 绑定后的渲染行,存入 options._renderRows */
239
- interface RenderRow {
240
- type: RenderRowType;
241
- height: number;
242
- cells: RenderCell[];
243
- }
244
- interface CodeRenderOptions {
245
- /** 条形码码制(jsbarcode 格式名),仅 barcode 类型使用 */
246
- barcodeType?: string;
247
- /** 二维码纠错级别 L/M/Q/H,仅 qrcode 类型使用 */
248
- qrCodeLevel?: string;
249
- /** 条形码下方是否显示文本 */
250
- showText?: boolean;
251
- /** 条码模块宽度倍率 */
252
- barWidth?: number;
253
- /** 条码下方文本字号(pt) */
254
- fontSize?: number;
255
- }
256
- /**
257
- * 码值 → SVG 字符串渲染器。
258
- * 服务端由 print-render 用 bwip-js 实现;浏览器由 print-canvas 用 jsbarcode/qrcode 实现。
259
- * 码值非法时抛出异常,由调用方降级为文本占位。
260
- */
261
- interface CodeRenderer {
262
- render(value: string, cellType: 'barcode' | 'qrcode', opts?: CodeRenderOptions): string;
263
- }
264
- interface RenderRequest {
265
- templateJson: TemplateData;
266
- printData?: Record<string, any>;
267
- /** 服务端对外访问 base URL,用于把 /docfiles/... 等相对路径图片拼接为完整地址 */
268
- baseUrl?: string;
269
- }
270
- interface MeasuredElement {
271
- id: string;
272
- measuredHeight: number;
273
- /** 表格每行实际高度(mm),仅表格元素有值 */
274
- measuredRowHeights?: number[];
275
- /** 重复表头段实际高度(mm)= 前 _repeatHeaderCount 个渲染行高之和,仅表格元素有值 */
276
- repeatHeaderHeight?: number;
277
- }
278
- interface PageLayout {
279
- pageIndex: number;
280
- sections: PageSection[];
281
- }
282
- interface PageSection {
283
- elementId: string;
284
- type: 'element' | 'table-slice' | 'flow-group';
285
- /** table-slice 专用:渲染行起始索引(含表头行) */
286
- startRow?: number;
287
- /** table-slice 专用:渲染行结束索引(不含) */
288
- endRow?: number;
289
- /** table-slice 专用:非首片时在切片前重复表头段 */
290
- repeatHeader?: boolean;
291
- /** table-slice 专用:本片末尾是否渲染小计行(当前页数据小计,每页重复) */
292
- subtotal?: boolean;
293
- /** table-slice 专用:本片末尾是否渲染整表汇总行(总计,仅最后一页) */
294
- summary?: boolean;
295
- /** 本节在本页内容区内的实际 top(mm)。发生换页后的内容为 0;缺省回退元素设计 top */
296
- renderTop?: number;
297
- /**
298
- * flow-group 专用:相对容器在本页的实际 top(mm),覆盖元素设计 top。
299
- * 同页时 = 表格设计 top(容器顶部对齐表格 slice 顶部);
300
- * 跟随区整体移页时 = 新页内容区顶部(0)。
301
- */
302
- groupTop?: number;
303
- /** flow-group 专用:跟随区成员元素 id(容器内按文档流渲染) */
304
- followElementIds?: string[];
305
- }
306
- /** 获取纸张物理尺寸(考虑方向) */
307
- declare function getPaperDimensions(template: TemplateData): {
308
- width: number;
309
- height: number;
310
- };
311
-
312
132
  /**
313
133
  * 将模板中元素的 formatter 表达式求值为实际值。
314
134
  * 返回新的模板对象(深拷贝),不修改原始模板。
@@ -382,4 +202,4 @@ declare class TemplateEngine {
382
202
  render(template: string, context: Record<string, any>): string;
383
203
  }
384
204
 
385
- export { type ASTNode, type CodeRenderOptions, type CodeRenderer, type EngineOptions, type ExprFunction, type GenerateOptions, type MeasuredElement, PAPER_DIMENSIONS, type PageLayout, type PageSection, type PaperSize, type TemplateData as PrintTemplateData, type TemplateElement as PrintTemplateElement, type RenderCell, type RenderRequest, type RenderRow, type TemplateAST, TemplateEngine, avg, bindData, buildPageCss, compileTemplate, count, elementPositionStyle, evaluate, evaluateTemplate, formatDate, formatMoney, generateHtml, getByPath, getPaperDimensions, ifFn, injectSystemVariables, max, min, mm, paginate, parse, parseTemplate, renderTemplate, safeEval, setPageIndex, setTotalPages, sum, systemVars, tableDesignBottom, toUpperCaseAmount, tokenize };
205
+ export { type ASTNode, CodeRenderer, type EngineOptions, type ExprFunction, type GenerateOptions, MeasuredElement, PageLayout, TemplateData as PrintTemplateData, TemplateElement as PrintTemplateElement, type TemplateAST, TemplateEngine, avg, bindData, buildPageCss, compileTemplate, count, elementPositionStyle, evaluate, evaluateTemplate, formatDate, formatMoney, generateHtml, getByPath, ifFn, injectSystemVariables, max, min, mm, paginate, parse, parseTemplate, renderTemplate, safeEval, setPageIndex, setTotalPages, sum, systemVars, tableDesignBottom, toUpperCaseAmount, tokenize };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import { T as TemplateData, C as CodeRenderer, P as PageLayout, M as MeasuredElement, a as TemplateElement } from './types-BGBAbQD5.js';
2
+ export { b as CodeRenderOptions, c as PAPER_DIMENSIONS, d as PageSection, e as PaperSize, R as RenderCell, f as RenderRequest, g as RenderRow, h as getPaperDimensions } from './types-BGBAbQD5.js';
3
+
1
4
  type TokenType = 'num' | 'str' | 'bool' | 'ident' | 'punc';
2
5
  interface Token {
3
6
  type: TokenType;
@@ -126,189 +129,6 @@ declare const systemVars: {
126
129
  printTime: () => number;
127
130
  };
128
131
 
129
- type PaperSize = 'A4' | 'A3' | 'A5' | 'Letter' | 'Legal' | 'CUSTOM';
130
- /** 纸张尺寸映射(mm) */
131
- declare const PAPER_DIMENSIONS: Record<PaperSize, {
132
- width: number;
133
- height: number;
134
- }>;
135
- interface TemplateData {
136
- paperSize: PaperSize;
137
- orientation: 'portrait' | 'landscape';
138
- /** 自定义纸张宽度(mm),仅 paperSize='CUSTOM' 时生效 */
139
- customWidth?: number;
140
- /** 自定义纸张高度(mm),仅 paperSize='CUSTOM' 时生效 */
141
- customHeight?: number;
142
- /** 页面(纸张)背景色;未设置时默认白色 */
143
- pageBackground?: string;
144
- margins: {
145
- top: number;
146
- right: number;
147
- bottom: number;
148
- left: number;
149
- };
150
- header: {
151
- height: number;
152
- elements: TemplateElement[];
153
- };
154
- footer: {
155
- height: number;
156
- elements: TemplateElement[];
157
- };
158
- firstPageOverlay: {
159
- height: number;
160
- elements: TemplateElement[];
161
- };
162
- elements: TemplateElement[];
163
- }
164
- /** 元素分页属性(非表格元素) */
165
- interface PaginationConfig {
166
- pageable: boolean;
167
- keepWithNext: boolean;
168
- }
169
- /** 表格分页配置 */
170
- interface TablePaginationConfig {
171
- enabled: boolean;
172
- }
173
- /**
174
- * 模板元素 — print-render 侧的简化视图。
175
- * 兼容前端 PrintElementData 的 options 嵌套结构,
176
- * 同时提供扁平访问器方便分页引擎使用。
177
- */
178
- interface TemplateElement {
179
- id: string;
180
- type: string;
181
- /** 元素选项(与前端 ElementOptions 对齐) */
182
- options: Record<string, any>;
183
- /** 元素类型元数据(与前端 PrintElementTypeMeta 对齐) */
184
- printElementType?: {
185
- type: string;
186
- title?: string;
187
- [key: string]: any;
188
- };
189
- /** 分页属性(非表格元素) */
190
- pagination?: PaginationConfig;
191
- /** 表格分页配置(表格元素) */
192
- tablePagination?: TablePaginationConfig;
193
- }
194
- type RenderRowType = 'header' | 'data' | 'summary' | 'subtotal' | 'static';
195
- interface RenderCellBorder {
196
- width: number;
197
- style: string;
198
- color: string;
199
- }
200
- interface RenderCellBorders {
201
- top?: RenderCellBorder;
202
- right?: RenderCellBorder;
203
- bottom?: RenderCellBorder;
204
- left?: RenderCellBorder;
205
- }
206
- /** 绑定后的单元格:content 已是最终文本(小计行 content 为占位值,真实值按每页数据渲染时求值) */
207
- interface RenderCell {
208
- content: string;
209
- /** 小计行专用:单元格原始 formatter 表达式,渲染阶段以当前页数据行上下文求值 */
210
- rawFormatter?: string;
211
- /** 内容类型:text(默认)/ barcode / qrcode / image,非 text 时 content 为码值或图片 URL */
212
- cellType?: string;
213
- /** 条形码码制(jsbarcode 格式名),仅 cellType='barcode' 时生效 */
214
- barcodeType?: string;
215
- /** 二维码纠错级别 L/M/Q/H,仅 cellType='qrcode' 时生效 */
216
- qrCodeLevel?: string;
217
- /** 条形码下方是否显示文本,仅 cellType='barcode' 时生效 */
218
- showBarcodeText?: boolean;
219
- /** 图片缩放模式,仅 cellType='image' 时生效 */
220
- fit?: string;
221
- /** 图片最大宽度(mm),仅 cellType='image' 时生效 */
222
- maxWidth?: number;
223
- /** 图片最大高度(mm),仅 cellType='image' 时生效 */
224
- maxHeight?: number;
225
- rowspan: number;
226
- colspan: number;
227
- merged: boolean;
228
- align?: string;
229
- valign?: string;
230
- fontSize?: number;
231
- fontWeight?: string;
232
- color?: string;
233
- backgroundColor?: string;
234
- borders?: RenderCellBorders;
235
- padding?: number;
236
- wordWrap?: boolean;
237
- }
238
- /** 绑定后的渲染行,存入 options._renderRows */
239
- interface RenderRow {
240
- type: RenderRowType;
241
- height: number;
242
- cells: RenderCell[];
243
- }
244
- interface CodeRenderOptions {
245
- /** 条形码码制(jsbarcode 格式名),仅 barcode 类型使用 */
246
- barcodeType?: string;
247
- /** 二维码纠错级别 L/M/Q/H,仅 qrcode 类型使用 */
248
- qrCodeLevel?: string;
249
- /** 条形码下方是否显示文本 */
250
- showText?: boolean;
251
- /** 条码模块宽度倍率 */
252
- barWidth?: number;
253
- /** 条码下方文本字号(pt) */
254
- fontSize?: number;
255
- }
256
- /**
257
- * 码值 → SVG 字符串渲染器。
258
- * 服务端由 print-render 用 bwip-js 实现;浏览器由 print-canvas 用 jsbarcode/qrcode 实现。
259
- * 码值非法时抛出异常,由调用方降级为文本占位。
260
- */
261
- interface CodeRenderer {
262
- render(value: string, cellType: 'barcode' | 'qrcode', opts?: CodeRenderOptions): string;
263
- }
264
- interface RenderRequest {
265
- templateJson: TemplateData;
266
- printData?: Record<string, any>;
267
- /** 服务端对外访问 base URL,用于把 /docfiles/... 等相对路径图片拼接为完整地址 */
268
- baseUrl?: string;
269
- }
270
- interface MeasuredElement {
271
- id: string;
272
- measuredHeight: number;
273
- /** 表格每行实际高度(mm),仅表格元素有值 */
274
- measuredRowHeights?: number[];
275
- /** 重复表头段实际高度(mm)= 前 _repeatHeaderCount 个渲染行高之和,仅表格元素有值 */
276
- repeatHeaderHeight?: number;
277
- }
278
- interface PageLayout {
279
- pageIndex: number;
280
- sections: PageSection[];
281
- }
282
- interface PageSection {
283
- elementId: string;
284
- type: 'element' | 'table-slice' | 'flow-group';
285
- /** table-slice 专用:渲染行起始索引(含表头行) */
286
- startRow?: number;
287
- /** table-slice 专用:渲染行结束索引(不含) */
288
- endRow?: number;
289
- /** table-slice 专用:非首片时在切片前重复表头段 */
290
- repeatHeader?: boolean;
291
- /** table-slice 专用:本片末尾是否渲染小计行(当前页数据小计,每页重复) */
292
- subtotal?: boolean;
293
- /** table-slice 专用:本片末尾是否渲染整表汇总行(总计,仅最后一页) */
294
- summary?: boolean;
295
- /** 本节在本页内容区内的实际 top(mm)。发生换页后的内容为 0;缺省回退元素设计 top */
296
- renderTop?: number;
297
- /**
298
- * flow-group 专用:相对容器在本页的实际 top(mm),覆盖元素设计 top。
299
- * 同页时 = 表格设计 top(容器顶部对齐表格 slice 顶部);
300
- * 跟随区整体移页时 = 新页内容区顶部(0)。
301
- */
302
- groupTop?: number;
303
- /** flow-group 专用:跟随区成员元素 id(容器内按文档流渲染) */
304
- followElementIds?: string[];
305
- }
306
- /** 获取纸张物理尺寸(考虑方向) */
307
- declare function getPaperDimensions(template: TemplateData): {
308
- width: number;
309
- height: number;
310
- };
311
-
312
132
  /**
313
133
  * 将模板中元素的 formatter 表达式求值为实际值。
314
134
  * 返回新的模板对象(深拷贝),不修改原始模板。
@@ -382,4 +202,4 @@ declare class TemplateEngine {
382
202
  render(template: string, context: Record<string, any>): string;
383
203
  }
384
204
 
385
- export { type ASTNode, type CodeRenderOptions, type CodeRenderer, type EngineOptions, type ExprFunction, type GenerateOptions, type MeasuredElement, PAPER_DIMENSIONS, type PageLayout, type PageSection, type PaperSize, type TemplateData as PrintTemplateData, type TemplateElement as PrintTemplateElement, type RenderCell, type RenderRequest, type RenderRow, type TemplateAST, TemplateEngine, avg, bindData, buildPageCss, compileTemplate, count, elementPositionStyle, evaluate, evaluateTemplate, formatDate, formatMoney, generateHtml, getByPath, getPaperDimensions, ifFn, injectSystemVariables, max, min, mm, paginate, parse, parseTemplate, renderTemplate, safeEval, setPageIndex, setTotalPages, sum, systemVars, tableDesignBottom, toUpperCaseAmount, tokenize };
205
+ export { type ASTNode, CodeRenderer, type EngineOptions, type ExprFunction, type GenerateOptions, MeasuredElement, PageLayout, TemplateData as PrintTemplateData, TemplateElement as PrintTemplateElement, type TemplateAST, TemplateEngine, avg, bindData, buildPageCss, compileTemplate, count, elementPositionStyle, evaluate, evaluateTemplate, formatDate, formatMoney, generateHtml, getByPath, ifFn, injectSystemVariables, max, min, mm, paginate, parse, parseTemplate, renderTemplate, safeEval, setPageIndex, setTotalPages, sum, systemVars, tableDesignBottom, toUpperCaseAmount, tokenize };