New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graphql-ws

Package Overview
Dependencies
Maintainers
1
Versions
159
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-ws - npm Package Compare versions

Comparing version 6.0.0-alpha-6da42d9e001323c89623839b674f34b166c5e31f to 6.0.0-alpha-762205fc85dcd4025c050b9794d4b77a7ecea1c9

dist/client.d.ts

6

dist/client.js

@@ -1,3 +0,3 @@

import { G as GRAPHQL_TRANSPORT_WS_PROTOCOL, s as stringifyMessage, M as MessageType, C as CloseCode, l as limitCloseReason, p as parseMessage, a as isObject } from './common-C3FuvWlV.js';
export { D as DEPRECATED_GRAPHQL_WS_PROTOCOL, i as isMessage, v as validateMessage } from './common-C3FuvWlV.js';
import { G as GRAPHQL_TRANSPORT_WS_PROTOCOL, s as stringifyMessage, M as MessageType, C as CloseCode, l as limitCloseReason, p as parseMessage, i as isObject } from './common-CGW11Fyb.js';
export { D as DEPRECATED_GRAPHQL_WS_PROTOCOL, v as validateMessage } from './common-CGW11Fyb.js';

@@ -29,3 +29,2 @@ function createClient(options) {

shouldRetry = isLikeCloseEvent,
isFatalConnectionProblem,
on,

@@ -304,3 +303,2 @@ webSocketImpl,

if (!shouldRetry(errOrCloseEvent)) throw errOrCloseEvent;
if (isFatalConnectionProblem?.(errOrCloseEvent)) throw errOrCloseEvent;
return retrying = true;

@@ -307,0 +305,0 @@ }

@@ -1,410 +0,4 @@

