veryfront 0.1.856 → 0.1.858
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/esm/cli/commands/lint/handler.d.ts.map +1 -1
- package/esm/cli/commands/lint/handler.js +9 -12
- package/esm/cli/commands/mcp/handler.d.ts +3 -0
- package/esm/cli/commands/mcp/handler.d.ts.map +1 -1
- package/esm/cli/commands/mcp/handler.js +4 -4
- package/esm/cli/commands/serve/split-mode.d.ts +1 -0
- package/esm/cli/commands/serve/split-mode.d.ts.map +1 -1
- package/esm/cli/commands/serve/split-mode.js +45 -13
- package/esm/cli/commands/test/command.d.ts.map +1 -1
- package/esm/cli/commands/test/command.js +5 -2
- package/esm/cli/commands/test/handler.d.ts.map +1 -1
- package/esm/cli/commands/test/handler.js +19 -13
- package/esm/cli/mcp/standalone.d.ts +7 -0
- package/esm/cli/mcp/standalone.d.ts.map +1 -1
- package/esm/cli/mcp/standalone.js +9 -10
- package/esm/cli/mcp/tools/context7-tools.d.ts.map +1 -1
- package/esm/cli/mcp/tools/context7-tools.js +3 -3
- package/esm/cli/mcp/tools/helpers.d.ts +8 -0
- package/esm/cli/mcp/tools/helpers.d.ts.map +1 -1
- package/esm/cli/mcp/tools/project-tools.d.ts.map +1 -1
- package/esm/cli/mcp/tools/project-tools.js +33 -3
- package/esm/cli/mcp/tools/run-lint-tool.d.ts +6 -0
- package/esm/cli/mcp/tools/run-lint-tool.d.ts.map +1 -1
- package/esm/cli/mcp/tools/run-lint-tool.js +10 -58
- package/esm/cli/mcp/tools/run-tests-tool.d.ts +6 -0
- package/esm/cli/mcp/tools/run-tests-tool.d.ts.map +1 -1
- package/esm/cli/mcp/tools/run-tests-tool.js +8 -32
- package/esm/cli/scaffold/engine.js +1 -1
- package/esm/cli/shared/animation.d.ts +8 -0
- package/esm/cli/shared/animation.d.ts.map +1 -1
- package/esm/cli/shared/animation.js +2 -7
- package/esm/cli/templates/manifest.js +7 -7
- package/esm/cli/utils/write-run-result.js +4 -4
- package/esm/deno.js +1 -1
- package/esm/src/agent/runtime/constants.js +1 -1
- package/esm/src/agent/runtime/index.js +3 -3
- package/esm/src/agent/runtime/text-generation-runtime-message-converter.d.ts +9 -0
- package/esm/src/agent/runtime/text-generation-runtime-message-converter.d.ts.map +1 -1
- package/esm/src/agent/runtime/text-generation-runtime-message-converter.js +15 -0
- package/esm/src/chat/conversation.d.ts.map +1 -1
- package/esm/src/chat/conversation.js +18 -2
- package/esm/src/platform/compat/process/command.d.ts.map +1 -1
- package/esm/src/platform/compat/process/command.js +4 -3
- package/esm/src/platform/compat/process/env.d.ts.map +1 -1
- package/esm/src/platform/compat/process/env.js +13 -9
- package/esm/src/platform/compat/process/lifecycle.d.ts.map +1 -1
- package/esm/src/platform/compat/process/lifecycle.js +55 -37
- package/esm/src/platform/compat/process/runtime-process.d.ts.map +1 -1
- package/esm/src/platform/compat/process/runtime-process.js +4 -3
- package/esm/src/platform/compat/runtime.d.ts +2 -0
- package/esm/src/platform/compat/runtime.d.ts.map +1 -1
- package/esm/src/platform/compat/runtime.js +14 -6
- package/esm/src/platform/compat/stdin.d.ts.map +1 -1
- package/esm/src/platform/compat/stdin.js +17 -13
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
import * as dntShim from "../../../../_dnt.shims.js";
|
|
2
|
-
import { isBun as IS_BUN, isDeno as IS_DENO } from "../runtime.js";
|
|
2
|
+
import { getDenoRuntime, isBun as IS_BUN, isDeno as IS_DENO } from "../runtime.js";
|
|
3
3
|
import { runtimeProcess } from "./runtime-process.js";
|
|
4
4
|
/** Get command-line arguments (cross-runtime: Deno.args or process.argv). */
|
|
5
5
|
export function getArgs() {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
7
|
+
if (deno)
|
|
8
|
+
return deno.args;
|
|
8
9
|
if (runtimeProcess)
|
|
9
10
|
return runtimeProcess.argv.slice(2);
|
|
10
11
|
return [];
|
|
11
12
|
}
|
|
12
13
|
/** Exit the process with an optional code (cross-runtime: Deno.exit or process.exit). */
|
|
13
14
|
export function exit(code) {
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
16
|
+
if (deno)
|
|
17
|
+
deno.exit(code);
|
|
16
18
|
if (runtimeProcess)
|
|
17
19
|
runtimeProcess.exit(code);
|
|
18
20
|
throw new Error("exit() is not supported in this runtime");
|
|
19
21
|
}
|
|
20
22
|
/** Return the current working directory. */
|
|
21
23
|
export function cwd() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
25
|
+
if (deno)
|
|
26
|
+
return deno.cwd();
|
|
24
27
|
if (runtimeProcess)
|
|
25
28
|
return runtimeProcess.cwd();
|
|
26
29
|
throw new Error("cwd() is not supported in this runtime");
|
|
27
30
|
}
|
|
28
31
|
export function chdir(directory) {
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
33
|
+
if (deno) {
|
|
34
|
+
deno.chdir(directory);
|
|
31
35
|
return;
|
|
32
36
|
}
|
|
33
37
|
if (runtimeProcess) {
|
|
@@ -37,15 +41,17 @@ export function chdir(directory) {
|
|
|
37
41
|
throw new Error("chdir() is not supported in this runtime");
|
|
38
42
|
}
|
|
39
43
|
export function pid() {
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
45
|
+
if (deno)
|
|
46
|
+
return deno.pid;
|
|
42
47
|
if (runtimeProcess)
|
|
43
48
|
return runtimeProcess.pid;
|
|
44
49
|
return 0;
|
|
45
50
|
}
|
|
46
51
|
export function memoryUsage() {
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
53
|
+
if (deno) {
|
|
54
|
+
const { rss, heapTotal, heapUsed, external } = deno.memoryUsage();
|
|
49
55
|
return { rss, heapTotal, heapUsed, external };
|
|
50
56
|
}
|
|
51
57
|
if (!runtimeProcess) {
|
|
@@ -58,8 +64,9 @@ export function memoryUsage() {
|
|
|
58
64
|
* Check if stdin is a TTY (terminal)
|
|
59
65
|
*/
|
|
60
66
|
export function isInteractive() {
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
68
|
+
if (deno)
|
|
69
|
+
return deno.stdin.isTerminal();
|
|
63
70
|
if (runtimeProcess)
|
|
64
71
|
return runtimeProcess.stdin.isTTY ?? false;
|
|
65
72
|
return false;
|
|
@@ -68,8 +75,9 @@ export function isInteractive() {
|
|
|
68
75
|
* Check if stdout is a TTY (terminal)
|
|
69
76
|
*/
|
|
70
77
|
export function isStdoutTTY() {
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
79
|
+
if (deno)
|
|
80
|
+
return deno.stdout.isTerminal();
|
|
73
81
|
if (runtimeProcess)
|
|
74
82
|
return runtimeProcess.stdout.isTTY ?? false;
|
|
75
83
|
return false;
|
|
@@ -80,9 +88,10 @@ export function isStdoutTTY() {
|
|
|
80
88
|
*/
|
|
81
89
|
export function getTerminalSize() {
|
|
82
90
|
const defaultSize = { columns: 80, rows: 24 };
|
|
83
|
-
|
|
91
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
92
|
+
if (deno) {
|
|
84
93
|
try {
|
|
85
|
-
const { columns, rows } =
|
|
94
|
+
const { columns, rows } = deno.consoleSize();
|
|
86
95
|
return { columns, rows };
|
|
87
96
|
}
|
|
88
97
|
catch (_) {
|
|
@@ -102,8 +111,9 @@ export function getTerminalSize() {
|
|
|
102
111
|
* Get runtime version string
|
|
103
112
|
*/
|
|
104
113
|
export function getRuntimeVersion() {
|
|
105
|
-
|
|
106
|
-
|
|
114
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
115
|
+
if (deno)
|
|
116
|
+
return `Deno ${deno.version.deno}`;
|
|
107
117
|
if ("Bun" in dntShim.dntGlobalThis) {
|
|
108
118
|
return `Bun ${dntShim.dntGlobalThis.Bun.version}`;
|
|
109
119
|
}
|
|
@@ -116,8 +126,9 @@ export function getRuntimeVersion() {
|
|
|
116
126
|
* Returns: "darwin" (macOS), "linux", "windows", or the raw platform string
|
|
117
127
|
*/
|
|
118
128
|
export function getOsType() {
|
|
119
|
-
|
|
120
|
-
|
|
129
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
130
|
+
if (deno)
|
|
131
|
+
return deno.build.os;
|
|
121
132
|
if (runtimeProcess) {
|
|
122
133
|
// Node/Bun uses process.platform which returns "win32" for Windows
|
|
123
134
|
const platform = runtimeProcess.platform;
|
|
@@ -129,8 +140,9 @@ export function getOsType() {
|
|
|
129
140
|
* Register a signal handler (SIGINT, SIGTERM) for graceful shutdown
|
|
130
141
|
*/
|
|
131
142
|
export function onSignal(signal, handler) {
|
|
132
|
-
|
|
133
|
-
|
|
143
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
144
|
+
if (deno) {
|
|
145
|
+
deno.addSignalListener(signal, handler);
|
|
134
146
|
return;
|
|
135
147
|
}
|
|
136
148
|
if (runtimeProcess)
|
|
@@ -193,8 +205,9 @@ export function onGlobalError(onError) {
|
|
|
193
205
|
* Unreference a timer to prevent it from keeping the process alive
|
|
194
206
|
*/
|
|
195
207
|
export function unrefTimer(timerId) {
|
|
196
|
-
|
|
197
|
-
|
|
208
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
209
|
+
if (deno && typeof deno.unrefTimer === "function" && typeof timerId === "number") {
|
|
210
|
+
deno.unrefTimer(timerId);
|
|
198
211
|
return;
|
|
199
212
|
}
|
|
200
213
|
if (timerId && typeof timerId === "object") {
|
|
@@ -208,8 +221,9 @@ export function unrefTimer(timerId) {
|
|
|
208
221
|
* Get the executable path of the current runtime
|
|
209
222
|
*/
|
|
210
223
|
export function execPath() {
|
|
211
|
-
|
|
212
|
-
|
|
224
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
225
|
+
if (deno)
|
|
226
|
+
return deno.execPath();
|
|
213
227
|
if (runtimeProcess)
|
|
214
228
|
return runtimeProcess.execPath;
|
|
215
229
|
return "";
|
|
@@ -219,9 +233,10 @@ export function execPath() {
|
|
|
219
233
|
* Returns OS uptime on Deno, process uptime on Node.js
|
|
220
234
|
*/
|
|
221
235
|
export function uptime() {
|
|
222
|
-
|
|
236
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
237
|
+
if (deno) {
|
|
223
238
|
// Deno.osUptime() returns system uptime in seconds
|
|
224
|
-
return
|
|
239
|
+
return deno.osUptime?.() ?? 0;
|
|
225
240
|
}
|
|
226
241
|
if (runtimeProcess) {
|
|
227
242
|
// process.uptime() returns process uptime in seconds
|
|
@@ -234,9 +249,10 @@ export function uptime() {
|
|
|
234
249
|
* Returns null if not available (e.g., in browser/workers)
|
|
235
250
|
*/
|
|
236
251
|
export function getStdout() {
|
|
237
|
-
|
|
252
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
253
|
+
if (deno) {
|
|
238
254
|
const encoder = new TextEncoder();
|
|
239
|
-
return { write: (data) =>
|
|
255
|
+
return { write: (data) => deno.stdout.writeSync(encoder.encode(data)) };
|
|
240
256
|
}
|
|
241
257
|
const stdout = runtimeProcess?.stdout;
|
|
242
258
|
if (stdout) {
|
|
@@ -256,8 +272,9 @@ export function writeStdout(text) {
|
|
|
256
272
|
* Returns a promise that resolves when the write is complete
|
|
257
273
|
*/
|
|
258
274
|
export async function writeStdoutAsync(data) {
|
|
259
|
-
|
|
260
|
-
|
|
275
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
276
|
+
if (deno)
|
|
277
|
+
return await deno.stdout.write(data);
|
|
261
278
|
const stdout = runtimeProcess?.stdout;
|
|
262
279
|
if (stdout) {
|
|
263
280
|
return await new Promise((resolve, reject) => {
|
|
@@ -290,8 +307,9 @@ export function promptSync(message) {
|
|
|
290
307
|
*/
|
|
291
308
|
export function readStdinByteSync() {
|
|
292
309
|
const buf = new Uint8Array(1);
|
|
293
|
-
|
|
294
|
-
|
|
310
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
311
|
+
if (deno) {
|
|
312
|
+
const n = deno.stdin.readSync(buf);
|
|
295
313
|
return n ? buf[0] ?? null : null;
|
|
296
314
|
}
|
|
297
315
|
if (IS_BUN) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-process.d.ts","sourceRoot":"","sources":["../../../../../src/src/platform/compat/process/runtime-process.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,cAAc,GAAG,cAAc,cAAc,CAAC,CAAC;AAE3D;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,OAAO,GAAG,WAAW,IAAI,cAAc,CAIzF;AAED,eAAO,MAAM,cAAc,EAAE,cAAc,GAAG,IAEtC,CAAC;AAET,wBAAgB,iBAAiB,IAAI,OAAO,
|
|
1
|
+
{"version":3,"file":"runtime-process.d.ts","sourceRoot":"","sources":["../../../../../src/src/platform/compat/process/runtime-process.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,cAAc,GAAG,cAAc,cAAc,CAAC,CAAC;AAE3D;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,OAAO,GAAG,WAAW,IAAI,cAAc,CAIzF;AAED,eAAO,MAAM,cAAc,EAAE,cAAc,GAAG,IAEtC,CAAC;AAET,wBAAgB,iBAAiB,IAAI,OAAO,CAM3C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as dntShim from "../../../../_dnt.shims.js";
|
|
2
|
-
import { isDeno as IS_DENO } from "../runtime.js";
|
|
2
|
+
import { getDenoRuntime, isDeno as IS_DENO } from "../runtime.js";
|
|
3
3
|
const nodeProcess = dntShim.dntGlobalThis.process;
|
|
4
4
|
/**
|
|
5
5
|
* Detect a real Node/Bun process object.
|
|
@@ -16,8 +16,9 @@ export const runtimeProcess = testHasRuntimeProcess(nodeProcess)
|
|
|
16
16
|
? nodeProcess
|
|
17
17
|
: null;
|
|
18
18
|
export function isWindowsPlatform() {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
20
|
+
if (deno)
|
|
21
|
+
return deno.build.os === "windows";
|
|
21
22
|
const platform = runtimeProcess?.platform ??
|
|
22
23
|
dntShim.dntGlobalThis.process?.platform;
|
|
23
24
|
return platform === "win32";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
2
|
+
export declare function getDenoRuntime(): typeof dntShim.Deno | undefined;
|
|
1
3
|
/**
|
|
2
4
|
* Check if an executable path is a compiled Deno binary.
|
|
3
5
|
* Detects by binary name: "deno" or "deno.exe" = standard runtime, anything else = compiled.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/compat/runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/compat/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAelD,wBAAgB,cAAc,IAAI,OAAO,OAAO,CAAC,IAAI,GAAG,SAAS,CAWhE;AAMD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAOnE;AAmBD,uFAAuF;AACvF,eAAO,MAAM,KAAK,EAAE,OAAwB,CAAC;AAE7C,gGAAgG;AAChG,eAAO,MAAM,MAAM,EAAE,OAAoC,CAAC;AAE1D,0DAA0D;AAC1D,eAAO,MAAM,MAAM,EAAE,OAA4C,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,OAA0C,CAAC;AAExE,oDAAoD;AACpD,eAAO,MAAM,YAAY,EAAE,OAAgC,CAAC;AAE5D;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAK7C;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C"}
|
|
@@ -5,11 +5,18 @@ function hasNodeProcess() {
|
|
|
5
5
|
function hasBunGlobal() {
|
|
6
6
|
return globalThis.Bun != null;
|
|
7
7
|
}
|
|
8
|
+
export function getDenoRuntime() {
|
|
9
|
+
const deno = Reflect.get(globalThis, "Deno");
|
|
10
|
+
if (deno &&
|
|
11
|
+
typeof deno.version === "object" &&
|
|
12
|
+
typeof deno.build === "object" &&
|
|
13
|
+
typeof deno.build.os === "string") {
|
|
14
|
+
return deno;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
8
18
|
function hasRealDeno() {
|
|
9
|
-
return (
|
|
10
|
-
typeof globalThis.Deno.version === "object" &&
|
|
11
|
-
typeof globalThis.Deno.build === "object" &&
|
|
12
|
-
typeof globalThis.Deno.build.os === "string");
|
|
19
|
+
return getDenoRuntime() != null;
|
|
13
20
|
}
|
|
14
21
|
/**
|
|
15
22
|
* Check if an executable path is a compiled Deno binary.
|
|
@@ -26,10 +33,11 @@ export function testDenoCompiledDetection(execPath) {
|
|
|
26
33
|
}
|
|
27
34
|
/** Compiled Deno binaries cannot dynamically import HTTP URLs at runtime. */
|
|
28
35
|
function isDenoCompiledBinary() {
|
|
29
|
-
|
|
36
|
+
const deno = getDenoRuntime();
|
|
37
|
+
if (!deno)
|
|
30
38
|
return false;
|
|
31
39
|
try {
|
|
32
|
-
return testDenoCompiledDetection(
|
|
40
|
+
return testDenoCompiledDetection(deno.execPath());
|
|
33
41
|
}
|
|
34
42
|
catch (_) {
|
|
35
43
|
/* expected: Deno.execPath() may not be available in all environments */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdin.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/compat/stdin.ts"],"names":[],"mappings":"AAwBA;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"stdin.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/compat/stdin.ts"],"names":[],"mappings":"AAwBA;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAYjD;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAClE,WAAW,IAAI,IAAI,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,WAAW,CA4D5C;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CA8B/C;AAOD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACnC,KAAK,IAAI,IAAI,CAAC;CACf;AAKD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,YAAY,CAgCjF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC,CA+DrD"}
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
* @module platform/compat/stdin
|
|
5
5
|
*/
|
|
6
6
|
import * as dntShim from "../../../_dnt.shims.js";
|
|
7
|
-
import { isDeno } from "./runtime.js";
|
|
7
|
+
import { getDenoRuntime, isDeno } from "./runtime.js";
|
|
8
8
|
/**
|
|
9
9
|
* Set raw mode on stdin (enables character-by-character input)
|
|
10
10
|
*/
|
|
11
11
|
export function setRawMode(enabled) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const deno = isDeno ? getDenoRuntime() : undefined;
|
|
13
|
+
if (deno) {
|
|
14
|
+
deno.stdin.setRaw(enabled);
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
const stdin = process?.stdin;
|
|
@@ -25,8 +26,9 @@ export function setRawMode(enabled) {
|
|
|
25
26
|
* Returns an object with read() and releaseLock() methods
|
|
26
27
|
*/
|
|
27
28
|
export function getStdinReader() {
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
const deno = isDeno ? getDenoRuntime() : undefined;
|
|
30
|
+
if (deno) {
|
|
31
|
+
const reader = deno.stdin.readable.getReader();
|
|
30
32
|
return {
|
|
31
33
|
read: async () => {
|
|
32
34
|
const result = await reader.read();
|
|
@@ -83,15 +85,16 @@ export function getStdinReader() {
|
|
|
83
85
|
* Works in both Deno and Node.js.
|
|
84
86
|
*/
|
|
85
87
|
export function waitForKeypress() {
|
|
86
|
-
|
|
88
|
+
const deno = isDeno ? getDenoRuntime() : undefined;
|
|
89
|
+
if (deno) {
|
|
87
90
|
return (async () => {
|
|
88
|
-
|
|
89
|
-
const reader =
|
|
91
|
+
deno.stdin.setRaw(true);
|
|
92
|
+
const reader = deno.stdin.readable.getReader();
|
|
90
93
|
try {
|
|
91
94
|
await reader.read();
|
|
92
95
|
}
|
|
93
96
|
finally {
|
|
94
|
-
|
|
97
|
+
deno.stdin.setRaw(false);
|
|
95
98
|
reader.releaseLock();
|
|
96
99
|
}
|
|
97
100
|
})();
|
|
@@ -157,11 +160,12 @@ export function createEscapeBuffer(onTimeout) {
|
|
|
157
160
|
*/
|
|
158
161
|
export function waitForEnterOrExit() {
|
|
159
162
|
return new Promise((resolve) => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
+
const deno = isDeno ? getDenoRuntime() : undefined;
|
|
164
|
+
if (deno) {
|
|
165
|
+
deno.stdin.setRaw(true);
|
|
166
|
+
const reader = deno.stdin.readable.getReader();
|
|
163
167
|
const cleanup = (result) => {
|
|
164
|
-
|
|
168
|
+
deno.stdin.setRaw(false);
|
|
165
169
|
reader.releaseLock();
|
|
166
170
|
resolve(result);
|
|
167
171
|
};
|