@jsenv/plugin-supervisor 1.4.3 → 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.
@@ -642,7 +642,7 @@ window.__supervisor__ = (() => {
642
642
  exception.code = DYNAMIC_IMPORT_EXPORT_MISSING;
643
643
  }
644
644
  // firefox
645
- if (exception.message.startsWith("import not found:") || exception.message.startsWith("ambiguous indirect export:")) {
645
+ if (exception.message.startsWith("import not found:") || exception.message.startsWith("ambiguous indirect export:") || exception.message.includes("doesn't provide an export named:")) {
646
646
  exception.code = DYNAMIC_IMPORT_EXPORT_MISSING;
647
647
  }
648
648
  // safari
@@ -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,14 +48,6 @@ const getOriginalPosition = ({
48
48
  return originalPosition;
49
49
  };
50
50
 
51
- /* global window */
52
- const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
53
- !isBrowser && process$1.env.TERM_PROGRAM === 'Apple_Terminal';
54
- !isBrowser && process$1.platform === 'win32';
55
- isBrowser ? () => {
56
- throw new Error('`process.cwd()` only works in Node.js, not the browser.');
57
- } : process$1.cwd;
58
-
59
51
  // From: https://github.com/sindresorhus/has-flag/blob/main/index.js
60
52
  /// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
61
53
  function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) {
@@ -195,36 +187,45 @@ function createSupportsColor(stream, options = {}) {
195
187
  isTTY: tty.isatty(2)
196
188
  })
197
189
  });
198
- const processSupportsBasicColor = createSupportsColor(process.stdout).hasBasic;
190
+
199
191
  // https://github.com/Marak/colors.js/blob/master/lib/styles.js
200
192
  // https://stackoverflow.com/a/75985833/2634179
201
193
  const RESET = "\x1b[0m";
202
- const ANSI = {
203
- supported: processSupportsBasicColor,
204
- RED: "\x1b[31m",
205
- GREEN: "\x1b[32m",
206
- YELLOW: "\x1b[33m",
207
- BLUE: "\x1b[34m",
208
- MAGENTA: "\x1b[35m",
209
- GREY: "\x1b[90m",
210
- color: (text, ANSI_COLOR) => {
211
- return ANSI.supported ? "".concat(ANSI_COLOR).concat(text).concat(RESET) : text;
212
- },
213
- BOLD: "\x1b[1m",
214
- effect: (text, ANSI_EFFECT) => {
215
- return ANSI.supported ? "".concat(ANSI_EFFECT).concat(text).concat(RESET) : text;
216
- }
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;
217
217
  };
218
-
219
- // GitHub workflow does support ANSI but "supports-color" returns false
220
- // because stream.isTTY returns false, see https://github.com/actions/runner/issues/241
221
- if (process.env.GITHUB_WORKFLOW &&
222
- // Check on FORCE_COLOR is to ensure it is prio over GitHub workflow check
223
- // in unit test we use process.env.FORCE_COLOR = 'false' to fake
224
- // that colors are not supported. Let it have priority
225
- process.env.FORCE_COLOR !== "false") {
226
- ANSI.supported = true;
227
- }
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
+ });
228
229
  function isUnicodeSupported() {
229
230
  if (process$1.platform !== 'win32') {
230
231
  return process$1.env.TERM !== 'linux'; // Linux console (kernel)
@@ -237,51 +238,64 @@ function isUnicodeSupported() {
237
238
 
238
239
  // see also https://github.com/sindresorhus/figures
239
240
 
240
- const UNICODE = {
241
- supported: isUnicodeSupported(),
242
- get COMMAND_RAW() {
243
- return UNICODE.supported ? "\u276F" : ">";
244
- },
245
- get OK_RAW() {
246
- return UNICODE.supported ? "\u2714" : "\u221A";
247
- },
248
- get FAILURE_RAW() {
249
- return UNICODE.supported ? "\u2716" : "\xD7";
250
- },
251
- get DEBUG_RAW() {
252
- return UNICODE.supported ? "\u25C6" : "\u2666";
253
- },
254
- get INFO_RAW() {
255
- return UNICODE.supported ? "\u2139" : "i";
256
- },
257
- get WARNING_RAW() {
258
- return UNICODE.supported ? "\u26A0" : "\u203C";
259
- },
260
- get CIRCLE_CROSS_RAW() {
261
- return UNICODE.supported ? "\u24E7" : "(\xD7)";
262
- },
263
- get COMMAND() {
264
- return ANSI.color(UNICODE.COMMAND_RAW, ANSI.GREY); // ANSI_MAGENTA)
265
- },
266
- get OK() {
267
- return ANSI.color(UNICODE.OK_RAW, ANSI.GREEN);
268
- },
269
- get FAILURE() {
270
- return ANSI.color(UNICODE.FAILURE_RAW, ANSI.RED);
271
- },
272
- get DEBUG() {
273
- return ANSI.color(UNICODE.DEBUG_RAW, ANSI.GREY);
274
- },
275
- get INFO() {
276
- return ANSI.color(UNICODE.INFO_RAW, ANSI.BLUE);
277
- },
278
- get WARNING() {
279
- return ANSI.color(UNICODE.WARNING_RAW, ANSI.YELLOW);
280
- },
281
- get CIRCLE_CROSS() {
282
- return ANSI.color(UNICODE.CIRCLE_CROSS_RAW, ANSI.RED);
283
- }
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;
284
294
  };
295
+ createUnicode({
296
+ supported: isUnicodeSupported(),
297
+ ANSI
298
+ });
285
299
  const formatDefault = v => v;
286
300
  const generateContentFrame = ({
287
301
  content,
@@ -430,6 +444,32 @@ const fillLeft = (value, biggestValue, char = " ") => {
430
444
  return padded;
431
445
  };
432
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
+
433
473
  const getCommonPathname = (pathname, otherPathname) => {
434
474
  if (pathname === otherPathname) {
435
475
  return pathname;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/plugin-supervisor",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,10 +26,10 @@
26
26
  "/dist/"
27
27
  ],
28
28
  "dependencies": {
29
- "@jsenv/ast": "6.0.3",
30
- "@jsenv/urls": "2.2.3",
31
- "@jsenv/sourcemap": "1.2.6",
32
- "launch-editor": "2.6.1"
29
+ "@jsenv/ast": "6.0.5",
30
+ "@jsenv/urls": "2.2.5",
31
+ "@jsenv/sourcemap": "1.2.8",
32
+ "launch-editor": "2.8.0"
33
33
  },
34
34
  "scripts": {
35
35
  "eslint": "npx eslint . --ext=.js,.mjs,.cjs,.html",
@@ -606,7 +606,8 @@ window.__supervisor__ = (() => {
606
606
  // firefox
607
607
  if (
608
608
  exception.message.startsWith("import not found:") ||
609
- exception.message.startsWith("ambiguous indirect export:")
609
+ exception.message.startsWith("ambiguous indirect export:") ||
610
+ exception.message.includes("doesn't provide an export named:")
610
611
  ) {
611
612
  exception.code = DYNAMIC_IMPORT_EXPORT_MISSING;
612
613
  }