@evotecit/officeimo 0.1.21 → 0.1.43

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 (92) hide show
  1. package/README.md +39 -8
  2. package/bundles/officeimo-canopyx-adapter.js +56 -36
  3. package/bundles/officeimo-canopyx-adapter.min.js +1 -1
  4. package/bundles/officeimo-canopyx-adapter.min.mjs +1 -1
  5. package/bundles/officeimo-canopyx-adapter.mjs +42 -22
  6. package/bundles/officeimo-canopyx.js +420 -177
  7. package/bundles/officeimo-canopyx.min.js +1 -1
  8. package/bundles/officeimo-canopyx.min.mjs +1 -1
  9. package/bundles/officeimo-canopyx.mjs +346 -103
  10. package/bundles/officeimo-chartforgex-adapter.js +1924 -0
  11. package/bundles/officeimo-chartforgex-adapter.min.js +2 -0
  12. package/bundles/officeimo-chartforgex-adapter.min.mjs +2 -0
  13. package/bundles/officeimo-chartforgex-adapter.mjs +1910 -0
  14. package/bundles/officeimo-chartforgex.js +13594 -0
  15. package/bundles/officeimo-chartforgex.min.js +2 -0
  16. package/bundles/officeimo-chartforgex.min.mjs +2 -0
  17. package/bundles/officeimo-chartforgex.mjs +13487 -0
  18. package/bundles/officeimo-csv.js +12 -7
  19. package/bundles/officeimo-csv.min.js +1 -1
  20. package/bundles/officeimo-csv.min.mjs +1 -1
  21. package/bundles/officeimo-csv.mjs +8 -3
  22. package/bundles/officeimo-datatables-adapter.js +11 -11
  23. package/bundles/officeimo-datatables-adapter.min.js +1 -1
  24. package/bundles/officeimo-datatables-adapter.min.mjs +1 -1
  25. package/bundles/officeimo-datatables-adapter.mjs +7 -7
  26. package/bundles/officeimo-datatables.js +375 -152
  27. package/bundles/officeimo-datatables.min.js +1 -1
  28. package/bundles/officeimo-datatables.min.mjs +1 -1
  29. package/bundles/officeimo-datatables.mjs +311 -88
  30. package/bundles/officeimo-execution.js +14 -9
  31. package/bundles/officeimo-execution.min.js +1 -1
  32. package/bundles/officeimo-execution.min.mjs +1 -1
  33. package/bundles/officeimo-execution.mjs +8 -3
  34. package/bundles/officeimo-pdf.js +286 -120
  35. package/bundles/officeimo-pdf.min.js +1 -1
  36. package/bundles/officeimo-pdf.min.mjs +1 -1
  37. package/bundles/officeimo-pdf.mjs +244 -78
  38. package/bundles/officeimo-xlsx.js +93 -31
  39. package/bundles/officeimo-xlsx.min.js +1 -1
  40. package/bundles/officeimo-xlsx.min.mjs +1 -1
  41. package/bundles/officeimo-xlsx.mjs +75 -13
  42. package/bundles/officeimo.js +373 -150
  43. package/bundles/officeimo.min.js +1 -1
  44. package/bundles/officeimo.min.mjs +1 -1
  45. package/bundles/officeimo.mjs +312 -89
  46. package/dist/core/progress.js +7 -2
  47. package/dist/index.d.ts +1 -1
  48. package/dist/integrations/canopyx/index.js +9 -2
  49. package/dist/integrations/canopyx/source.js +26 -13
  50. package/dist/integrations/chartforgex/capture.d.ts +31 -0
  51. package/dist/integrations/chartforgex/capture.js +103 -0
  52. package/dist/integrations/chartforgex/index.d.ts +13 -0
  53. package/dist/integrations/chartforgex/index.js +88 -0
  54. package/dist/integrations/chartforgex/svg-drawing.d.ts +5 -0
  55. package/dist/integrations/chartforgex/svg-drawing.js +775 -0
  56. package/dist/integrations/chartforgex/svg-geometry.d.ts +23 -0
  57. package/dist/integrations/chartforgex/svg-geometry.js +304 -0
  58. package/dist/integrations/chartforgex/svg-image.d.ts +9 -0
  59. package/dist/integrations/chartforgex/svg-image.js +46 -0
  60. package/dist/integrations/chartforgex/svg-markup.d.ts +10 -0
  61. package/dist/integrations/chartforgex/svg-markup.js +124 -0
  62. package/dist/integrations/chartforgex/svg-paint.d.ts +16 -0
  63. package/dist/integrations/chartforgex/svg-paint.js +146 -0
  64. package/dist/integrations/chartforgex/types.d.ts +77 -0
  65. package/dist/integrations/chartforgex/types.js +1 -0
  66. package/dist/integrations/chartforgex/winansi.d.ts +4 -0
  67. package/dist/integrations/chartforgex/winansi.js +48 -0
  68. package/dist/integrations/chartforgex/workbook.d.ts +12 -0
  69. package/dist/integrations/chartforgex/workbook.js +137 -0
  70. package/dist/pdf/document-drawings.d.ts +1 -1
  71. package/dist/pdf/document-drawings.js +91 -17
  72. package/dist/pdf/document-images.d.ts +7 -1
  73. package/dist/pdf/document-images.js +59 -24
  74. package/dist/pdf/document-types.d.ts +3 -1
  75. package/dist/pdf/document.d.ts +2 -2
  76. package/dist/pdf/document.js +3 -1
  77. package/dist/pdf/drawing-types.d.ts +37 -10
  78. package/dist/pdf/font-resources.d.ts +1 -1
  79. package/dist/pdf/font-resources.js +6 -3
  80. package/dist/pdf/index.d.ts +1 -1
  81. package/dist/pdf/pages.js +15 -0
  82. package/dist/pdf/png.d.ts +11 -2
  83. package/dist/pdf/png.js +50 -23
  84. package/dist/pdf/session.js +3 -2
  85. package/dist/pdf/settings.d.ts +2 -2
  86. package/dist/pdf/settings.js +7 -3
  87. package/dist/xlsx/options.js +1 -1
  88. package/dist/xlsx/types.d.ts +8 -0
  89. package/dist/xlsx/workbook.js +6 -0
  90. package/dist/xlsx/worksheet.d.ts +13 -1
  91. package/dist/xlsx/worksheet.js +60 -9
  92. package/package.json +9 -2
