@ts-for-gir/lib 4.0.0-beta.1 → 4.0.0-beta.10
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 +147 -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,68 +103,48 @@ 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
146
|
return transitiveDependencies;
|
|
111
147
|
}
|
|
112
|
-
getTsDoc(girDoc) {
|
|
113
|
-
const tsDoc = {
|
|
114
|
-
text: '',
|
|
115
|
-
tags: [],
|
|
116
|
-
};
|
|
117
|
-
if (girDoc.doc?.[0]?._) {
|
|
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;
|
|
129
|
-
}
|
|
130
|
-
tags.push({
|
|
131
|
-
tagName: girTypeName,
|
|
132
|
-
paramName: '',
|
|
133
|
-
text: '',
|
|
134
|
-
});
|
|
135
|
-
return tags;
|
|
136
|
-
}
|
|
137
148
|
getTsDocReturnTags(girElement) {
|
|
138
149
|
const girReturnValue = girElement?.returnTypeDoc;
|
|
139
150
|
if (!girReturnValue) {
|
|
@@ -200,58 +211,58 @@ export class GirModule {
|
|
|
200
211
|
hasImport(name) {
|
|
201
212
|
return this.dependencies.some((dep) => dep.importName === name);
|
|
202
213
|
}
|
|
203
|
-
_getImport(
|
|
204
|
-
if (
|
|
214
|
+
_getImport(namespace) {
|
|
215
|
+
if (namespace === this.namespace) {
|
|
205
216
|
return this;
|
|
206
217
|
}
|
|
207
|
-
const dep = this.dependencies
|
|
208
|
-
this.transitiveDependencies.find((dep) => dep.namespace ===
|
|
218
|
+
const dep = this.dependencies?.find((dep) => dep.namespace === namespace) ??
|
|
219
|
+
this.transitiveDependencies.find((dep) => dep.namespace === namespace);
|
|
209
220
|
// Handle finding imports via their other prefixes
|
|
210
221
|
if (!dep) {
|
|
211
|
-
this.log.info(`Failed to find namespace ${
|
|
222
|
+
this.log.info(`Failed to find namespace ${namespace} in dependencies, resolving via c:prefixes`);
|
|
212
223
|
// TODO: It might make more sense to move this conversion _before_
|
|
213
224
|
// the _getImport call.
|
|
214
|
-
const resolvedNamespaces = this.dependencyManager.namespacesForPrefix(
|
|
225
|
+
const resolvedNamespaces = this.dependencyManager.namespacesForPrefix(namespace);
|
|
215
226
|
if (resolvedNamespaces.length > 0) {
|
|
216
|
-
this.log.info(`Found namespaces for prefix ${
|
|
227
|
+
this.log.info(`Found namespaces for prefix ${namespace}: ${resolvedNamespaces.map((r) => `${r.namespace} (${r.version})`).join(', ')}`);
|
|
217
228
|
}
|
|
218
229
|
for (const resolvedNamespace of resolvedNamespaces) {
|
|
219
|
-
if (resolvedNamespace.
|
|
230
|
+
if (resolvedNamespace.namespace === this.namespace && resolvedNamespace.version === this.version) {
|
|
220
231
|
return this;
|
|
221
232
|
}
|
|
222
|
-
const dep = this.dependencies
|
|
223
|
-
this.transitiveDependencies.find((dep) => dep.namespace === resolvedNamespace.
|
|
233
|
+
const dep = this.dependencies?.find((dep) => dep.namespace === resolvedNamespace.namespace && dep.version === resolvedNamespace.version) ??
|
|
234
|
+
this.transitiveDependencies.find((dep) => dep.namespace === resolvedNamespace.namespace && dep.version === resolvedNamespace.version);
|
|
224
235
|
if (dep) {
|
|
225
|
-
return this.parent.namespace(resolvedNamespace.
|
|
236
|
+
return this.parent.namespace(resolvedNamespace.namespace, dep.version);
|
|
226
237
|
}
|
|
227
238
|
}
|
|
228
239
|
}
|
|
229
240
|
let version = dep?.version;
|
|
230
241
|
if (!version) {
|
|
231
|
-
version = this.parent.assertDefaultVersionOf(
|
|
242
|
+
version = this.parent.assertDefaultVersionOf(namespace);
|
|
232
243
|
}
|
|
233
|
-
return this.parent.namespace(
|
|
244
|
+
return this.parent.namespace(namespace, version);
|
|
234
245
|
}
|
|
235
|
-
getInstalledImport(
|
|
236
|
-
if (
|
|
246
|
+
getInstalledImport(_namespace) {
|
|
247
|
+
if (_namespace === this.namespace) {
|
|
237
248
|
return this;
|
|
238
249
|
}
|
|
239
|
-
const dep = this.dependencies
|
|
240
|
-
this.transitiveDependencies.find((dep) => dep.namespace ===
|
|
250
|
+
const dep = this.dependencies?.find((dep) => dep.namespace === _namespace) ??
|
|
251
|
+
this.transitiveDependencies.find((dep) => dep.namespace === _namespace);
|
|
241
252
|
let version = dep?.version;
|
|
242
253
|
if (!version) {
|
|
243
|
-
version = this.parent.defaultVersionOf(
|
|
254
|
+
version = this.parent.defaultVersionOf(_namespace) ?? undefined;
|
|
244
255
|
}
|
|
245
256
|
if (!version) {
|
|
246
257
|
return null;
|
|
247
258
|
}
|
|
248
|
-
const namespace = this.parent.namespace(
|
|
259
|
+
const namespace = this.parent.namespace(_namespace, version);
|
|
249
260
|
return namespace;
|
|
250
261
|
}
|
|
251
|
-
assertInstalledImport(
|
|
252
|
-
const namespace = this._getImport(
|
|
262
|
+
assertInstalledImport(_namespace) {
|
|
263
|
+
const namespace = this._getImport(_namespace);
|
|
253
264
|
if (!namespace) {
|
|
254
|
-
throw new Error(`Failed to import ${
|
|
265
|
+
throw new Error(`Failed to import ${_namespace} in ${this.namespace}, not installed or accessible.`);
|
|
255
266
|
}
|
|
256
267
|
return namespace;
|
|
257
268
|
}
|
|
@@ -282,7 +293,7 @@ export class GirModule {
|
|
|
282
293
|
assertClass(name) {
|
|
283
294
|
const clazz = this.getClass(name);
|
|
284
295
|
if (!clazz) {
|
|
285
|
-
throw new Error(`Class ${name} does not exist in namespace ${this.
|
|
296
|
+
throw new Error(`Class ${name} does not exist in namespace ${this.namespace}.`);
|
|
286
297
|
}
|
|
287
298
|
return clazz;
|
|
288
299
|
}
|
|
@@ -342,22 +353,17 @@ export class GirModule {
|
|
|
342
353
|
this.__dts__references ??= [];
|
|
343
354
|
this.__dts__references.push(reference);
|
|
344
355
|
}
|
|
345
|
-
static load(
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
356
|
+
static async load(dependency, config, registry) {
|
|
357
|
+
const girXML = dependency.girXML;
|
|
358
|
+
const ns = girXML?.repository[0]?.namespace?.[0];
|
|
359
|
+
if (!girXML) {
|
|
360
|
+
throw new Error(`Failed to load gir xml of ${dependency.packageName}`);
|
|
361
|
+
}
|
|
362
|
+
if (!ns) {
|
|
363
|
+
throw new Error(`Missing namespace in ${girXML.repository[0].package[0].$.name}`);
|
|
364
|
+
}
|
|
349
365
|
const modName = ns.$['name'];
|
|
350
366
|
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
367
|
if (!modName) {
|
|
362
368
|
throw new Error('Invalid GIR file: no namespace name specified.');
|
|
363
369
|
}
|
|
@@ -365,112 +371,130 @@ export class GirModule {
|
|
|
365
371
|
throw new Error('Invalid GIR file: no version name specified.');
|
|
366
372
|
}
|
|
367
373
|
const c_prefix = ns.$?.['c:identifier-prefixes']?.split(',') ?? [];
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
const building = new GirModule(repo.repository[0], modName, version, c_prefix, config);
|
|
374
|
+
const building = new GirModule(dependency, c_prefix, config);
|
|
375
|
+
await building.initDependencies();
|
|
372
376
|
building.parent = registry;
|
|
373
377
|
// Set the namespace object here to prevent re-parsing the namespace if
|
|
374
378
|
// another namespace imports it.
|
|
375
379
|
registry.register(building);
|
|
376
|
-
const prefixes =
|
|
380
|
+
const prefixes = girXML.repository[0]?.$?.['c:identifier-prefixes']?.split(',');
|
|
377
381
|
const unknownPrefixes = prefixes?.filter((pre) => pre !== modName);
|
|
378
382
|
if (unknownPrefixes && unknownPrefixes.length > 0) {
|
|
379
|
-
|
|
383
|
+
Logger.log(`Found additional prefixes for ${modName}: ${unknownPrefixes.join(', ')}`);
|
|
380
384
|
building.prefixes.push(...unknownPrefixes);
|
|
381
385
|
}
|
|
386
|
+
building.transformation = Transformation.getSingleton(config);
|
|
387
|
+
building.log = new Logger(config.verbose, `GirModule(${building.packageName})`);
|
|
388
|
+
return building;
|
|
389
|
+
}
|
|
390
|
+
/** Start to parse all the data from the XML we need for the typescript generation */
|
|
391
|
+
parse() {
|
|
392
|
+
this.log.debug(`Parsing ${this.dependency.packageName}...`);
|
|
393
|
+
const girXML = this.dependency.girXML;
|
|
394
|
+
const ns = girXML?.repository[0]?.namespace?.[0];
|
|
395
|
+
const options = {
|
|
396
|
+
loadDocs: !this.config.noComments,
|
|
397
|
+
propertyCase: 'both',
|
|
398
|
+
verbose: this.config.verbose,
|
|
399
|
+
};
|
|
400
|
+
if (!girXML) {
|
|
401
|
+
throw new Error(`Failed to load gir xml of ${this.dependency.packageName}`);
|
|
402
|
+
}
|
|
403
|
+
if (!ns) {
|
|
404
|
+
throw new Error(`Missing namespace in ${girXML.repository[0].package[0].$.name}`);
|
|
405
|
+
}
|
|
382
406
|
const importConflicts = (el) => {
|
|
383
|
-
return !
|
|
407
|
+
return !this.hasImport(el.name);
|
|
384
408
|
};
|
|
385
409
|
if (ns.enumeration) {
|
|
386
410
|
// Get the requested enums
|
|
387
411
|
ns.enumeration
|
|
388
412
|
?.map((enumeration) => {
|
|
389
413
|
if (enumeration.$['glib:error-domain']) {
|
|
390
|
-
return IntrospectedError.fromXML(enumeration,
|
|
414
|
+
return IntrospectedError.fromXML(enumeration, this, options);
|
|
391
415
|
}
|
|
392
416
|
else {
|
|
393
|
-
return IntrospectedEnum.fromXML(enumeration,
|
|
417
|
+
return IntrospectedEnum.fromXML(enumeration, this, options);
|
|
394
418
|
}
|
|
395
419
|
})
|
|
396
|
-
.forEach((c) =>
|
|
420
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
397
421
|
}
|
|
398
422
|
// Constants
|
|
399
423
|
if (ns.constant) {
|
|
400
424
|
ns.constant
|
|
401
425
|
?.filter(isIntrospectable)
|
|
402
|
-
.map((constant) => IntrospectedConstant.fromXML(constant,
|
|
426
|
+
.map((constant) => IntrospectedConstant.fromXML(constant, this, options))
|
|
403
427
|
.filter(importConflicts)
|
|
404
|
-
.forEach((c) =>
|
|
428
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
405
429
|
}
|
|
406
430
|
// Get the requested functions
|
|
407
431
|
if (ns.function) {
|
|
408
432
|
ns.function
|
|
409
433
|
?.filter(isIntrospectable)
|
|
410
|
-
.map((func) => IntrospectedFunction.fromXML(func,
|
|
434
|
+
.map((func) => IntrospectedFunction.fromXML(func, this, options))
|
|
411
435
|
.filter(importConflicts)
|
|
412
|
-
.forEach((c) =>
|
|
436
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
413
437
|
}
|
|
414
438
|
if (ns.callback) {
|
|
415
439
|
ns.callback
|
|
416
440
|
?.filter(isIntrospectable)
|
|
417
|
-
.map((callback) => IntrospectedCallback.fromXML(callback,
|
|
441
|
+
.map((callback) => IntrospectedCallback.fromXML(callback, this, options))
|
|
418
442
|
.filter(importConflicts)
|
|
419
|
-
.forEach((c) =>
|
|
443
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
420
444
|
}
|
|
421
445
|
if (ns['glib:boxed']) {
|
|
422
446
|
ns['glib:boxed']
|
|
423
447
|
?.filter(isIntrospectable)
|
|
424
448
|
.map((boxed) => new IntrospectedAlias({
|
|
425
449
|
name: boxed.$['glib:name'],
|
|
426
|
-
namespace:
|
|
450
|
+
namespace: this,
|
|
427
451
|
type: new NullableType(ObjectType),
|
|
428
452
|
}))
|
|
429
|
-
.forEach((c) =>
|
|
453
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
430
454
|
}
|
|
431
455
|
// Bitfield is a type of enum
|
|
432
456
|
if (ns.bitfield) {
|
|
433
457
|
ns.bitfield
|
|
434
458
|
?.filter(isIntrospectable)
|
|
435
|
-
.map((field) => IntrospectedEnum.fromXML(field,
|
|
436
|
-
.forEach((c) =>
|
|
459
|
+
.map((field) => IntrospectedEnum.fromXML(field, this, options, true))
|
|
460
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
437
461
|
}
|
|
438
462
|
// The `enum_constants` map maps the C identifiers (GTK_BUTTON_TYPE_Y)
|
|
439
463
|
// to the name of the enum (Button) to resolve references (Gtk.Button.Y)
|
|
440
|
-
Array.from(
|
|
464
|
+
Array.from(this.members.values())
|
|
441
465
|
.filter((m) => m instanceof IntrospectedEnum)
|
|
442
466
|
.forEach((m) => {
|
|
443
467
|
m.members.forEach((member) => {
|
|
444
|
-
|
|
468
|
+
this.enum_constants.set(member.c_identifier, [m.name, member.name]);
|
|
445
469
|
});
|
|
446
470
|
});
|
|
447
471
|
// Get the requested classes
|
|
448
472
|
if (ns.class) {
|
|
449
473
|
ns.class
|
|
450
474
|
?.filter(isIntrospectable)
|
|
451
|
-
.map((klass) => IntrospectedClass.fromXML(klass,
|
|
475
|
+
.map((klass) => IntrospectedClass.fromXML(klass, this, options))
|
|
452
476
|
.filter(importConflicts)
|
|
453
|
-
.forEach((c) =>
|
|
477
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
454
478
|
}
|
|
455
479
|
if (ns.record) {
|
|
456
480
|
ns.record
|
|
457
481
|
?.filter(isIntrospectable)
|
|
458
|
-
.map((record) => IntrospectedRecord.fromXML(record,
|
|
482
|
+
.map((record) => IntrospectedRecord.fromXML(record, this, options))
|
|
459
483
|
.filter(importConflicts)
|
|
460
|
-
.forEach((c) =>
|
|
484
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
461
485
|
}
|
|
462
486
|
if (ns.union) {
|
|
463
487
|
ns.union
|
|
464
488
|
?.filter(isIntrospectable)
|
|
465
|
-
.map((union) => IntrospectedRecord.fromXML(union,
|
|
489
|
+
.map((union) => IntrospectedRecord.fromXML(union, this, options))
|
|
466
490
|
.filter(importConflicts)
|
|
467
|
-
.forEach((c) =>
|
|
491
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
468
492
|
}
|
|
469
493
|
if (ns.interface) {
|
|
470
494
|
ns.interface
|
|
471
|
-
?.map((inter) => IntrospectedInterface.fromXML(inter,
|
|
495
|
+
?.map((inter) => IntrospectedInterface.fromXML(inter, this, options))
|
|
472
496
|
.filter(importConflicts)
|
|
473
|
-
.forEach((c) =>
|
|
497
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
474
498
|
}
|
|
475
499
|
if (ns.alias) {
|
|
476
500
|
ns.alias
|
|
@@ -481,7 +505,7 @@ export class GirModule {
|
|
|
481
505
|
?.filter((t) => !!(t && t.$.name))
|
|
482
506
|
.map((t) => {
|
|
483
507
|
if (t.$.name &&
|
|
484
|
-
!
|
|
508
|
+
!this.hasSymbol(t.$.name) &&
|
|
485
509
|
!isPrimitiveType(t.$.name) &&
|
|
486
510
|
!t.$.name.includes('.')) {
|
|
487
511
|
return { $: { name: 'unknown', 'c:type': 'unknown' } };
|
|
@@ -490,38 +514,12 @@ export class GirModule {
|
|
|
490
514
|
});
|
|
491
515
|
return b;
|
|
492
516
|
})
|
|
493
|
-
.map((alias) => IntrospectedAlias.fromXML(alias,
|
|
517
|
+
.map((alias) => IntrospectedAlias.fromXML(alias, this, options))
|
|
494
518
|
.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
|
-
}
|
|
519
|
+
.forEach((c) => this.members.set(c.name, c));
|
|
518
520
|
}
|
|
519
521
|
}
|
|
520
522
|
}
|
|
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
523
|
export function promisifyNamespaceFunctions(namespace) {
|
|
526
524
|
return namespace.members.forEach((node) => {
|
|
527
525
|
if (!(node instanceof IntrospectedFunction))
|