mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 23:10:02 -04:00
start bootstrapper
This commit is contained in:
parent
034c8e1c6d
commit
17b440ea37
15 changed files with 166 additions and 131 deletions
|
@ -1,3 +1,4 @@
|
|||
import IDBMap from "idb-map-entries";
|
||||
import { FakeServiceWorker } from "./fakesw";
|
||||
import { swfetch } from "./fetch";
|
||||
import { ScramjetThreadpool } from "./threadpool";
|
||||
|
@ -18,10 +19,9 @@ export class ScramjetServiceWorker {
|
|||
|
||||
serviceWorkers: FakeServiceWorker[] = [];
|
||||
|
||||
constructor(config = self.$scramjet.config) {
|
||||
constructor() {
|
||||
this.loadConfig();
|
||||
this.client = new self.$scramjet.shared.util.BareClient();
|
||||
if (!config.prefix) config.prefix = "/scramjet/";
|
||||
this.config = config;
|
||||
|
||||
this.threadpool = new ScramjetThreadpool();
|
||||
|
||||
|
@ -46,6 +46,20 @@ export class ScramjetServiceWorker {
|
|||
});
|
||||
}
|
||||
|
||||
loadConfig() {
|
||||
const store = new IDBMap("config", {
|
||||
prefix: "scramjet"
|
||||
});
|
||||
|
||||
if (store.has("config")) {
|
||||
store.get("config").then((config) => {
|
||||
this.config = config;
|
||||
self.$scramjet.config = config;
|
||||
self.$scramjet.codec = self.$scramjet.codecs[config.codec]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async getLocalStorage(): Promise<Record<string, string>> {
|
||||
let clients = await self.clients.matchAll();
|
||||
clients = clients.filter(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue