@ts-for-gir/templates 4.0.0-rc.9 → 4.0.1
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
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
2
|
+
"name": "@ts-for-gir/templates",
|
|
3
|
+
"version": "4.0.1",
|
|
4
|
+
"description": "Templates for ts-for-gir",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "package.json",
|
|
7
|
+
"module": "package.json",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/gjsify/ts-for-gir.git"
|
|
14
|
+
},
|
|
15
|
+
"author": "Pascal Garber <pascal@mailfreun.de>",
|
|
16
|
+
"files": [
|
|
17
|
+
"templates"
|
|
18
|
+
],
|
|
19
|
+
"license": "Apache-2.0",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/gjsify/ts-for-gir/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/gjsify/ts-for-gir#readme"
|
|
24
|
+
}
|
|
@@ -41,29 +41,17 @@ export interface MetaInfo<Props, Interfaces, Sigs> {
|
|
|
41
41
|
export type Property<K extends ParamSpec> = K extends ParamSpec<infer T> ? T : any
|
|
42
42
|
|
|
43
43
|
<%_ if (!noAdvancedVariants) { _%>
|
|
44
|
-
// Advanced type inference for GObject class registration
|
|
45
|
-
//
|
|
44
|
+
// Advanced type inference for GObject class registration.
|
|
45
|
+
// Convert kebab-case property names (e.g. "my-prop") to snake_case
|
|
46
|
+
// ("my_prop"). GJS exposes registered properties on the JS side as
|
|
47
|
+
// snake_case (and via `get_property('kebab-name')`), so we only alias to
|
|
48
|
+
// that form; camelCase aliases would not match anything at runtime.
|
|
46
49
|
type SnakeToUnderscoreCase<S extends string> = S extends `${infer T}-${infer U}`
|
|
47
50
|
? `${T}_${SnakeToUnderscoreCase<U>}`
|
|
48
51
|
: S extends `${infer T}`
|
|
49
52
|
? `${T}`
|
|
50
53
|
: never
|
|
51
54
|
|
|
52
|
-
type SnakeToCamelCase<S extends string> = S extends `${infer T}-${infer U}`
|
|
53
|
-
? `${Lowercase<T>}${SnakeToPascalCase<U>}`
|
|
54
|
-
: S extends `${infer T}`
|
|
55
|
-
? `${Lowercase<T>}`
|
|
56
|
-
: SnakeToPascalCase<S>
|
|
57
|
-
|
|
58
|
-
type SnakeToPascalCase<S extends string> = string extends S
|
|
59
|
-
? string
|
|
60
|
-
: S extends `${infer T}-${infer U}`
|
|
61
|
-
? `${Capitalize<Lowercase<T>>}${SnakeToPascalCase<U>}`
|
|
62
|
-
: S extends `${infer T}`
|
|
63
|
-
? `${Capitalize<Lowercase<T>>}`
|
|
64
|
-
: never
|
|
65
|
-
|
|
66
|
-
type SnakeToCamel<T> = { [P in keyof T as P extends string ? SnakeToCamelCase<P> : P]: T[P] }
|
|
67
55
|
type SnakeToUnderscore<T> = { [P in keyof T as P extends string ? SnakeToUnderscoreCase<P> : P]: T[P] }
|
|
68
56
|
|
|
69
57
|
// Advanced utility types for class registration
|
|
@@ -88,7 +76,7 @@ export type RegisteredPrototype<
|
|
|
88
76
|
P extends {},
|
|
89
77
|
Props extends { [key: string]: ParamSpec },
|
|
90
78
|
Interfaces extends any[],
|
|
91
|
-
> = Properties<P,
|
|
79
|
+
> = Properties<P, SnakeToUnderscore<Props>> & UnionToIntersection<Interfaces[number]> & P
|
|
92
80
|
|
|
93
81
|
type Ctor = new (...a: any[]) => object
|
|
94
82
|
type Init = { _init(...args: any[]): void }
|
|
@@ -319,9 +307,12 @@ export type SignalCallback<Emitter, Fn> = Fn extends (...args: infer P) => infer
|
|
|
319
307
|
// TODO: What about the generated class Closure
|
|
320
308
|
export type TClosure<R = any, P = any> = (...args: P[]) => R
|
|
321
309
|
|
|
310
|
+
<%_ if (noAdvancedVariants) { _%>
|
|
311
|
+
// Fallback registerClass overloads — used when advanced variants are
|
|
312
|
+
// disabled. The class type is returned unchanged: callers are expected to
|
|
313
|
+
// declare property/signal types manually on their class body.
|
|
322
314
|
type ObjectConstructor = { new (...args: any[]): Object }
|
|
323
315
|
|
|
324
|
-
// Standard registerClass overloads
|
|
325
316
|
export function registerClass<T extends ObjectConstructor>(cls: T): T
|
|
326
317
|
|
|
327
318
|
export function registerClass<
|
|
@@ -335,9 +326,18 @@ export function registerClass<
|
|
|
335
326
|
}
|
|
336
327
|
},
|
|
337
328
|
>(options: MetaInfo<Props, Interfaces, Sigs>, cls: T): T
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
//
|
|
329
|
+
<%_ } else { _%>
|
|
330
|
+
// Enhanced registerClass overloads with advanced type inference. Previously
|
|
331
|
+
// shadowed by the standard overloads above, which matched any class
|
|
332
|
+
// extending GObject.Object via `T extends ObjectConstructor` and returned
|
|
333
|
+
// the class type unchanged — making the enhanced inference unreachable.
|
|
334
|
+
// The two overload sets are now mutually exclusive on the `noAdvancedVariants`
|
|
335
|
+
// flag.
|
|
336
|
+
//
|
|
337
|
+
// When the return value is captured (`const Foo = GObject.registerClass(...)`),
|
|
338
|
+
// the resulting class carries inferred property types via RegisteredPrototype.
|
|
339
|
+
// The idiomatic `static { GObject.registerClass(...) }` pattern discards the
|
|
340
|
+
// return and is unaffected.
|
|
341
341
|
|
|
342
342
|
export function registerClass<P extends {}, T extends new (...args: any[]) => P>(
|
|
343
343
|
klass: T,
|
|
@@ -354,17 +354,7 @@ export function registerClass<
|
|
|
354
354
|
}
|
|
355
355
|
},
|
|
356
356
|
>(
|
|
357
|
-
options:
|
|
358
|
-
GTypeName?: string
|
|
359
|
-
GTypeFlags?: TypeFlags
|
|
360
|
-
Properties?: Props
|
|
361
|
-
Signals?: Sigs
|
|
362
|
-
Implements?: Interfaces
|
|
363
|
-
CssName?: string
|
|
364
|
-
Template?: string
|
|
365
|
-
Children?: string[]
|
|
366
|
-
InternalChildren?: string[]
|
|
367
|
-
},
|
|
357
|
+
options: MetaInfo<Props, Interfaces, Sigs>,
|
|
368
358
|
klass: T,
|
|
369
359
|
): RegisteredClass<T, Props, Interfaces>
|
|
370
360
|
<%_ } _%>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// Workaround
|
|
3
3
|
/** @ignore */
|
|
4
|
-
export
|
|
4
|
+
export namespace GraniteServicesSettingsSerializable {
|
|
5
5
|
export interface ConstructorProps extends ServicesSettingsSerializable.ConstructorProps {}
|
|
6
6
|
}
|
|
7
7
|
/** @ignore */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// Workaround
|
|
3
3
|
/** @ignore */
|
|
4
|
-
export
|
|
4
|
+
export namespace GraniteServicesSettingsSerializable {
|
|
5
5
|
export interface ConstructorProps extends ServicesSettingsSerializable.ConstructorProps {}
|
|
6
6
|
}
|
|
7
7
|
/** @ignore */
|