create-raman.js 1.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/dist/index.js +1491 -0
- package/package.json +20 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1491 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
function __accessProp(key) {
|
|
9
|
+
return this[key];
|
|
10
|
+
}
|
|
11
|
+
var __toESMCache_node;
|
|
12
|
+
var __toESMCache_esm;
|
|
13
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
14
|
+
var canCache = mod != null && typeof mod === "object";
|
|
15
|
+
if (canCache) {
|
|
16
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
17
|
+
var cached = cache.get(mod);
|
|
18
|
+
if (cached)
|
|
19
|
+
return cached;
|
|
20
|
+
}
|
|
21
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
22
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
|
+
for (let key of __getOwnPropNames(mod))
|
|
24
|
+
if (!__hasOwnProp.call(to, key))
|
|
25
|
+
__defProp(to, key, {
|
|
26
|
+
get: __accessProp.bind(mod, key),
|
|
27
|
+
enumerable: true
|
|
28
|
+
});
|
|
29
|
+
if (canCache)
|
|
30
|
+
cache.set(mod, to);
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
|
+
|
|
35
|
+
// node_modules/sisteransi/src/index.js
|
|
36
|
+
var require_src = __commonJS((exports, module) => {
|
|
37
|
+
var ESC2 = "\x1B";
|
|
38
|
+
var CSI2 = `${ESC2}[`;
|
|
39
|
+
var beep = "\x07";
|
|
40
|
+
var cursor = {
|
|
41
|
+
to(x, y) {
|
|
42
|
+
if (!y)
|
|
43
|
+
return `${CSI2}${x + 1}G`;
|
|
44
|
+
return `${CSI2}${y + 1};${x + 1}H`;
|
|
45
|
+
},
|
|
46
|
+
move(x, y) {
|
|
47
|
+
let ret = "";
|
|
48
|
+
if (x < 0)
|
|
49
|
+
ret += `${CSI2}${-x}D`;
|
|
50
|
+
else if (x > 0)
|
|
51
|
+
ret += `${CSI2}${x}C`;
|
|
52
|
+
if (y < 0)
|
|
53
|
+
ret += `${CSI2}${-y}A`;
|
|
54
|
+
else if (y > 0)
|
|
55
|
+
ret += `${CSI2}${y}B`;
|
|
56
|
+
return ret;
|
|
57
|
+
},
|
|
58
|
+
up: (count = 1) => `${CSI2}${count}A`,
|
|
59
|
+
down: (count = 1) => `${CSI2}${count}B`,
|
|
60
|
+
forward: (count = 1) => `${CSI2}${count}C`,
|
|
61
|
+
backward: (count = 1) => `${CSI2}${count}D`,
|
|
62
|
+
nextLine: (count = 1) => `${CSI2}E`.repeat(count),
|
|
63
|
+
prevLine: (count = 1) => `${CSI2}F`.repeat(count),
|
|
64
|
+
left: `${CSI2}G`,
|
|
65
|
+
hide: `${CSI2}?25l`,
|
|
66
|
+
show: `${CSI2}?25h`,
|
|
67
|
+
save: `${ESC2}7`,
|
|
68
|
+
restore: `${ESC2}8`
|
|
69
|
+
};
|
|
70
|
+
var scroll = {
|
|
71
|
+
up: (count = 1) => `${CSI2}S`.repeat(count),
|
|
72
|
+
down: (count = 1) => `${CSI2}T`.repeat(count)
|
|
73
|
+
};
|
|
74
|
+
var erase = {
|
|
75
|
+
screen: `${CSI2}2J`,
|
|
76
|
+
up: (count = 1) => `${CSI2}1J`.repeat(count),
|
|
77
|
+
down: (count = 1) => `${CSI2}J`.repeat(count),
|
|
78
|
+
line: `${CSI2}2K`,
|
|
79
|
+
lineEnd: `${CSI2}K`,
|
|
80
|
+
lineStart: `${CSI2}1K`,
|
|
81
|
+
lines(count) {
|
|
82
|
+
let clear = "";
|
|
83
|
+
for (let i = 0;i < count; i++)
|
|
84
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
85
|
+
if (count)
|
|
86
|
+
clear += cursor.left;
|
|
87
|
+
return clear;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
module.exports = { cursor, scroll, erase, beep };
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// node_modules/@clack/core/dist/index.mjs
|
|
94
|
+
import { styleText } from "util";
|
|
95
|
+
import { stdout, stdin } from "process";
|
|
96
|
+
import l__default from "readline";
|
|
97
|
+
|
|
98
|
+
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
99
|
+
var getCodePointsLength = (() => {
|
|
100
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
101
|
+
return (input) => {
|
|
102
|
+
let surrogatePairsNr = 0;
|
|
103
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
104
|
+
while (SURROGATE_PAIR_RE.test(input)) {
|
|
105
|
+
surrogatePairsNr += 1;
|
|
106
|
+
}
|
|
107
|
+
return input.length - surrogatePairsNr;
|
|
108
|
+
};
|
|
109
|
+
})();
|
|
110
|
+
var isFullWidth = (x) => {
|
|
111
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
112
|
+
};
|
|
113
|
+
var isWideNotCJKTNotEmoji = (x) => {
|
|
114
|
+
return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// node_modules/fast-string-truncated-width/dist/index.js
|
|
118
|
+
var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
119
|
+
var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
120
|
+
var CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
|
|
121
|
+
var TAB_RE = /\t{1,1000}/y;
|
|
122
|
+
var EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
|
|
123
|
+
var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
124
|
+
var MODIFIER_RE = /\p{M}+/gu;
|
|
125
|
+
var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
|
|
126
|
+
var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
127
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
128
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
129
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
130
|
+
const ANSI_WIDTH = 0;
|
|
131
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
132
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
133
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
134
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
135
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
136
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
137
|
+
const PARSE_BLOCKS = [
|
|
138
|
+
[LATIN_RE, REGULAR_WIDTH],
|
|
139
|
+
[ANSI_RE, ANSI_WIDTH],
|
|
140
|
+
[CONTROL_RE, CONTROL_WIDTH],
|
|
141
|
+
[TAB_RE, TAB_WIDTH],
|
|
142
|
+
[EMOJI_RE, EMOJI_WIDTH],
|
|
143
|
+
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
144
|
+
];
|
|
145
|
+
let indexPrev = 0;
|
|
146
|
+
let index = 0;
|
|
147
|
+
let length = input.length;
|
|
148
|
+
let lengthExtra = 0;
|
|
149
|
+
let truncationEnabled = false;
|
|
150
|
+
let truncationIndex = length;
|
|
151
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
152
|
+
let unmatchedStart = 0;
|
|
153
|
+
let unmatchedEnd = 0;
|
|
154
|
+
let width = 0;
|
|
155
|
+
let widthExtra = 0;
|
|
156
|
+
outer:
|
|
157
|
+
while (true) {
|
|
158
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
159
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
160
|
+
lengthExtra = 0;
|
|
161
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
162
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
163
|
+
if (isFullWidth(codePoint)) {
|
|
164
|
+
widthExtra = FULL_WIDTH_WIDTH;
|
|
165
|
+
} else if (isWideNotCJKTNotEmoji(codePoint)) {
|
|
166
|
+
widthExtra = WIDE_WIDTH;
|
|
167
|
+
} else {
|
|
168
|
+
widthExtra = REGULAR_WIDTH;
|
|
169
|
+
}
|
|
170
|
+
if (width + widthExtra > truncationLimit) {
|
|
171
|
+
truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
172
|
+
}
|
|
173
|
+
if (width + widthExtra > LIMIT) {
|
|
174
|
+
truncationEnabled = true;
|
|
175
|
+
break outer;
|
|
176
|
+
}
|
|
177
|
+
lengthExtra += char.length;
|
|
178
|
+
width += widthExtra;
|
|
179
|
+
}
|
|
180
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
181
|
+
}
|
|
182
|
+
if (index >= length) {
|
|
183
|
+
break outer;
|
|
184
|
+
}
|
|
185
|
+
for (let i = 0, l = PARSE_BLOCKS.length;i < l; i++) {
|
|
186
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
187
|
+
BLOCK_RE.lastIndex = index;
|
|
188
|
+
if (BLOCK_RE.test(input)) {
|
|
189
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
190
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
191
|
+
if (width + widthExtra > truncationLimit) {
|
|
192
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
193
|
+
}
|
|
194
|
+
if (width + widthExtra > LIMIT) {
|
|
195
|
+
truncationEnabled = true;
|
|
196
|
+
break outer;
|
|
197
|
+
}
|
|
198
|
+
width += widthExtra;
|
|
199
|
+
unmatchedStart = indexPrev;
|
|
200
|
+
unmatchedEnd = index;
|
|
201
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
202
|
+
continue outer;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
index += 1;
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
209
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
210
|
+
truncated: truncationEnabled,
|
|
211
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
var dist_default = getStringTruncatedWidth;
|
|
215
|
+
|
|
216
|
+
// node_modules/fast-string-width/dist/index.js
|
|
217
|
+
var NO_TRUNCATION2 = {
|
|
218
|
+
limit: Infinity,
|
|
219
|
+
ellipsis: "",
|
|
220
|
+
ellipsisWidth: 0
|
|
221
|
+
};
|
|
222
|
+
var fastStringWidth = (input, options = {}) => {
|
|
223
|
+
return dist_default(input, NO_TRUNCATION2, options).width;
|
|
224
|
+
};
|
|
225
|
+
var dist_default2 = fastStringWidth;
|
|
226
|
+
|
|
227
|
+
// node_modules/fast-wrap-ansi/lib/main.js
|
|
228
|
+
var ESC = "\x1B";
|
|
229
|
+
var CSI = "\x9B";
|
|
230
|
+
var END_CODE = 39;
|
|
231
|
+
var ANSI_ESCAPE_BELL = "\x07";
|
|
232
|
+
var ANSI_CSI = "[";
|
|
233
|
+
var ANSI_OSC = "]";
|
|
234
|
+
var ANSI_SGR_TERMINATOR = "m";
|
|
235
|
+
var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
236
|
+
var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
237
|
+
var getClosingCode = (openingCode) => {
|
|
238
|
+
if (openingCode >= 30 && openingCode <= 37)
|
|
239
|
+
return 39;
|
|
240
|
+
if (openingCode >= 90 && openingCode <= 97)
|
|
241
|
+
return 39;
|
|
242
|
+
if (openingCode >= 40 && openingCode <= 47)
|
|
243
|
+
return 49;
|
|
244
|
+
if (openingCode >= 100 && openingCode <= 107)
|
|
245
|
+
return 49;
|
|
246
|
+
if (openingCode === 1 || openingCode === 2)
|
|
247
|
+
return 22;
|
|
248
|
+
if (openingCode === 3)
|
|
249
|
+
return 23;
|
|
250
|
+
if (openingCode === 4)
|
|
251
|
+
return 24;
|
|
252
|
+
if (openingCode === 7)
|
|
253
|
+
return 27;
|
|
254
|
+
if (openingCode === 8)
|
|
255
|
+
return 28;
|
|
256
|
+
if (openingCode === 9)
|
|
257
|
+
return 29;
|
|
258
|
+
if (openingCode === 0)
|
|
259
|
+
return 0;
|
|
260
|
+
return;
|
|
261
|
+
};
|
|
262
|
+
var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
263
|
+
var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
264
|
+
var wrapWord = (rows, word, columns) => {
|
|
265
|
+
const characters = word[Symbol.iterator]();
|
|
266
|
+
let isInsideEscape = false;
|
|
267
|
+
let isInsideLinkEscape = false;
|
|
268
|
+
let lastRow = rows.at(-1);
|
|
269
|
+
let visible = lastRow === undefined ? 0 : dist_default2(lastRow);
|
|
270
|
+
let currentCharacter = characters.next();
|
|
271
|
+
let nextCharacter = characters.next();
|
|
272
|
+
let rawCharacterIndex = 0;
|
|
273
|
+
while (!currentCharacter.done) {
|
|
274
|
+
const character = currentCharacter.value;
|
|
275
|
+
const characterLength = dist_default2(character);
|
|
276
|
+
if (visible + characterLength <= columns) {
|
|
277
|
+
rows[rows.length - 1] += character;
|
|
278
|
+
} else {
|
|
279
|
+
rows.push(character);
|
|
280
|
+
visible = 0;
|
|
281
|
+
}
|
|
282
|
+
if (character === ESC || character === CSI) {
|
|
283
|
+
isInsideEscape = true;
|
|
284
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
285
|
+
}
|
|
286
|
+
if (isInsideEscape) {
|
|
287
|
+
if (isInsideLinkEscape) {
|
|
288
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
289
|
+
isInsideEscape = false;
|
|
290
|
+
isInsideLinkEscape = false;
|
|
291
|
+
}
|
|
292
|
+
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
293
|
+
isInsideEscape = false;
|
|
294
|
+
}
|
|
295
|
+
} else {
|
|
296
|
+
visible += characterLength;
|
|
297
|
+
if (visible === columns && !nextCharacter.done) {
|
|
298
|
+
rows.push("");
|
|
299
|
+
visible = 0;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
currentCharacter = nextCharacter;
|
|
303
|
+
nextCharacter = characters.next();
|
|
304
|
+
rawCharacterIndex += character.length;
|
|
305
|
+
}
|
|
306
|
+
lastRow = rows.at(-1);
|
|
307
|
+
if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
|
|
308
|
+
rows[rows.length - 2] += rows.pop();
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
var stringVisibleTrimSpacesRight = (string) => {
|
|
312
|
+
const words = string.split(" ");
|
|
313
|
+
let last = words.length;
|
|
314
|
+
while (last) {
|
|
315
|
+
if (dist_default2(words[last - 1])) {
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
last--;
|
|
319
|
+
}
|
|
320
|
+
if (last === words.length) {
|
|
321
|
+
return string;
|
|
322
|
+
}
|
|
323
|
+
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
324
|
+
};
|
|
325
|
+
var exec = (string, columns, options = {}) => {
|
|
326
|
+
if (options.trim !== false && string.trim() === "") {
|
|
327
|
+
return "";
|
|
328
|
+
}
|
|
329
|
+
let returnValue = "";
|
|
330
|
+
let escapeCode;
|
|
331
|
+
let escapeUrl;
|
|
332
|
+
const words = string.split(" ");
|
|
333
|
+
let rows = [""];
|
|
334
|
+
let rowLength = 0;
|
|
335
|
+
for (let index = 0;index < words.length; index++) {
|
|
336
|
+
const word = words[index];
|
|
337
|
+
if (options.trim !== false) {
|
|
338
|
+
const row = rows.at(-1) ?? "";
|
|
339
|
+
const trimmed = row.trimStart();
|
|
340
|
+
if (row.length !== trimmed.length) {
|
|
341
|
+
rows[rows.length - 1] = trimmed;
|
|
342
|
+
rowLength = dist_default2(trimmed);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
if (index !== 0) {
|
|
346
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
347
|
+
rows.push("");
|
|
348
|
+
rowLength = 0;
|
|
349
|
+
}
|
|
350
|
+
if (rowLength || options.trim === false) {
|
|
351
|
+
rows[rows.length - 1] += " ";
|
|
352
|
+
rowLength++;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
const wordLength = dist_default2(word);
|
|
356
|
+
if (options.hard && wordLength > columns) {
|
|
357
|
+
const remainingColumns = columns - rowLength;
|
|
358
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
359
|
+
const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
|
|
360
|
+
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
361
|
+
rows.push("");
|
|
362
|
+
}
|
|
363
|
+
wrapWord(rows, word, columns);
|
|
364
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
368
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
369
|
+
wrapWord(rows, word, columns);
|
|
370
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
rows.push("");
|
|
374
|
+
rowLength = 0;
|
|
375
|
+
}
|
|
376
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
377
|
+
wrapWord(rows, word, columns);
|
|
378
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
rows[rows.length - 1] += word;
|
|
382
|
+
rowLength += wordLength;
|
|
383
|
+
}
|
|
384
|
+
if (options.trim !== false) {
|
|
385
|
+
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
386
|
+
}
|
|
387
|
+
const preString = rows.join(`
|
|
388
|
+
`);
|
|
389
|
+
let inSurrogate = false;
|
|
390
|
+
for (let i = 0;i < preString.length; i++) {
|
|
391
|
+
const character = preString[i];
|
|
392
|
+
returnValue += character;
|
|
393
|
+
if (!inSurrogate) {
|
|
394
|
+
inSurrogate = character >= "\uD800" && character <= "\uDBFF";
|
|
395
|
+
if (inSurrogate) {
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
} else {
|
|
399
|
+
inSurrogate = false;
|
|
400
|
+
}
|
|
401
|
+
if (character === ESC || character === CSI) {
|
|
402
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
403
|
+
const groupsResult = GROUP_REGEX.exec(preString);
|
|
404
|
+
const groups = groupsResult?.groups;
|
|
405
|
+
if (groups?.code !== undefined) {
|
|
406
|
+
const code = Number.parseFloat(groups.code);
|
|
407
|
+
escapeCode = code === END_CODE ? undefined : code;
|
|
408
|
+
} else if (groups?.uri !== undefined) {
|
|
409
|
+
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (preString[i + 1] === `
|
|
413
|
+
`) {
|
|
414
|
+
if (escapeUrl) {
|
|
415
|
+
returnValue += wrapAnsiHyperlink("");
|
|
416
|
+
}
|
|
417
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
|
|
418
|
+
if (escapeCode && closingCode) {
|
|
419
|
+
returnValue += wrapAnsiCode(closingCode);
|
|
420
|
+
}
|
|
421
|
+
} else if (character === `
|
|
422
|
+
`) {
|
|
423
|
+
if (escapeCode && getClosingCode(escapeCode)) {
|
|
424
|
+
returnValue += wrapAnsiCode(escapeCode);
|
|
425
|
+
}
|
|
426
|
+
if (escapeUrl) {
|
|
427
|
+
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return returnValue;
|
|
432
|
+
};
|
|
433
|
+
var CRLF_OR_LF = /\r?\n/;
|
|
434
|
+
function wrapAnsi(string, columns, options) {
|
|
435
|
+
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
|
|
436
|
+
`);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// node_modules/@clack/core/dist/index.mjs
|
|
440
|
+
var import_sisteransi = __toESM(require_src(), 1);
|
|
441
|
+
function findCursor(s, o, l) {
|
|
442
|
+
if (!l.some((r) => !r.disabled))
|
|
443
|
+
return s;
|
|
444
|
+
const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
|
|
445
|
+
return l[e].disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
|
|
446
|
+
}
|
|
447
|
+
function findTextCursor(s, o, l, i) {
|
|
448
|
+
const t = i.split(`
|
|
449
|
+
`);
|
|
450
|
+
let n = 0, e = s;
|
|
451
|
+
for (const r of t) {
|
|
452
|
+
if (e <= r.length)
|
|
453
|
+
break;
|
|
454
|
+
e -= r.length + 1, n++;
|
|
455
|
+
}
|
|
456
|
+
for (n = Math.max(0, Math.min(t.length - 1, n + l)), e = Math.min(e, t[n].length) + o;e < 0 && n > 0; )
|
|
457
|
+
n--, e += t[n].length + 1;
|
|
458
|
+
for (;e > t[n].length && n < t.length - 1; )
|
|
459
|
+
e -= t[n].length + 1, n++;
|
|
460
|
+
e = Math.max(0, Math.min(t[n].length, e));
|
|
461
|
+
let h = 0;
|
|
462
|
+
for (let r = 0;r < n; r++)
|
|
463
|
+
h += t[r].length + 1;
|
|
464
|
+
return h + e;
|
|
465
|
+
}
|
|
466
|
+
var a$2 = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
467
|
+
var t = [
|
|
468
|
+
"January",
|
|
469
|
+
"February",
|
|
470
|
+
"March",
|
|
471
|
+
"April",
|
|
472
|
+
"May",
|
|
473
|
+
"June",
|
|
474
|
+
"July",
|
|
475
|
+
"August",
|
|
476
|
+
"September",
|
|
477
|
+
"October",
|
|
478
|
+
"November",
|
|
479
|
+
"December"
|
|
480
|
+
];
|
|
481
|
+
var settings = {
|
|
482
|
+
actions: new Set(a$2),
|
|
483
|
+
aliases: /* @__PURE__ */ new Map([
|
|
484
|
+
["k", "up"],
|
|
485
|
+
["j", "down"],
|
|
486
|
+
["h", "left"],
|
|
487
|
+
["l", "right"],
|
|
488
|
+
["\x03", "cancel"],
|
|
489
|
+
["escape", "cancel"]
|
|
490
|
+
]),
|
|
491
|
+
messages: {
|
|
492
|
+
cancel: "Canceled",
|
|
493
|
+
error: "Something went wrong"
|
|
494
|
+
},
|
|
495
|
+
withGuide: true,
|
|
496
|
+
date: {
|
|
497
|
+
monthNames: [...t],
|
|
498
|
+
messages: {
|
|
499
|
+
required: "Please enter a valid date",
|
|
500
|
+
invalidMonth: "There are only 12 months in a year",
|
|
501
|
+
invalidDay: (n, e) => `There are only ${n} days in ${e}`,
|
|
502
|
+
afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
|
|
503
|
+
beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
function isActionKey(n, e) {
|
|
508
|
+
if (typeof n == "string")
|
|
509
|
+
return settings.aliases.get(n) === e;
|
|
510
|
+
for (const s of n)
|
|
511
|
+
if (s !== undefined && isActionKey(s, e))
|
|
512
|
+
return true;
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
function diffLines(i, s) {
|
|
516
|
+
if (i === s)
|
|
517
|
+
return;
|
|
518
|
+
const e = i.split(`
|
|
519
|
+
`), t2 = s.split(`
|
|
520
|
+
`), r = Math.max(e.length, t2.length), f = [];
|
|
521
|
+
for (let n = 0;n < r; n++)
|
|
522
|
+
e[n] !== t2[n] && f.push(n);
|
|
523
|
+
return {
|
|
524
|
+
lines: f,
|
|
525
|
+
numLinesBefore: e.length,
|
|
526
|
+
numLinesAfter: t2.length,
|
|
527
|
+
numLines: r
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
var R = globalThis.process.platform.startsWith("win");
|
|
531
|
+
var CANCEL_SYMBOL = Symbol("clack:cancel");
|
|
532
|
+
function isCancel(e) {
|
|
533
|
+
return e === CANCEL_SYMBOL;
|
|
534
|
+
}
|
|
535
|
+
function setRawMode(e, r) {
|
|
536
|
+
const o = e;
|
|
537
|
+
o.isTTY && o.setRawMode(r);
|
|
538
|
+
}
|
|
539
|
+
var getColumns = (e) => ("columns" in e) && typeof e.columns == "number" ? e.columns : 80;
|
|
540
|
+
var getRows = (e) => ("rows" in e) && typeof e.rows == "number" ? e.rows : 20;
|
|
541
|
+
function wrapTextWithPrefix(e, r, o, t2 = o, s = o, n) {
|
|
542
|
+
const f = getColumns(e ?? stdout);
|
|
543
|
+
return wrapAnsi(r, f - o.length, {
|
|
544
|
+
hard: true,
|
|
545
|
+
trim: false
|
|
546
|
+
}).split(`
|
|
547
|
+
`).map((c, i, m) => {
|
|
548
|
+
const d = n ? n(c, i) : c;
|
|
549
|
+
return i === 0 ? `${t2}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
550
|
+
}).join(`
|
|
551
|
+
`);
|
|
552
|
+
}
|
|
553
|
+
function runValidation(e, n) {
|
|
554
|
+
if ("~standard" in e) {
|
|
555
|
+
const a = e["~standard"].validate(n);
|
|
556
|
+
if (a instanceof Promise)
|
|
557
|
+
throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
|
|
558
|
+
return a.issues?.at(0)?.message;
|
|
559
|
+
}
|
|
560
|
+
return e(n);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
class V {
|
|
564
|
+
input;
|
|
565
|
+
output;
|
|
566
|
+
_abortSignal;
|
|
567
|
+
rl;
|
|
568
|
+
opts;
|
|
569
|
+
_render;
|
|
570
|
+
_track = false;
|
|
571
|
+
_prevFrame = "";
|
|
572
|
+
_subscribers = /* @__PURE__ */ new Map;
|
|
573
|
+
_cursor = 0;
|
|
574
|
+
state = "initial";
|
|
575
|
+
error = "";
|
|
576
|
+
value;
|
|
577
|
+
userInput = "";
|
|
578
|
+
constructor(t2, e = true) {
|
|
579
|
+
const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t2;
|
|
580
|
+
this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r, this.input = i, this.output = n;
|
|
581
|
+
}
|
|
582
|
+
unsubscribe() {
|
|
583
|
+
this._subscribers.clear();
|
|
584
|
+
}
|
|
585
|
+
setSubscriber(t2, e) {
|
|
586
|
+
const i = this._subscribers.get(t2) ?? [];
|
|
587
|
+
i.push(e), this._subscribers.set(t2, i);
|
|
588
|
+
}
|
|
589
|
+
on(t2, e) {
|
|
590
|
+
this.setSubscriber(t2, { cb: e });
|
|
591
|
+
}
|
|
592
|
+
once(t2, e) {
|
|
593
|
+
this.setSubscriber(t2, { cb: e, once: true });
|
|
594
|
+
}
|
|
595
|
+
emit(t2, ...e) {
|
|
596
|
+
const i = this._subscribers.get(t2) ?? [], n = [];
|
|
597
|
+
for (const s of i)
|
|
598
|
+
s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
|
|
599
|
+
for (const s of n)
|
|
600
|
+
s();
|
|
601
|
+
}
|
|
602
|
+
prompt() {
|
|
603
|
+
return new Promise((t2) => {
|
|
604
|
+
if (this._abortSignal) {
|
|
605
|
+
if (this._abortSignal.aborted)
|
|
606
|
+
return this.state = "cancel", this.close(), t2(CANCEL_SYMBOL);
|
|
607
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
608
|
+
this.state = "cancel", this.close();
|
|
609
|
+
}, { once: true });
|
|
610
|
+
}
|
|
611
|
+
this.rl = l__default.createInterface({
|
|
612
|
+
input: this.input,
|
|
613
|
+
tabSize: 2,
|
|
614
|
+
prompt: "",
|
|
615
|
+
escapeCodeTimeout: 50,
|
|
616
|
+
terminal: true
|
|
617
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
618
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
|
|
619
|
+
}), this.once("cancel", () => {
|
|
620
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
|
|
621
|
+
});
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
_isActionKey(t2, e) {
|
|
625
|
+
return t2 === "\t";
|
|
626
|
+
}
|
|
627
|
+
_shouldSubmit(t2, e) {
|
|
628
|
+
return true;
|
|
629
|
+
}
|
|
630
|
+
_setValue(t2) {
|
|
631
|
+
this.value = t2, this.emit("value", this.value);
|
|
632
|
+
}
|
|
633
|
+
_setUserInput(t2, e) {
|
|
634
|
+
this.userInput = t2 ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
635
|
+
}
|
|
636
|
+
_clearUserInput() {
|
|
637
|
+
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
638
|
+
}
|
|
639
|
+
onKeypress(t2, e) {
|
|
640
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2, e), e?.name === "return" && this._shouldSubmit(t2, e)) {
|
|
641
|
+
if (this.opts.validate) {
|
|
642
|
+
const i = runValidation(this.opts.validate, this.value);
|
|
643
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
644
|
+
}
|
|
645
|
+
this.state !== "error" && (this.state = "submit");
|
|
646
|
+
}
|
|
647
|
+
isActionKey([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
648
|
+
}
|
|
649
|
+
close() {
|
|
650
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
651
|
+
`), setRawMode(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
652
|
+
}
|
|
653
|
+
restoreCursor() {
|
|
654
|
+
const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
655
|
+
`).length - 1;
|
|
656
|
+
this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
|
|
657
|
+
}
|
|
658
|
+
render() {
|
|
659
|
+
const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
660
|
+
hard: true,
|
|
661
|
+
trim: false
|
|
662
|
+
});
|
|
663
|
+
if (t2 !== this._prevFrame) {
|
|
664
|
+
if (this.state === "initial")
|
|
665
|
+
this.output.write(import_sisteransi.cursor.hide);
|
|
666
|
+
else {
|
|
667
|
+
const e = diffLines(this._prevFrame, t2), i = getRows(this.output);
|
|
668
|
+
if (this.restoreCursor(), e) {
|
|
669
|
+
const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
|
|
670
|
+
let r = e.lines.find((o) => o >= n);
|
|
671
|
+
if (r === undefined) {
|
|
672
|
+
this._prevFrame = t2;
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
if (e.lines.length === 1) {
|
|
676
|
+
this.output.write(import_sisteransi.cursor.move(0, r - s)), this.output.write(import_sisteransi.erase.lines(1));
|
|
677
|
+
const o = t2.split(`
|
|
678
|
+
`);
|
|
679
|
+
this.output.write(o[r]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o.length - r - 1));
|
|
680
|
+
return;
|
|
681
|
+
} else if (e.lines.length > 1) {
|
|
682
|
+
if (n < s)
|
|
683
|
+
r = n;
|
|
684
|
+
else {
|
|
685
|
+
const h = r - s;
|
|
686
|
+
h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
|
|
687
|
+
}
|
|
688
|
+
this.output.write(import_sisteransi.erase.down());
|
|
689
|
+
const f = t2.split(`
|
|
690
|
+
`).slice(r);
|
|
691
|
+
this.output.write(f.join(`
|
|
692
|
+
`)), this._prevFrame = t2;
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
this.output.write(import_sisteransi.erase.down());
|
|
697
|
+
}
|
|
698
|
+
this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
function p$1(l, e) {
|
|
703
|
+
if (l === undefined || e.length === 0)
|
|
704
|
+
return 0;
|
|
705
|
+
const i = e.findIndex((s) => s.value === l);
|
|
706
|
+
return i !== -1 ? i : 0;
|
|
707
|
+
}
|
|
708
|
+
function g(l, e) {
|
|
709
|
+
return (e.label ?? String(e.value)).toLowerCase().includes(l.toLowerCase());
|
|
710
|
+
}
|
|
711
|
+
function m(l, e) {
|
|
712
|
+
if (e)
|
|
713
|
+
return l ? e : e[0];
|
|
714
|
+
}
|
|
715
|
+
var T$1 = class T extends V {
|
|
716
|
+
filteredOptions;
|
|
717
|
+
multiple;
|
|
718
|
+
isNavigating = false;
|
|
719
|
+
selectedValues = [];
|
|
720
|
+
focusedValue;
|
|
721
|
+
#e = 0;
|
|
722
|
+
#s = "";
|
|
723
|
+
#t;
|
|
724
|
+
#i;
|
|
725
|
+
#n;
|
|
726
|
+
get cursor() {
|
|
727
|
+
return this.#e;
|
|
728
|
+
}
|
|
729
|
+
get userInputWithCursor() {
|
|
730
|
+
if (!this.userInput)
|
|
731
|
+
return styleText(["inverse", "hidden"], "_");
|
|
732
|
+
if (this._cursor >= this.userInput.length)
|
|
733
|
+
return `${this.userInput}\u2588`;
|
|
734
|
+
const e = this.userInput.slice(0, this._cursor), [t2, ...i] = this.userInput.slice(this._cursor);
|
|
735
|
+
return `${e}${styleText("inverse", t2)}${i.join("")}`;
|
|
736
|
+
}
|
|
737
|
+
get options() {
|
|
738
|
+
return typeof this.#i == "function" ? this.#i() : this.#i;
|
|
739
|
+
}
|
|
740
|
+
constructor(e) {
|
|
741
|
+
super(e), this.#i = e.options, this.#n = e.placeholder;
|
|
742
|
+
const t2 = this.options;
|
|
743
|
+
this.filteredOptions = [...t2], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? g;
|
|
744
|
+
let i;
|
|
745
|
+
if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0].value]), i)
|
|
746
|
+
for (const s of i) {
|
|
747
|
+
const n = t2.findIndex((o) => o.value === s);
|
|
748
|
+
n !== -1 && (this.toggleSelected(s), this.#e = n);
|
|
749
|
+
}
|
|
750
|
+
this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n) => this.#l(s, n)), this.on("userInput", (s) => this.#u(s));
|
|
751
|
+
}
|
|
752
|
+
_isActionKey(e, t2) {
|
|
753
|
+
return e === "\t" || this.multiple && this.isNavigating && t2.name === "space" && e !== undefined && e !== "";
|
|
754
|
+
}
|
|
755
|
+
#l(e, t2) {
|
|
756
|
+
const i = t2.name === "up", s = t2.name === "down", n = t2.name === "return", o = this.userInput === "" || this.userInput === "\t", u = this.#n, h = this.options, f = u !== undefined && u !== "" && h.some((r) => !r.disabled && (this.#t ? this.#t(u, r) : true));
|
|
757
|
+
if (t2.name === "tab" && o && f) {
|
|
758
|
+
this.userInput === "\t" && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
i || s ? (this.#e = findCursor(this.#e, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = m(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (t2.name === "tab" || this.isNavigating && t2.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
|
|
762
|
+
}
|
|
763
|
+
deselectAll() {
|
|
764
|
+
this.selectedValues = [];
|
|
765
|
+
}
|
|
766
|
+
toggleSelected(e) {
|
|
767
|
+
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((t2) => t2 !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
|
|
768
|
+
}
|
|
769
|
+
#u(e) {
|
|
770
|
+
if (e !== this.#s) {
|
|
771
|
+
this.#s = e;
|
|
772
|
+
const t2 = this.options;
|
|
773
|
+
e && this.#t ? this.filteredOptions = t2.filter((n) => this.#t?.(e, n)) : this.filteredOptions = [...t2];
|
|
774
|
+
const i = p$1(this.focusedValue, this.filteredOptions);
|
|
775
|
+
this.#e = findCursor(i, 0, this.filteredOptions);
|
|
776
|
+
const s = this.filteredOptions[this.#e];
|
|
777
|
+
s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
};
|
|
781
|
+
var _ = {
|
|
782
|
+
Y: { type: "year", len: 4 },
|
|
783
|
+
M: { type: "month", len: 2 },
|
|
784
|
+
D: { type: "day", len: 2 }
|
|
785
|
+
};
|
|
786
|
+
function M(r) {
|
|
787
|
+
return [...r].map((t2) => _[t2]);
|
|
788
|
+
}
|
|
789
|
+
function P(r) {
|
|
790
|
+
const i = new Intl.DateTimeFormat(r, {
|
|
791
|
+
year: "numeric",
|
|
792
|
+
month: "2-digit",
|
|
793
|
+
day: "2-digit"
|
|
794
|
+
}).formatToParts(new Date(2000, 0, 15)), s = [];
|
|
795
|
+
let n = "/";
|
|
796
|
+
for (const e of i)
|
|
797
|
+
e.type === "literal" ? n = e.value.trim() || e.value : (e.type === "year" || e.type === "month" || e.type === "day") && s.push({ type: e.type, len: e.type === "year" ? 4 : 2 });
|
|
798
|
+
return { segments: s, separator: n };
|
|
799
|
+
}
|
|
800
|
+
function p(r) {
|
|
801
|
+
return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
|
|
802
|
+
}
|
|
803
|
+
function f(r) {
|
|
804
|
+
return {
|
|
805
|
+
year: p(r.year),
|
|
806
|
+
month: p(r.month),
|
|
807
|
+
day: p(r.day)
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
function c(r, t2) {
|
|
811
|
+
return new Date(r || 2001, t2 || 1, 0).getDate();
|
|
812
|
+
}
|
|
813
|
+
function b(r) {
|
|
814
|
+
const { year: t2, month: i, day: s } = f(r);
|
|
815
|
+
if (!t2 || t2 < 0 || t2 > 9999 || !i || i < 1 || i > 12 || !s || s < 1)
|
|
816
|
+
return;
|
|
817
|
+
const n = new Date(Date.UTC(t2, i - 1, s));
|
|
818
|
+
if (!(n.getUTCFullYear() !== t2 || n.getUTCMonth() !== i - 1 || n.getUTCDate() !== s))
|
|
819
|
+
return { year: t2, month: i, day: s };
|
|
820
|
+
}
|
|
821
|
+
function C(r) {
|
|
822
|
+
const t2 = b(r);
|
|
823
|
+
return t2 ? new Date(Date.UTC(t2.year, t2.month - 1, t2.day)) : undefined;
|
|
824
|
+
}
|
|
825
|
+
function T2(r, t2, i, s) {
|
|
826
|
+
const n = i ? {
|
|
827
|
+
year: i.getUTCFullYear(),
|
|
828
|
+
month: i.getUTCMonth() + 1,
|
|
829
|
+
day: i.getUTCDate()
|
|
830
|
+
} : null, e = s ? {
|
|
831
|
+
year: s.getUTCFullYear(),
|
|
832
|
+
month: s.getUTCMonth() + 1,
|
|
833
|
+
day: s.getUTCDate()
|
|
834
|
+
} : null;
|
|
835
|
+
return r === "year" ? { min: n?.year ?? 1, max: e?.year ?? 9999 } : r === "month" ? {
|
|
836
|
+
min: n && t2.year === n.year ? n.month : 1,
|
|
837
|
+
max: e && t2.year === e.year ? e.month : 12
|
|
838
|
+
} : {
|
|
839
|
+
min: n && t2.year === n.year && t2.month === n.month ? n.day : 1,
|
|
840
|
+
max: e && t2.year === e.year && t2.month === e.month ? e.day : c(t2.year, t2.month)
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
class U extends V {
|
|
845
|
+
#i;
|
|
846
|
+
#o;
|
|
847
|
+
#t;
|
|
848
|
+
#h;
|
|
849
|
+
#u;
|
|
850
|
+
#e = { segmentIndex: 0, positionInSegment: 0 };
|
|
851
|
+
#n = true;
|
|
852
|
+
#s = null;
|
|
853
|
+
inlineError = "";
|
|
854
|
+
get segmentCursor() {
|
|
855
|
+
return { ...this.#e };
|
|
856
|
+
}
|
|
857
|
+
get segmentValues() {
|
|
858
|
+
return { ...this.#t };
|
|
859
|
+
}
|
|
860
|
+
get segments() {
|
|
861
|
+
return this.#i;
|
|
862
|
+
}
|
|
863
|
+
get separator() {
|
|
864
|
+
return this.#o;
|
|
865
|
+
}
|
|
866
|
+
get formattedValue() {
|
|
867
|
+
return this.#l(this.#t);
|
|
868
|
+
}
|
|
869
|
+
#l(t2) {
|
|
870
|
+
return this.#i.map((i) => t2[i.type]).join(this.#o);
|
|
871
|
+
}
|
|
872
|
+
#r() {
|
|
873
|
+
this._setUserInput(this.#l(this.#t)), this._setValue(C(this.#t) ?? undefined);
|
|
874
|
+
}
|
|
875
|
+
constructor(t2) {
|
|
876
|
+
const i = t2.format ? { segments: M(t2.format), separator: t2.separator ?? "/" } : P(t2.locale), s = t2.separator ?? i.separator, n = t2.format ? M(t2.format) : i.segments, e = t2.initialValue ?? t2.defaultValue, m2 = e ? {
|
|
877
|
+
year: String(e.getUTCFullYear()).padStart(4, "0"),
|
|
878
|
+
month: String(e.getUTCMonth() + 1).padStart(2, "0"),
|
|
879
|
+
day: String(e.getUTCDate()).padStart(2, "0")
|
|
880
|
+
} : { year: "____", month: "__", day: "__" }, o = n.map((a) => m2[a.type]).join(s);
|
|
881
|
+
super({ ...t2, initialUserInput: o }, false), this.#i = n, this.#o = s, this.#t = m2, this.#h = t2.minDate, this.#u = t2.maxDate, this.#r(), this.on("cursor", (a) => this.#f(a)), this.on("key", (a, u) => this.#y(a, u)), this.on("finalize", () => this.#p(t2));
|
|
882
|
+
}
|
|
883
|
+
#a() {
|
|
884
|
+
const t2 = Math.max(0, Math.min(this.#e.segmentIndex, this.#i.length - 1)), i = this.#i[t2];
|
|
885
|
+
if (i)
|
|
886
|
+
return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, i.len - 1)), { segment: i, index: t2 };
|
|
887
|
+
}
|
|
888
|
+
#m(t2) {
|
|
889
|
+
this.inlineError = "", this.#s = null;
|
|
890
|
+
const i = this.#a();
|
|
891
|
+
i && (this.#e.segmentIndex = Math.max(0, Math.min(this.#i.length - 1, i.index + t2)), this.#e.positionInSegment = 0, this.#n = true);
|
|
892
|
+
}
|
|
893
|
+
#d(t2) {
|
|
894
|
+
const i = this.#a();
|
|
895
|
+
if (!i)
|
|
896
|
+
return;
|
|
897
|
+
const { segment: s } = i, n = this.#t[s.type], e = !n || n.replace(/_/g, "") === "", m2 = Number.parseInt((n || "0").replace(/_/g, "0"), 10) || 0, o = T2(s.type, f(this.#t), this.#h, this.#u);
|
|
898
|
+
let a;
|
|
899
|
+
e ? a = t2 === 1 ? o.min : o.max : a = Math.max(Math.min(o.max, m2 + t2), o.min), this.#t = {
|
|
900
|
+
...this.#t,
|
|
901
|
+
[s.type]: a.toString().padStart(s.len, "0")
|
|
902
|
+
}, this.#n = true, this.#s = null, this.#r();
|
|
903
|
+
}
|
|
904
|
+
#f(t2) {
|
|
905
|
+
if (t2)
|
|
906
|
+
switch (t2) {
|
|
907
|
+
case "right":
|
|
908
|
+
return this.#m(1);
|
|
909
|
+
case "left":
|
|
910
|
+
return this.#m(-1);
|
|
911
|
+
case "up":
|
|
912
|
+
return this.#d(1);
|
|
913
|
+
case "down":
|
|
914
|
+
return this.#d(-1);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
#y(t2, i) {
|
|
918
|
+
if (i?.name === "backspace" || i?.sequence === "\x7F" || i?.sequence === "\b" || t2 === "\x7F" || t2 === "\b") {
|
|
919
|
+
this.inlineError = "";
|
|
920
|
+
const n = this.#a();
|
|
921
|
+
if (!n)
|
|
922
|
+
return;
|
|
923
|
+
if (!this.#t[n.segment.type].replace(/_/g, "")) {
|
|
924
|
+
this.#m(-1);
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
this.#t[n.segment.type] = "_".repeat(n.segment.len), this.#n = true, this.#e.positionInSegment = 0, this.#r();
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
if (i?.name === "tab") {
|
|
931
|
+
this.inlineError = "";
|
|
932
|
+
const n = this.#a();
|
|
933
|
+
if (!n)
|
|
934
|
+
return;
|
|
935
|
+
const e = i.shift ? -1 : 1, m2 = n.index + e;
|
|
936
|
+
m2 >= 0 && m2 < this.#i.length && (this.#e.segmentIndex = m2, this.#e.positionInSegment = 0, this.#n = true);
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
if (t2 && /^[0-9]$/.test(t2)) {
|
|
940
|
+
const n = this.#a();
|
|
941
|
+
if (!n)
|
|
942
|
+
return;
|
|
943
|
+
const { segment: e } = n, m2 = !this.#t[e.type].replace(/_/g, "");
|
|
944
|
+
if (this.#n && this.#s !== null && !m2) {
|
|
945
|
+
const h = this.#s + t2, d = { ...this.#t, [e.type]: h }, g2 = this.#g(d, e);
|
|
946
|
+
if (g2) {
|
|
947
|
+
this.inlineError = g2, this.#s = null, this.#n = false;
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
this.inlineError = "", this.#t[e.type] = h, this.#s = null, this.#n = false, this.#r(), n.index < this.#i.length - 1 && (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true);
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
this.#n && !m2 && (this.#t[e.type] = "_".repeat(e.len), this.#e.positionInSegment = 0), this.#n = false, this.#s = null;
|
|
954
|
+
const o = this.#t[e.type], a = o.indexOf("_"), u = a >= 0 ? a : Math.min(this.#e.positionInSegment, e.len - 1);
|
|
955
|
+
if (u < 0 || u >= e.len)
|
|
956
|
+
return;
|
|
957
|
+
let l = o.slice(0, u) + t2 + o.slice(u + 1), D = false;
|
|
958
|
+
if (u === 0 && o === "__" && (e.type === "month" || e.type === "day")) {
|
|
959
|
+
const h = Number.parseInt(t2, 10);
|
|
960
|
+
l = `0${t2}`, D = h <= (e.type === "month" ? 1 : 2);
|
|
961
|
+
}
|
|
962
|
+
if (e.type === "year" && (l = (o.replace(/_/g, "") + t2).padStart(e.len, "_")), !l.includes("_")) {
|
|
963
|
+
const h = { ...this.#t, [e.type]: l }, d = this.#g(h, e);
|
|
964
|
+
if (d) {
|
|
965
|
+
this.inlineError = d;
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
this.inlineError = "", this.#t[e.type] = l;
|
|
970
|
+
const y = l.includes("_") ? undefined : b(this.#t);
|
|
971
|
+
if (y) {
|
|
972
|
+
const { year: h, month: d } = y, g2 = c(h, d);
|
|
973
|
+
this.#t = {
|
|
974
|
+
year: String(Math.max(0, Math.min(9999, h))).padStart(4, "0"),
|
|
975
|
+
month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
|
|
976
|
+
day: String(Math.max(1, Math.min(g2, y.day))).padStart(2, "0")
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
this.#r();
|
|
980
|
+
const S = l.indexOf("_");
|
|
981
|
+
D ? (this.#n = true, this.#s = t2) : S >= 0 ? this.#e.positionInSegment = S : a >= 0 && n.index < this.#i.length - 1 ? (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true) : this.#e.positionInSegment = Math.min(u + 1, e.len - 1);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
#g(t2, i) {
|
|
985
|
+
const { month: s, day: n } = f(t2);
|
|
986
|
+
if (i.type === "month" && (s < 0 || s > 12))
|
|
987
|
+
return settings.date.messages.invalidMonth;
|
|
988
|
+
if (i.type === "day" && (n < 0 || n > 31))
|
|
989
|
+
return settings.date.messages.invalidDay(31, "any month");
|
|
990
|
+
}
|
|
991
|
+
#p(t2) {
|
|
992
|
+
const { year: i, month: s, day: n } = f(this.#t);
|
|
993
|
+
if (i && s && n) {
|
|
994
|
+
const e = c(i, s);
|
|
995
|
+
this.#t = {
|
|
996
|
+
...this.#t,
|
|
997
|
+
day: String(Math.min(n, e)).padStart(2, "0")
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
this.value = C(this.#t) ?? t2.defaultValue ?? undefined;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
var u$1 = class u extends V {
|
|
1004
|
+
options;
|
|
1005
|
+
cursor = 0;
|
|
1006
|
+
#t;
|
|
1007
|
+
getGroupItems(t2) {
|
|
1008
|
+
return this.options.filter((r) => r.group === t2);
|
|
1009
|
+
}
|
|
1010
|
+
isGroupSelected(t2) {
|
|
1011
|
+
const r = this.getGroupItems(t2), e = this.value;
|
|
1012
|
+
return e === undefined ? false : r.every((s) => e.includes(s.value));
|
|
1013
|
+
}
|
|
1014
|
+
toggleValue() {
|
|
1015
|
+
const t2 = this.options[this.cursor];
|
|
1016
|
+
if (this.value === undefined && (this.value = []), t2.group === true) {
|
|
1017
|
+
const r = t2.value, e = this.getGroupItems(r);
|
|
1018
|
+
this.isGroupSelected(r) ? this.value = this.value.filter((s) => e.findIndex((i) => i.value === s) === -1) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
|
|
1019
|
+
} else {
|
|
1020
|
+
const r = this.value.includes(t2.value);
|
|
1021
|
+
this.value = r ? this.value.filter((e) => e !== t2.value) : [...this.value, t2.value];
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
constructor(t2) {
|
|
1025
|
+
super(t2, false);
|
|
1026
|
+
const { options: r } = t2;
|
|
1027
|
+
this.#t = t2.selectableGroups !== false, this.options = Object.entries(r).flatMap(([e, s]) => [
|
|
1028
|
+
{ value: e, group: true, label: e },
|
|
1029
|
+
...s.map((i) => ({ ...i, group: e }))
|
|
1030
|
+
]), this.value = [...t2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: e }) => e === t2.cursorAt), this.#t ? 0 : 1), this.on("cursor", (e) => {
|
|
1031
|
+
switch (e) {
|
|
1032
|
+
case "left":
|
|
1033
|
+
case "up": {
|
|
1034
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
1035
|
+
const s = this.options[this.cursor]?.group === true;
|
|
1036
|
+
!this.#t && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
1037
|
+
break;
|
|
1038
|
+
}
|
|
1039
|
+
case "down":
|
|
1040
|
+
case "right": {
|
|
1041
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1042
|
+
const s = this.options[this.cursor]?.group === true;
|
|
1043
|
+
!this.#t && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1044
|
+
break;
|
|
1045
|
+
}
|
|
1046
|
+
case "space":
|
|
1047
|
+
this.toggleValue();
|
|
1048
|
+
break;
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
};
|
|
1053
|
+
var o$1 = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
|
|
1054
|
+
|
|
1055
|
+
class h extends V {
|
|
1056
|
+
#t = false;
|
|
1057
|
+
#s;
|
|
1058
|
+
focused = "editor";
|
|
1059
|
+
get userInputWithCursor() {
|
|
1060
|
+
if (this.state === "submit")
|
|
1061
|
+
return this.userInput;
|
|
1062
|
+
const t2 = this.userInput;
|
|
1063
|
+
if (this.cursor >= t2.length)
|
|
1064
|
+
return `${t2}\u2588`;
|
|
1065
|
+
const s = t2.slice(0, this.cursor), r = t2[this.cursor], i = t2.slice(this.cursor + 1);
|
|
1066
|
+
return r === `
|
|
1067
|
+
` ? `${s}\u2588
|
|
1068
|
+
${i}` : `${s}${styleText("inverse", r)}${i}`;
|
|
1069
|
+
}
|
|
1070
|
+
get cursor() {
|
|
1071
|
+
return this._cursor;
|
|
1072
|
+
}
|
|
1073
|
+
#r(t2) {
|
|
1074
|
+
if (this.userInput.length === 0) {
|
|
1075
|
+
this._setUserInput(t2);
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
this._setUserInput(this.userInput.slice(0, this.cursor) + t2 + this.userInput.slice(this.cursor));
|
|
1079
|
+
}
|
|
1080
|
+
#i(t2) {
|
|
1081
|
+
const s = this.value ?? "";
|
|
1082
|
+
switch (t2) {
|
|
1083
|
+
case "up":
|
|
1084
|
+
this._cursor = findTextCursor(this._cursor, 0, -1, s);
|
|
1085
|
+
return;
|
|
1086
|
+
case "down":
|
|
1087
|
+
this._cursor = findTextCursor(this._cursor, 0, 1, s);
|
|
1088
|
+
return;
|
|
1089
|
+
case "left":
|
|
1090
|
+
this._cursor = findTextCursor(this._cursor, -1, 0, s);
|
|
1091
|
+
return;
|
|
1092
|
+
case "right":
|
|
1093
|
+
this._cursor = findTextCursor(this._cursor, 1, 0, s);
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
_shouldSubmit(t2, s) {
|
|
1098
|
+
if (this.#s)
|
|
1099
|
+
return this.focused === "submit" ? true : (this.#r(`
|
|
1100
|
+
`), this._cursor++, false);
|
|
1101
|
+
const r = this.#t;
|
|
1102
|
+
return this.#t = true, r && this.cursor === this.userInput.length ? (this.userInput[this.cursor - 1] === `
|
|
1103
|
+
` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#r(`
|
|
1104
|
+
`), this._cursor++, false);
|
|
1105
|
+
}
|
|
1106
|
+
constructor(t2) {
|
|
1107
|
+
const s = t2.initialUserInput ?? t2.initialValue;
|
|
1108
|
+
super({
|
|
1109
|
+
...t2,
|
|
1110
|
+
initialUserInput: s
|
|
1111
|
+
}, false), s !== undefined && (this._cursor = s.length), this.#s = t2.showSubmit ?? false, this.on("key", (r, i) => {
|
|
1112
|
+
if (i?.name && o$1.has(i.name)) {
|
|
1113
|
+
this.#t = false, this.#i(i.name);
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
if (r === "\t" && this.#s) {
|
|
1117
|
+
this.focused = this.focused === "editor" ? "submit" : "editor";
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
if (i?.name !== "return") {
|
|
1121
|
+
if (this.#t = false, i?.name === "backspace" && this.cursor > 0) {
|
|
1122
|
+
this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
if (i?.name === "delete" && this.cursor < this.userInput.length) {
|
|
1126
|
+
this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
r && (this.#s && this.focused === "submit" && (this.focused = "editor"), this.#r(r ?? ""), this._cursor++);
|
|
1130
|
+
}
|
|
1131
|
+
}), this.on("userInput", (r) => {
|
|
1132
|
+
this._setValue(r);
|
|
1133
|
+
}), this.on("finalize", () => {
|
|
1134
|
+
this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
class a extends V {
|
|
1139
|
+
options;
|
|
1140
|
+
cursor = 0;
|
|
1141
|
+
get _selectedValue() {
|
|
1142
|
+
return this.options[this.cursor];
|
|
1143
|
+
}
|
|
1144
|
+
changeValue() {
|
|
1145
|
+
this.value = this._selectedValue.value;
|
|
1146
|
+
}
|
|
1147
|
+
constructor(t2) {
|
|
1148
|
+
super(t2, false), this.options = t2.options;
|
|
1149
|
+
const i = this.options.findIndex(({ value: s }) => s === t2.initialValue), e = i === -1 ? 0 : i;
|
|
1150
|
+
this.cursor = this.options[e].disabled ? findCursor(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (s) => {
|
|
1151
|
+
switch (s) {
|
|
1152
|
+
case "left":
|
|
1153
|
+
case "up":
|
|
1154
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
1155
|
+
break;
|
|
1156
|
+
case "down":
|
|
1157
|
+
case "right":
|
|
1158
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
1159
|
+
break;
|
|
1160
|
+
}
|
|
1161
|
+
this.changeValue();
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
class n extends V {
|
|
1166
|
+
get userInputWithCursor() {
|
|
1167
|
+
if (this.state === "submit")
|
|
1168
|
+
return this.userInput;
|
|
1169
|
+
const t2 = this.userInput;
|
|
1170
|
+
if (this.cursor >= t2.length)
|
|
1171
|
+
return `${this.userInput}\u2588`;
|
|
1172
|
+
const e = t2.slice(0, this.cursor), [s, ...r] = t2.slice(this.cursor);
|
|
1173
|
+
return `${e}${styleText("inverse", s)}${r.join("")}`;
|
|
1174
|
+
}
|
|
1175
|
+
get cursor() {
|
|
1176
|
+
return this._cursor;
|
|
1177
|
+
}
|
|
1178
|
+
constructor(t2) {
|
|
1179
|
+
super({
|
|
1180
|
+
...t2,
|
|
1181
|
+
initialUserInput: t2.initialUserInput ?? t2.initialValue
|
|
1182
|
+
}), this.on("userInput", (e) => {
|
|
1183
|
+
this._setValue(e);
|
|
1184
|
+
}), this.on("finalize", () => {
|
|
1185
|
+
this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
// node_modules/@clack/prompts/dist/index.mjs
|
|
1191
|
+
import { styleText as styleText2, stripVTControlCharacters } from "util";
|
|
1192
|
+
import process$1 from "process";
|
|
1193
|
+
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
1194
|
+
function isUnicodeSupported() {
|
|
1195
|
+
if (process$1.platform !== "win32") {
|
|
1196
|
+
return process$1.env.TERM !== "linux";
|
|
1197
|
+
}
|
|
1198
|
+
return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
1199
|
+
}
|
|
1200
|
+
var unicode = isUnicodeSupported();
|
|
1201
|
+
var unicodeOr = (o2, e) => unicode ? o2 : e;
|
|
1202
|
+
var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
|
|
1203
|
+
var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
|
|
1204
|
+
var S_STEP_ERROR = unicodeOr("\u25B2", "x");
|
|
1205
|
+
var S_STEP_SUBMIT = unicodeOr("\u25C7", "o");
|
|
1206
|
+
var S_BAR_START = unicodeOr("\u250C", "T");
|
|
1207
|
+
var S_BAR = unicodeOr("\u2502", "|");
|
|
1208
|
+
var S_BAR_END = unicodeOr("\u2514", "\u2014");
|
|
1209
|
+
var S_BAR_START_RIGHT = unicodeOr("\u2510", "T");
|
|
1210
|
+
var S_BAR_END_RIGHT = unicodeOr("\u2518", "\u2014");
|
|
1211
|
+
var S_RADIO_ACTIVE = unicodeOr("\u25CF", ">");
|
|
1212
|
+
var S_RADIO_INACTIVE = unicodeOr("\u25CB", " ");
|
|
1213
|
+
var S_CHECKBOX_ACTIVE = unicodeOr("\u25FB", "[\u2022]");
|
|
1214
|
+
var S_CHECKBOX_SELECTED = unicodeOr("\u25FC", "[+]");
|
|
1215
|
+
var S_CHECKBOX_INACTIVE = unicodeOr("\u25FB", "[ ]");
|
|
1216
|
+
var S_PASSWORD_MASK = unicodeOr("\u25AA", "\u2022");
|
|
1217
|
+
var S_BAR_H = unicodeOr("\u2500", "-");
|
|
1218
|
+
var S_CORNER_TOP_RIGHT = unicodeOr("\u256E", "+");
|
|
1219
|
+
var S_CONNECT_LEFT = unicodeOr("\u251C", "+");
|
|
1220
|
+
var S_CORNER_BOTTOM_RIGHT = unicodeOr("\u256F", "+");
|
|
1221
|
+
var S_CORNER_BOTTOM_LEFT = unicodeOr("\u2570", "+");
|
|
1222
|
+
var S_CORNER_TOP_LEFT = unicodeOr("\u256D", "+");
|
|
1223
|
+
var S_INFO = unicodeOr("\u25CF", "\u2022");
|
|
1224
|
+
var S_SUCCESS = unicodeOr("\u25C6", "*");
|
|
1225
|
+
var S_WARN = unicodeOr("\u25B2", "!");
|
|
1226
|
+
var S_ERROR = unicodeOr("\u25A0", "x");
|
|
1227
|
+
var symbol = (o2) => {
|
|
1228
|
+
switch (o2) {
|
|
1229
|
+
case "initial":
|
|
1230
|
+
case "active":
|
|
1231
|
+
return styleText2("cyan", S_STEP_ACTIVE);
|
|
1232
|
+
case "cancel":
|
|
1233
|
+
return styleText2("red", S_STEP_CANCEL);
|
|
1234
|
+
case "error":
|
|
1235
|
+
return styleText2("yellow", S_STEP_ERROR);
|
|
1236
|
+
case "submit":
|
|
1237
|
+
return styleText2("green", S_STEP_SUBMIT);
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1240
|
+
var symbolBar = (o2) => {
|
|
1241
|
+
switch (o2) {
|
|
1242
|
+
case "initial":
|
|
1243
|
+
case "active":
|
|
1244
|
+
return styleText2("cyan", S_BAR);
|
|
1245
|
+
case "cancel":
|
|
1246
|
+
return styleText2("red", S_BAR);
|
|
1247
|
+
case "error":
|
|
1248
|
+
return styleText2("yellow", S_BAR);
|
|
1249
|
+
case "submit":
|
|
1250
|
+
return styleText2("green", S_BAR);
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
function formatInstructionFooter(o2, e) {
|
|
1254
|
+
const r2 = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${o2.join(" \u2022 ")}`];
|
|
1255
|
+
return e && r2.push(styleText2("cyan", S_BAR_END)), r2;
|
|
1256
|
+
}
|
|
1257
|
+
var E$1 = (l, o2, g2, c2, h2, O = false) => {
|
|
1258
|
+
let r2 = o2, w = 0;
|
|
1259
|
+
if (O)
|
|
1260
|
+
for (let i = c2 - 1;i >= g2 && (r2 -= l[i].length, w++, !(r2 <= h2)); i--)
|
|
1261
|
+
;
|
|
1262
|
+
else
|
|
1263
|
+
for (let i = g2;i < c2 && (r2 -= l[i].length, w++, !(r2 <= h2)); i++)
|
|
1264
|
+
;
|
|
1265
|
+
return { lineCount: r2, removals: w };
|
|
1266
|
+
};
|
|
1267
|
+
var limitOptions = ({
|
|
1268
|
+
cursor: l,
|
|
1269
|
+
options: o2,
|
|
1270
|
+
style: g2,
|
|
1271
|
+
output: c2 = process.stdout,
|
|
1272
|
+
maxItems: h2 = Number.POSITIVE_INFINITY,
|
|
1273
|
+
columnPadding: O = 0,
|
|
1274
|
+
rowPadding: r2 = 4
|
|
1275
|
+
}) => {
|
|
1276
|
+
const i = getColumns(c2) - O, I = getRows(c2), C2 = styleText2("dim", "..."), x = Math.max(I - r2, 0), m2 = Math.max(Math.min(h2, x), 5);
|
|
1277
|
+
let p2 = 0;
|
|
1278
|
+
l >= m2 - 3 && (p2 = Math.max(Math.min(l - m2 + 3, o2.length - m2), 0));
|
|
1279
|
+
let f2 = m2 < o2.length && p2 > 0, u3 = m2 < o2.length && p2 + m2 < o2.length;
|
|
1280
|
+
const W = Math.min(p2 + m2, o2.length), e = [];
|
|
1281
|
+
let d = 0;
|
|
1282
|
+
f2 && d++, u3 && d++;
|
|
1283
|
+
const v = p2 + (f2 ? 1 : 0), P2 = W - (u3 ? 1 : 0);
|
|
1284
|
+
for (let t2 = v;t2 < P2; t2++) {
|
|
1285
|
+
const n2 = wrapAnsi(g2(o2[t2], t2 === l), i, {
|
|
1286
|
+
hard: true,
|
|
1287
|
+
trim: false
|
|
1288
|
+
}).split(`
|
|
1289
|
+
`);
|
|
1290
|
+
e.push(n2), d += n2.length;
|
|
1291
|
+
}
|
|
1292
|
+
if (d > x) {
|
|
1293
|
+
let t2 = 0, n2 = 0, s = d;
|
|
1294
|
+
const M2 = l - v;
|
|
1295
|
+
let a2 = x;
|
|
1296
|
+
const T3 = () => E$1(e, s, 0, M2, a2), L = () => E$1(e, s, M2 + 1, e.length, a2, true);
|
|
1297
|
+
f2 ? ({ lineCount: s, removals: t2 } = T3(), s > a2 && (u3 || (a2 -= 1), { lineCount: s, removals: n2 } = L())) : (u3 || (a2 -= 1), { lineCount: s, removals: n2 } = L(), s > a2 && (a2 -= 1, { lineCount: s, removals: t2 } = T3())), t2 > 0 && (f2 = true, e.splice(0, t2)), n2 > 0 && (u3 = true, e.splice(e.length - n2, n2));
|
|
1298
|
+
}
|
|
1299
|
+
const b2 = [];
|
|
1300
|
+
f2 && b2.push(C2);
|
|
1301
|
+
for (const t2 of e)
|
|
1302
|
+
for (const n2 of t2)
|
|
1303
|
+
b2.push(n2);
|
|
1304
|
+
return u3 && b2.push(C2), b2;
|
|
1305
|
+
};
|
|
1306
|
+
var group = async (o2, r2) => {
|
|
1307
|
+
const t2 = {}, p2 = Object.keys(o2);
|
|
1308
|
+
for (const e of p2) {
|
|
1309
|
+
const i = o2[e], n2 = await i({ results: t2 })?.catch((a2) => {
|
|
1310
|
+
throw a2;
|
|
1311
|
+
});
|
|
1312
|
+
if (typeof r2?.onCancel == "function" && isCancel(n2)) {
|
|
1313
|
+
t2[e] = "canceled", r2.onCancel({ results: t2 });
|
|
1314
|
+
continue;
|
|
1315
|
+
}
|
|
1316
|
+
t2[e] = n2;
|
|
1317
|
+
}
|
|
1318
|
+
return t2;
|
|
1319
|
+
};
|
|
1320
|
+
var MULTISELECT_INSTRUCTIONS = [
|
|
1321
|
+
`${styleText2("dim", "\u2191/\u2193")} to navigate`,
|
|
1322
|
+
`${styleText2("dim", "Space:")} select`,
|
|
1323
|
+
`${styleText2("dim", "Enter:")} confirm`
|
|
1324
|
+
];
|
|
1325
|
+
var cancel = (o2 = "", t2) => {
|
|
1326
|
+
const i = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_END)} ` : "";
|
|
1327
|
+
i.write(`${e}${styleText2("red", o2)}
|
|
1328
|
+
|
|
1329
|
+
`);
|
|
1330
|
+
};
|
|
1331
|
+
var intro = (o2 = "", t2) => {
|
|
1332
|
+
const i = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_START)} ` : "";
|
|
1333
|
+
i.write(`${e}${o2}
|
|
1334
|
+
`);
|
|
1335
|
+
};
|
|
1336
|
+
var outro = (o2 = "", t2) => {
|
|
1337
|
+
const i = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR)}
|
|
1338
|
+
${styleText2("gray", S_BAR_END)} ` : "";
|
|
1339
|
+
i.write(`${e}${o2}
|
|
1340
|
+
|
|
1341
|
+
`);
|
|
1342
|
+
};
|
|
1343
|
+
var u3 = {
|
|
1344
|
+
light: unicodeOr("\u2500", "-"),
|
|
1345
|
+
heavy: unicodeOr("\u2501", "="),
|
|
1346
|
+
block: unicodeOr("\u2588", "#")
|
|
1347
|
+
};
|
|
1348
|
+
var SELECT_INSTRUCTIONS = [
|
|
1349
|
+
`${styleText2("dim", "\u2191/\u2193")} to navigate`,
|
|
1350
|
+
`${styleText2("dim", "Enter:")} confirm`
|
|
1351
|
+
];
|
|
1352
|
+
var c2 = (t2, a2) => t2.includes(`
|
|
1353
|
+
`) ? t2.split(`
|
|
1354
|
+
`).map((i) => a2(i)).join(`
|
|
1355
|
+
`) : a2(t2);
|
|
1356
|
+
var select = (t2) => {
|
|
1357
|
+
const a2 = (i, m2) => {
|
|
1358
|
+
const s = i.label ?? String(i.value);
|
|
1359
|
+
switch (m2) {
|
|
1360
|
+
case "disabled":
|
|
1361
|
+
return `${styleText2("gray", S_RADIO_INACTIVE)} ${c2(s, (n2) => styleText2("gray", n2))}${i.hint ? ` ${styleText2("dim", `(${i.hint ?? "disabled"})`)}` : ""}`;
|
|
1362
|
+
case "selected":
|
|
1363
|
+
return `${c2(s, (n2) => styleText2("dim", n2))}`;
|
|
1364
|
+
case "active":
|
|
1365
|
+
return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${i.hint ? ` ${styleText2("dim", `(${i.hint})`)}` : ""}`;
|
|
1366
|
+
case "cancelled":
|
|
1367
|
+
return `${c2(s, (n2) => styleText2(["strikethrough", "dim"], n2))}`;
|
|
1368
|
+
default:
|
|
1369
|
+
return `${styleText2("dim", S_RADIO_INACTIVE)} ${c2(s, (n2) => styleText2("dim", n2))}`;
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
return new a({
|
|
1373
|
+
options: t2.options,
|
|
1374
|
+
signal: t2.signal,
|
|
1375
|
+
input: t2.input,
|
|
1376
|
+
output: t2.output,
|
|
1377
|
+
initialValue: t2.initialValue,
|
|
1378
|
+
render() {
|
|
1379
|
+
const i = t2.withGuide ?? settings.withGuide, m2 = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, n2 = wrapTextWithPrefix(t2.output, t2.message, s, m2), u4 = `${i ? `${styleText2("gray", S_BAR)}
|
|
1380
|
+
` : ""}${n2}
|
|
1381
|
+
`;
|
|
1382
|
+
switch (this.state) {
|
|
1383
|
+
case "submit": {
|
|
1384
|
+
const r2 = i ? `${styleText2("gray", S_BAR)} ` : "", o2 = wrapTextWithPrefix(t2.output, a2(this.options[this.cursor], "selected"), r2);
|
|
1385
|
+
return `${u4}${o2}`;
|
|
1386
|
+
}
|
|
1387
|
+
case "cancel": {
|
|
1388
|
+
const r2 = i ? `${styleText2("gray", S_BAR)} ` : "", o2 = wrapTextWithPrefix(t2.output, a2(this.options[this.cursor], "cancelled"), r2);
|
|
1389
|
+
return `${u4}${o2}${i ? `
|
|
1390
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1391
|
+
}
|
|
1392
|
+
default: {
|
|
1393
|
+
const r2 = i ? `${styleText2("cyan", S_BAR)} ` : "", o2 = u4.split(`
|
|
1394
|
+
`).length, $ = formatInstructionFooter(SELECT_INSTRUCTIONS, i), h2 = $.join(`
|
|
1395
|
+
`), b2 = $.length + 1;
|
|
1396
|
+
return `${u4}${r2}${limitOptions({
|
|
1397
|
+
output: t2.output,
|
|
1398
|
+
cursor: this.cursor,
|
|
1399
|
+
options: this.options,
|
|
1400
|
+
maxItems: t2.maxItems,
|
|
1401
|
+
columnPadding: r2.length,
|
|
1402
|
+
rowPadding: o2 + b2,
|
|
1403
|
+
style: (p2, x) => a2(p2, p2.disabled ? "disabled" : x ? "active" : "inactive")
|
|
1404
|
+
}).join(`
|
|
1405
|
+
${r2}`)}
|
|
1406
|
+
${h2}
|
|
1407
|
+
`;
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
}).prompt();
|
|
1412
|
+
};
|
|
1413
|
+
var i = `${styleText2("gray", S_BAR)} `;
|
|
1414
|
+
var text = (t2) => new n({
|
|
1415
|
+
validate: t2.validate,
|
|
1416
|
+
placeholder: t2.placeholder,
|
|
1417
|
+
defaultValue: t2.defaultValue,
|
|
1418
|
+
initialValue: t2.initialValue,
|
|
1419
|
+
output: t2.output,
|
|
1420
|
+
signal: t2.signal,
|
|
1421
|
+
input: t2.input,
|
|
1422
|
+
render() {
|
|
1423
|
+
const i2 = t2?.withGuide ?? settings.withGuide, s = `${`${i2 ? `${styleText2("gray", S_BAR)}
|
|
1424
|
+
` : ""}${symbol(this.state)} `}${t2.message}
|
|
1425
|
+
`, c3 = t2.placeholder ? styleText2("inverse", t2.placeholder[0]) + styleText2("dim", t2.placeholder.slice(1)) : styleText2(["inverse", "hidden"], "_"), o2 = this.userInput ? this.userInputWithCursor : c3, a2 = this.value ?? "";
|
|
1426
|
+
switch (this.state) {
|
|
1427
|
+
case "error": {
|
|
1428
|
+
const n2 = this.error ? ` ${styleText2("yellow", this.error)}` : "", r2 = i2 ? `${styleText2("yellow", S_BAR)} ` : "", d = i2 ? styleText2("yellow", S_BAR_END) : "";
|
|
1429
|
+
return `${s.trim()}
|
|
1430
|
+
${r2}${o2}
|
|
1431
|
+
${d}${n2}
|
|
1432
|
+
`;
|
|
1433
|
+
}
|
|
1434
|
+
case "submit": {
|
|
1435
|
+
const n2 = a2 ? ` ${styleText2("dim", a2)}` : "", r2 = i2 ? styleText2("gray", S_BAR) : "";
|
|
1436
|
+
return `${s}${r2}${n2}`;
|
|
1437
|
+
}
|
|
1438
|
+
case "cancel": {
|
|
1439
|
+
const n2 = a2 ? ` ${styleText2(["strikethrough", "dim"], a2)}` : "", r2 = i2 ? styleText2("gray", S_BAR) : "";
|
|
1440
|
+
return `${s}${r2}${n2}${a2.trim() ? `
|
|
1441
|
+
${r2}` : ""}`;
|
|
1442
|
+
}
|
|
1443
|
+
default: {
|
|
1444
|
+
const n2 = i2 ? `${styleText2("cyan", S_BAR)} ` : "", r2 = i2 ? styleText2("cyan", S_BAR_END) : "";
|
|
1445
|
+
return `${s}${n2}${o2}
|
|
1446
|
+
${r2}
|
|
1447
|
+
`;
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
}).prompt();
|
|
1452
|
+
|
|
1453
|
+
// src/index.ts
|
|
1454
|
+
import path from "path";
|
|
1455
|
+
intro("\xA1Bienvenido a Raman.js! Tu builder personal.");
|
|
1456
|
+
var project = await group({
|
|
1457
|
+
name: () => text({
|
|
1458
|
+
message: "\xBFC\xF3mo se llama tu proyecto?",
|
|
1459
|
+
placeholder: "mi-app-raman",
|
|
1460
|
+
defaultValue: "mi-app-raman"
|
|
1461
|
+
}),
|
|
1462
|
+
framework: () => select({
|
|
1463
|
+
message: "\xBFQu\xE9 prefieres usar?",
|
|
1464
|
+
initialValue: "tsx",
|
|
1465
|
+
options: [
|
|
1466
|
+
{ value: "tsx", label: "TypeScript (.tsx)" },
|
|
1467
|
+
{ value: "jsx", label: "JavaScript (.jsx)" }
|
|
1468
|
+
]
|
|
1469
|
+
})
|
|
1470
|
+
});
|
|
1471
|
+
if (isCancel(project)) {
|
|
1472
|
+
cancel("Operaci\xF3n cancelada.");
|
|
1473
|
+
process.exit(0);
|
|
1474
|
+
}
|
|
1475
|
+
var targetDir = path.resolve(process.cwd(), project.name);
|
|
1476
|
+
var ext = project.framework;
|
|
1477
|
+
var userPkg = {
|
|
1478
|
+
name: project.name,
|
|
1479
|
+
version: "0.0.1",
|
|
1480
|
+
scripts: {
|
|
1481
|
+
dev: "raman.js dev",
|
|
1482
|
+
build: "raman.js build"
|
|
1483
|
+
}
|
|
1484
|
+
};
|
|
1485
|
+
await Bun.write(`${targetDir}/package.json`, JSON.stringify(userPkg, null, 2));
|
|
1486
|
+
var template = `<div>
|
|
1487
|
+
<h1>Hola desde Raman.js</h1>
|
|
1488
|
+
<button click="alert('Hola')">Saludar</button>
|
|
1489
|
+
</div>`;
|
|
1490
|
+
await Bun.write(`${targetDir}/src/index.${ext}`, template);
|
|
1491
|
+
outro(`Proyecto creado en ./${project.name}. \xA1Listo para programar!`);
|