@evotecit/officeimo 0.1.1 → 0.1.3

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 (43) hide show
  1. package/README.md +43 -49
  2. package/bundles/officeimo-canopyx.js +1047 -193
  3. package/bundles/officeimo-canopyx.mjs +958 -111
  4. package/bundles/officeimo-csv.js +18 -15
  5. package/bundles/officeimo-csv.mjs +16 -13
  6. package/bundles/officeimo-datatables.js +249 -153
  7. package/bundles/officeimo-datatables.mjs +169 -73
  8. package/bundles/officeimo-pdf.js +151 -67
  9. package/bundles/officeimo-pdf.mjs +127 -43
  10. package/bundles/officeimo-xlsx.js +78 -69
  11. package/bundles/officeimo-xlsx.mjs +26 -17
  12. package/bundles/officeimo.js +249 -153
  13. package/bundles/officeimo.mjs +169 -73
  14. package/dist/csv/index.js +16 -13
  15. package/dist/integrations/canopyx/diagnostics.d.ts +3 -0
  16. package/dist/integrations/canopyx/diagnostics.js +17 -0
  17. package/dist/integrations/canopyx/grouping.d.ts +6 -0
  18. package/dist/integrations/canopyx/grouping.js +188 -0
  19. package/dist/integrations/canopyx/index.d.ts +2 -2
  20. package/dist/integrations/canopyx/index.js +72 -15
  21. package/dist/integrations/canopyx/metadata.d.ts +4 -0
  22. package/dist/integrations/canopyx/metadata.js +51 -0
  23. package/dist/integrations/canopyx/presentation.d.ts +8 -0
  24. package/dist/integrations/canopyx/presentation.js +40 -0
  25. package/dist/integrations/canopyx/rule-predicates.d.ts +3 -0
  26. package/dist/integrations/canopyx/rule-predicates.js +110 -0
  27. package/dist/integrations/canopyx/rules.d.ts +6 -0
  28. package/dist/integrations/canopyx/rules.js +176 -0
  29. package/dist/integrations/canopyx/source.js +24 -22
  30. package/dist/integrations/canopyx/types.d.ts +89 -8
  31. package/dist/integrations/canopyx/workbook.d.ts +6 -0
  32. package/dist/integrations/canopyx/workbook.js +52 -0
  33. package/dist/opc/index.js +14 -9
  34. package/dist/pdf/font-resources.js +33 -14
  35. package/dist/pdf/pages.js +63 -16
  36. package/dist/pdf/table-band-flow.js +7 -2
  37. package/dist/pdf/table-band-plan.js +9 -1
  38. package/dist/pdf/table-layout.js +6 -2
  39. package/dist/pdf/table-structure.js +9 -8
  40. package/dist/xlsx/workbook.js +7 -4
  41. package/dist/xlsx/worksheet.js +2 -1
  42. package/dist/xml/index.js +3 -3
  43. package/package.json +1 -1
package/README.md CHANGED
@@ -4,13 +4,13 @@
4
4
 
5
5
  ## Install
6
6
 
7
- Install the npm archive in your JavaScript application:
7
+ Install the package in your JavaScript application:
8
8
 
9
9
  ```sh
10
- npm install /path/to/evotecit-officeimo-0.1.0.tgz
10
+ npm install @evotecit/officeimo
11
11
  ```
12
12
 
13
- To produce the archive from this package's source directory:
13
+ For local source qualification, produce an archive from this package's source directory:
14
14
 
15
15
  ```sh
16
16
  npm ci
@@ -18,6 +18,8 @@ npm run build
18
18
  npm pack --pack-destination /path/to/local-packages
19
19
  ```
20
20
 
21
+ Install that archive in an isolated consumer with `npm install /path/to/local-packages/evotecit-officeimo-0.1.0.tgz`.
22
+
21
23
  `tsc` produces ES modules and declarations in `dist/`. The archive contains those files, portable bundles, this README and the MIT license. TypeScript is a development dependency; installing the archive as an application dependency installs no compiler or runtime packages.
22
24
 
23
25
  ## Export a table
@@ -61,6 +63,8 @@ saveBlob(await writeCsv(rows, { columns }), "sales.csv");
61
63
 
62
64
  The table writers accept synchronous iterables and async iterables. XLSX defaults to the sheet name `Data`, a bold header, filtering when a header is present, and width sampling of up to 100 rows clamped to 6–54 characters. `sheet` supplies the existing worksheet layout options. Workbook-local style indexes belong to the advanced `Workbook` API; portable `ExportCell` presentation and row/cell style patches work with the table helper.
63
65
 
