Buckets:
| // src/helper/websocket/index.ts | |
| var WSContext = class { | |
| #init; | |
| constructor(init) { | |
| this.#init = init; | |
| this.raw = init.raw; | |
| this.url = init.url ? new URL(init.url) : null; | |
| this.protocol = init.protocol ?? null; | |
| } | |
| send(source, options) { | |
| this.#init.send(source, options ?? {}); | |
| } | |
| raw; | |
| binaryType = "arraybuffer"; | |
| get readyState() { | |
| return this.#init.readyState; | |
| } | |
| url; | |
| protocol; | |
| close(code, reason) { | |
| this.#init.close(code, reason); | |
| } | |
| }; | |
| var createWSMessageEvent = (source) => { | |
| return new MessageEvent("message", { | |
| data: source | |
| }); | |
| }; | |
| var defineWebSocketHelper = (handler) => { | |
| return ((...args) => { | |
| if (typeof args[0] === "function") { | |
| const [createEvents, options] = args; | |
| return async function upgradeWebSocket(c, next) { | |
| const events = await createEvents(c); | |
| const result = await handler(c, events, options); | |
| if (result) { | |
| return result; | |
| } | |
| await next(); | |
| }; | |
| } else { | |
| const [c, events, options] = args; | |
| return (async () => { | |
| const upgraded = await handler(c, events, options); | |
| if (!upgraded) { | |
| throw new Error("Failed to upgrade WebSocket"); | |
| } | |
| return upgraded; | |
| })(); | |
| } | |
| }); | |
| }; | |
| export { | |
| WSContext, | |
| createWSMessageEvent, | |
| defineWebSocketHelper | |
| }; | |
Xet Storage Details
- Size:
- 1.36 kB
- Xet hash:
- 0b4f65b40d9e56cabb10f86cf88aa4f6a17f538ace123ea20aadbd9f09ffe26e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.