@d0paminedriven/fs 10.1.0 → 12.0.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/dist/docs/index.d.ts +151 -0
- package/dist/docs/index.js +1163 -0
- package/dist/extract/client.d.ts +56 -0
- package/dist/extract/client.js +116 -0
- package/dist/extract/index.d.ts +66 -0
- package/dist/extract/index.js +620 -0
- package/dist/fs/index.d.ts +18 -58
- package/dist/fs/index.js +89 -19
- package/dist/fs-atomic/index.d.ts +25 -39
- package/dist/fs-atomic/index.js +94 -13
- package/dist/fs-base/index.d.ts +105 -113
- package/dist/fs-base/index.js +197 -12
- package/dist/fs-core/index.d.ts +18 -26
- package/dist/fs-core/index.js +43 -16
- package/dist/fs-fetch/index.d.ts +48 -65
- package/dist/fs-fetch/index.js +183 -18
- package/dist/fs-size/index.d.ts +15 -31
- package/dist/fs-size/index.js +63 -15
- package/dist/fs-tmp/index.d.ts +178 -195
- package/dist/fs-tmp/index.js +320 -17
- package/dist/images/index.d.ts +443 -0
- package/dist/images/index.js +893 -0
- package/dist/images/workup.d.ts +26 -0
- package/dist/images/workup.js +316 -0
- package/dist/index.d.ts +48 -22
- package/dist/index.js +19 -64
- package/dist/ld/index.d.ts +14 -16
- package/dist/ld/index.js +54 -6
- package/dist/mime/index.d.ts +301 -296
- package/dist/mime/index.js +348 -13
- package/dist/mixins/index.d.ts +30 -0
- package/dist/mixins/index.js +54 -0
- package/dist/types/index.d.ts +339 -260
- package/dist/types/index.js +10 -6
- package/dist/types/stream.d.ts +7 -9
- package/dist/types/stream.js +1 -1
- package/dist/url/index.d.ts +18 -25
- package/dist/url/index.js +19 -8
- package/dist/utils/index.d.ts +18 -26
- package/dist/utils/index.js +80 -7
- package/package.json +42 -22
- package/dist/chunk-4D2YBCI6.js +0 -163
- package/dist/chunk-5CACVZVF.js +0 -386
- package/dist/chunk-5H6GE5AO.js +0 -14
- package/dist/chunk-7QVYU63E.js +0 -7
- package/dist/chunk-DNR5ZI2T.js +0 -75
- package/dist/chunk-JZ6JNZZ6.js +0 -77
- package/dist/chunk-L2QMQOEJ.js +0 -366
- package/dist/chunk-NJHN5OE3.js +0 -33
- package/dist/chunk-OHKRQJZH.js +0 -82
- package/dist/chunk-OT5JEQKW.js +0 -139
- package/dist/chunk-PATMSIQK.js +0 -367
- package/dist/chunk-PB5A7ZFD.js +0 -79
- package/dist/chunk-VDKUXJE7.js +0 -240
- package/dist/chunk-Y5QWE4EG.js +0 -1335
- package/dist/chunk-YRCJWFZD.js +0 -107
- package/dist/image/index.d.ts +0 -182
- package/dist/image/index.js +0 -13
- package/dist/image/workup.d.ts +0 -40
- package/dist/image/workup.js +0 -12
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { Readable } from "node:stream";
|
|
2
|
+
import { DocSpecs, PdfImageAnalysisMetadata, ZipEntry } from "../types/index.js";
|
|
3
|
+
export declare class DocMetadataExtractor {
|
|
4
|
+
protected toSafeString(buf: Uint8Array, encoding?: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Detect XObject image references in the PDF
|
|
7
|
+
* Images are declared as XObjects with /Subtype /Image
|
|
8
|
+
*/
|
|
9
|
+
private detectXObjectImages;
|
|
10
|
+
/**
|
|
11
|
+
* Detect inline images (BI ... ID ... EI blocks)
|
|
12
|
+
* These are embedded directly in content streams, common in older PDFs
|
|
13
|
+
*/
|
|
14
|
+
private detectInlineImages;
|
|
15
|
+
/**
|
|
16
|
+
* Check for vector graphics (Form XObjects, paths, etc.)
|
|
17
|
+
* These don't need multimodal but indicate visual complexity
|
|
18
|
+
*/
|
|
19
|
+
private detectVectorGraphics;
|
|
20
|
+
private hasFaxEncoding;
|
|
21
|
+
/**
|
|
22
|
+
* Estimate if PDF is scanned (image-only with no real text layer)
|
|
23
|
+
*/
|
|
24
|
+
private detectScannedPdf;
|
|
25
|
+
/**
|
|
26
|
+
* Analyze images in compressed streams (for Acrobat-optimized PDFs)
|
|
27
|
+
* Reuses your existing decompression infrastructure
|
|
28
|
+
*/
|
|
29
|
+
private detectImagesInCompressedStreams;
|
|
30
|
+
analyzePdfImages(buffer: Buffer, pageCount: number | null): {
|
|
31
|
+
hasImages: boolean;
|
|
32
|
+
imageCount: number;
|
|
33
|
+
estimatedImageCoverage: "none" | "moderate" | "minimal" | "heavy";
|
|
34
|
+
imageTypes: Set<"jpeg" | "jpeg2000" | "png-like" | "ccitt-fax" | "jbig2" | "inline">;
|
|
35
|
+
isLikelyScanned: boolean;
|
|
36
|
+
hasVectorGraphics: boolean;
|
|
37
|
+
recommendation: "multimodal" | "text-only";
|
|
38
|
+
};
|
|
39
|
+
protected detectTextEncodingPrefix(buffer: Uint8Array): {
|
|
40
|
+
encoding: string;
|
|
41
|
+
offset: number;
|
|
42
|
+
};
|
|
43
|
+
protected detectAndDecodeText(buffer: Uint8Array): string;
|
|
44
|
+
private _stripXmlTags;
|
|
45
|
+
private getExtFromFilename;
|
|
46
|
+
private firstN;
|
|
47
|
+
private countWords;
|
|
48
|
+
private countLines;
|
|
49
|
+
private extToLanguage;
|
|
50
|
+
/**
|
|
51
|
+
* Decompress FlateDecode streams to search for page info
|
|
52
|
+
* Many modern PDFs compress their object streams
|
|
53
|
+
*/
|
|
54
|
+
private decompressFlateStreams;
|
|
55
|
+
/**
|
|
56
|
+
* Parse Object Streams (/Type /ObjStm) used by Acrobat-optimized PDFs
|
|
57
|
+
* These bundle multiple objects into compressed containers
|
|
58
|
+
*/
|
|
59
|
+
private parseObjectStreams;
|
|
60
|
+
/**
|
|
61
|
+
* Parse cross-reference table to find object offsets
|
|
62
|
+
*/
|
|
63
|
+
private parseXrefTable;
|
|
64
|
+
/**
|
|
65
|
+
* Parse PDF 1.5+ cross-reference streams (/Type /XRef)
|
|
66
|
+
* These replace traditional xref tables in modern PDFs
|
|
67
|
+
*/
|
|
68
|
+
private parseXrefStream;
|
|
69
|
+
/**
|
|
70
|
+
* Extract page count from object at specific offset
|
|
71
|
+
*/
|
|
72
|
+
private extractPageCountFromObject;
|
|
73
|
+
/**
|
|
74
|
+
* Strategy 1: Direct /Pages /Count in uncompressed content (fastest, high confidence)
|
|
75
|
+
* Finds the ROOT Pages object by looking for the highest /Count value
|
|
76
|
+
*/
|
|
77
|
+
private strategy1DirectPagesCount;
|
|
78
|
+
/**
|
|
79
|
+
* Strategy 2: Linearized hint (high confidence for linearized PDFs)
|
|
80
|
+
* /N in the linearization dict is the total page count
|
|
81
|
+
*/
|
|
82
|
+
private strategy2Linearized;
|
|
83
|
+
/**
|
|
84
|
+
* Strategy 3: Follow Catalog -> Pages reference chain (high confidence)
|
|
85
|
+
*/
|
|
86
|
+
private strategy3CatalogChain;
|
|
87
|
+
/**
|
|
88
|
+
* Strategy 4: Decompress FlateDecode streams and Object Streams (medium confidence)
|
|
89
|
+
* Handles Acrobat-optimized PDFs where page tree is compressed
|
|
90
|
+
*/
|
|
91
|
+
private strategy4DecompressedStreams;
|
|
92
|
+
/**
|
|
93
|
+
* Strategy 5: Count unique Page objects from Kids arrays (medium confidence)
|
|
94
|
+
* Only counts refs that point to actual /Type /Page objects
|
|
95
|
+
*/
|
|
96
|
+
private strategy5KidsPageRefs;
|
|
97
|
+
/**
|
|
98
|
+
* Strategy 6: Brute force count /Type /Page objects (low confidence)
|
|
99
|
+
*/
|
|
100
|
+
private strategy6BruteForce;
|
|
101
|
+
/**
|
|
102
|
+
* Strategy 7: Estimate from file characteristics (last resort)
|
|
103
|
+
*/
|
|
104
|
+
private strategy7Estimate;
|
|
105
|
+
/**
|
|
106
|
+
* Count PDF pages with confidence tracking
|
|
107
|
+
* Returns both the count and how confident we are in the result
|
|
108
|
+
*/
|
|
109
|
+
private countPDFPagesWithConfidence;
|
|
110
|
+
/**
|
|
111
|
+
* Legacy method for backward compatibility
|
|
112
|
+
*/
|
|
113
|
+
private countPDFPages;
|
|
114
|
+
private extractPDFText;
|
|
115
|
+
private decodePdfString;
|
|
116
|
+
private decodeHexString;
|
|
117
|
+
/**
|
|
118
|
+
* Parse PDF date format into ISO 8601
|
|
119
|
+
* PDF Format: D:YYYYMMDDHHmmSSOHH'mm'
|
|
120
|
+
* Your implementation is good but needs small fixes
|
|
121
|
+
*/
|
|
122
|
+
private parsePdfDate;
|
|
123
|
+
private getPdfInfoString;
|
|
124
|
+
/**
|
|
125
|
+
* Extract date fields from PDF - handles all encoding formats
|
|
126
|
+
* This is what you need to call from your main PDF parser
|
|
127
|
+
*/
|
|
128
|
+
private extractPdfDate;
|
|
129
|
+
/**
|
|
130
|
+
* Extract dates from XMP metadata packet
|
|
131
|
+
* Used as fallback when traditional PDF Info dictionary lacks dates
|
|
132
|
+
*/
|
|
133
|
+
private extractXmpDates;
|
|
134
|
+
private cleanPdfImgAnalysis;
|
|
135
|
+
parsePdf(buffer: Buffer, mime: "application/pdf"): DocSpecs<PdfImageAnalysisMetadata>;
|
|
136
|
+
parseRtf(buffer: Buffer, mime: string): DocSpecs;
|
|
137
|
+
parsePlainText(buffer: Buffer, mime: string, filename?: string): DocSpecs;
|
|
138
|
+
/** ---- Minimal ZIP reader utilities (central directory based) ---- */
|
|
139
|
+
private findEOCD;
|
|
140
|
+
readCentralDirectory(buffer: Buffer): ZipEntry[];
|
|
141
|
+
private parseCentralDirectory;
|
|
142
|
+
private recoverCentralDirectory;
|
|
143
|
+
readLocalFileData(buffer: Buffer, entry: ZipEntry): Uint8Array | null;
|
|
144
|
+
parseOpenXml(buffer: Buffer, mime: string, kind: "docx" | "pptx" | "xlsx"): DocSpecs;
|
|
145
|
+
protected readBytes(stream: Readable): Promise<Buffer<ArrayBufferLike>>;
|
|
146
|
+
extractDocViaStream(stream: Readable, mime: string): Promise<DocSpecs<unknown>>;
|
|
147
|
+
extractDocViaPath(filePath: string, mime: string): Promise<DocSpecs<unknown>>;
|
|
148
|
+
getDocumentSpecsWorkup(buffer: Buffer<ArrayBufferLike>, mime: "application/pdf", fileName?: string): DocSpecs<PdfImageAnalysisMetadata>;
|
|
149
|
+
getDocumentSpecsWorkup(buffer: Buffer<ArrayBufferLike>, mime: string, fileName?: string): DocSpecs<unknown>;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=index.d.ts.map
|