66
+ CSV-only applications can import `writeCsv` or `writeCsvTo` from `@evotecit/officeimo/csv` to load the CSV module graph without the XLSX and PDF writers. The root entry remains useful when an application exports several formats.
67
+
64
68
  An `ExportCell` can carry an external link alongside its typed value, display text and presentation:
65
69
 
66
70
  ```typescript
@@ -165,67 +169,57 @@ The optional `@evotecit/officeimo/integrations/canopyx` entry consumes CanopyX's
165
169
  import { exportCanopy } from "@evotecit/officeimo/integrations/canopyx";
166
170
 
167
171
  const capture = grid.prepareExport({ scope: "filtered", values: "raw" });
168
- const reportOptions = {
169
- tones: {
170
- neutral: {},
171
- success: { background: "E2F0D9" },
172
- warning: { background: "FFF2CC", color: "9C6500" },
173
- danger: { background: "FFC7CE", color: "9C0006", bold: true }
172
+ const blob = await exportCanopy(capture, "xlsx", {
173
+ datetime: "preserve",
174
+ xlsx: { dateMode: "utc" },
175
+ about: true,
176
+ grouped: {
177
+ labelColumn: { header: "Region" },
178
+ subtotalLabel: group => `${group.label} total`,
179
+ grandTotalLabel: () => "Grand total"
174
180
  },
175
- columnOptions: {
176
- amount: { format: "#,##0.00", width: 18 },
177
- updated: { format: "yyyy-mm-dd hh:mm:ss.000", width: 42, wrapText: true }
178
- },
179
- xlsx: { sheet: { title: { text: "Inventory" }, table: {} } },
181
+ columnOptions: { updated: { format: "yyyy-mm-dd hh:mm:ss.000" } },
180
182
  limits: { maxRows: 250_000, maxCells: 5_000_000 }
181
- };
182
- const blob = await exportCanopy(capture, "xlsx", reportOptions);
183
+ });
183
184
  // Deliver the Blob through the host's download or storage policy.
184
185
  ```
185
186
 
186
- `exportCanopy(capture, format, options)` accepts `"xlsx"`, `"csv"` or `"pdf"`. `writeCanopyTo(capture, format, destination, options)` writes to a caller-owned sink or `WritableStream`; failed partial output remains caller-owned. Format options live in `xlsx`, `csv` and `pdf`, with common cancellation, limits and progress at the top level. Common limits override matching format limits. For Unicode PDF text, supply embedding-permitted TrueType fonts through `pdf.fonts`.
187
-
188
- `createCanopyExport` retains `type: "number"` for native numeric columns in a raw capture, so grouped metrics can use its columns directly. Display captures keep their rendered strings. Datetime metadata remains unforced because the preservation profile can intentionally produce exact ISO text rather than a `Date`.
189
-
190
- `columnOptions` is keyed by captured column ID. Settings for unselected columns are ignored, so one host format map can serve different visible/selected captures. `PdfFont` is exported from this entry as well as the PDF layer for constructing caller-supplied fonts.
187
+ `exportCanopy(capture, format, options)` accepts `"xlsx"`, `"csv"` or `"pdf"`. `writeCanopyTo(capture, format, destination, options)` writes to a caller-owned sink or `WritableStream`; failed partial output remains caller-owned. Format options live in `xlsx`, `csv` and `pdf`, with common cancellation, limits and progress at the top level. Common limits override matching format limits.
191
188
 
192
189
  | Captured contract | Output behavior |
193
190
  | --- | --- |
194
- | Column IDs, titles and order | Preserved without re-reading the viewport or UI settings |
195
- | `values: "raw"` | Numeric, boolean and null values remain typed; CSV retains original ISO datetime strings |
196
- | `values: "display"` | Captured display strings become literal exported values; CSV formula protection still applies |
197
- | Resolved text | PDF uses it; XLSX retains raw values and uses explicit number/date formats |
198
- | Semantic tones | Host-supplied portable styles; cell tone overrides overlapping row tone properties |
199
- | Absolute HTTP(S)/mailto links | Native XLSX relationships and PDF annotations; CSV remains ordinary text |
200
- | Datetime columns | XLSX defaults to typed dates at exact millisecond precision and literal ISO text for finer precision |
201
- | CSS pixel width | Never treated as an Excel character width; `columnOptions.width` supplies explicit character widths and `pdf.columnWidths` supplies points |
202
- | `recordCount` | Used for progress when known and checked against the actual enumeration; unknown counts remain unknown |
191
+ | Column IDs, titles and order | Preserved without reading the viewport or evaluating queries |
192
+ | Raw values and resolved text | XLSX keeps typed numbers and dates; PDF keeps captured text; raw CSV retains original ISO dates |
193
+ | Display values | Literal exported strings; CSV formula protection still applies |
194
+ | Fitted CSS pixel widths | XLSX uses a Calibri 11 profile at 96 DPI, a seven-pixel maximum digit and five-pixel cell padding, quantized to 1/256 character; PDF converts pixels to points at 72/96 |
195
+ | Leading left pins | XLSX freezes the contiguous leading pinned columns and any included header; the grouped label column is included in the physical pane offset |
196
+ | Numeric format intent | Fraction digits from 0 through 10 and literal prefixes/suffixes become invariant Excel formats; text such as `Usage %` does not change a raw value of 17 into a percentage |
197
+ | Canonical neutral tone | No override unless explicitly mapped in `tones`; cell styles override overlapping row-style properties |
198
+ | Safe resolved links | Native XLSX relationships and PDF annotations; a hidden source URL column is not required |
199
+ | `recordCount` | Checked against enumeration and used for detail progress, independently of dataset `total` and live `matched` |
200
+ | Captured grouping | Validated contiguous half-open ranges, typed group identities and declared numeric aggregates feed the existing grouped XLSX/PDF writers |
201
+ | No grouping snapshot | Flat records, even if the accepted query contains `groupBy` |
202
+ | `about: true` | XLSX adds an `About` worksheet with captured revision, scope, UTC time, counts, selected IDs and the actual accepted export query |
203
203
 
