2019-03-22 01:18:13 +00:00
|
|
|
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const path = require("path");
|
|
|
|
const spawn = require("spawn");
|
2019-06-09 01:43:14 +00:00
|
|
|
const delay_1 = require("delay");
|
2019-03-22 01:18:13 +00:00
|
|
|
const { BrowserWindow } = require('electron');
|
|
|
|
let wv;
|
|
|
|
let cp;
|
|
|
|
let system = {};
|
|
|
|
let TMPDIR;
|
|
|
|
class WebView {
|
|
|
|
constructor() {
|
2019-03-22 02:54:49 +00:00
|
|
|
this.opened = false;
|
2019-03-22 02:33:30 +00:00
|
|
|
this.showing = false;
|
|
|
|
this.digitalWindow = new BrowserWindow({
|
2019-03-22 01:18:13 +00:00
|
|
|
webPreferences: {
|
|
|
|
nodeIntegration: true,
|
|
|
|
allowRunningInsecureContent: false,
|
|
|
|
'unsafe-eval': false
|
|
|
|
},
|
|
|
|
width: 800,
|
|
|
|
height: 600,
|
|
|
|
minWidth: 800,
|
|
|
|
minHeight: 600 //,
|
|
|
|
//icon: path.join(__dirname, '../../assets/icons/icon.png')
|
|
|
|
});
|
2019-03-22 02:33:30 +00:00
|
|
|
this.digitalWindow.loadURL('file://' + __dirname + '../../../display.html');
|
2019-03-22 01:18:13 +00:00
|
|
|
if (process.argv.indexOf('-d') !== -1 || process.argv.indexOf('--dev') !== -1) {
|
2019-03-22 02:33:30 +00:00
|
|
|
this.digitalWindow.webContents.openDevTools();
|
2019-03-22 01:18:13 +00:00
|
|
|
}
|
2019-03-22 02:33:30 +00:00
|
|
|
this.digitalWindow.on('closed', () => {
|
|
|
|
this.digitalWindow = null;
|
2019-03-22 01:18:13 +00:00
|
|
|
});
|
2019-03-22 02:33:30 +00:00
|
|
|
this.digitalWindow.hide();
|
|
|
|
}
|
|
|
|
async open() {
|
|
|
|
this.digitalWindow.show();
|
|
|
|
this.showing = true;
|
|
|
|
this.opened = true;
|
|
|
|
}
|
|
|
|
async start() {
|
|
|
|
await this.open();
|
|
|
|
await this.fullScreen();
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(300);
|
2019-03-22 01:18:13 +00:00
|
|
|
}
|
|
|
|
async fullScreen() {
|
2019-03-22 02:33:30 +00:00
|
|
|
//this.digitalWindow.setFullScreen(true);
|
|
|
|
await this.digitalWindow.maximize();
|
|
|
|
}
|
|
|
|
setImage(src) {
|
|
|
|
try {
|
|
|
|
this.digitalWindow.webContents.send('display', { src });
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
}
|
2019-03-22 01:18:13 +00:00
|
|
|
}
|
2019-03-22 02:33:30 +00:00
|
|
|
setMeter() {
|
|
|
|
this.digitalWindow.webContents.send('display', { meter: true });
|
2019-03-22 01:18:13 +00:00
|
|
|
}
|
2019-03-22 02:33:30 +00:00
|
|
|
setGrid() {
|
|
|
|
this.digitalWindow.webContents.send('display', { grid: true });
|
2019-03-22 01:18:13 +00:00
|
|
|
}
|
2019-03-22 02:33:30 +00:00
|
|
|
hide() {
|
|
|
|
if (this.digitalWindow) {
|
|
|
|
this.digitalWindow.hide();
|
|
|
|
}
|
|
|
|
this.showing = false;
|
2019-03-22 01:18:13 +00:00
|
|
|
}
|
2019-03-22 02:33:30 +00:00
|
|
|
close() {
|
|
|
|
if (this.digitalWindow) {
|
|
|
|
this.digitalWindow.close();
|
|
|
|
this.digitalWindow = null;
|
2019-03-22 01:18:13 +00:00
|
|
|
}
|
2019-03-22 02:33:30 +00:00
|
|
|
this.showing = false;
|
|
|
|
this.opened = false;
|
2019-03-22 01:18:13 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
async move() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function padded_frame(i) {
|
|
|
|
let len = (i + '').length;
|
|
|
|
let str = i + '';
|
|
|
|
for (let x = 0; x < 5 - len; x++) {
|
|
|
|
str = '0' + str;
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
async function display_eog(src) {
|
|
|
|
//timeout 3 eog --fullscreen ${src}
|
|
|
|
cp = spawn('eog', ['--fullscreen', src]);
|
2019-06-09 01:43:14 +00:00
|
|
|
await delay_1.delay(200);
|
2019-03-22 01:18:13 +00:00
|
|
|
}
|
2019-03-22 02:33:30 +00:00
|
|
|
function display_wv(src) {
|
|
|
|
wv.setImage(src);
|
|
|
|
}
|
|
|
|
async function hide() {
|
2019-03-22 01:18:13 +00:00
|
|
|
if (system.platform !== 'nix') {
|
2019-03-22 02:33:30 +00:00
|
|
|
//wv.hide();
|
2019-03-22 01:18:13 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (cp)
|
|
|
|
cp.kill();
|
|
|
|
}
|
|
|
|
}
|
2019-03-22 02:33:30 +00:00
|
|
|
async function show(frame) {
|
2019-03-22 01:18:13 +00:00
|
|
|
let padded = padded_frame(frame);
|
|
|
|
let ext = 'tif';
|
|
|
|
let tmppath;
|
|
|
|
if (system.platform !== 'nix') {
|
|
|
|
ext = 'png';
|
|
|
|
}
|
|
|
|
tmppath = path.join(TMPDIR, `export-${padded}.${ext}`);
|
|
|
|
if (system.platform !== 'nix') {
|
2019-03-22 02:33:30 +00:00
|
|
|
await open();
|
2019-03-22 01:18:13 +00:00
|
|
|
display_wv(tmppath);
|
|
|
|
}
|
|
|
|
else {
|
2019-03-22 02:33:30 +00:00
|
|
|
await display_eog(tmppath);
|
2019-03-22 01:18:13 +00:00
|
|
|
}
|
|
|
|
}
|
2019-03-22 02:33:30 +00:00
|
|
|
async function open() {
|
2019-03-22 01:18:13 +00:00
|
|
|
if (system.platform !== 'nix') {
|
2019-03-22 02:33:30 +00:00
|
|
|
if (!wv || !wv.opened) {
|
|
|
|
wv = new WebView();
|
|
|
|
await wv.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|
|
|
|
async function close() {
|
|
|
|
if (system.platform !== 'nix') {
|
|
|
|
wv.close();
|
2019-03-22 01:18:13 +00:00
|
|
|
}
|
|
|
|
else {
|
2019-03-22 02:33:30 +00:00
|
|
|
if (cp)
|
|
|
|
cp.kill();
|
2019-03-22 01:18:13 +00:00
|
|
|
}
|
2019-03-22 02:33:30 +00:00
|
|
|
}
|
|
|
|
module.exports = function (sys) {
|
|
|
|
system = sys;
|
|
|
|
TMPDIR = path.join(system.tmp, 'mcopy_digital');
|
2019-03-22 01:18:13 +00:00
|
|
|
return {
|
2019-03-22 02:33:30 +00:00
|
|
|
open,
|
|
|
|
show,
|
|
|
|
hide,
|
|
|
|
close
|
2019-03-22 01:18:13 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
//# sourceMappingURL=index.js.map
|