officeparser 7.2.2 → 7.2.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/README.md +13 -8
- package/dist/defaults.js +3 -3
- package/dist/officeparser.browser.d.ts +1 -1
- package/dist/officeparser.browser.iife.js +122 -122
- package/dist/officeparser.browser.mjs +122 -122
- package/dist/officeparser.browser.slim.d.ts +1992 -0
- package/dist/officeparser.browser.slim.iife.js +1182 -0
- package/dist/officeparser.browser.slim.mjs +1181 -0
- package/dist/parsers/OpenOfficeParser.js +241 -54
- package/dist/parsers/WordParser.js +2 -2
- package/dist/types.d.ts +4 -1
- package/package.json +12 -7
- package/dist/sbom.cdx.json +0 -1807
package/README.md
CHANGED
|
@@ -1007,12 +1007,17 @@ await officeParser.terminateOcr(); // immediate exit
|
|
|
1007
1007
|
|
|
1008
1008
|
## Browser Usage
|
|
1009
1009
|
|
|
1010
|
-
|
|
1010
|
+
Four bundles are available in the `dist/` directory:
|
|
1011
1011
|
|
|
1012
|
-
| Bundle |
|
|
1013
|
-
|
|
1014
|
-
| `officeparser.browser.mjs` | ESM
|
|
1015
|
-
| `officeparser.browser.iife.js` | IIFE
|
|
1012
|
+
| Bundle | Type | Description |
|
|
1013
|
+
|--------|------|-------------|
|
|
1014
|
+
| `officeparser.browser.mjs` | ESM | Standard ESM bundle for modern bundlers (Vite, Webpack, Next.js). |
|
|
1015
|
+
| `officeparser.browser.iife.js` | IIFE | Standard UMD bundle for direct `<script>` inclusion (exposes global `officeParser`). |
|
|
1016
|
+
| `officeparser.browser.slim.mjs` | ESM | Slim ESM bundle with Tesseract.js (OCR) stubbed out and remote CDN URLs removed. |
|
|
1017
|
+
| `officeparser.browser.slim.iife.js` | IIFE | Slim UMD bundle with Tesseract.js (OCR) stubbed out and remote CDN URLs removed. |
|
|
1018
|
+
|
|
1019
|
+
### Manifest V3 & Extension Compliance (Slim Bundles)
|
|
1020
|
+
For strict browser environments like **Chrome/Edge Manifest V3 extensions**, remotely hosted code is forbidden. Use the **slim** bundles (`officeparser.browser.slim.mjs` or `officeparser.browser.slim.iife.js`) as they do not include default remote CDN urls or the Tesseract OCR engine.
|
|
1016
1021
|
|
|
1017
1022
|
### ESM (Vite / Webpack / Next.js)
|
|
1018
1023
|
|
|
@@ -1055,12 +1060,12 @@ const ast = await officeParser.parseOffice(pdfArrayBuffer);
|
|
|
1055
1060
|
|
|
1056
1061
|
// Or specify your own:
|
|
1057
1062
|
const ast = await officeParser.parseOffice(pdfArrayBuffer, {
|
|
1058
|
-
pdfWorkerSrc: 'https://cdn.jsdelivr.net/npm/pdfjs-dist@
|
|
1063
|
+
pdfWorkerSrc: 'https://cdn.jsdelivr.net/npm/pdfjs-dist@6.1.200/build/pdf.worker.min.mjs'
|
|
1059
1064
|
});
|
|
1060
1065
|
```
|
|
1061
1066
|
|
|
1062
1067
|
> [!NOTE]
|
|
1063
|
-
> The `pdfjs-dist` worker version must match the version bundled with `officeparser` (currently **
|
|
1068
|
+
> The `pdfjs-dist` worker version must match the version bundled with `officeparser` (currently **6.1.200**).
|
|
1064
1069
|
|
|
1065
1070
|
---
|
|
1066
1071
|
|
|
@@ -1069,7 +1074,7 @@ const ast = await officeParser.parseOffice(pdfArrayBuffer, {
|
|
|
1069
1074
|
| Symptom | Fix |
|
|
1070
1075
|
|---------|-----|
|
|
1071
1076
|
| Node.js process stays alive after finishing | Call `await officeParser.terminateOcr()` at end of script when OCR was used |
|
|
1072
|
-
| `"Worker not found"` in browser for PDF | Verify `pdfWorkerSrc` points to `pdf.worker.min.mjs` matching version `
|
|
1077
|
+
| `"Worker not found"` in browser for PDF | Verify `pdfWorkerSrc` points to `pdf.worker.min.mjs` matching version `6.1.200` |
|
|
1073
1078
|
| Low OCR accuracy | Verify `ocrConfig.language` matches the document language; quality depends on image resolution |
|
|
1074
1079
|
| Out of memory on large Excel files | Call `ast.toText()` early and discard the AST object to allow garbage collection |
|
|
1075
1080
|
| `md`/`html`/`csv` buffer not detected | Add `fileType: 'md'` (or `'html'`, `'csv'`) to config (these formats have no magic bytes) |
|
package/dist/defaults.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_GENERATOR_CONFIG = exports.DEFAULT_SEMANTIC_CHUNKING_CONFIG = exports.DEFAULT_DOCUMENT_STRUCTURE_CHUNKING_CONFIG = exports.DEFAULT_FIXED_SIZE_CHUNKING_CONFIG = exports.DEFAULT_OFFICE_PARSER_CONFIG = exports.DEFAULT_ABBREVIATIONS = exports.DEFAULT_SENTENCE_BOUNDARY_REGEX = void 0;
|
|
4
|
-
const PDFJS_VERSION = '
|
|
5
|
-
const DEFAULT_PDF_WORKER_SRC = `https://cdn.jsdelivr.net/npm/pdfjs-dist@${PDFJS_VERSION}/build/pdf.worker.min.mjs`;
|
|
4
|
+
const PDFJS_VERSION = '6.1.200';
|
|
5
|
+
const DEFAULT_PDF_WORKER_SRC = typeof __SLIM__ !== 'undefined' && __SLIM__ ? '' : `https://cdn.jsdelivr.net/npm/pdfjs-dist@${PDFJS_VERSION}/build/pdf.worker.min.mjs`;
|
|
6
6
|
/**
|
|
7
7
|
* The default regex used for identifying sentence boundaries.
|
|
8
8
|
* When this default is used, the generator employs a high-fidelity "robust"
|
|
@@ -69,7 +69,7 @@ exports.DEFAULT_OFFICE_PARSER_CONFIG = {
|
|
|
69
69
|
*/
|
|
70
70
|
const DEFAULT_HTML_GENERATOR_CONFIG = {
|
|
71
71
|
standalone: true,
|
|
72
|
-
chartJsSrc: 'https://cdn.jsdelivr.net/npm/chart.js',
|
|
72
|
+
chartJsSrc: typeof __SLIM__ !== 'undefined' && __SLIM__ ? '' : 'https://cdn.jsdelivr.net/npm/chart.js',
|
|
73
73
|
containerWidth: 'auto',
|
|
74
74
|
customCss: '',
|
|
75
75
|
injections: {
|
|
@@ -319,7 +319,7 @@ export interface OfficeParserConfig {
|
|
|
319
319
|
* The URL/path to the PDF.js worker script.
|
|
320
320
|
*
|
|
321
321
|
* **Mandatory** when using PDF parsing in browser environments to avoid worker configuration errors.
|
|
322
|
-
* If not provided, it defaults to `https://cdn.jsdelivr.net/npm/pdfjs-dist@
|
|
322
|
+
* If not provided, it defaults to `https://cdn.jsdelivr.net/npm/pdfjs-dist@6.1.200/build/pdf.worker.min.mjs`.
|
|
323
323
|
* You can override this with your own local path or a different CDN link.
|
|
324
324
|
*/
|
|
325
325
|
pdfWorkerSrc?: string;
|