diff --git a/src/client/dom/css.ts b/src/client/dom/css.ts index d8bb0f8..9150a9d 100644 --- a/src/client/dom/css.ts +++ b/src/client/dom/css.ts @@ -1,19 +1,6 @@ import { ScramjetClient } from "../client"; import { rewriteCss, unrewriteCss } from "../../shared"; -// Why is this here? -// const cssProperties = [ -// "background", -// "background-image", -// "mask", -// "mask-image", -// "list-style", -// "list-style-image", -// "border-image", -// "border-image-source", -// "cursor", -// ]; - export default function (client: ScramjetClient) { client.Proxy("CSSStyleDeclaration.prototype.setProperty", { apply(ctx) { diff --git a/src/client/dom/element.ts b/src/client/dom/element.ts index 943e7a1..f5d2a4b 100644 --- a/src/client/dom/element.ts +++ b/src/client/dom/element.ts @@ -320,8 +320,8 @@ export default function (client: ScramjetClient, self: typeof window) { ], { apply(ctx) { - const document = ctx.call(); - if (document) { + const doc = ctx.call(); + if (doc) { ctx.return(ctx.this.contentDocument); } }, diff --git a/src/client/shared/caches.ts b/src/client/shared/caches.ts index 70a58db..5c2f3b8 100644 --- a/src/client/shared/caches.ts +++ b/src/client/shared/caches.ts @@ -17,7 +17,7 @@ export default function (client: ScramjetClient, _self: Self) { client.Proxy("CacheStorage.prototype.match", { apply(ctx) { if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) { - ctx.args[0] = rewriteUrl(ctx.args[0].toString(), client.meta); + ctx.args[0] = rewriteUrl(ctx.args[0], client.meta); } }, }); @@ -31,7 +31,7 @@ export default function (client: ScramjetClient, _self: Self) { client.Proxy("Cache.prototype.add", { apply(ctx) { if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) { - ctx.args[0] = rewriteUrl(ctx.args[0].toString(), client.meta); + ctx.args[0] = rewriteUrl(ctx.args[0], client.meta); } }, }); @@ -43,7 +43,7 @@ export default function (client: ScramjetClient, _self: Self) { typeof ctx.args[0][i] === "string" || ctx.args[0][i] instanceof URL ) { - ctx.args[0][i] = rewriteUrl(ctx.args[0][i].toString(), client.meta); + ctx.args[0][i] = rewriteUrl(ctx.args[0][i], client.meta); } } }, @@ -52,7 +52,7 @@ export default function (client: ScramjetClient, _self: Self) { client.Proxy("Cache.prototype.put", { apply(ctx) { if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) { - ctx.args[0] = rewriteUrl(ctx.args[0].toString(), client.meta); + ctx.args[0] = rewriteUrl(ctx.args[0], client.meta); } }, }); @@ -60,7 +60,7 @@ export default function (client: ScramjetClient, _self: Self) { client.Proxy("Cache.prototype.match", { apply(ctx) { if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) { - ctx.args[0] = rewriteUrl(ctx.args[0].toString(), client.meta); + ctx.args[0] = rewriteUrl(ctx.args[0], client.meta); } }, }); @@ -71,7 +71,7 @@ export default function (client: ScramjetClient, _self: Self) { (ctx.args[0] && typeof ctx.args[0] === "string") || (ctx.args[0] && ctx.args[0] instanceof URL) ) { - ctx.args[0] = rewriteUrl(ctx.args[0].toString(), client.meta); + ctx.args[0] = rewriteUrl(ctx.args[0], client.meta); } }, }); @@ -82,7 +82,7 @@ export default function (client: ScramjetClient, _self: Self) { (ctx.args[0] && typeof ctx.args[0] === "string") || (ctx.args[0] && ctx.args[0] instanceof URL) ) { - ctx.args[0] = rewriteUrl(ctx.args[0].toString(), client.meta); + ctx.args[0] = rewriteUrl(ctx.args[0], client.meta); } }, }); @@ -90,7 +90,7 @@ export default function (client: ScramjetClient, _self: Self) { client.Proxy("Cache.prototype.delete", { apply(ctx) { if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) { - ctx.args[0] = rewriteUrl(ctx.args[0].toString(), client.meta); + ctx.args[0] = rewriteUrl(ctx.args[0], client.meta); } }, }); diff --git a/src/client/shared/postmessage.ts b/src/client/shared/postmessage.ts index a9da497..08f7bd4 100644 --- a/src/client/shared/postmessage.ts +++ b/src/client/shared/postmessage.ts @@ -20,6 +20,7 @@ export default function (client: ScramjetClient) { } else if (typeof ctx.args[2] === "object" && ctx.args[2] !== null) { pollutant = ctx.args[2]; // next try to use transfer } else if ( + ctx.this && POLLUTANT in ctx.this && typeof ctx.this[POLLUTANT] === "object" && ctx.this[POLLUTANT] !== null diff --git a/src/client/shared/requests/fetch.ts b/src/client/shared/requests/fetch.ts index a395342..03befb0 100644 --- a/src/client/shared/requests/fetch.ts +++ b/src/client/shared/requests/fetch.ts @@ -9,7 +9,7 @@ export default function (client: ScramjetClient, _self: typeof globalThis) { client.Proxy("fetch", { apply(ctx) { if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) { - ctx.args[0] = rewriteUrl(ctx.args[0].toString(), client.meta); + ctx.args[0] = rewriteUrl(ctx.args[0], client.meta); if (isemulatedsw) ctx.args[0] += "?from=swruntime"; } @@ -19,7 +19,7 @@ export default function (client: ScramjetClient, _self: typeof globalThis) { client.Proxy("Request", { construct(ctx) { if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) { - ctx.args[0] = rewriteUrl(ctx.args[0].toString(), client.meta); + ctx.args[0] = rewriteUrl(ctx.args[0], client.meta); if (isemulatedsw) ctx.args[0] += "?from=swruntime"; } diff --git a/src/client/shared/requests/websocket.ts b/src/client/shared/requests/websocket.ts index 5da5953..76ac2fd 100644 --- a/src/client/shared/requests/websocket.ts +++ b/src/client/shared/requests/websocket.ts @@ -50,6 +50,10 @@ export default function (client: ScramjetClient, self: typeof globalThis) { binaryType: "blob", barews, + onclose: null, + onerror: null, + onmessage: null, + onopen: null, captureListeners: {}, listeners: {}, }; diff --git a/src/shared/rewriters/url.ts b/src/shared/rewriters/url.ts index b0b31cf..67296d1 100644 --- a/src/shared/rewriters/url.ts +++ b/src/shared/rewriters/url.ts @@ -28,7 +28,7 @@ export function unrewriteBlob(url: string) { export function rewriteUrl(url: string | URL, meta: URLMeta) { if (url instanceof URL) { - url = url.href; + url = url.toString(); } if (url.startsWith("javascript:")) { @@ -58,7 +58,7 @@ export function rewriteUrl(url: string | URL, meta: URLMeta) { export function unrewriteUrl(url: string | URL) { if (url instanceof URL) { - url = url.href; + url = url.toString(); } const prefixed = location.origin + $scramjet.config.prefix; diff --git a/static/ui.js b/static/ui.js index 671921b..41940d9 100644 --- a/static/ui.js +++ b/static/ui.js @@ -228,7 +228,7 @@ function BrowserApp() { const cfg = h(Config); document.body.appendChild(cfg); - this.githubURL = `https://github.com/MercuryWorkshop/scramjet/tree/${$scramjet.version.build}`; + this.githubURL = `https://github.com/MercuryWorkshop/scramjet/commit/${$scramjet.version.build}`; return html`