chore: prettier

This commit is contained in:
Percs 2024-10-10 23:03:39 -05:00
parent b3eeb91a2d
commit 9db2842c95
4 changed files with 19 additions and 19 deletions

View file

@ -108,7 +108,7 @@ export class ScramjetClient {
resolve(data.port); resolve(data.port);
} }
}); });
}), })
); );
} }
@ -249,7 +249,7 @@ export class ScramjetClient {
h.construct = function ( h.construct = function (
constructor: any, constructor: any,
argArray: any[], argArray: any[],
newTarget: AnyFunction, newTarget: AnyFunction
) { ) {
let returnValue: any = undefined; let returnValue: any = undefined;
let earlyreturn = false; let earlyreturn = false;
@ -364,7 +364,7 @@ export class ScramjetClient {
RawTrap<T>( RawTrap<T>(
target: any, target: any,
prop: string, prop: string,
descriptor: Trap<T>, descriptor: Trap<T>
): PropertyDescriptor { ): PropertyDescriptor {
if (!target) return; if (!target) return;
if (!prop) return; if (!prop) return;

View file

@ -26,13 +26,13 @@ function newmeta(url: URL): URLMeta {
export async function swfetch( export async function swfetch(
this: ScramjetServiceWorker, this: ScramjetServiceWorker,
request: Request, request: Request,
client: Client | null, client: Client | null
) { ) {
const urlParam = new URLSearchParams(new URL(request.url).search); const urlParam = new URLSearchParams(new URL(request.url).search);
if (urlParam.has("url")) { if (urlParam.has("url")) {
return Response.redirect( return Response.redirect(
encodeUrl(urlParam.get("url"), newmeta(new URL(urlParam.get("url")))), encodeUrl(urlParam.get("url"), newmeta(new URL(urlParam.get("url"))))
); );
} }
@ -49,7 +49,7 @@ export async function swfetch(
const url = new URL(decodeUrl(requesturl)); const url = new URL(decodeUrl(requesturl));
const activeWorker: FakeServiceWorker | null = this.serviceWorkers.find( const activeWorker: FakeServiceWorker | null = this.serviceWorkers.find(
(w) => w.origin === url.origin, (w) => w.origin === url.origin
); );
if ( if (
@ -63,7 +63,7 @@ export async function swfetch(
} }
if (url.origin == new URL(request.url).origin) { if (url.origin == new URL(request.url).origin) {
throw new Error( throw new Error(
"attempted to fetch from same origin - this means the site has obtained a reference to the real origin, aborting", "attempted to fetch from same origin - this means the site has obtained a reference to the real origin, aborting"
); );
} }
@ -116,7 +116,7 @@ export async function swfetch(
response, response,
this.cookieStore, this.cookieStore,
client, client,
this, this
); );
} catch (err) { } catch (err) {
console.error("ERROR FROM SERVICE WORKER FETCH", err); console.error("ERROR FROM SERVICE WORKER FETCH", err);
@ -134,7 +134,7 @@ async function handleResponse(
response: BareResponseFetch, response: BareResponseFetch,
cookieStore: CookieStore, cookieStore: CookieStore,
client: Client, client: Client,
swtarget: ScramjetServiceWorker, swtarget: ScramjetServiceWorker
): Promise<Response> { ): Promise<Response> {
let responseBody: string | ArrayBuffer | ReadableStream; let responseBody: string | ArrayBuffer | ReadableStream;
const responseHeaders = rewriteHeaders(response.rawHeaders, newmeta(url)); const responseHeaders = rewriteHeaders(response.rawHeaders, newmeta(url));
@ -151,7 +151,7 @@ async function handleResponse(
await cookieStore.setCookies( await cookieStore.setCookies(
maybeHeaders instanceof Array ? maybeHeaders : [maybeHeaders], maybeHeaders instanceof Array ? maybeHeaders : [maybeHeaders],
url, url
); );
for (const header in responseHeaders) { for (const header in responseHeaders) {
@ -169,7 +169,7 @@ async function handleResponse(
await response.text(), await response.text(),
cookieStore, cookieStore,
newmeta(url), newmeta(url),
true, true
); );
} else { } else {
responseBody = response.body; responseBody = response.body;
@ -188,7 +188,7 @@ async function handleResponse(
responseBody = rewriteWorkers( responseBody = rewriteWorkers(
await response.arrayBuffer(), await response.arrayBuffer(),
workertype, workertype,
newmeta(url), newmeta(url)
); );
break; break;
default: default:

View file

@ -76,7 +76,7 @@ export class ScramjetServiceWorker extends EventTarget {
clients = clients.filter( clients = clients.filter(
(client) => (client) =>
client.type === "window" && client.type === "window" &&
!new URL(client.url).pathname.startsWith(this.config.prefix), !new URL(client.url).pathname.startsWith(this.config.prefix)
); );
if (clients.length === 0) throw new Error("No clients found"); if (clients.length === 0) throw new Error("No clients found");
@ -99,7 +99,7 @@ export class ScramjetServiceWorker extends EventTarget {
clients = clients.filter( clients = clients.filter(
(client) => (client) =>
client.type === "window" && client.type === "window" &&
!new URL(client.url).pathname.startsWith(this.config.prefix), !new URL(client.url).pathname.startsWith(this.config.prefix)
); );
if (clients.length === 0) throw new Error("No clients found"); if (clients.length === 0) throw new Error("No clients found");
@ -130,7 +130,7 @@ export class ScramjetServiceWorker extends EventTarget {
const type = new URL(request.url).searchParams.get("type"); const type = new URL(request.url).searchParams.get("type");
const origin = new URL( const origin = new URL(
decodeURIComponent(new URL(request.url).searchParams.get("origin")), decodeURIComponent(new URL(request.url).searchParams.get("origin"))
); );
let promise = this.dataworkerpromises[id]; let promise = this.dataworkerpromises[id];

View file

@ -49,7 +49,7 @@ const store = $store(
"/bare/", "/bare/",
proxy: "", proxy: "",
}, },
{ ident: "settings", backing: "localstorage", autosave: "auto" }, { ident: "settings", backing: "localstorage", autosave: "auto" }
); );
connection.setTransport("/libcurl/index.mjs", [{ wisp: store.wispurl }]); connection.setTransport("/libcurl/index.mjs", [{ wisp: store.wispurl }]);
function App() { function App() {
@ -146,7 +146,7 @@ function App() {
if (url === "about:blank") return; if (url === "about:blank") return;
this.url = $scramjet.codecs.plain.decode( this.url = $scramjet.codecs.plain.decode(
url.substring((location.href + "/scramjet").length), url.substring((location.href + "/scramjet").length)
); );
}); });
@ -193,7 +193,7 @@ function App() {
<div class=${[flex, "nav"]} style="width: 60%"> <div class=${[flex, "nav"]} style="width: 60%">
<button on:click=${() => frame.back()}>&lt;-</button> <button on:click=${() => frame.back()}>&lt;-</button>
<input class="bar" style="flex: 1" bind:value=${use(this.url)} on:input=${( <input class="bar" style="flex: 1" bind:value=${use(this.url)} on:input=${(
e, e
) => { ) => {
this.url = e.target.value; this.url = e.target.value;
}} on:keyup=${(e) => e.keyCode == 13 && (store.url = this.url) && handleSubmit()}></input> }} on:keyup=${(e) => e.keyCode == 13 && (store.url = this.url) && handleSubmit()}></input>
@ -227,6 +227,6 @@ padding-bottom: 100px;
background-size: contain; background-size: contain;
background-position: center center; background-position: center center;
background-repeat: no-repeat; background-repeat: no-repeat;
`, `
); );
}); });