@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_text.js
CHANGED
|
@@ -75,6 +75,30 @@ export class WasmBuilder {
|
|
|
75
75
|
}
|
|
76
76
|
return WasmDocument.__wrap(ret[0]);
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Lays `document` out as tagged pages that flow, after any pages already added, filled from
|
|
80
|
+
* `options.data` first when it is given. The document's profiles are the builder's to set
|
|
81
|
+
* (`profiles` in its options); its warnings are the finished document's.
|
|
82
|
+
*
|
|
83
|
+
* # Errors
|
|
84
|
+
* `builder-finished`; `unknown-option`, `invalid-argument`; `invalid-document` with the JSON
|
|
85
|
+
* Pointer at fault and the closest keys in `didYouMean`; `template-data-missing`,
|
|
86
|
+
* `template-data-type`, `template-too-large`; `unknown-font` and `unknown-image` for a name
|
|
87
|
+
* `resources` lacks; `missing-glyph`, `flow-content-too-large`.
|
|
88
|
+
* @param {unknown} document
|
|
89
|
+
* @param {WasmFlowResources} resources
|
|
90
|
+
* @param {FlowOptionsInit | undefined} options
|
|
91
|
+
* @returns {FlowReportJs}
|
|
92
|
+
*/
|
|
93
|
+
flow(document, resources, options) {
|
|
94
|
+
_assertClass(resources, WasmFlowResources);
|
|
95
|
+
let ret;
|
|
96
|
+
ret = wasm.wasmbuilder_flow(this.__wbg_ptr, document, resources.__wbg_ptr, options);
|
|
97
|
+
if (ret[2]) {
|
|
98
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
99
|
+
}
|
|
100
|
+
return takeFromExternrefTable0(ret[0]);
|
|
101
|
+
}
|
|
78
102
|
/**
|
|
79
103
|
* Loads a font from its bytes (TrueType or OpenType/CFF) and registers it; it is
|
|
80
104
|
* subset to the glyphs drawn.
|
|
@@ -287,6 +311,48 @@ export class WasmDocument {
|
|
|
287
311
|
wasm.__wbg_wasmdocument_free(ptr, 0);
|
|
288
312
|
|
|
289
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* Adds another PDF as a source document: `{ id, pages }`, its ID (64 hex digits, the
|
|
316
|
+
* SHA-256 of `bytes`) and its page IDs in order. An encrypted one opens with `password`,
|
|
317
|
+
* which no op ever holds.
|
|
318
|
+
*
|
|
319
|
+
* # Errors
|
|
320
|
+
* `wrong-password`, `password-required`, and the errors of a file that doesn't open.
|
|
321
|
+
* @param {Uint8Array} bytes
|
|
322
|
+
* @param {string | null} [password]
|
|
323
|
+
* @returns {{ id: string; pages: string[] }}
|
|
324
|
+
*/
|
|
325
|
+
addSource(bytes, password) {
|
|
326
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
327
|
+
const len0 = WASM_VECTOR_LEN;
|
|
328
|
+
var ptr1 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
329
|
+
var len1 = WASM_VECTOR_LEN;
|
|
330
|
+
let ret;
|
|
331
|
+
ret = wasm.wasmdocument_addSource(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
332
|
+
if (ret[2]) {
|
|
333
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
334
|
+
}
|
|
335
|
+
return takeFromExternrefTable0(ret[0]);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Makes `bytes`, the whole output of `saveCopy`, the document's saved file (it rebases onto
|
|
339
|
+
* them), once they are written where the document lives; `historyCleared` is the copy's
|
|
340
|
+
* report's.
|
|
341
|
+
*
|
|
342
|
+
* # Errors
|
|
343
|
+
* `nested-transaction`, `saved-not-rebased`; `not-rebased` when `bytes` can't be read.
|
|
344
|
+
* @param {Uint8Array} bytes
|
|
345
|
+
* @param {boolean} historyCleared
|
|
346
|
+
*/
|
|
347
|
+
adoptCopy(bytes, historyCleared) {
|
|
348
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
349
|
+
const len0 = WASM_VECTOR_LEN;
|
|
350
|
+
let ret;
|
|
351
|
+
ret = wasm.wasmdocument_adoptCopy(this.__wbg_ptr, ptr0, len0, historyCleared);
|
|
352
|
+
if (ret[1]) {
|
|
353
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
290
356
|
/**
|
|
291
357
|
* Applies an op log (`{ "v": 1, "ops": [ … ] }`) as one transaction.
|
|
292
358
|
*
|
|
@@ -322,6 +388,24 @@ export class WasmDocument {
|
|
|
322
388
|
}
|
|
323
389
|
return takeFromExternrefTable0(ret[0]);
|
|
324
390
|
}
|
|
391
|
+
/**
|
|
392
|
+
* `view` (page space) on page `page` as the destination the outline and named-destination
|
|
393
|
+
* ops take, in the page's user space (the extract and text modules).
|
|
394
|
+
*
|
|
395
|
+
* # Errors
|
|
396
|
+
* `invalid-argument` for a view that isn't one; `page-index-out-of-range`; reading errors.
|
|
397
|
+
* @param {number} page
|
|
398
|
+
* @param {TargetViewJs} view
|
|
399
|
+
* @returns {ExplicitDestination}
|
|
400
|
+
*/
|
|
401
|
+
destinationAt(page, view) {
|
|
402
|
+
let ret;
|
|
403
|
+
ret = wasm.wasmdocument_destinationAt(this.__wbg_ptr, page, view);
|
|
404
|
+
if (ret[2]) {
|
|
405
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
406
|
+
}
|
|
407
|
+
return takeFromExternrefTable0(ret[0]);
|
|
408
|
+
}
|
|
325
409
|
/**
|
|
326
410
|
* An extraction stepped a page at a time, whose models the host runs: each step returns
|
|
327
411
|
* its progress, with the result it waits for under `request` (render that page at `dpi`,
|
|
@@ -341,6 +425,23 @@ export class WasmDocument {
|
|
|
341
425
|
}
|
|
342
426
|
return WasmExtractJob.__wrap(ret[0]);
|
|
343
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* A new document of `pages` of this one, in the order given.
|
|
430
|
+
*
|
|
431
|
+
* # Errors
|
|
432
|
+
* `invalid-argument` for a value that isn't a list of page IDs, `unknown-page`; reading
|
|
433
|
+
* errors.
|
|
434
|
+
* @param {string[]} pages
|
|
435
|
+
* @returns {WasmDocument}
|
|
436
|
+
*/
|
|
437
|
+
extractPages(pages) {
|
|
438
|
+
let ret;
|
|
439
|
+
ret = wasm.wasmdocument_extractPages(this.__wbg_ptr, pages);
|
|
440
|
+
if (ret[2]) {
|
|
441
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
442
|
+
}
|
|
443
|
+
return WasmDocument.__wrap(ret[0]);
|
|
444
|
+
}
|
|
344
445
|
/**
|
|
345
446
|
* The document's text for retrieval and LLMs, as one string: Markdown, plain text, the
|
|
346
447
|
* `laminapdf.extract/1` JSON, or the chunks as a JSON array (the extract and text modules).
|
|
@@ -394,6 +495,21 @@ export class WasmDocument {
|
|
|
394
495
|
}
|
|
395
496
|
return takeFromExternrefTable0(ret[0]);
|
|
396
497
|
}
|
|
498
|
+
/**
|
|
499
|
+
* How the document asks to be shown when it opens (the extract and text modules).
|
|
500
|
+
*
|
|
501
|
+
* # Errors
|
|
502
|
+
* `data-pending` and the reading errors.
|
|
503
|
+
* @returns {InitialViewJs}
|
|
504
|
+
*/
|
|
505
|
+
initialView() {
|
|
506
|
+
let ret;
|
|
507
|
+
ret = wasm.wasmdocument_initialView(this.__wbg_ptr);
|
|
508
|
+
if (ret[2]) {
|
|
509
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
510
|
+
}
|
|
511
|
+
return takeFromExternrefTable0(ret[0]);
|
|
512
|
+
}
|
|
397
513
|
/**
|
|
398
514
|
* Whether the file is encrypted (it opened with its password, or the empty one).
|
|
399
515
|
* @returns {boolean}
|
|
@@ -418,6 +534,42 @@ export class WasmDocument {
|
|
|
418
534
|
}
|
|
419
535
|
return ret[0] !== 0;
|
|
420
536
|
}
|
|
537
|
+
/**
|
|
538
|
+
* A new document of `inputs` (each `{ bytes, password?, title? }`) one after another,
|
|
539
|
+
* with their bookmarks, named destinations, form fields, layers and page labels; `options`
|
|
540
|
+
* as `mergeDocuments`' (`outline`, `fields`).
|
|
541
|
+
*
|
|
542
|
+
* # Errors
|
|
543
|
+
* `invalid-argument` / `unknown-option` for bad values, `wrong-password`,
|
|
544
|
+
* `password-required`, and the errors of a file that doesn't open.
|
|
545
|
+
* @param {{ bytes: Uint8Array; password?: string; title?: string }[]} inputs
|
|
546
|
+
* @param {MergeOptions | undefined} options
|
|
547
|
+
* @returns {WasmDocument}
|
|
548
|
+
*/
|
|
549
|
+
static merge(inputs, options) {
|
|
550
|
+
let ret;
|
|
551
|
+
ret = wasm.wasmdocument_merge(inputs, options);
|
|
552
|
+
if (ret[2]) {
|
|
553
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
554
|
+
}
|
|
555
|
+
return WasmDocument.__wrap(ret[0]);
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* The document's metadata, read from Info and XMP together, with the fields where they
|
|
559
|
+
* disagree.
|
|
560
|
+
*
|
|
561
|
+
* # Errors
|
|
562
|
+
* Reading errors.
|
|
563
|
+
* @returns {DocumentMetadata}
|
|
564
|
+
*/
|
|
565
|
+
metadata() {
|
|
566
|
+
let ret;
|
|
567
|
+
ret = wasm.wasmdocument_metadata(this.__wbg_ptr);
|
|
568
|
+
if (ret[2]) {
|
|
569
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
570
|
+
}
|
|
571
|
+
return takeFromExternrefTable0(ret[0]);
|
|
572
|
+
}
|
|
421
573
|
/**
|
|
422
574
|
* The named destination `name`, or `undefined` when the document has none by that name or
|
|
423
575
|
* it names no page here (the extract and text modules).
|
|
@@ -437,6 +589,21 @@ export class WasmDocument {
|
|
|
437
589
|
}
|
|
438
590
|
return takeFromExternrefTable0(ret[0]);
|
|
439
591
|
}
|
|
592
|
+
/**
|
|
593
|
+
* Every named destination, sorted by name (the extract and text modules).
|
|
594
|
+
*
|
|
595
|
+
* # Errors
|
|
596
|
+
* `data-pending` and the reading errors.
|
|
597
|
+
* @returns {NamedDestinationJs[]}
|
|
598
|
+
*/
|
|
599
|
+
namedDestinations() {
|
|
600
|
+
let ret;
|
|
601
|
+
ret = wasm.wasmdocument_namedDestinations(this.__wbg_ptr);
|
|
602
|
+
if (ret[2]) {
|
|
603
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
604
|
+
}
|
|
605
|
+
return takeFromExternrefTable0(ret[0]);
|
|
606
|
+
}
|
|
440
607
|
/**
|
|
441
608
|
* Opens a document from its bytes.
|
|
442
609
|
*
|
|
@@ -493,6 +660,23 @@ export class WasmDocument {
|
|
|
493
660
|
}
|
|
494
661
|
return takeFromExternrefTable0(ret[0]);
|
|
495
662
|
}
|
|
663
|
+
/**
|
|
664
|
+
* The annotations on page `index`, in the order of its `/Annots`, every subtype included
|
|
665
|
+
* (the extract and text modules).
|
|
666
|
+
*
|
|
667
|
+
* # Errors
|
|
668
|
+
* `page-index-out-of-range`, `data-pending` and the reading errors.
|
|
669
|
+
* @param {number} index
|
|
670
|
+
* @returns {PageAnnotationJs[]}
|
|
671
|
+
*/
|
|
672
|
+
pageAnnotations(index) {
|
|
673
|
+
let ret;
|
|
674
|
+
ret = wasm.wasmdocument_pageAnnotations(this.__wbg_ptr, index);
|
|
675
|
+
if (ret[2]) {
|
|
676
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
677
|
+
}
|
|
678
|
+
return takeFromExternrefTable0(ret[0]);
|
|
679
|
+
}
|
|
496
680
|
/**
|
|
497
681
|
* A handle on the page with `id` (`p12.0`).
|
|
498
682
|
*
|
|
@@ -589,6 +773,22 @@ export class WasmDocument {
|
|
|
589
773
|
}
|
|
590
774
|
return WasmPage.__wrap(ret[0]);
|
|
591
775
|
}
|
|
776
|
+
/**
|
|
777
|
+
* How a save with `options` would go, without saving.
|
|
778
|
+
*
|
|
779
|
+
* # Errors
|
|
780
|
+
* `invalid-argument` / `unknown-option` for bad options; reading errors.
|
|
781
|
+
* @param {SaveOptionsInit | undefined} options
|
|
782
|
+
* @returns {PlannedSaveJs}
|
|
783
|
+
*/
|
|
784
|
+
plan(options) {
|
|
785
|
+
let ret;
|
|
786
|
+
ret = wasm.wasmdocument_plan(this.__wbg_ptr, options);
|
|
787
|
+
if (ret[2]) {
|
|
788
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
789
|
+
}
|
|
790
|
+
return takeFromExternrefTable0(ret[0]);
|
|
791
|
+
}
|
|
592
792
|
/**
|
|
593
793
|
* The document's properties (the extract and text modules). Reads every object once.
|
|
594
794
|
*
|
|
@@ -636,6 +836,23 @@ export class WasmDocument {
|
|
|
636
836
|
}
|
|
637
837
|
return takeFromExternrefTable0(ret[0]);
|
|
638
838
|
}
|
|
839
|
+
/**
|
|
840
|
+
* Writes what `save` would and leaves the document as it was: not rebased, its changes
|
|
841
|
+
* still unsaved, the save-time stamp in the copy only (Save a copy).
|
|
842
|
+
*
|
|
843
|
+
* # Errors
|
|
844
|
+
* As `save`; the document is unchanged either way.
|
|
845
|
+
* @param {SaveOptionsInit | undefined} options
|
|
846
|
+
* @returns {{ bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs }}
|
|
847
|
+
*/
|
|
848
|
+
saveCopy(options) {
|
|
849
|
+
let ret;
|
|
850
|
+
ret = wasm.wasmdocument_saveCopy(this.__wbg_ptr, options);
|
|
851
|
+
if (ret[2]) {
|
|
852
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
853
|
+
}
|
|
854
|
+
return takeFromExternrefTable0(ret[0]);
|
|
855
|
+
}
|
|
639
856
|
/**
|
|
640
857
|
* A save as a job, stepped with a budget of work units (ADR 0028 §3, §4).
|
|
641
858
|
*
|
|
@@ -668,6 +885,26 @@ export class WasmDocument {
|
|
|
668
885
|
}
|
|
669
886
|
return takeFromExternrefTable0(ret[0]);
|
|
670
887
|
}
|
|
888
|
+
/**
|
|
889
|
+
* This document cut into new ones: `{ count: n }` parts of `n` pages, `{ ranges: [[id, …],
|
|
890
|
+
* …] }` one part per list of page IDs, or `{ bookmarks: level }` a part from each bookmark
|
|
891
|
+
* at that depth (1: the top level). Each part carries what its pages reach and the
|
|
892
|
+
* bookmarks that go to them.
|
|
893
|
+
*
|
|
894
|
+
* # Errors
|
|
895
|
+
* `invalid-argument` / `unknown-option` for a value that isn't one of those, `unknown-page`,
|
|
896
|
+
* `no-pages-left` for an empty list; reading errors.
|
|
897
|
+
* @param {{ readonly count: number } | { readonly ranges: readonly (readonly string[])[] } | { readonly bookmarks: number }} by
|
|
898
|
+
* @returns {WasmDocument[]}
|
|
899
|
+
*/
|
|
900
|
+
split(by) {
|
|
901
|
+
let ret;
|
|
902
|
+
ret = wasm.wasmdocument_split(this.__wbg_ptr, by);
|
|
903
|
+
if (ret[2]) {
|
|
904
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
905
|
+
}
|
|
906
|
+
return takeFromExternrefTable0(ret[0]);
|
|
907
|
+
}
|
|
671
908
|
/**
|
|
672
909
|
* The structure tree's top-level elements in reading order, or `undefined` without one (the
|
|
673
910
|
* extract and text modules, beside `WasmPage.text`, whose runs it links by MCID).
|
|
@@ -684,6 +921,21 @@ export class WasmDocument {
|
|
|
684
921
|
}
|
|
685
922
|
return takeFromExternrefTable0(ret[0]);
|
|
686
923
|
}
|
|
924
|
+
/**
|
|
925
|
+
* The document's article threads; empty without any (the extract and text modules).
|
|
926
|
+
*
|
|
927
|
+
* # Errors
|
|
928
|
+
* `data-pending` and the reading errors.
|
|
929
|
+
* @returns {ThreadJs[]}
|
|
930
|
+
*/
|
|
931
|
+
threads() {
|
|
932
|
+
let ret;
|
|
933
|
+
ret = wasm.wasmdocument_threads(this.__wbg_ptr);
|
|
934
|
+
if (ret[2]) {
|
|
935
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
936
|
+
}
|
|
937
|
+
return takeFromExternrefTable0(ret[0]);
|
|
938
|
+
}
|
|
687
939
|
/**
|
|
688
940
|
* Undoes the newest transaction: how it went and the pages it touched; `undefined` when
|
|
689
941
|
* there is nothing to undo.
|
|
@@ -709,6 +961,37 @@ export class WasmDocument {
|
|
|
709
961
|
ret = wasm.wasmdocument_warnings(this.__wbg_ptr);
|
|
710
962
|
return WasmWarningCursor.__wrap(ret);
|
|
711
963
|
}
|
|
964
|
+
/**
|
|
965
|
+
* The signature restrictions `op` would break if it were applied and saved.
|
|
966
|
+
*
|
|
967
|
+
* # Errors
|
|
968
|
+
* `invalid-argument` for a value that isn't an op; reading errors.
|
|
969
|
+
* @param {Op} op
|
|
970
|
+
* @returns {ViolationJs[]}
|
|
971
|
+
*/
|
|
972
|
+
wouldViolate(op) {
|
|
973
|
+
let ret;
|
|
974
|
+
ret = wasm.wasmdocument_wouldViolate(this.__wbg_ptr, op);
|
|
975
|
+
if (ret[2]) {
|
|
976
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
977
|
+
}
|
|
978
|
+
return takeFromExternrefTable0(ret[0]);
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* The document's XMP packet as text, with the edits made so far.
|
|
982
|
+
*
|
|
983
|
+
* # Errors
|
|
984
|
+
* Reading errors.
|
|
985
|
+
* @returns {XmpTextJs}
|
|
986
|
+
*/
|
|
987
|
+
xmpPacket() {
|
|
988
|
+
let ret;
|
|
989
|
+
ret = wasm.wasmdocument_xmpPacket(this.__wbg_ptr);
|
|
990
|
+
if (ret[2]) {
|
|
991
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
992
|
+
}
|
|
993
|
+
return takeFromExternrefTable0(ret[0]);
|
|
994
|
+
}
|
|
712
995
|
}
|
|
713
996
|
if (Symbol.dispose) WasmDocument.prototype[Symbol.dispose] = WasmDocument.prototype.free;
|
|
714
997
|
|
|
@@ -779,6 +1062,57 @@ export class WasmExtractJob {
|
|
|
779
1062
|
}
|
|
780
1063
|
if (Symbol.dispose) WasmExtractJob.prototype[Symbol.dispose] = WasmExtractJob.prototype.free;
|
|
781
1064
|
|
|
1065
|
+
/**
|
|
1066
|
+
* The fonts and images a document names, by the names it gives them.
|
|
1067
|
+
*/
|
|
1068
|
+
export class WasmFlowResources {
|
|
1069
|
+
__destroy_into_raw() {
|
|
1070
|
+
const ptr = this.__wbg_ptr;
|
|
1071
|
+
this.__wbg_ptr = 0;
|
|
1072
|
+
WasmFlowResourcesFinalization.unregister(this);
|
|
1073
|
+
return ptr;
|
|
1074
|
+
}
|
|
1075
|
+
free() {
|
|
1076
|
+
const ptr = this.__destroy_into_raw();
|
|
1077
|
+
wasm.__wbg_wasmflowresources_free(ptr, 0);
|
|
1078
|
+
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* `font` for the styles that name `name`; the same name again replaces it.
|
|
1082
|
+
* @param {string} name
|
|
1083
|
+
* @param {WasmFont} font
|
|
1084
|
+
*/
|
|
1085
|
+
font(name, font) {
|
|
1086
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1087
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1088
|
+
_assertClass(font, WasmFont);
|
|
1089
|
+
wasm.wasmflowresources_font(this.__wbg_ptr, ptr0, len0, font.__wbg_ptr);
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* `image` for the figures that name `name`; the same name again replaces it.
|
|
1093
|
+
* @param {string} name
|
|
1094
|
+
* @param {WasmImage} image
|
|
1095
|
+
*/
|
|
1096
|
+
image(name, image) {
|
|
1097
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1098
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1099
|
+
_assertClass(image, WasmImage);
|
|
1100
|
+
wasm.wasmflowresources_image(this.__wbg_ptr, ptr0, len0, image.__wbg_ptr);
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* No fonts and no images.
|
|
1104
|
+
*/
|
|
1105
|
+
constructor() {
|
|
1106
|
+
let ret;
|
|
1107
|
+
ret = wasm.wasmflowresources_new();
|
|
1108
|
+
this.__wbg_ptr = ret;
|
|
1109
|
+
Object.defineProperty(this, '__wbg_inst', { value: __wbg_instance_id, writable: true });
|
|
1110
|
+
WasmFlowResourcesFinalization.register(this, { ptr: ret, instance: __wbg_instance_id }, this);
|
|
1111
|
+
return this;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
if (Symbol.dispose) WasmFlowResources.prototype[Symbol.dispose] = WasmFlowResources.prototype.free;
|
|
1115
|
+
|
|
782
1116
|
/**
|
|
783
1117
|
* A font registered with a [`WasmBuilder`].
|
|
784
1118
|
*/
|
|
@@ -948,6 +1282,44 @@ export class WasmImage {
|
|
|
948
1282
|
}
|
|
949
1283
|
if (Symbol.dispose) WasmImage.prototype[Symbol.dispose] = WasmImage.prototype.free;
|
|
950
1284
|
|
|
1285
|
+
/**
|
|
1286
|
+
* The images of [`images_to_pdf`], in page order. Images are JavaScript-owned objects, which a
|
|
1287
|
+
* record can't carry, so they are added one by one.
|
|
1288
|
+
*/
|
|
1289
|
+
export class WasmImageList {
|
|
1290
|
+
__destroy_into_raw() {
|
|
1291
|
+
const ptr = this.__wbg_ptr;
|
|
1292
|
+
this.__wbg_ptr = 0;
|
|
1293
|
+
WasmImageListFinalization.unregister(this);
|
|
1294
|
+
return ptr;
|
|
1295
|
+
}
|
|
1296
|
+
free() {
|
|
1297
|
+
const ptr = this.__destroy_into_raw();
|
|
1298
|
+
wasm.__wbg_wasmimagelist_free(ptr, 0);
|
|
1299
|
+
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* An empty list.
|
|
1303
|
+
*/
|
|
1304
|
+
constructor() {
|
|
1305
|
+
let ret;
|
|
1306
|
+
ret = wasm.wasmimagelist_new();
|
|
1307
|
+
this.__wbg_ptr = ret;
|
|
1308
|
+
Object.defineProperty(this, '__wbg_inst', { value: __wbg_instance_id, writable: true });
|
|
1309
|
+
WasmImageListFinalization.register(this, { ptr: ret, instance: __wbg_instance_id }, this);
|
|
1310
|
+
return this;
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Adds `image` as the next page. The image stays usable: the list holds its own copy.
|
|
1314
|
+
* @param {WasmImage} image
|
|
1315
|
+
*/
|
|
1316
|
+
push(image) {
|
|
1317
|
+
_assertClass(image, WasmImage);
|
|
1318
|
+
wasm.wasmimagelist_push(this.__wbg_ptr, image.__wbg_ptr);
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
if (Symbol.dispose) WasmImageList.prototype[Symbol.dispose] = WasmImageList.prototype.free;
|
|
1322
|
+
|
|
951
1323
|
/**
|
|
952
1324
|
* The fonts and images of a Markdown build, by role and by the target the Markdown names.
|
|
953
1325
|
*/
|
|
@@ -1814,6 +2186,27 @@ export function hasText() {
|
|
|
1814
2186
|
return ret !== 0;
|
|
1815
2187
|
}
|
|
1816
2188
|
|
|
2189
|
+
/**
|
|
2190
|
+
* A new document with one page per image of `images`, in order: a JPEG embedded as it is, a PNG
|
|
2191
|
+
* with its transparency, each drawn the way up its EXIF orientation says.
|
|
2192
|
+
*
|
|
2193
|
+
* # Errors
|
|
2194
|
+
* `invalid-geometry` for no images, a negative margin or resolution, or a page too small for its
|
|
2195
|
+
* margins; `unknown-option`, `invalid-argument` for bad options.
|
|
2196
|
+
* @param {WasmImageList} images
|
|
2197
|
+
* @param {ImagesOptionsInit | undefined} options
|
|
2198
|
+
* @returns {WasmDocument}
|
|
2199
|
+
*/
|
|
2200
|
+
export function imagesToPdf(images, options) {
|
|
2201
|
+
_assertClass(images, WasmImageList);
|
|
2202
|
+
let ret;
|
|
2203
|
+
ret = wasm.imagesToPdf(images.__wbg_ptr, options);
|
|
2204
|
+
if (ret[2]) {
|
|
2205
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2206
|
+
}
|
|
2207
|
+
return WasmDocument.__wrap(ret[0]);
|
|
2208
|
+
}
|
|
2209
|
+
|
|
1817
2210
|
/**
|
|
1818
2211
|
* The crate version (`@laminapdf/wasm`'s).
|
|
1819
2212
|
* @returns {string}
|
|
@@ -1858,14 +2251,48 @@ function __wbg_get_imports() {
|
|
|
1858
2251
|
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
1859
2252
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1860
2253
|
},
|
|
2254
|
+
__wbg_get_31af05bd4842a84f: function() { return handleError(function (arg0, arg1) {
|
|
2255
|
+
const ret = Reflect.get(arg0, arg1);
|
|
2256
|
+
return ret;
|
|
2257
|
+
}, arguments); },
|
|
2258
|
+
__wbg_get_unchecked_288889d017702237: function(arg0, arg1) {
|
|
2259
|
+
const ret = arg0[arg1 >>> 0];
|
|
2260
|
+
return ret;
|
|
2261
|
+
},
|
|
2262
|
+
__wbg_instanceof_Uint8Array_828cef2aaacafc31: function(arg0) {
|
|
2263
|
+
let result;
|
|
2264
|
+
try {
|
|
2265
|
+
result = arg0 instanceof Uint8Array;
|
|
2266
|
+
} catch (_) {
|
|
2267
|
+
result = false;
|
|
2268
|
+
}
|
|
2269
|
+
const ret = result;
|
|
2270
|
+
return ret;
|
|
2271
|
+
},
|
|
2272
|
+
__wbg_isArray_e15a2ff68ffdbef2: function(arg0) {
|
|
2273
|
+
const ret = Array.isArray(arg0);
|
|
2274
|
+
return ret;
|
|
2275
|
+
},
|
|
1861
2276
|
__wbg_keys_440be172f17c0265: function(arg0) {
|
|
1862
2277
|
const ret = Object.keys(arg0);
|
|
1863
2278
|
return ret;
|
|
1864
2279
|
},
|
|
2280
|
+
__wbg_length_7f3c00c40364105e: function(arg0) {
|
|
2281
|
+
const ret = arg0.length;
|
|
2282
|
+
return ret;
|
|
2283
|
+
},
|
|
2284
|
+
__wbg_length_d4bdea10311bd9cf: function(arg0) {
|
|
2285
|
+
const ret = arg0.length;
|
|
2286
|
+
return ret;
|
|
2287
|
+
},
|
|
1865
2288
|
__wbg_new_617a8cdb8bb1130e: function() {
|
|
1866
2289
|
const ret = new Object();
|
|
1867
2290
|
return ret;
|
|
1868
2291
|
},
|
|
2292
|
+
__wbg_new_ee2291f50781bf1d: function() {
|
|
2293
|
+
const ret = new Array();
|
|
2294
|
+
return ret;
|
|
2295
|
+
},
|
|
1869
2296
|
__wbg_new_from_slice_37a3c3a194266cb8: function(arg0, arg1) {
|
|
1870
2297
|
const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
|
|
1871
2298
|
return ret;
|
|
@@ -1886,6 +2313,13 @@ function __wbg_get_imports() {
|
|
|
1886
2313
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
1887
2314
|
return ret;
|
|
1888
2315
|
}, arguments); },
|
|
2316
|
+
__wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
|
|
2317
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
2318
|
+
},
|
|
2319
|
+
__wbg_push_2baf45db356cf468: function(arg0, arg1) {
|
|
2320
|
+
const ret = arg0.push(arg1);
|
|
2321
|
+
return ret;
|
|
2322
|
+
},
|
|
1889
2323
|
__wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1890
2324
|
const ret = Reflect.set(arg0, arg1, arg2);
|
|
1891
2325
|
return ret;
|
|
@@ -1901,6 +2335,10 @@ function __wbg_get_imports() {
|
|
|
1901
2335
|
const ret = JSON.stringify(arg0);
|
|
1902
2336
|
return ret;
|
|
1903
2337
|
}, arguments); },
|
|
2338
|
+
__wbg_wasmdocument_new: function(arg0) {
|
|
2339
|
+
const ret = WasmDocument.__wrap(arg0);
|
|
2340
|
+
return ret;
|
|
2341
|
+
},
|
|
1904
2342
|
__wbindgen_generic_0000000000000001: function(arg0) {
|
|
1905
2343
|
// Cast intrinsic for `F64 -> Externref`.
|
|
1906
2344
|
const ret = arg0;
|
|
@@ -1951,6 +2389,11 @@ const WasmExtractJobFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
1951
2389
|
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
1952
2390
|
if (instance === __wbg_instance_id) wasm.__wbg_wasmextractjob_free(ptr, 1);
|
|
1953
2391
|
});
|
|
2392
|
+
const WasmFlowResourcesFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2393
|
+
? { register: () => {}, unregister: () => {} }
|
|
2394
|
+
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
2395
|
+
if (instance === __wbg_instance_id) wasm.__wbg_wasmflowresources_free(ptr, 1);
|
|
2396
|
+
});
|
|
1954
2397
|
const WasmFontFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1955
2398
|
? { register: () => {}, unregister: () => {} }
|
|
1956
2399
|
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
@@ -1961,6 +2404,11 @@ const WasmImageFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
1961
2404
|
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
1962
2405
|
if (instance === __wbg_instance_id) wasm.__wbg_wasmimage_free(ptr, 1);
|
|
1963
2406
|
});
|
|
2407
|
+
const WasmImageListFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2408
|
+
? { register: () => {}, unregister: () => {} }
|
|
2409
|
+
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
2410
|
+
if (instance === __wbg_instance_id) wasm.__wbg_wasmimagelist_free(ptr, 1);
|
|
2411
|
+
});
|
|
1964
2412
|
const WasmMarkdownOptionsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1965
2413
|
? { register: () => {}, unregister: () => {} }
|
|
1966
2414
|
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
Binary file
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A TIFF file being written, one page per [`TiffFile::add_page`].
|
|
6
|
+
*/
|
|
7
|
+
export class TiffFile {
|
|
8
|
+
free(): void;
|
|
9
|
+
[Symbol.dispose](): void;
|
|
10
|
+
/**
|
|
11
|
+
* Adds a page of `width` × `height` straight RGBA pixels, row by row, drawn at `dpi`.
|
|
12
|
+
*
|
|
13
|
+
* # Errors
|
|
14
|
+
* `invalid-argument` when `rgba` isn't `width × height × 4` bytes, `dpi` isn't
|
|
15
|
+
* positive, or the file is finished; `export-failed` if the encoder fails.
|
|
16
|
+
*/
|
|
17
|
+
addPage(width: number, height: number, rgba: Uint8Array, dpi: number): void;
|
|
18
|
+
/**
|
|
19
|
+
* The file's bytes. The file is finished: it takes no more pages.
|
|
20
|
+
*
|
|
21
|
+
* # Errors
|
|
22
|
+
* `invalid-argument` when it was already finished.
|
|
23
|
+
*/
|
|
24
|
+
finish(): Uint8Array;
|
|
25
|
+
/**
|
|
26
|
+
* An empty file.
|
|
27
|
+
*
|
|
28
|
+
* # Errors
|
|
29
|
+
* `export-failed` if the encoder can't write the file's header.
|
|
30
|
+
*/
|
|
31
|
+
constructor();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
35
|
+
|
|
36
|
+
export interface InitOutput {
|
|
37
|
+
readonly memory: WebAssembly.Memory;
|
|
38
|
+
readonly __wbg_tifffile_free: (a: number, b: number) => void;
|
|
39
|
+
readonly tifffile_addPage: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
40
|
+
readonly tifffile_finish: (a: number) => [number, number, number, number];
|
|
41
|
+
readonly tifffile_new: () => [number, number, number];
|
|
42
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
43
|
+
readonly __externref_table_alloc: () => number;
|
|
44
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
45
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
46
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
47
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
48
|
+
readonly __wbindgen_start: () => void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
55
|
+
* a precompiled `WebAssembly.Module`.
|
|
56
|
+
*
|
|
57
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
58
|
+
*
|
|
59
|
+
* @returns {InitOutput}
|
|
60
|
+
*/
|
|
61
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
65
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
66
|
+
*
|
|
67
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
68
|
+
*
|
|
69
|
+
* @returns {Promise<InitOutput>}
|
|
70
|
+
*/
|
|
71
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|