diff --git a/Makefile b/Makefile index e054de9..8577615 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ build: dist: build mkdir -p $(BUILD)/build - cp -r $(SRC)/*.html $(SRC)/term.js src/examples $(SRC)/sw.js $(BUILD) + cp -r $(SRC)/*.html $(SRC)/term.js src/examples $(SRC)/build/sw.js $(BUILD) cp $(SRC)/build/firmware.js $(SRC)/build/simulator.js $(SRC)/build/firmware.wasm $(BUILD)/build/ watch: dist diff --git a/src/Makefile b/src/Makefile index 66dbdcb..f2f7de1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -147,6 +147,7 @@ $(BUILD)/micropython.js: $(OBJ) jshal.js simulator-js simulator-js: npx esbuild ./simulator.ts --bundle --outfile=$(BUILD)/simulator.js --loader:.svg=text + npx esbuild --define:process.env.version=$$(cat ../package.json | jq .version) ./sw.ts --bundle --outfile=$(BUILD)/sw.js include $(TOP)/py/mkrules.mk diff --git a/src/sw.js b/src/sw.ts similarity index 81% rename from src/sw.js rename to src/sw.ts index 0ef355d..4aa1103 100644 --- a/src/sw.js +++ b/src/sw.ts @@ -1,6 +1,11 @@ -const version = "v0.0.3"; +/// +// Empty export required due to --isolatedModules flag in tsconfig.json +export type {}; +declare const self: ServiceWorkerGlobalScope; +declare const clients: Clients; + const assets = ["simulator.html", "build/simulator.js", "build/firmware.js"]; -const cacheName = `simulator-${version}`; +const cacheName = `simulator-${process.env.version}`; self.addEventListener("install", (event) => { console.log("Installing simulator service worker..."); diff --git a/tsconfig.json b/tsconfig.json index 0716a2c..40888c0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "target": "es2019", - "lib": ["dom", "dom.iterable", "esnext"], + "lib": ["dom", "dom.iterable", "esnext", "WebWorker"], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true,