@gtkx/ffi 0.1.34 → 0.1.35
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/native.d.ts +1 -0
- package/dist/native.js +16 -1
- package/package.json +3 -3
package/dist/native.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ export declare const wrapPtr: <T extends object>(ptr: unknown, cls: {
|
|
|
12
12
|
prototype: T;
|
|
13
13
|
}) => T;
|
|
14
14
|
export declare const start: (appId: string, flags?: ApplicationFlags) => Application;
|
|
15
|
+
export declare const getCurrentApp: () => Application;
|
|
15
16
|
export declare const stop: () => void;
|
package/dist/native.js
CHANGED
|
@@ -2,6 +2,7 @@ import { EventEmitter } from "node:events";
|
|
|
2
2
|
import { createRef, start as nativeStart, stop as nativeStop } from "@gtkx/native";
|
|
3
3
|
export { createRef };
|
|
4
4
|
import { Application } from "./generated/gtk/application.js";
|
|
5
|
+
let currentApp = null;
|
|
5
6
|
let keepAliveTimeout = null;
|
|
6
7
|
export const events = new EventEmitter();
|
|
7
8
|
export const wrapPtr = (ptr, cls) => {
|
|
@@ -13,16 +14,30 @@ const keepAlive = () => {
|
|
|
13
14
|
keepAliveTimeout = setTimeout(() => keepAlive(), 2147483647);
|
|
14
15
|
};
|
|
15
16
|
export const start = (appId, flags) => {
|
|
17
|
+
if (currentApp) {
|
|
18
|
+
return currentApp;
|
|
19
|
+
}
|
|
16
20
|
const app = nativeStart(appId, flags);
|
|
21
|
+
currentApp = wrapPtr(app, Application);
|
|
17
22
|
events.emit("start");
|
|
18
23
|
keepAlive();
|
|
19
|
-
return
|
|
24
|
+
return currentApp;
|
|
25
|
+
};
|
|
26
|
+
export const getCurrentApp = () => {
|
|
27
|
+
if (!currentApp) {
|
|
28
|
+
throw new Error("GTK application not initialized. Call start() first.");
|
|
29
|
+
}
|
|
30
|
+
return currentApp;
|
|
20
31
|
};
|
|
21
32
|
export const stop = () => {
|
|
33
|
+
if (!currentApp) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
22
36
|
if (keepAliveTimeout) {
|
|
23
37
|
clearTimeout(keepAliveTimeout);
|
|
24
38
|
keepAliveTimeout = null;
|
|
25
39
|
}
|
|
26
40
|
events.emit("stop");
|
|
27
41
|
nativeStop();
|
|
42
|
+
currentApp = null;
|
|
28
43
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/ffi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"description": "Generated TypeScript FFI bindings for GTK4 libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtk",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"dist"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@gtkx/native": "0.1.
|
|
49
|
+
"@gtkx/native": "0.1.35"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@gtkx/gir": "0.1.
|
|
52
|
+
"@gtkx/gir": "0.1.35"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "tsc -b && cp ../../README.md .",
|