diff --git a/com/codemirror.js b/com/codemirror.js index fb50a50..fba6327 100644 --- a/com/codemirror.js +++ b/com/codemirror.js @@ -109,7 +109,7 @@ AFRAME.registerComponent('codemirror', { // we don't do via shellcmd: isoterminal.exec(`echo '${str}' > ${file}`,1) // as it would require all kindof ugly stringescaping console.log("updating "+file) - await this.isoterminal.worker['emulator.update_file'](file, this.isoterminal.convert.toUint8Array(str) ) + await this.isoterminal.worker.update_file(file, this.isoterminal.convert.toUint8Array(str) ) }, events:{ @@ -117,7 +117,7 @@ AFRAME.registerComponent('codemirror', { // component events DOMready: function(e){ - this.isoterminal.worker['emulator.read_file'](this.data.file) + this.isoterminal.worker.read_file(this.data.file) .then( this.isoterminal.convert.Uint8ArrayToString ) .then( (str) => { console.log("creating editor") diff --git a/com/isoterminal/feat/autorestore.js b/com/isoterminal/feat/autorestore.js index 11882d2..56b8434 100644 --- a/com/isoterminal/feat/autorestore.js +++ b/com/isoterminal/feat/autorestore.js @@ -2,7 +2,7 @@ if( typeof emulator != 'undefined' ){ // inside worker-thread importScripts("localforage.js") // we don't instance it again here (just use its functions) - this['emulator.restore_state'] = async function(data){ + this.restore_state = async function(data){ return new Promise( (resolve,reject) => { localforage.getItem("state", async (err,stateBase64) => { if( stateBase64 && !err ){ @@ -14,7 +14,7 @@ if( typeof emulator != 'undefined' ){ }) }) } - this['emulator.save_state'] = async function(){ + this.save_state = async function(){ console.log("saving session") let state = await emulator.save_state() localforage.setDriver([ @@ -46,7 +46,7 @@ if( typeof emulator != 'undefined' ){ if( stateBase64 && !err && confirm('continue last session?') ){ this.noboot = true // see feat/boot.js try{ - await this.worker['emulator.restore_state']() + await this.worker.restore_state() // simulate / fastforward boot events this.postBoot( () => { this.send("l\n") @@ -57,7 +57,7 @@ if( typeof emulator != 'undefined' ){ }) this.save = async () => { - await this.worker['emulator.save_state']() + await this.worker.save_state() } window.addEventListener("beforeunload", function (e) { diff --git a/com/isoterminal/worker.js b/com/isoterminal/worker.js index 1e076c4..05a4ed0 100644 --- a/com/isoterminal/worker.js +++ b/com/isoterminal/worker.js @@ -42,10 +42,10 @@ this.runISO = function(opts){ /* * forward events/functions so non-worker world can reach them */ - this['emulator.create_file'] = async function(){ return emulator.create_file.apply(emulator, arguments[0]) } - this['emulator.read_file'] = async function(){ return emulator.read_file.apply(emulator, arguments[0]) } - this['emulator.append_file'] = async function(){ emulator.fs9p.append_file.apply(emulator.fs9p, arguments[0]) } - this['emulator.update_file'] = async function(){ emulator.fs9p.update_file.apply(emulator.fs9p, arguments[0]) } + this.create_file = async function(){ return emulator.create_file.apply(emulator, arguments[0]) } + this.read_file = async function(){ return emulator.read_file.apply(emulator, arguments[0]) } + this.append_file = async function(){ emulator.fs9p.append_file.apply(emulator.fs9p, arguments[0]) } + this.update_file = async function(){ emulator.fs9p.update_file.apply(emulator.fs9p, arguments[0]) } // filename will be read from 9pfs: "/mnt/"+filename emulator.readFromPipe = function(filename,cb){