mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-11 21:40:02 -04:00
actually use ts
This commit is contained in:
parent
fbeaf15283
commit
9f2d22ed37
7 changed files with 24 additions and 15 deletions
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ export class ScramjetServiceWorkerRuntime {
|
|||
}
|
||||
|
||||
hook() {
|
||||
// @ts-expect-error TODO
|
||||
this.client.global.registration = {
|
||||
// TODO IMPLEMENT SCOPES
|
||||
scope: this.client.url.href,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue