@girs/gobject-2.0 2.84.2-4.0.0-beta.25 → 2.84.4-4.0.0-beta.26

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,8 +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.2 using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v4.0.0-beta.25.
9
-
8
+ GJS TypeScript type definitions for GObject-2.0, generated from library version 2.84.4 using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v4.0.0-beta.26.
10
9
 
11
10
  ## Install
12
11
 
package/gobject-2.0.d.ts CHANGED
@@ -47,6 +47,79 @@ export namespace GObject {
47
47
  Requires?: Object[];
48
48
  }
49
49
 
50
+ export type Property<K extends ParamSpec> = K extends ParamSpec<infer T> ? T : any;
51
+
52
+ // Advanced type inference for GObject class registration
53
+ // String conversion utilities for property names
54
+ type SnakeToUnderscoreCase<S extends string> = S extends `${infer T}-${infer U}`
55
+ ? `${T}_${SnakeToUnderscoreCase<U>}`
56
+ : S extends `${infer T}`
57
+ ? `${T}`
58
+ : never;
59
+
60
+ type SnakeToCamelCase<S extends string> = S extends `${infer T}-${infer U}`
61
+ ? `${Lowercase<T>}${SnakeToPascalCase<U>}`
62
+ : S extends `${infer T}`
63
+ ? `${Lowercase<T>}`
64
+ : SnakeToPascalCase<S>;
65
+
66
+ type SnakeToPascalCase<S extends string> = string extends S
67
+ ? string
68
+ : S extends `${infer T}-${infer U}`
69
+ ? `${Capitalize<Lowercase<T>>}${SnakeToPascalCase<U>}`
70
+ : S extends `${infer T}`
71
+ ? `${Capitalize<Lowercase<T>>}`
72
+ : never;
73
+
74
+ type SnakeToCamel<T> = { [P in keyof T as P extends string ? SnakeToCamelCase<P> : P]: T[P] };
75
+ type SnakeToUnderscore<T> = { [P in keyof T as P extends string ? SnakeToUnderscoreCase<P> : P]: T[P] };
76
+
77
+ // Advanced utility types for class registration
78
+ type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) extends (x: infer R) => any ? R : never;
79
+
80
+ type IFaces<Interfaces extends { $gtype: GType<any> }[]> = {
81
+ [key in keyof Interfaces]: Interfaces[key] extends { $gtype: GType<infer I> } ? I : never;
82
+ };
83
+
84
+ export type Properties<Prototype extends {}, Properties extends { [key: string]: ParamSpec }> = Omit<
85
+ {
86
+ [key in keyof Properties | keyof Prototype]: key extends keyof Prototype
87
+ ? never
88
+ : key extends keyof Properties
89
+ ? Property<Properties[key]>
90
+ : never;
91
+ },
92
+ keyof Prototype
93
+ >;
94
+
95
+ export type RegisteredPrototype<
96
+ P extends {},
97
+ Props extends { [key: string]: ParamSpec },
98
+ Interfaces extends any[],
99
+ > = Properties<P, SnakeToCamel<Props> & SnakeToUnderscore<Props>> & UnionToIntersection<Interfaces[number]> & P;
100
+
101
+ type Ctor = new (...a: any[]) => object;
102
+ type Init = { _init(...args: any[]): void };
103
+
104
+ export type RegisteredClass<
105
+ T extends Ctor,
106
+ Props extends { [key: string]: ParamSpec },
107
+ Interfaces extends { $gtype: GType<any> }[],
108
+ > = T extends { prototype: infer P extends {} }
109
+ ? {
110
+ $gtype: GType<RegisteredClass<T, Props, IFaces<Interfaces>>>;
111
+ new (
112
+ ...args: P extends Init ? Parameters<P['_init']> : [void]
113
+ ): RegisteredPrototype<P, Props, IFaces<Interfaces>>;
114
+ prototype: RegisteredPrototype<P, Props, IFaces<Interfaces>>;
115
+ }
116
+ : never;
117
+
118
+ export type SignalDefinitionType = {
119
+ param_types?: readonly GType[];
120
+ [key: string]: any;
121
+ };
122
+
50
123
  // Correctly types interface checks.
51
124
  export function type_is_a<T extends Object>(obj: Object, is_a_type: { $gtype: GType<T> }): obj is T;
52
125
 
