@ts-for-gir/templates 4.0.0-beta.42 → 4.0.0-beta.44
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/package.json +1 -1
- package/templates/glib-2.0.d.ts +42 -31
- package/templates/gobject-2.0.d.ts +9 -5
package/package.json
CHANGED
package/templates/glib-2.0.d.ts
CHANGED
|
@@ -43,13 +43,13 @@ type CreateIndexType<Key extends string, Value extends any> =
|
|
|
43
43
|
type $ParseDeepVariantDict<State extends string> =
|
|
44
44
|
string extends State
|
|
45
45
|
? VariantTypeError<"$ParseDeepVariantDict: 'string' is not a supported type.">
|
|
46
|
-
: State extends `${infer Key}${infer
|
|
46
|
+
: State extends `${infer Key}${infer AfterKey}`
|
|
47
47
|
? Key extends 's' | 'o' | 'g' | 'n' | 'q' | 't' | 'd' | 'u' | 'i' | 'x' | 'y'
|
|
48
|
-
?
|
|
48
|
+
? AfterKey extends `v}${infer Remaining}`
|
|
49
49
|
? [CreateIndexType<Key, Variant>, Remaining] // a{sv} preserves Variant
|
|
50
|
-
: $ParseDeepVariantValue<
|
|
50
|
+
: $ParseDeepVariantValue<AfterKey> extends [infer V, `}${infer Remaining}`]
|
|
51
51
|
? [CreateIndexType<Key, V>, Remaining]
|
|
52
|
-
: VariantTypeError<`Invalid dictionary value type: ${
|
|
52
|
+
: VariantTypeError<`Invalid dictionary value type in: ${AfterKey}`>
|
|
53
53
|
: VariantTypeError<`Invalid dictionary key type: ${Key}`>
|
|
54
54
|
: VariantTypeError<`Invalid dictionary format: ${State}`>;
|
|
55
55
|
|
|
@@ -73,13 +73,13 @@ type $ParseDeepVariantTuple<State extends string, Memo extends any[] = []> =
|
|
|
73
73
|
type $ParseDeepVariantKeyValue<State extends string> =
|
|
74
74
|
string extends State
|
|
75
75
|
? VariantTypeError<"$ParseDeepVariantKeyValue: 'string' is not a supported type.">
|
|
76
|
-
: State extends `${infer Key}${infer
|
|
76
|
+
: State extends `${infer Key}${infer AfterKey}`
|
|
77
77
|
? Key extends 's' | 'o' | 'g' | 'n' | 'q' | 't' | 'd' | 'u' | 'i' | 'x' | 'y'
|
|
78
|
-
?
|
|
78
|
+
? AfterKey extends `v}${infer Remaining}`
|
|
79
79
|
? [[BasicTypeMap<Key>, Variant], Remaining] // Value remains Variant for 'v'
|
|
80
|
-
: $ParseDeepVariantValue<
|
|
80
|
+
: $ParseDeepVariantValue<AfterKey> extends [infer V, `}${infer Remaining}`]
|
|
81
81
|
? [[BasicTypeMap<Key>, V], Remaining]
|
|
82
|
-
: VariantTypeError<`Invalid key-value value type: ${
|
|
82
|
+
: VariantTypeError<`Invalid key-value value type in: ${AfterKey}`>
|
|
83
83
|
: VariantTypeError<`Invalid key-value key type: ${Key}`>
|
|
84
84
|
: VariantTypeError<`Invalid key-value format: ${State}`>;
|
|
85
85
|
|
|
@@ -236,8 +236,10 @@ type $SkipUntil<State extends string, Delimiter extends string, Depth extends nu
|
|
|
236
236
|
type $ParseShallowVariantDict<State extends string> =
|
|
237
237
|
string extends State
|
|
238
238
|
? VariantTypeError<"$ParseShallowVariantDict: 'string' is not a supported type.">
|
|
239
|
-
: State extends
|
|
240
|
-
?
|
|
239
|
+
: $SkipUntil<State, '}'> extends [infer Remaining]
|
|
240
|
+
? Remaining extends string
|
|
241
|
+
? [{ [key: string]: Variant }, Remaining]
|
|
242
|
+
: VariantTypeError<`Invalid dictionary format`>
|
|
241
243
|
: VariantTypeError<`Invalid dictionary format`>;
|
|
242
244
|
|
|
243
245
|
/**
|
|
@@ -246,8 +248,10 @@ type $ParseShallowVariantDict<State extends string> =
|
|
|
246
248
|
type $ParseShallowVariantKeyValue<State extends string> =
|
|
247
249
|
string extends State
|
|
248
250
|
? VariantTypeError<"$ParseShallowVariantKeyValue: 'string' is not a supported type.">
|
|
249
|
-
: State extends
|
|
250
|
-
?
|
|
251
|
+
: $SkipUntil<State, '}'> extends [infer Remaining]
|
|
252
|
+
? Remaining extends string
|
|
253
|
+
? [[any, Variant], Remaining]
|
|
254
|
+
: VariantTypeError<`Invalid key-value format`>
|
|
251
255
|
: VariantTypeError<`Invalid key-value format`>;
|
|
252
256
|
|
|
253
257
|
/**
|
|
@@ -275,7 +279,7 @@ type $ParseRecursiveVariantValue<State extends string> =
|
|
|
275
279
|
? Type extends 's' | 'o' | 'g' | 'b' | 'n' | 'q' | 't' | 'd' | 'u' | 'i' | 'x' | 'y' | 'h' | '?'
|
|
276
280
|
? [BasicTypeMap<Type>, Remaining]
|
|
277
281
|
: Type extends 'v'
|
|
278
|
-
? [
|
|
282
|
+
? [unknown, Remaining] // Variants are fully unpacked to unknown
|
|
279
283
|
// Container types
|
|
280
284
|
: Type extends '('
|
|
281
285
|
? $ParseRecursiveVariantTuple<Remaining>
|
|
@@ -320,13 +324,13 @@ type $ParseRecursiveVariantTuple<State extends string, Memo extends any[] = []>
|
|
|
320
324
|
type $ParseRecursiveVariantDict<State extends string> =
|
|
321
325
|
string extends State
|
|
322
326
|
? VariantTypeError<"$ParseRecursiveVariantDict: 'string' is not a supported type.">
|
|
323
|
-
: State extends `${infer Key}${infer
|
|
327
|
+
: State extends `${infer Key}${infer AfterKey}`
|
|
324
328
|
? Key extends 's' | 'o' | 'g' | 'n' | 'q' | 't' | 'd' | 'u' | 'i' | 'x' | 'y'
|
|
325
|
-
?
|
|
326
|
-
? [CreateIndexType<Key,
|
|
327
|
-
: $ParseRecursiveVariantValue<
|
|
329
|
+
? AfterKey extends `v}${infer Remaining}`
|
|
330
|
+
? [CreateIndexType<Key, unknown>, Remaining] // a{sv} becomes unknown when recursively unpacked
|
|
331
|
+
: $ParseRecursiveVariantValue<AfterKey> extends [infer V, `}${infer Remaining}`]
|
|
328
332
|
? [CreateIndexType<Key, V>, Remaining]
|
|
329
|
-
: VariantTypeError<`Invalid dictionary value type: ${
|
|
333
|
+
: VariantTypeError<`Invalid dictionary value type in: ${AfterKey}`>
|
|
330
334
|
: VariantTypeError<`Invalid dictionary key type: ${Key}`>
|
|
331
335
|
: VariantTypeError<`Invalid dictionary format: ${State}`>;
|
|
332
336
|
|
|
@@ -336,13 +340,13 @@ type $ParseRecursiveVariantDict<State extends string> =
|
|
|
336
340
|
type $ParseRecursiveVariantKeyValue<State extends string> =
|
|
337
341
|
string extends State
|
|
338
342
|
? VariantTypeError<"$ParseRecursiveVariantKeyValue: 'string' is not a supported type.">
|
|
339
|
-
: State extends `${infer Key}${infer
|
|
343
|
+
: State extends `${infer Key}${infer AfterKey}`
|
|
340
344
|
? Key extends 's' | 'o' | 'g' | 'n' | 'q' | 't' | 'd' | 'u' | 'i' | 'x' | 'y'
|
|
341
|
-
?
|
|
342
|
-
? [[BasicTypeMap<Key>,
|
|
343
|
-
: $ParseRecursiveVariantValue<
|
|
345
|
+
? AfterKey extends `v}${infer Remaining}`
|
|
346
|
+
? [[BasicTypeMap<Key>, unknown], Remaining] // Value is fully unpacked to unknown
|
|
347
|
+
: $ParseRecursiveVariantValue<AfterKey> extends [infer V, `}${infer Remaining}`]
|
|
344
348
|
? [[BasicTypeMap<Key>, V], Remaining]
|
|
345
|
-
: VariantTypeError<`Invalid key-value value type: ${
|
|
349
|
+
: VariantTypeError<`Invalid key-value value type in: ${AfterKey}`>
|
|
346
350
|
: VariantTypeError<`Invalid key-value key type: ${Key}`>
|
|
347
351
|
: VariantTypeError<`Invalid key-value format: ${State}`>;
|
|
348
352
|
|
|
@@ -416,9 +420,9 @@ type $ParseConstructorInputTuple<State extends string, Memo extends any[] = []>
|
|
|
416
420
|
type $ParseConstructorInputDict<State extends string> =
|
|
417
421
|
string extends State
|
|
418
422
|
? VariantTypeError<"Invalid dictionary state">
|
|
419
|
-
: State extends `${infer Key}${infer
|
|
423
|
+
: State extends `${infer Key}${infer AfterKey}`
|
|
420
424
|
? Key extends 's' | 'o' | 'g' | 'n' | 'q' | 't' | 'd' | 'u' | 'i' | 'x' | 'y'
|
|
421
|
-
? $ParseConstructorInputValue<
|
|
425
|
+
? $ParseConstructorInputValue<AfterKey> extends [infer V, `}${infer Remaining}`]
|
|
422
426
|
? [CreateIndexType<Key, V>, Remaining]
|
|
423
427
|
: VariantTypeError<`Invalid dictionary value type`>
|
|
424
428
|
: VariantTypeError<`Invalid dictionary key type`>
|
|
@@ -430,9 +434,9 @@ type $ParseConstructorInputDict<State extends string> =
|
|
|
430
434
|
type $ParseConstructorInputKeyValue<State extends string> =
|
|
431
435
|
string extends State
|
|
432
436
|
? VariantTypeError<"Invalid key-value state">
|
|
433
|
-
: State extends `${infer Key}${infer
|
|
437
|
+
: State extends `${infer Key}${infer AfterKey}`
|
|
434
438
|
? Key extends 's' | 'o' | 'g' | 'n' | 'q' | 't' | 'd' | 'u' | 'i' | 'x' | 'y'
|
|
435
|
-
? $ParseConstructorInputValue<
|
|
439
|
+
? $ParseConstructorInputValue<AfterKey> extends [infer V, `}${infer Remaining}`]
|
|
436
440
|
? [[BasicTypeMap<Key>, V], Remaining]
|
|
437
441
|
: VariantTypeError<`Invalid key-value value type`>
|
|
438
442
|
: VariantTypeError<`Invalid key-value key type`>
|
|
@@ -458,11 +462,18 @@ type $ParseVariant<T extends string> = $ParseShallowVariant<T>;
|
|
|
458
462
|
|
|
459
463
|
type $VariantTypeToString<T extends VariantType> = T extends VariantType<infer S> ? S : never;
|
|
460
464
|
|
|
461
|
-
type $ToTuple<T extends readonly
|
|
465
|
+
type $ToTuple<T extends readonly Variant[]> =
|
|
466
|
+
T extends [] ? '' :
|
|
467
|
+
T extends [Variant<infer S>] ? `${S}` :
|
|
468
|
+
T extends [Variant<infer S>, ...infer U] ? (
|
|
469
|
+
U extends [...Variant[]] ? `${S}${$ToTuple<U>}` : never) :
|
|
470
|
+
'?';
|
|
471
|
+
|
|
472
|
+
type $ToTupleVT<T extends readonly VariantType[]> =
|
|
462
473
|
T extends [] ? '' :
|
|
463
474
|
T extends [VariantType<infer S>] ? `${S}` :
|
|
464
475
|
T extends [VariantType<infer S>, ...infer U] ? (
|
|
465
|
-
U extends [...VariantType[]] ? `${S}${$
|
|
476
|
+
U extends [...VariantType[]] ? `${S}${$ToTupleVT<U>}` : never) :
|
|
466
477
|
'?';
|
|
467
478
|
|
|
468
479
|
type $ElementSig<E extends any> =
|
|
@@ -659,7 +670,7 @@ export class Variant<S extends string = any> {
|
|
|
659
670
|
*/
|
|
660
671
|
static new_strv(strv: string[]): Variant<'as'>;
|
|
661
672
|
|
|
662
|
-
static new_tuple<Items extends (ReadonlyArray<
|
|
673
|
+
static new_tuple<Items extends (ReadonlyArray<Variant> | readonly [Variant])>(children: Items): Variant<`(${$ToTuple<Items>})`>;
|
|
663
674
|
static new_uint16(value: number): Variant<'q'>;
|
|
664
675
|
|
|
665
676
|
/**
|
|
@@ -1093,7 +1104,7 @@ export class VariantType<S extends string = any> {
|
|
|
1093
1104
|
static new_array<S extends string>(element: VariantType<S>): VariantType<`a${S}`>;
|
|
1094
1105
|
static new_dict_entry<K extends string, V extends string>(key: VariantType<K>, value: VariantType<V>): VariantType<`{${K}${V}}`>;
|
|
1095
1106
|
static new_maybe<S extends string>(element: VariantType<S>): VariantType<`m${S}`>;
|
|
1096
|
-
static new_tuple<Items extends (ReadonlyArray<VariantType> | readonly [VariantType])>(items: Items): VariantType<`(${$
|
|
1107
|
+
static new_tuple<Items extends (ReadonlyArray<VariantType> | readonly [VariantType])>(items: Items): VariantType<`(${$ToTupleVT<Items>})`>;
|
|
1097
1108
|
// Members
|
|
1098
1109
|
copy(): VariantType<S>;
|
|
1099
1110
|
dup_string(): string;
|
|
@@ -12,13 +12,17 @@ export type GType<T = unknown> = {
|
|
|
12
12
|
name: string
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
// Accepts either a raw GType or a class constructor with $gtype property.
|
|
16
|
+
// Used in input positions where GJS automatically extracts $gtype from class constructors.
|
|
17
|
+
export type GTypeInput<T = unknown> = GType<T> | { $gtype: GType<T> }
|
|
18
|
+
|
|
15
19
|
// Extra interfaces used to help define GObject classes in js; these
|
|
16
20
|
// aren't part of gi.
|
|
17
21
|
export interface SignalDefinition {
|
|
18
22
|
flags?: SignalFlags
|
|
19
23
|
accumulator: number
|
|
20
|
-
return_type?:
|
|
21
|
-
param_types?:
|
|
24
|
+
return_type?: GTypeInput
|
|
25
|
+
param_types?: GTypeInput[]
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
export interface MetaInfo<Props, Interfaces, Sigs> {
|
|
@@ -104,7 +108,7 @@ export type RegisteredClass<
|
|
|
104
108
|
: never
|
|
105
109
|
|
|
106
110
|
export type SignalDefinitionType = {
|
|
107
|
-
param_types?: readonly
|
|
111
|
+
param_types?: readonly GTypeInput[]
|
|
108
112
|
[key: string]: any
|
|
109
113
|
}
|
|
110
114
|
<% } %>
|
|
@@ -326,7 +330,7 @@ export function registerClass<
|
|
|
326
330
|
Interfaces extends { $gtype: GType }[],
|
|
327
331
|
Sigs extends {
|
|
328
332
|
[key: string]: {
|
|
329
|
-
param_types?: readonly
|
|
333
|
+
param_types?: readonly GTypeInput[]
|
|
330
334
|
[key: string]: any
|
|
331
335
|
}
|
|
332
336
|
},
|
|
@@ -345,7 +349,7 @@ export function registerClass<
|
|
|
345
349
|
Interfaces extends { $gtype: GType }[],
|
|
346
350
|
Sigs extends {
|
|
347
351
|
[key: string]: {
|
|
348
|
-
param_types?: readonly
|
|
352
|
+
param_types?: readonly GTypeInput[]
|
|
349
353
|
[key: string]: any
|
|
350
354
|
}
|
|
351
355
|
},
|