mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-12 14:00:01 -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"
|
"url": "https://github.com/MercuryWorkshop/scramjet"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rspack build --mode production",
|
"build": "tsc && rspack build --mode production",
|
||||||
"rewriter:build": "cd rewriter/wasm/ && bash build.sh && cd ../../",
|
"rewriter:build": "cd rewriter/wasm/ && bash build.sh && cd ../../",
|
||||||
"dev": "node server.js",
|
"dev": "node server.js",
|
||||||
"dev:debug": "DEBUG=1 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
|
// 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
|
// 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 sab = new SharedArrayBuffer(1024, { maxByteLength: 2147483647 });
|
||||||
const view = new DataView(sab);
|
const view = new DataView(sab);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ export class ScramjetServiceWorkerRuntime {
|
||||||
}
|
}
|
||||||
|
|
||||||
hook() {
|
hook() {
|
||||||
|
// @ts-expect-error TODO
|
||||||
this.client.global.registration = {
|
this.client.global.registration = {
|
||||||
// TODO IMPLEMENT SCOPES
|
// TODO IMPLEMENT SCOPES
|
||||||
scope: this.client.url.href,
|
scope: this.client.url.href,
|
||||||
|
|
|
@ -102,7 +102,7 @@ function rewriteJsWasm(
|
||||||
}
|
}
|
||||||
|
|
||||||
function rewriteJsInner(
|
function rewriteJsInner(
|
||||||
js: string | ArrayBuffer,
|
js: string | Uint8Array,
|
||||||
url: string | null,
|
url: string | null,
|
||||||
meta: URLMeta,
|
meta: URLMeta,
|
||||||
module = false
|
module = false
|
||||||
|
@ -117,7 +117,7 @@ function rewriteJsInner(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function rewriteJs(
|
export function rewriteJs(
|
||||||
js: string | ArrayBuffer,
|
js: string | Uint8Array,
|
||||||
url: string | null,
|
url: string | null,
|
||||||
meta: URLMeta,
|
meta: URLMeta,
|
||||||
module = false
|
module = false
|
||||||
|
@ -126,7 +126,7 @@ export function rewriteJs(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function rewriteJsWithMap(
|
export function rewriteJsWithMap(
|
||||||
js: string | ArrayBuffer,
|
js: string | Uint8Array,
|
||||||
url: string | null,
|
url: string | null,
|
||||||
meta: URLMeta,
|
meta: URLMeta,
|
||||||
module = false
|
module = false
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { rewriteJs } from "./js";
|
||||||
import { URLMeta } from "./url";
|
import { URLMeta } from "./url";
|
||||||
|
|
||||||
export function rewriteWorkers(
|
export function rewriteWorkers(
|
||||||
js: string | ArrayBuffer,
|
js: string | Uint8Array,
|
||||||
type: string,
|
type: string,
|
||||||
url: string,
|
url: string,
|
||||||
meta: URLMeta
|
meta: URLMeta
|
||||||
|
|
|
@ -360,7 +360,7 @@ async function rewriteBody(
|
||||||
}
|
}
|
||||||
case "script":
|
case "script":
|
||||||
let { js, tag, map } = rewriteJsWithMap(
|
let { js, tag, map } = rewriteJsWithMap(
|
||||||
await response.arrayBuffer(),
|
new Uint8Array(await response.arrayBuffer()),
|
||||||
response.finalURL,
|
response.finalURL,
|
||||||
meta,
|
meta,
|
||||||
workertype === "module"
|
workertype === "module"
|
||||||
|
@ -376,7 +376,7 @@ async function rewriteBody(
|
||||||
case "sharedworker":
|
case "sharedworker":
|
||||||
case "worker":
|
case "worker":
|
||||||
return rewriteWorkers(
|
return rewriteWorkers(
|
||||||
await response.arrayBuffer(),
|
new Uint8Array(await response.arrayBuffer()),
|
||||||
workertype,
|
workertype,
|
||||||
response.finalURL,
|
response.finalURL,
|
||||||
meta
|
meta
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
// "allowJs": true,
|
// "allowJs": true,
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"moduleResolution": "Bundler",
|
"moduleResolution": "Bundler",
|
||||||
"module": "ES2022"
|
"module": "ES2022",
|
||||||
},
|
"noEmit": true,
|
||||||
"include": ["src"]
|
"skipLibCheck": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue