diff --git a/ELECTRON_API_STATUS.md b/ELECTRON_API_STATUS.md index e598de9..1c18da7 100644 --- a/ELECTRON_API_STATUS.md +++ b/ELECTRON_API_STATUS.md @@ -1,56 +1,131 @@ # Gelectron — Electron API Compatibility Status -## FULL (2) -| Module | Notes | -|---------------|-------| -| app | All methods/properties/events, quit lifecycle, dock, badge, GPU, about panel, secure keyboard entry, window tracking | -| ipcMain | handle/handleOnce/on/once/removeHandler, full EventEmitter | +> Every Electron module tracked. Status: **full** / **partial** / **stub** / **missing** +> +> **full** = API surface complete, behavior matches Electron for common use cases +> **partial** = Core methods work, some methods are no-ops or return defaults +> **stub** = API surface exists but does nothing real +> **missing** = Not implemented at all -## PARTIAL (14) -| Module | What works | What's missing | -|---------------------|-------------------------------------------|---------------------------------------------------| -| Menu / MenuItem | buildFromTemplate/append/insert/getMenuItemById, native setApplicationMenu via muda, popup via bridge, _serialize, submenu nesting | Click events from native menu, role-based predefined items | -| BrowserWindow | create/show/hide/focus/min/max/close/destroy/setTitle/setSize/loadURL/loadFile | DevTools actually opening, navigation (back/forward), capturePage, print, printToPDF, setPosition, setBounds | -| WebContents | loadURL/loadFile/send/executeJavaScript/reload, session stub | Real session, navigation history, DevTools CDP, zoom actually applied | -| ipcRenderer | invoke/send/sendSync/on/once/removeListener | Bridge not always wired, sendSync returns undefined | -| dialog | showOpenDialog/showSaveDialog/showMessageBox/showErrorBox | Native dialogs not wired (Rust has no dialog commands) | -| shell | openExternal/openPath (Node mode) | moveItemToTrash deletes permanently, shortcut stubs | -| Notification | show via browser Notification API | No native OS notification integration | -| nativeImage | createFromPath/Buffer/DataURL, toDataURL, getSize | resize/crop don't transform pixels, toPNG/toJPEG bugs | -| contextBridge | exposeInMainWorld with deep freeze | No real world isolation, no proxy serialization | -| webContents (utils) | getAllWebContents/getFocusedWebContents | Minimal | -| net | fetch delegates to globalThis.fetch | No net.request(), no ClientRequest API | -| process (polyfill) | pid/argv/env/platform/versions/cwd/nextTick | memoryUsage/cpuUsage/uptime/kill missing | -| contextIsolation | webPreferences.contextIsolation stored | No actual V8 isolate separation | +--- -## STUB (12) -| Module | Implementation | -|------------------|-------------------------------------------------------------| -| Tray | API surface present, no native system tray | -| safeStorage | base64 encoding, not real encryption | -| autoUpdater | API surface for electron-updater compat, no actual updates | -| session | defaultSession + fromPartition stubs, all no-ops | -| clipboard | readText/writeText no-ops | -| screen | Hardcoded 1920x1080 primary display | -| systemPreferences| Hardcoded dark mode / accent color | -| powerMonitor | getSystemIdleState returns 'active', no real monitoring | -| globalShortcut | register always returns true, does nothing | -| updater | Covered by autoUpdater stub | +## Browser (Main Process) Modules -## MISSING (9) -| Module | Notes | -|------------------|------------------------------------------| -| nativeTheme | No theme detection | -| netLog | No network log capture | -| protocol | No custom protocol registration | -| crashReporter | No crash reporting | -| desktopCapturer | No screen/window capture sources | -| pushNotifications| No push notification handling | -| utilityProcess | No utility/forked process | -| ShareMenu | No share menu (macOS) | -| TouchBar | No Touch Bar (macOS) | +| # | Module | File | webview-bundle | index.js | Status | Notes | +|---|--------|------|----------------|----------|--------|-------| +| 1 | app | YES | YES | YES | **full** | All methods, properties, events, quit lifecycle, dock, badge, GPU, about panel, secure keyboard, window tracking | +| 2 | autoUpdater | YES | YES | YES | **stub** | API surface for electron-updater compat, no actual updates | +| 3 | BaseWindow | NO | NO | NO | **missing** | Parent class for BrowserWindow, not implemented | +| 4 | BrowserView | NO | NO | NO | **missing** | Deprecated in favor of WebContentsView | +| 5 | BrowserWindow | YES | YES | YES | **partial** | create/show/hide/focus/min/max/close/destroy/setTitle/setSize/loadURL/loadFile. Missing: DevTools, navigation, capturePage, print, printToPDF | +| 6 | clipboard | NO | inline | YES | **stub** | readText/writeText no-ops, missing readHTML/writeHTML/readBookmark etc. | +| 7 | contentTracing | NO | NO | NO | **missing** | Tracing/recording profiling data | +| 8 | crashReporter | NO | NO | NO | **missing** | Crash upload to server | +| 9 | desktopCapturer | NO | NO | NO | **missing** | Screen/window capture source enumeration | +| 10 | dialog | YES | YES | YES | **partial** | showOpenDialog/showSaveDialog/showMessageBox/showErrorBox. Native dialogs not wired | +| 11 | globalShortcut | NO | inline | YES | **stub** | register() always returns true, does nothing | +| 12 | ipcMain | YES | YES | YES | **full** | handle/handleOnce/on/once/removeHandler, full EventEmitter | +| 13 | ImageView | NO | NO | NO | **missing** | New in Electron 33+, image display view | +| 14 | inAppPurchase | NO | NO | NO | **missing** | macOS App Store in-app purchases | +| 15 | Menu | YES | YES | YES | **partial** | buildFromTemplate/append/insert/getMenuItemById, native setApplicationMenu via muda, _serialize. Missing: click events from native menu, role-based predefined items | +| 16 | MenuItem | YES | YES | YES | **partial** | All properties present (id/label/type/role/accelerator/enabled/visible/checked/submenu/click). Missing: role auto-behavior | +| 17 | MessageChannelMain | NO | NO | NO | **missing** | MessagePort-based IPC between main/renderer | +| 18 | nativeImage | YES | YES | YES | **partial** | createFromPath/Buffer/DataURL, toDataURL, getSize. Missing: resize/crop pixel transform, proper toPNG/toJPEG | +| 19 | nativeTheme | NO | NO | NO | **missing** | Dark mode detection, shouldUseDarkColors, themeSource | +| 20 | net | NO | inline | YES | **partial** | fetch delegates to globalThis.fetch. Missing: net.request(), ClientRequest API | +| 21 | netLog | NO | NO | NO | **missing** | Network log capture | +| 22 | Notification | YES | YES | YES | **partial** | API surface complete, show via browser Notification API if available. No native OS integration | +| 23 | powerMonitor | NO | inline | YES | **stub** | getSystemIdleState returns 'active', no real monitoring | +| 24 | powerSaveBlocker | NO | NO | NO | **missing** | Prevent system sleep | +| 25 | protocol | NO | inline (session) | NO | **missing** | Custom protocol registration (standalone module). Session stubs exist | +| 26 | pushNotifications | NO | NO | NO | **missing** | macOS push notification registration | +| 27 | safeStorage | YES | YES | YES | **stub** | Base64 encoding, not real encryption | +| 28 | screen | NO | inline | YES | **stub** | Hardcoded 1920x1080 primary display | +| 29 | ServiceWorkerMain | NO | NO | NO | **missing** | Service worker management in main process | +| 30 | session | NO | inline | YES | **stub** | defaultSession + fromPartition stubs, all no-ops | +| 31 | sharedTexture | NO | NO | NO | **missing** | Shared texture between processes | +| 32 | ShareMenu | NO | NO | NO | **missing** | macOS share sheet | +| 33 | shell | YES | YES | YES | **partial** | openExternal/openPath work in Node.js mode. moveItemToTrash deletes permanently, shortcut stubs | +| 34 | systemPreferences | NO | inline | YES | **stub** | Hardcoded dark mode / accent color | +| 35 | TouchBar | NO | NO | NO | **missing** | macOS Touch Bar. Sub-classes: TouchBarButton, TouchBarColorPicker, TouchBarGroup, TouchBarLabel, TouchBarOtherItemsProxy, TouchBarPopover, TouchBarScrubber, TouchBarSegmentedControl, TouchBarSlider, TouchBarSpacer | +| 36 | Tray | YES | YES | YES | **stub** | API surface present, no native system tray | +| 37 | utilityProcess | NO | NO | NO | **missing** | Fork utility child processes | +| 38 | View | NO | NO | NO | **missing** | Base View class for embedding | +| 39 | webContents | YES | YES | YES | **partial** | loadURL/loadFile/send/executeJavaScript/reload, session stub. Missing: navigation history, DevTools CDP, zoom, print, capturePage | +| 40 | WebContentsView | NO | NO | NO | **missing** | View-based content embedding | +| 41 | webFrameMain | NO | NO | NO | **missing** | Main-process webFrame for frame control | -## Missing from existing modules -- BrowserWindow: webContents.debugger, setOpacity/getOpacity, setProgressBar actual display -- app: render-process-gone, child-process-gone events (require real process monitoring) -- Menu: native menu click events not wired back to JS, no role-based predefined items (copy/paste/undo etc.) +## Renderer Process Modules + +| # | Module | File | webview-bundle | index.js | Status | Notes | +|---|--------|------|----------------|----------|--------|-------| +| 42 | clipboard (renderer) | NO | inline | YES | **stub** | Same as main process stub | +| 43 | contextBridge | YES | YES | YES | **partial** | exposeInMainWorld with deep freeze. No real world isolation | +| 44 | crashReporter (renderer) | NO | NO | NO | **missing** | Renderer-side crash reporter | +| 45 | ipcRenderer | YES | NO (inline) | NO (via require hook) | **partial** | invoke/send/sendSync/on/once/removeListener. Bridge not always wired | +| 46 | sharedTexture (renderer) | NO | NO | NO | **missing** | Renderer-side shared texture | +| 47 | webFrame | NO | NO | NO | **missing** | setZoomFactor/setZoomLevel/insertCSS/executeJavaScript in frame context | +| 48 | webUtils | NO | NO | NO | **missing** | Renderer-side utilities (process | + +## Common Modules (Both Processes) + +| # | Module | File | webview-bundle | index.js | Status | Notes | +|---|--------|------|----------------|----------|--------|-------| +| 49 | nativeImage | YES | YES | YES | **partial** | createFromPath/Buffer/DataURL, toDataURL, getSize. Missing: resize/crop transform | +| 50 | shell | YES | YES | YES | **partial** | openExternal/openPath in Node mode | + +## Deprecated / Internal + +| # | Module | Status | Notes | +|---|--------|--------|-------| +| 51 | BrowserView | **missing** | Deprecated, replaced by WebContentsView | +| 52 | remote | **missing** | Removed in Electron 14+ | +| 53 | webviewTag | **missing** | Deprecated, replaced by BrowserView/WebContentsView | +| 54 | process (polyfill) | **partial** | WebView mode polyfill: pid/argv/env/platform/versions/cwd/nextTick. Missing: memoryUsage/cpuUsage/uptime/kill | +| 55 | contextIsolation | **stub** | webPreferences.contextIsolation stored but no actual V8 isolate separation | + +## Additional APIs from Electron Docs + +| # | API | Status | Notes | +|---|-----|--------|-------| +| 56 | navigation-history | **missing** | Navigation history API | +| 57 | parent-port | **missing** | UtilityProcess communication port | +| 58 | web-request | **missing** | Intercept/modify HTTP requests | +| 59 | web-socket | **missing** | WebSocket server | +| 60 | window-open | **missing** | window.open() handling | +| 61 | local-ai-handler | **missing** | Local AI model handler (new) | + +--- + +## Summary + +| Status | Count | Modules | +|--------|-------|---------| +| **full** | 2 | app, ipcMain | +| **partial** | 12 | BrowserWindow, Menu, MenuItem, dialog, shell, Notification, nativeImage, contextBridge, webContents, ipcRenderer, net, process | +| **stub** | 9 | Tray, safeStorage, autoUpdater, session, clipboard, screen, systemPreferences, powerMonitor, globalShortcut | +| **missing** | 38 | BaseWindow, BrowserView, contentTracing, crashReporter, desktopCapturer, ImageView, inAppPurchase, MessageChannelMain, nativeTheme, netLog, powerSaveBlocker, protocol, pushNotifications, ServiceWorkerMain, sharedTexture, ShareMenu, TouchBar (+10 sub-classes), utilityProcess, View, WebContentsView, webFrameMain, webFrame, webUtils, crashReporter (renderer), sharedTexture (renderer), remote, webviewTag, navigation-history, parent-port, web-request, web-socket, window-open | +| **Total** | **60** | | | + +## Rust Bridge (main.rs ToRust commands) + +These commands are implemented on the Rust side and can be triggered from the WebView: + +| Command | Status | Notes | +|---------|--------|-------| +| create-window | YES | Creates a new tao+wry window | +| destroy-window | YES | Removes window from state | +| load-url | YES | Navigates webview to URL | +| load-file | YES | Rebuilds WebView with file:// URL | +| set-title | YES | Updates window title | +| set-size | YES | Updates window inner size | +| show / hide / focus | YES | Window visibility | +| minimize / maximize | YES | Window state | +| close | YES | Closes window | +| eval-js | YES | Execute JavaScript in webview | +| ipc-message | YES | Forward IPC to renderer | +| quit | YES | Exit event loop | +| relaunch | YES | Spawn new process, exit | +| set-application-menu | YES | Set native menu via muda (macOS: init_for_nsapp) | +| popup-menu | YES | Show context menu via muda | +| close-popup-menu | YES | Close context menu | diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/Info.plist b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/Info.plist deleted file mode 100644 index fda3824..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDisplayName - GeelectronDemo - CFBundleExecutable - GeelectronDemo - CFBundleIdentifier - com.gelectron.geelectrondemo - CFBundleName - GeelectronDemo - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0.0 - CFBundleVersion - 1.0.0 - NSHighResolutionCapable - - NSRequiresAquaSystemAppearance - - - \ No newline at end of file diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/GeelectronDemo b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/GeelectronDemo deleted file mode 100755 index 1e0631c..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/GeelectronDemo +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -DIR="$(cd "$(dirname "$0")" && pwd)" -export PATH="$DIR:$PATH" -export GELECTRON_NATIVE=1 -exec "$DIR/gelectron-bin" "$@" diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/app.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/app.js deleted file mode 100644 index 6a3c000..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/app.js +++ /dev/null @@ -1,352 +0,0 @@ -'use strict'; - -/** - * Gelectron - app module (Electron compatible) - * - * Full implementation matching the Electron app API surface. - * Events: ready, second-instance, activate, window-all-closed, before-quit, - * will-quit, quit, focus, blur, browser-window-focus, browser-window-blur, - * web-contents-created, render-process-gone, child-process-gone, - * keyboard-visibility-changed, new-window-for-tab - */ - -const { EventEmitter } = require('events'); -const path = require('path'); - -class App extends EventEmitter { - constructor() { - super(); - this._ready = false; - this._windowCount = 0; - this._relaunchOptions = null; - this._relaunching = false; - this._aboutPanelOptions = {}; - this._badgeCount = 0; - this._secureKeyboardEntryEnabled = false; - this._userAgent = null; - this._name = 'Gelectron App'; - this._names = null; - - const os = require('os'); - const home = os.homedir(); - this._paths = { - home, - appData: path.join(home, process.platform === 'win32' ? '' : '.', process.platform === 'darwin' ? 'Library/Application Support' : 'config', 'gelectron'), - userData: path.join(home, process.platform === 'win32' ? '' : '.', process.platform === 'darwin' ? 'Library/Application Support' : 'config', 'gelectron'), - desktop: path.join(home, 'Desktop'), - documents: path.join(home, 'Documents'), - downloads: path.join(home, 'Downloads'), - temp: os.tmpdir(), - exe: process.execPath, - module: __dirname, - crashDumps: path.join(home, process.platform === 'win32' ? '' : '.', process.platform === 'darwin' ? 'Library/Application Support' : 'config', 'gelectron', 'crashDumps'), - logs: path.join(home, process.platform === 'win32' ? '' : '.', process.platform === 'darwin' ? 'Library/Application Support' : 'config', 'gelectron', 'logs'), - }; - - this._commandLine = new Map(); - this._dock = process.platform === 'darwin' ? { - setIcon: (icon) => {}, - bounce: () => 0, - cancelBounce: () => {}, - setBadge: () => {}, - getBadge: () => '', - hide: () => {}, - show: () => {}, - isVisible: () => true, - setMenu: () => {}, - setBadgeCount: (count) => { return 0; }, - getBadgeCount: () => 0, - setThumbnail: () => {}, - setThumbnailClip: () => {}, - setThumbnailToolTip: () => {}, - } : null; - - this._argv = process.argv.slice(); - - // Emit 'ready' automatically on the next tick, matching real Electron - process.nextTick(() => { - if (!this._ready) { - this._ready = true; - this.emit('ready'); - } - }); - } - - // ─── Properties ────────────────────────────────────────────── - - get commandLine() { - const self = this; - return { - appendSwitch: (name, value) => { self._commandLine.set(name, value || ''); }, - removeSwitch: (name) => { self._commandLine.delete(name); }, - getSwitch: (name) => { return self._commandLine.get(name) || ''; }, - hasSwitch: (name) => { return self._commandLine.has(name); }, - }; - } - - get dock() { return this._dock; } - get argv() { return this._argv; } - - get isPackaged() { - return !process.argv[0].includes('node') && !process.argv[0].includes('gelectron'); - } - - get name() { return this._name; } - set name(val) { this._name = val || 'Gelectron App'; } - - get version() { return process.env.GELECTRON_VERSION || '0.1.0'; } - - get locale() { return this.getLocale(); } - get userAgent() { return this.getUserAgent(); } - - get isReady() { return this._ready; } - - get appPath() { return this.getAppPath(); } - - // ─── Core Methods ──────────────────────────────────────────── - - getAppPath() { return process.env.GELECTRON_APP_PATH || process.cwd(); } - - getPath(name) { - if (name === 'app' || name === 'appData' || name === 'userData') { - return this._paths[name === 'app' ? 'appData' : name] || this._paths.userData; - } - return this._paths[name] || this._paths.userData; - } - - setPath(name, value) { this._paths[name] = value; } - - getName() { return this._name; } - setName(name) { this._name = name; } - - getVersion() { return this.version; } - - getLocale() { return Intl.DateTimeFormat().resolvedOptions().locale || 'en-US'; } - - getUserAgent() { - return this._userAgent || `Gelectron/${this.version} (${process.platform} ${process.arch}) Node.js/${process.versions ? process.versions.node : 'unknown'}`; - } - - setUserAgent(userAgent) { this._userAgent = userAgent || null; } - - getPathForProtocol(protocol) { return null; } - - getApplicationInfoForProtocol(protocol) { - return Promise.resolve({ - defaultIcon: null, - icon: null, - }); - } - - // ─── Lifecycle ─────────────────────────────────────────────── - - async whenReady() { - if (this._ready) return Promise.resolve(); - return new Promise((resolve) => { this.once('ready', resolve); }); - } - - isReady() { return this._ready; } - - requestSingleInstanceLock() { return true; } - acquireSingleInstanceLock() { return true; } - releaseSingleInstanceLock() {} - - quit(exitCode = 0) { - if (this.listenerCount('before-quit') > 0 || this.listenerCount('will-quit') > 0) { - this.emit('before-quit'); - this.emit('will-quit'); - } - this.emit('quit', exitCode); - process.exit(exitCode); - } - - exit(exitCode = 0) { - if (this._ready) { - this.emit('before-quit'); - this.emit('will-quit'); - } - this.emit('quit', exitCode); - process.exit(exitCode); - } - - relaunch(options = {}) { - this._relaunchOptions = options; - this._relaunching = true; - this.emit('before-quit'); - const { spawn } = require('child_process'); - const execPath = options.execPath || process.execPath; - const args = options.args || process.argv.slice(1); - spawn(execPath, args, { - detached: true, - stdio: 'ignore', - env: process.env, - }).unref(); - process.exit(0); - } - - // ─── Window Management Helpers ─────────────────────────────── - - focus() { - if (process.platform === 'darwin') { this.dock && this.dock.show(); } - this.emit('focus'); - } - - hide() { if (this.dock) this.dock.hide(); this.emit('blur'); } - show() { if (this.dock) this.dock.show(); this.emit('focus'); } - isVisible() { return this.dock ? this.dock.isVisible() : true; } - isHidden() { return this.dock ? !this.dock.isVisible() : false; } - - // ─── App Metrics / GPU ────────────────────────────────────── - - getAppMetrics() { - return [ - { - creationTime: Date.now() - (process.uptime() * 1000) | 0, - pid: process.pid, - rid: 0, - type: 'Browser', - memory: { workingSetSize: 0, peakWorkingSetSize: 0, privateBytes: 0, sharedBytes: 0 }, - sandboxed: false, - }, - ]; - } - - getGPUInfo(infoType) { - if (infoType === 'basic') { - return Promise.resolve({ - gpuDevice: [{ driverVendor: 'Gelectron', driverVersion: '0.0.0', driverDate: '', active: false }], - GPUActive: false, - }); - } - return Promise.resolve({ - gpuDevice: [{ driverVendor: 'Gelectron', driverVersion: '0.0.0', driverDate: '', active: false }], - GPUActive: false, - auxAttributes: {}, - gpuDriver: 'Gelectron', - gpuDriverVersion: '0.0.0', - gpuWorkingSetSize: 0, - }); - } - - getGPUFeatureStatus() { - return { - gpuCompositing: 'disabled', - multipleRasterThreads: 'disabled', - nativeGpuMemoryBuffers: 'disabled', - rasterization: 'disabled', - smoothScrolling: 'disabled', - videoDecode: 'disabled', - videoEncode: 'disabled', - webgl: 'disabled', - webgl2: 'disabled', - }; - } - - disableHardwareAcceleration() {} - disableDomainBlockingFor3DAPIs() {} - - // ─── Badge ─────────────────────────────────────────────────── - - setBadgeCount(count) { - this._badgeCount = count || 0; - if (this.dock) this.dock.setBadgeCount(this._badgeCount); - return this._badgeCount; - } - - getBadgeCount() { return this._badgeCount; } - - // ─── Recent Documents ──────────────────────────────────────── - - addRecentDocument(path) {} - clearRecentDocuments() {} - setRecentDocumentLabel(label) {} - - // ─── App User Model ID ────────────────────────────────────── - - setAppUserModelId(id) {} - getAppUserModelId() { return ''; } - - // ─── Login Items ───────────────────────────────────────────── - - getLoginItemSettings() { - return { - openAtLogin: false, - openAsHidden: false, - launchAtLogin: false, - launchItems: [], - }; - } - - setLoginItemSettings(settings) {} - - // ─── Applications Folder ───────────────────────────────────── - - isInApplicationsFolder() { return true; } - moveToApplicationsFolder() {} - - // ─── File Icons ────────────────────────────────────────────── - - getFileIcon(path, options, callback) { - if (typeof options === 'function') { callback = options; } - if (callback) callback(null, null); - } - - // ─── About Panel ───────────────────────────────────────────── - - setAboutPanelOptions(options = {}) { - this._aboutPanelOptions = { - applicationName: this._name, - applicationVersion: this.version, - copyright: '', - credits: '', - authors: [], - website: '', - iconPath: '', - ...options, - }; - } - - getAboutPanelOptions() { - return { ...this._aboutPanelOptions }; - } - - // ─── Certificate Trust ─────────────────────────────────────── - - async showCertificateTrustDialog() {} - - // ─── Secure Keyboard Entry ────────────────────────────────── - - setSecureKeyboardEntryEnabled(enabled) { - this._secureKeyboardEntryEnabled = !!enabled; - } - - isSecureKeyboardEntryEnabled() { - return this._secureKeyboardEntryEnabled; - } - - // ─── Window Tracking ──────────────────────────────────────── - - _trackWindow() { this._windowCount++; } - - _untrackWindow() { - this._windowCount--; - if (this._windowCount <= 0) { - this._windowCount = 0; - this.emit('window-all-closed'); - } - } - - getWindowCount() { return this._windowCount; } - - // ─── EventEmitter overrides (return this for chaining) ────── - - on(eventName, listener) { super.on(eventName, listener); return this; } - once(eventName, listener) { super.once(eventName, listener); return this; } - addListener(eventName, listener) { super.addListener(eventName, listener); return this; } - removeListener(eventName, listener) { super.removeListener(eventName, listener); return this; } - removeAllListeners(eventName) { super.removeAllListeners(eventName); return this; } -} - -const app = new App(); - -module.exports = { app, App }; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/auto-updater.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/auto-updater.js deleted file mode 100644 index 3c98fe6..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/auto-updater.js +++ /dev/null @@ -1,84 +0,0 @@ -'use strict'; - -/** - * Gelectron - autoUpdater module (Electron compatible) - * Stub implementation for electron-updater compatibility. - * - * electron-updater's MacUpdater / NsisUpdater / AppImageUpdater all - * access `require("electron").autoUpdater` and expect it to be an - * EventEmitter with the native Electron autoUpdater API surface: - * .on("error", …), .on("update-downloaded", …) - * .setFeedURL(), .getFeedURL() - * .checkForUpdates() - * .quitAndInstall() - * .removeListener() - */ - -const { EventEmitter } = require('events'); - -class AutoUpdater extends EventEmitter { - constructor() { - super(); - this._isUpdateAvailable = false; - this._updateInfo = null; - this._feedURL = null; - this.autoDownload = true; - this.autoInstallOnAppQuit = false; - this.autoRunAppAfterInstall = true; - this._logger = console; - } - - getFeedURL() { - return this._feedURL; - } - - setFeedURL(options) { - this._feedURL = options; - } - - 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 }; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/browser-window.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/browser-window.js deleted file mode 100644 index c98e35e..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/browser-window.js +++ /dev/null @@ -1,389 +0,0 @@ -'use strict'; - -/** - * Gelectron - BrowserWindow module (Electron compatible) - */ - -const { EventEmitter } = require('events'); -const path = require('path'); -const { bridge, isNative } = require('./native-bridge'); -const { app } = require('./app'); - -class WebContents extends EventEmitter { - constructor(id) { - super(); - this.id = id; - this._url = ''; - this._title = ''; - this._isLoading = false; - this._zoomFactor = 1.0; - this._zoomLevel = 0; - this._userAgent = ''; - this._audioMuted = false; - } - - get URL() { return this._url; } - get isLoading() { return this._isLoading; } - get title() { return this._title; } - - get session() { - return { - id: `session-${this.id}`, - cookies: { - get: async () => [], - set: async () => {}, - remove: async () => {}, - }, - protocol: { - registerFileProtocol: () => {}, - registerHttpProtocol: () => {}, - unregisterProtocol: () => {}, - isProtocolRegistered: () => false, - }, - setPermissionRequestHandler: () => {}, - setPermissionCheckHandler: () => {}, - webRequest: { onBeforeRequest: () => {}, onHeadersReceived: () => {} }, - setUserAgent: () => {}, - getUserAgent: () => '', - }; - } - - get processId() { return process.pid; } - - loadURL(targetUrl) { - this._url = targetUrl; - this._isLoading = true; - this.emit('did-start-loading'); - if (isNative) { - bridge.loadUrl(this.id, targetUrl); - } - setTimeout(() => { - this._isLoading = false; - this.emit('did-stop-loading'); - this.emit('did-finish-load'); - this.emit('dom-ready'); - }, isNative ? 500 : 100); - return Promise.resolve(); - } - - loadFile(filePath) { - const url = `file://${path.resolve(filePath)}`; - this._url = url; - this._isLoading = true; - this.emit('did-start-loading'); - if (isNative) { - bridge.loadFile(this.id, filePath); - } - setTimeout(() => { - this._isLoading = false; - this.emit('did-stop-loading'); - this.emit('did-finish-load'); - this.emit('dom-ready'); - }, isNative ? 500 : 100); - return Promise.resolve(); - } - - reload() { - this._isLoading = true; - this.emit('did-start-loading'); - if (isNative && this._url) { - bridge.loadUrl(this.id, this._url); - } - setTimeout(() => { - this._isLoading = false; - this.emit('did-stop-loading'); - this.emit('did-finish-load'); - }, 50); - return Promise.resolve(); - } - - canGoBack() { return false; } - canGoForward() { return false; } - goBack() {} - goForward() {} - - executeJavaScript(code, userGesture = true) { - if (isNative) { - bridge.evalJs(this.id, code); - } - return Promise.resolve(null); - } - - insertCSS(css) { return Promise.resolve(0); } - insertJS(code, hasUserGesture = true) { return this.executeJavaScript(code, hasUserGesture); } - - send(channel, ...args) { - if (isNative) { - bridge.sendToRenderer(this.id, channel, ...args); - } else { - console.log(`[gelectron] webContents.send('${channel}')`); - } - } - - sendInputEvent() {} - - setZoomFactor(factor) { this._zoomFactor = factor; } - getZoomFactor() { return this._zoomFactor; } - setZoomLevel(level) { this._zoomLevel = level; } - getZoomLevel() { return this._zoomLevel; } - setUserAgent(ua) { this._userAgent = ua; } - getUserAgent() { return this._userAgent; } - setAudioMuted(muted) { this._audioMuted = muted; } - isAudioMuted() { return this._audioMuted; } - - openDevTools() { console.log('[gelectron] openDevTools'); } - closeDevTools() {} - isDevToolsOpened() { return false; } - toggleDevTools() {} - inspectElement() {} - - setIgnoreMenuShortcuts() {} - setWindowOpenHandler() { return { action: 'deny' }; } - setPermissionRequestHandler() {} - setCertificateVerifyProc() {} - setBackgroundColor() {} - isCrashed() { return false; } - capturePage() { return Promise.resolve(null); } - getResourceUsage() { return { images: 0, scripts: 0, css: 0, xhr: 0, webgl: 0 }; } - type() { return 'backgroundPage'; } - focused() { return false; } - isFocused() { return false; } - destroy() {} -} - -class BrowserWindow extends EventEmitter { - static _windows = new Map(); - static _nextId = 1; - - constructor(options = {}) { - super(); - - this.id = BrowserWindow._nextId++; - this._options = { - width: options.width || 800, - height: options.height || 600, - minWidth: options.minWidth || 0, - minHeight: options.minHeight || 0, - maxWidth: options.maxWidth || 0, - maxHeight: options.maxHeight || 0, - title: options.title || 'Gelectron', - backgroundColor: options.backgroundColor || '#ffffff', - show: options.show !== false, - frame: options.frame !== false, - resizable: options.resizable !== false, - minimizable: options.minimizable !== false, - maximizable: options.maximizable !== false, - closable: options.closable !== false, - fullscreen: options.fullscreen || false, - alwaysOnTop: options.alwaysOnTop || false, - transparent: options.transparent || false, - decorations: options.decorations !== false, - icon: options.icon || null, - titleBarStyle: options.titleBarStyle || 'default', - trafficLightPosition: options.trafficLightPosition || null, - vibrancy: options.vibrancy || null, - webPreferences: { - preload: options.webPreferences?.preload || null, - contextIsolation: options.webPreferences?.contextIsolation !== false, - nodeIntegration: options.webPreferences?.nodeIntegration || false, - sandbox: options.webPreferences?.sandbox || false, - devTools: options.webPreferences?.devTools !== false, - webSecurity: options.webPreferences?.webSecurity !== false, - allowRunningInsecureContent: options.webPreferences?.allowRunningInsecureContent || false, - experimentalFeatures: options.webPreferences?.experimentalFeatures || false, - ...options.webPreferences, - }, - }; - - this._url = ''; - this._isDestroyed = false; - this._isVisible = this._options.show; - this._isMinimized = false; - this._isMaximized = false; - this._isFullScreen = this._options.fullscreen; - - this.webContents = new WebContents(this.id); - - BrowserWindow._windows.set(this.id, this); - - if (typeof app._trackWindow === 'function') { - app._trackWindow(); - } - - if (isNative) { - bridge.createWindow(this.id, { - width: this._options.width, - height: this._options.height, - title: this._options.title, - show: this._options.show, - resizable: this._options.resizable, - alwaysOnTop: this._options.alwaysOnTop, - fullscreen: this._options.fullscreen, - }); - } - - if (this._options.show) { - process.nextTick(() => { - if (!this._isDestroyed) { - this.emit('ready-to-show'); - this.show(); - } - }); - } - } - - static fromWebContents(webContents) { - for (const win of BrowserWindow._windows.values()) { - if (win.webContents && win.webContents.id === webContents.id) return win; - } - return null; - } - - static getAllWindows() { - return Array.from(BrowserWindow._windows.values()).filter((w) => !w.isDestroyed()); - } - - static getFocusedWindow() { return null; } - - static fromId(id) { return BrowserWindow._windows.get(id) || null; } - - static addExtension() {} - static removeExtension() {} - static getExtensions() { return {}; } - - loadURL(targetUrl) { - this._url = targetUrl; - if (isNative) { - bridge.loadUrl(this.id, targetUrl); - } - return this.webContents.loadURL(targetUrl); - } - - loadFile(filePath) { - return this.webContents.loadFile(filePath); - } - - show() { - if (this._isDestroyed) return; - this._isVisible = true; - this._isMinimized = false; - if (isNative) bridge.showWindow(this.id); - this.emit('show'); - } - - hide() { - if (this._isDestroyed) return; - this._isVisible = false; - if (isNative) bridge.hideWindow(this.id); - this.emit('hide'); - } - - close() { - if (this._isDestroyed) return; - this.emit('close'); - this.destroy(); - } - - destroy() { - if (this._isDestroyed) return; - this._isDestroyed = true; - if (isNative) bridge.destroyWindow(this.id); - BrowserWindow._windows.delete(this.id); - if (typeof app._untrackWindow === 'function') { - app._untrackWindow(); - } - this.emit('closed'); - } - - focus() { if (!this._isDestroyed) { if (isNative) bridge.focusWindow(this.id); this.emit('focus'); } } - blur() {} - - minimize() { if (!this._isDestroyed) { this._isMinimized = true; if (isNative) bridge.minimizeWindow(this.id); this.emit('minimize'); } } - maximize() { if (!this._isDestroyed) { this._isMaximized = true; if (isNative) bridge.maximizeWindow(this.id); this.emit('maximize'); } } - unmaximize() { if (!this._isDestroyed) { this._isMaximized = false; this.emit('unmaximize'); } } - restore() { if (!this._isDestroyed) { this._isMinimized = false; this._isMaximized = false; this.emit('restore'); } } - - setFullScreen(flag) { this._isFullScreen = flag; this.emit('enter-full-screen'); } - isFullScreen() { return this._isFullScreen; } - isMinimized() { return this._isMinimized; } - isMaximized() { return this._isMaximized; } - isVisible() { return this._isVisible; } - isDestroyed() { return this._isDestroyed; } - isFocused() { return false; } - isNormal() { return !this._isMinimized && !this._isMaximized && !this._isFullScreen; } - - setAlwaysOnTop(flag) { this._options.alwaysOnTop = flag; } - isAlwaysOnTop() { return this._options.alwaysOnTop; } - - setPosition(x, y) {} - getPosition() { return [0, 0]; } - setSize(w, h) { this._options.width = w; this._options.height = h; } - getSize() { return [this._options.width, this._options.height]; } - setMinimumSize(w, h) { this._options.minWidth = w; this._options.minHeight = h; } - getMinimumSize() { return [this._options.minWidth, this._options.minHeight]; } - setMaximumSize(w, h) { this._options.maxWidth = w; this._options.maxHeight = h; } - getMaximumSize() { return [this._options.maxWidth, this._options.maxHeight]; } - - setResizable(v) { this._options.resizable = v; } - isResizable() { return this._options.resizable; } - setMovable() {} - isMovable() { return true; } - setMinimizable(v) { this._options.minimizable = v; } - isMinimizable() { return this._options.minimizable; } - setMaximizable(v) { this._options.maximizable = v; } - isMaximizable() { return this._options.maximizable; } - setClosable(v) { this._options.closable = v; } - isClosable() { return this._options.closable; } - - setTitle(title) { this._options.title = title; this.webContents._title = title; if (isNative) bridge.setTitle(this.id, title); } - getTitle() { return this._options.title; } - - setSkipTaskbar() {} - setKiosk() {} - isKiosk() { return false; } - - center() {} - setBounds() {} - getBounds() { return { x: 0, y: 0, width: this._options.width, height: this._options.height }; } - setSimpleFullScreen() {} - isSimpleFullScreen() { return false; } - setAutoHideCursor() {} - setContentBounds() {} - getContentBounds() { return this.getBounds(); } - isEnabled() { return true; } - setEnabled() {} - setProgressBar() {} - setOverlayIcon() {} - setVisibleOnAllWorkspaces() {} - isVisibleOnAllWorkspaces() { return false; } - setVibrancy() {} - getNativeWindowHandle() { return Buffer.alloc(0); } - setHasShadow() {} - hasShadow() { return true; } - setOpacity() {} - getOpacity() { return 1.0; } - setThumbarButtons() {} - setThumbnailClip() {} - setThumbnailToolTip() {} - setAppDetails() {} - setForeground() {} - flashFrame() {} - setIcon() {} - setBackgroundColor(c) { this._options.backgroundColor = c; } - getBackgroundColor() { return this._options.backgroundColor; } - - capturePage() { return this.webContents.capturePage(); } - print() { console.log('[gelectron] print called'); } - printToPDF() { return Promise.resolve(Buffer.alloc(0)); } - setParentWindow() {} - getParentWindow() { return null; } - getChildWindows() { return []; } - selectPreviousTab() {} - selectNextTab() {} - mergeAllWindows() {} - moveTabToNewWindow() {} - toggleTabBar() {} - addTabbedWindow() {} -} - -module.exports = { BrowserWindow, WebContents }; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/context-bridge.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/context-bridge.js deleted file mode 100644 index 73ab567..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/context-bridge.js +++ /dev/null @@ -1,33 +0,0 @@ -'use strict'; - -/** - * Gelectron - contextBridge module (Electron compatible) - */ - -const contextBridge = { - exposeInMainWorld(key, api) { - if (typeof globalThis.window === 'undefined') { - return; - } - - // Create a frozen copy of the API - const safeApi = deepFreeze(JSON.parse(JSON.stringify(api))); - - globalThis.window[key] = safeApi; - - console.log(`[gelectron] contextBridge: exposed '${key}' to main world`); - }, -}; - -function deepFreeze(obj) { - if (typeof obj !== 'object' || obj === null) return obj; - Object.freeze(obj); - Object.keys(obj).forEach((key) => { - if (typeof obj[key] === 'object' && obj[key] !== null && !Object.isFrozen(obj[key])) { - deepFreeze(obj[key]); - } - }); - return obj; -} - -module.exports = contextBridge; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/dialog.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/dialog.js deleted file mode 100644 index 29e6c0a..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/dialog.js +++ /dev/null @@ -1,70 +0,0 @@ -'use strict'; - -/** - * Gelectron - dialog module (Electron compatible) - */ - -const dialog = { - showOpenDialog(browserWindowOrOptions, options) { - let opts = options || browserWindowOrOptions || {}; - if (browserWindowOrOptions && browserWindowOrOptions.webContents) { - opts = options || {}; - } - - // Route through native if available - if (typeof globalThis.__gelectron_dialog_open === 'function') { - return globalThis.__gelectron_dialog_open(opts); - } - - return Promise.resolve({ canceled: true, filePaths: [] }); - }, - - showSaveDialog(browserWindowOrOptions, options) { - let opts = options || browserWindowOrOptions || {}; - if (browserWindowOrOptions && browserWindowOrOptions.webContents) { - opts = options || {}; - } - - if (typeof globalThis.__gelectron_dialog_save === 'function') { - return globalThis.__gelectron_dialog_save(opts); - } - - return Promise.resolve({ canceled: true, filePath: undefined }); - }, - - showMessageBox(browserWindowOrOptions, options) { - let opts = options || browserWindowOrOptions || {}; - if (browserWindowOrOptions && browserWindowOrOptions.webContents) { - opts = options || {}; - } - - if (typeof globalThis.__gelectron_dialog_message === 'function') { - return globalThis.__gelectron_dialog_message(opts); - } - - return Promise.resolve({ response: 0, checkboxChecked: false }); - }, - - showErrorBox(title, content) { - console.error(`[gelectron] ${title}: ${content}`); - }, - - showMessageBoxSync(browserWindowOrOptions, options) { - let opts = options || browserWindowOrOptions || {}; - if (browserWindowOrOptions && browserWindowOrOptions.webContents) { - opts = options || {}; - } - - if (typeof globalThis.__gelectron_dialog_message_sync === 'function') { - return globalThis.__gelectron_dialog_message_sync(opts); - } - - return 0; - }, - - showCertificateTrustDialog(browserWindowOrOptions, options) { - return Promise.resolve(); - }, -}; - -module.exports = dialog; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/index.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/index.js deleted file mode 100644 index 47e8f56..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/index.js +++ /dev/null @@ -1,159 +0,0 @@ -'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'); -const { autoUpdater, AutoUpdater } = require('./auto-updater'); -const { bridge, isNative } = require('./native-bridge'); - -if (isNative) { - bridge.on('ipc-message', (windowId, channel, data) => { - const event = { sender: { id: windowId }, channel }; - ipcMain._emit(channel, event, data); - }); -} - -// 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, - BrowserWindow, - ipcMain, - Menu, - MenuItem, - Tray, - dialog, - shell, - Notification, - nativeImage, - safeStorage, - contextBridge, - webContents, - autoUpdater, - AutoUpdater, - session: sessionStub, - - // 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, - }, - net: { - fetch: globalThis.fetch || (() => Promise.reject(new Error('fetch not available'))), - }, - - // Constants - IPCRenderer: { - invoke: () => Promise.resolve(), - send: () => {}, - on: () => () => {}, - removeListener: () => {}, - }, -}; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/ipc-main.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/ipc-main.js deleted file mode 100644 index d161525..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/ipc-main.js +++ /dev/null @@ -1,107 +0,0 @@ -'use strict'; - -/** - * Gelectron - ipcMain module (Electron compatible) - */ - -const { EventEmitter } = require('events'); - -class IpcMain extends EventEmitter { - constructor() { - super(); - this._handlers = new Map(); - this._onceHandlers = new Map(); - } - - handle(channel, handler) { - if (typeof handler !== 'function') { - throw new TypeError(`Expected function for channel '${channel}'`); - } - this._handlers.set(channel, handler); - return this; - } - - handleOnce(channel, handler) { - if (typeof handler !== 'function') { - throw new TypeError(`Expected function for channel '${channel}'`); - } - this._onceHandlers.set(channel, handler); - return this; - } - - on(channel, listener) { - if (typeof listener !== 'function') { - throw new TypeError(`Expected function for channel '${channel}'`); - } - super.on(channel, listener); - return this; - } - - once(channel, listener) { - if (typeof listener !== 'function') { - throw new TypeError(`Expected function for channel '${channel}'`); - } - super.once(channel, listener); - return this; - } - - removeHandler(channel) { - this._handlers.delete(channel); - return this; - } - - removeListener(channel, listener) { - super.removeListener(channel, listener); - return this; - } - - removeAllListeners(channel) { - super.removeAllListeners(channel); - return this; - } - - listenerCount(channel) { - return super.listenerCount(channel); - } - - rawListeners(channel) { - return super.rawListeners(channel); - } - - eventNames() { - return super.eventNames(); - } - - _invoke(channel, ...args) { - const handler = this._handlers.get(channel); - if (!handler) { - return Promise.reject(new Error(`No handler registered for channel '${channel}'`)); - } - try { - const result = handler(...args); - if (result instanceof Promise) { - return result; - } - return Promise.resolve(result); - } catch (err) { - return Promise.reject(err); - } - } - - _emit(channel, ...args) { - return this.emit(channel, ...args); - } - - _emitOnce(channel, ...args) { - const handler = this._onceHandlers.get(channel); - if (handler) { - this._onceHandlers.delete(channel); - return handler(...args); - } - return this.emit(channel, ...args); - } -} - -const ipcMain = new IpcMain(); - -module.exports = ipcMain; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/ipc-renderer.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/ipc-renderer.js deleted file mode 100644 index b4ffd73..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/ipc-renderer.js +++ /dev/null @@ -1,145 +0,0 @@ -'use strict'; - -/** - * Gelectron - ipcRenderer module (Electron compatible) - */ - -const { EventEmitter } = require('events'); - -class IpcRendererEvent { - constructor(sender, channel) { - this.sender = sender; - this.channel = channel; - this._returnValue = undefined; - this._defaultPrevented = false; - } - - preventDefault() { - this._defaultPrevented = true; - } - - get defaultPrevented() { - return this._defaultPrevented; - } -} - -class IpcRenderer extends EventEmitter { - constructor() { - super(); - this._requestId = 0; - this._pending = new Map(); - this._listeners = new Map(); - } - - async invoke(channel, ...args) { - const requestId = `ipc-${++this._requestId}-${Date.now()}`; - const argsJson = JSON.stringify(args); - - // In full integration, this calls the native ipc_renderer_invoke - // For now, route through the global IPC bridge if available - if (typeof globalThis.__gelectron_ipc === 'function') { - return globalThis.__gelectron_ipc(channel, ...args); - } - - // Fallback: emit event for main process handling - return new Promise((resolve, reject) => { - this._pending.set(requestId, { resolve, reject }); - - // Emit for any registered handlers - this.emit(`invoke:${channel}`, ...args); - - // Timeout after 30 seconds - setTimeout(() => { - if (this._pending.has(requestId)) { - this._pending.delete(requestId); - reject(new Error(`IPC invoke timed out for channel '${channel}'`)); - } - }, 30000); - }); - } - - send(channel, ...args) { - const argsJson = JSON.stringify(args); - - if (typeof globalThis.__gelectron_send === 'function') { - globalThis.__gelectron_send(channel, ...args); - } - - this.emit(`send:${channel}`, ...args); - } - - sendSync(channel, ...args) { - // Synchronous IPC is deprecated in Electron; return undefined - return undefined; - } - - postMessage(channel, message, transfer) { - this.send(channel, message); - } - - on(channel, listener) { - const wrappedListener = (event, ...args) => { - listener(event, ...args); - }; - - // Store wrapped reference for removeListener - if (!this._listeners.has(channel)) { - this._listeners.set(channel, new Map()); - } - this._listeners.get(channel).set(listener, wrappedListener); - - return super.on(channel, wrappedListener); - } - - once(channel, listener) { - const wrappedListener = (event, ...args) => { - listener(event, ...args); - }; - return super.once(channel, wrappedListener); - } - - removeListener(channel, listener) { - const channelListeners = this._listeners.get(channel); - if (channelListeners) { - const wrapped = channelListeners.get(listener); - if (wrapped) { - channelListeners.delete(listener); - return super.removeListener(channel, wrapped); - } - } - return super.removeListener(channel, listener); - } - - removeAllListeners(channel) { - this._listeners.delete(channel); - return super.removeAllListeners(channel); - } - - // Internal method to receive messages from main process - _receiveMessage(channel, data) { - const event = new IpcRendererEvent(this, channel); - this.emit(channel, event, data); - } - - // Internal method to resolve a pending invoke - _resolveInvoke(requestId, result) { - const pending = this._pending.get(requestId); - if (pending) { - this._pending.delete(requestId); - pending.resolve(result); - } - } - - // Internal method to reject a pending invoke - _rejectInvoke(requestId, error) { - const pending = this._pending.get(requestId); - if (pending) { - this._pending.delete(requestId); - pending.reject(new Error(error)); - } - } -} - -const ipcRenderer = new IpcRenderer(); - -module.exports = { ipcRenderer, IpcRendererEvent }; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/menu.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/menu.js deleted file mode 100644 index 1c31023..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/menu.js +++ /dev/null @@ -1,183 +0,0 @@ -'use strict'; - -/** - * Gelectron - menu module (Electron compatible) - * - * Supports native menu rendering through the Rust/tao bridge. - * When running in native mode, setApplicationMenu and popup route - * through the bridge for native OS menu rendering. - */ - -const { EventEmitter } = require('events'); - -class MenuItem extends EventEmitter { - constructor(options = {}) { - super(); - this.id = options.id || ''; - this.label = options.label || ''; - this.type = options.type || 'normal'; - this.role = options.role || ''; - this.accelerator = options.accelerator || ''; - this.enabled = options.enabled !== false; - this.visible = options.visible !== false; - this.checked = options.checked || false; - this.submenu = options.submenu || null; - this.toolTip = options.toolTip || ''; - this.icon = options.icon || null; - this._click = options.click || null; - - // Recursively build submenu - if (this.submenu && !(this.submenu instanceof Menu)) { - if (Array.isArray(this.submenu)) { - this.submenu = Menu.buildFromTemplate(this.submenu); - } else { - this.submenu = Menu.buildFromTemplate(this.submenu.items || []); - } - } - } - - click() { - if (this._click) { - this._click(this, null); - } - this.emit('click'); - } -} - -class Menu extends EventEmitter { - constructor() { - super(); - this.items = []; - this._id = Menu._nextId++; - } - - static _nextId = 1; - static _applicationMenu = null; - - static buildFromTemplate(template) { - const menu = new Menu(); - if (Array.isArray(template)) { - menu.items = template.map((item) => { - if (item instanceof MenuItem) return item; - if (item.type === 'separator') { - return new MenuItem({ type: 'separator' }); - } - return new MenuItem(item); - }); - } - return menu; - } - - static getApplicationMenu() { - return Menu._applicationMenu || null; - } - - static setApplicationMenu(menu) { - Menu._applicationMenu = menu; - if (menu) { - // Route through bridge if available - try { - const { bridge, isNative } = require('./native-bridge'); - if (isNative && bridge) { - bridge._send({ type: 'set-application-menu', menu: menu._serialize() }); - } - } catch (e) { - // Not available in all contexts - } - } - } - - append(menuItem) { - if (menuItem instanceof MenuItem) { - this.items.push(menuItem); - } else { - this.items.push(new MenuItem(menuItem)); - } - return this; - } - - insert(menuItem, position) { - if (menuItem instanceof MenuItem) { - this.items.splice(position, 0, menuItem); - } else { - this.items.splice(position, 0, new MenuItem(menuItem)); - } - return this; - } - - popup(options = {}) { - try { - const { bridge, isNative } = require('./native-bridge'); - if (isNative && bridge) { - bridge._send({ type: 'popup-menu', menu: this._serialize(), x: options.x, y: options.y }); - return; - } - } catch (e) {} - console.log('[gelectron] Menu.popup called'); - } - - closePopup() { - try { - const { bridge, isNative } = require('./native-bridge'); - if (isNative && bridge) { - bridge._send({ type: 'close-popup-menu' }); - return; - } - } catch (e) {} - console.log('[gelectron] Menu.closePopup called'); - } - - getMenuItemById(id) { - return this._findMenuItemById(this.items, id); - } - - _findMenuItemById(items, id) { - for (const item of items) { - if (item.id === id) return item; - if (item.submenu) { - const submenu = item.submenu instanceof Menu ? item.submenu.items : (item.submenu.items || item.submenu); - const found = this._findMenuItemById(submenu, id); - if (found) return found; - } - } - return null; - } - - _serialize() { - return { - items: this.items.map((item) => { - const obj = { - id: item.id, - label: item.label, - type: item.type, - role: item.role, - accelerator: item.accelerator, - enabled: item.enabled, - visible: item.visible, - checked: item.checked, - toolTip: item.toolTip, - }; - if (item.submenu instanceof Menu) { - obj.submenu = item.submenu._serialize(); - } else if (item.submenu && Array.isArray(item.submenu)) { - obj.submenu = Menu.buildFromTemplate(item.submenu)._serialize(); - } - return obj; - }), - }; - } - - items() { - return this.items; - } - - getApplicationMenu() { - return Menu._applicationMenu; - } - - setApplicationMenu(menu) { - Menu._applicationMenu = menu; - } -} - -module.exports = { Menu, MenuItem }; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/native-bridge.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/native-bridge.js deleted file mode 100644 index 4a1a61e..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/native-bridge.js +++ /dev/null @@ -1,142 +0,0 @@ -'use strict'; - -/** - * Gelectron Native Bridge - IPC between Node.js and the Rust binary. - * When GELECTRON_NATIVE=1, communicates via stdin/stdout JSON lines. - */ - -const readline = require('readline'); -const { EventEmitter } = require('events'); - -const isNative = process.env.GELECTRON_NATIVE === '1'; - -class NativeBridge extends EventEmitter { - constructor() { - super(); - this._ready = false; - this._readyCallbacks = []; - this._windowListeners = new Map(); - - if (isNative) { - this._setupStdio(); - } - } - - _setupStdio() { - const rl = readline.createInterface({ input: process.stdin, terminal: false }); - - rl.on('line', (line) => { - const trimmed = line.trim(); - if (!trimmed || !trimmed.startsWith('{')) return; - try { - const msg = JSON.parse(trimmed); - this._handleMessage(msg); - } catch (e) { - // Not IPC, ignore - } - }); - - process.stdout.on('error', () => {}); - } - - _handleMessage(msg) { - switch (msg.type) { - case 'ready': - this._ready = true; - for (const cb of this._readyCallbacks) cb(); - this._readyCallbacks = []; - this.emit('ready'); - break; - case 'window-closed': - this.emit('window-closed', msg.id); - break; - case 'window-focus': - this.emit('window-focus', msg.id); - break; - case 'ipc-message': - this.emit('ipc-message', msg.id, msg.channel, msg.data); - break; - } - } - - _send(msg) { - if (!isNative) return; - try { - process.stdout.write(JSON.stringify(msg) + '\n'); - } catch (e) { - // stdout may be closed - } - } - - onReady(cb) { - if (this._ready) { - cb(); - } else { - this._readyCallbacks.push(cb); - } - } - - createWindow(id, options) { - this._send({ type: 'create-window', id, options }); - } - - loadUrl(id, url) { - this._send({ type: 'load-url', id, url }); - } - - loadFile(id, filePath) { - this._send({ type: 'load-file', id, path: filePath }); - } - - destroyWindow(id) { - this._send({ type: 'destroy-window', id }); - } - - setTitle(id, title) { - this._send({ type: 'set-title', id, title }); - } - - setSize(id, width, height) { - this._send({ type: 'set-size', id, width, height }); - } - - showWindow(id) { - this._send({ type: 'show', id }); - } - - hideWindow(id) { - this._send({ type: 'hide', id }); - } - - focusWindow(id) { - this._send({ type: 'focus', id }); - } - - minimizeWindow(id) { - this._send({ type: 'minimize', id }); - } - - maximizeWindow(id) { - this._send({ type: 'maximize', id }); - } - - closeWindow(id) { - this._send({ type: 'close', id }); - } - - sendToRenderer(id, channel, ...data) { - this._send({ type: 'ipc-message', id, channel, data: data.length === 1 ? data[0] : data }); - } - - evalJs(id, script) { - this._send({ type: 'eval-js', id, script }); - } - - quit() { - this._send({ type: 'quit' }); - } -} - -const bridge = new NativeBridge(); - -module.exports = { bridge, isNative }; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/native-image.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/native-image.js deleted file mode 100644 index e6b6364..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/native-image.js +++ /dev/null @@ -1,117 +0,0 @@ -'use strict'; - -/** - * Gelectron - nativeImage module (Electron compatible) - */ - -class NativeImage { - constructor() { - this._isEmpty = true; - this._width = 0; - this._height = 0; - this._data = null; - } - - static createFromPath(path) { - const img = new NativeImage(); - try { - const fs = require('fs'); - const data = fs.readFileSync(path); - // Basic PNG header parsing for dimensions - if (data.length > 24 && data[0] === 0x89 && data[1] === 0x50) { - img._width = data.readUInt32BE(16); - img._height = data.readUInt32BE(20); - img._data = data; - img._isEmpty = false; - } - } catch (err) { - console.error(`[gelectron] Failed to load image: ${path}`, err.message); - } - return img; - } - - static createFromBuffer(buffer, options = {}) { - const img = new NativeImage(); - if (buffer && buffer.length > 0) { - img._data = buffer; - img._isEmpty = false; - img._width = options.width || 0; - img._height = options.height || 0; - - // Try to detect PNG dimensions - if (buffer.length > 24 && buffer[0] === 0x89 && buffer[1] === 0x50) { - img._width = buffer.readUInt32BE(16); - img._height = buffer.readUInt32BE(20); - } - } - return img; - } - - static createFromDataURL(dataURL) { - const matches = dataURL.match(/^data:[^;]+;base64,(.+)$/); - if (matches) { - return NativeImage.createFromBuffer(Buffer.from(matches[1], 'base64')); - } - return NativeImage.createEmpty(); - } - - static createEmpty() { - return new NativeImage(); - } - - toPNG(options = {}) { - return this._data || Buffer.alloc(0); - } - - toJPEG(quality) { - return this._data || Buffer.alloc(0); - } - - toBitmap(options = {}) { - return this._data || Buffer.alloc(0); - } - - toDataURL() { - if (!this._data) return 'data:,'; - const base64 = this._data.toString('base64'); - return `data:image/png;base64,${base64}`; - } - - resize(options) { - const resized = new NativeImage(); - resized._width = options.width || this._width; - resized._height = options.height || this._height; - resized._data = this._data; - resized._isEmpty = this._isEmpty; - return resized; - } - - crop(rect) { - return this.resize({ width: rect.width, height: rect.height }); - } - - getBitmap(options = {}) { - return this._data || Buffer.alloc(0); - } - - getSize() { - return { width: this._width, height: this._height }; - } - - isEmpty() { - return this._isEmpty; - } - - setTemplateImage(template) { - this._isTemplate = template; - } - - isTemplateImage() { - return this._isTemplate || false; - } - - toPNG(options) { return this.toPNG(options); } - toJPEG(quality) { return this.toJPEG(quality); } -} - -module.exports = NativeImage; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/notification.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/notification.js deleted file mode 100644 index edcff3b..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/notification.js +++ /dev/null @@ -1,59 +0,0 @@ -'use strict'; - -/** - * Gelectron - Notification module (Electron compatible) - */ - -const { EventEmitter } = require('events'); - -class Notification extends EventEmitter { - static _notifications = new Map(); - static _nextId = 1; - - constructor(options = {}) { - super(); - this.id = Notification._nextId++; - this.title = options.title || ''; - this.body = options.body || ''; - this.subtitle = options.subtitle || ''; - this.silent = options.silent || false; - this.icon = options.icon || null; - this.urgency = options.urgency || 'normal'; - this.timeoutType = options.timeoutType || 'default'; - this.closeButtonText = options.closeButtonText || ''; - this.toastXml = options.toastXml || ''; - this.actions = options.actions || []; - this.replyPlaceholder = options.replyPlaceholder || ''; - - Notification._notifications.set(this.id, this); - } - - static isSupported() { - return true; - } - - show() { - if (typeof Notification !== 'undefined' && Notification.permission === 'granted') { - new globalThis.Notification(this.title, { - body: this.body, - icon: this.icon, - }); - } - - console.log(`[gelectron] Notification shown: ${this.title}`); - this.emit('show'); - return true; - } - - close() { - Notification._notifications.delete(this.id); - console.log(`[gelectron] Notification ${this.id} closed`); - this.emit('close'); - } - - static fromNotification(notification) { - return notification; - } -} - -module.exports = { Notification }; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/preload-loader.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/preload-loader.js deleted file mode 100644 index 933ac58..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/preload-loader.js +++ /dev/null @@ -1,156 +0,0 @@ -'use strict'; - -/** - * Gelectron - Preload script injection - * - * This script is injected into the renderer process before the page loads. - * It provides the ipcRenderer and contextBridge APIs to preload scripts. - */ - -function getPreloadScript() { - return ` -(function() { - 'use strict'; - - // Expose gelectron preload APIs - window.__gelectron = window.__gelectron || {}; - - // IPC Renderer stub - window.__gelectron.ipcRenderer = { - _requestId: 0, - _pending: {}, - - invoke: function(channel) { - var args = Array.prototype.slice.call(arguments, 1); - var requestId = 'ipc-' + (++this._requestId) + '-' + Date.now(); - var message = { - type: 'invoke', - requestId: requestId, - channel: channel, - args: args - }; - - if (typeof window.__gelectron_send === 'function') { - window.__gelectron_send(JSON.stringify(message)); - } - - return new Promise(function(resolve, reject) { - window.__gelectron.ipcRenderer._pending[requestId] = { resolve: resolve, reject: reject }; - setTimeout(function() { - if (window.__gelectron.ipcRenderer._pending[requestId]) { - delete window.__gelectron.ipcRenderer._pending[requestId]; - reject(new Error('IPC invoke timed out for channel: ' + channel)); - } - }, 30000); - }); - }, - - send: function(channel) { - var args = Array.prototype.slice.call(arguments, 1); - var message = { - type: 'send', - channel: channel, - args: args - }; - if (typeof window.__gelectron_send === 'function') { - window.__gelectron_send(JSON.stringify(message)); - } - }, - - sendSync: function() { return undefined; }, - postMessage: function(channel, message) { this.send(channel, message); }, - - on: function(channel, listener) { - var wrappedListener = function(event) { - listener(event, Array.prototype.slice.call(arguments, 1)); - }; - window.addEventListener('message', function(event) { - if (event.data && event.data.__gelectron_channel === channel) { - wrappedListener(event, event.data.args); - } - }); - return this; - }, - - once: function(channel, listener) { - var self = this; - var wrappedListener = function(event) { - listener(event, Array.prototype.slice.call(arguments, 1)); - self.removeListener(channel, listener); - }; - return this.on(channel, wrappedListener); - }, - - removeListener: function(channel, listener) { - return this; - }, - - removeAllListeners: function(channel) { - return this; - }, - - _resolveInvoke: function(requestId, result) { - var pending = this._pending[requestId]; - if (pending) { - delete this._pending[requestId]; - pending.resolve(result); - } - }, - - _rejectInvoke: function(requestId, error) { - var pending = this._pending[requestId]; - if (pending) { - delete this._pending[requestId]; - pending.reject(new Error(error)); - } - } - }; - - // Context Bridge API - window.__gelectron.contextBridge = { - exposeInMainWorld: function(key, api) { - if (typeof window[key] !== 'undefined') { - console.warn('[gelectron] contextBridge: window.' + key + ' already exists, skipping'); - return; - } - Object.defineProperty(window, key, { - value: Object.freeze(JSON.parse(JSON.stringify(api))), - writable: false, - configurable: false, - enumerable: true - }); - } - }; - - // Receive messages from main process - window.addEventListener('message', function(event) { - if (event.data && event.data.__gelectron_channel) { - var channel = event.data.__gelectron_channel; - var args = event.data.args; - - // Resolve pending invoke - if (channel === '__gelectron_ipc_resolve') { - var requestId = args[0]; - var result = args[1]; - window.__gelectron.ipcRenderer._resolveInvoke(requestId, result); - } else if (channel === '__gelectron_ipc_reject') { - var requestId = args[0]; - var error = args[1]; - window.__gelectron.ipcRenderer._rejectInvoke(requestId, error); - } else { - // Regular IPC message from main process - window.__gelectron.ipcRenderer._receiveMessage(channel, args); - } - } - }); - - // Expose as global for preload scripts - window.electron = window.electron || {}; - window.electron.ipcRenderer = window.__gelectron.ipcRenderer; - window.electron.contextBridge = window.__gelectron.contextBridge; - -})(); -`; -} - -module.exports = { getPreloadScript }; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/runtime.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/runtime.js deleted file mode 100644 index 81c0472..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/runtime.js +++ /dev/null @@ -1,74 +0,0 @@ -'use strict'; - -/** - * Gelectron Runtime - Node.js fallback when native binary is not available. - * Loads and runs an Electron app's main process using the JS compatibility layer. - */ - -const path = require('path'); -const Module = require('module'); - -function run(mainScript, env) { - // Set up the environment - Object.assign(process.env, env); - - // Patch require so that 'electron' resolves to gelectron's compat layer - const electronCompatPath = path.join(__dirname, 'index.js'); - const ipcRendererPath = path.join(__dirname, 'ipc-renderer.js'); - - // Purge any cached 'electron' module from the real npm package so that - // our _resolveFilename patch takes absolute priority. The real 'electron' - // npm package (devDependency in the target app) exports a *path string* - // to the Electron binary – it does NOT have .autoUpdater, .app, etc. - for (const key of Object.keys(Module._cache)) { - const normalized = key.replace(/\\/g, '/'); - if ( - normalized.endsWith('/electron') || - normalized.endsWith('/electron/index.js') || - normalized.endsWith('/electron/index.cjs') - ) { - delete Module._cache[key]; - } - } - - const originalResolveFilename = Module._resolveFilename; - Module._resolveFilename = function (request, parent, isMain, options) { - if (request === 'electron' || request === 'electron/main' || request === 'electron/common') { - return electronCompatPath; - } - if (request === 'electron/renderer') { - return ipcRendererPath; - } - return originalResolveFilename.call(this, request, parent, isMain, options); - }; - - // Also monkey-patch Module._resolveRequest for Node ≥ 22 where it may - // be used internally instead of _resolveFilename. - if (typeof Module._resolveRequest === 'function') { - const originalResolveRequest = Module._resolveRequest; - Module._resolveRequest = function (request, parent, isMain, options) { - if (request === 'electron' || request === 'electron/main' || request === 'electron/common') { - return electronCompatPath; - } - if (request === 'electron/renderer') { - return ipcRendererPath; - } - return originalResolveRequest.call(this, request, parent, isMain, options); - }; - } - - // Pre-load the gelectron shim into the module cache so that every - // subsequent require('electron') hits cache immediately. - require(electronCompatPath); - - // Require the app's main script - try { - require(mainScript); - } catch (err) { - console.error(`[gelectron] Error loading main script: ${mainScript}`); - console.error(err); - process.exit(1); - } -} - -module.exports = { run }; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/safe-storage.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/safe-storage.js deleted file mode 100644 index 251d714..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/safe-storage.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -/** - * Gelectron - safeStorage module (Electron compatible) - */ - -const safeStorage = { - isAvailable() { - return true; - }, - - async encryptString(plaintext) { - // Basic obfuscation; in production, this routes through the native keyring - return Buffer.from(plaintext).toString('base64'); - }, - - async decryptString(encrypted) { - return Buffer.from(encrypted, 'base64').toString('utf-8'); - }, - - async encryptBuffer(buffer) { - return Buffer.from(buffer).toString('base64'); - }, - - async decryptBuffer(encrypted) { - return Buffer.from(encrypted, 'base64'); - }, -}; - -module.exports = safeStorage; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/shell.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/shell.js deleted file mode 100644 index 08fdb3c..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/shell.js +++ /dev/null @@ -1,100 +0,0 @@ -'use strict'; - -/** - * Gelectron - shell module (Electron compatible) - */ - -const { exec } = require('child_process'); -const path = require('path'); -const os = require('os'); - -const shell = { - openExternal(url, options = {}) { - const platform = os.platform(); - let cmd; - - if (platform === 'darwin') { - cmd = `open "${url}"`; - } else if (platform === 'win32') { - cmd = `start "" "${url}"`; - } else { - cmd = `xdg-open "${url}"`; - } - - return new Promise((resolve, reject) => { - exec(cmd, (error) => { - if (error) reject(error); - else resolve(); - }); - }); - }, - - openPath(path) { - return new Promise((resolve, reject) => { - const platform = os.platform(); - let cmd; - - if (platform === 'darwin') { - cmd = `open "${path}"`; - } else if (platform === 'win32') { - cmd = `start "" "${path}"`; - } else { - cmd = `xdg-open "${path}"`; - } - - exec(cmd, (error) => { - if (error) reject(error.message); - else resolve(''); - }); - }); - }, - - showItemInFolder(fullPath) { - const platform = os.platform(); - let cmd; - - if (platform === 'darwin') { - cmd = `open -R "${fullPath}"`; - } else if (platform === 'win32') { - cmd = `explorer /select,"${fullPath}"`; - } else { - const dir = path.dirname(fullPath); - cmd = `xdg-open "${dir}"`; - } - - exec(cmd); - }, - - moveItemToTrash(fullPath) { - // Use fs.rm or platform-specific trash command - const fs = require('fs'); - try { - fs.rmSync(fullPath, { recursive: true, force: true }); - return Promise.resolve(''); - } catch (err) { - return Promise.reject(err.message); - } - }, - - beep() { - process.stdout.write('\x07'); - }, - - writeShortcutLink(shortcutPath, options = {}) { - console.log('[gelectron] writeShortcutLink called'); - return true; - }, - - readShortcutLink(shortcutPath) { - return { - target: '', - cwd: '', - args: '', - description: '', - icon: '', - iconIndex: 0, - }; - }, -}; - -module.exports = shell; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/tray.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/tray.js deleted file mode 100644 index 835d64b..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/tray.js +++ /dev/null @@ -1,74 +0,0 @@ -'use strict'; - -/** - * Gelectron - Tray module (Electron compatible) - */ - -const { EventEmitter } = require('events'); - -class Tray extends EventEmitter { - static _trays = new Map(); - static _nextId = 1; - - constructor(image) { - super(); - this.id = Tray._nextId++; - this._image = image; - this._tooltip = ''; - this._menu = null; - this._isDestroyed = false; - - Tray._trays.set(this.id, this); - console.log(`[gelectron] Tray ${this.id} created`); - } - - setToolTip(tooltip) { - this._tooltip = tooltip; - } - - getToolTip() { - return this._tooltip; - } - - setImage(image) { - this._image = image; - } - - setPressedImage(image) {} - - setContextMenu(menu) { - this._menu = menu; - } - - getContextMenu() { - return this._menu; - } - - popupContextMenu(options) { - console.log('[gelectron] Tray.popupContextMenu'); - } - - isDestroyed() { - return this._isDestroyed; - } - - destroy() { - this._isDestroyed = true; - Tray._trays.delete(this.id); - this.emit('destroy'); - } - - getBounds() { - return { x: 0, y: 0, width: 22, height: 22 }; - } - - static fromId(id) { - return Tray._trays.get(id) || null; - } - - static getAllTrays() { - return Array.from(Tray._trays.values()); - } -} - -module.exports = { Tray }; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/web-contents.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/web-contents.js deleted file mode 100644 index 3d60234..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/web-contents.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -/** - * Gelectron - webContents utilities (Electron compatible) - */ - -const { BrowserWindow } = require('./browser-window'); - -const webContents = { - getAllWebContents() { - return BrowserWindow.getAllWindows().map((win) => win.webContents); - }, - - getFocusedWebContents() { - const focused = BrowserWindow.getFocusedWindow(); - return focused ? focused.webContents : null; - }, - - fromId(id) { - const win = BrowserWindow.fromId(id); - return win ? win.webContents : null; - }, -}; - -module.exports = webContents; diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/webview-bundle.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/webview-bundle.js deleted file mode 100644 index 3514d87..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/webview-bundle.js +++ /dev/null @@ -1,1200 +0,0 @@ -(function() { -'use strict'; - -/* ─── process polyfill ────────────────────────────────────────────── */ -if (typeof process === 'undefined') { - var _ua = navigator.userAgent || ''; - var _isMac = /Mac/.test(navigator.platform || _ua); - var _isWin = /Win/.test(navigator.platform || _ua); - window.process = { - pid: Math.floor(Math.random() * 90000 + 10000), - ppid: 0, - argv: ['gelectron', ''], - env: { GELECTRON_NATIVE: '0', HOME: '/tmp', PATH: '' }, - platform: _isMac ? 'darwin' : _isWin ? 'win32' : 'linux', - arch: (navigator.userAgentData && navigator.userAgentData.arch) || 'x64', - version: 'v18.0.0', - versions: { node: '18.0.0', v8: '10.0.0', electron: '0.1.0', gelectron: '0.1.0' }, - execPath: 'gelectron', - cwd: function() { return '/'; }, - nextTick: function(fn) { - var args = Array.prototype.slice.call(arguments, 1); - setTimeout(function() { fn.apply(null, args); }, 0); - }, - exit: function() { /* no-op in WebView */ }, - on: function() { return process; }, - once: function() { return process; }, - removeListener: function() { return process; }, - removeAllListeners: function() { return process; }, - emit: function() { return false; }, - stdout: { write: function() {}, on: function() {} }, - stderr: { write: function() {}, on: function() {} }, - stdin: { on: function() {}, setEncoding: function() {} }, - stdout_columns: 80, - }; -} -var process = window.process; - -/* ─── __dirname / __filename ─────────────────────────────────────── */ -if (typeof __dirname === 'undefined') window.__dirname = '/gelectron'; -if (typeof __filename === 'undefined') window.__filename = '/gelectron/webview-bundle.js'; -var __dirname = window.__dirname; - -/* ─── Buffer polyfill ────────────────────────────────────────────── */ -if (typeof Buffer === 'undefined') { - window.Buffer = { - alloc: function(size, fill) { - var arr = new Uint8Array(size); - if (fill !== undefined) arr.fill(typeof fill === 'number' ? fill : 0); - return arr; - }, - from: function(data, enc) { - if (typeof data === 'string') { - if (enc === 'base64') return Uint8Array.from(atob(data), function(c) { return c.charCodeAt(0); }); - if (enc === 'hex') { - var bytes = new Uint8Array(data.length / 2); - for (var i = 0; i < data.length; i += 2) bytes[i / 2] = parseInt(data.substr(i, 2), 16); - return bytes; - } - return new TextEncoder().encode(data); - } - if (data instanceof ArrayBuffer) return new Uint8Array(data); - if (ArrayBuffer.isView(data)) return new Uint8Array(data.buffer, data.byteOffset, data.byteLength); - if (Array.isArray(data)) return new Uint8Array(data); - return new Uint8Array(0); - }, - isBuffer: function(obj) { return obj instanceof Uint8Array; }, - concat: function(list) { - var total = 0; - for (var i = 0; i < list.length; i++) total += list[i].length; - var result = new Uint8Array(total); - var offset = 0; - for (var i = 0; i < list.length; i++) { result.set(list[i], offset); offset += list[i].length; } - return result; - }, - }; - Uint8Array.prototype.toString = function(enc) { - if (enc === 'base64') { - var binary = ''; for (var i = 0; i < this.length; i++) binary += String.fromCharCode(this[i]); - return btoa(binary); - } - if (enc === 'hex') { - var hex = ''; for (var i = 0; i < this.length; i++) hex += this[i].toString(16).padStart(2, '0'); - return hex; - } - return new TextDecoder().decode(this); - }; - Uint8Array.prototype.toJSON = function() { return { type: 'Buffer', data: Array.prototype.slice.call(this) }; }; - Uint8Array.prototype.slice = function(start, end) { var s = start || 0; var e = end !== undefined ? end : this.length; return new Uint8Array(this.buffer, this.byteOffset + s, e - s); }; - Uint8Array.prototype.readUInt32BE = function(offset) { - return (this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]) >>> 0; - }; -} -var Buffer = window.Buffer; - -/* ─── Module system ──────────────────────────────────────────────── */ -var _modules = {}; -function _define(id, factory) { _modules[id] = { factory: factory, exports: null }; } -function require(id) { - if (id === 'electron') return _modules['index'].exports; - var mod = _modules[id]; - if (!mod) throw new Error("Cannot find module '" + id + "'"); - if (mod.exports !== null) return mod.exports; - var m = { exports: {} }; - mod.exports = m.exports; - mod.factory(require, m, m.exports); - mod.exports = m.exports; - return mod.exports; -} - -/* ─── events (EventEmitter) ──────────────────────────────────────── */ -_define('events', function(req, module) { - function EventEmitter() { this._events = {}; this._eventsCount = 0; } - EventEmitter.prototype.on = function(type, fn) { - if (typeof fn !== 'function') throw new TypeError('Listener must be a function'); - if (!this._events[type]) { this._events[type] = []; this._eventsCount++; } - this._events[type].push(fn); - return this; - }; - EventEmitter.prototype.once = function(type, fn) { - var self = this; - function onceWrapper() { self.removeListener(type, onceWrapper); fn.apply(this, arguments); } - onceWrapper._original = fn; - return this.on(type, onceWrapper); - }; - EventEmitter.prototype.removeListener = function(type, fn) { - var list = this._events[type]; - if (!list) return this; - for (var i = list.length - 1; i >= 0; i--) { - if (list[i] === fn || list[i]._original === fn) { list.splice(i, 1); break; } - } - if (list.length === 0) { delete this._events[type]; this._eventsCount--; } - return this; - }; - EventEmitter.prototype.removeAllListeners = function(type) { - if (type) { delete this._events[type]; this._eventsCount--; } - else { this._events = {}; this._eventsCount = 0; } - return this; - }; - EventEmitter.prototype.emit = function(type) { - var list = this._events[type]; - if (!list) return false; - var args = Array.prototype.slice.call(arguments, 1); - var copy = list.slice(); - for (var i = 0; i < copy.length; i++) copy[i].apply(this, args); - return true; - }; - EventEmitter.prototype.listenerCount = function(type) { return (this._events[type] || []).length; }; - EventEmitter.prototype.eventNames = function() { return Object.keys(this._events); }; - EventEmitter.prototype.rawListeners = function(type) { return (this._events[type] || []).slice(); }; - EventEmitter.prototype.off = EventEmitter.prototype.removeListener; - EventEmitter.prototype.addListener = EventEmitter.prototype.on; - module.exports = { EventEmitter: EventEmitter }; -}); - -/* ─── path ───────────────────────────────────────────────────────── */ -_define('path', function(req, module) { - function normalize(p) { - if (!p) return ''; - p = p.replace(/\\/g, '/'); - if (p.endsWith('/') && p.length > 1) p = p.slice(0, -1); - return p; - } - function join() { - var parts = []; - for (var i = 0; i < arguments.length; i++) { - if (arguments[i]) parts.push(arguments[i]); - } - return normalize(parts.join('/')); - } - function resolve() { - var parts = []; - for (var i = 0; i < arguments.length; i++) parts.push(arguments[i]); - var result = join.apply(null, parts); - if (!result.startsWith('/')) result = '/' + result; - return result; - } - function basename(p, ext) { - if (!p) return ''; - p = normalize(p); - var name = p.split('/').pop() || ''; - if (ext && name.endsWith(ext)) name = name.slice(0, -ext.length); - return name; - } - function dirname(p) { - if (!p) return '.'; - p = normalize(p); - var idx = p.lastIndexOf('/'); - return idx <= 0 ? '/' : p.slice(0, idx); - } - function extname(p) { - if (!p) return ''; - var base = basename(p); - var idx = base.lastIndexOf('.'); - return idx <= 0 ? '' : base.slice(idx); - } - function isAbsolute(p) { return typeof p === 'string' && (p.startsWith('/') || /^[A-Za-z]:/.test(p)); } - module.exports = { join: join, resolve: resolve, basename: basename, dirname: dirname, extname: extname, normalize: normalize, isAbsolute: isAbsolute, sep: '/', delimiter: ':' }; -}); - -/* ─── os ─────────────────────────────────────────────────────────── */ -_define('os', function(req, module) { - var _h = '/tmp'; - try { _h = process.env.HOME || process.env.USERPROFILE || '/tmp'; } catch(e) {} - module.exports = { - homedir: function() { return _h; }, - tmpdir: function() { return '/tmp'; }, - platform: function() { return process.platform; }, - arch: function() { return process.arch; }, - type: function() { return process.platform === 'darwin' ? 'Darwin' : process.platform === 'win32' ? 'Windows_NT' : 'Linux'; }, - release: function() { return '0.0.0'; }, - hostname: function() { return 'gelectron'; }, - endianness: function() { return 'LE'; }, - cpus: function() { return []; }, - totalmem: function() { return 0; }, - freemem: function() { return 0; }, - uptime: function() { return 0; }, - networkInterfaces: function() { return {}; }, - }; -}); - -/* ─── readline stub ──────────────────────────────────────────────── */ -_define('readline', function(req, module) { - module.exports = { createInterface: function() { return { on: function() { return this; }, close: function() {} }; } }; -}); - -/* ─── child_process stub ─────────────────────────────────────────── */ -_define('child_process', function(req, module) { - module.exports = { - exec: function(cmd, cb) { if (cb) cb(null, '', ''); return { on: function() { return this; } }; }, - execSync: function() { return Buffer.alloc(0); }, - spawn: function() { return { on: function() { return this; }, stdout: { on: function() {} }, stderr: { on: function() {} } }; }, - }; -}); - -/* ─── fs stub ────────────────────────────────────────────────────── */ -_define('fs', function(req, module) { - module.exports = { - readFileSync: function() { return Buffer.alloc(0); }, - existsSync: function() { return false; }, - readlinkSync: function() { return ''; }, - }; -}); - -/* ─── WebView IPC bridge (replaces native-bridge stdin/stdout) ───── */ -_define('native-bridge', function(req, module) { - var EventEmitter = req('events').EventEmitter; - var _ready = false; - var _readyCbs = []; - - function _send(msg) { - try { - var str = JSON.stringify(msg); - if (window.ipc && window.ipc.postMessage) { - window.ipc.postMessage(str); - } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.ipc) { - window.webkit.messageHandlers.ipc.postMessage(str); - } - } catch(e) { - console.error('[gelectron] _send error:', e); - } - } - - window.addEventListener('message', function(event) { - var data = event.data; - if (!data || typeof data !== 'object') return; - try { - if (typeof data === 'string') data = JSON.parse(data); - } catch(e) { return; } - if (!data.type) return; - switch (data.type) { - case 'ready': - _ready = true; - for (var i = 0; i < _readyCbs.length; i++) _readyCbs[i](); - _readyCbs = []; - bridge.emit('ready'); - break; - case 'window-closed': - bridge.emit('window-closed', data.id); - break; - case 'window-focus': - bridge.emit('window-focus', data.id); - break; - case 'ipc-message': - bridge.emit('ipc-message', data.id, data.channel, data.data); - break; - case 'ipc-invoke-response': - bridge.emit('ipc-invoke-response', data.requestId, data.result, data.error); - break; - } - }); - - var bridge = new EventEmitter(); - bridge._ready = false; - bridge.onReady = function(cb) { if (_ready) cb(); else _readyCbs.push(cb); }; - bridge.createWindow = function(id, opts) { _send({ type: 'create-window', id: id, options: opts }); }; - bridge.loadUrl = function(id, url) { _send({ type: 'load-url', id: id, url: url }); }; - bridge.loadFile = function(id, path) { _send({ type: 'load-file', id: id, path: path }); }; - bridge.destroyWindow = function(id) { _send({ type: 'destroy-window', id: id }); }; - bridge.setTitle = function(id, title) { _send({ type: 'set-title', id: id, title: title }); }; - bridge.setSize = function(id, w, h) { _send({ type: 'set-size', id: id, width: w, height: h }); }; - bridge.showWindow = function(id) { _send({ type: 'show', id: id }); }; - bridge.hideWindow = function(id) { _send({ type: 'hide', id: id }); }; - bridge.focusWindow = function(id) { _send({ type: 'focus', id: id }); }; - bridge.minimizeWindow = function(id) { _send({ type: 'minimize', id: id }); }; - bridge.maximizeWindow = function(id) { _send({ type: 'maximize', id: id }); }; - bridge.closeWindow = function(id) { _send({ type: 'close', id: id }); }; - bridge.sendToRenderer = function(id, channel) { - var data = Array.prototype.slice.call(arguments, 2); - _send({ type: 'ipc-message', id: id, channel: channel, data: data.length === 1 ? data[0] : data }); - }; - bridge.evalJs = function(id, script) { _send({ type: 'eval-js', id: id, script: script }); }; - bridge.quit = function() { _send({ type: 'quit' }); }; - bridge._send = _send; - bridge.invoke = function(id, channel) { - var args = Array.prototype.slice.call(arguments, 2); - var requestId = 'ipc-' + Date.now() + '-' + Math.floor(Math.random() * 1e6); - _send({ type: 'ipc-invoke', id: id, requestId: requestId, channel: channel, args: args }); - return requestId; - }; - - var isNative = !!(window.ipc) || !!(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.ipc); - module.exports = { bridge: bridge, isNative: isNative }; -}); - -/* ─── app ────────────────────────────────────────────────────────── */ -_define('app', function(req, module) { - var EventEmitter = req('events').EventEmitter; - var path = req('path'); - var os = req('os'); - - function App() { - EventEmitter.call(this); - this._ready = false; - this._windowCount = 0; - this._relaunching = false; - this._aboutPanelOptions = {}; - this._badgeCount = 0; - this._secureKeyboardEntryEnabled = false; - this._userAgent = null; - this._name = 'Gelectron App'; - var home = os.homedir(); - this._paths = { - home: home, - appData: path.join(home, '.config', 'gelectron'), - userData: path.join(home, '.config', 'gelectron'), - desktop: path.join(home, 'Desktop'), documents: path.join(home, 'Documents'), - downloads: path.join(home, 'Downloads'), temp: os.tmpdir(), - exe: process.execPath, module: __dirname, - crashDumps: path.join(home, '.config', 'gelectron', 'crashDumps'), - logs: path.join(home, '.config', 'gelectron', 'logs'), - }; - this._commandLine = new Map(); - this._dock = process.platform === 'darwin' ? { - setIcon: function() {}, bounce: function() { return 0; }, cancelBounce: function() {}, - setBadge: function() {}, getBadge: function() { return ''; }, hide: function() {}, - show: function() {}, isVisible: function() { return true; }, setMenu: function() {}, - setBadgeCount: function() { return 0; }, getBadgeCount: function() { return 0; }, - setThumbnail: function() {}, setThumbnailClip: function() {}, setThumbnailToolTip: function() {}, - } : null; - this._argv = process.argv.slice(); - var self = this; - process.nextTick(function() { if (!self._ready) { self._ready = true; self.emit('ready'); } }); - } - App.prototype = Object.create(EventEmitter.prototype); - App.prototype.constructor = App; - - Object.defineProperty(App.prototype, 'commandLine', { get: function() { - var self = this; - return { - appendSwitch: function(n, v) { self._commandLine.set(n, v || ''); }, - removeSwitch: function(n) { self._commandLine.delete(n); }, - getSwitch: function(n) { return self._commandLine.get(n) || ''; }, - hasSwitch: function(n) { return self._commandLine.has(n); }, - }; - }}); - Object.defineProperty(App.prototype, 'dock', { get: function() { return this._dock; } }); - Object.defineProperty(App.prototype, 'argv', { get: function() { return this._argv; } }); - Object.defineProperty(App.prototype, 'isPackaged', { get: function() { return false; } }); - Object.defineProperty(App.prototype, 'name', { - get: function() { return this._name; }, - set: function(v) { this._name = v || 'Gelectron App'; } - }); - Object.defineProperty(App.prototype, 'version', { get: function() { return process.env.GELECTRON_VERSION || '0.1.0'; } }); - Object.defineProperty(App.prototype, 'locale', { get: function() { return this.getLocale(); } }); - Object.defineProperty(App.prototype, 'userAgent', { get: function() { return this.getUserAgent(); } }); - Object.defineProperty(App.prototype, 'appPath', { get: function() { return this.getAppPath(); } }); - - App.prototype.getAppPath = function() { return process.env.GELECTRON_APP_PATH || process.cwd(); }; - App.prototype.getPath = function(n) { - if (n === 'app') return this._paths.appData || this._paths.userData; - return this._paths[n] || this._paths.userData; - }; - App.prototype.setPath = function(n, p) { this._paths[n] = p; }; - App.prototype.getName = function() { return this._name; }; - App.prototype.setName = function(n) { this._name = n; }; - App.prototype.getVersion = function() { return this.version; }; - App.prototype.getLocale = function() { return Intl.DateTimeFormat().resolvedOptions().locale || 'en-US'; }; - App.prototype.getUserAgent = function() { return this._userAgent || ('Gelectron/' + this.version + ' (' + process.platform + ' ' + process.arch + ')'); }; - App.prototype.setUserAgent = function(ua) { this._userAgent = ua || null; }; - App.prototype.getPathForProtocol = function() { return null; }; - App.prototype.getApplicationInfoForProtocol = function() { return Promise.resolve({ defaultIcon: null, icon: null }); }; - - App.prototype.whenReady = function() { var self = this; if (self._ready) return Promise.resolve(); return new Promise(function(r) { self.once('ready', r); }); }; - App.prototype.requestSingleInstanceLock = function() { return true; }; - App.prototype.acquireSingleInstanceLock = function() { return true; }; - App.prototype.releaseSingleInstanceLock = function() {}; - - App.prototype.quit = function() { - if (this.listenerCount('before-quit') > 0 || this.listenerCount('will-quit') > 0) { - this.emit('before-quit'); - this.emit('will-quit'); - } - this.emit('quit'); - var bridgeObj = req('native-bridge'); - if (bridgeObj.isNative) { bridgeObj.bridge.quit(); } - }; - App.prototype.exit = function() { - if (this._ready) { this.emit('before-quit'); this.emit('will-quit'); } - this.emit('quit'); - var bridgeObj = req('native-bridge'); - if (bridgeObj.isNative) { bridgeObj.bridge.quit(); } - }; - App.prototype.relaunch = function(options) { - this._relaunching = true; - this.emit('before-quit'); - var bridgeObj = req('native-bridge'); - if (bridgeObj.isNative) { - var msg = { type: 'relaunch' }; - if (options && options.execPath) msg.execPath = options.execPath; - if (options && options.args) msg.args = options.args; - bridgeObj.bridge._send(msg); - } - }; - App.prototype.isReady = function() { return this._ready; }; - - App.prototype.focus = function() {}; - App.prototype.hide = function() {}; - App.prototype.show = function() {}; - App.prototype.isVisible = function() { return true; }; - App.prototype.isHidden = function() { return false; }; - - App.prototype.getAppMetrics = function() { - return [{ creationTime: Date.now(), pid: process.pid, rid: 0, type: 'Browser', memory: { workingSetSize: 0 }, sandboxed: false }]; - }; - App.prototype.getGPUInfo = function(type) { - return Promise.resolve({ gpuDevice: [{ driverVendor: 'Gelectron', active: false }], GPUActive: false }); - }; - App.prototype.getGPUFeatureStatus = function() { - return { gpuCompositing: 'disabled', multipleRasterThreads: 'disabled', nativeGpuMemoryBuffers: 'disabled', rasterization: 'disabled', smoothScrolling: 'disabled', videoDecode: 'disabled', videoEncode: 'disabled', webgl: 'disabled', webgl2: 'disabled' }; - }; - App.prototype.disableHardwareAcceleration = function() {}; - App.prototype.disableDomainBlockingFor3DAPIs = function() {}; - - App.prototype.setBadgeCount = function(count) { this._badgeCount = count || 0; return this._badgeCount; }; - App.prototype.getBadgeCount = function() { return this._badgeCount; }; - - App.prototype.addRecentDocument = function() {}; - App.prototype.clearRecentDocuments = function() {}; - App.prototype.setRecentDocumentLabel = function() {}; - App.prototype.setAppUserModelId = function() {}; - App.prototype.getAppUserModelId = function() { return ''; }; - - App.prototype.getLoginItemSettings = function() { return { openAtLogin: false, openAsHidden: false, launchAtLogin: false, launchItems: [] }; }; - App.prototype.setLoginItemSettings = function() {}; - App.prototype.isInApplicationsFolder = function() { return true; }; - App.prototype.moveToApplicationsFolder = function() {}; - App.prototype.getFileIcon = function(p, opts, cb) { if (typeof opts === 'function') { cb = opts; } cb(null, null); }; - - App.prototype.setAboutPanelOptions = function(opts) { this._aboutPanelOptions = opts || {}; }; - App.prototype.getAboutPanelOptions = function() { return this._aboutPanelOptions; }; - App.prototype.showCertificateTrustDialog = function() { return Promise.resolve(); }; - App.prototype.setSecureKeyboardEntryEnabled = function(e) { this._secureKeyboardEntryEnabled = !!e; }; - App.prototype.isSecureKeyboardEntryEnabled = function() { return this._secureKeyboardEntryEnabled; }; - - App.prototype._trackWindow = function() { this._windowCount++; }; - App.prototype._untrackWindow = function() { - this._windowCount--; - if (this._windowCount <= 0) { this._windowCount = 0; this.emit('window-all-closed'); } - }; - App.prototype.getWindowCount = function() { return this._windowCount; }; - - App.prototype.on = function(e, l) { EventEmitter.prototype.on.call(this, e, l); return this; }; - App.prototype.once = function(e, l) { EventEmitter.prototype.once.call(this, e, l); return this; }; - App.prototype.addListener = function(e, l) { EventEmitter.prototype.addListener.call(this, e, l); return this; }; - App.prototype.removeListener = function(e, l) { EventEmitter.prototype.removeListener.call(this, e, l); return this; }; - - var app = new App(); - module.exports = { app: app, App: App }; -}); - -/* ─── browser-window ─────────────────────────────────────────────── */ -_define('browser-window', function(req, module) { - var EventEmitter = req('events').EventEmitter; - var path = req('path'); - var bridgeObj = req('native-bridge'); - var bridge = bridgeObj.bridge; - var isNative = bridgeObj.isNative; - - function WebContents(id) { - EventEmitter.call(this); - this.id = id; this._url = ''; this._title = ''; this._isLoading = false; - this._zoomFactor = 1.0; this._zoomLevel = 0; this._userAgent = ''; this._audioMuted = false; - } - WebContents.prototype = Object.create(EventEmitter.prototype); - WebContents.prototype.constructor = WebContents; - Object.defineProperty(WebContents.prototype, 'URL', { get: function() { return this._url; } }); - Object.defineProperty(WebContents.prototype, 'isLoading', { get: function() { return this._isLoading; } }); - Object.defineProperty(WebContents.prototype, 'title', { get: function() { return this._title; } }); - Object.defineProperty(WebContents.prototype, 'session', { get: function() { - var self = this; - return { - id: 'session-' + self.id, - cookies: { get: function() { return Promise.resolve([]); }, set: function() {}, remove: function() {} }, - protocol: { registerFileProtocol: function() {}, registerHttpProtocol: function() {}, unregisterProtocol: function() {}, isProtocolRegistered: function() { return false; } }, - setPermissionRequestHandler: function() {}, setPermissionCheckHandler: function() {}, - webRequest: { onBeforeRequest: function() {}, onHeadersReceived: function() {} }, - setUserAgent: function() {}, getUserAgent: function() { return ''; }, - }; - }}); - Object.defineProperty(WebContents.prototype, 'processId', { get: function() { return process.pid; } }); - WebContents.prototype.loadURL = function(url) { - this._url = url; this._isLoading = true; this.emit('did-start-loading'); - if (isNative) bridge.loadUrl(this.id, url); - var self = this; - setTimeout(function() { self._isLoading = false; self.emit('did-stop-loading'); self.emit('did-finish-load'); self.emit('dom-ready'); }, isNative ? 500 : 100); - return Promise.resolve(); - }; - WebContents.prototype.loadFile = function(fp) { - var url = 'file://' + path.resolve(fp); - this._url = url; this._isLoading = true; this.emit('did-start-loading'); - if (isNative) bridge.loadFile(this.id, fp); - var self = this; - setTimeout(function() { self._isLoading = false; self.emit('did-stop-loading'); self.emit('did-finish-load'); self.emit('dom-ready'); }, isNative ? 500 : 100); - return Promise.resolve(); - }; - WebContents.prototype.reload = function() { - this._isLoading = true; this.emit('did-start-loading'); - if (isNative && this._url) bridge.loadUrl(this.id, this._url); - var self = this; - setTimeout(function() { self._isLoading = false; self.emit('did-stop-loading'); self.emit('did-finish-load'); }, 50); - return Promise.resolve(); - }; - WebContents.prototype.canGoBack = function() { return false; }; - WebContents.prototype.canGoForward = function() { return false; }; - WebContents.prototype.goBack = function() {}; - WebContents.prototype.goForward = function() {}; - WebContents.prototype.executeJavaScript = function(code) { if (isNative) bridge.evalJs(this.id, code); return Promise.resolve(null); }; - WebContents.prototype.insertCSS = function() { return Promise.resolve(0); }; - WebContents.prototype.insertJS = function(code) { return this.executeJavaScript(code); }; - WebContents.prototype.send = function(channel) { - var args = [this.id, channel].concat(Array.prototype.slice.call(arguments, 1)); - if (isNative) bridge.sendToRenderer.apply(bridge, args); - }; - WebContents.prototype.sendInputEvent = function() {}; - WebContents.prototype.setZoomFactor = function(f) { this._zoomFactor = f; }; - WebContents.prototype.getZoomFactor = function() { return this._zoomFactor; }; - WebContents.prototype.setZoomLevel = function(l) { this._zoomLevel = l; }; - WebContents.prototype.getZoomLevel = function() { return this._zoomLevel; }; - WebContents.prototype.setUserAgent = function(ua) { this._userAgent = ua; }; - WebContents.prototype.getUserAgent = function() { return this._userAgent; }; - WebContents.prototype.setAudioMuted = function(m) { this._audioMuted = m; }; - WebContents.prototype.isAudioMuted = function() { return this._audioMuted; }; - WebContents.prototype.openDevTools = function() {}; - WebContents.prototype.closeDevTools = function() {}; - WebContents.prototype.isDevToolsOpened = function() { return false; }; - WebContents.prototype.toggleDevTools = function() {}; - WebContents.prototype.inspectElement = function() {}; - WebContents.prototype.setIgnoreMenuShortcuts = function() {}; - WebContents.prototype.setWindowOpenHandler = function() { return { action: 'deny' }; }; - WebContents.prototype.setPermissionRequestHandler = function() {}; - WebContents.prototype.setCertificateVerifyProc = function() {}; - WebContents.prototype.setBackgroundColor = function() {}; - WebContents.prototype.isCrashed = function() { return false; }; - WebContents.prototype.capturePage = function() { return Promise.resolve(null); }; - WebContents.prototype.getResourceUsage = function() { return { images: 0, scripts: 0, css: 0, xhr: 0, webgl: 0 }; }; - WebContents.prototype.type = function() { return 'backgroundPage'; }; - WebContents.prototype.focused = function() { return false; }; - WebContents.prototype.isFocused = function() { return false; }; - WebContents.prototype.destroy = function() {}; - - function BrowserWindow(opts) { - EventEmitter.call(this); - opts = opts || {}; - this.id = BrowserWindow._nextId++; - this._options = { - width: opts.width || 800, height: opts.height || 600, - minWidth: opts.minWidth || 0, minHeight: opts.minHeight || 0, - maxWidth: opts.maxWidth || 0, maxHeight: opts.maxHeight || 0, - title: opts.title || 'Gelectron', backgroundColor: opts.backgroundColor || '#ffffff', - show: opts.show !== false, frame: opts.frame !== false, - resizable: opts.resizable !== false, minimizable: opts.minimizable !== false, - maximizable: opts.maximizable !== false, closable: opts.closable !== false, - fullscreen: opts.fullscreen || false, alwaysOnTop: opts.alwaysOnTop || false, - transparent: opts.transparent || false, decorations: opts.decorations !== false, - icon: opts.icon || null, titleBarStyle: opts.titleBarStyle || 'default', - trafficLightPosition: opts.trafficLightPosition || null, vibrancy: opts.vibrancy || null, - webPreferences: Object.assign({ - preload: null, contextIsolation: true, nodeIntegration: false, sandbox: false, - devTools: true, webSecurity: true, allowRunningInsecureContent: false, experimentalFeatures: false, - }, opts.webPreferences || {}), - }; - this._url = ''; this._isDestroyed = false; this._isVisible = this._options.show; - this._isMinimized = false; this._isMaximized = false; this._isFullScreen = this._options.fullscreen; - this.webContents = new WebContents(this.id); - BrowserWindow._windows.set(this.id, this); - var appMod = req('app'); - if (appMod && appMod.app && typeof appMod.app._trackWindow === 'function') { - appMod.app._trackWindow(); - } - if (isNative) { - bridge.createWindow(this.id, { width: this._options.width, height: this._options.height, title: this._options.title, show: this._options.show, resizable: this._options.resizable, alwaysOnTop: this._options.alwaysOnTop, fullscreen: this._options.fullscreen }); - } - if (this._options.show) { - var self = this; - process.nextTick(function() { if (!self._isDestroyed) { self.emit('ready-to-show'); self.show(); } }); - } - } - BrowserWindow.prototype = Object.create(EventEmitter.prototype); - BrowserWindow.prototype.constructor = BrowserWindow; - BrowserWindow._windows = new Map(); - BrowserWindow._nextId = 2; - BrowserWindow.fromWebContents = function(wc) { - var wins = BrowserWindow._windows.values(); - var w; while (!(w = wins.next()).done) { if (w.value.webContents && w.value.webContents.id === wc.id) return w.value; } - return null; - }; - BrowserWindow.getAllWindows = function() { - var out = [], wins = BrowserWindow._windows.values(), w; - while (!(w = wins.next()).done) { if (!w.value.isDestroyed()) out.push(w.value); } - return out; - }; - BrowserWindow.getFocusedWindow = function() { return null; }; - BrowserWindow.fromId = function(id) { return BrowserWindow._windows.get(id) || null; }; - BrowserWindow.addExtension = function() {}; - BrowserWindow.removeExtension = function() {}; - BrowserWindow.getExtensions = function() { return {}; }; - BrowserWindow.prototype.loadURL = function(url) { this._url = url; if (isNative) bridge.loadUrl(this.id, url); return this.webContents.loadURL(url); }; - BrowserWindow.prototype.loadFile = function(fp) { return this.webContents.loadFile(fp); }; - BrowserWindow.prototype.show = function() { if (this._isDestroyed) return; this._isVisible = true; this._isMinimized = false; if (isNative) bridge.showWindow(this.id); this.emit('show'); }; - BrowserWindow.prototype.hide = function() { if (this._isDestroyed) return; this._isVisible = false; if (isNative) bridge.hideWindow(this.id); this.emit('hide'); }; - BrowserWindow.prototype.close = function() { if (this._isDestroyed) return; this.emit('close'); this.destroy(); }; - BrowserWindow.prototype.destroy = function() { - if (this._isDestroyed) return; - this._isDestroyed = true; - if (isNative) bridge.destroyWindow(this.id); - BrowserWindow._windows.delete(this.id); - var appMod = req('app'); - if (appMod && appMod.app && typeof appMod.app._untrackWindow === 'function') { - appMod.app._untrackWindow(); - } - this.emit('closed'); - }; - BrowserWindow.prototype.focus = function() { if (!this._isDestroyed) { if (isNative) bridge.focusWindow(this.id); this.emit('focus'); } }; - BrowserWindow.prototype.blur = function() {}; - BrowserWindow.prototype.minimize = function() { if (!this._isDestroyed) { this._isMinimized = true; if (isNative) bridge.minimizeWindow(this.id); this.emit('minimize'); } }; - BrowserWindow.prototype.maximize = function() { if (!this._isDestroyed) { this._isMaximized = true; if (isNative) bridge.maximizeWindow(this.id); this.emit('maximize'); } }; - BrowserWindow.prototype.unmaximize = function() { if (!this._isDestroyed) { this._isMaximized = false; this.emit('unmaximize'); } }; - BrowserWindow.prototype.restore = function() { if (!this._isDestroyed) { this._isMinimized = false; this._isMaximized = false; this.emit('restore'); } }; - BrowserWindow.prototype.setFullScreen = function(f) { this._isFullScreen = f; this.emit('enter-full-screen'); }; - BrowserWindow.prototype.isFullScreen = function() { return this._isFullScreen; }; - BrowserWindow.prototype.isMinimized = function() { return this._isMinimized; }; - BrowserWindow.prototype.isMaximized = function() { return this._isMaximized; }; - BrowserWindow.prototype.isVisible = function() { return this._isVisible; }; - BrowserWindow.prototype.isDestroyed = function() { return this._isDestroyed; }; - BrowserWindow.prototype.isFocused = function() { return false; }; - BrowserWindow.prototype.isNormal = function() { return !this._isMinimized && !this._isMaximized && !this._isFullScreen; }; - BrowserWindow.prototype.setAlwaysOnTop = function(f) { this._options.alwaysOnTop = f; }; - BrowserWindow.prototype.isAlwaysOnTop = function() { return this._options.alwaysOnTop; }; - BrowserWindow.prototype.setPosition = function() {}; - BrowserWindow.prototype.getPosition = function() { return [0, 0]; }; - BrowserWindow.prototype.setSize = function(w, h) { this._options.width = w; this._options.height = h; }; - BrowserWindow.prototype.getSize = function() { return [this._options.width, this._options.height]; }; - BrowserWindow.prototype.setMinimumSize = function(w, h) { this._options.minWidth = w; this._options.minHeight = h; }; - BrowserWindow.prototype.getMinimumSize = function() { return [this._options.minWidth, this._options.minHeight]; }; - BrowserWindow.prototype.setMaximumSize = function(w, h) { this._options.maxWidth = w; this._options.maxHeight = h; }; - BrowserWindow.prototype.getMaximumSize = function() { return [this._options.maxWidth, this._options.maxHeight]; }; - BrowserWindow.prototype.setResizable = function(v) { this._options.resizable = v; }; - BrowserWindow.prototype.isResizable = function() { return this._options.resizable; }; - BrowserWindow.prototype.setMovable = function() {}; - BrowserWindow.prototype.isMovable = function() { return true; }; - BrowserWindow.prototype.setMinimizable = function(v) { this._options.minimizable = v; }; - BrowserWindow.prototype.isMinimizable = function() { return this._options.minimizable; }; - BrowserWindow.prototype.setMaximizable = function(v) { this._options.maximizable = v; }; - BrowserWindow.prototype.isMaximizable = function() { return this._options.maximizable; }; - BrowserWindow.prototype.setClosable = function(v) { this._options.closable = v; }; - BrowserWindow.prototype.isClosable = function() { return this._options.closable; }; - BrowserWindow.prototype.setTitle = function(t) { this._options.title = t; this.webContents._title = t; if (isNative) bridge.setTitle(this.id, t); }; - BrowserWindow.prototype.getTitle = function() { return this._options.title; }; - BrowserWindow.prototype.setSkipTaskbar = function() {}; - BrowserWindow.prototype.setKiosk = function() {}; - BrowserWindow.prototype.isKiosk = function() { return false; }; - BrowserWindow.prototype.center = function() {}; - BrowserWindow.prototype.setBounds = function() {}; - BrowserWindow.prototype.getBounds = function() { return { x: 0, y: 0, width: this._options.width, height: this._options.height }; }; - BrowserWindow.prototype.setSimpleFullScreen = function() {}; - BrowserWindow.prototype.isSimpleFullScreen = function() { return false; }; - BrowserWindow.prototype.setAutoHideCursor = function() {}; - BrowserWindow.prototype.setContentBounds = function() {}; - BrowserWindow.prototype.getContentBounds = function() { return this.getBounds(); }; - BrowserWindow.prototype.isEnabled = function() { return true; }; - BrowserWindow.prototype.setEnabled = function() {}; - BrowserWindow.prototype.setProgressBar = function() {}; - BrowserWindow.prototype.setOverlayIcon = function() {}; - BrowserWindow.prototype.setVisibleOnAllWorkspaces = function() {}; - BrowserWindow.prototype.isVisibleOnAllWorkspaces = function() { return false; }; - BrowserWindow.prototype.setVibrancy = function() {}; - BrowserWindow.prototype.getNativeWindowHandle = function() { return Buffer.alloc(0); }; - BrowserWindow.prototype.setHasShadow = function() {}; - BrowserWindow.prototype.hasShadow = function() { return true; }; - BrowserWindow.prototype.setOpacity = function() {}; - BrowserWindow.prototype.getOpacity = function() { return 1.0; }; - BrowserWindow.prototype.setThumbarButtons = function() {}; - BrowserWindow.prototype.setThumbnailClip = function() {}; - BrowserWindow.prototype.setThumbnailToolTip = function() {}; - BrowserWindow.prototype.setAppDetails = function() {}; - BrowserWindow.prototype.setForeground = function() {}; - BrowserWindow.prototype.flashFrame = function() {}; - BrowserWindow.prototype.setIcon = function() {}; - BrowserWindow.prototype.setBackgroundColor = function(c) { this._options.backgroundColor = c; }; - BrowserWindow.prototype.getBackgroundColor = function() { return this._options.backgroundColor; }; - BrowserWindow.prototype.capturePage = function() { return this.webContents.capturePage(); }; - BrowserWindow.prototype.print = function() {}; - BrowserWindow.prototype.printToPDF = function() { return Promise.resolve(Buffer.alloc(0)); }; - BrowserWindow.prototype.setParentWindow = function() {}; - BrowserWindow.prototype.getParentWindow = function() { return null; }; - BrowserWindow.prototype.getChildWindows = function() { return []; }; - BrowserWindow.prototype.selectPreviousTab = function() {}; - BrowserWindow.prototype.selectNextTab = function() {}; - BrowserWindow.prototype.mergeAllWindows = function() {}; - BrowserWindow.prototype.moveTabToNewWindow = function() {}; - BrowserWindow.prototype.toggleTabBar = function() {}; - BrowserWindow.prototype.addTabbedWindow = function() {}; - - module.exports = { BrowserWindow: BrowserWindow, WebContents: WebContents }; -}); - -/* ─── ipc-main ───────────────────────────────────────────────────── */ -_define('ipc-main', function(req, module) { - var EventEmitter = req('events').EventEmitter; - function IpcMain() { - EventEmitter.call(this); - this._handlers = new Map(); - this._onceHandlers = new Map(); - } - IpcMain.prototype = Object.create(EventEmitter.prototype); - IpcMain.prototype.constructor = IpcMain; - IpcMain.prototype.handle = function(ch, fn) { if (typeof fn !== 'function') throw new TypeError('Expected function'); this._handlers.set(ch, fn); return this; }; - IpcMain.prototype.handleOnce = function(ch, fn) { if (typeof fn !== 'function') throw new TypeError('Expected function'); this._onceHandlers.set(ch, fn); return this; }; - IpcMain.prototype.on = function(ch, fn) { if (typeof fn !== 'function') throw new TypeError('Expected function'); EventEmitter.prototype.on.call(this, ch, fn); return this; }; - IpcMain.prototype.once = function(ch, fn) { if (typeof fn !== 'function') throw new TypeError('Expected function'); EventEmitter.prototype.once.call(this, ch, fn); return this; }; - IpcMain.prototype.removeHandler = function(ch) { this._handlers.delete(ch); return this; }; - IpcMain.prototype.removeListener = function(ch, fn) { EventEmitter.prototype.removeListener.call(this, ch, fn); return this; }; - IpcMain.prototype.removeAllListeners = function(ch) { EventEmitter.prototype.removeAllListeners.call(this, ch); return this; }; - IpcMain.prototype.listenerCount = function(ch) { return EventEmitter.prototype.listenerCount.call(this, ch); }; - IpcMain.prototype.rawListeners = function(ch) { return EventEmitter.prototype.rawListeners.call(this, ch); }; - IpcMain.prototype.eventNames = function() { return EventEmitter.prototype.eventNames.call(this); }; - IpcMain.prototype._invoke = function(ch) { - var handler = this._handlers.get(ch); - if (!handler) return Promise.reject(new Error("No handler for '" + ch + "'")); - try { var r = handler.apply(null, Array.prototype.slice.call(arguments, 1)); return r instanceof Promise ? r : Promise.resolve(r); } catch(e) { return Promise.reject(e); } - }; - IpcMain.prototype._emit = function(ch) { return this.emit.apply(this, arguments); }; - IpcMain.prototype._emitOnce = function(ch) { - var handler = this._onceHandlers.get(ch); - if (handler) { this._onceHandlers.delete(ch); return handler.apply(null, Array.prototype.slice.call(arguments, 1)); } - return this.emit.apply(this, arguments); - }; - module.exports = new IpcMain(); -}); - -/* ─── menu ───────────────────────────────────────────────────────── */ -_define('menu', function(req, module) { - var EventEmitter = req('events').EventEmitter; - - function MenuItem(opts) { - EventEmitter.call(this); - opts = opts || {}; - this.id = opts.id || ''; this.label = opts.label || ''; this.type = opts.type || 'normal'; - this.role = opts.role || ''; this.accelerator = opts.accelerator || ''; - this.enabled = opts.enabled !== false; this.visible = opts.visible !== false; - this.checked = opts.checked || false; this.submenu = opts.submenu || null; - this.toolTip = opts.toolTip || ''; this.icon = opts.icon || null; - this._click = opts.click || null; - if (this.submenu && !(this.submenu instanceof Menu)) { - if (Array.isArray(this.submenu)) { - this.submenu = Menu.buildFromTemplate(this.submenu); - } else if (this.submenu.items) { - this.submenu = Menu.buildFromTemplate(this.submenu.items); - } - } - } - MenuItem.prototype = Object.create(EventEmitter.prototype); - MenuItem.prototype.constructor = MenuItem; - MenuItem.prototype.click = function() { if (this._click) this._click(this, null); this.emit('click'); }; - - function Menu() { EventEmitter.call(this); this.items = []; this._id = Menu._nextId++; } - Menu.prototype = Object.create(EventEmitter.prototype); - Menu.prototype.constructor = Menu; - Menu._nextId = 1; - Menu._applicationMenu = null; - Menu.buildFromTemplate = function(template) { - var menu = new Menu(); - if (Array.isArray(template)) { - menu.items = template.map(function(item) { - if (item instanceof MenuItem) return item; - if (item.type === 'separator') return new MenuItem({ type: 'separator' }); - return new MenuItem(item); - }); - } - return menu; - }; - Menu.getApplicationMenu = function() { return Menu._applicationMenu || null; }; - Menu.setApplicationMenu = function(m) { - Menu._applicationMenu = m; - if (m) { - var bridgeObj = req('native-bridge'); - if (bridgeObj.isNative) { - bridgeObj.bridge._send({ type: 'set-application-menu', menu: m._serialize() }); - } - } - }; - Menu.prototype.append = function(mi) { this.items.push(mi instanceof MenuItem ? mi : new MenuItem(mi)); return this; }; - Menu.prototype.insert = function(mi, pos) { this.items.splice(pos, 0, mi instanceof MenuItem ? mi : new MenuItem(mi)); return this; }; - Menu.prototype.popup = function(opts) { - var bridgeObj = req('native-bridge'); - if (bridgeObj.isNative) { - bridgeObj.bridge._send({ type: 'popup-menu', menu: this._serialize(), x: opts && opts.x, y: opts && opts.y }); - } - }; - Menu.prototype.closePopup = function() { - var bridgeObj = req('native-bridge'); - if (bridgeObj.isNative) { bridgeObj.bridge._send({ type: 'close-popup-menu' }); } - }; - Menu.prototype.getMenuItemById = function(id) { return _find(this.items, id); }; - Menu.prototype._serialize = function() { - return { items: this.items.map(function(item) { - var obj = { id: item.id, label: item.label, type: item.type, role: item.role, accelerator: item.accelerator, enabled: item.enabled, visible: item.visible, checked: item.checked, toolTip: item.toolTip }; - if (item.submenu instanceof Menu) obj.submenu = item.submenu._serialize(); - else if (item.submenu && Array.isArray(item.submenu)) obj.submenu = Menu.buildFromTemplate(item.submenu)._serialize(); - return obj; - }) }; - }; - function _find(items, id) { - for (var i = 0; i < items.length; i++) { - if (items[i].id === id) return items[i]; - if (items[i].submenu) { - var sub = items[i].submenu instanceof Menu ? items[i].submenu.items : (items[i].submenu.items || items[i].submenu); - var f = _find(sub, id); if (f) return f; - } - } - return null; - } - module.exports = { Menu: Menu, MenuItem: MenuItem }; -}); - -/* ─── tray ───────────────────────────────────────────────────────── */ -_define('tray', function(req, module) { - var EventEmitter = req('events').EventEmitter; - function Tray(image) { - EventEmitter.call(this); - this.id = Tray._nextId++; this._image = image; this._tooltip = ''; - this._menu = null; this._isDestroyed = false; - Tray._trays.set(this.id, this); - } - Tray.prototype = Object.create(EventEmitter.prototype); - Tray.prototype.constructor = Tray; - Tray._trays = new Map(); Tray._nextId = 1; - Tray.prototype.setToolTip = function(t) { this._tooltip = t; }; - Tray.prototype.getToolTip = function() { return this._tooltip; }; - Tray.prototype.setImage = function(i) { this._image = i; }; - Tray.prototype.setPressedImage = function() {}; - Tray.prototype.setContextMenu = function(m) { this._menu = m; }; - Tray.prototype.getContextMenu = function() { return this._menu; }; - Tray.prototype.popupContextMenu = function() {}; - Tray.prototype.isDestroyed = function() { return this._isDestroyed; }; - Tray.prototype.destroy = function() { this._isDestroyed = true; Tray._trays.delete(this.id); this.emit('destroy'); }; - Tray.prototype.getBounds = function() { return { x: 0, y: 0, width: 22, height: 22 }; }; - Tray.fromId = function(id) { return Tray._trays.get(id) || null; }; - Tray.getAllTrays = function() { return Array.from(Tray._trays.values()); }; - module.exports = { Tray: Tray }; -}); - -/* ─── dialog ─────────────────────────────────────────────────────── */ -_define('dialog', function(req, module) { - function _opts(a, b) { - var o = b || a || {}; - if (a && a.webContents) o = b || {}; - return o; - } - module.exports = { - showOpenDialog: function(a, b) { - var o = _opts(a, b); - if (typeof globalThis.__gelectron_dialog_open === 'function') return globalThis.__gelectron_dialog_open(o); - return Promise.resolve({ canceled: true, filePaths: [] }); - }, - showSaveDialog: function(a, b) { - var o = _opts(a, b); - if (typeof globalThis.__gelectron_dialog_save === 'function') return globalThis.__gelectron_dialog_save(o); - return Promise.resolve({ canceled: true, filePath: undefined }); - }, - showMessageBox: function(a, b) { - var o = _opts(a, b); - if (typeof globalThis.__gelectron_dialog_message === 'function') return globalThis.__gelectron_dialog_message(o); - return Promise.resolve({ response: 0, checkboxChecked: false }); - }, - showErrorBox: function(title, content) { console.error('[gelectron] ' + title + ': ' + content); }, - showMessageBoxSync: function(a, b) { - var o = _opts(a, b); - if (typeof globalThis.__gelectron_dialog_message_sync === 'function') return globalThis.__gelectron_dialog_message_sync(o); - return 0; - }, - showCertificateTrustDialog: function() { return Promise.resolve(); }, - }; -}); - -/* ─── shell ──────────────────────────────────────────────────────── */ -_define('shell', function(req, module) { - module.exports = { - openExternal: function(url) { - try { window.open(url, '_blank'); } catch(e) {} - return Promise.resolve(); - }, - openPath: function(p) { - try { window.open('file://' + p, '_blank'); } catch(e) {} - return Promise.resolve(''); - }, - showItemInFolder: function() {}, - moveItemToTrash: function() { return Promise.resolve(''); }, - beep: function() {}, - writeShortcutLink: function() { return true; }, - readShortcutLink: function() { return { target: '', cwd: '', args: '', description: '', icon: '', iconIndex: 0 }; }, - }; -}); - -/* ─── notification ───────────────────────────────────────────────── */ -_define('notification', function(req, module) { - var EventEmitter = req('events').EventEmitter; - function Notification(opts) { - EventEmitter.call(this); - opts = opts || {}; - this.id = Notification._nextId++; this.title = opts.title || ''; this.body = opts.body || ''; - this.subtitle = opts.subtitle || ''; this.silent = opts.silent || false; - this.icon = opts.icon || null; this.urgency = opts.urgency || 'normal'; - this.timeoutType = opts.timeoutType || 'default'; this.closeButtonText = opts.closeButtonText || ''; - this.toastXml = opts.toastXml || ''; this.actions = opts.actions || []; - this.replyPlaceholder = opts.replyPlaceholder || ''; - Notification._notifications.set(this.id, this); - } - Notification.prototype = Object.create(EventEmitter.prototype); - Notification.prototype.constructor = Notification; - Notification._notifications = new Map(); Notification._nextId = 1; - Notification.isSupported = function() { return true; }; - Notification.prototype.show = function() { - if (typeof globalThis.Notification !== 'undefined' && globalThis.Notification.permission === 'granted') { - new globalThis.Notification(this.title, { body: this.body, icon: this.icon }); - } - this.emit('show'); return true; - }; - Notification.prototype.close = function() { Notification._notifications.delete(this.id); this.emit('close'); }; - Notification.fromNotification = function(n) { return n; }; - module.exports = { Notification: Notification }; -}); - -/* ─── native-image ───────────────────────────────────────────────── */ -_define('native-image', function(req, module) { - function NativeImage() { this._isEmpty = true; this._width = 0; this._height = 0; this._data = null; } - NativeImage.createFromPath = function(p) { - var img = new NativeImage(); - try { - var data = req('fs').readFileSync(p); - if (data.length > 24 && data[0] === 0x89 && data[1] === 0x50) { - img._width = data.readUInt32BE(16); img._height = data.readUInt32BE(20); - img._data = data; img._isEmpty = false; - } - } catch(e) {} - return img; - }; - NativeImage.createFromBuffer = function(buf, opts) { - opts = opts || {}; var img = new NativeImage(); - if (buf && buf.length > 0) { - img._data = buf; img._isEmpty = false; img._width = opts.width || 0; img._height = opts.height || 0; - if (buf.length > 24 && buf[0] === 0x89 && buf[1] === 0x50) { img._width = buf.readUInt32BE(16); img._height = buf.readUInt32BE(20); } - } - return img; - }; - NativeImage.createFromDataURL = function(d) { - var m = d.match(/^data:[^;]+;base64,(.+)$/); - if (m) return NativeImage.createFromBuffer(Buffer.from(m[1], 'base64')); - return NativeImage.createEmpty(); - }; - NativeImage.createEmpty = function() { return new NativeImage(); }; - NativeImage.prototype.toPNG = function() { return this._data || Buffer.alloc(0); }; - NativeImage.prototype.toJPEG = function() { return this._data || Buffer.alloc(0); }; - NativeImage.prototype.toBitmap = function() { return this._data || Buffer.alloc(0); }; - NativeImage.prototype.toDataURL = function() { if (!this._data) return 'data:,'; return 'data:image/png;base64,' + Buffer.from(this._data).toString('base64'); }; - NativeImage.prototype.resize = function(opts) { - var r = new NativeImage(); r._width = opts.width || this._width; r._height = opts.height || this._height; - r._data = this._data; r._isEmpty = this._isEmpty; return r; - }; - NativeImage.prototype.crop = function(rect) { return this.resize({ width: rect.width, height: rect.height }); }; - NativeImage.prototype.getBitmap = function() { return this._data || Buffer.alloc(0); }; - NativeImage.prototype.getSize = function() { return { width: this._width, height: this._height }; }; - NativeImage.prototype.isEmpty = function() { return this._isEmpty; }; - NativeImage.prototype.setTemplateImage = function(t) { this._isTemplate = t; }; - NativeImage.prototype.isTemplateImage = function() { return this._isTemplate || false; }; - module.exports = NativeImage; -}); - -/* ─── safe-storage ───────────────────────────────────────────────── */ -_define('safe-storage', function(req, module) { - module.exports = { - isAvailable: function() { return true; }, - encryptString: function(s) { return Promise.resolve(Buffer.from(s).toString('base64')); }, - decryptString: function(s) { return Promise.resolve(Buffer.from(s, 'base64').toString('utf-8')); }, - encryptBuffer: function(b) { return Promise.resolve(Buffer.from(b).toString('base64')); }, - decryptBuffer: function(s) { return Promise.resolve(Buffer.from(s, 'base64')); }, - }; -}); - -/* ─── context-bridge ─────────────────────────────────────────────── */ -_define('context-bridge', function(req, module) { - function deepFreeze(o) { - if (typeof o !== 'object' || o === null) return o; - Object.freeze(o); - Object.keys(o).forEach(function(k) { if (typeof o[k] === 'object' && o[k] !== null && !Object.isFrozen(o[k])) deepFreeze(o[k]); }); - return o; - } - module.exports = { - exposeInMainWorld: function(key, api) { - if (typeof window === 'undefined') return; - window[key] = deepFreeze(JSON.parse(JSON.stringify(api))); - }, - }; -}); - -/* ─── web-contents ───────────────────────────────────────────────── */ -_define('web-contents', function(req, module) { - var BrowserWindow = req('browser-window').BrowserWindow; - module.exports = { - getAllWebContents: function() { return BrowserWindow.getAllWindows().map(function(w) { return w.webContents; }); }, - getFocusedWebContents: function() { var f = BrowserWindow.getFocusedWindow(); return f ? f.webContents : null; }, - fromId: function(id) { var w = BrowserWindow.fromId(id); return w ? w.webContents : null; }, - }; -}); - -/* ─── auto-updater ───────────────────────────────────────────────── */ -_define('auto-updater', function(req, module) { - var EventEmitter = req('events').EventEmitter; - function AutoUpdater() { - EventEmitter.call(this); - this._isUpdateAvailable = false; this._updateInfo = null; this._feedURL = null; - this.autoDownload = true; this.autoInstallOnAppQuit = false; this.autoRunAppAfterInstall = true; - this._logger = console; - } - AutoUpdater.prototype = Object.create(EventEmitter.prototype); - AutoUpdater.prototype.constructor = AutoUpdater; - AutoUpdater.prototype.getFeedURL = function() { return this._feedURL; }; - AutoUpdater.prototype.setFeedURL = function(o) { this._feedURL = o; }; - AutoUpdater.prototype.checkForUpdates = function() { return Promise.resolve({ updateInfo: null, isUpdateAvailable: false }); }; - AutoUpdater.prototype.checkForAndNotifyIfAvailable = function() { return this.checkForUpdates(); }; - AutoUpdater.prototype.downloadUpdate = function() { return Promise.resolve(); }; - AutoUpdater.prototype.quitAndInstall = function() { this.emit('before-quit-for-update'); process.exit(0); }; - AutoUpdater.prototype.quitAndInstallAgain = function() { this.quitAndInstall(); }; - AutoUpdater.prototype.updateDownloaded = function() { return Promise.resolve(false); }; - Object.defineProperty(AutoUpdater.prototype, 'isUpdateActive', { get: function() { return false; } }); - Object.defineProperty(AutoUpdater.prototype, 'updateInfo', { get: function() { return this._updateInfo; } }); - Object.defineProperty(AutoUpdater.prototype, 'logger', { get: function() { return this._logger; }, set: function(v) { this._logger = v; } }); - var autoUpdater = new AutoUpdater(); - module.exports = { autoUpdater: autoUpdater, AutoUpdater: AutoUpdater }; -}); - -/* ─── index (main electron module) ───────────────────────────────── */ -_define('index', function(req, module) { - var app = req('app').app; - var BrowserWindow = req('browser-window').BrowserWindow; - var ipcMain = req('ipc-main'); - var Menu = req('menu').Menu; - var MenuItem = req('menu').MenuItem; - var Tray = req('tray').Tray; - var dialog = req('dialog'); - var shell = req('shell'); - var Notification = req('notification').Notification; - var nativeImage = req('native-image'); - var safeStorage = req('safe-storage'); - var contextBridge = req('context-bridge'); - var webContents = req('web-contents'); - var autoUpdater = req('auto-updater').autoUpdater; - var AutoUpdater = req('auto-updater').AutoUpdater; - var bridgeObj = req('native-bridge'); - var bridge = bridgeObj.bridge; - var isNative = bridgeObj.isNative; - - if (isNative) { - bridge.on('ipc-message', function(windowId, channel, data) { - var event = { sender: { id: windowId }, channel: channel }; - ipcMain._emit(channel, event, data); - }); - } - - var sessionStub = { - defaultSession: { - cookies: { get: function() { return Promise.resolve([]); }, set: function() {}, remove: function() {}, getSession: function() { return null; } }, - protocol: { registerFileProtocol: function() {}, registerHttpProtocol: function() {}, unregisterProtocol: function() {}, isProtocolRegistered: function() { return false; } }, - setPermissionRequestHandler: function() {}, setPermissionCheckHandler: function() {}, - webRequest: { onBeforeRequest: function() {}, onHeadersReceived: function() {} }, - setUserAgent: function() {}, getUserAgent: function() { return ''; }, - }, - fromPartition: function() { - return { - cookies: { get: function() { return Promise.resolve([]); }, set: function() {}, remove: function() {} }, - protocol: { registerFileProtocol: function() {}, registerHttpProtocol: function() {}, unregisterProtocol: function() {}, isProtocolRegistered: function() { return false; } }, - webRequest: { onBeforeRequest: function() {}, onHeadersReceived: function() {}, resolveProxy: function() { return Promise.resolve(''); } }, - setUserAgent: function() {}, getUserAgent: function() { return ''; }, - clearCache: function() { return Promise.resolve(); }, clearStorageData: function() { return Promise.resolve(); }, - setProxy: function() { return Promise.resolve(); }, getProxy: function() { return Promise.resolve({ mode: 'direct' }); }, - }; - }, - }; - - module.exports = { - app: app, - BrowserWindow: BrowserWindow, - ipcMain: ipcMain, - Menu: Menu, - MenuItem: MenuItem, - Tray: Tray, - dialog: dialog, - shell: shell, - Notification: Notification, - nativeImage: nativeImage, - safeStorage: safeStorage, - contextBridge: contextBridge, - webContents: webContents, - autoUpdater: autoUpdater, - AutoUpdater: AutoUpdater, - session: sessionStub, - clipboard: { readText: function() { return ''; }, writeText: function() {}, readImage: function() { return nativeImage.createEmpty(); }, writeImage: function() {} }, - screen: { - getPrimaryDisplay: function() { return { 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: function() { return []; }, - getDisplayMatching: function() { return null; }, - }, - systemPreferences: { - isDarkMode: function() { return false; }, getAccentColor: function() { return '#007AFF'; }, getColor: function() { return '#ffffff'; }, - isSwipeTrackingFromScrollEventsEnabled: function() { return false; }, - subscribeNotification: function() { return function() {}; }, unsubscribeNotification: function() {}, - subscribeLocalNotification: function() { return function() {}; }, unsubscribeLocalNotification: function() {}, - getUserDefault: function() { return null; }, setUserDefault: function() {}, removeUserDefault: function() {}, - }, - powerMonitor: { on: function() {}, off: function() {}, once: function() {}, getSystemIdleState: function() { return 'active'; }, getSystemIdleTime: function() { return 0; }, isInLowPowerMode: function() { return false; } }, - globalShortcut: { register: function() { return true; }, unregister: function() {}, unregisterAll: function() {}, isRegistered: function() { return false; } }, - net: { fetch: (typeof globalThis.fetch === 'function' ? globalThis.fetch : function() { return Promise.reject(new Error('fetch not available')); }) }, - IPCRenderer: { invoke: function() { return Promise.resolve(); }, send: function() {}, on: function() { return function() {}; }, removeListener: function() {} }, - }; -}); - -/* ─── IPC adapter: send to Rust via webkit messageHandlers ──────── */ -function _ipcSend(msg) { - try { - if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.ipc) { - window.webkit.messageHandlers.ipc.postMessage(JSON.stringify(msg)); - } - } catch(e) {} -} - -/* ─── Wire up IPC listener to dispatch incoming Rust messages ───── */ -window.addEventListener('message', function(event) { - var data = event.data; - if (!data || typeof data !== 'object') return; - try { if (typeof data === 'string') data = JSON.parse(data); } catch(e) { return; } - if (!data.type) return; - var ipcMain = require('ipc-main'); - switch (data.type) { - case 'ipc-message': - var ev = { sender: { id: data.id || 0 }, channel: data.channel }; - ipcMain._emit(data.channel, ev, data.data); - break; - case 'ipc-invoke-response': - break; - } -}); - -/* ─── Public API ─────────────────────────────────────────────────── */ -window.electron = require('index'); -window.require = require; -window.__gelectron_ready = true; - -window.__gelectron_run_main = function(script) { - try { - var fn = new Function('require', 'module', 'exports', '__dirname', '__filename', 'process', 'Buffer', 'global', 'window', 'console', 'setTimeout', 'setInterval', 'clearTimeout', 'clearInterval', 'URL', 'URLSearchParams', 'fetch', 'navigator', script); - var m = { exports: {} }; - fn(require, m, m.exports, window.__dirname || __dirname, window.__filename || __filename, process, Buffer, globalThis, window, console, setTimeout, setInterval, clearTimeout, clearInterval, typeof URL !== 'undefined' ? URL : null, typeof URLSearchParams !== 'undefined' ? URLSearchParams : null, typeof fetch === 'function' ? fetch : function() { return Promise.reject(new Error('fetch not available')); }, navigator); - return m.exports; - } catch(e) { - console.error('[gelectron] Error running main script:', e); - throw e; - } -}; - -})(); diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/gelectron-bin b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/gelectron-bin deleted file mode 100755 index 3982960..0000000 Binary files a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/gelectron-bin and /dev/null differ diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/node b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/node deleted file mode 100755 index 5e1059f..0000000 Binary files a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/node and /dev/null differ diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/Resources/app/index.html b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/Resources/app/index.html deleted file mode 100644 index 2443f42..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/Resources/app/index.html +++ /dev/null @@ -1,706 +0,0 @@ - - - - - - Gelectron Demo - - - -
-

