/
opt
/
canhelp
/
node_modules
/
hono
/
dist
/
helper
/
websocket
/
/opt/canhelp/node_modules/hono/dist/helper/websocket
mkdir
upload
Name
Size
Mode
Actions
index.js
1358
0644
edit
dl
rm
Edit:
/opt/canhelp/node_modules/hono/dist/helper/websocket/index.js
(1358B)
// 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 };
Save
cmd:
run