create-vue 3.22.2 → 3.22.4
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 +89 -0
- package/bundle.js +1545 -1663
- package/package.json +9 -10
- package/template/base/package.json +5 -5
- package/template/base/vite.config.js.ejs +1 -1
- package/template/config/cypress/package.json +2 -2
- package/template/config/cypress-ct/package.json +2 -2
- package/template/config/jsx/package.json +2 -2
- package/template/config/pinia/package.json +1 -1
- package/template/config/playwright/package.json +1 -1
- package/template/config/router/package.json +2 -2
- package/template/config/typescript/package.json +3 -3
- package/template/config/vitest/package.json +4 -4
- package/template/formatting/oxfmt/package.json +1 -1
- package/template/formatting/prettier/package.json +1 -1
- package/template/linting/base/package.json +3 -2
- package/template/linting/core/js/package.json +3 -3
- package/template/linting/core/ts/package.json +4 -4
- package/template/linting/cypress/package.json +1 -1
- package/template/linting/oxlint/package.json +4 -4
- package/template/linting/playwright/package.json +1 -1
- package/template/linting/vitest/package.json +1 -1
- package/template/tsconfig/cypress/cypress/tsconfig.json +1 -5
- package/template/tsconfig/vitest/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -1,42 +1,300 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/*! create-vue v3.22.
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import "node:
|
|
6
|
-
import
|
|
7
|
-
import "node:path";
|
|
2
|
+
/*! create-vue v3.22.4 | MIT */
|
|
3
|
+
import * as fs$1 from "node:fs";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import * as path$2 from "node:path";
|
|
6
|
+
import path from "node:path";
|
|
8
7
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
9
|
-
import { parseArgs,
|
|
10
|
-
import
|
|
11
|
-
import "node:readline";
|
|
12
|
-
import
|
|
13
|
-
import "node:tty";
|
|
14
|
-
import * as path from "path";
|
|
8
|
+
import { parseArgs, styleText } from "node:util";
|
|
9
|
+
import process$1, { stdin, stdout } from "node:process";
|
|
10
|
+
import l__default from "node:readline";
|
|
11
|
+
import * as path$1 from "path";
|
|
15
12
|
//#region \0rolldown/runtime.js
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
16
|
+
const getCodePointsLength = (() => {
|
|
17
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
18
|
+
return (input) => {
|
|
19
|
+
let surrogatePairsNr = 0;
|
|
20
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
21
|
+
while (SURROGATE_PAIR_RE.test(input)) surrogatePairsNr += 1;
|
|
22
|
+
return input.length - surrogatePairsNr;
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
const isFullWidth = (x) => {
|
|
26
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
27
|
+
};
|
|
28
|
+
const isWideNotCJKTNotEmoji = (x) => {
|
|
29
|
+
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;
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
|
|
33
|
+
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
34
|
+
const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
35
|
+
const CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy;
|
|
36
|
+
const TAB_RE = /\t{1,1000}/y;
|
|
37
|
+
const 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?))*/uy;
|
|
38
|
+
const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
39
|
+
const MODIFIER_RE = /\p{M}+/gu;
|
|
40
|
+
const NO_TRUNCATION$1 = {
|
|
41
|
+
limit: Infinity,
|
|
42
|
+
ellipsis: ""
|
|
43
|
+
};
|
|
44
|
+
const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
45
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
46
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
47
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
|
|
48
|
+
const ANSI_WIDTH = 0;
|
|
49
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
50
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
51
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
52
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
53
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
54
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
55
|
+
const PARSE_BLOCKS = [
|
|
56
|
+
[LATIN_RE, REGULAR_WIDTH],
|
|
57
|
+
[ANSI_RE, ANSI_WIDTH],
|
|
58
|
+
[CONTROL_RE, CONTROL_WIDTH],
|
|
59
|
+
[TAB_RE, TAB_WIDTH],
|
|
60
|
+
[EMOJI_RE, EMOJI_WIDTH],
|
|
61
|
+
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
62
|
+
];
|
|
63
|
+
let indexPrev = 0;
|
|
64
|
+
let index = 0;
|
|
65
|
+
let length = input.length;
|
|
66
|
+
let lengthExtra = 0;
|
|
67
|
+
let truncationEnabled = false;
|
|
68
|
+
let truncationIndex = length;
|
|
69
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
70
|
+
let unmatchedStart = 0;
|
|
71
|
+
let unmatchedEnd = 0;
|
|
72
|
+
let width = 0;
|
|
73
|
+
let widthExtra = 0;
|
|
74
|
+
outer: while (true) {
|
|
75
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
76
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
77
|
+
lengthExtra = 0;
|
|
78
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
79
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
80
|
+
if (isFullWidth(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
|
|
81
|
+
else if (isWideNotCJKTNotEmoji(codePoint)) widthExtra = WIDE_WIDTH;
|
|
82
|
+
else widthExtra = REGULAR_WIDTH;
|
|
83
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
84
|
+
if (width + widthExtra > LIMIT) {
|
|
85
|
+
truncationEnabled = true;
|
|
86
|
+
break outer;
|
|
87
|
+
}
|
|
88
|
+
lengthExtra += char.length;
|
|
89
|
+
width += widthExtra;
|
|
90
|
+
}
|
|
91
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
92
|
+
}
|
|
93
|
+
if (index >= length) break outer;
|
|
94
|
+
for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
|
|
95
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
96
|
+
BLOCK_RE.lastIndex = index;
|
|
97
|
+
if (BLOCK_RE.test(input)) {
|
|
98
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
99
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
100
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
101
|
+
if (width + widthExtra > LIMIT) {
|
|
102
|
+
truncationEnabled = true;
|
|
103
|
+
break outer;
|
|
104
|
+
}
|
|
105
|
+
width += widthExtra;
|
|
106
|
+
unmatchedStart = indexPrev;
|
|
107
|
+
unmatchedEnd = index;
|
|
108
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
109
|
+
continue outer;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
index += 1;
|
|
30
113
|
}
|
|
31
|
-
return
|
|
114
|
+
return {
|
|
115
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
116
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
117
|
+
truncated: truncationEnabled,
|
|
118
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
|
|
123
|
+
const NO_TRUNCATION = {
|
|
124
|
+
limit: Infinity,
|
|
125
|
+
ellipsis: "",
|
|
126
|
+
ellipsisWidth: 0
|
|
127
|
+
};
|
|
128
|
+
const fastStringWidth = (input, options = {}) => {
|
|
129
|
+
return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
|
|
130
|
+
};
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region node_modules/.pnpm/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js
|
|
133
|
+
const ESC = "\x1B";
|
|
134
|
+
const CSI = "";
|
|
135
|
+
const END_CODE = 39;
|
|
136
|
+
const ANSI_ESCAPE_BELL = "\x07";
|
|
137
|
+
const ANSI_CSI = "[";
|
|
138
|
+
const ANSI_OSC = "]";
|
|
139
|
+
const ANSI_SGR_TERMINATOR = "m";
|
|
140
|
+
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
141
|
+
const GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
142
|
+
const getClosingCode = (openingCode) => {
|
|
143
|
+
if (openingCode >= 30 && openingCode <= 37) return 39;
|
|
144
|
+
if (openingCode >= 90 && openingCode <= 97) return 39;
|
|
145
|
+
if (openingCode >= 40 && openingCode <= 47) return 49;
|
|
146
|
+
if (openingCode >= 100 && openingCode <= 107) return 49;
|
|
147
|
+
if (openingCode === 1 || openingCode === 2) return 22;
|
|
148
|
+
if (openingCode === 3) return 23;
|
|
149
|
+
if (openingCode === 4) return 24;
|
|
150
|
+
if (openingCode === 7) return 27;
|
|
151
|
+
if (openingCode === 8) return 28;
|
|
152
|
+
if (openingCode === 9) return 29;
|
|
153
|
+
if (openingCode === 0) return 0;
|
|
154
|
+
};
|
|
155
|
+
const wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
156
|
+
const wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
157
|
+
const wrapWord = (rows, word, columns) => {
|
|
158
|
+
const characters = word[Symbol.iterator]();
|
|
159
|
+
let isInsideEscape = false;
|
|
160
|
+
let isInsideLinkEscape = false;
|
|
161
|
+
let lastRow = rows.at(-1);
|
|
162
|
+
let visible = lastRow === void 0 ? 0 : fastStringWidth(lastRow);
|
|
163
|
+
let currentCharacter = characters.next();
|
|
164
|
+
let nextCharacter = characters.next();
|
|
165
|
+
let rawCharacterIndex = 0;
|
|
166
|
+
while (!currentCharacter.done) {
|
|
167
|
+
const character = currentCharacter.value;
|
|
168
|
+
const characterLength = fastStringWidth(character);
|
|
169
|
+
if (visible + characterLength <= columns) rows[rows.length - 1] += character;
|
|
170
|
+
else {
|
|
171
|
+
rows.push(character);
|
|
172
|
+
visible = 0;
|
|
173
|
+
}
|
|
174
|
+
if (character === ESC || character === CSI) {
|
|
175
|
+
isInsideEscape = true;
|
|
176
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
177
|
+
}
|
|
178
|
+
if (isInsideEscape) {
|
|
179
|
+
if (isInsideLinkEscape) {
|
|
180
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
181
|
+
isInsideEscape = false;
|
|
182
|
+
isInsideLinkEscape = false;
|
|
183
|
+
}
|
|
184
|
+
} else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
|
|
185
|
+
} else {
|
|
186
|
+
visible += characterLength;
|
|
187
|
+
if (visible === columns && !nextCharacter.done) {
|
|
188
|
+
rows.push("");
|
|
189
|
+
visible = 0;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
currentCharacter = nextCharacter;
|
|
193
|
+
nextCharacter = characters.next();
|
|
194
|
+
rawCharacterIndex += character.length;
|
|
195
|
+
}
|
|
196
|
+
lastRow = rows.at(-1);
|
|
197
|
+
if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) rows[rows.length - 2] += rows.pop();
|
|
198
|
+
};
|
|
199
|
+
const stringVisibleTrimSpacesRight = (string) => {
|
|
200
|
+
const words = string.split(" ");
|
|
201
|
+
let last = words.length;
|
|
202
|
+
while (last) {
|
|
203
|
+
if (fastStringWidth(words[last - 1])) break;
|
|
204
|
+
last--;
|
|
205
|
+
}
|
|
206
|
+
if (last === words.length) return string;
|
|
207
|
+
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
208
|
+
};
|
|
209
|
+
const exec = (string, columns, options = {}) => {
|
|
210
|
+
if (options.trim !== false && string.trim() === "") return "";
|
|
211
|
+
let returnValue = "";
|
|
212
|
+
let escapeCode;
|
|
213
|
+
let escapeUrl;
|
|
214
|
+
const words = string.split(" ");
|
|
215
|
+
let rows = [""];
|
|
216
|
+
let rowLength = 0;
|
|
217
|
+
for (let index = 0; index < words.length; index++) {
|
|
218
|
+
const word = words[index];
|
|
219
|
+
if (options.trim !== false) {
|
|
220
|
+
const row = rows.at(-1) ?? "";
|
|
221
|
+
const trimmed = row.trimStart();
|
|
222
|
+
if (row.length !== trimmed.length) {
|
|
223
|
+
rows[rows.length - 1] = trimmed;
|
|
224
|
+
rowLength = fastStringWidth(trimmed);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (index !== 0) {
|
|
228
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
229
|
+
rows.push("");
|
|
230
|
+
rowLength = 0;
|
|
231
|
+
}
|
|
232
|
+
if (rowLength || options.trim === false) {
|
|
233
|
+
rows[rows.length - 1] += " ";
|
|
234
|
+
rowLength++;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const wordLength = fastStringWidth(word);
|
|
238
|
+
if (options.hard && wordLength > columns) {
|
|
239
|
+
const remainingColumns = columns - rowLength;
|
|
240
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
241
|
+
if (Math.floor((wordLength - 1) / columns) < breaksStartingThisLine) rows.push("");
|
|
242
|
+
wrapWord(rows, word, columns);
|
|
243
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
247
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
248
|
+
wrapWord(rows, word, columns);
|
|
249
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
rows.push("");
|
|
253
|
+
rowLength = 0;
|
|
254
|
+
}
|
|
255
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
256
|
+
wrapWord(rows, word, columns);
|
|
257
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
rows[rows.length - 1] += word;
|
|
261
|
+
rowLength += wordLength;
|
|
262
|
+
}
|
|
263
|
+
if (options.trim !== false) rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
264
|
+
const preString = rows.join("\n");
|
|
265
|
+
let inSurrogate = false;
|
|
266
|
+
for (let i = 0; i < preString.length; i++) {
|
|
267
|
+
const character = preString[i];
|
|
268
|
+
returnValue += character;
|
|
269
|
+
if (!inSurrogate) {
|
|
270
|
+
inSurrogate = character >= "\ud800" && character <= "\udbff";
|
|
271
|
+
if (inSurrogate) continue;
|
|
272
|
+
} else inSurrogate = false;
|
|
273
|
+
if (character === ESC || character === CSI) {
|
|
274
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
275
|
+
const groups = GROUP_REGEX.exec(preString)?.groups;
|
|
276
|
+
if (groups?.code !== void 0) {
|
|
277
|
+
const code = Number.parseFloat(groups.code);
|
|
278
|
+
escapeCode = code === END_CODE ? void 0 : code;
|
|
279
|
+
} else if (groups?.uri !== void 0) escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
280
|
+
}
|
|
281
|
+
if (preString[i + 1] === "\n") {
|
|
282
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink("");
|
|
283
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
284
|
+
if (escapeCode && closingCode) returnValue += wrapAnsiCode(closingCode);
|
|
285
|
+
} else if (character === "\n") {
|
|
286
|
+
if (escapeCode && getClosingCode(escapeCode)) returnValue += wrapAnsiCode(escapeCode);
|
|
287
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return returnValue;
|
|
32
291
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
292
|
+
const CRLF_OR_LF = /\r?\n/;
|
|
293
|
+
function wrapAnsi(string, columns, options) {
|
|
294
|
+
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
295
|
+
}
|
|
38
296
|
//#endregion
|
|
39
|
-
//#region node_modules/.pnpm/@clack+core@1.1
|
|
297
|
+
//#region node_modules/.pnpm/@clack+core@1.4.1/node_modules/@clack/core/dist/index.mjs
|
|
40
298
|
var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
41
299
|
const ESC = "\x1B";
|
|
42
300
|
const CSI = `${ESC}[`;
|
|
@@ -89,162 +347,12 @@ var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
89
347
|
beep
|
|
90
348
|
};
|
|
91
349
|
})))();
|
|
92
|
-
function
|
|
93
|
-
if (!
|
|
94
|
-
const
|
|
95
|
-
return
|
|
96
|
-
}
|
|
97
|
-
const at = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109, lt = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, ht = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141, O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, L = /\t{1,1000}/y, P = /[\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?))*/uy, M = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ct = /\p{M}+/gu, ft$1 = {
|
|
98
|
-
limit: Infinity,
|
|
99
|
-
ellipsis: ""
|
|
100
|
-
}, X$1 = (t, e = {}, s = {}) => {
|
|
101
|
-
const i = e.limit ?? Infinity, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X$1(r, ft$1, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V = s.wideWidth ?? 2;
|
|
102
|
-
let h = 0, o = 0, p = t.length, v = 0, F = !1, d = p, b = Math.max(0, i - n), C = 0, w = 0, c = 0, f = 0;
|
|
103
|
-
t: for (;;) {
|
|
104
|
-
if (w > C || o >= p && o > h) {
|
|
105
|
-
const ut = t.slice(C, w) || t.slice(h, o);
|
|
106
|
-
v = 0;
|
|
107
|
-
for (const Y of ut.replaceAll(ct, "")) {
|
|
108
|
-
const $ = Y.codePointAt(0) || 0;
|
|
109
|
-
if (lt($) ? f = m : ht($) ? f = V : E !== A && at($) ? f = E : f = A, c + f > b && (d = Math.min(d, Math.max(C, h) + v)), c + f > i) {
|
|
110
|
-
F = !0;
|
|
111
|
-
break t;
|
|
112
|
-
}
|
|
113
|
-
v += Y.length, c += f;
|
|
114
|
-
}
|
|
115
|
-
C = w = 0;
|
|
116
|
-
}
|
|
117
|
-
if (o >= p) break;
|
|
118
|
-
if (M.lastIndex = o, M.test(t)) {
|
|
119
|
-
if (v = M.lastIndex - o, f = v * A, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + f > i) {
|
|
120
|
-
F = !0;
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
c += f, C = h, w = o, o = h = M.lastIndex;
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
if (O.lastIndex = o, O.test(t)) {
|
|
127
|
-
if (c + u > b && (d = Math.min(d, o)), c + u > i) {
|
|
128
|
-
F = !0;
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
c += u, C = h, w = o, o = h = O.lastIndex;
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
if (y.lastIndex = o, y.test(t)) {
|
|
135
|
-
if (v = y.lastIndex - o, f = v * a, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + f > i) {
|
|
136
|
-
F = !0;
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
c += f, C = h, w = o, o = h = y.lastIndex;
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
if (L.lastIndex = o, L.test(t)) {
|
|
143
|
-
if (v = L.lastIndex - o, f = v * l, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + f > i) {
|
|
144
|
-
F = !0;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
c += f, C = h, w = o, o = h = L.lastIndex;
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (P.lastIndex = o, P.test(t)) {
|
|
151
|
-
if (c + g > b && (d = Math.min(d, o)), c + g > i) {
|
|
152
|
-
F = !0;
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
c += g, C = h, w = o, o = h = P.lastIndex;
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
o += 1;
|
|
159
|
-
}
|
|
160
|
-
return {
|
|
161
|
-
width: F ? b : c,
|
|
162
|
-
index: F ? d : p,
|
|
163
|
-
truncated: F,
|
|
164
|
-
ellipsed: F && i >= n
|
|
165
|
-
};
|
|
166
|
-
}, pt$1 = {
|
|
167
|
-
limit: Infinity,
|
|
168
|
-
ellipsis: "",
|
|
169
|
-
ellipsisWidth: 0
|
|
170
|
-
}, S = (t, e = {}) => X$1(t, pt$1, e).width, T = "\x1B", Z = "", Ft$1 = 39, j = "\x07", Q$1 = "[", dt = "]", tt = "m", U$1 = `${dt}8;;`, et = new RegExp(`(?:\\${Q$1}(?<code>\\d+)m|\\${U$1}(?<uri>.*)${j})`, "y"), mt$1 = (t) => {
|
|
171
|
-
if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
|
|
172
|
-
if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
|
|
173
|
-
if (t === 1 || t === 2) return 22;
|
|
174
|
-
if (t === 3) return 23;
|
|
175
|
-
if (t === 4) return 24;
|
|
176
|
-
if (t === 7) return 27;
|
|
177
|
-
if (t === 8) return 28;
|
|
178
|
-
if (t === 9) return 29;
|
|
179
|
-
if (t === 0) return 0;
|
|
180
|
-
}, st = (t) => `${T}${Q$1}${t}${tt}`, it = (t) => `${T}${U$1}${t}${j}`, gt$1 = (t) => t.map((e) => S(e)), G = (t, e, s) => {
|
|
181
|
-
const i = e[Symbol.iterator]();
|
|
182
|
-
let r = !1, n = !1, u = t.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
|
|
183
|
-
for (; !l.done;) {
|
|
184
|
-
const m = l.value, A = S(m);
|
|
185
|
-
a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === T || m === Z) && (r = !0, n = e.startsWith(U$1, g + 1)), r ? n ? m === j && (r = !1, n = !1) : m === tt && (r = !1) : (a += A, a === s && !E.done && (t.push(""), a = 0)), l = E, E = i.next(), g += m.length;
|
|
186
|
-
}
|
|
187
|
-
u = t.at(-1), !a && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
188
|
-
}, vt$1 = (t) => {
|
|
189
|
-
const e = t.split(" ");
|
|
190
|
-
let s = e.length;
|
|
191
|
-
for (; s > 0 && !(S(e[s - 1]) > 0);) s--;
|
|
192
|
-
return s === e.length ? t : e.slice(0, s).join(" ") + e.slice(s).join("");
|
|
193
|
-
}, Et$1 = (t, e, s = {}) => {
|
|
194
|
-
if (s.trim !== !1 && t.trim() === "") return "";
|
|
195
|
-
let i = "", r, n;
|
|
196
|
-
const u = t.split(" "), a = gt$1(u);
|
|
197
|
-
let l = [""];
|
|
198
|
-
for (const [h, o] of u.entries()) {
|
|
199
|
-
s.trim !== !1 && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
|
|
200
|
-
let p = S(l.at(-1) ?? "");
|
|
201
|
-
if (h !== 0 && (p >= e && (s.wordWrap === !1 || s.trim === !1) && (l.push(""), p = 0), (p > 0 || s.trim === !1) && (l[l.length - 1] += " ", p++)), s.hard && a[h] > e) {
|
|
202
|
-
const v = e - p, F = 1 + Math.floor((a[h] - v - 1) / e);
|
|
203
|
-
Math.floor((a[h] - 1) / e) < F && l.push(""), G(l, o, e);
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
if (p + a[h] > e && p > 0 && a[h] > 0) {
|
|
207
|
-
if (s.wordWrap === !1 && p < e) {
|
|
208
|
-
G(l, o, e);
|
|
209
|
-
continue;
|
|
210
|
-
}
|
|
211
|
-
l.push("");
|
|
212
|
-
}
|
|
213
|
-
if (p + a[h] > e && s.wordWrap === !1) {
|
|
214
|
-
G(l, o, e);
|
|
215
|
-
continue;
|
|
216
|
-
}
|
|
217
|
-
l[l.length - 1] += o;
|
|
218
|
-
}
|
|
219
|
-
s.trim !== !1 && (l = l.map((h) => vt$1(h)));
|
|
220
|
-
const E = l.join(`
|
|
221
|
-
`), g = E[Symbol.iterator]();
|
|
222
|
-
let m = g.next(), A = g.next(), V = 0;
|
|
223
|
-
for (; !m.done;) {
|
|
224
|
-
const h = m.value, o = A.value;
|
|
225
|
-
if (i += h, h === T || h === Z) {
|
|
226
|
-
et.lastIndex = V + 1;
|
|
227
|
-
const F = et.exec(E)?.groups;
|
|
228
|
-
if (F?.code !== void 0) {
|
|
229
|
-
const d = Number.parseFloat(F.code);
|
|
230
|
-
r = d === Ft$1 ? void 0 : d;
|
|
231
|
-
} else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
|
|
232
|
-
}
|
|
233
|
-
const p = r ? mt$1(r) : void 0;
|
|
234
|
-
o === `
|
|
235
|
-
` ? (n && (i += it("")), r && p && (i += st(p))) : h === `
|
|
236
|
-
` && (r && p && (i += st(r)), n && (i += it(n))), V += h.length, m = A, A = g.next();
|
|
237
|
-
}
|
|
238
|
-
return i;
|
|
239
|
-
};
|
|
240
|
-
function K$1(t, e, s) {
|
|
241
|
-
return String(t).normalize().replaceAll(`\r
|
|
242
|
-
`, `
|
|
243
|
-
`).split(`
|
|
244
|
-
`).map((i) => Et$1(i, e, s)).join(`
|
|
245
|
-
`);
|
|
350
|
+
function findCursor(s, o, l) {
|
|
351
|
+
if (!l.some((r) => !r.disabled)) return s;
|
|
352
|
+
const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
|
|
353
|
+
return l[e].disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
|
|
246
354
|
}
|
|
247
|
-
const
|
|
355
|
+
const settings = {
|
|
248
356
|
actions: new Set([
|
|
249
357
|
"up",
|
|
250
358
|
"down",
|
|
@@ -254,7 +362,7 @@ const _ = {
|
|
|
254
362
|
"enter",
|
|
255
363
|
"cancel"
|
|
256
364
|
]),
|
|
257
|
-
aliases: new Map([
|
|
365
|
+
aliases: /* @__PURE__ */ new Map([
|
|
258
366
|
["k", "up"],
|
|
259
367
|
["j", "down"],
|
|
260
368
|
["h", "left"],
|
|
@@ -266,52 +374,86 @@ const _ = {
|
|
|
266
374
|
cancel: "Canceled",
|
|
267
375
|
error: "Something went wrong"
|
|
268
376
|
},
|
|
269
|
-
withGuide:
|
|
377
|
+
withGuide: true,
|
|
378
|
+
date: {
|
|
379
|
+
monthNames: [...[
|
|
380
|
+
"January",
|
|
381
|
+
"February",
|
|
382
|
+
"March",
|
|
383
|
+
"April",
|
|
384
|
+
"May",
|
|
385
|
+
"June",
|
|
386
|
+
"July",
|
|
387
|
+
"August",
|
|
388
|
+
"September",
|
|
389
|
+
"October",
|
|
390
|
+
"November",
|
|
391
|
+
"December"
|
|
392
|
+
]],
|
|
393
|
+
messages: {
|
|
394
|
+
required: "Please enter a valid date",
|
|
395
|
+
invalidMonth: "There are only 12 months in a year",
|
|
396
|
+
invalidDay: (n, e) => `There are only ${n} days in ${e}`,
|
|
397
|
+
afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
|
|
398
|
+
beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
|
|
399
|
+
}
|
|
400
|
+
}
|
|
270
401
|
};
|
|
271
|
-
function
|
|
272
|
-
if (typeof
|
|
273
|
-
for (const s of
|
|
274
|
-
return
|
|
402
|
+
function isActionKey(n, e) {
|
|
403
|
+
if (typeof n == "string") return settings.aliases.get(n) === e;
|
|
404
|
+
for (const s of n) if (s !== void 0 && isActionKey(s, e)) return true;
|
|
405
|
+
return false;
|
|
275
406
|
}
|
|
276
|
-
function
|
|
277
|
-
if (
|
|
278
|
-
const
|
|
279
|
-
`),
|
|
280
|
-
`), r = Math.max(
|
|
281
|
-
for (let
|
|
407
|
+
function diffLines(i, s) {
|
|
408
|
+
if (i === s) return;
|
|
409
|
+
const e = i.split(`
|
|
410
|
+
`), t = s.split(`
|
|
411
|
+
`), r = Math.max(e.length, t.length), f = [];
|
|
412
|
+
for (let n = 0; n < r; n++) e[n] !== t[n] && f.push(n);
|
|
282
413
|
return {
|
|
283
|
-
lines:
|
|
284
|
-
numLinesBefore:
|
|
285
|
-
numLinesAfter:
|
|
414
|
+
lines: f,
|
|
415
|
+
numLinesBefore: e.length,
|
|
416
|
+
numLinesAfter: t.length,
|
|
286
417
|
numLines: r
|
|
287
418
|
};
|
|
288
419
|
}
|
|
289
420
|
globalThis.process.platform.startsWith("win");
|
|
290
|
-
const
|
|
291
|
-
function
|
|
292
|
-
return
|
|
421
|
+
const CANCEL_SYMBOL = Symbol("clack:cancel");
|
|
422
|
+
function isCancel(e) {
|
|
423
|
+
return e === CANCEL_SYMBOL;
|
|
293
424
|
}
|
|
294
|
-
function
|
|
295
|
-
const
|
|
296
|
-
|
|
425
|
+
function setRawMode(e, r) {
|
|
426
|
+
const o = e;
|
|
427
|
+
o.isTTY && o.setRawMode(r);
|
|
297
428
|
}
|
|
298
|
-
const
|
|
299
|
-
function
|
|
300
|
-
return
|
|
301
|
-
hard:
|
|
302
|
-
trim:
|
|
429
|
+
const getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80, getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
|
|
430
|
+
function wrapTextWithPrefix(e, r, o, t = o, s = o, n) {
|
|
431
|
+
return wrapAnsi(r, getColumns(e ?? stdout) - o.length, {
|
|
432
|
+
hard: true,
|
|
433
|
+
trim: false
|
|
303
434
|
}).split(`
|
|
304
|
-
`).map((
|
|
435
|
+
`).map((c, i, m) => {
|
|
436
|
+
const d = n ? n(c, i) : c;
|
|
437
|
+
return i === 0 ? `${t}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
438
|
+
}).join(`
|
|
305
439
|
`);
|
|
306
440
|
}
|
|
307
|
-
|
|
441
|
+
function runValidation(e, n) {
|
|
442
|
+
if ("~standard" in e) {
|
|
443
|
+
const a = e["~standard"].validate(n);
|
|
444
|
+
if (a instanceof Promise) throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
|
|
445
|
+
return a.issues?.at(0)?.message;
|
|
446
|
+
}
|
|
447
|
+
return e(n);
|
|
448
|
+
}
|
|
449
|
+
var V = class {
|
|
308
450
|
input;
|
|
309
451
|
output;
|
|
310
452
|
_abortSignal;
|
|
311
453
|
rl;
|
|
312
454
|
opts;
|
|
313
455
|
_render;
|
|
314
|
-
_track =
|
|
456
|
+
_track = false;
|
|
315
457
|
_prevFrame = "";
|
|
316
458
|
_subscribers = /* @__PURE__ */ new Map();
|
|
317
459
|
_cursor = 0;
|
|
@@ -319,191 +461,218 @@ var B = class {
|
|
|
319
461
|
error = "";
|
|
320
462
|
value;
|
|
321
463
|
userInput = "";
|
|
322
|
-
constructor(
|
|
323
|
-
const { input: i = stdin, output:
|
|
324
|
-
this.opts =
|
|
464
|
+
constructor(t, e = true) {
|
|
465
|
+
const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t;
|
|
466
|
+
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;
|
|
325
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* Unsubscribe all listeners
|
|
470
|
+
*/
|
|
326
471
|
unsubscribe() {
|
|
327
472
|
this._subscribers.clear();
|
|
328
473
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
474
|
+
/**
|
|
475
|
+
* Set a subscriber with opts
|
|
476
|
+
* @param event - The event name
|
|
477
|
+
*/
|
|
478
|
+
setSubscriber(t, e) {
|
|
479
|
+
const i = this._subscribers.get(t) ?? [];
|
|
480
|
+
i.push(e), this._subscribers.set(t, i);
|
|
332
481
|
}
|
|
333
|
-
|
|
334
|
-
|
|
482
|
+
/**
|
|
483
|
+
* Subscribe to an event
|
|
484
|
+
* @param event - The event name
|
|
485
|
+
* @param cb - The callback
|
|
486
|
+
*/
|
|
487
|
+
on(t, e) {
|
|
488
|
+
this.setSubscriber(t, { cb: e });
|
|
335
489
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
490
|
+
/**
|
|
491
|
+
* Subscribe to an event once
|
|
492
|
+
* @param event - The event name
|
|
493
|
+
* @param cb - The callback
|
|
494
|
+
*/
|
|
495
|
+
once(t, e) {
|
|
496
|
+
this.setSubscriber(t, {
|
|
497
|
+
cb: e,
|
|
498
|
+
once: true
|
|
340
499
|
});
|
|
341
500
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
501
|
+
/**
|
|
502
|
+
* Emit an event with data
|
|
503
|
+
* @param event - The event name
|
|
504
|
+
* @param data - The data to pass to the callback
|
|
505
|
+
*/
|
|
506
|
+
emit(t, ...e) {
|
|
507
|
+
const i = this._subscribers.get(t) ?? [], n = [];
|
|
508
|
+
for (const s of i) s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
|
|
509
|
+
for (const s of n) s();
|
|
346
510
|
}
|
|
347
511
|
prompt() {
|
|
348
|
-
return new Promise((
|
|
512
|
+
return new Promise((t) => {
|
|
349
513
|
if (this._abortSignal) {
|
|
350
|
-
if (this._abortSignal.aborted) return this.state = "cancel", this.close(),
|
|
514
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(CANCEL_SYMBOL);
|
|
351
515
|
this._abortSignal.addEventListener("abort", () => {
|
|
352
516
|
this.state = "cancel", this.close();
|
|
353
|
-
}, { once:
|
|
517
|
+
}, { once: true });
|
|
354
518
|
}
|
|
355
|
-
this.rl =
|
|
519
|
+
this.rl = l__default.createInterface({
|
|
356
520
|
input: this.input,
|
|
357
521
|
tabSize: 2,
|
|
358
522
|
prompt: "",
|
|
359
523
|
escapeCodeTimeout: 50,
|
|
360
|
-
terminal:
|
|
361
|
-
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput,
|
|
362
|
-
this.output.write(import_src.cursor.show), this.output.off("resize", this.render),
|
|
524
|
+
terminal: true
|
|
525
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && 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", () => {
|
|
526
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
|
|
363
527
|
}), this.once("cancel", () => {
|
|
364
|
-
this.output.write(import_src.cursor.show), this.output.off("resize", this.render),
|
|
528
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
|
|
365
529
|
});
|
|
366
530
|
});
|
|
367
531
|
}
|
|
368
|
-
_isActionKey(
|
|
369
|
-
return
|
|
532
|
+
_isActionKey(t, e) {
|
|
533
|
+
return t === " ";
|
|
370
534
|
}
|
|
371
|
-
|
|
372
|
-
|
|
535
|
+
_shouldSubmit(t, e) {
|
|
536
|
+
return true;
|
|
537
|
+
}
|
|
538
|
+
_setValue(t) {
|
|
539
|
+
this.value = t, this.emit("value", this.value);
|
|
373
540
|
}
|
|
374
|
-
_setUserInput(
|
|
375
|
-
this.userInput =
|
|
541
|
+
_setUserInput(t, e) {
|
|
542
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
376
543
|
}
|
|
377
544
|
_clearUserInput() {
|
|
378
545
|
this.rl?.write(null, {
|
|
379
|
-
ctrl:
|
|
546
|
+
ctrl: true,
|
|
380
547
|
name: "u"
|
|
381
548
|
}), this._setUserInput("");
|
|
382
549
|
}
|
|
383
|
-
onKeypress(
|
|
384
|
-
if (this._track &&
|
|
385
|
-
ctrl:
|
|
550
|
+
onKeypress(t, e) {
|
|
551
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, {
|
|
552
|
+
ctrl: true,
|
|
386
553
|
name: "h"
|
|
387
|
-
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"),
|
|
554
|
+
}), 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)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, e), e?.name === "return" && this._shouldSubmit(t, e)) {
|
|
388
555
|
if (this.opts.validate) {
|
|
389
|
-
const i = this.opts.validate
|
|
556
|
+
const i = runValidation(this.opts.validate, this.value);
|
|
390
557
|
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
391
558
|
}
|
|
392
559
|
this.state !== "error" && (this.state = "submit");
|
|
393
560
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
561
|
+
isActionKey([
|
|
562
|
+
t,
|
|
563
|
+
e?.name,
|
|
564
|
+
e?.sequence
|
|
398
565
|
], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
399
566
|
}
|
|
400
567
|
close() {
|
|
401
568
|
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
402
|
-
`),
|
|
569
|
+
`), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
403
570
|
}
|
|
404
571
|
restoreCursor() {
|
|
405
|
-
const
|
|
406
|
-
hard:
|
|
407
|
-
trim:
|
|
572
|
+
const t = wrapAnsi(this._prevFrame, process.stdout.columns, {
|
|
573
|
+
hard: true,
|
|
574
|
+
trim: false
|
|
408
575
|
}).split(`
|
|
409
576
|
`).length - 1;
|
|
410
|
-
this.output.write(import_src.cursor.move(-999,
|
|
577
|
+
this.output.write(import_src.cursor.move(-999, t * -1));
|
|
411
578
|
}
|
|
412
579
|
render() {
|
|
413
|
-
const
|
|
414
|
-
hard:
|
|
415
|
-
trim:
|
|
580
|
+
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
581
|
+
hard: true,
|
|
582
|
+
trim: false
|
|
416
583
|
});
|
|
417
|
-
if (
|
|
584
|
+
if (t !== this._prevFrame) {
|
|
418
585
|
if (this.state === "initial") this.output.write(import_src.cursor.hide);
|
|
419
586
|
else {
|
|
420
|
-
const
|
|
421
|
-
if (this.restoreCursor(),
|
|
422
|
-
const
|
|
423
|
-
let
|
|
424
|
-
if (
|
|
425
|
-
this._prevFrame =
|
|
587
|
+
const e = diffLines(this._prevFrame, t), i = getRows(this.output);
|
|
588
|
+
if (this.restoreCursor(), e) {
|
|
589
|
+
const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
|
|
590
|
+
let r = e.lines.find((o) => o >= n);
|
|
591
|
+
if (r === void 0) {
|
|
592
|
+
this._prevFrame = t;
|
|
426
593
|
return;
|
|
427
594
|
}
|
|
428
|
-
if (
|
|
429
|
-
this.output.write(import_src.cursor.move(0,
|
|
430
|
-
const
|
|
595
|
+
if (e.lines.length === 1) {
|
|
596
|
+
this.output.write(import_src.cursor.move(0, r - s)), this.output.write(import_src.erase.lines(1));
|
|
597
|
+
const o = t.split(`
|
|
431
598
|
`);
|
|
432
|
-
this.output.write(
|
|
599
|
+
this.output.write(o[r]), this._prevFrame = t, this.output.write(import_src.cursor.move(0, o.length - r - 1));
|
|
433
600
|
return;
|
|
434
|
-
} else if (
|
|
435
|
-
if (
|
|
601
|
+
} else if (e.lines.length > 1) {
|
|
602
|
+
if (n < s) r = n;
|
|
436
603
|
else {
|
|
437
|
-
const
|
|
438
|
-
|
|
604
|
+
const h = r - s;
|
|
605
|
+
h > 0 && this.output.write(import_src.cursor.move(0, h));
|
|
439
606
|
}
|
|
440
607
|
this.output.write(import_src.erase.down());
|
|
441
|
-
const
|
|
442
|
-
`).slice(
|
|
443
|
-
this.output.write(
|
|
444
|
-
`)), this._prevFrame =
|
|
608
|
+
const f = t.split(`
|
|
609
|
+
`).slice(r);
|
|
610
|
+
this.output.write(f.join(`
|
|
611
|
+
`)), this._prevFrame = t;
|
|
445
612
|
return;
|
|
446
613
|
}
|
|
447
614
|
}
|
|
448
615
|
this.output.write(import_src.erase.down());
|
|
449
616
|
}
|
|
450
|
-
this.output.write(
|
|
617
|
+
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
451
618
|
}
|
|
452
619
|
}
|
|
453
620
|
};
|
|
454
|
-
var
|
|
621
|
+
var r = class extends V {
|
|
455
622
|
get cursor() {
|
|
456
623
|
return this.value ? 0 : 1;
|
|
457
624
|
}
|
|
458
625
|
get _value() {
|
|
459
626
|
return this.cursor === 0;
|
|
460
627
|
}
|
|
461
|
-
constructor(
|
|
462
|
-
super(
|
|
628
|
+
constructor(t) {
|
|
629
|
+
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
463
630
|
this.value = this._value;
|
|
464
|
-
}), this.on("confirm", (
|
|
465
|
-
this.output.write(import_src.cursor.move(0, -1)), this.value =
|
|
631
|
+
}), this.on("confirm", (i) => {
|
|
632
|
+
this.output.write(import_src.cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
|
|
466
633
|
}), this.on("cursor", () => {
|
|
467
634
|
this.value = !this.value;
|
|
468
635
|
});
|
|
469
636
|
}
|
|
470
637
|
};
|
|
471
|
-
let
|
|
638
|
+
let a$1 = class a extends V {
|
|
472
639
|
options;
|
|
473
640
|
cursor = 0;
|
|
474
641
|
get _value() {
|
|
475
642
|
return this.options[this.cursor].value;
|
|
476
643
|
}
|
|
477
644
|
get _enabledOptions() {
|
|
478
|
-
return this.options.filter((e) => e.disabled !==
|
|
645
|
+
return this.options.filter((e) => e.disabled !== true);
|
|
479
646
|
}
|
|
480
647
|
toggleAll() {
|
|
481
|
-
const e = this._enabledOptions;
|
|
482
|
-
this.value =
|
|
648
|
+
const e = this._enabledOptions, i = this.value !== void 0 && this.value.length === e.length;
|
|
649
|
+
this.value = i ? [] : e.map((t) => t.value);
|
|
483
650
|
}
|
|
484
651
|
toggleInvert() {
|
|
485
652
|
const e = this.value;
|
|
486
653
|
if (!e) return;
|
|
487
|
-
|
|
654
|
+
const i = this._enabledOptions.filter((t) => !e.includes(t.value));
|
|
655
|
+
this.value = i.map((t) => t.value);
|
|
488
656
|
}
|
|
489
657
|
toggleValue() {
|
|
490
658
|
this.value === void 0 && (this.value = []);
|
|
491
|
-
|
|
659
|
+
const e = this.value.includes(this._value);
|
|
660
|
+
this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
|
|
492
661
|
}
|
|
493
662
|
constructor(e) {
|
|
494
|
-
super(e,
|
|
495
|
-
const
|
|
496
|
-
this.cursor = this.options[
|
|
497
|
-
|
|
498
|
-
}), this.on("cursor", (
|
|
499
|
-
switch (
|
|
663
|
+
super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
664
|
+
const i = Math.max(this.options.findIndex(({ value: t }) => t === e.cursorAt), 0);
|
|
665
|
+
this.cursor = this.options[i].disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t, l) => {
|
|
666
|
+
l.name === "a" && this.toggleAll(), l.name === "i" && this.toggleInvert();
|
|
667
|
+
}), this.on("cursor", (t) => {
|
|
668
|
+
switch (t) {
|
|
500
669
|
case "left":
|
|
501
670
|
case "up":
|
|
502
|
-
this.cursor =
|
|
671
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
503
672
|
break;
|
|
504
673
|
case "down":
|
|
505
674
|
case "right":
|
|
506
|
-
this.cursor =
|
|
675
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
507
676
|
break;
|
|
508
677
|
case "space":
|
|
509
678
|
this.toggleValue();
|
|
@@ -512,7 +681,7 @@ let Lt$1 = class extends B {
|
|
|
512
681
|
});
|
|
513
682
|
}
|
|
514
683
|
};
|
|
515
|
-
var
|
|
684
|
+
var a = class extends V {
|
|
516
685
|
options;
|
|
517
686
|
cursor = 0;
|
|
518
687
|
get _selectedValue() {
|
|
@@ -521,372 +690,170 @@ var Tt$1 = class extends B {
|
|
|
521
690
|
changeValue() {
|
|
522
691
|
this.value = this._selectedValue.value;
|
|
523
692
|
}
|
|
524
|
-
constructor(
|
|
525
|
-
super(
|
|
526
|
-
const
|
|
527
|
-
this.cursor = this.options[
|
|
528
|
-
switch (
|
|
693
|
+
constructor(t) {
|
|
694
|
+
super(t, false), this.options = t.options;
|
|
695
|
+
const i = this.options.findIndex(({ value: s }) => s === t.initialValue), e = i === -1 ? 0 : i;
|
|
696
|
+
this.cursor = this.options[e].disabled ? findCursor(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (s) => {
|
|
697
|
+
switch (s) {
|
|
529
698
|
case "left":
|
|
530
699
|
case "up":
|
|
531
|
-
this.cursor =
|
|
700
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
532
701
|
break;
|
|
533
702
|
case "down":
|
|
534
703
|
case "right":
|
|
535
|
-
this.cursor =
|
|
704
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
536
705
|
break;
|
|
537
706
|
}
|
|
538
707
|
this.changeValue();
|
|
539
708
|
});
|
|
540
709
|
}
|
|
541
710
|
};
|
|
542
|
-
var
|
|
711
|
+
var n = class extends V {
|
|
543
712
|
get userInputWithCursor() {
|
|
544
713
|
if (this.state === "submit") return this.userInput;
|
|
545
|
-
const
|
|
546
|
-
if (this.cursor >=
|
|
547
|
-
const
|
|
548
|
-
return `${
|
|
714
|
+
const t = this.userInput;
|
|
715
|
+
if (this.cursor >= t.length) return `${this.userInput}\u2588`;
|
|
716
|
+
const e = t.slice(0, this.cursor), [s, ...r] = t.slice(this.cursor);
|
|
717
|
+
return `${e}${styleText("inverse", s)}${r.join("")}`;
|
|
549
718
|
}
|
|
550
719
|
get cursor() {
|
|
551
720
|
return this._cursor;
|
|
552
721
|
}
|
|
553
|
-
constructor(
|
|
722
|
+
constructor(t) {
|
|
554
723
|
super({
|
|
555
|
-
...
|
|
556
|
-
initialUserInput:
|
|
557
|
-
}), this.on("userInput", (
|
|
558
|
-
this._setValue(
|
|
724
|
+
...t,
|
|
725
|
+
initialUserInput: t.initialUserInput ?? t.initialValue
|
|
726
|
+
}), this.on("userInput", (e) => {
|
|
727
|
+
this._setValue(e);
|
|
559
728
|
}), this.on("finalize", () => {
|
|
560
|
-
this.value || (this.value =
|
|
729
|
+
this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
|
|
561
730
|
});
|
|
562
731
|
}
|
|
563
732
|
};
|
|
564
733
|
//#endregion
|
|
565
|
-
//#region node_modules/.pnpm/@clack+prompts@1.1
|
|
566
|
-
function
|
|
567
|
-
|
|
734
|
+
//#region node_modules/.pnpm/@clack+prompts@1.5.1/node_modules/@clack/prompts/dist/index.mjs
|
|
735
|
+
function isUnicodeSupported() {
|
|
736
|
+
if (process$1.platform !== "win32") return process$1.env.TERM !== "linux";
|
|
737
|
+
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";
|
|
568
738
|
}
|
|
569
|
-
const
|
|
570
|
-
I("┐", "T");
|
|
571
|
-
I("┘", "—");
|
|
572
|
-
const z = I("●", ">"), H = I("○", " "), te = I("◻", "[•]"), U = I("◼", "[+]"), q = I("◻", "[ ]");
|
|
573
|
-
I("▪", "•");
|
|
574
|
-
I("─", "-");
|
|
575
|
-
I("╮", "+");
|
|
576
|
-
I("├", "+");
|
|
577
|
-
I("╯", "+");
|
|
578
|
-
I("╰", "+");
|
|
579
|
-
I("╭", "+");
|
|
580
|
-
const fe = I("●", "•"), Fe = I("◆", "*"), ye = I("▲", "!"), Ee = I("■", "x"), W = (e) => {
|
|
739
|
+
const unicode = isUnicodeSupported(), unicodeOr = (e, o) => unicode ? e : o, S_STEP_ACTIVE = unicodeOr("◆", "*"), S_STEP_CANCEL = unicodeOr("■", "x"), S_STEP_ERROR = unicodeOr("▲", "x"), S_STEP_SUBMIT = unicodeOr("◇", "o"), S_BAR_START = unicodeOr("┌", "T"), S_BAR = unicodeOr("│", "|"), S_BAR_END = unicodeOr("└", "—"), S_RADIO_ACTIVE = unicodeOr("●", ">"), S_RADIO_INACTIVE = unicodeOr("○", " "), S_CHECKBOX_ACTIVE = unicodeOr("◻", "[•]"), S_CHECKBOX_SELECTED = unicodeOr("◼", "[+]"), S_CHECKBOX_INACTIVE = unicodeOr("◻", "[ ]"), symbol = (e) => {
|
|
581
740
|
switch (e) {
|
|
582
741
|
case "initial":
|
|
583
|
-
case "active": return styleText("cyan",
|
|
584
|
-
case "cancel": return styleText("red",
|
|
585
|
-
case "error": return styleText("yellow",
|
|
586
|
-
case "submit": return styleText("green",
|
|
742
|
+
case "active": return styleText("cyan", S_STEP_ACTIVE);
|
|
743
|
+
case "cancel": return styleText("red", S_STEP_CANCEL);
|
|
744
|
+
case "error": return styleText("yellow", S_STEP_ERROR);
|
|
745
|
+
case "submit": return styleText("green", S_STEP_SUBMIT);
|
|
587
746
|
}
|
|
588
|
-
},
|
|
747
|
+
}, symbolBar = (e) => {
|
|
589
748
|
switch (e) {
|
|
590
749
|
case "initial":
|
|
591
|
-
case "active": return styleText("cyan",
|
|
592
|
-
case "cancel": return styleText("red",
|
|
593
|
-
case "error": return styleText("yellow",
|
|
594
|
-
case "submit": return styleText("green",
|
|
595
|
-
}
|
|
596
|
-
}, mt = (e) => e === 161 || e === 164 || e === 167 || e === 168 || e === 170 || e === 173 || e === 174 || e >= 176 && e <= 180 || e >= 182 && e <= 186 || e >= 188 && e <= 191 || e === 198 || e === 208 || e === 215 || e === 216 || e >= 222 && e <= 225 || e === 230 || e >= 232 && e <= 234 || e === 236 || e === 237 || e === 240 || e === 242 || e === 243 || e >= 247 && e <= 250 || e === 252 || e === 254 || e === 257 || e === 273 || e === 275 || e === 283 || e === 294 || e === 295 || e === 299 || e >= 305 && e <= 307 || e === 312 || e >= 319 && e <= 322 || e === 324 || e >= 328 && e <= 331 || e === 333 || e === 338 || e === 339 || e === 358 || e === 359 || e === 363 || e === 462 || e === 464 || e === 466 || e === 468 || e === 470 || e === 472 || e === 474 || e === 476 || e === 593 || e === 609 || e === 708 || e === 711 || e >= 713 && e <= 715 || e === 717 || e === 720 || e >= 728 && e <= 731 || e === 733 || e === 735 || e >= 768 && e <= 879 || e >= 913 && e <= 929 || e >= 931 && e <= 937 || e >= 945 && e <= 961 || e >= 963 && e <= 969 || e === 1025 || e >= 1040 && e <= 1103 || e === 1105 || e === 8208 || e >= 8211 && e <= 8214 || e === 8216 || e === 8217 || e === 8220 || e === 8221 || e >= 8224 && e <= 8226 || e >= 8228 && e <= 8231 || e === 8240 || e === 8242 || e === 8243 || e === 8245 || e === 8251 || e === 8254 || e === 8308 || e === 8319 || e >= 8321 && e <= 8324 || e === 8364 || e === 8451 || e === 8453 || e === 8457 || e === 8467 || e === 8470 || e === 8481 || e === 8482 || e === 8486 || e === 8491 || e === 8531 || e === 8532 || e >= 8539 && e <= 8542 || e >= 8544 && e <= 8555 || e >= 8560 && e <= 8569 || e === 8585 || e >= 8592 && e <= 8601 || e === 8632 || e === 8633 || e === 8658 || e === 8660 || e === 8679 || e === 8704 || e === 8706 || e === 8707 || e === 8711 || e === 8712 || e === 8715 || e === 8719 || e === 8721 || e === 8725 || e === 8730 || e >= 8733 && e <= 8736 || e === 8739 || e === 8741 || e >= 8743 && e <= 8748 || e === 8750 || e >= 8756 && e <= 8759 || e === 8764 || e === 8765 || e === 8776 || e === 8780 || e === 8786 || e === 8800 || e === 8801 || e >= 8804 && e <= 8807 || e === 8810 || e === 8811 || e === 8814 || e === 8815 || e === 8834 || e === 8835 || e === 8838 || e === 8839 || e === 8853 || e === 8857 || e === 8869 || e === 8895 || e === 8978 || e >= 9312 && e <= 9449 || e >= 9451 && e <= 9547 || e >= 9552 && e <= 9587 || e >= 9600 && e <= 9615 || e >= 9618 && e <= 9621 || e === 9632 || e === 9633 || e >= 9635 && e <= 9641 || e === 9650 || e === 9651 || e === 9654 || e === 9655 || e === 9660 || e === 9661 || e === 9664 || e === 9665 || e >= 9670 && e <= 9672 || e === 9675 || e >= 9678 && e <= 9681 || e >= 9698 && e <= 9701 || e === 9711 || e === 9733 || e === 9734 || e === 9737 || e === 9742 || e === 9743 || e === 9756 || e === 9758 || e === 9792 || e === 9794 || e === 9824 || e === 9825 || e >= 9827 && e <= 9829 || e >= 9831 && e <= 9834 || e === 9836 || e === 9837 || e === 9839 || e === 9886 || e === 9887 || e === 9919 || e >= 9926 && e <= 9933 || e >= 9935 && e <= 9939 || e >= 9941 && e <= 9953 || e === 9955 || e === 9960 || e === 9961 || e >= 9963 && e <= 9969 || e === 9972 || e >= 9974 && e <= 9977 || e === 9979 || e === 9980 || e === 9982 || e === 9983 || e === 10045 || e >= 10102 && e <= 10111 || e >= 11094 && e <= 11097 || e >= 12872 && e <= 12879 || e >= 57344 && e <= 63743 || e >= 65024 && e <= 65039 || e === 65533 || e >= 127232 && e <= 127242 || e >= 127248 && e <= 127277 || e >= 127280 && e <= 127337 || e >= 127344 && e <= 127373 || e === 127375 || e === 127376 || e >= 127387 && e <= 127404 || e >= 917760 && e <= 917999 || e >= 983040 && e <= 1048573 || e >= 1048576 && e <= 1114109, gt = (e) => e === 12288 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510, ft = (e) => e >= 4352 && e <= 4447 || e === 8986 || e === 8987 || e === 9001 || e === 9002 || e >= 9193 && e <= 9196 || e === 9200 || e === 9203 || e === 9725 || e === 9726 || e === 9748 || e === 9749 || e >= 9800 && e <= 9811 || e === 9855 || e === 9875 || e === 9889 || e === 9898 || e === 9899 || e === 9917 || e === 9918 || e === 9924 || e === 9925 || e === 9934 || e === 9940 || e === 9962 || e === 9970 || e === 9971 || e === 9973 || e === 9978 || e === 9981 || e === 9989 || e === 9994 || e === 9995 || e === 10024 || e === 10060 || e === 10062 || e >= 10067 && e <= 10069 || e === 10071 || e >= 10133 && e <= 10135 || e === 10160 || e === 10175 || e === 11035 || e === 11036 || e === 11088 || e === 11093 || e >= 11904 && e <= 11929 || e >= 11931 && e <= 12019 || e >= 12032 && e <= 12245 || e >= 12272 && e <= 12287 || e >= 12289 && e <= 12350 || e >= 12353 && e <= 12438 || e >= 12441 && e <= 12543 || e >= 12549 && e <= 12591 || e >= 12593 && e <= 12686 || e >= 12688 && e <= 12771 || e >= 12783 && e <= 12830 || e >= 12832 && e <= 12871 || e >= 12880 && e <= 19903 || e >= 19968 && e <= 42124 || e >= 42128 && e <= 42182 || e >= 43360 && e <= 43388 || e >= 44032 && e <= 55203 || e >= 63744 && e <= 64255 || e >= 65040 && e <= 65049 || e >= 65072 && e <= 65106 || e >= 65108 && e <= 65126 || e >= 65128 && e <= 65131 || e >= 94176 && e <= 94180 || e === 94192 || e === 94193 || e >= 94208 && e <= 100343 || e >= 100352 && e <= 101589 || e >= 101632 && e <= 101640 || e >= 110576 && e <= 110579 || e >= 110581 && e <= 110587 || e === 110589 || e === 110590 || e >= 110592 && e <= 110882 || e === 110898 || e >= 110928 && e <= 110930 || e === 110933 || e >= 110948 && e <= 110951 || e >= 110960 && e <= 111355 || e === 126980 || e === 127183 || e === 127374 || e >= 127377 && e <= 127386 || e >= 127488 && e <= 127490 || e >= 127504 && e <= 127547 || e >= 127552 && e <= 127560 || e === 127568 || e === 127569 || e >= 127584 && e <= 127589 || e >= 127744 && e <= 127776 || e >= 127789 && e <= 127797 || e >= 127799 && e <= 127868 || e >= 127870 && e <= 127891 || e >= 127904 && e <= 127946 || e >= 127951 && e <= 127955 || e >= 127968 && e <= 127984 || e === 127988 || e >= 127992 && e <= 128062 || e === 128064 || e >= 128066 && e <= 128252 || e >= 128255 && e <= 128317 || e >= 128331 && e <= 128334 || e >= 128336 && e <= 128359 || e === 128378 || e === 128405 || e === 128406 || e === 128420 || e >= 128507 && e <= 128591 || e >= 128640 && e <= 128709 || e === 128716 || e >= 128720 && e <= 128722 || e >= 128725 && e <= 128727 || e >= 128732 && e <= 128735 || e === 128747 || e === 128748 || e >= 128756 && e <= 128764 || e >= 128992 && e <= 129003 || e === 129008 || e >= 129292 && e <= 129338 || e >= 129340 && e <= 129349 || e >= 129351 && e <= 129535 || e >= 129648 && e <= 129660 || e >= 129664 && e <= 129672 || e >= 129680 && e <= 129725 || e >= 129727 && e <= 129733 || e >= 129742 && e <= 129755 || e >= 129760 && e <= 129768 || e >= 129776 && e <= 129784 || e >= 131072 && e <= 196605 || e >= 196608 && e <= 262141, we = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, re = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, ie = /\t{1,1000}/y, Ae = /[\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?))*/uy, ne = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, Ft = /\p{M}+/gu, yt = {
|
|
597
|
-
limit: Infinity,
|
|
598
|
-
ellipsis: ""
|
|
599
|
-
}, Le = (e, r = {}, s = {}) => {
|
|
600
|
-
const i = r.limit ?? Infinity, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? Le(a, yt, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, p = s.emojiWidth ?? 2, f = s.fullWidthWidth ?? 2, g = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
|
|
601
|
-
let $ = 0, m = 0, d = e.length, F = 0, y = !1, v = d, C = Math.max(0, i - o), A = 0, b = 0, w = 0, S = 0;
|
|
602
|
-
e: for (;;) {
|
|
603
|
-
if (b > A || m >= d && m > $) {
|
|
604
|
-
const T = e.slice(A, b) || e.slice($, m);
|
|
605
|
-
F = 0;
|
|
606
|
-
for (const M of T.replaceAll(Ft, "")) {
|
|
607
|
-
const O = M.codePointAt(0) || 0;
|
|
608
|
-
if (gt(O) ? S = f : ft(O) ? S = E : c !== g && mt(O) ? S = c : S = g, w + S > C && (v = Math.min(v, Math.max(A, $) + F)), w + S > i) {
|
|
609
|
-
y = !0;
|
|
610
|
-
break e;
|
|
611
|
-
}
|
|
612
|
-
F += M.length, w += S;
|
|
613
|
-
}
|
|
614
|
-
A = b = 0;
|
|
615
|
-
}
|
|
616
|
-
if (m >= d) break;
|
|
617
|
-
if (ne.lastIndex = m, ne.test(e)) {
|
|
618
|
-
if (F = ne.lastIndex - m, S = F * g, w + S > C && (v = Math.min(v, m + Math.floor((C - w) / g))), w + S > i) {
|
|
619
|
-
y = !0;
|
|
620
|
-
break;
|
|
621
|
-
}
|
|
622
|
-
w += S, A = $, b = m, m = $ = ne.lastIndex;
|
|
623
|
-
continue;
|
|
624
|
-
}
|
|
625
|
-
if (we.lastIndex = m, we.test(e)) {
|
|
626
|
-
if (w + u > C && (v = Math.min(v, m)), w + u > i) {
|
|
627
|
-
y = !0;
|
|
628
|
-
break;
|
|
629
|
-
}
|
|
630
|
-
w += u, A = $, b = m, m = $ = we.lastIndex;
|
|
631
|
-
continue;
|
|
632
|
-
}
|
|
633
|
-
if (re.lastIndex = m, re.test(e)) {
|
|
634
|
-
if (F = re.lastIndex - m, S = F * l, w + S > C && (v = Math.min(v, m + Math.floor((C - w) / l))), w + S > i) {
|
|
635
|
-
y = !0;
|
|
636
|
-
break;
|
|
637
|
-
}
|
|
638
|
-
w += S, A = $, b = m, m = $ = re.lastIndex;
|
|
639
|
-
continue;
|
|
640
|
-
}
|
|
641
|
-
if (ie.lastIndex = m, ie.test(e)) {
|
|
642
|
-
if (F = ie.lastIndex - m, S = F * n, w + S > C && (v = Math.min(v, m + Math.floor((C - w) / n))), w + S > i) {
|
|
643
|
-
y = !0;
|
|
644
|
-
break;
|
|
645
|
-
}
|
|
646
|
-
w += S, A = $, b = m, m = $ = ie.lastIndex;
|
|
647
|
-
continue;
|
|
648
|
-
}
|
|
649
|
-
if (Ae.lastIndex = m, Ae.test(e)) {
|
|
650
|
-
if (w + p > C && (v = Math.min(v, m)), w + p > i) {
|
|
651
|
-
y = !0;
|
|
652
|
-
break;
|
|
653
|
-
}
|
|
654
|
-
w += p, A = $, b = m, m = $ = Ae.lastIndex;
|
|
655
|
-
continue;
|
|
656
|
-
}
|
|
657
|
-
m += 1;
|
|
658
|
-
}
|
|
659
|
-
return {
|
|
660
|
-
width: y ? C : w,
|
|
661
|
-
index: y ? v : d,
|
|
662
|
-
truncated: y,
|
|
663
|
-
ellipsed: y && i >= o
|
|
664
|
-
};
|
|
665
|
-
}, Et = {
|
|
666
|
-
limit: Infinity,
|
|
667
|
-
ellipsis: "",
|
|
668
|
-
ellipsisWidth: 0
|
|
669
|
-
}, D = (e, r = {}) => Le(e, Et, r).width, ae = "\x1B", je = "", vt = 39, Ce = "\x07", ke = "[", wt = "]", Ve = "m", Se = `${wt}8;;`, He = new RegExp(`(?:\\${ke}(?<code>\\d+)m|\\${Se}(?<uri>.*)${Ce})`, "y"), At = (e) => {
|
|
670
|
-
if (e >= 30 && e <= 37 || e >= 90 && e <= 97) return 39;
|
|
671
|
-
if (e >= 40 && e <= 47 || e >= 100 && e <= 107) return 49;
|
|
672
|
-
if (e === 1 || e === 2) return 22;
|
|
673
|
-
if (e === 3) return 23;
|
|
674
|
-
if (e === 4) return 24;
|
|
675
|
-
if (e === 7) return 27;
|
|
676
|
-
if (e === 8) return 28;
|
|
677
|
-
if (e === 9) return 29;
|
|
678
|
-
if (e === 0) return 0;
|
|
679
|
-
}, Ue = (e) => `${ae}${ke}${e}${Ve}`, Ke = (e) => `${ae}${Se}${e}${Ce}`, Ct = (e) => e.map((r) => D(r)), Ie = (e, r, s) => {
|
|
680
|
-
const i = r[Symbol.iterator]();
|
|
681
|
-
let a = !1, o = !1, u = e.at(-1), l = u === void 0 ? 0 : D(u), n = i.next(), c = i.next(), p = 0;
|
|
682
|
-
for (; !n.done;) {
|
|
683
|
-
const f = n.value, g = D(f);
|
|
684
|
-
l + g <= s ? e[e.length - 1] += f : (e.push(f), l = 0), (f === ae || f === je) && (a = !0, o = r.startsWith(Se, p + 1)), a ? o ? f === Ce && (a = !1, o = !1) : f === Ve && (a = !1) : (l += g, l === s && !c.done && (e.push(""), l = 0)), n = c, c = i.next(), p += f.length;
|
|
685
|
-
}
|
|
686
|
-
u = e.at(-1), !l && u !== void 0 && u.length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
|
|
687
|
-
}, St = (e) => {
|
|
688
|
-
const r = e.split(" ");
|
|
689
|
-
let s = r.length;
|
|
690
|
-
for (; s > 0 && !(D(r[s - 1]) > 0);) s--;
|
|
691
|
-
return s === r.length ? e : r.slice(0, s).join(" ") + r.slice(s).join("");
|
|
692
|
-
}, It = (e, r, s = {}) => {
|
|
693
|
-
if (s.trim !== !1 && e.trim() === "") return "";
|
|
694
|
-
let i = "", a, o;
|
|
695
|
-
const u = e.split(" "), l = Ct(u);
|
|
696
|
-
let n = [""];
|
|
697
|
-
for (const [$, m] of u.entries()) {
|
|
698
|
-
s.trim !== !1 && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
|
|
699
|
-
let d = D(n.at(-1) ?? "");
|
|
700
|
-
if ($ !== 0 && (d >= r && (s.wordWrap === !1 || s.trim === !1) && (n.push(""), d = 0), (d > 0 || s.trim === !1) && (n[n.length - 1] += " ", d++)), s.hard && l[$] > r) {
|
|
701
|
-
const F = r - d, y = 1 + Math.floor((l[$] - F - 1) / r);
|
|
702
|
-
Math.floor((l[$] - 1) / r) < y && n.push(""), Ie(n, m, r);
|
|
703
|
-
continue;
|
|
704
|
-
}
|
|
705
|
-
if (d + l[$] > r && d > 0 && l[$] > 0) {
|
|
706
|
-
if (s.wordWrap === !1 && d < r) {
|
|
707
|
-
Ie(n, m, r);
|
|
708
|
-
continue;
|
|
709
|
-
}
|
|
710
|
-
n.push("");
|
|
711
|
-
}
|
|
712
|
-
if (d + l[$] > r && s.wordWrap === !1) {
|
|
713
|
-
Ie(n, m, r);
|
|
714
|
-
continue;
|
|
715
|
-
}
|
|
716
|
-
n[n.length - 1] += m;
|
|
717
|
-
}
|
|
718
|
-
s.trim !== !1 && (n = n.map(($) => St($)));
|
|
719
|
-
const c = n.join(`
|
|
720
|
-
`), p = c[Symbol.iterator]();
|
|
721
|
-
let f = p.next(), g = p.next(), E = 0;
|
|
722
|
-
for (; !f.done;) {
|
|
723
|
-
const $ = f.value, m = g.value;
|
|
724
|
-
if (i += $, $ === ae || $ === je) {
|
|
725
|
-
He.lastIndex = E + 1;
|
|
726
|
-
const y = He.exec(c)?.groups;
|
|
727
|
-
if (y?.code !== void 0) {
|
|
728
|
-
const v = Number.parseFloat(y.code);
|
|
729
|
-
a = v === vt ? void 0 : v;
|
|
730
|
-
} else y?.uri !== void 0 && (o = y.uri.length === 0 ? void 0 : y.uri);
|
|
731
|
-
}
|
|
732
|
-
const d = a ? At(a) : void 0;
|
|
733
|
-
m === `
|
|
734
|
-
` ? (o && (i += Ke("")), a && d && (i += Ue(d))) : $ === `
|
|
735
|
-
` && (a && d && (i += Ue(a)), o && (i += Ke(o))), E += $.length, f = g, g = p.next();
|
|
750
|
+
case "active": return styleText("cyan", S_BAR);
|
|
751
|
+
case "cancel": return styleText("red", S_BAR);
|
|
752
|
+
case "error": return styleText("yellow", S_BAR);
|
|
753
|
+
case "submit": return styleText("green", S_BAR);
|
|
736
754
|
}
|
|
737
|
-
return i;
|
|
738
755
|
};
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
`).map((i) => It(i, r, s)).join(`
|
|
744
|
-
`);
|
|
745
|
-
}
|
|
746
|
-
const bt = (e, r, s, i, a) => {
|
|
747
|
-
let o = r, u = 0;
|
|
748
|
-
for (let l = s; l < i; l++) {
|
|
749
|
-
const n = e[l];
|
|
750
|
-
if (o = o - n.length, u++, o <= a) break;
|
|
751
|
-
}
|
|
756
|
+
const E$1 = (l, o, g, c, h, O = false) => {
|
|
757
|
+
let r = o, w = 0;
|
|
758
|
+
if (O) for (let i = c - 1; i >= g && (r -= l[i].length, w++, !(r <= h)); i--);
|
|
759
|
+
else for (let i = g; i < c && (r -= l[i].length, w++, !(r <= h)); i++);
|
|
752
760
|
return {
|
|
753
|
-
lineCount:
|
|
754
|
-
removals:
|
|
761
|
+
lineCount: r,
|
|
762
|
+
removals: w
|
|
755
763
|
};
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
764
|
+
};
|
|
765
|
+
const limitOptions = ({ cursor: l, options: o, style: g, output: c = process.stdout, maxItems: h = Number.POSITIVE_INFINITY, columnPadding: O = 0, rowPadding: r = 4 }) => {
|
|
766
|
+
const i = getColumns(c) - O, I = getRows(c), C = styleText("dim", "..."), x = Math.max(I - r, 0), m = Math.max(Math.min(h, x), 5);
|
|
767
|
+
let p = 0;
|
|
768
|
+
l >= m - 3 && (p = Math.max(Math.min(l - m + 3, o.length - m), 0));
|
|
769
|
+
let f = m < o.length && p > 0, u = m < o.length && p + m < o.length;
|
|
770
|
+
const W = Math.min(p + m, o.length), e = [];
|
|
771
|
+
let d = 0;
|
|
772
|
+
f && d++, u && d++;
|
|
773
|
+
const v = p + (f ? 1 : 0), P = W - (u ? 1 : 0);
|
|
774
|
+
for (let t = v; t < P; t++) {
|
|
775
|
+
const n = wrapAnsi(g(o[t], t === l), i, {
|
|
776
|
+
hard: true,
|
|
777
|
+
trim: false
|
|
769
778
|
}).split(`
|
|
770
779
|
`);
|
|
771
|
-
|
|
772
|
-
}
|
|
773
|
-
if (
|
|
774
|
-
let
|
|
775
|
-
const
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
780
|
+
e.push(n), d += n.length;
|
|
781
|
+
}
|
|
782
|
+
if (d > x) {
|
|
783
|
+
let t = 0, n = 0, s = d;
|
|
784
|
+
const M = l - v;
|
|
785
|
+
let a = x;
|
|
786
|
+
const T = () => E$1(e, s, 0, M, a), L = () => E$1(e, s, M + 1, e.length, a, true);
|
|
787
|
+
f ? ({lineCount: s, removals: t} = T(), s > a && (u || (a -= 1), {lineCount: s, removals: n} = L())) : (u || (a -= 1), {lineCount: s, removals: n} = L(), s > a && (a -= 1, {lineCount: s, removals: t} = T())), t > 0 && (f = true, e.splice(0, t)), n > 0 && (u = true, e.splice(e.length - n, n));
|
|
788
|
+
}
|
|
789
|
+
const b = [];
|
|
790
|
+
f && b.push(C);
|
|
791
|
+
for (const t of e) for (const n of t) b.push(n);
|
|
792
|
+
return u && b.push(C), b;
|
|
793
|
+
};
|
|
794
|
+
const confirm = (i) => {
|
|
795
|
+
const a = i.active ?? "Yes", s = i.inactive ?? "No";
|
|
796
|
+
return new r({
|
|
797
|
+
active: a,
|
|
786
798
|
inactive: s,
|
|
787
|
-
signal:
|
|
788
|
-
input:
|
|
789
|
-
output:
|
|
790
|
-
initialValue:
|
|
799
|
+
signal: i.signal,
|
|
800
|
+
input: i.input,
|
|
801
|
+
output: i.output,
|
|
802
|
+
initialValue: i.initialValue ?? true,
|
|
791
803
|
render() {
|
|
792
|
-
const
|
|
793
|
-
` : ""}${
|
|
794
|
-
`,
|
|
804
|
+
const e = i.withGuide ?? settings.withGuide, u = `${symbol(this.state)} `, l = e ? `${styleText("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(i.output, i.message, l, u), o = `${e ? `${styleText("gray", S_BAR)}
|
|
805
|
+
` : ""}${f}
|
|
806
|
+
`, c = this.value ? a : s;
|
|
795
807
|
switch (this.state) {
|
|
796
|
-
case "submit": return `${
|
|
797
|
-
case "cancel": return `${
|
|
798
|
-
${styleText("gray",
|
|
808
|
+
case "submit": return `${o}${e ? `${styleText("gray", S_BAR)} ` : ""}${styleText("dim", c)}`;
|
|
809
|
+
case "cancel": return `${o}${e ? `${styleText("gray", S_BAR)} ` : ""}${styleText(["strikethrough", "dim"], c)}${e ? `
|
|
810
|
+
${styleText("gray", S_BAR)}` : ""}`;
|
|
799
811
|
default: {
|
|
800
|
-
const
|
|
801
|
-
return `${
|
|
802
|
-
${styleText("cyan",
|
|
803
|
-
` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim",
|
|
804
|
-
${
|
|
812
|
+
const r = e ? `${styleText("cyan", S_BAR)} ` : "", g = e ? styleText("cyan", S_BAR_END) : "";
|
|
813
|
+
return `${o}${r}${this.value ? `${styleText("green", S_RADIO_ACTIVE)} ${a}` : `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", a)}`}${i.vertical ? e ? `
|
|
814
|
+
${styleText("cyan", S_BAR)} ` : `
|
|
815
|
+
` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", s)}` : `${styleText("green", S_RADIO_ACTIVE)} ${s}`}
|
|
816
|
+
${g}
|
|
805
817
|
`;
|
|
806
818
|
}
|
|
807
819
|
}
|
|
808
820
|
}
|
|
809
821
|
}).prompt();
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
const f = Array.isArray(e) ? e : e.split(`
|
|
815
|
-
`);
|
|
816
|
-
if (f.length > 0) {
|
|
817
|
-
const [g, ...E] = f;
|
|
818
|
-
g.length > 0 ? u.push(`${c}${g}`) : u.push(l ? r : "");
|
|
819
|
-
for (const $ of E) $.length > 0 ? u.push(`${p}${$}`) : u.push(l ? s : "");
|
|
820
|
-
}
|
|
821
|
-
i.write(`${u.join(`
|
|
822
|
-
`)}
|
|
823
|
-
`);
|
|
824
|
-
},
|
|
825
|
-
info: (e, r) => {
|
|
826
|
-
R.message(e, {
|
|
827
|
-
...r,
|
|
828
|
-
symbol: styleText("blue", fe)
|
|
829
|
-
});
|
|
830
|
-
},
|
|
831
|
-
success: (e, r) => {
|
|
832
|
-
R.message(e, {
|
|
833
|
-
...r,
|
|
834
|
-
symbol: styleText("green", Fe)
|
|
835
|
-
});
|
|
836
|
-
},
|
|
837
|
-
step: (e, r) => {
|
|
838
|
-
R.message(e, {
|
|
839
|
-
...r,
|
|
840
|
-
symbol: styleText("green", V)
|
|
841
|
-
});
|
|
842
|
-
},
|
|
843
|
-
warn: (e, r) => {
|
|
844
|
-
R.message(e, {
|
|
845
|
-
...r,
|
|
846
|
-
symbol: styleText("yellow", ye)
|
|
847
|
-
});
|
|
848
|
-
},
|
|
849
|
-
warning: (e, r) => {
|
|
850
|
-
R.warn(e, r);
|
|
851
|
-
},
|
|
852
|
-
error: (e, r) => {
|
|
853
|
-
R.message(e, {
|
|
854
|
-
...r,
|
|
855
|
-
symbol: styleText("red", Ee)
|
|
856
|
-
});
|
|
857
|
-
}
|
|
858
|
-
}, Nt = (e = "", r) => {
|
|
859
|
-
const s = r?.output ?? process.stdout, i = r?.withGuide ?? _.withGuide ? `${styleText("gray", x)} ` : "";
|
|
860
|
-
s.write(`${i}${styleText("red", e)}
|
|
822
|
+
};
|
|
823
|
+
const cancel = (o = "", t) => {
|
|
824
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_END)} ` : "";
|
|
825
|
+
i.write(`${e}${styleText("red", o)}
|
|
861
826
|
|
|
862
827
|
`);
|
|
863
|
-
},
|
|
864
|
-
const
|
|
865
|
-
|
|
828
|
+
}, intro = (o = "", t) => {
|
|
829
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_START)} ` : "";
|
|
830
|
+
i.write(`${e}${o}
|
|
866
831
|
`);
|
|
867
|
-
},
|
|
868
|
-
const
|
|
869
|
-
${styleText("gray",
|
|
870
|
-
|
|
832
|
+
}, outro = (o = "", t) => {
|
|
833
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR)}
|
|
834
|
+
${styleText("gray", S_BAR_END)} ` : "";
|
|
835
|
+
i.write(`${e}${o}
|
|
871
836
|
|
|
872
837
|
`);
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
`)
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
838
|
+
};
|
|
839
|
+
const d = (n, a) => n.split(`
|
|
840
|
+
`).map((m) => a(m)).join(`
|
|
841
|
+
`);
|
|
842
|
+
const multiselect = (n) => {
|
|
843
|
+
const a = (t, o) => {
|
|
844
|
+
const r = t.label ?? String(t.value);
|
|
845
|
+
return o === "disabled" ? `${styleText("gray", S_CHECKBOX_INACTIVE)} ${d(r, (l) => styleText(["strikethrough", "gray"], l))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}` : o === "active" ? `${styleText("cyan", S_CHECKBOX_ACTIVE)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${d(r, (l) => styleText("dim", l))}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "cancelled" ? `${d(r, (l) => styleText(["strikethrough", "dim"], l))}` : o === "active-selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "submitted" ? `${d(r, (l) => styleText("dim", l))}` : `${styleText("dim", S_CHECKBOX_INACTIVE)} ${d(r, (l) => styleText("dim", l))}`;
|
|
846
|
+
}, m = n.required ?? true;
|
|
847
|
+
return new a$1({
|
|
848
|
+
options: n.options,
|
|
849
|
+
signal: n.signal,
|
|
850
|
+
input: n.input,
|
|
851
|
+
output: n.output,
|
|
852
|
+
initialValues: n.initialValues,
|
|
853
|
+
required: m,
|
|
854
|
+
cursorAt: n.cursorAt,
|
|
855
|
+
validate(t) {
|
|
856
|
+
if (m && (t === void 0 || t.length === 0)) return `Please select at least one option.
|
|
890
857
|
${styleText("reset", styleText("dim", `Press ${styleText([
|
|
891
858
|
"gray",
|
|
892
859
|
"bgWhite",
|
|
@@ -894,178 +861,157 @@ ${styleText("reset", styleText("dim", `Press ${styleText([
|
|
|
894
861
|
], " space ")} to select, ${styleText("gray", styleText("bgWhite", styleText("inverse", " enter ")))} to submit`))}`;
|
|
895
862
|
},
|
|
896
863
|
render() {
|
|
897
|
-
const
|
|
898
|
-
${
|
|
899
|
-
`,
|
|
900
|
-
if (
|
|
901
|
-
const
|
|
902
|
-
return
|
|
864
|
+
const t = n.withGuide ?? settings.withGuide, o = wrapTextWithPrefix(n.output, n.message, t ? `${symbolBar(this.state)} ` : "", `${symbol(this.state)} `), r = `${t ? `${styleText("gray", S_BAR)}
|
|
865
|
+
` : ""}${o}
|
|
866
|
+
`, l = this.value ?? [], g = (i, u) => {
|
|
867
|
+
if (i.disabled) return a(i, "disabled");
|
|
868
|
+
const s = l.includes(i.value);
|
|
869
|
+
return u && s ? a(i, "active-selected") : s ? a(i, "selected") : a(i, u ? "active" : "inactive");
|
|
903
870
|
};
|
|
904
871
|
switch (this.state) {
|
|
905
872
|
case "submit": {
|
|
906
|
-
const
|
|
907
|
-
return `${
|
|
873
|
+
const i = this.options.filter(({ value: s }) => l.includes(s)).map((s) => a(s, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none");
|
|
874
|
+
return `${r}${wrapTextWithPrefix(n.output, i, t ? `${styleText("gray", S_BAR)} ` : "")}`;
|
|
908
875
|
}
|
|
909
876
|
case "cancel": {
|
|
910
|
-
const
|
|
911
|
-
if (
|
|
912
|
-
return `${
|
|
913
|
-
${styleText("gray",
|
|
877
|
+
const i = this.options.filter(({ value: s }) => l.includes(s)).map((s) => a(s, "cancelled")).join(styleText("dim", ", "));
|
|
878
|
+
if (i.trim() === "") return `${r}${styleText("gray", S_BAR)}`;
|
|
879
|
+
return `${r}${wrapTextWithPrefix(n.output, i, t ? `${styleText("gray", S_BAR)} ` : "")}${t ? `
|
|
880
|
+
${styleText("gray", S_BAR)}` : ""}`;
|
|
914
881
|
}
|
|
915
882
|
case "error": {
|
|
916
|
-
const
|
|
917
|
-
`).map((
|
|
918
|
-
`),
|
|
919
|
-
`).length,
|
|
883
|
+
const i = t ? `${styleText("yellow", S_BAR)} ` : "", u = this.error.split(`
|
|
884
|
+
`).map((h, x) => x === 0 ? `${t ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", h)}` : ` ${h}`).join(`
|
|
885
|
+
`), s = r.split(`
|
|
886
|
+
`).length, v = u.split(`
|
|
920
887
|
`).length + 1;
|
|
921
|
-
return `${
|
|
922
|
-
output:
|
|
888
|
+
return `${r}${i}${limitOptions({
|
|
889
|
+
output: n.output,
|
|
923
890
|
options: this.options,
|
|
924
891
|
cursor: this.cursor,
|
|
925
|
-
maxItems:
|
|
926
|
-
columnPadding:
|
|
927
|
-
rowPadding:
|
|
928
|
-
style:
|
|
892
|
+
maxItems: n.maxItems,
|
|
893
|
+
columnPadding: i.length,
|
|
894
|
+
rowPadding: s + v,
|
|
895
|
+
style: g
|
|
929
896
|
}).join(`
|
|
930
|
-
${
|
|
931
|
-
${
|
|
897
|
+
${i}`)}
|
|
898
|
+
${u}
|
|
932
899
|
`;
|
|
933
900
|
}
|
|
934
901
|
default: {
|
|
935
|
-
const
|
|
936
|
-
`).length;
|
|
937
|
-
return `${
|
|
938
|
-
output:
|
|
902
|
+
const i = t ? `${styleText("cyan", S_BAR)} ` : "", u = r.split(`
|
|
903
|
+
`).length, s = t ? 2 : 1;
|
|
904
|
+
return `${r}${i}${limitOptions({
|
|
905
|
+
output: n.output,
|
|
939
906
|
options: this.options,
|
|
940
907
|
cursor: this.cursor,
|
|
941
|
-
maxItems:
|
|
942
|
-
columnPadding:
|
|
943
|
-
rowPadding:
|
|
944
|
-
style:
|
|
908
|
+
maxItems: n.maxItems,
|
|
909
|
+
columnPadding: i.length,
|
|
910
|
+
rowPadding: u + s,
|
|
911
|
+
style: g
|
|
945
912
|
}).join(`
|
|
946
|
-
${
|
|
947
|
-
${styleText("cyan",
|
|
913
|
+
${i}`)}
|
|
914
|
+
${t ? styleText("cyan", S_BAR_END) : ""}
|
|
948
915
|
`;
|
|
949
916
|
}
|
|
950
917
|
}
|
|
951
918
|
}
|
|
952
919
|
}).prompt();
|
|
953
920
|
};
|
|
954
|
-
|
|
955
|
-
const oe = (e, r) => e.includes(`
|
|
921
|
+
const c = (e, a) => e.includes(`
|
|
956
922
|
`) ? e.split(`
|
|
957
|
-
`).map((
|
|
958
|
-
`) :
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
case "
|
|
964
|
-
case "
|
|
965
|
-
case "
|
|
966
|
-
|
|
923
|
+
`).map((t) => a(t)).join(`
|
|
924
|
+
`) : a(e);
|
|
925
|
+
const select = (e) => {
|
|
926
|
+
const a$2 = (t, d) => {
|
|
927
|
+
const s = t.label ?? String(t.value);
|
|
928
|
+
switch (d) {
|
|
929
|
+
case "disabled": return `${styleText("gray", S_RADIO_INACTIVE)} ${c(s, (n) => styleText("gray", n))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}`;
|
|
930
|
+
case "selected": return `${c(s, (n) => styleText("dim", n))}`;
|
|
931
|
+
case "active": return `${styleText("green", S_RADIO_ACTIVE)} ${s}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}`;
|
|
932
|
+
case "cancelled": return `${c(s, (n) => styleText(["strikethrough", "dim"], n))}`;
|
|
933
|
+
default: return `${styleText("dim", S_RADIO_INACTIVE)} ${c(s, (n) => styleText("dim", n))}`;
|
|
967
934
|
}
|
|
968
935
|
};
|
|
969
|
-
return new
|
|
936
|
+
return new a({
|
|
970
937
|
options: e.options,
|
|
971
938
|
signal: e.signal,
|
|
972
939
|
input: e.input,
|
|
973
940
|
output: e.output,
|
|
974
941
|
initialValue: e.initialValue,
|
|
975
942
|
render() {
|
|
976
|
-
const
|
|
977
|
-
` : ""}${
|
|
943
|
+
const t = e.withGuide ?? settings.withGuide, d = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, n = wrapTextWithPrefix(e.output, e.message, s, d), u = `${t ? `${styleText("gray", S_BAR)}
|
|
944
|
+
` : ""}${n}
|
|
978
945
|
`;
|
|
979
946
|
switch (this.state) {
|
|
980
947
|
case "submit": {
|
|
981
|
-
const
|
|
982
|
-
return `${u}${
|
|
948
|
+
const r = t ? `${styleText("gray", S_BAR)} ` : "";
|
|
949
|
+
return `${u}${wrapTextWithPrefix(e.output, a$2(this.options[this.cursor], "selected"), r)}`;
|
|
983
950
|
}
|
|
984
951
|
case "cancel": {
|
|
985
|
-
const
|
|
986
|
-
return `${u}${
|
|
987
|
-
${styleText("gray",
|
|
952
|
+
const r = t ? `${styleText("gray", S_BAR)} ` : "";
|
|
953
|
+
return `${u}${wrapTextWithPrefix(e.output, a$2(this.options[this.cursor], "cancelled"), r)}${t ? `
|
|
954
|
+
${styleText("gray", S_BAR)}` : ""}`;
|
|
988
955
|
}
|
|
989
956
|
default: {
|
|
990
|
-
const
|
|
991
|
-
`).length,
|
|
992
|
-
return `${u}${
|
|
957
|
+
const r = t ? `${styleText("cyan", S_BAR)} ` : "", l = t ? styleText("cyan", S_BAR_END) : "", g = u.split(`
|
|
958
|
+
`).length, h = t ? 2 : 1;
|
|
959
|
+
return `${u}${r}${limitOptions({
|
|
993
960
|
output: e.output,
|
|
994
961
|
cursor: this.cursor,
|
|
995
962
|
options: this.options,
|
|
996
963
|
maxItems: e.maxItems,
|
|
997
|
-
columnPadding:
|
|
998
|
-
rowPadding:
|
|
999
|
-
style: (
|
|
964
|
+
columnPadding: r.length,
|
|
965
|
+
rowPadding: g + h,
|
|
966
|
+
style: (p, b) => a$2(p, p.disabled ? "disabled" : b ? "active" : "inactive")
|
|
1000
967
|
}).join(`
|
|
1001
|
-
${
|
|
1002
|
-
${
|
|
968
|
+
${r}`)}
|
|
969
|
+
${l}
|
|
1003
970
|
`;
|
|
1004
971
|
}
|
|
1005
972
|
}
|
|
1006
973
|
}
|
|
1007
974
|
}).prompt();
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
const a = stripVTControlCharacters(i).length;
|
|
1019
|
-
s + a < process.stdout.columns ? (s += a, process.stdout.write(i)) : (process.stdout.write(`
|
|
1020
|
-
${Qe}${i.trimStart()}`), s = 3 + stripVTControlCharacters(i.trimStart()).length);
|
|
1021
|
-
}
|
|
1022
|
-
process.stdout.write(`
|
|
1023
|
-
`);
|
|
1024
|
-
},
|
|
1025
|
-
info: (e) => K.message(e, { symbol: styleText("blue", fe) }),
|
|
1026
|
-
success: (e) => K.message(e, { symbol: styleText("green", Fe) }),
|
|
1027
|
-
step: (e) => K.message(e, { symbol: styleText("green", V) }),
|
|
1028
|
-
warn: (e) => K.message(e, { symbol: styleText("yellow", ye) }),
|
|
1029
|
-
warning: (e) => K.warn(e),
|
|
1030
|
-
error: (e) => K.message(e, { symbol: styleText("red", Ee) })
|
|
1031
|
-
}, Zt = (e) => new $t({
|
|
1032
|
-
validate: e.validate,
|
|
1033
|
-
placeholder: e.placeholder,
|
|
1034
|
-
defaultValue: e.defaultValue,
|
|
1035
|
-
initialValue: e.initialValue,
|
|
1036
|
-
output: e.output,
|
|
1037
|
-
signal: e.signal,
|
|
1038
|
-
input: e.input,
|
|
975
|
+
};
|
|
976
|
+
`${styleText("gray", S_BAR)}`;
|
|
977
|
+
const text = (t) => new n({
|
|
978
|
+
validate: t.validate,
|
|
979
|
+
placeholder: t.placeholder,
|
|
980
|
+
defaultValue: t.defaultValue,
|
|
981
|
+
initialValue: t.initialValue,
|
|
982
|
+
output: t.output,
|
|
983
|
+
signal: t.signal,
|
|
984
|
+
input: t.input,
|
|
1039
985
|
render() {
|
|
1040
|
-
const
|
|
1041
|
-
` : ""}${
|
|
1042
|
-
`,
|
|
986
|
+
const i = t?.withGuide ?? settings.withGuide, s = `${`${i ? `${styleText("gray", S_BAR)}
|
|
987
|
+
` : ""}${symbol(this.state)} `}${t.message}
|
|
988
|
+
`, c = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : c, a = this.value ?? "";
|
|
1043
989
|
switch (this.state) {
|
|
1044
990
|
case "error": {
|
|
1045
|
-
const
|
|
991
|
+
const n = this.error ? ` ${styleText("yellow", this.error)}` : "", r = i ? `${styleText("yellow", S_BAR)} ` : "", d = i ? styleText("yellow", S_BAR_END) : "";
|
|
1046
992
|
return `${s.trim()}
|
|
1047
|
-
${
|
|
1048
|
-
${
|
|
993
|
+
${r}${o}
|
|
994
|
+
${d}${n}
|
|
1049
995
|
`;
|
|
1050
996
|
}
|
|
1051
997
|
case "submit": {
|
|
1052
|
-
const
|
|
1053
|
-
return `${s}${
|
|
998
|
+
const n = a ? ` ${styleText("dim", a)}` : "";
|
|
999
|
+
return `${s}${i ? styleText("gray", S_BAR) : ""}${n}`;
|
|
1054
1000
|
}
|
|
1055
1001
|
case "cancel": {
|
|
1056
|
-
const
|
|
1057
|
-
return `${s}${
|
|
1058
|
-
${
|
|
1002
|
+
const n = a ? ` ${styleText(["strikethrough", "dim"], a)}` : "", r = i ? styleText("gray", S_BAR) : "";
|
|
1003
|
+
return `${s}${r}${n}${a.trim() ? `
|
|
1004
|
+
${r}` : ""}`;
|
|
1059
1005
|
}
|
|
1060
|
-
default: return `${s}${
|
|
1061
|
-
${
|
|
1006
|
+
default: return `${s}${i ? `${styleText("cyan", S_BAR)} ` : ""}${o}
|
|
1007
|
+
${i ? styleText("cyan", S_BAR_END) : ""}
|
|
1062
1008
|
`;
|
|
1063
1009
|
}
|
|
1064
1010
|
}
|
|
1065
1011
|
}).prompt();
|
|
1066
1012
|
//#endregion
|
|
1067
|
-
//#region node_modules/.pnpm/
|
|
1068
|
-
var
|
|
1013
|
+
//#region node_modules/.pnpm/ejs@5.0.2/node_modules/ejs/lib/esm/utils.js
|
|
1014
|
+
var import_picocolors = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1069
1015
|
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
1070
1016
|
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
1071
1017
|
let formatter = (open, close, replace = open) => (input) => {
|
|
@@ -1130,892 +1076,828 @@ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1130
1076
|
};
|
|
1131
1077
|
module.exports = createColors();
|
|
1132
1078
|
module.exports.createColors = createColors;
|
|
1133
|
-
}));
|
|
1134
|
-
//#endregion
|
|
1135
|
-
//#region node_modules/.pnpm/ejs@3.1.10/node_modules/ejs/lib/utils.js
|
|
1079
|
+
})))();
|
|
1136
1080
|
/**
|
|
1137
1081
|
* Private utility functions
|
|
1138
1082
|
* @module utils
|
|
1139
1083
|
* @private
|
|
1140
1084
|
*/
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1085
|
+
const utils = {};
|
|
1086
|
+
var regExpChars = /[|\\{}()[\]^$+*?.]/g;
|
|
1087
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1088
|
+
var hasOwn = function(obj, key) {
|
|
1089
|
+
return hasOwnProperty.apply(obj, [key]);
|
|
1090
|
+
};
|
|
1091
|
+
utils.hasOwn = hasOwn;
|
|
1092
|
+
/**
|
|
1093
|
+
* Escape characters reserved in regular expressions.
|
|
1094
|
+
*
|
|
1095
|
+
* If `string` is `undefined` or `null`, the empty string is returned.
|
|
1096
|
+
*
|
|
1097
|
+
* @param {String} string Input string
|
|
1098
|
+
* @return {String} Escaped string
|
|
1099
|
+
* @static
|
|
1100
|
+
* @private
|
|
1101
|
+
*/
|
|
1102
|
+
utils.escapeRegExpChars = function(string) {
|
|
1103
|
+
// istanbul ignore if
|
|
1104
|
+
if (!string) return "";
|
|
1105
|
+
return String(string).replace(regExpChars, "\\$&");
|
|
1106
|
+
};
|
|
1107
|
+
var _ENCODE_HTML_RULES = {
|
|
1108
|
+
"&": "&",
|
|
1109
|
+
"<": "<",
|
|
1110
|
+
">": ">",
|
|
1111
|
+
"\"": """,
|
|
1112
|
+
"'": "'"
|
|
1113
|
+
};
|
|
1114
|
+
var _MATCH_HTML = /[&<>'"]/g;
|
|
1115
|
+
function encode_char(c) {
|
|
1116
|
+
return _ENCODE_HTML_RULES[c] || c;
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Stringified version of constants used by {@link module:utils.escapeXML}.
|
|
1120
|
+
*
|
|
1121
|
+
* @readonly
|
|
1122
|
+
* @type {String}
|
|
1123
|
+
*/
|
|
1124
|
+
var escapeFuncStr = "var _ENCODE_HTML_RULES = {\n \"&\": \"&\"\n , \"<\": \"<\"\n , \">\": \">\"\n , '\"': \""\"\n , \"'\": \"'\"\n }\n , _MATCH_HTML = /[&<>'\"]/g;\nfunction encode_char(c) {\n return _ENCODE_HTML_RULES[c] || c;\n};\n";
|
|
1125
|
+
/**
|
|
1126
|
+
* Escape characters reserved in XML.
|
|
1127
|
+
*
|
|
1128
|
+
* If `markup` is `undefined` or `null`, the empty string is returned.
|
|
1129
|
+
*
|
|
1130
|
+
* @implements {EscapeCallback}
|
|
1131
|
+
* @param {String} markup Input string
|
|
1132
|
+
* @return {String} Escaped string
|
|
1133
|
+
* @static
|
|
1134
|
+
* @private
|
|
1135
|
+
*/
|
|
1136
|
+
utils.escapeXML = function(markup) {
|
|
1137
|
+
return markup == void 0 ? "" : String(markup).replace(_MATCH_HTML, encode_char);
|
|
1138
|
+
};
|
|
1139
|
+
function escapeXMLToString() {
|
|
1140
|
+
return Function.prototype.toString.call(this) + ";\n" + escapeFuncStr;
|
|
1141
|
+
}
|
|
1142
|
+
try {
|
|
1143
|
+
if (typeof Object.defineProperty === "function") Object.defineProperty(utils.escapeXML, "toString", { value: escapeXMLToString });
|
|
1144
|
+
else utils.escapeXML.toString = escapeXMLToString;
|
|
1145
|
+
} catch (err) {
|
|
1146
|
+
console.warn("Unable to set escapeXML.toString (is the Function prototype frozen?)");
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Naive copy of properties from one object to another.
|
|
1150
|
+
* Does not recurse into non-scalar properties
|
|
1151
|
+
* Does not check to see if the property has a value before copying
|
|
1152
|
+
*
|
|
1153
|
+
* @param {Object} to Destination object
|
|
1154
|
+
* @param {Object} from Source object
|
|
1155
|
+
* @return {Object} Destination object
|
|
1156
|
+
* @static
|
|
1157
|
+
* @private
|
|
1158
|
+
*/
|
|
1159
|
+
utils.shallowCopy = function(to, from) {
|
|
1160
|
+
from = from || {};
|
|
1161
|
+
if (to !== null && to !== void 0) for (var p in from) {
|
|
1162
|
+
if (!hasOwn(from, p)) continue;
|
|
1163
|
+
if (p === "__proto__" || p === "constructor") continue;
|
|
1164
|
+
to[p] = from[p];
|
|
1204
1165
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1166
|
+
return to;
|
|
1167
|
+
};
|
|
1168
|
+
/**
|
|
1169
|
+
* Naive copy of a list of key names, from one object to another.
|
|
1170
|
+
* Only copies property if it is actually defined
|
|
1171
|
+
* Does not recurse into non-scalar properties
|
|
1172
|
+
*
|
|
1173
|
+
* @param {Object} to Destination object
|
|
1174
|
+
* @param {Object} from Source object
|
|
1175
|
+
* @param {Array} list List of properties to copy
|
|
1176
|
+
* @return {Object} Destination object
|
|
1177
|
+
* @static
|
|
1178
|
+
* @private
|
|
1179
|
+
*/
|
|
1180
|
+
utils.shallowCopyFromList = function(to, from, list) {
|
|
1181
|
+
list = list || [];
|
|
1182
|
+
from = from || {};
|
|
1183
|
+
if (to !== null && to !== void 0) for (var i = 0; i < list.length; i++) {
|
|
1184
|
+
var p = list[i];
|
|
1185
|
+
if (typeof from[p] != "undefined") {
|
|
1219
1186
|
if (!hasOwn(from, p)) continue;
|
|
1220
1187
|
if (p === "__proto__" || p === "constructor") continue;
|
|
1221
1188
|
to[p] = from[p];
|
|
1222
1189
|
}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
};
|
|
1273
|
-
/**
|
|
1274
|
-
* Transforms hyphen case variable into camel case.
|
|
1275
|
-
*
|
|
1276
|
-
* @param {String} string Hyphen case string
|
|
1277
|
-
* @return {String} Camel case string
|
|
1278
|
-
* @static
|
|
1279
|
-
* @private
|
|
1280
|
-
*/
|
|
1281
|
-
exports.hyphenToCamel = function(str) {
|
|
1282
|
-
return str.replace(/-[a-z]/g, function(match) {
|
|
1283
|
-
return match[1].toUpperCase();
|
|
1284
|
-
});
|
|
1190
|
+
}
|
|
1191
|
+
return to;
|
|
1192
|
+
};
|
|
1193
|
+
/**
|
|
1194
|
+
* Simple in-process cache implementation. Does not implement limits of any
|
|
1195
|
+
* sort.
|
|
1196
|
+
*
|
|
1197
|
+
* @implements {Cache}
|
|
1198
|
+
* @static
|
|
1199
|
+
* @private
|
|
1200
|
+
*/
|
|
1201
|
+
utils.cache = {
|
|
1202
|
+
_data: {},
|
|
1203
|
+
set: function(key, val) {
|
|
1204
|
+
this._data[key] = val;
|
|
1205
|
+
},
|
|
1206
|
+
get: function(key) {
|
|
1207
|
+
return this._data[key];
|
|
1208
|
+
},
|
|
1209
|
+
remove: function(key) {
|
|
1210
|
+
delete this._data[key];
|
|
1211
|
+
},
|
|
1212
|
+
reset: function() {
|
|
1213
|
+
this._data = {};
|
|
1214
|
+
}
|
|
1215
|
+
};
|
|
1216
|
+
/**
|
|
1217
|
+
* Transforms hyphen case variable into camel case.
|
|
1218
|
+
*
|
|
1219
|
+
* @param {String} string Hyphen case string
|
|
1220
|
+
* @return {String} Camel case string
|
|
1221
|
+
* @static
|
|
1222
|
+
* @private
|
|
1223
|
+
*/
|
|
1224
|
+
utils.hyphenToCamel = function(str) {
|
|
1225
|
+
return str.replace(/-[a-z]/g, function(match) {
|
|
1226
|
+
return match[1].toUpperCase();
|
|
1227
|
+
});
|
|
1228
|
+
};
|
|
1229
|
+
/**
|
|
1230
|
+
* Returns a null-prototype object in runtimes that support it
|
|
1231
|
+
*
|
|
1232
|
+
* @return {Object} Object, prototype will be set to null where possible
|
|
1233
|
+
* @static
|
|
1234
|
+
* @private
|
|
1235
|
+
*/
|
|
1236
|
+
utils.createNullProtoObjWherePossible = (function() {
|
|
1237
|
+
if (typeof Object.create == "function") return function() {
|
|
1238
|
+
return Object.create(null);
|
|
1285
1239
|
};
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
*
|
|
1289
|
-
* @return {Object} Object, prototype will be set to null where possible
|
|
1290
|
-
* @static
|
|
1291
|
-
* @private
|
|
1292
|
-
*/
|
|
1293
|
-
exports.createNullProtoObjWherePossible = (function() {
|
|
1294
|
-
if (typeof Object.create == "function") return function() {
|
|
1295
|
-
return Object.create(null);
|
|
1296
|
-
};
|
|
1297
|
-
if (!({ __proto__: null } instanceof Object)) return function() {
|
|
1298
|
-
return { __proto__: null };
|
|
1299
|
-
};
|
|
1300
|
-
return function() {
|
|
1301
|
-
return {};
|
|
1302
|
-
};
|
|
1303
|
-
})();
|
|
1304
|
-
exports.hasOwnOnlyObject = function(obj) {
|
|
1305
|
-
var o = exports.createNullProtoObjWherePossible();
|
|
1306
|
-
for (var p in obj) if (hasOwn(obj, p)) o[p] = obj[p];
|
|
1307
|
-
return o;
|
|
1240
|
+
if (!({ __proto__: null } instanceof Object)) return function() {
|
|
1241
|
+
return { __proto__: null };
|
|
1308
1242
|
};
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
//#region node_modules/.pnpm/ejs@3.1.10/node_modules/ejs/package.json
|
|
1312
|
-
var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1313
|
-
module.exports = {
|
|
1314
|
-
"name": "ejs",
|
|
1315
|
-
"description": "Embedded JavaScript templates",
|
|
1316
|
-
"keywords": [
|
|
1317
|
-
"template",
|
|
1318
|
-
"engine",
|
|
1319
|
-
"ejs"
|
|
1320
|
-
],
|
|
1321
|
-
"version": "3.1.10",
|
|
1322
|
-
"author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
|
|
1323
|
-
"license": "Apache-2.0",
|
|
1324
|
-
"bin": { "ejs": "./bin/cli.js" },
|
|
1325
|
-
"main": "./lib/ejs.js",
|
|
1326
|
-
"jsdelivr": "ejs.min.js",
|
|
1327
|
-
"unpkg": "ejs.min.js",
|
|
1328
|
-
"repository": {
|
|
1329
|
-
"type": "git",
|
|
1330
|
-
"url": "git://github.com/mde/ejs.git"
|
|
1331
|
-
},
|
|
1332
|
-
"bugs": "https://github.com/mde/ejs/issues",
|
|
1333
|
-
"homepage": "https://github.com/mde/ejs",
|
|
1334
|
-
"dependencies": { "jake": "^10.8.5" },
|
|
1335
|
-
"devDependencies": {
|
|
1336
|
-
"browserify": "^16.5.1",
|
|
1337
|
-
"eslint": "^6.8.0",
|
|
1338
|
-
"git-directory-deploy": "^1.5.1",
|
|
1339
|
-
"jsdoc": "^4.0.2",
|
|
1340
|
-
"lru-cache": "^4.0.1",
|
|
1341
|
-
"mocha": "^10.2.0",
|
|
1342
|
-
"uglify-js": "^3.3.16"
|
|
1343
|
-
},
|
|
1344
|
-
"engines": { "node": ">=0.10.0" },
|
|
1345
|
-
"scripts": { "test": "npx jake test" }
|
|
1243
|
+
return function() {
|
|
1244
|
+
return {};
|
|
1346
1245
|
};
|
|
1347
|
-
}));
|
|
1246
|
+
})();
|
|
1247
|
+
/**
|
|
1248
|
+
* Copies own-properties from one object to a null-prototype object for basic
|
|
1249
|
+
* protection against prototype pollution
|
|
1250
|
+
*
|
|
1251
|
+
* @return {Object} Object with own-properties of input object
|
|
1252
|
+
* @static
|
|
1253
|
+
* @private
|
|
1254
|
+
*/
|
|
1255
|
+
utils.hasOwnOnlyObject = function(obj) {
|
|
1256
|
+
var o = utils.createNullProtoObjWherePossible();
|
|
1257
|
+
for (var p in obj) if (hasOwn(obj, p)) o[p] = obj[p];
|
|
1258
|
+
return o;
|
|
1259
|
+
};
|
|
1260
|
+
if (typeof exports != "undefined") module.exports = utils;
|
|
1348
1261
|
//#endregion
|
|
1349
|
-
//#region node_modules/.pnpm/ejs@
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
path = path.replace(/^\/*/, "");
|
|
1480
|
-
if (Array.isArray(options.root)) includePath = resolvePaths(path, options.root);
|
|
1481
|
-
else includePath = exports.resolveInclude(path, options.root || "/", true);
|
|
1482
|
-
} else {
|
|
1483
|
-
if (options.filename) {
|
|
1484
|
-
filePath = exports.resolveInclude(path, options.filename);
|
|
1485
|
-
if (fs$1.existsSync(filePath)) includePath = filePath;
|
|
1486
|
-
}
|
|
1487
|
-
if (!includePath && Array.isArray(views)) includePath = resolvePaths(path, views);
|
|
1488
|
-
if (!includePath && typeof options.includer !== "function") throw new Error("Could not find the include file \"" + options.escapeFunction(path) + "\"");
|
|
1262
|
+
//#region node_modules/.pnpm/ejs@5.0.2/node_modules/ejs/lib/esm/ejs.js
|
|
1263
|
+
/**
|
|
1264
|
+
* @file Embedded JavaScript templating engine. {@link http://ejs.co}
|
|
1265
|
+
* @author Matthew Eernisse <mde@fleegix.org>
|
|
1266
|
+
* @project EJS
|
|
1267
|
+
* @license {@link http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0}
|
|
1268
|
+
*/
|
|
1269
|
+
/**
|
|
1270
|
+
* EJS internal functions.
|
|
1271
|
+
*
|
|
1272
|
+
* Technically this "module" lies in the same file as {@link module:ejs}, for
|
|
1273
|
+
* the sake of organization all the private functions re grouped into this
|
|
1274
|
+
* module.
|
|
1275
|
+
*
|
|
1276
|
+
* @module ejs-internal
|
|
1277
|
+
* @private
|
|
1278
|
+
*/
|
|
1279
|
+
/**
|
|
1280
|
+
* Embedded JavaScript templating engine.
|
|
1281
|
+
*
|
|
1282
|
+
* @module ejs
|
|
1283
|
+
* @public
|
|
1284
|
+
*/
|
|
1285
|
+
const DECLARATION_KEYWORD = "let";
|
|
1286
|
+
const ejs = {};
|
|
1287
|
+
/** @type {string} */
|
|
1288
|
+
let _DEFAULT_OPEN_DELIMITER = "<";
|
|
1289
|
+
let _DEFAULT_CLOSE_DELIMITER = ">";
|
|
1290
|
+
let _DEFAULT_DELIMITER = "%";
|
|
1291
|
+
let _DEFAULT_LOCALS_NAME = "locals";
|
|
1292
|
+
let _REGEX_STRING = "(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)";
|
|
1293
|
+
let _OPTS_PASSABLE_WITH_DATA = [
|
|
1294
|
+
"delimiter",
|
|
1295
|
+
"scope",
|
|
1296
|
+
"context",
|
|
1297
|
+
"debug",
|
|
1298
|
+
"compileDebug",
|
|
1299
|
+
"_with",
|
|
1300
|
+
"rmWhitespace",
|
|
1301
|
+
"strict",
|
|
1302
|
+
"filename",
|
|
1303
|
+
"async"
|
|
1304
|
+
];
|
|
1305
|
+
let _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat("cache");
|
|
1306
|
+
let _BOM = /^\uFEFF/;
|
|
1307
|
+
let _JS_IDENTIFIER = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
|
|
1308
|
+
/**
|
|
1309
|
+
* EJS template function cache. This can be a LRU object from lru-cache NPM
|
|
1310
|
+
* module. By default, it is {@link module:utils.cache}, a simple in-process
|
|
1311
|
+
* cache that grows continuously.
|
|
1312
|
+
*
|
|
1313
|
+
* @type {Cache}
|
|
1314
|
+
*/
|
|
1315
|
+
ejs.cache = utils.cache;
|
|
1316
|
+
/**
|
|
1317
|
+
* Custom file loader. Useful for template preprocessing or restricting access
|
|
1318
|
+
* to a certain part of the filesystem.
|
|
1319
|
+
*
|
|
1320
|
+
* @type {fileLoader}
|
|
1321
|
+
*/
|
|
1322
|
+
ejs.fileLoader = fs.readFileSync;
|
|
1323
|
+
/**
|
|
1324
|
+
* Name of the object containing the locals.
|
|
1325
|
+
*
|
|
1326
|
+
* This variable is overridden by {@link Options}`.localsName` if it is not
|
|
1327
|
+
* `undefined`.
|
|
1328
|
+
*
|
|
1329
|
+
* @type {String}
|
|
1330
|
+
* @public
|
|
1331
|
+
*/
|
|
1332
|
+
ejs.localsName = _DEFAULT_LOCALS_NAME;
|
|
1333
|
+
/**
|
|
1334
|
+
* Promise implementation -- defaults to the native implementation if available
|
|
1335
|
+
* This is mostly just for testability
|
|
1336
|
+
*
|
|
1337
|
+
* @type {PromiseConstructorLike}
|
|
1338
|
+
* @public
|
|
1339
|
+
*/
|
|
1340
|
+
ejs.promiseImpl = new Function("return this;")().Promise;
|
|
1341
|
+
/**
|
|
1342
|
+
* Get the path to the included file from the parent file path and the
|
|
1343
|
+
* specified path.
|
|
1344
|
+
*
|
|
1345
|
+
* @param {String} name specified path
|
|
1346
|
+
* @param {String} filename parent file path
|
|
1347
|
+
* @param {Boolean} [isDir=false] whether the parent file path is a directory
|
|
1348
|
+
* @return {String}
|
|
1349
|
+
*/
|
|
1350
|
+
ejs.resolveInclude = function(name, filename, isDir) {
|
|
1351
|
+
let dirname = path.dirname;
|
|
1352
|
+
let extname = path.extname;
|
|
1353
|
+
let resolve = path.resolve;
|
|
1354
|
+
let includePath = resolve(isDir ? filename : dirname(filename), name);
|
|
1355
|
+
if (!extname(name)) includePath += ".ejs";
|
|
1356
|
+
return includePath;
|
|
1357
|
+
};
|
|
1358
|
+
/**
|
|
1359
|
+
* Try to resolve file path on multiple directories
|
|
1360
|
+
*
|
|
1361
|
+
* @param {String} name specified path
|
|
1362
|
+
* @param {Array<String>} paths list of possible parent directory paths
|
|
1363
|
+
* @return {String}
|
|
1364
|
+
*/
|
|
1365
|
+
function resolvePaths(name, paths) {
|
|
1366
|
+
let filePath;
|
|
1367
|
+
if (paths.some(function(v) {
|
|
1368
|
+
filePath = ejs.resolveInclude(name, v, true);
|
|
1369
|
+
return fs.existsSync(filePath);
|
|
1370
|
+
})) return filePath;
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Get the path to the included file by Options
|
|
1374
|
+
*
|
|
1375
|
+
* @param {String} path specified path
|
|
1376
|
+
* @param {Options} options compilation options
|
|
1377
|
+
* @return {String}
|
|
1378
|
+
*/
|
|
1379
|
+
function getIncludePath(path, options) {
|
|
1380
|
+
let includePath;
|
|
1381
|
+
let filePath;
|
|
1382
|
+
let views = options.views;
|
|
1383
|
+
let match = /^[A-Za-z]+:\\|^\//.exec(path);
|
|
1384
|
+
if (match && match.length) {
|
|
1385
|
+
path = path.replace(/^\/*/, "");
|
|
1386
|
+
if (Array.isArray(options.root)) includePath = resolvePaths(path, options.root);
|
|
1387
|
+
else includePath = ejs.resolveInclude(path, options.root || "/", true);
|
|
1388
|
+
} else {
|
|
1389
|
+
if (options.filename) {
|
|
1390
|
+
filePath = ejs.resolveInclude(path, options.filename);
|
|
1391
|
+
if (fs.existsSync(filePath)) includePath = filePath;
|
|
1489
1392
|
}
|
|
1490
|
-
|
|
1393
|
+
if (!includePath && Array.isArray(views)) includePath = resolvePaths(path, views);
|
|
1394
|
+
if (!includePath && typeof options.includer !== "function") throw new Error("Could not find the include file \"" + options.escapeFunction(path) + "\"");
|
|
1491
1395
|
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1396
|
+
return includePath;
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Get the template from a string or a file, either compiled on-the-fly or
|
|
1400
|
+
* read from cache (if enabled), and cache the template if needed.
|
|
1401
|
+
*
|
|
1402
|
+
* If `template` is not set, the file specified in `options.filename` will be
|
|
1403
|
+
* read.
|
|
1404
|
+
*
|
|
1405
|
+
* If `options.cache` is true, this function reads the file from
|
|
1406
|
+
* `options.filename` so it must be set prior to calling this function.
|
|
1407
|
+
*
|
|
1408
|
+
* @memberof module:ejs-internal
|
|
1409
|
+
* @param {Options} options compilation options
|
|
1410
|
+
* @param {String} [template] template source
|
|
1411
|
+
* @return {TemplateFunction}
|
|
1412
|
+
* @static
|
|
1413
|
+
*/
|
|
1414
|
+
function handleCache(options, template) {
|
|
1415
|
+
let func;
|
|
1416
|
+
let filename = options.filename;
|
|
1417
|
+
let hasTemplate = arguments.length > 1;
|
|
1418
|
+
if (options.cache) {
|
|
1419
|
+
if (!filename) throw new Error("cache option requires a filename");
|
|
1420
|
+
func = ejs.cache.get(filename);
|
|
1421
|
+
if (func) return func;
|
|
1422
|
+
if (!hasTemplate) template = fileLoader(filename).toString().replace(_BOM, "");
|
|
1423
|
+
} else if (!hasTemplate) {
|
|
1424
|
+
// istanbul ignore if: should not happen at all
|
|
1425
|
+
if (!filename) throw new Error("Internal EJS error: no file name or template provided");
|
|
1426
|
+
template = fileLoader(filename).toString().replace(_BOM, "");
|
|
1427
|
+
}
|
|
1428
|
+
func = ejs.compile(template, options);
|
|
1429
|
+
if (options.cache) ejs.cache.set(filename, func);
|
|
1430
|
+
return func;
|
|
1431
|
+
}
|
|
1432
|
+
/**
|
|
1433
|
+
* Try calling handleCache with the given options and data and call the
|
|
1434
|
+
* callback with the result. If an error occurs, call the callback with
|
|
1435
|
+
* the error. Used by renderFile().
|
|
1436
|
+
*
|
|
1437
|
+
* @memberof module:ejs-internal
|
|
1438
|
+
* @param {Options} options compilation options
|
|
1439
|
+
* @param {Object} data template data
|
|
1440
|
+
* @param {RenderFileCallback} cb callback
|
|
1441
|
+
* @static
|
|
1442
|
+
*/
|
|
1443
|
+
function tryHandleCache(options, data, cb) {
|
|
1444
|
+
let result;
|
|
1445
|
+
if (!cb) if (typeof ejs.promiseImpl == "function") return new ejs.promiseImpl(function(resolve, reject) {
|
|
1446
|
+
try {
|
|
1447
|
+
result = handleCache(options)(data);
|
|
1448
|
+
resolve(result);
|
|
1449
|
+
} catch (err) {
|
|
1450
|
+
reject(err);
|
|
1522
1451
|
}
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
* the error. Used by renderFile().
|
|
1531
|
-
*
|
|
1532
|
-
* @memberof module:ejs-internal
|
|
1533
|
-
* @param {Options} options compilation options
|
|
1534
|
-
* @param {Object} data template data
|
|
1535
|
-
* @param {RenderFileCallback} cb callback
|
|
1536
|
-
* @static
|
|
1537
|
-
*/
|
|
1538
|
-
function tryHandleCache(options, data, cb) {
|
|
1539
|
-
var result;
|
|
1540
|
-
if (!cb) if (typeof exports.promiseImpl == "function") return new exports.promiseImpl(function(resolve, reject) {
|
|
1541
|
-
try {
|
|
1542
|
-
result = handleCache(options)(data);
|
|
1543
|
-
resolve(result);
|
|
1544
|
-
} catch (err) {
|
|
1545
|
-
reject(err);
|
|
1546
|
-
}
|
|
1547
|
-
});
|
|
1548
|
-
else throw new Error("Please provide a callback function");
|
|
1549
|
-
else {
|
|
1550
|
-
try {
|
|
1551
|
-
result = handleCache(options)(data);
|
|
1552
|
-
} catch (err) {
|
|
1553
|
-
return cb(err);
|
|
1554
|
-
}
|
|
1555
|
-
cb(null, result);
|
|
1452
|
+
});
|
|
1453
|
+
else throw new Error("Please provide a callback function");
|
|
1454
|
+
else {
|
|
1455
|
+
try {
|
|
1456
|
+
result = handleCache(options)(data);
|
|
1457
|
+
} catch (err) {
|
|
1458
|
+
return cb(err);
|
|
1556
1459
|
}
|
|
1460
|
+
cb(null, result);
|
|
1557
1461
|
}
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
}
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* fileLoader is independent
|
|
1465
|
+
*
|
|
1466
|
+
* @param {String} filePath ejs file path.
|
|
1467
|
+
* @return {String} The contents of the specified file.
|
|
1468
|
+
* @static
|
|
1469
|
+
*/
|
|
1470
|
+
function fileLoader(filePath) {
|
|
1471
|
+
return ejs.fileLoader(filePath);
|
|
1472
|
+
}
|
|
1473
|
+
/**
|
|
1474
|
+
* Get the template function.
|
|
1475
|
+
*
|
|
1476
|
+
* If `options.cache` is `true`, then the template is cached.
|
|
1477
|
+
*
|
|
1478
|
+
* @memberof module:ejs-internal
|
|
1479
|
+
* @param {String} path path for the specified file
|
|
1480
|
+
* @param {Options} options compilation options
|
|
1481
|
+
* @return {TemplateFunction}
|
|
1482
|
+
* @static
|
|
1483
|
+
*/
|
|
1484
|
+
function includeFile(path, options) {
|
|
1485
|
+
let opts = utils.shallowCopy(utils.createNullProtoObjWherePossible(), options);
|
|
1486
|
+
opts.filename = getIncludePath(path, opts);
|
|
1487
|
+
if (typeof options.includer === "function") {
|
|
1488
|
+
let includerResult = options.includer(path, opts.filename);
|
|
1489
|
+
if (includerResult) {
|
|
1490
|
+
if (includerResult.filename) opts.filename = includerResult.filename;
|
|
1491
|
+
if (includerResult.template) return handleCache(opts, includerResult.template);
|
|
1589
1492
|
}
|
|
1590
|
-
return handleCache(opts);
|
|
1591
|
-
}
|
|
1592
|
-
/**
|
|
1593
|
-
* Re-throw the given `err` in context to the `str` of ejs, `filename`, and
|
|
1594
|
-
* `lineno`.
|
|
1595
|
-
*
|
|
1596
|
-
* @implements {RethrowCallback}
|
|
1597
|
-
* @memberof module:ejs-internal
|
|
1598
|
-
* @param {Error} err Error object
|
|
1599
|
-
* @param {String} str EJS source
|
|
1600
|
-
* @param {String} flnm file name of the EJS file
|
|
1601
|
-
* @param {Number} lineno line number of the error
|
|
1602
|
-
* @param {EscapeCallback} esc
|
|
1603
|
-
* @static
|
|
1604
|
-
*/
|
|
1605
|
-
function rethrow(err, str, flnm, lineno, esc) {
|
|
1606
|
-
var lines = str.split("\n");
|
|
1607
|
-
var start = Math.max(lineno - 3, 0);
|
|
1608
|
-
var end = Math.min(lines.length, lineno + 3);
|
|
1609
|
-
var filename = esc(flnm);
|
|
1610
|
-
var context = lines.slice(start, end).map(function(line, i) {
|
|
1611
|
-
var curr = i + start + 1;
|
|
1612
|
-
return (curr == lineno ? " >> " : " ") + curr + "| " + line;
|
|
1613
|
-
}).join("\n");
|
|
1614
|
-
err.path = filename;
|
|
1615
|
-
err.message = (filename || "ejs") + ":" + lineno + "\n" + context + "\n\n" + err.message;
|
|
1616
|
-
throw err;
|
|
1617
|
-
}
|
|
1618
|
-
function stripSemi(str) {
|
|
1619
|
-
return str.replace(/;(\s*$)/, "$1");
|
|
1620
1493
|
}
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1494
|
+
return handleCache(opts);
|
|
1495
|
+
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Re-throw the given `err` in context to the `str` of ejs, `filename`, and
|
|
1498
|
+
* `lineno`.
|
|
1499
|
+
*
|
|
1500
|
+
* @implements {RethrowCallback}
|
|
1501
|
+
* @memberof module:ejs-internal
|
|
1502
|
+
* @param {Error} err Error object
|
|
1503
|
+
* @param {String} str EJS source
|
|
1504
|
+
* @param {String} flnm file name of the EJS file
|
|
1505
|
+
* @param {Number} lineno line number of the error
|
|
1506
|
+
* @param {EscapeCallback} esc
|
|
1507
|
+
* @static
|
|
1508
|
+
*/
|
|
1509
|
+
function rethrow(err, str, flnm, lineno, esc) {
|
|
1510
|
+
let lines = str.split("\n");
|
|
1511
|
+
let start = Math.max(lineno - 3, 0);
|
|
1512
|
+
let end = Math.min(lines.length, lineno + 3);
|
|
1513
|
+
let filename = esc(flnm);
|
|
1514
|
+
let context = lines.slice(start, end).map(function(line, i) {
|
|
1515
|
+
let curr = i + start + 1;
|
|
1516
|
+
return (curr == lineno ? " >> " : " ") + curr + "| " + line;
|
|
1517
|
+
}).join("\n");
|
|
1518
|
+
err.path = filename;
|
|
1519
|
+
err.message = (filename || "ejs") + ":" + lineno + "\n" + context + "\n\n" + err.message;
|
|
1520
|
+
throw err;
|
|
1521
|
+
}
|
|
1522
|
+
function stripSemi(str) {
|
|
1523
|
+
return str.replace(/;(\s*$)/, "$1");
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Compile the given `str` of ejs into a template function.
|
|
1527
|
+
*
|
|
1528
|
+
* @param {String} template EJS template
|
|
1529
|
+
*
|
|
1530
|
+
* @param {Options} [opts] compilation options
|
|
1531
|
+
*
|
|
1532
|
+
* @return {TemplateFunction}
|
|
1533
|
+
* Note that the return type of the function depends on the value of `opts.async`.
|
|
1534
|
+
* @public
|
|
1535
|
+
*/
|
|
1536
|
+
ejs.compile = function compile(template, opts) {
|
|
1537
|
+
let templ;
|
|
1538
|
+
if (opts && opts.scope) {
|
|
1539
|
+
console.warn("`scope` option is deprecated and will be removed in future EJS");
|
|
1540
|
+
if (!opts.context) opts.context = opts.scope;
|
|
1541
|
+
delete opts.scope;
|
|
1542
|
+
}
|
|
1543
|
+
templ = new Template(template, opts);
|
|
1544
|
+
return templ.compile();
|
|
1545
|
+
};
|
|
1546
|
+
/**
|
|
1547
|
+
* Render the given `template` of ejs.
|
|
1548
|
+
*
|
|
1549
|
+
* If you would like to include options but not data, you need to explicitly
|
|
1550
|
+
* call this function with `data` being an empty object or `null`.
|
|
1551
|
+
*
|
|
1552
|
+
* @param {String} template EJS template
|
|
1553
|
+
* @param {Object} [data={}] template data
|
|
1554
|
+
* @param {Options} [opts={}] compilation and rendering options
|
|
1555
|
+
* @return {(String|Promise<String>)}
|
|
1556
|
+
* Return value type depends on `opts.async`.
|
|
1557
|
+
* @public
|
|
1558
|
+
*/
|
|
1559
|
+
ejs.render = function(template, d, o) {
|
|
1560
|
+
let data = d || utils.createNullProtoObjWherePossible();
|
|
1561
|
+
let opts = o || utils.createNullProtoObjWherePossible();
|
|
1562
|
+
if (arguments.length == 2) utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);
|
|
1563
|
+
return handleCache(opts, template)(data);
|
|
1564
|
+
};
|
|
1565
|
+
/**
|
|
1566
|
+
* Render an EJS file at the given `path` and callback `cb(err, str)`.
|
|
1567
|
+
*
|
|
1568
|
+
* If you would like to include options but not data, you need to explicitly
|
|
1569
|
+
* call this function with `data` being an empty object or `null`.
|
|
1570
|
+
*
|
|
1571
|
+
* @param {String} path path to the EJS file
|
|
1572
|
+
* @param {Object} [data={}] template data
|
|
1573
|
+
* @param {Options} [opts={}] compilation and rendering options
|
|
1574
|
+
* @param {RenderFileCallback} cb callback
|
|
1575
|
+
* @public
|
|
1576
|
+
*/
|
|
1577
|
+
ejs.renderFile = function() {
|
|
1578
|
+
let args = Array.prototype.slice.call(arguments);
|
|
1579
|
+
let filename = args.shift();
|
|
1580
|
+
let cb;
|
|
1581
|
+
let opts = { filename };
|
|
1582
|
+
let data;
|
|
1583
|
+
let viewOpts;
|
|
1584
|
+
if (typeof arguments[arguments.length - 1] == "function") cb = args.pop();
|
|
1585
|
+
if (args.length) {
|
|
1586
|
+
data = args.shift();
|
|
1587
|
+
if (args.length) utils.shallowCopy(opts, args.pop());
|
|
1588
|
+
else {
|
|
1589
|
+
if (utils.hasOwn(data, "settings") && data.settings) {
|
|
1590
|
+
if (data.settings.views) opts.views = data.settings.views;
|
|
1591
|
+
if (data.settings["view cache"]) opts.cache = true;
|
|
1592
|
+
viewOpts = data.settings["view options"];
|
|
1593
|
+
if (viewOpts) utils.shallowCopy(opts, viewOpts);
|
|
1639
1594
|
}
|
|
1640
|
-
|
|
1641
|
-
delete opts.scope;
|
|
1595
|
+
utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA_EXPRESS);
|
|
1642
1596
|
}
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1597
|
+
opts.filename = filename;
|
|
1598
|
+
} else data = utils.createNullProtoObjWherePossible();
|
|
1599
|
+
return tryHandleCache(opts, data, cb);
|
|
1600
|
+
};
|
|
1601
|
+
/**
|
|
1602
|
+
* Clear intermediate JavaScript cache. Calls {@link Cache#reset}.
|
|
1603
|
+
* @public
|
|
1604
|
+
*/
|
|
1605
|
+
/**
|
|
1606
|
+
* EJS template class
|
|
1607
|
+
* @public
|
|
1608
|
+
*/
|
|
1609
|
+
ejs.Template = Template;
|
|
1610
|
+
ejs.clearCache = function() {
|
|
1611
|
+
ejs.cache.reset();
|
|
1612
|
+
};
|
|
1613
|
+
function Template(text, optsParam) {
|
|
1614
|
+
let opts = utils.hasOwnOnlyObject(optsParam);
|
|
1615
|
+
let options = utils.createNullProtoObjWherePossible();
|
|
1616
|
+
this.templateText = text;
|
|
1617
|
+
/** @type {string | null} */
|
|
1618
|
+
this.mode = null;
|
|
1619
|
+
this.truncate = false;
|
|
1620
|
+
this.currentLine = 1;
|
|
1621
|
+
this.source = "";
|
|
1622
|
+
options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
|
|
1623
|
+
options.compileDebug = opts.compileDebug !== false;
|
|
1624
|
+
options.debug = !!opts.debug;
|
|
1625
|
+
options.filename = opts.filename;
|
|
1626
|
+
options.openDelimiter = opts.openDelimiter || ejs.openDelimiter || _DEFAULT_OPEN_DELIMITER;
|
|
1627
|
+
options.closeDelimiter = opts.closeDelimiter || ejs.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;
|
|
1628
|
+
options.delimiter = opts.delimiter || ejs.delimiter || _DEFAULT_DELIMITER;
|
|
1629
|
+
options.strict = opts.strict || false;
|
|
1630
|
+
options.context = opts.context;
|
|
1631
|
+
options.cache = opts.cache || false;
|
|
1632
|
+
options.rmWhitespace = opts.rmWhitespace;
|
|
1633
|
+
options.root = opts.root;
|
|
1634
|
+
options.includer = opts.includer;
|
|
1635
|
+
options.outputFunctionName = opts.outputFunctionName;
|
|
1636
|
+
options.localsName = opts.localsName || ejs.localsName || _DEFAULT_LOCALS_NAME;
|
|
1637
|
+
options.views = opts.views;
|
|
1638
|
+
options.async = opts.async;
|
|
1639
|
+
options.destructuredLocals = opts.destructuredLocals;
|
|
1640
|
+
options.legacyInclude = typeof opts.legacyInclude != "undefined" ? !!opts.legacyInclude : true;
|
|
1641
|
+
if (options.strict) options._with = false;
|
|
1642
|
+
else options._with = typeof opts._with != "undefined" ? opts._with : true;
|
|
1643
|
+
this.opts = options;
|
|
1644
|
+
this.regex = this.createRegex();
|
|
1645
|
+
}
|
|
1646
|
+
Template.modes = {
|
|
1647
|
+
EVAL: "eval",
|
|
1648
|
+
ESCAPED: "escaped",
|
|
1649
|
+
RAW: "raw",
|
|
1650
|
+
COMMENT: "comment",
|
|
1651
|
+
LITERAL: "literal"
|
|
1652
|
+
};
|
|
1653
|
+
Template.prototype = {
|
|
1654
|
+
createRegex: function() {
|
|
1655
|
+
let str = _REGEX_STRING;
|
|
1656
|
+
let delim = utils.escapeRegExpChars(this.opts.delimiter);
|
|
1657
|
+
let open = utils.escapeRegExpChars(this.opts.openDelimiter);
|
|
1658
|
+
let close = utils.escapeRegExpChars(this.opts.closeDelimiter);
|
|
1659
|
+
str = str.replace(/%/g, delim).replace(/</g, open).replace(/>/g, close);
|
|
1660
|
+
return new RegExp(str);
|
|
1661
|
+
},
|
|
1662
|
+
compile: function() {
|
|
1663
|
+
/** @type {string} */
|
|
1664
|
+
let src;
|
|
1665
|
+
let fn;
|
|
1666
|
+
let opts = this.opts;
|
|
1667
|
+
let prepended = "";
|
|
1668
|
+
let appended = "";
|
|
1669
|
+
/** @type {EscapeCallback} */
|
|
1670
|
+
let escapeFn = opts.escapeFunction;
|
|
1671
|
+
/** @type {FunctionConstructor} */
|
|
1672
|
+
let ctor;
|
|
1673
|
+
/** @type {string} */
|
|
1674
|
+
let sanitizedFilename = opts.filename ? JSON.stringify(opts.filename) : "undefined";
|
|
1675
|
+
if (!this.source) {
|
|
1676
|
+
this.generateSource();
|
|
1677
|
+
prepended += ` ${DECLARATION_KEYWORD} __output = "";\n function __append(s) { if (s !== undefined && s !== null) __output += s }
|
|
1678
|
+
`;
|
|
1679
|
+
if (opts.outputFunctionName) {
|
|
1680
|
+
if (!_JS_IDENTIFIER.test(opts.outputFunctionName)) throw new Error("outputFunctionName is not a valid JS identifier.");
|
|
1681
|
+
prepended += ` ${DECLARATION_KEYWORD} ` + opts.outputFunctionName + " = __append;\n";
|
|
1696
1682
|
}
|
|
1697
|
-
opts.
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
/**
|
|
1706
|
-
* EJS template class
|
|
1707
|
-
* @public
|
|
1708
|
-
*/
|
|
1709
|
-
exports.Template = Template;
|
|
1710
|
-
exports.clearCache = function() {
|
|
1711
|
-
exports.cache.reset();
|
|
1712
|
-
};
|
|
1713
|
-
function Template(text, optsParam) {
|
|
1714
|
-
var opts = utils.hasOwnOnlyObject(optsParam);
|
|
1715
|
-
var options = utils.createNullProtoObjWherePossible();
|
|
1716
|
-
this.templateText = text;
|
|
1717
|
-
/** @type {string | null} */
|
|
1718
|
-
this.mode = null;
|
|
1719
|
-
this.truncate = false;
|
|
1720
|
-
this.currentLine = 1;
|
|
1721
|
-
this.source = "";
|
|
1722
|
-
options.client = opts.client || false;
|
|
1723
|
-
options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
|
|
1724
|
-
options.compileDebug = opts.compileDebug !== false;
|
|
1725
|
-
options.debug = !!opts.debug;
|
|
1726
|
-
options.filename = opts.filename;
|
|
1727
|
-
options.openDelimiter = opts.openDelimiter || exports.openDelimiter || _DEFAULT_OPEN_DELIMITER;
|
|
1728
|
-
options.closeDelimiter = opts.closeDelimiter || exports.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;
|
|
1729
|
-
options.delimiter = opts.delimiter || exports.delimiter || _DEFAULT_DELIMITER;
|
|
1730
|
-
options.strict = opts.strict || false;
|
|
1731
|
-
options.context = opts.context;
|
|
1732
|
-
options.cache = opts.cache || false;
|
|
1733
|
-
options.rmWhitespace = opts.rmWhitespace;
|
|
1734
|
-
options.root = opts.root;
|
|
1735
|
-
options.includer = opts.includer;
|
|
1736
|
-
options.outputFunctionName = opts.outputFunctionName;
|
|
1737
|
-
options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
|
|
1738
|
-
options.views = opts.views;
|
|
1739
|
-
options.async = opts.async;
|
|
1740
|
-
options.destructuredLocals = opts.destructuredLocals;
|
|
1741
|
-
options.legacyInclude = typeof opts.legacyInclude != "undefined" ? !!opts.legacyInclude : true;
|
|
1742
|
-
if (options.strict) options._with = false;
|
|
1743
|
-
else options._with = typeof opts._with != "undefined" ? opts._with : true;
|
|
1744
|
-
this.opts = options;
|
|
1745
|
-
this.regex = this.createRegex();
|
|
1746
|
-
}
|
|
1747
|
-
Template.modes = {
|
|
1748
|
-
EVAL: "eval",
|
|
1749
|
-
ESCAPED: "escaped",
|
|
1750
|
-
RAW: "raw",
|
|
1751
|
-
COMMENT: "comment",
|
|
1752
|
-
LITERAL: "literal"
|
|
1753
|
-
};
|
|
1754
|
-
Template.prototype = {
|
|
1755
|
-
createRegex: function() {
|
|
1756
|
-
var str = _REGEX_STRING;
|
|
1757
|
-
var delim = utils.escapeRegExpChars(this.opts.delimiter);
|
|
1758
|
-
var open = utils.escapeRegExpChars(this.opts.openDelimiter);
|
|
1759
|
-
var close = utils.escapeRegExpChars(this.opts.closeDelimiter);
|
|
1760
|
-
str = str.replace(/%/g, delim).replace(/</g, open).replace(/>/g, close);
|
|
1761
|
-
return new RegExp(str);
|
|
1762
|
-
},
|
|
1763
|
-
compile: function() {
|
|
1764
|
-
/** @type {string} */
|
|
1765
|
-
var src;
|
|
1766
|
-
/** @type {ClientFunction} */
|
|
1767
|
-
var fn;
|
|
1768
|
-
var opts = this.opts;
|
|
1769
|
-
var prepended = "";
|
|
1770
|
-
var appended = "";
|
|
1771
|
-
/** @type {EscapeCallback} */
|
|
1772
|
-
var escapeFn = opts.escapeFunction;
|
|
1773
|
-
/** @type {FunctionConstructor} */
|
|
1774
|
-
var ctor;
|
|
1775
|
-
/** @type {string} */
|
|
1776
|
-
var sanitizedFilename = opts.filename ? JSON.stringify(opts.filename) : "undefined";
|
|
1777
|
-
if (!this.source) {
|
|
1778
|
-
this.generateSource();
|
|
1779
|
-
prepended += " var __output = \"\";\n function __append(s) { if (s !== undefined && s !== null) __output += s }\n";
|
|
1780
|
-
if (opts.outputFunctionName) {
|
|
1781
|
-
if (!_JS_IDENTIFIER.test(opts.outputFunctionName)) throw new Error("outputFunctionName is not a valid JS identifier.");
|
|
1782
|
-
prepended += " var " + opts.outputFunctionName + " = __append;\n";
|
|
1683
|
+
if (opts.localsName && !_JS_IDENTIFIER.test(opts.localsName)) throw new Error("localsName is not a valid JS identifier.");
|
|
1684
|
+
if (opts.destructuredLocals && opts.destructuredLocals.length) {
|
|
1685
|
+
let destructuring = ` ${DECLARATION_KEYWORD} __locals = (` + opts.localsName + " || {}),\n";
|
|
1686
|
+
for (let i = 0; i < opts.destructuredLocals.length; i++) {
|
|
1687
|
+
let name = opts.destructuredLocals[i];
|
|
1688
|
+
if (!_JS_IDENTIFIER.test(name)) throw new Error("destructuredLocals[" + i + "] is not a valid JS identifier.");
|
|
1689
|
+
if (i > 0) destructuring += ",\n ";
|
|
1690
|
+
destructuring += name + " = __locals." + name;
|
|
1783
1691
|
}
|
|
1784
|
-
|
|
1785
|
-
if (opts.destructuredLocals && opts.destructuredLocals.length) {
|
|
1786
|
-
var destructuring = " var __locals = (" + opts.localsName + " || {}),\n";
|
|
1787
|
-
for (var i = 0; i < opts.destructuredLocals.length; i++) {
|
|
1788
|
-
var name = opts.destructuredLocals[i];
|
|
1789
|
-
if (!_JS_IDENTIFIER.test(name)) throw new Error("destructuredLocals[" + i + "] is not a valid JS identifier.");
|
|
1790
|
-
if (i > 0) destructuring += ",\n ";
|
|
1791
|
-
destructuring += name + " = __locals." + name;
|
|
1792
|
-
}
|
|
1793
|
-
prepended += destructuring + ";\n";
|
|
1794
|
-
}
|
|
1795
|
-
if (opts._with !== false) {
|
|
1796
|
-
prepended += " with (" + opts.localsName + " || {}) {\n";
|
|
1797
|
-
appended += " }\n";
|
|
1798
|
-
}
|
|
1799
|
-
appended += " return __output;\n";
|
|
1800
|
-
this.source = prepended + this.source + appended;
|
|
1692
|
+
prepended += destructuring + ";\n";
|
|
1801
1693
|
}
|
|
1802
|
-
if (opts.
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
src = "escapeFn = escapeFn || " + escapeFn.toString() + ";\n" + src;
|
|
1806
|
-
if (opts.compileDebug) src = "rethrow = rethrow || " + rethrow.toString() + ";\n" + src;
|
|
1694
|
+
if (opts._with !== false) {
|
|
1695
|
+
prepended += " with (" + opts.localsName + " || {}) {\n";
|
|
1696
|
+
appended += " }\n";
|
|
1807
1697
|
}
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1698
|
+
appended += " return __output;\n";
|
|
1699
|
+
this.source = prepended + this.source + appended;
|
|
1700
|
+
}
|
|
1701
|
+
if (opts.compileDebug) src = `${DECLARATION_KEYWORD} __line = 1
|
|
1702
|
+
, __lines = ` + JSON.stringify(this.templateText) + "\n , __filename = " + sanitizedFilename + ";\ntry {\n" + this.source + "} catch (e) {\n rethrow(e, __lines, __filename, __line, escapeFn);\n}\n";
|
|
1703
|
+
else src = this.source;
|
|
1704
|
+
if (opts.strict) src = "\"use strict\";\n" + src;
|
|
1705
|
+
if (opts.debug) console.log(src);
|
|
1706
|
+
if (opts.compileDebug && opts.filename) src = src + "\n//# sourceURL=" + sanitizedFilename + "\n";
|
|
1707
|
+
try {
|
|
1708
|
+
if (opts.async) try {
|
|
1709
|
+
ctor = new Function("return (async function(){}).constructor;")();
|
|
1820
1710
|
} catch (e) {
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1711
|
+
if (e instanceof SyntaxError) throw new Error("This environment does not support async/await");
|
|
1712
|
+
else throw e;
|
|
1713
|
+
}
|
|
1714
|
+
else ctor = Function;
|
|
1715
|
+
fn = new ctor(opts.localsName + ", escapeFn, include, rethrow", src);
|
|
1716
|
+
} catch (e) {
|
|
1717
|
+
// istanbul ignore else
|
|
1718
|
+
if (e instanceof SyntaxError) {
|
|
1719
|
+
if (opts.filename) e.message += " in " + opts.filename;
|
|
1720
|
+
e.message += " while compiling ejs\n\n";
|
|
1721
|
+
e.message += "If the above error is not helpful, you may want to try EJS-Lint:\n";
|
|
1722
|
+
e.message += "https://github.com/RyanZim/EJS-Lint";
|
|
1723
|
+
if (!opts.async) {
|
|
1724
|
+
e.message += "\n";
|
|
1725
|
+
e.message += "Or, if you meant to create an async function, pass `async: true` as an option.";
|
|
1831
1726
|
}
|
|
1832
|
-
throw e;
|
|
1833
1727
|
}
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
return
|
|
1841
|
-
data || utils.createNullProtoObjWherePossible(),
|
|
1842
|
-
escapeFn,
|
|
1843
|
-
include,
|
|
1844
|
-
rethrow
|
|
1845
|
-
]);
|
|
1728
|
+
throw e;
|
|
1729
|
+
}
|
|
1730
|
+
let returnedFn = function anonymous(data) {
|
|
1731
|
+
let include = function(path, includeData) {
|
|
1732
|
+
let d = utils.shallowCopy(utils.createNullProtoObjWherePossible(), data);
|
|
1733
|
+
if (includeData) d = utils.shallowCopy(d, includeData);
|
|
1734
|
+
return includeFile(path, opts)(d);
|
|
1846
1735
|
};
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1736
|
+
return fn.apply(opts.context, [
|
|
1737
|
+
data || utils.createNullProtoObjWherePossible(),
|
|
1738
|
+
escapeFn,
|
|
1739
|
+
include,
|
|
1740
|
+
rethrow
|
|
1741
|
+
]);
|
|
1742
|
+
};
|
|
1743
|
+
if (opts.filename && typeof Object.defineProperty === "function") {
|
|
1744
|
+
let filename = opts.filename;
|
|
1745
|
+
let basename = path.basename(filename, path.extname(filename));
|
|
1746
|
+
try {
|
|
1747
|
+
Object.defineProperty(returnedFn, "name", {
|
|
1748
|
+
value: basename,
|
|
1749
|
+
writable: false,
|
|
1750
|
+
enumerable: false,
|
|
1751
|
+
configurable: true
|
|
1752
|
+
});
|
|
1753
|
+
} catch (e) {}
|
|
1754
|
+
}
|
|
1755
|
+
return returnedFn;
|
|
1756
|
+
},
|
|
1757
|
+
generateSource: function() {
|
|
1758
|
+
if (this.opts.rmWhitespace) this.templateText = this.templateText.replace(/[\r\n]+/g, "\n").replace(/^\s+|\s+$/gm, "");
|
|
1759
|
+
let self = this;
|
|
1760
|
+
let d = this.opts.delimiter;
|
|
1761
|
+
let o = this.opts.openDelimiter;
|
|
1762
|
+
let c = this.opts.closeDelimiter;
|
|
1763
|
+
let openWhitespaceSlurpTag = utils.escapeRegExpChars(o + d + "_");
|
|
1764
|
+
let closeWhitespaceSlurpTag = utils.escapeRegExpChars("_" + d + c);
|
|
1765
|
+
let openWhitespaceSlurpReplacement = o + d + "_";
|
|
1766
|
+
let closeWhitespaceSlurpReplacement = "_" + d + c;
|
|
1767
|
+
this.templateText = this.templateText.replace(new RegExp("[ \\t]*" + openWhitespaceSlurpTag, "gm"), openWhitespaceSlurpReplacement).replace(new RegExp(closeWhitespaceSlurpTag + "[ \\t]*", "gm"), closeWhitespaceSlurpReplacement);
|
|
1768
|
+
let matches = this.parseTemplateText();
|
|
1769
|
+
if (matches && matches.length) matches.forEach(function(line, index) {
|
|
1770
|
+
let closing;
|
|
1771
|
+
if (line.indexOf(o + d) === 0 && line.indexOf(o + d + d) !== 0) {
|
|
1772
|
+
closing = matches[index + 2];
|
|
1773
|
+
if (!(closing == d + c || closing == "-" + d + c || closing == "_" + d + c)) throw new Error("Could not find matching close tag for \"" + line + "\".");
|
|
1858
1774
|
}
|
|
1859
|
-
|
|
1860
|
-
}
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1775
|
+
self.scanLine(line);
|
|
1776
|
+
});
|
|
1777
|
+
},
|
|
1778
|
+
parseTemplateText: function() {
|
|
1779
|
+
let str = this.templateText;
|
|
1780
|
+
let pat = this.regex;
|
|
1781
|
+
let result = pat.exec(str);
|
|
1782
|
+
let arr = [];
|
|
1783
|
+
let firstPos;
|
|
1784
|
+
while (result) {
|
|
1785
|
+
firstPos = result.index;
|
|
1786
|
+
if (firstPos !== 0) {
|
|
1787
|
+
arr.push(str.substring(0, firstPos));
|
|
1788
|
+
str = str.slice(firstPos);
|
|
1789
|
+
}
|
|
1790
|
+
arr.push(result[0]);
|
|
1791
|
+
str = str.slice(result[0].length);
|
|
1792
|
+
result = pat.exec(str);
|
|
1793
|
+
}
|
|
1794
|
+
if (str) arr.push(str);
|
|
1795
|
+
return arr;
|
|
1796
|
+
},
|
|
1797
|
+
_addOutput: function(line) {
|
|
1798
|
+
if (this.truncate) {
|
|
1799
|
+
line = line.replace(/^(?:\r\n|\r|\n)/, "");
|
|
1800
|
+
this.truncate = false;
|
|
1801
|
+
}
|
|
1802
|
+
if (!line) return line;
|
|
1803
|
+
line = line.replace(/\\/g, "\\\\");
|
|
1804
|
+
line = line.replace(/\n/g, "\\n");
|
|
1805
|
+
line = line.replace(/\r/g, "\\r");
|
|
1806
|
+
line = line.replace(/"/g, "\\\"");
|
|
1807
|
+
this.source += " ; __append(\"" + line + "\")\n";
|
|
1808
|
+
},
|
|
1809
|
+
scanLine: function(line) {
|
|
1810
|
+
let self = this;
|
|
1811
|
+
let d = this.opts.delimiter;
|
|
1812
|
+
let o = this.opts.openDelimiter;
|
|
1813
|
+
let c = this.opts.closeDelimiter;
|
|
1814
|
+
let newLineCount = 0;
|
|
1815
|
+
newLineCount = line.split("\n").length - 1;
|
|
1816
|
+
switch (line) {
|
|
1817
|
+
case o + d:
|
|
1818
|
+
case o + d + "_":
|
|
1819
|
+
this.mode = Template.modes.EVAL;
|
|
1820
|
+
break;
|
|
1821
|
+
case o + d + "=":
|
|
1822
|
+
this.mode = Template.modes.ESCAPED;
|
|
1823
|
+
break;
|
|
1824
|
+
case o + d + "-":
|
|
1825
|
+
this.mode = Template.modes.RAW;
|
|
1826
|
+
break;
|
|
1827
|
+
case o + d + "#":
|
|
1828
|
+
this.mode = Template.modes.COMMENT;
|
|
1829
|
+
break;
|
|
1830
|
+
case o + d + d:
|
|
1831
|
+
this.mode = Template.modes.LITERAL;
|
|
1832
|
+
this.source += " ; __append(\"" + line.replace(o + d + d, o + d) + "\")\n";
|
|
1833
|
+
break;
|
|
1834
|
+
case d + d + c:
|
|
1835
|
+
this.mode = Template.modes.LITERAL;
|
|
1836
|
+
this.source += " ; __append(\"" + line.replace(d + d + c, d + c) + "\")\n";
|
|
1837
|
+
break;
|
|
1838
|
+
case d + c:
|
|
1839
|
+
case "-" + d + c:
|
|
1840
|
+
case "_" + d + c:
|
|
1841
|
+
if (this.mode == Template.modes.LITERAL) this._addOutput(line);
|
|
1842
|
+
this.mode = null;
|
|
1843
|
+
this.truncate = line.indexOf("-") === 0 || line.indexOf("_") === 0;
|
|
1844
|
+
break;
|
|
1845
|
+
default: if (this.mode) {
|
|
1846
|
+
switch (this.mode) {
|
|
1847
|
+
case Template.modes.EVAL:
|
|
1848
|
+
case Template.modes.ESCAPED:
|
|
1849
|
+
case Template.modes.RAW: if (line.lastIndexOf("//") > line.lastIndexOf("\n")) line += "\n";
|
|
1874
1850
|
}
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1851
|
+
switch (this.mode) {
|
|
1852
|
+
case Template.modes.EVAL:
|
|
1853
|
+
this.source += " ; " + line + "\n";
|
|
1854
|
+
break;
|
|
1855
|
+
case Template.modes.ESCAPED:
|
|
1856
|
+
this.source += " ; __append(escapeFn(" + stripSemi(line) + "))\n";
|
|
1857
|
+
break;
|
|
1858
|
+
case Template.modes.RAW:
|
|
1859
|
+
this.source += " ; __append(" + stripSemi(line) + ")\n";
|
|
1860
|
+
break;
|
|
1861
|
+
case Template.modes.COMMENT: break;
|
|
1862
|
+
case Template.modes.LITERAL:
|
|
1863
|
+
this._addOutput(line);
|
|
1864
|
+
break;
|
|
1889
1865
|
}
|
|
1890
|
-
|
|
1891
|
-
str = str.slice(result[0].length);
|
|
1892
|
-
result = pat.exec(str);
|
|
1893
|
-
}
|
|
1894
|
-
if (str) arr.push(str);
|
|
1895
|
-
return arr;
|
|
1896
|
-
},
|
|
1897
|
-
_addOutput: function(line) {
|
|
1898
|
-
if (this.truncate) {
|
|
1899
|
-
line = line.replace(/^(?:\r\n|\r|\n)/, "");
|
|
1900
|
-
this.truncate = false;
|
|
1901
|
-
}
|
|
1902
|
-
if (!line) return line;
|
|
1903
|
-
line = line.replace(/\\/g, "\\\\");
|
|
1904
|
-
line = line.replace(/\n/g, "\\n");
|
|
1905
|
-
line = line.replace(/\r/g, "\\r");
|
|
1906
|
-
line = line.replace(/"/g, "\\\"");
|
|
1907
|
-
this.source += " ; __append(\"" + line + "\")\n";
|
|
1908
|
-
},
|
|
1909
|
-
scanLine: function(line) {
|
|
1910
|
-
var self = this;
|
|
1911
|
-
var d = this.opts.delimiter;
|
|
1912
|
-
var o = this.opts.openDelimiter;
|
|
1913
|
-
var c = this.opts.closeDelimiter;
|
|
1914
|
-
var newLineCount = 0;
|
|
1915
|
-
newLineCount = line.split("\n").length - 1;
|
|
1916
|
-
switch (line) {
|
|
1917
|
-
case o + d:
|
|
1918
|
-
case o + d + "_":
|
|
1919
|
-
this.mode = Template.modes.EVAL;
|
|
1920
|
-
break;
|
|
1921
|
-
case o + d + "=":
|
|
1922
|
-
this.mode = Template.modes.ESCAPED;
|
|
1923
|
-
break;
|
|
1924
|
-
case o + d + "-":
|
|
1925
|
-
this.mode = Template.modes.RAW;
|
|
1926
|
-
break;
|
|
1927
|
-
case o + d + "#":
|
|
1928
|
-
this.mode = Template.modes.COMMENT;
|
|
1929
|
-
break;
|
|
1930
|
-
case o + d + d:
|
|
1931
|
-
this.mode = Template.modes.LITERAL;
|
|
1932
|
-
this.source += " ; __append(\"" + line.replace(o + d + d, o + d) + "\")\n";
|
|
1933
|
-
break;
|
|
1934
|
-
case d + d + c:
|
|
1935
|
-
this.mode = Template.modes.LITERAL;
|
|
1936
|
-
this.source += " ; __append(\"" + line.replace(d + d + c, d + c) + "\")\n";
|
|
1937
|
-
break;
|
|
1938
|
-
case d + c:
|
|
1939
|
-
case "-" + d + c:
|
|
1940
|
-
case "_" + d + c:
|
|
1941
|
-
if (this.mode == Template.modes.LITERAL) this._addOutput(line);
|
|
1942
|
-
this.mode = null;
|
|
1943
|
-
this.truncate = line.indexOf("-") === 0 || line.indexOf("_") === 0;
|
|
1944
|
-
break;
|
|
1945
|
-
default: if (this.mode) {
|
|
1946
|
-
switch (this.mode) {
|
|
1947
|
-
case Template.modes.EVAL:
|
|
1948
|
-
case Template.modes.ESCAPED:
|
|
1949
|
-
case Template.modes.RAW: if (line.lastIndexOf("//") > line.lastIndexOf("\n")) line += "\n";
|
|
1950
|
-
}
|
|
1951
|
-
switch (this.mode) {
|
|
1952
|
-
case Template.modes.EVAL:
|
|
1953
|
-
this.source += " ; " + line + "\n";
|
|
1954
|
-
break;
|
|
1955
|
-
case Template.modes.ESCAPED:
|
|
1956
|
-
this.source += " ; __append(escapeFn(" + stripSemi(line) + "))\n";
|
|
1957
|
-
break;
|
|
1958
|
-
case Template.modes.RAW:
|
|
1959
|
-
this.source += " ; __append(" + stripSemi(line) + ")\n";
|
|
1960
|
-
break;
|
|
1961
|
-
case Template.modes.COMMENT: break;
|
|
1962
|
-
case Template.modes.LITERAL:
|
|
1963
|
-
this._addOutput(line);
|
|
1964
|
-
break;
|
|
1965
|
-
}
|
|
1966
|
-
} else this._addOutput(line);
|
|
1967
|
-
}
|
|
1968
|
-
if (self.opts.compileDebug && newLineCount) {
|
|
1969
|
-
this.currentLine += newLineCount;
|
|
1970
|
-
this.source += " ; __line = " + this.currentLine + "\n";
|
|
1971
|
-
}
|
|
1866
|
+
} else this._addOutput(line);
|
|
1972
1867
|
}
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
/**
|
|
2005
|
-
* Name for detection of EJS.
|
|
2006
|
-
*
|
|
2007
|
-
* @readonly
|
|
2008
|
-
* @type {String}
|
|
2009
|
-
* @public
|
|
2010
|
-
*/
|
|
2011
|
-
exports.name = _NAME;
|
|
2012
|
-
/* istanbul ignore if */
|
|
2013
|
-
if (typeof window != "undefined") window.ejs = exports;
|
|
2014
|
-
}));
|
|
1868
|
+
if (self.opts.compileDebug && newLineCount) {
|
|
1869
|
+
this.currentLine += newLineCount;
|
|
1870
|
+
this.source += " ; __line = " + this.currentLine + "\n";
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
};
|
|
1874
|
+
/**
|
|
1875
|
+
* Escape characters reserved in XML.
|
|
1876
|
+
*
|
|
1877
|
+
* This is simply an export of {@link module:utils.escapeXML}.
|
|
1878
|
+
*
|
|
1879
|
+
* If `markup` is `undefined` or `null`, the empty string is returned.
|
|
1880
|
+
*
|
|
1881
|
+
* @param {String} markup Input string
|
|
1882
|
+
* @return {String} Escaped string
|
|
1883
|
+
* @public
|
|
1884
|
+
* @func
|
|
1885
|
+
* */
|
|
1886
|
+
ejs.escapeXML = utils.escapeXML;
|
|
1887
|
+
/**
|
|
1888
|
+
* Express.js support.
|
|
1889
|
+
*
|
|
1890
|
+
* This is an alias for {@link module:ejs.renderFile}, in order to support
|
|
1891
|
+
* Express.js out-of-the-box.
|
|
1892
|
+
*
|
|
1893
|
+
* @func
|
|
1894
|
+
*/
|
|
1895
|
+
ejs.__express = ejs.renderFile;
|
|
1896
|
+
/* istanbul ignore if */
|
|
1897
|
+
if (typeof window != "undefined") window.ejs = ejs;
|
|
1898
|
+
if (typeof module != "undefined") module.exports = ejs;
|
|
2015
1899
|
//#endregion
|
|
2016
1900
|
//#region utils/banners.ts
|
|
2017
|
-
var import_picocolors = require_picocolors();
|
|
2018
|
-
var import_ejs = /* @__PURE__ */ __toESM(require_ejs(), 1);
|
|
2019
1901
|
const defaultBanner = "Vue.js - The Progressive JavaScript Framework";
|
|
2020
1902
|
const gradientBanner = "\x1B[38;2;66;211;146mV\x1B[39m\x1B[38;2;66;211;146mu\x1B[39m\x1B[38;2;66;211;146me\x1B[39m\x1B[38;2;66;211;146m.\x1B[39m\x1B[38;2;66;211;146mj\x1B[39m\x1B[38;2;67;209;149ms\x1B[39m \x1B[38;2;68;206;152m-\x1B[39m \x1B[38;2;69;204;155mT\x1B[39m\x1B[38;2;70;201;158mh\x1B[39m\x1B[38;2;71;199;162me\x1B[39m \x1B[38;2;72;196;165mP\x1B[39m\x1B[38;2;73;194;168mr\x1B[39m\x1B[38;2;74;192;171mo\x1B[39m\x1B[38;2;75;189;174mg\x1B[39m\x1B[38;2;76;187;177mr\x1B[39m\x1B[38;2;77;184;180me\x1B[39m\x1B[38;2;78;182;183ms\x1B[39m\x1B[38;2;79;179;186ms\x1B[39m\x1B[38;2;80;177;190mi\x1B[39m\x1B[38;2;81;175;193mv\x1B[39m\x1B[38;2;82;172;196me\x1B[39m \x1B[38;2;83;170;199mJ\x1B[39m\x1B[38;2;83;167;202ma\x1B[39m\x1B[38;2;84;165;205mv\x1B[39m\x1B[38;2;85;162;208ma\x1B[39m\x1B[38;2;86;160;211mS\x1B[39m\x1B[38;2;87;158;215mc\x1B[39m\x1B[38;2;88;155;218mr\x1B[39m\x1B[38;2;89;153;221mi\x1B[39m\x1B[38;2;90;150;224mp\x1B[39m\x1B[38;2;91;148;227mt\x1B[39m \x1B[38;2;92;145;230mF\x1B[39m\x1B[38;2;93;143;233mr\x1B[39m\x1B[38;2;94;141;236ma\x1B[39m\x1B[38;2;95;138;239mm\x1B[39m\x1B[38;2;96;136;243me\x1B[39m\x1B[38;2;97;133;246mw\x1B[39m\x1B[38;2;98;131;249mo\x1B[39m\x1B[38;2;99;128;252mr\x1B[39m\x1B[38;2;100;126;255mk\x1B[39m";
|
|
2021
1903
|
//#endregion
|
|
@@ -2069,33 +1951,33 @@ function sortDependencies(packageJson) {
|
|
|
2069
1951
|
* @param {string} dest destination filename of the copy operation
|
|
2070
1952
|
*/
|
|
2071
1953
|
function renderTemplate(src, dest, callbacks) {
|
|
2072
|
-
if (fs.statSync(src).isDirectory()) {
|
|
2073
|
-
if (path$
|
|
2074
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
2075
|
-
for (const file of fs.readdirSync(src)) renderTemplate(path$
|
|
1954
|
+
if (fs$1.statSync(src).isDirectory()) {
|
|
1955
|
+
if (path$2.basename(src) === "node_modules") return;
|
|
1956
|
+
fs$1.mkdirSync(dest, { recursive: true });
|
|
1957
|
+
for (const file of fs$1.readdirSync(src)) renderTemplate(path$2.resolve(src, file), path$2.resolve(dest, file), callbacks);
|
|
2076
1958
|
return;
|
|
2077
1959
|
}
|
|
2078
|
-
const filename = path$
|
|
2079
|
-
if (filename === "package.json" && fs.existsSync(dest)) {
|
|
2080
|
-
const pkg = sortDependencies(deepMerge(JSON.parse(fs.readFileSync(dest, "utf8")), JSON.parse(fs.readFileSync(src, "utf8"))));
|
|
2081
|
-
fs.writeFileSync(dest, JSON.stringify(pkg, null, 2) + "\n");
|
|
1960
|
+
const filename = path$2.basename(src);
|
|
1961
|
+
if (filename === "package.json" && fs$1.existsSync(dest)) {
|
|
1962
|
+
const pkg = sortDependencies(deepMerge(JSON.parse(fs$1.readFileSync(dest, "utf8")), JSON.parse(fs$1.readFileSync(src, "utf8"))));
|
|
1963
|
+
fs$1.writeFileSync(dest, JSON.stringify(pkg, null, 2) + "\n");
|
|
2082
1964
|
return;
|
|
2083
1965
|
}
|
|
2084
|
-
if (filename === "extensions.json" && fs.existsSync(dest)) {
|
|
2085
|
-
const extensions = deepMerge(JSON.parse(fs.readFileSync(dest, "utf8")), JSON.parse(fs.readFileSync(src, "utf8")));
|
|
2086
|
-
fs.writeFileSync(dest, JSON.stringify(extensions, null, 2) + "\n");
|
|
1966
|
+
if (filename === "extensions.json" && fs$1.existsSync(dest)) {
|
|
1967
|
+
const extensions = deepMerge(JSON.parse(fs$1.readFileSync(dest, "utf8")), JSON.parse(fs$1.readFileSync(src, "utf8")));
|
|
1968
|
+
fs$1.writeFileSync(dest, JSON.stringify(extensions, null, 2) + "\n");
|
|
2087
1969
|
return;
|
|
2088
1970
|
}
|
|
2089
|
-
if (filename === "settings.json" && fs.existsSync(dest)) {
|
|
2090
|
-
const settings = deepMerge(JSON.parse(fs.readFileSync(dest, "utf8")), JSON.parse(fs.readFileSync(src, "utf8")));
|
|
2091
|
-
fs.writeFileSync(dest, JSON.stringify(settings, null, 2) + "\n");
|
|
1971
|
+
if (filename === "settings.json" && fs$1.existsSync(dest)) {
|
|
1972
|
+
const settings = deepMerge(JSON.parse(fs$1.readFileSync(dest, "utf8")), JSON.parse(fs$1.readFileSync(src, "utf8")));
|
|
1973
|
+
fs$1.writeFileSync(dest, JSON.stringify(settings, null, 2) + "\n");
|
|
2092
1974
|
return;
|
|
2093
1975
|
}
|
|
2094
|
-
if (filename.startsWith("_")) dest = path$
|
|
2095
|
-
if (filename === "_gitignore" && fs.existsSync(dest)) {
|
|
2096
|
-
const existing = fs.readFileSync(dest, "utf8");
|
|
2097
|
-
const newGitignore = fs.readFileSync(src, "utf8");
|
|
2098
|
-
fs.writeFileSync(dest, existing + "\n" + newGitignore);
|
|
1976
|
+
if (filename.startsWith("_")) dest = path$2.resolve(path$2.dirname(dest), filename.replace(/^_/, "."));
|
|
1977
|
+
if (filename === "_gitignore" && fs$1.existsSync(dest)) {
|
|
1978
|
+
const existing = fs$1.readFileSync(dest, "utf8");
|
|
1979
|
+
const newGitignore = fs$1.readFileSync(src, "utf8");
|
|
1980
|
+
fs$1.writeFileSync(dest, existing + "\n" + newGitignore);
|
|
2099
1981
|
return;
|
|
2100
1982
|
}
|
|
2101
1983
|
if (filename.endsWith(".data.mjs")) {
|
|
@@ -2106,17 +1988,17 @@ function renderTemplate(src, dest, callbacks) {
|
|
|
2106
1988
|
});
|
|
2107
1989
|
return;
|
|
2108
1990
|
}
|
|
2109
|
-
fs.copyFileSync(src, dest);
|
|
1991
|
+
fs$1.copyFileSync(src, dest);
|
|
2110
1992
|
}
|
|
2111
1993
|
//#endregion
|
|
2112
1994
|
//#region utils/directoryTraverse.ts
|
|
2113
1995
|
function preOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
|
|
2114
|
-
for (const filename of fs.readdirSync(dir)) {
|
|
1996
|
+
for (const filename of fs$1.readdirSync(dir)) {
|
|
2115
1997
|
if (filename === ".git") continue;
|
|
2116
|
-
const fullpath = path$
|
|
2117
|
-
if (fs.lstatSync(fullpath).isDirectory()) {
|
|
1998
|
+
const fullpath = path$2.resolve(dir, filename);
|
|
1999
|
+
if (fs$1.lstatSync(fullpath).isDirectory()) {
|
|
2118
2000
|
dirCallback(fullpath);
|
|
2119
|
-
if (fs.existsSync(fullpath)) preOrderDirectoryTraverse(fullpath, dirCallback, fileCallback);
|
|
2001
|
+
if (fs$1.existsSync(fullpath)) preOrderDirectoryTraverse(fullpath, dirCallback, fileCallback);
|
|
2120
2002
|
continue;
|
|
2121
2003
|
}
|
|
2122
2004
|
fileCallback(fullpath);
|
|
@@ -2124,13 +2006,13 @@ function preOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
|
|
|
2124
2006
|
}
|
|
2125
2007
|
const dotGitDirectoryState = { hasDotGitDirectory: false };
|
|
2126
2008
|
function postOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
|
|
2127
|
-
for (const filename of fs.readdirSync(dir)) {
|
|
2009
|
+
for (const filename of fs$1.readdirSync(dir)) {
|
|
2128
2010
|
if (filename === ".git") {
|
|
2129
2011
|
dotGitDirectoryState.hasDotGitDirectory = true;
|
|
2130
2012
|
continue;
|
|
2131
2013
|
}
|
|
2132
|
-
const fullpath = path$
|
|
2133
|
-
if (fs.lstatSync(fullpath).isDirectory()) {
|
|
2014
|
+
const fullpath = path$2.resolve(dir, filename);
|
|
2015
|
+
if (fs$1.lstatSync(fullpath).isDirectory()) {
|
|
2134
2016
|
postOrderDirectoryTraverse(fullpath, dirCallback, fileCallback);
|
|
2135
2017
|
dirCallback(fullpath);
|
|
2136
2018
|
continue;
|
|
@@ -2293,43 +2175,43 @@ function getLocale() {
|
|
|
2293
2175
|
return linkLocale((process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG || Intl.DateTimeFormat().resolvedOptions().locale || "en-US").split(".")[0].replace("_", "-"));
|
|
2294
2176
|
}
|
|
2295
2177
|
async function loadLanguageFile(filePath) {
|
|
2296
|
-
return await fs.promises.readFile(filePath, "utf-8").then((data) => {
|
|
2178
|
+
return await fs$1.promises.readFile(filePath, "utf-8").then((data) => {
|
|
2297
2179
|
const parsedData = JSON.parse(data);
|
|
2298
2180
|
if (parsedData) return parsedData;
|
|
2299
2181
|
});
|
|
2300
2182
|
}
|
|
2301
2183
|
async function getLanguage(localesRoot) {
|
|
2302
2184
|
const locale = getLocale();
|
|
2303
|
-
const languageFilePath = path$
|
|
2304
|
-
const fallbackPath = path$
|
|
2305
|
-
return fs.existsSync(languageFilePath) ? await loadLanguageFile(languageFilePath) : await loadLanguageFile(fallbackPath);
|
|
2185
|
+
const languageFilePath = path$2.resolve(localesRoot, `${locale}.json`);
|
|
2186
|
+
const fallbackPath = path$2.resolve(localesRoot, "en-US.json");
|
|
2187
|
+
return fs$1.existsSync(languageFilePath) ? await loadLanguageFile(languageFilePath) : await loadLanguageFile(fallbackPath);
|
|
2306
2188
|
}
|
|
2307
2189
|
//#endregion
|
|
2308
2190
|
//#region utils/trimBoilerplate.ts
|
|
2309
2191
|
function replaceContent(filepath, replacer) {
|
|
2310
|
-
const content = fs.readFileSync(filepath, "utf8");
|
|
2311
|
-
fs.writeFileSync(filepath, replacer(content));
|
|
2192
|
+
const content = fs$1.readFileSync(filepath, "utf8");
|
|
2193
|
+
fs$1.writeFileSync(filepath, replacer(content));
|
|
2312
2194
|
}
|
|
2313
2195
|
function trimBoilerplate(rootDir) {
|
|
2314
|
-
const srcDir = path.resolve(rootDir, "src");
|
|
2315
|
-
for (const filename of fs.readdirSync(srcDir)) {
|
|
2196
|
+
const srcDir = path$1.resolve(rootDir, "src");
|
|
2197
|
+
for (const filename of fs$1.readdirSync(srcDir)) {
|
|
2316
2198
|
if ([
|
|
2317
2199
|
"main.js",
|
|
2318
2200
|
"main.ts",
|
|
2319
2201
|
"router",
|
|
2320
2202
|
"stores"
|
|
2321
2203
|
].includes(filename)) continue;
|
|
2322
|
-
const fullpath = path.resolve(srcDir, filename);
|
|
2323
|
-
fs.rmSync(fullpath, { recursive: true });
|
|
2204
|
+
const fullpath = path$1.resolve(srcDir, filename);
|
|
2205
|
+
fs$1.rmSync(fullpath, { recursive: true });
|
|
2324
2206
|
}
|
|
2325
2207
|
}
|
|
2326
2208
|
function removeCSSImport(rootDir, needsTypeScript, needsCypressCT) {
|
|
2327
|
-
replaceContent(path.resolve(rootDir, needsTypeScript ? "src/main.ts" : "src/main.js"), (content) => content.replace("import './assets/main.css'\n\n", ""));
|
|
2328
|
-
if (needsCypressCT) replaceContent(path.resolve(rootDir, needsTypeScript ? "cypress/support/component.ts" : "cypress/support/component.js"), (content) => content.replace("import '@/assets/main.css'", "// import '@/assets/main.css'"));
|
|
2209
|
+
replaceContent(path$1.resolve(rootDir, needsTypeScript ? "src/main.ts" : "src/main.js"), (content) => content.replace("import './assets/main.css'\n\n", ""));
|
|
2210
|
+
if (needsCypressCT) replaceContent(path$1.resolve(rootDir, needsTypeScript ? "cypress/support/component.ts" : "cypress/support/component.js"), (content) => content.replace("import '@/assets/main.css'", "// import '@/assets/main.css'"));
|
|
2329
2211
|
}
|
|
2330
2212
|
function emptyRouterConfig(rootDir, needsTypeScript) {
|
|
2331
|
-
const srcDir = path.resolve(rootDir, "src");
|
|
2332
|
-
replaceContent(path.resolve(srcDir, needsTypeScript ? "router/index.ts" : "router/index.js"), (content) => content.replace(`import HomeView from '../views/HomeView.vue'\n`, "").replace(/routes:\s*\[[\s\S]*?\],/, "routes: [],"));
|
|
2213
|
+
const srcDir = path$1.resolve(rootDir, "src");
|
|
2214
|
+
replaceContent(path$1.resolve(srcDir, needsTypeScript ? "router/index.ts" : "router/index.js"), (content) => content.replace(`import HomeView from '../views/HomeView.vue'\n`, "").replace(/routes:\s*\[[\s\S]*?\],/, "routes: [],"));
|
|
2333
2215
|
}
|
|
2334
2216
|
//#endregion
|
|
2335
2217
|
//#region utils/applyVueBeta.ts
|
|
@@ -2382,7 +2264,7 @@ peerDependencyRules:
|
|
|
2382
2264
|
allowAny:
|
|
2383
2265
|
- 'vue'
|
|
2384
2266
|
`;
|
|
2385
|
-
fs.writeFileSync(path$
|
|
2267
|
+
fs$1.writeFileSync(path$2.resolve(root, "pnpm-workspace.yaml"), yamlContent, "utf-8");
|
|
2386
2268
|
}
|
|
2387
2269
|
}
|
|
2388
2270
|
//#endregion
|
|
@@ -2412,7 +2294,7 @@ function getPackageManagerOptions(preferred) {
|
|
|
2412
2294
|
//#endregion
|
|
2413
2295
|
//#region package.json
|
|
2414
2296
|
var name = "create-vue";
|
|
2415
|
-
var version = "3.22.
|
|
2297
|
+
var version = "3.22.4";
|
|
2416
2298
|
//#endregion
|
|
2417
2299
|
//#region index.ts
|
|
2418
2300
|
const language = await getLanguage(fileURLToPath(new URL("./locales", import.meta.url)));
|
|
@@ -2480,8 +2362,8 @@ function toValidPackageName(projectName) {
|
|
|
2480
2362
|
return projectName.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-");
|
|
2481
2363
|
}
|
|
2482
2364
|
function canSkipEmptying(dir) {
|
|
2483
|
-
if (!fs.existsSync(dir)) return true;
|
|
2484
|
-
const files = fs.readdirSync(dir);
|
|
2365
|
+
if (!fs$1.existsSync(dir)) return true;
|
|
2366
|
+
const files = fs$1.readdirSync(dir);
|
|
2485
2367
|
if (files.length === 0) return true;
|
|
2486
2368
|
if (files.length === 1 && files[0] === ".git") {
|
|
2487
2369
|
dotGitDirectoryState.hasDotGitDirectory = true;
|
|
@@ -2490,13 +2372,13 @@ function canSkipEmptying(dir) {
|
|
|
2490
2372
|
return false;
|
|
2491
2373
|
}
|
|
2492
2374
|
function emptyDir(dir) {
|
|
2493
|
-
if (!fs.existsSync(dir)) return;
|
|
2494
|
-
postOrderDirectoryTraverse(dir, (dir) => fs.rmdirSync(dir), (file) => fs.unlinkSync(file));
|
|
2375
|
+
if (!fs$1.existsSync(dir)) return;
|
|
2376
|
+
postOrderDirectoryTraverse(dir, (dir) => fs$1.rmdirSync(dir), (file) => fs$1.unlinkSync(file));
|
|
2495
2377
|
}
|
|
2496
2378
|
async function unwrapPrompt(maybeCancelPromise) {
|
|
2497
2379
|
const result = await maybeCancelPromise;
|
|
2498
|
-
if (
|
|
2499
|
-
|
|
2380
|
+
if (isCancel(result)) {
|
|
2381
|
+
cancel((0, import_picocolors.red)("✖") + ` ${language.errors.operationCancelled}`);
|
|
2500
2382
|
process.exit(0);
|
|
2501
2383
|
}
|
|
2502
2384
|
return result;
|
|
@@ -2593,41 +2475,41 @@ async function init() {
|
|
|
2593
2475
|
experimentFeatures: [],
|
|
2594
2476
|
needsBareboneTemplates: false
|
|
2595
2477
|
};
|
|
2596
|
-
|
|
2597
|
-
if (!targetDir) targetDir = result.projectName = result.packageName = (await unwrapPrompt(
|
|
2478
|
+
intro(process.stdout.isTTY && process.stdout.getColorDepth() > 8 ? gradientBanner : defaultBanner);
|
|
2479
|
+
if (!targetDir) targetDir = result.projectName = result.packageName = (await unwrapPrompt(text({
|
|
2598
2480
|
message: language.projectName.message,
|
|
2599
2481
|
placeholder: defaultProjectName,
|
|
2600
2482
|
defaultValue: defaultProjectName,
|
|
2601
2483
|
validate: (value) => !value || value.trim().length > 0 ? void 0 : language.projectName.invalidMessage
|
|
2602
2484
|
})))?.trim() || defaultProjectName;
|
|
2603
2485
|
if (!canSkipEmptying(targetDir) && !forceOverwrite) {
|
|
2604
|
-
result.shouldOverwrite = await unwrapPrompt(
|
|
2486
|
+
result.shouldOverwrite = await unwrapPrompt(confirm({
|
|
2605
2487
|
message: `${targetDir === "." ? language.shouldOverwrite.dirForPrompts.current : `${language.shouldOverwrite.dirForPrompts.target} "${targetDir}"`} ${language.shouldOverwrite.message}`,
|
|
2606
2488
|
initialValue: false
|
|
2607
2489
|
}));
|
|
2608
2490
|
if (!result.shouldOverwrite) {
|
|
2609
|
-
|
|
2491
|
+
cancel((0, import_picocolors.red)("✖") + ` ${language.errors.operationCancelled}`);
|
|
2610
2492
|
process.exit(0);
|
|
2611
2493
|
}
|
|
2612
2494
|
}
|
|
2613
|
-
if (!isValidPackageName(targetDir)) result.packageName = await unwrapPrompt(
|
|
2495
|
+
if (!isValidPackageName(targetDir)) result.packageName = await unwrapPrompt(text({
|
|
2614
2496
|
message: language.packageName.message,
|
|
2615
2497
|
initialValue: toValidPackageName(targetDir),
|
|
2616
2498
|
validate: (value) => isValidPackageName(value) ? void 0 : language.packageName.invalidMessage
|
|
2617
2499
|
}));
|
|
2618
2500
|
if (!isFeatureFlagsUsed) {
|
|
2619
|
-
result.needsTypeScript = await unwrapPrompt(
|
|
2501
|
+
result.needsTypeScript = await unwrapPrompt(confirm({
|
|
2620
2502
|
message: language.needsTypeScript.message,
|
|
2621
2503
|
initialValue: true
|
|
2622
2504
|
}));
|
|
2623
|
-
result.features = await unwrapPrompt(
|
|
2505
|
+
result.features = await unwrapPrompt(multiselect({
|
|
2624
2506
|
message: `${language.featureSelection.message} ${(0, import_picocolors.dim)(language.featureSelection.hint)}`,
|
|
2625
2507
|
options: FEATURE_OPTIONS,
|
|
2626
2508
|
required: false
|
|
2627
2509
|
}));
|
|
2628
2510
|
if (result.features.includes("e2e")) {
|
|
2629
2511
|
const hasVitest = result.features.includes("vitest");
|
|
2630
|
-
result.e2eFramework = await unwrapPrompt(
|
|
2512
|
+
result.e2eFramework = await unwrapPrompt(select({
|
|
2631
2513
|
message: `${language.e2eSelection.message} ${(0, import_picocolors.dim)(language.e2eSelection.hint)}`,
|
|
2632
2514
|
options: [{
|
|
2633
2515
|
value: "playwright",
|
|
@@ -2640,7 +2522,7 @@ async function init() {
|
|
|
2640
2522
|
}]
|
|
2641
2523
|
}));
|
|
2642
2524
|
}
|
|
2643
|
-
result.experimentFeatures = await unwrapPrompt(
|
|
2525
|
+
result.experimentFeatures = await unwrapPrompt(multiselect({
|
|
2644
2526
|
message: `${language.needsExperimentalFeatures.message} ${(0, import_picocolors.dim)(language.needsExperimentalFeatures.hint)}`,
|
|
2645
2527
|
options: EXPERIMENTAL_FEATURE_OPTIONS,
|
|
2646
2528
|
required: false
|
|
@@ -2650,14 +2532,14 @@ async function init() {
|
|
|
2650
2532
|
value: pm,
|
|
2651
2533
|
label: pm
|
|
2652
2534
|
}));
|
|
2653
|
-
result.packageManager = await unwrapPrompt(
|
|
2535
|
+
result.packageManager = await unwrapPrompt(select({
|
|
2654
2536
|
message: `${language.packageManagerSelection.message} ${(0, import_picocolors.dim)(language.packageManagerSelection.hint)}`,
|
|
2655
2537
|
options: packageManagerOptions
|
|
2656
2538
|
}));
|
|
2657
2539
|
}
|
|
2658
2540
|
}
|
|
2659
2541
|
if (argv.bare) result.needsBareboneTemplates = true;
|
|
2660
|
-
else if (!isFeatureFlagsUsed) result.needsBareboneTemplates = await unwrapPrompt(
|
|
2542
|
+
else if (!isFeatureFlagsUsed) result.needsBareboneTemplates = await unwrapPrompt(confirm({
|
|
2661
2543
|
message: language.needsBareboneTemplates.message,
|
|
2662
2544
|
initialValue: false
|
|
2663
2545
|
}));
|
|
@@ -2675,19 +2557,19 @@ async function init() {
|
|
|
2675
2557
|
const needsCypress = argv.cypress || argv.tests || argv["with-tests"] || e2eFramework === "cypress";
|
|
2676
2558
|
const needsCypressCT = needsCypress && !needsVitest;
|
|
2677
2559
|
const needsPlaywright = argv.playwright || e2eFramework === "playwright";
|
|
2678
|
-
const root = path$
|
|
2679
|
-
if (fs.existsSync(root) && result.shouldOverwrite) emptyDir(root);
|
|
2680
|
-
else if (!fs.existsSync(root)) fs.mkdirSync(root);
|
|
2560
|
+
const root = path$2.join(cwd, targetDir);
|
|
2561
|
+
if (fs$1.existsSync(root) && result.shouldOverwrite) emptyDir(root);
|
|
2562
|
+
else if (!fs$1.existsSync(root)) fs$1.mkdirSync(root);
|
|
2681
2563
|
console.log(`\n${language.infos.scaffolding} ${root}...`);
|
|
2682
2564
|
const pkg = {
|
|
2683
2565
|
name: result.packageName,
|
|
2684
2566
|
version: "0.0.0"
|
|
2685
2567
|
};
|
|
2686
|
-
fs.writeFileSync(path$
|
|
2568
|
+
fs$1.writeFileSync(path$2.resolve(root, "package.json"), JSON.stringify(pkg, null, 2));
|
|
2687
2569
|
const templateRoot = fileURLToPath(new URL("./template", import.meta.url));
|
|
2688
2570
|
const callbacks = [];
|
|
2689
2571
|
const render = function render(templateName) {
|
|
2690
|
-
renderTemplate(path$
|
|
2572
|
+
renderTemplate(path$2.resolve(templateRoot, templateName), root, callbacks);
|
|
2691
2573
|
};
|
|
2692
2574
|
render("base");
|
|
2693
2575
|
if (needsJsx) render("config/jsx");
|
|
@@ -2714,7 +2596,7 @@ async function init() {
|
|
|
2714
2596
|
render("tsconfig/vitest");
|
|
2715
2597
|
rootTsConfig.references.push({ path: "./tsconfig.vitest.json" });
|
|
2716
2598
|
}
|
|
2717
|
-
fs.writeFileSync(path$
|
|
2599
|
+
fs$1.writeFileSync(path$2.resolve(root, "tsconfig.json"), JSON.stringify(rootTsConfig, null, 2) + "\n", "utf-8");
|
|
2718
2600
|
}
|
|
2719
2601
|
if (needsEslint) {
|
|
2720
2602
|
render("linting/base");
|
|
@@ -2726,7 +2608,7 @@ async function init() {
|
|
|
2726
2608
|
if (needsVitest) render("linting/vitest");
|
|
2727
2609
|
render("linting/oxlint");
|
|
2728
2610
|
callbacks.push(async (dataStore) => {
|
|
2729
|
-
const oxlintrcPath = path$
|
|
2611
|
+
const oxlintrcPath = path$2.resolve(root, ".oxlintrc.json");
|
|
2730
2612
|
dataStore[oxlintrcPath] = {
|
|
2731
2613
|
needsTypeScript,
|
|
2732
2614
|
needsVitest
|
|
@@ -2745,11 +2627,11 @@ async function init() {
|
|
|
2745
2627
|
for (const cb of callbacks) await cb(dataStore);
|
|
2746
2628
|
preOrderDirectoryTraverse(root, () => {}, (filepath) => {
|
|
2747
2629
|
if (filepath.endsWith(".ejs")) {
|
|
2748
|
-
const template = fs.readFileSync(filepath, "utf-8");
|
|
2630
|
+
const template = fs$1.readFileSync(filepath, "utf-8");
|
|
2749
2631
|
const dest = filepath.replace(/\.ejs$/, "");
|
|
2750
|
-
const content =
|
|
2751
|
-
fs.writeFileSync(dest, content);
|
|
2752
|
-
fs.unlinkSync(filepath);
|
|
2632
|
+
const content = ejs.render(template, dataStore[dest]);
|
|
2633
|
+
fs$1.writeFileSync(dest, content);
|
|
2634
|
+
fs$1.unlinkSync(filepath);
|
|
2753
2635
|
}
|
|
2754
2636
|
});
|
|
2755
2637
|
if (needsBareboneTemplates) {
|
|
@@ -2763,15 +2645,15 @@ async function init() {
|
|
|
2763
2645
|
preOrderDirectoryTraverse(root, () => {}, (filepath) => {
|
|
2764
2646
|
if (filepath.endsWith(".js")) {
|
|
2765
2647
|
const tsFilePath = filepath.replace(/\.js$/, ".ts");
|
|
2766
|
-
if (fs.existsSync(tsFilePath)) fs.unlinkSync(filepath);
|
|
2767
|
-
else fs.renameSync(filepath, tsFilePath);
|
|
2768
|
-
} else if (path$
|
|
2648
|
+
if (fs$1.existsSync(tsFilePath)) fs$1.unlinkSync(filepath);
|
|
2649
|
+
else fs$1.renameSync(filepath, tsFilePath);
|
|
2650
|
+
} else if (path$2.basename(filepath) === "jsconfig.json") fs$1.unlinkSync(filepath);
|
|
2769
2651
|
});
|
|
2770
|
-
const indexHtmlPath = path$
|
|
2771
|
-
const indexHtmlContent = fs.readFileSync(indexHtmlPath, "utf8");
|
|
2772
|
-
fs.writeFileSync(indexHtmlPath, indexHtmlContent.replace("src/main.js", "src/main.ts"));
|
|
2652
|
+
const indexHtmlPath = path$2.resolve(root, "index.html");
|
|
2653
|
+
const indexHtmlContent = fs$1.readFileSync(indexHtmlPath, "utf8");
|
|
2654
|
+
fs$1.writeFileSync(indexHtmlPath, indexHtmlContent.replace("src/main.js", "src/main.ts"));
|
|
2773
2655
|
} else preOrderDirectoryTraverse(root, () => {}, (filepath) => {
|
|
2774
|
-
if (filepath.endsWith(".ts")) fs.unlinkSync(filepath);
|
|
2656
|
+
if (filepath.endsWith(".ts")) fs$1.unlinkSync(filepath);
|
|
2775
2657
|
});
|
|
2776
2658
|
if (needsBareboneTemplates) {
|
|
2777
2659
|
removeCSSImport(root, needsTypeScript, needsCypressCT);
|
|
@@ -2779,12 +2661,12 @@ async function init() {
|
|
|
2779
2661
|
}
|
|
2780
2662
|
const packageManager = result.packageManager ?? inferredPackageManager;
|
|
2781
2663
|
if (needsVueBeta) {
|
|
2782
|
-
const pkgPath = path$
|
|
2783
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
2664
|
+
const pkgPath = path$2.resolve(root, "package.json");
|
|
2665
|
+
const pkg = JSON.parse(fs$1.readFileSync(pkgPath, "utf-8"));
|
|
2784
2666
|
applyVueBeta(root, packageManager, pkg);
|
|
2785
|
-
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
2667
|
+
fs$1.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
2786
2668
|
}
|
|
2787
|
-
fs.writeFileSync(path$
|
|
2669
|
+
fs$1.writeFileSync(path$2.resolve(root, "README.md"), generateReadme({
|
|
2788
2670
|
projectName: result.projectName ?? result.packageName ?? defaultProjectName,
|
|
2789
2671
|
packageManager,
|
|
2790
2672
|
needsTypeScript,
|
|
@@ -2796,7 +2678,7 @@ async function init() {
|
|
|
2796
2678
|
}));
|
|
2797
2679
|
let outroMessage = `${language.infos.done}\n\n`;
|
|
2798
2680
|
if (root !== cwd) {
|
|
2799
|
-
const cdProjectName = path$
|
|
2681
|
+
const cdProjectName = path$2.relative(cwd, root);
|
|
2800
2682
|
outroMessage += ` ${(0, import_picocolors.bold)((0, import_picocolors.green)(`cd ${cdProjectName.includes(" ") ? `"${cdProjectName}"` : cdProjectName}`))}\n`;
|
|
2801
2683
|
}
|
|
2802
2684
|
outroMessage += ` ${(0, import_picocolors.bold)((0, import_picocolors.green)(getCommand(packageManager, "install")))}\n`;
|
|
@@ -2806,7 +2688,7 @@ async function init() {
|
|
|
2806
2688
|
${(0, import_picocolors.dim)("|")} ${language.infos.optionalGitCommand}
|
|
2807
2689
|
|
|
2808
2690
|
${(0, import_picocolors.bold)((0, import_picocolors.green)("git init && git add -A && git commit -m \"initial commit\""))}`;
|
|
2809
|
-
|
|
2691
|
+
outro(outroMessage);
|
|
2810
2692
|
}
|
|
2811
2693
|
init().catch((e) => {
|
|
2812
2694
|
console.error(e);
|