chore: Updated prettier run

This commit is contained in:
Felix Rieseberg 2020-08-02 13:11:20 -07:00
parent 045b83f843
commit 92717c8047
12 changed files with 130 additions and 124 deletions

1
.gitattributes vendored Normal file
View file

@ -0,0 +1 @@
text eol=lf

View file

@ -1,8 +1,8 @@
import { session } from 'electron'; import { session } from "electron";
export async function clearCaches() { export async function clearCaches() {
await clearCache() await clearCache();
await clearStorageData() await clearStorageData();
} }
export async function clearCache() { export async function clearCache() {
@ -17,9 +17,21 @@ export function clearStorageData() {
return resolve(); return resolve();
} }
session.defaultSession.clearStorageData({ session.defaultSession.clearStorageData(
storages: [ 'appcache', 'cookies', 'filesystem', 'indexdb', 'localstorage', 'shadercache', 'websql', 'serviceworkers' ], {
quotas: [ 'temporary', 'persistent', 'syncable' ] storages: [
}, resolve) "appcache",
}) "cookies",
"filesystem",
"indexdb",
"localstorage",
"shadercache",
"websql",
"serviceworkers",
],
quotas: ["temporary", "persistent", "syncable"],
},
resolve
);
});
} }

View file

@ -1,31 +1,31 @@
import { remote, app } from 'electron'; import { remote, app } from "electron";
import * as path from 'path'; import * as path from "path";
const _app = app || remote.app const _app = app || remote.app;
export const CONSTANTS = { export const CONSTANTS = {
IMAGE_PATH: path.join(__dirname, '../../images/windows95.img'), IMAGE_PATH: path.join(__dirname, "../../images/windows95.img"),
IMAGE_DEFAULT_SIZE: 1073741824, // 1GB IMAGE_DEFAULT_SIZE: 1073741824, // 1GB
DEFAULT_STATE_PATH: path.join(__dirname, '../../images/default-state.bin'), DEFAULT_STATE_PATH: path.join(__dirname, "../../images/default-state.bin"),
STATE_PATH: path.join(_app.getPath('userData'), 'state-v2.bin') STATE_PATH: path.join(_app.getPath("userData"), "state-v2.bin"),
} };
export const IPC_COMMANDS = { export const IPC_COMMANDS = {
TOGGLE_INFO: 'TOGGLE_INFO', TOGGLE_INFO: "TOGGLE_INFO",
SHOW_DISK_IMAGE: 'SHOW_DISK_IMAGE', SHOW_DISK_IMAGE: "SHOW_DISK_IMAGE",
ZOOM_IN: 'ZOOM_IN', ZOOM_IN: "ZOOM_IN",
ZOOM_OUT: 'ZOOM_OUT', ZOOM_OUT: "ZOOM_OUT",
ZOOM_RESET: 'ZOOM_RESET', ZOOM_RESET: "ZOOM_RESET",
// Machine instructions // Machine instructions
MACHINE_START: 'MACHINE_START', MACHINE_START: "MACHINE_START",
MACHINE_RESTART: 'MACHINE_RESTART', MACHINE_RESTART: "MACHINE_RESTART",
MACHINE_STOP: 'MACHINE_STOP', MACHINE_STOP: "MACHINE_STOP",
MACHINE_RESET: 'MACHINE_RESET', MACHINE_RESET: "MACHINE_RESET",
MACHINE_ALT_F4: 'MACHINE_ALT_F4', MACHINE_ALT_F4: "MACHINE_ALT_F4",
MACHINE_ESC: 'MACHINE_ESC', MACHINE_ESC: "MACHINE_ESC",
MACHINE_ALT_ENTER: 'MACHINE_ALT_ENTER', MACHINE_ALT_ENTER: "MACHINE_ALT_ENTER",
MACHINE_CTRL_ALT_DEL: 'MACHINE_CTRL_ALT_DEL', MACHINE_CTRL_ALT_DEL: "MACHINE_CTRL_ALT_DEL",
// Machine events // Machine events
MACHINE_STARTED: 'MACHINE_STARTED', MACHINE_STARTED: "MACHINE_STARTED",
MACHINE_STOPPED: 'MACHINE_STOPPED' MACHINE_STOPPED: "MACHINE_STOPPED",
} };

View file

