mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
#12: Start moving Electron to dedicated folder
This commit is contained in:
parent
02ff68b6c7
commit
9e27e4886e
2
electron/.gitignore
vendored
Normal file
2
electron/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
dist
|
5916
electron/package-lock.json
generated
Normal file
5916
electron/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
33
electron/package.json
Normal file
33
electron/package.json
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "electron",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "src/electron.ts",
|
||||
"scripts": {
|
||||
"start-electron": "rimraf ./dist && tsc && ts-node ./bin/copy-dist.ts && cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron ./dist/electron.js --inspect=5858 .",
|
||||
"start-electron-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 electron --inspect=5858 .",
|
||||
"qstart-electron": "npm run qswitch-electron && TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron --inspect=5858 .",
|
||||
"switch-electron": "./node_modules/.bin/electron-rebuild",
|
||||
"qswitch-electron": "rm -rf ./node_modules/better-sqlite3/bin ; mkdir -p ./node_modules/better-sqlite3/build ; cp ./bin/better-sqlite3/linux-desktop-better_sqlite3.node ./node_modules/better-sqlite3/build/better_sqlite3.node"
|
||||
},
|
||||
"dependencies": {
|
||||
"@electron/remote": "2.1.2",
|
||||
"electron-debug": "3.2.0",
|
||||
"electron-dl": "3.5.2",
|
||||
"electron-window-state": "5.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "25.9.8",
|
||||
"electron-builder": "24.13.3",
|
||||
"electron-packager": "17.1.2",
|
||||
"electron-rebuild": "3.2.9",
|
||||
"ts-node": "^10.9.2",
|
||||
"cross-env": "7.0.3"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"electron-installer-debian": "3.2.0"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
import electron = require("electron");
|
||||
import sqlInit = require("../server/src/services/sql_init");
|
||||
import appIconService = require("../server/src/services/app_icon");
|
||||
import windowService = require("../server/src/services/window");
|
||||
import tray = require("../server/src/services/tray");
|
||||
import sqlInit = require("../../server/src/services/sql_init");
|
||||
import appIconService = require("./services/app_icon");
|
||||
import windowService = require("./services/window");
|
||||
import tray = require("./services/tray");
|
||||
|
||||
// Adds debug features like hotkeys for triggering dev tools and reload
|
||||
require("electron-debug")();
|
@ -1,12 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
import path = require('path');
|
||||
import resourceDir = require('./resource_dir');
|
||||
import log = require('./log');
|
||||
import resourceDir = require('../../../server/src/services/resource_dir');
|
||||
import log = require('../../../server/src/services/log');
|
||||
import os = require('os');
|
||||
import fs = require('fs');
|
||||
import config = require('./config');
|
||||
import utils = require('./utils');
|
||||
import config = require('../../../server/src/services/config');
|
||||
import utils = require('../../../server/src/services/utils');
|
||||
|
||||
const template = `[Desktop Entry]
|
||||
Type=Application
|
@ -1,7 +1,7 @@
|
||||
import { Menu, Tray } from 'electron';
|
||||
import path = require('path');
|
||||
import windowService = require('./window');
|
||||
import optionService = require('./options');
|
||||
import optionService = require('../../../server/src/services/options');
|
||||
|
||||
let tray: Tray;
|
||||
// `mainWindow.isVisible` doesn't work with `mainWindow.show` and `mainWindow.hide` - it returns `false` when the window
|
@ -1,12 +1,12 @@
|
||||
import path = require('path');
|
||||
import url = require("url");
|
||||
import port = require('./port');
|
||||
import optionService = require('./options');
|
||||
import env = require('./env');
|
||||
import log = require('./log');
|
||||
import sqlInit = require('./sql_init');
|
||||
import cls = require('./cls');
|
||||
import keyboardActionsService = require('./keyboard_actions');
|
||||
import port = require('../../../server/src/services/port');
|
||||
import optionService = require('../../../server/src/services/options');
|
||||
import env = require('../../../server/src/services/env');
|
||||
import log = require('../../../server/src/services/log');
|
||||
import sqlInit = require('../../../server/src/services/sql_init');
|
||||
import cls = require('../../../server/src/services/cls');
|
||||
import keyboardActionsService = require('../../../server/src/services/keyboard_actions');
|
||||
import remoteMain = require("@electron/remote/main")
|
||||
import { App, BrowserWindow, WebContents, ipcMain } from 'electron';
|
||||
|
27
electron/tsconfig.json
Normal file
27
electron/tsconfig.json
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "Node",
|
||||
"declaration": false,
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"strict": true,
|
||||
"noImplicitAny": true,
|
||||
"resolveJsonModule": true,
|
||||
"lib": ["ES2022"],
|
||||
"downlevelIteration": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": [
|
||||
"../server/src/**/*.js",
|
||||
"../server/src/**/*.ts",
|
||||
"bin/**/*.ts",
|
||||
"src/**/*.ts"
|
||||
],
|
||||
"exclude": ["./node_modules/**/*"],
|
||||
"ts-node": {
|
||||
"files": true
|
||||
},
|
||||
"files": [
|
||||
"../server/src/types.d.ts"
|
||||
]
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
|
||||
const DEST_DIR = "./dist";
|
||||
const DEST_DIR_SRC = path.join(DEST_DIR, "src");
|
||||
const DEST_DIR_NODE_MODULES = path.join(DEST_DIR, "node_modules");
|
||||
|
||||
async function copyNodeModuleFileOrFolder(source: string) {
|
||||
const adjustedSource = source.substring(13);
|
||||
const destination = path.join(DEST_DIR_NODE_MODULES, adjustedSource);
|
||||
|
||||
console.log(`Copying ${source} to ${destination}`);
|
||||
await fs.ensureDir(path.dirname(destination));
|
||||
await fs.copy(source, destination);
|
||||
}
|
||||
|
||||
const copy = async () => {
|
||||
const filesToCopy = ["config-sample.ini"];
|
||||
for (const file of filesToCopy) {
|
||||
console.log(`Copying ${file}`);
|
||||
await fs.copy(file, path.join(DEST_DIR, file));
|
||||
}
|
||||
|
||||
const dirsToCopy = ["images", "libraries", "db"];
|
||||
for (const dir of dirsToCopy) {
|
||||
console.log(`Copying ${dir}`);
|
||||
await fs.copy(dir, path.join(DEST_DIR, dir));
|
||||
}
|
||||
|
||||
const srcDirsToCopy = ["./src/public", "./src/views"];
|
||||
for (const dir of srcDirsToCopy) {
|
||||
console.log(`Copying ${dir}`);
|
||||
await fs.copy(dir, path.join(DEST_DIR_SRC, path.basename(dir)));
|
||||
}
|
||||
|
||||
const nodeModulesFile = [
|
||||
"node_modules/react/umd/react.production.min.js",
|
||||
"node_modules/react/umd/react.development.js",
|
||||
"node_modules/react-dom/umd/react-dom.production.min.js",
|
||||
"node_modules/react-dom/umd/react-dom.development.js",
|
||||
"node_modules/katex/dist/katex.min.js",
|
||||
"node_modules/katex/dist/contrib/mhchem.min.js",
|
||||
"node_modules/katex/dist/contrib/auto-render.min.js",
|
||||
];
|
||||
|
||||
for (const file of nodeModulesFile) {
|
||||
await copyNodeModuleFileOrFolder(file);
|
||||
}
|
||||
|
||||
const nodeModulesFolder = [
|
||||
"node_modules/@excalidraw/excalidraw/dist/",
|
||||
"node_modules/katex/dist/",
|
||||
"node_modules/dayjs/",
|
||||
"node_modules/force-graph/dist/",
|
||||
"node_modules/boxicons/css/",
|
||||
"node_modules/boxicons/fonts/",
|
||||
"node_modules/mermaid/dist/",
|
||||
"node_modules/jquery/dist/",
|
||||
"node_modules/jquery-hotkeys/",
|
||||
"node_modules/print-this/",
|
||||
"node_modules/split.js/dist/",
|
||||
"node_modules/panzoom/dist/",
|
||||
];
|
||||
|
||||
for (const folder of nodeModulesFolder) {
|
||||
await copyNodeModuleFileOrFolder(folder);
|
||||
}
|
||||
};
|
||||
|
||||
copy()
|
||||
.then(() => console.log("Copying complete!"))
|
||||
.catch((err) => console.error("Error during copy:", err));
|
@ -1,29 +0,0 @@
|
||||
[General]
|
||||
# Instance name can be used to distinguish between different instances using backend api.getInstanceName()
|
||||
instanceName=
|
||||
|
||||
# set to true to allow using Trilium without authentication (makes sense for server build only, desktop build doesn't need password)
|
||||
noAuthentication=false
|
||||
|
||||
# set to true to disable backups (e.g. because of limited space on server)
|
||||
noBackup=false
|
||||
|
||||
# Disable automatically generating desktop icon
|
||||
# noDesktopIcon=true
|
||||
|
||||
[Network]
|
||||
# host setting is relevant only for web deployments - set the host on which the server will listen
|
||||
# host=0.0.0.0
|
||||
# port setting is relevant only for web deployments, desktop builds run on a fixed port (changeable with TRILIUM_PORT environment variable)
|
||||
port=8080
|
||||
# true for TLS/SSL/HTTPS (secure), false for HTTP (insecure).
|
||||
https=false
|
||||
# path to certificate (run "bash bin/generate-cert.sh" to generate self-signed certificate). Relevant only if https=true
|
||||
certPath=
|
||||
keyPath=
|
||||
# setting to give trust to reverse proxies, a comma-separated list of trusted rev. proxy IPs can be specified (CIDR notation is permitted),
|
||||
# alternatively 'true' will make use of the leftmost IP in X-Forwarded-For, ultimately an integer can be used to tell about the number of hops between
|
||||
# Trilium (which is hop 0) and the first trusted rev. proxy.
|
||||
# once set, expressjs will use the X-Forwarded-For header set by the rev. proxy to determinate the real IPs of clients.
|
||||
# expressjs shortcuts are supported: loopback(127.0.0.1/8, ::1/128), linklocal(169.254.0.0/16, fe80::/10), uniquelocal(10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, fc00::/7)
|
||||
trustedReverseProxy=false
|
@ -13,15 +13,10 @@
|
||||
"url": "https://github.com/zadam/trilium.git"
|
||||
},
|
||||
"scripts": {
|
||||
"start-electron": "rimraf ./dist && tsc && ts-node ./bin/copy-dist.ts && cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron ./dist/electron.js --inspect=5858 .",
|
||||
"start-electron-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 electron --inspect=5858 .",
|
||||
"qstart-electron": "npm run qswitch-electron && TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron --inspect=5858 .",
|
||||
"start-test-server": "npm run qswitch-server; rm -rf ./data-test; cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data-test TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev TRILIUM_PORT=9999 ts-node src/www.ts",
|
||||
"switch-server": "rm -rf ./node_modules/better-sqlite3 && npm install",
|
||||
"switch-electron": "./node_modules/.bin/electron-rebuild",
|
||||
"rebuild": "electron-rebuild",
|
||||
"qswitch-server": "rm -rf ./node_modules/better-sqlite3/bin ; mkdir -p ./node_modules/better-sqlite3/build ; cp ./bin/better-sqlite3/linux-server-better_sqlite3.node ./node_modules/better-sqlite3/build/better_sqlite3.node",
|
||||
"qswitch-electron": "rm -rf ./node_modules/better-sqlite3/bin ; mkdir -p ./node_modules/better-sqlite3/build ; cp ./bin/better-sqlite3/linux-desktop-better_sqlite3.node ./node_modules/better-sqlite3/build/better_sqlite3.node",
|
||||
"build-backend-docs": "rm -rf ./docs/backend_api && ./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/backend_api src/becca/entities/*.js src/services/backend_script_api.js src/services/sql.js",
|
||||
"build-frontend-docs": "rm -rf ./docs/frontend_api && ./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/frontend_api src/public/app/entities/*.js src/public/app/services/frontend_script_api.js src/public/app/widgets/basic_widget.js src/public/app/widgets/note_context_aware_widget.js src/public/app/widgets/right_panel_widget.js",
|
||||
"build-docs": "npm run build-backend-docs && npm run build-frontend-docs",
|
||||
@ -32,10 +27,6 @@
|
||||
"postinstall": "rimraf ./node_modules/canvas && npm run rebuild"
|
||||
},
|
||||
"dependencies": {
|
||||
"@electron/remote": "2.1.2",
|
||||
"electron-debug": "3.2.0",
|
||||
"electron-dl": "3.5.2",
|
||||
"electron-window-state": "5.0.3",
|
||||
"node-abi": "3.56.0",
|
||||
"open": "8.4.1",
|
||||
"request": "2.88.2",
|
||||
@ -43,10 +34,6 @@
|
||||
"tree-kill": "1.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "25.9.8",
|
||||
"electron-builder": "24.13.3",
|
||||
"electron-packager": "17.1.2",
|
||||
"electron-rebuild": "3.2.9",
|
||||
"esm": "3.2.25",
|
||||
"jasmine": "5.1.0",
|
||||
"jsdoc": "4.0.2",
|
||||
@ -54,8 +41,5 @@
|
||||
"rcedit": "4.0.1",
|
||||
"webpack": "5.90.3",
|
||||
"webpack-cli": "5.1.4"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"electron-installer-debian": "3.2.0"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user