@jsenv/core 38.4.7 → 38.4.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.
@@ -44,7 +44,10 @@ function AsyncFromSyncIterator(s) {
44
44
  },
45
45
  throw: function (value) {
46
46
  var thr = this.s.return;
47
- if (thr === undefined) return Promise.reject(value);
47
+ if (thr === undefined) {
48
+ // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
49
+ return Promise.reject(maybeError);
50
+ }
48
51
  return AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
49
52
  },
50
53
  };
@@ -11,7 +11,7 @@ export default function _isNativeReflectConstruct() {
11
11
  var result = !Boolean.prototype.valueOf.call(
12
12
  Reflect.construct(Boolean, [], function () {}),
13
13
  );
14
- } catch (e) {}
14
+ } catch (_) {}
15
15
  // @ts-expect-error assign to function
16
16
  return (_isNativeReflectConstruct = function () {
17
17
  return !!result;
@@ -10,7 +10,7 @@ export default (source, excluded) => {
10
10
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
11
11
  for (i = 0; i < sourceSymbolKeys.length; i++) {
12
12
  key = sourceSymbolKeys[i];
13
- if (excluded.indexOf(key) >= 0) continue;
13
+ if (excluded.includes(key)) continue;
14
14
  if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
15
15
  target[key] = source[key];
16
16
  }
@@ -6,7 +6,7 @@ export default (source, excluded) => {
6
6
  var i;
7
7
  for (i = 0; i < sourceKeys.length; i++) {
8
8
  key = sourceKeys[i];
9
- if (excluded.indexOf(key) >= 0) continue;
9
+ if (excluded.includes(key)) continue;
10
10
  target[key] = source[key];
11
11
  }
12
12
  return target;
@@ -3,6 +3,7 @@
3
3
  // https://tc39.es/ecma262/#sec-setfunctionname
4
4
  export default function setFunctionName(fn, name, prefix) {
5
5
  if (typeof name === "symbol") {
6
+ // Here `undefined` is possible, we check for it in the next line.
6
7
  name = name.description;
7
8
  name = name ? "[" + name + "]" : "";
8
9
  }
@@ -1,4 +1,3 @@
1
- export default function (name) {
2
- // eslint-disable-next-line prefer-template
3
- throw new TypeError(name + " is write-only");
1
+ export default function _writeOnlyError(name) {
2
+ throw new TypeError('"' + name + '" is write-only');
4
3
  }
package/dist/js/ws.js CHANGED
@@ -876,13 +876,6 @@ const { concat, toArrayBuffer, unmask } = bufferUtilExports;
876
876
  const { isValidStatusCode: isValidStatusCode$1, isValidUTF8 } = validationExports;
877
877
 
878
878
  const FastBuffer = Buffer[Symbol.species];
879
- const promise = Promise.resolve();
880
-
881
- //
882
- // `queueMicrotask()` is not available in Node.js < 11.
883
- //
884
- const queueTask =
885
- typeof queueMicrotask === 'function' ? queueMicrotask : queueMicrotaskShim;
886
879
 
887
880
  const GET_INFO = 0;
888
881
  const GET_PAYLOAD_LENGTH_16 = 1;
@@ -902,7 +895,7 @@ let Receiver$1 = class Receiver extends Writable {
902
895
  * Creates a Receiver instance.
903
896
  *
904
897
  * @param {Object} [options] Options object
905
- * @param {Boolean} [options.allowSynchronousEvents=false] Specifies whether
898
+ * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
906
899
  * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
907
900
  * multiple times in the same tick
908
901
  * @param {String} [options.binaryType=nodebuffer] The type for binary data
@@ -917,7 +910,10 @@ let Receiver$1 = class Receiver extends Writable {
917
910
  constructor(options = {}) {
918
911
  super();
919
912
 
920
- this._allowSynchronousEvents = !!options.allowSynchronousEvents;
913
+ this._allowSynchronousEvents =
914
+ options.allowSynchronousEvents !== undefined
915
+ ? options.allowSynchronousEvents
916
+ : true;
921
917
  this._binaryType = options.binaryType || BINARY_TYPES$1[0];
922
918
  this._extensions = options.extensions || {};
923
919
  this._isServer = !!options.isServer;
@@ -1430,17 +1426,12 @@ let Receiver$1 = class Receiver extends Writable {
1430
1426
  data = fragments;
1431
1427
  }
1432
1428
 
1433
- //
1434
- // If the state is `INFLATING`, it means that the frame data was
1435
- // decompressed asynchronously, so there is no need to defer the event
1436
- // as it will be emitted asynchronously anyway.
1437
- //
1438
- if (this._state === INFLATING || this._allowSynchronousEvents) {
1429
+ if (this._allowSynchronousEvents) {
1439
1430
  this.emit('message', data, true);
1440
1431
  this._state = GET_INFO;
1441
1432
  } else {
1442
1433
  this._state = DEFER_EVENT;
1443
- queueTask(() => {
1434
+ setImmediate(() => {
1444
1435
  this.emit('message', data, true);
1445
1436
  this._state = GET_INFO;
1446
1437
  this.startLoop(cb);
@@ -1467,7 +1458,7 @@ let Receiver$1 = class Receiver extends Writable {
1467
1458
  this._state = GET_INFO;
1468
1459
  } else {
1469
1460
  this._state = DEFER_EVENT;
1470
- queueTask(() => {
1461
+ setImmediate(() => {
1471
1462
  this.emit('message', buf, false);
1472
1463
  this._state = GET_INFO;
1473
1464
  this.startLoop(cb);
@@ -1538,7 +1529,7 @@ let Receiver$1 = class Receiver extends Writable {
1538
1529
  this._state = GET_INFO;
1539
1530
  } else {
1540
1531
  this._state = DEFER_EVENT;
1541
- queueTask(() => {
1532
+ setImmediate(() => {
1542
1533
  this.emit(this._opcode === 0x09 ? 'ping' : 'pong', data);
1543
1534
  this._state = GET_INFO;
1544
1535
  this.startLoop(cb);
@@ -1575,35 +1566,6 @@ let Receiver$1 = class Receiver extends Writable {
1575
1566
 
1576
1567
  var receiver = Receiver$1;
1577
1568
 
1578
- /**
1579
- * A shim for `queueMicrotask()`.
1580
- *
1581
- * @param {Function} cb Callback
1582
- */
1583
- function queueMicrotaskShim(cb) {
1584
- promise.then(cb).catch(throwErrorNextTick);
1585
- }
1586
-
1587
- /**
1588
- * Throws an error.
1589
- *
1590
- * @param {Error} err The error to throw
1591
- * @private
1592
- */
1593
- function throwError(err) {
1594
- throw err;
1595
- }
1596
-
1597
- /**
1598
- * Throws an error in the next tick.
1599
- *
1600
- * @param {Error} err The error to throw
1601
- * @private
1602
- */
1603
- function throwErrorNextTick(err) {
1604
- process.nextTick(throwError, err);
1605
- }
1606
-
1607
1569
  /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex" }] */
1608
1570
  const { randomFillSync } = require$$1;
1609
1571
 
@@ -1614,6 +1576,9 @@ const { mask: applyMask, toBuffer: toBuffer$1 } = bufferUtilExports;
1614
1576
 
1615
1577
  const kByteLength = Symbol('kByteLength');
1616
1578
  const maskBuffer = Buffer.alloc(4);
1579
+ const RANDOM_POOL_SIZE = 8 * 1024;
1580
+ let randomPool;
1581
+ let randomPoolPointer = RANDOM_POOL_SIZE;
1617
1582
 
1618
1583
  /**
1619
1584
  * HyBi Sender implementation.
@@ -1678,7 +1643,24 @@ let Sender$1 = class Sender {
1678
1643
  if (options.generateMask) {
1679
1644
  options.generateMask(mask);
1680
1645
  } else {
1681
- randomFillSync(mask, 0, 4);
1646
+ if (randomPoolPointer === RANDOM_POOL_SIZE) {
1647
+ /* istanbul ignore else */
1648
+ if (randomPool === undefined) {
1649
+ //
1650
+ // This is lazily initialized because server-sent frames must not
1651
+ // be masked so it may never be used.
1652
+ //
1653
+ randomPool = Buffer.alloc(RANDOM_POOL_SIZE);
1654
+ }
1655
+
1656
+ randomFillSync(randomPool, 0, RANDOM_POOL_SIZE);
1657
+ randomPoolPointer = 0;
1658
+ }
1659
+
1660
+ mask[0] = randomPool[randomPoolPointer++];
1661
+ mask[1] = randomPool[randomPoolPointer++];
1662
+ mask[2] = randomPool[randomPoolPointer++];
1663
+ mask[3] = randomPool[randomPoolPointer++];
1682
1664
  }
1683
1665
 
1684
1666
  skipMasking = (mask[0] | mask[1] | mask[2] | mask[3]) === 0;
@@ -2571,7 +2553,7 @@ function format$1(extensions) {
2571
2553
 
2572
2554
  var extension$1 = { format: format$1, parse: parse$2 };
2573
2555
 
2574
- /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex|Readable$" }] */
2556
+ /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex|Readable$", "caughtErrors": "none" }] */
2575
2557
 
2576
2558
  const EventEmitter$1 = require$$0$3;
2577
2559
  const https = require$$1$1;
@@ -3193,7 +3175,7 @@ var websocket = WebSocket$1;
3193
3175
  * @param {(String|URL)} address The URL to which to connect
3194
3176
  * @param {Array} protocols The subprotocols
3195
3177
  * @param {Object} [options] Connection options
3196
- * @param {Boolean} [options.allowSynchronousEvents=false] Specifies whether any
3178
+ * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether any
3197
3179
  * of the `'message'`, `'ping'`, and `'pong'` events can be emitted multiple
3198
3180
  * times in the same tick
3199
3181
  * @param {Boolean} [options.autoPong=true] Specifies whether or not to
@@ -3222,7 +3204,7 @@ var websocket = WebSocket$1;
3222
3204
  */
3223
3205
  function initAsClient(websocket, address, protocols, options) {
3224
3206
  const opts = {
3225
- allowSynchronousEvents: false,
3207
+ allowSynchronousEvents: true,
3226
3208
  autoPong: true,
3227
3209
  protocolVersion: protocolVersions[1],
3228
3210
  maxPayload: 100 * 1024 * 1024,
@@ -3231,7 +3213,6 @@ function initAsClient(websocket, address, protocols, options) {
3231
3213
  followRedirects: false,
3232
3214
  maxRedirects: 10,
3233
3215
  ...options,
3234
- createConnection: undefined,
3235
3216
  socketPath: undefined,
3236
3217
  hostname: undefined,
3237
3218
  protocol: undefined,
@@ -3302,7 +3283,8 @@ function initAsClient(websocket, address, protocols, options) {
3302
3283
  const protocolSet = new Set();
3303
3284
  let perMessageDeflate;
3304
3285
 
3305
- opts.createConnection = isSecure ? tlsConnect : netConnect;
3286
+ opts.createConnection =
3287
+ opts.createConnection || (isSecure ? tlsConnect : netConnect);
3306
3288
  opts.defaultPort = opts.defaultPort || defaultPort;
3307
3289
  opts.port = parsedUrl.port || defaultPort;
3308
3290
  opts.host = parsedUrl.hostname.startsWith('[')
@@ -3498,7 +3480,9 @@ function initAsClient(websocket, address, protocols, options) {
3498
3480
 
3499
3481
  req = websocket._req = null;
3500
3482
 
3501
- if (res.headers.upgrade.toLowerCase() !== 'websocket') {
3483
+ const upgrade = res.headers.upgrade;
3484
+
3485
+ if (upgrade === undefined || upgrade.toLowerCase() !== 'websocket') {
3502
3486
  abortHandshake$1(websocket, socket, 'Invalid Upgrade header');
3503
3487
  return;
3504
3488
  }
@@ -3966,7 +3950,7 @@ function parse(header) {
3966
3950
 
3967
3951
  var subprotocol$1 = { parse };
3968
3952
 
3969
- /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex$" }] */
3953
+ /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex$", "caughtErrors": "none" }] */
3970
3954
 
3971
3955
  const EventEmitter = require$$0$3;
3972
3956
  const http = require$$2;
@@ -3994,7 +3978,7 @@ class WebSocketServer extends EventEmitter {
3994
3978
  * Create a `WebSocketServer` instance.
3995
3979
  *
3996
3980
  * @param {Object} options Configuration options
3997
- * @param {Boolean} [options.allowSynchronousEvents=false] Specifies whether
3981
+ * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
3998
3982
  * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
3999
3983
  * multiple times in the same tick
4000
3984
  * @param {Boolean} [options.autoPong=true] Specifies whether or not to
@@ -4025,7 +4009,7 @@ class WebSocketServer extends EventEmitter {
4025
4009
  super();
4026
4010
 
4027
4011
  options = {
4028
- allowSynchronousEvents: false,
4012
+ allowSynchronousEvents: true,
4029
4013
  autoPong: true,
4030
4014
  maxPayload: 100 * 1024 * 1024,
4031
4015
  skipUTF8Validation: false,
@@ -4200,6 +4184,7 @@ class WebSocketServer extends EventEmitter {
4200
4184
  socket.on('error', socketOnError);
4201
4185
 
4202
4186
  const key = req.headers['sec-websocket-key'];
4187
+ const upgrade = req.headers.upgrade;
4203
4188
  const version = +req.headers['sec-websocket-version'];
4204
4189
 
4205
4190
  if (req.method !== 'GET') {
@@ -4208,13 +4193,13 @@ class WebSocketServer extends EventEmitter {
4208
4193
  return;
4209
4194
  }
4210
4195
 
4211
- if (req.headers.upgrade.toLowerCase() !== 'websocket') {
4196
+ if (upgrade === undefined || upgrade.toLowerCase() !== 'websocket') {
4212
4197
  const message = 'Invalid Upgrade header';
4213
4198
  abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
4214
4199
  return;
4215
4200
  }
4216
4201
 
4217
- if (!key || !keyRegex.test(key)) {
4202
+ if (key === undefined || !keyRegex.test(key)) {
4218
4203
  const message = 'Missing or invalid Sec-WebSocket-Key header';
4219
4204
  abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
4220
4205
  return;
@@ -1,6 +1,7 @@
1
1
  import { readdir, chmod, stat, lstat, promises, writeFileSync as writeFileSync$1, mkdirSync, unlink, openSync, closeSync, rmdir, watch, readdirSync, statSync, createReadStream, readFile, existsSync, readFileSync, realpathSync } from "node:fs";
2
2
  import stringWidth from "string-width";
3
3
  import process$1 from "node:process";
4
+ import { isBrowser } from "environment";
4
5
  import os, { networkInterfaces } from "node:os";
5
6
  import tty from "node:tty";
6
7
  import { pathToFileURL, fileURLToPath } from "node:url";
@@ -110,7 +111,7 @@ const applyMatching = (pattern, string) => {
110
111
  }
111
112
  // pattern consumed, string not consumed
112
113
  if (remainingPattern === "" && remainingString !== "") {
113
- return false; // fails because string longer than expected
114
+ return false; // fails because string longer than expect
114
115
  }
115
116
  // -- from this point pattern is not consumed --
116
117
  // string consumed, pattern not consumed
@@ -123,7 +124,7 @@ const applyMatching = (pattern, string) => {
123
124
  if (remainingPattern === "*") {
124
125
  groups.push({ string: "" });
125
126
  }
126
- return false; // fail because string shorter than expected
127
+ return false; // fail because string shorter than expect
127
128
  }
128
129
  // -- from this point pattern and string are not consumed --
129
130
  // fast path trailing slash
@@ -185,7 +186,7 @@ const applyMatching = (pattern, string) => {
185
186
  groups.push({ string: consumeString(slashIndex) });
186
187
  return false;
187
188
  }
188
- // the next char must not the one expected by remainingPattern[0]
189
+ // the next char must not the one expect by remainingPattern[0]
189
190
  // because * is greedy and expect to skip at least one char
190
191
  if (remainingPattern[0] === remainingString[0]) {
191
192
  groups.push({ string: "" });
@@ -677,169 +678,41 @@ const error = (...args) => console.error(...args);
677
678
  const errorDisabled = () => {};
678
679
 
679
680
  const ESC = '\u001B[';
680
- const OSC = '\u001B]';
681
- const BEL = '\u0007';
682
- const SEP = ';';
683
681
 
684
- /* global window */
685
- const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
686
-
687
- const isTerminalApp = !isBrowser && process$1.env.TERM_PROGRAM === 'Apple_Terminal';
682
+ !isBrowser && process$1.env.TERM_PROGRAM === 'Apple_Terminal';
688
683
  const isWindows$3 = !isBrowser && process$1.platform === 'win32';
689
- const cwdFunction = isBrowser ? () => {
684
+
685
+ isBrowser ? () => {
690
686
  throw new Error('`process.cwd()` only works in Node.js, not the browser.');
691
687
  } : process$1.cwd;
692
688
 
693
- const ansiEscapes = {};
694
-
695
- ansiEscapes.cursorTo = (x, y) => {
696
- if (typeof x !== 'number') {
697
- throw new TypeError('The `x` argument is required');
698
- }
699
-
700
- if (typeof y !== 'number') {
701
- return ESC + (x + 1) + 'G';
702
- }
703
-
704
- return ESC + (y + 1) + SEP + (x + 1) + 'H';
705
- };
706
-
707
- ansiEscapes.cursorMove = (x, y) => {
708
- if (typeof x !== 'number') {
709
- throw new TypeError('The `x` argument is required');
710
- }
711
-
712
- let returnValue = '';
713
-
714
- if (x < 0) {
715
- returnValue += ESC + (-x) + 'D';
716
- } else if (x > 0) {
717
- returnValue += ESC + x + 'C';
718
- }
719
-
720
- if (y < 0) {
721
- returnValue += ESC + (-y) + 'A';
722
- } else if (y > 0) {
723
- returnValue += ESC + y + 'B';
724
- }
725
-
726
- return returnValue;
727
- };
728
-
729
- ansiEscapes.cursorUp = (count = 1) => ESC + count + 'A';
730
- ansiEscapes.cursorDown = (count = 1) => ESC + count + 'B';
731
- ansiEscapes.cursorForward = (count = 1) => ESC + count + 'C';
732
- ansiEscapes.cursorBackward = (count = 1) => ESC + count + 'D';
689
+ const cursorUp = (count = 1) => ESC + count + 'A';
733
690
 
734
- ansiEscapes.cursorLeft = ESC + 'G';
735
- ansiEscapes.cursorSavePosition = isTerminalApp ? '\u001B7' : ESC + 's';
736
- ansiEscapes.cursorRestorePosition = isTerminalApp ? '\u001B8' : ESC + 'u';
737
- ansiEscapes.cursorGetPosition = ESC + '6n';
738
- ansiEscapes.cursorNextLine = ESC + 'E';
739
- ansiEscapes.cursorPrevLine = ESC + 'F';
740
- ansiEscapes.cursorHide = ESC + '?25l';
741
- ansiEscapes.cursorShow = ESC + '?25h';
691
+ const cursorLeft = ESC + 'G';
742
692
 
743
- ansiEscapes.eraseLines = count => {
693
+ const eraseLines = count => {
744
694
  let clear = '';
745
695
 
746
696
  for (let i = 0; i < count; i++) {
747
- clear += ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : '');
697
+ clear += eraseLine + (i < count - 1 ? cursorUp() : '');
748
698
  }
749
699
 
750
700
  if (count) {
751
- clear += ansiEscapes.cursorLeft;
701
+ clear += cursorLeft;
752
702
  }
753
703
 
754
704
  return clear;
755
705
  };
706
+ const eraseLine = ESC + '2K';
707
+ const eraseScreen = ESC + '2J';
756
708
 
757
- ansiEscapes.eraseEndLine = ESC + 'K';
758
- ansiEscapes.eraseStartLine = ESC + '1K';
759
- ansiEscapes.eraseLine = ESC + '2K';
760
- ansiEscapes.eraseDown = ESC + 'J';
761
- ansiEscapes.eraseUp = ESC + '1J';
762
- ansiEscapes.eraseScreen = ESC + '2J';
763
- ansiEscapes.scrollUp = ESC + 'S';
764
- ansiEscapes.scrollDown = ESC + 'T';
765
-
766
- ansiEscapes.clearScreen = '\u001Bc';
767
-
768
- ansiEscapes.clearTerminal = isWindows$3
769
- ? `${ansiEscapes.eraseScreen}${ESC}0f`
709
+ const clearTerminal = isWindows$3
710
+ ? `${eraseScreen}${ESC}0f`
770
711
  // 1. Erases the screen (Only done in case `2` is not supported)
771
712
  // 2. Erases the whole screen including scrollback buffer
772
713
  // 3. Moves cursor to the top-left position
773
714
  // More info: https://www.real-world-systems.com/docs/ANSIcode.html
774
- : `${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`;
775
-
776
- ansiEscapes.enterAlternativeScreen = ESC + '?1049h';
777
- ansiEscapes.exitAlternativeScreen = ESC + '?1049l';
778
-
779
- ansiEscapes.beep = BEL;
780
-
781
- ansiEscapes.link = (text, url) => [
782
- OSC,
783
- '8',
784
- SEP,
785
- SEP,
786
- url,
787
- BEL,
788
- text,
789
- OSC,
790
- '8',
791
- SEP,
792
- SEP,
793
- BEL,
794
- ].join('');
795
-
796
- ansiEscapes.image = (buffer, options = {}) => {
797
- let returnValue = `${OSC}1337;File=inline=1`;
798
-
799
- if (options.width) {
800
- returnValue += `;width=${options.width}`;
801
- }
802
-
803
- if (options.height) {
804
- returnValue += `;height=${options.height}`;
805
- }
806
-
807
- if (options.preserveAspectRatio === false) {
808
- returnValue += ';preserveAspectRatio=0';
809
- }
810
-
811
- return returnValue + ':' + buffer.toString('base64') + BEL;
812
- };
813
-
814
- ansiEscapes.iTerm = {
815
- setCwd: (cwd = cwdFunction()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
816
-
817
- annotation(message, options = {}) {
818
- let returnValue = `${OSC}1337;`;
819
-
820
- const hasX = typeof options.x !== 'undefined';
821
- const hasY = typeof options.y !== 'undefined';
822
- if ((hasX || hasY) && !(hasX && hasY && typeof options.length !== 'undefined')) {
823
- throw new Error('`x`, `y` and `length` must be defined when `x` or `y` is defined');
824
- }
825
-
826
- message = message.replace(/\|/g, '');
827
-
828
- returnValue += options.isHidden ? 'AddHiddenAnnotation=' : 'AddAnnotation=';
829
-
830
- if (options.length > 0) {
831
- returnValue += (
832
- hasX
833
- ? [message, options.length, options.x, options.y]
834
- : [options.length, message]
835
- ).join('|');
836
- } else {
837
- returnValue += message;
838
- }
839
-
840
- return returnValue + BEL;
841
- },
842
- };
715
+ : `${eraseScreen}${ESC}3J${ESC}H`;
843
716
 
844
717
  /*
845
718
  * see also https://github.com/vadimdemedes/ink
@@ -887,7 +760,7 @@ const createDynamicLog = ({
887
760
  if (visualLineCount > rows) {
888
761
  if (clearTerminalAllowed) {
889
762
  clearAttemptResult = true;
890
- return ansiEscapes.clearTerminal;
763
+ return clearTerminal;
891
764
  }
892
765
  // the whole log cannot be cleared because it's vertically to long
893
766
  // (longer than terminal height)
@@ -900,7 +773,7 @@ const createDynamicLog = ({
900
773
  }
901
774
 
902
775
  clearAttemptResult = true;
903
- return ansiEscapes.eraseLines(visualLineCount);
776
+ return eraseLines(visualLineCount);
904
777
  };
905
778
 
906
779
  const update = (string) => {
@@ -929,20 +802,22 @@ const createDynamicLog = ({
929
802
  clearAttemptResult = undefined;
930
803
  };
931
804
 
932
- const clearDuringFunctionCall = (callback) => {
805
+ const clearDuringFunctionCall = (
806
+ callback,
807
+ ouputAfterCallback = lastOutput,
808
+ ) => {
933
809
  // 1. Erase the current log
934
- // 2. Call callback (expected to write something on stdout)
810
+ // 2. Call callback (expect to write something on stdout)
935
811
  // 3. Restore the current log
936
812
  // During step 2. we expect a "write from outside" so we uninstall
937
813
  // the stream spy during function call
938
- const currentOutput = lastOutput;
939
814
  update("");
940
815
 
941
816
  writing = true;
942
817
  callback();
943
818
  writing = false;
944
819
 
945
- update(currentOutput);
820
+ update(ouputAfterCallback);
946
821
  };
947
822
 
948
823
  const writeFromOutsideEffect = (value) => {
@@ -1215,14 +1090,19 @@ const ANSI = {
1215
1090
  YELLOW: "\x1b[33m",
1216
1091
  BLUE: "\x1b[34m",
1217
1092
  MAGENTA: "\x1b[35m",
1093
+ CYAN: "\x1b[36m",
1218
1094
  GREY: "\x1b[90m",
1219
1095
  color: (text, ANSI_COLOR) => {
1220
- return ANSI.supported ? `${ANSI_COLOR}${text}${RESET}` : text;
1096
+ return ANSI.supported && ANSI_COLOR ? `${ANSI_COLOR}${text}${RESET}` : text;
1221
1097
  },
1222
1098
 
1223
1099
  BOLD: "\x1b[1m",
1100
+ UNDERLINE: "\x1b[4m",
1101
+ STRIKE: "\x1b[9m",
1224
1102
  effect: (text, ANSI_EFFECT) => {
1225
- return ANSI.supported ? `${ANSI_EFFECT}${text}${RESET}` : text;
1103
+ return ANSI.supported && ANSI_EFFECT
1104
+ ? `${ANSI_EFFECT}${text}${RESET}`
1105
+ : text;
1226
1106
  },
1227
1107
  };
1228
1108
 
@@ -1567,6 +1447,9 @@ const UNICODE = {
1567
1447
  get CIRCLE_CROSS() {
1568
1448
  return ANSI.color(UNICODE.CIRCLE_CROSS_RAW, ANSI.RED);
1569
1449
  },
1450
+ get ELLIPSIS() {
1451
+ return UNICODE.supported ? `…` : `...`;
1452
+ },
1570
1453
  };
1571
1454
 
1572
1455
  const createTaskLog = (
@@ -2521,7 +2404,7 @@ const ensureWindowsDriveLetter = (url, baseUrl) => {
2521
2404
  try {
2522
2405
  url = String(new URL(url));
2523
2406
  } catch (e) {
2524
- throw new Error(`absolute url expected but got ${url}`);
2407
+ throw new Error(`absolute url expect but got ${url}`);
2525
2408
  }
2526
2409
 
2527
2410
  if (!isWindows$2) {
@@ -2532,7 +2415,7 @@ const ensureWindowsDriveLetter = (url, baseUrl) => {
2532
2415
  baseUrl = String(new URL(baseUrl));
2533
2416
  } catch (e) {
2534
2417
  throw new Error(
2535
- `absolute baseUrl expected but got ${baseUrl} to ensure windows drive letter on ${url}`,
2418
+ `absolute baseUrl expect but got ${baseUrl} to ensure windows drive letter on ${url}`,
2536
2419
  );
2537
2420
  }
2538
2421
 
@@ -2554,7 +2437,7 @@ const ensureWindowsDriveLetter = (url, baseUrl) => {
2554
2437
  );
2555
2438
  if (!driveLetter) {
2556
2439
  throw new Error(
2557
- `drive letter expected on baseUrl but got ${baseUrl} to ensure windows drive letter on ${url}`,
2440
+ `drive letter expect on baseUrl but got ${baseUrl} to ensure windows drive letter on ${url}`,
2558
2441
  );
2559
2442
  }
2560
2443
  return `file:///${driveLetter}:${afterProtocol}`;
@@ -2754,7 +2637,7 @@ const createOperation = () => {
2754
2637
  const operationSignal = operationAbortController.signal;
2755
2638
 
2756
2639
  // abortCallbackList is used to ignore the max listeners warning from Node.js
2757
- // this warning is useful but becomes problematic when it's expected
2640
+ // this warning is useful but becomes problematic when it's expect
2758
2641
  // (a function doing 20 http call in parallel)
2759
2642
  // To be 100% sure we don't have memory leak, only Abortable.asyncCallback
2760
2643
  // uses abortCallbackList to know when something is aborted
@@ -3114,67 +2997,11 @@ const readDirectory = async (url, { emfileMaxWait = 1000 } = {}) => {
3114
2997
  return attempt();
3115
2998
  };
3116
2999
 
3117
- // https://github.com/coderaiser/cloudcmd/issues/63#issuecomment-195478143
3118
- // https://nodejs.org/api/fs.html#fs_file_modes
3119
- // https://github.com/TooTallNate/stat-mode
3120
-
3121
- // cannot get from fs.constants because they are not available on windows
3122
- const S_IRUSR = 256; /* 0000400 read permission, owner */
3123
- const S_IWUSR = 128; /* 0000200 write permission, owner */
3124
- const S_IXUSR = 64; /* 0000100 execute/search permission, owner */
3125
- const S_IRGRP = 32; /* 0000040 read permission, group */
3126
- const S_IWGRP = 16; /* 0000020 write permission, group */
3127
- const S_IXGRP = 8; /* 0000010 execute/search permission, group */
3128
- const S_IROTH = 4; /* 0000004 read permission, others */
3129
- const S_IWOTH = 2; /* 0000002 write permission, others */
3130
- const S_IXOTH = 1; /* 0000001 execute/search permission, others */
3131
-
3132
- const permissionsToBinaryFlags = ({ owner, group, others }) => {
3133
- let binaryFlags = 0;
3134
-
3135
- if (owner.read) binaryFlags |= S_IRUSR;
3136
- if (owner.write) binaryFlags |= S_IWUSR;
3137
- if (owner.execute) binaryFlags |= S_IXUSR;
3138
-
3139
- if (group.read) binaryFlags |= S_IRGRP;
3140
- if (group.write) binaryFlags |= S_IWGRP;
3141
- if (group.execute) binaryFlags |= S_IXGRP;
3142
-
3143
- if (others.read) binaryFlags |= S_IROTH;
3144
- if (others.write) binaryFlags |= S_IWOTH;
3145
- if (others.execute) binaryFlags |= S_IXOTH;
3146
-
3147
- return binaryFlags;
3148
- };
3149
-
3150
3000
  const writeEntryPermissions = async (source, permissions) => {
3151
3001
  const sourceUrl = assertAndNormalizeFileUrl(source);
3152
3002
 
3153
3003
  let binaryFlags;
3154
- if (typeof permissions === "object") {
3155
- permissions = {
3156
- owner: {
3157
- read: getPermissionOrComputeDefault("read", "owner", permissions),
3158
- write: getPermissionOrComputeDefault("write", "owner", permissions),
3159
- execute: getPermissionOrComputeDefault("execute", "owner", permissions),
3160
- },
3161
- group: {
3162
- read: getPermissionOrComputeDefault("read", "group", permissions),
3163
- write: getPermissionOrComputeDefault("write", "group", permissions),
3164
- execute: getPermissionOrComputeDefault("execute", "group", permissions),
3165
- },
3166
- others: {
3167
- read: getPermissionOrComputeDefault("read", "others", permissions),
3168
- write: getPermissionOrComputeDefault("write", "others", permissions),
3169
- execute: getPermissionOrComputeDefault(
3170
- "execute",
3171
- "others",
3172
- permissions,
3173
- ),
3174
- },
3175
- };
3176
- binaryFlags = permissionsToBinaryFlags(permissions);
3177
- } else {
3004
+ {
3178
3005
  binaryFlags = permissions;
3179
3006
  }
3180
3007
 
@@ -3189,45 +3016,6 @@ const writeEntryPermissions = async (source, permissions) => {
3189
3016
  });
3190
3017
  };
3191
3018
 
3192
- const actionLevels = { read: 0, write: 1, execute: 2 };
3193
- const subjectLevels = { others: 0, group: 1, owner: 2 };
3194
-
3195
- const getPermissionOrComputeDefault = (action, subject, permissions) => {
3196
- if (subject in permissions) {
3197
- const subjectPermissions = permissions[subject];
3198
- if (action in subjectPermissions) {
3199
- return subjectPermissions[action];
3200
- }
3201
-
3202
- const actionLevel = actionLevels[action];
3203
- const actionFallback = Object.keys(actionLevels).find(
3204
- (actionFallbackCandidate) =>
3205
- actionLevels[actionFallbackCandidate] > actionLevel &&
3206
- actionFallbackCandidate in subjectPermissions,
3207
- );
3208
- if (actionFallback) {
3209
- return subjectPermissions[actionFallback];
3210
- }
3211
- }
3212
-
3213
- const subjectLevel = subjectLevels[subject];
3214
- // do we have a subject with a stronger level (group or owner)
3215
- // where we could read the action permission ?
3216
- const subjectFallback = Object.keys(subjectLevels).find(
3217
- (subjectFallbackCandidate) =>
3218
- subjectLevels[subjectFallbackCandidate] > subjectLevel &&
3219
- subjectFallbackCandidate in permissions,
3220
- );
3221
- if (subjectFallback) {
3222
- const subjectPermissions = permissions[subjectFallback];
3223
- return action in subjectPermissions
3224
- ? subjectPermissions[action]
3225
- : getPermissionOrComputeDefault(action, subjectFallback, permissions);
3226
- }
3227
-
3228
- return false;
3229
- };
3230
-
3231
3019
  /*
3232
3020
  * - stats object documentation on Node.js
3233
3021
  * https://nodejs.org/docs/latest-v13.x/api/fs.html#fs_class_fs_stats
@@ -3952,7 +3740,7 @@ const registerDirectoryLifecycle = (
3952
3740
  notifyExistent = false,
3953
3741
  keepProcessAlive = true,
3954
3742
  recursive = false,
3955
- // filesystem might dispatch more events than expected
3743
+ // filesystem might dispatch more events than expect
3956
3744
  // Code can use "cooldownBetweenFileEvents" to prevent that
3957
3745
  // BUT it is UNADVISED to rely on this as explained later (search for "is lying" in this file)
3958
3746
  // For this reason"cooldownBetweenFileEvents" should be reserved to scenarios
@@ -4320,7 +4108,7 @@ const ETAG_FOR_EMPTY_CONTENT$1 = '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
4320
4108
 
4321
4109
  const bufferToEtag$1 = (buffer) => {
4322
4110
  if (!Buffer.isBuffer(buffer)) {
4323
- throw new TypeError(`buffer expected, got ${buffer}`);
4111
+ throw new TypeError(`buffer expect,got ${buffer}`);
4324
4112
  }
4325
4113
 
4326
4114
  if (buffer.length === 0) {
@@ -7290,7 +7078,7 @@ const ETAG_FOR_EMPTY_CONTENT = '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
7290
7078
 
7291
7079
  const bufferToEtag = (buffer) => {
7292
7080
  if (!Buffer.isBuffer(buffer)) {
7293
- throw new TypeError(`buffer expected, got ${buffer}`);
7081
+ throw new TypeError(`buffer expect,got ${buffer}`);
7294
7082
  }
7295
7083
 
7296
7084
  if (buffer.length === 0) {
@@ -14120,13 +13908,13 @@ const assertFetchedContentCompliance = ({ urlInfo, content }) => {
14120
13908
  const { expectedContentType } = urlInfo.firstReference;
14121
13909
  if (expectedContentType && urlInfo.contentType !== expectedContentType) {
14122
13910
  throw new Error(
14123
- `Unexpected content-type on url: "${expectedContentType}" was expected but got "${urlInfo.contentType}`,
13911
+ `Unexpected content-type on url: "${expectedContentType}" was expect but got "${urlInfo.contentType}`,
14124
13912
  );
14125
13913
  }
14126
13914
  const { expectedType } = urlInfo.firstReference;
14127
13915
  if (expectedType && urlInfo.type !== expectedType) {
14128
13916
  throw new Error(
14129
- `Unexpected type on url: "${expectedType}" was expected but got "${urlInfo.type}"`,
13917
+ `Unexpected type on url: "${expectedType}" was expect but got "${urlInfo.type}"`,
14130
13918
  );
14131
13919
  }
14132
13920
  const { integrity } = urlInfo.firstReference;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "38.4.7",
3
+ "version": "38.4.9",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -34,6 +34,9 @@
34
34
  "/dist/",
35
35
  "/src/"
36
36
  ],
37
+ "volta": {
38
+ "node": "22.3.0"
39
+ },
37
40
  "workspaces": [
38
41
  "./packages/independent/*",
39
42
  "./packages/internal/*",
@@ -43,7 +46,7 @@
43
46
  "scripts": {
44
47
  "eslint": "npx eslint . --ext=.js,.mjs,.cjs,.html",
45
48
  "dev": "node --conditions=development ./scripts/dev/dev.mjs",
46
- "test": "node --conditions=development ./scripts/test/test.mjs",
49
+ "test": "node --trace-deprecation --conditions=development ./scripts/test/test.mjs",
47
50
  "test:workspace": "npm run test --workspaces --if-present -- --workspace",
48
51
  "test:snapshots_clear": "npx @jsenv/snapshot clear **/tests/**/snapshots/",
49
52
  "test:only_dev_server_errors": "node --conditions=development ./tests/dev_server/errors/dev_errors_snapshots.test.mjs",
@@ -62,27 +65,28 @@
62
65
  "dependencies": {
63
66
  "@financial-times/polyfill-useragent-normaliser": "1.10.2",
64
67
  "@jsenv/abort": "4.3.0",
65
- "@jsenv/ast": "6.0.2",
66
- "@jsenv/filesystem": "4.6.4",
68
+ "@jsenv/ast": "6.0.4",
69
+ "@jsenv/filesystem": "4.6.6",
70
+ "@jsenv/humanize": "1.1.0",
67
71
  "@jsenv/importmap": "1.2.1",
68
72
  "@jsenv/integrity": "0.0.1",
69
- "@jsenv/js-module-fallback": "1.3.11",
70
- "@jsenv/humanize": "1.0.0",
73
+ "@jsenv/js-module-fallback": "1.3.13",
71
74
  "@jsenv/node-esm-resolution": "1.0.2",
72
- "@jsenv/plugin-bundling": "2.6.5",
75
+ "@jsenv/plugin-bundling": "2.6.7",
73
76
  "@jsenv/plugin-minification": "1.5.4",
74
- "@jsenv/plugin-supervisor": "1.4.2",
75
- "@jsenv/plugin-transpilation": "1.3.11",
76
- "@jsenv/runtime-compat": "1.2.2",
77
- "@jsenv/server": "15.2.2",
78
- "@jsenv/sourcemap": "1.2.5",
77
+ "@jsenv/plugin-supervisor": "1.4.4",
78
+ "@jsenv/plugin-transpilation": "1.3.13",
79
+ "@jsenv/runtime-compat": "1.3.0",
80
+ "@jsenv/server": "15.2.3",
81
+ "@jsenv/sourcemap": "1.2.7",
79
82
  "@jsenv/url-meta": "8.4.0",
80
- "@jsenv/urls": "2.2.2",
83
+ "@jsenv/urls": "2.2.4",
81
84
  "@jsenv/utils": "2.1.1"
82
85
  },
83
86
  "devDependencies": {
84
- "@babel/eslint-parser": "7.23.3",
85
- "@babel/plugin-syntax-import-assertions": "7.23.3",
87
+ "@babel/eslint-parser": "7.24.7",
88
+ "@babel/plugin-syntax-import-assertions": "7.24.7",
89
+ "@babel/plugin-syntax-optional-chaining-assign": "7.24.7",
86
90
  "@jsenv/assert": "./packages/independent/assert/",
87
91
  "@jsenv/core": "./",
88
92
  "@jsenv/eslint-config": "./packages/independent/eslint-config/",
@@ -93,16 +97,16 @@
93
97
  "@jsenv/plugin-as-js-classic": "./packages/related/plugin-as-js-classic/",
94
98
  "@jsenv/snapshot": "./packages/independent/snapshot/",
95
99
  "@jsenv/test": "./packages/related/test/",
100
+ "@playwright/browser-chromium": "1.45.0",
101
+ "@playwright/browser-firefox": "1.45.0",
102
+ "@playwright/browser-webkit": "1.45.0",
96
103
  "babel-plugin-transform-async-to-promises": "0.8.18",
97
104
  "eslint": "8.56.0",
98
105
  "eslint-plugin-html": "7.1.0",
99
106
  "eslint-plugin-import": "2.29.1",
100
- "eslint-plugin-react": "7.33.2",
101
- "open": "10.0.3",
102
- "playwright": "1.40.1",
103
- "@playwright/browser-chromium": "1.40.1",
104
- "@playwright/browser-firefox": "1.40.1",
105
- "@playwright/browser-webkit": "1.40.1",
106
- "prettier": "3.2.2"
107
+ "eslint-plugin-react": "7.34.3",
108
+ "open": "10.1.0",
109
+ "playwright": "1.45.0",
110
+ "prettier": "3.3.2"
107
111
  }
108
112
  }
@@ -4,13 +4,13 @@ export const assertFetchedContentCompliance = ({ urlInfo, content }) => {
4
4
  const { expectedContentType } = urlInfo.firstReference;
5
5
  if (expectedContentType && urlInfo.contentType !== expectedContentType) {
6
6
  throw new Error(
7
- `Unexpected content-type on url: "${expectedContentType}" was expected but got "${urlInfo.contentType}`,
7
+ `Unexpected content-type on url: "${expectedContentType}" was expect but got "${urlInfo.contentType}`,
8
8
  );
9
9
  }
10
10
  const { expectedType } = urlInfo.firstReference;
11
11
  if (expectedType && urlInfo.type !== expectedType) {
12
12
  throw new Error(
13
- `Unexpected type on url: "${expectedType}" was expected but got "${urlInfo.type}"`,
13
+ `Unexpected type on url: "${expectedType}" was expect but got "${urlInfo.type}"`,
14
14
  );
15
15
  }
16
16
  const { integrity } = urlInfo.firstReference;