@gtkx/native 2.0.0-beta.5 → 2.0.0-beta.7
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 +43 -40
- package/index.d.ts +15 -0
- package/index.js +57 -56
- package/main.d.ts +20 -0
- package/main.js +12 -0
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
<h1 align="center">GTKX</h1>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
The React framework for Linux
|
|
9
|
-
Write native
|
|
10
|
-
Real
|
|
8
|
+
The React framework for Linux.<br />
|
|
9
|
+
Write native GNOME applications with React and TypeScript.
|
|
10
|
+
Real Adwaita and GTK4 widgets with standard web tooling.
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
13
|
<p align="center">
|
|
@@ -38,11 +38,12 @@
|
|
|
38
38
|
|
|
39
39
|
## Demo
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
This app starts with an Adwaita application shell, renders native GTK4 widgets inside it, and uses ordinary React hooks and events:
|
|
42
42
|
|
|
43
43
|
```tsx
|
|
44
44
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
45
|
-
import {
|
|
45
|
+
import { AdwApplication, AdwApplicationWindow, AdwHeaderBar, AdwToolbarView } from "@gtkx/jsx/adw";
|
|
46
|
+
import { GtkBox, GtkButton, GtkLabel } from "@gtkx/jsx/gtk";
|
|
46
47
|
import { createRoot, quit } from "@gtkx/react";
|
|
47
48
|
import { useState } from "react";
|
|
48
49
|
|
|
@@ -50,38 +51,40 @@ const Counter = () => {
|
|
|
50
51
|
const [count, setCount] = useState(0);
|
|
51
52
|
|
|
52
53
|
return (
|
|
53
|
-
<
|
|
54
|
+
<AdwApplicationWindow
|
|
54
55
|
title="Hello GTKX"
|
|
55
56
|
defaultWidth={400}
|
|
56
57
|
defaultHeight={300}
|
|
57
58
|
onCloseRequest={quit}
|
|
58
59
|
>
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
60
|
+
<AdwToolbarView topBar={<AdwHeaderBar />}>
|
|
61
|
+
<GtkBox
|
|
62
|
+
orientation={Gtk.Orientation.VERTICAL}
|
|
63
|
+
spacing={20}
|
|
64
|
+
marginTop={40}
|
|
65
|
+
marginBottom={40}
|
|
66
|
+
marginStart={40}
|
|
67
|
+
marginEnd={40}
|
|
68
|
+
valign={Gtk.Align.CENTER}
|
|
69
|
+
halign={Gtk.Align.CENTER}
|
|
70
|
+
>
|
|
71
|
+
<GtkLabel cssClasses={["title-1"]}>Welcome to GTKX!</GtkLabel>
|
|
72
|
+
<GtkLabel cssClasses={["title-2"]}>{`Count: ${String(count)}`}</GtkLabel>
|
|
73
|
+
<GtkButton
|
|
74
|
+
label="Increment"
|
|
75
|
+
onClicked={() => setCount((c) => c + 1)}
|
|
76
|
+
cssClasses={["suggested-action", "pill"]}
|
|
77
|
+
/>
|
|
78
|
+
</GtkBox>
|
|
79
|
+
</AdwToolbarView>
|
|
80
|
+
</AdwApplicationWindow>
|
|
78
81
|
);
|
|
79
82
|
};
|
|
80
83
|
|
|
81
84
|
const App = () => (
|
|
82
|
-
<
|
|
85
|
+
<AdwApplication>
|
|
83
86
|
<Counter />
|
|
84
|
-
</
|
|
87
|
+
</AdwApplication>
|
|
85
88
|
);
|
|
86
89
|
|
|
87
90
|
createRoot().render(<App />);
|
|
@@ -91,9 +94,9 @@ This is the [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/
|
|
|
91
94
|
|
|
92
95
|
## Why GTKX
|
|
93
96
|
|
|
94
|
-
###
|
|
97
|
+
### Adwaita-first application development
|
|
95
98
|
|
|
96
|
-
|
|
99
|
+
GTKX uses Adwaita as the foundation for applications, windows, navigation, dialogs, and adaptive layouts, with the complete GTK4 toolkit underneath. It adds a declarative React layer and an integrated TypeScript toolchain to the GNOME platform:
|
|
97
100
|
|
|
98
101
|
- a React reconciler that exposes every GObject as a JSX element,
|
|
99
102
|
- a CLI for scaffolding, development, and production builds,
|
|
@@ -102,17 +105,17 @@ GTK4 is mature, and GtkBuilder XML can lay out a static interface, but nothing r
|
|
|
102
105
|
- a Testing Library-style API for querying and driving your widgets in tests,
|
|
103
106
|
- and a Model Context Protocol (MCP) server that exposes your live app to AI agents.
|
|
104
107
|
|
|
105
|
-
###
|
|
108
|
+
### Native GNOME widgets, without a compatibility layer
|
|
106
109
|
|
|
107
|
-
React Native and similar frameworks hide the native toolkit so one API can run everywhere. GTKX
|
|
110
|
+
React Native and similar frameworks hide the native toolkit so one API can run everywhere. GTKX renders real Adwaita and GTK4 widgets and exposes any other GObject-Introspection library on your system. It is GNOME-native and Linux-only by design.
|
|
108
111
|
|
|
109
112
|
### Why Node.js, and why generated bindings
|
|
110
113
|
|
|
111
114
|
GTKX runs on Node.js, which puts native modules, the npm ecosystem, and the tooling built for Node.js APIs within reach. GJS is GNOME's own runtime, built on SpiderMonkey rather than V8; node-gtk runs on Node.js but is lightly maintained, on the older nan/V8 ABI rather than N-API, and still centered on GTK3. The [Why GTKX guide](https://gtkx.dev/guide/why-gtkx) covers what running on Node.js means day to day.
|
|
112
115
|
|
|
113
|
-
GTKX generates the TypeScript types and
|
|
116
|
+
GTKX generates the TypeScript types and native FFI calls from the same GObject-Introspection data, so the types cannot drift from the calls they back. `Adw-1` is the sole default GIR root; its GIR include pulls in `Gtk-4.0`, so codegen covers both complete API surfaces. Neither belongs in a GTKX 2 `libraries` list.
|
|
114
117
|
|
|
115
|
-
At runtime, the native Rust core calls straight into the system
|
|
118
|
+
At runtime, the native Rust core calls straight into the system Adwaita, GTK4, and GLib libraries through libffi, without loading libgirepository at all.
|
|
116
119
|
|
|
117
120
|
## Quick start
|
|
118
121
|
|
|
@@ -121,10 +124,10 @@ GTKX is Linux-only and needs Node.js 26.7 or later. See [Requirements](#requirem
|
|
|
121
124
|
Scaffold a new app with the `create-gtkx` initializer:
|
|
122
125
|
|
|
123
126
|
```sh
|
|
124
|
-
npm create gtkx
|
|
127
|
+
npm create gtkx@beta
|
|
125
128
|
```
|
|
126
129
|
|
|
127
|
-
The same command works with other package managers: `pnpm create gtkx` or `yarn create gtkx`.
|
|
130
|
+
The same command works with other package managers: `pnpm create gtkx@beta` or `yarn create gtkx@beta`.
|
|
128
131
|
|
|
129
132
|
Then run your new app:
|
|
130
133
|
|
|
@@ -145,7 +148,7 @@ The documentation at **[gtkx.dev](https://gtkx.dev)** includes a step-by-step tu
|
|
|
145
148
|
|
|
146
149
|
GTKX is Linux-only. You need:
|
|
147
150
|
|
|
148
|
-
- Linux with the
|
|
151
|
+
- Linux with the Adwaita (1.8 or later), GTK4 (4.20 or later), and GLib development libraries
|
|
149
152
|
- Node.js 26.7 or later
|
|
150
153
|
|
|
151
154
|
The `@gtkx/native` addon ships prebuilt for x64 and arm64 glibc Linux; other targets need to build it from the GTKX repository, which requires a Rust toolchain.
|
|
@@ -154,10 +157,10 @@ The `@gtkx/native` addon ships prebuilt for x64 and arm64 glibc Linux; other tar
|
|
|
154
157
|
|
|
155
158
|
Explore the [example apps](https://github.com/gtkx-org/gtkx/tree/main/examples):
|
|
156
159
|
|
|
157
|
-
- [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/hello-world): the counter above.
|
|
158
|
-
- [`gtk-demo`](https://github.com/gtkx-org/gtkx/tree/main/examples/gtk-demo):
|
|
159
|
-
- [`browser`](https://github.com/gtkx-org/gtkx/tree/main/examples/browser):
|
|
160
|
-
- [`animations`](https://github.com/gtkx-org/gtkx/tree/main/examples/animations):
|
|
160
|
+
- [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/hello-world): the Adwaita counter above.
|
|
161
|
+
- [`gtk-demo`](https://github.com/gtkx-org/gtkx/tree/main/examples/gtk-demo): the official GTK4 widget showcase in an Adwaita application shell, covering lists, dialogs, gestures, CSS, and OpenGL.
|
|
162
|
+
- [`browser`](https://github.com/gtkx-org/gtkx/tree/main/examples/browser): an Adwaita browser built around `WebKitWebView`.
|
|
163
|
+
- [`animations`](https://github.com/gtkx-org/gtkx/tree/main/examples/animations): an Adwaita showcase for `@gtkx/animated`, with React Spring animations driven by the GTK frame clock.
|
|
161
164
|
- [`navigation`](https://github.com/gtkx-org/gtkx/tree/main/examples/navigation): a tour of `@gtkx/navigation`, React Navigation's stack, tab, and drawer navigators rendered with libadwaita.
|
|
162
165
|
- [`tutorial`](https://github.com/gtkx-org/gtkx/tree/main/examples/tutorial): the Tasks app the documentation builds.
|
|
163
166
|
|
package/index.d.ts
CHANGED
|
@@ -7,6 +7,15 @@ export declare class ExternalObject<T> {
|
|
|
7
7
|
[K: symbol]: T
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Registers `listener` for every `GLib` log record the process writes, whichever thread logs it,
|
|
12
|
+
* and returns the id `removeLogListener` takes. The public `onLog` wrapper in `main.js` pairs the
|
|
13
|
+
* two into a subscription. Records are queued to the JavaScript thread and delivered
|
|
14
|
+
* asynchronously; a level `GLib` treats as fatal aborts the process before the queued delivery
|
|
15
|
+
* runs, and removing a listener does not cancel records already queued for it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function addLogListener(listener: (level: "error" | "critical" | "warning" | "message" | "info" | "debug", domain: string, message: string) => void): number
|
|
18
|
+
|
|
10
19
|
/**
|
|
11
20
|
* Allocates a zero-filled native memory block of `size` bytes and returns an opaque handle to it.
|
|
12
21
|
* A `gtype` naming a registered boxed type selects `g_boxed_free` as the handle's destructor, so a
|
|
@@ -339,6 +348,12 @@ export interface RegisterClassVfunc {
|
|
|
339
348
|
fn: (...args: never[]) => unknown
|
|
340
349
|
}
|
|
341
350
|
|
|
351
|
+
/**
|
|
352
|
+
* Removes the listener `addLogListener` returned `id` for; an unknown or already removed id is
|
|
353
|
+
* ignored.
|
|
354
|
+
*/
|
|
355
|
+
export declare function removeLogListener(id: number): void
|
|
356
|
+
|
|
342
357
|
/**
|
|
343
358
|
* Calls the `getTypeFnName` registration function in `sharedLibrary` and returns the resulting
|
|
344
359
|
* `GType`, or 0 when the symbol is absent.
|
package/index.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
import { createRequire } from 'module'
|
|
7
7
|
const require = createRequire(import.meta.url)
|
|
8
|
-
const __dirname = new URL('.', import.meta.url).pathname
|
|
9
8
|
|
|
10
9
|
const { readFileSync } = require('fs')
|
|
11
10
|
let nativeBinding = null
|
|
@@ -81,8 +80,8 @@ function requireNative() {
|
|
|
81
80
|
try {
|
|
82
81
|
const binding = require('@gtkx/native-android-arm64')
|
|
83
82
|
const bindingPackageVersion = require('@gtkx/native-android-arm64/package.json').version
|
|
84
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
85
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
83
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
84
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
86
85
|
}
|
|
87
86
|
return binding
|
|
88
87
|
} catch (e) {
|
|
@@ -97,8 +96,8 @@ function requireNative() {
|
|
|
97
96
|
try {
|
|
98
97
|
const binding = require('@gtkx/native-android-arm-eabi')
|
|
99
98
|
const bindingPackageVersion = require('@gtkx/native-android-arm-eabi/package.json').version
|
|
100
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
101
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
99
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
100
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
102
101
|
}
|
|
103
102
|
return binding
|
|
104
103
|
} catch (e) {
|
|
@@ -118,8 +117,8 @@ function requireNative() {
|
|
|
118
117
|
try {
|
|
119
118
|
const binding = require('@gtkx/native-win32-x64-gnu')
|
|
120
119
|
const bindingPackageVersion = require('@gtkx/native-win32-x64-gnu/package.json').version
|
|
121
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
122
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
120
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
121
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
123
122
|
}
|
|
124
123
|
return binding
|
|
125
124
|
} catch (e) {
|
|
@@ -134,8 +133,8 @@ function requireNative() {
|
|
|
134
133
|
try {
|
|
135
134
|
const binding = require('@gtkx/native-win32-x64-msvc')
|
|
136
135
|
const bindingPackageVersion = require('@gtkx/native-win32-x64-msvc/package.json').version
|
|
137
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
138
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
136
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
137
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
139
138
|
}
|
|
140
139
|
return binding
|
|
141
140
|
} catch (e) {
|
|
@@ -151,8 +150,8 @@ function requireNative() {
|
|
|
151
150
|
try {
|
|
152
151
|
const binding = require('@gtkx/native-win32-ia32-msvc')
|
|
153
152
|
const bindingPackageVersion = require('@gtkx/native-win32-ia32-msvc/package.json').version
|
|
154
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
155
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
153
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
154
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
156
155
|
}
|
|
157
156
|
return binding
|
|
158
157
|
} catch (e) {
|
|
@@ -167,8 +166,8 @@ function requireNative() {
|
|
|
167
166
|
try {
|
|
168
167
|
const binding = require('@gtkx/native-win32-arm64-msvc')
|
|
169
168
|
const bindingPackageVersion = require('@gtkx/native-win32-arm64-msvc/package.json').version
|
|
170
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
171
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
169
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
170
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
172
171
|
}
|
|
173
172
|
return binding
|
|
174
173
|
} catch (e) {
|
|
@@ -186,8 +185,8 @@ function requireNative() {
|
|
|
186
185
|
try {
|
|
187
186
|
const binding = require('@gtkx/native-darwin-universal')
|
|
188
187
|
const bindingPackageVersion = require('@gtkx/native-darwin-universal/package.json').version
|
|
189
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
190
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
188
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
189
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
191
190
|
}
|
|
192
191
|
return binding
|
|
193
192
|
} catch (e) {
|
|
@@ -202,8 +201,8 @@ function requireNative() {
|
|
|
202
201
|
try {
|
|
203
202
|
const binding = require('@gtkx/native-darwin-x64')
|
|
204
203
|
const bindingPackageVersion = require('@gtkx/native-darwin-x64/package.json').version
|
|
205
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
206
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
204
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
205
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
207
206
|
}
|
|
208
207
|
return binding
|
|
209
208
|
} catch (e) {
|
|
@@ -218,8 +217,8 @@ function requireNative() {
|
|
|
218
217
|
try {
|
|
219
218
|
const binding = require('@gtkx/native-darwin-arm64')
|
|
220
219
|
const bindingPackageVersion = require('@gtkx/native-darwin-arm64/package.json').version
|
|
221
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
222
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
220
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
221
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
223
222
|
}
|
|
224
223
|
return binding
|
|
225
224
|
} catch (e) {
|
|
@@ -238,8 +237,8 @@ function requireNative() {
|
|
|
238
237
|
try {
|
|
239
238
|
const binding = require('@gtkx/native-freebsd-x64')
|
|
240
239
|
const bindingPackageVersion = require('@gtkx/native-freebsd-x64/package.json').version
|
|
241
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
242
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
240
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
241
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
243
242
|
}
|
|
244
243
|
return binding
|
|
245
244
|
} catch (e) {
|
|
@@ -254,8 +253,8 @@ function requireNative() {
|
|
|
254
253
|
try {
|
|
255
254
|
const binding = require('@gtkx/native-freebsd-arm64')
|
|
256
255
|
const bindingPackageVersion = require('@gtkx/native-freebsd-arm64/package.json').version
|
|
257
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
258
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
256
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
257
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
259
258
|
}
|
|
260
259
|
return binding
|
|
261
260
|
} catch (e) {
|
|
@@ -275,8 +274,8 @@ function requireNative() {
|
|
|
275
274
|
try {
|
|
276
275
|
const binding = require('@gtkx/native-linux-x64-musl')
|
|
277
276
|
const bindingPackageVersion = require('@gtkx/native-linux-x64-musl/package.json').version
|
|
278
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
279
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
277
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
278
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
280
279
|
}
|
|
281
280
|
return binding
|
|
282
281
|
} catch (e) {
|
|
@@ -291,8 +290,8 @@ function requireNative() {
|
|
|
291
290
|
try {
|
|
292
291
|
const binding = require('@gtkx/native-linux-x64-gnu')
|
|
293
292
|
const bindingPackageVersion = require('@gtkx/native-linux-x64-gnu/package.json').version
|
|
294
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
295
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
293
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
294
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
296
295
|
}
|
|
297
296
|
return binding
|
|
298
297
|
} catch (e) {
|
|
@@ -309,8 +308,8 @@ function requireNative() {
|
|
|
309
308
|
try {
|
|
310
309
|
const binding = require('@gtkx/native-linux-arm64-musl')
|
|
311
310
|
const bindingPackageVersion = require('@gtkx/native-linux-arm64-musl/package.json').version
|
|
312
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
313
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
311
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
312
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
314
313
|
}
|
|
315
314
|
return binding
|
|
316
315
|
} catch (e) {
|
|
@@ -325,8 +324,8 @@ function requireNative() {
|
|
|
325
324
|
try {
|
|
326
325
|
const binding = require('@gtkx/native-linux-arm64-gnu')
|
|
327
326
|
const bindingPackageVersion = require('@gtkx/native-linux-arm64-gnu/package.json').version
|
|
328
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
329
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
327
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
328
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
330
329
|
}
|
|
331
330
|
return binding
|
|
332
331
|
} catch (e) {
|
|
@@ -343,8 +342,8 @@ function requireNative() {
|
|
|
343
342
|
try {
|
|
344
343
|
const binding = require('@gtkx/native-linux-arm-musleabihf')
|
|
345
344
|
const bindingPackageVersion = require('@gtkx/native-linux-arm-musleabihf/package.json').version
|
|
346
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
347
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
345
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
346
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
348
347
|
}
|
|
349
348
|
return binding
|
|
350
349
|
} catch (e) {
|
|
@@ -359,8 +358,8 @@ function requireNative() {
|
|
|
359
358
|
try {
|
|
360
359
|
const binding = require('@gtkx/native-linux-arm-gnueabihf')
|
|
361
360
|
const bindingPackageVersion = require('@gtkx/native-linux-arm-gnueabihf/package.json').version
|
|
362
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
363
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
361
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
362
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
364
363
|
}
|
|
365
364
|
return binding
|
|
366
365
|
} catch (e) {
|
|
@@ -377,8 +376,8 @@ function requireNative() {
|
|
|
377
376
|
try {
|
|
378
377
|
const binding = require('@gtkx/native-linux-loong64-musl')
|
|
379
378
|
const bindingPackageVersion = require('@gtkx/native-linux-loong64-musl/package.json').version
|
|
380
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
381
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
379
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
380
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
382
381
|
}
|
|
383
382
|
return binding
|
|
384
383
|
} catch (e) {
|
|
@@ -393,8 +392,8 @@ function requireNative() {
|
|
|
393
392
|
try {
|
|
394
393
|
const binding = require('@gtkx/native-linux-loong64-gnu')
|
|
395
394
|
const bindingPackageVersion = require('@gtkx/native-linux-loong64-gnu/package.json').version
|
|
396
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
397
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
395
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
396
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
398
397
|
}
|
|
399
398
|
return binding
|
|
400
399
|
} catch (e) {
|
|
@@ -411,8 +410,8 @@ function requireNative() {
|
|
|
411
410
|
try {
|
|
412
411
|
const binding = require('@gtkx/native-linux-riscv64-musl')
|
|
413
412
|
const bindingPackageVersion = require('@gtkx/native-linux-riscv64-musl/package.json').version
|
|
414
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
415
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
413
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
414
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
416
415
|
}
|
|
417
416
|
return binding
|
|
418
417
|
} catch (e) {
|
|
@@ -427,8 +426,8 @@ function requireNative() {
|
|
|
427
426
|
try {
|
|
428
427
|
const binding = require('@gtkx/native-linux-riscv64-gnu')
|
|
429
428
|
const bindingPackageVersion = require('@gtkx/native-linux-riscv64-gnu/package.json').version
|
|
430
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
431
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
429
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
430
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
432
431
|
}
|
|
433
432
|
return binding
|
|
434
433
|
} catch (e) {
|
|
@@ -444,8 +443,8 @@ function requireNative() {
|
|
|
444
443
|
try {
|
|
445
444
|
const binding = require('@gtkx/native-linux-ppc64-gnu')
|
|
446
445
|
const bindingPackageVersion = require('@gtkx/native-linux-ppc64-gnu/package.json').version
|
|
447
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
448
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
446
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
447
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
449
448
|
}
|
|
450
449
|
return binding
|
|
451
450
|
} catch (e) {
|
|
@@ -460,8 +459,8 @@ function requireNative() {
|
|
|
460
459
|
try {
|
|
461
460
|
const binding = require('@gtkx/native-linux-s390x-gnu')
|
|
462
461
|
const bindingPackageVersion = require('@gtkx/native-linux-s390x-gnu/package.json').version
|
|
463
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
464
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
462
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
463
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
465
464
|
}
|
|
466
465
|
return binding
|
|
467
466
|
} catch (e) {
|
|
@@ -480,8 +479,8 @@ function requireNative() {
|
|
|
480
479
|
try {
|
|
481
480
|
const binding = require('@gtkx/native-openharmony-arm64')
|
|
482
481
|
const bindingPackageVersion = require('@gtkx/native-openharmony-arm64/package.json').version
|
|
483
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
484
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
482
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
483
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
485
484
|
}
|
|
486
485
|
return binding
|
|
487
486
|
} catch (e) {
|
|
@@ -496,8 +495,8 @@ function requireNative() {
|
|
|
496
495
|
try {
|
|
497
496
|
const binding = require('@gtkx/native-openharmony-x64')
|
|
498
497
|
const bindingPackageVersion = require('@gtkx/native-openharmony-x64/package.json').version
|
|
499
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
500
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
498
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
499
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
501
500
|
}
|
|
502
501
|
return binding
|
|
503
502
|
} catch (e) {
|
|
@@ -512,8 +511,8 @@ function requireNative() {
|
|
|
512
511
|
try {
|
|
513
512
|
const binding = require('@gtkx/native-openharmony-arm')
|
|
514
513
|
const bindingPackageVersion = require('@gtkx/native-openharmony-arm/package.json').version
|
|
515
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
516
|
-
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.
|
|
514
|
+
if (bindingPackageVersion !== '2.0.0-beta.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
515
|
+
throw new Error(`Native binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
517
516
|
}
|
|
518
517
|
return binding
|
|
519
518
|
} catch (e) {
|
|
@@ -652,8 +651,8 @@ if (!nativeBinding || forceWasi) {
|
|
|
652
651
|
if (!candidateFailed) {
|
|
653
652
|
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
654
653
|
const bindingPackageVersion = require('@gtkx/native-wasm32-wasi/package.json').version
|
|
655
|
-
if (bindingPackageVersion !== '2.0.0-beta.
|
|
656
|
-
throw new Error(`WASI binding package version mismatch, expected 2.0.0-beta.
|
|
654
|
+
if (bindingPackageVersion !== '2.0.0-beta.7') {
|
|
655
|
+
throw new Error(`WASI binding package version mismatch, expected 2.0.0-beta.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
657
656
|
}
|
|
658
657
|
}
|
|
659
658
|
wasiBinding = require('@gtkx/native-wasm32-wasi')
|
|
@@ -703,7 +702,8 @@ if (!nativeBinding) {
|
|
|
703
702
|
throw new Error(`Failed to load native binding`)
|
|
704
703
|
}
|
|
705
704
|
|
|
706
|
-
const { alloc, armParentDeath, ArrayKind, bind, bindField, bindFunctionPointer, bindVfunc, call, CallbackScope, copy, DestroyNotifyKind, getFundamentalWrapper, getType, getTypeClass, getWrapper, init, keepAlive, newObject, Ownership, quit, read, readField, registerClass, resolveType, setFundamentalWrapper, setWrapper, symbolAddress, write, writeField } = nativeBinding
|
|
705
|
+
const { addLogListener, alloc, armParentDeath, ArrayKind, bind, bindField, bindFunctionPointer, bindVfunc, call, CallbackScope, copy, DestroyNotifyKind, getFundamentalWrapper, getType, getTypeClass, getWrapper, init, keepAlive, newObject, Ownership, quit, read, readField, registerClass, removeLogListener, resolveType, setFundamentalWrapper, setWrapper, symbolAddress, write, writeField } = nativeBinding
|
|
706
|
+
export { addLogListener }
|
|
707
707
|
export { alloc }
|
|
708
708
|
export { armParentDeath }
|
|
709
709
|
export { ArrayKind }
|
|
@@ -727,6 +727,7 @@ export { quit }
|
|
|
727
727
|
export { read }
|
|
728
728
|
export { readField }
|
|
729
729
|
export { registerClass }
|
|
730
|
+
export { removeLogListener }
|
|
730
731
|
export { resolveType }
|
|
731
732
|
export { setFundamentalWrapper }
|
|
732
733
|
export { setWrapper }
|
package/main.d.ts
CHANGED
|
@@ -24,3 +24,23 @@ declare module "./index.js" {
|
|
|
24
24
|
*/
|
|
25
25
|
export type Ref = { value: unknown };
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
type LogLevel = "error" | "critical" | "warning" | "message" | "info" | "debug";
|
|
29
|
+
|
|
30
|
+
type LogListener = (level: LogLevel, domain: string, message: string) => void;
|
|
31
|
+
|
|
32
|
+
type LogSubscription = { unsubscribe(): void };
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Subscribes `listener` to every GLib log record the process writes, whichever thread logs it,
|
|
36
|
+
* and returns the subscription whose `unsubscribe` removes it again. The listener receives the
|
|
37
|
+
* level name, the log domain and the message. Records are queued to the JavaScript thread and
|
|
38
|
+
* delivered asynchronously, so a check that reads what the listener collected has to yield to the
|
|
39
|
+
* event loop once after the logging call. A level GLib treats as fatal, including one made fatal
|
|
40
|
+
* through `logSetAlwaysFatal`, aborts the process before the queued delivery runs, so such a
|
|
41
|
+
* listener never sees it. `unsubscribe` stops further records from being queued but does not cancel
|
|
42
|
+
* the ones already queued, so the listener can still run for those after `unsubscribe` returns.
|
|
43
|
+
*/
|
|
44
|
+
declare function onLog(listener: LogListener): LogSubscription;
|
|
45
|
+
|
|
46
|
+
export { type LogLevel, type LogListener, type LogSubscription, onLog };
|
package/main.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
import "./bootstrap.js";
|
|
2
|
+
import { addLogListener, removeLogListener } from "./index.js";
|
|
3
|
+
|
|
4
|
+
const onLog = (listener) => {
|
|
5
|
+
const id = addLogListener(listener);
|
|
6
|
+
|
|
7
|
+
return {
|
|
8
|
+
unsubscribe: () => {
|
|
9
|
+
removeLogListener(id);
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
};
|
|
2
13
|
|
|
3
14
|
export * from "./index.js";
|
|
15
|
+
export { onLog };
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/native",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
4
|
-
"description": "Rust addon for
|
|
3
|
+
"version": "2.0.0-beta.7",
|
|
4
|
+
"description": "Rust FFI addon for the GTKX GNOME stack and GObject libraries.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
7
7
|
"gtk",
|
|
8
8
|
"gtk4",
|
|
9
|
+
"adwaita",
|
|
10
|
+
"gnome",
|
|
9
11
|
"native",
|
|
10
12
|
"ffi",
|
|
11
13
|
"rust",
|
|
@@ -137,12 +139,12 @@
|
|
|
137
139
|
"node": ">=26.7.0"
|
|
138
140
|
},
|
|
139
141
|
"devDependencies": {
|
|
140
|
-
"@gtkx/vitest": "2.0.0-beta.
|
|
141
|
-
"@napi-rs/cli": "^3.
|
|
142
|
+
"@gtkx/vitest": "2.0.0-beta.7",
|
|
143
|
+
"@napi-rs/cli": "^3.9.0"
|
|
142
144
|
},
|
|
143
145
|
"optionalDependencies": {
|
|
144
|
-
"@gtkx/native-linux-arm64-gnu": "2.0.0-beta.
|
|
145
|
-
"@gtkx/native-linux-x64-gnu": "2.0.0-beta.
|
|
146
|
+
"@gtkx/native-linux-arm64-gnu": "2.0.0-beta.7",
|
|
147
|
+
"@gtkx/native-linux-x64-gnu": "2.0.0-beta.7"
|
|
146
148
|
},
|
|
147
149
|
"scripts": {
|
|
148
150
|
"artifacts": "napi artifacts",
|