document-cli 1.14.0 → 1.14.2

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 CHANGED
@@ -32,8 +32,6 @@ graph TD
32
32
  documents --> mcp
33
33
  pdfcodec --> mcp
34
34
  documents --> cli
35
- odf --> cli
36
- pdfcodec --> cli
37
35
 
38
36
  click schema "https://github.com/ExaDev/document-schema.js" "document-schema.js"
39
37
  click ooxml "https://github.com/ExaDev/ooxml.js" "ooxml.js"
@@ -270,7 +268,7 @@ pnpm test:smoke # tsdown, then vitest run --project smoke -- spawns the built
270
268
  - **The lazy TUI import is load-bearing, not incidental.** `src/cli.ts` computes the dispatch token before doing anything else and only reaches `await import('./tui/index.js')` on the bare/`tui` branch — every other command path (all 27 explicit conversions, `convert`, `formats`, `from-package`, `odm-to-pdf`, `odb-*`, `pdf-inspect`, `fonts`, `docx-extras`, `metadata`, `set-metadata`) never touches that import at all. This is what keeps a scripted, high-frequency CLI invocation from paying React/Ink's module-load cost on every call.
271
269
  - **A bare invocation and an explicit `tui` invocation fail differently on non-interactive stdout.** `document-cli` with no arguments and redirected stdout prints help and exits `0`, on the assumption that a bare invocation piped somewhere was more likely a forgotten argument than a deliberate TUI request. `document-cli tui` with redirected stdout is unambiguous, so it fails outright (exit `2`) rather than silently reinterpreting it as a help request.
272
270
  - **`tsdown.config.ts` disables `fixedExtension` on both build passes.** `platform: 'node'` defaults tsdown's `fixedExtension` to `true`, which would emit `dist/cli.mjs`/`dist/index.mjs` regardless of `package.json`'s own `"type": "module"` — mismatching the `.js`/`.cjs` paths `bin` and `exports` actually name. Both entries set `fixedExtension: false` explicitly so the build output matches what's published.
