@ts-for-gir/lib 3.0.0-beta.12 → 3.0.1
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 +7 -3
- package/lib/constants.js +14 -2
- package/lib/constants.js.map +1 -1
- package/lib/dependency-manager.d.ts +52 -3
- package/lib/dependency-manager.js +138 -18
- package/lib/dependency-manager.js.map +1 -1
- package/lib/gir-module.d.ts +12 -5
- package/lib/gir-module.js +25 -8
- package/lib/gir-module.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/injection/classes/gjs/index.js +3 -3
- package/lib/injection/classes/index.js +1 -1
- package/lib/injection/classes/node-gtk/index.js +8 -8
- package/lib/messages.d.ts +0 -2
- package/lib/messages.js +1 -3
- package/lib/messages.js.map +1 -1
- package/lib/package-data-parser.d.ts +13 -0
- package/lib/package-data-parser.js +67 -0
- package/lib/package-data-parser.js.map +1 -0
- package/lib/package-data.d.ts +9 -0
- package/lib/package-data.js +41 -0
- package/lib/package-data.js.map +1 -0
- package/lib/symtable.js +2 -1
- package/lib/symtable.js.map +1 -1
- package/lib/template-processor.d.ts +59 -19
- package/lib/template-processor.js +128 -41
- package/lib/template-processor.js.map +1 -1
- package/lib/transformation.d.ts +2 -1
- package/lib/transformation.js +44 -26
- package/lib/transformation.js.map +1 -1
- package/lib/types/construct-name.d.ts +1 -1
- package/lib/types/dependency.d.ts +17 -2
- package/lib/types/generate-config.d.ts +9 -2
- package/lib/types/index.d.ts +5 -0
- package/lib/types/index.js +5 -0
- package/lib/types/index.js.map +1 -1
- package/lib/types/module-type.d.ts +1 -1
- package/lib/types/package-data-parsed.d.ts +28 -0
- package/lib/types/package-data-parsed.js +2 -0
- package/lib/types/package-data-parsed.js.map +1 -0
- package/lib/types/package-data.d.ts +23 -0
- package/lib/types/package-data.js +2 -0
- package/lib/types/package-data.js.map +1 -0
- package/lib/types/package-section-parsed.d.ts +8 -0
- package/lib/types/package-section-parsed.js +2 -0
- package/lib/types/package-section-parsed.js.map +1 -0
- package/lib/types/package-section.d.ts +8 -0
- package/lib/types/package-section.js +2 -0
- package/lib/types/package-section.js.map +1 -0
- package/lib/types/parsed-package-data.d.ts +6 -0
- package/lib/types/parsed-package-data.js +2 -0
- package/lib/types/parsed-package-data.js.map +1 -0
- package/lib/types/template-data.d.ts +2 -1
- package/lib/types/transformation-case.d.ts +1 -1
- package/lib/types/transformations.d.ts +1 -1
- package/lib/types/user-config.d.ts +6 -2
- package/lib/utils.d.ts +31 -16
- package/lib/utils.js +68 -30
- package/lib/utils.js.map +1 -1
- package/package.json +22 -20
- package/packages.xml +1213 -0
- package/templates/README.md +102 -0
- package/templates/gjs/README-GJS.md +109 -0
- package/templates/gjs/ambient.d.ts +59 -0
- package/templates/gjs/cairo-1.0.d.ts +9 -0
- package/templates/gjs/cairo.d.ts +8 -0
- package/templates/gjs/cairo.js +11 -0
- package/templates/gjs/gettext.d.ts +41 -0
- package/templates/gjs/gettext.js +11 -0
- package/templates/{Gjs/Gio-2.0.d.ts → gjs/gio-2.0.d.ts} +1 -1
- package/templates/{Gjs/index.d.ts → gjs/gjs.d.ts} +221 -58
- package/templates/gjs/gjs.js +10 -0
- package/templates/{Gjs/GObject-2.0.d.ts → gjs/gobject-2.0.d.ts} +1 -1
- package/templates/gjs/module-ambient.d.ts +31 -0
- package/templates/gjs/module-import.d.ts +33 -0
- package/templates/gjs/module.append.d.ts +1 -0
- package/templates/gjs/module.d.ts +12 -0
- package/templates/gjs/module.js +17 -0
- package/templates/gjs/system.d.ts +32 -0
- package/templates/gjs/system.js +11 -0
- package/templates/gjs/tsconfig.alias.json +12 -0
- package/templates/node-gtk/README-NODE-GTK.md +71 -0
- package/templates/node-gtk/ambient.d.ts +19 -0
- package/templates/node-gtk/module-import.d.ts +29 -0
- package/templates/node-gtk/module.append.d.ts +1 -0
- package/templates/node-gtk/module.d.ts +4 -0
- package/templates/node-gtk/module.js +2 -1
- package/templates/node-gtk/node-gtk.d.ts +25 -0
- package/templates/node-gtk/{index.js → node-gtk.js} +0 -2
- package/templates/package.json +173 -0
- package/templates/tsconfig.doc.json +30 -0
- package/lib/injection/classes/GooCanvas-2.0.d.ts +0 -2
- package/lib/injection/classes/GooCanvas-2.0.js +0 -26
- package/lib/injection/classes/GooCanvas-2.0.js.map +0 -1
- package/lib/injection/classes/GooCanvas-3.0.d.ts +0 -2
- package/lib/injection/classes/GooCanvas-3.0.js +0 -26
- package/lib/injection/classes/GooCanvas-3.0.js.map +0 -1
- package/lib/injection/classes/GooCanvas-x.0.d.ts +0 -2
- package/lib/injection/classes/GooCanvas-x.0.js +0 -26
- package/lib/injection/classes/GooCanvas-x.0.js.map +0 -1
- package/lib/injection/classes/gjs/GooCanvas-2.0.d.ts +0 -2
- package/lib/injection/classes/gjs/GooCanvas-2.0.js +0 -14
- package/lib/injection/classes/gjs/GooCanvas-2.0.js.map +0 -1
- package/lib/types/library-version.d.ts +0 -7
- package/lib/types/library-version.js +0 -2
- package/lib/types/library-version.js.map +0 -1
- package/templates/Gjs/Gjs.d.ts +0 -204
- package/templates/Gjs/Gjs.js +0 -21
- package/templates/Gjs/GnomeShell.d.ts +0 -154
- package/templates/Gjs/GnomeShell.js +0 -10
- package/templates/Gjs/index.js +0 -4
- package/templates/Gjs/misc/dbusUtils.d.ts +0 -15
- package/templates/Gjs/misc/dbusUtils.js +0 -6
- package/templates/Gjs/misc/extensionUtils.d.ts +0 -99
- package/templates/Gjs/misc/extensionUtils.js +0 -6
- package/templates/Gjs/misc/fileUtils.d.ts +0 -51
- package/templates/Gjs/misc/fileUtils.js +0 -6
- package/templates/Gjs/misc/gnomeSession.d.ts +0 -74
- package/templates/Gjs/misc/gnomeSession.js +0 -6
- package/templates/Gjs/misc/parentalControlsManager.d.ts +0 -42
- package/templates/Gjs/misc/parentalControlsManager.js +0 -6
- package/templates/Gjs/misc/signals.d.ts +0 -15
- package/templates/Gjs/misc/signals.js +0 -6
- package/templates/Gjs/module.d.ts +0 -6
- package/templates/Gjs/module.js +0 -16
- package/templates/Gjs/tsconfig.alias.json +0 -10
- package/templates/Gjs/ui/accessDialog.d.ts +0 -19
- package/templates/Gjs/ui/accessDialog.js +0 -6
- package/templates/Gjs/ui/altTab.d.ts +0 -124
- package/templates/Gjs/ui/altTab.js +0 -6
- package/templates/Gjs/ui/animation.d.ts +0 -58
- package/templates/Gjs/ui/animation.js +0 -6
- package/templates/Gjs/ui/appDisplay.d.ts +0 -204
- package/templates/Gjs/ui/appDisplay.js +0 -6
- package/templates/Gjs/ui/appFavorites.d.ts +0 -34
- package/templates/Gjs/ui/appFavorites.js +0 -6
- package/templates/Gjs/ui/appMenu.d.ts +0 -74
- package/templates/Gjs/ui/appMenu.js +0 -6
- package/templates/Gjs/ui/audioDeviceSelection.d.ts +0 -51
- package/templates/Gjs/ui/audioDeviceSelection.js +0 -6
- package/templates/Gjs/ui/background.d.ts +0 -255
- package/templates/Gjs/ui/background.js +0 -5
- package/templates/Gjs/ui/backgroundMenu.d.ts +0 -19
- package/templates/Gjs/ui/backgroundMenu.js +0 -5
- package/templates/Gjs/ui/barLevel.d.ts +0 -42
- package/templates/Gjs/ui/barLevel.js +0 -5
- package/templates/Gjs/ui/boxpointer.d.ts +0 -103
- package/templates/Gjs/ui/boxpointer.js +0 -5
- package/templates/Gjs/ui/calendar.d.ts +0 -261
- package/templates/Gjs/ui/calendar.js +0 -5
- package/templates/Gjs/ui/checkBox.d.ts +0 -22
- package/templates/Gjs/ui/checkBox.js +0 -5
- package/templates/Gjs/ui/closeDialog.d.ts +0 -40
- package/templates/Gjs/ui/closeDialog.js +0 -5
- package/templates/Gjs/ui/components/__init__.d.ts +0 -9
- package/templates/Gjs/ui/components/__init__.js +0 -6
- package/templates/Gjs/ui/components/automountManager.d.ts +0 -8
- package/templates/Gjs/ui/components/automountManager.js +0 -6
- package/templates/Gjs/ui/components/autorunManager.d.ts +0 -8
- package/templates/Gjs/ui/components/autorunManager.js +0 -6
- package/templates/Gjs/ui/components/index.d.ts +0 -6
- package/templates/Gjs/ui/components/index.js +0 -6
- package/templates/Gjs/ui/components/keyring.d.ts +0 -19
- package/templates/Gjs/ui/components/keyring.js +0 -6
- package/templates/Gjs/ui/components/networkAgent.d.ts +0 -10
- package/templates/Gjs/ui/components/networkAgent.js +0 -6
- package/templates/Gjs/ui/components/polkitAgent.d.ts +0 -19
- package/templates/Gjs/ui/components/polkitAgent.js +0 -6
- package/templates/Gjs/ui/components/telepathyClient.d.ts +0 -10
- package/templates/Gjs/ui/components/telepathyClient.js +0 -6
- package/templates/Gjs/ui/dialog.d.ts +0 -78
- package/templates/Gjs/ui/dialog.js +0 -6
- package/templates/Gjs/ui/dnd.d.ts +0 -127
- package/templates/Gjs/ui/dnd.js +0 -6
- package/templates/Gjs/ui/iconGrid.d.ts +0 -172
- package/templates/Gjs/ui/iconGrid.js +0 -6
- package/templates/Gjs/ui/layout.d.ts +0 -311
- package/templates/Gjs/ui/layout.js +0 -6
- package/templates/Gjs/ui/main.d.ts +0 -215
- package/templates/Gjs/ui/main.js +0 -6
- package/templates/Gjs/ui/messageList.d.ts +0 -113
- package/templates/Gjs/ui/messageList.js +0 -6
- package/templates/Gjs/ui/messageTray.d.ts +0 -423
- package/templates/Gjs/ui/messageTray.js +0 -6
- package/templates/Gjs/ui/modalDialog.d.ts +0 -96
- package/templates/Gjs/ui/modalDialog.js +0 -6
- package/templates/Gjs/ui/mpris.d.ts +0 -78
- package/templates/Gjs/ui/mpris.js +0 -6
- package/templates/Gjs/ui/notificationDaemon.d.ts +0 -5
- package/templates/Gjs/ui/notificationDaemon.js +0 -6
- package/templates/Gjs/ui/panel.d.ts +0 -65
- package/templates/Gjs/ui/panel.js +0 -6
- package/templates/Gjs/ui/panelMenu.d.ts +0 -51
- package/templates/Gjs/ui/panelMenu.js +0 -6
- package/templates/Gjs/ui/popupMenu.d.ts +0 -228
- package/templates/Gjs/ui/popupMenu.js +0 -6
- package/templates/Gjs/ui/ripples.d.ts +0 -44
- package/templates/Gjs/ui/ripples.js +0 -6
- package/templates/Gjs/ui/search.d.ts +0 -158
- package/templates/Gjs/ui/search.js +0 -6
- package/templates/Gjs/ui/switcherPopup.d.ts +0 -107
- package/templates/Gjs/ui/switcherPopup.js +0 -6
- package/templates/Gjs/ui/userWidget.d.ts +0 -13
- package/templates/Gjs/ui/userWidget.js +0 -6
- package/templates/node-gtk/index.d.ts +0 -40
- /package/templates/{Cogl-2.0.d.ts → cogl-2-0.d.ts} +0 -0
- /package/templates/{Granite-1.0.d.ts → granite-1.0.d.ts} +0 -0
- /package/templates/{Granite-7.0.d.ts → granite-7.0.d.ts} +0 -0
- /package/templates/{GstBase-0.10.d.ts → gstbase-0.10.d.ts} +0 -0
- /package/templates/node-gtk/{GObject-2.0.d.ts → gobject-2.0.d.ts} +0 -0
- /package/templates/{RygelServer-2.6.d.ts → rygelserver-2.6.d.ts} +0 -0
package/lib/constants.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LibraryVersion } from './library-version.js';
|
|
2
|
+
import type { Environment } from './types/index.js';
|
|
2
3
|
/**
|
|
3
4
|
* In gjs all classes have a static name property but the classes listed below already have a static name property
|
|
4
5
|
*/
|
|
@@ -9,8 +10,11 @@ export declare const OPT_PARAM_REG_EXP: RegExp;
|
|
|
9
10
|
export declare const NEW_LINE_REG_EXP: RegExp;
|
|
10
11
|
export declare const MAX_CLASS_PARENT_DEPTH = 100;
|
|
11
12
|
export declare const APP_NAME = "ts-for-gir";
|
|
12
|
-
export declare const APP_USAGE = "
|
|
13
|
-
export declare const APP_SOURCE = "https://github.com/gjsify/ts-for-
|
|
13
|
+
export declare const APP_USAGE = "TypeScript type definition generator for GObject introspection GIR files";
|
|
14
|
+
export declare const APP_SOURCE = "https://github.com/gjsify/ts-for-gir";
|
|
15
|
+
export declare const APP_VERSION = "3.0.1";
|
|
16
|
+
export declare const PACKAGE_DESC: (packageName: string, environment: Environment, libraryVersion?: LibraryVersion) => string;
|
|
17
|
+
export declare const PACKAGE_KEYWORDS: (packageName: string, environment: Environment) => string;
|
|
14
18
|
export declare const GENERIC_NAMES: string[];
|
|
15
19
|
export declare const SIGNAL_METHOD_NAMES_GENERAL: string[];
|
|
16
20
|
export declare const SIGNAL_METHOD_NAMES_GJS: string[];
|
package/lib/constants.js
CHANGED
|
@@ -8,8 +8,20 @@ export const OPT_PARAM_REG_EXP = /[0-9a-zA-Z_]*\?:/g;
|
|
|
8
8
|
export const NEW_LINE_REG_EXP = /[\n\r]+/g;
|
|
9
9
|
export const MAX_CLASS_PARENT_DEPTH = 100;
|
|
10
10
|
export const APP_NAME = 'ts-for-gir';
|
|
11
|
-
export const APP_USAGE = '
|
|
12
|
-
export const APP_SOURCE = 'https://github.com/gjsify/ts-for-
|
|
11
|
+
export const APP_USAGE = 'TypeScript type definition generator for GObject introspection GIR files';
|
|
12
|
+
export const APP_SOURCE = 'https://github.com/gjsify/ts-for-gir';
|
|
13
|
+
export const APP_VERSION = '3.0.1';
|
|
14
|
+
export const PACKAGE_DESC = (packageName, environment, libraryVersion) => {
|
|
15
|
+
const envStr = environment === 'node' ? 'Node.js' : 'GJS';
|
|
16
|
+
if (libraryVersion) {
|
|
17
|
+
return `${envStr} TypeScript type definitions for ${packageName}, generated from library version ${libraryVersion.toString()}`;
|
|
18
|
+
}
|
|
19
|
+
return `${envStr} TypeScript type definitions for ${packageName}`;
|
|
20
|
+
};
|
|
21
|
+
export const PACKAGE_KEYWORDS = (packageName, environment) => {
|
|
22
|
+
const envKeywords = environment === 'node' ? '"node", "node-gtk"' : '"GJS"';
|
|
23
|
+
return `"Gir", "TypeScript", "types", "GObject-Introspection", ${envKeywords}, "${packageName}"`;
|
|
24
|
+
};
|
|
13
25
|
export const GENERIC_NAMES = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K'];
|
|
14
26
|
export const SIGNAL_METHOD_NAMES_GENERAL = ['connect', 'emit'];
|
|
15
27
|
export const SIGNAL_METHOD_NAMES_GJS = ['connect_after', 'emit', 'disconnect'];
|
package/lib/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAA;AAE9E,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAA;AAC5C,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAA;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAA;AACpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAA;AAE1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAA;AAEzC,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAA;AACpC,MAAM,CAAC,MAAM,SAAS,GAAG,0EAA0E,CAAA;AACnG,MAAM,CAAC,MAAM,UAAU,GAAG,sCAAsC,CAAA;AAChE,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAA;AAElC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,WAAmB,EAAE,WAAwB,EAAE,cAA+B,EAAE,EAAE;IAC3G,MAAM,MAAM,GAAG,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAA;IACzD,IAAI,cAAc,EAAE;QAChB,OAAO,GAAG,MAAM,oCAAoC,WAAW,oCAAoC,cAAc,CAAC,QAAQ,EAAE,EAAE,CAAA;KACjI;IACD,OAAO,GAAG,MAAM,oCAAoC,WAAW,EAAE,CAAA;AACrE,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,WAAmB,EAAE,WAAwB,EAAE,EAAE;IAC9E,MAAM,WAAW,GAAG,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAA;IAC3E,OAAO,0DAA0D,WAAW,MAAM,WAAW,GAAG,CAAA;AACpG,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAa,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AAEzF,MAAM,CAAC,MAAM,2BAA2B,GAAa,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AACxE,MAAM,CAAC,MAAM,uBAAuB,GAAa,CAAC,eAAe,EAAE,MAAM,EAAE,YAAY,CAAC,CAAA;AACxF,MAAM,CAAC,MAAM,wBAAwB,GAAa,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AAChF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAgB,EAAE,EAAE;IACpD,IAAI,GAAG,KAAK,MAAM,EAAE;QAChB,OAAO,CAAC,GAAG,2BAA2B,EAAE,wBAAwB,CAAC,CAAA;KACpE;IACD,OAAO,CAAC,GAAG,2BAA2B,EAAE,uBAAuB,CAAC,CAAA;AACpE,CAAC,CAAA"}
|
|
@@ -1,17 +1,44 @@
|
|
|
1
1
|
import { Logger } from './logger.js';
|
|
2
|
+
import { Transformation } from './transformation.js';
|
|
2
3
|
import type { Dependency, GenerateConfig, GirInclude } from './types/index.js';
|
|
4
|
+
import type { GirModule } from './gir-module.js';
|
|
3
5
|
export declare class DependencyManager {
|
|
4
6
|
protected readonly config: GenerateConfig;
|
|
5
7
|
protected log: Logger;
|
|
8
|
+
protected transformation: Transformation;
|
|
6
9
|
cache: {
|
|
7
|
-
[
|
|
10
|
+
[packageName: string]: Dependency;
|
|
11
|
+
};
|
|
12
|
+
static instances: {
|
|
13
|
+
[env: string]: DependencyManager;
|
|
8
14
|
};
|
|
9
|
-
static instance: DependencyManager;
|
|
10
15
|
protected constructor(config: GenerateConfig);
|
|
11
16
|
/**
|
|
12
17
|
* Get the DependencyManager singleton instance
|
|
13
18
|
*/
|
|
14
19
|
static getInstance(config: GenerateConfig): DependencyManager;
|
|
20
|
+
/**
|
|
21
|
+
* Get all dependencies in the cache
|
|
22
|
+
* @returns All dependencies in the cache
|
|
23
|
+
*/
|
|
24
|
+
all(): Dependency[];
|
|
25
|
+
/**
|
|
26
|
+
* Get the core dependencies
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
core(): Dependency[];
|
|
30
|
+
createImportProperties(namespace: string, packageName: string): {
|
|
31
|
+
importPath: string;
|
|
32
|
+
importDef: string;
|
|
33
|
+
};
|
|
34
|
+
createImportPath(packageName: string): string;
|
|
35
|
+
createImportDef(namespace: string, importPath: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Get the dependency object by packageName
|
|
38
|
+
* @param packageName The package name (with version affix) of the dependency
|
|
39
|
+
* @returns The dependency object
|
|
40
|
+
*/
|
|
41
|
+
get(packageName: string): Dependency;
|
|
15
42
|
/**
|
|
16
43
|
* Get the dependency object by namespace and version
|
|
17
44
|
* @param namespace The namespace of the dependency
|
|
@@ -19,16 +46,38 @@ export declare class DependencyManager {
|
|
|
19
46
|
* @returns The dependency object
|
|
20
47
|
*/
|
|
21
48
|
get(namespace: string, version: string): Dependency;
|
|
49
|
+
/**
|
|
50
|
+
* Add all dependencies from an array of gir modules
|
|
51
|
+
* @param girModules
|
|
52
|
+
*/
|
|
53
|
+
addAll(girModules: GirModule[]): Dependency[];
|
|
22
54
|
/**
|
|
23
55
|
* Transforms a gir include object array to a dependency object array
|
|
24
56
|
* @param girIncludes - Array of gir includes
|
|
25
57
|
* @returns Array of dependencies
|
|
26
58
|
*/
|
|
27
59
|
fromGirIncludes(girIncludes: GirInclude[]): Dependency[];
|
|
60
|
+
getAllPackageNames(): string[];
|
|
61
|
+
/**
|
|
62
|
+
* Check if multiple dependencies with the given namespace exist in the cache
|
|
63
|
+
* @param namespace The namespace of the dependency
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
hasConflict(namespace: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Check if the given version is the latest version of the dependency
|
|
69
|
+
* @param namespace The namespace of the dependency
|
|
70
|
+
* @param version The version of the dependency
|
|
71
|
+
* @returns
|
|
72
|
+
*/
|
|
73
|
+
isLatestVersion(namespace: string, version: string): boolean;
|
|
28
74
|
/**
|
|
29
|
-
* Find a dependency by it's namespace from the cache
|
|
75
|
+
* Find a dependency by it's namespace from the cache, if multiple versions are found, the latest version is returned
|
|
30
76
|
* @param namespace The namespace of the dependency
|
|
31
77
|
* @returns The dependency object or null if not found
|
|
32
78
|
*/
|
|
33
79
|
find(namespace: string): Dependency | null;
|
|
80
|
+
protected getPseudoPackage(packageName: string): Dependency;
|
|
81
|
+
getGjs(): Dependency;
|
|
82
|
+
getNodeGtk(): Dependency;
|
|
34
83
|
}
|
|
@@ -1,34 +1,82 @@
|
|
|
1
|
-
import { findFileInDirs } from './utils.js';
|
|
1
|
+
import { findFileInDirs, splitModuleName, pascalCase } from './utils.js';
|
|
2
2
|
import { Logger } from './logger.js';
|
|
3
|
-
|
|
3
|
+
import { Transformation } from './transformation.js';
|
|
4
|
+
class DependencyManager {
|
|
4
5
|
config;
|
|
5
6
|
log;
|
|
7
|
+
transformation;
|
|
6
8
|
cache = {};
|
|
7
|
-
static
|
|
9
|
+
static instances = {};
|
|
8
10
|
constructor(config) {
|
|
9
11
|
this.config = config;
|
|
12
|
+
this.transformation = new Transformation(config);
|
|
10
13
|
this.log = new Logger(config.environment, config.verbose, 'DependencyManager');
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
16
|
* Get the DependencyManager singleton instance
|
|
14
17
|
*/
|
|
15
18
|
static getInstance(config) {
|
|
16
|
-
if (this.
|
|
17
|
-
return this.
|
|
19
|
+
if (this.instances[config.environment]) {
|
|
20
|
+
return this.instances[config.environment];
|
|
18
21
|
}
|
|
19
|
-
this.
|
|
20
|
-
return this.
|
|
22
|
+
this.instances[config.environment] = new DependencyManager(config);
|
|
23
|
+
return this.instances[config.environment];
|
|
21
24
|
}
|
|
22
25
|
/**
|
|
23
|
-
* Get
|
|
24
|
-
* @
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
* Get all dependencies in the cache
|
|
27
|
+
* @returns All dependencies in the cache
|
|
28
|
+
*/
|
|
29
|
+
all() {
|
|
30
|
+
return Object.values(this.cache);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get the core dependencies
|
|
34
|
+
* @returns
|
|
27
35
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
core() {
|
|
37
|
+
return [this.get('GObject-2.0'), this.get('GLib-2.0')];
|
|
38
|
+
}
|
|
39
|
+
createImportProperties(namespace, packageName) {
|
|
40
|
+
const importPath = this.createImportPath(packageName);
|
|
41
|
+
const importDef = this.createImportDef(namespace, importPath);
|
|
42
|
+
return {
|
|
43
|
+
importPath,
|
|
44
|
+
importDef,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
createImportPath(packageName) {
|
|
48
|
+
const importName = this.transformation.transformImportName(packageName);
|
|
49
|
+
const importPath = this.config.package ? `${this.config.npmScope}/${importName}` : `./${importName}.js`;
|
|
50
|
+
return importPath;
|
|
51
|
+
}
|
|
52
|
+
createImportDef(namespace, importPath) {
|
|
53
|
+
return this.config.noNamespace
|
|
54
|
+
? `import type * as ${namespace} from '${importPath}'`
|
|
55
|
+
: `import type ${namespace} from '${importPath}';`;
|
|
56
|
+
}
|
|
57
|
+
get(namespaceOrPackageName, version) {
|
|
58
|
+
// Special case for Gjs
|
|
59
|
+
if (namespaceOrPackageName === 'Gjs') {
|
|
60
|
+
return this.getGjs();
|
|
61
|
+
}
|
|
62
|
+
else if (namespaceOrPackageName === 'node-gtk') {
|
|
63
|
+
return this.getNodeGtk();
|
|
64
|
+
}
|
|
65
|
+
let packageName;
|
|
66
|
+
let namespace;
|
|
67
|
+
if (version) {
|
|
68
|
+
packageName = `${namespaceOrPackageName}-${version}`;
|
|
69
|
+
namespace = namespaceOrPackageName;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
packageName = namespaceOrPackageName;
|
|
73
|
+
const { namespace: _namespace, version: _version } = splitModuleName(packageName);
|
|
74
|
+
namespace = _namespace;
|
|
75
|
+
version = _version;
|
|
76
|
+
}
|
|
30
77
|
if (this.cache[packageName]) {
|
|
31
|
-
|
|
78
|
+
const dep = this.cache[packageName];
|
|
79
|
+
return dep;
|
|
32
80
|
}
|
|
33
81
|
const filename = `${packageName}.gir`;
|
|
34
82
|
const { exists, path } = findFileInDirs(this.config.girDirectories, filename);
|
|
@@ -38,11 +86,23 @@ export class DependencyManager {
|
|
|
38
86
|
filename,
|
|
39
87
|
path,
|
|
40
88
|
packageName,
|
|
89
|
+
importName: this.transformation.transformImportName(packageName),
|
|
41
90
|
version,
|
|
91
|
+
...this.createImportProperties(namespace, packageName),
|
|
42
92
|
};
|
|
43
93
|
this.cache[packageName] = dependency;
|
|
44
94
|
return dependency;
|
|
45
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Add all dependencies from an array of gir modules
|
|
98
|
+
* @param girModules
|
|
99
|
+
*/
|
|
100
|
+
addAll(girModules) {
|
|
101
|
+
for (const girModule of girModules) {
|
|
102
|
+
this.get(girModule.namespace, girModule.version || '0.0');
|
|
103
|
+
}
|
|
104
|
+
return this.all();
|
|
105
|
+
}
|
|
46
106
|
/**
|
|
47
107
|
* Transforms a gir include object array to a dependency object array
|
|
48
108
|
* @param girIncludes - Array of gir includes
|
|
@@ -55,13 +115,49 @@ export class DependencyManager {
|
|
|
55
115
|
}
|
|
56
116
|
return dependencies;
|
|
57
117
|
}
|
|
118
|
+
getAllPackageNames() {
|
|
119
|
+
return Object.keys(this.cache);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Check if multiple dependencies with the given namespace exist in the cache
|
|
123
|
+
* @param namespace The namespace of the dependency
|
|
124
|
+
* @returns
|
|
125
|
+
*/
|
|
126
|
+
hasConflict(namespace) {
|
|
127
|
+
const packageNames = this.getAllPackageNames();
|
|
128
|
+
const candidates = packageNames.filter((packageName) => {
|
|
129
|
+
return packageName.startsWith(`${namespace}-`) && this.cache[packageName].namespace === namespace;
|
|
130
|
+
});
|
|
131
|
+
return candidates.length > 1;
|
|
132
|
+
}
|
|
58
133
|
/**
|
|
59
|
-
*
|
|
134
|
+
* Check if the given version is the latest version of the dependency
|
|
135
|
+
* @param namespace The namespace of the dependency
|
|
136
|
+
* @param version The version of the dependency
|
|
137
|
+
* @returns
|
|
138
|
+
*/
|
|
139
|
+
isLatestVersion(namespace, version) {
|
|
140
|
+
const hasConflict = this.hasConflict(namespace);
|
|
141
|
+
if (!hasConflict) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
const latestVersion = this.find(namespace);
|
|
145
|
+
return latestVersion?.version === version;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Find a dependency by it's namespace from the cache, if multiple versions are found, the latest version is returned
|
|
60
149
|
* @param namespace The namespace of the dependency
|
|
61
150
|
* @returns The dependency object or null if not found
|
|
62
151
|
*/
|
|
63
152
|
find(namespace) {
|
|
64
|
-
|
|
153
|
+
// Special case for Gjs
|
|
154
|
+
if (namespace === 'Gjs') {
|
|
155
|
+
return this.getGjs();
|
|
156
|
+
}
|
|
157
|
+
else if (namespace === 'node-gtk') {
|
|
158
|
+
return this.getNodeGtk();
|
|
159
|
+
}
|
|
160
|
+
const packageNames = this.getAllPackageNames();
|
|
65
161
|
const candidates = packageNames.filter((packageName) => {
|
|
66
162
|
return packageName.startsWith(`${namespace}-`) && this.cache[packageName].namespace === namespace;
|
|
67
163
|
});
|
|
@@ -69,10 +165,34 @@ export class DependencyManager {
|
|
|
69
165
|
this.log.warn(`Found multiple versions of ${namespace}: ${candidates.join(', ')}`);
|
|
70
166
|
}
|
|
71
167
|
const latestVersion = candidates.sort().pop();
|
|
72
|
-
if (latestVersion) {
|
|
73
|
-
|
|
168
|
+
if (latestVersion && this.cache[latestVersion]) {
|
|
169
|
+
const dep = this.cache[latestVersion];
|
|
170
|
+
return dep;
|
|
74
171
|
}
|
|
75
172
|
return null;
|
|
76
173
|
}
|
|
174
|
+
getPseudoPackage(packageName) {
|
|
175
|
+
if (this.cache[packageName]) {
|
|
176
|
+
return this.cache[packageName];
|
|
177
|
+
}
|
|
178
|
+
const dep = {
|
|
179
|
+
namespace: pascalCase(packageName),
|
|
180
|
+
exists: true,
|
|
181
|
+
filename: '',
|
|
182
|
+
path: '',
|
|
183
|
+
packageName: packageName,
|
|
184
|
+
importName: this.transformation.transformImportName(packageName),
|
|
185
|
+
version: '0.0',
|
|
186
|
+
...this.createImportProperties(packageName, packageName),
|
|
187
|
+
};
|
|
188
|
+
return dep;
|
|
189
|
+
}
|
|
190
|
+
getGjs() {
|
|
191
|
+
return this.getPseudoPackage('Gjs');
|
|
192
|
+
}
|
|
193
|
+
getNodeGtk() {
|
|
194
|
+
return this.getPseudoPackage('node-gtk');
|
|
195
|
+
}
|
|
77
196
|
}
|
|
197
|
+
export { DependencyManager };
|
|
78
198
|
//# sourceMappingURL=dependency-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency-manager.js","sourceRoot":"","sources":["../src/dependency-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"dependency-manager.js","sourceRoot":"","sources":["../src/dependency-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAKpD,MAAa,i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AAS,KAAK,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;SACrF;QAED,MAAM,aAAa,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,CAAA;QAE7C,IAAI,aAAa,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE;YAC5C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;YACrC,OAAO,GAAG,CAAA;SACb;QAED,OAAO,IAAI,CAAA;IACf,CAAC;IAES,gBAAgB,CAAC,WAAmB;QAC1C,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;SACjC;QAED,MAAM,GAAG,GAAe;YACpB,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC;YAClC,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;YACR,WAAW,EAAE,WAAW;YACxB,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,mBAAmB,CAAC,WAAW,CAAC;YAChE,OAAO,EAAE,KAAK;YACd,GAAG,IAAI,CAAC,sBAAsB,CAAC,WAAW,EAAE,WAAW,CAAC;SAC3D,CAAA;QAED,OAAO,GAAG,CAAA;IACd,CAAC;IAED,MAAM;QACF,OAAO,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACvC,CAAC;IAED,UAAU;QACN,OAAO,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAA;IAC5C,CAAC;;SAvOQ,iBAAiB"}
|
package/lib/gir-module.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { GirFactory } from './gir-factory.js';
|
|
|
5
5
|
import { ConflictResolver } from './conflict-resolver.js';
|
|
6
6
|
import { DependencyManager } from './dependency-manager.js';
|
|
7
7
|
import { SymTable } from './symtable.js';
|
|
8
|
+
import { LibraryVersion } from './library-version.js';
|
|
8
9
|
import type { Dependency, GirRepository, GirNamespace, GirAliasElement, GirFunctionElement, GirType, GirCallableParamElement, GirCallableReturn, GirConstantElement, GirFieldElement, GirPropertyElement, InheritanceTable, ParsedGir, GenerateConfig, ClassParent } from './types/index.js';
|
|
9
10
|
export declare class GirModule {
|
|
10
11
|
private readonly config;
|
|
@@ -17,18 +18,24 @@ export declare class GirModule {
|
|
|
17
18
|
*/
|
|
18
19
|
namespace: string;
|
|
19
20
|
/**
|
|
20
|
-
* E.g. '
|
|
21
|
+
* E.g. '4.0'
|
|
21
22
|
*/
|
|
22
23
|
version: string;
|
|
23
24
|
/**
|
|
24
|
-
* E.g. 'Gtk-
|
|
25
|
+
* E.g. 'Gtk-4.0'
|
|
25
26
|
*/
|
|
26
27
|
packageName: string;
|
|
27
28
|
/**
|
|
28
|
-
* E.g. '
|
|
29
|
-
* Is used in the generated index.d.ts, for example: `import * as
|
|
29
|
+
* E.g. 'Gtk40'
|
|
30
|
+
* Is used in the generated index.d.ts, for example: `import * as Gtk40 from "./Gtk-4.0.js";`
|
|
30
31
|
*/
|
|
32
|
+
importNamespace: string;
|
|
31
33
|
importName: string;
|
|
34
|
+
/**
|
|
35
|
+
* The version of the library as an object.
|
|
36
|
+
* E.g. `{ major: 4, minor: 0, patch: 0 }` or as string `4.0.0`'
|
|
37
|
+
*/
|
|
38
|
+
libraryVersion: LibraryVersion;
|
|
32
39
|
dependencies: Dependency[];
|
|
33
40
|
private _transitiveDependencies;
|
|
34
41
|
set transitiveDependencies(deps: Dependency[]);
|
|
@@ -255,5 +262,5 @@ export declare class GirModule {
|
|
|
255
262
|
/**
|
|
256
263
|
* Start processing the typescript data
|
|
257
264
|
*/
|
|
258
|
-
start(): void;
|
|
265
|
+
start(girModules: GirModule[]): void;
|
|
259
266
|
}
|
package/lib/gir-module.js
CHANGED
|
@@ -9,8 +9,9 @@ import { DependencyManager } from './dependency-manager.js';
|
|
|
9
9
|
import { NO_TSDATA, WARN_NOT_FOUND_TYPE, WARN_CONSTANT_ALREADY_EXPORTED, WARN_DUPLICATE_SYMBOL, WARN_DUPLICATE_PARAMETER, WARN_DUPLICATE_ENUM_IDENTIFIER, } from './messages.js';
|
|
10
10
|
import { isEqual, find, clone, girBool, removeNamespace, addNamespace, girElementIsIntrospectable } from './utils.js';
|
|
11
11
|
import { SymTable } from './symtable.js';
|
|
12
|
+
import { LibraryVersion } from './library-version.js';
|
|
12
13
|
import { GirDirection } from './types/index.js';
|
|
13
|
-
|
|
14
|
+
class GirModule {
|
|
14
15
|
config;
|
|
15
16
|
/**
|
|
16
17
|
* Array of all gir modules
|
|
@@ -21,18 +22,24 @@ export class GirModule {
|
|
|
21
22
|
*/
|
|
22
23
|
namespace;
|
|
23
24
|
/**
|
|
24
|
-
* E.g. '
|
|
25
|
+
* E.g. '4.0'
|
|
25
26
|
*/
|
|
26
27
|
version = '0.0';
|
|
27
28
|
/**
|
|
28
|
-
* E.g. 'Gtk-
|
|
29
|
+
* E.g. 'Gtk-4.0'
|
|
29
30
|
*/
|
|
30
31
|
packageName;
|
|
31
32
|
/**
|
|
32
|
-
* E.g. '
|
|
33
|
-
* Is used in the generated index.d.ts, for example: `import * as
|
|
33
|
+
* E.g. 'Gtk40'
|
|
34
|
+
* Is used in the generated index.d.ts, for example: `import * as Gtk40 from "./Gtk-4.0.js";`
|
|
34
35
|
*/
|
|
36
|
+
importNamespace;
|
|
35
37
|
importName;
|
|
38
|
+
/**
|
|
39
|
+
* The version of the library as an object.
|
|
40
|
+
* E.g. `{ major: 4, minor: 0, patch: 0 }` or as string `4.0.0`'
|
|
41
|
+
*/
|
|
42
|
+
libraryVersion;
|
|
36
43
|
dependencies = [];
|
|
37
44
|
_transitiveDependencies = [];
|
|
38
45
|
set transitiveDependencies(deps) {
|
|
@@ -74,11 +81,13 @@ export class GirModule {
|
|
|
74
81
|
this.namespace = this.ns.$.name;
|
|
75
82
|
this.version = this.ns.$.version;
|
|
76
83
|
this.packageName = `${this.namespace}-${this.version}`;
|
|
77
|
-
this.
|
|
84
|
+
this.libraryVersion = new LibraryVersion(this.ns.constant, this.version);
|
|
85
|
+
this.transformation = new Transformation(config);
|
|
78
86
|
this.log = new Logger(config.environment, config.verbose, this.packageName || 'GirModule');
|
|
79
87
|
this.conflictResolver = new ConflictResolver(config.environment, config.verbose);
|
|
80
88
|
this.inject = new Injector(this.config.environment);
|
|
81
|
-
this.
|
|
89
|
+
this.importNamespace = this.transformation.transformModuleNamespaceName(this.packageName);
|
|
90
|
+
this.importName = this.transformation.transformImportName(this.packageName);
|
|
82
91
|
this.symTable = new SymTable(this.config, this.packageName, this.namespace);
|
|
83
92
|
}
|
|
84
93
|
checkTransitiveDependencies(transitiveDependencies) {
|
|
@@ -2184,8 +2193,16 @@ export class GirModule {
|
|
|
2184
2193
|
/**
|
|
2185
2194
|
* Start processing the typescript data
|
|
2186
2195
|
*/
|
|
2187
|
-
start() {
|
|
2196
|
+
start(girModules) {
|
|
2197
|
+
// GObject and Gio are following the version of GLib
|
|
2198
|
+
if (this.namespace === 'GObject' || this.namespace === 'Gio') {
|
|
2199
|
+
const glibModule = girModules.find((girModule) => girModule.namespace === 'GLib');
|
|
2200
|
+
if (glibModule) {
|
|
2201
|
+
this.libraryVersion = glibModule.libraryVersion;
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2188
2204
|
this.setModuleTsData();
|
|
2189
2205
|
}
|
|
2190
2206
|
}
|
|
2207
|
+
export { GirModule };
|
|
2191
2208
|
//# sourceMappingURL=gir-module.js.map
|