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", { client.Proxy("Element.prototype.setAttributeNS", {
apply(ctx) { apply(ctx) {
const [_namespace, name, value] = ctx.args; const [namespace, name, value] = ctx.args;
const ruleList = htmlRules.find((rule) => { const ruleList = htmlRules.find((rule) => {
const r = rule[name]; const r = rule[name];

View file

@ -2,7 +2,7 @@ import { ScramjetClient } from "../client";
import { rewriteUrl } from "../../shared"; import { rewriteUrl } from "../../shared";
import { UrlChangeEvent } from "../events"; import { UrlChangeEvent } from "../events";
export default function (client: ScramjetClient, _self: typeof globalThis) { export default function (client: ScramjetClient, self: typeof globalThis) {
client.Proxy("history.pushState", { client.Proxy("history.pushState", {
apply(ctx) { apply(ctx) {
if (ctx.args[2]) ctx.args[2] = rewriteUrl(ctx.args[2], client.meta); if (ctx.args[2]) ctx.args[2] = rewriteUrl(ctx.args[2], client.meta);

View file

@ -1,6 +1,7 @@
import { ScramjetClient } from "../client"; 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", { client.Trap("origin", {
get() { get() {
// this isn't right!! // this isn't right!!

View file

@ -1,7 +1,7 @@
import { unrewriteUrl } from "../../shared"; import { unrewriteUrl } from "../../shared";
import { ScramjetClient } from "../client"; 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", { client.Trap("PerformanceEntry.prototype.name", {
get(ctx) { get(ctx) {
return unrewriteUrl(ctx.get() as string); 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 realLocalStorage = self.localStorage;
// const realSessionStorage = self.sessionStorage; const realSessionStorage = self.sessionStorage;
const localStorageProxy = new Proxy(self.localStorage, handler); const localStorageProxy = new Proxy(self.localStorage, handler);
const sessionStorageProxy = new Proxy(self.sessionStorage, handler); const sessionStorageProxy = new Proxy(self.sessionStorage, handler);

View file

@ -1,7 +1,7 @@
// @ts-nocheck // @ts-nocheck
import { ScramjetClient } from "./client"; import { ScramjetClient } from "./client";
import { nativeGetOwnPropertyDescriptor } from "./natives"; import { nativeGetOwnPropertyDescriptor } from "./natives";
import { rewriteUrl } from "../shared"; import { unrewriteUrl, rewriteUrl } from "../shared";
import { iswindow } from "."; import { iswindow } from ".";
export function createLocationProxy( export function createLocationProxy(

View file

@ -10,10 +10,10 @@ export default function (client: ScramjetClient) {
const log = console.log; const log = console.log;
client.Trap("console.log", { client.Trap("console.log", {
set(_ctx, _v) { set(ctx, v) {
// is there a legitimate reason to let sites do this? // is there a legitimate reason to let sites do this?
}, },
get(_ctx) { get(ctx) {
return log; return log;
}, },
}); });

View file

@ -8,7 +8,7 @@ function rewriteFunction(ctx: ProxyCtx, client: ScramjetClient) {
ctx.return(ctx.fn(content)()); ctx.return(ctx.fn(content)());
} }
export default function (client: ScramjetClient, _self: Self) { export default function (client: ScramjetClient, self: Self) {
const handler: Proxy = { const handler: Proxy = {
apply(ctx) { apply(ctx) {
rewriteFunction(ctx, client); rewriteFunction(ctx, client);

View file

@ -1,6 +1,6 @@
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
export default function (client: ScramjetClient, _self: Self) { export default function (client: ScramjetClient, self: Self) {
client.Proxy("IDBFactory.prototype.open", { client.Proxy("IDBFactory.prototype.open", {
apply(ctx) { apply(ctx) {
ctx.args[0] = `${client.url.origin}@${ctx.args[0]}`; ctx.args[0] = `${client.url.origin}@${ctx.args[0]}`;

View file

@ -1,7 +1,7 @@
import { rewriteUrl } from "../../../shared"; import { rewriteUrl } from "../../../shared";
import { ScramjetClient } from "../../client"; import { ScramjetClient } from "../../client";
export default function (client: ScramjetClient, _self) { export default function (client: ScramjetClient, self) {
client.Proxy("navigator.sendBeacon", { client.Proxy("navigator.sendBeacon", {
apply(ctx) { apply(ctx) {
ctx.args[0] = rewriteUrl(ctx.args[0], client.meta); ctx.args[0] = rewriteUrl(ctx.args[0], client.meta);

View file

@ -1,6 +1,7 @@
import { iswindow } from ".."; import { iswindow } from "..";
import { BareMuxConnection } from "../../shared"; import { BareMuxConnection } from "../../shared";
import { rewriteUrl } from "../../shared"; import { rewriteUrl } from "../../shared";
import type { MessageC2W } from "../../worker";
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
const sharedworkerpostmessage = MessagePort.prototype.postMessage; const sharedworkerpostmessage = MessagePort.prototype.postMessage;

View file

@ -2,15 +2,15 @@ import { iswindow, isworker } from "..";
import { SCRAMJETCLIENT } from "../../symbols"; import { SCRAMJETCLIENT } from "../../symbols";
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
import { config } from "../../shared"; import { config } from "../../shared";
import { argdbg } from "./err";
import { indirectEval } from "./eval"; import { indirectEval } from "./eval";
// import { argdbg } from "./err";
export function createWrapFn(client: ScramjetClient, self: typeof globalThis) { export function createWrapFn(client: ScramjetClient, self: typeof globalThis) {
return function (identifier: any, args: any) { return function (identifier: any, args: any) {
if (args && typeof args === "object" && args.length === 0) if (args && typeof args === "object" && args.length === 0)
// for (const arg of args) { for (const arg of args) {
// argdbg(arg); // argdbg(arg);
// } }
if (iswindow && identifier instanceof self.Window) { if (iswindow && identifier instanceof self.Window) {
return client.globalProxy; return client.globalProxy;
} else if (iswindow && identifier instanceof self.parent.self.Window) { } else if (iswindow && identifier instanceof self.parent.self.Window) {

View file

@ -38,7 +38,6 @@ export class ScramjetServiceWorkerRuntime {
postMessage: () => {}, postMessage: () => {},
addEventListener: () => {}, addEventListener: () => {},
removeEventListener: () => {}, removeEventListener: () => {},
// @ts-ignore
dispatchEvent: (_e: Event) => {}, dispatchEvent: (_e: Event) => {},
}, },
showNotification: async () => {}, showNotification: async () => {},
@ -124,7 +123,7 @@ function handleMessage(
function trustEvent(event: Event): Event { function trustEvent(event: Event): Event {
return new Proxy(event, { return new Proxy(event, {
get(target, prop, _reciever) { get(target, prop, reciever) {
if (prop === "isTrusted") return true; if (prop === "isTrusted") return true;
return Reflect.get(target, prop); return Reflect.get(target, prop);

View file

@ -31,14 +31,14 @@ addEventListener(
cursor += 2; cursor += 2;
// next write the header string // next write the header string
const resHeaders = xhr.getAllResponseHeaders(); const headers = xhr.getAllResponseHeaders();
view.setUint32(cursor, resHeaders.length); view.setUint32(cursor, headers.length);
cursor += 4; cursor += 4;
if (sab.byteLength < cursor + resHeaders.length) if (sab.byteLength < cursor + headers.length)
sab.grow(cursor + resHeaders.length); sab.grow(cursor + headers.length);
u8view.set(new TextEncoder().encode(resHeaders), cursor); u8view.set(new TextEncoder().encode(headers), cursor);
cursor += resHeaders.length; cursor += headers.length;
view.setUint32(cursor, xhr.response.byteLength); view.setUint32(cursor, xhr.response.byteLength);
cursor += 4; cursor += 4;

View file

@ -1,8 +1,8 @@
import { rewriteJs } from "../shared/rewriters/js"; import { rewriteJs } from "../shared/rewriters/js";
// @ts-ignore // @ts-ignore
onconnect = (ev) => { onconnect = (e) => {
const port = ev.ports[0]; const port = e.ports[0];
console.log("thread: connected to port", port); console.log("thread: connected to port", port);
port.postMessage("ready"); port.postMessage("ready");
@ -20,10 +20,10 @@ onconnect = (ev) => {
token, token,
result: res, result: res,
}); });
} catch (err) { } catch (e) {
port.postMessage({ port.postMessage({
token, token,
error: err.message, error: e.message,
}); });
} }