Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@miniflare/web-sockets

Package Overview
Dependencies
Maintainers
4
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@miniflare/web-sockets - npm Package Compare versions

Comparing version 2.8.1 to 2.9.0-next.1

3

dist/src/index.d.ts

@@ -42,2 +42,4 @@ import { Dispatcher } from 'undici';

declare const kSend: unique symbol;
export declare class MessageEvent extends Event {

@@ -61,2 +63,3 @@ readonly data: ArrayBuffer | string;

send(message: ArrayBuffer | string): void;
[kSend](message: ArrayBuffer | string): void;
close(code?: number, reason?: string): void;

@@ -63,0 +66,0 @@ [kClose](code?: number, reason?: string): void;

47

dist/src/index.js

@@ -44,2 +44,3 @@ var __create = Object.create;

// packages/web-sockets/src/couple.ts
var import_events = __toModule(require("events"));
var import_shared2 = __toModule(require("@miniflare/shared"));

@@ -80,2 +81,3 @@ var import_ws = __toModule(require("ws"));

var kClosed = Symbol("kClosed");
var kSend = Symbol("kSend");
var kClose = Symbol("kClose");

@@ -122,2 +124,5 @@ var WebSocket = class extends import_shared.InputGatedEventTarget {

}
this[kSend](message);
}
[kSend](message) {
if (this[kClosed]) {

@@ -186,15 +191,6 @@ throw new TypeError("Can't call WebSocket send() after close().");

ws.on("message", (message, isBinary) => {
if (isBinary) {
pair.send((0, import_shared2.viewToBuffer)(message));
} else {
pair.send(message.toString());
if (!pair[kClosed]) {
pair[kSend](isBinary ? (0, import_shared2.viewToBuffer)(message) : message.toString());
}
});
ws.on("close", (code, reason) => {
if (!pair[kClosed])
pair[kClose](code, reason.toString());
});
ws.on("error", (error) => {
pair.dispatchEvent(new ErrorEvent("error", { error }));
});
pair.addEventListener("message", (e) => {

@@ -213,20 +209,15 @@ ws.send(e.data);

if (ws.readyState === import_ws.default.CONNECTING) {
await new Promise((resolve, reject) => {
ws.once("open", () => {
pair.accept();
pair[kCoupled] = true;
ws.off("close", reject);
ws.off("error", reject);
resolve();
});
ws.once("close", reject);
ws.once("error", reject);
});
} else {
pair.accept();
pair[kCoupled] = true;
if (ws.readyState >= import_ws.default.CLOSING) {
throw new TypeError("Incoming WebSocket connection already closed.");
}
await (0, import_events.once)(ws, "open");
} else if (ws.readyState >= import_ws.default.CLOSING) {
throw new TypeError("Incoming WebSocket connection already closed.");
}
pair.accept();
pair[kCoupled] = true;
ws.on("close", (code, reason) => {
if (!pair[kClosed])
pair[kClose](code, reason.toString());
});
ws.on("error", (error) => {
pair.dispatchEvent(new ErrorEvent("error", { error }));
});
}

@@ -233,0 +224,0 @@

{
"name": "@miniflare/web-sockets",
"version": "2.8.1",
"version": "2.9.0-next.1",
"description": "WebSocket module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers",

@@ -38,4 +38,4 @@ "keywords": [

"dependencies": {
"@miniflare/core": "2.8.1",
"@miniflare/shared": "2.8.1",
"@miniflare/core": "2.9.0-next.1",
"@miniflare/shared": "2.9.0-next.1",
"undici": "5.9.1",

@@ -45,5 +45,5 @@ "ws": "^8.2.2"

"devDependencies": {
"@miniflare/shared-test": "2.8.1",
"@miniflare/shared-test": "2.9.0-next.1",
"@types/ws": "^8.2.0"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc