@treeseed/cli 0.4.8 → 0.4.10
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/cli/handlers/config-ui.d.ts +72 -0
- package/dist/cli/handlers/config-ui.js +785 -0
- package/dist/cli/handlers/config.js +105 -35
- package/dist/cli/handlers/export.d.ts +2 -0
- package/dist/cli/handlers/export.js +28 -0
- package/dist/cli/help-ui.d.ts +3 -0
- package/dist/cli/help-ui.js +490 -0
- package/dist/cli/help.d.ts +26 -0
- package/dist/cli/help.js +332 -91
- package/dist/cli/operations-registry.js +678 -28
- package/dist/cli/operations-types.d.ts +37 -2
- package/dist/cli/registry.d.ts +1 -0
- package/dist/cli/registry.js +2 -0
- package/dist/cli/runtime.js +22 -9
- package/dist/cli/ui/framework.d.ts +159 -0
- package/dist/cli/ui/framework.js +296 -0
- package/dist/cli/ui/mouse.d.ts +11 -0
- package/dist/cli/ui/mouse.js +72 -0
- package/package.json +7 -4
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useStdin, useStdout } from "ink";
|
|
3
|
+
function decodeButton(code) {
|
|
4
|
+
if ((code & 64) === 64) {
|
|
5
|
+
return (code & 1) === 1 ? "scroll-down" : "scroll-up";
|
|
6
|
+
}
|
|
7
|
+
switch (code & 3) {
|
|
8
|
+
case 0:
|
|
9
|
+
return "left";
|
|
10
|
+
case 1:
|
|
11
|
+
return "middle";
|
|
12
|
+
case 2:
|
|
13
|
+
return "right";
|
|
14
|
+
default:
|
|
15
|
+
return "unknown";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function decodeAction(code, suffix) {
|
|
19
|
+
if ((code & 32) === 32) {
|
|
20
|
+
return "drag";
|
|
21
|
+
}
|
|
22
|
+
return suffix === "m" ? "release" : "press";
|
|
23
|
+
}
|
|
24
|
+
function parseTerminalMouseInput(input) {
|
|
25
|
+
const matches = input.matchAll(/\u001B\[<(\d+);(\d+);(\d+)([mM])/gu);
|
|
26
|
+
const events = [];
|
|
27
|
+
for (const match of matches) {
|
|
28
|
+
const code = Number(match[1] ?? 0);
|
|
29
|
+
const x = Math.max(0, Number(match[2] ?? 0) - 1);
|
|
30
|
+
const y = Math.max(0, Number(match[3] ?? 0) - 1);
|
|
31
|
+
const suffix = match[4] ?? "M";
|
|
32
|
+
events.push({
|
|
33
|
+
x,
|
|
34
|
+
y,
|
|
35
|
+
button: decodeButton(code),
|
|
36
|
+
action: decodeAction(code, suffix),
|
|
37
|
+
shift: (code & 4) === 4,
|
|
38
|
+
meta: (code & 8) === 8,
|
|
39
|
+
ctrl: (code & 16) === 16
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return events;
|
|
43
|
+
}
|
|
44
|
+
function useTerminalMouse(onEvent) {
|
|
45
|
+
const { stdin } = useStdin();
|
|
46
|
+
const { stdout } = useStdout();
|
|
47
|
+
const handlerRef = React.useRef(onEvent);
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
handlerRef.current = onEvent;
|
|
50
|
+
}, [onEvent]);
|
|
51
|
+
React.useEffect(() => {
|
|
52
|
+
if (!stdin || !stdout || !process.stdin.isTTY || !process.stdout.isTTY) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
stdout.write("\x1B[?1000h\x1B[?1006h");
|
|
56
|
+
const handleData = (chunk) => {
|
|
57
|
+
const raw = typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
58
|
+
for (const event of parseTerminalMouseInput(raw)) {
|
|
59
|
+
handlerRef.current(event);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
stdin.on("data", handleData);
|
|
63
|
+
return () => {
|
|
64
|
+
stdin.off("data", handleData);
|
|
65
|
+
stdout.write("\x1B[?1000l\x1B[?1006l");
|
|
66
|
+
};
|
|
67
|
+
}, [stdin, stdout]);
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
parseTerminalMouseInput,
|
|
71
|
+
useTerminalMouse
|
|
72
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treeseed/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.10",
|
|
4
4
|
"description": "Operator-facing Treeseed CLI package.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"setup:ci": "npm ci",
|
|
31
31
|
"build": "npm run build:dist",
|
|
32
32
|
"lint": "npm run build:dist",
|
|
33
|
-
"test": "npm run build:dist && node --test ./scripts/treeseed-help.test.mjs ./scripts/wrapper-package.test.mjs",
|
|
33
|
+
"test": "npm run build:dist && node --test --test-concurrency=1 ./scripts/treeseed-help.test.mjs ./scripts/wrapper-package.test.mjs",
|
|
34
34
|
"build:dist": "node ./scripts/run-ts.mjs ./scripts/build-dist.ts",
|
|
35
35
|
"prepack": "npm run build:dist",
|
|
36
36
|
"verify:direct": "npm run release:verify",
|
|
@@ -43,7 +43,9 @@
|
|
|
43
43
|
"release:publish": "node ./scripts/run-ts.mjs ./scripts/publish-package.ts"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@treeseed/sdk": "^0.4.
|
|
46
|
+
"@treeseed/sdk": "^0.4.9",
|
|
47
|
+
"ink": "^7.0.0",
|
|
48
|
+
"react": "^19.2.5"
|
|
47
49
|
},
|
|
48
50
|
"devDependencies": {
|
|
49
51
|
"@types/node": "^24.6.0",
|
|
@@ -51,6 +53,7 @@
|
|
|
51
53
|
"typescript": "^5.9.3"
|
|
52
54
|
},
|
|
53
55
|
"bin": {
|
|
54
|
-
"treeseed": "./dist/cli/main.js"
|
|
56
|
+
"treeseed": "./dist/cli/main.js",
|
|
57
|
+
"trsd": "./dist/cli/main.js"
|
|
55
58
|
}
|
|
56
59
|
}
|