import { ExecutionResult } from 'graphql';
import { C as ConnectionAckMessage, P as PingMessage, a as PongMessage, M as Message, b as ConnectionInitMessage, S as SubscribePayload, I as ID, J as JSONMessageReviver, c as JSONMessageReplacer, D as Disposable, d as Sink } from './server-CgaLfd0V.js';
export { f as CloseCode, k as CompleteMessage, q as Context, e as DEPRECATED_GRAPHQL_WS_PROTOCOL, j as ErrorMessage, i as ExecutionPatchResult, E as ExecutionResult, G as GRAPHQL_TRANSPORT_WS_PROTOCOL, m as GraphQLExecutionContextValue, g as MessageType, N as NextMessage, O as OperationResult, o as Server, n as ServerOptions, h as SubscribeMessage, W as WebSocket, t as handleProtocols, l as isMessage, r as makeServer, p as parseMessage, s as stringifyMessage, v as validateMessage } from './server-CgaLfd0V.js';
/**
*
* client
*
*/
/**
* WebSocket started connecting.
*
* @category Client
*/
type EventConnecting = 'connecting';
/**
* WebSocket has opened.
*
* @category Client
*/
type EventOpened = 'opened';
/**
* Open WebSocket connection has been acknowledged.
*
* @category Client
*/
type EventConnected = 'connected';
/**
* `PingMessage` has been received or sent.
*
* @category Client
*/
type EventPing = 'ping';
/**
* `PongMessage` has been received or sent.
*
* @category Client
*/
type EventPong = 'pong';
/**
* A message has been received.
*
* @category Client
*/
type EventMessage = 'message';
/**
* WebSocket connection has closed.
*
* @category Client
*/
type EventClosed = 'closed';
/**
* WebSocket connection had an error or client had an internal error.
*
* @category Client
*/
type EventError = 'error';
/**
* All events that could occur.
*
* @category Client
*/
type Event = EventConnecting | EventOpened | EventConnected | EventPing | EventPong | EventMessage | EventClosed | EventError;
/** @category Client */
type EventConnectingListener = (isRetry: boolean) => void;
/**
* The first argument is actually the `WebSocket`, but to avoid
* bundling DOM typings because the client can run in Node env too,
* you should assert the websocket type during implementation.
*
* @category Client
*/
type EventOpenedListener = (socket: unknown) => void;
/**
* The first argument is actually the `WebSocket`, but to avoid
* bundling DOM typings because the client can run in Node env too,
* you should assert the websocket type during implementation.
*
* Also, the second argument is the optional payload that the server may
* send through the `ConnectionAck` message.
*
* @category Client
*/
type EventConnectedListener = (socket: unknown, payload: ConnectionAckMessage['payload'], wasRetry: boolean) => void;
/**
* The first argument communicates whether the ping was received from the server.
* If `false`, the ping was sent by the client.
*
* @category Client
*/
type EventPingListener = (received: boolean, payload: PingMessage['payload']) => void;
/**
* The first argument communicates whether the pong was received from the server.
* If `false`, the pong was sent by the client.
*
* @category Client
*/
type EventPongListener = (received: boolean, payload: PongMessage['payload']) => void;
/**
* Called for all **valid** messages received by the client. Mainly useful for
* debugging and logging received messages.
*
* @category Client
*/
type EventMessageListener = (message: Message) => void;
/**
* The argument is actually the websocket `CloseEvent`, but to avoid
* bundling DOM typings because the client can run in Node env too,
* you should assert the websocket type during implementation.
*
* @category Client
*/
type EventClosedListener = (event: unknown) => void;
/**
* Events dispatched from the WebSocket `onerror` are handled in this listener,
* as well as all internal client errors that could throw.
*
* @category Client
*/
type EventErrorListener = (error: unknown) => void;
/** @category Client */
type EventListener<E extends Event> = E extends EventConnecting ? EventConnectingListener : E extends EventOpened ? EventOpenedListener : E extends EventConnected ? EventConnectedListener : E extends EventPing ? EventPingListener : E extends EventPong ? EventPongListener : E extends EventMessage ? EventMessageListener : E extends EventClosed ? EventClosedListener : E extends EventError ? EventErrorListener : never;
/**
* Configuration used for the GraphQL over WebSocket client.
*
* @category Client
*/
interface ClientOptions<P extends ConnectionInitMessage['payload'] = ConnectionInitMessage['payload']> {
/**
* URL of the GraphQL over WebSocket Protocol compliant server to connect.
*
* If the option is a function, it will be called on every WebSocket connection attempt.
* Returning a promise is supported too and the connecting phase will stall until it
* resolves with the URL.
*
* A good use-case for having a function is when using the URL for authentication,
* where subsequent reconnects (due to auth) may have a refreshed identity token in
* the URL.
*/
url: string | (() => Promise<string> | string);
/**
* Optional parameters, passed through the `payload` field with the `ConnectionInit` message,
* that the client specifies when establishing a connection with the server. You can use this
* for securely passing arguments for authentication.
*
* If you decide to return a promise, keep in mind that the server might kick you off if it
* takes too long to resolve! Check the `connectionInitWaitTimeout` on the server for more info.
*
* Throwing an error from within this function will close the socket with the `Error` message
* in the close event reason.
*/
connectionParams?: P | (() => Promise<P> | P);
/**
* Controls when should the connection be established.
*
* - `false`: Establish a connection immediately. Use `onNonLazyError` to handle errors.
* - `true`: Establish a connection on first subscribe and close on last unsubscribe. Use
* the subscription sink's `error` to handle errors.
*
* @default true
*/
lazy?: boolean;
/**
* Used ONLY when the client is in non-lazy mode (`lazy = false`). When
* using this mode, the errors might have no sinks to report to; however,
* to avoid swallowing errors, consider using `onNonLazyError`, which will
* be called when either:
* - An unrecoverable error/close event occurs
* - Silent retry attempts have been exceeded
*
* After a client has errored out, it will NOT perform any automatic actions.
*
* The argument can be a websocket `CloseEvent` or an `Error`. To avoid bundling
* DOM types, you should derive and assert the correct type. When receiving:
* - A `CloseEvent`: retry attempts have been exceeded or the specific
* close event is labeled as fatal (read more in `retryAttempts`).
* - An `Error`: some internal issue has occured, all internal errors are
* fatal by nature.
*
* @default console.error
*/
onNonLazyError?: (errorOrCloseEvent: unknown) => void;
/**
* How long should the client wait before closing the socket after the last operation has
* completed. This is meant to be used in combination with `lazy`. You might want to have
* a calmdown time before actually closing the connection. Kinda' like a lazy close "debounce".
*
* @default 0
*/
lazyCloseTimeout?: number;
/**
* The timeout between dispatched keep-alive messages, namely server pings. Internally
* dispatches the `PingMessage` type to the server and expects a `PongMessage` in response.
* This helps with making sure that the connection with the server is alive and working.
*
* Timeout countdown starts from the moment the socket was opened and subsequently
* after every received `PongMessage`.
*
* Note that NOTHING will happen automatically with the client if the server never
* responds to a `PingMessage` with a `PongMessage`. If you want the connection to close,
* you should implement your own logic on top of the client. A simple example looks like this:
*
* ```js
* import { createClient } from 'graphql-ws';
*
* let activeSocket, timedOut;
* createClient({
* url: 'ws://i.time.out:4000/after-5/seconds',
* keepAlive: 10_000, // ping server every 10 seconds
* on: {
* connected: (socket) => (activeSocket = socket),
* ping: (received) => {
* if (!received) // sent
* timedOut = setTimeout(() => {
* if (activeSocket.readyState === WebSocket.OPEN)
* activeSocket.close(4408, 'Request Timeout');
* }, 5_000); // wait 5 seconds for the pong and then close the connection
* },
* pong: (received) => {
* if (received) clearTimeout(timedOut); // pong is received, clear connection close timeout
* },
* },
* });
* ```
*
* @default 0
*/
keepAlive?: number;
/**
* The amount of time for which the client will wait
* for `ConnectionAck` message.
*
* Set the value to `Infinity`, `''`, `0`, `null` or `undefined` to skip waiting.
*
* If the wait timeout has passed and the server
* has not responded with `ConnectionAck` message,
* the client will terminate the socket by
* dispatching a close event `4418: Connection acknowledgement timeout`
*
* @default 0
*/
connectionAckWaitTimeout?: number;
/**
* Disable sending the `PongMessage` automatically.
*
* Useful for when integrating your own custom client pinger that performs
* custom actions before responding to a ping, or to pass along the optional pong
* message payload. Please check the readme recipes for a concrete example.
*/
disablePong?: boolean;
/**
* How many times should the client try to reconnect on abnormal socket closure before it errors out?
*
* The library classifies the following close events as fatal:
* - _All internal WebSocket fatal close codes (check `isFatalInternalCloseCode` in `src/client.ts` for exact list)_
* - `4500: Internal server error`
* - `4005: Internal client error`
* - `4400: Bad request`
* - `4004: Bad response`
* - `4401: Unauthorized` _tried subscribing before connect ack_
* - `4406: Subprotocol not acceptable`
* - `4409: Subscriber for <id> already exists` _distinction is very important_
* - `4429: Too many initialisation requests`
*
* In addition to the aforementioned close events, any _non-CloseEvent_ connection problem
* is considered fatal by default. However, this specific behaviour can be altered by using
* the `shouldRetry` option.
*
* These events are reported immediately and the client will not reconnect.
*
* @default 5
*/
retryAttempts?: number;
/**
* Control the wait time between retries. You may implement your own strategy
* by timing the resolution of the returned promise with the retries count.
* `retries` argument counts actual connection attempts, so it will begin with
* 0 after the first retryable disconnect.
*
* @default 'Randomised exponential backoff'
*/
retryWait?: (retries: number) => Promise<void>;
/**
* Check if the close event or connection error is fatal. If you return `false`,
* the client will fail immediately without additional retries; however, if you
* return `true`, the client will keep retrying until the `retryAttempts` have
* been exceeded.
*
* The argument is whatever has been thrown during the connection phase.
*
* Beware, the library classifies a few close events as fatal regardless of
* what is returned here. They are listed in the documentation of the `retryAttempts`
* option.
*
* @default 'Only `CloseEvent`s'
*/
shouldRetry?: (errOrCloseEvent: unknown) => boolean;
/**
* @deprecated Use `shouldRetry` instead.
*
* Check if the close event or connection error is fatal. If you return `true`,
* the client will fail immediately without additional retries; however, if you
* return `false`, the client will keep retrying until the `retryAttempts` have
* been exceeded.
*
* The argument is either a WebSocket `CloseEvent` or an error thrown during
* the connection phase.
*
* Beware, the library classifies a few close events as fatal regardless of
* what is returned. They are listed in the documentation of the `retryAttempts`
* option.
*
* @default 'Any non-`CloseEvent`'
*/
isFatalConnectionProblem?: (errOrCloseEvent: unknown) => boolean;
/**
* Register listeners before initialising the client. This way
* you can ensure to catch all client relevant emitted events.
*
* The listeners passed in will **always** be the first ones
* to get the emitted event before other registered listeners.
*/
on?: Partial<{
[event in Event]: EventListener<event>;
}>;
/**
* A custom WebSocket implementation to use instead of the
* one provided by the global scope. Mostly useful for when
* using the client outside of the browser environment.
*/
webSocketImpl?: unknown;
/**
* A custom ID generator for identifying subscriptions.
*
* The default generates a v4 UUID to be used as the ID using `Math`
* as the random number generator. Supply your own generator
* in case you need more uniqueness.
*
* Reference: https://gist.github.com/jed/982883
*/
generateID?: (payload: SubscribePayload) => ID;
/**
* An optional override for the JSON.parse function used to hydrate
* incoming messages to this client. Useful for parsing custom datatypes
* out of the incoming JSON.
*/
jsonMessageReviver?: JSONMessageReviver;
/**
* An optional override for the JSON.stringify function used to serialize
* outgoing messages from this client. Useful for serializing custom
* datatypes out to the client.
*/
jsonMessageReplacer?: JSONMessageReplacer;
}
/** @category Client */
interface Client extends Disposable {
/**
* Listens on the client which dispatches events about the socket state.
*/
on<E extends Event>(event: E, listener: EventListener<E>): () => void;
/**
* Subscribes through the WebSocket following the config parameters. It
* uses the `sink` to emit received data or errors. Returns a _cleanup_
* function used for dropping the subscription and cleaning stuff up.
*/
subscribe<Data = Record<string, unknown>, Extensions = unknown>(payload: SubscribePayload, sink: Sink<ExecutionResult<Data, Extensions>>): () => void;
/**
* Subscribes and iterates over emitted results from the WebSocket
* through the returned async iterator.
*/
iterate<Data = Record<string, unknown>, Extensions = unknown>(payload: SubscribePayload): AsyncIterableIterator<ExecutionResult<Data, Extensions>>;
/**
* Terminates the WebSocket abruptly and immediately.
*
* A close event `4499: Terminated` is issued to the current WebSocket and a
* synthetic {@link TerminatedCloseEvent} is immediately emitted without waiting for
* the one coming from `WebSocket.onclose`.
*
* Terminating is not considered fatal and a connection retry will occur as expected.
*
* Useful in cases where the WebSocket is stuck and not emitting any events;
* can happen on iOS Safari, see: https://github.com/enisdenjo/graphql-ws/discussions/290.
*/
terminate(): void;
}
/**
* Creates a disposable GraphQL over WebSocket client.
*
* @category Client
*/
declare function createClient<P extends ConnectionInitMessage['payload'] = ConnectionInitMessage['payload']>(options: ClientOptions<P>): Client;
/**
* A synthetic close event `4499: Terminated` is issued to the current to immediately
* close the connection without waiting for the one coming from `WebSocket.onclose`.
*
* Terminating is not considered fatal and a connection retry will occur as expected.
*
* Useful in cases where the WebSocket is stuck and not emitting any events;
* can happen on iOS Safari, see: https://github.com/enisdenjo/graphql-ws/discussions/290.
*/
declare class TerminatedCloseEvent extends Error {
name: string;
message: string;
code: number;
reason: string;
wasClean: boolean;
}
export { type Client, type ClientOptions, ConnectionAckMessage, ConnectionInitMessage, Disposable, type Event, type EventClosed, type EventClosedListener, type EventConnected, type EventConnectedListener, type EventConnecting, type EventConnectingListener, type EventError, type EventErrorListener, type EventListener, type EventMessage, type EventMessageListener, type EventOpened, type EventOpenedListener, type EventPing, type EventPingListener, type EventPong, type EventPongListener, ID, JSONMessageReplacer, JSONMessageReviver, Message, PingMessage, PongMessage, Sink, SubscribePayload, TerminatedCloseEvent, createClient };
export { Client, ClientOptions, Event, EventClosed, EventClosedListener, EventConnected, EventConnectedListener, EventConnecting, EventConnectingListener, EventError, EventErrorListener, EventListener, EventMessage, EventMessageListener, EventOpened, EventOpenedListener, EventPing, EventPingListener, EventPong, EventPongListener, TerminatedCloseEvent, createClient } from './client.js';
export { C as Context, G as GraphQLExecutionContextValue, O as OperationResult, a as Server, S as ServerOptions, W as WebSocket, b as areGraphQLErrors, h as handleProtocols, m as makeServer } from './server-Bi7EJiHd.js';
export { C as CloseCode, j as CompleteMessage, c as ConnectionAckMessage, b as ConnectionInitMessage, D as DEPRECATED_GRAPHQL_WS_PROTOCOL, a as Disposable, i as ErrorMessage, g as ExecutionPatchResult, E as ExecutionResult, h as FormattedExecutionPatchResult, F as FormattedExecutionResult, G as GRAPHQL_TRANSPORT_WS_PROTOCOL, I as ID, l as JSONMessageReplacer, J as JSONMessageReviver, k as Message, M as MessageType, N as NextMessage, P as PingMessage, d as PongMessage, S as Sink, e as SubscribeMessage, f as SubscribePayload, p as parseMessage, s as stringifyMessage, v as validateMessage } from './common-Uq_q7l8w.js';
import 'graphql';
export { TerminatedCloseEvent, createClient } from './client.js';
export { h as handleProtocols, m as makeServer } from './server-C2VkalQ-.js';
export { C as CloseCode, D as DEPRECATED_GRAPHQL_WS_PROTOCOL, G as GRAPHQL_TRANSPORT_WS_PROTOCOL, M as MessageType, i as isMessage, p as parseMessage, s as stringifyMessage, v as validateMessage } from './common-C3FuvWlV.js';
export { a as areGraphQLErrors, h as handleProtocols, m as makeServer } from './server-oIdYR9fn.js';
export { C as CloseCode, D as DEPRECATED_GRAPHQL_WS_PROTOCOL, G as GRAPHQL_TRANSPORT_WS_PROTOCOL, M as MessageType, p as parseMessage, s as stringifyMessage, v as validateMessage } from './common-CGW11Fyb.js';
import 'graphql';
import { WebSocket, WebsocketHandler } from '@fastify/websocket';
import { FastifyRequest } from 'fastify';
import { b as ConnectionInitMessage, n as ServerOptions } from '../../server-CgaLfd0V.js';
import { b as ConnectionInitMessage } from '../../common-Uq_q7l8w.js';
import { S as ServerOptions } from '../../server-Bi7EJiHd.js';
import 'graphql';