@ -12,7 +12,7 @@ export function setupAboutPanel(): void {
applicationName: "windows95", applicationName: "windows95",
applicationVersion: app.getVersion(), applicationVersion: app.getVersion(),
version: process.versions.electron, version: process.versions.electron,
copyright: "Felix Rieseberg" copyright: "Felix Rieseberg",
}; };
switch (process.platform) { switch (process.platform) {

View file

@ -1,15 +1,14 @@
import { app, shell, Menu, BrowserWindow, ipcMain, webFrame } from "electron"; import { app, shell, Menu, BrowserWindow, ipcMain } from "electron";
import { clearCaches } from "../cache"; import { clearCaches } from "../cache";
import { IPC_COMMANDS } from "../constants"; import { IPC_COMMANDS } from "../constants";
import { isDevMode } from "../utils/devmode"; import { isDevMode } from "../utils/devmode";
import { getOrCreateWindow } from "./windows";
const LINKS = { const LINKS = {
homepage: "https://www.twitter.com/felixrieseberg", homepage: "https://www.twitter.com/felixrieseberg",
repo: "https://github.com/felixrieseberg/windows95", repo: "https://github.com/felixrieseberg/windows95",
credits: "https://github.com/felixrieseberg/windows95/blob/master/CREDITS.md", credits: "https://github.com/felixrieseberg/windows95/blob/master/CREDITS.md",
help: "https://github.com/felixrieseberg/windows95/blob/master/HELP.md" help: "https://github.com/felixrieseberg/windows95/blob/master/HELP.md",
}; };
export async function setupMenu() { export async function setupMenu() {
@ -41,52 +40,52 @@ async function createMenu({ isRunning } = { isRunning: false }) {
submenu: [ submenu: [
{ {
label: "Toggle Full Screen", label: "Toggle Full Screen",
accelerator: (function() { accelerator: (function () {
if (process.platform === "darwin") { if (process.platform === "darwin") {
return "Ctrl+Command+F"; return "Ctrl+Command+F";
} else { } else {
return "F11"; return "F11";
} }
})(), })(),
click: function(_item, focusedWindow) { click: function (_item, focusedWindow) {
if (focusedWindow) { if (focusedWindow) {
focusedWindow.setFullScreen(!focusedWindow.isFullScreen()); focusedWindow.setFullScreen(!focusedWindow.isFullScreen());
} }
} },
}, },
{ {
label: "Toggle Developer Tools", label: "Toggle Developer Tools",
accelerator: (function() { accelerator: (function () {
if (process.platform === "darwin") { if (process.platform === "darwin") {
return "Alt+Command+I"; return "Alt+Command+I";
} else { } else {
return "Ctrl+Shift+I"; return "Ctrl+Shift+I";
} }
})(), })(),
click: function(_item, focusedWindow) { click: function (_item, focusedWindow) {
if (focusedWindow) { if (focusedWindow) {
focusedWindow.webContents.toggleDevTools(); focusedWindow.webContents.toggleDevTools();
} }
} },
}, },
{ {
type: "separator" type: "separator",
}, },
{ {
label: "Toggle Emulator Info", label: "Toggle Emulator Info",
click: () => send(IPC_COMMANDS.TOGGLE_INFO) click: () => send(IPC_COMMANDS.TOGGLE_INFO),
}, },
{ {
type: "separator" type: "separator",
}, },
{ {
role: "reload" role: "reload",
} },
] ],
}, },
{ {
role: "editMenu", role: "editMenu",
visible: isDevMode() visible: isDevMode(),
}, },
{ {
label: "Window", label: "Window",
@ -95,32 +94,32 @@ async function createMenu({ isRunning } = { isRunning: false }) {
{ {
label: "Minimize", label: "Minimize",
accelerator: "CmdOrCtrl+M", accelerator: "CmdOrCtrl+M",
role: "minimize" role: "minimize",
}, },
{ {
label: "Close", label: "Close",
accelerator: "CmdOrCtrl+W", accelerator: "CmdOrCtrl+W",
role: "close" role: "close",
}, },
{ {
type: "separator" type: "separator",
}, },
{ {
label: "Zoom in", label: "Zoom in",
click: () => send(IPC_COMMANDS.ZOOM_IN), click: () => send(IPC_COMMANDS.ZOOM_IN),
enabled: isRunning enabled: isRunning,
}, },
{ {
label: "Zoom out", label: "Zoom out",
click: () => send(IPC_COMMANDS.ZOOM_OUT), click: () => send(IPC_COMMANDS.ZOOM_OUT),
enabled: isRunning enabled: isRunning,
}, },
{ {
label: "Reset zoom", label: "Reset zoom",
click: () => send(IPC_COMMANDS.ZOOM_RESET), click: () => send(IPC_COMMANDS.ZOOM_RESET),
enabled: isRunning enabled: isRunning,
} },
] ],
}, },
{ {
label: "Machine", label: "Machine",
@ -128,53 +127,53 @@ async function createMenu({ isRunning } = { isRunning: false }) {
{ {
label: "Send Ctrl+Alt+Del", label: "Send Ctrl+Alt+Del",
click: () => send(IPC_COMMANDS.MACHINE_CTRL_ALT_DEL), click: () => send(IPC_COMMANDS.MACHINE_CTRL_ALT_DEL),
enabled: isRunning enabled: isRunning,
}, },
{ {
label: "Send Alt+F4", label: "Send Alt+F4",
click: () => send(IPC_COMMANDS.MACHINE_ALT_F4), click: () => send(IPC_COMMANDS.MACHINE_ALT_F4),
enabled: isRunning enabled: isRunning,
}, },
{ {
label: "Send Alt+Enter", label: "Send Alt+Enter",
click: () => send(IPC_COMMANDS.MACHINE_ALT_ENTER), click: () => send(IPC_COMMANDS.MACHINE_ALT_ENTER),
enabled: isRunning enabled: isRunning,
}, },
{ {
label: "Send Esc", label: "Send Esc",
click: () => send(IPC_COMMANDS.MACHINE_ESC), click: () => send(IPC_COMMANDS.MACHINE_ESC),
enabled: isRunning enabled: isRunning,
}, },
{ {
type: "separator" type: "separator",
}, },
isRunning isRunning
? { ? {
label: "Stop", label: "Stop",
click: () => send(IPC_COMMANDS.MACHINE_STOP) click: () => send(IPC_COMMANDS.MACHINE_STOP),
} }
: { : {
label: "Start", label: "Start",
click: () => send(IPC_COMMANDS.MACHINE_START) click: () => send(IPC_COMMANDS.MACHINE_START),
}, },
{ {
label: "Restart", label: "Restart",
click: () => send(IPC_COMMANDS.MACHINE_RESTART), click: () => send(IPC_COMMANDS.MACHINE_RESTART),
enabled: isRunning enabled: isRunning,
}, },
{ {
label: "Reset", label: "Reset",
click: () => send(IPC_COMMANDS.MACHINE_RESET), click: () => send(IPC_COMMANDS.MACHINE_RESET),
enabled: isRunning enabled: isRunning,
}, },
{ {
type: "separator" type: "separator",
}, },
{ {
label: "Go to Disk Image", label: "Go to Disk Image",
click: () => send(IPC_COMMANDS.SHOW_DISK_IMAGE) click: () => send(IPC_COMMANDS.SHOW_DISK_IMAGE),
} },
] ],
}, },
{ {
label: "Help", label: "Help",
@ -182,18 +181,18 @@ async function createMenu({ isRunning } = { isRunning: false }) {
submenu: [ submenu: [
{ {
label: "Author", label: "Author",
click: () => shell.openExternal(LINKS.homepage) click: () => shell.openExternal(LINKS.homepage),
}, },
{ {
label: "windows95 on GitHub", label: "windows95 on GitHub",
click: () => shell.openExternal(LINKS.repo) click: () => shell.openExternal(LINKS.repo),
}, },
{ {
label: "Help", label: "Help",
click: () => shell.openExternal(LINKS.help) click: () => shell.openExternal(LINKS.help),
}, },
{ {
type: "separator" type: "separator",
}, },
{ {
label: "Troubleshooting", label: "Troubleshooting",
@ -205,12 +204,12 @@ async function createMenu({ isRunning } = { isRunning: false }) {
app.relaunch(); app.relaunch();
app.quit(); app.quit();
} },
} },
] ],
} },
] ],
} },
]; ];
if (process.platform === "darwin") { if (process.platform === "darwin") {
@ -218,41 +217,41 @@ async function createMenu({ isRunning } = { isRunning: false }) {
label: "windows95", label: "windows95",
submenu: [ submenu: [
{ {
role: "about" role: "about",
}, },
{ {
type: "separator" type: "separator",
}, },
{ {
role: "services" role: "services",
}, },
{ {
type: "separator" type: "separator",
}, },
{ {
label: "Hide windows95", label: "Hide windows95",
accelerator: "Command+H", accelerator: "Command+H",
role: "hide" role: "hide",
}, },
{ {
label: "Hide Others", label: "Hide Others",
accelerator: "Command+Shift+H", accelerator: "Command+Shift+H",
role: "hideothers" role: "hideothers",
}, },
{ {
role: "unhide" role: "unhide",
}, },
{ {
type: "separator" type: "separator",
}, },
{ {
label: "Quit", label: "Quit",
accelerator: "Command+Q", accelerator: "Command+Q",
click() { click() {
app.quit(); app.quit();
} },
} },
] ],
} as any); } as any);
} }

