refactor beautify: worker['emulator.foo'](..) => worker.foo(..)
This commit is contained in:
parent
277dafbd36
commit
de8883673c
|
@ -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")
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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){
|
||||
|
|
Loading…
Reference in New Issue