Spaces:
Sleeping
Sleeping
pythonic-rag-FastAPIReact / frontend /node_modules /@pmmmwh /react-refresh-webpack-plugin /sockets /utils /getWDSMetadata.js
Download frontend/node_modules/@pmmmwh/react-refresh-webpack-plugin/sockets/utils/getWDSMetadata.js from sepidnes/pythonic-rag-FastAPIReact: direct link, hf CLI and curl.
- Browser
- Download file 979 Bytes
-
https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/94e32638a275d46bc1ba62feac204fcaaf313da4/frontend/node_modules/%40pmmmwh/react-refresh-webpack-plugin/sockets/utils/getWDSMetadata.js
- Command line
-
hf download hf://spaces/sepidnes/pythonic-rag-FastAPIReact@94e32638a275d46bc1ba62feac204fcaaf313da4/frontend/node_modules/@pmmmwh/react-refresh-webpack-plugin/sockets/utils/getWDSMetadata.js
-
curl -L -o getWDSMetadata.js https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/94e32638a275d46bc1ba62feac204fcaaf313da4/frontend/node_modules/%40pmmmwh/react-refresh-webpack-plugin/sockets/utils/getWDSMetadata.js
979 Bytes
| /** | |
| * @typedef {Object} WDSMetaObj | |
| * @property {boolean} enforceWs | |
| * @property {number} version | |
| */ | |
| /** | |
| * Derives WDS metadata from a compatible socket client. | |
| * @param {Function} SocketClient A WDS socket client (SockJS/WebSocket). | |
| * @returns {WDSMetaObj} The parsed WDS metadata object. | |
| */ | |
| function getWDSMetadata(SocketClient) { | |
| let enforceWs = false; | |
| if ( | |
| typeof SocketClient.name !== 'undefined' && | |
| SocketClient.name !== null && | |
| SocketClient.name.toLowerCase().includes('websocket') | |
| ) { | |
| enforceWs = true; | |
| } | |
| let version; | |
| // WDS versions <=3.5.0 | |
| if (!('onMessage' in SocketClient.prototype)) { | |
| version = 3; | |
| } else { | |
| // WDS versions >=3.5.0 <4 | |
| if ( | |
| 'getClientPath' in SocketClient || | |
| Object.getPrototypeOf(SocketClient).name === 'BaseClient' | |
| ) { | |
| version = 3; | |
| } else { | |
| version = 4; | |
| } | |
| } | |
| return { | |
| enforceWs: enforceWs, | |
| version: version, | |
| }; | |
| } | |
| module.exports = getWDSMetadata; | |