officeparser 7.2.0 → 7.2.2
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 +66 -44
- package/dist/OfficeGenerator.d.ts +5 -1
- package/dist/OfficeGenerator.js +14 -2
- package/dist/OfficeParser.d.ts +1 -1
- package/dist/OfficeParser.js +1 -1
- package/dist/cli.d.ts +18 -16
- package/dist/cli.js +255 -90
- package/dist/defaults.js +5 -1
- package/dist/generators/BaseGenerator.d.ts +1 -0
- package/dist/generators/BaseGenerator.js +13 -1
- package/dist/generators/ChunkingGenerator.js +25 -5
- package/dist/generators/HtmlGenerator.js +20 -3
- package/dist/generators/MarkdownGenerator.js +32 -1
- package/dist/generators/RtfGenerator.js +6 -0
- package/dist/generators/TextGenerator.js +6 -0
- package/dist/officeparser.browser.d.ts +39 -3
- package/dist/officeparser.browser.iife.js +294 -169
- package/dist/officeparser.browser.mjs +294 -169
- package/dist/parsers/ExcelParser.js +1 -1
- package/dist/parsers/OpenOfficeParser.js +1 -1
- package/dist/parsers/PdfParser.js +5 -2
- package/dist/parsers/PowerPointParser.js +1 -1
- package/dist/parsers/WordParser.js +1 -1
- package/dist/sbom.cdx.json +99 -99
- package/dist/types.d.ts +34 -2
- package/dist/types.js +10 -0
- package/dist/utils/configUtils.js +14 -2
- package/dist/utils/errorUtils.js +6 -1
- package/dist/utils/moduleLoader.js +55 -11
- package/dist/utils/zipUtils.d.ts +2 -1
- package/dist/utils/zipUtils.js +34 -2
- package/package.json +6 -3
|
@@ -221,6 +221,12 @@ class RtfGenerator extends BaseGenerator_js_1.BaseGenerator {
|
|
|
221
221
|
for (const node of ast.content) {
|
|
222
222
|
body += await this.processNodeRecursive(node, processor);
|
|
223
223
|
}
|
|
224
|
+
if (this.collectedNotes.length > 0) {
|
|
225
|
+
body += '\\pard\\sb120\\sa120\\keepn{\\b Notes:}\\par\n';
|
|
226
|
+
for (const note of this.collectedNotes) {
|
|
227
|
+
body += await this.processNodeRecursive(note, processor);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
224
230
|
return body;
|
|
225
231
|
}
|
|
226
232
|
getColorIndex(hex) {
|
|
@@ -62,6 +62,12 @@ class TextGenerator extends BaseGenerator_js_1.BaseGenerator {
|
|
|
62
62
|
for (const node of this.ast.content) {
|
|
63
63
|
output += await this.processNodeRecursive(node, processor);
|
|
64
64
|
}
|
|
65
|
+
if (this.collectedNotes.length > 0) {
|
|
66
|
+
output += `${newline}${newline}--- Notes ---${newline}`;
|
|
67
|
+
for (const note of this.collectedNotes) {
|
|
68
|
+
output += await this.processNodeRecursive(note, processor);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
65
71
|
return {
|
|
66
72
|
value: output.trim(),
|
|
67
73
|
messages: this.messages
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
export declare enum OfficeErrorType {
|
|
8
8
|
/** Unsupported file extension */
|
|
9
9
|
EXTENSION_UNSUPPORTED = "EXTENSION_UNSUPPORTED",
|
|
10
|
+
/** Unsupported output generator format */
|
|
11
|
+
FORMAT_UNSUPPORTED = "FORMAT_UNSUPPORTED",
|
|
10
12
|
/** File appears to be corrupted or malformed */
|
|
11
13
|
FILE_CORRUPTED = "FILE_CORRUPTED",
|
|
12
14
|
/** File could not be found at the specified path */
|
|
@@ -32,7 +34,15 @@ export declare enum OfficeErrorType {
|
|
|
32
34
|
/** Semantic chunking strategy is selected but no embedding function is provided */
|
|
33
35
|
MISSING_EMBEDDING_FUNCTION = "MISSING_EMBEDDING_FUNCTION",
|
|
34
36
|
/** The operation was aborted */
|
|
35
|
-
OPERATION_ABORTED = "OPERATION_ABORTED"
|
|
37
|
+
OPERATION_ABORTED = "OPERATION_ABORTED",
|
|
38
|
+
/** ZIP entry count exceeds limit */
|
|
39
|
+
ZIP_ENTRY_COUNT_LIMIT_EXCEEDED = "ZIP_ENTRY_COUNT_LIMIT_EXCEEDED",
|
|
40
|
+
/** ZIP entry missing a valid declared size */
|
|
41
|
+
ZIP_ENTRY_INVALID_SIZE = "ZIP_ENTRY_INVALID_SIZE",
|
|
42
|
+
/** ZIP uncompressed size limit exceeded */
|
|
43
|
+
ZIP_SIZE_LIMIT_EXCEEDED = "ZIP_SIZE_LIMIT_EXCEEDED",
|
|
44
|
+
/** Embedding call timed out */
|
|
45
|
+
EMBEDDING_TIMEOUT = "EMBEDDING_TIMEOUT"
|
|
36
46
|
}
|
|
37
47
|
/**
|
|
38
48
|
* Standard warning types for OfficeParser.
|
|
@@ -347,6 +357,28 @@ export interface OfficeParserConfig {
|
|
|
347
357
|
* Defaults to ',' but can be overridden (e.g., ';', '\t').
|
|
348
358
|
*/
|
|
349
359
|
csvDelimiter?: string;
|
|
360
|
+
/**
|
|
361
|
+
* Limits and checks applied during ZIP extraction to protect against excessive
|
|
362
|
+
* memory and resource usage.
|
|
363
|
+
*/
|
|
364
|
+
decompressionLimits?: DecompressionLimits;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Limits applied to ZIP archive decompression.
|
|
368
|
+
*/
|
|
369
|
+
export interface DecompressionLimits {
|
|
370
|
+
/**
|
|
371
|
+
* Maximum allowed total uncompressed size (in bytes) of files extracted from a ZIP archive.
|
|
372
|
+
* Applies to OOXML (DOCX, XLSX, PPTX) and ODF (ODT, ODP, ODS) formats.
|
|
373
|
+
* Default is 536870912 (512 MB).
|
|
374
|
+
*/
|
|
375
|
+
maxUncompressedBytes?: number;
|
|
376
|
+
/**
|
|
377
|
+
* Maximum allowed number of entries (files and directories) in a ZIP archive.
|
|
378
|
+
* Applies to OOXML (DOCX, XLSX, PPTX) and ODF (ODT, ODP, ODS) formats.
|
|
379
|
+
* Default is 10000.
|
|
380
|
+
*/
|
|
381
|
+
maxZipEntries?: number;
|
|
350
382
|
}
|
|
351
383
|
/**
|
|
352
384
|
* Represents a single issue (warning, error, or info) generated during document processing.
|
|
@@ -397,7 +429,7 @@ export interface CommonGeneratorConfig {
|
|
|
397
429
|
* 1. **Filter/Remove Nodes**: Return `false` to skip a node and all its children.
|
|
398
430
|
* 2. **Override Rendering**: Return a `string` to use that exact text as the output, bypassing default logic and recursion.
|
|
399
431
|
* 3. **Mutate Nodes**: Modify the `node` object directly (e.g., changing `node.text`) and return `void` to let the generator proceed with your changes.
|
|
400
|
-
* 4. **Async Support**: The callback can be `async`, allowing you to
|
|
432
|
+
* 4. **Async Support**: The callback can be `async`, allowing you to load external data or perform complex logic during generation.
|
|
401
433
|
*/
|
|
402
434
|
onNode?: (node: OfficeContentNode) => string | false | Promise<string | false | void> | void;
|
|
403
435
|
/**
|
|
@@ -1860,7 +1892,7 @@ export declare class OfficeParser {
|
|
|
1860
1892
|
* });
|
|
1861
1893
|
*
|
|
1862
1894
|
* // Parse a Buffer with OCR enabled
|
|
1863
|
-
* const buffer = await
|
|
1895
|
+
* const buffer = await retrieveData('document.pdf').then(r => r.arrayBuffer());
|
|
1864
1896
|
* const ast = await OfficeParser.parseOffice(buffer, {
|
|
1865
1897
|
* ocr: true,
|
|
1866
1898
|
* ocrLanguage: 'eng+fra'
|
|
@@ -1885,6 +1917,10 @@ export declare class OfficeParser {
|
|
|
1885
1917
|
* Main generator class providing document conversion functionality.
|
|
1886
1918
|
*/
|
|
1887
1919
|
export declare class OfficeGenerator {
|
|
1920
|
+
/**
|
|
1921
|
+
* Normalizes format aliases (e.g., 'txt' to 'text', 'markdown' to 'md') to standard internal formats.
|
|
1922
|
+
*/
|
|
1923
|
+
static normalizeDestination(dest: string): UniversalGeneratorFormat;
|
|
1888
1924
|
/**
|
|
1889
1925
|
* Generates a file of the specified type from an AST.
|
|
1890
1926
|
* This is the single source of truth for generation logic.
|