@@ -192,15 +192,20 @@ return _exports;
192
192
  const _m4 = (() => {
193
193
  /** @internal Notify synchronously; observe an accidental promise before rejecting its unsupported use. */
194
194
  function notifyProgress(callback, progress) {
195
+ notifySynchronously("onProgress", callback, progress);
196
+ }
197
+ /** @internal Run a host notification that must finish before the export continues. A returned promise is observed,
198
+ * so its rejection is never unhandled, and the export fails instead of reporting success before the callback ends. */
199
+ function notifySynchronously(name, callback, value) {
195
200
  if (!callback)
196
201
  return;
197
- const result = callback(progress);
202
+ const result = callback(value);
198
203
  if (result && typeof result.then === "function") {
199
204
  void Promise.resolve(result).catch(() => { });
200
- throw new TypeError("onProgress must be synchronous.");
205
+ throw new TypeError(name + " must be synchronous.");
201
206
  }
202
207
  }
203
- const _exports = Object.freeze({ notifyProgress: notifyProgress });
208
+ const _exports = Object.freeze({ notifyProgress: notifyProgress, notifySynchronously: notifySynchronously });
204
209
  return _exports;
205
210
  })();
206
211
 
@@ -3036,7 +3041,7 @@ const { ChunkedTextSink, BlobByteSink } = _m5;
3036
3041
 
3037
3042
  const { OfficeIMOError } = _m3;
3038
3043
 
3039
- const { notifyProgress } = _m4;
3044
+ const { notifyProgress, notifySynchronously } = _m4;
3040
3045
 
3041
3046
  const { copyColumns, createRowProjector } = _m24;
3042
3047
 
