🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

crossws

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crossws - npm Package Compare versions

Comparing version
0.4.3
to
0.4.4
+3
-2
dist/_chunks/_request.mjs

@@ -5,3 +5,3 @@ //#region src/_request.ts

url;
_signal;
_abortController;
_headers;

@@ -24,3 +24,4 @@ _init;

get signal() {
return this._signal ??= new AbortSignal();
if (!this._abortController) this._abortController = new AbortController();
return this._abortController.signal;
}

@@ -27,0 +28,0 @@ get cache() {

+40
-40

@@ -29,4 +29,4 @@ import { a as WebSocket } from "./web.mjs";

/**
* Unique random [uuid v4](https://developer.mozilla.org/en-US/docs/Glossary/UUID) identifier for the peer.
*/
* Unique random [uuid v4](https://developer.mozilla.org/en-US/docs/Glossary/UUID) identifier for the peer.
*/
get id(): string;

@@ -38,9 +38,9 @@ /** IP address of the peer */

/**
* Get the [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) instance.
*
* **Note:** crossws adds polyfill for the following properties if native values are not available:
* - `protocol`: Extracted from the `sec-websocket-protocol` header.
* - `extensions`: Extracted from the `sec-websocket-extensions` header.
* - `url`: Extracted from the request URL (http -> ws).
* */
* Get the [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) instance.
*
* **Note:** crossws adds polyfill for the following properties if native values are not available:
* - `protocol`: Extracted from the `sec-websocket-protocol` header.
* - `extensions`: Extracted from the `sec-websocket-extensions` header.
* - `url`: Extracted from the request URL (http -> ws).
* */
get websocket(): Partial<WebSocket>;

@@ -83,35 +83,35 @@ /** All connected peers to the server */

/**
* Unique random [uuid v4](https://developer.mozilla.org/en-US/docs/Glossary/UUID) identifier for the message.
*/
* Unique random [uuid v4](https://developer.mozilla.org/en-US/docs/Glossary/UUID) identifier for the message.
*/
get id(): string;
/**
* Get data as [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) value.
*
* If raw data is in any other format or string, it will be automatically converted and encoded.
*/
* Get data as [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) value.
*
* If raw data is in any other format or string, it will be automatically converted and encoded.
*/
uint8Array(): Uint8Array;
/**
* Get data as [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) or [SharedArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) value.
*
* If raw data is in any other format or string, it will be automatically converted and encoded.
*/
* Get data as [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) or [SharedArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) value.
*
* If raw data is in any other format or string, it will be automatically converted and encoded.
*/
arrayBuffer(): ArrayBuffer | SharedArrayBuffer;
/**
* Get data as [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) value.
*
* If raw data is in any other format or string, it will be automatically converted and encoded. */
* Get data as [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) value.
*
* If raw data is in any other format or string, it will be automatically converted and encoded. */
blob(): Blob;
/**
* Get stringified text version of the message.
*
* If raw data is in any other format, it will be automatically converted and decoded.
*/
* Get stringified text version of the message.
*
* If raw data is in any other format, it will be automatically converted and decoded.
*/
text(): string;
/**
* Get parsed version of the message text with [`JSON.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
*/
* Get parsed version of the message text with [`JSON.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
*/
json<T = unknown>(): T;
/**
* Message data (value varies based on `peer.websocket.binaryType`).
*/
* Message data (value varies based on `peer.websocket.binaryType`).
*/
get data(): unknown;

@@ -131,12 +131,12 @@ toString(): string;

/**
* Upgrading a request to a WebSocket connection.
*
* - You can throw a Response to abort the upgrade.
* - You can return { headers } to modify the response.
* - You can return { namespace } to change the pub/sub namespace.
* - You can return { context } to provide a custom peer context.
*
* @param request
* @throws {Response}
*/
* Upgrading a request to a WebSocket connection.
*
* - You can throw a Response to abort the upgrade.
* - You can return { headers } to modify the response.
* - You can return { namespace } to change the pub/sub namespace.
* - You can return { context } to provide a custom peer context.
*
* @param request
* @throws {Response}
*/
upgrade: (request: Request & {

@@ -143,0 +143,0 @@ readonly context?: Record<string, unknown>;

@@ -13,22 +13,22 @@ import { n as AdapterInstance, r as AdapterOptions, t as Adapter } from "./adapter.mjs";

/**
* Durable Object binding name from environment.
*
* **Note:** This option will be ignored if `resolveDurableStub` is provided.
*
* @default "$DurableObject"
*/
* Durable Object binding name from environment.
*
* **Note:** This option will be ignored if `resolveDurableStub` is provided.
*
* @default "$DurableObject"
*/
bindingName?: string;
/**
* Durable Object instance name.
*
* **Note:** This option will be ignored if `resolveDurableStub` is provided.
*
* @default "crossws"
*/
* Durable Object instance name.
*
* **Note:** This option will be ignored if `resolveDurableStub` is provided.
*
* @default "crossws"
*/
instanceName?: string;
/**
* Custom function that resolves Durable Object binding to handle the WebSocket upgrade.
*
* **Note:** This option will override `bindingName` and `instanceName`.
*/
* Custom function that resolves Durable Object binding to handle the WebSocket upgrade.
*
* **Note:** This option will override `bindingName` and `instanceName`.
*/
resolveDurableStub?: ResolveDurableStub;

@@ -35,0 +35,0 @@ }

@@ -73,11 +73,11 @@ import { n as AdapterInstance, r as AdapterOptions, t as Adapter } from "./adapter.mjs";

/**
* Pause the websocket causing it to stop emitting events. Some events can still be
* emitted after this is called, until all buffered data is consumed. This method
* is a noop if the ready state is `CONNECTING` or `CLOSED`.
*/
* Pause the websocket causing it to stop emitting events. Some events can still be
* emitted after this is called, until all buffered data is consumed. This method
* is a noop if the ready state is `CONNECTING` or `CLOSED`.
*/
pause(): void;
/**
* Make a paused socket resume emitting events. This method is a noop if the ready
* state is `CONNECTING` or `CLOSED`.
*/
* Make a paused socket resume emitting events. This method is a noop if the ready
* state is `CONNECTING` or `CLOSED`.
*/
resume(): void;

@@ -84,0 +84,0 @@ addEventListener(method: "message", cb: (event: MessageEvent) => void, options?: EventListenerOptions): void;

@@ -9,18 +9,18 @@ //#region types/web.d.ts

/**
* Returns the WebSocket connection close code provided by the server.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
*/
* Returns the WebSocket connection close code provided by the server.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
*/
readonly code: number;
/**
* Returns the WebSocket connection close reason provided by the server.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
*/
* Returns the WebSocket connection close reason provided by the server.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
*/
readonly reason: string;
/**
* Returns true if the connection closed cleanly; false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)
*/
* Returns true if the connection closed cleanly; false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)
*/
readonly wasClean: boolean;

@@ -35,108 +35,108 @@ }

/**
* Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
*/
* Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
*/
readonly bubbles: boolean;
/**
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
*/
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
*/
cancelBubble: boolean;
/**
* Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
*/
* Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
*/
readonly cancelable: boolean;
/**
* Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
*/
* Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
*/
readonly composed: boolean;
/**
* Returns the object whose event listener's callback is currently being invoked.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
*/
* Returns the object whose event listener's callback is currently being invoked.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
*/
readonly currentTarget: EventTarget | null;
/**
* Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
*/
* Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
*/
readonly defaultPrevented: boolean;
/**
* Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
*/
* Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
*/
readonly eventPhase: number;
/**
* Returns true if event was dispatched by the user agent, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
*/
* Returns true if event was dispatched by the user agent, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
*/
readonly isTrusted: boolean;
/**
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
*/
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
*/
returnValue: boolean;
/**
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
*/
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
*/
readonly srcElement: EventTarget | null;
/**
* Returns the object to which event is dispatched (its target).
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
*/
* Returns the object to which event is dispatched (its target).
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
*/
readonly target: EventTarget | null;
/**
* Returns the event's timestamp as the number of milliseconds measured relative to the time origin.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
*/
* Returns the event's timestamp as the number of milliseconds measured relative to the time origin.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
*/
readonly timeStamp: DOMHighResTimeStamp;
/**
* Returns the type of event, e.g. "click", "hashchange", or "submit".
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
*/
* Returns the type of event, e.g. "click", "hashchange", or "submit".
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
*/
readonly type: string;
/**
* Returns the invocation target objects of event's path (objects on which listeners will be invoked), except for any nodes in shadow trees of which the shadow root's mode is "closed" that are not reachable from event's currentTarget.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
*/
* Returns the invocation target objects of event's path (objects on which listeners will be invoked), except for any nodes in shadow trees of which the shadow root's mode is "closed" that are not reachable from event's currentTarget.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
*/
composedPath(): EventTarget[];
/**
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/initEvent)
*/
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/initEvent)
*/
initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
/**
* If invoked when the cancelable attribute value is true, and while executing a listener for the event with passive set to false, signals to the operation that caused event to be dispatched that it needs to be canceled.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
*/
* If invoked when the cancelable attribute value is true, and while executing a listener for the event with passive set to false, signals to the operation that caused event to be dispatched that it needs to be canceled.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
*/
preventDefault(): void;
/**
* Invoking this method prevents event from reaching any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any other objects.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
*/
* Invoking this method prevents event from reaching any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any other objects.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
*/
stopImmediatePropagation(): void;
/**
* When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
*/
* When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
*/
stopPropagation(): void;

@@ -155,30 +155,30 @@ readonly NONE: 0;

/**
* Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
*
* The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
*
* When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
*
* When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
*
* When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
*
* If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
*
* The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
*/
* Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
*
* The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
*
* When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
*
* When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
*
* When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
*
* If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
*
* The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
*/
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void;
/**
* Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
*/
* Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
*/
dispatchEvent(event: Event): boolean;
/**
* Removes the event listener in target's event listener list with the same type, callback, and options.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
*/
* Removes the event listener in target's event listener list with the same type, callback, and options.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
*/
removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;

@@ -193,30 +193,30 @@ }

/**
* Returns the data of the message.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)
*/
* Returns the data of the message.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)
*/
readonly data: T;
/**
* Returns the last event ID string, for server-sent events.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId)
*/
* Returns the last event ID string, for server-sent events.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId)
*/
readonly lastEventId: string;
/**
* Returns the origin of the message, for server-sent events and cross-document messaging.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin)
*/
* Returns the origin of the message, for server-sent events and cross-document messaging.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin)
*/
readonly origin: string;
/**
* Returns the MessagePort array sent with the message, for cross-document messaging and channel messaging.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports)
*/
* Returns the MessagePort array sent with the message, for cross-document messaging and channel messaging.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports)
*/
readonly ports: ReadonlyArray<MessagePort>;
/**
* Returns the WindowProxy of the source window, for cross-document messaging, and the MessagePort being attached, in the connect event fired at SharedWorkerGlobalScope objects.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)
*/
* Returns the WindowProxy of the source window, for cross-document messaging, and the MessagePort being attached, in the connect event fired at SharedWorkerGlobalScope objects.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)
*/
readonly source: MessageEventSource | null;

@@ -233,22 +233,22 @@ /** @deprecated */

/**
* Returns a string that indicates how binary data from the WebSocket object is exposed to scripts:
*
* Can be set, to change how binary data is returned. The default is "blob".
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType)
*/
* Returns a string that indicates how binary data from the WebSocket object is exposed to scripts:
*
* Can be set, to change how binary data is returned. The default is "blob".
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType)
*/
binaryType: BinaryType | (string & {});
/**
* Returns the number of bytes of application data (UTF-8 text and binary data) that have been queued using send() but not yet been transmitted to the network.
*
* If the WebSocket connection is closed, this attribute's value will only increase with each call to the send() method. (The number does not reset to zero once the connection closes.)
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/bufferedAmount)
*/
* Returns the number of bytes of application data (UTF-8 text and binary data) that have been queued using send() but not yet been transmitted to the network.
*
* If the WebSocket connection is closed, this attribute's value will only increase with each call to the send() method. (The number does not reset to zero once the connection closes.)
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/bufferedAmount)
*/
readonly bufferedAmount: number;
/**
* Returns the extensions selected by the server, if any.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
*/
* Returns the extensions selected by the server, if any.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
*/
readonly extensions: string;

@@ -264,30 +264,30 @@ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close_event) */

/**
* Returns the subprotocol selected by the server, if any. It can be used in conjunction with the array form of the constructor's second argument to perform subprotocol negotiation.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
*/
* Returns the subprotocol selected by the server, if any. It can be used in conjunction with the array form of the constructor's second argument to perform subprotocol negotiation.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
*/
readonly protocol: string;
/**
* Returns the state of the WebSocket object's connection. It can have the values described below.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
*/
* Returns the state of the WebSocket object's connection. It can have the values described below.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
*/
readonly readyState: number;
/**
* Returns the URL that was used to establish the WebSocket connection.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
*/
* Returns the URL that was used to establish the WebSocket connection.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
*/
readonly url: string;
/**
* Closes the WebSocket connection, optionally using code as the the WebSocket connection close code and reason as the the WebSocket connection close reason.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)
*/
* Closes the WebSocket connection, optionally using code as the the WebSocket connection close code and reason as the the WebSocket connection close reason.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)
*/
close(code?: number, reason?: string): void;
/**
* Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)
*/
* Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)
*/
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;

@@ -294,0 +294,0 @@ readonly CONNECTING: 0;

@@ -5,3 +5,3 @@ import { i as AdapterHookable, r as getPeers, t as adapterUtils } from "../_chunks/adapter.mjs";

import { t as WSError } from "../_chunks/error.mjs";
import { env } from "cloudflare:workers";
import { env as env$1 } from "cloudflare:workers";

@@ -12,5 +12,5 @@ //#region src/adapters/cloudflare.ts

const globalPeers = /* @__PURE__ */ new Map();
const resolveDurableStub = opts.resolveDurableStub || ((_req, env$1, _context) => {
const resolveDurableStub = opts.resolveDurableStub || ((_req, env, _context) => {
const bindingName = opts.bindingName || "$DurableObject";
const binding = (env$1 || env)[bindingName];
const binding = (env || env$1)[bindingName];
if (binding) {

@@ -64,3 +64,3 @@ const instanceId = binding.idFromName(opts.instanceName || "crossws");

},
handleDurableInit: async (obj, state, env$1) => {},
handleDurableInit: async (obj, state, env) => {},
handleDurableUpgrade: async (obj, request) => {

@@ -97,10 +97,10 @@ const { upgradeHeaders, endResponse, namespace } = await hooks.upgrade(request);

},
handleDurablePublish: async (_obj, topic, data, opts$1) => {
return durablePublish(topic, data, opts$1);
handleDurablePublish: async (_obj, topic, data, opts) => {
return durablePublish(topic, data, opts);
},
publish: async (topic, data, opts$1) => {
const stub = await resolveDurableStub(void 0, env, void 0);
publish: async (topic, data, opts) => {
const stub = await resolveDurableStub(void 0, env$1, void 0);
if (!stub) throw new Error("[crossws] Durable Object binding cannot be resolved.");
try {
return await stub.webSocketPublish(topic, data, opts$1);
return await stub.webSocketPublish(topic, data, opts);
} catch (error) {

@@ -107,0 +107,0 @@ console.error(error);

{
"name": "crossws",
"version": "0.4.3",
"version": "0.4.4",
"description": "Cross-platform WebSocket Servers for Node.js, Deno, Bun and Cloudflare Workers",

@@ -71,10 +71,10 @@ "homepage": "https://crossws.h3.dev",

"devDependencies": {
"@cloudflare/workers-types": "^4.20260118.0",
"@cloudflare/workers-types": "^4.20260127.0",
"@types/bun": "^1.3.6",
"@types/deno": "^2.5.0",
"@types/node": "^25.0.9",
"@types/web": "^0.0.318",
"@types/node": "^25.0.10",
"@types/web": "^0.0.323",
"@types/ws": "^8.18.1",
"@typescript/native-preview": "7.0.0-dev.20260119.1",
"@vitest/coverage-v8": "^4.0.17",
"@typescript/native-preview": "^7.0.0-dev.20260127.1",
"@vitest/coverage-v8": "^4.0.18",
"automd": "^0.4.2",

@@ -88,7 +88,7 @@ "changelogen": "^0.6.2",

"get-port-please": "^3.2.0",
"h3": "^2.0.1-rc.8",
"h3": "^2.0.1-rc.11",
"jiti": "^2.6.1",
"listhen": "^1.9.0",
"obuild": "^0.4.16",
"prettier": "^3.8.0",
"obuild": "^0.4.20",
"prettier": "^3.8.1",
"srvx": "^0.10.1",

@@ -98,5 +98,5 @@ "typescript": "^5.9.3",

"unbuild": "^3.6.1",
"undici": "^7.18.2",
"vitest": "^4.0.17",
"wrangler": "^4.59.2",
"undici": "^7.19.1",
"vitest": "^4.0.18",
"wrangler": "^4.60.0",
"ws": "^8.19.0"

@@ -112,3 +112,3 @@ },

},
"packageManager": "pnpm@10.28.1",
"packageManager": "pnpm@10.28.2",
"pnpm": {

@@ -115,0 +115,0 @@ "ignoredBuiltDependencies": [

Sorry, the diff of this file is too big to display