-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpreload.js
More file actions
47 lines (37 loc) · 1.3 KB
/
preload.js
File metadata and controls
47 lines (37 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* Preload Script
*
* This script runs in a context that has access to both the renderer process
* and Node.js APIs. It exposes a safe API to the renderer via contextBridge.
*/
const { contextBridge, ipcRenderer } = require('electron');
// Expose protected methods to the renderer process
contextBridge.exposeInMainWorld('ababilAPI', {
// Make HTTP request via native Rust library
makeHttpRequest: (requestJson) => {
return ipcRenderer.invoke('native:makeHttpRequest', requestJson);
},
// Get native library status
getNativeLibraryStatus: () => {
return ipcRenderer.invoke('native:getStatus');
},
// Parse Postman collection
parsePostmanCollection: (jsonString) => {
return ipcRenderer.invoke('native:parsePostmanCollection', jsonString);
},
// Select Postman file
selectPostmanFile: () => {
return ipcRenderer.invoke('native:selectPostmanFile');
},
// Parse Postman environment
parsePostmanEnvironment: (jsonString) => {
return ipcRenderer.invoke('native:parsePostmanEnvironment', jsonString);
},
// Select Postman environment file
selectPostmanEnvironmentFile: () => {
return ipcRenderer.invoke('native:selectPostmanEnvironmentFile');
},
// Platform info
platform: process.platform,
});
console.log('[Preload] Ababil API exposed to renderer');