rolldown 0.14.0 → 0.15.0-commit.1265c2c

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.
Files changed (103) hide show
  1. package/dist/cjs/cli.cjs +960 -966
  2. package/dist/cjs/experimental-index.cjs +68 -26
  3. package/dist/cjs/index.cjs +6 -8
  4. package/dist/cjs/parallel-plugin-worker.cjs +20 -14
  5. package/dist/cjs/parallel-plugin.cjs +1 -3
  6. package/dist/esm/cli.mjs +914 -922
  7. package/dist/esm/experimental-index.mjs +44 -7
  8. package/dist/esm/index.mjs +2 -4
  9. package/dist/esm/parallel-plugin-worker.mjs +15 -10
  10. package/dist/esm/parallel-plugin.mjs +1 -3
  11. package/dist/shared/{chunk-JoMxl5V2.cjs → chunk-BFvIen8E.cjs} +13 -11
  12. package/dist/shared/{consola.36c0034f-HcmWcfPe.cjs → consola_36c0034f-B7L-radJ.cjs} +249 -295
  13. package/dist/shared/{consola.36c0034f-Xyw7SC_7.mjs → consola_36c0034f-D9ce-831.mjs} +221 -286
  14. package/dist/shared/{prompt-9Ij3R3TG.cjs → prompt-BiXtYIJ2.cjs} +157 -204
  15. package/dist/shared/{prompt-hoPhcrA-.mjs → prompt-DlQ-08lk.mjs} +125 -174
  16. package/dist/shared/src-BtX1cCkj.mjs +2851 -0
  17. package/dist/shared/src-Di4duR8G.cjs +2985 -0
  18. package/dist/tsconfig.dts.tsbuildinfo +1 -0
  19. package/dist/types/api/build.d.ts +16 -0
  20. package/dist/types/api/experimental.d.ts +7 -0
  21. package/dist/types/api/rolldown/index.d.ts +3 -0
  22. package/dist/types/api/rolldown/rolldown-build.d.ts +12 -0
  23. package/dist/types/api/watch/index.d.ts +3 -0
  24. package/dist/types/{watcher.d.ts → api/watch/watch-emitter.d.ts} +17 -17
  25. package/dist/types/api/watch/watcher.d.ts +13 -0
  26. package/dist/types/binding.d.ts +273 -49
  27. package/dist/types/builtin-plugin/alias-plugin.d.ts +10 -0
  28. package/dist/types/builtin-plugin/constructors.d.ts +16 -0
  29. package/dist/types/builtin-plugin/replace-plugin.d.ts +28 -0
  30. package/dist/types/{options/normalized-ecma-transform-plugin-config.d.ts → builtin-plugin/transform-plugin.d.ts} +2 -1
  31. package/dist/types/builtin-plugin/utils.d.ts +8 -0
  32. package/dist/types/cli/arguments/index.d.ts +5 -3
  33. package/dist/types/cli/arguments/normalize.d.ts +2 -6
  34. package/dist/types/cli/arguments/schema.d.ts +10 -309
  35. package/dist/types/cli/colors.d.ts +11 -1
  36. package/dist/types/cli/load-config.d.ts +3 -0
  37. package/dist/types/cli/logger.d.ts +5 -0
  38. package/dist/types/constants/plugin.d.ts +10 -1
  39. package/dist/types/experimental-index.d.ts +5 -2
  40. package/dist/types/index.d.ts +13 -10
  41. package/dist/types/log/logger.d.ts +2 -16
  42. package/dist/types/log/logging.d.ts +11 -8
  43. package/dist/types/log/logs.d.ts +3 -0
  44. package/dist/types/options/input-options-schema.d.ts +4 -0
  45. package/dist/types/options/input-options.d.ts +89 -430
  46. package/dist/types/options/normalized-input-options.d.ts +17 -11
  47. package/dist/types/options/normalized-output-options.d.ts +60 -21
  48. package/dist/types/options/output-options-schema.d.ts +3 -0
  49. package/dist/types/options/output-options.d.ts +73 -265
  50. package/dist/types/options/watch-options.d.ts +5 -0
  51. package/dist/types/plugin/bindingify-build-hooks.d.ts +9 -11
  52. package/dist/types/plugin/bindingify-hook-filter.d.ts +5 -5
  53. package/dist/types/plugin/bindingify-output-hooks.d.ts +13 -16
  54. package/dist/types/plugin/bindingify-plugin.d.ts +12 -3
  55. package/dist/types/plugin/bindingify-watch-hooks.d.ts +3 -5
  56. package/dist/types/plugin/hook-filter.d.ts +1 -1
  57. package/dist/types/plugin/index.d.ts +21 -18
  58. package/dist/types/plugin/minimal-plugin-context.d.ts +15 -0
  59. package/dist/types/plugin/plugin-context-data.d.ts +4 -4
  60. package/dist/types/plugin/plugin-context.d.ts +9 -4
  61. package/dist/types/plugin/plugin-driver.d.ts +4 -5
  62. package/dist/types/plugin/transform-plugin-context.d.ts +4 -3
  63. package/dist/types/rollup-types.d.ts +1 -1
  64. package/dist/types/rollup.d.ts +4 -0
  65. package/dist/types/treeshake/index.d.ts +0 -12
  66. package/dist/types/treeshake/module-side-effects.d.ts +14 -15
  67. package/dist/types/types/rolldown-output.d.ts +17 -2
  68. package/dist/types/types/utils.d.ts +1 -0
  69. package/dist/types/utils/bindingify-input-options.d.ts +7 -0
  70. package/dist/types/utils/bindingify-output-options.d.ts +3 -0
  71. package/dist/types/utils/create-bundler-option.d.ts +11 -0
  72. package/dist/types/utils/define-config.d.ts +3 -0
  73. package/dist/types/utils/error.d.ts +2 -0
  74. package/dist/types/utils/misc.d.ts +1 -0
  75. package/dist/types/utils/normalize-hook.d.ts +1 -1
  76. package/dist/types/utils/normalize-plugin-option.d.ts +8 -3
  77. package/dist/types/{options/utils.d.ts → utils/normalize-string-or-regex.d.ts} +1 -1
  78. package/dist/types/utils/transform-rendered-chunk.d.ts +4 -0
  79. package/dist/types/utils/transform-rendered-module.d.ts +3 -0
  80. package/dist/types/utils/transform-sourcemap.d.ts +2 -0
  81. package/dist/types/utils/transform-to-rollup-output.d.ts +1 -0
  82. package/dist/types/utils/zod-ext.d.ts +6 -5
  83. package/package.json +30 -22
  84. package/dist/shared/rolldown-binding.wasi.cjs +0 -187
  85. package/dist/shared/src_index-3pqhEViJ.cjs +0 -2785
  86. package/dist/shared/src_index-ywYMd4vB.mjs +0 -2786
  87. package/dist/shared/wasi-worker-browser.mjs +0 -39
  88. package/dist/shared/wasi-worker.mjs +0 -63
  89. package/dist/shared/watcher-worker.js +0 -1
  90. package/dist/types/cli/utils.d.ts +0 -6
  91. package/dist/types/constants/types.d.ts +0 -1
  92. package/dist/types/options/bindingify-input-options.d.ts +0 -4
  93. package/dist/types/options/bindingify-output-options.d.ts +0 -3
  94. package/dist/types/options/normalized-alias-plugin-config.d.ts +0 -8
  95. package/dist/types/options/watch-option.d.ts +0 -5
  96. package/dist/types/plugin/builtin-plugin.d.ts +0 -81
  97. package/dist/types/rolldown-build.d.ts +0 -10
  98. package/dist/types/rolldown.d.ts +0 -12
  99. package/dist/types/types/rendered-module.d.ts +0 -2
  100. package/dist/types/utils/normalize-input-options.d.ts +0 -3
  101. package/dist/types/utils/normalize-output-options.d.ts +0 -3
  102. package/dist/types/utils/normalize-tree-shake.d.ts +0 -3
  103. /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 { __toESM } = require("./chunk-JoMxl5V2.cjs");
