@jsenv/core 38.2.0 → 38.2.2
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/README.md +3 -7
- package/dist/babel_helpers/applyDecs2305/applyDecs2305.js +39 -10
- package/dist/babel_helpers/dispose/dispose.js +45 -0
- package/dist/babel_helpers/importDeferProxy/importDeferProxy.js +31 -0
- package/dist/babel_helpers/nullishReceiverError/nullishReceiverError.js +3 -0
- package/dist/babel_helpers/regeneratorRuntime/regeneratorRuntime.js +2 -6
- package/dist/babel_helpers/using/using.js +23 -0
- package/dist/js/ws.js +91 -33
- package/dist/jsenv_core.js +24 -3
- package/package.json +15 -15
- package/src/plugins/reference_analysis/js/jsenv_plugin_js_reference_analysis.js +17 -0
package/README.md
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
# @jsenv/core [](https://www.npmjs.com/package/@jsenv/core)
|
|
2
2
|
|
|
3
|
-
Jsenv is a tool to develop test and build projects using JavaScript.
|
|
3
|
+
Jsenv is a tool to develop test and build projects using JavaScript.
|
|
4
|
+
Jsenv is simple, easy to understand and well documented.
|
|
4
5
|
|
|
5
|
-
[Documentation](<https://github.com/jsenv/core/wiki/A)-Introduction>)
|
|
6
|
-
|
|
7
|
-
See also
|
|
8
|
-
|
|
9
|
-
- [Documentation for contributors](./docs/contributors/README.md)
|
|
10
|
-
- [Documentation for maintainers](./docs/maintainers/README.md)
|
|
6
|
+
[Documentation](<https://github.com/jsenv/core/wiki/A)-Introduction>)
|
|
11
7
|
|
|
12
8
|
<!-- # Installation
|
|
13
9
|
|
|
@@ -45,7 +45,8 @@ function memberDec(
|
|
|
45
45
|
isStatic,
|
|
46
46
|
isPrivate,
|
|
47
47
|
value,
|
|
48
|
-
hasPrivateBrand
|
|
48
|
+
hasPrivateBrand,
|
|
49
|
+
metadata
|
|
49
50
|
) {
|
|
50
51
|
var kindStr;
|
|
51
52
|
|
|
@@ -71,6 +72,7 @@ function memberDec(
|
|
|
71
72
|
name: isPrivate ? "#" + name : name,
|
|
72
73
|
static: isStatic,
|
|
73
74
|
private: isPrivate,
|
|
75
|
+
metadata: metadata,
|
|
74
76
|
};
|
|
75
77
|
|
|
76
78
|
var decoratorFinishedRef = { v: false };
|
|
@@ -211,7 +213,8 @@ function applyMemberDec(
|
|
|
211
213
|
isStatic,
|
|
212
214
|
isPrivate,
|
|
213
215
|
initializers,
|
|
214
|
-
hasPrivateBrand
|
|
216
|
+
hasPrivateBrand,
|
|
217
|
+
metadata
|
|
215
218
|
) {
|
|
216
219
|
var decs = decInfo[0];
|
|
217
220
|
|
|
@@ -276,7 +279,8 @@ function applyMemberDec(
|
|
|
276
279
|
isStatic,
|
|
277
280
|
isPrivate,
|
|
278
281
|
value,
|
|
279
|
-
hasPrivateBrand
|
|
282
|
+
hasPrivateBrand,
|
|
283
|
+
metadata
|
|
280
284
|
);
|
|
281
285
|
|
|
282
286
|
if (newValue !== void 0) {
|
|
@@ -369,7 +373,7 @@ function applyMemberDec(
|
|
|
369
373
|
}
|
|
370
374
|
}
|
|
371
375
|
|
|
372
|
-
function applyMemberDecs(Class, decInfos, instanceBrand) {
|
|
376
|
+
function applyMemberDecs(Class, decInfos, instanceBrand, metadata) {
|
|
373
377
|
var ret = [];
|
|
374
378
|
var protoInitializers;
|
|
375
379
|
var staticInitializers;
|
|
@@ -451,7 +455,8 @@ function applyMemberDecs(Class, decInfos, instanceBrand) {
|
|
|
451
455
|
isStatic,
|
|
452
456
|
isPrivate,
|
|
453
457
|
initializers,
|
|
454
|
-
hasPrivateBrand
|
|
458
|
+
hasPrivateBrand,
|
|
459
|
+
metadata
|
|
455
460
|
);
|
|
456
461
|
}
|
|
457
462
|
|
|
@@ -471,7 +476,7 @@ function pushInitializers(ret, initializers) {
|
|
|
471
476
|
}
|
|
472
477
|
}
|
|
473
478
|
|
|
474
|
-
function applyClassDecs(targetClass, classDecs, decoratorsHaveThis) {
|
|
479
|
+
function applyClassDecs(targetClass, classDecs, decoratorsHaveThis, metadata) {
|
|
475
480
|
if (classDecs.length) {
|
|
476
481
|
var initializers = [];
|
|
477
482
|
var newClass = targetClass;
|
|
@@ -493,6 +498,7 @@ function applyClassDecs(targetClass, classDecs, decoratorsHaveThis) {
|
|
|
493
498
|
initializers,
|
|
494
499
|
decoratorFinishedRef
|
|
495
500
|
),
|
|
501
|
+
metadata,
|
|
496
502
|
}
|
|
497
503
|
);
|
|
498
504
|
} finally {
|
|
@@ -506,7 +512,7 @@ function applyClassDecs(targetClass, classDecs, decoratorsHaveThis) {
|
|
|
506
512
|
}
|
|
507
513
|
|
|
508
514
|
return [
|
|
509
|
-
newClass,
|
|
515
|
+
defineMetadata(newClass, metadata),
|
|
510
516
|
function () {
|
|
511
517
|
for (var i = 0; i < initializers.length; i++) {
|
|
512
518
|
initializers[i].call(newClass);
|
|
@@ -518,6 +524,14 @@ function applyClassDecs(targetClass, classDecs, decoratorsHaveThis) {
|
|
|
518
524
|
// so we don't have to return an empty array here.
|
|
519
525
|
}
|
|
520
526
|
|
|
527
|
+
function defineMetadata(Class, metadata) {
|
|
528
|
+
return Object.defineProperty(
|
|
529
|
+
Class,
|
|
530
|
+
Symbol.metadata || Symbol.for("Symbol.metadata"),
|
|
531
|
+
{ configurable: true, enumerable: true, value: metadata }
|
|
532
|
+
);
|
|
533
|
+
}
|
|
534
|
+
|
|
521
535
|
/**
|
|
522
536
|
Basic usage:
|
|
523
537
|
|
|
@@ -669,13 +683,28 @@ export default function applyDecs2305(
|
|
|
669
683
|
memberDecs,
|
|
670
684
|
classDecs,
|
|
671
685
|
classDecsHaveThis,
|
|
672
|
-
instanceBrand
|
|
686
|
+
instanceBrand,
|
|
687
|
+
parentClass
|
|
673
688
|
) {
|
|
689
|
+
if (arguments.length >= 6) {
|
|
690
|
+
var parentMetadata =
|
|
691
|
+
parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
692
|
+
}
|
|
693
|
+
var metadata = Object.create(
|
|
694
|
+
parentMetadata === void 0 ? null : parentMetadata
|
|
695
|
+
);
|
|
696
|
+
var e = applyMemberDecs(targetClass, memberDecs, instanceBrand, metadata);
|
|
697
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
674
698
|
return {
|
|
675
|
-
e:
|
|
699
|
+
e: e,
|
|
676
700
|
// Lazily apply class decorations so that member init locals can be properly bound.
|
|
677
701
|
get c() {
|
|
678
|
-
return applyClassDecs(
|
|
702
|
+
return applyClassDecs(
|
|
703
|
+
targetClass,
|
|
704
|
+
classDecs,
|
|
705
|
+
classDecsHaveThis,
|
|
706
|
+
metadata
|
|
707
|
+
);
|
|
679
708
|
},
|
|
680
709
|
};
|
|
681
710
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* @minVersion 7.22.0 */
|
|
2
|
+
function dispose_SuppressedError(suppressed, error) {
|
|
3
|
+
if (typeof SuppressedError !== "undefined") {
|
|
4
|
+
// eslint-disable-next-line no-undef
|
|
5
|
+
dispose_SuppressedError = SuppressedError;
|
|
6
|
+
} else {
|
|
7
|
+
dispose_SuppressedError = function SuppressedError(suppressed, error) {
|
|
8
|
+
this.suppressed = suppressed;
|
|
9
|
+
this.error = error;
|
|
10
|
+
this.stack = new Error().stack;
|
|
11
|
+
};
|
|
12
|
+
dispose_SuppressedError.prototype = Object.create(Error.prototype, {
|
|
13
|
+
constructor: {
|
|
14
|
+
value: dispose_SuppressedError,
|
|
15
|
+
writable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return new dispose_SuppressedError(suppressed, error);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default function _dispose(stack, error, hasError) {
|
|
24
|
+
function next() {
|
|
25
|
+
while (stack.length > 0) {
|
|
26
|
+
try {
|
|
27
|
+
var r = stack.pop();
|
|
28
|
+
var p = r.d.call(r.v);
|
|
29
|
+
if (r.a) return Promise.resolve(p).then(next, err);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
return err(e);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (hasError) throw error;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function err(e) {
|
|
38
|
+
error = hasError ? new dispose_SuppressedError(e, error) : e;
|
|
39
|
+
hasError = true;
|
|
40
|
+
|
|
41
|
+
return next();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return next();
|
|
45
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* @minVersion 7.23.0 */
|
|
2
|
+
export default function _importDeferProxy(init) {
|
|
3
|
+
var ns = null;
|
|
4
|
+
var constValue = function (v) {
|
|
5
|
+
return function () {
|
|
6
|
+
return v;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
var proxy = function (run) {
|
|
10
|
+
return function (arg1, arg2, arg3) {
|
|
11
|
+
if (ns === null) ns = init();
|
|
12
|
+
return run(ns, arg2, arg3);
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
return new Proxy(
|
|
16
|
+
{},
|
|
17
|
+
{
|
|
18
|
+
defineProperty: constValue(false),
|
|
19
|
+
deleteProperty: constValue(false),
|
|
20
|
+
get: proxy(Reflect.get),
|
|
21
|
+
getOwnPropertyDescriptor: proxy(Reflect.getOwnPropertyDescriptor),
|
|
22
|
+
getPrototypeOf: constValue(null),
|
|
23
|
+
isExtensible: constValue(false),
|
|
24
|
+
has: proxy(Reflect.has),
|
|
25
|
+
ownKeys: proxy(Reflect.ownKeys),
|
|
26
|
+
preventExtensions: constValue(true),
|
|
27
|
+
set: constValue(false),
|
|
28
|
+
setPrototypeOf: constValue(false),
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -483,7 +483,7 @@ export default function _regeneratorRuntime() {
|
|
|
483
483
|
};
|
|
484
484
|
};
|
|
485
485
|
function values(iterable) {
|
|
486
|
-
if (iterable) {
|
|
486
|
+
if (iterable || iterable === "") {
|
|
487
487
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
488
488
|
if (iteratorMethod) {
|
|
489
489
|
return iteratorMethod.call(iterable);
|
|
@@ -508,11 +508,7 @@ export default function _regeneratorRuntime() {
|
|
|
508
508
|
return (next.next = next);
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
|
-
|
|
512
|
-
// Return an iterator with no values.
|
|
513
|
-
return {
|
|
514
|
-
next: doneResult,
|
|
515
|
-
};
|
|
511
|
+
throw new TypeError(typeof iterable + " is not iterable");
|
|
516
512
|
}
|
|
517
513
|
exports.values = values;
|
|
518
514
|
function doneResult() {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* @minVersion 7.22.0 */
|
|
2
|
+
|
|
3
|
+
export default function _using(stack, value, isAwait) {
|
|
4
|
+
if (value === null || value === void 0) return value;
|
|
5
|
+
if (typeof value !== "object") {
|
|
6
|
+
throw new TypeError(
|
|
7
|
+
"using declarations can only be used with objects, null, or undefined."
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
// core-js-pure uses Symbol.for for polyfilling well-known symbols
|
|
11
|
+
if (isAwait) {
|
|
12
|
+
var dispose =
|
|
13
|
+
value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
|
|
14
|
+
}
|
|
15
|
+
if (dispose === null || dispose === void 0) {
|
|
16
|
+
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
|
|
17
|
+
}
|
|
18
|
+
if (typeof dispose !== "function") {
|
|
19
|
+
throw new TypeError(`Property [Symbol.dispose] is not a function.`);
|
|
20
|
+
}
|
|
21
|
+
stack.push({ v: value, d: dispose, a: isAwait });
|
|
22
|
+
return value;
|
|
23
|
+
}
|
package/dist/js/ws.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import require$$0 from "stream";
|
|
2
2
|
import require$$0$3 from "events";
|
|
3
3
|
import require$$2 from "http";
|
|
4
|
-
import require$$1 from "
|
|
5
|
-
import require$$3 from "net";
|
|
6
|
-
import require$$4 from "tls";
|
|
7
|
-
import require$$5 from "crypto";
|
|
4
|
+
import require$$1 from "crypto";
|
|
8
5
|
import require$$0$1 from "zlib";
|
|
9
6
|
import require$$0$2 from "buffer";
|
|
7
|
+
import require$$1$1 from "https";
|
|
8
|
+
import require$$3 from "net";
|
|
9
|
+
import require$$4 from "tls";
|
|
10
10
|
import require$$7 from "url";
|
|
11
11
|
|
|
12
12
|
function getDefaultExportFromCjs (x) {
|
|
@@ -876,12 +876,21 @@ 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
|
const GET_INFO = 0;
|
|
880
888
|
const GET_PAYLOAD_LENGTH_16 = 1;
|
|
881
889
|
const GET_PAYLOAD_LENGTH_64 = 2;
|
|
882
890
|
const GET_MASK = 3;
|
|
883
891
|
const GET_DATA = 4;
|
|
884
892
|
const INFLATING = 5;
|
|
893
|
+
const WAIT_MICROTASK = 6;
|
|
885
894
|
|
|
886
895
|
/**
|
|
887
896
|
* HyBi Receiver implementation.
|
|
@@ -1020,9 +1029,19 @@ let Receiver$1 = class Receiver extends Writable {
|
|
|
1020
1029
|
case GET_DATA:
|
|
1021
1030
|
err = this.getData(cb);
|
|
1022
1031
|
break;
|
|
1032
|
+
case INFLATING:
|
|
1033
|
+
this._loop = false;
|
|
1034
|
+
return;
|
|
1023
1035
|
default:
|
|
1024
|
-
//
|
|
1036
|
+
//
|
|
1037
|
+
// `WAIT_MICROTASK`.
|
|
1038
|
+
//
|
|
1025
1039
|
this._loop = false;
|
|
1040
|
+
|
|
1041
|
+
queueTask(() => {
|
|
1042
|
+
this._state = GET_INFO;
|
|
1043
|
+
this.startLoop(cb);
|
|
1044
|
+
});
|
|
1026
1045
|
return;
|
|
1027
1046
|
}
|
|
1028
1047
|
} while (this._loop);
|
|
@@ -1405,7 +1424,7 @@ let Receiver$1 = class Receiver extends Writable {
|
|
|
1405
1424
|
}
|
|
1406
1425
|
}
|
|
1407
1426
|
|
|
1408
|
-
this._state =
|
|
1427
|
+
this._state = WAIT_MICROTASK;
|
|
1409
1428
|
}
|
|
1410
1429
|
|
|
1411
1430
|
/**
|
|
@@ -1422,6 +1441,8 @@ let Receiver$1 = class Receiver extends Writable {
|
|
|
1422
1441
|
if (data.length === 0) {
|
|
1423
1442
|
this.emit('conclude', 1005, EMPTY_BUFFER$2);
|
|
1424
1443
|
this.end();
|
|
1444
|
+
|
|
1445
|
+
this._state = GET_INFO;
|
|
1425
1446
|
} else {
|
|
1426
1447
|
const code = data.readUInt16BE(0);
|
|
1427
1448
|
|
|
@@ -1453,14 +1474,16 @@ let Receiver$1 = class Receiver extends Writable {
|
|
|
1453
1474
|
|
|
1454
1475
|
this.emit('conclude', code, buf);
|
|
1455
1476
|
this.end();
|
|
1477
|
+
|
|
1478
|
+
this._state = GET_INFO;
|
|
1456
1479
|
}
|
|
1457
1480
|
} else if (this._opcode === 0x09) {
|
|
1458
1481
|
this.emit('ping', data);
|
|
1482
|
+
this._state = WAIT_MICROTASK;
|
|
1459
1483
|
} else {
|
|
1460
1484
|
this.emit('pong', data);
|
|
1485
|
+
this._state = WAIT_MICROTASK;
|
|
1461
1486
|
}
|
|
1462
|
-
|
|
1463
|
-
this._state = GET_INFO;
|
|
1464
1487
|
}
|
|
1465
1488
|
};
|
|
1466
1489
|
|
|
@@ -1489,8 +1512,37 @@ function error(ErrorCtor, message, prefix, statusCode, errorCode) {
|
|
|
1489
1512
|
return err;
|
|
1490
1513
|
}
|
|
1491
1514
|
|
|
1492
|
-
|
|
1493
|
-
|
|
1515
|
+
/**
|
|
1516
|
+
* A shim for `queueMicrotask()`.
|
|
1517
|
+
*
|
|
1518
|
+
* @param {Function} cb Callback
|
|
1519
|
+
*/
|
|
1520
|
+
function queueMicrotaskShim(cb) {
|
|
1521
|
+
promise.then(cb).catch(throwErrorNextTick);
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
/**
|
|
1525
|
+
* Throws an error.
|
|
1526
|
+
*
|
|
1527
|
+
* @param {Error} err The error to throw
|
|
1528
|
+
* @private
|
|
1529
|
+
*/
|
|
1530
|
+
function throwError(err) {
|
|
1531
|
+
throw err;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
/**
|
|
1535
|
+
* Throws an error in the next tick.
|
|
1536
|
+
*
|
|
1537
|
+
* @param {Error} err The error to throw
|
|
1538
|
+
* @private
|
|
1539
|
+
*/
|
|
1540
|
+
function throwErrorNextTick(err) {
|
|
1541
|
+
process.nextTick(throwError, err);
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex" }] */
|
|
1545
|
+
const { randomFillSync } = require$$1;
|
|
1494
1546
|
|
|
1495
1547
|
const PerMessageDeflate$2 = permessageDeflate;
|
|
1496
1548
|
const { EMPTY_BUFFER: EMPTY_BUFFER$1 } = constants;
|
|
@@ -1507,7 +1559,7 @@ let Sender$1 = class Sender {
|
|
|
1507
1559
|
/**
|
|
1508
1560
|
* Creates a Sender instance.
|
|
1509
1561
|
*
|
|
1510
|
-
* @param {
|
|
1562
|
+
* @param {Duplex} socket The connection socket
|
|
1511
1563
|
* @param {Object} [extensions] An object containing the negotiated extensions
|
|
1512
1564
|
* @param {Function} [generateMask] The function used to generate the masking
|
|
1513
1565
|
* key
|
|
@@ -2456,14 +2508,14 @@ function format$1(extensions) {
|
|
|
2456
2508
|
|
|
2457
2509
|
var extension$1 = { format: format$1, parse: parse$2 };
|
|
2458
2510
|
|
|
2459
|
-
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Readable$" }] */
|
|
2511
|
+
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex|Readable$" }] */
|
|
2460
2512
|
|
|
2461
2513
|
const EventEmitter$1 = require$$0$3;
|
|
2462
|
-
const https = require$$1;
|
|
2514
|
+
const https = require$$1$1;
|
|
2463
2515
|
const http$1 = require$$2;
|
|
2464
2516
|
const net = require$$3;
|
|
2465
2517
|
const tls = require$$4;
|
|
2466
|
-
const { randomBytes, createHash: createHash$1 } = require$$
|
|
2518
|
+
const { randomBytes, createHash: createHash$1 } = require$$1;
|
|
2467
2519
|
const { URL } = require$$7;
|
|
2468
2520
|
|
|
2469
2521
|
const PerMessageDeflate$1 = permessageDeflate;
|
|
@@ -2644,8 +2696,7 @@ let WebSocket$1 = class WebSocket extends EventEmitter$1 {
|
|
|
2644
2696
|
/**
|
|
2645
2697
|
* Set up the socket and the internal resources.
|
|
2646
2698
|
*
|
|
2647
|
-
* @param {
|
|
2648
|
-
* server and client
|
|
2699
|
+
* @param {Duplex} socket The network socket between the server and client
|
|
2649
2700
|
* @param {Buffer} head The first packet of the upgraded stream
|
|
2650
2701
|
* @param {Object} options Options object
|
|
2651
2702
|
* @param {Function} [options.generateMask] The function used to generate the
|
|
@@ -2678,8 +2729,11 @@ let WebSocket$1 = class WebSocket extends EventEmitter$1 {
|
|
|
2678
2729
|
receiver.on('ping', receiverOnPing);
|
|
2679
2730
|
receiver.on('pong', receiverOnPong);
|
|
2680
2731
|
|
|
2681
|
-
|
|
2682
|
-
socket
|
|
2732
|
+
//
|
|
2733
|
+
// These methods may not be available if `socket` is just a `Duplex`.
|
|
2734
|
+
//
|
|
2735
|
+
if (socket.setTimeout) socket.setTimeout(0);
|
|
2736
|
+
if (socket.setNoDelay) socket.setNoDelay();
|
|
2683
2737
|
|
|
2684
2738
|
if (head.length > 0) socket.unshift(head);
|
|
2685
2739
|
|
|
@@ -3122,24 +3176,30 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
3122
3176
|
|
|
3123
3177
|
if (address instanceof URL) {
|
|
3124
3178
|
parsedUrl = address;
|
|
3125
|
-
websocket._url = address.href;
|
|
3126
3179
|
} else {
|
|
3127
3180
|
try {
|
|
3128
3181
|
parsedUrl = new URL(address);
|
|
3129
3182
|
} catch (e) {
|
|
3130
3183
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
3131
3184
|
}
|
|
3185
|
+
}
|
|
3132
3186
|
|
|
3133
|
-
|
|
3187
|
+
if (parsedUrl.protocol === 'http:') {
|
|
3188
|
+
parsedUrl.protocol = 'ws:';
|
|
3189
|
+
} else if (parsedUrl.protocol === 'https:') {
|
|
3190
|
+
parsedUrl.protocol = 'wss:';
|
|
3134
3191
|
}
|
|
3135
3192
|
|
|
3193
|
+
websocket._url = parsedUrl.href;
|
|
3194
|
+
|
|
3136
3195
|
const isSecure = parsedUrl.protocol === 'wss:';
|
|
3137
3196
|
const isIpcUrl = parsedUrl.protocol === 'ws+unix:';
|
|
3138
3197
|
let invalidUrlMessage;
|
|
3139
3198
|
|
|
3140
3199
|
if (parsedUrl.protocol !== 'ws:' && !isSecure && !isIpcUrl) {
|
|
3141
3200
|
invalidUrlMessage =
|
|
3142
|
-
'The URL\'s protocol must be one of "ws:", "wss:",
|
|
3201
|
+
'The URL\'s protocol must be one of "ws:", "wss:", ' +
|
|
3202
|
+
'"http:", "https", or "ws+unix:"';
|
|
3143
3203
|
} else if (isIpcUrl && !parsedUrl.pathname) {
|
|
3144
3204
|
invalidUrlMessage = "The URL's pathname is empty";
|
|
3145
3205
|
} else if (parsedUrl.hash) {
|
|
@@ -3673,7 +3733,7 @@ function resume(stream) {
|
|
|
3673
3733
|
}
|
|
3674
3734
|
|
|
3675
3735
|
/**
|
|
3676
|
-
* The listener of the
|
|
3736
|
+
* The listener of the socket `'close'` event.
|
|
3677
3737
|
*
|
|
3678
3738
|
* @private
|
|
3679
3739
|
*/
|
|
@@ -3724,7 +3784,7 @@ function socketOnClose() {
|
|
|
3724
3784
|
}
|
|
3725
3785
|
|
|
3726
3786
|
/**
|
|
3727
|
-
* The listener of the
|
|
3787
|
+
* The listener of the socket `'data'` event.
|
|
3728
3788
|
*
|
|
3729
3789
|
* @param {Buffer} chunk A chunk of data
|
|
3730
3790
|
* @private
|
|
@@ -3736,7 +3796,7 @@ function socketOnData(chunk) {
|
|
|
3736
3796
|
}
|
|
3737
3797
|
|
|
3738
3798
|
/**
|
|
3739
|
-
* The listener of the
|
|
3799
|
+
* The listener of the socket `'end'` event.
|
|
3740
3800
|
*
|
|
3741
3801
|
* @private
|
|
3742
3802
|
*/
|
|
@@ -3749,7 +3809,7 @@ function socketOnEnd() {
|
|
|
3749
3809
|
}
|
|
3750
3810
|
|
|
3751
3811
|
/**
|
|
3752
|
-
* The listener of the
|
|
3812
|
+
* The listener of the socket `'error'` event.
|
|
3753
3813
|
*
|
|
3754
3814
|
* @private
|
|
3755
3815
|
*/
|
|
@@ -3826,11 +3886,11 @@ function parse(header) {
|
|
|
3826
3886
|
|
|
3827
3887
|
var subprotocol$1 = { parse };
|
|
3828
3888
|
|
|
3829
|
-
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^
|
|
3889
|
+
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex$" }] */
|
|
3830
3890
|
|
|
3831
3891
|
const EventEmitter = require$$0$3;
|
|
3832
3892
|
const http = require$$2;
|
|
3833
|
-
const { createHash } = require$$
|
|
3893
|
+
const { createHash } = require$$1;
|
|
3834
3894
|
|
|
3835
3895
|
const extension = extension$1;
|
|
3836
3896
|
const PerMessageDeflate = permessageDeflate;
|
|
@@ -4044,8 +4104,7 @@ class WebSocketServer extends EventEmitter {
|
|
|
4044
4104
|
* Handle a HTTP Upgrade request.
|
|
4045
4105
|
*
|
|
4046
4106
|
* @param {http.IncomingMessage} req The request object
|
|
4047
|
-
* @param {
|
|
4048
|
-
* server and client
|
|
4107
|
+
* @param {Duplex} socket The network socket between the server and client
|
|
4049
4108
|
* @param {Buffer} head The first packet of the upgraded stream
|
|
4050
4109
|
* @param {Function} cb Callback
|
|
4051
4110
|
* @public
|
|
@@ -4169,8 +4228,7 @@ class WebSocketServer extends EventEmitter {
|
|
|
4169
4228
|
* @param {String} key The value of the `Sec-WebSocket-Key` header
|
|
4170
4229
|
* @param {Set} protocols The subprotocols
|
|
4171
4230
|
* @param {http.IncomingMessage} req The request object
|
|
4172
|
-
* @param {
|
|
4173
|
-
* server and client
|
|
4231
|
+
* @param {Duplex} socket The network socket between the server and client
|
|
4174
4232
|
* @param {Buffer} head The first packet of the upgraded stream
|
|
4175
4233
|
* @param {Function} cb Callback
|
|
4176
4234
|
* @throws {Error} If called more than once with the same socket
|
|
@@ -4300,7 +4358,7 @@ function socketOnError() {
|
|
|
4300
4358
|
/**
|
|
4301
4359
|
* Close the connection when preconditions are not fulfilled.
|
|
4302
4360
|
*
|
|
4303
|
-
* @param {
|
|
4361
|
+
* @param {Duplex} socket The socket of the upgrade request
|
|
4304
4362
|
* @param {Number} code The HTTP response status code
|
|
4305
4363
|
* @param {String} [message] The HTTP response body
|
|
4306
4364
|
* @param {Object} [headers] Additional HTTP response headers
|
|
@@ -4341,7 +4399,7 @@ function abortHandshake(socket, code, message, headers) {
|
|
|
4341
4399
|
*
|
|
4342
4400
|
* @param {WebSocketServer} server The WebSocket server
|
|
4343
4401
|
* @param {http.IncomingMessage} req The request object
|
|
4344
|
-
* @param {
|
|
4402
|
+
* @param {Duplex} socket The socket of the upgrade request
|
|
4345
4403
|
* @param {Number} code The HTTP response status code
|
|
4346
4404
|
* @param {String} message The HTTP response body
|
|
4347
4405
|
* @private
|
package/dist/jsenv_core.js
CHANGED
|
@@ -7751,9 +7751,10 @@ const getCompressedResponse = async ({ sourceUrl, headers }) => {
|
|
|
7751
7751
|
}
|
|
7752
7752
|
|
|
7753
7753
|
const fileReadableStream = fileUrlToReadableStream(sourceUrl);
|
|
7754
|
-
const body =
|
|
7755
|
-
|
|
7756
|
-
|
|
7754
|
+
const body =
|
|
7755
|
+
await availableCompressionFormats[acceptedCompressionFormat](
|
|
7756
|
+
fileReadableStream,
|
|
7757
|
+
);
|
|
7757
7758
|
|
|
7758
7759
|
return {
|
|
7759
7760
|
status: 200,
|
|
@@ -10579,9 +10580,13 @@ const jsenvPluginJsModuleFallbackOnWorkers = () => {
|
|
|
10579
10580
|
name: `jsenv:js_module_fallback_on_${subtype}`,
|
|
10580
10581
|
appliesDuring: "*",
|
|
10581
10582
|
init: (context) => {
|
|
10583
|
+
if (Object.keys(context.runtimeCompat).toString() === "node") {
|
|
10584
|
+
return false;
|
|
10585
|
+
}
|
|
10582
10586
|
if (context.isSupportedOnCurrentClients(`${subtype}_type_module`)) {
|
|
10583
10587
|
return false;
|
|
10584
10588
|
}
|
|
10589
|
+
|
|
10585
10590
|
return true;
|
|
10586
10591
|
},
|
|
10587
10592
|
redirectReference: {
|
|
@@ -15482,6 +15487,8 @@ const parseAndTransformJsReferences = async (
|
|
|
15482
15487
|
const magicSource = createMagicSource(urlInfo.content);
|
|
15483
15488
|
const parallelActions = [];
|
|
15484
15489
|
const sequentialActions = [];
|
|
15490
|
+
const isNodeJs =
|
|
15491
|
+
Object.keys(urlInfo.context.runtimeCompat).toString() === "node";
|
|
15485
15492
|
|
|
15486
15493
|
const onInlineReference = (inlineReferenceInfo) => {
|
|
15487
15494
|
const inlineUrl = getUrlForContentInsideJs(inlineReferenceInfo, {
|
|
@@ -15529,6 +15536,19 @@ const parseAndTransformJsReferences = async (
|
|
|
15529
15536
|
) {
|
|
15530
15537
|
urlInfo.data.usesImport = true;
|
|
15531
15538
|
}
|
|
15539
|
+
if (
|
|
15540
|
+
isNodeJs &&
|
|
15541
|
+
externalReferenceInfo.type === "js_url" &&
|
|
15542
|
+
externalReferenceInfo.expectedSubtype === "worker" &&
|
|
15543
|
+
externalReferenceInfo.expectedType === "js_classic" &&
|
|
15544
|
+
// TODO: it's true also if closest package.json
|
|
15545
|
+
// is type: module
|
|
15546
|
+
urlToExtension$1(
|
|
15547
|
+
new URL(externalReferenceInfo.specifier, urlInfo.url).href,
|
|
15548
|
+
) === ".mjs"
|
|
15549
|
+
) {
|
|
15550
|
+
externalReferenceInfo.expectedType = "js_module";
|
|
15551
|
+
}
|
|
15532
15552
|
const reference = urlInfo.dependencies.found({
|
|
15533
15553
|
type: externalReferenceInfo.type,
|
|
15534
15554
|
subtype: externalReferenceInfo.subtype,
|
|
@@ -15571,6 +15591,7 @@ const parseAndTransformJsReferences = async (
|
|
|
15571
15591
|
isJsModule: urlInfo.type === "js_module",
|
|
15572
15592
|
isWebWorker: isWebWorkerUrlInfo(urlInfo),
|
|
15573
15593
|
inlineContent,
|
|
15594
|
+
isNodeJs,
|
|
15574
15595
|
});
|
|
15575
15596
|
for (const jsReferenceInfo of jsReferenceInfos) {
|
|
15576
15597
|
if (jsReferenceInfo.isInline) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "38.2.
|
|
3
|
+
"version": "38.2.2",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -61,26 +61,26 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
63
63
|
"@jsenv/abort": "4.2.4",
|
|
64
|
-
"@jsenv/ast": "5.1.
|
|
64
|
+
"@jsenv/ast": "5.1.4",
|
|
65
65
|
"@jsenv/filesystem": "4.2.6",
|
|
66
66
|
"@jsenv/importmap": "1.2.1",
|
|
67
67
|
"@jsenv/integrity": "0.0.1",
|
|
68
68
|
"@jsenv/log": "3.4.0",
|
|
69
69
|
"@jsenv/node-esm-resolution": "1.0.1",
|
|
70
|
-
"@jsenv/js-module-fallback": "1.3.
|
|
70
|
+
"@jsenv/js-module-fallback": "1.3.5",
|
|
71
71
|
"@jsenv/runtime-compat": "1.2.0",
|
|
72
|
-
"@jsenv/server": "15.1.
|
|
73
|
-
"@jsenv/sourcemap": "1.2.
|
|
74
|
-
"@jsenv/plugin-bundling": "2.5.
|
|
75
|
-
"@jsenv/plugin-minification": "1.5.
|
|
76
|
-
"@jsenv/plugin-transpilation": "1.3.
|
|
77
|
-
"@jsenv/plugin-supervisor": "1.3.
|
|
72
|
+
"@jsenv/server": "15.1.2",
|
|
73
|
+
"@jsenv/sourcemap": "1.2.3",
|
|
74
|
+
"@jsenv/plugin-bundling": "2.5.4",
|
|
75
|
+
"@jsenv/plugin-minification": "1.5.2",
|
|
76
|
+
"@jsenv/plugin-transpilation": "1.3.4",
|
|
77
|
+
"@jsenv/plugin-supervisor": "1.3.4",
|
|
78
78
|
"@jsenv/url-meta": "8.1.0",
|
|
79
79
|
"@jsenv/urls": "2.2.1",
|
|
80
80
|
"@jsenv/utils": "2.0.1"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@babel/eslint-parser": "7.22.
|
|
83
|
+
"@babel/eslint-parser": "7.22.15",
|
|
84
84
|
"@babel/plugin-syntax-import-assertions": "7.22.5",
|
|
85
85
|
"babel-plugin-transform-async-to-promises": "0.8.18",
|
|
86
86
|
"@jsenv/assert": "./packages/independent/assert/",
|
|
@@ -92,12 +92,12 @@
|
|
|
92
92
|
"@jsenv/performance-impact": "4.1.1",
|
|
93
93
|
"@jsenv/plugin-as-js-classic": "./packages/related/plugin-as-js-classic/",
|
|
94
94
|
"@jsenv/test": "./packages/related/test/",
|
|
95
|
-
"eslint": "8.
|
|
95
|
+
"eslint": "8.50.0",
|
|
96
96
|
"eslint-plugin-html": "7.1.0",
|
|
97
|
-
"eslint-plugin-import": "2.28.
|
|
98
|
-
"eslint-plugin-react": "7.33.
|
|
97
|
+
"eslint-plugin-import": "2.28.1",
|
|
98
|
+
"eslint-plugin-react": "7.33.2",
|
|
99
99
|
"open": "9.1.0",
|
|
100
|
-
"playwright": "1.
|
|
101
|
-
"prettier": "3.0.
|
|
100
|
+
"playwright": "1.38.1",
|
|
101
|
+
"prettier": "3.0.3"
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createMagicSource } from "@jsenv/sourcemap";
|
|
2
2
|
import { parseJsUrls, getUrlForContentInsideJs } from "@jsenv/ast";
|
|
3
|
+
import { urlToExtension } from "@jsenv/urls";
|
|
3
4
|
import { JS_QUOTES } from "@jsenv/utils/src/string/js_quotes.js";
|
|
4
5
|
|
|
5
6
|
import { isWebWorkerUrlInfo } from "@jsenv/core/src/kitchen/web_workers.js";
|
|
@@ -34,6 +35,8 @@ const parseAndTransformJsReferences = async (
|
|
|
34
35
|
const magicSource = createMagicSource(urlInfo.content);
|
|
35
36
|
const parallelActions = [];
|
|
36
37
|
const sequentialActions = [];
|
|
38
|
+
const isNodeJs =
|
|
39
|
+
Object.keys(urlInfo.context.runtimeCompat).toString() === "node";
|
|
37
40
|
|
|
38
41
|
const onInlineReference = (inlineReferenceInfo) => {
|
|
39
42
|
const inlineUrl = getUrlForContentInsideJs(inlineReferenceInfo, {
|
|
@@ -81,6 +84,19 @@ const parseAndTransformJsReferences = async (
|
|
|
81
84
|
) {
|
|
82
85
|
urlInfo.data.usesImport = true;
|
|
83
86
|
}
|
|
87
|
+
if (
|
|
88
|
+
isNodeJs &&
|
|
89
|
+
externalReferenceInfo.type === "js_url" &&
|
|
90
|
+
externalReferenceInfo.expectedSubtype === "worker" &&
|
|
91
|
+
externalReferenceInfo.expectedType === "js_classic" &&
|
|
92
|
+
// TODO: it's true also if closest package.json
|
|
93
|
+
// is type: module
|
|
94
|
+
urlToExtension(
|
|
95
|
+
new URL(externalReferenceInfo.specifier, urlInfo.url).href,
|
|
96
|
+
) === ".mjs"
|
|
97
|
+
) {
|
|
98
|
+
externalReferenceInfo.expectedType = "js_module";
|
|
99
|
+
}
|
|
84
100
|
const reference = urlInfo.dependencies.found({
|
|
85
101
|
type: externalReferenceInfo.type,
|
|
86
102
|
subtype: externalReferenceInfo.subtype,
|
|
@@ -123,6 +139,7 @@ const parseAndTransformJsReferences = async (
|
|
|
123
139
|
isJsModule: urlInfo.type === "js_module",
|
|
124
140
|
isWebWorker: isWebWorkerUrlInfo(urlInfo),
|
|
125
141
|
inlineContent,
|
|
142
|
+
isNodeJs,
|
|
126
143
|
});
|
|
127
144
|
for (const jsReferenceInfo of jsReferenceInfos) {
|
|
128
145
|
if (jsReferenceInfo.isInline) {
|