create-vue 3.22.3 → 3.22.4

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