@jsenv/core 40.3.3 → 40.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/build.js +166 -47
- package/dist/build/jsenv_core_node_modules.js +709 -0
- package/dist/{jsenv_core_packages.js → build/jsenv_core_packages.js} +9716 -17415
- package/dist/start_build_server/jsenv_core_node_modules.js +685 -0
- package/dist/start_build_server/jsenv_core_packages.js +1550 -0
- package/dist/start_build_server/start_build_server.js +2 -4
- package/dist/start_dev_server/jsenv_core_node_modules.js +685 -0
- package/dist/start_dev_server/jsenv_core_packages.js +6208 -0
- package/dist/start_dev_server/start_dev_server.js +85 -38
- package/package.json +16 -17
- package/src/build/build.js +43 -2
- package/src/build/build_specifier_manager.js +2 -2
- package/src/build/build_urls_generator.js +42 -5
- package/src/plugins/resolution_node_esm/node_esm_resolver.js +83 -36
- package/dist/jsenv_core_node_modules.js +0 -2069
- /package/dist/{browserslist_index → build/browserslist_index}/browserslist_index.js +0 -0
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import tty from "node:tty";
|
|
4
|
+
|
|
5
|
+
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
|
6
|
+
/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
|
|
7
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) {
|
|
8
|
+
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
|
9
|
+
const position = argv.indexOf(prefix + flag);
|
|
10
|
+
const terminatorPosition = argv.indexOf('--');
|
|
11
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const {env} = process;
|
|
15
|
+
|
|
16
|
+
let flagForceColor;
|
|
17
|
+
if (
|
|
18
|
+
hasFlag('no-color')
|
|
19
|
+
|| hasFlag('no-colors')
|
|
20
|
+
|| hasFlag('color=false')
|
|
21
|
+
|| hasFlag('color=never')
|
|
22
|
+
) {
|
|
23
|
+
flagForceColor = 0;
|
|
24
|
+
} else if (
|
|
25
|
+
hasFlag('color')
|
|
26
|
+
|| hasFlag('colors')
|
|
27
|
+
|| hasFlag('color=true')
|
|
28
|
+
|| hasFlag('color=always')
|
|
29
|
+
) {
|
|
30
|
+
flagForceColor = 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function envForceColor() {
|
|
34
|
+
if (!('FORCE_COLOR' in env)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (env.FORCE_COLOR === 'true') {
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (env.FORCE_COLOR === 'false') {
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (env.FORCE_COLOR.length === 0) {
|
|
47
|
+
return 1;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
51
|
+
|
|
52
|
+
if (![0, 1, 2, 3].includes(level)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return level;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function translateLevel(level) {
|
|
60
|
+
if (level === 0) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
level,
|
|
66
|
+
hasBasic: true,
|
|
67
|
+
has256: level >= 2,
|
|
68
|
+
has16m: level >= 3,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
73
|
+
const noFlagForceColor = envForceColor();
|
|
74
|
+
if (noFlagForceColor !== undefined) {
|
|
75
|
+
flagForceColor = noFlagForceColor;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
79
|
+
|
|
80
|
+
if (forceColor === 0) {
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (sniffFlags) {
|
|
85
|
+
if (hasFlag('color=16m')
|
|
86
|
+
|| hasFlag('color=full')
|
|
87
|
+
|| hasFlag('color=truecolor')) {
|
|
88
|
+
return 3;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (hasFlag('color=256')) {
|
|
92
|
+
return 2;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Check for Azure DevOps pipelines.
|
|
97
|
+
// Has to be above the `!streamIsTTY` check.
|
|
98
|
+
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
|
|
99
|
+
return 1;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const min = forceColor || 0;
|
|
107
|
+
|
|
108
|
+
if (env.TERM === 'dumb') {
|
|
109
|
+
return min;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (process.platform === 'win32') {
|
|
113
|
+
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
|
114
|
+
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
|
115
|
+
const osRelease = os.release().split('.');
|
|
116
|
+
if (
|
|
117
|
+
Number(osRelease[0]) >= 10
|
|
118
|
+
&& Number(osRelease[2]) >= 10_586
|
|
119
|
+
) {
|
|
120
|
+
return Number(osRelease[2]) >= 14_931 ? 3 : 2;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return 1;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if ('CI' in env) {
|
|
127
|
+
if (['GITHUB_ACTIONS', 'GITEA_ACTIONS', 'CIRCLECI'].some(key => key in env)) {
|
|
128
|
+
return 3;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (['TRAVIS', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
132
|
+
return 1;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return min;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if ('TEAMCITY_VERSION' in env) {
|
|
139
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (env.COLORTERM === 'truecolor') {
|
|
143
|
+
return 3;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (env.TERM === 'xterm-kitty') {
|
|
147
|
+
return 3;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if ('TERM_PROGRAM' in env) {
|
|
151
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
152
|
+
|
|
153
|
+
switch (env.TERM_PROGRAM) {
|
|
154
|
+
case 'iTerm.app': {
|
|
155
|
+
return version >= 3 ? 3 : 2;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
case 'Apple_Terminal': {
|
|
159
|
+
return 2;
|
|
160
|
+
}
|
|
161
|
+
// No default
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
166
|
+
return 2;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
170
|
+
return 1;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if ('COLORTERM' in env) {
|
|
174
|
+
return 1;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return min;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function createSupportsColor(stream, options = {}) {
|
|
181
|
+
const level = _supportsColor(stream, {
|
|
182
|
+
streamIsTTY: stream && stream.isTTY,
|
|
183
|
+
...options,
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
return translateLevel(level);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
({
|
|
190
|
+
stdout: createSupportsColor({isTTY: tty.isatty(1)}),
|
|
191
|
+
stderr: createSupportsColor({isTTY: tty.isatty(2)}),
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
function isUnicodeSupported() {
|
|
195
|
+
const {env} = process;
|
|
196
|
+
const {TERM, TERM_PROGRAM} = env;
|
|
197
|
+
|
|
198
|
+
if (process.platform !== 'win32') {
|
|
199
|
+
return TERM !== 'linux'; // Linux console (kernel)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return Boolean(env.WT_SESSION) // Windows Terminal
|
|
203
|
+
|| Boolean(env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
|
|
204
|
+
|| env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
|
|
205
|
+
|| TERM_PROGRAM === 'Terminus-Sublime'
|
|
206
|
+
|| TERM_PROGRAM === 'vscode'
|
|
207
|
+
|| TERM === 'xterm-256color'
|
|
208
|
+
|| TERM === 'alacritty'
|
|
209
|
+
|| TERM === 'rxvt-unicode'
|
|
210
|
+
|| TERM === 'rxvt-unicode-256color'
|
|
211
|
+
|| env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function ansiRegex({onlyFirst = false} = {}) {
|
|
215
|
+
// Valid string terminator sequences are BEL, ESC\, and 0x9c
|
|
216
|
+
const ST = '(?:\\u0007|\\u001B\\u005C|\\u009C)';
|
|
217
|
+
const pattern = [
|
|
218
|
+
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
|
|
219
|
+
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))',
|
|
220
|
+
].join('|');
|
|
221
|
+
|
|
222
|
+
return new RegExp(pattern, onlyFirst ? undefined : 'g');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const regex = ansiRegex();
|
|
226
|
+
|
|
227
|
+
function stripAnsi(string) {
|
|
228
|
+
if (typeof string !== 'string') {
|
|
229
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Even though the regex is global, we don't need to reset the `.lastIndex`
|
|
233
|
+
// because unlike `.exec()` and `.test()`, `.replace()` does it automatically
|
|
234
|
+
// and doing it manually has a performance penalty.
|
|
235
|
+
return string.replace(regex, '');
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const r = String.raw;
|
|
239
|
+
const seq = r`(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})`;
|
|
240
|
+
const sTags = r`\u{E0061}-\u{E007A}`;
|
|
241
|
+
const emojiRegex = () => new RegExp(r`[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[${sTags}]{2}[\u{E0030}-\u{E0039}${sTags}]{1,3}\u{E007F}|${seq}(?:\u200D${seq})*`, 'gu');
|
|
242
|
+
|
|
243
|
+
// Generated code.
|
|
244
|
+
|
|
245
|
+
function isAmbiguous(x) {
|
|
246
|
+
return x === 0xA1
|
|
247
|
+
|| x === 0xA4
|
|
248
|
+
|| x === 0xA7
|
|
249
|
+
|| x === 0xA8
|
|
250
|
+
|| x === 0xAA
|
|
251
|
+
|| x === 0xAD
|
|
252
|
+
|| x === 0xAE
|
|
253
|
+
|| x >= 0xB0 && x <= 0xB4
|
|
254
|
+
|| x >= 0xB6 && x <= 0xBA
|
|
255
|
+
|| x >= 0xBC && x <= 0xBF
|
|
256
|
+
|| x === 0xC6
|
|
257
|
+
|| x === 0xD0
|
|
258
|
+
|| x === 0xD7
|
|
259
|
+
|| x === 0xD8
|
|
260
|
+
|| x >= 0xDE && x <= 0xE1
|
|
261
|
+
|| x === 0xE6
|
|
262
|
+
|| x >= 0xE8 && x <= 0xEA
|
|
263
|
+
|| x === 0xEC
|
|
264
|
+
|| x === 0xED
|
|
265
|
+
|| x === 0xF0
|
|
266
|
+
|| x === 0xF2
|
|
267
|
+
|| x === 0xF3
|
|
268
|
+
|| x >= 0xF7 && x <= 0xFA
|
|
269
|
+
|| x === 0xFC
|
|
270
|
+
|| x === 0xFE
|
|
271
|
+
|| x === 0x101
|
|
272
|
+
|| x === 0x111
|
|
273
|
+
|| x === 0x113
|
|
274
|
+
|| x === 0x11B
|
|
275
|
+
|| x === 0x126
|
|
276
|
+
|| x === 0x127
|
|
277
|
+
|| x === 0x12B
|
|
278
|
+
|| x >= 0x131 && x <= 0x133
|
|
279
|
+
|| x === 0x138
|
|
280
|
+
|| x >= 0x13F && x <= 0x142
|
|
281
|
+
|| x === 0x144
|
|
282
|
+
|| x >= 0x148 && x <= 0x14B
|
|
283
|
+
|| x === 0x14D
|
|
284
|
+
|| x === 0x152
|
|
285
|
+
|| x === 0x153
|
|
286
|
+
|| x === 0x166
|
|
287
|
+
|| x === 0x167
|
|
288
|
+
|| x === 0x16B
|
|
289
|
+
|| x === 0x1CE
|
|
290
|
+
|| x === 0x1D0
|
|
291
|
+
|| x === 0x1D2
|
|
292
|
+
|| x === 0x1D4
|
|
293
|
+
|| x === 0x1D6
|
|
294
|
+
|| x === 0x1D8
|
|
295
|
+
|| x === 0x1DA
|
|
296
|
+
|| x === 0x1DC
|
|
297
|
+
|| x === 0x251
|
|
298
|
+
|| x === 0x261
|
|
299
|
+
|| x === 0x2C4
|
|
300
|
+
|| x === 0x2C7
|
|
301
|
+
|| x >= 0x2C9 && x <= 0x2CB
|
|
302
|
+
|| x === 0x2CD
|
|
303
|
+
|| x === 0x2D0
|
|
304
|
+
|| x >= 0x2D8 && x <= 0x2DB
|
|
305
|
+
|| x === 0x2DD
|
|
306
|
+
|| x === 0x2DF
|
|
307
|
+
|| x >= 0x300 && x <= 0x36F
|
|
308
|
+
|| x >= 0x391 && x <= 0x3A1
|
|
309
|
+
|| x >= 0x3A3 && x <= 0x3A9
|
|
310
|
+
|| x >= 0x3B1 && x <= 0x3C1
|
|
311
|
+
|| x >= 0x3C3 && x <= 0x3C9
|
|
312
|
+
|| x === 0x401
|
|
313
|
+
|| x >= 0x410 && x <= 0x44F
|
|
314
|
+
|| x === 0x451
|
|
315
|
+
|| x === 0x2010
|
|
316
|
+
|| x >= 0x2013 && x <= 0x2016
|
|
317
|
+
|| x === 0x2018
|
|
318
|
+
|| x === 0x2019
|
|
319
|
+
|| x === 0x201C
|
|
320
|
+
|| x === 0x201D
|
|
321
|
+
|| x >= 0x2020 && x <= 0x2022
|
|
322
|
+
|| x >= 0x2024 && x <= 0x2027
|
|
323
|
+
|| x === 0x2030
|
|
324
|
+
|| x === 0x2032
|
|
325
|
+
|| x === 0x2033
|
|
326
|
+
|| x === 0x2035
|
|
327
|
+
|| x === 0x203B
|
|
328
|
+
|| x === 0x203E
|
|
329
|
+
|| x === 0x2074
|
|
330
|
+
|| x === 0x207F
|
|
331
|
+
|| x >= 0x2081 && x <= 0x2084
|
|
332
|
+
|| x === 0x20AC
|
|
333
|
+
|| x === 0x2103
|
|
334
|
+
|| x === 0x2105
|
|
335
|
+
|| x === 0x2109
|
|
336
|
+
|| x === 0x2113
|
|
337
|
+
|| x === 0x2116
|
|
338
|
+
|| x === 0x2121
|
|
339
|
+
|| x === 0x2122
|
|
340
|
+
|| x === 0x2126
|
|
341
|
+
|| x === 0x212B
|
|
342
|
+
|| x === 0x2153
|
|
343
|
+
|| x === 0x2154
|
|
344
|
+
|| x >= 0x215B && x <= 0x215E
|
|
345
|
+
|| x >= 0x2160 && x <= 0x216B
|
|
346
|
+
|| x >= 0x2170 && x <= 0x2179
|
|
347
|
+
|| x === 0x2189
|
|
348
|
+
|| x >= 0x2190 && x <= 0x2199
|
|
349
|
+
|| x === 0x21B8
|
|
350
|
+
|| x === 0x21B9
|
|
351
|
+
|| x === 0x21D2
|
|
352
|
+
|| x === 0x21D4
|
|
353
|
+
|| x === 0x21E7
|
|
354
|
+
|| x === 0x2200
|
|
355
|
+
|| x === 0x2202
|
|
356
|
+
|| x === 0x2203
|
|
357
|
+
|| x === 0x2207
|
|
358
|
+
|| x === 0x2208
|
|
359
|
+
|| x === 0x220B
|
|
360
|
+
|| x === 0x220F
|
|
361
|
+
|| x === 0x2211
|
|
362
|
+
|| x === 0x2215
|
|
363
|
+
|| x === 0x221A
|
|
364
|
+
|| x >= 0x221D && x <= 0x2220
|
|
365
|
+
|| x === 0x2223
|
|
366
|
+
|| x === 0x2225
|
|
367
|
+
|| x >= 0x2227 && x <= 0x222C
|
|
368
|
+
|| x === 0x222E
|
|
369
|
+
|| x >= 0x2234 && x <= 0x2237
|
|
370
|
+
|| x === 0x223C
|
|
371
|
+
|| x === 0x223D
|
|
372
|
+
|| x === 0x2248
|
|
373
|
+
|| x === 0x224C
|
|
374
|
+
|| x === 0x2252
|
|
375
|
+
|| x === 0x2260
|
|
376
|
+
|| x === 0x2261
|
|
377
|
+
|| x >= 0x2264 && x <= 0x2267
|
|
378
|
+
|| x === 0x226A
|
|
379
|
+
|| x === 0x226B
|
|
380
|
+
|| x === 0x226E
|
|
381
|
+
|| x === 0x226F
|
|
382
|
+
|| x === 0x2282
|
|
383
|
+
|| x === 0x2283
|
|
384
|
+
|| x === 0x2286
|
|
385
|
+
|| x === 0x2287
|
|
386
|
+
|| x === 0x2295
|
|
387
|
+
|| x === 0x2299
|
|
388
|
+
|| x === 0x22A5
|
|
389
|
+
|| x === 0x22BF
|
|
390
|
+
|| x === 0x2312
|
|
391
|
+
|| x >= 0x2460 && x <= 0x24E9
|
|
392
|
+
|| x >= 0x24EB && x <= 0x254B
|
|
393
|
+
|| x >= 0x2550 && x <= 0x2573
|
|
394
|
+
|| x >= 0x2580 && x <= 0x258F
|
|
395
|
+
|| x >= 0x2592 && x <= 0x2595
|
|
396
|
+
|| x === 0x25A0
|
|
397
|
+
|| x === 0x25A1
|
|
398
|
+
|| x >= 0x25A3 && x <= 0x25A9
|
|
399
|
+
|| x === 0x25B2
|
|
400
|
+
|| x === 0x25B3
|
|
401
|
+
|| x === 0x25B6
|
|
402
|
+
|| x === 0x25B7
|
|
403
|
+
|| x === 0x25BC
|
|
404
|
+
|| x === 0x25BD
|
|
405
|
+
|| x === 0x25C0
|
|
406
|
+
|| x === 0x25C1
|
|
407
|
+
|| x >= 0x25C6 && x <= 0x25C8
|
|
408
|
+
|| x === 0x25CB
|
|
409
|
+
|| x >= 0x25CE && x <= 0x25D1
|
|
410
|
+
|| x >= 0x25E2 && x <= 0x25E5
|
|
411
|
+
|| x === 0x25EF
|
|
412
|
+
|| x === 0x2605
|
|
413
|
+
|| x === 0x2606
|
|
414
|
+
|| x === 0x2609
|
|
415
|
+
|| x === 0x260E
|
|
416
|
+
|| x === 0x260F
|
|
417
|
+
|| x === 0x261C
|
|
418
|
+
|| x === 0x261E
|
|
419
|
+
|| x === 0x2640
|
|
420
|
+
|| x === 0x2642
|
|
421
|
+
|| x === 0x2660
|
|
422
|
+
|| x === 0x2661
|
|
423
|
+
|| x >= 0x2663 && x <= 0x2665
|
|
424
|
+
|| x >= 0x2667 && x <= 0x266A
|
|
425
|
+
|| x === 0x266C
|
|
426
|
+
|| x === 0x266D
|
|
427
|
+
|| x === 0x266F
|
|
428
|
+
|| x === 0x269E
|
|
429
|
+
|| x === 0x269F
|
|
430
|
+
|| x === 0x26BF
|
|
431
|
+
|| x >= 0x26C6 && x <= 0x26CD
|
|
432
|
+
|| x >= 0x26CF && x <= 0x26D3
|
|
433
|
+
|| x >= 0x26D5 && x <= 0x26E1
|
|
434
|
+
|| x === 0x26E3
|
|
435
|
+
|| x === 0x26E8
|
|
436
|
+
|| x === 0x26E9
|
|
437
|
+
|| x >= 0x26EB && x <= 0x26F1
|
|
438
|
+
|| x === 0x26F4
|
|
439
|
+
|| x >= 0x26F6 && x <= 0x26F9
|
|
440
|
+
|| x === 0x26FB
|
|
441
|
+
|| x === 0x26FC
|
|
442
|
+
|| x === 0x26FE
|
|
443
|
+
|| x === 0x26FF
|
|
444
|
+
|| x === 0x273D
|
|
445
|
+
|| x >= 0x2776 && x <= 0x277F
|
|
446
|
+
|| x >= 0x2B56 && x <= 0x2B59
|
|
447
|
+
|| x >= 0x3248 && x <= 0x324F
|
|
448
|
+
|| x >= 0xE000 && x <= 0xF8FF
|
|
449
|
+
|| x >= 0xFE00 && x <= 0xFE0F
|
|
450
|
+
|| x === 0xFFFD
|
|
451
|
+
|| x >= 0x1F100 && x <= 0x1F10A
|
|
452
|
+
|| x >= 0x1F110 && x <= 0x1F12D
|
|
453
|
+
|| x >= 0x1F130 && x <= 0x1F169
|
|
454
|
+
|| x >= 0x1F170 && x <= 0x1F18D
|
|
455
|
+
|| x === 0x1F18F
|
|
456
|
+
|| x === 0x1F190
|
|
457
|
+
|| x >= 0x1F19B && x <= 0x1F1AC
|
|
458
|
+
|| x >= 0xE0100 && x <= 0xE01EF
|
|
459
|
+
|| x >= 0xF0000 && x <= 0xFFFFD
|
|
460
|
+
|| x >= 0x100000 && x <= 0x10FFFD;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function isFullWidth(x) {
|
|
464
|
+
return x === 0x3000
|
|
465
|
+
|| x >= 0xFF01 && x <= 0xFF60
|
|
466
|
+
|| x >= 0xFFE0 && x <= 0xFFE6;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
function isWide(x) {
|
|
470
|
+
return x >= 0x1100 && x <= 0x115F
|
|
471
|
+
|| x === 0x231A
|
|
472
|
+
|| x === 0x231B
|
|
473
|
+
|| x === 0x2329
|
|
474
|
+
|| x === 0x232A
|
|
475
|
+
|| x >= 0x23E9 && x <= 0x23EC
|
|
476
|
+
|| x === 0x23F0
|
|
477
|
+
|| x === 0x23F3
|
|
478
|
+
|| x === 0x25FD
|
|
479
|
+
|| x === 0x25FE
|
|
480
|
+
|| x === 0x2614
|
|
481
|
+
|| x === 0x2615
|
|
482
|
+
|| x >= 0x2630 && x <= 0x2637
|
|
483
|
+
|| x >= 0x2648 && x <= 0x2653
|
|
484
|
+
|| x === 0x267F
|
|
485
|
+
|| x >= 0x268A && x <= 0x268F
|
|
486
|
+
|| x === 0x2693
|
|
487
|
+
|| x === 0x26A1
|
|
488
|
+
|| x === 0x26AA
|
|
489
|
+
|| x === 0x26AB
|
|
490
|
+
|| x === 0x26BD
|
|
491
|
+
|| x === 0x26BE
|
|
492
|
+
|| x === 0x26C4
|
|
493
|
+
|| x === 0x26C5
|
|
494
|
+
|| x === 0x26CE
|
|
495
|
+
|| x === 0x26D4
|
|
496
|
+
|| x === 0x26EA
|
|
497
|
+
|| x === 0x26F2
|
|
498
|
+
|| x === 0x26F3
|
|
499
|
+
|| x === 0x26F5
|
|
500
|
+
|| x === 0x26FA
|
|
501
|
+
|| x === 0x26FD
|
|
502
|
+
|| x === 0x2705
|
|
503
|
+
|| x === 0x270A
|
|
504
|
+
|| x === 0x270B
|
|
505
|
+
|| x === 0x2728
|
|
506
|
+
|| x === 0x274C
|
|
507
|
+
|| x === 0x274E
|
|
508
|
+
|| x >= 0x2753 && x <= 0x2755
|
|
509
|
+
|| x === 0x2757
|
|
510
|
+
|| x >= 0x2795 && x <= 0x2797
|
|
511
|
+
|| x === 0x27B0
|
|
512
|
+
|| x === 0x27BF
|
|
513
|
+
|| x === 0x2B1B
|
|
514
|
+
|| x === 0x2B1C
|
|
515
|
+
|| x === 0x2B50
|
|
516
|
+
|| x === 0x2B55
|
|
517
|
+
|| x >= 0x2E80 && x <= 0x2E99
|
|
518
|
+
|| x >= 0x2E9B && x <= 0x2EF3
|
|
519
|
+
|| x >= 0x2F00 && x <= 0x2FD5
|
|
520
|
+
|| x >= 0x2FF0 && x <= 0x2FFF
|
|
521
|
+
|| x >= 0x3001 && x <= 0x303E
|
|
522
|
+
|| x >= 0x3041 && x <= 0x3096
|
|
523
|
+
|| x >= 0x3099 && x <= 0x30FF
|
|
524
|
+
|| x >= 0x3105 && x <= 0x312F
|
|
525
|
+
|| x >= 0x3131 && x <= 0x318E
|
|
526
|
+
|| x >= 0x3190 && x <= 0x31E5
|
|
527
|
+
|| x >= 0x31EF && x <= 0x321E
|
|
528
|
+
|| x >= 0x3220 && x <= 0x3247
|
|
529
|
+
|| x >= 0x3250 && x <= 0xA48C
|
|
530
|
+
|| x >= 0xA490 && x <= 0xA4C6
|
|
531
|
+
|| x >= 0xA960 && x <= 0xA97C
|
|
532
|
+
|| x >= 0xAC00 && x <= 0xD7A3
|
|
533
|
+
|| x >= 0xF900 && x <= 0xFAFF
|
|
534
|
+
|| x >= 0xFE10 && x <= 0xFE19
|
|
535
|
+
|| x >= 0xFE30 && x <= 0xFE52
|
|
536
|
+
|| x >= 0xFE54 && x <= 0xFE66
|
|
537
|
+
|| x >= 0xFE68 && x <= 0xFE6B
|
|
538
|
+
|| x >= 0x16FE0 && x <= 0x16FE4
|
|
539
|
+
|| x === 0x16FF0
|
|
540
|
+
|| x === 0x16FF1
|
|
541
|
+
|| x >= 0x17000 && x <= 0x187F7
|
|
542
|
+
|| x >= 0x18800 && x <= 0x18CD5
|
|
543
|
+
|| x >= 0x18CFF && x <= 0x18D08
|
|
544
|
+
|| x >= 0x1AFF0 && x <= 0x1AFF3
|
|
545
|
+
|| x >= 0x1AFF5 && x <= 0x1AFFB
|
|
546
|
+
|| x === 0x1AFFD
|
|
547
|
+
|| x === 0x1AFFE
|
|
548
|
+
|| x >= 0x1B000 && x <= 0x1B122
|
|
549
|
+
|| x === 0x1B132
|
|
550
|
+
|| x >= 0x1B150 && x <= 0x1B152
|
|
551
|
+
|| x === 0x1B155
|
|
552
|
+
|| x >= 0x1B164 && x <= 0x1B167
|
|
553
|
+
|| x >= 0x1B170 && x <= 0x1B2FB
|
|
554
|
+
|| x >= 0x1D300 && x <= 0x1D356
|
|
555
|
+
|| x >= 0x1D360 && x <= 0x1D376
|
|
556
|
+
|| x === 0x1F004
|
|
557
|
+
|| x === 0x1F0CF
|
|
558
|
+
|| x === 0x1F18E
|
|
559
|
+
|| x >= 0x1F191 && x <= 0x1F19A
|
|
560
|
+
|| x >= 0x1F200 && x <= 0x1F202
|
|
561
|
+
|| x >= 0x1F210 && x <= 0x1F23B
|
|
562
|
+
|| x >= 0x1F240 && x <= 0x1F248
|
|
563
|
+
|| x === 0x1F250
|
|
564
|
+
|| x === 0x1F251
|
|
565
|
+
|| x >= 0x1F260 && x <= 0x1F265
|
|
566
|
+
|| x >= 0x1F300 && x <= 0x1F320
|
|
567
|
+
|| x >= 0x1F32D && x <= 0x1F335
|
|
568
|
+
|| x >= 0x1F337 && x <= 0x1F37C
|
|
569
|
+
|| x >= 0x1F37E && x <= 0x1F393
|
|
570
|
+
|| x >= 0x1F3A0 && x <= 0x1F3CA
|
|
571
|
+
|| x >= 0x1F3CF && x <= 0x1F3D3
|
|
572
|
+
|| x >= 0x1F3E0 && x <= 0x1F3F0
|
|
573
|
+
|| x === 0x1F3F4
|
|
574
|
+
|| x >= 0x1F3F8 && x <= 0x1F43E
|
|
575
|
+
|| x === 0x1F440
|
|
576
|
+
|| x >= 0x1F442 && x <= 0x1F4FC
|
|
577
|
+
|| x >= 0x1F4FF && x <= 0x1F53D
|
|
578
|
+
|| x >= 0x1F54B && x <= 0x1F54E
|
|
579
|
+
|| x >= 0x1F550 && x <= 0x1F567
|
|
580
|
+
|| x === 0x1F57A
|
|
581
|
+
|| x === 0x1F595
|
|
582
|
+
|| x === 0x1F596
|
|
583
|
+
|| x === 0x1F5A4
|
|
584
|
+
|| x >= 0x1F5FB && x <= 0x1F64F
|
|
585
|
+
|| x >= 0x1F680 && x <= 0x1F6C5
|
|
586
|
+
|| x === 0x1F6CC
|
|
587
|
+
|| x >= 0x1F6D0 && x <= 0x1F6D2
|
|
588
|
+
|| x >= 0x1F6D5 && x <= 0x1F6D7
|
|
589
|
+
|| x >= 0x1F6DC && x <= 0x1F6DF
|
|
590
|
+
|| x === 0x1F6EB
|
|
591
|
+
|| x === 0x1F6EC
|
|
592
|
+
|| x >= 0x1F6F4 && x <= 0x1F6FC
|
|
593
|
+
|| x >= 0x1F7E0 && x <= 0x1F7EB
|
|
594
|
+
|| x === 0x1F7F0
|
|
595
|
+
|| x >= 0x1F90C && x <= 0x1F93A
|
|
596
|
+
|| x >= 0x1F93C && x <= 0x1F945
|
|
597
|
+
|| x >= 0x1F947 && x <= 0x1F9FF
|
|
598
|
+
|| x >= 0x1FA70 && x <= 0x1FA7C
|
|
599
|
+
|| x >= 0x1FA80 && x <= 0x1FA89
|
|
600
|
+
|| x >= 0x1FA8F && x <= 0x1FAC6
|
|
601
|
+
|| x >= 0x1FACE && x <= 0x1FADC
|
|
602
|
+
|| x >= 0x1FADF && x <= 0x1FAE9
|
|
603
|
+
|| x >= 0x1FAF0 && x <= 0x1FAF8
|
|
604
|
+
|| x >= 0x20000 && x <= 0x2FFFD
|
|
605
|
+
|| x >= 0x30000 && x <= 0x3FFFD;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
function validate(codePoint) {
|
|
609
|
+
if (!Number.isSafeInteger(codePoint)) {
|
|
610
|
+
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
function eastAsianWidth(codePoint, {ambiguousAsWide = false} = {}) {
|
|
615
|
+
validate(codePoint);
|
|
616
|
+
|
|
617
|
+
if (
|
|
618
|
+
isFullWidth(codePoint)
|
|
619
|
+
|| isWide(codePoint)
|
|
620
|
+
|| (ambiguousAsWide && isAmbiguous(codePoint))
|
|
621
|
+
) {
|
|
622
|
+
return 2;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
return 1;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/* globals WorkerGlobalScope, DedicatedWorkerGlobalScope, SharedWorkerGlobalScope, ServiceWorkerGlobalScope */
|
|
629
|
+
|
|
630
|
+
const isBrowser = globalThis.window?.document !== undefined;
|
|
631
|
+
|
|
632
|
+
globalThis.process?.versions?.node !== undefined;
|
|
633
|
+
|
|
634
|
+
globalThis.process?.versions?.bun !== undefined;
|
|
635
|
+
|
|
636
|
+
globalThis.Deno?.version?.deno !== undefined;
|
|
637
|
+
|
|
638
|
+
globalThis.process?.versions?.electron !== undefined;
|
|
639
|
+
|
|
640
|
+
globalThis.navigator?.userAgent?.includes('jsdom') === true;
|
|
641
|
+
|
|
642
|
+
typeof WorkerGlobalScope !== 'undefined' && globalThis instanceof WorkerGlobalScope;
|
|
643
|
+
|
|
644
|
+
typeof DedicatedWorkerGlobalScope !== 'undefined' && globalThis instanceof DedicatedWorkerGlobalScope;
|
|
645
|
+
|
|
646
|
+
typeof SharedWorkerGlobalScope !== 'undefined' && globalThis instanceof SharedWorkerGlobalScope;
|
|
647
|
+
|
|
648
|
+
typeof ServiceWorkerGlobalScope !== 'undefined' && globalThis instanceof ServiceWorkerGlobalScope;
|
|
649
|
+
|
|
650
|
+
// Note: I'm intentionally not DRYing up the other variables to keep them "lazy".
|
|
651
|
+
const platform = globalThis.navigator?.userAgentData?.platform;
|
|
652
|
+
|
|
653
|
+
platform === 'macOS'
|
|
654
|
+
|| globalThis.navigator?.platform === 'MacIntel' // Even on Apple silicon Macs.
|
|
655
|
+
|| globalThis.navigator?.userAgent?.includes(' Mac ') === true
|
|
656
|
+
|| globalThis.process?.platform === 'darwin';
|
|
657
|
+
|
|
658
|
+
platform === 'Windows'
|
|
659
|
+
|| globalThis.navigator?.platform === 'Win32'
|
|
660
|
+
|| globalThis.process?.platform === 'win32';
|
|
661
|
+
|
|
662
|
+
platform === 'Linux'
|
|
663
|
+
|| globalThis.navigator?.platform?.startsWith('Linux') === true
|
|
664
|
+
|| globalThis.navigator?.userAgent?.includes(' Linux ') === true
|
|
665
|
+
|| globalThis.process?.platform === 'linux';
|
|
666
|
+
|
|
667
|
+
platform === 'Android'
|
|
668
|
+
|| globalThis.navigator?.platform === 'Android'
|
|
669
|
+
|| globalThis.navigator?.userAgent?.includes(' Android ') === true
|
|
670
|
+
|| globalThis.process?.platform === 'android';
|
|
671
|
+
|
|
672
|
+
const ESC = '\u001B[';
|
|
673
|
+
|
|
674
|
+
!isBrowser && process.env.TERM_PROGRAM === 'Apple_Terminal';
|
|
675
|
+
const isWindows = !isBrowser && process.platform === 'win32';
|
|
676
|
+
|
|
677
|
+
isBrowser ? () => {
|
|
678
|
+
throw new Error('`process.cwd()` only works in Node.js, not the browser.');
|
|
679
|
+
} : process.cwd;
|
|
680
|
+
|
|
681
|
+
const cursorUp = (count = 1) => ESC + count + 'A';
|
|
682
|
+
|
|
683
|
+
const cursorLeft = ESC + 'G';
|
|
684
|
+
|
|
685
|
+
const eraseLines = count => {
|
|
686
|
+
let clear = '';
|
|
687
|
+
|
|
688
|
+
for (let i = 0; i < count; i++) {
|
|
689
|
+
clear += eraseLine + (i < count - 1 ? cursorUp() : '');
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
if (count) {
|
|
693
|
+
clear += cursorLeft;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
return clear;
|
|
697
|
+
};
|
|
698
|
+
const eraseLine = ESC + '2K';
|
|
699
|
+
const eraseScreen = ESC + '2J';
|
|
700
|
+
|
|
701
|
+
const clearTerminal = isWindows
|
|
702
|
+
? `${eraseScreen}${ESC}0f`
|
|
703
|
+
// 1. Erases the screen (Only done in case `2` is not supported)
|
|
704
|
+
// 2. Erases the whole screen including scrollback buffer
|
|
705
|
+
// 3. Moves cursor to the top-left position
|
|
706
|
+
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
|
707
|
+
: `${eraseScreen}${ESC}3J${ESC}H`;
|
|
708
|
+
|
|
709
|
+
export { clearTerminal, createSupportsColor, eastAsianWidth, emojiRegex, eraseLines, isUnicodeSupported, stripAnsi };
|