Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 36 additions & 59 deletions .github/local-actions/branch-manager/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -41264,7 +41264,7 @@ function useKeypress(userHandler) {
const handler2 = withUpdates((_input, event) => {
if (ignore)
return;
signal.current(event, rl);
void signal.current(event, rl);
});
rl.input.on("keypress", handler2);
return () => {
Expand Down Expand Up @@ -41611,6 +41611,9 @@ var import_strip_ansi = __toESM(require_strip_ansi(), 1);
var import_ansi_escapes = __toESM(require_ansi_escapes(), 1);
var height = (content) => content.split("\n").length;
var lastLine = (content) => content.split("\n").pop() ?? "";
function cursorDown(n) {
return n > 0 ? import_ansi_escapes.default.cursorDown(n) : "";
}
var ScreenManager = class {
rl;
height = 0;
Expand All @@ -41621,6 +41624,11 @@ var ScreenManager = class {
this.rl = rl;
this.cursorPos = rl.getCursorPos();
}
write(content) {
this.rl.output.unmute();
this.rl.output.write(content);
this.rl.output.mute();
}
render(content, bottomContent = "") {
const promptLine = lastLine(content);
const rawPromptLine = (0, import_strip_ansi.default)(promptLine);
Expand All @@ -41642,44 +41650,23 @@ var ScreenManager = class {
if (bottomContentHeight > 0)
output += import_ansi_escapes.default.cursorUp(bottomContentHeight);
output += import_ansi_escapes.default.cursorTo(this.cursorPos.cols);
this.clean();
this.rl.output.unmute();
this.write(cursorDown(this.extraLinesUnderPrompt) + import_ansi_escapes.default.eraseLines(this.height) + output);
this.extraLinesUnderPrompt = bottomContentHeight;
this.height = height(output);
this.rl.output.write(output);
this.rl.output.mute();
}
checkCursorPos() {
const cursorPos = this.rl.getCursorPos();
if (cursorPos.cols !== this.cursorPos.cols) {
this.rl.output.unmute();
this.rl.output.write(import_ansi_escapes.default.cursorTo(cursorPos.cols));
this.rl.output.mute();
this.write(import_ansi_escapes.default.cursorTo(cursorPos.cols));
this.cursorPos = cursorPos;
}
}
clean() {
this.rl.output.unmute();
this.rl.output.write([
this.extraLinesUnderPrompt > 0 ? import_ansi_escapes.default.cursorDown(this.extraLinesUnderPrompt) : "",
import_ansi_escapes.default.eraseLines(this.height)
].join(""));
this.extraLinesUnderPrompt = 0;
this.rl.output.mute();
}
clearContent() {
this.rl.output.unmute();
this.rl.output.write([
this.extraLinesUnderPrompt > 0 ? import_ansi_escapes.default.cursorDown(this.extraLinesUnderPrompt) : "",
"\n"
].join(""));
this.rl.output.mute();
}
done() {
done({ clearContent }) {
this.rl.setPrompt("");
this.rl.output.unmute();
this.rl.output.write(import_ansi_escapes.default.cursorShow);
this.rl.output.end();
let output = cursorDown(this.extraLinesUnderPrompt);
output += clearContent ? import_ansi_escapes.default.eraseLines(this.height) : "\n";
output += import_ansi_escapes.default.cursorShow;
this.write(output);
this.rl.close();
}
};
Expand Down Expand Up @@ -41716,12 +41703,7 @@ function createPrompt(view) {
});
function onExit2() {
hooksCleanup();
if (context2 == null ? void 0 : context2.clearPromptOnDone) {
screen.clean();
} else {
screen.clearContent();
}
screen.done();
screen.done({ clearContent: Boolean(context2 == null ? void 0 : context2.clearPromptOnDone) });
removeExitListener();
rl.input.removeListener("keypress", checkCursorPos);
rl.removeListener("close", hooksCleanup);
Expand Down Expand Up @@ -42154,7 +42136,7 @@ var esm_default2 = createPrompt((config, done) => {
if (Separator.isSeparator(item)) {
return ` ${item.separator}`;
}
const line = item.name || item.value;
const line = String(item.name || item.value);
if (item.disabled) {
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
return theme.style.disabledChoice(`${line} ${disabledLabel}`);
Expand Down Expand Up @@ -42205,7 +42187,7 @@ ${page}${helpTipBottom}${error2}${import_ansi_escapes2.default.cursorHide}`;
var import_external_editor = __toESM(require_main2(), 1);
import { AsyncResource as AsyncResource4 } from "node:async_hooks";
var esm_default3 = createPrompt((config, done) => {
const { waitForUseInput = true, validate = () => true } = config;
const { waitForUseInput = true, postfix = ".txt", validate = () => true } = config;
const theme = makeTheme(config.theme);
const [status, setStatus] = useState("pending");
const [value, setValue] = useState(config.default || "");
Expand All @@ -42214,30 +42196,25 @@ var esm_default3 = createPrompt((config, done) => {
const prefix = usePrefix({ isLoading, theme });
function startEditor(rl) {
rl.pause();
(0, import_external_editor.editAsync)(
value,
AsyncResource4.bind(async (error3, answer) => {
rl.resume();
if (error3) {
setError(error3.toString());
const editCallback = AsyncResource4.bind(async (error3, answer) => {
rl.resume();
if (error3) {
setError(error3.toString());
} else {
setStatus("loading");
const isValid = await validate(answer);
if (isValid === true) {
setError(void 0);
setStatus("done");
done(answer);
} else {
setStatus("loading");
const isValid = await validate(answer);
if (isValid === true) {
setError(void 0);
setStatus("done");
done(answer);
} else {
setValue(answer);
setError(isValid || "You must provide a valid value");
setStatus("pending");
}
setValue(answer);
setError(isValid || "You must provide a valid value");
setStatus("pending");
}
}),
{
postfix: config.postfix || ".txt"
}
);
});
(0, import_external_editor.editAsync)(value, (error3, answer) => void editCallback(error3, answer), { postfix });
}
useEffect((rl) => {
if (!waitForUseInput) {
Expand Down Expand Up @@ -42456,7 +42433,7 @@ ${theme.style.help("(Use arrow keys to reveal more choices)")}`;
if (Separator.isSeparator(item)) {
return ` ${item.separator}`;
}
const line = item.name || item.value;
const line = String(item.name || item.value);
if (item.disabled) {
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
return theme.style.disabled(`${line} ${disabledLabel}`);
Expand Down
95 changes: 36 additions & 59 deletions .github/local-actions/changelog/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40827,7 +40827,7 @@ function useKeypress(userHandler) {
const handler2 = withUpdates((_input, event) => {
if (ignore)
return;
signal.current(event, rl);
void signal.current(event, rl);
});
rl.input.on("keypress", handler2);
return () => {
Expand Down Expand Up @@ -41174,6 +41174,9 @@ var import_strip_ansi = __toESM(require_strip_ansi(), 1);
var import_ansi_escapes = __toESM(require_ansi_escapes(), 1);
var height = (content) => content.split("\n").length;
var lastLine = (content) => content.split("\n").pop() ?? "";
function cursorDown(n) {
return n > 0 ? import_ansi_escapes.default.cursorDown(n) : "";
}
var ScreenManager = class {
rl;
height = 0;
Expand All @@ -41184,6 +41187,11 @@ var ScreenManager = class {
this.rl = rl;
this.cursorPos = rl.getCursorPos();
}
write(content) {
this.rl.output.unmute();
this.rl.output.write(content);
this.rl.output.mute();
}
render(content, bottomContent = "") {
const promptLine = lastLine(content);
const rawPromptLine = (0, import_strip_ansi.default)(promptLine);
Expand All @@ -41205,44 +41213,23 @@ var ScreenManager = class {
if (bottomContentHeight > 0)
output += import_ansi_escapes.default.cursorUp(bottomContentHeight);
output += import_ansi_escapes.default.cursorTo(this.cursorPos.cols);
this.clean();
this.rl.output.unmute();
this.write(cursorDown(this.extraLinesUnderPrompt) + import_ansi_escapes.default.eraseLines(this.height) + output);
this.extraLinesUnderPrompt = bottomContentHeight;
this.height = height(output);
this.rl.output.write(output);
this.rl.output.mute();
}
checkCursorPos() {
const cursorPos = this.rl.getCursorPos();
if (cursorPos.cols !== this.cursorPos.cols) {
this.rl.output.unmute();
this.rl.output.write(import_ansi_escapes.default.cursorTo(cursorPos.cols));
this.rl.output.mute();
this.write(import_ansi_escapes.default.cursorTo(cursorPos.cols));
this.cursorPos = cursorPos;
}
}
clean() {
this.rl.output.unmute();
this.rl.output.write([
this.extraLinesUnderPrompt > 0 ? import_ansi_escapes.default.cursorDown(this.extraLinesUnderPrompt) : "",
import_ansi_escapes.default.eraseLines(this.height)
].join(""));
this.extraLinesUnderPrompt = 0;
this.rl.output.mute();
}
clearContent() {
this.rl.output.unmute();
this.rl.output.write([
this.extraLinesUnderPrompt > 0 ? import_ansi_escapes.default.cursorDown(this.extraLinesUnderPrompt) : "",
"\n"
].join(""));
this.rl.output.mute();
}
done() {
done({ clearContent }) {
this.rl.setPrompt("");
this.rl.output.unmute();
this.rl.output.write(import_ansi_escapes.default.cursorShow);
this.rl.output.end();
let output = cursorDown(this.extraLinesUnderPrompt);
output += clearContent ? import_ansi_escapes.default.eraseLines(this.height) : "\n";
output += import_ansi_escapes.default.cursorShow;
this.write(output);
this.rl.close();
}
};
Expand Down Expand Up @@ -41279,12 +41266,7 @@ function createPrompt(view) {
});
function onExit2() {
hooksCleanup();
if (context3 == null ? void 0 : context3.clearPromptOnDone) {
screen.clean();
} else {
screen.clearContent();
}
screen.done();
screen.done({ clearContent: Boolean(context3 == null ? void 0 : context3.clearPromptOnDone) });
removeExitListener();
rl.input.removeListener("keypress", checkCursorPos);
rl.removeListener("close", hooksCleanup);
Expand Down Expand Up @@ -41717,7 +41699,7 @@ var esm_default2 = createPrompt((config2, done) => {
if (Separator.isSeparator(item)) {
return ` ${item.separator}`;
}
const line = item.name || item.value;
const line = String(item.name || item.value);
if (item.disabled) {
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
return theme.style.disabledChoice(`${line} ${disabledLabel}`);
Expand Down Expand Up @@ -41768,7 +41750,7 @@ ${page}${helpTipBottom}${error2}${import_ansi_escapes2.default.cursorHide}`;
var import_external_editor = __toESM(require_main2(), 1);
import { AsyncResource as AsyncResource4 } from "node:async_hooks";
var esm_default3 = createPrompt((config2, done) => {
const { waitForUseInput = true, validate = () => true } = config2;
const { waitForUseInput = true, postfix = ".txt", validate = () => true } = config2;
const theme = makeTheme(config2.theme);
const [status, setStatus] = useState("pending");
const [value, setValue] = useState(config2.default || "");
Expand All @@ -41777,30 +41759,25 @@ var esm_default3 = createPrompt((config2, done) => {
const prefix = usePrefix({ isLoading, theme });
function startEditor(rl) {
rl.pause();
(0, import_external_editor.editAsync)(
value,
AsyncResource4.bind(async (error3, answer) => {
rl.resume();
if (error3) {
setError(error3.toString());
const editCallback = AsyncResource4.bind(async (error3, answer) => {
rl.resume();
if (error3) {
setError(error3.toString());
} else {
setStatus("loading");
const isValid = await validate(answer);
if (isValid === true) {
setError(void 0);
setStatus("done");
done(answer);
} else {
setStatus("loading");
const isValid = await validate(answer);
if (isValid === true) {
setError(void 0);
setStatus("done");
done(answer);
} else {
setValue(answer);
setError(isValid || "You must provide a valid value");
setStatus("pending");
}
setValue(answer);
setError(isValid || "You must provide a valid value");
setStatus("pending");
}
}),
{
postfix: config2.postfix || ".txt"
}
);
});
(0, import_external_editor.editAsync)(value, (error3, answer) => void editCallback(error3, answer), { postfix });
}
useEffect((rl) => {
if (!waitForUseInput) {
Expand Down Expand Up @@ -42019,7 +41996,7 @@ ${theme.style.help("(Use arrow keys to reveal more choices)")}`;
if (Separator.isSeparator(item)) {
return ` ${item.separator}`;
}
const line = item.name || item.value;
const line = String(item.name || item.value);
if (item.disabled) {
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
return theme.style.disabled(`${line} ${disabledLabel}`);
Expand Down
Loading