Skip to content

Commit

Permalink
chore: Updated prettier run
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrieseberg committed Aug 2, 2020
1 parent 045b83f commit 92717c8
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 124 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
text eol=lf
28 changes: 20 additions & 8 deletions src/cache.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { session } from 'electron';
import { session } from "electron";

export async function clearCaches() {
await clearCache()
await clearStorageData()
await clearCache();
await clearStorageData();
}

export async function clearCache() {
Expand All @@ -17,9 +17,21 @@ export function clearStorageData() {
return resolve();
}

session.defaultSession.clearStorageData({
storages: [ 'appcache', 'cookies', 'filesystem', 'indexdb', 'localstorage', 'shadercache', 'websql', 'serviceworkers' ],
quotas: [ 'temporary', 'persistent', 'syncable' ]
}, resolve)
})
session.defaultSession.clearStorageData(
{
storages: [
"appcache",
"cookies",
"filesystem",
"indexdb",
"localstorage",
"shadercache",
"websql",
"serviceworkers",
],
quotas: ["temporary", "persistent", "syncable"],
},
resolve
);
});
}
46 changes: 23 additions & 23 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { remote, app } from 'electron';
import * as path from 'path';
import { remote, app } from "electron";
import * as path from "path";

const _app = app || remote.app
const _app = app || remote.app;

export const CONSTANTS = {
IMAGE_PATH: path.join(__dirname, '../../images/windows95.img'),
IMAGE_PATH: path.join(__dirname, "../../images/windows95.img"),
IMAGE_DEFAULT_SIZE: 1073741824, // 1GB
DEFAULT_STATE_PATH: path.join(__dirname, '../../images/default-state.bin'),
STATE_PATH: path.join(_app.getPath('userData'), 'state-v2.bin')
}
DEFAULT_STATE_PATH: path.join(__dirname, "../../images/default-state.bin"),
STATE_PATH: path.join(_app.getPath("userData"), "state-v2.bin"),
};

export const IPC_COMMANDS = {
TOGGLE_INFO: 'TOGGLE_INFO',
SHOW_DISK_IMAGE: 'SHOW_DISK_IMAGE',
ZOOM_IN: 'ZOOM_IN',
ZOOM_OUT: 'ZOOM_OUT',
ZOOM_RESET: 'ZOOM_RESET',
TOGGLE_INFO: "TOGGLE_INFO",
SHOW_DISK_IMAGE: "SHOW_DISK_IMAGE",
ZOOM_IN: "ZOOM_IN",
ZOOM_OUT: "ZOOM_OUT",
ZOOM_RESET: "ZOOM_RESET",
// Machine instructions
MACHINE_START: 'MACHINE_START',
MACHINE_RESTART: 'MACHINE_RESTART',
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_START: "MACHINE_START",
MACHINE_RESTART: "MACHINE_RESTART",
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
MACHINE_STARTED: 'MACHINE_STARTED',
MACHINE_STOPPED: 'MACHINE_STOPPED'
}
MACHINE_STARTED: "MACHINE_STARTED",
MACHINE_STOPPED: "MACHINE_STOPPED",
};
2 changes: 1 addition & 1 deletion src/main/about-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function setupAboutPanel(): void {
applicationName: "windows95",
applicationVersion: app.getVersion(),
version: process.versions.electron,
copyright: "Felix Rieseberg"
copyright: "Felix Rieseberg",
};

