mirror of
https://github.com/mileswolfallen2/gelectron.git
synced 2026-12-04 16:07:43 +00:00
Add Gelectron demo application with main functionality and benchmark results
- Created main.js for the Gelectron demo application, implementing various app tests and lifecycle management. - Added package.json to define application metadata. - Included necessary code signature files for macOS compatibility. - Generated benchmark results for the application startup and memory usage.
This commit is contained in:
1 parent
f73e8f02d1
commit
a11d5a1350
38 files changed
+6175
-424
No files matched your search
+7
-24
@@ -19,6 +19,9 @@ const contextBridge = require('./context-bridge');
|
||||
const webContents = require('./web-contents');
|
||||
const { autoUpdater, AutoUpdater } = require('./auto-updater');
|
||||
const { bridge, isNative } = require('./native-bridge');
|
||||
const clipboard = require('./clipboard');
|
||||
const { Screen } = require('./screen');
|
||||
const nativeTheme = require('./nativeTheme');
|
||||
|
||||
if (isNative) {
|
||||
bridge.on('ipc-message', (windowId, channel, data) => {
|
||||
@@ -94,32 +97,12 @@ module.exports = {
|
||||
autoUpdater,
|
||||
AutoUpdater,
|
||||
session: sessionStub,
|
||||
clipboard,
|
||||
screen: new Screen(),
|
||||
nativeTheme,
|
||||
|
||||
// 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,
|
||||
isDarkMode: () => nativeTheme.shouldUseDarkColors,
|
||||
getAccentColor: () => '#007AFF',
|
||||
getColor: () => '#ffffff',
|
||||
isSwipeTrackingFromScrollEventsEnabled: () => false,
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
'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');
|
||||
|
||||
@@ -16,6 +11,7 @@ class NativeBridge extends EventEmitter {
|
||||
this._ready = false;
|
||||
this._readyCallbacks = [];
|
||||
this._windowListeners = new Map();
|
||||
this._pendingRequests = {};
|
||||
|
||||
if (isNative) {
|
||||
this._setupStdio();
|
||||
@@ -56,6 +52,27 @@ class NativeBridge extends EventEmitter {
|
||||
case 'ipc-message':
|
||||
this.emit('ipc-message', msg.id, msg.channel, msg.data);
|
||||
break;
|
||||
case 'response':
|
||||
this._resolveRequest(msg.request_id, msg.result, msg.error || null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_request(msg) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const id = 'req-' + Date.now() + '-' + Math.floor(Math.random() * 1e6);
|
||||
this._pendingRequests[id] = { resolve, reject };
|
||||
msg.request_id = id;
|
||||
this._send(msg);
|
||||
});
|
||||
}
|
||||
|
||||
_resolveRequest(requestId, result, error) {
|
||||
const pending = this._pendingRequests[requestId];
|
||||
if (pending) {
|
||||
delete this._pendingRequests[requestId];
|
||||
if (error) pending.reject(new Error(error));
|
||||
else pending.resolve(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user