Revert previous commit

This commit is contained in:
wearrrrr 2024-10-12 22:55:31 -05:00
parent 63db07da89
commit 4128bc778a
15 changed files with 28 additions and 27 deletions

View file

@ -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];

View file

@ -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);

View file

@ -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!!

View file

@ -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);

View file

@ -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);

View file

@ -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(

View file

@ -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;
},
});

View file

@ -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);

View file

@ -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]}`;

View file

@ -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);

View file

@ -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;

View file

@ -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) {
// argdbg(arg);
// }
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) {

View file

@ -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);

View file

@ -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;

View file

@ -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,
});
}