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:
@@ -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);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user