mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 14:30:02 -04:00
ScramjetClient.SCRAMJET -> SCRAMJETCLIENT
This commit is contained in:
parent
2050fa140c
commit
5f77342d8d
11 changed files with 82 additions and 50 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue