@laminapdf/wasm 0.0.0-stage → 0.2.0-alpha.3
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 +21 -2
- package/dist/lamina_pdf_base.d.ts +1268 -0
- package/dist/lamina_pdf_base.js +1718 -0
- package/dist/lamina_pdf_base.wasm +0 -0
- package/dist/lamina_pdf_extract.d.ts +1450 -0
- package/dist/lamina_pdf_extract.js +1808 -0
- package/dist/lamina_pdf_extract.wasm +0 -0
- package/dist/lamina_pdf_render_hayro.d.ts +114 -0
- package/dist/lamina_pdf_render_hayro.js +459 -0
- package/dist/lamina_pdf_render_hayro.wasm +0 -0
- package/dist/lamina_pdf_text.d.ts +1692 -0
- package/dist/lamina_pdf_text.js +1973 -0
- package/dist/lamina_pdf_text.wasm +0 -0
- package/package.json +60 -3
|
@@ -0,0 +1,1808 @@
|
|
|
1
|
+
/* @ts-self-types="./lamina_pdf_extract.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Builds a new document: pages, navigation and metadata, then [`WasmBuilder::finish`]
|
|
5
|
+
* gives a [`WasmDocument`] (unsaved; its save is a full rewrite).
|
|
6
|
+
*/
|
|
7
|
+
export class WasmBuilder {
|
|
8
|
+
__destroy_into_raw() {
|
|
9
|
+
const ptr = this.__wbg_ptr;
|
|
10
|
+
this.__wbg_ptr = 0;
|
|
11
|
+
WasmBuilderFinalization.unregister(this);
|
|
12
|
+
return ptr;
|
|
13
|
+
}
|
|
14
|
+
free() {
|
|
15
|
+
const ptr = this.__destroy_into_raw();
|
|
16
|
+
wasm.__wbg_wasmbuilder_free(ptr, 0);
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Attaches a file (`/EmbeddedFiles`, the catalog's `/AF`): `name`, its bytes and its MIME
|
|
21
|
+
* type. The same name again replaces the file.
|
|
22
|
+
*
|
|
23
|
+
* # Errors
|
|
24
|
+
* `builder-finished`; `invalid-argument` (a date that isn't a PDF date); `unknown-option`.
|
|
25
|
+
* @param {string} name
|
|
26
|
+
* @param {Uint8Array} bytes
|
|
27
|
+
* @param {string} mime
|
|
28
|
+
* @param {AttachmentInit | undefined} options
|
|
29
|
+
*/
|
|
30
|
+
attach(name, bytes, mime, options) {
|
|
31
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
32
|
+
const len0 = WASM_VECTOR_LEN;
|
|
33
|
+
const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
34
|
+
const len1 = WASM_VECTOR_LEN;
|
|
35
|
+
const ptr2 = passStringToWasm0(mime, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
36
|
+
const len2 = WASM_VECTOR_LEN;
|
|
37
|
+
let ret;
|
|
38
|
+
ret = wasm.wasmbuilder_attach(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, options);
|
|
39
|
+
if (ret[1]) {
|
|
40
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Defines the named destination `name`: page `index` shown as `fit` (default: the page).
|
|
45
|
+
*
|
|
46
|
+
* # Errors
|
|
47
|
+
* `builder-finished`; `invalid-argument` for a bad `fit`.
|
|
48
|
+
* @param {string} name
|
|
49
|
+
* @param {number} index
|
|
50
|
+
* @param {FitInit | undefined} fit
|
|
51
|
+
*/
|
|
52
|
+
destination(name, index, fit) {
|
|
53
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
54
|
+
const len0 = WASM_VECTOR_LEN;
|
|
55
|
+
let ret;
|
|
56
|
+
ret = wasm.wasmbuilder_destination(this.__wbg_ptr, ptr0, len0, index, fit);
|
|
57
|
+
if (ret[1]) {
|
|
58
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Writes the fonts, links, page tree, outline and metadata, and returns the document.
|
|
63
|
+
* The builder is finished afterwards, and so are its unfinished pages.
|
|
64
|
+
*
|
|
65
|
+
* # Errors
|
|
66
|
+
* `builder-finished`; `page-index-out-of-range`, `unknown-destination`,
|
|
67
|
+
* `invalid-page-labels`, `invalid-geometry`, `subset-failed`.
|
|
68
|
+
* @returns {WasmDocument}
|
|
69
|
+
*/
|
|
70
|
+
finish() {
|
|
71
|
+
let ret;
|
|
72
|
+
ret = wasm.wasmbuilder_finish(this.__wbg_ptr);
|
|
73
|
+
if (ret[2]) {
|
|
74
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
75
|
+
}
|
|
76
|
+
return WasmDocument.__wrap(ret[0]);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The natural language (`/Lang`), a BCP 47 tag.
|
|
80
|
+
*
|
|
81
|
+
* # Errors
|
|
82
|
+
* `builder-finished`.
|
|
83
|
+
* @param {string} lang
|
|
84
|
+
*/
|
|
85
|
+
lang(lang) {
|
|
86
|
+
const ptr0 = passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
87
|
+
const len0 = WASM_VECTOR_LEN;
|
|
88
|
+
let ret;
|
|
89
|
+
ret = wasm.wasmbuilder_lang(this.__wbg_ptr, ptr0, len0);
|
|
90
|
+
if (ret[1]) {
|
|
91
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The metadata, written as the Info dictionary and an XMP packet.
|
|
96
|
+
*
|
|
97
|
+
* # Errors
|
|
98
|
+
* `builder-finished`; `invalid-argument` (a date that isn't a PDF date).
|
|
99
|
+
* @param {MetadataInit} metadata
|
|
100
|
+
*/
|
|
101
|
+
metadata(metadata) {
|
|
102
|
+
let ret;
|
|
103
|
+
ret = wasm.wasmbuilder_metadata(this.__wbg_ptr, metadata);
|
|
104
|
+
if (ret[1]) {
|
|
105
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A builder for a new, empty document.
|
|
110
|
+
*
|
|
111
|
+
* # Errors
|
|
112
|
+
* `invalid-argument` / `unknown-option` for bad options.
|
|
113
|
+
* @param {BuildOptionsInit | undefined} options
|
|
114
|
+
*/
|
|
115
|
+
constructor(options) {
|
|
116
|
+
let ret;
|
|
117
|
+
ret = wasm.wasmbuilder_new(options);
|
|
118
|
+
if (ret[2]) {
|
|
119
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
120
|
+
}
|
|
121
|
+
this.__wbg_ptr = ret[0];
|
|
122
|
+
Object.defineProperty(this, '__wbg_inst', { value: __wbg_instance_id, writable: true });
|
|
123
|
+
WasmBuilderFinalization.register(this, { ptr: ret[0], instance: __wbg_instance_id }, this);
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Adds outline items (with their children); returns their IDs in pre-order.
|
|
128
|
+
*
|
|
129
|
+
* # Errors
|
|
130
|
+
* `builder-finished`; `invalid-argument`; `limit-exceeded`.
|
|
131
|
+
* @param {OutlineEntryInit[]} entries
|
|
132
|
+
* @returns {string[]}
|
|
133
|
+
*/
|
|
134
|
+
outline(entries) {
|
|
135
|
+
let ret;
|
|
136
|
+
ret = wasm.wasmbuilder_outline(this.__wbg_ptr, entries);
|
|
137
|
+
if (ret[2]) {
|
|
138
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
139
|
+
}
|
|
140
|
+
return takeFromExternrefTable0(ret[0]);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The page labels, ranges by first page (checked at [`WasmBuilder::finish`]).
|
|
144
|
+
*
|
|
145
|
+
* # Errors
|
|
146
|
+
* `builder-finished`; `invalid-argument`.
|
|
147
|
+
* @param {PageLabelInit[]} ranges
|
|
148
|
+
*/
|
|
149
|
+
pageLabels(ranges) {
|
|
150
|
+
let ret;
|
|
151
|
+
ret = wasm.wasmbuilder_pageLabels(this.__wbg_ptr, ranges);
|
|
152
|
+
if (ret[1]) {
|
|
153
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* A page of `width` × `height` points, written by [`WasmPageBuilder::finish`].
|
|
158
|
+
* @param {number} width
|
|
159
|
+
* @param {number} height
|
|
160
|
+
* @returns {WasmPageBuilder}
|
|
161
|
+
*/
|
|
162
|
+
page(width, height) {
|
|
163
|
+
let ret;
|
|
164
|
+
ret = wasm.wasmbuilder_page(this.__wbg_ptr, width, height);
|
|
165
|
+
return WasmPageBuilder.__wrap(ret);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* How viewers present the document when it opens.
|
|
169
|
+
*
|
|
170
|
+
* # Errors
|
|
171
|
+
* `builder-finished`; `invalid-argument`.
|
|
172
|
+
* @param {ViewerPreferencesInit} prefs
|
|
173
|
+
*/
|
|
174
|
+
viewerPreferences(prefs) {
|
|
175
|
+
let ret;
|
|
176
|
+
ret = wasm.wasmbuilder_viewerPreferences(this.__wbg_ptr, prefs);
|
|
177
|
+
if (ret[1]) {
|
|
178
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (Symbol.dispose) WasmBuilder.prototype[Symbol.dispose] = WasmBuilder.prototype.free;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* An open PDF: read it, edit it with ops (with undo), save it. The binding of
|
|
186
|
+
* `laminapdf::Document`, method for method (F12).
|
|
187
|
+
*/
|
|
188
|
+
export class WasmDocument {
|
|
189
|
+
static __wrap(ptr) {
|
|
190
|
+
const obj = Object.create(WasmDocument.prototype);
|
|
191
|
+
obj.__wbg_ptr = ptr;
|
|
192
|
+
Object.defineProperty(obj, '__wbg_inst', { value: __wbg_instance_id, writable: true });
|
|
193
|
+
|
|
194
|
+
WasmDocumentFinalization.register(obj, { ptr, instance: __wbg_instance_id }, obj);
|
|
195
|
+
return obj;
|
|
196
|
+
}
|
|
197
|
+
__destroy_into_raw() {
|
|
198
|
+
const ptr = this.__wbg_ptr;
|
|
199
|
+
this.__wbg_ptr = 0;
|
|
200
|
+
WasmDocumentFinalization.unregister(this);
|
|
201
|
+
return ptr;
|
|
202
|
+
}
|
|
203
|
+
free() {
|
|
204
|
+
const ptr = this.__destroy_into_raw();
|
|
205
|
+
wasm.__wbg_wasmdocument_free(ptr, 0);
|
|
206
|
+
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Applies an op log (`{ "v": 1, "ops": [ … ] }`) as one transaction.
|
|
210
|
+
*
|
|
211
|
+
* # Errors
|
|
212
|
+
* `invalid-op-log`, `unsupported-version`; as [`WasmDocument::apply`].
|
|
213
|
+
* @param {string} json
|
|
214
|
+
* @returns {EditedJs}
|
|
215
|
+
*/
|
|
216
|
+
applyLog(json) {
|
|
217
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
218
|
+
const len0 = WASM_VECTOR_LEN;
|
|
219
|
+
let ret;
|
|
220
|
+
ret = wasm.wasmdocument_applyLog(this.__wbg_ptr, ptr0, len0);
|
|
221
|
+
if (ret[2]) {
|
|
222
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
223
|
+
}
|
|
224
|
+
return takeFromExternrefTable0(ret[0]);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Applies `ops` (the op JSON of ADR 0006 §6) in order, as one transaction.
|
|
228
|
+
*
|
|
229
|
+
* # Errors
|
|
230
|
+
* `invalid-argument` / `unknown-option` for a value that isn't an op; the first op's
|
|
231
|
+
* error (nothing is applied).
|
|
232
|
+
* @param {Op[]} ops
|
|
233
|
+
* @returns {EditedJs}
|
|
234
|
+
*/
|
|
235
|
+
apply(ops) {
|
|
236
|
+
let ret;
|
|
237
|
+
ret = wasm.wasmdocument_apply(this.__wbg_ptr, ops);
|
|
238
|
+
if (ret[2]) {
|
|
239
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
240
|
+
}
|
|
241
|
+
return takeFromExternrefTable0(ret[0]);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* The document's text for retrieval and LLMs, as one string: Markdown, plain text, the
|
|
245
|
+
* `laminapdf.extract/1` JSON, or the chunks as a JSON array (the extract and text modules).
|
|
246
|
+
*
|
|
247
|
+
* # Errors
|
|
248
|
+
* `page-index-out-of-range` for a page in `pages` past the end; `data-pending` and the
|
|
249
|
+
* reading errors; `unknown-option` / `invalid-argument` for bad options.
|
|
250
|
+
* @param {ExtractInit} options
|
|
251
|
+
* @returns {string}
|
|
252
|
+
*/
|
|
253
|
+
extract(options) {
|
|
254
|
+
let deferred2_0;
|
|
255
|
+
let deferred2_1;
|
|
256
|
+
try {
|
|
257
|
+
let ret;
|
|
258
|
+
ret = wasm.wasmdocument_extract(this.__wbg_ptr, options);
|
|
259
|
+
var ptr1 = ret[0];
|
|
260
|
+
var len1 = ret[1];
|
|
261
|
+
if (ret[3]) {
|
|
262
|
+
ptr1 = 0; len1 = 0;
|
|
263
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
264
|
+
}
|
|
265
|
+
deferred2_0 = ptr1;
|
|
266
|
+
deferred2_1 = len1;
|
|
267
|
+
return getStringFromWasm0(ptr1, len1);
|
|
268
|
+
} finally {
|
|
269
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Whether there are changes no save has written yet.
|
|
274
|
+
* @returns {boolean}
|
|
275
|
+
*/
|
|
276
|
+
hasUnsavedChanges() {
|
|
277
|
+
let ret;
|
|
278
|
+
ret = wasm.wasmdocument_hasUnsavedChanges(this.__wbg_ptr);
|
|
279
|
+
return ret !== 0;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* The Info dictionary's text entries.
|
|
283
|
+
*
|
|
284
|
+
* # Errors
|
|
285
|
+
* Reading errors.
|
|
286
|
+
* @returns {DocumentInfoJs}
|
|
287
|
+
*/
|
|
288
|
+
info() {
|
|
289
|
+
let ret;
|
|
290
|
+
ret = wasm.wasmdocument_info(this.__wbg_ptr);
|
|
291
|
+
if (ret[2]) {
|
|
292
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
293
|
+
}
|
|
294
|
+
return takeFromExternrefTable0(ret[0]);
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Opens a document from its bytes.
|
|
298
|
+
*
|
|
299
|
+
* # Errors
|
|
300
|
+
* The §1 object: `not-pdf`, `password-required`, `wrong-password`, `limit-exceeded`, …;
|
|
301
|
+
* `invalid-argument` / `unknown-option` for bad options.
|
|
302
|
+
* @param {Uint8Array} bytes
|
|
303
|
+
* @param {OpenOptionsInit | undefined} options
|
|
304
|
+
* @returns {WasmDocument}
|
|
305
|
+
*/
|
|
306
|
+
static openBytes(bytes, options) {
|
|
307
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
308
|
+
const len0 = WASM_VECTOR_LEN;
|
|
309
|
+
let ret;
|
|
310
|
+
ret = wasm.wasmdocument_openBytes(ptr0, len0, options);
|
|
311
|
+
if (ret[2]) {
|
|
312
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
313
|
+
}
|
|
314
|
+
return WasmDocument.__wrap(ret[0]);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Opens a document over a sparse source whose bytes arrive later. Until the source holds
|
|
318
|
+
* what a call needs, the call throws `data-pending` with `data.ranges` (`[offset, length]`
|
|
319
|
+
* pairs): supply them and call again. Lazy reads on the document can do the same.
|
|
320
|
+
*
|
|
321
|
+
* # Errors
|
|
322
|
+
* As `openBytes`, and `data-pending`.
|
|
323
|
+
* @param {WasmSparseSource} source
|
|
324
|
+
* @param {OpenOptionsInit | undefined} options
|
|
325
|
+
* @returns {WasmDocument}
|
|
326
|
+
*/
|
|
327
|
+
static openSource(source, options) {
|
|
328
|
+
_assertClass(source, WasmSparseSource);
|
|
329
|
+
let ret;
|
|
330
|
+
ret = wasm.wasmdocument_openSource(source.__wbg_ptr, options);
|
|
331
|
+
if (ret[2]) {
|
|
332
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
333
|
+
}
|
|
334
|
+
return WasmDocument.__wrap(ret[0]);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* A handle on the page with `id` (`p12.0`).
|
|
338
|
+
*
|
|
339
|
+
* # Errors
|
|
340
|
+
* `invalid-argument` for a malformed ID; `unknown-page`.
|
|
341
|
+
* @param {string} id
|
|
342
|
+
* @returns {WasmPage}
|
|
343
|
+
*/
|
|
344
|
+
pageById(id) {
|
|
345
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
346
|
+
const len0 = WASM_VECTOR_LEN;
|
|
347
|
+
let ret;
|
|
348
|
+
ret = wasm.wasmdocument_pageById(this.__wbg_ptr, ptr0, len0);
|
|
349
|
+
if (ret[2]) {
|
|
350
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
351
|
+
}
|
|
352
|
+
return WasmPage.__wrap(ret[0]);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* The number of pages.
|
|
356
|
+
*
|
|
357
|
+
* # Errors
|
|
358
|
+
* Reading errors.
|
|
359
|
+
* @returns {number}
|
|
360
|
+
*/
|
|
361
|
+
pageCount() {
|
|
362
|
+
let ret;
|
|
363
|
+
ret = wasm.wasmdocument_pageCount(this.__wbg_ptr);
|
|
364
|
+
if (ret[2]) {
|
|
365
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
366
|
+
}
|
|
367
|
+
return ret[0] >>> 0;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Page `index`'s facts.
|
|
371
|
+
*
|
|
372
|
+
* # Errors
|
|
373
|
+
* `page-index-out-of-range`; reading errors.
|
|
374
|
+
* @param {number} index
|
|
375
|
+
* @returns {PageInfoJs}
|
|
376
|
+
*/
|
|
377
|
+
pageInfo(index) {
|
|
378
|
+
let ret;
|
|
379
|
+
ret = wasm.wasmdocument_pageInfo(this.__wbg_ptr, index);
|
|
380
|
+
if (ret[2]) {
|
|
381
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
382
|
+
}
|
|
383
|
+
return takeFromExternrefTable0(ret[0]);
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Every page's facts, in order (one page-tree walk).
|
|
387
|
+
*
|
|
388
|
+
* # Errors
|
|
389
|
+
* Reading errors.
|
|
390
|
+
* @returns {PageInfoJs[]}
|
|
391
|
+
*/
|
|
392
|
+
pageInfos() {
|
|
393
|
+
let ret;
|
|
394
|
+
ret = wasm.wasmdocument_pageInfos(this.__wbg_ptr);
|
|
395
|
+
if (ret[2]) {
|
|
396
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
397
|
+
}
|
|
398
|
+
return takeFromExternrefTable0(ret[0]);
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* A handle on page `index` that follows the page by its ID (F2).
|
|
402
|
+
*
|
|
403
|
+
* # Errors
|
|
404
|
+
* `page-index-out-of-range`; reading errors.
|
|
405
|
+
* @param {number} index
|
|
406
|
+
* @returns {WasmPage}
|
|
407
|
+
*/
|
|
408
|
+
page(index) {
|
|
409
|
+
let ret;
|
|
410
|
+
ret = wasm.wasmdocument_page(this.__wbg_ptr, index);
|
|
411
|
+
if (ret[2]) {
|
|
412
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
413
|
+
}
|
|
414
|
+
return WasmPage.__wrap(ret[0]);
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Rebases onto `bytes`, the output of a save whose rebase failed (`not-rebased`).
|
|
418
|
+
*
|
|
419
|
+
* # Errors
|
|
420
|
+
* `no-pending-save`; reading errors in `bytes`.
|
|
421
|
+
* @param {Uint8Array} bytes
|
|
422
|
+
*/
|
|
423
|
+
rebase(bytes) {
|
|
424
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
425
|
+
const len0 = WASM_VECTOR_LEN;
|
|
426
|
+
let ret;
|
|
427
|
+
ret = wasm.wasmdocument_rebase(this.__wbg_ptr, ptr0, len0);
|
|
428
|
+
if (ret[1]) {
|
|
429
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Redoes the newest undone transaction; `undefined` when there is nothing to redo.
|
|
434
|
+
*
|
|
435
|
+
* # Errors
|
|
436
|
+
* As [`WasmDocument::undo`].
|
|
437
|
+
* @returns {UndoOutcomeJs | undefined}
|
|
438
|
+
*/
|
|
439
|
+
redo() {
|
|
440
|
+
let ret;
|
|
441
|
+
ret = wasm.wasmdocument_redo(this.__wbg_ptr);
|
|
442
|
+
if (ret[2]) {
|
|
443
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
444
|
+
}
|
|
445
|
+
return takeFromExternrefTable0(ret[0]);
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* A save as a job, stepped with a budget of work units (ADR 0028 §3, §4).
|
|
449
|
+
*
|
|
450
|
+
* # Errors
|
|
451
|
+
* `invalid-argument` / `unknown-option` for bad options.
|
|
452
|
+
* @param {SaveOptionsInit | undefined} options
|
|
453
|
+
* @returns {WasmSaveJob}
|
|
454
|
+
*/
|
|
455
|
+
saveJob(options) {
|
|
456
|
+
let ret;
|
|
457
|
+
ret = wasm.wasmdocument_saveJob(this.__wbg_ptr, options);
|
|
458
|
+
if (ret[2]) {
|
|
459
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
460
|
+
}
|
|
461
|
+
return WasmSaveJob.__wrap(ret[0]);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Saves and rebases onto the output, running to completion: `{ bytes, report }`.
|
|
465
|
+
*
|
|
466
|
+
* # Errors
|
|
467
|
+
* The save's errors (`would-invalidate-signatures`, `requires-rewrite`, …).
|
|
468
|
+
* @param {SaveOptionsInit | undefined} options
|
|
469
|
+
* @returns {{ bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs }}
|
|
470
|
+
*/
|
|
471
|
+
save(options) {
|
|
472
|
+
let ret;
|
|
473
|
+
ret = wasm.wasmdocument_save(this.__wbg_ptr, options);
|
|
474
|
+
if (ret[2]) {
|
|
475
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
476
|
+
}
|
|
477
|
+
return takeFromExternrefTable0(ret[0]);
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Undoes the newest transaction; `undefined` when there is nothing to undo.
|
|
481
|
+
*
|
|
482
|
+
* # Errors
|
|
483
|
+
* `nested-transaction`, `saved-not-rebased`; reading errors.
|
|
484
|
+
* @returns {UndoOutcomeJs | undefined}
|
|
485
|
+
*/
|
|
486
|
+
undo() {
|
|
487
|
+
let ret;
|
|
488
|
+
ret = wasm.wasmdocument_undo(this.__wbg_ptr);
|
|
489
|
+
if (ret[2]) {
|
|
490
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
491
|
+
}
|
|
492
|
+
return takeFromExternrefTable0(ret[0]);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* A cursor over the warnings so far (build warnings first), each as the §1 object.
|
|
496
|
+
* @returns {WasmWarningCursor}
|
|
497
|
+
*/
|
|
498
|
+
warnings() {
|
|
499
|
+
let ret;
|
|
500
|
+
ret = wasm.wasmdocument_warnings(this.__wbg_ptr);
|
|
501
|
+
return WasmWarningCursor.__wrap(ret);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (Symbol.dispose) WasmDocument.prototype[Symbol.dispose] = WasmDocument.prototype.free;
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* An image to draw (decoded or passed through once, shared by every use).
|
|
508
|
+
*/
|
|
509
|
+
export class WasmImage {
|
|
510
|
+
static __wrap(ptr) {
|
|
511
|
+
const obj = Object.create(WasmImage.prototype);
|
|
512
|
+
obj.__wbg_ptr = ptr;
|
|
513
|
+
Object.defineProperty(obj, '__wbg_inst', { value: __wbg_instance_id, writable: true });
|
|
514
|
+
|
|
515
|
+
WasmImageFinalization.register(obj, { ptr, instance: __wbg_instance_id }, obj);
|
|
516
|
+
return obj;
|
|
517
|
+
}
|
|
518
|
+
__destroy_into_raw() {
|
|
519
|
+
const ptr = this.__wbg_ptr;
|
|
520
|
+
this.__wbg_ptr = 0;
|
|
521
|
+
WasmImageFinalization.unregister(this);
|
|
522
|
+
return ptr;
|
|
523
|
+
}
|
|
524
|
+
free() {
|
|
525
|
+
const ptr = this.__destroy_into_raw();
|
|
526
|
+
wasm.__wbg_wasmimage_free(ptr, 0);
|
|
527
|
+
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Height in pixels.
|
|
531
|
+
* @returns {number}
|
|
532
|
+
*/
|
|
533
|
+
get height() {
|
|
534
|
+
let ret;
|
|
535
|
+
ret = wasm.wasmimage_height(this.__wbg_ptr);
|
|
536
|
+
return ret >>> 0;
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* A JPEG, passed through (`DCTDecode`).
|
|
540
|
+
*
|
|
541
|
+
* # Errors
|
|
542
|
+
* `invalid-image`, `unsupported-image`.
|
|
543
|
+
* @param {Uint8Array} bytes
|
|
544
|
+
* @returns {WasmImage}
|
|
545
|
+
*/
|
|
546
|
+
static jpeg(bytes) {
|
|
547
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
548
|
+
const len0 = WASM_VECTOR_LEN;
|
|
549
|
+
let ret;
|
|
550
|
+
ret = wasm.wasmimage_jpeg(ptr0, len0);
|
|
551
|
+
if (ret[2]) {
|
|
552
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
553
|
+
}
|
|
554
|
+
return WasmImage.__wrap(ret[0]);
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* A PNG (alpha as an `/SMask`).
|
|
558
|
+
*
|
|
559
|
+
* # Errors
|
|
560
|
+
* `invalid-image`, `unsupported-image`, `image-too-large`.
|
|
561
|
+
* @param {Uint8Array} bytes
|
|
562
|
+
* @returns {WasmImage}
|
|
563
|
+
*/
|
|
564
|
+
static png(bytes) {
|
|
565
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
566
|
+
const len0 = WASM_VECTOR_LEN;
|
|
567
|
+
let ret;
|
|
568
|
+
ret = wasm.wasmimage_png(ptr0, len0);
|
|
569
|
+
if (ret[2]) {
|
|
570
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
571
|
+
}
|
|
572
|
+
return WasmImage.__wrap(ret[0]);
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Raw 8-bit RGBA pixels, row by row.
|
|
576
|
+
*
|
|
577
|
+
* # Errors
|
|
578
|
+
* `invalid-image` when the length isn't `width × height × 4`.
|
|
579
|
+
* @param {number} width
|
|
580
|
+
* @param {number} height
|
|
581
|
+
* @param {Uint8Array} rgba
|
|
582
|
+
* @returns {WasmImage}
|
|
583
|
+
*/
|
|
584
|
+
static rgba(width, height, rgba) {
|
|
585
|
+
const ptr0 = passArray8ToWasm0(rgba, wasm.__wbindgen_malloc);
|
|
586
|
+
const len0 = WASM_VECTOR_LEN;
|
|
587
|
+
let ret;
|
|
588
|
+
ret = wasm.wasmimage_rgba(width, height, ptr0, len0);
|
|
589
|
+
if (ret[2]) {
|
|
590
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
591
|
+
}
|
|
592
|
+
return WasmImage.__wrap(ret[0]);
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Width in pixels.
|
|
596
|
+
* @returns {number}
|
|
597
|
+
*/
|
|
598
|
+
get width() {
|
|
599
|
+
let ret;
|
|
600
|
+
ret = wasm.wasmimage_width(this.__wbg_ptr);
|
|
601
|
+
return ret >>> 0;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
if (Symbol.dispose) WasmImage.prototype[Symbol.dispose] = WasmImage.prototype.free;
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* A page of a [`WasmDocument`], held by its ID (F2): moving pages doesn't retarget it.
|
|
608
|
+
*/
|
|
609
|
+
export class WasmPage {
|
|
610
|
+
static __wrap(ptr) {
|
|
611
|
+
const obj = Object.create(WasmPage.prototype);
|
|
612
|
+
obj.__wbg_ptr = ptr;
|
|
613
|
+
Object.defineProperty(obj, '__wbg_inst', { value: __wbg_instance_id, writable: true });
|
|
614
|
+
|
|
615
|
+
WasmPageFinalization.register(obj, { ptr, instance: __wbg_instance_id }, obj);
|
|
616
|
+
return obj;
|
|
617
|
+
}
|
|
618
|
+
__destroy_into_raw() {
|
|
619
|
+
const ptr = this.__wbg_ptr;
|
|
620
|
+
this.__wbg_ptr = 0;
|
|
621
|
+
WasmPageFinalization.unregister(this);
|
|
622
|
+
return ptr;
|
|
623
|
+
}
|
|
624
|
+
free() {
|
|
625
|
+
const ptr = this.__destroy_into_raw();
|
|
626
|
+
wasm.__wbg_wasmpage_free(ptr, 0);
|
|
627
|
+
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* The page's stable ID (`p12.0`).
|
|
631
|
+
* @returns {string}
|
|
632
|
+
*/
|
|
633
|
+
get id() {
|
|
634
|
+
let deferred1_0;
|
|
635
|
+
let deferred1_1;
|
|
636
|
+
try {
|
|
637
|
+
let ret;
|
|
638
|
+
ret = wasm.wasmpage_id(this.__wbg_ptr);
|
|
639
|
+
deferred1_0 = ret[0];
|
|
640
|
+
deferred1_1 = ret[1];
|
|
641
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
642
|
+
} finally {
|
|
643
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* The page's current 0-based index.
|
|
648
|
+
*
|
|
649
|
+
* # Errors
|
|
650
|
+
* `unknown-page` when the page is gone; `disposed` when its document is freed; reading
|
|
651
|
+
* errors.
|
|
652
|
+
* @returns {number}
|
|
653
|
+
*/
|
|
654
|
+
index() {
|
|
655
|
+
let ret;
|
|
656
|
+
ret = wasm.wasmpage_index(this.__wbg_ptr);
|
|
657
|
+
if (ret[2]) {
|
|
658
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
659
|
+
}
|
|
660
|
+
return ret[0] >>> 0;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* The page's facts now.
|
|
664
|
+
*
|
|
665
|
+
* # Errors
|
|
666
|
+
* As [`WasmPage::index`].
|
|
667
|
+
* @returns {PageInfoJs}
|
|
668
|
+
*/
|
|
669
|
+
info() {
|
|
670
|
+
let ret;
|
|
671
|
+
ret = wasm.wasmpage_info(this.__wbg_ptr);
|
|
672
|
+
if (ret[2]) {
|
|
673
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
674
|
+
}
|
|
675
|
+
return takeFromExternrefTable0(ret[0]);
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* The page's text: lines, runs, glyph quads and glyph text (the extract and text modules).
|
|
679
|
+
*
|
|
680
|
+
* # Errors
|
|
681
|
+
* `unknown-page` when the page is gone; `disposed` when its document is freed;
|
|
682
|
+
* `data-pending` and the reading errors; `unknown-option` / `invalid-argument` for bad
|
|
683
|
+
* options.
|
|
684
|
+
* @param {TextOptionsInit | undefined} options
|
|
685
|
+
* @returns {PageTextJs}
|
|
686
|
+
*/
|
|
687
|
+
text(options) {
|
|
688
|
+
let ret;
|
|
689
|
+
ret = wasm.wasmpage_text(this.__wbg_ptr, options);
|
|
690
|
+
if (ret[2]) {
|
|
691
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
692
|
+
}
|
|
693
|
+
return takeFromExternrefTable0(ret[0]);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
if (Symbol.dispose) WasmPage.prototype[Symbol.dispose] = WasmPage.prototype.free;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* One page being drawn, in page space (points from the top-left, y down; ADR 0027).
|
|
700
|
+
* Invalid geometry is reported by [`WasmPageBuilder::finish`] (`invalid-geometry`).
|
|
701
|
+
*/
|
|
702
|
+
export class WasmPageBuilder {
|
|
703
|
+
static __wrap(ptr) {
|
|
704
|
+
const obj = Object.create(WasmPageBuilder.prototype);
|
|
705
|
+
obj.__wbg_ptr = ptr;
|
|
706
|
+
Object.defineProperty(obj, '__wbg_inst', { value: __wbg_instance_id, writable: true });
|
|
707
|
+
|
|
708
|
+
WasmPageBuilderFinalization.register(obj, { ptr, instance: __wbg_instance_id }, obj);
|
|
709
|
+
return obj;
|
|
710
|
+
}
|
|
711
|
+
__destroy_into_raw() {
|
|
712
|
+
const ptr = this.__wbg_ptr;
|
|
713
|
+
this.__wbg_ptr = 0;
|
|
714
|
+
WasmPageBuilderFinalization.unregister(this);
|
|
715
|
+
return ptr;
|
|
716
|
+
}
|
|
717
|
+
free() {
|
|
718
|
+
const ptr = this.__destroy_into_raw();
|
|
719
|
+
wasm.__wbg_wasmpagebuilder_free(ptr, 0);
|
|
720
|
+
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Opens an artifact until the matching `endTag`: `kind` is `layout`, `page`, `pagination`
|
|
724
|
+
* or `background`.
|
|
725
|
+
*
|
|
726
|
+
* # Errors
|
|
727
|
+
* `invalid-argument` for another kind.
|
|
728
|
+
* @param {string} kind
|
|
729
|
+
*/
|
|
730
|
+
beginArtifact(kind) {
|
|
731
|
+
const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
732
|
+
const len0 = WASM_VECTOR_LEN;
|
|
733
|
+
let ret;
|
|
734
|
+
ret = wasm.wasmpagebuilder_beginArtifact(this.__wbg_ptr, ptr0, len0);
|
|
735
|
+
if (ret[1]) {
|
|
736
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Opens a structure element until the matching `endTag`: `kind` names a standard type
|
|
741
|
+
* (`Document`, `Part`, `Sect`, `H1`–`H6`, `P`, `L`, `LI`, `Lbl`, `LBody`, `Table`, `TR`,
|
|
742
|
+
* `TH`, `TD`, `Figure`, `Caption`, `Link`, `Span`, `Quote`, `Note`, `Code`), the role of
|
|
743
|
+
* `custom` when given; `/Alt`, `/ActualText`, `/Lang`, `/E`; `scope` is `row`, `column` or
|
|
744
|
+
* `both` when given.
|
|
745
|
+
*
|
|
746
|
+
* # Errors
|
|
747
|
+
* `invalid-argument` for an unknown `kind` or `scope`.
|
|
748
|
+
* @param {string} kind
|
|
749
|
+
* @param {string | null} [custom]
|
|
750
|
+
* @param {string | null} [alt]
|
|
751
|
+
* @param {string | null} [actualText]
|
|
752
|
+
* @param {string | null} [lang]
|
|
753
|
+
* @param {string | null} [expansion]
|
|
754
|
+
* @param {string | null} [scope]
|
|
755
|
+
*/
|
|
756
|
+
beginTag(kind, custom, alt, actualText, lang, expansion, scope) {
|
|
757
|
+
const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
758
|
+
const len0 = WASM_VECTOR_LEN;
|
|
759
|
+
var ptr1 = isLikeNone(custom) ? 0 : passStringToWasm0(custom, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
760
|
+
var len1 = WASM_VECTOR_LEN;
|
|
761
|
+
var ptr2 = isLikeNone(alt) ? 0 : passStringToWasm0(alt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
762
|
+
var len2 = WASM_VECTOR_LEN;
|
|
763
|
+
var ptr3 = isLikeNone(actualText) ? 0 : passStringToWasm0(actualText, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
764
|
+
var len3 = WASM_VECTOR_LEN;
|
|
765
|
+
var ptr4 = isLikeNone(lang) ? 0 : passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
766
|
+
var len4 = WASM_VECTOR_LEN;
|
|
767
|
+
var ptr5 = isLikeNone(expansion) ? 0 : passStringToWasm0(expansion, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
768
|
+
var len5 = WASM_VECTOR_LEN;
|
|
769
|
+
var ptr6 = isLikeNone(scope) ? 0 : passStringToWasm0(scope, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
770
|
+
var len6 = WASM_VECTOR_LEN;
|
|
771
|
+
let ret;
|
|
772
|
+
ret = wasm.wasmpagebuilder_beginTag(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
|
|
773
|
+
if (ret[1]) {
|
|
774
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* The blend mode, camelCase (`multiply`, `colorDodge`, …).
|
|
779
|
+
*
|
|
780
|
+
* # Errors
|
|
781
|
+
* `invalid-argument` for an unknown mode.
|
|
782
|
+
* @param {string} mode
|
|
783
|
+
*/
|
|
784
|
+
blendMode(mode) {
|
|
785
|
+
const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
786
|
+
const len0 = WASM_VECTOR_LEN;
|
|
787
|
+
let ret;
|
|
788
|
+
ret = wasm.wasmpagebuilder_blendMode(this.__wbg_ptr, ptr0, len0);
|
|
789
|
+
if (ret[1]) {
|
|
790
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Clips to `path` (with `rule`) until the next `restore`.
|
|
795
|
+
*
|
|
796
|
+
* # Errors
|
|
797
|
+
* As [`WasmPageBuilder::fill_path`].
|
|
798
|
+
* @param {Float64Array} path
|
|
799
|
+
* @param {string} rule
|
|
800
|
+
*/
|
|
801
|
+
clipPath(path, rule) {
|
|
802
|
+
const ptr0 = passArrayF64ToWasm0(path, wasm.__wbindgen_malloc);
|
|
803
|
+
const len0 = WASM_VECTOR_LEN;
|
|
804
|
+
const ptr1 = passStringToWasm0(rule, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
805
|
+
const len1 = WASM_VECTOR_LEN;
|
|
806
|
+
let ret;
|
|
807
|
+
ret = wasm.wasmpagebuilder_clipPath(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
808
|
+
if (ret[1]) {
|
|
809
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Ends the innermost open element or artifact (none open: nothing happens).
|
|
814
|
+
*
|
|
815
|
+
* # Errors
|
|
816
|
+
* `builder-finished`.
|
|
817
|
+
*/
|
|
818
|
+
endTag() {
|
|
819
|
+
let ret;
|
|
820
|
+
ret = wasm.wasmpagebuilder_endTag(this.__wbg_ptr);
|
|
821
|
+
if (ret[1]) {
|
|
822
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* The fill colour as `#rrggbb` or `#rgb` (`DeviceRGB`).
|
|
827
|
+
*
|
|
828
|
+
* # Errors
|
|
829
|
+
* `invalid-color`.
|
|
830
|
+
* @param {string} hex
|
|
831
|
+
*/
|
|
832
|
+
fillColorHex(hex) {
|
|
833
|
+
const ptr0 = passStringToWasm0(hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
834
|
+
const len0 = WASM_VECTOR_LEN;
|
|
835
|
+
let ret;
|
|
836
|
+
ret = wasm.wasmpagebuilder_fillColorHex(this.__wbg_ptr, ptr0, len0);
|
|
837
|
+
if (ret[1]) {
|
|
838
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* The colour fills use: 1 (gray), 3 (RGB) or 4 (CMYK) components, 0 to 1.
|
|
843
|
+
*
|
|
844
|
+
* # Errors
|
|
845
|
+
* `invalid-argument` for another number of components.
|
|
846
|
+
* @param {Float64Array} components
|
|
847
|
+
*/
|
|
848
|
+
fillColor(components) {
|
|
849
|
+
const ptr0 = passArrayF64ToWasm0(components, wasm.__wbindgen_malloc);
|
|
850
|
+
const len0 = WASM_VECTOR_LEN;
|
|
851
|
+
let ret;
|
|
852
|
+
ret = wasm.wasmpagebuilder_fillColor(this.__wbg_ptr, ptr0, len0);
|
|
853
|
+
if (ret[1]) {
|
|
854
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Fills `path` (the flat path encoding) with `rule` (`nonZero` or `evenOdd`).
|
|
859
|
+
*
|
|
860
|
+
* # Errors
|
|
861
|
+
* `invalid-argument` for a bad path or rule.
|
|
862
|
+
* @param {Float64Array} path
|
|
863
|
+
* @param {string} rule
|
|
864
|
+
*/
|
|
865
|
+
fillPath(path, rule) {
|
|
866
|
+
const ptr0 = passArrayF64ToWasm0(path, wasm.__wbindgen_malloc);
|
|
867
|
+
const len0 = WASM_VECTOR_LEN;
|
|
868
|
+
const ptr1 = passStringToWasm0(rule, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
869
|
+
const len1 = WASM_VECTOR_LEN;
|
|
870
|
+
let ret;
|
|
871
|
+
ret = wasm.wasmpagebuilder_fillPath(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
872
|
+
if (ret[1]) {
|
|
873
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Fills `path` with `rule`, then strokes it with the current stroke style.
|
|
878
|
+
*
|
|
879
|
+
* # Errors
|
|
880
|
+
* As [`WasmPageBuilder::fill_path`].
|
|
881
|
+
* @param {Float64Array} path
|
|
882
|
+
* @param {string} rule
|
|
883
|
+
*/
|
|
884
|
+
fillStrokePath(path, rule) {
|
|
885
|
+
const ptr0 = passArrayF64ToWasm0(path, wasm.__wbindgen_malloc);
|
|
886
|
+
const len0 = WASM_VECTOR_LEN;
|
|
887
|
+
const ptr1 = passStringToWasm0(rule, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
888
|
+
const len1 = WASM_VECTOR_LEN;
|
|
889
|
+
let ret;
|
|
890
|
+
ret = wasm.wasmpagebuilder_fillStrokePath(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
891
|
+
if (ret[1]) {
|
|
892
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Writes the page into its builder: content stream, resources and page dictionary.
|
|
897
|
+
* Returns its page ID. The page is finished afterwards: every later call on it fails
|
|
898
|
+
* with `builder-finished`.
|
|
899
|
+
*
|
|
900
|
+
* # Errors
|
|
901
|
+
* `builder-finished` (the page or its builder already finished); `invalid-geometry` for
|
|
902
|
+
* the first invalid value drawn; `unknown-font` for a font from another builder.
|
|
903
|
+
* @returns {string}
|
|
904
|
+
*/
|
|
905
|
+
finish() {
|
|
906
|
+
let deferred2_0;
|
|
907
|
+
let deferred2_1;
|
|
908
|
+
try {
|
|
909
|
+
let ret;
|
|
910
|
+
ret = wasm.wasmpagebuilder_finish(this.__wbg_ptr);
|
|
911
|
+
var ptr1 = ret[0];
|
|
912
|
+
var len1 = ret[1];
|
|
913
|
+
if (ret[3]) {
|
|
914
|
+
ptr1 = 0; len1 = 0;
|
|
915
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
916
|
+
}
|
|
917
|
+
deferred2_0 = ptr1;
|
|
918
|
+
deferred2_1 = len1;
|
|
919
|
+
return getStringFromWasm0(ptr1, len1);
|
|
920
|
+
} finally {
|
|
921
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Draws `image` scaled into the rectangle.
|
|
926
|
+
*
|
|
927
|
+
* # Errors
|
|
928
|
+
* `builder-finished`.
|
|
929
|
+
* @param {WasmImage} image
|
|
930
|
+
* @param {number} x
|
|
931
|
+
* @param {number} y
|
|
932
|
+
* @param {number} width
|
|
933
|
+
* @param {number} height
|
|
934
|
+
*/
|
|
935
|
+
image(image, x, y, width, height) {
|
|
936
|
+
_assertClass(image, WasmImage);
|
|
937
|
+
let ret;
|
|
938
|
+
ret = wasm.wasmpagebuilder_image(this.__wbg_ptr, image.__wbg_ptr, x, y, width, height);
|
|
939
|
+
if (ret[1]) {
|
|
940
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* A link annotation over the rectangle, with `contents` as its alternate text.
|
|
945
|
+
*
|
|
946
|
+
* # Errors
|
|
947
|
+
* `invalid-argument` / `unknown-option` for a bad target.
|
|
948
|
+
* @param {number} x
|
|
949
|
+
* @param {number} y
|
|
950
|
+
* @param {number} width
|
|
951
|
+
* @param {number} height
|
|
952
|
+
* @param {LinkTargetInit} target
|
|
953
|
+
* @param {string | null} [contents]
|
|
954
|
+
*/
|
|
955
|
+
link(x, y, width, height, target, contents) {
|
|
956
|
+
var ptr0 = isLikeNone(contents) ? 0 : passStringToWasm0(contents, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
957
|
+
var len0 = WASM_VECTOR_LEN;
|
|
958
|
+
let ret;
|
|
959
|
+
ret = wasm.wasmpagebuilder_link(this.__wbg_ptr, x, y, width, height, target, ptr0, len0);
|
|
960
|
+
if (ret[1]) {
|
|
961
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Fill and stroke opacity, 0 to 1 (an `ExtGState`).
|
|
966
|
+
*
|
|
967
|
+
* # Errors
|
|
968
|
+
* `builder-finished`.
|
|
969
|
+
* @param {number} fill
|
|
970
|
+
* @param {number} stroke
|
|
971
|
+
*/
|
|
972
|
+
opacity(fill, stroke) {
|
|
973
|
+
let ret;
|
|
974
|
+
ret = wasm.wasmpagebuilder_opacity(this.__wbg_ptr, fill, stroke);
|
|
975
|
+
if (ret[1]) {
|
|
976
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Restores the graphics state (`Q`); one without a matching save is ignored.
|
|
981
|
+
*
|
|
982
|
+
* # Errors
|
|
983
|
+
* `builder-finished`.
|
|
984
|
+
*/
|
|
985
|
+
restore() {
|
|
986
|
+
let ret;
|
|
987
|
+
ret = wasm.wasmpagebuilder_restore(this.__wbg_ptr);
|
|
988
|
+
if (ret[1]) {
|
|
989
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* `/Rotate`: 0, 90, 180 or 270 degrees.
|
|
994
|
+
*
|
|
995
|
+
* # Errors
|
|
996
|
+
* `invalid-argument` for another angle.
|
|
997
|
+
* @param {number} degrees
|
|
998
|
+
*/
|
|
999
|
+
rotate(degrees) {
|
|
1000
|
+
let ret;
|
|
1001
|
+
ret = wasm.wasmpagebuilder_rotate(this.__wbg_ptr, degrees);
|
|
1002
|
+
if (ret[1]) {
|
|
1003
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Saves the graphics state (`q`).
|
|
1008
|
+
*
|
|
1009
|
+
* # Errors
|
|
1010
|
+
* `builder-finished` after [`WasmPageBuilder::finish`] (so does every drawing method).
|
|
1011
|
+
*/
|
|
1012
|
+
save() {
|
|
1013
|
+
let ret;
|
|
1014
|
+
ret = wasm.wasmpagebuilder_save(this.__wbg_ptr);
|
|
1015
|
+
if (ret[1]) {
|
|
1016
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* `/CropBox`, `/BleedBox`, `/TrimBox` or `/ArtBox` (`kind`: `crop`, `bleed`, `trim`,
|
|
1021
|
+
* `art`), in the media box's page space.
|
|
1022
|
+
*
|
|
1023
|
+
* # Errors
|
|
1024
|
+
* `invalid-argument` for another kind.
|
|
1025
|
+
* @param {"crop" | "bleed" | "trim" | "art"} kind
|
|
1026
|
+
* @param {number} x
|
|
1027
|
+
* @param {number} y
|
|
1028
|
+
* @param {number} width
|
|
1029
|
+
* @param {number} height
|
|
1030
|
+
*/
|
|
1031
|
+
setBox(kind, x, y, width, height) {
|
|
1032
|
+
const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1033
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1034
|
+
let ret;
|
|
1035
|
+
ret = wasm.wasmpagebuilder_setBox(this.__wbg_ptr, ptr0, len0, x, y, width, height);
|
|
1036
|
+
if (ret[1]) {
|
|
1037
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* The stroke colour as `#rrggbb` or `#rgb`.
|
|
1042
|
+
*
|
|
1043
|
+
* # Errors
|
|
1044
|
+
* `invalid-color`.
|
|
1045
|
+
* @param {string} hex
|
|
1046
|
+
*/
|
|
1047
|
+
strokeColorHex(hex) {
|
|
1048
|
+
const ptr0 = passStringToWasm0(hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1049
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1050
|
+
let ret;
|
|
1051
|
+
ret = wasm.wasmpagebuilder_strokeColorHex(this.__wbg_ptr, ptr0, len0);
|
|
1052
|
+
if (ret[1]) {
|
|
1053
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* The colour strokes use (as [`WasmPageBuilder::fill_color`]).
|
|
1058
|
+
*
|
|
1059
|
+
* # Errors
|
|
1060
|
+
* As [`WasmPageBuilder::fill_color`].
|
|
1061
|
+
* @param {Float64Array} components
|
|
1062
|
+
*/
|
|
1063
|
+
strokeColor(components) {
|
|
1064
|
+
const ptr0 = passArrayF64ToWasm0(components, wasm.__wbindgen_malloc);
|
|
1065
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1066
|
+
let ret;
|
|
1067
|
+
ret = wasm.wasmpagebuilder_strokeColor(this.__wbg_ptr, ptr0, len0);
|
|
1068
|
+
if (ret[1]) {
|
|
1069
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Strokes `path` with the current stroke style.
|
|
1074
|
+
*
|
|
1075
|
+
* # Errors
|
|
1076
|
+
* `invalid-argument` for a bad path.
|
|
1077
|
+
* @param {Float64Array} path
|
|
1078
|
+
*/
|
|
1079
|
+
strokePath(path) {
|
|
1080
|
+
const ptr0 = passArrayF64ToWasm0(path, wasm.__wbindgen_malloc);
|
|
1081
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1082
|
+
let ret;
|
|
1083
|
+
ret = wasm.wasmpagebuilder_strokePath(this.__wbg_ptr, ptr0, len0);
|
|
1084
|
+
if (ret[1]) {
|
|
1085
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* The style later strokes use: `width` (points), `cap` (`butt`, `round`, `square`),
|
|
1090
|
+
* `join` (`miter`, `round`, `bevel`), the miter limit and a dash pattern (empty: solid).
|
|
1091
|
+
*
|
|
1092
|
+
* # Errors
|
|
1093
|
+
* `invalid-argument` for an unknown cap or join.
|
|
1094
|
+
* @param {number} width
|
|
1095
|
+
* @param {string} cap
|
|
1096
|
+
* @param {string} join
|
|
1097
|
+
* @param {number} miterLimit
|
|
1098
|
+
* @param {Float64Array} dash
|
|
1099
|
+
* @param {number} dashPhase
|
|
1100
|
+
*/
|
|
1101
|
+
strokeStyle(width, cap, join, miterLimit, dash, dashPhase) {
|
|
1102
|
+
const ptr0 = passStringToWasm0(cap, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1103
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1104
|
+
const ptr1 = passStringToWasm0(join, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1105
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1106
|
+
const ptr2 = passArrayF64ToWasm0(dash, wasm.__wbindgen_malloc);
|
|
1107
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1108
|
+
let ret;
|
|
1109
|
+
ret = wasm.wasmpagebuilder_strokeStyle(this.__wbg_ptr, width, ptr0, len0, ptr1, len1, miterLimit, ptr2, len2, dashPhase);
|
|
1110
|
+
if (ret[1]) {
|
|
1111
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Applies `[a, b, c, d, e, f]` (page space) to what is drawn next.
|
|
1116
|
+
*
|
|
1117
|
+
* # Errors
|
|
1118
|
+
* `invalid-argument` unless there are 6 numbers.
|
|
1119
|
+
* @param {Float64Array} m
|
|
1120
|
+
*/
|
|
1121
|
+
transform(m) {
|
|
1122
|
+
const ptr0 = passArrayF64ToWasm0(m, wasm.__wbindgen_malloc);
|
|
1123
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1124
|
+
let ret;
|
|
1125
|
+
ret = wasm.wasmpagebuilder_transform(this.__wbg_ptr, ptr0, len0);
|
|
1126
|
+
if (ret[1]) {
|
|
1127
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* `/UserUnit`, for pages larger than 14,400 units.
|
|
1132
|
+
* @param {number} unit
|
|
1133
|
+
*/
|
|
1134
|
+
userUnit(unit) {
|
|
1135
|
+
wasm.wasmpagebuilder_userUnit(this.__wbg_ptr, unit);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
if (Symbol.dispose) WasmPageBuilder.prototype[Symbol.dispose] = WasmPageBuilder.prototype.free;
|
|
1139
|
+
|
|
1140
|
+
/**
|
|
1141
|
+
* A save in progress (F10). Each `step` checks that the document is unchanged since the
|
|
1142
|
+
* job was created (`document-changed`).
|
|
1143
|
+
*/
|
|
1144
|
+
export class WasmSaveJob {
|
|
1145
|
+
static __wrap(ptr) {
|
|
1146
|
+
const obj = Object.create(WasmSaveJob.prototype);
|
|
1147
|
+
obj.__wbg_ptr = ptr;
|
|
1148
|
+
Object.defineProperty(obj, '__wbg_inst', { value: __wbg_instance_id, writable: true });
|
|
1149
|
+
|
|
1150
|
+
WasmSaveJobFinalization.register(obj, { ptr, instance: __wbg_instance_id }, obj);
|
|
1151
|
+
return obj;
|
|
1152
|
+
}
|
|
1153
|
+
__destroy_into_raw() {
|
|
1154
|
+
const ptr = this.__wbg_ptr;
|
|
1155
|
+
this.__wbg_ptr = 0;
|
|
1156
|
+
WasmSaveJobFinalization.unregister(this);
|
|
1157
|
+
return ptr;
|
|
1158
|
+
}
|
|
1159
|
+
free() {
|
|
1160
|
+
const ptr = this.__destroy_into_raw();
|
|
1161
|
+
wasm.__wbg_wasmsavejob_free(ptr, 0);
|
|
1162
|
+
|
|
1163
|
+
}
|
|
1164
|
+
/**
|
|
1165
|
+
* Stops the job: its next step fails with `cancelled`.
|
|
1166
|
+
*/
|
|
1167
|
+
cancel() {
|
|
1168
|
+
wasm.wasmsavejob_cancel(this.__wbg_ptr);
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Runs at most `budget` work units: `{ state: "progress", done, total?, phase }` or
|
|
1172
|
+
* `{ state: "done", bytes, report }`.
|
|
1173
|
+
*
|
|
1174
|
+
* # Errors
|
|
1175
|
+
* `cancelled`, `document-changed`, `job-finished`, `disposed` when the document is freed,
|
|
1176
|
+
* or the save's own errors.
|
|
1177
|
+
* @param {number} budget
|
|
1178
|
+
* @returns {({ state: "progress" } & ProgressJs) | { state: "done"; bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs }}
|
|
1179
|
+
*/
|
|
1180
|
+
step(budget) {
|
|
1181
|
+
let ret;
|
|
1182
|
+
ret = wasm.wasmsavejob_step(this.__wbg_ptr, budget);
|
|
1183
|
+
if (ret[2]) {
|
|
1184
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1185
|
+
}
|
|
1186
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
if (Symbol.dispose) WasmSaveJob.prototype[Symbol.dispose] = WasmSaveJob.prototype.free;
|
|
1190
|
+
|
|
1191
|
+
/**
|
|
1192
|
+
* A PDF of known size whose bytes arrive later: give it to `WasmDocument.openSource`, and
|
|
1193
|
+
* after a `data-pending` error `supply` the ranges in its `data.ranges` and call again.
|
|
1194
|
+
*/
|
|
1195
|
+
export class WasmSparseSource {
|
|
1196
|
+
__destroy_into_raw() {
|
|
1197
|
+
const ptr = this.__wbg_ptr;
|
|
1198
|
+
this.__wbg_ptr = 0;
|
|
1199
|
+
WasmSparseSourceFinalization.unregister(this);
|
|
1200
|
+
return ptr;
|
|
1201
|
+
}
|
|
1202
|
+
free() {
|
|
1203
|
+
const ptr = this.__destroy_into_raw();
|
|
1204
|
+
wasm.__wbg_wasmsparsesource_free(ptr, 0);
|
|
1205
|
+
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* An empty source of `size` bytes holding at most `budget` bytes (no limit when omitted).
|
|
1209
|
+
*
|
|
1210
|
+
* # Errors
|
|
1211
|
+
* `invalid-argument` when a number isn't a whole number of bytes.
|
|
1212
|
+
* @param {number} size
|
|
1213
|
+
* @param {number | null} [budget]
|
|
1214
|
+
*/
|
|
1215
|
+
constructor(size, budget) {
|
|
1216
|
+
let ret;
|
|
1217
|
+
ret = wasm.wasmsparsesource_new(size, !isLikeNone(budget), isLikeNone(budget) ? 0 : budget);
|
|
1218
|
+
if (ret[2]) {
|
|
1219
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1220
|
+
}
|
|
1221
|
+
this.__wbg_ptr = ret[0];
|
|
1222
|
+
Object.defineProperty(this, '__wbg_inst', { value: __wbg_instance_id, writable: true });
|
|
1223
|
+
WasmSparseSourceFinalization.register(this, { ptr: ret[0], instance: __wbg_instance_id }, this);
|
|
1224
|
+
return this;
|
|
1225
|
+
}
|
|
1226
|
+
/**
|
|
1227
|
+
* The source's size in bytes.
|
|
1228
|
+
* @returns {number}
|
|
1229
|
+
*/
|
|
1230
|
+
get size() {
|
|
1231
|
+
let ret;
|
|
1232
|
+
ret = wasm.wasmsparsesource_size(this.__wbg_ptr);
|
|
1233
|
+
return ret;
|
|
1234
|
+
}
|
|
1235
|
+
/**
|
|
1236
|
+
* Adds `bytes` at `offset` (bytes already held win over overlapping ones).
|
|
1237
|
+
*
|
|
1238
|
+
* # Errors
|
|
1239
|
+
* `invalid-argument` past the end; `source-budget-exceeded` over the budget.
|
|
1240
|
+
* @param {number} offset
|
|
1241
|
+
* @param {Uint8Array} bytes
|
|
1242
|
+
*/
|
|
1243
|
+
supply(offset, bytes) {
|
|
1244
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
1245
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1246
|
+
let ret;
|
|
1247
|
+
ret = wasm.wasmsparsesource_supply(this.__wbg_ptr, offset, ptr0, len0);
|
|
1248
|
+
if (ret[1]) {
|
|
1249
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* What to fetch for the ranges a `data-pending` asked for (flat `[start, end, …]`): each
|
|
1254
|
+
* widened to blocks of `block` bytes (0: as asked) plus `readahead`, merged, minus what is
|
|
1255
|
+
* held, in the same flat form. The planning step of `laminapdf-source`'s `retry`, so every
|
|
1256
|
+
* loop plans the same way.
|
|
1257
|
+
*
|
|
1258
|
+
* # Errors
|
|
1259
|
+
* `invalid-argument` for an odd length or a value that isn't a whole number of bytes.
|
|
1260
|
+
* @param {Float64Array} asked
|
|
1261
|
+
* @param {number} block
|
|
1262
|
+
* @param {number} readahead
|
|
1263
|
+
* @returns {Float64Array}
|
|
1264
|
+
*/
|
|
1265
|
+
toFetch(asked, block, readahead) {
|
|
1266
|
+
const ptr0 = passArrayF64ToWasm0(asked, wasm.__wbindgen_malloc);
|
|
1267
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1268
|
+
let ret;
|
|
1269
|
+
ret = wasm.wasmsparsesource_toFetch(this.__wbg_ptr, ptr0, len0, block, readahead);
|
|
1270
|
+
if (ret[2]) {
|
|
1271
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1272
|
+
}
|
|
1273
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
if (Symbol.dispose) WasmSparseSource.prototype[Symbol.dispose] = WasmSparseSource.prototype.free;
|
|
1277
|
+
|
|
1278
|
+
/**
|
|
1279
|
+
* The warnings of a document, read in batches (F8).
|
|
1280
|
+
*/
|
|
1281
|
+
export class WasmWarningCursor {
|
|
1282
|
+
static __wrap(ptr) {
|
|
1283
|
+
const obj = Object.create(WasmWarningCursor.prototype);
|
|
1284
|
+
obj.__wbg_ptr = ptr;
|
|
1285
|
+
Object.defineProperty(obj, '__wbg_inst', { value: __wbg_instance_id, writable: true });
|
|
1286
|
+
|
|
1287
|
+
WasmWarningCursorFinalization.register(obj, { ptr, instance: __wbg_instance_id }, obj);
|
|
1288
|
+
return obj;
|
|
1289
|
+
}
|
|
1290
|
+
__destroy_into_raw() {
|
|
1291
|
+
const ptr = this.__wbg_ptr;
|
|
1292
|
+
this.__wbg_ptr = 0;
|
|
1293
|
+
WasmWarningCursorFinalization.unregister(this);
|
|
1294
|
+
return ptr;
|
|
1295
|
+
}
|
|
1296
|
+
free() {
|
|
1297
|
+
const ptr = this.__destroy_into_raw();
|
|
1298
|
+
wasm.__wbg_wasmwarningcursor_free(ptr, 0);
|
|
1299
|
+
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* Up to `max` more warnings, each as the ADR 0026 §1 object; empty at the end.
|
|
1303
|
+
* @param {number} max
|
|
1304
|
+
* @returns {Diagnostic[]}
|
|
1305
|
+
*/
|
|
1306
|
+
nextBatch(max) {
|
|
1307
|
+
let ret;
|
|
1308
|
+
ret = wasm.wasmwarningcursor_nextBatch(this.__wbg_ptr, max);
|
|
1309
|
+
return ret;
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* How many warnings are left.
|
|
1313
|
+
* @returns {number}
|
|
1314
|
+
*/
|
|
1315
|
+
remaining() {
|
|
1316
|
+
let ret;
|
|
1317
|
+
ret = wasm.wasmwarningcursor_remaining(this.__wbg_ptr);
|
|
1318
|
+
return ret >>> 0;
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
if (Symbol.dispose) WasmWarningCursor.prototype[Symbol.dispose] = WasmWarningCursor.prototype.free;
|
|
1322
|
+
|
|
1323
|
+
export function __wbg_reset_state () {
|
|
1324
|
+
__wbg_instance_id++;
|
|
1325
|
+
cachedDataViewMemory0 = null;
|
|
1326
|
+
cachedFloat32ArrayMemory0 = null;
|
|
1327
|
+
cachedFloat64ArrayMemory0 = null;
|
|
1328
|
+
cachedUint32ArrayMemory0 = null;
|
|
1329
|
+
cachedUint8ArrayMemory0 = null;
|
|
1330
|
+
if (typeof numBytesDecoded !== 'undefined') numBytesDecoded = 0;
|
|
1331
|
+
if (typeof WASM_VECTOR_LEN !== 'undefined') WASM_VECTOR_LEN = 0;
|
|
1332
|
+
__wbg_reinit_scheduled = false;
|
|
1333
|
+
wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
1334
|
+
wasm = wasmInstance.exports;
|
|
1335
|
+
wasm.__wbindgen_start();
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* Whether the most recent allocation failed: after a trap, `true` means the module ran out of
|
|
1340
|
+
* memory.
|
|
1341
|
+
* @returns {boolean}
|
|
1342
|
+
*/
|
|
1343
|
+
export function allocationFailed() {
|
|
1344
|
+
let ret;
|
|
1345
|
+
ret = wasm.allocationFailed();
|
|
1346
|
+
return ret !== 0;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
/**
|
|
1350
|
+
* Whether this module is the text module (fonts, `text`, `textBox`).
|
|
1351
|
+
* @returns {boolean}
|
|
1352
|
+
*/
|
|
1353
|
+
export function hasText() {
|
|
1354
|
+
let ret;
|
|
1355
|
+
ret = wasm.hasText();
|
|
1356
|
+
return ret !== 0;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
/**
|
|
1360
|
+
* The crate version (`@laminapdf/wasm`'s).
|
|
1361
|
+
* @returns {string}
|
|
1362
|
+
*/
|
|
1363
|
+
export function version() {
|
|
1364
|
+
let deferred1_0;
|
|
1365
|
+
let deferred1_1;
|
|
1366
|
+
try {
|
|
1367
|
+
let ret;
|
|
1368
|
+
ret = wasm.version();
|
|
1369
|
+
deferred1_0 = ret[0];
|
|
1370
|
+
deferred1_1 = ret[1];
|
|
1371
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1372
|
+
} finally {
|
|
1373
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
function __wbg_get_imports() {
|
|
1377
|
+
const import0 = {
|
|
1378
|
+
__proto__: null,
|
|
1379
|
+
__wbg___wbindgen_is_null_e343b7d08827ba72: function(arg0) {
|
|
1380
|
+
const ret = arg0 === null;
|
|
1381
|
+
return ret;
|
|
1382
|
+
},
|
|
1383
|
+
__wbg___wbindgen_is_object_3c45d4f2dde4e749: function(arg0) {
|
|
1384
|
+
const val = arg0;
|
|
1385
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
1386
|
+
return ret;
|
|
1387
|
+
},
|
|
1388
|
+
__wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
|
|
1389
|
+
const ret = arg0 === undefined;
|
|
1390
|
+
return ret;
|
|
1391
|
+
},
|
|
1392
|
+
__wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
|
|
1393
|
+
const obj = arg1;
|
|
1394
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
1395
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1396
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1397
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1398
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1399
|
+
},
|
|
1400
|
+
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
1401
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1402
|
+
},
|
|
1403
|
+
__wbg_keys_440be172f17c0265: function(arg0) {
|
|
1404
|
+
const ret = Object.keys(arg0);
|
|
1405
|
+
return ret;
|
|
1406
|
+
},
|
|
1407
|
+
__wbg_new_617a8cdb8bb1130e: function() {
|
|
1408
|
+
const ret = new Object();
|
|
1409
|
+
return ret;
|
|
1410
|
+
},
|
|
1411
|
+
__wbg_new_from_slice_37a3c3a194266cb8: function(arg0, arg1) {
|
|
1412
|
+
const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
|
|
1413
|
+
return ret;
|
|
1414
|
+
},
|
|
1415
|
+
__wbg_new_from_slice_9a868026ffa4208a: function(arg0, arg1) {
|
|
1416
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
1417
|
+
return ret;
|
|
1418
|
+
},
|
|
1419
|
+
__wbg_new_from_slice_ca6ad97db1f4779a: function(arg0, arg1) {
|
|
1420
|
+
const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
|
|
1421
|
+
return ret;
|
|
1422
|
+
},
|
|
1423
|
+
__wbg_new_from_slice_f545fd22ddc142b8: function(arg0, arg1) {
|
|
1424
|
+
const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
|
|
1425
|
+
return ret;
|
|
1426
|
+
},
|
|
1427
|
+
__wbg_parse_0fc53dead14b3b42: function() { return handleError(function (arg0, arg1) {
|
|
1428
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
1429
|
+
return ret;
|
|
1430
|
+
}, arguments); },
|
|
1431
|
+
__wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1432
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
1433
|
+
return ret;
|
|
1434
|
+
}, arguments); },
|
|
1435
|
+
__wbg_slice_6da4cdc5d543fcd0: function(arg0, arg1) {
|
|
1436
|
+
const ret = arg1.slice();
|
|
1437
|
+
const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_malloc);
|
|
1438
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1439
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1440
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1441
|
+
},
|
|
1442
|
+
__wbg_stringify_52ff602c1cc4fbb6: function() { return handleError(function (arg0) {
|
|
1443
|
+
const ret = JSON.stringify(arg0);
|
|
1444
|
+
return ret;
|
|
1445
|
+
}, arguments); },
|
|
1446
|
+
__wbindgen_generic_0000000000000001: function(arg0) {
|
|
1447
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
1448
|
+
const ret = arg0;
|
|
1449
|
+
return ret;
|
|
1450
|
+
},
|
|
1451
|
+
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
1452
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1453
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1454
|
+
return ret;
|
|
1455
|
+
},
|
|
1456
|
+
__wbindgen_init_externref_table: function() {
|
|
1457
|
+
const table = wasm.__wbindgen_externrefs;
|
|
1458
|
+
const offset = table.grow(4);
|
|
1459
|
+
table.set(0, undefined);
|
|
1460
|
+
table.set(offset + 0, undefined);
|
|
1461
|
+
table.set(offset + 1, null);
|
|
1462
|
+
table.set(offset + 2, true);
|
|
1463
|
+
table.set(offset + 3, false);
|
|
1464
|
+
},
|
|
1465
|
+
};
|
|
1466
|
+
return {
|
|
1467
|
+
__proto__: null,
|
|
1468
|
+
"./lamina_pdf_extract_bg.js": import0,
|
|
1469
|
+
};
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
function __wbg_call_guard() {
|
|
1473
|
+
if (__wbg_reinit_scheduled) {
|
|
1474
|
+
__wbg_reset_state();
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
|
|
1480
|
+
let __wbg_instance_id = 0;
|
|
1481
|
+
const WasmBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1482
|
+
? { register: () => {}, unregister: () => {} }
|
|
1483
|
+
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
1484
|
+
if (instance === __wbg_instance_id) wasm.__wbg_wasmbuilder_free(ptr, 1);
|
|
1485
|
+
});
|
|
1486
|
+
const WasmDocumentFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1487
|
+
? { register: () => {}, unregister: () => {} }
|
|
1488
|
+
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
1489
|
+
if (instance === __wbg_instance_id) wasm.__wbg_wasmdocument_free(ptr, 1);
|
|
1490
|
+
});
|
|
1491
|
+
const WasmImageFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1492
|
+
? { register: () => {}, unregister: () => {} }
|
|
1493
|
+
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
1494
|
+
if (instance === __wbg_instance_id) wasm.__wbg_wasmimage_free(ptr, 1);
|
|
1495
|
+
});
|
|
1496
|
+
const WasmPageFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1497
|
+
? { register: () => {}, unregister: () => {} }
|
|
1498
|
+
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
1499
|
+
if (instance === __wbg_instance_id) wasm.__wbg_wasmpage_free(ptr, 1);
|
|
1500
|
+
});
|
|
1501
|
+
const WasmPageBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1502
|
+
? { register: () => {}, unregister: () => {} }
|
|
1503
|
+
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
1504
|
+
if (instance === __wbg_instance_id) wasm.__wbg_wasmpagebuilder_free(ptr, 1);
|
|
1505
|
+
});
|
|
1506
|
+
const WasmSaveJobFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1507
|
+
? { register: () => {}, unregister: () => {} }
|
|
1508
|
+
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
1509
|
+
if (instance === __wbg_instance_id) wasm.__wbg_wasmsavejob_free(ptr, 1);
|
|
1510
|
+
});
|
|
1511
|
+
const WasmSparseSourceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1512
|
+
? { register: () => {}, unregister: () => {} }
|
|
1513
|
+
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
1514
|
+
if (instance === __wbg_instance_id) wasm.__wbg_wasmsparsesource_free(ptr, 1);
|
|
1515
|
+
});
|
|
1516
|
+
const WasmWarningCursorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1517
|
+
? { register: () => {}, unregister: () => {} }
|
|
1518
|
+
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
1519
|
+
if (instance === __wbg_instance_id) wasm.__wbg_wasmwarningcursor_free(ptr, 1);
|
|
1520
|
+
});
|
|
1521
|
+
|
|
1522
|
+
function addToExternrefTable0(obj) {
|
|
1523
|
+
const idx = wasm.__externref_table_alloc();
|
|
1524
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
1525
|
+
return idx;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
function _assertClass(instance, klass) {
|
|
1529
|
+
if (!(instance instanceof klass)) {
|
|
1530
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
1535
|
+
ptr = ptr >>> 0;
|
|
1536
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
1540
|
+
ptr = ptr >>> 0;
|
|
1541
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
1545
|
+
ptr = ptr >>> 0;
|
|
1546
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
1550
|
+
ptr = ptr >>> 0;
|
|
1551
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
let cachedDataViewMemory0 = null;
|
|
1555
|
+
function getDataViewMemory0() {
|
|
1556
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
1557
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
1558
|
+
}
|
|
1559
|
+
return cachedDataViewMemory0;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
1563
|
+
function getFloat32ArrayMemory0() {
|
|
1564
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
1565
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
1566
|
+
}
|
|
1567
|
+
return cachedFloat32ArrayMemory0;
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
1571
|
+
function getFloat64ArrayMemory0() {
|
|
1572
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
1573
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
1574
|
+
}
|
|
1575
|
+
return cachedFloat64ArrayMemory0;
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
function getStringFromWasm0(ptr, len) {
|
|
1579
|
+
return decodeText(ptr >>> 0, len);
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
let cachedUint32ArrayMemory0 = null;
|
|
1583
|
+
function getUint32ArrayMemory0() {
|
|
1584
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
1585
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
1586
|
+
}
|
|
1587
|
+
return cachedUint32ArrayMemory0;
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
let cachedUint8ArrayMemory0 = null;
|
|
1591
|
+
function getUint8ArrayMemory0() {
|
|
1592
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
1593
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
1594
|
+
}
|
|
1595
|
+
return cachedUint8ArrayMemory0;
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
function handleError(f, args) {
|
|
1599
|
+
try {
|
|
1600
|
+
return f.apply(this, args);
|
|
1601
|
+
} catch (e) {
|
|
1602
|
+
const idx = addToExternrefTable0(e);
|
|
1603
|
+
wasm.__wbindgen_exn_store(idx);
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
function isLikeNone(x) {
|
|
1608
|
+
return x === undefined || x === null;
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
1612
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
1613
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
1614
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1615
|
+
return ptr;
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
1619
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
1620
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
1621
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1622
|
+
return ptr;
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
1626
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
1627
|
+
for (let i = 0; i < array.length; i++) {
|
|
1628
|
+
const add = addToExternrefTable0(array[i]);
|
|
1629
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
1630
|
+
}
|
|
1631
|
+
WASM_VECTOR_LEN = array.length;
|
|
1632
|
+
return ptr;
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
1636
|
+
if (realloc === undefined) {
|
|
1637
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1638
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
1639
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
1640
|
+
WASM_VECTOR_LEN = buf.length;
|
|
1641
|
+
return ptr;
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
let len = arg.length;
|
|
1645
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
1646
|
+
|
|
1647
|
+
const mem = getUint8ArrayMemory0();
|
|
1648
|
+
|
|
1649
|
+
let offset = 0;
|
|
1650
|
+
|
|
1651
|
+
for (; offset < len; offset++) {
|
|
1652
|
+
const code = arg.charCodeAt(offset);
|
|
1653
|
+
if (code > 0x7F) break;
|
|
1654
|
+
mem[ptr + offset] = code;
|
|
1655
|
+
}
|
|
1656
|
+
if (offset !== len) {
|
|
1657
|
+
if (offset !== 0) {
|
|
1658
|
+
arg = arg.slice(offset);
|
|
1659
|
+
}
|
|
1660
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1661
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1662
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1663
|
+
|
|
1664
|
+
offset += ret.written;
|
|
1665
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
WASM_VECTOR_LEN = offset;
|
|
1669
|
+
return ptr;
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
let __wbg_reinit_scheduled = false;
|
|
1673
|
+
|
|
1674
|
+
function takeFromExternrefTable0(idx) {
|
|
1675
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1676
|
+
wasm.__externref_table_dealloc(idx);
|
|
1677
|
+
return value;
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1681
|
+
cachedTextDecoder.decode();
|
|
1682
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
1683
|
+
let numBytesDecoded = 0;
|
|
1684
|
+
function decodeText(ptr, len) {
|
|
1685
|
+
numBytesDecoded += len;
|
|
1686
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1687
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1688
|
+
cachedTextDecoder.decode();
|
|
1689
|
+
numBytesDecoded = len;
|
|
1690
|
+
}
|
|
1691
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
const cachedTextEncoder = new TextEncoder();
|
|
1695
|
+
|
|
1696
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
1697
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1698
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1699
|
+
view.set(buf);
|
|
1700
|
+
return {
|
|
1701
|
+
read: arg.length,
|
|
1702
|
+
written: buf.length
|
|
1703
|
+
};
|
|
1704
|
+
};
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
let WASM_VECTOR_LEN = 0;
|
|
1708
|
+
|
|
1709
|
+
let wasmModule, wasmInstance, wasm;
|
|
1710
|
+
function __wbg_finalize_init(instance, module) {
|
|
1711
|
+
wasmInstance = instance;
|
|
1712
|
+
wasm = instance.exports;
|
|
1713
|
+
wasmModule = module;
|
|
1714
|
+
cachedDataViewMemory0 = null;
|
|
1715
|
+
cachedFloat32ArrayMemory0 = null;
|
|
1716
|
+
cachedFloat64ArrayMemory0 = null;
|
|
1717
|
+
cachedUint32ArrayMemory0 = null;
|
|
1718
|
+
cachedUint8ArrayMemory0 = null;
|
|
1719
|
+
wasm.__wbindgen_start();
|
|
1720
|
+
return wasm;
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
async function __wbg_load(module, imports) {
|
|
1724
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
1725
|
+
if (!module.ok) {
|
|
1726
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1730
|
+
try {
|
|
1731
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1732
|
+
} catch (e) {
|
|
1733
|
+
const validResponse = expectedResponseType(module.type);
|
|
1734
|
+
|
|
1735
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
1736
|
+
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);
|
|
1737
|
+
|
|
1738
|
+
} else { throw e; }
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
const bytes = await module.arrayBuffer();
|
|
1743
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1744
|
+
} else {
|
|
1745
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1746
|
+
|
|
1747
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1748
|
+
return { instance, module };
|
|
1749
|
+
} else {
|
|
1750
|
+
return instance;
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
function expectedResponseType(type) {
|
|
1755
|
+
switch (type) {
|
|
1756
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
1757
|
+
}
|
|
1758
|
+
return false;
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
function initSync(module) {
|
|
1763
|
+
if (wasm !== undefined) return wasm;
|
|
1764
|
+
|
|
1765
|
+
|
|
1766
|
+
if (module !== undefined) {
|
|
1767
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1768
|
+
({module} = module)
|
|
1769
|
+
} else {
|
|
1770
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
const imports = __wbg_get_imports();
|
|
1775
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1776
|
+
module = new WebAssembly.Module(module);
|
|
1777
|
+
}
|
|
1778
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1779
|
+
return __wbg_finalize_init(instance, module);
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
async function __wbg_init(module_or_path) {
|
|
1783
|
+
if (wasm !== undefined) return wasm;
|
|
1784
|
+
|
|
1785
|
+
|
|
1786
|
+
if (module_or_path !== undefined) {
|
|
1787
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1788
|
+
({module_or_path} = module_or_path)
|
|
1789
|
+
} else {
|
|
1790
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
if (module_or_path === undefined) {
|
|
1795
|
+
module_or_path = new URL('lamina_pdf_extract.wasm', import.meta.url);
|
|
1796
|
+
}
|
|
1797
|
+
const imports = __wbg_get_imports();
|
|
1798
|
+
|
|
1799
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
1800
|
+
module_or_path = fetch(module_or_path);
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1804
|
+
|
|
1805
|
+
return __wbg_finalize_init(instance, module);
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
export { initSync, __wbg_init as default };
|