odf.js 5.5.2 → 6.1.0
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 +49 -43
- package/dist/{build-XSm3I8LT.d.cts → build--uPsivid.d.cts} +1 -1
- package/dist/{build-Z1KRkSEB.d.ts → build-DgBE0bmv.d.ts} +1 -1
- package/dist/{cascade-DWQfTwaM.d.cts → cascade-BDkyOmoo.d.cts} +5 -5
- package/dist/{cascade-BZ7zqXhL.d.ts → cascade-CaVinmvp.d.ts} +5 -5
- package/dist/{codec-CbPSWzQ2.d.ts → codec-CyJ4gSH2.d.ts} +39 -39
- package/dist/{codec-C3i7QbVt.d.cts → codec-lz3vgEos.d.cts} +39 -39
- package/dist/codec.d.cts +1 -1
- package/dist/codec.d.ts +1 -1
- package/dist/{constructs-C1S8qlVv.d.ts → constructs-BntJjuvH.d.ts} +8 -8
- package/dist/{constructs-FLBse5UV.d.cts → constructs-BzLZy5YP.d.cts} +8 -8
- package/dist/{embedded-CBTvjVKb.cjs → embedded-BsO-SvtW.cjs} +2 -2
- package/dist/{embedded-Zv8KtFUo.d.ts → embedded-C8tiMCE_.d.ts} +3 -3
- package/dist/{embedded-D2MXjcFm.js → embedded-UQQNFd5U.js} +3 -3
- package/dist/{embedded-BzPTTzdf.d.cts → embedded-tlaHMady.d.cts} +3 -3
- package/dist/{form-RJTtSmwn.d.ts → form-D6XHM5SR.d.ts} +3 -3
- package/dist/{form-CWWCkG-r.d.cts → form-coDwVdjG.d.cts} +3 -3
- package/dist/{forms-Eh1N15Qy.d.cts → forms-Dc74fCtk.d.cts} +2 -2
- package/dist/{forms-CyLw7lpE.d.ts → forms-Eq2p1ss3.d.ts} +2 -2
- package/dist/{fragment-B1og_8uA.d.cts → fragment-9dNg-m46.d.cts} +1 -1
- package/dist/{fragment-B1ZV7T5Z.d.ts → fragment-ClgCV_if.d.ts} +1 -1
- package/dist/{geometry-lKWJ_ifA.d.cts → geometry-B7FZHSyD.d.cts} +1 -1
- package/dist/{geometry-DnhkIhAM.d.ts → geometry-BI33aJpv.d.ts} +1 -1
- package/dist/image/sniff.d.cts +1 -1
- package/dist/image/sniff.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +41 -41
- package/dist/index.d.ts +41 -41
- package/dist/index.js +1 -1
- package/dist/{list-KZeXA0mR.d.cts → list-DwTyo_B2.d.cts} +3 -3
- package/dist/{list-Qeuawtew.d.ts → list-X_GJY7P3.d.ts} +3 -3
- package/dist/{manifest-BALwu2JR.d.cts → manifest-BGs8Bbd_.d.cts} +1 -1
- package/dist/{manifest-CP1sqyGU.d.ts → manifest-Bju-_gTQ.d.ts} +1 -1
- package/dist/manifest.d.cts +1 -1
- package/dist/manifest.d.ts +1 -1
- package/dist/{masterpage-By_F05W4.d.ts → masterpage-BLK2OJ9q.d.ts} +2 -2
- package/dist/{masterpage-Bt6gxuoL.d.cts → masterpage-KqZshNGZ.d.cts} +2 -2
- package/dist/{metadata-1j1zm9Cx.d.cts → metadata-01SgHkRR.d.cts} +1 -1
- package/dist/{metadata-BXpjrAS-.d.ts → metadata-D1SOBTh8.d.ts} +1 -1
- package/dist/{mimetype-CPNMj04s.d.cts → mimetype-1BaQzNiS.d.cts} +1 -1
- package/dist/{mimetype-BfkwTeaW.d.ts → mimetype-DvMCOzmu.d.ts} +1 -1
- package/dist/mimetype.d.cts +1 -1
- package/dist/mimetype.d.ts +1 -1
- package/dist/model/node.d.cts +1 -1
- package/dist/model/node.d.ts +1 -1
- package/dist/model/package.d.cts +1 -1
- package/dist/model/package.d.ts +1 -1
- package/dist/{node-CkBWRjNR.d.cts → node-B6JX5CRX.d.cts} +1 -1
- package/dist/{node-CkBWRjNR.d.ts → node-B6JX5CRX.d.ts} +1 -1
- package/dist/{package-L24lkba-.d.cts → package-DMk9fuTI.d.cts} +1 -1
- package/dist/package-io/read.d.cts +1 -1
- package/dist/package-io/read.d.ts +1 -1
- package/dist/package-io/write.d.cts +1 -1
- package/dist/package-io/write.d.ts +1 -1
- package/dist/{package-BUojjTXf.d.ts → package-otZYrxiO.d.ts} +1 -1
- package/dist/{paragraph-hzoy-Wos.d.ts → paragraph-ByTzS8Li.d.ts} +4 -4
- package/dist/{paragraph-DaMqmhe3.d.cts → paragraph-CVULactG.d.cts} +4 -4
- package/dist/{parse-A8_8sdpX.d.ts → parse-BLukZ2z0.d.ts} +1 -1
- package/dist/{parse-CP5FLZqv.d.cts → parse-DcVtB3jT.d.cts} +1 -1
- package/dist/{path-DE7wkIcz.d.cts → path-CK0dIPgx.d.cts} +2 -2
- package/dist/{path-DE7wkIcz.d.ts → path-CK0dIPgx.d.ts} +2 -2
- package/dist/{properties-Rral02h1.d.ts → properties-CJyykyc_.d.ts} +1 -1
- package/dist/{properties-C-JKQZUD.d.cts → properties-CiIoNu2h.d.cts} +1 -1
- package/dist/{query-P-Y5DK0-.d.cts → query-C69wTkqg.d.cts} +1 -1
- package/dist/{query-sECN-7vU.d.ts → query-CbxD-WiQ.d.ts} +1 -1
- package/dist/{read-DYYxbvfo.d.ts → read-8s8AdaEd.d.ts} +2 -2
- package/dist/{read-CvjbdgH3.d.ts → read-B2jnd5eS.d.ts} +3 -3
- package/dist/{read-24g5eZw6.d.ts → read-BcxAWBB5.d.ts} +6 -6
- package/dist/read-Bo1GBjSE.d.ts +13 -0
- package/dist/{read-BnN7u9Y2.d.ts → read-C_oVZAnY.d.ts} +4 -4
- package/dist/{read-BV2an1ok.d.cts → read-D3V_MVAL.d.cts} +3 -3
- package/dist/read-D3wLfr-7.d.ts +12 -0
- package/dist/read-DHOQqjOZ.d.cts +12 -0
- package/dist/read-DSyz0YLj.d.cts +12 -0
- package/dist/read-DUOJ-1hX.d.ts +12 -0
- package/dist/{read-rwDsgR0d.d.cts → read-Dy5p1OMb.d.cts} +6 -6
- package/dist/{read-CMDEXqGw.d.ts → read-a0p7laV3.d.ts} +1 -1
- package/dist/{read-DUCm1nUv.d.cts → read-j9o0IoMq.d.cts} +4 -4
- package/dist/{read-ydLJ8bid.d.cts → read-jVX8DHs3.d.cts} +2 -2
- package/dist/{read-DzmMJPHd.d.cts → read-sawU0IWI.d.cts} +1 -1
- package/dist/read-tpfiT_n4.d.cts +13 -0
- package/dist/{registry-CphRYjDD.d.cts → registry-B-ZkdQv1.d.cts} +2 -2
- package/dist/{registry-D5RGBteE.d.ts → registry-Dajfxsbz.d.ts} +2 -2
- package/dist/{report-D6WNYaVn.d.cts → report-39DyUx5W.d.cts} +2 -2
- package/dist/{report-DbslT2OR.d.ts → report-x9RuNwmr.d.ts} +2 -2
- package/dist/{serialize-D1fti8C5.d.cts → serialize-BU7HZ8Qh.d.cts} +2 -2
- package/dist/{serialize-B-lq0LiG.d.ts → serialize-CWz84e0m.d.ts} +2 -2
- package/dist/{shapes-8o3NjBLU.d.cts → shapes-BCjeY90t.d.cts} +4 -4
- package/dist/{shapes-CCB8ydqD.d.ts → shapes-QkOsc-WT.d.ts} +4 -4
- package/dist/{sniff-DjpnUZRp.d.cts → sniff-DGOBHA0O.d.cts} +1 -1
- package/dist/{sniff-DjpnUZRp.d.ts → sniff-DGOBHA0O.d.ts} +1 -1
- package/dist/{span-KXroEGuH.d.ts → span-C3aJuEOM.d.ts} +1 -1
- package/dist/{span-BtmvlqZH.d.cts → span-DSM1SnHI.d.cts} +1 -1
- package/dist/styles/properties.d.cts +1 -1
- package/dist/styles/properties.d.ts +1 -1
- package/dist/styles/registry.d.cts +1 -1
- package/dist/styles/registry.d.ts +1 -1
- package/dist/styles/serialize.d.cts +1 -1
- package/dist/styles/serialize.d.ts +1 -1
- package/dist/styles/span.d.cts +1 -1
- package/dist/styles/span.d.ts +1 -1
- package/dist/{subdocument-BwW3FZC_.d.ts → subdocument-BhabEY9P.d.ts} +1 -1
- package/dist/{subdocument-yY8ASE4N.d.cts → subdocument-CQptFIQK.d.cts} +1 -1
- package/dist/{table-BH_Q2n_N.d.cts → table-CYvFMlP6.d.cts} +3 -3
- package/dist/{table-ByOoGcq_.d.ts → table-DclDgC5h.d.ts} +3 -3
- package/dist/{text-gJ5R0q3u.d.ts → text-Bn3C7lnm.d.ts} +1 -1
- package/dist/{text-BAi1tapc.d.cts → text-CDUCcwje.d.cts} +1 -1
- package/dist/{transform-C7GrZZdR.d.ts → transform-BFNc16LQ.d.ts} +3 -3
- package/dist/{transform-DKEjydnm.d.cts → transform-M1gbHp4j.d.cts} +3 -3
- package/dist/typed/draw/embedded.cjs +1 -1
- package/dist/typed/draw/embedded.d.cts +1 -1
- package/dist/typed/draw/embedded.d.ts +1 -1
- package/dist/typed/draw/embedded.js +1 -1
- package/dist/typed/draw/shapes.d.cts +1 -1
- package/dist/typed/draw/shapes.d.ts +1 -1
- package/dist/typed/formula/read.cjs +1 -1
- package/dist/typed/formula/read.d.cts +1 -1
- package/dist/typed/formula/read.d.ts +1 -1
- package/dist/typed/formula/read.js +2 -2
- package/dist/typed/odb/form.cjs +1 -1
- package/dist/typed/odb/form.d.cts +1 -1
- package/dist/typed/odb/form.d.ts +1 -1
- package/dist/typed/odb/form.js +1 -1
- package/dist/typed/odb/read.d.cts +1 -1
- package/dist/typed/odb/read.d.ts +1 -1
- package/dist/typed/odb/report.d.cts +1 -1
- package/dist/typed/odb/report.d.ts +1 -1
- package/dist/typed/odb/subdocument.d.cts +1 -1
- package/dist/typed/odb/subdocument.d.ts +1 -1
- package/dist/typed/odg/read.cjs +1 -1
- package/dist/typed/odg/read.d.cts +1 -1
- package/dist/typed/odg/read.d.ts +1 -1
- package/dist/typed/odg/read.js +2 -2
- package/dist/typed/odm/read.d.cts +1 -1
- package/dist/typed/odm/read.d.ts +1 -1
- package/dist/typed/odp/read.cjs +1 -1
- package/dist/typed/odp/read.d.cts +1 -1
- package/dist/typed/odp/read.d.ts +1 -1
- package/dist/typed/odp/read.js +2 -2
- package/dist/typed/ods/read.cjs +1 -1
- package/dist/typed/ods/read.d.cts +1 -1
- package/dist/typed/ods/read.d.ts +1 -1
- package/dist/typed/ods/read.js +1 -1
- package/dist/typed/odt/read.cjs +1 -1
- package/dist/typed/odt/read.d.cts +1 -1
- package/dist/typed/odt/read.d.ts +1 -1
- package/dist/typed/odt/read.js +1 -1
- package/dist/typed/shared/cascade.d.cts +1 -1
- package/dist/typed/shared/cascade.d.ts +1 -1
- package/dist/typed/shared/constructs.cjs +4 -3
- package/dist/typed/shared/constructs.d.cts +1 -1
- package/dist/typed/shared/constructs.d.ts +1 -1
- package/dist/typed/shared/constructs.js +4 -3
- package/dist/typed/shared/forms.d.cts +1 -1
- package/dist/typed/shared/forms.d.ts +1 -1
- package/dist/typed/shared/geometry.d.cts +1 -1
- package/dist/typed/shared/geometry.d.ts +1 -1
- package/dist/typed/shared/list.d.cts +1 -1
- package/dist/typed/shared/list.d.ts +1 -1
- package/dist/typed/shared/masterpage.d.cts +1 -1
- package/dist/typed/shared/masterpage.d.ts +1 -1
- package/dist/typed/shared/metadata.d.cts +1 -1
- package/dist/typed/shared/metadata.d.ts +1 -1
- package/dist/typed/shared/paragraph.cjs +1 -1
- package/dist/typed/shared/paragraph.d.cts +1 -1
- package/dist/typed/shared/paragraph.d.ts +1 -1
- package/dist/typed/shared/paragraph.js +1 -1
- package/dist/typed/shared/path.d.cts +1 -1
- package/dist/typed/shared/path.d.ts +1 -1
- package/dist/typed/shared/table.cjs +1 -1
- package/dist/typed/shared/table.d.cts +1 -1
- package/dist/typed/shared/table.d.ts +1 -1
- package/dist/typed/shared/table.js +1 -1
- package/dist/typed/shared/text.d.cts +1 -1
- package/dist/typed/shared/text.d.ts +1 -1
- package/dist/typed/shared/transform.d.cts +1 -1
- package/dist/typed/shared/transform.d.ts +1 -1
- package/dist/typed/shared/units.d.cts +1 -1
- package/dist/typed/shared/units.d.ts +1 -1
- package/dist/{units-7pCiECuP.d.cts → units-BQSNkTQZ.d.cts} +1 -1
- package/dist/{units-7pCiECuP.d.ts → units-BQSNkTQZ.d.ts} +1 -1
- package/dist/util/base64.cjs +4 -4
- package/dist/util/base64.js +4 -4
- package/dist/{write-D3kyj1Xw.d.cts → write-Crk-Yt_w.d.cts} +1 -1
- package/dist/{write-BxVkPZID.d.ts → write-R36XIZKx.d.ts} +1 -1
- package/dist/xml/build.d.cts +1 -1
- package/dist/xml/build.d.ts +1 -1
- package/dist/xml/fragment.d.cts +1 -1
- package/dist/xml/fragment.d.ts +1 -1
- package/dist/xml/parse.d.cts +1 -1
- package/dist/xml/parse.d.ts +1 -1
- package/dist/xml/query.d.cts +1 -1
- package/dist/xml/query.d.ts +1 -1
- package/package.json +2 -10
- package/dist/read-BLoaDxr_.d.ts +0 -12
- package/dist/read-C3Ei_MYc.d.cts +0 -13
- package/dist/read-CDSmR3qt.d.cts +0 -12
- package/dist/read-DJqvINGW.d.ts +0 -13
- package/dist/read-DfEHXwgn.d.ts +0 -12
- package/dist/read-IOYq80AA.d.cts +0 -12
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
`odf.js` is the ODF sibling of [`ooxml.js`](../ooxml.js/README.md), mirroring its architecture: a lossless ZIP-of-XML core that round-trips any package byte-for-content-faithful, with typed readers layered on top. Two ODF-specific differences shape the design: ODF has no relationship mechanism (inter-part references are direct paths, with an exhaustive `META-INF/manifest.xml`), and ODF has no inline/direct formatting — every formatting difference must be a named "automatic style," so `odf.js` owns a style-interning subsystem (`src/styles/`) with no OOXML equivalent.
|
|
8
8
|
|
|
9
|
-
**This package does not depend on `ooxml.js`.** `ooxml.js`'s branding and SBOM are scoped to ECMA-376/OOXML; depending on it would be the wrong signal for an OASIS-standard codec and would force a breaking `ooxml.js` release for every ODF-only fix. The small generic ZIP/XML/`Package` layer is duplicated, kept structurally identical so TypeScript's structural typing makes both packages' values interchangeable for a shared consumer like `documents.js`. Both depend on [`document-schema.js`](../document-schema.js/README.md) for the genuinely identical `ContentDocument`/`
|
|
9
|
+
**This package does not depend on `ooxml.js`.** `ooxml.js`'s branding and SBOM are scoped to ECMA-376/OOXML; depending on it would be the wrong signal for an OASIS-standard codec and would force a breaking `ooxml.js` release for every ODF-only fix. The small generic ZIP/XML/`Package` layer is duplicated, kept structurally identical so TypeScript's structural typing makes both packages' values interchangeable for a shared consumer like `documents.js`. Both depend on [`document-schema.js`](../document-schema.js/README.md) for the genuinely identical `ContentDocument`/`DocumentTree` content model.
|
|
10
10
|
|
|
11
11
|
```mermaid
|
|
12
12
|
graph TD
|
|
@@ -58,12 +58,12 @@ Under active development. Built and shipped:
|
|
|
58
58
|
- **Namespaces, media types, mimetype, manifest** (`src/ns.ts`, `src/media-type.ts`, `src/mimetype.ts`, `src/manifest.ts`) — full read and write, including `META-INF/manifest.xml` and the mimetype part's mandatory first-entry/stored/uncompressed layout.
|
|
59
59
|
- **Style interning** (`src/styles/`) — `StyleRegistry` adopts existing automatic styles, finds-or-mints on `intern()`, fingerprints on canonical serialized properties (never `JSON.stringify`), collision-checked across all four style containers.
|
|
60
60
|
- **Shared typed primitives** (`src/typed/shared/`) — unit parsing, A1 cell-reference computation with repeat-count cursor advancement, colour/geometry/master-page parsing into `document-schema.js` types, whitespace-run decoding, the read-side style cascade, shared `readOdfParagraph`/`readOdfTable`, the `draw:transform`/`draw:g` group-flattening geometry resolver, an `svg:d`/`draw:points` path parser, and `meta.xml` reading.
|
|
61
|
-
- **Typed readers, at two levels** — `readOdt`/`readOdp`/`readOdg`/`readOds`/`readOdfFormula` resolve a `Package` into a `document-schema.js` **`
|
|
61
|
+
- **Typed readers, at two levels** — `readOdt`/`readOdp`/`readOdg`/`readOds`/`readOdfFormula` resolve a `Package` into a `document-schema.js` **`DocumentTree`**: the single hierarchical artefact, with a minted styles table. Beneath each sits its `*Content` sibling (`readOdtContent`, `readOdpContent`, `readOdgContent`, `readOdsContent`, `readOdfFormulaContent`) producing the flat `ContentDocument`-level shape instead. See [Reading a document](#reading-a-document).
|
|
62
62
|
- **What each reader actually covers** — wordprocessing (`readOdt`), presentation (`readOdp`), drawing (`readOdg`: vector primitives in `draw:z-index`-aware paint order), spreadsheet (`readOds`: every `office:value-type`, cell/page-anchored images, and embedded sub-documents including charts), each expressed in `document-schema.js`'s own `ContentSection`/`ContentSlide`/`ContentDrawPage`/`ContentSheet` vocabulary — plus the fidelity construct vocabulary in `readOdt` (fields including the cross-reference displays, bookmarks and reference-marks, tracked changes, notes, annotations, divisions, index wrappers, forms, and anchored frames; see [Fidelity constructs](#fidelity-constructs)).
|
|
63
|
-
- **`readOdfFormulaMathMl`** — resolves a standalone/embedded `.odf` formula's bare-MathML `content.xml` into raw MathML nodes plus a StarMath annotation, with no pivot shaping at all. **`readOdfFormulaContent`** wraps that into a real `'formula'`-kind `ContentDocument`, and **`readOdfFormula`** into a `
|
|
63
|
+
- **`readOdfFormulaMathMl`** — resolves a standalone/embedded `.odf` formula's bare-MathML `content.xml` into raw MathML nodes plus a StarMath annotation, with no pivot shaping at all. **`readOdfFormulaContent`** wraps that into a real `'formula'`-kind `ContentDocument`, and **`readOdfFormula`** into a `DocumentTree`.
|
|
64
64
|
- **`readOdm`** — resolves a `.odm` master document into an ordered list of chapter references (`{ name, href, filterName? }`); chapters are genuinely external `.odt` files by ODF design, never cached.
|
|
65
|
-
- **`readOdbInventory`** — resolves a `.odb` into connection info, table names, query definitions (`{ name, command, escapeProcessing? }` with real SQL text), and form/report `{ name, href }` pairs. A sub-document directory is named after an opaque
|
|
66
|
-
- **`readOdbForm`/`readOdbReport`** — extract one sub-document's
|
|
65
|
+
- **`readOdbInventory`** — resolves a `.odb` into connection info, table names, query definitions (`{ name, command, escapeProcessing? }` with real SQL text), and form/report `{ name, href }` pairs. A sub-document directory is named after an opaque _persistent_ name (`forms/Obj11`), not the user-visible name.
|
|
66
|
+
- **`readOdbForm`/`readOdbReport`** — extract one sub-document's _static structure_, executing nothing: a form's control tree and data bindings, or a report's band stack, recursive group tree, bound fields, and computed expressions.
|
|
67
67
|
|
|
68
68
|
Not yet built: live-view editors and the `.odb` database-table-export subsystem. A general-purpose SQL query engine for rendering a Report against its data is **deliberately not attempted** — building even a bounded SQL engine means reimplementing HSQLDB's/Firebird's query semantics, a materially different undertaking from decoding their file formats, with unreviewed licensing questions. Gated on the requesting engineer's explicit sign-off.
|
|
69
69
|
|
|
@@ -99,70 +99,70 @@ To run a single test file: `pnpm vitest run src/path/to/file.test.ts`.
|
|
|
99
99
|
|
|
100
100
|
### Reading a document
|
|
101
101
|
|
|
102
|
-
A typed reader takes a `Package` (bytes go through `decodePackage`/`parsePackage` first) and returns a [`
|
|
102
|
+
A typed reader takes a `Package` (bytes go through `decodePackage`/`parsePackage` first) and returns a [`DocumentTree`](../document-schema.js/README.md#the-package-tree) — `document-schema.js`'s single hierarchical artefact, where structure, layout, and content are fused in one tree and a `styles` table has already been minted over it:
|
|
103
103
|
|
|
104
104
|
```ts
|
|
105
|
-
import { decodePackage, readOdt } from
|
|
105
|
+
import { decodePackage, readOdt } from "odf.js";
|
|
106
106
|
|
|
107
107
|
const pkg = decodePackage(new Uint8Array(await file.arrayBuffer()));
|
|
108
108
|
const document = readOdt(pkg);
|
|
109
109
|
|
|
110
|
-
document.kind;
|
|
111
|
-
document.metadata;
|
|
112
|
-
document.children;
|
|
113
|
-
document.styles;
|
|
110
|
+
document.kind; // 'wordprocessing'
|
|
111
|
+
document.metadata; // title, author, keywords, ... from meta.xml
|
|
112
|
+
document.children; // one section group per ContentSection, headings and lists grouped inside it
|
|
113
|
+
document.styles; // the minted styles table the tree's `style` refs name
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
One reader per format, each returning the `
|
|
116
|
+
One reader per format, each returning the `DocumentTree` arm its format produces:
|
|
117
117
|
|
|
118
|
-
| Format | Reader
|
|
119
|
-
|
|
|
120
|
-
| `.odt` | `readOdt`
|
|
121
|
-
| `.odp` | `readOdp`
|
|
122
|
-
| `.ods` | `readOds`
|
|
123
|
-
| `.odg` | `readOdg`
|
|
124
|
-
| `.odf` | `readOdfFormula` | `formula`
|
|
118
|
+
| Format | Reader | Package kind |
|
|
119
|
+
| ------ | ---------------- | ---------------- |
|
|
120
|
+
| `.odt` | `readOdt` | `wordprocessing` |
|
|
121
|
+
| `.odp` | `readOdp` | `presentation` |
|
|
122
|
+
| `.ods` | `readOds` | `spreadsheet` |
|
|
123
|
+
| `.odg` | `readOdg` | `drawing` |
|
|
124
|
+
| `.odf` | `readOdfFormula` | `formula` |
|
|
125
125
|
|
|
126
|
-
Each is assembled through `document-schema.js`'s own `
|
|
126
|
+
Each is assembled through `document-schema.js`'s own `assembleTree`, so odf.js's packages are built exactly the way every other package construction site in this family builds one. No `pages` array is populated and no node carries `frames`: a reader runs before any layout pass, and rendered page geometry is a layout engine's to report, never a reader's to invent.
|
|
127
127
|
|
|
128
128
|
### The flat `ContentDocument` level
|
|
129
129
|
|
|
130
130
|
Beneath each package-native reader sits the flat reader it is built on, unchanged in behaviour and exported under a `*Content` name. Reach for these when you work in `document-schema.js`'s flat codec-exchange form — as `documents.js`'s own conversion pipeline does — rather than in the tree:
|
|
131
131
|
|
|
132
132
|
```ts
|
|
133
|
-
import { readOdsContent, readOdfFormulaMathMl } from
|
|
133
|
+
import { readOdsContent, readOdfFormulaMathMl } from "odf.js";
|
|
134
134
|
|
|
135
|
-
const { metadata, sheets } = readOdsContent(pkg);
|
|
135
|
+
const { metadata, sheets } = readOdsContent(pkg); // the flat ContentSheet[] shape, no tree, no styles table
|
|
136
136
|
const { mathml, starMath } = readOdfFormulaMathMl(formulaPkg); // rawest of all: MathML nodes and the StarMath annotation
|
|
137
137
|
```
|
|
138
138
|
|
|
139
139
|
`readOdtContent`/`readOdpContent`/`readOdgContent`/`readOdsContent` return `{ metadata, sections | slides | pages | sheets }`; `readOdfFormulaContent` returns a whole `'formula'`-kind `ContentDocument`; `readOdfFormulaMathMl` returns the raw MathML with no pivot shaping at all. A package-native reader calls its own `*Content` sibling and reshapes that result, so the two levels are one read and can never disagree about what the file says.
|
|
140
140
|
|
|
141
|
-
Crossing between the levels is `document-schema.js`'s job, not this package's: `
|
|
141
|
+
Crossing between the levels is `document-schema.js`'s job, not this package's: `flattenTree(readOdt(pkg))` reproduces exactly what `readOdtContent(pkg)` returns, wrapped in its `ContentDocument` envelope. That equality is pinned per format against real fixture bytes in this package's own test suites.
|
|
142
142
|
|
|
143
143
|
### The primary names moved — migrating from 4.x
|
|
144
144
|
|
|
145
145
|
Every bare `readOdX` name now belongs to the package-native reader. Callers of the old flat functions rename; nothing about those functions' behaviour changed:
|
|
146
146
|
|
|
147
|
-
| 4.x
|
|
148
|
-
|
|
|
149
|
-
| `readOdt`
|
|
150
|
-
| `readOdp`
|
|
151
|
-
| `readOdg`
|
|
152
|
-
| `readOds`
|
|
153
|
-
| `readOdfFormulaDocument` | `readOdfFormulaContent` | `ContentDocument`
|
|
154
|
-
| `readOdfFormula`
|
|
147
|
+
| 4.x | 5.0 | Returns |
|
|
148
|
+
| ------------------------ | ----------------------- | -------------------- |
|
|
149
|
+
| `readOdt` | `readOdtContent` | `OdtDocument` |
|
|
150
|
+
| `readOdp` | `readOdpContent` | `OdpDocument` |
|
|
151
|
+
| `readOdg` | `readOdgContent` | `OdgDocument` |
|
|
152
|
+
| `readOds` | `readOdsContent` | `OdsDocument` |
|
|
153
|
+
| `readOdfFormulaDocument` | `readOdfFormulaContent` | `ContentDocument` |
|
|
154
|
+
| `readOdfFormula` | `readOdfFormulaMathMl` | `OdfFormulaDocument` |
|
|
155
155
|
|
|
156
|
-
The rename is a compile error at every call site, never a silent behaviour change: each new bare name returns a `
|
|
156
|
+
The rename is a compile error at every call site, never a silent behaviour change: each new bare name returns a `DocumentTree`, which is assignable to none of the old return types.
|
|
157
157
|
|
|
158
|
-
`readOdm`, `readOdbInventory`, `readOdbForm`, and `readOdbReport` are untouched, and none gains a package-native form. `readOdm`'s chapters are external file references and `readOdbInventory`/`readOdbReport` describe structure rather than content, so none of those three has a `ContentDocument` to decompose. `readOdbForm` is the exception that proves the rule rather than a fourth case of it: a form's sub-document is a complete, ordinary ODF text document, so `readOdbForm` does call `readOdtContent` on it and does return an `OdtDocument` — but that document is one component nested inside the form's own control-tree result, not the function's own top-level return value, so there is no `
|
|
158
|
+
`readOdm`, `readOdbInventory`, `readOdbForm`, and `readOdbReport` are untouched, and none gains a package-native form. `readOdm`'s chapters are external file references and `readOdbInventory`/`readOdbReport` describe structure rather than content, so none of those three has a `ContentDocument` to decompose. `readOdbForm` is the exception that proves the rule rather than a fourth case of it: a form's sub-document is a complete, ordinary ODF text document, so `readOdbForm` does call `readOdtContent` on it and does return an `OdtDocument` — but that document is one component nested inside the form's own control-tree result, not the function's own top-level return value, so there is no `DocumentTree`-native `readOdbForm` to add without changing what the function returns altogether.
|
|
159
159
|
|
|
160
160
|
### The lossless core
|
|
161
161
|
|
|
162
162
|
The ZIP-of-XML layer every reader above is built on:
|
|
163
163
|
|
|
164
164
|
```ts
|
|
165
|
-
import { decodePackage, encodePackage } from
|
|
165
|
+
import { decodePackage, encodePackage } from "odf.js";
|
|
166
166
|
|
|
167
167
|
// .odt / .ods / .odp bytes -> faithful JSON Package
|
|
168
168
|
const pkg = decodePackage(new Uint8Array(await file.arrayBuffer()));
|
|
@@ -176,10 +176,15 @@ const bytes = encodePackage(pkg);
|
|
|
176
176
|
Manifest and mimetype, ODF's own package-identity mechanism (no relationships, unlike OOXML):
|
|
177
177
|
|
|
178
178
|
```ts
|
|
179
|
-
import {
|
|
179
|
+
import {
|
|
180
|
+
readManifest,
|
|
181
|
+
syncManifest,
|
|
182
|
+
setDocumentMediaType,
|
|
183
|
+
readMimetype,
|
|
184
|
+
} from "odf.js";
|
|
180
185
|
|
|
181
186
|
const manifest = readManifest(pkg); // { entries: [{ fullPath, mediaType }, ...] }
|
|
182
|
-
setDocumentMediaType(pkg,
|
|
187
|
+
setDocumentMediaType(pkg, "application/vnd.oasis.opendocument.text"); // updates mimetype + manifest root entry atomically
|
|
183
188
|
syncManifest(pkg); // rebuilds manifest.xml to exactly match pkg's current parts
|
|
184
189
|
readMimetype(pkg); // 'application/vnd.oasis.opendocument.text'
|
|
185
190
|
```
|
|
@@ -189,9 +194,9 @@ readMimetype(pkg); // 'application/vnd.oasis.opendocument.text'
|
|
|
189
194
|
Every module is also importable directly by its own subpath, without going through the barrel:
|
|
190
195
|
|
|
191
196
|
```ts
|
|
192
|
-
import { parseOdfLength } from
|
|
197
|
+
import { parseOdfLength } from "odf.js/typed/shared/units";
|
|
193
198
|
|
|
194
|
-
parseOdfLength(
|
|
199
|
+
parseOdfLength("2.5cm"); // 70.86614173228347
|
|
195
200
|
```
|
|
196
201
|
|
|
197
202
|
Any `src/**/*.ts` module (excluding tests and `test-support/` fixtures) resolves at its path relative to `src/` — `src/manifest.ts` as `odf.js/manifest`, `src/typed/odt/read.ts` as `odf.js/typed/odt/read`, and so on.
|
|
@@ -203,7 +208,7 @@ Layered from a lossless core outward, mirroring `ooxml.js`:
|
|
|
203
208
|
- **`src/model/`** — `Package`/`XmlNode`/`XmlElement`: a duplicate-by-design copy of `ooxml.js`'s equivalent.
|
|
204
209
|
- **`src/xml/`** — XML parse/build (`fast-xml-parser`), production element/text-node construction, entity encoding, and tree-query helpers.
|
|
205
210
|
- **`src/image/`** — `sniffImageFormat`: a PNG/JPEG magic-byte sniffer consumed by `src/manifest.ts` and `src/typed/draw/shapes.ts`.
|
|
206
|
-
- **`src/zip.ts`** — takes
|
|
211
|
+
- **`src/zip.ts`** — takes _ordered_ `[path, entry]` tuples, not a `Record`, so the mimetype-first/stored/uncompressed requirement doesn't depend on insertion order surviving a Zod round trip.
|
|
207
212
|
- **`src/package-io/`** — `write.ts` hoists `mimetype` first (stored) and `META-INF/manifest.xml` second if present; never fabricates either as a side effect.
|
|
208
213
|
- **`src/manifest.ts`** — full manifest read/write; the manifest is ODF's one mandatory part, unlike `ooxml.js`'s read-only OPC-relationship stance.
|
|
209
214
|
- **`src/styles/`** — `properties.ts`/`serialize.ts` (canonical property-bag ↔ XML attributes), `registry.ts` (`StyleRegistry`, the mandatory style-interning layer), `span.ts` (character-range `text:span` wrapping).
|
|
@@ -224,7 +229,7 @@ Layered from a lossless core outward, mirroring `ooxml.js`:
|
|
|
224
229
|
|
|
225
230
|
- **Several ODF namespace URIs are not what you'd guess from the prefix.** `draw:` is `...drawing:1.0`, `number:` is `...datastyle:1.0`, `fo:`/`svg:`/`smil:` are `*-compatible:1.0`. See `src/ns.ts`.
|
|
226
231
|
- **`.odb`'s media type is `application/vnd.oasis.opendocument.base`**, not `...database`.
|
|
227
|
-
- **`dc:creator` records whoever most recently
|
|
232
|
+
- **`dc:creator` records whoever most recently _saved_ the document, not the author** — the original author is `meta:initial-creator`.
|
|
228
233
|
- **`meta:keyword` appears once per keyword**, unlike OOXML's single comma-separated `cp:keywords`.
|
|
229
234
|
- **`table:number-columns-repeated`/`-rows-repeated` must be cursor-advanced, never materialized** — real sheets have trailing repeat counts over a million.
|
|
230
235
|
- **ODF cells carry no explicit cell-reference attribute** (unlike xlsx's `r="B7"`) — `typed/shared/a1.ts` computes references from a running cursor.
|
|
@@ -233,7 +238,7 @@ Layered from a lossless core outward, mirroring `ooxml.js`:
|
|
|
233
238
|
- **`svg:fill-rule` and `draw:stroke` map onto `ContentVector.fillRule`/`ContentStroke.style`.** A dotted pattern and `"double"` stroke have no ODF vector-stroke counterpart and remain unread.
|
|
234
239
|
- **`readOdsContent`/`readTableCell` resolve cell `background`/`borders`/`alignment`/`verticalAlignment` from the real style cascade.** An explicit `fo:border-*` of `"none"`/`"hidden"` clears an inherited edge.
|
|
235
240
|
- **`readOdsContent` reads sheet-anchored drawings** — cell-anchored `draw:frame`s (coordinates relative to the cell) and page-anchored ones (in `table:shapes`). An embedded chart resolves as a `chart`-kind object whose document is a frame-sized drawing page carrying the chart's own cached data table, with the `chart:chart` element quarantined in residue. A sheet cannot carry a floating text box or bare vector; each is skipped.
|
|
236
|
-
- **`readDrawObjectReference` resolves a frame's embedded sub-document kind from its own `content.xml`, not the manifest.** A `draw:object` must be checked
|
|
241
|
+
- **`readDrawObjectReference` resolves a frame's embedded sub-document kind from its own `content.xml`, not the manifest.** A `draw:object` must be checked _before_ the frame's preview image, since an embedded-object frame also carries a preview `draw:image`.
|
|
237
242
|
|
|
238
243
|
## Fidelity constructs
|
|
239
244
|
|
|
@@ -250,7 +255,8 @@ Layered from a lossless core outward, mirroring `ooxml.js`:
|
|
|
250
255
|
- **The quarantined residue rows** — inline no-analogue constructs (`text:ruby`, `text:meta`, a heading's `text:is-list-header` flag) quarantine on their own paragraph beside the style-chain unknowns; document-level tenants nothing else owns (`xforms:model`, DDE connection declarations and `text:dde-source` links, vendor-extension elements) quarantine at the package tier on `OdtDocument.source`; `table:calculation-settings` and vendor-extension elements (Calc writes its `calcext:conditional-formats` inside each `table:table`) do the same on `OdsDocument.source`; an odp slide's presentation extras — the transition attributes off the slide's own drawing-page style, where every ODF schema version and real Impress output put them (the legacy `presentation:transition-*`/`presentation:duration` spelling and the ODF 1.2 `smil:type`/`-subtype`/`-direction`/`-fadeColor` one), plus `presentation:sound` and `anim:` trees — and every format's unmapped shape kinds (`dr3d:scene`, `draw:connector`, `draw:measure`, applet/plugin/floating-frame) quarantine on their own slide/page; an unrecognised `draw:custom-shape` preset's whole `draw:enhanced-geometry` quarantines in the text shape it degrades to; and every non-content XML part (`settings.xml`, `META-INF/manifest.rdf`, `Configurations2/…`) quarantines at the package tier keyed by its part path — never an embedded sub-document's own `Object N/` parts, which the semantic channel already carries whole.
|
|
251
256
|
|
|
252
257
|
Every read-side construct has no write-side counterpart because this package's typed layer is read-only — the honest asymmetry of a reader with no content writer; the lossless `encodePackage` layer remains the byte-fidelity tier.
|
|
253
|
-
|
|
258
|
+
|
|
259
|
+
- **An embedded Math object in a spreadsheet cell reads as `objectKind: 'formula'`** — its `content.xml` root _is_ the MathML root, so `readDrawObjectReference` falls back to `findMathRoot` and dispatches to `readOdfFormulaContent`.
|
|
254
260
|
- **A `draw:frame`'s alternative text (`svg:title`, falling back to `svg:desc`) reads into `ContentImageBlock.altText`.**
|
|
255
261
|
- **`readOdbInventory`'s `queries` carry real `db:command` SQL text**, not just names — a breaking rename from `string[]` to `OdbQueryInfo[]`.
|
|
256
262
|
- **`.odb` Form/Report structure extraction is real** (`readOdbForm`/`readOdbReport`), grounded in a genuine fixture. **A SQL/`rpt:` rendering engine to execute a query or evaluate report totals is deliberately not attempted** — see the Status section. Even a fully bounded SQL engine would not suffice to render a report: grouping breaks (`rpt:HASCHANGED`), prefix functions (`rpt:LEFT`), and running totals (`rpt:SUM`) are evaluated by Report Builder's own `rpt:` formula language, not by SQL.
|
|
@@ -266,7 +272,7 @@ Conventional Commits, enforced workspace-wide by commitlint through a root `comm
|
|
|
266
272
|
## References
|
|
267
273
|
|
|
268
274
|
- [ooxml.js](../ooxml.js/README.md) — the OOXML sibling; architecturally mirrored, deliberately not depended on.
|
|
269
|
-
- [document-schema.js](../document-schema.js/README.md) — the canonical `ContentDocument`/`
|
|
275
|
+
- [document-schema.js](../document-schema.js/README.md) — the canonical `ContentDocument`/`DocumentTree` schema both packages depend on, and the home of the `assembleTree`/`flattenTree`/`decompose`/`factorStyles` transform between the two encodings.
|
|
270
276
|
- [documents.js](https://github.com/ExaDev/documents.js) — the downstream consumer; its own `readOdtContent`/`readOdpContent`/`readOdsContent`/`readOdgContent` adapters wrap this package's flat `*Content` readers into `ContentDocument`s, adding the odt/odp formula, image, and vector detection passes those readers deliberately leave out.
|
|
271
277
|
|
|
272
278
|
## License
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { l as XmlElement } from "./node-
|
|
2
|
-
import { r as Package } from "./package-
|
|
3
|
-
import { n as StyleProperties } from "./properties-
|
|
4
|
-
import { i as StyleFamily } from "./registry-
|
|
1
|
+
import { l as XmlElement } from "./node-B6JX5CRX.cjs";
|
|
2
|
+
import { r as Package } from "./package-DMk9fuTI.cjs";
|
|
3
|
+
import { n as StyleProperties } from "./properties-CiIoNu2h.cjs";
|
|
4
|
+
import { i as StyleFamily } from "./registry-B-ZkdQv1.cjs";
|
|
5
5
|
//#region src/typed/shared/cascade.d.ts
|
|
6
6
|
interface CascadeDiagnostic {
|
|
7
|
-
severity:
|
|
7
|
+
severity: "warning";
|
|
8
8
|
message: string;
|
|
9
9
|
}
|
|
10
10
|
interface StyleCascadeResult {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { l as XmlElement } from "./node-
|
|
2
|
-
import { r as Package } from "./package-
|
|
3
|
-
import { n as StyleProperties } from "./properties-
|
|
4
|
-
import { i as StyleFamily } from "./registry-
|
|
1
|
+
import { l as XmlElement } from "./node-B6JX5CRX.js";
|
|
2
|
+
import { r as Package } from "./package-otZYrxiO.js";
|
|
3
|
+
import { n as StyleProperties } from "./properties-CJyykyc_.js";
|
|
4
|
+
import { i as StyleFamily } from "./registry-Dajfxsbz.js";
|
|
5
5
|
//#region src/typed/shared/cascade.d.ts
|
|
6
6
|
interface CascadeDiagnostic {
|
|
7
|
-
severity:
|
|
7
|
+
severity: "warning";
|
|
8
8
|
message: string;
|
|
9
9
|
}
|
|
10
10
|
interface StyleCascadeResult {
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { d as XmlNode } from "./node-
|
|
2
|
-
import { r as Package } from "./package-
|
|
3
|
-
import "./read-
|
|
4
|
-
import "./write-
|
|
5
|
-
import "./parse-
|
|
6
|
-
import "./build-
|
|
7
|
-
import "./mimetype-
|
|
8
|
-
import "./fragment-
|
|
9
|
-
import "./manifest-
|
|
10
|
-
import "./properties-
|
|
11
|
-
import "./serialize-
|
|
12
|
-
import "./registry-
|
|
13
|
-
import "./span-
|
|
14
|
-
import "./query-
|
|
1
|
+
import { d as XmlNode } from "./node-B6JX5CRX.js";
|
|
2
|
+
import { r as Package } from "./package-otZYrxiO.js";
|
|
3
|
+
import "./read-a0p7laV3.js";
|
|
4
|
+
import "./write-R36XIZKx.js";
|
|
5
|
+
import "./parse-BLukZ2z0.js";
|
|
6
|
+
import "./build-DgBE0bmv.js";
|
|
7
|
+
import "./mimetype-DvMCOzmu.js";
|
|
8
|
+
import "./fragment-ClgCV_if.js";
|
|
9
|
+
import "./manifest-Bju-_gTQ.js";
|
|
10
|
+
import "./properties-CJyykyc_.js";
|
|
11
|
+
import "./serialize-CWz84e0m.js";
|
|
12
|
+
import "./registry-Dajfxsbz.js";
|
|
13
|
+
import "./span-C3aJuEOM.js";
|
|
14
|
+
import "./query-CbxD-WiQ.js";
|
|
15
15
|
import "./color-CqXjt_to.js";
|
|
16
|
-
import "./geometry-
|
|
17
|
-
import "./text-
|
|
18
|
-
import "./cascade-
|
|
19
|
-
import "./metadata-
|
|
20
|
-
import "./list-
|
|
21
|
-
import "./paragraph-
|
|
22
|
-
import "./table-
|
|
23
|
-
import "./transform-
|
|
24
|
-
import "./masterpage-
|
|
25
|
-
import "./path-
|
|
26
|
-
import "./shapes-
|
|
27
|
-
import "./embedded-
|
|
28
|
-
import "./read-
|
|
29
|
-
import "./read-
|
|
30
|
-
import "./read-
|
|
31
|
-
import "./read-
|
|
32
|
-
import "./read-
|
|
33
|
-
import "./read-
|
|
34
|
-
import "./read-
|
|
35
|
-
import "./subdocument-
|
|
36
|
-
import "./forms-
|
|
37
|
-
import "./form-
|
|
38
|
-
import "./report-
|
|
16
|
+
import "./geometry-BI33aJpv.js";
|
|
17
|
+
import "./text-Bn3C7lnm.js";
|
|
18
|
+
import "./cascade-CaVinmvp.js";
|
|
19
|
+
import "./metadata-D1SOBTh8.js";
|
|
20
|
+
import "./list-X_GJY7P3.js";
|
|
21
|
+
import "./paragraph-ByTzS8Li.js";
|
|
22
|
+
import "./table-DclDgC5h.js";
|
|
23
|
+
import "./transform-BFNc16LQ.js";
|
|
24
|
+
import "./masterpage-BLK2OJ9q.js";
|
|
25
|
+
import "./path-CK0dIPgx.js";
|
|
26
|
+
import "./shapes-QkOsc-WT.js";
|
|
27
|
+
import "./embedded-C8tiMCE_.js";
|
|
28
|
+
import "./read-DUOJ-1hX.js";
|
|
29
|
+
import "./read-BcxAWBB5.js";
|
|
30
|
+
import "./read-D3wLfr-7.js";
|
|
31
|
+
import "./read-Bo1GBjSE.js";
|
|
32
|
+
import "./read-C_oVZAnY.js";
|
|
33
|
+
import "./read-8s8AdaEd.js";
|
|
34
|
+
import "./read-B2jnd5eS.js";
|
|
35
|
+
import "./subdocument-BhabEY9P.js";
|
|
36
|
+
import "./forms-Eq2p1ss3.js";
|
|
37
|
+
import "./form-D6XHM5SR.js";
|
|
38
|
+
import "./report-x9RuNwmr.js";
|
|
39
39
|
import { z } from "zod";
|
|
40
|
-
import { Alignment as Alignment$1, AlignmentSchema as AlignmentSchema$1,
|
|
40
|
+
import { Alignment as Alignment$1, AlignmentSchema as AlignmentSchema$1, DocumentTree as DocumentTree$1 } from "document-schema.js";
|
|
41
41
|
//#region src/codec.d.ts
|
|
42
42
|
declare const xmlCodec: z.ZodCodec<z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
43
43
|
type: z.ZodLiteral<"text">;
|
|
@@ -106,4 +106,4 @@ declare const packageCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint
|
|
|
106
106
|
declare function decodePackage(bytes: Uint8Array<ArrayBuffer>): Package;
|
|
107
107
|
declare function encodePackage(pkg: Package): Uint8Array<ArrayBuffer>;
|
|
108
108
|
//#endregion
|
|
109
|
-
export { Alignment$1 as a, xmlCodec as i, encodePackage as n, AlignmentSchema$1 as o, packageCodec as r,
|
|
109
|
+
export { Alignment$1 as a, xmlCodec as i, encodePackage as n, AlignmentSchema$1 as o, packageCodec as r, DocumentTree$1 as s, decodePackage as t };
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { d as XmlNode } from "./node-
|
|
2
|
-
import { r as Package } from "./package-
|
|
3
|
-
import "./read-
|
|
4
|
-
import "./write-
|
|
5
|
-
import "./parse-
|
|
6
|
-
import "./build
|
|
7
|
-
import "./mimetype-
|
|
8
|
-
import "./fragment-
|
|
9
|
-
import "./manifest-
|
|
10
|
-
import "./properties-
|
|
11
|
-
import "./serialize-
|
|
12
|
-
import "./registry-
|
|
13
|
-
import "./span-
|
|
14
|
-
import "./query-
|
|
1
|
+
import { d as XmlNode } from "./node-B6JX5CRX.cjs";
|
|
2
|
+
import { r as Package } from "./package-DMk9fuTI.cjs";
|
|
3
|
+
import "./read-sawU0IWI.cjs";
|
|
4
|
+
import "./write-Crk-Yt_w.cjs";
|
|
5
|
+
import "./parse-DcVtB3jT.cjs";
|
|
6
|
+
import "./build--uPsivid.cjs";
|
|
7
|
+
import "./mimetype-1BaQzNiS.cjs";
|
|
8
|
+
import "./fragment-9dNg-m46.cjs";
|
|
9
|
+
import "./manifest-BGs8Bbd_.cjs";
|
|
10
|
+
import "./properties-CiIoNu2h.cjs";
|
|
11
|
+
import "./serialize-BU7HZ8Qh.cjs";
|
|
12
|
+
import "./registry-B-ZkdQv1.cjs";
|
|
13
|
+
import "./span-DSM1SnHI.cjs";
|
|
14
|
+
import "./query-C69wTkqg.cjs";
|
|
15
15
|
import "./color-CqXjt_to.cjs";
|
|
16
|
-
import "./geometry-
|
|
17
|
-
import "./text-
|
|
18
|
-
import "./cascade-
|
|
19
|
-
import "./metadata-
|
|
20
|
-
import "./list-
|
|
21
|
-
import "./paragraph-
|
|
22
|
-
import "./table-
|
|
23
|
-
import "./transform-
|
|
24
|
-
import "./masterpage-
|
|
25
|
-
import "./path-
|
|
26
|
-
import "./shapes-
|
|
27
|
-
import "./embedded-
|
|
28
|
-
import "./read-
|
|
29
|
-
import "./read-
|
|
30
|
-
import "./read-
|
|
31
|
-
import "./read-
|
|
32
|
-
import "./read-
|
|
33
|
-
import "./read-
|
|
34
|
-
import "./read-
|
|
35
|
-
import "./subdocument-
|
|
36
|
-
import "./forms-
|
|
37
|
-
import "./form-
|
|
38
|
-
import "./report-
|
|
16
|
+
import "./geometry-B7FZHSyD.cjs";
|
|
17
|
+
import "./text-CDUCcwje.cjs";
|
|
18
|
+
import "./cascade-BDkyOmoo.cjs";
|
|
19
|
+
import "./metadata-01SgHkRR.cjs";
|
|
20
|
+
import "./list-DwTyo_B2.cjs";
|
|
21
|
+
import "./paragraph-CVULactG.cjs";
|
|
22
|
+
import "./table-CYvFMlP6.cjs";
|
|
23
|
+
import "./transform-M1gbHp4j.cjs";
|
|
24
|
+
import "./masterpage-KqZshNGZ.cjs";
|
|
25
|
+
import "./path-CK0dIPgx.cjs";
|
|
26
|
+
import "./shapes-BCjeY90t.cjs";
|
|
27
|
+
import "./embedded-tlaHMady.cjs";
|
|
28
|
+
import "./read-DHOQqjOZ.cjs";
|
|
29
|
+
import "./read-Dy5p1OMb.cjs";
|
|
30
|
+
import "./read-DSyz0YLj.cjs";
|
|
31
|
+
import "./read-tpfiT_n4.cjs";
|
|
32
|
+
import "./read-j9o0IoMq.cjs";
|
|
33
|
+
import "./read-jVX8DHs3.cjs";
|
|
34
|
+
import "./read-D3V_MVAL.cjs";
|
|
35
|
+
import "./subdocument-CQptFIQK.cjs";
|
|
36
|
+
import "./forms-Dc74fCtk.cjs";
|
|
37
|
+
import "./form-coDwVdjG.cjs";
|
|
38
|
+
import "./report-39DyUx5W.cjs";
|
|
39
39
|
import { z } from "zod";
|
|
40
|
-
import { Alignment as Alignment$1, AlignmentSchema,
|
|
40
|
+
import { Alignment as Alignment$1, AlignmentSchema, DocumentTree as DocumentTree$1 } from "document-schema.js";
|
|
41
41
|
//#region src/codec.d.ts
|
|
42
42
|
declare const xmlCodec: z.ZodCodec<z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
43
43
|
type: z.ZodLiteral<"text">;
|
|
@@ -106,4 +106,4 @@ declare const packageCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint
|
|
|
106
106
|
declare function decodePackage(bytes: Uint8Array<ArrayBuffer>): Package;
|
|
107
107
|
declare function encodePackage(pkg: Package): Uint8Array<ArrayBuffer>;
|
|
108
108
|
//#endregion
|
|
109
|
-
export { Alignment$1 as a, xmlCodec as i, encodePackage as n, AlignmentSchema as o, packageCodec as r,
|
|
109
|
+
export { Alignment$1 as a, xmlCodec as i, encodePackage as n, AlignmentSchema as o, packageCodec as r, DocumentTree$1 as s, decodePackage as t };
|
package/dist/codec.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-
|
|
1
|
+
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-lz3vgEos.cjs";
|
|
2
2
|
export { decodePackage, encodePackage, packageCodec, xmlCodec };
|
package/dist/codec.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-
|
|
1
|
+
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-CyJ4gSH2.js";
|
|
2
2
|
export { decodePackage, encodePackage, packageCodec, xmlCodec };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { d as XmlNode, l as XmlElement } from "./node-
|
|
2
|
-
import { r as Package } from "./package-
|
|
1
|
+
import { d as XmlNode, l as XmlElement } from "./node-B6JX5CRX.js";
|
|
2
|
+
import { r as Package } from "./package-otZYrxiO.js";
|
|
3
3
|
import { AnchorDescriptor, ConstructDescriptor, ContentBlock, ContentControlDescriptor, DefinitionEntry, DivisionDescriptor, FieldDescriptor, ProvenanceDescriptor, RunConstructExtent, SourceResidue } from "document-schema.js";
|
|
4
4
|
//#region src/typed/shared/constructs.d.ts
|
|
5
5
|
declare function odfFieldDescriptor(element: XmlElement): FieldDescriptor;
|
|
6
6
|
declare function odfBookmarkAnchorDescriptor(name: string): AnchorDescriptor;
|
|
7
|
-
type OdfResidueFormat =
|
|
7
|
+
type OdfResidueFormat = "odt" | "ods" | "odp" | "odg" | "odm" | "odb" | "odf";
|
|
8
8
|
declare function odfResidue(format: OdfResidueFormat, ...elements: XmlElement[]): SourceResidue;
|
|
9
9
|
declare function isOdfExtensionElement(element: XmlElement): boolean;
|
|
10
10
|
declare const ODF_UNMAPPED_SHAPE_TAGS: ReadonlySet<string>;
|
|
@@ -17,16 +17,16 @@ declare function odfDivisionDescriptor(sectionElement: XmlElement, pkg: Package)
|
|
|
17
17
|
declare const ODF_INDEX_WRAPPER_TAGS: ReadonlySet<string>;
|
|
18
18
|
declare function isOdfIndexWrapper(element: XmlElement): boolean;
|
|
19
19
|
declare function odfIndexControlDescriptor(wrapper: XmlElement): ContentControlDescriptor;
|
|
20
|
-
type OdfMarkerKind =
|
|
20
|
+
type OdfMarkerKind = "bookmark" | "referenceMark" | "change" | "annotation";
|
|
21
21
|
interface OdfMarkerHalf {
|
|
22
22
|
readonly kind: OdfMarkerKind;
|
|
23
|
-
readonly side:
|
|
23
|
+
readonly side: "start" | "end";
|
|
24
24
|
readonly key: string;
|
|
25
25
|
readonly element: XmlElement;
|
|
26
26
|
readonly parent: XmlElement;
|
|
27
27
|
readonly runPosition: number;
|
|
28
28
|
readonly order: number;
|
|
29
|
-
readonly descriptor: () => RunConstructExtent[
|
|
29
|
+
readonly descriptor: () => RunConstructExtent["descriptor"] | undefined;
|
|
30
30
|
}
|
|
31
31
|
declare function odfMarkerHalfEventIndex(half: OdfMarkerHalf, paragraphElement: XmlElement, paragraphStartIndex: number, liftedBlocksBeforeHalf?: number): number | undefined;
|
|
32
32
|
declare function isOdfBlockScopedHalf(half: OdfMarkerHalf, paragraphElement: XmlElement): boolean;
|
|
@@ -48,12 +48,12 @@ interface OdfConstructExtent {
|
|
|
48
48
|
declare function insertOdfConstructMarkers(blocks: readonly ContentBlock[], extents: readonly OdfConstructExtent[]): ContentBlock[];
|
|
49
49
|
interface OdfMarkerEvent {
|
|
50
50
|
readonly kind: OdfMarkerKind;
|
|
51
|
-
readonly side:
|
|
51
|
+
readonly side: "start" | "end";
|
|
52
52
|
readonly key: string;
|
|
53
53
|
readonly index: number;
|
|
54
54
|
readonly qualified: boolean;
|
|
55
55
|
readonly order: number;
|
|
56
|
-
readonly descriptor: () => RunConstructExtent[
|
|
56
|
+
readonly descriptor: () => RunConstructExtent["descriptor"] | undefined;
|
|
57
57
|
readonly element: XmlElement;
|
|
58
58
|
}
|
|
59
59
|
declare function resolveOdfMarkerEvents(events: readonly OdfMarkerEvent[]): {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { d as XmlNode, l as XmlElement } from "./node-
|
|
2
|
-
import { r as Package } from "./package-
|
|
1
|
+
import { d as XmlNode, l as XmlElement } from "./node-B6JX5CRX.cjs";
|
|
2
|
+
import { r as Package } from "./package-DMk9fuTI.cjs";
|
|
3
3
|
import { AnchorDescriptor, ConstructDescriptor, ContentBlock, ContentControlDescriptor, DefinitionEntry, DivisionDescriptor, FieldDescriptor, ProvenanceDescriptor, RunConstructExtent, SourceResidue } from "document-schema.js";
|
|
4
4
|
//#region src/typed/shared/constructs.d.ts
|
|
5
5
|
declare function odfFieldDescriptor(element: XmlElement): FieldDescriptor;
|
|
6
6
|
declare function odfBookmarkAnchorDescriptor(name: string): AnchorDescriptor;
|
|
7
|
-
type OdfResidueFormat =
|
|
7
|
+
type OdfResidueFormat = "odt" | "ods" | "odp" | "odg" | "odm" | "odb" | "odf";
|
|
8
8
|
declare function odfResidue(format: OdfResidueFormat, ...elements: XmlElement[]): SourceResidue;
|
|
9
9
|
declare function isOdfExtensionElement(element: XmlElement): boolean;
|
|
10
10
|
declare const ODF_UNMAPPED_SHAPE_TAGS: ReadonlySet<string>;
|
|
@@ -17,16 +17,16 @@ declare function odfDivisionDescriptor(sectionElement: XmlElement, pkg: Package)
|
|
|
17
17
|
declare const ODF_INDEX_WRAPPER_TAGS: ReadonlySet<string>;
|
|
18
18
|
declare function isOdfIndexWrapper(element: XmlElement): boolean;
|
|
19
19
|
declare function odfIndexControlDescriptor(wrapper: XmlElement): ContentControlDescriptor;
|
|
20
|
-
type OdfMarkerKind =
|
|
20
|
+
type OdfMarkerKind = "bookmark" | "referenceMark" | "change" | "annotation";
|
|
21
21
|
interface OdfMarkerHalf {
|
|
22
22
|
readonly kind: OdfMarkerKind;
|
|
23
|
-
readonly side:
|
|
23
|
+
readonly side: "start" | "end";
|
|
24
24
|
readonly key: string;
|
|
25
25
|
readonly element: XmlElement;
|
|
26
26
|
readonly parent: XmlElement;
|
|
27
27
|
readonly runPosition: number;
|
|
28
28
|
readonly order: number;
|
|
29
|
-
readonly descriptor: () => RunConstructExtent[
|
|
29
|
+
readonly descriptor: () => RunConstructExtent["descriptor"] | undefined;
|
|
30
30
|
}
|
|
31
31
|
declare function odfMarkerHalfEventIndex(half: OdfMarkerHalf, paragraphElement: XmlElement, paragraphStartIndex: number, liftedBlocksBeforeHalf?: number): number | undefined;
|
|
32
32
|
declare function isOdfBlockScopedHalf(half: OdfMarkerHalf, paragraphElement: XmlElement): boolean;
|
|
@@ -48,12 +48,12 @@ interface OdfConstructExtent {
|
|
|
48
48
|
declare function insertOdfConstructMarkers(blocks: readonly ContentBlock[], extents: readonly OdfConstructExtent[]): ContentBlock[];
|
|
49
49
|
interface OdfMarkerEvent {
|
|
50
50
|
readonly kind: OdfMarkerKind;
|
|
51
|
-
readonly side:
|
|
51
|
+
readonly side: "start" | "end";
|
|
52
52
|
readonly key: string;
|
|
53
53
|
readonly index: number;
|
|
54
54
|
readonly qualified: boolean;
|
|
55
55
|
readonly order: number;
|
|
56
|
-
readonly descriptor: () => RunConstructExtent[
|
|
56
|
+
readonly descriptor: () => RunConstructExtent["descriptor"] | undefined;
|
|
57
57
|
readonly element: XmlElement;
|
|
58
58
|
}
|
|
59
59
|
declare function resolveOdfMarkerEvents(events: readonly OdfMarkerEvent[]): {
|
|
@@ -395,7 +395,7 @@ function readOdsContent(pkg) {
|
|
|
395
395
|
}
|
|
396
396
|
function readOds(pkg) {
|
|
397
397
|
const { metadata, sheets, definitions, source } = readOdsContent(pkg);
|
|
398
|
-
const assembled = (0, document_schema_js.
|
|
398
|
+
const assembled = (0, document_schema_js.assembleTree)({
|
|
399
399
|
kind: "spreadsheet",
|
|
400
400
|
metadata,
|
|
401
401
|
sheets
|
|
@@ -747,7 +747,7 @@ function readOdtContent(pkg, options = {}) {
|
|
|
747
747
|
}
|
|
748
748
|
function readOdt(pkg, options = {}) {
|
|
749
749
|
const { metadata, sections, definitions, source } = readOdtContent(pkg, options);
|
|
750
|
-
const assembled = (0, document_schema_js.
|
|
750
|
+
const assembled = (0, document_schema_js.assembleTree)({
|
|
751
751
|
kind: "wordprocessing",
|
|
752
752
|
metadata,
|
|
753
753
|
sections
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { l as XmlElement } from "./node-
|
|
2
|
-
import { r as Package } from "./package-
|
|
3
|
-
import { l as OdfResidueFormat } from "./constructs-
|
|
1
|
+
import { l as XmlElement } from "./node-B6JX5CRX.js";
|
|
2
|
+
import { r as Package } from "./package-otZYrxiO.js";
|
|
3
|
+
import { l as OdfResidueFormat } from "./constructs-BntJjuvH.js";
|
|
4
4
|
import { Box, ContentDocument, ContentEmbeddedObjectKind, SourceResidue } from "document-schema.js";
|
|
5
5
|
//#region src/typed/draw/embedded.d.ts
|
|
6
6
|
type EmbeddedDocumentKind = ContentEmbeddedObjectKind;
|
|
@@ -16,7 +16,7 @@ import { subDocumentPackage } from "./typed/odb/subdocument.js";
|
|
|
16
16
|
import { readOdgContent } from "./typed/odg/read.js";
|
|
17
17
|
import { readOdpContent } from "./typed/odp/read.js";
|
|
18
18
|
import { readOdfFormControlConstructs } from "./typed/shared/forms.js";
|
|
19
|
-
import { PAGE_SIZE_A4,
|
|
19
|
+
import { PAGE_SIZE_A4, assembleTree } from "document-schema.js";
|
|
20
20
|
//#region src/typed/ods/read.ts
|
|
21
21
|
const CONTENT_PART$2 = "content.xml";
|
|
22
22
|
function parseKnownOdfLength$1(value) {
|
|
@@ -395,7 +395,7 @@ function readOdsContent(pkg) {
|
|
|
395
395
|
}
|
|
396
396
|
function readOds(pkg) {
|
|
397
397
|
const { metadata, sheets, definitions, source } = readOdsContent(pkg);
|
|
398
|
-
const assembled =
|
|
398
|
+
const assembled = assembleTree({
|
|
399
399
|
kind: "spreadsheet",
|
|
400
400
|
metadata,
|
|
401
401
|
sheets
|
|
@@ -747,7 +747,7 @@ function readOdtContent(pkg, options = {}) {
|
|
|
747
747
|
}
|
|
748
748
|
function readOdt(pkg, options = {}) {
|
|
749
749
|
const { metadata, sections, definitions, source } = readOdtContent(pkg, options);
|
|
750
|
-
const assembled =
|
|
750
|
+
const assembled = assembleTree({
|
|
751
751
|
kind: "wordprocessing",
|
|
752
752
|
metadata,
|
|
753
753
|
sections
|