@ts-for-gir/cli 4.0.0-beta.4 → 4.0.0-beta.40

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 (63) hide show
  1. package/README.md +185 -174
  2. package/bin/ts-for-gir +20593 -0
  3. package/bin/ts-for-gir-dev +43 -0
  4. package/package.json +37 -38
  5. package/src/commands/analyze.ts +344 -0
  6. package/src/commands/command-builder.ts +30 -0
  7. package/src/commands/copy.ts +71 -76
  8. package/src/commands/doc.ts +58 -46
  9. package/src/commands/generate.ts +97 -78
  10. package/src/commands/index.ts +6 -4
  11. package/src/commands/json.ts +104 -0
  12. package/src/commands/list.ts +71 -90
  13. package/src/config/config-loader.ts +203 -0
  14. package/src/config/config-writer.ts +52 -0
  15. package/src/config/defaults.ts +61 -0
  16. package/src/config/index.ts +8 -0
  17. package/src/config/options.ts +292 -0
  18. package/src/config.ts +3 -450
  19. package/src/formatters/typescript-formatter.ts +24 -0
  20. package/src/generation-handler.ts +122 -67
  21. package/src/index.ts +4 -4
  22. package/src/module-loader/dependency-resolver.ts +100 -0
  23. package/src/module-loader/file-finder.ts +65 -0
  24. package/src/module-loader/index.ts +8 -0
  25. package/src/module-loader/module-grouper.ts +77 -0
  26. package/src/module-loader/prompt-handler.ts +111 -0
  27. package/src/module-loader.ts +289 -578
  28. package/src/start.ts +17 -14
  29. package/src/types/command-args.ts +110 -0
  30. package/src/types/command-definition.ts +17 -0
  31. package/src/types/commands.ts +30 -0
  32. package/src/types/index.ts +15 -0
  33. package/src/types/report-types.ts +34 -0
  34. package/lib/commands/copy.d.ts +0 -12
  35. package/lib/commands/copy.js +0 -80
  36. package/lib/commands/copy.js.map +0 -1
  37. package/lib/commands/doc.d.ts +0 -12
  38. package/lib/commands/doc.js +0 -40
  39. package/lib/commands/doc.js.map +0 -1
  40. package/lib/commands/generate.d.ts +0 -12
  41. package/lib/commands/generate.js +0 -73
  42. package/lib/commands/generate.js.map +0 -1
  43. package/lib/commands/index.d.ts +0 -4
  44. package/lib/commands/index.js +0 -5
  45. package/lib/commands/index.js.map +0 -1
  46. package/lib/commands/list.d.ts +0 -12
  47. package/lib/commands/list.js +0 -81
  48. package/lib/commands/list.js.map +0 -1
  49. package/lib/config.d.ts +0 -104
  50. package/lib/config.js +0 -408
  51. package/lib/config.js.map +0 -1
  52. package/lib/generation-handler.d.ts +0 -10
  53. package/lib/generation-handler.js +0 -47
  54. package/lib/generation-handler.js.map +0 -1
  55. package/lib/index.d.ts +0 -4
  56. package/lib/index.js +0 -5
  57. package/lib/index.js.map +0 -1
  58. package/lib/module-loader.d.ts +0 -148
  59. package/lib/module-loader.js +0 -468
  60. package/lib/module-loader.js.map +0 -1
  61. package/lib/start.d.ts +0 -2
  62. package/lib/start.js +0 -16
  63. package/lib/start.js.map +0 -1
package/README.md CHANGED
@@ -18,13 +18,12 @@
18
18
 
19
19
  # CLI
20
20
 
21
- CLI tool to generate Typescript Type Definition files for GJS and node-gtk.
21
+ CLI tool to generate TypeScript type definitions for GObject Introspection Repository (GIR) files, primarily for GJS applications.
22
22
 
23
23
  ## Getting started
24
24
 
25
25
  ``` bash
26
- npm install -g @ts-for-gir/cli
27
- ts-for-gir --help
26
+ npx @ts-for-gir/cli --help
28
27
  ```
29
28
 
30
29
  > Alternatively you can also add @ts-for-gir/cli to your dependencies:
