feat: add electron app support

This commit is contained in:
thecodrr
2021-03-10 22:35:29 +05:00
parent 23440391f0
commit eb06e7fe9a
18 changed files with 1442 additions and 40 deletions

4
apps/web/.gitignore vendored
View File

@@ -24,4 +24,6 @@ yarn-error.log*
.now
__diff_output__
__diff_output__
dist

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
</dict>
</plist>

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 KiB

View File

@@ -2,6 +2,7 @@
"name": "notes-web",
"version": "1.3.4",
"private": true,
"main": "public/electron.js",
"dependencies": {
"@mdi/js": "^5.9.55",
"@mdi/react": "^1.4.0",
@@ -39,9 +40,11 @@
"tinymce": "^5.7.0",
"uzip": "^0.20201231.0",
"wouter": "^2.7.3",
"zustand": "^3.3.1"
"zustand": "^3.3.1",
"electron-serve": "^1.1.0"
},
"devDependencies": {
"@neutralinojs/neu": "^2.4.0",
"@sentry/types": "^6.1.0",
"@types/hookrouter": "^2.2.5",
"@types/jest": "^26.0.20",
@@ -49,6 +52,8 @@
"@types/quill": "^2.0.5",
"babel-eslint": "^10.1.0",
"chalk": "^4.1.0",
"electron": "^12.0.0",
"electron-builder": "^22.10.5",
"eslint": "^7.20.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-import": "^2.20.2",
@@ -73,7 +78,10 @@
"test": "REACT_APP_CI=true BROWSER= jest --runInBand -c jest.e2e.config.js",
"eject": "react-scripts eject",
"update": "npm i @streetwriters/editor@latest @streetwriters/notesnook-core@latest @streetwriters/theme@latest",
"analyze": "source-map-explorer 'build/static/js/*.js'"
"analyze": "source-map-explorer 'build/static/js/*.js'",
"electron-dev": "ELECTRON_START_URL=http://localhost:3000 electron .",
"electron-prod": "electron electron/main.js",
"electron-build": "electron-builder"
},
"eslintConfig": {
"extends": "react-app"
@@ -92,5 +100,61 @@
"last 3 ie version",
"last 4 edge version"
]
},
"author": {
"name": "Streetwriters (Private) Ltd.",
"email": "support@streetwriters.co",
"url": "https://streetwriters.co"
},
"build": {
"productName": "Notesnook",
"appId": "com.streetwriters.notesnook",
"copyright": "Copyright © 2021 Streetwriters (Private) Ltd.",
"files": [
"build/",
"node_modules/electron-serve"
],
"mac": {
"target": [
"dmg"
],
"type": "distribution",
"hardenedRuntime": true,
"entitlements": "assets/entitlements.mac.plist",
"entitlementsInherit": "assets/entitlements.mac.plist",
"gatekeeperAssess": false
},
"dmg": {
"contents": [
{
"x": 130,
"y": 220
},
{
"x": 410,
"y": 220,
"type": "link",
"path": "/Applications"
}
]
},
"win": {
"target": [
"nsis"
]
},
"linux": {
"target": [
"AppImage"
],
"category": "Development"
},
"extraResources": [
"./assets/**"
],
"directories": {
"buildResources": "assets",
"output": "dist/"
}
}
}

View File

@@ -0,0 +1,38 @@
const { app, BrowserWindow } = require("electron");
const serve = require("electron-serve");
const loadURL = serve({
directory: __dirname,
scheme: "nn",
isCorsEnabled: false,
});
let mainWindow;
async function createWindow() {
mainWindow = new BrowserWindow({
autoHideMenuBar: true,
});
mainWindow.maximize();
await loadURL(mainWindow);
mainWindow.on("closed", () => {
mainWindow = null;
});
}
app.on("ready", createWindow);
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
if (mainWindow === null) {
createWindow();
}
});

View File

@@ -54,7 +54,7 @@
-->
<title>Notesnook - A safe place to write</title>
<style>
#splash img {
#splash svg {
transform: scale(1);
animation: pulse 2s infinite;
}

View File

@@ -47,4 +47,4 @@ initializeDatabase().then(() => {
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
serviceWorker.register();

File diff suppressed because it is too large Load Diff