204
- Excel/PDF reject unsupported presentation diagnostics and unmapped tones by default. The reporting runtime supplies semantic captures. For an ordinary grid, custom renderer or CSS-only presentation, choose `unsupportedPresentation: "text"` to accept the captured text fallback and optionally observe each diagnostic with synchronous `onDiagnostic`. That fallback uses capture data; it does not scrape custom DOM renderer output. CSV defaults to text because the format has no visual styling; choose `"reject"` explicitly when diagnostics should stop it. No unbounded diagnostic list is retained.
204
+ The width profile provides reproducible conversion; it does not promise pixel-identical rendering in native Excel. `columnOptions[id].width` overrides the XLSX character width, and `pdf.columnWidths` overrides PDF point widths. Right and nonleading pins retain their column order and require an explicit text fallback diagnostic. `columnOptions` applies only to selected IDs; native `columnOptions[id].format` remains the explicit Excel-format override.
205
205
 
206
- `datetime: "typed"` requires exact millisecond precision; `"text"` keeps the original ISO value. The default `"preserve"` retains finer timestamps and dates outside Excel's 1900–9999 range as text rather than rounding or dropping them. An ISO value converted to a typed Excel date must carry an explicit time zone. XLSX defaults to the capture's UTC/local clock choice; `xlsx.dateMode` can override it. PDF displays the captured text, and CSV raw mode retains the original string and its zone.
206
+ XLSX maps the declared rule subset to editable data bars, two/three-stop color scales and row/cell highlights. The first matching tone wins within each row or cell target, and a cell tone overrides a row tone. Native cell visuals take precedence over row tints; their own declaration order is retained. Predicates support `and`/`or`, numeric `eq`/`ne`/`gt`/`ge`/`lt`/`le`, and null tests, within four levels and 64 nodes. Numeric operands use numbers, booleans or plain invariant numeric strings. Each comparison excludes null cells. Equality and inequality with boolean or numeric operands on text columns retain the raw value's type; string comparisons on text columns and separator/culture profiles are unsupported.
207
207
 
208
- `createCanopyExport(capture, format, options)` exposes frozen columns, `rowCount` and fresh `rows()` enumerations for applications using the format writers directly. It retains no whole-table body. Each enumeration passes its cancellation signal into CanopyX's page requests, and destination backpressure stops reading ahead. CanopyX's source may retain identity/cursor bookkeeping for revision and duplicate detection; streamed document output does not imply constant memory for that entire source.
208
+ Datetime rule filters require `datetime: "typed"` and the UTC XLSX clock. Operands use explicit-zone ISO timestamps at exact millisecond precision, or integer epoch milliseconds; the existing date writer converts them to native serials. Local, preserved-text and sub-millisecond predicate profiles report an unsupported diagnostic. Native numeric rules require numeric or null cells; datetime rules require ISO cells that the typed writer converts to native dates, or null. Numeric strings in numeric cells and numeric epoch values in datetime cells are unsupported native rule profiles and reject during enumeration, including text fallback. The flat source retains its raw values. Ordinary datetime output keeps its separate preservation policy below.
209
209
 
210
- Host export callbacks can use the already-captured enumeration:
210
+ `stopIfTrue` masks later highlight predicates across the whole row in the original declaration order. A captured rule sequence combining this behavior with native bars or scales is unsupported. Cell-tone and data-bar rules targeting the same column are also unsupported because the cell tone's fill depends on whether the bar resolves. Explicit text fallback omits either unsupported captured sequence and reports the loss. Native rule ranges cover only details, including with omitted or multilevel headers and in grouped reports. CSS variables and resolved `cell.format` properties are not parsed. The portable default rule palette is info `4472C4`, success `70AD47`, warning `FFC000` and danger `C00000`, with matching pale fills; explicit tone mappings override it.
211
211
 
