Abhinav 2022-08-09 10:32:19 +05:30
parent c3c99e0970
commit 239e243ac3

View file

@ -1,6 +1,6 @@
import { Readable } from 'stream';
import * as fs from 'promise-fs';
import * as electron from 'electron';
import { webFrame, ipcRenderer } from 'electron';
import {
getElectronFile,
getPendingUploads,
@ -13,7 +13,23 @@ import { ElectronFile } from './types';
import { getEncryptionKey, setEncryptionKey } from './utils/safeStorage';
import { clearElectronStore } from './utils/electronStore';
const { ipcRenderer } = electron;
// Patch the global WebSocket constructor to use the correct DevServer url
const fixHotReloadNext12 = () => {
webFrame.executeJavaScript(`Object.defineProperty(globalThis, 'WebSocket', {
value: new Proxy(WebSocket, {
construct: (Target, [url, protocols]) => {
if (url.endsWith('/_next/webpack-hmr')) {
// Fix the Next.js hmr client url
return new Target("ws://localhost:3000/_next/webpack-hmr", protocols)
} else {
return new Target(url, protocols)
}
}
})
});`);
};
fixHotReloadNext12();
const responseToReadable = (fileStream: any) => {
const reader = fileStream.getReader();