@formepdf/core 0.9.2 → 0.10.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/dist/browser.d.ts +10 -21
- package/dist/browser.js +24 -54
- package/dist/index.js +13 -32
- package/package.json +4 -3
- package/pkg/forme.d.ts +0 -46
- package/pkg/forme.js +7 -477
- package/pkg/forme_bg.js +379 -0
- package/pkg/forme_bg.wasm +0 -0
- package/pkg/package.json +3 -1
package/dist/browser.d.ts
CHANGED
|
@@ -1,31 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Browser entry point for @formepdf/core.
|
|
2
|
+
* Browser / edge entry point for @formepdf/core.
|
|
3
3
|
*
|
|
4
4
|
* Import as `@formepdf/core/browser` — no Node APIs, works in any
|
|
5
|
-
* modern browser with WebAssembly support.
|
|
5
|
+
* modern browser, edge runtime, or worker with WebAssembly support.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* module
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Backed by the wasm-pack `--target bundler` build of pkg/, so the
|
|
8
|
+
* WASM module is wired up implicitly by the consuming bundler at
|
|
9
|
+
* module-load time (via `import * as wasm from './forme_bg.wasm'`
|
|
10
|
+
* inside pkg/forme.js). Vite, esbuild, Webpack, Turbopack, and
|
|
11
|
+
* Wrangler all handle this — there is no explicit init step.
|
|
11
12
|
*/
|
|
12
|
-
import type { InitInput } from '../pkg/forme.js';
|
|
13
13
|
export type { Color, EdgeValues, CornerValues, ElementStyleInfo, ElementInfo, PageInfo, LayoutInfo, RenderWithLayoutResult, RenderDocumentOptions, RedactionRegion, RedactionPattern, } from './index.js';
|
|
14
14
|
import type { RenderWithLayoutResult, RenderDocumentOptions, RedactionRegion, RedactionPattern } from './index.js';
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
* WASM URL/bytes.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* // Auto-resolve (works with bundlers)
|
|
22
|
-
* await initWasm();
|
|
23
|
-
*
|
|
24
|
-
* // Explicit URL (CDN, custom path, etc.)
|
|
25
|
-
* await initWasm('/wasm/forme_bg.wasm');
|
|
26
|
-
* await initWasm(new URL('./forme_bg.wasm', import.meta.url));
|
|
27
|
-
*/
|
|
28
|
-
export declare function init(module?: InitInput | Promise<InitInput>): Promise<void>;
|
|
15
|
+
/** @deprecated The bundler now wires up WASM automatically; calling
|
|
16
|
+
* this is a no-op. Safe to delete from your code. */
|
|
17
|
+
export declare function init(_module?: unknown): Promise<void>;
|
|
29
18
|
export declare function renderPdf(json: string): Promise<Uint8Array>;
|
|
30
19
|
export declare function renderPdfWithLayout(json: string): Promise<RenderWithLayoutResult>;
|
|
31
20
|
export declare function renderDocument(element: import('react').ReactElement, options?: RenderDocumentOptions): Promise<Uint8Array>;
|
package/dist/browser.js
CHANGED
|
@@ -1,40 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Browser entry point for @formepdf/core.
|
|
2
|
+
* Browser / edge entry point for @formepdf/core.
|
|
3
3
|
*
|
|
4
4
|
* Import as `@formepdf/core/browser` — no Node APIs, works in any
|
|
5
|
-
* modern browser with WebAssembly support.
|
|
5
|
+
* modern browser, edge runtime, or worker with WebAssembly support.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* module
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Backed by the wasm-pack `--target bundler` build of pkg/, so the
|
|
8
|
+
* WASM module is wired up implicitly by the consuming bundler at
|
|
9
|
+
* module-load time (via `import * as wasm from './forme_bg.wasm'`
|
|
10
|
+
* inside pkg/forme.js). Vite, esbuild, Webpack, Turbopack, and
|
|
11
|
+
* Wrangler all handle this — there is no explicit init step.
|
|
11
12
|
*/
|
|
12
|
-
import
|
|
13
|
+
import { certify_pdf as wasmCertifyPdf, find_text_regions as wasmFindTextRegions, merge_pdfs as wasmMergePdfs, redact_pdf as wasmRedactPdf, redact_text as wasmRedactText, render_pdf as wasmRenderPdf, render_pdf_with_layout as wasmRenderPdfWithLayout, render_template_pdf as wasmRenderTemplatePdf, render_template_pdf_with_layout as wasmRenderTemplatePdfWithLayout, } from '../pkg/forme.js';
|
|
13
14
|
// ── WASM initialization ────────────────────────────────────────────
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* await initWasm('/wasm/forme_bg.wasm');
|
|
26
|
-
* await initWasm(new URL('./forme_bg.wasm', import.meta.url));
|
|
27
|
-
*/
|
|
28
|
-
export async function init(module) {
|
|
29
|
-
if (initialized)
|
|
30
|
-
return;
|
|
31
|
-
if (module !== undefined) {
|
|
32
|
-
await initWasm({ module_or_path: module });
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
await initWasm();
|
|
36
|
-
}
|
|
37
|
-
initialized = true;
|
|
15
|
+
//
|
|
16
|
+
// Kept as a no-op for backward compatibility with callers that did
|
|
17
|
+
// `await init()` against the old --target web build. The bundler-
|
|
18
|
+
// target build instantiates the WASM at module-load time, so by the
|
|
19
|
+
// time anyone could invoke any of the exports below, the engine is
|
|
20
|
+
// already live.
|
|
21
|
+
//
|
|
22
|
+
/** @deprecated The bundler now wires up WASM automatically; calling
|
|
23
|
+
* this is a no-op. Safe to delete from your code. */
|
|
24
|
+
export async function init(_module) {
|
|
25
|
+
return;
|
|
38
26
|
}
|
|
39
27
|
// ── Helpers ────────────────────────────────────────────────────────
|
|
40
28
|
function uint8ArrayToBase64(bytes) {
|
|
@@ -93,16 +81,10 @@ async function resolveImagesInNode(node) {
|
|
|
93
81
|
}
|
|
94
82
|
}
|
|
95
83
|
// ── Render functions ───────────────────────────────────────────────
|
|
96
|
-
async function ensureInit() {
|
|
97
|
-
if (!initialized)
|
|
98
|
-
await init();
|
|
99
|
-
}
|
|
100
84
|
export async function renderPdf(json) {
|
|
101
|
-
await ensureInit();
|
|
102
85
|
return wasmRenderPdf(json);
|
|
103
86
|
}
|
|
104
87
|
export async function renderPdfWithLayout(json) {
|
|
105
|
-
await ensureInit();
|
|
106
88
|
const result = wasmRenderPdfWithLayout(json);
|
|
107
89
|
return result;
|
|
108
90
|
}
|
|
@@ -164,27 +146,21 @@ export async function renderSerializedDocWithLayout(doc, options) {
|
|
|
164
146
|
}
|
|
165
147
|
// ── Template rendering ──────────────────────────────────────────────
|
|
166
148
|
export async function renderTemplate(templateJson, dataJson) {
|
|
167
|
-
await ensureInit();
|
|
168
149
|
return wasmRenderTemplatePdf(templateJson, dataJson);
|
|
169
150
|
}
|
|
170
151
|
export async function renderTemplateWithLayout(templateJson, dataJson) {
|
|
171
|
-
await ensureInit();
|
|
172
152
|
const result = wasmRenderTemplatePdfWithLayout(templateJson, dataJson);
|
|
173
153
|
return result;
|
|
174
154
|
}
|
|
175
155
|
// ── PDF certification ────────────────────────────────────────────────
|
|
176
156
|
export async function certifyPdf(pdfBytes, config) {
|
|
177
|
-
|
|
178
|
-
const { certify_pdf } = await import('../pkg/forme.js');
|
|
179
|
-
return certify_pdf(pdfBytes, JSON.stringify(config));
|
|
157
|
+
return wasmCertifyPdf(pdfBytes, JSON.stringify(config));
|
|
180
158
|
}
|
|
181
159
|
/** @deprecated Use certifyPdf */
|
|
182
160
|
export const signPdf = certifyPdf;
|
|
183
161
|
// ── PDF redaction ────────────────────────────────────────────────────
|
|
184
162
|
export async function redactPdf(pdfBytes, regions) {
|
|
185
|
-
|
|
186
|
-
const { redact_pdf } = await import('../pkg/forme.js');
|
|
187
|
-
return redact_pdf(pdfBytes, JSON.stringify(regions));
|
|
163
|
+
return wasmRedactPdf(pdfBytes, JSON.stringify(regions));
|
|
188
164
|
}
|
|
189
165
|
// ── Text-search redaction ─────────────────────────────────────────────
|
|
190
166
|
/**
|
|
@@ -194,9 +170,7 @@ export async function redactPdf(pdfBytes, regions) {
|
|
|
194
170
|
* redaction regions (in web top-origin coordinates) for each match.
|
|
195
171
|
*/
|
|
196
172
|
export async function findTextRegions(pdfBytes, patterns) {
|
|
197
|
-
|
|
198
|
-
const { find_text_regions } = await import('../pkg/forme.js');
|
|
199
|
-
const json = find_text_regions(pdfBytes, JSON.stringify(patterns));
|
|
173
|
+
const json = wasmFindTextRegions(pdfBytes, JSON.stringify(patterns));
|
|
200
174
|
return JSON.parse(json);
|
|
201
175
|
}
|
|
202
176
|
/**
|
|
@@ -206,9 +180,7 @@ export async function findTextRegions(pdfBytes, patterns) {
|
|
|
206
180
|
* applies coordinate-based redaction to each match.
|
|
207
181
|
*/
|
|
208
182
|
export async function redactText(pdfBytes, patterns) {
|
|
209
|
-
|
|
210
|
-
const { redact_text } = await import('../pkg/forme.js');
|
|
211
|
-
return redact_text(pdfBytes, JSON.stringify(patterns));
|
|
183
|
+
return wasmRedactText(pdfBytes, JSON.stringify(patterns));
|
|
212
184
|
}
|
|
213
185
|
// ── PDF merging ──────────────────────────────────────────────────────
|
|
214
186
|
/**
|
|
@@ -218,10 +190,8 @@ export async function redactText(pdfBytes, patterns) {
|
|
|
218
190
|
* @returns The merged PDF as a Uint8Array.
|
|
219
191
|
*/
|
|
220
192
|
export async function mergePdfs(pdfs) {
|
|
221
|
-
await ensureInit();
|
|
222
|
-
const { merge_pdfs } = await import('../pkg/forme.js');
|
|
223
193
|
const base64Pdfs = pdfs.map((pdf) => btoa(Array.from(pdf, (b) => String.fromCharCode(b)).join('')));
|
|
224
|
-
return
|
|
194
|
+
return wasmMergePdfs(JSON.stringify(base64Pdfs));
|
|
225
195
|
}
|
|
226
196
|
// ── Data extraction (browser-native decompression) ──────────────────
|
|
227
197
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// Node entry uses the wasm-pack `--target nodejs` build, which is a
|
|
2
|
+
// self-initializing CJS module: it `require('fs').readFileSync`s its
|
|
3
|
+
// own .wasm at import time, so callers don't need to await any init.
|
|
4
|
+
import { render_pdf as wasmRenderPdf } from '../pkg-node/forme.js';
|
|
2
5
|
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import {
|
|
4
|
-
import { dirname, join, resolve } from 'node:path';
|
|
5
|
-
// ── WASM initialization ────────────────────────────────────────────
|
|
6
|
-
let initialized = false;
|
|
7
|
-
async function ensureInit() {
|
|
8
|
-
if (initialized)
|
|
9
|
-
return;
|
|
10
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
-
const wasmPath = join(__dirname, '..', 'pkg', 'forme_bg.wasm');
|
|
12
|
-
const wasmBytes = await readFile(wasmPath);
|
|
13
|
-
await initWasm({ module_or_path: wasmBytes });
|
|
14
|
-
initialized = true;
|
|
15
|
-
}
|
|
6
|
+
import { resolve } from 'node:path';
|
|
16
7
|
// ── Font resolution ──────────────────────────────────────────────
|
|
17
8
|
function uint8ArrayToBase64(bytes) {
|
|
18
9
|
return Buffer.from(bytes).toString('base64');
|
|
@@ -63,13 +54,10 @@ async function resolveImagesInNode(node) {
|
|
|
63
54
|
}
|
|
64
55
|
// ── Render functions ───────────────────────────────────────────────
|
|
65
56
|
export async function renderPdf(json) {
|
|
66
|
-
await ensureInit();
|
|
67
57
|
return wasmRenderPdf(json);
|
|
68
58
|
}
|
|
69
59
|
export async function renderPdfWithLayout(json) {
|
|
70
|
-
await
|
|
71
|
-
// Dynamic import to access the WASM binding that returns { pdf, layout }
|
|
72
|
-
const { render_pdf_with_layout } = await import('../pkg/forme.js');
|
|
60
|
+
const { render_pdf_with_layout } = await import('../pkg-node/forme.js');
|
|
73
61
|
const result = render_pdf_with_layout(json);
|
|
74
62
|
return result;
|
|
75
63
|
}
|
|
@@ -99,27 +87,23 @@ export async function renderDocumentWithLayout(element, options) {
|
|
|
99
87
|
}
|
|
100
88
|
// ── Template rendering ──────────────────────────────────────────────
|
|
101
89
|
export async function renderTemplate(templateJson, dataJson) {
|
|
102
|
-
await
|
|
103
|
-
const { render_template_pdf } = await import('../pkg/forme.js');
|
|
90
|
+
const { render_template_pdf } = await import('../pkg-node/forme.js');
|
|
104
91
|
return render_template_pdf(templateJson, dataJson);
|
|
105
92
|
}
|
|
106
93
|
export async function renderTemplateWithLayout(templateJson, dataJson) {
|
|
107
|
-
await
|
|
108
|
-
const { render_template_pdf_with_layout } = await import('../pkg/forme.js');
|
|
94
|
+
const { render_template_pdf_with_layout } = await import('../pkg-node/forme.js');
|
|
109
95
|
const result = render_template_pdf_with_layout(templateJson, dataJson);
|
|
110
96
|
return result;
|
|
111
97
|
}
|
|
112
98
|
// ── PDF certification ────────────────────────────────────────────────
|
|
113
99
|
export async function certifyPdf(pdfBytes, config) {
|
|
114
|
-
await
|
|
115
|
-
const { certify_pdf } = await import('../pkg/forme.js');
|
|
100
|
+
const { certify_pdf } = await import('../pkg-node/forme.js');
|
|
116
101
|
return certify_pdf(pdfBytes, JSON.stringify(config));
|
|
117
102
|
}
|
|
118
103
|
/** @deprecated Use certifyPdf */
|
|
119
104
|
export const signPdf = certifyPdf;
|
|
120
105
|
export async function redactPdf(pdfBytes, regions) {
|
|
121
|
-
await
|
|
122
|
-
const { redact_pdf } = await import('../pkg/forme.js');
|
|
106
|
+
const { redact_pdf } = await import('../pkg-node/forme.js');
|
|
123
107
|
return redact_pdf(pdfBytes, JSON.stringify(regions));
|
|
124
108
|
}
|
|
125
109
|
/**
|
|
@@ -129,8 +113,7 @@ export async function redactPdf(pdfBytes, regions) {
|
|
|
129
113
|
* redaction regions (in web top-origin coordinates) for each match.
|
|
130
114
|
*/
|
|
131
115
|
export async function findTextRegions(pdfBytes, patterns) {
|
|
132
|
-
await
|
|
133
|
-
const { find_text_regions } = await import('../pkg/forme.js');
|
|
116
|
+
const { find_text_regions } = await import('../pkg-node/forme.js');
|
|
134
117
|
const json = find_text_regions(pdfBytes, JSON.stringify(patterns));
|
|
135
118
|
return JSON.parse(json);
|
|
136
119
|
}
|
|
@@ -141,8 +124,7 @@ export async function findTextRegions(pdfBytes, patterns) {
|
|
|
141
124
|
* applies coordinate-based redaction to each match.
|
|
142
125
|
*/
|
|
143
126
|
export async function redactText(pdfBytes, patterns) {
|
|
144
|
-
await
|
|
145
|
-
const { redact_text } = await import('../pkg/forme.js');
|
|
127
|
+
const { redact_text } = await import('../pkg-node/forme.js');
|
|
146
128
|
return redact_text(pdfBytes, JSON.stringify(patterns));
|
|
147
129
|
}
|
|
148
130
|
// ── PDF merging ──────────────────────────────────────────────────────
|
|
@@ -153,8 +135,7 @@ export async function redactText(pdfBytes, patterns) {
|
|
|
153
135
|
* @returns The merged PDF as a Uint8Array.
|
|
154
136
|
*/
|
|
155
137
|
export async function mergePdfs(pdfs) {
|
|
156
|
-
await
|
|
157
|
-
const { merge_pdfs } = await import('../pkg/forme.js');
|
|
138
|
+
const { merge_pdfs } = await import('../pkg-node/forme.js');
|
|
158
139
|
const base64Pdfs = pdfs.map((pdf) => Buffer.from(pdf).toString('base64'));
|
|
159
140
|
return merge_pdfs(JSON.stringify(base64Pdfs));
|
|
160
141
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formepdf/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "WASM-powered PDF rendering engine for Forme",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"test": "vitest run"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@formepdf/react": "0.
|
|
51
|
+
"@formepdf/react": "0.10.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"react": "^18 || ^19"
|
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
},
|
|
63
63
|
"files": [
|
|
64
64
|
"dist/",
|
|
65
|
-
"pkg/"
|
|
65
|
+
"pkg/",
|
|
66
|
+
"pkg-node/"
|
|
66
67
|
],
|
|
67
68
|
"license": "MIT",
|
|
68
69
|
"repository": {
|
package/pkg/forme.d.ts
CHANGED
|
@@ -37,49 +37,3 @@ export function render_pdf_with_layout(json: string): any;
|
|
|
37
37
|
export function render_template_pdf(template_json: string, data_json: string): Uint8Array;
|
|
38
38
|
|
|
39
39
|
export function render_template_pdf_with_layout(template_json: string, data_json: string): any;
|
|
40
|
-
|
|
41
|
-
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
42
|
-
|
|
43
|
-
export interface InitOutput {
|
|
44
|
-
readonly memory: WebAssembly.Memory;
|
|
45
|
-
readonly certify_pdf: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
46
|
-
readonly find_text_regions: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
47
|
-
readonly merge_pdfs: (a: number, b: number) => [number, number, number, number];
|
|
48
|
-
readonly redact_pdf: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
49
|
-
readonly redact_text: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
50
|
-
readonly render_pdf: (a: number, b: number) => [number, number, number, number];
|
|
51
|
-
readonly render_pdf_with_layout: (a: number, b: number) => [number, number, number];
|
|
52
|
-
readonly render_template_pdf: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
53
|
-
readonly render_template_pdf_with_layout: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
54
|
-
readonly init_panic_hook: () => void;
|
|
55
|
-
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
56
|
-
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
57
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
58
|
-
readonly __wbindgen_exn_store: (a: number) => void;
|
|
59
|
-
readonly __externref_table_alloc: () => number;
|
|
60
|
-
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
61
|
-
readonly __externref_table_dealloc: (a: number) => void;
|
|
62
|
-
readonly __wbindgen_start: () => void;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Instantiates the given `module`, which can either be bytes or
|
|
69
|
-
* a precompiled `WebAssembly.Module`.
|
|
70
|
-
*
|
|
71
|
-
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
72
|
-
*
|
|
73
|
-
* @returns {InitOutput}
|
|
74
|
-
*/
|
|
75
|
-
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
79
|
-
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
80
|
-
*
|
|
81
|
-
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
82
|
-
*
|
|
83
|
-
* @returns {Promise<InitOutput>}
|
|
84
|
-
*/
|
|
85
|
-
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/pkg/forme.js
CHANGED
|
@@ -1,479 +1,9 @@
|
|
|
1
1
|
/* @ts-self-types="./forme.d.ts" */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const ptr0 = passArray8ToWasm0(pdf_bytes, wasm.__wbindgen_malloc);
|
|
11
|
-
const len0 = WASM_VECTOR_LEN;
|
|
12
|
-
const ptr1 = passStringToWasm0(config_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
13
|
-
const len1 = WASM_VECTOR_LEN;
|
|
14
|
-
const ret = wasm.certify_pdf(ptr0, len0, ptr1, len1);
|
|
15
|
-
if (ret[3]) {
|
|
16
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
17
|
-
}
|
|
18
|
-
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
19
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
20
|
-
return v3;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Find text regions matching patterns in a PDF.
|
|
25
|
-
* Returns JSON string of Vec<RedactionRegion>.
|
|
26
|
-
* @param {Uint8Array} pdf_bytes
|
|
27
|
-
* @param {string} patterns_json
|
|
28
|
-
* @returns {string}
|
|
29
|
-
*/
|
|
30
|
-
export function find_text_regions(pdf_bytes, patterns_json) {
|
|
31
|
-
let deferred4_0;
|
|
32
|
-
let deferred4_1;
|
|
33
|
-
try {
|
|
34
|
-
const ptr0 = passArray8ToWasm0(pdf_bytes, wasm.__wbindgen_malloc);
|
|
35
|
-
const len0 = WASM_VECTOR_LEN;
|
|
36
|
-
const ptr1 = passStringToWasm0(patterns_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
37
|
-
const len1 = WASM_VECTOR_LEN;
|
|
38
|
-
const ret = wasm.find_text_regions(ptr0, len0, ptr1, len1);
|
|
39
|
-
var ptr3 = ret[0];
|
|
40
|
-
var len3 = ret[1];
|
|
41
|
-
if (ret[3]) {
|
|
42
|
-
ptr3 = 0; len3 = 0;
|
|
43
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
44
|
-
}
|
|
45
|
-
deferred4_0 = ptr3;
|
|
46
|
-
deferred4_1 = len3;
|
|
47
|
-
return getStringFromWasm0(ptr3, len3);
|
|
48
|
-
} finally {
|
|
49
|
-
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function init_panic_hook() {
|
|
54
|
-
wasm.init_panic_hook();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Merge multiple PDFs into a single document.
|
|
59
|
-
* Accepts a JSON array of base64-encoded PDF strings.
|
|
60
|
-
* @param {string} pdfs_json
|
|
61
|
-
* @returns {Uint8Array}
|
|
62
|
-
*/
|
|
63
|
-
export function merge_pdfs(pdfs_json) {
|
|
64
|
-
const ptr0 = passStringToWasm0(pdfs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
65
|
-
const len0 = WASM_VECTOR_LEN;
|
|
66
|
-
const ret = wasm.merge_pdfs(ptr0, len0);
|
|
67
|
-
if (ret[3]) {
|
|
68
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
69
|
-
}
|
|
70
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
71
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
72
|
-
return v2;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Redact regions of a PDF by overlaying opaque rectangles.
|
|
77
|
-
* @param {Uint8Array} pdf_bytes
|
|
78
|
-
* @param {string} redactions_json
|
|
79
|
-
* @returns {Uint8Array}
|
|
80
|
-
*/
|
|
81
|
-
export function redact_pdf(pdf_bytes, redactions_json) {
|
|
82
|
-
const ptr0 = passArray8ToWasm0(pdf_bytes, wasm.__wbindgen_malloc);
|
|
83
|
-
const len0 = WASM_VECTOR_LEN;
|
|
84
|
-
const ptr1 = passStringToWasm0(redactions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
85
|
-
const len1 = WASM_VECTOR_LEN;
|
|
86
|
-
const ret = wasm.redact_pdf(ptr0, len0, ptr1, len1);
|
|
87
|
-
if (ret[3]) {
|
|
88
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
89
|
-
}
|
|
90
|
-
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
91
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
92
|
-
return v3;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Redact text matching patterns from a PDF.
|
|
97
|
-
* @param {Uint8Array} pdf_bytes
|
|
98
|
-
* @param {string} patterns_json
|
|
99
|
-
* @returns {Uint8Array}
|
|
100
|
-
*/
|
|
101
|
-
export function redact_text(pdf_bytes, patterns_json) {
|
|
102
|
-
const ptr0 = passArray8ToWasm0(pdf_bytes, wasm.__wbindgen_malloc);
|
|
103
|
-
const len0 = WASM_VECTOR_LEN;
|
|
104
|
-
const ptr1 = passStringToWasm0(patterns_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
105
|
-
const len1 = WASM_VECTOR_LEN;
|
|
106
|
-
const ret = wasm.redact_text(ptr0, len0, ptr1, len1);
|
|
107
|
-
if (ret[3]) {
|
|
108
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
109
|
-
}
|
|
110
|
-
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
111
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
112
|
-
return v3;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* @param {string} json
|
|
117
|
-
* @returns {Uint8Array}
|
|
118
|
-
*/
|
|
119
|
-
export function render_pdf(json) {
|
|
120
|
-
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
121
|
-
const len0 = WASM_VECTOR_LEN;
|
|
122
|
-
const ret = wasm.render_pdf(ptr0, len0);
|
|
123
|
-
if (ret[3]) {
|
|
124
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
125
|
-
}
|
|
126
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
127
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
128
|
-
return v2;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* @param {string} json
|
|
133
|
-
* @returns {any}
|
|
134
|
-
*/
|
|
135
|
-
export function render_pdf_with_layout(json) {
|
|
136
|
-
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
137
|
-
const len0 = WASM_VECTOR_LEN;
|
|
138
|
-
const ret = wasm.render_pdf_with_layout(ptr0, len0);
|
|
139
|
-
if (ret[2]) {
|
|
140
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
141
|
-
}
|
|
142
|
-
return takeFromExternrefTable0(ret[0]);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @param {string} template_json
|
|
147
|
-
* @param {string} data_json
|
|
148
|
-
* @returns {Uint8Array}
|
|
149
|
-
*/
|
|
150
|
-
export function render_template_pdf(template_json, data_json) {
|
|
151
|
-
const ptr0 = passStringToWasm0(template_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
152
|
-
const len0 = WASM_VECTOR_LEN;
|
|
153
|
-
const ptr1 = passStringToWasm0(data_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
154
|
-
const len1 = WASM_VECTOR_LEN;
|
|
155
|
-
const ret = wasm.render_template_pdf(ptr0, len0, ptr1, len1);
|
|
156
|
-
if (ret[3]) {
|
|
157
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
158
|
-
}
|
|
159
|
-
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
160
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
161
|
-
return v3;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* @param {string} template_json
|
|
166
|
-
* @param {string} data_json
|
|
167
|
-
* @returns {any}
|
|
168
|
-
*/
|
|
169
|
-
export function render_template_pdf_with_layout(template_json, data_json) {
|
|
170
|
-
const ptr0 = passStringToWasm0(template_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
171
|
-
const len0 = WASM_VECTOR_LEN;
|
|
172
|
-
const ptr1 = passStringToWasm0(data_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
173
|
-
const len1 = WASM_VECTOR_LEN;
|
|
174
|
-
const ret = wasm.render_template_pdf_with_layout(ptr0, len0, ptr1, len1);
|
|
175
|
-
if (ret[2]) {
|
|
176
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
177
|
-
}
|
|
178
|
-
return takeFromExternrefTable0(ret[0]);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function __wbg_get_imports() {
|
|
182
|
-
const import0 = {
|
|
183
|
-
__proto__: null,
|
|
184
|
-
__wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
|
|
185
|
-
const ret = String(arg1);
|
|
186
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
187
|
-
const len1 = WASM_VECTOR_LEN;
|
|
188
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
189
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
190
|
-
},
|
|
191
|
-
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
192
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
193
|
-
},
|
|
194
|
-
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
195
|
-
let deferred0_0;
|
|
196
|
-
let deferred0_1;
|
|
197
|
-
try {
|
|
198
|
-
deferred0_0 = arg0;
|
|
199
|
-
deferred0_1 = arg1;
|
|
200
|
-
console.error(getStringFromWasm0(arg0, arg1));
|
|
201
|
-
} finally {
|
|
202
|
-
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
__wbg_new_361308b2356cecd0: function() {
|
|
206
|
-
const ret = new Object();
|
|
207
|
-
return ret;
|
|
208
|
-
},
|
|
209
|
-
__wbg_new_3eb36ae241fe6f44: function() {
|
|
210
|
-
const ret = new Array();
|
|
211
|
-
return ret;
|
|
212
|
-
},
|
|
213
|
-
__wbg_new_8a6f238a6ece86ea: function() {
|
|
214
|
-
const ret = new Error();
|
|
215
|
-
return ret;
|
|
216
|
-
},
|
|
217
|
-
__wbg_new_from_slice_a3d2629dc1826784: function(arg0, arg1) {
|
|
218
|
-
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
219
|
-
return ret;
|
|
220
|
-
},
|
|
221
|
-
__wbg_now_a3af9a2f4bbaa4d1: function() {
|
|
222
|
-
const ret = Date.now();
|
|
223
|
-
return ret;
|
|
224
|
-
},
|
|
225
|
-
__wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
|
|
226
|
-
arg0[arg1] = arg2;
|
|
227
|
-
},
|
|
228
|
-
__wbg_set_6cb8631f80447a67: function() { return handleError(function (arg0, arg1, arg2) {
|
|
229
|
-
const ret = Reflect.set(arg0, arg1, arg2);
|
|
230
|
-
return ret;
|
|
231
|
-
}, arguments); },
|
|
232
|
-
__wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
|
|
233
|
-
arg0[arg1 >>> 0] = arg2;
|
|
234
|
-
},
|
|
235
|
-
__wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
|
|
236
|
-
const ret = arg1.stack;
|
|
237
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
238
|
-
const len1 = WASM_VECTOR_LEN;
|
|
239
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
240
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
241
|
-
},
|
|
242
|
-
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
243
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
244
|
-
const ret = arg0;
|
|
245
|
-
return ret;
|
|
246
|
-
},
|
|
247
|
-
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
248
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
249
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
250
|
-
return ret;
|
|
251
|
-
},
|
|
252
|
-
__wbindgen_init_externref_table: function() {
|
|
253
|
-
const table = wasm.__wbindgen_externrefs;
|
|
254
|
-
const offset = table.grow(4);
|
|
255
|
-
table.set(0, undefined);
|
|
256
|
-
table.set(offset + 0, undefined);
|
|
257
|
-
table.set(offset + 1, null);
|
|
258
|
-
table.set(offset + 2, true);
|
|
259
|
-
table.set(offset + 3, false);
|
|
260
|
-
},
|
|
261
|
-
};
|
|
262
|
-
return {
|
|
263
|
-
__proto__: null,
|
|
264
|
-
"./forme_bg.js": import0,
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function addToExternrefTable0(obj) {
|
|
269
|
-
const idx = wasm.__externref_table_alloc();
|
|
270
|
-
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
271
|
-
return idx;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
275
|
-
ptr = ptr >>> 0;
|
|
276
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
let cachedDataViewMemory0 = null;
|
|
280
|
-
function getDataViewMemory0() {
|
|
281
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
282
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
283
|
-
}
|
|
284
|
-
return cachedDataViewMemory0;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function getStringFromWasm0(ptr, len) {
|
|
288
|
-
ptr = ptr >>> 0;
|
|
289
|
-
return decodeText(ptr, len);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
let cachedUint8ArrayMemory0 = null;
|
|
293
|
-
function getUint8ArrayMemory0() {
|
|
294
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
295
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
296
|
-
}
|
|
297
|
-
return cachedUint8ArrayMemory0;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
function handleError(f, args) {
|
|
301
|
-
try {
|
|
302
|
-
return f.apply(this, args);
|
|
303
|
-
} catch (e) {
|
|
304
|
-
const idx = addToExternrefTable0(e);
|
|
305
|
-
wasm.__wbindgen_exn_store(idx);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
310
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
311
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
312
|
-
WASM_VECTOR_LEN = arg.length;
|
|
313
|
-
return ptr;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
317
|
-
if (realloc === undefined) {
|
|
318
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
319
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
320
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
321
|
-
WASM_VECTOR_LEN = buf.length;
|
|
322
|
-
return ptr;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
let len = arg.length;
|
|
326
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
327
|
-
|
|
328
|
-
const mem = getUint8ArrayMemory0();
|
|
329
|
-
|
|
330
|
-
let offset = 0;
|
|
331
|
-
|
|
332
|
-
for (; offset < len; offset++) {
|
|
333
|
-
const code = arg.charCodeAt(offset);
|
|
334
|
-
if (code > 0x7F) break;
|
|
335
|
-
mem[ptr + offset] = code;
|
|
336
|
-
}
|
|
337
|
-
if (offset !== len) {
|
|
338
|
-
if (offset !== 0) {
|
|
339
|
-
arg = arg.slice(offset);
|
|
340
|
-
}
|
|
341
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
342
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
343
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
344
|
-
|
|
345
|
-
offset += ret.written;
|
|
346
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
WASM_VECTOR_LEN = offset;
|
|
350
|
-
return ptr;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
function takeFromExternrefTable0(idx) {
|
|
354
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
355
|
-
wasm.__externref_table_dealloc(idx);
|
|
356
|
-
return value;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
360
|
-
cachedTextDecoder.decode();
|
|
361
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
362
|
-
let numBytesDecoded = 0;
|
|
363
|
-
function decodeText(ptr, len) {
|
|
364
|
-
numBytesDecoded += len;
|
|
365
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
366
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
367
|
-
cachedTextDecoder.decode();
|
|
368
|
-
numBytesDecoded = len;
|
|
369
|
-
}
|
|
370
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
const cachedTextEncoder = new TextEncoder();
|
|
374
|
-
|
|
375
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
376
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
377
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
378
|
-
view.set(buf);
|
|
379
|
-
return {
|
|
380
|
-
read: arg.length,
|
|
381
|
-
written: buf.length
|
|
382
|
-
};
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
let WASM_VECTOR_LEN = 0;
|
|
387
|
-
|
|
388
|
-
let wasmModule, wasm;
|
|
389
|
-
function __wbg_finalize_init(instance, module) {
|
|
390
|
-
wasm = instance.exports;
|
|
391
|
-
wasmModule = module;
|
|
392
|
-
cachedDataViewMemory0 = null;
|
|
393
|
-
cachedUint8ArrayMemory0 = null;
|
|
394
|
-
wasm.__wbindgen_start();
|
|
395
|
-
return wasm;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
async function __wbg_load(module, imports) {
|
|
399
|
-
if (typeof Response === 'function' && module instanceof Response) {
|
|
400
|
-
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
401
|
-
try {
|
|
402
|
-
return await WebAssembly.instantiateStreaming(module, imports);
|
|
403
|
-
} catch (e) {
|
|
404
|
-
const validResponse = module.ok && expectedResponseType(module.type);
|
|
405
|
-
|
|
406
|
-
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
407
|
-
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
408
|
-
|
|
409
|
-
} else { throw e; }
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
const bytes = await module.arrayBuffer();
|
|
414
|
-
return await WebAssembly.instantiate(bytes, imports);
|
|
415
|
-
} else {
|
|
416
|
-
const instance = await WebAssembly.instantiate(module, imports);
|
|
417
|
-
|
|
418
|
-
if (instance instanceof WebAssembly.Instance) {
|
|
419
|
-
return { instance, module };
|
|
420
|
-
} else {
|
|
421
|
-
return instance;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
function expectedResponseType(type) {
|
|
426
|
-
switch (type) {
|
|
427
|
-
case 'basic': case 'cors': case 'default': return true;
|
|
428
|
-
}
|
|
429
|
-
return false;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
function initSync(module) {
|
|
434
|
-
if (wasm !== undefined) return wasm;
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
if (module !== undefined) {
|
|
438
|
-
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
439
|
-
({module} = module)
|
|
440
|
-
} else {
|
|
441
|
-
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
const imports = __wbg_get_imports();
|
|
446
|
-
if (!(module instanceof WebAssembly.Module)) {
|
|
447
|
-
module = new WebAssembly.Module(module);
|
|
448
|
-
}
|
|
449
|
-
const instance = new WebAssembly.Instance(module, imports);
|
|
450
|
-
return __wbg_finalize_init(instance, module);
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
async function __wbg_init(module_or_path) {
|
|
454
|
-
if (wasm !== undefined) return wasm;
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
if (module_or_path !== undefined) {
|
|
458
|
-
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
459
|
-
({module_or_path} = module_or_path)
|
|
460
|
-
} else {
|
|
461
|
-
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
if (module_or_path === undefined) {
|
|
466
|
-
module_or_path = new URL('forme_bg.wasm', import.meta.url);
|
|
467
|
-
}
|
|
468
|
-
const imports = __wbg_get_imports();
|
|
469
|
-
|
|
470
|
-
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
471
|
-
module_or_path = fetch(module_or_path);
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
475
|
-
|
|
476
|
-
return __wbg_finalize_init(instance, module);
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
export { initSync, __wbg_init as default };
|
|
3
|
+
import * as wasm from "./forme_bg.wasm";
|
|
4
|
+
import { __wbg_set_wasm } from "./forme_bg.js";
|
|
5
|
+
__wbg_set_wasm(wasm);
|
|
6
|
+
wasm.__wbindgen_start();
|
|
7
|
+
export {
|
|
8
|
+
certify_pdf, find_text_regions, init_panic_hook, merge_pdfs, redact_pdf, redact_text, render_pdf, render_pdf_with_layout, render_template_pdf, render_template_pdf_with_layout
|
|
9
|
+
} from "./forme_bg.js";
|
package/pkg/forme_bg.js
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Certify PDF bytes with an X.509 certificate (PKCS#7 detached signature).
|
|
3
|
+
* @param {Uint8Array} pdf_bytes
|
|
4
|
+
* @param {string} config_json
|
|
5
|
+
* @returns {Uint8Array}
|
|
6
|
+
*/
|
|
7
|
+
export function certify_pdf(pdf_bytes, config_json) {
|
|
8
|
+
const ptr0 = passArray8ToWasm0(pdf_bytes, wasm.__wbindgen_malloc);
|
|
9
|
+
const len0 = WASM_VECTOR_LEN;
|
|
10
|
+
const ptr1 = passStringToWasm0(config_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
11
|
+
const len1 = WASM_VECTOR_LEN;
|
|
12
|
+
const ret = wasm.certify_pdf(ptr0, len0, ptr1, len1);
|
|
13
|
+
if (ret[3]) {
|
|
14
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
15
|
+
}
|
|
16
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
17
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
18
|
+
return v3;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Find text regions matching patterns in a PDF.
|
|
23
|
+
* Returns JSON string of Vec<RedactionRegion>.
|
|
24
|
+
* @param {Uint8Array} pdf_bytes
|
|
25
|
+
* @param {string} patterns_json
|
|
26
|
+
* @returns {string}
|
|
27
|
+
*/
|
|
28
|
+
export function find_text_regions(pdf_bytes, patterns_json) {
|
|
29
|
+
let deferred4_0;
|
|
30
|
+
let deferred4_1;
|
|
31
|
+
try {
|
|
32
|
+
const ptr0 = passArray8ToWasm0(pdf_bytes, wasm.__wbindgen_malloc);
|
|
33
|
+
const len0 = WASM_VECTOR_LEN;
|
|
34
|
+
const ptr1 = passStringToWasm0(patterns_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
35
|
+
const len1 = WASM_VECTOR_LEN;
|
|
36
|
+
const ret = wasm.find_text_regions(ptr0, len0, ptr1, len1);
|
|
37
|
+
var ptr3 = ret[0];
|
|
38
|
+
var len3 = ret[1];
|
|
39
|
+
if (ret[3]) {
|
|
40
|
+
ptr3 = 0; len3 = 0;
|
|
41
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
42
|
+
}
|
|
43
|
+
deferred4_0 = ptr3;
|
|
44
|
+
deferred4_1 = len3;
|
|
45
|
+
return getStringFromWasm0(ptr3, len3);
|
|
46
|
+
} finally {
|
|
47
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function init_panic_hook() {
|
|
52
|
+
wasm.init_panic_hook();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Merge multiple PDFs into a single document.
|
|
57
|
+
* Accepts a JSON array of base64-encoded PDF strings.
|
|
58
|
+
* @param {string} pdfs_json
|
|
59
|
+
* @returns {Uint8Array}
|
|
60
|
+
*/
|
|
61
|
+
export function merge_pdfs(pdfs_json) {
|
|
62
|
+
const ptr0 = passStringToWasm0(pdfs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
63
|
+
const len0 = WASM_VECTOR_LEN;
|
|
64
|
+
const ret = wasm.merge_pdfs(ptr0, len0);
|
|
65
|
+
if (ret[3]) {
|
|
66
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
67
|
+
}
|
|
68
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
69
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
70
|
+
return v2;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Redact regions of a PDF by overlaying opaque rectangles.
|
|
75
|
+
* @param {Uint8Array} pdf_bytes
|
|
76
|
+
* @param {string} redactions_json
|
|
77
|
+
* @returns {Uint8Array}
|
|
78
|
+
*/
|
|
79
|
+
export function redact_pdf(pdf_bytes, redactions_json) {
|
|
80
|
+
const ptr0 = passArray8ToWasm0(pdf_bytes, wasm.__wbindgen_malloc);
|
|
81
|
+
const len0 = WASM_VECTOR_LEN;
|
|
82
|
+
const ptr1 = passStringToWasm0(redactions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
83
|
+
const len1 = WASM_VECTOR_LEN;
|
|
84
|
+
const ret = wasm.redact_pdf(ptr0, len0, ptr1, len1);
|
|
85
|
+
if (ret[3]) {
|
|
86
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
87
|
+
}
|
|
88
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
89
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
90
|
+
return v3;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Redact text matching patterns from a PDF.
|
|
95
|
+
* @param {Uint8Array} pdf_bytes
|
|
96
|
+
* @param {string} patterns_json
|
|
97
|
+
* @returns {Uint8Array}
|
|
98
|
+
*/
|
|
99
|
+
export function redact_text(pdf_bytes, patterns_json) {
|
|
100
|
+
const ptr0 = passArray8ToWasm0(pdf_bytes, wasm.__wbindgen_malloc);
|
|
101
|
+
const len0 = WASM_VECTOR_LEN;
|
|
102
|
+
const ptr1 = passStringToWasm0(patterns_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
103
|
+
const len1 = WASM_VECTOR_LEN;
|
|
104
|
+
const ret = wasm.redact_text(ptr0, len0, ptr1, len1);
|
|
105
|
+
if (ret[3]) {
|
|
106
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
107
|
+
}
|
|
108
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
109
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
110
|
+
return v3;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @param {string} json
|
|
115
|
+
* @returns {Uint8Array}
|
|
116
|
+
*/
|
|
117
|
+
export function render_pdf(json) {
|
|
118
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
119
|
+
const len0 = WASM_VECTOR_LEN;
|
|
120
|
+
const ret = wasm.render_pdf(ptr0, len0);
|
|
121
|
+
if (ret[3]) {
|
|
122
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
123
|
+
}
|
|
124
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
125
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
126
|
+
return v2;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @param {string} json
|
|
131
|
+
* @returns {any}
|
|
132
|
+
*/
|
|
133
|
+
export function render_pdf_with_layout(json) {
|
|
134
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
135
|
+
const len0 = WASM_VECTOR_LEN;
|
|
136
|
+
const ret = wasm.render_pdf_with_layout(ptr0, len0);
|
|
137
|
+
if (ret[2]) {
|
|
138
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
139
|
+
}
|
|
140
|
+
return takeFromExternrefTable0(ret[0]);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @param {string} template_json
|
|
145
|
+
* @param {string} data_json
|
|
146
|
+
* @returns {Uint8Array}
|
|
147
|
+
*/
|
|
148
|
+
export function render_template_pdf(template_json, data_json) {
|
|
149
|
+
const ptr0 = passStringToWasm0(template_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
150
|
+
const len0 = WASM_VECTOR_LEN;
|
|
151
|
+
const ptr1 = passStringToWasm0(data_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
152
|
+
const len1 = WASM_VECTOR_LEN;
|
|
153
|
+
const ret = wasm.render_template_pdf(ptr0, len0, ptr1, len1);
|
|
154
|
+
if (ret[3]) {
|
|
155
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
156
|
+
}
|
|
157
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
158
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
159
|
+
return v3;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @param {string} template_json
|
|
164
|
+
* @param {string} data_json
|
|
165
|
+
* @returns {any}
|
|
166
|
+
*/
|
|
167
|
+
export function render_template_pdf_with_layout(template_json, data_json) {
|
|
168
|
+
const ptr0 = passStringToWasm0(template_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
169
|
+
const len0 = WASM_VECTOR_LEN;
|
|
170
|
+
const ptr1 = passStringToWasm0(data_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
171
|
+
const len1 = WASM_VECTOR_LEN;
|
|
172
|
+
const ret = wasm.render_template_pdf_with_layout(ptr0, len0, ptr1, len1);
|
|
173
|
+
if (ret[2]) {
|
|
174
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
175
|
+
}
|
|
176
|
+
return takeFromExternrefTable0(ret[0]);
|
|
177
|
+
}
|
|
178
|
+
export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
|
|
179
|
+
const ret = String(arg1);
|
|
180
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
181
|
+
const len1 = WASM_VECTOR_LEN;
|
|
182
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
183
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
184
|
+
}
|
|
185
|
+
export function __wbg___wbindgen_throw_be289d5034ed271b(arg0, arg1) {
|
|
186
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
187
|
+
}
|
|
188
|
+
export function __wbg_error_7534b8e9a36f1ab4(arg0, arg1) {
|
|
189
|
+
let deferred0_0;
|
|
190
|
+
let deferred0_1;
|
|
191
|
+
try {
|
|
192
|
+
deferred0_0 = arg0;
|
|
193
|
+
deferred0_1 = arg1;
|
|
194
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
195
|
+
} finally {
|
|
196
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
export function __wbg_new_361308b2356cecd0() {
|
|
200
|
+
const ret = new Object();
|
|
201
|
+
return ret;
|
|
202
|
+
}
|
|
203
|
+
export function __wbg_new_3eb36ae241fe6f44() {
|
|
204
|
+
const ret = new Array();
|
|
205
|
+
return ret;
|
|
206
|
+
}
|
|
207
|
+
export function __wbg_new_8a6f238a6ece86ea() {
|
|
208
|
+
const ret = new Error();
|
|
209
|
+
return ret;
|
|
210
|
+
}
|
|
211
|
+
export function __wbg_new_from_slice_a3d2629dc1826784(arg0, arg1) {
|
|
212
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
213
|
+
return ret;
|
|
214
|
+
}
|
|
215
|
+
export function __wbg_now_a3af9a2f4bbaa4d1() {
|
|
216
|
+
const ret = Date.now();
|
|
217
|
+
return ret;
|
|
218
|
+
}
|
|
219
|
+
export function __wbg_set_3f1d0b984ed272ed(arg0, arg1, arg2) {
|
|
220
|
+
arg0[arg1] = arg2;
|
|
221
|
+
}
|
|
222
|
+
export function __wbg_set_6cb8631f80447a67() { return handleError(function (arg0, arg1, arg2) {
|
|
223
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
224
|
+
return ret;
|
|
225
|
+
}, arguments); }
|
|
226
|
+
export function __wbg_set_f43e577aea94465b(arg0, arg1, arg2) {
|
|
227
|
+
arg0[arg1 >>> 0] = arg2;
|
|
228
|
+
}
|
|
229
|
+
export function __wbg_stack_0ed75d68575b0f3c(arg0, arg1) {
|
|
230
|
+
const ret = arg1.stack;
|
|
231
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
232
|
+
const len1 = WASM_VECTOR_LEN;
|
|
233
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
234
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
235
|
+
}
|
|
236
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
237
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
238
|
+
const ret = arg0;
|
|
239
|
+
return ret;
|
|
240
|
+
}
|
|
241
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
242
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
243
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
244
|
+
return ret;
|
|
245
|
+
}
|
|
246
|
+
export function __wbindgen_init_externref_table() {
|
|
247
|
+
const table = wasm.__wbindgen_externrefs;
|
|
248
|
+
const offset = table.grow(4);
|
|
249
|
+
table.set(0, undefined);
|
|
250
|
+
table.set(offset + 0, undefined);
|
|
251
|
+
table.set(offset + 1, null);
|
|
252
|
+
table.set(offset + 2, true);
|
|
253
|
+
table.set(offset + 3, false);
|
|
254
|
+
}
|
|
255
|
+
function addToExternrefTable0(obj) {
|
|
256
|
+
const idx = wasm.__externref_table_alloc();
|
|
257
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
258
|
+
return idx;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
262
|
+
ptr = ptr >>> 0;
|
|
263
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
let cachedDataViewMemory0 = null;
|
|
267
|
+
function getDataViewMemory0() {
|
|
268
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
269
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
270
|
+
}
|
|
271
|
+
return cachedDataViewMemory0;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function getStringFromWasm0(ptr, len) {
|
|
275
|
+
ptr = ptr >>> 0;
|
|
276
|
+
return decodeText(ptr, len);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
let cachedUint8ArrayMemory0 = null;
|
|
280
|
+
function getUint8ArrayMemory0() {
|
|
281
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
282
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
283
|
+
}
|
|
284
|
+
return cachedUint8ArrayMemory0;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function handleError(f, args) {
|
|
288
|
+
try {
|
|
289
|
+
return f.apply(this, args);
|
|
290
|
+
} catch (e) {
|
|
291
|
+
const idx = addToExternrefTable0(e);
|
|
292
|
+
wasm.__wbindgen_exn_store(idx);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
297
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
298
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
299
|
+
WASM_VECTOR_LEN = arg.length;
|
|
300
|
+
return ptr;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
304
|
+
if (realloc === undefined) {
|
|
305
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
306
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
307
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
308
|
+
WASM_VECTOR_LEN = buf.length;
|
|
309
|
+
return ptr;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
let len = arg.length;
|
|
313
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
314
|
+
|
|
315
|
+
const mem = getUint8ArrayMemory0();
|
|
316
|
+
|
|
317
|
+
let offset = 0;
|
|
318
|
+
|
|
319
|
+
for (; offset < len; offset++) {
|
|
320
|
+
const code = arg.charCodeAt(offset);
|
|
321
|
+
if (code > 0x7F) break;
|
|
322
|
+
mem[ptr + offset] = code;
|
|
323
|
+
}
|
|
324
|
+
if (offset !== len) {
|
|
325
|
+
if (offset !== 0) {
|
|
326
|
+
arg = arg.slice(offset);
|
|
327
|
+
}
|
|
328
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
329
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
330
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
331
|
+
|
|
332
|
+
offset += ret.written;
|
|
333
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
WASM_VECTOR_LEN = offset;
|
|
337
|
+
return ptr;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function takeFromExternrefTable0(idx) {
|
|
341
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
342
|
+
wasm.__externref_table_dealloc(idx);
|
|
343
|
+
return value;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
347
|
+
cachedTextDecoder.decode();
|
|
348
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
349
|
+
let numBytesDecoded = 0;
|
|
350
|
+
function decodeText(ptr, len) {
|
|
351
|
+
numBytesDecoded += len;
|
|
352
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
353
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
354
|
+
cachedTextDecoder.decode();
|
|
355
|
+
numBytesDecoded = len;
|
|
356
|
+
}
|
|
357
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const cachedTextEncoder = new TextEncoder();
|
|
361
|
+
|
|
362
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
363
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
364
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
365
|
+
view.set(buf);
|
|
366
|
+
return {
|
|
367
|
+
read: arg.length,
|
|
368
|
+
written: buf.length
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
let WASM_VECTOR_LEN = 0;
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
let wasm;
|
|
377
|
+
export function __wbg_set_wasm(val) {
|
|
378
|
+
wasm = val;
|
|
379
|
+
}
|
package/pkg/forme_bg.wasm
CHANGED
|
Binary file
|
package/pkg/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "forme-pdf",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "A page-native PDF rendering engine. Layout INTO pages, not onto an infinite canvas.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.10.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"forme_bg.wasm",
|
|
13
13
|
"forme.js",
|
|
14
|
+
"forme_bg.js",
|
|
14
15
|
"forme.d.ts"
|
|
15
16
|
],
|
|
16
17
|
"main": "forme.js",
|
|
17
18
|
"homepage": "https://formepdf.com",
|
|
18
19
|
"types": "forme.d.ts",
|
|
19
20
|
"sideEffects": [
|
|
21
|
+
"./forme.js",
|
|
20
22
|
"./snippets/*"
|
|
21
23
|
],
|
|
22
24
|
"keywords": [
|