diff --git a/js/codec/workers/tsconfig_base.json b/js/codec/workers/tsconfig_base.json new file mode 100644 index 00000000..d938d42f --- /dev/null +++ b/js/codec/workers/tsconfig_base.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "module": "none", + "target": "es6", + "sourceMap": true + }, + "exclude": [ + "../node_modules", + "../js/codec/workers" + ] +} \ No newline at end of file diff --git a/js/load.ts b/js/load.ts index dadc7f7b..3609df27 100644 --- a/js/load.ts +++ b/js/load.ts @@ -1,3 +1,13 @@ +let moduleInitliaized = false; +let moduleInitliaizeListener: (() => any)[] = []; +if(typeof Module == "undefined") + this["Module"] = {}; +Module['onRuntimeInitialized'] = function() { + moduleInitliaized = true; + for(let l of moduleInitliaizeListener) + l(); +}; + function loadScripts(paths: (string | string[])[]) : {path: string, promise: Promise}[] { let result = []; for(let path of paths) diff --git a/js/main.ts b/js/main.ts index 42dcfa03..cd6d9d85 100644 --- a/js/main.ts +++ b/js/main.ts @@ -15,10 +15,8 @@ let chat: ChatBox; let forumIdentity: TeaForumIdentity; function invokeMain() { - Module['onRuntimeInitialized'] = function() { - console.log("Runtime ready!"); - main(); - }; + if(moduleInitliaized) main(); + else moduleInitliaizeListener.push(main); } function main() {