@@ -5,0 +6,0 @@

@@ -1,3 +0,3 @@

import { C as CloseCode, l as limitCloseReason, D as DEPRECATED_GRAPHQL_WS_PROTOCOL } from '../../common-C3FuvWlV.js';
import { h as handleProtocols, m as makeServer } from '../../server-C2VkalQ-.js';
import { C as CloseCode, l as limitCloseReason, D as DEPRECATED_GRAPHQL_WS_PROTOCOL } from '../../common-CGW11Fyb.js';
import { h as handleProtocols, m as makeServer } from '../../server-oIdYR9fn.js';
import 'graphql';

@@ -4,0 +4,0 @@

import { ServerWebSocket, WebSocketHandler } from 'bun';
import { b as ConnectionInitMessage, n as ServerOptions } from '../server-CgaLfd0V.js';
export { t as handleProtocols } from '../server-CgaLfd0V.js';
import { b as ConnectionInitMessage } from '../common-Uq_q7l8w.js';
import { S as ServerOptions } from '../server-Bi7EJiHd.js';
export { h as handleProtocols } from '../server-Bi7EJiHd.js';
import 'graphql';

@@ -5,0 +6,0 @@

@@ -1,4 +0,4 @@

import { G as GRAPHQL_TRANSPORT_WS_PROTOCOL } from '../common-C3FuvWlV.js';
import { m as makeServer } from '../server-C2VkalQ-.js';
export { h as handleProtocols } from '../server-C2VkalQ-.js';
import { G as GRAPHQL_TRANSPORT_WS_PROTOCOL } from '../common-CGW11Fyb.js';
import { m as makeServer } from '../server-oIdYR9fn.js';
export { h as handleProtocols } from '../server-oIdYR9fn.js';
import 'graphql';