4
- const { colors, getDefaultExportFromCjs, isUnicodeSupported } = require("./consola.36c0034f-HcmWcfPe.cjs");
5
- require("node:path");
6
- const { stdin, stdout } = __toESM(require("node:process"));
7
- require("node:util");
8
- const { WriteStream, default: require$$0 } = __toESM(require("node:tty"));
9
- const { default: f } = __toESM(require("node:readline"));
2
+ const require_chunk = require('./chunk-BFvIen8E.cjs');
3
+ const require_consola_36c0034f = require('./consola_36c0034f-B7L-radJ.cjs');
4
+ const node_path = require_chunk.__toESM(require("node:path"));
5
+ const node_process = require_chunk.__toESM(require("node:process"));
6
+ const tty = require_chunk.__toESM(require("tty"));
7
+ const node_util = require_chunk.__toESM(require("node:util"));
8
+ const node_tty = require_chunk.__toESM(require("node: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 = require$$0;
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 [0, 0, 0];
259
+ if (!F) return [
260
+ 0,
261
+ 0,
262
+ 0
263
+ ];
260
264
  let [e] = F;
261
- e.length === 3 && (e = ([...e].map((C) => C + C)).join(""));
265
+ e.length === 3 && (e = [...e].map((C) => C + C).join(""));
262
266
  const s$1 = Number.parseInt(e, 16);
263
- return [s$1 >> 16 & 255, s$1 >> 8 & 255, s$1 & 255];
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) => `${((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) => {
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 = ((e.slice(i + 1)).join("")).startsWith(w)), s$1) {
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 : (u.slice(0, F)).join(" ") + (u.slice(F)).join("");
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 (t.split(" ")).entries()) {
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 } = (new RegExp(`(?:\\${W}(?<code>\\d+)m|\\${w}(?<uri>.*)${b})`)).exec((o.slice(E)).join("")) || {groups: {}};
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 (((((String(t)).normalize()).replace(/\r\n/g, `
362
- `)).split(`
363
- `)).map((e) => uD(e, u, F))).join(`
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([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"]]), tD = new Set(["up", "down", "left", "right", "space", "enter"]);
379
- class h {
380
- constructor({ render: u, input: F = stdin, output: e = stdout,...s$1 }, C = !0) {
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 = f.createInterface({
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
- }), f.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) => {
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 = ((P(this._prevFrame, process.stdout.columns, {hard: !0})).split(`
436
- `)).length - 1;
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 = (u.split(`
456
- `)).slice(e);
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
- class sD extends h {
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
- class iD extends h {
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
- class ED extends h {
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
- class oD extends h {
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
- return colors.cyan(S_STEP_ACTIVE);
573
- }
574
- case "cancel": {
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 (new oD({
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
- return `${title.trim()}
600
- ${colors.yellow(S_BAR)} ${value}
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 "submit": {
605
- return `${title}${colors.gray(S_BAR)} ${colors.dim(this.value || opts.placeholder)}`;
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
- })).prompt();
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 (new sD({
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
- return `${title}${colors.gray(S_BAR)} ${colors.dim(value)}`;
634
- }
635
- case "cancel": {
636
- return `${title}${colors.gray(S_BAR)} ${colors.strikethrough(colors.dim(value))}
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
- })).prompt();
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
- return `${colors.green(S_RADIO_ACTIVE)} ${label} ${option.hint ? colors.dim(`(${option.hint})`) : ""}`;
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 (new ED({
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
- return `${title}${colors.gray(S_BAR)} ${opt(this.options[this.cursor], "selected")}`;
674
- }
675
- case "cancel": {
676
- return `${title}${colors.gray(S_BAR)} ${opt(this.options[this.cursor], "cancelled")}
677
- ${colors.gray(S_BAR)}`;
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
- })).prompt();
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
- return `${colors.cyan(S_CHECKBOX_ACTIVE)} ${label} ${option.hint ? colors.dim(`(${option.hint})`) : ""}`;
695
- }
696
- case "selected": {
697
- return `${colors.green(S_CHECKBOX_SELECTED)} ${colors.dim(label)}`;
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 (new iD({
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
- return `Please select at least one option.
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 = ((this.options.filter(({ value: value }) => this.value.includes(value))).map((option) => opt(option, "cancelled"))).join(colors.dim(", "));
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 = ((this.error.split("\n")).map((ln, i) => i === 0 ? `${colors.yellow(S_BAR_END)} ${colors.yellow(ln)}` : ` ${ln}`)).join("\n");
737
- return title + colors.yellow(S_BAR) + " " + (this.options.map((option, i) => {
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
- return opt(option, "active-selected");
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
- })).join(`
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
- return `${title}${colors.cyan(S_BAR)} ${(this.options.map((option, i) => {
752
- const selected = this.value.includes(option.value);
753
- const active = i === this.cursor;
754
- if (active && selected) {
755
- return opt(option, "active-selected");
756
- }
757
- if (selected) {
758
- return opt(option, "selected");
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
- })).prompt();
730
+ }).prompt();
769
731
  };
770
732
  async function prompt(message, opts = {}) {
771
- if (!opts.type || opts.type === "text") {
772
- return await text({
773
- message,
774
- defaultValue: opts.default,
775
- placeholder: opts.placeholder,
776
- initialValue: opts.initial
777
- });
778
- }
779
- if (opts.type === "confirm") {
780
- return await confirm({
781
- message,
782
- initialValue: opts.initial
783
- });
784
- }
785
- if (opts.type === "select") {
786
- return await select({
787
- message,
788
- options: opts.options.map((o) => typeof o === "string" ? {
789
- value: o,
790
- label: o
791
- } : o)
792
- });
793
- }
794
- if (opts.type === "multiselect") {
795
- return await multiselect({
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
- Object.defineProperty(exports, '__esModule', { value: true });
809
- exports.prompt = prompt;
762
+ exports.prompt = prompt