Skip to content

Commit

Permalink
35.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dmail committed Apr 26, 2023
1 parent 0353f50 commit 7b7d7f7
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 172 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 35.0.1

- Update dependencies

# 35.0.0

- Introduce `@jsenv/test` and update how runtimes are configured
Expand Down
146 changes: 1 addition & 145 deletions dist/js/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,147 +12,6 @@ import require$$7 from "url";
function getDefaultExportFromCjs(x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
const {
Duplex
} = require$$0;

/**
* Emits the `'close'` event on a stream.
*
* @param {Duplex} stream The stream.
* @private
*/
function emitClose$1(stream) {
stream.emit('close');
}

/**
* The listener of the `'end'` event.
*
* @private
*/
function duplexOnEnd() {
if (!this.destroyed && this._writableState.finished) {
this.destroy();
}
}

/**
* The listener of the `'error'` event.
*
* @param {Error} err The error
* @private
*/
function duplexOnError(err) {
this.removeListener('error', duplexOnError);
this.destroy();
if (this.listenerCount('error') === 0) {
// Do not suppress the throwing behavior.
this.emit('error', err);
}
}

/**
* Wraps a `WebSocket` in a duplex stream.
*
* @param {WebSocket} ws The `WebSocket` to wrap
* @param {Object} [options] The options for the `Duplex` constructor
* @return {Duplex} The duplex stream
* @public
*/
function createWebSocketStream(ws, options) {
let terminateOnDestroy = true;
const duplex = new Duplex({
...options,
autoDestroy: false,
emitClose: false,
objectMode: false,
writableObjectMode: false
});
ws.on('message', function message(msg, isBinary) {
const data = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
if (!duplex.push(data)) ws.pause();
});
ws.once('error', function error(err) {
if (duplex.destroyed) return;

// Prevent `ws.terminate()` from being called by `duplex._destroy()`.
//
// - If the `'error'` event is emitted before the `'open'` event, then
// `ws.terminate()` is a noop as no socket is assigned.
// - Otherwise, the error is re-emitted by the listener of the `'error'`
// event of the `Receiver` object. The listener already closes the
// connection by calling `ws.close()`. This allows a close frame to be
// sent to the other peer. If `ws.terminate()` is called right after this,
// then the close frame might not be sent.
terminateOnDestroy = false;
duplex.destroy(err);
});
ws.once('close', function close() {
if (duplex.destroyed) return;
duplex.push(null);
});
duplex._destroy = function (err, callback) {
if (ws.readyState === ws.CLOSED) {
callback(err);
process.nextTick(emitClose$1, duplex);
return;
}
let called = false;
ws.once('error', function error(err) {
called = true;
callback(err);
});
ws.once('close', function close() {
if (!called) callback(err);
process.nextTick(emitClose$1, duplex);
});
if (terminateOnDestroy) ws.terminate();
};
duplex._final = function (callback) {
if (ws.readyState === ws.CONNECTING) {
ws.once('open', function open() {
duplex._final(callback);
});
return;
}

// If the value of the `_socket` property is `null` it means that `ws` is a
// client websocket and the handshake failed. In fact, when this happens, a
// socket is never assigned to the websocket. Wait for the `'error'` event
// that will be emitted by the websocket.
if (ws._socket === null) return;
if (ws._socket._writableState.finished) {
callback();
if (duplex._readableState.endEmitted) duplex.destroy();
} else {
ws._socket.once('finish', function finish() {
// `duplex` is not destroyed here because the `'end'` event will be
// emitted on `duplex` after this `'finish'` event. The EOF signaling
// `null` chunk is, in fact, pushed when the websocket emits `'close'`.
callback();
});
ws.close();
}
};
duplex._read = function () {
if (ws.isPaused) ws.resume();
};
duplex._write = function (chunk, encoding, callback) {
if (ws.readyState === ws.CONNECTING) {
ws.once('open', function open() {
duplex._write(chunk, encoding, callback);
});
return;
}
ws.send(chunk, callback);
};
duplex.on('end', duplexOnEnd);
duplex.on('error', duplexOnError);
return duplex;
}
var stream = createWebSocketStream;
var stream$1 = /*@__PURE__*/getDefaultExportFromCjs(stream);
var bufferUtil$1 = {
exports: {}
};
Expand Down Expand Up @@ -1303,7 +1162,6 @@ function error(ErrorCtor, message, prefix, statusCode, errorCode) {
err[kStatusCode$1] = statusCode;
return err;
}
var receiver$1 = /*@__PURE__*/getDefaultExportFromCjs(receiver);

/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^net|tls$" }] */
const {
Expand Down Expand Up @@ -1720,7 +1578,6 @@ let Sender$1 = class Sender {
}
};
var sender = Sender$1;
var sender$1 = /*@__PURE__*/getDefaultExportFromCjs(sender);
const {
kForOnEventAttribute: kForOnEventAttribute$1,
kListener: kListener$1
Expand Down Expand Up @@ -3312,7 +3169,6 @@ function socketOnError$1() {
this.destroy();
}
}
var WebSocket$2 = /*@__PURE__*/getDefaultExportFromCjs(websocket);
const {
tokenChars
} = validationExports;
Expand Down Expand Up @@ -3800,4 +3656,4 @@ function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
}
var websocketServer$1 = /*@__PURE__*/getDefaultExportFromCjs(websocketServer);

