@gtkx/ffi 0.12.1 → 0.13.0
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/README.md +1 -1
- package/dist/native/lifecycle.js +4 -52
- package/package.json +3 -3
package/README.md
CHANGED
package/dist/native/lifecycle.js
CHANGED
|
@@ -7,61 +7,13 @@ const isDeno = typeof Deno !== "undefined";
|
|
|
7
7
|
let keepAliveTimeout = null;
|
|
8
8
|
let pollInterval = null;
|
|
9
9
|
let application = null;
|
|
10
|
+
let isStopping = false;
|
|
10
11
|
/**
|
|
11
12
|
* Checks if the GTK application runtime is currently running.
|
|
12
13
|
*
|
|
13
14
|
* @returns `true` if {@link start} has been called and {@link stop} has not
|
|
14
15
|
*/
|
|
15
16
|
export const isStarted = () => application !== null;
|
|
16
|
-
let exitHandlersRegistered = false;
|
|
17
|
-
const teardown = () => {
|
|
18
|
-
if (application) {
|
|
19
|
-
try {
|
|
20
|
-
stop();
|
|
21
|
-
}
|
|
22
|
-
catch { }
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const handleSigint = () => {
|
|
26
|
-
teardown();
|
|
27
|
-
process.exit(130);
|
|
28
|
-
};
|
|
29
|
-
const handleSigterm = () => {
|
|
30
|
-
teardown();
|
|
31
|
-
process.exit(143);
|
|
32
|
-
};
|
|
33
|
-
const handleException = (error) => {
|
|
34
|
-
teardown();
|
|
35
|
-
console.error(error);
|
|
36
|
-
process.exit(1);
|
|
37
|
-
};
|
|
38
|
-
const handleRejection = (reason) => {
|
|
39
|
-
teardown();
|
|
40
|
-
console.error("Unhandled rejection:", reason);
|
|
41
|
-
process.exit(1);
|
|
42
|
-
};
|
|
43
|
-
const registerExitHandlers = () => {
|
|
44
|
-
if (exitHandlersRegistered || isDeno) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
exitHandlersRegistered = true;
|
|
48
|
-
process.on("exit", teardown);
|
|
49
|
-
process.on("SIGINT", handleSigint);
|
|
50
|
-
process.on("SIGTERM", handleSigterm);
|
|
51
|
-
process.on("uncaughtException", handleException);
|
|
52
|
-
process.on("unhandledRejection", handleRejection);
|
|
53
|
-
};
|
|
54
|
-
const unregisterExitHandlers = () => {
|
|
55
|
-
if (!exitHandlersRegistered) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
exitHandlersRegistered = false;
|
|
59
|
-
process.off("exit", teardown);
|
|
60
|
-
process.off("SIGINT", handleSigint);
|
|
61
|
-
process.off("SIGTERM", handleSigterm);
|
|
62
|
-
process.off("uncaughtException", handleException);
|
|
63
|
-
process.off("unhandledRejection", handleRejection);
|
|
64
|
-
};
|
|
65
17
|
const keepAlive = () => {
|
|
66
18
|
keepAliveTimeout = setTimeout(() => keepAlive(), 2147483647);
|
|
67
19
|
};
|
|
@@ -111,7 +63,6 @@ export const start = (appId, flags) => {
|
|
|
111
63
|
startPolling();
|
|
112
64
|
}
|
|
113
65
|
application = getNativeObject(app);
|
|
114
|
-
registerExitHandlers();
|
|
115
66
|
return application;
|
|
116
67
|
};
|
|
117
68
|
/**
|
|
@@ -124,10 +75,10 @@ export const start = (appId, flags) => {
|
|
|
124
75
|
* @see {@link events} for lifecycle event handling
|
|
125
76
|
*/
|
|
126
77
|
export const stop = () => {
|
|
127
|
-
if (!application) {
|
|
78
|
+
if (!application || isStopping) {
|
|
128
79
|
return;
|
|
129
80
|
}
|
|
130
|
-
|
|
81
|
+
isStopping = true;
|
|
131
82
|
if (keepAliveTimeout) {
|
|
132
83
|
clearTimeout(keepAliveTimeout);
|
|
133
84
|
keepAliveTimeout = null;
|
|
@@ -140,4 +91,5 @@ export const stop = () => {
|
|
|
140
91
|
catch { }
|
|
141
92
|
application = null;
|
|
142
93
|
nativeStop();
|
|
94
|
+
isStopping = false;
|
|
143
95
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/ffi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Generated TypeScript FFI bindings for GTKX",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"dist"
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@gtkx/native": "0.
|
|
50
|
+
"@gtkx/native": "0.13.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@gtkx/vitest": "0.
|
|
53
|
+
"@gtkx/vitest": "0.13.0"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "tsc -b && cp ../../README.md .",
|