View file

@ -4,7 +4,7 @@ export function setupUpdates() {
if (app.isPackaged) { if (app.isPackaged) {
require("update-electron-app")({ require("update-electron-app")({
repo: "felixrieseberg/windows95", repo: "felixrieseberg/windows95",
updateInterval: "1 hour" updateInterval: "1 hour",
}); });
} }
} }

View file

@ -13,8 +13,8 @@ export function getOrCreateWindow(): BrowserWindow {
webPreferences: { webPreferences: {
nodeIntegration: true, nodeIntegration: true,
sandbox: false, sandbox: false,
webviewTag: false webviewTag: false,
} },
}); });
mainWindow.loadFile("./dist/static/index.html"); mainWindow.loadFile("./dist/static/index.html");

View file

@ -28,7 +28,7 @@ export class App {
} }
window["win95"] = window["win95"] || { window["win95"] = window["win95"] || {
app: new App() app: new App(),
}; };
window["win95"].app.setup(); window["win95"].app.setup();

View file

@ -1,5 +1,4 @@
import * as React from "react"; import * as React from "react";
import { shell } from "electron";
interface CardDriveProps { interface CardDriveProps {
showDiskImage: () => void; showDiskImage: () => void;
@ -54,13 +53,8 @@ export class CardDrive extends React.Component<CardDriveProps, CardDriveState> {
<p> <p>
Windows 10 cannot mount raw disk images (ironically, macOS and Linux Windows 10 cannot mount raw disk images (ironically, macOS and Linux
can). However, tools exist that let you mount this drive, like the can). However, tools exist that let you mount this drive, like the
freeware tool{" "} freeware tool <a href="https://google.com">OSFMount</a>. I am not
<a affiliated with it, so please use it at your own risk.
href="https://google.com"
>
OSFMount
</a>
. I am not affiliated with it, so please use it at your own risk.
</p> </p>
{this.renderMountButton("Windows Explorer")} {this.renderMountButton("Windows Explorer")}
</fieldset> </fieldset>

View file

@ -24,7 +24,7 @@ export class CardSettings extends React.Component<
this.onResetState = this.onResetState.bind(this); this.onResetState = this.onResetState.bind(this);
this.state = { this.state = {
isStateReset: false isStateReset: false,
}; };
} }

View file

@ -29,7 +29,7 @@ export class EmulatorInfo extends React.Component<
cpu: 0, cpu: 0,
disk: "Idle", disk: "Idle",
lastCounter: 0, lastCounter: 0,
lastTick: 0 lastTick: 0,
}; };
} }
@ -160,7 +160,7 @@ export class EmulatorInfo extends React.Component<
this.setState({ this.setState({
lastTick: now, lastTick: now,
lastCounter: instructionCounter, lastCounter: instructionCounter,
cpu: Math.round(ips / deltaTime) cpu: Math.round(ips / deltaTime),
}); });
} }
} }

