@ts-for-gir/lib 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 +7 -7
- package/src/generics/clutter.ts +3 -2
- package/src/generics/meta.ts +3 -2
- package/src/generics/st.ts +3 -2
- package/src/gir/introspected-classes.ts +28 -0
- package/src/injections/gobject.ts +1 -1
- package/src/injections/shell.ts +3 -2
- package/src/utils/girs.ts +1 -2
- package/src/validators/class.ts +12 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-for-gir/lib",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.44",
|
|
4
4
|
"description": "Typescript .d.ts generator from GIR for gjs",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "src/index.ts",
|
|
@@ -41,20 +41,20 @@
|
|
|
41
41
|
"type definitions"
|
|
42
42
|
],
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@ts-for-gir/tsconfig": "^4.0.0-beta.
|
|
44
|
+
"@ts-for-gir/tsconfig": "^4.0.0-beta.44",
|
|
45
45
|
"@types/ejs": "^3.1.5",
|
|
46
46
|
"@types/lodash": "^4.17.24",
|
|
47
47
|
"@types/node": "^24.12.0",
|
|
48
48
|
"rimraf": "^6.1.3",
|
|
49
|
-
"typescript": "^
|
|
49
|
+
"typescript": "^6.0.2"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@gi.ts/parser": "^4.0.0-beta.
|
|
53
|
-
"@ts-for-gir/reporter": "^4.0.0-beta.
|
|
54
|
-
"@ts-for-gir/templates": "^4.0.0-beta.
|
|
52
|
+
"@gi.ts/parser": "^4.0.0-beta.44",
|
|
53
|
+
"@ts-for-gir/reporter": "^4.0.0-beta.44",
|
|
54
|
+
"@ts-for-gir/templates": "^4.0.0-beta.44",
|
|
55
55
|
"colorette": "^2.0.20",
|
|
56
56
|
"ejs": "^5.0.1",
|
|
57
57
|
"glob": "^13.0.6",
|
|
58
|
-
"lodash": "
|
|
58
|
+
"lodash": "4.17.21"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/src/generics/clutter.ts
CHANGED
|
@@ -66,7 +66,7 @@ export const clutter10 = createClutterTemplate("10");
|
|
|
66
66
|
export const clutter11 = createClutterTemplate("11");
|
|
67
67
|
export const clutter12 = createClutterTemplate("12");
|
|
68
68
|
export const clutter13 = createClutterTemplate("13");
|
|
69
|
-
/** Clutter-14 was introduced with GNOME
|
|
69
|
+
/** Clutter-14 was introduced with GNOME 46 */
|
|
70
70
|
export const clutter14 = createClutterTemplate("14");
|
|
71
71
|
/** Clutter-15 was introduced with GNOME 47 */
|
|
72
72
|
export const clutter15 = createClutterTemplate("15");
|
|
@@ -74,7 +74,8 @@ export const clutter15 = createClutterTemplate("15");
|
|
|
74
74
|
export const clutter16 = createClutterTemplate("16");
|
|
75
75
|
/** Clutter-17 was introduced with GNOME 49 */
|
|
76
76
|
export const clutter17 = createClutterTemplate("17");
|
|
77
|
-
|
|
77
|
+
/** Clutter-18 was introduced with GNOME 50 */
|
|
78
78
|
export const clutter18 = createClutterTemplate("18");
|
|
79
|
+
// Possibly future versions, adjust if necessary
|
|
79
80
|
export const clutter19 = createClutterTemplate("19");
|
|
80
81
|
export const clutter20 = createClutterTemplate("20");
|
package/src/generics/meta.ts
CHANGED
|
@@ -36,7 +36,7 @@ export const meta10 = createMetaTemplate("10");
|
|
|
36
36
|
export const meta11 = createMetaTemplate("11");
|
|
37
37
|
export const meta12 = createMetaTemplate("12");
|
|
38
38
|
export const meta13 = createMetaTemplate("13");
|
|
39
|
-
/** Meta-14 was introduced with GNOME
|
|
39
|
+
/** Meta-14 was introduced with GNOME 46 */
|
|
40
40
|
export const meta14 = createMetaTemplate("14");
|
|
41
41
|
/** Meta-15 was introduced with GNOME 47 */
|
|
42
42
|
export const meta15 = createMetaTemplate("15");
|
|
@@ -44,7 +44,8 @@ export const meta15 = createMetaTemplate("15");
|
|
|
44
44
|
export const meta16 = createMetaTemplate("16");
|
|
45
45
|
/** Meta-17 was introduced with GNOME 49 */
|
|
46
46
|
export const meta17 = createMetaTemplate("17");
|
|
47
|
-
|
|
47
|
+
/** Meta-18 was introduced with GNOME 50 */
|
|
48
48
|
export const meta18 = createMetaTemplate("18");
|
|
49
|
+
// Possibly future versions, adjust if necessary
|
|
49
50
|
export const meta19 = createMetaTemplate("19");
|
|
50
51
|
export const meta20 = createMetaTemplate("20");
|
package/src/generics/st.ts
CHANGED
|
@@ -192,7 +192,7 @@ function updatePropertyType(
|
|
|
192
192
|
export const st1 = createStTemplate("1.0");
|
|
193
193
|
export const st12 = createStTemplate("12");
|
|
194
194
|
export const st13 = createStTemplate("13");
|
|
195
|
-
/** St-14 was introduced with GNOME
|
|
195
|
+
/** St-14 was introduced with GNOME 46 */
|
|
196
196
|
export const st14 = createStTemplate("14");
|
|
197
197
|
/** St-15 was introduced with GNOME 47 */
|
|
198
198
|
export const st15 = createStTemplate("15");
|
|
@@ -200,7 +200,8 @@ export const st15 = createStTemplate("15");
|
|
|
200
200
|
export const st16 = createStTemplate("16");
|
|
201
201
|
/** St-17 was introduced with GNOME 49 */
|
|
202
202
|
export const st17 = createStTemplate("17");
|
|
203
|
-
|
|
203
|
+
/** St-18 was introduced with GNOME 50 */
|
|
204
204
|
export const st18 = createStTemplate("18");
|
|
205
|
+
// Possibly future versions, adjust if necessary
|
|
205
206
|
export const st19 = createStTemplate("19");
|
|
206
207
|
export const st20 = createStTemplate("20");
|
|
@@ -55,6 +55,7 @@ export interface SignalDescriptor {
|
|
|
55
55
|
signal?: IntrospectedSignal;
|
|
56
56
|
isNotifySignal?: boolean;
|
|
57
57
|
isDetailSignal?: boolean;
|
|
58
|
+
isTemplateLiteral?: boolean;
|
|
58
59
|
parameterTypes?: string[];
|
|
59
60
|
returnType?: string;
|
|
60
61
|
}
|
|
@@ -663,6 +664,19 @@ export class IntrospectedClass extends IntrospectedBaseClass {
|
|
|
663
664
|
returnType: "void",
|
|
664
665
|
});
|
|
665
666
|
});
|
|
667
|
+
|
|
668
|
+
// Add template literal catch-all for arbitrary property names.
|
|
669
|
+
// Only on GObject.Object itself — children inherit it via SignalSignatures extends.
|
|
670
|
+
if (this.isGObjectObject()) {
|
|
671
|
+
allSignals.push({
|
|
672
|
+
name: `notify::\${string}`,
|
|
673
|
+
isNotifySignal: true,
|
|
674
|
+
isDetailSignal: false,
|
|
675
|
+
isTemplateLiteral: true,
|
|
676
|
+
parameterTypes: ["GObject.ParamSpec"],
|
|
677
|
+
returnType: "void",
|
|
678
|
+
});
|
|
679
|
+
}
|
|
666
680
|
}
|
|
667
681
|
|
|
668
682
|
private addDetailedSignals(allSignals: SignalDescriptor[]): void {
|
|
@@ -670,6 +684,9 @@ export class IntrospectedClass extends IntrospectedBaseClass {
|
|
|
670
684
|
|
|
671
685
|
this.signals.forEach((signal) => {
|
|
672
686
|
if (signal.detailed) {
|
|
687
|
+
// Skip "notify" signal — already handled by addNotifySignals
|
|
688
|
+
if (signal.name === "notify") return;
|
|
689
|
+
|
|
673
690
|
propertyNames.forEach((propertyName) => {
|
|
674
691
|
allSignals.push({
|
|
675
692
|
name: `${signal.name}::${propertyName}`,
|
|
@@ -680,6 +697,17 @@ export class IntrospectedClass extends IntrospectedBaseClass {
|
|
|
680
697
|
returnType: this.getPropertyTypeString(signal.return_type),
|
|
681
698
|
});
|
|
682
699
|
});
|
|
700
|
+
|
|
701
|
+
// Add template literal catch-all for arbitrary detail strings
|
|
702
|
+
allSignals.push({
|
|
703
|
+
name: `${signal.name}::\${string}`,
|
|
704
|
+
signal: signal,
|
|
705
|
+
isNotifySignal: false,
|
|
706
|
+
isDetailSignal: true,
|
|
707
|
+
isTemplateLiteral: true,
|
|
708
|
+
parameterTypes: signal.parameters.map((p) => this.getPropertyTypeString(p.type)),
|
|
709
|
+
returnType: this.getPropertyTypeString(signal.return_type),
|
|
710
|
+
});
|
|
683
711
|
}
|
|
684
712
|
});
|
|
685
713
|
}
|
|
@@ -292,7 +292,7 @@ See https://gjs.guide/guides/gobject/basics.html#properties for more details.`;
|
|
|
292
292
|
const override = new IntrospectedClassFunction({
|
|
293
293
|
parent: ParamSpec,
|
|
294
294
|
name: "override",
|
|
295
|
-
return_type:
|
|
295
|
+
return_type: ParamSpec.getType(),
|
|
296
296
|
parameters: [
|
|
297
297
|
new IntrospectedFunctionParameter({
|
|
298
298
|
direction: GirDirection.In,
|
package/src/injections/shell.ts
CHANGED
|
@@ -35,7 +35,7 @@ const shellTemplate = (version: string) => ({
|
|
|
35
35
|
},
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
/** Shell 14 was introduced with GNOME
|
|
38
|
+
/** Shell 14 was introduced with GNOME 46 */
|
|
39
39
|
export const shell14 = shellTemplate("14");
|
|
40
40
|
/** Shell 15 was introduced with GNOME 47 */
|
|
41
41
|
export const shell15 = shellTemplate("15");
|
|
@@ -43,7 +43,8 @@ export const shell15 = shellTemplate("15");
|
|
|
43
43
|
export const shell16 = shellTemplate("16");
|
|
44
44
|
/** Shell 17 was introduced with GNOME 49 */
|
|
45
45
|
export const shell17 = shellTemplate("17");
|
|
46
|
-
|
|
46
|
+
/** Shell 18 was introduced with GNOME 50 */
|
|
47
47
|
export const shell18 = shellTemplate("18");
|
|
48
|
+
// Possibly future versions, adjust if necessary
|
|
48
49
|
export const shell19 = shellTemplate("19");
|
|
49
50
|
export const shell20 = shellTemplate("20");
|
package/src/utils/girs.ts
CHANGED
|
@@ -106,8 +106,7 @@ export const printGirDocComment = (tsDoc: TsDoc, config: { noComments: boolean }
|
|
|
106
106
|
return desc.join("\n");
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
export const isIntrospectable = (e: { $?: GirInfoAttrs }) =>
|
|
110
|
-
!e || !e.$ || !e.$.introspectable || e.$.introspectable === "1";
|
|
109
|
+
export const isIntrospectable = (e: { $?: GirInfoAttrs }) => !e?.$?.introspectable || e.$.introspectable === "1";
|
|
111
110
|
export const isDeprecated = (e: { $: GirInfoAttrs }) => e?.$ && e.$.deprecated === "1";
|
|
112
111
|
export const deprecatedVersion = (e: { $: GirInfoAttrs }) => e?.$?.["deprecated-version"];
|
|
113
112
|
export const introducedVersion = (e: { $: GirInfoAttrs }) => e?.$?.version;
|
package/src/validators/class.ts
CHANGED
|
@@ -7,12 +7,23 @@ import { AnyType, NativeType, TypeIdentifier } from "../gir.ts";
|
|
|
7
7
|
import { resolveTypeIdentifier } from "../utils/type-resolution.ts";
|
|
8
8
|
import { GirVisitor } from "../visitor.ts";
|
|
9
9
|
|
|
10
|
+
// These methods are often marked introspectable="0" in GIR because the C signatures
|
|
11
|
+
// involve gpointer types, but GJS exposes them at runtime regardless. Their signatures are
|
|
12
|
+
// always trivial (no params, return self or void) so they are safe to keep.
|
|
13
|
+
// Only exempt on records — classes have deep inheritance hierarchies where return types
|
|
14
|
+
// at different levels conflict (e.g. GObject.Object.ref() vs Gtk.Widget.ref()).
|
|
15
|
+
const INTROSPECTABLE_EXEMPT_METHODS = new Set(["ref", "unref", "copy", "free", "destroy"]);
|
|
16
|
+
|
|
10
17
|
const filterIntrospectableClassMembers = <T extends IntrospectedBaseClass>(node: T): T => {
|
|
11
18
|
node.fields = node.fields.filter((field) => field.isIntrospectable);
|
|
12
19
|
node.props = node.props.filter((prop) => prop.isIntrospectable);
|
|
13
20
|
node.callbacks = node.callbacks.filter((prop) => prop.isIntrospectable);
|
|
14
21
|
node.constructors = node.constructors.filter((prop) => prop.isIntrospectable);
|
|
15
|
-
|
|
22
|
+
|
|
23
|
+
const isRecord = node instanceof IntrospectedRecord;
|
|
24
|
+
node.members = node.members.filter(
|
|
25
|
+
(member) => member.isIntrospectable || (isRecord && INTROSPECTABLE_EXEMPT_METHODS.has(member.name)),
|
|
26
|
+
);
|
|
16
27
|
|
|
17
28
|
return node;
|
|
18
29
|
};
|