@@ -5,0 +5,0 @@

@@ -1,3 +0,4 @@

import { b as ConnectionInitMessage, n as ServerOptions } from '../server-CgaLfd0V.js';
export { G as GRAPHQL_TRANSPORT_WS_PROTOCOL } from '../server-CgaLfd0V.js';
import { b as ConnectionInitMessage } from '../common-Uq_q7l8w.js';
export { G as GRAPHQL_TRANSPORT_WS_PROTOCOL } from '../common-Uq_q7l8w.js';
import { S as ServerOptions } from '../server-Bi7EJiHd.js';
import 'graphql';

@@ -4,0 +5,0 @@

@@ -1,4 +0,4 @@

import { C as CloseCode, D as DEPRECATED_GRAPHQL_WS_PROTOCOL } from '../common-C3FuvWlV.js';
export { G as GRAPHQL_TRANSPORT_WS_PROTOCOL } from '../common-C3FuvWlV.js';
import { m as makeServer } from '../server-C2VkalQ-.js';
import { C as CloseCode, D as DEPRECATED_GRAPHQL_WS_PROTOCOL } from '../common-CGW11Fyb.js';
export { G as GRAPHQL_TRANSPORT_WS_PROTOCOL } from '../common-CGW11Fyb.js';
import { m as makeServer } from '../server-oIdYR9fn.js';
import 'graphql';

@@ -5,0 +5,0 @@

import http__default from 'http';
import * as uWS from 'uWebSockets.js';
import { b as ConnectionInitMessage, n as ServerOptions } from '../server-CgaLfd0V.js';
import { b as ConnectionInitMessage } from '../common-Uq_q7l8w.js';
import { S as ServerOptions } from '../server-Bi7EJiHd.js';
import 'graphql';

@@ -5,0 +6,0 @@

@@ -1,3 +0,3 @@

import { C as CloseCode, l as limitCloseReason } from '../common-C3FuvWlV.js';
import { h as handleProtocols, m as makeServer } from '../server-C2VkalQ-.js';
import { C as CloseCode, l as limitCloseReason } from '../common-CGW11Fyb.js';
import { h as handleProtocols, m as makeServer } from '../server-oIdYR9fn.js';
import 'graphql';

@@ -4,0 +4,0 @@

import * as http from 'http';
import WebSocket from 'ws';
export { default as WebSocket } from 'ws';
import { b as ConnectionInitMessage, n as ServerOptions, D as Disposable } from '../server-CgaLfd0V.js';
import { b as ConnectionInitMessage, a as Disposable } from '../common-Uq_q7l8w.js';
import { S as ServerOptions } from '../server-Bi7EJiHd.js';
import 'graphql';

@@ -6,0 +7,0 @@

@@ -1,3 +0,3 @@

