@evotecit/officeimo 0.1.19 → 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 (102) hide show
  1. package/README.md +44 -10
  2. package/bundles/officeimo-canopyx-adapter.js +147 -65
  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 +134 -53
  6. package/bundles/officeimo-canopyx.js +554 -234
  7. package/bundles/officeimo-canopyx.min.js +1 -1
  8. package/bundles/officeimo-canopyx.min.mjs +1 -1
  9. package/bundles/officeimo-canopyx.mjs +477 -158
  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 +418 -180
  27. package/bundles/officeimo-datatables.min.js +1 -1
  28. package/bundles/officeimo-datatables.min.mjs +1 -1
  29. package/bundles/officeimo-datatables.mjs +350 -112
  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 +136 -59
  39. package/bundles/officeimo-xlsx.min.js +1 -1
  40. package/bundles/officeimo-xlsx.min.mjs +1 -1
  41. package/bundles/officeimo-xlsx.mjs +114 -37
  42. package/bundles/officeimo.js +416 -178
  43. package/bundles/officeimo.min.js +1 -1
  44. package/bundles/officeimo.min.mjs +1 -1
  45. package/bundles/officeimo.mjs +351 -113
  46. package/dist/core/progress.js +7 -2
  47. package/dist/index.d.ts +1 -1
  48. package/dist/integrations/canopyx/index.js +13 -4
  49. package/dist/integrations/canopyx/pdf-number.js +9 -6
  50. package/dist/integrations/canopyx/rule-predicates.d.ts +1 -1
  51. package/dist/integrations/canopyx/rule-predicates.js +2 -1
  52. package/dist/integrations/canopyx/rules.d.ts +1 -1
  53. package/dist/integrations/canopyx/rules.js +11 -13
  54. package/dist/integrations/canopyx/source.js +57 -7
  55. package/dist/integrations/canopyx/tones.d.ts +10 -0
  56. package/dist/integrations/canopyx/tones.js +12 -0
  57. package/dist/integrations/canopyx/types.d.ts +8 -1
  58. package/dist/integrations/chartforgex/capture.d.ts +31 -0
  59. package/dist/integrations/chartforgex/capture.js +103 -0
  60. package/dist/integrations/chartforgex/index.d.ts +13 -0
  61. package/dist/integrations/chartforgex/index.js +88 -0
  62. package/dist/integrations/chartforgex/svg-drawing.d.ts +5 -0
  63. package/dist/integrations/chartforgex/svg-drawing.js +775 -0
  64. package/dist/integrations/chartforgex/svg-geometry.d.ts +23 -0
  65. package/dist/integrations/chartforgex/svg-geometry.js +304 -0
  66. package/dist/integrations/chartforgex/svg-image.d.ts +9 -0
  67. package/dist/integrations/chartforgex/svg-image.js +46 -0
  68. package/dist/integrations/chartforgex/svg-markup.d.ts +10 -0
  69. package/dist/integrations/chartforgex/svg-markup.js +124 -0
  70. package/dist/integrations/chartforgex/svg-paint.d.ts +16 -0
  71. package/dist/integrations/chartforgex/svg-paint.js +146 -0
  72. package/dist/integrations/chartforgex/types.d.ts +77 -0
  73. package/dist/integrations/chartforgex/types.js +1 -0
  74. package/dist/integrations/chartforgex/winansi.d.ts +4 -0
  75. package/dist/integrations/chartforgex/winansi.js +48 -0
  76. package/dist/integrations/chartforgex/workbook.d.ts +12 -0
  77. package/dist/integrations/chartforgex/workbook.js +137 -0
  78. package/dist/pdf/document-drawings.d.ts +1 -1
  79. package/dist/pdf/document-drawings.js +91 -17
  80. package/dist/pdf/document-images.d.ts +7 -1
  81. package/dist/pdf/document-images.js +59 -24
  82. package/dist/pdf/document-types.d.ts +3 -1
  83. package/dist/pdf/document.d.ts +2 -2
  84. package/dist/pdf/document.js +3 -1
  85. package/dist/pdf/drawing-types.d.ts +37 -10
  86. package/dist/pdf/font-resources.d.ts +1 -1
  87. package/dist/pdf/font-resources.js +6 -3
  88. package/dist/pdf/index.d.ts +1 -1
  89. package/dist/pdf/pages.js +15 -0
  90. package/dist/pdf/png.d.ts +11 -2
  91. package/dist/pdf/png.js +50 -23
  92. package/dist/pdf/session.js +3 -2
  93. package/dist/pdf/settings.d.ts +2 -2
  94. package/dist/pdf/settings.js +7 -3
  95. package/dist/xlsx/options.js +2 -2
  96. package/dist/xlsx/portable.js +1 -1
  97. package/dist/xlsx/styles.js +28 -18
  98. package/dist/xlsx/types.d.ts +13 -1
  99. package/dist/xlsx/workbook.js +9 -1
  100. package/dist/xlsx/worksheet.d.ts +13 -1
  101. package/dist/xlsx/worksheet.js +65 -11
  102. package/package.json +9 -2
