@laminapdf/wasm 0.2.0-alpha.6 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/lamina_pdf_base.d.ts +1718 -119
- package/dist/lamina_pdf_base.js +224 -0
- package/dist/lamina_pdf_base.wasm +0 -0
- package/dist/lamina_pdf_extract.d.ts +1995 -81
- package/dist/lamina_pdf_extract.js +368 -0
- package/dist/lamina_pdf_extract.wasm +0 -0
- package/dist/lamina_pdf_render_hayro.wasm +0 -0
- package/dist/lamina_pdf_text.d.ts +2029 -57
- package/dist/lamina_pdf_text.js +448 -0
- package/dist/lamina_pdf_text.wasm +0 -0
- package/dist/lamina_pdf_tiff.d.ts +71 -0
- package/dist/lamina_pdf_tiff.js +259 -0
- package/dist/lamina_pdf_tiff.wasm +0 -0
- package/package.json +14 -3
package/dist/lamina_pdf_base.js
CHANGED
|
@@ -205,6 +205,48 @@ export class WasmDocument {
|
|
|
205
205
|
wasm.__wbg_wasmdocument_free(ptr, 0);
|
|
206
206
|
|
|
207
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Adds another PDF as a source document: `{ id, pages }`, its ID (64 hex digits, the
|
|
210
|
+
* SHA-256 of `bytes`) and its page IDs in order. An encrypted one opens with `password`,
|
|
211
|
+
* which no op ever holds.
|
|
212
|
+
*
|
|
213
|
+
* # Errors
|
|
214
|
+
* `wrong-password`, `password-required`, and the errors of a file that doesn't open.
|
|
215
|
+
* @param {Uint8Array} bytes
|
|
216
|
+
* @param {string | null} [password]
|
|
217
|
+
* @returns {{ id: string; pages: string[] }}
|
|
218
|
+
*/
|
|
219
|
+
addSource(bytes, password) {
|
|
220
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
221
|
+
const len0 = WASM_VECTOR_LEN;
|
|
222
|
+
var ptr1 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
223
|
+
var len1 = WASM_VECTOR_LEN;
|
|
224
|
+
let ret;
|
|
225
|
+
ret = wasm.wasmdocument_addSource(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
226
|
+
if (ret[2]) {
|
|
227
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
228
|
+
}
|
|
229
|
+
return takeFromExternrefTable0(ret[0]);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Makes `bytes`, the whole output of `saveCopy`, the document's saved file (it rebases onto
|
|
233
|
+
* them), once they are written where the document lives; `historyCleared` is the copy's
|
|
234
|
+
* report's.
|
|
235
|
+
*
|
|
236
|
+
* # Errors
|
|
237
|
+
* `nested-transaction`, `saved-not-rebased`; `not-rebased` when `bytes` can't be read.
|
|
238
|
+
* @param {Uint8Array} bytes
|
|
239
|
+
* @param {boolean} historyCleared
|
|
240
|
+
*/
|
|
241
|
+
adoptCopy(bytes, historyCleared) {
|
|
242
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
243
|
+
const len0 = WASM_VECTOR_LEN;
|
|
244
|
+
let ret;
|
|
245
|
+
ret = wasm.wasmdocument_adoptCopy(this.__wbg_ptr, ptr0, len0, historyCleared);
|
|
246
|
+
if (ret[1]) {
|
|
247
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
208
250
|
/**
|
|
209
251
|
* Applies an op log (`{ "v": 1, "ops": [ … ] }`) as one transaction.
|
|
210
252
|
*
|
|
@@ -240,6 +282,23 @@ export class WasmDocument {
|
|
|
240
282
|
}
|
|
241
283
|
return takeFromExternrefTable0(ret[0]);
|
|
242
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* A new document of `pages` of this one, in the order given.
|
|
287
|
+
*
|
|
288
|
+
* # Errors
|
|
289
|
+
* `invalid-argument` for a value that isn't a list of page IDs, `unknown-page`; reading
|
|
290
|
+
* errors.
|
|
291
|
+
* @param {string[]} pages
|
|
292
|
+
* @returns {WasmDocument}
|
|
293
|
+
*/
|
|
294
|
+
extractPages(pages) {
|
|
295
|
+
let ret;
|
|
296
|
+
ret = wasm.wasmdocument_extractPages(this.__wbg_ptr, pages);
|
|
297
|
+
if (ret[2]) {
|
|
298
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
299
|
+
}
|
|
300
|
+
return WasmDocument.__wrap(ret[0]);
|
|
301
|
+
}
|
|
243
302
|
/**
|
|
244
303
|
* Whether there are changes no save has written yet.
|
|
245
304
|
* @returns {boolean}
|
|
@@ -273,6 +332,42 @@ export class WasmDocument {
|
|
|
273
332
|
ret = wasm.wasmdocument_isEncrypted(this.__wbg_ptr);
|
|
274
333
|
return ret !== 0;
|
|
275
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* A new document of `inputs` (each `{ bytes, password?, title? }`) one after another,
|
|
337
|
+
* with their bookmarks, named destinations, form fields, layers and page labels; `options`
|
|
338
|
+
* as `mergeDocuments`' (`outline`, `fields`).
|
|
339
|
+
*
|
|
340
|
+
* # Errors
|
|
341
|
+
* `invalid-argument` / `unknown-option` for bad values, `wrong-password`,
|
|
342
|
+
* `password-required`, and the errors of a file that doesn't open.
|
|
343
|
+
* @param {{ bytes: Uint8Array; password?: string; title?: string }[]} inputs
|
|
344
|
+
* @param {MergeOptions | undefined} options
|
|
345
|
+
* @returns {WasmDocument}
|
|
346
|
+
*/
|
|
347
|
+
static merge(inputs, options) {
|
|
348
|
+
let ret;
|
|
349
|
+
ret = wasm.wasmdocument_merge(inputs, options);
|
|
350
|
+
if (ret[2]) {
|
|
351
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
352
|
+
}
|
|
353
|
+
return WasmDocument.__wrap(ret[0]);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* The document's metadata, read from Info and XMP together, with the fields where they
|
|
357
|
+
* disagree.
|
|
358
|
+
*
|
|
359
|
+
* # Errors
|
|
360
|
+
* Reading errors.
|
|
361
|
+
* @returns {DocumentMetadata}
|
|
362
|
+
*/
|
|
363
|
+
metadata() {
|
|
364
|
+
let ret;
|
|
365
|
+
ret = wasm.wasmdocument_metadata(this.__wbg_ptr);
|
|
366
|
+
if (ret[2]) {
|
|
367
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
368
|
+
}
|
|
369
|
+
return takeFromExternrefTable0(ret[0]);
|
|
370
|
+
}
|
|
276
371
|
/**
|
|
277
372
|
* Opens a document from its bytes.
|
|
278
373
|
*
|
|
@@ -393,6 +488,22 @@ export class WasmDocument {
|
|
|
393
488
|
}
|
|
394
489
|
return WasmPage.__wrap(ret[0]);
|
|
395
490
|
}
|
|
491
|
+
/**
|
|
492
|
+
* How a save with `options` would go, without saving.
|
|
493
|
+
*
|
|
494
|
+
* # Errors
|
|
495
|
+
* `invalid-argument` / `unknown-option` for bad options; reading errors.
|
|
496
|
+
* @param {SaveOptionsInit | undefined} options
|
|
497
|
+
* @returns {PlannedSaveJs}
|
|
498
|
+
*/
|
|
499
|
+
plan(options) {
|
|
500
|
+
let ret;
|
|
501
|
+
ret = wasm.wasmdocument_plan(this.__wbg_ptr, options);
|
|
502
|
+
if (ret[2]) {
|
|
503
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
504
|
+
}
|
|
505
|
+
return takeFromExternrefTable0(ret[0]);
|
|
506
|
+
}
|
|
396
507
|
/**
|
|
397
508
|
* Rebases onto `bytes`, the output of a save whose rebase failed (`not-rebased`).
|
|
398
509
|
*
|
|
@@ -425,6 +536,23 @@ export class WasmDocument {
|
|
|
425
536
|
}
|
|
426
537
|
return takeFromExternrefTable0(ret[0]);
|
|
427
538
|
}
|
|
539
|
+
/**
|
|
540
|
+
* Writes what `save` would and leaves the document as it was: not rebased, its changes
|
|
541
|
+
* still unsaved, the save-time stamp in the copy only (Save a copy).
|
|
542
|
+
*
|
|
543
|
+
* # Errors
|
|
544
|
+
* As `save`; the document is unchanged either way.
|
|
545
|
+
* @param {SaveOptionsInit | undefined} options
|
|
546
|
+
* @returns {{ bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs }}
|
|
547
|
+
*/
|
|
548
|
+
saveCopy(options) {
|
|
549
|
+
let ret;
|
|
550
|
+
ret = wasm.wasmdocument_saveCopy(this.__wbg_ptr, options);
|
|
551
|
+
if (ret[2]) {
|
|
552
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
553
|
+
}
|
|
554
|
+
return takeFromExternrefTable0(ret[0]);
|
|
555
|
+
}
|
|
428
556
|
/**
|
|
429
557
|
* A save as a job, stepped with a budget of work units (ADR 0028 §3, §4).
|
|
430
558
|
*
|
|
@@ -457,6 +585,26 @@ export class WasmDocument {
|
|
|
457
585
|
}
|
|
458
586
|
return takeFromExternrefTable0(ret[0]);
|
|
459
587
|
}
|
|
588
|
+
/**
|
|
589
|
+
* This document cut into new ones: `{ count: n }` parts of `n` pages, `{ ranges: [[id, …],
|
|
590
|
+
* …] }` one part per list of page IDs, or `{ bookmarks: level }` a part from each bookmark
|
|
591
|
+
* at that depth (1: the top level). Each part carries what its pages reach and the
|
|
592
|
+
* bookmarks that go to them.
|
|
593
|
+
*
|
|
594
|
+
* # Errors
|
|
595
|
+
* `invalid-argument` / `unknown-option` for a value that isn't one of those, `unknown-page`,
|
|
596
|
+
* `no-pages-left` for an empty list; reading errors.
|
|
597
|
+
* @param {{ readonly count: number } | { readonly ranges: readonly (readonly string[])[] } | { readonly bookmarks: number }} by
|
|
598
|
+
* @returns {WasmDocument[]}
|
|
599
|
+
*/
|
|
600
|
+
split(by) {
|
|
601
|
+
let ret;
|
|
602
|
+
ret = wasm.wasmdocument_split(this.__wbg_ptr, by);
|
|
603
|
+
if (ret[2]) {
|
|
604
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
605
|
+
}
|
|
606
|
+
return takeFromExternrefTable0(ret[0]);
|
|
607
|
+
}
|
|
460
608
|
/**
|
|
461
609
|
* Undoes the newest transaction: how it went and the pages it touched; `undefined` when
|
|
462
610
|
* there is nothing to undo.
|
|
@@ -482,6 +630,37 @@ export class WasmDocument {
|
|
|
482
630
|
ret = wasm.wasmdocument_warnings(this.__wbg_ptr);
|
|
483
631
|
return WasmWarningCursor.__wrap(ret);
|
|
484
632
|
}
|
|
633
|
+
/**
|
|
634
|
+
* The signature restrictions `op` would break if it were applied and saved.
|
|
635
|
+
*
|
|
636
|
+
* # Errors
|
|
637
|
+
* `invalid-argument` for a value that isn't an op; reading errors.
|
|
638
|
+
* @param {Op} op
|
|
639
|
+
* @returns {ViolationJs[]}
|
|
640
|
+
*/
|
|
641
|
+
wouldViolate(op) {
|
|
642
|
+
let ret;
|
|
643
|
+
ret = wasm.wasmdocument_wouldViolate(this.__wbg_ptr, op);
|
|
644
|
+
if (ret[2]) {
|
|
645
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
646
|
+
}
|
|
647
|
+
return takeFromExternrefTable0(ret[0]);
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* The document's XMP packet as text, with the edits made so far.
|
|
651
|
+
*
|
|
652
|
+
* # Errors
|
|
653
|
+
* Reading errors.
|
|
654
|
+
* @returns {XmpTextJs}
|
|
655
|
+
*/
|
|
656
|
+
xmpPacket() {
|
|
657
|
+
let ret;
|
|
658
|
+
ret = wasm.wasmdocument_xmpPacket(this.__wbg_ptr);
|
|
659
|
+
if (ret[2]) {
|
|
660
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
661
|
+
}
|
|
662
|
+
return takeFromExternrefTable0(ret[0]);
|
|
663
|
+
}
|
|
485
664
|
}
|
|
486
665
|
if (Symbol.dispose) WasmDocument.prototype[Symbol.dispose] = WasmDocument.prototype.free;
|
|
487
666
|
|
|
@@ -1363,14 +1542,48 @@ function __wbg_get_imports() {
|
|
|
1363
1542
|
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
1364
1543
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1365
1544
|
},
|
|
1545
|
+
__wbg_get_31af05bd4842a84f: function() { return handleError(function (arg0, arg1) {
|
|
1546
|
+
const ret = Reflect.get(arg0, arg1);
|
|
1547
|
+
return ret;
|
|
1548
|
+
}, arguments); },
|
|
1549
|
+
__wbg_get_unchecked_288889d017702237: function(arg0, arg1) {
|
|
1550
|
+
const ret = arg0[arg1 >>> 0];
|
|
1551
|
+
return ret;
|
|
1552
|
+
},
|
|
1553
|
+
__wbg_instanceof_Uint8Array_828cef2aaacafc31: function(arg0) {
|
|
1554
|
+
let result;
|
|
1555
|
+
try {
|
|
1556
|
+
result = arg0 instanceof Uint8Array;
|
|
1557
|
+
} catch (_) {
|
|
1558
|
+
result = false;
|
|
1559
|
+
}
|
|
1560
|
+
const ret = result;
|
|
1561
|
+
return ret;
|
|
1562
|
+
},
|
|
1563
|
+
__wbg_isArray_e15a2ff68ffdbef2: function(arg0) {
|
|
1564
|
+
const ret = Array.isArray(arg0);
|
|
1565
|
+
return ret;
|
|
1566
|
+
},
|
|
1366
1567
|
__wbg_keys_440be172f17c0265: function(arg0) {
|
|
1367
1568
|
const ret = Object.keys(arg0);
|
|
1368
1569
|
return ret;
|
|
1369
1570
|
},
|
|
1571
|
+
__wbg_length_7f3c00c40364105e: function(arg0) {
|
|
1572
|
+
const ret = arg0.length;
|
|
1573
|
+
return ret;
|
|
1574
|
+
},
|
|
1575
|
+
__wbg_length_d4bdea10311bd9cf: function(arg0) {
|
|
1576
|
+
const ret = arg0.length;
|
|
1577
|
+
return ret;
|
|
1578
|
+
},
|
|
1370
1579
|
__wbg_new_617a8cdb8bb1130e: function() {
|
|
1371
1580
|
const ret = new Object();
|
|
1372
1581
|
return ret;
|
|
1373
1582
|
},
|
|
1583
|
+
__wbg_new_ee2291f50781bf1d: function() {
|
|
1584
|
+
const ret = new Array();
|
|
1585
|
+
return ret;
|
|
1586
|
+
},
|
|
1374
1587
|
__wbg_new_from_slice_9a868026ffa4208a: function(arg0, arg1) {
|
|
1375
1588
|
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
1376
1589
|
return ret;
|
|
@@ -1383,6 +1596,13 @@ function __wbg_get_imports() {
|
|
|
1383
1596
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
1384
1597
|
return ret;
|
|
1385
1598
|
}, arguments); },
|
|
1599
|
+
__wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
|
|
1600
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
1601
|
+
},
|
|
1602
|
+
__wbg_push_2baf45db356cf468: function(arg0, arg1) {
|
|
1603
|
+
const ret = arg0.push(arg1);
|
|
1604
|
+
return ret;
|
|
1605
|
+
},
|
|
1386
1606
|
__wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1387
1607
|
const ret = Reflect.set(arg0, arg1, arg2);
|
|
1388
1608
|
return ret;
|
|
@@ -1398,6 +1618,10 @@ function __wbg_get_imports() {
|
|
|
1398
1618
|
const ret = JSON.stringify(arg0);
|
|
1399
1619
|
return ret;
|
|
1400
1620
|
}, arguments); },
|
|
1621
|
+
__wbg_wasmdocument_new: function(arg0) {
|
|
1622
|
+
const ret = WasmDocument.__wrap(arg0);
|
|
1623
|
+
return ret;
|
|
1624
|
+
},
|
|
1401
1625
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
1402
1626
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1403
1627
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
Binary file
|