View file

@ -41,7 +41,7 @@ export class Emulator extends React.Component<{}, EmulatorState> {
isRunning: false, isRunning: false,
currentUiCard: "start", currentUiCard: "start",
isInfoDisplayed: true, isInfoDisplayed: true,
scale: 1 scale: 1,
}; };
this.setupInputListeners(); this.setupInputListeners();
@ -58,7 +58,7 @@ export class Emulator extends React.Component<{}, EmulatorState> {
*/ */
public setupInputListeners() { public setupInputListeners() {
// ESC // ESC
document.onkeydown = evt => { document.onkeydown = (evt) => {
const { isCursorCaptured } = this.state; const { isCursorCaptured } = this.state;
evt = evt || window.event; evt = evt || window.event;
@ -99,7 +99,7 @@ export class Emulator extends React.Component<{}, EmulatorState> {
}); });
}; };
window.onbeforeunload = event => { window.onbeforeunload = (event) => {
if (this.isQuitting || this.isResetting) { if (this.isQuitting || this.isResetting) {
console.log(`Unload: Not preventing`); console.log(`Unload: Not preventing`);
return; return;
@ -122,27 +122,27 @@ export class Emulator extends React.Component<{}, EmulatorState> {
this.sendKeys([ this.sendKeys([
0x1d, // ctrl 0x1d, // ctrl
0x38, // alt 0x38, // alt
0x53 // delete 0x53, // delete
]); ]);
}); });
ipcRenderer.on(IPC_COMMANDS.MACHINE_ALT_F4, () => { ipcRenderer.on(IPC_COMMANDS.MACHINE_ALT_F4, () => {
this.sendKeys([ this.sendKeys([
0x38, // alt 0x38, // alt
0x3e // f4 0x3e, // f4
]); ]);
}); });
ipcRenderer.on(IPC_COMMANDS.MACHINE_ALT_ENTER, () => { ipcRenderer.on(IPC_COMMANDS.MACHINE_ALT_ENTER, () => {
this.sendKeys([ this.sendKeys([
0x38, // alt 0x38, // alt
0 // enter 0, // enter
]); ]);
}); });
ipcRenderer.on(IPC_COMMANDS.MACHINE_ESC, () => { ipcRenderer.on(IPC_COMMANDS.MACHINE_ESC, () => {
this.sendKeys([ this.sendKeys([
0x18 // alt 0x18, // alt
]); ]);
}); });
@ -189,7 +189,7 @@ export class Emulator extends React.Component<{}, EmulatorState> {
if (currentUiCard === "settings") { if (currentUiCard === "settings") {
card = ( card = (
<CardSettings <CardSettings
setFloppy={floppyFile => this.setState({ floppyFile })} setFloppy={(floppyFile) => this.setState({ floppyFile })}
bootFromScratch={this.bootFromScratch} bootFromScratch={this.bootFromScratch}
floppy={floppyFile} floppy={floppyFile}
/> />
@ -204,7 +204,7 @@ export class Emulator extends React.Component<{}, EmulatorState> {
<> <>
{card} {card}
<StartMenu <StartMenu
navigate={target => this.setState({ currentUiCard: target })} navigate={(target) => this.setState({ currentUiCard: target })}
/> />
</> </>
); );
@ -257,10 +257,10 @@ export class Emulator extends React.Component<{}, EmulatorState> {
*/ */
public showDiskImage() { public showDiskImage() {
// Contents/Resources/app/dist/static // Contents/Resources/app/dist/static
const imagePath = path const imagePath = path.join(__dirname, "../../images/windows95.img");
.join(__dirname, "../../images/windows95.img");
console.log(`Showing disk image in ${imagePath}`);`` console.log(`Showing disk image in ${imagePath}`);
``;
shell.showItemInFolder(imagePath); shell.showItemInFolder(imagePath);
} }
@ -277,20 +277,20 @@ export class Emulator extends React.Component<{}, EmulatorState> {
video_memory_size: 32 * 1024 * 1024, video_memory_size: 32 * 1024 * 1024,
screen_container: document.getElementById("emulator"), screen_container: document.getElementById("emulator"),
bios: { bios: {
url: "../../bios/seabios.bin" url: "../../bios/seabios.bin",
}, },
vga_bios: { vga_bios: {
url: "../../bios/vgabios.bin" url: "../../bios/vgabios.bin",
}, },
hda: { hda: {
url: "../../images/windows95.img", url: "../../images/windows95.img",
async: true, async: true,
size: imageSize size: imageSize,
}, },
fda: { fda: {
buffer: this.state.floppyFile buffer: this.state.floppyFile,
}, },
boot_order: 0x132 boot_order: 0x132,
}; };
console.log(`🚜 Starting emulator with options`, options); console.log(`🚜 Starting emulator with options`, options);
@ -300,7 +300,7 @@ export class Emulator extends React.Component<{}, EmulatorState> {
// New v86 instance // New v86 instance
this.setState({ this.setState({
emulator: window["emulator"], emulator: window["emulator"],
isRunning: true isRunning: true,
}); });
ipcRenderer.send(IPC_COMMANDS.MACHINE_STARTED); ipcRenderer.send(IPC_COMMANDS.MACHINE_STARTED);
@ -367,7 +367,7 @@ export class Emulator extends React.Component<{}, EmulatorState> {
private async saveState(): Promise<void> { private async saveState(): Promise<void> {
const { emulator } = this.state; const { emulator } = this.state;
return new Promise(resolve => { return new Promise((resolve) => {
if (!emulator || !emulator.save_state) { if (!emulator || !emulator.save_state) {
console.log(`restoreState: No emulator present`); console.log(`restoreState: No emulator present`);
return resolve(); return resolve();