UNPKG

@ts-for-gir/lib

Version:

Typescript .d.ts generator from GIR for gjs

105 lines (104 loc) 4.47 kB
import { Logger } from './logger.js'; import { DependencyManager } from './dependency-manager.js'; import { LibraryVersion } from './library-version.js'; import type { Dependency, GirConstantElement, TsDocTag, OptionsGeneration } from './types/index.js'; import { GirNSMember } from './gir.js'; import { IntrospectedAlias } from './gir/alias.js'; import { IntrospectedNamespaceMember } from './gir/base.js'; import { IntrospectedBaseClass } from './gir/class.js'; import { IntrospectedEnum } from './gir/enum.js'; import { IntrospectedFunction, IntrospectedFunctionParameter, IntrospectedClassFunction } from './gir/function.js'; import { NSRegistry } from './gir/registry.js'; import { GirVisitor } from './visitor.js'; export declare class GirModule { readonly dependency: Dependency; /** * E.g. 'Gtk' */ get namespace(): string; /** * E.g. '4.0' */ get version(): string; /** * E.g. 'Gtk-4.0' */ get packageName(): string; /** * E.g. 'Gtk40' * Is used in the generated index.d.ts, for example: `import * as Gtk40 from "./Gtk-4.0.js";` */ get importNamespace(): string; /** * The NPM package name E.g. 'gtk-4.0' */ get importName(): string; /** * Import path for the package E.g. './Gtk-4.0.js' or '@girs/Gtk-4.0' */ get importPath(): string; prefixes: string[]; /** * The version of the library as an object. * E.g. `{ major: 4, minor: 0, patch: 0 }` or as string `4.0.0`' */ get libraryVersion(): LibraryVersion; protected _dependencies: Dependency[] | null; protected _transitiveDependencies: Dependency[] | null; get dependencies(): Dependency[]; get transitiveDependencies(): Dependency[]; get allDependencies(): Dependency[]; dependencyManager: DependencyManager; log: Logger; extends?: string; /** * To prevent constants from being exported twice, the names already exported are saved here for comparison. * Please note: Such a case is only known for Zeitgeist-2.0 with the constant "ATTACHMENT" */ constNames: { [varName: string]: GirConstantElement; }; readonly c_prefixes: string[]; private _members?; private _enum_constants?; private _resolve_names; __dts__references?: string[]; package_version: readonly [string, string] | readonly [string, string, string]; parent: NSRegistry; config: OptionsGeneration; constructor(dependency: Dependency, prefixes: string[], config: OptionsGeneration); initDependencies(): Promise<void>; initTransitiveDependencies(transitiveDependencies: Dependency[]): Promise<void>; get ns(): this; private checkTransitiveDependencies; getTsDocReturnTags(girElement?: IntrospectedFunction | IntrospectedClassFunction): TsDocTag[]; getTsDocInParamTags(inParams?: IntrospectedFunctionParameter[]): TsDocTag[]; registerResolveName(resolveName: string, namespace: string, name: string): void; get members(): Map<string, GirNSMember | GirNSMember[]>; get enum_constants(): Map<string, readonly [string, string]>; accept(visitor: GirVisitor): this; getImportsForCPrefix(c_prefix: string): GirModule[]; hasImport(name: string): boolean; private _getImport; getInstalledImport(_namespace: string): GirModule | null; assertInstalledImport(_namespace: string): GirModule; getMembers(name: string): IntrospectedNamespaceMember[]; getMemberWithoutOverrides(name: string): GirNSMember | null | undefined; assertClass(name: string): IntrospectedBaseClass; getClass(name: string): IntrospectedBaseClass | null; getEnum(name: string): IntrospectedEnum | null; getAlias(name: string): IntrospectedAlias | null; hasSymbol(name: string): boolean; resolveSymbolFromTypeName(name: string): string | null; findClassCallback(name: string): [string | null, string]; /** * This is an internal method to add TypeScript <reference> * comments when overrides use parts of the TypeScript standard * libraries that are newer than default. */ ___dts___addReference(reference: string): void; static load(dependency: Dependency, config: OptionsGeneration, registry: NSRegistry): Promise<GirModule>; /** Start to parse all the data from the XML we need for the typescript generation */ parse(): void; } export declare function promisifyNamespaceFunctions(namespace: GirModule): void;