@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Worm Base AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -26,10 +26,10 @@ print-core/
|
|
|
26
26
|
|
|
27
27
|
### 打印管线(`print/`,纯 TS)
|
|
28
28
|
|
|
29
|
-
- 入口:`prepareDocument(job, runtime)`、`renderPdf(job, runtime)
|
|
30
|
-
- 规格:`buildPdfTargetSpec`、`toElectronPrintToPdfOptions`(英寸)、`toPlaywrightPdfOptions`(mm
|
|
29
|
+
- 入口:`prepareDocument(job, runtime)`、`renderPdf(job, runtime)`;
|
|
30
|
+
- 规格:`buildPdfTargetSpec`、`toElectronPrintToPdfOptions`(英寸)、`toPlaywrightPdfOptions`(mm);
|
|
31
31
|
- 纸张:`resolvePaperMm`(宿主覆盖逃生门)、`paperViewportPx`(测量容器 mm→px)、`escapeHeightMm`(连续纸纸高逃生门);
|
|
32
|
-
- 契约:`PageDriver`(宿主只实现 open/setContent/injectExecutor/evaluate 与可选 pdf
|
|
32
|
+
- 契约:`PageDriver`(宿主只实现 open/setContent/injectExecutor/evaluate 与可选 pdf)+
|
|
33
33
|
`createDomHostRuntime(driverFactory, bundle)`(共享的载入→注入→就绪→执行→释放时序、超时预算与错误归一化);
|
|
34
34
|
- 拼版:`computeTileLayout` / `validateTiling` / `computeMaxColumns` / `tilePosition` / `resolveSheetMm` /
|
|
35
35
|
`composeTiledHtml`(标签多行多列铺到目标纸,如 70×40 标签铺满 A4)。配置为模板级 `TemplateData.tiling`,
|
|
@@ -65,8 +65,8 @@ const html = generateHtml(pages)
|
|
|
65
65
|
```ts
|
|
66
66
|
import { PrintDesigner, PrintHtmlPreview, createDefaultTemplate } from '@worm-vue3-print/canvas'
|
|
67
67
|
import type { PrintBusinessField, TemplateData } from '@worm-vue3-print/canvas'
|
|
68
|
-
//
|
|
69
|
-
import '@worm-vue3-print/canvas/
|
|
68
|
+
// 设计器控件样式(发布包唯一对外样式入口),需全局引入一次
|
|
69
|
+
import '@worm-vue3-print/canvas/style.css'
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
```vue
|
package/dist/browser/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 __create = Object.create;
|
|
3
9
|
var __defProp = Object.defineProperty;
|
|
@@ -173,23 +179,6 @@ function createDomHostRuntime(factory, bundle) {
|
|
|
173
179
|
"RENDER_TIMEOUT",
|
|
174
180
|
`PDF \u751F\u6210\u8D85\u8FC7 ${ms}ms`
|
|
175
181
|
);
|
|
176
|
-
},
|
|
177
|
-
async toScreenshot(html, spec, viewport) {
|
|
178
|
-
if (!driver.screenshot) throw new PrintFailure("UNSUPPORTED_RUNTIME", "\u5F53\u524D\u5BBF\u4E3B\u4E0D\u652F\u6301\u622A\u56FE");
|
|
179
|
-
const ms = budget();
|
|
180
|
-
return withTimeout(
|
|
181
|
-
(async () => {
|
|
182
|
-
try {
|
|
183
|
-
await load(html, viewport);
|
|
184
|
-
return await driver.screenshot(html, spec);
|
|
185
|
-
} catch (err) {
|
|
186
|
-
throw fail(err, "SCREENSHOT_FAILED", "\u622A\u56FE\u5931\u8D25");
|
|
187
|
-
}
|
|
188
|
-
})(),
|
|
189
|
-
ms,
|
|
190
|
-
"RENDER_TIMEOUT",
|
|
191
|
-
`\u622A\u56FE\u8D85\u8FC7 ${ms}ms`
|
|
192
|
-
);
|
|
193
182
|
}
|
|
194
183
|
};
|
|
195
184
|
try {
|
|
@@ -1517,9 +1506,6 @@ function bindData(template, printData, baseUrl, fontBaseUrl) {
|
|
|
1517
1506
|
if (bound.footer?.elements) {
|
|
1518
1507
|
bound.footer.elements = bound.footer.elements.map((el) => bindElement(el, data, baseUrl));
|
|
1519
1508
|
}
|
|
1520
|
-
if (bound.firstPageOverlay?.elements) {
|
|
1521
|
-
bound.firstPageOverlay.elements = bound.firstPageOverlay.elements.map((el) => bindElement(el, data, baseUrl));
|
|
1522
|
-
}
|
|
1523
1509
|
bound.elements = bound.elements.map((el) => bindElement(el, data, baseUrl));
|
|
1524
1510
|
const fontBase = fontBaseUrl ?? baseUrl;
|
|
1525
1511
|
if (fontBase && bound.fonts?.length) {
|
|
@@ -1960,7 +1946,6 @@ function areaGeometryBlock(template, paper, desc) {
|
|
|
1960
1946
|
const { bottom: mb } = template.margins;
|
|
1961
1947
|
const headerH = template.header?.height ?? 0;
|
|
1962
1948
|
const footerH = template.footer?.height ?? 0;
|
|
1963
|
-
const overlayH = template.firstPageOverlay?.height ?? 0;
|
|
1964
1949
|
const contentWidth = paper.width - ml - mr;
|
|
1965
1950
|
return `
|
|
1966
1951
|
/* \u2500\u2500 \u9875\u7709 \u2500\u2500 */
|
|
@@ -1988,13 +1973,6 @@ ${desc}.content-area {
|
|
|
1988
1973
|
position: relative;
|
|
1989
1974
|
overflow: visible;
|
|
1990
1975
|
}
|
|
1991
|
-
|
|
1992
|
-
/* \u2500\u2500 \u9996\u9875\u53E0\u52A0\u533A\u57DF \u2500\u2500 */
|
|
1993
|
-
${desc}.first-page-overlay {
|
|
1994
|
-
width: ${mm(contentWidth)};
|
|
1995
|
-
height: ${mm(overlayH)};
|
|
1996
|
-
position: relative;
|
|
1997
|
-
}
|
|
1998
1976
|
`;
|
|
1999
1977
|
}
|
|
2000
1978
|
function buildBasePageCss() {
|
|
@@ -2397,7 +2375,6 @@ function paginate(template, measuredElements) {
|
|
|
2397
2375
|
const { top: mt, bottom: mb } = template.margins;
|
|
2398
2376
|
const headerH = template.header?.height ?? 0;
|
|
2399
2377
|
const footerH = template.footer?.height ?? 0;
|
|
2400
|
-
const overlayH = template.firstPageOverlay?.height ?? 0;
|
|
2401
2378
|
const continuous = isContinuousPaper(template);
|
|
2402
2379
|
const contentHeight = continuous ? Number.POSITIVE_INFINITY : paper.height - mt - mb - headerH - footerH;
|
|
2403
2380
|
if (!continuous && contentHeight <= 0) {
|
|
@@ -2437,8 +2414,7 @@ function paginate(template, measuredElements) {
|
|
|
2437
2414
|
const unitOf = buildPaginationUnits(sorted, measuredElements, groupMap);
|
|
2438
2415
|
const pages = [];
|
|
2439
2416
|
let currentPage = [];
|
|
2440
|
-
let remaining = contentHeight -
|
|
2441
|
-
let isFirstPage = true;
|
|
2417
|
+
let remaining = contentHeight - SAFETY_MARGIN;
|
|
2442
2418
|
let pageBroken = false;
|
|
2443
2419
|
function sectionTop(el) {
|
|
2444
2420
|
return pageBroken ? pageCursorTop() : el.options?.top ?? 0;
|
|
@@ -2447,7 +2423,7 @@ function paginate(template, measuredElements) {
|
|
|
2447
2423
|
return Math.max(0, fullPageHeight() - remaining);
|
|
2448
2424
|
}
|
|
2449
2425
|
function fullPageHeight() {
|
|
2450
|
-
return
|
|
2426
|
+
return contentHeight - SAFETY_MARGIN;
|
|
2451
2427
|
}
|
|
2452
2428
|
let overflowOnCurrent = false;
|
|
2453
2429
|
function pushPage() {
|
|
@@ -2466,7 +2442,6 @@ function paginate(template, measuredElements) {
|
|
|
2466
2442
|
pushPage();
|
|
2467
2443
|
currentPage = [];
|
|
2468
2444
|
remaining = contentHeight - SAFETY_MARGIN;
|
|
2469
|
-
isFirstPage = false;
|
|
2470
2445
|
pageBroken = true;
|
|
2471
2446
|
overflowOnCurrent = false;
|
|
2472
2447
|
}
|
|
@@ -2769,7 +2744,6 @@ function generateMeasurementHtml(template, css, ctx, printData) {
|
|
|
2769
2744
|
// totalPages placeholder
|
|
2770
2745
|
ctx
|
|
2771
2746
|
);
|
|
2772
|
-
const overlayHtml = renderAreaElements(template.firstPageOverlay?.elements ?? [], contentWidth, void 0, void 0, ctx);
|
|
2773
2747
|
let html = `<!DOCTYPE html>
|
|
2774
2748
|
<html lang="zh-CN">
|
|
2775
2749
|
<head>
|
|
@@ -2780,7 +2754,6 @@ function generateMeasurementHtml(template, css, ctx, printData) {
|
|
|
2780
2754
|
<section class="print-page" data-measure-page="0">
|
|
2781
2755
|
${renderWatermarkLayerHtml(template.watermark, printData, getPaperDims(template))}
|
|
2782
2756
|
<div class="page-header">${headerHtml}</div>
|
|
2783
|
-
<div class="first-page-overlay">${overlayHtml}</div>
|
|
2784
2757
|
<div class="content-area" style="height:auto;overflow:visible;">
|
|
2785
2758
|
${elementsHtml}
|
|
2786
2759
|
</div>
|
|
@@ -2844,14 +2817,12 @@ function renderPage(template, page, pageNum, totalPages, ctx, printData, pageCla
|
|
|
2844
2817
|
totalPages,
|
|
2845
2818
|
pageCtx
|
|
2846
2819
|
);
|
|
2847
|
-
const overlayHtml = page.pageIndex === 0 ? `<div class="first-page-overlay">${renderAreaElements(scoped.firstPageOverlay?.elements ?? [], contentWidth, pageNum, totalPages, pageCtx)}</div>` : "";
|
|
2848
2820
|
let contentHtml = page.sections.map((section) => renderSection(section, scoped, pageCtx)).join("\n");
|
|
2849
2821
|
contentHtml = contentHtml.replace(/\{pageIndex\}/g, String(pageNum));
|
|
2850
2822
|
contentHtml = contentHtml.replace(/\{totalPages\}/g, String(totalPages));
|
|
2851
2823
|
const pageInner = `
|
|
2852
2824
|
${renderWatermarkLayerHtml(template.watermark, printData, paperMm, { pageIndex: pageNum, totalPages })}
|
|
2853
2825
|
<div class="page-header">${headerHtml}</div>
|
|
2854
|
-
${overlayHtml}
|
|
2855
2826
|
<div class="content-area">
|
|
2856
2827
|
${contentHtml}
|
|
2857
2828
|
</div>
|
|
@@ -2875,16 +2846,14 @@ function withPageNumbers(template, vars) {
|
|
|
2875
2846
|
...template,
|
|
2876
2847
|
elements: template.elements.map(mapEl),
|
|
2877
2848
|
header: mapArea(template.header),
|
|
2878
|
-
footer: mapArea(template.footer)
|
|
2879
|
-
firstPageOverlay: mapArea(template.firstPageOverlay)
|
|
2849
|
+
footer: mapArea(template.footer)
|
|
2880
2850
|
};
|
|
2881
2851
|
}
|
|
2882
2852
|
function templateReferencesPageNumbers(template) {
|
|
2883
2853
|
const areas = [
|
|
2884
2854
|
template.elements,
|
|
2885
2855
|
template.header?.elements,
|
|
2886
|
-
template.footer?.elements
|
|
2887
|
-
template.firstPageOverlay?.elements
|
|
2856
|
+
template.footer?.elements
|
|
2888
2857
|
];
|
|
2889
2858
|
return areas.some((list) => (list ?? []).some((el) => typeof el.options?.rawFormatter === "string"));
|
|
2890
2859
|
}
|
|
@@ -3376,7 +3345,6 @@ function applyTextFitSizes(template, fits) {
|
|
|
3376
3345
|
collect(template.elements);
|
|
3377
3346
|
collect(template.header?.elements);
|
|
3378
3347
|
collect(template.footer?.elements);
|
|
3379
|
-
collect(template.firstPageOverlay?.elements);
|
|
3380
3348
|
for (const fit of fits) {
|
|
3381
3349
|
const parsed = parseCellFitKey(fit.key);
|
|
3382
3350
|
if (!parsed) {
|
package/dist/browser/index.d.cts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 { P as PageLayout, T as TemplateData, M as MultiPageTemplateData, C as CodeRenderer, D as DriverFactory, R as RawMeasurement, a as CodeSpec } from '../driver-CFm0C_yX.cjs';
|
|
8
|
+
import { P as PrintRuntime, F as FitFontSize } from '../ports-BXYcHExa.cjs';
|
|
3
9
|
|
|
4
10
|
interface BrowserRenderResult {
|
|
5
11
|
/** 最终多页 HTML 字符串 */
|
|
@@ -46,7 +52,7 @@ declare function renderHtmlPages(template: TemplateData | MultiPageTemplateData,
|
|
|
46
52
|
/** 浏览器条码/二维码渲染器;码值非法或为空时抛错,由渲染管线降级文本占位 */
|
|
47
53
|
declare const browserCodeRenderer: CodeRenderer;
|
|
48
54
|
|
|
49
|
-
/** 浏览器端 runtime:iframe driver + 进程内执行器;不提供 PDF
|
|
55
|
+
/** 浏览器端 runtime:iframe driver + 进程内执行器;不提供 PDF */
|
|
50
56
|
declare function createBrowserPrintRuntime(): PrintRuntime;
|
|
51
57
|
|
|
52
58
|
/** 浏览器 iframe driver:进程内直调执行器,无需注入脚本;不提供出图能力 */
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 { P as PageLayout, T as TemplateData, M as MultiPageTemplateData, C as CodeRenderer, D as DriverFactory, R as RawMeasurement, a as CodeSpec } from '../driver-CFm0C_yX.js';
|
|
8
|
+
import { P as PrintRuntime, F as FitFontSize } from '../ports-Bdst9MWJ.js';
|
|
3
9
|
|
|
4
10
|
interface BrowserRenderResult {
|
|
5
11
|
/** 最终多页 HTML 字符串 */
|
|
@@ -46,7 +52,7 @@ declare function renderHtmlPages(template: TemplateData | MultiPageTemplateData,
|
|
|
46
52
|
/** 浏览器条码/二维码渲染器;码值非法或为空时抛错,由渲染管线降级文本占位 */
|
|
47
53
|
declare const browserCodeRenderer: CodeRenderer;
|
|
48
54
|
|
|
49
|
-
/** 浏览器端 runtime:iframe driver + 进程内执行器;不提供 PDF
|
|
55
|
+
/** 浏览器端 runtime:iframe driver + 进程内执行器;不提供 PDF */
|
|
50
56
|
declare function createBrowserPrintRuntime(): PrintRuntime;
|
|
51
57
|
|
|
52
58
|
/** 浏览器 iframe driver:进程内直调执行器,无需注入脚本;不提供出图能力 */
|
package/dist/browser/index.js
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
|
import {
|
|
2
8
|
BARCODE_BAR_HEIGHT_MODULES,
|
|
3
9
|
BARCODE_MARGIN_BOTTOM_MODULES,
|
|
@@ -11,7 +17,7 @@ import {
|
|
|
11
17
|
prepareDocument,
|
|
12
18
|
resolveBarcodeSize,
|
|
13
19
|
resolveShrinkMinFontSize
|
|
14
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-ZCA33XA6.js";
|
|
15
21
|
|
|
16
22
|
// src/browser/browser-code-renderer.ts
|
|
17
23
|
import JsBarcode from "jsbarcode";
|
|
@@ -1,9 +1,15 @@
|
|
|
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
|
compileTemplate,
|
|
3
9
|
evaluate,
|
|
4
10
|
parse,
|
|
5
11
|
tokenize
|
|
6
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ZCA33XA6.js";
|
|
7
13
|
|
|
8
14
|
// src/index.ts
|
|
9
15
|
var TemplateEngine = class {
|
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
// src/lexer.ts
|
|
2
9
|
var DANGEROUS_PROPS = /* @__PURE__ */ new Set([
|
|
3
10
|
"constructor",
|
|
@@ -925,9 +932,6 @@ function bindData(template, printData, baseUrl, fontBaseUrl) {
|
|
|
925
932
|
if (bound.footer?.elements) {
|
|
926
933
|
bound.footer.elements = bound.footer.elements.map((el) => bindElement(el, data, baseUrl));
|
|
927
934
|
}
|
|
928
|
-
if (bound.firstPageOverlay?.elements) {
|
|
929
|
-
bound.firstPageOverlay.elements = bound.firstPageOverlay.elements.map((el) => bindElement(el, data, baseUrl));
|
|
930
|
-
}
|
|
931
935
|
bound.elements = bound.elements.map((el) => bindElement(el, data, baseUrl));
|
|
932
936
|
const fontBase = fontBaseUrl ?? baseUrl;
|
|
933
937
|
if (fontBase && bound.fonts?.length) {
|
|
@@ -1368,7 +1372,6 @@ function areaGeometryBlock(template, paper, desc) {
|
|
|
1368
1372
|
const { bottom: mb } = template.margins;
|
|
1369
1373
|
const headerH = template.header?.height ?? 0;
|
|
1370
1374
|
const footerH = template.footer?.height ?? 0;
|
|
1371
|
-
const overlayH = template.firstPageOverlay?.height ?? 0;
|
|
1372
1375
|
const contentWidth = paper.width - ml - mr;
|
|
1373
1376
|
return `
|
|
1374
1377
|
/* \u2500\u2500 \u9875\u7709 \u2500\u2500 */
|
|
@@ -1396,13 +1399,6 @@ ${desc}.content-area {
|
|
|
1396
1399
|
position: relative;
|
|
1397
1400
|
overflow: visible;
|
|
1398
1401
|
}
|
|
1399
|
-
|
|
1400
|
-
/* \u2500\u2500 \u9996\u9875\u53E0\u52A0\u533A\u57DF \u2500\u2500 */
|
|
1401
|
-
${desc}.first-page-overlay {
|
|
1402
|
-
width: ${mm(contentWidth)};
|
|
1403
|
-
height: ${mm(overlayH)};
|
|
1404
|
-
position: relative;
|
|
1405
|
-
}
|
|
1406
1402
|
`;
|
|
1407
1403
|
}
|
|
1408
1404
|
function buildBasePageCss() {
|
|
@@ -1886,7 +1882,6 @@ function paginate(template, measuredElements) {
|
|
|
1886
1882
|
const { top: mt, bottom: mb } = template.margins;
|
|
1887
1883
|
const headerH = template.header?.height ?? 0;
|
|
1888
1884
|
const footerH = template.footer?.height ?? 0;
|
|
1889
|
-
const overlayH = template.firstPageOverlay?.height ?? 0;
|
|
1890
1885
|
const continuous = isContinuousPaper(template);
|
|
1891
1886
|
const contentHeight = continuous ? Number.POSITIVE_INFINITY : paper.height - mt - mb - headerH - footerH;
|
|
1892
1887
|
if (!continuous && contentHeight <= 0) {
|
|
@@ -1926,8 +1921,7 @@ function paginate(template, measuredElements) {
|
|
|
1926
1921
|
const unitOf = buildPaginationUnits(sorted, measuredElements, groupMap);
|
|
1927
1922
|
const pages = [];
|
|
1928
1923
|
let currentPage = [];
|
|
1929
|
-
let remaining = contentHeight -
|
|
1930
|
-
let isFirstPage = true;
|
|
1924
|
+
let remaining = contentHeight - SAFETY_MARGIN;
|
|
1931
1925
|
let pageBroken = false;
|
|
1932
1926
|
function sectionTop(el) {
|
|
1933
1927
|
return pageBroken ? pageCursorTop() : el.options?.top ?? 0;
|
|
@@ -1936,7 +1930,7 @@ function paginate(template, measuredElements) {
|
|
|
1936
1930
|
return Math.max(0, fullPageHeight() - remaining);
|
|
1937
1931
|
}
|
|
1938
1932
|
function fullPageHeight() {
|
|
1939
|
-
return
|
|
1933
|
+
return contentHeight - SAFETY_MARGIN;
|
|
1940
1934
|
}
|
|
1941
1935
|
let overflowOnCurrent = false;
|
|
1942
1936
|
function pushPage() {
|
|
@@ -1955,7 +1949,6 @@ function paginate(template, measuredElements) {
|
|
|
1955
1949
|
pushPage();
|
|
1956
1950
|
currentPage = [];
|
|
1957
1951
|
remaining = contentHeight - SAFETY_MARGIN;
|
|
1958
|
-
isFirstPage = false;
|
|
1959
1952
|
pageBroken = true;
|
|
1960
1953
|
overflowOnCurrent = false;
|
|
1961
1954
|
}
|
|
@@ -2312,7 +2305,6 @@ function generateMeasurementHtml(template, css, ctx, printData) {
|
|
|
2312
2305
|
// totalPages placeholder
|
|
2313
2306
|
ctx
|
|
2314
2307
|
);
|
|
2315
|
-
const overlayHtml = renderAreaElements(template.firstPageOverlay?.elements ?? [], contentWidth, void 0, void 0, ctx);
|
|
2316
2308
|
let html = `<!DOCTYPE html>
|
|
2317
2309
|
<html lang="zh-CN">
|
|
2318
2310
|
<head>
|
|
@@ -2323,7 +2315,6 @@ function generateMeasurementHtml(template, css, ctx, printData) {
|
|
|
2323
2315
|
<section class="print-page" data-measure-page="0">
|
|
2324
2316
|
${renderWatermarkLayerHtml(template.watermark, printData, getPaperDims(template))}
|
|
2325
2317
|
<div class="page-header">${headerHtml}</div>
|
|
2326
|
-
<div class="first-page-overlay">${overlayHtml}</div>
|
|
2327
2318
|
<div class="content-area" style="height:auto;overflow:visible;">
|
|
2328
2319
|
${elementsHtml}
|
|
2329
2320
|
</div>
|
|
@@ -2387,14 +2378,12 @@ function renderPage(template, page, pageNum, totalPages, ctx, printData, pageCla
|
|
|
2387
2378
|
totalPages,
|
|
2388
2379
|
pageCtx
|
|
2389
2380
|
);
|
|
2390
|
-
const overlayHtml = page.pageIndex === 0 ? `<div class="first-page-overlay">${renderAreaElements(scoped.firstPageOverlay?.elements ?? [], contentWidth, pageNum, totalPages, pageCtx)}</div>` : "";
|
|
2391
2381
|
let contentHtml = page.sections.map((section) => renderSection(section, scoped, pageCtx)).join("\n");
|
|
2392
2382
|
contentHtml = contentHtml.replace(/\{pageIndex\}/g, String(pageNum));
|
|
2393
2383
|
contentHtml = contentHtml.replace(/\{totalPages\}/g, String(totalPages));
|
|
2394
2384
|
const pageInner = `
|
|
2395
2385
|
${renderWatermarkLayerHtml(template.watermark, printData, paperMm, { pageIndex: pageNum, totalPages })}
|
|
2396
2386
|
<div class="page-header">${headerHtml}</div>
|
|
2397
|
-
${overlayHtml}
|
|
2398
2387
|
<div class="content-area">
|
|
2399
2388
|
${contentHtml}
|
|
2400
2389
|
</div>
|
|
@@ -2418,16 +2407,14 @@ function withPageNumbers(template, vars) {
|
|
|
2418
2407
|
...template,
|
|
2419
2408
|
elements: template.elements.map(mapEl),
|
|
2420
2409
|
header: mapArea(template.header),
|
|
2421
|
-
footer: mapArea(template.footer)
|
|
2422
|
-
firstPageOverlay: mapArea(template.firstPageOverlay)
|
|
2410
|
+
footer: mapArea(template.footer)
|
|
2423
2411
|
};
|
|
2424
2412
|
}
|
|
2425
2413
|
function templateReferencesPageNumbers(template) {
|
|
2426
2414
|
const areas = [
|
|
2427
2415
|
template.elements,
|
|
2428
2416
|
template.header?.elements,
|
|
2429
|
-
template.footer?.elements
|
|
2430
|
-
template.firstPageOverlay?.elements
|
|
2417
|
+
template.footer?.elements
|
|
2431
2418
|
];
|
|
2432
2419
|
return areas.some((list) => (list ?? []).some((el) => typeof el.options?.rawFormatter === "string"));
|
|
2433
2420
|
}
|
|
@@ -2916,9 +2903,6 @@ function toPlaywrightPdfOptions(spec) {
|
|
|
2916
2903
|
preferCSSPageSize: spec.preferCSSPageSize
|
|
2917
2904
|
};
|
|
2918
2905
|
}
|
|
2919
|
-
function buildScreenshotTargetSpec() {
|
|
2920
|
-
return { type: "png", fullPage: true, omitBackground: false };
|
|
2921
|
-
}
|
|
2922
2906
|
|
|
2923
2907
|
// src/print/measure.ts
|
|
2924
2908
|
function normalizeMeasurements(raw, template) {
|
|
@@ -2953,7 +2937,6 @@ function applyTextFitSizes(template, fits) {
|
|
|
2953
2937
|
collect(template.elements);
|
|
2954
2938
|
collect(template.header?.elements);
|
|
2955
2939
|
collect(template.footer?.elements);
|
|
2956
|
-
collect(template.firstPageOverlay?.elements);
|
|
2957
2940
|
for (const fit of fits) {
|
|
2958
2941
|
const parsed = parseCellFitKey(fit.key);
|
|
2959
2942
|
if (!parsed) {
|
|
@@ -3125,23 +3108,6 @@ function createDomHostRuntime(factory, bundle) {
|
|
|
3125
3108
|
"RENDER_TIMEOUT",
|
|
3126
3109
|
`PDF \u751F\u6210\u8D85\u8FC7 ${ms}ms`
|
|
3127
3110
|
);
|
|
3128
|
-
},
|
|
3129
|
-
async toScreenshot(html, spec, viewport) {
|
|
3130
|
-
if (!driver.screenshot) throw new PrintFailure("UNSUPPORTED_RUNTIME", "\u5F53\u524D\u5BBF\u4E3B\u4E0D\u652F\u6301\u622A\u56FE");
|
|
3131
|
-
const ms = budget();
|
|
3132
|
-
return withTimeout(
|
|
3133
|
-
(async () => {
|
|
3134
|
-
try {
|
|
3135
|
-
await load(html, viewport);
|
|
3136
|
-
return await driver.screenshot(html, spec);
|
|
3137
|
-
} catch (err) {
|
|
3138
|
-
throw fail(err, "SCREENSHOT_FAILED", "\u622A\u56FE\u5931\u8D25");
|
|
3139
|
-
}
|
|
3140
|
-
})(),
|
|
3141
|
-
ms,
|
|
3142
|
-
"RENDER_TIMEOUT",
|
|
3143
|
-
`\u622A\u56FE\u8D85\u8FC7 ${ms}ms`
|
|
3144
|
-
);
|
|
3145
3111
|
}
|
|
3146
3112
|
};
|
|
3147
3113
|
try {
|
|
@@ -3476,33 +3442,6 @@ async function renderPdf(job, runtime) {
|
|
|
3476
3442
|
return { pdf, prepared };
|
|
3477
3443
|
});
|
|
3478
3444
|
}
|
|
3479
|
-
async function renderScreenshot(job, runtime) {
|
|
3480
|
-
return runtime.withSession(job, async (session) => {
|
|
3481
|
-
const pageTemplates = normalizeTemplate(job.templateJson);
|
|
3482
|
-
if (pageTemplates.length > 1) {
|
|
3483
|
-
const normalized2 = normalizePrintData(job.printData);
|
|
3484
|
-
const data2 = normalized2.mode === "batch" ? normalized2.dataList[0] : normalized2.data;
|
|
3485
|
-
const copy = await prepareMultiCopy(job, session, data2);
|
|
3486
|
-
const doc = composeMultiPageDocument([copy]);
|
|
3487
|
-
const viewport2 = paperViewportPx(getPaperDimensions(pageTemplates[0]));
|
|
3488
|
-
return session.toScreenshot(doc.html, buildScreenshotTargetSpec(), viewport2);
|
|
3489
|
-
}
|
|
3490
|
-
const singleJob = pageTemplates[0] !== job.templateJson ? { ...job, templateJson: pageTemplates[0] } : job;
|
|
3491
|
-
const normalized = normalizePrintData(singleJob.printData);
|
|
3492
|
-
const data = normalized.mode === "batch" ? normalized.dataList[0] : normalized.data;
|
|
3493
|
-
const bound = bindData(singleJob.templateJson, data, singleJob.baseUrl, singleJob.fontBaseUrl);
|
|
3494
|
-
const built = await buildHtmlWithCodes({
|
|
3495
|
-
bound,
|
|
3496
|
-
job: singleJob,
|
|
3497
|
-
session,
|
|
3498
|
-
data,
|
|
3499
|
-
pageLayouts: [],
|
|
3500
|
-
isMeasurementPass: true
|
|
3501
|
-
});
|
|
3502
|
-
const viewport = paperViewportPx(getPaperDimensions(bound));
|
|
3503
|
-
return session.toScreenshot(built.html, buildScreenshotTargetSpec(), viewport);
|
|
3504
|
-
});
|
|
3505
|
-
}
|
|
3506
3445
|
async function prepareWithSession(job, session) {
|
|
3507
3446
|
const pageTemplates = normalizeTemplate(job.templateJson);
|
|
3508
3447
|
if (pageTemplates.length > 1) {
|
|
@@ -3837,7 +3776,6 @@ export {
|
|
|
3837
3776
|
buildPdfTargetSpec,
|
|
3838
3777
|
toElectronPrintToPdfOptions,
|
|
3839
3778
|
toPlaywrightPdfOptions,
|
|
3840
|
-
buildScreenshotTargetSpec,
|
|
3841
3779
|
normalizeMeasurements,
|
|
3842
3780
|
applyTextFitSizes,
|
|
3843
3781
|
codeSpecKey,
|
|
@@ -3866,6 +3804,5 @@ export {
|
|
|
3866
3804
|
mergeFontDeclarations,
|
|
3867
3805
|
composeMultiPageDocument,
|
|
3868
3806
|
prepareDocument,
|
|
3869
|
-
renderPdf
|
|
3870
|
-
renderScreenshot
|
|
3807
|
+
renderPdf
|
|
3871
3808
|
};
|
package/dist/client/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/client/index.d.cts
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
|
declare const APP_ID = "worm-print-client";
|
|
2
8
|
declare const DEFAULT_PORT = 17521;
|
|
3
9
|
declare const PORT_SCAN_LIMIT = 20;
|
package/dist/client/index.d.ts
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
|
declare const APP_ID = "worm-print-client";
|
|
2
8
|
declare const DEFAULT_PORT = 17521;
|
|
3
9
|
declare const PORT_SCAN_LIMIT = 20;
|
package/dist/client/index.js
CHANGED
package/dist/designer/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;
|
|
@@ -315,15 +321,17 @@ function round2(n) {
|
|
|
315
321
|
return Math.round(n * 100) / 100;
|
|
316
322
|
}
|
|
317
323
|
function normalizeTemplateUnits(data) {
|
|
318
|
-
|
|
324
|
+
const rest = { ...data };
|
|
325
|
+
delete rest.firstPageOverlay;
|
|
326
|
+
if (rest.unit === "mm") return rest;
|
|
327
|
+
const src = rest;
|
|
319
328
|
const convert = (els) => els?.map(convertElement) ?? [];
|
|
320
329
|
return {
|
|
321
|
-
...
|
|
330
|
+
...src,
|
|
322
331
|
unit: "mm",
|
|
323
|
-
elements: convert(
|
|
324
|
-
header:
|
|
325
|
-
footer:
|
|
326
|
-
firstPageOverlay: data.firstPageOverlay ? { ...data.firstPageOverlay, elements: convert(data.firstPageOverlay.elements) } : data.firstPageOverlay
|
|
332
|
+
elements: convert(src.elements),
|
|
333
|
+
header: src.header ? { ...src.header, elements: convert(src.header.elements) } : src.header,
|
|
334
|
+
footer: src.footer ? { ...src.footer, elements: convert(src.footer.elements) } : src.footer
|
|
327
335
|
};
|
|
328
336
|
}
|
|
329
337
|
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 { E as ElementBorderSide, b as ElementOptions, c as TemplateData, d as TableRow, e as TableCellBorder, f as TableCell, g as TableRowType, h as ElementType, i as RuntimeElement, j as ElementZone, k as PrintBusinessField, B as BindingDescriptor, l as ElementRect, A as AdsorbResult, m as ResizePoint } from '../driver-CFm0C_yX.cjs';
|
|
8
|
+
export { n as AlignLine, o as DesignBackground, p as ElementBorderEdge, q as ElementFieldBinding, r as MultiPageTemplateData, s as PaginationConfig, t as PaperSize, u as PrintElementData, v as PrintElementTypeMeta, w as TableCellBorders, x as TableCellType, y as TablePaginationConfig, z as TableSelection, F as TemplateElement, G as TextAlign, H as TextFit, U as UploadDesignBackgroundFn, I as UploadImageFn, V as VerticalAlign, W as WatermarkOptions } from '../driver-CFm0C_yX.cjs';
|
|
9
|
+
export { C as CellFitRowKind, D as DEFAULT_SHRINK_MIN_FONT_SIZE_PT, F as FitFontSize, M as MIN_SHRINK_FONT_SIZE_PT, c as cellFitCapMm, a as cellFitKey, b as cellFitWidthMm, f as floorFontSize, p as parseCellFitKey, r as resolveCellTextFit, d as resolveElementTextFit, e as resolveShrinkMinFontSize, g as roundFontSize } from '../ports-BXYcHExa.cjs';
|
|
4
10
|
import { TemplateEngine, formatMoney, ifFn, addNumbers, subtractNumbers, multiplyNumbers, divideNumbers, round, roundUp, roundDown, roundHalfEven, formatDate, toUpperCaseAmount } from '../index.cjs';
|
|
5
11
|
|
|
6
12
|
/** 1 英寸 = 25.4mm */
|
package/dist/designer/index.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 { E as ElementBorderSide, b as ElementOptions, c as TemplateData, d as TableRow, e as TableCellBorder, f as TableCell, g as TableRowType, h as ElementType, i as RuntimeElement, j as ElementZone, k as PrintBusinessField, B as BindingDescriptor, l as ElementRect, A as AdsorbResult, m as ResizePoint } from '../driver-CFm0C_yX.js';
|
|
8
|
+
export { n as AlignLine, o as DesignBackground, p as ElementBorderEdge, q as ElementFieldBinding, r as MultiPageTemplateData, s as PaginationConfig, t as PaperSize, u as PrintElementData, v as PrintElementTypeMeta, w as TableCellBorders, x as TableCellType, y as TablePaginationConfig, z as TableSelection, F as TemplateElement, G as TextAlign, H as TextFit, U as UploadDesignBackgroundFn, I as UploadImageFn, V as VerticalAlign, W as WatermarkOptions } from '../driver-CFm0C_yX.js';
|
|
9
|
+
export { C as CellFitRowKind, D as DEFAULT_SHRINK_MIN_FONT_SIZE_PT, F as FitFontSize, M as MIN_SHRINK_FONT_SIZE_PT, c as cellFitCapMm, a as cellFitKey, b as cellFitWidthMm, f as floorFontSize, p as parseCellFitKey, r as resolveCellTextFit, d as resolveElementTextFit, e as resolveShrinkMinFontSize, g as roundFontSize } from '../ports-Bdst9MWJ.js';
|
|
4
10
|
import { TemplateEngine, formatMoney, ifFn, addNumbers, subtractNumbers, multiplyNumbers, divideNumbers, round, roundUp, roundDown, roundHalfEven, formatDate, toUpperCaseAmount } from '../index.js';
|
|
5
11
|
|
|
6
12
|
/** 1 英寸 = 25.4mm */
|