Files
wehub-resource-sync 9f97f3abbe
CI - Python Bindings / sdist (push) Failing after 1s
CI - Python Bindings / Build x86_64-unknown-linux-musl (push) Failing after 1s
CI / fmt (push) Failing after 1s
E2E Output Validation / compare-outputs (push) Failing after 1s
Sync Docs to Developer Hub / sync-docs (push) Failing after 1s
CI - Python Bindings / Build x86_64-unknown-linux-gnu (push) Failing after 1s
CI - WASM Bindings / Build WASM (push) Failing after 0s
CI / clippy (push) Failing after 1s
CI / build-and-test (ubuntu-latest) (push) Failing after 0s
CI - WASM Bindings / Edge runtime PDF parse test (push) Has been skipped
CI - WASM Bindings / Browser PDF parse test (push) Has been skipped
Deploy Demo to GitHub Pages / deploy (push) Failing after 1s
CI / build-docker-image (push) Failing after 3s
CI - Node Bindings / Build darwin-x64 (push) Has been cancelled
CI - Node Bindings / Test win32-x64-msvc (push) Has been cancelled
CI - Node Bindings / Build linux-arm64-gnu (push) Has been cancelled
CI - Node Bindings / Build linux-x64-gnu (push) Has been cancelled
CI - Node Bindings / Build linux-x64-musl (push) Has been cancelled
CI - Node Bindings / Build win32-arm64-msvc (push) Has been cancelled
CI - Node Bindings / Build win32-x64-msvc (push) Has been cancelled
CI - Node Bindings / Test darwin-arm64 (push) Has been cancelled
CI - Node Bindings / Test darwin-x64 (push) Has been cancelled
CI - Node Bindings / Test linux-x64-gnu (push) Has been cancelled
CI - Node Bindings / Test linux-x64-musl (push) Has been cancelled
CI - Node Bindings / Test win32-arm64-msvc (push) Has been cancelled
CI - Python Bindings / Build aarch64-pc-windows-msvc (push) Has been cancelled
CI - Python Bindings / Build x86_64-pc-windows-msvc (push) Has been cancelled
CI - Python Bindings / Build x86_64-apple-darwin (push) Has been cancelled
CI - Python Bindings / Build aarch64-apple-darwin (push) Has been cancelled
CI - Python Bindings / Build aarch64-unknown-linux-gnu (push) Has been cancelled
CI - Node Bindings / Build darwin-arm64 (push) Has been cancelled
CI - Python Bindings / Test x86_64-apple-darwin (push) Has been cancelled
CI - Python Bindings / Test aarch64-apple-darwin (push) Has been cancelled
CI - Python Bindings / Test x86_64-unknown-linux-gnu (push) Has been cancelled
CI - Python Bindings / Test x86_64-unknown-linux-musl (push) Has been cancelled
CI - Python Bindings / Test aarch64-pc-windows-msvc (push) Has been cancelled
CI - Python Bindings / Test x86_64-pc-windows-msvc (push) Has been cancelled
CI / build-and-test (macos-26-intel) (push) Has been cancelled
CI / build-and-test (macos-latest) (push) Has been cancelled
CI / build-and-test (windows-11-arm) (push) Has been cancelled
CI / build-and-test (windows-latest) (push) Has been cancelled
E2E Output Validation / upload-dataset (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:23:44 +08:00

233 lines
7.7 KiB
TypeScript

/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export interface JsLiteParseConfig {
/** OCR language code (e.g., "eng", "fra"). */
ocrLanguage?: string
/** Whether OCR is enabled. */
ocrEnabled?: boolean
/** HTTP OCR server URL. If set, uses HTTP OCR instead of Tesseract. */
ocrServerUrl?: string
/**
* Extra HTTP headers sent with every request to `ocrServerUrl`
* (e.g. `{ Authorization: "Bearer <token>" }`).
*/
ocrServerHeaders?: Record<string, string>
/** Path to tessdata directory for Tesseract. */
tessdataPath?: string
/** Maximum number of pages to parse. */
maxPages?: number
/** Specific pages to parse (e.g., "1-5,10,15-20"). */
targetPages?: string
/** DPI for rendering pages (used for OCR and screenshots). */
dpi?: number
/** Output format: "json", "text", or "markdown". */
outputFormat?: string
/** Keep very small text that would normally be filtered out. */
preserveVerySmallText?: boolean
/** Password for encrypted/protected documents. */
password?: string
/** Suppress progress output. */
quiet?: boolean
/** Number of concurrent OCR workers (default: CPU cores - 1). */
numWorkers?: number
/**
* How to surface raster images in markdown output: "off", "placeholder"
* (default — emits `![](image_pN_K.png)` references with no bytes), or
* "embed" (also returns each image's PNG bytes on `images`).
*/
imageMode?: string
/**
* Render hyperlink annotations as `[text](url)` in markdown output
* (default true). Set false for plain anchor text.
*/
extractLinks?: boolean
/**
* Whether a systemic OCR failure aborts the whole parse (default true).
* Set false to keep already-recovered native text and return partial
* results when OCR is unavailable, instead of rejecting.
*/
ocrFailureFatal?: boolean
/**
* OCR request-hedging schedule (ms). Empty/unset = no hedging. Multiple
* delays (e.g. `[0, 5000, 10000]`) fire duplicate requests per attempt and
* take the first success — lower tail latency at the cost of extra load.
*/
ocrHedgeDelaysMs?: Array<number>
/**
* Emit per-word sub-boxes on each text item (`TextItem.words`). Default
* false. Word boxes roughly double the text-item payload, so enable only
* for word-level bbox attribution.
*/
emitWordBoxes?: boolean
/**
* Restrict output to a page sub-region. Each field is the fraction of the
* page cropped from that side; a text item survives only if it lies
* entirely inside the remaining rectangle. Unset keeps the whole page.
*/
cropBox?: JsCropBox
/**
* Drop diagonal text (rotation >2° off the nearest right angle). Default
* false. Use to exclude rotated watermarks/stamps from the output.
*/
skipDiagonalText?: boolean
}
/**
* A page sub-region as the fraction cropped from each side (top-left origin,
* each in `[0, 1]`).
*/
export interface JsCropBox {
top: number
right: number
bottom: number
left: number
}
/** One word's sub-box within a `JsTextItem`, in the same viewport space. */
export interface JsWordBox {
text: string
x: number
y: number
width: number
height: number
}
export interface JsTextItem {
text: string
x: number
y: number
width: number
height: number
fontName?: string
fontSize?: number
confidence?: number
/** Rotation in degrees (viewport space). Defaults to 0 when omitted. */
rotation?: number
/**
* Per-word sub-boxes for attribution. Empty for items with no word split
* (e.g. OCR-sourced or single-token items).
*/
words: Array<JsWordBox>
}
/**
* A vector-graphic primitive supplied by an external extractor. `kind` selects
* the variant: `"stroke"` (uses `x1/y1/x2/y2`) or `"rect"` (uses
* `x/y/width/height`). Coordinates are viewport space (top-left origin, 72
* DPI), matching the text items. `has_fill`/`has_stroke` carry the paint
* intent even when no color is known, so ruled-table edge detection still
* treats a colorless stroked rect as stroked.
*/
export interface JsGraphic {
/** "stroke" or "rect". Anything else is dropped. */
kind: string
x1?: number
y1?: number
x2?: number
y2?: number
x?: number
y?: number
width?: number
height?: number
/** Whether the path is filled. Drives Rect `fill` presence. */
hasFill?: boolean
/** Whether the path is stroked. Drives Rect `stroke` presence. */
hasStroke?: boolean
/** Fill color as ARGB hex (e.g. "ff000000"). May be absent even when filled. */
fillColor?: string
/** Stroke color as ARGB hex. May be absent even when stroked. */
strokeColor?: string
/** Stroke line width in points. */
lineWidth?: number
}
/**
* A page of pre-extracted text supplied by an external extractor. Coordinates
* are viewport space (top-left origin, 72 DPI). `graphics` enables ruled-table
* and horizontal-rule detection; struct nodes are still unsupported on this
* path, so tagged-heading detection remains unavailable until they are added.
*/
export interface JsPageInput {
pageNumber: number
pageWidth: number
pageHeight: number
textItems: Array<JsTextItem>
graphics?: Array<JsGraphic>
}
export interface JsParsedPage {
pageNum: number
width: number
height: number
text: string
markdown: string
textItems: Array<JsTextItem>
}
export interface JsParseResult {
pages: Array<JsParsedPage>
text: string
images: Array<JsExtractedImage>
}
export interface JsExtractedImage {
id: string
page: number
format: string
bytes: Buffer
}
export interface JsScreenshotResult {
pageNum: number
width: number
height: number
imageBuffer: Buffer
}
export interface JsPageComplexityStats {
pageNumber: number
textLength: number
textCoverage: number
hasSubstantialImages: boolean
imageBlockCount: number
imageCoverage: number
largestImageCoverage: number
fullPageImage: boolean
uncoveredVectorArea?: number
isGarbled: boolean
pageArea: number
needsOcr: boolean
reasons: Array<string>
}
/** Search text items for phrase matches, returning merged items with combined bounding boxes. */
export declare function searchItems(items: Array<JsTextItem>, phrase: string, caseSensitive?: boolean | undefined | null): Array<JsTextItem>
/** Main LiteParse parser class. */
export declare class LiteParse {
/**
* Create a new LiteParse instance with optional configuration.
* Any fields not provided will use defaults.
*/
constructor(config?: JsLiteParseConfig | undefined | null)
/** Parse a document. Accepts a file path (string) or raw PDF bytes (Buffer). */
parse(input: string | Buffer): Promise<JsParseResult>
/**
* Parse from pre-extracted pages, skipping PDFium text extraction.
*
* The caller supplies pages already populated with text items in viewport
* space (top-left origin, 72 DPI). Runs only grid projection + the
* configured output formatter, so it never loads PDFium. Use when an
* external extractor owns text extraction (e.g. to keep its own
* font-recovery pipeline).
*/
parsePages(pages: Array<JsPageInput>): JsParseResult
/**
* Determine per-page complexity. Returns one entry per parsed page with
* signals (text coverage, images, garbled text, vector area) and a
* `needsOcr` verdict — a cheap pre-OCR check to decide whether a document
* needs advanced parsing. Accepts a file path (string) or raw PDF bytes.
*/
isComplex(input: string | Buffer): Promise<Array<JsPageComplexityStats>>
/**
* Take screenshots of document pages. Returns PNG image buffers.
*
* Non-PDF files are automatically converted to PDF before rendering when
* LibreOffice/ImageMagick are available.
*/
screenshot(input: string | Buffer, pageNumbers?: Array<number> | undefined | null): Promise<Array<JsScreenshotResult>>
/** Get the current configuration. */
get config(): JsLiteParseConfig
}