create-vite-react-cli 0.1.0 → 0.4.2
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 +21 -21
- package/README.md +47 -83
- package/dist/index.mjs +2569 -0
- package/index.js +3 -0
- package/locales/en-US.json +42 -0
- package/locales/zh-Hans.json +42 -0
- package/package.json +68 -34
- package/templates/base/_gitignore +25 -0
- package/templates/base/_vscode/extensions.json +3 -0
- package/templates/base/_vscode/settings.json +4 -0
- package/templates/base/package.json +16 -0
- package/templates/{public → base/public}/vite.svg +1 -2
- package/templates/{vite.config.js → base/vite.config.js} +7 -8
- package/templates/{src → code/default/src}/App.css +42 -43
- package/templates/code/default/src/App.jsx +31 -0
- package/templates/code/default/src/assets/react.svg +1 -0
- package/templates/{src → code/default/src}/index.css +68 -69
- package/templates/code/typescript-/src/App.css +42 -0
- package/templates/code/typescript-/src/App.tsx +31 -0
- package/templates/code/typescript-/src/assets/react.svg +1 -0
- package/templates/code/typescript-/src/index.css +68 -0
- package/templates/config/typescript/package.json +7 -0
- package/templates/{index.html → entry/default/index.html.ejs} +13 -14
- package/templates/entry/default/src/main.jsx +10 -0
- package/templates/entry/default/src/main.tsx +10 -0
- package/templates/formatting/prettier/_prettierrc +7 -0
- package/templates/formatting/prettier/package.json +9 -0
- package/templates/linting/base/package.json +12 -0
- package/templates/linting/core/js/eslint.config.js +24 -0
- package/templates/linting/core/ts/eslint.config.js +25 -0
- package/templates/linting/core/ts/package.json +5 -0
- package/templates/linting/prettier/eslint.config.js +3 -0
- package/templates/tsconfig/base/tsconfig.app.json +25 -0
- package/templates/tsconfig/base/tsconfig.node.json +23 -0
- package/bin/cli.js +0 -16
- package/src/index.js +0 -86
- package/templates/README.md +0 -35
- package/templates/package.json +0 -22
- package/templates/public/react.svg +0 -2
- package/templates/src/App.jsx +0 -34
- package/templates/src/main.jsx +0 -11
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2569 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
|
+
import { parseArgs, stripVTControlCharacters } from "node:util";
|
|
6
|
+
import y, { stdin, stdout } from "node:process";
|
|
7
|
+
import * as g from "node:readline";
|
|
8
|
+
import O from "node:readline";
|
|
9
|
+
import { Writable } from "node:stream";
|
|
10
|
+
|
|
11
|
+
//#region rolldown:runtime
|
|
12
|
+
var __create = Object.create;
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
17
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
22
|
+
key = keys[i];
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
24
|
+
__defProp(to, key, {
|
|
25
|
+
get: ((k$2) => from[k$2]).bind(null, key),
|
|
26
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
34
|
+
value: mod,
|
|
35
|
+
enumerable: true
|
|
36
|
+
}) : target, mod));
|
|
37
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region node_modules/.pnpm/ejs@3.1.10/node_modules/ejs/lib/utils.js
|
|
41
|
+
/**
|
|
42
|
+
* Private utility functions
|
|
43
|
+
* @module utils
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
47
|
+
var regExpChars = /[|\\{}()[\]^$+*?.]/g;
|
|
48
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
49
|
+
var hasOwn = function(obj, key) {
|
|
50
|
+
return hasOwnProperty.apply(obj, [key]);
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Escape characters reserved in regular expressions.
|
|
54
|
+
*
|
|
55
|
+
* If `string` is `undefined` or `null`, the empty string is returned.
|
|
56
|
+
*
|
|
57
|
+
* @param {String} string Input string
|
|
58
|
+
* @return {String} Escaped string
|
|
59
|
+
* @static
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
exports.escapeRegExpChars = function(string) {
|
|
63
|
+
// istanbul ignore if
|
|
64
|
+
if (!string) return "";
|
|
65
|
+
return String(string).replace(regExpChars, "\\$&");
|
|
66
|
+
};
|
|
67
|
+
var _ENCODE_HTML_RULES = {
|
|
68
|
+
"&": "&",
|
|
69
|
+
"<": "<",
|
|
70
|
+
">": ">",
|
|
71
|
+
"\"": """,
|
|
72
|
+
"'": "'"
|
|
73
|
+
};
|
|
74
|
+
var _MATCH_HTML = /[&<>'"]/g;
|
|
75
|
+
function encode_char(c) {
|
|
76
|
+
return _ENCODE_HTML_RULES[c] || c;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Stringified version of constants used by {@link module:utils.escapeXML}.
|
|
80
|
+
*
|
|
81
|
+
* It is used in the process of generating {@link ClientFunction}s.
|
|
82
|
+
*
|
|
83
|
+
* @readonly
|
|
84
|
+
* @type {String}
|
|
85
|
+
*/
|
|
86
|
+
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";
|
|
87
|
+
/**
|
|
88
|
+
* Escape characters reserved in XML.
|
|
89
|
+
*
|
|
90
|
+
* If `markup` is `undefined` or `null`, the empty string is returned.
|
|
91
|
+
*
|
|
92
|
+
* @implements {EscapeCallback}
|
|
93
|
+
* @param {String} markup Input string
|
|
94
|
+
* @return {String} Escaped string
|
|
95
|
+
* @static
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
exports.escapeXML = function(markup) {
|
|
99
|
+
return markup == void 0 ? "" : String(markup).replace(_MATCH_HTML, encode_char);
|
|
100
|
+
};
|
|
101
|
+
function escapeXMLToString() {
|
|
102
|
+
return Function.prototype.toString.call(this) + ";\n" + escapeFuncStr;
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
if (typeof Object.defineProperty === "function") Object.defineProperty(exports.escapeXML, "toString", { value: escapeXMLToString });
|
|
106
|
+
else exports.escapeXML.toString = escapeXMLToString;
|
|
107
|
+
} catch (err) {
|
|
108
|
+
console.warn("Unable to set escapeXML.toString (is the Function prototype frozen?)");
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Naive copy of properties from one object to another.
|
|
112
|
+
* Does not recurse into non-scalar properties
|
|
113
|
+
* Does not check to see if the property has a value before copying
|
|
114
|
+
*
|
|
115
|
+
* @param {Object} to Destination object
|
|
116
|
+
* @param {Object} from Source object
|
|
117
|
+
* @return {Object} Destination object
|
|
118
|
+
* @static
|
|
119
|
+
* @private
|
|
120
|
+
*/
|
|
121
|
+
exports.shallowCopy = function(to, from) {
|
|
122
|
+
from = from || {};
|
|
123
|
+
if (to !== null && to !== void 0) for (var p$1 in from) {
|
|
124
|
+
if (!hasOwn(from, p$1)) continue;
|
|
125
|
+
if (p$1 === "__proto__" || p$1 === "constructor") continue;
|
|
126
|
+
to[p$1] = from[p$1];
|
|
127
|
+
}
|
|
128
|
+
return to;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Naive copy of a list of key names, from one object to another.
|
|
132
|
+
* Only copies property if it is actually defined
|
|
133
|
+
* Does not recurse into non-scalar properties
|
|
134
|
+
*
|
|
135
|
+
* @param {Object} to Destination object
|
|
136
|
+
* @param {Object} from Source object
|
|
137
|
+
* @param {Array} list List of properties to copy
|
|
138
|
+
* @return {Object} Destination object
|
|
139
|
+
* @static
|
|
140
|
+
* @private
|
|
141
|
+
*/
|
|
142
|
+
exports.shallowCopyFromList = function(to, from, list) {
|
|
143
|
+
list = list || [];
|
|
144
|
+
from = from || {};
|
|
145
|
+
if (to !== null && to !== void 0) for (var i = 0; i < list.length; i++) {
|
|
146
|
+
var p$1 = list[i];
|
|
147
|
+
if (typeof from[p$1] != "undefined") {
|
|
148
|
+
if (!hasOwn(from, p$1)) continue;
|
|
149
|
+
if (p$1 === "__proto__" || p$1 === "constructor") continue;
|
|
150
|
+
to[p$1] = from[p$1];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return to;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Simple in-process cache implementation. Does not implement limits of any
|
|
157
|
+
* sort.
|
|
158
|
+
*
|
|
159
|
+
* @implements {Cache}
|
|
160
|
+
* @static
|
|
161
|
+
* @private
|
|
162
|
+
*/
|
|
163
|
+
exports.cache = {
|
|
164
|
+
_data: {},
|
|
165
|
+
set: function(key, val) {
|
|
166
|
+
this._data[key] = val;
|
|
167
|
+
},
|
|
168
|
+
get: function(key) {
|
|
169
|
+
return this._data[key];
|
|
170
|
+
},
|
|
171
|
+
remove: function(key) {
|
|
172
|
+
delete this._data[key];
|
|
173
|
+
},
|
|
174
|
+
reset: function() {
|
|
175
|
+
this._data = {};
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Transforms hyphen case variable into camel case.
|
|
180
|
+
*
|
|
181
|
+
* @param {String} string Hyphen case string
|
|
182
|
+
* @return {String} Camel case string
|
|
183
|
+
* @static
|
|
184
|
+
* @private
|
|
185
|
+
*/
|
|
186
|
+
exports.hyphenToCamel = function(str) {
|
|
187
|
+
return str.replace(/-[a-z]/g, function(match) {
|
|
188
|
+
return match[1].toUpperCase();
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Returns a null-prototype object in runtimes that support it
|
|
193
|
+
*
|
|
194
|
+
* @return {Object} Object, prototype will be set to null where possible
|
|
195
|
+
* @static
|
|
196
|
+
* @private
|
|
197
|
+
*/
|
|
198
|
+
exports.createNullProtoObjWherePossible = (function() {
|
|
199
|
+
if (typeof Object.create == "function") return function() {
|
|
200
|
+
return Object.create(null);
|
|
201
|
+
};
|
|
202
|
+
if (!({ __proto__: null } instanceof Object)) return function() {
|
|
203
|
+
return { __proto__: null };
|
|
204
|
+
};
|
|
205
|
+
return function() {
|
|
206
|
+
return {};
|
|
207
|
+
};
|
|
208
|
+
})();
|
|
209
|
+
exports.hasOwnOnlyObject = function(obj) {
|
|
210
|
+
var o$1 = exports.createNullProtoObjWherePossible();
|
|
211
|
+
for (var p$1 in obj) if (hasOwn(obj, p$1)) o$1[p$1] = obj[p$1];
|
|
212
|
+
return o$1;
|
|
213
|
+
};
|
|
214
|
+
}));
|
|
215
|
+
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region node_modules/.pnpm/ejs@3.1.10/node_modules/ejs/package.json
|
|
218
|
+
var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
219
|
+
module.exports = {
|
|
220
|
+
"name": "ejs",
|
|
221
|
+
"description": "Embedded JavaScript templates",
|
|
222
|
+
"keywords": [
|
|
223
|
+
"template",
|
|
224
|
+
"engine",
|
|
225
|
+
"ejs"
|
|
226
|
+
],
|
|
227
|
+
"version": "3.1.10",
|
|
228
|
+
"author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
|
|
229
|
+
"license": "Apache-2.0",
|
|
230
|
+
"bin": { "ejs": "./bin/cli.js" },
|
|
231
|
+
"main": "./lib/ejs.js",
|
|
232
|
+
"jsdelivr": "ejs.min.js",
|
|
233
|
+
"unpkg": "ejs.min.js",
|
|
234
|
+
"repository": {
|
|
235
|
+
"type": "git",
|
|
236
|
+
"url": "git://github.com/mde/ejs.git"
|
|
237
|
+
},
|
|
238
|
+
"bugs": "https://github.com/mde/ejs/issues",
|
|
239
|
+
"homepage": "https://github.com/mde/ejs",
|
|
240
|
+
"dependencies": { "jake": "^10.8.5" },
|
|
241
|
+
"devDependencies": {
|
|
242
|
+
"browserify": "^16.5.1",
|
|
243
|
+
"eslint": "^6.8.0",
|
|
244
|
+
"git-directory-deploy": "^1.5.1",
|
|
245
|
+
"jsdoc": "^4.0.2",
|
|
246
|
+
"lru-cache": "^4.0.1",
|
|
247
|
+
"mocha": "^10.2.0",
|
|
248
|
+
"uglify-js": "^3.3.16"
|
|
249
|
+
},
|
|
250
|
+
"engines": { "node": ">=0.10.0" },
|
|
251
|
+
"scripts": { "test": "npx jake test" }
|
|
252
|
+
};
|
|
253
|
+
}));
|
|
254
|
+
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region node_modules/.pnpm/ejs@3.1.10/node_modules/ejs/lib/ejs.js
|
|
257
|
+
var require_ejs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
258
|
+
/**
|
|
259
|
+
* @file Embedded JavaScript templating engine. {@link http://ejs.co}
|
|
260
|
+
* @author Matthew Eernisse <mde@fleegix.org>
|
|
261
|
+
* @author Tiancheng "Timothy" Gu <timothygu99@gmail.com>
|
|
262
|
+
* @project EJS
|
|
263
|
+
* @license {@link http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0}
|
|
264
|
+
*/
|
|
265
|
+
/**
|
|
266
|
+
* EJS internal functions.
|
|
267
|
+
*
|
|
268
|
+
* Technically this "module" lies in the same file as {@link module:ejs}, for
|
|
269
|
+
* the sake of organization all the private functions re grouped into this
|
|
270
|
+
* module.
|
|
271
|
+
*
|
|
272
|
+
* @module ejs-internal
|
|
273
|
+
* @private
|
|
274
|
+
*/
|
|
275
|
+
/**
|
|
276
|
+
* Embedded JavaScript templating engine.
|
|
277
|
+
*
|
|
278
|
+
* @module ejs
|
|
279
|
+
* @public
|
|
280
|
+
*/
|
|
281
|
+
var fs$1 = __require("fs");
|
|
282
|
+
var path$1 = __require("path");
|
|
283
|
+
var utils = require_utils();
|
|
284
|
+
var scopeOptionWarned = false;
|
|
285
|
+
/** @type {string} */
|
|
286
|
+
var _VERSION_STRING = require_package().version;
|
|
287
|
+
var _DEFAULT_OPEN_DELIMITER = "<";
|
|
288
|
+
var _DEFAULT_CLOSE_DELIMITER = ">";
|
|
289
|
+
var _DEFAULT_DELIMITER = "%";
|
|
290
|
+
var _DEFAULT_LOCALS_NAME = "locals";
|
|
291
|
+
var _NAME = "ejs";
|
|
292
|
+
var _REGEX_STRING = "(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)";
|
|
293
|
+
var _OPTS_PASSABLE_WITH_DATA = [
|
|
294
|
+
"delimiter",
|
|
295
|
+
"scope",
|
|
296
|
+
"context",
|
|
297
|
+
"debug",
|
|
298
|
+
"compileDebug",
|
|
299
|
+
"client",
|
|
300
|
+
"_with",
|
|
301
|
+
"rmWhitespace",
|
|
302
|
+
"strict",
|
|
303
|
+
"filename",
|
|
304
|
+
"async"
|
|
305
|
+
];
|
|
306
|
+
var _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat("cache");
|
|
307
|
+
var _BOM = /^\uFEFF/;
|
|
308
|
+
var _JS_IDENTIFIER = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
|
|
309
|
+
/**
|
|
310
|
+
* EJS template function cache. This can be a LRU object from lru-cache NPM
|
|
311
|
+
* module. By default, it is {@link module:utils.cache}, a simple in-process
|
|
312
|
+
* cache that grows continuously.
|
|
313
|
+
*
|
|
314
|
+
* @type {Cache}
|
|
315
|
+
*/
|
|
316
|
+
exports.cache = utils.cache;
|
|
317
|
+
/**
|
|
318
|
+
* Custom file loader. Useful for template preprocessing or restricting access
|
|
319
|
+
* to a certain part of the filesystem.
|
|
320
|
+
*
|
|
321
|
+
* @type {fileLoader}
|
|
322
|
+
*/
|
|
323
|
+
exports.fileLoader = fs$1.readFileSync;
|
|
324
|
+
/**
|
|
325
|
+
* Name of the object containing the locals.
|
|
326
|
+
*
|
|
327
|
+
* This variable is overridden by {@link Options}`.localsName` if it is not
|
|
328
|
+
* `undefined`.
|
|
329
|
+
*
|
|
330
|
+
* @type {String}
|
|
331
|
+
* @public
|
|
332
|
+
*/
|
|
333
|
+
exports.localsName = _DEFAULT_LOCALS_NAME;
|
|
334
|
+
/**
|
|
335
|
+
* Promise implementation -- defaults to the native implementation if available
|
|
336
|
+
* This is mostly just for testability
|
|
337
|
+
*
|
|
338
|
+
* @type {PromiseConstructorLike}
|
|
339
|
+
* @public
|
|
340
|
+
*/
|
|
341
|
+
exports.promiseImpl = new Function("return this;")().Promise;
|
|
342
|
+
/**
|
|
343
|
+
* Get the path to the included file from the parent file path and the
|
|
344
|
+
* specified path.
|
|
345
|
+
*
|
|
346
|
+
* @param {String} name specified path
|
|
347
|
+
* @param {String} filename parent file path
|
|
348
|
+
* @param {Boolean} [isDir=false] whether the parent file path is a directory
|
|
349
|
+
* @return {String}
|
|
350
|
+
*/
|
|
351
|
+
exports.resolveInclude = function(name$1, filename, isDir) {
|
|
352
|
+
var dirname = path$1.dirname;
|
|
353
|
+
var extname = path$1.extname;
|
|
354
|
+
var resolve = path$1.resolve;
|
|
355
|
+
var includePath = resolve(isDir ? filename : dirname(filename), name$1);
|
|
356
|
+
if (!extname(name$1)) includePath += ".ejs";
|
|
357
|
+
return includePath;
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* Try to resolve file path on multiple directories
|
|
361
|
+
*
|
|
362
|
+
* @param {String} name specified path
|
|
363
|
+
* @param {Array<String>} paths list of possible parent directory paths
|
|
364
|
+
* @return {String}
|
|
365
|
+
*/
|
|
366
|
+
function resolvePaths(name$1, paths) {
|
|
367
|
+
var filePath;
|
|
368
|
+
if (paths.some(function(v$1) {
|
|
369
|
+
filePath = exports.resolveInclude(name$1, v$1, true);
|
|
370
|
+
return fs$1.existsSync(filePath);
|
|
371
|
+
})) return filePath;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Get the path to the included file by Options
|
|
375
|
+
*
|
|
376
|
+
* @param {String} path specified path
|
|
377
|
+
* @param {Options} options compilation options
|
|
378
|
+
* @return {String}
|
|
379
|
+
*/
|
|
380
|
+
function getIncludePath(path$2, options) {
|
|
381
|
+
var includePath;
|
|
382
|
+
var filePath;
|
|
383
|
+
var views = options.views;
|
|
384
|
+
var match = /^[A-Za-z]+:\\|^\//.exec(path$2);
|
|
385
|
+
if (match && match.length) {
|
|
386
|
+
path$2 = path$2.replace(/^\/*/, "");
|
|
387
|
+
if (Array.isArray(options.root)) includePath = resolvePaths(path$2, options.root);
|
|
388
|
+
else includePath = exports.resolveInclude(path$2, options.root || "/", true);
|
|
389
|
+
} else {
|
|
390
|
+
if (options.filename) {
|
|
391
|
+
filePath = exports.resolveInclude(path$2, options.filename);
|
|
392
|
+
if (fs$1.existsSync(filePath)) includePath = filePath;
|
|
393
|
+
}
|
|
394
|
+
if (!includePath && Array.isArray(views)) includePath = resolvePaths(path$2, views);
|
|
395
|
+
if (!includePath && typeof options.includer !== "function") throw new Error("Could not find the include file \"" + options.escapeFunction(path$2) + "\"");
|
|
396
|
+
}
|
|
397
|
+
return includePath;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Get the template from a string or a file, either compiled on-the-fly or
|
|
401
|
+
* read from cache (if enabled), and cache the template if needed.
|
|
402
|
+
*
|
|
403
|
+
* If `template` is not set, the file specified in `options.filename` will be
|
|
404
|
+
* read.
|
|
405
|
+
*
|
|
406
|
+
* If `options.cache` is true, this function reads the file from
|
|
407
|
+
* `options.filename` so it must be set prior to calling this function.
|
|
408
|
+
*
|
|
409
|
+
* @memberof module:ejs-internal
|
|
410
|
+
* @param {Options} options compilation options
|
|
411
|
+
* @param {String} [template] template source
|
|
412
|
+
* @return {(TemplateFunction|ClientFunction)}
|
|
413
|
+
* Depending on the value of `options.client`, either type might be returned.
|
|
414
|
+
* @static
|
|
415
|
+
*/
|
|
416
|
+
function handleCache(options, template) {
|
|
417
|
+
var func;
|
|
418
|
+
var filename = options.filename;
|
|
419
|
+
var hasTemplate = arguments.length > 1;
|
|
420
|
+
if (options.cache) {
|
|
421
|
+
if (!filename) throw new Error("cache option requires a filename");
|
|
422
|
+
func = exports.cache.get(filename);
|
|
423
|
+
if (func) return func;
|
|
424
|
+
if (!hasTemplate) template = fileLoader(filename).toString().replace(_BOM, "");
|
|
425
|
+
} else if (!hasTemplate) {
|
|
426
|
+
// istanbul ignore if: should not happen at all
|
|
427
|
+
if (!filename) throw new Error("Internal EJS error: no file name or template provided");
|
|
428
|
+
template = fileLoader(filename).toString().replace(_BOM, "");
|
|
429
|
+
}
|
|
430
|
+
func = exports.compile(template, options);
|
|
431
|
+
if (options.cache) exports.cache.set(filename, func);
|
|
432
|
+
return func;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Try calling handleCache with the given options and data and call the
|
|
436
|
+
* callback with the result. If an error occurs, call the callback with
|
|
437
|
+
* the error. Used by renderFile().
|
|
438
|
+
*
|
|
439
|
+
* @memberof module:ejs-internal
|
|
440
|
+
* @param {Options} options compilation options
|
|
441
|
+
* @param {Object} data template data
|
|
442
|
+
* @param {RenderFileCallback} cb callback
|
|
443
|
+
* @static
|
|
444
|
+
*/
|
|
445
|
+
function tryHandleCache(options, data, cb) {
|
|
446
|
+
var result;
|
|
447
|
+
if (!cb) if (typeof exports.promiseImpl == "function") return new exports.promiseImpl(function(resolve, reject) {
|
|
448
|
+
try {
|
|
449
|
+
result = handleCache(options)(data);
|
|
450
|
+
resolve(result);
|
|
451
|
+
} catch (err) {
|
|
452
|
+
reject(err);
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
else throw new Error("Please provide a callback function");
|
|
456
|
+
else {
|
|
457
|
+
try {
|
|
458
|
+
result = handleCache(options)(data);
|
|
459
|
+
} catch (err) {
|
|
460
|
+
return cb(err);
|
|
461
|
+
}
|
|
462
|
+
cb(null, result);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* fileLoader is independent
|
|
467
|
+
*
|
|
468
|
+
* @param {String} filePath ejs file path.
|
|
469
|
+
* @return {String} The contents of the specified file.
|
|
470
|
+
* @static
|
|
471
|
+
*/
|
|
472
|
+
function fileLoader(filePath) {
|
|
473
|
+
return exports.fileLoader(filePath);
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Get the template function.
|
|
477
|
+
*
|
|
478
|
+
* If `options.cache` is `true`, then the template is cached.
|
|
479
|
+
*
|
|
480
|
+
* @memberof module:ejs-internal
|
|
481
|
+
* @param {String} path path for the specified file
|
|
482
|
+
* @param {Options} options compilation options
|
|
483
|
+
* @return {(TemplateFunction|ClientFunction)}
|
|
484
|
+
* Depending on the value of `options.client`, either type might be returned
|
|
485
|
+
* @static
|
|
486
|
+
*/
|
|
487
|
+
function includeFile(path$2, options) {
|
|
488
|
+
var opts = utils.shallowCopy(utils.createNullProtoObjWherePossible(), options);
|
|
489
|
+
opts.filename = getIncludePath(path$2, opts);
|
|
490
|
+
if (typeof options.includer === "function") {
|
|
491
|
+
var includerResult = options.includer(path$2, opts.filename);
|
|
492
|
+
if (includerResult) {
|
|
493
|
+
if (includerResult.filename) opts.filename = includerResult.filename;
|
|
494
|
+
if (includerResult.template) return handleCache(opts, includerResult.template);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return handleCache(opts);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Re-throw the given `err` in context to the `str` of ejs, `filename`, and
|
|
501
|
+
* `lineno`.
|
|
502
|
+
*
|
|
503
|
+
* @implements {RethrowCallback}
|
|
504
|
+
* @memberof module:ejs-internal
|
|
505
|
+
* @param {Error} err Error object
|
|
506
|
+
* @param {String} str EJS source
|
|
507
|
+
* @param {String} flnm file name of the EJS file
|
|
508
|
+
* @param {Number} lineno line number of the error
|
|
509
|
+
* @param {EscapeCallback} esc
|
|
510
|
+
* @static
|
|
511
|
+
*/
|
|
512
|
+
function rethrow(err, str, flnm, lineno, esc) {
|
|
513
|
+
var lines = str.split("\n");
|
|
514
|
+
var start = Math.max(lineno - 3, 0);
|
|
515
|
+
var end = Math.min(lines.length, lineno + 3);
|
|
516
|
+
var filename = esc(flnm);
|
|
517
|
+
var context = lines.slice(start, end).map(function(line, i) {
|
|
518
|
+
var curr = i + start + 1;
|
|
519
|
+
return (curr == lineno ? " >> " : " ") + curr + "| " + line;
|
|
520
|
+
}).join("\n");
|
|
521
|
+
err.path = filename;
|
|
522
|
+
err.message = (filename || "ejs") + ":" + lineno + "\n" + context + "\n\n" + err.message;
|
|
523
|
+
throw err;
|
|
524
|
+
}
|
|
525
|
+
function stripSemi(str) {
|
|
526
|
+
return str.replace(/;(\s*$)/, "$1");
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Compile the given `str` of ejs into a template function.
|
|
530
|
+
*
|
|
531
|
+
* @param {String} template EJS template
|
|
532
|
+
*
|
|
533
|
+
* @param {Options} [opts] compilation options
|
|
534
|
+
*
|
|
535
|
+
* @return {(TemplateFunction|ClientFunction)}
|
|
536
|
+
* Depending on the value of `opts.client`, either type might be returned.
|
|
537
|
+
* Note that the return type of the function also depends on the value of `opts.async`.
|
|
538
|
+
* @public
|
|
539
|
+
*/
|
|
540
|
+
exports.compile = function compile(template, opts) {
|
|
541
|
+
var templ;
|
|
542
|
+
if (opts && opts.scope) {
|
|
543
|
+
if (!scopeOptionWarned) {
|
|
544
|
+
console.warn("`scope` option is deprecated and will be removed in EJS 3");
|
|
545
|
+
scopeOptionWarned = true;
|
|
546
|
+
}
|
|
547
|
+
if (!opts.context) opts.context = opts.scope;
|
|
548
|
+
delete opts.scope;
|
|
549
|
+
}
|
|
550
|
+
templ = new Template(template, opts);
|
|
551
|
+
return templ.compile();
|
|
552
|
+
};
|
|
553
|
+
/**
|
|
554
|
+
* Render the given `template` of ejs.
|
|
555
|
+
*
|
|
556
|
+
* If you would like to include options but not data, you need to explicitly
|
|
557
|
+
* call this function with `data` being an empty object or `null`.
|
|
558
|
+
*
|
|
559
|
+
* @param {String} template EJS template
|
|
560
|
+
* @param {Object} [data={}] template data
|
|
561
|
+
* @param {Options} [opts={}] compilation and rendering options
|
|
562
|
+
* @return {(String|Promise<String>)}
|
|
563
|
+
* Return value type depends on `opts.async`.
|
|
564
|
+
* @public
|
|
565
|
+
*/
|
|
566
|
+
exports.render = function(template, d$2, o$1) {
|
|
567
|
+
var data = d$2 || utils.createNullProtoObjWherePossible();
|
|
568
|
+
var opts = o$1 || utils.createNullProtoObjWherePossible();
|
|
569
|
+
if (arguments.length == 2) utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);
|
|
570
|
+
return handleCache(opts, template)(data);
|
|
571
|
+
};
|
|
572
|
+
/**
|
|
573
|
+
* Render an EJS file at the given `path` and callback `cb(err, str)`.
|
|
574
|
+
*
|
|
575
|
+
* If you would like to include options but not data, you need to explicitly
|
|
576
|
+
* call this function with `data` being an empty object or `null`.
|
|
577
|
+
*
|
|
578
|
+
* @param {String} path path to the EJS file
|
|
579
|
+
* @param {Object} [data={}] template data
|
|
580
|
+
* @param {Options} [opts={}] compilation and rendering options
|
|
581
|
+
* @param {RenderFileCallback} cb callback
|
|
582
|
+
* @public
|
|
583
|
+
*/
|
|
584
|
+
exports.renderFile = function() {
|
|
585
|
+
var args = Array.prototype.slice.call(arguments);
|
|
586
|
+
var filename = args.shift();
|
|
587
|
+
var cb;
|
|
588
|
+
var opts = { filename };
|
|
589
|
+
var data;
|
|
590
|
+
var viewOpts;
|
|
591
|
+
if (typeof arguments[arguments.length - 1] == "function") cb = args.pop();
|
|
592
|
+
if (args.length) {
|
|
593
|
+
data = args.shift();
|
|
594
|
+
if (args.length) utils.shallowCopy(opts, args.pop());
|
|
595
|
+
else {
|
|
596
|
+
if (data.settings) {
|
|
597
|
+
if (data.settings.views) opts.views = data.settings.views;
|
|
598
|
+
if (data.settings["view cache"]) opts.cache = true;
|
|
599
|
+
viewOpts = data.settings["view options"];
|
|
600
|
+
if (viewOpts) utils.shallowCopy(opts, viewOpts);
|
|
601
|
+
}
|
|
602
|
+
utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA_EXPRESS);
|
|
603
|
+
}
|
|
604
|
+
opts.filename = filename;
|
|
605
|
+
} else data = utils.createNullProtoObjWherePossible();
|
|
606
|
+
return tryHandleCache(opts, data, cb);
|
|
607
|
+
};
|
|
608
|
+
/**
|
|
609
|
+
* Clear intermediate JavaScript cache. Calls {@link Cache#reset}.
|
|
610
|
+
* @public
|
|
611
|
+
*/
|
|
612
|
+
/**
|
|
613
|
+
* EJS template class
|
|
614
|
+
* @public
|
|
615
|
+
*/
|
|
616
|
+
exports.Template = Template;
|
|
617
|
+
exports.clearCache = function() {
|
|
618
|
+
exports.cache.reset();
|
|
619
|
+
};
|
|
620
|
+
function Template(text, optsParam) {
|
|
621
|
+
var opts = utils.hasOwnOnlyObject(optsParam);
|
|
622
|
+
var options = utils.createNullProtoObjWherePossible();
|
|
623
|
+
this.templateText = text;
|
|
624
|
+
/** @type {string | null} */
|
|
625
|
+
this.mode = null;
|
|
626
|
+
this.truncate = false;
|
|
627
|
+
this.currentLine = 1;
|
|
628
|
+
this.source = "";
|
|
629
|
+
options.client = opts.client || false;
|
|
630
|
+
options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
|
|
631
|
+
options.compileDebug = opts.compileDebug !== false;
|
|
632
|
+
options.debug = !!opts.debug;
|
|
633
|
+
options.filename = opts.filename;
|
|
634
|
+
options.openDelimiter = opts.openDelimiter || exports.openDelimiter || _DEFAULT_OPEN_DELIMITER;
|
|
635
|
+
options.closeDelimiter = opts.closeDelimiter || exports.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;
|
|
636
|
+
options.delimiter = opts.delimiter || exports.delimiter || _DEFAULT_DELIMITER;
|
|
637
|
+
options.strict = opts.strict || false;
|
|
638
|
+
options.context = opts.context;
|
|
639
|
+
options.cache = opts.cache || false;
|
|
640
|
+
options.rmWhitespace = opts.rmWhitespace;
|
|
641
|
+
options.root = opts.root;
|
|
642
|
+
options.includer = opts.includer;
|
|
643
|
+
options.outputFunctionName = opts.outputFunctionName;
|
|
644
|
+
options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
|
|
645
|
+
options.views = opts.views;
|
|
646
|
+
options.async = opts.async;
|
|
647
|
+
options.destructuredLocals = opts.destructuredLocals;
|
|
648
|
+
options.legacyInclude = typeof opts.legacyInclude != "undefined" ? !!opts.legacyInclude : true;
|
|
649
|
+
if (options.strict) options._with = false;
|
|
650
|
+
else options._with = typeof opts._with != "undefined" ? opts._with : true;
|
|
651
|
+
this.opts = options;
|
|
652
|
+
this.regex = this.createRegex();
|
|
653
|
+
}
|
|
654
|
+
Template.modes = {
|
|
655
|
+
EVAL: "eval",
|
|
656
|
+
ESCAPED: "escaped",
|
|
657
|
+
RAW: "raw",
|
|
658
|
+
COMMENT: "comment",
|
|
659
|
+
LITERAL: "literal"
|
|
660
|
+
};
|
|
661
|
+
Template.prototype = {
|
|
662
|
+
createRegex: function() {
|
|
663
|
+
var str = _REGEX_STRING;
|
|
664
|
+
var delim = utils.escapeRegExpChars(this.opts.delimiter);
|
|
665
|
+
var open = utils.escapeRegExpChars(this.opts.openDelimiter);
|
|
666
|
+
var close = utils.escapeRegExpChars(this.opts.closeDelimiter);
|
|
667
|
+
str = str.replace(/%/g, delim).replace(/</g, open).replace(/>/g, close);
|
|
668
|
+
return new RegExp(str);
|
|
669
|
+
},
|
|
670
|
+
compile: function() {
|
|
671
|
+
/** @type {string} */
|
|
672
|
+
var src;
|
|
673
|
+
/** @type {ClientFunction} */
|
|
674
|
+
var fn;
|
|
675
|
+
var opts = this.opts;
|
|
676
|
+
var prepended = "";
|
|
677
|
+
var appended = "";
|
|
678
|
+
/** @type {EscapeCallback} */
|
|
679
|
+
var escapeFn = opts.escapeFunction;
|
|
680
|
+
/** @type {FunctionConstructor} */
|
|
681
|
+
var ctor;
|
|
682
|
+
/** @type {string} */
|
|
683
|
+
var sanitizedFilename = opts.filename ? JSON.stringify(opts.filename) : "undefined";
|
|
684
|
+
if (!this.source) {
|
|
685
|
+
this.generateSource();
|
|
686
|
+
prepended += " var __output = \"\";\n function __append(s) { if (s !== undefined && s !== null) __output += s }\n";
|
|
687
|
+
if (opts.outputFunctionName) {
|
|
688
|
+
if (!_JS_IDENTIFIER.test(opts.outputFunctionName)) throw new Error("outputFunctionName is not a valid JS identifier.");
|
|
689
|
+
prepended += " var " + opts.outputFunctionName + " = __append;\n";
|
|
690
|
+
}
|
|
691
|
+
if (opts.localsName && !_JS_IDENTIFIER.test(opts.localsName)) throw new Error("localsName is not a valid JS identifier.");
|
|
692
|
+
if (opts.destructuredLocals && opts.destructuredLocals.length) {
|
|
693
|
+
var destructuring = " var __locals = (" + opts.localsName + " || {}),\n";
|
|
694
|
+
for (var i = 0; i < opts.destructuredLocals.length; i++) {
|
|
695
|
+
var name$1 = opts.destructuredLocals[i];
|
|
696
|
+
if (!_JS_IDENTIFIER.test(name$1)) throw new Error("destructuredLocals[" + i + "] is not a valid JS identifier.");
|
|
697
|
+
if (i > 0) destructuring += ",\n ";
|
|
698
|
+
destructuring += name$1 + " = __locals." + name$1;
|
|
699
|
+
}
|
|
700
|
+
prepended += destructuring + ";\n";
|
|
701
|
+
}
|
|
702
|
+
if (opts._with !== false) {
|
|
703
|
+
prepended += " with (" + opts.localsName + " || {}) {\n";
|
|
704
|
+
appended += " }\n";
|
|
705
|
+
}
|
|
706
|
+
appended += " return __output;\n";
|
|
707
|
+
this.source = prepended + this.source + appended;
|
|
708
|
+
}
|
|
709
|
+
if (opts.compileDebug) src = "var __line = 1\n , __lines = " + JSON.stringify(this.templateText) + "\n , __filename = " + sanitizedFilename + ";\ntry {\n" + this.source + "} catch (e) {\n rethrow(e, __lines, __filename, __line, escapeFn);\n}\n";
|
|
710
|
+
else src = this.source;
|
|
711
|
+
if (opts.client) {
|
|
712
|
+
src = "escapeFn = escapeFn || " + escapeFn.toString() + ";\n" + src;
|
|
713
|
+
if (opts.compileDebug) src = "rethrow = rethrow || " + rethrow.toString() + ";\n" + src;
|
|
714
|
+
}
|
|
715
|
+
if (opts.strict) src = "\"use strict\";\n" + src;
|
|
716
|
+
if (opts.debug) console.log(src);
|
|
717
|
+
if (opts.compileDebug && opts.filename) src = src + "\n//# sourceURL=" + sanitizedFilename + "\n";
|
|
718
|
+
try {
|
|
719
|
+
if (opts.async) try {
|
|
720
|
+
ctor = new Function("return (async function(){}).constructor;")();
|
|
721
|
+
} catch (e$1) {
|
|
722
|
+
if (e$1 instanceof SyntaxError) throw new Error("This environment does not support async/await");
|
|
723
|
+
else throw e$1;
|
|
724
|
+
}
|
|
725
|
+
else ctor = Function;
|
|
726
|
+
fn = new ctor(opts.localsName + ", escapeFn, include, rethrow", src);
|
|
727
|
+
} catch (e$1) {
|
|
728
|
+
// istanbul ignore else
|
|
729
|
+
if (e$1 instanceof SyntaxError) {
|
|
730
|
+
if (opts.filename) e$1.message += " in " + opts.filename;
|
|
731
|
+
e$1.message += " while compiling ejs\n\n";
|
|
732
|
+
e$1.message += "If the above error is not helpful, you may want to try EJS-Lint:\n";
|
|
733
|
+
e$1.message += "https://github.com/RyanZim/EJS-Lint";
|
|
734
|
+
if (!opts.async) {
|
|
735
|
+
e$1.message += "\n";
|
|
736
|
+
e$1.message += "Or, if you meant to create an async function, pass `async: true` as an option.";
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
throw e$1;
|
|
740
|
+
}
|
|
741
|
+
var returnedFn = opts.client ? fn : function anonymous(data) {
|
|
742
|
+
var include = function(path$2, includeData) {
|
|
743
|
+
var d$2 = utils.shallowCopy(utils.createNullProtoObjWherePossible(), data);
|
|
744
|
+
if (includeData) d$2 = utils.shallowCopy(d$2, includeData);
|
|
745
|
+
return includeFile(path$2, opts)(d$2);
|
|
746
|
+
};
|
|
747
|
+
return fn.apply(opts.context, [
|
|
748
|
+
data || utils.createNullProtoObjWherePossible(),
|
|
749
|
+
escapeFn,
|
|
750
|
+
include,
|
|
751
|
+
rethrow
|
|
752
|
+
]);
|
|
753
|
+
};
|
|
754
|
+
if (opts.filename && typeof Object.defineProperty === "function") {
|
|
755
|
+
var filename = opts.filename;
|
|
756
|
+
var basename = path$1.basename(filename, path$1.extname(filename));
|
|
757
|
+
try {
|
|
758
|
+
Object.defineProperty(returnedFn, "name", {
|
|
759
|
+
value: basename,
|
|
760
|
+
writable: false,
|
|
761
|
+
enumerable: false,
|
|
762
|
+
configurable: true
|
|
763
|
+
});
|
|
764
|
+
} catch (e$1) {}
|
|
765
|
+
}
|
|
766
|
+
return returnedFn;
|
|
767
|
+
},
|
|
768
|
+
generateSource: function() {
|
|
769
|
+
if (this.opts.rmWhitespace) this.templateText = this.templateText.replace(/[\r\n]+/g, "\n").replace(/^\s+|\s+$/gm, "");
|
|
770
|
+
this.templateText = this.templateText.replace(/[ \t]*<%_/gm, "<%_").replace(/_%>[ \t]*/gm, "_%>");
|
|
771
|
+
var self = this;
|
|
772
|
+
var matches = this.parseTemplateText();
|
|
773
|
+
var d$2 = this.opts.delimiter;
|
|
774
|
+
var o$1 = this.opts.openDelimiter;
|
|
775
|
+
var c = this.opts.closeDelimiter;
|
|
776
|
+
if (matches && matches.length) matches.forEach(function(line, index) {
|
|
777
|
+
var closing;
|
|
778
|
+
if (line.indexOf(o$1 + d$2) === 0 && line.indexOf(o$1 + d$2 + d$2) !== 0) {
|
|
779
|
+
closing = matches[index + 2];
|
|
780
|
+
if (!(closing == d$2 + c || closing == "-" + d$2 + c || closing == "_" + d$2 + c)) throw new Error("Could not find matching close tag for \"" + line + "\".");
|
|
781
|
+
}
|
|
782
|
+
self.scanLine(line);
|
|
783
|
+
});
|
|
784
|
+
},
|
|
785
|
+
parseTemplateText: function() {
|
|
786
|
+
var str = this.templateText;
|
|
787
|
+
var pat = this.regex;
|
|
788
|
+
var result = pat.exec(str);
|
|
789
|
+
var arr = [];
|
|
790
|
+
var firstPos;
|
|
791
|
+
while (result) {
|
|
792
|
+
firstPos = result.index;
|
|
793
|
+
if (firstPos !== 0) {
|
|
794
|
+
arr.push(str.substring(0, firstPos));
|
|
795
|
+
str = str.slice(firstPos);
|
|
796
|
+
}
|
|
797
|
+
arr.push(result[0]);
|
|
798
|
+
str = str.slice(result[0].length);
|
|
799
|
+
result = pat.exec(str);
|
|
800
|
+
}
|
|
801
|
+
if (str) arr.push(str);
|
|
802
|
+
return arr;
|
|
803
|
+
},
|
|
804
|
+
_addOutput: function(line) {
|
|
805
|
+
if (this.truncate) {
|
|
806
|
+
line = line.replace(/^(?:\r\n|\r|\n)/, "");
|
|
807
|
+
this.truncate = false;
|
|
808
|
+
}
|
|
809
|
+
if (!line) return line;
|
|
810
|
+
line = line.replace(/\\/g, "\\\\");
|
|
811
|
+
line = line.replace(/\n/g, "\\n");
|
|
812
|
+
line = line.replace(/\r/g, "\\r");
|
|
813
|
+
line = line.replace(/"/g, "\\\"");
|
|
814
|
+
this.source += " ; __append(\"" + line + "\")\n";
|
|
815
|
+
},
|
|
816
|
+
scanLine: function(line) {
|
|
817
|
+
var self = this;
|
|
818
|
+
var d$2 = this.opts.delimiter;
|
|
819
|
+
var o$1 = this.opts.openDelimiter;
|
|
820
|
+
var c = this.opts.closeDelimiter;
|
|
821
|
+
var newLineCount = 0;
|
|
822
|
+
newLineCount = line.split("\n").length - 1;
|
|
823
|
+
switch (line) {
|
|
824
|
+
case o$1 + d$2:
|
|
825
|
+
case o$1 + d$2 + "_":
|
|
826
|
+
this.mode = Template.modes.EVAL;
|
|
827
|
+
break;
|
|
828
|
+
case o$1 + d$2 + "=":
|
|
829
|
+
this.mode = Template.modes.ESCAPED;
|
|
830
|
+
break;
|
|
831
|
+
case o$1 + d$2 + "-":
|
|
832
|
+
this.mode = Template.modes.RAW;
|
|
833
|
+
break;
|
|
834
|
+
case o$1 + d$2 + "#":
|
|
835
|
+
this.mode = Template.modes.COMMENT;
|
|
836
|
+
break;
|
|
837
|
+
case o$1 + d$2 + d$2:
|
|
838
|
+
this.mode = Template.modes.LITERAL;
|
|
839
|
+
this.source += " ; __append(\"" + line.replace(o$1 + d$2 + d$2, o$1 + d$2) + "\")\n";
|
|
840
|
+
break;
|
|
841
|
+
case d$2 + d$2 + c:
|
|
842
|
+
this.mode = Template.modes.LITERAL;
|
|
843
|
+
this.source += " ; __append(\"" + line.replace(d$2 + d$2 + c, d$2 + c) + "\")\n";
|
|
844
|
+
break;
|
|
845
|
+
case d$2 + c:
|
|
846
|
+
case "-" + d$2 + c:
|
|
847
|
+
case "_" + d$2 + c:
|
|
848
|
+
if (this.mode == Template.modes.LITERAL) this._addOutput(line);
|
|
849
|
+
this.mode = null;
|
|
850
|
+
this.truncate = line.indexOf("-") === 0 || line.indexOf("_") === 0;
|
|
851
|
+
break;
|
|
852
|
+
default: if (this.mode) {
|
|
853
|
+
switch (this.mode) {
|
|
854
|
+
case Template.modes.EVAL:
|
|
855
|
+
case Template.modes.ESCAPED:
|
|
856
|
+
case Template.modes.RAW: if (line.lastIndexOf("//") > line.lastIndexOf("\n")) line += "\n";
|
|
857
|
+
}
|
|
858
|
+
switch (this.mode) {
|
|
859
|
+
case Template.modes.EVAL:
|
|
860
|
+
this.source += " ; " + line + "\n";
|
|
861
|
+
break;
|
|
862
|
+
case Template.modes.ESCAPED:
|
|
863
|
+
this.source += " ; __append(escapeFn(" + stripSemi(line) + "))\n";
|
|
864
|
+
break;
|
|
865
|
+
case Template.modes.RAW:
|
|
866
|
+
this.source += " ; __append(" + stripSemi(line) + ")\n";
|
|
867
|
+
break;
|
|
868
|
+
case Template.modes.COMMENT: break;
|
|
869
|
+
case Template.modes.LITERAL:
|
|
870
|
+
this._addOutput(line);
|
|
871
|
+
break;
|
|
872
|
+
}
|
|
873
|
+
} else this._addOutput(line);
|
|
874
|
+
}
|
|
875
|
+
if (self.opts.compileDebug && newLineCount) {
|
|
876
|
+
this.currentLine += newLineCount;
|
|
877
|
+
this.source += " ; __line = " + this.currentLine + "\n";
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
/**
|
|
882
|
+
* Escape characters reserved in XML.
|
|
883
|
+
*
|
|
884
|
+
* This is simply an export of {@link module:utils.escapeXML}.
|
|
885
|
+
*
|
|
886
|
+
* If `markup` is `undefined` or `null`, the empty string is returned.
|
|
887
|
+
*
|
|
888
|
+
* @param {String} markup Input string
|
|
889
|
+
* @return {String} Escaped string
|
|
890
|
+
* @public
|
|
891
|
+
* @func
|
|
892
|
+
* */
|
|
893
|
+
exports.escapeXML = utils.escapeXML;
|
|
894
|
+
/**
|
|
895
|
+
* Express.js support.
|
|
896
|
+
*
|
|
897
|
+
* This is an alias for {@link module:ejs.renderFile}, in order to support
|
|
898
|
+
* Express.js out-of-the-box.
|
|
899
|
+
*
|
|
900
|
+
* @func
|
|
901
|
+
*/
|
|
902
|
+
exports.__express = exports.renderFile;
|
|
903
|
+
/**
|
|
904
|
+
* Version of EJS.
|
|
905
|
+
*
|
|
906
|
+
* @readonly
|
|
907
|
+
* @type {String}
|
|
908
|
+
* @public
|
|
909
|
+
*/
|
|
910
|
+
exports.VERSION = _VERSION_STRING;
|
|
911
|
+
/**
|
|
912
|
+
* Name for detection of EJS.
|
|
913
|
+
*
|
|
914
|
+
* @readonly
|
|
915
|
+
* @type {String}
|
|
916
|
+
* @public
|
|
917
|
+
*/
|
|
918
|
+
exports.name = _NAME;
|
|
919
|
+
/* istanbul ignore if */
|
|
920
|
+
if (typeof window != "undefined") window.ejs = exports;
|
|
921
|
+
}));
|
|
922
|
+
|
|
923
|
+
//#endregion
|
|
924
|
+
//#region node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
925
|
+
var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
926
|
+
const ESC = "\x1B";
|
|
927
|
+
const CSI = `${ESC}[`;
|
|
928
|
+
const beep = "\x07";
|
|
929
|
+
const cursor = {
|
|
930
|
+
to(x$2, y$2) {
|
|
931
|
+
if (!y$2) return `${CSI}${x$2 + 1}G`;
|
|
932
|
+
return `${CSI}${y$2 + 1};${x$2 + 1}H`;
|
|
933
|
+
},
|
|
934
|
+
move(x$2, y$2) {
|
|
935
|
+
let ret = "";
|
|
936
|
+
if (x$2 < 0) ret += `${CSI}${-x$2}D`;
|
|
937
|
+
else if (x$2 > 0) ret += `${CSI}${x$2}C`;
|
|
938
|
+
if (y$2 < 0) ret += `${CSI}${-y$2}A`;
|
|
939
|
+
else if (y$2 > 0) ret += `${CSI}${y$2}B`;
|
|
940
|
+
return ret;
|
|
941
|
+
},
|
|
942
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
943
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
944
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
945
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
946
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
947
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
948
|
+
left: `${CSI}G`,
|
|
949
|
+
hide: `${CSI}?25l`,
|
|
950
|
+
show: `${CSI}?25h`,
|
|
951
|
+
save: `${ESC}7`,
|
|
952
|
+
restore: `${ESC}8`
|
|
953
|
+
};
|
|
954
|
+
const scroll = {
|
|
955
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
956
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
957
|
+
};
|
|
958
|
+
const erase = {
|
|
959
|
+
screen: `${CSI}2J`,
|
|
960
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
961
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
962
|
+
line: `${CSI}2K`,
|
|
963
|
+
lineEnd: `${CSI}K`,
|
|
964
|
+
lineStart: `${CSI}1K`,
|
|
965
|
+
lines(count) {
|
|
966
|
+
let clear = "";
|
|
967
|
+
for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
968
|
+
if (count) clear += cursor.left;
|
|
969
|
+
return clear;
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
module.exports = {
|
|
973
|
+
cursor,
|
|
974
|
+
scroll,
|
|
975
|
+
erase,
|
|
976
|
+
beep
|
|
977
|
+
};
|
|
978
|
+
}));
|
|
979
|
+
|
|
980
|
+
//#endregion
|
|
981
|
+
//#region node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
982
|
+
var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
983
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
984
|
+
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);
|
|
985
|
+
let formatter = (open, close, replace = open) => (input) => {
|
|
986
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
987
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
988
|
+
};
|
|
989
|
+
let replaceClose = (string, close, replace, index) => {
|
|
990
|
+
let result = "", cursor = 0;
|
|
991
|
+
do {
|
|
992
|
+
result += string.substring(cursor, index) + replace;
|
|
993
|
+
cursor = index + close.length;
|
|
994
|
+
index = string.indexOf(close, cursor);
|
|
995
|
+
} while (~index);
|
|
996
|
+
return result + string.substring(cursor);
|
|
997
|
+
};
|
|
998
|
+
let createColors = (enabled = isColorSupported) => {
|
|
999
|
+
let f = enabled ? formatter : () => String;
|
|
1000
|
+
return {
|
|
1001
|
+
isColorSupported: enabled,
|
|
1002
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
1003
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
1004
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
1005
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
1006
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
1007
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
1008
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
1009
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
1010
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
1011
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
1012
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
1013
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
1014
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
1015
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
1016
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
1017
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
1018
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
1019
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
1020
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
1021
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
1022
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
1023
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
1024
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
1025
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
1026
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
1027
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
1028
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
1029
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
1030
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
1031
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
1032
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
1033
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
1034
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
1035
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
1036
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
1037
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
1038
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
1039
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
1040
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
1041
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
1042
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
1043
|
+
};
|
|
1044
|
+
};
|
|
1045
|
+
module.exports = createColors();
|
|
1046
|
+
module.exports.createColors = createColors;
|
|
1047
|
+
}));
|
|
1048
|
+
|
|
1049
|
+
//#endregion
|
|
1050
|
+
//#region node_modules/.pnpm/@clack+core@0.5.0/node_modules/@clack/core/dist/index.mjs
|
|
1051
|
+
var import_ejs = /* @__PURE__ */ __toESM(require_ejs(), 1);
|
|
1052
|
+
var import_src = require_src();
|
|
1053
|
+
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
1054
|
+
function DD({ onlyFirst: e$1 = !1 } = {}) {
|
|
1055
|
+
const t = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
|
|
1056
|
+
return new RegExp(t, e$1 ? void 0 : "g");
|
|
1057
|
+
}
|
|
1058
|
+
const uD = DD();
|
|
1059
|
+
function P$1(e$1) {
|
|
1060
|
+
if (typeof e$1 != "string") throw new TypeError(`Expected a \`string\`, got \`${typeof e$1}\``);
|
|
1061
|
+
return e$1.replace(uD, "");
|
|
1062
|
+
}
|
|
1063
|
+
function L$1(e$1) {
|
|
1064
|
+
return e$1 && e$1.__esModule && Object.prototype.hasOwnProperty.call(e$1, "default") ? e$1.default : e$1;
|
|
1065
|
+
}
|
|
1066
|
+
var W$1 = { exports: {} };
|
|
1067
|
+
(function(e$1) {
|
|
1068
|
+
var u$1 = {};
|
|
1069
|
+
e$1.exports = u$1, u$1.eastAsianWidth = function(F$1) {
|
|
1070
|
+
var s = F$1.charCodeAt(0), i = F$1.length == 2 ? F$1.charCodeAt(1) : 0, D$1 = s;
|
|
1071
|
+
return 55296 <= s && s <= 56319 && 56320 <= i && i <= 57343 && (s &= 1023, i &= 1023, D$1 = s << 10 | i, D$1 += 65536), D$1 == 12288 || 65281 <= D$1 && D$1 <= 65376 || 65504 <= D$1 && D$1 <= 65510 ? "F" : D$1 == 8361 || 65377 <= D$1 && D$1 <= 65470 || 65474 <= D$1 && D$1 <= 65479 || 65482 <= D$1 && D$1 <= 65487 || 65490 <= D$1 && D$1 <= 65495 || 65498 <= D$1 && D$1 <= 65500 || 65512 <= D$1 && D$1 <= 65518 ? "H" : 4352 <= D$1 && D$1 <= 4447 || 4515 <= D$1 && D$1 <= 4519 || 4602 <= D$1 && D$1 <= 4607 || 9001 <= D$1 && D$1 <= 9002 || 11904 <= D$1 && D$1 <= 11929 || 11931 <= D$1 && D$1 <= 12019 || 12032 <= D$1 && D$1 <= 12245 || 12272 <= D$1 && D$1 <= 12283 || 12289 <= D$1 && D$1 <= 12350 || 12353 <= D$1 && D$1 <= 12438 || 12441 <= D$1 && D$1 <= 12543 || 12549 <= D$1 && D$1 <= 12589 || 12593 <= D$1 && D$1 <= 12686 || 12688 <= D$1 && D$1 <= 12730 || 12736 <= D$1 && D$1 <= 12771 || 12784 <= D$1 && D$1 <= 12830 || 12832 <= D$1 && D$1 <= 12871 || 12880 <= D$1 && D$1 <= 13054 || 13056 <= D$1 && D$1 <= 19903 || 19968 <= D$1 && D$1 <= 42124 || 42128 <= D$1 && D$1 <= 42182 || 43360 <= D$1 && D$1 <= 43388 || 44032 <= D$1 && D$1 <= 55203 || 55216 <= D$1 && D$1 <= 55238 || 55243 <= D$1 && D$1 <= 55291 || 63744 <= D$1 && D$1 <= 64255 || 65040 <= D$1 && D$1 <= 65049 || 65072 <= D$1 && D$1 <= 65106 || 65108 <= D$1 && D$1 <= 65126 || 65128 <= D$1 && D$1 <= 65131 || 110592 <= D$1 && D$1 <= 110593 || 127488 <= D$1 && D$1 <= 127490 || 127504 <= D$1 && D$1 <= 127546 || 127552 <= D$1 && D$1 <= 127560 || 127568 <= D$1 && D$1 <= 127569 || 131072 <= D$1 && D$1 <= 194367 || 177984 <= D$1 && D$1 <= 196605 || 196608 <= D$1 && D$1 <= 262141 ? "W" : 32 <= D$1 && D$1 <= 126 || 162 <= D$1 && D$1 <= 163 || 165 <= D$1 && D$1 <= 166 || D$1 == 172 || D$1 == 175 || 10214 <= D$1 && D$1 <= 10221 || 10629 <= D$1 && D$1 <= 10630 ? "Na" : D$1 == 161 || D$1 == 164 || 167 <= D$1 && D$1 <= 168 || D$1 == 170 || 173 <= D$1 && D$1 <= 174 || 176 <= D$1 && D$1 <= 180 || 182 <= D$1 && D$1 <= 186 || 188 <= D$1 && D$1 <= 191 || D$1 == 198 || D$1 == 208 || 215 <= D$1 && D$1 <= 216 || 222 <= D$1 && D$1 <= 225 || D$1 == 230 || 232 <= D$1 && D$1 <= 234 || 236 <= D$1 && D$1 <= 237 || D$1 == 240 || 242 <= D$1 && D$1 <= 243 || 247 <= D$1 && D$1 <= 250 || D$1 == 252 || D$1 == 254 || D$1 == 257 || D$1 == 273 || D$1 == 275 || D$1 == 283 || 294 <= D$1 && D$1 <= 295 || D$1 == 299 || 305 <= D$1 && D$1 <= 307 || D$1 == 312 || 319 <= D$1 && D$1 <= 322 || D$1 == 324 || 328 <= D$1 && D$1 <= 331 || D$1 == 333 || 338 <= D$1 && D$1 <= 339 || 358 <= D$1 && D$1 <= 359 || D$1 == 363 || D$1 == 462 || D$1 == 464 || D$1 == 466 || D$1 == 468 || D$1 == 470 || D$1 == 472 || D$1 == 474 || D$1 == 476 || D$1 == 593 || D$1 == 609 || D$1 == 708 || D$1 == 711 || 713 <= D$1 && D$1 <= 715 || D$1 == 717 || D$1 == 720 || 728 <= D$1 && D$1 <= 731 || D$1 == 733 || D$1 == 735 || 768 <= D$1 && D$1 <= 879 || 913 <= D$1 && D$1 <= 929 || 931 <= D$1 && D$1 <= 937 || 945 <= D$1 && D$1 <= 961 || 963 <= D$1 && D$1 <= 969 || D$1 == 1025 || 1040 <= D$1 && D$1 <= 1103 || D$1 == 1105 || D$1 == 8208 || 8211 <= D$1 && D$1 <= 8214 || 8216 <= D$1 && D$1 <= 8217 || 8220 <= D$1 && D$1 <= 8221 || 8224 <= D$1 && D$1 <= 8226 || 8228 <= D$1 && D$1 <= 8231 || D$1 == 8240 || 8242 <= D$1 && D$1 <= 8243 || D$1 == 8245 || D$1 == 8251 || D$1 == 8254 || D$1 == 8308 || D$1 == 8319 || 8321 <= D$1 && D$1 <= 8324 || D$1 == 8364 || D$1 == 8451 || D$1 == 8453 || D$1 == 8457 || D$1 == 8467 || D$1 == 8470 || 8481 <= D$1 && D$1 <= 8482 || D$1 == 8486 || D$1 == 8491 || 8531 <= D$1 && D$1 <= 8532 || 8539 <= D$1 && D$1 <= 8542 || 8544 <= D$1 && D$1 <= 8555 || 8560 <= D$1 && D$1 <= 8569 || D$1 == 8585 || 8592 <= D$1 && D$1 <= 8601 || 8632 <= D$1 && D$1 <= 8633 || D$1 == 8658 || D$1 == 8660 || D$1 == 8679 || D$1 == 8704 || 8706 <= D$1 && D$1 <= 8707 || 8711 <= D$1 && D$1 <= 8712 || D$1 == 8715 || D$1 == 8719 || D$1 == 8721 || D$1 == 8725 || D$1 == 8730 || 8733 <= D$1 && D$1 <= 8736 || D$1 == 8739 || D$1 == 8741 || 8743 <= D$1 && D$1 <= 8748 || D$1 == 8750 || 8756 <= D$1 && D$1 <= 8759 || 8764 <= D$1 && D$1 <= 8765 || D$1 == 8776 || D$1 == 8780 || D$1 == 8786 || 8800 <= D$1 && D$1 <= 8801 || 8804 <= D$1 && D$1 <= 8807 || 8810 <= D$1 && D$1 <= 8811 || 8814 <= D$1 && D$1 <= 8815 || 8834 <= D$1 && D$1 <= 8835 || 8838 <= D$1 && D$1 <= 8839 || D$1 == 8853 || D$1 == 8857 || D$1 == 8869 || D$1 == 8895 || D$1 == 8978 || 9312 <= D$1 && D$1 <= 9449 || 9451 <= D$1 && D$1 <= 9547 || 9552 <= D$1 && D$1 <= 9587 || 9600 <= D$1 && D$1 <= 9615 || 9618 <= D$1 && D$1 <= 9621 || 9632 <= D$1 && D$1 <= 9633 || 9635 <= D$1 && D$1 <= 9641 || 9650 <= D$1 && D$1 <= 9651 || 9654 <= D$1 && D$1 <= 9655 || 9660 <= D$1 && D$1 <= 9661 || 9664 <= D$1 && D$1 <= 9665 || 9670 <= D$1 && D$1 <= 9672 || D$1 == 9675 || 9678 <= D$1 && D$1 <= 9681 || 9698 <= D$1 && D$1 <= 9701 || D$1 == 9711 || 9733 <= D$1 && D$1 <= 9734 || D$1 == 9737 || 9742 <= D$1 && D$1 <= 9743 || 9748 <= D$1 && D$1 <= 9749 || D$1 == 9756 || D$1 == 9758 || D$1 == 9792 || D$1 == 9794 || 9824 <= D$1 && D$1 <= 9825 || 9827 <= D$1 && D$1 <= 9829 || 9831 <= D$1 && D$1 <= 9834 || 9836 <= D$1 && D$1 <= 9837 || D$1 == 9839 || 9886 <= D$1 && D$1 <= 9887 || 9918 <= D$1 && D$1 <= 9919 || 9924 <= D$1 && D$1 <= 9933 || 9935 <= D$1 && D$1 <= 9953 || D$1 == 9955 || 9960 <= D$1 && D$1 <= 9983 || D$1 == 10045 || D$1 == 10071 || 10102 <= D$1 && D$1 <= 10111 || 11093 <= D$1 && D$1 <= 11097 || 12872 <= D$1 && D$1 <= 12879 || 57344 <= D$1 && D$1 <= 63743 || 65024 <= D$1 && D$1 <= 65039 || D$1 == 65533 || 127232 <= D$1 && D$1 <= 127242 || 127248 <= D$1 && D$1 <= 127277 || 127280 <= D$1 && D$1 <= 127337 || 127344 <= D$1 && D$1 <= 127386 || 917760 <= D$1 && D$1 <= 917999 || 983040 <= D$1 && D$1 <= 1048573 || 1048576 <= D$1 && D$1 <= 1114109 ? "A" : "N";
|
|
1072
|
+
}, u$1.characterLength = function(F$1) {
|
|
1073
|
+
var s = this.eastAsianWidth(F$1);
|
|
1074
|
+
return s == "F" || s == "W" || s == "A" ? 2 : 1;
|
|
1075
|
+
};
|
|
1076
|
+
function t(F$1) {
|
|
1077
|
+
return F$1.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
|
|
1078
|
+
}
|
|
1079
|
+
u$1.length = function(F$1) {
|
|
1080
|
+
for (var s = t(F$1), i = 0, D$1 = 0; D$1 < s.length; D$1++) i = i + this.characterLength(s[D$1]);
|
|
1081
|
+
return i;
|
|
1082
|
+
}, u$1.slice = function(F$1, s, i) {
|
|
1083
|
+
textLen = u$1.length(F$1), s = s || 0, i = i || 1, s < 0 && (s = textLen + s), i < 0 && (i = textLen + i);
|
|
1084
|
+
for (var D$1 = "", C$1 = 0, n = t(F$1), E = 0; E < n.length; E++) {
|
|
1085
|
+
var a = n[E], o$1 = u$1.length(a);
|
|
1086
|
+
if (C$1 >= s - (o$1 == 2 ? 1 : 0)) if (C$1 + o$1 <= i) D$1 += a;
|
|
1087
|
+
else break;
|
|
1088
|
+
C$1 += o$1;
|
|
1089
|
+
}
|
|
1090
|
+
return D$1;
|
|
1091
|
+
};
|
|
1092
|
+
})(W$1);
|
|
1093
|
+
var tD = W$1.exports;
|
|
1094
|
+
const eD = L$1(tD);
|
|
1095
|
+
var FD = function() {
|
|
1096
|
+
return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
|
|
1097
|
+
};
|
|
1098
|
+
const sD = L$1(FD);
|
|
1099
|
+
function p(e$1, u$1 = {}) {
|
|
1100
|
+
if (typeof e$1 != "string" || e$1.length === 0 || (u$1 = {
|
|
1101
|
+
ambiguousIsNarrow: !0,
|
|
1102
|
+
...u$1
|
|
1103
|
+
}, e$1 = P$1(e$1), e$1.length === 0)) return 0;
|
|
1104
|
+
e$1 = e$1.replace(sD(), " ");
|
|
1105
|
+
const t = u$1.ambiguousIsNarrow ? 1 : 2;
|
|
1106
|
+
let F$1 = 0;
|
|
1107
|
+
for (const s of e$1) {
|
|
1108
|
+
const i = s.codePointAt(0);
|
|
1109
|
+
if (i <= 31 || i >= 127 && i <= 159 || i >= 768 && i <= 879) continue;
|
|
1110
|
+
switch (eD.eastAsianWidth(s)) {
|
|
1111
|
+
case "F":
|
|
1112
|
+
case "W":
|
|
1113
|
+
F$1 += 2;
|
|
1114
|
+
break;
|
|
1115
|
+
case "A":
|
|
1116
|
+
F$1 += t;
|
|
1117
|
+
break;
|
|
1118
|
+
default: F$1 += 1;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
return F$1;
|
|
1122
|
+
}
|
|
1123
|
+
const w = 10, N = (e$1 = 0) => (u$1) => `\x1B[${u$1 + e$1}m`, I = (e$1 = 0) => (u$1) => `\x1B[${38 + e$1};5;${u$1}m`, R = (e$1 = 0) => (u$1, t, F$1) => `\x1B[${38 + e$1};2;${u$1};${t};${F$1}m`, r = {
|
|
1124
|
+
modifier: {
|
|
1125
|
+
reset: [0, 0],
|
|
1126
|
+
bold: [1, 22],
|
|
1127
|
+
dim: [2, 22],
|
|
1128
|
+
italic: [3, 23],
|
|
1129
|
+
underline: [4, 24],
|
|
1130
|
+
overline: [53, 55],
|
|
1131
|
+
inverse: [7, 27],
|
|
1132
|
+
hidden: [8, 28],
|
|
1133
|
+
strikethrough: [9, 29]
|
|
1134
|
+
},
|
|
1135
|
+
color: {
|
|
1136
|
+
black: [30, 39],
|
|
1137
|
+
red: [31, 39],
|
|
1138
|
+
green: [32, 39],
|
|
1139
|
+
yellow: [33, 39],
|
|
1140
|
+
blue: [34, 39],
|
|
1141
|
+
magenta: [35, 39],
|
|
1142
|
+
cyan: [36, 39],
|
|
1143
|
+
white: [37, 39],
|
|
1144
|
+
blackBright: [90, 39],
|
|
1145
|
+
gray: [90, 39],
|
|
1146
|
+
grey: [90, 39],
|
|
1147
|
+
redBright: [91, 39],
|
|
1148
|
+
greenBright: [92, 39],
|
|
1149
|
+
yellowBright: [93, 39],
|
|
1150
|
+
blueBright: [94, 39],
|
|
1151
|
+
magentaBright: [95, 39],
|
|
1152
|
+
cyanBright: [96, 39],
|
|
1153
|
+
whiteBright: [97, 39]
|
|
1154
|
+
},
|
|
1155
|
+
bgColor: {
|
|
1156
|
+
bgBlack: [40, 49],
|
|
1157
|
+
bgRed: [41, 49],
|
|
1158
|
+
bgGreen: [42, 49],
|
|
1159
|
+
bgYellow: [43, 49],
|
|
1160
|
+
bgBlue: [44, 49],
|
|
1161
|
+
bgMagenta: [45, 49],
|
|
1162
|
+
bgCyan: [46, 49],
|
|
1163
|
+
bgWhite: [47, 49],
|
|
1164
|
+
bgBlackBright: [100, 49],
|
|
1165
|
+
bgGray: [100, 49],
|
|
1166
|
+
bgGrey: [100, 49],
|
|
1167
|
+
bgRedBright: [101, 49],
|
|
1168
|
+
bgGreenBright: [102, 49],
|
|
1169
|
+
bgYellowBright: [103, 49],
|
|
1170
|
+
bgBlueBright: [104, 49],
|
|
1171
|
+
bgMagentaBright: [105, 49],
|
|
1172
|
+
bgCyanBright: [106, 49],
|
|
1173
|
+
bgWhiteBright: [107, 49]
|
|
1174
|
+
}
|
|
1175
|
+
};
|
|
1176
|
+
Object.keys(r.modifier);
|
|
1177
|
+
const iD = Object.keys(r.color), CD = Object.keys(r.bgColor);
|
|
1178
|
+
[...iD, ...CD];
|
|
1179
|
+
function rD() {
|
|
1180
|
+
const e$1 = /* @__PURE__ */ new Map();
|
|
1181
|
+
for (const [u$1, t] of Object.entries(r)) {
|
|
1182
|
+
for (const [F$1, s] of Object.entries(t)) r[F$1] = {
|
|
1183
|
+
open: `\x1B[${s[0]}m`,
|
|
1184
|
+
close: `\x1B[${s[1]}m`
|
|
1185
|
+
}, t[F$1] = r[F$1], e$1.set(s[0], s[1]);
|
|
1186
|
+
Object.defineProperty(r, u$1, {
|
|
1187
|
+
value: t,
|
|
1188
|
+
enumerable: !1
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
return Object.defineProperty(r, "codes", {
|
|
1192
|
+
value: e$1,
|
|
1193
|
+
enumerable: !1
|
|
1194
|
+
}), r.color.close = "\x1B[39m", r.bgColor.close = "\x1B[49m", r.color.ansi = N(), r.color.ansi256 = I(), r.color.ansi16m = R(), r.bgColor.ansi = N(w), r.bgColor.ansi256 = I(w), r.bgColor.ansi16m = R(w), Object.defineProperties(r, {
|
|
1195
|
+
rgbToAnsi256: {
|
|
1196
|
+
value: (u$1, t, F$1) => u$1 === t && t === F$1 ? u$1 < 8 ? 16 : u$1 > 248 ? 231 : Math.round((u$1 - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u$1 / 255 * 5) + 6 * Math.round(t / 255 * 5) + Math.round(F$1 / 255 * 5),
|
|
1197
|
+
enumerable: !1
|
|
1198
|
+
},
|
|
1199
|
+
hexToRgb: {
|
|
1200
|
+
value: (u$1) => {
|
|
1201
|
+
const t = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u$1.toString(16));
|
|
1202
|
+
if (!t) return [
|
|
1203
|
+
0,
|
|
1204
|
+
0,
|
|
1205
|
+
0
|
|
1206
|
+
];
|
|
1207
|
+
let [F$1] = t;
|
|
1208
|
+
F$1.length === 3 && (F$1 = [...F$1].map((i) => i + i).join(""));
|
|
1209
|
+
const s = Number.parseInt(F$1, 16);
|
|
1210
|
+
return [
|
|
1211
|
+
s >> 16 & 255,
|
|
1212
|
+
s >> 8 & 255,
|
|
1213
|
+
s & 255
|
|
1214
|
+
];
|
|
1215
|
+
},
|
|
1216
|
+
enumerable: !1
|
|
1217
|
+
},
|
|
1218
|
+
hexToAnsi256: {
|
|
1219
|
+
value: (u$1) => r.rgbToAnsi256(...r.hexToRgb(u$1)),
|
|
1220
|
+
enumerable: !1
|
|
1221
|
+
},
|
|
1222
|
+
ansi256ToAnsi: {
|
|
1223
|
+
value: (u$1) => {
|
|
1224
|
+
if (u$1 < 8) return 30 + u$1;
|
|
1225
|
+
if (u$1 < 16) return 90 + (u$1 - 8);
|
|
1226
|
+
let t, F$1, s;
|
|
1227
|
+
if (u$1 >= 232) t = ((u$1 - 232) * 10 + 8) / 255, F$1 = t, s = t;
|
|
1228
|
+
else {
|
|
1229
|
+
u$1 -= 16;
|
|
1230
|
+
const C$1 = u$1 % 36;
|
|
1231
|
+
t = Math.floor(u$1 / 36) / 5, F$1 = Math.floor(C$1 / 6) / 5, s = C$1 % 6 / 5;
|
|
1232
|
+
}
|
|
1233
|
+
const i = Math.max(t, F$1, s) * 2;
|
|
1234
|
+
if (i === 0) return 30;
|
|
1235
|
+
let D$1 = 30 + (Math.round(s) << 2 | Math.round(F$1) << 1 | Math.round(t));
|
|
1236
|
+
return i === 2 && (D$1 += 60), D$1;
|
|
1237
|
+
},
|
|
1238
|
+
enumerable: !1
|
|
1239
|
+
},
|
|
1240
|
+
rgbToAnsi: {
|
|
1241
|
+
value: (u$1, t, F$1) => r.ansi256ToAnsi(r.rgbToAnsi256(u$1, t, F$1)),
|
|
1242
|
+
enumerable: !1
|
|
1243
|
+
},
|
|
1244
|
+
hexToAnsi: {
|
|
1245
|
+
value: (u$1) => r.ansi256ToAnsi(r.hexToAnsi256(u$1)),
|
|
1246
|
+
enumerable: !1
|
|
1247
|
+
}
|
|
1248
|
+
}), r;
|
|
1249
|
+
}
|
|
1250
|
+
const ED = rD(), d$1 = new Set(["\x1B", ""]), oD = 39, y$1 = "\x07", V$1 = "[", nD = "]", G$1 = "m", _$1 = `${nD}8;;`, z = (e$1) => `${d$1.values().next().value}${V$1}${e$1}${G$1}`, K$1 = (e$1) => `${d$1.values().next().value}${_$1}${e$1}${y$1}`, aD = (e$1) => e$1.split(" ").map((u$1) => p(u$1)), k$1 = (e$1, u$1, t) => {
|
|
1251
|
+
const F$1 = [...u$1];
|
|
1252
|
+
let s = !1, i = !1, D$1 = p(P$1(e$1[e$1.length - 1]));
|
|
1253
|
+
for (const [C$1, n] of F$1.entries()) {
|
|
1254
|
+
const E = p(n);
|
|
1255
|
+
if (D$1 + E <= t ? e$1[e$1.length - 1] += n : (e$1.push(n), D$1 = 0), d$1.has(n) && (s = !0, i = F$1.slice(C$1 + 1).join("").startsWith(_$1)), s) {
|
|
1256
|
+
i ? n === y$1 && (s = !1, i = !1) : n === G$1 && (s = !1);
|
|
1257
|
+
continue;
|
|
1258
|
+
}
|
|
1259
|
+
D$1 += E, D$1 === t && C$1 < F$1.length - 1 && (e$1.push(""), D$1 = 0);
|
|
1260
|
+
}
|
|
1261
|
+
!D$1 && e$1[e$1.length - 1].length > 0 && e$1.length > 1 && (e$1[e$1.length - 2] += e$1.pop());
|
|
1262
|
+
}, hD = (e$1) => {
|
|
1263
|
+
const u$1 = e$1.split(" ");
|
|
1264
|
+
let t = u$1.length;
|
|
1265
|
+
for (; t > 0 && !(p(u$1[t - 1]) > 0);) t--;
|
|
1266
|
+
return t === u$1.length ? e$1 : u$1.slice(0, t).join(" ") + u$1.slice(t).join("");
|
|
1267
|
+
}, lD = (e$1, u$1, t = {}) => {
|
|
1268
|
+
if (t.trim !== !1 && e$1.trim() === "") return "";
|
|
1269
|
+
let F$1 = "", s, i;
|
|
1270
|
+
const D$1 = aD(e$1);
|
|
1271
|
+
let C$1 = [""];
|
|
1272
|
+
for (const [E, a] of e$1.split(" ").entries()) {
|
|
1273
|
+
t.trim !== !1 && (C$1[C$1.length - 1] = C$1[C$1.length - 1].trimStart());
|
|
1274
|
+
let o$1 = p(C$1[C$1.length - 1]);
|
|
1275
|
+
if (E !== 0 && (o$1 >= u$1 && (t.wordWrap === !1 || t.trim === !1) && (C$1.push(""), o$1 = 0), (o$1 > 0 || t.trim === !1) && (C$1[C$1.length - 1] += " ", o$1++)), t.hard && D$1[E] > u$1) {
|
|
1276
|
+
const c = u$1 - o$1, f = 1 + Math.floor((D$1[E] - c - 1) / u$1);
|
|
1277
|
+
Math.floor((D$1[E] - 1) / u$1) < f && C$1.push(""), k$1(C$1, a, u$1);
|
|
1278
|
+
continue;
|
|
1279
|
+
}
|
|
1280
|
+
if (o$1 + D$1[E] > u$1 && o$1 > 0 && D$1[E] > 0) {
|
|
1281
|
+
if (t.wordWrap === !1 && o$1 < u$1) {
|
|
1282
|
+
k$1(C$1, a, u$1);
|
|
1283
|
+
continue;
|
|
1284
|
+
}
|
|
1285
|
+
C$1.push("");
|
|
1286
|
+
}
|
|
1287
|
+
if (o$1 + D$1[E] > u$1 && t.wordWrap === !1) {
|
|
1288
|
+
k$1(C$1, a, u$1);
|
|
1289
|
+
continue;
|
|
1290
|
+
}
|
|
1291
|
+
C$1[C$1.length - 1] += a;
|
|
1292
|
+
}
|
|
1293
|
+
t.trim !== !1 && (C$1 = C$1.map((E) => hD(E)));
|
|
1294
|
+
const n = [...C$1.join(`
|
|
1295
|
+
`)];
|
|
1296
|
+
for (const [E, a] of n.entries()) {
|
|
1297
|
+
if (F$1 += a, d$1.has(a)) {
|
|
1298
|
+
const { groups: c } = (/* @__PURE__ */ new RegExp(`(?:\\${V$1}(?<code>\\d+)m|\\${_$1}(?<uri>.*)${y$1})`)).exec(n.slice(E).join("")) || { groups: {} };
|
|
1299
|
+
if (c.code !== void 0) {
|
|
1300
|
+
const f = Number.parseFloat(c.code);
|
|
1301
|
+
s = f === oD ? void 0 : f;
|
|
1302
|
+
} else c.uri !== void 0 && (i = c.uri.length === 0 ? void 0 : c.uri);
|
|
1303
|
+
}
|
|
1304
|
+
const o$1 = ED.codes.get(Number(s));
|
|
1305
|
+
n[E + 1] === `
|
|
1306
|
+
` ? (i && (F$1 += K$1("")), s && o$1 && (F$1 += z(o$1))) : a === `
|
|
1307
|
+
` && (s && o$1 && (F$1 += z(s)), i && (F$1 += K$1(i)));
|
|
1308
|
+
}
|
|
1309
|
+
return F$1;
|
|
1310
|
+
};
|
|
1311
|
+
function Y$1(e$1, u$1, t) {
|
|
1312
|
+
return String(e$1).normalize().replace(/\r\n/g, `
|
|
1313
|
+
`).split(`
|
|
1314
|
+
`).map((F$1) => lD(F$1, u$1, t)).join(`
|
|
1315
|
+
`);
|
|
1316
|
+
}
|
|
1317
|
+
const B = {
|
|
1318
|
+
actions: new Set([
|
|
1319
|
+
"up",
|
|
1320
|
+
"down",
|
|
1321
|
+
"left",
|
|
1322
|
+
"right",
|
|
1323
|
+
"space",
|
|
1324
|
+
"enter",
|
|
1325
|
+
"cancel"
|
|
1326
|
+
]),
|
|
1327
|
+
aliases: new Map([
|
|
1328
|
+
["k", "up"],
|
|
1329
|
+
["j", "down"],
|
|
1330
|
+
["h", "left"],
|
|
1331
|
+
["l", "right"],
|
|
1332
|
+
["", "cancel"],
|
|
1333
|
+
["escape", "cancel"]
|
|
1334
|
+
])
|
|
1335
|
+
};
|
|
1336
|
+
function $(e$1, u$1) {
|
|
1337
|
+
if (typeof e$1 == "string") return B.aliases.get(e$1) === u$1;
|
|
1338
|
+
for (const t of e$1) if (t !== void 0 && $(t, u$1)) return !0;
|
|
1339
|
+
return !1;
|
|
1340
|
+
}
|
|
1341
|
+
function BD(e$1, u$1) {
|
|
1342
|
+
if (e$1 === u$1) return;
|
|
1343
|
+
const t = e$1.split(`
|
|
1344
|
+
`), F$1 = u$1.split(`
|
|
1345
|
+
`), s = [];
|
|
1346
|
+
for (let i = 0; i < Math.max(t.length, F$1.length); i++) t[i] !== F$1[i] && s.push(i);
|
|
1347
|
+
return s;
|
|
1348
|
+
}
|
|
1349
|
+
const AD = globalThis.process.platform.startsWith("win"), S = Symbol("clack:cancel");
|
|
1350
|
+
function pD(e$1) {
|
|
1351
|
+
return e$1 === S;
|
|
1352
|
+
}
|
|
1353
|
+
function m(e$1, u$1) {
|
|
1354
|
+
const t = e$1;
|
|
1355
|
+
t.isTTY && t.setRawMode(u$1);
|
|
1356
|
+
}
|
|
1357
|
+
function fD({ input: e$1 = stdin, output: u$1 = stdout, overwrite: t = !0, hideCursor: F$1 = !0 } = {}) {
|
|
1358
|
+
const s = g.createInterface({
|
|
1359
|
+
input: e$1,
|
|
1360
|
+
output: u$1,
|
|
1361
|
+
prompt: "",
|
|
1362
|
+
tabSize: 1
|
|
1363
|
+
});
|
|
1364
|
+
g.emitKeypressEvents(e$1, s), e$1.isTTY && e$1.setRawMode(!0);
|
|
1365
|
+
const i = (D$1, { name: C$1, sequence: n }) => {
|
|
1366
|
+
if ($([
|
|
1367
|
+
String(D$1),
|
|
1368
|
+
C$1,
|
|
1369
|
+
n
|
|
1370
|
+
], "cancel")) {
|
|
1371
|
+
F$1 && u$1.write(import_src.cursor.show), process.exit(0);
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
if (!t) return;
|
|
1375
|
+
const a = C$1 === "return" ? 0 : -1, o$1 = C$1 === "return" ? -1 : 0;
|
|
1376
|
+
g.moveCursor(u$1, a, o$1, () => {
|
|
1377
|
+
g.clearLine(u$1, 1, () => {
|
|
1378
|
+
e$1.once("keypress", i);
|
|
1379
|
+
});
|
|
1380
|
+
});
|
|
1381
|
+
};
|
|
1382
|
+
return F$1 && u$1.write(import_src.cursor.hide), e$1.once("keypress", i), () => {
|
|
1383
|
+
e$1.off("keypress", i), F$1 && u$1.write(import_src.cursor.show), e$1.isTTY && !AD && e$1.setRawMode(!1), s.terminal = !1, s.close();
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
var gD = Object.defineProperty, vD = (e$1, u$1, t) => u$1 in e$1 ? gD(e$1, u$1, {
|
|
1387
|
+
enumerable: !0,
|
|
1388
|
+
configurable: !0,
|
|
1389
|
+
writable: !0,
|
|
1390
|
+
value: t
|
|
1391
|
+
}) : e$1[u$1] = t, h = (e$1, u$1, t) => (vD(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t);
|
|
1392
|
+
var x$1 = class {
|
|
1393
|
+
constructor(u$1, t = !0) {
|
|
1394
|
+
h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", !1), h(this, "_prevFrame", ""), h(this, "_subscribers", /* @__PURE__ */ new Map()), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
|
|
1395
|
+
const { input: F$1 = stdin, output: s = stdout, render: i, signal: D$1, ...C$1 } = u$1;
|
|
1396
|
+
this.opts = C$1, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = i.bind(this), this._track = t, this._abortSignal = D$1, this.input = F$1, this.output = s;
|
|
1397
|
+
}
|
|
1398
|
+
unsubscribe() {
|
|
1399
|
+
this._subscribers.clear();
|
|
1400
|
+
}
|
|
1401
|
+
setSubscriber(u$1, t) {
|
|
1402
|
+
const F$1 = this._subscribers.get(u$1) ?? [];
|
|
1403
|
+
F$1.push(t), this._subscribers.set(u$1, F$1);
|
|
1404
|
+
}
|
|
1405
|
+
on(u$1, t) {
|
|
1406
|
+
this.setSubscriber(u$1, { cb: t });
|
|
1407
|
+
}
|
|
1408
|
+
once(u$1, t) {
|
|
1409
|
+
this.setSubscriber(u$1, {
|
|
1410
|
+
cb: t,
|
|
1411
|
+
once: !0
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
emit(u$1, ...t) {
|
|
1415
|
+
const F$1 = this._subscribers.get(u$1) ?? [], s = [];
|
|
1416
|
+
for (const i of F$1) i.cb(...t), i.once && s.push(() => F$1.splice(F$1.indexOf(i), 1));
|
|
1417
|
+
for (const i of s) i();
|
|
1418
|
+
}
|
|
1419
|
+
prompt() {
|
|
1420
|
+
return new Promise((u$1, t) => {
|
|
1421
|
+
if (this._abortSignal) {
|
|
1422
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), u$1(S);
|
|
1423
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
1424
|
+
this.state = "cancel", this.close();
|
|
1425
|
+
}, { once: !0 });
|
|
1426
|
+
}
|
|
1427
|
+
const F$1 = new Writable();
|
|
1428
|
+
F$1._write = (s, i, D$1) => {
|
|
1429
|
+
this._track && (this.value = this.rl?.line.replace(/\t/g, ""), this._cursor = this.rl?.cursor ?? 0, this.emit("value", this.value)), D$1();
|
|
1430
|
+
}, this.input.pipe(F$1), this.rl = O.createInterface({
|
|
1431
|
+
input: this.input,
|
|
1432
|
+
output: F$1,
|
|
1433
|
+
tabSize: 2,
|
|
1434
|
+
prompt: "",
|
|
1435
|
+
escapeCodeTimeout: 50,
|
|
1436
|
+
terminal: !0
|
|
1437
|
+
}), O.emitKeypressEvents(this.input, this.rl), this.rl.prompt(), this.opts.initialValue !== void 0 && this._track && this.rl.write(this.opts.initialValue), this.input.on("keypress", this.onKeypress), m(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
1438
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), m(this.input, !1), u$1(this.value);
|
|
1439
|
+
}), this.once("cancel", () => {
|
|
1440
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), m(this.input, !1), u$1(S);
|
|
1441
|
+
});
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
onKeypress(u$1, t) {
|
|
1445
|
+
if (this.state === "error" && (this.state = "active"), t?.name && (!this._track && B.aliases.has(t.name) && this.emit("cursor", B.aliases.get(t.name)), B.actions.has(t.name) && this.emit("cursor", t.name)), u$1 && (u$1.toLowerCase() === "y" || u$1.toLowerCase() === "n") && this.emit("confirm", u$1.toLowerCase() === "y"), u$1 === " " && this.opts.placeholder && (this.value || (this.rl?.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u$1 && this.emit("key", u$1.toLowerCase()), t?.name === "return") {
|
|
1446
|
+
if (this.opts.validate) {
|
|
1447
|
+
const F$1 = this.opts.validate(this.value);
|
|
1448
|
+
F$1 && (this.error = F$1 instanceof Error ? F$1.message : F$1, this.state = "error", this.rl?.write(this.value));
|
|
1449
|
+
}
|
|
1450
|
+
this.state !== "error" && (this.state = "submit");
|
|
1451
|
+
}
|
|
1452
|
+
$([
|
|
1453
|
+
u$1,
|
|
1454
|
+
t?.name,
|
|
1455
|
+
t?.sequence
|
|
1456
|
+
], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
1457
|
+
}
|
|
1458
|
+
close() {
|
|
1459
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
1460
|
+
`), m(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
1461
|
+
}
|
|
1462
|
+
restoreCursor() {
|
|
1463
|
+
const u$1 = Y$1(this._prevFrame, process.stdout.columns, { hard: !0 }).split(`
|
|
1464
|
+
`).length - 1;
|
|
1465
|
+
this.output.write(import_src.cursor.move(-999, u$1 * -1));
|
|
1466
|
+
}
|
|
1467
|
+
render() {
|
|
1468
|
+
const u$1 = Y$1(this._render(this) ?? "", process.stdout.columns, { hard: !0 });
|
|
1469
|
+
if (u$1 !== this._prevFrame) {
|
|
1470
|
+
if (this.state === "initial") this.output.write(import_src.cursor.hide);
|
|
1471
|
+
else {
|
|
1472
|
+
const t = BD(this._prevFrame, u$1);
|
|
1473
|
+
if (this.restoreCursor(), t && t?.length === 1) {
|
|
1474
|
+
const F$1 = t[0];
|
|
1475
|
+
this.output.write(import_src.cursor.move(0, F$1)), this.output.write(import_src.erase.lines(1));
|
|
1476
|
+
const s = u$1.split(`
|
|
1477
|
+
`);
|
|
1478
|
+
this.output.write(s[F$1]), this._prevFrame = u$1, this.output.write(import_src.cursor.move(0, s.length - F$1 - 1));
|
|
1479
|
+
return;
|
|
1480
|
+
}
|
|
1481
|
+
if (t && t?.length > 1) {
|
|
1482
|
+
const F$1 = t[0];
|
|
1483
|
+
this.output.write(import_src.cursor.move(0, F$1)), this.output.write(import_src.erase.down());
|
|
1484
|
+
const s = u$1.split(`
|
|
1485
|
+
`).slice(F$1);
|
|
1486
|
+
this.output.write(s.join(`
|
|
1487
|
+
`)), this._prevFrame = u$1;
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1490
|
+
this.output.write(import_src.erase.down());
|
|
1491
|
+
}
|
|
1492
|
+
this.output.write(u$1), this.state === "initial" && (this.state = "active"), this._prevFrame = u$1;
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
};
|
|
1496
|
+
var dD = class extends x$1 {
|
|
1497
|
+
get cursor() {
|
|
1498
|
+
return this.value ? 0 : 1;
|
|
1499
|
+
}
|
|
1500
|
+
get _value() {
|
|
1501
|
+
return this.cursor === 0;
|
|
1502
|
+
}
|
|
1503
|
+
constructor(u$1) {
|
|
1504
|
+
super(u$1, !1), this.value = !!u$1.initialValue, this.on("value", () => {
|
|
1505
|
+
this.value = this._value;
|
|
1506
|
+
}), this.on("confirm", (t) => {
|
|
1507
|
+
this.output.write(import_src.cursor.move(0, -1)), this.value = t, this.state = "submit", this.close();
|
|
1508
|
+
}), this.on("cursor", () => {
|
|
1509
|
+
this.value = !this.value;
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
};
|
|
1513
|
+
var mD = Object.defineProperty, bD = (e$1, u$1, t) => u$1 in e$1 ? mD(e$1, u$1, {
|
|
1514
|
+
enumerable: !0,
|
|
1515
|
+
configurable: !0,
|
|
1516
|
+
writable: !0,
|
|
1517
|
+
value: t
|
|
1518
|
+
}) : e$1[u$1] = t, Z = (e$1, u$1, t) => (bD(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t), q$1 = (e$1, u$1, t) => {
|
|
1519
|
+
if (!u$1.has(e$1)) throw TypeError("Cannot " + t);
|
|
1520
|
+
}, T$1 = (e$1, u$1, t) => (q$1(e$1, u$1, "read from private field"), t ? t.call(e$1) : u$1.get(e$1)), wD = (e$1, u$1, t) => {
|
|
1521
|
+
if (u$1.has(e$1)) throw TypeError("Cannot add the same private member more than once");
|
|
1522
|
+
u$1 instanceof WeakSet ? u$1.add(e$1) : u$1.set(e$1, t);
|
|
1523
|
+
}, yD = (e$1, u$1, t, F$1) => (q$1(e$1, u$1, "write to private field"), F$1 ? F$1.call(e$1, t) : u$1.set(e$1, t), t), A$1;
|
|
1524
|
+
let _D = class extends x$1 {
|
|
1525
|
+
constructor(u$1) {
|
|
1526
|
+
super(u$1, !1), Z(this, "options"), Z(this, "cursor", 0), wD(this, A$1, void 0);
|
|
1527
|
+
const { options: t } = u$1;
|
|
1528
|
+
yD(this, A$1, u$1.selectableGroups !== !1), this.options = Object.entries(t).flatMap(([F$1, s]) => [{
|
|
1529
|
+
value: F$1,
|
|
1530
|
+
group: !0,
|
|
1531
|
+
label: F$1
|
|
1532
|
+
}, ...s.map((i) => ({
|
|
1533
|
+
...i,
|
|
1534
|
+
group: F$1
|
|
1535
|
+
}))]), this.value = [...u$1.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: F$1 }) => F$1 === u$1.cursorAt), T$1(this, A$1) ? 0 : 1), this.on("cursor", (F$1) => {
|
|
1536
|
+
switch (F$1) {
|
|
1537
|
+
case "left":
|
|
1538
|
+
case "up": {
|
|
1539
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
1540
|
+
const s = this.options[this.cursor]?.group === !0;
|
|
1541
|
+
!T$1(this, A$1) && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
1542
|
+
break;
|
|
1543
|
+
}
|
|
1544
|
+
case "down":
|
|
1545
|
+
case "right": {
|
|
1546
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1547
|
+
const s = this.options[this.cursor]?.group === !0;
|
|
1548
|
+
!T$1(this, A$1) && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1549
|
+
break;
|
|
1550
|
+
}
|
|
1551
|
+
case "space":
|
|
1552
|
+
this.toggleValue();
|
|
1553
|
+
break;
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
getGroupItems(u$1) {
|
|
1558
|
+
return this.options.filter((t) => t.group === u$1);
|
|
1559
|
+
}
|
|
1560
|
+
isGroupSelected(u$1) {
|
|
1561
|
+
return this.getGroupItems(u$1).every((t) => this.value.includes(t.value));
|
|
1562
|
+
}
|
|
1563
|
+
toggleValue() {
|
|
1564
|
+
const u$1 = this.options[this.cursor];
|
|
1565
|
+
if (u$1.group === !0) {
|
|
1566
|
+
const t = u$1.value, F$1 = this.getGroupItems(t);
|
|
1567
|
+
this.isGroupSelected(t) ? this.value = this.value.filter((s) => F$1.findIndex((i) => i.value === s) === -1) : this.value = [...this.value, ...F$1.map((s) => s.value)], this.value = Array.from(new Set(this.value));
|
|
1568
|
+
} else this.value = this.value.includes(u$1.value) ? this.value.filter((F$1) => F$1 !== u$1.value) : [...this.value, u$1.value];
|
|
1569
|
+
}
|
|
1570
|
+
};
|
|
1571
|
+
A$1 = /* @__PURE__ */ new WeakMap();
|
|
1572
|
+
var kD = Object.defineProperty, $D = (e$1, u$1, t) => u$1 in e$1 ? kD(e$1, u$1, {
|
|
1573
|
+
enumerable: !0,
|
|
1574
|
+
configurable: !0,
|
|
1575
|
+
writable: !0,
|
|
1576
|
+
value: t
|
|
1577
|
+
}) : e$1[u$1] = t, H = (e$1, u$1, t) => ($D(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t);
|
|
1578
|
+
let SD = class extends x$1 {
|
|
1579
|
+
constructor(u$1) {
|
|
1580
|
+
super(u$1, !1), H(this, "options"), H(this, "cursor", 0), this.options = u$1.options, this.value = [...u$1.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: t }) => t === u$1.cursorAt), 0), this.on("key", (t) => {
|
|
1581
|
+
t === "a" && this.toggleAll();
|
|
1582
|
+
}), this.on("cursor", (t) => {
|
|
1583
|
+
switch (t) {
|
|
1584
|
+
case "left":
|
|
1585
|
+
case "up":
|
|
1586
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
1587
|
+
break;
|
|
1588
|
+
case "down":
|
|
1589
|
+
case "right":
|
|
1590
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1591
|
+
break;
|
|
1592
|
+
case "space":
|
|
1593
|
+
this.toggleValue();
|
|
1594
|
+
break;
|
|
1595
|
+
}
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1598
|
+
get _value() {
|
|
1599
|
+
return this.options[this.cursor].value;
|
|
1600
|
+
}
|
|
1601
|
+
toggleAll() {
|
|
1602
|
+
this.value = this.value.length === this.options.length ? [] : this.options.map((t) => t.value);
|
|
1603
|
+
}
|
|
1604
|
+
toggleValue() {
|
|
1605
|
+
this.value = this.value.includes(this._value) ? this.value.filter((t) => t !== this._value) : [...this.value, this._value];
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
var TD = Object.defineProperty, jD = (e$1, u$1, t) => u$1 in e$1 ? TD(e$1, u$1, {
|
|
1609
|
+
enumerable: !0,
|
|
1610
|
+
configurable: !0,
|
|
1611
|
+
writable: !0,
|
|
1612
|
+
value: t
|
|
1613
|
+
}) : e$1[u$1] = t, U$1 = (e$1, u$1, t) => (jD(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t);
|
|
1614
|
+
var MD = class extends x$1 {
|
|
1615
|
+
constructor({ mask: u$1, ...t }) {
|
|
1616
|
+
super(t), U$1(this, "valueWithCursor", ""), U$1(this, "_mask", "•"), this._mask = u$1 ?? "•", this.on("finalize", () => {
|
|
1617
|
+
this.valueWithCursor = this.masked;
|
|
1618
|
+
}), this.on("value", () => {
|
|
1619
|
+
if (this.cursor >= this.value.length) this.valueWithCursor = `${this.masked}${import_picocolors.default.inverse(import_picocolors.default.hidden("_"))}`;
|
|
1620
|
+
else {
|
|
1621
|
+
const F$1 = this.masked.slice(0, this.cursor), s = this.masked.slice(this.cursor);
|
|
1622
|
+
this.valueWithCursor = `${F$1}${import_picocolors.default.inverse(s[0])}${s.slice(1)}`;
|
|
1623
|
+
}
|
|
1624
|
+
});
|
|
1625
|
+
}
|
|
1626
|
+
get cursor() {
|
|
1627
|
+
return this._cursor;
|
|
1628
|
+
}
|
|
1629
|
+
get masked() {
|
|
1630
|
+
return this.value.replaceAll(/./g, this._mask);
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
var OD = Object.defineProperty, PD = (e$1, u$1, t) => u$1 in e$1 ? OD(e$1, u$1, {
|
|
1634
|
+
enumerable: !0,
|
|
1635
|
+
configurable: !0,
|
|
1636
|
+
writable: !0,
|
|
1637
|
+
value: t
|
|
1638
|
+
}) : e$1[u$1] = t, J$1 = (e$1, u$1, t) => (PD(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t);
|
|
1639
|
+
var LD = class extends x$1 {
|
|
1640
|
+
constructor(u$1) {
|
|
1641
|
+
super(u$1, !1), J$1(this, "options"), J$1(this, "cursor", 0), this.options = u$1.options, this.cursor = this.options.findIndex(({ value: t }) => t === u$1.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (t) => {
|
|
1642
|
+
switch (t) {
|
|
1643
|
+
case "left":
|
|
1644
|
+
case "up":
|
|
1645
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
1646
|
+
break;
|
|
1647
|
+
case "down":
|
|
1648
|
+
case "right":
|
|
1649
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1650
|
+
break;
|
|
1651
|
+
}
|
|
1652
|
+
this.changeValue();
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
get _value() {
|
|
1656
|
+
return this.options[this.cursor];
|
|
1657
|
+
}
|
|
1658
|
+
changeValue() {
|
|
1659
|
+
this.value = this._value.value;
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
var WD = Object.defineProperty, ND = (e$1, u$1, t) => u$1 in e$1 ? WD(e$1, u$1, {
|
|
1663
|
+
enumerable: !0,
|
|
1664
|
+
configurable: !0,
|
|
1665
|
+
writable: !0,
|
|
1666
|
+
value: t
|
|
1667
|
+
}) : e$1[u$1] = t, Q = (e$1, u$1, t) => (ND(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t);
|
|
1668
|
+
var ID = class extends x$1 {
|
|
1669
|
+
constructor(u$1) {
|
|
1670
|
+
super(u$1, !1), Q(this, "options"), Q(this, "cursor", 0), this.options = u$1.options;
|
|
1671
|
+
const t = this.options.map(({ value: [F$1] }) => F$1?.toLowerCase());
|
|
1672
|
+
this.cursor = Math.max(t.indexOf(u$1.initialValue), 0), this.on("key", (F$1) => {
|
|
1673
|
+
if (!t.includes(F$1)) return;
|
|
1674
|
+
const s = this.options.find(({ value: [i] }) => i?.toLowerCase() === F$1);
|
|
1675
|
+
s && (this.value = s.value, this.state = "submit", this.emit("submit"));
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1679
|
+
var RD = class extends x$1 {
|
|
1680
|
+
get valueWithCursor() {
|
|
1681
|
+
if (this.state === "submit") return this.value;
|
|
1682
|
+
if (this.cursor >= this.value.length) return `${this.value}\u2588`;
|
|
1683
|
+
const u$1 = this.value.slice(0, this.cursor), [t, ...F$1] = this.value.slice(this.cursor);
|
|
1684
|
+
return `${u$1}${import_picocolors.default.inverse(t)}${F$1.join("")}`;
|
|
1685
|
+
}
|
|
1686
|
+
get cursor() {
|
|
1687
|
+
return this._cursor;
|
|
1688
|
+
}
|
|
1689
|
+
constructor(u$1) {
|
|
1690
|
+
super(u$1), this.on("finalize", () => {
|
|
1691
|
+
this.value || (this.value = u$1.defaultValue);
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1694
|
+
};
|
|
1695
|
+
|
|
1696
|
+
//#endregion
|
|
1697
|
+
//#region node_modules/.pnpm/@clack+prompts@0.11.0/node_modules/@clack/prompts/dist/index.mjs
|
|
1698
|
+
function ce() {
|
|
1699
|
+
return y.platform !== "win32" ? y.env.TERM !== "linux" : !!y.env.CI || !!y.env.WT_SESSION || !!y.env.TERMINUS_SUBLIME || y.env.ConEmuTask === "{cmd::Cmder}" || y.env.TERM_PROGRAM === "Terminus-Sublime" || y.env.TERM_PROGRAM === "vscode" || y.env.TERM === "xterm-256color" || y.env.TERM === "alacritty" || y.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
1700
|
+
}
|
|
1701
|
+
const V = ce(), u = (t, n) => V ? t : n, le = u("◆", "*"), L = u("■", "x"), W = u("▲", "x"), C = u("◇", "o"), ue = u("┌", "T"), o = u("│", "|"), d = u("└", "—"), k = u("●", ">"), P = u("○", " "), A = u("◻", "[•]"), T = u("◼", "[+]"), F = u("◻", "[ ]"), $e = u("▪", "•"), _ = u("─", "-"), me = u("╮", "+"), de = u("├", "+"), pe = u("╯", "+"), q = u("●", "•"), D = u("◆", "*"), U = u("▲", "!"), K = u("■", "x"), b = (t) => {
|
|
1702
|
+
switch (t) {
|
|
1703
|
+
case "initial":
|
|
1704
|
+
case "active": return import_picocolors.default.cyan(le);
|
|
1705
|
+
case "cancel": return import_picocolors.default.red(L);
|
|
1706
|
+
case "error": return import_picocolors.default.yellow(W);
|
|
1707
|
+
case "submit": return import_picocolors.default.green(C);
|
|
1708
|
+
}
|
|
1709
|
+
}, G = (t) => {
|
|
1710
|
+
const { cursor: n, options: r$1, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a = Math.min(c, Math.max(s, 5));
|
|
1711
|
+
let l$1 = 0;
|
|
1712
|
+
n >= l$1 + a - 3 ? l$1 = Math.max(Math.min(n - a + 3, r$1.length - a), 0) : n < l$1 + 2 && (l$1 = Math.max(n - 2, 0));
|
|
1713
|
+
const $$1 = a < r$1.length && l$1 > 0, g$1 = a < r$1.length && l$1 + a < r$1.length;
|
|
1714
|
+
return r$1.slice(l$1, l$1 + a).map((p$1, v$1, f) => {
|
|
1715
|
+
const j = v$1 === 0 && $$1, E = v$1 === f.length - 1 && g$1;
|
|
1716
|
+
return j || E ? import_picocolors.default.dim("...") : i(p$1, v$1 + l$1 === n);
|
|
1717
|
+
});
|
|
1718
|
+
}, he = (t) => new RD({
|
|
1719
|
+
validate: t.validate,
|
|
1720
|
+
placeholder: t.placeholder,
|
|
1721
|
+
defaultValue: t.defaultValue,
|
|
1722
|
+
initialValue: t.initialValue,
|
|
1723
|
+
render() {
|
|
1724
|
+
const n = `${import_picocolors.default.gray(o)}
|
|
1725
|
+
${b(this.state)} ${t.message}
|
|
1726
|
+
`, r$1 = t.placeholder ? import_picocolors.default.inverse(t.placeholder[0]) + import_picocolors.default.dim(t.placeholder.slice(1)) : import_picocolors.default.inverse(import_picocolors.default.hidden("_")), i = this.value ? this.valueWithCursor : r$1;
|
|
1727
|
+
switch (this.state) {
|
|
1728
|
+
case "error": return `${n.trim()}
|
|
1729
|
+
${import_picocolors.default.yellow(o)} ${i}
|
|
1730
|
+
${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(this.error)}
|
|
1731
|
+
`;
|
|
1732
|
+
case "submit": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(this.value || t.placeholder)}`;
|
|
1733
|
+
case "cancel": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(this.value ?? ""))}${this.value?.trim() ? `
|
|
1734
|
+
${import_picocolors.default.gray(o)}` : ""}`;
|
|
1735
|
+
default: return `${n}${import_picocolors.default.cyan(o)} ${i}
|
|
1736
|
+
${import_picocolors.default.cyan(d)}
|
|
1737
|
+
`;
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
}).prompt(), ge = (t) => new MD({
|
|
1741
|
+
validate: t.validate,
|
|
1742
|
+
mask: t.mask ?? $e,
|
|
1743
|
+
render() {
|
|
1744
|
+
const n = `${import_picocolors.default.gray(o)}
|
|
1745
|
+
${b(this.state)} ${t.message}
|
|
1746
|
+
`, r$1 = this.valueWithCursor, i = this.masked;
|
|
1747
|
+
switch (this.state) {
|
|
1748
|
+
case "error": return `${n.trim()}
|
|
1749
|
+
${import_picocolors.default.yellow(o)} ${i}
|
|
1750
|
+
${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(this.error)}
|
|
1751
|
+
`;
|
|
1752
|
+
case "submit": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(i)}`;
|
|
1753
|
+
case "cancel": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(i ?? ""))}${i ? `
|
|
1754
|
+
${import_picocolors.default.gray(o)}` : ""}`;
|
|
1755
|
+
default: return `${n}${import_picocolors.default.cyan(o)} ${r$1}
|
|
1756
|
+
${import_picocolors.default.cyan(d)}
|
|
1757
|
+
`;
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
}).prompt(), ye = (t) => {
|
|
1761
|
+
const n = t.active ?? "Yes", r$1 = t.inactive ?? "No";
|
|
1762
|
+
return new dD({
|
|
1763
|
+
active: n,
|
|
1764
|
+
inactive: r$1,
|
|
1765
|
+
initialValue: t.initialValue ?? !0,
|
|
1766
|
+
render() {
|
|
1767
|
+
const i = `${import_picocolors.default.gray(o)}
|
|
1768
|
+
${b(this.state)} ${t.message}
|
|
1769
|
+
`, s = this.value ? n : r$1;
|
|
1770
|
+
switch (this.state) {
|
|
1771
|
+
case "submit": return `${i}${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(s)}`;
|
|
1772
|
+
case "cancel": return `${i}${import_picocolors.default.gray(o)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}
|
|
1773
|
+
${import_picocolors.default.gray(o)}`;
|
|
1774
|
+
default: return `${i}${import_picocolors.default.cyan(o)} ${this.value ? `${import_picocolors.default.green(k)} ${n}` : `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(n)}`} ${import_picocolors.default.dim("/")} ${this.value ? `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(r$1)}` : `${import_picocolors.default.green(k)} ${r$1}`}
|
|
1775
|
+
${import_picocolors.default.cyan(d)}
|
|
1776
|
+
`;
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
}).prompt();
|
|
1780
|
+
}, ve = (t) => {
|
|
1781
|
+
const n = (r$1, i) => {
|
|
1782
|
+
const s = r$1.label ?? String(r$1.value);
|
|
1783
|
+
switch (i) {
|
|
1784
|
+
case "selected": return `${import_picocolors.default.dim(s)}`;
|
|
1785
|
+
case "active": return `${import_picocolors.default.green(k)} ${s} ${r$1.hint ? import_picocolors.default.dim(`(${r$1.hint})`) : ""}`;
|
|
1786
|
+
case "cancelled": return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}`;
|
|
1787
|
+
default: return `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(s)}`;
|
|
1788
|
+
}
|
|
1789
|
+
};
|
|
1790
|
+
return new LD({
|
|
1791
|
+
options: t.options,
|
|
1792
|
+
initialValue: t.initialValue,
|
|
1793
|
+
render() {
|
|
1794
|
+
const r$1 = `${import_picocolors.default.gray(o)}
|
|
1795
|
+
${b(this.state)} ${t.message}
|
|
1796
|
+
`;
|
|
1797
|
+
switch (this.state) {
|
|
1798
|
+
case "submit": return `${r$1}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
|
|
1799
|
+
case "cancel": return `${r$1}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
|
|
1800
|
+
${import_picocolors.default.gray(o)}`;
|
|
1801
|
+
default: return `${r$1}${import_picocolors.default.cyan(o)} ${G({
|
|
1802
|
+
cursor: this.cursor,
|
|
1803
|
+
options: this.options,
|
|
1804
|
+
maxItems: t.maxItems,
|
|
1805
|
+
style: (i, s) => n(i, s ? "active" : "inactive")
|
|
1806
|
+
}).join(`
|
|
1807
|
+
${import_picocolors.default.cyan(o)} `)}
|
|
1808
|
+
${import_picocolors.default.cyan(d)}
|
|
1809
|
+
`;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
}).prompt();
|
|
1813
|
+
}, we = (t) => {
|
|
1814
|
+
const n = (r$1, i = "inactive") => {
|
|
1815
|
+
const s = r$1.label ?? String(r$1.value);
|
|
1816
|
+
return i === "selected" ? `${import_picocolors.default.dim(s)}` : i === "cancelled" ? `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}` : i === "active" ? `${import_picocolors.default.bgCyan(import_picocolors.default.gray(` ${r$1.value} `))} ${s} ${r$1.hint ? import_picocolors.default.dim(`(${r$1.hint})`) : ""}` : `${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(` ${r$1.value} `)))} ${s} ${r$1.hint ? import_picocolors.default.dim(`(${r$1.hint})`) : ""}`;
|
|
1817
|
+
};
|
|
1818
|
+
return new ID({
|
|
1819
|
+
options: t.options,
|
|
1820
|
+
initialValue: t.initialValue,
|
|
1821
|
+
render() {
|
|
1822
|
+
const r$1 = `${import_picocolors.default.gray(o)}
|
|
1823
|
+
${b(this.state)} ${t.message}
|
|
1824
|
+
`;
|
|
1825
|
+
switch (this.state) {
|
|
1826
|
+
case "submit": return `${r$1}${import_picocolors.default.gray(o)} ${n(this.options.find((i) => i.value === this.value) ?? t.options[0], "selected")}`;
|
|
1827
|
+
case "cancel": return `${r$1}${import_picocolors.default.gray(o)} ${n(this.options[0], "cancelled")}
|
|
1828
|
+
${import_picocolors.default.gray(o)}`;
|
|
1829
|
+
default: return `${r$1}${import_picocolors.default.cyan(o)} ${this.options.map((i, s) => n(i, s === this.cursor ? "active" : "inactive")).join(`
|
|
1830
|
+
${import_picocolors.default.cyan(o)} `)}
|
|
1831
|
+
${import_picocolors.default.cyan(d)}
|
|
1832
|
+
`;
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
}).prompt();
|
|
1836
|
+
}, fe = (t) => {
|
|
1837
|
+
const n = (r$1, i) => {
|
|
1838
|
+
const s = r$1.label ?? String(r$1.value);
|
|
1839
|
+
return i === "active" ? `${import_picocolors.default.cyan(A)} ${s} ${r$1.hint ? import_picocolors.default.dim(`(${r$1.hint})`) : ""}` : i === "selected" ? `${import_picocolors.default.green(T)} ${import_picocolors.default.dim(s)} ${r$1.hint ? import_picocolors.default.dim(`(${r$1.hint})`) : ""}` : i === "cancelled" ? `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}` : i === "active-selected" ? `${import_picocolors.default.green(T)} ${s} ${r$1.hint ? import_picocolors.default.dim(`(${r$1.hint})`) : ""}` : i === "submitted" ? `${import_picocolors.default.dim(s)}` : `${import_picocolors.default.dim(F)} ${import_picocolors.default.dim(s)}`;
|
|
1840
|
+
};
|
|
1841
|
+
return new SD({
|
|
1842
|
+
options: t.options,
|
|
1843
|
+
initialValues: t.initialValues,
|
|
1844
|
+
required: t.required ?? !0,
|
|
1845
|
+
cursorAt: t.cursorAt,
|
|
1846
|
+
validate(r$1) {
|
|
1847
|
+
if (this.required && r$1.length === 0) return `Please select at least one option.
|
|
1848
|
+
${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
|
|
1849
|
+
},
|
|
1850
|
+
render() {
|
|
1851
|
+
const r$1 = `${import_picocolors.default.gray(o)}
|
|
1852
|
+
${b(this.state)} ${t.message}
|
|
1853
|
+
`, i = (s, c) => {
|
|
1854
|
+
const a = this.value.includes(s.value);
|
|
1855
|
+
return c && a ? n(s, "active-selected") : a ? n(s, "selected") : n(s, c ? "active" : "inactive");
|
|
1856
|
+
};
|
|
1857
|
+
switch (this.state) {
|
|
1858
|
+
case "submit": return `${r$1}${import_picocolors.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "submitted")).join(import_picocolors.default.dim(", ")) || import_picocolors.default.dim("none")}`;
|
|
1859
|
+
case "cancel": {
|
|
1860
|
+
const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(import_picocolors.default.dim(", "));
|
|
1861
|
+
return `${r$1}${import_picocolors.default.gray(o)} ${s.trim() ? `${s}
|
|
1862
|
+
${import_picocolors.default.gray(o)}` : ""}`;
|
|
1863
|
+
}
|
|
1864
|
+
case "error": {
|
|
1865
|
+
const s = this.error.split(`
|
|
1866
|
+
`).map((c, a) => a === 0 ? `${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(c)}` : ` ${c}`).join(`
|
|
1867
|
+
`);
|
|
1868
|
+
return `${r$1 + import_picocolors.default.yellow(o)} ${G({
|
|
1869
|
+
options: this.options,
|
|
1870
|
+
cursor: this.cursor,
|
|
1871
|
+
maxItems: t.maxItems,
|
|
1872
|
+
style: i
|
|
1873
|
+
}).join(`
|
|
1874
|
+
${import_picocolors.default.yellow(o)} `)}
|
|
1875
|
+
${s}
|
|
1876
|
+
`;
|
|
1877
|
+
}
|
|
1878
|
+
default: return `${r$1}${import_picocolors.default.cyan(o)} ${G({
|
|
1879
|
+
options: this.options,
|
|
1880
|
+
cursor: this.cursor,
|
|
1881
|
+
maxItems: t.maxItems,
|
|
1882
|
+
style: i
|
|
1883
|
+
}).join(`
|
|
1884
|
+
${import_picocolors.default.cyan(o)} `)}
|
|
1885
|
+
${import_picocolors.default.cyan(d)}
|
|
1886
|
+
`;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
}).prompt();
|
|
1890
|
+
}, be = (t) => {
|
|
1891
|
+
const { selectableGroups: n = !0 } = t, r$1 = (i, s, c = []) => {
|
|
1892
|
+
const a = i.label ?? String(i.value), l$1 = typeof i.group == "string", $$1 = l$1 && (c[c.indexOf(i) + 1] ?? { group: !0 }), g$1 = l$1 && $$1.group === !0, p$1 = l$1 ? n ? `${g$1 ? d : o} ` : " " : "";
|
|
1893
|
+
if (s === "active") return `${import_picocolors.default.dim(p$1)}${import_picocolors.default.cyan(A)} ${a} ${i.hint ? import_picocolors.default.dim(`(${i.hint})`) : ""}`;
|
|
1894
|
+
if (s === "group-active") return `${p$1}${import_picocolors.default.cyan(A)} ${import_picocolors.default.dim(a)}`;
|
|
1895
|
+
if (s === "group-active-selected") return `${p$1}${import_picocolors.default.green(T)} ${import_picocolors.default.dim(a)}`;
|
|
1896
|
+
if (s === "selected") {
|
|
1897
|
+
const f = l$1 || n ? import_picocolors.default.green(T) : "";
|
|
1898
|
+
return `${import_picocolors.default.dim(p$1)}${f} ${import_picocolors.default.dim(a)} ${i.hint ? import_picocolors.default.dim(`(${i.hint})`) : ""}`;
|
|
1899
|
+
}
|
|
1900
|
+
if (s === "cancelled") return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(a))}`;
|
|
1901
|
+
if (s === "active-selected") return `${import_picocolors.default.dim(p$1)}${import_picocolors.default.green(T)} ${a} ${i.hint ? import_picocolors.default.dim(`(${i.hint})`) : ""}`;
|
|
1902
|
+
if (s === "submitted") return `${import_picocolors.default.dim(a)}`;
|
|
1903
|
+
const v$1 = l$1 || n ? import_picocolors.default.dim(F) : "";
|
|
1904
|
+
return `${import_picocolors.default.dim(p$1)}${v$1} ${import_picocolors.default.dim(a)}`;
|
|
1905
|
+
};
|
|
1906
|
+
return new _D({
|
|
1907
|
+
options: t.options,
|
|
1908
|
+
initialValues: t.initialValues,
|
|
1909
|
+
required: t.required ?? !0,
|
|
1910
|
+
cursorAt: t.cursorAt,
|
|
1911
|
+
selectableGroups: n,
|
|
1912
|
+
validate(i) {
|
|
1913
|
+
if (this.required && i.length === 0) return `Please select at least one option.
|
|
1914
|
+
${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
|
|
1915
|
+
},
|
|
1916
|
+
render() {
|
|
1917
|
+
const i = `${import_picocolors.default.gray(o)}
|
|
1918
|
+
${b(this.state)} ${t.message}
|
|
1919
|
+
`;
|
|
1920
|
+
switch (this.state) {
|
|
1921
|
+
case "submit": return `${i}${import_picocolors.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => r$1(s, "submitted")).join(import_picocolors.default.dim(", "))}`;
|
|
1922
|
+
case "cancel": {
|
|
1923
|
+
const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => r$1(c, "cancelled")).join(import_picocolors.default.dim(", "));
|
|
1924
|
+
return `${i}${import_picocolors.default.gray(o)} ${s.trim() ? `${s}
|
|
1925
|
+
${import_picocolors.default.gray(o)}` : ""}`;
|
|
1926
|
+
}
|
|
1927
|
+
case "error": {
|
|
1928
|
+
const s = this.error.split(`
|
|
1929
|
+
`).map((c, a) => a === 0 ? `${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(c)}` : ` ${c}`).join(`
|
|
1930
|
+
`);
|
|
1931
|
+
return `${i}${import_picocolors.default.yellow(o)} ${this.options.map((c, a, l$1) => {
|
|
1932
|
+
const $$1 = this.value.includes(c.value) || c.group === !0 && this.isGroupSelected(`${c.value}`), g$1 = a === this.cursor;
|
|
1933
|
+
return !g$1 && typeof c.group == "string" && this.options[this.cursor].value === c.group ? r$1(c, $$1 ? "group-active-selected" : "group-active", l$1) : g$1 && $$1 ? r$1(c, "active-selected", l$1) : $$1 ? r$1(c, "selected", l$1) : r$1(c, g$1 ? "active" : "inactive", l$1);
|
|
1934
|
+
}).join(`
|
|
1935
|
+
${import_picocolors.default.yellow(o)} `)}
|
|
1936
|
+
${s}
|
|
1937
|
+
`;
|
|
1938
|
+
}
|
|
1939
|
+
default: return `${i}${import_picocolors.default.cyan(o)} ${this.options.map((s, c, a) => {
|
|
1940
|
+
const l$1 = this.value.includes(s.value) || s.group === !0 && this.isGroupSelected(`${s.value}`), $$1 = c === this.cursor;
|
|
1941
|
+
return !$$1 && typeof s.group == "string" && this.options[this.cursor].value === s.group ? r$1(s, l$1 ? "group-active-selected" : "group-active", a) : $$1 && l$1 ? r$1(s, "active-selected", a) : l$1 ? r$1(s, "selected", a) : r$1(s, $$1 ? "active" : "inactive", a);
|
|
1942
|
+
}).join(`
|
|
1943
|
+
${import_picocolors.default.cyan(o)} `)}
|
|
1944
|
+
${import_picocolors.default.cyan(d)}
|
|
1945
|
+
`;
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
}).prompt();
|
|
1949
|
+
}, Me = (t = "", n = "") => {
|
|
1950
|
+
const r$1 = `
|
|
1951
|
+
${t}
|
|
1952
|
+
`.split(`
|
|
1953
|
+
`), i = stripVTControlCharacters(n).length, s = Math.max(r$1.reduce((a, l$1) => {
|
|
1954
|
+
const $$1 = stripVTControlCharacters(l$1);
|
|
1955
|
+
return $$1.length > a ? $$1.length : a;
|
|
1956
|
+
}, 0), i) + 2, c = r$1.map((a) => `${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(a)}${" ".repeat(s - stripVTControlCharacters(a).length)}${import_picocolors.default.gray(o)}`).join(`
|
|
1957
|
+
`);
|
|
1958
|
+
process.stdout.write(`${import_picocolors.default.gray(o)}
|
|
1959
|
+
${import_picocolors.default.green(C)} ${import_picocolors.default.reset(n)} ${import_picocolors.default.gray(_.repeat(Math.max(s - i - 1, 1)) + me)}
|
|
1960
|
+
${c}
|
|
1961
|
+
${import_picocolors.default.gray(de + _.repeat(s + 2) + pe)}
|
|
1962
|
+
`);
|
|
1963
|
+
}, xe = (t = "") => {
|
|
1964
|
+
process.stdout.write(`${import_picocolors.default.gray(d)} ${import_picocolors.default.red(t)}
|
|
1965
|
+
|
|
1966
|
+
`);
|
|
1967
|
+
}, Ie = (t = "") => {
|
|
1968
|
+
process.stdout.write(`${import_picocolors.default.gray(ue)} ${t}
|
|
1969
|
+
`);
|
|
1970
|
+
}, Se = (t = "") => {
|
|
1971
|
+
process.stdout.write(`${import_picocolors.default.gray(o)}
|
|
1972
|
+
${import_picocolors.default.gray(d)} ${t}
|
|
1973
|
+
|
|
1974
|
+
`);
|
|
1975
|
+
}, M = {
|
|
1976
|
+
message: (t = "", { symbol: n = import_picocolors.default.gray(o) } = {}) => {
|
|
1977
|
+
const r$1 = [`${import_picocolors.default.gray(o)}`];
|
|
1978
|
+
if (t) {
|
|
1979
|
+
const [i, ...s] = t.split(`
|
|
1980
|
+
`);
|
|
1981
|
+
r$1.push(`${n} ${i}`, ...s.map((c) => `${import_picocolors.default.gray(o)} ${c}`));
|
|
1982
|
+
}
|
|
1983
|
+
process.stdout.write(`${r$1.join(`
|
|
1984
|
+
`)}
|
|
1985
|
+
`);
|
|
1986
|
+
},
|
|
1987
|
+
info: (t) => {
|
|
1988
|
+
M.message(t, { symbol: import_picocolors.default.blue(q) });
|
|
1989
|
+
},
|
|
1990
|
+
success: (t) => {
|
|
1991
|
+
M.message(t, { symbol: import_picocolors.default.green(D) });
|
|
1992
|
+
},
|
|
1993
|
+
step: (t) => {
|
|
1994
|
+
M.message(t, { symbol: import_picocolors.default.green(C) });
|
|
1995
|
+
},
|
|
1996
|
+
warn: (t) => {
|
|
1997
|
+
M.message(t, { symbol: import_picocolors.default.yellow(U) });
|
|
1998
|
+
},
|
|
1999
|
+
warning: (t) => {
|
|
2000
|
+
M.warn(t);
|
|
2001
|
+
},
|
|
2002
|
+
error: (t) => {
|
|
2003
|
+
M.message(t, { symbol: import_picocolors.default.red(K) });
|
|
2004
|
+
}
|
|
2005
|
+
}, J = `${import_picocolors.default.gray(o)} `, x = {
|
|
2006
|
+
message: async (t, { symbol: n = import_picocolors.default.gray(o) } = {}) => {
|
|
2007
|
+
process.stdout.write(`${import_picocolors.default.gray(o)}
|
|
2008
|
+
${n} `);
|
|
2009
|
+
let r$1 = 3;
|
|
2010
|
+
for await (let i of t) {
|
|
2011
|
+
i = i.replace(/\n/g, `
|
|
2012
|
+
${J}`), i.includes(`
|
|
2013
|
+
`) && (r$1 = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
|
|
2014
|
+
`))).length);
|
|
2015
|
+
const s = stripVTControlCharacters(i).length;
|
|
2016
|
+
r$1 + s < process.stdout.columns ? (r$1 += s, process.stdout.write(i)) : (process.stdout.write(`
|
|
2017
|
+
${J}${i.trimStart()}`), r$1 = 3 + stripVTControlCharacters(i.trimStart()).length);
|
|
2018
|
+
}
|
|
2019
|
+
process.stdout.write(`
|
|
2020
|
+
`);
|
|
2021
|
+
},
|
|
2022
|
+
info: (t) => x.message(t, { symbol: import_picocolors.default.blue(q) }),
|
|
2023
|
+
success: (t) => x.message(t, { symbol: import_picocolors.default.green(D) }),
|
|
2024
|
+
step: (t) => x.message(t, { symbol: import_picocolors.default.green(C) }),
|
|
2025
|
+
warn: (t) => x.message(t, { symbol: import_picocolors.default.yellow(U) }),
|
|
2026
|
+
warning: (t) => x.warn(t),
|
|
2027
|
+
error: (t) => x.message(t, { symbol: import_picocolors.default.red(K) })
|
|
2028
|
+
}, Y = ({ indicator: t = "dots" } = {}) => {
|
|
2029
|
+
const n = V ? [
|
|
2030
|
+
"◒",
|
|
2031
|
+
"◐",
|
|
2032
|
+
"◓",
|
|
2033
|
+
"◑"
|
|
2034
|
+
] : [
|
|
2035
|
+
"•",
|
|
2036
|
+
"o",
|
|
2037
|
+
"O",
|
|
2038
|
+
"0"
|
|
2039
|
+
], r$1 = V ? 80 : 120, i = process.env.CI === "true";
|
|
2040
|
+
let s, c, a = !1, l$1 = "", $$1, g$1 = performance.now();
|
|
2041
|
+
const p$1 = (m$1) => {
|
|
2042
|
+
a && N$1(m$1 > 1 ? "Something went wrong" : "Canceled", m$1);
|
|
2043
|
+
}, v$1 = () => p$1(2), f = () => p$1(1), j = () => {
|
|
2044
|
+
process.on("uncaughtExceptionMonitor", v$1), process.on("unhandledRejection", v$1), process.on("SIGINT", f), process.on("SIGTERM", f), process.on("exit", p$1);
|
|
2045
|
+
}, E = () => {
|
|
2046
|
+
process.removeListener("uncaughtExceptionMonitor", v$1), process.removeListener("unhandledRejection", v$1), process.removeListener("SIGINT", f), process.removeListener("SIGTERM", f), process.removeListener("exit", p$1);
|
|
2047
|
+
}, B$1 = () => {
|
|
2048
|
+
if ($$1 === void 0) return;
|
|
2049
|
+
i && process.stdout.write(`
|
|
2050
|
+
`);
|
|
2051
|
+
const m$1 = $$1.split(`
|
|
2052
|
+
`);
|
|
2053
|
+
process.stdout.write(import_src.cursor.move(-999, m$1.length - 1)), process.stdout.write(import_src.erase.down(m$1.length));
|
|
2054
|
+
}, R$1 = (m$1) => m$1.replace(/\.+$/, ""), O$1 = (m$1) => {
|
|
2055
|
+
const h$1 = (performance.now() - m$1) / 1e3, w$1 = Math.floor(h$1 / 60), I$1 = Math.floor(h$1 % 60);
|
|
2056
|
+
return w$1 > 0 ? `[${w$1}m ${I$1}s]` : `[${I$1}s]`;
|
|
2057
|
+
}, H$1 = (m$1 = "") => {
|
|
2058
|
+
a = !0, s = fD(), l$1 = R$1(m$1), g$1 = performance.now(), process.stdout.write(`${import_picocolors.default.gray(o)}
|
|
2059
|
+
`);
|
|
2060
|
+
let h$1 = 0, w$1 = 0;
|
|
2061
|
+
j(), c = setInterval(() => {
|
|
2062
|
+
if (i && l$1 === $$1) return;
|
|
2063
|
+
B$1(), $$1 = l$1;
|
|
2064
|
+
const I$1 = import_picocolors.default.magenta(n[h$1]);
|
|
2065
|
+
if (i) process.stdout.write(`${I$1} ${l$1}...`);
|
|
2066
|
+
else if (t === "timer") process.stdout.write(`${I$1} ${l$1} ${O$1(g$1)}`);
|
|
2067
|
+
else {
|
|
2068
|
+
const z$1 = ".".repeat(Math.floor(w$1)).slice(0, 3);
|
|
2069
|
+
process.stdout.write(`${I$1} ${l$1}${z$1}`);
|
|
2070
|
+
}
|
|
2071
|
+
h$1 = h$1 + 1 < n.length ? h$1 + 1 : 0, w$1 = w$1 < n.length ? w$1 + .125 : 0;
|
|
2072
|
+
}, r$1);
|
|
2073
|
+
}, N$1 = (m$1 = "", h$1 = 0) => {
|
|
2074
|
+
a = !1, clearInterval(c), B$1();
|
|
2075
|
+
const w$1 = h$1 === 0 ? import_picocolors.default.green(C) : h$1 === 1 ? import_picocolors.default.red(L) : import_picocolors.default.red(W);
|
|
2076
|
+
l$1 = R$1(m$1 ?? l$1), t === "timer" ? process.stdout.write(`${w$1} ${l$1} ${O$1(g$1)}
|
|
2077
|
+
`) : process.stdout.write(`${w$1} ${l$1}
|
|
2078
|
+
`), E(), s();
|
|
2079
|
+
};
|
|
2080
|
+
return {
|
|
2081
|
+
start: H$1,
|
|
2082
|
+
stop: N$1,
|
|
2083
|
+
message: (m$1 = "") => {
|
|
2084
|
+
l$1 = R$1(m$1 ?? l$1);
|
|
2085
|
+
}
|
|
2086
|
+
};
|
|
2087
|
+
}, Ce = async (t, n) => {
|
|
2088
|
+
const r$1 = {}, i = Object.keys(t);
|
|
2089
|
+
for (const s of i) {
|
|
2090
|
+
const c = t[s], a = await c({ results: r$1 })?.catch((l$1) => {
|
|
2091
|
+
throw l$1;
|
|
2092
|
+
});
|
|
2093
|
+
if (typeof n?.onCancel == "function" && pD(a)) {
|
|
2094
|
+
r$1[s] = "canceled", n.onCancel({ results: r$1 });
|
|
2095
|
+
continue;
|
|
2096
|
+
}
|
|
2097
|
+
r$1[s] = a;
|
|
2098
|
+
}
|
|
2099
|
+
return r$1;
|
|
2100
|
+
}, Te = async (t) => {
|
|
2101
|
+
for (const n of t) {
|
|
2102
|
+
if (n.enabled === !1) continue;
|
|
2103
|
+
const r$1 = Y();
|
|
2104
|
+
r$1.start(n.title);
|
|
2105
|
+
const i = await n.task(r$1.message);
|
|
2106
|
+
r$1.stop(i || n.title);
|
|
2107
|
+
}
|
|
2108
|
+
};
|
|
2109
|
+
|
|
2110
|
+
//#endregion
|
|
2111
|
+
//#region src/utils/getLanguage.ts
|
|
2112
|
+
function linkLocale(locale) {
|
|
2113
|
+
if (locale === "C") return "en-US";
|
|
2114
|
+
let linkedLocale = locale;
|
|
2115
|
+
try {
|
|
2116
|
+
linkedLocale = Intl.getCanonicalLocales(locale)[0];
|
|
2117
|
+
} catch (error) {
|
|
2118
|
+
console.log(`${error.toString()}, invalid language tag: "${locale}"\n`);
|
|
2119
|
+
}
|
|
2120
|
+
switch (linkedLocale) {
|
|
2121
|
+
case "zh-CN":
|
|
2122
|
+
case "zh-SG":
|
|
2123
|
+
linkedLocale = "zh-Hans";
|
|
2124
|
+
break;
|
|
2125
|
+
default: linkedLocale = locale;
|
|
2126
|
+
}
|
|
2127
|
+
return linkedLocale;
|
|
2128
|
+
}
|
|
2129
|
+
function getLocale() {
|
|
2130
|
+
return linkLocale((process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG || Intl.DateTimeFormat().resolvedOptions().locale || "en-US").split(".")[0].replace("_", "-"));
|
|
2131
|
+
}
|
|
2132
|
+
async function loadLanguageFile(filePath) {
|
|
2133
|
+
return await fs.promises.readFile(filePath, "utf-8").then((data) => {
|
|
2134
|
+
const parsedData = JSON.parse(data);
|
|
2135
|
+
if (parsedData) return parsedData;
|
|
2136
|
+
});
|
|
2137
|
+
}
|
|
2138
|
+
async function getLanguage(localesRoot) {
|
|
2139
|
+
const locale = getLocale();
|
|
2140
|
+
const languageFilePath = path.resolve(localesRoot, `${locale}.json`);
|
|
2141
|
+
const fallbackPath = path.resolve(localesRoot, "en-US.json");
|
|
2142
|
+
return fs.existsSync(languageFilePath) ? await loadLanguageFile(languageFilePath) : await loadLanguageFile(fallbackPath);
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
//#endregion
|
|
2146
|
+
//#region src/locales/index.ts
|
|
2147
|
+
const language = await getLanguage(fileURLToPath(new URL("../locales", import.meta.url)));
|
|
2148
|
+
|
|
2149
|
+
//#endregion
|
|
2150
|
+
//#region src/help/index.ts
|
|
2151
|
+
const helpMessage = `\
|
|
2152
|
+
Usage: create-vite-react-cli [FEATURE_FLAGS...] [OPTIONS...] [DIRECTORY]
|
|
2153
|
+
|
|
2154
|
+
Create a new Vite React project.
|
|
2155
|
+
Start the CLI in interactive mode when no FEATURE_FLAGS is provided, or if the DIRECTORY argument is not a valid package name.
|
|
2156
|
+
|
|
2157
|
+
Options:
|
|
2158
|
+
--force
|
|
2159
|
+
Create the project even if the directory is not empty.
|
|
2160
|
+
--help
|
|
2161
|
+
Display this help message.
|
|
2162
|
+
--version
|
|
2163
|
+
Display the version number of this CLI.
|
|
2164
|
+
|
|
2165
|
+
Available feature flags:
|
|
2166
|
+
--default
|
|
2167
|
+
Create a project with the default configuration without any additional features.
|
|
2168
|
+
--ts, --typescript
|
|
2169
|
+
Add TypeScript support.
|
|
2170
|
+
--eslint
|
|
2171
|
+
Add ESLint for code quality.
|
|
2172
|
+
--eslint-with-prettier (Deprecated in favor of ${(0, import_picocolors.cyan)("--eslint --prettier")})
|
|
2173
|
+
Add Prettier for code formatting in addition to ESLint.
|
|
2174
|
+
--prettier
|
|
2175
|
+
Add Prettier for code formatting.
|
|
2176
|
+
`;
|
|
2177
|
+
|
|
2178
|
+
//#endregion
|
|
2179
|
+
//#region src/types/index.ts
|
|
2180
|
+
const FEATURE_FLAGS = [
|
|
2181
|
+
"default",
|
|
2182
|
+
"ts",
|
|
2183
|
+
"typescript",
|
|
2184
|
+
"eslint",
|
|
2185
|
+
"prettier",
|
|
2186
|
+
"eslint-with-prettier"
|
|
2187
|
+
];
|
|
2188
|
+
const FEATURE_OPTIONS = [
|
|
2189
|
+
{
|
|
2190
|
+
value: "typescript",
|
|
2191
|
+
label: language.needsTypeScript.message
|
|
2192
|
+
},
|
|
2193
|
+
{
|
|
2194
|
+
value: "eslint",
|
|
2195
|
+
label: language.needsEslint.message
|
|
2196
|
+
},
|
|
2197
|
+
{
|
|
2198
|
+
value: "prettier",
|
|
2199
|
+
label: language.needsPrettier.message
|
|
2200
|
+
}
|
|
2201
|
+
];
|
|
2202
|
+
|
|
2203
|
+
//#endregion
|
|
2204
|
+
//#region src/utils/prompt.ts
|
|
2205
|
+
async function unwrapPrompt(maybeCancelPromise) {
|
|
2206
|
+
const result = await maybeCancelPromise;
|
|
2207
|
+
if (pD(result)) {
|
|
2208
|
+
xe((0, import_picocolors.red)("✖") + ` ${language.errors.operationCancelled}`);
|
|
2209
|
+
process.exit(0);
|
|
2210
|
+
}
|
|
2211
|
+
return result;
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
//#endregion
|
|
2215
|
+
//#region src/utils/banners.ts
|
|
2216
|
+
const defaultBanner = "React.js - The library for web and native user interfaces";
|
|
2217
|
+
/**
|
|
2218
|
+
* Generates a gradient banner string with ANSI color codes.
|
|
2219
|
+
*/
|
|
2220
|
+
const gradientBanner = (() => {
|
|
2221
|
+
const startColor = [
|
|
2222
|
+
97,
|
|
2223
|
+
218,
|
|
2224
|
+
251
|
|
2225
|
+
];
|
|
2226
|
+
const endColor = [
|
|
2227
|
+
30,
|
|
2228
|
+
144,
|
|
2229
|
+
255
|
|
2230
|
+
];
|
|
2231
|
+
const length = 57;
|
|
2232
|
+
let result = "";
|
|
2233
|
+
for (let i = 0; i < length; i++) {
|
|
2234
|
+
const r$1 = Math.round(startColor[0] + (endColor[0] - startColor[0]) * i / (length - 1));
|
|
2235
|
+
const g$1 = Math.round(startColor[1] + (endColor[1] - startColor[1]) * i / (length - 1));
|
|
2236
|
+
const b$2 = Math.round(startColor[2] + (endColor[2] - startColor[2]) * i / (length - 1));
|
|
2237
|
+
result += `\x1B[38;2;${r$1};${g$1};${b$2}m${defaultBanner[i]}\x1B[39m`;
|
|
2238
|
+
}
|
|
2239
|
+
return result;
|
|
2240
|
+
})();
|
|
2241
|
+
|
|
2242
|
+
//#endregion
|
|
2243
|
+
//#region src/utils/getCommand.ts
|
|
2244
|
+
function getCommand(packageManager, scriptName, args) {
|
|
2245
|
+
if (scriptName === "install") return packageManager === "yarn" ? "yarn" : `${packageManager} install`;
|
|
2246
|
+
if (scriptName === "build") return packageManager === "npm" || packageManager === "bun" ? `${packageManager} run build` : `${packageManager} build`;
|
|
2247
|
+
if (args) return packageManager === "npm" ? `npm run ${scriptName} -- ${args}` : `${packageManager} ${scriptName} ${args}`;
|
|
2248
|
+
else return packageManager === "npm" ? `npm run ${scriptName}` : `${packageManager} ${scriptName}`;
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
//#endregion
|
|
2252
|
+
//#region src/utils/package.ts
|
|
2253
|
+
function isValidPackageName(projectName) {
|
|
2254
|
+
return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(projectName);
|
|
2255
|
+
}
|
|
2256
|
+
function toValidPackageName(projectName) {
|
|
2257
|
+
return projectName.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-");
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
//#endregion
|
|
2261
|
+
//#region src/utils/directoryTraverse.ts
|
|
2262
|
+
function preOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
|
|
2263
|
+
for (const filename of fs.readdirSync(dir)) {
|
|
2264
|
+
if (filename === ".git") continue;
|
|
2265
|
+
const fullpath = path.resolve(dir, filename);
|
|
2266
|
+
if (fs.lstatSync(fullpath).isDirectory()) {
|
|
2267
|
+
dirCallback(fullpath);
|
|
2268
|
+
if (fs.existsSync(fullpath)) preOrderDirectoryTraverse(fullpath, dirCallback, fileCallback);
|
|
2269
|
+
continue;
|
|
2270
|
+
}
|
|
2271
|
+
fileCallback(fullpath);
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
const dotGitDirectoryState = { hasDotGitDirectory: false };
|
|
2275
|
+
function postOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
|
|
2276
|
+
for (const filename of fs.readdirSync(dir)) {
|
|
2277
|
+
if (filename === ".git") {
|
|
2278
|
+
dotGitDirectoryState.hasDotGitDirectory = true;
|
|
2279
|
+
continue;
|
|
2280
|
+
}
|
|
2281
|
+
const fullpath = path.resolve(dir, filename);
|
|
2282
|
+
if (fs.lstatSync(fullpath).isDirectory()) {
|
|
2283
|
+
postOrderDirectoryTraverse(fullpath, dirCallback, fileCallback);
|
|
2284
|
+
dirCallback(fullpath);
|
|
2285
|
+
continue;
|
|
2286
|
+
}
|
|
2287
|
+
fileCallback(fullpath);
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
//#endregion
|
|
2292
|
+
//#region src/utils/directory.ts
|
|
2293
|
+
function canSkipEmptying(dir) {
|
|
2294
|
+
if (!fs.existsSync(dir)) return true;
|
|
2295
|
+
const files = fs.readdirSync(dir);
|
|
2296
|
+
if (files.length === 0) return true;
|
|
2297
|
+
if (files.length === 1 && files[0] === ".git") {
|
|
2298
|
+
dotGitDirectoryState.hasDotGitDirectory = true;
|
|
2299
|
+
return true;
|
|
2300
|
+
}
|
|
2301
|
+
return false;
|
|
2302
|
+
}
|
|
2303
|
+
function emptyDir(dir) {
|
|
2304
|
+
if (!fs.existsSync(dir)) return;
|
|
2305
|
+
postOrderDirectoryTraverse(dir, (dir$1) => fs.rmdirSync(dir$1), (file) => fs.unlinkSync(file));
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2308
|
+
//#endregion
|
|
2309
|
+
//#region src/utils/deepMerge.ts
|
|
2310
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
2311
|
+
const mergeArrayWithDedupe = (a, b$2) => Array.from(new Set([...a, ...b$2]));
|
|
2312
|
+
/**
|
|
2313
|
+
* Recursively merge the content of the new object to the existing one
|
|
2314
|
+
* @param {Object} target the existing object
|
|
2315
|
+
* @param {Object} obj the new object
|
|
2316
|
+
*/
|
|
2317
|
+
function deepMerge(target, obj) {
|
|
2318
|
+
for (const key of Object.keys(obj)) {
|
|
2319
|
+
const oldVal = target[key];
|
|
2320
|
+
const newVal = obj[key];
|
|
2321
|
+
if (Array.isArray(oldVal) && Array.isArray(newVal)) target[key] = mergeArrayWithDedupe(oldVal, newVal);
|
|
2322
|
+
else if (isObject(oldVal) && isObject(newVal)) target[key] = deepMerge(oldVal, newVal);
|
|
2323
|
+
else target[key] = newVal;
|
|
2324
|
+
}
|
|
2325
|
+
return target;
|
|
2326
|
+
}
|
|
2327
|
+
var deepMerge_default = deepMerge;
|
|
2328
|
+
|
|
2329
|
+
//#endregion
|
|
2330
|
+
//#region src/utils/sortDependencies.ts
|
|
2331
|
+
function sortDependencies(packageJson) {
|
|
2332
|
+
const sorted = {};
|
|
2333
|
+
for (const depType of [
|
|
2334
|
+
"dependencies",
|
|
2335
|
+
"devDependencies",
|
|
2336
|
+
"peerDependencies",
|
|
2337
|
+
"optionalDependencies"
|
|
2338
|
+
]) {
|
|
2339
|
+
const dependencies = packageJson[depType];
|
|
2340
|
+
if (dependencies && typeof dependencies === "object" && dependencies !== null) {
|
|
2341
|
+
sorted[depType] = {};
|
|
2342
|
+
Object.keys(dependencies).sort().forEach((name$1) => {
|
|
2343
|
+
sorted[depType][name$1] = dependencies[name$1];
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
return {
|
|
2348
|
+
...packageJson,
|
|
2349
|
+
...sorted
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
//#endregion
|
|
2354
|
+
//#region src/utils/renderTemplate.ts
|
|
2355
|
+
/**
|
|
2356
|
+
* Renders a template folder/file to the file system,
|
|
2357
|
+
* by recursively copying all files under the `src` directory,
|
|
2358
|
+
* with the following exception:
|
|
2359
|
+
* - `_filename` should be renamed to `.filename`
|
|
2360
|
+
* - Fields in `package.json` should be recursively merged
|
|
2361
|
+
* @param {string} src source filename to copy
|
|
2362
|
+
* @param {string} dest destination filename of the copy operation
|
|
2363
|
+
*/
|
|
2364
|
+
function renderTemplate(src, dest, callbacks) {
|
|
2365
|
+
if (fs.statSync(src).isDirectory()) {
|
|
2366
|
+
if (path.basename(src) === "node_modules") return;
|
|
2367
|
+
const dirname = path.basename(src);
|
|
2368
|
+
if (dirname.startsWith("_")) dest = path.resolve(path.dirname(dest), dirname.replace(/^_/, "."));
|
|
2369
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
2370
|
+
for (const file of fs.readdirSync(src)) renderTemplate(path.resolve(src, file), path.resolve(dest, file), callbacks);
|
|
2371
|
+
return;
|
|
2372
|
+
}
|
|
2373
|
+
const filename = path.basename(src);
|
|
2374
|
+
if (filename === "package.json" && fs.existsSync(dest)) {
|
|
2375
|
+
const pkg = sortDependencies(deepMerge_default(JSON.parse(fs.readFileSync(dest, "utf8")), JSON.parse(fs.readFileSync(src, "utf8"))));
|
|
2376
|
+
fs.writeFileSync(dest, JSON.stringify(pkg, null, 2) + "\n");
|
|
2377
|
+
return;
|
|
2378
|
+
}
|
|
2379
|
+
if (filename === "extensions.json" && fs.existsSync(dest)) {
|
|
2380
|
+
const extensions = deepMerge_default(JSON.parse(fs.readFileSync(dest, "utf8")), JSON.parse(fs.readFileSync(src, "utf8")));
|
|
2381
|
+
fs.writeFileSync(dest, JSON.stringify(extensions, null, 2) + "\n");
|
|
2382
|
+
return;
|
|
2383
|
+
}
|
|
2384
|
+
if (filename === "settings.json" && fs.existsSync(dest)) {
|
|
2385
|
+
const settings = deepMerge_default(JSON.parse(fs.readFileSync(dest, "utf8")), JSON.parse(fs.readFileSync(src, "utf8")));
|
|
2386
|
+
fs.writeFileSync(dest, JSON.stringify(settings, null, 2) + "\n");
|
|
2387
|
+
return;
|
|
2388
|
+
}
|
|
2389
|
+
if (filename.startsWith("_")) dest = path.resolve(path.dirname(dest), filename.replace(/^_/, "."));
|
|
2390
|
+
if (filename === "_gitignore" && fs.existsSync(dest)) {
|
|
2391
|
+
const existing = fs.readFileSync(dest, "utf8");
|
|
2392
|
+
const newGitignore = fs.readFileSync(src, "utf8");
|
|
2393
|
+
fs.writeFileSync(dest, existing + "\n" + newGitignore);
|
|
2394
|
+
return;
|
|
2395
|
+
}
|
|
2396
|
+
if (filename.endsWith(".data.mjs")) {
|
|
2397
|
+
dest = dest.replace(/\.data\.mjs$/, "");
|
|
2398
|
+
callbacks.push(async (dataStore) => {
|
|
2399
|
+
const getData = (await import(pathToFileURL(src).toString())).default;
|
|
2400
|
+
dataStore[dest] = await getData({ oldData: dataStore[dest] || {} });
|
|
2401
|
+
});
|
|
2402
|
+
return;
|
|
2403
|
+
}
|
|
2404
|
+
fs.copyFileSync(src, dest);
|
|
2405
|
+
}
|
|
2406
|
+
var renderTemplate_default = renderTemplate;
|
|
2407
|
+
|
|
2408
|
+
//#endregion
|
|
2409
|
+
//#region package.json
|
|
2410
|
+
var name = "create-vite-react-cli";
|
|
2411
|
+
var version = "0.4.2";
|
|
2412
|
+
|
|
2413
|
+
//#endregion
|
|
2414
|
+
//#region src/index.ts
|
|
2415
|
+
const DEFAULT_PROJECT_NAME = "my-vite-react-app";
|
|
2416
|
+
async function createProject() {
|
|
2417
|
+
const cwd = process.cwd();
|
|
2418
|
+
const args = process.argv.slice(2);
|
|
2419
|
+
const flags = [
|
|
2420
|
+
...FEATURE_FLAGS,
|
|
2421
|
+
"force",
|
|
2422
|
+
"help",
|
|
2423
|
+
"version"
|
|
2424
|
+
];
|
|
2425
|
+
const { values: argv, positionals } = parseArgs({
|
|
2426
|
+
args,
|
|
2427
|
+
options: Object.fromEntries(flags.map((key) => [key, { type: "boolean" }])),
|
|
2428
|
+
strict: true,
|
|
2429
|
+
allowPositionals: true
|
|
2430
|
+
});
|
|
2431
|
+
if (argv.help) {
|
|
2432
|
+
console.log(helpMessage);
|
|
2433
|
+
process.exit(0);
|
|
2434
|
+
}
|
|
2435
|
+
if (argv.version) {
|
|
2436
|
+
console.log(`${name} v${version}`);
|
|
2437
|
+
process.exit(0);
|
|
2438
|
+
}
|
|
2439
|
+
const isFeatureFlagsUsed = FEATURE_FLAGS.some((flag) => typeof argv[flag] === "boolean");
|
|
2440
|
+
let targetDir = positionals[0];
|
|
2441
|
+
const defaultProjectName = targetDir || DEFAULT_PROJECT_NAME;
|
|
2442
|
+
const forceOverwrite = argv.force;
|
|
2443
|
+
const result = {
|
|
2444
|
+
projectName: defaultProjectName,
|
|
2445
|
+
shouldOverwrite: forceOverwrite,
|
|
2446
|
+
packageName: defaultProjectName,
|
|
2447
|
+
features: []
|
|
2448
|
+
};
|
|
2449
|
+
Ie(process.stdout.isTTY && process.stdout.getColorDepth() > 8 ? gradientBanner : defaultBanner);
|
|
2450
|
+
if (!targetDir) targetDir = result.projectName = result.packageName = (await unwrapPrompt(he({
|
|
2451
|
+
message: language.projectName.message,
|
|
2452
|
+
placeholder: defaultProjectName,
|
|
2453
|
+
defaultValue: defaultProjectName,
|
|
2454
|
+
validate: (value) => value.length === 0 || value.trim().length > 0 ? void 0 : language.projectName.invalidMessage
|
|
2455
|
+
}))).trim();
|
|
2456
|
+
if (!canSkipEmptying(targetDir) && !forceOverwrite) {
|
|
2457
|
+
result.shouldOverwrite = await unwrapPrompt(ye({
|
|
2458
|
+
message: `${targetDir === "." ? language.shouldOverwrite.dirForPrompts.current : `${language.shouldOverwrite.dirForPrompts.target} "${targetDir}"`} ${language.shouldOverwrite.message}`,
|
|
2459
|
+
initialValue: false
|
|
2460
|
+
}));
|
|
2461
|
+
if (!result.shouldOverwrite) {
|
|
2462
|
+
xe((0, import_picocolors.red)("✖") + ` ${language.errors.operationCancelled}`);
|
|
2463
|
+
process.exit(0);
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
if (!isValidPackageName(targetDir)) result.packageName = await unwrapPrompt(he({
|
|
2467
|
+
message: language.packageName.message,
|
|
2468
|
+
initialValue: toValidPackageName(targetDir),
|
|
2469
|
+
validate: (value) => isValidPackageName(value) ? void 0 : language.packageName.invalidMessage
|
|
2470
|
+
}));
|
|
2471
|
+
if (!isFeatureFlagsUsed) result.features = await unwrapPrompt(fe({
|
|
2472
|
+
message: `${language.featureSelection.message} ${(0, import_picocolors.dim)(language.featureSelection.hint)}`,
|
|
2473
|
+
options: FEATURE_OPTIONS,
|
|
2474
|
+
required: false
|
|
2475
|
+
}));
|
|
2476
|
+
const { features = [] } = result;
|
|
2477
|
+
const needsTypeScript = argv.ts || argv.typescript || features.includes("typescript");
|
|
2478
|
+
const needsEslint = argv.eslint || argv["eslint-with-prettier"] || features.includes("eslint");
|
|
2479
|
+
const needsPrettier = argv.prettier || argv["eslint-with-prettier"] || features.includes("prettier");
|
|
2480
|
+
const root = path.join(cwd, targetDir);
|
|
2481
|
+
if (fs.existsSync(root) && result.shouldOverwrite) emptyDir(root);
|
|
2482
|
+
else if (!fs.existsSync(root)) fs.mkdirSync(root);
|
|
2483
|
+
console.log(`\n${language.infos.scaffolding} ${root}...`);
|
|
2484
|
+
const pkg = {
|
|
2485
|
+
name: result.packageName,
|
|
2486
|
+
version: "0.0.0"
|
|
2487
|
+
};
|
|
2488
|
+
fs.writeFileSync(path.resolve(root, "package.json"), JSON.stringify(pkg, null, 2));
|
|
2489
|
+
const templateRoot = fileURLToPath(new URL("../templates", import.meta.url));
|
|
2490
|
+
const callbacks = [];
|
|
2491
|
+
const render = function render$1(templateName) {
|
|
2492
|
+
renderTemplate_default(path.resolve(templateRoot, templateName), root, callbacks);
|
|
2493
|
+
};
|
|
2494
|
+
render("base");
|
|
2495
|
+
if (needsTypeScript) {
|
|
2496
|
+
render("config/typescript");
|
|
2497
|
+
render("tsconfig/base");
|
|
2498
|
+
fs.writeFileSync(path.resolve(root, "tsconfig.json"), JSON.stringify({
|
|
2499
|
+
files: [],
|
|
2500
|
+
references: [{ path: "./tsconfig.node.json" }, { path: "./tsconfig.app.json" }]
|
|
2501
|
+
}, null, 2) + "\n", "utf-8");
|
|
2502
|
+
}
|
|
2503
|
+
if (needsEslint) {
|
|
2504
|
+
render("linting/base");
|
|
2505
|
+
if (needsTypeScript) render("linting/core/ts");
|
|
2506
|
+
else render("linting/core/js");
|
|
2507
|
+
if (needsPrettier) render("linting/prettier");
|
|
2508
|
+
}
|
|
2509
|
+
if (needsPrettier) render("formatting/prettier");
|
|
2510
|
+
render(`code/${needsTypeScript ? "typescript-" : "default"}`);
|
|
2511
|
+
render("entry/default");
|
|
2512
|
+
const dataStore = {};
|
|
2513
|
+
const indexHtmlPath = path.resolve(root, "index.html");
|
|
2514
|
+
dataStore[indexHtmlPath] = {
|
|
2515
|
+
title: result.projectName,
|
|
2516
|
+
entryExt: needsTypeScript ? "tsx" : "jsx"
|
|
2517
|
+
};
|
|
2518
|
+
for (const cb of callbacks) await cb(dataStore);
|
|
2519
|
+
preOrderDirectoryTraverse(root, () => {}, (filepath) => {
|
|
2520
|
+
if (filepath.endsWith(".ejs")) {
|
|
2521
|
+
const template = fs.readFileSync(filepath, "utf-8");
|
|
2522
|
+
const dest = filepath.replace(/\.ejs$/, "");
|
|
2523
|
+
const content = import_ejs.render(template, dataStore[dest]);
|
|
2524
|
+
fs.writeFileSync(dest, content);
|
|
2525
|
+
fs.unlinkSync(filepath);
|
|
2526
|
+
}
|
|
2527
|
+
});
|
|
2528
|
+
if (needsTypeScript) {
|
|
2529
|
+
preOrderDirectoryTraverse(root, () => {}, (filepath) => {
|
|
2530
|
+
if (filepath.endsWith(".js")) {
|
|
2531
|
+
const tsFilePath = filepath.replace(/\.js$/, ".ts");
|
|
2532
|
+
if (fs.existsSync(tsFilePath)) fs.unlinkSync(filepath);
|
|
2533
|
+
else fs.renameSync(filepath, tsFilePath);
|
|
2534
|
+
} else if (filepath.endsWith(".jsx")) {
|
|
2535
|
+
const tsxFilePath = filepath.replace(/\.jsx$/, ".tsx");
|
|
2536
|
+
if (fs.existsSync(tsxFilePath)) fs.unlinkSync(filepath);
|
|
2537
|
+
else fs.renameSync(filepath, tsxFilePath);
|
|
2538
|
+
} else if (path.basename(filepath) === "jsconfig.json") fs.unlinkSync(filepath);
|
|
2539
|
+
});
|
|
2540
|
+
const indexHtmlPath$1 = path.resolve(root, "index.html");
|
|
2541
|
+
const indexHtmlContent = fs.readFileSync(indexHtmlPath$1, "utf8");
|
|
2542
|
+
fs.writeFileSync(indexHtmlPath$1, indexHtmlContent.replace("src/main.js", "src/main.ts"));
|
|
2543
|
+
} else preOrderDirectoryTraverse(root, () => {}, (filepath) => {
|
|
2544
|
+
if (filepath.endsWith(".ts") || filepath.endsWith(".tsx")) fs.unlinkSync(filepath);
|
|
2545
|
+
});
|
|
2546
|
+
const userAgent = process.env.npm_config_user_agent ?? "";
|
|
2547
|
+
const packageManager = /pnpm/.test(userAgent) ? "pnpm" : /yarn/.test(userAgent) ? "yarn" : /bun/.test(userAgent) ? "bun" : "npm";
|
|
2548
|
+
let outroMessage = `${language.infos.done}\n\n`;
|
|
2549
|
+
if (root !== cwd) {
|
|
2550
|
+
const cdProjectName = path.relative(cwd, root);
|
|
2551
|
+
outroMessage += ` ${(0, import_picocolors.bold)((0, import_picocolors.green)(`cd ${cdProjectName.includes(" ") ? `"${cdProjectName}"` : cdProjectName}`))}\n`;
|
|
2552
|
+
}
|
|
2553
|
+
outroMessage += ` ${(0, import_picocolors.bold)((0, import_picocolors.green)(getCommand(packageManager, "install")))}\n`;
|
|
2554
|
+
if (needsEslint) outroMessage += ` ${(0, import_picocolors.bold)((0, import_picocolors.green)(getCommand(packageManager, "lint")))}\n`;
|
|
2555
|
+
if (needsPrettier) outroMessage += ` ${(0, import_picocolors.bold)((0, import_picocolors.green)(getCommand(packageManager, "format")))}\n`;
|
|
2556
|
+
outroMessage += ` ${(0, import_picocolors.bold)((0, import_picocolors.green)(getCommand(packageManager, "dev")))}\n`;
|
|
2557
|
+
if (!dotGitDirectoryState.hasDotGitDirectory) outroMessage += `
|
|
2558
|
+
${(0, import_picocolors.dim)("|")} ${language.infos.optionalGitCommand}
|
|
2559
|
+
|
|
2560
|
+
${(0, import_picocolors.bold)((0, import_picocolors.green)("git init && git add -A && git commit -m \"initial commit\""))}`;
|
|
2561
|
+
Se(outroMessage);
|
|
2562
|
+
}
|
|
2563
|
+
createProject().catch((error) => {
|
|
2564
|
+
console.error(error);
|
|
2565
|
+
process.exit(1);
|
|
2566
|
+
});
|
|
2567
|
+
|
|
2568
|
+
//#endregion
|
|
2569
|
+
export { };
|