@cj-tech-master/excelts 1.0.0 → 1.4.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.
Files changed (69) hide show
  1. package/dist/browser/excelts.iife.js +2568 -1188
  2. package/dist/browser/excelts.iife.js.map +1 -1
  3. package/dist/browser/excelts.iife.min.js +21 -19
  4. package/dist/cjs/index.js +1 -0
  5. package/dist/cjs/stream/xlsx/workbook-reader.js +2 -2
  6. package/dist/cjs/stream/xlsx/workbook-writer.js +8 -4
  7. package/dist/cjs/utils/cell-format.js +815 -0
  8. package/dist/cjs/utils/cell-matrix.js +37 -2
  9. package/dist/cjs/utils/parse-sax.js +2 -2
  10. package/dist/cjs/utils/sheet-utils.js +615 -0
  11. package/dist/cjs/utils/stream-buf.js +15 -4
  12. package/dist/cjs/utils/unzip/buffer-stream.js +27 -0
  13. package/dist/cjs/utils/unzip/index.js +23 -0
  14. package/dist/cjs/utils/unzip/noop-stream.js +20 -0
  15. package/dist/cjs/utils/unzip/parse-buffer.js +60 -0
  16. package/dist/cjs/utils/unzip/parse-datetime.js +23 -0
  17. package/dist/cjs/utils/unzip/parse-extra-field.js +52 -0
  18. package/dist/cjs/utils/unzip/parse.js +340 -0
  19. package/dist/cjs/utils/unzip/pull-stream.js +145 -0
  20. package/dist/cjs/utils/utils.js +13 -17
  21. package/dist/cjs/utils/zip-stream.js +29 -33
  22. package/dist/cjs/xlsx/xlsx.js +1 -2
  23. package/dist/esm/index.browser.js +1 -0
  24. package/dist/esm/index.js +1 -0
  25. package/dist/esm/stream/xlsx/workbook-reader.js +2 -2
  26. package/dist/esm/stream/xlsx/workbook-writer.js +9 -5
  27. package/dist/esm/utils/cell-format.js +810 -0
  28. package/dist/esm/utils/cell-matrix.js +37 -2
  29. package/dist/esm/utils/parse-sax.js +1 -1
  30. package/dist/esm/utils/sheet-utils.js +595 -0
  31. package/dist/esm/utils/stream-buf.js +15 -4
  32. package/dist/esm/utils/unzip/buffer-stream.js +24 -0
  33. package/dist/esm/utils/unzip/index.js +12 -0
  34. package/dist/esm/utils/unzip/noop-stream.js +16 -0
  35. package/dist/esm/utils/unzip/parse-buffer.js +57 -0
  36. package/dist/esm/utils/unzip/parse-datetime.js +20 -0
  37. package/dist/esm/utils/unzip/parse-extra-field.js +49 -0
  38. package/dist/esm/utils/unzip/parse.js +332 -0
  39. package/dist/esm/utils/unzip/pull-stream.js +141 -0
  40. package/dist/esm/utils/utils.js +12 -16
  41. package/dist/esm/utils/zip-stream.js +30 -34
  42. package/dist/esm/xlsx/xlsx.js +1 -2
  43. package/dist/types/doc/column.d.ts +1 -1
  44. package/dist/types/doc/worksheet.d.ts +2 -2
  45. package/dist/types/index.browser.d.ts +1 -0
  46. package/dist/types/index.d.ts +1 -0
  47. package/dist/types/stream/xlsx/workbook-writer.d.ts +1 -0
  48. package/dist/types/utils/cell-format.d.ts +32 -0
  49. package/dist/types/utils/sheet-utils.d.ts +203 -0
  50. package/dist/types/utils/unzip/buffer-stream.d.ts +9 -0
  51. package/dist/types/utils/unzip/index.d.ts +12 -0
  52. package/dist/types/utils/unzip/noop-stream.d.ts +13 -0
  53. package/dist/types/utils/unzip/parse-buffer.d.ts +24 -0
  54. package/dist/types/utils/unzip/parse-datetime.d.ts +12 -0
  55. package/dist/types/utils/unzip/parse-extra-field.d.ts +18 -0
  56. package/dist/types/utils/unzip/parse.d.ts +70 -0
  57. package/dist/types/utils/unzip/pull-stream.d.ts +24 -0
  58. package/dist/types/utils/utils.d.ts +5 -2
  59. package/dist/types/utils/zip-stream.d.ts +5 -1
  60. package/package.json +35 -32
  61. package/dist/cjs/utils/browser-buffer-decode.js +0 -13
  62. package/dist/cjs/utils/browser-buffer-encode.js +0 -13
  63. package/dist/cjs/utils/browser.js +0 -6
  64. package/dist/esm/utils/browser-buffer-decode.js +0 -11
  65. package/dist/esm/utils/browser-buffer-encode.js +0 -11
  66. package/dist/esm/utils/browser.js +0 -3
  67. package/dist/types/utils/browser-buffer-decode.d.ts +0 -2
  68. package/dist/types/utils/browser-buffer-encode.d.ts +0 -2
  69. package/dist/types/utils/browser.d.ts +0 -1
