@ts-for-gir/generator-typescript 4.0.0-beta.6 → 4.0.0-beta.7

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.
Files changed (46) hide show
  1. package/lib/module-generator.d.ts +134 -0
  2. package/lib/module-generator.js +1220 -0
  3. package/lib/module-generator.js.map +1 -0
  4. package/lib/npm-package.d.ts +15 -0
  5. package/lib/npm-package.js +76 -0
  6. package/lib/npm-package.js.map +1 -0
  7. package/lib/package-data-parser.js +1 -1
  8. package/lib/package-data-parser.js.map +1 -1
  9. package/lib/template-processor.d.ts +6 -13
  10. package/lib/template-processor.js +37 -30
  11. package/lib/template-processor.js.map +1 -1
  12. package/lib/type-definition-generator.d.ts +4 -141
  13. package/lib/type-definition-generator.js +61 -1372
  14. package/lib/type-definition-generator.js.map +1 -1
  15. package/lib/utils.d.ts +0 -1
  16. package/lib/utils.js +4 -4
  17. package/lib/utils.js.map +1 -1
  18. package/package.json +8 -8
  19. package/templates/{gjs/README-GJS.md → README-GJS.md} +1 -1
  20. package/templates/README.md +1 -1
  21. package/templates/gi.d.ts +7 -0
  22. package/templates/gjs/cairo.d.ts +9 -1
  23. package/templates/gjs/dom.d.ts +10 -4
  24. package/templates/gjs/gettext.d.ts +9 -2
  25. package/templates/gjs/gjs.d.ts +22 -4
  26. package/templates/gjs/system.d.ts +15 -3
  27. package/templates/index-locally.d.ts +7 -0
  28. package/templates/{gjs/module.d.ts → index.d.ts} +7 -3
  29. package/templates/index.js +4 -0
  30. package/templates/module-ambient.d.ts +17 -0
  31. package/templates/module.append.d.ts +17 -0
  32. package/templates/module.d.ts +45 -0
  33. package/templates/module.js +4 -0
  34. package/templates/package.json +30 -30
  35. package/templates/tsconfig.json +2 -2
  36. package/templates/gjs/module-ambient.d.ts +0 -23
  37. package/templates/gjs/module-noNamespace.d.ts +0 -7
  38. package/templates/gjs/module.append.d.ts +0 -1
  39. package/templates/gjs/module.js +0 -5
  40. /package/templates/{gjs/gio-2.0.d.ts → gio-2.0.d.ts} +0 -0
  41. /package/templates/gjs/{ambient.d.ts → gjs-ambient.d.ts} +0 -0
  42. /package/templates/gjs/{ambient.js → gjs-ambient.js} +0 -0
  43. /package/templates/{gjs/gobject-2.0.d.ts → gobject-2.0.d.ts} +0 -0
  44. /package/templates/{gjs/module-ambient.js → module-ambient.js} +0 -0
  45. /package/templates/{gjs/module-import.d.ts → module-import.d.ts} +0 -0
  46. /package/templates/{gjs/module-import.js → module-import.js} +0 -0
