Spaces:
Sleeping
Sleeping
pythonic-rag-FastAPIReact / frontend /node_modules /@pmmmwh /react-refresh-webpack-plugin /sockets /WPSSocket.js
Download frontend/node_modules/@pmmmwh/react-refresh-webpack-plugin/sockets/WPSSocket.js from sepidnes/pythonic-rag-FastAPIReact: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/56fda741e84da791ee2e6198479f1d5630989f6c/frontend/node_modules/%40pmmmwh/react-refresh-webpack-plugin/sockets/WPSSocket.js
- Command line
-
hf download hf://spaces/sepidnes/pythonic-rag-FastAPIReact@56fda741e84da791ee2e6198479f1d5630989f6c/frontend/node_modules/@pmmmwh/react-refresh-webpack-plugin/sockets/WPSSocket.js
-
curl -L -o WPSSocket.js https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/56fda741e84da791ee2e6198479f1d5630989f6c/frontend/node_modules/%40pmmmwh/react-refresh-webpack-plugin/sockets/WPSSocket.js
1.54 kB
| /* global ʎɐɹɔosǝʌɹǝs */ | |
| const { ClientSocket } = require('webpack-plugin-serve/lib/client/ClientSocket'); | |
| /** | |
| * Initializes a socket server for HMR for webpack-plugin-serve. | |
| * @param {function(*): void} messageHandler A handler to consume Webpack compilation messages. | |
| * @returns {void} | |
| */ | |
| function initWPSSocket(messageHandler) { | |
| /** | |
| * The hard-coded options injection key from webpack-plugin-serve. | |
| * | |
| * [Ref](https://github.com/shellscape/webpack-plugin-serve/blob/aeb49f14e900802c98df4a4607a76bc67b1cffdf/lib/index.js#L258) | |
| * @type {Object | undefined} | |
| */ | |
| let options; | |
| try { | |
| options = ʎɐɹɔosǝʌɹǝs; | |
| } catch (e) { | |
| // Bail out because this indicates the plugin is not included | |
| return; | |
| } | |
| const { address, client = {}, secure } = options; | |
| const protocol = secure ? 'wss' : 'ws'; | |
| const socket = new ClientSocket(client, protocol + '://' + (client.address || address) + '/wps'); | |
| socket.addEventListener('message', function listener(message) { | |
| const { action, data } = JSON.parse(message.data); | |
| switch (action) { | |
| case 'done': { | |
| messageHandler({ type: 'ok' }); | |
| break; | |
| } | |
| case 'problems': { | |
| if (data.errors.length) { | |
| messageHandler({ type: 'errors', data: data.errors }); | |
| } else if (data.warnings.length) { | |
| messageHandler({ type: 'warnings', data: data.warnings }); | |
| } | |
| break; | |
| } | |
| default: { | |
| // Do nothing | |
| } | |
| } | |
| }); | |
| } | |
| module.exports = { init: initWPSSocket }; | |