@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/index.d.ts
CHANGED
|
@@ -1,28 +1,41 @@
|
|
|
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
|
|
22
20
|
*/
|
|
23
21
|
export { INTRINSIC_TYPES, isIntrinsicType, isNumericType, isStringType, isVoidType, NUMERIC_TYPES, STRING_TYPES, VOID_TYPES, } from "./intrinsics.js";
|
|
24
|
-
export {
|
|
25
|
-
export
|
|
26
|
-
export {
|
|
22
|
+
export { GirAlias } from "./model/alias.js";
|
|
23
|
+
export { GirConstructor, GirFunction, GirMethod } from "./model/callables.js";
|
|
24
|
+
export { GirCallback } from "./model/callback.js";
|
|
25
|
+
export { GirClass } from "./model/class.js";
|
|
26
|
+
export { GirConstant } from "./model/constant.js";
|
|
27
|
+
export { GirEnumeration, GirEnumerationMember } from "./model/enumeration.js";
|
|
28
|
+
export { GirField } from "./model/field.js";
|
|
29
|
+
export { GirInterface } from "./model/interface.js";
|
|
30
|
+
export { GirNamespace } from "./model/namespace.js";
|
|
31
|
+
export { GirParameter } from "./model/parameter.js";
|
|
32
|
+
export type { DefaultValue } from "./model/property.js";
|
|
33
|
+
export { GirProperty, parseDefaultValue } from "./model/property.js";
|
|
34
|
+
export { GirRecord } from "./model/record.js";
|
|
35
|
+
export type { RepositoryLike, TypeKind } from "./model/repository-like.js";
|
|
36
|
+
export { GirSignal } from "./model/signal.js";
|
|
37
|
+
export type { ContainerType } from "./model/type.js";
|
|
38
|
+
export { GirType } from "./model/type.js";
|
|
39
|
+
export { type DependencyGraph, GirRepository, type RepositoryOptions } from "./repository.js";
|
|
27
40
|
export { toCamelCase, toPascalCase } from "./utils.js";
|
|
28
41
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACH,eAAe,EACf,eAAe,EACf,aAAa,EACb,YAAY,EACZ,UAAU,EACV,aAAa,EACb,YAAY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
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
|
|
22
20
|
*/
|
|
23
21
|
export { INTRINSIC_TYPES, isIntrinsicType, isNumericType, isStringType, isVoidType, NUMERIC_TYPES, STRING_TYPES, VOID_TYPES, } from "./intrinsics.js";
|
|
22
|
+
export { GirAlias } from "./model/alias.js";
|
|
23
|
+
export { GirConstructor, GirFunction, GirMethod } from "./model/callables.js";
|
|
24
|
+
export { GirCallback } from "./model/callback.js";
|
|
25
|
+
export { GirClass } from "./model/class.js";
|
|
26
|
+
export { GirConstant } from "./model/constant.js";
|
|
27
|
+
export { GirEnumeration, GirEnumerationMember } from "./model/enumeration.js";
|
|
28
|
+
export { GirField } from "./model/field.js";
|
|
29
|
+
export { GirInterface } from "./model/interface.js";
|
|
30
|
+
export { GirNamespace } from "./model/namespace.js";
|
|
31
|
+
export { GirParameter } from "./model/parameter.js";
|
|
32
|
+
export { GirProperty, parseDefaultValue } from "./model/property.js";
|
|
33
|
+
export { GirRecord } from "./model/record.js";
|
|
34
|
+
export { GirSignal } from "./model/signal.js";
|
|
35
|
+
export { GirType } from "./model/type.js";
|
|
24
36
|
export { GirRepository } from "./repository.js";
|
|
25
|
-
export { GirAlias, GirCallback, GirClass, GirConstant, GirConstructor, GirEnumeration, GirEnumerationMember, GirField, GirFunction, GirInterface, GirMethod, GirNamespace, GirParameter, GirProperty, GirRecord, GirSignal, GirType, parseDefaultValue, parseQualifiedName, qualifiedName, } from "./types.js";
|
|
26
37
|
export { toCamelCase, toPascalCase } from "./utils.js";
|
|
27
38
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACH,eAAe,EACf,eAAe,EACf,aAAa,EACb,YAAY,EACZ,UAAU,EACV,aAAa,EACb,YAAY,EACZ,UAAU,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAwB,aAAa,EAA0B,MAAM,iBAAiB,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { RawNamespace } from "./raw-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Handles GIR file discovery, dependency graph resolution, and loading.
|
|
4
|
+
*
|
|
5
|
+
* Given a list of root namespace keys (e.g., `["Gtk-4.0"]`) and search paths,
|
|
6
|
+
* discovers all transitive dependencies via `<include>` tags, topologically
|
|
7
|
+
* sorts them, and returns fully parsed raw namespaces in dependency order.
|
|
8
|
+
*/
|
|
9
|
+
export declare class GirLoader {
|
|
10
|
+
private readonly girPath;
|
|
11
|
+
private readonly parser;
|
|
12
|
+
constructor(girPath: string[]);
|
|
13
|
+
/**
|
|
14
|
+
* Loads all GIR namespaces required by the given roots, including
|
|
15
|
+
* all transitive dependencies discovered via `<include>` tags.
|
|
16
|
+
*
|
|
17
|
+
* @returns Raw namespaces keyed by namespace name, in dependency order.
|
|
18
|
+
*/
|
|
19
|
+
loadAll(roots: string[]): Promise<Map<string, {
|
|
20
|
+
raw: RawNamespace;
|
|
21
|
+
xml: string;
|
|
22
|
+
}>>;
|
|
23
|
+
discoverDependencies(roots: string[]): Promise<Map<string, {
|
|
24
|
+
filePath: string;
|
|
25
|
+
dependencies: string[];
|
|
26
|
+
}>>;
|
|
27
|
+
private findGirFile;
|
|
28
|
+
private topologicalSort;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/internal/loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;GAMG;AACH,qBAAa,SAAS;IAClB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAW;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBAEvB,OAAO,EAAE,MAAM,EAAE;IAK7B;;;;;OAKG;IACG,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,YAAY,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAiBlF,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IA0B/G,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,eAAe;CA4C1B"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { GirParser } from "./parser.js";
|
|
5
|
+
/**
|
|
6
|
+
* Handles GIR file discovery, dependency graph resolution, and loading.
|
|
7
|
+
*
|
|
8
|
+
* Given a list of root namespace keys (e.g., `["Gtk-4.0"]`) and search paths,
|
|
9
|
+
* discovers all transitive dependencies via `<include>` tags, topologically
|
|
10
|
+
* sorts them, and returns fully parsed raw namespaces in dependency order.
|
|
11
|
+
*/
|
|
12
|
+
export class GirLoader {
|
|
13
|
+
girPath;
|
|
14
|
+
parser;
|
|
15
|
+
constructor(girPath) {
|
|
16
|
+
this.girPath = girPath;
|
|
17
|
+
this.parser = new GirParser();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Loads all GIR namespaces required by the given roots, including
|
|
21
|
+
* all transitive dependencies discovered via `<include>` tags.
|
|
22
|
+
*
|
|
23
|
+
* @returns Raw namespaces keyed by namespace name, in dependency order.
|
|
24
|
+
*/
|
|
25
|
+
async loadAll(roots) {
|
|
26
|
+
const fileMap = await this.discoverDependencies(roots);
|
|
27
|
+
const sorted = this.topologicalSort(fileMap);
|
|
28
|
+
const result = new Map();
|
|
29
|
+
for (const key of sorted) {
|
|
30
|
+
const entry = fileMap.get(key);
|
|
31
|
+
if (!entry)
|
|
32
|
+
continue;
|
|
33
|
+
const filePath = entry.filePath;
|
|
34
|
+
const xml = await readFile(filePath, "utf-8");
|
|
35
|
+
const raw = this.parser.parseNamespace(xml);
|
|
36
|
+
result.set(raw.name, { raw, xml });
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
async discoverDependencies(roots) {
|
|
41
|
+
const graph = new Map();
|
|
42
|
+
const queue = [...roots];
|
|
43
|
+
while (queue.length > 0) {
|
|
44
|
+
const key = queue.shift();
|
|
45
|
+
if (key === undefined || graph.has(key))
|
|
46
|
+
continue;
|
|
47
|
+
const filePath = this.findGirFile(key);
|
|
48
|
+
const xml = await readFile(filePath, "utf-8");
|
|
49
|
+
const header = this.parser.parseHeader(xml);
|
|
50
|
+
const dependencies = header.dependencies.map((dep) => `${dep.name}-${dep.version}`);
|
|
51
|
+
graph.set(key, { filePath, dependencies });
|
|
52
|
+
for (const dep of dependencies) {
|
|
53
|
+
if (!graph.has(dep)) {
|
|
54
|
+
queue.push(dep);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return graph;
|
|
59
|
+
}
|
|
60
|
+
findGirFile(namespaceKey) {
|
|
61
|
+
const filename = `${namespaceKey}.gir`;
|
|
62
|
+
for (const dir of this.girPath) {
|
|
63
|
+
const filePath = join(dir, filename);
|
|
64
|
+
if (existsSync(filePath)) {
|
|
65
|
+
return filePath;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
throw new Error(`GIR file not found for "${namespaceKey}" in paths: [${this.girPath.join(", ")}]`);
|
|
69
|
+
}
|
|
70
|
+
topologicalSort(graph) {
|
|
71
|
+
const inDegree = new Map();
|
|
72
|
+
const dependents = new Map();
|
|
73
|
+
for (const key of graph.keys()) {
|
|
74
|
+
dependents.set(key, []);
|
|
75
|
+
}
|
|
76
|
+
for (const [key, { dependencies }] of graph) {
|
|
77
|
+
inDegree.set(key, dependencies.filter((d) => graph.has(d)).length);
|
|
78
|
+
for (const dep of dependencies) {
|
|
79
|
+
dependents.get(dep)?.push(key);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const queue = [];
|
|
83
|
+
for (const [key, degree] of inDegree) {
|
|
84
|
+
if (degree === 0) {
|
|
85
|
+
queue.push(key);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const sorted = [];
|
|
89
|
+
while (queue.length > 0) {
|
|
90
|
+
const key = queue.shift();
|
|
91
|
+
if (key === undefined)
|
|
92
|
+
break;
|
|
93
|
+
sorted.push(key);
|
|
94
|
+
for (const dependent of dependents.get(key) ?? []) {
|
|
95
|
+
const newDegree = (inDegree.get(dependent) ?? 0) - 1;
|
|
96
|
+
inDegree.set(dependent, newDegree);
|
|
97
|
+
if (newDegree === 0) {
|
|
98
|
+
queue.push(dependent);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (sorted.length !== graph.size) {
|
|
103
|
+
const remaining = [...graph.keys()].filter((k) => !sorted.includes(k));
|
|
104
|
+
throw new Error(`Circular GIR dependency detected involving: ${remaining.join(", ")}`);
|
|
105
|
+
}
|
|
106
|
+
return sorted;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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AAC,KAAK,EAAE,CAAC;YAC1B,IAAI,GAAG,KAAK,SAAS;gBAAE,MAAM;YAC7B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAEjB,KAAK,MAAM,SAAS,IAAI,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;gBAChD,MAAM,SAAS,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;gBACrD,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBACnC,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;oBAClB,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBAC1B,CAAC;YACL,CAAC;QACL,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;YAC/B,MAAM,SAAS,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YACvE,MAAM,IAAI,KAAK,CAAC,+CAA+C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC3F,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
|
@@ -1,23 +1,106 @@
|
|
|
1
|
+
import { GirAlias } from "../model/alias.js";
|
|
2
|
+
import { GirConstructor, GirFunction, GirMethod } from "../model/callables.js";
|
|
3
|
+
import { GirCallback } from "../model/callback.js";
|
|
4
|
+
import { GirConstant } from "../model/constant.js";
|
|
5
|
+
import { GirEnumeration } from "../model/enumeration.js";
|
|
6
|
+
import { GirProperty } from "../model/property.js";
|
|
7
|
+
import { GirRecord } from "../model/record.js";
|
|
8
|
+
import { GirSignal } from "../model/signal.js";
|
|
9
|
+
import type { RawNamespace } from "./raw-types.js";
|
|
1
10
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* The key job is to qualify all type references with their namespace,
|
|
5
|
-
* except for intrinsic types which remain unqualified.
|
|
6
|
-
*
|
|
7
|
-
* @internal
|
|
11
|
+
* Data produced for a class before the repository exists.
|
|
12
|
+
* Used to defer GirClass construction until the repo is available.
|
|
8
13
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
export type GirClassData = {
|
|
15
|
+
name: string;
|
|
16
|
+
qualifiedName: string;
|
|
17
|
+
cType: string;
|
|
18
|
+
parent: string | null;
|
|
19
|
+
abstract: boolean;
|
|
20
|
+
glibTypeName?: string;
|
|
21
|
+
glibGetType?: string;
|
|
22
|
+
cSymbolPrefix?: string;
|
|
23
|
+
fundamental?: boolean;
|
|
24
|
+
refFunc?: string;
|
|
25
|
+
unrefFunc?: string;
|
|
26
|
+
implements: string[];
|
|
27
|
+
methods: GirMethod[];
|
|
28
|
+
constructors: GirConstructor[];
|
|
29
|
+
staticFunctions: GirFunction[];
|
|
30
|
+
properties: GirProperty[];
|
|
31
|
+
signals: GirSignal[];
|
|
32
|
+
doc?: string;
|
|
33
|
+
};
|
|
11
34
|
/**
|
|
12
|
-
*
|
|
13
|
-
* for resolving cross-namespace references.
|
|
35
|
+
* Data produced for an interface before the repository exists.
|
|
14
36
|
*/
|
|
15
|
-
export type
|
|
16
|
-
|
|
17
|
-
|
|
37
|
+
export type GirInterfaceData = {
|
|
38
|
+
name: string;
|
|
39
|
+
qualifiedName: string;
|
|
40
|
+
cType: string;
|
|
41
|
+
glibTypeName?: string;
|
|
42
|
+
prerequisites: string[];
|
|
43
|
+
methods: GirMethod[];
|
|
44
|
+
properties: GirProperty[];
|
|
45
|
+
signals: GirSignal[];
|
|
46
|
+
doc?: string;
|
|
18
47
|
};
|
|
19
48
|
/**
|
|
20
|
-
*
|
|
49
|
+
* Intermediate namespace data produced by the normalizer.
|
|
50
|
+
*
|
|
51
|
+
* Classes and interfaces are stored as plain data because they need
|
|
52
|
+
* the repository reference at construction time (which doesn't exist yet).
|
|
53
|
+
* All other types are fully constructed model instances.
|
|
54
|
+
*/
|
|
55
|
+
export type GirNamespaceIntermediate = {
|
|
56
|
+
name: string;
|
|
57
|
+
version: string;
|
|
58
|
+
sharedLibrary: string;
|
|
59
|
+
cPrefix: string;
|
|
60
|
+
classes: Map<string, GirClassData>;
|
|
61
|
+
interfaces: Map<string, GirInterfaceData>;
|
|
62
|
+
records: Map<string, GirRecord>;
|
|
63
|
+
enumerations: Map<string, GirEnumeration>;
|
|
64
|
+
bitfields: Map<string, GirEnumeration>;
|
|
65
|
+
callbacks: Map<string, GirCallback>;
|
|
66
|
+
functions: Map<string, GirFunction>;
|
|
67
|
+
constants: Map<string, GirConstant>;
|
|
68
|
+
aliases: Map<string, GirAlias>;
|
|
69
|
+
doc?: string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Converts raw parsed GIR data into model instances with fully qualified
|
|
73
|
+
* type names.
|
|
74
|
+
*
|
|
75
|
+
* Uses indexed lookups for O(1) type name resolution and strict error
|
|
76
|
+
* handling (throws on unresolvable type references).
|
|
21
77
|
*/
|
|
22
|
-
export declare
|
|
78
|
+
export declare class GirNormalizer {
|
|
79
|
+
private typeIndex;
|
|
80
|
+
/**
|
|
81
|
+
* Normalizes all raw namespaces into intermediate namespace data.
|
|
82
|
+
*
|
|
83
|
+
* @param rawNamespaces - Raw namespaces keyed by name, in dependency order
|
|
84
|
+
* @returns Intermediate namespace data keyed by name, in the same order
|
|
85
|
+
*/
|
|
86
|
+
normalize(rawNamespaces: Map<string, RawNamespace>): Map<string, GirNamespaceIntermediate>;
|
|
87
|
+
private buildTypeIndex;
|
|
88
|
+
private normalizeNamespace;
|
|
89
|
+
private qualifyTypeName;
|
|
90
|
+
private normalizeType;
|
|
91
|
+
private normalizeClass;
|
|
92
|
+
private normalizeInterface;
|
|
93
|
+
private normalizeRecord;
|
|
94
|
+
private normalizeEnumeration;
|
|
95
|
+
private normalizeCallback;
|
|
96
|
+
private normalizeConstant;
|
|
97
|
+
private normalizeAlias;
|
|
98
|
+
private normalizeMethod;
|
|
99
|
+
private normalizeConstructor;
|
|
100
|
+
private normalizeFunction;
|
|
101
|
+
private normalizeParameter;
|
|
102
|
+
private normalizeProperty;
|
|
103
|
+
private normalizeSignal;
|
|
104
|
+
private normalizeField;
|
|
105
|
+
}
|
|
23
106
|
//# sourceMappingURL=normalizer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../src/internal/normalizer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../src/internal/normalizer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAwB,MAAM,yBAAyB,CAAC;AAG/E,OAAO,EAAE,WAAW,EAAqB,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EAWR,YAAY,EAMf,MAAM,gBAAgB,CAAC;AAIxB;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,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