officeparser 6.0.3 → 6.0.6

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 CHANGED
@@ -471,7 +471,7 @@ The browser bundle exposes the `officeParser` namespace. Include the bundle file
471
471
  ```
472
472
 
473
473
  ### PDF Worker Configuration in Browser
474
- When using `officeparser` in a browser environment to parse PDF files, you may provide the `pdfWorkerSrc` configuration option. If not provided, it defaults to a CDN link for `pdfjs-dist@5.4.530`.
474
+ When using `officeparser` in a browser environment to parse PDF files, you may provide the `pdfWorkerSrc` configuration option. If not provided, it defaults to a CDN link for `pdfjs-dist@5.5.207`.
475
475
 
476
476
  ```javascript
477
477
  const file = ...; // File object or ArrayBuffer
@@ -481,7 +481,7 @@ const ast = await officeParser.parseOffice(file);
481
481
 
482
482
  // Or override it with your own path or a different version:
483
483
  const ast2 = await officeParser.parseOffice(file, {
484
- pdfWorkerSrc: "https://unpkg.com/pdfjs-dist@5.4.530/build/pdf.worker.min.mjs"
484
+ pdfWorkerSrc: "https://unpkg.com/pdfjs-dist@5.5.207/build/pdf.worker.min.mjs"
485
485
  });
486
486
  ```
487
487
 
@@ -32,7 +32,6 @@
32
32
  *
33
33
  * @module OfficeParser
34
34
  */
35
- /// <reference types="node" />
36
35
  import { OfficeParserAST, OfficeParserConfig } from './types';
37
36
  /**
38
37
  * Main parser class providing office document parsing functionality.
@@ -49,16 +49,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
49
49
  }) : function(o, v) {
50
50
  o["default"] = v;
51
51
  });
52
- var __importStar = (this && this.__importStar) || function (mod) {
53
- if (mod && mod.__esModule) return mod;
54
- var result = {};
55
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
56
- __setModuleDefault(result, mod);
57
- return result;
58
- };
52
+ var __importStar = (this && this.__importStar) || (function () {
53
+ var ownKeys = function(o) {
54
+ ownKeys = Object.getOwnPropertyNames || function (o) {
55
+ var ar = [];
56
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
57
+ return ar;
58
+ };
59
+ return ownKeys(o);
60
+ };
61
+ return function (mod) {
62
+ if (mod && mod.__esModule) return mod;
63
+ var result = {};
64
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
65
+ __setModuleDefault(result, mod);
66
+ return result;
67
+ };
68
+ })();
59
69
  Object.defineProperty(exports, "__esModule", { value: true });
60
70
  exports.OfficeParser = void 0;
61
- const fileType = __importStar(require("file-type"));
62
71
  const fs = __importStar(require("fs"));
63
72
  const ExcelParser_1 = require("./parsers/ExcelParser");
64
73
  const OpenOfficeParser_1 = require("./parsers/OpenOfficeParser");
@@ -67,6 +76,7 @@ const PowerPointParser_1 = require("./parsers/PowerPointParser");
67
76
  const RtfParser_1 = require("./parsers/RtfParser");
68
77
  const WordParser_1 = require("./parsers/WordParser");
69
78
  const errorUtils_1 = require("./utils/errorUtils");
79
+ const moduleLoader_1 = require("./utils/moduleLoader");
70
80
  /**
71
81
  * Main parser class providing office document parsing functionality.
72
82
  *
@@ -169,7 +179,8 @@ class OfficeParser {
169
179
  throw (0, errorUtils_1.getOfficeError)(errorUtils_1.OfficeErrorType.INVALID_INPUT, internalConfig);
170
180
  }
171
181
  if (!ext) {
172
- const type = await fileType.fromBuffer(buffer);
182
+ const { fileTypeFromBuffer } = await (0, moduleLoader_1.loadFileType)();
183
+ const type = await fileTypeFromBuffer(buffer);
173
184
  if (type) {
174
185
  ext = type.ext.toLowerCase();
175
186
  }