rolldown 0.14.0 → 0.15.0-snapshot-b2570e7-20241204003545
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/cjs/cli.cjs +782 -854
- package/dist/cjs/experimental-index.cjs +68 -26
- package/dist/cjs/index.cjs +6 -8
- package/dist/cjs/parallel-plugin-worker.cjs +20 -14
- package/dist/cjs/parallel-plugin.cjs +1 -3
- package/dist/esm/cli.mjs +722 -796
- package/dist/esm/experimental-index.mjs +44 -7
- package/dist/esm/index.mjs +2 -4
- package/dist/esm/parallel-plugin-worker.mjs +15 -10
- package/dist/esm/parallel-plugin.mjs +1 -3
- package/dist/shared/{chunk-JoMxl5V2.cjs → chunk-BK2Ye-xa.cjs} +19 -6
- package/dist/shared/{consola.36c0034f-Xyw7SC_7.mjs → consola_36c0034f-DWsVjwtA.mjs} +218 -283
- package/dist/shared/{consola.36c0034f-HcmWcfPe.cjs → consola_36c0034f-_8_dG1Nr.cjs} +249 -295
- package/dist/shared/{prompt-hoPhcrA-.mjs → prompt-DGW8ZJmn.mjs} +125 -174
- package/dist/shared/{prompt-9Ij3R3TG.cjs → prompt-RFvZMmjc.cjs} +157 -204
- package/dist/shared/src-1jxF0vle.cjs +2917 -0
- package/dist/shared/src-Cm19F5A9.mjs +2789 -0
- package/dist/types/api/build.d.ts +16 -0
- package/dist/types/api/experimental.d.ts +7 -0
- package/dist/types/api/rolldown/index.d.ts +3 -0
- package/dist/types/api/rolldown/rolldown-build.d.ts +12 -0
- package/dist/types/api/watch/index.d.ts +3 -0
- package/dist/types/{watcher.d.ts → api/watch/watch-emitter.d.ts} +17 -17
- package/dist/types/api/watch/watcher.d.ts +13 -0
- package/dist/types/binding.d.ts +175 -40
- package/dist/types/builtin-plugin/alias-plugin.d.ts +10 -0
- package/dist/types/builtin-plugin/constructors.d.ts +20 -0
- package/dist/types/builtin-plugin/replace-plugin.d.ts +28 -0
- package/dist/types/{options/normalized-ecma-transform-plugin-config.d.ts → builtin-plugin/transform-plugin.d.ts} +2 -1
- package/dist/types/builtin-plugin/utils.d.ts +8 -0
- package/dist/types/cli/arguments/normalize.d.ts +2 -6
- package/dist/types/cli/arguments/schema.d.ts +169 -81
- package/dist/types/constants/plugin.d.ts +3 -1
- package/dist/types/experimental-index.d.ts +5 -2
- package/dist/types/index.d.ts +13 -10
- package/dist/types/log/locate-character/index.d.ts +13 -0
- package/dist/types/log/logger.d.ts +2 -16
- package/dist/types/log/logging.d.ts +6 -3
- package/dist/types/log/logs.d.ts +2 -0
- package/dist/types/options/input-options-schema.d.ts +596 -0
- package/dist/types/options/input-options.d.ts +74 -430
- package/dist/types/options/normalized-input-options.d.ts +17 -11
- package/dist/types/options/normalized-output-options.d.ts +57 -21
- package/dist/types/options/output-options-schema.d.ts +147 -0
- package/dist/types/options/output-options.d.ts +72 -265
- package/dist/types/options/watch-options.d.ts +5 -0
- package/dist/types/plugin/bindingify-build-hooks.d.ts +9 -11
- package/dist/types/plugin/bindingify-hook-filter.d.ts +5 -5
- package/dist/types/plugin/bindingify-output-hooks.d.ts +13 -16
- package/dist/types/plugin/bindingify-plugin.d.ts +12 -3
- package/dist/types/plugin/bindingify-watch-hooks.d.ts +3 -5
- package/dist/types/plugin/hook-filter.d.ts +1 -1
- package/dist/types/plugin/index.d.ts +21 -18
- package/dist/types/plugin/minimal-plugin-context.d.ts +15 -0
- package/dist/types/plugin/plugin-context-data.d.ts +4 -5
- package/dist/types/plugin/plugin-context.d.ts +9 -4
- package/dist/types/plugin/plugin-driver.d.ts +4 -5
- package/dist/types/plugin/transform-plugin-context.d.ts +4 -3
- package/dist/types/rollup-types.d.ts +1 -1
- package/dist/types/treeshake/index.d.ts +0 -12
- package/dist/types/treeshake/module-side-effects.d.ts +111 -11
- package/dist/types/types/rolldown-output.d.ts +11 -2
- package/dist/types/types/utils.d.ts +1 -0
- package/dist/types/utils/bindingify-input-options.d.ts +7 -0
- package/dist/types/utils/bindingify-output-options.d.ts +3 -0
- package/dist/types/utils/define-config.d.ts +3 -0
- package/dist/types/utils/error.d.ts +1 -0
- package/dist/types/utils/normalize-hook.d.ts +1 -1
- package/dist/types/utils/normalize-plugin-option.d.ts +8 -3
- package/dist/types/{options/utils.d.ts → utils/normalize-string-or-regex.d.ts} +1 -1
- package/dist/types/utils/transform-rendered-chunk.d.ts +4 -0
- package/dist/types/utils/transform-rendered-module.d.ts +3 -0
- package/dist/types/utils/transform-sourcemap.d.ts +2 -0
- package/dist/types/utils/transform-to-rollup-output.d.ts +1 -0
- package/package.json +30 -22
- package/dist/shared/rolldown-binding.wasi.cjs +0 -187
- package/dist/shared/src_index-3pqhEViJ.cjs +0 -2785
- package/dist/shared/src_index-ywYMd4vB.mjs +0 -2786
- package/dist/shared/wasi-worker-browser.mjs +0 -39
- package/dist/shared/wasi-worker.mjs +0 -63
- package/dist/shared/watcher-worker.js +0 -1
- package/dist/types/constants/types.d.ts +0 -1
- package/dist/types/options/bindingify-input-options.d.ts +0 -4
- package/dist/types/options/bindingify-output-options.d.ts +0 -3
- package/dist/types/options/normalized-alias-plugin-config.d.ts +0 -8
- package/dist/types/options/watch-option.d.ts +0 -5
- package/dist/types/plugin/builtin-plugin.d.ts +0 -81
- package/dist/types/rolldown-build.d.ts +0 -10
- package/dist/types/rolldown.d.ts +0 -12
- package/dist/types/types/rendered-module.d.ts +0 -2
- package/dist/types/utils/normalize-input-options.d.ts +0 -3
- package/dist/types/utils/normalize-output-options.d.ts +0 -3
- package/dist/types/utils/normalize-tree-shake.d.ts +0 -3
- /package/dist/types/{utils/type-assert.d.ts → types/assert.d.ts} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
require("node:
|
|
6
|
-
const
|
|
7
|
-
require("node:
|
|
8
|
-
const
|
|
9
|
-
const
|
|
2
|
+
const require_chunk = require('./chunk-BK2Ye-xa.cjs');
|
|
3
|
+
const require_consola_36c0034f = require('./consola_36c0034f-_8_dG1Nr.cjs');
|
|
4
|
+
const node_path = require_chunk.__toESM(require("node:path"));
|
|
5
|
+
const node_process = require_chunk.__toESM(require("node:process"));
|
|
6
|
+
const node_util = require_chunk.__toESM(require("node:util"));
|
|
7
|
+
const node_tty = require_chunk.__toESM(require("node:tty"));
|
|
8
|
+
const tty = require_chunk.__toESM(require("tty"));
|
|
9
|
+
const node_readline = require_chunk.__toESM(require("node:readline"));
|
|
10
10
|
|
|
11
11
|
//#region ../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/chunks/prompt.mjs
|
|
12
12
|
const ESC = "\x1B";
|
|
@@ -61,9 +61,9 @@ var src = {
|
|
|
61
61
|
erase,
|
|
62
62
|
beep
|
|
63
63
|
};
|
|
64
|
-
var picocolors = {exports: {}};
|
|
65
|
-
let tty =
|
|
66
|
-
let isColorSupported = !("NO_COLOR"in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR"in process.env || process.argv.includes("--color") || process.platform === "win32" || tty.isatty(1) && process.env.TERM !== "dumb" || "CI"in process.env);
|
|
64
|
+
var picocolors = { exports: {} };
|
|
65
|
+
let tty$1 = tty.default;
|
|
66
|
+
let isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || tty$1.isatty(1) && process.env.TERM !== "dumb" || "CI" in process.env);
|
|
67
67
|
let formatter = (open, close, replace = open) => (input) => {
|
|
68
68
|
let string = "" + input;
|
|
69
69
|
let index = string.indexOf(close, open.length);
|
|
@@ -106,7 +106,7 @@ let createColors = (enabled = isColorSupported) => ({
|
|
|
106
106
|
picocolors.exports = createColors();
|
|
107
107
|
picocolors.exports.createColors = createColors;
|
|
108
108
|
var picocolorsExports = picocolors.exports;
|
|
109
|
-
const l = /*@__PURE__*/ getDefaultExportFromCjs(picocolorsExports);
|
|
109
|
+
const l = /*@__PURE__*/ require_consola_36c0034f.getDefaultExportFromCjs(picocolorsExports);
|
|
110
110
|
function z({ onlyFirst: t = !1 } = {}) {
|
|
111
111
|
const u = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");
|
|
112
112
|
return new RegExp(u, t ? void 0 : "g");
|
|
@@ -256,11 +256,19 @@ function U() {
|
|
|
256
256
|
hexToRgb: {
|
|
257
257
|
value: (u) => {
|
|
258
258
|
const F = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));
|
|
259
|
-
if (!F) return [
|
|
259
|
+
if (!F) return [
|
|
260
|
+
0,
|
|
261
|
+
0,
|
|
262
|
+
0
|
|
263
|
+
];
|
|
260
264
|
let [e] = F;
|
|
261
|
-
e.length === 3 && (e =
|
|
265
|
+
e.length === 3 && (e = [...e].map((C) => C + C).join(""));
|
|
262
266
|
const s$1 = Number.parseInt(e, 16);
|
|
263
|
-
return [
|
|
267
|
+
return [
|
|
268
|
+
s$1 >> 16 & 255,
|
|
269
|
+
s$1 >> 8 & 255,
|
|
270
|
+
s$1 & 255
|
|
271
|
+
];
|
|
264
272
|
},
|
|
265
273
|
enumerable: !1
|
|
266
274
|
},
|
|
@@ -296,12 +304,12 @@ else {
|
|
|
296
304
|
}
|
|
297
305
|
}), r;
|
|
298
306
|
}
|
|
299
|
-
const q = U(), p = new Set(["\x1B", ""]), J = 39, b = "\x07", W = "[", Q = "]", I = "m", w = `${Q}8;;`, N = (t) => `${
|
|
307
|
+
const q = U(), p = new Set(["\x1B", ""]), J = 39, b = "\x07", W = "[", Q = "]", I = "m", w = `${Q}8;;`, N = (t) => `${p.values().next().value}${W}${t}${I}`, j = (t) => `${p.values().next().value}${w}${t}${b}`, X = (t) => t.split(" ").map((u) => c(u)), _ = (t, u, F) => {
|
|
300
308
|
const e = [...u];
|
|
301
309
|
let s$1 = !1, C = !1, D = c($(t[t.length - 1]));
|
|
302
310
|
for (const [i, o] of e.entries()) {
|
|
303
311
|
const E = c(o);
|
|
304
|
-
if (D + E <= F ? t[t.length - 1] += o : (t.push(o), D = 0), p.has(o) && (s$1 = !0, C =
|
|
312
|
+
if (D + E <= F ? t[t.length - 1] += o : (t.push(o), D = 0), p.has(o) && (s$1 = !0, C = e.slice(i + 1).join("").startsWith(w)), s$1) {
|
|
305
313
|
C ? o === b && (s$1 = !1, C = !1) : o === I && (s$1 = !1);
|
|
306
314
|
continue;
|
|
307
315
|
}
|
|
@@ -312,13 +320,13 @@ const q = U(), p = new Set(["\x1B", ""]), J = 39, b = "\x07", W = "[", Q = "]"
|
|
|
312
320
|
const u = t.split(" ");
|
|
313
321
|
let F = u.length;
|
|
314
322
|
for (; F > 0 && !(c(u[F - 1]) > 0);) F--;
|
|
315
|
-
return F === u.length ? t :
|
|
323
|
+
return F === u.length ? t : u.slice(0, F).join(" ") + u.slice(F).join("");
|
|
316
324
|
}, uD = (t, u, F = {}) => {
|
|
317
325
|
if (F.trim !== !1 && t.trim() === "") return "";
|
|
318
326
|
let e = "", s$1, C;
|
|
319
327
|
const D = X(t);
|
|
320
328
|
let i = [""];
|
|
321
|
-
for (const [E, a] of
|
|
329
|
+
for (const [E, a] of t.split(" ").entries()) {
|
|
322
330
|
F.trim !== !1 && (i[i.length - 1] = i[i.length - 1].trimStart());
|
|
323
331
|
let n = c(i[i.length - 1]);
|
|
324
332
|
if (E !== 0 && (n >= u && (F.wordWrap === !1 || F.trim === !1) && (i.push(""), n = 0), (n > 0 || F.trim === !1) && (i[i.length - 1] += " ", n++)), F.hard && D[E] > u) {
|
|
@@ -344,7 +352,7 @@ const q = U(), p = new Set(["\x1B", ""]), J = 39, b = "\x07", W = "[", Q = "]"
|
|
|
344
352
|
`)];
|
|
345
353
|
for (const [E, a] of o.entries()) {
|
|
346
354
|
if (e += a, p.has(a)) {
|
|
347
|
-
const { groups: B } =
|
|
355
|
+
const { groups: B } = new RegExp(`(?:\\${W}(?<code>\\d+)m|\\${w}(?<uri>.*)${b})`).exec(o.slice(E).join("")) || { groups: {} };
|
|
348
356
|
if (B.code !== void 0) {
|
|
349
357
|
const A = Number.parseFloat(B.code);
|
|
350
358
|
s$1 = A === J ? void 0 : A;
|
|
@@ -358,9 +366,9 @@ const q = U(), p = new Set(["\x1B", ""]), J = 39, b = "\x07", W = "[", Q = "]"
|
|
|
358
366
|
return e;
|
|
359
367
|
};
|
|
360
368
|
function P(t, u, F) {
|
|
361
|
-
return
|
|
362
|
-
`)
|
|
363
|
-
`)
|
|
369
|
+
return String(t).normalize().replace(/\r\n/g, `
|
|
370
|
+
`).split(`
|
|
371
|
+
`).map((e) => uD(e, u, F)).join(`
|
|
364
372
|
`);
|
|
365
373
|
}
|
|
366
374
|
function FD(t, u) {
|
|
@@ -375,22 +383,34 @@ const R = Symbol("clack:cancel");
|
|
|
375
383
|
function g(t, u) {
|
|
376
384
|
t.isTTY && t.setRawMode(u);
|
|
377
385
|
}
|
|
378
|
-
const V = new Map([
|
|
379
|
-
|
|
380
|
-
|
|
386
|
+
const V = new Map([
|
|
387
|
+
["k", "up"],
|
|
388
|
+
["j", "down"],
|
|
389
|
+
["h", "left"],
|
|
390
|
+
["l", "right"]
|
|
391
|
+
]), tD = new Set([
|
|
392
|
+
"up",
|
|
393
|
+
"down",
|
|
394
|
+
"left",
|
|
395
|
+
"right",
|
|
396
|
+
"space",
|
|
397
|
+
"enter"
|
|
398
|
+
]);
|
|
399
|
+
var h = class {
|
|
400
|
+
constructor({ render: u, input: F = node_process.stdin, output: e = node_process.stdout,...s$1 }, C = !0) {
|
|
381
401
|
this._track = !1, this._cursor = 0, this.state = "initial", this.error = "", this.subscribers = new Map(), this._prevFrame = "", this.opts = s$1, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = u.bind(this), this._track = C, this.input = F, this.output = e;
|
|
382
402
|
}
|
|
383
403
|
prompt() {
|
|
384
|
-
const u = new WriteStream(0);
|
|
404
|
+
const u = new node_tty.WriteStream(0);
|
|
385
405
|
return u._write = (F, e, s$1) => {
|
|
386
406
|
this._track && (this.value = this.rl.line.replace(/\t/g, ""), this._cursor = this.rl.cursor, this.emit("value", this.value)), s$1();
|
|
387
|
-
}, this.input.pipe(u), this.rl =
|
|
407
|
+
}, this.input.pipe(u), this.rl = node_readline.default.createInterface({
|
|
388
408
|
input: this.input,
|
|
389
409
|
output: u,
|
|
390
410
|
tabSize: 2,
|
|
391
411
|
prompt: "",
|
|
392
412
|
escapeCodeTimeout: 50
|
|
393
|
-
}),
|
|
413
|
+
}), node_readline.default.emitKeypressEvents(this.input, this.rl), this.rl.prompt(), this.opts.initialValue !== void 0 && this._track && this.rl.write(this.opts.initialValue), this.input.on("keypress", this.onKeypress), g(this.input, !0), this.output.on("resize", this.render), this.render(), new Promise((F, e) => {
|
|
394
414
|
this.once("submit", () => {
|
|
395
415
|
this.output.write(src.cursor.show), this.output.off("resize", this.render), g(this.input, !1), F(this.value);
|
|
396
416
|
}), this.once("cancel", () => {
|
|
@@ -400,7 +420,7 @@ class h {
|
|
|
400
420
|
}
|
|
401
421
|
on(u, F) {
|
|
402
422
|
const e = this.subscribers.get(u) ?? [];
|
|
403
|
-
e.push({cb: F}), this.subscribers.set(u, e);
|
|
423
|
+
e.push({ cb: F }), this.subscribers.set(u, e);
|
|
404
424
|
}
|
|
405
425
|
once(u, F) {
|
|
406
426
|
const e = this.subscribers.get(u) ?? [];
|
|
@@ -432,12 +452,12 @@ class h {
|
|
|
432
452
|
`), g(this.input, !1), this.rl.close(), this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
433
453
|
}
|
|
434
454
|
restoreCursor() {
|
|
435
|
-
const u =
|
|
436
|
-
`)
|
|
455
|
+
const u = P(this._prevFrame, process.stdout.columns, { hard: !0 }).split(`
|
|
456
|
+
`).length - 1;
|
|
437
457
|
this.output.write(src.cursor.move(-999, u * -1));
|
|
438
458
|
}
|
|
439
459
|
render() {
|
|
440
|
-
const u = P(this._render(this) ?? "", process.stdout.columns, {hard: !0});
|
|
460
|
+
const u = P(this._render(this) ?? "", process.stdout.columns, { hard: !0 });
|
|
441
461
|
if (u !== this._prevFrame) {
|
|
442
462
|
if (this.state === "initial") this.output.write(src.cursor.hide);
|
|
443
463
|
else {
|
|
@@ -452,8 +472,8 @@ else {
|
|
|
452
472
|
} else if (F && F?.length > 1) {
|
|
453
473
|
const e = F[0];
|
|
454
474
|
this.output.write(src.cursor.move(0, e)), this.output.write(src.erase.down());
|
|
455
|
-
const C =
|
|
456
|
-
`)
|
|
475
|
+
const C = u.split(`
|
|
476
|
+
`).slice(e);
|
|
457
477
|
this.output.write(C.join(`
|
|
458
478
|
`)), this._prevFrame = u;
|
|
459
479
|
return;
|
|
@@ -463,8 +483,8 @@ else {
|
|
|
463
483
|
this.output.write(u), this.state === "initial" && (this.state = "active"), this._prevFrame = u;
|
|
464
484
|
}
|
|
465
485
|
}
|
|
466
|
-
}
|
|
467
|
-
|
|
486
|
+
};
|
|
487
|
+
var sD = class extends h {
|
|
468
488
|
get cursor() {
|
|
469
489
|
return this.value ? 0 : 1;
|
|
470
490
|
}
|
|
@@ -480,8 +500,8 @@ class sD extends h {
|
|
|
480
500
|
this.value = !this.value;
|
|
481
501
|
});
|
|
482
502
|
}
|
|
483
|
-
}
|
|
484
|
-
|
|
503
|
+
};
|
|
504
|
+
var iD = class extends h {
|
|
485
505
|
constructor(u) {
|
|
486
506
|
super(u, !1), this.cursor = 0, this.options = u.options, this.value = [...u.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: F }) => F === u.cursorAt), 0), this.on("key", (F) => {
|
|
487
507
|
F === "a" && this.toggleAll();
|
|
@@ -512,8 +532,8 @@ class iD extends h {
|
|
|
512
532
|
const u = this.value.includes(this._value);
|
|
513
533
|
this.value = u ? this.value.filter((F) => F !== this._value) : [...this.value, this._value];
|
|
514
534
|
}
|
|
515
|
-
}
|
|
516
|
-
|
|
535
|
+
};
|
|
536
|
+
var ED = class extends h {
|
|
517
537
|
constructor(u) {
|
|
518
538
|
super(u, !1), this.cursor = 0, this.options = u.options, this.cursor = this.options.findIndex(({ value: F }) => F === u.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (F) => {
|
|
519
539
|
switch (F) {
|
|
@@ -535,8 +555,8 @@ class ED extends h {
|
|
|
535
555
|
changeValue() {
|
|
536
556
|
this.value = this._value.value;
|
|
537
557
|
}
|
|
538
|
-
}
|
|
539
|
-
|
|
558
|
+
};
|
|
559
|
+
var oD = class extends h {
|
|
540
560
|
constructor(u) {
|
|
541
561
|
super(u), this.valueWithCursor = "", this.on("finalize", () => {
|
|
542
562
|
this.value || (this.value = u.defaultValue), this.valueWithCursor = this.value;
|
|
@@ -551,8 +571,8 @@ else {
|
|
|
551
571
|
get cursor() {
|
|
552
572
|
return this._cursor;
|
|
553
573
|
}
|
|
554
|
-
}
|
|
555
|
-
const unicode = isUnicodeSupported();
|
|
574
|
+
};
|
|
575
|
+
const unicode = require_consola_36c0034f.isUnicodeSupported();
|
|
556
576
|
const s = (c$1, fallback) => unicode ? c$1 : fallback;
|
|
557
577
|
const S_STEP_ACTIVE = s("❯", ">");
|
|
558
578
|
const S_STEP_CANCEL = s("■", "x");
|
|
@@ -568,242 +588,175 @@ const S_CHECKBOX_INACTIVE = s("◻", "[ ]");
|
|
|
568
588
|
const symbol = (state) => {
|
|
569
589
|
switch (state) {
|
|
570
590
|
case "initial":
|
|
571
|
-
case "active":
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
case "
|
|
575
|
-
return colors.red(S_STEP_CANCEL);
|
|
576
|
-
}
|
|
577
|
-
case "error": {
|
|
578
|
-
return colors.yellow(S_STEP_ERROR);
|
|
579
|
-
}
|
|
580
|
-
case "submit": {
|
|
581
|
-
return colors.green(S_STEP_SUBMIT);
|
|
582
|
-
}
|
|
591
|
+
case "active": return require_consola_36c0034f.colors.cyan(S_STEP_ACTIVE);
|
|
592
|
+
case "cancel": return require_consola_36c0034f.colors.red(S_STEP_CANCEL);
|
|
593
|
+
case "error": return require_consola_36c0034f.colors.yellow(S_STEP_ERROR);
|
|
594
|
+
case "submit": return require_consola_36c0034f.colors.green(S_STEP_SUBMIT);
|
|
583
595
|
}
|
|
584
596
|
};
|
|
585
597
|
const text = (opts) => {
|
|
586
|
-
return
|
|
598
|
+
return new oD({
|
|
587
599
|
validate: opts.validate,
|
|
588
600
|
placeholder: opts.placeholder,
|
|
589
601
|
defaultValue: opts.defaultValue,
|
|
590
602
|
initialValue: opts.initialValue,
|
|
591
603
|
render() {
|
|
592
|
-
const title = `${colors.gray(S_BAR)}
|
|
604
|
+
const title = `${require_consola_36c0034f.colors.gray(S_BAR)}
|
|
593
605
|
${symbol(this.state)} ${opts.message}
|
|
594
606
|
`;
|
|
595
|
-
const placeholder = opts.placeholder ? colors.inverse(opts.placeholder[0]) + colors.dim(opts.placeholder.slice(1)) : colors.inverse(colors.hidden("_"));
|
|
607
|
+
const placeholder = opts.placeholder ? require_consola_36c0034f.colors.inverse(opts.placeholder[0]) + require_consola_36c0034f.colors.dim(opts.placeholder.slice(1)) : require_consola_36c0034f.colors.inverse(require_consola_36c0034f.colors.hidden("_"));
|
|
596
608
|
const value = this.value ? this.valueWithCursor : placeholder;
|
|
597
609
|
switch (this.state) {
|
|
598
|
-
case "error": {
|
|
599
|
-
|
|
600
|
-
${colors.yellow(
|
|
601
|
-
${colors.yellow(S_BAR_END)} ${colors.yellow(this.error)}
|
|
610
|
+
case "error": return `${title.trim()}
|
|
611
|
+
${require_consola_36c0034f.colors.yellow(S_BAR)} ${value}
|
|
612
|
+
${require_consola_36c0034f.colors.yellow(S_BAR_END)} ${require_consola_36c0034f.colors.yellow(this.error)}
|
|
602
613
|
`;
|
|
603
|
-
}
|
|
604
|
-
case "
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
case "cancel": {
|
|
608
|
-
return `${title}${colors.gray(S_BAR)} ${colors.strikethrough(colors.dim(this.value ?? ""))}${this.value?.trim() ? "\n" + colors.gray(S_BAR) : ""}`;
|
|
609
|
-
}
|
|
610
|
-
default: {
|
|
611
|
-
return `${title}${colors.cyan(S_BAR)} ${value}
|
|
612
|
-
${colors.cyan(S_BAR_END)}
|
|
614
|
+
case "submit": return `${title}${require_consola_36c0034f.colors.gray(S_BAR)} ${require_consola_36c0034f.colors.dim(this.value || opts.placeholder)}`;
|
|
615
|
+
case "cancel": return `${title}${require_consola_36c0034f.colors.gray(S_BAR)} ${require_consola_36c0034f.colors.strikethrough(require_consola_36c0034f.colors.dim(this.value ?? ""))}${this.value?.trim() ? "\n" + require_consola_36c0034f.colors.gray(S_BAR) : ""}`;
|
|
616
|
+
default: return `${title}${require_consola_36c0034f.colors.cyan(S_BAR)} ${value}
|
|
617
|
+
${require_consola_36c0034f.colors.cyan(S_BAR_END)}
|
|
613
618
|
`;
|
|
614
|
-
}
|
|
615
619
|
}
|
|
616
620
|
}
|
|
617
|
-
})
|
|
621
|
+
}).prompt();
|
|
618
622
|
};
|
|
619
623
|
const confirm = (opts) => {
|
|
620
624
|
const active = opts.active ?? "Yes";
|
|
621
625
|
const inactive = opts.inactive ?? "No";
|
|
622
|
-
return
|
|
626
|
+
return new sD({
|
|
623
627
|
active,
|
|
624
628
|
inactive,
|
|
625
629
|
initialValue: opts.initialValue ?? true,
|
|
626
630
|
render() {
|
|
627
|
-
const title = `${colors.gray(S_BAR)}
|
|
631
|
+
const title = `${require_consola_36c0034f.colors.gray(S_BAR)}
|
|
628
632
|
${symbol(this.state)} ${opts.message}
|
|
629
633
|
`;
|
|
630
634
|
const value = this.value ? active : inactive;
|
|
631
635
|
switch (this.state) {
|
|
632
|
-
case "submit": {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
${colors.gray(S_BAR)}`;
|
|
638
|
-
}
|
|
639
|
-
default: {
|
|
640
|
-
return `${title}${colors.cyan(S_BAR)} ${this.value ? `${colors.green(S_RADIO_ACTIVE)} ${active}` : `${colors.dim(S_RADIO_INACTIVE)} ${colors.dim(active)}`} ${colors.dim("/")} ${this.value ? `${colors.dim(S_RADIO_INACTIVE)} ${colors.dim(inactive)}` : `${colors.green(S_RADIO_ACTIVE)} ${inactive}`}
|
|
641
|
-
${colors.cyan(S_BAR_END)}
|
|
636
|
+
case "submit": return `${title}${require_consola_36c0034f.colors.gray(S_BAR)} ${require_consola_36c0034f.colors.dim(value)}`;
|
|
637
|
+
case "cancel": return `${title}${require_consola_36c0034f.colors.gray(S_BAR)} ${require_consola_36c0034f.colors.strikethrough(require_consola_36c0034f.colors.dim(value))}
|
|
638
|
+
${require_consola_36c0034f.colors.gray(S_BAR)}`;
|
|
639
|
+
default: return `${title}${require_consola_36c0034f.colors.cyan(S_BAR)} ${this.value ? `${require_consola_36c0034f.colors.green(S_RADIO_ACTIVE)} ${active}` : `${require_consola_36c0034f.colors.dim(S_RADIO_INACTIVE)} ${require_consola_36c0034f.colors.dim(active)}`} ${require_consola_36c0034f.colors.dim("/")} ${this.value ? `${require_consola_36c0034f.colors.dim(S_RADIO_INACTIVE)} ${require_consola_36c0034f.colors.dim(inactive)}` : `${require_consola_36c0034f.colors.green(S_RADIO_ACTIVE)} ${inactive}`}
|
|
640
|
+
${require_consola_36c0034f.colors.cyan(S_BAR_END)}
|
|
642
641
|
`;
|
|
643
|
-
}
|
|
644
642
|
}
|
|
645
643
|
}
|
|
646
|
-
})
|
|
644
|
+
}).prompt();
|
|
647
645
|
};
|
|
648
646
|
const select = (opts) => {
|
|
649
647
|
const opt = (option, state) => {
|
|
650
648
|
const label = option.label ?? String(option.value);
|
|
651
649
|
switch (state) {
|
|
652
|
-
case "active": {
|
|
653
|
-
|
|
654
|
-
}
|
|
655
|
-
case "selected": {
|
|
656
|
-
return `${colors.dim(label)}`;
|
|
657
|
-
}
|
|
658
|
-
case "cancelled": {
|
|
659
|
-
return `${colors.strikethrough(colors.dim(label))}`;
|
|
660
|
-
}
|
|
650
|
+
case "active": return `${require_consola_36c0034f.colors.green(S_RADIO_ACTIVE)} ${label} ${option.hint ? require_consola_36c0034f.colors.dim(`(${option.hint})`) : ""}`;
|
|
651
|
+
case "selected": return `${require_consola_36c0034f.colors.dim(label)}`;
|
|
652
|
+
case "cancelled": return `${require_consola_36c0034f.colors.strikethrough(require_consola_36c0034f.colors.dim(label))}`;
|
|
661
653
|
}
|
|
662
|
-
return `${colors.dim(S_RADIO_INACTIVE)} ${colors.dim(label)}`;
|
|
654
|
+
return `${require_consola_36c0034f.colors.dim(S_RADIO_INACTIVE)} ${require_consola_36c0034f.colors.dim(label)}`;
|
|
663
655
|
};
|
|
664
|
-
return
|
|
656
|
+
return new ED({
|
|
665
657
|
options: opts.options,
|
|
666
658
|
initialValue: opts.initialValue,
|
|
667
659
|
render() {
|
|
668
|
-
const title = `${colors.gray(S_BAR)}
|
|
660
|
+
const title = `${require_consola_36c0034f.colors.gray(S_BAR)}
|
|
669
661
|
${symbol(this.state)} ${opts.message}
|
|
670
662
|
`;
|
|
671
663
|
switch (this.state) {
|
|
672
|
-
case "submit": {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
${colors.
|
|
678
|
-
}
|
|
679
|
-
default: {
|
|
680
|
-
return `${title}${colors.cyan(S_BAR)} ${(this.options.map((option, i) => opt(option, i === this.cursor ? "active" : "inactive"))).join(`
|
|
681
|
-
${colors.cyan(S_BAR)} `)}
|
|
682
|
-
${colors.cyan(S_BAR_END)}
|
|
664
|
+
case "submit": return `${title}${require_consola_36c0034f.colors.gray(S_BAR)} ${opt(this.options[this.cursor], "selected")}`;
|
|
665
|
+
case "cancel": return `${title}${require_consola_36c0034f.colors.gray(S_BAR)} ${opt(this.options[this.cursor], "cancelled")}
|
|
666
|
+
${require_consola_36c0034f.colors.gray(S_BAR)}`;
|
|
667
|
+
default: return `${title}${require_consola_36c0034f.colors.cyan(S_BAR)} ${this.options.map((option, i) => opt(option, i === this.cursor ? "active" : "inactive")).join(`
|
|
668
|
+
${require_consola_36c0034f.colors.cyan(S_BAR)} `)}
|
|
669
|
+
${require_consola_36c0034f.colors.cyan(S_BAR_END)}
|
|
683
670
|
`;
|
|
684
|
-
}
|
|
685
671
|
}
|
|
686
672
|
}
|
|
687
|
-
})
|
|
673
|
+
}).prompt();
|
|
688
674
|
};
|
|
689
675
|
const multiselect = (opts) => {
|
|
690
676
|
const opt = (option, state) => {
|
|
691
677
|
const label = option.label ?? String(option.value);
|
|
692
678
|
switch (state) {
|
|
693
|
-
case "active": {
|
|
694
|
-
|
|
695
|
-
}
|
|
696
|
-
case "selected": {
|
|
697
|
-
|
|
698
|
-
}
|
|
699
|
-
case "cancelled": {
|
|
700
|
-
return `${colors.strikethrough(colors.dim(label))}`;
|
|
701
|
-
}
|
|
702
|
-
case "active-selected": {
|
|
703
|
-
return `${colors.green(S_CHECKBOX_SELECTED)} ${label} ${option.hint ? colors.dim(`(${option.hint})`) : ""}`;
|
|
704
|
-
}
|
|
705
|
-
case "submitted": {
|
|
706
|
-
return `${colors.dim(label)}`;
|
|
707
|
-
}
|
|
679
|
+
case "active": return `${require_consola_36c0034f.colors.cyan(S_CHECKBOX_ACTIVE)} ${label} ${option.hint ? require_consola_36c0034f.colors.dim(`(${option.hint})`) : ""}`;
|
|
680
|
+
case "selected": return `${require_consola_36c0034f.colors.green(S_CHECKBOX_SELECTED)} ${require_consola_36c0034f.colors.dim(label)}`;
|
|
681
|
+
case "cancelled": return `${require_consola_36c0034f.colors.strikethrough(require_consola_36c0034f.colors.dim(label))}`;
|
|
682
|
+
case "active-selected": return `${require_consola_36c0034f.colors.green(S_CHECKBOX_SELECTED)} ${label} ${option.hint ? require_consola_36c0034f.colors.dim(`(${option.hint})`) : ""}`;
|
|
683
|
+
case "submitted": return `${require_consola_36c0034f.colors.dim(label)}`;
|
|
708
684
|
}
|
|
709
|
-
return `${colors.dim(S_CHECKBOX_INACTIVE)} ${colors.dim(label)}`;
|
|
685
|
+
return `${require_consola_36c0034f.colors.dim(S_CHECKBOX_INACTIVE)} ${require_consola_36c0034f.colors.dim(label)}`;
|
|
710
686
|
};
|
|
711
|
-
return
|
|
687
|
+
return new iD({
|
|
712
688
|
options: opts.options,
|
|
713
689
|
initialValues: opts.initialValues,
|
|
714
690
|
required: opts.required ?? true,
|
|
715
691
|
cursorAt: opts.cursorAt,
|
|
716
692
|
validate(selected) {
|
|
717
|
-
if (this.required && selected.length === 0)
|
|
718
|
-
|
|
719
|
-
${colors.reset(colors.dim(`Press ${colors.gray(colors.bgWhite(colors.inverse(" space ")))} to select, ${colors.gray(colors.bgWhite(colors.inverse(" enter ")))} to submit`))}`;
|
|
720
|
-
}
|
|
693
|
+
if (this.required && selected.length === 0) return `Please select at least one option.
|
|
694
|
+
${require_consola_36c0034f.colors.reset(require_consola_36c0034f.colors.dim(`Press ${require_consola_36c0034f.colors.gray(require_consola_36c0034f.colors.bgWhite(require_consola_36c0034f.colors.inverse(" space ")))} to select, ${require_consola_36c0034f.colors.gray(require_consola_36c0034f.colors.bgWhite(require_consola_36c0034f.colors.inverse(" enter ")))} to submit`))}`;
|
|
721
695
|
},
|
|
722
696
|
render() {
|
|
723
|
-
const title = `${colors.gray(S_BAR)}
|
|
697
|
+
const title = `${require_consola_36c0034f.colors.gray(S_BAR)}
|
|
724
698
|
${symbol(this.state)} ${opts.message}
|
|
725
699
|
`;
|
|
726
700
|
switch (this.state) {
|
|
727
|
-
case "submit": {
|
|
728
|
-
return `${title}${colors.gray(S_BAR)} ${((this.options.filter(({ value: value }) => this.value.includes(value))).map((option) => opt(option, "submitted"))).join(colors.dim(", ")) || colors.dim("none")}`;
|
|
729
|
-
}
|
|
701
|
+
case "submit": return `${title}${require_consola_36c0034f.colors.gray(S_BAR)} ${this.options.filter(({ value }) => this.value.includes(value)).map((option) => opt(option, "submitted")).join(require_consola_36c0034f.colors.dim(", ")) || require_consola_36c0034f.colors.dim("none")}`;
|
|
730
702
|
case "cancel": {
|
|
731
|
-
const label =
|
|
732
|
-
return `${title}${colors.gray(S_BAR)} ${label.trim() ? `${label}
|
|
733
|
-
${colors.gray(S_BAR)}` : ""}`;
|
|
703
|
+
const label = this.options.filter(({ value }) => this.value.includes(value)).map((option) => opt(option, "cancelled")).join(require_consola_36c0034f.colors.dim(", "));
|
|
704
|
+
return `${title}${require_consola_36c0034f.colors.gray(S_BAR)} ${label.trim() ? `${label}
|
|
705
|
+
${require_consola_36c0034f.colors.gray(S_BAR)}` : ""}`;
|
|
734
706
|
}
|
|
735
707
|
case "error": {
|
|
736
|
-
const footer =
|
|
737
|
-
return title + colors.yellow(S_BAR) + " " +
|
|
708
|
+
const footer = this.error.split("\n").map((ln, i) => i === 0 ? `${require_consola_36c0034f.colors.yellow(S_BAR_END)} ${require_consola_36c0034f.colors.yellow(ln)}` : ` ${ln}`).join("\n");
|
|
709
|
+
return title + require_consola_36c0034f.colors.yellow(S_BAR) + " " + this.options.map((option, i) => {
|
|
738
710
|
const selected = this.value.includes(option.value);
|
|
739
711
|
const active = i === this.cursor;
|
|
740
|
-
if (active && selected)
|
|
741
|
-
|
|
742
|
-
}
|
|
743
|
-
if (selected) {
|
|
744
|
-
return opt(option, "selected");
|
|
745
|
-
}
|
|
712
|
+
if (active && selected) return opt(option, "active-selected");
|
|
713
|
+
if (selected) return opt(option, "selected");
|
|
746
714
|
return opt(option, active ? "active" : "inactive");
|
|
747
|
-
})
|
|
748
|
-
${colors.yellow(S_BAR)} `) + "\n" + footer + "\n";
|
|
715
|
+
}).join(`
|
|
716
|
+
${require_consola_36c0034f.colors.yellow(S_BAR)} `) + "\n" + footer + "\n";
|
|
749
717
|
}
|
|
750
|
-
default: {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
}
|
|
760
|
-
return opt(option, active ? "active" : "inactive");
|
|
761
|
-
})).join(`
|
|
762
|
-
${colors.cyan(S_BAR)} `)}
|
|
763
|
-
${colors.cyan(S_BAR_END)}
|
|
718
|
+
default: return `${title}${require_consola_36c0034f.colors.cyan(S_BAR)} ${this.options.map((option, i) => {
|
|
719
|
+
const selected = this.value.includes(option.value);
|
|
720
|
+
const active = i === this.cursor;
|
|
721
|
+
if (active && selected) return opt(option, "active-selected");
|
|
722
|
+
if (selected) return opt(option, "selected");
|
|
723
|
+
return opt(option, active ? "active" : "inactive");
|
|
724
|
+
}).join(`
|
|
725
|
+
${require_consola_36c0034f.colors.cyan(S_BAR)} `)}
|
|
726
|
+
${require_consola_36c0034f.colors.cyan(S_BAR_END)}
|
|
764
727
|
`;
|
|
765
|
-
}
|
|
766
728
|
}
|
|
767
729
|
}
|
|
768
|
-
})
|
|
730
|
+
}).prompt();
|
|
769
731
|
};
|
|
770
732
|
async function prompt(message, opts = {}) {
|
|
771
|
-
if (!opts.type || opts.type === "text") {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
message,
|
|
797
|
-
options: opts.options.map((o) => typeof o === "string" ? {
|
|
798
|
-
value: o,
|
|
799
|
-
label: o
|
|
800
|
-
} : o),
|
|
801
|
-
required: opts.required
|
|
802
|
-
});
|
|
803
|
-
}
|
|
733
|
+
if (!opts.type || opts.type === "text") return await text({
|
|
734
|
+
message,
|
|
735
|
+
defaultValue: opts.default,
|
|
736
|
+
placeholder: opts.placeholder,
|
|
737
|
+
initialValue: opts.initial
|
|
738
|
+
});
|
|
739
|
+
if (opts.type === "confirm") return await confirm({
|
|
740
|
+
message,
|
|
741
|
+
initialValue: opts.initial
|
|
742
|
+
});
|
|
743
|
+
if (opts.type === "select") return await select({
|
|
744
|
+
message,
|
|
745
|
+
options: opts.options.map((o) => typeof o === "string" ? {
|
|
746
|
+
value: o,
|
|
747
|
+
label: o
|
|
748
|
+
} : o)
|
|
749
|
+
});
|
|
750
|
+
if (opts.type === "multiselect") return await multiselect({
|
|
751
|
+
message,
|
|
752
|
+
options: opts.options.map((o) => typeof o === "string" ? {
|
|
753
|
+
value: o,
|
|
754
|
+
label: o
|
|
755
|
+
} : o),
|
|
756
|
+
required: opts.required
|
|
757
|
+
});
|
|
804
758
|
throw new Error(`Unknown prompt type: ${opts.type}`);
|
|
805
759
|
}
|
|
806
760
|
|
|
807
761
|
//#endregion
|
|
808
|
-
|
|
809
|
-
exports.prompt = prompt;
|
|
762
|
+
exports.prompt = prompt
|