document-cli 1.13.19 → 1.14.1
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`
|
|
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-
|
|
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.
|
|
1062
|
+
var version = "1.14.1";
|
|
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-
|
|
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,
|
|
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.
|
|
1390
|
+
var version = "1.14.1";
|
|
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 =
|
|
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.
|
|
1389
|
+
var version = "1.14.1";
|
|
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 =
|
|
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-
|
|
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.
|
|
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(
|
|
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.
|
|
3
|
+
"version": "1.14.1",
|
|
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": {
|
|
@@ -49,15 +49,22 @@
|
|
|
49
49
|
"node": ">=20"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
|
-
"build": "
|
|
52
|
+
"build": "turbo run _build",
|
|
53
|
+
"_build": "tsdown",
|
|
53
54
|
"prepublishOnly": "pnpm run lint && pnpm run typecheck && tsdown && publint && attw --pack",
|
|
54
|
-
"lint": "
|
|
55
|
-
"
|
|
56
|
-
"
|
|
55
|
+
"lint": "turbo run _lint",
|
|
56
|
+
"_lint": "eslint . --fix --cache --max-warnings 0",
|
|
57
|
+
"typecheck": "turbo run _typecheck",
|
|
58
|
+
"_typecheck": "tsc --noEmit",
|
|
59
|
+
"test": "turbo run _test",
|
|
60
|
+
"_test": "vitest run --project unit",
|
|
57
61
|
"test:watch": "vitest --project unit",
|
|
58
|
-
"test:coverage": "
|
|
59
|
-
"
|
|
60
|
-
"test:
|
|
62
|
+
"test:coverage": "turbo run _test:coverage",
|
|
63
|
+
"_test:coverage": "vitest run --project unit --coverage",
|
|
64
|
+
"test:smoke": "turbo run _test:smoke",
|
|
65
|
+
"_test:smoke": "tsdown && vitest run --project smoke",
|
|
66
|
+
"test:workers": "turbo run _test:workers",
|
|
67
|
+
"_test:workers": "vitest run --config vitest.workers.config.ts",
|
|
61
68
|
"prepare": "husky",
|
|
62
69
|
"release": "semantic-release"
|
|
63
70
|
},
|
|
@@ -81,11 +88,9 @@
|
|
|
81
88
|
"packageManager": "pnpm@11.6.0",
|
|
82
89
|
"dependencies": {
|
|
83
90
|
"commander": "^15.0.0",
|
|
84
|
-
"documents.js": "^1.
|
|
91
|
+
"documents.js": "^1.95.0",
|
|
85
92
|
"ink": "^7.1.1",
|
|
86
93
|
"ink-text-input": "^6.0.0",
|
|
87
|
-
"odf.js": "^2.4.8",
|
|
88
|
-
"pdf-codec": "^2.0.0",
|
|
89
94
|
"react": "^19.2.8"
|
|
90
95
|
},
|
|
91
96
|
"devDependencies": {
|
|
@@ -105,9 +110,12 @@
|
|
|
105
110
|
"husky": "^9.1.7",
|
|
106
111
|
"ink-testing-library": "^4.0.0",
|
|
107
112
|
"lint-staged": "^17.3.0",
|
|
113
|
+
"odf.js": "^2.4.8",
|
|
114
|
+
"pdf-codec": "^2.0.0",
|
|
108
115
|
"publint": "^0.3.22",
|
|
109
116
|
"semantic-release": "^25.0.8",
|
|
110
117
|
"tsdown": "^0.22.14",
|
|
118
|
+
"turbo": "^2.10.8",
|
|
111
119
|
"typescript": "^6.0.3",
|
|
112
120
|
"typescript-eslint": "^8.65.0",
|
|
113
121
|
"vitest": "^4.1.10"
|