diff --git a/README.md b/README.md index b13205d43..5dc758987 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ ## Getting Started + Directly start developing in your Chrome by visiting [lively4](https://lively-kernel.org/lively4/lively4-core/start.html) and follow the [Getting Started Guide](./doc/tutorial/index.md). Through checking out and serving git repositories with the [lively4-server](doc/lively4-server.md), we can directly edit and use the environment in a self-supporting way. diff --git a/src/babylonian-programming-editor/babylonian-programming-editor.js b/src/babylonian-programming-editor/babylonian-programming-editor.js index 4f3242ec5..f3a5a42f7 100644 --- a/src/babylonian-programming-editor/babylonian-programming-editor.js +++ b/src/babylonian-programming-editor/babylonian-programming-editor.js @@ -310,7 +310,7 @@ export default class BabylonianProgrammingEditor extends Morph { this.livelyEditor().setText(this._text); return } - console.log("AST for code ", this._text) + // console.log("AST for code ", this._text) this.collectAnnotationAndRemoveComments() this.addContext() diff --git a/src/babylonian-programming-editor/worker/ast-worker-babel-wrapper.js b/src/babylonian-programming-editor/worker/ast-worker-babel-wrapper.js deleted file mode 100644 index e42d3cc02..000000000 --- a/src/babylonian-programming-editor/worker/ast-worker-babel-wrapper.js +++ /dev/null @@ -1,18 +0,0 @@ - - -var myPath = "src/babylonian-programming-editor/worker/ast-worker-babel-wrapper.js" -self.lively4url = self.location.toString().replace(myPath, ""); - -importScripts("../../worker/livelyworker.js") - -// React to messages -onmessage = async function(e) { - await System.import("src/plugin-babel.js") - System.import("src/babylonian-programming-editor/worker/ast-worker.js") - .then((m) => { - m.default(e); - }) - .catch((error) => { - postMessage(error); - }); -}; diff --git a/src/babylonian-programming-editor/worker/ast-worker-promise-wrapper.js b/src/babylonian-programming-editor/worker/ast-worker-promise-wrapper.js index f52cd17f2..149dd6bcc 100644 --- a/src/babylonian-programming-editor/worker/ast-worker-promise-wrapper.js +++ b/src/babylonian-programming-editor/worker/ast-worker-promise-wrapper.js @@ -1,12 +1,18 @@ +import SystemjsWorker from "src/worker/systemjs-worker.js"; + let globalMsgId = 0; export default class ASTWorkerPromiseWrapper { constructor() { - this._worker = new Worker("src/babylonian-programming-editor/worker/ast-worker-babel-wrapper.js"); + // this._worker = new Worker("src/babylonian-programming-editor/worker/ast-worker-babel-wrapper.js"); + + this._worker = new SystemjsWorker("src/babylonian-programming-editor/worker/ast-worker.js"); } async process(code, annotations, customInstances, sourceUrl, replacementUrls) { + console.log("ast-worker-promise-wrapper.js process" ) + const msgId = globalMsgId++; const msg = { id: msgId, @@ -19,10 +25,15 @@ export default class ASTWorkerPromiseWrapper { }) }; - return new Promise((resolve, reject) => { + return new Promise(async (resolve, reject) => { + + await this.loaded + // TODO this._worker.onmessage = (result) => { + console.log("ast-worker-promise-wrapper.js onmessage" ) resolve(result.data.payload); }; + console.log("ast-worker-promise-wrapper.js postmessage" ) this._worker.postMessage(msg); }); } diff --git a/src/babylonian-programming-editor/worker/ast-worker.js b/src/babylonian-programming-editor/worker/ast-worker.js index 1639577e3..87c98733b 100644 --- a/src/babylonian-programming-editor/worker/ast-worker.js +++ b/src/babylonian-programming-editor/worker/ast-worker.js @@ -1,4 +1,5 @@ // Custom imports + import { deepCopy, generateLocationMap, @@ -15,10 +16,15 @@ import { } from "../utils/ast.js"; import Performance from "../utils/performance.js"; +console.log("ast-worker loaded") + + /** * Receive message from the main thread */ -export default async function onmessage(msg) { +export async function onmessage(msg) { + + console.log("ast-worker onmessage", msg) // Performance Performance.step("parse"); const { diff --git a/src/babylonian-programming-editor/worker/babylonian-worker.js b/src/babylonian-programming-editor/worker/babylonian-worker.js index 7747d110b..1769e491b 100644 --- a/src/babylonian-programming-editor/worker/babylonian-worker.js +++ b/src/babylonian-programming-editor/worker/babylonian-worker.js @@ -56,8 +56,9 @@ class BabylonianWorker { MD*/ // #important async evaluateEditor(editor, execute = true) { + console.log("BabylonianWorker>>evaluateEditor") // lively.notify("BabylonianWorker>>evaluateEditor") - + // Serialize annotations let serializedAnnotations = {}; diff --git a/src/components/widgets/lively-window.js b/src/components/widgets/lively-window.js index 60412369f..4277b4bad 100644 --- a/src/components/widgets/lively-window.js +++ b/src/components/widgets/lively-window.js @@ -530,8 +530,6 @@ export default class Window extends Morph { } onExtentChanged(evt) { - console.log(evt); - debugger; // console.log(evt); // evt has no content? => current bounds must already have been refreshed if (this.target) { this.target.dispatchEvent(new CustomEvent("extent-changed", evt)); diff --git a/src/worker/meta-worker.js b/src/worker/meta-worker.js index d096fe106..215d5a45d 100644 --- a/src/worker/meta-worker.js +++ b/src/worker/meta-worker.js @@ -9,6 +9,7 @@ self.lively4url = self.location.origin + path.join("/"); importScripts("./livelyworker.js") onmessage = function(evt) { + console.log("metaworker initial onmessage", evt) if (evt.data.message == "load") { console.log("meta worker load " + evt.data.url) System.import("src/plugin-babel.js").then(() => { @@ -20,7 +21,10 @@ onmessage = function(evt) { System.import(evt.data.url).then((m) => { postMessage({message: "loaded"}) - self.onmessage = m.onmessage + self.onmessage = (...args) => { + console.log("metaworker custom onmessage", args) + m.onmessage(...args) + } }).catch((err) => { console.log("meta worker error ", err) postMessage({message: "error", value: err}) diff --git a/src/worker/systemjs-worker.js b/src/worker/systemjs-worker.js index 14320c953..52f991d84 100644 --- a/src/worker/systemjs-worker.js +++ b/src/worker/systemjs-worker.js @@ -14,23 +14,36 @@ export default class SystemjsWorker { constructor(url) { this.metaworker = new Worker("src/worker/meta-worker.js"); // bootstrap onmessage - this.loaded = new Promise(resolve => { + console.log("sytemjs-worker new: " + url) + var isLoaded = false + this.loaded = new Promise((resolve, reject) => { + + + setTimeout(() => { + if (!isLoaded) reject("timeout") + }, 10000) // 10s then timeout? + + this.metaworker.onmessage = (evt) => { var msg = evt.data - console.log("bootstrap onmessage", msg) + console.log(`bootstrap onmessage (${url})` , msg) if (msg.message == "error") { lively.error("[systemjs-worker]", msg.error || msg.value) } if (msg.message == "loaded") { console.log("worker loaded", url) this.metaworker.onmessage = (msg) => { - // console.log("new onmessage") + console.log(`systemjs-worker.js metaworker.onmessage (${url})` ) this.onmessage(msg) } - resolve() // worker should accept postMessages now... + isLoaded = true + resolve(true) // worker should accept postMessages now... } } }) + this.loaded.then(() => { + console.log("systemjs loading finished: " + url) + }) this.metaworker.postMessage({message: "load", url: url, preferences: Preferences.config }) SystemjsWorker.workers.add(this) } @@ -46,6 +59,7 @@ export default class SystemjsWorker { async postMessage(msg) { await this.loaded + console.log("systemjs-worker.js post message", msg) this.metaworker.postMessage(msg) }