@gtkx/native 1.2.2 → 1.4.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 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.<br />
9
- Write native Linux applications with React and TypeScript.
10
- Built on the GNOME stack and standard web tooling.
8
+ The React framework for Linux, built on GTK.<br />
9
+ Write native GTK4 desktop applications with React and TypeScript.
10
+ Real GTK widgets, the GNOME stack, and standard web tooling.
11
11
  </p>
12
12
 
13
13
  <p align="center">
@@ -98,7 +98,7 @@ GTK4 is mature, and GtkBuilder XML can lay out a static interface, but nothing r
98
98
  - a React reconciler that exposes every GObject as a JSX element,
99
99
  - a CLI for scaffolding, development, and production builds,
100
100
  - a dev server with Fast Refresh that patches your running UI in place,
101
- - CSS-in-JS styling and high-level list, grid, and dialog components,
101
+ - CSS-in-JS styling, React Spring animations, React Navigation stack, tab, drawer, and split view navigators, and high-level list, grid, and dialog components,
102
102
  - a Testing Library-style API for querying and driving your widgets in tests,
103
103
  - and a Model Context Protocol (MCP) server that exposes your live app to AI agents.
104
104
 
@@ -157,6 +157,8 @@ Explore the [example apps](https://github.com/gtkx-org/gtkx/tree/main/examples):
157
157
  - [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/hello-world): the counter above.
158
158
  - [`gtk-demo`](https://github.com/gtkx-org/gtkx/tree/main/examples/gtk-demo): a React port of the official GTK4 widget showcase, covering lists, dialogs, gestures, CSS, and OpenGL.
159
159
  - [`browser`](https://github.com/gtkx-org/gtkx/tree/main/examples/browser): a WebKitWebView-based web browser.
160
+ - [`animations`](https://github.com/gtkx-org/gtkx/tree/main/examples/animations): a tour of `@gtkx/animated`, React Spring animations driven by the GTK frame clock.
161
+ - [`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.
160
162
  - [`tutorial`](https://github.com/gtkx-org/gtkx/tree/main/examples/tutorial): the Tasks app the documentation builds.
161
163
 
162
164
  ## Status
package/index.d.ts CHANGED
@@ -39,6 +39,25 @@ export type ArrayKind = 'array'|
39
39
  */
40
40
  export declare function bind(sharedLibrary: string, symbolName: string, argDescriptors: Array<Descriptor>, returnDescriptor: Descriptor, fixedArgCount?: number | undefined | null): ExternalObject<CallDescriptor>
41
41
 
42
+ /**
43
+ * Precompiles the marshalling `fieldDescriptor` describes into a reusable field descriptor that
44
+ * `readField` and `writeField` reach a field through, at whichever offset they are given. `read`
45
+ * and `write` compile the descriptor on every call instead.
46
+ *
47
+ * Binding costs about as much as one unbound access, so it pays off where the binding is hoisted
48
+ * out of the access path — held in a module-level constant an accessor reaches through — rather
49
+ * than made beside the access it serves.
50
+ */
51
+ export declare function bindField(fieldDescriptor: Descriptor): ExternalObject<FieldDescriptor>
52
+
53
+ /**
54
+ * Precompiles the argument and return marshalling of a call to a raw C function pointer into a
55
+ * reusable call descriptor that `call` can invoke. The pointer comes from a native caller that
56
+ * handed a callback into a JavaScript-implemented virtual function or callback, decoded as a
57
+ * bigint address; it must stay valid for as long as the descriptor is called through.
58
+ */
59
+ export declare function bindFunctionPointer(fnPtr: bigint, argDescriptors: Array<Descriptor>, returnDescriptor: Descriptor, label: string): ExternalObject<CallDescriptor>
60
+
42
61
  /**
43
62
  * Precompiles a call to the virtual function slot at `byteOffset` of `instanceType`'s class
44
63
  * structure, of the `interfaceType` vtable that class carries, or of `interfaceType`'s own default
@@ -118,7 +137,7 @@ export type Descriptor =
118
137
  | { kind: 'float32' }
119
138
  | { kind: 'float64' }
120
139
  | { kind: 'enum', sharedLibrary: string, getTypeFnName: string, isSigned: boolean }
121
- | { kind: 'flags', sharedLibrary: string, getTypeFnName: string, isSigned: boolean }
140
+ | { kind: 'flags', sharedLibrary: string, getTypeFnName: string, isSigned: boolean, mask?: number }
122
141
  | { kind: 'boolean' }
123
142
  | { kind: 'string', ownership: Ownership, length?: number }
124
143
  | { kind: 'object', ownership: Ownership, isCallScoped?: boolean }
@@ -127,10 +146,10 @@ export type Descriptor =
127
146
  | { kind: 'buffer' }
128
147
  | { kind: 'boxed', ownership: Ownership, typeName: string, sharedLibrary?: string, getTypeFnName?: string, freeFnName?: string, isCallerAllocated?: boolean, size?: number, isInline?: boolean }
129
148
  | { kind: 'struct', ownership: Ownership, size?: number, isCallerAllocated?: boolean, isInline?: boolean }
130
- | { kind: 'fundamental', ownership: Ownership, sharedLibrary: string, refFnName: string, unrefFnName: string, typeName?: string, isInline?: boolean }
131
- | { kind: 'array', itemDescriptor: Descriptor, arrayKind: ArrayKind, ownership: Ownership, baseParamIndex?: number, sizeParamIndex?: number, fixedSize?: number, elementSize?: number, isBytes?: boolean }
149
+ | { kind: 'fundamental', ownership: Ownership, sharedLibrary: string, refFnName: string, unrefFnName: string, typeName?: string, isCallerAllocated?: boolean, isInline?: boolean }
150
+ | { kind: 'array', itemDescriptor: Descriptor, arrayKind: ArrayKind, ownership: Ownership, baseParamIndex?: number, sizeParamIndex?: number, fixedSize?: number, elementSize?: number, isBytes?: boolean, isCallerAllocated?: boolean }
132
151
  | { kind: 'hashtable', keyDescriptor: Descriptor, valueDescriptor: Descriptor, ownership: Ownership }
133
- | { kind: 'callback', argDescriptors: Array<Descriptor>, returnDescriptor: Descriptor, hasDestroy?: boolean, destroyKind?: DestroyNotifyKind, hasUserData?: boolean, userDataIndex?: number, scope?: CallbackScope }
152
+ | { kind: 'callback', argDescriptors: Array<Descriptor>, returnDescriptor: Descriptor, hasDestroy?: boolean, destroyKind?: DestroyNotifyKind, hasUserData?: boolean, userDataIndex?: number, canThrow?: boolean, scope?: CallbackScope }
134
153
  | { kind: 'ref', innerDescriptor: Descriptor, inout?: boolean }
135
154
 
136
155
  /**
@@ -142,10 +161,24 @@ export type DestroyNotifyKind = 'destroyNotify'|
142
161
  'closureNotify';
143
162
 
144
163
  /**
145
- * Returns the `GType` of the `GObject` referenced by `handle`, or 0 when the handle does not
146
- * reference a `GObject`.
164
+ * Returns the JavaScript wrapper object previously cached for the handle's fundamental
165
+ * instance, or null when no wrapper is cached.
147
166
  */
148
- export declare function getType(handle: ExternalObject<Handle>): bigint
167
+ export declare function getFundamentalWrapper(handle: ExternalObject<Handle>): object | null
168
+
169
+ /**
170
+ * Returns the `GType` of the instance `handle` references, or 0 when it carries no type tag.
171
+ * A `GObject` always carries one. A fundamental instance carries one only when the type the
172
+ * binding declares, passed as `declaredType`, is instantiatable.
173
+ */
174
+ export declare function getType(handle: ExternalObject<Handle>, declaredType?: bigint | undefined | null): bigint
175
+
176
+ /**
177
+ * Returns a handle over the class struct of `gtype`, taking a class reference that is
178
+ * deliberately never released: the class struct of a statically registered type lives for the
179
+ * rest of the process, so the handle borrows it without owning anything.
180
+ */
181
+ export declare function getTypeClass(gtype: bigint): ExternalObject<Handle>
149
182
 
150
183
  /**
151
184
  * Returns the JavaScript wrapper object previously attached to the handle's `GObject`,
@@ -170,9 +203,13 @@ export declare function keepAlive(enable: boolean): void
170
203
  * it by calling `associate` with the instance's handle and the wrapper. A type registered through
171
204
  * `registerClass` binds them from its `instance_init`, before `constructed` runs, so a
172
205
  * `constructed` override already sees a fully usable wrapper; any other type binds them once
173
- * construction has returned.
206
+ * construction has returned. An abstract `gtype` is rejected before anything is constructed.
207
+ * When construction hands back an instance that already carries a
208
+ * wrapper — it reached JavaScript and was wrapped before `g_object_new` returned — that existing
209
+ * wrapper is returned instead of binding `wrapper`, so the caller can adopt it; otherwise the
210
+ * call returns `null`.
174
211
  */
175
- export declare function newObject(gtype: bigint, names: Array<string>, values: ExternalObject<Handle>[], wrapper: object, associate: (handle: ExternalObject<Handle>, wrapper: object) => void): void
212
+ export declare function newObject(gtype: bigint, names: Array<string>, values: ExternalObject<Handle>[], wrapper: object, associate: (handle: ExternalObject<Handle>, wrapper: object) => void): object | null
176
213
 
177
214
  /**
178
215
  * Ownership transfer mode for a marshalled value: `borrowed` leaves the native side owning it,
@@ -189,9 +226,20 @@ export declare function quit(): void
189
226
  * to interpret the raw bytes, and rejects a handle that points at nothing rather than reading at
190
227
  * the bare offset. A value the descriptor marks as stored inline decodes to a handle aliasing the
191
228
  * owner's memory, so writing one of its own fields reaches the owner.
229
+ *
230
+ * The descriptor is compiled on every call. A field read repeatedly from the same descriptor and
231
+ * offset is cheaper through `bindField`, which compiles both once.
192
232
  */
193
233
  export declare function read(handle: ExternalObject<Handle>, fieldDescriptor: Descriptor, offset: number): unknown
194
234
 
235
+ /**
236
+ * Reads and decodes the field a previously bound `descriptor` marshals, sitting `offset` bytes
237
+ * into the handle's memory, and rejects a handle that points at nothing rather than reading at
238
+ * the bare offset. A field the descriptor marks as stored inline decodes to a handle aliasing the
239
+ * owner's memory, so writing one of its own fields reaches the owner.
240
+ */
241
+ export declare function readField(descriptor: ExternalObject<FieldDescriptor>, handle: ExternalObject<Handle>, offset: number): unknown
242
+
195
243
  /**
196
244
  * Registers a new `GObject` subtype named `name` deriving from `parentType`, wiring up any vfunc
197
245
  * overrides and implemented interfaces, and returns the new `GType`.
@@ -212,7 +260,10 @@ export interface RegisterClassInterface {
212
260
  vfuncs: Array<RegisterClassVfunc>
213
261
  }
214
262
 
215
- /** Optional configuration for `registerClass`: vfunc overrides, implemented interfaces and properties. */
263
+ /**
264
+ * Optional configuration for `registerClass`: vfunc overrides, implemented interfaces, properties
265
+ * and signals.
266
+ */
216
267
  export interface RegisterClassOptions {
217
268
  /** Virtual function overrides for the class itself. */
218
269
  vfuncs?: Array<RegisterClassVfunc>
@@ -220,6 +271,15 @@ export interface RegisterClassOptions {
220
271
  interfaces?: Array<RegisterClassInterface>
221
272
  /** Properties to install on the class. */
222
273
  properties?: Array<RegisterClassProperty>
274
+ /** Signals to create on the class. */
275
+ signals?: Array<RegisterClassSignal>
276
+ /** Registers the type with `G_TYPE_FLAG_ABSTRACT`, so only its subtypes can be instantiated. */
277
+ abstract?: boolean
278
+ /**
279
+ * Name instances of the class carry in CSS, applied through `gtk_widget_class_set_css_name`
280
+ * from inside the type's `class_init`. Requires `parentType` to be a `GtkWidget`.
281
+ */
282
+ cssName?: string
223
283
  }
224
284
 
225
285
  /** A property the registered class installs on its class structure. */
@@ -230,6 +290,20 @@ export interface RegisterClassProperty {
230
290
  pspec: ExternalObject<Handle>
231
291
  }
232
292
 
293
+ /** A signal the registered class creates on its type during class initialization. */
294
+ export interface RegisterClassSignal {
295
+ /** Name to create the signal under. Must satisfy `g_signal_is_valid_name`. */
296
+ name: string
297
+ /** `GSignalFlags` bit mask, defaulting to `G_SIGNAL_RUN_FIRST`. */
298
+ flags?: number
299
+ /** `GType` of each argument an emission carries, defaulting to none. */
300
+ paramTypes?: Array<bigint>
301
+ /** `GType` of the value an emission returns, defaulting to `G_TYPE_NONE`. */
302
+ returnType?: bigint
303
+ /** Built-in accumulator combining handler returns: `"first-wins"` or `"true-handled"`. */
304
+ accumulator?: string
305
+ }
306
+
233
307
  /**
234
308
  * A single virtual function override for a registered class: which slot to patch and how its
235
309
  * arguments and return value are marshalled to and from the JavaScript implementation.
@@ -241,6 +315,11 @@ export interface RegisterClassVfunc {
241
315
  argDescriptors: Array<Descriptor>
242
316
  /** Descriptor for the value the JavaScript implementation returns. */
243
317
  returnDescriptor: Descriptor
318
+ /**
319
+ * The slot's C signature ends with a `GError**`, which receives a `GError` built from
320
+ * whatever the JavaScript implementation throws.
321
+ */
322
+ canThrow?: boolean
244
323
  /** The JavaScript function that implements the vfunc. */
245
324
  fn: (...args: never[]) => unknown
246
325
  }
@@ -251,6 +330,14 @@ export interface RegisterClassVfunc {
251
330
  */
252
331
  export declare function resolveType(sharedLibrary: string, getTypeFnName: string): bigint
253
332
 
333
+ /**
334
+ * Caches the JavaScript `wrapper` object for the handle's fundamental instance, so wrapping the
335
+ * same pointer again yields the same object for as long as the wrapper stays alive. A handle
336
+ * that owns no reference to its instance is left uncached, since its pointer can outlive the
337
+ * instance and later name a different one.
338
+ */
339
+ export declare function setFundamentalWrapper(handle: ExternalObject<Handle>, wrapper: object): void
340
+
254
341
  /**
255
342
  * Attaches the JavaScript `wrapper` object to the handle's `GObject` and registers a finalizer
256
343
  * that releases it when the wrapper is garbage collected.
@@ -260,5 +347,15 @@ export declare function setWrapper(handle: ExternalObject<Handle>, wrapper: obje
260
347
  /**
261
348
  * Encodes `value` with `fieldDescriptor` and writes it into the handle's memory at `offset` bytes,
262
349
  * rejecting a handle that points at nothing rather than writing at the bare offset.
350
+ *
351
+ * The descriptor is compiled on every call. A field written repeatedly through the same descriptor
352
+ * and offset is cheaper through `bindField`, which compiles both once.
263
353
  */
264
354
  export declare function write(handle: ExternalObject<Handle>, fieldDescriptor: Descriptor, offset: number, value: unknown): unknown
355
+
356
+ /**
357
+ * Encodes `value` with a previously bound `descriptor` and writes it `offset` bytes into the
358
+ * handle's memory, rejecting a handle that points at nothing rather than writing at the bare
359
+ * offset.
360
+ */
361
+ export declare function writeField(descriptor: ExternalObject<FieldDescriptor>, handle: ExternalObject<Handle>, offset: number, value: unknown): unknown
package/index.js CHANGED
@@ -81,8 +81,8 @@ function requireNative() {
81
81
  try {
82
82
  const binding = require('@gtkx/native-android-arm64')
83
83
  const bindingPackageVersion = require('@gtkx/native-android-arm64/package.json').version
84
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
85
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
84
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
85
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
86
86
  }
87
87
  return binding
88
88
  } catch (e) {
@@ -97,8 +97,8 @@ function requireNative() {
97
97
  try {
98
98
  const binding = require('@gtkx/native-android-arm-eabi')
99
99
  const bindingPackageVersion = require('@gtkx/native-android-arm-eabi/package.json').version
100
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
100
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
102
102
  }
103
103
  return binding
104
104
  } catch (e) {
@@ -118,8 +118,8 @@ function requireNative() {
118
118
  try {
119
119
  const binding = require('@gtkx/native-win32-x64-gnu')
120
120
  const bindingPackageVersion = require('@gtkx/native-win32-x64-gnu/package.json').version
121
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
122
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
121
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
122
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
123
123
  }
124
124
  return binding
125
125
  } catch (e) {
@@ -134,8 +134,8 @@ function requireNative() {
134
134
  try {
135
135
  const binding = require('@gtkx/native-win32-x64-msvc')
136
136
  const bindingPackageVersion = require('@gtkx/native-win32-x64-msvc/package.json').version
137
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
138
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
137
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
138
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
139
139
  }
140
140
  return binding
141
141
  } catch (e) {
@@ -151,8 +151,8 @@ function requireNative() {
151
151
  try {
152
152
  const binding = require('@gtkx/native-win32-ia32-msvc')
153
153
  const bindingPackageVersion = require('@gtkx/native-win32-ia32-msvc/package.json').version
154
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
155
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
154
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
155
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
156
156
  }
157
157
  return binding
158
158
  } catch (e) {
@@ -167,8 +167,8 @@ function requireNative() {
167
167
  try {
168
168
  const binding = require('@gtkx/native-win32-arm64-msvc')
169
169
  const bindingPackageVersion = require('@gtkx/native-win32-arm64-msvc/package.json').version
170
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
170
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
172
172
  }
173
173
  return binding
174
174
  } catch (e) {
@@ -186,8 +186,8 @@ function requireNative() {
186
186
  try {
187
187
  const binding = require('@gtkx/native-darwin-universal')
188
188
  const bindingPackageVersion = require('@gtkx/native-darwin-universal/package.json').version
189
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
190
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
189
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
190
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
191
191
  }
192
192
  return binding
193
193
  } catch (e) {
@@ -202,8 +202,8 @@ function requireNative() {
202
202
  try {
203
203
  const binding = require('@gtkx/native-darwin-x64')
204
204
  const bindingPackageVersion = require('@gtkx/native-darwin-x64/package.json').version
205
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
206
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
205
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
206
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
207
207
  }
208
208
  return binding
209
209
  } catch (e) {
@@ -218,8 +218,8 @@ function requireNative() {
218
218
  try {
219
219
  const binding = require('@gtkx/native-darwin-arm64')
220
220
  const bindingPackageVersion = require('@gtkx/native-darwin-arm64/package.json').version
221
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
222
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
221
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
222
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
223
223
  }
224
224
  return binding
225
225
  } catch (e) {
@@ -238,8 +238,8 @@ function requireNative() {
238
238
  try {
239
239
  const binding = require('@gtkx/native-freebsd-x64')
240
240
  const bindingPackageVersion = require('@gtkx/native-freebsd-x64/package.json').version
241
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
242
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
241
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
242
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
243
243
  }
244
244
  return binding
245
245
  } catch (e) {
@@ -254,8 +254,8 @@ function requireNative() {
254
254
  try {
255
255
  const binding = require('@gtkx/native-freebsd-arm64')
256
256
  const bindingPackageVersion = require('@gtkx/native-freebsd-arm64/package.json').version
257
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
258
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
257
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
258
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
259
259
  }
260
260
  return binding
261
261
  } catch (e) {
@@ -275,8 +275,8 @@ function requireNative() {
275
275
  try {
276
276
  const binding = require('@gtkx/native-linux-x64-musl')
277
277
  const bindingPackageVersion = require('@gtkx/native-linux-x64-musl/package.json').version
278
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
279
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
278
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
279
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
280
280
  }
281
281
  return binding
282
282
  } catch (e) {
@@ -291,8 +291,8 @@ function requireNative() {
291
291
  try {
292
292
  const binding = require('@gtkx/native-linux-x64-gnu')
293
293
  const bindingPackageVersion = require('@gtkx/native-linux-x64-gnu/package.json').version
294
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
295
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
294
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
295
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
296
296
  }
297
297
  return binding
298
298
  } catch (e) {
@@ -309,8 +309,8 @@ function requireNative() {
309
309
  try {
310
310
  const binding = require('@gtkx/native-linux-arm64-musl')
311
311
  const bindingPackageVersion = require('@gtkx/native-linux-arm64-musl/package.json').version
312
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
313
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
312
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
313
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
314
314
  }
315
315
  return binding
316
316
  } catch (e) {
@@ -325,8 +325,8 @@ function requireNative() {
325
325
  try {
326
326
  const binding = require('@gtkx/native-linux-arm64-gnu')
327
327
  const bindingPackageVersion = require('@gtkx/native-linux-arm64-gnu/package.json').version
328
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
329
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
328
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
329
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
330
330
  }
331
331
  return binding
332
332
  } catch (e) {
@@ -343,8 +343,8 @@ function requireNative() {
343
343
  try {
344
344
  const binding = require('@gtkx/native-linux-arm-musleabihf')
345
345
  const bindingPackageVersion = require('@gtkx/native-linux-arm-musleabihf/package.json').version
346
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
347
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
346
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
347
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
348
348
  }
349
349
  return binding
350
350
  } catch (e) {
@@ -359,8 +359,8 @@ function requireNative() {
359
359
  try {
360
360
  const binding = require('@gtkx/native-linux-arm-gnueabihf')
361
361
  const bindingPackageVersion = require('@gtkx/native-linux-arm-gnueabihf/package.json').version
362
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
363
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
362
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
363
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
364
364
  }
365
365
  return binding
366
366
  } catch (e) {
@@ -377,8 +377,8 @@ function requireNative() {
377
377
  try {
378
378
  const binding = require('@gtkx/native-linux-loong64-musl')
379
379
  const bindingPackageVersion = require('@gtkx/native-linux-loong64-musl/package.json').version
380
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
381
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
380
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
381
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
382
382
  }
383
383
  return binding
384
384
  } catch (e) {
@@ -393,8 +393,8 @@ function requireNative() {
393
393
  try {
394
394
  const binding = require('@gtkx/native-linux-loong64-gnu')
395
395
  const bindingPackageVersion = require('@gtkx/native-linux-loong64-gnu/package.json').version
396
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
397
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
396
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
397
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
398
398
  }
399
399
  return binding
400
400
  } catch (e) {
@@ -411,8 +411,8 @@ function requireNative() {
411
411
  try {
412
412
  const binding = require('@gtkx/native-linux-riscv64-musl')
413
413
  const bindingPackageVersion = require('@gtkx/native-linux-riscv64-musl/package.json').version
414
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
415
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
414
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
415
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
416
416
  }
417
417
  return binding
418
418
  } catch (e) {
@@ -427,8 +427,8 @@ function requireNative() {
427
427
  try {
428
428
  const binding = require('@gtkx/native-linux-riscv64-gnu')
429
429
  const bindingPackageVersion = require('@gtkx/native-linux-riscv64-gnu/package.json').version
430
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
431
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
430
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
431
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
432
432
  }
433
433
  return binding
434
434
  } catch (e) {
@@ -444,8 +444,8 @@ function requireNative() {
444
444
  try {
445
445
  const binding = require('@gtkx/native-linux-ppc64-gnu')
446
446
  const bindingPackageVersion = require('@gtkx/native-linux-ppc64-gnu/package.json').version
447
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
448
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
447
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
448
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
449
449
  }
450
450
  return binding
451
451
  } catch (e) {
@@ -460,8 +460,8 @@ function requireNative() {
460
460
  try {
461
461
  const binding = require('@gtkx/native-linux-s390x-gnu')
462
462
  const bindingPackageVersion = require('@gtkx/native-linux-s390x-gnu/package.json').version
463
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
464
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
463
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
464
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
465
465
  }
466
466
  return binding
467
467
  } catch (e) {
@@ -480,8 +480,8 @@ function requireNative() {
480
480
  try {
481
481
  const binding = require('@gtkx/native-openharmony-arm64')
482
482
  const bindingPackageVersion = require('@gtkx/native-openharmony-arm64/package.json').version
483
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
484
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
483
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
484
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
485
485
  }
486
486
  return binding
487
487
  } catch (e) {
@@ -496,8 +496,8 @@ function requireNative() {
496
496
  try {
497
497
  const binding = require('@gtkx/native-openharmony-x64')
498
498
  const bindingPackageVersion = require('@gtkx/native-openharmony-x64/package.json').version
499
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
500
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
499
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
500
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
501
501
  }
502
502
  return binding
503
503
  } catch (e) {
@@ -512,8 +512,8 @@ function requireNative() {
512
512
  try {
513
513
  const binding = require('@gtkx/native-openharmony-arm')
514
514
  const bindingPackageVersion = require('@gtkx/native-openharmony-arm/package.json').version
515
- if (bindingPackageVersion !== '1.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
516
- throw new Error(`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
515
+ if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
516
+ throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
517
517
  }
518
518
  return binding
519
519
  } catch (e) {
@@ -652,8 +652,8 @@ if (!nativeBinding || forceWasi) {
652
652
  if (!candidateFailed) {
653
653
  if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
654
654
  const bindingPackageVersion = require('@gtkx/native-wasm32-wasi/package.json').version
655
- if (bindingPackageVersion !== '1.2.2') {
656
- throw new Error(`WASI binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
655
+ if (bindingPackageVersion !== '1.4.0') {
656
+ throw new Error(`WASI binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
657
657
  }
658
658
  }
659
659
  wasiBinding = require('@gtkx/native-wasm32-wasi')
@@ -703,16 +703,20 @@ if (!nativeBinding) {
703
703
  throw new Error(`Failed to load native binding`)
704
704
  }
705
705
 
706
- const { alloc, ArrayKind, bind, bindVfunc, call, CallbackScope, copy, DestroyNotifyKind, getType, getWrapper, init, keepAlive, newObject, Ownership, quit, read, registerClass, resolveType, setWrapper, write } = nativeBinding
706
+ const { alloc, ArrayKind, bind, bindField, bindFunctionPointer, bindVfunc, call, CallbackScope, copy, DestroyNotifyKind, getFundamentalWrapper, getType, getTypeClass, getWrapper, init, keepAlive, newObject, Ownership, quit, read, readField, registerClass, resolveType, setFundamentalWrapper, setWrapper, write, writeField } = nativeBinding
707
707
  export { alloc }
708
708
  export { ArrayKind }
709
709
  export { bind }
710
+ export { bindField }
711
+ export { bindFunctionPointer }
710
712
  export { bindVfunc }
711
713
  export { call }
712
714
  export { CallbackScope }
713
715
  export { copy }
714
716
  export { DestroyNotifyKind }
717
+ export { getFundamentalWrapper }
715
718
  export { getType }
719
+ export { getTypeClass }
716
720
  export { getWrapper }
717
721
  export { init }
718
722
  export { keepAlive }
@@ -720,7 +724,10 @@ export { newObject }
720
724
  export { Ownership }
721
725
  export { quit }
722
726
  export { read }
727
+ export { readField }
723
728
  export { registerClass }
724
729
  export { resolveType }
730
+ export { setFundamentalWrapper }
725
731
  export { setWrapper }
726
732
  export { write }
733
+ export { writeField }
package/main.d.ts CHANGED
@@ -12,6 +12,12 @@ declare module "./index.js" {
12
12
  * It captures the resolved symbol and the marshalling of its arguments and return value.
13
13
  */
14
14
  export type CallDescriptor = { _opaque: "CallDescriptor" };
15
+ /**
16
+ * An opaque, precompiled binding of a struct field, produced by `bindField` and passed to
17
+ * `readField` and `writeField`. It captures the marshalling of the field's bytes; the byte
18
+ * offset the field sits at within its owner's memory is given on every access.
19
+ */
20
+ export type FieldDescriptor = { _opaque: "FieldDescriptor" };
15
21
  /**
16
22
  * A mutable box for an out or inout ('ref' descriptor) parameter. Pass an object with a `value`
17
23
  * property; after `call` returns, its `value` holds the decoded native result.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gtkx/native",
3
- "version": "1.2.2",
4
- "description": "Rust addon under GTKX that loads shared libraries, marshals values, and tracks GObject handles",
3
+ "version": "1.4.0",
4
+ "description": "Rust addon for GTK: loads libraries, marshals values, tracks GObjects.",
5
5
  "keywords": [
6
6
  "gtkx",
7
7
  "gtk",
@@ -69,6 +69,9 @@
69
69
  "{projectRoot}/tests/**/*",
70
70
  "{projectRoot}/test-support/**/*",
71
71
  "{workspaceRoot}/scripts/run-headless.ts",
72
+ "{workspaceRoot}/scripts/cargo-nightly.ts",
73
+ "{workspaceRoot}/scripts/coverage-target.ts",
74
+ "{workspaceRoot}/scripts/rust-nightly.ts",
72
75
  "{workspaceRoot}/packages/utils/src/**/*"
73
76
  ]
74
77
  },
@@ -177,8 +180,8 @@
177
180
  "@napi-rs/cli": "^3.8.6"
178
181
  },
179
182
  "optionalDependencies": {
180
- "@gtkx/native-linux-arm64-gnu": "1.2.2",
181
- "@gtkx/native-linux-x64-gnu": "1.2.2"
183
+ "@gtkx/native-linux-arm64-gnu": "1.4.0",
184
+ "@gtkx/native-linux-x64-gnu": "1.4.0"
182
185
  },
183
186
  "scripts": {
184
187
  "artifacts": "napi artifacts",