@@ -105,6 +178,7 @@ export namespace GObject {
105
178
  export let TYPE_UINT: GType<number>;
106
179
  export let TYPE_INT64: GType<number>;
107
180
  export let TYPE_UINT64: GType<number>;
181
+ export let TYPE_FLOAT: GType<number>;
108
182
 
109
183
  // fake enum for signal accumulators, keep in sync with gi/object.c
110
184
  export enum AccumulatorType {
@@ -231,8 +305,6 @@ export namespace GObject {
231
305
  export function signal_handlers_disconnect_by_func(instance: Object, func: (...args: any[]) => any): number;
232
306
  export function signal_handlers_disconnect_by_data(): void;
233
307
 
234
- export type Property<K extends ParamSpec> = K extends ParamSpec<infer T> ? T : any;
235
-
236
308
  // Helper types for type-safe signal handling
237
309
  export interface SignalSignatures {
238
310
  /** Fallback for dynamic signals and type compatibility */
@@ -251,6 +323,9 @@ export namespace GObject {
251
323
 
252
324
  type ObjectConstructor = { new (...args: any[]): Object };
253
325
 
326
+ // Standard registerClass overloads
327
+ export function registerClass<T extends ObjectConstructor>(cls: T): T;
328
+
254
329
  export function registerClass<
255
330
  T extends ObjectConstructor,
256
331
  Props extends { [key: string]: ParamSpec },
@@ -263,7 +338,36 @@ export namespace GObject {
263
338
  },
264
339
  >(options: MetaInfo<Props, Interfaces, Sigs>, cls: T): T;
265
340
 
266
- export function registerClass<T extends ObjectConstructor>(cls: T): T;
341
+ // Enhanced registerClass overloads with advanced type inference
342
+
343
+ export function registerClass<P extends {}, T extends new (...args: any[]) => P>(
344
+ klass: T,
345
+ ): RegisteredClass<T, {}, []>;
346
+
347
+ export function registerClass<
348
+ T extends Ctor,
349
+ Props extends { [key: string]: ParamSpec },
350
+ Interfaces extends { $gtype: GType }[],
351
+ Sigs extends {
352
+ [key: string]: {
353
+ param_types?: readonly GType[];
354
+ [key: string]: any;
355
+ };
356
+ },
357
+ >(
358
+ options: {
359
+ GTypeName?: string;
360
+ GTypeFlags?: TypeFlags;
361
+ Properties?: Props;
362
+ Signals?: Sigs;
363
+ Implements?: Interfaces;
364
+ CssName?: string;
365
+ Template?: string;
366
+ Children?: string[];
367
+ InternalChildren?: string[];
368
+ },
369
+ klass: T,
370
+ ): RegisteredClass<T, Props, Interfaces>;
267
371
 
268
372
  /**
269
373
  * GObject-2.0
@@ -4044,12 +4148,12 @@ export namespace GObject {
4044
4148
  /**
4045
4149
  * Creates a new GParamSpecChar instance specifying a G_TYPE_CHAR property.
4046
4150
  * @param name The name of the property
4047
- * @param nick A human readable name for the property
4048
- * @param blurb A longer description of the property
4151
+ * @param nick A human readable name for the property (can be null)
4152
+ * @param blurb A longer description of the property (can be null)
4049
4153
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4050
4154
  * @param minimum The minimum value for this property
4051
4155
  * @param maximum The maximum value for this property
4052
- * @param defaultValue The default value for this property
4156
+ * @param defaultValue The default value for this property (optional)
4053
4157
  */
4054
4158
  static ['char'](
4055
4159
  name: string,
@@ -4058,17 +4162,17 @@ export namespace GObject {
4058
4162
  flags: ParamFlags | number,
4059
4163
  minimum: number,
4060
4164
  maximum: number,
4061
- defaultValue: number,
4165
+ defaultValue?: number,
4062
4166
  ): ParamSpec<number>;
4063
4167
  /**
4064
4168
  * Creates a new GParamSpecUChar instance specifying a G_TYPE_UCHAR property.
4065
4169
  * @param name The name of the property
4066
- * @param nick A human readable name for the property
4067
- * @param blurb A longer description of the property
4170
+ * @param nick A human readable name for the property (can be null)
4171
+ * @param blurb A longer description of the property (can be null)
4068
4172
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4069
4173
  * @param minimum The minimum value for this property
4070
4174
  * @param maximum The maximum value for this property
4071
- * @param defaultValue The default value for this property
4175
+ * @param defaultValue The default value for this property (optional)
4072
4176
  */
4073
4177
  static uchar(
4074
4178
  name: string,
@@ -4077,17 +4181,17 @@ export namespace GObject {
4077
4181
  flags: ParamFlags | number,
4078
4182
  minimum: number,
4079
4183
  maximum: number,
4080
- defaultValue: number,
4184
+ defaultValue?: number,
4081
4185
  ): ParamSpec<number>;
4082
4186
  /**
4083
4187
  * Creates a new GParamSpecInt instance specifying a G_TYPE_INT property.
4084
4188
  * @param name The name of the property
4085
- * @param nick A human readable name for the property
4086
- * @param blurb A longer description of the property
4189
+ * @param nick A human readable name for the property (can be null)
4190
+ * @param blurb A longer description of the property (can be null)
4087
4191
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4088
4192
  * @param minimum The minimum value for this property
4089
4193
  * @param maximum The maximum value for this property
4090
- * @param defaultValue The default value for this property
4194
+ * @param defaultValue The default value for this property (optional)
4091
4195
  */
4092
4196
  static int(
4093
4197
  name: string,
@@ -4096,17 +4200,17 @@ export namespace GObject {
4096
4200
  flags: ParamFlags | number,
4097
4201
  minimum: number,
4098
4202
  maximum: number,
4099
- defaultValue: number,
4203
+ defaultValue?: number,
4100
4204
  ): ParamSpec<number>;
4101
4205
  /**
4102
4206
  * Creates a new GParamSpecUInt instance specifying a G_TYPE_UINT property.
4103
4207
  * @param name The name of the property
4104
- * @param nick A human readable name for the property
4105
- * @param blurb A longer description of the property
4208
+ * @param nick A human readable name for the property (can be null)
4209
+ * @param blurb A longer description of the property (can be null)
4106
4210
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4107
4211
  * @param minimum The minimum value for this property
4108
4212
  * @param maximum The maximum value for this property
4109
- * @param defaultValue The default value for this property
4213
+ * @param defaultValue The default value for this property (optional)
4110
4214
  */
4111
4215
  static uint(
4112
4216
  name: string,
@@ -4115,17 +4219,17 @@ export namespace GObject {
4115
4219
  flags: ParamFlags | number,
4116
4220
  minimum: number,
4117
4221
  maximum: number,
4118
- defaultValue: number,
4222
+ defaultValue?: number,
4119
4223
  ): ParamSpec<number>;
4120
4224
  /**
4121
4225
  * Creates a new GParamSpecLong instance specifying a G_TYPE_LONG property.
4122
4226
  * @param name The name of the property
4123
- * @param nick A human readable name for the property
4124
- * @param blurb A longer description of the property
4227
+ * @param nick A human readable name for the property (can be null)
4228
+ * @param blurb A longer description of the property (can be null)
4125
4229
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4126
4230
  * @param minimum The minimum value for this property
4127
4231
  * @param maximum The maximum value for this property
4128
- * @param defaultValue The default value for this property
4232
+ * @param defaultValue The default value for this property (optional)
4129
4233
  */
4130
4234
  static long(
4131
4235
  name: string,
@@ -4134,17 +4238,17 @@ export namespace GObject {
4134
4238
  flags: ParamFlags | number,
4135
4239
  minimum: number,
4136
4240
  maximum: number,
4137
- defaultValue: number,
4241
+ defaultValue?: number,
4138
4242
  ): ParamSpec<number>;
4139
4243
  /**
4140
4244
  * Creates a new GParamSpecULong instance specifying a G_TYPE_ULONG property.
4141
4245
  * @param name The name of the property
4142
- * @param nick A human readable name for the property
4143
- * @param blurb A longer description of the property
4246
+ * @param nick A human readable name for the property (can be null)
4247
+ * @param blurb A longer description of the property (can be null)
4144
4248
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4145
4249
  * @param minimum The minimum value for this property
4146
4250
  * @param maximum The maximum value for this property
4147
- * @param defaultValue The default value for this property
4251
+ * @param defaultValue The default value for this property (optional)
4148
4252
  */
4149
4253
  static ulong(
4150
4254
  name: string,
@@ -4153,17 +4257,17 @@ export namespace GObject {
4153
4257
  flags: ParamFlags | number,
4154
4258
  minimum: number,
4155
4259
  maximum: number,
4156
- defaultValue: number,
4260
+ defaultValue?: number,
4157
4261
  ): ParamSpec<number>;
4158
4262
  /**
4159
4263
  * Creates a new GParamSpecInt64 instance specifying a G_TYPE_INT64 property.
4160
4264
  * @param name The name of the property
4161
- * @param nick A human readable name for the property
4162
- * @param blurb A longer description of the property
4265
+ * @param nick A human readable name for the property (can be null)
4266
+ * @param blurb A longer description of the property (can be null)
4163
4267
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4164
4268
  * @param minimum The minimum value for this property
4165
4269
  * @param maximum The maximum value for this property
4166
- * @param defaultValue The default value for this property
4270
+ * @param defaultValue The default value for this property (optional)
4167
4271
  */
4168
4272
  static int64(
4169
4273
  name: string,
@@ -4172,17 +4276,17 @@ export namespace GObject {
4172
4276
  flags: ParamFlags | number,
4173
4277
  minimum: number,
4174
4278
  maximum: number,
4175
- defaultValue: number,
4279
+ defaultValue?: number,
4176
4280
  ): ParamSpec<number>;
4177
4281
  /**
4178
4282
  * Creates a new GParamSpecUInt64 instance specifying a G_TYPE_UINT64 property.
4179
4283
  * @param name The name of the property
4180
- * @param nick A human readable name for the property
4181
- * @param blurb A longer description of the property
4284
+ * @param nick A human readable name for the property (can be null)
4285
+ * @param blurb A longer description of the property (can be null)
4182
4286
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4183
4287
  * @param minimum The minimum value for this property
4184
4288
  * @param maximum The maximum value for this property
4185
- * @param defaultValue The default value for this property
4289
+ * @param defaultValue The default value for this property (optional)
4186
4290
  */
4187
4291
  static uint64(
4188
4292
  name: string,
@@ -4191,17 +4295,17 @@ export namespace GObject {
4191
4295
  flags: ParamFlags | number,
4192
4296
  minimum: number,
4193
4297
  maximum: number,
4194
- defaultValue: number,
4298
+ defaultValue?: number,
4195
4299
  ): ParamSpec<number>;
4196
4300
  /**
4197
4301
  * Creates a new GParamSpecFloat instance specifying a G_TYPE_FLOAT property.
4198
4302
  * @param name The name of the property
4199
- * @param nick A human readable name for the property
4200
- * @param blurb A longer description of the property
4303
+ * @param nick A human readable name for the property (can be null)
4304
+ * @param blurb A longer description of the property (can be null)
4201
4305
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4202
4306
  * @param minimum The minimum value for this property
4203
4307
  * @param maximum The maximum value for this property
4204
- * @param defaultValue The default value for this property
4308
+ * @param defaultValue The default value for this property (optional)
4205
4309
  */
4206
4310
  static float(
4207
4311
  name: string,
@@ -4210,31 +4314,31 @@ export namespace GObject {
4210
4314
  flags: ParamFlags | number,
4211
4315
  minimum: number,
4212
4316
  maximum: number,
4213
- defaultValue: number,
4317
+ defaultValue?: number,
4214
4318
  ): ParamSpec<number>;
4215
4319
  /**
4216
4320
  * Creates a new GParamSpecBoolean instance specifying a G_TYPE_BOOLEAN property. In many cases, it may be more appropriate to use an enum with g_param_spec_enum(), both to improve code clarity by using explicitly named values, and to allow for more values to be added in future without breaking API.
4217
4321
  * @param name The name of the property
4218
- * @param nick A human readable name for the property
4219
- * @param blurb A longer description of the property
4322
+ * @param nick A human readable name for the property (can be null)
4323
+ * @param blurb A longer description of the property (can be null)
4220
4324
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4221
- * @param defaultValue The default value for this property
4325
+ * @param defaultValue The default value for this property (optional)
4222
4326
  */
4223
4327
  static ['boolean'](
4224
4328
  name: string,
4225
4329
  nick: string | null,
4226
4330
  blurb: string | null,
4227
4331
  flags: ParamFlags | number,
4228
- defaultValue: boolean,
4332
+ defaultValue?: boolean,
4229
4333
  ): ParamSpec<boolean>;
4230
4334
  /**
4231
4335
  * Creates a new GParamSpecEnum instance specifying a G_TYPE_ENUM property.
4232
4336
  * @param name The name of the property
4233
- * @param nick A human readable name for the property
4234
- * @param blurb A longer description of the property
4337
+ * @param nick A human readable name for the property (can be null)
4338
+ * @param blurb A longer description of the property (can be null)
4235
4339
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4236
- * @param enumType
4237
- * @param defaultValue The default value for this property
4340
+ * @param enumType The GType for this property
4341
+ * @param defaultValue The default value for this property (optional)
4238
4342
  */
4239
4343
  static ['enum']<T>(
4240
4344
  name: string,
@@ -4242,17 +4346,17 @@ export namespace GObject {
4242
4346
  blurb: string | null,
4243
4347
  flags: ParamFlags | number,
4244
4348
  enumType: GType<T> | { $gtype: GType<T> },
4245
- defaultValue: any,
4349
+ defaultValue?: any,
4246
4350
  ): ParamSpec<T>;
4247
4351
  /**
4248
4352
  * Creates a new GParamSpecDouble instance specifying a G_TYPE_DOUBLE property.
4249
4353
  * @param name The name of the property
4250
- * @param nick A human readable name for the property
4251
- * @param blurb A longer description of the property
4354
+ * @param nick A human readable name for the property (can be null)
4355
+ * @param blurb A longer description of the property (can be null)
4252
4356
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4253
4357
  * @param minimum The minimum value for this property
4254
4358
  * @param maximum The maximum value for this property
4255
- * @param defaultValue The default value for this property
4359
+ * @param defaultValue The default value for this property (optional)
4256
4360
  */
4257
4361
  static double(
4258
4362
  name: string,
@@ -4261,30 +4365,30 @@ export namespace GObject {
4261
4365
  flags: ParamFlags | number,
4262
4366
  minimum: number,
4263
4367
  maximum: number,
4264
- defaultValue: number,
4368
+ defaultValue?: number,
4265
4369
  ): ParamSpec<number>;
4266
4370
  /**
4267
4371
  * Creates a new GParamSpecString instance specifying a G_TYPE_STRING property.
4268
4372
  * @param name The name of the property
4269
- * @param nick A human readable name for the property
4270
- * @param blurb A longer description of the property
4373
+ * @param nick A human readable name for the property (can be null)
4374
+ * @param blurb A longer description of the property (can be null)
4271
4375
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4272
- * @param defaultValue The default value for this property
4376
+ * @param defaultValue The default value for this property (optional, defaults to null if not provided)
4273
4377
  */
4274
4378
  static string(
4275
4379
  name: string,
4276
4380
  nick: string | null,
4277
4381
  blurb: string | null,
4278
4382
  flags: ParamFlags | number,
4279
- defaultValue: string,
4383
+ defaultValue?: string | null,
4280
4384
  ): ParamSpec<string>;
4281
4385
  /**
4282
4386
  * Creates a new GParamSpecBoxed instance specifying a G_TYPE_BOXED derived property.
4283
4387
  * @param name The name of the property
4284
- * @param nick A human readable name for the property
4285
- * @param blurb A longer description of the property
4388
+ * @param nick A human readable name for the property (can be null)
4389
+ * @param blurb A longer description of the property (can be null)
4286
4390
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4287
- * @param boxedType
4391
+ * @param boxedType The GType for this property
4288
4392
  */
4289
4393
  static boxed<T>(
4290
4394
  name: string,
@@ -4299,22 +4403,22 @@ export namespace GObject {
4299
4403
  * @param nick A human readable name for the property (can be null)
4300
4404
  * @param blurb A longer description of the property (can be null)
4301
4405
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4302
- * @param objectType The GType of the object
4406
+ * @param objectType The GType of the object (optional)
4303
4407
  */
4304
4408
  static object<T>(
4305
4409
  name: string,
4306
4410
  nick: string | null,
4307
4411
  blurb: string | null,
4308
4412
  flags: ParamFlags | number,
4309
- objectType: GType<T> | { $gtype: GType<T> },
4413
+ objectType?: GType<T> | { $gtype: GType<T> },
4310
4414
  ): ParamSpec<T>;
4311
4415
  /**
4312
4416
  * Creates a new GParamSpecParam instance specifying a G_TYPE_PARAM property.
4313
4417
  * @param name The name of the property
4314
- * @param nick A human readable name for the property
4315
- * @param blurb A longer description of the property
4418
+ * @param nick A human readable name for the property (can be null)
4419
+ * @param blurb A longer description of the property (can be null)
4316
4420
  * @param flags The flags for this property (e.g. READABLE, WRITABLE)
4317
- * @param paramType
4421
+ * @param paramType The GType for this property
4318
4422
  */
4319
4423
  static param(
4320
4424
  name: string,
@@ -4458,6 +4562,7 @@ export namespace GObject {
4458
4562
  * @param oclass The object class or type that contains the property to override
4459
4563
  */
4460
4564
  override(name: string, oclass: Object | Function | GType): void;
4565
+ __type__(arg: never): A;
4461
4566
  }
4462
4567
 
4463
4568
  namespace SignalGroup {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@girs/gobject-2.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",
3
+ "version": "2.84.4-4.0.0-beta.26",
4
+ "description": "GJS TypeScript type definitions for GObject-2.0, generated from library version 2.84.4",
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.25",
35
- "@girs/glib-2.0": "^2.84.2-4.0.0-beta.25"
34
+ "@girs/gjs": "^4.0.0-beta.26",
35
+ "@girs/glib-2.0": "^2.84.4-4.0.0-beta.26"
36
36
  },
37
37
  "devDependencies": {
38
38
  "typescript": "*"