diff --git a/webapp/package.json b/webapp/package.json index 6e6c5a35..dec0ce98 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -1,12 +1,14 @@ { "name": "noot", "version": "1.0.0", - "source": "src/index.html", + "source": [ + "src/index.html" + ], "license": "MIT", "browserslist": "> 0.5%, last 2 versions, not dead", "scripts": { - "start": "parcel", - "build": "parcel build", + "start": "cp src/function_worker.js dist/ && parcel", + "build": "parcel build && cp src/function_worker.js dist/", "check-watch": "tsc --noEmit --watch" }, "devDependencies": { @@ -14,7 +16,11 @@ "@types/react": "^17.0.39", "@types/react-dom": "^17.0.11", "parcel": "^2.3.2", - "typescript": ">=3.0.0" + "typescript": ">=3.0.0", + "uglify-js": "^3.15.1" + }, + "resolutions": { + "@lezer/common": "git://github.com/zefhemel/common.git#046c880d1fcab713cadad327a5b7d8bb5de6522c" }, "dependencies": { "@codemirror/basic-setup": "^0.19.1", diff --git a/webapp/src/plugins/function_worker.ts b/webapp/src/function_worker.js similarity index 75% rename from webapp/src/plugins/function_worker.ts rename to webapp/src/function_worker.js index ec815570..191e3af7 100644 --- a/webapp/src/plugins/function_worker.ts +++ b/webapp/src/function_worker.js @@ -1,16 +1,16 @@ -function safeRun(fn: () => Promise) { +function safeRun(fn) { fn().catch((e) => { console.error(e); }); } let func = null; -let pendingRequests: { - [key: number]: any; -} = {}; +let pendingRequests = {}; + +console.log("hello world!"); self.addEventListener("syscall", (event) => { - let customEvent = event as CustomEvent; + let customEvent = event; let detail = customEvent.detail; pendingRequests[detail.id] = detail.callback; self.postMessage({ @@ -22,7 +22,7 @@ self.addEventListener("syscall", (event) => { }); self.addEventListener("result", (event) => { - let customEvent = event as CustomEvent; + let customEvent = event; self.postMessage({ type: "result", result: customEvent.detail, @@ -30,8 +30,8 @@ self.addEventListener("result", (event) => { }); self.addEventListener("app-error", (event) => { - let customEvent = event as CustomEvent; - postMessage({ + let customEvent = event; + self.postMessage({ type: "error", reason: customEvent.detail, }); @@ -39,17 +39,12 @@ self.addEventListener("app-error", (event) => { self.addEventListener("message", (event) => { safeRun(async () => { - let messageEvent = event as MessageEvent; + let messageEvent = event; let data = messageEvent.data; switch (data.type) { case "boot": console.log("Booting", `./${data.prefix}/function/${data.name}`); importScripts(`./${data.prefix}/function/${data.name}`); - // if (data.userAgent && data.userAgent.indexOf("Firefox") !== -1) { - // // @ts-ignore - // } else { - // await import(`./${data.prefix}/function/${data.name}`); - // } self.postMessage({ type: "inited", }); diff --git a/webapp/src/plugins/runtime.ts b/webapp/src/plugins/runtime.ts index 04f5920a..461e6bdb 100644 --- a/webapp/src/plugins/runtime.ts +++ b/webapp/src/plugins/runtime.ts @@ -22,7 +22,12 @@ export class FunctionWorker { private cartridge: Cartridge; constructor(cartridge: Cartridge, pathPrefix: string, name: string) { - this.worker = new Worker(new URL("function_worker.ts", import.meta.url)); + // this.worker = new Worker(new URL("function_worker.ts", import.meta.url), { + // type: "classic", + // }); + let worker = window.Worker; + this.worker = new worker("function_worker.js"); + // console.log("Starting worker", this.worker); this.worker.onmessage = this.onmessage.bind(this); this.worker.postMessage({ diff --git a/webapp/yarn.lock b/webapp/yarn.lock index cf8f71dd..ec2cbaac 100644 --- a/webapp/yarn.lock +++ b/webapp/yarn.lock @@ -280,10 +280,9 @@ style-mod "^4.0.0" w3c-keyname "^2.2.4" -"@lezer/common@^0.15.0", "@lezer/common@^0.15.5": +"@lezer/common@^0.15.0", "@lezer/common@^0.15.5", "@lezer/common@git://github.com/zefhemel/common.git#046c880d1fcab713cadad327a5b7d8bb5de6522c": version "0.15.11" - resolved "https://registry.yarnpkg.com/@lezer/common/-/common-0.15.11.tgz#965b5067036305f12e8a3efc344076850be1d3a8" - integrity sha512-vv0nSdIaVCRcJ8rPuDdsrNVfBOYe/4Szr/LhF929XyDmBndLDuWiCCHooGlGlJfzELyO608AyDhVsuX/ZG36NA== + resolved "git://github.com/zefhemel/common.git#046c880d1fcab713cadad327a5b7d8bb5de6522c" "@lezer/css@^0.15.2": version "0.15.2" @@ -1889,6 +1888,11 @@ typescript@>=3.0.0: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3" integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA== +uglify-js@^3.15.1: + version "3.15.1" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.15.1.tgz#9403dc6fa5695a6172a91bc983ea39f0f7c9086d" + integrity sha512-FAGKF12fWdkpvNJZENacOH0e/83eG6JyVQyanIJaBXCN1J11TUQv1T1/z8S+Z0CG0ZPk1nPcreF/c7lrTd0TEQ== + util-deprecate@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"