switch (process.platform) {
Expand Down
115 changes: 57 additions & 58 deletions src/main/menu.ts
Original file line number Diff line number Diff line change
@@ -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 { IPC_COMMANDS } from "../constants";
import { isDevMode } from "../utils/devmode";
import { getOrCreateWindow } from "./windows";

const LINKS = {
homepage: "https://www.twitter.com/felixrieseberg",
repo: "https://github.com/felixrieseberg/windows95",
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() {
Expand Down Expand Up @@ -41,52 +40,52 @@ async function createMenu({ isRunning } = { isRunning: false }) {
submenu: [
{
label: "Toggle Full Screen",
accelerator: (function() {
accelerator: (function () {
if (process.platform === "darwin") {
return "Ctrl+Command+F";
} else {
return "F11";
}
})(),
click: function(_item, focusedWindow) {
click: function (_item, focusedWindow) {
if (focusedWindow) {
focusedWindow.setFullScreen(!focusedWindow.isFullScreen());
}
}
},
},
{
label: "Toggle Developer Tools",
accelerator: (function() {
accelerator: (function () {
if (process.platform === "darwin") {
return "Alt+Command+I";
} else {
return "Ctrl+Shift+I";
}
})(),
click: function(_item, focusedWindow) {
click: function (_item, focusedWindow) {
if (focusedWindow) {
focusedWindow.webContents.toggleDevTools();
}
}
},
},
{
type: "separator"
type: "separator",
},
{
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",
visible: isDevMode()
visible: isDevMode(),
},
{
label: "Window",
Expand All @@ -95,105 +94,105 @@ async function createMenu({ isRunning } = { isRunning: false }) {
{
label: "Minimize",
accelerator: "CmdOrCtrl+M",
role: "minimize"
role: "minimize",
},
{
label: "Close",
accelerator: "CmdOrCtrl+W",
role: "close"
role: "close",
},
{
type: "separator"
type: "separator",
},
{
label: "Zoom in",
click: () => send(IPC_COMMANDS.ZOOM_IN),
enabled: isRunning
enabled: isRunning,
},
{
label: "Zoom out",
click: () => send(IPC_COMMANDS.ZOOM_OUT),
enabled: isRunning
enabled: isRunning,
},
{
label: "Reset zoom",
click: () => send(IPC_COMMANDS.ZOOM_RESET),
enabled: isRunning
}
]
enabled: isRunning,
},
],
},
{
label: "Machine",
submenu: [
{
label: "Send Ctrl+Alt+Del",
click: () => send(IPC_COMMANDS.MACHINE_CTRL_ALT_DEL),
enabled: isRunning
enabled: isRunning,
},
{
label: "Send Alt+F4",
click: () => send(IPC_COMMANDS.MACHINE_ALT_F4),
enabled: isRunning
enabled: isRunning,
},
{
label: "Send Alt+Enter",
click: () => send(IPC_COMMANDS.MACHINE_ALT_ENTER),
enabled: isRunning
enabled: isRunning,
},
{
label: "Send Esc",
click: () => send(IPC_COMMANDS.MACHINE_ESC),
enabled: isRunning
enabled: isRunning,
},
{
type: "separator"
type: "separator",
},
isRunning
? {
label: "Stop",
click: () => send(IPC_COMMANDS.MACHINE_STOP)
click: () => send(IPC_COMMANDS.MACHINE_STOP),
}
: {
label: "Start",
click: () => send(IPC_COMMANDS.MACHINE_START)
click: () => send(IPC_COMMANDS.MACHINE_START),
},
{
label: "Restart",
click: () => send(IPC_COMMANDS.MACHINE_RESTART),
enabled: isRunning
enabled: isRunning,
},
{
label: "Reset",
click: () => send(IPC_COMMANDS.MACHINE_RESET),
enabled: isRunning
enabled: isRunning,
},
{
type: "separator"
type: "separator",
},
{
label: "Go to Disk Image",
click: () => send(IPC_COMMANDS.SHOW_DISK_IMAGE)
}
]
click: () => send(IPC_COMMANDS.SHOW_DISK_IMAGE),
},
],
},
{
label: "Help",
role: "help",
submenu: [
{
label: "Author",
click: () => shell.openExternal(LINKS.homepage)
click: () => shell.openExternal(LINKS.homepage),
},
{
label: "windows95 on GitHub",
click: () => shell.openExternal(LINKS.repo)
click: () => shell.openExternal(LINKS.repo),
},
{
label: "Help",
click: () => shell.openExternal(LINKS.help)
click: () => shell.openExternal(LINKS.help),
},
{
type: "separator"
type: "separator",
},
{
label: "Troubleshooting",
Expand All @@ -205,54 +204,54 @@ async function createMenu({ isRunning } = { isRunning: false }) {

app.relaunch();
app.quit();
}
}
]
}
]
}
},
},
],
},
],
},
];

if (process.platform === "darwin") {
template.unshift({
label: "windows95",
submenu: [
{
role: "about"
role: "about",
},
{
type: "separator"
type: "separator",
},
{
role: "services"
role: "services",
},
{
type: "separator"
type: "separator",
},
{
label: "Hide windows95",
accelerator: "Command+H",
role: "hide"
role: "hide",
},
{
label: "Hide Others",
accelerator: "Command+Shift+H",
role: "hideothers"
role: "hideothers",
},
{
role: "unhide"
role: "unhide",
},
{
type: "separator"
type: "separator",
},
{
label: "Quit",
accelerator: "Command+Q",
click() {
app.quit();
}
}
]
},
},
],
} as any);
}

Expand Down
Loading

0 comments on commit 92717c8

Please sign in to comment.