@ts-for-gir/lib 4.0.0-beta.1 → 4.0.0-beta.11
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/lib/constants.d.ts +6 -7
- package/lib/constants.js +74 -9
- package/lib/constants.js.map +1 -1
- package/lib/dependency-manager.d.ts +60 -14
- package/lib/dependency-manager.js +143 -46
- package/lib/dependency-manager.js.map +1 -1
- package/lib/generators/dts-inline.d.ts +4 -2
- package/lib/generators/dts-inline.js +10 -12
- package/lib/generators/dts-inline.js.map +1 -1
- package/lib/generators/dts-modules.d.ts +4 -2
- package/lib/generators/dts-modules.js +12 -14
- package/lib/generators/dts-modules.js.map +1 -1
- package/lib/generators/dts.d.ts +2 -2
- package/lib/generators/dts.js +8 -8
- package/lib/generators/dts.js.map +1 -1
- package/lib/generators/generator.d.ts +3 -3
- package/lib/generators/generator.js.map +1 -1
- package/lib/generators/json.d.ts +4 -2
- package/lib/generators/json.js +18 -20
- package/lib/generators/json.js.map +1 -1
- package/lib/generics/visitor.js +5 -9
- package/lib/generics/visitor.js.map +1 -1
- package/lib/gir/alias.d.ts +2 -2
- package/lib/gir/alias.js +3 -3
- package/lib/gir/alias.js.map +1 -1
- package/lib/gir/base.d.ts +3 -3
- package/lib/gir/base.js.map +1 -1
- package/lib/gir/class.d.ts +5 -5
- package/lib/gir/class.js +32 -33
- package/lib/gir/class.js.map +1 -1
- package/lib/gir/const.d.ts +2 -2
- package/lib/gir/const.js +1 -1
- package/lib/gir/const.js.map +1 -1
- package/lib/gir/enum.d.ts +5 -5
- package/lib/gir/enum.js +7 -7
- package/lib/gir/enum.js.map +1 -1
- package/lib/gir/function.d.ts +9 -9
- package/lib/gir/function.js +4 -4
- package/lib/gir/function.js.map +1 -1
- package/lib/gir/nodes.d.ts +1 -1
- package/lib/gir/nodes.js +1 -1
- package/lib/gir/nodes.js.map +1 -1
- package/lib/gir/property.d.ts +2 -2
- package/lib/gir/property.js.map +1 -1
- package/lib/gir/registry.d.ts +6 -6
- package/lib/gir/registry.js +3 -3
- package/lib/gir/registry.js.map +1 -1
- package/lib/gir/signal.d.ts +2 -2
- package/lib/gir/signal.js.map +1 -1
- package/lib/gir/util.d.ts +3 -3
- package/lib/gir/util.js +17 -14
- package/lib/gir/util.js.map +1 -1
- package/lib/gir-module.d.ts +27 -39
- package/lib/gir-module.js +156 -149
- package/lib/gir-module.js.map +1 -1
- package/lib/gir.d.ts +42 -40
- package/lib/gir.js +27 -23
- package/lib/gir.js.map +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/library-version.d.ts +2 -0
- package/lib/library-version.js +13 -0
- package/lib/library-version.js.map +1 -1
- package/lib/logger.d.ts +18 -16
- package/lib/logger.js +28 -26
- package/lib/logger.js.map +1 -1
- package/lib/messages.d.ts +0 -3
- package/lib/messages.js +0 -3
- package/lib/messages.js.map +1 -1
- package/lib/registry.d.ts +0 -1
- package/lib/registry.js +0 -1
- package/lib/registry.js.map +1 -1
- package/lib/transformation.d.ts +5 -15
- package/lib/transformation.js +9 -89
- package/lib/transformation.js.map +1 -1
- package/lib/types/dependency.d.ts +13 -1
- package/lib/types/format.d.ts +1 -0
- package/lib/types/format.js +2 -0
- package/lib/types/format.js.map +1 -0
- package/lib/types/gir-module-resolved-by.d.ts +5 -0
- package/lib/types/index.d.ts +7 -2
- package/lib/types/index.js +7 -2
- package/lib/types/index.js.map +1 -1
- package/lib/types/metadata.d.ts +8 -0
- package/lib/types/metadata.js +2 -0
- package/lib/types/metadata.js.map +1 -0
- package/lib/types/options-base.d.ts +4 -0
- package/lib/types/options-base.js +2 -0
- package/lib/types/options-base.js.map +1 -0
- package/lib/types/{generate-config.d.ts → options-generation.d.ts} +21 -11
- package/lib/types/options-generation.js +2 -0
- package/lib/types/options-generation.js.map +1 -0
- package/lib/types/options-load.d.ts +5 -0
- package/lib/types/options-load.js +2 -0
- package/lib/types/options-load.js.map +1 -0
- package/lib/types/options-transform.d.ts +4 -0
- package/lib/types/options-transform.js +2 -0
- package/lib/types/options-transform.js.map +1 -0
- package/lib/types/output-format.d.ts +1 -0
- package/lib/types/output-format.js +2 -0
- package/lib/types/output-format.js.map +1 -0
- package/lib/types/property-case.d.ts +1 -0
- package/lib/types/property-case.js +2 -0
- package/lib/types/property-case.js.map +1 -0
- package/lib/types/template-data.d.ts +2 -2
- package/lib/types/user-config.d.ts +21 -6
- package/lib/utils/files.d.ts +21 -0
- package/lib/utils/files.js +62 -0
- package/lib/utils/files.js.map +1 -0
- package/lib/utils/girs.d.ts +45 -0
- package/lib/utils/girs.js +101 -0
- package/lib/utils/girs.js.map +1 -0
- package/lib/utils/index.d.ts +6 -0
- package/lib/utils/index.js +7 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/numbers.d.ts +6 -0
- package/lib/utils/numbers.js +10 -0
- package/lib/utils/numbers.js.map +1 -0
- package/lib/utils/objects.d.ts +135 -0
- package/lib/utils/objects.js +122 -0
- package/lib/utils/objects.js.map +1 -0
- package/lib/utils/path.d.ts +1 -0
- package/lib/utils/path.js +7 -0
- package/lib/utils/path.js.map +1 -0
- package/lib/utils/strings.d.ts +74 -0
- package/lib/utils/strings.js +121 -0
- package/lib/utils/strings.js.map +1 -0
- package/lib/utils.d.ts +21 -15
- package/lib/utils.js +58 -13
- package/lib/utils.js.map +1 -1
- package/lib/validators/interface.js +1 -1
- package/lib/validators/interface.js.map +1 -1
- package/package.json +12 -11
- package/lib/conflict-resolver.d.ts +0 -119
- package/lib/conflict-resolver.js +0 -893
- package/lib/conflict-resolver.js.map +0 -1
- package/lib/generators/dts/gio.d.ts +0 -2
- package/lib/generators/dts/gio.js +0 -9
- package/lib/generators/dts/gio.js.map +0 -1
- package/lib/gir-factory.d.ts +0 -52
- package/lib/gir-factory.js +0 -340
- package/lib/gir-factory.js.map +0 -1
- package/lib/injection/callbacks/gjs/Gio-2.0.d.ts +0 -2
- package/lib/injection/callbacks/gjs/Gio-2.0.js +0 -36
- package/lib/injection/callbacks/gjs/Gio-2.0.js.map +0 -1
- package/lib/injection/callbacks/gjs/index.d.ts +0 -2
- package/lib/injection/callbacks/gjs/index.js +0 -3
- package/lib/injection/callbacks/gjs/index.js.map +0 -1
- package/lib/injection/callbacks/index.d.ts +0 -3
- package/lib/injection/callbacks/index.js +0 -3
- package/lib/injection/callbacks/index.js.map +0 -1
- package/lib/injection/classes/gjs/gio-2.0.d.ts +0 -5
- package/lib/injection/classes/gjs/gio-2.0.js +0 -254
- package/lib/injection/classes/gjs/gio-2.0.js.map +0 -1
- package/lib/injection/classes/gjs/glib-2.0.d.ts +0 -2
- package/lib/injection/classes/gjs/glib-2.0.js +0 -225
- package/lib/injection/classes/gjs/glib-2.0.js.map +0 -1
- package/lib/injection/classes/gjs/gobject-2.0.d.ts +0 -2
- package/lib/injection/classes/gjs/gobject-2.0.js +0 -634
- package/lib/injection/classes/gjs/gobject-2.0.js.map +0 -1
- package/lib/injection/classes/gjs/index.d.ts +0 -2
- package/lib/injection/classes/gjs/index.js +0 -5
- package/lib/injection/classes/gjs/index.js.map +0 -1
- package/lib/injection/classes/glib-2.0.d.ts +0 -2
- package/lib/injection/classes/glib-2.0.js +0 -35
- package/lib/injection/classes/glib-2.0.js.map +0 -1
- package/lib/injection/classes/index.d.ts +0 -3
- package/lib/injection/classes/index.js +0 -4
- package/lib/injection/classes/index.js.map +0 -1
- package/lib/injection/index.d.ts +0 -3
- package/lib/injection/index.js +0 -4
- package/lib/injection/index.js.map +0 -1
- package/lib/injection/injector.d.ts +0 -16
- package/lib/injection/injector.js +0 -138
- package/lib/injection/injector.js.map +0 -1
- package/lib/symtable.d.ts +0 -24
- package/lib/symtable.js +0 -63
- package/lib/symtable.js.map +0 -1
- package/lib/types/conflict-child-element.d.ts +0 -10
- package/lib/types/conflict-child-element.js +0 -2
- package/lib/types/conflict-child-element.js.map +0 -1
- package/lib/types/conflict-grouped-element.d.ts +0 -6
- package/lib/types/conflict-grouped-element.js +0 -2
- package/lib/types/conflict-grouped-element.js.map +0 -1
- package/lib/types/conflict-grouped-elements.d.ts +0 -4
- package/lib/types/conflict-grouped-elements.js +0 -2
- package/lib/types/conflict-grouped-elements.js.map +0 -1
- package/lib/types/generate-config.js +0 -2
- package/lib/types/generate-config.js.map +0 -1
- package/lib/types/injection-callback.d.ts +0 -16
- package/lib/types/injection-callback.js +0 -2
- package/lib/types/injection-callback.js.map +0 -1
- package/lib/types/injection-class.d.ts +0 -25
- package/lib/types/injection-class.js +0 -2
- package/lib/types/injection-class.js.map +0 -1
- package/lib/types/injection-function.d.ts +0 -7
- package/lib/types/injection-function.js +0 -2
- package/lib/types/injection-function.js.map +0 -1
- package/lib/types/injection-generic-parameter.d.ts +0 -2
- package/lib/types/injection-generic-parameter.js +0 -2
- package/lib/types/injection-generic-parameter.js.map +0 -1
- package/lib/types/injection-instance-parameter.d.ts +0 -2
- package/lib/types/injection-instance-parameter.js +0 -2
- package/lib/types/injection-instance-parameter.js.map +0 -1
- package/lib/types/injection-parameter.d.ts +0 -8
- package/lib/types/injection-parameter.js +0 -2
- package/lib/types/injection-parameter.js.map +0 -1
- package/lib/types/injection-property.d.ts +0 -4
- package/lib/types/injection-property.js +0 -2
- package/lib/types/injection-property.js.map +0 -1
- package/lib/types/injection-type.d.ts +0 -2
- package/lib/types/injection-type.js +0 -2
- package/lib/types/injection-type.js.map +0 -1
- package/lib/types/injection.d.ts +0 -5
- package/lib/types/injection.js +0 -2
- package/lib/types/injection.js.map +0 -1
- package/lib/types/promisify-func.d.ts +0 -7
- package/lib/types/promisify-func.js +0 -2
- package/lib/types/promisify-func.js.map +0 -1
- package/lib/types/sym-table-items.d.ts +0 -4
- package/lib/types/sym-table-items.js +0 -2
- package/lib/types/sym-table-items.js.map +0 -1
- package/lib/types/ts-alias.d.ts +0 -10
- package/lib/types/ts-alias.js +0 -2
- package/lib/types/ts-alias.js.map +0 -1
- package/lib/types/ts-callback-interface.d.ts +0 -10
- package/lib/types/ts-callback-interface.js +0 -2
- package/lib/types/ts-callback-interface.js.map +0 -1
- package/lib/types/ts-callback.d.ts +0 -17
- package/lib/types/ts-callback.js +0 -2
- package/lib/types/ts-callback.js.map +0 -1
- package/lib/types/ts-class.d.ts +0 -85
- package/lib/types/ts-class.js +0 -2
- package/lib/types/ts-class.js.map +0 -1
- package/lib/types/ts-enum.d.ts +0 -12
- package/lib/types/ts-enum.js +0 -2
- package/lib/types/ts-enum.js.map +0 -1
- package/lib/types/ts-function.d.ts +0 -55
- package/lib/types/ts-function.js +0 -2
- package/lib/types/ts-function.js.map +0 -1
- package/lib/types/ts-generic-parameter.d.ts +0 -8
- package/lib/types/ts-generic-parameter.js +0 -2
- package/lib/types/ts-generic-parameter.js.map +0 -1
- package/lib/types/ts-instance-parameter.d.ts +0 -4
- package/lib/types/ts-instance-parameter.js +0 -2
- package/lib/types/ts-instance-parameter.js.map +0 -1
- package/lib/types/ts-member.d.ts +0 -10
- package/lib/types/ts-member.js +0 -2
- package/lib/types/ts-member.js.map +0 -1
- package/lib/types/ts-method.d.ts +0 -5
- package/lib/types/ts-method.js +0 -2
- package/lib/types/ts-method.js.map +0 -1
- package/lib/types/ts-parameter.d.ts +0 -15
- package/lib/types/ts-parameter.js +0 -2
- package/lib/types/ts-parameter.js.map +0 -1
- package/lib/types/ts-property.d.ts +0 -17
- package/lib/types/ts-property.js +0 -2
- package/lib/types/ts-property.js.map +0 -1
- package/lib/types/ts-signal.d.ts +0 -17
- package/lib/types/ts-signal.js +0 -2
- package/lib/types/ts-signal.js.map +0 -1
- package/lib/types/ts-type-name.d.ts +0 -1
- package/lib/types/ts-type-name.js +0 -2
- package/lib/types/ts-type-name.js.map +0 -1
- package/lib/types/ts-type-separator.d.ts +0 -1
- package/lib/types/ts-type-separator.js +0 -2
- package/lib/types/ts-type-separator.js.map +0 -1
- package/lib/types/ts-type.d.ts +0 -26
- package/lib/types/ts-type.js +0 -2
- package/lib/types/ts-type.js.map +0 -1
- package/lib/types/ts-var.d.ts +0 -17
- package/lib/types/ts-var.js +0 -2
- package/lib/types/ts-var.js.map +0 -1
- package/lib/types.d.ts +0 -23
- package/lib/types.js +0 -2
- package/lib/types.js.map +0 -1
package/lib/gir-module.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Transformation } from './transformation.js';
|
|
2
2
|
import { Logger } from './logger.js';
|
|
3
3
|
import { DependencyManager } from './dependency-manager.js';
|
|
4
|
-
import { SymTable } from './symtable.js';
|
|
5
4
|
import { LibraryVersion } from './library-version.js';
|
|
6
|
-
import type { Dependency,
|
|
5
|
+
import type { Dependency, GirConstantElement, TsDocTag, OptionsGeneration } from './types/index.js';
|
|
7
6
|
import { GirNSMember } from './gir.js';
|
|
8
7
|
import { IntrospectedAlias } from './gir/alias.js';
|
|
9
8
|
import { IntrospectedNamespaceMember } from './gir/base.js';
|
|
@@ -13,39 +12,43 @@ import { IntrospectedFunction, IntrospectedFunctionParameter, IntrospectedClassF
|
|
|
13
12
|
import { NSRegistry } from './gir/registry.js';
|
|
14
13
|
import { GirVisitor } from './visitor.js';
|
|
15
14
|
export declare class GirModule {
|
|
15
|
+
readonly dependency: Dependency;
|
|
16
16
|
/**
|
|
17
17
|
* E.g. 'Gtk'
|
|
18
18
|
*/
|
|
19
|
-
namespace: string;
|
|
19
|
+
get namespace(): string;
|
|
20
20
|
/**
|
|
21
21
|
* E.g. '4.0'
|
|
22
22
|
*/
|
|
23
|
-
version: string;
|
|
23
|
+
get version(): string;
|
|
24
24
|
/**
|
|
25
25
|
* E.g. 'Gtk-4.0'
|
|
26
26
|
*/
|
|
27
|
-
packageName: string;
|
|
27
|
+
get packageName(): string;
|
|
28
28
|
/**
|
|
29
29
|
* E.g. 'Gtk40'
|
|
30
30
|
* Is used in the generated index.d.ts, for example: `import * as Gtk40 from "./Gtk-4.0.js";`
|
|
31
31
|
*/
|
|
32
|
-
importNamespace: string;
|
|
33
|
-
|
|
32
|
+
get importNamespace(): string;
|
|
33
|
+
/**
|
|
34
|
+
* The NPM package name E.g. 'gtk-4.0'
|
|
35
|
+
*/
|
|
36
|
+
get importName(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Import path for the package E.g. './Gtk-4.0.js' or '@girs/Gtk-4.0'
|
|
39
|
+
*/
|
|
40
|
+
get importPath(): string;
|
|
34
41
|
prefixes: string[];
|
|
35
42
|
/**
|
|
36
43
|
* The version of the library as an object.
|
|
37
44
|
* E.g. `{ major: 4, minor: 0, patch: 0 }` or as string `4.0.0`'
|
|
38
45
|
*/
|
|
39
|
-
libraryVersion: LibraryVersion;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
get libraryVersion(): LibraryVersion;
|
|
47
|
+
protected _dependencies: Dependency[] | null;
|
|
48
|
+
protected _transitiveDependencies: Dependency[] | null;
|
|
49
|
+
get dependencies(): Dependency[];
|
|
43
50
|
get transitiveDependencies(): Dependency[];
|
|
44
51
|
get allDependencies(): Dependency[];
|
|
45
|
-
/**
|
|
46
|
-
* Used to find namespaces that are used in other modules
|
|
47
|
-
*/
|
|
48
|
-
symTable: SymTable;
|
|
49
52
|
transformation: Transformation;
|
|
50
53
|
dependencyManager: DependencyManager;
|
|
51
54
|
log: Logger;
|
|
@@ -57,7 +60,6 @@ export declare class GirModule {
|
|
|
57
60
|
constNames: {
|
|
58
61
|
[varName: string]: GirConstantElement;
|
|
59
62
|
};
|
|
60
|
-
readonly name: string;
|
|
61
63
|
readonly c_prefixes: string[];
|
|
62
64
|
private _members?;
|
|
63
65
|
private _enum_constants?;
|
|
@@ -65,12 +67,12 @@ export declare class GirModule {
|
|
|
65
67
|
__dts__references?: string[];
|
|
66
68
|
package_version: readonly [string, string] | readonly [string, string, string];
|
|
67
69
|
parent: NSRegistry;
|
|
68
|
-
config:
|
|
69
|
-
constructor(
|
|
70
|
+
config: OptionsGeneration;
|
|
71
|
+
constructor(dependency: Dependency, prefixes: string[], config: OptionsGeneration);
|
|
72
|
+
initDependencies(): Promise<void>;
|
|
73
|
+
initTransitiveDependencies(transitiveDependencies: Dependency[]): Promise<void>;
|
|
70
74
|
get ns(): this;
|
|
71
75
|
private checkTransitiveDependencies;
|
|
72
|
-
private getTsDoc;
|
|
73
|
-
private getTsDocGirElementTags;
|
|
74
76
|
getTsDocReturnTags(girElement?: IntrospectedFunction | IntrospectedClassFunction): TsDocTag[];
|
|
75
77
|
getTsDocInParamTags(inParams?: IntrospectedFunctionParameter[]): TsDocTag[];
|
|
76
78
|
registerResolveName(resolveName: string, namespace: string, name: string): void;
|
|
@@ -80,8 +82,8 @@ export declare class GirModule {
|
|
|
80
82
|
getImportsForCPrefix(c_prefix: string): GirModule[];
|
|
81
83
|
hasImport(name: string): boolean;
|
|
82
84
|
private _getImport;
|
|
83
|
-
getInstalledImport(
|
|
84
|
-
assertInstalledImport(
|
|
85
|
+
getInstalledImport(_namespace: string): GirModule | null;
|
|
86
|
+
assertInstalledImport(_namespace: string): GirModule;
|
|
85
87
|
getMembers(name: string): IntrospectedNamespaceMember[];
|
|
86
88
|
getMemberWithoutOverrides(name: string): GirNSMember | null | undefined;
|
|
87
89
|
assertClass(name: string): IntrospectedBaseClass;
|
|
@@ -97,22 +99,8 @@ export declare class GirModule {
|
|
|
97
99
|
* libraries that are newer than default.
|
|
98
100
|
*/
|
|
99
101
|
___dts___addReference(reference: string): void;
|
|
100
|
-
static load(
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
-
*/
|
|
104
|
-
start(girModules: GirModule[]): void;
|
|
102
|
+
static load(dependency: Dependency, config: OptionsGeneration, registry: NSRegistry): Promise<GirModule>;
|
|
103
|
+
/** Start to parse all the data from the XML we need for the typescript generation */
|
|
104
|
+
parse(): void;
|
|
105
105
|
}
|
|
106
|
-
export declare const isIntrospectable: (e: {
|
|
107
|
-
$?: GirInfoAttrs;
|
|
108
|
-
}) => boolean;
|
|
109
|
-
export declare const isDeprecated: (e: {
|
|
110
|
-
$: GirInfoAttrs;
|
|
111
|
-
}) => boolean;
|
|
112
|
-
export declare const deprecatedVersion: (e: {
|
|
113
|
-
$: GirInfoAttrs;
|
|
114
|
-
}) => string | undefined;
|
|
115
|
-
export declare const introducedVersion: (e: {
|
|
116
|
-
$: GirInfoAttrs;
|
|
117
|
-
}) => string | undefined;
|
|
118
106
|
export declare function promisifyNamespaceFunctions(namespace: GirModule): void;
|
package/lib/gir-module.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
// TODO move this class into a web-worker? https://www.npmjs.com/package/web-worker
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
-
import {
|
|
3
|
+
import { Transformation } from './transformation.js';
|
|
4
4
|
import { Logger } from './logger.js';
|
|
5
5
|
import { DependencyManager } from './dependency-manager.js';
|
|
6
|
-
import { find } from './utils.js';
|
|
7
|
-
import { SymTable } from './symtable.js';
|
|
8
|
-
import { LibraryVersion } from './library-version.js';
|
|
6
|
+
import { find, isIntrospectable } from './utils/index.js';
|
|
9
7
|
import { ClosureType, TypeIdentifier, PromiseType, VoidType, BooleanType, TupleType, BinaryType, NullableType, ObjectType, } from './gir.js';
|
|
10
8
|
import { IntrospectedAlias } from './gir/alias.js';
|
|
11
9
|
import { IntrospectedBase } from './gir/base.js';
|
|
@@ -15,45 +13,79 @@ import { IntrospectedEnum, IntrospectedError } from './gir/enum.js';
|
|
|
15
13
|
import { IntrospectedFunction, IntrospectedCallback, } from './gir/function.js';
|
|
16
14
|
import { isPrimitiveType } from './gir/util.js';
|
|
17
15
|
export class GirModule {
|
|
16
|
+
dependency;
|
|
18
17
|
/**
|
|
19
18
|
* E.g. 'Gtk'
|
|
20
19
|
*/
|
|
21
|
-
namespace
|
|
20
|
+
get namespace() {
|
|
21
|
+
return this.dependency.namespace;
|
|
22
|
+
}
|
|
22
23
|
/**
|
|
23
24
|
* E.g. '4.0'
|
|
24
25
|
*/
|
|
25
|
-
version
|
|
26
|
+
get version() {
|
|
27
|
+
return this.dependency.version;
|
|
28
|
+
}
|
|
26
29
|
/**
|
|
27
30
|
* E.g. 'Gtk-4.0'
|
|
28
31
|
*/
|
|
29
|
-
packageName
|
|
32
|
+
get packageName() {
|
|
33
|
+
return this.dependency.packageName;
|
|
34
|
+
}
|
|
30
35
|
/**
|
|
31
36
|
* E.g. 'Gtk40'
|
|
32
37
|
* Is used in the generated index.d.ts, for example: `import * as Gtk40 from "./Gtk-4.0.js";`
|
|
33
38
|
*/
|
|
34
|
-
importNamespace
|
|
35
|
-
|
|
39
|
+
get importNamespace() {
|
|
40
|
+
return this.dependency.importNamespace;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The NPM package name E.g. 'gtk-4.0'
|
|
44
|
+
*/
|
|
45
|
+
get importName() {
|
|
46
|
+
return this.dependency.importName;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Import path for the package E.g. './Gtk-4.0.js' or '@girs/Gtk-4.0'
|
|
50
|
+
*/
|
|
51
|
+
get importPath() {
|
|
52
|
+
return this.dependency.importPath;
|
|
53
|
+
}
|
|
36
54
|
prefixes = [];
|
|
37
55
|
/**
|
|
38
56
|
* The version of the library as an object.
|
|
39
57
|
* E.g. `{ major: 4, minor: 0, patch: 0 }` or as string `4.0.0`'
|
|
40
58
|
*/
|
|
41
|
-
libraryVersion
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
get libraryVersion() {
|
|
60
|
+
// GObject and Gio are following the version of GLib
|
|
61
|
+
if (this.namespace === 'GObject' || this.namespace === 'Gio') {
|
|
62
|
+
const dep = this.allDependencies.find((girModule) => girModule.namespace === 'GLib');
|
|
63
|
+
if (dep) {
|
|
64
|
+
return dep.libraryVersion;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return this.dependency.libraryVersion;
|
|
68
|
+
}
|
|
69
|
+
_dependencies = null;
|
|
70
|
+
_transitiveDependencies = null;
|
|
71
|
+
get dependencies() {
|
|
72
|
+
if (!this._dependencies) {
|
|
73
|
+
throw new Error('dependencies is not initialized, run initDependencies() first');
|
|
74
|
+
}
|
|
75
|
+
return this._dependencies;
|
|
46
76
|
}
|
|
47
77
|
get transitiveDependencies() {
|
|
78
|
+
if (!this._transitiveDependencies) {
|
|
79
|
+
throw new Error('transitiveDependencies is not initialized, run initTransitiveDependencies() first');
|
|
80
|
+
}
|
|
48
81
|
return this._transitiveDependencies;
|
|
49
82
|
}
|
|
50
83
|
get allDependencies() {
|
|
84
|
+
if (!this.dependencies) {
|
|
85
|
+
throw new Error('dependencies is not initialized, run init() first');
|
|
86
|
+
}
|
|
51
87
|
return [...new Set([...this.dependencies, ...this.transitiveDependencies])];
|
|
52
88
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Used to find namespaces that are used in other modules
|
|
55
|
-
*/
|
|
56
|
-
symTable;
|
|
57
89
|
transformation;
|
|
58
90
|
dependencyManager;
|
|
59
91
|
log;
|
|
@@ -63,7 +95,6 @@ export class GirModule {
|
|
|
63
95
|
* Please note: Such a case is only known for Zeitgeist-2.0 with the constant "ATTACHMENT"
|
|
64
96
|
*/
|
|
65
97
|
constNames = {};
|
|
66
|
-
name;
|
|
67
98
|
c_prefixes;
|
|
68
99
|
_members;
|
|
69
100
|
_enum_constants;
|
|
@@ -72,67 +103,56 @@ export class GirModule {
|
|
|
72
103
|
package_version;
|
|
73
104
|
parent;
|
|
74
105
|
config;
|
|
75
|
-
constructor(
|
|
76
|
-
this.
|
|
77
|
-
this.version = version;
|
|
106
|
+
constructor(dependency, prefixes, config) {
|
|
107
|
+
this.dependency = dependency;
|
|
78
108
|
this.c_prefixes = [...prefixes];
|
|
79
109
|
this.package_version = ['0', '0'];
|
|
80
110
|
this.config = config;
|
|
111
|
+
// TODO: Make this a singleton
|
|
81
112
|
this.dependencyManager = DependencyManager.getInstance(this.config);
|
|
82
|
-
|
|
113
|
+
}
|
|
114
|
+
async initDependencies() {
|
|
115
|
+
this._dependencies = await this.dependencyManager.fromGirIncludes(this.dependency.girXML?.repository[0]?.include || []);
|
|
116
|
+
}
|
|
117
|
+
async initTransitiveDependencies(transitiveDependencies) {
|
|
118
|
+
this._transitiveDependencies = await this.checkTransitiveDependencies(transitiveDependencies);
|
|
83
119
|
}
|
|
84
120
|
get ns() {
|
|
85
121
|
return this;
|
|
86
122
|
}
|
|
87
|
-
checkTransitiveDependencies(transitiveDependencies) {
|
|
123
|
+
async checkTransitiveDependencies(transitiveDependencies) {
|
|
88
124
|
// Always pull in GObject-2.0, as we may need it for e.g. GObject-2.0.type
|
|
89
125
|
if (this.packageName !== 'GObject-2.0') {
|
|
90
126
|
if (!find(transitiveDependencies, (x) => x.packageName === 'GObject-2.0')) {
|
|
91
|
-
transitiveDependencies.push(this.dependencyManager.get('GObject', '2.0'));
|
|
127
|
+
transitiveDependencies.push(await this.dependencyManager.get('GObject', '2.0'));
|
|
92
128
|
}
|
|
93
129
|
}
|
|
94
130
|
// Add missing dependencies
|
|
95
131
|
if (this.packageName === 'UnityExtras-7.0') {
|
|
96
132
|
if (!find(transitiveDependencies, (x) => x.packageName === 'Unity-7.0')) {
|
|
97
|
-
transitiveDependencies.push(this.dependencyManager.get('Unity', '7.0'));
|
|
133
|
+
transitiveDependencies.push(await this.dependencyManager.get('Unity', '7.0'));
|
|
98
134
|
}
|
|
99
135
|
}
|
|
100
136
|
if (this.packageName === 'UnityExtras-6.0') {
|
|
101
137
|
if (!find(transitiveDependencies, (x) => x.packageName === 'Unity-6.0')) {
|
|
102
|
-
transitiveDependencies.push(this.dependencyManager.get('Unity', '6.0'));
|
|
138
|
+
transitiveDependencies.push(await this.dependencyManager.get('Unity', '6.0'));
|
|
103
139
|
}
|
|
104
140
|
}
|
|
105
141
|
if (this.packageName === 'GTop-2.0') {
|
|
106
142
|
if (!find(transitiveDependencies, (x) => x.packageName === 'GLib-2.0')) {
|
|
107
|
-
transitiveDependencies.push(this.dependencyManager.get('GLib', '2.0'));
|
|
143
|
+
transitiveDependencies.push(await this.dependencyManager.get('GLib', '2.0'));
|
|
108
144
|
}
|
|
109
145
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
// TODO: Somehow _ is not a string
|
|
119
|
-
let text = `${girDoc.doc?.[0]?._ || ''}`;
|
|
120
|
-
text = this.transformation.transformGirDocText(text);
|
|
121
|
-
tsDoc.text = text;
|
|
122
|
-
}
|
|
123
|
-
return tsDoc;
|
|
124
|
-
}
|
|
125
|
-
getTsDocGirElementTags(tsTypeName, girTypeName) {
|
|
126
|
-
const tags = [];
|
|
127
|
-
if (!girTypeName || IGNORE_GIR_TYPE_TS_DOC_TYPES.includes(girTypeName)) {
|
|
128
|
-
return tags;
|
|
146
|
+
// Gio
|
|
147
|
+
if (this.packageName === 'GioUnix-2.0') {
|
|
148
|
+
if (!find(transitiveDependencies, (x) => x.packageName === 'Gio-2.0')) {
|
|
149
|
+
transitiveDependencies.push(await this.dependencyManager.get('Gio', '2.0'));
|
|
150
|
+
}
|
|
151
|
+
if (!find(transitiveDependencies, (x) => x.packageName === 'GLib-2.0')) {
|
|
152
|
+
transitiveDependencies.push(await this.dependencyManager.get('GLib', '2.0'));
|
|
153
|
+
}
|
|
129
154
|
}
|
|
130
|
-
|
|
131
|
-
tagName: girTypeName,
|
|
132
|
-
paramName: '',
|
|
133
|
-
text: '',
|
|
134
|
-
});
|
|
135
|
-
return tags;
|
|
155
|
+
return transitiveDependencies;
|
|
136
156
|
}
|
|
137
157
|
getTsDocReturnTags(girElement) {
|
|
138
158
|
const girReturnValue = girElement?.returnTypeDoc;
|
|
@@ -200,58 +220,58 @@ export class GirModule {
|
|
|
200
220
|
hasImport(name) {
|
|
201
221
|
return this.dependencies.some((dep) => dep.importName === name);
|
|
202
222
|
}
|
|
203
|
-
_getImport(
|
|
204
|
-
if (
|
|
223
|
+
_getImport(namespace) {
|
|
224
|
+
if (namespace === this.namespace) {
|
|
205
225
|
return this;
|
|
206
226
|
}
|
|
207
|
-
const dep = this.dependencies
|
|
208
|
-
this.transitiveDependencies.find((dep) => dep.namespace ===
|
|
227
|
+
const dep = this.dependencies?.find((dep) => dep.namespace === namespace) ??
|
|
228
|
+
this.transitiveDependencies.find((dep) => dep.namespace === namespace);
|
|
209
229
|
// Handle finding imports via their other prefixes
|
|
210
230
|
if (!dep) {
|
|
211
|
-
this.log.info(`Failed to find namespace ${
|
|
231
|
+
this.log.info(`Failed to find namespace ${namespace} in dependencies, resolving via c:prefixes`);
|
|
212
232
|
// TODO: It might make more sense to move this conversion _before_
|
|
213
233
|
// the _getImport call.
|
|
214
|
-
const resolvedNamespaces = this.dependencyManager.namespacesForPrefix(
|
|
234
|
+
const resolvedNamespaces = this.dependencyManager.namespacesForPrefix(namespace);
|
|
215
235
|
if (resolvedNamespaces.length > 0) {
|
|
216
|
-
this.log.info(`Found namespaces for prefix ${
|
|
236
|
+
this.log.info(`Found namespaces for prefix ${namespace}: ${resolvedNamespaces.map((r) => `${r.namespace} (${r.version})`).join(', ')}`);
|
|
217
237
|
}
|
|
218
238
|
for (const resolvedNamespace of resolvedNamespaces) {
|
|
219
|
-
if (resolvedNamespace.
|
|
239
|
+
if (resolvedNamespace.namespace === this.namespace && resolvedNamespace.version === this.version) {
|
|
220
240
|
return this;
|
|
221
241
|
}
|
|
222
|
-
const dep = this.dependencies
|
|
223
|
-
this.transitiveDependencies.find((dep) => dep.namespace === resolvedNamespace.
|
|
242
|
+
const dep = this.dependencies?.find((dep) => dep.namespace === resolvedNamespace.namespace && dep.version === resolvedNamespace.version) ??
|
|
243
|
+
this.transitiveDependencies.find((dep) => dep.namespace === resolvedNamespace.namespace && dep.version === resolvedNamespace.version);
|
|
224
244
|
if (dep) {
|
|
225
|
-
return this.parent.namespace(resolvedNamespace.
|
|
245
|
+
return this.parent.namespace(resolvedNamespace.namespace, dep.version);
|
|
226
246
|
}
|
|
227
247
|
}
|
|
228
248
|
}
|
|
229
249
|
let version = dep?.version;
|
|
230
250
|
if (!version) {
|
|
231
|
-
version = this.parent.assertDefaultVersionOf(
|
|
251
|
+
version = this.parent.assertDefaultVersionOf(namespace);
|
|
232
252
|
}
|
|
233
|
-
return this.parent.namespace(
|
|
253
|
+
return this.parent.namespace(namespace, version);
|
|
234
254
|
}
|
|
235
|
-
getInstalledImport(
|
|
236
|
-
if (
|
|
255
|
+
getInstalledImport(_namespace) {
|
|
256
|
+
if (_namespace === this.namespace) {
|
|
237
257
|
return this;
|
|
238
258
|
}
|
|
239
|
-
const dep = this.dependencies
|
|
240
|
-
this.transitiveDependencies.find((dep) => dep.namespace ===
|
|
259
|
+
const dep = this.dependencies?.find((dep) => dep.namespace === _namespace) ??
|
|
260
|
+
this.transitiveDependencies.find((dep) => dep.namespace === _namespace);
|
|
241
261
|
let version = dep?.version;
|
|
242
262
|
if (!version) {
|
|
243
|
-
version = this.parent.defaultVersionOf(
|
|
263
|
+
version = this.parent.defaultVersionOf(_namespace) ?? undefined;
|
|
244
264
|
}
|
|
245
265
|
if (!version) {
|
|
246
266
|
return null;
|
|
247
267
|
}
|
|
248
|
-
const namespace = this.parent.namespace(
|
|
268
|
+
const namespace = this.parent.namespace(_namespace, version);
|
|
249
269
|
return namespace;
|
|
250
270
|
}
|
|
251
|
-
assertInstalledImport(
|
|
252
|
-
const namespace = this._getImport(
|
|
271
|
+
assertInstalledImport(_namespace) {
|
|
272
|
+
const namespace = this._getImport(_namespace);
|
|
253
273
|
if (!namespace) {
|
|
254
|
-
throw new Error(`Failed to import ${
|
|
274
|
+
throw new Error(`Failed to import ${_namespace} in ${this.namespace}, not installed or accessible.`);
|
|
255
275
|
}
|
|
256
276
|
return namespace;
|
|
257
277
|
}
|
|
@@ -282,7 +302,7 @@ export class GirModule {
|
|
|
282
302
|
assertClass(name) {
|
|
283
303
|
const clazz = this.getClass(name);
|
|
284
304
|
if (!clazz) {
|
|
285
|
-
throw new Error(`Class ${name} does not exist in namespace ${this.
|
|
305
|
+
throw new Error(`Class ${name} does not exist in namespace ${this.namespace}.`);
|
|
286
306
|
}
|
|
287
307
|
return clazz;
|
|
288
308
|
}
|
|
@@ -342,22 +362,17 @@ export class GirModule {
|
|
|
342
362
|
this.__dts__references ??= [];
|
|
343
363
|
this.__dts__references.push(reference);
|
|
344
364
|
}
|
|
345
|
-
static load(
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
365
|
+
static async load(dependency, config, registry) {
|
|
366
|
+
const girXML = dependency.girXML;
|
|
367
|
+
const ns = girXML?.repository[0]?.namespace?.[0];
|
|
368
|
+
if (!girXML) {
|
|
369
|
+
throw new Error(`Failed to load gir xml of ${dependency.packageName}`);
|
|
370
|
+
}
|
|
371
|
+
if (!ns) {
|
|
372
|
+
throw new Error(`Missing namespace in ${girXML.repository[0].package[0].$.name}`);
|
|
373
|
+
}
|
|
349
374
|
const modName = ns.$['name'];
|
|
350
375
|
const version = ns.$['version'];
|
|
351
|
-
// TODO: Hardcoding HarfBuzz here leads to issues when loading...
|
|
352
|
-
// Hardcode harfbuzz version for now...
|
|
353
|
-
// if (modName === 'HarfBuzz' && version === '0.0') {
|
|
354
|
-
// version = '2.0'
|
|
355
|
-
// }
|
|
356
|
-
const options = {
|
|
357
|
-
loadDocs: !config.noComments,
|
|
358
|
-
propertyCase: 'both',
|
|
359
|
-
verbose: config.verbose,
|
|
360
|
-
};
|
|
361
376
|
if (!modName) {
|
|
362
377
|
throw new Error('Invalid GIR file: no namespace name specified.');
|
|
363
378
|
}
|
|
@@ -365,112 +380,130 @@ export class GirModule {
|
|
|
365
380
|
throw new Error('Invalid GIR file: no version name specified.');
|
|
366
381
|
}
|
|
367
382
|
const c_prefix = ns.$?.['c:identifier-prefixes']?.split(',') ?? [];
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
const building = new GirModule(repo.repository[0], modName, version, c_prefix, config);
|
|
383
|
+
const building = new GirModule(dependency, c_prefix, config);
|
|
384
|
+
await building.initDependencies();
|
|
372
385
|
building.parent = registry;
|
|
373
386
|
// Set the namespace object here to prevent re-parsing the namespace if
|
|
374
387
|
// another namespace imports it.
|
|
375
388
|
registry.register(building);
|
|
376
|
-
const prefixes =
|
|
389
|
+
const prefixes = girXML.repository[0]?.$?.['c:identifier-prefixes']?.split(',');
|
|
377
390
|
const unknownPrefixes = prefixes?.filter((pre) => pre !== modName);
|
|
378
391
|
if (unknownPrefixes && unknownPrefixes.length > 0) {
|
|
379
|
-
|
|
392
|
+
Logger.log(`Found additional prefixes for ${modName}: ${unknownPrefixes.join(', ')}`);
|
|
380
393
|
building.prefixes.push(...unknownPrefixes);
|
|
381
394
|
}
|
|
395
|
+
building.transformation = Transformation.getSingleton(config);
|
|
396
|
+
building.log = new Logger(config.verbose, `GirModule(${building.packageName})`);
|
|
397
|
+
return building;
|
|
398
|
+
}
|
|
399
|
+
/** Start to parse all the data from the XML we need for the typescript generation */
|
|
400
|
+
parse() {
|
|
401
|
+
this.log.debug(`Parsing ${this.dependency.packageName}...`);
|
|
402
|
+
const girXML = this.dependency.girXML;
|
|
403
|
+
const ns = girXML?.repository[0]?.namespace?.[0];
|
|
404
|
+
const options = {
|
|
405
|
+
loadDocs: !this.config.noComments,
|
|
406
|
+
propertyCase: 'both',
|
|
407
|
+
verbose: this.config.verbose,
|
|
408
|
+
};
|
|
409
|
+
if (!girXML) {
|
|
410
|
+
throw new Error(`Failed to load gir xml of ${this.dependency.packageName}`);
|
|
411
|
+
}
|
|
412
|
+
if (!ns) {
|
|
413
|
+
throw new Error(`Missing namespace in ${girXML.repository[0].package[0].$.name}`);
|
|
414
|
+
}
|
|
382
415
|
const importConflicts = (el) => {
|
|
383
|
-
return !
|
|
416
|
+
return !this.hasImport(el.name);
|
|
384
417
|
};
|
|
385
418
|
if (ns.enumeration) {
|
|
386
419
|
// Get the requested enums
|
|
387
420
|
ns.enumeration
|
|
388
421
|
?.map((enumeration) => {
|
|
389
422
|
if (enumeration.$['glib:error-domain']) {
|
|
390
|
-
return IntrospectedError.fromXML(enumeration,
|
|
423
|
+
return IntrospectedError.fromXML(enumeration, this, options);
|
|
391
424
|
}
|
|
392
425
|
else {
|
|
393
|
-
return IntrospectedEnum.fromXML(enumeration,
|
|
426
|
+
return IntrospectedEnum.fromXML(enumeration, this, options);
|
|
394
427
|
}
|
|
395
428
|
})
|
|
396
|
-
.forEach((c) =>
|
|
429
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
397
430
|
}
|
|
398
431
|
// Constants
|
|
399
432
|
if (ns.constant) {
|
|
400
433
|
ns.constant
|
|
401
434
|
?.filter(isIntrospectable)
|
|
402
|
-
.map((constant) => IntrospectedConstant.fromXML(constant,
|
|
435
|
+
.map((constant) => IntrospectedConstant.fromXML(constant, this, options))
|
|
403
436
|
.filter(importConflicts)
|
|
404
|
-
.forEach((c) =>
|
|
437
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
405
438
|
}
|
|
406
439
|
// Get the requested functions
|
|
407
440
|
if (ns.function) {
|
|
408
441
|
ns.function
|
|
409
442
|
?.filter(isIntrospectable)
|
|
410
|
-
.map((func) => IntrospectedFunction.fromXML(func,
|
|
443
|
+
.map((func) => IntrospectedFunction.fromXML(func, this, options))
|
|
411
444
|
.filter(importConflicts)
|
|
412
|
-
.forEach((c) =>
|
|
445
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
413
446
|
}
|
|
414
447
|
if (ns.callback) {
|
|
415
448
|
ns.callback
|
|
416
449
|
?.filter(isIntrospectable)
|
|
417
|
-
.map((callback) => IntrospectedCallback.fromXML(callback,
|
|
450
|
+
.map((callback) => IntrospectedCallback.fromXML(callback, this, options))
|
|
418
451
|
.filter(importConflicts)
|
|
419
|
-
.forEach((c) =>
|
|
452
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
420
453
|
}
|
|
421
454
|
if (ns['glib:boxed']) {
|
|
422
455
|
ns['glib:boxed']
|
|
423
456
|
?.filter(isIntrospectable)
|
|
424
457
|
.map((boxed) => new IntrospectedAlias({
|
|
425
458
|
name: boxed.$['glib:name'],
|
|
426
|
-
namespace:
|
|
459
|
+
namespace: this,
|
|
427
460
|
type: new NullableType(ObjectType),
|
|
428
461
|
}))
|
|
429
|
-
.forEach((c) =>
|
|
462
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
430
463
|
}
|
|
431
464
|
// Bitfield is a type of enum
|
|
432
465
|
if (ns.bitfield) {
|
|
433
466
|
ns.bitfield
|
|
434
467
|
?.filter(isIntrospectable)
|
|
435
|
-
.map((field) => IntrospectedEnum.fromXML(field,
|
|
436
|
-
.forEach((c) =>
|
|
468
|
+
.map((field) => IntrospectedEnum.fromXML(field, this, options, true))
|
|
469
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
437
470
|
}
|
|
438
471
|
// The `enum_constants` map maps the C identifiers (GTK_BUTTON_TYPE_Y)
|
|
439
472
|
// to the name of the enum (Button) to resolve references (Gtk.Button.Y)
|
|
440
|
-
Array.from(
|
|
473
|
+
Array.from(this.members.values())
|
|
441
474
|
.filter((m) => m instanceof IntrospectedEnum)
|
|
442
475
|
.forEach((m) => {
|
|
443
476
|
m.members.forEach((member) => {
|
|
444
|
-
|
|
477
|
+
this.enum_constants.set(member.c_identifier, [m.name, member.name]);
|
|
445
478
|
});
|
|
446
479
|
});
|
|
447
480
|
// Get the requested classes
|
|
448
481
|
if (ns.class) {
|
|
449
482
|
ns.class
|
|
450
483
|
?.filter(isIntrospectable)
|
|
451
|
-
.map((klass) => IntrospectedClass.fromXML(klass,
|
|
484
|
+
.map((klass) => IntrospectedClass.fromXML(klass, this, options))
|
|
452
485
|
.filter(importConflicts)
|
|
453
|
-
.forEach((c) =>
|
|
486
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
454
487
|
}
|
|
455
488
|
if (ns.record) {
|
|
456
489
|
ns.record
|
|
457
490
|
?.filter(isIntrospectable)
|
|
458
|
-
.map((record) => IntrospectedRecord.fromXML(record,
|
|
491
|
+
.map((record) => IntrospectedRecord.fromXML(record, this, options))
|
|
459
492
|
.filter(importConflicts)
|
|
460
|
-
.forEach((c) =>
|
|
493
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
461
494
|
}
|
|
462
495
|
if (ns.union) {
|
|
463
496
|
ns.union
|
|
464
497
|
?.filter(isIntrospectable)
|
|
465
|
-
.map((union) => IntrospectedRecord.fromXML(union,
|
|
498
|
+
.map((union) => IntrospectedRecord.fromXML(union, this, options))
|
|
466
499
|
.filter(importConflicts)
|
|
467
|
-
.forEach((c) =>
|
|
500
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
468
501
|
}
|
|
469
502
|
if (ns.interface) {
|
|
470
503
|
ns.interface
|
|
471
|
-
?.map((inter) => IntrospectedInterface.fromXML(inter,
|
|
504
|
+
?.map((inter) => IntrospectedInterface.fromXML(inter, this, options))
|
|
472
505
|
.filter(importConflicts)
|
|
473
|
-
.forEach((c) =>
|
|
506
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
474
507
|
}
|
|
475
508
|
if (ns.alias) {
|
|
476
509
|
ns.alias
|
|
@@ -481,7 +514,7 @@ export class GirModule {
|
|
|
481
514
|
?.filter((t) => !!(t && t.$.name))
|
|
482
515
|
.map((t) => {
|
|
483
516
|
if (t.$.name &&
|
|
484
|
-
!
|
|
517
|
+
!this.hasSymbol(t.$.name) &&
|
|
485
518
|
!isPrimitiveType(t.$.name) &&
|
|
486
519
|
!t.$.name.includes('.')) {
|
|
487
520
|
return { $: { name: 'unknown', 'c:type': 'unknown' } };
|
|
@@ -490,38 +523,12 @@ export class GirModule {
|
|
|
490
523
|
});
|
|
491
524
|
return b;
|
|
492
525
|
})
|
|
493
|
-
.map((alias) => IntrospectedAlias.fromXML(alias,
|
|
526
|
+
.map((alias) => IntrospectedAlias.fromXML(alias, this, options))
|
|
494
527
|
.filter((alias) => alias != null)
|
|
495
|
-
.forEach((c) =>
|
|
496
|
-
}
|
|
497
|
-
building.namespace = building.ns.name;
|
|
498
|
-
building.version = building.ns.version;
|
|
499
|
-
building.packageName = `${building.namespace}-${building.version}`;
|
|
500
|
-
building.libraryVersion = new LibraryVersion(ns.constant, building.version);
|
|
501
|
-
building.transformation = new Transformation(config);
|
|
502
|
-
building.log = new Logger(config.verbose, building.packageName || 'GirModule');
|
|
503
|
-
building.importNamespace = building.transformation.transformModuleNamespaceName(building.packageName);
|
|
504
|
-
building.importName = building.transformation.transformImportName(building.packageName);
|
|
505
|
-
building.symTable = new SymTable(building.config, building.packageName, building.namespace);
|
|
506
|
-
return building;
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* Start processing the typescript data
|
|
510
|
-
*/
|
|
511
|
-
start(girModules) {
|
|
512
|
-
// GObject and Gio are following the version of GLib
|
|
513
|
-
if (this.namespace === 'GObject' || this.namespace === 'Gio') {
|
|
514
|
-
const glibModule = girModules.find((girModule) => girModule.namespace === 'GLib');
|
|
515
|
-
if (glibModule) {
|
|
516
|
-
this.libraryVersion = glibModule.libraryVersion;
|
|
517
|
-
}
|
|
528
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
518
529
|
}
|
|
519
530
|
}
|
|
520
531
|
}
|
|
521
|
-
export const isIntrospectable = (e) => !e || !e.$ || !e.$.introspectable || e.$.introspectable === '1';
|
|
522
|
-
export const isDeprecated = (e) => e && e.$ && e.$.deprecated === '1';
|
|
523
|
-
export const deprecatedVersion = (e) => e?.$?.['deprecated-version'];
|
|
524
|
-
export const introducedVersion = (e) => e?.$?.version;
|
|
525
532
|
export function promisifyNamespaceFunctions(namespace) {
|
|
526
533
|
return namespace.members.forEach((node) => {
|
|
527
534
|
if (!(node instanceof IntrospectedFunction))
|