mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
Merge branch 'main' of https://github.com/MercuryWorkshop/scramjet
This commit is contained in:
commit
94f22bf762
5 changed files with 12 additions and 11 deletions
|
@ -16,6 +16,7 @@
|
||||||
"prefer-const": "warn",
|
"prefer-const": "warn",
|
||||||
"no-unreachable": "warn",
|
"no-unreachable": "warn",
|
||||||
"no-undef": "off",
|
"no-undef": "off",
|
||||||
|
"no-empty": "off",
|
||||||
"@typescript-eslint/no-explicit-any": "off",
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
"@typescript-eslint/ban-ts-comment": "off",
|
"@typescript-eslint/ban-ts-comment": "off",
|
||||||
"@typescript-eslint/ban-types": "off",
|
"@typescript-eslint/ban-types": "off",
|
||||||
|
|
|
@ -12,9 +12,9 @@ import {
|
||||||
import type { URLMeta } from "../../shared/rewriters/url";
|
import type { URLMeta } from "../../shared/rewriters/url";
|
||||||
|
|
||||||
export default function (client: ScramjetClient, self: typeof window) {
|
export default function (client: ScramjetClient, self: typeof window) {
|
||||||
const nativeGetAttribute = self.Element.prototype.getAttribute;
|
const _nativeGetAttribute = self.Element.prototype.getAttribute;
|
||||||
const nativeSetAttribute = self.Element.prototype.setAttribute;
|
const nativeSetAttribute = self.Element.prototype.setAttribute;
|
||||||
const nativeHasAttribute = self.Element.prototype.hasAttribute;
|
const _nativeHasAttribute = self.Element.prototype.hasAttribute;
|
||||||
|
|
||||||
const attrObject = {
|
const attrObject = {
|
||||||
nonce: [self.HTMLElement],
|
nonce: [self.HTMLElement],
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { ScramjetClient } from "../client";
|
import { ScramjetClient } from "../client";
|
||||||
import { decodeUrl, rewriteCss } from "../../shared";
|
import { rewriteCss } from "../../shared";
|
||||||
|
|
||||||
export default function (client: ScramjetClient, self: typeof window) {
|
export default function (client: ScramjetClient, _self: Self) {
|
||||||
client.Proxy("FontFace", {
|
client.Proxy("FontFace", {
|
||||||
construct(ctx) {
|
construct(ctx) {
|
||||||
ctx.args[1] = rewriteCss(ctx.args[1], client.meta);
|
ctx.args[1] = rewriteCss(ctx.args[1], client.meta);
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { config, decodeUrl } from "../../shared";
|
||||||
import { ScramjetClient } from "../client";
|
import { ScramjetClient } from "../client";
|
||||||
|
|
||||||
export const enabled = () => self.$scramjet.config.flags.cleanerrors;
|
export const enabled = () => self.$scramjet.config.flags.cleanerrors;
|
||||||
export default function (client: ScramjetClient, self: Self) {
|
export default function (client: ScramjetClient, _self: Self) {
|
||||||
// v8 only. all we need to do is clean the scramjet urls from stack traces
|
// v8 only. all we need to do is clean the scramjet urls from stack traces
|
||||||
const closure = (error, stack) => {
|
const closure = (error, stack) => {
|
||||||
let newstack = error.stack;
|
let newstack = error.stack;
|
||||||
|
@ -12,9 +12,9 @@ export default function (client: ScramjetClient, self: Self) {
|
||||||
|
|
||||||
if (url.endsWith(config.client)) {
|
if (url.endsWith(config.client)) {
|
||||||
// strip stack frames including scramjet handlers from the trace
|
// strip stack frames including scramjet handlers from the trace
|
||||||
let lines = newstack.split("\n");
|
const lines = newstack.split("\n");
|
||||||
let i = lines.find((l) => l.includes(url));
|
const line = lines.find((l) => l.includes(url));
|
||||||
lines.splice(i, 1);
|
lines.splice(line, 1);
|
||||||
newstack = lines.join("\n");
|
newstack = lines.join("\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,11 @@ export default function (client: ScramjetClient, self: Self) {
|
||||||
return newstack;
|
return newstack;
|
||||||
};
|
};
|
||||||
client.Trap("Error.prepareStackTrace", {
|
client.Trap("Error.prepareStackTrace", {
|
||||||
get(ctx) {
|
get(_ctx) {
|
||||||
// this is a funny js quirk. the getter is ran every time you type something in console
|
// this is a funny js quirk. the getter is ran every time you type something in console
|
||||||
return closure;
|
return closure;
|
||||||
},
|
},
|
||||||
set(value) {
|
set(_value) {
|
||||||
// just ignore it if a site tries setting their own. not much we can really do
|
// just ignore it if a site tries setting their own. not much we can really do
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -270,7 +270,7 @@ export function rewriteSrcset(srcset: string, meta: URLMeta) {
|
||||||
return rewrittenUrls.join("");
|
return rewrittenUrls.join("");
|
||||||
}
|
}
|
||||||
|
|
||||||
function base64ToBytes(base64) {
|
function _base64ToBytes(base64) {
|
||||||
const binString = atob(base64);
|
const binString = atob(base64);
|
||||||
|
|
||||||
return Uint8Array.from(binString, (m) => m.codePointAt(0));
|
return Uint8Array.from(binString, (m) => m.codePointAt(0));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue