@voidzero-dev/vite-plus-prompts 0.0.0

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/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Forked from https://github.com/bombshell-dev/clack
2
+
3
+ Original License:
4
+
5
+ MIT License
6
+
7
+ Copyright (c) Nate Moore
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,432 @@
1
+ import { AutocompletePrompt, ClackSettings, State, isCancel, settings, updateSettings } from "@clack/core";
2
+ import { Readable, Writable } from "node:stream";
3
+ //#region src/common.d.ts
4
+ export declare const unicode: boolean;
5
+ export declare const isCI: () => boolean;
6
+ export declare const isTTY: (output: Writable) => boolean;
7
+ export declare const unicodeOr: (c: string, fallback: string) => string;
8
+ export declare const S_POINTER_ACTIVE: string;
9
+ export declare const S_POINTER_INACTIVE = " ";
10
+ export declare const S_STEP_ACTIVE: string;
11
+ export declare const S_STEP_CANCEL: string;
12
+ export declare const S_STEP_ERROR: string;
13
+ export declare const S_STEP_SUBMIT: string;
14
+ export declare const S_BAR_START: string;
15
+ export declare const S_BAR: string;
16
+ export declare const S_BAR_END: string;
17
+ export declare const S_BAR_START_RIGHT: string;
18
+ export declare const S_BAR_END_RIGHT: string;
19
+ export declare const S_RADIO_ACTIVE: string;
20
+ export declare const S_RADIO_INACTIVE = " ";
21
+ export declare const S_CHECKBOX_ACTIVE: string;
22
+ export declare const S_CHECKBOX_SELECTED: string;
23
+ export declare const S_CHECKBOX_INACTIVE: string;
24
+ export declare const S_PASSWORD_MASK: string;
25
+ export declare const S_BAR_H: string;
26
+ export declare const S_CORNER_TOP_RIGHT: string;
27
+ export declare const S_CONNECT_LEFT: string;
28
+ export declare const S_CORNER_BOTTOM_RIGHT: string;
29
+ export declare const S_CORNER_BOTTOM_LEFT: string;
30
+ export declare const S_CORNER_TOP_LEFT: string;
31
+ export declare const S_INFO: string;
32
+ export declare const S_SUCCESS: string;
33
+ export declare const S_WARN: string;
34
+ export declare const S_ERROR: string;
35
+ export declare const completeColor: (value: string) => string;
36
+ declare const symbol$1: (state: State) => string;
37
+ export declare const symbolBar: (state: State) => string;
38
+ export interface CommonOptions {
39
+ input?: Readable;
40
+ output?: Writable;
41
+ signal?: AbortSignal;
42
+ withGuide?: boolean;
43
+ /**
44
+ * Stable identifier used in snapshot-test milestones
45
+ * (`<kind>:<testId>:<state>`). Only read when `VP_EMIT_MILESTONES=1`;
46
+ * defaults to the prompt kind. Set it when a flow shows several prompts of
47
+ * the same kind, so tests can target each one unambiguously.
48
+ */
49
+ testId?: string;
50
+ }
51
+ //#endregion
52
+ //#region src/select.d.ts
53
+ type Primitive = Readonly<string | boolean | number>;
54
+ export type Option<Value> = Value extends Primitive ? {
55
+ /**
56
+ * Internal data for this option.
57
+ */
58
+ value: Value;
59
+ /**
60
+ * The optional, user-facing text for this option.
61
+ *
62
+ * By default, the `value` is converted to a string.
63
+ */
64
+ label?: string;
65
+ /**
66
+ * An optional hint to display to the user when
67
+ * this option might be selected.
68
+ *
69
+ * By default, no `hint` is displayed.
70
+ */
71
+ hint?: string;
72
+ /**
73
+ * Whether this option is disabled.
74
+ * Disabled options are visible but cannot be selected.
75
+ *
76
+ * By default, options are not disabled.
77
+ */
78
+ disabled?: boolean;
79
+ } : {
80
+ /**
81
+ * Internal data for this option.
82
+ */
83
+ value: Value;
84
+ /**
85
+ * Required. The user-facing text for this option.
86
+ */
87
+ label: string;
88
+ /**
89
+ * An optional hint to display to the user when
90
+ * this option might be selected.
91
+ *
92
+ * By default, no `hint` is displayed.
93
+ */
94
+ hint?: string;
95
+ /**
96
+ * Whether this option is disabled.
97
+ * Disabled options are visible but cannot be selected.
98
+ *
99
+ * By default, options are not disabled.
100
+ */
101
+ disabled?: boolean;
102
+ };
103
+ export interface SelectOptions<Value> extends CommonOptions {
104
+ message: string;
105
+ options: Option<Value>[];
106
+ initialValue?: Value;
107
+ maxItems?: number;
108
+ }
109
+ export declare const select: <Value>(opts: SelectOptions<Value>) => Promise<Value | symbol>;
110
+ //#endregion
111
+ //#region src/autocomplete.d.ts
112
+ interface AutocompleteSharedOptions<Value> extends CommonOptions {
113
+ /**
114
+ * The message to display to the user.
115
+ */
116
+ message: string;
117
+ /**
118
+ * Available options for the autocomplete prompt.
119
+ */
120
+ options: Option<Value>[] | ((this: AutocompletePrompt<Option<Value>>) => Option<Value>[]);
121
+ /**
122
+ * Maximum number of items to display at once.
123
+ */
124
+ maxItems?: number;
125
+ /**
126
+ * Placeholder text to display when no input is provided.
127
+ */
128
+ placeholder?: string;
129
+ /**
130
+ * Validates the value
131
+ */
132
+ validate?: (value: Value | Value[] | undefined) => string | Error | undefined;
133
+ /**
134
+ * Custom filter function to match options against search input.
135
+ * If not provided, a default filter that matches label, hint, and value is used.
136
+ */
137
+ filter?: (search: string, option: Option<Value>) => boolean;
138
+ }
139
+ export interface AutocompleteOptions<Value> extends AutocompleteSharedOptions<Value> {
140
+ /**
141
+ * The initial selected value.
142
+ */
143
+ initialValue?: Value;
144
+ /**
145
+ * The initial user input
146
+ */
147
+ initialUserInput?: string;
148
+ }
149
+ export declare const autocomplete: <Value>(opts: AutocompleteOptions<Value>) => Promise<Value | symbol>;
150
+ export interface AutocompleteMultiSelectOptions<Value> extends AutocompleteSharedOptions<Value> {
151
+ /**
152
+ * The initial selected values
153
+ */
154
+ initialValues?: Value[];
155
+ /**
156
+ * If true, at least one option must be selected
157
+ */
158
+ required?: boolean;
159
+ }
160
+ /**
161
+ * Integrated autocomplete multiselect - combines type-ahead filtering with multiselect in one UI
162
+ */
163
+ export declare const autocompleteMultiselect: <Value>(opts: AutocompleteMultiSelectOptions<Value>) => Promise<Value[] | symbol>;
164
+ //#endregion
165
+ //#region src/box.d.ts
166
+ export type BoxAlignment = 'left' | 'center' | 'right';
167
+ export interface BoxOptions extends CommonOptions {
168
+ contentAlign?: BoxAlignment;
169
+ titleAlign?: BoxAlignment;
170
+ width?: number | 'auto';
171
+ titlePadding?: number;
172
+ contentPadding?: number;
173
+ rounded?: boolean;
174
+ formatBorder?: (text: string) => string;
175
+ }
176
+ export declare const box: (message?: string, title?: string, opts?: BoxOptions) => void;
177
+ //#endregion
178
+ //#region src/confirm.d.ts
179
+ export interface ConfirmOptions extends CommonOptions {
180
+ message: string;
181
+ active?: string;
182
+ inactive?: string;
183
+ initialValue?: boolean;
184
+ vertical?: boolean;
185
+ }
186
+ export declare const confirm: (opts: ConfirmOptions) => Promise<boolean | symbol>;
187
+ //#endregion
188
+ //#region src/group.d.ts
189
+ type Prettify<T> = { [P in keyof T]: T[P]; } & {};
190
+ export type PromptGroupAwaitedReturn<T> = { [P in keyof T]: Exclude<Awaited<T[P]>, symbol>; };
191
+ export interface PromptGroupOptions<T> {
192
+ /**
193
+ * Control how the group can be canceled
194
+ * if one of the prompts is canceled.
195
+ */
196
+ onCancel?: (opts: {
197
+ results: Prettify<Partial<PromptGroupAwaitedReturn<T>>>;
198
+ }) => void;
199
+ }
200
+ export type PromptGroup<T> = { [P in keyof T]: (opts: {
201
+ results: Prettify<Partial<PromptGroupAwaitedReturn<Omit<T, P>>>>;
202
+ }) => undefined | Promise<T[P] | undefined>; };
203
+ /**
204
+ * Define a group of prompts to be displayed
205
+ * and return a results of objects within the group
206
+ */
207
+ export declare const group: <T>(prompts: PromptGroup<T>, opts?: PromptGroupOptions<T>) => Promise<Prettify<PromptGroupAwaitedReturn<T>>>;
208
+ //#endregion
209
+ //#region src/group-multi-select.d.ts
210
+ export interface GroupMultiSelectOptions<Value> extends CommonOptions {
211
+ message: string;
212
+ options: Record<string, Option<Value>[]>;
213
+ initialValues?: Value[];
214
+ required?: boolean;
215
+ cursorAt?: Value;
216
+ selectableGroups?: boolean;
217
+ groupSpacing?: number;
218
+ }
219
+ export declare const groupMultiselect: <Value>(opts: GroupMultiSelectOptions<Value>) => Promise<Value[] | symbol>;
220
+ //#endregion
221
+ //#region src/limit-options.d.ts
222
+ export interface LimitOptionsParams<TOption> extends CommonOptions {
223
+ options: TOption[];
224
+ maxItems: number | undefined;
225
+ cursor: number;
226
+ style: (option: TOption, active: boolean) => string;
227
+ columnPadding?: number;
228
+ rowPadding?: number;
229
+ }
230
+ export declare const limitOptions: <TOption>(params: LimitOptionsParams<TOption>) => string[];
231
+ //#endregion
232
+ //#region src/log.d.ts
233
+ export interface LogMessageOptions extends CommonOptions {
234
+ symbol?: string;
235
+ spacing?: number;
236
+ secondarySymbol?: string;
237
+ }
238
+ export declare const log: {
239
+ message: (message?: string | string[], { symbol, secondarySymbol, output, spacing, withGuide }?: LogMessageOptions) => void;
240
+ info: (message: string, opts?: LogMessageOptions) => void;
241
+ success: (message: string, opts?: LogMessageOptions) => void;
242
+ step: (message: string, opts?: LogMessageOptions) => void;
243
+ warn: (message: string, opts?: LogMessageOptions) => void;
244
+ /** alias for `log.warn()`. */
245
+ warning: (message: string, opts?: LogMessageOptions) => void;
246
+ error: (message: string, opts?: LogMessageOptions) => void;
247
+ };
248
+ //#endregion
249
+ //#region src/messages.d.ts
250
+ export declare const cancel: (message?: string, opts?: CommonOptions) => void;
251
+ export declare const intro: (title?: string, opts?: CommonOptions) => void;
252
+ export declare const outro: (message?: string, opts?: CommonOptions) => void;
253
+ //#endregion
254
+ //#region src/milestone.d.ts
255
+ /**
256
+ * Render-milestone markers for the PTY snapshot suite
257
+ * (crates/vp_cli_snapshots): invisible window-title updates the runner
258
+ * synchronizes on via `expect-milestone` interactions. Emission is gated on
259
+ * `VP_EMIT_MILESTONES=1`, which only the runner sets; real terminals and
260
+ * piped output never see these markers as content (they only update the
261
+ * window title, which the runner's PTY captures).
262
+ *
263
+ * Protocol (shared with vite-task's `pty_terminal_test_client` crate):
264
+ * `OSC 2 ; pty-terminal-test:<32-hex-id>:<base64url(name)> ST`. The runner
265
+ * decodes the title with `decode_milestone_title`, ignoring ordinary title
266
+ * updates. A fresh random id per emission keeps repeated milestones with the
267
+ * same name observable as distinct title changes through Windows ConPTY.
268
+ */
269
+ /**
270
+ * Returns the encoded milestone byte sequence for `name`, or an empty string
271
+ * when emission is disabled. Append the result to a rendered prompt frame so
272
+ * the marker arrives in the output stream together with the render it marks.
273
+ */
274
+ export declare function milestone(name: string): string;
275
+ /**
276
+ * Milestone for a prompt render, following the runner naming convention
277
+ * `<kind>:<id>:<state>` (e.g. `select:template:1`, `confirm:approve:yes`,
278
+ * `text:project-name:my-app`). `id` defaults to the prompt kind; pass
279
+ * `testId` at ambiguous call sites (multiple prompts of one kind in a flow).
280
+ */
281
+ export declare function promptMilestone(kind: string, id: string | undefined, state: string): string;
282
+ //#endregion
283
+ //#region src/multi-select.d.ts
284
+ export interface MultiSelectOptions<Value> extends CommonOptions {
285
+ message: string;
286
+ options: Option<Value>[];
287
+ initialValues?: Value[];
288
+ maxItems?: number;
289
+ required?: boolean;
290
+ cursorAt?: Value;
291
+ }
292
+ export declare const multiselect: <Value>(opts: MultiSelectOptions<Value>) => Promise<Value[] | symbol>;
293
+ //#endregion
294
+ //#region src/note.d.ts
295
+ type FormatFn = (line: string) => string;
296
+ export interface NoteOptions extends CommonOptions {
297
+ format?: FormatFn;
298
+ }
299
+ export declare const note: (message?: string, title?: string, opts?: NoteOptions) => void;
300
+ //#endregion
301
+ //#region src/password.d.ts
302
+ export interface PasswordOptions extends CommonOptions {
303
+ message: string;
304
+ mask?: string;
305
+ validate?: (value: string | undefined) => string | Error | undefined;
306
+ clearOnError?: boolean;
307
+ }
308
+ export declare const password: (opts: PasswordOptions) => Promise<string | symbol>;
309
+ //#endregion
310
+ //#region src/path.d.ts
311
+ export interface PathOptions extends CommonOptions {
312
+ root?: string;
313
+ directory?: boolean;
314
+ initialValue?: string;
315
+ message: string;
316
+ validate?: (value: string | undefined) => string | Error | undefined;
317
+ }
318
+ export declare const path: (opts: PathOptions) => Promise<string | symbol>;
319
+ //#endregion
320
+ //#region src/spinner.d.ts
321
+ export interface SpinnerOptions extends CommonOptions {
322
+ indicator?: 'dots' | 'timer';
323
+ onCancel?: () => void;
324
+ cancelMessage?: string;
325
+ errorMessage?: string;
326
+ frames?: string[];
327
+ delay?: number;
328
+ styleFrame?: (frame: string) => string;
329
+ }
330
+ export interface SpinnerResult {
331
+ start(msg?: string): void;
332
+ pause(): void;
333
+ resume(msg?: string): void;
334
+ stop(msg?: string): void;
335
+ cancel(msg?: string): void;
336
+ error(msg?: string): void;
337
+ message(msg?: string): void;
338
+ clear(): void;
339
+ readonly isCancelled: boolean;
340
+ }
341
+ export declare const spinner: ({ indicator, onCancel, output, cancelMessage, errorMessage, frames, delay, signal, ...opts }?: SpinnerOptions) => SpinnerResult;
342
+ //#endregion
343
+ //#region src/progress-bar.d.ts
344
+ export interface ProgressOptions extends SpinnerOptions {
345
+ style?: 'light' | 'heavy' | 'block';
346
+ max?: number;
347
+ size?: number;
348
+ }
349
+ export interface ProgressResult extends SpinnerResult {
350
+ advance(step?: number, msg?: string): void;
351
+ }
352
+ export declare function progress({ style, max: userMax, size: userSize, ...spinnerOptions }?: ProgressOptions): ProgressResult;
353
+ //#endregion
354
+ //#region src/select-key.d.ts
355
+ export interface SelectKeyOptions<Value extends string> extends CommonOptions {
356
+ message: string;
357
+ options: Option<Value>[];
358
+ initialValue?: Value;
359
+ caseSensitive?: boolean;
360
+ }
361
+ export declare const selectKey: <Value extends string>(opts: SelectKeyOptions<Value>) => Promise<Value | symbol>;
362
+ //#endregion
363
+ //#region src/stream.d.ts
364
+ export declare const stream: {
365
+ message: (iterable: Iterable<string> | AsyncIterable<string>, { symbol }?: LogMessageOptions) => Promise<void>;
366
+ info: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
367
+ success: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
368
+ step: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
369
+ warn: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
370
+ /** alias for `log.warn()`. */
371
+ warning: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
372
+ error: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
373
+ };
374
+ //#endregion
375
+ //#region src/task.d.ts
376
+ export type Task = {
377
+ /**
378
+ * Task title
379
+ */
380
+ title: string;
381
+ /**
382
+ * Task function
383
+ */
384
+ task: (message: (string: string) => void) => string | Promise<string> | void | Promise<void>;
385
+ /**
386
+ * If enabled === false the task will be skipped
387
+ */
388
+ enabled?: boolean;
389
+ };
390
+ /**
391
+ * Define a group of tasks to be executed
392
+ */
393
+ export declare const tasks: (tasks: Task[], opts?: CommonOptions) => Promise<void>;
394
+ //#endregion
395
+ //#region src/task-log.d.ts
396
+ export interface TaskLogOptions extends CommonOptions {
397
+ title: string;
398
+ limit?: number;
399
+ spacing?: number;
400
+ retainLog?: boolean;
401
+ }
402
+ export interface TaskLogMessageOptions {
403
+ raw?: boolean;
404
+ }
405
+ export interface TaskLogCompletionOptions {
406
+ showLog?: boolean;
407
+ }
408
+ /**
409
+ * Renders a log which clears on success and remains on failure
410
+ */
411
+ export declare const taskLog: (opts: TaskLogOptions) => {
412
+ message(msg: string, mopts?: TaskLogMessageOptions): void;
413
+ group(name: string): {
414
+ message(msg: string, mopts?: TaskLogMessageOptions): void;
415
+ error(message: string): void;
416
+ success(message: string): void;
417
+ };
418
+ error(message: string, opts?: TaskLogCompletionOptions): void;
419
+ success(message: string, opts?: TaskLogCompletionOptions): void;
420
+ };
421
+ //#endregion
422
+ //#region src/text.d.ts
423
+ export interface TextOptions extends CommonOptions {
424
+ message: string;
425
+ placeholder?: string;
426
+ defaultValue?: string;
427
+ initialValue?: string;
428
+ validate?: (value: string | undefined) => string | Error | undefined;
429
+ }
430
+ export declare const text: (opts: TextOptions) => Promise<string | symbol>;
431
+ //#endregion
432
+ export { type ClackSettings, isCancel, settings, symbol$1 as symbol, updateSettings };