@@ -32,116 +31,112 @@ ts-for-gir --help
32
31
  > npm install --save-dev @ts-for-gir/cli
33
32
  > ```
34
33
  >
35
- > Or without installing using `npx`:
34
+ > Or globally install it:
36
35
  > ```bash
37
- > npx @ts-for-gir/cli --help
36
+ > npm install -g @ts-for-gir/cli
37
+ > ts-for-gir --help
38
38
  > ```
39
39
 
40
- After you have installed `@ts-for-gir/cli` you can run the `ts-for-gir` command:
41
-
42
40
  ```bash
43
- $ ts-for-gir --help
41
+ $ npx @ts-for-gir/cli --help
44
42
 
45
- Typescript .d.ts generator from GIR for GJS or node-gtk
43
+ TypeScript type definition generator for GObject introspection GIR files
46
44
 
47
45
  Commands:
48
- ts-for-gir generate [modules..] Generates .d.ts files from GIR for GJS or nod
49
- e-gtk
46
+ ts-for-gir generate [modules..] Generates .d.ts files from GIR for GJS
50
47
  ts-for-gir list [modules..] Lists all available GIR modules
51
- ts-for-gir doc [modules..] The HTML documentation generator is not yet i
52
- mplemented, but feel free to implement it 🤗
48
+ ts-for-gir analyze Analyze report files generated by ts-for-gir reporter
49
+ ts-for-gir copy [modules..] Scan for *.gir files and copy them to a new directory
50
+ ts-for-gir doc [modules..] The HTML documentation generator is not yet implemented, but feel free to implement it 🤗
53
51
 
54
52
  Options:
55
53
  --version Show version number [boolean]
56
- --help Show help [boolean] [boolean]
54
+ --help Show help [boolean]
57
55
  ```
58
56
 
59
57
  ## Example
60
58
 
61
- To generate the Typescript type definitions of Gtk-4.0 for GJS run:
59
+ To generate the TypeScript type definitions of Gtk-4.0 for GJS run:
62
60
 
63
61
  ```
64
62
  ts-for-gir generate Gtk-4.0
65
63
  ```
66
64
 
67
- To generate this types for [node-gtk](https://github.com/romgrk/node-gtk) run:
68
-
69
- ```
70
- ts-for-gir generate Gtk-4.0 -e node
71
- ```
72
-
73
- You can also look at the [examples](https://github.com/gjsify/ts-for-gir/tree/main/examples) to see how the types are generated there.
65
+ You can also look at the [examples](https://github.com/gjsify/ts-for-gir/tree/main/examples) to see how the types are generated and/or used there.
74
66
 
75
67
  ## Generate .d.ts files
76
68
 
77
69
  ```bash
78
- $ ts-for-gir generate --help
70
+ $ npx @ts-for-gir/cli generate --help
79
71
 
80
72
  ts-for-gir generate [modules..]
81
73
 
82
- ts-for-gir generate [modules..]
83
-
84
- Generates .d.ts files from GIR for GJS or node-gtk
74
+ Generates .d.ts files from GIR for GJS
85
75
 
86
76
  Options:
87
77
  --version Show version number [boolean]
88
78
  --help Show help [boolean]
89
- --modules GIR modules to load, e.g. 'Gio-2.0'. Accepts mul
90
- tiple modules [array] [default: ["*"]]
79
+ --modules GIR modules to load, e.g. 'Gio-2.0'. Accepts multiple modules [array] [default: ["*"]]
91
80
  -g, --girDirectories GIR directories
