launcher ok

This commit is contained in:
bordun 2020-03-11 16:42:45 +01:00
parent a8fee9c5c3
commit 97c504e79a
23 changed files with 220 additions and 89 deletions

View file

@ -57,13 +57,11 @@ module.exports = function(options={}) {
shell.openExternal(url)
})
if (options.fullscreen) {
window.webContents.on('dom-ready', ()=>{
window.webContents.executeJavaScript(`
window.ELECTRON_FULLSCREEN = true
`)
})
}
// window.webContents.on('dom-ready', ()=>{
// window.webContents.executeJavaScript(`
// window.ELECTRON = true
// `)
// })
if (options.zoom === false) {
window.webContents.setVisualZoomLevelLimits(1, 1)

View file

@ -7,7 +7,7 @@ var serverStarted
function nodeMode() {
console.warn('Running with node')
console.warn('(INFO) Running with node')
if (!settings.read('noGui')) {
settings.cli = true
@ -71,6 +71,9 @@ function openClient() {
var launch = ()=>{
var win = require('./electron-window')({address:address, shortcuts:true, zoom:false, fullscreen: settings.read('fullScreen')})
win.on('error', ()=>{
console.log('ERR')
})
return win
}
if (app.isReady()) {
@ -96,11 +99,18 @@ if (settings.cli) {
path = require('path'),
address = 'file://' + path.resolve(__dirname + '/../launcher/' + 'index.html'),
{ipcMain} = require('electron'),
{spawn} = require('child_process'),
launcher
process.on('exit',()=>{
if (global.serverProcess) global.serverProcess.kill()
})
app.on('ready',function(){
global.settings = settings
global.midilist = require('./midi').list
global.serverProcess = null
global.clientWindows = []
launcher = require('./electron-window')({address:address, shortcuts:dev, width:680, height:(40 + 200 + 20 + 24 * Object.keys(settings.options).filter(x=>settings.options[x].launcher !== false).length / 2), node:true, color:'#151a24'})
launcher.on('close', ()=>{
process.stdout.write = stdoutWrite
@ -132,15 +142,53 @@ if (settings.cli) {
ipcMain.on('start',function(e, options){
start()
if (!settings.read('noGui')) openClient()
var args = ['--no-gui']
for (var k in settings.read('argv')) {
args.push('--' + k)
var val = settings.read('argv')[k]
if (typeof val === 'object') {
args = args.concat(val)
} else if (typeof val !== 'boolean') {
args.push(val)
}
}
global.serverProcess = spawn(process.argv[0], process.argv.slice(1).concat(args), {stdio: 'pipe'/*, env: {"ELECTRON_RUN_AS_NODE":"1"}*/})
if (!settings.read('noGui')) {
global.serverProcess.stdout.once('data', (data) => {
global.clientWindows.push(openClient())
})
}
global.serverProcess.stdout.on('data', (data) => {
console.log(String(data).trim())
})
global.serverProcess.stderr.on('data', (data) => {
console.error(String(data).trim())
})
global.serverProcess.on('close', (code) => {
console.log('(INFO) Server stopped')
global.serverProcess = null
if (global.defaultClient) global.defaultClient.close()
})
})
ipcMain.on('stop',function(e, options){
if (global.serverProcess) global.serverProcess.kill()
for (var w of [...global.clientWindows]) {
if (w && !w.isDestroyed()) w.close()
}
global.clientWindows = []
})
ipcMain.on('openClient',function(e, options){
openClient()
global.clientWindows.push(openClient())
})

View file

@ -20,6 +20,14 @@ class MidiConverter {
pythonPath
}, pythonOptions))
this.py.childProcess.on('error', (e)=>{
if (e.code === 'ENOENT') {
console.error(`(ERROR, MIDI) Could not find python binary: ${e.message.replace(/spawn (.*) ENOENT/, '$1')}`)
} else {
console.error(`(ERROR, MIDI) ${e.message}`)
}
})
}
send(data) {
@ -58,7 +66,7 @@ class MidiConverter {
// console.log(err)
}
if (name == 'log') {
if (data.indexOf('ERROR') === 0) {
if (data.indexOf('ERROR') > -1) {
console.error(data)
} else {
console.log(data)
@ -76,8 +84,15 @@ class MidiConverter {
var pythonPath = settings.read('midi') ? settings.read('midi').filter(x=>x.includes('path=')).map(x=>x.split('=')[1])[0] : undefined
PythonShell.run('python/list.py', Object.assign({pythonPath}, pythonOptions), function(err, results) {
if (err) console.error(err)
PythonShell.run('python/list.py', Object.assign({pythonPath}, pythonOptions), function(e, results) {
if (e) {
if (e.code === 'ENOENT') {
console.error(`(ERROR, MIDI) Could not find python binary: ${e.message.replace(/spawn (.*) ENOENT/, '$1')}`)
} else {
console.error(`(ERROR, MIDI) ${e.message}`)
}
}
MidiConverter.parseIpc(results)
})

View file

@ -7,7 +7,6 @@ module.exports = {
},
'l':{alias:'load',type:'string',file:{name:'OSC Session (.json)', extensions: ['json', 'js']},describe:'session file to load'},
'state':{type:'string',file:{name:'OSC State (.state)', extensions: ['state']},describe:'state file to load'},
// 'b':{alias:'blank',type:'boolean',describe:'load a blank session and start the editor'},
'c':{alias:'custom-module',type:'array',file:{name:'OSC Custom module (.js)', extensions: ['js']},describe:'custom module file to load (custom options can be passed after the filename)'},
'p':{alias:'port',type:'number',describe:'http port of the server (default to 8080)',
check: (p)=>{
@ -44,19 +43,7 @@ module.exports = {
true : 'no-gui and gui-only can\'s be enabled simultaneously'
}
},
// 'g':{alias:'gui-only',type:'string',describe:'app server\'s url. If true, local port (--port) is used',
// check: (g,argv)=>{
// return (!g || !argv.n) ?
// true : 'no-gui and gui-only can\'s be enabled simultaneously'
// }
// },
't':{alias:'theme',type:'array',describe:'theme name or path (mutliple values allowed)'},
// 'e':{alias:'examples',type:'boolean',describe:'list examples instead of recent sessions',
// check: (e,argv)=>{
// return (!e || !argv.l) ?
// true : 'examples can\'t be listed if --load is set'
// }
// },
'url-options':{type:'array',describe:'url options (opt=value pairs)',
check: (u, argv)=>{
return (!u || !argv.n) ?

View file

@ -36,7 +36,7 @@ class OscServer {
try {
return fs.readFileSync(customModule[0], 'utf8')
} catch(err) {
console.log('(ERROR) Custom module not found: ' + customModule[0])
console.error('(ERROR) Custom module not found: ' + customModule[0])
return false
}
})(),

View file

@ -92,7 +92,7 @@ function httpCheck(ok){
clearTimeout(httpCheckTimeout)
httpCheckTimeout = null
if (ok) {
console.log('(INFO) App available at ' + appAddresses.join(' & '))
console.log('(INFO) Server started, app available at \n ' + appAddresses.join('\n '))
} else {
console.error('(ERROR, HTTP) Could not setup http server, maybe try a different port ?')
}

View file

@ -59,7 +59,7 @@ var baseDir = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'
defaultConfig
if (!configPath) {
console.warn('Home directory not found, settings and session history will not be saved.')
console.warn('(WARNING) Home directory not found, settings and session history will not be saved.')
}