package/dist/cjs/index.js CHANGED
@@ -49,3 +49,4 @@ Object.defineProperty(exports, "DataValidations", { enumerable: true, get: funct
49
49
  __exportStar(require("./doc/enums"), exports);
50
50
  // Export all type definitions
51
51
  __exportStar(require("./types"), exports);
52
+ __exportStar(require("./utils/sheet-utils"), exports);
@@ -9,7 +9,6 @@ const events_1 = require("events");
9
9
  const stream_1 = require("stream");
10
10
  const os_1 = __importDefault(require("os"));
11
11
  const path_1 = require("path");
12
- const unzipper_1 = require("unzipper");
13
12
  const iterate_stream_js_1 = require("../../utils/iterate-stream");
14
13
  const parse_sax_js_1 = require("../../utils/parse-sax");
15
14
  const styles_xform_js_1 = require("../../xlsx/xform/style/styles-xform");
@@ -17,6 +16,7 @@ const workbook_xform_js_1 = require("../../xlsx/xform/book/workbook-xform");
17
16
  const relationships_xform_js_1 = require("../../xlsx/xform/core/relationships-xform");
18
17
  const worksheet_reader_js_1 = require("./worksheet-reader");
19
18
  const hyperlink_reader_js_1 = require("./hyperlink-reader");
19
+ const parse_js_1 = require("../../utils/unzip/parse");
20
20
  class WorkbookReader extends events_1.EventEmitter {
21
21
  constructor(input, options = {}) {
22
22
  super();
@@ -76,7 +76,7 @@ class WorkbookReader extends events_1.EventEmitter {
76
76
  this.options = options;
77
77
  }
78
78
  const stream = (this.stream = this._getStream(input || this.input));
79
- const zip = (0, unzipper_1.Parse)({ forceStream: true });
79
+ const zip = (0, parse_js_1.createParse)({ forceStream: true });
80
80
  // Handle pipe errors to prevent unhandled rejection
81
81
  stream.on("error", (err) => {
82
82
  zip.emit("error", err);
@@ -36,6 +36,10 @@ class WorkbookWriter {
36
36
  this._worksheets = [];
37
37
  this.views = [];
38
38
  this.zipOptions = options.zip;
39
+ // Extract compression level from zip options (supports both zlib.level and compressionOptions.level)
40
+ // Default compression level is 6 (good balance of speed and size)
41
+ const level = options.zip?.zlib?.level ?? options.zip?.compressionOptions?.level ?? 6;
42
+ this.compressionLevel = Math.max(0, Math.min(9, level));
39
43
  this.media = [];
40
44
  this.commentRefs = [];
41
45
  // Create fflate Zip instance
@@ -67,8 +71,8 @@ class WorkbookWriter {
67
71
  }
68
72
  _openStream(path) {
69
73
  const stream = new stream_buf_js_1.StreamBuf({ bufSize: 65536, batch: true });
70
- // Create a ZipPassThrough for this file
71
- const zipFile = new fflate_1.ZipPassThrough(path);
74
+ // Create a ZipDeflate for this file with compression
75
+ const zipFile = new fflate_1.ZipDeflate(path, { level: this.compressionLevel });
72
76
  this.zip.add(zipFile);
73
77
  // Don't pause the stream - we need data events to flow
74
78
  // The original implementation used archiver which consumed the stream internally
@@ -87,8 +91,8 @@ class WorkbookWriter {
87
91
  return stream;
88
92
  }
89
93
  _addFile(data, name, base64) {
90
- // Helper method to add a file to the zip using fflate
91
- const zipFile = new fflate_1.ZipPassThrough(name);
94
+ // Helper method to add a file to the zip using fflate with compression
95
+ const zipFile = new fflate_1.ZipDeflate(name, { level: this.compressionLevel });
92
96
  this.zip.add(zipFile);
93
97
  let buffer;
94
98
  if (base64) {