add electron build!

- use webpack to build electron-main and electron-preload
- intercept 'https' protocol to run on 'https://replayweb.page' in app
- serve local files from 'https://files.replayweb.page'
- support flash in with service worker replay: catch any fallthrough urls and load via intercept with render process callback
- add icons for electron build
This commit is contained in:
Ilya Kreymer
2020-05-19 22:49:08 -07:00
parent abd5060d20
commit 1a2f2c00a2
13 changed files with 1481 additions and 47 deletions
+46
View File
@@ -0,0 +1,46 @@
"use strict";
import { CollectionLoader } from 'wabac/src/loaders';
const { ipcRenderer } = require('electron');
const dbs = {};
const loader = new CollectionLoader();
async function getDB(name) {
if (!dbs[name]) {
dbs[name] = await loader.loadColl(name);
console.log(dbs[name]);
}
return dbs[name].store;
}
async function getResponse(event, request, coll, ts) {
const db = await getDB(coll);
await db.initing;
const req = {request, url: request.url, timestamp: ts};
const result = await db.getResource(req, "", {request});
const channel = "req:" + request.url;
if (!result) {
ipcRenderer.send(channel, 404);
return;
}
const headers = Object.fromEntries(result.headers.entries());
const buffer = await result.getBuffer();
ipcRenderer.send(channel, result.status, headers, buffer);
}
ipcRenderer.on('getresponse', getResponse);