chore: Improve build

This commit is contained in:
Felix Rieseberg 2019-08-24 16:58:21 +02:00
parent 7653d7294c
commit 186a2a8ba9
10 changed files with 77 additions and 57 deletions

View file

@ -17,6 +17,18 @@ module.exports = {
osxSign: {
identity: 'Developer ID Application: Felix Rieseberg (LT94ZKYDCJ)'
},
ignore: [
/\/assets(\/?)/,
/\/docs(\/?)/,
/\/tools(\/?)/,
/\/src\/.*\.ts/,
/package-lock\.json/,
/README\.md/,
/tsconfig\.json/,
/Dockerfile/,
/issue_template\.md/,
/HELP\.md/,
]
},
makers: [
{

View file

@ -22,6 +22,7 @@ export const IPC_COMMANDS = {
MACHINE_STOP: 'MACHINE_STOP',
MACHINE_RESET: 'MACHINE_RESET',
MACHINE_ALT_F4: 'MACHINE_ALT_F4',
MACHINE_ESC: 'MACHINE_ESC',
MACHINE_ALT_ENTER: 'MACHINE_ALT_ENTER',
MACHINE_CTRL_ALT_DEL: 'MACHINE_CTRL_ALT_DEL',
// Machine events

View file

@ -2,6 +2,7 @@
@import "./emulator.less";
@import "./info.less";
@import "./settings.less";
@import "./start.less";
/* GENERAL RESETS */
@ -51,7 +52,6 @@ section {
.nav-link > img,
.btn > img {
height: 24px;
margin-top: -3px;
margin-right: 4px;
}
@ -66,8 +66,7 @@ section {
nav .nav-link,
nav .nav-logo {
height: 33px;
line-height: 1.5;
height: 37px;
display: flex;
}
@ -85,7 +84,7 @@ section {
.btn {
height: 40px;
padding-top: 6px;
padding-top: 3px;
}
.btn:focus {

9
src/less/start.less Normal file
View file

@ -0,0 +1,9 @@
#section-start {
display: flex;
flex-direction: column;
> small {
margin-top: 25px;
font-size: .8rem;
}
}

View file

@ -140,6 +140,11 @@ async function createMenu({ isRunning } = { isRunning: false }) {
click: () => send(IPC_COMMANDS.MACHINE_ALT_ENTER),
enabled: isRunning
},
{
label: "Send Esc",
click: () => send(IPC_COMMANDS.MACHINE_ESC),
enabled: isRunning
},
{
type: "separator"
},

View file

@ -11,7 +11,9 @@ export function getOrCreateWindow(): BrowserWindow {
height: 768,
useContentSize: true,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
sandbox: false,
webviewTag: false
}
});

View file

@ -7,18 +7,12 @@ export interface CardStartProps {
export class CardStart extends React.Component<CardStartProps, {}> {
public render() {
return (
<section id="section-start" className="visible">
<div
className="btn btn-start"
id="win95"
onClick={this.props.startEmulator}
>
<section id="section-start">
<button className="btn" id="win95" onClick={this.props.startEmulator}>
<img src="../../static/run.png" />
<span>Start Windows 95</span>
<br />
<br />
<small>Hit ESC to lock or unlock your mouse</small>
</div>
</button>
<small>Hit ESC to lock or unlock your mouse</small>
</section>
);
}

View file

@ -69,6 +69,8 @@ export class Emulator extends React.Component<{}, EmulatorState> {
} else {
this.lockMouse();
}
evt.stopPropagation();
}
};
@ -117,44 +119,31 @@ export class Emulator extends React.Component<{}, EmulatorState> {
*/
public setupIpcListeners() {
ipcRenderer.on(IPC_COMMANDS.MACHINE_CTRL_ALT_DEL, () => {
if (this.state.emulator && this.state.isRunning) {
this.state.emulator.keyboard_send_scancodes([
0x1d, // ctrl
0x38, // alt
0x53, // delete
// break codes
0x1d | 0x80,
0x38 | 0x80,
0x53 | 0x80
]);
}
this.sendKeys([
0x1d, // ctrl
0x38, // alt
0x53 // delete
]);
});
ipcRenderer.on(IPC_COMMANDS.MACHINE_ALT_F4, () => {
if (this.state.emulator && this.state.isRunning) {
this.state.emulator.keyboard_send_scancodes([
0x38, // alt
0x3e, // f4
// break codes
0x38 | 0x80,
0x3e | 0x80
]);
}
this.sendKeys([
0x38, // alt
0x3e // f4
]);
});
ipcRenderer.on(IPC_COMMANDS.MACHINE_ALT_ENTER, () => {
if (this.state.emulator && this.state.isRunning) {
this.state.emulator.keyboard_send_scancodes([
0x38, // alt
0, // enter
this.sendKeys([
0x38, // alt
0 // enter
]);
});
// break codes
0x38 | 0x80,
0 | 0x80
]);
}
ipcRenderer.on(IPC_COMMANDS.MACHINE_ESC, () => {
this.sendKeys([
0x18 // alt
]);
});
ipcRenderer.on(IPC_COMMANDS.MACHINE_STOP, this.stopEmulator);
@ -467,4 +456,23 @@ export class Emulator extends React.Component<{}, EmulatorState> {
this.setState({ scale: target });
}
}
/**
* Send keys to the emulator (including the key-up),
* if it's running
*
* @param {Array<number>} codes
*/
private sendKeys(codes: Array<number>) {
if (this.state.emulator && this.state.isRunning) {
const scancodes = codes;
// Push break codes (key-up)
for (const scancode of scancodes) {
scancodes.push(scancode | 0x80);
}
this.state.emulator.keyboard_send_scancodes(scancodes);
}
}
}

View file

@ -12,15 +12,5 @@
<body class="paused windows95">
<div id="app"></div>
<script src="../src/renderer/app.tsx"></script>
<link rel="prefetch" href="../static/boot-fresh.png" />
<link rel="prefetch" href="../static/drive.png" />
<link rel="prefetch" href="../static/floppy.png" />
<link rel="prefetch" href="../static/reset-state.png" />
<link rel="prefetch" href="../static/reset.png" />
<link rel="prefetch" href="../static/run.png" />
<link rel="prefetch" href="../static/select-floppy.png" />
<link rel="prefetch" href="../static/settings.png" />
<link rel="prefetch" href="../static/show-disk-image.png" />
<link rel="prefetch" href="../static/start.png" />
</body>
</html>

View file

@ -25,7 +25,7 @@ async function compileParcel (options = {}) {
// key: './ssl/k.key' // path to custom key
// },
logLevel: 3, // 3 = log everything, 2 = log warnings & errors, 1 = log errors
hmr: true, // Enable or disable HMR while watching
hmr: false, // Enable or disable HMR while watching
hmrPort: 0, // The port the HMR socket runs on, defaults to a random free port (0 in node.js resolves to a random free port)
sourceMaps: true, // Enable or disable sourcemaps, defaults to enabled (minified builds currently always create sourcemaps)
hmrHostname: '', // A hostname for hot module reload, default to ''