diff options
| author | 8cy <[email protected]> | 2020-06-22 15:47:46 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-06-22 15:47:46 -0700 |
| commit | e34f19a50bda8de4812e9c2c364c303e1fd7ebfe (patch) | |
| tree | dd980c424adbb82771cd0fe41a5f4d7418af73f4 | |
| download | monkey-type-desktop-e34f19a50bda8de4812e9c2c364c303e1fd7ebfe.tar.xz monkey-type-desktop-e34f19a50bda8de4812e9c2c364c303e1fd7ebfe.zip | |
woah :star:
| -rw-r--r-- | .gitattributes | 1 | ||||
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | .travis.yml | 7 | ||||
| -rw-r--r-- | README.MD | 20 | ||||
| -rw-r--r-- | build/icon.png | bin | 0 -> 110828 bytes | |||
| -rw-r--r-- | config.js | 9 | ||||
| -rw-r--r-- | index.css | 43 | ||||
| -rw-r--r-- | index.js | 94 | ||||
| -rw-r--r-- | menu.js | 181 | ||||
| -rw-r--r-- | package.json | 73 | ||||
| -rw-r--r-- | static/icon.png | bin | 0 -> 110828 bytes |
11 files changed, 431 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6313b56 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b290a5b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +yarn.lock +/dist diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6eb48de --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +os: osx +osx_image: xcode10.2 +language: node_js +node_js: '12' +script: + - npm test + - npm run dist diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..839678d --- /dev/null +++ b/README.MD @@ -0,0 +1,20 @@ +# Monkey Type, but for desktop! +Basically title. + +## Useful Links +- [Original Monkey Type open source repository](https://github.com/Miodec/monkey-type) +- [Monkey Type Website](https://monkey-type.com/) + +## Development Usage +1. Clone or download repository. +2. `$ yarn` or `$ npm i` to install dependencies. +3. `$ npm run start` to start the application. + +## Installation +1. Go to [releases](https://github.com/8cy/monkey-type-desktop/releases) +2. Download + +Currently, only Windows builds are in the release section, however, you can build Linux or Mac using the `$ npm run dist` script along side your platforms flag; `--windows`, `--linux` or `--mac`. + +### License +MIT
\ No newline at end of file diff --git a/build/icon.png b/build/icon.png Binary files differnew file mode 100644 index 0000000..b9271ac --- /dev/null +++ b/build/icon.png diff --git a/config.js b/config.js new file mode 100644 index 0000000..4d0f3f3 --- /dev/null +++ b/config.js @@ -0,0 +1,9 @@ +'use strict'; +const Store = require('electron-store'); + +module.exports = new Store({ + defaults: { + debugEnable: false, + menuEnable: true + } +}); diff --git a/index.css b/index.css new file mode 100644 index 0000000..f8d0840 --- /dev/null +++ b/index.css @@ -0,0 +1,43 @@ +html, +body { + padding: 0; + margin: 0; + background: transparent; +} + +/* Use OS default fonts */ +body { + font-family: -apple-system, + BlinkMacSystemFont, + 'Segoe UI', + Roboto, + Oxygen-Sans, + Ubuntu, + Cantarell, + 'Helvetica Neue', + sans-serif, + 'Apple Color Emoji', + 'Segoe UI Emoji', + 'Segoe UI Symbol'; + text-rendering: optimizeLegibility; + font-feature-settings: 'liga', 'clig', 'kern'; +} + +header { + position: absolute; + width: 500px; + height: 250px; + top: 50%; + left: 50%; + margin-top: -125px; + margin-left: -250px; + text-align: center; +} + +header h1 { + font-size: 60px; + font-weight: 200; + margin: 0; + padding: 0; + opacity: 0.7; +} diff --git a/index.js b/index.js new file mode 100644 index 0000000..19a6b58 --- /dev/null +++ b/index.js @@ -0,0 +1,94 @@ +'use strict'; +const path = require('path'); +const { app, BrowserWindow, Menu, session } = require('electron'); +/// const {autoUpdater} = require('electron-updater'); +const {is} = require('electron-util'); +const unhandled = require('electron-unhandled'); +const debug = require('electron-debug'); +const contextMenu = require('electron-context-menu'); +const config = require('./config'); + +const menuEnable = config.get('menuEnable'); +const menu = require('./menu'); + +unhandled(); +contextMenu(); + +const debugEnable = config.get('debugEnable'); +if (debugEnable) debug(); + +// Note: Must match `build.appId` in package.json +app.setAppUserModelId('com.sin.monkey-type-desktop'); + +// Uncomment this before publishing your first version. +// It's commented out as it throws an error if there are no published versions. +// if (!is.development) { +// const FOUR_HOURS = 1000 * 60 * 60 * 4; +// setInterval(() => { +// autoUpdater.checkForUpdates(); +// }, FOUR_HOURS); +// +// autoUpdater.checkForUpdates(); +// } + +// Prevent window from being garbage collected +let mainWindow; + +const createMainWindow = async () => { + const win = new BrowserWindow({ + title: app.name, + show: false, + width: 960, + height: 540, + icon: path.join(__dirname, '/static/icon.png') + }); + + win.on('ready-to-show', () => { + win.show(); + }); + + win.on('closed', () => { + // Dereference the window + // For multiple windows store them in an array + mainWindow = undefined; + }); + + await win.loadURL("https://monkey-type.com/"); + + return win; +}; + +// Prevent multiple instances of the app +if (!app.requestSingleInstanceLock()) { + app.quit(); +} + +app.on('second-instance', () => { + if (mainWindow) { + if (mainWindow.isMinimized()) { + mainWindow.restore(); + } + + mainWindow.show(); + } +}); + +app.on('window-all-closed', () => { + if (!is.macos) { + app.quit(); + } +}); + +app.on('activate', async () => { + if (!mainWindow) { + mainWindow = await createMainWindow(); + } +}); + +(async () => { + await app.whenReady(); + menuEnable ? Menu.setApplicationMenu(menu) : Menu.setApplicationMenu(null); + mainWindow = await createMainWindow(); + + session.defaultSession.cookies.get({}).then(cookies => console.log(cookies)); +})(); @@ -0,0 +1,181 @@ +'use strict'; +const path = require('path'); +const { app, Menu, shell } = require('electron'); +const { + is, + appMenu, + aboutMenuItem, + openUrlMenuItem, + openNewGitHubIssue, + debugInfo +} = require('electron-util'); +const config = require('./config'); + +const showPreferences = () => { + // Show the app's preferences here +}; + +const helpSubmenu = [ + openUrlMenuItem({ + label: 'My Website', + url: 'https://kyzer.co/' + }), + openUrlMenuItem({ + label: 'Source Code', + url: 'https://github.com/8cy/MonkeyDesktop' + }), + { + label: 'Report an Issue…', + click() { + const body = ` +<!-- Please succinctly describe your issue and steps to reproduce it. --> + + +--- + +${debugInfo()}`; + + openNewGitHubIssue({ + user: '8cy', + repo: 'MonkeyDesktop', + body + }); + } + } +]; + +if (!is.macos) { + helpSubmenu.push( + { + type: 'separator' + }, + aboutMenuItem({ + icon: path.join(__dirname, 'static', 'icon.png'), + text: 'Made with love by Sin. Original Monkey Type web-application made by Miodec.' + }) + ); +} + +// Only pushed if debug mode. +const debugSubmenu = [ + { + label: 'Show Settings', + click() { + config.openInEditor(); + } + }, + { + label: 'Show App Data', + click() { + shell.openItem(app.getPath('userData')); + } + }, + { + type: 'separator' + }, + { + label: 'Delete Settings', + click() { + config.clear(); + app.relaunch(); + app.quit(); + } + }, + { + label: 'Delete App Data', + click() { + shell.moveItemToTrash(app.getPath('userData')); + app.relaunch(); + app.quit(); + } + } +]; + +const macosTemplate = [ + appMenu([ + { + label: 'Preferences…', + accelerator: 'Command+,', + click() { + showPreferences(); + } + } + ]), + { + role: 'fileMenu', + submenu: [ + { + label: 'Custom' + }, + { + type: 'separator' + }, + { + role: 'close' + } + ] + }, + { + role: 'editMenu' + }, + { + role: 'viewMenu' + }, + { + role: 'windowMenu' + }, + { + role: 'help', + submenu: helpSubmenu + } +]; + +// Linux and Windows +const otherTemplate = [ + { + role: 'fileMenu', + submenu: [ + { + label: 'Custom' + }, + { + type: 'separator' + }, + { + label: 'Settings', + accelerator: 'Control+,', + click() { + showPreferences(); + } + }, + { + type: 'separator' + }, + { + role: 'quit' + } + ] + }, + { + role: 'editMenu' + }, + { + role: 'viewMenu' + }, + { + role: 'help', + submenu: helpSubmenu + } +]; + +const template = process.platform === 'darwin' ? macosTemplate : otherTemplate; + +// Ideally, this should be un-commented and only pushed if in debug mode, but I find it pretty useful and chose to keep it in release. +//if (is.development) { + template.push({ + label: 'Debug', + submenu: debugSubmenu + }); +//} + +module.exports = Menu.buildFromTemplate(template); diff --git a/package.json b/package.json new file mode 100644 index 0000000..a0eec34 --- /dev/null +++ b/package.json @@ -0,0 +1,73 @@ +{ + "name": "monkey-type-desktop", + "productName": "Monkey Type", + "version": "1.0.0", + "description": "Monkey Type, but on desktop!", + "license": "MIT", + "repository": "8cy/monkey-type-desktop", + "author": "Sin", + "scripts": { + "postinstall": "electron-builder install-app-deps", + "lint": "xo", + "test": "npm run lint", + "start": "electron .", + "pack": "electron-builder --dir", + "dist": "electron-builder --macos --linux --windows", + "dist:win": "electron-builder --windows", + "release": "np" + }, + "dependencies": { + "discord-rpc": "^3.1.1", + "electron-context-menu": "^0.15.0", + "electron-debug": "^3.0.0", + "electron-store": "^5.1.0", + "electron-unhandled": "^3.0.0", + "electron-updater": "^4.0.6", + "electron-util": "^0.13.0" + }, + "devDependencies": { + "electron": "^7.1.1", + "electron-builder": "^21.2.0", + "np": "^5.0.3", + "xo": "^0.25.3" + }, + "xo": { + "envs": [ + "node", + "browser" + ] + }, + "np": { + "publish": false, + "releaseDraft": false + }, + "build": { + "appId": "com.sin.monkey-type-desktop", + "mac": { + "category": "public.app-category.social-networking", + "darkModeSupport": true + }, + "dmg": { + "iconSize": 160, + "contents": [ + { + "x": 180, + "y": 170 + }, + { + "x": 480, + "y": 170, + "type": "link", + "path": "/Applications" + } + ] + }, + "linux": { + "target": [ + "MonkeyType", + "deb" + ], + "category": "Network;Chat" + } + } +} diff --git a/static/icon.png b/static/icon.png Binary files differnew file mode 100644 index 0000000..b9271ac --- /dev/null +++ b/static/icon.png |