@ym-print/renderer-dom 0.0.0-stage → 0.1.0-rc.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/LICENSE +8 -0
- package/README.md +80 -2
- package/THIRD_PARTY_NOTICES.md +37 -0
- package/dependency-licenses.json +228 -0
- package/dist/browser-support.d.ts +2 -0
- package/dist/image-density.d.ts +2 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +450 -0
- package/dist/pdf-assets/cmaps/78-EUC-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/78-EUC-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/78-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/78-RKSJ-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/78-RKSJ-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/78-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/78ms-RKSJ-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/78ms-RKSJ-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/83pv-RKSJ-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/90ms-RKSJ-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/90ms-RKSJ-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/90msp-RKSJ-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/90msp-RKSJ-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/90pv-RKSJ-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/90pv-RKSJ-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Add-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Add-RKSJ-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Add-RKSJ-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Add-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-CNS1-0.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-CNS1-1.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-CNS1-2.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-CNS1-3.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-CNS1-4.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-CNS1-5.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-CNS1-6.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-GB1-0.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-GB1-1.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-GB1-2.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-GB1-3.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-GB1-4.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-GB1-5.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-Japan1-0.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-Japan1-1.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-Japan1-2.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-Japan1-3.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-Japan1-4.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-Japan1-5.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-Japan1-6.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-Korea1-0.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-Korea1-1.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-Korea1-2.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- package/dist/pdf-assets/cmaps/B5-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/B5-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/B5pc-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/B5pc-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/CNS-EUC-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/CNS-EUC-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/CNS1-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/CNS1-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/CNS2-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/CNS2-V.bcmap +3 -0
- package/dist/pdf-assets/cmaps/ETHK-B5-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/ETHK-B5-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/ETen-B5-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/ETen-B5-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/ETenms-B5-H.bcmap +3 -0
- package/dist/pdf-assets/cmaps/ETenms-B5-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/EUC-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/EUC-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Ext-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Ext-RKSJ-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Ext-RKSJ-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Ext-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GB-EUC-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GB-EUC-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GB-H.bcmap +4 -0
- package/dist/pdf-assets/cmaps/GB-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GBK-EUC-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GBK-EUC-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GBK2K-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GBK2K-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GBKp-EUC-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GBKp-EUC-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GBT-EUC-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GBT-EUC-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GBT-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GBT-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GBTpc-EUC-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GBTpc-EUC-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GBpc-EUC-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/GBpc-EUC-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/HKdla-B5-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/HKdla-B5-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/HKdlb-B5-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/HKdlb-B5-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/HKgccs-B5-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/HKgccs-B5-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/HKm314-B5-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/HKm314-B5-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/HKm471-B5-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/HKm471-B5-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/HKscs-B5-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/HKscs-B5-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Hankaku.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Hiragana.bcmap +0 -0
- package/dist/pdf-assets/cmaps/KSC-EUC-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/KSC-EUC-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/KSC-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/KSC-Johab-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/KSC-Johab-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/KSC-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/KSCms-UHC-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/KSCms-UHC-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/KSCpc-EUC-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/KSCpc-EUC-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Katakana.bcmap +0 -0
- package/dist/pdf-assets/cmaps/LICENSE +36 -0
- package/dist/pdf-assets/cmaps/NWP-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/NWP-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/RKSJ-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/RKSJ-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/Roman.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniGB-UCS2-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniGB-UCS2-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniGB-UTF16-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniGB-UTF16-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniGB-UTF32-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniGB-UTF32-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniGB-UTF8-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniGB-UTF8-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniKS-UCS2-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniKS-UCS2-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniKS-UTF16-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniKS-UTF16-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniKS-UTF32-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniKS-UTF32-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniKS-UTF8-H.bcmap +0 -0
- package/dist/pdf-assets/cmaps/UniKS-UTF8-V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/V.bcmap +0 -0
- package/dist/pdf-assets/cmaps/WP-Symbol.bcmap +0 -0
- package/dist/pdf-assets/iccs/CGATS001Compat-v2-micro.icc +0 -0
- package/dist/pdf-assets/iccs/LICENSE +116 -0
- package/dist/pdf-assets/pdf.worker.min.mjs +28 -0
- package/dist/pdf-assets/standard_fonts/FoxitDingbats.pfb +0 -0
- package/dist/pdf-assets/standard_fonts/FoxitFixed.pfb +0 -0
- package/dist/pdf-assets/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/dist/pdf-assets/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/dist/pdf-assets/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/dist/pdf-assets/standard_fonts/FoxitSerif.pfb +0 -0
- package/dist/pdf-assets/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/dist/pdf-assets/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/dist/pdf-assets/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/dist/pdf-assets/standard_fonts/FoxitSymbol.pfb +0 -0
- package/dist/pdf-assets/standard_fonts/LICENSE_FOXIT +27 -0
- package/dist/pdf-assets/standard_fonts/LICENSE_LIBERATION +363 -0
- package/dist/pdf-assets/standard_fonts/LiberationSans-Bold.ttf +0 -0
- package/dist/pdf-assets/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/dist/pdf-assets/standard_fonts/LiberationSans-Italic.ttf +0 -0
- package/dist/pdf-assets/standard_fonts/LiberationSans-Regular.ttf +0 -0
- package/dist/pdf-assets/wasm/LICENSE_JBIG2 +196 -0
- package/dist/pdf-assets/wasm/LICENSE_OPENJPEG +39 -0
- package/dist/pdf-assets/wasm/LICENSE_PDFJS_JBIG2 +13 -0
- package/dist/pdf-assets/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
- package/dist/pdf-assets/wasm/LICENSE_PDFJS_QCMS +19 -0
- package/dist/pdf-assets/wasm/LICENSE_QCMS +21 -0
- package/dist/pdf-assets/wasm/jbig2.wasm +0 -0
- package/dist/pdf-assets/wasm/jbig2_nowasm_fallback.js +15 -0
- package/dist/pdf-assets/wasm/openjpeg.wasm +0 -0
- package/dist/pdf-assets/wasm/openjpeg_nowasm_fallback.js +17 -0
- package/dist/pdf-assets/wasm/qcms_bg.wasm +0 -0
- package/dist/pdf-assets/wasm/quickjs-eval.js +16 -0
- package/dist/pdf-assets/wasm/quickjs-eval.wasm +0 -0
- package/dist/pdf-import-bNngi03w.js +16337 -0
- package/dist/pdf-import.d.ts +17 -0
- package/dist/raster.d.ts +48 -0
- package/dist/system-font.d.ts +32 -0
- package/dist/vite-assets.d.ts +3 -0
- package/dist/vite.js +39 -0
- package/package.json +52 -4
- package/third-party-licenses/@oxc-project__types@0.155.0/LICENSE +22 -0
- package/third-party-licenses/@rolldown__pluginutils@1.0.1/LICENSE +21 -0
- package/third-party-licenses/detect-libc@2.1.2/LICENSE +201 -0
- package/third-party-licenses/fdir@6.5.0/LICENSE +7 -0
- package/third-party-licenses/lightningcss@1.33.0/LICENSE +373 -0
- package/third-party-licenses/nanoid@3.3.20/LICENSE +20 -0
- package/third-party-licenses/pdfjs-dist@6.4.299/LICENSE +177 -0
- package/third-party-licenses/picocolors@1.1.1/LICENSE +15 -0
- package/third-party-licenses/picomatch@4.0.7/LICENSE +21 -0
- package/third-party-licenses/postcss@8.5.32/LICENSE +20 -0
- package/third-party-licenses/rolldown@1.2.15/LICENSE +25 -0
- package/third-party-licenses/source-map-js@1.2.2/LICENSE +28 -0
- package/third-party-licenses/tinyglobby@0.2.17/LICENSE +21 -0
- package/third-party-licenses/vite@8.3.5/LICENSE.md +2084 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
import { DEFAULT_FONT_FAMILY as e, PrintError as t, mptToUm as n, printLayout as r, umToMm as i, validateFontFamily as a, validateLetterSpacing as o } from "@ym-print/core";
|
|
2
|
+
// src/browser-support.ts
|
|
3
|
+
function s() {
|
|
4
|
+
if (typeof document > "u") throw new t("BROWSER_REQUIRED", "PDF 导入需要浏览器环境");
|
|
5
|
+
let e = [
|
|
6
|
+
["Promise.withResolvers", Reflect.get(Promise, "withResolvers")],
|
|
7
|
+
["Map.getOrInsert", Reflect.get(Map.prototype, "getOrInsert")],
|
|
8
|
+
["Map.getOrInsertComputed", Reflect.get(Map.prototype, "getOrInsertComputed")],
|
|
9
|
+
["WeakMap.getOrInsertComputed", Reflect.get(WeakMap.prototype, "getOrInsertComputed")],
|
|
10
|
+
["Uint8Array.toBase64", Reflect.get(Uint8Array.prototype, "toBase64")]
|
|
11
|
+
].filter(([, e]) => typeof e != "function").map(([e]) => e);
|
|
12
|
+
if (e.length) throw new t("BROWSER_UNSUPPORTED", `PDF 导入需要 Chrome/Edge 145 或更新版本;当前浏览器缺少 ${e.join("、")}`);
|
|
13
|
+
}
|
|
14
|
+
// src/system-font.ts
|
|
15
|
+
var c = class n {
|
|
16
|
+
family;
|
|
17
|
+
weight;
|
|
18
|
+
fontStyle;
|
|
19
|
+
id = "font.body";
|
|
20
|
+
sha256 = "system";
|
|
21
|
+
unitsPerEm = 1e3;
|
|
22
|
+
system = !0;
|
|
23
|
+
ascent;
|
|
24
|
+
descent;
|
|
25
|
+
context;
|
|
26
|
+
widths = /* @__PURE__ */ new Map();
|
|
27
|
+
variants = /* @__PURE__ */ new Map();
|
|
28
|
+
lineMetrics = /* @__PURE__ */ new Map();
|
|
29
|
+
spacingSupported;
|
|
30
|
+
constructor(n = e, r = 400, i = "normal") {
|
|
31
|
+
if (this.family = n, this.weight = r, this.fontStyle = i, a(n), typeof document > "u") throw new t("BROWSER_REQUIRED", "系统字体排版需要浏览器环境,请在 Web 页面调用");
|
|
32
|
+
if (!CSS.supports("font-family", n)) throw new t("FONT_FAMILY_INVALID", "字体名称不是有效的 font-family");
|
|
33
|
+
let o = document.createElement("canvas").getContext("2d");
|
|
34
|
+
if (!o) throw new t("FONT_MEASURE", "浏览器无法测量文字");
|
|
35
|
+
this.context = o, this.spacingSupported = "letterSpacing" in o, this.configure(100);
|
|
36
|
+
let s = o.measureText("Hg汉");
|
|
37
|
+
this.ascent = Math.ceil((Math.max(s.fontBoundingBoxAscent ?? 0, s.actualBoundingBoxAscent ?? 0) || 80) * 10), this.descent = -Math.ceil((Math.max(s.fontBoundingBoxDescent ?? 0, s.actualBoundingBoxDescent ?? 0) || 20) * 10);
|
|
38
|
+
}
|
|
39
|
+
clear() {
|
|
40
|
+
this.widths.clear(), this.lineMetrics.clear();
|
|
41
|
+
for (let e of this.variants.values()) e.clear();
|
|
42
|
+
this.variants.clear(), this.context.canvas.width = this.context.canvas.height = 0;
|
|
43
|
+
}
|
|
44
|
+
configure(e, t = 0) {
|
|
45
|
+
this.context.font = `${this.fontStyle} ${this.weight} ${e}px ${this.family}`, this.context.fontKerning = "none", this.context.textBaseline = "alphabetic", this.context.direction = "ltr", this.context.letterSpacing = `${t * 96 / 25400}px`;
|
|
46
|
+
}
|
|
47
|
+
forStyle(e) {
|
|
48
|
+
let t = e.fontFamily || this.family, r = e.fontWeight ?? this.weight, i = e.fontStyle ?? this.fontStyle;
|
|
49
|
+
if (t === this.family && r === this.weight && i === this.fontStyle) return this;
|
|
50
|
+
let a = `${i}:${r}:${t}`, o = this.variants.get(a);
|
|
51
|
+
return o || (o = new n(t, r, i), this.variants.set(a, o)), o;
|
|
52
|
+
}
|
|
53
|
+
glyph(e) {
|
|
54
|
+
return this.configure(100), {
|
|
55
|
+
id: 0,
|
|
56
|
+
advance: Math.round(this.context.measureText(e).width * 10)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
toUm(e, t) {
|
|
60
|
+
return Math.round(e * t * 25400 / (this.unitsPerEm * 72e3));
|
|
61
|
+
}
|
|
62
|
+
metrics(e, t) {
|
|
63
|
+
let n = `${t}:${e}`, r = this.lineMetrics.get(n);
|
|
64
|
+
if (r) return r;
|
|
65
|
+
this.configure(t / 1e3 * 96 / 72);
|
|
66
|
+
let i = this.context.measureText(e.normalize("NFC")), a = {
|
|
67
|
+
ascentUm: Math.ceil(Math.max(i.actualBoundingBoxAscent, i.fontBoundingBoxAscent ?? 0) * 25400 / 96),
|
|
68
|
+
descentUm: Math.ceil(Math.max(i.actualBoundingBoxDescent, i.fontBoundingBoxDescent ?? 0) * 25400 / 96)
|
|
69
|
+
};
|
|
70
|
+
return this.lineMetrics.size > 2e4 && this.lineMetrics.clear(), this.lineMetrics.set(n, a), a;
|
|
71
|
+
}
|
|
72
|
+
measure(e, n, r = 0) {
|
|
73
|
+
if (o(r), r && !this.spacingSupported) throw new t("TEXT_SPACING_UNSUPPORTED", "当前浏览器不支持 Canvas 字距测量,请使用支持 letterSpacing 的浏览器");
|
|
74
|
+
let i = `${n}:${r}:${e}`, a = this.widths.get(i);
|
|
75
|
+
return a === void 0 && (this.configure(n / 1e3 * 96 / 72, r), a = Math.max(0, Math.round(this.context.measureText(e.normalize("NFC")).width * 25400 / 96)), this.widths.size > 2e4 && this.widths.clear(), this.widths.set(i, a)), a;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
// src/image-density.ts
|
|
79
|
+
async function l(e, t) {
|
|
80
|
+
let n = new Uint8Array(await e.arrayBuffer()), r = new DataView(n.buffer);
|
|
81
|
+
if (e.type === "image/png") {
|
|
82
|
+
let i = /* @__PURE__ */ new Uint8Array(21), a = new DataView(i.buffer);
|
|
83
|
+
a.setUint32(0, 9), i.set([
|
|
84
|
+
112,
|
|
85
|
+
72,
|
|
86
|
+
89,
|
|
87
|
+
115
|
|
88
|
+
], 4);
|
|
89
|
+
let o = Math.round(t / .0254);
|
|
90
|
+
a.setUint32(8, o), a.setUint32(12, o), i[16] = 1;
|
|
91
|
+
let s = 4294967295;
|
|
92
|
+
for (let e of i.subarray(4, 17)) {
|
|
93
|
+
s ^= e;
|
|
94
|
+
for (let e = 0; e < 8; e++) s = s & 1 ? 3988292384 ^ s >>> 1 : s >>> 1;
|
|
95
|
+
}
|
|
96
|
+
a.setUint32(17, (s ^ 4294967295) >>> 0);
|
|
97
|
+
let c = [n.subarray(0, 8)], l = !1;
|
|
98
|
+
for (let e = 8; e + 12 <= n.length;) {
|
|
99
|
+
let t = e + 12 + r.getUint32(e), a = String.fromCharCode(...n.subarray(e + 4, e + 8));
|
|
100
|
+
if (t > n.length) throw Error("PNG chunk is truncated");
|
|
101
|
+
a !== "pHYs" && c.push(n.subarray(e, t)), a === "IHDR" && !l && (c.push(i), l = !0), e = t;
|
|
102
|
+
}
|
|
103
|
+
return new Blob(c, { type: e.type });
|
|
104
|
+
}
|
|
105
|
+
if (e.type === "image/jpeg") {
|
|
106
|
+
for (let i = 2; i + 4 < n.length;) {
|
|
107
|
+
let a = n[i + 1];
|
|
108
|
+
if (n[i] !== 255 || a === 218 || a === 217) break;
|
|
109
|
+
let o = r.getUint16(i + 2);
|
|
110
|
+
if (o < 2 || i + 2 + o > n.length) break;
|
|
111
|
+
if (a === 224 && o >= 16 && String.fromCharCode(...n.subarray(i + 4, i + 9)) === "JFIF\0") return n[i + 11] = 1, r.setUint16(i + 12, t), r.setUint16(i + 14, t), new Blob([n], { type: e.type });
|
|
112
|
+
i += 2 + o;
|
|
113
|
+
}
|
|
114
|
+
let i = new Uint8Array([
|
|
115
|
+
255,
|
|
116
|
+
224,
|
|
117
|
+
0,
|
|
118
|
+
16,
|
|
119
|
+
74,
|
|
120
|
+
70,
|
|
121
|
+
73,
|
|
122
|
+
70,
|
|
123
|
+
0,
|
|
124
|
+
1,
|
|
125
|
+
2,
|
|
126
|
+
1,
|
|
127
|
+
0,
|
|
128
|
+
0,
|
|
129
|
+
0,
|
|
130
|
+
0,
|
|
131
|
+
0,
|
|
132
|
+
0
|
|
133
|
+
]), a = new DataView(i.buffer);
|
|
134
|
+
return a.setUint16(12, t), a.setUint16(14, t), new Blob([
|
|
135
|
+
n.subarray(0, 2),
|
|
136
|
+
i,
|
|
137
|
+
n.subarray(2)
|
|
138
|
+
], { type: e.type });
|
|
139
|
+
}
|
|
140
|
+
return e;
|
|
141
|
+
}
|
|
142
|
+
// src/raster.ts
|
|
143
|
+
var u = {
|
|
144
|
+
dimension: 16e3,
|
|
145
|
+
pixels: 4e7
|
|
146
|
+
}, d = {
|
|
147
|
+
dimension: 8192,
|
|
148
|
+
pixels: 8e6,
|
|
149
|
+
totalPixels: 1e9,
|
|
150
|
+
regions: 1024
|
|
151
|
+
};
|
|
152
|
+
function f(e) {
|
|
153
|
+
if (e?.aborted) throw new t("PRINT_CANCELLED", "图片导出已取消");
|
|
154
|
+
}
|
|
155
|
+
function p(e, n = 144, r = !1, i = 2048) {
|
|
156
|
+
if (!Number.isInteger(n) || n < 72 || n > 600) throw new t("IMAGE_DPI_INVALID", "图片 DPI 需在 72–600 之间");
|
|
157
|
+
if (![e.widthUm, e.heightUm].every((e) => Number.isSafeInteger(e) && e > 0)) throw new t("IMAGE_SIZE_INVALID", "图片物理尺寸无效");
|
|
158
|
+
if (!Number.isSafeInteger(i) || i < 1 || i > 8192) throw new t("IMAGE_STRIP_INVALID", "分条高度需为 1–8192 像素");
|
|
159
|
+
let a = Math.max(1, Math.round(e.widthUm * n / 25400)), o = Math.max(1, Math.round(e.heightUm * n / 25400));
|
|
160
|
+
if (a * o > d.totalPixels) throw new t("IMAGE_SIZE_LIMIT", "单页导出最多 10 亿像素,请降低 DPI 或缩小纸张");
|
|
161
|
+
let s = r || a > u.dimension || o > u.dimension || a * o > u.pixels, c = [];
|
|
162
|
+
if (!s) c.push({
|
|
163
|
+
index: 0,
|
|
164
|
+
xPx: 0,
|
|
165
|
+
yPx: 0,
|
|
166
|
+
widthPx: a,
|
|
167
|
+
heightPx: o
|
|
168
|
+
});
|
|
169
|
+
else {
|
|
170
|
+
let e = Math.min(a, d.dimension), n = Math.min(i, Math.floor(d.pixels / e));
|
|
171
|
+
if (Math.ceil(a / e) * Math.ceil(o / n) > d.regions) throw new t("IMAGE_STRIP_LIMIT", "分条数量超过 1024,请增大分条高度或降低 DPI");
|
|
172
|
+
for (let t = 0; t < o; t += n) for (let r = 0; r < a; r += e) c.push({
|
|
173
|
+
index: c.length,
|
|
174
|
+
xPx: r,
|
|
175
|
+
yPx: t,
|
|
176
|
+
widthPx: Math.min(e, a - r),
|
|
177
|
+
heightPx: Math.min(n, o - t)
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
pageId: e.id,
|
|
182
|
+
dpi: n,
|
|
183
|
+
widthPx: a,
|
|
184
|
+
heightPx: o,
|
|
185
|
+
widthUm: e.widthUm,
|
|
186
|
+
heightUm: e.heightUm,
|
|
187
|
+
tiled: s,
|
|
188
|
+
regions: c
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
async function m(e, n, r, i, a) {
|
|
192
|
+
f(a);
|
|
193
|
+
let o = n.widthUm / n.widthPx, s = n.heightUm / n.heightPx;
|
|
194
|
+
e.setAttribute("viewBox", `${r.xPx * o} ${r.yPx * s} ${r.widthPx * o} ${r.heightPx * s}`), e.setAttribute("preserveAspectRatio", "none"), e.setAttribute("width", String(r.widthPx)), e.setAttribute("height", String(r.heightPx));
|
|
195
|
+
let c = URL.createObjectURL(new Blob([new XMLSerializer().serializeToString(e)], { type: "image/svg+xml;charset=utf-8" })), u = new Image(), d = document.createElement("canvas");
|
|
196
|
+
try {
|
|
197
|
+
await new Promise((e, n) => {
|
|
198
|
+
let r = () => {
|
|
199
|
+
u.onload = null, u.onerror = null, a?.removeEventListener("abort", i);
|
|
200
|
+
}, i = () => {
|
|
201
|
+
r(), u.src = "", n(new t("PRINT_CANCELLED", "图片导出已取消"));
|
|
202
|
+
};
|
|
203
|
+
u.onload = () => {
|
|
204
|
+
r(), e();
|
|
205
|
+
}, u.onerror = () => {
|
|
206
|
+
r(), n(new t("IMAGE_DECODE_FAILED", "页面图片生成失败"));
|
|
207
|
+
}, a?.addEventListener("abort", i, { once: !0 }), u.src = c, a?.aborted && i();
|
|
208
|
+
}), f(a), d.width = r.widthPx, d.height = r.heightPx;
|
|
209
|
+
let e = d.getContext("2d");
|
|
210
|
+
if (!e) throw new t("IMAGE_CANVAS_UNAVAILABLE", "Canvas 不可用");
|
|
211
|
+
e.fillStyle = "#ffffff", e.fillRect(0, 0, d.width, d.height), e.drawImage(u, 0, 0), f(a);
|
|
212
|
+
let o = await new Promise((e, n) => d.toBlob((r) => r ? e(r) : n(new t("IMAGE_ENCODE_FAILED", "图片编码失败")), `image/${i}`, .95));
|
|
213
|
+
if (f(a), o.type !== `image/${i}`) throw new t("IMAGE_FORMAT_UNSUPPORTED", "浏览器不支持所选图片格式");
|
|
214
|
+
let s = await l(o, n.dpi);
|
|
215
|
+
return f(a), s;
|
|
216
|
+
} finally {
|
|
217
|
+
u.src = "", d.width = 0, d.height = 0, URL.revokeObjectURL(c);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
async function* h(e, t, n = {}) {
|
|
221
|
+
yield* g(e, t, n, !0);
|
|
222
|
+
}
|
|
223
|
+
async function* g(n, r, i = {}, a = !1) {
|
|
224
|
+
let { signal: o, format: s = "png" } = i;
|
|
225
|
+
if (!["png", "jpeg"].includes(s)) throw new t("IMAGE_FORMAT_INVALID", "图片格式仅支持 PNG/JPEG");
|
|
226
|
+
let c = p(n, i.dpi ?? 144, a, i.stripHeightPx), l = w(n, document, r ? x : e).firstElementChild;
|
|
227
|
+
if (r) {
|
|
228
|
+
let e = document.createElementNS("http://www.w3.org/2000/svg", "style");
|
|
229
|
+
e.textContent = E(O(r)), l.prepend(e);
|
|
230
|
+
}
|
|
231
|
+
f(o), await document.fonts.ready, f(o);
|
|
232
|
+
for (let e of c.regions) {
|
|
233
|
+
f(o);
|
|
234
|
+
let t = await m(l, c, e, s, o);
|
|
235
|
+
yield {
|
|
236
|
+
...e,
|
|
237
|
+
blob: t
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
async function _(e, n, r = 144, i = "png", a) {
|
|
242
|
+
if (p(e, r).tiled) throw new t("IMAGE_STRIPS_REQUIRED", "图片超过单画布限制,请使用分条导出(exportPageImageStrips / exportImageArchive)");
|
|
243
|
+
for await (let t of g(e, n, {
|
|
244
|
+
dpi: r,
|
|
245
|
+
format: i,
|
|
246
|
+
signal: a
|
|
247
|
+
})) return t.blob;
|
|
248
|
+
throw new t("IMAGE_ENCODE_FAILED", "未生成图片");
|
|
249
|
+
}
|
|
250
|
+
var v = (e, t, n = 144, r) => _(e, t, n, "png", r), y = (e, t, n = 144, r) => _(e, t, n, "jpeg", r), b = "http://www.w3.org/2000/svg", x = "YmPrintNoto";
|
|
251
|
+
function S(e, t, n) {
|
|
252
|
+
let r = e.createElementNS(b, t);
|
|
253
|
+
for (let [e, t] of Object.entries(n)) r.setAttribute(e, String(t));
|
|
254
|
+
return r;
|
|
255
|
+
}
|
|
256
|
+
function C(e, t, r) {
|
|
257
|
+
let i;
|
|
258
|
+
if (t.type === "text") {
|
|
259
|
+
let a = S(e, "text", {
|
|
260
|
+
y: t.baselineUm,
|
|
261
|
+
"font-family": t.fontFamily ?? r,
|
|
262
|
+
"font-size": n(t.sizeMpt),
|
|
263
|
+
fill: t.color,
|
|
264
|
+
"xml:space": "preserve",
|
|
265
|
+
style: t.fontFamily ? "font-kerning:none;white-space:pre" : "font-kerning:none;font-variant-ligatures:none;font-synthesis:none;white-space:pre"
|
|
266
|
+
});
|
|
267
|
+
if (t.letterSpacingUm && a.setAttribute("letter-spacing", String(t.letterSpacingUm)), a.setAttribute("direction", "ltr"), t.fontFamily ? (a.setAttribute("x", String(t.xUm)), a.setAttribute("font-weight", String(t.fontWeight ?? 400)), a.textContent = t.text, t.text && t.widthUm > 0 && (a.setAttribute("textLength", String(t.widthUm)), a.setAttribute("lengthAdjust", "spacingAndGlyphs"))) : t.fontWeight === 700 && (a.setAttribute("stroke", t.color), a.setAttribute("stroke-width", String(n(t.sizeMpt) * .025)), a.setAttribute("paint-order", "stroke fill"), a.setAttribute("stroke-linejoin", "round")), !t.fontFamily) for (let n of t.glyphs) {
|
|
268
|
+
let t = S(e, "tspan", { x: n.xUm });
|
|
269
|
+
t.textContent = n.text, a.append(t);
|
|
270
|
+
}
|
|
271
|
+
t.fontStyle && a.setAttribute("font-style", t.fontStyle), t.textRotationMdeg && a.setAttribute("transform", `rotate(${t.textRotationMdeg / 1e3} ${t.xUm} ${t.baselineUm})`), i = a;
|
|
272
|
+
} else if (t.type === "path") {
|
|
273
|
+
let n = S(e, "svg", {
|
|
274
|
+
x: t.xUm,
|
|
275
|
+
y: t.yUm,
|
|
276
|
+
width: t.widthUm,
|
|
277
|
+
height: t.heightUm,
|
|
278
|
+
viewBox: t.viewBox.join(" "),
|
|
279
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
280
|
+
overflow: "hidden"
|
|
281
|
+
});
|
|
282
|
+
for (let r of t.paths) {
|
|
283
|
+
let t = S(e, "path", {
|
|
284
|
+
d: r.d,
|
|
285
|
+
fill: r.fill ?? "none",
|
|
286
|
+
stroke: r.stroke ?? "none",
|
|
287
|
+
"stroke-width": r.strokeWidth,
|
|
288
|
+
"fill-rule": r.fillRule ?? "nonzero"
|
|
289
|
+
});
|
|
290
|
+
r.matrix && t.setAttribute("transform", `matrix(${r.matrix.join(" ")})`), r.opacity !== void 0 && t.setAttribute("opacity", String(r.opacity)), n.append(t);
|
|
291
|
+
}
|
|
292
|
+
i = n;
|
|
293
|
+
} else if (t.type === "line") i = S(e, "line", {
|
|
294
|
+
x1: t.x1Um,
|
|
295
|
+
y1: t.y1Um,
|
|
296
|
+
x2: t.x2Um,
|
|
297
|
+
y2: t.y2Um,
|
|
298
|
+
stroke: t.color,
|
|
299
|
+
"stroke-width": t.widthUm
|
|
300
|
+
}), t.dash && i.setAttribute("stroke-dasharray", t.dash.join(" ")), t.lineCap && i.setAttribute("stroke-linecap", t.lineCap);
|
|
301
|
+
else if (t.type === "image") {
|
|
302
|
+
let n = S(e, "image", {
|
|
303
|
+
x: t.xUm,
|
|
304
|
+
y: t.yUm,
|
|
305
|
+
width: t.widthUm,
|
|
306
|
+
height: t.heightUm,
|
|
307
|
+
href: t.dataUrl,
|
|
308
|
+
preserveAspectRatio: "none"
|
|
309
|
+
});
|
|
310
|
+
if (t.clip) {
|
|
311
|
+
let r = t.clip, a = S(e, "svg", {
|
|
312
|
+
x: r.xUm,
|
|
313
|
+
y: r.yUm,
|
|
314
|
+
width: r.widthUm,
|
|
315
|
+
height: r.heightUm,
|
|
316
|
+
viewBox: `${r.xUm} ${r.yUm} ${r.widthUm} ${r.heightUm}`,
|
|
317
|
+
overflow: "hidden"
|
|
318
|
+
});
|
|
319
|
+
a.append(n), i = a;
|
|
320
|
+
} else i = n;
|
|
321
|
+
} else {
|
|
322
|
+
let n = {
|
|
323
|
+
fill: t.fill ?? "none",
|
|
324
|
+
stroke: t.stroke ?? "none",
|
|
325
|
+
"stroke-width": t.strokeWidthUm
|
|
326
|
+
};
|
|
327
|
+
i = t.type === "ellipse" ? S(e, "ellipse", {
|
|
328
|
+
cx: t.xUm + t.widthUm / 2,
|
|
329
|
+
cy: t.yUm + t.heightUm / 2,
|
|
330
|
+
rx: t.widthUm / 2,
|
|
331
|
+
ry: t.heightUm / 2,
|
|
332
|
+
...n
|
|
333
|
+
}) : S(e, "rect", {
|
|
334
|
+
x: t.xUm,
|
|
335
|
+
y: t.yUm,
|
|
336
|
+
width: t.widthUm,
|
|
337
|
+
height: t.heightUm,
|
|
338
|
+
...n
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
if (i.setAttribute("data-node-id", t.nodeId), t.cellElementId && i.setAttribute("data-cell-element-id", t.cellElementId), t.opacity !== void 0 && i.setAttribute("opacity", String(t.opacity)), t.transform) {
|
|
342
|
+
let { rotationMdeg: e, cxUm: n, cyUm: r } = t.transform;
|
|
343
|
+
i.setAttribute("transform", `rotate(${e / 1e3} ${n} ${r}) ${i.getAttribute("transform") ?? ""}`.trim());
|
|
344
|
+
}
|
|
345
|
+
return i;
|
|
346
|
+
}
|
|
347
|
+
function w(e, t = document, n = x) {
|
|
348
|
+
let r = t.createElement("section");
|
|
349
|
+
r.className = "ym-print-page", r.dataset.pageId = e.id, r.style.width = `${i(e.widthUm)}mm`, r.style.height = `${i(e.heightUm)}mm`, r.setAttribute("aria-label", `${i(e.widthUm)} × ${i(e.heightUm)} mm`);
|
|
350
|
+
let a = S(t, "svg", {
|
|
351
|
+
viewBox: `0 0 ${e.widthUm} ${e.heightUm}`,
|
|
352
|
+
width: "100%",
|
|
353
|
+
height: "100%",
|
|
354
|
+
role: "img",
|
|
355
|
+
"aria-label": `打印页面 ${e.id}`
|
|
356
|
+
});
|
|
357
|
+
a.style.display = "block", a.style.overflow = "hidden";
|
|
358
|
+
for (let r of e.commands) a.append(C(t, r, n));
|
|
359
|
+
return r.append(a), r;
|
|
360
|
+
}
|
|
361
|
+
function T(e, t) {
|
|
362
|
+
let n = e.ownerDocument.createDocumentFragment();
|
|
363
|
+
for (let r of t.pages) n.append(w(r, e.ownerDocument));
|
|
364
|
+
e.replaceChildren(n);
|
|
365
|
+
}
|
|
366
|
+
function E(e) {
|
|
367
|
+
return `@font-face{font-family:${x};src:url(${JSON.stringify(e)});font-weight:400;font-style:normal;font-display:block;}`;
|
|
368
|
+
}
|
|
369
|
+
function D(e, t) {
|
|
370
|
+
e = r(e);
|
|
371
|
+
let n = document.implementation.createHTMLDocument(e.name), a = n.createElement("style");
|
|
372
|
+
a.textContent = (t ? E(t) : "") + "\n*{box-sizing:border-box}html,body{margin:0;padding:0;background:white}.ym-print-page{margin:0;overflow:hidden;break-after:page;print-color-adjust:exact;-webkit-print-color-adjust:exact}.ym-print-page:last-child{break-after:auto}" + e.pages.map((e, t) => `@page ym${t}{size:${i(e.widthUm)}mm ${i(e.heightUm)}mm;margin:0}.ym-print-page:nth-child(${t + 1}){page:ym${t}}`).join("\n"), n.head.append(a);
|
|
373
|
+
for (let r of e.pages) n.body.append(w(r, n, t ? x : e.font.family));
|
|
374
|
+
return n.documentElement.lang = "zh-CN", "<!doctype html>\n" + n.documentElement.outerHTML;
|
|
375
|
+
}
|
|
376
|
+
function O(e) {
|
|
377
|
+
let t = "";
|
|
378
|
+
for (let n = 0; n < e.length; n += 32768) t += String.fromCharCode(...e.subarray(n, n + 32768));
|
|
379
|
+
return `data:font/${String.fromCharCode(...e.subarray(0, 4)) === "OTTO" ? "otf" : "ttf"};base64,${btoa(t)}`;
|
|
380
|
+
}
|
|
381
|
+
async function k(e, n, r = {}) {
|
|
382
|
+
let { signal: i } = r, a = r.timeoutMs ?? 3e4;
|
|
383
|
+
if (i?.aborted) throw new t("PRINT_CANCELLED", "打印准备已取消");
|
|
384
|
+
if (!Number.isSafeInteger(a) || a < 1 || a > 12e4) throw new t("PRINT_OPTIONS", "打印准备超时需要 1–120000 ms");
|
|
385
|
+
let o = D(e, n ? O(n) : void 0), s = document.createElement("iframe");
|
|
386
|
+
s.title = "YmPrintUnit 打印文档", s.style.cssText = "position:fixed;left:-20000px;top:0;width:1200px;height:900px;border:0;";
|
|
387
|
+
let c = !1, l = !1, u, d = () => {}, f = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set(), m = () => {
|
|
388
|
+
if (!c) {
|
|
389
|
+
c = !0, clearTimeout(u), i?.removeEventListener("abort", h), s.onload = s.onerror = null, s.contentWindow?.removeEventListener("afterprint", g);
|
|
390
|
+
for (let e of f) e.onload = e.onerror = null, e.src = "";
|
|
391
|
+
f.clear(), p.clear(), s.remove(), l || d(new t("PRINT_CANCELLED", "打印准备已取消"));
|
|
392
|
+
}
|
|
393
|
+
}, h = () => m(), g = () => {
|
|
394
|
+
try {
|
|
395
|
+
for (let e of [...p]) e();
|
|
396
|
+
} finally {
|
|
397
|
+
queueMicrotask(m);
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
try {
|
|
401
|
+
return await new Promise((e, r) => {
|
|
402
|
+
d = r, u = setTimeout(() => {
|
|
403
|
+
r(new t("PRINT_FRAME_TIMEOUT", "打印文档加载超时")), m();
|
|
404
|
+
}, a), i?.addEventListener("abort", h, { once: !0 }), s.onerror = () => {
|
|
405
|
+
r(new t("PRINT_FRAME_FAILED", "打印文档加载失败")), m();
|
|
406
|
+
}, s.onload = () => {
|
|
407
|
+
(async () => {
|
|
408
|
+
if (c) return;
|
|
409
|
+
let r = s.contentDocument;
|
|
410
|
+
if (!r) throw new t("PRINT_FRAME_FAILED", "打印文档不可访问");
|
|
411
|
+
n && await r.fonts.load(`16px ${x}`), await r.fonts.ready, !c && (await Promise.all([...r.querySelectorAll("image")].map((e) => new Promise((n, r) => {
|
|
412
|
+
let i = new Image();
|
|
413
|
+
f.add(i);
|
|
414
|
+
let a = (e) => {
|
|
415
|
+
i.onload = i.onerror = null, i.src = "", f.delete(i), e ? r(e) : n();
|
|
416
|
+
};
|
|
417
|
+
i.onload = () => a(), i.onerror = () => a(new t("IMAGE_DECODE", "打印图片解码失败")), i.src = e.getAttribute("href");
|
|
418
|
+
}))), !c && (l = !0, clearTimeout(u), s.onload = s.onerror = null, s.contentWindow.addEventListener("afterprint", g), e()));
|
|
419
|
+
})().catch((e) => {
|
|
420
|
+
r(e), m();
|
|
421
|
+
});
|
|
422
|
+
}, s.srcdoc = o, document.body.append(s), i?.aborted && h();
|
|
423
|
+
}), {
|
|
424
|
+
frame: s,
|
|
425
|
+
html: o,
|
|
426
|
+
isDisposed: () => c,
|
|
427
|
+
dispose: m,
|
|
428
|
+
onAfterPrint: (e) => {
|
|
429
|
+
if (c) throw new t("PRINT_DISPOSED", "打印会话已销毁");
|
|
430
|
+
return p.add(e), () => p.delete(e);
|
|
431
|
+
},
|
|
432
|
+
print: () => {
|
|
433
|
+
if (c) throw new t("PRINT_DISPOSED", "打印会话已销毁");
|
|
434
|
+
try {
|
|
435
|
+
s.contentWindow.focus(), s.contentWindow.print();
|
|
436
|
+
} catch (e) {
|
|
437
|
+
throw m(), e;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
} catch (e) {
|
|
442
|
+
throw m(), e;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
async function A(e, t = {}) {
|
|
446
|
+
s();
|
|
447
|
+
let { rasterizePdf: n } = await import("./pdf-import-bNngi03w.js");
|
|
448
|
+
return n(e, t);
|
|
449
|
+
}
|
|
450
|
+
export { c as BrowserFont, x as FONT_FAMILY, u as SINGLE_IMAGE_LIMITS, d as STRIP_IMAGE_LIMITS, w as createPageElement, D as createPrintHtml, _ as exportPageImage, h as exportPageImageStrips, y as exportPageJpeg, v as exportPagePng, O as fontDataUrl, E as fontFaceCss, A as importPdfPages, g as pageRasterSegments, p as planPageImage, k as preparePrintFrame, T as renderLayout };
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
�RCopyright 1990-2009 Adobe Systems Incorporated.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
See ./LICENSE!!��]aX!!]`�21�> �p�z�$]��"R�d�-U�7�*�
|
|
4
|
+
�"]�h�"]�F�"]�$�"]��"]�`�"]�>�"]��"]�z�"]�X�"]�6�"]��"]�r�"]�P�"]�.�"]��"]�j�"]�H�"]�&�"]��"]�b�"]�@�"]��"]�|�"]�Z�"]�8�"]��"]�t�"]�R�"]�0�"]��"]�l�"]�J�"]�(�"]��"]�d�"]�B�"]� �"X�~�']�W�"]�5�"]��"]�q�"]�O�"]�-�"]��"]�i�"]�G�"]�%�"]��"]�a�"]�?�"]��"]�{�"]�Y�"]�7�"]��"]�s�"]�Q�"]�/�"]�
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|