@laminapdf/wasm 0.2.0-alpha.2 → 0.2.0-alpha.3
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 +13 -2
- package/dist/lamina_pdf_base.js +225 -84
- package/dist/lamina_pdf_base.wasm +0 -0
- package/dist/lamina_pdf_extract.d.ts +120 -8
- package/dist/lamina_pdf_extract.js +262 -89
- package/dist/lamina_pdf_extract.wasm +0 -0
- package/dist/lamina_pdf_render_hayro.wasm +0 -0
- package/dist/lamina_pdf_text.d.ts +120 -8
- package/dist/lamina_pdf_text.js +283 -98
- 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[];
|
|
@@ -286,6 +286,24 @@ export type AfRelationshipInit = "source" | "data" | "alternative" | "supplement
|
|
|
286
286
|
*/
|
|
287
287
|
export type UndoOutcomeJs = "applied" | "partial" | "skipped";
|
|
288
288
|
|
|
289
|
+
/**
|
|
290
|
+
* How the Markdown is cut into chunks.
|
|
291
|
+
*/
|
|
292
|
+
export interface ChunkInit {
|
|
293
|
+
/**
|
|
294
|
+
* A chunk's budget in approximate tokens (characters / 4); 512 by default.
|
|
295
|
+
*/
|
|
296
|
+
maxTokens?: number;
|
|
297
|
+
/**
|
|
298
|
+
* Approximate tokens of whole blocks repeated from the chunk before; 0 by default.
|
|
299
|
+
*/
|
|
300
|
+
overlap?: number;
|
|
301
|
+
/**
|
|
302
|
+
* Where chunks may start; `"headings"` by default.
|
|
303
|
+
*/
|
|
304
|
+
splitOn?: SplitOnName;
|
|
305
|
+
}
|
|
306
|
+
|
|
289
307
|
/**
|
|
290
308
|
* How viewers present the document when it opens.
|
|
291
309
|
*/
|
|
@@ -423,7 +441,7 @@ export interface PageLabelInit {
|
|
|
423
441
|
}
|
|
424
442
|
|
|
425
443
|
/**
|
|
426
|
-
* One text run (`laminapdf::extract::
|
|
444
|
+
* One text run (`laminapdf::extract::PageTextRun`): glyphs of one font, size, direction and marked
|
|
427
445
|
* content on one baseline, in logical order.
|
|
428
446
|
*/
|
|
429
447
|
export interface TextRunJs {
|
|
@@ -465,6 +483,44 @@ export interface TextRunJs {
|
|
|
465
483
|
glyphs: [number, number];
|
|
466
484
|
}
|
|
467
485
|
|
|
486
|
+
/**
|
|
487
|
+
* Options for `WasmDocument.extract`.
|
|
488
|
+
*/
|
|
489
|
+
export interface ExtractInit {
|
|
490
|
+
/**
|
|
491
|
+
* What to return.
|
|
492
|
+
*/
|
|
493
|
+
format: ExtractFormat;
|
|
494
|
+
/**
|
|
495
|
+
* The 0-based page indices to extract, in this order; every page by default.
|
|
496
|
+
*/
|
|
497
|
+
pages?: number[];
|
|
498
|
+
/**
|
|
499
|
+
* Where the reading order comes from; `"auto"` by default.
|
|
500
|
+
*/
|
|
501
|
+
readingOrder?: ReadingOrderName;
|
|
502
|
+
/**
|
|
503
|
+
* What happens to hidden text.
|
|
504
|
+
*/
|
|
505
|
+
drop?: DropInit;
|
|
506
|
+
/**
|
|
507
|
+
* Which table detectors run; `"lattice"` by default.
|
|
508
|
+
*/
|
|
509
|
+
tables?: TableModeName;
|
|
510
|
+
/**
|
|
511
|
+
* Join words hyphenated across lines; on by default.
|
|
512
|
+
*/
|
|
513
|
+
dehyphenate?: boolean;
|
|
514
|
+
/**
|
|
515
|
+
* Write `<!-- page N -->` before each page's first block (Markdown, chunks and JSON).
|
|
516
|
+
*/
|
|
517
|
+
pageMarkers?: boolean;
|
|
518
|
+
/**
|
|
519
|
+
* How chunks are cut (`chunks`, and `json` to include them).
|
|
520
|
+
*/
|
|
521
|
+
chunk?: ChunkInit;
|
|
522
|
+
}
|
|
523
|
+
|
|
468
524
|
/**
|
|
469
525
|
* Options for `WasmDocument.openBytes`.
|
|
470
526
|
*/
|
|
@@ -730,6 +786,11 @@ export type PageModeInit = "none" | "outlines" | "thumbnails" | "fullScreen" | "
|
|
|
730
786
|
*/
|
|
731
787
|
export type SaveModeJs = "auto" | "incremental" | "fullRewrite";
|
|
732
788
|
|
|
789
|
+
/**
|
|
790
|
+
* What `WasmDocument.extract` returns.
|
|
791
|
+
*/
|
|
792
|
+
export type ExtractFormat = "markdown" | "json" | "text" | "chunks";
|
|
793
|
+
|
|
733
794
|
/**
|
|
734
795
|
* What a run measures.
|
|
735
796
|
*/
|
|
@@ -783,6 +844,21 @@ export interface SaveReportJs {
|
|
|
783
844
|
*/
|
|
784
845
|
export type OutputJs = "whole" | "appendedOnly";
|
|
785
846
|
|
|
847
|
+
/**
|
|
848
|
+
* What happens to hidden text and page furniture.
|
|
849
|
+
*/
|
|
850
|
+
export interface DropInit {
|
|
851
|
+
/**
|
|
852
|
+
* Keep each dropped run's text in its `dropped` entry (JSON only), for auditing a file.
|
|
853
|
+
*/
|
|
854
|
+
keepSpans?: boolean;
|
|
855
|
+
/**
|
|
856
|
+
* Drop running headers, footers, page numbers and artifact-marked text too, listing them
|
|
857
|
+
* in `dropped`; on by default.
|
|
858
|
+
*/
|
|
859
|
+
furniture?: boolean;
|
|
860
|
+
}
|
|
861
|
+
|
|
786
862
|
/**
|
|
787
863
|
* What happens to text that doesn't fit a text box.
|
|
788
864
|
*/
|
|
@@ -793,6 +869,21 @@ export type OverflowInit = "clip" | "error";
|
|
|
793
869
|
*/
|
|
794
870
|
export type LinkTargetInit = { type: "uri"; uri: string } | { type: "page"; index: number; fit?: FitInit } | { type: "named"; name: string };
|
|
795
871
|
|
|
872
|
+
/**
|
|
873
|
+
* Where chunks may start.
|
|
874
|
+
*/
|
|
875
|
+
export type SplitOnName = "headings" | "blocks" | "pages";
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* Where the reading order comes from.
|
|
879
|
+
*/
|
|
880
|
+
export type ReadingOrderName = "auto" | "tagged" | "layout" | "content-stream";
|
|
881
|
+
|
|
882
|
+
/**
|
|
883
|
+
* Which table detectors run.
|
|
884
|
+
*/
|
|
885
|
+
export type TableModeName = "off" | "lattice" | "lattice-and-stream";
|
|
886
|
+
|
|
796
887
|
/**
|
|
797
888
|
* `Limits` with every field optional (ADR 0003 §3; names as in Rust, camelCase).
|
|
798
889
|
*/
|
|
@@ -978,6 +1069,15 @@ export class WasmDocument {
|
|
|
978
1069
|
* error (nothing is applied).
|
|
979
1070
|
*/
|
|
980
1071
|
apply(ops: Op[]): EditedJs;
|
|
1072
|
+
/**
|
|
1073
|
+
* The document's text for retrieval and LLMs, as one string: Markdown, plain text, the
|
|
1074
|
+
* `laminapdf.extract/1` JSON, or the chunks as a JSON array (the extract and text modules).
|
|
1075
|
+
*
|
|
1076
|
+
* # Errors
|
|
1077
|
+
* `page-index-out-of-range` for a page in `pages` past the end; `data-pending` and the
|
|
1078
|
+
* reading errors; `unknown-option` / `invalid-argument` for bad options.
|
|
1079
|
+
*/
|
|
1080
|
+
extract(options: ExtractInit): string;
|
|
981
1081
|
/**
|
|
982
1082
|
* Whether there are changes no save has written yet.
|
|
983
1083
|
*/
|
|
@@ -1152,7 +1252,8 @@ export class WasmPage {
|
|
|
1152
1252
|
* The page's current 0-based index.
|
|
1153
1253
|
*
|
|
1154
1254
|
* # Errors
|
|
1155
|
-
* `unknown-page` when the page is gone; reading
|
|
1255
|
+
* `unknown-page` when the page is gone; `disposed` when its document is freed; reading
|
|
1256
|
+
* errors.
|
|
1156
1257
|
*/
|
|
1157
1258
|
index(): number;
|
|
1158
1259
|
/**
|
|
@@ -1163,12 +1264,12 @@ export class WasmPage {
|
|
|
1163
1264
|
*/
|
|
1164
1265
|
info(): PageInfoJs;
|
|
1165
1266
|
/**
|
|
1166
|
-
* The page's text: lines, runs, glyph quads and glyph text (
|
|
1167
|
-
* modules).
|
|
1267
|
+
* The page's text: lines, runs, glyph quads and glyph text (the extract and text modules).
|
|
1168
1268
|
*
|
|
1169
1269
|
* # Errors
|
|
1170
|
-
* `unknown-page` when the page is gone; `
|
|
1171
|
-
* `unknown-option` / `invalid-argument` for bad
|
|
1270
|
+
* `unknown-page` when the page is gone; `disposed` when its document is freed;
|
|
1271
|
+
* `data-pending` and the reading errors; `unknown-option` / `invalid-argument` for bad
|
|
1272
|
+
* options.
|
|
1172
1273
|
*/
|
|
1173
1274
|
text(options: TextOptionsInit | undefined): PageTextJs;
|
|
1174
1275
|
/**
|
|
@@ -1389,7 +1490,8 @@ export class WasmSaveJob {
|
|
|
1389
1490
|
* `{ state: "done", bytes, report }`.
|
|
1390
1491
|
*
|
|
1391
1492
|
* # Errors
|
|
1392
|
-
* `cancelled`, `document-changed`, `job-finished`,
|
|
1493
|
+
* `cancelled`, `document-changed`, `job-finished`, `disposed` when the document is freed,
|
|
1494
|
+
* or the save's own errors.
|
|
1393
1495
|
*/
|
|
1394
1496
|
step(budget: number): ({ state: "progress" } & ProgressJs) | { state: "done"; bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs };
|
|
1395
1497
|
}
|
|
@@ -1448,6 +1550,14 @@ export class WasmWarningCursor {
|
|
|
1448
1550
|
remaining(): number;
|
|
1449
1551
|
}
|
|
1450
1552
|
|
|
1553
|
+
export function __wbg_reset_state(): void;
|
|
1554
|
+
|
|
1555
|
+
/**
|
|
1556
|
+
* Whether the most recent allocation failed: after a trap, `true` means the module ran out of
|
|
1557
|
+
* memory.
|
|
1558
|
+
*/
|
|
1559
|
+
export function allocationFailed(): boolean;
|
|
1560
|
+
|
|
1451
1561
|
/**
|
|
1452
1562
|
* Whether this module is the text module (fonts, `text`, `textBox`).
|
|
1453
1563
|
*/
|
|
@@ -1471,6 +1581,7 @@ export interface InitOutput {
|
|
|
1471
1581
|
readonly __wbg_wasmsavejob_free: (a: number, b: number) => void;
|
|
1472
1582
|
readonly __wbg_wasmsparsesource_free: (a: number, b: number) => void;
|
|
1473
1583
|
readonly __wbg_wasmwarningcursor_free: (a: number, b: number) => void;
|
|
1584
|
+
readonly allocationFailed: () => number;
|
|
1474
1585
|
readonly hasText: () => number;
|
|
1475
1586
|
readonly version: () => [number, number];
|
|
1476
1587
|
readonly wasmbuilder_attach: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number];
|
|
@@ -1487,6 +1598,7 @@ export interface InitOutput {
|
|
|
1487
1598
|
readonly wasmbuilder_viewerPreferences: (a: number, b: any) => [number, number];
|
|
1488
1599
|
readonly wasmdocument_apply: (a: number, b: any) => [number, number, number];
|
|
1489
1600
|
readonly wasmdocument_applyLog: (a: number, b: number, c: number) => [number, number, number];
|
|
1601
|
+
readonly wasmdocument_extract: (a: number, b: any) => [number, number, number, number];
|
|
1490
1602
|
readonly wasmdocument_hasUnsavedChanges: (a: number) => number;
|
|
1491
1603
|
readonly wasmdocument_info: (a: number) => [number, number, number];
|
|
1492
1604
|
readonly wasmdocument_openBytes: (a: number, b: number, c: any) => [number, number, number];
|