@@ -0,0 +1,88 @@
1
+ import { BlobByteSink, checkAbort } from "../../core/index.js";
2
+ import { captureFields } from "../../internal/capture.js";
3
+ import { captureCommonLimits, captureXlsxOptions, mergeAdapterLimits } from "../options.js";
4
+ import { writeXlsxTo } from "../../xlsx/index.js";
5
+ import { writePdfDocumentTo } from "../../pdf/index.js";
6
+ import { capturePdfLimits } from "../../pdf/settings.js";
7
+ import { prepareChart } from "./capture.js";
8
+ import { svgToPdfDrawing } from "./svg-drawing.js";
9
+ import { chartTable } from "./workbook.js";
10
+ import { winAnsiText } from "./winansi.js";
11
+ export { PdfFont } from "../../pdf/font.js";
12
+ const slots = ["regular", "bold", "italic", "boldItalic"];
13
+ const headerFill = "E7EDF5", headerBorder = Object.freeze({ bottom: Object.freeze({ style: "thin", color: "A6B4C8" }) });
14
+ export function chartForgeXDrawing(svg, optionsOrVersion = {}, imageOptions = {}) {
15
+ const options = optionsOrVersion === 2 ? imageOptions : optionsOrVersion;
16
+ const selected = captureFields(options, ["unsupported", "fonts", "winAnsi", "limits", "onDiagnostic"]);
17
+ return optionsOrVersion === 2 ? svgToPdfDrawing(svg, selected, 2) : svgToPdfDrawing(svg, selected, 1);
18
+ }
19
+ /** Write a ChartForgeX capture as a typed XLSX sheet of its series, or a PDF with its title, description and vector SVG. */
20
+ export async function writeChartForgeXTo(capture, format, destination, options = {}) {
21
+ const selected = captureFields(options, ["layout", "signal", "limits", "onProgress", "onDiagnostic", "unsupported", "xlsx", "pdf"]);
22
+ if (format !== "xlsx" && format !== "pdf")
23
+ throw new TypeError("ChartForgeX exports are xlsx or pdf.");
24
+ const { signal, onProgress, onDiagnostic, unsupported } = selected, limits = captureCommonLimits(selected.limits);
25
+ if (unsupported !== undefined && unsupported !== "skip" && unsupported !== "reject")
26
+ throw new TypeError("unsupported must be skip or reject.");
27
+ checkAbort(signal);
28
+ const chart = prepareChart(capture), stream = { ...(signal ? { signal } : {}), ...(onProgress ? { onProgress } : {}) };
29
+ if (format === "xlsx") {
30
+ const input = captureFields(selected.xlsx ?? {}, ["dateMode", "compression", "creator", "created", "modified", "sheetName"]);
31
+ const { sheetName = "Chart data", ...workbook } = input;
32
+ const xlsx = captureXlsxOptions(workbook), xlsxLimits = mergeAdapterLimits(xlsx.limits, limits);
33
+ const table = chartTable(chart, selected.layout, xlsxLimits);
34
+ return writeXlsxTo(table.rows, destination, { dateMode: "utc", ...xlsx, ...stream, columns: table.columns,
35
+ ...(chart.title === undefined ? {} : { title: chart.title }), ...(chart.description === undefined ? {} : { description: chart.description }),
36
+ limits: xlsxLimits,
37
+ sheet: { name: sheetName, headerFill, headerBorder, headerWrap: true, freezeHeader: true, autoFilter: true, boldHeader: true,
38
+ autoSize: { minWidth: 8, maxWidth: 48 }, ...(chart.title ? { title: { text: chart.title } } : {}) } });
39
+ }
40
+ if (chart.svg === undefined)
41
+ throw new TypeError("A ChartForgeX PDF needs the chart's SVG markup.");
42
+ const pdf = captureFields(selected.pdf ?? {}, ["pageSize", "orientation", "margins", "fonts", "tagged", "compression", "pageNumbers", "pageHeader",
43
+ "pageFooter", "fontSize", "limits"]);
44
+ const pdfLimits = mergeAdapterLimits(pdf.limits === undefined ? undefined : capturePdfLimits(pdf.limits), limits);
45
+ // Keep Unicode labels in the embedded regular face when an emphasis face is missing.
46
+ const faces = pdf.fonts === undefined ? undefined : captureFields(pdf.fonts, slots);
47
+ const available = faces ? slots.filter(slot => slot === "regular" || faces[slot] !== undefined) : slots;
48
+ const reported = new Set();
49
+ const report = (diagnostic) => {
50
+ if (reported.has(diagnostic.code))
51
+ return;
52
+ reported.add(diagnostic.code);
53
+ onDiagnostic?.(diagnostic);
54
+ };
55
+ const drawing = svgToPdfDrawing(chart.svg, { fonts: available, winAnsi: !faces?.regular, limits: pdfLimits, ...(unsupported ? { unsupported } : {}),
56
+ onDiagnostic: report }, 2, signal);
57
+ const paintedText = (text) => {
58
+ if (text === undefined)
59
+ return undefined;
60
+ if (faces?.regular)
61
+ return text.normalize("NFC");
62
+ return winAnsiText(text, () => {
63
+ if (unsupported === "reject")
64
+ throw new TypeError("Chart text needs an embedded font: supply pdf.fonts.regular.");
65
+ report({ code: "TEXT_SUBSTITUTED" });
66
+ });
67
+ };
68
+ const title = paintedText(chart.title), description = paintedText(chart.description);
69
+ // The figure alternative stays exact: it is Unicode metadata, not painted text.
70
+ const alternativeText = chart.description?.trim() ? chart.description : chart.title?.trim() ? chart.title : "Chart";
71
+ const blocks = [...(description ? [{ kind: "paragraph", text: description }] : []),
72
+ { kind: "drawing", drawing, alignment: "center", alternativeText }];
73
+ return writePdfDocumentTo(blocks, destination, { orientation: drawing.width > drawing.height ? "landscape" : "portrait", pageNumbers: false,
74
+ ...pdf, ...stream, ...(faces ? { fonts: faces } : {}), ...(title ? { title } : {}),
75
+ ...(chart.title ? { metadataTitle: chart.title } : {}), limits: pdfLimits });
76
+ }
77
+ /** Export a ChartForgeX capture as a Blob. No chart runtime, browser layout or server is involved. */
78
+ export async function exportChartForgeX(capture, format, options = {}) {
79
+ const sink = new BlobByteSink();
80
+ try {
81
+ await writeChartForgeXTo(capture, format, sink, options);
82
+ return sink.toBlob(format === "xlsx" ? "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" : "application/pdf");
83
+ }
84
+ catch (error) {
85
+ sink.discard();
86
+ throw error;
87
+ }
88
+ }
@@ -0,0 +1,5 @@
1
+ import type { PdfDrawing } from "../../pdf/drawing-types.js";
2
+ import type { ChartForgeXSvgOptions } from "./types.js";
3
+ /** Convert a resolved chart SVG into the PDF writer's portable drawing. Lengths become points (96 px = 72 pt). */
4
+ export declare function svgToPdfDrawing(svg: string, options: ChartForgeXSvgOptions, version: 1, signal?: AbortSignal): PdfDrawing<1>;
5
+ export declare function svgToPdfDrawing(svg: string, options: ChartForgeXSvgOptions, version: 2, signal?: AbortSignal): PdfDrawing<2>;