| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| const { contextBridge, ipcRenderer } = require('electron'); |
|
|
| |
| |
| contextBridge.exposeInMainWorld('electronAPI', { |
| getAppVersion: async () => { |
| try { |
| const version = await ipcRenderer.invoke('get-app-version'); |
| console.log(' App version retrieved:', version); |
| return version; |
| } catch (error) { |
| console.warn(' Failed to get app version:', error); |
| return '1.0.0'; |
| } |
| }, |
|
|
| showMessageBox: (options) => ipcRenderer.invoke('show-message-box', options), |
|
|
| |
| platform: process.platform, |
|
|
| |
| frameworkAPI: { |
| baseUrl: 'https://chahuadev.com/api' |
| }, |
|
|
| |
| executeCommand: (payload) => ipcRenderer.invoke('execute-command', payload), |
|
|
| |
| executeQuickCommand: (command) => ipcRenderer.invoke('execute-quick-command', command), |
|
|
| |
| executePluginCommand: (pluginName, command, data) => ipcRenderer.invoke('execute-plugin-command', pluginName, command, data), |
|
|
| |
| processCommand: (request) => ipcRenderer.invoke('process-command', request), |
|
|
| |
| runNpmProject: (payload) => ipcRenderer.invoke('run-npm-project', payload), |
|
|
| |
| runManifestGenerator: () => ipcRenderer.invoke('run-manifest-generator'), |
|
|
| |
| runSystemCheck: () => ipcRenderer.invoke('run-system-check'), |
| runParameterizedSystemCheck: (params) => ipcRenderer.invoke('run-parameterized-system-check', params), |
| getAvailablePlugins: () => ipcRenderer.invoke('get-available-plugins'), |
|
|
| |
| openPluginsFolder: () => ipcRenderer.invoke('open-plugins-folder'), |
|
|
| |
| startBuild: () => ipcRenderer.invoke('start-build'), |
|
|
| |
| onBuildLog: (callback) => ipcRenderer.on('build-log', (_event, value) => callback(value)), |
| removeBuildLogListeners: () => ipcRenderer.removeAllListeners('build-log'), |
|
|
| |
| getRunMode: () => ipcRenderer.invoke('get-run-mode'), |
|
|
| |
| getDevModeStatus: () => ipcRenderer.invoke('security:get-dev-mode'), |
|
|
| |
| getPreloadPath: () => ipcRenderer.invoke('get-preload-path'), |
|
|
| |
| executeNpmCommand: (command) => ipcRenderer.invoke('execute-npm-command', command), |
|
|
| |
| isElectronApp: true, |
|
|
| |
| openExternal: (url) => ipcRenderer.invoke('open-external', url), |
|
|
| |
| splashScreenFinished: () => ipcRenderer.invoke('splash:finished'), |
|
|
| |
| terminal: { |
| execute: (command, options = {}) => ipcRenderer.invoke('terminal:execute', command, options), |
| executeStream: (command, callback) => { |
| const channel = `terminal-output-${Date.now()}`; |
| ipcRenderer.on(channel, (_event, data) => callback(data)); |
| return ipcRenderer.invoke('terminal:execute-stream', command, channel); |
| }, |
| |
| executeCommand: (command) => ipcRenderer.invoke('terminal:execute-command', command), |
| getSystemInfo: () => ipcRenderer.invoke('terminal:get-system-info'), |
| kill: (processId) => ipcRenderer.invoke('terminal:kill', processId), |
| getHistory: () => ipcRenderer.invoke('terminal:get-history'), |
| clearHistory: () => ipcRenderer.invoke('terminal:clear-history'), |
| |
| onMessage: (callback) => ipcRenderer.on('terminal:message', callback), |
| onCommandResult: (callback) => ipcRenderer.on('terminal:command-result', callback), |
| onCommandExecuted: (callback) => ipcRenderer.on('terminal:command-executed', callback), |
| onClear: (callback) => ipcRenderer.on('terminal:clear', callback), |
| onWelcome: (callback) => ipcRenderer.on('terminal:welcome', callback), |
| onNewLog: (callback) => ipcRenderer.on('terminal:new-log', callback), |
| |
| removeAllListeners: () => { |
| ipcRenderer.removeAllListeners('terminal:message'); |
| ipcRenderer.removeAllListeners('terminal:command-result'); |
| ipcRenderer.removeAllListeners('terminal:command-executed'); |
| ipcRenderer.removeAllListeners('terminal:clear'); |
| ipcRenderer.removeAllListeners('terminal:welcome'); |
| ipcRenderer.removeAllListeners('terminal:new-log'); |
| } |
| }, |
|
|
| |
| ui: { |
| saveState: (key, value) => ipcRenderer.invoke('ui:save-state', key, value), |
| loadState: (key, defaultValue) => ipcRenderer.invoke('ui:load-state', key, defaultValue), |
| clearState: (key) => ipcRenderer.invoke('ui:clear-state', key) |
| }, |
|
|
| |
| getPreloadWebviewPath: () => ipcRenderer.invoke('get-preload-webview-path'), |
|
|
| |
| project: { |
| analyze: (projectPath) => ipcRenderer.invoke('project:analyze', projectPath), |
| getStats: (analysis) => ipcRenderer.invoke('project:get-stats', analysis), |
| setRules: (rules) => ipcRenderer.invoke('project:set-rules', rules), |
| |
| onStatusUpdate: (callback) => ipcRenderer.on('inspector:status-update', (_event, value) => callback(value)) |
| }, |
|
|
| |
| plugins: { |
| |
| getAll: () => ipcRenderer.invoke('get-available-plugins'), |
|
|
| |
| getInfo: (pluginName) => ipcRenderer.invoke('get-plugin-info', pluginName), |
|
|
| |
| execute: (pluginName, data) => ipcRenderer.invoke('execute-command', { |
| plugin: pluginName, |
| data: data |
| }), |
|
|
| |
| openHTML: (pluginName) => ipcRenderer.invoke('execute-command', { |
| plugin: pluginName, |
| data: { action: 'open_html' } |
| }), |
|
|
| |
| viewProject: (pluginName) => ipcRenderer.invoke('execute-command', { |
| plugin: pluginName, |
| data: { action: 'view_project' } |
| }) |
| }, |
|
|
|
|
| |
| getSystemInfo: () => ipcRenderer.invoke('get-system-info'), |
|
|
| |
|
|
| |
| |
| |
| auth: { |
| |
| startDeviceFlow: () => ipcRenderer.invoke('auth:start-device-flow'), |
|
|
| |
| offlineLogin: (username, password) => ipcRenderer.invoke('auth:offline-login', { username, password }), |
|
|
| |
| pollDeviceAuth: (deviceCode) => ipcRenderer.invoke('auth:poll-device', deviceCode), |
|
|
| |
| getCurrentUser: () => ipcRenderer.invoke('auth:get-current-user'), |
|
|
| |
| checkStatus: () => ipcRenderer.invoke('auth:check-status'), |
|
|
| |
| logout: () => ipcRenderer.invoke('auth:logout') |
| }, |
|
|
| |
| onMessage: (channel, callback) => { |
| ipcRenderer.on(channel, (event, ...args) => callback(...args)); |
| }, |
|
|
| |
| isDesktopApp: true, |
| isElectron: true |
| }); |
|
|
| |
| window.addEventListener('message', (event) => { |
| |
| if (event.origin !== 'https://chahuadev.com') { |
| console.warn(`[Preload] Blocked message from untrusted origin: ${event.origin}`); |
| return; |
| } |
|
|
| const message = event.data; |
| console.log('[Preload] Message received from WebView:', message); |
|
|
| |
| }); |
|
|
| |
| console.log(' Chahuadev Framework preload script loaded with Plugin Management System'); |
|
|
| |
| window.addEventListener('DOMContentLoaded', () => { |
| document.body.classList.add('electron-app'); |
|
|
| }); |