@jsenv/plugin-supervisor 1.4.4 → 1.4.5
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/jsenv_plugin_supervisor.js +119 -103
- package/package.json +4 -4
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
import "string-width";
|
|
4
3
|
import process$1 from "node:process";
|
|
5
4
|
import os from "node:os";
|
|
6
5
|
import tty from "node:tty";
|
|
6
|
+
import "string-width";
|
|
7
7
|
import { applyBabelPlugins, parseHtml, visitHtmlNodes, analyzeScriptNode, getHtmlNodeAttribute, getHtmlNodeText, injectHtmlNodeAsEarlyAsPossible, createHtmlNode, stringifyHtmlAst, getHtmlNodePosition, getUrlForContentInsideHtml, setHtmlNodeText, setHtmlNodeAttributes } from "@jsenv/ast";
|
|
8
8
|
|
|
9
9
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
@@ -48,32 +48,6 @@ const getOriginalPosition = ({
|
|
|
48
48
|
return originalPosition;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
/* globals WorkerGlobalScope, DedicatedWorkerGlobalScope, SharedWorkerGlobalScope, ServiceWorkerGlobalScope */
|
|
52
|
-
|
|
53
|
-
const isBrowser = globalThis.window?.document !== undefined;
|
|
54
|
-
globalThis.process?.versions?.node !== undefined;
|
|
55
|
-
globalThis.process?.versions?.bun !== undefined;
|
|
56
|
-
globalThis.Deno?.version?.deno !== undefined;
|
|
57
|
-
globalThis.process?.versions?.electron !== undefined;
|
|
58
|
-
globalThis.navigator?.userAgent?.includes('jsdom') === true;
|
|
59
|
-
typeof WorkerGlobalScope !== 'undefined' && globalThis instanceof WorkerGlobalScope;
|
|
60
|
-
typeof DedicatedWorkerGlobalScope !== 'undefined' && globalThis instanceof DedicatedWorkerGlobalScope;
|
|
61
|
-
typeof SharedWorkerGlobalScope !== 'undefined' && globalThis instanceof SharedWorkerGlobalScope;
|
|
62
|
-
typeof ServiceWorkerGlobalScope !== 'undefined' && globalThis instanceof ServiceWorkerGlobalScope;
|
|
63
|
-
|
|
64
|
-
// Note: I'm intentionally not DRYing up the other variables to keep them "lazy".
|
|
65
|
-
const platform = globalThis.navigator?.userAgentData?.platform;
|
|
66
|
-
platform === 'macOS' || globalThis.navigator?.platform === 'MacIntel' // Even on Apple silicon Macs.
|
|
67
|
-
|| globalThis.navigator?.userAgent?.includes(' Mac ') === true || globalThis.process?.platform === 'darwin';
|
|
68
|
-
platform === 'Windows' || globalThis.navigator?.platform === 'Win32' || globalThis.process?.platform === 'win32';
|
|
69
|
-
platform === 'Linux' || globalThis.navigator?.platform?.startsWith('Linux') === true || globalThis.navigator?.userAgent?.includes(' Linux ') === true || globalThis.process?.platform === 'linux';
|
|
70
|
-
platform === 'Android' || globalThis.navigator?.platform === 'Android' || globalThis.navigator?.userAgent?.includes(' Android ') === true || globalThis.process?.platform === 'android';
|
|
71
|
-
!isBrowser && process$1.env.TERM_PROGRAM === 'Apple_Terminal';
|
|
72
|
-
!isBrowser && process$1.platform === 'win32';
|
|
73
|
-
isBrowser ? () => {
|
|
74
|
-
throw new Error('`process.cwd()` only works in Node.js, not the browser.');
|
|
75
|
-
} : process$1.cwd;
|
|
76
|
-
|
|
77
51
|
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
|
78
52
|
/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
|
|
79
53
|
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) {
|
|
@@ -213,39 +187,45 @@ function createSupportsColor(stream, options = {}) {
|
|
|
213
187
|
isTTY: tty.isatty(2)
|
|
214
188
|
})
|
|
215
189
|
});
|
|
216
|
-
|
|
190
|
+
|
|
217
191
|
// https://github.com/Marak/colors.js/blob/master/lib/styles.js
|
|
218
192
|
// https://stackoverflow.com/a/75985833/2634179
|
|
219
193
|
const RESET = "\x1b[0m";
|
|
220
|
-
const
|
|
221
|
-
supported
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
194
|
+
const createAnsi = ({
|
|
195
|
+
supported
|
|
196
|
+
}) => {
|
|
197
|
+
const ANSI = {
|
|
198
|
+
supported,
|
|
199
|
+
RED: "\x1b[31m",
|
|
200
|
+
GREEN: "\x1b[32m",
|
|
201
|
+
YELLOW: "\x1b[33m",
|
|
202
|
+
BLUE: "\x1b[34m",
|
|
203
|
+
MAGENTA: "\x1b[35m",
|
|
204
|
+
CYAN: "\x1b[36m",
|
|
205
|
+
GREY: "\x1b[90m",
|
|
206
|
+
color: (text, ANSI_COLOR) => {
|
|
207
|
+
return ANSI.supported && ANSI_COLOR ? "".concat(ANSI_COLOR).concat(text).concat(RESET) : text;
|
|
208
|
+
},
|
|
209
|
+
BOLD: "\x1b[1m",
|
|
210
|
+
UNDERLINE: "\x1b[4m",
|
|
211
|
+
STRIKE: "\x1b[9m",
|
|
212
|
+
effect: (text, ANSI_EFFECT) => {
|
|
213
|
+
return ANSI.supported && ANSI_EFFECT ? "".concat(ANSI_EFFECT).concat(text).concat(RESET) : text;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
return ANSI;
|
|
238
217
|
};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
//
|
|
244
|
-
|
|
245
|
-
//
|
|
246
|
-
process.env.FORCE_COLOR
|
|
247
|
-
|
|
248
|
-
|
|
218
|
+
const processSupportsBasicColor = createSupportsColor(process.stdout).hasBasic;
|
|
219
|
+
const ANSI = createAnsi({
|
|
220
|
+
supported: processSupportsBasicColor ||
|
|
221
|
+
// GitHub workflow does support ANSI but "supports-color" returns false
|
|
222
|
+
// because stream.isTTY returns false, see https://github.com/actions/runner/issues/241
|
|
223
|
+
process.env.GITHUB_WORKFLOW &&
|
|
224
|
+
// Check on FORCE_COLOR is to ensure it is prio over GitHub workflow check
|
|
225
|
+
// in unit test we use process.env.FORCE_COLOR = 'false' to fake
|
|
226
|
+
// that colors are not supported. Let it have priority
|
|
227
|
+
process.env.FORCE_COLOR !== "false"
|
|
228
|
+
});
|
|
249
229
|
function isUnicodeSupported() {
|
|
250
230
|
if (process$1.platform !== 'win32') {
|
|
251
231
|
return process$1.env.TERM !== 'linux'; // Linux console (kernel)
|
|
@@ -258,54 +238,64 @@ function isUnicodeSupported() {
|
|
|
258
238
|
|
|
259
239
|
// see also https://github.com/sindresorhus/figures
|
|
260
240
|
|
|
261
|
-
const
|
|
262
|
-
supported
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
241
|
+
const createUnicode = ({
|
|
242
|
+
supported,
|
|
243
|
+
ANSI
|
|
244
|
+
}) => {
|
|
245
|
+
const UNICODE = {
|
|
246
|
+
supported,
|
|
247
|
+
get COMMAND_RAW() {
|
|
248
|
+
return UNICODE.supported ? "\u276F" : ">";
|
|
249
|
+
},
|
|
250
|
+
get OK_RAW() {
|
|
251
|
+
return UNICODE.supported ? "\u2714" : "\u221A";
|
|
252
|
+
},
|
|
253
|
+
get FAILURE_RAW() {
|
|
254
|
+
return UNICODE.supported ? "\u2716" : "\xD7";
|
|
255
|
+
},
|
|
256
|
+
get DEBUG_RAW() {
|
|
257
|
+
return UNICODE.supported ? "\u25C6" : "\u2666";
|
|
258
|
+
},
|
|
259
|
+
get INFO_RAW() {
|
|
260
|
+
return UNICODE.supported ? "\u2139" : "i";
|
|
261
|
+
},
|
|
262
|
+
get WARNING_RAW() {
|
|
263
|
+
return UNICODE.supported ? "\u26A0" : "\u203C";
|
|
264
|
+
},
|
|
265
|
+
get CIRCLE_CROSS_RAW() {
|
|
266
|
+
return UNICODE.supported ? "\u24E7" : "(\xD7)";
|
|
267
|
+
},
|
|
268
|
+
get COMMAND() {
|
|
269
|
+
return ANSI.color(UNICODE.COMMAND_RAW, ANSI.GREY); // ANSI_MAGENTA)
|
|
270
|
+
},
|
|
271
|
+
get OK() {
|
|
272
|
+
return ANSI.color(UNICODE.OK_RAW, ANSI.GREEN);
|
|
273
|
+
},
|
|
274
|
+
get FAILURE() {
|
|
275
|
+
return ANSI.color(UNICODE.FAILURE_RAW, ANSI.RED);
|
|
276
|
+
},
|
|
277
|
+
get DEBUG() {
|
|
278
|
+
return ANSI.color(UNICODE.DEBUG_RAW, ANSI.GREY);
|
|
279
|
+
},
|
|
280
|
+
get INFO() {
|
|
281
|
+
return ANSI.color(UNICODE.INFO_RAW, ANSI.BLUE);
|
|
282
|
+
},
|
|
283
|
+
get WARNING() {
|
|
284
|
+
return ANSI.color(UNICODE.WARNING_RAW, ANSI.YELLOW);
|
|
285
|
+
},
|
|
286
|
+
get CIRCLE_CROSS() {
|
|
287
|
+
return ANSI.color(UNICODE.CIRCLE_CROSS_RAW, ANSI.RED);
|
|
288
|
+
},
|
|
289
|
+
get ELLIPSIS() {
|
|
290
|
+
return UNICODE.supported ? "\u2026" : "...";
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
return UNICODE;
|
|
308
294
|
};
|
|
295
|
+
createUnicode({
|
|
296
|
+
supported: isUnicodeSupported(),
|
|
297
|
+
ANSI
|
|
298
|
+
});
|
|
309
299
|
const formatDefault = v => v;
|
|
310
300
|
const generateContentFrame = ({
|
|
311
301
|
content,
|
|
@@ -454,6 +444,32 @@ const fillLeft = (value, biggestValue, char = " ") => {
|
|
|
454
444
|
return padded;
|
|
455
445
|
};
|
|
456
446
|
|
|
447
|
+
/* globals WorkerGlobalScope, DedicatedWorkerGlobalScope, SharedWorkerGlobalScope, ServiceWorkerGlobalScope */
|
|
448
|
+
|
|
449
|
+
const isBrowser = globalThis.window?.document !== undefined;
|
|
450
|
+
globalThis.process?.versions?.node !== undefined;
|
|
451
|
+
globalThis.process?.versions?.bun !== undefined;
|
|
452
|
+
globalThis.Deno?.version?.deno !== undefined;
|
|
453
|
+
globalThis.process?.versions?.electron !== undefined;
|
|
454
|
+
globalThis.navigator?.userAgent?.includes('jsdom') === true;
|
|
455
|
+
typeof WorkerGlobalScope !== 'undefined' && globalThis instanceof WorkerGlobalScope;
|
|
456
|
+
typeof DedicatedWorkerGlobalScope !== 'undefined' && globalThis instanceof DedicatedWorkerGlobalScope;
|
|
457
|
+
typeof SharedWorkerGlobalScope !== 'undefined' && globalThis instanceof SharedWorkerGlobalScope;
|
|
458
|
+
typeof ServiceWorkerGlobalScope !== 'undefined' && globalThis instanceof ServiceWorkerGlobalScope;
|
|
459
|
+
|
|
460
|
+
// Note: I'm intentionally not DRYing up the other variables to keep them "lazy".
|
|
461
|
+
const platform = globalThis.navigator?.userAgentData?.platform;
|
|
462
|
+
platform === 'macOS' || globalThis.navigator?.platform === 'MacIntel' // Even on Apple silicon Macs.
|
|
463
|
+
|| globalThis.navigator?.userAgent?.includes(' Mac ') === true || globalThis.process?.platform === 'darwin';
|
|
464
|
+
platform === 'Windows' || globalThis.navigator?.platform === 'Win32' || globalThis.process?.platform === 'win32';
|
|
465
|
+
platform === 'Linux' || globalThis.navigator?.platform?.startsWith('Linux') === true || globalThis.navigator?.userAgent?.includes(' Linux ') === true || globalThis.process?.platform === 'linux';
|
|
466
|
+
platform === 'Android' || globalThis.navigator?.platform === 'Android' || globalThis.navigator?.userAgent?.includes(' Android ') === true || globalThis.process?.platform === 'android';
|
|
467
|
+
!isBrowser && process$1.env.TERM_PROGRAM === 'Apple_Terminal';
|
|
468
|
+
!isBrowser && process$1.platform === 'win32';
|
|
469
|
+
isBrowser ? () => {
|
|
470
|
+
throw new Error('`process.cwd()` only works in Node.js, not the browser.');
|
|
471
|
+
} : process$1.cwd;
|
|
472
|
+
|
|
457
473
|
const getCommonPathname = (pathname, otherPathname) => {
|
|
458
474
|
if (pathname === otherPathname) {
|
|
459
475
|
return pathname;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/plugin-supervisor",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"/dist/"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@jsenv/ast": "6.0.
|
|
30
|
-
"@jsenv/urls": "2.2.
|
|
31
|
-
"@jsenv/sourcemap": "1.2.
|
|
29
|
+
"@jsenv/ast": "6.0.5",
|
|
30
|
+
"@jsenv/urls": "2.2.5",
|
|
31
|
+
"@jsenv/sourcemap": "1.2.8",
|
|
32
32
|
"launch-editor": "2.8.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|