@worm-vue3-print/core 1.3.4 → 1.3.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/LICENSE +21 -0
- package/README.md +5 -5
- package/dist/browser/index.cjs +10 -42
- package/dist/browser/index.d.cts +9 -3
- package/dist/browser/index.d.ts +9 -3
- package/dist/browser/index.js +7 -1
- package/dist/{chunk-M4ZERK33.js → chunk-GHASCGL6.js} +7 -1
- package/dist/{chunk-RZJ6AY6T.js → chunk-ZCA33XA6.js} +12 -75
- package/dist/client/index.cjs +6 -0
- package/dist/client/index.d.cts +6 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +7 -0
- package/dist/designer/index.cjs +14 -6
- package/dist/designer/index.d.cts +9 -3
- package/dist/designer/index.d.ts +9 -3
- package/dist/designer/index.js +16 -8
- package/dist/dom-executor.iife.global.js +10 -4
- package/dist/{driver-BMqI4QV-.d.cts → driver-CFm0C_yX.d.cts} +8 -23
- package/dist/{driver-BMqI4QV-.d.ts → driver-CFm0C_yX.d.ts} +8 -23
- package/dist/index.cjs +10 -76
- package/dist/index.d.cts +14 -12
- package/dist/index.d.ts +14 -12
- package/dist/index.js +8 -6
- package/dist/node/index.cjs +6 -0
- package/dist/node/index.d.cts +7 -1
- package/dist/node/index.d.ts +7 -1
- package/dist/node/index.js +7 -0
- package/dist/{ports-DmJos9Ce.d.ts → ports-BXYcHExa.d.cts} +7 -2
- package/dist/{ports-BL-PbuKG.d.cts → ports-Bdst9MWJ.d.ts} +7 -2
- package/package.json +10 -2
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/core v1.3.5
|
|
3
|
+
* Copyright (c) 2026 Worm Base AI
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 Worm Base AI
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
1
7
|
/** 拼版配置(模板级,随模板保存) */
|
|
2
8
|
interface TilingOptions {
|
|
3
9
|
enabled: boolean;
|
|
@@ -200,10 +206,6 @@ interface TemplateData$1 {
|
|
|
200
206
|
height: number;
|
|
201
207
|
elements: TemplateElement$1[];
|
|
202
208
|
};
|
|
203
|
-
firstPageOverlay: {
|
|
204
|
-
height: number;
|
|
205
|
-
elements: TemplateElement$1[];
|
|
206
|
-
};
|
|
207
209
|
elements: TemplateElement$1[];
|
|
208
210
|
/** 页面名称(多页面模板中用于设计器页签显示;渲染端忽略) */
|
|
209
211
|
name?: string;
|
|
@@ -255,7 +257,7 @@ type TextFit = 'clip' | 'shrink' | 'autoHeight';
|
|
|
255
257
|
type VerticalAlign = 'top' | 'middle' | 'bottom';
|
|
256
258
|
/** 缩放手柄方向 */
|
|
257
259
|
type ResizePoint = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w';
|
|
258
|
-
/** 设计背景(定位底图):仅设计画布显示,预览/PDF
|
|
260
|
+
/** 设计背景(定位底图):仅设计画布显示,预览/PDF/打印均不输出 */
|
|
259
261
|
interface DesignBackground {
|
|
260
262
|
/** 宿主上传接口返回的完整图片路径,可直接用于 <img src> */
|
|
261
263
|
src: string;
|
|
@@ -527,13 +529,6 @@ interface BindingDescriptor {
|
|
|
527
529
|
/** 是否允许清空 */
|
|
528
530
|
clearable?: boolean;
|
|
529
531
|
}
|
|
530
|
-
/** 截图请求载荷(设计器叠层对比用) */
|
|
531
|
-
interface ScreenshotRequest {
|
|
532
|
-
templateJson: TemplateData$1;
|
|
533
|
-
printData: Record<string, any>;
|
|
534
|
-
}
|
|
535
|
-
/** 截图适配器:宿主依据模板 + 数据返回 PNG Blob */
|
|
536
|
-
type RequestScreenshotFn = (req: ScreenshotRequest) => Promise<Blob>;
|
|
537
532
|
/** 图片上传适配器:宿主上传文件并返回可访问的图片 URL */
|
|
538
533
|
type UploadImageFn = (file: File) => Promise<string>;
|
|
539
534
|
/**
|
|
@@ -603,10 +598,6 @@ interface TemplateData {
|
|
|
603
598
|
height: number;
|
|
604
599
|
elements: TemplateElement[];
|
|
605
600
|
};
|
|
606
|
-
firstPageOverlay: {
|
|
607
|
-
height: number;
|
|
608
|
-
elements: TemplateElement[];
|
|
609
|
-
};
|
|
610
601
|
elements: TemplateElement[];
|
|
611
602
|
}
|
|
612
603
|
/** 元素分页属性(非表格元素) */
|
|
@@ -843,11 +834,6 @@ interface PdfTargetSpec {
|
|
|
843
834
|
scale: number;
|
|
844
835
|
preferCSSPageSize: boolean;
|
|
845
836
|
}
|
|
846
|
-
interface ScreenshotTargetSpec {
|
|
847
|
-
type: 'png';
|
|
848
|
-
fullPage: boolean;
|
|
849
|
-
omitBackground: boolean;
|
|
850
|
-
}
|
|
851
837
|
/** 宿主回传的原始测量值(CSS px,不做任何业务换算) */
|
|
852
838
|
interface RawMeasurement {
|
|
853
839
|
id: string;
|
|
@@ -935,11 +921,10 @@ interface PageDriver {
|
|
|
935
921
|
injectExecutor(bundle: ExecutorBundle): Promise<void>;
|
|
936
922
|
evaluate<T>(method: ExecutorMethod, args?: unknown[]): Promise<T>;
|
|
937
923
|
pdf?(html: string, spec: PdfTargetSpec): Promise<Uint8Array>;
|
|
938
|
-
screenshot?(html: string, spec: ScreenshotTargetSpec): Promise<Uint8Array>;
|
|
939
924
|
close(): Promise<void>;
|
|
940
925
|
}
|
|
941
926
|
interface DriverFactory {
|
|
942
927
|
createDriver(): Promise<PageDriver>;
|
|
943
928
|
}
|
|
944
929
|
|
|
945
|
-
export { type
|
|
930
|
+
export { type PreparedDocument as $, type AdsorbResult as A, type BindingDescriptor as B, type CodeRenderer as C, type DriverFactory as D, type ElementBorderSide as E, type TemplateElement$1 as F, type TextAlign as G, type TextFit as H, type UploadImageFn as I, type MeasuredElement as J, type TemplateElement as K, type PaperMm as L, type MultiPageTemplateData as M, type ViewportPx as N, type HeightSource as O, type PageLayout as P, type MarginsMm as Q, type RawMeasurement as R, type PdfTargetSpec as S, type TemplateData as T, type UploadDesignBackgroundFn as U, type VerticalAlign as V, type WatermarkOptions as W, type CodeRenderOptions as X, type ExecutorBundle as Y, type TileLayout as Z, type PrintJob as _, type CodeSpec as a, type RenderPdfResult as a0, type PrintFontDeclaration as a1, type ContinuousPaperSize as a2, EXECUTOR_TARGETS as a3, type ExecutorMethod as a4, type ExecutorTargetKind as a5, FALLBACK_FONT_STACK as a6, MAX_BATCH_COPIES as a7, type NormalizedPrintData as a8, PAPER_DIMENSIONS as a9, roundMm as aA, tilePosition as aB, toFontFamilyStack as aC, validateTiling as aD, type PageDriver as aa, type PageSection as ab, type PaperSize as ac, type PrintDataInput as ad, type PrintFontFile as ae, type RenderCell as af, type RenderRequest as ag, type RenderRow as ah, type SheetPaperSize as ai, TILE_DEFAULTS as aj, TilingError as ak, type TilingIssue as al, type TilingIssueCode as am, type TilingOptions as an, type TilingResolveOptions as ao, type TilingTemplateInput as ap, buildFontFaceCss as aq, computeMaxColumns as ar, computeTileLayout as as, escapeInlineStyleValue as at, getPaperDimensions as au, isContinuousPaper as av, isContinuousPaperSize as aw, normalizePrintData as ax, normalizeTilingOptions as ay, resolveSheetMm as az, type ElementOptions as b, type TemplateData$1 as c, type TableRow as d, type TableCellBorder as e, type TableCell as f, type TableRowType as g, type ElementType as h, type RuntimeElement as i, type ElementZone as j, type PrintBusinessField as k, type ElementRect as l, type ResizePoint as m, type AlignLine as n, type DesignBackground as o, type ElementBorderEdge as p, type ElementFieldBinding as q, type MultiPageTemplateData$1 as r, type PaginationConfig$1 as s, type PaperSize$1 as t, type PrintElementData as u, type PrintElementTypeMeta as v, type TableCellBorders as w, type TableCellType as x, type TablePaginationConfig$1 as y, type TableSelection as z };
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/core v1.3.5
|
|
3
|
+
* Copyright (c) 2026 Worm Base AI
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 Worm Base AI
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
1
7
|
/** 拼版配置(模板级,随模板保存) */
|
|
2
8
|
interface TilingOptions {
|
|
3
9
|
enabled: boolean;
|
|
@@ -200,10 +206,6 @@ interface TemplateData$1 {
|
|
|
200
206
|
height: number;
|
|
201
207
|
elements: TemplateElement$1[];
|
|
202
208
|
};
|
|
203
|
-
firstPageOverlay: {
|
|
204
|
-
height: number;
|
|
205
|
-
elements: TemplateElement$1[];
|
|
206
|
-
};
|
|
207
209
|
elements: TemplateElement$1[];
|
|
208
210
|
/** 页面名称(多页面模板中用于设计器页签显示;渲染端忽略) */
|
|
209
211
|
name?: string;
|
|
@@ -255,7 +257,7 @@ type TextFit = 'clip' | 'shrink' | 'autoHeight';
|
|
|
255
257
|
type VerticalAlign = 'top' | 'middle' | 'bottom';
|
|
256
258
|
/** 缩放手柄方向 */
|
|
257
259
|
type ResizePoint = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w';
|
|
258
|
-
/** 设计背景(定位底图):仅设计画布显示,预览/PDF
|
|
260
|
+
/** 设计背景(定位底图):仅设计画布显示,预览/PDF/打印均不输出 */
|
|
259
261
|
interface DesignBackground {
|
|
260
262
|
/** 宿主上传接口返回的完整图片路径,可直接用于 <img src> */
|
|
261
263
|
src: string;
|
|
@@ -527,13 +529,6 @@ interface BindingDescriptor {
|
|
|
527
529
|
/** 是否允许清空 */
|
|
528
530
|
clearable?: boolean;
|
|
529
531
|
}
|
|
530
|
-
/** 截图请求载荷(设计器叠层对比用) */
|
|
531
|
-
interface ScreenshotRequest {
|
|
532
|
-
templateJson: TemplateData$1;
|
|
533
|
-
printData: Record<string, any>;
|
|
534
|
-
}
|
|
535
|
-
/** 截图适配器:宿主依据模板 + 数据返回 PNG Blob */
|
|
536
|
-
type RequestScreenshotFn = (req: ScreenshotRequest) => Promise<Blob>;
|
|
537
532
|
/** 图片上传适配器:宿主上传文件并返回可访问的图片 URL */
|
|
538
533
|
type UploadImageFn = (file: File) => Promise<string>;
|
|
539
534
|
/**
|
|
@@ -603,10 +598,6 @@ interface TemplateData {
|
|
|
603
598
|
height: number;
|
|
604
599
|
elements: TemplateElement[];
|
|
605
600
|
};
|
|
606
|
-
firstPageOverlay: {
|
|
607
|
-
height: number;
|
|
608
|
-
elements: TemplateElement[];
|
|
609
|
-
};
|
|
610
601
|
elements: TemplateElement[];
|
|
611
602
|
}
|
|
612
603
|
/** 元素分页属性(非表格元素) */
|
|
@@ -843,11 +834,6 @@ interface PdfTargetSpec {
|
|
|
843
834
|
scale: number;
|
|
844
835
|
preferCSSPageSize: boolean;
|
|
845
836
|
}
|
|
846
|
-
interface ScreenshotTargetSpec {
|
|
847
|
-
type: 'png';
|
|
848
|
-
fullPage: boolean;
|
|
849
|
-
omitBackground: boolean;
|
|
850
|
-
}
|
|
851
837
|
/** 宿主回传的原始测量值(CSS px,不做任何业务换算) */
|
|
852
838
|
interface RawMeasurement {
|
|
853
839
|
id: string;
|
|
@@ -935,11 +921,10 @@ interface PageDriver {
|
|
|
935
921
|
injectExecutor(bundle: ExecutorBundle): Promise<void>;
|
|
936
922
|
evaluate<T>(method: ExecutorMethod, args?: unknown[]): Promise<T>;
|
|
937
923
|
pdf?(html: string, spec: PdfTargetSpec): Promise<Uint8Array>;
|
|
938
|
-
screenshot?(html: string, spec: ScreenshotTargetSpec): Promise<Uint8Array>;
|
|
939
924
|
close(): Promise<void>;
|
|
940
925
|
}
|
|
941
926
|
interface DriverFactory {
|
|
942
927
|
createDriver(): Promise<PageDriver>;
|
|
943
928
|
}
|
|
944
929
|
|
|
945
|
-
export { type
|
|
930
|
+
export { type PreparedDocument as $, type AdsorbResult as A, type BindingDescriptor as B, type CodeRenderer as C, type DriverFactory as D, type ElementBorderSide as E, type TemplateElement$1 as F, type TextAlign as G, type TextFit as H, type UploadImageFn as I, type MeasuredElement as J, type TemplateElement as K, type PaperMm as L, type MultiPageTemplateData as M, type ViewportPx as N, type HeightSource as O, type PageLayout as P, type MarginsMm as Q, type RawMeasurement as R, type PdfTargetSpec as S, type TemplateData as T, type UploadDesignBackgroundFn as U, type VerticalAlign as V, type WatermarkOptions as W, type CodeRenderOptions as X, type ExecutorBundle as Y, type TileLayout as Z, type PrintJob as _, type CodeSpec as a, type RenderPdfResult as a0, type PrintFontDeclaration as a1, type ContinuousPaperSize as a2, EXECUTOR_TARGETS as a3, type ExecutorMethod as a4, type ExecutorTargetKind as a5, FALLBACK_FONT_STACK as a6, MAX_BATCH_COPIES as a7, type NormalizedPrintData as a8, PAPER_DIMENSIONS as a9, roundMm as aA, tilePosition as aB, toFontFamilyStack as aC, validateTiling as aD, type PageDriver as aa, type PageSection as ab, type PaperSize as ac, type PrintDataInput as ad, type PrintFontFile as ae, type RenderCell as af, type RenderRequest as ag, type RenderRow as ah, type SheetPaperSize as ai, TILE_DEFAULTS as aj, TilingError as ak, type TilingIssue as al, type TilingIssueCode as am, type TilingOptions as an, type TilingResolveOptions as ao, type TilingTemplateInput as ap, buildFontFaceCss as aq, computeMaxColumns as ar, computeTileLayout as as, escapeInlineStyleValue as at, getPaperDimensions as au, isContinuousPaper as av, isContinuousPaperSize as aw, normalizePrintData as ax, normalizeTilingOptions as ay, resolveSheetMm as az, type ElementOptions as b, type TemplateData$1 as c, type TableRow as d, type TableCellBorder as e, type TableCell as f, type TableRowType as g, type ElementType as h, type RuntimeElement as i, type ElementZone as j, type PrintBusinessField as k, type ElementRect as l, type ResizePoint as m, type AlignLine as n, type DesignBackground as o, type ElementBorderEdge as p, type ElementFieldBinding as q, type MultiPageTemplateData$1 as r, type PaginationConfig$1 as s, type PaperSize$1 as t, type PrintElementData as u, type PrintElementTypeMeta as v, type TableCellBorders as w, type TableCellType as x, type TablePaginationConfig$1 as y, type TableSelection as z };
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/core v1.3.5
|
|
3
|
+
* Copyright (c) 2026 Worm Base AI
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 Worm Base AI
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
1
7
|
"use strict";
|
|
2
8
|
var __defProp = Object.defineProperty;
|
|
3
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -50,7 +56,6 @@ __export(index_exports, {
|
|
|
50
56
|
buildPageGeometryCss: () => buildPageGeometryCss,
|
|
51
57
|
buildPageRuleCss: () => buildPageRuleCss,
|
|
52
58
|
buildPdfTargetSpec: () => buildPdfTargetSpec,
|
|
53
|
-
buildScreenshotTargetSpec: () => buildScreenshotTargetSpec,
|
|
54
59
|
cellFitCapMm: () => cellFitCapMm,
|
|
55
60
|
cellFitKey: () => cellFitKey,
|
|
56
61
|
codeSpecKey: () => codeSpecKey,
|
|
@@ -106,7 +111,6 @@ __export(index_exports, {
|
|
|
106
111
|
prepareDocument: () => prepareDocument,
|
|
107
112
|
pxToMm: () => pxToMm,
|
|
108
113
|
renderPdf: () => renderPdf,
|
|
109
|
-
renderScreenshot: () => renderScreenshot,
|
|
110
114
|
renderTemplate: () => renderTemplate,
|
|
111
115
|
renderWatermarkLayerHtml: () => renderWatermarkLayerHtml,
|
|
112
116
|
renderWatermarkTileSvg: () => renderWatermarkTileSvg,
|
|
@@ -1070,9 +1074,6 @@ function bindData(template, printData, baseUrl, fontBaseUrl) {
|
|
|
1070
1074
|
if (bound.footer?.elements) {
|
|
1071
1075
|
bound.footer.elements = bound.footer.elements.map((el) => bindElement(el, data, baseUrl));
|
|
1072
1076
|
}
|
|
1073
|
-
if (bound.firstPageOverlay?.elements) {
|
|
1074
|
-
bound.firstPageOverlay.elements = bound.firstPageOverlay.elements.map((el) => bindElement(el, data, baseUrl));
|
|
1075
|
-
}
|
|
1076
1077
|
bound.elements = bound.elements.map((el) => bindElement(el, data, baseUrl));
|
|
1077
1078
|
const fontBase = fontBaseUrl ?? baseUrl;
|
|
1078
1079
|
if (fontBase && bound.fonts?.length) {
|
|
@@ -1513,7 +1514,6 @@ function areaGeometryBlock(template, paper, desc) {
|
|
|
1513
1514
|
const { bottom: mb } = template.margins;
|
|
1514
1515
|
const headerH = template.header?.height ?? 0;
|
|
1515
1516
|
const footerH = template.footer?.height ?? 0;
|
|
1516
|
-
const overlayH = template.firstPageOverlay?.height ?? 0;
|
|
1517
1517
|
const contentWidth = paper.width - ml - mr;
|
|
1518
1518
|
return `
|
|
1519
1519
|
/* \u2500\u2500 \u9875\u7709 \u2500\u2500 */
|
|
@@ -1541,13 +1541,6 @@ ${desc}.content-area {
|
|
|
1541
1541
|
position: relative;
|
|
1542
1542
|
overflow: visible;
|
|
1543
1543
|
}
|
|
1544
|
-
|
|
1545
|
-
/* \u2500\u2500 \u9996\u9875\u53E0\u52A0\u533A\u57DF \u2500\u2500 */
|
|
1546
|
-
${desc}.first-page-overlay {
|
|
1547
|
-
width: ${mm(contentWidth)};
|
|
1548
|
-
height: ${mm(overlayH)};
|
|
1549
|
-
position: relative;
|
|
1550
|
-
}
|
|
1551
1544
|
`;
|
|
1552
1545
|
}
|
|
1553
1546
|
function buildBasePageCss() {
|
|
@@ -2022,7 +2015,6 @@ function paginate(template, measuredElements) {
|
|
|
2022
2015
|
const { top: mt, bottom: mb } = template.margins;
|
|
2023
2016
|
const headerH = template.header?.height ?? 0;
|
|
2024
2017
|
const footerH = template.footer?.height ?? 0;
|
|
2025
|
-
const overlayH = template.firstPageOverlay?.height ?? 0;
|
|
2026
2018
|
const continuous = isContinuousPaper(template);
|
|
2027
2019
|
const contentHeight = continuous ? Number.POSITIVE_INFINITY : paper.height - mt - mb - headerH - footerH;
|
|
2028
2020
|
if (!continuous && contentHeight <= 0) {
|
|
@@ -2062,8 +2054,7 @@ function paginate(template, measuredElements) {
|
|
|
2062
2054
|
const unitOf = buildPaginationUnits(sorted, measuredElements, groupMap);
|
|
2063
2055
|
const pages = [];
|
|
2064
2056
|
let currentPage = [];
|
|
2065
|
-
let remaining = contentHeight -
|
|
2066
|
-
let isFirstPage = true;
|
|
2057
|
+
let remaining = contentHeight - SAFETY_MARGIN;
|
|
2067
2058
|
let pageBroken = false;
|
|
2068
2059
|
function sectionTop(el) {
|
|
2069
2060
|
return pageBroken ? pageCursorTop() : el.options?.top ?? 0;
|
|
@@ -2072,7 +2063,7 @@ function paginate(template, measuredElements) {
|
|
|
2072
2063
|
return Math.max(0, fullPageHeight() - remaining);
|
|
2073
2064
|
}
|
|
2074
2065
|
function fullPageHeight() {
|
|
2075
|
-
return
|
|
2066
|
+
return contentHeight - SAFETY_MARGIN;
|
|
2076
2067
|
}
|
|
2077
2068
|
let overflowOnCurrent = false;
|
|
2078
2069
|
function pushPage() {
|
|
@@ -2091,7 +2082,6 @@ function paginate(template, measuredElements) {
|
|
|
2091
2082
|
pushPage();
|
|
2092
2083
|
currentPage = [];
|
|
2093
2084
|
remaining = contentHeight - SAFETY_MARGIN;
|
|
2094
|
-
isFirstPage = false;
|
|
2095
2085
|
pageBroken = true;
|
|
2096
2086
|
overflowOnCurrent = false;
|
|
2097
2087
|
}
|
|
@@ -2401,7 +2391,6 @@ function generateMeasurementHtml(template, css, ctx, printData) {
|
|
|
2401
2391
|
// totalPages placeholder
|
|
2402
2392
|
ctx
|
|
2403
2393
|
);
|
|
2404
|
-
const overlayHtml = renderAreaElements(template.firstPageOverlay?.elements ?? [], contentWidth, void 0, void 0, ctx);
|
|
2405
2394
|
let html = `<!DOCTYPE html>
|
|
2406
2395
|
<html lang="zh-CN">
|
|
2407
2396
|
<head>
|
|
@@ -2412,7 +2401,6 @@ function generateMeasurementHtml(template, css, ctx, printData) {
|
|
|
2412
2401
|
<section class="print-page" data-measure-page="0">
|
|
2413
2402
|
${renderWatermarkLayerHtml(template.watermark, printData, getPaperDims(template))}
|
|
2414
2403
|
<div class="page-header">${headerHtml}</div>
|
|
2415
|
-
<div class="first-page-overlay">${overlayHtml}</div>
|
|
2416
2404
|
<div class="content-area" style="height:auto;overflow:visible;">
|
|
2417
2405
|
${elementsHtml}
|
|
2418
2406
|
</div>
|
|
@@ -2476,14 +2464,12 @@ function renderPage(template, page, pageNum, totalPages, ctx, printData, pageCla
|
|
|
2476
2464
|
totalPages,
|
|
2477
2465
|
pageCtx
|
|
2478
2466
|
);
|
|
2479
|
-
const overlayHtml = page.pageIndex === 0 ? `<div class="first-page-overlay">${renderAreaElements(scoped.firstPageOverlay?.elements ?? [], contentWidth, pageNum, totalPages, pageCtx)}</div>` : "";
|
|
2480
2467
|
let contentHtml = page.sections.map((section) => renderSection(section, scoped, pageCtx)).join("\n");
|
|
2481
2468
|
contentHtml = contentHtml.replace(/\{pageIndex\}/g, String(pageNum));
|
|
2482
2469
|
contentHtml = contentHtml.replace(/\{totalPages\}/g, String(totalPages));
|
|
2483
2470
|
const pageInner = `
|
|
2484
2471
|
${renderWatermarkLayerHtml(template.watermark, printData, paperMm, { pageIndex: pageNum, totalPages })}
|
|
2485
2472
|
<div class="page-header">${headerHtml}</div>
|
|
2486
|
-
${overlayHtml}
|
|
2487
2473
|
<div class="content-area">
|
|
2488
2474
|
${contentHtml}
|
|
2489
2475
|
</div>
|
|
@@ -2507,16 +2493,14 @@ function withPageNumbers(template, vars) {
|
|
|
2507
2493
|
...template,
|
|
2508
2494
|
elements: template.elements.map(mapEl),
|
|
2509
2495
|
header: mapArea(template.header),
|
|
2510
|
-
footer: mapArea(template.footer)
|
|
2511
|
-
firstPageOverlay: mapArea(template.firstPageOverlay)
|
|
2496
|
+
footer: mapArea(template.footer)
|
|
2512
2497
|
};
|
|
2513
2498
|
}
|
|
2514
2499
|
function templateReferencesPageNumbers(template) {
|
|
2515
2500
|
const areas = [
|
|
2516
2501
|
template.elements,
|
|
2517
2502
|
template.header?.elements,
|
|
2518
|
-
template.footer?.elements
|
|
2519
|
-
template.firstPageOverlay?.elements
|
|
2503
|
+
template.footer?.elements
|
|
2520
2504
|
];
|
|
2521
2505
|
return areas.some((list) => (list ?? []).some((el) => typeof el.options?.rawFormatter === "string"));
|
|
2522
2506
|
}
|
|
@@ -3005,9 +2989,6 @@ function toPlaywrightPdfOptions(spec) {
|
|
|
3005
2989
|
preferCSSPageSize: spec.preferCSSPageSize
|
|
3006
2990
|
};
|
|
3007
2991
|
}
|
|
3008
|
-
function buildScreenshotTargetSpec() {
|
|
3009
|
-
return { type: "png", fullPage: true, omitBackground: false };
|
|
3010
|
-
}
|
|
3011
2992
|
|
|
3012
2993
|
// src/print/measure.ts
|
|
3013
2994
|
function normalizeMeasurements(raw, template) {
|
|
@@ -3042,7 +3023,6 @@ function applyTextFitSizes(template, fits) {
|
|
|
3042
3023
|
collect(template.elements);
|
|
3043
3024
|
collect(template.header?.elements);
|
|
3044
3025
|
collect(template.footer?.elements);
|
|
3045
|
-
collect(template.firstPageOverlay?.elements);
|
|
3046
3026
|
for (const fit of fits) {
|
|
3047
3027
|
const parsed = parseCellFitKey(fit.key);
|
|
3048
3028
|
if (!parsed) {
|
|
@@ -3214,23 +3194,6 @@ function createDomHostRuntime(factory, bundle) {
|
|
|
3214
3194
|
"RENDER_TIMEOUT",
|
|
3215
3195
|
`PDF \u751F\u6210\u8D85\u8FC7 ${ms}ms`
|
|
3216
3196
|
);
|
|
3217
|
-
},
|
|
3218
|
-
async toScreenshot(html, spec, viewport) {
|
|
3219
|
-
if (!driver.screenshot) throw new PrintFailure("UNSUPPORTED_RUNTIME", "\u5F53\u524D\u5BBF\u4E3B\u4E0D\u652F\u6301\u622A\u56FE");
|
|
3220
|
-
const ms = budget();
|
|
3221
|
-
return withTimeout(
|
|
3222
|
-
(async () => {
|
|
3223
|
-
try {
|
|
3224
|
-
await load(html, viewport);
|
|
3225
|
-
return await driver.screenshot(html, spec);
|
|
3226
|
-
} catch (err) {
|
|
3227
|
-
throw fail(err, "SCREENSHOT_FAILED", "\u622A\u56FE\u5931\u8D25");
|
|
3228
|
-
}
|
|
3229
|
-
})(),
|
|
3230
|
-
ms,
|
|
3231
|
-
"RENDER_TIMEOUT",
|
|
3232
|
-
`\u622A\u56FE\u8D85\u8FC7 ${ms}ms`
|
|
3233
|
-
);
|
|
3234
3197
|
}
|
|
3235
3198
|
};
|
|
3236
3199
|
try {
|
|
@@ -3565,33 +3528,6 @@ async function renderPdf(job, runtime) {
|
|
|
3565
3528
|
return { pdf, prepared };
|
|
3566
3529
|
});
|
|
3567
3530
|
}
|
|
3568
|
-
async function renderScreenshot(job, runtime) {
|
|
3569
|
-
return runtime.withSession(job, async (session) => {
|
|
3570
|
-
const pageTemplates = normalizeTemplate(job.templateJson);
|
|
3571
|
-
if (pageTemplates.length > 1) {
|
|
3572
|
-
const normalized2 = normalizePrintData(job.printData);
|
|
3573
|
-
const data2 = normalized2.mode === "batch" ? normalized2.dataList[0] : normalized2.data;
|
|
3574
|
-
const copy = await prepareMultiCopy(job, session, data2);
|
|
3575
|
-
const doc = composeMultiPageDocument([copy]);
|
|
3576
|
-
const viewport2 = paperViewportPx(getPaperDimensions(pageTemplates[0]));
|
|
3577
|
-
return session.toScreenshot(doc.html, buildScreenshotTargetSpec(), viewport2);
|
|
3578
|
-
}
|
|
3579
|
-
const singleJob = pageTemplates[0] !== job.templateJson ? { ...job, templateJson: pageTemplates[0] } : job;
|
|
3580
|
-
const normalized = normalizePrintData(singleJob.printData);
|
|
3581
|
-
const data = normalized.mode === "batch" ? normalized.dataList[0] : normalized.data;
|
|
3582
|
-
const bound = bindData(singleJob.templateJson, data, singleJob.baseUrl, singleJob.fontBaseUrl);
|
|
3583
|
-
const built = await buildHtmlWithCodes({
|
|
3584
|
-
bound,
|
|
3585
|
-
job: singleJob,
|
|
3586
|
-
session,
|
|
3587
|
-
data,
|
|
3588
|
-
pageLayouts: [],
|
|
3589
|
-
isMeasurementPass: true
|
|
3590
|
-
});
|
|
3591
|
-
const viewport = paperViewportPx(getPaperDimensions(bound));
|
|
3592
|
-
return session.toScreenshot(built.html, buildScreenshotTargetSpec(), viewport);
|
|
3593
|
-
});
|
|
3594
|
-
}
|
|
3595
3531
|
async function prepareWithSession(job, session) {
|
|
3596
3532
|
const pageTemplates = normalizeTemplate(job.templateJson);
|
|
3597
3533
|
if (pageTemplates.length > 1) {
|
|
@@ -3872,7 +3808,6 @@ var TemplateEngine = class {
|
|
|
3872
3808
|
buildPageGeometryCss,
|
|
3873
3809
|
buildPageRuleCss,
|
|
3874
3810
|
buildPdfTargetSpec,
|
|
3875
|
-
buildScreenshotTargetSpec,
|
|
3876
3811
|
cellFitCapMm,
|
|
3877
3812
|
cellFitKey,
|
|
3878
3813
|
codeSpecKey,
|
|
@@ -3928,7 +3863,6 @@ var TemplateEngine = class {
|
|
|
3928
3863
|
prepareDocument,
|
|
3929
3864
|
pxToMm,
|
|
3930
3865
|
renderPdf,
|
|
3931
|
-
renderScreenshot,
|
|
3932
3866
|
renderTemplate,
|
|
3933
3867
|
renderWatermarkLayerHtml,
|
|
3934
3868
|
renderWatermarkTileSvg,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/core v1.3.5
|
|
3
|
+
* Copyright (c) 2026 Worm Base AI
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 Worm Base AI
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
import { T as TemplateData, C as CodeRenderer, P as PageLayout, J as MeasuredElement, K as TemplateElement, W as WatermarkOptions, L as PaperMm, N as ViewportPx, O as HeightSource, Q as MarginsMm, S as PdfTargetSpec, R as RawMeasurement, a as CodeSpec, X as CodeRenderOptions, D as DriverFactory, Y as ExecutorBundle, Z as TileLayout, _ as PrintJob, $ as PreparedDocument, a0 as RenderPdfResult, M as MultiPageTemplateData, a1 as PrintFontDeclaration } from './driver-CFm0C_yX.cjs';
|
|
8
|
+
export { a2 as ContinuousPaperSize, a3 as EXECUTOR_TARGETS, a4 as ExecutorMethod, a5 as ExecutorTargetKind, a6 as FALLBACK_FONT_STACK, a7 as MAX_BATCH_COPIES, a8 as NormalizedPrintData, a9 as PAPER_DIMENSIONS, aa as PageDriver, ab as PageSection, ac as PaperSize, ad as PrintDataInput, ae as PrintFontFile, af as RenderCell, ag as RenderRequest, ah as RenderRow, ai as SheetPaperSize, aj as TILE_DEFAULTS, H as TextFit, ak as TilingError, al as TilingIssue, am as TilingIssueCode, an as TilingOptions, ao as TilingResolveOptions, ap as TilingTemplateInput, aq as buildFontFaceCss, ar as computeMaxColumns, as as computeTileLayout, at as escapeInlineStyleValue, au as getPaperDimensions, av as isContinuousPaper, aw as isContinuousPaperSize, ax as normalizePrintData, ay as normalizeTilingOptions, az as resolveSheetMm, aA as roundMm, aB as tilePosition, aC as toFontFamilyStack, aD as validateTiling } from './driver-CFm0C_yX.cjs';
|
|
9
|
+
import { F as FitFontSize, P as PrintRuntime } from './ports-BXYcHExa.cjs';
|
|
10
|
+
export { C as CellFitRowKind, h as DEFAULT_READINESS_MS, D as DEFAULT_SHRINK_MIN_FONT_SIZE_PT, i as DEFAULT_TIMEOUT_MS, M as MIN_SHRINK_FONT_SIZE_PT, j as MeasureResult, k as PrintSession, S as SessionBudget, c as cellFitCapMm, a as cellFitKey, f as floorFontSize, p as parseCellFitKey, r as resolveCellTextFit, d as resolveElementTextFit, e as resolveShrinkMinFontSize, g as roundFontSize } from './ports-BXYcHExa.cjs';
|
|
5
11
|
|
|
6
12
|
type TokenType = 'num' | 'str' | 'bool' | 'ident' | 'punc';
|
|
7
13
|
interface Token {
|
|
@@ -218,7 +224,7 @@ declare function buildPageRuleCss(template: TemplateData, pageHeightMm?: number)
|
|
|
218
224
|
declare function buildPageGeometryCss(template: TemplateData, scope?: string, pageHeightMm?: number): string;
|
|
219
225
|
/**
|
|
220
226
|
* 生成完整的打印页面 CSS。
|
|
221
|
-
*
|
|
227
|
+
* 包含纸张尺寸、边距、页眉页脚、内容区几何等样式。
|
|
222
228
|
* 出纸旋转角度非 0(固定纸)时,额外输出 .print-page-rotor / .print-page-rotor-${angle} 转子规则完成整页旋转。
|
|
223
229
|
* @param pageHeightMm 连续纸由浏览器探针推导出的最终纸高(mm);传入时替换模板纸张高度,
|
|
224
230
|
* 使 @page/.print-page/footer 全部对齐该高度。普通纸不传。
|
|
@@ -246,7 +252,7 @@ declare function tableDesignBottom(el: TemplateElement): number;
|
|
|
246
252
|
* 1. 计算页面可用高度(contentHeight / availableHeight)
|
|
247
253
|
* 2. 按 Y 坐标顺序遍历内容区元素
|
|
248
254
|
* 3. 表格:逐行切片;非表格:元素级不拆分
|
|
249
|
-
* 4. 处理 keepWithNext
|
|
255
|
+
* 4. 处理 keepWithNext、单行超高、表格跟随等边界
|
|
250
256
|
* 5. 表格下方跟随区:与最后一片同页时包成 flow-group;放不下整体移下一页
|
|
251
257
|
*/
|
|
252
258
|
declare function paginate(template: TemplateData, measuredElements: Map<string, MeasuredElement>): PageLayout[];
|
|
@@ -369,7 +375,7 @@ declare function micrometersToMillimeters(um: number): number;
|
|
|
369
375
|
declare function millimetersToInches(mm: number): number;
|
|
370
376
|
|
|
371
377
|
/** core 统一失败分类;各端只做映射,不新增协议码 */
|
|
372
|
-
type PrintFailureCode = 'INVALID_PAPER' | 'MEASURE_FAILED' | 'RENDER_TIMEOUT' | 'PDF_FAILED' | '
|
|
378
|
+
type PrintFailureCode = 'INVALID_PAPER' | 'MEASURE_FAILED' | 'RENDER_TIMEOUT' | 'PDF_FAILED' | 'UNSUPPORTED_RUNTIME' | 'INTERNAL';
|
|
373
379
|
declare class PrintFailure extends Error {
|
|
374
380
|
readonly code: PrintFailureCode;
|
|
375
381
|
readonly cause?: unknown;
|
|
@@ -433,8 +439,6 @@ interface PlaywrightPdfOptions {
|
|
|
433
439
|
preferCSSPageSize: boolean;
|
|
434
440
|
}
|
|
435
441
|
declare function toPlaywrightPdfOptions(spec: PdfTargetSpec): PlaywrightPdfOptions;
|
|
436
|
-
/** Playwright page.screenshot 的最小结构 */
|
|
437
|
-
declare function buildScreenshotTargetSpec(): ScreenshotTargetSpec;
|
|
438
442
|
|
|
439
443
|
/**
|
|
440
444
|
* 原始测量 → 分页输入。三端共用:px→mm、表格行高、重复表头段高度。
|
|
@@ -518,8 +522,6 @@ declare function composeTiledHtml(input: {
|
|
|
518
522
|
declare function prepareDocument(job: PrintJob, runtime: PrintRuntime): Promise<PreparedDocument>;
|
|
519
523
|
/** 阶段 1–7:prepared + HTML→PDF,且与准备阶段共用同一个 driver 会话 */
|
|
520
524
|
declare function renderPdf(job: PrintJob, runtime: PrintRuntime): Promise<RenderPdfResult>;
|
|
521
|
-
/** 截图:不分页,用测量模式 HTML 单页完整渲染;数组数据仅渲染首条。不参与拼版(仍是标签纸单页快照) */
|
|
522
|
-
declare function renderScreenshot(job: PrintJob, runtime: PrintRuntime): Promise<Uint8Array>;
|
|
523
525
|
|
|
524
526
|
/**
|
|
525
527
|
* 归一化模板为页面模板数组:
|
|
@@ -573,4 +575,4 @@ declare class TemplateEngine {
|
|
|
573
575
|
render(template: string, context: Record<string, any>): string;
|
|
574
576
|
}
|
|
575
577
|
|
|
576
|
-
export { type ASTNode, type BatchCopyInput, CodeRenderOptions, CodeRenderer, CodeSpec, type CollectingCodeRenderer, DriverFactory, type ElectronPrintToPdfOptions, type EngineOptions, ExecutorBundle, type ExprFunction, FitFontSize, type GenerateOptions, HeightSource, MICROMETERS_PER_INCH, MICROMETERS_PER_MM, MIN_CONTINUOUS_HEIGHT_MM, MM_PER_INCH, MM_PER_PX, MarginsMm, MeasuredElement, type MultiPageCopyInput, type MultiPageDocument, MultiPageTemplateData, PX_PER_MM, PageLayout, PaperMm, type PaperOverride, PdfTargetSpec, type PlaywrightPdfOptions, PreparedDocument, PrintFailure, type PrintFailureCode, PrintFontDeclaration, PrintJob, PrintRuntime, TemplateData as PrintTemplateData, TemplateElement as PrintTemplateElement, RawMeasurement, type RenderFinalPagesOptions, RenderPdfResult, type ResolvePaperInput, type ResolvedWatermark,
|
|
578
|
+
export { type ASTNode, type BatchCopyInput, CodeRenderOptions, CodeRenderer, CodeSpec, type CollectingCodeRenderer, DriverFactory, type ElectronPrintToPdfOptions, type EngineOptions, ExecutorBundle, type ExprFunction, FitFontSize, type GenerateOptions, HeightSource, MICROMETERS_PER_INCH, MICROMETERS_PER_MM, MIN_CONTINUOUS_HEIGHT_MM, MM_PER_INCH, MM_PER_PX, MarginsMm, MeasuredElement, type MultiPageCopyInput, type MultiPageDocument, MultiPageTemplateData, PX_PER_MM, PageLayout, PaperMm, type PaperOverride, PdfTargetSpec, type PlaywrightPdfOptions, PreparedDocument, PrintFailure, type PrintFailureCode, PrintFontDeclaration, PrintJob, PrintRuntime, TemplateData as PrintTemplateData, TemplateElement as PrintTemplateElement, RawMeasurement, type RenderFinalPagesOptions, RenderPdfResult, type ResolvePaperInput, type ResolvedWatermark, type SystemVariableContext, type TemplateAST, TemplateEngine, type TileInput, TileLayout, ViewportPx, WATERMARK_DEFAULTS, WATERMARK_DENSITY_PRESETS, WatermarkOptions, type WatermarkPaper, type WatermarkTile, addNumbers, applyTextFitSizes, avg, bindData, buildBasePageCss, buildPageCss, buildPageGeometryCss, buildPageRuleCss, buildPdfTargetSpec, codeSpecKey, compileTemplate, composeBatchHtml, composeContinuousHeight, composeMultiPageDocument, composeTiledHtml, count, createCollectingCodeRenderer, createDomHostRuntime, createMapCodeRenderer, divideNumbers, elementPositionStyle, escapeHeightMm, evaluate, evaluateTemplate, formatDate, formatMoney, formatTimestamp, generateHtml, getByPath, ifFn, injectSystemVariables, isMultiPageTemplate, isWatermarkVisible, max, mergeCodeMaps, mergeFontDeclarations, micrometersToMillimeters, millimetersToInches, millimetersToMicrometers, min, mm, mmToPx, multiplyNumbers, normalizeMeasurements, normalizeTemplate, paginate, paperViewportPx, parse, parseTemplate, prepareDocument, pxToMm, renderPdf, renderTemplate, renderWatermarkLayerHtml, renderWatermarkTileSvg, resolvePaperMm, resolveSystemVariables, resolveWatermarkLayout, resolveWatermarkText, round, roundDown, roundHalfEven, roundUp, safeEval, setPageIndex, setTotalPages, subtractNumbers, sum, systemVars, tableDesignBottom, toElectronPrintToPdfOptions, toPlaywrightPdfOptions, toPrintFailure, toUpperCaseAmount, tokenize, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/core v1.3.5
|
|
3
|
+
* Copyright (c) 2026 Worm Base AI
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 Worm Base AI
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
import { T as TemplateData, C as CodeRenderer, P as PageLayout, J as MeasuredElement, K as TemplateElement, W as WatermarkOptions, L as PaperMm, N as ViewportPx, O as HeightSource, Q as MarginsMm, S as PdfTargetSpec, R as RawMeasurement, a as CodeSpec, X as CodeRenderOptions, D as DriverFactory, Y as ExecutorBundle, Z as TileLayout, _ as PrintJob, $ as PreparedDocument, a0 as RenderPdfResult, M as MultiPageTemplateData, a1 as PrintFontDeclaration } from './driver-CFm0C_yX.js';
|
|
8
|
+
export { a2 as ContinuousPaperSize, a3 as EXECUTOR_TARGETS, a4 as ExecutorMethod, a5 as ExecutorTargetKind, a6 as FALLBACK_FONT_STACK, a7 as MAX_BATCH_COPIES, a8 as NormalizedPrintData, a9 as PAPER_DIMENSIONS, aa as PageDriver, ab as PageSection, ac as PaperSize, ad as PrintDataInput, ae as PrintFontFile, af as RenderCell, ag as RenderRequest, ah as RenderRow, ai as SheetPaperSize, aj as TILE_DEFAULTS, H as TextFit, ak as TilingError, al as TilingIssue, am as TilingIssueCode, an as TilingOptions, ao as TilingResolveOptions, ap as TilingTemplateInput, aq as buildFontFaceCss, ar as computeMaxColumns, as as computeTileLayout, at as escapeInlineStyleValue, au as getPaperDimensions, av as isContinuousPaper, aw as isContinuousPaperSize, ax as normalizePrintData, ay as normalizeTilingOptions, az as resolveSheetMm, aA as roundMm, aB as tilePosition, aC as toFontFamilyStack, aD as validateTiling } from './driver-CFm0C_yX.js';
|
|
9
|
+
import { F as FitFontSize, P as PrintRuntime } from './ports-Bdst9MWJ.js';
|
|
10
|
+
export { C as CellFitRowKind, h as DEFAULT_READINESS_MS, D as DEFAULT_SHRINK_MIN_FONT_SIZE_PT, i as DEFAULT_TIMEOUT_MS, M as MIN_SHRINK_FONT_SIZE_PT, j as MeasureResult, k as PrintSession, S as SessionBudget, c as cellFitCapMm, a as cellFitKey, f as floorFontSize, p as parseCellFitKey, r as resolveCellTextFit, d as resolveElementTextFit, e as resolveShrinkMinFontSize, g as roundFontSize } from './ports-Bdst9MWJ.js';
|
|
5
11
|
|
|
6
12
|
type TokenType = 'num' | 'str' | 'bool' | 'ident' | 'punc';
|
|
7
13
|
interface Token {
|
|
@@ -218,7 +224,7 @@ declare function buildPageRuleCss(template: TemplateData, pageHeightMm?: number)
|
|
|
218
224
|
declare function buildPageGeometryCss(template: TemplateData, scope?: string, pageHeightMm?: number): string;
|
|
219
225
|
/**
|
|
220
226
|
* 生成完整的打印页面 CSS。
|
|
221
|
-
*
|
|
227
|
+
* 包含纸张尺寸、边距、页眉页脚、内容区几何等样式。
|
|
222
228
|
* 出纸旋转角度非 0(固定纸)时,额外输出 .print-page-rotor / .print-page-rotor-${angle} 转子规则完成整页旋转。
|
|
223
229
|
* @param pageHeightMm 连续纸由浏览器探针推导出的最终纸高(mm);传入时替换模板纸张高度,
|
|
224
230
|
* 使 @page/.print-page/footer 全部对齐该高度。普通纸不传。
|
|
@@ -246,7 +252,7 @@ declare function tableDesignBottom(el: TemplateElement): number;
|
|
|
246
252
|
* 1. 计算页面可用高度(contentHeight / availableHeight)
|
|
247
253
|
* 2. 按 Y 坐标顺序遍历内容区元素
|
|
248
254
|
* 3. 表格:逐行切片;非表格:元素级不拆分
|
|
249
|
-
* 4. 处理 keepWithNext
|
|
255
|
+
* 4. 处理 keepWithNext、单行超高、表格跟随等边界
|
|
250
256
|
* 5. 表格下方跟随区:与最后一片同页时包成 flow-group;放不下整体移下一页
|
|
251
257
|
*/
|
|
252
258
|
declare function paginate(template: TemplateData, measuredElements: Map<string, MeasuredElement>): PageLayout[];
|
|
@@ -369,7 +375,7 @@ declare function micrometersToMillimeters(um: number): number;
|
|
|
369
375
|
declare function millimetersToInches(mm: number): number;
|
|
370
376
|
|
|
371
377
|
/** core 统一失败分类;各端只做映射,不新增协议码 */
|
|
372
|
-
type PrintFailureCode = 'INVALID_PAPER' | 'MEASURE_FAILED' | 'RENDER_TIMEOUT' | 'PDF_FAILED' | '
|
|
378
|
+
type PrintFailureCode = 'INVALID_PAPER' | 'MEASURE_FAILED' | 'RENDER_TIMEOUT' | 'PDF_FAILED' | 'UNSUPPORTED_RUNTIME' | 'INTERNAL';
|
|
373
379
|
declare class PrintFailure extends Error {
|
|
374
380
|
readonly code: PrintFailureCode;
|
|
375
381
|
readonly cause?: unknown;
|
|
@@ -433,8 +439,6 @@ interface PlaywrightPdfOptions {
|
|
|
433
439
|
preferCSSPageSize: boolean;
|
|
434
440
|
}
|
|
435
441
|
declare function toPlaywrightPdfOptions(spec: PdfTargetSpec): PlaywrightPdfOptions;
|
|
436
|
-
/** Playwright page.screenshot 的最小结构 */
|
|
437
|
-
declare function buildScreenshotTargetSpec(): ScreenshotTargetSpec;
|
|
438
442
|
|
|
439
443
|
/**
|
|
440
444
|
* 原始测量 → 分页输入。三端共用:px→mm、表格行高、重复表头段高度。
|
|
@@ -518,8 +522,6 @@ declare function composeTiledHtml(input: {
|
|
|
518
522
|
declare function prepareDocument(job: PrintJob, runtime: PrintRuntime): Promise<PreparedDocument>;
|
|
519
523
|
/** 阶段 1–7:prepared + HTML→PDF,且与准备阶段共用同一个 driver 会话 */
|
|
520
524
|
declare function renderPdf(job: PrintJob, runtime: PrintRuntime): Promise<RenderPdfResult>;
|
|
521
|
-
/** 截图:不分页,用测量模式 HTML 单页完整渲染;数组数据仅渲染首条。不参与拼版(仍是标签纸单页快照) */
|
|
522
|
-
declare function renderScreenshot(job: PrintJob, runtime: PrintRuntime): Promise<Uint8Array>;
|
|
523
525
|
|
|
524
526
|
/**
|
|
525
527
|
* 归一化模板为页面模板数组:
|
|
@@ -573,4 +575,4 @@ declare class TemplateEngine {
|
|
|
573
575
|
render(template: string, context: Record<string, any>): string;
|
|
574
576
|
}
|
|
575
577
|
|
|
576
|
-
export { type ASTNode, type BatchCopyInput, CodeRenderOptions, CodeRenderer, CodeSpec, type CollectingCodeRenderer, DriverFactory, type ElectronPrintToPdfOptions, type EngineOptions, ExecutorBundle, type ExprFunction, FitFontSize, type GenerateOptions, HeightSource, MICROMETERS_PER_INCH, MICROMETERS_PER_MM, MIN_CONTINUOUS_HEIGHT_MM, MM_PER_INCH, MM_PER_PX, MarginsMm, MeasuredElement, type MultiPageCopyInput, type MultiPageDocument, MultiPageTemplateData, PX_PER_MM, PageLayout, PaperMm, type PaperOverride, PdfTargetSpec, type PlaywrightPdfOptions, PreparedDocument, PrintFailure, type PrintFailureCode, PrintFontDeclaration, PrintJob, PrintRuntime, TemplateData as PrintTemplateData, TemplateElement as PrintTemplateElement, RawMeasurement, type RenderFinalPagesOptions, RenderPdfResult, type ResolvePaperInput, type ResolvedWatermark,
|
|
578
|
+
export { type ASTNode, type BatchCopyInput, CodeRenderOptions, CodeRenderer, CodeSpec, type CollectingCodeRenderer, DriverFactory, type ElectronPrintToPdfOptions, type EngineOptions, ExecutorBundle, type ExprFunction, FitFontSize, type GenerateOptions, HeightSource, MICROMETERS_PER_INCH, MICROMETERS_PER_MM, MIN_CONTINUOUS_HEIGHT_MM, MM_PER_INCH, MM_PER_PX, MarginsMm, MeasuredElement, type MultiPageCopyInput, type MultiPageDocument, MultiPageTemplateData, PX_PER_MM, PageLayout, PaperMm, type PaperOverride, PdfTargetSpec, type PlaywrightPdfOptions, PreparedDocument, PrintFailure, type PrintFailureCode, PrintFontDeclaration, PrintJob, PrintRuntime, TemplateData as PrintTemplateData, TemplateElement as PrintTemplateElement, RawMeasurement, type RenderFinalPagesOptions, RenderPdfResult, type ResolvePaperInput, type ResolvedWatermark, type SystemVariableContext, type TemplateAST, TemplateEngine, type TileInput, TileLayout, ViewportPx, WATERMARK_DEFAULTS, WATERMARK_DENSITY_PRESETS, WatermarkOptions, type WatermarkPaper, type WatermarkTile, addNumbers, applyTextFitSizes, avg, bindData, buildBasePageCss, buildPageCss, buildPageGeometryCss, buildPageRuleCss, buildPdfTargetSpec, codeSpecKey, compileTemplate, composeBatchHtml, composeContinuousHeight, composeMultiPageDocument, composeTiledHtml, count, createCollectingCodeRenderer, createDomHostRuntime, createMapCodeRenderer, divideNumbers, elementPositionStyle, escapeHeightMm, evaluate, evaluateTemplate, formatDate, formatMoney, formatTimestamp, generateHtml, getByPath, ifFn, injectSystemVariables, isMultiPageTemplate, isWatermarkVisible, max, mergeCodeMaps, mergeFontDeclarations, micrometersToMillimeters, millimetersToInches, millimetersToMicrometers, min, mm, mmToPx, multiplyNumbers, normalizeMeasurements, normalizeTemplate, paginate, paperViewportPx, parse, parseTemplate, prepareDocument, pxToMm, renderPdf, renderTemplate, renderWatermarkLayerHtml, renderWatermarkTileSvg, resolvePaperMm, resolveSystemVariables, resolveWatermarkLayout, resolveWatermarkText, round, roundDown, roundHalfEven, roundUp, safeEval, setPageIndex, setTotalPages, subtractNumbers, sum, systemVars, tableDesignBottom, toElectronPrintToPdfOptions, toPlaywrightPdfOptions, toPrintFailure, toUpperCaseAmount, tokenize, withTimeout };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/core v1.3.5
|
|
3
|
+
* Copyright (c) 2026 Worm Base AI
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 Worm Base AI
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
1
7
|
import {
|
|
2
8
|
TemplateEngine
|
|
3
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GHASCGL6.js";
|
|
4
10
|
import {
|
|
5
11
|
DEFAULT_READINESS_MS,
|
|
6
12
|
DEFAULT_SHRINK_MIN_FONT_SIZE_PT,
|
|
@@ -31,7 +37,6 @@ import {
|
|
|
31
37
|
buildPageGeometryCss,
|
|
32
38
|
buildPageRuleCss,
|
|
33
39
|
buildPdfTargetSpec,
|
|
34
|
-
buildScreenshotTargetSpec,
|
|
35
40
|
cellFitCapMm,
|
|
36
41
|
cellFitKey,
|
|
37
42
|
codeSpecKey,
|
|
@@ -87,7 +92,6 @@ import {
|
|
|
87
92
|
prepareDocument,
|
|
88
93
|
pxToMm2 as pxToMm,
|
|
89
94
|
renderPdf,
|
|
90
|
-
renderScreenshot,
|
|
91
95
|
renderTemplate,
|
|
92
96
|
renderWatermarkLayerHtml,
|
|
93
97
|
renderWatermarkTileSvg,
|
|
@@ -121,7 +125,7 @@ import {
|
|
|
121
125
|
tokenize,
|
|
122
126
|
validateTiling,
|
|
123
127
|
withTimeout
|
|
124
|
-
} from "./chunk-
|
|
128
|
+
} from "./chunk-ZCA33XA6.js";
|
|
125
129
|
export {
|
|
126
130
|
DEFAULT_READINESS_MS,
|
|
127
131
|
DEFAULT_SHRINK_MIN_FONT_SIZE_PT,
|
|
@@ -153,7 +157,6 @@ export {
|
|
|
153
157
|
buildPageGeometryCss,
|
|
154
158
|
buildPageRuleCss,
|
|
155
159
|
buildPdfTargetSpec,
|
|
156
|
-
buildScreenshotTargetSpec,
|
|
157
160
|
cellFitCapMm,
|
|
158
161
|
cellFitKey,
|
|
159
162
|
codeSpecKey,
|
|
@@ -209,7 +212,6 @@ export {
|
|
|
209
212
|
prepareDocument,
|
|
210
213
|
pxToMm,
|
|
211
214
|
renderPdf,
|
|
212
|
-
renderScreenshot,
|
|
213
215
|
renderTemplate,
|
|
214
216
|
renderWatermarkLayerHtml,
|
|
215
217
|
renderWatermarkTileSvg,
|
package/dist/node/index.cjs
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/core v1.3.5
|
|
3
|
+
* Copyright (c) 2026 Worm Base AI
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 Worm Base AI
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
1
7
|
"use strict";
|
|
2
8
|
var __defProp = Object.defineProperty;
|
|
3
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
package/dist/node/index.d.cts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/core v1.3.5
|
|
3
|
+
* Copyright (c) 2026 Worm Base AI
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 Worm Base AI
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
import { Y as ExecutorBundle } from '../driver-CFm0C_yX.cjs';
|
|
2
8
|
|
|
3
9
|
/** 读取 core 自带的 DOM 执行器 IIFE 产物;宿主把它注入页面后即可调用 __wormDom */
|
|
4
10
|
declare function loadExecutorBundle(): ExecutorBundle;
|