mirror of
https://github.com/mileswolfallen2/gelectron.git
synced 2026-12-04 16:07:43 +00:00
fix: add autoUpdater, session stubs, npm publishing support
- Add auto-updater.js EventEmitter stub for electron-updater MacUpdater - Add session.fromPartition() stub for electron HTTP executor - Fix app.js getAppPath/getName methods - Update CLI to find napi .node files - Fix package.json napi config (binaryName/targets) - Add npm/darwin-arm64 platform package - Add .npmignore for clean publish
This commit is contained in:
1 parent
86c19b0012
commit
628f77460b
9 files changed
+2132
-46
No files matched your search
@@ -90,6 +90,14 @@ class App extends EventEmitter {
|
||||
return process.env.GELECTRON_VERSION || '0.1.0';
|
||||
}
|
||||
|
||||
getAppPath() {
|
||||
return process.env.GELECTRON_APP_PATH || process.cwd();
|
||||
}
|
||||
|
||||
relaunch(options = {}) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
getPath(name) {
|
||||
return this._paths[name] || this._paths.userData;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Gelectron - autoUpdater module (Electron compatible)
|
||||
* Stub implementation for electron-updater compatibility.
|
||||
* electron-updater uses require("electron").autoUpdater as its native backend.
|
||||
*/
|
||||
|
||||
const { EventEmitter } = require('events');
|
||||
|
||||
class AutoUpdater extends EventEmitter {
|
||||
constructor() {
|
||||
super();
|
||||
this._isUpdateAvailable = false;
|
||||
this._updateInfo = null;
|
||||
this.autoDownload = true;
|
||||
this.autoInstallOnAppQuit = false;
|
||||
this.autoRunAppAfterInstall = true;
|
||||
this._logger = console;
|
||||
}
|
||||
|
||||
getFeedURL() {
|
||||
return null;
|
||||
}
|
||||
|
||||
setFeedURL() {}
|
||||
|
||||
async checkForUpdates() {
|
||||
return {
|
||||
updateInfo: null,
|
||||
isUpdateAvailable: false,
|
||||
};
|
||||
}
|
||||
|
||||
async checkForAndNotifyIfAvailable() {
|
||||
return this.checkForUpdates();
|
||||
}
|
||||
|
||||
async downloadUpdate() {}
|
||||
|
||||
quitAndInstall(isSilent = false, isForceRunAfter = false) {
|
||||
this.emit('before-quit-for-update');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
quitAndInstallAgain(isSilent = false, isForceRunAfter = false) {
|
||||
this.quitAndInstall(isSilent, isForceRunAfter);
|
||||
}
|
||||
|
||||
async updateDownloaded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
get isUpdateActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
get updateInfo() {
|
||||
return this._updateInfo;
|
||||
}
|
||||
|
||||
get logger() {
|
||||
return this._logger;
|
||||
}
|
||||
|
||||
set logger(val) {
|
||||
this._logger = val;
|
||||
}
|
||||
}
|
||||
|
||||
const autoUpdater = new AutoUpdater();
|
||||
|
||||
module.exports = { autoUpdater, AutoUpdater };
|
||||
+55
-25
@@ -17,6 +17,57 @@ const nativeImage = require('./native-image');
|
||||
const safeStorage = require('./safe-storage');
|
||||
const contextBridge = require('./context-bridge');
|
||||
const webContents = require('./web-contents');
|
||||
const { autoUpdater, AutoUpdater } = require('./auto-updater');
|
||||
|
||||
// Session stub (electron-updater calls session.fromPartition)
|
||||
const sessionStub = {
|
||||
defaultSession: {
|
||||
cookies: {
|
||||
get: async () => [],
|
||||
set: async () => {},
|
||||
remove: async () => {},
|
||||
getSession: () => null,
|
||||
},
|
||||
protocol: {
|
||||
registerFileProtocol: () => {},
|
||||
registerHttpProtocol: () => {},
|
||||
unregisterProtocol: () => {},
|
||||
isProtocolRegistered: () => false,
|
||||
},
|
||||
setPermissionRequestHandler: () => {},
|
||||
setPermissionCheckHandler: () => {},
|
||||
webRequest: {
|
||||
onBeforeRequest: () => {},
|
||||
onHeadersReceived: () => {},
|
||||
},
|
||||
setUserAgent: () => {},
|
||||
getUserAgent: () => '',
|
||||
},
|
||||
fromPartition: (partition, options) => ({
|
||||
cookies: {
|
||||
get: async () => [],
|
||||
set: async () => {},
|
||||
remove: async () => {},
|
||||
},
|
||||
protocol: {
|
||||
registerFileProtocol: () => {},
|
||||
registerHttpProtocol: () => {},
|
||||
unregisterProtocol: () => {},
|
||||
isProtocolRegistered: () => false,
|
||||
},
|
||||
webRequest: {
|
||||
onBeforeRequest: () => {},
|
||||
onHeadersReceived: () => {},
|
||||
resolveProxy: async () => '',
|
||||
},
|
||||
setUserAgent: () => {},
|
||||
getUserAgent: () => '',
|
||||
clearCache: async () => {},
|
||||
clearStorageData: async () => {},
|
||||
setProxy: async () => {},
|
||||
getProxy: async () => ({ mode: 'direct' }),
|
||||
}),
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
app,
|
||||
@@ -32,6 +83,9 @@ module.exports = {
|
||||
safeStorage,
|
||||
contextBridge,
|
||||
webContents,
|
||||
autoUpdater,
|
||||
AutoUpdater,
|
||||
session: sessionStub,
|
||||
|
||||
// Aliases for common imports
|
||||
clipboard: {
|
||||
@@ -83,32 +137,8 @@ module.exports = {
|
||||
unregisterAll: () => {},
|
||||
isRegistered: () => false,
|
||||
},
|
||||
session: {
|
||||
defaultSession: {
|
||||
cookies: {
|
||||
get: async () => [],
|
||||
set: async () => {},
|
||||
remove: async () => {},
|
||||
getSession: () => null,
|
||||
},
|
||||
protocol: {
|
||||
registerFileProtocol: () => {},
|
||||
registerHttpProtocol: () => {},
|
||||
unregisterProtocol: () => {},
|
||||
isProtocolRegistered: () => false,
|
||||
},
|
||||
setPermissionRequestHandler: () => {},
|
||||
setPermissionCheckHandler: () => {},
|
||||
webRequest: {
|
||||
onBeforeRequest: () => {},
|
||||
onHeadersReceived: () => {},
|
||||
},
|
||||
setUserAgent: () => {},
|
||||
getUserAgent: () => '',
|
||||
},
|
||||
},
|
||||
net: {
|
||||
fetch: globalThis.fetch || require('node-fetch'),
|
||||
fetch: globalThis.fetch || (() => Promise.reject(new Error('fetch not available'))),
|
||||
},
|
||||
|
||||
// Constants
|
||||
|
||||
Reference in new issue
Block a user