@llamaindex/liteparse 2.13.0 → 2.14.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 +38 -0
- package/dist/cli.js +1236 -398
- package/dist/cli.js.map +1 -1
- package/dist/lib.cjs +712 -0
- package/dist/lib.cjs.map +1 -0
- package/dist/lib.d.cts +911 -0
- package/dist/lib.d.ts +339 -38
- package/dist/lib.js +654 -323
- package/dist/lib.js.map +1 -1
- package/dist/pool-worker.js +253 -0
- package/dist/pool-worker.js.map +1 -0
- package/liteparse.linux-x64-gnu.node +0 -0
- package/package.json +22 -12
- package/dist/cli-json.d.ts +0 -154
- package/dist/cli-json.d.ts.map +0 -1
- package/dist/cli-json.js +0 -241
- package/dist/cli-json.js.map +0 -1
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/lib.d.ts.map +0 -1
- package/dist/native.d.ts +0 -345
- package/dist/native.d.ts.map +0 -1
- package/dist/native.js +0 -71
- package/dist/native.js.map +0 -1
package/dist/lib.d.ts
CHANGED
|
@@ -1,7 +1,289 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
interface NativeWordBox {
|
|
2
|
+
text: string;
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
interface NativeTextItem {
|
|
9
|
+
text: string;
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
fontName?: string;
|
|
15
|
+
fontSize?: number;
|
|
16
|
+
fontHeight?: number;
|
|
17
|
+
fontAscent?: number;
|
|
18
|
+
fontDescent?: number;
|
|
19
|
+
fontWeight?: number;
|
|
20
|
+
textWidth?: number;
|
|
21
|
+
fontIsBuggy?: boolean;
|
|
22
|
+
mcid?: number;
|
|
23
|
+
fillColor?: string;
|
|
24
|
+
strokeColor?: string;
|
|
25
|
+
charCodes?: number[];
|
|
26
|
+
trailingSpaceGenerated?: boolean;
|
|
27
|
+
confidence?: number;
|
|
28
|
+
rotation?: number;
|
|
29
|
+
words?: NativeWordBox[];
|
|
30
|
+
}
|
|
31
|
+
interface NativeRect {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
}
|
|
37
|
+
interface NativeParsedPage {
|
|
38
|
+
pageNum: number;
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
contentBounds?: NativeRect;
|
|
42
|
+
text: string;
|
|
43
|
+
markdown: string;
|
|
44
|
+
textItems: NativeTextItem[];
|
|
45
|
+
complexity?: NativePageComplexityStats;
|
|
46
|
+
vectorGraphics?: NativeVectorGraphics;
|
|
47
|
+
annotations?: NativeDocumentAnnotation[];
|
|
48
|
+
formFields?: NativeFormField[];
|
|
49
|
+
structureTree?: NativeStructureTree;
|
|
50
|
+
blocks?: NativeLayoutBlock[];
|
|
51
|
+
}
|
|
52
|
+
interface NativeLayoutCell {
|
|
53
|
+
text: string;
|
|
54
|
+
bbox?: NativeRect;
|
|
55
|
+
}
|
|
56
|
+
interface NativeLayoutBlock {
|
|
57
|
+
kind: string;
|
|
58
|
+
text?: string;
|
|
59
|
+
level?: number;
|
|
60
|
+
bold?: boolean;
|
|
61
|
+
italic?: boolean;
|
|
62
|
+
ordered?: boolean;
|
|
63
|
+
marker?: string;
|
|
64
|
+
lines?: string[];
|
|
65
|
+
lang?: string;
|
|
66
|
+
header?: NativeLayoutCell[];
|
|
67
|
+
rows?: NativeLayoutCell[][];
|
|
68
|
+
id?: string;
|
|
69
|
+
format?: string;
|
|
70
|
+
bbox?: NativeRect;
|
|
71
|
+
}
|
|
72
|
+
interface NativeStructureAttribute {
|
|
73
|
+
name: string;
|
|
74
|
+
booleanValue?: boolean;
|
|
75
|
+
numberValue?: number;
|
|
76
|
+
stringValue?: string;
|
|
77
|
+
}
|
|
78
|
+
interface NativeStructureTree {
|
|
79
|
+
roots: NativeStructureTreeElement[];
|
|
80
|
+
}
|
|
81
|
+
interface NativeStructureTreeElement {
|
|
82
|
+
elementType: string;
|
|
83
|
+
id?: string;
|
|
84
|
+
actualText?: string;
|
|
85
|
+
altText?: string;
|
|
86
|
+
title?: string;
|
|
87
|
+
attributes: NativeStructureAttribute[];
|
|
88
|
+
markedContentIds: number[];
|
|
89
|
+
children: NativeStructureTreeElement[];
|
|
90
|
+
annotations: NativeDocumentAnnotation[];
|
|
91
|
+
}
|
|
92
|
+
interface NativeVectorGraphics {
|
|
93
|
+
shapes: Array<{
|
|
94
|
+
bbox: {
|
|
95
|
+
x: number;
|
|
96
|
+
y: number;
|
|
97
|
+
width: number;
|
|
98
|
+
height: number;
|
|
99
|
+
};
|
|
100
|
+
stroke: boolean;
|
|
101
|
+
strokeColor?: string;
|
|
102
|
+
fill: boolean;
|
|
103
|
+
fillColor?: string;
|
|
104
|
+
hasCurve: boolean;
|
|
105
|
+
}>;
|
|
106
|
+
lines: Array<{
|
|
107
|
+
x1: number;
|
|
108
|
+
y1: number;
|
|
109
|
+
x2: number;
|
|
110
|
+
y2: number;
|
|
111
|
+
stroke: boolean;
|
|
112
|
+
strokeWidth?: number;
|
|
113
|
+
strokeColor?: string;
|
|
114
|
+
fill: boolean;
|
|
115
|
+
fillColor?: string;
|
|
116
|
+
}>;
|
|
117
|
+
}
|
|
118
|
+
interface NativeAnnotationRect {
|
|
119
|
+
x: number;
|
|
120
|
+
y: number;
|
|
121
|
+
width: number;
|
|
122
|
+
height: number;
|
|
123
|
+
}
|
|
124
|
+
interface NativeDocumentAnnotation {
|
|
125
|
+
subtype: string;
|
|
126
|
+
contents?: string;
|
|
127
|
+
created?: string;
|
|
128
|
+
modified?: string;
|
|
129
|
+
title?: string;
|
|
130
|
+
rect?: NativeAnnotationRect;
|
|
131
|
+
quadpointRects: NativeAnnotationRect[];
|
|
132
|
+
uri?: string;
|
|
133
|
+
}
|
|
134
|
+
interface NativeFormField {
|
|
135
|
+
id: string;
|
|
136
|
+
fieldType: string;
|
|
137
|
+
page: number;
|
|
138
|
+
annotationIndex: number;
|
|
139
|
+
widgetIndex: number;
|
|
140
|
+
objectNumber?: number;
|
|
141
|
+
name?: string;
|
|
142
|
+
alternateName?: string;
|
|
143
|
+
value?: string;
|
|
144
|
+
exportValue?: string;
|
|
145
|
+
fieldFlags: number;
|
|
146
|
+
controlCount?: number;
|
|
147
|
+
controlIndex?: number;
|
|
148
|
+
checked?: boolean;
|
|
149
|
+
rect?: NativeAnnotationRect;
|
|
150
|
+
options: string[];
|
|
151
|
+
selectedOptions: string[];
|
|
152
|
+
}
|
|
153
|
+
interface NativeExtractedImage {
|
|
154
|
+
id: string;
|
|
155
|
+
name: string;
|
|
156
|
+
path?: string;
|
|
157
|
+
page: number;
|
|
158
|
+
bbox: {
|
|
159
|
+
x: number;
|
|
160
|
+
y: number;
|
|
161
|
+
width: number;
|
|
162
|
+
height: number;
|
|
163
|
+
};
|
|
164
|
+
width: number;
|
|
165
|
+
height: number;
|
|
166
|
+
rotation: number;
|
|
167
|
+
format: string;
|
|
168
|
+
duplicateOf?: string;
|
|
169
|
+
bytes: Buffer;
|
|
170
|
+
}
|
|
171
|
+
interface NativeParseResult {
|
|
172
|
+
totalPages: number;
|
|
173
|
+
pages: NativeParsedPage[];
|
|
174
|
+
pageErrors: Array<{
|
|
175
|
+
pageNum: number;
|
|
176
|
+
message: string;
|
|
177
|
+
}>;
|
|
178
|
+
text: string;
|
|
179
|
+
images: NativeExtractedImage[];
|
|
180
|
+
screenshots: NativeScreenshotResult[];
|
|
181
|
+
imageErrorCount: number;
|
|
182
|
+
formType?: number;
|
|
183
|
+
creator?: string;
|
|
184
|
+
producer?: string;
|
|
185
|
+
docMeta?: NativeDocumentMetadata;
|
|
186
|
+
xfaPackets?: NativeXfaPacket[];
|
|
187
|
+
}
|
|
188
|
+
interface NativeDocumentMetadata {
|
|
189
|
+
creationDate?: string;
|
|
190
|
+
modDate?: string;
|
|
191
|
+
fileVersion?: number;
|
|
192
|
+
isEncrypted?: boolean;
|
|
193
|
+
securityHandlerRevision?: number;
|
|
194
|
+
permissions?: number;
|
|
195
|
+
eofSectionCount?: number;
|
|
196
|
+
startxrefCount?: number;
|
|
197
|
+
trailerIdPairDiffers?: boolean;
|
|
198
|
+
rawFileSize?: number;
|
|
199
|
+
xmp?: string;
|
|
200
|
+
xmpTruncated?: boolean;
|
|
201
|
+
signatureCount?: number;
|
|
202
|
+
signatureByteRangeReachesEof?: boolean;
|
|
203
|
+
}
|
|
204
|
+
interface NativeXfaPacket {
|
|
205
|
+
index: number;
|
|
206
|
+
name?: string;
|
|
207
|
+
contentLength: number;
|
|
208
|
+
content?: string;
|
|
209
|
+
}
|
|
210
|
+
interface NativeScreenshotResult {
|
|
211
|
+
pageNum: number;
|
|
212
|
+
width: number;
|
|
213
|
+
height: number;
|
|
214
|
+
imageBuffer: Buffer;
|
|
215
|
+
isSolidFill: boolean;
|
|
216
|
+
rects: NativeScreenshotRect[];
|
|
217
|
+
}
|
|
218
|
+
interface NativeScreenshotRect {
|
|
219
|
+
x: number;
|
|
220
|
+
y: number;
|
|
221
|
+
width: number;
|
|
222
|
+
height: number;
|
|
223
|
+
color: string;
|
|
224
|
+
isLine: boolean;
|
|
225
|
+
}
|
|
226
|
+
interface NativeLayoutComplexityStats {
|
|
227
|
+
columnCount: number;
|
|
228
|
+
ruledTableCount: number;
|
|
229
|
+
ruledTableCoverage: number;
|
|
230
|
+
textTableRunCount: number;
|
|
231
|
+
figureCount: number;
|
|
232
|
+
figureCoverage: number;
|
|
233
|
+
isComplex: boolean;
|
|
234
|
+
reasons: string[];
|
|
235
|
+
}
|
|
236
|
+
interface NativePageComplexityStats {
|
|
237
|
+
pageNumber: number;
|
|
238
|
+
textLength: number;
|
|
239
|
+
textCoverage: number;
|
|
240
|
+
hasSubstantialImages: boolean;
|
|
241
|
+
imageBlockCount: number;
|
|
242
|
+
imageCoverage: number;
|
|
243
|
+
largestImageCoverage: number;
|
|
244
|
+
fullPageImage: boolean;
|
|
245
|
+
uncoveredVectorArea?: number;
|
|
246
|
+
isGarbled: boolean;
|
|
247
|
+
pageArea: number;
|
|
248
|
+
needsOcr: boolean;
|
|
249
|
+
reasons: string[];
|
|
250
|
+
layout?: NativeLayoutComplexityStats;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** A pooled parse exceeded `parseTimeoutMs` and its worker was killed.
|
|
254
|
+
*
|
|
255
|
+
* Only thrown in pool mode, where the deadline is enforced by killing the
|
|
256
|
+
* worker process — the timed-out parse is guaranteed dead, not still running
|
|
257
|
+
* in the background. `source` names the document (file path, or `<N bytes>`
|
|
258
|
+
* for byte inputs); log it to identify the documents that stall your
|
|
259
|
+
* pipeline.
|
|
260
|
+
*/
|
|
261
|
+
declare class ParseTimeoutError extends Error {
|
|
262
|
+
readonly source: string;
|
|
263
|
+
readonly timeoutMs: number;
|
|
264
|
+
constructor(message: string, source: string, timeoutMs: number);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
type LiteParseInput = string | Buffer | Uint8Array;
|
|
268
|
+
type OutputFormat = "json" | "text" | "markdown";
|
|
269
|
+
type ImageMode = "off" | "placeholder" | "embed";
|
|
270
|
+
/** Options for pool mode: parsing in persistent, killable worker processes. */
|
|
271
|
+
interface PoolOptions {
|
|
272
|
+
/**
|
|
273
|
+
* Route `parse()` through a pool of this many persistent worker processes.
|
|
274
|
+
* Call `close()` when done (an idle pool never keeps the event loop alive,
|
|
275
|
+
* but explicit shutdown frees workers immediately).
|
|
276
|
+
*/
|
|
277
|
+
poolSize?: number;
|
|
278
|
+
/**
|
|
279
|
+
* Hard per-parse deadline in milliseconds. Requires `poolSize`.
|
|
280
|
+
* The pool enforces the deadline by SIGKILLing the worker. On expiry
|
|
281
|
+
* the parse rejects with {@link ParseTimeoutError} (naming the document)
|
|
282
|
+
* and a fresh worker replaces the killed one.
|
|
283
|
+
*/
|
|
284
|
+
parseTimeoutMs?: number;
|
|
285
|
+
}
|
|
286
|
+
interface LiteParseConfig {
|
|
5
287
|
ocrLanguage: string;
|
|
6
288
|
ocrEnabled: boolean;
|
|
7
289
|
ocrServerUrl?: string;
|
|
@@ -105,7 +387,7 @@ export interface LiteParseConfig {
|
|
|
105
387
|
* A page sub-region expressed as the fraction cropped from each side
|
|
106
388
|
* (top-left origin, each value in `[0, 1]`).
|
|
107
389
|
*/
|
|
108
|
-
|
|
390
|
+
interface CropBox {
|
|
109
391
|
top: number;
|
|
110
392
|
right: number;
|
|
111
393
|
bottom: number;
|
|
@@ -115,14 +397,14 @@ export interface CropBox {
|
|
|
115
397
|
* One word's bounding box within a {@link TextItem}, in the same viewport space
|
|
116
398
|
* (top-left origin, 72 DPI). `text` excludes inter-word spaces.
|
|
117
399
|
*/
|
|
118
|
-
|
|
400
|
+
interface WordBox {
|
|
119
401
|
text: string;
|
|
120
402
|
x: number;
|
|
121
403
|
y: number;
|
|
122
404
|
width: number;
|
|
123
405
|
height: number;
|
|
124
406
|
}
|
|
125
|
-
|
|
407
|
+
interface TextItem {
|
|
126
408
|
text: string;
|
|
127
409
|
x: number;
|
|
128
410
|
y: number;
|
|
@@ -168,7 +450,7 @@ export interface TextItem {
|
|
|
168
450
|
* when the color is unknown, so ruled-table edge detection still treats a
|
|
169
451
|
* colorless stroked rect as stroked.
|
|
170
452
|
*/
|
|
171
|
-
|
|
453
|
+
interface Graphic {
|
|
172
454
|
kind: "stroke" | "rect";
|
|
173
455
|
x1?: number;
|
|
174
456
|
y1?: number;
|
|
@@ -189,20 +471,20 @@ export interface Graphic {
|
|
|
189
471
|
* Coordinates are viewport space (top-left origin, 72 DPI). `graphics` is
|
|
190
472
|
* optional; when supplied it enables ruled-table and horizontal-rule detection.
|
|
191
473
|
*/
|
|
192
|
-
|
|
474
|
+
interface PageInput {
|
|
193
475
|
pageNumber: number;
|
|
194
476
|
pageWidth: number;
|
|
195
477
|
pageHeight: number;
|
|
196
478
|
textItems: TextItem[];
|
|
197
479
|
graphics?: Graphic[];
|
|
198
480
|
}
|
|
199
|
-
|
|
481
|
+
interface Rect {
|
|
200
482
|
x: number;
|
|
201
483
|
y: number;
|
|
202
484
|
width: number;
|
|
203
485
|
height: number;
|
|
204
486
|
}
|
|
205
|
-
|
|
487
|
+
interface ParsedPage {
|
|
206
488
|
pageNum: number;
|
|
207
489
|
width: number;
|
|
208
490
|
height: number;
|
|
@@ -237,7 +519,7 @@ export interface ParsedPage {
|
|
|
237
519
|
blocks?: LayoutBlock[];
|
|
238
520
|
}
|
|
239
521
|
/** One table cell: its text and the region of the page it was read from. */
|
|
240
|
-
|
|
522
|
+
interface LayoutCell {
|
|
241
523
|
text: string;
|
|
242
524
|
/**
|
|
243
525
|
* Absent for cells with no ink behind them — padding inserted to square off
|
|
@@ -246,7 +528,7 @@ export interface LayoutCell {
|
|
|
246
528
|
bbox?: Rect;
|
|
247
529
|
}
|
|
248
530
|
/** A classified block of page content, discriminated by `kind`. */
|
|
249
|
-
|
|
531
|
+
interface LayoutBlock {
|
|
250
532
|
kind: "heading" | "paragraph" | "list_item" | "code" | "table" | "grid_fallback" | "rule" | "figure";
|
|
251
533
|
/** Rendered text for `heading`, `paragraph`, and `list_item`. */
|
|
252
534
|
text?: string;
|
|
@@ -273,11 +555,11 @@ export interface LayoutBlock {
|
|
|
273
555
|
*/
|
|
274
556
|
bbox?: Rect;
|
|
275
557
|
}
|
|
276
|
-
|
|
277
|
-
|
|
558
|
+
type StructureAttributeValue = boolean | number | string;
|
|
559
|
+
interface StructureTree {
|
|
278
560
|
roots: StructureTreeElement[];
|
|
279
561
|
}
|
|
280
|
-
|
|
562
|
+
interface StructureTreeElement {
|
|
281
563
|
type: string;
|
|
282
564
|
id?: string;
|
|
283
565
|
actualText?: string;
|
|
@@ -288,11 +570,11 @@ export interface StructureTreeElement {
|
|
|
288
570
|
children: StructureTreeElement[];
|
|
289
571
|
annotations: DocumentAnnotation[];
|
|
290
572
|
}
|
|
291
|
-
|
|
573
|
+
interface VectorGraphics {
|
|
292
574
|
shapes: VectorShape[];
|
|
293
575
|
lines: VectorLine[];
|
|
294
576
|
}
|
|
295
|
-
|
|
577
|
+
interface VectorShape {
|
|
296
578
|
bbox: {
|
|
297
579
|
x: number;
|
|
298
580
|
y: number;
|
|
@@ -305,7 +587,7 @@ export interface VectorShape {
|
|
|
305
587
|
fillColor?: string;
|
|
306
588
|
hasCurve: boolean;
|
|
307
589
|
}
|
|
308
|
-
|
|
590
|
+
interface VectorLine {
|
|
309
591
|
x1: number;
|
|
310
592
|
y1: number;
|
|
311
593
|
x2: number;
|
|
@@ -316,13 +598,13 @@ export interface VectorLine {
|
|
|
316
598
|
fill: boolean;
|
|
317
599
|
fillColor?: string;
|
|
318
600
|
}
|
|
319
|
-
|
|
601
|
+
interface AnnotationRect {
|
|
320
602
|
x: number;
|
|
321
603
|
y: number;
|
|
322
604
|
width: number;
|
|
323
605
|
height: number;
|
|
324
606
|
}
|
|
325
|
-
|
|
607
|
+
interface DocumentAnnotation {
|
|
326
608
|
subtype: string;
|
|
327
609
|
contents?: string;
|
|
328
610
|
created?: string;
|
|
@@ -332,7 +614,7 @@ export interface DocumentAnnotation {
|
|
|
332
614
|
quadpointRects: AnnotationRect[];
|
|
333
615
|
uri?: string;
|
|
334
616
|
}
|
|
335
|
-
|
|
617
|
+
interface FormField {
|
|
336
618
|
id: string;
|
|
337
619
|
type: string;
|
|
338
620
|
page: number;
|
|
@@ -351,7 +633,7 @@ export interface FormField {
|
|
|
351
633
|
options: string[];
|
|
352
634
|
selectedOptions: string[];
|
|
353
635
|
}
|
|
354
|
-
|
|
636
|
+
interface ExtractedImage {
|
|
355
637
|
/** Reference id used in the markdown output (e.g. `` → `"p1_1"`). */
|
|
356
638
|
id: string;
|
|
357
639
|
/** File name used when `imageOutputDir` is configured. */
|
|
@@ -376,7 +658,7 @@ export interface ExtractedImage {
|
|
|
376
658
|
duplicateOf?: string;
|
|
377
659
|
bytes: Buffer;
|
|
378
660
|
}
|
|
379
|
-
|
|
661
|
+
interface ParseResult {
|
|
380
662
|
/** Total source-document pages before `targetPages` or `maxPages` filtering. */
|
|
381
663
|
totalPages: number;
|
|
382
664
|
pages: ParsedPage[];
|
|
@@ -407,11 +689,11 @@ export interface ParseResult {
|
|
|
407
689
|
/** Raw XFA packets; present only when `extractXfaPackets` is enabled. */
|
|
408
690
|
xfaPackets?: XfaPacket[];
|
|
409
691
|
}
|
|
410
|
-
|
|
692
|
+
interface ParseBatchOptions {
|
|
411
693
|
/** Pages materialized in one batch. Default: 25. */
|
|
412
694
|
batchSize?: number;
|
|
413
695
|
}
|
|
414
|
-
|
|
696
|
+
interface ParseBatch {
|
|
415
697
|
/** First source page in this batch (1-indexed). */
|
|
416
698
|
startPage: number;
|
|
417
699
|
/** Last source page in this batch (1-indexed, inclusive). */
|
|
@@ -421,7 +703,7 @@ export interface ParseBatch {
|
|
|
421
703
|
result: ParseResult;
|
|
422
704
|
}
|
|
423
705
|
/** Provenance and tamper-analysis facts extracted from the source PDF. */
|
|
424
|
-
|
|
706
|
+
interface DocumentMetadata {
|
|
425
707
|
creationDate?: string;
|
|
426
708
|
modDate?: string;
|
|
427
709
|
/** Encoded PDF version (`14` means PDF 1.4). */
|
|
@@ -446,14 +728,14 @@ export interface DocumentMetadata {
|
|
|
446
728
|
signatureByteRangeReachesEof?: boolean;
|
|
447
729
|
}
|
|
448
730
|
/** One raw packet from an XFA form document's `/XFA` array. */
|
|
449
|
-
|
|
731
|
+
interface XfaPacket {
|
|
450
732
|
index: number;
|
|
451
733
|
name?: string;
|
|
452
734
|
contentLength: number;
|
|
453
735
|
/** Packet content (usually XML), lossily decoded as UTF-8. */
|
|
454
736
|
content?: string;
|
|
455
737
|
}
|
|
456
|
-
|
|
738
|
+
interface ScreenshotResult {
|
|
457
739
|
pageNum: number;
|
|
458
740
|
width: number;
|
|
459
741
|
height: number;
|
|
@@ -464,7 +746,7 @@ export interface ScreenshotResult {
|
|
|
464
746
|
rects: ScreenshotRect[];
|
|
465
747
|
}
|
|
466
748
|
/** One solid rectangle (or line) detected in a rendered page bitmap. */
|
|
467
|
-
|
|
749
|
+
interface ScreenshotRect {
|
|
468
750
|
x: number;
|
|
469
751
|
y: number;
|
|
470
752
|
width: number;
|
|
@@ -478,7 +760,7 @@ export interface ScreenshotRect {
|
|
|
478
760
|
* Per-page complexity signals from {@link LiteParse.isComplex}, used to decide
|
|
479
761
|
* whether a document needs OCR or other advanced parsing.
|
|
480
762
|
*/
|
|
481
|
-
|
|
763
|
+
interface PageComplexityStats {
|
|
482
764
|
pageNumber: number;
|
|
483
765
|
textLength: number;
|
|
484
766
|
/** Fraction of the page area covered by native text (0–1). */
|
|
@@ -533,7 +815,7 @@ export interface PageComplexityStats {
|
|
|
533
815
|
* Layout-difficulty signals for one page, computed from the real
|
|
534
816
|
* grid-projection pass.
|
|
535
817
|
*/
|
|
536
|
-
|
|
818
|
+
interface LayoutComplexityStats {
|
|
537
819
|
/** Side-by-side text columns found by the layout pass (1 = single column). */
|
|
538
820
|
columnCount: number;
|
|
539
821
|
/** Ruled-table grids detected on the page. */
|
|
@@ -559,11 +841,28 @@ export interface LayoutComplexityStats {
|
|
|
559
841
|
*/
|
|
560
842
|
reasons: string[];
|
|
561
843
|
}
|
|
562
|
-
|
|
844
|
+
declare class LiteParse {
|
|
563
845
|
private _native;
|
|
564
846
|
private _config;
|
|
565
|
-
|
|
847
|
+
private _pool;
|
|
848
|
+
constructor(userConfig?: Partial<LiteParseConfig> & PoolOptions);
|
|
566
849
|
parse(input: LiteParseInput): Promise<ParseResult>;
|
|
850
|
+
/**
|
|
851
|
+
* Resolves once every pool worker is initialized. No-op without `poolSize`.
|
|
852
|
+
*
|
|
853
|
+
* Optional: the first parse on each worker waits for its init anyway. Call
|
|
854
|
+
* this before latency-sensitive traffic to avoid paying worker startup on
|
|
855
|
+
* the first request.
|
|
856
|
+
*/
|
|
857
|
+
warmUp(): Promise<void>;
|
|
858
|
+
/**
|
|
859
|
+
* Shut down pool workers, if pool mode is enabled. Idempotent.
|
|
860
|
+
*
|
|
861
|
+
* Without `poolSize` this is a no-op. An idle pool never keeps the event
|
|
862
|
+
* loop alive and workers exit when the parent does, so forgetting to call
|
|
863
|
+
* this leaks nothing past process exit.
|
|
864
|
+
*/
|
|
865
|
+
close(): void;
|
|
567
866
|
/**
|
|
568
867
|
* Parse a document in bounded-memory page batches of `batchSize` pages.
|
|
569
868
|
*
|
|
@@ -601,10 +900,12 @@ export declare class LiteParse {
|
|
|
601
900
|
screenshot(input: LiteParseInput, pageNumbers?: number[]): Promise<ScreenshotResult[]>;
|
|
602
901
|
getConfig(): LiteParseConfig;
|
|
603
902
|
}
|
|
604
|
-
|
|
903
|
+
/** @internal Exported for pool-worker.ts only; not public API. */
|
|
904
|
+
declare function toParseResult(result: NativeParseResult): ParseResult;
|
|
905
|
+
interface SearchItemsOptions {
|
|
605
906
|
phrase: string;
|
|
606
907
|
caseSensitive?: boolean;
|
|
607
908
|
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
909
|
+
declare function searchItems(items: TextItem[], options: SearchItemsOptions): TextItem[];
|
|
910
|
+
|
|
911
|
+
export { type AnnotationRect, type CropBox, type DocumentAnnotation, type DocumentMetadata, type ExtractedImage, type FormField, type Graphic, type ImageMode, type LayoutBlock, type LayoutCell, type LayoutComplexityStats, LiteParse, type LiteParseConfig, type LiteParseInput, type OutputFormat, type PageComplexityStats, type PageInput, type ParseBatch, type ParseBatchOptions, type ParseResult, ParseTimeoutError, type ParsedPage, type PoolOptions, type Rect, type ScreenshotRect, type ScreenshotResult, type SearchItemsOptions, type StructureAttributeValue, type StructureTree, type StructureTreeElement, type TextItem, type VectorGraphics, type VectorLine, type VectorShape, type WordBox, type XfaPacket, LiteParse as default, searchItems, toParseResult };
|