feat: add Gelectron compatibility layer for Electron modules

- Introduced contextBridge module for exposing APIs to the main world.
- Added dialog module for handling open, save, and message dialogs.
- Created index module as a drop-in replacement for Electron's main API.
- Implemented ipcMain and ipcRenderer modules for inter-process communication.
- Developed menu and menu item modules for creating application menus.
- Added nativeImage module for handling images in various formats.
- Implemented notification module for displaying system notifications.
- Created preload-loader for injecting preload scripts into the renderer process.
- Developed runtime module for running Electron apps in a Node.js environment.
- Added safe-storage module for basic string encryption and decryption.
- Implemented shell module for opening external URLs and managing file paths.
- Created tray module for managing system tray icons and menus.
- Developed webContents utilities for interacting with browser windows.
This commit is contained in:
miles committed 2026-07-26 17:12:47 -05:00
1 parent 4af8378d72
commit 86c19b0012
39 files changed
+4687 -2

No files matched your search

+121
View File
@@ -0,0 +1,121 @@
'use strict';
/**
* Gelectron - Electron compatibility layer.
* Drop-in replacement for require('electron').
*/
const { app } = require('./app');
const { BrowserWindow } = require('./browser-window');
const ipcMain = require('./ipc-main');
const { Menu, MenuItem } = require('./menu');
const { Tray } = require('./tray');
const dialog = require('./dialog');
const shell = require('./shell');
const { Notification } = require('./notification');
const nativeImage = require('./native-image');
const safeStorage = require('./safe-storage');
const contextBridge = require('./context-bridge');
const webContents = require('./web-contents');
module.exports = {
app,
BrowserWindow,
ipcMain,
Menu,
MenuItem,
Tray,
dialog,
shell,
Notification,
nativeImage,
safeStorage,
contextBridge,
webContents,
// Aliases for common imports
clipboard: {
readText: () => '',
writeText: () => {},
readImage: () => nativeImage.createEmpty(),
writeImage: () => {},
},
screen: {
getPrimaryDisplay: () => ({
id: 0,
label: '',
bounds: { x: 0, y: 0, width: 1920, height: 1080 },
workArea: { x: 0, y: 0, width: 1920, height: 1040 },
size: { width: 1920, height: 1080 },
workAreaSize: { width: 1920, height: 1040 },
scaleFactor: 1.0,
rotation: 0,
internal: false,
touchSupport: 'unknown',
}),
getAllDisplays: () => [],
getDisplayMatching: () => null,
},
systemPreferences: {
isDarkMode: () => false,
getAccentColor: () => '#007AFF',
getColor: () => '#ffffff',
isSwipeTrackingFromScrollEventsEnabled: () => false,
subscribeNotification: () => () => {},
unsubscribeNotification: () => {},
subscribeLocalNotification: () => () => {},
unsubscribeLocalNotification: () => {},
getUserDefault: () => null,
setUserDefault: () => {},
removeUserDefault: () => {},
},
powerMonitor: {
on: () => {},
off: () => {},
once: () => {},
getSystemIdleState: () => 'active',
getSystemIdleTime: () => 0,
isInLowPowerMode: () => false,
},
globalShortcut: {
register: () => true,
unregister: () => {},
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'),
},
// Constants
IPCRenderer: {
invoke: () => Promise.resolve(),
send: () => {},
on: () => () => {},
removeListener: () => {},
},
};