@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
|
|
@@ -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[];
|
|
@@ -50,11 +50,35 @@ export interface ProgressJs {
|
|
|
50
50
|
*/
|
|
51
51
|
total?: number;
|
|
52
52
|
/**
|
|
53
|
-
* The phase (`parse`, `layout`, `extract`, `render`, `write`, `sign`).
|
|
53
|
+
* The phase (`parse`, `layout`, `extract`, `render`, `write`, `sign`, `model`).
|
|
54
54
|
*/
|
|
55
55
|
phase: string;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* A kid of a structure element: an element, or marked content on a page.
|
|
60
|
+
*/
|
|
61
|
+
export type StructureKidJs = ({ type: "node" } & StructureNodeJs) | { type: "content"; page: number; mcid: number };
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A layout region, its box `[x, y, width, height]` in top-left points (ADR 0027), as the
|
|
65
|
+
* output's boxes are.
|
|
66
|
+
*/
|
|
67
|
+
export interface RegionInit {
|
|
68
|
+
/**
|
|
69
|
+
* What it is.
|
|
70
|
+
*/
|
|
71
|
+
label: RegionLabelName;
|
|
72
|
+
/**
|
|
73
|
+
* `[x, y, width, height]`.
|
|
74
|
+
*/
|
|
75
|
+
bbox: [number, number, number, number];
|
|
76
|
+
/**
|
|
77
|
+
* The model's confidence, 0 to 1.
|
|
78
|
+
*/
|
|
79
|
+
score: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
58
82
|
/**
|
|
59
83
|
* A list of ops with its schema version ([ADR 0006] §6): `{ "v": 1, "ops": [ … ] }`, used
|
|
60
84
|
* for saved op logs, batch processing and sync messages. Unknown fields are rejected, and so
|
|
@@ -76,11 +100,114 @@ export interface OpLog {
|
|
|
76
100
|
ops: Op[];
|
|
77
101
|
}
|
|
78
102
|
|
|
103
|
+
/**
|
|
104
|
+
* A model result the job waits for.
|
|
105
|
+
*/
|
|
106
|
+
export interface ModelRequestJs {
|
|
107
|
+
/**
|
|
108
|
+
* `layout` (regions) or `ocr` (words).
|
|
109
|
+
*/
|
|
110
|
+
kind: string;
|
|
111
|
+
/**
|
|
112
|
+
* The 0-based page to render.
|
|
113
|
+
*/
|
|
114
|
+
page: number;
|
|
115
|
+
/**
|
|
116
|
+
* The resolution to render it at.
|
|
117
|
+
*/
|
|
118
|
+
dpi: number;
|
|
119
|
+
/**
|
|
120
|
+
* OCR's languages (BCP 47); empty for the engine's default.
|
|
121
|
+
*/
|
|
122
|
+
langs: string[];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* A model the host runs, as the output's `generator.models` names it.
|
|
127
|
+
*/
|
|
128
|
+
export interface ModelInfoInit {
|
|
129
|
+
/**
|
|
130
|
+
* Its name.
|
|
131
|
+
*/
|
|
132
|
+
name: string;
|
|
133
|
+
/**
|
|
134
|
+
* Its version or revision.
|
|
135
|
+
*/
|
|
136
|
+
version: string;
|
|
137
|
+
/**
|
|
138
|
+
* Its weights' SHA-256, lowercase hex.
|
|
139
|
+
*/
|
|
140
|
+
sha256: string;
|
|
141
|
+
/**
|
|
142
|
+
* Its weights' SPDX licence.
|
|
143
|
+
*/
|
|
144
|
+
licence: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* A page and how to show it.
|
|
149
|
+
*/
|
|
150
|
+
export interface TargetJs {
|
|
151
|
+
/**
|
|
152
|
+
* The page's 0-based index.
|
|
153
|
+
*/
|
|
154
|
+
page: number;
|
|
155
|
+
/**
|
|
156
|
+
* How to show it, in page space.
|
|
157
|
+
*/
|
|
158
|
+
view: TargetViewJs;
|
|
159
|
+
}
|
|
160
|
+
|
|
79
161
|
/**
|
|
80
162
|
* A page-label numbering style.
|
|
81
163
|
*/
|
|
82
164
|
export type LabelStyleInit = "decimal" | "upperRoman" | "lowerRoman" | "upperLetters" | "lowerLetters";
|
|
83
165
|
|
|
166
|
+
/**
|
|
167
|
+
* A region's kind.
|
|
168
|
+
*/
|
|
169
|
+
export type RegionLabelName = "text" | "title" | "section-header" | "list-item" | "table" | "picture" | "caption" | "footnote" | "formula" | "page-header" | "page-footer" | "other";
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* A step's progress, and the model result the job waits for, if any.
|
|
173
|
+
*/
|
|
174
|
+
export interface ExtractProgressJs {
|
|
175
|
+
/**
|
|
176
|
+
* Pages done.
|
|
177
|
+
*/
|
|
178
|
+
done: number;
|
|
179
|
+
/**
|
|
180
|
+
* Pages asked for.
|
|
181
|
+
*/
|
|
182
|
+
total?: number;
|
|
183
|
+
/**
|
|
184
|
+
* `extract`, or `model` while a request is open.
|
|
185
|
+
*/
|
|
186
|
+
phase: string;
|
|
187
|
+
/**
|
|
188
|
+
* The result the job waits for: hand it to `provide`.
|
|
189
|
+
*/
|
|
190
|
+
request?: ModelRequestJs;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* An OCR word, its box as a region's.
|
|
195
|
+
*/
|
|
196
|
+
export interface WordInit {
|
|
197
|
+
/**
|
|
198
|
+
* Its text.
|
|
199
|
+
*/
|
|
200
|
+
text: string;
|
|
201
|
+
/**
|
|
202
|
+
* `[x, y, width, height]`.
|
|
203
|
+
*/
|
|
204
|
+
bbox: [number, number, number, number];
|
|
205
|
+
/**
|
|
206
|
+
* The engine's confidence, 0 to 1.
|
|
207
|
+
*/
|
|
208
|
+
confidence: number;
|
|
209
|
+
}
|
|
210
|
+
|
|
84
211
|
/**
|
|
85
212
|
* An attached file's options.
|
|
86
213
|
*/
|
|
@@ -181,6 +308,11 @@ export interface SetInfo {
|
|
|
181
308
|
*/
|
|
182
309
|
export type FitInit = { type: "page" } | { type: "width"; top?: number } | { type: "height"; left?: number } | { type: "xyz"; left?: number; top?: number; zoom?: number } | { type: "rect"; x: number; y: number; width: number; height: number } | { type: "bounds" };
|
|
183
310
|
|
|
311
|
+
/**
|
|
312
|
+
* How a target shows its page, in page space; an unset coordinate is left out.
|
|
313
|
+
*/
|
|
314
|
+
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 };
|
|
315
|
+
|
|
184
316
|
/**
|
|
185
317
|
* How a viewer lays pages out.
|
|
186
318
|
*/
|
|
@@ -196,6 +328,24 @@ export type AfRelationshipInit = "source" | "data" | "alternative" | "supplement
|
|
|
196
328
|
*/
|
|
197
329
|
export type UndoOutcomeJs = "applied" | "partial" | "skipped";
|
|
198
330
|
|
|
331
|
+
/**
|
|
332
|
+
* How the Markdown is cut into chunks.
|
|
333
|
+
*/
|
|
334
|
+
export interface ChunkInit {
|
|
335
|
+
/**
|
|
336
|
+
* A chunk's budget in approximate tokens (characters / 4); 512 by default.
|
|
337
|
+
*/
|
|
338
|
+
maxTokens?: number;
|
|
339
|
+
/**
|
|
340
|
+
* Approximate tokens of whole blocks repeated from the chunk before; 0 by default.
|
|
341
|
+
*/
|
|
342
|
+
overlap?: number;
|
|
343
|
+
/**
|
|
344
|
+
* Where chunks may start; `"headings"` by default.
|
|
345
|
+
*/
|
|
346
|
+
splitOn?: SplitOnName;
|
|
347
|
+
}
|
|
348
|
+
|
|
199
349
|
/**
|
|
200
350
|
* How viewers present the document when it opens.
|
|
201
351
|
*/
|
|
@@ -219,6 +369,32 @@ export interface ViewerPreferencesInit {
|
|
|
219
369
|
*/
|
|
220
370
|
export type RenumberJs = "keep" | "compact";
|
|
221
371
|
|
|
372
|
+
/**
|
|
373
|
+
* One element of the structure tree (`laminapdf::StructureNode`; its strings are document text).
|
|
374
|
+
*/
|
|
375
|
+
export interface StructureNodeJs {
|
|
376
|
+
/**
|
|
377
|
+
* Its standard structure type (`H1`, `P`, `LI`, `Figure` …), through the `/RoleMap`.
|
|
378
|
+
*/
|
|
379
|
+
kind: string;
|
|
380
|
+
/**
|
|
381
|
+
* `/Alt`: alternate text.
|
|
382
|
+
*/
|
|
383
|
+
alt?: string;
|
|
384
|
+
/**
|
|
385
|
+
* `/Lang`: the language of its content.
|
|
386
|
+
*/
|
|
387
|
+
lang?: string;
|
|
388
|
+
/**
|
|
389
|
+
* `/ActualText`: the text its content stands for.
|
|
390
|
+
*/
|
|
391
|
+
actualText?: string;
|
|
392
|
+
/**
|
|
393
|
+
* Its kids, in reading order.
|
|
394
|
+
*/
|
|
395
|
+
kids: StructureKidJs[];
|
|
396
|
+
}
|
|
397
|
+
|
|
222
398
|
/**
|
|
223
399
|
* One outline item and its children.
|
|
224
400
|
*/
|
|
@@ -253,6 +429,28 @@ export interface OutlineEntryInit {
|
|
|
253
429
|
italic?: boolean;
|
|
254
430
|
}
|
|
255
431
|
|
|
432
|
+
/**
|
|
433
|
+
* One outline item.
|
|
434
|
+
*/
|
|
435
|
+
export interface OutlineNodeJs {
|
|
436
|
+
/**
|
|
437
|
+
* Its title (document text).
|
|
438
|
+
*/
|
|
439
|
+
title: string;
|
|
440
|
+
/**
|
|
441
|
+
* Whether it opens with its children shown.
|
|
442
|
+
*/
|
|
443
|
+
open: boolean;
|
|
444
|
+
/**
|
|
445
|
+
* Where it goes, when its destination names a page of this document.
|
|
446
|
+
*/
|
|
447
|
+
target?: TargetJs;
|
|
448
|
+
/**
|
|
449
|
+
* Its children, in order.
|
|
450
|
+
*/
|
|
451
|
+
children: OutlineNodeJs[];
|
|
452
|
+
}
|
|
453
|
+
|
|
256
454
|
/**
|
|
257
455
|
* One page's facts (`laminapdf::PageInfo`).
|
|
258
456
|
*/
|
|
@@ -306,7 +504,7 @@ export interface PageLabelInit {
|
|
|
306
504
|
}
|
|
307
505
|
|
|
308
506
|
/**
|
|
309
|
-
* One text run (`laminapdf::extract::
|
|
507
|
+
* One text run (`laminapdf::extract::PageTextRun`): glyphs of one font, size, direction and marked
|
|
310
508
|
* content on one baseline, in logical order.
|
|
311
509
|
*/
|
|
312
510
|
export interface TextRunJs {
|
|
@@ -348,6 +546,48 @@ export interface TextRunJs {
|
|
|
348
546
|
glyphs: [number, number];
|
|
349
547
|
}
|
|
350
548
|
|
|
549
|
+
/**
|
|
550
|
+
* Options for `WasmDocument.extract`.
|
|
551
|
+
*/
|
|
552
|
+
export interface ExtractInit {
|
|
553
|
+
/**
|
|
554
|
+
* What to return.
|
|
555
|
+
*/
|
|
556
|
+
format: ExtractFormat;
|
|
557
|
+
/**
|
|
558
|
+
* The 0-based page indices to extract, in this order; every page by default.
|
|
559
|
+
*/
|
|
560
|
+
pages?: number[];
|
|
561
|
+
/**
|
|
562
|
+
* Where the reading order comes from; `"auto"` by default.
|
|
563
|
+
*/
|
|
564
|
+
readingOrder?: ReadingOrderName;
|
|
565
|
+
/**
|
|
566
|
+
* What happens to hidden text.
|
|
567
|
+
*/
|
|
568
|
+
drop?: DropInit;
|
|
569
|
+
/**
|
|
570
|
+
* Which table detectors run; `"lattice"` by default.
|
|
571
|
+
*/
|
|
572
|
+
tables?: TableModeName;
|
|
573
|
+
/**
|
|
574
|
+
* Join words hyphenated across lines; on by default.
|
|
575
|
+
*/
|
|
576
|
+
dehyphenate?: boolean;
|
|
577
|
+
/**
|
|
578
|
+
* Write `<!-- page N -->` before each page's first block (Markdown, chunks and JSON).
|
|
579
|
+
*/
|
|
580
|
+
pageMarkers?: boolean;
|
|
581
|
+
/**
|
|
582
|
+
* How chunks are cut (`chunks`, and `json` to include them).
|
|
583
|
+
*/
|
|
584
|
+
chunk?: ChunkInit;
|
|
585
|
+
/**
|
|
586
|
+
* Models the host runs (`extractJob` only): the job asks for their results.
|
|
587
|
+
*/
|
|
588
|
+
models?: ModelsInit;
|
|
589
|
+
}
|
|
590
|
+
|
|
351
591
|
/**
|
|
352
592
|
* Options for `WasmDocument.openBytes`.
|
|
353
593
|
*/
|
|
@@ -553,6 +793,28 @@ export interface MetadataInit {
|
|
|
553
793
|
*/
|
|
554
794
|
export type ModificationClass = "metadata" | "formFill" | "annotation" | "signature" | "pageStructure" | "content" | "document";
|
|
555
795
|
|
|
796
|
+
/**
|
|
797
|
+
* The models the host runs for an extraction job.
|
|
798
|
+
*/
|
|
799
|
+
export interface ModelsInit {
|
|
800
|
+
/**
|
|
801
|
+
* A layout model: every page's regions are asked for.
|
|
802
|
+
*/
|
|
803
|
+
layout?: ModelInfoInit;
|
|
804
|
+
/**
|
|
805
|
+
* An OCR engine: pages with no visible text are asked for.
|
|
806
|
+
*/
|
|
807
|
+
ocr?: ModelInfoInit;
|
|
808
|
+
/**
|
|
809
|
+
* The resolution pages are asked for at; 150 by default.
|
|
810
|
+
*/
|
|
811
|
+
dpi?: number;
|
|
812
|
+
/**
|
|
813
|
+
* OCR's languages (BCP 47).
|
|
814
|
+
*/
|
|
815
|
+
langs?: string[];
|
|
816
|
+
}
|
|
817
|
+
|
|
556
818
|
/**
|
|
557
819
|
* The pages an edit touched.
|
|
558
820
|
*/
|
|
@@ -573,6 +835,16 @@ export type PageModeInit = "none" | "outlines" | "thumbnails" | "fullScreen" | "
|
|
|
573
835
|
*/
|
|
574
836
|
export type SaveModeJs = "auto" | "incremental" | "fullRewrite";
|
|
575
837
|
|
|
838
|
+
/**
|
|
839
|
+
* What `WasmDocument.extract` returns.
|
|
840
|
+
*/
|
|
841
|
+
export type ExtractFormat = "markdown" | "json" | "text" | "chunks";
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* What `provide` takes.
|
|
845
|
+
*/
|
|
846
|
+
export type ModelResultInit = { kind: "layout"; regions: RegionInit[] } | { kind: "ocr"; words: WordInit[] };
|
|
847
|
+
|
|
576
848
|
/**
|
|
577
849
|
* What a save wrote (`laminapdf::SaveReport`).
|
|
578
850
|
*/
|
|
@@ -608,11 +880,41 @@ export interface SaveReportJs {
|
|
|
608
880
|
*/
|
|
609
881
|
export type OutputJs = "whole" | "appendedOnly";
|
|
610
882
|
|
|
883
|
+
/**
|
|
884
|
+
* What happens to hidden text and page furniture.
|
|
885
|
+
*/
|
|
886
|
+
export interface DropInit {
|
|
887
|
+
/**
|
|
888
|
+
* Keep each dropped run's text in its `dropped` entry (JSON only), for auditing a file.
|
|
889
|
+
*/
|
|
890
|
+
keepSpans?: boolean;
|
|
891
|
+
/**
|
|
892
|
+
* Drop running headers, footers, page numbers and artifact-marked text too, listing them
|
|
893
|
+
* in `dropped`; on by default.
|
|
894
|
+
*/
|
|
895
|
+
furniture?: boolean;
|
|
896
|
+
}
|
|
897
|
+
|
|
611
898
|
/**
|
|
612
899
|
* Where a link or outline item goes.
|
|
613
900
|
*/
|
|
614
901
|
export type LinkTargetInit = { type: "uri"; uri: string } | { type: "page"; index: number; fit?: FitInit } | { type: "named"; name: string };
|
|
615
902
|
|
|
903
|
+
/**
|
|
904
|
+
* Where chunks may start.
|
|
905
|
+
*/
|
|
906
|
+
export type SplitOnName = "headings" | "blocks" | "pages";
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* Where the reading order comes from.
|
|
910
|
+
*/
|
|
911
|
+
export type ReadingOrderName = "auto" | "tagged" | "layout" | "content-stream";
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* Which table detectors run.
|
|
915
|
+
*/
|
|
916
|
+
export type TableModeName = "off" | "lattice" | "lattice-and-stream";
|
|
917
|
+
|
|
616
918
|
/**
|
|
617
919
|
* `Limits` with every field optional (ADR 0003 §3; names as in Rust, camelCase).
|
|
618
920
|
*/
|
|
@@ -782,6 +1084,25 @@ export class WasmDocument {
|
|
|
782
1084
|
* error (nothing is applied).
|
|
783
1085
|
*/
|
|
784
1086
|
apply(ops: Op[]): EditedJs;
|
|
1087
|
+
/**
|
|
1088
|
+
* An extraction stepped a page at a time, whose models the host runs: each step returns
|
|
1089
|
+
* its progress, with the result it waits for under `request` (render that page at `dpi`,
|
|
1090
|
+
* run the model, hand the result to `provide`), and once every page is done, the output in
|
|
1091
|
+
* `options.format` (the extract and text modules).
|
|
1092
|
+
*
|
|
1093
|
+
* # Errors
|
|
1094
|
+
* As `extract`, for the options and the pages asked for.
|
|
1095
|
+
*/
|
|
1096
|
+
extractJob(options: ExtractInit): WasmExtractJob;
|
|
1097
|
+
/**
|
|
1098
|
+
* The document's text for retrieval and LLMs, as one string: Markdown, plain text, the
|
|
1099
|
+
* `laminapdf.extract/1` JSON, or the chunks as a JSON array (the extract and text modules).
|
|
1100
|
+
*
|
|
1101
|
+
* # Errors
|
|
1102
|
+
* `page-index-out-of-range` for a page in `pages` past the end; `data-pending` and the
|
|
1103
|
+
* reading errors; `unknown-option` / `invalid-argument` for bad options.
|
|
1104
|
+
*/
|
|
1105
|
+
extract(options: ExtractInit): string;
|
|
785
1106
|
/**
|
|
786
1107
|
* Whether there are changes no save has written yet.
|
|
787
1108
|
*/
|
|
@@ -793,6 +1114,21 @@ export class WasmDocument {
|
|
|
793
1114
|
* Reading errors.
|
|
794
1115
|
*/
|
|
795
1116
|
info(): DocumentInfoJs;
|
|
1117
|
+
/**
|
|
1118
|
+
* Whether the document says it is tagged (`/MarkInfo /Marked true`; the extract and text modules).
|
|
1119
|
+
*
|
|
1120
|
+
* # Errors
|
|
1121
|
+
* Reading errors.
|
|
1122
|
+
*/
|
|
1123
|
+
isTagged(): boolean;
|
|
1124
|
+
/**
|
|
1125
|
+
* The named destination `name`, or `undefined` when the document has none by that name or
|
|
1126
|
+
* it names no page here (the extract and text modules).
|
|
1127
|
+
*
|
|
1128
|
+
* # Errors
|
|
1129
|
+
* `data-pending` and the reading errors.
|
|
1130
|
+
*/
|
|
1131
|
+
namedDestination(name: string): TargetJs | undefined;
|
|
796
1132
|
/**
|
|
797
1133
|
* Opens a document from its bytes.
|
|
798
1134
|
*
|
|
@@ -810,6 +1146,14 @@ export class WasmDocument {
|
|
|
810
1146
|
* As `openBytes`, and `data-pending`.
|
|
811
1147
|
*/
|
|
812
1148
|
static openSource(source: WasmSparseSource, options: OpenOptionsInit | undefined): WasmDocument;
|
|
1149
|
+
/**
|
|
1150
|
+
* The outline's top-level items, each with its children; empty without an outline (the
|
|
1151
|
+
* extract and text modules).
|
|
1152
|
+
*
|
|
1153
|
+
* # Errors
|
|
1154
|
+
* `data-pending` and the reading errors.
|
|
1155
|
+
*/
|
|
1156
|
+
outline(): OutlineNodeJs[];
|
|
813
1157
|
/**
|
|
814
1158
|
* A handle on the page with `id` (`p12.0`).
|
|
815
1159
|
*
|
|
@@ -873,6 +1217,14 @@ export class WasmDocument {
|
|
|
873
1217
|
* The save's errors (`would-invalidate-signatures`, `requires-rewrite`, …).
|
|
874
1218
|
*/
|
|
875
1219
|
save(options: SaveOptionsInit | undefined): { bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs };
|
|
1220
|
+
/**
|
|
1221
|
+
* The structure tree's top-level elements in reading order, or `undefined` without one (the
|
|
1222
|
+
* extract and text modules, beside `WasmPage.text`, whose runs it links by MCID).
|
|
1223
|
+
*
|
|
1224
|
+
* # Errors
|
|
1225
|
+
* Reading errors.
|
|
1226
|
+
*/
|
|
1227
|
+
structureTree(): StructureNodeJs[] | undefined;
|
|
876
1228
|
/**
|
|
877
1229
|
* Undoes the newest transaction; `undefined` when there is nothing to undo.
|
|
878
1230
|
*
|
|
@@ -886,6 +1238,38 @@ export class WasmDocument {
|
|
|
886
1238
|
warnings(): WasmWarningCursor;
|
|
887
1239
|
}
|
|
888
1240
|
|
|
1241
|
+
/**
|
|
1242
|
+
* An extraction in progress, from `WasmDocument.extractJob`; it holds its document weakly.
|
|
1243
|
+
*/
|
|
1244
|
+
export class WasmExtractJob {
|
|
1245
|
+
private constructor();
|
|
1246
|
+
free(): void;
|
|
1247
|
+
[Symbol.dispose](): void;
|
|
1248
|
+
/**
|
|
1249
|
+
* Stops the job: its next step fails with `cancelled`.
|
|
1250
|
+
*/
|
|
1251
|
+
cancel(): void;
|
|
1252
|
+
/**
|
|
1253
|
+
* Hands the job the result of its open request: `{ kind: "layout", regions }` or
|
|
1254
|
+
* `{ kind: "ocr", words }`, boxes as `[x, y, width, height]` in top-left points.
|
|
1255
|
+
*
|
|
1256
|
+
* # Errors
|
|
1257
|
+
* `model-result-unexpected` when nothing was asked for or `result` is the other kind;
|
|
1258
|
+
* `invalid-argument` / `unknown-option` for a malformed result.
|
|
1259
|
+
*/
|
|
1260
|
+
provide(result: ModelResultInit): void;
|
|
1261
|
+
/**
|
|
1262
|
+
* Extracts up to `budget` pages: `{ state: "progress", done, total, phase, request? }` or
|
|
1263
|
+
* `{ state: "done", output }`, the output in the job's format. While `request` is set, a
|
|
1264
|
+
* step does nothing until `provide` answers it.
|
|
1265
|
+
*
|
|
1266
|
+
* # Errors
|
|
1267
|
+
* `cancelled`, `document-changed`, `job-finished`, `disposed` when the document is freed,
|
|
1268
|
+
* and the reading errors.
|
|
1269
|
+
*/
|
|
1270
|
+
step(budget: number): ({ state: "progress" } & ExtractProgressJs) | { state: "done"; output: string };
|
|
1271
|
+
}
|
|
1272
|
+
|
|
889
1273
|
/**
|
|
890
1274
|
* An image to draw (decoded or passed through once, shared by every use).
|
|
891
1275
|
*/
|
|
@@ -935,7 +1319,8 @@ export class WasmPage {
|
|
|
935
1319
|
* The page's current 0-based index.
|
|
936
1320
|
*
|
|
937
1321
|
* # Errors
|
|
938
|
-
* `unknown-page` when the page is gone; reading
|
|
1322
|
+
* `unknown-page` when the page is gone; `disposed` when its document is freed; reading
|
|
1323
|
+
* errors.
|
|
939
1324
|
*/
|
|
940
1325
|
index(): number;
|
|
941
1326
|
/**
|
|
@@ -946,12 +1331,12 @@ export class WasmPage {
|
|
|
946
1331
|
*/
|
|
947
1332
|
info(): PageInfoJs;
|
|
948
1333
|
/**
|
|
949
|
-
* The page's text: lines, runs, glyph quads and glyph text (
|
|
950
|
-
* modules).
|
|
1334
|
+
* The page's text: lines, runs, glyph quads and glyph text (the extract and text modules).
|
|
951
1335
|
*
|
|
952
1336
|
* # Errors
|
|
953
|
-
* `unknown-page` when the page is gone; `
|
|
954
|
-
* `unknown-option` / `invalid-argument` for bad
|
|
1337
|
+
* `unknown-page` when the page is gone; `disposed` when its document is freed;
|
|
1338
|
+
* `data-pending` and the reading errors; `unknown-option` / `invalid-argument` for bad
|
|
1339
|
+
* options.
|
|
955
1340
|
*/
|
|
956
1341
|
text(options: TextOptionsInit | undefined): PageTextJs;
|
|
957
1342
|
/**
|
|
@@ -970,7 +1355,8 @@ export class WasmPageBuilder {
|
|
|
970
1355
|
[Symbol.dispose](): void;
|
|
971
1356
|
/**
|
|
972
1357
|
* Opens an artifact until the matching `endTag`: `kind` is `layout`, `page`, `pagination`
|
|
973
|
-
* or `background
|
|
1358
|
+
* or `background`, or a pagination artifact that says what it is: `header` (attached to the
|
|
1359
|
+
* top edge), `footer` (the bottom) or `watermark`.
|
|
974
1360
|
*
|
|
975
1361
|
* # Errors
|
|
976
1362
|
* `invalid-argument` for another kind.
|
|
@@ -1155,7 +1541,8 @@ export class WasmSaveJob {
|
|
|
1155
1541
|
* `{ state: "done", bytes, report }`.
|
|
1156
1542
|
*
|
|
1157
1543
|
* # Errors
|
|
1158
|
-
* `cancelled`, `document-changed`, `job-finished`,
|
|
1544
|
+
* `cancelled`, `document-changed`, `job-finished`, `disposed` when the document is freed,
|
|
1545
|
+
* or the save's own errors.
|
|
1159
1546
|
*/
|
|
1160
1547
|
step(budget: number): ({ state: "progress" } & ProgressJs) | { state: "done"; bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs };
|
|
1161
1548
|
}
|
|
@@ -1214,6 +1601,14 @@ export class WasmWarningCursor {
|
|
|
1214
1601
|
remaining(): number;
|
|
1215
1602
|
}
|
|
1216
1603
|
|
|
1604
|
+
export function __wbg_reset_state(): void;
|
|
1605
|
+
|
|
1606
|
+
/**
|
|
1607
|
+
* Whether the most recent allocation failed: after a trap, `true` means the module ran out of
|
|
1608
|
+
* memory.
|
|
1609
|
+
*/
|
|
1610
|
+
export function allocationFailed(): boolean;
|
|
1611
|
+
|
|
1217
1612
|
/**
|
|
1218
1613
|
* Whether this module is the text module (fonts, `text`, `textBox`).
|
|
1219
1614
|
*/
|
|
@@ -1230,12 +1625,14 @@ export interface InitOutput {
|
|
|
1230
1625
|
readonly memory: WebAssembly.Memory;
|
|
1231
1626
|
readonly __wbg_wasmbuilder_free: (a: number, b: number) => void;
|
|
1232
1627
|
readonly __wbg_wasmdocument_free: (a: number, b: number) => void;
|
|
1628
|
+
readonly __wbg_wasmextractjob_free: (a: number, b: number) => void;
|
|
1233
1629
|
readonly __wbg_wasmimage_free: (a: number, b: number) => void;
|
|
1234
1630
|
readonly __wbg_wasmpage_free: (a: number, b: number) => void;
|
|
1235
1631
|
readonly __wbg_wasmpagebuilder_free: (a: number, b: number) => void;
|
|
1236
1632
|
readonly __wbg_wasmsavejob_free: (a: number, b: number) => void;
|
|
1237
1633
|
readonly __wbg_wasmsparsesource_free: (a: number, b: number) => void;
|
|
1238
1634
|
readonly __wbg_wasmwarningcursor_free: (a: number, b: number) => void;
|
|
1635
|
+
readonly allocationFailed: () => number;
|
|
1239
1636
|
readonly hasText: () => number;
|
|
1240
1637
|
readonly version: () => [number, number];
|
|
1241
1638
|
readonly wasmbuilder_attach: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number];
|
|
@@ -1250,10 +1647,15 @@ export interface InitOutput {
|
|
|
1250
1647
|
readonly wasmbuilder_viewerPreferences: (a: number, b: any) => [number, number];
|
|
1251
1648
|
readonly wasmdocument_apply: (a: number, b: any) => [number, number, number];
|
|
1252
1649
|
readonly wasmdocument_applyLog: (a: number, b: number, c: number) => [number, number, number];
|
|
1650
|
+
readonly wasmdocument_extract: (a: number, b: any) => [number, number, number, number];
|
|
1651
|
+
readonly wasmdocument_extractJob: (a: number, b: any) => [number, number, number];
|
|
1253
1652
|
readonly wasmdocument_hasUnsavedChanges: (a: number) => number;
|
|
1254
1653
|
readonly wasmdocument_info: (a: number) => [number, number, number];
|
|
1654
|
+
readonly wasmdocument_isTagged: (a: number) => [number, number, number];
|
|
1655
|
+
readonly wasmdocument_namedDestination: (a: number, b: number, c: number) => [number, number, number];
|
|
1255
1656
|
readonly wasmdocument_openBytes: (a: number, b: number, c: any) => [number, number, number];
|
|
1256
1657
|
readonly wasmdocument_openSource: (a: number, b: any) => [number, number, number];
|
|
1658
|
+
readonly wasmdocument_outline: (a: number) => [number, number, number];
|
|
1257
1659
|
readonly wasmdocument_page: (a: number, b: number) => [number, number, number];
|
|
1258
1660
|
readonly wasmdocument_pageById: (a: number, b: number, c: number) => [number, number, number];
|
|
1259
1661
|
readonly wasmdocument_pageCount: (a: number) => [number, number, number];
|
|
@@ -1263,8 +1665,12 @@ export interface InitOutput {
|
|
|
1263
1665
|
readonly wasmdocument_redo: (a: number) => [number, number, number];
|
|
1264
1666
|
readonly wasmdocument_save: (a: number, b: any) => [number, number, number];
|
|
1265
1667
|
readonly wasmdocument_saveJob: (a: number, b: any) => [number, number, number];
|
|
1668
|
+
readonly wasmdocument_structureTree: (a: number) => [number, number, number];
|
|
1266
1669
|
readonly wasmdocument_undo: (a: number) => [number, number, number];
|
|
1267
1670
|
readonly wasmdocument_warnings: (a: number) => number;
|
|
1671
|
+
readonly wasmextractjob_cancel: (a: number) => void;
|
|
1672
|
+
readonly wasmextractjob_provide: (a: number, b: any) => [number, number];
|
|
1673
|
+
readonly wasmextractjob_step: (a: number, b: number) => [number, number, number];
|
|
1268
1674
|
readonly wasmimage_height: (a: number) => number;
|
|
1269
1675
|
readonly wasmimage_jpeg: (a: number, b: number) => [number, number, number];
|
|
1270
1676
|
readonly wasmimage_png: (a: number, b: number) => [number, number, number];
|