mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 23:10:02 -04:00
refactor: delete codecs/ & self.$scramjet
This commit is contained in:
parent
f8d33a207e
commit
337134bcdc
22 changed files with 148 additions and 206 deletions
|
@ -3,22 +3,23 @@ import { swfetch } from "./fetch";
|
|||
import { ScramjetThreadpool } from "./threadpool";
|
||||
import type BareClient from "@mercuryworkshop/bare-mux";
|
||||
import { ScramjetConfig } from "../types";
|
||||
import { $scramjet, loadCodecs } from "../scramjet";
|
||||
|
||||
export class ScramjetServiceWorker extends EventTarget {
|
||||
client: BareClient;
|
||||
config: typeof self.$scramjet.config;
|
||||
config: ScramjetConfig;
|
||||
threadpool: ScramjetThreadpool;
|
||||
|
||||
syncPool: Record<number, (val?: any) => void> = {};
|
||||
synctoken = 0;
|
||||
|
||||
cookieStore = new self.$scramjet.shared.CookieStore();
|
||||
cookieStore = new $scramjet.shared.CookieStore();
|
||||
|
||||
serviceWorkers: FakeServiceWorker[] = [];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.client = new self.$scramjet.shared.util.BareClient();
|
||||
this.client = new $scramjet.shared.util.BareClient();
|
||||
|
||||
this.threadpool = new ScramjetThreadpool();
|
||||
|
||||
|
@ -40,19 +41,6 @@ export class ScramjetServiceWorker extends EventTarget {
|
|||
async loadConfig() {
|
||||
if (this.config) return;
|
||||
|
||||
// const store = new IDBMap("config", {
|
||||
// prefix: "scramjet",
|
||||
// });
|
||||
|
||||
// if (store.has("config")) {
|
||||
// const config = await store.get("config");
|
||||
// this.config = config;
|
||||
// self.$scramjet.config = config;
|
||||
// self.$scramjet.codec = self.$scramjet.codecs[config.codec];
|
||||
// }
|
||||
|
||||
// Recreate the above code using the stock IDB API
|
||||
|
||||
const request = indexedDB.open("$scramjet", 1);
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
|
@ -64,8 +52,9 @@ export class ScramjetServiceWorker extends EventTarget {
|
|||
|
||||
config.onsuccess = () => {
|
||||
this.config = config.result;
|
||||
self.$scramjet.config = config.result;
|
||||
self.$scramjet.codec = self.$scramjet.codecs[config.result.codec];
|
||||
$scramjet.config = config.result;
|
||||
|
||||
loadCodecs();
|
||||
|
||||
resolve();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue