@jsenv/plugin-supervisor 1.4.4 → 1.4.6
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 +115 -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,41 @@ 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 !== "false") {
|
|
247
|
-
ANSI.supported = true;
|
|
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
|
+
});
|
|
249
225
|
function isUnicodeSupported() {
|
|
250
226
|
if (process$1.platform !== 'win32') {
|
|
251
227
|
return process$1.env.TERM !== 'linux'; // Linux console (kernel)
|
|
@@ -258,54 +234,64 @@ function isUnicodeSupported() {
|
|
|
258
234
|
|
|
259
235
|
// see also https://github.com/sindresorhus/figures
|
|
260
236
|
|
|
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
|
-
|
|
237
|
+
const createUnicode = ({
|
|
238
|
+
supported,
|
|
239
|
+
ANSI
|
|
240
|
+
}) => {
|
|
241
|
+
const UNICODE = {
|
|
242
|
+
supported,
|
|
243
|
+
get COMMAND_RAW() {
|
|
244
|
+
return UNICODE.supported ? "\u276F" : ">";
|
|
245
|
+
},
|
|
246
|
+
get OK_RAW() {
|
|
247
|
+
return UNICODE.supported ? "\u2714" : "\u221A";
|
|
248
|
+
},
|
|
249
|
+
get FAILURE_RAW() {
|
|
250
|
+
return UNICODE.supported ? "\u2716" : "\xD7";
|
|
251
|
+
},
|
|
252
|
+
get DEBUG_RAW() {
|
|
253
|
+
return UNICODE.supported ? "\u25C6" : "\u2666";
|
|
254
|
+
},
|
|
255
|
+
get INFO_RAW() {
|
|
256
|
+
return UNICODE.supported ? "\u2139" : "i";
|
|
257
|
+
},
|
|
258
|
+
get WARNING_RAW() {
|
|
259
|
+
return UNICODE.supported ? "\u26A0" : "\u203C";
|
|
260
|
+
},
|
|
261
|
+
get CIRCLE_CROSS_RAW() {
|
|
262
|
+
return UNICODE.supported ? "\u24E7" : "(\xD7)";
|
|
263
|
+
},
|
|
264
|
+
get COMMAND() {
|
|
265
|
+
return ANSI.color(UNICODE.COMMAND_RAW, ANSI.GREY); // ANSI_MAGENTA)
|
|
266
|
+
},
|
|
267
|
+
get OK() {
|
|
268
|
+
return ANSI.color(UNICODE.OK_RAW, ANSI.GREEN);
|
|
269
|
+
},
|
|
270
|
+
get FAILURE() {
|
|
271
|
+
return ANSI.color(UNICODE.FAILURE_RAW, ANSI.RED);
|
|
272
|
+
},
|
|
273
|
+
get DEBUG() {
|
|
274
|
+
return ANSI.color(UNICODE.DEBUG_RAW, ANSI.GREY);
|
|
275
|
+
},
|
|
276
|
+
get INFO() {
|
|
277
|
+
return ANSI.color(UNICODE.INFO_RAW, ANSI.BLUE);
|
|
278
|
+
},
|
|
279
|
+
get WARNING() {
|
|
280
|
+
return ANSI.color(UNICODE.WARNING_RAW, ANSI.YELLOW);
|
|
281
|
+
},
|
|
282
|
+
get CIRCLE_CROSS() {
|
|
283
|
+
return ANSI.color(UNICODE.CIRCLE_CROSS_RAW, ANSI.RED);
|
|
284
|
+
},
|
|
285
|
+
get ELLIPSIS() {
|
|
286
|
+
return UNICODE.supported ? "\u2026" : "...";
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
return UNICODE;
|
|
308
290
|
};
|
|
291
|
+
createUnicode({
|
|
292
|
+
supported: isUnicodeSupported(),
|
|
293
|
+
ANSI
|
|
294
|
+
});
|
|
309
295
|
const formatDefault = v => v;
|
|
310
296
|
const generateContentFrame = ({
|
|
311
297
|
content,
|
|
@@ -454,6 +440,32 @@ const fillLeft = (value, biggestValue, char = " ") => {
|
|
|
454
440
|
return padded;
|
|
455
441
|
};
|
|
456
442
|
|
|
443
|
+
/* globals WorkerGlobalScope, DedicatedWorkerGlobalScope, SharedWorkerGlobalScope, ServiceWorkerGlobalScope */
|
|
444
|
+
|
|
445
|
+
const isBrowser = globalThis.window?.document !== undefined;
|
|
446
|
+
globalThis.process?.versions?.node !== undefined;
|
|
447
|
+
globalThis.process?.versions?.bun !== undefined;
|
|
448
|
+
globalThis.Deno?.version?.deno !== undefined;
|
|
449
|
+
globalThis.process?.versions?.electron !== undefined;
|
|
450
|
+
globalThis.navigator?.userAgent?.includes('jsdom') === true;
|
|
451
|
+
typeof WorkerGlobalScope !== 'undefined' && globalThis instanceof WorkerGlobalScope;
|
|
452
|
+
typeof DedicatedWorkerGlobalScope !== 'undefined' && globalThis instanceof DedicatedWorkerGlobalScope;
|
|
453
|
+
typeof SharedWorkerGlobalScope !== 'undefined' && globalThis instanceof SharedWorkerGlobalScope;
|
|
454
|
+
typeof ServiceWorkerGlobalScope !== 'undefined' && globalThis instanceof ServiceWorkerGlobalScope;
|
|
455
|
+
|
|
456
|
+
// Note: I'm intentionally not DRYing up the other variables to keep them "lazy".
|
|
457
|
+
const platform = globalThis.navigator?.userAgentData?.platform;
|
|
458
|
+
platform === 'macOS' || globalThis.navigator?.platform === 'MacIntel' // Even on Apple silicon Macs.
|
|
459
|
+
|| globalThis.navigator?.userAgent?.includes(' Mac ') === true || globalThis.process?.platform === 'darwin';
|
|
460
|
+
platform === 'Windows' || globalThis.navigator?.platform === 'Win32' || globalThis.process?.platform === 'win32';
|
|
461
|
+
platform === 'Linux' || globalThis.navigator?.platform?.startsWith('Linux') === true || globalThis.navigator?.userAgent?.includes(' Linux ') === true || globalThis.process?.platform === 'linux';
|
|
462
|
+
platform === 'Android' || globalThis.navigator?.platform === 'Android' || globalThis.navigator?.userAgent?.includes(' Android ') === true || globalThis.process?.platform === 'android';
|
|
463
|
+
!isBrowser && process$1.env.TERM_PROGRAM === 'Apple_Terminal';
|
|
464
|
+
!isBrowser && process$1.platform === 'win32';
|
|
465
|
+
isBrowser ? () => {
|
|
466
|
+
throw new Error('`process.cwd()` only works in Node.js, not the browser.');
|
|
467
|
+
} : process$1.cwd;
|
|
468
|
+
|
|
457
469
|
const getCommonPathname = (pathname, otherPathname) => {
|
|
458
470
|
if (pathname === otherPathname) {
|
|
459
471
|
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.6",
|
|
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.6",
|
|
30
|
+
"@jsenv/urls": "2.2.6",
|
|
31
|
+
"@jsenv/sourcemap": "1.2.9",
|
|
32
32
|
"launch-editor": "2.8.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|