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/aerojet
This commit is contained in:
commit
78116c2d0c
3 changed files with 18 additions and 6 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import BareClient from "@mercuryworkshop/bare-mux";
|
||||||
|
|
||||||
import "./scope.ts";
|
import "./scope.ts";
|
||||||
import "./window.ts";
|
import "./window.ts";
|
||||||
import "./event.ts";
|
import "./event.ts";
|
||||||
|
@ -21,5 +23,10 @@ declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
$s: any;
|
$s: any;
|
||||||
$sImport: any;
|
$sImport: any;
|
||||||
|
$client: BareClient;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const client = new BareClient();
|
||||||
|
|
||||||
|
export { client };
|
|
@ -1,13 +1,19 @@
|
||||||
// ts throws an error if you dont do window.fetch
|
// ts throws an error if you dont do window.fetch
|
||||||
|
|
||||||
import { encodeUrl, rewriteHeaders } from "../shared";
|
import { encodeUrl, rewriteHeaders } from "../shared";
|
||||||
|
import { client } from "../index";
|
||||||
|
|
||||||
window.fetch = new Proxy(window.fetch, {
|
window.fetch = new Proxy(window.fetch, {
|
||||||
apply(target, thisArg, argArray) {
|
async apply(target, thisArg, argArray) {
|
||||||
argArray[0] = encodeUrl(argArray[0]);
|
// @ts-expect-error
|
||||||
|
const response = await client.fetch(...argArray);
|
||||||
|
|
||||||
return Reflect.apply(target, thisArg, argArray);
|
return new Response(response.body, {
|
||||||
},
|
status: response.status,
|
||||||
|
statusText: response.statusText,
|
||||||
|
headers: response.headers
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Headers = new Proxy(Headers, {
|
Headers = new Proxy(Headers, {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { decodeUrl } from "../../shared/rewriters/url";
|
import { decodeUrl } from "../../shared/rewriters/url";
|
||||||
import { BareClient } from "../shared";
|
import { client } from "../index";
|
||||||
const client = new BareClient();
|
|
||||||
|
|
||||||
WebSocket = new Proxy(WebSocket, {
|
WebSocket = new Proxy(WebSocket, {
|
||||||
construct(target, args) {
|
construct(target, args) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue