@evotecit/officeimo 0.1.4 → 0.1.9

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 (36) hide show
  1. package/README.md +18 -4
  2. package/bundles/officeimo-canopyx-adapter.js +1444 -0
  3. package/bundles/officeimo-canopyx-adapter.min.js +2 -0
  4. package/bundles/officeimo-canopyx-adapter.min.mjs +2 -0
  5. package/bundles/officeimo-canopyx-adapter.mjs +1426 -0
  6. package/bundles/officeimo-canopyx.js +108 -50
  7. package/bundles/officeimo-canopyx.min.js +2 -0
  8. package/bundles/officeimo-canopyx.min.mjs +2 -0
  9. package/bundles/officeimo-canopyx.mjs +96 -38
  10. package/bundles/officeimo-csv.min.js +2 -0
  11. package/bundles/officeimo-csv.min.mjs +2 -0
  12. package/bundles/officeimo-datatables-adapter.js +626 -0
  13. package/bundles/officeimo-datatables-adapter.min.js +2 -0
  14. package/bundles/officeimo-datatables-adapter.min.mjs +2 -0
  15. package/bundles/officeimo-datatables-adapter.mjs +617 -0
  16. package/bundles/officeimo-datatables.js +55 -10
  17. package/bundles/officeimo-datatables.min.js +2 -0
  18. package/bundles/officeimo-datatables.min.mjs +2 -0
  19. package/bundles/officeimo-datatables.mjs +51 -6
  20. package/bundles/officeimo-execution.min.js +2 -0
  21. package/bundles/officeimo-execution.min.mjs +2 -0
  22. package/bundles/officeimo-pdf.min.js +2 -0
  23. package/bundles/officeimo-pdf.min.mjs +2 -0
  24. package/bundles/officeimo-xlsx.min.js +2 -0
  25. package/bundles/officeimo-xlsx.min.mjs +2 -0
  26. package/bundles/officeimo.min.js +2 -0
  27. package/bundles/officeimo.min.mjs +2 -0
  28. package/bundles/officeimo.mjs +2 -1
  29. package/dist/integrations/canopyx/pdf-number.d.ts +1 -1
  30. package/dist/integrations/canopyx/pdf-number.js +89 -35
  31. package/dist/integrations/canopyx/pivot.d.ts +1 -1
  32. package/dist/integrations/canopyx/pivot.js +4 -0
  33. package/dist/integrations/canopyx/source.js +2 -2
  34. package/dist/integrations/canopyx/types.d.ts +1 -0
  35. package/dist/integrations/datatables/snapshot.js +51 -6
  36. package/package.json +6 -2
@@ -11698,7 +11698,7 @@ _modules.set("3d1862d8ab32171bca4b3ba5fe0bdcc073f67ce940aaff0ee735635893f86ee8",
11698
11698
  return _exports;
11699
11699
  })();
11700
11700
 
