@laminapdf/wasm 0.2.0-alpha.2 → 0.2.0-alpha.4
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 +16 -4
- package/dist/lamina_pdf_base.js +227 -85
- package/dist/lamina_pdf_base.wasm +0 -0
- package/dist/lamina_pdf_extract.d.ts +416 -10
- package/dist/lamina_pdf_extract.js +421 -90
- package/dist/lamina_pdf_extract.wasm +0 -0
- package/dist/lamina_pdf_render_hayro.wasm +0 -0
- package/dist/lamina_pdf_text.d.ts +429 -11
- package/dist/lamina_pdf_text.js +442 -99
- package/dist/lamina_pdf_text.wasm +0 -0
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
-
/** A page's text as `WasmPage.text` returns it
|
|
4
|
+
/** A page's text as `WasmPage.text` returns it. */
|
|
5
5
|
export interface PageTextJs {
|
|
6
6
|
/** The text by line, in content order (runs on one baseline, joined; trimmed). */
|
|
7
7
|
lines: string[];
|
|
@@ -55,11 +55,35 @@ export interface ProgressJs {
|
|
|
55
55
|
*/
|
|
56
56
|
total?: number;
|
|
57
57
|
/**
|
|
58
|
-
* The phase (`parse`, `layout`, `extract`, `render`, `write`, `sign`).
|
|
58
|
+
* The phase (`parse`, `layout`, `extract`, `render`, `write`, `sign`, `model`).
|
|
59
59
|
*/
|
|
60
60
|
phase: string;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* A kid of a structure element: an element, or marked content on a page.
|
|
65
|
+
*/
|
|
66
|
+
export type StructureKidJs = ({ type: "node" } & StructureNodeJs) | { type: "content"; page: number; mcid: number };
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A layout region, its box `[x, y, width, height]` in top-left points (ADR 0027), as the
|
|
70
|
+
* output's boxes are.
|
|
71
|
+
*/
|
|
72
|
+
export interface RegionInit {
|
|
73
|
+
/**
|
|
74
|
+
* What it is.
|
|
75
|
+
*/
|
|
76
|
+
label: RegionLabelName;
|
|
77
|
+
/**
|
|
78
|
+
* `[x, y, width, height]`.
|
|
79
|
+
*/
|
|
80
|
+
bbox: [number, number, number, number];
|
|
81
|
+
/**
|
|
82
|
+
* The model's confidence, 0 to 1.
|
|
83
|
+
*/
|
|
84
|
+
score: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
63
87
|
/**
|
|
64
88
|
* A link over drawn text.
|
|
65
89
|
*/
|
|
@@ -95,6 +119,64 @@ export interface OpLog {
|
|
|
95
119
|
ops: Op[];
|
|
96
120
|
}
|
|
97
121
|
|
|
122
|
+
/**
|
|
123
|
+
* A model result the job waits for.
|
|
124
|
+
*/
|
|
125
|
+
export interface ModelRequestJs {
|
|
126
|
+
/**
|
|
127
|
+
* `layout` (regions) or `ocr` (words).
|
|
128
|
+
*/
|
|
129
|
+
kind: string;
|
|
130
|
+
/**
|
|
131
|
+
* The 0-based page to render.
|
|
132
|
+
*/
|
|
133
|
+
page: number;
|
|
134
|
+
/**
|
|
135
|
+
* The resolution to render it at.
|
|
136
|
+
*/
|
|
137
|
+
dpi: number;
|
|
138
|
+
/**
|
|
139
|
+
* OCR's languages (BCP 47); empty for the engine's default.
|
|
140
|
+
*/
|
|
141
|
+
langs: string[];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* A model the host runs, as the output's `generator.models` names it.
|
|
146
|
+
*/
|
|
147
|
+
export interface ModelInfoInit {
|
|
148
|
+
/**
|
|
149
|
+
* Its name.
|
|
150
|
+
*/
|
|
151
|
+
name: string;
|
|
152
|
+
/**
|
|
153
|
+
* Its version or revision.
|
|
154
|
+
*/
|
|
155
|
+
version: string;
|
|
156
|
+
/**
|
|
157
|
+
* Its weights' SHA-256, lowercase hex.
|
|
158
|
+
*/
|
|
159
|
+
sha256: string;
|
|
160
|
+
/**
|
|
161
|
+
* Its weights' SPDX licence.
|
|
162
|
+
*/
|
|
163
|
+
licence: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* A page and how to show it.
|
|
168
|
+
*/
|
|
169
|
+
export interface TargetJs {
|
|
170
|
+
/**
|
|
171
|
+
* The page's 0-based index.
|
|
172
|
+
*/
|
|
173
|
+
page: number;
|
|
174
|
+
/**
|
|
175
|
+
* How to show it, in page space.
|
|
176
|
+
*/
|
|
177
|
+
view: TargetViewJs;
|
|
178
|
+
}
|
|
179
|
+
|
|
98
180
|
/**
|
|
99
181
|
* A page-label numbering style.
|
|
100
182
|
*/
|
|
@@ -122,11 +204,56 @@ export interface RectJs {
|
|
|
122
204
|
height: number;
|
|
123
205
|
}
|
|
124
206
|
|
|
207
|
+
/**
|
|
208
|
+
* A region's kind.
|
|
209
|
+
*/
|
|
210
|
+
export type RegionLabelName = "text" | "title" | "section-header" | "list-item" | "table" | "picture" | "caption" | "footnote" | "formula" | "page-header" | "page-footer" | "other";
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* A step's progress, and the model result the job waits for, if any.
|
|
214
|
+
*/
|
|
215
|
+
export interface ExtractProgressJs {
|
|
216
|
+
/**
|
|
217
|
+
* Pages done.
|
|
218
|
+
*/
|
|
219
|
+
done: number;
|
|
220
|
+
/**
|
|
221
|
+
* Pages asked for.
|
|
222
|
+
*/
|
|
223
|
+
total?: number;
|
|
224
|
+
/**
|
|
225
|
+
* `extract`, or `model` while a request is open.
|
|
226
|
+
*/
|
|
227
|
+
phase: string;
|
|
228
|
+
/**
|
|
229
|
+
* The result the job waits for: hand it to `provide`.
|
|
230
|
+
*/
|
|
231
|
+
request?: ModelRequestJs;
|
|
232
|
+
}
|
|
233
|
+
|
|
125
234
|
/**
|
|
126
235
|
* Alignment of a text box's lines.
|
|
127
236
|
*/
|
|
128
237
|
export type AlignInit = "start" | "end" | "left" | "right" | "center";
|
|
129
238
|
|
|
239
|
+
/**
|
|
240
|
+
* An OCR word, its box as a region's.
|
|
241
|
+
*/
|
|
242
|
+
export interface WordInit {
|
|
243
|
+
/**
|
|
244
|
+
* Its text.
|
|
245
|
+
*/
|
|
246
|
+
text: string;
|
|
247
|
+
/**
|
|
248
|
+
* `[x, y, width, height]`.
|
|
249
|
+
*/
|
|
250
|
+
bbox: [number, number, number, number];
|
|
251
|
+
/**
|
|
252
|
+
* The engine's confidence, 0 to 1.
|
|
253
|
+
*/
|
|
254
|
+
confidence: number;
|
|
255
|
+
}
|
|
256
|
+
|
|
130
257
|
/**
|
|
131
258
|
* An attached file's options.
|
|
132
259
|
*/
|
|
@@ -257,6 +384,11 @@ export interface TextOptionsInit {
|
|
|
257
384
|
direction?: DirectionInit;
|
|
258
385
|
}
|
|
259
386
|
|
|
387
|
+
/**
|
|
388
|
+
* How a target shows its page, in page space; an unset coordinate is left out.
|
|
389
|
+
*/
|
|
390
|
+
export type TargetViewJs = { kind: "at"; x?: number; y?: number; zoom?: number } | { kind: "fit" } | { kind: "fit-width"; y?: number } | { kind: "fit-height"; x?: number } | { kind: "fit-rect"; x0: number; y0: number; x1: number; y1: number };
|
|
391
|
+
|
|
260
392
|
/**
|
|
261
393
|
* How a text box laid its text out.
|
|
262
394
|
*/
|
|
@@ -266,9 +398,15 @@ export interface TextLayoutJs {
|
|
|
266
398
|
*/
|
|
267
399
|
lines: LineBoxJs[];
|
|
268
400
|
/**
|
|
269
|
-
* Where the text that didn't fit starts (UTF-16 offset), if any.
|
|
401
|
+
* Where the text that didn't fit starts (UTF-16 offset), if any; `0` when no line fitted.
|
|
270
402
|
*/
|
|
271
403
|
overflow?: number;
|
|
404
|
+
/**
|
|
405
|
+
* Where the next element can start: the bottom of the last drawn line that draws
|
|
406
|
+
* something, before the surface's transform. Left out when no line does (nothing, only
|
|
407
|
+
* white space and control characters, or a box too short).
|
|
408
|
+
*/
|
|
409
|
+
bottom?: number;
|
|
272
410
|
}
|
|
273
411
|
|
|
274
412
|
/**
|
|
@@ -286,6 +424,24 @@ export type AfRelationshipInit = "source" | "data" | "alternative" | "supplement
|
|
|
286
424
|
*/
|
|
287
425
|
export type UndoOutcomeJs = "applied" | "partial" | "skipped";
|
|
288
426
|
|
|
427
|
+
/**
|
|
428
|
+
* How the Markdown is cut into chunks.
|
|
429
|
+
*/
|
|
430
|
+
export interface ChunkInit {
|
|
431
|
+
/**
|
|
432
|
+
* A chunk's budget in approximate tokens (characters / 4); 512 by default.
|
|
433
|
+
*/
|
|
434
|
+
maxTokens?: number;
|
|
435
|
+
/**
|
|
436
|
+
* Approximate tokens of whole blocks repeated from the chunk before; 0 by default.
|
|
437
|
+
*/
|
|
438
|
+
overlap?: number;
|
|
439
|
+
/**
|
|
440
|
+
* Where chunks may start; `"headings"` by default.
|
|
441
|
+
*/
|
|
442
|
+
splitOn?: SplitOnName;
|
|
443
|
+
}
|
|
444
|
+
|
|
289
445
|
/**
|
|
290
446
|
* How viewers present the document when it opens.
|
|
291
447
|
*/
|
|
@@ -336,6 +492,32 @@ export interface LineBoxJs {
|
|
|
336
492
|
baseline: number;
|
|
337
493
|
}
|
|
338
494
|
|
|
495
|
+
/**
|
|
496
|
+
* One element of the structure tree (`laminapdf::StructureNode`; its strings are document text).
|
|
497
|
+
*/
|
|
498
|
+
export interface StructureNodeJs {
|
|
499
|
+
/**
|
|
500
|
+
* Its standard structure type (`H1`, `P`, `LI`, `Figure` …), through the `/RoleMap`.
|
|
501
|
+
*/
|
|
502
|
+
kind: string;
|
|
503
|
+
/**
|
|
504
|
+
* `/Alt`: alternate text.
|
|
505
|
+
*/
|
|
506
|
+
alt?: string;
|
|
507
|
+
/**
|
|
508
|
+
* `/Lang`: the language of its content.
|
|
509
|
+
*/
|
|
510
|
+
lang?: string;
|
|
511
|
+
/**
|
|
512
|
+
* `/ActualText`: the text its content stands for.
|
|
513
|
+
*/
|
|
514
|
+
actualText?: string;
|
|
515
|
+
/**
|
|
516
|
+
* Its kids, in reading order.
|
|
517
|
+
*/
|
|
518
|
+
kids: StructureKidJs[];
|
|
519
|
+
}
|
|
520
|
+
|
|
339
521
|
/**
|
|
340
522
|
* One outline item and its children.
|
|
341
523
|
*/
|
|
@@ -370,6 +552,28 @@ export interface OutlineEntryInit {
|
|
|
370
552
|
italic?: boolean;
|
|
371
553
|
}
|
|
372
554
|
|
|
555
|
+
/**
|
|
556
|
+
* One outline item.
|
|
557
|
+
*/
|
|
558
|
+
export interface OutlineNodeJs {
|
|
559
|
+
/**
|
|
560
|
+
* Its title (document text).
|
|
561
|
+
*/
|
|
562
|
+
title: string;
|
|
563
|
+
/**
|
|
564
|
+
* Whether it opens with its children shown.
|
|
565
|
+
*/
|
|
566
|
+
open: boolean;
|
|
567
|
+
/**
|
|
568
|
+
* Where it goes, when its destination names a page of this document.
|
|
569
|
+
*/
|
|
570
|
+
target?: TargetJs;
|
|
571
|
+
/**
|
|
572
|
+
* Its children, in order.
|
|
573
|
+
*/
|
|
574
|
+
children: OutlineNodeJs[];
|
|
575
|
+
}
|
|
576
|
+
|
|
373
577
|
/**
|
|
374
578
|
* One page's facts (`laminapdf::PageInfo`).
|
|
375
579
|
*/
|
|
@@ -423,7 +627,7 @@ export interface PageLabelInit {
|
|
|
423
627
|
}
|
|
424
628
|
|
|
425
629
|
/**
|
|
426
|
-
* One text run (`laminapdf::extract::
|
|
630
|
+
* One text run (`laminapdf::extract::PageTextRun`): glyphs of one font, size, direction and marked
|
|
427
631
|
* content on one baseline, in logical order.
|
|
428
632
|
*/
|
|
429
633
|
export interface TextRunJs {
|
|
@@ -465,6 +669,48 @@ export interface TextRunJs {
|
|
|
465
669
|
glyphs: [number, number];
|
|
466
670
|
}
|
|
467
671
|
|
|
672
|
+
/**
|
|
673
|
+
* Options for `WasmDocument.extract`.
|
|
674
|
+
*/
|
|
675
|
+
export interface ExtractInit {
|
|
676
|
+
/**
|
|
677
|
+
* What to return.
|
|
678
|
+
*/
|
|
679
|
+
format: ExtractFormat;
|
|
680
|
+
/**
|
|
681
|
+
* The 0-based page indices to extract, in this order; every page by default.
|
|
682
|
+
*/
|
|
683
|
+
pages?: number[];
|
|
684
|
+
/**
|
|
685
|
+
* Where the reading order comes from; `"auto"` by default.
|
|
686
|
+
*/
|
|
687
|
+
readingOrder?: ReadingOrderName;
|
|
688
|
+
/**
|
|
689
|
+
* What happens to hidden text.
|
|
690
|
+
*/
|
|
691
|
+
drop?: DropInit;
|
|
692
|
+
/**
|
|
693
|
+
* Which table detectors run; `"lattice"` by default.
|
|
694
|
+
*/
|
|
695
|
+
tables?: TableModeName;
|
|
696
|
+
/**
|
|
697
|
+
* Join words hyphenated across lines; on by default.
|
|
698
|
+
*/
|
|
699
|
+
dehyphenate?: boolean;
|
|
700
|
+
/**
|
|
701
|
+
* Write `<!-- page N -->` before each page's first block (Markdown, chunks and JSON).
|
|
702
|
+
*/
|
|
703
|
+
pageMarkers?: boolean;
|
|
704
|
+
/**
|
|
705
|
+
* How chunks are cut (`chunks`, and `json` to include them).
|
|
706
|
+
*/
|
|
707
|
+
chunk?: ChunkInit;
|
|
708
|
+
/**
|
|
709
|
+
* Models the host runs (`extractJob` only): the job asks for their results.
|
|
710
|
+
*/
|
|
711
|
+
models?: ModelsInit;
|
|
712
|
+
}
|
|
713
|
+
|
|
468
714
|
/**
|
|
469
715
|
* Options for `WasmDocument.openBytes`.
|
|
470
716
|
*/
|
|
@@ -710,6 +956,28 @@ export interface MetadataInit {
|
|
|
710
956
|
*/
|
|
711
957
|
export type ModificationClass = "metadata" | "formFill" | "annotation" | "signature" | "pageStructure" | "content" | "document";
|
|
712
958
|
|
|
959
|
+
/**
|
|
960
|
+
* The models the host runs for an extraction job.
|
|
961
|
+
*/
|
|
962
|
+
export interface ModelsInit {
|
|
963
|
+
/**
|
|
964
|
+
* A layout model: every page's regions are asked for.
|
|
965
|
+
*/
|
|
966
|
+
layout?: ModelInfoInit;
|
|
967
|
+
/**
|
|
968
|
+
* An OCR engine: pages with no visible text are asked for.
|
|
969
|
+
*/
|
|
970
|
+
ocr?: ModelInfoInit;
|
|
971
|
+
/**
|
|
972
|
+
* The resolution pages are asked for at; 150 by default.
|
|
973
|
+
*/
|
|
974
|
+
dpi?: number;
|
|
975
|
+
/**
|
|
976
|
+
* OCR's languages (BCP 47).
|
|
977
|
+
*/
|
|
978
|
+
langs?: string[];
|
|
979
|
+
}
|
|
980
|
+
|
|
713
981
|
/**
|
|
714
982
|
* The pages an edit touched.
|
|
715
983
|
*/
|
|
@@ -730,6 +998,16 @@ export type PageModeInit = "none" | "outlines" | "thumbnails" | "fullScreen" | "
|
|
|
730
998
|
*/
|
|
731
999
|
export type SaveModeJs = "auto" | "incremental" | "fullRewrite";
|
|
732
1000
|
|
|
1001
|
+
/**
|
|
1002
|
+
* What `WasmDocument.extract` returns.
|
|
1003
|
+
*/
|
|
1004
|
+
export type ExtractFormat = "markdown" | "json" | "text" | "chunks";
|
|
1005
|
+
|
|
1006
|
+
/**
|
|
1007
|
+
* What `provide` takes.
|
|
1008
|
+
*/
|
|
1009
|
+
export type ModelResultInit = { kind: "layout"; regions: RegionInit[] } | { kind: "ocr"; words: WordInit[] };
|
|
1010
|
+
|
|
733
1011
|
/**
|
|
734
1012
|
* What a run measures.
|
|
735
1013
|
*/
|
|
@@ -746,6 +1024,12 @@ export interface TextRunJs {
|
|
|
746
1024
|
* Its lines (a run breaks only at line breaks in the text).
|
|
747
1025
|
*/
|
|
748
1026
|
lines: number;
|
|
1027
|
+
/**
|
|
1028
|
+
* Where the next element can start: the bottom of the descent below its last line that
|
|
1029
|
+
* draws something, before the surface's transform. Left out when nothing is drawn (empty
|
|
1030
|
+
* text, or only white space and control characters); invisible text counts.
|
|
1031
|
+
*/
|
|
1032
|
+
bottom?: number;
|
|
749
1033
|
}
|
|
750
1034
|
|
|
751
1035
|
/**
|
|
@@ -783,6 +1067,21 @@ export interface SaveReportJs {
|
|
|
783
1067
|
*/
|
|
784
1068
|
export type OutputJs = "whole" | "appendedOnly";
|
|
785
1069
|
|
|
1070
|
+
/**
|
|
1071
|
+
* What happens to hidden text and page furniture.
|
|
1072
|
+
*/
|
|
1073
|
+
export interface DropInit {
|
|
1074
|
+
/**
|
|
1075
|
+
* Keep each dropped run's text in its `dropped` entry (JSON only), for auditing a file.
|
|
1076
|
+
*/
|
|
1077
|
+
keepSpans?: boolean;
|
|
1078
|
+
/**
|
|
1079
|
+
* Drop running headers, footers, page numbers and artifact-marked text too, listing them
|
|
1080
|
+
* in `dropped`; on by default.
|
|
1081
|
+
*/
|
|
1082
|
+
furniture?: boolean;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
786
1085
|
/**
|
|
787
1086
|
* What happens to text that doesn't fit a text box.
|
|
788
1087
|
*/
|
|
@@ -793,6 +1092,21 @@ export type OverflowInit = "clip" | "error";
|
|
|
793
1092
|
*/
|
|
794
1093
|
export type LinkTargetInit = { type: "uri"; uri: string } | { type: "page"; index: number; fit?: FitInit } | { type: "named"; name: string };
|
|
795
1094
|
|
|
1095
|
+
/**
|
|
1096
|
+
* Where chunks may start.
|
|
1097
|
+
*/
|
|
1098
|
+
export type SplitOnName = "headings" | "blocks" | "pages";
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* Where the reading order comes from.
|
|
1102
|
+
*/
|
|
1103
|
+
export type ReadingOrderName = "auto" | "tagged" | "layout" | "content-stream";
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* Which table detectors run.
|
|
1107
|
+
*/
|
|
1108
|
+
export type TableModeName = "off" | "lattice" | "lattice-and-stream";
|
|
1109
|
+
|
|
796
1110
|
/**
|
|
797
1111
|
* `Limits` with every field optional (ADR 0003 §3; names as in Rust, camelCase).
|
|
798
1112
|
*/
|
|
@@ -978,6 +1292,25 @@ export class WasmDocument {
|
|
|
978
1292
|
* error (nothing is applied).
|
|
979
1293
|
*/
|
|
980
1294
|
apply(ops: Op[]): EditedJs;
|
|
1295
|
+
/**
|
|
1296
|
+
* An extraction stepped a page at a time, whose models the host runs: each step returns
|
|
1297
|
+
* its progress, with the result it waits for under `request` (render that page at `dpi`,
|
|
1298
|
+
* run the model, hand the result to `provide`), and once every page is done, the output in
|
|
1299
|
+
* `options.format` (the extract and text modules).
|
|
1300
|
+
*
|
|
1301
|
+
* # Errors
|
|
1302
|
+
* As `extract`, for the options and the pages asked for.
|
|
1303
|
+
*/
|
|
1304
|
+
extractJob(options: ExtractInit): WasmExtractJob;
|
|
1305
|
+
/**
|
|
1306
|
+
* The document's text for retrieval and LLMs, as one string: Markdown, plain text, the
|
|
1307
|
+
* `laminapdf.extract/1` JSON, or the chunks as a JSON array (the extract and text modules).
|
|
1308
|
+
*
|
|
1309
|
+
* # Errors
|
|
1310
|
+
* `page-index-out-of-range` for a page in `pages` past the end; `data-pending` and the
|
|
1311
|
+
* reading errors; `unknown-option` / `invalid-argument` for bad options.
|
|
1312
|
+
*/
|
|
1313
|
+
extract(options: ExtractInit): string;
|
|
981
1314
|
/**
|
|
982
1315
|
* Whether there are changes no save has written yet.
|
|
983
1316
|
*/
|
|
@@ -989,6 +1322,21 @@ export class WasmDocument {
|
|
|
989
1322
|
* Reading errors.
|
|
990
1323
|
*/
|
|
991
1324
|
info(): DocumentInfoJs;
|
|
1325
|
+
/**
|
|
1326
|
+
* Whether the document says it is tagged (`/MarkInfo /Marked true`; the extract and text modules).
|
|
1327
|
+
*
|
|
1328
|
+
* # Errors
|
|
1329
|
+
* Reading errors.
|
|
1330
|
+
*/
|
|
1331
|
+
isTagged(): boolean;
|
|
1332
|
+
/**
|
|
1333
|
+
* The named destination `name`, or `undefined` when the document has none by that name or
|
|
1334
|
+
* it names no page here (the extract and text modules).
|
|
1335
|
+
*
|
|
1336
|
+
* # Errors
|
|
1337
|
+
* `data-pending` and the reading errors.
|
|
1338
|
+
*/
|
|
1339
|
+
namedDestination(name: string): TargetJs | undefined;
|
|
992
1340
|
/**
|
|
993
1341
|
* Opens a document from its bytes.
|
|
994
1342
|
*
|
|
@@ -1006,6 +1354,14 @@ export class WasmDocument {
|
|
|
1006
1354
|
* As `openBytes`, and `data-pending`.
|
|
1007
1355
|
*/
|
|
1008
1356
|
static openSource(source: WasmSparseSource, options: OpenOptionsInit | undefined): WasmDocument;
|
|
1357
|
+
/**
|
|
1358
|
+
* The outline's top-level items, each with its children; empty without an outline (the
|
|
1359
|
+
* extract and text modules).
|
|
1360
|
+
*
|
|
1361
|
+
* # Errors
|
|
1362
|
+
* `data-pending` and the reading errors.
|
|
1363
|
+
*/
|
|
1364
|
+
outline(): OutlineNodeJs[];
|
|
1009
1365
|
/**
|
|
1010
1366
|
* A handle on the page with `id` (`p12.0`).
|
|
1011
1367
|
*
|
|
@@ -1069,6 +1425,14 @@ export class WasmDocument {
|
|
|
1069
1425
|
* The save's errors (`would-invalidate-signatures`, `requires-rewrite`, …).
|
|
1070
1426
|
*/
|
|
1071
1427
|
save(options: SaveOptionsInit | undefined): { bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs };
|
|
1428
|
+
/**
|
|
1429
|
+
* The structure tree's top-level elements in reading order, or `undefined` without one (the
|
|
1430
|
+
* extract and text modules, beside `WasmPage.text`, whose runs it links by MCID).
|
|
1431
|
+
*
|
|
1432
|
+
* # Errors
|
|
1433
|
+
* Reading errors.
|
|
1434
|
+
*/
|
|
1435
|
+
structureTree(): StructureNodeJs[] | undefined;
|
|
1072
1436
|
/**
|
|
1073
1437
|
* Undoes the newest transaction; `undefined` when there is nothing to undo.
|
|
1074
1438
|
*
|
|
@@ -1082,6 +1446,38 @@ export class WasmDocument {
|
|
|
1082
1446
|
warnings(): WasmWarningCursor;
|
|
1083
1447
|
}
|
|
1084
1448
|
|
|
1449
|
+
/**
|
|
1450
|
+
* An extraction in progress, from `WasmDocument.extractJob`; it holds its document weakly.
|
|
1451
|
+
*/
|
|
1452
|
+
export class WasmExtractJob {
|
|
1453
|
+
private constructor();
|
|
1454
|
+
free(): void;
|
|
1455
|
+
[Symbol.dispose](): void;
|
|
1456
|
+
/**
|
|
1457
|
+
* Stops the job: its next step fails with `cancelled`.
|
|
1458
|
+
*/
|
|
1459
|
+
cancel(): void;
|
|
1460
|
+
/**
|
|
1461
|
+
* Hands the job the result of its open request: `{ kind: "layout", regions }` or
|
|
1462
|
+
* `{ kind: "ocr", words }`, boxes as `[x, y, width, height]` in top-left points.
|
|
1463
|
+
*
|
|
1464
|
+
* # Errors
|
|
1465
|
+
* `model-result-unexpected` when nothing was asked for or `result` is the other kind;
|
|
1466
|
+
* `invalid-argument` / `unknown-option` for a malformed result.
|
|
1467
|
+
*/
|
|
1468
|
+
provide(result: ModelResultInit): void;
|
|
1469
|
+
/**
|
|
1470
|
+
* Extracts up to `budget` pages: `{ state: "progress", done, total, phase, request? }` or
|
|
1471
|
+
* `{ state: "done", output }`, the output in the job's format. While `request` is set, a
|
|
1472
|
+
* step does nothing until `provide` answers it.
|
|
1473
|
+
*
|
|
1474
|
+
* # Errors
|
|
1475
|
+
* `cancelled`, `document-changed`, `job-finished`, `disposed` when the document is freed,
|
|
1476
|
+
* and the reading errors.
|
|
1477
|
+
*/
|
|
1478
|
+
step(budget: number): ({ state: "progress" } & ExtractProgressJs) | { state: "done"; output: string };
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1085
1481
|
/**
|
|
1086
1482
|
* A font registered with a [`WasmBuilder`].
|
|
1087
1483
|
*/
|
|
@@ -1152,7 +1548,8 @@ export class WasmPage {
|
|
|
1152
1548
|
* The page's current 0-based index.
|
|
1153
1549
|
*
|
|
1154
1550
|
* # Errors
|
|
1155
|
-
* `unknown-page` when the page is gone; reading
|
|
1551
|
+
* `unknown-page` when the page is gone; `disposed` when its document is freed; reading
|
|
1552
|
+
* errors.
|
|
1156
1553
|
*/
|
|
1157
1554
|
index(): number;
|
|
1158
1555
|
/**
|
|
@@ -1163,12 +1560,12 @@ export class WasmPage {
|
|
|
1163
1560
|
*/
|
|
1164
1561
|
info(): PageInfoJs;
|
|
1165
1562
|
/**
|
|
1166
|
-
* The page's text: lines, runs, glyph quads and glyph text (
|
|
1167
|
-
* modules).
|
|
1563
|
+
* The page's text: lines, runs, glyph quads and glyph text (the extract and text modules).
|
|
1168
1564
|
*
|
|
1169
1565
|
* # Errors
|
|
1170
|
-
* `unknown-page` when the page is gone; `
|
|
1171
|
-
* `unknown-option` / `invalid-argument` for bad
|
|
1566
|
+
* `unknown-page` when the page is gone; `disposed` when its document is freed;
|
|
1567
|
+
* `data-pending` and the reading errors; `unknown-option` / `invalid-argument` for bad
|
|
1568
|
+
* options.
|
|
1172
1569
|
*/
|
|
1173
1570
|
text(options: TextOptionsInit | undefined): PageTextJs;
|
|
1174
1571
|
/**
|
|
@@ -1187,7 +1584,8 @@ export class WasmPageBuilder {
|
|
|
1187
1584
|
[Symbol.dispose](): void;
|
|
1188
1585
|
/**
|
|
1189
1586
|
* Opens an artifact until the matching `endTag`: `kind` is `layout`, `page`, `pagination`
|
|
1190
|
-
* or `background
|
|
1587
|
+
* or `background`, or a pagination artifact that says what it is: `header` (attached to the
|
|
1588
|
+
* top edge), `footer` (the bottom) or `watermark`.
|
|
1191
1589
|
*
|
|
1192
1590
|
* # Errors
|
|
1193
1591
|
* `invalid-argument` for another kind.
|
|
@@ -1389,7 +1787,8 @@ export class WasmSaveJob {
|
|
|
1389
1787
|
* `{ state: "done", bytes, report }`.
|
|
1390
1788
|
*
|
|
1391
1789
|
* # Errors
|
|
1392
|
-
* `cancelled`, `document-changed`, `job-finished`,
|
|
1790
|
+
* `cancelled`, `document-changed`, `job-finished`, `disposed` when the document is freed,
|
|
1791
|
+
* or the save's own errors.
|
|
1393
1792
|
*/
|
|
1394
1793
|
step(budget: number): ({ state: "progress" } & ProgressJs) | { state: "done"; bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs };
|
|
1395
1794
|
}
|
|
@@ -1448,6 +1847,14 @@ export class WasmWarningCursor {
|
|
|
1448
1847
|
remaining(): number;
|
|
1449
1848
|
}
|
|
1450
1849
|
|
|
1850
|
+
export function __wbg_reset_state(): void;
|
|
1851
|
+
|
|
1852
|
+
/**
|
|
1853
|
+
* Whether the most recent allocation failed: after a trap, `true` means the module ran out of
|
|
1854
|
+
* memory.
|
|
1855
|
+
*/
|
|
1856
|
+
export function allocationFailed(): boolean;
|
|
1857
|
+
|
|
1451
1858
|
/**
|
|
1452
1859
|
* Whether this module is the text module (fonts, `text`, `textBox`).
|
|
1453
1860
|
*/
|
|
@@ -1464,6 +1871,7 @@ export interface InitOutput {
|
|
|
1464
1871
|
readonly memory: WebAssembly.Memory;
|
|
1465
1872
|
readonly __wbg_wasmbuilder_free: (a: number, b: number) => void;
|
|
1466
1873
|
readonly __wbg_wasmdocument_free: (a: number, b: number) => void;
|
|
1874
|
+
readonly __wbg_wasmextractjob_free: (a: number, b: number) => void;
|
|
1467
1875
|
readonly __wbg_wasmfont_free: (a: number, b: number) => void;
|
|
1468
1876
|
readonly __wbg_wasmimage_free: (a: number, b: number) => void;
|
|
1469
1877
|
readonly __wbg_wasmpage_free: (a: number, b: number) => void;
|
|
@@ -1471,6 +1879,7 @@ export interface InitOutput {
|
|
|
1471
1879
|
readonly __wbg_wasmsavejob_free: (a: number, b: number) => void;
|
|
1472
1880
|
readonly __wbg_wasmsparsesource_free: (a: number, b: number) => void;
|
|
1473
1881
|
readonly __wbg_wasmwarningcursor_free: (a: number, b: number) => void;
|
|
1882
|
+
readonly allocationFailed: () => number;
|
|
1474
1883
|
readonly hasText: () => number;
|
|
1475
1884
|
readonly version: () => [number, number];
|
|
1476
1885
|
readonly wasmbuilder_attach: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number];
|
|
@@ -1487,10 +1896,15 @@ export interface InitOutput {
|
|
|
1487
1896
|
readonly wasmbuilder_viewerPreferences: (a: number, b: any) => [number, number];
|
|
1488
1897
|
readonly wasmdocument_apply: (a: number, b: any) => [number, number, number];
|
|
1489
1898
|
readonly wasmdocument_applyLog: (a: number, b: number, c: number) => [number, number, number];
|
|
1899
|
+
readonly wasmdocument_extract: (a: number, b: any) => [number, number, number, number];
|
|
1900
|
+
readonly wasmdocument_extractJob: (a: number, b: any) => [number, number, number];
|
|
1490
1901
|
readonly wasmdocument_hasUnsavedChanges: (a: number) => number;
|
|
1491
1902
|
readonly wasmdocument_info: (a: number) => [number, number, number];
|
|
1903
|
+
readonly wasmdocument_isTagged: (a: number) => [number, number, number];
|
|
1904
|
+
readonly wasmdocument_namedDestination: (a: number, b: number, c: number) => [number, number, number];
|
|
1492
1905
|
readonly wasmdocument_openBytes: (a: number, b: number, c: any) => [number, number, number];
|
|
1493
1906
|
readonly wasmdocument_openSource: (a: number, b: any) => [number, number, number];
|
|
1907
|
+
readonly wasmdocument_outline: (a: number) => [number, number, number];
|
|
1494
1908
|
readonly wasmdocument_page: (a: number, b: number) => [number, number, number];
|
|
1495
1909
|
readonly wasmdocument_pageById: (a: number, b: number, c: number) => [number, number, number];
|
|
1496
1910
|
readonly wasmdocument_pageCount: (a: number) => [number, number, number];
|
|
@@ -1500,8 +1914,12 @@ export interface InitOutput {
|
|
|
1500
1914
|
readonly wasmdocument_redo: (a: number) => [number, number, number];
|
|
1501
1915
|
readonly wasmdocument_save: (a: number, b: any) => [number, number, number];
|
|
1502
1916
|
readonly wasmdocument_saveJob: (a: number, b: any) => [number, number, number];
|
|
1917
|
+
readonly wasmdocument_structureTree: (a: number) => [number, number, number];
|
|
1503
1918
|
readonly wasmdocument_undo: (a: number) => [number, number, number];
|
|
1504
1919
|
readonly wasmdocument_warnings: (a: number) => number;
|
|
1920
|
+
readonly wasmextractjob_cancel: (a: number) => void;
|
|
1921
|
+
readonly wasmextractjob_provide: (a: number, b: any) => [number, number];
|
|
1922
|
+
readonly wasmextractjob_step: (a: number, b: number) => [number, number, number];
|
|
1505
1923
|
readonly wasmfont_family: (a: number) => [number, number];
|
|
1506
1924
|
readonly wasmfont_isStandard: (a: number) => number;
|
|
1507
1925
|
readonly wasmfont_postscriptName: (a: number) => [number, number];
|