mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 06:20:02 -04:00
fix un proxy jank
This commit is contained in:
parent
98422f736d
commit
0fef6e8853
3 changed files with 18 additions and 13 deletions
|
@ -1,5 +1,6 @@
|
|||
import { iswindow } from "..";
|
||||
import { ScramjetClient } from "../client";
|
||||
import { unproxy } from "./unproxy";
|
||||
|
||||
const realOnEvent = Symbol.for("scramjet original onevent function");
|
||||
|
||||
|
@ -45,6 +46,7 @@ export default function (client: ScramjetClient, self: Self) {
|
|||
|
||||
client.Proxy("EventTarget.prototype.addEventListener", {
|
||||
apply(ctx) {
|
||||
unproxy(ctx, client);
|
||||
if (typeof ctx.args[1] === "object")
|
||||
ctx.args[1] = wraplistener(ctx.args[1]);
|
||||
},
|
||||
|
|
|
@ -2,12 +2,12 @@ import { isworker } from "../..";
|
|||
import { ScramjetClient } from "../../client";
|
||||
import { BareClient } from "../../shared";
|
||||
|
||||
const bare = new BareClient();
|
||||
|
||||
export default function (client: ScramjetClient, self: typeof globalThis) {
|
||||
// r58 please fix
|
||||
if (isworker) return;
|
||||
|
||||
const bare = new BareClient();
|
||||
|
||||
client.Proxy("WebSocket", {
|
||||
construct(ctx) {
|
||||
ctx.return(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { iswindow } from "..";
|
||||
import { ScramjetClient } from "../client";
|
||||
import { ProxyCtx, ScramjetClient } from "../client";
|
||||
|
||||
export default function (client: ScramjetClient, self: typeof window) {
|
||||
// an automated approach to cleaning the documentProxy from dom functions
|
||||
|
@ -11,11 +11,7 @@ export default function (client: ScramjetClient, self: typeof window) {
|
|||
if (typeof target[prop] === "function") {
|
||||
client.RawProxy(target, prop, {
|
||||
apply(ctx) {
|
||||
if (ctx.this == client.windowProxy) ctx.this = self;
|
||||
for (const i in ctx.args) {
|
||||
if (ctx.args[i] === client.windowProxy)
|
||||
ctx.args[i] = self.global;
|
||||
}
|
||||
unproxy(ctx, client);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -35,11 +31,7 @@ export default function (client: ScramjetClient, self: typeof window) {
|
|||
if (typeof target[prop] === "function") {
|
||||
client.RawProxy(target, prop, {
|
||||
apply(ctx) {
|
||||
for (const i in ctx.args) {
|
||||
if (ctx.args[i] === client.documentProxy)
|
||||
ctx.args[i] = self.document;
|
||||
if (ctx.this === client.documentProxy) ctx.this = self.document;
|
||||
}
|
||||
unproxy(ctx, client);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -47,3 +39,14 @@ export default function (client: ScramjetClient, self: typeof window) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function unproxy(ctx: ProxyCtx, client: ScramjetClient) {
|
||||
const self = client.global;
|
||||
if (ctx.this === client.windowProxy) ctx.this = self;
|
||||
if (ctx.this === client.documentProxy) ctx.this = self.document;
|
||||
|
||||
for (const i in ctx.args) {
|
||||
if (ctx.args[i] === client.documentProxy) ctx.args[i] = self.document;
|
||||
if (ctx.args[i] === client.windowProxy) ctx.args[i] = self;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue