Skip to content

Commit f4ca659

Browse files
fix(overmind-devtools): keep hack due to bug
1 parent 6cae3fa commit f4ca659

File tree

1 file changed

+32
-1
lines changed
  • packages/node_modules/overmind-devtools/src

1 file changed

+32
-1
lines changed

packages/node_modules/overmind-devtools/src/main.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ function createWindow() {
1717
minWidth: 500,
1818
})
1919

20+
21+
electron.protocol.registerFileProtocol('filestub', (request, callback) => {
22+
const url = request.url.substr(10)
23+
const file = { path: path.normalize(`${path.join(__dirname, '..')}/${url}`) }
24+
25+
callback(file)
26+
})
27+
28+
2029
const devtoolBackend = DevtoolBackend.create({
2130
onRelaunch() {
2231
app.relaunch()
@@ -86,6 +95,7 @@ function createWindow() {
8695
.connect(port)
8796
.then(() => resolve(port))
8897
.catch(() => {
98+
8999
mainWindow.loadURL(
90100
'data:text/html;charset=UTF-8,' +
91101
encodeURIComponent(
@@ -94,7 +104,10 @@ function createWindow() {
94104
onPortSubmit,
95105
onRestart
96106
)
97-
)
107+
),
108+
{
109+
baseURLForDataURL: `file://${path.resolve()}/devtoolsDist/`,
110+
}
98111
)
99112
})
100113
})
@@ -159,6 +172,24 @@ function createWindow() {
159172
)
160173

161174
startDevtoolBackend().then(openDevtools)
175+
176+
/*
177+
BUG FIX: https://github.com/electron/electron/issues/13008#issuecomment-575909942
178+
*/
179+
180+
let redirectURL = 'data:application/x-javascript;base64,UHJvZHVjdFJlZ2lzdHJ5SW1wbC5SZWdpc3RyeT1jbGFzc3tjb25zdHJ1Y3Rvcigpe31uYW1lRm9yVXJsKHIpe3JldHVybiBudWxsfWVudHJ5Rm9yVXJsKHIpe3JldHVybiBudWxsfXR5cGVGb3JVcmwocil7cmV0dXJuIG51bGx9fSxQcm9kdWN0UmVnaXN0cnlJbXBsLl9oYXNoRm9yRG9tYWluPWZ1bmN0aW9uKHIpe3JldHVybiIifSxQcm9kdWN0UmVnaXN0cnlJbXBsLnJlZ2lzdGVyPWZ1bmN0aW9uKHIsdCl7UHJvZHVjdFJlZ2lzdHJ5SW1wbC5fcHJvZHVjdHNCeURvbWFpbkhhc2g9bmV3IE1hcH0sUHJvZHVjdFJlZ2lzdHJ5SW1wbC5fcHJvZHVjdHNCeURvbWFpbkhhc2g9bmV3IE1hcCxQcm9kdWN0UmVnaXN0cnlJbXBsLnJlZ2lzdGVyKFtdLFtdKSxQcm9kdWN0UmVnaXN0cnlJbXBsLnNoYTE9ZnVuY3Rpb24ocil7cmV0dXJuIiJ9Ow==';
181+
electron.session.defaultSession.webRequest.onBeforeRequest((details, callback) => {
182+
if ((/^devtools:\/\/devtools\/remote\/serve_file\/@[0-9a-f]{40}\/product_registry_impl\/product_registry_impl_module.js$/ui).test(details.url)) {
183+
// eslint-disable-next-line
184+
callback({
185+
redirectURL
186+
});
187+
return;
188+
}
189+
// eslint-disable-next-line
190+
callback({});
191+
});
192+
162193
}
163194

164195
// This method will be called when Electron has finished

0 commit comments

Comments
 (0)