mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 22:40:01 -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 { ScramjetClient } from "../client";
|
||||||
import { rewriteCss, unrewriteCss } from "../../shared";
|
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) {
|
export default function (client: ScramjetClient) {
|
||||||
client.Proxy("CSSStyleDeclaration.prototype.setProperty", {
|
client.Proxy("CSSStyleDeclaration.prototype.setProperty", {
|
||||||
apply(ctx) {
|
apply(ctx) {
|
||||||
|
|
|
@ -320,8 +320,8 @@ export default function (client: ScramjetClient, self: typeof window) {
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
apply(ctx) {
|
apply(ctx) {
|
||||||
const document = ctx.call();
|
const doc = ctx.call();
|
||||||
if (document) {
|
if (doc) {
|
||||||
ctx.return(ctx.this.contentDocument);
|
ctx.return(ctx.this.contentDocument);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default function (client: ScramjetClient, _self: Self) {
|
||||||
client.Proxy("CacheStorage.prototype.match", {
|
client.Proxy("CacheStorage.prototype.match", {
|
||||||
apply(ctx) {
|
apply(ctx) {
|
||||||
if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) {
|
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", {
|
client.Proxy("Cache.prototype.add", {
|
||||||
apply(ctx) {
|
apply(ctx) {
|
||||||
if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) {
|
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" ||
|
typeof ctx.args[0][i] === "string" ||
|
||||||
ctx.args[0][i] instanceof URL
|
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", {
|
client.Proxy("Cache.prototype.put", {
|
||||||
apply(ctx) {
|
apply(ctx) {
|
||||||
if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) {
|
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", {
|
client.Proxy("Cache.prototype.match", {
|
||||||
apply(ctx) {
|
apply(ctx) {
|
||||||
if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) {
|
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] && typeof ctx.args[0] === "string") ||
|
||||||
(ctx.args[0] && ctx.args[0] instanceof URL)
|
(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] && typeof ctx.args[0] === "string") ||
|
||||||
(ctx.args[0] && ctx.args[0] instanceof URL)
|
(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", {
|
client.Proxy("Cache.prototype.delete", {
|
||||||
apply(ctx) {
|
apply(ctx) {
|
||||||
if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) {
|
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) {
|
} else if (typeof ctx.args[2] === "object" && ctx.args[2] !== null) {
|
||||||
pollutant = ctx.args[2]; // next try to use transfer
|
pollutant = ctx.args[2]; // next try to use transfer
|
||||||
} else if (
|
} else if (
|
||||||
|
ctx.this &&
|
||||||
POLLUTANT in ctx.this &&
|
POLLUTANT in ctx.this &&
|
||||||
typeof ctx.this[POLLUTANT] === "object" &&
|
typeof ctx.this[POLLUTANT] === "object" &&
|
||||||
ctx.this[POLLUTANT] !== null
|
ctx.this[POLLUTANT] !== null
|
||||||
|
|
|
@ -9,7 +9,7 @@ export default function (client: ScramjetClient, _self: typeof globalThis) {
|
||||||
client.Proxy("fetch", {
|
client.Proxy("fetch", {
|
||||||
apply(ctx) {
|
apply(ctx) {
|
||||||
if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) {
|
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";
|
if (isemulatedsw) ctx.args[0] += "?from=swruntime";
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ export default function (client: ScramjetClient, _self: typeof globalThis) {
|
||||||
client.Proxy("Request", {
|
client.Proxy("Request", {
|
||||||
construct(ctx) {
|
construct(ctx) {
|
||||||
if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) {
|
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";
|
if (isemulatedsw) ctx.args[0] += "?from=swruntime";
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,10 @@ export default function (client: ScramjetClient, self: typeof globalThis) {
|
||||||
binaryType: "blob",
|
binaryType: "blob",
|
||||||
barews,
|
barews,
|
||||||
|
|
||||||
|
onclose: null,
|
||||||
|
onerror: null,
|
||||||
|
onmessage: null,
|
||||||
|
onopen: null,
|
||||||
captureListeners: {},
|
captureListeners: {},
|
||||||
listeners: {},
|
listeners: {},
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,7 @@ export function unrewriteBlob(url: string) {
|
||||||
|
|
||||||
export function rewriteUrl(url: string | URL, meta: URLMeta) {
|
export function rewriteUrl(url: string | URL, meta: URLMeta) {
|
||||||
if (url instanceof URL) {
|
if (url instanceof URL) {
|
||||||
url = url.href;
|
url = url.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url.startsWith("javascript:")) {
|
if (url.startsWith("javascript:")) {
|
||||||
|
@ -58,7 +58,7 @@ export function rewriteUrl(url: string | URL, meta: URLMeta) {
|
||||||
|
|
||||||
export function unrewriteUrl(url: string | URL) {
|
export function unrewriteUrl(url: string | URL) {
|
||||||
if (url instanceof URL) {
|
if (url instanceof URL) {
|
||||||
url = url.href;
|
url = url.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
const prefixed = location.origin + $scramjet.config.prefix;
|
const prefixed = location.origin + $scramjet.config.prefix;
|
||||||
|
|
|
@ -228,7 +228,7 @@ function BrowserApp() {
|
||||||
|
|
||||||
const cfg = h(Config);
|
const cfg = h(Config);
|
||||||
document.body.appendChild(cfg);
|
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`
|
return html`
|
||||||
<div>
|
<div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue