diff options
| author | Adam Mathes <adam@adammathes.com> | 2026-02-14 14:46:37 -0800 |
|---|---|---|
| committer | Adam Mathes <adam@adammathes.com> | 2026-02-14 14:46:37 -0800 |
| commit | afa87af01c79a9baa539f2992d32154d2a4739bd (patch) | |
| tree | 92c7416db734270a2fee1d72ee9cc119379ff8e1 /vanilla/node_modules/undici/lib/web/websocket/sender.js | |
| parent | 3b927e84d200402281f68181cd4253bc77e5528d (diff) | |
| download | neko-afa87af01c79a9baa539f2992d32154d2a4739bd.tar.gz neko-afa87af01c79a9baa539f2992d32154d2a4739bd.tar.bz2 neko-afa87af01c79a9baa539f2992d32154d2a4739bd.zip | |
task: delete vanilla js prototype\n\n- Removed vanilla/ directory and web/dist/vanilla directory\n- Updated Makefile, Dockerfile, and CI workflow to remove vanilla references\n- Cleaned up web/web.go to remove vanilla embed and routes\n- Verified build and tests pass\n\nCloses NK-2tcnmq
Diffstat (limited to 'vanilla/node_modules/undici/lib/web/websocket/sender.js')
| -rw-r--r-- | vanilla/node_modules/undici/lib/web/websocket/sender.js | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/vanilla/node_modules/undici/lib/web/websocket/sender.js b/vanilla/node_modules/undici/lib/web/websocket/sender.js deleted file mode 100644 index c647bf6..0000000 --- a/vanilla/node_modules/undici/lib/web/websocket/sender.js +++ /dev/null @@ -1,109 +0,0 @@ -'use strict' - -const { WebsocketFrameSend } = require('./frame') -const { opcodes, sendHints } = require('./constants') -const FixedQueue = require('../../dispatcher/fixed-queue') - -/** - * @typedef {object} SendQueueNode - * @property {Promise<void> | null} promise - * @property {((...args: any[]) => any)} callback - * @property {Buffer | null} frame - */ - -class SendQueue { - /** - * @type {FixedQueue} - */ - #queue = new FixedQueue() - - /** - * @type {boolean} - */ - #running = false - - /** @type {import('node:net').Socket} */ - #socket - - constructor (socket) { - this.#socket = socket - } - - add (item, cb, hint) { - if (hint !== sendHints.blob) { - if (!this.#running) { - // TODO(@tsctx): support fast-path for string on running - if (hint === sendHints.text) { - // special fast-path for string - const { 0: head, 1: body } = WebsocketFrameSend.createFastTextFrame(item) - this.#socket.cork() - this.#socket.write(head) - this.#socket.write(body, cb) - this.#socket.uncork() - } else { - // direct writing - this.#socket.write(createFrame(item, hint), cb) - } - } else { - /** @type {SendQueueNode} */ - const node = { - promise: null, - callback: cb, - frame: createFrame(item, hint) - } - this.#queue.push(node) - } - return - } - - /** @type {SendQueueNode} */ - const node = { - promise: item.arrayBuffer().then((ab) => { - node.promise = null - node.frame = createFrame(ab, hint) - }), - callback: cb, - frame: null - } - - this.#queue.push(node) - - if (!this.#running) { - this.#run() - } - } - - async #run () { - this.#running = true - const queue = this.#queue - while (!queue.isEmpty()) { - const node = queue.shift() - // wait pending promise - if (node.promise !== null) { - await node.promise - } - // write - this.#socket.write(node.frame, node.callback) - // cleanup - node.callback = node.frame = null - } - this.#running = false - } -} - -function createFrame (data, hint) { - return new WebsocketFrameSend(toBuffer(data, hint)).createFrame(hint === sendHints.text ? opcodes.TEXT : opcodes.BINARY) -} - -function toBuffer (data, hint) { - switch (hint) { - case sendHints.text: - case sendHints.typedArray: - return new Uint8Array(data.buffer, data.byteOffset, data.byteLength) - case sendHints.arrayBuffer: - case sendHints.blob: - return new Uint8Array(data) - } -} - -module.exports = { SendQueue } |
