ScramjetClient.SCRAMJET -> SCRAMJETCLIENT

This commit is contained in:
velzie 2024-08-30 16:59:52 -04:00
parent 2050fa140c
commit 5f77342d8d
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
11 changed files with 82 additions and 50 deletions

View file

@ -1,6 +1,8 @@
import IDBMap from "@webreflection/idb-map";
import { ScramjetConfig } from "../types";
import { Codec } from "../codecs";
import type { ScramjetClient } from "../client/client";
import { ScramjetFrame } from "./frame";
export class ScramjetController {
config: ScramjetConfig;
@ -24,7 +26,7 @@ export class ScramjetController {
client: "/scramjet.client.js",
codecs: "/scramjet.codecs.js",
flags: {
serviceworkers: true,
serviceworkers: false,
},
};
@ -74,31 +76,4 @@ export class ScramjetController {
}
}
class ScramjetFrame extends EventTarget {
static SCRAMJETFRAME = Symbol.for("scramjet frame handle");
constructor(
private controller: ScramjetController,
public frame: HTMLIFrameElement
) {
super();
frame[ScramjetFrame.SCRAMJETFRAME] = this;
}
go(url: string | URL) {
if (url instanceof URL) url = url.toString();
dbg.log("navigated to", url);
this.frame.src = this.controller.encodeUrl(url);
}
back() {
this.frame.contentWindow?.history.back();
}
forward() {
this.frame.contentWindow?.history.forward();
}
}
window.ScramjetController = ScramjetController;