refactor: clean app dependencies
This commit is contained in:
parent
cfb6e03d98
commit
fd512f2cee
@ -1,30 +1,32 @@
|
||||
import { ipcRenderer, contextBridge } from "electron"
|
||||
const { ipcRenderer, contextBridge } = require("electron");
|
||||
|
||||
export default function useFacade() {
|
||||
function useFacade() {
|
||||
const interfaces = {
|
||||
install(plugins) {
|
||||
return ipcRenderer.invoke('pluggable:install', plugins)
|
||||
return ipcRenderer.invoke("pluggable:install", plugins);
|
||||
},
|
||||
uninstall(plugins, reload) {
|
||||
return ipcRenderer.invoke('pluggable:uninstall', plugins, reload)
|
||||
return ipcRenderer.invoke("pluggable:uninstall", plugins, reload);
|
||||
},
|
||||
getActive() {
|
||||
return ipcRenderer.invoke('pluggable:getActivePlugins')
|
||||
return ipcRenderer.invoke("pluggable:getActivePlugins");
|
||||
},
|
||||
update(plugins, reload) {
|
||||
return ipcRenderer.invoke('pluggable:update', plugins, reload)
|
||||
return ipcRenderer.invoke("pluggable:update", plugins, reload);
|
||||
},
|
||||
updatesAvailable(plugin) {
|
||||
return ipcRenderer.invoke('pluggable:updatesAvailable', plugin)
|
||||
return ipcRenderer.invoke("pluggable:updatesAvailable", plugin);
|
||||
},
|
||||
toggleActive(plugin, active) {
|
||||
return ipcRenderer.invoke('pluggable:togglePluginActive', plugin, active)
|
||||
return ipcRenderer.invoke("pluggable:togglePluginActive", plugin, active);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
if (contextBridge) {
|
||||
contextBridge.exposeInMainWorld('pluggableElectronIpc', interfaces)
|
||||
contextBridge.exposeInMainWorld("pluggableElectronIpc", interfaces);
|
||||
}
|
||||
|
||||
return interfaces
|
||||
return interfaces;
|
||||
}
|
||||
|
||||
module.exports = useFacade;
|
||||
|
||||
@ -6,7 +6,6 @@ import { init } from "./core/plugin-manager/pluginMgr";
|
||||
import { setupMenu } from "./utils/menu";
|
||||
import { dispose } from "./utils/disposable";
|
||||
|
||||
const isDev = require("electron-is-dev");
|
||||
const request = require("request");
|
||||
const progress = require("request-progress");
|
||||
const { autoUpdater } = require("electron-updater");
|
||||
@ -49,9 +48,9 @@ function createMainWindow() {
|
||||
},
|
||||
});
|
||||
|
||||
const startURL = isDev
|
||||
? "http://localhost:3000"
|
||||
: `file://${join(__dirname, "../renderer/index.html")}`;
|
||||
const startURL = app.isPackaged
|
||||
? `file://${join(__dirname, "../renderer/index.html")}`
|
||||
: "http://localhost:3000";
|
||||
|
||||
mainWindow.loadURL(startURL);
|
||||
|
||||
@ -60,7 +59,7 @@ function createMainWindow() {
|
||||
if (process.platform !== "darwin") app.quit();
|
||||
});
|
||||
|
||||
if (isDev) mainWindow.webContents.openDevTools();
|
||||
if (!app.isPackaged) mainWindow.webContents.openDevTools();
|
||||
}
|
||||
|
||||
function handleAppUpdates() {
|
||||
@ -127,7 +126,9 @@ function handleIPCs() {
|
||||
const basePluginPath = join(
|
||||
__dirname,
|
||||
"../",
|
||||
isDev ? "/core/pre-install" : "../app.asar.unpacked/core/pre-install"
|
||||
app.isPackaged
|
||||
? "../app.asar.unpacked/core/pre-install"
|
||||
: "/core/pre-install"
|
||||
);
|
||||
return readdirSync(basePluginPath)
|
||||
.filter((file) => extname(file) === ".tgz")
|
||||
|
||||
@ -37,22 +37,17 @@
|
||||
"postinstall": "electron-builder install-app-deps"
|
||||
},
|
||||
"dependencies": {
|
||||
"electron-is-dev": "^2.0.0",
|
||||
"electron-store": "^8.1.0",
|
||||
"electron-updater": "^6.1.4",
|
||||
"node-llama-cpp": "^2.4.1",
|
||||
"pluggable-electron": "^0.6.0",
|
||||
"request": "^2.88.2",
|
||||
"request-progress": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^6.7.3",
|
||||
"@typescript-eslint/parser": "^6.7.3",
|
||||
"concurrently": "^8.2.1",
|
||||
"electron": "26.2.1",
|
||||
"electron-builder": "^24.6.4",
|
||||
"eslint-plugin-react": "^7.33.2",
|
||||
"wait-on": "^7.0.1"
|
||||
"eslint-plugin-react": "^7.33.2"
|
||||
},
|
||||
"installConfig": {
|
||||
"hoistingLimits": "workspaces"
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
/* eslint-disable react-hooks/rules-of-hooks */
|
||||
// Make Pluggable Electron's facade available to the renderer on window.plugins
|
||||
//@ts-ignore
|
||||
const useFacade = require("pluggable-electron/facade");
|
||||
const useFacade = require("../core/plugin-manager/facade");
|
||||
useFacade();
|
||||
//@ts-ignore
|
||||
const { contextBridge, ipcRenderer } = require("electron");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user