@jsenv/core 29.1.7 → 29.1.9

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/main.js CHANGED
@@ -1563,7 +1563,7 @@ const collectFiles = async ({
1563
1563
  });
1564
1564
 
1565
1565
  if (directoryChildNodeStats.isDirectory()) {
1566
- const subDirectoryUrl = `${directoryChildNodeUrl}/`;
1566
+ const subDirectoryUrl = `${decodeURIComponent(directoryChildNodeUrl)}/`;
1567
1567
 
1568
1568
  if (!URL_META.urlChildMayMatch({
1569
1569
  url: subDirectoryUrl,
@@ -1579,7 +1579,7 @@ const collectFiles = async ({
1579
1579
 
1580
1580
  if (directoryChildNodeStats.isFile()) {
1581
1581
  const meta = URL_META.applyAssociations({
1582
- url: directoryChildNodeUrl,
1582
+ url: decodeURIComponent(directoryChildNodeUrl),
1583
1583
  associations
1584
1584
  });
1585
1585
  if (!predicate(meta)) return;
@@ -2540,16 +2540,16 @@ const writeFileSync = (destination, content = "") => {
2540
2540
  }
2541
2541
  };
2542
2542
 
2543
- const LOG_LEVEL_OFF$1 = "off";
2544
- const LOG_LEVEL_DEBUG$1 = "debug";
2545
- const LOG_LEVEL_INFO$1 = "info";
2546
- const LOG_LEVEL_WARN$1 = "warn";
2547
- const LOG_LEVEL_ERROR$1 = "error";
2543
+ const LOG_LEVEL_OFF = "off";
2544
+ const LOG_LEVEL_DEBUG = "debug";
2545
+ const LOG_LEVEL_INFO = "info";
2546
+ const LOG_LEVEL_WARN = "warn";
2547
+ const LOG_LEVEL_ERROR = "error";
2548
2548
 
2549
- const createLogger$1 = ({
2550
- logLevel = LOG_LEVEL_INFO$1
2549
+ const createLogger = ({
2550
+ logLevel = LOG_LEVEL_INFO
2551
2551
  } = {}) => {
2552
- if (logLevel === LOG_LEVEL_DEBUG$1) {
2552
+ if (logLevel === LOG_LEVEL_DEBUG) {
2553
2553
  return {
2554
2554
  level: "debug",
2555
2555
  levels: {
@@ -2558,14 +2558,14 @@ const createLogger$1 = ({
2558
2558
  warn: true,
2559
2559
  error: true
2560
2560
  },
2561
- debug: debug$1,
2562
- info: info$1,
2563
- warn: warn$1,
2564
- error: error$1
2561
+ debug,
2562
+ info,
2563
+ warn,
2564
+ error
2565
2565
  };
2566
2566
  }
2567
2567
 
2568
- if (logLevel === LOG_LEVEL_INFO$1) {
2568
+ if (logLevel === LOG_LEVEL_INFO) {
2569
2569
  return {
2570
2570
  level: "info",
2571
2571
  levels: {
@@ -2574,14 +2574,14 @@ const createLogger$1 = ({
2574
2574
  warn: true,
2575
2575
  error: true
2576
2576
  },
2577
- debug: debugDisabled$1,
2578
- info: info$1,
2579
- warn: warn$1,
2580
- error: error$1
2577
+ debug: debugDisabled,
2578
+ info,
2579
+ warn,
2580
+ error
2581
2581
  };
2582
2582
  }
2583
2583
 
2584
- if (logLevel === LOG_LEVEL_WARN$1) {
2584
+ if (logLevel === LOG_LEVEL_WARN) {
2585
2585
  return {
2586
2586
  level: "warn",
2587
2587
  levels: {
@@ -2590,14 +2590,14 @@ const createLogger$1 = ({
2590
2590
  warn: true,
2591
2591
  error: true
2592
2592
  },
2593
- debug: debugDisabled$1,
2594
- info: infoDisabled$1,
2595
- warn: warn$1,
2596
- error: error$1
2593
+ debug: debugDisabled,
2594
+ info: infoDisabled,
2595
+ warn,
2596
+ error
2597
2597
  };
2598
2598
  }
2599
2599
 
2600
- if (logLevel === LOG_LEVEL_ERROR$1) {
2600
+ if (logLevel === LOG_LEVEL_ERROR) {
2601
2601
  return {
2602
2602
  level: "error",
2603
2603
  levels: {
@@ -2606,14 +2606,14 @@ const createLogger$1 = ({
2606
2606
  warn: false,
2607
2607
  error: true
2608
2608
  },
2609
- debug: debugDisabled$1,
2610
- info: infoDisabled$1,
2611
- warn: warnDisabled$1,
2612
- error: error$1
2609
+ debug: debugDisabled,
2610
+ info: infoDisabled,
2611
+ warn: warnDisabled,
2612
+ error
2613
2613
  };
2614
2614
  }
2615
2615
 
2616
- if (logLevel === LOG_LEVEL_OFF$1) {
2616
+ if (logLevel === LOG_LEVEL_OFF) {
2617
2617
  return {
2618
2618
  level: "off",
2619
2619
  levels: {
@@ -2622,10 +2622,10 @@ const createLogger$1 = ({
2622
2622
  warn: false,
2623
2623
  error: false
2624
2624
  },
2625
- debug: debugDisabled$1,
2626
- info: infoDisabled$1,
2627
- warn: warnDisabled$1,
2628
- error: errorDisabled$1
2625
+ debug: debugDisabled,
2626
+ info: infoDisabled,
2627
+ warn: warnDisabled,
2628
+ error: errorDisabled
2629
2629
  };
2630
2630
  }
2631
2631
 
@@ -2633,30 +2633,30 @@ const createLogger$1 = ({
2633
2633
  --- logLevel ---
2634
2634
  ${logLevel}
2635
2635
  --- allowed log levels ---
2636
- ${LOG_LEVEL_OFF$1}
2637
- ${LOG_LEVEL_ERROR$1}
2638
- ${LOG_LEVEL_WARN$1}
2639
- ${LOG_LEVEL_INFO$1}
2640
- ${LOG_LEVEL_DEBUG$1}`);
2636
+ ${LOG_LEVEL_OFF}
2637
+ ${LOG_LEVEL_ERROR}
2638
+ ${LOG_LEVEL_WARN}
2639
+ ${LOG_LEVEL_INFO}
2640
+ ${LOG_LEVEL_DEBUG}`);
2641
2641
  };
2642
2642
 
2643
- const debug$1 = (...args) => console.debug(...args);
2643
+ const debug = (...args) => console.debug(...args);
2644
2644
 
2645
- const debugDisabled$1 = () => {};
2645
+ const debugDisabled = () => {};
2646
2646
 
2647
- const info$1 = (...args) => console.info(...args);
2647
+ const info = (...args) => console.info(...args);
2648
2648
 
2649
- const infoDisabled$1 = () => {};
2649
+ const infoDisabled = () => {};
2650
2650
 
2651
- const warn$1 = (...args) => console.warn(...args);
2651
+ const warn = (...args) => console.warn(...args);
2652
2652
 
2653
- const warnDisabled$1 = () => {};
2653
+ const warnDisabled = () => {};
2654
2654
 
2655
- const error$1 = (...args) => console.error(...args);
2655
+ const error = (...args) => console.error(...args);
2656
2656
 
2657
- const errorDisabled$1 = () => {};
2657
+ const errorDisabled = () => {};
2658
2658
 
2659
- function hasFlag$1(flag, argv = process$1.argv) {
2659
+ function hasFlag(flag, argv = process$1.argv) {
2660
2660
  const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
2661
2661
  const position = argv.indexOf(prefix + flag);
2662
2662
  const terminatorPosition = argv.indexOf('--');
@@ -2664,31 +2664,31 @@ function hasFlag$1(flag, argv = process$1.argv) {
2664
2664
  }
2665
2665
 
2666
2666
  const {
2667
- env: env$1
2667
+ env
2668
2668
  } = process$1;
2669
- let flagForceColor$1;
2669
+ let flagForceColor;
2670
2670
 
2671
- if (hasFlag$1('no-color') || hasFlag$1('no-colors') || hasFlag$1('color=false') || hasFlag$1('color=never')) {
2672
- flagForceColor$1 = 0;
2673
- } else if (hasFlag$1('color') || hasFlag$1('colors') || hasFlag$1('color=true') || hasFlag$1('color=always')) {
2674
- flagForceColor$1 = 1;
2671
+ if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) {
2672
+ flagForceColor = 0;
2673
+ } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
2674
+ flagForceColor = 1;
2675
2675
  }
2676
2676
 
2677
- function envForceColor$1() {
2678
- if ('FORCE_COLOR' in env$1) {
2679
- if (env$1.FORCE_COLOR === 'true') {
2677
+ function envForceColor() {
2678
+ if ('FORCE_COLOR' in env) {
2679
+ if (env.FORCE_COLOR === 'true') {
2680
2680
  return 1;
2681
2681
  }
2682
2682
 
2683
- if (env$1.FORCE_COLOR === 'false') {
2683
+ if (env.FORCE_COLOR === 'false') {
2684
2684
  return 0;
2685
2685
  }
2686
2686
 
2687
- return env$1.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env$1.FORCE_COLOR, 10), 3);
2687
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
2688
2688
  }
2689
2689
  }
2690
2690
 
2691
- function translateLevel$1(level) {
2691
+ function translateLevel(level) {
2692
2692
  if (level === 0) {
2693
2693
  return false;
2694
2694
  }
@@ -2701,28 +2701,28 @@ function translateLevel$1(level) {
2701
2701
  };
2702
2702
  }
2703
2703
 
2704
- function _supportsColor$1(haveStream, {
2704
+ function _supportsColor(haveStream, {
2705
2705
  streamIsTTY,
2706
2706
  sniffFlags = true
2707
2707
  } = {}) {
2708
- const noFlagForceColor = envForceColor$1();
2708
+ const noFlagForceColor = envForceColor();
2709
2709
 
2710
2710
  if (noFlagForceColor !== undefined) {
2711
- flagForceColor$1 = noFlagForceColor;
2711
+ flagForceColor = noFlagForceColor;
2712
2712
  }
2713
2713
 
2714
- const forceColor = sniffFlags ? flagForceColor$1 : noFlagForceColor;
2714
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
2715
2715
 
2716
2716
  if (forceColor === 0) {
2717
2717
  return 0;
2718
2718
  }
2719
2719
 
2720
2720
  if (sniffFlags) {
2721
- if (hasFlag$1('color=16m') || hasFlag$1('color=full') || hasFlag$1('color=truecolor')) {
2721
+ if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
2722
2722
  return 3;
2723
2723
  }
2724
2724
 
2725
- if (hasFlag$1('color=256')) {
2725
+ if (hasFlag('color=256')) {
2726
2726
  return 2;
2727
2727
  }
2728
2728
  }
@@ -2733,7 +2733,7 @@ function _supportsColor$1(haveStream, {
2733
2733
 
2734
2734
  const min = forceColor || 0;
2735
2735
 
2736
- if (env$1.TERM === 'dumb') {
2736
+ if (env.TERM === 'dumb') {
2737
2737
  return min;
2738
2738
  }
2739
2739
 
@@ -2749,31 +2749,31 @@ function _supportsColor$1(haveStream, {
2749
2749
  return 1;
2750
2750
  }
2751
2751
 
2752
- if ('CI' in env$1) {
2753
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE', 'DRONE'].some(sign => sign in env$1) || env$1.CI_NAME === 'codeship') {
2752
+ if ('CI' in env) {
2753
+ if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
2754
2754
  return 1;
2755
2755
  }
2756
2756
 
2757
2757
  return min;
2758
2758
  }
2759
2759
 
2760
- if ('TEAMCITY_VERSION' in env$1) {
2761
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0;
2760
+ if ('TEAMCITY_VERSION' in env) {
2761
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
2762
2762
  } // Check for Azure DevOps pipelines
2763
2763
 
2764
2764
 
2765
- if ('TF_BUILD' in env$1 && 'AGENT_NAME' in env$1) {
2765
+ if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
2766
2766
  return 1;
2767
2767
  }
2768
2768
 
2769
- if (env$1.COLORTERM === 'truecolor') {
2769
+ if (env.COLORTERM === 'truecolor') {
2770
2770
  return 3;
2771
2771
  }
2772
2772
 
2773
- if ('TERM_PROGRAM' in env$1) {
2774
- const version = Number.parseInt((env$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
2773
+ if ('TERM_PROGRAM' in env) {
2774
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
2775
2775
 
2776
- switch (env$1.TERM_PROGRAM) {
2776
+ switch (env.TERM_PROGRAM) {
2777
2777
  case 'iTerm.app':
2778
2778
  return version >= 3 ? 3 : 2;
2779
2779
 
@@ -2783,39 +2783,39 @@ function _supportsColor$1(haveStream, {
2783
2783
  }
2784
2784
  }
2785
2785
 
2786
- if (/-256(color)?$/i.test(env$1.TERM)) {
2786
+ if (/-256(color)?$/i.test(env.TERM)) {
2787
2787
  return 2;
2788
2788
  }
2789
2789
 
2790
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) {
2790
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
2791
2791
  return 1;
2792
2792
  }
2793
2793
 
2794
- if ('COLORTERM' in env$1) {
2794
+ if ('COLORTERM' in env) {
2795
2795
  return 1;
2796
2796
  }
2797
2797
 
2798
2798
  return min;
2799
2799
  }
2800
2800
 
2801
- function createSupportsColor$1(stream, options = {}) {
2802
- const level = _supportsColor$1(stream, {
2801
+ function createSupportsColor(stream, options = {}) {
2802
+ const level = _supportsColor(stream, {
2803
2803
  streamIsTTY: stream && stream.isTTY,
2804
2804
  ...options
2805
2805
  });
2806
2806
 
2807
- return translateLevel$1(level);
2807
+ return translateLevel(level);
2808
2808
  }
2809
2809
  ({
2810
- stdout: createSupportsColor$1({
2810
+ stdout: createSupportsColor({
2811
2811
  isTTY: tty.isatty(1)
2812
2812
  }),
2813
- stderr: createSupportsColor$1({
2813
+ stderr: createSupportsColor({
2814
2814
  isTTY: tty.isatty(2)
2815
2815
  })
2816
2816
  });
2817
2817
 
2818
- const processSupportsBasicColor = createSupportsColor$1(process.stdout).hasBasic;
2818
+ const processSupportsBasicColor = createSupportsColor(process.stdout).hasBasic;
2819
2819
  let canUseColors = processSupportsBasicColor; // GitHub workflow does support ANSI but "supports-color" returns false
2820
2820
  // because stream.isTTY returns false, see https://github.com/actions/runner/issues/241
2821
2821
 
@@ -2849,7 +2849,7 @@ const ANSI = {
2849
2849
  color: setANSIColor
2850
2850
  };
2851
2851
 
2852
- function isUnicodeSupported$1() {
2852
+ function isUnicodeSupported() {
2853
2853
  if (process$1.platform !== 'win32') {
2854
2854
  return process$1.env.TERM !== 'linux'; // Linux console (kernel)
2855
2855
  }
@@ -2861,7 +2861,7 @@ function isUnicodeSupported$1() {
2861
2861
  }
2862
2862
 
2863
2863
  // see also https://github.com/sindresorhus/figures
2864
- const canUseUnicode = isUnicodeSupported$1();
2864
+ const canUseUnicode = isUnicodeSupported();
2865
2865
  const COMMAND_RAW = canUseUnicode ? `❯` : `>`;
2866
2866
  const OK_RAW = canUseUnicode ? `✔` : `√`;
2867
2867
  const FAILURE_RAW = canUseUnicode ? `✖` : `×`;
@@ -2895,7 +2895,7 @@ const UNICODE = {
2895
2895
  supported: canUseUnicode
2896
2896
  };
2897
2897
 
2898
- const createDetailedMessage$2 = (message, details = {}) => {
2898
+ const createDetailedMessage$1 = (message, details = {}) => {
2899
2899
  let string = `${message}`;
2900
2900
  Object.keys(details).forEach(key => {
2901
2901
  const value = details[key];
@@ -3194,26 +3194,26 @@ const distributePercentages = (namedNumbers, {
3194
3194
  return percentages;
3195
3195
  };
3196
3196
 
3197
- const ESC$1 = '\u001B[';
3198
- const OSC$1 = '\u001B]';
3199
- const BEL$1 = '\u0007';
3200
- const SEP$1 = ';';
3201
- const isTerminalApp$1 = process$1.env.TERM_PROGRAM === 'Apple_Terminal';
3202
- const ansiEscapes$1 = {};
3197
+ const ESC = '\u001B[';
3198
+ const OSC = '\u001B]';
3199
+ const BEL = '\u0007';
3200
+ const SEP = ';';
3201
+ const isTerminalApp = process$1.env.TERM_PROGRAM === 'Apple_Terminal';
3202
+ const ansiEscapes = {};
3203
3203
 
3204
- ansiEscapes$1.cursorTo = (x, y) => {
3204
+ ansiEscapes.cursorTo = (x, y) => {
3205
3205
  if (typeof x !== 'number') {
3206
3206
  throw new TypeError('The `x` argument is required');
3207
3207
  }
3208
3208
 
3209
3209
  if (typeof y !== 'number') {
3210
- return ESC$1 + (x + 1) + 'G';
3210
+ return ESC + (x + 1) + 'G';
3211
3211
  }
3212
3212
 
3213
- return ESC$1 + (y + 1) + SEP$1 + (x + 1) + 'H';
3213
+ return ESC + (y + 1) + SEP + (x + 1) + 'H';
3214
3214
  };
3215
3215
 
3216
- ansiEscapes$1.cursorMove = (x, y) => {
3216
+ ansiEscapes.cursorMove = (x, y) => {
3217
3217
  if (typeof x !== 'number') {
3218
3218
  throw new TypeError('The `x` argument is required');
3219
3219
  }
@@ -3221,71 +3221,71 @@ ansiEscapes$1.cursorMove = (x, y) => {
3221
3221
  let returnValue = '';
3222
3222
 
3223
3223
  if (x < 0) {
3224
- returnValue += ESC$1 + -x + 'D';
3224
+ returnValue += ESC + -x + 'D';
3225
3225
  } else if (x > 0) {
3226
- returnValue += ESC$1 + x + 'C';
3226
+ returnValue += ESC + x + 'C';
3227
3227
  }
3228
3228
 
3229
3229
  if (y < 0) {
3230
- returnValue += ESC$1 + -y + 'A';
3230
+ returnValue += ESC + -y + 'A';
3231
3231
  } else if (y > 0) {
3232
- returnValue += ESC$1 + y + 'B';
3232
+ returnValue += ESC + y + 'B';
3233
3233
  }
3234
3234
 
3235
3235
  return returnValue;
3236
3236
  };
3237
3237
 
3238
- ansiEscapes$1.cursorUp = (count = 1) => ESC$1 + count + 'A';
3238
+ ansiEscapes.cursorUp = (count = 1) => ESC + count + 'A';
3239
3239
 
3240
- ansiEscapes$1.cursorDown = (count = 1) => ESC$1 + count + 'B';
3240
+ ansiEscapes.cursorDown = (count = 1) => ESC + count + 'B';
3241
3241
 
3242
- ansiEscapes$1.cursorForward = (count = 1) => ESC$1 + count + 'C';
3242
+ ansiEscapes.cursorForward = (count = 1) => ESC + count + 'C';
3243
3243
 
3244
- ansiEscapes$1.cursorBackward = (count = 1) => ESC$1 + count + 'D';
3244
+ ansiEscapes.cursorBackward = (count = 1) => ESC + count + 'D';
3245
3245
 
3246
- ansiEscapes$1.cursorLeft = ESC$1 + 'G';
3247
- ansiEscapes$1.cursorSavePosition = isTerminalApp$1 ? '\u001B7' : ESC$1 + 's';
3248
- ansiEscapes$1.cursorRestorePosition = isTerminalApp$1 ? '\u001B8' : ESC$1 + 'u';
3249
- ansiEscapes$1.cursorGetPosition = ESC$1 + '6n';
3250
- ansiEscapes$1.cursorNextLine = ESC$1 + 'E';
3251
- ansiEscapes$1.cursorPrevLine = ESC$1 + 'F';
3252
- ansiEscapes$1.cursorHide = ESC$1 + '?25l';
3253
- ansiEscapes$1.cursorShow = ESC$1 + '?25h';
3246
+ ansiEscapes.cursorLeft = ESC + 'G';
3247
+ ansiEscapes.cursorSavePosition = isTerminalApp ? '\u001B7' : ESC + 's';
3248
+ ansiEscapes.cursorRestorePosition = isTerminalApp ? '\u001B8' : ESC + 'u';
3249
+ ansiEscapes.cursorGetPosition = ESC + '6n';
3250
+ ansiEscapes.cursorNextLine = ESC + 'E';
3251
+ ansiEscapes.cursorPrevLine = ESC + 'F';
3252
+ ansiEscapes.cursorHide = ESC + '?25l';
3253
+ ansiEscapes.cursorShow = ESC + '?25h';
3254
3254
 
3255
- ansiEscapes$1.eraseLines = count => {
3255
+ ansiEscapes.eraseLines = count => {
3256
3256
  let clear = '';
3257
3257
 
3258
3258
  for (let i = 0; i < count; i++) {
3259
- clear += ansiEscapes$1.eraseLine + (i < count - 1 ? ansiEscapes$1.cursorUp() : '');
3259
+ clear += ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : '');
3260
3260
  }
3261
3261
 
3262
3262
  if (count) {
3263
- clear += ansiEscapes$1.cursorLeft;
3263
+ clear += ansiEscapes.cursorLeft;
3264
3264
  }
3265
3265
 
3266
3266
  return clear;
3267
3267
  };
3268
3268
 
3269
- ansiEscapes$1.eraseEndLine = ESC$1 + 'K';
3270
- ansiEscapes$1.eraseStartLine = ESC$1 + '1K';
3271
- ansiEscapes$1.eraseLine = ESC$1 + '2K';
3272
- ansiEscapes$1.eraseDown = ESC$1 + 'J';
3273
- ansiEscapes$1.eraseUp = ESC$1 + '1J';
3274
- ansiEscapes$1.eraseScreen = ESC$1 + '2J';
3275
- ansiEscapes$1.scrollUp = ESC$1 + 'S';
3276
- ansiEscapes$1.scrollDown = ESC$1 + 'T';
3277
- ansiEscapes$1.clearScreen = '\u001Bc';
3278
- ansiEscapes$1.clearTerminal = process$1.platform === 'win32' ? `${ansiEscapes$1.eraseScreen}${ESC$1}0f` // 1. Erases the screen (Only done in case `2` is not supported)
3269
+ ansiEscapes.eraseEndLine = ESC + 'K';
3270
+ ansiEscapes.eraseStartLine = ESC + '1K';
3271
+ ansiEscapes.eraseLine = ESC + '2K';
3272
+ ansiEscapes.eraseDown = ESC + 'J';
3273
+ ansiEscapes.eraseUp = ESC + '1J';
3274
+ ansiEscapes.eraseScreen = ESC + '2J';
3275
+ ansiEscapes.scrollUp = ESC + 'S';
3276
+ ansiEscapes.scrollDown = ESC + 'T';
3277
+ ansiEscapes.clearScreen = '\u001Bc';
3278
+ ansiEscapes.clearTerminal = process$1.platform === 'win32' ? `${ansiEscapes.eraseScreen}${ESC}0f` // 1. Erases the screen (Only done in case `2` is not supported)
3279
3279
  // 2. Erases the whole screen including scrollback buffer
3280
3280
  // 3. Moves cursor to the top-left position
3281
3281
  // More info: https://www.real-world-systems.com/docs/ANSIcode.html
3282
- : `${ansiEscapes$1.eraseScreen}${ESC$1}3J${ESC$1}H`;
3283
- ansiEscapes$1.beep = BEL$1;
3282
+ : `${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`;
3283
+ ansiEscapes.beep = BEL;
3284
3284
 
3285
- ansiEscapes$1.link = (text, url) => [OSC$1, '8', SEP$1, SEP$1, url, BEL$1, text, OSC$1, '8', SEP$1, SEP$1, BEL$1].join('');
3285
+ ansiEscapes.link = (text, url) => [OSC, '8', SEP, SEP, url, BEL, text, OSC, '8', SEP, SEP, BEL].join('');
3286
3286
 
3287
- ansiEscapes$1.image = (buffer, options = {}) => {
3288
- let returnValue = `${OSC$1}1337;File=inline=1`;
3287
+ ansiEscapes.image = (buffer, options = {}) => {
3288
+ let returnValue = `${OSC}1337;File=inline=1`;
3289
3289
 
3290
3290
  if (options.width) {
3291
3291
  returnValue += `;width=${options.width}`;
@@ -3299,14 +3299,14 @@ ansiEscapes$1.image = (buffer, options = {}) => {
3299
3299
  returnValue += ';preserveAspectRatio=0';
3300
3300
  }
3301
3301
 
3302
- return returnValue + ':' + buffer.toString('base64') + BEL$1;
3302
+ return returnValue + ':' + buffer.toString('base64') + BEL;
3303
3303
  };
3304
3304
 
3305
- ansiEscapes$1.iTerm = {
3306
- setCwd: (cwd = process$1.cwd()) => `${OSC$1}50;CurrentDir=${cwd}${BEL$1}`,
3305
+ ansiEscapes.iTerm = {
3306
+ setCwd: (cwd = process$1.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
3307
3307
 
3308
3308
  annotation(message, options = {}) {
3309
- let returnValue = `${OSC$1}1337;`;
3309
+ let returnValue = `${OSC}1337;`;
3310
3310
  const hasX = typeof options.x !== 'undefined';
3311
3311
  const hasY = typeof options.y !== 'undefined';
3312
3312
 
@@ -3323,7 +3323,7 @@ ansiEscapes$1.iTerm = {
3323
3323
  returnValue += message;
3324
3324
  }
3325
3325
 
3326
- return returnValue + BEL$1;
3326
+ return returnValue + BEL;
3327
3327
  }
3328
3328
 
3329
3329
  };
@@ -3409,7 +3409,7 @@ const createLog = ({
3409
3409
  }
3410
3410
 
3411
3411
  clearAttemptResult = true;
3412
- return ansiEscapes$1.eraseLines(visualLineCount);
3412
+ return ansiEscapes.eraseLines(visualLineCount);
3413
3413
  };
3414
3414
 
3415
3415
  const spyStream = () => {
@@ -3532,531 +3532,89 @@ const startSpinner = ({
3532
3532
  log.write(update(render()));
3533
3533
  interval = setInterval(() => {
3534
3534
  frameIndex = frameIndex === frames.length - 1 ? 0 : frameIndex + 1;
3535
- log.dynamicWrite(({
3536
- outputFromOutside
3537
- }) => {
3538
- if (outputFromOutside && stopOnWriteFromOutside) {
3539
- stop();
3540
- return "";
3541
- }
3542
-
3543
- return update(render());
3544
- });
3545
- }, 1000 / fps);
3546
-
3547
- if (!keepProcessAlive) {
3548
- interval.unref();
3549
- }
3550
- } else {
3551
- log.write(update(render()));
3552
- }
3553
-
3554
- const stop = message => {
3555
- running = false;
3556
-
3557
- if (interval) {
3558
- clearInterval(interval);
3559
- interval = null;
3560
- }
3561
-
3562
- if (cleanup) {
3563
- cleanup();
3564
- cleanup = null;
3565
- }
3566
-
3567
- if (log && message) {
3568
- log.write(update(message));
3569
- log = null;
3570
- }
3571
- };
3572
-
3573
- spinner.stop = stop;
3574
-
3575
- if (stopOnVerticalOverflow) {
3576
- log.onVerticalOverflow = stop;
3577
- }
3578
-
3579
- return spinner;
3580
- };
3581
-
3582
- const createTaskLog = (label, {
3583
- disabled = false,
3584
- stopOnWriteFromOutside
3585
- } = {}) => {
3586
- if (disabled) {
3587
- return {
3588
- setRightText: () => {},
3589
- done: () => {},
3590
- happen: () => {},
3591
- fail: () => {}
3592
- };
3593
- }
3594
-
3595
- const startMs = Date.now();
3596
- const log = createLog();
3597
- let message = label;
3598
- const taskSpinner = startSpinner({
3599
- log,
3600
- render: () => message,
3601
- stopOnWriteFromOutside
3602
- });
3603
- return {
3604
- setRightText: value => {
3605
- message = `${label} ${value}`;
3606
- },
3607
- done: () => {
3608
- const msEllapsed = Date.now() - startMs;
3609
- taskSpinner.stop(`${UNICODE.OK} ${label} (done in ${msAsDuration(msEllapsed)})`);
3610
- },
3611
- happen: message => {
3612
- taskSpinner.stop(`${UNICODE.INFO} ${message} (at ${new Date().toLocaleTimeString()})`);
3613
- },
3614
- fail: (message = `failed to ${label}`) => {
3615
- taskSpinner.stop(`${UNICODE.FAILURE} ${message}`);
3616
- }
3617
- };
3618
- };
3619
-
3620
- const LOG_LEVEL_OFF = "off";
3621
- const LOG_LEVEL_DEBUG = "debug";
3622
- const LOG_LEVEL_INFO = "info";
3623
- const LOG_LEVEL_WARN = "warn";
3624
- const LOG_LEVEL_ERROR = "error";
3625
-
3626
- const createLogger = ({
3627
- logLevel = LOG_LEVEL_INFO
3628
- } = {}) => {
3629
- if (logLevel === LOG_LEVEL_DEBUG) {
3630
- return {
3631
- level: "debug",
3632
- levels: {
3633
- debug: true,
3634
- info: true,
3635
- warn: true,
3636
- error: true
3637
- },
3638
- debug,
3639
- info,
3640
- warn,
3641
- error
3642
- };
3643
- }
3644
-
3645
- if (logLevel === LOG_LEVEL_INFO) {
3646
- return {
3647
- level: "info",
3648
- levels: {
3649
- debug: false,
3650
- info: true,
3651
- warn: true,
3652
- error: true
3653
- },
3654
- debug: debugDisabled,
3655
- info,
3656
- warn,
3657
- error
3658
- };
3659
- }
3660
-
3661
- if (logLevel === LOG_LEVEL_WARN) {
3662
- return {
3663
- level: "warn",
3664
- levels: {
3665
- debug: false,
3666
- info: false,
3667
- warn: true,
3668
- error: true
3669
- },
3670
- debug: debugDisabled,
3671
- info: infoDisabled,
3672
- warn,
3673
- error
3674
- };
3675
- }
3676
-
3677
- if (logLevel === LOG_LEVEL_ERROR) {
3678
- return {
3679
- level: "error",
3680
- levels: {
3681
- debug: false,
3682
- info: false,
3683
- warn: false,
3684
- error: true
3685
- },
3686
- debug: debugDisabled,
3687
- info: infoDisabled,
3688
- warn: warnDisabled,
3689
- error
3690
- };
3691
- }
3692
-
3693
- if (logLevel === LOG_LEVEL_OFF) {
3694
- return {
3695
- level: "off",
3696
- levels: {
3697
- debug: false,
3698
- info: false,
3699
- warn: false,
3700
- error: false
3701
- },
3702
- debug: debugDisabled,
3703
- info: infoDisabled,
3704
- warn: warnDisabled,
3705
- error: errorDisabled
3706
- };
3707
- }
3708
-
3709
- throw new Error(`unexpected logLevel.
3710
- --- logLevel ---
3711
- ${logLevel}
3712
- --- allowed log levels ---
3713
- ${LOG_LEVEL_OFF}
3714
- ${LOG_LEVEL_ERROR}
3715
- ${LOG_LEVEL_WARN}
3716
- ${LOG_LEVEL_INFO}
3717
- ${LOG_LEVEL_DEBUG}`);
3718
- };
3719
-
3720
- const debug = (...args) => console.debug(...args);
3721
-
3722
- const debugDisabled = () => {};
3723
-
3724
- const info = (...args) => console.info(...args);
3725
-
3726
- const infoDisabled = () => {};
3727
-
3728
- const warn = (...args) => console.warn(...args);
3729
-
3730
- const warnDisabled = () => {};
3731
-
3732
- const error = (...args) => console.error(...args);
3733
-
3734
- const errorDisabled = () => {};
3735
-
3736
- function hasFlag(flag, argv = process$1.argv) {
3737
- const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
3738
- const position = argv.indexOf(prefix + flag);
3739
- const terminatorPosition = argv.indexOf('--');
3740
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
3741
- }
3742
-
3743
- const {
3744
- env
3745
- } = process$1;
3746
- let flagForceColor;
3747
-
3748
- if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) {
3749
- flagForceColor = 0;
3750
- } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
3751
- flagForceColor = 1;
3752
- }
3753
-
3754
- function envForceColor() {
3755
- if ('FORCE_COLOR' in env) {
3756
- if (env.FORCE_COLOR === 'true') {
3757
- return 1;
3758
- }
3759
-
3760
- if (env.FORCE_COLOR === 'false') {
3761
- return 0;
3762
- }
3763
-
3764
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
3765
- }
3766
- }
3767
-
3768
- function translateLevel(level) {
3769
- if (level === 0) {
3770
- return false;
3771
- }
3772
-
3773
- return {
3774
- level,
3775
- hasBasic: true,
3776
- has256: level >= 2,
3777
- has16m: level >= 3
3778
- };
3779
- }
3780
-
3781
- function _supportsColor(haveStream, {
3782
- streamIsTTY,
3783
- sniffFlags = true
3784
- } = {}) {
3785
- const noFlagForceColor = envForceColor();
3786
-
3787
- if (noFlagForceColor !== undefined) {
3788
- flagForceColor = noFlagForceColor;
3789
- }
3790
-
3791
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
3792
-
3793
- if (forceColor === 0) {
3794
- return 0;
3795
- }
3796
-
3797
- if (sniffFlags) {
3798
- if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
3799
- return 3;
3800
- }
3801
-
3802
- if (hasFlag('color=256')) {
3803
- return 2;
3804
- }
3805
- }
3806
-
3807
- if (haveStream && !streamIsTTY && forceColor === undefined) {
3808
- return 0;
3809
- }
3810
-
3811
- const min = forceColor || 0;
3812
-
3813
- if (env.TERM === 'dumb') {
3814
- return min;
3815
- }
3816
-
3817
- if (process$1.platform === 'win32') {
3818
- // Windows 10 build 10586 is the first Windows release that supports 256 colors.
3819
- // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
3820
- const osRelease = os.release().split('.');
3821
-
3822
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10_586) {
3823
- return Number(osRelease[2]) >= 14_931 ? 3 : 2;
3824
- }
3825
-
3826
- return 1;
3827
- }
3828
-
3829
- if ('CI' in env) {
3830
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
3831
- return 1;
3832
- }
3833
-
3834
- return min;
3835
- }
3836
-
3837
- if ('TEAMCITY_VERSION' in env) {
3838
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
3839
- } // Check for Azure DevOps pipelines
3840
-
3841
-
3842
- if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
3843
- return 1;
3844
- }
3845
-
3846
- if (env.COLORTERM === 'truecolor') {
3847
- return 3;
3848
- }
3849
-
3850
- if ('TERM_PROGRAM' in env) {
3851
- const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
3852
-
3853
- switch (env.TERM_PROGRAM) {
3854
- case 'iTerm.app':
3855
- return version >= 3 ? 3 : 2;
3856
-
3857
- case 'Apple_Terminal':
3858
- return 2;
3859
- // No default
3860
- }
3861
- }
3862
-
3863
- if (/-256(color)?$/i.test(env.TERM)) {
3864
- return 2;
3865
- }
3866
-
3867
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
3868
- return 1;
3869
- }
3870
-
3871
- if ('COLORTERM' in env) {
3872
- return 1;
3873
- }
3874
-
3875
- return min;
3876
- }
3877
-
3878
- function createSupportsColor(stream, options = {}) {
3879
- const level = _supportsColor(stream, {
3880
- streamIsTTY: stream && stream.isTTY,
3881
- ...options
3882
- });
3883
-
3884
- return translateLevel(level);
3885
- }
3886
- ({
3887
- stdout: createSupportsColor({
3888
- isTTY: tty.isatty(1)
3889
- }),
3890
- stderr: createSupportsColor({
3891
- isTTY: tty.isatty(2)
3892
- })
3893
- });
3894
-
3895
- createSupportsColor(process.stdout).hasBasic;
3896
- // because stream.isTTY returns false, see https://github.com/actions/runner/issues/241
3897
-
3898
- if (process.env.GITHUB_WORKFLOW) {
3899
- // Check on FORCE_COLOR is to ensure it is prio over GitHub workflow check
3900
- if (process.env.FORCE_COLOR !== "false") ;
3901
- } // https://github.com/Marak/colors.js/blob/master/lib/styles.js
3902
-
3903
- function isUnicodeSupported() {
3904
- if (process$1.platform !== 'win32') {
3905
- return process$1.env.TERM !== 'linux'; // Linux console (kernel)
3906
- }
3907
-
3908
- return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) // Windows Terminal
3909
- || process$1.env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
3910
- || process$1.env.TERM_PROGRAM === 'vscode' || process$1.env.TERM === 'xterm-256color' || process$1.env.TERM === 'alacritty' || process$1.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
3911
- }
3912
-
3913
- // see also https://github.com/sindresorhus/figures
3914
- isUnicodeSupported();
3915
-
3916
- const createDetailedMessage$1 = (message, details = {}) => {
3917
- let string = `${message}`;
3918
- Object.keys(details).forEach(key => {
3919
- const value = details[key];
3920
- string += `
3921
- --- ${key} ---
3922
- ${Array.isArray(value) ? value.join(`
3923
- `) : value}`;
3924
- });
3925
- return string;
3926
- };
3927
-
3928
- const ESC = '\u001B[';
3929
- const OSC = '\u001B]';
3930
- const BEL = '\u0007';
3931
- const SEP = ';';
3932
- const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
3933
- const ansiEscapes = {};
3934
-
3935
- ansiEscapes.cursorTo = (x, y) => {
3936
- if (typeof x !== 'number') {
3937
- throw new TypeError('The `x` argument is required');
3938
- }
3939
-
3940
- if (typeof y !== 'number') {
3941
- return ESC + (x + 1) + 'G';
3942
- }
3943
-
3944
- return ESC + (y + 1) + ';' + (x + 1) + 'H';
3945
- };
3946
-
3947
- ansiEscapes.cursorMove = (x, y) => {
3948
- if (typeof x !== 'number') {
3949
- throw new TypeError('The `x` argument is required');
3950
- }
3951
-
3952
- let returnValue = '';
3953
-
3954
- if (x < 0) {
3955
- returnValue += ESC + -x + 'D';
3956
- } else if (x > 0) {
3957
- returnValue += ESC + x + 'C';
3958
- }
3959
-
3960
- if (y < 0) {
3961
- returnValue += ESC + -y + 'A';
3962
- } else if (y > 0) {
3963
- returnValue += ESC + y + 'B';
3964
- }
3965
-
3966
- return returnValue;
3967
- };
3968
-
3969
- ansiEscapes.cursorUp = (count = 1) => ESC + count + 'A';
3970
-
3971
- ansiEscapes.cursorDown = (count = 1) => ESC + count + 'B';
3972
-
3973
- ansiEscapes.cursorForward = (count = 1) => ESC + count + 'C';
3974
-
3975
- ansiEscapes.cursorBackward = (count = 1) => ESC + count + 'D';
3976
-
3977
- ansiEscapes.cursorLeft = ESC + 'G';
3978
- ansiEscapes.cursorSavePosition = isTerminalApp ? '\u001B7' : ESC + 's';
3979
- ansiEscapes.cursorRestorePosition = isTerminalApp ? '\u001B8' : ESC + 'u';
3980
- ansiEscapes.cursorGetPosition = ESC + '6n';
3981
- ansiEscapes.cursorNextLine = ESC + 'E';
3982
- ansiEscapes.cursorPrevLine = ESC + 'F';
3983
- ansiEscapes.cursorHide = ESC + '?25l';
3984
- ansiEscapes.cursorShow = ESC + '?25h';
3985
-
3986
- ansiEscapes.eraseLines = count => {
3987
- let clear = '';
3535
+ log.dynamicWrite(({
3536
+ outputFromOutside
3537
+ }) => {
3538
+ if (outputFromOutside && stopOnWriteFromOutside) {
3539
+ stop();
3540
+ return "";
3541
+ }
3988
3542
 
3989
- for (let i = 0; i < count; i++) {
3990
- clear += ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : '');
3991
- }
3543
+ return update(render());
3544
+ });
3545
+ }, 1000 / fps);
3992
3546
 
3993
- if (count) {
3994
- clear += ansiEscapes.cursorLeft;
3547
+ if (!keepProcessAlive) {
3548
+ interval.unref();
3549
+ }
3550
+ } else {
3551
+ log.write(update(render()));
3995
3552
  }
3996
3553
 
3997
- return clear;
3998
- };
3999
-
4000
- ansiEscapes.eraseEndLine = ESC + 'K';
4001
- ansiEscapes.eraseStartLine = ESC + '1K';
4002
- ansiEscapes.eraseLine = ESC + '2K';
4003
- ansiEscapes.eraseDown = ESC + 'J';
4004
- ansiEscapes.eraseUp = ESC + '1J';
4005
- ansiEscapes.eraseScreen = ESC + '2J';
4006
- ansiEscapes.scrollUp = ESC + 'S';
4007
- ansiEscapes.scrollDown = ESC + 'T';
4008
- ansiEscapes.clearScreen = '\u001Bc';
4009
- ansiEscapes.clearTerminal = process.platform === 'win32' ? `${ansiEscapes.eraseScreen}${ESC}0f` : // 1. Erases the screen (Only done in case `2` is not supported)
4010
- // 2. Erases the whole screen including scrollback buffer
4011
- // 3. Moves cursor to the top-left position
4012
- // More info: https://www.real-world-systems.com/docs/ANSIcode.html
4013
- `${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`;
4014
- ansiEscapes.beep = BEL;
3554
+ const stop = message => {
3555
+ running = false;
4015
3556
 
4016
- ansiEscapes.link = (text, url) => {
4017
- return [OSC, '8', SEP, SEP, url, BEL, text, OSC, '8', SEP, SEP, BEL].join('');
4018
- };
3557
+ if (interval) {
3558
+ clearInterval(interval);
3559
+ interval = null;
3560
+ }
4019
3561
 
4020
- ansiEscapes.image = (buffer, options = {}) => {
4021
- let returnValue = `${OSC}1337;File=inline=1`;
3562
+ if (cleanup) {
3563
+ cleanup();
3564
+ cleanup = null;
3565
+ }
4022
3566
 
4023
- if (options.width) {
4024
- returnValue += `;width=${options.width}`;
4025
- }
3567
+ if (log && message) {
3568
+ log.write(update(message));
3569
+ log = null;
3570
+ }
3571
+ };
4026
3572
 
4027
- if (options.height) {
4028
- returnValue += `;height=${options.height}`;
4029
- }
3573
+ spinner.stop = stop;
4030
3574
 
4031
- if (options.preserveAspectRatio === false) {
4032
- returnValue += ';preserveAspectRatio=0';
3575
+ if (stopOnVerticalOverflow) {
3576
+ log.onVerticalOverflow = stop;
4033
3577
  }
4034
3578
 
4035
- return returnValue + ':' + buffer.toString('base64') + BEL;
3579
+ return spinner;
4036
3580
  };
4037
3581
 
4038
- ansiEscapes.iTerm = {
4039
- setCwd: (cwd = process.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
4040
- annotation: (message, options = {}) => {
4041
- let returnValue = `${OSC}1337;`;
4042
- const hasX = typeof options.x !== 'undefined';
4043
- const hasY = typeof options.y !== 'undefined';
4044
-
4045
- if ((hasX || hasY) && !(hasX && hasY && typeof options.length !== 'undefined')) {
4046
- throw new Error('`x`, `y` and `length` must be defined when `x` or `y` is defined');
4047
- }
4048
-
4049
- message = message.replace(/\|/g, '');
4050
- returnValue += options.isHidden ? 'AddHiddenAnnotation=' : 'AddAnnotation=';
3582
+ const createTaskLog = (label, {
3583
+ disabled = false,
3584
+ stopOnWriteFromOutside
3585
+ } = {}) => {
3586
+ if (disabled) {
3587
+ return {
3588
+ setRightText: () => {},
3589
+ done: () => {},
3590
+ happen: () => {},
3591
+ fail: () => {}
3592
+ };
3593
+ }
4051
3594
 
4052
- if (options.length > 0) {
4053
- returnValue += (hasX ? [message, options.length, options.x, options.y] : [options.length, message]).join('|');
4054
- } else {
4055
- returnValue += message;
3595
+ const startMs = Date.now();
3596
+ const log = createLog();
3597
+ let message = label;
3598
+ const taskSpinner = startSpinner({
3599
+ log,
3600
+ render: () => message,
3601
+ stopOnWriteFromOutside
3602
+ });
3603
+ return {
3604
+ setRightText: value => {
3605
+ message = `${label} ${value}`;
3606
+ },
3607
+ done: () => {
3608
+ const msEllapsed = Date.now() - startMs;
3609
+ taskSpinner.stop(`${UNICODE.OK} ${label} (done in ${msAsDuration(msEllapsed)})`);
3610
+ },
3611
+ happen: message => {
3612
+ taskSpinner.stop(`${UNICODE.INFO} ${message} (at ${new Date().toLocaleTimeString()})`);
3613
+ },
3614
+ fail: (message = `failed to ${label}`) => {
3615
+ taskSpinner.stop(`${UNICODE.FAILURE} ${message}`);
4056
3616
  }
4057
-
4058
- return returnValue + BEL;
4059
- }
3617
+ };
4060
3618
  };
4061
3619
 
4062
3620
  const memoize = compute => {
@@ -6736,7 +6294,7 @@ const startServer = async ({
6736
6294
  }) => {
6737
6295
  const statusType = statusToType(status);
6738
6296
  addRequestLog(requestNode, {
6739
- type: {
6297
+ type: status === 404 && request.pathname === "/favicon.ico" ? "debug" : {
6740
6298
  information: "info",
6741
6299
  success: "info",
6742
6300
  redirection: "info",
@@ -8992,7 +8550,7 @@ const createUrlInfoTransformer = ({
8992
8550
  sourcemaps,
8993
8551
  sourcemapsSourcesProtocol,
8994
8552
  sourcemapsSourcesContent,
8995
- sourcemapsRelativeSources,
8553
+ sourcemapsSourcesRelative,
8996
8554
  urlGraph,
8997
8555
  injectSourcemapPlaceholder,
8998
8556
  foundSourcemap
@@ -9182,7 +8740,7 @@ const createUrlInfoTransformer = ({
9182
8740
  sourcemapUrlInfo.contentType = "application/json";
9183
8741
  const sourcemap = urlInfo.sourcemap;
9184
8742
 
9185
- if (sourcemapsRelativeSources) {
8743
+ if (sourcemapsSourcesRelative) {
9186
8744
  sourcemap.sources = sourcemap.sources.map(source => {
9187
8745
  const sourceRelative = urlToRelativeUrl(source, urlInfo.url);
9188
8746
  return sourceRelative || ".";
@@ -9210,7 +8768,7 @@ const createUrlInfoTransformer = ({
9210
8768
  urlInfo.content = SOURCEMAP.writeComment({
9211
8769
  contentType: urlInfo.contentType,
9212
8770
  content: urlInfo.content,
9213
- specifier: sourcemaps === "file" && sourcemapsRelativeSources ? urlToRelativeUrl(sourcemapReference.url, urlInfo.url) : sourcemapReference.generatedSpecifier
8771
+ specifier: sourcemaps === "file" && sourcemapsSourcesRelative ? urlToRelativeUrl(sourcemapReference.url, urlInfo.url) : sourcemapReference.generatedSpecifier
9214
8772
  });
9215
8773
  }
9216
8774
  }
@@ -9539,7 +9097,7 @@ const createResolveUrlError = ({
9539
9097
  reason,
9540
9098
  ...details
9541
9099
  }) => {
9542
- const resolveError = new Error(createDetailedMessage$2(`Failed to resolve url reference`, {
9100
+ const resolveError = new Error(createDetailedMessage$1(`Failed to resolve url reference`, {
9543
9101
  reason,
9544
9102
  ...details,
9545
9103
  "specifier": `"${reference.specifier}"`,
@@ -9575,7 +9133,7 @@ const createFetchUrlContentError = ({
9575
9133
  reason,
9576
9134
  ...details
9577
9135
  }) => {
9578
- const fetchError = new Error(createDetailedMessage$2(`Failed to fetch url content`, {
9136
+ const fetchError = new Error(createDetailedMessage$1(`Failed to fetch url content`, {
9579
9137
  reason,
9580
9138
  ...details,
9581
9139
  "url": urlInfo.url,
@@ -9631,7 +9189,7 @@ const createTransformUrlContentError = ({
9631
9189
  reason,
9632
9190
  ...details
9633
9191
  }) => {
9634
- const transformError = new Error(createDetailedMessage$2(`"transformUrlContent" error on "${urlInfo.type}"`, {
9192
+ const transformError = new Error(createDetailedMessage$1(`"transformUrlContent" error on "${urlInfo.type}"`, {
9635
9193
  reason,
9636
9194
  ...details,
9637
9195
  "url": urlInfo.url,
@@ -9687,7 +9245,7 @@ const createFinalizeUrlContentError = ({
9687
9245
  urlInfo,
9688
9246
  error
9689
9247
  }) => {
9690
- const finalizeError = new Error(createDetailedMessage$2(`"finalizeUrlContent" error on "${urlInfo.type}"`, { ...detailsFromValueThrown(error),
9248
+ const finalizeError = new Error(createDetailedMessage$1(`"finalizeUrlContent" error on "${urlInfo.type}"`, { ...detailsFromValueThrown(error),
9691
9249
  "url": urlInfo.url,
9692
9250
  "url reference trace": reference.trace.message,
9693
9251
  ...detailsFromPluginController(pluginController)
@@ -9945,11 +9503,11 @@ const createKitchen = ({
9945
9503
  // "programmatic" and "file" also allowed
9946
9504
  sourcemapsSourcesProtocol,
9947
9505
  sourcemapsSourcesContent,
9948
- sourcemapsRelativeSources,
9506
+ sourcemapsSourcesRelative,
9949
9507
  writeGeneratedFiles,
9950
9508
  outDirectoryUrl
9951
9509
  }) => {
9952
- const logger = createLogger$1({
9510
+ const logger = createLogger({
9953
9511
  logLevel
9954
9512
  });
9955
9513
  const pluginController = createPluginController({
@@ -10087,10 +9645,17 @@ const createKitchen = ({
10087
9645
  }
10088
9646
 
10089
9647
  resolvedUrl = normalizeUrl(resolvedUrl);
10090
- let referencedUrlObject = new URL(resolvedUrl);
10091
- let searchParams = referencedUrlObject.searchParams;
10092
- reference.url = resolvedUrl;
10093
- reference.searchParams = searchParams;
9648
+ let referencedUrlObject;
9649
+ let searchParams;
9650
+
9651
+ const onReferenceUrlChange = referenceUrl => {
9652
+ referencedUrlObject = new URL(referenceUrl);
9653
+ searchParams = referencedUrlObject.searchParams;
9654
+ reference.url = referenceUrl;
9655
+ reference.searchParams = searchParams;
9656
+ };
9657
+
9658
+ onReferenceUrlChange(resolvedUrl);
10094
9659
 
10095
9660
  if (reference.debug) {
10096
9661
  logger.debug(`url resolved by "${pluginController.getLastPluginUsed().name}"
@@ -10116,17 +9681,9 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
10116
9681
  const prevReference = { ...reference
10117
9682
  };
10118
9683
  updateReference(prevReference, reference);
10119
- referencedUrlObject = new URL(normalizedReturnValue);
10120
- searchParams = referencedUrlObject.searchParams;
10121
- reference.url = normalizedReturnValue;
10122
- reference.searchParams = searchParams;
9684
+ onReferenceUrlChange(normalizedReturnValue);
10123
9685
  });
10124
9686
  reference.generatedUrl = reference.url;
10125
-
10126
- if (searchParams.has("entry_point")) {
10127
- reference.isEntryPoint = true;
10128
- }
10129
-
10130
9687
  const urlInfo = urlGraph.reuseOrCreateUrlInfo(reference.url);
10131
9688
  applyReferenceEffectsOnUrlInfo(reference, urlInfo, context); // This hook must touch reference.generatedUrl, NOT reference.url
10132
9689
  // And this is because this hook inject query params used to:
@@ -10161,7 +9718,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
10161
9718
  sourcemaps,
10162
9719
  sourcemapsSourcesProtocol,
10163
9720
  sourcemapsSourcesContent,
10164
- sourcemapsRelativeSources,
9721
+ sourcemapsSourcesRelative,
10165
9722
  clientRuntimeCompat,
10166
9723
  injectSourcemapPlaceholder: ({
10167
9724
  urlInfo,
@@ -10214,7 +9771,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
10214
9771
  const fetchUrlContentReturnValue = await pluginController.callAsyncHooksUntil("fetchUrlContent", urlInfo, contextDuringFetch);
10215
9772
 
10216
9773
  if (!fetchUrlContentReturnValue) {
10217
- logger.warn(createDetailedMessage$2(`no plugin has handled url during "fetchUrlContent" hook -> url will be ignored`, {
9774
+ logger.warn(createDetailedMessage$1(`no plugin has handled url during "fetchUrlContent" hook -> url will be ignored`, {
10218
9775
  "url": urlInfo.url,
10219
9776
  "url reference trace": reference.trace.message
10220
9777
  }));
@@ -10251,15 +9808,8 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
10251
9808
 
10252
9809
  urlInfo.contentType = contentType;
10253
9810
  urlInfo.headers = headers;
10254
- urlInfo.type = type || reference.expectedType || inferUrlInfoType({
10255
- url: urlInfo.url,
10256
- contentType
10257
- });
10258
- urlInfo.subtype = subtype || reference.expectedSubtype || inferUrlInfoSubtype({
10259
- url: urlInfo.url,
10260
- type: urlInfo.type,
10261
- subtype: urlInfo.subtype
10262
- }); // during build urls info are reused and load returns originalUrl/originalContent
9811
+ urlInfo.type = type || reference.expectedType || inferUrlInfoType(contentType);
9812
+ urlInfo.subtype = subtype || reference.expectedSubtype || ""; // during build urls info are reused and load returns originalUrl/originalContent
10263
9813
 
10264
9814
  urlInfo.originalUrl = originalUrl || urlInfo.originalUrl;
10265
9815
  urlInfo.originalContent = originalContent === undefined ? content : originalContent;
@@ -10521,7 +10071,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
10521
10071
  } = urlInfo;
10522
10072
 
10523
10073
  if (generatedUrl && generatedUrl.startsWith("file:")) {
10524
- if (urlInfo.type === "directory") ; else {
10074
+ if (urlInfo.type === "directory") ; else if (urlInfo.content === null) ; else {
10525
10075
  writeFileSync(new URL(generatedUrl), urlInfo.content);
10526
10076
  const {
10527
10077
  sourcemapGeneratedUrl,
@@ -10727,8 +10277,8 @@ const adjustUrlSite = (urlInfo, {
10727
10277
  isOriginal: true,
10728
10278
  url: inlineUrlSite.url,
10729
10279
  content: inlineUrlSite.content,
10730
- line: inlineUrlSite.line + urlSite.line,
10731
- column: inlineUrlSite.column + urlSite.column
10280
+ line: inlineUrlSite.line === undefined ? urlSite.line : inlineUrlSite.line + urlSite.line,
10281
+ column: inlineUrlSite.column === undefined ? urlSite.column : inlineUrlSite.column + urlSite.column
10732
10282
  }, parentUrlInfo);
10733
10283
  };
10734
10284
 
@@ -10741,10 +10291,7 @@ const adjustUrlSite = (urlInfo, {
10741
10291
  }, urlInfo);
10742
10292
  };
10743
10293
 
10744
- const inferUrlInfoType = ({
10745
- url,
10746
- contentType
10747
- }) => {
10294
+ const inferUrlInfoType = contentType => {
10748
10295
  if (contentType === "text/html") {
10749
10296
  return "html";
10750
10297
  }
@@ -10754,12 +10301,6 @@ const inferUrlInfoType = ({
10754
10301
  }
10755
10302
 
10756
10303
  if (contentType === "text/javascript") {
10757
- const urlObject = new URL(url);
10758
-
10759
- if (urlObject.searchParams.has("js_classic")) {
10760
- return "js_classic";
10761
- }
10762
-
10763
10304
  return "js_module";
10764
10305
  }
10765
10306
 
@@ -10786,33 +10327,6 @@ const inferUrlInfoType = ({
10786
10327
  return "other";
10787
10328
  };
10788
10329
 
10789
- const inferUrlInfoSubtype = ({
10790
- type,
10791
- subtype,
10792
- url
10793
- }) => {
10794
- if (type === "js_classic" || type === "js_module") {
10795
- const urlObject = new URL(url);
10796
-
10797
- if (urlObject.searchParams.has("worker")) {
10798
- return "worker";
10799
- }
10800
-
10801
- if (urlObject.searchParams.has("service_worker")) {
10802
- return "service_worker";
10803
- }
10804
-
10805
- if (urlObject.searchParams.has("shared_worker")) {
10806
- return "shared_worker";
10807
- } // if we are currently inside a worker, all deps are consider inside worker too
10808
-
10809
-
10810
- return subtype;
10811
- }
10812
-
10813
- return "";
10814
- };
10815
-
10816
10330
  const determineFileUrlForOutDirectory = ({
10817
10331
  urlInfo,
10818
10332
  context
@@ -11140,6 +10654,56 @@ const createRepartitionMessage = ({
11140
10654
  - `)}`;
11141
10655
  };
11142
10656
 
10657
+ const jsenvPluginReferenceExpectedTypes = () => {
10658
+ const redirectJsUrls = reference => {
10659
+ const urlObject = new URL(reference.url);
10660
+ const {
10661
+ searchParams
10662
+ } = urlObject;
10663
+
10664
+ if (searchParams.has("entry_point")) {
10665
+ reference.isEntryPoint = true;
10666
+ }
10667
+
10668
+ if (searchParams.has("js_classic")) {
10669
+ searchParams.delete("js_classic");
10670
+ reference.expectedType = "js_classic";
10671
+ } else if (searchParams.has("as_js_classic") || searchParams.has("as_js_classic_library")) {
10672
+ reference.expectedType = "js_classic";
10673
+ } else if (searchParams.has("js_module")) {
10674
+ searchParams.delete("js_module");
10675
+ reference.expectedType = "js_module";
10676
+ } else if (reference.type === "js_url_specifier" && reference.expectedType === undefined && CONTENT_TYPE.fromUrlExtension(reference.url) === "text/javascript") {
10677
+ // by default, js referenced by new URL is considered as "js_module"
10678
+ // in case this is not desired code must use "?js_classic" like
10679
+ // new URL('./file.js?js_classic', import.meta.url)
10680
+ reference.expectedType = "js_module";
10681
+ }
10682
+
10683
+ if (searchParams.has("worker")) {
10684
+ reference.expectedSubtype = "worker";
10685
+ searchParams.delete("worker");
10686
+ } else if (searchParams.has("service_worker")) {
10687
+ reference.expectedSubtype = "service_worker";
10688
+ searchParams.delete("service_worker");
10689
+ } else if (searchParams.has("shared_worker")) {
10690
+ reference.expectedSubtype = "shared_worker";
10691
+ searchParams.delete("shared_worker");
10692
+ }
10693
+
10694
+ return urlObject.href;
10695
+ };
10696
+
10697
+ return {
10698
+ name: "jsenv:reference_expected_types",
10699
+ appliesDuring: "*",
10700
+ redirectUrl: {
10701
+ script_src: redirectJsUrls,
10702
+ js_url_specifier: redirectJsUrls
10703
+ }
10704
+ };
10705
+ };
10706
+
11143
10707
  const parseAndTransformHtmlUrls = async (urlInfo, context) => {
11144
10708
  const url = urlInfo.originalUrl;
11145
10709
  const content = urlInfo.content;
@@ -11621,7 +11185,7 @@ const jsenvPluginUrlAnalysis = ({
11621
11185
  };
11622
11186
  }
11623
11187
 
11624
- return {
11188
+ return [{
11625
11189
  name: "jsenv:url_analysis",
11626
11190
  appliesDuring: "*",
11627
11191
  redirectUrl: reference => {
@@ -11680,7 +11244,7 @@ const jsenvPluginUrlAnalysis = ({
11680
11244
  });
11681
11245
  }
11682
11246
  }
11683
- };
11247
+ }, jsenvPluginReferenceExpectedTypes()];
11684
11248
  };
11685
11249
 
11686
11250
  const findOriginalDirectoryReference = (urlInfo, context) => {
@@ -16916,10 +16480,25 @@ const convertJsModuleToJsClassic = async ({
16916
16480
 
16917
16481
  if (systemJsInjection && jsClassicFormat === "system" && urlInfo.isEntryPoint) {
16918
16482
  const magicSource = createMagicSource(code);
16919
- const systemjsCode = readFileSync(systemJsClientFileUrl, {
16483
+ let systemJsFileContent = readFileSync(systemJsClientFileUrl, {
16920
16484
  as: "string"
16921
16485
  });
16922
- magicSource.prepend(`${systemjsCode}\n\n`);
16486
+ const sourcemapFound = SOURCEMAP.readComment({
16487
+ contentType: "text/javascript",
16488
+ content: systemJsFileContent
16489
+ });
16490
+
16491
+ if (sourcemapFound) {
16492
+ // for now let's remove s.js sourcemap
16493
+ // because it would likely mess the sourcemap of the entry point itself
16494
+ systemJsFileContent = SOURCEMAP.writeComment({
16495
+ contentType: "text/javascript",
16496
+ content: systemJsFileContent,
16497
+ specifier: ""
16498
+ });
16499
+ }
16500
+
16501
+ magicSource.prepend(`${systemJsFileContent}\n\n`);
16923
16502
  const magicResult = magicSource.toContentAndSourcemap();
16924
16503
  sourcemap = await composeTwoSourcemaps(sourcemap, magicResult.sourcemap);
16925
16504
  return {
@@ -16943,14 +16522,31 @@ const jsenvPluginAsJsClassicConversion = ({
16943
16522
  systemJsClientFileUrl,
16944
16523
  generateJsClassicFilename
16945
16524
  }) => {
16525
+ const isReferencingJsModule = reference => {
16526
+ if (reference.type === "js_import_export" || reference.subtype === "system_register_arg" || reference.subtype === "system_import_arg") {
16527
+ return true;
16528
+ }
16529
+
16530
+ if (reference.type === "js_url_specifier" && reference.expectedType === "js_module") {
16531
+ return true;
16532
+ }
16533
+
16534
+ return false;
16535
+ };
16536
+
16946
16537
  const shouldPropagateJsClassic = (reference, context) => {
16947
- const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl);
16538
+ if (isReferencingJsModule(reference)) {
16539
+ const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl);
16948
16540
 
16949
- if (!parentUrlInfo) {
16950
- return false;
16541
+ if (!parentUrlInfo) {
16542
+ return false;
16543
+ }
16544
+
16545
+ const parentGotAsJsClassic = new URL(parentUrlInfo.url).searchParams.has("as_js_classic");
16546
+ return parentGotAsJsClassic;
16951
16547
  }
16952
16548
 
16953
- return new URL(parentUrlInfo.url).searchParams.has("as_js_classic");
16549
+ return false;
16954
16550
  };
16955
16551
 
16956
16552
  const markAsJsClassicProxy = reference => {
@@ -16973,18 +16569,16 @@ const jsenvPluginAsJsClassicConversion = ({
16973
16569
  if (reference.searchParams.has("as_js_classic")) {
16974
16570
  markAsJsClassicProxy(reference);
16975
16571
  return null;
16976
- }
16572
+ } // We want to propagate transformation of js module to js classic to:
16573
+ // - import specifier (static/dynamic import + re-export)
16574
+ // - url specifier when inside System.register/_context.import()
16575
+ // (because it's the transpiled equivalent of static and dynamic imports)
16576
+ // And not other references otherwise we could try to transform inline resources
16577
+ // or specifiers inside new URL()...
16977
16578
 
16978
- if (reference.type === "js_import_export" || reference.subtype === "system_register_arg" || reference.subtype === "system_import_arg") {
16979
- // We want to propagate transformation of js module to js classic to:
16980
- // - import specifier (static/dynamic import + re-export)
16981
- // - url specifier when inside System.register/_context.import()
16982
- // (because it's the transpiled equivalent of static and dynamic imports)
16983
- // And not other references otherwise we could try to transform inline resources
16984
- // or specifiers inside new URL()...
16985
- if (shouldPropagateJsClassic(reference, context)) {
16986
- return turnIntoJsClassicProxy(reference);
16987
- }
16579
+
16580
+ if (shouldPropagateJsClassic(reference, context)) {
16581
+ return turnIntoJsClassicProxy(reference);
16988
16582
  }
16989
16583
 
16990
16584
  return null;
@@ -17062,7 +16656,8 @@ const jsenvPluginAsJsClassicHtml = ({
17062
16656
  name: "jsenv:as_js_classic_html",
17063
16657
  appliesDuring: "*",
17064
16658
  init: context => {
17065
- shouldTransformScriptTypeModule = !context.isSupportedOnCurrentClients("script_type_module") || !context.isSupportedOnCurrentClients("import_dynamic") || !context.isSupportedOnCurrentClients("import_meta");
16659
+ const nodeRuntimeEnabled = Object.keys(context.runtimeCompat).includes("node");
16660
+ shouldTransformScriptTypeModule = nodeRuntimeEnabled ? false : !context.isSupportedOnCurrentClients("script_type_module") || !context.isSupportedOnCurrentClients("import_dynamic") || !context.isSupportedOnCurrentClients("import_meta");
17066
16661
  },
17067
16662
  redirectUrl: {
17068
16663
  link_href: reference => {
@@ -17081,6 +16676,13 @@ const jsenvPluginAsJsClassicHtml = ({
17081
16676
  return turnIntoJsClassicProxy(reference);
17082
16677
  }
17083
16678
 
16679
+ return null;
16680
+ },
16681
+ js_url_specifier: reference => {
16682
+ if (shouldTransformScriptTypeModule && reference.expectedType === "js_module") {
16683
+ return turnIntoJsClassicProxy(reference);
16684
+ }
16685
+
17084
16686
  return null;
17085
16687
  }
17086
16688
  },
@@ -17195,9 +16797,23 @@ const jsenvPluginAsJsClassicHtml = ({
17195
16797
 
17196
16798
  if (needsSystemJs) {
17197
16799
  mutations.push(async () => {
17198
- const systemJsFileContent = readFileSync$1(new URL(systemJsClientFileUrl), {
16800
+ let systemJsFileContent = readFileSync$1(new URL(systemJsClientFileUrl), {
17199
16801
  encoding: "utf8"
17200
16802
  });
16803
+ const sourcemapFound = SOURCEMAP.readComment({
16804
+ contentType: "text/javascript",
16805
+ content: systemJsFileContent
16806
+ });
16807
+
16808
+ if (sourcemapFound) {
16809
+ const sourcemapFileUrl = new URL(sourcemapFound.specifier, systemJsClientFileUrl);
16810
+ systemJsFileContent = SOURCEMAP.writeComment({
16811
+ contentType: "text/javascript",
16812
+ content: systemJsFileContent,
16813
+ specifier: urlToRelativeUrl(sourcemapFileUrl, urlInfo.url)
16814
+ });
16815
+ }
16816
+
17201
16817
  const [systemJsReference, systemJsUrlInfo] = context.referenceUtils.inject({
17202
16818
  type: "script_src",
17203
16819
  expectedType: "js_classic",
@@ -17471,24 +17087,34 @@ const rollupPluginJsenv = ({
17471
17087
  const rollupFileInfo = rollupResult[fileName]; // there is 3 types of file: "placeholder", "asset", "chunk"
17472
17088
 
17473
17089
  if (rollupFileInfo.type === "chunk") {
17090
+ const sourceUrls = Object.keys(rollupFileInfo.modules).map(id => fileUrlConverter.asFileUrl(id));
17474
17091
  let url;
17092
+ let originalUrl;
17475
17093
 
17476
17094
  if (rollupFileInfo.facadeModuleId) {
17477
17095
  url = fileUrlConverter.asFileUrl(rollupFileInfo.facadeModuleId);
17096
+ originalUrl = url;
17478
17097
  } else {
17479
17098
  url = new URL(rollupFileInfo.fileName, buildDirectoryUrl).href;
17099
+
17100
+ if (rollupFileInfo.isDynamicEntry) {
17101
+ originalUrl = sourceUrls[sourceUrls.length - 1];
17102
+ } else {
17103
+ originalUrl = url;
17104
+ }
17480
17105
  }
17481
17106
 
17482
17107
  const jsModuleBundleUrlInfo = {
17483
17108
  url,
17484
- originalUrl: url,
17109
+ originalUrl,
17485
17110
  type: format === "esm" ? "js_module" : "common_js",
17486
17111
  data: {
17487
17112
  generatedBy: "rollup",
17488
17113
  bundleRelativeUrl: rollupFileInfo.fileName,
17489
- usesImport: rollupFileInfo.imports.length > 0 || rollupFileInfo.dynamicImports.length > 0
17114
+ usesImport: rollupFileInfo.imports.length > 0 || rollupFileInfo.dynamicImports.length > 0,
17115
+ isDynamicEntry: rollupFileInfo.isDynamicEntry
17490
17116
  },
17491
- sourceUrls: Object.keys(rollupFileInfo.modules).map(id => fileUrlConverter.asFileUrl(id)),
17117
+ sourceUrls,
17492
17118
  contentType: "text/javascript",
17493
17119
  content: rollupFileInfo.code,
17494
17120
  sourcemap: rollupFileInfo.map
@@ -17713,7 +17339,7 @@ const buildWithRollup = async ({
17713
17339
  return resultRef.current;
17714
17340
  } catch (e) {
17715
17341
  if (e.code === "MISSING_EXPORT") {
17716
- const detailedMessage = createDetailedMessage$2(e.message, {
17342
+ const detailedMessage = createDetailedMessage$1(e.message, {
17717
17343
  frame: e.frame
17718
17344
  });
17719
17345
  throw new Error(detailedMessage, {
@@ -24278,7 +23904,7 @@ const build = async ({
24278
23904
  signal,
24279
23905
  logLevel
24280
23906
  }) => {
24281
- const logger = createLogger$1({
23907
+ const logger = createLogger({
24282
23908
  logLevel
24283
23909
  });
24284
23910
  const buildOperation = Abort.startOperation();
@@ -24347,7 +23973,7 @@ build ${entryPointKeys.length} entry points`);
24347
23973
  const buildUrlsGenerator = createBuilUrlsGenerator({
24348
23974
  buildDirectoryUrl
24349
23975
  });
24350
- const buildToRawUrls = {}; // rename "buildDirectoryRedirections"?
23976
+ const buildDirectoryRedirections = new Map();
24351
23977
 
24352
23978
  const associateBuildUrlAndRawUrl = (buildUrl, rawUrl, reason) => {
24353
23979
  if (urlIsInsideOf(rawUrl, buildDirectoryUrl)) {
@@ -24358,7 +23984,7 @@ build ${entryPointKeys.length} entry points`);
24358
23984
  ${ANSI.color(rawUrl, ANSI.GREY)} ->
24359
23985
  ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24360
23986
  `);
24361
- buildToRawUrls[buildUrl] = rawUrl;
23987
+ buildDirectoryRedirections.set(buildUrl, rawUrl);
24362
23988
  };
24363
23989
 
24364
23990
  const buildUrls = new Map();
@@ -24389,7 +24015,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24389
24015
  resolveUrl: reference => {
24390
24016
  const getUrl = () => {
24391
24017
  if (reference.type === "filesystem") {
24392
- const parentRawUrl = buildToRawUrls[reference.parentUrl];
24018
+ const parentRawUrl = buildDirectoryRedirections.get(reference.parentUrl);
24393
24019
  const baseUrl = ensurePathnameTrailingSlash(parentRawUrl);
24394
24020
  return new URL(reference.specifier, baseUrl).href;
24395
24021
  }
@@ -24420,7 +24046,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24420
24046
  } // already a build url
24421
24047
 
24422
24048
 
24423
- const rawUrl = buildToRawUrls[reference.url];
24049
+ const rawUrl = buildDirectoryRedirections.get(reference.url);
24424
24050
 
24425
24051
  if (rawUrl) {
24426
24052
  return reference.url;
@@ -24590,14 +24216,14 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24590
24216
  return bundleUrlInfo;
24591
24217
  }
24592
24218
 
24593
- const rawUrl = buildToRawUrls[url] || url;
24219
+ const rawUrl = buildDirectoryRedirections.get(url) || url;
24594
24220
  const rawUrlInfo = rawGraph.getUrlInfo(rawUrl);
24595
24221
 
24596
24222
  if (!rawUrlInfo) {
24597
- throw new Error(createDetailedMessage$2(`Cannot find url`, {
24223
+ throw new Error(createDetailedMessage$1(`Cannot find url`, {
24598
24224
  url,
24599
- "raw urls": Object.values(buildToRawUrls),
24600
- "build urls": Object.keys(buildToRawUrls)
24225
+ "raw urls": Array.from(buildDirectoryRedirections.values()),
24226
+ "build urls": Array.from(buildDirectoryRedirections.keys())
24601
24227
  }));
24602
24228
  } // logger.debug(`fetching from raw graph ${url}`)
24603
24229
 
@@ -24626,7 +24252,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24626
24252
 
24627
24253
  if (reference.injected) {
24628
24254
  const [ref, rawUrlInfo] = rawGraphKitchen.injectReference({ ...reference,
24629
- parentUrl: buildToRawUrls[reference.parentUrl]
24255
+ parentUrl: buildDirectoryRedirections.get(reference.parentUrl)
24630
24256
  });
24631
24257
  await rawGraphKitchen.cook(rawUrlInfo, {
24632
24258
  reference: ref
@@ -24657,7 +24283,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24657
24283
  }],
24658
24284
  sourcemaps,
24659
24285
  sourcemapsSourcesContent,
24660
- sourcemapsRelativeSources: !versioning,
24286
+ sourcemapsSourcesRelative: !versioning,
24661
24287
  writeGeneratedFiles,
24662
24288
  outDirectoryUrl: new URL(".jsenv/postbuild/", rootDirectoryUrl)
24663
24289
  });
@@ -24841,10 +24467,10 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24841
24467
 
24842
24468
  if (bundlerGeneratedUrlInfo.sourceUrls) {
24843
24469
  bundlerGeneratedUrlInfo.sourceUrls.forEach(sourceUrl => {
24844
- const rawUrlInfo = rawGraph.getUrlInfo(sourceUrl);
24470
+ const sourceRawUrlInfo = rawGraph.getUrlInfo(sourceUrl);
24845
24471
 
24846
- if (rawUrlInfo) {
24847
- rawUrlInfo.data.bundled = true;
24472
+ if (sourceRawUrlInfo) {
24473
+ sourceRawUrlInfo.data.bundled = true;
24848
24474
  }
24849
24475
  });
24850
24476
  }
@@ -24854,7 +24480,14 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
24854
24480
  });
24855
24481
  bundleRedirections.set(url, buildUrl);
24856
24482
 
24857
- if (urlIsInsideOf(url, buildDirectoryUrl)) {// chunk generated by rollup to share code
24483
+ if (urlIsInsideOf(url, buildDirectoryUrl)) {
24484
+ if (bundlerGeneratedUrlInfo.data.isDynamicEntry) {
24485
+ const rawUrlInfo = rawGraph.getUrlInfo(bundlerGeneratedUrlInfo.originalUrl);
24486
+ rawUrlInfo.data.bundled = false;
24487
+ bundleRedirections.set(bundlerGeneratedUrlInfo.originalUrl, buildUrl);
24488
+ associateBuildUrlAndRawUrl(buildUrl, bundlerGeneratedUrlInfo.originalUrl, "bundle");
24489
+ } else {// chunk generated by rollup to share code
24490
+ }
24858
24491
  } else {
24859
24492
  associateBuildUrlAndRawUrl(buildUrl, url, "bundle");
24860
24493
  }
@@ -25117,7 +24750,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
25117
24750
  },
25118
24751
  fetchUrlContent: versionedUrlInfo => {
25119
24752
  if (versionedUrlInfo.isInline) {
25120
- const rawUrlInfo = rawGraph.getUrlInfo(buildToRawUrls[versionedUrlInfo.url]);
24753
+ const rawUrlInfo = rawGraph.getUrlInfo(buildDirectoryRedirections.get(versionedUrlInfo.url));
25121
24754
  const finalUrlInfo = finalGraph.getUrlInfo(versionedUrlInfo.url);
25122
24755
  return {
25123
24756
  content: versionedUrlInfo.content,
@@ -25132,7 +24765,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
25132
24765
  }],
25133
24766
  sourcemaps,
25134
24767
  sourcemapsSourcesContent,
25135
- sourcemapsRelativeSources: true,
24768
+ sourcemapsSourcesRelative: true,
25136
24769
  writeGeneratedFiles,
25137
24770
  outDirectoryUrl: new URL(".jsenv/postbuild/", finalGraphKitchen.rootDirectoryUrl)
25138
24771
  });
@@ -25202,7 +24835,8 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
25202
24835
  /*
25203
24836
  * Update <link rel="preload"> and friends after build (once we know everything)
25204
24837
  * - Used to remove resource hint targeting an url that is no longer used:
25205
- * - Happens because of import assertions transpilation (file is inlined into JS)
24838
+ * - because of bundlings
24839
+ * - because of import assertions transpilation (file is inlined into JS)
25206
24840
  */
25207
24841
 
25208
24842
 
@@ -25245,7 +24879,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
25245
24879
  }
25246
24880
 
25247
24881
  if (buildUrlInfo.dependents.size === 0) {
25248
- logger.info(`remove resource hint because "${href}" not used anymore`);
24882
+ logger.warn(`remove resource hint because "${href}" not used anymore`);
25249
24883
  mutations.push(() => {
25250
24884
  removeHtmlNode(node);
25251
24885
  });
@@ -25268,7 +24902,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
25268
24902
  const rawUrlInfo = rawGraph.getUrlInfo(url);
25269
24903
 
25270
24904
  if (rawUrlInfo && rawUrlInfo.data.bundled) {
25271
- logger.info(`remove resource hint on "${href}" because it was bundled`);
24905
+ logger.warn(`remove resource hint on "${href}" because it was bundled`);
25272
24906
  mutations.push(() => {
25273
24907
  removeHtmlNode(node);
25274
24908
  });
@@ -25276,6 +24910,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
25276
24910
  url = bundleRedirections.get(url) || url;
25277
24911
  url = bundleInternalRedirections.get(url) || url;
25278
24912
  url = finalRedirections.get(url) || url;
24913
+ url = findKey(buildDirectoryRedirections, url) || url;
25279
24914
  onBuildUrl(url);
25280
24915
  }
25281
24916
  } else {
@@ -25897,7 +25532,18 @@ const createFileService = ({
25897
25532
  }
25898
25533
 
25899
25534
  if (!watch) {
25900
- const fileContentAsBuffer = readFileSync$1(new URL(urlInfo.url));
25535
+ let fileContentAsBuffer;
25536
+
25537
+ try {
25538
+ fileContentAsBuffer = readFileSync$1(new URL(urlInfo.url));
25539
+ } catch (e) {
25540
+ if (e.code === "ENOENT") {
25541
+ return false;
25542
+ }
25543
+
25544
+ return false;
25545
+ }
25546
+
25901
25547
  const fileContentEtag = bufferToEtag$1(fileContentAsBuffer);
25902
25548
 
25903
25549
  if (fileContentEtag !== urlInfo.originalContentEtag) {
@@ -26018,27 +25664,27 @@ const createFileService = ({
26018
25664
  const ifNoneMatch = request.headers["if-none-match"];
26019
25665
  const urlInfoTargetedByCache = urlGraph.getParentIfInline(urlInfo);
26020
25666
 
26021
- if (ifNoneMatch) {
26022
- const [clientOriginalContentEtag, clientContentEtag] = ifNoneMatch.split("_");
25667
+ try {
25668
+ if (ifNoneMatch) {
25669
+ const [clientOriginalContentEtag, clientContentEtag] = ifNoneMatch.split("_");
25670
+
25671
+ if (urlInfoTargetedByCache.originalContentEtag === clientOriginalContentEtag && urlInfoTargetedByCache.contentEtag === clientContentEtag && urlInfoTargetedByCache.isValid()) {
25672
+ const headers = {
25673
+ "cache-control": `private,max-age=0,must-revalidate`
25674
+ };
25675
+ Object.keys(urlInfo.headers).forEach(key => {
25676
+ if (key !== "content-length") {
25677
+ headers[key] = urlInfo.headers[key];
25678
+ }
25679
+ });
25680
+ return {
25681
+ status: 304,
25682
+ headers
25683
+ };
25684
+ }
25685
+ } // urlInfo objects are reused, they must be "reset" before cooking them again
26023
25686
 
26024
- if (urlInfoTargetedByCache.originalContentEtag === clientOriginalContentEtag && urlInfoTargetedByCache.contentEtag === clientContentEtag && urlInfoTargetedByCache.isValid()) {
26025
- const headers = {
26026
- "cache-control": `private,max-age=0,must-revalidate`
26027
- };
26028
- Object.keys(urlInfo.headers).forEach(key => {
26029
- if (key !== "content-length") {
26030
- headers[key] = urlInfo.headers[key];
26031
- }
26032
- });
26033
- return {
26034
- status: 304,
26035
- headers
26036
- };
26037
- }
26038
- }
26039
25687
 
26040
- try {
26041
- // urlInfo objects are reused, they must be "reset" before cooking them again
26042
25688
  if ((urlInfo.error || urlInfo.contentEtag) && !urlInfo.isInline && urlInfo.type !== "sourcemap") {
26043
25689
  urlInfo.error = null;
26044
25690
  urlInfo.sourcemap = null;
@@ -26231,7 +25877,7 @@ const startDevServer = async ({
26231
25877
  // and mitigates https://github.com/actions/runner-images/issues/3885
26232
25878
  writeGeneratedFiles = !process.env.CI
26233
25879
  }) => {
26234
- const logger = createLogger$1({
25880
+ const logger = createLogger({
26235
25881
  logLevel
26236
25882
  });
26237
25883
  rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
@@ -26577,7 +26223,7 @@ const readNodeV8CoverageDirectory = async ({
26577
26223
  return tryReadJsonFile();
26578
26224
  }
26579
26225
 
26580
- console.warn(createDetailedMessage$2(`Error while reading coverage file`, {
26226
+ console.warn(createDetailedMessage$1(`Error while reading coverage file`, {
26581
26227
  "error stack": e.stack,
26582
26228
  "file": dirEntryUrl
26583
26229
  }));
@@ -26751,7 +26397,7 @@ const composeV8AndIstanbul = (v8FileByFileCoverage, istanbulFileByFileCoverage,
26751
26397
 
26752
26398
  if (v8Coverage) {
26753
26399
  if (coverageV8ConflictWarning) {
26754
- console.warn(createDetailedMessage$2(`Coverage conflict on "${key}", found two coverage that cannot be merged together: v8 and istanbul. The istanbul coverage will be ignored.`, {
26400
+ console.warn(createDetailedMessage$1(`Coverage conflict on "${key}", found two coverage that cannot be merged together: v8 and istanbul. The istanbul coverage will be ignored.`, {
26755
26401
  details: `This happens when a file is executed on a runtime using v8 coverage (node or chromium) and on runtime using istanbul coverage (firefox or webkit)`,
26756
26402
  suggestion: "You can disable this warning with coverageV8ConflictWarning: false"
26757
26403
  }));
@@ -27278,7 +26924,7 @@ const generateFileExecutionSteps = ({
27278
26924
  }
27279
26925
 
27280
26926
  if (typeof stepConfig !== "object") {
27281
- throw new TypeError(createDetailedMessage$2(`found unexpected value in plan, they must be object`, {
26927
+ throw new TypeError(createDetailedMessage$1(`found unexpected value in plan, they must be object`, {
27282
26928
  ["file relative path"]: fileRelativeUrl,
27283
26929
  ["execution name"]: executionName,
27284
26930
  ["value"]: stepConfig
@@ -27746,7 +27392,7 @@ const executePlan = async (plan, {
27746
27392
  }
27747
27393
  });
27748
27394
  });
27749
- logger.debug(createDetailedMessage$2(`Prepare executing plan`, {
27395
+ logger.debug(createDetailedMessage$1(`Prepare executing plan`, {
27750
27396
  runtimes: JSON.stringify(runtimes, null, " ")
27751
27397
  }));
27752
27398
  const multipleExecutionsOperation = Abort.startOperation();
@@ -27778,7 +27424,7 @@ const executePlan = async (plan, {
27778
27424
  await ensureEmptyDirectory(process.env.NODE_V8_COVERAGE);
27779
27425
  } else {
27780
27426
  coverageMethodForNodeJs = "Profiler";
27781
- logger.warn(createDetailedMessage$2(`process.env.NODE_V8_COVERAGE is required to generate coverage for Node.js subprocesses`, {
27427
+ logger.warn(createDetailedMessage$1(`process.env.NODE_V8_COVERAGE is required to generate coverage for Node.js subprocesses`, {
27782
27428
  "suggestion": `set process.env.NODE_V8_COVERAGE`,
27783
27429
  "suggestion 2": `use coverageMethodForNodeJs: "Profiler". But it means coverage for child_process and worker_thread cannot be collected`
27784
27430
  }));
@@ -28251,7 +27897,7 @@ const executeTestPlan = async ({
28251
27897
  coverageReportJsonFile = process.env.CI ? null : "./.coverage/coverage.json",
28252
27898
  coverageReportHtmlDirectory = process.env.CI ? "./.coverage/" : null
28253
27899
  }) => {
28254
- const logger = createLogger$1({
27900
+ const logger = createLogger({
28255
27901
  logLevel
28256
27902
  });
28257
27903
  rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
@@ -28288,7 +27934,7 @@ const executeTestPlan = async ({
28288
27934
 
28289
27935
  if (patternsMatchingCoverAndExecute.length) {
28290
27936
  // It would be strange, for a given file to be both covered and executed
28291
- throw new Error(createDetailedMessage$2(`some file will be both covered and executed`, {
27937
+ throw new Error(createDetailedMessage$1(`some file will be both covered and executed`, {
28292
27938
  patterns: patternsMatchingCoverAndExecute
28293
27939
  }));
28294
27940
  }
@@ -28838,7 +28484,7 @@ const importPlaywright = async ({
28838
28484
  return namespace;
28839
28485
  } catch (e) {
28840
28486
  if (e.code === "ERR_MODULE_NOT_FOUND") {
28841
- throw new Error(createDetailedMessage$2(`"playwright" not found. You need playwright in your dependencies to use "${browserName}"`, {
28487
+ throw new Error(createDetailedMessage$1(`"playwright" not found. You need playwright in your dependencies to use "${browserName}"`, {
28842
28488
  suggestion: `npm install --save-dev playwright`
28843
28489
  }), {
28844
28490
  cause: e
@@ -29006,7 +28652,7 @@ const createChildExecOptions = async ({
29006
28652
  debugModeInheritBreak = true
29007
28653
  } = {}) => {
29008
28654
  if (typeof debugMode === "string" && AVAILABLE_DEBUG_MODE.indexOf(debugMode) === -1) {
29009
- throw new TypeError(createDetailedMessage$2(`unexpected debug mode.`, {
28655
+ throw new TypeError(createDetailedMessage$1(`unexpected debug mode.`, {
29010
28656
  ["debug mode"]: debugMode,
29011
28657
  ["allowed debug mode"]: AVAILABLE_DEBUG_MODE
29012
28658
  }));
@@ -29303,7 +28949,7 @@ nodeChildProcess.run = async ({
29303
28949
  stdio: ["pipe", "pipe", "pipe", "ipc"],
29304
28950
  env: envForChildProcess
29305
28951
  });
29306
- logger.debug(createDetailedMessage$2(`child process forked (pid ${childProcess.pid})`, {
28952
+ logger.debug(createDetailedMessage$1(`child process forked (pid ${childProcess.pid})`, {
29307
28953
  "execArgv": execArgv.join(`\n`),
29308
28954
  "custom env": JSON.stringify(env, null, " ")
29309
28955
  })); // if we pass stream, pipe them https://github.com/sindresorhus/execa/issues/81
@@ -29901,7 +29547,7 @@ const startBuildServer = async ({
29901
29547
  buildServerMainFile = getCallerPosition().url,
29902
29548
  cooldownBetweenFileEvents
29903
29549
  }) => {
29904
- const logger = createLogger$1({
29550
+ const logger = createLogger({
29905
29551
  logLevel
29906
29552
  });
29907
29553
  rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
@@ -30045,6 +29691,12 @@ const startBuildServer = async ({
30045
29691
  })]
30046
29692
  });
30047
29693
  startBuildServerTask.done();
29694
+
29695
+ if (hostname) {
29696
+ delete server.origins.localip;
29697
+ delete server.origins.externalip;
29698
+ }
29699
+
30048
29700
  logger.info(``);
30049
29701
  Object.keys(server.origins).forEach(key => {
30050
29702
  logger.info(`- ${server.origins[key]}`);
@@ -30126,7 +29778,7 @@ const execute = async ({
30126
29778
  runtimeParams,
30127
29779
  ignoreError = false
30128
29780
  }) => {
30129
- const logger = createLogger$1({
29781
+ const logger = createLogger({
30130
29782
  logLevel
30131
29783
  });
30132
29784
  rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);