full site update
This commit is contained in:
3
node_modules/crossws/dist/websocket/native.d.mts
generated
vendored
Normal file
3
node_modules/crossws/dist/websocket/native.d.mts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare const WebSocket: typeof globalThis.WebSocket;
|
||||
|
||||
export { WebSocket as default };
|
3
node_modules/crossws/dist/websocket/native.d.ts
generated
vendored
Normal file
3
node_modules/crossws/dist/websocket/native.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare const WebSocket: typeof globalThis.WebSocket;
|
||||
|
||||
export { WebSocket as default };
|
3
node_modules/crossws/dist/websocket/native.mjs
generated
vendored
Normal file
3
node_modules/crossws/dist/websocket/native.mjs
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
const WebSocket = globalThis.WebSocket;
|
||||
|
||||
export { WebSocket as default };
|
3
node_modules/crossws/dist/websocket/node.d.mts
generated
vendored
Normal file
3
node_modules/crossws/dist/websocket/node.d.mts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare const Websocket: typeof globalThis.WebSocket;
|
||||
|
||||
export { Websocket as default };
|
3
node_modules/crossws/dist/websocket/node.d.ts
generated
vendored
Normal file
3
node_modules/crossws/dist/websocket/node.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare const Websocket: typeof globalThis.WebSocket;
|
||||
|
||||
export { Websocket as default };
|
15
node_modules/crossws/dist/websocket/node.mjs
generated
vendored
Normal file
15
node_modules/crossws/dist/websocket/node.mjs
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { a as _WebSocket } from '../shared/crossws.CipVM6lf.mjs';
|
||||
import 'stream';
|
||||
import 'events';
|
||||
import 'http';
|
||||
import 'crypto';
|
||||
import 'buffer';
|
||||
import 'zlib';
|
||||
import 'https';
|
||||
import 'net';
|
||||
import 'tls';
|
||||
import 'url';
|
||||
|
||||
const Websocket = globalThis.WebSocket || _WebSocket;
|
||||
|
||||
export { Websocket as default };
|
42
node_modules/crossws/dist/websocket/sse.d.mts
generated
vendored
Normal file
42
node_modules/crossws/dist/websocket/sse.d.mts
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import { E as EventTarget, W as WebSocket, C as CloseEvent, a as Event, M as MessageEvent } from '../shared/crossws.BQXMA5bH.mjs';
|
||||
|
||||
type Ctor<T> = {
|
||||
prototype: T;
|
||||
new (): T;
|
||||
};
|
||||
declare const _EventTarget: Ctor<EventTarget>;
|
||||
interface WebSocketSSEOptions {
|
||||
protocols?: string | string[];
|
||||
/** enabled by default */
|
||||
bidir?: boolean;
|
||||
/** enabled by default */
|
||||
stream?: boolean;
|
||||
headers?: HeadersInit;
|
||||
}
|
||||
declare class WebSocketSSE extends _EventTarget implements WebSocket {
|
||||
#private;
|
||||
static CONNECTING: number;
|
||||
static OPEN: number;
|
||||
static CLOSING: number;
|
||||
static CLOSED: number;
|
||||
readonly CONNECTING = 0;
|
||||
readonly OPEN = 1;
|
||||
readonly CLOSING = 2;
|
||||
readonly CLOSED = 3;
|
||||
onclose: ((this: WebSocket, ev: CloseEvent) => any) | null;
|
||||
onerror: ((this: WebSocket, ev: Event) => any) | null;
|
||||
onopen: ((this: WebSocket, ev: Event) => any) | null;
|
||||
onmessage: ((this: WebSocket, ev: MessageEvent<any>) => any) | null;
|
||||
binaryType: BinaryType;
|
||||
readyState: number;
|
||||
readonly url: string;
|
||||
readonly protocol: string;
|
||||
readonly extensions: string;
|
||||
readonly bufferedAmount: number;
|
||||
constructor(url: string, init?: string | string[] | WebSocketSSEOptions);
|
||||
close(_code?: number, _reason?: string): void;
|
||||
send(data: any): Promise<void>;
|
||||
}
|
||||
|
||||
export { WebSocketSSE };
|
||||
export type { WebSocketSSEOptions };
|
42
node_modules/crossws/dist/websocket/sse.d.ts
generated
vendored
Normal file
42
node_modules/crossws/dist/websocket/sse.d.ts
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import { E as EventTarget, W as WebSocket, C as CloseEvent, a as Event, M as MessageEvent } from '../shared/crossws.BQXMA5bH.js';
|
||||
|
||||
type Ctor<T> = {
|
||||
prototype: T;
|
||||
new (): T;
|
||||
};
|
||||
declare const _EventTarget: Ctor<EventTarget>;
|
||||
interface WebSocketSSEOptions {
|
||||
protocols?: string | string[];
|
||||
/** enabled by default */
|
||||
bidir?: boolean;
|
||||
/** enabled by default */
|
||||
stream?: boolean;
|
||||
headers?: HeadersInit;
|
||||
}
|
||||
declare class WebSocketSSE extends _EventTarget implements WebSocket {
|
||||
#private;
|
||||
static CONNECTING: number;
|
||||
static OPEN: number;
|
||||
static CLOSING: number;
|
||||
static CLOSED: number;
|
||||
readonly CONNECTING = 0;
|
||||
readonly OPEN = 1;
|
||||
readonly CLOSING = 2;
|
||||
readonly CLOSED = 3;
|
||||
onclose: ((this: WebSocket, ev: CloseEvent) => any) | null;
|
||||
onerror: ((this: WebSocket, ev: Event) => any) | null;
|
||||
onopen: ((this: WebSocket, ev: Event) => any) | null;
|
||||
onmessage: ((this: WebSocket, ev: MessageEvent<any>) => any) | null;
|
||||
binaryType: BinaryType;
|
||||
readyState: number;
|
||||
readonly url: string;
|
||||
readonly protocol: string;
|
||||
readonly extensions: string;
|
||||
readonly bufferedAmount: number;
|
||||
constructor(url: string, init?: string | string[] | WebSocketSSEOptions);
|
||||
close(_code?: number, _reason?: string): void;
|
||||
send(data: any): Promise<void>;
|
||||
}
|
||||
|
||||
export { WebSocketSSE };
|
||||
export type { WebSocketSSEOptions };
|
127
node_modules/crossws/dist/websocket/sse.mjs
generated
vendored
Normal file
127
node_modules/crossws/dist/websocket/sse.mjs
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
const _EventTarget = EventTarget;
|
||||
const defaultOptions = Object.freeze({
|
||||
bidir: true,
|
||||
stream: true
|
||||
});
|
||||
class WebSocketSSE extends _EventTarget {
|
||||
static CONNECTING = 0;
|
||||
static OPEN = 1;
|
||||
static CLOSING = 2;
|
||||
static CLOSED = 3;
|
||||
CONNECTING = 0;
|
||||
OPEN = 1;
|
||||
CLOSING = 2;
|
||||
CLOSED = 3;
|
||||
/* eslint-disable unicorn/no-null */
|
||||
onclose = null;
|
||||
onerror = null;
|
||||
onopen = null;
|
||||
onmessage = null;
|
||||
/* eslint-enable unicorn/no-null */
|
||||
binaryType = "blob";
|
||||
readyState = WebSocketSSE.CONNECTING;
|
||||
url;
|
||||
protocol = "";
|
||||
extensions = "";
|
||||
bufferedAmount = 0;
|
||||
#options = {};
|
||||
#sse;
|
||||
#id;
|
||||
#sendController;
|
||||
#queue = [];
|
||||
constructor(url, init) {
|
||||
super();
|
||||
this.url = url.replace(/^ws/, "http");
|
||||
if (typeof init === "string") {
|
||||
this.#options = { ...defaultOptions, protocols: init };
|
||||
} else if (Array.isArray(init)) {
|
||||
this.#options = { ...defaultOptions, protocols: init };
|
||||
} else {
|
||||
this.#options = { ...defaultOptions, ...init };
|
||||
}
|
||||
this.#sse = new EventSource(this.url);
|
||||
this.#sse.addEventListener("open", (_sseEvent) => {
|
||||
this.readyState = WebSocketSSE.OPEN;
|
||||
const event = new Event("open");
|
||||
this.onopen?.(event);
|
||||
this.dispatchEvent(event);
|
||||
});
|
||||
this.#sse.addEventListener("message", (sseEvent) => {
|
||||
const _event = new MessageEvent("message", {
|
||||
data: sseEvent.data
|
||||
});
|
||||
this.onmessage?.(_event);
|
||||
this.dispatchEvent(_event);
|
||||
});
|
||||
if (this.#options.bidir) {
|
||||
this.#sse.addEventListener("crossws-id", (sseEvent) => {
|
||||
this.#id = sseEvent.data;
|
||||
if (this.#options.stream) {
|
||||
fetch(this.url, {
|
||||
method: "POST",
|
||||
// @ts-expect-error
|
||||
duplex: "half",
|
||||
headers: {
|
||||
"content-type": "application/octet-stream",
|
||||
"x-crossws-id": this.#id
|
||||
},
|
||||
body: new ReadableStream({
|
||||
start: (controller) => {
|
||||
this.#sendController = controller;
|
||||
},
|
||||
cancel: () => {
|
||||
this.#sendController = void 0;
|
||||
}
|
||||
}).pipeThrough(new TextEncoderStream())
|
||||
}).catch(() => {
|
||||
});
|
||||
}
|
||||
for (const data of this.#queue) {
|
||||
this.send(data);
|
||||
}
|
||||
this.#queue = [];
|
||||
});
|
||||
}
|
||||
this.#sse.addEventListener("error", (_sseEvent) => {
|
||||
const event = new Event("error");
|
||||
this.onerror?.(event);
|
||||
this.dispatchEvent(event);
|
||||
});
|
||||
this.#sse.addEventListener("close", (_sseEvent) => {
|
||||
this.readyState = WebSocketSSE.CLOSED;
|
||||
const event = new Event("close");
|
||||
this.onclose?.(event);
|
||||
this.dispatchEvent(event);
|
||||
});
|
||||
}
|
||||
close(_code, _reason) {
|
||||
this.readyState = WebSocketSSE.CLOSING;
|
||||
this.#sse.close();
|
||||
this.readyState = WebSocketSSE.CLOSED;
|
||||
}
|
||||
async send(data) {
|
||||
if (!this.#options.bidir) {
|
||||
throw new Error("bdir option is not enabled!");
|
||||
}
|
||||
if (this.readyState !== WebSocketSSE.OPEN) {
|
||||
throw new Error("WebSocket is not open!");
|
||||
}
|
||||
if (!this.#id) {
|
||||
this.#queue.push(data);
|
||||
return;
|
||||
}
|
||||
if (this.#sendController) {
|
||||
this.#sendController.enqueue(data);
|
||||
return;
|
||||
}
|
||||
await fetch(this.url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"x-crossws-id": this.#id
|
||||
},
|
||||
body: data
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { WebSocketSSE };
|
Reference in New Issue
Block a user