@docmentis/udoc-cli 0.0.1 → 0.8.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/LICENSE-APACHE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 docMentis LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # @docmentis/udoc-cli
2
+
3
+ **Document tools from the command line.**
4
+
5
+ Run document inspection, rendering, and export operations from your terminal or automation scripts, powered by the same udoc engine used across the docMentis ecosystem.
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@docmentis/udoc-cli)](https://www.npmjs.com/package/@docmentis/udoc-cli)
8
+ [![license](https://img.shields.io/npm/l/@docmentis/udoc-cli)](https://github.com/docMentis/docmentis-udoc#open-source-packages-shared-runtime)
9
+
10
+ **[Docs](https://www.docmentis.com/docs)** · **[Changelog](https://github.com/docMentis/docmentis-udoc/blob/main/CHANGELOG.md)** · **[Report Issue](https://github.com/docMentis/docmentis-udoc/issues)**
11
+
12
+ ---
13
+
14
+ ## Get started
15
+
16
+ ```sh
17
+ npm install -g @docmentis/udoc-cli
18
+ ```
19
+
20
+ ```sh
21
+ udoc page-count slides.pptx
22
+ udoc render slides.pptx --page 3 --scale 2 --out slide-3.png
23
+ udoc save slides.pptx --out slides.udoc
24
+ ```
25
+
26
+ Run `udoc --help` for supported commands and options.
27
+
28
+ ## Where it fits
29
+
30
+ Choose the CLI for terminal workflows and scripts. To build document operations into your Node.js application, use [`@docmentis/udoc-node`](https://www.npmjs.com/package/@docmentis/udoc-node).
31
+
32
+ ## Licensing
33
+
34
+ The CLI source code is open source under **MIT OR Apache-2.0**. Its underlying [`@docmentis/udoc-wasm`](https://www.npmjs.com/package/@docmentis/udoc-wasm) engine is proprietary and separately licensed. Free use requires online authorization; commercial licensing supports offline use. A commercial license can be supplied using `UDOC_LICENSE` and `UDOC_DOMAIN`.
35
+
36
+ [Source and documentation](https://github.com/docMentis/docmentis-udoc)
package/dist/args.js ADDED
@@ -0,0 +1,202 @@
1
+ // The `udoc` command line, parsed.
2
+ //
3
+ // Nothing here imports a sibling at runtime, so the tests load it from `src`.
4
+ import { basename, extname } from "node:path";
5
+ import { parseArgs } from "node:util";
6
+ export const USAGE = `Usage: udoc render <input> [--page <n>] [--scale <s>] [--out <file.png>]
7
+ udoc save <input> --out <file>
8
+ udoc page-count <input>
9
+
10
+ Commands:
11
+ render render one page of a document to a PNG
12
+ save save a document faithfully, in the format --out's
13
+ extension names: one of its own (.pdf, .pptx, …), or .udoc
14
+ page-count print how many pages the document has
15
+
16
+ The format is detected from the bytes; a .csv, .tsv, .tab or .psv's from its
17
+ extension.
18
+ Counting pages lays out the whole document; rendering lays it out only as far
19
+ as the page asked for.
20
+
21
+ Options (render):
22
+ -p, --page <n> page to render, counting from 1 (default 1)
23
+ -s, --scale <s> output pixels per point; 1 is 72 DPI (default 1)
24
+ -o, --out <file> where to write it (default <input-name>_page_<n>.png)
25
+
26
+ Options (save):
27
+ -o, --out <file> where to write it; its extension names the format
28
+
29
+ Options:
30
+ --password <p>
31
+ the password a protected PDF opens with: its user or its
32
+ owner password
33
+ --delimiter <c>
34
+ the character a .csv's fields are split by: the input's,
35
+ and for save the output's (default: detected on open, and
36
+ on save the one the input was split by, else a comma)
37
+ -h, --help show this help
38
+ --version show the version
39
+
40
+ Environment:
41
+ UDOC_LICENSE commercial license key; without one, usage is metered and
42
+ each document opened needs a permit from docMentis
43
+ UDOC_DOMAIN the domain that license is issued for
44
+ `;
45
+ /** A command line asking for nothing `udoc` can do. The message says why. */
46
+ export class UsageError extends Error {
47
+ constructor(message) {
48
+ super(message);
49
+ this.name = "UsageError";
50
+ }
51
+ }
52
+ export function parseInvocation(argv) {
53
+ let parsed;
54
+ try {
55
+ parsed = parseArgs({
56
+ args: [...argv],
57
+ allowPositionals: true,
58
+ options: {
59
+ page: { type: "string", short: "p" },
60
+ scale: { type: "string", short: "s" },
61
+ out: { type: "string", short: "o" },
62
+ password: { type: "string" },
63
+ delimiter: { type: "string" },
64
+ help: { type: "boolean", short: "h" },
65
+ version: { type: "boolean" },
66
+ },
67
+ });
68
+ }
69
+ catch (error) {
70
+ throw new UsageError(error instanceof Error ? error.message : String(error));
71
+ }
72
+ const { values, positionals } = parsed;
73
+ if (values.help)
74
+ return { command: "help" };
75
+ if (values.version)
76
+ return { command: "version" };
77
+ const [command, ...operands] = positionals;
78
+ const password = values.password !== undefined ? { password: values.password } : {};
79
+ const { delimiter } = values;
80
+ /** `--delimiter` for `input`, which takes one only as a CSV. */
81
+ const inputDelimiter = (input) => {
82
+ if (delimiter === undefined)
83
+ return {};
84
+ if (!isCsv(input))
85
+ throw new UsageError("--delimiter is for a .csv input");
86
+ return { delimiter };
87
+ };
88
+ switch (command) {
89
+ case undefined:
90
+ throw new UsageError("no command given");
91
+ case "render": {
92
+ if (operands.length !== 1)
93
+ throw new UsageError("render takes exactly one input document");
94
+ const input = operands[0];
95
+ const page = pageOf(values.page);
96
+ const scale = scaleOf(values.scale);
97
+ return {
98
+ command: "render",
99
+ input,
100
+ page,
101
+ scale,
102
+ out: values.out ?? defaultOut(input, page),
103
+ ...password,
104
+ ...inputDelimiter(input),
105
+ };
106
+ }
107
+ case "save": {
108
+ if (operands.length !== 1)
109
+ throw new UsageError("save takes exactly one input document");
110
+ if (values.page !== undefined || values.scale !== undefined) {
111
+ throw new UsageError("--page and --scale are for render");
112
+ }
113
+ if (values.out === undefined)
114
+ throw new UsageError("save needs --out, whose extension names the format");
115
+ const input = operands[0];
116
+ const format = saveFormatOf(values.out);
117
+ if (delimiter !== undefined && !isCsv(input) && format !== "csv") {
118
+ throw new UsageError("--delimiter is for a .csv, in or out");
119
+ }
120
+ return {
121
+ command: "save",
122
+ input,
123
+ out: values.out,
124
+ format,
125
+ ...password,
126
+ ...(delimiter !== undefined && isCsv(input) ? { delimiter } : {}),
127
+ ...(delimiter !== undefined && format === "csv" ? { outDelimiter: delimiter } : {}),
128
+ };
129
+ }
130
+ case "page-count": {
131
+ if (operands.length !== 1)
132
+ throw new UsageError("page-count takes exactly one input document");
133
+ // Accepted by the parser for `render`, but meaningless here — say
134
+ // so rather than silently ignore what the user asked for.
135
+ if (values.page !== undefined || values.scale !== undefined || values.out !== undefined) {
136
+ throw new UsageError("--page, --scale and --out are for render");
137
+ }
138
+ return { command: "page-count", input: operands[0], ...password, ...inputDelimiter(operands[0]) };
139
+ }
140
+ default:
141
+ throw new UsageError(`unknown command ${JSON.stringify(command)}`);
142
+ }
143
+ }
144
+ /** Whether `path` names a CSV by its extension. */
145
+ function isCsv(path) {
146
+ return extname(path).slice(1).toLowerCase() === "csv";
147
+ }
148
+ function pageOf(value) {
149
+ if (value === undefined)
150
+ return 1;
151
+ const page = Number(value);
152
+ if (!Number.isInteger(page))
153
+ throw new UsageError(`--page takes a whole number, got ${JSON.stringify(value)}`);
154
+ if (page < 1)
155
+ throw new UsageError("page numbers count from 1");
156
+ return page;
157
+ }
158
+ function scaleOf(value) {
159
+ if (value === undefined)
160
+ return 1;
161
+ const scale = Number(value);
162
+ if (!Number.isFinite(scale) || scale <= 0) {
163
+ throw new UsageError(`--scale takes a positive number, got ${JSON.stringify(value)}`);
164
+ }
165
+ return scale;
166
+ }
167
+ /** Each extension `save` writes, and the format it names. */
168
+ const SAVE_FORMATS = {
169
+ pdf: "pdf",
170
+ docx: "docx",
171
+ pptx: "pptx",
172
+ xlsx: "xlsx",
173
+ csv: "csv",
174
+ tsv: "tsv",
175
+ tab: "tsv",
176
+ psv: "psv",
177
+ jpg: "jpg",
178
+ jpeg: "jpg",
179
+ png: "png",
180
+ gif: "gif",
181
+ bmp: "bmp",
182
+ tif: "tiff",
183
+ tiff: "tiff",
184
+ webp: "webp",
185
+ svg: "svg",
186
+ emf: "emf",
187
+ wmf: "wmf",
188
+ udoc: "udoc",
189
+ };
190
+ function saveFormatOf(out) {
191
+ const ext = extname(out).slice(1).toLowerCase();
192
+ const format = SAVE_FORMATS[ext];
193
+ if (format === undefined) {
194
+ throw new UsageError(`--out ${JSON.stringify(out)} doesn't name a format save writes`);
195
+ }
196
+ return format;
197
+ }
198
+ /** `<input-name>_page_<page>.png`, in the working directory. */
199
+ function defaultOut(input, page) {
200
+ return `${basename(input, extname(input)) || "page"}_page_${page}.png`;
201
+ }
202
+ //# sourceMappingURL=args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,EAAE;AACF,8EAA8E;AAE9E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC,MAAM,CAAC,MAAM,KA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CAAC,CAAC,IAAI,MAAM,SAAS,IAAI,MAAM,CAAC;AAC3E,CAAC"}
package/dist/main.js ADDED
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env node
2
+ // `udoc` — the udoc engine on the command line.
3
+ //
4
+ // It runs the wasm engine through `@docmentis/udoc-node`, so it is licensed as
5
+ // any other host is: a key from `UDOC_LICENSE` (for the domain in
6
+ // `UDOC_DOMAIN`), or free usage, which spends a permit per document opened.
7
+ import { readFile, writeFile } from "node:fs/promises";
8
+ import { extname } from "node:path";
9
+ import process from "node:process";
10
+ import { UDocError, UDocNode } from "@docmentis/udoc-node";
11
+ import { USAGE, UsageError, parseInvocation } from "./args.js";
12
+ import { WRAPPER_VERSION } from "./version.js";
13
+ async function main() {
14
+ let invocation;
15
+ try {
16
+ invocation = parseInvocation(process.argv.slice(2));
17
+ }
18
+ catch (error) {
19
+ if (!(error instanceof UsageError))
20
+ throw error;
21
+ console.error(`error [invalidRequest]: ${error.message}\n\n${USAGE}`);
22
+ return 2;
23
+ }
24
+ switch (invocation.command) {
25
+ case "help":
26
+ console.log(USAGE);
27
+ return 0;
28
+ case "version":
29
+ console.log(WRAPPER_VERSION);
30
+ return 0;
31
+ case "render":
32
+ await render(invocation);
33
+ return 0;
34
+ case "save":
35
+ await save(invocation);
36
+ return 0;
37
+ case "page-count":
38
+ await pageCount(invocation);
39
+ return 0;
40
+ }
41
+ }
42
+ async function render({ input, password, delimiter, page, scale, out }) {
43
+ const session = await open(input, password, delimiter);
44
+ try {
45
+ const png = await session.exportPageToBytes(page - 1, { png: { scale } }).catch((error) => {
46
+ // The engine counts pages from 0 and says only how many there are;
47
+ // the address is ours to word, in the user's numbering.
48
+ throw error instanceof UDocError && error.code === "notFound"
49
+ ? new UDocError("notFound", `page ${page} is out of range: ${error.message}`)
50
+ : error;
51
+ });
52
+ await fileIo(writeFile(out, png));
53
+ console.log(`Rendered page ${page} → ${out} (${png.length} bytes, scale ${scale})`);
54
+ }
55
+ finally {
56
+ await session.close();
57
+ }
58
+ }
59
+ async function save({ input, password, delimiter, out, format, outDelimiter }) {
60
+ const session = await open(input, password, delimiter);
61
+ try {
62
+ const bytes = format === "udoc"
63
+ ? await session.saveToPackage()
64
+ : await session.saveToBytes(format, undefined, outDelimiter);
65
+ await fileIo(writeFile(out, bytes));
66
+ console.log(`Saved → ${out} (${bytes.length} bytes)`);
67
+ }
68
+ finally {
69
+ await session.close();
70
+ }
71
+ }
72
+ async function pageCount({ input, password, delimiter }) {
73
+ const session = await open(input, password, delimiter);
74
+ try {
75
+ console.log(await session.pageCount());
76
+ }
77
+ finally {
78
+ await session.close();
79
+ }
80
+ }
81
+ async function open(input, password, delimiter) {
82
+ const bytes = await fileIo(readFile(input));
83
+ const udoc = await UDocNode.create({
84
+ ...licenseFromEnvironment(),
85
+ wrapper: { name: "udoc-cli", version: WRAPPER_VERSION },
86
+ });
87
+ const session = await udoc.open(bytes, signaturelessFormat(input), delimiter);
88
+ try {
89
+ if (session.needsPassword)
90
+ await unlock(session, input, password);
91
+ return session;
92
+ }
93
+ catch (error) {
94
+ await session.close();
95
+ throw error;
96
+ }
97
+ }
98
+ /**
99
+ * The format `input`'s extension names when the bytes can't say it: a CSV's, a
100
+ * TSV's or a PSV's, which have no signature to detect. `undefined` for any
101
+ * other file.
102
+ */
103
+ function signaturelessFormat(input) {
104
+ switch (extname(input).slice(1).toLowerCase()) {
105
+ case "csv":
106
+ return "csv";
107
+ case "tsv":
108
+ case "tab":
109
+ return "tsv";
110
+ case "psv":
111
+ return "psv";
112
+ default:
113
+ return undefined;
114
+ }
115
+ }
116
+ /**
117
+ * Unlock `session`, just opened from `input`, with the `--password` given.
118
+ * Tried once: a command line has no one to ask again.
119
+ */
120
+ async function unlock(session, input, password) {
121
+ if (password === undefined) {
122
+ throw new UDocError("passwordRequired", `${input} needs a password: give it with --password`);
123
+ }
124
+ if (!(await session.authenticate(password))) {
125
+ throw new UDocError("passwordRequired", `the password given doesn't open ${input}`);
126
+ }
127
+ }
128
+ /** `done`, a file read or write: its failure is `io`. */
129
+ function fileIo(done) {
130
+ return done.catch((error) => {
131
+ throw new UDocError("io", error instanceof Error ? error.message : String(error), undefined, { cause: error });
132
+ });
133
+ }
134
+ function licenseFromEnvironment() {
135
+ const license = process.env["UDOC_LICENSE"];
136
+ const domain = process.env["UDOC_DOMAIN"];
137
+ return {
138
+ ...(license ? { license } : {}),
139
+ ...(domain ? { domain } : {}),
140
+ };
141
+ }
142
+ main().then((code) => {
143
+ process.exitCode = code;
144
+ }, (error) => {
145
+ const { code, message } = UDocError.from(error);
146
+ console.error(`error [${code}]: ${message}`);
147
+ process.exitCode = 1;
148
+ });
149
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AACA,gDAAgD;AAChD,EAAE;AACF,+EAA+E;AAC/E,kEAAkE;AAClE,4EAA4E;AAE5E,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,KAAK,UAAU,IAAI;IACf,IAAI,UAAsB,CAAC;IAC3B,IAAI,CAAC;QACD,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC;YAAE,MAAM,KAAK,CAAC;QAChD,OAAO,CAAC,KAAK,CAAC,2BAA2B,KAAK,CAAC,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G,CAAC,CAAC;AACzB,CAAC,CACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ // This package's version, reported to the engine as the wrapper version so a
2
+ // permit request and a usage event can name what produced them.
3
+ //
4
+ // Read from the `package.json` npm ships beside `dist` — the one place a
5
+ // release bumps — so it is always the version actually running. `../` is the
6
+ // package root from `src` and from `dist` alike.
7
+ import { readFileSync } from "node:fs";
8
+ const manifest = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
9
+ export const WRAPPER_VERSION = manifest.version;
10
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,gEAAgE;AAChE,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,iDAAiD;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAwB,CAAC;AAEtH,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,56 @@
1
1
  {
2
- "name": "@docmentis/udoc-cli",
3
- "version": "0.0.1",
4
- "description": "Placeholder: the first release is on its way.",
5
- "license": "MIT OR Apache-2.0",
6
- "repository": { "type": "git", "url": "git+https://github.com/docMentis/docmentis-udoc.git", "directory": "packages/udoc-cli" }
2
+ "name": "@docmentis/udoc-cli",
3
+ "version": "0.8.0",
4
+ "description": "Inspect, render, and export documents from the command line.",
5
+ "keywords": [
6
+ "cli",
7
+ "command-line",
8
+ "document",
9
+ "pdf",
10
+ "docx",
11
+ "pptx",
12
+ "xlsx",
13
+ "word",
14
+ "powerpoint",
15
+ "excel",
16
+ "office",
17
+ "render",
18
+ "png",
19
+ "docmentis",
20
+ "udoc",
21
+ "webassembly",
22
+ "wasm"
23
+ ],
24
+ "homepage": "https://www.docmentis.com/docs",
25
+ "license": "MIT OR Apache-2.0",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/docMentis/docmentis-udoc.git",
29
+ "directory": "packages/udoc-cli"
30
+ },
31
+ "type": "module",
32
+ "files": [
33
+ "dist",
34
+ "LICENSE-MIT",
35
+ "LICENSE-APACHE"
36
+ ],
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "bin": {
41
+ "udoc": "dist/main.js"
42
+ },
43
+ "engines": {
44
+ "node": ">=22.18"
45
+ },
46
+ "scripts": {
47
+ "dev": "tsc -p tsconfig.json --watch",
48
+ "build": "npm run clean && node scripts/check-version.mjs && tsc -p tsconfig.json && chmod +x dist/main.js",
49
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json",
50
+ "test": "node --test",
51
+ "clean": "rm -rf dist"
52
+ },
53
+ "dependencies": {
54
+ "@docmentis/udoc-node": "0.8.0"
55
+ }
7
56
  }