@reliverse/rempts 1.7.53 → 1.7.55

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.
@@ -94,15 +94,15 @@ export async function datePrompt(opts) {
94
94
  title: `${title} [${dateFormat}]`,
95
95
  titleColor,
96
96
  titleTypography,
97
- titleVariant,
97
+ ...titleVariant !== void 0 && { titleVariant },
98
98
  content,
99
99
  contentColor,
100
100
  contentTypography,
101
- contentVariant,
101
+ ...contentVariant !== void 0 && { contentVariant },
102
102
  borderColor,
103
103
  hint: `${hint ? `${hint} ` : ""}${defaultValue ? `Default: ${defaultValue}` : ""}`,
104
104
  hintPlaceholderColor,
105
- variantOptions,
105
+ ...variantOptions !== void 0 && { variantOptions },
106
106
  errorMessage
107
107
  });
108
108
  const questionLines = countLines(questionText);
@@ -327,7 +327,7 @@ let state = {
327
327
  function setupTheme(configTheme) {
328
328
  let mode = configTheme;
329
329
  if (mode === "auto") {
330
- const termBg = process.env.COLORFGBG;
330
+ const termBg = process.env["COLORFGBG"];
331
331
  mode = termBg && termBg.split(";")[1] === "0" ? "dark" : "light";
332
332
  if (!termBg) mode = "light";
333
333
  }
@@ -1002,9 +1002,9 @@ async function initializeEditorState(options) {
1002
1002
  },
1003
1003
  options: {
1004
1004
  // Will be resolved below
1005
- filename: options.filename,
1006
- initialContent: options.initialContent,
1007
- configOverrides: options.configOverrides || {},
1005
+ ...options.filename !== void 0 && { filename: options.filename },
1006
+ ...options.initialContent !== void 0 && { initialContent: options.initialContent },
1007
+ ...options.configOverrides !== void 0 && { configOverrides: options.configOverrides },
1008
1008
  allowSaveAs: true,
1009
1009
  // Default, will be overridden
1010
1010
  allowOpen: true,
@@ -1118,7 +1118,7 @@ const isDirectRun = (() => {
1118
1118
  })();
1119
1119
  if (isDirectRun) {
1120
1120
  const fileArg = process.argv[2];
1121
- startEditor({ filename: fileArg }).then((_result) => {
1121
+ startEditor({ ...fileArg !== void 0 && { filename: fileArg } }).then((_result) => {
1122
1122
  }).catch((error) => {
1123
1123
  try {
1124
1124
  term.grabInput(false);
@@ -1,12 +1,12 @@
1
1
  import process from "node:process";
2
2
  function isUnicodeSupported() {
3
3
  if (process.platform !== "win32") {
4
- return process.env.TERM !== "linux";
4
+ return process.env["TERM"] !== "linux";
5
5
  }
6
- return Boolean(process.env.WT_SESSION) || // Windows Terminal
7
- Boolean(process.env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
8
- process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
9
- process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
6
+ return Boolean(process.env["WT_SESSION"]) || // Windows Terminal
7
+ Boolean(process.env["TERMINUS_SUBLIME"]) || // Terminus (<0.2.27)
8
+ process.env["ConEmuTask"] === "{cmd::Cmder}" || // ConEmu and cmder
9
+ process.env["TERM_PROGRAM"] === "Terminus-Sublime" || process.env["TERM_PROGRAM"] === "vscode" || process.env["TERM"] === "xterm-256color" || process.env["TERM"] === "alacritty" || process.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
10
10
  }
11
11
  const common = {
12
12
  circleQuestionMark: "(?)",
@@ -108,7 +108,7 @@ function renderPromptUI(params) {
108
108
  msgUndoAll();
109
109
  msg({
110
110
  type,
111
- title,
111
+ ...title !== void 0 && { title },
112
112
  titleColor,
113
113
  titleTypography,
114
114
  titleVariant,
@@ -137,7 +137,7 @@ function renderPromptUI(params) {
137
137
  deleteLastLine();
138
138
  msg({
139
139
  type,
140
- title,
140
+ ...title !== void 0 && { title },
141
141
  titleColor,
142
142
  titleTypography,
143
143
  titleVariant,
@@ -160,7 +160,7 @@ function renderPromptUI(params) {
160
160
  }
161
161
  msg({
162
162
  type,
163
- title,
163
+ ...title !== void 0 && { title },
164
164
  titleColor,
165
165
  titleTypography,
166
166
  titleVariant,
@@ -264,24 +264,24 @@ export async function inputPrompt(options) {
264
264
  msgUndoAll();
265
265
  await renderPromptUI({
266
266
  title: finalTitle,
267
- hint,
268
- hintPlaceholderColor,
269
- content,
270
- contentColor,
271
- contentTypography,
272
- contentVariant,
267
+ ...hint !== void 0 && { hint },
268
+ ...hintPlaceholderColor !== void 0 && { hintPlaceholderColor },
269
+ content: content ?? "",
270
+ ...contentColor !== void 0 && { contentColor },
271
+ ...contentTypography !== void 0 && { contentTypography },
272
+ ...contentVariant !== void 0 && { contentVariant },
273
273
  titleColor,
274
274
  titleTypography,
275
- titleVariant,
275
+ ...titleVariant !== void 0 && { titleVariant },
276
276
  borderColor,
277
- placeholder: showPlaceholder ? placeholder : "",
277
+ placeholder: showPlaceholder && placeholder ? placeholder : "",
278
278
  userInput: currentInput,
279
279
  errorMessage,
280
280
  border,
281
- symbol,
282
- customSymbol,
283
- symbolColor,
284
- mask,
281
+ ...symbol !== void 0 && { symbol },
282
+ ...customSymbol !== void 0 && { customSymbol },
283
+ ...symbolColor !== void 0 && { symbolColor },
284
+ ...mask !== void 0 && { mask },
285
285
  shouldStream,
286
286
  streamDelay
287
287
  });
@@ -310,24 +310,24 @@ export async function inputPrompt(options) {
310
310
  }
311
311
  await renderPromptUI({
312
312
  title: finalTitle,
313
- hint,
313
+ ...hint !== void 0 && { hint },
314
314
  hintPlaceholderColor,
315
- content,
315
+ content: content ?? "",
316
316
  contentColor,
317
317
  contentTypography,
318
- contentVariant,
318
+ ...contentVariant !== void 0 && { contentVariant },
319
319
  titleColor,
320
320
  titleTypography,
321
- titleVariant,
321
+ ...titleVariant !== void 0 && { titleVariant },
322
322
  borderColor,
323
- placeholder: showPlaceholder ? placeholder : "",
323
+ placeholder: showPlaceholder && placeholder ? placeholder : "",
324
324
  userInput: displayedUserInput,
325
325
  errorMessage,
326
326
  border,
327
- symbol,
328
- customSymbol,
329
- symbolColor,
330
- mask,
327
+ ...symbol !== void 0 && { symbol },
328
+ ...customSymbol !== void 0 && { customSymbol },
329
+ ...symbolColor !== void 0 && { symbolColor },
330
+ ...mask !== void 0 && { mask },
331
331
  shouldStream,
332
332
  streamDelay
333
333
  });
@@ -49,7 +49,7 @@ export async function introPrompt(optionsOrTitle) {
49
49
  if (variant === "ascii-art") {
50
50
  await createAsciiArt({
51
51
  message: formattedTitle,
52
- font: asciiArtFont,
52
+ ...asciiArtFont !== void 0 && { font: asciiArtFont },
53
53
  clearConsole
54
54
  });
55
55
  return;
@@ -67,17 +67,17 @@ export function defineCommand(options) {
67
67
  commands = options.subCommands;
68
68
  }
69
69
  const cmdObj = {
70
- meta: options.meta,
70
+ ...options.meta !== void 0 && { meta: options.meta },
71
71
  args: options.args || {},
72
- run: options.run,
73
- commands,
74
- onCmdInit,
75
- onCmdExit,
76
- onLauncherInit,
77
- onLauncherExit,
72
+ ...options.run !== void 0 && { run: options.run },
73
+ ...commands !== void 0 && { commands },
74
+ ...onCmdInit !== void 0 && { onCmdInit },
75
+ ...onCmdExit !== void 0 && { onCmdExit },
76
+ ...onLauncherInit !== void 0 && { onLauncherInit },
77
+ ...onLauncherExit !== void 0 && { onLauncherExit },
78
78
  // Backward-compatible aliases
79
- setup: onCmdInit,
80
- cleanup: onCmdExit
79
+ ...onCmdInit !== void 0 && { setup: onCmdInit },
80
+ ...onCmdExit !== void 0 && { cleanup: onCmdExit }
81
81
  };
82
82
  Object.defineProperty(cmdObj, "subCommands", {
83
83
  get() {
@@ -319,14 +319,14 @@ export function createCli(options, legacyParserOptions) {
319
319
  } else if ("mainCommand" in options) {
320
320
  command = options.mainCommand;
321
321
  parserOptions = {
322
- fileBased: options.fileBased,
323
- autoExit: options.autoExit,
324
- metaSettings: options.metaSettings
322
+ ...options.fileBased !== void 0 && { fileBased: options.fileBased },
323
+ ...options.autoExit !== void 0 && { autoExit: options.autoExit },
324
+ ...options.metaSettings !== void 0 && { metaSettings: options.metaSettings }
325
325
  };
326
326
  globalCliMeta = {
327
- name: options.name,
328
- version: options.version,
329
- description: options.description
327
+ ...options.name !== void 0 && { name: options.name },
328
+ ...options.version !== void 0 && { version: options.version },
329
+ ...options.description !== void 0 && { description: options.description }
330
330
  };
331
331
  } else {
332
332
  const inlineOptions = options;
@@ -341,21 +341,29 @@ export function createCli(options, legacyParserOptions) {
341
341
  ...commandOptions
342
342
  } = inlineOptions;
343
343
  command = {
344
- meta: commandOptions.meta,
345
- args: commandOptions.args,
346
- run: commandOptions.run,
347
- commands: commandOptions.commands,
348
- onCmdInit: commandOptions.onCmdInit,
349
- onCmdExit: commandOptions.onCmdExit,
350
- onLauncherInit: commandOptions.onLauncherInit,
351
- onLauncherExit: commandOptions.onLauncherExit
344
+ ...commandOptions.meta !== void 0 && { meta: commandOptions.meta },
345
+ ...commandOptions.args !== void 0 && { args: commandOptions.args },
346
+ ...commandOptions.run !== void 0 && { run: commandOptions.run },
347
+ ...commandOptions.commands !== void 0 && { commands: commandOptions.commands },
348
+ ...commandOptions.onCmdInit !== void 0 && { onCmdInit: commandOptions.onCmdInit },
349
+ ...commandOptions.onCmdExit !== void 0 && { onCmdExit: commandOptions.onCmdExit },
350
+ ...commandOptions.onLauncherInit !== void 0 && {
351
+ onLauncherInit: commandOptions.onLauncherInit
352
+ },
353
+ ...commandOptions.onLauncherExit !== void 0 && {
354
+ onLauncherExit: commandOptions.onLauncherExit
355
+ }
352
356
  };
353
357
  parserOptions = {
354
- fileBased,
355
- autoExit,
356
- metaSettings
358
+ ...fileBased !== void 0 && { fileBased },
359
+ ...autoExit !== void 0 && { autoExit },
360
+ ...metaSettings !== void 0 && { metaSettings }
361
+ };
362
+ globalCliMeta = {
363
+ ...name !== void 0 && { name },
364
+ ...version !== void 0 && { version },
365
+ ...description !== void 0 && { description }
357
366
  };
358
- globalCliMeta = { name, version, description };
359
367
  }
360
368
  if (command.run && (globalCliMeta.name || globalCliMeta.version || globalCliMeta.description)) {
361
369
  const mergedMeta = { ...command.meta };
@@ -68,29 +68,29 @@ export const relinkaAsyncByRemptsDeprecated = async (kind, title, content, hint,
68
68
  await streamTextWithSpinner({
69
69
  text: titleText,
70
70
  color: toSolidColor(config.titleColor),
71
- delay: streamOpts.delay,
72
- spinnerFrames: streamOpts.spinnerFrames,
73
- spinnerDelay: streamOpts.spinnerDelay
71
+ ...streamOpts.delay !== void 0 && { delay: streamOpts.delay },
72
+ ...streamOpts.spinnerFrames !== void 0 && { spinnerFrames: streamOpts.spinnerFrames },
73
+ ...streamOpts.spinnerDelay !== void 0 && { spinnerDelay: streamOpts.spinnerDelay }
74
74
  });
75
75
  } else {
76
76
  await streamText({
77
77
  text: titleText,
78
78
  color: toSolidColor(config.titleColor),
79
- delay: streamOpts.delay
79
+ ...streamOpts.delay !== void 0 && { delay: streamOpts.delay }
80
80
  });
81
81
  }
82
82
  if (content) {
83
83
  await streamText({
84
84
  text: content,
85
85
  color: toSolidColor(config.contentColor) ?? "dim",
86
- delay: streamOpts.delay
86
+ ...streamOpts.delay !== void 0 && { delay: streamOpts.delay }
87
87
  });
88
88
  }
89
89
  if (hint) {
90
90
  await streamText({
91
91
  text: hint,
92
92
  color: "dim",
93
- delay: streamOpts.delay
93
+ ...streamOpts.delay !== void 0 && { delay: streamOpts.delay }
94
94
  });
95
95
  }
96
96
  };
@@ -195,7 +195,7 @@ export async function multiselectPrompt(params) {
195
195
  contentTypography,
196
196
  debug,
197
197
  borderColor,
198
- titleVariant,
198
+ ...titleVariant !== void 0 && { titleVariant },
199
199
  titleTypography,
200
200
  terminalWidth: customTerminalWidth,
201
201
  resized: false,
@@ -217,7 +217,7 @@ export async function multiselectPrompt(params) {
217
217
  contentTypography,
218
218
  debug,
219
219
  borderColor,
220
- titleVariant,
220
+ ...titleVariant !== void 0 && { titleVariant },
221
221
  titleTypography,
222
222
  terminalWidth: customTerminalWidth,
223
223
  resized: false,
@@ -21,7 +21,7 @@ export async function outroPrompt(optionsOrTitle) {
21
21
  if (variant === "ascii-art") {
22
22
  await createAsciiArt({
23
23
  message: title || " ",
24
- font: asciiArtFont
24
+ ...asciiArtFont !== void 0 && { font: asciiArtFont }
25
25
  });
26
26
  return;
27
27
  }
@@ -32,7 +32,7 @@ export async function outroPrompt(optionsOrTitle) {
32
32
  await animateText({
33
33
  title: title ? title : " ",
34
34
  anim: titleAnimation,
35
- delay: titleAnimationDelay,
35
+ ...titleAnimationDelay !== void 0 && { delay: titleAnimationDelay },
36
36
  type: "M_END",
37
37
  titleColor,
38
38
  titleTypography,
@@ -46,7 +46,7 @@ export async function outroPrompt(optionsOrTitle) {
46
46
  title: title ? title : " ",
47
47
  titleColor,
48
48
  titleTypography,
49
- titleVariant,
49
+ ...titleVariant !== void 0 && { titleVariant },
50
50
  border,
51
51
  borderColor,
52
52
  horizontalLineLength
@@ -39,14 +39,14 @@ export async function numSelectPrompt(opts) {
39
39
  title,
40
40
  titleColor,
41
41
  titleTypography,
42
- titleVariant,
42
+ ...titleVariant !== void 0 && { titleVariant },
43
43
  content,
44
44
  contentColor,
45
45
  contentTypography,
46
- contentVariant,
46
+ ...contentVariant !== void 0 && { contentVariant },
47
47
  borderColor,
48
- hint,
49
- variantOptions,
48
+ ...hint !== void 0 && { hint },
49
+ ...variantOptions !== void 0 && { variantOptions },
50
50
  errorMessage
51
51
  });
52
52
  let choicesText = "";
@@ -1,9 +1,9 @@
1
1
  import { selectPrompt } from "../select/select-prompt.js";
2
2
  export const select = selectPrompt;
3
3
  export const selectSimple = (params) => {
4
+ const { options, ...restParams } = params;
4
5
  return selectPrompt({
5
- ...params,
6
- optionsArray: params.options,
7
- options: void 0
6
+ ...restParams,
7
+ optionsArray: options
8
8
  });
9
9
  };
@@ -45,8 +45,8 @@ async function renderPromptUI(params) {
45
45
  type: "M_GENERAL",
46
46
  title,
47
47
  titleColor,
48
- titleVariant,
49
- titleTypography
48
+ ...titleVariant !== void 0 && { titleVariant },
49
+ ...titleTypography !== void 0 && { titleTypography }
50
50
  });
51
51
  if (content) {
52
52
  msg({
@@ -136,7 +136,7 @@ export async function selectPrompt(params) {
136
136
  const finalOptions = options ?? optionsArray?.map((opt) => ({
137
137
  value: opt.value,
138
138
  label: opt.label ?? opt.value,
139
- hint: opt.hint,
139
+ ...opt.hint !== void 0 && { hint: opt.hint },
140
140
  disabled: false
141
141
  })) ?? [];
142
142
  let selectedIndex = finalDefaultValue ? finalOptions.findIndex(
@@ -177,8 +177,8 @@ export async function selectPrompt(params) {
177
177
  contentColor,
178
178
  contentTypography,
179
179
  debug,
180
- titleVariant,
181
- titleTypography,
180
+ ...titleVariant !== void 0 && { titleVariant },
181
+ ...titleTypography !== void 0 && { titleTypography },
182
182
  terminalWidth: customTerminalWidth,
183
183
  isRerender: true,
184
184
  shouldStream,
@@ -201,8 +201,8 @@ export async function selectPrompt(params) {
201
201
  contentColor,
202
202
  contentTypography,
203
203
  debug,
204
- titleVariant,
205
- titleTypography,
204
+ ...titleVariant !== void 0 && { titleVariant },
205
+ ...titleTypography !== void 0 && { titleTypography },
206
206
  terminalWidth: customTerminalWidth,
207
207
  isRerender: false,
208
208
  shouldStream,
@@ -1,10 +1,10 @@
1
1
  import { re } from "@reliverse/relico";
2
2
  import { block } from "../cancel/cancel.js";
3
- const unicode = process.platform !== "win32" || process.env.TERM_PROGRAM === "vscode";
3
+ const unicode = process.platform !== "win32" || process.env["TERM_PROGRAM"] === "vscode";
4
4
  const defaultFrames = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"];
5
5
  const defaultDelay = unicode ? 80 : 120;
6
6
  function isInteractive() {
7
- return process.stdout.isTTY && !process.env.CI && !process.env.GITHUB_ACTIONS && !process.env.GITLAB_CI && !process.env.BUILDKITE && process.env.TERM !== "dumb";
7
+ return process.stdout.isTTY && !process.env["CI"] && !process.env["GITHUB_ACTIONS"] && !process.env["GITLAB_CI"] && !process.env["BUILDKITE"] && process.env["TERM"] !== "dumb";
8
8
  }
9
9
  function formatProgress(options) {
10
10
  const { current, total, format = "both" } = options;
@@ -77,7 +77,7 @@ export function useSpinner(options) {
77
77
  };
78
78
  const clearPrevMessage = () => {
79
79
  if (state.prevMessage === void 0) return;
80
- if (process.env.CI) process.stdout.write("\n");
80
+ if (process.env["CI"]) process.stdout.write("\n");
81
81
  const prevLines = state.prevMessage.split("\n");
82
82
  process.stdout.write(`\x1B[${prevLines.length}A`);
83
83
  process.stdout.write("\x1B[0J");
@@ -102,13 +102,13 @@ export function useSpinner(options) {
102
102
  let frameIndex = 0;
103
103
  registerHooks();
104
104
  loop = setInterval(() => {
105
- if (process.env.CI && state.text === state.prevMessage) {
105
+ if (process.env["CI"] && state.text === state.prevMessage) {
106
106
  return;
107
107
  }
108
108
  clearPrevMessage();
109
109
  state.prevMessage = state.text;
110
110
  const frame = re.magenta((options.frames ?? defaultFrames)[frameIndex] ?? "");
111
- if (process.env.CI) {
111
+ if (process.env["CI"]) {
112
112
  process.stdout.write(`${frame} ${state.text}...`);
113
113
  } else if (options.indicator === "timer") {
114
114
  process.stdout.write(`${frame} ${state.text} ${formatTimer(state.origin)}`);
@@ -102,7 +102,7 @@ export async function streamTextBox({
102
102
  text,
103
103
  delay,
104
104
  showCursor: false,
105
- color,
105
+ ...color !== void 0 && { color },
106
106
  newline: false,
107
107
  clearLine: false
108
108
  });
@@ -120,12 +120,13 @@ export async function streamTextWithSpinner({
120
120
  spinnerDelay
121
121
  }) {
122
122
  let currentText = "";
123
+ const baseColor = toBaseColor(color);
123
124
  const spinner = ora({
124
125
  text: currentText,
125
- color: toBaseColor(color),
126
+ ...baseColor !== void 0 && { color: baseColor },
126
127
  spinner: spinnerFrames ? {
127
128
  frames: spinnerFrames,
128
- interval: spinnerDelay
129
+ ...spinnerDelay !== void 0 && { interval: spinnerDelay }
129
130
  } : "dots"
130
131
  }).start();
131
132
  for (const char of text) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@figliolia/chalk-animation": "^1.0.4",
4
- "@reliverse/relico": "^1.3.7",
4
+ "@reliverse/relico": "^1.3.8",
5
5
  "@reliverse/relinka": "^1.5.9",
6
6
  "@reliverse/runtime": "^1.0.3",
7
7
  "ansi-escapes": "^7.0.0",
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "name": "@reliverse/rempts",
23
23
  "type": "module",
24
- "version": "1.7.53",
24
+ "version": "1.7.55",
25
25
  "author": "reliverse",
26
26
  "bugs": {
27
27
  "email": "blefnk@gmail.com",