fixed worker issues
/ test (push) Successful in 5s
Details
/ test (push) Successful in 5s
Details
This commit is contained in:
parent
2105120819
commit
e5a24bbb66
|
@ -4,6 +4,8 @@ AFRAME.registerComponent('codemirror', {
|
|||
schema: {
|
||||
file: { type:"string"},
|
||||
term: { type:"selector", default: "[isoterminal]" },
|
||||
width: { type:"number", default:900},
|
||||
height: { type:"number", default:700},
|
||||
},
|
||||
|
||||
init: function () {
|
||||
|
@ -32,8 +34,9 @@ AFRAME.registerComponent('codemirror', {
|
|||
html: (me) => `<div class="codemirror">
|
||||
</div>`,
|
||||
|
||||
css: (me) => `.codemirror{
|
||||
width:100%;
|
||||
css: (me) => `.CodeMirror{
|
||||
width: ${me.com.data.width}px !important;
|
||||
height: ${me.com.data.height}px !important;
|
||||
}
|
||||
.codemirror *{
|
||||
font-size: 14px;
|
||||
|
@ -42,7 +45,8 @@ AFRAME.registerComponent('codemirror', {
|
|||
letter-spacing: 0 !important;
|
||||
text-shadow: 0px 0px 10px #F075;
|
||||
}
|
||||
.wb-body + .codemirror{ overflow:hidden; }
|
||||
#${me.dom.id} .wb-body { overflow:hidden; }
|
||||
|
||||
.CodeMirror {
|
||||
margin-top:18px;
|
||||
}
|
||||
|
@ -53,7 +57,7 @@ AFRAME.registerComponent('codemirror', {
|
|||
},
|
||||
|
||||
createEditor: function(value){
|
||||
this.el.setAttribute("window", `title: codemirror; uid: ${this.el.dom.id}; attach: #overlay; dom: #${this.el.dom.id};`)
|
||||
this.el.setAttribute("window", `title: codemirror; uid: ${this.el.dom.id}; attach: #overlay; dom: #${this.el.dom.id}; width: ${this.data.width}px; height: ${this.data.height}px`)
|
||||
this.editor = CodeMirror( this.el.dom, {
|
||||
value,
|
||||
mode: "htmlmixed",
|
||||
|
@ -67,10 +71,9 @@ AFRAME.registerComponent('codemirror', {
|
|||
}
|
||||
})
|
||||
this.editor.setOption("theme", "shadowfox")
|
||||
this.editor.updateFile = AFRAME.utils.throttleLeadingAndTrailing( (file,str) => {
|
||||
this.updateFile(file,str),
|
||||
2000
|
||||
})
|
||||
this.editor.updateFile = AFRAME.utils.throttle( (file,str) => {
|
||||
this.updateFile(file,str)
|
||||
}, 1500)
|
||||
this.editor.on('change', (instance,changeObj) => {
|
||||
this.editor.updateFile( this.data.file, instance.getValue() )
|
||||
})
|
||||
|
@ -84,7 +87,8 @@ 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.create_file'](file, term.convert.toUint8Array(str) )
|
||||
console.log(str)
|
||||
await this.isoterminal.worker['emulator.update_file'](file, term.convert.toUint8Array(str) )
|
||||
},
|
||||
|
||||
events:{
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
* ┌─────────┐ ┌────────────┐ ┌─────────────┐ exit-AR
|
||||
* ┌───────►│ com/dom ┼──►│ com/window ├─►│ domrenderer │◄────────── exit-VR ◄─┐
|
||||
* │ └─────────┘ └────────────┘ └─────▲───────┘ │
|
||||
* │ │ ┌───────────────┐ │ renderer=dom
|
||||
* │ │ ┌───────────────┐ │
|
||||
* ┌──────────┴────────┐ ┌─────┴──────┐ │ xterm.js │ ┌─────────────────────────────┐
|
||||
* │ com/isoterminal ├────────────────────────────►│com/xterm.js│◄─┤ │ │com/html-as-texture-in-XR.js │
|
||||
* └────────┬─┬────────┘ └──┬──────┬▲─┘ │ xterm.css │ └─────────────────────────────┘
|
||||
* │ │ ┌────────┐ ┌─────────▼──┐ ││ └───────────────┘ │ ▲
|
||||
* │ └───────►│ plane ├─────►text───┼►canvas │◄────────────────── enter-VR │ │
|
||||
* │ └────────┘ └────────────┘ ││ renderer=canvas enter-AR ◄─┘ │
|
||||
* │ ││ │
|
||||
* │ └────────┘ └────────────┘ ││ enter-AR ◄─┘ │
|
||||
* │ renderer=canvas ││ │
|
||||
* │ ││ │
|
||||
* │ ISOTerminal.js ││ │
|
||||
* │ ┌───────────────────────────┐◄────┘│ │
|
||||
|
|
|
@ -13,6 +13,8 @@ emulator.fs9p.update_file = async function(file,data){
|
|||
|
||||
const inode = this.GetInode(p.id);
|
||||
const buf = typeof data == 'string' ? convert.toUint8Array(data) : data || ""
|
||||
if( buf.length == 0 ) return new Promise( (resolve,reject) => resolve(data) )
|
||||
|
||||
try{
|
||||
await this.Write(p.id,0, buf.length, buf )
|
||||
// update inode
|
||||
|
@ -48,5 +50,3 @@ emulator.fs9p.append_file = async function(file,data){
|
|||
|
||||
}
|
||||
|
||||
this['fs9p.append_file'] = function(){ emulator.fs9p.append_file.apply(emulator.fs9p, arguments[0]) }
|
||||
this['fs9p.update_file'] = function(){ emulator.fs9p.update_file.apply(emulator.fs9p, arguments[0]) }
|
||||
|
|
|
@ -34,7 +34,10 @@ if( typeof emulator != 'undefined' ){
|
|||
|
||||
this.addEventListener('state_restored', function(){
|
||||
// simulate / fastforward boot events
|
||||
this.postBoot( () => this.send("l\n") )
|
||||
this.postBoot( () => {
|
||||
this.send("l\n")
|
||||
this.send("hook wakeup\n")
|
||||
})
|
||||
})
|
||||
|
||||
this.worker.postMessage({event:'emulator.restore_state',data:state})
|
||||
|
|
|
@ -20,10 +20,20 @@ if( typeof emulator != 'undefined' ){
|
|||
}else{
|
||||
// inside browser-thread
|
||||
|
||||
ISOTerminal.addEventListener('javascript-eval', function(e){
|
||||
ISOTerminal.addEventListener('javascript-eval', async function(e){
|
||||
const {script,PID} = e.detail
|
||||
let res = (new Function(`${script}`))()
|
||||
if( res && typeof res != 'string' ) res = JSON.stringify(res,null,2)
|
||||
let res
|
||||
try{
|
||||
res = (new Function(`${script}`))()
|
||||
if( res && typeof res != 'string' ) res = JSON.stringify(res,null,2)
|
||||
}catch(e){
|
||||
console.error(e)
|
||||
console.info(script)
|
||||
res = "error: "+e.toString()
|
||||
if( e.filename ){
|
||||
res += "\n"+e.filename+":"+e.lineno+":"+e.colno
|
||||
}
|
||||
}
|
||||
// update output to 9p with PID as filename (in /mnt/run)
|
||||
this.emit('fs9p.update_file', [`run/${PID}`, this.convert.toUint8Array(res)] )
|
||||
})
|
||||
|
|
|
@ -34,7 +34,7 @@ ISOTerminal.addEventListener('emulator-started', function(){
|
|||
str.trim().split("\n").map( (line) => {
|
||||
finalStr += '\x1b[38;5;165m/dev/browser: \x1b[0m'+prefix+line+'\n'
|
||||
})
|
||||
this.emit('fs9p.append_file', ["/dev/browser/console",finalStr])
|
||||
this.emit('append_file', ["/dev/browser/console",finalStr])
|
||||
})
|
||||
|
||||
window.addEventListener('error', function(event) {
|
||||
|
|
|
@ -44,6 +44,8 @@ this.runISO = function(opts){
|
|||
*/
|
||||
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]) }
|
||||
|
||||
// filename will be read from 9pfs: "/mnt/"+filename
|
||||
emulator.readFromPipe = function(filename,cb){
|
||||
|
@ -62,9 +64,9 @@ this.runISO = function(opts){
|
|||
* forward events/functions so non-worker world can reach them
|
||||
*/
|
||||
|
||||
this['serial0-input'] = function(c){ this.emulator.bus.send( 'serial0-input', c) } // to /dev/ttyS0
|
||||
this['serial1-input'] = function(c){ this.emulator.bus.send( 'serial1-input', c) } // to /dev/ttyS1
|
||||
this['serial2-input'] = function(c){ this.emulator.bus.send( 'serial2-input', c) } // to /dev/ttyS2
|
||||
this['serial0-input'] = function(c){ emulator.bus.send( 'serial0-input', c) } // to /dev/ttyS0
|
||||
this['serial1-input'] = function(c){ emulator.bus.send( 'serial1-input', c) } // to /dev/ttyS1
|
||||
this['serial2-input'] = function(c){ emulator.bus.send( 'serial2-input', c) } // to /dev/ttyS2
|
||||
|
||||
this.onmessage = async function(e){
|
||||
let {event,data} = e.data
|
||||
|
|
|
@ -156,6 +156,7 @@ AFRAME.registerComponent('xterm', {
|
|||
disableStdin: false,
|
||||
rows: this.data.rows,
|
||||
cols: this.data.cols,
|
||||
fontFamily: 'Cousine, monospace',
|
||||
fontSize: this.fontSize,
|
||||
lineHeight: 1.15,
|
||||
useFlowControl: true,
|
||||
|
|
Loading…
Reference in New Issue