@ts-for-gir/lib
Version:
Typescript .d.ts generator from GIR for gjs
152 lines (151 loc) • 5.64 kB
TypeScript
import { GirXML, GirRepository, GirNamespace } from '@gi.ts/parser';
import { Logger } from './logger.js';
import { LibraryVersion } from './library-version.js';
import type { Dependency, OptionsGeneration, GirInclude, FileInfo } from './types/index.js';
import type { GirModule } from './gir-module.js';
import { GirNSRegistry } from './registry.js';
export declare class DependencyManager extends GirNSRegistry {
protected readonly config: OptionsGeneration;
protected log: Logger;
protected _cache: {
[packageName: string]: Dependency;
};
static instances: {
[key: string]: DependencyManager;
};
protected constructor(config: OptionsGeneration);
/**
* Get the DependencyManager singleton instance
*/
static getInstance(config?: OptionsGeneration): DependencyManager;
protected parsePackageName(namespaceOrPackageName: string, version?: string): {
packageName: string;
namespace: string;
version: string;
};
protected parseArgs(namespaceOrPackageNameOrRepo: string | GirRepository, version?: string, noOverride?: boolean): {
repo: null;
namespace: string;
importNamespace: string;
version: string;
libraryVersion: LibraryVersion;
packageName: string;
importName: string;
importPath: string;
importDef: string;
packageJsonImport: string;
girXML: GirXML | null;
path: string | null;
filename: string;
exists: boolean;
} | {
packageName: string;
namespace: string;
version: string;
repo: GirRepository | null;
};
/**
* Get all dependencies in the cache
* @returns All dependencies in the cache
*/
all(): Dependency[];
getAllPackageNames(): string[];
/**
* Get the core dependencies
* @returns
*/
core(): Promise<Dependency[]>;
createImportProperties(namespace: string, packageName: string, version: string): {
importPath: string;
importDef: string;
packageJsonImport: string;
};
createImportPath(packageName: string, namespace: string, version: string): string;
createImportDef(namespace: string, importPath: string): string;
createPackageJsonImport(importPath: string): string;
protected parseGir(path: string): Promise<{
girXML: GirXML;
repo: GirRepository;
ns: GirNamespace | undefined;
version: string | undefined;
}>;
protected parseGirAndReturnLatestVersion(filesInfo: FileInfo[]): Promise<{
libraryVersion: LibraryVersion;
girXML: GirXML;
fileInfo: FileInfo;
} | {
libraryVersion: LibraryVersion;
girXML: null;
fileInfo: FileInfo;
}>;
/**
* Get the dependency object by packageName
* @param packageName The package name (with version affix) of the dependency
* @returns The dependency object
*/
get(packageName: string): Promise<Dependency>;
/**
* Get the dependency object by namespace and version
* @param namespace The namespace of the dependency
* @param version The version of the dependency
* @returns The dependency object
*/
get(namespace: string, version: string, noOverride?: boolean): Promise<Dependency>;
/**
* Get the dependency object by {@link GirRepository}
* @param namespace The namespace of the dependency
* @param version The version of the dependency
* @returns The dependency object
*/
get(repo: GirRepository, version?: string, noOverride?: boolean): Promise<Dependency>;
/**
* Get all dependencies with the given namespace
* @param namespace The namespace of the dependency
* @returns All dependencies with the given namespace
*/
list(namespace: string): Dependency[];
/**
* Get girModule for dependency
* @param girModules
* @param packageName
*/
getModule(girModules: GirModule[], dep: Dependency): GirModule | undefined;
/**
* Add all dependencies from an array of gir modules
* @param girModules
*/
addAll(girModules: GirModule[]): Promise<Dependency[]>;
/**
* Transforms a gir include object array to a dependency object array
* @param girIncludes - Array of gir includes
* @returns Array of dependencies
*/
fromGirIncludes(girIncludes: GirInclude[]): Promise<Dependency[]>;
/**
* Check if multiple dependencies with the given namespace exist in the cache
* @param namespace The namespace of the dependency
* @returns
*/
hasConflict(namespace: string): boolean;
/**
* get the latest version of the dependency with the given namespace
* @param namespace The namespace of the dependency
* @returns The latest version of the dependency
*/
getLatestVersion(namespace: string): Dependency | undefined;
/**
* Check if the given version is the latest version of the dependency
* @param namespace The namespace of the dependency
* @param version The version of the dependency
* @returns
*/
isLatestVersion(namespace: string, version: string): boolean;
/**
* Find a dependency by it's namespace from the cache, if multiple versions are found, the latest version is returned
* @param namespace The namespace of the dependency
* @returns The dependency object or null if not found
*/
find(namespace: string): Dependency | null;
protected getPseudoPackage(packageName: string, namespace?: string, version?: string): Dependency;
getGjs(): Dependency;
}