@@ -0,0 +1,134 @@
1
+ import { Logger, DependencyManager, TypeExpression, NSRegistry, IntrospectedClass, IntrospectedRecord, IntrospectedInterface, IntrospectedBaseClass, IntrospectedField, GirDirection, TsDocTag, OptionsGeneration, GirModule, IntrospectedFunction, IntrospectedCallback, IntrospectedSignal, IntrospectedProperty, IntrospectedConstant, IntrospectedClassCallback, IntrospectedClassFunction, IntrospectedConstructor, IntrospectedDirectAllocationConstructor, IntrospectedFunctionParameter, IntrospectedStaticClassFunction, IntrospectedVirtualClassFunction, IntrospectedAlias, IntrospectedEnum, IntrospectedSignalType, IntrospectedEnumMember, IntrospectedError, FormatGenerator, Generic } from '@ts-for-gir/lib';
2
+ import { TemplateProcessor } from './template-processor.js';
3
+ import { PackageDataParser } from './package-data-parser.js';
4
+ export declare class ModuleGenerator extends FormatGenerator<string[]> {
5
+ log: Logger;
6
+ dependencyManager: DependencyManager;
7
+ packageData?: PackageDataParser;
8
+ config: OptionsGeneration;
9
+ moduleTemplateProcessor: TemplateProcessor;
10
+ /**
11
+ * @param _config The config to use without the override config
12
+ */
13
+ constructor(namespace: GirModule, config: OptionsGeneration);
14
+ generateClassCallback(node: IntrospectedClassCallback): string[];
15
+ generateConstructor(node: IntrospectedConstructor): string[];
16
+ generateDirectAllocationConstructor(node: IntrospectedDirectAllocationConstructor): string[];
17
+ protected generateParameters(parameters: IntrospectedFunctionParameter[]): string;
18
+ generateConstructorFunction(node: IntrospectedConstructor): string[];
19
+ generateRecord(node: IntrospectedRecord): string[];
20
+ generateInterface(node: IntrospectedInterface): string[];
21
+ generateInterfaceNamespace(node: IntrospectedInterface): string[];
22
+ generateInterfaceDeclaration(node: IntrospectedInterface): string[];
23
+ generateError(node: IntrospectedError): string[];
24
+ generateSignal(node: IntrospectedSignal, type?: IntrospectedSignalType): string[];
25
+ generateStaticClassFunction(node: IntrospectedStaticClassFunction): string[];
26
+ generateVirtualClassFunction(node: IntrospectedVirtualClassFunction): string[];
27
+ generateExport(type: string, name: string, definition: string, indentCount?: number): string;
28
+ generateProperty(tsProp: IntrospectedProperty, construct?: boolean, indentCount?: number): string[];
29
+ generateField(tsProp: IntrospectedField, indentCount?: number): string[];
30
+ generateProperties(tsProps: IntrospectedProperty[], comment: string, indentCount?: number): string[];
31
+ generateFields(tsProps: IntrospectedField[], comment: string, indentCount?: number): string[];
32
+ generateMemberName(tsVar: IntrospectedProperty | IntrospectedConstant | IntrospectedField): string;
33
+ /**
34
+ * @param tsType The type expression
35
+ * @param namespace Provides the namespace to import relative to, defaults to the current namespace
36
+ * @returns A string for the type expression
37
+ */
38
+ generateType(tsType: TypeExpression): string;
39
+ generateDirectedType(tsType: TypeExpression, direction: GirDirection): string;
40
+ generateInParameters(inParams: IntrospectedFunctionParameter[]): string[];
41
+ /**
42
+ * Adds documentation comments
43
+ * @see https://github.com/microsoft/tsdoc
44
+ * @param lines
45
+ * @param indentCount
46
+ */
47
+ addTSDocCommentLines(lines: string[], indentCount?: number): string[];
48
+ /**
49
+ * Adds the documentation as comments
50
+ * @see https://github.com/microsoft/tsdoc
51
+ * @param girDoc
52
+ * @param indentCount
53
+ * @param overwriteDoc
54
+ * @returns
55
+ */
56
+ addGirDocComment(tsDoc: string | null | undefined, tags?: TsDocTag[], indentCount?: number): string[];
57
+ /**
58
+ * Adds an info comment, is used for debugging the generated types
59
+ * @param comment
60
+ * @param indentCount
61
+ * @returns
62
+ */
63
+ addInfoComment(comment?: string, indentCount?: number): string[];
64
+ mergeDescs(descs: string[], comment?: string, indentCount?: number): string[];
65
+ generateParameter(tsParam: IntrospectedFunctionParameter): string[];
66
+ /**
67
+ *
68
+ * @param tsGenerics
69
+ * @param isOut If this generic parameters are out do only generate the type parameter names
70
+ * @returns
71
+ */
72
+ generateGenericParameters(nodes: Generic[], withDefaults?: boolean): string;
73
+ generateFunctionReturn(tsFunction: IntrospectedFunction | IntrospectedClassFunction | IntrospectedClassCallback | IntrospectedCallback): string;
74
+ generateClassFunction(node: IntrospectedClassFunction): string[];
75
+ generateFunction(tsFunction: IntrospectedClassFunction | IntrospectedFunction | IntrospectedCallback, indentCount?: number): string[];
76
+ generateFunctions(tsFunctions: IntrospectedFunction[] | IntrospectedClassFunction[], indentCount?: number, comment?: string): string[];
77
+ generateCallback(tsCallback: IntrospectedCallback | IntrospectedClassCallback, indentCount?: number, classModuleName?: string): string[];
78
+ generateCallbackInterfaces(tsCallbacks: Array<IntrospectedCallback | IntrospectedClassCallback>, indentCount: number | undefined, classModuleName: string, comment?: string): string[];
79
+ generateEnum(girEnum: IntrospectedEnum, indentCount?: number): string[];
80
+ generateEnumMember(tsMember: IntrospectedEnumMember, indentCount?: number): string[];
81
+ generateConst(tsConst: IntrospectedConstant, indentCount?: number): string[];
82
+ generateAlias(girAlias: IntrospectedAlias, indentCount?: number): string[];
83
+ generateConstructPropsInterface(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
84
+ generateClassStaticFields(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
85
+ generateClassMemberFields(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
86
+ generateClassFields(girClass: IntrospectedClass | IntrospectedRecord, indentCount?: number): string[];
87
+ generateClassProperties(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
88
+ generateClassStaticMethods(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
89
+ generateClassMethods(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
90
+ generateClassConstructors(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
91
+ /**
92
+ * Instance methods, vfunc_ prefix
93
+ * @param girClass
94
+ */
95
+ generateClassVirtualMethods(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
96
+ generateClassSignalInterfaces(girClass: IntrospectedClass, indentCount?: number): string[];
97
+ generateSignals(girClass: IntrospectedClass): string[];
98
+ generateClassSignals(girClass: IntrospectedClass): string[];
99
+ generateClassModules(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
100
+ generateClassCallbacks(girClass: IntrospectedClass | IntrospectedInterface | IntrospectedRecord): string[];
101
+ /**
102
+ * In Typescript, interfaces and classes can have the same name,
103
+ * so we use this to generate interfaces with the same name to implement multiple inheritance
104
+ * @param girClass
105
+ * @param namespace
106
+ */
107
+ generateImplementationInterface(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface): string[];
108
+ protected extends(node: IntrospectedBaseClass): string;
109
+ protected implements(node: IntrospectedClass): string;
110
+ /**
111
+ * Represents a record, GObject class or interface as a Typescript class
112
+ * @param girClass
113
+ * @param namespace
114
+ */
115
+ generateClass(girClass: IntrospectedClass | IntrospectedRecord): string[];
116
+ stringifyNamespace(node: GirModule): Promise<string | null>;
117
+ exportModuleIndexJS(): Promise<void>;
118
+ exportModuleIndexTS(): Promise<void>;
119
+ exportModuleJS(girModule: GirModule): Promise<void>;
120
+ exportModuleAmbientTS(girModule: GirModule): Promise<void>;
121
+ protected exportModuleAmbientJS(girModule: GirModule): Promise<void>;
122
+ protected exportModuleImportTS(girModule: GirModule): Promise<void>;
123
+ protected exportModuleImportJS(girModule: GirModule): Promise<void>;
124
+ exportModuleTS(): Promise<void>;
125
+ generateModule(girModule: GirModule): Promise<string[]>;
126
+ /**
127
+ * Generates a namespace for the given GirModule.
128
+ * @deprecated Use `generateModule` instead @ewlsh
129
+ * @param girModule The GirModule to generate a namespace for.
130
+ * @returns A promise that resolves to the generated namespace.
131
+ */
132
+ generateNamespace(girModule: GirModule): Promise<string[]>;
133
+ exportModule(_registry: NSRegistry, girModule: GirModule): Promise<void>;
134
+ }