Files
gelectron/GeelectronDemo-darwin-arm64/GeelectronDemo.app/Contents/MacOS/compat/context-bridge.js
T
miles e5d93b3613 Add initial implementation of GeelectronDemo app
- Created main.js for the application logic, including tests for Electron app properties and methods.
- Added package.json to define app metadata.
- Included necessary code signature files for macOS app distribution.
- Implemented basic window management and event handling in the app.
2026-07-27 23:56:34 -05:00

34 lines
768 B
JavaScript

'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;