actually use ts

This commit is contained in:
Toshit Chawda 2025-03-07 17:08:01 -08:00
parent fbeaf15283
commit 9f2d22ed37
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
7 changed files with 24 additions and 15 deletions

View file

@ -10,7 +10,7 @@
"url": "https://github.com/MercuryWorkshop/scramjet"
},
"scripts": {
"build": "rspack build --mode production",
"build": "tsc && rspack build --mode production",
"rewriter:build": "cd rewriter/wasm/ && bash build.sh && cd ../../",
"dev": "node server.js",
"dev:debug": "DEBUG=1 node server.js",

View file

@ -40,6 +40,7 @@ export default function (client: ScramjetClient, self: Self) {
// sync xhr to service worker is not supported
// there's a nice way of polyfilling this though, we can spin on an atomic using sharedarraybuffer. this will maintain the sync behavior
// @ts-expect-error ts dum
const sab = new SharedArrayBuffer(1024, { maxByteLength: 2147483647 });
const view = new DataView(sab);

View file

@ -26,6 +26,7 @@ export class ScramjetServiceWorkerRuntime {
}
hook() {
// @ts-expect-error TODO
this.client.global.registration = {
// TODO IMPLEMENT SCOPES
scope: this.client.url.href,

View file

@ -102,7 +102,7 @@ function rewriteJsWasm(
}
function rewriteJsInner(
js: string | ArrayBuffer,
js: string | Uint8Array,
url: string | null,
meta: URLMeta,
module = false
@ -117,7 +117,7 @@ function rewriteJsInner(
}
export function rewriteJs(
js: string | ArrayBuffer,
js: string | Uint8Array,
url: string | null,
meta: URLMeta,
module = false
@ -126,7 +126,7 @@ export function rewriteJs(
}
export function rewriteJsWithMap(
js: string | ArrayBuffer,
js: string | Uint8Array,
url: string | null,
meta: URLMeta,
module = false

View file

@ -3,7 +3,7 @@ import { rewriteJs } from "./js";
import { URLMeta } from "./url";
export function rewriteWorkers(
js: string | ArrayBuffer,
js: string | Uint8Array,
type: string,
url: string,
meta: URLMeta

View file

@ -360,7 +360,7 @@ async function rewriteBody(
}
case "script":
let { js, tag, map } = rewriteJsWithMap(
await response.arrayBuffer(),
new Uint8Array(await response.arrayBuffer()),
response.finalURL,
meta,
workertype === "module"
@ -376,7 +376,7 @@ async function rewriteBody(
case "sharedworker":
case "worker":
return rewriteWorkers(
await response.arrayBuffer(),
new Uint8Array(await response.arrayBuffer()),
workertype,
response.finalURL,
meta

View file

@ -1,10 +1,17 @@
{
"compilerOptions": {
// "allowJs": true,
"rootDir": "./src",
"target": "ES2022",
"moduleResolution": "Bundler",
"module": "ES2022"
},
"include": ["src"]
"compilerOptions": {
// "allowJs": true,
"rootDir": "./src",
"target": "ES2022",
"moduleResolution": "Bundler",
"module": "ES2022",
"noEmit": true,
"skipLibCheck": true
},
"include": [
"src"
],
"exclude": [
"node_modules"
]
}