@girs/gobject-2.0 2.84.0-4.0.0-beta.23 → 2.84.2-4.0.0-beta.25

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,7 +5,7 @@
5
5
  ![downloads/week](https://img.shields.io/npm/dw/@girs/gobject-2.0)
6
6
 
7
7
 
8
- GJS TypeScript type definitions for GObject-2.0, generated from library version 2.84.0 using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v4.0.0-beta.23.
8
+ GJS TypeScript type definitions for GObject-2.0, generated from library version 2.84.2 using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v4.0.0-beta.25.
9
9
 
10
10
 
11
11
  ## Install
package/gobject-2.0.d.ts CHANGED
@@ -13,9 +13,11 @@ import '@girs/gjs';
13
13
  import type GLib from '@girs/glib-2.0';
14
14
 
15
15
  export namespace GObject {
16
- // A few things here are inspired by gi.ts
17
- // See https://gitlab.gnome.org/ewlsh/gi.ts/-/blob/master/packages/lib/src/generators/dts/gobject.ts
18
- // Copyright Evan Welsh
16
+ /**
17
+ * Obtain the parameters of a function type in a tuple.
18
+ * Note: This is a copy of the Parameters type from the TypeScript standard library to avoid name conflicts, as some GIR types define `Parameters` as a namespace.
19
+ */
20
+ export type GjsParameters<T extends (...args: any) => any> = T extends (...args: infer P) => any ? P : never;
19
21
 
20
22
  // __type__ forces all GTypes to not match structurally.
21
23
  export type GType<T = unknown> = {
@@ -231,6 +233,19 @@ export namespace GObject {
231
233
 
232
234
  export type Property<K extends ParamSpec> = K extends ParamSpec<infer T> ? T : any;
233
235
 
236
+ // Helper types for type-safe signal handling
237
+ export interface SignalSignatures {
238
+ /** Fallback for dynamic signals and type compatibility */
239
+ [signal: string]: (...args: any[]) => any;
240
+ }
241
+
242
+ /**
243
+ * Helper to prepend the emitter (`source`) to an existing callback type.
244
+ */
245
+ export type SignalCallback<Emitter, Fn> = Fn extends (...args: infer P) => infer R
246
+ ? (source: Emitter, ...args: P) => R
247
+ : never;
248
+
234
249
  // TODO: What about the generated class Closure
235
250
  export type TClosure<R = any, P = any> = (...args: P[]) => R;
236
251
 
@@ -1336,7 +1351,7 @@ export namespace GObject {
1336
1351
  name: string,
1337
1352
  nick: string | null,
1338
1353
  blurb: string | null,
1339
- default_value: number,
1354
+ default_value: string,
1340
1355
  flags: ParamFlags | null,
1341
1356
  ): ParamSpec;
1342
1357
  /**
@@ -2925,6 +2940,15 @@ export namespace GObject {
2925
2940
  DEEP_DERIVABLE,
2926
2941
  }
2927
2942
  namespace Binding {
2943
+ // Signal signatures
2944
+ interface SignalSignatures extends Object.SignalSignatures {
2945
+ 'notify::flags': (pspec: ParamSpec) => void;
2946
+ 'notify::source': (pspec: ParamSpec) => void;
2947
+ 'notify::source-property': (pspec: ParamSpec) => void;
2948
+ 'notify::target': (pspec: ParamSpec) => void;
2949
+ 'notify::target-property': (pspec: ParamSpec) => void;
2950
+ }
2951
+
2928
2952
  // Constructor properties interface
2929
2953
 
2930
2954
  interface ConstructorProps extends Object.ConstructorProps {
@@ -3065,12 +3089,39 @@ export namespace GObject {
3065
3089
  */
3066
3090
  get targetProperty(): string;
3067
3091
 
3092
+ /**
3093
+ * Compile-time signal type information.
3094
+ *
3095
+ * This instance property is generated only for TypeScript type checking.
3096
+ * It is not defined at runtime and should not be accessed in JS code.
3097
+ * @internal
3098
+ */
3099
+ $signals: Binding.SignalSignatures;
3100
+
3068
3101
  // Constructors
3069
3102
 
3070
3103
  constructor(properties?: Partial<Binding.ConstructorProps>, ...args: any[]);
3071
3104
 
3072
3105
  _init(...args: any[]): void;
3073
3106
 
3107
+ // Signals
3108
+
3109
+ connect<K extends keyof Binding.SignalSignatures>(
3110
+ signal: K,
3111
+ callback: SignalCallback<this, Binding.SignalSignatures[K]>,
3112
+ ): number;
3113
+ connect(signal: string, callback: (...args: any[]) => any): number;
3114
+ connect_after<K extends keyof Binding.SignalSignatures>(
3115
+ signal: K,
3116
+ callback: SignalCallback<this, Binding.SignalSignatures[K]>,
3117
+ ): number;
3118
+ connect_after(signal: string, callback: (...args: any[]) => any): number;
3119
+ emit<K extends keyof Binding.SignalSignatures>(
3120
+ signal: K,
3121
+ ...args: GjsParameters<Binding.SignalSignatures[K]> extends [any, ...infer Q] ? Q : never
3122
+ ): void;
3123
+ emit(signal: string, ...args: any[]): void;
3124
+
3074
3125
  // Methods
3075
3126
 
3076
3127
  /**
@@ -3151,6 +3202,11 @@ export namespace GObject {
3151
3202
  }
3152
3203
 
3153
3204
  namespace BindingGroup {
3205
+ // Signal signatures
3206
+ interface SignalSignatures extends Object.SignalSignatures {
3207
+ 'notify::source': (pspec: ParamSpec) => void;
3208
+ }
3209
+
3154
3210
  // Constructor properties interface
3155
3211
 
3156
3212
  interface ConstructorProps extends Object.ConstructorProps {
@@ -3178,6 +3234,15 @@ export namespace GObject {
3178
3234
  get source(): Object;
3179
3235
  set source(val: Object);
3180
3236
 
3237
+ /**
3238
+ * Compile-time signal type information.
3239
+ *
3240
+ * This instance property is generated only for TypeScript type checking.
3241
+ * It is not defined at runtime and should not be accessed in JS code.
3242
+ * @internal
3243
+ */
3244
+ $signals: BindingGroup.SignalSignatures;
3245
+
3181
3246
  // Constructors
3182
3247
 
3183
3248
  constructor(properties?: Partial<BindingGroup.ConstructorProps>, ...args: any[]);
@@ -3186,6 +3251,24 @@ export namespace GObject {
3186
3251
 
3187
3252
  static ['new'](): BindingGroup;
3188
3253
 
3254
+ // Signals
3255
+
3256
+ connect<K extends keyof BindingGroup.SignalSignatures>(
3257
+ signal: K,
3258
+ callback: SignalCallback<this, BindingGroup.SignalSignatures[K]>,
3259
+ ): number;
3260
+ connect(signal: string, callback: (...args: any[]) => any): number;
3261
+ connect_after<K extends keyof BindingGroup.SignalSignatures>(
3262
+ signal: K,
3263
+ callback: SignalCallback<this, BindingGroup.SignalSignatures[K]>,
3264
+ ): number;
3265
+ connect_after(signal: string, callback: (...args: any[]) => any): number;
3266
+ emit<K extends keyof BindingGroup.SignalSignatures>(
3267
+ signal: K,
3268
+ ...args: GjsParameters<BindingGroup.SignalSignatures[K]> extends [any, ...infer Q] ? Q : never
3269
+ ): void;
3270
+ emit(signal: string, ...args: any[]): void;
3271
+
3189
3272
  // Methods
3190
3273
 
3191
3274
  /**
@@ -3266,6 +3349,9 @@ export namespace GObject {
3266
3349
  }
3267
3350
 
3268
3351
  namespace InitiallyUnowned {
3352
+ // Signal signatures
3353
+ interface SignalSignatures extends Object.SignalSignatures {}
3354
+
3269
3355
  // Constructor properties interface
3270
3356
 
3271
3357
  interface ConstructorProps extends Object.ConstructorProps {}
@@ -3280,18 +3366,44 @@ export namespace GObject {
3280
3366
  class InitiallyUnowned extends Object {
3281
3367
  static $gtype: GType<InitiallyUnowned>;
3282
3368
 
3369
+ /**
3370
+ * Compile-time signal type information.
3371
+ *
3372
+ * This instance property is generated only for TypeScript type checking.
3373
+ * It is not defined at runtime and should not be accessed in JS code.
3374
+ * @internal
3375
+ */
3376
+ $signals: InitiallyUnowned.SignalSignatures;
3377
+
3283
3378
  // Constructors
3284
3379
 
3285
3380
  constructor(properties?: Partial<InitiallyUnowned.ConstructorProps>, ...args: any[]);
3286
3381
 
3287
3382
  _init(...args: any[]): void;
3383
+
3384
+ // Signals
3385
+
3386
+ connect<K extends keyof InitiallyUnowned.SignalSignatures>(
3387
+ signal: K,
3388
+ callback: SignalCallback<this, InitiallyUnowned.SignalSignatures[K]>,
3389
+ ): number;
3390
+ connect(signal: string, callback: (...args: any[]) => any): number;
3391
+ connect_after<K extends keyof InitiallyUnowned.SignalSignatures>(
3392
+ signal: K,
3393
+ callback: SignalCallback<this, InitiallyUnowned.SignalSignatures[K]>,
3394
+ ): number;
3395
+ connect_after(signal: string, callback: (...args: any[]) => any): number;
3396
+ emit<K extends keyof InitiallyUnowned.SignalSignatures>(
3397
+ signal: K,
3398
+ ...args: GjsParameters<InitiallyUnowned.SignalSignatures[K]> extends [any, ...infer Q] ? Q : never
3399
+ ): void;
3400
+ emit(signal: string, ...args: any[]): void;
3288
3401
  }
3289
3402
 
3290
3403
  namespace Object {
3291
- // Signal callback interfaces
3292
-
3293
- interface Notify {
3294
- (pspec: ParamSpec): void;
3404
+ // Signal signatures
3405
+ interface SignalSignatures {
3406
+ notify: (arg0: ParamSpec) => void;
3295
3407
  }
3296
3408
 
3297
3409
  // Constructor properties interface
@@ -3326,6 +3438,15 @@ export namespace GObject {
3326
3438
  class Object {
3327
3439
  static $gtype: GType<Object>;
3328
3440
 
3441
+ /**
3442
+ * Compile-time signal type information.
3443
+ *
3444
+ * This instance property is generated only for TypeScript type checking.
3445
+ * It is not defined at runtime and should not be accessed in JS code.
3446
+ * @internal
3447
+ */
3448
+ $signals: Object.SignalSignatures;
3449
+
3329
3450
  // Constructors
3330
3451
 
3331
3452
  _init(...args: any[]): void;
@@ -3334,12 +3455,21 @@ export namespace GObject {
3334
3455
 
3335
3456
  // Signals
3336
3457
 
3337
- connect(id: string, callback: (...args: any[]) => any): number;
3338
- connect_after(id: string, callback: (...args: any[]) => any): number;
3339
- emit(id: string, ...args: any[]): void;
3340
- connect(signal: 'notify', callback: (_source: this, pspec: ParamSpec) => void): number;
3341
- connect_after(signal: 'notify', callback: (_source: this, pspec: ParamSpec) => void): number;
3342
- emit(signal: 'notify', pspec: ParamSpec): void;
3458
+ connect<K extends keyof Object.SignalSignatures>(
3459
+ signal: K,
3460
+ callback: SignalCallback<this, Object.SignalSignatures[K]>,
3461
+ ): number;
3462
+ connect(signal: string, callback: (...args: any[]) => any): number;
3463
+ connect_after<K extends keyof Object.SignalSignatures>(
3464
+ signal: K,
3465
+ callback: SignalCallback<this, Object.SignalSignatures[K]>,
3466
+ ): number;
3467
+ connect_after(signal: string, callback: (...args: any[]) => any): number;
3468
+ emit<K extends keyof Object.SignalSignatures>(
3469
+ signal: K,
3470
+ ...args: GjsParameters<Object.SignalSignatures[K]> extends [any, ...infer Q] ? Q : never
3471
+ ): void;
3472
+ emit(signal: string, ...args: any[]): void;
3343
3473
 
3344
3474
  // Static methods
3345
3475
 
@@ -3571,8 +3701,8 @@ export namespace GObject {
3571
3701
  target: Object,
3572
3702
  target_property: string,
3573
3703
  flags: BindingFlags | null,
3574
- transform_to: Closure,
3575
- transform_from: Closure,
3704
+ transform_to: Closure | null,
3705
+ transform_from: Closure | null,
3576
3706
  ): Binding;
3577
3707
  /**
3578
3708
  * This function is intended for #GObject implementations to re-enforce
@@ -3858,6 +3988,11 @@ export namespace GObject {
3858
3988
  stop_emission_by_name(detailedName: string): void;
3859
3989
  }
3860
3990
 
3991
+ namespace ParamSpec {
3992
+ // Signal signatures
3993
+ interface SignalSignatures extends Object.SignalSignatures {}
3994
+ }
3995
+
3861
3996
  /**
3862
3997
  * A GObject parameter specification that defines property characteristics.
3863
3998
  * See https://gjs.guide/guides/gobject/basics.html#properties for more details.
@@ -3876,6 +4011,24 @@ export namespace GObject {
3876
4011
 
3877
4012
  _init(...args: any[]): void;
3878
4013
 
4014
+ // Signals
4015
+
4016
+ connect<K extends keyof ParamSpec.SignalSignatures>(
4017
+ signal: K,
4018
+ callback: SignalCallback<this, ParamSpec.SignalSignatures[K]>,
4019
+ ): number;
4020
+ connect(signal: string, callback: (...args: any[]) => any): number;
4021
+ connect_after<K extends keyof ParamSpec.SignalSignatures>(
4022
+ signal: K,
4023
+ callback: SignalCallback<this, ParamSpec.SignalSignatures[K]>,
4024
+ ): number;
4025
+ connect_after(signal: string, callback: (...args: any[]) => any): number;
4026
+ emit<K extends keyof ParamSpec.SignalSignatures>(
4027
+ signal: K,
4028
+ ...args: GjsParameters<ParamSpec.SignalSignatures[K]> extends [any, ...infer Q] ? Q : never
4029
+ ): void;
4030
+ emit(signal: string, ...args: any[]): void;
4031
+
3879
4032
  // Static methods
3880
4033
 
3881
4034
  /**
@@ -4308,14 +4461,12 @@ export namespace GObject {
4308
4461
  }
4309
4462
 
4310
4463
  namespace SignalGroup {
4311
- // Signal callback interfaces
4312
-
4313
- interface Bind {
4314
- (instance: Object): void;
4315
- }
4316
-
4317
- interface Unbind {
4318
- (): void;
4464
+ // Signal signatures
4465
+ interface SignalSignatures extends Object.SignalSignatures {
4466
+ bind: (arg0: Object) => void;
4467
+ unbind: () => void;
4468
+ 'notify::target': (pspec: ParamSpec) => void;
4469
+ 'notify::target-type': (pspec: ParamSpec) => void;
4319
4470
  }
4320
4471
 
4321
4472
  // Constructor properties interface
@@ -4367,6 +4518,15 @@ export namespace GObject {
4367
4518
  */
4368
4519
  get targetType(): GType;
4369
4520
 
4521
+ /**
4522
+ * Compile-time signal type information.
4523
+ *
4524
+ * This instance property is generated only for TypeScript type checking.
4525
+ * It is not defined at runtime and should not be accessed in JS code.
4526
+ * @internal
4527
+ */
4528
+ $signals: SignalGroup.SignalSignatures;
4529
+
4370
4530
  // Constructors
4371
4531
 
4372
4532
  constructor(properties?: Partial<SignalGroup.ConstructorProps>, ...args: any[]);
@@ -4377,15 +4537,21 @@ export namespace GObject {
4377
4537
 
4378
4538
  // Signals
4379
4539
 
4380
- connect(id: string, callback: (...args: any[]) => any): number;
4381
- connect_after(id: string, callback: (...args: any[]) => any): number;
4382
- emit(id: string, ...args: any[]): void;
4383
- connect(signal: 'bind', callback: (_source: this, instance: Object) => void): number;
4384
- connect_after(signal: 'bind', callback: (_source: this, instance: Object) => void): number;
4385
- emit(signal: 'bind', instance: Object): void;
4386
- connect(signal: 'unbind', callback: (_source: this) => void): number;
4387
- connect_after(signal: 'unbind', callback: (_source: this) => void): number;
4388
- emit(signal: 'unbind'): void;
4540
+ connect<K extends keyof SignalGroup.SignalSignatures>(
4541
+ signal: K,
4542
+ callback: SignalCallback<this, SignalGroup.SignalSignatures[K]>,
4543
+ ): number;
4544
+ connect(signal: string, callback: (...args: any[]) => any): number;
4545
+ connect_after<K extends keyof SignalGroup.SignalSignatures>(
4546
+ signal: K,
4547
+ callback: SignalCallback<this, SignalGroup.SignalSignatures[K]>,
4548
+ ): number;
4549
+ connect_after(signal: string, callback: (...args: any[]) => any): number;
4550
+ emit<K extends keyof SignalGroup.SignalSignatures>(
4551
+ signal: K,
4552
+ ...args: GjsParameters<SignalGroup.SignalSignatures[K]> extends [any, ...infer Q] ? Q : never
4553
+ ): void;
4554
+ emit(signal: string, ...args: any[]): void;
4389
4555
 
4390
4556
  // Methods
4391
4557
 
@@ -4459,6 +4625,9 @@ export namespace GObject {
4459
4625
  }
4460
4626
 
4461
4627
  namespace TypeModule {
4628
+ // Signal signatures
4629
+ interface SignalSignatures extends Object.SignalSignatures {}
4630
+
4462
4631
  // Constructor properties interface
4463
4632
 
4464
4633
  interface ConstructorProps extends Object.ConstructorProps, TypePlugin.ConstructorProps {}
@@ -4500,6 +4669,15 @@ export namespace GObject {
4500
4669
  abstract class TypeModule extends Object implements TypePlugin {
4501
4670
  static $gtype: GType<TypeModule>;
4502
4671
 
4672
+ /**
4673
+ * Compile-time signal type information.
4674
+ *
4675
+ * This instance property is generated only for TypeScript type checking.
4676
+ * It is not defined at runtime and should not be accessed in JS code.
4677
+ * @internal
4678
+ */
4679
+ $signals: TypeModule.SignalSignatures;
4680
+
4503
4681
  // Fields
4504
4682
 
4505
4683
  use_count: number;
@@ -4513,6 +4691,24 @@ export namespace GObject {
4513
4691
 
4514
4692
  _init(...args: any[]): void;
4515
4693
 
4694
+ // Signals
4695
+
4696
+ connect<K extends keyof TypeModule.SignalSignatures>(
4697
+ signal: K,
4698
+ callback: SignalCallback<this, TypeModule.SignalSignatures[K]>,
4699
+ ): number;
4700
+ connect(signal: string, callback: (...args: any[]) => any): number;
4701
+ connect_after<K extends keyof TypeModule.SignalSignatures>(
4702
+ signal: K,
4703
+ callback: SignalCallback<this, TypeModule.SignalSignatures[K]>,
4704
+ ): number;
4705
+ connect_after(signal: string, callback: (...args: any[]) => any): number;
4706
+ emit<K extends keyof TypeModule.SignalSignatures>(
4707
+ signal: K,
4708
+ ...args: GjsParameters<TypeModule.SignalSignatures[K]> extends [any, ...infer Q] ? Q : never
4709
+ ): void;
4710
+ emit(signal: string, ...args: any[]): void;
4711
+
4516
4712
  // Virtual methods
4517
4713
 
4518
4714
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@girs/gobject-2.0",
3
- "version": "2.84.0-4.0.0-beta.23",
4
- "description": "GJS TypeScript type definitions for GObject-2.0, generated from library version 2.84.0",
3
+ "version": "2.84.2-4.0.0-beta.25",
4
+ "description": "GJS TypeScript type definitions for GObject-2.0, generated from library version 2.84.2",
5
5
  "type": "module",
6
6
  "module": "gobject-2.0.js",
7
7
  "main": "gobject-2.0.js",
@@ -31,8 +31,8 @@
31
31
  "test": "tsc --project tsconfig.json"
32
32
  },
33
33
  "dependencies": {
34
- "@girs/gjs": "^4.0.0-beta.23",
35
- "@girs/glib-2.0": "^2.84.0-4.0.0-beta.23"
34
+ "@girs/gjs": "^4.0.0-beta.25",
35
+ "@girs/glib-2.0": "^2.84.2-4.0.0-beta.25"
36
36
  },
37
37
  "devDependencies": {
38
38
  "typescript": "*"