Deployed the page to Github Pages.
This commit is contained in:
parent
1d79754e93
commit
2c89899458
62797 changed files with 6551425 additions and 15279 deletions
76
node_modules/@inquirer/editor/dist/cjs/index.js
generated
vendored
Normal file
76
node_modules/@inquirer/editor/dist/cjs/index.js
generated
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const node_async_hooks_1 = require("node:async_hooks");
|
||||
const external_editor_1 = require("external-editor");
|
||||
const core_1 = require("@inquirer/core");
|
||||
exports.default = (0, core_1.createPrompt)((config, done) => {
|
||||
const { waitForUseInput = true, postfix = '.txt', validate = () => true } = config;
|
||||
const theme = (0, core_1.makeTheme)(config.theme);
|
||||
const [status, setStatus] = (0, core_1.useState)('pending');
|
||||
const [value, setValue] = (0, core_1.useState)(config.default || '');
|
||||
const [errorMsg, setError] = (0, core_1.useState)();
|
||||
const isLoading = status === 'loading';
|
||||
const prefix = (0, core_1.usePrefix)({ isLoading, theme });
|
||||
function startEditor(rl) {
|
||||
rl.pause();
|
||||
// Note: The bind call isn't strictly required. But we need it for our mocks to work as expected.
|
||||
const editCallback = node_async_hooks_1.AsyncResource.bind((error, answer) => __awaiter(this, void 0, void 0, function* () {
|
||||
rl.resume();
|
||||
if (error) {
|
||||
setError(error.toString());
|
||||
}
|
||||
else {
|
||||
setStatus('loading');
|
||||
const isValid = yield validate(answer);
|
||||
if (isValid === true) {
|
||||
setError(undefined);
|
||||
setStatus('done');
|
||||
done(answer);
|
||||
}
|
||||
else {
|
||||
setValue(answer);
|
||||
setError(isValid || 'You must provide a valid value');
|
||||
setStatus('pending');
|
||||
}
|
||||
}
|
||||
}));
|
||||
(0, external_editor_1.editAsync)(value, (error, answer) => void editCallback(error, answer), { postfix });
|
||||
}
|
||||
(0, core_1.useEffect)((rl) => {
|
||||
if (!waitForUseInput) {
|
||||
startEditor(rl);
|
||||
}
|
||||
}, []);
|
||||
(0, core_1.useKeypress)((key, rl) => {
|
||||
// Ignore keypress while our prompt is doing other processing.
|
||||
if (status !== 'pending') {
|
||||
return;
|
||||
}
|
||||
if ((0, core_1.isEnterKey)(key)) {
|
||||
startEditor(rl);
|
||||
}
|
||||
});
|
||||
const message = theme.style.message(config.message);
|
||||
let helpTip = '';
|
||||
if (status === 'loading') {
|
||||
helpTip = theme.style.help('Received');
|
||||
}
|
||||
else if (status === 'pending') {
|
||||
const enterKey = theme.style.key('enter');
|
||||
helpTip = theme.style.help(`Press ${enterKey} to launch your preferred editor.`);
|
||||
}
|
||||
let error = '';
|
||||
if (errorMsg) {
|
||||
error = theme.style.error(errorMsg);
|
||||
}
|
||||
return [[prefix, message, helpTip].filter(Boolean).join(' '), error];
|
||||
});
|
12
node_modules/@inquirer/editor/dist/cjs/types/index.d.ts
generated
vendored
Normal file
12
node_modules/@inquirer/editor/dist/cjs/types/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { type Theme } from '@inquirer/core';
|
||||
import type { PartialDeep } from '@inquirer/type';
|
||||
type EditorConfig = {
|
||||
message: string;
|
||||
default?: string;
|
||||
postfix?: string;
|
||||
waitForUseInput?: boolean;
|
||||
validate?: (value: string) => boolean | string | Promise<string | boolean>;
|
||||
theme?: PartialDeep<Theme>;
|
||||
};
|
||||
declare const _default: import("@inquirer/type").Prompt<string, EditorConfig>;
|
||||
export default _default;
|
Loading…
Add table
Add a link
Reference in a new issue