273
- - **`readOdbTables` needs `decodeOdbPackage` from `documents.js`, not `decodePackage`.** `documents.js`'s own `decodePackage` re-exports `ooxml.js`'s OOXML-only reader and cannot decode an ODF `.odb` container at all; `decodeDocumentPackage(format, bytes)` dispatches to `odf.js` internally for every real `DocumentFormat` member (odt/odp/ods/odg/odf), but `.odb` is deliberately not one of those (it has no PDF conversion and no write direction — see documents.js's own README), so it has no format string to pass either. `decodeOdbPackage` is the `.odb`-specific sibling that decodes the identical raw ODF container directly — `commands/odb.ts` and the TUI's `format/open-document.ts` both use it for exactly this reason. `odf.js` stays a genuine direct dependency regardless: the TUI's own ods spreadsheet grid (`screens/editors/ods/spreadsheet-grid.tsx`) imports `cellReference`/`columnIndexToLetters` from it directly for A1-style cell/column labelling, a small utility need unrelated to package decoding.
271
+ - **`readOdbTables` needs `decodeOdbPackage` from `documents.js`, not `decodePackage`.** `documents.js`'s own `decodePackage` re-exports `ooxml.js`'s OOXML-only reader and cannot decode an ODF `.odb` container at all; `decodeDocumentPackage(format, bytes)` dispatches to `odf.js` internally for every real `DocumentFormat` member (odt/odp/ods/odg/odf), but `.odb` is deliberately not one of those (it has no PDF conversion and no write direction — see documents.js's own README), so it has no format string to pass either. `decodeOdbPackage` is the `.odb`-specific sibling that decodes the identical raw ODF container directly — `commands/odb.ts` and the TUI's `format/open-document.ts` both use it for exactly this reason. `odf.js` and `pdf-codec` are devDependencies only: every runtime reach into them (the spreadsheet grid's `cellReference`/`columnIndexToLetters` for A1-style cell/column labelling, font-file inspection via `describeFontFace`) now goes through `documents.js`'s own re-exports, and `odf.js` survives in `devDependencies` solely because `src/test-support/embedded-font-fixture.ts` builds real ODF package fixtures from its low-level XML primitives.
274
272
  - **A TUI screen must call an editor's own accessors fresh on every render, never cache them.** documents.js's live-view editors (`DocxRun`, `OdtParagraph`, `OdsCell`, ...) mutate the real XML tree in place — `editor.paragraphs()`/`slide.shapes()`/`sheet.cell(r, c)` called once and stored in `useState`/`useMemo` goes stale the instant any screen mutates the underlying document, with nothing in the type system or in React to catch it (see `src/tui/state/types.ts`'s own doc comment on `Screen`).
275
273
  - **The conversions this CLI runs carry the same fidelity limits documents.js itself documents** — most notably that PDF-pivot conversions are not round-trip-lossless (line wrapping drifts under standard-14 font substitution, justified text renders left-aligned, tables and vector shapes don't reconstruct from a PDF), and that `pdf-to-ods` recovers only what a spreadsheet printed, never a real number/date/formula. None of that is specific to this CLI or the TUI; see documents.js's own README, particularly its [Fidelity](https://github.com/ExaDev/documents.js#fidelity) section, for the full, format-by-format account.
276
274
 
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as odbFormSummary, c as formatDocxExtrasLines, d as writeOutput, f as loadProvidedFonts, h as isDocumentFormat, i as formatOdbReportLines, l as readInput, m as inferFormatFromExtension, n as describeOdbReport, o as formatMetadataLines, r as formatOdbFormLines, s as presentMetadataEntries, t as describeOdbForm, u as resolveDefaultOutputPath } from "./odb-structure-CNpUdKwi.js";
2
+ import { a as odbFormSummary, c as formatDocxExtrasLines, d as writeOutput, f as loadProvidedFonts, h as isDocumentFormat, i as formatOdbReportLines, l as readInput, m as inferFormatFromExtension, n as describeOdbReport, o as formatMetadataLines, r as formatOdbFormLines, s as presentMetadataEntries, t as describeOdbForm, u as resolveDefaultOutputPath } from "./odb-structure-DePnGZAI.js";
3
3
  import { Command, CommanderError, InvalidArgumentError } from "commander";
4
4
  import { writeFile } from "node:fs/promises";
5
5
  import { basename, dirname, extname, join, resolve } from "node:path";
@@ -1059,7 +1059,7 @@ function registerSetMetadataCommand(program) {
1059
1059
  }
1060
1060
  //#endregion
1061
1061
  //#region package.json
1062
- var version = "1.14.0";
1062
+ var version = "1.14.2";
1063
1063
  //#endregion
1064
1064
  //#region src/program.ts
1065
1065
  function createProgram() {
@@ -1086,7 +1086,7 @@ function createProgram() {
1086
1086
  //#region src/cli.ts
1087
1087
  async function launchTui(startPath, signal) {
1088
1088
  try {
1089
- const { runTui } = await import("./tui-h7lEAPtd.js");
1089
+ const { runTui } = await import("./tui-Bg4JfhRZ.js");
1090
1090
  await runTui({
1091
1091
  startPath,
1092
1092
  signal
package/dist/index.cjs CHANGED
@@ -2,7 +2,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let node_fs_promises = require("node:fs/promises");
3
3
  let node_path = require("node:path");
4
4
  let documents_js = require("documents.js");
5
- let pdf_codec = require("pdf-codec");
6
5
  let node_fs = require("node:fs");
7
6
  let commander = require("commander");
8
7
  //#region src/format.ts
@@ -185,7 +184,7 @@ async function loadProvidedFonts(paths, options) {
185
184
  const fonts = [];
186
185
  for (const path of paths) {
187
186
  const bytes = new Uint8Array(await (0, node_fs_promises.readFile)(path, { signal: options?.signal }));
188
- const face = (0, pdf_codec.readFontFace)(bytes, path);
187
+ const face = (0, documents_js.describeFontFace)(bytes, path);
189
188
  fonts.push({
190
189
  family: face.family,
191
190
  bold: face.bold,
@@ -1388,7 +1387,7 @@ function registerSetMetadataCommand(program) {
1388
1387
  }
1389
1388
  //#endregion
1390
1389
  //#region package.json
1391
- var version = "1.14.0";
1390
+ var version = "1.14.2";
1392
1391
  //#endregion
1393
1392
  //#region src/program.ts
1394
1393
  function createProgram() {
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { readFile, writeFile } from "node:fs/promises";
2
2
  import { basename, dirname, extname, join, resolve } from "node:path";
3
- import { HsqldbSqlEvaluationError, HsqldbSqlParseError, HsqldbSqlUnsupportedError, OdbNoEmbeddedDataSourceError, OdbReportNotSpecifiedError, OdbTableNotFoundError, OdbTableNotSpecifiedError, OdbUnsupportedFormatError, OdmUnresolvedSectionError, PdfEncryptedError, PdfParseError, UnrecognizedDocumentSchemaError, UnsupportedFontSourceFormatError, buildDocumentBytes, createLocalDocumentConverter, decodeOdbPackage, decodePackage, documentFromJson, documentPackageWithSchema, evaluateSelect, extractSourceFontsForFormat, hsqldbCellDisplayText, layoutDocumentWithSchema, odbReportToDocx, odbReportToOdt, odbReportToPdf, odbToCsv, odbToXlsx, odmToPdf, parseSelect, readDocumentMetadata, readDocxExtras, readOdbForms, readOdbInventory, readOdbReportContent, readOdbReports, readOdbTables, readPdf, setDocumentMetadata } from "documents.js";
4
- import { readFontFace } from "pdf-codec";
3
+ import { HsqldbSqlEvaluationError, HsqldbSqlParseError, HsqldbSqlUnsupportedError, OdbNoEmbeddedDataSourceError, OdbReportNotSpecifiedError, OdbTableNotFoundError, OdbTableNotSpecifiedError, OdbUnsupportedFormatError, OdmUnresolvedSectionError, PdfEncryptedError, PdfParseError, UnrecognizedDocumentSchemaError, UnsupportedFontSourceFormatError, buildDocumentBytes, createLocalDocumentConverter, decodeOdbPackage, decodePackage, describeFontFace, documentFromJson, documentPackageWithSchema, evaluateSelect, extractSourceFontsForFormat, hsqldbCellDisplayText, layoutDocumentWithSchema, odbReportToDocx, odbReportToOdt, odbReportToPdf, odbToCsv, odbToXlsx, odmToPdf, parseSelect, readDocumentMetadata, readDocxExtras, readOdbForms, readOdbInventory, readOdbReportContent, readOdbReports, readOdbTables, readPdf, setDocumentMetadata } from "documents.js";
5
4
  import { existsSync, readFileSync } from "node:fs";
6
5
  import { Command, InvalidArgumentError } from "commander";
7
6
  //#region src/format.ts
@@ -184,7 +183,7 @@ async function loadProvidedFonts(paths, options) {
184
183
  const fonts = [];
185
184
  for (const path of paths) {
186
185
  const bytes = new Uint8Array(await readFile(path, { signal: options?.signal }));
187
- const face = readFontFace(bytes, path);
186
+ const face = describeFontFace(bytes, path);
188
187
  fonts.push({
189
188
  family: face.family,
190
189
  bold: face.bold,
@@ -1387,7 +1386,7 @@ function registerSetMetadataCommand(program) {
1387
1386
  }
1388
1387
  //#endregion
1389
1388
  //#region package.json
1390
- var version = "1.14.0";
1389
+ var version = "1.14.2";
1391
1390
  //#endregion
1392
1391
  //#region src/program.ts
1393
1392
  function createProgram() {
@@ -1,7 +1,6 @@
1
1
  import { readFile, writeFile } from "node:fs/promises";
2
2
  import { basename, dirname, extname, join } from "node:path";
3
- import "documents.js";
4
- import { readFontFace } from "pdf-codec";
3
+ import { describeFontFace } from "documents.js";
5
4
  //#region src/format.ts
6
5
  const EXTENSION_TO_FORMAT = {
7
6
  docx: "docx",
@@ -59,7 +58,7 @@ async function loadProvidedFonts(paths, options) {
59
58
  const fonts = [];
60
59
  for (const path of paths) {
61
60
  const bytes = new Uint8Array(await readFile(path, { signal: options?.signal }));
62
- const face = readFontFace(bytes, path);
61
+ const face = describeFontFace(bytes, path);
63
62
  fonts.push({
64
63
  family: face.family,
65
64
  bold: face.bold,
@@ -1,13 +1,12 @@
1
- import { c as formatDocxExtrasLines, f as loadProvidedFonts, i as formatOdbReportLines, l as readInput, m as inferFormatFromExtension, n as describeOdbReport, o as formatMetadataLines, p as formatToExtension, r as formatOdbFormLines, t as describeOdbForm } from "./odb-structure-CNpUdKwi.js";
1
+ import { c as formatDocxExtrasLines, f as loadProvidedFonts, i as formatOdbReportLines, l as readInput, m as inferFormatFromExtension, n as describeOdbReport, o as formatMetadataLines, p as formatToExtension, r as formatOdbFormLines, t as describeOdbForm } from "./odb-structure-DePnGZAI.js";
2
2
  import { readFile, writeFile } from "node:fs/promises";
3
3
  import { basename, dirname, extname, join } from "node:path";
4
- import { bytesToBase64, createDocx, createOdg, createOdp, createOds, createOdt, createPdf, createPptx, decodeMarkdownText, decodeOdbPackage, docxToPdf, encodeMarkdownText, hsqldbCellDisplayText, markdownToPdf, odbReportToDocx, odbReportToOdt, odbReportToPdf, odgToPdf, odpToPdf, odsToPdf, odtToPdf, openDocx, openMarkdown, openOdg, openOdp, openOds, openOdt, openPdf, openPptx, parseXml, pptxToPdf, readDocxContent, readDocxExtras, readMarkdownContent, readOdbForms, readOdbReportContent, readOdbReports, readOdbTables, readOdgContent, readOdpContent, readOdsContent, readOdtContent, readPdf, readPptxContent, rgbHexToColor, xlsxToPdf } from "documents.js";
4
+ import { bytesToBase64, cellReference, columnIndexToLetters, createDocx, createOdg, createOdp, createOds, createOdt, createPdf, createPptx, decodeMarkdownText, decodeOdbPackage, docxToPdf, encodeMarkdownText, hsqldbCellDisplayText, markdownToPdf, odbReportToDocx, odbReportToOdt, odbReportToPdf, odgToPdf, odpToPdf, odsToPdf, odtToPdf, openDocx, openMarkdown, openOdg, openOdp, openOds, openOdt, openPdf, openPptx, parseXml, pptxToPdf, readDocxContent, readDocxExtras, readMarkdownContent, readOdbForms, readOdbReportContent, readOdbReports, readOdbTables, readOdgContent, readOdpContent, readOdsContent, readOdtContent, readPdf, readPptxContent, rgbHexToColor, xlsxToPdf } from "documents.js";
5
5
  import { readdirSync } from "node:fs";
6
6
  import { Box, Text, render, useApp, useInput, useWindowSize } from "ink";
7
7
  import { createContext, useContext, useEffect, useReducer, useState } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
  import TextInput from "ink-text-input";
10
- import { cellReference, columnIndexToLetters } from "odf.js";
11
10
  //#region src/tui/errors.ts
12
11
  function describeError(error) {
13
12
  if (error instanceof Error) return error.message;
@@ -6824,7 +6823,7 @@ function OdsSpreadsheetGridScreen() {
6824
6823
  const compactRows = sheet === void 0 ? [] : sheet.cells.filter((cell) => cell.value.kind !== "empty").map((cell) => ({
6825
6824
  row: cell.row,
6826
6825
  column: cell.column,
6827
- address: cellReference(cell.column, cell.row),
6826
+ address: cellReference(cell.row, cell.column),
6828
6827
  badge: KIND_BADGE[cell.value.kind],
6829
6828
  displayText: cell.displayText
6830
6829
  })).sort((a, b) => a.row - b.row || a.column - b.column);
@@ -6845,7 +6844,7 @@ function OdsSpreadsheetGridScreen() {
6845
6844
  isActive: !overlayOpen && !editing && viewMode === "compact"
6846
6845
  });
6847
6846
  const cursorCell = cells.get(cellKey(clampedRow, clampedColumn));
6848
- const cursorAddress = cellReference(clampedColumn, clampedRow);
6847
+ const cursorAddress = cellReference(clampedRow, clampedColumn);
6849
6848
  const cursorKind = cursorCell === void 0 ? "empty" : cursorCell.value.kind;
6850
6849
  const viewportRows = Math.max(1, terminalRows - GRID_CHROME_ROWS);
6851
6850
  const visibleColumnCount = Math.max(1, Math.floor((terminalColumns - ROW_HEADER_WIDTH) / CELL_WIDTH));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-cli",
3
- "version": "1.14.0",
3
+ "version": "1.14.2",
4
4
  "description": "CLI and interactive Ink TUI for documents.js: every docx/pptx/odt/odp/ods/odg/odf/pdf/odm/odb/xlsx/markdown conversion, bridge, and editor as a scriptable command or a terminal app.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -88,11 +88,9 @@
88
88
  "packageManager": "pnpm@11.6.0",
89
89
  "dependencies": {
90
90
  "commander": "^15.0.0",
91
- "documents.js": "^1.94.0",
91
+ "documents.js": "^1.95.1",
92
92
  "ink": "^7.1.1",
93
93
  "ink-text-input": "^6.0.0",
94
- "odf.js": "^2.4.8",
95
- "pdf-codec": "^2.0.0",
96
94
  "react": "^19.2.8"
97
95
  },
98
96
  "devDependencies": {
@@ -112,6 +110,8 @@
112
110
  "husky": "^9.1.7",
113
111
  "ink-testing-library": "^4.0.0",
114
112
  "lint-staged": "^17.3.0",
113
+ "odf.js": "^2.4.8",
114
+ "pdf-codec": "^2.0.0",
115
115
  "publint": "^0.3.22",
116
116
  "semantic-release": "^25.0.8",
117
117
  "tsdown": "^0.22.14",