import { C as CloseCode, l as limitCloseReason, D as DEPRECATED_GRAPHQL_WS_PROTOCOL } from '../common-C3FuvWlV.js';
import { h as handleProtocols, m as makeServer } from '../server-C2VkalQ-.js';
import { C as CloseCode, l as limitCloseReason, D as DEPRECATED_GRAPHQL_WS_PROTOCOL } from '../common-CGW11Fyb.js';
import { h as handleProtocols, m as makeServer } from '../server-oIdYR9fn.js';
import 'graphql';

@@ -4,0 +4,0 @@

{
"name": "graphql-ws",
"version": "6.0.0-alpha-6da42d9e001323c89623839b674f34b166c5e31f",
"version": "6.0.0-alpha-762205fc85dcd4025c050b9794d4b77a7ecea1c9",
"description": "Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client",

@@ -25,2 +25,8 @@ "type": "module",

},
"./client": {
"types": "./dist/client.d.ts",
"require": "./dist/client.cjs",
"import": "./dist/client.js",
"browser": "./dist/client.js"
},
"./use/ws": {

@@ -91,3 +97,3 @@ "types": "./dist/use/ws.d.ts",

"peerDependencies": {
"graphql": "^15.9.0 || ^16.9.0"
"graphql": "^15.10.1 || ^16.10.0"
},

@@ -97,13 +103,13 @@ "devDependencies": {

"@changesets/cli": "^2.27.11",
"@fastify/websocket": "^11.0.1",
"@ianvs/prettier-plugin-sort-imports": "^4.4.0",
"@fastify/websocket": "^11.0.2",
"@ianvs/prettier-plugin-sort-imports": "^4.4.1",
"@rollup/plugin-terser": "^0.4.4",
"@tsconfig/strictest": "^2.0.5",
"@types/glob": "^8.1.0",
"@types/ws": "^8.5.10",
"bun-types": "^1.1.4",
"@types/ws": "^8.5.13",
"bun-types": "^1.1.43",
"fastify": "^5.2.1",
"glob": "^10.3.12",
"graphql": "^16.9.0",
"jsdom": "^25.0.1",
"glob": "^11.0.1",
"graphql": "^16.10.0",
"jsdom": "^26.0.0",
"pkgroll": "patch:pkgroll@npm%3A2.6.1#~/.yarn/patches/pkgroll-npm-2.6.1-193e78e84e.patch",

@@ -113,9 +119,9 @@ "prettier": "^3.4.2",

"rollup": "^4.30.1",
"typedoc": "^0.25.13",
"typedoc-plugin-markdown": "^3.17.1",
"typedoc": "^0.27.6",
"typedoc-plugin-markdown": "^4.4.1",
"typescript": "^5.7.3",
"uWebSockets.js": "uNetworking/uWebSockets.js#v20.51.0",
"vitest": "^2.1.8",
"ws": "8.12.0"
"ws": "^8.18.0"
}
}