@@ -3108,8 +3113,14 @@ class Worksheet {
3108
3113
  pendingCharacters = 0;
3109
3114
  reservedLayout = false;
3110
3115
  internalLinks = [];
3116
+ // Evicted entries become holes and are compacted in one pass when the links are read, keeping eviction O(1).
3111
3117
  links = [];
3118
+ evictedLinks = 0;
3112
3119
  linkedCells = new Set();
3120
+ /** Indexes in `links` of data-cell links that `hyperlinkOverflow: "drop"` may give up, in row order. */
3121
+ droppable = [];
3122
+ droppableLinks = new WeakSet();
3123
+ droppedLinks = 0;
3113
3124
  pictures = [];
3114
3125
  nativeCharts = [];
3115
3126
  conditional;
@@ -3321,7 +3332,8 @@ class Worksheet {
3321
3332
  const cell = col.letter + row;
3322
3333
  if (link || this.linkedCells.has(cell))
3323
3334
  throw new TypeError("A text-preservation cell cannot also have an external hyperlink.");
3324
- checkHyperlinkCount(this.links.length + this.internalLinks.length + 1);
3335
+ this.makeLinkRoom();
3336
+ checkHyperlinkCount(this.linkCount + 1);
3325
3337
  this.book.checkLinks(1);
3326
3338
  // Replace a generated cell's original reservation with its preview and overflow records.
3327
3339
  if (reservedCharacters !== undefined) {
@@ -3335,7 +3347,7 @@ class Worksheet {
3335
3347
  value = preserved.preview;
3336
3348
  }
3337
3349
  if (link)
3338
- this.appendHyperlink({ cell: col.letter + row, ...link });
3350
+ this.appendHyperlink({ cell: col.letter + row, ...link }, !header && !footer && !title && this.book.settings.hyperlinkOverflow === "drop");
3339
3351
  if (type === "date")
3340
3352
  value = excelDate(value, this.book.settings.dateMode);
3341
3353
  if (!header && !footer && visible && (!formula || !isSubtotalFormula(formula)))
@@ -3644,20 +3656,61 @@ class Worksheet {
3644
3656
  throw this.error;
3645
3657
  this.appendHyperlink(link);
3646
3658
  }
3647
- appendHyperlink(link) {
3659
+ appendHyperlink(link, droppable = false) {
3660
+ // Validate before any overflow decision, so a dropped link can never hide an unsafe target.
3648
3661
  const copied = copyHyperlink(link, this.book.settings.invalidCharacterPolicy);
3649
3662
  const position = cellPosition(copied.cell);
3650
3663
  if (this.layout.regions.covered(position.column, position.row))
3651
3664
  throw new TypeError("Hyperlinks cannot address a covered merged cell.");
3652
3665
  if (this.linkedCells.has(copied.cell))
3653
3666
  throw new TypeError("Duplicate hyperlink cell: " + copied.cell);
3654
- checkHyperlinkCount(this.links.length + this.internalLinks.length + 1);
3667
+ if (droppable && this.linkCount >= maximumHyperlinks) {
3668
+ this.droppedLinks++;
3669
+ return;
3670
+ }
3671
+ if (!droppable)
3672
+ this.makeLinkRoom();
3673
+ checkHyperlinkCount(this.linkCount + 1);
3655
3674
  this.book.retainLink();
3675
+ if (droppable) {
3676
+ this.droppable.push(this.links.length);
3677
+ this.droppableLinks.add(copied);
3678
+ }
3656
3679
  this.links.push(copied);
3657
3680
  this.linkedCells.add(copied.cell);
3658
3681
  }
3682
+ /** Links the worksheet holds now, not counting evicted holes. */
3683
+ get linkCount() { return this.links.length - this.evictedLinks + this.internalLinks.length; }
3684
+ /** A full worksheet gives up its latest data-cell link for a link that cannot be dropped. Hyperlinks are serialized after
3685
+ * the rows, so the cell keeps its written value. The entry becomes a hole, so other indexes stay valid until compaction. */
3686
+ makeLinkRoom() {
3687
+ if (this.linkCount < maximumHyperlinks || !this.droppable.length)
3688
+ return;
3689
+ const index = this.droppable.pop(), removed = this.links[index];
3690
+ this.links[index] = undefined;
3691
+ this.evictedLinks++;
3692
+ this.linkedCells.delete(removed.cell);
3693
+ this.book.releaseLink();
3694
+ this.droppedLinks++;
3695
+ }
3696
+ /** One ordered pass removes evicted holes and rebuilds the droppable indexes. */
3697
+ compactLinks() {
3698
+ if (this.evictedLinks) {
3699
+ const kept = [], droppable = [];
3700
+ for (const link of this.links)
3701
+ if (link) {
3702
+ if (this.droppableLinks.has(link))
3703
+ droppable.push(kept.length);
3704
+ kept.push(link);
3705
+ }
3706
+ this.links = kept;
3707
+ this.droppable = droppable;
3708
+ this.evictedLinks = 0;
3709
+ }
3710
+ return this.links;
3711
+ }
3659
3712
  /** @internal */
3660
- get hyperlinks() { return this.links; }
3713
+ get hyperlinks() { return this.compactLinks(); }
3661
3714
  /** @internal */
3662
3715
  get images() { return this.pictures; }
3663
3716
  /** @internal An empty export has no data table; it still emits the declared headers. */
@@ -3708,7 +3761,7 @@ class Worksheet {
3708
3761
  for (const binding of this.chartSources)
3709
3762
  binding.finish();
3710
3763
  this.chartSources.length = 0;
3711
- for (const link of this.links) {
3764
+ for (const link of this.compactLinks()) {
3712
3765
  const position = cellPosition(link.cell);
3713
3766
  if (position.column > this.columns.length || position.row > this.totalRows)
3714
3767
  throw new RangeError("Hyperlinks must address cells within the exported rows and columns.");
@@ -3738,8 +3791,11 @@ class Worksheet {
3738
3791
  await this.buffer.write(xml);
3739
3792
  for (const xml of dataValidationsXml(this.validations, this.headerRows, this.count, detailRanges))
3740
3793
  await this.buffer.write(xml);
3741
- if (this.links.length || this.internalLinks.length)
3742
- await this.buffer.write(hyperlinksXml(this.links, this.book.settings.invalidCharacterPolicy, this.internalLinks));
3794
+ if (this.droppedLinks)
3795
+ notifySynchronously("onHyperlinkOverflow", this.book.settings.onHyperlinkOverflow, Object.freeze({ sheetName: this.name, dropped: this.droppedLinks }));
3796
+ const links = this.compactLinks();
3797
+ if (links.length || this.internalLinks.length)
3798
+ await this.buffer.write(hyperlinksXml(links, this.book.settings.invalidCharacterPolicy, this.internalLinks));
3743
3799
  await this.buffer.write(printXml(this.options.print, this.book.settings.invalidCharacterPolicy));
3744
3800
  if (this.pictures.length || this.nativeCharts.length)
3745
3801
  await this.buffer.write('<drawing r:id="drawing"/>');
@@ -3884,7 +3940,7 @@ const _m40 = (() => {
3884
3940
  const { captureFields } = _m7;
3885
3941
 
3886
3942
  /** @internal The workbook owner captures these settings before validation or adapter merging. */
3887
- const workbookOptionFields = ["signal", "onProgress", "limits", "sink", "dateMode", "compression", "invalidCharacterPolicy", "appProperties", "cellValueWriters", "oversizedText", "creator", "title", "subject", "description", "created", "modified"];
3943
+ const workbookOptionFields = ["signal", "onProgress", "limits", "sink", "dateMode", "compression", "invalidCharacterPolicy", "appProperties", "cellValueWriters", "oversizedText", "hyperlinkOverflow", "onHyperlinkOverflow", "creator", "title", "subject", "description", "created", "modified"];
3888
3944
  /** @internal Worksheet settings also used by the portable sheet owner. */
3889
3945
  const sheetOptionFields = ["columns", "includeHeader", "headerRows", "freezeHeader", "autoFilter", "boldHeader", "headerFill", "headerBorder", "headerWrap", "headerStyle", "alternatingRowStyle", "rowStyle", "cellStyle", "rowOutline", "maxOutlineLevel", "outlineSummaryBelow", "outlineSummaryRight", "columnOutlines", "rowHeight", "headerHeight", "defaultColumnWidth", "freezeColumns", "table", "autoSize", "footer", "print", "title", "mergedCells", "hyperlinks", "conditionalFormats", "dataValidation"];
3890
3946
  /** @internal Includes inherited format-specific ceilings before a wrapper combines stream settings. */
@@ -4336,6 +4392,10 @@ class Workbook {
4336
4392
  throw new RangeError("compression must be auto or store.");
4337
4393
  if (options.oversizedText !== undefined && !["reject", "preserve"].includes(options.oversizedText))
4338
4394
  throw new RangeError("oversizedText must be reject or preserve.");
4395
+ if (options.hyperlinkOverflow !== undefined && !["reject", "drop"].includes(options.hyperlinkOverflow))
4396
+ throw new RangeError("hyperlinkOverflow must be reject or drop.");
4397
+ if (options.onHyperlinkOverflow !== undefined && typeof options.onHyperlinkOverflow !== "function")
4398
+ throw new TypeError("onHyperlinkOverflow must be a function.");
4339
4399
  cleanXml("", policy);
4340
4400
  corePropertiesXml(options, policy);
4341
4401
  this.budget = new ExportBudget(options.limits);
@@ -4413,6 +4473,8 @@ class Workbook {
4413
4473
  }
4414
4474
  /** @internal Reserve a preflighted worksheet batch or one row hyperlink. */
4415
4475
  retainLink(count = 1) { this.checkLinks(count); this.links += count; }
4476
+ /** @internal A worksheet dropped a data-cell link it had retained. */
4477
+ releaseLink() { this.links--; }
4416
4478
  /** @internal */
4417
4479
  checkImage(bytes) {
4418
4480
  if (this.settings.limits?.maxImageBytes !== undefined && this.imageBytes + bytes > this.settings.limits.maxImageBytes)