perstack 0.0.62 → 0.0.64
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/cli.js +73 -3
- package/dist/bin/cli.js.map +1 -1
- package/package.json +7 -7
package/dist/bin/cli.js
CHANGED
|
@@ -13,15 +13,14 @@ import { existsSync, readdirSync, readFileSync, statSync } from 'fs';
|
|
|
13
13
|
import { spawn, execSync } from 'child_process';
|
|
14
14
|
import * as os from 'os';
|
|
15
15
|
import { render, useApp, useInput, Box, Text } from 'ink';
|
|
16
|
-
import { createContext, useMemo, useReducer, useState, useEffect, useCallback, useRef, useContext } from 'react';
|
|
17
|
-
import { useTextInput, useListNavigation } from '@perstack/tui-components';
|
|
16
|
+
import { createContext, useMemo, useReducer, useState, useEffect, useCallback, useRef, useInsertionEffect, useContext } from 'react';
|
|
18
17
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
19
18
|
import { useRun } from '@perstack/react';
|
|
20
19
|
|
|
21
20
|
// package.json
|
|
22
21
|
var package_default = {
|
|
23
22
|
name: "perstack",
|
|
24
|
-
version: "0.0.
|
|
23
|
+
version: "0.0.64",
|
|
25
24
|
description: "PerStack CLI"};
|
|
26
25
|
function getEnv(envPath) {
|
|
27
26
|
const env = Object.fromEntries(
|
|
@@ -5451,6 +5450,77 @@ var KEY_HINTS = {
|
|
|
5451
5450
|
NEW: `${KEY_BINDINGS.NEW}:New Run`,
|
|
5452
5451
|
CHECKPOINTS: `${KEY_BINDINGS.CHECKPOINTS}:Checkpoints`,
|
|
5453
5452
|
EVENTS: `${KEY_BINDINGS.EVENTS}:Events`};
|
|
5453
|
+
var useLatestRef = (value) => {
|
|
5454
|
+
const ref = useRef(value);
|
|
5455
|
+
useInsertionEffect(() => {
|
|
5456
|
+
ref.current = value;
|
|
5457
|
+
});
|
|
5458
|
+
return ref;
|
|
5459
|
+
};
|
|
5460
|
+
var useListNavigation = (options) => {
|
|
5461
|
+
const { items, onSelect, onBack } = options;
|
|
5462
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
5463
|
+
useEffect(() => {
|
|
5464
|
+
if (selectedIndex >= items.length && items.length > 0) {
|
|
5465
|
+
setSelectedIndex(items.length - 1);
|
|
5466
|
+
}
|
|
5467
|
+
}, [items.length, selectedIndex]);
|
|
5468
|
+
const handleNavigation = useCallback(
|
|
5469
|
+
(inputChar, key) => {
|
|
5470
|
+
if (key.upArrow && items.length > 0) {
|
|
5471
|
+
setSelectedIndex((prev) => Math.max(0, prev - 1));
|
|
5472
|
+
return true;
|
|
5473
|
+
}
|
|
5474
|
+
if (key.downArrow && items.length > 0) {
|
|
5475
|
+
setSelectedIndex((prev) => Math.min(items.length - 1, prev + 1));
|
|
5476
|
+
return true;
|
|
5477
|
+
}
|
|
5478
|
+
if (key.return && items[selectedIndex]) {
|
|
5479
|
+
onSelect?.(items[selectedIndex]);
|
|
5480
|
+
return true;
|
|
5481
|
+
}
|
|
5482
|
+
if ((key.escape || inputChar === "b") && onBack) {
|
|
5483
|
+
onBack();
|
|
5484
|
+
return true;
|
|
5485
|
+
}
|
|
5486
|
+
return false;
|
|
5487
|
+
},
|
|
5488
|
+
[items, selectedIndex, onSelect, onBack]
|
|
5489
|
+
);
|
|
5490
|
+
return { selectedIndex, handleNavigation };
|
|
5491
|
+
};
|
|
5492
|
+
var useTextInput = (options) => {
|
|
5493
|
+
const [input, setInput] = useState("");
|
|
5494
|
+
const inputRef = useLatestRef(input);
|
|
5495
|
+
const onSubmitRef = useLatestRef(options.onSubmit);
|
|
5496
|
+
const onCancelRef = useLatestRef(options.onCancel);
|
|
5497
|
+
const handleInput = useCallback(
|
|
5498
|
+
(inputChar, key) => {
|
|
5499
|
+
if (key.escape) {
|
|
5500
|
+
setInput("");
|
|
5501
|
+
onCancelRef.current?.();
|
|
5502
|
+
return;
|
|
5503
|
+
}
|
|
5504
|
+
if (key.return && inputRef.current.trim()) {
|
|
5505
|
+
onSubmitRef.current(inputRef.current.trim());
|
|
5506
|
+
setInput("");
|
|
5507
|
+
return;
|
|
5508
|
+
}
|
|
5509
|
+
if (key.backspace || key.delete) {
|
|
5510
|
+
setInput((prev) => prev.slice(0, -1));
|
|
5511
|
+
return;
|
|
5512
|
+
}
|
|
5513
|
+
if (!key.ctrl && !key.meta && inputChar) {
|
|
5514
|
+
setInput((prev) => prev + inputChar);
|
|
5515
|
+
}
|
|
5516
|
+
},
|
|
5517
|
+
[inputRef, onSubmitRef, onCancelRef]
|
|
5518
|
+
);
|
|
5519
|
+
const reset = useCallback(() => {
|
|
5520
|
+
setInput("");
|
|
5521
|
+
}, []);
|
|
5522
|
+
return { input, handleInput, reset };
|
|
5523
|
+
};
|
|
5454
5524
|
var ListBrowser = ({
|
|
5455
5525
|
title,
|
|
5456
5526
|
items,
|