@@ -19,3 +19,3 @@ (function (global, factory) {

}
function areGraphQLErrors(obj) {
function areGraphQLFormattedErrors(obj) {
return Array.isArray(obj) && // must be at least one error

@@ -169,3 +169,3 @@ obj.length > 0 && // error has at least a message

}
if (!areGraphQLErrors(val.payload)) {
if (!areGraphQLFormattedErrors(val.payload)) {
throw new Error(

@@ -199,10 +199,2 @@ `"${val.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(

}
function isMessage(val) {
try {
validateMessage(val);
return true;
} catch {
return false;
}
}
function parseMessage(data, reviver) {

@@ -243,3 +235,2 @@ return validateMessage(

shouldRetry = isLikeCloseEvent,
isFatalConnectionProblem,
on,

@@ -518,3 +509,2 @@ webSocketImpl,

if (!shouldRetry(errOrCloseEvent)) throw errOrCloseEvent;
if (isFatalConnectionProblem?.(errOrCloseEvent)) throw errOrCloseEvent;
return retrying = true;

@@ -720,3 +710,2 @@ }

exports.createClient = createClient;
exports.isMessage = isMessage;
exports.parseMessage = parseMessage;

@@ -723,0 +712,0 @@ exports.stringifyMessage = stringifyMessage;

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).graphqlWs={})}(this,(function(e){"use strict";function t(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function o(e){return"object"===t(e)}function r(e,t){return e.length<124?e:t}const n="graphql-transport-ws";var i=(e=>(e[e.InternalServerError=4500]="InternalServerError",e[e.InternalClientError=4005]="InternalClientError",e[e.BadRequest=4400]="BadRequest",e[e.BadResponse=4004]="BadResponse",e[e.Unauthorized=4401]="Unauthorized",e[e.Forbidden=4403]="Forbidden",e[e.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",e[e.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",e[e.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",e[e.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",e[e.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",e))(i||{}),a=(e=>(e.ConnectionInit="connection_init",e.ConnectionAck="connection_ack",e.Ping="ping",e.Pong="pong",e.Subscribe="subscribe",e.Next="next",e.Error="error",e.Complete="complete",e))(a||{});function s(e){if(!o(e))throw new Error(`Message is expected to be an object, but got ${t(e)}`);if(!e.type)throw new Error("Message is missing the 'type' property");if("string"!=typeof e.type)throw new Error(`Message is expects the 'type' property to be a string, but got ${t(e.type)}`);switch(e.type){case"connection_init":case"connection_ack":case"ping":case"pong":if(null!=e.payload&&!o(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${e.payload}"`);break;case"subscribe":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${t(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!o(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${t(e.payload)}`);if("string"!=typeof e.payload.query)throw new Error(`"${e.type}" message payload expects the 'query' property to be a string, but got ${t(e.payload.query)}`);if(null!=e.payload.variables&&!o(e.payload.variables))throw new Error(`"${e.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${t(e.payload.variables)}`);if(null!=e.payload.operationName&&"string"!==t(e.payload.operationName))throw new Error(`"${e.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${t(e.payload.operationName)}`);if(null!=e.payload.extensions&&!o(e.payload.extensions))throw new Error(`"${e.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${t(e.payload.extensions)}`);break;case"next":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${t(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!o(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${t(e.payload)}`);break;case"error":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${t(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(r=e.payload,!(Array.isArray(r)&&r.length>0&&r.every((e=>"message"in e))))throw new Error(`"${e.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(e.payload)}`);break;case"complete":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${t(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);break;default:throw new Error(`Invalid message 'type' property "${e.type}"`)}var r;return e}function c(e,t){return s("string"==typeof e?JSON.parse(e,t):e)}function p(e,t){return s(e),JSON.stringify(e,t)}class l extends Error{name="TerminatedCloseEvent";message="4499: Terminated";code=4499;reason="Terminated";wasClean=!1}function d(e){return o(e)&&"code"in e&&"reason"in e}e.CloseCode=i,e.DEPRECATED_GRAPHQL_WS_PROTOCOL="graphql-ws",e.GRAPHQL_TRANSPORT_WS_PROTOCOL=n,e.MessageType=a,e.TerminatedCloseEvent=l,e.createClient=function(e){const{url:t,connectionParams:o,lazy:s=!0,onNonLazyError:y=console.error,lazyCloseTimeout:u=0,keepAlive:g=0,disablePong:m,connectionAckWaitTimeout:f=0,retryAttempts:b=5,retryWait:w=async function(e){let t=1e3;for(let o=0;o<e;o++)t*=2;await new Promise((e=>setTimeout(e,t+Math.floor(2700*Math.random()+300))))},shouldRetry:h=d,isFatalConnectionProblem:x,on:E,webSocketImpl:S,generateID:v=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},jsonMessageReplacer:C,jsonMessageReviver:T}=e;let $;if(S){if(!("function"==typeof(k=S)&&"constructor"in k&&"CLOSED"in k&&"CLOSING"in k&&"CONNECTING"in k&&"OPEN"in k))throw new Error("Invalid WebSocket implementation provided");$=S}else"undefined"!=typeof WebSocket?$=WebSocket:"undefined"!=typeof global?$=global.WebSocket||global.MozWebSocket:"undefined"!=typeof window&&($=window.WebSocket||window.MozWebSocket);var k;if(!$)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const N=$,P=(()=>{const e=(()=>{const e={};return{on:(t,o)=>(e[t]=o,()=>{delete e[t]}),emit(t){"id"in t&&e[t.id]?.(t)}}})(),t={connecting:E?.connecting?[E.connecting]:[],opened:E?.opened?[E.opened]:[],connected:E?.connected?[E.connected]:[],ping:E?.ping?[E.ping]:[],pong:E?.pong?[E.pong]:[],message:E?.message?[e.emit,E.message]:[e.emit],closed:E?.closed?[E.closed]:[],error:E?.error?[E.error]:[]};return{onMessage:e.on,on(e,o){const r=t[e];return r.push(o),()=>{r.splice(r.indexOf(o),1)}},emit(e,...o){for(const r of[...t[e]])r(...o)}}})();function I(e){const t=[P.on("error",(o=>{t.forEach((e=>e())),e(o)})),P.on("closed",(o=>{t.forEach((e=>e())),e(o)}))]}let A,M,O=0,R=!1,q=0,W=!1;async function j(){clearTimeout(M);const[e,s]=await(A??(A=new Promise(((e,s)=>(async()=>{if(R){if(await w(q),!O)return A=void 0,s({code:1e3,reason:"All Subscriptions Gone"});q++}P.emit("connecting",R);const d=new N("function"==typeof t?await t():t,n);let y,u;function b(){isFinite(g)&&g>0&&(clearTimeout(u),u=setTimeout((()=>{d.readyState===N.OPEN&&(d.send(p({type:a.Ping})),P.emit("ping",!1,void 0))}),g))}I((e=>{A=void 0,clearTimeout(y),clearTimeout(u),s(e),e instanceof l&&(d.close(4499,"Terminated"),d.onerror=null,d.onclose=null)})),d.onerror=e=>P.emit("error",e),d.onclose=e=>P.emit("closed",e),d.onopen=async()=>{try{P.emit("opened",d);const e="function"==typeof o?await o():o;if(d.readyState!==N.OPEN)return;d.send(p(e?{type:a.ConnectionInit,payload:e}:{type:a.ConnectionInit},C)),isFinite(f)&&f>0&&(y=setTimeout((()=>{d.close(i.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")}),f)),b()}catch(e){P.emit("error",e),d.close(i.InternalClientError,r(e instanceof Error?e.message:String(e),"Internal client error"))}};let h=!1;d.onmessage=({data:t})=>{try{const o=c(t,T);if(P.emit("message",o),"ping"===o.type||"pong"===o.type)return P.emit(o.type,!0,o.payload),void("pong"===o.type?b():m||(d.send(p(o.payload?{type:a.Pong,payload:o.payload}:{type:a.Pong})),P.emit("pong",!1,o.payload)));if(h)return;if(o.type!==a.ConnectionAck)throw new Error(`First message cannot be of type ${o.type}`);clearTimeout(y),h=!0,P.emit("connected",d,o.payload,R),R=!1,q=0,e([d,new Promise(((e,t)=>I(t)))])}catch(e){d.onmessage=null,P.emit("error",e),d.close(i.BadResponse,r(e instanceof Error?e.message:String(e),"Bad response"))}}})()))));e.readyState===N.CLOSING&&await s;let d=()=>{};const y=new Promise((e=>d=e));return[e,d,Promise.race([y.then((()=>{if(!O){const t=()=>e.close(1e3,"Normal Closure");isFinite(u)&&u>0?M=setTimeout((()=>{e.readyState===N.OPEN&&t()}),u):t()}})),s])]}function _(e){if(d(e)&&(t=e.code,![1e3,1001,1006,1005,1012,1013,1014].includes(t)&&t>=1e3&&t<=1999||[i.InternalServerError,i.InternalClientError,i.BadRequest,i.BadResponse,i.Unauthorized,i.SubprotocolNotAcceptable,i.SubscriberAlreadyExists,i.TooManyInitialisationRequests].includes(e.code)))throw e;var t;if(W)return!1;if(d(e)&&1e3===e.code)return O>0;if(!b||q>=b)throw e;if(!h(e))throw e;if(x?.(e))throw e;return R=!0}function L(e,t){const o=v(e);let r=!1,n=!1,i=()=>{O--,r=!0};return(async()=>{for(O++;;)try{const[s,c,l]=await j();if(r)return c();const d=P.onMessage(o,(e=>{switch(e.type){case a.Next:return void t.next(e.payload);case a.Error:return n=!0,r=!0,t.error(e.payload),void i();case a.Complete:return r=!0,void i()}}));return s.send(p({id:o,type:a.Subscribe,payload:e},C)),i=()=>{r||s.readyState!==N.OPEN||s.send(p({id:o,type:a.Complete},C)),O--,r=!0,c()},void await l.finally(d)}catch(e){if(!_(e))return}})().then((()=>{n||t.complete()})).catch((e=>{t.error(e)})),()=>{r||i()}}return s||(async()=>{for(O++;;)try{const[,,e]=await j();await e}catch(e){try{if(!_(e))return}catch(e){return y?.(e)}}})(),{on:P.on,subscribe:L,iterate(e){const t=[],o={done:!1,error:null,resolve:()=>{}},r=L(e,{next(e){t.push(e),o.resolve()},error(e){o.done=!0,o.error=e,o.resolve()},complete(){o.done=!0,o.resolve()}}),n=async function*(){for(;;){for(t.length||await new Promise((e=>o.resolve=e));t.length;)yield t.shift();if(o.error)throw o.error;if(o.done)return}}();return n.throw=async e=>(o.done||(o.done=!0,o.error=e,o.resolve()),{done:!0,value:void 0}),n.return=async()=>(r(),{done:!0,value:void 0}),n},async dispose(){if(W=!0,A){const[e]=await A;e.close(1e3,"Normal Closure")}},terminate(){A&&P.emit("closed",new l)}}},e.isMessage=function(e){try{return s(e),!0}catch{return!1}},e.parseMessage=c,e.stringifyMessage=p,e.validateMessage=s}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).graphqlWs={})}(this,(function(e){"use strict";function t(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function o(e){return"object"===t(e)}function r(e,t){return e.length<124?e:t}const n="graphql-transport-ws";var i=(e=>(e[e.InternalServerError=4500]="InternalServerError",e[e.InternalClientError=4005]="InternalClientError",e[e.BadRequest=4400]="BadRequest",e[e.BadResponse=4004]="BadResponse",e[e.Unauthorized=4401]="Unauthorized",e[e.Forbidden=4403]="Forbidden",e[e.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",e[e.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",e[e.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",e[e.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",e[e.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",e))(i||{}),a=(e=>(e.ConnectionInit="connection_init",e.ConnectionAck="connection_ack",e.Ping="ping",e.Pong="pong",e.Subscribe="subscribe",e.Next="next",e.Error="error",e.Complete="complete",e))(a||{});function s(e){if(!o(e))throw new Error(`Message is expected to be an object, but got ${t(e)}`);if(!e.type)throw new Error("Message is missing the 'type' property");if("string"!=typeof e.type)throw new Error(`Message is expects the 'type' property to be a string, but got ${t(e.type)}`);switch(e.type){case"connection_init":case"connection_ack":case"ping":case"pong":if(null!=e.payload&&!o(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${e.payload}"`);break;case"subscribe":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${t(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!o(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${t(e.payload)}`);if("string"!=typeof e.payload.query)throw new Error(`"${e.type}" message payload expects the 'query' property to be a string, but got ${t(e.payload.query)}`);if(null!=e.payload.variables&&!o(e.payload.variables))throw new Error(`"${e.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${t(e.payload.variables)}`);if(null!=e.payload.operationName&&"string"!==t(e.payload.operationName))throw new Error(`"${e.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${t(e.payload.operationName)}`);if(null!=e.payload.extensions&&!o(e.payload.extensions))throw new Error(`"${e.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${t(e.payload.extensions)}`);break;case"next":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${t(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!o(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${t(e.payload)}`);break;case"error":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${t(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(r=e.payload,!(Array.isArray(r)&&r.length>0&&r.every((e=>"message"in e))))throw new Error(`"${e.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(e.payload)}`);break;case"complete":if("string"!=typeof e.id)throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${t(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);break;default:throw new Error(`Invalid message 'type' property "${e.type}"`)}var r;return e}function c(e,t){return s("string"==typeof e?JSON.parse(e,t):e)}function p(e,t){return s(e),JSON.stringify(e,t)}class l extends Error{name="TerminatedCloseEvent";message="4499: Terminated";code=4499;reason="Terminated";wasClean=!1}function d(e){return o(e)&&"code"in e&&"reason"in e}e.CloseCode=i,e.DEPRECATED_GRAPHQL_WS_PROTOCOL="graphql-ws",e.GRAPHQL_TRANSPORT_WS_PROTOCOL=n,e.MessageType=a,e.TerminatedCloseEvent=l,e.createClient=function(e){const{url:t,connectionParams:o,lazy:s=!0,onNonLazyError:y=console.error,lazyCloseTimeout:u=0,keepAlive:g=0,disablePong:m,connectionAckWaitTimeout:f=0,retryAttempts:b=5,retryWait:w=async function(e){let t=1e3;for(let o=0;o<e;o++)t*=2;await new Promise((e=>setTimeout(e,t+Math.floor(2700*Math.random()+300))))},shouldRetry:h=d,on:x,webSocketImpl:E,generateID:S=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},jsonMessageReplacer:v,jsonMessageReviver:C}=e;let T;if(E){if(!("function"==typeof($=E)&&"constructor"in $&&"CLOSED"in $&&"CLOSING"in $&&"CONNECTING"in $&&"OPEN"in $))throw new Error("Invalid WebSocket implementation provided");T=E}else"undefined"!=typeof WebSocket?T=WebSocket:"undefined"!=typeof global?T=global.WebSocket||global.MozWebSocket:"undefined"!=typeof window&&(T=window.WebSocket||window.MozWebSocket);var $;if(!T)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const k=T,N=(()=>{const e=(()=>{const e={};return{on:(t,o)=>(e[t]=o,()=>{delete e[t]}),emit(t){"id"in t&&e[t.id]?.(t)}}})(),t={connecting:x?.connecting?[x.connecting]:[],opened:x?.opened?[x.opened]:[],connected:x?.connected?[x.connected]:[],ping:x?.ping?[x.ping]:[],pong:x?.pong?[x.pong]:[],message:x?.message?[e.emit,x.message]:[e.emit],closed:x?.closed?[x.closed]:[],error:x?.error?[x.error]:[]};return{onMessage:e.on,on(e,o){const r=t[e];return r.push(o),()=>{r.splice(r.indexOf(o),1)}},emit(e,...o){for(const r of[...t[e]])r(...o)}}})();function I(e){const t=[N.on("error",(o=>{t.forEach((e=>e())),e(o)})),N.on("closed",(o=>{t.forEach((e=>e())),e(o)}))]}let P,A,O=0,R=!1,M=0,q=!1;async function W(){clearTimeout(A);const[e,s]=await(P??(P=new Promise(((e,s)=>(async()=>{if(R){if(await w(M),!O)return P=void 0,s({code:1e3,reason:"All Subscriptions Gone"});M++}N.emit("connecting",R);const d=new k("function"==typeof t?await t():t,n);let y,u;function b(){isFinite(g)&&g>0&&(clearTimeout(u),u=setTimeout((()=>{d.readyState===k.OPEN&&(d.send(p({type:a.Ping})),N.emit("ping",!1,void 0))}),g))}I((e=>{P=void 0,clearTimeout(y),clearTimeout(u),s(e),e instanceof l&&(d.close(4499,"Terminated"),d.onerror=null,d.onclose=null)})),d.onerror=e=>N.emit("error",e),d.onclose=e=>N.emit("closed",e),d.onopen=async()=>{try{N.emit("opened",d);const e="function"==typeof o?await o():o;if(d.readyState!==k.OPEN)return;d.send(p(e?{type:a.ConnectionInit,payload:e}:{type:a.ConnectionInit},v)),isFinite(f)&&f>0&&(y=setTimeout((()=>{d.close(i.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")}),f)),b()}catch(e){N.emit("error",e),d.close(i.InternalClientError,r(e instanceof Error?e.message:String(e),"Internal client error"))}};let h=!1;d.onmessage=({data:t})=>{try{const o=c(t,C);if(N.emit("message",o),"ping"===o.type||"pong"===o.type)return N.emit(o.type,!0,o.payload),void("pong"===o.type?b():m||(d.send(p(o.payload?{type:a.Pong,payload:o.payload}:{type:a.Pong})),N.emit("pong",!1,o.payload)));if(h)return;if(o.type!==a.ConnectionAck)throw new Error(`First message cannot be of type ${o.type}`);clearTimeout(y),h=!0,N.emit("connected",d,o.payload,R),R=!1,M=0,e([d,new Promise(((e,t)=>I(t)))])}catch(e){d.onmessage=null,N.emit("error",e),d.close(i.BadResponse,r(e instanceof Error?e.message:String(e),"Bad response"))}}})()))));e.readyState===k.CLOSING&&await s;let d=()=>{};const y=new Promise((e=>d=e));return[e,d,Promise.race([y.then((()=>{if(!O){const t=()=>e.close(1e3,"Normal Closure");isFinite(u)&&u>0?A=setTimeout((()=>{e.readyState===k.OPEN&&t()}),u):t()}})),s])]}function j(e){if(d(e)&&(t=e.code,![1e3,1001,1006,1005,1012,1013,1014].includes(t)&&t>=1e3&&t<=1999||[i.InternalServerError,i.InternalClientError,i.BadRequest,i.BadResponse,i.Unauthorized,i.SubprotocolNotAcceptable,i.SubscriberAlreadyExists,i.TooManyInitialisationRequests].includes(e.code)))throw e;var t;if(q)return!1;if(d(e)&&1e3===e.code)return O>0;if(!b||M>=b)throw e;if(!h(e))throw e;return R=!0}function _(e,t){const o=S(e);let r=!1,n=!1,i=()=>{O--,r=!0};return(async()=>{for(O++;;)try{const[s,c,l]=await W();if(r)return c();const d=N.onMessage(o,(e=>{switch(e.type){case a.Next:return void t.next(e.payload);case a.Error:return n=!0,r=!0,t.error(e.payload),void i();case a.Complete:return r=!0,void i()}}));return s.send(p({id:o,type:a.Subscribe,payload:e},v)),i=()=>{r||s.readyState!==k.OPEN||s.send(p({id:o,type:a.Complete},v)),O--,r=!0,c()},void await l.finally(d)}catch(e){if(!j(e))return}})().then((()=>{n||t.complete()})).catch((e=>{t.error(e)})),()=>{r||i()}}return s||(async()=>{for(O++;;)try{const[,,e]=await W();await e}catch(e){try{if(!j(e))return}catch(e){return y?.(e)}}})(),{on:N.on,subscribe:_,iterate(e){const t=[],o={done:!1,error:null,resolve:()=>{}},r=_(e,{next(e){t.push(e),o.resolve()},error(e){o.done=!0,o.error=e,o.resolve()},complete(){o.done=!0,o.resolve()}}),n=async function*(){for(;;){for(t.length||await new Promise((e=>o.resolve=e));t.length;)yield t.shift();if(o.error)throw o.error;if(o.done)return}}();return n.throw=async e=>(o.done||(o.done=!0,o.error=e,o.resolve()),{done:!0,value:void 0}),n.return=async()=>(r(),{done:!0,value:void 0}),n},async dispose(){if(q=!0,P){const[e]=await P;e.close(1e3,"Normal Closure")}},terminate(){P&&N.emit("closed",new l)}}},e.parseMessage=c,e.stringifyMessage=p,e.validateMessage=s}));

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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