Polyfill WebSocket on Node
This commit is contained in:
parent
fcd0cb84fe
commit
85648c9466
5 changed files with 1427 additions and 272 deletions
|
|
@ -249,6 +249,15 @@ export class Syncer {
|
|||
const wsUri = new URL(settings.remoteUri);
|
||||
wsUri.protocol = wsUri.protocol === "https" ? "wss" : "ws";
|
||||
wsUri.pathname = `/vaults/${settings.vaultName}/ws`;
|
||||
|
||||
if (
|
||||
typeof globalThis !== "undefined" &&
|
||||
typeof globalThis.WebSocket === "undefined"
|
||||
) {
|
||||
// polyfill for WebSocket in Node.js
|
||||
globalThis.WebSocket = require("ws");
|
||||
}
|
||||
|
||||
this.applyRemoteChangesWebSocket = new WebSocket(wsUri);
|
||||
|
||||
this.applyRemoteChangesWebSocket.onmessage = (event): void =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue