js.documents 1.54.2 → 1.54.4
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.
- package/README.md +15 -15
- package/dist/index.cjs +98 -98
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
## Why
|
|
10
10
|
|
|
11
|
-
Converting docx/pptx to PDF and back is usually solved by wrapping a mature third-party PDF library. This package takes the opposite approach for the PDF side of the equation: pdf-codec hand-writes every layer of the PDF format — the object model, the cross-reference table, the content-stream operators, standard-font metrics, the parser's cross-reference/object-stream resolution and content-stream interpreter — against the ISO 32000-1 specification, rather than wrapping one. That is a genuinely large undertaking, and it comes with an honest trade-off spelled out in [Fidelity](#fidelity) below and in pdf-codec's own README: this is not, and does not attempt to be, as robust against adversarial or badly malformed real-world PDFs as a library with 15+ years of hardening. What it buys instead is a dependency-free, fully auditable PDF implementation, with `documents.js`'s own supply-chain surface staying limited to `ooxml.js`, `odf.js`, `document-
|
|
11
|
+
Converting docx/pptx to PDF and back is usually solved by wrapping a mature third-party PDF library. This package takes the opposite approach for the PDF side of the equation: pdf-codec hand-writes every layer of the PDF format — the object model, the cross-reference table, the content-stream operators, standard-font metrics, the parser's cross-reference/object-stream resolution and content-stream interpreter — against the ISO 32000-1 specification, rather than wrapping one. That is a genuinely large undertaking, and it comes with an honest trade-off spelled out in [Fidelity](#fidelity) below and in pdf-codec's own README: this is not, and does not attempt to be, as robust against adversarial or badly malformed real-world PDFs as a library with 15+ years of hardening. What it buys instead is a dependency-free, fully auditable PDF implementation, with `documents.js`'s own supply-chain surface staying limited to `ooxml.js`, `odf.js`, `document-schema.js`, `pdf-codec`, and `fflate`.
|
|
12
12
|
|
|
13
13
|
The read-and-write editor exists because `ooxml.js`'s own typed readers are a deliberate one-way, lossy projection — reading is fine, but there is no way to add a paragraph, style a run, or insert an image and get a valid docx/pptx back out. `documents.js`'s editors are live views directly over the `XmlElement` objects inside a decoded `Package`: a mutation edits that tree in place, and everything you don't touch round-trips byte-faithful, because it never stopped being the original XML.
|
|
14
14
|
|
|
@@ -81,7 +81,7 @@ const { document, diagnostics } = await converter.convert(
|
|
|
81
81
|
|
|
82
82
|
`DocumentFormat` includes `xlsx` alongside `docx`/`pptx`/`odt`/`odp`/`ods`/`odg`/`pdf` — not because xlsx has a PDF conversion of its own, but because `createLocalDocumentConverter`'s `{ source, targetFormat }` contract already generalises past "targetFormat always means pdf": `odt`→`docx`, `docx`→`odt`, `odp`→`pptx`, `pptx`→`odp`, `ods`→`xlsx`, and `xlsx`→`ods` are six further entries in the same `conversions` list, routed to the six bridge functions above with an empty `diagnostics` array.
|
|
83
83
|
|
|
84
|
-
Getting back the intermediate `DocumentPackage` (content + layout, from `document-
|
|
84
|
+
Getting back the intermediate `DocumentPackage` (content + layout, from `document-schema.js`) a conversion built internally, instead of only the target bytes — every ergonomic conversion function above accepts an `onDocument` callback for this, and the port surfaces the same value as `package` on its `ConversionResult`:
|
|
85
85
|
|
|
86
86
|
```ts
|
|
87
87
|
import { docxToPdf } from 'documents.js';
|
|
@@ -263,7 +263,7 @@ import { odtToPdf } from 'documents.js';
|
|
|
263
263
|
const pdfBytes = odtToPdf(odtBytes);
|
|
264
264
|
```
|
|
265
265
|
|
|
266
|
-
This works by threading the formula's own raw MathML alongside the `ContentDocument` `readOdtContent`/`readOdpContent` already produce (see `OdtContentResult`/`OdpContentResult`'s own `formulas` field) rather than through `ContentDocument` itself, since document-
|
|
266
|
+
This works by threading the formula's own raw MathML alongside the `ContentDocument` `readOdtContent`/`readOdpContent` already produce (see `OdtContentResult`/`OdpContentResult`'s own `formulas` field) rather than through `ContentDocument` itself, since document-schema.js's own `ContentEmbeddedObject.document` field has no MathML-shaped variant to carry it in:
|
|
267
267
|
|
|
268
268
|
```ts
|
|
269
269
|
import { convertWordprocessingToLayout, readOdtContent } from 'documents.js';
|
|
@@ -288,22 +288,22 @@ const { box, diagnostics } = layoutFormula(mathml, { metrics: metricsAt(12), siz
|
|
|
288
288
|
|
|
289
289
|
The package is layered from generic primitives outward to the two conversion directions:
|
|
290
290
|
|
|
291
|
-
- **`src/model/`** — thin, documents.js-specific additions on top of the sibling [`document-
|
|
291
|
+
- **`src/model/`** — thin, documents.js-specific additions on top of the sibling [`document-schema.js`](https://github.com/ExaDev/document-schema.js) package, which now owns the two pivot models themselves: `LayoutDocument` (the PDF-side pivot: pages of positioned text/image/rect/line/ellipse/path/link items, PDF-native coordinates and units — `LayoutPath` is a general vector path, one or more subpaths of line/cubic segments sharing one fill/fillRule/stroke, the item kind `writePath`, pdf-codec's own content-write.ts, turns into PDF `m`/`l`/`c`/`h` content-stream operators) and `ContentDocument` (the semantic pivot: a discriminated union of `wordprocessing`, `presentation`, `spreadsheet`, and `drawing` variants sharing paragraph/run/table/image building blocks, `drawing`'s own `ContentVector` vocabulary — rect/ellipse/line/path — being the vector-primitive counterpart to the shared `ContentShape`) are both imported, not defined here — `document-schema.js` exists specifically so `ooxml.js`, `odf.js`, `pdf-codec`, and `documents.js` share one schema instead of each maintaining an independent, drift-prone copy. What remains local: `bytes.ts` (magic-byte-validated `Uint8Array` schemas for docx/pptx/PDF, plus `Odt`/`Ods`/`Odp`/`OdgBytesSchema`, which check the package's actual declared media type against `odf.js`'s `ODF_MEDIA_TYPES` table rather than only the generic ZIP signature the OOXML schemas are limited to), `units.ts` (OOXML EMU/twip/point/half-point conversions), and `geometry.ts`/`color.ts`/`style.ts`, each now mostly a thin re-export of `document-schema.js`'s `Box`/`Margins`/`PageSize`/`Color`/`Alignment`/`LayoutFont` — the one genuinely PDF-specific piece each still adds locally is `geometry.ts`'s `flipY` (the top-left/y-down ↔ bottom-left/y-up space conversion between OOXML/ODF and PDF coordinates); `LayoutFont`/`DEFAULT_LAYOUT_FONT` moved to `document-schema.js` too (since `LayoutText`, part of the pivot, needs the field), leaving only the standard-14 font *resolution* logic that consumes it (pdf-codec's own `fonts.ts`/`font-read.ts`) as PDF-specific, now external to this package entirely. `content.ts` holds the one genuinely local piece of the `ContentDocument` envelope (`CONTENT_FORMAT_VERSION`), and `formula.ts` defines `EmbeddedFormula` — the side-channel formula shape threaded alongside a `ContentDocument` rather than inside it (see the Usage section above), with a type-only dependency on `MathMlNode` from `mathml` (see the dependency-direction note below). `PositionedFormula` (the equivalent side-channel shape for a `LayoutDocument`) now lives in `pdf-codec` itself, which redeclares its own structurally-identical copy of it and of `MathBox` — see [Architecture](#architecture) below and pdf-codec's own README for why a real `MathBox` this package's `layoutFormula` produces crosses that package boundary with zero cast or wrapper.
|
|
292
292
|
- **The hand-written PDF codec, and the generic byte/image primitives it depends on, are now the external [`pdf-codec`](https://github.com/ExaDev/pdf-codec) dependency** rather than local `src/pdf/`/`src/bytes/`/`src/image/` directories — see that package's own README for its internal architecture (the object model, cross-reference handling, content-stream interpreter, standard-14 font resolution, the embedded math-font writer, and the generic byte/PNG/JPEG primitives it exports for a layout engine like this package's own `src/layout/` to build on).
|
|
293
293
|
- **`src/ports/`** — the injectable ports this package's own "identity, clock, and observability are first-class ports" convention calls for: `abort.ts`'s `throwIfAborted` (a signal-check helper called at row loop boundaries in `src/layout/sheets.ts`/`reconstruct.ts` — the codebase has no `await` point for cancellation to hook into implicitly, since the local pipeline is synchronous end to end, so every long-running loop checks explicitly instead; `pdf-codec` needed the identical helper for its own page loops and now carries its own independently-duplicated copy rather than depending on this package for it) and `clock.ts`'s `ClockPort`/`systemClock`/`fixedClock` (an injectable "now", for deterministic PDF output in tests). `ClockPort` is exported and tested in isolation but not yet consumed by any conversion path — `writePdf`'s own `/CreationDate`/`/ModDate` come directly from `LayoutDocument.metadata.createdIso`/`modifiedIso` when present, with nothing in pdf-codec's own write path calling `new Date()` to fill in a missing one, so there is currently no real call site for `ClockPort` to inject into. A real, tracked gap in wiring, not a documentation gap: a future default-timestamp write path should consume it rather than reaching for `new Date()` directly.
|
|
294
294
|
- **`src/xml/`** and **`src/opc/`** — parent-aware XML query/mutation and OPC package mechanics (relationship IDs, content-type entries, atomic media-part insertion) built over `ooxml.js`'s `Package`/`XmlNode`, needed because `ooxml.js`'s own XML nodes have no parent pointers and `ooxml.js` never writes new parts into an existing package. `src/xml/odf-text.ts` is the one ODF-specific module in this directory: `encodeOdfText`/`decodeOdfText` convert between a plain string and ODF's own whitespace-run element sequence (`text:s` for a run of two or more literal spaces, `text:tab`, `text:line-break` — all three occupy real character positions in an ODF paragraph but are ELEMENTS, not text-node characters, unlike docx's flat `w:t` run text) — see the Gotchas entry below on why every ODF text getter in this codebase must call `decodeOdfText`, never `ooxml.js`'s own plain-text-node `textContent()`.
|
|
295
295
|
- **`src/odf-package/`** — the ODF-side counterpart to `src/opc/`: `manifest.ts` is a pure re-export of `odf.js`'s own manifest read/build/write/sync/validate functions (`odf.js` already owns `META-INF/manifest.xml` end to end — reading, deriving, writing, syncing, and validating it — unlike `ooxml.js`'s read-only OPC relationship handling), and `media.ts`'s `addImageMedia` inserts a binary image part under `Pictures/` (the real-world LibreOffice/OASIS convention, confirmed against `odf.js`'s own round-trip/manifest fixtures) and re-syncs the manifest via that same `syncManifest` re-export — one step simpler than OOXML's own `addImageMedia` (`src/opc/media.ts`) since ODF references a media part directly by its package path (`xlink:href`) rather than through a relationship-ID indirection. `OdpSlide.addImage`/`OdpShape` (`src/edit/odp/image.ts`) is `addImageMedia`'s real caller — and, through `src/edit/odg/*`'s wholesale reuse of `OdpShape` (see the `src/edit/` entry below), `OdgPage.addImage` too; `src/odb/read.ts` also reuses `manifest.ts`'s `readManifest` directly, to check `database/script`'s own manifest-declared media type before treating it as an HSQLDB script part.
|
|
296
296
|
- **`src/edit/`** — the read-and-write editable model: live-view classes (`DocxEditor`/`DocxParagraph`/`DocxRun`/`DocxTable`, `PptxEditor`/`PptxSlide`/`PptxShape`, `OdtEditor`/`OdtParagraph`/`OdtRun`/`OdtTable`/`OdtList`, `OdpEditor`/`OdpSlide`/`OdpShape`, `OdsEditor`/`OdsSheet`/`OdsCell`, `OdgEditor`/`OdgPage`/`OdgBoxVector`/`OdgLineVector`/`OdgPathVector`) wrapping the actual `XmlElement` objects inside a decoded `Package`, plus `buildDocxPackage`/`buildPptxPackage`/`buildOdtPackage`/`buildOdpPackage`/`buildOdsPackage`/`buildOdgPackage` bridging a `ContentDocument` to a fresh package built entirely through those same primitives — `pdfToOdt`/`pdfToOdp`/`pdfToOds`/`pdfToOdg` each call the matching one. `src/edit/odp/*` reuses `src/edit/odt/*`'s own paragraph/run/list/style-interning classes WHOLESALE rather than reimplementing them for presentations: a `draw:frame`'s `draw:text-box` holds the identical `text:p`/`text:span` content model `office:text` does, interned into the identical `content.xml` `office:automatic-styles` registry (`src/edit/odt/props.ts`'s `applyStyleChange`) — `OdpShape.appendParagraph`/`.paragraphs()`/`.addList()` return real `OdtParagraph`/`OdtList` instances, not odp-specific lookalikes. The genuinely new odp-specific work is `draw:page`/`draw:frame` mechanics (a slide is a `draw:page`, a shape's geometry is explicit `svg:x`/`svg:y`/`svg:width`/`svg:height` rather than pptx's placeholder-inheritance-heavy model) and rotation: `OdpShape.rotationDeg` is a genuine `draw:transform` setter built on `odf.js`'s own `applyOdfTransform`/`resolveOdfShapeGeometry` (`typed/shared/transform.ts`) — the write-side inverse of the exact function odf.js's own reader uses — unlike `PptxShape`, which has no rotation setter yet (see Gotchas below). `src/edit/ods/*` has no docx/pptx/odt/odp analogue to reuse for its core concern (cell addressing) but still reuses `src/edit/odt/*`'s style interning and `src/edit/odt/content.ts`'s `populateParagraph` for cell text content — `src/edit/ods/address.ts` is the write-side counterpart to `odf.js`'s own read-side `table:number-*-repeated`-aware cursor: setting a distant cell's value splits the covering repeated run in place at that one position rather than materialising every cell in between, exactly mirroring the read-side hazard `odf.js`'s own `typed/shared/a1.ts` already solved. `src/edit/ods/print-settings.ts` is the newest addition: `OdsSheet.printSettings`'s own getter/setter, mining `styles.xml`'s `office:automatic-styles`/`office:master-styles` directly (a part no other `src/edit/ods/*` module needed to touch before) rather than `content.xml` alone, reusing `odf.js`'s own exported `findStyleElement`/`resolvePageLayoutProperties`/`parsePageSize`/`parseMargins` for the read half and `src/edit/odt/automatic-styles.ts`'s `nextStyleName` (already generic over which `office:automatic-styles` element it scans) for the write half's own fresh-name minting. `src/edit/odg/*` reuses `OdpShape`/`buildTextBoxFrame`/`insertImageFrameMedia` WHOLESALE for `draw:frame` text/image content (a drawing page's `draw:frame` content model and geometry resolution — rotation included — are byte-for-byte identical to a presentation's, both resolved through `odf.js`'s own shared `readDrawFrame`), so there is no separate `OdgShape` class at all; the genuinely new work is the vector-primitive classes (no rotation, a per-kind attribute vocabulary: `svg:x`/`y`/`width`/`height` for rect/ellipse/path, `svg:x1`/`y1`/`x2`/`y2` for a line) and their own fill/stroke, which needed a small, self-contained graphic-family style writer (`src/edit/odg/style.ts`) since `odf.js`'s own `StyleRegistry` recognises `'graphic'` as a style family but its `StylePropertiesSchema` only ever models text/paragraph formatting — it has no fill/stroke fields and never emits a `style:graphic-properties` element. A path vector's own `svg:d` is generated by `src/edit/odg/svg-path.ts`, the write-side inverse of `odf.js`'s own `typed/shared/path.ts` parser — always absolute, always space-separated commands, anchoring `svg:viewBox` at `"0 0 {widthPt} {heightPt}"` so the written numbers are the exact source `ContentPathPoint` values with no rescaling arithmetic either way (see Gotchas below for the cross-check against that exact parser).
|
|
297
|
-
- **`src/mathml/`** — a MathML presentation-layer typesetting engine, comparable in scope to pdf-codec's own standard-14 text-layout half — genuinely self-contained: no import from `model`, `pdf-codec`, or `odf.js` at all (not even `document-
|
|
297
|
+
- **`src/mathml/`** — a MathML presentation-layer typesetting engine, comparable in scope to pdf-codec's own standard-14 text-layout half — genuinely self-contained: no import from `model`, `pdf-codec`, or `odf.js` at all (not even `document-schema.js`), matching `src/layout/`'s own "pure conversion algorithm" isolation one tier further down. `nodes.ts` defines `MathMlNode`/`MathMlElement` as a local, structurally-compatible mirror of `odf.js`'s own `XmlNode` (the same "mirror the shape, don't import the package" trick `src/interop.test.ts` already proves holds between `ooxml.js` and `odf.js`), so `odf.js`'s `readOdfFormula`'s real return value type-checks against it with zero cast. `variant.ts` maps `mathvariant` to the Unicode Mathematical Alphanumeric Symbols block (Latin/Greek/digits, including the block's own well-known Letterlike-Symbols hole-fillers — italic small h, eleven Script/Fraktur/Double-struck capitals — generated directly from Unicode's own `UnicodeData.txt`, not transcribed by hand). `operators.ts` is a deliberately bounded operator dictionary (lspace/rspace/stretchy/largeop/movablelimits per operator), not the MathML3 spec's own multi-thousand-entry table. `layout.ts` is the recursive box-model engine itself (`mrow`/`mi`/`mn`/`mo`/`mtext`/`mspace`/`msub`/`msup`/`msubsup`/`munder`/`mover`/`munderover`/`mfrac`/`msqrt`/`mroot`/`mtable`/`mtr`/`mtd`/`mstyle`/`semantics`, plus a text-content fallback with a diagnostic for anything else), driven entirely by the injected `MathFontMetrics` port (`metrics.ts`) rather than any font-parsing code of its own — pdf-codec's own `math-font.ts` is the real implementation, consumed only through this structural port, never imported directly. `compose.ts`/`radical.ts`/`length.ts` are its own small geometry helpers (baseline-offset box placement, a hand-drawn hooked radical sign built from line segments rather than a bare glyph substitute, MathML length-unit parsing). Output is a flat `MathBox` (positioned glyph runs, rules, and strokes, box-local top-left/y-down coordinates), passed with zero cast into pdf-codec's `writePdf({ formulas })` — see pdf-codec's own README for the structural-typing mechanism that makes this work across a package boundary with no shared class or branded type.
|
|
298
298
|
- **`src/ooxml/`** — resolves a `Package` into a `ContentDocument`: `docx/read.ts` and `pptx/read.ts` are now thin adapters over `ooxml.js`'s own `readDocx`/`readPptx`, wrapping their `{ metadata, sections }`/`{ metadata, slides }` result into `ContentDocument`'s `wordprocessing`/`presentation` shape. The docx style cascade (`docDefaults` → named-style `basedOn` chains → paragraph-mark run properties → character styles → direct formatting), the pptx placeholder → layout → master → theme inheritance cascade, and DrawingML geometry/colour resolution all now live upstream in `ooxml.js` itself, not in this package.
|
|
299
299
|
- **`src/odf/`** — the ODF-side counterpart to `src/ooxml/`, resolving an `odf.js` `Package` into a `ContentDocument`: `odt/read.ts`'s `readOdtContent` is a thin adapter over `odf.js`'s own `readOdt`, wrapping its `{ metadata, sections }` result into the identical `wordprocessing` shape `readDocxContent` produces — the concrete proof that odt and docx genuinely share one pivot and one layout engine. `odp/read.ts`'s `readOdpContent` is the same adapter over `odf.js`'s own `readOdp`, wrapping `{ metadata, slides }` into the identical `presentation` shape `readPptxContent` produces. `ods/read.ts`'s `readOdsContent` wraps `odf.js`'s `readOds`'s `{ metadata, sheets }` into the `spreadsheet` `ContentDocument` variant, and `odg/read.ts`'s `readOdgContent` wraps `odf.js`'s `readOdg`'s `{ metadata, pages }` into the `drawing` variant — `odg` still has no OOXML-side sibling adapter at all (no drawing-equivalent OOXML format this package reads); `ods` now does, `ooxml.js`'s own `readXlsxContent`/`buildXlsxPackage`, consumed directly by `src/convert/convert.ts`'s `odsToXlsx`/`xlsxToOds` bridge (see below) but deliberately not re-exported from this package's own public surface, mirroring the `readDocx`/`readPptx` non-re-export choice above. `buildOdtPackage`/`buildOdpPackage`/`buildOdsPackage`/`buildOdgPackage` (`src/edit/{odt,odp,ods,odg}/content.ts`) each bridge a `ContentDocument` back to a fresh package built on that format's own live-view editor, closing the PDF → odt/odp/ods/odg direction (`pdfToOdt`/`pdfToOdp`/`pdfToOds`/`pdfToOdg` each call the matching one) — see the `pdfToOds` gotcha below for `buildOdsPackage`'s own printSettings-writing addition. `formula/read.ts`'s `readOdfFormulaContent`/`readOdfEmbeddedFormula` are the same thin-adapter pattern over `odf.js`'s own `readOdfFormula`, for a standalone `.odf` and an embedded sub-object respectively (the latter reading the sub-object's own `content.xml`/`meta.xml` directly out of the outer package's flat `Package.parts` record, no separate unzip step needed); `formula/detect.ts`'s `detectEmbeddedFormulaFrames` is genuinely new work with no `odf.js`-side equivalent at all — `odf.js`'s own `readDrawFrameContent` doesn't recognise a `draw:object`-bearing `draw:frame` yet, so `odt/read.ts` and `odp/read.ts` each run this as a second pass over the same package's raw `content.xml` to find and inject a formula's own placeholder block (see the Gotchas entry below for the exact scope and positioning caveats this second pass carries).
|
|
300
300
|
- **`src/layout/`** — the pure conversion algorithms, importing `model`, (for formula placement) `mathml`, and — for line-wrapping/pagination itself — several primitives sourced from the external `pdf-codec` dependency: the injected `TextMeasurer` port and `wrapRunsToWidth` (pdf-codec's own `measure.ts`/`text-layout.ts`, since deciding where a line breaks needs to know how wide text renders in a PDF standard-14 font, regardless of which format the content came from), `loadMathFont` (pdf-codec's own `math-font.ts`, for formula placement), pdf-codec's `matrix.ts`'s `rotatePointAboutCenter` (`slides.ts`'s own shape-rotation placement), and pdf-codec's `afm-widths.ts`/`fonts.ts`'s `STANDARD_METRICS`/`resolveStandardFont` (`reconstruct.ts`'s own font-matching when reconstructing from a `LayoutDocument`) — this package's one dependency on external font/text-measurement primitives, since text layout is inherently coupled to the one font model (pdf-codec's own standard-14 resolution) every conversion direction ultimately renders through: `engine.ts` (`ContentDocument` wordprocessing → `LayoutDocument`: flow, line-breaking, pagination — fed identically by docx- and odt-sourced content; also returns `WordprocessingLayoutResult.formulas`, every embedded formula block it laid out via `src/mathml`'s `layoutFormula`, positioned in PDF page space — see the Gotchas entry below on why a formula can't become an ordinary `LayoutItem`), `slides.ts` (`ContentDocument` presentation → `LayoutDocument`: direct EMU-to-point placement, no pagination needed — fed identically by pptx- and odp-sourced content; also exports `convertShape`, the single-`ContentShape`-to-`LayoutItem[]` conversion `drawing.ts` below reuses verbatim, now optionally formula-aware via its own trailing `formulaContext` parameter so `drawing.ts`'s existing call site keeps compiling unchanged), `sheets.ts` (`ContentDocument` spreadsheet → `LayoutDocument`: resolve the print range, build cumulative column/row offsets skipping hidden ones, reserve header/repeat-row-column space, resolve an explicit or non-iterative fit-to-page scale, partition into column/row bands honouring manual breaks with the same "an oversized item gets its own band and overflows rather than looping" guarantee `engine.ts`'s `ensureRoom` documents, emit pages in `downThenOver`/`overThenDown` order, then per page paint backgrounds/gridlines/headers/cell text with default alignment by value kind and `###`/spill-then-truncate overflow handling — the first layout algorithm in this package that accepts an `AbortSignal`, since a 50k-cell sheet needs cancellation where a docx/pptx page count never did), `drawing.ts` (`ContentDocument` drawing → `LayoutDocument`: one `ContentDrawPage` per PDF page, direct placement like `slides.ts`, with one new emission path — a `ContentVector` `rect`/`ellipse`/`line` maps onto the pre-existing `LayoutRect`/`LayoutEllipse`/`LayoutLine` kinds, and a `path` vector's local, viewBox-relative subpath points are resolved through the vector's own frame offset then a single page-space flip into a `LayoutPath` value; vectors paint before shapes, a documented, bounded choice — see this module's own top-of-file note — since `ContentDrawPageSchema` keeps `shapes` and `vectors` as two independently paint-ordered arrays with no field recording their relative order when the two genuinely overlap), `reconstruct.ts` (`LayoutDocument` → `ContentDocument`: `reconstructWordprocessing`/`reconstructPresentation` do baseline-proximity line clustering, then paragraph/text-block clustering from geometry — PDF has no semantic paragraph or shape structure to recover, only positioned glyphs; `reconstructDrawing` does no clustering at all, since a drawing has no such structure to infer in the first place — every `LayoutItem` maps close to 1:1 back onto a `ContentVector` `rect`/`ellipse`/`line`/`path` or a `ContentShape`, in the exact z-order it was painted, bucketed into `ContentDrawPageSchema`'s own two independently-ordered `shapes`/`vectors` arrays the same way `drawing.ts` produced them; `reconstructSpreadsheet` tries a real gridline lattice first — scanning the page's `LayoutLine`/stroked-single-segment-`LayoutPath` items for enough parallel horizontal and vertical lines at consistent positions to call it a printed grid, using those line positions directly as cell boundaries when found — and falls back to text-position clustering otherwise, reusing this same module's `clusterIntoLines` for rows and a parallel recurring-x-position generalisation of `clusterIntoParagraphs`'s own `dominantLeftX` for columns; every recovered cell is a bare string, column widths/row heights are genuinely measured from whichever geometry was used, and no print range/scale/repeat-rows/repeat-columns/manual-breaks are ever inferred).
|
|
301
|
-
- **`src/hsqldb/`** — the `.odb` decoders, in two tiers over two genuinely different on-disk storage shapes a HSQLDB table can use. `script.ts` (Tier 1): a small, bounded HSQLDB TEXT-script-format (`hsqldb.script_format=0`) DDL/DML text parser, not a database engine — `parseHsqldbScript(bytes)` extracts `CREATE TABLE`'s own column names/types and `INSERT INTO`'s own row values into `HsqldbTable[]`, tolerating (skipping) every other statement kind real HSQLDB output emits that this package has no use for (users, grants, sequences, indexes, views), and throwing `HsqldbScriptParseError` for anything matching neither list. `rowformat.ts`/`cache.ts` (Tier 2): a CACHED table's own binary row-store format — LibreOffice's embedded-HSQLDB default (`database.isStoredFileAccess()` switches `hsqldb.default_table_type` to `cached` specifically for storage-backed access, confirmed against the decompiled engine source) — a CACHED table's DDL still lives in `database/script` as ordinary TEXT (Tier 1 parses it unmodified) but its row *data* lives in a separate binary page-cache file, `database/data`. `rowformat.ts` decodes one column's own binary field at a time (`HsqldbDataCursor`, a big-endian `DataView` cursor; `readHsqldbColumnValue`, one branch per SQL type code); `cache.ts` walks a table's own AVL row-position tree (`readHsqldbCachedTableRows`, following each row's persisted `iLeft`/`iRight` child positions recursively, needing no key-comparison or free-list logic at all — a deleted row is already unlinked from the tree before its space can be reused, so a traversal rooted at the tree's current root only ever reaches live rows), rooted at the position `parseHsqldbIndexRoots` recovers from each table's own `SET TABLE ... INDEX'...'` script line, using `parseHsqldbProperties`'s reading of `database/properties` (cache-file scale, engine version) to resolve byte offsets; `decodeHsqldbCachedTables` is the orchestration `src/odb/read.ts` calls, splicing real rows into every table with an index-root line and leaving every other table (MEMORY/TEXT, or a genuinely empty CACHED table — HSQLDB never writes an index-root line for one) exactly as Tier 1 already produced it. Both tiers mirror pdf-codec's own isolation discipline: `script.ts` imports only `document-
|
|
301
|
+
- **`src/hsqldb/`** — the `.odb` decoders, in two tiers over two genuinely different on-disk storage shapes a HSQLDB table can use. `script.ts` (Tier 1): a small, bounded HSQLDB TEXT-script-format (`hsqldb.script_format=0`) DDL/DML text parser, not a database engine — `parseHsqldbScript(bytes)` extracts `CREATE TABLE`'s own column names/types and `INSERT INTO`'s own row values into `HsqldbTable[]`, tolerating (skipping) every other statement kind real HSQLDB output emits that this package has no use for (users, grants, sequences, indexes, views), and throwing `HsqldbScriptParseError` for anything matching neither list. `rowformat.ts`/`cache.ts` (Tier 2): a CACHED table's own binary row-store format — LibreOffice's embedded-HSQLDB default (`database.isStoredFileAccess()` switches `hsqldb.default_table_type` to `cached` specifically for storage-backed access, confirmed against the decompiled engine source) — a CACHED table's DDL still lives in `database/script` as ordinary TEXT (Tier 1 parses it unmodified) but its row *data* lives in a separate binary page-cache file, `database/data`. `rowformat.ts` decodes one column's own binary field at a time (`HsqldbDataCursor`, a big-endian `DataView` cursor; `readHsqldbColumnValue`, one branch per SQL type code); `cache.ts` walks a table's own AVL row-position tree (`readHsqldbCachedTableRows`, following each row's persisted `iLeft`/`iRight` child positions recursively, needing no key-comparison or free-list logic at all — a deleted row is already unlinked from the tree before its space can be reused, so a traversal rooted at the tree's current root only ever reaches live rows), rooted at the position `parseHsqldbIndexRoots` recovers from each table's own `SET TABLE ... INDEX'...'` script line, using `parseHsqldbProperties`'s reading of `database/properties` (cache-file scale, engine version) to resolve byte offsets; `decodeHsqldbCachedTables` is the orchestration `src/odb/read.ts` calls, splicing real rows into every table with an index-root line and leaving every other table (MEMORY/TEXT, or a genuinely empty CACHED table — HSQLDB never writes an index-root line for one) exactly as Tier 1 already produced it. Both tiers mirror pdf-codec's own isolation discipline: `script.ts` imports only `document-schema.js`'s `ContentCellValue` type; `rowformat.ts` imports the same plus nothing else; `cache.ts` imports only those two and `script.ts`'s own types — no odf.js `Package`/`XmlElement` knowledge anywhere in `src/hsqldb/` — the caller is responsible for handing every function its raw bytes/text already extracted from a real `.odb` package. `HsqldbTable`/`HsqldbColumn` are also the shared pivot shape `src/firebird/`'s own Tier 3 decoder below produces. See Gotchas for Tier 2's own version scope and verification account.
|
|
302
302
|
- **`src/firebird/`** — the Tier 3 `.odb` decoder: a reader for Firebird's own gbak logical-backup format (`database/firebird.fbk`), the artifact a real Firebird-embedded `.odb` actually contains — see the README's own Gotchas entry below for the empirical finding that this is NOT a raw on-disk ODS page dump, the single largest correction this subsystem's own design went through. `reader.ts` holds the two distinct byte-level primitives the format mixes (`FirebirdBackupReader`, the generic little-endian tag+length+value attribute framing every `rec_*`/`att_*` record uses, plus its own RLE/"PackBits"-style decompression for `att_data_data` when the backup is compressed; `XdrReader`, the big-endian, 4-byte-aligned RFC 1832 XDR decoding a row's own field values use once compression is peeled off). `blr-types.ts` maps a field's own BLR type opcode (`att_field_type`) onto its physical storage representation, sourced directly from Firebird's own `blr.h`/`align.h`. `date.ts` restates Firebird's own MJD-epoch DATE and 1/10000-second-tick TIME encoding, taken from `NoThrowTimeStamp.cpp`. `schema.ts` walks `rec_relation`/`rec_field` (column definitions gbak has ALREADY resolved from the live engine's system tables at backup time — see the Gotchas entry). `data.ts` walks `rec_relation_data`/`rec_data` (a relation's own rows, addressed by name), decoding each row's XDR-and-possibly-RLE-compressed field-value sequence into `ContentCellValue[]`. `backup.ts`'s `readFirebirdBackup` is the top-level entry point, producing the identical `HsqldbTable[]` shape `parseHsqldbScript` does.
|
|
303
303
|
- **`src/odb/`** — the decoder-selection and pivot-mapping layer sitting between odf.js's `.odb` support and `src/hsqldb/`/`src/firebird/`: `read.ts`'s `readOdbTables(pkg)` calls odf.js's own `readOdbInventory` to classify the package's connection (throwing `OdbNoEmbeddedDataSourceError` for an external-only datasource) and its embedded engine, then routes a genuine HSQLDB TEXT script to `parseHsqldbScript`, then — whenever a `database/data` part is present — hands Tier 1's own result to `src/hsqldb/cache.ts`'s `decodeHsqldbCachedTables` to splice in every CACHED table's real rows (a `.odb` with no CACHED table at all, the common case, never even looks for `database/data`, leaving Tier 1's own result untouched), or routes a Firebird `database/firebird.fbk` part to `readFirebirdBackup` — throwing `OdbUnsupportedFormatError` (naming HSQLDB's own whole-script binary/compressed serialisation explicitly, the one embedded shape still unimplemented) for anything none of these cover. `spreadsheet.ts`'s `odbTablesToSpreadsheetDocument` maps `HsqldbTable[]` onto the same `ContentSheet`-based `ContentDocument` spreadsheet variant `readOdsContent`/`buildOdsPackage` already produce and consume, feeding `odbToXlsx`'s call into `buildXlsxPackage` directly. `csv.ts`'s `buildOdbTableCsv` writes exactly one named table as CSV bytes, with no `ContentSheet`/xlsx machinery involved at all, throwing `OdbTableNotSpecifiedError`/`OdbTableNotFoundError` (naming every available table) when the caller's own `table` option doesn't resolve to exactly one table.
|
|
304
|
-
- **`src/convert/`** — `convert.ts` (the twelve PDF-pivot round-trip ergonomic wrappers, a dedicated "Six cross-format bridges" section: `odtToDocx`/`docxToOdt`, `odpToPptx`/`pptxToOdp`, `odsToXlsx`/`xlsxToOds`, each a direct `readXContent` → `buildYPackage` composition bypassing PDF entirely — see [Fidelity](#fidelity) — `odmToPdf`, the one further conversion shaped around a caller-supplied `resolveSubDocument` callback rather than being purely bytes-in/bytes-out, since a `.odm` master document's own chapters are external references odf.js's `readOdm` never inlines — see Gotchas — `odbToXlsx`/`odbToCsv`, thin compositions over `readOdbTables` and `src/odb/`'s own pivot/CSV mapping, and `odfToPdf`, a standalone `.odf` formula document → PDF via `readOdfFormulaContent` → `src/mathml`'s `layoutFormula` → `writePdf`'s own formula-aware option, with no reverse `pdfToOdf` at all), `codec.ts` (`docxPdfCodec`/`pptxPdfCodec`/`odtPdfCodec`/`odpPdfCodec`/`odsPdfCodec`/`odgPdfCodec` plus `odtDocxCodec`/`odpPptxCodec`/`odsXlsxCodec`, a `z.codec()` pair over each — `odmToPdf`/`odbToXlsx`/`odbToCsv`/`odfToPdf` have no codec of their own, for the same fixed-signature/one-directional reasons each has no port entry, or a one-way port entry, below), `port.ts`/`local.ts` (the swappable `DocumentConverter` contract and its synchronous local implementation, covering `docx`/`pptx`/`odt`/`odp`/`ods`/`odg`/`odf` → `pdf`, `pdf` → `docx`/`pptx`/`odt`/`odp`/`ods`/`odg`, and the six bridge pairs — `DocumentFormat` includes `xlsx` for exactly this reason, even though xlsx has no PDF conversion of its own; `odm` and `odb` are deliberately not `DocumentFormat` members, since neither `odmToPdf` nor `odbToXlsx`/`odbToCsv` is wired into this port at all; `odf` IS a member, but with only the one `odf → pdf` entry — no `pdf → odf`). Every conversion function that builds a `ContentDocument`/`LayoutDocument` internally (the twelve PDF-pivot conversions and the six bridges; `odfToPdf` accepts but never invokes it) also accepts an `onDocument` callback, and `ConversionResult` carries the same value through the port as an optional `package` field — the full `DocumentPackage` (content + layout, from `document-
|
|
304
|
+
- **`src/convert/`** — `convert.ts` (the twelve PDF-pivot round-trip ergonomic wrappers, a dedicated "Six cross-format bridges" section: `odtToDocx`/`docxToOdt`, `odpToPptx`/`pptxToOdp`, `odsToXlsx`/`xlsxToOds`, each a direct `readXContent` → `buildYPackage` composition bypassing PDF entirely — see [Fidelity](#fidelity) — `odmToPdf`, the one further conversion shaped around a caller-supplied `resolveSubDocument` callback rather than being purely bytes-in/bytes-out, since a `.odm` master document's own chapters are external references odf.js's `readOdm` never inlines — see Gotchas — `odbToXlsx`/`odbToCsv`, thin compositions over `readOdbTables` and `src/odb/`'s own pivot/CSV mapping, and `odfToPdf`, a standalone `.odf` formula document → PDF via `readOdfFormulaContent` → `src/mathml`'s `layoutFormula` → `writePdf`'s own formula-aware option, with no reverse `pdfToOdf` at all), `codec.ts` (`docxPdfCodec`/`pptxPdfCodec`/`odtPdfCodec`/`odpPdfCodec`/`odsPdfCodec`/`odgPdfCodec` plus `odtDocxCodec`/`odpPptxCodec`/`odsXlsxCodec`, a `z.codec()` pair over each — `odmToPdf`/`odbToXlsx`/`odbToCsv`/`odfToPdf` have no codec of their own, for the same fixed-signature/one-directional reasons each has no port entry, or a one-way port entry, below), `port.ts`/`local.ts` (the swappable `DocumentConverter` contract and its synchronous local implementation, covering `docx`/`pptx`/`odt`/`odp`/`ods`/`odg`/`odf` → `pdf`, `pdf` → `docx`/`pptx`/`odt`/`odp`/`ods`/`odg`, and the six bridge pairs — `DocumentFormat` includes `xlsx` for exactly this reason, even though xlsx has no PDF conversion of its own; `odm` and `odb` are deliberately not `DocumentFormat` members, since neither `odmToPdf` nor `odbToXlsx`/`odbToCsv` is wired into this port at all; `odf` IS a member, but with only the one `odf → pdf` entry — no `pdf → odf`). Every conversion function that builds a `ContentDocument`/`LayoutDocument` internally (the twelve PDF-pivot conversions and the six bridges; `odfToPdf` accepts but never invokes it) also accepts an `onDocument` callback, and `ConversionResult` carries the same value through the port as an optional `package` field — the full `DocumentPackage` (content + layout, from `document-schema.js`) that conversion built, not just its target bytes.
|
|
305
305
|
|
|
306
|
-
Dependency direction among this package's own local modules is downward and checkable, with one deliberate exception (`layout`, noted below): `mathml`/`ports` import nothing local (`mathml` is fully self-contained — no dependency on `model`, `document-
|
|
306
|
+
Dependency direction among this package's own local modules is downward and checkable, with one deliberate exception (`layout`, noted below): `mathml`/`ports` import nothing local (`mathml` is fully self-contained — no dependency on `model`, `document-schema.js`, or any ODF package, since it consumes only its own locally-mirrored `MathMlNode` input and its own injected `MathFontMetrics` port); `model` imports nothing local at the value level, but `formula.ts` carries one type-only import of `MathMlNode` from `mathml` (erased entirely at runtime, and not a cycle — `mathml` itself imports nothing from `model`); `ooxml/*` imports `model` only (now a thin adapter over `ooxml.js`'s own `readDocx`/`readPptx` — see the `src/ooxml/` entry above — with no `xml/*` dependency of its own left; no PDF knowledge either); `odf/*` imports `model` only (no PDF knowledge, no `xml/*` — `odf.js` already owns its own XML query helpers); `hsqldb` imports `document-schema.js` only (no odf.js knowledge); `firebird` imports `document-schema.js` (its own row/schema decoding, `ContentCellValue` only) and `hsqldb` (`HsqldbTable`/`HsqldbColumn`, a type-only import for its own output shape — the deliberate pivot-sharing point between Tier 1 and Tier 3) but no odf.js knowledge at all; `layout` imports `model`+`mathml`+`ports`, plus, genuinely upward and outward, several text-measurement/font-metric/matrix primitives from the external `pdf-codec` dependency (`measure.ts`/`text-layout.ts`/`math-font.ts`/`matrix.ts`/`afm-widths.ts`/`fonts.ts` — see the `src/layout/` entry above for exactly which); `odf-package` imports odf.js only (no local dependency, mirroring `opc`'s relationship to `ooxml.js`); `odb` imports `hsqldb`+`firebird`+`model`+`odf-package`+odf.js only; `convert` composes everything else, including `pdf-codec` directly for `readPdf`/`writePdf`/`loadMathFont`. Beyond this package's own local modules, four external dependencies each own a distinct concern with no overlap: `ooxml.js` (docx/pptx/xlsx ⇄ JSON), `odf.js` (odt/ods/odp/odg ⇄ JSON), `document-schema.js` (the shared `ContentDocument`/`LayoutDocument` schemas), and `pdf-codec` (the PDF codec itself, plus the text-layout/font-resolution/byte/image primitives built on it). No `PdfObject`/`PdfDict`/`PdfStream` type appears anywhere in this package at all — that type is pdf-codec's own internal concern now, never exposed across the package boundary.
|
|
307
307
|
|
|
308
308
|
## Build, test, and lint
|
|
309
309
|
|
|
@@ -335,7 +335,7 @@ To run a single test file: `pnpm vitest run src/path/to/file.test.ts`.
|
|
|
335
335
|
- **`ooxml.js`'s typed readers (`readDocx`/`readPptx`) are now the actual basis for conversion** — `readDocxContent`/`readPptxContent` are thin wrappers around them, not an independent walk of `word/document.xml`/`ppt/slides/slideN.xml`. They are still deliberately not re-exported from this package's own public surface: `readDocx`/`readPptx` also carry `comments`/`footnotes`/`headers`/`footers` (docx) that `ContentDocument` doesn't model, so exposing both the wrapper and the thing it wraps would invite a caller to reach for the wrong one rather than genuinely offering two competing models.
|
|
336
336
|
- **ODF paragraph/heading text content is not a plain string the way a docx run's `w:t` is, and reading it wrong fails silently.** Real whitespace collapses HTML-style when an ODF consumer renders XML text-node content, so the format represents a run of two or more literal spaces as `<text:s text:c="N"/>` (an ELEMENT, not a text node), a tab as `<text:tab/>`, and a hard line break as `<text:line-break/>` — all three occupy real character positions in a paragraph's flat content model but carry no text-node value at all. Every ODF text getter in this codebase's editor layer (`src/edit/odt/*`, `src/edit/odp/*`, `src/edit/ods/*`) MUST call `decodeOdfText` (`src/xml/odf-text.ts`) — never `ooxml.js`'s own `textContent()`, a plain text-node concatenation with no idea `text:s`/`text:tab`/`text:line-break` exist. `textContent()` would silently DROP every one of them: the file still parses as valid XML, so this produces no error and no warning, just silently shorter text. `decodeOdfText` delegates the real work entirely to `odf.js`'s own `decodeOdfText` (wrapped in a synthetic container element, since `odf.js`'s version operates on a whole `XmlElement`'s children rather than a bare node array); the encode direction, `encodeOdfText` (plain string → the same element sequence, coalescing adjacent literal characters into as few text nodes as practical), is local to this package, since `odf.js` is a read-and-manifest package with no write-side text builder of its own.
|
|
337
337
|
- **The docx⇄PDF and pptx⇄PDF conversions are explicitly not round-trip-lossless** — in deliberate contrast to `ooxml.js`'s own `packageCodec`, which is byte/part-faithful by design. See [Fidelity](#fidelity). The six cross-format bridges below (`odtToDocx`/`docxToOdt`, `odpToPptx`/`pptxToOdp`, `odsToXlsx`/`xlsxToOds`) are a genuinely different case — see the [Fidelity](#fidelity) section's own paragraph on them.
|
|
338
|
-
- **A `DocumentPackage` returned via `onDocument`/`ConversionResult.package` is a snapshot from that one conversion pass, not a live view** — its `layout` correlates with its `content` only as of the exact read+layout that produced it (`document-
|
|
338
|
+
- **A `DocumentPackage` returned via `onDocument`/`ConversionResult.package` is a snapshot from that one conversion pass, not a live view** — its `layout` correlates with its `content` only as of the exact read+layout that produced it (`document-schema.js`'s own `DocumentPackageSchema` doc comment), so if a caller mutates the returned `content` afterwards, the `layout` sitting alongside it silently goes stale; nothing in this package (or `document-schema.js`) detects or rejects that.
|
|
339
339
|
- **Building the six cross-format bridges surfaced two real, previously-undiscovered gaps in existing `populateParagraph` write paths, both now fixed.** `buildDocxPackage`'s `populateParagraph` (`src/edit/docx/content.ts`) never wrote a paragraph's own `list` membership back (`ContentParagraph.list`, docx's flat `numId`/`level` model) — only read, never written, since no existing caller had ever round-tripped a list-bearing paragraph through it. `buildOdtPackage`'s `populateParagraph` (`src/edit/odt/content.ts`) never wrote a paragraph's own `styleId` back at all (`readOdtContent`/`readOdfParagraph` in `odf.js` reads it unconditionally from `text:style-name`, but nothing on the write side ever set that attribute). Both are now fixed: `DocxParagraph.list` is set unconditionally alongside `styleId`/`alignment`, matching that function's own existing pattern; `OdtParagraph.styleId` is set conditionally alongside `alignment`, matching odt's own local convention. `buildOdtPackage` additionally gained `appendBlocks`/`appendListRun` (`src/edit/odt/content.ts`) — ODF has no flat per-paragraph list property to set the way docx does, so a run of consecutive `ContentParagraph`s sharing `list.numId` is grouped and written as a real, potentially multi-level `text:list`/`text:list-item` tree via `OdtList`/`OdtListItem`, the structural inverse of `odf.js`'s own list-reading (a fresh `text:list` per `numId` change, one level of nesting per `list.level` step, descending only one level at a time since ODF can only open a nested list from inside an existing item). Both gaps were invisible before this task specifically because nothing had previously round-tripped a list-bearing paragraph or a styled paragraph through `docx ⇄ odt` at all — the PDF-pivot conversions never exercised `buildDocxPackage`/`buildOdtPackage` on content read back from the OTHER format.
|
|
340
340
|
- **A table shape inside an odp slide does not survive `odpToPptx`.** `buildPptxPackage`'s `appendShape` (`src/edit/pptx/content.ts`) silently drops any non-paragraph block found inside a shape's own text-box loop — a scope choice whose own comment ("PDF-reconstructed shapes never mix kinds") assumed its only caller was the PDF-reconstruction path, where that is true. `odpToPptx` is a second, non-PDF-reconstructed caller for which it is not: a real odp `draw:frame` containing a `table:table` directly (not inside a text box) reads as a `ContentShape` with a `'table'` block, and that block is silently dropped, leaving an empty pptx text box where the table was. Everything else on the same slide — a rotated shape, grouped shapes, an image, speaker notes — survives correctly (see `src/convert/bridges.test.ts`'s own dedicated fidelity-gap test, which proves both halves against the existing `minimalOdpBytes()` fixture). A real, tracked, bounded gap, not a silent one: closing it means teaching `buildPptxPackage`/`buildOdpPackage` to write a real table into a slide shape, a materially larger feature than this bridge's own scope.
|
|
341
341
|
- **The `ods ⇄ xlsx` bridge inherits several real, format-boundary fidelity limits from `ooxml.js`'s brand-new `readXlsxContent`/`buildXlsxPackage`, on top of its own pivot-copy design.** xlsx has no `percentage`/`currency` cell type of its own (both are a plain numeric cell plus a number-format style neither this reader nor this writer interprets) — an ods `percentage`/`currency` cell survives the `odsToXlsx` hop with its numeric *value* intact but downgrades to a plain `number` *kind*, permanently (currency's own currency code is dropped outright). xlsx also has only one rare `t="d"` cell type covering BOTH date and time — an ods `time` cell survives as a `date`-kind cell carrying its original value string verbatim, but mislabelled; an ods `date` cell is unaffected (it was already the kind xlsx's own `t="d"` maps onto). A formula (`table:formula`/`<f>`) is carried completely verbatim in both directions — never parsed, translated, or evaluated by either this package's own reader or writer — but a REAL spreadsheet application does evaluate a workbook's own `<f>`/`table:formula` on open: confirmed against genuine LibreOffice 26.2, an ods formula authored in OpenFormula syntax (`of:=[.B2]*2`) becomes a formula ERROR (`Err:510`) when the bridged xlsx is opened in real Calc, even though the formula's own cached value is still present and correctly readable via `readXlsxContent` — going the other way is less fragile in practice only because a genuine xlsx formula (bare Excel A1 syntax, e.g. `B2*2`) happens to still parse under LibreOffice's own more lenient, backward-compatible ODF formula grammar, not because of anything this bridge does differently in either direction. Column widths survive the `odsToXlsx` hop within roughly a pixel of rounding tolerance (see `src/convert/bridges.test.ts`'s own `COLUMN_WIDTH_TOLERANCE_PT`) but are then dropped entirely on the return `xlsxToOds` hop — not a character-width-unit rounding loss, but `buildOdsPackage` not writing `ContentSheetColumn.widthPt` at all, a pre-existing, already-documented gap in that file's own module comment, unrelated to and unfixed by this bridge. A boolean cell written by `buildXlsxPackage` renders as a raw `1`/`0` rather than `TRUE`/`FALSE` when opened in real Excel/Calc, since that writer's own genuinely-minimal `xl/styles.xml` (one default cell format, no boolean-specific number format) has nothing else to apply — the underlying `{ kind: 'boolean', value: true }` is still read back correctly by `readXlsxContent` regardless; this is a real-application *display* gap, not a data-fidelity one. `readXlsxContent`'s own cell.value.kind never produces `'error'` from an odf.js-sourced document at all, for a structural reason rather than a bug: ODF's `office:value-type` enumeration has no `error` member, so `OdsCell.value`'s own write-side choice for a `kind: 'error'` cell is to write it as a genuine, non-empty `office:string-value` carrying the error's own text — an `xlsxToOds` → `odsToXlsx` round trip of a genuine xlsx `t="e"` error cell therefore turns it into a plain `string` cell carrying the identical text; the message survives, the `error` semantic does not.
|
|
@@ -350,13 +350,13 @@ To run a single test file: `pnpm vitest run src/path/to/file.test.ts`.
|
|
|
350
350
|
- **A vector primitive's own fill/stroke needed a self-contained graphic-family style writer, not `odf.js`'s own `StyleRegistry`.** `'graphic'` is a recognised `StyleFamily` member (`odf.js`'s `src/styles/registry.ts`), but `StylePropertiesSchema`/`buildStylePropertyElements` (`properties.ts`/`serialize.ts`) only ever model text/paragraph formatting and never emit a `style:graphic-properties` element for any family — extending that shared package for one narrow, documents.js-local need (`draw:fill(-color)`/`draw:stroke` + `svg:stroke-color`/`svg:stroke-width`) would be scope creep into a foreign package for a two-attribute-group writer this package can express directly. `src/edit/odg/style.ts` is that writer: it still reuses `odf.js`'s general append-only style-editing invariant (a setter always mints a fresh `style:style` and repoints `draw:style-name`, never mutates an existing entry — verified by the same `assertAutomaticStylesOnlyAppended` helper `OdpEditor`'s own live-view fidelity test uses) and `src/edit/odt/automatic-styles.ts`'s `ensureAutomaticStyles`/`nextStyleName` (the "find-or-create `office:automatic-styles`, mint the next unused name" logic every other hand-rolled style helper in this package already shares), rather than a third reimplementation of either.
|
|
351
351
|
- **A path vector's own `svg:d` is cross-checked against `odf.js`'s real parser, not merely asserted to "look plausible".** `src/edit/odg/svg-path.ts`'s `buildSvgPathData` is the write-side inverse of `odf.js`'s `parseOdfPathData`; `OdgPathVector.subpaths` re-derives its value by reparsing the actual written `svg:viewBox`/`svg:d` through that exact function (plus `parseOdfViewBox`/`buildOdfSubpaths`) on every read, rather than echoing back whatever `ContentSubpath[]` the caller originally passed to `addPath` — so every read is itself a live round-trip proof, and this module's own test suite additionally feeds `buildSvgPathData`'s output straight into `parseOdfPathData` to confirm point-for-point recovery.
|
|
352
352
|
- **A newly added vector/shape's paint order is expressed purely as document order, with no `draw:z-index` ever written.** This matches `odf.js`'s own reader-side convention exactly (`typed/draw/shapes.ts`'s `paintOrderKey`: honour an explicit `draw:z-index` when present, otherwise fall back to document order — and real LibreOffice output never emits one, it reorders elements instead), so `OdgPage.addRect`/`addEllipse`/`addLine`/`addPath`/`addTextBox`/`addImage` simply append to `draw:page`'s own children in call order and nothing more is needed for a later `add*` call to paint in front of an earlier one.
|
|
353
|
-
- **`LayoutPathSchema` (`document-
|
|
354
|
-
- **A drawing page's `shapes` and `vectors` paint in two independently-ordered arrays, with no field recording their relative order.** `ContentDrawPageSchema` (`document-
|
|
353
|
+
- **`LayoutPathSchema` (`document-schema.js`) has no quadratic or elliptical-arc segment kind, deliberately — not a scope gap that happens to be unfilled.** `writePath` (pdf-codec's own `content-write.ts`) therefore has no quadratic-to-cubic elevation and no SVG-arc-to-cubic endpoint-to-centre parameterization anywhere in it: `odf.js`'s own real-LibreOffice-output-verified `svg:d` parser (`typed/shared/path.ts`) recognises `S`/`s`/`Q`/`q`/`T`/`t`/`A`/`a` as command letters (so its own token stream stays in sync) but produces no segment for any of them — real LibreOffice output for rectangles, ellipses, freeform curves, and basic custom-shape presets never emits a quadratic or an arc in the first place, only `M`/`L`/`H`/`V`/`C`/`Z`. Building unused quadratic/arc conversion code against a segment kind that can never occur would be speculative, not root-cause work.
|
|
354
|
+
- **A drawing page's `shapes` and `vectors` paint in two independently-ordered arrays, with no field recording their relative order.** `ContentDrawPageSchema` (`document-schema.js`) keeps text/image/table content (`shapes`) and vector primitives (`vectors`) as two separate arrays, each correctly paint-ordered on its own by `odf.js`'s own reader (honouring a real `draw:z-index` when present, falling back to document order otherwise) — but there is no shared ordering field between the two arrays at all, a real, tracked gap in the shared schema, not something `convertDrawingToLayout` can reconstruct after the fact. `convertDrawingToLayout` resolves it with one fixed, documented choice: every vector paints before every shape (vectors are the common "diagram" content in a real `.odg`; shapes are far more often text labels layered on top of them than the reverse). A page that genuinely interleaves the two mid-stack will not paint in true document z-order until the schema itself grows a shared field. `reconstructDrawing` resolves the identical gap in reverse the same way: it buckets each recovered `LayoutItem` into `vectors` or `shapes` by kind while walking the page once in overall paint order, so each array keeps its own items' relative order — which reproduces a `convertDrawingToLayout`-produced page's original paint order exactly (vectors-then-shapes, by construction), and is still the best either array's own shape is able to express for a `LayoutDocument` from any other producer.
|
|
355
355
|
- **A vector primitive's own rotation is never read at all.** None of `ContentVectorSchema`'s variants carry a rotation field, unlike `ContentShapeSchema` — `readOdgContent`'s underlying `odf.js` reader deliberately discards a `draw:rect`/`draw:ellipse`/`draw:custom-shape`'s own rotation, so it reads (and `convertDrawingToLayout` places) at its unrotated bounding frame. A real, tracked model limitation inherited from `odf.js`, not something this package's own layout code introduces.
|
|
356
356
|
- **`ContentVector`'s `path` variant's `fillRule` is never populated by the reader — always `undefined`, which `writePath` treats as nonzero.** `odf.js`'s `readDrawPathVector` does not currently resolve an evenodd fill rule from real ODF output, so every path this pipeline reads paints with PDF's default nonzero winding rule. `LayoutPathSchema`/`writePath` fully support `fillRule: 'evenodd'` regardless — a caller constructing a `LayoutPath` (or a future `ContentVector` producer) directly can still set it; it just never arrives via `odgToPdf` today.
|
|
357
|
-
- **`ContentSheetCellSchema` (`document-
|
|
357
|
+
- **`ContentSheetCellSchema` (`document-schema.js`) models no per-cell border or background, and no per-cell alignment override** — unlike `ContentTableCellSchema.background`. `sheets.ts`'s cell-background and cell-border z-order steps are consequently skipped entirely (no dead placeholder code), and cell text alignment always falls back to the value-kind default (numeric right, boolean/error centre, string left) since there is nothing to override it with. A tracked, documented gap, not a silent one.
|
|
358
358
|
- **Ordinary text in PDF output uses the standard 14 fonts only — no font embedding.** Helvetica/Times-Roman are genuinely metric-compatible substitutes for Arial/Times New Roman, but Word's actual current defaults (Calibri, Aptos) are not, so line wrapping and pagination will drift slightly from what Word itself would produce. Expect a faithful visual approximation, not a line-identical reproduction. The one exception is MathML formula rendering (`odfToPdf`, and formulas embedded inside odt/odp): those genuinely embed the real STIX Two Math font — see the CFF-embedding gotcha below, and pdf-codec's own README, for the exact scope of that embedding (the whole `CFF ` table, not glyph-subsetted).
|
|
359
|
-
- **Justified paragraphs render left-aligned, not justified.** `Alignment` (`document-
|
|
359
|
+
- **Justified paragraphs render left-aligned, not justified.** `Alignment` (`document-schema.js`) has a real `'justify'` member, and it survives reading a docx/odt paragraph's own alignment correctly, but `src/layout/shared.ts`'s `alignmentOffsetPt` — the one function every layout engine (`engine.ts`/`slides.ts`/`sheets.ts`) consults to position a line — has no branch for it at all, falling through to the same `0` offset `'left'` gets; there is no inter-word spacing stretch anywhere in this package's line-wrapping code either. A documented narrowing, not a silent approximation: `alignmentOffsetPt`'s own comment states "not implemented for v1" explicitly. Every other alignment value (`center`/`right`) works correctly.
|
|
360
360
|
- **Reading arbitrary real-world PDFs, encrypted-PDF support, and unsupported image filters (`CCITTFaxDecode`/`JBIG2Decode`/`JPXDecode`) are all pdf-codec's own scope boundaries now, not this package's.** In short: the parser targets cleanly-generated output from mainstream producers rather than adversarial-input robustness; `/Encrypt` in the trailer throws rather than attempting decryption, even for the common empty-user-password case; scanned-fax and JPEG2000 images are skipped with a diagnostic while the rest of the page still reads (JPEG and PNG both pass through losslessly). See pdf-codec's own README for the full statement of each.
|
|
361
361
|
- **PDF → docx/pptx reconstruction has no table or vector-shape recovery.** A PDF has no semantic table structure to recover — a wide horizontal gap on a line becomes a tab character, not a reconstructed grid. General vector paths, curves, gradients, and shadings are not recovered either. This is a genuinely different scope boundary from `pdfToOds`'s own grid recovery (see the `pdfToOds` gotcha above): there, the grid itself IS the deliverable, so a real gridline lattice or text-position clustering builds one deliberately, within its own honestly-scoped limits (a bare string per cell, never a typed value).
|
|
362
362
|
- **Table cell `colSpan`/`rowSpan` and pptx shape rotation are read from a `ContentDocument` but not yet written back** by `buildDocxPackage`/`buildOdtPackage`/`buildPptxPackage` — a merged cell round-trips as an ordinary unmerged one, and a rotated *pptx* shape round-trips unrotated (`buildOdpPackage` does not share the rotation half of this gap — see the `OdpShape.rotationDeg` gotcha above). Both are bounded, tracked gaps (the cell's own text content and the shape's own position are still correct), not silent ones.
|
|
@@ -417,9 +417,9 @@ Commits follow Conventional Commits (`feat:`, `fix:`, `test:`, `chore:`, …), e
|
|
|
417
417
|
## References
|
|
418
418
|
|
|
419
419
|
- [ooxml.js](https://github.com/ExaDev/ooxml.js) — the sibling package this depends on for all docx/pptx/xlsx ⇄ JSON handling and cascade-resolved typed reading, including its own `readXlsxContent`/`buildXlsxPackage` (a `ContentDocument`-shaped xlsx reader/writer pair), consumed directly by `src/convert/convert.ts`'s `odsToXlsx`/`xlsxToOds` bridge but not re-exported from this package's own public surface.
|
|
420
|
-
- [document-
|
|
420
|
+
- [document-schema.js](https://github.com/ExaDev/document-schema.js) — the sibling package that owns `ContentDocument`/`LayoutDocument` themselves; `ooxml.js`, `odf.js`, `pdf-codec`, and `documents.js` all import from it rather than each maintaining an independent copy.
|
|
421
421
|
- [pdf-codec](https://github.com/ExaDev/pdf-codec) — the sibling package this depends on for the hand-written PDF codec itself (`readPdf`/`writePdf`/`pdfCodec`), extracted from this repository: parsing arbitrary real-world PDFs and generating new ones, the embedded STIX Two Math font, and the text-measurement/font-resolution/byte/image primitives `src/layout/` builds on. See [Architecture](#architecture) above for exactly where the boundary between the two packages sits, and pdf-codec's own README for its internals.
|
|
422
|
-
- [odf.js](https://github.com/ExaDev/odf.js) — a sibling package doing the equivalent lossless-codec job for the OpenDocument Format (odt/ods/odp/odg/…), also built on `document-
|
|
422
|
+
- [odf.js](https://github.com/ExaDev/odf.js) — a sibling package doing the equivalent lossless-codec job for the OpenDocument Format (odt/ods/odp/odg/…), also built on `document-schema.js`. A dependency of `documents.js` for: this package's `Odt`/`Ods`/`Odp`/`OdgBytesSchema` (`src/model/bytes.ts`), which validate against its `ODF_MEDIA_TYPES` table; `src/interop.test.ts`, a type-level guard that `ooxml.js`'s and `odf.js`'s raw `XmlElement`/`XmlNode`/`Attribute`/`Package` container types stay structurally compatible; `src/odf/odt/read.ts`'s `readOdtContent`, a thin adapter over `odf.js`'s own `readOdt`, feeding `odtToPdf`/`pdfToOdt` (`src/convert/convert.ts`); `src/odf/odp/read.ts`'s `readOdpContent`, the same adapter over `odf.js`'s `readOdp`, feeding `odpToPdf`/`pdfToOdp`; `src/odf/ods/read.ts`'s `readOdsContent`, the same adapter over `odf.js`'s `readOds`, feeding `odsToPdf`/`pdfToOds`, and reused directly by `src/edit/ods/print-settings.ts`'s own `readSheetPrintSettings` (`findStyleElement`/`resolvePageLayoutProperties`/`parsePageSize`/`parseMargins`, the same style-chain-resolution primitives `readOds`'s own `readPrintSettings` is built on); `src/odf/odg/read.ts`'s `readOdgContent`, the same adapter over `odf.js`'s `readOdg` — including its own `typed/shared/path.ts`, the real-LibreOffice-output-verified `svg:d`/`draw:points` parser this package's `writePath` content is ultimately sourced from, and which `src/edit/odg/svg-path.ts`'s `buildSvgPathData` (the write-side inverse) also cross-checks its own output against directly — feeding `odgToPdf`/`pdfToOdg` (the latter re-reading a rebuilt package's own real geometry through this same `readOdg`, not just writing one); `src/odf/formula/read.ts`'s `readOdfFormulaContent`/`readOdfEmbeddedFormula`, thin adapters over `odf.js`'s own `readOdfFormula`, feeding `odfToPdf` and the odt/odp embedded-formula paths respectively; `src/edit/odt/*`'s `StyleRegistry`/`resolveStyle` (style interning), `src/edit/odp/shape.ts`'s `applyOdfTransform`/`resolveOdfShapeGeometry` (rotation), and `src/edit/odt/automatic-styles.ts`'s `ensureAutomaticStyles`/`nextStyleName` (reused by `src/edit/odg/style.ts`'s own graphic-family style writer and `src/edit/ods/print-settings.ts`'s own page-layout/master-page/table-style minting), all consumed directly rather than reimplemented. odt, odp, ods, and odg → `ContentDocument` reading and PDF conversion are now all integrated both ways.
|
|
423
423
|
- [STIX Two Math](https://github.com/stipub/stixfonts) — the embedded math font `odfToPdf` (and the odt/odp embedded-formula paths) render through. Vendored, parsed, and embedded entirely within `pdf-codec` now (this repository no longer carries the font asset directly) — see that package's own README for the exact source commit/version and licensing (OFL-1.1) provenance.
|
|
424
424
|
- [firebirdsql/firebird](https://github.com/FirebirdSQL/firebird) — the ground truth `src/firebird/` is built against, since Firebird's own gbak backup format has no ratified public specification: `src/burp/burp.h` (the `rec_type`/`att_type` enumerations and their own per-block numbering, and the backup-format version history), `src/burp/backup.epp`/`restore.epp` (the write/read reference implementation `src/firebird/reader.ts`'s attribute framing and RLE decompression are restated from), `src/burp/canonical.cpp` (the per-SQL-type XDR shape a row's own field values use), `src/burp/mvol.cpp` (the backup-header attributes and their own presence-means-true encoding), `src/common/xdr.cpp` (the underlying big-endian XDR primitive encodings, including the `xdr_hyper` high-word-first ordering this reader's own construction initially got backwards), `src/jrd/align.h`/`src/include/firebird/impl/blr.h` (the BLR-type-opcode-to-physical-storage-type mapping), and `src/common/classes/NoThrowTimeStamp.cpp` (the DATE/TIME encoding algorithms). Not a dependency of this package at build or runtime — read and cited as source material only, per commit state at the time `src/firebird/` was built.
|
|
425
425
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let ooxml_js = require("ooxml.js");
|
|
3
|
-
let
|
|
3
|
+
let document_schema_js = require("document-schema.js");
|
|
4
4
|
let zod = require("zod");
|
|
5
5
|
let odf_js = require("odf.js");
|
|
6
6
|
let pdf_codec = require("pdf-codec");
|
|
@@ -10,26 +10,26 @@ const ContentDocumentSchema = zod.z.discriminatedUnion("kind", [
|
|
|
10
10
|
zod.z.object({
|
|
11
11
|
kind: zod.z.literal("wordprocessing"),
|
|
12
12
|
formatVersion: zod.z.literal(1),
|
|
13
|
-
metadata:
|
|
14
|
-
sections: zod.z.array(
|
|
13
|
+
metadata: document_schema_js.LayoutMetadataSchema,
|
|
14
|
+
sections: zod.z.array(document_schema_js.ContentSectionSchema)
|
|
15
15
|
}),
|
|
16
16
|
zod.z.object({
|
|
17
17
|
kind: zod.z.literal("presentation"),
|
|
18
18
|
formatVersion: zod.z.literal(1),
|
|
19
|
-
metadata:
|
|
20
|
-
slides: zod.z.array(
|
|
19
|
+
metadata: document_schema_js.LayoutMetadataSchema,
|
|
20
|
+
slides: zod.z.array(document_schema_js.ContentSlideSchema)
|
|
21
21
|
}),
|
|
22
22
|
zod.z.object({
|
|
23
23
|
kind: zod.z.literal("spreadsheet"),
|
|
24
24
|
formatVersion: zod.z.literal(1),
|
|
25
|
-
metadata:
|
|
26
|
-
sheets: zod.z.array(
|
|
25
|
+
metadata: document_schema_js.LayoutMetadataSchema,
|
|
26
|
+
sheets: zod.z.array(document_schema_js.ContentSheetSchema)
|
|
27
27
|
}),
|
|
28
28
|
zod.z.object({
|
|
29
29
|
kind: zod.z.literal("drawing"),
|
|
30
30
|
formatVersion: zod.z.literal(1),
|
|
31
|
-
metadata:
|
|
32
|
-
pages: zod.z.array(
|
|
31
|
+
metadata: document_schema_js.LayoutMetadataSchema,
|
|
32
|
+
pages: zod.z.array(document_schema_js.ContentDrawPageSchema)
|
|
33
33
|
})
|
|
34
34
|
]);
|
|
35
35
|
//#endregion
|
|
@@ -500,10 +500,10 @@ function getColor(rPr) {
|
|
|
500
500
|
if (color === void 0) return;
|
|
501
501
|
const val = (0, ooxml_js.attr)(color, "w:val");
|
|
502
502
|
if (val === void 0 || val.toLowerCase() === "auto") return;
|
|
503
|
-
return (0,
|
|
503
|
+
return (0, document_schema_js.rgbHexToColor)(val);
|
|
504
504
|
}
|
|
505
505
|
function setColor(rPr, color) {
|
|
506
|
-
setAttr(getOrCreateChildElement(rPr, "w:color", RPR_ORDER, () => el("w:color")), "w:val", (0,
|
|
506
|
+
setAttr(getOrCreateChildElement(rPr, "w:color", RPR_ORDER, () => el("w:color")), "w:val", (0, document_schema_js.colorToRgbHex)(color));
|
|
507
507
|
}
|
|
508
508
|
function getStyleId(propsElement, tag) {
|
|
509
509
|
if (propsElement === void 0) return;
|
|
@@ -656,7 +656,7 @@ function buildRun$1(init = {}) {
|
|
|
656
656
|
const half = String(Math.round(init.sizePt * 2));
|
|
657
657
|
rPrChildren.push(el("w:sz", { "w:val": half }), el("w:szCs", { "w:val": half }));
|
|
658
658
|
}
|
|
659
|
-
if (init.color !== void 0) rPrChildren.push(el("w:color", { "w:val": (0,
|
|
659
|
+
if (init.color !== void 0) rPrChildren.push(el("w:color", { "w:val": (0, document_schema_js.colorToRgbHex)(init.color) }));
|
|
660
660
|
const run = el("w:r");
|
|
661
661
|
if (rPrChildren.length > 0 || init.underline === true) {
|
|
662
662
|
const rPr = el("w:rPr");
|
|
@@ -2350,8 +2350,8 @@ function declaration$3() {
|
|
|
2350
2350
|
}
|
|
2351
2351
|
function buildPageLayout$3() {
|
|
2352
2352
|
return el("style:page-layout", { "style:name": PAGE_LAYOUT_NAME$3 }, [el("style:page-layout-properties", {
|
|
2353
|
-
"fo:page-width": `${
|
|
2354
|
-
"fo:page-height": `${
|
|
2353
|
+
"fo:page-width": `${document_schema_js.PAGE_SIZE_LETTER.widthPt}pt`,
|
|
2354
|
+
"fo:page-height": `${document_schema_js.PAGE_SIZE_LETTER.heightPt}pt`,
|
|
2355
2355
|
"fo:margin-top": `${DEFAULT_MARGIN_PT$1}pt`,
|
|
2356
2356
|
"fo:margin-right": `${DEFAULT_MARGIN_PT$1}pt`,
|
|
2357
2357
|
"fo:margin-bottom": `${DEFAULT_MARGIN_PT$1}pt`,
|
|
@@ -2760,8 +2760,8 @@ function declaration$2() {
|
|
|
2760
2760
|
}
|
|
2761
2761
|
function buildPageLayout$2() {
|
|
2762
2762
|
return el("style:page-layout", { "style:name": "PM1" }, [el("style:page-layout-properties", {
|
|
2763
|
-
"fo:page-width": `${
|
|
2764
|
-
"fo:page-height": `${
|
|
2763
|
+
"fo:page-width": `${document_schema_js.SLIDE_SIZE_WIDESCREEN.widthPt}pt`,
|
|
2764
|
+
"fo:page-height": `${document_schema_js.SLIDE_SIZE_WIDESCREEN.heightPt}pt`
|
|
2765
2765
|
})]);
|
|
2766
2766
|
}
|
|
2767
2767
|
function buildStylesXml$2() {
|
|
@@ -3223,8 +3223,8 @@ function declaration$1() {
|
|
|
3223
3223
|
}
|
|
3224
3224
|
function buildPageLayout$1() {
|
|
3225
3225
|
return el("style:page-layout", { "style:name": "PM1" }, [el("style:page-layout-properties", {
|
|
3226
|
-
"fo:page-width": `${
|
|
3227
|
-
"fo:page-height": `${
|
|
3226
|
+
"fo:page-width": `${document_schema_js.PAGE_SIZE_A4.widthPt}pt`,
|
|
3227
|
+
"fo:page-height": `${document_schema_js.PAGE_SIZE_A4.heightPt}pt`,
|
|
3228
3228
|
"fo:margin-top": DEFAULT_MARGIN,
|
|
3229
3229
|
"fo:margin-right": DEFAULT_MARGIN,
|
|
3230
3230
|
"fo:margin-bottom": DEFAULT_MARGIN,
|
|
@@ -3603,7 +3603,7 @@ function readSheetPrintSettings(pkg, tableElement) {
|
|
|
3603
3603
|
const printTokens = new Set((layoutProperties === void 0 ? void 0 : (0, ooxml_js.attr)(layoutProperties, "style:print"))?.split(" ").filter((token) => token.length > 0) ?? []);
|
|
3604
3604
|
const pageOrder = (layoutProperties === void 0 ? void 0 : (0, ooxml_js.attr)(layoutProperties, "style:print-page-order")) === "ltr" ? "overThenDown" : "downThenOver";
|
|
3605
3605
|
return {
|
|
3606
|
-
pageSize: pageSize ??
|
|
3606
|
+
pageSize: pageSize ?? document_schema_js.PAGE_SIZE_A4,
|
|
3607
3607
|
margins: margins ?? DEFAULT_MARGINS,
|
|
3608
3608
|
gridlines: printTokens.has("grid"),
|
|
3609
3609
|
headers: printTokens.has("headers"),
|
|
@@ -3847,8 +3847,8 @@ function declaration() {
|
|
|
3847
3847
|
}
|
|
3848
3848
|
function buildPageLayout() {
|
|
3849
3849
|
return el("style:page-layout", { "style:name": "PM1" }, [el("style:page-layout-properties", {
|
|
3850
|
-
"fo:page-width": `${
|
|
3851
|
-
"fo:page-height": `${
|
|
3850
|
+
"fo:page-width": `${document_schema_js.PAGE_SIZE_A4.widthPt}pt`,
|
|
3851
|
+
"fo:page-height": `${document_schema_js.PAGE_SIZE_A4.heightPt}pt`
|
|
3852
3852
|
})]);
|
|
3853
3853
|
}
|
|
3854
3854
|
function buildStylesXml() {
|
|
@@ -6350,7 +6350,7 @@ function placeholderFormulaDocument(formula) {
|
|
|
6350
6350
|
formatVersion: 1,
|
|
6351
6351
|
metadata: {},
|
|
6352
6352
|
sections: [{
|
|
6353
|
-
pageSize:
|
|
6353
|
+
pageSize: document_schema_js.PAGE_SIZE_A4,
|
|
6354
6354
|
margins: ZERO_MARGINS$1,
|
|
6355
6355
|
blocks: [{
|
|
6356
6356
|
kind: "paragraph",
|
|
@@ -6469,7 +6469,7 @@ function readOdgContent(pkg) {
|
|
|
6469
6469
|
const FALLBACK_ROW_HEIGHT_PT = 20;
|
|
6470
6470
|
function runFont(run) {
|
|
6471
6471
|
return {
|
|
6472
|
-
family: run.fontFamily ??
|
|
6472
|
+
family: run.fontFamily ?? document_schema_js.DEFAULT_LAYOUT_FONT.family,
|
|
6473
6473
|
weight: run.bold === true ? "bold" : "normal",
|
|
6474
6474
|
style: run.italic === true ? "italic" : "normal"
|
|
6475
6475
|
};
|
|
@@ -6479,7 +6479,7 @@ function toStyledRuns(runs, fontScale = 1) {
|
|
|
6479
6479
|
text: run.text,
|
|
6480
6480
|
font: runFont(run),
|
|
6481
6481
|
sizePt: (run.sizePt ?? 18) * fontScale,
|
|
6482
|
-
color: run.color ??
|
|
6482
|
+
color: run.color ?? document_schema_js.COLOR_BLACK,
|
|
6483
6483
|
underline: run.underline,
|
|
6484
6484
|
hyperlink: run.hyperlink,
|
|
6485
6485
|
sourcePath: run.sourcePath
|
|
@@ -6489,9 +6489,9 @@ function effectiveStyledRuns(runs, fontScale = 1) {
|
|
|
6489
6489
|
const styled = toStyledRuns(runs, fontScale);
|
|
6490
6490
|
return styled.length > 0 ? styled : [{
|
|
6491
6491
|
text: "",
|
|
6492
|
-
font:
|
|
6492
|
+
font: document_schema_js.DEFAULT_LAYOUT_FONT,
|
|
6493
6493
|
sizePt: 18 * fontScale,
|
|
6494
|
-
color:
|
|
6494
|
+
color: document_schema_js.COLOR_BLACK
|
|
6495
6495
|
}];
|
|
6496
6496
|
}
|
|
6497
6497
|
function lineNaturalHeightPt(line, measurer, fallback) {
|
|
@@ -6718,7 +6718,7 @@ function layoutFormulaFlow(block, section, pages, state, contentLeftXDown, conte
|
|
|
6718
6718
|
const { box } = layoutFormula(embedded.mathml, {
|
|
6719
6719
|
metrics,
|
|
6720
6720
|
sizePt,
|
|
6721
|
-
color:
|
|
6721
|
+
color: document_schema_js.COLOR_BLACK
|
|
6722
6722
|
});
|
|
6723
6723
|
ensureRoom(state, section, pages, box.heightPt, contentBottomYDown);
|
|
6724
6724
|
const flippedFrame = flipY({
|
|
@@ -6755,7 +6755,7 @@ function convertWordprocessingToLayout(doc, options) {
|
|
|
6755
6755
|
for (const section of doc.sections) paginateSection(section, options.measurer, images, pages, options, formulas);
|
|
6756
6756
|
return {
|
|
6757
6757
|
document: {
|
|
6758
|
-
formatVersion:
|
|
6758
|
+
formatVersion: document_schema_js.LAYOUT_FORMAT_VERSION,
|
|
6759
6759
|
metadata: doc.metadata,
|
|
6760
6760
|
pages,
|
|
6761
6761
|
images
|
|
@@ -6882,7 +6882,7 @@ function layoutShapeFormula(block, flippedFrame, formulaContext) {
|
|
|
6882
6882
|
const { box } = layoutFormula(embedded.mathml, {
|
|
6883
6883
|
metrics,
|
|
6884
6884
|
sizePt,
|
|
6885
|
-
color:
|
|
6885
|
+
color: document_schema_js.COLOR_BLACK
|
|
6886
6886
|
});
|
|
6887
6887
|
formulaContext.positioned.push({
|
|
6888
6888
|
pageIndex: formulaContext.pageIndex,
|
|
@@ -6941,7 +6941,7 @@ function convertPresentationToLayout(doc, options) {
|
|
|
6941
6941
|
const pages = doc.slides.map((slide, slideIndex) => convertSlide(slide, slideIndex, options.measurer, images, options.formulas, formulas));
|
|
6942
6942
|
return {
|
|
6943
6943
|
document: {
|
|
6944
|
-
formatVersion:
|
|
6944
|
+
formatVersion: document_schema_js.LAYOUT_FORMAT_VERSION,
|
|
6945
6945
|
metadata: doc.metadata,
|
|
6946
6946
|
pages,
|
|
6947
6947
|
images
|
|
@@ -6964,9 +6964,9 @@ const CELL_TEXT_PADDING_PT = 2;
|
|
|
6964
6964
|
const HEADER_LABEL_PADDING_PT = 2;
|
|
6965
6965
|
const MINIMUM_SCALE = .01;
|
|
6966
6966
|
const NUMERIC_OVERFLOW_TEXT = "###";
|
|
6967
|
-
const GRIDLINE_COLOR = (0,
|
|
6967
|
+
const GRIDLINE_COLOR = (0, document_schema_js.rgbHexToColor)("#D0D0D0");
|
|
6968
6968
|
const GRIDLINE_WIDTH_PT = .5;
|
|
6969
|
-
const HEADER_LABEL_COLOR = (0,
|
|
6969
|
+
const HEADER_LABEL_COLOR = (0, document_schema_js.rgbHexToColor)("#606060");
|
|
6970
6970
|
function columnLetters(index) {
|
|
6971
6971
|
let n = index + 1;
|
|
6972
6972
|
let letters = "";
|
|
@@ -7024,8 +7024,8 @@ function computeHeaderGutter(printSettings, range, measurer) {
|
|
|
7024
7024
|
};
|
|
7025
7025
|
const widestRowLabel = String(range.endRow + 1);
|
|
7026
7026
|
return {
|
|
7027
|
-
widthPt: measurer.widthOfTextAtSize(widestRowLabel,
|
|
7028
|
-
heightPt: measurer.lineHeightAtSize(
|
|
7027
|
+
widthPt: measurer.widthOfTextAtSize(widestRowLabel, document_schema_js.DEFAULT_LAYOUT_FONT, HEADER_LABEL_SIZE_PT) + 4,
|
|
7028
|
+
heightPt: measurer.lineHeightAtSize(document_schema_js.DEFAULT_LAYOUT_FONT, HEADER_LABEL_SIZE_PT)
|
|
7029
7029
|
};
|
|
7030
7030
|
}
|
|
7031
7031
|
function resolveScale(printSettings, availableWidthPt, availableHeightPt, totalContentWidthPt, totalContentHeightPt) {
|
|
@@ -7068,9 +7068,9 @@ function cellStyledRuns(cell) {
|
|
|
7068
7068
|
} : run));
|
|
7069
7069
|
return [{
|
|
7070
7070
|
text: cell.displayText,
|
|
7071
|
-
font:
|
|
7071
|
+
font: document_schema_js.DEFAULT_LAYOUT_FONT,
|
|
7072
7072
|
sizePt: NOMINAL_CELL_TEXT_SIZE_PT,
|
|
7073
|
-
color:
|
|
7073
|
+
color: document_schema_js.COLOR_BLACK
|
|
7074
7074
|
}];
|
|
7075
7075
|
}
|
|
7076
7076
|
function isNumericLikeValue(kind) {
|
|
@@ -7186,7 +7186,7 @@ function renderCellText(cell, rowCells, columnAxis, rowAxis, gridLeftXPt, gridTo
|
|
|
7186
7186
|
}
|
|
7187
7187
|
}
|
|
7188
7188
|
function renderHeaderLabels(gutter, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt, pageHeightPt, measurer, out) {
|
|
7189
|
-
const labelFont =
|
|
7189
|
+
const labelFont = document_schema_js.DEFAULT_LAYOUT_FONT;
|
|
7190
7190
|
const lineHeightPt = measurer.lineHeightAtSize(labelFont, HEADER_LABEL_SIZE_PT);
|
|
7191
7191
|
const ascentPt = measurer.ascenderAtSize(labelFont, HEADER_LABEL_SIZE_PT);
|
|
7192
7192
|
columnAxis.indices.forEach((columnIndex, position) => {
|
|
@@ -7353,7 +7353,7 @@ function convertSpreadsheetToLayout(doc, options) {
|
|
|
7353
7353
|
const pages = [];
|
|
7354
7354
|
for (const sheet of doc.sheets) convertSheetToPages(sheet, options.measurer, options.signal, pages);
|
|
7355
7355
|
return {
|
|
7356
|
-
formatVersion:
|
|
7356
|
+
formatVersion: document_schema_js.LAYOUT_FORMAT_VERSION,
|
|
7357
7357
|
metadata: doc.metadata,
|
|
7358
7358
|
pages,
|
|
7359
7359
|
images: {}
|
|
@@ -7465,7 +7465,7 @@ function convertDrawingToLayout(doc, options) {
|
|
|
7465
7465
|
const images = {};
|
|
7466
7466
|
const pages = doc.pages.map((page) => convertPage(page, options.measurer, images));
|
|
7467
7467
|
return {
|
|
7468
|
-
formatVersion:
|
|
7468
|
+
formatVersion: document_schema_js.LAYOUT_FORMAT_VERSION,
|
|
7469
7469
|
metadata: doc.metadata,
|
|
7470
7470
|
pages,
|
|
7471
7471
|
images
|
|
@@ -9866,7 +9866,7 @@ const COLUMN_WIDTH_PT = 64;
|
|
|
9866
9866
|
const ROW_HEIGHT_PT = 15;
|
|
9867
9867
|
const MARGIN_PT = 56.69291338582677;
|
|
9868
9868
|
const DEFAULT_PRINT_SETTINGS = {
|
|
9869
|
-
pageSize:
|
|
9869
|
+
pageSize: document_schema_js.PAGE_SIZE_A4,
|
|
9870
9870
|
margins: {
|
|
9871
9871
|
topPt: MARGIN_PT,
|
|
9872
9872
|
rightPt: MARGIN_PT,
|
|
@@ -9929,7 +9929,7 @@ function docxToPdf(bytes, options) {
|
|
|
9929
9929
|
if (content.kind !== "wordprocessing") throw new Error("readDocxContent returned a non-wordprocessing ContentDocument");
|
|
9930
9930
|
const { document: layout, formulas } = convertWordprocessingToLayout(content, { measurer: (0, pdf_codec.createStandardFontMeasurer)() });
|
|
9931
9931
|
options?.onDocument?.({
|
|
9932
|
-
formatVersion:
|
|
9932
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
9933
9933
|
content,
|
|
9934
9934
|
layout
|
|
9935
9935
|
});
|
|
@@ -9947,7 +9947,7 @@ function odtToPdf(bytes, options) {
|
|
|
9947
9947
|
formulas: content.formulas
|
|
9948
9948
|
});
|
|
9949
9949
|
options?.onDocument?.({
|
|
9950
|
-
formatVersion:
|
|
9950
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
9951
9951
|
content: content.document,
|
|
9952
9952
|
layout
|
|
9953
9953
|
});
|
|
@@ -9962,7 +9962,7 @@ function pptxToPdf(bytes, options) {
|
|
|
9962
9962
|
if (content.kind !== "presentation") throw new Error("readPptxContent returned a non-presentation ContentDocument");
|
|
9963
9963
|
const { document: layout } = convertPresentationToLayout(content, { measurer: (0, pdf_codec.createStandardFontMeasurer)() });
|
|
9964
9964
|
options?.onDocument?.({
|
|
9965
|
-
formatVersion:
|
|
9965
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
9966
9966
|
content,
|
|
9967
9967
|
layout
|
|
9968
9968
|
});
|
|
@@ -9979,7 +9979,7 @@ function odpToPdf(bytes, options) {
|
|
|
9979
9979
|
formulas: content.formulas
|
|
9980
9980
|
});
|
|
9981
9981
|
options?.onDocument?.({
|
|
9982
|
-
formatVersion:
|
|
9982
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
9983
9983
|
content: content.document,
|
|
9984
9984
|
layout
|
|
9985
9985
|
});
|
|
@@ -9997,7 +9997,7 @@ function odsToPdf(bytes, options) {
|
|
|
9997
9997
|
signal: options?.signal
|
|
9998
9998
|
});
|
|
9999
9999
|
options?.onDocument?.({
|
|
10000
|
-
formatVersion:
|
|
10000
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
10001
10001
|
content,
|
|
10002
10002
|
layout
|
|
10003
10003
|
});
|
|
@@ -10011,7 +10011,7 @@ function odgToPdf(bytes, options) {
|
|
|
10011
10011
|
if (content.kind !== "drawing") throw new Error("readOdgContent returned a non-drawing ContentDocument");
|
|
10012
10012
|
const layout = convertDrawingToLayout(content, { measurer: (0, pdf_codec.createStandardFontMeasurer)() });
|
|
10013
10013
|
options?.onDocument?.({
|
|
10014
|
-
formatVersion:
|
|
10014
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
10015
10015
|
content,
|
|
10016
10016
|
layout
|
|
10017
10017
|
});
|
|
@@ -10029,20 +10029,20 @@ function odfToPdf(bytes, options) {
|
|
|
10029
10029
|
const { box } = layoutFormula(formula.mathml, {
|
|
10030
10030
|
metrics,
|
|
10031
10031
|
sizePt: STANDALONE_FORMULA_SIZE_PT,
|
|
10032
|
-
color:
|
|
10032
|
+
color: document_schema_js.COLOR_BLACK
|
|
10033
10033
|
});
|
|
10034
10034
|
const flipped = flipY({
|
|
10035
10035
|
xPt: STANDALONE_FORMULA_MARGIN_PT,
|
|
10036
10036
|
yPt: STANDALONE_FORMULA_MARGIN_PT,
|
|
10037
10037
|
widthPt: box.widthPt,
|
|
10038
10038
|
heightPt: box.heightPt
|
|
10039
|
-
},
|
|
10039
|
+
}, document_schema_js.PAGE_SIZE_A4.heightPt);
|
|
10040
10040
|
const layout = {
|
|
10041
|
-
formatVersion:
|
|
10041
|
+
formatVersion: document_schema_js.LAYOUT_FORMAT_VERSION,
|
|
10042
10042
|
metadata: formula.metadata,
|
|
10043
10043
|
pages: [{
|
|
10044
|
-
widthPt:
|
|
10045
|
-
heightPt:
|
|
10044
|
+
widthPt: document_schema_js.PAGE_SIZE_A4.widthPt,
|
|
10045
|
+
heightPt: document_schema_js.PAGE_SIZE_A4.heightPt,
|
|
10046
10046
|
items: []
|
|
10047
10047
|
}],
|
|
10048
10048
|
images: {}
|
|
@@ -10065,7 +10065,7 @@ function pdfToDocx(bytes, options) {
|
|
|
10065
10065
|
});
|
|
10066
10066
|
const content = reconstructWordprocessing(layout, { signal: options?.signal });
|
|
10067
10067
|
options?.onDocument?.({
|
|
10068
|
-
formatVersion:
|
|
10068
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
10069
10069
|
content,
|
|
10070
10070
|
layout
|
|
10071
10071
|
});
|
|
@@ -10078,7 +10078,7 @@ function pdfToPptx(bytes, options) {
|
|
|
10078
10078
|
});
|
|
10079
10079
|
const content = reconstructPresentation(layout, { signal: options?.signal });
|
|
10080
10080
|
options?.onDocument?.({
|
|
10081
|
-
formatVersion:
|
|
10081
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
10082
10082
|
content,
|
|
10083
10083
|
layout
|
|
10084
10084
|
});
|
|
@@ -10091,7 +10091,7 @@ function pdfToOdt(bytes, options) {
|
|
|
10091
10091
|
});
|
|
10092
10092
|
const content = reconstructWordprocessing(layout, { signal: options?.signal });
|
|
10093
10093
|
options?.onDocument?.({
|
|
10094
|
-
formatVersion:
|
|
10094
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
10095
10095
|
content,
|
|
10096
10096
|
layout
|
|
10097
10097
|
});
|
|
@@ -10104,7 +10104,7 @@ function pdfToOdp(bytes, options) {
|
|
|
10104
10104
|
});
|
|
10105
10105
|
const content = reconstructPresentation(layout, { signal: options?.signal });
|
|
10106
10106
|
options?.onDocument?.({
|
|
10107
|
-
formatVersion:
|
|
10107
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
10108
10108
|
content,
|
|
10109
10109
|
layout
|
|
10110
10110
|
});
|
|
@@ -10117,7 +10117,7 @@ function pdfToOdg(bytes, options) {
|
|
|
10117
10117
|
});
|
|
10118
10118
|
const content = reconstructDrawing(layout, { signal: options?.signal });
|
|
10119
10119
|
options?.onDocument?.({
|
|
10120
|
-
formatVersion:
|
|
10120
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
10121
10121
|
content,
|
|
10122
10122
|
layout
|
|
10123
10123
|
});
|
|
@@ -10130,7 +10130,7 @@ function pdfToOds(bytes, options) {
|
|
|
10130
10130
|
});
|
|
10131
10131
|
const content = reconstructSpreadsheet(layout, { signal: options?.signal });
|
|
10132
10132
|
options?.onDocument?.({
|
|
10133
|
-
formatVersion:
|
|
10133
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
10134
10134
|
content,
|
|
10135
10135
|
layout
|
|
10136
10136
|
});
|
|
@@ -10142,7 +10142,7 @@ function odtToDocx(bytes, options) {
|
|
|
10142
10142
|
if (content.kind !== "wordprocessing") throw new Error("readOdtContent returned a non-wordprocessing ContentDocument");
|
|
10143
10143
|
throwIfAborted(options?.signal);
|
|
10144
10144
|
options?.onDocument?.({
|
|
10145
|
-
formatVersion:
|
|
10145
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
10146
10146
|
content
|
|
10147
10147
|
});
|
|
10148
10148
|
return (0, ooxml_js.encodePackage)(buildDocxPackage(content));
|
|
@@ -10153,7 +10153,7 @@ function docxToOdt(bytes, options) {
|
|
|
10153
10153
|
if (content.kind !== "wordprocessing") throw new Error("readDocxContent returned a non-wordprocessing ContentDocument");
|
|
10154
10154
|
throwIfAborted(options?.signal);
|
|
10155
10155
|
options?.onDocument?.({
|
|
10156
|
-
formatVersion:
|
|
10156
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
10157
10157
|
content
|
|
10158
10158
|
});
|
|
10159
10159
|
return (0, odf_js.encodePackage)(buildOdtPackage(content));
|
|
@@ -10164,7 +10164,7 @@ function odpToPptx(bytes, options) {
|
|
|
10164
10164
|
if (content.kind !== "presentation") throw new Error("readOdpContent returned a non-presentation ContentDocument");
|
|
10165
10165
|
throwIfAborted(options?.signal);
|
|
10166
10166
|
options?.onDocument?.({
|
|
10167
|
-
formatVersion:
|
|
10167
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
10168
10168
|
content
|
|
10169
10169
|
});
|
|
10170
10170
|
return (0, ooxml_js.encodePackage)(buildPptxPackage(content));
|
|
@@ -10175,7 +10175,7 @@ function pptxToOdp(bytes, options) {
|
|
|
10175
10175
|
if (content.kind !== "presentation") throw new Error("readPptxContent returned a non-presentation ContentDocument");
|
|
10176
10176
|
throwIfAborted(options?.signal);
|
|
10177
10177
|
options?.onDocument?.({
|
|
10178
|
-
formatVersion:
|
|
10178
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
10179
10179
|
content
|
|
10180
10180
|
});
|
|
10181
10181
|
return (0, odf_js.encodePackage)(buildOdpPackage(content));
|
|
@@ -10186,7 +10186,7 @@ function odsToXlsx(bytes, options) {
|
|
|
10186
10186
|
if (content.kind !== "spreadsheet") throw new Error("readOdsContent returned a non-spreadsheet ContentDocument");
|
|
10187
10187
|
throwIfAborted(options?.signal);
|
|
10188
10188
|
options?.onDocument?.({
|
|
10189
|
-
formatVersion:
|
|
10189
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
10190
10190
|
content
|
|
10191
10191
|
});
|
|
10192
10192
|
return (0, ooxml_js.encodePackage)((0, ooxml_js.buildXlsxPackage)(content));
|
|
@@ -10198,7 +10198,7 @@ function xlsxToOds(bytes, options) {
|
|
|
10198
10198
|
if (content.kind !== "spreadsheet") throw new Error("readXlsxContent returned a non-spreadsheet ContentDocument");
|
|
10199
10199
|
throwIfAborted(options?.signal);
|
|
10200
10200
|
options?.onDocument?.({
|
|
10201
|
-
formatVersion:
|
|
10201
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
10202
10202
|
content
|
|
10203
10203
|
});
|
|
10204
10204
|
return (0, odf_js.encodePackage)(buildOdsPackage(content));
|
|
@@ -10226,7 +10226,7 @@ function inlineOdmSectionToContentSection(section, pkg) {
|
|
|
10226
10226
|
else if (node.tag === "table:table") blocks.push((0, odf_js.readOdfTable)(node, pkg));
|
|
10227
10227
|
}
|
|
10228
10228
|
return {
|
|
10229
|
-
pageSize:
|
|
10229
|
+
pageSize: document_schema_js.PAGE_SIZE_A4,
|
|
10230
10230
|
margins: INLINE_SECTION_MARGINS,
|
|
10231
10231
|
blocks
|
|
10232
10232
|
};
|
|
@@ -10743,7 +10743,7 @@ Object.defineProperty(exports, "BinaryPartSchema", {
|
|
|
10743
10743
|
Object.defineProperty(exports, "COLOR_BLACK", {
|
|
10744
10744
|
enumerable: true,
|
|
10745
10745
|
get: function() {
|
|
10746
|
-
return
|
|
10746
|
+
return document_schema_js.COLOR_BLACK;
|
|
10747
10747
|
}
|
|
10748
10748
|
});
|
|
10749
10749
|
exports.CONTENT_FORMAT_VERSION = CONTENT_FORMAT_VERSION;
|
|
@@ -10774,158 +10774,158 @@ Object.defineProperty(exports, "CompactXmlNodeSchema", {
|
|
|
10774
10774
|
Object.defineProperty(exports, "ContentBlockSchema", {
|
|
10775
10775
|
enumerable: true,
|
|
10776
10776
|
get: function() {
|
|
10777
|
-
return
|
|
10777
|
+
return document_schema_js.ContentBlockSchema;
|
|
10778
10778
|
}
|
|
10779
10779
|
});
|
|
10780
10780
|
Object.defineProperty(exports, "ContentCellValueSchema", {
|
|
10781
10781
|
enumerable: true,
|
|
10782
10782
|
get: function() {
|
|
10783
|
-
return
|
|
10783
|
+
return document_schema_js.ContentCellValueSchema;
|
|
10784
10784
|
}
|
|
10785
10785
|
});
|
|
10786
10786
|
exports.ContentDocumentSchema = ContentDocumentSchema;
|
|
10787
10787
|
Object.defineProperty(exports, "ContentDrawPageSchema", {
|
|
10788
10788
|
enumerable: true,
|
|
10789
10789
|
get: function() {
|
|
10790
|
-
return
|
|
10790
|
+
return document_schema_js.ContentDrawPageSchema;
|
|
10791
10791
|
}
|
|
10792
10792
|
});
|
|
10793
10793
|
Object.defineProperty(exports, "ContentImageBlockSchema", {
|
|
10794
10794
|
enumerable: true,
|
|
10795
10795
|
get: function() {
|
|
10796
|
-
return
|
|
10796
|
+
return document_schema_js.ContentImageBlockSchema;
|
|
10797
10797
|
}
|
|
10798
10798
|
});
|
|
10799
10799
|
Object.defineProperty(exports, "ContentPageBreakSchema", {
|
|
10800
10800
|
enumerable: true,
|
|
10801
10801
|
get: function() {
|
|
10802
|
-
return
|
|
10802
|
+
return document_schema_js.ContentPageBreakSchema;
|
|
10803
10803
|
}
|
|
10804
10804
|
});
|
|
10805
10805
|
Object.defineProperty(exports, "ContentParagraphSchema", {
|
|
10806
10806
|
enumerable: true,
|
|
10807
10807
|
get: function() {
|
|
10808
|
-
return
|
|
10808
|
+
return document_schema_js.ContentParagraphSchema;
|
|
10809
10809
|
}
|
|
10810
10810
|
});
|
|
10811
10811
|
Object.defineProperty(exports, "ContentPathPointSchema", {
|
|
10812
10812
|
enumerable: true,
|
|
10813
10813
|
get: function() {
|
|
10814
|
-
return
|
|
10814
|
+
return document_schema_js.ContentPathPointSchema;
|
|
10815
10815
|
}
|
|
10816
10816
|
});
|
|
10817
10817
|
Object.defineProperty(exports, "ContentPathSegmentSchema", {
|
|
10818
10818
|
enumerable: true,
|
|
10819
10819
|
get: function() {
|
|
10820
|
-
return
|
|
10820
|
+
return document_schema_js.ContentPathSegmentSchema;
|
|
10821
10821
|
}
|
|
10822
10822
|
});
|
|
10823
10823
|
Object.defineProperty(exports, "ContentRunSchema", {
|
|
10824
10824
|
enumerable: true,
|
|
10825
10825
|
get: function() {
|
|
10826
|
-
return
|
|
10826
|
+
return document_schema_js.ContentRunSchema;
|
|
10827
10827
|
}
|
|
10828
10828
|
});
|
|
10829
10829
|
Object.defineProperty(exports, "ContentSectionSchema", {
|
|
10830
10830
|
enumerable: true,
|
|
10831
10831
|
get: function() {
|
|
10832
|
-
return
|
|
10832
|
+
return document_schema_js.ContentSectionSchema;
|
|
10833
10833
|
}
|
|
10834
10834
|
});
|
|
10835
10835
|
Object.defineProperty(exports, "ContentShapeSchema", {
|
|
10836
10836
|
enumerable: true,
|
|
10837
10837
|
get: function() {
|
|
10838
|
-
return
|
|
10838
|
+
return document_schema_js.ContentShapeSchema;
|
|
10839
10839
|
}
|
|
10840
10840
|
});
|
|
10841
10841
|
Object.defineProperty(exports, "ContentSheetCellSchema", {
|
|
10842
10842
|
enumerable: true,
|
|
10843
10843
|
get: function() {
|
|
10844
|
-
return
|
|
10844
|
+
return document_schema_js.ContentSheetCellSchema;
|
|
10845
10845
|
}
|
|
10846
10846
|
});
|
|
10847
10847
|
Object.defineProperty(exports, "ContentSheetColumnSchema", {
|
|
10848
10848
|
enumerable: true,
|
|
10849
10849
|
get: function() {
|
|
10850
|
-
return
|
|
10850
|
+
return document_schema_js.ContentSheetColumnSchema;
|
|
10851
10851
|
}
|
|
10852
10852
|
});
|
|
10853
10853
|
Object.defineProperty(exports, "ContentSheetPrintRangeSchema", {
|
|
10854
10854
|
enumerable: true,
|
|
10855
10855
|
get: function() {
|
|
10856
|
-
return
|
|
10856
|
+
return document_schema_js.ContentSheetPrintRangeSchema;
|
|
10857
10857
|
}
|
|
10858
10858
|
});
|
|
10859
10859
|
Object.defineProperty(exports, "ContentSheetPrintSettingsSchema", {
|
|
10860
10860
|
enumerable: true,
|
|
10861
10861
|
get: function() {
|
|
10862
|
-
return
|
|
10862
|
+
return document_schema_js.ContentSheetPrintSettingsSchema;
|
|
10863
10863
|
}
|
|
10864
10864
|
});
|
|
10865
10865
|
Object.defineProperty(exports, "ContentSheetRepeatRangeSchema", {
|
|
10866
10866
|
enumerable: true,
|
|
10867
10867
|
get: function() {
|
|
10868
|
-
return
|
|
10868
|
+
return document_schema_js.ContentSheetRepeatRangeSchema;
|
|
10869
10869
|
}
|
|
10870
10870
|
});
|
|
10871
10871
|
Object.defineProperty(exports, "ContentSheetRowSchema", {
|
|
10872
10872
|
enumerable: true,
|
|
10873
10873
|
get: function() {
|
|
10874
|
-
return
|
|
10874
|
+
return document_schema_js.ContentSheetRowSchema;
|
|
10875
10875
|
}
|
|
10876
10876
|
});
|
|
10877
10877
|
Object.defineProperty(exports, "ContentSheetSchema", {
|
|
10878
10878
|
enumerable: true,
|
|
10879
10879
|
get: function() {
|
|
10880
|
-
return
|
|
10880
|
+
return document_schema_js.ContentSheetSchema;
|
|
10881
10881
|
}
|
|
10882
10882
|
});
|
|
10883
10883
|
Object.defineProperty(exports, "ContentSlideSchema", {
|
|
10884
10884
|
enumerable: true,
|
|
10885
10885
|
get: function() {
|
|
10886
|
-
return
|
|
10886
|
+
return document_schema_js.ContentSlideSchema;
|
|
10887
10887
|
}
|
|
10888
10888
|
});
|
|
10889
10889
|
Object.defineProperty(exports, "ContentStrokeSchema", {
|
|
10890
10890
|
enumerable: true,
|
|
10891
10891
|
get: function() {
|
|
10892
|
-
return
|
|
10892
|
+
return document_schema_js.ContentStrokeSchema;
|
|
10893
10893
|
}
|
|
10894
10894
|
});
|
|
10895
10895
|
Object.defineProperty(exports, "ContentSubpathSchema", {
|
|
10896
10896
|
enumerable: true,
|
|
10897
10897
|
get: function() {
|
|
10898
|
-
return
|
|
10898
|
+
return document_schema_js.ContentSubpathSchema;
|
|
10899
10899
|
}
|
|
10900
10900
|
});
|
|
10901
10901
|
Object.defineProperty(exports, "ContentTableCellSchema", {
|
|
10902
10902
|
enumerable: true,
|
|
10903
10903
|
get: function() {
|
|
10904
|
-
return
|
|
10904
|
+
return document_schema_js.ContentTableCellSchema;
|
|
10905
10905
|
}
|
|
10906
10906
|
});
|
|
10907
10907
|
Object.defineProperty(exports, "ContentTableRowSchema", {
|
|
10908
10908
|
enumerable: true,
|
|
10909
10909
|
get: function() {
|
|
10910
|
-
return
|
|
10910
|
+
return document_schema_js.ContentTableRowSchema;
|
|
10911
10911
|
}
|
|
10912
10912
|
});
|
|
10913
10913
|
Object.defineProperty(exports, "ContentTableSchema", {
|
|
10914
10914
|
enumerable: true,
|
|
10915
10915
|
get: function() {
|
|
10916
|
-
return
|
|
10916
|
+
return document_schema_js.ContentTableSchema;
|
|
10917
10917
|
}
|
|
10918
10918
|
});
|
|
10919
10919
|
Object.defineProperty(exports, "ContentVectorSchema", {
|
|
10920
10920
|
enumerable: true,
|
|
10921
10921
|
get: function() {
|
|
10922
|
-
return
|
|
10922
|
+
return document_schema_js.ContentVectorSchema;
|
|
10923
10923
|
}
|
|
10924
10924
|
});
|
|
10925
10925
|
Object.defineProperty(exports, "DEFAULT_LAYOUT_FONT", {
|
|
10926
10926
|
enumerable: true,
|
|
10927
10927
|
get: function() {
|
|
10928
|
-
return
|
|
10928
|
+
return document_schema_js.DEFAULT_LAYOUT_FONT;
|
|
10929
10929
|
}
|
|
10930
10930
|
});
|
|
10931
10931
|
Object.defineProperty(exports, "DefinedNameSchema", {
|
|
@@ -10953,7 +10953,7 @@ exports.HsqldbScriptParseError = HsqldbScriptParseError;
|
|
|
10953
10953
|
Object.defineProperty(exports, "LAYOUT_FORMAT_VERSION", {
|
|
10954
10954
|
enumerable: true,
|
|
10955
10955
|
get: function() {
|
|
10956
|
-
return
|
|
10956
|
+
return document_schema_js.LAYOUT_FORMAT_VERSION;
|
|
10957
10957
|
}
|
|
10958
10958
|
});
|
|
10959
10959
|
Object.defineProperty(exports, "NOOP_DIAGNOSTIC_SINK", {
|
|
@@ -10993,13 +10993,13 @@ exports.OdtTableRow = OdtTableRow;
|
|
|
10993
10993
|
Object.defineProperty(exports, "PAGE_SIZE_A4", {
|
|
10994
10994
|
enumerable: true,
|
|
10995
10995
|
get: function() {
|
|
10996
|
-
return
|
|
10996
|
+
return document_schema_js.PAGE_SIZE_A4;
|
|
10997
10997
|
}
|
|
10998
10998
|
});
|
|
10999
10999
|
Object.defineProperty(exports, "PAGE_SIZE_LETTER", {
|
|
11000
11000
|
enumerable: true,
|
|
11001
11001
|
get: function() {
|
|
11002
|
-
return
|
|
11002
|
+
return document_schema_js.PAGE_SIZE_LETTER;
|
|
11003
11003
|
}
|
|
11004
11004
|
});
|
|
11005
11005
|
Object.defineProperty(exports, "PackageSchema", {
|
|
@@ -11034,13 +11034,13 @@ exports.PptxSlide = PptxSlide;
|
|
|
11034
11034
|
Object.defineProperty(exports, "SLIDE_SIZE_STANDARD", {
|
|
11035
11035
|
enumerable: true,
|
|
11036
11036
|
get: function() {
|
|
11037
|
-
return
|
|
11037
|
+
return document_schema_js.SLIDE_SIZE_STANDARD;
|
|
11038
11038
|
}
|
|
11039
11039
|
});
|
|
11040
11040
|
Object.defineProperty(exports, "SLIDE_SIZE_WIDESCREEN", {
|
|
11041
11041
|
enumerable: true,
|
|
11042
11042
|
get: function() {
|
|
11043
|
-
return
|
|
11043
|
+
return document_schema_js.SLIDE_SIZE_WIDESCREEN;
|
|
11044
11044
|
}
|
|
11045
11045
|
});
|
|
11046
11046
|
exports.XlsxBytesSchema = XlsxBytesSchema;
|
|
@@ -11213,7 +11213,7 @@ Object.defineProperty(exports, "isCompactXmlNode", {
|
|
|
11213
11213
|
Object.defineProperty(exports, "isContentBlock", {
|
|
11214
11214
|
enumerable: true,
|
|
11215
11215
|
get: function() {
|
|
11216
|
-
return
|
|
11216
|
+
return document_schema_js.isContentBlock;
|
|
11217
11217
|
}
|
|
11218
11218
|
});
|
|
11219
11219
|
exports.isMathMlElement = isMathMlElement;
|
|
@@ -11323,7 +11323,7 @@ Object.defineProperty(exports, "resolveRelationships", {
|
|
|
11323
11323
|
Object.defineProperty(exports, "rgbHexToColor", {
|
|
11324
11324
|
enumerable: true,
|
|
11325
11325
|
get: function() {
|
|
11326
|
-
return
|
|
11326
|
+
return document_schema_js.rgbHexToColor;
|
|
11327
11327
|
}
|
|
11328
11328
|
});
|
|
11329
11329
|
Object.defineProperty(exports, "rootElement", {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Attribute, AttributeSchema, BinaryPart, BinaryPartSchema, Comment, CommentSchema, CompactAttrPairs, CompactPackage, CompactPackageSchema, CompactPart, CompactPartSchema, CompactXmlNode, CompactXmlNodeSchema, DefinedName, DefinedNameSchema, Package, Package as Package$1, PackageSchema, Part, PartSchema, Relationship, XmlCdata, XmlCdataSchema, XmlComment, XmlCommentSchema, XmlDeclaration, XmlDeclarationSchema, XmlElement, XmlElement as XmlElement$1, XmlElementSchema, XmlNode, XmlNode as XmlNode$1, XmlNodeSchema, XmlPart, XmlPartSchema, XmlPi, XmlPiSchema, XmlText, XmlTextSchema, attr, base64ToBytes, buildXml, bytesToBase64, childrenWithTag, compactCodec, compactPackageCodec, decodeCompactPackage, decodeEntities, decodePackage, elementsWithTag, encodeCompactPackage, encodePackage, fromCompact, isCompactXmlNode, isXmlNode, packageCodec, parsePackage, parseXml, resolveRelationships, rootElement, serializePackage, textContent as textContent$1, toCompact, unzipPackage, walk, xmlCodec, zipPackage } from "ooxml.js";
|
|
2
|
-
import { Alignment, Box, Box as Box$1, COLOR_BLACK, Color, Color as LayoutColor, ContentBlock, ContentBlockSchema, ContentCellValue, ContentCellValue as ContentCellValue$1, ContentCellValueSchema, ContentDrawPage, ContentDrawPageSchema, ContentImageBlock, ContentImageBlockSchema, ContentListMembership, ContentListMembership as ContentListMembership$1, ContentPageBreak, ContentPageBreakSchema, ContentParagraph, ContentParagraphSchema, ContentPathPoint, ContentPathPoint as ContentPathPoint$1, ContentPathPointSchema, ContentPathSegment, ContentPathSegmentSchema, ContentRun, ContentRun as ContentRun$1, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSheet, ContentSheetCell, ContentSheetCellSchema, ContentSheetColumn, ContentSheetColumnSchema, ContentSheetImage, ContentSheetPrintRange, ContentSheetPrintRangeSchema, ContentSheetPrintSettings, ContentSheetPrintSettings as ContentSheetPrintSettings$1, ContentSheetPrintSettingsSchema, ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, ContentSlide, ContentSlideSchema, ContentStroke, ContentStroke as ContentStroke$1, ContentStrokeSchema, ContentSubpath, ContentSubpath as ContentSubpath$1, ContentSubpathSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, ContentVector, ContentVectorSchema, DEFAULT_LAYOUT_FONT, DocumentPackage, LAYOUT_FORMAT_VERSION, LayoutDocument, LayoutDocument as LayoutDocument$1, LayoutEllipse, LayoutFont, LayoutImage, LayoutImageAsset, LayoutItem, LayoutLine, LayoutLink, LayoutMetadata, LayoutMetadata as LayoutMetadata$1, LayoutPage, LayoutPath, LayoutPathSegment, LayoutRect, LayoutSubpath, LayoutText, Margins, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSize, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, isContentBlock, rgbHexToColor } from "document-
|
|
2
|
+
import { Alignment, Box, Box as Box$1, COLOR_BLACK, Color, Color as LayoutColor, ContentBlock, ContentBlockSchema, ContentCellValue, ContentCellValue as ContentCellValue$1, ContentCellValueSchema, ContentDrawPage, ContentDrawPageSchema, ContentImageBlock, ContentImageBlockSchema, ContentListMembership, ContentListMembership as ContentListMembership$1, ContentPageBreak, ContentPageBreakSchema, ContentParagraph, ContentParagraphSchema, ContentPathPoint, ContentPathPoint as ContentPathPoint$1, ContentPathPointSchema, ContentPathSegment, ContentPathSegmentSchema, ContentRun, ContentRun as ContentRun$1, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSheet, ContentSheetCell, ContentSheetCellSchema, ContentSheetColumn, ContentSheetColumnSchema, ContentSheetImage, ContentSheetPrintRange, ContentSheetPrintRangeSchema, ContentSheetPrintSettings, ContentSheetPrintSettings as ContentSheetPrintSettings$1, ContentSheetPrintSettingsSchema, ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, ContentSlide, ContentSlideSchema, ContentStroke, ContentStroke as ContentStroke$1, ContentStrokeSchema, ContentSubpath, ContentSubpath as ContentSubpath$1, ContentSubpathSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, ContentVector, ContentVectorSchema, DEFAULT_LAYOUT_FONT, DocumentPackage, LAYOUT_FORMAT_VERSION, LayoutDocument, LayoutDocument as LayoutDocument$1, LayoutEllipse, LayoutFont, LayoutImage, LayoutImageAsset, LayoutItem, LayoutLine, LayoutLink, LayoutMetadata, LayoutMetadata as LayoutMetadata$1, LayoutPage, LayoutPath, LayoutPathSegment, LayoutRect, LayoutSubpath, LayoutText, Margins, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSize, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, isContentBlock, rgbHexToColor } from "document-schema.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { Package as Package$2, XmlElement as XmlElement$2, XmlNode as XmlNode$2 } from "odf.js";
|
|
5
5
|
import { LoadedMathFont, MathFont, MathFontDescriptorMetrics, NOOP_DIAGNOSTIC_SINK, PdfDiagnostic, PdfDiagnosticSeverity, PdfDiagnosticSink, PdfDiagnosticSink as PdfDiagnosticSink$1, PdfEncryptedError, PdfParseError, PositionedFormula, PositionedFormula as PositionedFormula$1, ReadPdfOptions, TextMeasurer, WinAnsiSubstitution, WinAnsiSubstitution as WinAnsiSubstitution$1, WritePdfOptions, loadMathFont, pdfCodec, readPdf, writePdf } from "pdf-codec";
|
|
@@ -29,7 +29,7 @@ declare const ContentDocumentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
29
29
|
bottomPt: z.ZodNumber;
|
|
30
30
|
leftPt: z.ZodNumber;
|
|
31
31
|
}, z.core.$strip>;
|
|
32
|
-
blocks: z.ZodArray<z.ZodCustom<import("document-
|
|
32
|
+
blocks: z.ZodArray<z.ZodCustom<import("document-schema.js").ContentBlock, import("document-schema.js").ContentBlock>>;
|
|
33
33
|
}, z.core.$strip>>;
|
|
34
34
|
}, z.core.$strip>, z.ZodObject<{
|
|
35
35
|
kind: z.ZodLiteral<"presentation">;
|
|
@@ -65,7 +65,7 @@ declare const ContentDocumentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
65
65
|
fontScale: z.ZodOptional<z.ZodNumber>;
|
|
66
66
|
lineSpacingReduction: z.ZodOptional<z.ZodNumber>;
|
|
67
67
|
sourcePath: z.ZodOptional<z.ZodString>;
|
|
68
|
-
blocks: z.ZodArray<z.ZodCustom<import("document-
|
|
68
|
+
blocks: z.ZodArray<z.ZodCustom<import("document-schema.js").ContentBlock, import("document-schema.js").ContentBlock>>;
|
|
69
69
|
}, z.core.$strip>>;
|
|
70
70
|
notes: z.ZodString;
|
|
71
71
|
}, z.core.$strip>>;
|
|
@@ -203,7 +203,7 @@ declare const ContentDocumentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
203
203
|
columns: z.ZodArray<z.ZodNumber>;
|
|
204
204
|
}, z.core.$strip>>;
|
|
205
205
|
}, z.core.$strip>;
|
|
206
|
-
embeddedObjects: z.ZodOptional<z.ZodArray<z.ZodCustom<import("document-
|
|
206
|
+
embeddedObjects: z.ZodOptional<z.ZodArray<z.ZodCustom<import("document-schema.js").ContentEmbeddedObject, import("document-schema.js").ContentEmbeddedObject>>>;
|
|
207
207
|
}, z.core.$strip>>;
|
|
208
208
|
}, z.core.$strip>, z.ZodObject<{
|
|
209
209
|
kind: z.ZodLiteral<"drawing">;
|
|
@@ -239,7 +239,7 @@ declare const ContentDocumentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
239
239
|
fontScale: z.ZodOptional<z.ZodNumber>;
|
|
240
240
|
lineSpacingReduction: z.ZodOptional<z.ZodNumber>;
|
|
241
241
|
sourcePath: z.ZodOptional<z.ZodString>;
|
|
242
|
-
blocks: z.ZodArray<z.ZodCustom<import("document-
|
|
242
|
+
blocks: z.ZodArray<z.ZodCustom<import("document-schema.js").ContentBlock, import("document-schema.js").ContentBlock>>;
|
|
243
243
|
}, z.core.$strip>>;
|
|
244
244
|
vectors: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
245
245
|
kind: z.ZodLiteral<"rect">;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Attribute, AttributeSchema, BinaryPart, BinaryPartSchema, Comment, CommentSchema, CompactAttrPairs, CompactPackage, CompactPackageSchema, CompactPart, CompactPartSchema, CompactXmlNode, CompactXmlNodeSchema, DefinedName, DefinedNameSchema, Package, Package as Package$1, PackageSchema, Part, PartSchema, Relationship, XmlCdata, XmlCdataSchema, XmlComment, XmlCommentSchema, XmlDeclaration, XmlDeclarationSchema, XmlElement, XmlElement as XmlElement$1, XmlElementSchema, XmlNode, XmlNode as XmlNode$1, XmlNodeSchema, XmlPart, XmlPartSchema, XmlPi, XmlPiSchema, XmlText, XmlTextSchema, attr, base64ToBytes, buildXml, bytesToBase64, childrenWithTag, compactCodec, compactPackageCodec, decodeCompactPackage, decodeEntities, decodePackage, elementsWithTag, encodeCompactPackage, encodePackage, fromCompact, isCompactXmlNode, isXmlNode, packageCodec, parsePackage, parseXml, resolveRelationships, rootElement, serializePackage, textContent as textContent$1, toCompact, unzipPackage, walk, xmlCodec, zipPackage } from "ooxml.js";
|
|
2
|
-
import { Alignment, Box, Box as Box$1, COLOR_BLACK, Color, Color as LayoutColor, ContentBlock, ContentBlockSchema, ContentCellValue, ContentCellValue as ContentCellValue$1, ContentCellValueSchema, ContentDrawPage, ContentDrawPageSchema, ContentImageBlock, ContentImageBlockSchema, ContentListMembership, ContentListMembership as ContentListMembership$1, ContentPageBreak, ContentPageBreakSchema, ContentParagraph, ContentParagraphSchema, ContentPathPoint, ContentPathPoint as ContentPathPoint$1, ContentPathPointSchema, ContentPathSegment, ContentPathSegmentSchema, ContentRun, ContentRun as ContentRun$1, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSheet, ContentSheetCell, ContentSheetCellSchema, ContentSheetColumn, ContentSheetColumnSchema, ContentSheetImage, ContentSheetPrintRange, ContentSheetPrintRangeSchema, ContentSheetPrintSettings, ContentSheetPrintSettings as ContentSheetPrintSettings$1, ContentSheetPrintSettingsSchema, ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, ContentSlide, ContentSlideSchema, ContentStroke, ContentStroke as ContentStroke$1, ContentStrokeSchema, ContentSubpath, ContentSubpath as ContentSubpath$1, ContentSubpathSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, ContentVector, ContentVectorSchema, DEFAULT_LAYOUT_FONT, DocumentPackage, LAYOUT_FORMAT_VERSION, LayoutDocument, LayoutDocument as LayoutDocument$1, LayoutEllipse, LayoutFont, LayoutImage, LayoutImageAsset, LayoutItem, LayoutLine, LayoutLink, LayoutMetadata, LayoutMetadata as LayoutMetadata$1, LayoutPage, LayoutPath, LayoutPathSegment, LayoutRect, LayoutSubpath, LayoutText, Margins, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSize, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, isContentBlock, rgbHexToColor } from "document-
|
|
2
|
+
import { Alignment, Box, Box as Box$1, COLOR_BLACK, Color, Color as LayoutColor, ContentBlock, ContentBlockSchema, ContentCellValue, ContentCellValue as ContentCellValue$1, ContentCellValueSchema, ContentDrawPage, ContentDrawPageSchema, ContentImageBlock, ContentImageBlockSchema, ContentListMembership, ContentListMembership as ContentListMembership$1, ContentPageBreak, ContentPageBreakSchema, ContentParagraph, ContentParagraphSchema, ContentPathPoint, ContentPathPoint as ContentPathPoint$1, ContentPathPointSchema, ContentPathSegment, ContentPathSegmentSchema, ContentRun, ContentRun as ContentRun$1, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSheet, ContentSheetCell, ContentSheetCellSchema, ContentSheetColumn, ContentSheetColumnSchema, ContentSheetImage, ContentSheetPrintRange, ContentSheetPrintRangeSchema, ContentSheetPrintSettings, ContentSheetPrintSettings as ContentSheetPrintSettings$1, ContentSheetPrintSettingsSchema, ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, ContentSlide, ContentSlideSchema, ContentStroke, ContentStroke as ContentStroke$1, ContentStrokeSchema, ContentSubpath, ContentSubpath as ContentSubpath$1, ContentSubpathSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, ContentVector, ContentVectorSchema, DEFAULT_LAYOUT_FONT, DocumentPackage, LAYOUT_FORMAT_VERSION, LayoutDocument, LayoutDocument as LayoutDocument$1, LayoutEllipse, LayoutFont, LayoutImage, LayoutImageAsset, LayoutItem, LayoutLine, LayoutLink, LayoutMetadata, LayoutMetadata as LayoutMetadata$1, LayoutPage, LayoutPath, LayoutPathSegment, LayoutRect, LayoutSubpath, LayoutText, Margins, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSize, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, isContentBlock, rgbHexToColor } from "document-schema.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { Package as Package$2, XmlElement as XmlElement$2, XmlNode as XmlNode$2 } from "odf.js";
|
|
5
5
|
import { LoadedMathFont, MathFont, MathFontDescriptorMetrics, NOOP_DIAGNOSTIC_SINK, PdfDiagnostic, PdfDiagnosticSeverity, PdfDiagnosticSink, PdfDiagnosticSink as PdfDiagnosticSink$1, PdfEncryptedError, PdfParseError, PositionedFormula, PositionedFormula as PositionedFormula$1, ReadPdfOptions, TextMeasurer, WinAnsiSubstitution, WinAnsiSubstitution as WinAnsiSubstitution$1, WritePdfOptions, loadMathFont, pdfCodec, readPdf, writePdf } from "pdf-codec";
|
|
@@ -29,7 +29,7 @@ declare const ContentDocumentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
29
29
|
bottomPt: z.ZodNumber;
|
|
30
30
|
leftPt: z.ZodNumber;
|
|
31
31
|
}, z.core.$strip>;
|
|
32
|
-
blocks: z.ZodArray<z.ZodCustom<import("document-
|
|
32
|
+
blocks: z.ZodArray<z.ZodCustom<import("document-schema.js").ContentBlock, import("document-schema.js").ContentBlock>>;
|
|
33
33
|
}, z.core.$strip>>;
|
|
34
34
|
}, z.core.$strip>, z.ZodObject<{
|
|
35
35
|
kind: z.ZodLiteral<"presentation">;
|
|
@@ -65,7 +65,7 @@ declare const ContentDocumentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
65
65
|
fontScale: z.ZodOptional<z.ZodNumber>;
|
|
66
66
|
lineSpacingReduction: z.ZodOptional<z.ZodNumber>;
|
|
67
67
|
sourcePath: z.ZodOptional<z.ZodString>;
|
|
68
|
-
blocks: z.ZodArray<z.ZodCustom<import("document-
|
|
68
|
+
blocks: z.ZodArray<z.ZodCustom<import("document-schema.js").ContentBlock, import("document-schema.js").ContentBlock>>;
|
|
69
69
|
}, z.core.$strip>>;
|
|
70
70
|
notes: z.ZodString;
|
|
71
71
|
}, z.core.$strip>>;
|
|
@@ -203,7 +203,7 @@ declare const ContentDocumentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
203
203
|
columns: z.ZodArray<z.ZodNumber>;
|
|
204
204
|
}, z.core.$strip>>;
|
|
205
205
|
}, z.core.$strip>;
|
|
206
|
-
embeddedObjects: z.ZodOptional<z.ZodArray<z.ZodCustom<import("document-
|
|
206
|
+
embeddedObjects: z.ZodOptional<z.ZodArray<z.ZodCustom<import("document-schema.js").ContentEmbeddedObject, import("document-schema.js").ContentEmbeddedObject>>>;
|
|
207
207
|
}, z.core.$strip>>;
|
|
208
208
|
}, z.core.$strip>, z.ZodObject<{
|
|
209
209
|
kind: z.ZodLiteral<"drawing">;
|
|
@@ -239,7 +239,7 @@ declare const ContentDocumentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
239
239
|
fontScale: z.ZodOptional<z.ZodNumber>;
|
|
240
240
|
lineSpacingReduction: z.ZodOptional<z.ZodNumber>;
|
|
241
241
|
sourcePath: z.ZodOptional<z.ZodString>;
|
|
242
|
-
blocks: z.ZodArray<z.ZodCustom<import("document-
|
|
242
|
+
blocks: z.ZodArray<z.ZodCustom<import("document-schema.js").ContentBlock, import("document-schema.js").ContentBlock>>;
|
|
243
243
|
}, z.core.$strip>>;
|
|
244
244
|
vectors: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
245
245
|
kind: z.ZodLiteral<"rect">;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AttributeSchema, BinaryPartSchema, CommentSchema, CompactPackageSchema, CompactPartSchema, CompactXmlNodeSchema, DefinedNameSchema, PackageSchema, PartSchema, XmlCdataSchema, XmlCommentSchema, XmlDeclarationSchema, XmlElementSchema, XmlNodeSchema, XmlPartSchema, XmlPiSchema, XmlTextSchema, attr, attr as attr$1, base64ToBytes, base64ToBytes as base64ToBytes$1, buildXlsxPackage, buildXml, bytesToBase64, bytesToBase64 as bytesToBase64$1, childrenWithTag, compactCodec, compactPackageCodec, decodeCompactPackage, decodeEntities, decodePackage, decodePackage as decodePackage$1, elementsWithTag, elementsWithTag as elementsWithTag$1, encodeCompactPackage, encodePackage, encodePackage as encodePackage$1, fromCompact, isCompactXmlNode, isXmlNode, packageCodec, parsePackage, parseXml, readDocx, readPptx, readXlsxContent, resolveRelationships, resolveRelationships as resolveRelationships$1, rootElement, rootElement as rootElement$1, serializePackage, textContent as textContent$1, textContent as textContent$2, toCompact, unzipPackage, walk, xmlCodec, zipPackage } from "ooxml.js";
|
|
2
|
-
import { COLOR_BLACK, COLOR_BLACK as COLOR_BLACK$1, ContentBlockSchema, ContentCellValueSchema, ContentDrawPageSchema, ContentDrawPageSchema as ContentDrawPageSchema$1, ContentImageBlockSchema, ContentPageBreakSchema, ContentParagraphSchema, ContentPathPointSchema, ContentPathSegmentSchema, ContentRunSchema, ContentSectionSchema, ContentSectionSchema as ContentSectionSchema$1, ContentShapeSchema, ContentSheetCellSchema, ContentSheetColumnSchema, ContentSheetPrintRangeSchema, ContentSheetPrintSettingsSchema, ContentSheetRepeatRangeSchema, ContentSheetRowSchema, ContentSheetSchema, ContentSheetSchema as ContentSheetSchema$1, ContentSlideSchema, ContentSlideSchema as ContentSlideSchema$1, ContentStrokeSchema, ContentSubpathSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, ContentVectorSchema, DEFAULT_LAYOUT_FONT, DOCUMENT_PACKAGE_FORMAT_VERSION, LAYOUT_FORMAT_VERSION, LAYOUT_FORMAT_VERSION as LAYOUT_FORMAT_VERSION$1, LayoutMetadataSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, colorToRgbHex, isContentBlock, rgbHexToColor } from "document-
|
|
2
|
+
import { COLOR_BLACK, COLOR_BLACK as COLOR_BLACK$1, ContentBlockSchema, ContentCellValueSchema, ContentDrawPageSchema, ContentDrawPageSchema as ContentDrawPageSchema$1, ContentImageBlockSchema, ContentPageBreakSchema, ContentParagraphSchema, ContentPathPointSchema, ContentPathSegmentSchema, ContentRunSchema, ContentSectionSchema, ContentSectionSchema as ContentSectionSchema$1, ContentShapeSchema, ContentSheetCellSchema, ContentSheetColumnSchema, ContentSheetPrintRangeSchema, ContentSheetPrintSettingsSchema, ContentSheetRepeatRangeSchema, ContentSheetRowSchema, ContentSheetSchema, ContentSheetSchema as ContentSheetSchema$1, ContentSlideSchema, ContentSlideSchema as ContentSlideSchema$1, ContentStrokeSchema, ContentSubpathSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, ContentVectorSchema, DEFAULT_LAYOUT_FONT, DOCUMENT_PACKAGE_FORMAT_VERSION, LAYOUT_FORMAT_VERSION, LAYOUT_FORMAT_VERSION as LAYOUT_FORMAT_VERSION$1, LayoutMetadataSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, colorToRgbHex, isContentBlock, rgbHexToColor } from "document-schema.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { ODF_MEDIA_TYPES, StyleRegistry, applyOdfTransform, attrValue, base64ToBytes as base64ToBytes$2, buildOdfSubpaths, bytesToBase64 as bytesToBase64$2, childrenWithTag as childrenWithTag$1, decodeOdfText, decodePackage as decodePackage$2, encodePackage as encodePackage$2, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, parseBox, parseCellReference, parseLinePoints, parseMargins, parseOdfColor, parseOdfLength, parseOdfPathData, parseOdfViewBox, parsePageSize, readDrawFrame, readManifest, readOdbInventory, readOdfFormula, readOdfMetadata, readOdfParagraph, readOdfTable, readOdg, readOdm, readOdp, readOds, readOdt, resolveOdfShapeGeometry, resolvePageLayoutProperties, resolveStyle, rootElement as rootElement$2, setDocumentMediaType, syncManifest, syncManifest as syncManifest$1, xmlnsAttributes } from "odf.js";
|
|
5
5
|
import { NOOP_DIAGNOSTIC_SINK, PdfEncryptedError, PdfParseError, STANDARD_METRICS, crc32, createStandardFontMeasurer, decodePng, loadMathFont, loadMathFont as loadMathFont$1, pdfCodec, readJpegInfo, readPdf, readPdf as readPdf$1, resolveStandardFont, rotatePointAboutCenter, wrapRunsToWidth, writePdf, writePdf as writePdf$1 } from "pdf-codec";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js.documents",
|
|
3
|
-
"version": "1.54.
|
|
3
|
+
"version": "1.54.4",
|
|
4
4
|
"description": "Bidirectional docx/pptx <-> PDF conversion and a read+write editable OOXML document model, built on ooxml.js and Zod 4 codecs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
],
|
|
51
51
|
"license": "MIT",
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"document-
|
|
53
|
+
"document-schema.js": "^1.5.3",
|
|
54
54
|
"fflate": "^0.8.3",
|
|
55
|
-
"odf.js": "^1.10.
|
|
56
|
-
"ooxml.js": "^2.2.
|
|
57
|
-
"pdf-codec": "^1.
|
|
55
|
+
"odf.js": "^1.10.3",
|
|
56
|
+
"ooxml.js": "^2.2.3",
|
|
57
|
+
"pdf-codec": "^1.1.3",
|
|
58
58
|
"zod": "^4.4.3"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|