add license and client apis

This commit is contained in:
Avad3 2024-06-17 06:20:32 -04:00
parent ecff2aca52
commit aac959936c
19 changed files with 1004 additions and 89 deletions

33
src/client/fetch.ts Normal file
View file

@ -0,0 +1,33 @@
// ts throws an error if you dont do window.fetch
window.fetch = new Proxy(window.fetch, {
apply(target, thisArg, argArray) {
argArray[0] = self.__scramjet$bundle.rewriters.url.encodeUrl(argArray[0]);
return Reflect.apply(target, thisArg, argArray);
},
});
Headers = new Proxy(Headers, {
construct(target, argArray, newTarget) {
argArray[0] = self.__scramjet$bundle.rewriters.rewriteHeaders(argArray[0]);
return Reflect.construct(target, argArray, newTarget);
},
})
Request = new Proxy(Request, {
construct(target, argArray, newTarget) {
if (typeof argArray[0] === "string") argArray[0] = self.__scramjet$bundle.rewriters.url.encodeUrl(argArray[0]);
return Reflect.construct(target, argArray, newTarget);
},
});
Response.redirect = new Proxy(Response.redirect, {
apply(target, thisArg, argArray) {
argArray[0] = self.__scramjet$bundle.rewriters.url.encodeUrl(argArray[0]);
return Reflect.apply(target, thisArg, argArray);
},
});