client options

This commit is contained in:
bordun 2020-03-12 12:07:58 +01:00
parent 1750909f24
commit f58db44858
8 changed files with 38 additions and 32 deletions

View file

@ -56,6 +56,7 @@
"nosleep.js": "0.9.0",
"osc": "2.4.0",
"python-shell": "1.0.8",
"replacestream": "^4.0.3",
"sanitize-html": "1.20.1",
"scope-css": "1.2.1",
"screenfull": "5.0.1",

View file

@ -1,9 +1,9 @@
window.ARGV = {}
window.ENV = window.ENV || {}
location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi, (s,k,v)=>{
ARGV[k]=v
ENV[k]=v
})
window.LANG = ARGV.lang === 'debug' ? 'debug' : (ARGV.lang || navigator.language || '').substr(0, 2).toLowerCase()
window.LANG = ENV.lang === 'debug' ? 'debug' : (ENV.lang || navigator.language || '').substr(0, 2).toLowerCase()
window.PACKAGE = require('../../package.json')
@ -13,13 +13,13 @@ window.READ_ONLY = false
window.GRIDWIDTH = 10
window.CANVAS_FRAMERATE = parseFloat(ARGV.framerate || 60)
window.CANVAS_SCALING = parseFloat(ARGV.forceHdpi) || ( ARGV.hdpi ? window.devicePixelRatio : 1 )
window.INITIALZOOM = ARGV.zoom ? ARGV.zoom : 1
window.CANVAS_FRAMERATE = parseFloat(ENV.framerate || 60)
window.CANVAS_SCALING = parseFloat(ENV.forceHdpi) || ( ENV.hdpi ? window.devicePixelRatio : 1 )
window.INITIALZOOM = ENV.zoom ? parseFloat(ENV.zoom) : 1
window.PXSCALE = INITIALZOOM
document.documentElement.style.setProperty('font-size', PXSCALE + 'px')
window.DOUBLE_TAP_TIME = ARGV.doubletap ? ARGV.doubletap : 375
window.DOUBLE_TAP_TIME = ENV.doubletap ? parseInt(ENV.doubletap) : 375
window.JSON.parseFlex = require('json5').parse

View file

@ -1,11 +1,12 @@
require('./stacktrace')
require('./globals')
var locales = require('./locales'),
html = require('nanohtml')
document.addEventListener('DOMContentLoaded', function(event) {
require('./globals')
var locales = require('./locales'),
html = require('nanohtml')
DOM.get(document, '#osc-greeting-header')[0].appendChild(html`${PACKAGE.productName} <span class="version">v${PACKAGE.version}</span>`)
DOM.init()
@ -23,7 +24,7 @@ document.addEventListener('DOMContentLoaded', function(event) {
document.title = TITLE
ipc.send('ready', {backupId: ARGV.backupId})
ipc.send('ready', {backupId: ENV.backupId})
}, 100)

View file

@ -70,6 +70,7 @@ module.exports = function(options={}) {
if (process.platform !== 'darwin') {
// already registered in app menu on macOs
// ISSUE seems to bind ctrl+z as well (FR keyboard ?)
shortcut.register(window,'CmdOrCtrl+W',function(){
window.close()
})

View file

@ -67,7 +67,6 @@ function openClient() {
var app = require('./electron-app')
var address = settings.read('appAddresses')[0]
address += settings.read('urlOptions')
var launch = ()=>{
var win = require('./electron-window')({address:address, shortcuts:true, fullscreen: settings.read('fullScreen')})

View file

@ -37,28 +37,18 @@ module.exports = {
},
'm':{alias:'midi',type:'array',describe:'midi router settings'},
'd':{alias:'debug',type:'boolean',describe:'log received osc messages in the console'},
'n':{alias:'no-gui',type:'boolean',describe:'disable default gui',
check: (n,argv)=>{
return (!n || !argv.g) ?
true : 'no-gui and gui-only can\'s be enabled simultaneously'
}
},
'n':{alias:'no-gui',type:'boolean',describe:'disable default gui'},
't':{alias:'theme',type:'array',describe:'theme name or path (mutliple values allowed)'},
'url-options':{type:'array',describe:'url options (opt=value pairs)',
check: (u, argv)=>{
return (!u || !argv.n) ?
true : 'url options can\'t be passed in no-gui mode'
'client-options':{type:'array',describe:'client options (opt=value pairs)',
check: (o)=>{
return o.some(item=>!item.match(/^[^=]*=[^=]*$/)) ?
'Options must be key=value pairs' : true
}
},
'disable-vsync':{type:'boolean',describe:'disable gui\'s vertical synchronization', restart: true},
// 'disable-gpu':{type:'boolean',describe:'disable hardware acceleration', restart: true},
'force-gpu':{type:'boolean',describe:'ignore chrome\'s gpu blacklist', restart: true},
'read-only':{type:'boolean',describe:'disable session editing and session history changes',
check: (r, argv)=>{
return (!r || !argv.b) ?
true : 'blank session can\'t be started in read-only mode'
}
},
'read-only':{type:'boolean',describe:'disable session editing and session history changes'},
'remote-saving':{type:'string',describe:'disable remote session saving for hosts that don\'t match the regular expresion',
check: (r, argv)=>{
var msg = true

View file

@ -3,6 +3,7 @@ var urlparser = require('url'),
fs = require('fs'),
send = require('send'),
http = require('http'),
replaceStream = require('replacestream'),
server = http.createServer(httpRoute),
Ipc = require('./ipc/server'),
ipc = new Ipc(server),
@ -19,14 +20,19 @@ function httpRoute(req, res) {
res.sendFile = (path)=>{
var fpath = path.split('?')[0]
if (!fs.existsSync(fpath)) throw `File "${fpath}" not found.`
send(req, fpath).pipe(res)
return send(req, fpath).pipe(res)
}
var url = req.url
if (url === '/' || url.indexOf('/?') === 0) {
res.sendFile(path.resolve(__dirname + '/../client/index.html'))
fs.createReadStream(path.resolve(__dirname + '/../client/index.html'))
.pipe(replaceStream('</body>', `<script>window.ENV=${JSON.stringify(settings.read('clientOptions'))}</script></body>`))
.pipe(res);
// res.sendFile(path.resolve(__dirname + '/../client/index.html'))
} else {

View file

@ -81,7 +81,15 @@ var makeDefaultConfig = function(argv){
fullScreen: argv['fullscreen'] || false,
noGui: argv['no-gui'] || false,
guiOnly: typeof argv['gui-only'] == 'string' ? argv['gui-only'].length ? argv['gui-only'] : true : false,
urlOptions: argv['url-options'] ? '?' + argv['url-options'].join('&') : '',
clientOptions: argv['client-options'] ? (function(){
var opts = {}
for (var o of argv['client-options']) {
if (!o.includes('=')) continue
var [k, v] = o.split('=')
opts[k] = v
}
return opts
})() : false,
noVsync: argv['disable-vsync'] || false,
noGpu: argv['disable-gpu'] || false,
forceGpu: argv['force-gpu'] || false,