@laminapdf/wasm 0.2.0-alpha.4 → 0.2.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lamina_pdf_base.d.ts +30 -4
- package/dist/lamina_pdf_base.js +15 -4
- package/dist/lamina_pdf_base.wasm +0 -0
- package/dist/lamina_pdf_extract.d.ts +273 -4
- package/dist/lamina_pdf_extract.js +74 -4
- package/dist/lamina_pdf_extract.wasm +0 -0
- package/dist/lamina_pdf_render_hayro.d.ts +7 -4
- package/dist/lamina_pdf_render_hayro.js +10 -4
- package/dist/lamina_pdf_render_hayro.wasm +0 -0
- package/dist/lamina_pdf_text.d.ts +384 -4
- package/dist/lamina_pdf_text.js +154 -4
- package/dist/lamina_pdf_text.wasm +0 -0
- package/package.json +3 -3
package/dist/lamina_pdf_text.js
CHANGED
|
@@ -94,6 +94,25 @@ export class WasmBuilder {
|
|
|
94
94
|
}
|
|
95
95
|
return WasmFont.__wrap(ret[0]);
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Loads face `index` (from 0) of a font collection (`.ttc`, `.otc`) and registers it.
|
|
99
|
+
*
|
|
100
|
+
* # Errors
|
|
101
|
+
* `builder-finished`; `invalid-font`, `collection-index` (no such face), `font-not-embeddable`.
|
|
102
|
+
* @param {Uint8Array} bytes
|
|
103
|
+
* @param {number} index
|
|
104
|
+
* @returns {WasmFont}
|
|
105
|
+
*/
|
|
106
|
+
fontCollection(bytes, index) {
|
|
107
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
108
|
+
const len0 = WASM_VECTOR_LEN;
|
|
109
|
+
let ret;
|
|
110
|
+
ret = wasm.wasmbuilder_fontCollection(this.__wbg_ptr, ptr0, len0, index);
|
|
111
|
+
if (ret[2]) {
|
|
112
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
113
|
+
}
|
|
114
|
+
return WasmFont.__wrap(ret[0]);
|
|
115
|
+
}
|
|
97
116
|
/**
|
|
98
117
|
* The natural language (`/Lang`), a BCP 47 tag.
|
|
99
118
|
*
|
|
@@ -110,6 +129,31 @@ export class WasmBuilder {
|
|
|
110
129
|
throw takeFromExternrefTable0(ret[0]);
|
|
111
130
|
}
|
|
112
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Lays `markdown` out as tagged pages that flow, after any pages already added; its front
|
|
134
|
+
* matter's title, language, author and subject become the document's. Its warnings
|
|
135
|
+
* (`markdown-html-ignored`, `markdown-image-missing`, the flow's) are the finished
|
|
136
|
+
* document's.
|
|
137
|
+
*
|
|
138
|
+
* # Errors
|
|
139
|
+
* `builder-finished`; `unknown-option`, `invalid-argument`; `missing-glyph`,
|
|
140
|
+
* `flow-content-too-large`; `unknown-font` at `finish` for a font another builder registered.
|
|
141
|
+
* @param {string} markdown
|
|
142
|
+
* @param {WasmMarkdownOptions} resources
|
|
143
|
+
* @param {MarkdownOptionsInit | undefined} options
|
|
144
|
+
* @returns {MarkdownReportJs}
|
|
145
|
+
*/
|
|
146
|
+
markdown(markdown, resources, options) {
|
|
147
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
148
|
+
const len0 = WASM_VECTOR_LEN;
|
|
149
|
+
_assertClass(resources, WasmMarkdownOptions);
|
|
150
|
+
let ret;
|
|
151
|
+
ret = wasm.wasmbuilder_markdown(this.__wbg_ptr, ptr0, len0, resources.__wbg_ptr, options);
|
|
152
|
+
if (ret[2]) {
|
|
153
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
154
|
+
}
|
|
155
|
+
return takeFromExternrefTable0(ret[0]);
|
|
156
|
+
}
|
|
113
157
|
/**
|
|
114
158
|
* The metadata, written as the Info dictionary and an XMP packet.
|
|
115
159
|
*
|
|
@@ -350,6 +394,15 @@ export class WasmDocument {
|
|
|
350
394
|
}
|
|
351
395
|
return takeFromExternrefTable0(ret[0]);
|
|
352
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* Whether the file is encrypted (it opened with its password, or the empty one).
|
|
399
|
+
* @returns {boolean}
|
|
400
|
+
*/
|
|
401
|
+
isEncrypted() {
|
|
402
|
+
let ret;
|
|
403
|
+
ret = wasm.wasmdocument_isEncrypted(this.__wbg_ptr);
|
|
404
|
+
return ret !== 0;
|
|
405
|
+
}
|
|
353
406
|
/**
|
|
354
407
|
* Whether the document says it is tagged (`/MarkInfo /Marked true`; the extract and text modules).
|
|
355
408
|
*
|
|
@@ -504,6 +557,22 @@ export class WasmDocument {
|
|
|
504
557
|
}
|
|
505
558
|
return takeFromExternrefTable0(ret[0]);
|
|
506
559
|
}
|
|
560
|
+
/**
|
|
561
|
+
* The visible links on page `index`, in annotation order (the extract and text modules).
|
|
562
|
+
*
|
|
563
|
+
* # Errors
|
|
564
|
+
* `page-index-out-of-range`, `data-pending` and the reading errors.
|
|
565
|
+
* @param {number} index
|
|
566
|
+
* @returns {PageLinkJs[]}
|
|
567
|
+
*/
|
|
568
|
+
pageLinks(index) {
|
|
569
|
+
let ret;
|
|
570
|
+
ret = wasm.wasmdocument_pageLinks(this.__wbg_ptr, index);
|
|
571
|
+
if (ret[2]) {
|
|
572
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
573
|
+
}
|
|
574
|
+
return takeFromExternrefTable0(ret[0]);
|
|
575
|
+
}
|
|
507
576
|
/**
|
|
508
577
|
* A handle on page `index` that follows the page by its ID (F2).
|
|
509
578
|
*
|
|
@@ -520,6 +589,21 @@ export class WasmDocument {
|
|
|
520
589
|
}
|
|
521
590
|
return WasmPage.__wrap(ret[0]);
|
|
522
591
|
}
|
|
592
|
+
/**
|
|
593
|
+
* The document's properties (the extract and text modules). Reads every object once.
|
|
594
|
+
*
|
|
595
|
+
* # Errors
|
|
596
|
+
* `data-pending` and the reading errors.
|
|
597
|
+
* @returns {PropertiesJs}
|
|
598
|
+
*/
|
|
599
|
+
properties() {
|
|
600
|
+
let ret;
|
|
601
|
+
ret = wasm.wasmdocument_properties(this.__wbg_ptr);
|
|
602
|
+
if (ret[2]) {
|
|
603
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
604
|
+
}
|
|
605
|
+
return takeFromExternrefTable0(ret[0]);
|
|
606
|
+
}
|
|
523
607
|
/**
|
|
524
608
|
* Rebases onto `bytes`, the output of a save whose rebase failed (`not-rebased`).
|
|
525
609
|
*
|
|
@@ -537,11 +621,12 @@ export class WasmDocument {
|
|
|
537
621
|
}
|
|
538
622
|
}
|
|
539
623
|
/**
|
|
540
|
-
* Redoes the newest undone transaction
|
|
624
|
+
* Redoes the newest undone transaction: how it went and the pages it touched; `undefined`
|
|
625
|
+
* when there is nothing to redo.
|
|
541
626
|
*
|
|
542
627
|
* # Errors
|
|
543
628
|
* As [`WasmDocument::undo`].
|
|
544
|
-
* @returns {
|
|
629
|
+
* @returns {RevertedJs | undefined}
|
|
545
630
|
*/
|
|
546
631
|
redo() {
|
|
547
632
|
let ret;
|
|
@@ -600,11 +685,12 @@ export class WasmDocument {
|
|
|
600
685
|
return takeFromExternrefTable0(ret[0]);
|
|
601
686
|
}
|
|
602
687
|
/**
|
|
603
|
-
* Undoes the newest transaction; `undefined` when
|
|
688
|
+
* Undoes the newest transaction: how it went and the pages it touched; `undefined` when
|
|
689
|
+
* there is nothing to undo.
|
|
604
690
|
*
|
|
605
691
|
* # Errors
|
|
606
692
|
* `nested-transaction`, `saved-not-rebased`; reading errors.
|
|
607
|
-
* @returns {
|
|
693
|
+
* @returns {RevertedJs | undefined}
|
|
608
694
|
*/
|
|
609
695
|
undo() {
|
|
610
696
|
let ret;
|
|
@@ -862,6 +948,65 @@ export class WasmImage {
|
|
|
862
948
|
}
|
|
863
949
|
if (Symbol.dispose) WasmImage.prototype[Symbol.dispose] = WasmImage.prototype.free;
|
|
864
950
|
|
|
951
|
+
/**
|
|
952
|
+
* The fonts and images of a Markdown build, by role and by the target the Markdown names.
|
|
953
|
+
*/
|
|
954
|
+
export class WasmMarkdownOptions {
|
|
955
|
+
__destroy_into_raw() {
|
|
956
|
+
const ptr = this.__wbg_ptr;
|
|
957
|
+
this.__wbg_ptr = 0;
|
|
958
|
+
WasmMarkdownOptionsFinalization.unregister(this);
|
|
959
|
+
return ptr;
|
|
960
|
+
}
|
|
961
|
+
free() {
|
|
962
|
+
const ptr = this.__destroy_into_raw();
|
|
963
|
+
wasm.__wbg_wasmmarkdownoptions_free(ptr, 0);
|
|
964
|
+
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* `font` for `role`: `regular`, `bold` (headings too), `italic`, `boldItalic`, `mono`, or
|
|
968
|
+
* `fallback` (each call adds one) for characters the others lack.
|
|
969
|
+
*
|
|
970
|
+
* # Errors
|
|
971
|
+
* `invalid-argument` for another role.
|
|
972
|
+
* @param {string} role
|
|
973
|
+
* @param {WasmFont} font
|
|
974
|
+
*/
|
|
975
|
+
font(role, font) {
|
|
976
|
+
const ptr0 = passStringToWasm0(role, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
977
|
+
const len0 = WASM_VECTOR_LEN;
|
|
978
|
+
_assertClass(font, WasmFont);
|
|
979
|
+
let ret;
|
|
980
|
+
ret = wasm.wasmmarkdownoptions_font(this.__wbg_ptr, ptr0, len0, font.__wbg_ptr);
|
|
981
|
+
if (ret[1]) {
|
|
982
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* `image` for the images whose target is `target`, as the Markdown writes it.
|
|
987
|
+
* @param {string} target
|
|
988
|
+
* @param {WasmImage} image
|
|
989
|
+
*/
|
|
990
|
+
image(target, image) {
|
|
991
|
+
const ptr0 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
992
|
+
const len0 = WASM_VECTOR_LEN;
|
|
993
|
+
_assertClass(image, WasmImage);
|
|
994
|
+
wasm.wasmmarkdownoptions_image(this.__wbg_ptr, ptr0, len0, image.__wbg_ptr);
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* No fonts (the standard 14 Helvetica family and Courier) and no images.
|
|
998
|
+
*/
|
|
999
|
+
constructor() {
|
|
1000
|
+
let ret;
|
|
1001
|
+
ret = wasm.wasmmarkdownoptions_new();
|
|
1002
|
+
this.__wbg_ptr = ret;
|
|
1003
|
+
Object.defineProperty(this, '__wbg_inst', { value: __wbg_instance_id, writable: true });
|
|
1004
|
+
WasmMarkdownOptionsFinalization.register(this, { ptr: ret, instance: __wbg_instance_id }, this);
|
|
1005
|
+
return this;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
if (Symbol.dispose) WasmMarkdownOptions.prototype[Symbol.dispose] = WasmMarkdownOptions.prototype.free;
|
|
1009
|
+
|
|
865
1010
|
/**
|
|
866
1011
|
* A page of a [`WasmDocument`], held by its ID (F2): moving pages doesn't retarget it.
|
|
867
1012
|
*/
|
|
@@ -1816,6 +1961,11 @@ const WasmImageFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
1816
1961
|
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
1817
1962
|
if (instance === __wbg_instance_id) wasm.__wbg_wasmimage_free(ptr, 1);
|
|
1818
1963
|
});
|
|
1964
|
+
const WasmMarkdownOptionsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1965
|
+
? { register: () => {}, unregister: () => {} }
|
|
1966
|
+
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
1967
|
+
if (instance === __wbg_instance_id) wasm.__wbg_wasmmarkdownoptions_free(ptr, 1);
|
|
1968
|
+
});
|
|
1819
1969
|
const WasmPageFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1820
1970
|
? { register: () => {}, unregister: () => {} }
|
|
1821
1971
|
: new FinalizationRegistry(({ ptr, instance }) => {
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laminapdf/wasm",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.6",
|
|
4
4
|
"description": "Lamina PDF's WebAssembly modules and their wasm-bindgen glue: lamina_pdf_base (open, read, edit, save, vector and image pages), lamina_pdf_text (all of base plus fonts and text) and lamina_pdf_extract (all of base plus text extraction); and lamina_pdf_render_hayro, laminapdf-render's hayro adapter, which @laminapdf/render-hayro wraps. Generated into dist/ by `cargo xtask wasm`; @laminapdf/sdk is the API to use.",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"homepage": "https://laminapdf.com",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"./package.json": "./package.json"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@types/node": "26.6.
|
|
49
|
+
"@types/node": "26.6.6",
|
|
50
50
|
"ajv": "8.20.0",
|
|
51
51
|
"esbuild": "0.28.2",
|
|
52
52
|
"typescript": "7.0.2",
|
|
53
|
-
"vitest": "5.0
|
|
53
|
+
"vitest": "5.1.0",
|
|
54
54
|
"@laminapdf/test-utils": "0.0.0"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|