@ts-for-gir/generator-typescript 3.3.0 → 4.0.0-beta.2

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 (44) hide show
  1. package/lib/package-data-parser.js +3 -3
  2. package/lib/package-data-parser.js.map +1 -1
  3. package/lib/template-processor.d.ts +11 -14
  4. package/lib/template-processor.js +29 -38
  5. package/lib/template-processor.js.map +1 -1
  6. package/lib/type-definition-generator.d.ts +99 -85
  7. package/lib/type-definition-generator.js +1024 -791
  8. package/lib/type-definition-generator.js.map +1 -1
  9. package/package.json +17 -7
  10. package/templates/README.md +1 -10
  11. package/templates/gjs/ambient.d.ts +0 -40
  12. package/templates/gjs/cairo.d.ts +0 -4
  13. package/templates/gjs/cairo.js +0 -7
  14. package/templates/gjs/gettext.js +0 -7
  15. package/templates/gjs/gio-2.0.d.ts +0 -65
  16. package/templates/gjs/gjs.js +0 -6
  17. package/templates/gjs/gobject-2.0.d.ts +17 -28
  18. package/templates/gjs/module-ambient.d.ts +8 -16
  19. package/templates/gjs/module-import.d.ts +3 -15
  20. package/templates/gjs/module-noNamespace.d.ts +7 -0
  21. package/templates/gjs/module.d.ts +3 -2
  22. package/templates/gjs/module.js +1 -13
  23. package/templates/gjs/system.js +1 -8
  24. package/templates/granite-1.0.d.ts +1 -1
  25. package/templates/granite-7.0.d.ts +1 -1
  26. package/templates/gstbase-0.10.d.ts +1 -1
  27. package/templates/package.json +22 -120
  28. package/templates/tsconfig.json +0 -7
  29. package/templates/typedoc.json +0 -5
  30. package/lib/package-xml-parser.d.ts +0 -2
  31. package/lib/package-xml-parser.js +0 -16
  32. package/lib/package-xml-parser.js.map +0 -1
  33. package/templates/gjs/tsconfig.alias.json +0 -12
  34. package/templates/node-gtk/README-NODE-GTK.md +0 -74
  35. package/templates/node-gtk/ambient.d.ts +0 -19
  36. package/templates/node-gtk/ambient.js +0 -5
  37. package/templates/node-gtk/gobject-2.0.d.ts +0 -57
  38. package/templates/node-gtk/module-import.d.ts +0 -29
  39. package/templates/node-gtk/module-import.js +0 -10
  40. package/templates/node-gtk/module.append.d.ts +0 -1
  41. package/templates/node-gtk/module.d.ts +0 -10
  42. package/templates/node-gtk/module.js +0 -18
  43. package/templates/node-gtk/node-gtk.d.ts +0 -25
  44. package/templates/node-gtk/node-gtk.js +0 -7
@@ -1,4 +1,4 @@
1
- import { packageXmlParser } from './package-xml-parser.js';
1
+ import { parseStringPromise } from 'xml2js';
2
2
  import { readFile } from 'fs/promises';
3
3
  import { resolve } from 'path';
4
4
  import { Logger, splitModuleName, cleanString } from '@ts-for-gir/lib';
