create-vite-react-cli 0.4.1 → 0.4.3
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/README.md +20 -0
- package/dist/index.mjs +2597 -0
- package/index.js +3 -0
- package/package.json +52 -58
- package/templates/formatting/prettier/package.json +3 -3
- package/bundle.js +0 -2013
package/bundle.js
DELETED
|
@@ -1,2013 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/*! create-vite-react-cli v0.4.1 | MIT */
|
|
3
|
-
import * as fs from 'node:fs';
|
|
4
|
-
import * as path from 'node:path';
|
|
5
|
-
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
|
-
import { parseArgs } from 'node:util';
|
|
7
|
-
import require$$0 from 'fs';
|
|
8
|
-
import require$$1 from 'path';
|
|
9
|
-
import y$1, { stdin, stdout } from 'node:process';
|
|
10
|
-
import g from 'node:readline';
|
|
11
|
-
import { Writable } from 'node:stream';
|
|
12
|
-
|
|
13
|
-
function getDefaultExportFromCjs (x) {
|
|
14
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
var ejs$1 = {};
|
|
18
|
-
|
|
19
|
-
var utils = {};
|
|
20
|
-
|
|
21
|
-
/*
|
|
22
|
-
* EJS Embedded JavaScript templates
|
|
23
|
-
* Copyright 2112 Matthew Eernisse (mde@fleegix.org)
|
|
24
|
-
*
|
|
25
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
26
|
-
* you may not use this file except in compliance with the License.
|
|
27
|
-
* You may obtain a copy of the License at
|
|
28
|
-
*
|
|
29
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
30
|
-
*
|
|
31
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
32
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
33
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
34
|
-
* See the License for the specific language governing permissions and
|
|
35
|
-
* limitations under the License.
|
|
36
|
-
*
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
var hasRequiredUtils;
|
|
40
|
-
|
|
41
|
-
function requireUtils () {
|
|
42
|
-
if (hasRequiredUtils) return utils;
|
|
43
|
-
hasRequiredUtils = 1;
|
|
44
|
-
(function (exports$1) {
|
|
45
|
-
|
|
46
|
-
var regExpChars = /[|\\{}()[\]^$+*?.]/g;
|
|
47
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
48
|
-
var hasOwn = function (obj, key) { return hasOwnProperty.apply(obj, [key]); };
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Escape characters reserved in regular expressions.
|
|
52
|
-
*
|
|
53
|
-
* If `string` is `undefined` or `null`, the empty string is returned.
|
|
54
|
-
*
|
|
55
|
-
* @param {String} string Input string
|
|
56
|
-
* @return {String} Escaped string
|
|
57
|
-
* @static
|
|
58
|
-
* @private
|
|
59
|
-
*/
|
|
60
|
-
exports$1.escapeRegExpChars = function (string) {
|
|
61
|
-
// istanbul ignore if
|
|
62
|
-
if (!string) {
|
|
63
|
-
return '';
|
|
64
|
-
}
|
|
65
|
-
return String(string).replace(regExpChars, '\\$&');
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
var _ENCODE_HTML_RULES = {
|
|
69
|
-
'&': '&',
|
|
70
|
-
'<': '<',
|
|
71
|
-
'>': '>',
|
|
72
|
-
'"': '"',
|
|
73
|
-
"'": '''
|
|
74
|
-
};
|
|
75
|
-
var _MATCH_HTML = /[&<>'"]/g;
|
|
76
|
-
|
|
77
|
-
function encode_char(c) {
|
|
78
|
-
return _ENCODE_HTML_RULES[c] || c;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Stringified version of constants used by {@link module:utils.escapeXML}.
|
|
83
|
-
*
|
|
84
|
-
* It is used in the process of generating {@link ClientFunction}s.
|
|
85
|
-
*
|
|
86
|
-
* @readonly
|
|
87
|
-
* @type {String}
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
var escapeFuncStr =
|
|
91
|
-
'var _ENCODE_HTML_RULES = {\n'
|
|
92
|
-
+ ' "&": "&"\n'
|
|
93
|
-
+ ' , "<": "<"\n'
|
|
94
|
-
+ ' , ">": ">"\n'
|
|
95
|
-
+ ' , \'"\': """\n'
|
|
96
|
-
+ ' , "\'": "'"\n'
|
|
97
|
-
+ ' }\n'
|
|
98
|
-
+ ' , _MATCH_HTML = /[&<>\'"]/g;\n'
|
|
99
|
-
+ 'function encode_char(c) {\n'
|
|
100
|
-
+ ' return _ENCODE_HTML_RULES[c] || c;\n'
|
|
101
|
-
+ '};\n';
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Escape characters reserved in XML.
|
|
105
|
-
*
|
|
106
|
-
* If `markup` is `undefined` or `null`, the empty string is returned.
|
|
107
|
-
*
|
|
108
|
-
* @implements {EscapeCallback}
|
|
109
|
-
* @param {String} markup Input string
|
|
110
|
-
* @return {String} Escaped string
|
|
111
|
-
* @static
|
|
112
|
-
* @private
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
exports$1.escapeXML = function (markup) {
|
|
116
|
-
return markup == undefined
|
|
117
|
-
? ''
|
|
118
|
-
: String(markup)
|
|
119
|
-
.replace(_MATCH_HTML, encode_char);
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
function escapeXMLToString() {
|
|
123
|
-
return Function.prototype.toString.call(this) + ';\n' + escapeFuncStr;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
try {
|
|
127
|
-
if (typeof Object.defineProperty === 'function') {
|
|
128
|
-
// If the Function prototype is frozen, the "toString" property is non-writable. This means that any objects which inherit this property
|
|
129
|
-
// cannot have the property changed using an assignment. If using strict mode, attempting that will cause an error. If not using strict
|
|
130
|
-
// mode, attempting that will be silently ignored.
|
|
131
|
-
// However, we can still explicitly shadow the prototype's "toString" property by defining a new "toString" property on this object.
|
|
132
|
-
Object.defineProperty(exports$1.escapeXML, 'toString', { value: escapeXMLToString });
|
|
133
|
-
} else {
|
|
134
|
-
// If Object.defineProperty() doesn't exist, attempt to shadow this property using the assignment operator.
|
|
135
|
-
exports$1.escapeXML.toString = escapeXMLToString;
|
|
136
|
-
}
|
|
137
|
-
} catch (err) {
|
|
138
|
-
console.warn('Unable to set escapeXML.toString (is the Function prototype frozen?)');
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Naive copy of properties from one object to another.
|
|
143
|
-
* Does not recurse into non-scalar properties
|
|
144
|
-
* Does not check to see if the property has a value before copying
|
|
145
|
-
*
|
|
146
|
-
* @param {Object} to Destination object
|
|
147
|
-
* @param {Object} from Source object
|
|
148
|
-
* @return {Object} Destination object
|
|
149
|
-
* @static
|
|
150
|
-
* @private
|
|
151
|
-
*/
|
|
152
|
-
exports$1.shallowCopy = function (to, from) {
|
|
153
|
-
from = from || {};
|
|
154
|
-
if ((to !== null) && (to !== undefined)) {
|
|
155
|
-
for (var p in from) {
|
|
156
|
-
if (!hasOwn(from, p)) {
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
if (p === '__proto__' || p === 'constructor') {
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
to[p] = from[p];
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return to;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Naive copy of a list of key names, from one object to another.
|
|
170
|
-
* Only copies property if it is actually defined
|
|
171
|
-
* Does not recurse into non-scalar properties
|
|
172
|
-
*
|
|
173
|
-
* @param {Object} to Destination object
|
|
174
|
-
* @param {Object} from Source object
|
|
175
|
-
* @param {Array} list List of properties to copy
|
|
176
|
-
* @return {Object} Destination object
|
|
177
|
-
* @static
|
|
178
|
-
* @private
|
|
179
|
-
*/
|
|
180
|
-
exports$1.shallowCopyFromList = function (to, from, list) {
|
|
181
|
-
list = list || [];
|
|
182
|
-
from = from || {};
|
|
183
|
-
if ((to !== null) && (to !== undefined)) {
|
|
184
|
-
for (var i = 0; i < list.length; i++) {
|
|
185
|
-
var p = list[i];
|
|
186
|
-
if (typeof from[p] != 'undefined') {
|
|
187
|
-
if (!hasOwn(from, p)) {
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
|
-
if (p === '__proto__' || p === 'constructor') {
|
|
191
|
-
continue;
|
|
192
|
-
}
|
|
193
|
-
to[p] = from[p];
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
return to;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Simple in-process cache implementation. Does not implement limits of any
|
|
202
|
-
* sort.
|
|
203
|
-
*
|
|
204
|
-
* @implements {Cache}
|
|
205
|
-
* @static
|
|
206
|
-
* @private
|
|
207
|
-
*/
|
|
208
|
-
exports$1.cache = {
|
|
209
|
-
_data: {},
|
|
210
|
-
set: function (key, val) {
|
|
211
|
-
this._data[key] = val;
|
|
212
|
-
},
|
|
213
|
-
get: function (key) {
|
|
214
|
-
return this._data[key];
|
|
215
|
-
},
|
|
216
|
-
remove: function (key) {
|
|
217
|
-
delete this._data[key];
|
|
218
|
-
},
|
|
219
|
-
reset: function () {
|
|
220
|
-
this._data = {};
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Transforms hyphen case variable into camel case.
|
|
226
|
-
*
|
|
227
|
-
* @param {String} string Hyphen case string
|
|
228
|
-
* @return {String} Camel case string
|
|
229
|
-
* @static
|
|
230
|
-
* @private
|
|
231
|
-
*/
|
|
232
|
-
exports$1.hyphenToCamel = function (str) {
|
|
233
|
-
return str.replace(/-[a-z]/g, function (match) { return match[1].toUpperCase(); });
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Returns a null-prototype object in runtimes that support it
|
|
238
|
-
*
|
|
239
|
-
* @return {Object} Object, prototype will be set to null where possible
|
|
240
|
-
* @static
|
|
241
|
-
* @private
|
|
242
|
-
*/
|
|
243
|
-
exports$1.createNullProtoObjWherePossible = (function () {
|
|
244
|
-
if (typeof Object.create == 'function') {
|
|
245
|
-
return function () {
|
|
246
|
-
return Object.create(null);
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
if (!({__proto__: null} instanceof Object)) {
|
|
250
|
-
return function () {
|
|
251
|
-
return {__proto__: null};
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
// Not possible, just pass through
|
|
255
|
-
return function () {
|
|
256
|
-
return {};
|
|
257
|
-
};
|
|
258
|
-
})();
|
|
259
|
-
|
|
260
|
-
exports$1.hasOwnOnlyObject = function (obj) {
|
|
261
|
-
var o = exports$1.createNullProtoObjWherePossible();
|
|
262
|
-
for (var p in obj) {
|
|
263
|
-
if (hasOwn(obj, p)) {
|
|
264
|
-
o[p] = obj[p];
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return o;
|
|
268
|
-
};
|
|
269
|
-
} (utils));
|
|
270
|
-
return utils;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
var version$1 = "3.1.10";
|
|
274
|
-
var require$$3 = {
|
|
275
|
-
version: version$1};
|
|
276
|
-
|
|
277
|
-
/*
|
|
278
|
-
* EJS Embedded JavaScript templates
|
|
279
|
-
* Copyright 2112 Matthew Eernisse (mde@fleegix.org)
|
|
280
|
-
*
|
|
281
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
282
|
-
* you may not use this file except in compliance with the License.
|
|
283
|
-
* You may obtain a copy of the License at
|
|
284
|
-
*
|
|
285
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
286
|
-
*
|
|
287
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
288
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
289
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
290
|
-
* See the License for the specific language governing permissions and
|
|
291
|
-
* limitations under the License.
|
|
292
|
-
*
|
|
293
|
-
*/
|
|
294
|
-
|
|
295
|
-
var hasRequiredEjs;
|
|
296
|
-
|
|
297
|
-
function requireEjs () {
|
|
298
|
-
if (hasRequiredEjs) return ejs$1;
|
|
299
|
-
hasRequiredEjs = 1;
|
|
300
|
-
(function (exports$1) {
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* @file Embedded JavaScript templating engine. {@link http://ejs.co}
|
|
304
|
-
* @author Matthew Eernisse <mde@fleegix.org>
|
|
305
|
-
* @author Tiancheng "Timothy" Gu <timothygu99@gmail.com>
|
|
306
|
-
* @project EJS
|
|
307
|
-
* @license {@link http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0}
|
|
308
|
-
*/
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* EJS internal functions.
|
|
312
|
-
*
|
|
313
|
-
* Technically this "module" lies in the same file as {@link module:ejs}, for
|
|
314
|
-
* the sake of organization all the private functions re grouped into this
|
|
315
|
-
* module.
|
|
316
|
-
*
|
|
317
|
-
* @module ejs-internal
|
|
318
|
-
* @private
|
|
319
|
-
*/
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Embedded JavaScript templating engine.
|
|
323
|
-
*
|
|
324
|
-
* @module ejs
|
|
325
|
-
* @public
|
|
326
|
-
*/
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
var fs = require$$0;
|
|
330
|
-
var path = require$$1;
|
|
331
|
-
var utils = requireUtils();
|
|
332
|
-
|
|
333
|
-
var scopeOptionWarned = false;
|
|
334
|
-
/** @type {string} */
|
|
335
|
-
var _VERSION_STRING = require$$3.version;
|
|
336
|
-
var _DEFAULT_OPEN_DELIMITER = '<';
|
|
337
|
-
var _DEFAULT_CLOSE_DELIMITER = '>';
|
|
338
|
-
var _DEFAULT_DELIMITER = '%';
|
|
339
|
-
var _DEFAULT_LOCALS_NAME = 'locals';
|
|
340
|
-
var _NAME = 'ejs';
|
|
341
|
-
var _REGEX_STRING = '(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)';
|
|
342
|
-
var _OPTS_PASSABLE_WITH_DATA = ['delimiter', 'scope', 'context', 'debug', 'compileDebug',
|
|
343
|
-
'client', '_with', 'rmWhitespace', 'strict', 'filename', 'async'];
|
|
344
|
-
// We don't allow 'cache' option to be passed in the data obj for
|
|
345
|
-
// the normal `render` call, but this is where Express 2 & 3 put it
|
|
346
|
-
// so we make an exception for `renderFile`
|
|
347
|
-
var _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat('cache');
|
|
348
|
-
var _BOM = /^\uFEFF/;
|
|
349
|
-
var _JS_IDENTIFIER = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* EJS template function cache. This can be a LRU object from lru-cache NPM
|
|
353
|
-
* module. By default, it is {@link module:utils.cache}, a simple in-process
|
|
354
|
-
* cache that grows continuously.
|
|
355
|
-
*
|
|
356
|
-
* @type {Cache}
|
|
357
|
-
*/
|
|
358
|
-
|
|
359
|
-
exports$1.cache = utils.cache;
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* Custom file loader. Useful for template preprocessing or restricting access
|
|
363
|
-
* to a certain part of the filesystem.
|
|
364
|
-
*
|
|
365
|
-
* @type {fileLoader}
|
|
366
|
-
*/
|
|
367
|
-
|
|
368
|
-
exports$1.fileLoader = fs.readFileSync;
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Name of the object containing the locals.
|
|
372
|
-
*
|
|
373
|
-
* This variable is overridden by {@link Options}`.localsName` if it is not
|
|
374
|
-
* `undefined`.
|
|
375
|
-
*
|
|
376
|
-
* @type {String}
|
|
377
|
-
* @public
|
|
378
|
-
*/
|
|
379
|
-
|
|
380
|
-
exports$1.localsName = _DEFAULT_LOCALS_NAME;
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Promise implementation -- defaults to the native implementation if available
|
|
384
|
-
* This is mostly just for testability
|
|
385
|
-
*
|
|
386
|
-
* @type {PromiseConstructorLike}
|
|
387
|
-
* @public
|
|
388
|
-
*/
|
|
389
|
-
|
|
390
|
-
exports$1.promiseImpl = (new Function('return this;'))().Promise;
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Get the path to the included file from the parent file path and the
|
|
394
|
-
* specified path.
|
|
395
|
-
*
|
|
396
|
-
* @param {String} name specified path
|
|
397
|
-
* @param {String} filename parent file path
|
|
398
|
-
* @param {Boolean} [isDir=false] whether the parent file path is a directory
|
|
399
|
-
* @return {String}
|
|
400
|
-
*/
|
|
401
|
-
exports$1.resolveInclude = function(name, filename, isDir) {
|
|
402
|
-
var dirname = path.dirname;
|
|
403
|
-
var extname = path.extname;
|
|
404
|
-
var resolve = path.resolve;
|
|
405
|
-
var includePath = resolve(isDir ? filename : dirname(filename), name);
|
|
406
|
-
var ext = extname(name);
|
|
407
|
-
if (!ext) {
|
|
408
|
-
includePath += '.ejs';
|
|
409
|
-
}
|
|
410
|
-
return includePath;
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Try to resolve file path on multiple directories
|
|
415
|
-
*
|
|
416
|
-
* @param {String} name specified path
|
|
417
|
-
* @param {Array<String>} paths list of possible parent directory paths
|
|
418
|
-
* @return {String}
|
|
419
|
-
*/
|
|
420
|
-
function resolvePaths(name, paths) {
|
|
421
|
-
var filePath;
|
|
422
|
-
if (paths.some(function (v) {
|
|
423
|
-
filePath = exports$1.resolveInclude(name, v, true);
|
|
424
|
-
return fs.existsSync(filePath);
|
|
425
|
-
})) {
|
|
426
|
-
return filePath;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* Get the path to the included file by Options
|
|
432
|
-
*
|
|
433
|
-
* @param {String} path specified path
|
|
434
|
-
* @param {Options} options compilation options
|
|
435
|
-
* @return {String}
|
|
436
|
-
*/
|
|
437
|
-
function getIncludePath(path, options) {
|
|
438
|
-
var includePath;
|
|
439
|
-
var filePath;
|
|
440
|
-
var views = options.views;
|
|
441
|
-
var match = /^[A-Za-z]+:\\|^\//.exec(path);
|
|
442
|
-
|
|
443
|
-
// Abs path
|
|
444
|
-
if (match && match.length) {
|
|
445
|
-
path = path.replace(/^\/*/, '');
|
|
446
|
-
if (Array.isArray(options.root)) {
|
|
447
|
-
includePath = resolvePaths(path, options.root);
|
|
448
|
-
} else {
|
|
449
|
-
includePath = exports$1.resolveInclude(path, options.root || '/', true);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
// Relative paths
|
|
453
|
-
else {
|
|
454
|
-
// Look relative to a passed filename first
|
|
455
|
-
if (options.filename) {
|
|
456
|
-
filePath = exports$1.resolveInclude(path, options.filename);
|
|
457
|
-
if (fs.existsSync(filePath)) {
|
|
458
|
-
includePath = filePath;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
// Then look in any views directories
|
|
462
|
-
if (!includePath && Array.isArray(views)) {
|
|
463
|
-
includePath = resolvePaths(path, views);
|
|
464
|
-
}
|
|
465
|
-
if (!includePath && typeof options.includer !== 'function') {
|
|
466
|
-
throw new Error('Could not find the include file "' +
|
|
467
|
-
options.escapeFunction(path) + '"');
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
return includePath;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* Get the template from a string or a file, either compiled on-the-fly or
|
|
475
|
-
* read from cache (if enabled), and cache the template if needed.
|
|
476
|
-
*
|
|
477
|
-
* If `template` is not set, the file specified in `options.filename` will be
|
|
478
|
-
* read.
|
|
479
|
-
*
|
|
480
|
-
* If `options.cache` is true, this function reads the file from
|
|
481
|
-
* `options.filename` so it must be set prior to calling this function.
|
|
482
|
-
*
|
|
483
|
-
* @memberof module:ejs-internal
|
|
484
|
-
* @param {Options} options compilation options
|
|
485
|
-
* @param {String} [template] template source
|
|
486
|
-
* @return {(TemplateFunction|ClientFunction)}
|
|
487
|
-
* Depending on the value of `options.client`, either type might be returned.
|
|
488
|
-
* @static
|
|
489
|
-
*/
|
|
490
|
-
|
|
491
|
-
function handleCache(options, template) {
|
|
492
|
-
var func;
|
|
493
|
-
var filename = options.filename;
|
|
494
|
-
var hasTemplate = arguments.length > 1;
|
|
495
|
-
|
|
496
|
-
if (options.cache) {
|
|
497
|
-
if (!filename) {
|
|
498
|
-
throw new Error('cache option requires a filename');
|
|
499
|
-
}
|
|
500
|
-
func = exports$1.cache.get(filename);
|
|
501
|
-
if (func) {
|
|
502
|
-
return func;
|
|
503
|
-
}
|
|
504
|
-
if (!hasTemplate) {
|
|
505
|
-
template = fileLoader(filename).toString().replace(_BOM, '');
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
else if (!hasTemplate) {
|
|
509
|
-
// istanbul ignore if: should not happen at all
|
|
510
|
-
if (!filename) {
|
|
511
|
-
throw new Error('Internal EJS error: no file name or template '
|
|
512
|
-
+ 'provided');
|
|
513
|
-
}
|
|
514
|
-
template = fileLoader(filename).toString().replace(_BOM, '');
|
|
515
|
-
}
|
|
516
|
-
func = exports$1.compile(template, options);
|
|
517
|
-
if (options.cache) {
|
|
518
|
-
exports$1.cache.set(filename, func);
|
|
519
|
-
}
|
|
520
|
-
return func;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* Try calling handleCache with the given options and data and call the
|
|
525
|
-
* callback with the result. If an error occurs, call the callback with
|
|
526
|
-
* the error. Used by renderFile().
|
|
527
|
-
*
|
|
528
|
-
* @memberof module:ejs-internal
|
|
529
|
-
* @param {Options} options compilation options
|
|
530
|
-
* @param {Object} data template data
|
|
531
|
-
* @param {RenderFileCallback} cb callback
|
|
532
|
-
* @static
|
|
533
|
-
*/
|
|
534
|
-
|
|
535
|
-
function tryHandleCache(options, data, cb) {
|
|
536
|
-
var result;
|
|
537
|
-
if (!cb) {
|
|
538
|
-
if (typeof exports$1.promiseImpl == 'function') {
|
|
539
|
-
return new exports$1.promiseImpl(function (resolve, reject) {
|
|
540
|
-
try {
|
|
541
|
-
result = handleCache(options)(data);
|
|
542
|
-
resolve(result);
|
|
543
|
-
}
|
|
544
|
-
catch (err) {
|
|
545
|
-
reject(err);
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
else {
|
|
550
|
-
throw new Error('Please provide a callback function');
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
else {
|
|
554
|
-
try {
|
|
555
|
-
result = handleCache(options)(data);
|
|
556
|
-
}
|
|
557
|
-
catch (err) {
|
|
558
|
-
return cb(err);
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
cb(null, result);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
* fileLoader is independent
|
|
567
|
-
*
|
|
568
|
-
* @param {String} filePath ejs file path.
|
|
569
|
-
* @return {String} The contents of the specified file.
|
|
570
|
-
* @static
|
|
571
|
-
*/
|
|
572
|
-
|
|
573
|
-
function fileLoader(filePath){
|
|
574
|
-
return exports$1.fileLoader(filePath);
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
/**
|
|
578
|
-
* Get the template function.
|
|
579
|
-
*
|
|
580
|
-
* If `options.cache` is `true`, then the template is cached.
|
|
581
|
-
*
|
|
582
|
-
* @memberof module:ejs-internal
|
|
583
|
-
* @param {String} path path for the specified file
|
|
584
|
-
* @param {Options} options compilation options
|
|
585
|
-
* @return {(TemplateFunction|ClientFunction)}
|
|
586
|
-
* Depending on the value of `options.client`, either type might be returned
|
|
587
|
-
* @static
|
|
588
|
-
*/
|
|
589
|
-
|
|
590
|
-
function includeFile(path, options) {
|
|
591
|
-
var opts = utils.shallowCopy(utils.createNullProtoObjWherePossible(), options);
|
|
592
|
-
opts.filename = getIncludePath(path, opts);
|
|
593
|
-
if (typeof options.includer === 'function') {
|
|
594
|
-
var includerResult = options.includer(path, opts.filename);
|
|
595
|
-
if (includerResult) {
|
|
596
|
-
if (includerResult.filename) {
|
|
597
|
-
opts.filename = includerResult.filename;
|
|
598
|
-
}
|
|
599
|
-
if (includerResult.template) {
|
|
600
|
-
return handleCache(opts, includerResult.template);
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
return handleCache(opts);
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* Re-throw the given `err` in context to the `str` of ejs, `filename`, and
|
|
609
|
-
* `lineno`.
|
|
610
|
-
*
|
|
611
|
-
* @implements {RethrowCallback}
|
|
612
|
-
* @memberof module:ejs-internal
|
|
613
|
-
* @param {Error} err Error object
|
|
614
|
-
* @param {String} str EJS source
|
|
615
|
-
* @param {String} flnm file name of the EJS file
|
|
616
|
-
* @param {Number} lineno line number of the error
|
|
617
|
-
* @param {EscapeCallback} esc
|
|
618
|
-
* @static
|
|
619
|
-
*/
|
|
620
|
-
|
|
621
|
-
function rethrow(err, str, flnm, lineno, esc) {
|
|
622
|
-
var lines = str.split('\n');
|
|
623
|
-
var start = Math.max(lineno - 3, 0);
|
|
624
|
-
var end = Math.min(lines.length, lineno + 3);
|
|
625
|
-
var filename = esc(flnm);
|
|
626
|
-
// Error context
|
|
627
|
-
var context = lines.slice(start, end).map(function (line, i){
|
|
628
|
-
var curr = i + start + 1;
|
|
629
|
-
return (curr == lineno ? ' >> ' : ' ')
|
|
630
|
-
+ curr
|
|
631
|
-
+ '| '
|
|
632
|
-
+ line;
|
|
633
|
-
}).join('\n');
|
|
634
|
-
|
|
635
|
-
// Alter exception message
|
|
636
|
-
err.path = filename;
|
|
637
|
-
err.message = (filename || 'ejs') + ':'
|
|
638
|
-
+ lineno + '\n'
|
|
639
|
-
+ context + '\n\n'
|
|
640
|
-
+ err.message;
|
|
641
|
-
|
|
642
|
-
throw err;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
function stripSemi(str){
|
|
646
|
-
return str.replace(/;(\s*$)/, '$1');
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
/**
|
|
650
|
-
* Compile the given `str` of ejs into a template function.
|
|
651
|
-
*
|
|
652
|
-
* @param {String} template EJS template
|
|
653
|
-
*
|
|
654
|
-
* @param {Options} [opts] compilation options
|
|
655
|
-
*
|
|
656
|
-
* @return {(TemplateFunction|ClientFunction)}
|
|
657
|
-
* Depending on the value of `opts.client`, either type might be returned.
|
|
658
|
-
* Note that the return type of the function also depends on the value of `opts.async`.
|
|
659
|
-
* @public
|
|
660
|
-
*/
|
|
661
|
-
|
|
662
|
-
exports$1.compile = function compile(template, opts) {
|
|
663
|
-
var templ;
|
|
664
|
-
|
|
665
|
-
// v1 compat
|
|
666
|
-
// 'scope' is 'context'
|
|
667
|
-
// FIXME: Remove this in a future version
|
|
668
|
-
if (opts && opts.scope) {
|
|
669
|
-
if (!scopeOptionWarned){
|
|
670
|
-
console.warn('`scope` option is deprecated and will be removed in EJS 3');
|
|
671
|
-
scopeOptionWarned = true;
|
|
672
|
-
}
|
|
673
|
-
if (!opts.context) {
|
|
674
|
-
opts.context = opts.scope;
|
|
675
|
-
}
|
|
676
|
-
delete opts.scope;
|
|
677
|
-
}
|
|
678
|
-
templ = new Template(template, opts);
|
|
679
|
-
return templ.compile();
|
|
680
|
-
};
|
|
681
|
-
|
|
682
|
-
/**
|
|
683
|
-
* Render the given `template` of ejs.
|
|
684
|
-
*
|
|
685
|
-
* If you would like to include options but not data, you need to explicitly
|
|
686
|
-
* call this function with `data` being an empty object or `null`.
|
|
687
|
-
*
|
|
688
|
-
* @param {String} template EJS template
|
|
689
|
-
* @param {Object} [data={}] template data
|
|
690
|
-
* @param {Options} [opts={}] compilation and rendering options
|
|
691
|
-
* @return {(String|Promise<String>)}
|
|
692
|
-
* Return value type depends on `opts.async`.
|
|
693
|
-
* @public
|
|
694
|
-
*/
|
|
695
|
-
|
|
696
|
-
exports$1.render = function (template, d, o) {
|
|
697
|
-
var data = d || utils.createNullProtoObjWherePossible();
|
|
698
|
-
var opts = o || utils.createNullProtoObjWherePossible();
|
|
699
|
-
|
|
700
|
-
// No options object -- if there are optiony names
|
|
701
|
-
// in the data, copy them to options
|
|
702
|
-
if (arguments.length == 2) {
|
|
703
|
-
utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
return handleCache(opts, template)(data);
|
|
707
|
-
};
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
* Render an EJS file at the given `path` and callback `cb(err, str)`.
|
|
711
|
-
*
|
|
712
|
-
* If you would like to include options but not data, you need to explicitly
|
|
713
|
-
* call this function with `data` being an empty object or `null`.
|
|
714
|
-
*
|
|
715
|
-
* @param {String} path path to the EJS file
|
|
716
|
-
* @param {Object} [data={}] template data
|
|
717
|
-
* @param {Options} [opts={}] compilation and rendering options
|
|
718
|
-
* @param {RenderFileCallback} cb callback
|
|
719
|
-
* @public
|
|
720
|
-
*/
|
|
721
|
-
|
|
722
|
-
exports$1.renderFile = function () {
|
|
723
|
-
var args = Array.prototype.slice.call(arguments);
|
|
724
|
-
var filename = args.shift();
|
|
725
|
-
var cb;
|
|
726
|
-
var opts = {filename: filename};
|
|
727
|
-
var data;
|
|
728
|
-
var viewOpts;
|
|
729
|
-
|
|
730
|
-
// Do we have a callback?
|
|
731
|
-
if (typeof arguments[arguments.length - 1] == 'function') {
|
|
732
|
-
cb = args.pop();
|
|
733
|
-
}
|
|
734
|
-
// Do we have data/opts?
|
|
735
|
-
if (args.length) {
|
|
736
|
-
// Should always have data obj
|
|
737
|
-
data = args.shift();
|
|
738
|
-
// Normal passed opts (data obj + opts obj)
|
|
739
|
-
if (args.length) {
|
|
740
|
-
// Use shallowCopy so we don't pollute passed in opts obj with new vals
|
|
741
|
-
utils.shallowCopy(opts, args.pop());
|
|
742
|
-
}
|
|
743
|
-
// Special casing for Express (settings + opts-in-data)
|
|
744
|
-
else {
|
|
745
|
-
// Express 3 and 4
|
|
746
|
-
if (data.settings) {
|
|
747
|
-
// Pull a few things from known locations
|
|
748
|
-
if (data.settings.views) {
|
|
749
|
-
opts.views = data.settings.views;
|
|
750
|
-
}
|
|
751
|
-
if (data.settings['view cache']) {
|
|
752
|
-
opts.cache = true;
|
|
753
|
-
}
|
|
754
|
-
// Undocumented after Express 2, but still usable, esp. for
|
|
755
|
-
// items that are unsafe to be passed along with data, like `root`
|
|
756
|
-
viewOpts = data.settings['view options'];
|
|
757
|
-
if (viewOpts) {
|
|
758
|
-
utils.shallowCopy(opts, viewOpts);
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
// Express 2 and lower, values set in app.locals, or people who just
|
|
762
|
-
// want to pass options in their data. NOTE: These values will override
|
|
763
|
-
// anything previously set in settings or settings['view options']
|
|
764
|
-
utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA_EXPRESS);
|
|
765
|
-
}
|
|
766
|
-
opts.filename = filename;
|
|
767
|
-
}
|
|
768
|
-
else {
|
|
769
|
-
data = utils.createNullProtoObjWherePossible();
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
return tryHandleCache(opts, data, cb);
|
|
773
|
-
};
|
|
774
|
-
|
|
775
|
-
/**
|
|
776
|
-
* Clear intermediate JavaScript cache. Calls {@link Cache#reset}.
|
|
777
|
-
* @public
|
|
778
|
-
*/
|
|
779
|
-
|
|
780
|
-
/**
|
|
781
|
-
* EJS template class
|
|
782
|
-
* @public
|
|
783
|
-
*/
|
|
784
|
-
exports$1.Template = Template;
|
|
785
|
-
|
|
786
|
-
exports$1.clearCache = function () {
|
|
787
|
-
exports$1.cache.reset();
|
|
788
|
-
};
|
|
789
|
-
|
|
790
|
-
function Template(text, optsParam) {
|
|
791
|
-
var opts = utils.hasOwnOnlyObject(optsParam);
|
|
792
|
-
var options = utils.createNullProtoObjWherePossible();
|
|
793
|
-
this.templateText = text;
|
|
794
|
-
/** @type {string | null} */
|
|
795
|
-
this.mode = null;
|
|
796
|
-
this.truncate = false;
|
|
797
|
-
this.currentLine = 1;
|
|
798
|
-
this.source = '';
|
|
799
|
-
options.client = opts.client || false;
|
|
800
|
-
options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
|
|
801
|
-
options.compileDebug = opts.compileDebug !== false;
|
|
802
|
-
options.debug = !!opts.debug;
|
|
803
|
-
options.filename = opts.filename;
|
|
804
|
-
options.openDelimiter = opts.openDelimiter || exports$1.openDelimiter || _DEFAULT_OPEN_DELIMITER;
|
|
805
|
-
options.closeDelimiter = opts.closeDelimiter || exports$1.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;
|
|
806
|
-
options.delimiter = opts.delimiter || exports$1.delimiter || _DEFAULT_DELIMITER;
|
|
807
|
-
options.strict = opts.strict || false;
|
|
808
|
-
options.context = opts.context;
|
|
809
|
-
options.cache = opts.cache || false;
|
|
810
|
-
options.rmWhitespace = opts.rmWhitespace;
|
|
811
|
-
options.root = opts.root;
|
|
812
|
-
options.includer = opts.includer;
|
|
813
|
-
options.outputFunctionName = opts.outputFunctionName;
|
|
814
|
-
options.localsName = opts.localsName || exports$1.localsName || _DEFAULT_LOCALS_NAME;
|
|
815
|
-
options.views = opts.views;
|
|
816
|
-
options.async = opts.async;
|
|
817
|
-
options.destructuredLocals = opts.destructuredLocals;
|
|
818
|
-
options.legacyInclude = typeof opts.legacyInclude != 'undefined' ? !!opts.legacyInclude : true;
|
|
819
|
-
|
|
820
|
-
if (options.strict) {
|
|
821
|
-
options._with = false;
|
|
822
|
-
}
|
|
823
|
-
else {
|
|
824
|
-
options._with = typeof opts._with != 'undefined' ? opts._with : true;
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
this.opts = options;
|
|
828
|
-
|
|
829
|
-
this.regex = this.createRegex();
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
Template.modes = {
|
|
833
|
-
EVAL: 'eval',
|
|
834
|
-
ESCAPED: 'escaped',
|
|
835
|
-
RAW: 'raw',
|
|
836
|
-
COMMENT: 'comment',
|
|
837
|
-
LITERAL: 'literal'
|
|
838
|
-
};
|
|
839
|
-
|
|
840
|
-
Template.prototype = {
|
|
841
|
-
createRegex: function () {
|
|
842
|
-
var str = _REGEX_STRING;
|
|
843
|
-
var delim = utils.escapeRegExpChars(this.opts.delimiter);
|
|
844
|
-
var open = utils.escapeRegExpChars(this.opts.openDelimiter);
|
|
845
|
-
var close = utils.escapeRegExpChars(this.opts.closeDelimiter);
|
|
846
|
-
str = str.replace(/%/g, delim)
|
|
847
|
-
.replace(/</g, open)
|
|
848
|
-
.replace(/>/g, close);
|
|
849
|
-
return new RegExp(str);
|
|
850
|
-
},
|
|
851
|
-
|
|
852
|
-
compile: function () {
|
|
853
|
-
/** @type {string} */
|
|
854
|
-
var src;
|
|
855
|
-
/** @type {ClientFunction} */
|
|
856
|
-
var fn;
|
|
857
|
-
var opts = this.opts;
|
|
858
|
-
var prepended = '';
|
|
859
|
-
var appended = '';
|
|
860
|
-
/** @type {EscapeCallback} */
|
|
861
|
-
var escapeFn = opts.escapeFunction;
|
|
862
|
-
/** @type {FunctionConstructor} */
|
|
863
|
-
var ctor;
|
|
864
|
-
/** @type {string} */
|
|
865
|
-
var sanitizedFilename = opts.filename ? JSON.stringify(opts.filename) : 'undefined';
|
|
866
|
-
|
|
867
|
-
if (!this.source) {
|
|
868
|
-
this.generateSource();
|
|
869
|
-
prepended +=
|
|
870
|
-
' var __output = "";\n' +
|
|
871
|
-
' function __append(s) { if (s !== undefined && s !== null) __output += s }\n';
|
|
872
|
-
if (opts.outputFunctionName) {
|
|
873
|
-
if (!_JS_IDENTIFIER.test(opts.outputFunctionName)) {
|
|
874
|
-
throw new Error('outputFunctionName is not a valid JS identifier.');
|
|
875
|
-
}
|
|
876
|
-
prepended += ' var ' + opts.outputFunctionName + ' = __append;' + '\n';
|
|
877
|
-
}
|
|
878
|
-
if (opts.localsName && !_JS_IDENTIFIER.test(opts.localsName)) {
|
|
879
|
-
throw new Error('localsName is not a valid JS identifier.');
|
|
880
|
-
}
|
|
881
|
-
if (opts.destructuredLocals && opts.destructuredLocals.length) {
|
|
882
|
-
var destructuring = ' var __locals = (' + opts.localsName + ' || {}),\n';
|
|
883
|
-
for (var i = 0; i < opts.destructuredLocals.length; i++) {
|
|
884
|
-
var name = opts.destructuredLocals[i];
|
|
885
|
-
if (!_JS_IDENTIFIER.test(name)) {
|
|
886
|
-
throw new Error('destructuredLocals[' + i + '] is not a valid JS identifier.');
|
|
887
|
-
}
|
|
888
|
-
if (i > 0) {
|
|
889
|
-
destructuring += ',\n ';
|
|
890
|
-
}
|
|
891
|
-
destructuring += name + ' = __locals.' + name;
|
|
892
|
-
}
|
|
893
|
-
prepended += destructuring + ';\n';
|
|
894
|
-
}
|
|
895
|
-
if (opts._with !== false) {
|
|
896
|
-
prepended += ' with (' + opts.localsName + ' || {}) {' + '\n';
|
|
897
|
-
appended += ' }' + '\n';
|
|
898
|
-
}
|
|
899
|
-
appended += ' return __output;' + '\n';
|
|
900
|
-
this.source = prepended + this.source + appended;
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
if (opts.compileDebug) {
|
|
904
|
-
src = 'var __line = 1' + '\n'
|
|
905
|
-
+ ' , __lines = ' + JSON.stringify(this.templateText) + '\n'
|
|
906
|
-
+ ' , __filename = ' + sanitizedFilename + ';' + '\n'
|
|
907
|
-
+ 'try {' + '\n'
|
|
908
|
-
+ this.source
|
|
909
|
-
+ '} catch (e) {' + '\n'
|
|
910
|
-
+ ' rethrow(e, __lines, __filename, __line, escapeFn);' + '\n'
|
|
911
|
-
+ '}' + '\n';
|
|
912
|
-
}
|
|
913
|
-
else {
|
|
914
|
-
src = this.source;
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
if (opts.client) {
|
|
918
|
-
src = 'escapeFn = escapeFn || ' + escapeFn.toString() + ';' + '\n' + src;
|
|
919
|
-
if (opts.compileDebug) {
|
|
920
|
-
src = 'rethrow = rethrow || ' + rethrow.toString() + ';' + '\n' + src;
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
if (opts.strict) {
|
|
925
|
-
src = '"use strict";\n' + src;
|
|
926
|
-
}
|
|
927
|
-
if (opts.debug) {
|
|
928
|
-
console.log(src);
|
|
929
|
-
}
|
|
930
|
-
if (opts.compileDebug && opts.filename) {
|
|
931
|
-
src = src + '\n'
|
|
932
|
-
+ '//# sourceURL=' + sanitizedFilename + '\n';
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
try {
|
|
936
|
-
if (opts.async) {
|
|
937
|
-
// Have to use generated function for this, since in envs without support,
|
|
938
|
-
// it breaks in parsing
|
|
939
|
-
try {
|
|
940
|
-
ctor = (new Function('return (async function(){}).constructor;'))();
|
|
941
|
-
}
|
|
942
|
-
catch(e) {
|
|
943
|
-
if (e instanceof SyntaxError) {
|
|
944
|
-
throw new Error('This environment does not support async/await');
|
|
945
|
-
}
|
|
946
|
-
else {
|
|
947
|
-
throw e;
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
else {
|
|
952
|
-
ctor = Function;
|
|
953
|
-
}
|
|
954
|
-
fn = new ctor(opts.localsName + ', escapeFn, include, rethrow', src);
|
|
955
|
-
}
|
|
956
|
-
catch(e) {
|
|
957
|
-
// istanbul ignore else
|
|
958
|
-
if (e instanceof SyntaxError) {
|
|
959
|
-
if (opts.filename) {
|
|
960
|
-
e.message += ' in ' + opts.filename;
|
|
961
|
-
}
|
|
962
|
-
e.message += ' while compiling ejs\n\n';
|
|
963
|
-
e.message += 'If the above error is not helpful, you may want to try EJS-Lint:\n';
|
|
964
|
-
e.message += 'https://github.com/RyanZim/EJS-Lint';
|
|
965
|
-
if (!opts.async) {
|
|
966
|
-
e.message += '\n';
|
|
967
|
-
e.message += 'Or, if you meant to create an async function, pass `async: true` as an option.';
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
throw e;
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
// Return a callable function which will execute the function
|
|
974
|
-
// created by the source-code, with the passed data as locals
|
|
975
|
-
// Adds a local `include` function which allows full recursive include
|
|
976
|
-
var returnedFn = opts.client ? fn : function anonymous(data) {
|
|
977
|
-
var include = function (path, includeData) {
|
|
978
|
-
var d = utils.shallowCopy(utils.createNullProtoObjWherePossible(), data);
|
|
979
|
-
if (includeData) {
|
|
980
|
-
d = utils.shallowCopy(d, includeData);
|
|
981
|
-
}
|
|
982
|
-
return includeFile(path, opts)(d);
|
|
983
|
-
};
|
|
984
|
-
return fn.apply(opts.context,
|
|
985
|
-
[data || utils.createNullProtoObjWherePossible(), escapeFn, include, rethrow]);
|
|
986
|
-
};
|
|
987
|
-
if (opts.filename && typeof Object.defineProperty === 'function') {
|
|
988
|
-
var filename = opts.filename;
|
|
989
|
-
var basename = path.basename(filename, path.extname(filename));
|
|
990
|
-
try {
|
|
991
|
-
Object.defineProperty(returnedFn, 'name', {
|
|
992
|
-
value: basename,
|
|
993
|
-
writable: false,
|
|
994
|
-
enumerable: false,
|
|
995
|
-
configurable: true
|
|
996
|
-
});
|
|
997
|
-
} catch (e) {/* ignore */}
|
|
998
|
-
}
|
|
999
|
-
return returnedFn;
|
|
1000
|
-
},
|
|
1001
|
-
|
|
1002
|
-
generateSource: function () {
|
|
1003
|
-
var opts = this.opts;
|
|
1004
|
-
|
|
1005
|
-
if (opts.rmWhitespace) {
|
|
1006
|
-
// Have to use two separate replace here as `^` and `$` operators don't
|
|
1007
|
-
// work well with `\r` and empty lines don't work well with the `m` flag.
|
|
1008
|
-
this.templateText =
|
|
1009
|
-
this.templateText.replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
// Slurp spaces and tabs before <%_ and after _%>
|
|
1013
|
-
this.templateText =
|
|
1014
|
-
this.templateText.replace(/[ \t]*<%_/gm, '<%_').replace(/_%>[ \t]*/gm, '_%>');
|
|
1015
|
-
|
|
1016
|
-
var self = this;
|
|
1017
|
-
var matches = this.parseTemplateText();
|
|
1018
|
-
var d = this.opts.delimiter;
|
|
1019
|
-
var o = this.opts.openDelimiter;
|
|
1020
|
-
var c = this.opts.closeDelimiter;
|
|
1021
|
-
|
|
1022
|
-
if (matches && matches.length) {
|
|
1023
|
-
matches.forEach(function (line, index) {
|
|
1024
|
-
var closing;
|
|
1025
|
-
// If this is an opening tag, check for closing tags
|
|
1026
|
-
// FIXME: May end up with some false positives here
|
|
1027
|
-
// Better to store modes as k/v with openDelimiter + delimiter as key
|
|
1028
|
-
// Then this can simply check against the map
|
|
1029
|
-
if ( line.indexOf(o + d) === 0 // If it is a tag
|
|
1030
|
-
&& line.indexOf(o + d + d) !== 0) { // and is not escaped
|
|
1031
|
-
closing = matches[index + 2];
|
|
1032
|
-
if (!(closing == d + c || closing == '-' + d + c || closing == '_' + d + c)) {
|
|
1033
|
-
throw new Error('Could not find matching close tag for "' + line + '".');
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
self.scanLine(line);
|
|
1037
|
-
});
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
},
|
|
1041
|
-
|
|
1042
|
-
parseTemplateText: function () {
|
|
1043
|
-
var str = this.templateText;
|
|
1044
|
-
var pat = this.regex;
|
|
1045
|
-
var result = pat.exec(str);
|
|
1046
|
-
var arr = [];
|
|
1047
|
-
var firstPos;
|
|
1048
|
-
|
|
1049
|
-
while (result) {
|
|
1050
|
-
firstPos = result.index;
|
|
1051
|
-
|
|
1052
|
-
if (firstPos !== 0) {
|
|
1053
|
-
arr.push(str.substring(0, firstPos));
|
|
1054
|
-
str = str.slice(firstPos);
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
arr.push(result[0]);
|
|
1058
|
-
str = str.slice(result[0].length);
|
|
1059
|
-
result = pat.exec(str);
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
if (str) {
|
|
1063
|
-
arr.push(str);
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
return arr;
|
|
1067
|
-
},
|
|
1068
|
-
|
|
1069
|
-
_addOutput: function (line) {
|
|
1070
|
-
if (this.truncate) {
|
|
1071
|
-
// Only replace single leading linebreak in the line after
|
|
1072
|
-
// -%> tag -- this is the single, trailing linebreak
|
|
1073
|
-
// after the tag that the truncation mode replaces
|
|
1074
|
-
// Handle Win / Unix / old Mac linebreaks -- do the \r\n
|
|
1075
|
-
// combo first in the regex-or
|
|
1076
|
-
line = line.replace(/^(?:\r\n|\r|\n)/, '');
|
|
1077
|
-
this.truncate = false;
|
|
1078
|
-
}
|
|
1079
|
-
if (!line) {
|
|
1080
|
-
return line;
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
// Preserve literal slashes
|
|
1084
|
-
line = line.replace(/\\/g, '\\\\');
|
|
1085
|
-
|
|
1086
|
-
// Convert linebreaks
|
|
1087
|
-
line = line.replace(/\n/g, '\\n');
|
|
1088
|
-
line = line.replace(/\r/g, '\\r');
|
|
1089
|
-
|
|
1090
|
-
// Escape double-quotes
|
|
1091
|
-
// - this will be the delimiter during execution
|
|
1092
|
-
line = line.replace(/"/g, '\\"');
|
|
1093
|
-
this.source += ' ; __append("' + line + '")' + '\n';
|
|
1094
|
-
},
|
|
1095
|
-
|
|
1096
|
-
scanLine: function (line) {
|
|
1097
|
-
var self = this;
|
|
1098
|
-
var d = this.opts.delimiter;
|
|
1099
|
-
var o = this.opts.openDelimiter;
|
|
1100
|
-
var c = this.opts.closeDelimiter;
|
|
1101
|
-
var newLineCount = 0;
|
|
1102
|
-
|
|
1103
|
-
newLineCount = (line.split('\n').length - 1);
|
|
1104
|
-
|
|
1105
|
-
switch (line) {
|
|
1106
|
-
case o + d:
|
|
1107
|
-
case o + d + '_':
|
|
1108
|
-
this.mode = Template.modes.EVAL;
|
|
1109
|
-
break;
|
|
1110
|
-
case o + d + '=':
|
|
1111
|
-
this.mode = Template.modes.ESCAPED;
|
|
1112
|
-
break;
|
|
1113
|
-
case o + d + '-':
|
|
1114
|
-
this.mode = Template.modes.RAW;
|
|
1115
|
-
break;
|
|
1116
|
-
case o + d + '#':
|
|
1117
|
-
this.mode = Template.modes.COMMENT;
|
|
1118
|
-
break;
|
|
1119
|
-
case o + d + d:
|
|
1120
|
-
this.mode = Template.modes.LITERAL;
|
|
1121
|
-
this.source += ' ; __append("' + line.replace(o + d + d, o + d) + '")' + '\n';
|
|
1122
|
-
break;
|
|
1123
|
-
case d + d + c:
|
|
1124
|
-
this.mode = Template.modes.LITERAL;
|
|
1125
|
-
this.source += ' ; __append("' + line.replace(d + d + c, d + c) + '")' + '\n';
|
|
1126
|
-
break;
|
|
1127
|
-
case d + c:
|
|
1128
|
-
case '-' + d + c:
|
|
1129
|
-
case '_' + d + c:
|
|
1130
|
-
if (this.mode == Template.modes.LITERAL) {
|
|
1131
|
-
this._addOutput(line);
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
this.mode = null;
|
|
1135
|
-
this.truncate = line.indexOf('-') === 0 || line.indexOf('_') === 0;
|
|
1136
|
-
break;
|
|
1137
|
-
default:
|
|
1138
|
-
// In script mode, depends on type of tag
|
|
1139
|
-
if (this.mode) {
|
|
1140
|
-
// If '//' is found without a line break, add a line break.
|
|
1141
|
-
switch (this.mode) {
|
|
1142
|
-
case Template.modes.EVAL:
|
|
1143
|
-
case Template.modes.ESCAPED:
|
|
1144
|
-
case Template.modes.RAW:
|
|
1145
|
-
if (line.lastIndexOf('//') > line.lastIndexOf('\n')) {
|
|
1146
|
-
line += '\n';
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
switch (this.mode) {
|
|
1150
|
-
// Just executing code
|
|
1151
|
-
case Template.modes.EVAL:
|
|
1152
|
-
this.source += ' ; ' + line + '\n';
|
|
1153
|
-
break;
|
|
1154
|
-
// Exec, esc, and output
|
|
1155
|
-
case Template.modes.ESCAPED:
|
|
1156
|
-
this.source += ' ; __append(escapeFn(' + stripSemi(line) + '))' + '\n';
|
|
1157
|
-
break;
|
|
1158
|
-
// Exec and output
|
|
1159
|
-
case Template.modes.RAW:
|
|
1160
|
-
this.source += ' ; __append(' + stripSemi(line) + ')' + '\n';
|
|
1161
|
-
break;
|
|
1162
|
-
case Template.modes.COMMENT:
|
|
1163
|
-
// Do nothing
|
|
1164
|
-
break;
|
|
1165
|
-
// Literal <%% mode, append as raw output
|
|
1166
|
-
case Template.modes.LITERAL:
|
|
1167
|
-
this._addOutput(line);
|
|
1168
|
-
break;
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
// In string mode, just add the output
|
|
1172
|
-
else {
|
|
1173
|
-
this._addOutput(line);
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
if (self.opts.compileDebug && newLineCount) {
|
|
1178
|
-
this.currentLine += newLineCount;
|
|
1179
|
-
this.source += ' ; __line = ' + this.currentLine + '\n';
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
};
|
|
1183
|
-
|
|
1184
|
-
/**
|
|
1185
|
-
* Escape characters reserved in XML.
|
|
1186
|
-
*
|
|
1187
|
-
* This is simply an export of {@link module:utils.escapeXML}.
|
|
1188
|
-
*
|
|
1189
|
-
* If `markup` is `undefined` or `null`, the empty string is returned.
|
|
1190
|
-
*
|
|
1191
|
-
* @param {String} markup Input string
|
|
1192
|
-
* @return {String} Escaped string
|
|
1193
|
-
* @public
|
|
1194
|
-
* @func
|
|
1195
|
-
* */
|
|
1196
|
-
exports$1.escapeXML = utils.escapeXML;
|
|
1197
|
-
|
|
1198
|
-
/**
|
|
1199
|
-
* Express.js support.
|
|
1200
|
-
*
|
|
1201
|
-
* This is an alias for {@link module:ejs.renderFile}, in order to support
|
|
1202
|
-
* Express.js out-of-the-box.
|
|
1203
|
-
*
|
|
1204
|
-
* @func
|
|
1205
|
-
*/
|
|
1206
|
-
|
|
1207
|
-
exports$1.__express = exports$1.renderFile;
|
|
1208
|
-
|
|
1209
|
-
/**
|
|
1210
|
-
* Version of EJS.
|
|
1211
|
-
*
|
|
1212
|
-
* @readonly
|
|
1213
|
-
* @type {String}
|
|
1214
|
-
* @public
|
|
1215
|
-
*/
|
|
1216
|
-
|
|
1217
|
-
exports$1.VERSION = _VERSION_STRING;
|
|
1218
|
-
|
|
1219
|
-
/**
|
|
1220
|
-
* Name for detection of EJS.
|
|
1221
|
-
*
|
|
1222
|
-
* @readonly
|
|
1223
|
-
* @type {String}
|
|
1224
|
-
* @public
|
|
1225
|
-
*/
|
|
1226
|
-
|
|
1227
|
-
exports$1.name = _NAME;
|
|
1228
|
-
|
|
1229
|
-
/* istanbul ignore if */
|
|
1230
|
-
if (typeof window != 'undefined') {
|
|
1231
|
-
window.ejs = exports$1;
|
|
1232
|
-
}
|
|
1233
|
-
} (ejs$1));
|
|
1234
|
-
return ejs$1;
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
var ejsExports = requireEjs();
|
|
1238
|
-
var ejs = /*@__PURE__*/getDefaultExportFromCjs(ejsExports);
|
|
1239
|
-
|
|
1240
|
-
var src;
|
|
1241
|
-
var hasRequiredSrc;
|
|
1242
|
-
|
|
1243
|
-
function requireSrc () {
|
|
1244
|
-
if (hasRequiredSrc) return src;
|
|
1245
|
-
hasRequiredSrc = 1;
|
|
1246
|
-
|
|
1247
|
-
const ESC = '\x1B';
|
|
1248
|
-
const CSI = `${ESC}[`;
|
|
1249
|
-
const beep = '\u0007';
|
|
1250
|
-
|
|
1251
|
-
const cursor = {
|
|
1252
|
-
to(x, y) {
|
|
1253
|
-
if (!y) return `${CSI}${x + 1}G`;
|
|
1254
|
-
return `${CSI}${y + 1};${x + 1}H`;
|
|
1255
|
-
},
|
|
1256
|
-
move(x, y) {
|
|
1257
|
-
let ret = '';
|
|
1258
|
-
|
|
1259
|
-
if (x < 0) ret += `${CSI}${-x}D`;
|
|
1260
|
-
else if (x > 0) ret += `${CSI}${x}C`;
|
|
1261
|
-
|
|
1262
|
-
if (y < 0) ret += `${CSI}${-y}A`;
|
|
1263
|
-
else if (y > 0) ret += `${CSI}${y}B`;
|
|
1264
|
-
|
|
1265
|
-
return ret;
|
|
1266
|
-
},
|
|
1267
|
-
up: (count = 1) => `${CSI}${count}A`,
|
|
1268
|
-
down: (count = 1) => `${CSI}${count}B`,
|
|
1269
|
-
forward: (count = 1) => `${CSI}${count}C`,
|
|
1270
|
-
backward: (count = 1) => `${CSI}${count}D`,
|
|
1271
|
-
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
1272
|
-
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
1273
|
-
left: `${CSI}G`,
|
|
1274
|
-
hide: `${CSI}?25l`,
|
|
1275
|
-
show: `${CSI}?25h`,
|
|
1276
|
-
save: `${ESC}7`,
|
|
1277
|
-
restore: `${ESC}8`
|
|
1278
|
-
};
|
|
1279
|
-
|
|
1280
|
-
const scroll = {
|
|
1281
|
-
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
1282
|
-
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
1283
|
-
};
|
|
1284
|
-
|
|
1285
|
-
const erase = {
|
|
1286
|
-
screen: `${CSI}2J`,
|
|
1287
|
-
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
1288
|
-
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
1289
|
-
line: `${CSI}2K`,
|
|
1290
|
-
lineEnd: `${CSI}K`,
|
|
1291
|
-
lineStart: `${CSI}1K`,
|
|
1292
|
-
lines(count) {
|
|
1293
|
-
let clear = '';
|
|
1294
|
-
for (let i = 0; i < count; i++)
|
|
1295
|
-
clear += this.line + (i < count - 1 ? cursor.up() : '');
|
|
1296
|
-
if (count)
|
|
1297
|
-
clear += cursor.left;
|
|
1298
|
-
return clear;
|
|
1299
|
-
}
|
|
1300
|
-
};
|
|
1301
|
-
|
|
1302
|
-
src = { cursor, scroll, erase, beep };
|
|
1303
|
-
return src;
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
var srcExports = requireSrc();
|
|
1307
|
-
|
|
1308
|
-
var picocolors = {exports: {}};
|
|
1309
|
-
|
|
1310
|
-
var hasRequiredPicocolors;
|
|
1311
|
-
|
|
1312
|
-
function requirePicocolors () {
|
|
1313
|
-
if (hasRequiredPicocolors) return picocolors.exports;
|
|
1314
|
-
hasRequiredPicocolors = 1;
|
|
1315
|
-
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
1316
|
-
let isColorSupported =
|
|
1317
|
-
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
|
|
1318
|
-
(!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
|
|
1319
|
-
|
|
1320
|
-
let formatter = (open, close, replace = open) =>
|
|
1321
|
-
input => {
|
|
1322
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
1323
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
|
|
1324
|
-
};
|
|
1325
|
-
|
|
1326
|
-
let replaceClose = (string, close, replace, index) => {
|
|
1327
|
-
let result = "", cursor = 0;
|
|
1328
|
-
do {
|
|
1329
|
-
result += string.substring(cursor, index) + replace;
|
|
1330
|
-
cursor = index + close.length;
|
|
1331
|
-
index = string.indexOf(close, cursor);
|
|
1332
|
-
} while (~index)
|
|
1333
|
-
return result + string.substring(cursor)
|
|
1334
|
-
};
|
|
1335
|
-
|
|
1336
|
-
let createColors = (enabled = isColorSupported) => {
|
|
1337
|
-
let f = enabled ? formatter : () => String;
|
|
1338
|
-
return {
|
|
1339
|
-
isColorSupported: enabled,
|
|
1340
|
-
reset: f("\x1b[0m", "\x1b[0m"),
|
|
1341
|
-
bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
|
|
1342
|
-
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
|
1343
|
-
italic: f("\x1b[3m", "\x1b[23m"),
|
|
1344
|
-
underline: f("\x1b[4m", "\x1b[24m"),
|
|
1345
|
-
inverse: f("\x1b[7m", "\x1b[27m"),
|
|
1346
|
-
hidden: f("\x1b[8m", "\x1b[28m"),
|
|
1347
|
-
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
|
1348
|
-
|
|
1349
|
-
black: f("\x1b[30m", "\x1b[39m"),
|
|
1350
|
-
red: f("\x1b[31m", "\x1b[39m"),
|
|
1351
|
-
green: f("\x1b[32m", "\x1b[39m"),
|
|
1352
|
-
yellow: f("\x1b[33m", "\x1b[39m"),
|
|
1353
|
-
blue: f("\x1b[34m", "\x1b[39m"),
|
|
1354
|
-
magenta: f("\x1b[35m", "\x1b[39m"),
|
|
1355
|
-
cyan: f("\x1b[36m", "\x1b[39m"),
|
|
1356
|
-
white: f("\x1b[37m", "\x1b[39m"),
|
|
1357
|
-
gray: f("\x1b[90m", "\x1b[39m"),
|
|
1358
|
-
|
|
1359
|
-
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
|
1360
|
-
bgRed: f("\x1b[41m", "\x1b[49m"),
|
|
1361
|
-
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
|
1362
|
-
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
|
1363
|
-
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
|
1364
|
-
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
|
1365
|
-
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
|
1366
|
-
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
|
1367
|
-
|
|
1368
|
-
blackBright: f("\x1b[90m", "\x1b[39m"),
|
|
1369
|
-
redBright: f("\x1b[91m", "\x1b[39m"),
|
|
1370
|
-
greenBright: f("\x1b[92m", "\x1b[39m"),
|
|
1371
|
-
yellowBright: f("\x1b[93m", "\x1b[39m"),
|
|
1372
|
-
blueBright: f("\x1b[94m", "\x1b[39m"),
|
|
1373
|
-
magentaBright: f("\x1b[95m", "\x1b[39m"),
|
|
1374
|
-
cyanBright: f("\x1b[96m", "\x1b[39m"),
|
|
1375
|
-
whiteBright: f("\x1b[97m", "\x1b[39m"),
|
|
1376
|
-
|
|
1377
|
-
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
|
1378
|
-
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
|
1379
|
-
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
|
1380
|
-
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
|
1381
|
-
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
|
1382
|
-
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
|
1383
|
-
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
|
1384
|
-
bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
|
|
1385
|
-
}
|
|
1386
|
-
};
|
|
1387
|
-
|
|
1388
|
-
picocolors.exports = createColors();
|
|
1389
|
-
picocolors.exports.createColors = createColors;
|
|
1390
|
-
return picocolors.exports;
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
var picocolorsExports = /*@__PURE__*/ requirePicocolors();
|
|
1394
|
-
var e = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
|
|
1395
|
-
|
|
1396
|
-
function DD({onlyFirst:e=false}={}){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("|");return new RegExp(t,e?void 0:"g")}const uD=DD();function P$1(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(uD,"")}function L$1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var W$1={exports:{}};(function(e){var u={};e.exports=u,u.eastAsianWidth=function(F){var s=F.charCodeAt(0),i=F.length==2?F.charCodeAt(1):0,D=s;return 55296<=s&&s<=56319&&56320<=i&&i<=57343&&(s&=1023,i&=1023,D=s<<10|i,D+=65536),D==12288||65281<=D&&D<=65376||65504<=D&&D<=65510?"F":D==8361||65377<=D&&D<=65470||65474<=D&&D<=65479||65482<=D&&D<=65487||65490<=D&&D<=65495||65498<=D&&D<=65500||65512<=D&&D<=65518?"H":4352<=D&&D<=4447||4515<=D&&D<=4519||4602<=D&&D<=4607||9001<=D&&D<=9002||11904<=D&&D<=11929||11931<=D&&D<=12019||12032<=D&&D<=12245||12272<=D&&D<=12283||12289<=D&&D<=12350||12353<=D&&D<=12438||12441<=D&&D<=12543||12549<=D&&D<=12589||12593<=D&&D<=12686||12688<=D&&D<=12730||12736<=D&&D<=12771||12784<=D&&D<=12830||12832<=D&&D<=12871||12880<=D&&D<=13054||13056<=D&&D<=19903||19968<=D&&D<=42124||42128<=D&&D<=42182||43360<=D&&D<=43388||44032<=D&&D<=55203||55216<=D&&D<=55238||55243<=D&&D<=55291||63744<=D&&D<=64255||65040<=D&&D<=65049||65072<=D&&D<=65106||65108<=D&&D<=65126||65128<=D&&D<=65131||110592<=D&&D<=110593||127488<=D&&D<=127490||127504<=D&&D<=127546||127552<=D&&D<=127560||127568<=D&&D<=127569||131072<=D&&D<=194367||177984<=D&&D<=196605||196608<=D&&D<=262141?"W":32<=D&&D<=126||162<=D&&D<=163||165<=D&&D<=166||D==172||D==175||10214<=D&&D<=10221||10629<=D&&D<=10630?"Na":D==161||D==164||167<=D&&D<=168||D==170||173<=D&&D<=174||176<=D&&D<=180||182<=D&&D<=186||188<=D&&D<=191||D==198||D==208||215<=D&&D<=216||222<=D&&D<=225||D==230||232<=D&&D<=234||236<=D&&D<=237||D==240||242<=D&&D<=243||247<=D&&D<=250||D==252||D==254||D==257||D==273||D==275||D==283||294<=D&&D<=295||D==299||305<=D&&D<=307||D==312||319<=D&&D<=322||D==324||328<=D&&D<=331||D==333||338<=D&&D<=339||358<=D&&D<=359||D==363||D==462||D==464||D==466||D==468||D==470||D==472||D==474||D==476||D==593||D==609||D==708||D==711||713<=D&&D<=715||D==717||D==720||728<=D&&D<=731||D==733||D==735||768<=D&&D<=879||913<=D&&D<=929||931<=D&&D<=937||945<=D&&D<=961||963<=D&&D<=969||D==1025||1040<=D&&D<=1103||D==1105||D==8208||8211<=D&&D<=8214||8216<=D&&D<=8217||8220<=D&&D<=8221||8224<=D&&D<=8226||8228<=D&&D<=8231||D==8240||8242<=D&&D<=8243||D==8245||D==8251||D==8254||D==8308||D==8319||8321<=D&&D<=8324||D==8364||D==8451||D==8453||D==8457||D==8467||D==8470||8481<=D&&D<=8482||D==8486||D==8491||8531<=D&&D<=8532||8539<=D&&D<=8542||8544<=D&&D<=8555||8560<=D&&D<=8569||D==8585||8592<=D&&D<=8601||8632<=D&&D<=8633||D==8658||D==8660||D==8679||D==8704||8706<=D&&D<=8707||8711<=D&&D<=8712||D==8715||D==8719||D==8721||D==8725||D==8730||8733<=D&&D<=8736||D==8739||D==8741||8743<=D&&D<=8748||D==8750||8756<=D&&D<=8759||8764<=D&&D<=8765||D==8776||D==8780||D==8786||8800<=D&&D<=8801||8804<=D&&D<=8807||8810<=D&&D<=8811||8814<=D&&D<=8815||8834<=D&&D<=8835||8838<=D&&D<=8839||D==8853||D==8857||D==8869||D==8895||D==8978||9312<=D&&D<=9449||9451<=D&&D<=9547||9552<=D&&D<=9587||9600<=D&&D<=9615||9618<=D&&D<=9621||9632<=D&&D<=9633||9635<=D&&D<=9641||9650<=D&&D<=9651||9654<=D&&D<=9655||9660<=D&&D<=9661||9664<=D&&D<=9665||9670<=D&&D<=9672||D==9675||9678<=D&&D<=9681||9698<=D&&D<=9701||D==9711||9733<=D&&D<=9734||D==9737||9742<=D&&D<=9743||9748<=D&&D<=9749||D==9756||D==9758||D==9792||D==9794||9824<=D&&D<=9825||9827<=D&&D<=9829||9831<=D&&D<=9834||9836<=D&&D<=9837||D==9839||9886<=D&&D<=9887||9918<=D&&D<=9919||9924<=D&&D<=9933||9935<=D&&D<=9953||D==9955||9960<=D&&D<=9983||D==10045||D==10071||10102<=D&&D<=10111||11093<=D&&D<=11097||12872<=D&&D<=12879||57344<=D&&D<=63743||65024<=D&&D<=65039||D==65533||127232<=D&&D<=127242||127248<=D&&D<=127277||127280<=D&&D<=127337||127344<=D&&D<=127386||917760<=D&&D<=917999||983040<=D&&D<=1048573||1048576<=D&&D<=1114109?"A":"N"},u.characterLength=function(F){var s=this.eastAsianWidth(F);return s=="F"||s=="W"||s=="A"?2:1};function t(F){return F.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}u.length=function(F){for(var s=t(F),i=0,D=0;D<s.length;D++)i=i+this.characterLength(s[D]);return i},u.slice=function(F,s,i){textLen=u.length(F),s=s||0,i=i||1,s<0&&(s=textLen+s),i<0&&(i=textLen+i);for(var D="",C=0,n=t(F),E=0;E<n.length;E++){var a=n[E],o=u.length(a);if(C>=s-(o==2?1:0))if(C+o<=i)D+=a;else break;C+=o;}return D};})(W$1);var tD=W$1.exports;const eD=L$1(tD);var FD=function(){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};const sD=L$1(FD);function p(e,u={}){if(typeof e!="string"||e.length===0||(u={ambiguousIsNarrow:true,...u},e=P$1(e),e.length===0))return 0;e=e.replace(sD()," ");const t=u.ambiguousIsNarrow?1:2;let F=0;for(const s of e){const i=s.codePointAt(0);if(i<=31||i>=127&&i<=159||i>=768&&i<=879)continue;switch(eD.eastAsianWidth(s)){case "F":case "W":F+=2;break;case "A":F+=t;break;default:F+=1;}}return F}const w=10,N=(e=0)=>u=>`\x1B[${u+e}m`,I=(e=0)=>u=>`\x1B[${38+e};5;${u}m`,R=(e=0)=>(u,t,F)=>`\x1B[${38+e};2;${u};${t};${F}m`,r={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(r.modifier);const iD=Object.keys(r.color),CD=Object.keys(r.bgColor);[...iD,...CD];function rD(){const e=new Map;for(const[u,t]of Object.entries(r)){for(const[F,s]of Object.entries(t))r[F]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},t[F]=r[F],e.set(s[0],s[1]);Object.defineProperty(r,u,{value:t,enumerable:false});}return Object.defineProperty(r,"codes",{value:e,enumerable:false}),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,{rgbToAnsi256:{value:(u,t,F)=>u===t&&t===F?u<8?16:u>248?231:Math.round((u-8)/247*24)+232:16+36*Math.round(u/255*5)+6*Math.round(t/255*5)+Math.round(F/255*5),enumerable:false},hexToRgb:{value:u=>{const t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!t)return [0,0,0];let[F]=t;F.length===3&&(F=[...F].map(i=>i+i).join(""));const s=Number.parseInt(F,16);return [s>>16&255,s>>8&255,s&255]},enumerable:false},hexToAnsi256:{value:u=>r.rgbToAnsi256(...r.hexToRgb(u)),enumerable:false},ansi256ToAnsi:{value:u=>{if(u<8)return 30+u;if(u<16)return 90+(u-8);let t,F,s;if(u>=232)t=((u-232)*10+8)/255,F=t,s=t;else {u-=16;const C=u%36;t=Math.floor(u/36)/5,F=Math.floor(C/6)/5,s=C%6/5;}const i=Math.max(t,F,s)*2;if(i===0)return 30;let D=30+(Math.round(s)<<2|Math.round(F)<<1|Math.round(t));return i===2&&(D+=60),D},enumerable:false},rgbToAnsi:{value:(u,t,F)=>r.ansi256ToAnsi(r.rgbToAnsi256(u,t,F)),enumerable:false},hexToAnsi:{value:u=>r.ansi256ToAnsi(r.hexToAnsi256(u)),enumerable:false}}),r}const ED=rD(),d$1=new Set(["\x1B","\x9B"]),oD=39,y="\x07",V$1="[",nD="]",G$1="m",_=`${nD}8;;`,z=e=>`${d$1.values().next().value}${V$1}${e}${G$1}`,K=e=>`${d$1.values().next().value}${_}${e}${y}`,aD=e=>e.split(" ").map(u=>p(u)),k$1=(e,u,t)=>{const F=[...u];let s=false,i=false,D=p(P$1(e[e.length-1]));for(const[C,n]of F.entries()){const E=p(n);if(D+E<=t?e[e.length-1]+=n:(e.push(n),D=0),d$1.has(n)&&(s=true,i=F.slice(C+1).join("").startsWith(_)),s){i?n===y&&(s=false,i=false):n===G$1&&(s=false);continue}D+=E,D===t&&C<F.length-1&&(e.push(""),D=0);}!D&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop());},hD=e=>{const u=e.split(" ");let t=u.length;for(;t>0&&!(p(u[t-1])>0);)t--;return t===u.length?e:u.slice(0,t).join(" ")+u.slice(t).join("")},lD=(e,u,t={})=>{if(t.trim!==false&&e.trim()==="")return "";let F="",s,i;const D=aD(e);let C=[""];for(const[E,a]of e.split(" ").entries()){t.trim!==false&&(C[C.length-1]=C[C.length-1].trimStart());let o=p(C[C.length-1]);if(E!==0&&(o>=u&&(t.wordWrap===false||t.trim===false)&&(C.push(""),o=0),(o>0||t.trim===false)&&(C[C.length-1]+=" ",o++)),t.hard&&D[E]>u){const c=u-o,f=1+Math.floor((D[E]-c-1)/u);Math.floor((D[E]-1)/u)<f&&C.push(""),k$1(C,a,u);continue}if(o+D[E]>u&&o>0&&D[E]>0){if(t.wordWrap===false&&o<u){k$1(C,a,u);continue}C.push("");}if(o+D[E]>u&&t.wordWrap===false){k$1(C,a,u);continue}C[C.length-1]+=a;}t.trim!==false&&(C=C.map(E=>hD(E)));const n=[...C.join(`
|
|
1397
|
-
`)];for(const[E,a]of n.entries()){if(F+=a,d$1.has(a)){const{groups:c}=new RegExp(`(?:\\${V$1}(?<code>\\d+)m|\\${_}(?<uri>.*)${y})`).exec(n.slice(E).join(""))||{groups:{}};if(c.code!==void 0){const f=Number.parseFloat(c.code);s=f===oD?void 0:f;}else c.uri!==void 0&&(i=c.uri.length===0?void 0:c.uri);}const o=ED.codes.get(Number(s));n[E+1]===`
|
|
1398
|
-
`?(i&&(F+=K("")),s&&o&&(F+=z(o))):a===`
|
|
1399
|
-
`&&(s&&o&&(F+=z(s)),i&&(F+=K(i)));}return F};function Y(e,u,t){return String(e).normalize().replace(/\r\n/g,`
|
|
1400
|
-
`).split(`
|
|
1401
|
-
`).map(F=>lD(F,u,t)).join(`
|
|
1402
|
-
`)}const xD=["up","down","left","right","space","enter","cancel"],B={actions:new Set(xD),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]])};function $(e,u){if(typeof e=="string")return B.aliases.get(e)===u;for(const t of e)if(t!==void 0&&$(t,u))return true;return false}function BD(e,u){if(e===u)return;const t=e.split(`
|
|
1403
|
-
`),F=u.split(`
|
|
1404
|
-
`),s=[];for(let i=0;i<Math.max(t.length,F.length);i++)t[i]!==F[i]&&s.push(i);return s}globalThis.process.platform.startsWith("win");const S=Symbol("clack:cancel");function pD(e){return e===S}function m(e,u){const t=e;t.isTTY&&t.setRawMode(u);}var gD=Object.defineProperty,vD=(e,u,t)=>u in e?gD(e,u,{enumerable:true,configurable:true,writable:true,value:t}):e[u]=t,h=(e,u,t)=>(vD(e,typeof u!="symbol"?u+"":u,t),t);class x{constructor(u,t=true){h(this,"input"),h(this,"output"),h(this,"_abortSignal"),h(this,"rl"),h(this,"opts"),h(this,"_render"),h(this,"_track",false),h(this,"_prevFrame",""),h(this,"_subscribers",new Map),h(this,"_cursor",0),h(this,"state","initial"),h(this,"error",""),h(this,"value");const{input:F=stdin,output:s=stdout,render:i,signal:D,...C}=u;this.opts=C,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,this.input=F,this.output=s;}unsubscribe(){this._subscribers.clear();}setSubscriber(u,t){const F=this._subscribers.get(u)??[];F.push(t),this._subscribers.set(u,F);}on(u,t){this.setSubscriber(u,{cb:t});}once(u,t){this.setSubscriber(u,{cb:t,once:true});}emit(u,...t){const F=this._subscribers.get(u)??[],s=[];for(const i of F)i.cb(...t),i.once&&s.push(()=>F.splice(F.indexOf(i),1));for(const i of s)i();}prompt(){return new Promise((u,t)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),u(S);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close();},{once:true});}const F=new Writable;F._write=(s,i,D)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),D();},this.input.pipe(F),this.rl=g.createInterface({input:this.input,output:F,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:true}),g.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,true),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(srcExports.cursor.show),this.output.off("resize",this.render),m(this.input,false),u(this.value);}),this.once("cancel",()=>{this.output.write(srcExports.cursor.show),this.output.off("resize",this.render),m(this.input,false),u(S);});})}onKeypress(u,t){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&&(u.toLowerCase()==="y"||u.toLowerCase()==="n")&&this.emit("confirm",u.toLowerCase()==="y"),u===" "&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),u&&this.emit("key",u.toLowerCase()),t?.name==="return"){if(this.opts.validate){const F=this.opts.validate(this.value);F&&(this.error=F instanceof Error?F.message:F,this.state="error",this.rl?.write(this.value));}this.state!=="error"&&(this.state="submit");}$([u,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close();}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
1405
|
-
`),m(this.input,false),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe();}restoreCursor(){const u=Y(this._prevFrame,process.stdout.columns,{hard:true}).split(`
|
|
1406
|
-
`).length-1;this.output.write(srcExports.cursor.move(-999,u*-1));}render(){const u=Y(this._render(this)??"",process.stdout.columns,{hard:true});if(u!==this._prevFrame){if(this.state==="initial")this.output.write(srcExports.cursor.hide);else {const t=BD(this._prevFrame,u);if(this.restoreCursor(),t&&t?.length===1){const F=t[0];this.output.write(srcExports.cursor.move(0,F)),this.output.write(srcExports.erase.lines(1));const s=u.split(`
|
|
1407
|
-
`);this.output.write(s[F]),this._prevFrame=u,this.output.write(srcExports.cursor.move(0,s.length-F-1));return}if(t&&t?.length>1){const F=t[0];this.output.write(srcExports.cursor.move(0,F)),this.output.write(srcExports.erase.down());const s=u.split(`
|
|
1408
|
-
`).slice(F);this.output.write(s.join(`
|
|
1409
|
-
`)),this._prevFrame=u;return}this.output.write(srcExports.erase.down());}this.output.write(u),this.state==="initial"&&(this.state="active"),this._prevFrame=u;}}}class dD extends x{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(u){super(u,false),this.value=!!u.initialValue,this.on("value",()=>{this.value=this._value;}),this.on("confirm",t=>{this.output.write(srcExports.cursor.move(0,-1)),this.value=t,this.state="submit",this.close();}),this.on("cursor",()=>{this.value=!this.value;});}}var kD=Object.defineProperty,$D=(e,u,t)=>u in e?kD(e,u,{enumerable:true,configurable:true,writable:true,value:t}):e[u]=t,H=(e,u,t)=>($D(e,typeof u!="symbol"?u+"":u,t),t);let SD=class extends x{constructor(u){super(u,false),H(this,"options"),H(this,"cursor",0),this.options=u.options,this.value=[...u.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===u.cursorAt),0),this.on("key",t=>{t==="a"&&this.toggleAll();}),this.on("cursor",t=>{switch(t){case "left":case "up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case "down":case "right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case "space":this.toggleValue();break}});}get _value(){return this.options[this.cursor].value}toggleAll(){const u=this.value.length===this.options.length;this.value=u?[]:this.options.map(t=>t.value);}toggleValue(){const u=this.value.includes(this._value);this.value=u?this.value.filter(t=>t!==this._value):[...this.value,this._value];}};class RD extends x{get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return `${this.value}\u2588`;const u=this.value.slice(0,this.cursor),[t,...F]=this.value.slice(this.cursor);return `${u}${e.inverse(t)}${F.join("")}`}get cursor(){return this._cursor}constructor(u){super(u),this.on("finalize",()=>{this.value||(this.value=u.defaultValue);});}}
|
|
1410
|
-
|
|
1411
|
-
function ce(){return y$1.platform!=="win32"?y$1.env.TERM!=="linux":!!y$1.env.CI||!!y$1.env.WT_SESSION||!!y$1.env.TERMINUS_SUBLIME||y$1.env.ConEmuTask==="{cmd::Cmder}"||y$1.env.TERM_PROGRAM==="Terminus-Sublime"||y$1.env.TERM_PROGRAM==="vscode"||y$1.env.TERM==="xterm-256color"||y$1.env.TERM==="alacritty"||y$1.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const V=ce(),u=(t,n)=>V?t:n,le=u("\u25C6","*"),L=u("\u25A0","x"),W=u("\u25B2","x"),C=u("\u25C7","o"),ue=u("\u250C","T"),o=u("\u2502","|"),d=u("\u2514","\u2014"),k=u("\u25CF",">"),P=u("\u25CB"," "),A=u("\u25FB","[\u2022]"),T=u("\u25FC","[+]"),F=u("\u25FB","[ ]"),b=t=>{switch(t){case "initial":case "active":return e.cyan(le);case "cancel":return e.red(L);case "error":return e.yellow(W);case "submit":return e.green(C)}},G=t=>{const{cursor:n,options:r,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));let l=0;n>=l+a-3?l=Math.max(Math.min(n-a+3,r.length-a),0):n<l+2&&(l=Math.max(n-2,0));const $=a<r.length&&l>0,g=a<r.length&&l+a<r.length;return r.slice(l,l+a).map((p,v,f)=>{const j=v===0&&$,E=v===f.length-1&&g;return j||E?e.dim("..."):i(p,v+l===n)})},he=t=>new RD({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){const n=`${e.gray(o)}
|
|
1412
|
-
${b(this.state)} ${t.message}
|
|
1413
|
-
`,r=t.placeholder?e.inverse(t.placeholder[0])+e.dim(t.placeholder.slice(1)):e.inverse(e.hidden("_")),i=this.value?this.valueWithCursor:r;switch(this.state){case "error":return `${n.trim()}
|
|
1414
|
-
${e.yellow(o)} ${i}
|
|
1415
|
-
${e.yellow(d)} ${e.yellow(this.error)}
|
|
1416
|
-
`;case "submit":return `${n}${e.gray(o)} ${e.dim(this.value||t.placeholder)}`;case "cancel":return `${n}${e.gray(o)} ${e.strikethrough(e.dim(this.value??""))}${this.value?.trim()?`
|
|
1417
|
-
${e.gray(o)}`:""}`;default:return `${n}${e.cyan(o)} ${i}
|
|
1418
|
-
${e.cyan(d)}
|
|
1419
|
-
`}}}).prompt(),ye=t=>{const n=t.active??"Yes",r=t.inactive??"No";return new dD({active:n,inactive:r,initialValue:t.initialValue??true,render(){const i=`${e.gray(o)}
|
|
1420
|
-
${b(this.state)} ${t.message}
|
|
1421
|
-
`,s=this.value?n:r;switch(this.state){case "submit":return `${i}${e.gray(o)} ${e.dim(s)}`;case "cancel":return `${i}${e.gray(o)} ${e.strikethrough(e.dim(s))}
|
|
1422
|
-
${e.gray(o)}`;default:return `${i}${e.cyan(o)} ${this.value?`${e.green(k)} ${n}`:`${e.dim(P)} ${e.dim(n)}`} ${e.dim("/")} ${this.value?`${e.dim(P)} ${e.dim(r)}`:`${e.green(k)} ${r}`}
|
|
1423
|
-
${e.cyan(d)}
|
|
1424
|
-
`}}}).prompt()},fe=t=>{const n=(r,i)=>{const s=r.label??String(r.value);return i==="active"?`${e.cyan(A)} ${s} ${r.hint?e.dim(`(${r.hint})`):""}`:i==="selected"?`${e.green(T)} ${e.dim(s)} ${r.hint?e.dim(`(${r.hint})`):""}`:i==="cancelled"?`${e.strikethrough(e.dim(s))}`:i==="active-selected"?`${e.green(T)} ${s} ${r.hint?e.dim(`(${r.hint})`):""}`:i==="submitted"?`${e.dim(s)}`:`${e.dim(F)} ${e.dim(s)}`};return new SD({options:t.options,initialValues:t.initialValues,required:t.required??true,cursorAt:t.cursorAt,validate(r){if(this.required&&r.length===0)return `Please select at least one option.
|
|
1425
|
-
${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`},render(){const r=`${e.gray(o)}
|
|
1426
|
-
${b(this.state)} ${t.message}
|
|
1427
|
-
`,i=(s,c)=>{const a=this.value.includes(s.value);return c&&a?n(s,"active-selected"):a?n(s,"selected"):n(s,c?"active":"inactive")};switch(this.state){case "submit":return `${r}${e.gray(o)} ${this.options.filter(({value:s})=>this.value.includes(s)).map(s=>n(s,"submitted")).join(e.dim(", "))||e.dim("none")}`;case "cancel":{const s=this.options.filter(({value:c})=>this.value.includes(c)).map(c=>n(c,"cancelled")).join(e.dim(", "));return `${r}${e.gray(o)} ${s.trim()?`${s}
|
|
1428
|
-
${e.gray(o)}`:""}`}case "error":{const s=this.error.split(`
|
|
1429
|
-
`).map((c,a)=>a===0?`${e.yellow(d)} ${e.yellow(c)}`:` ${c}`).join(`
|
|
1430
|
-
`);return `${r+e.yellow(o)} ${G({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:i}).join(`
|
|
1431
|
-
${e.yellow(o)} `)}
|
|
1432
|
-
${s}
|
|
1433
|
-
`}default:return `${r}${e.cyan(o)} ${G({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:i}).join(`
|
|
1434
|
-
${e.cyan(o)} `)}
|
|
1435
|
-
${e.cyan(d)}
|
|
1436
|
-
`}}}).prompt()},xe=(t="")=>{process.stdout.write(`${e.gray(d)} ${e.red(t)}
|
|
1437
|
-
|
|
1438
|
-
`);},Ie=(t="")=>{process.stdout.write(`${e.gray(ue)} ${t}
|
|
1439
|
-
`);},Se=(t="")=>{process.stdout.write(`${e.gray(o)}
|
|
1440
|
-
${e.gray(d)} ${t}
|
|
1441
|
-
|
|
1442
|
-
`);};`${e.gray(o)} `;
|
|
1443
|
-
|
|
1444
|
-
function linkLocale(locale) {
|
|
1445
|
-
if (locale === 'C') {
|
|
1446
|
-
return 'en-US';
|
|
1447
|
-
}
|
|
1448
|
-
let linkedLocale;
|
|
1449
|
-
try {
|
|
1450
|
-
linkedLocale = Intl.getCanonicalLocales(locale)[0];
|
|
1451
|
-
}
|
|
1452
|
-
catch (error) {
|
|
1453
|
-
console.log(`${error.toString()}, invalid language tag: "${locale}"\n`);
|
|
1454
|
-
}
|
|
1455
|
-
switch (linkedLocale) {
|
|
1456
|
-
case 'zh-CN':
|
|
1457
|
-
case 'zh-SG':
|
|
1458
|
-
linkedLocale = 'zh-Hans';
|
|
1459
|
-
break;
|
|
1460
|
-
default:
|
|
1461
|
-
linkedLocale = locale;
|
|
1462
|
-
}
|
|
1463
|
-
return linkedLocale;
|
|
1464
|
-
}
|
|
1465
|
-
function getLocale() {
|
|
1466
|
-
const shellLocale = process.env.LC_ALL ||
|
|
1467
|
-
process.env.LC_MESSAGES ||
|
|
1468
|
-
process.env.LANG ||
|
|
1469
|
-
Intl.DateTimeFormat().resolvedOptions().locale ||
|
|
1470
|
-
'en-US';
|
|
1471
|
-
return linkLocale(shellLocale.split('.')[0].replace('_', '-'));
|
|
1472
|
-
}
|
|
1473
|
-
async function loadLanguageFile(filePath) {
|
|
1474
|
-
return await fs.promises.readFile(filePath, 'utf-8').then((data) => {
|
|
1475
|
-
const parsedData = JSON.parse(data);
|
|
1476
|
-
if (parsedData) {
|
|
1477
|
-
return parsedData;
|
|
1478
|
-
}
|
|
1479
|
-
});
|
|
1480
|
-
}
|
|
1481
|
-
async function getLanguage(localesRoot) {
|
|
1482
|
-
const locale = getLocale();
|
|
1483
|
-
const languageFilePath = path.resolve(localesRoot, `${locale}.json`);
|
|
1484
|
-
const fallbackPath = path.resolve(localesRoot, 'en-US.json');
|
|
1485
|
-
const doesLanguageExist = fs.existsSync(languageFilePath);
|
|
1486
|
-
const lang = doesLanguageExist
|
|
1487
|
-
? await loadLanguageFile(languageFilePath)
|
|
1488
|
-
: await loadLanguageFile(fallbackPath);
|
|
1489
|
-
return lang;
|
|
1490
|
-
}
|
|
1491
|
-
|
|
1492
|
-
// 这里的 await 会阻塞所有引用它的模块,直到加载完成
|
|
1493
|
-
const language = await getLanguage(fileURLToPath(new URL('./locales', import.meta.url)));
|
|
1494
|
-
|
|
1495
|
-
const helpMessage = `\
|
|
1496
|
-
Usage: create-vite-react-cli [FEATURE_FLAGS...] [OPTIONS...] [DIRECTORY]
|
|
1497
|
-
|
|
1498
|
-
Create a new Vite React project.
|
|
1499
|
-
Start the CLI in interactive mode when no FEATURE_FLAGS is provided, or if the DIRECTORY argument is not a valid package name.
|
|
1500
|
-
|
|
1501
|
-
Options:
|
|
1502
|
-
--force
|
|
1503
|
-
Create the project even if the directory is not empty.
|
|
1504
|
-
--help
|
|
1505
|
-
Display this help message.
|
|
1506
|
-
--version
|
|
1507
|
-
Display the version number of this CLI.
|
|
1508
|
-
|
|
1509
|
-
Available feature flags:
|
|
1510
|
-
--default
|
|
1511
|
-
Create a project with the default configuration without any additional features.
|
|
1512
|
-
--ts, --typescript
|
|
1513
|
-
Add TypeScript support.
|
|
1514
|
-
--eslint
|
|
1515
|
-
Add ESLint for code quality.
|
|
1516
|
-
--eslint-with-prettier (Deprecated in favor of ${picocolorsExports.cyan('--eslint --prettier')})
|
|
1517
|
-
Add Prettier for code formatting in addition to ESLint.
|
|
1518
|
-
--prettier
|
|
1519
|
-
Add Prettier for code formatting.
|
|
1520
|
-
`;
|
|
1521
|
-
|
|
1522
|
-
const FEATURE_FLAGS = [
|
|
1523
|
-
'default',
|
|
1524
|
-
'ts',
|
|
1525
|
-
'typescript',
|
|
1526
|
-
'eslint',
|
|
1527
|
-
'prettier',
|
|
1528
|
-
'eslint-with-prettier',
|
|
1529
|
-
];
|
|
1530
|
-
const FEATURE_OPTIONS = [
|
|
1531
|
-
{
|
|
1532
|
-
value: 'typescript',
|
|
1533
|
-
label: language.needsTypeScript.message,
|
|
1534
|
-
},
|
|
1535
|
-
{
|
|
1536
|
-
value: 'eslint',
|
|
1537
|
-
label: language.needsEslint.message,
|
|
1538
|
-
},
|
|
1539
|
-
{
|
|
1540
|
-
value: 'prettier',
|
|
1541
|
-
label: language.needsPrettier.message,
|
|
1542
|
-
},
|
|
1543
|
-
];
|
|
1544
|
-
|
|
1545
|
-
async function unwrapPrompt(maybeCancelPromise) {
|
|
1546
|
-
const result = await maybeCancelPromise;
|
|
1547
|
-
if (pD(result)) {
|
|
1548
|
-
xe(picocolorsExports.red('✖') + ` ${language.errors.operationCancelled}`);
|
|
1549
|
-
process.exit(0);
|
|
1550
|
-
}
|
|
1551
|
-
return result;
|
|
1552
|
-
}
|
|
1553
|
-
|
|
1554
|
-
const defaultBanner = 'React.js - The library for web and native user interfaces';
|
|
1555
|
-
/**
|
|
1556
|
-
* Generates a gradient banner string with ANSI color codes.
|
|
1557
|
-
*/
|
|
1558
|
-
const gradientBanner = (() => {
|
|
1559
|
-
const startColor = [97, 218, 251]; // #61dafb RGB
|
|
1560
|
-
const endColor = [30, 144, 255]; // #1e90ff RGB
|
|
1561
|
-
const length = defaultBanner.length;
|
|
1562
|
-
let result = '';
|
|
1563
|
-
for (let i = 0; i < length; i++) {
|
|
1564
|
-
const r = Math.round(startColor[0] + ((endColor[0] - startColor[0]) * i) / (length - 1));
|
|
1565
|
-
const g = Math.round(startColor[1] + ((endColor[1] - startColor[1]) * i) / (length - 1));
|
|
1566
|
-
const b = Math.round(startColor[2] + ((endColor[2] - startColor[2]) * i) / (length - 1));
|
|
1567
|
-
result += `\x1B[38;2;${r};${g};${b}m${defaultBanner[i]}\x1B[39m`;
|
|
1568
|
-
}
|
|
1569
|
-
return result;
|
|
1570
|
-
})();
|
|
1571
|
-
|
|
1572
|
-
function getCommand(packageManager, scriptName, args) {
|
|
1573
|
-
if (scriptName === 'install') {
|
|
1574
|
-
return packageManager === 'yarn' ? 'yarn' : `${packageManager} install`;
|
|
1575
|
-
}
|
|
1576
|
-
if (scriptName === 'build') {
|
|
1577
|
-
return packageManager === 'npm' || packageManager === 'bun'
|
|
1578
|
-
? `${packageManager} run build`
|
|
1579
|
-
: `${packageManager} build`;
|
|
1580
|
-
}
|
|
1581
|
-
{
|
|
1582
|
-
return packageManager === 'npm' ? `npm run ${scriptName}` : `${packageManager} ${scriptName}`;
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
function isValidPackageName(projectName) {
|
|
1587
|
-
return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(projectName);
|
|
1588
|
-
}
|
|
1589
|
-
function toValidPackageName(projectName) {
|
|
1590
|
-
return projectName
|
|
1591
|
-
.trim()
|
|
1592
|
-
.toLowerCase()
|
|
1593
|
-
.replace(/\s+/g, '-')
|
|
1594
|
-
.replace(/^[._]/, '')
|
|
1595
|
-
.replace(/[^a-z0-9-~]+/g, '-');
|
|
1596
|
-
}
|
|
1597
|
-
|
|
1598
|
-
function preOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
|
|
1599
|
-
for (const filename of fs.readdirSync(dir)) {
|
|
1600
|
-
if (filename === '.git') {
|
|
1601
|
-
continue;
|
|
1602
|
-
}
|
|
1603
|
-
const fullpath = path.resolve(dir, filename);
|
|
1604
|
-
if (fs.lstatSync(fullpath).isDirectory()) {
|
|
1605
|
-
dirCallback(fullpath);
|
|
1606
|
-
// in case the dirCallback removes the directory entirely
|
|
1607
|
-
if (fs.existsSync(fullpath)) {
|
|
1608
|
-
preOrderDirectoryTraverse(fullpath, dirCallback, fileCallback);
|
|
1609
|
-
}
|
|
1610
|
-
continue;
|
|
1611
|
-
}
|
|
1612
|
-
fileCallback(fullpath);
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
const dotGitDirectoryState = {
|
|
1616
|
-
hasDotGitDirectory: false,
|
|
1617
|
-
};
|
|
1618
|
-
function postOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
|
|
1619
|
-
for (const filename of fs.readdirSync(dir)) {
|
|
1620
|
-
if (filename === '.git') {
|
|
1621
|
-
dotGitDirectoryState.hasDotGitDirectory = true;
|
|
1622
|
-
continue;
|
|
1623
|
-
}
|
|
1624
|
-
const fullpath = path.resolve(dir, filename);
|
|
1625
|
-
if (fs.lstatSync(fullpath).isDirectory()) {
|
|
1626
|
-
postOrderDirectoryTraverse(fullpath, dirCallback, fileCallback);
|
|
1627
|
-
dirCallback(fullpath);
|
|
1628
|
-
continue;
|
|
1629
|
-
}
|
|
1630
|
-
fileCallback(fullpath);
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
|
-
function canSkipEmptying(dir) {
|
|
1635
|
-
if (!fs.existsSync(dir)) {
|
|
1636
|
-
return true;
|
|
1637
|
-
}
|
|
1638
|
-
const files = fs.readdirSync(dir);
|
|
1639
|
-
if (files.length === 0) {
|
|
1640
|
-
return true;
|
|
1641
|
-
}
|
|
1642
|
-
if (files.length === 1 && files[0] === '.git') {
|
|
1643
|
-
dotGitDirectoryState.hasDotGitDirectory = true;
|
|
1644
|
-
return true;
|
|
1645
|
-
}
|
|
1646
|
-
return false;
|
|
1647
|
-
}
|
|
1648
|
-
function emptyDir(dir) {
|
|
1649
|
-
if (!fs.existsSync(dir)) {
|
|
1650
|
-
return;
|
|
1651
|
-
}
|
|
1652
|
-
postOrderDirectoryTraverse(dir, (dir) => fs.rmdirSync(dir), (file) => fs.unlinkSync(file));
|
|
1653
|
-
}
|
|
1654
|
-
|
|
1655
|
-
const isObject = (val) => val && typeof val === 'object';
|
|
1656
|
-
const mergeArrayWithDedupe = (a, b) => Array.from(new Set([...a, ...b]));
|
|
1657
|
-
/**
|
|
1658
|
-
* Recursively merge the content of the new object to the existing one
|
|
1659
|
-
* @param {Object} target the existing object
|
|
1660
|
-
* @param {Object} obj the new object
|
|
1661
|
-
*/
|
|
1662
|
-
function deepMerge(target, obj) {
|
|
1663
|
-
for (const key of Object.keys(obj)) {
|
|
1664
|
-
const oldVal = target[key];
|
|
1665
|
-
const newVal = obj[key];
|
|
1666
|
-
if (Array.isArray(oldVal) && Array.isArray(newVal)) {
|
|
1667
|
-
target[key] = mergeArrayWithDedupe(oldVal, newVal);
|
|
1668
|
-
}
|
|
1669
|
-
else if (isObject(oldVal) && isObject(newVal)) {
|
|
1670
|
-
target[key] = deepMerge(oldVal, newVal);
|
|
1671
|
-
}
|
|
1672
|
-
else {
|
|
1673
|
-
target[key] = newVal;
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
|
-
return target;
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1679
|
-
function sortDependencies(packageJson) {
|
|
1680
|
-
const sorted = {};
|
|
1681
|
-
const depTypes = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
|
|
1682
|
-
for (const depType of depTypes) {
|
|
1683
|
-
if (packageJson[depType]) {
|
|
1684
|
-
sorted[depType] = {};
|
|
1685
|
-
Object.keys(packageJson[depType])
|
|
1686
|
-
.sort()
|
|
1687
|
-
.forEach((name) => {
|
|
1688
|
-
sorted[depType][name] = packageJson[depType][name];
|
|
1689
|
-
});
|
|
1690
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
return {
|
|
1693
|
-
...packageJson,
|
|
1694
|
-
...sorted,
|
|
1695
|
-
};
|
|
1696
|
-
}
|
|
1697
|
-
|
|
1698
|
-
/**
|
|
1699
|
-
* Renders a template folder/file to the file system,
|
|
1700
|
-
* by recursively copying all files under the `src` directory,
|
|
1701
|
-
* with the following exception:
|
|
1702
|
-
* - `_filename` should be renamed to `.filename`
|
|
1703
|
-
* - Fields in `package.json` should be recursively merged
|
|
1704
|
-
* @param {string} src source filename to copy
|
|
1705
|
-
* @param {string} dest destination filename of the copy operation
|
|
1706
|
-
*/
|
|
1707
|
-
function renderTemplate(src, dest, callbacks) {
|
|
1708
|
-
const stats = fs.statSync(src);
|
|
1709
|
-
if (stats.isDirectory()) {
|
|
1710
|
-
// skip node_module
|
|
1711
|
-
if (path.basename(src) === 'node_modules') {
|
|
1712
|
-
return;
|
|
1713
|
-
}
|
|
1714
|
-
// rename `_dirname` to `.dirname`
|
|
1715
|
-
const dirname = path.basename(src);
|
|
1716
|
-
if (dirname.startsWith('_')) {
|
|
1717
|
-
dest = path.resolve(path.dirname(dest), dirname.replace(/^_/, '.'));
|
|
1718
|
-
}
|
|
1719
|
-
// if it's a directory, render its subdirectories and files recursively
|
|
1720
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
1721
|
-
for (const file of fs.readdirSync(src)) {
|
|
1722
|
-
renderTemplate(path.resolve(src, file), path.resolve(dest, file), callbacks);
|
|
1723
|
-
}
|
|
1724
|
-
return;
|
|
1725
|
-
}
|
|
1726
|
-
const filename = path.basename(src);
|
|
1727
|
-
if (filename === 'package.json' && fs.existsSync(dest)) {
|
|
1728
|
-
// merge instead of overwriting
|
|
1729
|
-
const existing = JSON.parse(fs.readFileSync(dest, 'utf8'));
|
|
1730
|
-
const newPackage = JSON.parse(fs.readFileSync(src, 'utf8'));
|
|
1731
|
-
const pkg = sortDependencies(deepMerge(existing, newPackage));
|
|
1732
|
-
fs.writeFileSync(dest, JSON.stringify(pkg, null, 2) + '\n');
|
|
1733
|
-
return;
|
|
1734
|
-
}
|
|
1735
|
-
if (filename === 'extensions.json' && fs.existsSync(dest)) {
|
|
1736
|
-
// merge instead of overwriting
|
|
1737
|
-
const existing = JSON.parse(fs.readFileSync(dest, 'utf8'));
|
|
1738
|
-
const newExtensions = JSON.parse(fs.readFileSync(src, 'utf8'));
|
|
1739
|
-
const extensions = deepMerge(existing, newExtensions);
|
|
1740
|
-
fs.writeFileSync(dest, JSON.stringify(extensions, null, 2) + '\n');
|
|
1741
|
-
return;
|
|
1742
|
-
}
|
|
1743
|
-
if (filename === 'settings.json' && fs.existsSync(dest)) {
|
|
1744
|
-
// merge instead of overwriting
|
|
1745
|
-
const existing = JSON.parse(fs.readFileSync(dest, 'utf8'));
|
|
1746
|
-
const newSettings = JSON.parse(fs.readFileSync(src, 'utf8'));
|
|
1747
|
-
const settings = deepMerge(existing, newSettings);
|
|
1748
|
-
fs.writeFileSync(dest, JSON.stringify(settings, null, 2) + '\n');
|
|
1749
|
-
return;
|
|
1750
|
-
}
|
|
1751
|
-
if (filename.startsWith('_')) {
|
|
1752
|
-
// rename `_file` to `.file`
|
|
1753
|
-
dest = path.resolve(path.dirname(dest), filename.replace(/^_/, '.'));
|
|
1754
|
-
}
|
|
1755
|
-
if (filename === '_gitignore' && fs.existsSync(dest)) {
|
|
1756
|
-
// append to existing .gitignore
|
|
1757
|
-
const existing = fs.readFileSync(dest, 'utf8');
|
|
1758
|
-
const newGitignore = fs.readFileSync(src, 'utf8');
|
|
1759
|
-
fs.writeFileSync(dest, existing + '\n' + newGitignore);
|
|
1760
|
-
return;
|
|
1761
|
-
}
|
|
1762
|
-
// data file for EJS templates
|
|
1763
|
-
if (filename.endsWith('.data.mjs')) {
|
|
1764
|
-
// use dest path as key for the data store
|
|
1765
|
-
dest = dest.replace(/\.data\.mjs$/, '');
|
|
1766
|
-
// Add a callback to the array for late usage when template files are being processed
|
|
1767
|
-
callbacks.push(async (dataStore) => {
|
|
1768
|
-
const getData = (await import(pathToFileURL(src).toString())).default;
|
|
1769
|
-
// Though current `getData` are all sync, we still retain the possibility of async
|
|
1770
|
-
dataStore[dest] = await getData({
|
|
1771
|
-
oldData: dataStore[dest] || {},
|
|
1772
|
-
});
|
|
1773
|
-
});
|
|
1774
|
-
return; // skip copying the data file
|
|
1775
|
-
}
|
|
1776
|
-
fs.copyFileSync(src, dest);
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
|
-
var name = "create-vite-react-cli";
|
|
1780
|
-
var version = "0.4.1";
|
|
1781
|
-
var cliPackageJson = {
|
|
1782
|
-
name: name,
|
|
1783
|
-
version: version};
|
|
1784
|
-
|
|
1785
|
-
const DEFAULT_PROJECT_NAME = 'my-vite-react-app';
|
|
1786
|
-
async function createProject() {
|
|
1787
|
-
const cwd = process.cwd();
|
|
1788
|
-
const args = process.argv.slice(2);
|
|
1789
|
-
const flags = [...FEATURE_FLAGS, 'force', 'help', 'version'];
|
|
1790
|
-
const options = Object.fromEntries(flags.map((key) => [key, { type: 'boolean' }]));
|
|
1791
|
-
const { values: argv, positionals } = parseArgs({
|
|
1792
|
-
args,
|
|
1793
|
-
options,
|
|
1794
|
-
strict: true,
|
|
1795
|
-
allowPositionals: true,
|
|
1796
|
-
});
|
|
1797
|
-
if (argv.help) {
|
|
1798
|
-
console.log(helpMessage);
|
|
1799
|
-
process.exit(0);
|
|
1800
|
-
}
|
|
1801
|
-
if (argv.version) {
|
|
1802
|
-
console.log(`${cliPackageJson.name} v${cliPackageJson.version}`);
|
|
1803
|
-
process.exit(0);
|
|
1804
|
-
}
|
|
1805
|
-
// if any of the feature flags is set, we would skip the feature prompts
|
|
1806
|
-
const isFeatureFlagsUsed = FEATURE_FLAGS.some((flag) => typeof argv[flag] === 'boolean');
|
|
1807
|
-
let targetDir = positionals[0];
|
|
1808
|
-
const defaultProjectName = targetDir || DEFAULT_PROJECT_NAME;
|
|
1809
|
-
const forceOverwrite = argv.force;
|
|
1810
|
-
const result = {
|
|
1811
|
-
projectName: defaultProjectName,
|
|
1812
|
-
shouldOverwrite: forceOverwrite,
|
|
1813
|
-
packageName: defaultProjectName,
|
|
1814
|
-
features: [],
|
|
1815
|
-
};
|
|
1816
|
-
Ie(process.stdout.isTTY && process.stdout.getColorDepth() > 8 ? gradientBanner : defaultBanner);
|
|
1817
|
-
if (!targetDir) {
|
|
1818
|
-
const _result = await unwrapPrompt(he({
|
|
1819
|
-
message: language.projectName.message,
|
|
1820
|
-
placeholder: defaultProjectName,
|
|
1821
|
-
defaultValue: defaultProjectName,
|
|
1822
|
-
validate: (value) => value.length === 0 || value.trim().length > 0
|
|
1823
|
-
? undefined
|
|
1824
|
-
: language.projectName.invalidMessage,
|
|
1825
|
-
}));
|
|
1826
|
-
targetDir = result.projectName = result.packageName = _result.trim();
|
|
1827
|
-
}
|
|
1828
|
-
if (!canSkipEmptying(targetDir) && !forceOverwrite) {
|
|
1829
|
-
result.shouldOverwrite = await unwrapPrompt(ye({
|
|
1830
|
-
message: `${targetDir === '.'
|
|
1831
|
-
? language.shouldOverwrite.dirForPrompts.current
|
|
1832
|
-
: `${language.shouldOverwrite.dirForPrompts.target} "${targetDir}"`} ${language.shouldOverwrite.message}`,
|
|
1833
|
-
initialValue: false,
|
|
1834
|
-
}));
|
|
1835
|
-
if (!result.shouldOverwrite) {
|
|
1836
|
-
xe(picocolorsExports.red('✖') + ` ${language.errors.operationCancelled}`);
|
|
1837
|
-
process.exit(0);
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
if (!isValidPackageName(targetDir)) {
|
|
1841
|
-
result.packageName = await unwrapPrompt(he({
|
|
1842
|
-
message: language.packageName.message,
|
|
1843
|
-
initialValue: toValidPackageName(targetDir),
|
|
1844
|
-
validate: (value) => isValidPackageName(value) ? undefined : language.packageName.invalidMessage,
|
|
1845
|
-
}));
|
|
1846
|
-
}
|
|
1847
|
-
if (!isFeatureFlagsUsed) {
|
|
1848
|
-
result.features = await unwrapPrompt(fe({
|
|
1849
|
-
message: `${language.featureSelection.message} ${picocolorsExports.dim(language.featureSelection.hint)}`,
|
|
1850
|
-
// @ts-expect-error @clack/prompt's type doesn't support readonly array yet
|
|
1851
|
-
options: FEATURE_OPTIONS,
|
|
1852
|
-
required: false,
|
|
1853
|
-
}));
|
|
1854
|
-
}
|
|
1855
|
-
const { features } = result;
|
|
1856
|
-
const needsTypeScript = argv.ts || argv.typescript || features.includes('typescript');
|
|
1857
|
-
const needsEslint = argv.eslint || argv['eslint-with-prettier'] || features.includes('eslint');
|
|
1858
|
-
const needsPrettier = argv.prettier || argv['eslint-with-prettier'] || features.includes('prettier');
|
|
1859
|
-
const root = path.join(cwd, targetDir);
|
|
1860
|
-
if (fs.existsSync(root) && result.shouldOverwrite) {
|
|
1861
|
-
emptyDir(root);
|
|
1862
|
-
}
|
|
1863
|
-
else if (!fs.existsSync(root)) {
|
|
1864
|
-
fs.mkdirSync(root);
|
|
1865
|
-
}
|
|
1866
|
-
console.log(`\n${language.infos.scaffolding} ${root}...`);
|
|
1867
|
-
const pkg = { name: result.packageName, version: '0.0.0' };
|
|
1868
|
-
fs.writeFileSync(path.resolve(root, 'package.json'), JSON.stringify(pkg, null, 2));
|
|
1869
|
-
const templateRoot = fileURLToPath(new URL('./templates', import.meta.url));
|
|
1870
|
-
const callbacks = [];
|
|
1871
|
-
const render = function render(templateName) {
|
|
1872
|
-
const templateDir = path.resolve(templateRoot, templateName);
|
|
1873
|
-
renderTemplate(templateDir, root, callbacks);
|
|
1874
|
-
};
|
|
1875
|
-
// Render base template
|
|
1876
|
-
render('base');
|
|
1877
|
-
// Add configs.
|
|
1878
|
-
if (needsTypeScript) {
|
|
1879
|
-
render('config/typescript');
|
|
1880
|
-
// Render tsconfigs
|
|
1881
|
-
render('tsconfig/base');
|
|
1882
|
-
// The content of the root `tsconfig.json` is a bit complicated,
|
|
1883
|
-
// So here we are programmatically generating it.
|
|
1884
|
-
const rootTsConfig = {
|
|
1885
|
-
// It doesn't target any specific files because they are all configured in the referenced ones.
|
|
1886
|
-
files: [],
|
|
1887
|
-
// All templates contain at least a `.node` and a `.app` tsconfig.
|
|
1888
|
-
references: [
|
|
1889
|
-
{
|
|
1890
|
-
path: './tsconfig.node.json',
|
|
1891
|
-
},
|
|
1892
|
-
{
|
|
1893
|
-
path: './tsconfig.app.json',
|
|
1894
|
-
},
|
|
1895
|
-
],
|
|
1896
|
-
};
|
|
1897
|
-
fs.writeFileSync(path.resolve(root, 'tsconfig.json'), JSON.stringify(rootTsConfig, null, 2) + '\n', 'utf-8');
|
|
1898
|
-
}
|
|
1899
|
-
// Render ESLint config
|
|
1900
|
-
if (needsEslint) {
|
|
1901
|
-
render('linting/base');
|
|
1902
|
-
if (needsTypeScript) {
|
|
1903
|
-
render('linting/core/ts');
|
|
1904
|
-
}
|
|
1905
|
-
else {
|
|
1906
|
-
render('linting/core/js');
|
|
1907
|
-
}
|
|
1908
|
-
// These configs only disable rules, so they should be applied last.
|
|
1909
|
-
if (needsPrettier) {
|
|
1910
|
-
render('linting/prettier');
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
if (needsPrettier) {
|
|
1914
|
-
render('formatting/prettier');
|
|
1915
|
-
}
|
|
1916
|
-
// Render code template.
|
|
1917
|
-
const codeTemplate = needsTypeScript ? 'typescript-' : 'default';
|
|
1918
|
-
render(`code/${codeTemplate}`);
|
|
1919
|
-
render('entry/default');
|
|
1920
|
-
// An external data store for callbacks to share data
|
|
1921
|
-
const dataStore = {};
|
|
1922
|
-
const indexHtmlPath = path.resolve(root, 'index.html');
|
|
1923
|
-
dataStore[indexHtmlPath] = {
|
|
1924
|
-
title: result.projectName,
|
|
1925
|
-
entryExt: needsTypeScript ? 'tsx' : 'jsx',
|
|
1926
|
-
};
|
|
1927
|
-
// Process callbacks
|
|
1928
|
-
for (const cb of callbacks) {
|
|
1929
|
-
await cb(dataStore);
|
|
1930
|
-
}
|
|
1931
|
-
// EJS template rendering
|
|
1932
|
-
preOrderDirectoryTraverse(root, () => { }, (filepath) => {
|
|
1933
|
-
if (filepath.endsWith('.ejs')) {
|
|
1934
|
-
const template = fs.readFileSync(filepath, 'utf-8');
|
|
1935
|
-
const dest = filepath.replace(/\.ejs$/, '');
|
|
1936
|
-
const content = ejs.render(template, dataStore[dest]);
|
|
1937
|
-
fs.writeFileSync(dest, content);
|
|
1938
|
-
fs.unlinkSync(filepath);
|
|
1939
|
-
}
|
|
1940
|
-
});
|
|
1941
|
-
if (needsTypeScript) {
|
|
1942
|
-
preOrderDirectoryTraverse(root, () => { }, (filepath) => {
|
|
1943
|
-
if (filepath.endsWith('.js')) {
|
|
1944
|
-
const tsFilePath = filepath.replace(/\.js$/, '.ts');
|
|
1945
|
-
if (fs.existsSync(tsFilePath)) {
|
|
1946
|
-
fs.unlinkSync(filepath);
|
|
1947
|
-
}
|
|
1948
|
-
else {
|
|
1949
|
-
fs.renameSync(filepath, tsFilePath);
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1952
|
-
else if (filepath.endsWith('.jsx')) {
|
|
1953
|
-
const tsxFilePath = filepath.replace(/\.jsx$/, '.tsx');
|
|
1954
|
-
if (fs.existsSync(tsxFilePath)) {
|
|
1955
|
-
fs.unlinkSync(filepath);
|
|
1956
|
-
}
|
|
1957
|
-
else {
|
|
1958
|
-
fs.renameSync(filepath, tsxFilePath);
|
|
1959
|
-
}
|
|
1960
|
-
}
|
|
1961
|
-
else if (path.basename(filepath) === 'jsconfig.json') {
|
|
1962
|
-
fs.unlinkSync(filepath);
|
|
1963
|
-
}
|
|
1964
|
-
});
|
|
1965
|
-
// Rename entry in `index.html`
|
|
1966
|
-
const indexHtmlPath = path.resolve(root, 'index.html');
|
|
1967
|
-
const indexHtmlContent = fs.readFileSync(indexHtmlPath, 'utf8');
|
|
1968
|
-
fs.writeFileSync(indexHtmlPath, indexHtmlContent.replace('src/main.js', 'src/main.ts'));
|
|
1969
|
-
}
|
|
1970
|
-
else {
|
|
1971
|
-
// Remove all the remaining `.ts` and `.tsx` files
|
|
1972
|
-
preOrderDirectoryTraverse(root, () => { }, (filepath) => {
|
|
1973
|
-
if (filepath.endsWith('.ts') || filepath.endsWith('.tsx')) {
|
|
1974
|
-
fs.unlinkSync(filepath);
|
|
1975
|
-
}
|
|
1976
|
-
});
|
|
1977
|
-
}
|
|
1978
|
-
// Instructions:
|
|
1979
|
-
// Supported package managers: pnpm > yarn > bun > npm
|
|
1980
|
-
const userAgent = process.env.npm_config_user_agent ?? '';
|
|
1981
|
-
const packageManager = /pnpm/.test(userAgent)
|
|
1982
|
-
? 'pnpm'
|
|
1983
|
-
: /yarn/.test(userAgent)
|
|
1984
|
-
? 'yarn'
|
|
1985
|
-
: /bun/.test(userAgent)
|
|
1986
|
-
? 'bun'
|
|
1987
|
-
: 'npm';
|
|
1988
|
-
// TODO README generation
|
|
1989
|
-
let outroMessage = `${language.infos.done}\n\n`;
|
|
1990
|
-
if (root !== cwd) {
|
|
1991
|
-
const cdProjectName = path.relative(cwd, root);
|
|
1992
|
-
outroMessage += ` ${picocolorsExports.bold(picocolorsExports.green(`cd ${cdProjectName.includes(' ') ? `"${cdProjectName}"` : cdProjectName}`))}\n`;
|
|
1993
|
-
}
|
|
1994
|
-
outroMessage += ` ${picocolorsExports.bold(picocolorsExports.green(getCommand(packageManager, 'install')))}\n`;
|
|
1995
|
-
if (needsEslint) {
|
|
1996
|
-
outroMessage += ` ${picocolorsExports.bold(picocolorsExports.green(getCommand(packageManager, 'lint')))}\n`;
|
|
1997
|
-
}
|
|
1998
|
-
if (needsPrettier) {
|
|
1999
|
-
outroMessage += ` ${picocolorsExports.bold(picocolorsExports.green(getCommand(packageManager, 'format')))}\n`;
|
|
2000
|
-
}
|
|
2001
|
-
outroMessage += ` ${picocolorsExports.bold(picocolorsExports.green(getCommand(packageManager, 'dev')))}\n`;
|
|
2002
|
-
if (!dotGitDirectoryState.hasDotGitDirectory) {
|
|
2003
|
-
outroMessage += `
|
|
2004
|
-
${picocolorsExports.dim('|')} ${language.infos.optionalGitCommand}
|
|
2005
|
-
|
|
2006
|
-
${picocolorsExports.bold(picocolorsExports.green('git init && git add -A && git commit -m "initial commit"'))}`;
|
|
2007
|
-
}
|
|
2008
|
-
Se(outroMessage);
|
|
2009
|
-
}
|
|
2010
|
-
createProject().catch((error) => {
|
|
2011
|
-
console.error(error);
|
|
2012
|
-
process.exit(1);
|
|
2013
|
-
});
|