misc refactors

This commit is contained in:
velzie 2024-08-31 11:01:51 -04:00
parent 819c1701d0
commit 0939dd2b57
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
25 changed files with 82 additions and 66 deletions

View file

@ -6,7 +6,7 @@ import { createGlobalProxy } from "./global";
import { getOwnPropertyDescriptorHandler } from "./helpers";
import { createLocationProxy } from "./location";
import { nativeGetOwnPropertyDescriptor } from "./natives";
import { CookieStore, config, decodeUrl } from "./shared";
import { CookieStore, config, decodeUrl, encodeUrl } from "../shared";
import { createWrapFn } from "./shared/wrap";
declare global {
@ -135,6 +135,20 @@ export class ScramjetClient {
}
}
get url(): URL {
return new URL(decodeUrl(self.location.href));
}
set url(url: URL | string) {
if (typeof url === "string") url = new URL(url);
self.location.href = encodeUrl(url.href);
}
// below are the utilities for proxying and trapping dom APIs
// you don't have to understand this it just makes the rest easier
// i'll document it eventually
Proxy(name: string | string[], handler: Proxy) {
if (Array.isArray(name)) {
for (const n of name) {
@ -320,8 +334,4 @@ export class ScramjetClient {
return oldDescriptor;
}
get url(): URL {
return new URL(decodeUrl(location.href));
}
}