@@ -9,7 +9,7 @@ export class PackageDataParser {
9
9
  packages = [];
10
10
  constructor(config) {
11
11
  this.config = config;
12
- this.log = new Logger('', config.verbose, 'ModuleLoader');
12
+ this.log = new Logger(config.verbose, 'ModuleLoader');
13
13
  }
14
14
  get(name) {
15
15
  return this.packages.find((pkg) => pkg.gir === name);
@@ -61,7 +61,7 @@ export class PackageDataParser {
61
61
  const filePath = resolve(__dirname, '../packages.xml');
62
62
  this.log.log(`Parsing ${filePath}...`);
63
63
  const fileContents = await readFile(filePath, 'utf8');
64
- const result = packageXmlParser(fileContents);
64
+ const result = (await parseStringPromise(fileContents));
65
65
  this.parseSections(result.packages.section);
66
66
  }
67
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"package-data-parser.js","sourceRoot":"","sources":["../src/package-data-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAItC,MAAM,OAAO,iBAAiB;IAIK;IAHrB,GAAG,CAAQ;IACX,QA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AE,iBAAiB,CAAC,CAAA;QACtD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,QAAQ,KAAK,CAAC,CAAA;QACtC,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QACrD,MAAM,MAAM,GAAG,CAAC,MAAM,kBAAkB,CAAC,YAAY,CAAC,CAAsB,CAAA;QAC5E,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC/C,CAAC;CACJ"}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import ejs from 'ejs';
6
6
  import { Logger, Transformation } from '@ts-for-gir/lib';
7
- import type { GenerateConfig, Dependency, TemplateData, Environment } from '@ts-for-gir/lib';
7
+ import type { GenerateConfig, Dependency, TemplateData } from '@ts-for-gir/lib';
8
8
  export declare class TemplateProcessor {
9
9
  protected readonly data: TemplateData | undefined;
10
10
  protected readonly packageName: string;
@@ -20,13 +20,13 @@ export declare class TemplateProcessor {
20
20
  * @param baseDir The base directory
21
21
  * @returns The path to the directory
22
22
  */
23
- protected getEnvironmentDir: (environment: Environment, baseDir: string) => string;
23
+ protected getEnvironmentDir: (baseDir: string) => string;
24
24
  protected getAppendTemplateName(templateFilename: string): string;
25
25
  /**
26
26
  * Loads and renders a template and gets the rendered templates back
27
27
  * @param templateFilename
28
28
  */
29
- load(templateFilename: string, options?: Partial<ejs.Options>, overrideTemplateData?: TemplateData): Promise<{
29
+ load(templateFilename: string, ejsOptions?: Partial<ejs.Options>, overrideTemplateData?: TemplateData): Promise<{
30
30
  prepend: string;
31
31
  append: string;
32
32
  }>;
@@ -34,11 +34,11 @@ export declare class TemplateProcessor {
34
34
  * Loads and renders all templates in a directory and gets the rendered templates back
35
35
  * @param templateDirname
36
36
  * @param fileExtension
37
- * @param options EJS options
37
+ * @param ejsOptions EJS options
38
38
  * @param overrideTemplateData Override template data if you want
39
39
  * @returns The rendered templates
40
40
  */
41
- loadAll(templateDirname: string, fileExtension: string, options?: Partial<ejs.Options>, overrideTemplateData?: TemplateData): Promise<{
41
+ loadAll(templateDirname: string, fileExtension: string, ejsOptions?: Partial<ejs.Options>, overrideTemplateData?: TemplateData): Promise<{
42
42
  [path: string]: string;
43
43
  }>;
44
44
  /**
@@ -46,38 +46,35 @@ export declare class TemplateProcessor {
46
46
  * @param templateFilename The filename of the template
47
47
  * @param baseOutputPath The base output directory path where the templates should be written to
48
48
  * @param outputFilename The filename of the output file
49
- * @param prependEnv A (optional) boolean that indicates if the environment should be prepended to the output path
50
49
  * @param content A (optional) string that should be appended to the rendered template
51
- * @param options EJS options
50
+ * @param ejsOptions EJS options
52
51
  * @param overrideTemplateData Override template data if you want
53
52
  * @return The rendered template string
54
53
  */
55
- create(templateFilename: string, baseOutputPath: string, outputFilename: string, prependEnv?: boolean, content?: string, options?: Partial<ejs.Options>, overrideTemplateData?: TemplateData): Promise<string>;
54
+ create(templateFilename: string, baseOutputPath: string, outputFilename: string, content?: string, ejsOptions?: Partial<ejs.Options>, overrideTemplateData?: TemplateData): Promise<string>;
56
55
  /**
57
56
  * Loads all templates with file extension in dir, render the templates and write the template to the filesystem
58
57
  * @param fileExtension The file extension of the templates
59
58
  * @param templateDirname The directory where the templates are located
60
59
  * @param baseOutputPath The base output directory path where the templates should be written to
61
60
  * @param outputDirname The child output directory of the base output directory where the templates should be written to
62
- * @param prependEnv A (optional) boolean that indicates if the environment should be prepended to the output path
63
61
  * @param append A (optional) string that should be appended to the rendered template
64
- * @param options EJS options
62
+ * @param ejsOptions EJS options
65
63
  * @param overrideTemplateData Override template data if you want
66
64
  * @return The rendered (and if possible prettified) templates
67
65
  */
68
- createAll(fileExtension: string, templateDirname: string, baseOutputPath: string, outputDirname: string, prependEnv?: boolean, append?: string, options?: Partial<ejs.Options>, overrideTemplateData?: TemplateData): Promise<{
66
+ createAll(fileExtension: string, templateDirname: string, baseOutputPath: string, outputDirname: string, append?: string, ejsOptions?: Partial<ejs.Options>, overrideTemplateData?: TemplateData): Promise<{
69
67
  [path: string]: string;
70
68
  }>;
71
- getOutputPath(baseOutputPath: string, outputFilename: string, prependEnv?: boolean): string;
69
+ getOutputPath(baseOutputPath: string, outputFilename: string): string;
72
70
  /**
73
71
  * Writes the `content` to the filesystem
74
72
  * @param content The content (normally the content of a rendered template file) that should be written to the filesystem
75
73
  * @param baseOutputPath The base output directory path where the templates should be written to
76
74
  * @param outputFilename The filename of the output file
77
- * @param prependEnv A (optional) boolean that indicates if the environment should be prepended to the output path
78
75
  * @returns
79
76
  */
80
- protected write(content: string, baseOutputPath: string, outputFilename: string, prependEnv?: boolean): Promise<string>;
77
+ protected write(content: string, baseOutputPath: string, outputFilename: string): Promise<string>;
81
78
  /**
82
79
  *
83
80
  * @param templateString The template content string that should be rendered
@@ -7,7 +7,7 @@ import { readFile, writeFile, mkdir, readdir } from 'fs/promises';
7
7
  import { join, dirname, relative, extname } from 'path';
8
8
  import ejs from 'ejs';
9
9
  import { __dirname } from './utils.js';
10
- import { Logger, APP_NAME, APP_USAGE, APP_SOURCE, APP_VERSION, PACKAGE_DESC, PACKAGE_KEYWORDS, getDestPath, DependencyManager, Transformation, } from '@ts-for-gir/lib';
10
+ import { Logger, APP_NAME, APP_USAGE, APP_SOURCE, APP_VERSION, PACKAGE_DESC, PACKAGE_KEYWORDS, DependencyManager, Transformation, } from '@ts-for-gir/lib';
11
11
  const TEMPLATE_DIR = join(__dirname, '../templates');
12
12
  export class TemplateProcessor {
13
13
  data;
@@ -27,15 +27,15 @@ export class TemplateProcessor {
27
27
  let outdir = config.outdir || './';
28
28
  // Make outdir relative to the root directory
29
29
  outdir = relative(config.root, outdir);
30
- const typeDir = getDestPath(outdir);
30
+ const typeDir = outdir;
31
31
  this.data = {
32
32
  ...this.data,
33
33
  APP_NAME,
34
34
  APP_USAGE,
35
35
  APP_SOURCE,
36
36
  APP_VERSION,
37
- PACKAGE_DESC: PACKAGE_DESC(packageName, this.config.environment, this.data?.girModule?.libraryVersion),
38
- PACKAGE_KEYWORDS: PACKAGE_KEYWORDS(packageName, this.config.environment),
37
+ PACKAGE_DESC: PACKAGE_DESC(packageName, this.data?.girModule?.libraryVersion),
38
+ PACKAGE_KEYWORDS: PACKAGE_KEYWORDS(packageName),
39
39
  importName: this.transformation.transformImportName(packageName),
40
40
  dep,
41
41
  deps,
@@ -43,8 +43,8 @@ export class TemplateProcessor {
43
43
  join,
44
44
  dirname,
45
45
  };
46
- this.environmentTemplateDir = this.getEnvironmentDir(config.environment, TEMPLATE_DIR);
47
- this.log = new Logger(config.environment, config.verbose, this.packageName);
46
+ this.environmentTemplateDir = this.getEnvironmentDir(TEMPLATE_DIR);
47
+ this.log = new Logger(config.verbose, this.packageName);
48
48
  }
49
49
  /**
50
50
  * Get the output or input directory of the environment
@@ -52,13 +52,9 @@ export class TemplateProcessor {
52
52
  * @param baseDir The base directory
53
53
  * @returns The path to the directory
54
54
  */
55
- getEnvironmentDir = (environment, baseDir) => {
56
- if (!baseDir.endsWith(environment))
57
- if (environment === 'gjs' && !baseDir.endsWith('/gjs')) {
58
- return join(baseDir, 'gjs');
59
- }
60
- if (environment === 'node' && !baseDir.endsWith('/node-gtk')) {
61
- return join(baseDir, 'node-gtk');
55
+ getEnvironmentDir = (baseDir) => {
56
+ if (!baseDir.endsWith('/gjs')) {
57
+ return join(baseDir, 'gjs');
62
58
  }
63
59
  return baseDir;
64
60
  };
@@ -80,14 +76,14 @@ export class TemplateProcessor {
80
76
  * Loads and renders a template and gets the rendered templates back
81
77
  * @param templateFilename
82
78
  */
83
- async load(templateFilename, options = {}, overrideTemplateData = {}) {
79
+ async load(templateFilename, ejsOptions = {}, overrideTemplateData = {}) {
84
80
  const fileContent = await this.read(templateFilename);
85
- const prepend = await this.render(fileContent, options, overrideTemplateData);
81
+ const prepend = await this.render(fileContent, ejsOptions, overrideTemplateData);
86
82
  let append = '';
87
83
  const appendTemplateFilename = this.getAppendTemplateName(templateFilename);
88
84
  if (this.exists(appendTemplateFilename)) {
89
85
  const appendFileContent = await this.read(appendTemplateFilename);
90
- append = await this.render(appendFileContent, options, overrideTemplateData);
86
+ append = await this.render(appendFileContent, ejsOptions, overrideTemplateData);
91
87
  }
92
88
  return { prepend, append };
93
89
  }
@@ -95,14 +91,14 @@ export class TemplateProcessor {
95
91
  * Loads and renders all templates in a directory and gets the rendered templates back
96
92
  * @param templateDirname
97
93
  * @param fileExtension
98
- * @param options EJS options
94
+ * @param ejsOptions EJS options
99
95
  * @param overrideTemplateData Override template data if you want
100
96
  * @returns The rendered templates
101
97
  */
102
- async loadAll(templateDirname, fileExtension, options = {}, overrideTemplateData = {}) {
98
+ async loadAll(templateDirname, fileExtension, ejsOptions = {}, overrideTemplateData = {}) {
103
99
  const fileContents = await this.readAll(templateDirname, fileExtension);
104
100
  for (const file of Object.keys(fileContents)) {
105
- fileContents[file] = await this.render(fileContents[file], options, overrideTemplateData);
101
+ fileContents[file] = await this.render(fileContents[file], ejsOptions, overrideTemplateData);
106
102
  }
107
103
  return fileContents;
108
104
  }
@@ -111,16 +107,15 @@ export class TemplateProcessor {
111
107
  * @param templateFilename The filename of the template
112
108
  * @param baseOutputPath The base output directory path where the templates should be written to
113
109
  * @param outputFilename The filename of the output file
114
- * @param prependEnv A (optional) boolean that indicates if the environment should be prepended to the output path
115
110
  * @param content A (optional) string that should be appended to the rendered template
116
- * @param options EJS options
111
+ * @param ejsOptions EJS options
117
112
  * @param overrideTemplateData Override template data if you want
118
113
  * @return The rendered template string
119
114
  */
120
- async create(templateFilename, baseOutputPath, outputFilename, prependEnv = true, content = '', options = {}, overrideTemplateData = {}) {
121
- const { prepend, append } = await this.load(templateFilename, options, overrideTemplateData);
115
+ async create(templateFilename, baseOutputPath, outputFilename, content = '', ejsOptions = {}, overrideTemplateData = {}) {
116
+ const { prepend, append } = await this.load(templateFilename, ejsOptions, overrideTemplateData);
122
117
  const code = prepend + '\n' + content + '\n' + append;
123
- await this.write(code, baseOutputPath, outputFilename, prependEnv);
118
+ await this.write(code, baseOutputPath, outputFilename);
124
119
  return code;
125
120
  }
126
121
  /**
@@ -129,27 +124,24 @@ export class TemplateProcessor {
129
124
  * @param templateDirname The directory where the templates are located
130
125
  * @param baseOutputPath The base output directory path where the templates should be written to
131
126
  * @param outputDirname The child output directory of the base output directory where the templates should be written to
132
- * @param prependEnv A (optional) boolean that indicates if the environment should be prepended to the output path
133
127
  * @param append A (optional) string that should be appended to the rendered template
134
- * @param options EJS options
128
+ * @param ejsOptions EJS options
135
129
  * @param overrideTemplateData Override template data if you want
136
130
  * @return The rendered (and if possible prettified) templates
137
131
  */
138
- async createAll(fileExtension, templateDirname, baseOutputPath, outputDirname, prependEnv = true, append = '', options = {}, overrideTemplateData = {}) {
139
- const rendered = await this.loadAll(templateDirname, fileExtension, options, overrideTemplateData);
132
+ async createAll(fileExtension, templateDirname, baseOutputPath, outputDirname, append = '', ejsOptions = {}, overrideTemplateData = {}) {
133
+ const rendered = await this.loadAll(templateDirname, fileExtension, ejsOptions, overrideTemplateData);
140
134
  const result = {};
141
135
  for (const filename of Object.keys(rendered)) {
142
- const destPath = getDestPath(baseOutputPath, outputDirname, filename);
136
+ const destPath = join(baseOutputPath, outputDirname, filename);
143
137
  result[destPath] = rendered[filename] + '\n' + append;
144
- await this.write(result[destPath], baseOutputPath, join(outputDirname, filename), prependEnv);
138
+ await this.write(result[destPath], baseOutputPath, join(outputDirname, filename));
145
139
  }
146
140
  return result;
147
141
  }
148
- getOutputPath(baseOutputPath, outputFilename, prependEnv = true) {
149
- const filePath = this.config.package
150
- ? join(this.data?.importName || this.packageName, outputFilename)
151
- : outputFilename;
152
- const outputPath = prependEnv ? getDestPath(baseOutputPath, filePath) : join(baseOutputPath, filePath);
142
+ getOutputPath(baseOutputPath, outputFilename) {
143
+ const filePath = join(this.data?.importName || this.packageName, outputFilename);
144
+ const outputPath = join(baseOutputPath, filePath);
153
145
  return outputPath;
154
146
  }
155
147
  /**
@@ -157,11 +149,10 @@ export class TemplateProcessor {
157
149
  * @param content The content (normally the content of a rendered template file) that should be written to the filesystem
158
150
  * @param baseOutputPath The base output directory path where the templates should be written to
159
151
  * @param outputFilename The filename of the output file
160
- * @param prependEnv A (optional) boolean that indicates if the environment should be prepended to the output path
161
152
  * @returns
162
153
  */
163
- async write(content, baseOutputPath, outputFilename, prependEnv = true) {
164
- const outputPath = this.getOutputPath(baseOutputPath, outputFilename, prependEnv);
154
+ async write(content, baseOutputPath, outputFilename) {
155
+ const outputPath = this.getOutputPath(baseOutputPath, outputFilename);
165
156
  // write template result file
166
157
  await mkdir(dirname(outputPath), { recursive: true });
167
158
  await writeFile(outputPath, content, { encoding: 'utf8', flag: 'w' });
@@ -1 +1 @@
1
- {"version":3,"file":"template-processor.js","sourceRoot":"","sources":["../src/template-processor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACvD,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EACH,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAU,EACV,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,cAAc,GACjB,MAAM,iBAAiB,CAAA;AAIxB,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;AAEpD,MAAM,OAAO,iBAAiB;IAKH;IACA;IACA;IACA;IAPb,sBAAsB,CAAQ;IAC9B,GAAG,CAAQ;IACX,cAAc,CAAgB;IACxC,YACuB,IAA8B,EAC9B,WAAmB,EACnB,IAAkB,EAClB,MAAsB;QAHtB,SAAI,GAAJ,IAAI,CAA0B;QAC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OAAO,GAA+B,EAAE,CAAA;YAC9C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACvB,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAA;YAC5D,CAAC;YACD,OAAO,OAAO,CAAA;QAClB,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,uBAAuB,eAAe,cAAc,CAAC,CAAA;IACzE,CAAC;CACJ;AAED,eAAe,iBAAiB,CAAA"}
@@ -1,54 +1,52 @@
1
1
  import { Generator } from '@ts-for-gir/generator-base';
2
- import { Logger, Dependency, DependencyManager } from '@ts-for-gir/lib';
2
+ import { Logger, DependencyManager, TypeExpression, NSRegistry, IntrospectedClass, IntrospectedRecord, IntrospectedInterface, IntrospectedBaseClass, IntrospectedField, GirDirection, TsDocTag } from '@ts-for-gir/lib';
3
3
  import { TemplateProcessor } from './template-processor.js';
4
4
  import { PackageDataParser } from './package-data-parser.js';
5
- import type { GenerateConfig, GirClassElement, GirCallableParamElement, GirSignalElement, GirEnumElement, GirAliasElement, GirInterfaceElement, GirUnionElement, GirModulesGrouped, GirRecordElement, GirBitfieldElement, GirInstanceParameter, GirModule, TsGenericParameter, TsType, TsDoc, TsFunction, TsCallback, TsSignal, TsMember, TsVar, TsProperty, TsParameter } from '@ts-for-gir/lib';
6
- export declare class TypeDefinitionGenerator implements Generator {
7
- protected readonly _config: GenerateConfig;
8
- protected log: Logger;
9
- protected dependencyManager: DependencyManager;
10
- protected packageData?: PackageDataParser;
11
- /** Override config, used to override the config temporarily to generate both ESM and CJS for NPM packages */
12
- protected overrideConfig: Partial<GenerateConfig>;
13
- /** Get the current config, including the override config */
14
- protected get config(): GenerateConfig;
5
+ import { GenerateConfig, 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';
6
+ declare class ModuleGenerator extends FormatGenerator<string[]> {
7
+ log: Logger;
8
+ dependencyManager: DependencyManager;
9
+ packageData?: PackageDataParser;
10
+ config: GenerateConfig;
11
+ moduleTemplateProcessor: TemplateProcessor;
15
12
  /**
16
13
  * @param _config The config to use without the override config
17
14
  */
18
- constructor(_config: GenerateConfig);
15
+ constructor(namespace: GirModule, config: GenerateConfig);
16
+ generateClassCallback(node: IntrospectedClassCallback): string[];
17
+ generateConstructor(node: IntrospectedConstructor): string[];
18
+ generateDirectAllocationConstructor(node: IntrospectedDirectAllocationConstructor): string[];
19
+ protected generateParameters(parameters: IntrospectedFunctionParameter[]): string;
20
+ generateConstructorFunction(node: IntrospectedConstructor): string[];
21
+ generateRecord(node: IntrospectedRecord): string[];
22
+ generateInterface(node: IntrospectedInterface): string[];
23
+ generateInterfaceNamespace(node: IntrospectedInterface): string[];
24
+ generateInterfaceDeclaration(node: IntrospectedInterface): string[];
25
+ generateError(node: IntrospectedError): string[];
26
+ generateSignal(node: IntrospectedSignal, type?: IntrospectedSignalType): string[];
27
+ generateStaticClassFunction(node: IntrospectedStaticClassFunction): string[];
28
+ generateVirtualClassFunction(node: IntrospectedVirtualClassFunction): string[];
29
+ generateExport(type: string, name: string, definition: string, indentCount?: number): string;
30
+ generateProperty(tsProp: IntrospectedProperty, construct?: boolean, indentCount?: number): string[];
31
+ generateField(tsProp: IntrospectedField, indentCount?: number): string[];
32
+ generateProperties(tsProps: IntrospectedProperty[], comment: string, indentCount?: number): string[];
33
+ generateFields(tsProps: IntrospectedField[], comment: string, indentCount?: number): string[];
34
+ generateMemberName(tsVar: IntrospectedProperty | IntrospectedConstant | IntrospectedField): string;
19
35
  /**
20
- *
21
- * @param namespace E.g. 'Gtk'
22
- * @param packageName E.g. 'Gtk-3.0'
23
- * @param asExternType Currently only used for node type imports
24
- */
25
- protected generateModuleDependenciesImport(packageName: string): string[];
26
- protected generateExport(type: string, name: string, definition: string, indentCount?: number): string;
27
- protected generateProperty(tsProp: TsProperty, onlyStatic: boolean, namespace: string, indentCount?: number): string[];
28
- protected generateProperties(tsProps: TsProperty[], onlyStatic: boolean, namespace: string, comment: string, indentCount?: number): string[];
29
- protected generateVariableCallbackType(tsType: TsType, namespace: string): string;
30
- protected generateVariable(tsVar: TsProperty | TsVar, namespace: string, indentCount?: number, allowCommentOut?: boolean): string;
31
- protected generateType(tsType: TsType, namespace: string, generateNullable?: boolean): string;
32
- protected generateTypes(tsTypes: TsType[], namespace: string): string;
33
- protected generateGenericValues(tsType: TsType, namespace: string): string;
34
- /**
35
- * Generates signals from all properties of a base class
36
- * TODO: Build new `GirSignalElement`s in `gir-module.ts` instead of generate the strings directly
37
- * @param girClass
38
- * @param namespace
39
- * @param indentCount
40
- * @returns
36
+ * @param tsType The type expression
37
+ * @param namespace Provides the namespace to import relative to, defaults to the current namespace
38
+ * @returns A string for the type expression
41
39
  */
42
- protected generateClassPropertySignals(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, namespace: string, indentCount?: number): string[];
43
- protected generateInParameters(inParams: GirCallableParamElement[], instanceParameters: GirInstanceParameter[], namespace: string): string[];
44
- protected generateSignals(girSignals: GirSignalElement[], girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, namespace: string, indentCount?: number): string[];
40
+ generateType(tsType: TypeExpression): string;
41
+ generateDirectedType(tsType: TypeExpression, direction: GirDirection): string;
42
+ generateInParameters(inParams: IntrospectedFunctionParameter[]): string[];
45
43
  /**
46
44
  * Adds documentation comments
47
45
  * @see https://github.com/microsoft/tsdoc
48
46
  * @param lines
49
47
  * @param indentCount
50
48
  */
51
- protected addTSDocCommentLines(lines: string[], indentCount?: number): string[];
49
+ addTSDocCommentLines(lines: string[], indentCount?: number): string[];
52
50
  /**
53
51
  * Adds the documentation as comments
54
52
  * @see https://github.com/microsoft/tsdoc
@@ -57,87 +55,103 @@ export declare class TypeDefinitionGenerator implements Generator {
57
55
  * @param overwriteDoc
58
56
  * @returns
59
57
  */
60
- protected addGirDocComment(tsDoc: TsDoc | undefined, indentCount?: number, overwriteDoc?: Partial<TsDoc>): string[];
58
+ addGirDocComment(tsDoc: string | null | undefined, tags?: TsDocTag[], indentCount?: number): string[];
61
59
  /**
62
60
  * Adds an info comment, is used for debugging the generated types
63
61
  * @param comment
64
62
  * @param indentCount
65
63
  * @returns
66
64
  */
67
- protected addInfoComment(comment?: string, indentCount?: number): string[];
65
+ addInfoComment(comment?: string, indentCount?: number): string[];
68
66
  /**
69
67
  * Adds an inline info comment, is used for debugging the generated types
70
68
  * @param comment
71
69
  * @param indentCount
72
70
  * @returns
73
71
  */
74
- protected addInlineInfoComment(comment?: string, indentCount?: number): string[];
75
- protected mergeDescs(descs: string[], comment?: string, indentCount?: number): string[];
76
- protected generateParameter(tsParam: TsParameter, namespace: string): string[];
72
+ addInlineInfoComment(comment?: string, indentCount?: number): string[];
73
+ mergeDescs(descs: string[], comment?: string, indentCount?: number): string[];
74
+ generateParameter(tsParam: IntrospectedFunctionParameter): string[];
77
75
  /**
78
76
  *
79
77
  * @param tsGenerics
80
78
  * @param isOut If this generic parameters are out do only generate the type parameter names
81
79
  * @returns
82
80
  */
83
- protected generateGenericParameters(tsGenerics?: TsGenericParameter[], isOut?: boolean): string;
84
- protected generateOutParameterReturn(girParam: GirCallableParamElement, namespace: string): string[];
85
- protected generateFunctionReturn(tsFunction: TsFunction | TsCallback | TsSignal, namespace: string): string;
86
- protected generateFunction(tsFunction: TsFunction | TsCallback | TsSignal | undefined,
87
- /** If true only generate static functions otherwise generate only non static functions */
88
- onlyStatic: boolean, namespace: string, indentCount?: number, overloads?: boolean): string[];
89
- protected generateFunctions(tsFunctions: TsFunction[], onlyStatic: boolean, namespace: string, indentCount?: number, comment?: string): string[];
90
- protected generateCallbackInterface(tsCallback: TsCallback | TsSignal, namespace: string, indentCount?: number, classModuleName?: string): string[];
91
- protected generateCallbackInterfaces(tsCallbacks: Array<TsCallback | TsSignal>, namespace: string, indentCount: number | undefined, classModuleName: string, comment?: string): string[];
92
- protected generateEnumeration(girEnum: GirEnumElement | GirBitfieldElement, indentCount?: number): string[];
93
- protected generateEnumerationMember(tsMember: TsMember, indentCount?: number): string[];
94
- protected generateConstant(tsConst: TsVar, namespace: string, indentCount?: number): string[];
95
- protected generateAlias(girAlias: GirAliasElement, namespace: string, indentCount?: number): string[] | "";
96
- protected generateConstructPropsInterface(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, namespace: string, indentCount?: number): string[];
97
- protected generateClassFields(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, onlyStatic: boolean, namespace: string, indentCount?: number): string[];
98
- protected generateClassProperties(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, onlyStatic: boolean, namespace: string, indentCount?: number): string[];
99
- protected generateClassMethods(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, onlyStatic: boolean, namespace: string, indentCount?: number): string[];
100
- protected generateClassConstructors(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, namespace: string, indentCount?: number): string[];
81
+ generateGenericParameters(nodes: Generic[], withDefaults?: boolean): string;
82
+ generateFunctionReturn(tsFunction: IntrospectedFunction | IntrospectedClassFunction | IntrospectedClassCallback | IntrospectedCallback): string;
83
+ generateClassFunction(node: IntrospectedClassFunction): string[];
84
+ generateFunction(tsFunction: IntrospectedClassFunction | IntrospectedFunction | IntrospectedCallback, indentCount?: number): string[];
85
+ generateFunctions(tsFunctions: IntrospectedFunction[] | IntrospectedClassFunction[], indentCount?: number, comment?: string): string[];
86
+ generateCallback(tsCallback: IntrospectedCallback | IntrospectedClassCallback, indentCount?: number, classModuleName?: string): string[];
87
+ generateCallbackInterfaces(tsCallbacks: Array<IntrospectedCallback | IntrospectedClassCallback>, indentCount: number | undefined, classModuleName: string, comment?: string): string[];
88
+ generateEnum(girEnum: IntrospectedEnum, indentCount?: number): string[];
89
+ generateEnumMember(tsMember: IntrospectedEnumMember, indentCount?: number): string[];
90
+ generateConst(tsConst: IntrospectedConstant, indentCount?: number): string[];
91
+ generateAlias(girAlias: IntrospectedAlias, indentCount?: number): string[];
92
+ generateConstructPropsInterface(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
93
+ generateClassStaticFields(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
94
+ generateClassMemberFields(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
95
+ generateClassFields(girClass: IntrospectedClass | IntrospectedRecord, indentCount?: number): string[];
96
+ generateClassProperties(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
97
+ generateClassStaticMethods(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
98
+ generateClassMethods(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
99
+ generateClassConstructors(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
101
100
  /**
102
101
  * Instance methods, vfunc_ prefix
103
102
  * @param girClass
104
103
  */
105
- protected generateClassVirtualMethods(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, namespace: string, indentCount?: number): string[];
106
- protected generateClassSignalInterfaces(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, namespace: string, indentCount?: number): string[];
107
- protected generateClassSignals(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, namespace: string): string[];
108
- protected generateClassModules(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, namespace: string, indentCount?: number): string[];
104
+ generateClassVirtualMethods(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
105
+ generateClassSignalInterfaces(girClass: IntrospectedClass, indentCount?: number): string[];
106
+ generateSignals(girClass: IntrospectedClass): string[];
107
+ generateClassSignals(girClass: IntrospectedClass): string[];
108
+ generateClassModules(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface, indentCount?: number): string[];
109
+ generateClassCallbacks(girClass: IntrospectedClass | IntrospectedInterface | IntrospectedRecord): string[];
109
110
  /**
110
111
  * In Typescript, interfaces and classes can have the same name,
111
112
  * so we use this to generate interfaces with the same name to implement multiple inheritance
112
113
  * @param girClass
113
114
  * @param namespace
114
115
  */
115
- protected generateImplementationInterface(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, namespace: string): string[];
116
+ generateImplementationInterface(girClass: IntrospectedClass | IntrospectedRecord | IntrospectedInterface): string[];
117
+ protected extends(node: IntrospectedBaseClass): string;
118
+ protected implements(node: IntrospectedClass): string;
116
119
  /**
117
120
  * Represents a record, GObject class or interface as a Typescript class
118
121
  * @param girClass
119
122
  * @param namespace
120
123
  */
121
- protected generateClass(girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement, namespace: string): string[];
122
- protected exportModuleJS(moduleTemplateProcessor: TemplateProcessor, girModule: GirModule): Promise<void>;
123
- protected exportModuleAmbientTS(moduleTemplateProcessor: TemplateProcessor, girModule: GirModule): Promise<void>;
124
- protected exportModuleAmbientJS(moduleTemplateProcessor: TemplateProcessor, girModule: GirModule): Promise<void>;
125
- protected exportModuleImportTS(moduleTemplateProcessor: TemplateProcessor, girModule: GirModule): Promise<void>;
126
- protected exportModuleImportJS(moduleTemplateProcessor: TemplateProcessor, girModule: GirModule): Promise<void>;
127
- protected exportModuleTS(moduleTemplateProcessor: TemplateProcessor, girModule: GirModule): Promise<void>;
128
- protected exportNPMPackage(moduleTemplateProcessor: TemplateProcessor, girModuleImportName: string): Promise<void>;
129
- protected exportNPMPackageJson(moduleTemplateProcessor: TemplateProcessor): Promise<void>;
130
- protected exportNPMReadme(moduleTemplateProcessor: TemplateProcessor, girModuleImportName: string): Promise<void>;
131
- protected exportTSConfig(moduleTemplateProcessor: TemplateProcessor): Promise<void>;
132
- protected exportTypeDoc(moduleTemplateProcessor: TemplateProcessor): Promise<void>;
133
- protected exportModule(girModule: GirModule, girModules: GirModule[], girModulesGrouped: GirModulesGrouped[]): Promise<void>;
124
+ generateClass(girClass: IntrospectedClass | IntrospectedRecord): string[];
125
+ stringifyNamespace(node: GirModule): Promise<string | null>;
126
+ exportModuleJS(girModule: GirModule): Promise<void>;
127
+ exportModuleAmbientTS(girModule: GirModule): Promise<void>;
128
+ protected exportModuleAmbientJS(girModule: GirModule): Promise<void>;
129
+ protected exportModuleImportTS(girModule: GirModule): Promise<void>;
130
+ protected exportModuleImportJS(girModule: GirModule): Promise<void>;
131
+ exportModuleTS(): Promise<void>;
134
132
  /**
135
- * We build both module types if we build an NPM package,
136
- * so we need to switch the module type and use the default noNamespace value for the module type
133
+ *
134
+ * @param namespace E.g. 'Gtk'
135
+ * @param packageName E.g. 'Gtk-3.0'
136
+ * @param asExternType Currently only used for node type imports
137
+ */
138
+ protected generateModuleDependenciesImport(packageName: string): string[];
139
+ generateNamespace(girModule: GirModule): Promise<string[] | null>;
140
+ exportModule(_registry: NSRegistry, girModule: GirModule): Promise<void>;
141
+ }
142
+ export declare class TypeDefinitionGenerator implements Generator {
143
+ readonly config: GenerateConfig;
144
+ log: Logger;
145
+ dependencyManager: DependencyManager;
146
+ packageData?: PackageDataParser;
147
+ module: ModuleGenerator;
148
+ /**
149
+ * @param _config The config to use without the override config
137
150
  */
138
- protected setOverrideConfigForOtherModuleType(): void;
139
- protected resetOverrideConfig(): void;
140
- protected exportGjs(dependencies: Dependency[], girModules: GirModule[], girModulesGrouped: GirModulesGrouped[]): Promise<void>;
141
- protected exportNodeGtk(dependencies: Dependency[], girModules: GirModule[], girModulesGrouped: GirModulesGrouped[]): Promise<void>;
142
- start(girModules: GirModule[], girModulesGrouped?: GirModulesGrouped[]): Promise<void>;
151
+ constructor(config: GenerateConfig);
152
+ exportGjs(): Promise<void>;
153
+ generate(registry: NSRegistry, module: GirModule): Promise<void>;
154
+ start(): Promise<void>;
155
+ finish(): Promise<void>;
143
156
  }
157
+ export {};