@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.
@@ -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
- 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
+ // 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 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
- }
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.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.4",
30
- "@jsenv/urls": "2.2.4",
31
- "@jsenv/sourcemap": "1.2.7",
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": {