Gelectron Demo

-

HTML + CSS + JavaScript rendering via Gecko / Servo engine

-
- -
-
-

Interactive Counter

-

Proof that JavaScript runs and DOM updates work.

-
- -
0
- -
-
- -
-

Live Clock

-

requestAnimationFrame-driven rendering.

-
--:--:--
-
- -
-

Canvas 2D

-

Animated canvas with moving shapes.

-
- -
-
- -
-

Runtime Info

-

Environment details from the gelectron shim.

- - - - - -
Platform
Arch
Node.js
User Agent
-
- -
-

CSS Features

-

Grid, gradients, border-radius, transitions, flexbox, backdrop styling.

-
- - - - - - -
-
- -
-

App Module Demo

-

Interactive demo of the Electron app API — properties, methods, and lifecycle.

-
- - - - - - - - - - - - - - - - -
-
-
- -
-

Menu Module Demo

-

Interactive demo of the Electron Menu API — build, set, and inspect native menus.

-
- - - - - - - - -
- -
- -
-

App Module Tests

-

Automated tests for the Electron app compatibility layer.

-
-

Waiting for test results...

-
-
-
- - - - - - diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/Resources/app/main.js b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/Resources/app/main.js deleted file mode 100644 index dba472e..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/Resources/app/main.js +++ /dev/null @@ -1,488 +0,0 @@ -const { app, BrowserWindow } = require('electron'); -const path = require('path'); - -const results = []; - -function test(name, fn) { - try { - const val = fn(); - results.push({ name, status: 'PASS', value: String(val) }); - } catch (e) { - results.push({ name, status: 'FAIL', value: e.message }); - } -} - -function asyncTest(name, fn) { - return fn().then((val) => { - results.push({ name, status: 'PASS', value: String(val) }); - }).catch((e) => { - results.push({ name, status: 'FAIL', value: e.message }); - }); -} - -let mainWindow = null; - -// ─── Properties ──────────────────────────────────────────────── - -test('app.requestSingleInstanceLock() returns boolean', () => { - const lock = app.requestSingleInstanceLock(); - if (typeof lock !== 'boolean') throw new Error('Expected boolean, got ' + typeof lock); - return lock; -}); - -test('app.isReady() (method)', () => app.isReady()); - -test('app.isReady (property)', () => { - if (typeof app.isReady !== 'boolean') throw new Error('Expected boolean, got ' + typeof app.isReady); - return app.isReady; -}); - -test('app.appPath (property)', () => { - if (typeof app.appPath !== 'string') throw new Error('Expected string, got ' + typeof app.appPath); - return app.appPath; -}); - -test('app.locale (property)', () => { - if (typeof app.locale !== 'string') throw new Error('Expected string, got ' + typeof app.locale); - return app.locale; -}); - -test('app.userAgent (property)', () => { - if (typeof app.userAgent !== 'string') throw new Error('Expected string, got ' + typeof app.userAgent); - return app.userAgent; -}); - -test('app.getVersion()', () => app.getVersion()); - -test('app.getName()', () => app.getName()); - -test('app.getAppPath()', () => app.getAppPath()); - -test('app.name get/set', () => { - const old = app.name; - app.name = 'TestApp'; - const result = app.name; - app.name = old; - if (result !== 'TestApp') throw new Error('Expected TestApp, got ' + result); - return result; -}); - -test('app.name set null reverts', () => { - app.name = null; - return app.name === 'Gelectron App'; -}); - -// ─── Path Methods ────────────────────────────────────────────── - -test('app.getPath("home")', () => app.getPath('home')); - -test('app.getPath("userData")', () => app.getPath('userData')); - -test('app.getPath("temp")', () => app.getPath('temp')); - -test('app.getPath("desktop")', () => app.getPath('desktop')); - -test('app.getPath("documents")', () => app.getPath('documents')); - -test('app.getPath("downloads")', () => app.getPath('downloads')); - -test('app.getPath("logs")', () => app.getPath('logs')); - -test('app.getPath("crashDumps")', () => app.getPath('crashDumps')); - -test('app.getPath("app") returns userData', () => { - return app.getPath('app') === app.getPath('userData'); -}); - -test('app.setPath / app.getPath roundtrip', () => { - app.setPath('testPath', '/tmp/test-gelectron'); - return app.getPath('testPath') === '/tmp/test-gelectron'; -}); - -test('app.getPath("unknown") returns userData fallback', () => { - return app.getPath('nonexistent') === app.getPath('userData'); -}); - -// ─── User Agent / Locale ─────────────────────────────────────── - -test('app.getLocale()', () => app.getLocale()); - -test('app.getUserAgent()', () => app.getUserAgent()); - -test('app.setUserAgent()', () => { - app.setUserAgent('TestAgent/1.0'); - const result = app.getUserAgent(); - app.setUserAgent(null); - return result; -}); - -test('app.setUserAgent(null) resets', () => { - app.setUserAgent(null); - const ua = app.getUserAgent(); - if (!ua.includes('Gelectron')) throw new Error('Expected Gelectron UA, got ' + ua); - return true; -}); - -// ─── Lifecycle ───────────────────────────────────────────────── - -test('app.isPackaged is boolean', () => { - if (typeof app.isPackaged !== 'boolean') throw new Error('Expected boolean'); - return app.isPackaged; -}); - -test('app.whenReady() returns Promise', () => { - const p = app.whenReady(); - if (!p || typeof p.then !== 'function') throw new Error('Not a Promise'); - return true; -}); - -test('app.requestSingleInstanceLock() sync', () => { - const result = app.requestSingleInstanceLock(); - return typeof result === 'boolean'; -}); - -test('app.acquireSingleInstanceLock() sync', () => { - const result = app.acquireSingleInstanceLock(); - return typeof result === 'boolean'; -}); - -test('app.releaseSingleInstanceLock() no-op', () => { - app.releaseSingleInstanceLock(); - return true; -}); - -// ─── Events ──────────────────────────────────────────────────── - -test('app.on / app.removeListener', () => { - let called = false; - const fn = () => { called = true; }; - app.on('test-event', fn); - app.emit('test-event'); - app.removeListener('test-event', fn); - return called; -}); - -test('app.once fires once', () => { - let count = 0; - app.once('test-once', () => { count++; }); - app.emit('test-once'); - app.emit('test-once'); - return count === 1; -}); - -test('app.addListener returns this', () => { - const fn = () => {}; - const result = app.addListener('test-chain', fn); - app.removeListener('test-chain', fn); - return result === app; -}); - -test('app.emit("activate") does not crash', () => { - app.emit('activate'); - return true; -}); - -test('app.emit("focus") does not crash', () => { - app.emit('focus'); - return true; -}); - -test('app.emit("blur") does not crash', () => { - app.emit('blur'); - return true; -}); - -test('app.emit("browser-window-focus") does not crash', () => { - app.emit('browser-window-focus'); - return true; -}); - -test('app.emit("browser-window-blur") does not crash', () => { - app.emit('browser-window-blur'); - return true; -}); - -test('app.emit("web-contents-created") does not crash', () => { - app.emit('web-contents-created', {}, {}); - return true; -}); - -// ─── Dock (macOS) ────────────────────────────────────────────── - -test('app.dock exists (macOS)', () => { - if (process.platform === 'darwin') { - if (!app.dock) throw new Error('app.dock is null on macOS'); - return typeof app.dock; - } - return 'N/A (not macOS)'; -}); - -test('app.dock.bounce', () => { - if (process.platform === 'darwin') return app.dock.bounce(); - return 'N/A'; -}); - -test('app.dock.setBadgeCount / getBadgeCount', () => { - if (process.platform === 'darwin') { - app.dock.setBadgeCount(5); - return app.dock.getBadgeCount(); - } - return 'N/A'; -}); - -// ─── Command Line ────────────────────────────────────────────── - -test('app.commandLine.appendSwitch', () => { - app.commandLine.appendSwitch('test-switch', 'test-value'); - return app.commandLine.hasSwitch('test-switch'); -}); - -test('app.commandLine.getSwitch', () => app.commandLine.getSwitch('test-switch')); - -test('app.commandLine.removeSwitch', () => { - app.commandLine.removeSwitch('test-switch'); - return !app.commandLine.hasSwitch('test-switch'); -}); - -// ─── Badge ───────────────────────────────────────────────────── - -test('app.setBadgeCount / getBadgeCount', () => { - const result = app.setBadgeCount(3); - if (app.getBadgeCount() !== 3) throw new Error('Expected 3, got ' + app.getBadgeCount()); - app.setBadgeCount(0); - return result; -}); - -test('app.setBadgeCount(0) resets', () => { - app.setBadgeCount(5); - app.setBadgeCount(0); - return app.getBadgeCount() === 0; -}); - -// ─── Metrics / GPU ──────────────────────────────────────────── - -test('app.getAppMetrics() returns array', () => { - const metrics = app.getAppMetrics(); - if (!Array.isArray(metrics)) throw new Error('Expected array'); - if (metrics.length === 0) throw new Error('Expected at least one entry'); - const m = metrics[0]; - if (typeof m.pid !== 'number') throw new Error('Expected pid to be number'); - if (!m.memory) throw new Error('Expected memory object'); - return metrics.length + ' entries'; -}); - -test('app.getGPUInfo("basic")', async () => { - const info = await app.getGPUInfo('basic'); - if (!info || !info.gpuDevice) throw new Error('Missing gpuDevice'); - return info.GPUActive; -}); - -test('app.getGPUInfo("complete")', async () => { - const info = await app.getGPUInfo('complete'); - if (!info || !info.gpuDriver) throw new Error('Missing gpuDriver'); - return info.gpuDriver; -}); - -test('app.getGPUFeatureStatus()', () => { - const status = app.getGPUFeatureStatus(); - if (!status || typeof status.gpuCompositing !== 'string') throw new Error('Missing gpuCompositing'); - return Object.keys(status).length + ' features'; -}); - -test('app.disableHardwareAcceleration() no-op', () => { - app.disableHardwareAcceleration(); - return true; -}); - -test('app.disableDomainBlockingFor3DAPIs() no-op', () => { - app.disableDomainBlockingFor3DAPIs(); - return true; -}); - -// ─── Login Items ─────────────────────────────────────────────── - -test('app.getLoginItemSettings()', () => { - const s = app.getLoginItemSettings(); - if (typeof s.openAtLogin !== 'boolean') throw new Error('Missing openAtLogin'); - if (!s.hasOwnProperty('launchAtLogin')) throw new Error('Missing launchAtLogin'); - return true; -}); - -test('app.setLoginItemSettings() no-op', () => { - app.setLoginItemSettings({ openAtLogin: true }); - return true; -}); - -// ─── About Panel ─────────────────────────────────────────────── - -test('app.setAboutPanelOptions / getAboutPanelOptions', () => { - app.setAboutPanelOptions({ applicationName: 'Test', copyright: 'MIT' }); - const opts = app.getAboutPanelOptions(); - if (opts.applicationName !== 'Test') throw new Error('Expected Test, got ' + opts.applicationName); - return opts.copyright; -}); - -test('app.setAboutPanelOptions() with no args resets', () => { - app.setAboutPanelOptions(); - const opts = app.getAboutPanelOptions(); - return typeof opts === 'object'; -}); - -// ─── Recent Documents ────────────────────────────────────────── - -test('app.addRecentDocument() no-op', () => { app.addRecentDocument('/tmp/test'); return true; }); -test('app.clearRecentDocuments() no-op', () => { app.clearRecentDocuments(); return true; }); -test('app.setRecentDocumentLabel() no-op', () => { app.setRecentDocumentLabel('Test'); return true; }); - -// ─── App User Model ID ──────────────────────────────────────── - -test('app.setAppUserModelId() no-op', () => { app.setAppUserModelId('com.test'); return true; }); -test('app.getAppUserModelId()', () => { - const result = app.getAppUserModelId(); - if (typeof result !== 'string') throw new Error('Expected string'); - return result === '' ? '(empty)' : result; -}); - -// ─── Applications Folder ────────────────────────────────────── - -test('app.isInApplicationsFolder()', () => app.isInApplicationsFolder()); -test('app.moveToApplicationsFolder() no-op', () => { app.moveToApplicationsFolder(); return true; }); - -// ─── File Icons ──────────────────────────────────────────────── - -test('app.getFileIcon() callback', (done) => { - return new Promise((resolve) => { - app.getFileIcon('/tmp', (err, icon) => { - resolve(true); - }); - }); -}); - -// ─── Certificate Trust ──────────────────────────────────────── - -test('app.showCertificateTrustDialog()', async () => { - await app.showCertificateTrustDialog(); - return true; -}); - -// ─── Secure Keyboard Entry ──────────────────────────────────── - -test('app.setSecureKeyboardEntryEnabled / isSecureKeyboardEntryEnabled', () => { - app.setSecureKeyboardEntryEnabled(true); - const result = app.isSecureKeyboardEntryEnabled(); - app.setSecureKeyboardEntryEnabled(false); - return result; -}); - -// ─── Window Count ────────────────────────────────────────────── - -test('app.getWindowCount() initial', () => { - return app.getWindowCount(); -}); - -test('app.getPath("appData")', () => app.getPath('appData')); - -test('app.getPath("exe")', () => app.getPath('exe')); - -test('app.getPath("module")', () => app.getPath('module')); - -// ─── Launch App ──────────────────────────────────────────────── - -const gotLock = app.requestSingleInstanceLock(); -if (!gotLock) { - app.quit(); -} else { - app.on('second-instance', () => { - if (mainWindow) { - if (mainWindow.isMinimized()) mainWindow.restore(); - mainWindow.show(); - mainWindow.focus(); - } - }); - - app.whenReady().then(() => { - test('app.whenReady() resolved', () => true); - - mainWindow = new BrowserWindow({ - width: 900, - height: 680, - title: 'Gelectron Demo', - backgroundColor: '#1a1a2e', - webPreferences: { - contextIsolation: true, - nodeIntegration: false, - }, - }); - - test('BrowserWindow created', () => mainWindow.id > 0); - - test('BrowserWindow.getSize()', () => { - const [w, h] = mainWindow.getSize(); - if (w < 100 || h < 100) throw new Error('Size too small: ' + w + 'x' + h); - return w + 'x' + h; - }); - - test('BrowserWindow.getTitle()', () => mainWindow.getTitle()); - - test('BrowserWindow.isVisible()', () => mainWindow.isVisible()); - - test('BrowserWindow.isDestroyed()', () => !mainWindow.isDestroyed()); - - test('BrowserWindow.isNormal()', () => mainWindow.isNormal()); - - test('BrowserWindow.isResizable()', () => mainWindow.isResizable()); - - test('BrowserWindow.getAllWindows().length', () => BrowserWindow.getAllWindows().length); - - test('BrowserWindow.fromId(id)', () => { - const win = BrowserWindow.fromId(mainWindow.id); - return win ? win.id === mainWindow.id : false; - }); - - test('window-all-closed listener registered', () => { - app.on('window-all-closed', () => { - app.quit(); - }); - return true; - }); - - test('app.relaunch is a function', () => typeof app.relaunch === 'function'); - - test('app.exit is a function', () => typeof app.exit === 'function'); - - test('app.quit is a function', () => typeof app.quit === 'function'); - - test('app.getWindowCount() after create', () => app.getWindowCount()); - - test('app.getPathForProtocol()', () => { - const result = app.getPathForProtocol('https:'); - return result === null ? 'null' : result; - }); - - test('app.getApplicationInfoForProtocol()', async () => { - const result = await app.getApplicationInfoForProtocol('https:'); - return typeof result === 'object'; - }); - - mainWindow.loadFile(path.join(__dirname, 'index.html')); - - mainWindow.webContents.on('did-finish-load', () => { - const testResults = JSON.stringify(results); - mainWindow.webContents.executeJavaScript( - `window.__appTestResults = ${testResults}; renderAppTests();` - ); - }); - - mainWindow.once('ready-to-show', () => { - mainWindow.show(); - }); - - mainWindow.on('closed', () => { - mainWindow = null; - }); - }); - - app.on('window-all-closed', () => { - app.quit(); - }); -} diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/Resources/app/package.json b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/Resources/app/package.json deleted file mode 100644 index 464e304..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/Resources/app/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "gelectron-demo", - "version": "1.0.0", - "description": "Minimal demo for gelectron — HTML, CSS, JavaScript rendering", - "main": "main.js" -} diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/_CodeSignature/CodeDirectory b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/_CodeSignature/CodeDirectory deleted file mode 100644 index 02900ab..0000000 Binary files a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/_CodeSignature/CodeDirectory and /dev/null differ diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/_CodeSignature/CodeRequirements b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/_CodeSignature/CodeRequirements deleted file mode 100644 index b4c105e..0000000 Binary files a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/_CodeSignature/CodeRequirements and /dev/null differ diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/_CodeSignature/CodeResources b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/_CodeSignature/CodeResources deleted file mode 100644 index ef5a228..0000000 --- a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/_CodeSignature/CodeResources +++ /dev/null @@ -1,339 +0,0 @@ - - - - - files - - Resources/app/index.html - - sG0CkHSfK6EH/aUgSy18Gzs2drg= - - Resources/app/main.js - - e16s5rQbnpal4xcLf8x/NhGbS2g= - - Resources/app/package.json - - Y7NDit/zkULoNATi0P/tZR+DKxM= - - - files2 - - MacOS/compat/app.js - - cdhash - - 1lkepb5Ez0HGGLSXwgy8EDApOdE= - - requirement - cdhash H"d6591ea5be44cf41c618b497c20cbc10302939d1" - - MacOS/compat/auto-updater.js - - cdhash - - 6hr81wA+Q4cJzyBNArOA45tEkVY= - - requirement - cdhash H"ea1afcd7003e438709cf204d02b380e39b449156" - - MacOS/compat/browser-window.js - - cdhash - - qAdLtfb7mpG6gR6xmy9gCKs6FBE= - - requirement - cdhash H"a8074bb5f6fb9a91ba811eb19b2f6008ab3a1411" - - MacOS/compat/context-bridge.js - - cdhash - - KafHH/4oRUwwDuZqwipWOhxM268= - - requirement - cdhash H"29a7c71ffe28454c300ee66ac22a563a1c4cdbaf" - - MacOS/compat/dialog.js - - cdhash - - SXCSgmcZ/vl0xxt9pd2zVWxEYjU= - - requirement - cdhash H"497092826719fef974c71b7da5ddb3556c446235" - - MacOS/compat/index.js - - cdhash - - Nn0CHTP29YJYvNdElbvNoaIx+rc= - - requirement - cdhash H"367d021d33f6f58258bcd74495bbcda1a231fab7" - - MacOS/compat/ipc-main.js - - cdhash - - 16s5WbfI+qEVIALfGZh0f3mwIz4= - - requirement - cdhash H"d7ab3959b7c8faa1152002df1998747f79b0233e" - - MacOS/compat/ipc-renderer.js - - cdhash - - 3kHQy1UIFXY4M9e+jjEaGf+4PZA= - - requirement - cdhash H"de41d0cb550815763833d7be8e311a19ffb83d90" - - MacOS/compat/menu.js - - cdhash - - mG00gq46cpyWtov3xc27eZWOsAQ= - - requirement - cdhash H"986d3482ae3a729c96b68bf7c5cdbb79958eb004" - - MacOS/compat/native-bridge.js - - cdhash - - Rb9fSRqUVjk1KzuBt3EGHUE31s8= - - requirement - cdhash H"45bf5f491a945639352b3b81b771061d4137d6cf" - - MacOS/compat/native-image.js - - cdhash - - eutIvrwoL/WLitX7ZSm7Qzo+hRo= - - requirement - cdhash H"7aeb48bebc282ff58b8ad5fb6529bb433a3e851a" - - MacOS/compat/notification.js - - cdhash - - tzWUf6RK0ECImeqn3BvgQnZxJiI= - - requirement - cdhash H"b735947fa44ad0408899eaa7dc1be04276712622" - - MacOS/compat/preload-loader.js - - cdhash - - 2pD8SFhJ1ghYKM9eDCVn5UnRamo= - - requirement - cdhash H"da90fc485849d6085828cf5e0c2567e549d16a6a" - - MacOS/compat/runtime.js - - cdhash - - OtT9xp7FBV99spiMrCjN4POHTD8= - - requirement - cdhash H"3ad4fdc69ec5055f7db2988cac28cde0f3874c3f" - - MacOS/compat/safe-storage.js - - cdhash - - C6FIL05pKS9uwt8HzfQNaDijvw4= - - requirement - cdhash H"0ba1482f4e69292f6ec2df07cdf40d6838a3bf0e" - - MacOS/compat/shell.js - - cdhash - - pdQ3SzT0lEAMd4rkCN40O3QlWWo= - - requirement - cdhash H"a5d4374b34f494400c778ae408de343b7425596a" - - MacOS/compat/tray.js - - cdhash - - AoFk0BeiEzIY9sU1Oh+PQwgduZM= - - requirement - cdhash H"028164d017a2133218f6c5353a1f8f43081db993" - - MacOS/compat/web-contents.js - - cdhash - - KLiqJQByq2M9brxskLOF0YX1jkk= - - requirement - cdhash H"28b8aa250072ab633d6ebc6c90b385d185f58e49" - - MacOS/compat/webview-bundle.js - - cdhash - - XJO9bSeIHn+ykzJJLFGKXj1bL1c= - - requirement - cdhash H"5c93bd6d27881e7fb29332492c518a5e3d5b2f57" - - MacOS/gelectron-bin - - cdhash - - jYiEyVsY2PoR7VZCjnBcvL1y2jA= - - requirement - cdhash H"8d8884c95b18d8fa11ed56428e705cbcbd72da30" - - MacOS/node - - cdhash - - nhZUTCVVb73fdsZ0dHft7VPJ7e8= - - requirement - cdhash H"9e16544c25556fbddf76c6747477eded53c9edef" - - Resources/app/index.html - - hash2 - - q1YGzqi9XhTXA9N6blykkfje2XPlK7ODkCZ2za6Umjc= - - - Resources/app/main.js - - hash2 - - oRbv77Ab5dvdtFjb5nLPDG3VkG2mnGDabYl/xdgnjqg= - - - Resources/app/package.json - - hash2 - - Gkj33l7Q2sTuSFNjF+J+1cp5p3yOfGwHvM8MQI89/bw= - - - - rules - - ^Resources/ - - ^Resources/.*\.lproj/ - - optional - - weight - 1000 - - ^Resources/.*\.lproj/locversion.plist$ - - omit - - weight - 1100 - - ^Resources/Base\.lproj/ - - weight - 1010 - - ^version.plist$ - - - rules2 - - .*\.dSYM($|/) - - weight - 11 - - ^(.*/)?\.DS_Store$ - - omit - - weight - 2000 - - ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ - - nested - - weight - 10 - - ^.* - - ^Info\.plist$ - - omit - - weight - 20 - - ^PkgInfo$ - - omit - - weight - 20 - - ^Resources/ - - weight - 20 - - ^Resources/.*\.lproj/ - - optional - - weight - 1000 - - ^Resources/.*\.lproj/locversion.plist$ - - omit - - weight - 1100 - - ^Resources/Base\.lproj/ - - weight - 1010 - - ^[^/]+$ - - nested - - weight - 10 - - ^embedded\.provisionprofile$ - - weight - 20 - - ^version\.plist$ - - weight - 20 - - - - diff --git a/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/_CodeSignature/CodeSignature b/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/_CodeSignature/CodeSignature deleted file mode 100644 index e69de29..0000000