js.documents 1.96.4 → 1.97.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/dist/bin-dispatch.cjs +47 -0
- package/dist/bin-dispatch.d.cts +15 -0
- package/dist/bin-dispatch.d.ts +15 -0
- package/dist/bin-dispatch.js +46 -0
- package/dist/bin.cjs +8 -0
- package/dist/bin.d.cts +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +8 -0
- package/package.json +4 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/bin-dispatch.ts
|
|
3
|
+
const RUNNERS = {
|
|
4
|
+
npm: {
|
|
5
|
+
command: "npx",
|
|
6
|
+
prefixArgs: ["-y"]
|
|
7
|
+
},
|
|
8
|
+
pnpm: {
|
|
9
|
+
command: "pnpm",
|
|
10
|
+
prefixArgs: ["dlx"]
|
|
11
|
+
},
|
|
12
|
+
yarn: {
|
|
13
|
+
command: "yarn",
|
|
14
|
+
prefixArgs: ["dlx"]
|
|
15
|
+
},
|
|
16
|
+
bun: {
|
|
17
|
+
command: "bunx",
|
|
18
|
+
prefixArgs: []
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
function detectPackageManager(userAgent) {
|
|
22
|
+
const ua = userAgent ?? "";
|
|
23
|
+
if (ua.startsWith("yarn/")) return ua.startsWith("yarn/1.") ? "npm" : "yarn";
|
|
24
|
+
if (ua.startsWith("pnpm/")) return "pnpm";
|
|
25
|
+
if (ua.startsWith("bun/")) return "bun";
|
|
26
|
+
return "npm";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolves a launcher invocation into the companion package to run and the runner argument list to spawn it with. A bare invocation or any args that are not the `mcp` dispatch token run the interactive CLI; `mcp` launches the server. `cli` is the explicit escape hatch for the one collision a dispatcher that reserves a subcommand name necessarily has: a leading bare `mcp` is intercepted as "launch the server", so targeting a CLI command on a file literally named `mcp` needs `documents.js cli mcp`. document-cli's own commands never start with `mcp`, so the collision is narrow in practice -- the same "dispatcher reserves a subcommand name" model `git` uses.
|
|
30
|
+
*/
|
|
31
|
+
function resolveBinDispatch(argv, userAgent) {
|
|
32
|
+
const head = argv[0];
|
|
33
|
+
const pkg = head === "mcp" ? "document-mcp" : "document-cli";
|
|
34
|
+
const passThrough = head === "mcp" || head === "cli" ? argv.slice(1) : argv;
|
|
35
|
+
const { command, prefixArgs } = RUNNERS[detectPackageManager(userAgent)];
|
|
36
|
+
return {
|
|
37
|
+
pkg,
|
|
38
|
+
command,
|
|
39
|
+
runnerArgs: [
|
|
40
|
+
...prefixArgs,
|
|
41
|
+
pkg,
|
|
42
|
+
...passThrough
|
|
43
|
+
]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
exports.resolveBinDispatch = resolveBinDispatch;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/bin-dispatch.d.ts
|
|
2
|
+
interface BinDispatch {
|
|
3
|
+
/** The npm package the launcher resolves and invokes. */
|
|
4
|
+
readonly pkg: 'document-cli' | 'document-mcp';
|
|
5
|
+
/** The executable to spawn -- each JS package manager's own download-and-run command. */
|
|
6
|
+
readonly command: 'npx' | 'pnpm' | 'yarn' | 'bunx';
|
|
7
|
+
/** Arguments after the command itself -- begins with the manager's fetch flags, then the package name, then the passthrough args. */
|
|
8
|
+
readonly runnerArgs: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolves a launcher invocation into the companion package to run and the runner argument list to spawn it with. A bare invocation or any args that are not the `mcp` dispatch token run the interactive CLI; `mcp` launches the server. `cli` is the explicit escape hatch for the one collision a dispatcher that reserves a subcommand name necessarily has: a leading bare `mcp` is intercepted as "launch the server", so targeting a CLI command on a file literally named `mcp` needs `documents.js cli mcp`. document-cli's own commands never start with `mcp`, so the collision is narrow in practice -- the same "dispatcher reserves a subcommand name" model `git` uses.
|
|
12
|
+
*/
|
|
13
|
+
declare function resolveBinDispatch(argv: readonly string[], userAgent: string | undefined): BinDispatch;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BinDispatch, resolveBinDispatch };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/bin-dispatch.d.ts
|
|
2
|
+
interface BinDispatch {
|
|
3
|
+
/** The npm package the launcher resolves and invokes. */
|
|
4
|
+
readonly pkg: 'document-cli' | 'document-mcp';
|
|
5
|
+
/** The executable to spawn -- each JS package manager's own download-and-run command. */
|
|
6
|
+
readonly command: 'npx' | 'pnpm' | 'yarn' | 'bunx';
|
|
7
|
+
/** Arguments after the command itself -- begins with the manager's fetch flags, then the package name, then the passthrough args. */
|
|
8
|
+
readonly runnerArgs: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolves a launcher invocation into the companion package to run and the runner argument list to spawn it with. A bare invocation or any args that are not the `mcp` dispatch token run the interactive CLI; `mcp` launches the server. `cli` is the explicit escape hatch for the one collision a dispatcher that reserves a subcommand name necessarily has: a leading bare `mcp` is intercepted as "launch the server", so targeting a CLI command on a file literally named `mcp` needs `documents.js cli mcp`. document-cli's own commands never start with `mcp`, so the collision is narrow in practice -- the same "dispatcher reserves a subcommand name" model `git` uses.
|
|
12
|
+
*/
|
|
13
|
+
declare function resolveBinDispatch(argv: readonly string[], userAgent: string | undefined): BinDispatch;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BinDispatch, resolveBinDispatch };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/bin-dispatch.ts
|
|
2
|
+
const RUNNERS = {
|
|
3
|
+
npm: {
|
|
4
|
+
command: "npx",
|
|
5
|
+
prefixArgs: ["-y"]
|
|
6
|
+
},
|
|
7
|
+
pnpm: {
|
|
8
|
+
command: "pnpm",
|
|
9
|
+
prefixArgs: ["dlx"]
|
|
10
|
+
},
|
|
11
|
+
yarn: {
|
|
12
|
+
command: "yarn",
|
|
13
|
+
prefixArgs: ["dlx"]
|
|
14
|
+
},
|
|
15
|
+
bun: {
|
|
16
|
+
command: "bunx",
|
|
17
|
+
prefixArgs: []
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function detectPackageManager(userAgent) {
|
|
21
|
+
const ua = userAgent ?? "";
|
|
22
|
+
if (ua.startsWith("yarn/")) return ua.startsWith("yarn/1.") ? "npm" : "yarn";
|
|
23
|
+
if (ua.startsWith("pnpm/")) return "pnpm";
|
|
24
|
+
if (ua.startsWith("bun/")) return "bun";
|
|
25
|
+
return "npm";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolves a launcher invocation into the companion package to run and the runner argument list to spawn it with. A bare invocation or any args that are not the `mcp` dispatch token run the interactive CLI; `mcp` launches the server. `cli` is the explicit escape hatch for the one collision a dispatcher that reserves a subcommand name necessarily has: a leading bare `mcp` is intercepted as "launch the server", so targeting a CLI command on a file literally named `mcp` needs `documents.js cli mcp`. document-cli's own commands never start with `mcp`, so the collision is narrow in practice -- the same "dispatcher reserves a subcommand name" model `git` uses.
|
|
29
|
+
*/
|
|
30
|
+
function resolveBinDispatch(argv, userAgent) {
|
|
31
|
+
const head = argv[0];
|
|
32
|
+
const pkg = head === "mcp" ? "document-mcp" : "document-cli";
|
|
33
|
+
const passThrough = head === "mcp" || head === "cli" ? argv.slice(1) : argv;
|
|
34
|
+
const { command, prefixArgs } = RUNNERS[detectPackageManager(userAgent)];
|
|
35
|
+
return {
|
|
36
|
+
pkg,
|
|
37
|
+
command,
|
|
38
|
+
runnerArgs: [
|
|
39
|
+
...prefixArgs,
|
|
40
|
+
pkg,
|
|
41
|
+
...passThrough
|
|
42
|
+
]
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { resolveBinDispatch };
|
package/dist/bin.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const require_bin_dispatch = require("./bin-dispatch.cjs");
|
|
3
|
+
let node_child_process = require("node:child_process");
|
|
4
|
+
//#region src/bin.ts
|
|
5
|
+
const { command, runnerArgs } = require_bin_dispatch.resolveBinDispatch(process.argv.slice(2), process.env.npm_config_user_agent);
|
|
6
|
+
const { status } = (0, node_child_process.spawnSync)(command, [...runnerArgs], { stdio: "inherit" });
|
|
7
|
+
process.exit(status ?? 1);
|
|
8
|
+
//#endregion
|
package/dist/bin.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { resolveBinDispatch } from "./bin-dispatch.js";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
//#region src/bin.ts
|
|
5
|
+
const { command, runnerArgs } = resolveBinDispatch(process.argv.slice(2), process.env.npm_config_user_agent);
|
|
6
|
+
const { status } = spawnSync(command, [...runnerArgs], { stdio: "inherit" });
|
|
7
|
+
process.exit(status ?? 1);
|
|
8
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js.documents",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.97.0",
|
|
4
4
|
"description": "Bidirectional docx/pptx <-> PDF conversion and a read+write editable OOXML document model, built on ooxml.js and Zod 4 codecs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -32,6 +32,9 @@
|
|
|
32
32
|
"main": "./dist/index.cjs",
|
|
33
33
|
"module": "./dist/index.js",
|
|
34
34
|
"types": "./dist/index.d.ts",
|
|
35
|
+
"bin": {
|
|
36
|
+
"documents.js": "./dist/bin.js"
|
|
37
|
+
},
|
|
35
38
|
"files": [
|
|
36
39
|
"dist"
|
|
37
40
|
],
|