@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
@@ -108,6 +108,10 @@ export class Workbook {
108
108
  throw new RangeError("compression must be auto or store.");
109
109
  if (options.oversizedText !== undefined && !["reject", "preserve"].includes(options.oversizedText))
110
110
  throw new RangeError("oversizedText must be reject or preserve.");
111
+ if (options.hyperlinkOverflow !== undefined && !["reject", "drop"].includes(options.hyperlinkOverflow))
112
+ throw new RangeError("hyperlinkOverflow must be reject or drop.");
113
+ if (options.onHyperlinkOverflow !== undefined && typeof options.onHyperlinkOverflow !== "function")
114
+ throw new TypeError("onHyperlinkOverflow must be a function.");
111
115
  cleanXml("", policy);
112
116
  corePropertiesXml(options, policy);
113
117
  this.budget = new ExportBudget(options.limits);
@@ -185,6 +189,8 @@ export class Workbook {
185
189
  }
186
190
  /** @internal Reserve a preflighted worksheet batch or one row hyperlink. */
187
191
  retainLink(count = 1) { this.checkLinks(count); this.links += count; }
192
+ /** @internal A worksheet dropped a data-cell link it had retained. */
193
+ releaseLink() { this.links--; }
188
194
  /** @internal */
189
195
  checkImage(bytes) {
190
196
  if (this.settings.limits?.maxImageBytes !== undefined && this.imageBytes + bytes > this.settings.limits.maxImageBytes)
@@ -35,8 +35,13 @@ export declare class Worksheet<T = never> {
35
35
  private pendingCharacters;
36
36
  private reservedLayout;
37
37
  private readonly internalLinks;
38
- private readonly links;
38
+ private links;
39
+ private evictedLinks;
39
40
  private readonly linkedCells;
41
+ /** Indexes in `links` of data-cell links that `hyperlinkOverflow: "drop"` may give up, in row order. */
42
+ private droppable;
43
+ private readonly droppableLinks;
44
+ private droppedLinks;
40
45
  private readonly pictures;
41
46
  private readonly nativeCharts;
42
47
  private readonly conditional;
@@ -66,6 +71,13 @@ export declare class Worksheet<T = never> {
66
71
  /** Attach an external report link to a cell without changing its literal value. */
67
72
  addHyperlink(link: Hyperlink): void;
68
73
  private appendHyperlink;
74
+ /** Links the worksheet holds now, not counting evicted holes. */
75
+ private get linkCount();
76
+ /** A full worksheet gives up its latest data-cell link for a link that cannot be dropped. Hyperlinks are serialized after
77
+ * the rows, so the cell keeps its written value. The entry becomes a hole, so other indexes stay valid until compaction. */
78
+ private makeLinkRoom;
79
+ /** One ordered pass removes evicted holes and rebuilds the droppable indexes. */
80
+ private compactLinks;
69
81
  /** Complete this worksheet. A streamed workbook can then start its next worksheet. */
70
82
  close(): Promise<void>;
71
83
  }
@@ -1,7 +1,7 @@
1
1
  import { checkAbort, consumeRows, inputRows, pause, taskYieldDue } from "../core/iteration.js";
2
2
  import { ChunkedTextSink, BlobByteSink } from "../core/sinks.js";
3
3
  import { OfficeIMOError } from "../core/errors.js";
4
- import { notifyProgress } from "../core/progress.js";
4
+ import { notifyProgress, notifySynchronously } from "../core/progress.js";
5
5
  import { copyColumns, createRowProjector } from "../internal/rows.js";
6
6
  import { EntryWriter } from "../zip/entry.js";
7
7
  import { xmlDeclaration } from "../xml/index.js";
@@ -55,8 +55,14 @@ export class Worksheet {
55
55
  pendingCharacters = 0;
56
56
  reservedLayout = false;
57
57
  internalLinks = [];
58
+ // Evicted entries become holes and are compacted in one pass when the links are read, keeping eviction O(1).
58
59
  links = [];
60
+ evictedLinks = 0;
59
61
  linkedCells = new Set();
62
+ /** Indexes in `links` of data-cell links that `hyperlinkOverflow: "drop"` may give up, in row order. */
63
+ droppable = [];
64
+ droppableLinks = new WeakSet();
65
+ droppedLinks = 0;
60
66
  pictures = [];
61
67
  nativeCharts = [];
62
68
  conditional;
@@ -268,7 +274,8 @@ export class Worksheet {
268
274
  const cell = col.letter + row;
269
275
  if (link || this.linkedCells.has(cell))
270
276
  throw new TypeError("A text-preservation cell cannot also have an external hyperlink.");
271
- checkHyperlinkCount(this.links.length + this.internalLinks.length + 1);
277
+ this.makeLinkRoom();
278
+ checkHyperlinkCount(this.linkCount + 1);
272
279
  this.book.checkLinks(1);
273
280
  // Replace a generated cell's original reservation with its preview and overflow records.
274
281
  if (reservedCharacters !== undefined) {
@@ -282,7 +289,7 @@ export class Worksheet {
282
289
  value = preserved.preview;
283
290
  }
284
291
  if (link)
285
- this.appendHyperlink({ cell: col.letter + row, ...link });
292
+ this.appendHyperlink({ cell: col.letter + row, ...link }, !header && !footer && !title && this.book.settings.hyperlinkOverflow === "drop");
286
293
  if (type === "date")
287
294
  value = excelDate(value, this.book.settings.dateMode);
288
295
  if (!header && !footer && visible && (!formula || !isSubtotalFormula(formula)))
@@ -591,20 +598,61 @@ export class Worksheet {
591
598
  throw this.error;
592
599
  this.appendHyperlink(link);
593
600
  }
594
- appendHyperlink(link) {
601
+ appendHyperlink(link, droppable = false) {
602
+ // Validate before any overflow decision, so a dropped link can never hide an unsafe target.
595
603
  const copied = copyHyperlink(link, this.book.settings.invalidCharacterPolicy);
596
604
  const position = cellPosition(copied.cell);
597
605
  if (this.layout.regions.covered(position.column, position.row))
598
606
  throw new TypeError("Hyperlinks cannot address a covered merged cell.");
599
607
  if (this.linkedCells.has(copied.cell))
600
608
  throw new TypeError("Duplicate hyperlink cell: " + copied.cell);
601
- checkHyperlinkCount(this.links.length + this.internalLinks.length + 1);
609
+ if (droppable && this.linkCount >= maximumHyperlinks) {
610
+ this.droppedLinks++;
611
+ return;
612
+ }
613
+ if (!droppable)
614
+ this.makeLinkRoom();
615
+ checkHyperlinkCount(this.linkCount + 1);
602
616
  this.book.retainLink();
617
+ if (droppable) {
618
+ this.droppable.push(this.links.length);
619
+ this.droppableLinks.add(copied);
620
+ }
603
621
  this.links.push(copied);
604
622
  this.linkedCells.add(copied.cell);
605
623
  }
624
+ /** Links the worksheet holds now, not counting evicted holes. */
625
+ get linkCount() { return this.links.length - this.evictedLinks + this.internalLinks.length; }
626
+ /** A full worksheet gives up its latest data-cell link for a link that cannot be dropped. Hyperlinks are serialized after
627
+ * the rows, so the cell keeps its written value. The entry becomes a hole, so other indexes stay valid until compaction. */
628
+ makeLinkRoom() {
629
+ if (this.linkCount < maximumHyperlinks || !this.droppable.length)
630
+ return;
631
+ const index = this.droppable.pop(), removed = this.links[index];
632
+ this.links[index] = undefined;
633
+ this.evictedLinks++;
634
+ this.linkedCells.delete(removed.cell);
635
+ this.book.releaseLink();
636
+ this.droppedLinks++;
637
+ }
638
+ /** One ordered pass removes evicted holes and rebuilds the droppable indexes. */
639
+ compactLinks() {
640
+ if (this.evictedLinks) {
641
+ const kept = [], droppable = [];
642
+ for (const link of this.links)
643
+ if (link) {
644
+ if (this.droppableLinks.has(link))
645
+ droppable.push(kept.length);
646
+ kept.push(link);
647
+ }
648
+ this.links = kept;
649
+ this.droppable = droppable;
650
+ this.evictedLinks = 0;
651
+ }
652
+ return this.links;
653
+ }
606
654
  /** @internal */
607
- get hyperlinks() { return this.links; }
655
+ get hyperlinks() { return this.compactLinks(); }
608
656
  /** @internal */
609
657
  get images() { return this.pictures; }
610
658
  /** @internal An empty export has no data table; it still emits the declared headers. */
@@ -655,7 +703,7 @@ export class Worksheet {
655
703
  for (const binding of this.chartSources)
656
704
  binding.finish();
657
705
  this.chartSources.length = 0;
658
- for (const link of this.links) {
706
+ for (const link of this.compactLinks()) {
659
707
  const position = cellPosition(link.cell);
660
708
  if (position.column > this.columns.length || position.row > this.totalRows)
661
709
  throw new RangeError("Hyperlinks must address cells within the exported rows and columns.");
@@ -685,8 +733,11 @@ export class Worksheet {
685
733
  await this.buffer.write(xml);
686
734
  for (const xml of dataValidationsXml(this.validations, this.headerRows, this.count, detailRanges))
687
735
  await this.buffer.write(xml);
688
- if (this.links.length || this.internalLinks.length)
689
- await this.buffer.write(hyperlinksXml(this.links, this.book.settings.invalidCharacterPolicy, this.internalLinks));
736
+ if (this.droppedLinks)
737
+ notifySynchronously("onHyperlinkOverflow", this.book.settings.onHyperlinkOverflow, Object.freeze({ sheetName: this.name, dropped: this.droppedLinks }));
738
+ const links = this.compactLinks();
739
+ if (links.length || this.internalLinks.length)
740
+ await this.buffer.write(hyperlinksXml(links, this.book.settings.invalidCharacterPolicy, this.internalLinks));
690
741
  await this.buffer.write(printXml(this.options.print, this.book.settings.invalidCharacterPolicy));
691
742
  if (this.pictures.length || this.nativeCharts.length)
692
743
  await this.buffer.write('<drawing r:id="drawing"/>');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evotecit/officeimo",
3
- "version": "0.1.21",
3
+ "version": "0.1.43",
4
4
  "description": "Dependency-free OfficeIMO document libraries for browsers, workers and Node.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -56,7 +56,12 @@
56
56
  "types": "./dist/integrations/canopyx/index.d.ts",
57
57
  "import": "./dist/integrations/canopyx/index.js"
58
58
  },
59
+ "./integrations/chartforgex": {
60
+ "types": "./dist/integrations/chartforgex/index.d.ts",
61
+ "import": "./dist/integrations/chartforgex/index.js"
62
+ },
59
63
  "./canopyx.js": "./bundles/officeimo-canopyx.js",
64
+ "./chartforgex.js": "./bundles/officeimo-chartforgex.js",
60
65
  "./datatables.js": "./bundles/officeimo-datatables.js",
61
66
  "./classic.js": "./bundles/officeimo.js",
62
67
  "./xlsx.js": "./bundles/officeimo-xlsx.js",
@@ -65,6 +70,7 @@
65
70
  "./execution.js": "./bundles/officeimo-execution.js",
66
71
  "./canopyx-adapter.js": "./bundles/officeimo-canopyx-adapter.js",
67
72
  "./datatables-adapter.js": "./bundles/officeimo-datatables-adapter.js",
73
+ "./chartforgex-adapter.js": "./bundles/officeimo-chartforgex-adapter.js",
68
74
  "./bundles/*": "./bundles/*"
69
75
  },
70
76
  "files": [
@@ -105,6 +111,7 @@
105
111
  "excel",
106
112
  "browser",
107
113
  "streaming",
108
- "typescript"
114
+ "typescript",
115
+ "chartforgex"
109
116
  ]
110
117
  }