electrobun 0.0.19-beta.116 → 0.0.19-beta.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/bun/proc/native.ts +31 -0
- package/package.json +1 -1
- package/src/cli/index.ts +18 -4
|
@@ -49,6 +49,12 @@ export const native = (() => {
|
|
|
49
49
|
],
|
|
50
50
|
returns: FFIType.void,
|
|
51
51
|
},
|
|
52
|
+
closeNSWindow: {
|
|
53
|
+
args: [
|
|
54
|
+
FFIType.ptr, // window ptr
|
|
55
|
+
],
|
|
56
|
+
returns: FFIType.void,
|
|
57
|
+
},
|
|
52
58
|
// webview
|
|
53
59
|
initWebview: {
|
|
54
60
|
args: [
|
|
@@ -345,7 +351,10 @@ export const ffi = {
|
|
|
345
351
|
}
|
|
346
352
|
|
|
347
353
|
native.symbols.setNSWindowTitle(windowPtr, toCString(title));
|
|
354
|
+
// setTimeout(() => {
|
|
355
|
+
// console.log('calling makeNSWindowKeyAndOrderFront', windowPtr)
|
|
348
356
|
native.symbols.makeNSWindowKeyAndOrderFront(windowPtr);
|
|
357
|
+
// }, 1000)
|
|
349
358
|
|
|
350
359
|
return windowPtr;
|
|
351
360
|
},
|
|
@@ -360,6 +369,18 @@ export const ffi = {
|
|
|
360
369
|
|
|
361
370
|
native.symbols.setNSWindowTitle(windowPtr, toCString(title));
|
|
362
371
|
},
|
|
372
|
+
|
|
373
|
+
closeWindow: (params: {winId: number}) => {
|
|
374
|
+
const {winId} = params;
|
|
375
|
+
const windowPtr = BrowserWindow.getById(winId)?.ptr;
|
|
376
|
+
|
|
377
|
+
if (!windowPtr) {
|
|
378
|
+
throw `Can't close window. Window no longer exists`;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
native.symbols.closeNSWindow(windowPtr);
|
|
382
|
+
// Note: Cleanup of BrowserWindowMap happens in the windowCloseCallback
|
|
383
|
+
},
|
|
363
384
|
|
|
364
385
|
createWebview: (params: {
|
|
365
386
|
id: number;
|
|
@@ -725,6 +746,16 @@ process.on('unhandledRejection', (reason, promise) => {
|
|
|
725
746
|
console.error('Unhandled rejection in worker:', reason);
|
|
726
747
|
});
|
|
727
748
|
|
|
749
|
+
process.on('SIGINT', () => {
|
|
750
|
+
console.log('[electrobun] Received SIGINT, calling killApp() for graceful shutdown...');
|
|
751
|
+
native.symbols.killApp();
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
process.on('SIGTERM', () => {
|
|
755
|
+
console.log('[electrobun] Received SIGTERM, calling killApp() for graceful shutdown...');
|
|
756
|
+
native.symbols.killApp();
|
|
757
|
+
});
|
|
758
|
+
|
|
728
759
|
|
|
729
760
|
|
|
730
761
|
|
package/package.json
CHANGED
package/src/cli/index.ts
CHANGED
|
@@ -1871,10 +1871,24 @@ exec "\$LAUNCHER_BINARY" "\$@"
|
|
|
1871
1871
|
}
|
|
1872
1872
|
|
|
1873
1873
|
process.on("SIGINT", () => {
|
|
1874
|
-
console.log('
|
|
1875
|
-
|
|
1876
|
-
mainProc
|
|
1877
|
-
|
|
1874
|
+
console.log('[electrobun dev] Received SIGINT, initiating graceful shutdown...')
|
|
1875
|
+
|
|
1876
|
+
if (mainProc) {
|
|
1877
|
+
// First attempt graceful shutdown by sending SIGINT to child
|
|
1878
|
+
console.log('[electrobun dev] Requesting graceful shutdown from app...')
|
|
1879
|
+
mainProc.kill("SIGINT");
|
|
1880
|
+
|
|
1881
|
+
// Give the app time to clean up (e.g., call killApp())
|
|
1882
|
+
setTimeout(() => {
|
|
1883
|
+
if (mainProc && !mainProc.killed) {
|
|
1884
|
+
console.log('[electrobun dev] App did not exit gracefully, forcing termination...')
|
|
1885
|
+
mainProc.kill("SIGKILL");
|
|
1886
|
+
}
|
|
1887
|
+
process.exit(0);
|
|
1888
|
+
}, 2000); // 2 second timeout for graceful shutdown
|
|
1889
|
+
} else {
|
|
1890
|
+
process.exit(0);
|
|
1891
|
+
}
|
|
1878
1892
|
});
|
|
1879
1893
|
|
|
1880
1894
|
}
|