modern-pdf-lib 0.25.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -3
- package/dist/{batchOptimize-Ba_pWw71.cjs → batchOptimize-CXC9gNqD.cjs} +55 -55
- package/dist/{batchOptimize-DtRwBOqR.mjs → batchOptimize-CjLGD5ie.mjs} +25 -25
- package/dist/{bridge-DYCQzxF7.cjs → bridge-ByvzPu5h.cjs} +29 -31
- package/dist/{bridge-CcivG_Sm.mjs → bridge-ZD6O6QQa.mjs} +4 -5
- package/dist/browser.cjs +263 -151
- package/dist/browser.d.cts +166 -166
- package/dist/browser.d.cts.map +1 -1
- package/dist/browser.d.mts +166 -166
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.mjs +15 -19
- package/dist/cli/index.cjs +7 -7
- package/dist/cli/index.mjs +8 -8
- package/dist/{compressionAnalysis-odbHC7Uk.mjs → compressionAnalysis-BgKy45pA.mjs} +60 -74
- package/dist/{compressionAnalysis-DGs-MqTe.d.mts → compressionAnalysis-CDOp_vPr.d.mts} +136 -136
- package/dist/compressionAnalysis-CDOp_vPr.d.mts.map +1 -0
- package/dist/{compressionAnalysis-B84FPXaQ.cjs → compressionAnalysis-Djv-Zvcd.cjs} +90 -104
- package/dist/{compressionAnalysis-VtYV9Zmq.d.cts → compressionAnalysis-UfmonqbM.d.cts} +136 -136
- package/dist/compressionAnalysis-UfmonqbM.d.cts.map +1 -0
- package/dist/create.cjs +21 -23
- package/dist/create.d.cts +2 -2
- package/dist/create.d.mts +2 -2
- package/dist/create.mjs +3 -5
- package/dist/{deduplicateImages-MfUDPxQz.mjs → deduplicateImages-BTCyAPfJ.mjs} +4 -5
- package/dist/{deduplicateImages-cKsnD6Ep.cjs → deduplicateImages-CaGgaqyS.cjs} +14 -15
- package/dist/{fieldAppearance-C8PoLFSc.d.mts → fieldAppearance-Df1262CT.d.cts} +44 -44
- package/dist/fieldAppearance-Df1262CT.d.cts.map +1 -0
- package/dist/{fieldAppearance-CdiGFG5e.d.cts → fieldAppearance-_CZdoUCD.d.mts} +44 -44
- package/dist/fieldAppearance-_CZdoUCD.d.mts.map +1 -0
- package/dist/fontEmbed-DGiZS0h2.d.cts +677 -0
- package/dist/fontEmbed-DGiZS0h2.d.cts.map +1 -0
- package/dist/fontEmbed-DtA_riGC.d.mts +677 -0
- package/dist/fontEmbed-DtA_riGC.d.mts.map +1 -0
- package/dist/forms.cjs +3 -4
- package/dist/forms.d.cts +2 -2
- package/dist/forms.d.mts +2 -2
- package/dist/forms.mjs +2 -3
- package/dist/{grayscaleDetect-C6kFF3dk.mjs → grayscaleDetect-6GJrgBRT.mjs} +3 -3
- package/dist/{grayscaleDetect-C2m-eEXR.cjs → grayscaleDetect-DAUqxjgR.cjs} +13 -14
- package/dist/{imageExtract-zEb1gnkb.cjs → imageExtract-DT50Hp_g.cjs} +13 -14
- package/dist/{imageExtract-Dnk_Ssv7.mjs → imageExtract-Dapir-ux.mjs} +3 -4
- package/dist/index-C1lZe66f.d.mts +8682 -0
- package/dist/index-C1lZe66f.d.mts.map +1 -0
- package/dist/index-D1SvXWSI.d.cts +8682 -0
- package/dist/index-D1SvXWSI.d.cts.map +1 -0
- package/dist/index.cjs +263 -150
- package/dist/index.d.cts +7 -7
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +14 -17
- package/dist/{layout-DH61a1iR.cjs → layout-C4vbTlBW.cjs} +184 -134
- package/dist/{layout-D6EUKSP8.mjs → layout-lO4x64kY.mjs} +50 -12
- package/dist/{loader-C7B5dVCI.mjs → loader-B1Ix7ozU.mjs} +259 -13
- package/dist/{loader-I4zdkoWc.cjs → loader-DR7H0XOf.cjs} +343 -67
- package/dist/parse.cjs +7 -8
- package/dist/parse.d.cts +3 -3
- package/dist/parse.d.mts +3 -3
- package/dist/parse.mjs +6 -7
- package/dist/pdfDocument-CH2E4UCc.d.mts +5160 -0
- package/dist/pdfDocument-CH2E4UCc.d.mts.map +1 -0
- package/dist/{pdfDocument-CEbbUP9i.cjs → pdfDocument-C_7mrBCL.cjs} +20493 -9511
- package/dist/pdfDocument-CzOipXnw.d.cts +5160 -0
- package/dist/pdfDocument-CzOipXnw.d.cts.map +1 -0
- package/dist/{pdfDocument-B0_XwS4X.mjs → pdfDocument-DRbT6HZw.mjs} +11017 -863
- package/dist/{pdfForm-9gd40uz9.cjs → pdfForm-BVS_do95.cjs} +113 -102
- package/dist/pdfForm-Ca86NDWn.d.cts +897 -0
- package/dist/pdfForm-Ca86NDWn.d.cts.map +1 -0
- package/dist/pdfForm-Ca86NDWn.d.mts +897 -0
- package/dist/pdfForm-Ca86NDWn.d.mts.map +1 -0
- package/dist/{pdfForm-Cn-cVicP.mjs → pdfForm-CfLnlsj-.mjs} +23 -18
- package/dist/{pdfObjects-1veop1_d.cjs → pdfObjects-BcPlSI0a.cjs} +62 -53
- package/dist/{pdfObjects-uEsWlfzU.mjs → pdfObjects-CB7TEdbW.mjs} +12 -2
- package/dist/rolldown-runtime-ak5kbic3.cjs +18 -0
- package/dist/{src-B1iDGLCL.cjs → src-C-IDXuvi.cjs} +9886 -1421
- package/dist/{src-Db6Qknoz.mjs → src-DJaD-bJ2.mjs} +8392 -515
- package/dist/{streamDecode-Bj568Nc9.mjs → streamDecode-BamENT3k.mjs} +129 -150
- package/dist/{streamDecode-CvgErkFu.cjs → streamDecode-DcaZz309.cjs} +139 -160
- package/package.json +26 -22
- package/dist/compressionAnalysis-DGs-MqTe.d.mts.map +0 -1
- package/dist/compressionAnalysis-VtYV9Zmq.d.cts.map +0 -1
- package/dist/fflateAdapter-LTAeAhaD.cjs +0 -207
- package/dist/fflateAdapter-PSiW_ML7.mjs +0 -196
- package/dist/fieldAppearance-C8PoLFSc.d.mts.map +0 -1
- package/dist/fieldAppearance-CdiGFG5e.d.cts.map +0 -1
- package/dist/fontEmbed-BN842wlb.d.cts +0 -659
- package/dist/fontEmbed-BN842wlb.d.cts.map +0 -1
- package/dist/fontEmbed-Dgq5K89o.d.mts +0 -659
- package/dist/fontEmbed-Dgq5K89o.d.mts.map +0 -1
- package/dist/fontSubset-5SLWMmEw.cjs +0 -518
- package/dist/fontSubset-D-vQQems.mjs +0 -495
- package/dist/index-DCSbmXWh.d.mts +0 -5939
- package/dist/index-DCSbmXWh.d.mts.map +0 -1
- package/dist/index-J1W3FdL8.d.cts +0 -5939
- package/dist/index-J1W3FdL8.d.cts.map +0 -1
- package/dist/libdeflateWasm-8b91Vmia.mjs +0 -220
- package/dist/libdeflateWasm-BdiDEJOj.cjs +0 -237
- package/dist/pdfCatalog-3yMIhJtt.mjs +0 -138
- package/dist/pdfCatalog-CYy4NXEY.cjs +0 -173
- package/dist/pdfDocument-BgvEP5Po.d.mts +0 -4673
- package/dist/pdfDocument-BgvEP5Po.d.mts.map +0 -1
- package/dist/pdfDocument-CbU-2TjT.d.cts +0 -4673
- package/dist/pdfDocument-CbU-2TjT.d.cts.map +0 -1
- package/dist/pdfForm-BiyNtYem.d.mts +0 -905
- package/dist/pdfForm-BiyNtYem.d.mts.map +0 -1
- package/dist/pdfForm-SOXJ72LW.d.cts +0 -905
- package/dist/pdfForm-SOXJ72LW.d.cts.map +0 -1
- package/dist/pdfPage-B_d9HmkG.mjs +0 -8015
- package/dist/pdfPage-Cd8jOJp6.cjs +0 -8728
- package/dist/pngEmbed-BWAbEUKF.mjs +0 -552
- package/dist/pngEmbed-D4X4ZN-3.cjs +0 -563
- package/dist/rolldown-runtime-CKhH4XqG.cjs +0 -24
|
@@ -1,6 +1,236 @@
|
|
|
1
|
-
const require_rolldown_runtime = require(
|
|
2
|
-
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-ak5kbic3.cjs");
|
|
2
|
+
//#region src/wasm/inlineWasm.ts
|
|
3
|
+
/**
|
|
4
|
+
* @module wasm/inlineWasm
|
|
5
|
+
*
|
|
6
|
+
* Provides runtime access to inline (base64-encoded) WASM module bytes
|
|
7
|
+
* with **lazy decoding** and **GC-friendly caching**.
|
|
8
|
+
*
|
|
9
|
+
* This module is the runtime companion to the build-time code generation
|
|
10
|
+
* script `scripts/generate-inline-wasm.ts`. It imports the generated
|
|
11
|
+
* constants from `inlineWasm.generated.ts` and exposes functions that
|
|
12
|
+
* decode a module's base64 string into a `Uint8Array` on demand.
|
|
13
|
+
*
|
|
14
|
+
* Design:
|
|
15
|
+
* - The heavy lifting (reading WASM files, base64 encoding) happens at
|
|
16
|
+
* **build time** via the code generation script.
|
|
17
|
+
* - At **runtime**, base64 decoding is deferred until the module is
|
|
18
|
+
* actually requested — no upfront cost.
|
|
19
|
+
* - Decoded bytes are held via `WeakRef` so the GC can reclaim them
|
|
20
|
+
* when memory pressure is high. A strong cache is also available
|
|
21
|
+
* for performance-critical paths.
|
|
22
|
+
* - {@link preloadInlineWasm} allows proactive decoding before first use.
|
|
23
|
+
* - {@link getInlineWasmSize} returns the encoded size without triggering
|
|
24
|
+
* any base64 decode.
|
|
25
|
+
*
|
|
26
|
+
* @packageDocumentation
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* The set of all WASM module names supported by the library.
|
|
30
|
+
*
|
|
31
|
+
* These correspond to the crate directories under `src/wasm/`.
|
|
32
|
+
*/
|
|
33
|
+
const WASM_MODULE_NAMES = [
|
|
34
|
+
"libdeflate",
|
|
35
|
+
"png",
|
|
36
|
+
"ttf",
|
|
37
|
+
"shaping",
|
|
38
|
+
"jbig2",
|
|
39
|
+
"jpeg"
|
|
40
|
+
];
|
|
41
|
+
/**
|
|
42
|
+
* Strong cache of decoded WASM bytes, keyed by module name.
|
|
43
|
+
*
|
|
44
|
+
* Entries are populated on first access and kept alive as long as
|
|
45
|
+
* callers hold references. {@link clearInlineWasmCache} clears this.
|
|
46
|
+
*/
|
|
47
|
+
const strongCache = /* @__PURE__ */ new Map();
|
|
48
|
+
/**
|
|
49
|
+
* Weak cache of decoded WASM bytes.
|
|
50
|
+
*
|
|
51
|
+
* When the strong cache is cleared (e.g., to reduce memory), the
|
|
52
|
+
* weak cache may still hold a reference if the GC hasn't collected
|
|
53
|
+
* the bytes. This avoids redundant re-decoding when bytes are still
|
|
54
|
+
* reachable elsewhere.
|
|
55
|
+
*/
|
|
56
|
+
const weakCache = /* @__PURE__ */ new Map();
|
|
57
|
+
/**
|
|
58
|
+
* Retrieve the decoded WASM bytes for a given module name.
|
|
59
|
+
*
|
|
60
|
+
* On first call for a module, the base64 string from the generated file
|
|
61
|
+
* is decoded into a `Uint8Array`. Subsequent calls return the cached
|
|
62
|
+
* result. If the strong cache has been cleared but a `WeakRef` still
|
|
63
|
+
* holds the bytes, they are recovered without re-decoding.
|
|
64
|
+
*
|
|
65
|
+
* @param name The WASM module name (e.g., `'libdeflate'`, `'png'`).
|
|
66
|
+
* @returns The decoded WASM binary as a `Uint8Array`.
|
|
67
|
+
* @throws If the module name is unknown or the generated file does
|
|
68
|
+
* not contain data for the requested module.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const wasmBytes = getInlineWasmBytes('libdeflate');
|
|
73
|
+
* const module = await WebAssembly.compile(wasmBytes);
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
function getInlineWasmBytes(name) {
|
|
77
|
+
if (!isValidModuleName(name)) throw new Error(`Unknown WASM module: "${name}". Valid modules: ${WASM_MODULE_NAMES.join(", ")}`);
|
|
78
|
+
const strong = strongCache.get(name);
|
|
79
|
+
if (strong) return strong;
|
|
80
|
+
const weakRef = weakCache.get(name);
|
|
81
|
+
if (weakRef) {
|
|
82
|
+
const weakBytes = weakRef.deref();
|
|
83
|
+
if (weakBytes) {
|
|
84
|
+
strongCache.set(name, weakBytes);
|
|
85
|
+
return weakBytes;
|
|
86
|
+
}
|
|
87
|
+
weakCache.delete(name);
|
|
88
|
+
}
|
|
89
|
+
const base64Data = getBase64Data(name);
|
|
90
|
+
const bytes = Uint8Array.fromBase64(base64Data);
|
|
91
|
+
strongCache.set(name, bytes);
|
|
92
|
+
weakCache.set(name, new WeakRef(bytes));
|
|
93
|
+
return bytes;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Check whether a given module name is a valid WASM module name.
|
|
97
|
+
*
|
|
98
|
+
* @param name The name to check.
|
|
99
|
+
* @returns `true` if the name is one of the known WASM modules.
|
|
100
|
+
*/
|
|
101
|
+
function isValidModuleName(name) {
|
|
102
|
+
return WASM_MODULE_NAMES.includes(name);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Check whether inline WASM data is available for a given module.
|
|
106
|
+
*
|
|
107
|
+
* Returns `true` if the generated file contains base64 data for the
|
|
108
|
+
* requested module. Returns `false` if the generated file does not
|
|
109
|
+
* exist or does not include the module.
|
|
110
|
+
*
|
|
111
|
+
* @param name The WASM module name.
|
|
112
|
+
* @returns `true` if inline bytes can be retrieved for this module.
|
|
113
|
+
*/
|
|
114
|
+
function hasInlineWasmData(name) {
|
|
115
|
+
if (!isValidModuleName(name)) return false;
|
|
116
|
+
try {
|
|
117
|
+
return name in requireGenerated().INLINE_WASM_MODULES;
|
|
118
|
+
} catch {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get the encoded (base64) size of a WASM module **without** decoding it.
|
|
124
|
+
*
|
|
125
|
+
* This is useful for diagnostics, size budgeting, and bundle analysis.
|
|
126
|
+
* The returned value is the number of characters in the base64 string;
|
|
127
|
+
* the actual binary size is approximately `encodedSize * 3 / 4`.
|
|
128
|
+
*
|
|
129
|
+
* @param name The WASM module name.
|
|
130
|
+
* @returns The base64 string length (in characters), or `0` if the
|
|
131
|
+
* module is not available.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* const encoded = getInlineWasmSize('libdeflate');
|
|
136
|
+
* const binaryApprox = Math.floor(encoded * 3 / 4);
|
|
137
|
+
* console.log(`libdeflate: ~${binaryApprox} bytes binary`);
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
function getInlineWasmSize(name) {
|
|
141
|
+
if (!isValidModuleName(name)) return 0;
|
|
142
|
+
try {
|
|
143
|
+
const data = requireGenerated().INLINE_WASM_MODULES[name];
|
|
144
|
+
return data ? data.length : 0;
|
|
145
|
+
} catch {
|
|
146
|
+
return 0;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Proactively decode and cache WASM bytes for the specified modules.
|
|
151
|
+
*
|
|
152
|
+
* Call this during application initialization to avoid decoding latency
|
|
153
|
+
* on the first actual use. If no names are provided, all available
|
|
154
|
+
* modules are preloaded.
|
|
155
|
+
*
|
|
156
|
+
* @param names Optional list of module names to preload. Defaults to
|
|
157
|
+
* all modules present in the generated data.
|
|
158
|
+
* @returns The names of modules that were successfully preloaded.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* // Preload specific modules
|
|
163
|
+
* preloadInlineWasm('libdeflate', 'png');
|
|
164
|
+
*
|
|
165
|
+
* // Preload everything available
|
|
166
|
+
* preloadInlineWasm();
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
function preloadInlineWasm(...names) {
|
|
170
|
+
const targets = names.length > 0 ? names : [...WASM_MODULE_NAMES];
|
|
171
|
+
const loaded = [];
|
|
172
|
+
for (const name of targets) {
|
|
173
|
+
if (!isValidModuleName(name)) continue;
|
|
174
|
+
if (strongCache.has(name)) {
|
|
175
|
+
loaded.push(name);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
getInlineWasmBytes(name);
|
|
180
|
+
loaded.push(name);
|
|
181
|
+
} catch {}
|
|
182
|
+
}
|
|
183
|
+
return loaded;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Lazily load and cache the generated module.
|
|
187
|
+
*
|
|
188
|
+
* Uses a dynamic import expression to avoid hard compile-time dependency
|
|
189
|
+
* on the generated file (which may not exist during development).
|
|
190
|
+
*/
|
|
191
|
+
function requireGenerated() {
|
|
192
|
+
try {
|
|
193
|
+
throw new Error("Inline WASM data not loaded. Call loadInlineWasmModule() first, or run `npm run generate:wasm-inline`.");
|
|
194
|
+
} catch (err) {
|
|
195
|
+
throw err;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Extract the base64 string for a given module name from the generated data.
|
|
200
|
+
*
|
|
201
|
+
* @throws If the generated data is not loaded or does not contain the module.
|
|
202
|
+
*/
|
|
203
|
+
function getBase64Data(name) {
|
|
204
|
+
try {
|
|
205
|
+
const moduleData = requireGenerated().INLINE_WASM_MODULES[name];
|
|
206
|
+
if (!moduleData) throw new Error(`WASM module "${name}" is not available in the generated inline data. Run \`npm run generate:wasm-inline\` to regenerate.`);
|
|
207
|
+
return moduleData;
|
|
208
|
+
} catch (err) {
|
|
209
|
+
if (err instanceof Error && err.message.includes("is not available")) throw err;
|
|
210
|
+
throw new Error(`Failed to load inline WASM data for module "${name}". The generated file may not exist. Run \`npm run generate:wasm-inline\` to generate it. Original error: ${err instanceof Error ? err.message : String(err)}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
//#endregion
|
|
3
214
|
//#region src/wasm/loader.ts
|
|
215
|
+
/**
|
|
216
|
+
* @module wasm/loader
|
|
217
|
+
*
|
|
218
|
+
* Universal WASM module loader for the modern-pdf library.
|
|
219
|
+
*
|
|
220
|
+
* Provides a single entry point for loading `.wasm` binaries across
|
|
221
|
+
* all supported JavaScript runtimes:
|
|
222
|
+
*
|
|
223
|
+
* - **Browser**: Uses `fetch()` to load from a URL.
|
|
224
|
+
* - **Node.js**: Uses `fs/promises` via dynamic import to read from disk.
|
|
225
|
+
* - **Deno**: Uses `Deno.readFile()` or `fetch()` for local/remote files.
|
|
226
|
+
* - **Bun**: Uses `Bun.file()` for local files or `fetch()` for URLs.
|
|
227
|
+
* - **Cloudflare Workers / Edge**: Must provide WASM bytes directly
|
|
228
|
+
* (no filesystem access), or use bundled imports.
|
|
229
|
+
*
|
|
230
|
+
* Loaded modules are cached by name to avoid redundant fetches.
|
|
231
|
+
*
|
|
232
|
+
* @packageDocumentation
|
|
233
|
+
*/
|
|
4
234
|
var loader_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
5
235
|
clearWasmCache: () => clearWasmCache,
|
|
6
236
|
configureWasmLoader: () => configureWasmLoader,
|
|
@@ -39,13 +269,13 @@ let globalConfig = {};
|
|
|
39
269
|
* ```
|
|
40
270
|
*/
|
|
41
271
|
function detectRuntime() {
|
|
42
|
-
if (
|
|
272
|
+
if ("caches" in globalThis && !("HTMLElement" in globalThis) && !("process" in globalThis)) {
|
|
43
273
|
if (typeof globalThis["navigator"] === "object") {
|
|
44
274
|
if ((globalThis.navigator?.userAgent ?? "").includes("Cloudflare-Workers")) return "workerd";
|
|
45
275
|
}
|
|
46
276
|
}
|
|
47
|
-
if (
|
|
48
|
-
if (
|
|
277
|
+
if ("Deno" in globalThis) return "deno";
|
|
278
|
+
if ("Bun" in globalThis) return "bun";
|
|
49
279
|
if (typeof globalThis["process"] === "object" && typeof globalThis["process"]?.["versions"] === "object" && typeof (globalThis["process"]?.["versions"])?.["node"] === "string") return "node";
|
|
50
280
|
if (typeof globalThis["ServiceWorkerGlobalScope"] === "function" && typeof self !== "undefined" && self instanceof globalThis["ServiceWorkerGlobalScope"]) return "service-worker";
|
|
51
281
|
if (typeof globalThis.document === "object" || typeof globalThis.window === "object") return "browser";
|
|
@@ -99,7 +329,10 @@ async function loadViaFetch(url) {
|
|
|
99
329
|
*/
|
|
100
330
|
async function loadViaNodeFs(filePath) {
|
|
101
331
|
try {
|
|
102
|
-
const { readFile } = await import(
|
|
332
|
+
const { readFile } = await import(
|
|
333
|
+
/* @vite-ignore */
|
|
334
|
+
"node:fs/promises"
|
|
335
|
+
);
|
|
103
336
|
const buffer = await readFile(filePath);
|
|
104
337
|
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
105
338
|
} catch (err) {
|
|
@@ -129,14 +362,22 @@ function resolveModulePath(name, config, runtime) {
|
|
|
129
362
|
case "service-worker": return `/wasm/${filename}`;
|
|
130
363
|
case "node":
|
|
131
364
|
case "bun": try {
|
|
132
|
-
return new URL(
|
|
365
|
+
return new URL(`./wasm/${name}/${filename}`, require("url").pathToFileURL(__filename).href).pathname;
|
|
133
366
|
} catch {
|
|
134
|
-
|
|
367
|
+
try {
|
|
368
|
+
return new URL(`../wasm/${name}/pkg/${filename}`, require("url").pathToFileURL(__filename).href).pathname;
|
|
369
|
+
} catch {
|
|
370
|
+
return `./wasm/${name}/pkg/${filename}`;
|
|
371
|
+
}
|
|
135
372
|
}
|
|
136
373
|
case "deno": try {
|
|
137
|
-
return new URL(
|
|
374
|
+
return new URL(`./wasm/${name}/${filename}`, require("url").pathToFileURL(__filename).href).href;
|
|
138
375
|
} catch {
|
|
139
|
-
|
|
376
|
+
try {
|
|
377
|
+
return new URL(`../wasm/${name}/pkg/${filename}`, require("url").pathToFileURL(__filename).href).href;
|
|
378
|
+
} catch {
|
|
379
|
+
return `./wasm/${name}/pkg/${filename}`;
|
|
380
|
+
}
|
|
140
381
|
}
|
|
141
382
|
case "workerd": throw new Error(`Cannot auto-resolve WASM path in Workers/Edge runtime. Provide WASM bytes via configureWasmLoader({ moduleBytes: { ${name}: bytes } }) or use modulePaths configuration.`);
|
|
142
383
|
default: return `./wasm/${name}/pkg/${filename}`;
|
|
@@ -174,6 +415,11 @@ async function loadWasmModule(name) {
|
|
|
174
415
|
moduleCache.set(name, bytes);
|
|
175
416
|
return bytes;
|
|
176
417
|
}
|
|
418
|
+
if (hasInlineWasmData(name)) try {
|
|
419
|
+
const bytes = getInlineWasmBytes(name);
|
|
420
|
+
moduleCache.set(name, bytes);
|
|
421
|
+
return bytes;
|
|
422
|
+
} catch {}
|
|
177
423
|
const runtime = detectRuntime();
|
|
178
424
|
const modulePath = resolveModulePath(name, globalConfig, runtime);
|
|
179
425
|
let bytes;
|
|
@@ -322,72 +568,102 @@ function resetWasmLoader() {
|
|
|
322
568
|
moduleCache.clear();
|
|
323
569
|
globalConfig = {};
|
|
324
570
|
}
|
|
325
|
-
|
|
326
571
|
//#endregion
|
|
327
|
-
Object.defineProperty(exports,
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
572
|
+
Object.defineProperty(exports, "clearWasmCache", {
|
|
573
|
+
enumerable: true,
|
|
574
|
+
get: function() {
|
|
575
|
+
return clearWasmCache;
|
|
576
|
+
}
|
|
332
577
|
});
|
|
333
|
-
Object.defineProperty(exports,
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
578
|
+
Object.defineProperty(exports, "configureWasmLoader", {
|
|
579
|
+
enumerable: true,
|
|
580
|
+
get: function() {
|
|
581
|
+
return configureWasmLoader;
|
|
582
|
+
}
|
|
338
583
|
});
|
|
339
|
-
Object.defineProperty(exports,
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
584
|
+
Object.defineProperty(exports, "detectRuntime", {
|
|
585
|
+
enumerable: true,
|
|
586
|
+
get: function() {
|
|
587
|
+
return detectRuntime;
|
|
588
|
+
}
|
|
344
589
|
});
|
|
345
|
-
Object.defineProperty(exports,
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
590
|
+
Object.defineProperty(exports, "getInlineWasmBytes", {
|
|
591
|
+
enumerable: true,
|
|
592
|
+
get: function() {
|
|
593
|
+
return getInlineWasmBytes;
|
|
594
|
+
}
|
|
350
595
|
});
|
|
351
|
-
Object.defineProperty(exports,
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
596
|
+
Object.defineProperty(exports, "getInlineWasmSize", {
|
|
597
|
+
enumerable: true,
|
|
598
|
+
get: function() {
|
|
599
|
+
return getInlineWasmSize;
|
|
600
|
+
}
|
|
356
601
|
});
|
|
357
|
-
Object.defineProperty(exports,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
602
|
+
Object.defineProperty(exports, "hasInlineWasmData", {
|
|
603
|
+
enumerable: true,
|
|
604
|
+
get: function() {
|
|
605
|
+
return hasInlineWasmData;
|
|
606
|
+
}
|
|
362
607
|
});
|
|
363
|
-
Object.defineProperty(exports,
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
608
|
+
Object.defineProperty(exports, "instantiateWasmModuleStreaming", {
|
|
609
|
+
enumerable: true,
|
|
610
|
+
get: function() {
|
|
611
|
+
return instantiateWasmModuleStreaming;
|
|
612
|
+
}
|
|
368
613
|
});
|
|
369
|
-
Object.defineProperty(exports,
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
614
|
+
Object.defineProperty(exports, "isValidModuleName", {
|
|
615
|
+
enumerable: true,
|
|
616
|
+
get: function() {
|
|
617
|
+
return isValidModuleName;
|
|
618
|
+
}
|
|
374
619
|
});
|
|
375
|
-
Object.defineProperty(exports,
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
620
|
+
Object.defineProperty(exports, "isWasmDisabled", {
|
|
621
|
+
enumerable: true,
|
|
622
|
+
get: function() {
|
|
623
|
+
return isWasmDisabled;
|
|
624
|
+
}
|
|
380
625
|
});
|
|
381
|
-
Object.defineProperty(exports,
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
626
|
+
Object.defineProperty(exports, "isWasmModuleCached", {
|
|
627
|
+
enumerable: true,
|
|
628
|
+
get: function() {
|
|
629
|
+
return isWasmModuleCached;
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
Object.defineProperty(exports, "loadWasmModule", {
|
|
633
|
+
enumerable: true,
|
|
634
|
+
get: function() {
|
|
635
|
+
return loadWasmModule;
|
|
636
|
+
}
|
|
386
637
|
});
|
|
387
|
-
Object.defineProperty(exports,
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
638
|
+
Object.defineProperty(exports, "loadWasmModuleStreaming", {
|
|
639
|
+
enumerable: true,
|
|
640
|
+
get: function() {
|
|
641
|
+
return loadWasmModuleStreaming;
|
|
642
|
+
}
|
|
392
643
|
});
|
|
393
|
-
|
|
644
|
+
Object.defineProperty(exports, "loader_exports", {
|
|
645
|
+
enumerable: true,
|
|
646
|
+
get: function() {
|
|
647
|
+
return loader_exports;
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
Object.defineProperty(exports, "preloadInlineWasm", {
|
|
651
|
+
enumerable: true,
|
|
652
|
+
get: function() {
|
|
653
|
+
return preloadInlineWasm;
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
Object.defineProperty(exports, "provideWasmBytes", {
|
|
657
|
+
enumerable: true,
|
|
658
|
+
get: function() {
|
|
659
|
+
return provideWasmBytes;
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
Object.defineProperty(exports, "resetWasmLoader", {
|
|
663
|
+
enumerable: true,
|
|
664
|
+
get: function() {
|
|
665
|
+
return resetWasmLoader;
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
//# sourceMappingURL=loader-DR7H0XOf.cjs.map
|
package/dist/parse.cjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const require_streamDecode = require(
|
|
5
|
-
const require_compressionAnalysis = require(
|
|
6
|
-
const require_imageExtract = require(
|
|
7
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_pdfDocument = require("./pdfDocument-C_7mrBCL.cjs");
|
|
3
|
+
const require_pdfObjects = require("./pdfObjects-BcPlSI0a.cjs");
|
|
4
|
+
const require_streamDecode = require("./streamDecode-DcaZz309.cjs");
|
|
5
|
+
const require_compressionAnalysis = require("./compressionAnalysis-Djv-Zvcd.cjs");
|
|
6
|
+
const require_imageExtract = require("./imageExtract-DT50Hp_g.cjs");
|
|
8
7
|
exports.PdfArray = require_pdfObjects.PdfArray;
|
|
9
8
|
exports.PdfBool = require_pdfObjects.PdfBool;
|
|
10
9
|
exports.PdfDict = require_pdfObjects.PdfDict;
|
|
@@ -23,4 +22,4 @@ exports.extractText = require_compressionAnalysis.extractText;
|
|
|
23
22
|
exports.extractTextWithPositions = require_compressionAnalysis.extractTextWithPositions;
|
|
24
23
|
exports.formatHexContext = require_pdfDocument.formatHexContext;
|
|
25
24
|
exports.loadPdf = require_pdfDocument.loadPdf;
|
|
26
|
-
exports.parseContentStream = require_compressionAnalysis.parseContentStream;
|
|
25
|
+
exports.parseContentStream = require_compressionAnalysis.parseContentStream;
|
package/dist/parse.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as PdfRef, T as PdfString, _ as PdfDict, b as PdfNumber, g as PdfBool, h as PdfArray, v as PdfName, w as PdfStream, x as PdfObject, y as PdfNull } from "./pdfForm-
|
|
3
|
-
import { _ as parseContentStream, a as ImageInfo, c as PdfParseError, d as TextExtractionOptions, f as TextItem, g as Operand, h as ContentStreamOperator, i as analyzeImages, l as formatHexContext, m as extractTextWithPositions, n as AnalyzeImagesOptions, o as decodeImageStream, p as extractText, r as ImageAnalysis, s as extractImages, t as AnalysisReport, u as decodeStream } from "./compressionAnalysis-
|
|
1
|
+
import { F as loadPdf, P as LoadPdfOptions } from "./pdfDocument-CzOipXnw.cjs";
|
|
2
|
+
import { C as PdfRef, T as PdfString, _ as PdfDict, b as PdfNumber, g as PdfBool, h as PdfArray, v as PdfName, w as PdfStream, x as PdfObject, y as PdfNull } from "./pdfForm-Ca86NDWn.cjs";
|
|
3
|
+
import { _ as parseContentStream, a as ImageInfo, c as PdfParseError, d as TextExtractionOptions, f as TextItem, g as Operand, h as ContentStreamOperator, i as analyzeImages, l as formatHexContext, m as extractTextWithPositions, n as AnalyzeImagesOptions, o as decodeImageStream, p as extractText, r as ImageAnalysis, s as extractImages, t as AnalysisReport, u as decodeStream } from "./compressionAnalysis-UfmonqbM.cjs";
|
|
4
4
|
export { type AnalysisReport, type AnalyzeImagesOptions, type ContentStreamOperator, type ImageAnalysis, type ImageInfo, type LoadPdfOptions, type Operand, PdfArray, PdfBool, PdfDict, PdfName, PdfNull, PdfNumber, type PdfObject, PdfParseError, PdfRef, PdfStream, PdfString, type TextExtractionOptions, type TextItem, analyzeImages, decodeImageStream, decodeStream, extractImages, extractText, extractTextWithPositions, formatHexContext, loadPdf, parseContentStream };
|
package/dist/parse.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as PdfRef, T as PdfString, _ as PdfDict, b as PdfNumber, g as PdfBool, h as PdfArray, v as PdfName, w as PdfStream, x as PdfObject, y as PdfNull } from "./pdfForm-
|
|
3
|
-
import { _ as parseContentStream, a as ImageInfo, c as PdfParseError, d as TextExtractionOptions, f as TextItem, g as Operand, h as ContentStreamOperator, i as analyzeImages, l as formatHexContext, m as extractTextWithPositions, n as AnalyzeImagesOptions, o as decodeImageStream, p as extractText, r as ImageAnalysis, s as extractImages, t as AnalysisReport, u as decodeStream } from "./compressionAnalysis-
|
|
1
|
+
import { F as loadPdf, P as LoadPdfOptions } from "./pdfDocument-CH2E4UCc.mjs";
|
|
2
|
+
import { C as PdfRef, T as PdfString, _ as PdfDict, b as PdfNumber, g as PdfBool, h as PdfArray, v as PdfName, w as PdfStream, x as PdfObject, y as PdfNull } from "./pdfForm-Ca86NDWn.mjs";
|
|
3
|
+
import { _ as parseContentStream, a as ImageInfo, c as PdfParseError, d as TextExtractionOptions, f as TextItem, g as Operand, h as ContentStreamOperator, i as analyzeImages, l as formatHexContext, m as extractTextWithPositions, n as AnalyzeImagesOptions, o as decodeImageStream, p as extractText, r as ImageAnalysis, s as extractImages, t as AnalysisReport, u as decodeStream } from "./compressionAnalysis-CDOp_vPr.mjs";
|
|
4
4
|
export { type AnalysisReport, type AnalyzeImagesOptions, type ContentStreamOperator, type ImageAnalysis, type ImageInfo, type LoadPdfOptions, type Operand, PdfArray, PdfBool, PdfDict, PdfName, PdfNull, PdfNumber, type PdfObject, PdfParseError, PdfRef, PdfStream, PdfString, type TextExtractionOptions, type TextItem, analyzeImages, decodeImageStream, decodeStream, extractImages, extractText, extractTextWithPositions, formatHexContext, loadPdf, parseContentStream };
|
package/dist/parse.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as decodeStream } from "./streamDecode-
|
|
4
|
-
import { a as extractText, i as parseContentStream, o as extractTextWithPositions, t as analyzeImages } from "./compressionAnalysis-
|
|
5
|
-
import { n as extractImages, t as decodeImageStream } from "./imageExtract-
|
|
6
|
-
|
|
7
|
-
export { PdfArray, PdfBool, PdfDict, PdfName, PdfNull, PdfNumber, PdfParseError, PdfRef, PdfStream, PdfString, analyzeImages, decodeImageStream, decodeStream, extractImages, extractText, extractTextWithPositions, formatHexContext, loadPdf, parseContentStream };
|
|
1
|
+
import { $ as loadPdf, gt as formatHexContext, ht as PdfParseError } from "./pdfDocument-DRbT6HZw.mjs";
|
|
2
|
+
import { a as PdfNull, c as PdfRef, i as PdfName, l as PdfStream, n as PdfBool, o as PdfNumber, r as PdfDict, t as PdfArray, u as PdfString } from "./pdfObjects-CB7TEdbW.mjs";
|
|
3
|
+
import { t as decodeStream } from "./streamDecode-BamENT3k.mjs";
|
|
4
|
+
import { a as extractText, i as parseContentStream, o as extractTextWithPositions, t as analyzeImages } from "./compressionAnalysis-BgKy45pA.mjs";
|
|
5
|
+
import { n as extractImages, t as decodeImageStream } from "./imageExtract-Dapir-ux.mjs";
|
|
6
|
+
export { PdfArray, PdfBool, PdfDict, PdfName, PdfNull, PdfNumber, PdfParseError, PdfRef, PdfStream, PdfString, analyzeImages, decodeImageStream, decodeStream, extractImages, extractText, extractTextWithPositions, formatHexContext, loadPdf, parseContentStream };
|