chore: lint:fix

This commit is contained in:
wearrrrr 2024-10-10 19:31:35 -05:00
parent 4d7fa7abb6
commit e8a8a66397
5 changed files with 22 additions and 13 deletions

View file

@ -171,9 +171,10 @@ export default function (client: ScramjetClient, self: typeof window) {
// since the prototype chain is fucked
const style = ctx.get() as CSSStyleDeclaration;
return new Proxy(style, {
get(t, p) {
let v = Reflect.get(t, p);
const v = Reflect.get(t, p);
if (typeof v === "function") {
return new Proxy(v, {
apply(target, thisArg, argArray) {
@ -189,6 +190,7 @@ export default function (client: ScramjetClient, self: typeof window) {
if (v == "" || typeof v !== "string") {
return Reflect.set(t, p, v);
}
return Reflect.set(t, p, rewriteCss(v, client.meta));
},
});

View file

@ -9,7 +9,8 @@ export default function (client: ScramjetClient, self: Self) {
client.Trap("IDBDatabase.prototype.name", {
get(ctx) {
let name = ctx.get() as string;
const name = ctx.get() as string;
return name.substring(name.indexOf("@") + 1);
},
});

View file

@ -47,7 +47,7 @@ export default function (client: ScramjetClient, self: Self) {
body: ctx.args[0],
});
let now = performance.now();
const now = performance.now();
while (view.getUint8(0) === 0) {
if (performance.now() - now > 1000) {
throw new Error("xhr timeout");
@ -85,12 +85,14 @@ export default function (client: ScramjetClient, self: Self) {
client.RawTrap(ctx.this, "response", {
get() {
if (ctx.this.responseType === "arraybuffer") return bodyab.buffer;
return body;
},
});
client.RawTrap(ctx.this, "responseXML", {
get() {
const parser = new DOMParser();
return parser.parseFromString(body, "text/xml");
},
});
@ -104,6 +106,7 @@ export default function (client: ScramjetClient, self: Self) {
return (header: string) => {
const re = new RegExp(`^${header}: (.*)$`, "m");
const match = re.exec(headers);
return match ? match[1] : null;
};
},

View file

@ -66,6 +66,7 @@ export default function (client: ScramjetClient, self: typeof globalThis) {
if (typeof v === "string" && v.includes("scramjet")) {
debugger;
}
return v;
};

View file

@ -219,7 +219,7 @@ function traverseParsedHtml(
) {
let js = node.children[0].data;
// node.attribs[`data-scramjet-script-source-src`] = btoa(js);
node.attribs[`data-scramjet-script-source-src`] = bytesToBase64(
node.attribs["data-scramjet-script-source-src"] = bytesToBase64(
new TextEncoder().encode(js)
);
const htmlcomment = /<!--[\s\S]*?-->/g;
@ -272,6 +272,7 @@ export function rewriteSrcset(srcset: string, meta: URLMeta) {
function base64ToBytes(base64) {
const binString = atob(base64);
return Uint8Array.from(binString, (m) => m.codePointAt(0));
}
@ -279,5 +280,6 @@ function bytesToBase64(bytes: Uint8Array) {
const binString = Array.from(bytes, (byte) =>
String.fromCodePoint(byte)
).join("");
return btoa(binString);
}