11701
- const _m97 = _modules.get("9914b45196123264d883d65b074b339b224324876baa3f157c0ddec6ad1f67f9") ?? (() => {
11701
+ const _m97 = _modules.get("5e0a9bdc75106268fcdff0cc6d7778080db216c7597514163f5fe5ff8ce93be1") ?? (() => {
11702
11702
  function presentation(input, axes) {
11703
11703
  const { axisKey, outlineLevel, summary, grandTotal, hidden, collapsed } = input;
11704
11704
  if (typeof axisKey !== "string" || !axes.has(axisKey) || !Number.isInteger(outlineLevel) || outlineLevel < 0 || outlineLevel > 7 ||
@@ -11761,13 +11761,17 @@ function canopyPivot(request) {
11761
11761
  }
11762
11762
  /** Per-cell formats preserve already-computed fractional percentages, ranks and differences. */
11763
11763
  function pivotNumberFormat(cell) {
11764
+ // Raw-value aggregates need no decimal declaration. Transformed values still
11765
+ // require the producer's frozen format (especially percent scaling).
11766
+ if (cell.mode === "value" && cell.numberFormat === undefined)
11767
+ return undefined;
11764
11768
  if (!["value", "percentGrandTotal", "percentParent", "percentColumn", "percentRow", "runningTotal", "rank", "difference", "percentChange"].includes(cell.mode ?? "") ||
11765
11769
  typeof cell.numberFormat !== "string" || !cell.numberFormat.length)
11766
11770
  throw new TypeError("Numeric pivot cells require a frozen mode and native numberFormat.");
11767
11771
  return cell.numberFormat;
11768
11772
  }
11769
11773
  const _exports = Object.freeze({ canopyPivot: canopyPivot, pivotNumberFormat: pivotNumberFormat });
11770
- _modules.set("9914b45196123264d883d65b074b339b224324876baa3f157c0ddec6ad1f67f9", _exports);
11774
+ _modules.set("5e0a9bdc75106268fcdff0cc6d7778080db216c7597514163f5fe5ff8ce93be1", _exports);
11771
11775
  return _exports;
11772
11776
  })();
11773
11777
 
@@ -11857,7 +11861,7 @@ _modules.set("040752afe195985e6f2e91f8c62fc13464c455fc44034b8cef4828851e05b83d",
11857
11861
  return _exports;
11858
11862
  })();
11859
11863
 
11860
- const _m96 = _modules.get("965483034a9b849ca9359aaecae287d9a4a8ea4d64379af0f665743df7baa403") ?? (() => {
11864
+ const _m96 = _modules.get("40e200b77947621ffacdfa2e1326760a78a52a7dfb6d0cbaa7c7a71607b119a2") ?? (() => {
11861
11865
  const { ExportCell, checkAbort, inputRows } = _m1;
11862
11866
 
11863
11867
  const { canopyPivot, pivotNumberFormat } = _m97;
@@ -11999,11 +12003,11 @@ function prepareCanopyExport(capture, format, options = {}) {
11999
12003
  if (format === "xlsx" && values === "raw" && spec.kind === "datetime" && typeof value === "string")
12000
12004
  value = datetime(value, dateMode, clock);
12001
12005
  const capturedFormat = pivot && spec.kind === "number" && cell.value !== null ? pivotNumberFormat(cell) : undefined;
12002
- const nativeFormat = capturedFormat === undefined ? undefined : spec.nativeFormatOverride === "" ? "General" : spec.nativeFormatOverride ?? capturedFormat;
12006
+ const nativeFormat = spec.nativeFormatOverride === "" ? "General" : spec.nativeFormatOverride ?? capturedFormat;
12003
12007
  const summary = format === "pdf" && pivot && (row.summary || row.grandTotal);
12004
12008
  const cellStyle = tone(cell.tone, row.id, spec.id), presentation = rowStyle || cellStyle || nativeFormat || summary ? {
12005
12009
  ...rowStyle, ...(summary ? { bold: true } : {}), ...cellStyle,
12006
- ...((format === "xlsx" || format === "pdf") && values === "raw" && nativeFormat !== undefined ? { numberFormat: nativeFormat } : {})
12010
+ ...((format === "pdf" || (format === "xlsx" && pivot)) && values === "raw" && nativeFormat !== undefined ? { numberFormat: nativeFormat } : {})
12007
12011
  } : undefined;
12008
12012
  // CSV has no presentation or link metadata: emit its selected scalar directly.
12009
12013
  // This also avoids a frozen wrapper for every cell in large CSV captures.
@@ -12027,7 +12031,7 @@ function prepareCanopyExport(capture, format, options = {}) {
12027
12031
  return Object.freeze({ source, request: Object.freeze({ ...request, columns: Object.freeze(specs.map(spec => spec.input)) }), report, tones, pivot });
12028
12032
  }
12029
12033
  const _exports = Object.freeze({ canopyIdentityValue: canopyIdentityValue, createCanopyExport: createCanopyExport, prepareCanopyExport: prepareCanopyExport });
12030
- _modules.set("965483034a9b849ca9359aaecae287d9a4a8ea4d64379af0f665743df7baa403", _exports);
12034
+ _modules.set("40e200b77947621ffacdfa2e1326760a78a52a7dfb6d0cbaa7c7a71607b119a2", _exports);
12031
12035
  return _exports;
12032
12036
  })();
12033
12037
 
@@ -12334,7 +12338,7 @@ _modules.set("eb8cf81d2a340cdb41301d59c667cef44f3ad1d6a19f717eb8137257b545115e",
12334
12338
  return _exports;
12335
12339
  })();
12336
12340
 
12337
- const _m102 = _modules.get("4aefd89b060b86e8e6e50a47a502f9ee7e64a2a1df334e0e9482f7ed30f0bee2") ?? (() => {
12341
+ const _m102 = _modules.get("97b7bd3037e8060328387470a7e471b6933f1fa062e9562c7908f8ea9a29044b") ?? (() => {
12338
12342
  const { createGroupedReport } = _m8;
12339
12343
 
12340
12344
  const { checkAbort } = _m4;
@@ -12540,7 +12544,7 @@ function canopyGrouped(source, request, options, limits, report, format) {
12540
12544
  ...(options.signal === undefined ? {} : { signal: options.signal }), ...(sourceLimits === undefined ? {} : { limits: sourceLimits }) });
12541
12545
  }
12542
12546
  const _exports = Object.freeze({ canopyGrouped: canopyGrouped });
12543
- _modules.set("4aefd89b060b86e8e6e50a47a502f9ee7e64a2a1df334e0e9482f7ed30f0bee2", _exports);
12547
+ _modules.set("97b7bd3037e8060328387470a7e471b6933f1fa062e9562c7908f8ea9a29044b", _exports);
12544
12548
  return _exports;
12545
12549
  })();
12546
12550
 
@@ -12664,78 +12668,132 @@ _modules.set("ccfefc97a47cc288f2c9a2eed33fff323570e35193cedbd876ebb3e8fb78a42e",
12664
12668
  return _exports;
12665
12669
  })();
12666
12670
 
12667
- const _m106 = _modules.get("0fb3a852d2d81b9921e07024df980295e7d9ad436f8f1640d90456dd4e36e2e0") ?? (() => {
12671
+ const _m106 = _modules.get("a0c020124a53cd7be15e3d53388b8393c981c3abc0f8d4aee76a442a2458457f") ?? (() => {
12668
12672
  const { ExportCell } = _m1;
12669
12673
 
12670
12674
  /** Fixed numeric formats affect PDF text, not the frozen numeric value used by other writers. */
12671
12675
  function numericProfile(format) {
12672
- if (format === undefined)
12673
- return undefined;
12674
- const match = /^((?:"[^"\\]*")*)(#,##)?0(?:\.([0#]+))?(%)?((?:"[^"\\]*")*)$/.exec(format);
12676
+ // No declared precision: whole values (including counts) stay whole.
12677
+ if (format === undefined || format === "General")
12678
+ return { minimumFractionDigits: 0, maximumFractionDigits: 20,
12679
+ percent: false, grouping: false, prefix: "", suffix: "" };
12680
+ const match = /^((?:"[^"]*"|\\["%])*)(#,##)?0(?:\.([0#]+))?(%)?((?:"[^"]*"|\\["%])*)$/.exec(format);
12675
12681
  if (!match || (match[3]?.length ?? 0) > 10)
12676
12682
  return undefined;
12683
+ const literal = (text) => text.replace(/"([^"]*)"|\\(["%])/g, (_, quoted, escaped) => quoted ?? escaped);
12677
12684
  return { minimumFractionDigits: (match[3]?.match(/0/g) ?? []).length, maximumFractionDigits: match[3]?.length ?? 0,
12678
- percent: !!match[4], grouping: !!match[2], prefix: match[1].replace(/"/g, ""), suffix: match[5].replace(/"/g, "") };
12679
- }
12680
- /** Preserve the captured decimal convention across a column, including whole percentages without a separator. */
12681
- function canopyPdfNumbers(sample, columns) {
12682
- const formatters = new Map();
12683
- const decimal = columns.map((column, index) => {
12684
- let fallback = ".";
12685
- for (const row of sample) {
12686
- const cell = row[index];
12687
- if (!(cell instanceof ExportCell) || typeof cell.value !== "number")
12688
- continue;
12689
- const profile = numericProfile(cell.presentation?.numberFormat ?? column.format);
12690
- if (!profile?.maximumFractionDigits)
12691
- continue;
12692
- const match = /([.,])(\d+)[^\d.,]*$/.exec(cell.text ?? "");
12693
- if (match && match[2].length <= profile.maximumFractionDigits) {
12694
- const numeric = /([+-]?\d[\d.,]*)[^\d]*$/.exec(cell.text ?? "")?.[1] ?? "";
12695
- const scaled = cell.value * (profile.percent ? 100 : 1);
12696
- if (/^[+-]?\d{1,3}(?:,\d{3})+$/.test(numeric) || /^[+-]?\d{1,3}(?:\.\d{3})+$/.test(numeric)) {
12697
- if (Math.abs(Number(numeric.replace(/[.,]/g, "")) - scaled) < .5) {
12685
+ percent: !!match[4], grouping: !!match[2], prefix: literal(match[1]), suffix: literal(match[5]) };
12686
+ }
12687
+ /** Separate declared literal units before recognizing the captured numeric token. U+2212 MINUS SIGN counts as a
12688
+ * sign like "-": the number is re-rendered with Intl's sign, so it never becomes a literal prefix. */
12689
+ function capturedNumber(text, profile) {
12690
+ let body = text, signBeforePrefix = false;
12691
+ if (profile.prefix && body.startsWith(profile.prefix))
12692
+ body = body.slice(profile.prefix.length);
12693
+ else if (profile.prefix && /^[+\-\u2212]/.test(body) && body.slice(1).startsWith(profile.prefix)) {
12694
+ signBeforePrefix = true;
12695
+ body = body[0] + body.slice(1 + profile.prefix.length);
12696
+ }
12697
+ if (profile.suffix && body.endsWith(profile.suffix))
12698
+ body = body.slice(0, -profile.suffix.length);
12699
+ const match = /^([^0-9+\-\u2212]*)([+\-\u2212]?\d[\d., \u00a0\u202f]*?)([^0-9]*)$/.exec(body);
12700
+ return match ? { prefix: profile.prefix || match[1], number: match[2], suffix: profile.suffix || match[3], signBeforePrefix } : undefined;
12701
+ }
12702
+ /** Distinguish a captured thousands mark from a decimal, using the raw value. */
12703
+ function groupedInteger(numeric, value) {
12704
+ if (!/^[+\-\u2212]?\d{1,3}(?:,\d{3})+$/.test(numeric) && !/^[+\-\u2212]?\d{1,3}(?:\.\d{3})+$/.test(numeric))
12705
+ return false;
12706
+ const grouped = Number(numeric.replace(/[.,]/g, "").replace("\u2212", "-"));
12707
+ return grouped !== 0 && Math.abs(grouped - value) <= .5;
12708
+ }
12709
+ /** Choose once for the document; percent text is the strongest captured culture signal. */
12710
+ function documentDecimal(sample, columns) {
12711
+ let fallback;
12712
+ for (const percent of [true, false]) {
12713
+ for (const row of sample)
12714
+ for (let index = 0; index < columns.length; index++) {
12715
+ const cell = row[index], column = columns[index];
12716
+ if (!(cell instanceof ExportCell) || typeof cell.value !== "number")
12717
+ continue;
12718
+ const profile = numericProfile(cell.presentation?.numberFormat ?? column.format);
12719
+ if (!profile)
12720
+ continue;
12721
+ const captured = capturedNumber(cell.text ?? "", profile);
12722
+ if (!captured)
12723
+ continue;
12724
+ // A literal percent label is a culture signal without requesting numeric scaling.
12725
+ const percentageSignal = profile.percent || profile.prefix.includes("%") || profile.suffix.includes("%") || (cell.text ?? "").includes("%");
12726
+ if (percentageSignal !== percent)
12727
+ continue;
12728
+ const match = /([.,])(\d+)$/.exec(captured.number.trimEnd());
12729
+ if (match) {
12730
+ const numeric = captured.number;
12731
+ // An override changes output scaling/precision, not the captured label.
12732
+ if (groupedInteger(numeric, cell.value) || (percentageSignal && groupedInteger(numeric, cell.value * 100))) {
12698
12733
  fallback = match[1] === "," ? "." : ",";
12699
12734
  continue;
12700
12735
  }
12736
+ return match[1];
12701
12737
  }
12702
- return match[1];
12703
12738
  }
12704
- }
12705
- return fallback;
12706
- });
12739
+ if (fallback !== undefined)
12740
+ return fallback;
12741
+ }
12742
+ return ".";
12743
+ }
12744
+ /** Apply one captured numeric convention to every supported numeric cell, including later streamed rows. */
12745
+ function canopyPdfNumbers(sample, columns) {
12746
+ const formatters = new Map(), decimal = documentDecimal(sample, columns);
12707
12747
  return row => row.map((value, index) => {
12708
12748
  if (!(value instanceof ExportCell) || typeof value.value !== "number")
12709
12749
  return value;
12710
- const profile = numericProfile(value.presentation?.numberFormat ?? columns[index].format);
12711
- if (!profile)
12750
+ const format = value.presentation?.numberFormat ?? columns[index].format;
12751
+ let profile = numericProfile(format);
12752
+ if (!profile || value.text === "")
12712
12753
  return value;
12713
- const captured = /^([^0-9+-]*)([+-]?\d[\d., \u00a0\u202f]*?)([^0-9]*)$/.exec(value.text ?? "");
12754
+ const captured = capturedNumber(value.text ?? "", profile);
12714
12755
  if (value.text && !captured)
12715
12756
  return value;
12716
- const key = [decimal[index], profile.minimumFractionDigits, profile.maximumFractionDigits, profile.grouping].join(":");
12757
+ // Undeclared formats normalize only plain numeric labels; a decoration
12758
+ // alone does not declare how the raw value was transformed for display.
12759
+ if ((format === undefined || format === "General") && captured && (captured.prefix.trim() || captured.suffix.trim()))
12760
+ return value;
12761
+ if (format === undefined || format === "General") {
12762
+ const digits = Number.isInteger(value.value) || (captured && groupedInteger(captured.number, value.value)) ? 0 :
12763
+ captured ? /[.,](\d+)$/.exec(captured.number.trimEnd())?.[1]?.length ?? 0 : undefined;
12764
+ // Retain a fractional value's captured precision, without padding an
12765
+ // undeclared whole aggregate merely because its display text was padded.
12766
+ if (digits !== undefined && digits <= 20)
12767
+ profile = { ...profile, minimumFractionDigits: digits, maximumFractionDigits: digits };
12768
+ }
12769
+ const key = [profile.minimumFractionDigits, profile.maximumFractionDigits, profile.grouping].join(":");
12717
12770
  let formatter = formatters.get(key);
12718
12771
  if (!formatter) {
12719
- formatter = new Intl.NumberFormat(decimal[index] === "," ? "de-DE" : "en-US", {
12772
+ formatter = new Intl.NumberFormat(decimal === "," ? "de-DE" : "en-US", {
12720
12773
  minimumFractionDigits: profile.minimumFractionDigits, maximumFractionDigits: profile.maximumFractionDigits, useGrouping: profile.grouping
12721
12774
  });
12722
12775
  formatters.set(key, formatter);
12723
12776
  }
12724
- const formatted = formatter.format(value.value * (profile.percent ? 100 : 1));
12725
- const prefix = profile.prefix || captured?.[1] || "";
12726
- let suffix = profile.suffix || captured?.[3] || "";
12777
+ let formatted = formatter.format(value.value * (profile.percent ? 100 : 1));
12778
+ if (captured?.number.startsWith("+") && !formatted.startsWith("-"))
12779
+ formatted = "+" + formatted;
12780
+ const leadingSign = captured?.signBeforePrefix ? /^[+-]/.exec(formatted)?.[0] ?? "" : "";
12781
+ if (leadingSign)
12782
+ formatted = formatted.slice(1);
12783
+ const prefix = captured?.prefix || profile.prefix;
12784
+ let suffix = captured?.suffix || profile.suffix;
12727
12785
  if (profile.percent && !profile.suffix)
12728
12786
  suffix = suffix.replace(/%/g, "");
12729
- return new ExportCell(value.value, { text: prefix + formatted + (profile.percent ? "%" : "") + suffix,
12787
+ return new ExportCell(value.value, { text: leadingSign + prefix + formatted + (profile.percent ? "%" : "") + suffix,
12730
12788
  ...(value.presentation ? { presentation: value.presentation } : {}), ...(value.link ? { link: value.link } : {}) });
12731
12789
  });
12732
12790
  }
12733
12791
  const _exports = Object.freeze({ canopyPdfNumbers: canopyPdfNumbers });
12734
- _modules.set("0fb3a852d2d81b9921e07024df980295e7d9ad436f8f1640d90456dd4e36e2e0", _exports);
12792
+ _modules.set("a0c020124a53cd7be15e3d53388b8393c981c3abc0f8d4aee76a442a2458457f", _exports);
12735
12793
  return _exports;
12736
12794
  })();
12737
12795
 
12738
- const _m105 = _modules.get("8cf0b0de5a9930ea2c50a459ce70b695b69483978ca9343cb2c22982845ff142") ?? (() => {
12796
+ const _m105 = _modules.get("dab3e04542b3619c5c937162b41068f7cb1c3021b4620987c0fb95d4bd98d8e2") ?? (() => {
12739
12797
  const { ExportCell, NotSupportedError, OfficeIMOError } = _m1;
12740
12798
 
12741
12799
  const { inputRows, checkAbort, pause, taskYieldDue } = _m4;
@@ -12840,11 +12898,11 @@ async function withCanopyPdfLayout(source, captured, options, write) {
12840
12898
  }
12841
12899
  }
12842
12900
  const _exports = Object.freeze({ withCanopyPdfLayout: withCanopyPdfLayout });
12843
- _modules.set("8cf0b0de5a9930ea2c50a459ce70b695b69483978ca9343cb2c22982845ff142", _exports);
12901
+ _modules.set("dab3e04542b3619c5c937162b41068f7cb1c3021b4620987c0fb95d4bd98d8e2", _exports);
12844
12902
  return _exports;
12845
12903
  })();
12846
12904
 
12847
- const _m0 = _modules.get("8a4acb328f0d0bd6089df8bcce4099064ea408bdef1e20d13fdbe59b083c76c9") ?? (() => {
12905
+ const _m0 = _modules.get("1f0435c9bc6e437b986c72df8ed33a7636aea9e87db25a98bdb2a48a43985e5d") ?? (() => {
12848
12906
  const { BlobByteSink, ExportCell } = _m1;
12849
12907
 
12850
12908
  const { notifyProgress } = _m14;
@@ -12983,7 +13041,7 @@ async function exportCanopy(capture, format, options = {}) {
12983
13041
  }
12984
13042
  }
12985
13043
  const _exports = Object.freeze({ createCanopyExport: _m96.createCanopyExport, ExportCell: _m5.ExportCell, PdfFont: _m64.PdfFont, writeCanopyTo: writeCanopyTo, exportCanopy: exportCanopy });
12986
- _modules.set("8a4acb328f0d0bd6089df8bcce4099064ea408bdef1e20d13fdbe59b083c76c9", _exports);
13044
+ _modules.set("1f0435c9bc6e437b986c72df8ed33a7636aea9e87db25a98bdb2a48a43985e5d", _exports);
12987
13045
  return _exports;
12988
13046
  })();
12989
13047
  Object.assign(officeimo, _m0);