mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-16 07:30:02 -04:00
kill snapshot.ts (untested)
This commit is contained in:
parent
9a39435c7d
commit
7f398cda17
7 changed files with 33 additions and 18 deletions
|
@ -4,7 +4,7 @@ import { rewriteJs } from "../shared";
|
|||
function rewriteFunction(ctx: ProxyCtx) {
|
||||
const stringifiedFunction = ctx.fn(...ctx.args).toString();
|
||||
|
||||
ctx.return(Function(`return ${rewriteJs(stringifiedFunction)}`)());
|
||||
ctx.return(ctx.fn(`return ${rewriteJs(stringifiedFunction)}`)());
|
||||
}
|
||||
|
||||
export default function (client: ScramjetClient, self: Self) {
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import { ScramjetClient } from "../client";
|
||||
import { config, encodeUrl } from "../shared";
|
||||
|
||||
export default function (client, self) {
|
||||
export default function (client: ScramjetClient, self: Self) {
|
||||
const Function = client.natives.Function;
|
||||
|
||||
self[config.importfn] = function (base: string) {
|
||||
return function (url: string) {
|
||||
const resolved = new URL(url, base).href;
|
||||
|
|
|
@ -8,7 +8,8 @@ export default function (client: ScramjetClient, self: typeof globalThis) {
|
|||
if (args[0].startsWith("blob:") || args[0].startsWith("data:")) {
|
||||
if (args[0].startsWith("blob:")) {
|
||||
args[0] =
|
||||
"data:application/javascript;base64," + btoa(syncfetch(args[0]));
|
||||
"data:application/javascript;base64," +
|
||||
btoa(syncfetch(client, args[0]));
|
||||
}
|
||||
|
||||
args[0] = "/scramjet/worker?data=" + args[0];
|
||||
|
@ -30,9 +31,12 @@ export default function (client: ScramjetClient, self: typeof globalThis) {
|
|||
});
|
||||
}
|
||||
|
||||
function syncfetch(url: string) {
|
||||
function syncfetch(client: ScramjetClient, url: string) {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", url, false);
|
||||
|
||||
const realOpen = client.natives["XMLHttpRequest.prototype.open"].bind(xhr);
|
||||
|
||||
realOpen("GET", url, false);
|
||||
xhr.send();
|
||||
|
||||
return xhr.responseText;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue