works on windows i guess?!
parent
730ba1af3f
commit
076dcb9aaa
|
|
@ -10,9 +10,11 @@
|
|||
"@nodegui/nodegui": "^0.34.0",
|
||||
"@rollup/plugin-alias": "^3.1.4",
|
||||
"@rollup/plugin-babel": "^5.3.0",
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"@types/blessed": "^0.1.17",
|
||||
"@types/bonjour": "^3.5.8",
|
||||
"@types/chai": "^4.2.19",
|
||||
"@types/chokidar": "^2.1.3",
|
||||
"@types/faker": "^5.5.6",
|
||||
"@types/fs-extra": "^9.0.11",
|
||||
"@types/mocha": "^8.2.2",
|
||||
|
|
@ -50,13 +52,13 @@
|
|||
},
|
||||
"scripts": {
|
||||
"compile": "yarn tsc & yarn rollup",
|
||||
"start": "yarn qode bin/app.bundle.js",
|
||||
"dev": "yarn x bin/ipc-tower.bundle.js",
|
||||
"start": "yarn qode bin/app.bundle.cjs",
|
||||
"dev": "yarn x bin/ipc-tower.bundle.cjs",
|
||||
"prod": "git fetch && git pull && yarn && tsc && yarn start",
|
||||
"test": "mocha",
|
||||
"lint": "eslint src/**/*.ts",
|
||||
"web": "web-dev-server --open index.html --node-resolve --watch",
|
||||
"profile": "yarn qode --inspect-brk bin/app.bundle.js",
|
||||
"profile": "yarn qode --inspect-brk bin/app.bundle.cjs",
|
||||
"qode": "qode",
|
||||
"x": "node",
|
||||
"tsc": "tsc",
|
||||
|
|
|
|||
|
|
@ -17,9 +17,20 @@ const shared = {
|
|||
alias({
|
||||
entries: [
|
||||
...aliases,
|
||||
{ find: 'frigid', replacement: resolve(__dirname, 'node_modules/frigid/out/index.js') }
|
||||
{
|
||||
find: 'frigid',
|
||||
replacement: resolve(__dirname, 'node_modules/frigid/out/index.js')
|
||||
},
|
||||
{
|
||||
find: 'node-ipc',
|
||||
replacement: resolve(__dirname, 'node_modules/node-ipc/node-ipc.js')
|
||||
},
|
||||
{
|
||||
find: 'event-pubsub',
|
||||
replacement: resolve(__dirname, 'node_modules/event-pubsub/index.js')
|
||||
},
|
||||
]
|
||||
})
|
||||
}),
|
||||
],
|
||||
watch: {
|
||||
include: 'out/**/*'
|
||||
|
|
@ -31,16 +42,16 @@ export default [
|
|||
...shared,
|
||||
input: './out/src/index.js',
|
||||
output: {
|
||||
file: 'bin/app.bundle.js',
|
||||
format: 'es'
|
||||
file: 'bin/app.bundle.cjs',
|
||||
format: 'cjs'
|
||||
}
|
||||
},
|
||||
{
|
||||
...shared,
|
||||
input: './out/src/hot-index.js',
|
||||
output: {
|
||||
file: 'bin/ipc-tower.bundle.js',
|
||||
format: 'es'
|
||||
file: 'bin/ipc-tower.bundle.cjs',
|
||||
format: 'cjs'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Frigid, Serializable } from 'frigid';
|
||||
import { Frigid } from 'frigid';
|
||||
import { Pawn } from './Pawn.js';
|
||||
import { TaskList } from './TaskList.js';
|
||||
import { Inventory } from './Inventory.js';
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ let connected = false;
|
|||
class ProcessManagerClass extends EventEmitter {
|
||||
quit() {
|
||||
if (connected) {
|
||||
console.log('client sending quit event')
|
||||
ipc.of[name].emit(IPC_QUIT_EVENT);
|
||||
process.exit(0);
|
||||
} else {
|
||||
process.exit(0);
|
||||
}
|
||||
|
|
@ -21,9 +23,12 @@ class ProcessManagerClass extends EventEmitter {
|
|||
|
||||
restart() {
|
||||
if (connected) {
|
||||
console.log('client emitting ipc restart')
|
||||
ipc.of[name].emit(IPC_RESTART_EVENT);
|
||||
process.exit(0);
|
||||
} else {
|
||||
process.exit(1);
|
||||
console.log('eh?! not connected to tower... closing')
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -40,4 +45,6 @@ ipc.connectTo(name, () => {
|
|||
ipc.of[name].on(IPC_REQUEST_RESTART, () => {
|
||||
ProcessManager.emit('reload');
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
/////////////
|
||||
|
|
@ -7,13 +7,14 @@ import {
|
|||
} from './Constants.js';
|
||||
import { spawn, ChildProcess } from 'child_process';
|
||||
import watch from 'watch';
|
||||
import chokidar from 'chokidar';
|
||||
import chalk from 'chalk';
|
||||
|
||||
ipc.config.silent = true;
|
||||
// ipc.config.silent = true;
|
||||
|
||||
const exec = 'yarn' + (process.platform === "win32" ? '.cmd' : '');
|
||||
const exec = 'qode' + (process.platform === "win32" ? '.cmd' : '');
|
||||
const args = [
|
||||
'start'
|
||||
'bin/app.bundle.cjs'
|
||||
]
|
||||
|
||||
ipc.serve(IPC_PATH, () => {
|
||||
|
|
@ -25,15 +26,14 @@ ipc.serve(IPC_PATH, () => {
|
|||
ipc.server.on(IPC_RESTART_EVENT, restart)
|
||||
});
|
||||
|
||||
console.log('started ipc tower server!')
|
||||
ipc.server.start();
|
||||
|
||||
let proc: ChildProcess = null;
|
||||
|
||||
function startProcess() {
|
||||
proc = spawn(exec, args, {
|
||||
stdio: 'inherit',
|
||||
cwd: process.cwd(),
|
||||
env: process.env
|
||||
stdio: 'inherit'
|
||||
});
|
||||
console.log(`[${proc.pid}] ${chalk.grey(`${exec} ${args.join(' ')}`)}`);
|
||||
proc.on('exit', () => {
|
||||
|
|
@ -46,23 +46,22 @@ async function killProcess() {
|
|||
if(proc) {
|
||||
console.log('killing process...');
|
||||
const killedPromise = new Promise((res) => {
|
||||
proc.on('exit', () => {
|
||||
res(void 0);
|
||||
proc.on('exit', (code, sig) => {
|
||||
res(code || sig);
|
||||
})
|
||||
})
|
||||
proc.kill();
|
||||
await killedPromise;
|
||||
console.log('process died with code', await killedPromise);
|
||||
proc = null;
|
||||
console.log()
|
||||
}
|
||||
}
|
||||
|
||||
async function restart() {
|
||||
if(proc) {
|
||||
await killProcess();
|
||||
startProcess();
|
||||
} else {
|
||||
startProcess();
|
||||
}
|
||||
console.log('received restart event');
|
||||
await killProcess();
|
||||
console.log('')
|
||||
startProcess();
|
||||
}
|
||||
|
||||
startProcess();
|
||||
|
|
@ -70,14 +69,20 @@ startProcess();
|
|||
let restartTimer: NodeJS.Timeout = null;
|
||||
|
||||
function fileChange() {
|
||||
console.log('changes detected');
|
||||
// appendFileSync('log.log', evt + ' ' + path + '\n');
|
||||
// console.log(cluster.isMaster, evt, path);
|
||||
if(restartTimer) clearTimeout(restartTimer)
|
||||
restartTimer = setTimeout(() => {
|
||||
ipc.server.broadcast(IPC_REQUEST_RESTART);
|
||||
console.log('changes detected');
|
||||
if(proc) {
|
||||
ipc.server.broadcast(IPC_REQUEST_RESTART);
|
||||
} else {
|
||||
startProcess();
|
||||
}
|
||||
restartTimer = null;
|
||||
}, 1000);
|
||||
}, 100);
|
||||
}
|
||||
// chokidar.watch('./out').on('all', fileChange);
|
||||
watch.watchTree('./bin', fileChange);
|
||||
chokidar.watch('./out').on('all', fileChange);
|
||||
// watch.watchTree('./bin', fileChange);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {
|
|||
setView,
|
||||
start
|
||||
} from '@ui';
|
||||
// @ts-ignore
|
||||
import ansi from 'sisteransi';
|
||||
|
||||
// HACK static extension loading
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
import { QGridLayout, QLabel, QMainWindow, QPushButton, QWidget } from "@nodegui/nodegui";
|
||||
import { FocusReason, QGridLayout, QLabel, QMainWindow, QPushButton, QWidget } from "@nodegui/nodegui";
|
||||
import { ProcessManager } from "../ProcessManager";
|
||||
|
||||
export class RequestReloadPopup {
|
||||
static exists = false;
|
||||
|
||||
static show() {
|
||||
if(this.exists) return;
|
||||
this.exists = true;
|
||||
const window = new QMainWindow();
|
||||
window.setFixedSize(200, 100);
|
||||
const root = new QWidget();
|
||||
|
|
@ -16,6 +20,7 @@ export class RequestReloadPopup {
|
|||
reloadButton.setText('Reload');
|
||||
layout.addWidget(reloadButton, 4, 2, 1, 1);
|
||||
window.show();
|
||||
window.setWindowTitle('Reload?');
|
||||
|
||||
reloadButton.addEventListener('clicked', () => {
|
||||
ProcessManager.restart();
|
||||
|
|
@ -23,4 +28,4 @@ export class RequestReloadPopup {
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
//////
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { QGridLayout, QMainWindow, QWidget } from "@nodegui/nodegui";
|
||||
import { QGridLayout, QMainWindow, QWidget, WindowState } from "@nodegui/nodegui";
|
||||
import { QEvent } from "@nodegui/nodegui/dist/lib/QtGui/QEvent/QEvent";
|
||||
import { win } from "@ui";
|
||||
|
||||
export abstract class View {
|
||||
|
|
|
|||
|
|
@ -12,40 +12,40 @@ export { Popup } from './Popup.js';
|
|||
export const win = new QMainWindow();
|
||||
win.setFixedSize(800, 600);
|
||||
win.setWindowTitle(APPLICATION_NAME);
|
||||
win.setStyleSheet(`
|
||||
#root {
|
||||
background-color: black;
|
||||
height: '100%';
|
||||
}
|
||||
QPushButton {
|
||||
background: #333333;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background: cyan;
|
||||
color: black;
|
||||
}
|
||||
* {
|
||||
font-family: 'MxPlus IBM VGA 8x16';
|
||||
font-size: 16px;
|
||||
}
|
||||
QTabWidget {
|
||||
border: 1px solid white;
|
||||
}
|
||||
QTabWidget::pane {
|
||||
background: black;
|
||||
border: none;
|
||||
border-radius: 0px;
|
||||
}
|
||||
QTabBar::tab {
|
||||
background: black;
|
||||
color: cyan;
|
||||
padding: 4px 12px;
|
||||
}
|
||||
QTabBar::tab:selected {
|
||||
background: cyan;
|
||||
color: black;
|
||||
}
|
||||
`);
|
||||
// win.setStyleSheet(`
|
||||
// #root {
|
||||
// background-color: black;
|
||||
// height: '100%';
|
||||
// }
|
||||
// QPushButton {
|
||||
// background: #333333;
|
||||
// }
|
||||
// QPushButton:pressed {
|
||||
// background: cyan;
|
||||
// color: black;
|
||||
// }
|
||||
// * {
|
||||
// font-family: 'MxPlus IBM VGA 8x16';
|
||||
// font-size: 16px;
|
||||
// }
|
||||
// QTabWidget {
|
||||
// border: 1px solid white;
|
||||
// }
|
||||
// QTabWidget::pane {
|
||||
// background: black;
|
||||
// border: none;
|
||||
// border-radius: 0px;
|
||||
// }
|
||||
// QTabBar::tab {
|
||||
// background: black;
|
||||
// color: cyan;
|
||||
// padding: 4px 12px;
|
||||
// }
|
||||
// QTabBar::tab:selected {
|
||||
// background: cyan;
|
||||
// color: black;
|
||||
// }
|
||||
// `);
|
||||
win.show();
|
||||
(global as any).win = win;
|
||||
win.addEventListener(WidgetEventTypes.Paint, _ => _);
|
||||
|
|
@ -77,13 +77,14 @@ export function update() {
|
|||
}
|
||||
|
||||
export function isStarted() {
|
||||
return true;
|
||||
return win.isVisible();
|
||||
}
|
||||
|
||||
ProcessManager.on('reload', () => {
|
||||
RequestReloadPopup.show();
|
||||
//
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
// HACK this is bullshit, :)
|
||||
|
|
|
|||
Loading…
Reference in New Issue