212
- ```typescript
213
- import { writeCanopyTo } from "@evotecit/officeimo/integrations/canopyx";
214
- import type { GridHostOptions } from "@evotecit/canopyx/reporting";
212
+ PDF defaults captured fitted tables to a landscape fit profile. `pdf.wideTable` can select the existing horizontal bands and repeated identifier columns instead. Group headings, repeated column headings and continuation context use the existing grouped layout. Supply embedding-permitted TrueType fonts through `pdf.fonts` for Unicode, and a declared language through `pdf.tagged` for tagged reports. XLSX's native rule declarations do not render PDF bars or scales: PDF reports that loss and requires `unsupportedPresentation: "text"` to accept it. This option does not remove typed values, resolved text or valid links.
215
213
 
216
- const onExport: GridHostOptions["onExport"] = async ({ capture, format, signal, reportProgress }) => {
217
- if (format !== "xlsx" && format !== "csv" && format !== "pdf") {
218
- throw new Error("Unsupported export format");
219
- }
220
- const destination = await openDestination(format); // Host-owned delivery.
221
- await writeCanopyTo(capture, format, destination, {
222
- ...reportOptions, signal,
223
- onProgress: progress => reportProgress?.("generating", progress.rows)
224
- });
225
- };
226
- ```
214
+ Ordinary text-only grid/tree captures are accepted as flat output. Tree indentation does not create analytical groups. Genuine unsupported presentation diagnostics, unknown non-neutral tones and unsupported declarations reject by default in XLSX/PDF. Explicit `unsupportedPresentation: "text"` accepts their text fallback and reports each diagnostic through synchronous `onDiagnostic`. CSV defaults to text. No unbounded diagnostic list or whole-table body is retained.
215
+
216
+ Grouping requires a raw capture with an exact count and complete scope-specific ranges and aggregate values. Up to four levels and 1,000 groups are supported. One aggregate operation per numeric column maps `sum`, `count`, `average`, `minimum` and `maximum` to the canonical report owner; numeric `count` ignores nulls. Captured sums and averages are checked using Canopy's compensated accumulation and empty-input convention. Native formulas calculate their own caches, which can differ by floating-point rounding; an empty native sum is zero. Range and declared-total mismatches still reject the export. Grouped sheets own their summary rows and cannot also use a native table, arbitrary heading matrix or footer. Existing grouped label callbacks remain caller-owned; omitted labels use the English defaults `Group`, `<label> total` and `Grand total`. `xlsx.sheet.includeHeader: false` omits the data header and its default freeze; explicit settings remain subject to the worksheet contract.
217
+
218
+ `about` metadata uses the technical capture field names with `Field` and `Value` headings. `About` is reserved when this worksheet is requested, and the data sheet must have another name. Metadata is limited to 65,536 UTF-16 units in total. Known cell text is validated before detail enumeration; `xlsx.oversizedText: "preserve"` retains the workbook's bounded overflow policy for longer values. Metadata and generated summary rows consume output resource limits, but progress and result `rows` count source details only. Selected/all query metadata describes the accepted export query; the adapter does not reconstruct the original live filter from `matched`.
219
+
220
+ `datetime: "typed"` requires exact millisecond precision; `"text"` retains the original ISO value. The default `"preserve"` keeps finer timestamps and dates outside Excel's 1900–9999 range as text rather than rounding or dropping them. Typed Excel dates require an explicit time zone and default to the capture's UTC/local clock; `xlsx.dateMode` overrides it.
227
221
 
228
- This entry exports grid records. Collapsed visual groups do not remove their records. The adapter exports records in the captured order; use the [grouped report writers](#grouped-analytical-reports) when an explicitly group-ordered capture needs summary rows and Excel outlines. Workers consume a host-owned bounded capture/row bridge; a live CanopyX grid remains on the page. Pass the writer's signal to the same capture enumeration and release the bridge when the host cancels it.
222
+ `createCanopyExport(capture, format, options)` remains the flat source API: frozen columns, `rowCount` and fresh `rows()` enumerations. Full adapter writers add captured grouping, native rules and optional metadata. Each enumeration passes its cancellation signal into CanopyX's page requests. A live grid remains page-owned; worker hosts own and release their bounded capture/row bridge. CanopyX may retain identity/cursor bookkeeping, so streamed output does not imply constant memory for the source itself.
229
223
 
230
224
  ## PDF tables
231
225