@evotecit/officeimo 0.1.1 → 0.1.2

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.
@@ -1289,6 +1289,8 @@ const { OfficeIMOError } = _m2;
1289
1289
  const { ChunkedTextSink } = _m3;
1290
1290
 
1291
1291
  const xmlDeclaration = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
1292
+ const xmlEscapes = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&apos;",
1293
+ "\r": "&#13;", "\n": "&#10;", "\t": "&#9;" };
1292
1294
  /** XML 1.0 characters; Unicode mode retains valid surrogate pairs. */
1293
1295
  function cleanXml(value, policy = "strip") {
1294
1296
  if (policy !== "strip" && policy !== "reject")
@@ -1300,9 +1302,7 @@ function cleanXml(value, policy = "strip") {
1300
1302
  }
1301
1303
  /** Escape data, including whitespace that XML parsers otherwise normalize. */
1302
1304
  function escapeXml(value, policy = "strip") {
1303
- const escapes = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&apos;",
1304
- "\r": "&#13;", "\n": "&#10;", "\t": "&#9;" };
1305
- return cleanXml(value, policy).replace(/[&<>"'\r\n\t]/g, c => escapes[c]);
1305
+ return cleanXml(value, policy).replace(/[&<>"'\r\n\t]/g, c => xmlEscapes[c]);
1306
1306
  }
1307
1307
  /** Encode an OOXML ST_Xstring attribute without interpreting literal escape tokens as characters. */
1308
1308
  function escapeOoxmlAttribute(value, policy = "strip") {
@@ -1900,8 +1900,11 @@ class OpcPackage {
1900
1900
  return uri;
1901
1901
  }
1902
1902
  addPart(part) {
1903
- const uri = this.reserve(part.uri, part.contentType);
1904
- this.parts.set(uri.toLowerCase(), { ...part, uri, data: part.data instanceof Uint8Array ? new Uint8Array(part.data) : part.data });
1903
+ const { uri: requestedUri, contentType, data } = part;
1904
+ // Structural accessors and byte ownership are captured before reserving metadata.
1905
+ const capturedData = data instanceof Uint8Array ? new Uint8Array(data) : data;
1906
+ const uri = this.reserve(requestedUri, contentType);
1907
+ this.parts.set(uri.toLowerCase(), { uri, contentType, data: capturedData });
1905
1908
  }
1906
1909
  /** @internal */
1907
1910
  addPrepared(uri, type, prepared) {
@@ -1926,17 +1929,19 @@ class OpcPackage {
1926
1929
  checkAbort(this.options.signal);
1927
1930
  this.open();
1928
1931
  source = source === "/" ? source : partUri(source);
1929
- if (!/^[A-Za-z_][A-Za-z0-9_.-]*$/.test(relationship.id))
1932
+ const { id, type, target: requestedTarget, external } = relationship;
1933
+ this.open();
1934
+ if (!/^[A-Za-z_][A-Za-z0-9_.-]*$/.test(id))
1930
1935
  throw new TypeError("Relationship id must be an XML ID.");
1931
- if (!/^[A-Za-z][A-Za-z0-9+.-]*:[^\s<>"']+$/.test(relationship.type))
1936
+ if (!/^[A-Za-z][A-Za-z0-9+.-]*:[^\s<>"']+$/.test(type))
1932
1937
  throw new TypeError("Relationship type must be an absolute URI.");
1933
- const target = relationship.external ? relationship.target : partUri(relationship.target);
1934
- if (relationship.external && (!target || /[\u0000-\u0020]/.test(target)))
1938
+ const target = external ? requestedTarget : partUri(requestedTarget);
1939
+ if (external && (!target || /[\u0000-\u0020]/.test(target)))
1935
1940
  throw new TypeError("Invalid external relationship target.");
1936
1941
  const key = source.toLowerCase(), list = this.relationships.get(key) ?? new Map();
1937
- if (list.has(relationship.id))
1938
- throw new TypeError("Duplicate relationship id: " + relationship.id);
1939
- list.set(relationship.id, { ...relationship, target });
1942
+ if (list.has(id))
1943
+ throw new TypeError("Duplicate relationship id: " + id);
1944
+ list.set(id, { id, type, target, ...(external === undefined ? {} : { external }) });
1940
1945
  this.relationships.set(key, list);
1941
1946
  }
1942
1947
  setProperties(core = {}, app = {}) {
@@ -3747,7 +3752,8 @@ class Worksheet {
3747
3752
  });
3748
3753
  const originalCharacters = typeof value === "string" ? value.length : 0;
3749
3754
  let reservedCharacters = this.preserved || header || footer ? originalCharacters : undefined;
3750
- if (type === "string" && cleanXml(value, this.book.settings.invalidCharacterPolicy).length > 32767) {
3755
+ // Cleaning removes characters; ordinary strings cannot cross Excel's limit.
3756
+ if (type === "string" && originalCharacters > 32767 && cleanXml(value, this.book.settings.invalidCharacterPolicy).length > 32767) {
3751
3757
  const cell = col.letter + row;
3752
3758
  if (link || this.linkedCells.has(cell))
3753
3759
  throw new TypeError("A text-preservation cell cannot also have an external hyperlink.");
@@ -4967,12 +4973,15 @@ class Workbook {
4967
4973
  });
4968
4974
  }
4969
4975
  addPart(part) {
4976
+ this.assertOpen();
4977
+ const { uri, contentType, data, relationship } = part;
4978
+ const capturedRelationship = relationship && { id: relationship.id, type: relationship.type, source: relationship.source };
4970
4979
  this.assertOpen();
4971
4980
  // Reserve now so collisions and invalid names fail at the call site.
4972
- this.package.addPart(part);
4973
- if (part.relationship) {
4974
- const { source, ...rel } = part.relationship;
4975
- this.package.addRelationship(source ?? "/xl/workbook.xml", { ...rel, target: part.uri });
4981
+ this.package.addPart({ uri, contentType, data });
4982
+ if (capturedRelationship) {
4983
+ const { source, id, type } = capturedRelationship;
4984
+ this.package.addRelationship(source ?? "/xl/workbook.xml", { id, type, target: uri });
4976
4985
  }
4977
4986
  }
4978
4987
  /** Complete the archive and return counts. Does not close or dispose a caller-owned sink. */
@@ -8816,7 +8825,7 @@ class PdfPages {
8816
8825
  // Charge physical repeats without recapturing callbacks or making them semantic duplicates.
8817
8826
  for (const cell of header.cells)
8818
8827
  if (!this.bandCellBudget && this.paintedHeaderBudgetCells.has(cell.source ?? cell))
8819
- this.settings.budget.cell(cell.lines.map(line => line.text).join(""));
8828
+ this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters === undefined ? "" : cell.lines.map(line => line.text).join(""));
8820
8829
  const elements = this.tableStructure ? header.cells.map(cell => this.tableStructure.owner(cell.source ?? cell)) : undefined;
8821
8830
  const repeated = header.cells.map(cell => this.paintedHeaderCells.has(cell.source ?? cell));
8822
8831
  this.draw(header, 0, header.lines, elements, repeated);
@@ -8837,7 +8846,8 @@ class PdfPages {
8837
8846
  const { padding, fontSize } = this.settings, n = pdfNumber, height = lineCount * row.lineHeight + padding * 2;
8838
8847
  for (const [index, cell] of row.cells.entries()) {
8839
8848
  if (this.bandCellBudget)
8840
- this.settings.budget.cell((cell.height === undefined ? cell.lines.slice(firstLine, firstLine + lineCount) : cell.lines).map(line => line.text).join(""));
8849
+ this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters === undefined ? "" :
8850
+ (cell.height === undefined ? cell.lines.slice(firstLine, firstLine + lineCount) : cell.lines).map(line => line.text).join(""));
8841
8851
  const x = this.layout.lefts[cell.first], cellHeight = cell.height ?? height;
8842
8852
  if (cell.style.background)
8843
8853
  this.add(this.artifact("q " + this.rgb(cell.style.background) + " rg " + n(x) + " " + n(this.y - cellHeight) + " " + n(cell.width) + " " + n(cellHeight) + " re f Q\n"));
@@ -3821,7 +3821,7 @@ _modules.set("a66257a32f03d958aa57be4de9da7f80b708cebca26b5cc6404de0ee11bfe052",
3821
3821
  return _exports;
3822
3822
  })();
3823
3823
 
3824
- const _m34 = _modules.get("ce2a4bebe6ca61c77a6a974bd91981622b1f263d4e56e6b8466af41419151410") ?? (() => {
3824
+ const _m34 = _modules.get("a7fca40cb8c75af206111c90db36839b4648982beeb4179efda0ddd1ee366210") ?? (() => {
3825
3825
  const { OfficeIMOError } = _m4;
3826
3826
 
3827
3827
  const { checkAbort } = _m3;
@@ -4106,7 +4106,7 @@ class PdfPages {
4106
4106
  // Charge physical repeats without recapturing callbacks or making them semantic duplicates.
4107
4107
  for (const cell of header.cells)
4108
4108
  if (!this.bandCellBudget && this.paintedHeaderBudgetCells.has(cell.source ?? cell))
4109
- this.settings.budget.cell(cell.lines.map(line => line.text).join(""));
4109
+ this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters === undefined ? "" : cell.lines.map(line => line.text).join(""));
4110
4110
  const elements = this.tableStructure ? header.cells.map(cell => this.tableStructure.owner(cell.source ?? cell)) : undefined;
4111
4111
  const repeated = header.cells.map(cell => this.paintedHeaderCells.has(cell.source ?? cell));
4112
4112
  this.draw(header, 0, header.lines, elements, repeated);
@@ -4127,7 +4127,8 @@ class PdfPages {
4127
4127
  const { padding, fontSize } = this.settings, n = pdfNumber, height = lineCount * row.lineHeight + padding * 2;
4128
4128
  for (const [index, cell] of row.cells.entries()) {
4129
4129
  if (this.bandCellBudget)
4130
- this.settings.budget.cell((cell.height === undefined ? cell.lines.slice(firstLine, firstLine + lineCount) : cell.lines).map(line => line.text).join(""));
4130
+ this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters === undefined ? "" :
4131
+ (cell.height === undefined ? cell.lines.slice(firstLine, firstLine + lineCount) : cell.lines).map(line => line.text).join(""));
4131
4132
  const x = this.layout.lefts[cell.first], cellHeight = cell.height ?? height;
4132
4133
  if (cell.style.background)
4133
4134
  this.add(this.artifact("q " + this.rgb(cell.style.background) + " rg " + n(x) + " " + n(this.y - cellHeight) + " " + n(cell.width) + " " + n(cellHeight) + " re f Q\n"));
@@ -4512,7 +4513,7 @@ class PdfPages {
4512
4513
  }
4513
4514
  }
4514
4515
  const _exports = Object.freeze({ PdfPages: PdfPages });
4515
- _modules.set("ce2a4bebe6ca61c77a6a974bd91981622b1f263d4e56e6b8466af41419151410", _exports);
4516
+ _modules.set("a7fca40cb8c75af206111c90db36839b4648982beeb4179efda0ddd1ee366210", _exports);
4516
4517
  return _exports;
4517
4518
  })();
4518
4519
 
@@ -4955,7 +4956,7 @@ _modules.set("52c78ca6833cee7e5a96b657e2c00172d550176daf2c95e742692f8416977bea",
4955
4956
  return _exports;
4956
4957
  })();
4957
4958
 
4958
- const _m18 = _modules.get("6f13eca1cc6a3dee16e260ffb7ee38115cc2390084e9b156f0a90915fa5b18b9") ?? (() => {
4959
+ const _m18 = _modules.get("eb2c981b4568b33deca2137956ace31ea621b6a6287755ec234336d0a7c23cfc") ?? (() => {
4959
4960
  const { PdfObjects, unicodeHex } = _m19;
4960
4961
 
4961
4962
  const { PdfFontResources } = _m21;
@@ -5018,11 +5019,11 @@ class PdfWriteSession {
5018
5019
  }
5019
5020
  }
5020
5021
  const _exports = Object.freeze({ PdfWriteSession: PdfWriteSession });
5021
- _modules.set("6f13eca1cc6a3dee16e260ffb7ee38115cc2390084e9b156f0a90915fa5b18b9", _exports);
5022
+ _modules.set("eb2c981b4568b33deca2137956ace31ea621b6a6287755ec234336d0a7c23cfc", _exports);
5022
5023
  return _exports;
5023
5024
  })();
5024
5025
 
5025
- const _m1 = _modules.get("4a658d1639cc333dc8b174a84d2d80a7e20bec2f0e86409d00c3f77199e2eda2") ?? (() => {
5026
+ const _m1 = _modules.get("98eb735e985f873ed0ffc628449a20d1f3bb729a87b6d6b3099b6f308438fcb5") ?? (() => {
5026
5027
  const { BlobByteSink, withDestination } = _m2;
5027
5028
 
5028
5029
  const { beginTask, checkAbort, consumeRows, pause, taskYieldDue } = _m3;
@@ -5087,7 +5088,7 @@ async function writePdfTo(rows, destination, configuration) {
5087
5088
  });
5088
5089
  }
5089
5090
  const _exports = Object.freeze({ writePdf: writePdf, writePdfTo: writePdfTo });
5090
- _modules.set("4a658d1639cc333dc8b174a84d2d80a7e20bec2f0e86409d00c3f77199e2eda2", _exports);
5091
+ _modules.set("98eb735e985f873ed0ffc628449a20d1f3bb729a87b6d6b3099b6f308438fcb5", _exports);
5091
5092
  return _exports;
5092
5093
  })();
5093
5094
 
@@ -6566,7 +6567,7 @@ _modules.set("d43e573fd5bad18a7ec2d71752168c422c4f8fabbc51f1cef8e3ba389f298715",
6566
6567
  return _exports;
6567
6568
  })();
6568
6569
 
6569
- const _m45 = _modules.get("67060b0c8b6d3f6a6d9d53d41dd780ee99ffdae0ed0f90004ac675d382a80223") ?? (() => {
6570
+ const _m45 = _modules.get("f6c70e9a0bed09b5a1c61a662ad7d3faf731c911f574e2df285f669bd643b947") ?? (() => {
6570
6571
  const { BlobByteSink, withDestination } = _m2;
6571
6572
 
6572
6573
  const { OfficeIMOError } = _m4;
@@ -6856,11 +6857,11 @@ function captureTableOptions(options) {
6856
6857
  return { ...captured, ...(captured.wideTable === undefined ? {} : { wideTable: captureWideTable(captured.wideTable) }) };
6857
6858
  }
6858
6859
  const _exports = Object.freeze({ pdfTable: pdfTable, writePdfDocument: writePdfDocument, writePdfDocumentTo: writePdfDocumentTo });
6859
- _modules.set("67060b0c8b6d3f6a6d9d53d41dd780ee99ffdae0ed0f90004ac675d382a80223", _exports);
6860
+ _modules.set("f6c70e9a0bed09b5a1c61a662ad7d3faf731c911f574e2df285f669bd643b947", _exports);
6860
6861
  return _exports;
6861
6862
  })();
6862
6863
 
6863
- const _m43 = _modules.get("91d1ab43a388d5d7a78db095e27ed8b0f6d28004358cbf296ac818479c58c557") ?? (() => {
6864
+ const _m43 = _modules.get("879a0adeb3c62918085a071cbc37f221eb89a0fd73d56ebb5e9cfe0d49db8ee9") ?? (() => {
6864
6865
  const { assertGroupedReportSource } = _m44;
6865
6866
 
6866
6867
  const { BlobByteSink } = _m2;
@@ -6906,7 +6907,7 @@ async function writeGroupedPdfTo(report, destination, configuration) {
6906
6907
  return writePdfDocumentTo([pdfGroupedTable(report, tableOptions)], destination, documentOptions);
6907
6908
  }
6908
6909
  const _exports = Object.freeze({ pdfGroupedTable: _m54.pdfGroupedTable, writeGroupedPdf: writeGroupedPdf, writeGroupedPdfTo: writeGroupedPdfTo });
6909
- _modules.set("91d1ab43a388d5d7a78db095e27ed8b0f6d28004358cbf296ac818479c58c557", _exports);
6910
+ _modules.set("879a0adeb3c62918085a071cbc37f221eb89a0fd73d56ebb5e9cfe0d49db8ee9", _exports);
6910
6911
  return _exports;
6911
6912
  })();
6912
6913
 
@@ -6999,10 +7000,10 @@ _modules.set("81b3d47c02b7d8443b79e02b3cfb52032d6b73d9a3fb592b777ebe028ad0ef00",
6999
7000
  return _exports;
7000
7001
  })();
7001
7002
 
7002
- const _m0 = _modules.get("dcf6840f5eda4f8535cb4e226425587c2ae436c0eebfbd746aa0bc8a7acb6c4c") ?? (() => {
7003
+ const _m0 = _modules.get("2deab7b4ccb08bed297341ddb563d8fcf74277aff38c1dfc3d9edd61c0d98481") ?? (() => {
7003
7004
 
7004
7005
  const _exports = Object.freeze({ writePdf: _m1.writePdf, writePdfTo: _m1.writePdfTo, writeGroupedPdf: _m43.writeGroupedPdf, writeGroupedPdfTo: _m43.writeGroupedPdfTo, pdfGroupedTable: _m43.pdfGroupedTable, createGroupedReport: _m44.createGroupedReport, writePdfDocument: _m45.writePdfDocument, writePdfDocumentTo: _m45.writePdfDocumentTo, pdfTable: _m45.pdfTable, PdfFont: _m22.PdfFont, preflightPdfText: _m55.preflightPdfText, ExportCell: _m7.ExportCell, saveBlob: _m56.saveBlob });
7005
- _modules.set("dcf6840f5eda4f8535cb4e226425587c2ae436c0eebfbd746aa0bc8a7acb6c4c", _exports);
7006
+ _modules.set("2deab7b4ccb08bed297341ddb563d8fcf74277aff38c1dfc3d9edd61c0d98481", _exports);
7006
7007
  return _exports;
7007
7008
  })();
7008
7009
  Object.assign(officeimo, _m0, { core: _m56, pdf: _m0 });
@@ -4064,7 +4064,7 @@ class PdfPages {
4064
4064
  // Charge physical repeats without recapturing callbacks or making them semantic duplicates.
4065
4065
  for (const cell of header.cells)
4066
4066
  if (!this.bandCellBudget && this.paintedHeaderBudgetCells.has(cell.source ?? cell))
4067
- this.settings.budget.cell(cell.lines.map(line => line.text).join(""));
4067
+ this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters === undefined ? "" : cell.lines.map(line => line.text).join(""));
4068
4068
  const elements = this.tableStructure ? header.cells.map(cell => this.tableStructure.owner(cell.source ?? cell)) : undefined;
4069
4069
  const repeated = header.cells.map(cell => this.paintedHeaderCells.has(cell.source ?? cell));
4070
4070
  this.draw(header, 0, header.lines, elements, repeated);
@@ -4085,7 +4085,8 @@ class PdfPages {
4085
4085
  const { padding, fontSize } = this.settings, n = pdfNumber, height = lineCount * row.lineHeight + padding * 2;
4086
4086
  for (const [index, cell] of row.cells.entries()) {
4087
4087
  if (this.bandCellBudget)
4088
- this.settings.budget.cell((cell.height === undefined ? cell.lines.slice(firstLine, firstLine + lineCount) : cell.lines).map(line => line.text).join(""));
4088
+ this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters === undefined ? "" :
4089
+ (cell.height === undefined ? cell.lines.slice(firstLine, firstLine + lineCount) : cell.lines).map(line => line.text).join(""));
4089
4090
  const x = this.layout.lefts[cell.first], cellHeight = cell.height ?? height;
4090
4091
  if (cell.style.background)
4091
4092
  this.add(this.artifact("q " + this.rgb(cell.style.background) + " rg " + n(x) + " " + n(this.y - cellHeight) + " " + n(cell.width) + " " + n(cellHeight) + " re f Q\n"));