@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.
@@ -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
- const processSupportsBasicColor = createSupportsColor(process.stdout).hasBasic;
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 ANSI = {
221
- supported: processSupportsBasicColor,
222
- RED: "\x1b[31m",
223
- GREEN: "\x1b[32m",
224
- YELLOW: "\x1b[33m",
225
- BLUE: "\x1b[34m",
226
- MAGENTA: "\x1b[35m",
227
- CYAN: "\x1b[36m",
228
- GREY: "\x1b[90m",
229
- color: (text, ANSI_COLOR) => {
230
- return ANSI.supported && ANSI_COLOR ? "".concat(ANSI_COLOR).concat(text).concat(RESET) : text;
231
- },
232
- BOLD: "\x1b[1m",
233
- UNDERLINE: "\x1b[4m",
234
- STRIKE: "\x1b[9m",
235
- effect: (text, ANSI_EFFECT) => {
236
- return ANSI.supported && ANSI_EFFECT ? "".concat(ANSI_EFFECT).concat(text).concat(RESET) : text;
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
- // GitHub workflow does support ANSI but "supports-color" returns false
241
- // because stream.isTTY returns false, see https://github.com/actions/runner/issues/241
242
- if (process.env.GITHUB_WORKFLOW &&
243
- // Check on FORCE_COLOR is to ensure it is prio over GitHub workflow check
244
- // in unit test we use process.env.FORCE_COLOR = 'false' to fake
245
- // that colors are not supported. Let it have priority
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 UNICODE = {
262
- supported: isUnicodeSupported(),
263
- get COMMAND_RAW() {
264
- return UNICODE.supported ? "\u276F" : ">";
265
- },
266
- get OK_RAW() {
267
- return UNICODE.supported ? "\u2714" : "\u221A";
268
- },
269
- get FAILURE_RAW() {
270
- return UNICODE.supported ? "\u2716" : "\xD7";
271
- },
272
- get DEBUG_RAW() {
273
- return UNICODE.supported ? "\u25C6" : "\u2666";
274
- },
275
- get INFO_RAW() {
276
- return UNICODE.supported ? "\u2139" : "i";
277
- },
278
- get WARNING_RAW() {
279
- return UNICODE.supported ? "\u26A0" : "\u203C";
280
- },
281
- get CIRCLE_CROSS_RAW() {
282
- return UNICODE.supported ? "\u24E7" : "(\xD7)";
283
- },
284
- get COMMAND() {
285
- return ANSI.color(UNICODE.COMMAND_RAW, ANSI.GREY); // ANSI_MAGENTA)
286
- },
287
- get OK() {
288
- return ANSI.color(UNICODE.OK_RAW, ANSI.GREEN);
289
- },
290
- get FAILURE() {
291
- return ANSI.color(UNICODE.FAILURE_RAW, ANSI.RED);
292
- },
293
- get DEBUG() {
294
- return ANSI.color(UNICODE.DEBUG_RAW, ANSI.GREY);
295
- },
296
- get INFO() {
297
- return ANSI.color(UNICODE.INFO_RAW, ANSI.BLUE);
298
- },
299
- get WARNING() {
300
- return ANSI.color(UNICODE.WARNING_RAW, ANSI.YELLOW);
301
- },
302
- get CIRCLE_CROSS() {
303
- return ANSI.color(UNICODE.CIRCLE_CROSS_RAW, ANSI.RED);
304
- },
305
- get ELLIPSIS() {
306
- return UNICODE.supported ? "\u2026" : "...";
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.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.4",
30
- "@jsenv/urls": "2.2.4",
31
- "@jsenv/sourcemap": "1.2.7",
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": {