feat: add more helper functions to controller

This commit is contained in:
Percs 2024-12-15 17:23:33 -06:00
parent 519c4e3486
commit 542049470e
2 changed files with 11 additions and 1 deletions

View file

@ -15,6 +15,10 @@ export class ScramjetFrame extends EventTarget {
return this.frame.contentWindow.window[SCRAMJETCLIENT];
}
get url(): URL {
return this.client.url;
}
go(url: string | URL) {
if (url instanceof URL) url = url.toString();

View file

@ -29,7 +29,7 @@ export class ScramjetController {
flags: {
serviceworkers: false,
naiiveRewriter: false,
captureErrors: true,
captureErrors: false,
strictRewrites: true,
syncxhr: false,
cleanerrors: false,
@ -84,6 +84,12 @@ export class ScramjetController {
return $scramjet.config.prefix + $scramjet.codec.encode(url);
}
decodeUrl(url: string | URL) {
if (url instanceof URL) url = url.toString();
return $scramjet.codec.decode(url);
}
async openIDB(): Promise<IDBDatabase> {
const db = indexedDB.open("$scramjet", 1);