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:
2026-07-26 17:21:55 -05:00
parent 86c19b0012
commit 628f77460b
9 changed files with 2132 additions and 46 deletions
+11
View File
@@ -0,0 +1,11 @@
target/
crates/*/src/
crates/*/Cargo.toml
crates/*/build.rs
Cargo.toml
Cargo.lock
.git/
.github/
*.rs
*.lock
*.md
+11 -4
View File
@@ -76,11 +76,18 @@ if (!fs.existsSync(mainScript)) {
} }
const nativeDir = path.join(__dirname, '..', 'crates', 'gelectron-core'); const nativeDir = path.join(__dirname, '..', 'crates', 'gelectron-core');
const platformSuffix = process.platform === 'win32' ? 'win32' : process.platform === 'darwin' ? 'darwin' : 'linux';
const archSuffix = process.arch === 'arm64' ? 'arm64' : 'x64';
const ext = process.platform === 'win32' ? 'dll' : process.platform === 'darwin' ? 'dylib' : 'so';
const napiPlatform = process.platform === 'win32' ? `${platformSuffix}-${archSuffix}-msvc` : process.platform === 'darwin' ? `${platformSuffix}-${archSuffix}` : `${platformSuffix}-${archSuffix}-gnu`;
const candidates = [ const candidates = [
path.join(nativeDir, 'release', `gelectron_core.${process.platform === 'win32' ? 'dll' : process.platform === 'darwin' ? 'dylib' : 'so'}`), path.join(nativeDir, `gelectron_core.${napiPlatform}.node`),
path.join(nativeDir, 'debug', `gelectron_core.${process.platform === 'win32' ? 'dll' : process.platform === 'darwin' ? 'dylib' : 'so'}`), path.join(__dirname, '..', `gelectron_core.${napiPlatform}.node`),
path.join(__dirname, '..', `gelectron_core.${process.platform === 'win32' ? 'dll' : process.platform === 'darwin' ? 'dylib' : 'so'}`), path.join(__dirname, '..', 'npm', napiPlatform, `gelectron_core.${napiPlatform}.node`),
path.join(__dirname, '..', 'napi-dist', process.platform, process.arch, `gelectron_core.${process.platform === 'win32' ? 'dll' : process.platform === 'darwin' ? 'dylib' : 'so'}`), path.join(nativeDir, 'release', `gelectron_core.${ext}`),
path.join(nativeDir, 'debug', `gelectron_core.${ext}`),
path.join(__dirname, '..', `gelectron_core.${ext}`),
path.join(__dirname, '..', 'napi-dist', process.platform, process.arch, `gelectron_core.${ext}`),
]; ];
let nativeAddonPath = null; let nativeAddonPath = null;
View File
+12
View File
@@ -0,0 +1,12 @@
{
"name": "gelectron-darwin-arm64",
"version": "0.1.0",
"description": "Gelectron native binary for macOS ARM64",
"main": "gelectron_core.darwin-arm64.node",
"files": [
"gelectron_core.darwin-arm64.node"
],
"os": ["darwin"],
"cpu": ["arm64"],
"license": "MIT"
}
+1934
View File
File diff suppressed because it is too large Load Diff
+27 -16
View File
@@ -7,25 +7,22 @@
"gelectron": "./cli/gelectron.js" "gelectron": "./cli/gelectron.js"
}, },
"scripts": { "scripts": {
"build": "napi build --platform --release", "build": "napi build --platform --release --package gelectron-core",
"build:debug": "napi build --platform", "build:debug": "napi build --platform --package gelectron-core",
"artifacts": "napi artifacts", "artifacts": "napi artifacts",
"prepublishOnly": "napi prepublish -t npm", "prepublishOnly": "napi prepublish -t npm --package gelectron-core",
"universal": "napi universal" "universal": "napi universal"
}, },
"napi": { "napi": {
"name": "gelectron_core", "binaryName": "gelectron_core",
"triples": { "targets": [
"defaults": true, "x86_64-apple-darwin",
"additional": [ "aarch64-apple-darwin",
"aarch64-apple-darwin", "x86_64-pc-windows-msvc",
"x86_64-apple-darwin", "aarch64-pc-windows-msvc",
"x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu",
"aarch64-pc-windows-msvc", "aarch64-unknown-linux-gnu"
"x86_64-unknown-linux-gnu", ]
"aarch64-unknown-linux-gnu"
]
}
}, },
"files": [ "files": [
"cli/", "cli/",
@@ -36,10 +33,21 @@
"electron", "electron",
"servo", "servo",
"gecko", "gecko",
"firefox",
"browser", "browser",
"desktop", "desktop",
"webview" "webview",
"chromium",
"alternative"
], ],
"repository": {
"type": "git",
"url": "https://github.com/mileswolfallen2/gelectron.git"
},
"bugs": {
"url": "https://github.com/mileswolfallen2/gelectron/issues"
},
"homepage": "https://github.com/mileswolfallen2/gelectron#readme",
"author": "mileswa1q22", "author": "mileswa1q22",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
@@ -47,5 +55,8 @@
}, },
"engines": { "engines": {
"node": ">=18.0.0" "node": ">=18.0.0"
},
"optionalDependencies": {
"gelectron-darwin-arm64": "0.1.0"
} }
} }
+8
View File
@@ -90,6 +90,14 @@ class App extends EventEmitter {
return process.env.GELECTRON_VERSION || '0.1.0'; return process.env.GELECTRON_VERSION || '0.1.0';
} }
getAppPath() {
return process.env.GELECTRON_APP_PATH || process.cwd();
}
relaunch(options = {}) {
process.exit(0);
}
getPath(name) { getPath(name) {
return this._paths[name] || this._paths.userData; return this._paths[name] || this._paths.userData;
} }
+73
View File
@@ -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
View File
@@ -17,6 +17,57 @@ const nativeImage = require('./native-image');
const safeStorage = require('./safe-storage'); const safeStorage = require('./safe-storage');
const contextBridge = require('./context-bridge'); const contextBridge = require('./context-bridge');
const webContents = require('./web-contents'); 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 = { module.exports = {
app, app,
@@ -32,6 +83,9 @@ module.exports = {
safeStorage, safeStorage,
contextBridge, contextBridge,
webContents, webContents,
autoUpdater,
AutoUpdater,
session: sessionStub,
// Aliases for common imports // Aliases for common imports
clipboard: { clipboard: {
@@ -83,32 +137,8 @@ module.exports = {
unregisterAll: () => {}, unregisterAll: () => {},
isRegistered: () => false, 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: { net: {
fetch: globalThis.fetch || require('node-fetch'), fetch: globalThis.fetch || (() => Promise.reject(new Error('fetch not available'))),
}, },
// Constants // Constants