export { receiver$1 as Receiver, sender$1 as Sender, WebSocket$2 as WebSocket, websocketServer$1 as WebSocketServer, stream$1 as createWebSocketStream, WebSocket$2 as default };
export { websocketServer$1 as WebSocketServer };
2 changes: 2 additions & 0 deletions dist/jsenv_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3359,6 +3359,8 @@ ansiEscapes.clearTerminal = isWindows ? `${ansiEscapes.eraseScreen}${ESC}0f`
// 3. Moves cursor to the top-left position
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
: `${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`;
ansiEscapes.enterAlternativeScreen = ESC + '?1049h';
ansiEscapes.exitAlternativeScreen = ESC + '?1049l';
ansiEscapes.beep = BEL;
ansiEscapes.link = (text, url) => [OSC, '8', SEP, SEP, url, BEL, text, OSC, '8', SEP, SEP, BEL].join('');
ansiEscapes.image = (buffer, options = {}) => {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jsenv/core",
"version": "35.0.0",
"version": "35.0.1",
"description": "Tool to develop, test and build js projects",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -76,7 +76,7 @@
"@jsenv/utils": "2.0.1",
"construct-style-sheets-polyfill": "3.1.0",
"launch-editor": "2.6.0",
"lightningcss": "1.19.0"
"lightningcss": "1.20.0"
},
"devDependencies": {
"@babel/eslint-parser": "7.21.3",
Expand All @@ -92,11 +92,11 @@
"@jsenv/plugin-placeholders": "./packages/jsenv-plugin-placeholders/",
"@jsenv/plugin-as-js-classic": "./packages/jsenv-plugin-as-js-classic/",
"@jsenv/test": "./packages/test/",
"eslint": "8.38.0",
"eslint": "8.39.0",
"eslint-plugin-html": "7.1.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-react": "7.32.2",
"playwright": "1.32.3",
"prettier": "2.8.7"
"prettier": "2.8.8"
}
}
2 changes: 1 addition & 1 deletion packages/ast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"acorn-import-assertions": "1.8.0",
"acorn-walk": "8.2.0",
"parse5": "7.1.2",
"postcss": "8.4.22",
"postcss": "8.4.23",
"postcss-value-parser": "4.2.0"
}
}
4 changes: 2 additions & 2 deletions packages/create-jsenv/demo-node-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
},
"devDependencies": {
"@jsenv/assert": "2.8.1",
"@jsenv/core": "35.0.0",
"@jsenv/core": "35.0.1",
"@jsenv/eslint-config": "16.3.9",
"@jsenv/eslint-import-resolver": "0.4.10",
"@jsenv/test": "1.0.0",
"@jsenv/test": "1.0.1",
"eslint": "8.39.0",
"eslint-plugin-import": "2.27.5",
"prettier": "2.8.8"
Expand Down
4 changes: 2 additions & 2 deletions packages/create-jsenv/demo-web-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
"@babel/plugin-syntax-import-assertions": "7.20.0",
"@babel/plugin-transform-react-jsx": "7.21.0",
"@jsenv/assert": "2.8.1",
"@jsenv/core": "35.0.0",
"@jsenv/core": "35.0.1",
"@jsenv/plugin-preact": "1.2.25",
"@jsenv/plugin-bundling": "2.1.6",
"@jsenv/plugin-minification": "1.2.2",
"@jsenv/eslint-config": "16.3.9",
"@jsenv/eslint-import-resolver": "0.4.10",
"@jsenv/test": "1.0.0",
"@jsenv/test": "1.0.1",
"eslint": "8.39.0",
"eslint-plugin-html": "7.1.0",
"eslint-plugin-import": "2.27.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/create-jsenv/demo-web-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
"@babel/plugin-syntax-import-assertions": "7.20.0",
"@babel/plugin-transform-react-jsx": "7.21.0",
"@jsenv/assert": "2.8.1",
"@jsenv/core": "35.0.0",
"@jsenv/core": "35.0.1",
"@jsenv/plugin-react": "1.2.16",
"@jsenv/plugin-bundling": "2.1.6",
"@jsenv/plugin-minification": "1.2.2",
"@jsenv/eslint-config": "16.3.9",
"@jsenv/eslint-import-resolver": "0.4.10",
"@jsenv/test": "1.0.0",
"@jsenv/test": "1.0.1",
"eslint": "8.39.0",
"eslint-plugin-html": "7.1.0",
"eslint-plugin-import": "2.27.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/create-jsenv/demo-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
"@babel/eslint-parser": "7.21.3",
"@babel/plugin-syntax-import-assertions": "7.20.0",
"@jsenv/assert": "2.8.1",
"@jsenv/core": "35.0.0",
"@jsenv/core": "35.0.1",
"@jsenv/plugin-bundling": "2.1.6",
"@jsenv/plugin-minification": "1.2.2",
"@jsenv/eslint-config": "16.3.9",
"@jsenv/eslint-import-resolver": "0.4.10",
"@jsenv/test": "1.0.0",
"@jsenv/test": "1.0.1",
"eslint": "8.39.0",
"eslint-plugin-html": "7.1.0",
"eslint-plugin-import": "2.27.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-jsenv/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-jsenv",
"version": "1.7.15",
"version": "1.7.16",
"description": "npm initializer for jsenv",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-import-resolver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
"@jsenv/node-esm-resolution": "1.0.1"
},
"devDependencies": {
"rollup": "3.20.4"
"rollup": "3.21.0"
}
}
4 changes: 2 additions & 2 deletions packages/jsenv-plugin-as-js-classic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jsenv/plugin-as-js-classic",
"version": "1.0.4",
"version": "1.0.5",
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -24,7 +24,7 @@
"test": "node --conditions=development ./scripts/test.mjs"
},
"dependencies": {
"@jsenv/core": "35.0.0",
"@jsenv/core": "35.0.1",
"@jsenv/plugin-bundling": "2.1.6"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/jsenv-plugin-bundling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"@jsenv/urls": "2.0.0",
"@jsenv/sourcemap": "1.0.10",
"acorn-import-assertions": "1.8.0",
"lightningcss": "1.19.0",
"rollup": "3.20.4"
"lightningcss": "1.20.0",
"rollup": "3.21.0"
},
"peerDependencies": {
"@jsenv/core": "*"
Expand Down
6 changes: 3 additions & 3 deletions packages/jsenv-plugin-commonjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
"@rollup/plugin-replace": "5.0.2",
"cjs-module-lexer": "1.2.2",
"is-valid-identifier": "2.0.2",
"resolve": "1.22.3",
"rollup": "3.20.4",
"resolve": "1.22.2",
"rollup": "3.21.0",
"rollup-plugin-node-globals": "1.4.0",
"rollup-plugin-polyfill-node": "0.12.0",
"vm2": "3.9.16"
"vm2": "3.9.17"
},
"devDependencies": {
"@jsenv/core": "../../"
Expand Down
4 changes: 2 additions & 2 deletions packages/jsenv-plugin-minification/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
},
"dependencies": {
"html-minifier": "4.0.0",
"lightningcss": "1.19.0",
"terser": "5.16.9"
"lightningcss": "1.20.0",
"terser": "5.17.1"
},
"peerDependencies": {
"@jsenv/core": "*"
Expand Down
2 changes: 1 addition & 1 deletion packages/log/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"test": "node --conditions=development ./scripts/test.mjs"
},
"dependencies": {
"ansi-escapes": "6.1.0",
"ansi-escapes": "6.2.0",
"is-unicode-supported": "1.3.0",
"string-width": "5.1.2",
"supports-color": "9.3.1"
Expand Down
2 changes: 2 additions & 0 deletions packages/test/dist/jsenv_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2081,6 +2081,8 @@ ansiEscapes.clearTerminal = isWindows ? `${ansiEscapes.eraseScreen}${ESC}0f`
// 3. Moves cursor to the top-left position
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
: `${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`;
ansiEscapes.enterAlternativeScreen = ESC + '?1049h';
ansiEscapes.exitAlternativeScreen = ESC + '?1049l';
ansiEscapes.beep = BEL;
ansiEscapes.link = (text, url) => [OSC, '8', SEP, SEP, url, BEL, text, OSC, '8', SEP, SEP, BEL].join('');
ansiEscapes.image = (buffer, options = {}) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jsenv/test",
"version": "1.0.0",
"version": "1.0.1",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -33,7 +33,7 @@
"playwright": "1.x"
},
"dependencies": {
"@jsenv/core": "35.0.0",
"@jsenv/core": "35.0.1",
"@jsenv/abort": "4.2.4",
"@jsenv/ast": "3.0.6",
"@jsenv/filesystem": "4.2.3",
Expand Down

0 comments on commit 7b7d7f7

Please sign in to comment.