qjs-ws is a simple way to give QuickJS https://bellard.org/quickjs/ WebSocket server capability.
Uses gwsocket <gwsocket http://gwsocket.io/> and utf.js https://github.com/DesWurstes/utf.js
utf.js is supplied with qjs-ws (renamed utf.mjs, and exports added)
gwsocket needs to be downloaded and built. gwsocket provides WebSocket server capability to shell and scripting languages.
Wrap up in module. Add WebSocket client capability. Looking at websocat to provide WebSocket client capability. Appears to be a reasonable choice.