92
- [array] [default: ["/usr/local/share/gir-1.0","/usr/share/gir-1.0","/usr/share
93
- /gnome-shell","/usr/share/gnome-shell/gir-1.0","/usr/lib64/mutter-10","/usr/li
94
- b64/mutter-11","/usr/lib64/mutter-12","/usr/lib/x86_64-linux-gnu/mutter-10","/
95
- usr/lib/x86_64-linux-gnu/mutter-11","/usr/lib/x86_64-linux-gnu/mutter-12","/ho
96
- me/jumplink/.local/share/flatpak/exports/share/gir-1.0","/var/lib/flatpak/expo
97
- rts/share/gir-1.0"]]
81
+ [array] [default: ["/usr/local/share/gir-1.0","/usr/share/gir-1.0","/usr/share/*/gir-1.0","/usr/share/gnome-shell","/usr/share/gnome-shell/gir-1.0","/usr/lib64/mutter-*","/usr/lib/mutter-*","/usr/lib/x86_64-linux-gnu/mutter-*"]]
98
82
  --root Root directory of your project
99
- [string] [default: "/home/jumplink/Projekte/ts-for-gir"]
83
+ [string] [default: "/home/jumplink/Projekte/gjsify/ts-for-gir"]
100
84
  -o, --outdir Directory to output to
101
85
  [string] [default: "./@types"]
102
86
  -i, --ignore Modules that should be ignored
103
87
  [array] [default: []]
104
88
  -v, --verbose Switch on/off the verbose mode
105
- [string] [default: false]
106
- --ignoreVersionConflicts Do not ask for package versions if multiple vers
107
- ions are found [string] [default: false]
89
+ [boolean] [default: false]
90
+ --ignoreVersionConflicts Skip prompts for library version selection when
91
+ multiple versions are detected
92
+ [boolean] [default: false]
108
93
  -p, --print Print the output to console and create no files
109
- [string] [default: false]
110
- --configName Name of the config if you want to use a differen
111
- t name [string] [default: ".ts-for-girrc.js"]
112
- -d, --noNamespace Do not export all symbols for each module as a n
113
- amespace [string] [default: false]
94
+ [boolean] [default: false]
95
+ --configName Specify a custom name for the configuration file
96
+ [string] [default: ".ts-for-girrc.js"]
97
+ -d, --noNamespace Do not export all symbols for each module as a namespace
98
+ [boolean] [default: false]
114
99
  -n, --noComments Do not generate documentation comments
115
- [string] [default: false]
116
- --noDebugComments Do not generate debugging inline comments
117
- [string] [default: false]
118
- --fixConflicts Fix Inheritance and implementation type conflict
119
- s [string] [default: true]
100
+ [boolean] [default: false]
120
101
  --promisify Generate promisified functions for async/finish
121
- calls [string] [default: true]
102
+ calls [boolean] [default: true]
122
103
  --npmScope Scope of the generated NPM packages
123
104
  [string] [default: "@girs"]
105
+ --workspace Uses the workspace protocol for the generated packages
106
+ which can be used with package managers like
107
+ Yarn and PNPM [boolean] [default: false]
108
+ --onlyVersionPrefix Only use the version prefix for the ambient module
109
+ exports. This is useful if you want to use different
110
+ library versions of the same library in your project.
111
+ [boolean] [default: false]
112
+ --noPrettyPrint Do not prettify the generated types
113
+ [boolean] [default: false]
114
+ --noAdvancedVariants Disable GLib.Variant class with string parsing
115
+ [boolean] [default: false]
116
+ --package Generate the typescript types with package.json
117
+ support [boolean] [default: false]
118
+ --reporter Enable generation problem reporter and create a
119
+ detailed report file [boolean] [default: false]
120
+ --reporterOutput Output file path for the reporter (default:
121
+ ts-for-gir-report.json)
122
+ [string] [default: "ts-for-gir-report.json"]
124
123
 
125
124
  Examples:
126
- ts-for-gir generate Run 'ts-for-gir generate' in your gj
127
- s or node-gtk project to generate ty
128
- pings for your project, pass the gir
129
- modules you need for your project
130
- ts-for-gir generate Gtk* You can also use wild cards
131
- ts-for-gir generate '*' If you want to parse all of your loc
132
- ally installed gir modules run
133
- ts-for-gir generate '*' -e gjs Generate .d.ts. files only for gjs
134
- ts-for-gir generate '*' -e node Generate .d.ts. files only for node
135
- ts-for-gir generate --configName='.ts-fo Use a special config file
136
- r-gir.gtk4.rc.js
137
- ts-for-gir generate --ignore=Gtk-4.0 xra Generate .d.ts. files but not for Gt
138
- ndr-1.3 k-4.0 and xrandr-1.3
125
+ ts-for-gir generate Run 'ts-for-gir generate' in your gjs
126
+ project to generate typings for your
127
+ project, pass the gir modules you need
128
+ ts-for-gir generate 'Gtk*' You can also use wild cards
129
+ ts-for-gir generate '*' If you want to parse all of your locally
130
+ installed gir modules run
131
+ ts-for-gir generate --configName='.ts-for-gir.gtk4.rc.js' Use a special config file
132
+ ts-for-gir generate --ignore=Gtk-4.0 xrandr-1.3 Generate .d.ts files but not for
133
+ Gtk-4.0 and xrandr-1.3
139
134
  ```
140
135
 
141
136
  ## List available GIR modules
142
137
 
143
138
  ```bash
144
- $ ts-for-gir list --help
139
+ $ npx @ts-for-gir/cli list --help
145
140
 
146
141
  ts-for-gir list [modules..]
147
142
 
@@ -150,38 +145,113 @@ Lists all available GIR modules
150
145
  Options:
151
146
  --version Show version number [boolean]
152
147
  --help Show help [boolean]
153
- --modules GIR modules to load, e.g. 'Gio-2.0'. Accepts multiple mo
154
- dules [array] [default: ["*"]]
148
+ --modules GIR modules to load, e.g. 'Gio-2.0'. Accepts multiple modules
149
+ [array] [default: ["*"]]
155
150
  -g, --girDirectories GIR directories
156
- [array] [default: ["/usr/local/share/gir-1.0","/usr/share/gir-1.0","/usr/share
157
- /gnome-shell","/usr/share/gnome-shell/gir-1.0","/usr/lib64/mutter-10","/usr/li
158
- b64/mutter-11","/usr/lib64/mutter-12","/usr/lib/x86_64-linux-gnu/mutter-10","/
159
- usr/lib/x86_64-linux-gnu/mutter-11","/usr/lib/x86_64-linux-gnu/mutter-12","/ho
160
- me/jumplink/.local/share/flatpak/exports/share/gir-1.0","/var/lib/flatpak/expo
161
- rts/share/gir-1.0"]]
151
+ [array] [default: ["/usr/local/share/gir-1.0","/usr/share/gir-1.0","/usr/share/*/gir-1.0","/usr/share/gnome-shell","/usr/share/gnome-shell/gir-1.0","/usr/lib64/mutter-*","/usr/lib/mutter-*","/usr/lib/x86_64-linux-gnu/mutter-*"]]
152
+ --root Root directory of your project
153
+ [string] [default: "/home/jumplink/Projekte/gjsify/ts-for-gir"]
162
154
  -i, --ignore Modules that should be ignored [array] [default: []]
163
- --configName Name of the config if you want to use a different name
155
+ --configName Specify a custom name for the configuration file
164
156
  [string] [default: ".ts-for-girrc.js"]
165
- -v, --verbose Switch on/off the verbose mode [string] [default: false]
157
+ -v, --verbose Switch on/off the verbose mode [boolean] [default: false]
166
158
 
167
159
  Examples:
168
- ts-for-gir list -g ./vala-girs/gir-1.0 Lists all available GIR modules in .
169
- /vala-girs/gir-1.0
170
- ts-for-gir list --ignore=Gtk-3.0 xrandr- Lists all available GIR modules in /
171
- 1.3 usr/share/gir-1.0 but not Gtk-3.0 an
172
- d xrandr-1.3
160
+ ts-for-gir list -g ./vala-girs/gir-1.0 Lists all available GIR modules in ./vala-girs/gir-1.0
161
+ ts-for-gir list --ignore=Gtk-3.0 xrandr-1.3 Lists all available GIR modules but not Gtk-3.0 and xrandr-1.3
173
162
  ```
174
163
 
164
+ ## Analyze report files
165
+
166
+ ```bash
167
+ $ npx @ts-for-gir/cli analyze --help
168
+
169
+ ts-for-gir analyze [options]
170
+
171
+ Analyze report files generated by ts-for-gir reporter
172
+
173
+ Options:
174
+ --version Show version number [boolean]
175
+ --help Show help [boolean]
176
+ -f, --reportFile Path to the report file to analyze [string] [required]
177
+ --severity Filter by problem severity (debug, info, warning, error, critical)
178
+ [array]
179
+ --category Filter by problem category [array]
180
+ --namespace Filter by namespace/module [array]
181
+ --type Filter by specific type name [array]
182
+ --search Search for text in messages, details, or type names
183
+ [string]
184
+ --since Filter problems since date/time (ISO format) [string]
185
+ --until Filter problems until date/time (ISO format) [string]
186
+ --top Show top N most problematic items [number]
187
+ --format Output format (table, json, summary)
188
+ [string] [default: "summary"]
189
+ --export Export filtered results to file [string]
190
+ --verbose Enable verbose output [boolean] [default: false]
191
+
192
+ Examples:
193
+ ts-for-gir analyze -f ./ts-for-gir-report.json
194
+ Show summary statistics of the report
195
+ ts-for-gir analyze -f ./report.json --severity error critical
196
+ Show only critical and error problems
197
+ ts-for-gir analyze -f ./report.json --category type_resolution --format table
198
+ Show type resolution problems in table format
199
+ ts-for-gir analyze -f ./report.json --namespace Gtk --top 10
200
+ Show top 10 problems in Gtk namespace
201
+ ts-for-gir analyze -f ./report.json --search "Unable to resolve" --export errors.json
202
+ Export unresolved type errors to file
203
+ ts-for-gir analyze -f ./report.json --type time_t --format json
204
+ Analyze specific type problems in JSON format
205
+ ```
206
+
207
+ The `analyze` command is designed to help developers and AI agents efficiently debug type generation issues by providing powerful filtering and analysis capabilities for ts-for-gir report files.
208
+
209
+ **Key Features:**
210
+ - **Comprehensive Filtering**: Filter by severity, category, namespace, type name, or search text
211
+ - **Multiple Output Formats**: Table, JSON, or summary format for different use cases
212
+ - **Statistical Analysis**: Show most problematic types, namespaces, and categories
213
+ - **Export Capabilities**: Save filtered results for further analysis
214
+ - **Time-based Filtering**: Analyze problems within specific time ranges
215
+ - **AI-Friendly**: Structured output perfect for automated analysis and debugging
216
+
217
+ **Common Use Cases:**
218
+ - Debug type resolution failures for specific libraries
219
+ - Identify patterns in generation problems across modules
220
+ - Export specific error categories for detailed analysis
221
+ - Monitor type generation quality over time
222
+ - Automated problem detection in CI/CD pipelines
223
+
175
224
  ## Generate HTML documentation
176
225
 
177
226
  ```bash
178
- $ ts-for-gir doc --help
227
+ $ npx @ts-for-gir/cli doc --help
179
228
 
180
229
  ts-for-gir doc [modules..]
181
230
 
182
- The HTML documentation generator is not yet implemented, but feel free to implem
183
- ent it 🤗
231
+ The HTML documentation generator is not yet implemented, but feel free to implement it 🤗
232
+
233
+ Options:
234
+ --version Show version number [boolean]
235
+ --help Show help [boolean]
236
+ --modules GIR modules to load, e.g. 'Gio-2.0'. Accepts multiple modules
237
+ [array] [default: ["*"]]
238
+ -g, --girDirectories GIR directories
239
+ [array] [default: ["/usr/local/share/gir-1.0","/usr/share/gir-1.0","/usr/share/*/gir-1.0","/usr/share/gnome-shell","/usr/share/gnome-shell/gir-1.0","/usr/lib64/mutter-*","/usr/lib/mutter-*","/usr/lib/x86_64-linux-gnu/mutter-*"]]
240
+ --root Root directory of your project
241
+ [string] [default: "/home/jumplink/Projekte/gjsify/ts-for-gir"]
242
+ -o, --outdir Directory to output to
243
+ [string] [default: "./@types"]
244
+ -i, --ignore Modules that should be ignored
245
+ [array] [default: []]
246
+ -v, --verbose Switch on/off the verbose mode
247
+ [boolean] [default: false]
248
+ --ignoreVersionConflicts Skip prompts for library version selection when
249
+ multiple versions are detected
250
+ [boolean] [default: false]
251
+ --configName Specify a custom name for the configuration file
252
+ [string] [default: ".ts-for-girrc.js"]
184
253
  ```
254
+
185
255
  ## Config
186
256
 
187
257
  In addition to the option of passing options as a CLI flag, you can also write them in a config file.
@@ -190,16 +260,11 @@ To do that, create a new config file called `.ts-for-girrc.js` in your project r
190
260
  ```js
191
261
  // or on CommonJs: exports.default = {
192
262
  export default {
193
- print: false,
194
263
  verbose: true,
195
- environments: ['gjs', 'node'],
196
264
  outdir: '@types',
197
265
  girDirectories: ['/usr/share/gir-1.0'],
198
266
  modules: ['*'],
199
267
  ignore: [],
200
- noNamespace: false,
201
- buildType: 'lib',
202
- moduleType: 'esm'
203
268
  }
204
269
  ```
205
270
 
@@ -241,97 +306,23 @@ In this example, the generated TypeScript types will be saved in the `./types` d
241
306
 
242
307
  It is important to note that the outdir option should be a valid directory path, and `ts-for-gir` will create the directory if it does not exist. If the specified directory already contains files, `ts-for-gir` will overwrite the existing files with the newly generated types.
243
308
 
244
- ### environments
245
- The `environments` option allows you to specify the JavaScript environment for which you want to generate the TypeScript type definitions. The available values are `"gjs"` and `"node"`. You can also specify both environments.
246
-
247
- The default value for this option is `"gjs"`.
248
-
249
- To specify the environments option when running ts-for-gir, you would add the `--environments` or `-e` flag, followed by a comma-separated list of values. For example:
250
-
251
- ```bash
252
- ts-for-gir generate * --environments gjs node
253
- ```
254
-
255
- This option is useful if you want to generate type definitions for use in different JavaScript environments, such as in a `GJS` application or in a `Node.js` application using [node-gtk](https://github.com/romgrk/node-gtk). By specifying the appropriate environment, ts-for-gir can generate type definitions that are optimized for that environment, ensuring that your code will be type-checked correctly and you will receive meaningful error messages in your development environment.
256
-
257
309
  ### ignore
258
310
  The `ignore` CLI option allows you to specify modules that should be ignored when generating TypeScript types. This can be useful if you have multiple versions of a library installed but only want to generate types for one of them.
259
311
 
260
312
  To use the ignore option, pass one or more module names as arguments. For example, to ignore the `Gtk-3.0` module, you would use the following command:
261
313
 
262
314
  ```bash
263
- ts-for-gir generate Gtk-* --ignore Gtk-3.0
315
+ ts-for-gir generate Gtk-* --ignore */Gtk-3.0
264
316
  ```
265
317
 
266
318
  You can also ignore multiple modules:
267
319
 
268
320
  ```bash
269
- ts-for-gir generate * --ignore Gtk-2.0 Gtk-3.0 Gtk-4.0
321
+ ts-for-gir generate * --ignore */Gtk-2.0 */Gtk-3.0 */Gtk-4.0
270
322
  ```
271
323
 
272
324
  Note that ignoring a module will prevent ts-for-gir from generating types for that module and any submodules that it might contain.
273
325
 
274
- ### buildType
275
- `ts-for-gir` supports two build types for generating the types: `"lib"` and `"types"`.
276
-
277
- * If `"lib"` is specified, `.js` files are generated as well as `.d.ts`, this is useful for some bundlers that expect a `.js` file. Some bundlers are also able to generate the import of this file only once, even if it occurs multiple times in your code.
278
- * If `"types"` is specified, only `.d.ts` files are generated. In this mode it is recommended to add the generated `"@types/gjs.d.ts"` and `"@types/ambient.d.ts"` under `"include"` in the `tsconfig` to make the generated types known in your project.
279
-
280
- ### moduleType
281
- The `moduleType` CLI option determines the format in which the generated JavaScript files should be exported. The option takes either `"esm"` or `"cjs"` as its value, with `"esm"` being the default.
282
-
283
- > This option is only relevant if the `buildType` is set to `"lib"`. The choice of `moduleType` may affect how the generated code is used in other parts of your project, so it's important to choose the right format that works best for your use case.
284
-
285
- The choice of `moduleType` is also important in the context of the bundler that you plan to use in your project. For example, if you are using a bundler that only supports ESM (such as Rollup), you would need to set `moduleType` to "esm". On the other hand, if you are using a bundler that supports both ESM and CommonJS (such as Webpack), you can choose whichever format you prefer. Ultimately, the choice of `moduleType` will depend on your project requirements and the tools that you are using. For Example, if you want to build a GNOME Shell Extension, you should use `"cjs"` because `ESM` is currently not supported for GNOME Shell Extensions. For [node-gtk](https://github.com/romgrk/node-gtk) you also need to use `"cjs"`. If you want to build a regular GJS Application we recommend to use `ESM`.
286
-
287
- When `"esm"` is set, the generated JavaScript files will use the ECMAScript module (ESM) format for imports and exports. For example, the generated code might look like this:
288
-
289
- ```ts
290
- // Gtk-4.0.d.ts
291
- import type GLib from './GLib-2.0.js';
292
-
293
- namespace Gtk {
294
- class Window extends Widget {
295
- ...
296
- }
297
- function builder_error_quark(): GLib.Quark
298
- }
299
-
300
- export default Gtk;
301
- ```
302
-
303
- ```js
304
- // Gtk-4.0.js
305
- import Gtk from 'gi://Gtk?version=4.0';
306
- export default Gtk;
307
- ```
308
-
309
- > The `"esm"` module type is recommended for GJS applications as it makes use of the ESM import syntax, which is more modern and flexible compared to imports.gi / CommonJS imports. This allows for a more streamlined and convenient way of using the generated types in your GJS application. Support for ES modules can be activated in `gjs` with its `gjs -m` flag.
310
-
311
- When `"cjs"` and [`noNamespace`](#nonamespace) is set, the generated JavaScript files will use the CommonJS format exports and the `imports.gi` object for imports. For example:
312
-
313
- ```ts
314
- // Gtk-4.0.d.ts
315
- import type * as GLib from './GLib-2.0.js';
316
-
317
- export class Window extends Widget {
318
- ...
319
- }
320
- export function builder_error_quark(): GLib.Quark
321
- ```
322
-
323
- ```js
324
- // Gtk-4.0.js
325
- imports.gi.versions.Gtk = '4.0'
326
- const Gtk = imports.gi.Gtk;
327
-
328
- module.exports = { Gtk };
329
- exports.default = Gtk;
330
- ```
331
-
332
- > It is recommended to also set the [noNamespace](#nonamespace) option to true when using the `"cjs"` moduleType option. This will ensure that the generated code is fully compatible with the CommonJS format.
333
-
334
-
335
326
  ### verbose
336
327
  The `--verbose` or `-v` option is a flag that can be used to enable verbose output in the console when running the CLI. When this option is enabled, additional warnings and information about the processing of GIR files and the generation of TypeScript definitions will be printed to the console. This information can be useful for debugging purposes or for understanding what is happening behind the scenes when generating the TypeScript definitions.
337
328
 
@@ -374,20 +365,24 @@ When `noComments` is set to `true`, `ts-for-gir` will not include TSDoc comments
374
365
  To use the noComments option, pass it as a command line argument to `ts-for-gir`:
375
366
 
376
367
  ```bash
377
- ts-for-gir generate * --noComments`
368
+ ts-for-gir generate * --noComments
378
369
  ```
379
370
 
380
- ### noDebugComments
381
- The `noDebugComments` CLI option is used to control the generation of inline comments in the generated TypeScript files. These comments are used for debugging purposes and can be useful in tracking down issues with the generated types.
371
+ ### noPrettyPrint
372
+ The `noPrettyPrint` option controls whether the generated TypeScript definitions are formatted using Prettier. When set to `true`, the output will not be formatted, which can be useful for debugging or in cases where you want to handle formatting separately.
382
373
 
383
- By default, the `noDebugComments` option is disabled and these inline comments will be included in the generated TypeScript files. If you do not require these comments for debugging purposes, you can use the -`-noDebugComments` option to disable their generation and keep your TypeScript code more compact.
374
+ ```bash
375
+ ts-for-gir generate * --noPrettyPrint
376
+ ```
384
377
 
385
- ### fixConflicts
386
- The `fixConflicts` CLI option is used to resolve type conflicts between the GObject Introspection descriptions in GIR XML format and TypeScript. For example, properties in the GIR XML format can be overwritten by methods, which is not allowed in TypeScript. When this option is active, `ts-for-gir` attempts to resolve these conflicts. However, it's important to note that this may result in generating types that do not exist.
378
+ ### noAdvancedVariants
379
+ The `noAdvancedVariants` option disables the advanced GLib.Variant class with string parsing capabilities. This option is enabled by default (`false`) as these advanced features can impact performance, especially with older TypeScript versions.
387
380
 
388
- > If you have found an issue with the `fixConflicts` CLI option, we encourage you to report it. Reporting issues helps improve the quality of `ts-for-gir` and makes it a better tool for everyone.
381
+ ```bash
382
+ ts-for-gir generate * --noAdvancedVariants=false
383
+ ```
389
384
 
390
- # package
385
+ ### package
391
386
 
392
387
  The `--package` option of ts-for-gir is used to package the generated TypeScript type definitions into an NPM package. The generated package can be easily installed and used in other TypeScript projects via `npm install`.
393
388
 
@@ -395,14 +390,14 @@ The `--package` option of ts-for-gir is used to package the generated TypeScript
395
390
 
396
391
  When this option is used, each GObject introspection module will be packaged into its own NPM package. The package name will be in the format of `@girs/<lower case module name>-<version>`.
397
392
 
398
- For example, if the `--package` option is used to generate the TypeScript type definitions for the `Gtk-4.0` module, then the generated NPM package will have the name `@girs/gtk-3.0`.
393
+ For example, if the `--package` option is used to generate the TypeScript type definitions for the `Gtk-4.0` module, then the generated NPM package will have the name `@girs/gtk-4.0`.
399
394
 
400
395
  > You can change the NPM package scope name with the [`--npmScope`](#npmscope) option.
401
396
 
402
397
  To use the generated NPM package in your TypeScript project, you can also install our pregenerated packages:
403
398
 
404
399
  ```bash
405
- npm install @girs/gtk-3.0
400
+ npm install @girs/gtk-4.0
406
401
  ```
407
402
 
408
403
  Then, import the desired module in your TypeScript code:
@@ -426,10 +421,10 @@ The `--npmScope` CLI option can be used to specify a custom NPM package scope na
426
421
  Here's an example command to generate NPM packages with a custom scope name:
427
422
 
428
423
  ```bash
429
- ts-for-gir --buildType lib --package --npmScope my-scope
424
+ ts-for-gir generate * --package --npmScope my-scope
430
425
  ```
431
426
 
432
- This command will generate NPM packages with the scope `my-scope` instead of the default `@girs` scope. For `Gtk-4.0` this would generate a package with the name of `@my-scope/gtk-4.0`.
427
+ This command will generate NPM packages with the scope `@my-scope` instead of the default `@girs` scope. For `Gtk-4.0` this would generate a package with the name of `@my-scope/gtk-4.0`.
433
428
 
434
429
  ## Ambient modules
435
430
 
@@ -473,4 +468,20 @@ declare module "gi://Gtk" {
473
468
  import Gtk from "gi://Gtk?version=4.0";
474
469
  export default Gtk;
475
470
  }
471
+ ```
472
+
473
+ ## reporter
474
+
475
+ The `--reporter` option enables the generation of a problem reporter and creates a detailed report file.
476
+
477
+ ```bash
478
+ ts-for-gir generate * --reporter
479
+ ```
480
+
481
+ ## reporterOutput
482
+
483
+ The `--reporterOutput` option specifies the output file path for the reporter. The default value is `ts-for-gir-report.json`.
484
+
485
+ ```bash
486
+ ts-for-gir generate * --reporterOutput custom-report.json
476
487
  ```