mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 14:30:02 -04:00
fix: misc bugs
This commit is contained in:
parent
58fed66f78
commit
ca3e09af8e
8 changed files with 20 additions and 28 deletions
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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: {},
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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`
|
||||
<div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue