@gtkx/gir 0.20.0 → 0.21.0
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/dist/index.d.ts +25 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -10
- package/dist/index.js.map +1 -1
- package/dist/internal/loader.d.ts +30 -0
- package/dist/internal/loader.d.ts.map +1 -0
- package/dist/internal/loader.js +109 -0
- package/dist/internal/loader.js.map +1 -0
- package/dist/internal/normalizer.d.ts +98 -15
- package/dist/internal/normalizer.d.ts.map +1 -1
- package/dist/internal/normalizer.js +381 -412
- package/dist/internal/normalizer.js.map +1 -1
- package/dist/internal/parser.d.ts +23 -31
- package/dist/internal/parser.d.ts.map +1 -1
- package/dist/internal/parser.js +228 -244
- package/dist/internal/parser.js.map +1 -1
- package/dist/internal/raw-types.d.ts +58 -109
- package/dist/internal/raw-types.d.ts.map +1 -1
- package/dist/internal/raw-types.js +0 -8
- package/dist/internal/raw-types.js.map +1 -1
- package/dist/intrinsics.d.ts.map +1 -1
- package/dist/intrinsics.js +7 -0
- package/dist/intrinsics.js.map +1 -1
- package/dist/model/alias.d.ts +21 -0
- package/dist/model/alias.d.ts.map +1 -0
- package/dist/model/alias.js +22 -0
- package/dist/model/alias.js.map +1 -0
- package/dist/model/callables.d.ts +102 -0
- package/dist/model/callables.d.ts.map +1 -0
- package/dist/model/callables.js +123 -0
- package/dist/model/callables.js.map +1 -0
- package/dist/model/callback.d.ts +22 -0
- package/dist/model/callback.d.ts.map +1 -0
- package/dist/model/callback.js +20 -0
- package/dist/model/callback.js.map +1 -0
- package/dist/model/class.d.ts +92 -0
- package/dist/model/class.d.ts.map +1 -0
- package/dist/model/class.js +171 -0
- package/dist/model/class.js.map +1 -0
- package/dist/model/constant.d.ts +21 -0
- package/dist/model/constant.d.ts.map +1 -0
- package/dist/model/constant.js +20 -0
- package/dist/model/constant.js.map +1 -0
- package/dist/model/enumeration.d.ts +41 -0
- package/dist/model/enumeration.d.ts.map +1 -0
- package/dist/model/enumeration.js +47 -0
- package/dist/model/enumeration.js.map +1 -0
- package/dist/model/field.d.ts +21 -0
- package/dist/model/field.d.ts.map +1 -0
- package/dist/model/field.js +20 -0
- package/dist/model/field.js.map +1 -0
- package/dist/model/interface.d.ts +44 -0
- package/dist/model/interface.d.ts.map +1 -0
- package/dist/model/interface.js +67 -0
- package/dist/model/interface.js.map +1 -0
- package/dist/model/namespace.d.ts +44 -0
- package/dist/model/namespace.d.ts.map +1 -0
- package/dist/model/namespace.js +36 -0
- package/dist/model/namespace.js.map +1 -0
- package/dist/model/parameter.d.ts +43 -0
- package/dist/model/parameter.d.ts.map +1 -0
- package/dist/model/parameter.js +54 -0
- package/dist/model/parameter.js.map +1 -0
- package/dist/model/property.d.ts +62 -0
- package/dist/model/property.d.ts.map +1 -0
- package/dist/model/property.js +69 -0
- package/dist/model/property.js.map +1 -0
- package/dist/model/record.d.ts +56 -0
- package/dist/model/record.d.ts.map +1 -0
- package/dist/model/record.js +70 -0
- package/dist/model/record.js.map +1 -0
- package/dist/model/repository-like.d.ts +19 -0
- package/dist/model/repository-like.d.ts.map +1 -0
- package/dist/model/repository-like.js +2 -0
- package/dist/model/repository-like.js.map +1 -0
- package/dist/model/signal.d.ts +22 -0
- package/dist/model/signal.d.ts.map +1 -0
- package/dist/model/signal.js +22 -0
- package/dist/model/signal.js.map +1 -0
- package/dist/model/type.d.ts +71 -0
- package/dist/model/type.d.ts.map +1 -0
- package/dist/model/type.js +112 -0
- package/dist/model/type.js.map +1 -0
- package/dist/repository.d.ts +92 -138
- package/dist/repository.d.ts.map +1 -1
- package/dist/repository.js +155 -219
- package/dist/repository.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +25 -39
- package/src/internal/loader.ts +127 -0
- package/src/internal/normalizer.ts +451 -475
- package/src/internal/parser.ts +242 -284
- package/src/internal/raw-types.ts +65 -116
- package/src/intrinsics.ts +7 -0
- package/src/model/alias.ts +31 -0
- package/src/model/callables.ts +172 -0
- package/src/model/callback.ts +30 -0
- package/src/model/class.ts +215 -0
- package/src/model/constant.ts +29 -0
- package/src/model/enumeration.ts +64 -0
- package/src/model/field.ts +29 -0
- package/src/model/interface.ts +89 -0
- package/src/model/namespace.ts +60 -0
- package/src/model/parameter.ts +74 -0
- package/src/model/property.ts +97 -0
- package/src/model/record.ts +97 -0
- package/src/model/repository-like.ts +20 -0
- package/src/model/signal.ts +32 -0
- package/src/model/type.ts +143 -0
- package/src/repository.ts +197 -283
- package/dist/types.d.ts +0 -655
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -879
- package/dist/types.js.map +0 -1
- package/src/types.ts +0 -1192
package/dist/repository.js
CHANGED
|
@@ -1,197 +1,179 @@
|
|
|
1
|
+
import { GirLoader } from "./internal/loader.js";
|
|
2
|
+
import { GirNormalizer } from "./internal/normalizer.js";
|
|
3
|
+
import { GirParser } from "./internal/parser.js";
|
|
4
|
+
import { isIntrinsicType } from "./intrinsics.js";
|
|
5
|
+
import { GirClass } from "./model/class.js";
|
|
6
|
+
import { GirInterface } from "./model/interface.js";
|
|
7
|
+
import { GirNamespace } from "./model/namespace.js";
|
|
1
8
|
/**
|
|
2
|
-
*
|
|
9
|
+
* Central registry for GIR data.
|
|
10
|
+
*
|
|
11
|
+
* Loads, resolves, and provides query access to GIR namespaces.
|
|
12
|
+
* All type references use fully qualified names (`Namespace.TypeName`).
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const repo = await GirRepository.load(["Gtk-4.0", "Adw-1"], {
|
|
17
|
+
* girPath: ["/usr/share/gir-1.0"]
|
|
18
|
+
* });
|
|
3
19
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
20
|
+
* const button = repo.resolveClass("Gtk.Button");
|
|
21
|
+
* button.isSubclassOf("Gtk.Widget"); // true
|
|
22
|
+
* button.getInheritanceChain();
|
|
23
|
+
* // ["Gtk.Button", "Gtk.Widget", "GObject.InitiallyUnowned", "GObject.Object"]
|
|
24
|
+
* ```
|
|
6
25
|
*/
|
|
7
|
-
import { readdir, readFile } from "node:fs/promises";
|
|
8
|
-
import { join } from "node:path";
|
|
9
|
-
import { normalizeNamespace } from "./internal/normalizer.js";
|
|
10
|
-
import { RawGirParser } from "./internal/parser.js";
|
|
11
|
-
import { isIntrinsicType } from "./intrinsics.js";
|
|
12
|
-
import { parseQualifiedName, } from "./types.js";
|
|
13
26
|
export class GirRepository {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
resolved = false;
|
|
18
|
-
constructor(options = {}) {
|
|
19
|
-
this.parser = new RawGirParser(options);
|
|
27
|
+
namespaces;
|
|
28
|
+
constructor(namespaces) {
|
|
29
|
+
this.namespaces = namespaces;
|
|
20
30
|
}
|
|
21
31
|
/**
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (existing && this.compareVersions(existing.version, raw.version) >= 0) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
this.rawNamespaces.set(raw.name, raw);
|
|
31
|
-
this.resolved = false;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Loads a GIR file from disk.
|
|
32
|
+
* Discovers all transitive dependencies for the given roots without
|
|
33
|
+
* performing a full parse. Returns namespace keys and their file paths.
|
|
34
|
+
*
|
|
35
|
+
* @param roots - Namespace keys to start from (e.g., `["Gtk-4.0", "Adw-1"]`)
|
|
36
|
+
* @param options - Search paths for GIR files
|
|
35
37
|
*/
|
|
36
|
-
async
|
|
37
|
-
const
|
|
38
|
-
|
|
38
|
+
static async discoverDependencies(roots, options) {
|
|
39
|
+
const loader = new GirLoader(options.girPath);
|
|
40
|
+
return loader.discoverDependencies(roots);
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
|
-
* Loads
|
|
43
|
+
* Loads GIR files for the given namespace roots and all their transitive
|
|
44
|
+
* dependencies, returning a fully resolved repository.
|
|
45
|
+
*
|
|
46
|
+
* @param roots - Namespace keys to load (e.g., `["Gtk-4.0", "Adw-1"]`)
|
|
47
|
+
* @param options - Search paths for GIR files
|
|
42
48
|
*/
|
|
43
|
-
async
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
49
|
+
static async load(roots, options) {
|
|
50
|
+
const loader = new GirLoader(options.girPath);
|
|
51
|
+
const loaded = await loader.loadAll(roots);
|
|
52
|
+
const rawNamespaces = new Map();
|
|
53
|
+
for (const [name, { raw }] of loaded) {
|
|
54
|
+
rawNamespaces.set(name, raw);
|
|
55
|
+
}
|
|
56
|
+
return GirRepository.buildFromRaw(rawNamespaces);
|
|
47
57
|
}
|
|
48
58
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
59
|
+
* Creates a repository from inline GIR XML strings.
|
|
60
|
+
* Useful for testing and scenarios where GIR data is already in memory.
|
|
51
61
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
for (const [name, raw] of this.rawNamespaces) {
|
|
59
|
-
const normalized = normalizeNamespace(raw, ctx);
|
|
60
|
-
this.normalizedNamespaces.set(name, normalized);
|
|
62
|
+
static fromXml(xmlStrings) {
|
|
63
|
+
const parser = new GirParser();
|
|
64
|
+
const rawNamespaces = new Map();
|
|
65
|
+
for (const xml of xmlStrings) {
|
|
66
|
+
const raw = parser.parseNamespace(xml);
|
|
67
|
+
rawNamespaces.set(raw.name, raw);
|
|
61
68
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
return GirRepository.buildFromRaw(rawNamespaces);
|
|
70
|
+
}
|
|
71
|
+
static buildFromRaw(rawNamespaces) {
|
|
72
|
+
const normalizer = new GirNormalizer();
|
|
73
|
+
const intermediates = normalizer.normalize(rawNamespaces);
|
|
74
|
+
return GirRepository.buildFromIntermediates(intermediates);
|
|
75
|
+
}
|
|
76
|
+
static buildFromIntermediates(intermediates) {
|
|
77
|
+
const namespaceMap = new Map();
|
|
78
|
+
const repo = new GirRepository(namespaceMap);
|
|
79
|
+
for (const [nsName, data] of intermediates) {
|
|
80
|
+
const classes = new Map();
|
|
81
|
+
for (const [name, classData] of data.classes) {
|
|
82
|
+
classes.set(name, new GirClass(classData, repo));
|
|
65
83
|
}
|
|
66
|
-
|
|
67
|
-
|
|
84
|
+
const interfaces = new Map();
|
|
85
|
+
for (const [name, ifaceData] of data.interfaces) {
|
|
86
|
+
interfaces.set(name, new GirInterface(ifaceData, repo));
|
|
68
87
|
}
|
|
88
|
+
namespaceMap.set(nsName, new GirNamespace({
|
|
89
|
+
name: data.name,
|
|
90
|
+
version: data.version,
|
|
91
|
+
sharedLibrary: data.sharedLibrary,
|
|
92
|
+
cPrefix: data.cPrefix,
|
|
93
|
+
classes,
|
|
94
|
+
interfaces,
|
|
95
|
+
records: data.records,
|
|
96
|
+
enumerations: data.enumerations,
|
|
97
|
+
bitfields: data.bitfields,
|
|
98
|
+
callbacks: data.callbacks,
|
|
99
|
+
functions: data.functions,
|
|
100
|
+
constants: data.constants,
|
|
101
|
+
aliases: data.aliases,
|
|
102
|
+
doc: data.doc,
|
|
103
|
+
}));
|
|
69
104
|
}
|
|
70
|
-
|
|
105
|
+
return repo;
|
|
71
106
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Gets all loaded namespace names.
|
|
74
|
-
*/
|
|
107
|
+
/** Gets all loaded namespace names. */
|
|
75
108
|
getNamespaceNames() {
|
|
76
|
-
this.
|
|
77
|
-
return [...this.normalizedNamespaces.keys()];
|
|
109
|
+
return [...this.namespaces.keys()];
|
|
78
110
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Gets a normalized namespace by name.
|
|
81
|
-
*/
|
|
111
|
+
/** Gets a namespace by name, or null if not loaded. */
|
|
82
112
|
getNamespace(name) {
|
|
83
|
-
this.
|
|
84
|
-
return this.normalizedNamespaces.get(name) ?? null;
|
|
113
|
+
return this.namespaces.get(name) ?? null;
|
|
85
114
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Gets all normalized namespaces.
|
|
88
|
-
*/
|
|
115
|
+
/** Gets all loaded namespaces. */
|
|
89
116
|
getAllNamespaces() {
|
|
90
|
-
this.
|
|
91
|
-
return this.normalizedNamespaces;
|
|
117
|
+
return this.namespaces;
|
|
92
118
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Resolves a class by qualified name.
|
|
95
|
-
* @example repo.resolveClass("Gtk.Button" as QualifiedName)
|
|
96
|
-
*/
|
|
119
|
+
/** Resolves a class by qualified name (e.g., `"Gtk.Button"`). */
|
|
97
120
|
resolveClass(qualifiedName) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return this.normalizedNamespaces.get(namespace)?.classes.get(name) ?? null;
|
|
121
|
+
const { namespace, name } = splitQualifiedName(qualifiedName);
|
|
122
|
+
return this.namespaces.get(namespace)?.classes.get(name) ?? null;
|
|
101
123
|
}
|
|
102
|
-
/**
|
|
103
|
-
* Resolves an interface by qualified name.
|
|
104
|
-
* @example repo.resolveInterface("Gio.ListModel" as QualifiedName)
|
|
105
|
-
*/
|
|
124
|
+
/** Resolves an interface by qualified name (e.g., `"Gio.ListModel"`). */
|
|
106
125
|
resolveInterface(qualifiedName) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return this.normalizedNamespaces.get(namespace)?.interfaces.get(name) ?? null;
|
|
126
|
+
const { namespace, name } = splitQualifiedName(qualifiedName);
|
|
127
|
+
return this.namespaces.get(namespace)?.interfaces.get(name) ?? null;
|
|
110
128
|
}
|
|
111
|
-
/**
|
|
112
|
-
* Resolves a record (boxed type) by qualified name.
|
|
113
|
-
* @example repo.resolveRecord("Gdk.Rectangle" as QualifiedName)
|
|
114
|
-
*/
|
|
129
|
+
/** Resolves a record by qualified name (e.g., `"Gdk.Rectangle"`). */
|
|
115
130
|
resolveRecord(qualifiedName) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return this.normalizedNamespaces.get(namespace)?.records.get(name) ?? null;
|
|
131
|
+
const { namespace, name } = splitQualifiedName(qualifiedName);
|
|
132
|
+
return this.namespaces.get(namespace)?.records.get(name) ?? null;
|
|
119
133
|
}
|
|
120
|
-
/**
|
|
121
|
-
* Resolves an enumeration by qualified name.
|
|
122
|
-
* @example repo.resolveEnum("Gtk.Orientation" as QualifiedName)
|
|
123
|
-
*/
|
|
134
|
+
/** Resolves an enumeration by qualified name (e.g., `"Gtk.Orientation"`). */
|
|
124
135
|
resolveEnum(qualifiedName) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return this.normalizedNamespaces.get(namespace)?.enumerations.get(name) ?? null;
|
|
136
|
+
const { namespace, name } = splitQualifiedName(qualifiedName);
|
|
137
|
+
return this.namespaces.get(namespace)?.enumerations.get(name) ?? null;
|
|
128
138
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Resolves a bitfield (flags) by qualified name.
|
|
131
|
-
* @example repo.resolveFlags("Gdk.ModifierType" as QualifiedName)
|
|
132
|
-
*/
|
|
139
|
+
/** Resolves a bitfield by qualified name (e.g., `"Gdk.ModifierType"`). */
|
|
133
140
|
resolveFlags(qualifiedName) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return this.normalizedNamespaces.get(namespace)?.bitfields.get(name) ?? null;
|
|
141
|
+
const { namespace, name } = splitQualifiedName(qualifiedName);
|
|
142
|
+
return this.namespaces.get(namespace)?.bitfields.get(name) ?? null;
|
|
137
143
|
}
|
|
138
|
-
/**
|
|
139
|
-
* Resolves a callback type by qualified name.
|
|
140
|
-
* @example repo.resolveCallback("Gio.AsyncReadyCallback" as QualifiedName)
|
|
141
|
-
*/
|
|
144
|
+
/** Resolves a callback by qualified name (e.g., `"Gio.AsyncReadyCallback"`). */
|
|
142
145
|
resolveCallback(qualifiedName) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return this.normalizedNamespaces.get(namespace)?.callbacks.get(name) ?? null;
|
|
146
|
+
const { namespace, name } = splitQualifiedName(qualifiedName);
|
|
147
|
+
return this.namespaces.get(namespace)?.callbacks.get(name) ?? null;
|
|
146
148
|
}
|
|
147
|
-
/**
|
|
148
|
-
* Resolves a constant by qualified name.
|
|
149
|
-
* @example repo.resolveConstant("Gtk.MAJOR_VERSION" as QualifiedName)
|
|
150
|
-
*/
|
|
149
|
+
/** Resolves a constant by qualified name (e.g., `"Gtk.MAJOR_VERSION"`). */
|
|
151
150
|
resolveConstant(qualifiedName) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return this.normalizedNamespaces.get(namespace)?.constants.get(name) ?? null;
|
|
151
|
+
const { namespace, name } = splitQualifiedName(qualifiedName);
|
|
152
|
+
return this.namespaces.get(namespace)?.constants.get(name) ?? null;
|
|
155
153
|
}
|
|
156
|
-
/**
|
|
157
|
-
* Resolves a standalone function by qualified name.
|
|
158
|
-
* @example repo.resolveFunction("Gtk.init" as QualifiedName)
|
|
159
|
-
*/
|
|
154
|
+
/** Resolves a standalone function by qualified name (e.g., `"Gtk.init"`). */
|
|
160
155
|
resolveFunction(qualifiedName) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return this.normalizedNamespaces.get(namespace)?.functions.get(name) ?? null;
|
|
156
|
+
const { namespace, name } = splitQualifiedName(qualifiedName);
|
|
157
|
+
return this.namespaces.get(namespace)?.functions.get(name) ?? null;
|
|
164
158
|
}
|
|
165
|
-
/**
|
|
166
|
-
* Resolves an alias by qualified name.
|
|
167
|
-
* @example repo.resolveAlias("Pango.LayoutRun" as QualifiedName)
|
|
168
|
-
*/
|
|
159
|
+
/** Resolves an alias by qualified name (e.g., `"Pango.LayoutRun"`). */
|
|
169
160
|
resolveAlias(qualifiedName) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return this.normalizedNamespaces.get(namespace)?.aliases.get(name) ?? null;
|
|
161
|
+
const { namespace, name } = splitQualifiedName(qualifiedName);
|
|
162
|
+
return this.namespaces.get(namespace)?.aliases.get(name) ?? null;
|
|
173
163
|
}
|
|
174
|
-
/**
|
|
175
|
-
* Resolves a type name through aliases to get the target type.
|
|
176
|
-
* If the type is an alias, returns the target type.
|
|
177
|
-
* If not an alias, returns null.
|
|
178
|
-
* @example repo.resolveTypeAlias("Pango.LayoutRun" as QualifiedName) // returns GirType pointing to Pango.GlyphItem
|
|
179
|
-
*/
|
|
164
|
+
/** Resolves a type alias to its target type, or null if not an alias. */
|
|
180
165
|
resolveTypeAlias(qualifiedName) {
|
|
181
|
-
|
|
182
|
-
return alias?.targetType ?? null;
|
|
166
|
+
return this.resolveAlias(qualifiedName)?.targetType ?? null;
|
|
183
167
|
}
|
|
184
168
|
/**
|
|
185
169
|
* Gets the kind of a type (class, interface, record, enum, flags, callback).
|
|
186
170
|
* Returns null for intrinsic types or unknown types.
|
|
187
171
|
*/
|
|
188
172
|
getTypeKind(qualifiedName) {
|
|
189
|
-
|
|
190
|
-
if (isIntrinsicType(qualifiedName)) {
|
|
173
|
+
if (isIntrinsicType(qualifiedName))
|
|
191
174
|
return null;
|
|
192
|
-
}
|
|
193
|
-
const
|
|
194
|
-
const ns = this.normalizedNamespaces.get(namespace);
|
|
175
|
+
const { namespace, name } = splitQualifiedName(qualifiedName);
|
|
176
|
+
const ns = this.namespaces.get(namespace);
|
|
195
177
|
if (!ns)
|
|
196
178
|
return null;
|
|
197
179
|
if (ns.classes.has(name))
|
|
@@ -208,32 +190,18 @@ export class GirRepository {
|
|
|
208
190
|
return "callback";
|
|
209
191
|
return null;
|
|
210
192
|
}
|
|
211
|
-
/**
|
|
212
|
-
* Gets the full inheritance chain for a class.
|
|
213
|
-
* Returns array from most derived to base.
|
|
214
|
-
*
|
|
215
|
-
* @example
|
|
216
|
-
* getInheritanceChain("Gtk.Button" as QualifiedName)
|
|
217
|
-
* // ["Gtk.Button", "Gtk.Widget", "GObject.InitiallyUnowned", "GObject.Object"]
|
|
218
|
-
*/
|
|
193
|
+
/** Gets the full inheritance chain for a class (most derived to base). */
|
|
219
194
|
getInheritanceChain(qualifiedName) {
|
|
220
|
-
|
|
221
|
-
return cls?.getInheritanceChain() ?? [];
|
|
195
|
+
return this.resolveClass(qualifiedName)?.getInheritanceChain() ?? [];
|
|
222
196
|
}
|
|
223
|
-
/**
|
|
224
|
-
* Gets all interfaces implemented by a class (including inherited).
|
|
225
|
-
*/
|
|
197
|
+
/** Gets all interfaces implemented by a class (including inherited). */
|
|
226
198
|
getImplementedInterfaces(qualifiedName) {
|
|
227
|
-
|
|
228
|
-
return cls?.getAllImplementedInterfaces() ?? [];
|
|
199
|
+
return this.resolveClass(qualifiedName)?.getAllImplementedInterfaces() ?? [];
|
|
229
200
|
}
|
|
230
|
-
/**
|
|
231
|
-
* Gets all classes that derive from a given class.
|
|
232
|
-
*/
|
|
201
|
+
/** Gets all classes that derive from a given class. */
|
|
233
202
|
getDerivedClasses(qualifiedName) {
|
|
234
|
-
this.ensureResolved();
|
|
235
203
|
const derived = [];
|
|
236
|
-
for (const ns of this.
|
|
204
|
+
for (const ns of this.namespaces.values()) {
|
|
237
205
|
for (const cls of ns.classes.values()) {
|
|
238
206
|
if (cls.qualifiedName !== qualifiedName && cls.isSubclassOf(qualifiedName)) {
|
|
239
207
|
derived.push(cls.qualifiedName);
|
|
@@ -242,13 +210,10 @@ export class GirRepository {
|
|
|
242
210
|
}
|
|
243
211
|
return derived;
|
|
244
212
|
}
|
|
245
|
-
/**
|
|
246
|
-
* Gets all classes that implement a given interface.
|
|
247
|
-
*/
|
|
213
|
+
/** Gets all classes that implement a given interface. */
|
|
248
214
|
getImplementors(interfaceName) {
|
|
249
|
-
this.ensureResolved();
|
|
250
215
|
const implementors = [];
|
|
251
|
-
for (const ns of this.
|
|
216
|
+
for (const ns of this.namespaces.values()) {
|
|
252
217
|
for (const cls of ns.classes.values()) {
|
|
253
218
|
if (cls.implementsInterface(interfaceName)) {
|
|
254
219
|
implementors.push(cls.qualifiedName);
|
|
@@ -257,86 +222,57 @@ export class GirRepository {
|
|
|
257
222
|
}
|
|
258
223
|
return implementors;
|
|
259
224
|
}
|
|
260
|
-
/**
|
|
261
|
-
* Checks if a type is a GObject (class with GType).
|
|
262
|
-
*/
|
|
225
|
+
/** Checks if a type is a GObject (class with GType). */
|
|
263
226
|
isGObject(qualifiedName) {
|
|
264
|
-
|
|
265
|
-
return cls?.hasGType() ?? false;
|
|
227
|
+
return this.resolveClass(qualifiedName)?.hasGType() ?? false;
|
|
266
228
|
}
|
|
267
|
-
/**
|
|
268
|
-
* Checks if a type is a boxed type (record with GType).
|
|
269
|
-
*/
|
|
229
|
+
/** Checks if a type is a boxed type (record with GType). */
|
|
270
230
|
isBoxed(qualifiedName) {
|
|
271
|
-
|
|
272
|
-
return record?.isBoxed() ?? false;
|
|
231
|
+
return this.resolveRecord(qualifiedName)?.isBoxed() ?? false;
|
|
273
232
|
}
|
|
274
|
-
/**
|
|
275
|
-
* Checks if a type is a primitive (intrinsic).
|
|
276
|
-
*/
|
|
233
|
+
/** Checks if a type is a primitive (intrinsic). */
|
|
277
234
|
isPrimitive(typeName) {
|
|
278
235
|
return isIntrinsicType(typeName);
|
|
279
236
|
}
|
|
280
|
-
/**
|
|
281
|
-
* Finds all classes matching a predicate across all namespaces.
|
|
282
|
-
*/
|
|
237
|
+
/** Finds all classes matching a predicate across all namespaces. */
|
|
283
238
|
findClasses(predicate) {
|
|
284
|
-
this.ensureResolved();
|
|
285
239
|
const results = [];
|
|
286
|
-
for (const ns of this.
|
|
240
|
+
for (const ns of this.namespaces.values()) {
|
|
287
241
|
for (const cls of ns.classes.values()) {
|
|
288
|
-
if (predicate(cls))
|
|
242
|
+
if (predicate(cls))
|
|
289
243
|
results.push(cls);
|
|
290
|
-
}
|
|
291
244
|
}
|
|
292
245
|
}
|
|
293
246
|
return results;
|
|
294
247
|
}
|
|
295
|
-
/**
|
|
296
|
-
* Finds all interfaces matching a predicate across all namespaces.
|
|
297
|
-
*/
|
|
248
|
+
/** Finds all interfaces matching a predicate across all namespaces. */
|
|
298
249
|
findInterfaces(predicate) {
|
|
299
|
-
this.ensureResolved();
|
|
300
250
|
const results = [];
|
|
301
|
-
for (const ns of this.
|
|
251
|
+
for (const ns of this.namespaces.values()) {
|
|
302
252
|
for (const iface of ns.interfaces.values()) {
|
|
303
|
-
if (predicate(iface))
|
|
253
|
+
if (predicate(iface))
|
|
304
254
|
results.push(iface);
|
|
305
|
-
}
|
|
306
255
|
}
|
|
307
256
|
}
|
|
308
257
|
return results;
|
|
309
258
|
}
|
|
310
|
-
/**
|
|
311
|
-
* Finds all records matching a predicate across all namespaces.
|
|
312
|
-
*/
|
|
259
|
+
/** Finds all records matching a predicate across all namespaces. */
|
|
313
260
|
findRecords(predicate) {
|
|
314
|
-
this.ensureResolved();
|
|
315
261
|
const results = [];
|
|
316
|
-
for (const ns of this.
|
|
262
|
+
for (const ns of this.namespaces.values()) {
|
|
317
263
|
for (const record of ns.records.values()) {
|
|
318
|
-
if (predicate(record))
|
|
264
|
+
if (predicate(record))
|
|
319
265
|
results.push(record);
|
|
320
|
-
}
|
|
321
266
|
}
|
|
322
267
|
}
|
|
323
268
|
return results;
|
|
324
269
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
return diff;
|
|
333
|
-
}
|
|
334
|
-
return 0;
|
|
335
|
-
}
|
|
336
|
-
ensureResolved() {
|
|
337
|
-
if (!this.resolved) {
|
|
338
|
-
throw new Error("GirRepository.resolve() must be called before querying. Call resolve() after loading all GIR files.");
|
|
339
|
-
}
|
|
340
|
-
}
|
|
270
|
+
}
|
|
271
|
+
function splitQualifiedName(qn) {
|
|
272
|
+
const dot = qn.indexOf(".");
|
|
273
|
+
return {
|
|
274
|
+
namespace: qn.slice(0, dot),
|
|
275
|
+
name: qn.slice(dot + 1),
|
|
276
|
+
};
|
|
341
277
|
}
|
|
342
278
|
//# sourceMappingURL=repository.js.map
|
package/dist/repository.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIlD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAkBpD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,aAAa;IACL,UAAU,CAA4B;IAEvD,YAAoB,UAAqC;QACrD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,KAAe,EAAE,OAA0B;QACzE,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAe,EAAE,OAA0B;QACzD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAE3C,MAAM,aAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;QACtD,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC;YACnC,aAAa,CAAC,GAAG,CAAC,I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,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/gir",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "GObject Introspection file parser for GTKX",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"src"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"fast-xml-parser": "^5.
|
|
40
|
+
"fast-xml-parser": "^5.5.9"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "tsc -b tsconfig.lib.json",
|
package/src/index.ts
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @gtkx/gir - GObject Introspection Repository
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Parses GIR files and exposes a fully queryable registry of namespaces
|
|
5
|
+
* with resolved type references.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
9
|
* import { GirRepository } from "@gtkx/gir";
|
|
10
10
|
*
|
|
11
|
-
* const repo =
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* const repo = await GirRepository.load(["Gtk-4.0"], {
|
|
12
|
+
* girPath: ["/usr/share/gir-1.0"]
|
|
13
|
+
* });
|
|
14
14
|
*
|
|
15
|
-
* const button = repo.resolveClass("Gtk.Button"
|
|
16
|
-
* button.isSubclassOf("Gtk.Widget"
|
|
17
|
-
* button.getInheritanceChain();
|
|
18
|
-
* // ["Gtk.Button", "Gtk.Widget", "GObject.InitiallyUnowned", "GObject.Object"]
|
|
15
|
+
* const button = repo.resolveClass("Gtk.Button");
|
|
16
|
+
* button.isSubclassOf("Gtk.Widget"); // true
|
|
19
17
|
* ```
|
|
20
18
|
*
|
|
21
19
|
* @packageDocumentation
|
|
@@ -31,34 +29,22 @@ export {
|
|
|
31
29
|
STRING_TYPES,
|
|
32
30
|
VOID_TYPES,
|
|
33
31
|
} from "./intrinsics.js";
|
|
34
|
-
export {
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
} from "./
|
|
41
|
-
export {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
GirMethod,
|
|
53
|
-
GirNamespace,
|
|
54
|
-
GirParameter,
|
|
55
|
-
GirProperty,
|
|
56
|
-
GirRecord,
|
|
57
|
-
GirSignal,
|
|
58
|
-
GirType,
|
|
59
|
-
parseDefaultValue,
|
|
60
|
-
parseQualifiedName,
|
|
61
|
-
qualifiedName,
|
|
62
|
-
} from "./types.js";
|
|
63
|
-
|
|
32
|
+
export { GirAlias } from "./model/alias.js";
|
|
33
|
+
export { GirConstructor, GirFunction, GirMethod } from "./model/callables.js";
|
|
34
|
+
export { GirCallback } from "./model/callback.js";
|
|
35
|
+
export { GirClass } from "./model/class.js";
|
|
36
|
+
export { GirConstant } from "./model/constant.js";
|
|
37
|
+
export { GirEnumeration, GirEnumerationMember } from "./model/enumeration.js";
|
|
38
|
+
export { GirField } from "./model/field.js";
|
|
39
|
+
export { GirInterface } from "./model/interface.js";
|
|
40
|
+
export { GirNamespace } from "./model/namespace.js";
|
|
41
|
+
export { GirParameter } from "./model/parameter.js";
|
|
42
|
+
export type { DefaultValue } from "./model/property.js";
|
|
43
|
+
export { GirProperty, parseDefaultValue } from "./model/property.js";
|
|
44
|
+
export { GirRecord } from "./model/record.js";
|
|
45
|
+
export type { RepositoryLike, TypeKind } from "./model/repository-like.js";
|
|
46
|
+
export { GirSignal } from "./model/signal.js";
|
|
47
|
+
export type { ContainerType } from "./model/type.js";
|
|
48
|
+
export { GirType } from "./model/type.js";
|
|
49
|
+
export { type DependencyGraph, GirRepository, type RepositoryOptions } from "./repository.js";
|
|
64
50
|
export { toCamelCase, toPascalCase } from "./utils.js";
|