Start work on testing Hyperspace desktop app (note: BROKEN)

This commit is contained in:
Marquis Kurt 2019-04-30 16:53:50 -04:00
parent bd9e096bd8
commit a58a172fe5
3 changed files with 1583 additions and 2 deletions

1382
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
"name": "hyperspace",
"version": "1.0.0",
"private": true,
"homepage": "./",
"devDependencies": {
"@date-io/moment": "^1.3.5",
"@material-ui/core": "^3.9.3",
@ -27,11 +28,17 @@
"react-scripts": "^2.1.8",
"react-swipeable-views": "^0.13.1",
"react-web-share-api": "^0.0.2",
"typescript": "3.4.1"
"typescript": "3.4.1",
"electron": "^5.0.0",
"electron-builder": "^20.39.0",
"electron-updater": "^4.0.6"
},
"main": "public/desktop.js",
"scripts": {
"start": "HTTPS=true BROWSER='Safari Technology Preview' react-scripts start",
"electrify": "npm run build; electron .",
"build": "react-scripts build",
"build-desktop": "build -mwl deb AppImage snap",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
@ -43,5 +50,40 @@
"not dead",
"not ie <= 11",
"not op_mini all"
]
],
"build": {
"appId": "net.marquiskurt.hyperspace",
"directories": {
"buildResources": "desktop"
},
"mac": {
"category": "public.app-category.social-networking",
"icon": "desktop/app.icns",
"target": [
"dmg",
"mas"
]
},
"mas": {
"entitlements": "desktop/entitlements.mas.plist",
"provisioningProfile": "desktop/embedded.provisionprofile"
},
"win": {
"target": [
"nsis"
],
"icon": "desktop/app.ico"
},
"linux": {
"target": [
"${@:1}"
],
"icon": "linux",
"category": "Network"
},
"snap": {
"confinement": "strict",
"summary": "A beautiful, fluffy client for the fediverse"
}
}
}

157
public/desktop.js Normal file
View File

@ -0,0 +1,157 @@
const electron = require('electron');
const app = electron.app;
const menu = electron.Menu;
const BrowserWindow = electron.BrowserWindow;
const {autoUpdater} = require('electron-updater');
const path = require('path');
autoUpdater.checkForUpdatesAndNotify();
let mainWindow;
function createWindow() {
mainWindow = new BrowserWindow(
{
width: 1000,
height: 600,
minWidth: 476,
titleBarStyle: 'hidden',
webPreferences: {nodeIntegration: true}
}
);
mainWindow.loadURL(`file://${path.join(__dirname, '../build/index.html')}`);
mainWindow.on('closed', () => {
mainWindow = null
});
}
function createMenubar() {
const menuBar = [
{
label: 'File',
submenu: [
{
label: 'New Window',
accelerator: 'CmdOrCtrl+N',
click() {
if (mainWindow == null)
createWindow();
}
}
]
},
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
{ role: 'pasteandmatchstyle' },
{ role: 'delete' },
{ role: 'selectall' }
]
},
{
label: 'View',
submenu: [
{ role: 'reload' },
{ role: 'forcereload' },
{
label: 'Open Dev Tools',
click () {
try {
mainWindow.webContents.openDevTools({mode: 'undocked'});
} catch (err) {
console.error("Couldn't open dev tools: " + err);
}
},
accelerator: 'Shift+CmdOrCtrl+I'
},
{ type: 'separator' },
{ role: 'togglefullscreen' }
]
},
{
role: 'window',
submenu: [
{ role: 'minimize' },
{ role: 'close' }
]
},
{
role: 'help',
submenu: [
{
label: 'Report a Bug',
click () { require('electron').shell.openExternal('https://github.com/hyperspacedev/hyperspace/issues') }
}
]
}
]
if (process.platform === 'darwin') {
menuBar.unshift({
label: app.getName(),
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services' },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideothers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' }
]
})
// Edit menu
menuBar[2].submenu.push(
{ type: 'separator' },
{
label: 'Speech',
submenu: [
{ role: 'startspeaking' },
{ role: 'stopspeaking' }
]
}
)
// Window menu
menuBar[4].submenu = [
{ role: 'close' },
{ role: 'minimize' },
{ role: 'zoom' },
{ type: 'separator' },
{ role: 'front' }
]
}
const thisMenu = menu.buildFromTemplate(menuBar);
menu.setApplicationMenu(thisMenu);
}
app.on('ready', () => {
createWindow();
createMenubar();
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
});
app.on('activate', () => {
if (mainWindow === null) {
createWindow()
createMenubar()
}
});