mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
Revert previous commit
This commit is contained in:
parent
63db07da89
commit
4128bc778a
15 changed files with 28 additions and 27 deletions
|
@ -166,7 +166,7 @@ export default function (client: ScramjetClient, self: typeof window) {
|
|||
});
|
||||
client.Proxy("Element.prototype.setAttributeNS", {
|
||||
apply(ctx) {
|
||||
const [_namespace, name, value] = ctx.args;
|
||||
const [namespace, name, value] = ctx.args;
|
||||
|
||||
const ruleList = htmlRules.find((rule) => {
|
||||
const r = rule[name];
|
||||
|
|
|
@ -2,7 +2,7 @@ import { ScramjetClient } from "../client";
|
|||
import { rewriteUrl } from "../../shared";
|
||||
import { UrlChangeEvent } from "../events";
|
||||
|
||||
export default function (client: ScramjetClient, _self: typeof globalThis) {
|
||||
export default function (client: ScramjetClient, self: typeof globalThis) {
|
||||
client.Proxy("history.pushState", {
|
||||
apply(ctx) {
|
||||
if (ctx.args[2]) ctx.args[2] = rewriteUrl(ctx.args[2], client.meta);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { ScramjetClient } from "../client";
|
||||
import { unrewriteUrl } from "../../shared";
|
||||
|
||||
export default function (client: ScramjetClient, _self: typeof window) {
|
||||
export default function (client: ScramjetClient, self: typeof window) {
|
||||
client.Trap("origin", {
|
||||
get() {
|
||||
// this isn't right!!
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { unrewriteUrl } from "../../shared";
|
||||
import { ScramjetClient } from "../client";
|
||||
|
||||
export default function (client: ScramjetClient, _self: typeof globalThis) {
|
||||
export default function (client: ScramjetClient, self: typeof globalThis) {
|
||||
client.Trap("PerformanceEntry.prototype.name", {
|
||||
get(ctx) {
|
||||
return unrewriteUrl(ctx.get() as string);
|
||||
|
|
|
@ -86,7 +86,7 @@ export default function (client: ScramjetClient, self: typeof window) {
|
|||
};
|
||||
|
||||
const realLocalStorage = self.localStorage;
|
||||
// const realSessionStorage = self.sessionStorage;
|
||||
const realSessionStorage = self.sessionStorage;
|
||||
|
||||
const localStorageProxy = new Proxy(self.localStorage, handler);
|
||||
const sessionStorageProxy = new Proxy(self.sessionStorage, handler);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// @ts-nocheck
|
||||
import { ScramjetClient } from "./client";
|
||||
import { nativeGetOwnPropertyDescriptor } from "./natives";
|
||||
import { rewriteUrl } from "../shared";
|
||||
import { unrewriteUrl, rewriteUrl } from "../shared";
|
||||
import { iswindow } from ".";
|
||||
|
||||
export function createLocationProxy(
|
||||
|
|
|
@ -10,10 +10,10 @@ export default function (client: ScramjetClient) {
|
|||
|
||||
const log = console.log;
|
||||
client.Trap("console.log", {
|
||||
set(_ctx, _v) {
|
||||
set(ctx, v) {
|
||||
// is there a legitimate reason to let sites do this?
|
||||
},
|
||||
get(_ctx) {
|
||||
get(ctx) {
|
||||
return log;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@ function rewriteFunction(ctx: ProxyCtx, client: ScramjetClient) {
|
|||
ctx.return(ctx.fn(content)());
|
||||
}
|
||||
|
||||
export default function (client: ScramjetClient, _self: Self) {
|
||||
export default function (client: ScramjetClient, self: Self) {
|
||||
const handler: Proxy = {
|
||||
apply(ctx) {
|
||||
rewriteFunction(ctx, client);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { ScramjetClient } from "../client";
|
||||
|
||||
export default function (client: ScramjetClient, _self: Self) {
|
||||
export default function (client: ScramjetClient, self: Self) {
|
||||
client.Proxy("IDBFactory.prototype.open", {
|
||||
apply(ctx) {
|
||||
ctx.args[0] = `${client.url.origin}@${ctx.args[0]}`;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { rewriteUrl } from "../../../shared";
|
||||
import { ScramjetClient } from "../../client";
|
||||
|
||||
export default function (client: ScramjetClient, _self) {
|
||||
export default function (client: ScramjetClient, self) {
|
||||
client.Proxy("navigator.sendBeacon", {
|
||||
apply(ctx) {
|
||||
ctx.args[0] = rewriteUrl(ctx.args[0], client.meta);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { iswindow } from "..";
|
||||
import { BareMuxConnection } from "../../shared";
|
||||
import { rewriteUrl } from "../../shared";
|
||||
import type { MessageC2W } from "../../worker";
|
||||
import { ScramjetClient } from "../client";
|
||||
|
||||
const sharedworkerpostmessage = MessagePort.prototype.postMessage;
|
||||
|
|
|
@ -2,15 +2,15 @@ import { iswindow, isworker } from "..";
|
|||
import { SCRAMJETCLIENT } from "../../symbols";
|
||||
import { ScramjetClient } from "../client";
|
||||
import { config } from "../../shared";
|
||||
import { argdbg } from "./err";
|
||||
import { indirectEval } from "./eval";
|
||||
// import { argdbg } from "./err";
|
||||
|
||||
export function createWrapFn(client: ScramjetClient, self: typeof globalThis) {
|
||||
return function (identifier: any, args: any) {
|
||||
if (args && typeof args === "object" && args.length === 0)
|
||||
// for (const arg of args) {
|
||||
for (const arg of args) {
|
||||
// argdbg(arg);
|
||||
// }
|
||||
}
|
||||
if (iswindow && identifier instanceof self.Window) {
|
||||
return client.globalProxy;
|
||||
} else if (iswindow && identifier instanceof self.parent.self.Window) {
|
||||
|
|
|
@ -38,7 +38,6 @@ export class ScramjetServiceWorkerRuntime {
|
|||
postMessage: () => {},
|
||||
addEventListener: () => {},
|
||||
removeEventListener: () => {},
|
||||
// @ts-ignore
|
||||
dispatchEvent: (_e: Event) => {},
|
||||
},
|
||||
showNotification: async () => {},
|
||||
|
@ -124,7 +123,7 @@ function handleMessage(
|
|||
|
||||
function trustEvent(event: Event): Event {
|
||||
return new Proxy(event, {
|
||||
get(target, prop, _reciever) {
|
||||
get(target, prop, reciever) {
|
||||
if (prop === "isTrusted") return true;
|
||||
|
||||
return Reflect.get(target, prop);
|
||||
|
|
12
src/sync.ts
12
src/sync.ts
|
@ -31,14 +31,14 @@ addEventListener(
|
|||
cursor += 2;
|
||||
|
||||
// next write the header string
|
||||
const resHeaders = xhr.getAllResponseHeaders();
|
||||
view.setUint32(cursor, resHeaders.length);
|
||||
const headers = xhr.getAllResponseHeaders();
|
||||
view.setUint32(cursor, headers.length);
|
||||
cursor += 4;
|
||||
|
||||
if (sab.byteLength < cursor + resHeaders.length)
|
||||
sab.grow(cursor + resHeaders.length);
|
||||
u8view.set(new TextEncoder().encode(resHeaders), cursor);
|
||||
cursor += resHeaders.length;
|
||||
if (sab.byteLength < cursor + headers.length)
|
||||
sab.grow(cursor + headers.length);
|
||||
u8view.set(new TextEncoder().encode(headers), cursor);
|
||||
cursor += headers.length;
|
||||
|
||||
view.setUint32(cursor, xhr.response.byteLength);
|
||||
cursor += 4;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { rewriteJs } from "../shared/rewriters/js";
|
||||
|
||||
// @ts-ignore
|
||||
onconnect = (ev) => {
|
||||
const port = ev.ports[0];
|
||||
onconnect = (e) => {
|
||||
const port = e.ports[0];
|
||||
|
||||
console.log("thread: connected to port", port);
|
||||
port.postMessage("ready");
|
||||
|
@ -20,10 +20,10 @@ onconnect = (ev) => {
|
|||
token,
|
||||
result: res,
|
||||
});
|
||||
} catch (err) {
|
||||
} catch (e) {
|
||||
port.postMessage({
|
||||
token,
|
||||
error: err.message,
|
||||
error: e.message,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue