@ts-for-gir/cli 3.0.0-beta.10

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 (773) hide show
  1. package/README.md +420 -0
  2. package/lib/commands/doc.d.ts +27 -0
  3. package/lib/commands/doc.js +48 -0
  4. package/lib/commands/doc.js.map +1 -0
  5. package/lib/commands/generate.d.ts +49 -0
  6. package/lib/commands/generate.js +73 -0
  7. package/lib/commands/generate.js.map +1 -0
  8. package/lib/commands/index.d.ts +3 -0
  9. package/lib/commands/index.js +4 -0
  10. package/lib/commands/index.js.map +1 -0
  11. package/lib/commands/list.d.ts +21 -0
  12. package/lib/commands/list.js +77 -0
  13. package/lib/commands/list.js.map +1 -0
  14. package/lib/config.d.ts +88 -0
  15. package/lib/config.js +471 -0
  16. package/lib/config.js.map +1 -0
  17. package/lib/conflict-resolver.d.ts +155 -0
  18. package/lib/conflict-resolver.js +1103 -0
  19. package/lib/conflict-resolver.js.map +1 -0
  20. package/lib/constants.d.ts +18 -0
  21. package/lib/constants.js +23 -0
  22. package/lib/constants.js.map +1 -0
  23. package/lib/dependency-manager.d.ts +34 -0
  24. package/lib/dependency-manager.js +78 -0
  25. package/lib/dependency-manager.js.map +1 -0
  26. package/lib/generation-handler.d.ts +12 -0
  27. package/lib/generation-handler.js +63 -0
  28. package/lib/generation-handler.js.map +1 -0
  29. package/lib/generator.d.ts +5 -0
  30. package/lib/generator.js +2 -0
  31. package/lib/generator.js.map +1 -0
  32. package/lib/gir-factory.d.ts +52 -0
  33. package/lib/gir-factory.js +376 -0
  34. package/lib/gir-factory.js.map +1 -0
  35. package/lib/gir-module.d.ts +259 -0
  36. package/lib/gir-module.js +2181 -0
  37. package/lib/gir-module.js.map +1 -0
  38. package/lib/html-doc-generator.d.ts +13 -0
  39. package/lib/html-doc-generator.js +18 -0
  40. package/lib/html-doc-generator.js.map +1 -0
  41. package/lib/index.d.ts +17 -0
  42. package/lib/index.js +18 -0
  43. package/lib/index.js.map +1 -0
  44. package/lib/injection/callbacks/gjs/Gio-2.0.d.ts +2 -0
  45. package/lib/injection/callbacks/gjs/Gio-2.0.js +36 -0
  46. package/lib/injection/callbacks/gjs/Gio-2.0.js.map +1 -0
  47. package/lib/injection/callbacks/gjs/index.d.ts +2 -0
  48. package/lib/injection/callbacks/gjs/index.js +3 -0
  49. package/lib/injection/callbacks/gjs/index.js.map +1 -0
  50. package/lib/injection/callbacks/index.d.ts +4 -0
  51. package/lib/injection/callbacks/index.js +4 -0
  52. package/lib/injection/callbacks/index.js.map +1 -0
  53. package/lib/injection/callbacks/node-gtk/index.d.ts +2 -0
  54. package/lib/injection/callbacks/node-gtk/index.js +2 -0
  55. package/lib/injection/callbacks/node-gtk/index.js.map +1 -0
  56. package/lib/injection/classes/GLib-2-0.d.ts +2 -0
  57. package/lib/injection/classes/GLib-2-0.js +35 -0
  58. package/lib/injection/classes/GLib-2-0.js.map +1 -0
  59. package/lib/injection/classes/gjs/GLib-2.0.d.ts +2 -0
  60. package/lib/injection/classes/gjs/GLib-2.0.js +205 -0
  61. package/lib/injection/classes/gjs/GLib-2.0.js.map +1 -0
  62. package/lib/injection/classes/gjs/GObject-2.0.d.ts +2 -0
  63. package/lib/injection/classes/gjs/GObject-2.0.js +634 -0
  64. package/lib/injection/classes/gjs/GObject-2.0.js.map +1 -0
  65. package/lib/injection/classes/gjs/Gio-2.0.d.ts +5 -0
  66. package/lib/injection/classes/gjs/Gio-2.0.js +218 -0
  67. package/lib/injection/classes/gjs/Gio-2.0.js.map +1 -0
  68. package/lib/injection/classes/gjs/index.d.ts +2 -0
  69. package/lib/injection/classes/gjs/index.js +5 -0
  70. package/lib/injection/classes/gjs/index.js.map +1 -0
  71. package/lib/injection/classes/index.d.ts +4 -0
  72. package/lib/injection/classes/index.js +5 -0
  73. package/lib/injection/classes/index.js.map +1 -0
  74. package/lib/injection/classes/node-gtk/GLib-2.0.d.ts +2 -0
  75. package/lib/injection/classes/node-gtk/GLib-2.0.js +19 -0
  76. package/lib/injection/classes/node-gtk/GLib-2.0.js.map +1 -0
  77. package/lib/injection/classes/node-gtk/GObject-2.0.d.ts +2 -0
  78. package/lib/injection/classes/node-gtk/GObject-2.0.js +66 -0
  79. package/lib/injection/classes/node-gtk/GObject-2.0.js.map +1 -0
  80. package/lib/injection/classes/node-gtk/Gdk-4.0.d.ts +2 -0
  81. package/lib/injection/classes/node-gtk/Gdk-4.0.js +32 -0
  82. package/lib/injection/classes/node-gtk/Gdk-4.0.js.map +1 -0
  83. package/lib/injection/classes/node-gtk/Gio-2.0.d.ts +2 -0
  84. package/lib/injection/classes/node-gtk/Gio-2.0.js +14 -0
  85. package/lib/injection/classes/node-gtk/Gio-2.0.js.map +1 -0
  86. package/lib/injection/classes/node-gtk/Graphene-1.0.d.ts +2 -0
  87. package/lib/injection/classes/node-gtk/Graphene-1.0.js +133 -0
  88. package/lib/injection/classes/node-gtk/Graphene-1.0.js.map +1 -0
  89. package/lib/injection/classes/node-gtk/Gtk-3.0.d.ts +2 -0
  90. package/lib/injection/classes/node-gtk/Gtk-3.0.js +31 -0
  91. package/lib/injection/classes/node-gtk/Gtk-3.0.js.map +1 -0
  92. package/lib/injection/classes/node-gtk/Gtk-4.0.d.ts +2 -0
  93. package/lib/injection/classes/node-gtk/Gtk-4.0.js +52 -0
  94. package/lib/injection/classes/node-gtk/Gtk-4.0.js.map +1 -0
  95. package/lib/injection/classes/node-gtk/Pango-1.0.d.ts +2 -0
  96. package/lib/injection/classes/node-gtk/Pango-1.0.js +31 -0
  97. package/lib/injection/classes/node-gtk/Pango-1.0.js.map +1 -0
  98. package/lib/injection/classes/node-gtk/index.d.ts +2 -0
  99. package/lib/injection/classes/node-gtk/index.js +19 -0
  100. package/lib/injection/classes/node-gtk/index.js.map +1 -0
  101. package/lib/injection/index.d.ts +3 -0
  102. package/lib/injection/index.js +4 -0
  103. package/lib/injection/index.js.map +1 -0
  104. package/lib/injection/injector.d.ts +17 -0
  105. package/lib/injection/injector.js +139 -0
  106. package/lib/injection/injector.js.map +1 -0
  107. package/lib/logger.d.ts +36 -0
  108. package/lib/logger.js +137 -0
  109. package/lib/logger.js.map +1 -0
  110. package/lib/messages.d.ts +31 -0
  111. package/lib/messages.js +46 -0
  112. package/lib/messages.js.map +1 -0
  113. package/lib/module-loader.d.ts +134 -0
  114. package/lib/module-loader.js +475 -0
  115. package/lib/module-loader.js.map +1 -0
  116. package/lib/start.d.ts +2 -0
  117. package/lib/start.js +15 -0
  118. package/lib/start.js.map +1 -0
  119. package/lib/symtable.d.ts +24 -0
  120. package/lib/symtable.js +63 -0
  121. package/lib/symtable.js.map +1 -0
  122. package/lib/template-processor.d.ts +74 -0
  123. package/lib/template-processor.js +165 -0
  124. package/lib/template-processor.js.map +1 -0
  125. package/lib/transformation.d.ts +156 -0
  126. package/lib/transformation.js +524 -0
  127. package/lib/transformation.js.map +1 -0
  128. package/lib/type-definition-generator.d.ts +116 -0
  129. package/lib/type-definition-generator.js +996 -0
  130. package/lib/type-definition-generator.js.map +1 -0
  131. package/lib/types/answer-version.d.ts +4 -0
  132. package/lib/types/answer-version.js +2 -0
  133. package/lib/types/answer-version.js.map +1 -0
  134. package/lib/types/build-type.d.ts +1 -0
  135. package/lib/types/build-type.js +2 -0
  136. package/lib/types/build-type.js.map +1 -0
  137. package/lib/types/class-parent.d.ts +13 -0
  138. package/lib/types/class-parent.js +2 -0
  139. package/lib/types/class-parent.js.map +1 -0
  140. package/lib/types/config-flags.d.ts +4 -0
  141. package/lib/types/config-flags.js +2 -0
  142. package/lib/types/config-flags.js.map +1 -0
  143. package/lib/types/conflict-child-element.d.ts +10 -0
  144. package/lib/types/conflict-child-element.js +2 -0
  145. package/lib/types/conflict-child-element.js.map +1 -0
  146. package/lib/types/conflict-grouped-element.d.ts +6 -0
  147. package/lib/types/conflict-grouped-element.js +2 -0
  148. package/lib/types/conflict-grouped-element.js.map +1 -0
  149. package/lib/types/conflict-grouped-elements.d.ts +4 -0
  150. package/lib/types/conflict-grouped-elements.js +2 -0
  151. package/lib/types/conflict-grouped-elements.js.map +1 -0
  152. package/lib/types/construct-name.d.ts +1 -0
  153. package/lib/types/construct-name.js +2 -0
  154. package/lib/types/construct-name.js.map +1 -0
  155. package/lib/types/dependency-map.d.ts +4 -0
  156. package/lib/types/dependency-map.js +2 -0
  157. package/lib/types/dependency-map.js.map +1 -0
  158. package/lib/types/dependency.d.ts +15 -0
  159. package/lib/types/dependency.js +2 -0
  160. package/lib/types/dependency.js.map +1 -0
  161. package/lib/types/environment.d.ts +1 -0
  162. package/lib/types/environment.js +2 -0
  163. package/lib/types/environment.js.map +1 -0
  164. package/lib/types/file-info.d.ts +14 -0
  165. package/lib/types/file-info.js +2 -0
  166. package/lib/types/file-info.js.map +1 -0
  167. package/lib/types/generate-config.d.ts +34 -0
  168. package/lib/types/generate-config.js +2 -0
  169. package/lib/types/generate-config.js.map +1 -0
  170. package/lib/types/generator-type.d.ts +4 -0
  171. package/lib/types/generator-type.js +6 -0
  172. package/lib/types/generator-type.js.map +1 -0
  173. package/lib/types/gir-alias-element.d.ts +13 -0
  174. package/lib/types/gir-alias-element.js +2 -0
  175. package/lib/types/gir-alias-element.js.map +1 -0
  176. package/lib/types/gir-annotation.d.ts +9 -0
  177. package/lib/types/gir-annotation.js +2 -0
  178. package/lib/types/gir-annotation.js.map +1 -0
  179. package/lib/types/gir-any-element.d.ts +2 -0
  180. package/lib/types/gir-any-element.js +2 -0
  181. package/lib/types/gir-any-element.js.map +1 -0
  182. package/lib/types/gir-any-type.d.ts +5 -0
  183. package/lib/types/gir-any-type.js +2 -0
  184. package/lib/types/gir-any-type.js.map +1 -0
  185. package/lib/types/gir-array-type.d.ts +20 -0
  186. package/lib/types/gir-array-type.js +3 -0
  187. package/lib/types/gir-array-type.js.map +1 -0
  188. package/lib/types/gir-bitfield-element.d.ts +17 -0
  189. package/lib/types/gir-bitfield-element.js +2 -0
  190. package/lib/types/gir-bitfield-element.js.map +1 -0
  191. package/lib/types/gir-boolean.d.ts +1 -0
  192. package/lib/types/gir-boolean.js +2 -0
  193. package/lib/types/gir-boolean.js.map +1 -0
  194. package/lib/types/gir-boxed-element.d.ts +15 -0
  195. package/lib/types/gir-boxed-element.js +2 -0
  196. package/lib/types/gir-boxed-element.js.map +1 -0
  197. package/lib/types/gir-c-include.d.ts +7 -0
  198. package/lib/types/gir-c-include.js +2 -0
  199. package/lib/types/gir-c-include.js.map +1 -0
  200. package/lib/types/gir-callable-attrs.d.ts +15 -0
  201. package/lib/types/gir-callable-attrs.js +3 -0
  202. package/lib/types/gir-callable-attrs.js.map +1 -0
  203. package/lib/types/gir-callable-param-element.d.ts +30 -0
  204. package/lib/types/gir-callable-param-element.js +2 -0
  205. package/lib/types/gir-callable-param-element.js.map +1 -0
  206. package/lib/types/gir-callable-param.d.ts +7 -0
  207. package/lib/types/gir-callable-param.js +2 -0
  208. package/lib/types/gir-callable-param.js.map +1 -0
  209. package/lib/types/gir-callable-return.d.ts +22 -0
  210. package/lib/types/gir-callable-return.js +2 -0
  211. package/lib/types/gir-callable-return.js.map +1 -0
  212. package/lib/types/gir-callback-element.d.ts +15 -0
  213. package/lib/types/gir-callback-element.js +2 -0
  214. package/lib/types/gir-callback-element.js.map +1 -0
  215. package/lib/types/gir-class-element.d.ts +48 -0
  216. package/lib/types/gir-class-element.js +2 -0
  217. package/lib/types/gir-class-element.js.map +1 -0
  218. package/lib/types/gir-constant-element.d.ts +15 -0
  219. package/lib/types/gir-constant-element.js +2 -0
  220. package/lib/types/gir-constant-element.js.map +1 -0
  221. package/lib/types/gir-constructor-element.d.ts +8 -0
  222. package/lib/types/gir-constructor-element.js +2 -0
  223. package/lib/types/gir-constructor-element.js.map +1 -0
  224. package/lib/types/gir-direction.d.ts +5 -0
  225. package/lib/types/gir-direction.js +7 -0
  226. package/lib/types/gir-direction.js.map +1 -0
  227. package/lib/types/gir-doc-element.d.ts +68 -0
  228. package/lib/types/gir-doc-element.js +2 -0
  229. package/lib/types/gir-doc-element.js.map +1 -0
  230. package/lib/types/gir-enum-element.d.ts +19 -0
  231. package/lib/types/gir-enum-element.js +2 -0
  232. package/lib/types/gir-enum-element.js.map +1 -0
  233. package/lib/types/gir-field-element.d.ts +18 -0
  234. package/lib/types/gir-field-element.js +2 -0
  235. package/lib/types/gir-field-element.js.map +1 -0
  236. package/lib/types/gir-function-element.d.ts +8 -0
  237. package/lib/types/gir-function-element.js +2 -0
  238. package/lib/types/gir-function-element.js.map +1 -0
  239. package/lib/types/gir-implements.d.ts +8 -0
  240. package/lib/types/gir-implements.js +2 -0
  241. package/lib/types/gir-implements.js.map +1 -0
  242. package/lib/types/gir-include.d.ts +9 -0
  243. package/lib/types/gir-include.js +2 -0
  244. package/lib/types/gir-include.js.map +1 -0
  245. package/lib/types/gir-info-attrs.d.ts +13 -0
  246. package/lib/types/gir-info-attrs.js +2 -0
  247. package/lib/types/gir-info-attrs.js.map +1 -0
  248. package/lib/types/gir-info-elements.d.ts +5 -0
  249. package/lib/types/gir-info-elements.js +2 -0
  250. package/lib/types/gir-info-elements.js.map +1 -0
  251. package/lib/types/gir-instance-parameter.d.ts +21 -0
  252. package/lib/types/gir-instance-parameter.js +2 -0
  253. package/lib/types/gir-instance-parameter.js.map +1 -0
  254. package/lib/types/gir-interface-element.d.ts +31 -0
  255. package/lib/types/gir-interface-element.js +2 -0
  256. package/lib/types/gir-interface-element.js.map +1 -0
  257. package/lib/types/gir-member-element.d.ts +17 -0
  258. package/lib/types/gir-member-element.js +2 -0
  259. package/lib/types/gir-member-element.js.map +1 -0
  260. package/lib/types/gir-method-element.d.ts +13 -0
  261. package/lib/types/gir-method-element.js +2 -0
  262. package/lib/types/gir-method-element.js.map +1 -0
  263. package/lib/types/gir-module-resolved-by.d.ts +10 -0
  264. package/lib/types/gir-module-resolved-by.js +2 -0
  265. package/lib/types/gir-module-resolved-by.js.map +1 -0
  266. package/lib/types/gir-modules-grouped-map.d.ts +4 -0
  267. package/lib/types/gir-modules-grouped-map.js +2 -0
  268. package/lib/types/gir-modules-grouped-map.js.map +1 -0
  269. package/lib/types/gir-modules-grouped.d.ts +12 -0
  270. package/lib/types/gir-modules-grouped.js +2 -0
  271. package/lib/types/gir-modules-grouped.js.map +1 -0
  272. package/lib/types/gir-namespace.d.ts +30 -0
  273. package/lib/types/gir-namespace.js +2 -0
  274. package/lib/types/gir-namespace.js.map +1 -0
  275. package/lib/types/gir-package.d.ts +7 -0
  276. package/lib/types/gir-package.js +2 -0
  277. package/lib/types/gir-package.js.map +1 -0
  278. package/lib/types/gir-prerequisite.d.ts +5 -0
  279. package/lib/types/gir-prerequisite.js +2 -0
  280. package/lib/types/gir-prerequisite.js.map +1 -0
  281. package/lib/types/gir-property-element.d.ts +21 -0
  282. package/lib/types/gir-property-element.js +2 -0
  283. package/lib/types/gir-property-element.js.map +1 -0
  284. package/lib/types/gir-record-element.d.ts +30 -0
  285. package/lib/types/gir-record-element.js +2 -0
  286. package/lib/types/gir-record-element.js.map +1 -0
  287. package/lib/types/gir-repository.d.ts +16 -0
  288. package/lib/types/gir-repository.js +2 -0
  289. package/lib/types/gir-repository.js.map +1 -0
  290. package/lib/types/gir-signal.d.ts +25 -0
  291. package/lib/types/gir-signal.js +2 -0
  292. package/lib/types/gir-signal.js.map +1 -0
  293. package/lib/types/gir-transfer-ownership-type.d.ts +5 -0
  294. package/lib/types/gir-transfer-ownership-type.js +7 -0
  295. package/lib/types/gir-transfer-ownership-type.js.map +1 -0
  296. package/lib/types/gir-transfer-ownership.d.ts +5 -0
  297. package/lib/types/gir-transfer-ownership.js +2 -0
  298. package/lib/types/gir-transfer-ownership.js.map +1 -0
  299. package/lib/types/gir-type.d.ts +14 -0
  300. package/lib/types/gir-type.js +2 -0
  301. package/lib/types/gir-type.js.map +1 -0
  302. package/lib/types/gir-union-element.d.ts +22 -0
  303. package/lib/types/gir-union-element.js +2 -0
  304. package/lib/types/gir-union-element.js.map +1 -0
  305. package/lib/types/gir-unparsed-number.d.ts +2 -0
  306. package/lib/types/gir-unparsed-number.js +2 -0
  307. package/lib/types/gir-unparsed-number.js.map +1 -0
  308. package/lib/types/gir-var-args.d.ts +5 -0
  309. package/lib/types/gir-var-args.js +2 -0
  310. package/lib/types/gir-var-args.js.map +1 -0
  311. package/lib/types/gir-virtual-method.d.ts +10 -0
  312. package/lib/types/gir-virtual-method.js +2 -0
  313. package/lib/types/gir-virtual-method.js.map +1 -0
  314. package/lib/types/index.d.ts +120 -0
  315. package/lib/types/index.js +121 -0
  316. package/lib/types/index.js.map +1 -0
  317. package/lib/types/inheritance-table.d.ts +3 -0
  318. package/lib/types/inheritance-table.js +2 -0
  319. package/lib/types/inheritance-table.js.map +1 -0
  320. package/lib/types/injection-callback.d.ts +16 -0
  321. package/lib/types/injection-callback.js +2 -0
  322. package/lib/types/injection-callback.js.map +1 -0
  323. package/lib/types/injection-class.d.ts +25 -0
  324. package/lib/types/injection-class.js +2 -0
  325. package/lib/types/injection-class.js.map +1 -0
  326. package/lib/types/injection-function.d.ts +7 -0
  327. package/lib/types/injection-function.js +2 -0
  328. package/lib/types/injection-function.js.map +1 -0
  329. package/lib/types/injection-generic-parameter.d.ts +2 -0
  330. package/lib/types/injection-generic-parameter.js +2 -0
  331. package/lib/types/injection-generic-parameter.js.map +1 -0
  332. package/lib/types/injection-instance-parameter.d.ts +2 -0
  333. package/lib/types/injection-instance-parameter.js +2 -0
  334. package/lib/types/injection-instance-parameter.js.map +1 -0
  335. package/lib/types/injection-parameter.d.ts +8 -0
  336. package/lib/types/injection-parameter.js +2 -0
  337. package/lib/types/injection-parameter.js.map +1 -0
  338. package/lib/types/injection-property.d.ts +4 -0
  339. package/lib/types/injection-property.js +2 -0
  340. package/lib/types/injection-property.js.map +1 -0
  341. package/lib/types/injection-type.d.ts +2 -0
  342. package/lib/types/injection-type.js +2 -0
  343. package/lib/types/injection-type.js.map +1 -0
  344. package/lib/types/injection.d.ts +5 -0
  345. package/lib/types/injection.js +2 -0
  346. package/lib/types/injection.js.map +1 -0
  347. package/lib/types/local-name-check.d.ts +4 -0
  348. package/lib/types/local-name-check.js +2 -0
  349. package/lib/types/local-name-check.js.map +1 -0
  350. package/lib/types/local-name-type.d.ts +1 -0
  351. package/lib/types/local-name-type.js +2 -0
  352. package/lib/types/local-name-type.js.map +1 -0
  353. package/lib/types/local-name.d.ts +7 -0
  354. package/lib/types/local-name.js +2 -0
  355. package/lib/types/local-name.js.map +1 -0
  356. package/lib/types/local-names.d.ts +4 -0
  357. package/lib/types/local-names.js +2 -0
  358. package/lib/types/local-names.js.map +1 -0
  359. package/lib/types/module-type.d.ts +1 -0
  360. package/lib/types/module-type.js +2 -0
  361. package/lib/types/module-type.js.map +1 -0
  362. package/lib/types/parsed-gir.d.ts +4 -0
  363. package/lib/types/parsed-gir.js +2 -0
  364. package/lib/types/parsed-gir.js.map +1 -0
  365. package/lib/types/part-of-class.d.ts +7 -0
  366. package/lib/types/part-of-class.js +2 -0
  367. package/lib/types/part-of-class.js.map +1 -0
  368. package/lib/types/part-of-module.d.ts +6 -0
  369. package/lib/types/part-of-module.js +2 -0
  370. package/lib/types/part-of-module.js.map +1 -0
  371. package/lib/types/promisify-func.d.ts +7 -0
  372. package/lib/types/promisify-func.js +2 -0
  373. package/lib/types/promisify-func.js.map +1 -0
  374. package/lib/types/resolve-type.d.ts +4 -0
  375. package/lib/types/resolve-type.js +6 -0
  376. package/lib/types/resolve-type.js.map +1 -0
  377. package/lib/types/sym-table-items.d.ts +4 -0
  378. package/lib/types/sym-table-items.js +2 -0
  379. package/lib/types/sym-table-items.js.map +1 -0
  380. package/lib/types/transformation-case.d.ts +1 -0
  381. package/lib/types/transformation-case.js +2 -0
  382. package/lib/types/transformation-case.js.map +1 -0
  383. package/lib/types/transformations.d.ts +11 -0
  384. package/lib/types/transformations.js +2 -0
  385. package/lib/types/transformations.js.map +1 -0
  386. package/lib/types/ts-alias.d.ts +10 -0
  387. package/lib/types/ts-alias.js +2 -0
  388. package/lib/types/ts-alias.js.map +1 -0
  389. package/lib/types/ts-callback-interface.d.ts +10 -0
  390. package/lib/types/ts-callback-interface.js +2 -0
  391. package/lib/types/ts-callback-interface.js.map +1 -0
  392. package/lib/types/ts-callback.d.ts +17 -0
  393. package/lib/types/ts-callback.js +2 -0
  394. package/lib/types/ts-callback.js.map +1 -0
  395. package/lib/types/ts-class.d.ts +85 -0
  396. package/lib/types/ts-class.js +2 -0
  397. package/lib/types/ts-class.js.map +1 -0
  398. package/lib/types/ts-doc-tag.d.ts +21 -0
  399. package/lib/types/ts-doc-tag.js +2 -0
  400. package/lib/types/ts-doc-tag.js.map +1 -0
  401. package/lib/types/ts-doc.d.ts +16 -0
  402. package/lib/types/ts-doc.js +2 -0
  403. package/lib/types/ts-doc.js.map +1 -0
  404. package/lib/types/ts-enum.d.ts +12 -0
  405. package/lib/types/ts-enum.js +2 -0
  406. package/lib/types/ts-enum.js.map +1 -0
  407. package/lib/types/ts-function.d.ts +55 -0
  408. package/lib/types/ts-function.js +2 -0
  409. package/lib/types/ts-function.js.map +1 -0
  410. package/lib/types/ts-generic-parameter.d.ts +8 -0
  411. package/lib/types/ts-generic-parameter.js +2 -0
  412. package/lib/types/ts-generic-parameter.js.map +1 -0
  413. package/lib/types/ts-instance-parameter.d.ts +4 -0
  414. package/lib/types/ts-instance-parameter.js +2 -0
  415. package/lib/types/ts-instance-parameter.js.map +1 -0
  416. package/lib/types/ts-member.d.ts +10 -0
  417. package/lib/types/ts-member.js +2 -0
  418. package/lib/types/ts-member.js.map +1 -0
  419. package/lib/types/ts-method.d.ts +5 -0
  420. package/lib/types/ts-method.js +2 -0
  421. package/lib/types/ts-method.js.map +1 -0
  422. package/lib/types/ts-parameter.d.ts +15 -0
  423. package/lib/types/ts-parameter.js +2 -0
  424. package/lib/types/ts-parameter.js.map +1 -0
  425. package/lib/types/ts-property.d.ts +17 -0
  426. package/lib/types/ts-property.js +2 -0
  427. package/lib/types/ts-property.js.map +1 -0
  428. package/lib/types/ts-signal.d.ts +17 -0
  429. package/lib/types/ts-signal.js +2 -0
  430. package/lib/types/ts-signal.js.map +1 -0
  431. package/lib/types/ts-type-name.d.ts +1 -0
  432. package/lib/types/ts-type-name.js +2 -0
  433. package/lib/types/ts-type-name.js.map +1 -0
  434. package/lib/types/ts-type-separator.d.ts +1 -0
  435. package/lib/types/ts-type-separator.js +2 -0
  436. package/lib/types/ts-type-separator.js.map +1 -0
  437. package/lib/types/ts-type.d.ts +26 -0
  438. package/lib/types/ts-type.js +2 -0
  439. package/lib/types/ts-type.js.map +1 -0
  440. package/lib/types/ts-var.d.ts +17 -0
  441. package/lib/types/ts-var.js +2 -0
  442. package/lib/types/ts-var.js.map +1 -0
  443. package/lib/types/type-gir-alias.d.ts +2 -0
  444. package/lib/types/type-gir-alias.js +2 -0
  445. package/lib/types/type-gir-alias.js.map +1 -0
  446. package/lib/types/type-gir-class.d.ts +2 -0
  447. package/lib/types/type-gir-class.js +2 -0
  448. package/lib/types/type-gir-class.js.map +1 -0
  449. package/lib/types/type-gir-element.d.ts +3 -0
  450. package/lib/types/type-gir-element.js +2 -0
  451. package/lib/types/type-gir-element.js.map +1 -0
  452. package/lib/types/type-gir-enumeration-member.d.ts +2 -0
  453. package/lib/types/type-gir-enumeration-member.js +2 -0
  454. package/lib/types/type-gir-enumeration-member.js.map +1 -0
  455. package/lib/types/type-gir-enumeration.d.ts +2 -0
  456. package/lib/types/type-gir-enumeration.js +2 -0
  457. package/lib/types/type-gir-enumeration.js.map +1 -0
  458. package/lib/types/type-gir-function.d.ts +1 -0
  459. package/lib/types/type-gir-function.js +2 -0
  460. package/lib/types/type-gir-function.js.map +1 -0
  461. package/lib/types/type-gir-interface.d.ts +2 -0
  462. package/lib/types/type-gir-interface.js +2 -0
  463. package/lib/types/type-gir-interface.js.map +1 -0
  464. package/lib/types/type-gir-method.d.ts +2 -0
  465. package/lib/types/type-gir-method.js +2 -0
  466. package/lib/types/type-gir-method.js.map +1 -0
  467. package/lib/types/type-gir-parameter.d.ts +1 -0
  468. package/lib/types/type-gir-parameter.js +2 -0
  469. package/lib/types/type-gir-parameter.js.map +1 -0
  470. package/lib/types/type-gir-property.d.ts +2 -0
  471. package/lib/types/type-gir-property.js +2 -0
  472. package/lib/types/type-gir-property.js.map +1 -0
  473. package/lib/types/type-gir-variable.d.ts +1 -0
  474. package/lib/types/type-gir-variable.js +2 -0
  475. package/lib/types/type-gir-variable.js.map +1 -0
  476. package/lib/types/type-ts-element.d.ts +3 -0
  477. package/lib/types/type-ts-element.js +2 -0
  478. package/lib/types/type-ts-element.js.map +1 -0
  479. package/lib/types/type-ts-enumeration-member.d.ts +2 -0
  480. package/lib/types/type-ts-enumeration-member.js +2 -0
  481. package/lib/types/type-ts-enumeration-member.js.map +1 -0
  482. package/lib/types/type-ts-function.d.ts +1 -0
  483. package/lib/types/type-ts-function.js +2 -0
  484. package/lib/types/type-ts-function.js.map +1 -0
  485. package/lib/types/type-ts-property.d.ts +1 -0
  486. package/lib/types/type-ts-property.js +2 -0
  487. package/lib/types/type-ts-property.js.map +1 -0
  488. package/lib/types/user-config-load-result.d.ts +6 -0
  489. package/lib/types/user-config-load-result.js +2 -0
  490. package/lib/types/user-config-load-result.js.map +1 -0
  491. package/lib/types/user-config.d.ts +42 -0
  492. package/lib/types/user-config.js +2 -0
  493. package/lib/types/user-config.js.map +1 -0
  494. package/lib/utils.d.ts +292 -0
  495. package/lib/utils.js +403 -0
  496. package/lib/utils.js.map +1 -0
  497. package/package.json +89 -0
  498. package/src/commands/doc.ts +65 -0
  499. package/src/commands/generate.ts +88 -0
  500. package/src/commands/index.ts +3 -0
  501. package/src/commands/list.ts +96 -0
  502. package/src/config.ts +528 -0
  503. package/src/conflict-resolver.ts +1358 -0
  504. package/src/constants.ts +29 -0
  505. package/src/dependency-manager.ts +91 -0
  506. package/src/generation-handler.ts +79 -0
  507. package/src/generator.ts +10 -0
  508. package/src/gir-factory.ts +526 -0
  509. package/src/gir-module.ts +2953 -0
  510. package/src/html-doc-generator.ts +23 -0
  511. package/src/index.ts +17 -0
  512. package/src/injection/callbacks/gjs/Gio-2.0.ts +37 -0
  513. package/src/injection/callbacks/gjs/index.ts +5 -0
  514. package/src/injection/callbacks/index.ts +6 -0
  515. package/src/injection/callbacks/node-gtk/index.ts +3 -0
  516. package/src/injection/classes/GLib-2-0.ts +36 -0
  517. package/src/injection/classes/gjs/GLib-2.0.ts +206 -0
  518. package/src/injection/classes/gjs/GObject-2.0.ts +635 -0
  519. package/src/injection/classes/gjs/Gio-2.0.ts +219 -0
  520. package/src/injection/classes/gjs/index.ts +7 -0
  521. package/src/injection/classes/index.ts +7 -0
  522. package/src/injection/classes/node-gtk/GLib-2.0.ts +20 -0
  523. package/src/injection/classes/node-gtk/GObject-2.0.ts +67 -0
  524. package/src/injection/classes/node-gtk/Gdk-4.0.ts +33 -0
  525. package/src/injection/classes/node-gtk/Gio-2.0.ts +15 -0
  526. package/src/injection/classes/node-gtk/Graphene-1.0.ts +134 -0
  527. package/src/injection/classes/node-gtk/Gtk-3.0.ts +32 -0
  528. package/src/injection/classes/node-gtk/Gtk-4.0.ts +53 -0
  529. package/src/injection/classes/node-gtk/Pango-1.0.ts +32 -0
  530. package/src/injection/classes/node-gtk/index.ts +21 -0
  531. package/src/injection/index.ts +3 -0
  532. package/src/injection/injector.ts +184 -0
  533. package/src/logger.ts +134 -0
  534. package/src/messages.ts +69 -0
  535. package/src/module-loader.ts +576 -0
  536. package/src/start.ts +16 -0
  537. package/src/symtable.ts +72 -0
  538. package/src/template-processor.ts +199 -0
  539. package/src/transformation.ts +584 -0
  540. package/src/type-definition-generator.ts +1467 -0
  541. package/src/types/answer-version.ts +4 -0
  542. package/src/types/build-type.ts +1 -0
  543. package/src/types/class-parent.ts +14 -0
  544. package/src/types/config-flags.ts +5 -0
  545. package/src/types/conflict-child-element.ts +11 -0
  546. package/src/types/conflict-grouped-element.ts +7 -0
  547. package/src/types/conflict-grouped-elements.ts +5 -0
  548. package/src/types/construct-name.ts +11 -0
  549. package/src/types/dependency-map.ts +4 -0
  550. package/src/types/dependency.ts +16 -0
  551. package/src/types/environment.ts +1 -0
  552. package/src/types/file-info.ts +14 -0
  553. package/src/types/generate-config.ts +35 -0
  554. package/src/types/generator-type.ts +4 -0
  555. package/src/types/gir-alias-element.ts +15 -0
  556. package/src/types/gir-annotation.ts +10 -0
  557. package/src/types/gir-any-element.ts +35 -0
  558. package/src/types/gir-any-type.ts +7 -0
  559. package/src/types/gir-array-type.ts +23 -0
  560. package/src/types/gir-bitfield-element.ts +20 -0
  561. package/src/types/gir-boolean.ts +1 -0
  562. package/src/types/gir-boxed-element.ts +19 -0
  563. package/src/types/gir-c-include.ts +7 -0
  564. package/src/types/gir-callable-attrs.ts +19 -0
  565. package/src/types/gir-callable-param-element.ts +45 -0
  566. package/src/types/gir-callable-param.ts +9 -0
  567. package/src/types/gir-callable-return.ts +25 -0
  568. package/src/types/gir-callback-element.ts +28 -0
  569. package/src/types/gir-class-element.ts +71 -0
  570. package/src/types/gir-constant-element.ts +17 -0
  571. package/src/types/gir-constructor-element.ts +18 -0
  572. package/src/types/gir-direction.ts +5 -0
  573. package/src/types/gir-doc-element.ts +73 -0
  574. package/src/types/gir-enum-element.ts +28 -0
  575. package/src/types/gir-field-element.ts +31 -0
  576. package/src/types/gir-function-element.ts +19 -0
  577. package/src/types/gir-implements.ts +9 -0
  578. package/src/types/gir-include.ts +9 -0
  579. package/src/types/gir-info-attrs.ts +16 -0
  580. package/src/types/gir-info-elements.ts +8 -0
  581. package/src/types/gir-instance-parameter.ts +25 -0
  582. package/src/types/gir-interface-element.ts +53 -0
  583. package/src/types/gir-member-element.ts +19 -0
  584. package/src/types/gir-method-element.ts +25 -0
  585. package/src/types/gir-module-resolved-by.ts +11 -0
  586. package/src/types/gir-modules-grouped-map.ts +5 -0
  587. package/src/types/gir-modules-grouped.ts +13 -0
  588. package/src/types/gir-namespace.ts +47 -0
  589. package/src/types/gir-package.ts +7 -0
  590. package/src/types/gir-prerequisite.ts +5 -0
  591. package/src/types/gir-property-element.ts +31 -0
  592. package/src/types/gir-record-element.ts +47 -0
  593. package/src/types/gir-repository.ts +20 -0
  594. package/src/types/gir-signal.ts +43 -0
  595. package/src/types/gir-transfer-ownership-type.ts +5 -0
  596. package/src/types/gir-transfer-ownership.ts +6 -0
  597. package/src/types/gir-type.ts +16 -0
  598. package/src/types/gir-union-element.ts +35 -0
  599. package/src/types/gir-unparsed-number.ts +2 -0
  600. package/src/types/gir-var-args.ts +6 -0
  601. package/src/types/gir-virtual-method.ts +22 -0
  602. package/src/types/index.ts +120 -0
  603. package/src/types/inheritance-table.ts +3 -0
  604. package/src/types/injection-callback.ts +20 -0
  605. package/src/types/injection-class.ts +30 -0
  606. package/src/types/injection-function.ts +31 -0
  607. package/src/types/injection-generic-parameter.ts +3 -0
  608. package/src/types/injection-instance-parameter.ts +3 -0
  609. package/src/types/injection-parameter.ts +9 -0
  610. package/src/types/injection-property.ts +7 -0
  611. package/src/types/injection-type.ts +3 -0
  612. package/src/types/injection.ts +6 -0
  613. package/src/types/local-name-check.ts +5 -0
  614. package/src/types/local-name-type.ts +1 -0
  615. package/src/types/local-name.ts +8 -0
  616. package/src/types/local-names.ts +5 -0
  617. package/src/types/module-type.ts +1 -0
  618. package/src/types/parsed-gir.ts +5 -0
  619. package/src/types/part-of-class.ts +9 -0
  620. package/src/types/part-of-module.ts +8 -0
  621. package/src/types/promisify-func.ts +9 -0
  622. package/src/types/resolve-type.ts +4 -0
  623. package/src/types/sym-table-items.ts +5 -0
  624. package/src/types/transformation-case.ts +7 -0
  625. package/src/types/transformations.ts +12 -0
  626. package/src/types/ts-alias.ts +11 -0
  627. package/src/types/ts-callback-interface.ts +11 -0
  628. package/src/types/ts-callback.ts +21 -0
  629. package/src/types/ts-class.ts +109 -0
  630. package/src/types/ts-doc-tag.ts +23 -0
  631. package/src/types/ts-doc.ts +18 -0
  632. package/src/types/ts-enum.ts +15 -0
  633. package/src/types/ts-function.ts +70 -0
  634. package/src/types/ts-generic-parameter.ts +8 -0
  635. package/src/types/ts-instance-parameter.ts +4 -0
  636. package/src/types/ts-member.ts +11 -0
  637. package/src/types/ts-method.ts +6 -0
  638. package/src/types/ts-parameter.ts +20 -0
  639. package/src/types/ts-property.ts +22 -0
  640. package/src/types/ts-signal.ts +21 -0
  641. package/src/types/ts-type-name.ts +1 -0
  642. package/src/types/ts-type-separator.ts +1 -0
  643. package/src/types/ts-type.ts +28 -0
  644. package/src/types/ts-var.ts +21 -0
  645. package/src/types/type-gir-alias.ts +2 -0
  646. package/src/types/type-gir-class.ts +2 -0
  647. package/src/types/type-gir-element.ts +25 -0
  648. package/src/types/type-gir-enumeration-member.ts +2 -0
  649. package/src/types/type-gir-enumeration.ts +2 -0
  650. package/src/types/type-gir-function.ts +8 -0
  651. package/src/types/type-gir-interface.ts +2 -0
  652. package/src/types/type-gir-method.ts +2 -0
  653. package/src/types/type-gir-parameter.ts +1 -0
  654. package/src/types/type-gir-property.ts +2 -0
  655. package/src/types/type-gir-variable.ts +1 -0
  656. package/src/types/type-ts-element.ts +13 -0
  657. package/src/types/type-ts-enumeration-member.ts +2 -0
  658. package/src/types/type-ts-function.ts +1 -0
  659. package/src/types/type-ts-property.ts +1 -0
  660. package/src/types/user-config-load-result.ts +6 -0
  661. package/src/types/user-config.ts +43 -0
  662. package/src/utils.ts +433 -0
  663. package/templates/Cogl-2.0.d.ts +0 -0
  664. package/templates/Gjs/GObject-2.0.d.ts +238 -0
  665. package/templates/Gjs/Gio-2.0.d.ts +101 -0
  666. package/templates/Gjs/Gjs.d.ts +204 -0
  667. package/templates/Gjs/Gjs.js +21 -0
  668. package/templates/Gjs/GnomeShell.d.ts +154 -0
  669. package/templates/Gjs/GnomeShell.js +10 -0
  670. package/templates/Gjs/index.d.ts +594 -0
  671. package/templates/Gjs/index.js +4 -0
  672. package/templates/Gjs/misc/dbusUtils.d.ts +15 -0
  673. package/templates/Gjs/misc/dbusUtils.js +6 -0
  674. package/templates/Gjs/misc/extensionUtils.d.ts +99 -0
  675. package/templates/Gjs/misc/extensionUtils.js +6 -0
  676. package/templates/Gjs/misc/fileUtils.d.ts +51 -0
  677. package/templates/Gjs/misc/fileUtils.js +6 -0
  678. package/templates/Gjs/misc/gnomeSession.d.ts +74 -0
  679. package/templates/Gjs/misc/gnomeSession.js +6 -0
  680. package/templates/Gjs/misc/parentalControlsManager.d.ts +42 -0
  681. package/templates/Gjs/misc/parentalControlsManager.js +6 -0
  682. package/templates/Gjs/misc/signals.d.ts +15 -0
  683. package/templates/Gjs/misc/signals.js +6 -0
  684. package/templates/Gjs/module.d.ts +6 -0
  685. package/templates/Gjs/module.js +16 -0
  686. package/templates/Gjs/tsconfig.alias.json +10 -0
  687. package/templates/Gjs/ui/accessDialog.d.ts +19 -0
  688. package/templates/Gjs/ui/accessDialog.js +6 -0
  689. package/templates/Gjs/ui/altTab.d.ts +124 -0
  690. package/templates/Gjs/ui/altTab.js +6 -0
  691. package/templates/Gjs/ui/animation.d.ts +58 -0
  692. package/templates/Gjs/ui/animation.js +6 -0
  693. package/templates/Gjs/ui/appDisplay.d.ts +204 -0
  694. package/templates/Gjs/ui/appDisplay.js +6 -0
  695. package/templates/Gjs/ui/appFavorites.d.ts +34 -0
  696. package/templates/Gjs/ui/appFavorites.js +6 -0
  697. package/templates/Gjs/ui/appMenu.d.ts +74 -0
  698. package/templates/Gjs/ui/appMenu.js +6 -0
  699. package/templates/Gjs/ui/audioDeviceSelection.d.ts +51 -0
  700. package/templates/Gjs/ui/audioDeviceSelection.js +6 -0
  701. package/templates/Gjs/ui/background.d.ts +255 -0
  702. package/templates/Gjs/ui/background.js +5 -0
  703. package/templates/Gjs/ui/backgroundMenu.d.ts +19 -0
  704. package/templates/Gjs/ui/backgroundMenu.js +5 -0
  705. package/templates/Gjs/ui/barLevel.d.ts +42 -0
  706. package/templates/Gjs/ui/barLevel.js +5 -0
  707. package/templates/Gjs/ui/boxpointer.d.ts +103 -0
  708. package/templates/Gjs/ui/boxpointer.js +5 -0
  709. package/templates/Gjs/ui/calendar.d.ts +261 -0
  710. package/templates/Gjs/ui/calendar.js +5 -0
  711. package/templates/Gjs/ui/checkBox.d.ts +22 -0
  712. package/templates/Gjs/ui/checkBox.js +5 -0
  713. package/templates/Gjs/ui/closeDialog.d.ts +40 -0
  714. package/templates/Gjs/ui/closeDialog.js +5 -0
  715. package/templates/Gjs/ui/components/__init__.d.ts +9 -0
  716. package/templates/Gjs/ui/components/__init__.js +6 -0
  717. package/templates/Gjs/ui/components/automountManager.d.ts +8 -0
  718. package/templates/Gjs/ui/components/automountManager.js +6 -0
  719. package/templates/Gjs/ui/components/autorunManager.d.ts +8 -0
  720. package/templates/Gjs/ui/components/autorunManager.js +6 -0
  721. package/templates/Gjs/ui/components/index.d.ts +6 -0
  722. package/templates/Gjs/ui/components/index.js +6 -0
  723. package/templates/Gjs/ui/components/keyring.d.ts +19 -0
  724. package/templates/Gjs/ui/components/keyring.js +6 -0
  725. package/templates/Gjs/ui/components/networkAgent.d.ts +10 -0
  726. package/templates/Gjs/ui/components/networkAgent.js +6 -0
  727. package/templates/Gjs/ui/components/polkitAgent.d.ts +19 -0
  728. package/templates/Gjs/ui/components/polkitAgent.js +6 -0
  729. package/templates/Gjs/ui/components/telepathyClient.d.ts +10 -0
  730. package/templates/Gjs/ui/components/telepathyClient.js +6 -0
  731. package/templates/Gjs/ui/dialog.d.ts +78 -0
  732. package/templates/Gjs/ui/dialog.js +6 -0
  733. package/templates/Gjs/ui/dnd.d.ts +127 -0
  734. package/templates/Gjs/ui/dnd.js +6 -0
  735. package/templates/Gjs/ui/iconGrid.d.ts +172 -0
  736. package/templates/Gjs/ui/iconGrid.js +6 -0
  737. package/templates/Gjs/ui/layout.d.ts +311 -0
  738. package/templates/Gjs/ui/layout.js +6 -0
  739. package/templates/Gjs/ui/main.d.ts +215 -0
  740. package/templates/Gjs/ui/main.js +6 -0
  741. package/templates/Gjs/ui/messageList.d.ts +113 -0
  742. package/templates/Gjs/ui/messageList.js +6 -0
  743. package/templates/Gjs/ui/messageTray.d.ts +423 -0
  744. package/templates/Gjs/ui/messageTray.js +6 -0
  745. package/templates/Gjs/ui/modalDialog.d.ts +96 -0
  746. package/templates/Gjs/ui/modalDialog.js +6 -0
  747. package/templates/Gjs/ui/mpris.d.ts +78 -0
  748. package/templates/Gjs/ui/mpris.js +6 -0
  749. package/templates/Gjs/ui/notificationDaemon.d.ts +5 -0
  750. package/templates/Gjs/ui/notificationDaemon.js +6 -0
  751. package/templates/Gjs/ui/panel.d.ts +65 -0
  752. package/templates/Gjs/ui/panel.js +6 -0
  753. package/templates/Gjs/ui/panelMenu.d.ts +51 -0
  754. package/templates/Gjs/ui/panelMenu.js +6 -0
  755. package/templates/Gjs/ui/popupMenu.d.ts +228 -0
  756. package/templates/Gjs/ui/popupMenu.js +6 -0
  757. package/templates/Gjs/ui/ripples.d.ts +44 -0
  758. package/templates/Gjs/ui/ripples.js +6 -0
  759. package/templates/Gjs/ui/search.d.ts +158 -0
  760. package/templates/Gjs/ui/search.js +6 -0
  761. package/templates/Gjs/ui/switcherPopup.d.ts +107 -0
  762. package/templates/Gjs/ui/switcherPopup.js +6 -0
  763. package/templates/Gjs/ui/userWidget.d.ts +13 -0
  764. package/templates/Gjs/ui/userWidget.js +6 -0
  765. package/templates/Granite-1.0.d.ts +7 -0
  766. package/templates/Granite-7.0.d.ts +7 -0
  767. package/templates/GstBase-0.10.d.ts +5 -0
  768. package/templates/RygelServer-2.6.d.ts +3 -0
  769. package/templates/node-gtk/GObject-2.0.d.ts +57 -0
  770. package/templates/node-gtk/index.d.ts +40 -0
  771. package/templates/node-gtk/index.js +9 -0
  772. package/templates/node-gtk/module.d.ts +6 -0
  773. package/templates/node-gtk/module.js +17 -0
@@ -0,0 +1,1467 @@
1
+ import type {
2
+ GenerateConfig,
3
+ InheritanceTable,
4
+ GirClassElement,
5
+ GirCallableParamElement,
6
+ GirSignalElement,
7
+ GirEnumElement,
8
+ GirAliasElement,
9
+ GirInterfaceElement,
10
+ GirUnionElement,
11
+ GirModulesGrouped,
12
+ GirRecordElement,
13
+ GirBitfieldElement,
14
+ GirInstanceParameter,
15
+ TsGenericParameter,
16
+ TsType,
17
+ TsDoc,
18
+ TsFunction,
19
+ TsCallback,
20
+ TsSignal,
21
+ TsMember,
22
+ TsVar,
23
+ TsProperty,
24
+ TsParameter,
25
+ } from './types/index.js'
26
+ import { Generator } from './generator.js'
27
+ import type { GirModule } from './gir-module.js'
28
+ import TemplateProcessor from './template-processor.js'
29
+ import { Logger } from './logger.js'
30
+ import {
31
+ generateIndent,
32
+ removeNamespace,
33
+ removeClassModule,
34
+ girElementIsIntrospectable,
35
+ typeIsOptional,
36
+ } from './utils.js'
37
+ import {
38
+ NO_TSDATA,
39
+ WARN_NOT_FOUND_DEPENDENCY_GIR_FILE,
40
+ WARN_IGNORE_MULTIPLE_CALLBACKS,
41
+ WARN_IGNORE_MULTIPLE_FUNC_DESC,
42
+ } from './messages.js'
43
+
44
+ export default class TypeDefinitionGenerator implements Generator {
45
+ protected log: Logger
46
+ constructor(protected readonly config: GenerateConfig) {
47
+ this.log = new Logger(config.environment, config.verbose, TypeDefinitionGenerator.name)
48
+ }
49
+
50
+ /**
51
+ *
52
+ * @param namespace E.g. 'Gtk'
53
+ * @param packageName E.g. 'Gtk-3.0'
54
+ * @param asExternType Currently only used for node type imports
55
+ */
56
+ private generateModuleDependenciesImport(namespace: string, packageName: string, asExternType = false): string[] {
57
+ const def: string[] = []
58
+ const sas = !this.config.noNamespace && packageName !== 'Gjs' ? '' : '* as '
59
+ if (this.config.buildType === 'lib') {
60
+ def.push(`import type ${sas}${namespace} from './${packageName}.js';`)
61
+ } else if (this.config.buildType === 'types') {
62
+ if (asExternType) {
63
+ // def.push(`/// <reference types="${packageName}" />`)
64
+ def.push(`import ${namespace} from "${packageName}.js"`)
65
+ } else {
66
+ def.push(`/// <reference path="${packageName}.d.ts" />`)
67
+ def.push(`import type ${sas}${namespace} from './${packageName}.js';`)
68
+ }
69
+ }
70
+ return def
71
+ }
72
+
73
+ private generateExport(type: string, name: string, definition: string, indentCount = 0) {
74
+ const exp = !this.config.noNamespace || this.config.buildType === 'types' ? '' : 'export '
75
+ const indent = generateIndent(indentCount)
76
+ if (!definition.startsWith(':')) {
77
+ definition = ' ' + definition
78
+ }
79
+ return `${indent}${exp}${type} ${name}${definition}`
80
+ }
81
+
82
+ private generateProperty(tsProp: TsProperty, onlyStatic: boolean, namespace: string, indentCount = 0) {
83
+ if (!tsProp) {
84
+ throw new Error('[generateProperty] Not all required properties set!')
85
+ }
86
+
87
+ const desc: string[] = []
88
+ const isStatic = tsProp.isStatic
89
+
90
+ if ((isStatic && !onlyStatic) || (!isStatic && onlyStatic)) {
91
+ return desc
92
+ }
93
+
94
+ if (!tsProp.hasUnresolvedConflict) {
95
+ desc.push(...this.addGirDocComment(tsProp.doc, indentCount))
96
+ }
97
+
98
+ const indent = generateIndent(indentCount)
99
+ const varDesc = this.generateVariable(tsProp, namespace, 0, false)
100
+ const staticStr = isStatic ? 'static ' : ''
101
+ const readonly = tsProp.readonly ? 'readonly ' : ''
102
+
103
+ // temporary solution, will be solved differently later
104
+ const commentOut = tsProp.hasUnresolvedConflict ? '// Has conflict: ' : ''
105
+
106
+ desc.push(`${indent}${commentOut}${staticStr}${readonly}${varDesc}`)
107
+ return desc
108
+ }
109
+
110
+ private generateProperties(
111
+ tsProps: TsProperty[],
112
+ onlyStatic: boolean,
113
+ namespace: string,
114
+ comment: string,
115
+ indentCount = 0,
116
+ ) {
117
+ const def: string[] = []
118
+ for (const tsProp of tsProps) {
119
+ def.push(...this.generateProperty(tsProp, onlyStatic, namespace, indentCount))
120
+ }
121
+
122
+ if (def.length > 0) {
123
+ def.unshift(...this.addInfoComment(comment, indentCount))
124
+ }
125
+
126
+ return def
127
+ }
128
+
129
+ private generateVariableCallbackType(tsType: TsType, namespace: string) {
130
+ // The type of a callback is a functions definition
131
+
132
+ let typeStr = 'any'
133
+
134
+ const { callbacks } = tsType
135
+
136
+ if (!callbacks.length) return typeStr
137
+
138
+ if (callbacks.length > 1) {
139
+ this.log.warn(WARN_IGNORE_MULTIPLE_CALLBACKS)
140
+ }
141
+
142
+ const girCallback = callbacks[0]
143
+
144
+ if (!girCallback._tsData) {
145
+ throw new Error(NO_TSDATA('generateVariableCallbackType'))
146
+ }
147
+
148
+ const funcDesc = this.generateFunction(girCallback._tsData, false, namespace, 0)
149
+
150
+ if (girCallback._tsData && funcDesc?.length) {
151
+ if (funcDesc.length > 1) {
152
+ this.log.warn(WARN_IGNORE_MULTIPLE_FUNC_DESC)
153
+ }
154
+ typeStr = funcDesc[0]
155
+ }
156
+
157
+ return typeStr
158
+ }
159
+
160
+ private generateVariable(tsVar: TsProperty | TsVar, namespace: string, indentCount = 0, allowCommentOut = true) {
161
+ const indent = generateIndent(indentCount)
162
+ const name = tsVar.name
163
+ const optional = typeIsOptional(tsVar.type)
164
+
165
+ if (!name) {
166
+ throw new Error('[generateVariable] "name" not set!')
167
+ }
168
+
169
+ const affix = optional ? '?' : ''
170
+ const typeStr = this.generateTypes(tsVar.type, namespace)
171
+
172
+ // temporary solution, will be solved differently later
173
+ const commentOut = allowCommentOut && tsVar.hasUnresolvedConflict ? '// Has conflict: ' : ''
174
+
175
+ return `${indent}${commentOut}${name}${affix}: ${typeStr}`
176
+ }
177
+
178
+ private generateTypes(tsTypes: TsType[], namespace: string) {
179
+ let def = ''
180
+ for (const tsType of tsTypes) {
181
+ const separator = tsType.leftSeparator || '|'
182
+ const typeStr = this.generateType(tsType, namespace)
183
+ if (!def) {
184
+ def = typeStr
185
+ } else {
186
+ def += ` ${separator} ${typeStr}`
187
+ }
188
+ }
189
+ return def
190
+ }
191
+
192
+ private generateGenericValues(tsType: TsType, namespace: string) {
193
+ // We just use the generic values here
194
+ const genericValues = tsType.generics.map((g) => removeNamespace(g.value || '', namespace)).filter((g) => !!g)
195
+ const genericStr = tsType.generics.length ? `<${genericValues.join(', ')}>` : ''
196
+ return genericStr
197
+ }
198
+
199
+ private generateType(tsType: TsType, namespace: string) {
200
+ let typeName = removeNamespace(tsType.type, namespace)
201
+
202
+ if (tsType.callbacks.length) {
203
+ typeName = this.generateVariableCallbackType(tsType, namespace)
204
+ }
205
+
206
+ if (!typeName) {
207
+ throw new Error('[generateVariable] "typeName" not set!')
208
+ }
209
+
210
+ let prefix = tsType.isArray ? '[]' : ''
211
+ prefix += tsType.nullable ? ' | null' : ''
212
+
213
+ // We just use the generic values here
214
+ const genericStr = this.generateGenericValues(tsType, namespace)
215
+
216
+ return `${typeName}${genericStr}${prefix}`
217
+ }
218
+
219
+ /**
220
+ * Generates signals from all properties of a base class
221
+ * TODO: Build new `GirSignalElement`s in `gir-module.ts` instead of generate the strings directly
222
+ * @param girClass
223
+ * @param namespace
224
+ * @param indentCount
225
+ * @returns
226
+ */
227
+ private generateClassPropertySignals(
228
+ girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
229
+ namespace: string,
230
+ indentCount = 1,
231
+ ) {
232
+ const def: string[] = []
233
+
234
+ if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
235
+ throw new Error(NO_TSDATA('generateClassPropertySignals'))
236
+ }
237
+
238
+ if (girClass._tsData?.isDerivedFromGObject) {
239
+ if (girClass._tsData.propertySignalMethods.length > 0) {
240
+ def.push(
241
+ ...this.addInfoComment(
242
+ `Class property signals of ${girClass._module?.packageName}.${girClass._fullSymName}`,
243
+ indentCount,
244
+ ),
245
+ )
246
+ for (const tsSignalMethod of girClass._tsData.propertySignalMethods) {
247
+ if (!tsSignalMethod) {
248
+ continue
249
+ }
250
+ def.push(...this.generateFunction(tsSignalMethod, false, namespace, indentCount))
251
+ }
252
+ }
253
+ }
254
+ return def
255
+ }
256
+
257
+ private generateInParameters(
258
+ inParams: GirCallableParamElement[],
259
+ instanceParameters: GirInstanceParameter[],
260
+ namespace: string,
261
+ ) {
262
+ const inParamsDef: string[] = []
263
+
264
+ // TODO: Should use of a constructor, and even of an instance, be discouraged?
265
+ for (const instanceParameter of instanceParameters) {
266
+ if (instanceParameter._tsData) {
267
+ let { structFor } = instanceParameter._tsData
268
+ const { name } = instanceParameter._tsData
269
+ const gobject = namespace === 'GObject' || namespace === 'GLib' ? '' : 'GObject.'
270
+
271
+ structFor = removeNamespace(structFor, namespace)
272
+
273
+ const returnTypes = [structFor, 'Function', `${gobject}GType`]
274
+ inParamsDef.push(`${name}: ${returnTypes.join(' | ')}`)
275
+ }
276
+ }
277
+
278
+ for (const inParam of inParams) {
279
+ if (inParam._tsData) inParamsDef.push(...this.generateParameter(inParam._tsData, namespace))
280
+ }
281
+
282
+ return inParamsDef
283
+ }
284
+
285
+ private generateSignals(
286
+ girSignals: GirSignalElement[],
287
+ girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
288
+ namespace: string,
289
+ indentCount = 0,
290
+ ) {
291
+ const def: string[] = []
292
+
293
+ for (const girSignal of girSignals) {
294
+ if (girSignal._tsData?.tsMethods?.length) {
295
+ for (const tsSignalMethod of girSignal._tsData?.tsMethods) {
296
+ if (!tsSignalMethod) {
297
+ continue
298
+ }
299
+ def.push(...this.generateFunction(tsSignalMethod, false, namespace, indentCount))
300
+ }
301
+ }
302
+ }
303
+ return def
304
+ }
305
+
306
+ /**
307
+ * Adds documentation comments
308
+ * @see https://github.com/microsoft/tsdoc
309
+ * @param lines
310
+ * @param indentCount
311
+ */
312
+ private addTSDocCommentLines(lines: string[], indentCount = 0): string[] {
313
+ const def: string[] = []
314
+ const indent = generateIndent(indentCount)
315
+ def.push(`${indent}/**`)
316
+ for (const line of lines) {
317
+ def.push(`${indent} * ${line}`)
318
+ }
319
+ def.push(`${indent} */`)
320
+ return def
321
+ }
322
+
323
+ /**
324
+ * Adds the documentation as comments
325
+ * @see https://github.com/microsoft/tsdoc
326
+ * @param girDoc
327
+ * @param indentCount
328
+ * @param overwriteDoc
329
+ * @returns
330
+ */
331
+ private addGirDocComment(tsDoc: TsDoc | undefined, indentCount = 0, overwriteDoc?: Partial<TsDoc>) {
332
+ const desc: string[] = []
333
+ const indent = generateIndent(indentCount)
334
+ if (this.config.noComments) {
335
+ return desc
336
+ }
337
+
338
+ const text = overwriteDoc?.text || tsDoc?.text
339
+ const tags = overwriteDoc?.tags || tsDoc?.tags || []
340
+
341
+ if (text) {
342
+ desc.push(`${indent}/**`)
343
+
344
+ if (text) {
345
+ const lines = text.split('\n')
346
+ if (lines.length) {
347
+ for (const line of lines) {
348
+ desc.push(`${indent} * ${line}`)
349
+ }
350
+ }
351
+ }
352
+
353
+ for (const tag of tags) {
354
+ if (tag.paramName) {
355
+ desc.push(`${indent} * @${tag.tagName} ${tag.paramName} ${tag.text}`)
356
+ } else {
357
+ desc.push(`${indent} * @${tag.tagName} ${tag.text}`)
358
+ }
359
+ }
360
+ desc.push(`${indent} */`)
361
+ }
362
+ return desc
363
+ }
364
+
365
+ /**
366
+ * Adds an info comment, is used for debugging the generated types
367
+ * @param comment
368
+ * @param indentCount
369
+ * @returns
370
+ */
371
+ private addInfoComment(comment?: string, indentCount = 0) {
372
+ const def: string[] = []
373
+ if (this.config.noDebugComments) {
374
+ return def
375
+ }
376
+ const indent = generateIndent(indentCount)
377
+ if (comment) {
378
+ def.push('')
379
+ def.push(`${indent}// ${comment}`)
380
+ def.push('')
381
+ }
382
+ return def
383
+ }
384
+
385
+ /**
386
+ * Adds an inline info comment, is used for debugging the generated types
387
+ * @param comment
388
+ * @param indentCount
389
+ * @returns
390
+ */
391
+ private addInlineInfoComment(comment?: string, indentCount = 0) {
392
+ const def: string[] = []
393
+ if (this.config.noDebugComments) {
394
+ return def
395
+ }
396
+ const indent = generateIndent(indentCount)
397
+ if (comment) {
398
+ def.push(`${indent}/* ${comment} */`)
399
+ }
400
+ return def
401
+ }
402
+
403
+ private mergeDescs(descs: string[], comment?: string, indentCount = 1) {
404
+ const def: string[] = []
405
+ const indent = generateIndent(indentCount)
406
+
407
+ for (const desc of descs) {
408
+ def.push(`${indent}${desc}`)
409
+ }
410
+
411
+ if (def.length > 0) {
412
+ def.unshift(...this.addInfoComment(comment, indentCount))
413
+ }
414
+
415
+ return def
416
+ }
417
+
418
+ private generateParameter(tsParam: TsParameter, namespace: string) {
419
+ if (typeof tsParam?.name !== 'string') {
420
+ throw new Error(NO_TSDATA('generateParameter'))
421
+ }
422
+
423
+ const types = tsParam.type
424
+ const name = tsParam.name
425
+ const typeStr = this.generateTypes(types, namespace)
426
+ const optional = typeIsOptional(types) && !tsParam.isRest
427
+ const affix = optional ? '?' : ''
428
+ const prefix = tsParam.isRest ? '...' : ''
429
+
430
+ return [`${prefix}${name}${affix}: ${typeStr}`]
431
+ }
432
+
433
+ /**
434
+ *
435
+ * @param tsGenerics
436
+ * @param isOut If this generic parameters are out do only generate the type parameter names
437
+ * @returns
438
+ */
439
+ private generateGenericParameters(tsGenerics?: TsGenericParameter[], isOut = false) {
440
+ const desc: string[] = []
441
+ if (!tsGenerics?.length) {
442
+ return ''
443
+ }
444
+
445
+ for (const tsGeneric of tsGenerics) {
446
+ if (!tsGeneric.name) {
447
+ continue
448
+ }
449
+ let genericStr = `${tsGeneric.name}`
450
+ if (!isOut && tsGeneric.extends) {
451
+ genericStr += ` extends ${tsGeneric.extends}`
452
+ }
453
+ if (!isOut && tsGeneric.value) {
454
+ genericStr += ` = ${tsGeneric.value}`
455
+ }
456
+ desc.push(genericStr)
457
+ }
458
+
459
+ return `<${desc.join(', ')}>`
460
+ }
461
+
462
+ private generateOutParameterReturn(girParam: GirCallableParamElement, namespace: string) {
463
+ const desc: string[] = []
464
+
465
+ if (!girParam._tsData) {
466
+ this.log.warn(NO_TSDATA('generateOutParameterReturn'))
467
+ return desc
468
+ }
469
+
470
+ const { name } = girParam._tsData
471
+ const typeStr = this.generateTypes(girParam._tsData.type, namespace)
472
+
473
+ desc.push(`/* ${name} */ ${typeStr}`)
474
+ return desc
475
+ }
476
+
477
+ private generateFunctionReturn(tsFunction: TsFunction | TsCallback | TsSignal, namespace: string) {
478
+ if (tsFunction.name === 'constructor') {
479
+ return ''
480
+ }
481
+
482
+ const overrideReturnType = tsFunction.overrideReturnType
483
+ const outParams = tsFunction.outParams
484
+ const retTypeIsVoid = tsFunction.retTypeIsVoid
485
+ const isPromise = tsFunction.isPromise || false
486
+ const typeStr = this.generateTypes(tsFunction.returnTypes, namespace)
487
+
488
+ let desc = typeStr
489
+
490
+ if (overrideReturnType) {
491
+ desc = removeNamespace(overrideReturnType, namespace)
492
+ }
493
+ // TODO: Transform the outParams to `tsFunction.returnTypes` to move this logic to `gir-module.ts`
494
+ else if (outParams.length + (retTypeIsVoid ? 0 : 1) > 1) {
495
+ const outParamsDesc: string[] = []
496
+
497
+ if (!retTypeIsVoid) {
498
+ outParamsDesc.push(`/* returnType */ ${typeStr}`)
499
+ }
500
+
501
+ for (const outParam of outParams) {
502
+ outParamsDesc.push(...this.generateOutParameterReturn(outParam, namespace))
503
+ }
504
+
505
+ desc = outParamsDesc.join(', ')
506
+ desc = `[ ${desc} ]`
507
+ } else if (outParams.length === 1 && retTypeIsVoid) {
508
+ desc = this.generateOutParameterReturn(outParams[0], namespace).join(' ')
509
+ }
510
+
511
+ if (isPromise) {
512
+ desc = `globalThis.Promise<${desc}>`
513
+ }
514
+
515
+ return desc
516
+ }
517
+
518
+ private generateFunction(
519
+ tsFunction: TsFunction | TsCallback | TsSignal | undefined,
520
+ /** If true only generate static functions otherwise generate only non static functions */
521
+ onlyStatic: boolean,
522
+ namespace: string,
523
+ indentCount = 1,
524
+ overloads = true,
525
+ ) {
526
+ const def: string[] = []
527
+ const indent = generateIndent(indentCount)
528
+
529
+ if (!tsFunction) {
530
+ this.log.warn(NO_TSDATA('generateFunction'))
531
+ return def
532
+ }
533
+
534
+ let { name } = tsFunction
535
+ const { isStatic } = tsFunction
536
+
537
+ const { isArrowType, isGlobal, inParams, instanceParameters } = tsFunction
538
+
539
+ if ((isStatic && !onlyStatic) || (!isStatic && onlyStatic)) {
540
+ return def
541
+ }
542
+
543
+ if (tsFunction.doc && !tsFunction.hasUnresolvedConflict)
544
+ def.push(...this.addGirDocComment(tsFunction.doc, indentCount))
545
+
546
+ const staticStr = isStatic && tsFunction.name !== 'constructor' ? 'static ' : ''
547
+
548
+ const globalStr = isGlobal ? 'function ' : ''
549
+ const genericStr = this.generateGenericParameters(tsFunction.generics)
550
+
551
+ // temporary solution, will be solved differently later
552
+ const commentOut = tsFunction.hasUnresolvedConflict ? '// Has conflict: ' : ''
553
+
554
+ let exportStr = ''
555
+ // `tsType === 'function'` are a global methods which can be exported
556
+ if (isGlobal) {
557
+ exportStr = !this.config.noNamespace || this.config.buildType === 'types' ? '' : 'export '
558
+ }
559
+
560
+ const returnType = this.generateFunctionReturn(tsFunction, namespace)
561
+
562
+ let retSep = ''
563
+ if (returnType) {
564
+ if (isArrowType) {
565
+ name = ''
566
+ retSep = ' =>'
567
+ } else {
568
+ retSep = ':'
569
+ }
570
+ }
571
+
572
+ const inParamsDef: string[] = this.generateInParameters(inParams, instanceParameters, namespace)
573
+
574
+ def.push(
575
+ `${indent}${commentOut}${exportStr}${staticStr}${globalStr}${name}${genericStr}(${inParamsDef.join(
576
+ ', ',
577
+ )})${retSep} ${returnType}`,
578
+ )
579
+
580
+ // Add overloaded methods
581
+ if (overloads && tsFunction.overloads.length > 0) {
582
+ def.push(...this.addInfoComment(`Overloads of ${name}`, indentCount))
583
+ for (const func of tsFunction.overloads) {
584
+ def.push(...this.generateFunction(func, onlyStatic, namespace, indentCount, false))
585
+ }
586
+ }
587
+
588
+ return def
589
+ }
590
+
591
+ private generateFunctions(
592
+ tsFunctions: TsFunction[],
593
+ onlyStatic: boolean,
594
+ namespace: string,
595
+ indentCount = 1,
596
+ comment?: string,
597
+ ) {
598
+ const def: string[] = []
599
+
600
+ for (const girFunction of tsFunctions) {
601
+ def.push(...this.generateFunction(girFunction, onlyStatic, namespace, indentCount))
602
+ }
603
+
604
+ if (def.length > 0) {
605
+ def.unshift(...this.addInfoComment(comment, indentCount))
606
+ }
607
+
608
+ return def
609
+ }
610
+
611
+ private generateCallbackInterface(
612
+ tsCallback: TsCallback | TsSignal,
613
+ namespace: string,
614
+ indentCount = 0,
615
+ classModuleName?: string,
616
+ ) {
617
+ const def: string[] = []
618
+
619
+ if (!tsCallback?.tsCallbackInterface) {
620
+ this.log.warn(NO_TSDATA('generateCallbackInterface'))
621
+ return def
622
+ }
623
+
624
+ def.push(...this.addGirDocComment(tsCallback.doc, indentCount, tsCallback.tsCallbackInterface.overwriteDoc))
625
+
626
+ const indent = generateIndent(indentCount)
627
+ const indentBody = generateIndent(indentCount + 1)
628
+ const { inParams, instanceParameters } = tsCallback
629
+ const returnTypeStr = this.generateTypes(tsCallback.returnTypes, namespace)
630
+
631
+ // Get name, remove namespace and remove module class name prefix
632
+ let { name } = tsCallback.tsCallbackInterface
633
+ const { generics } = tsCallback.tsCallbackInterface
634
+ name = removeNamespace(name, namespace)
635
+ if (classModuleName) name = removeClassModule(name, classModuleName)
636
+ const genericParameters = this.generateGenericParameters(generics)
637
+
638
+ const inParamsDef: string[] = this.generateInParameters(inParams, instanceParameters, namespace)
639
+
640
+ const interfaceHead = `${name}${genericParameters}`
641
+
642
+ def.push(this.generateExport('interface', `${interfaceHead}`, '{', indentCount))
643
+ def.push(`${indentBody}(${inParamsDef.join(', ')}): ${returnTypeStr}`)
644
+ def.push(indent + '}')
645
+
646
+ return def
647
+ }
648
+
649
+ private generateCallbackInterfaces(
650
+ tsCallbacks: Array<TsCallback | TsSignal>,
651
+ namespace: string,
652
+ indentCount = 0,
653
+ classModuleName: string,
654
+ comment?: string,
655
+ ) {
656
+ const def: string[] = []
657
+
658
+ for (const tsCallback of tsCallbacks) {
659
+ def.push(...this.generateCallbackInterface(tsCallback, namespace, indentCount, classModuleName), '')
660
+ }
661
+
662
+ if (def.length > 0) {
663
+ def.unshift(...this.addInfoComment(comment, indentCount))
664
+ }
665
+
666
+ return def
667
+ }
668
+
669
+ private generateEnumeration(girEnum: GirEnumElement | GirBitfieldElement, indentCount = 0) {
670
+ const desc: string[] = []
671
+
672
+ if (!girElementIsIntrospectable(girEnum)) {
673
+ return desc
674
+ }
675
+
676
+ if (!girEnum._tsData) {
677
+ this.log.warn(NO_TSDATA('generateEnumeration'))
678
+ return desc
679
+ }
680
+
681
+ desc.push(...this.addGirDocComment(girEnum._tsData.doc, indentCount))
682
+
683
+ const { name } = girEnum._tsData
684
+ desc.push(this.generateExport('enum', name, '{', indentCount))
685
+ if (girEnum.member) {
686
+ for (const girEnumMember of girEnum.member) {
687
+ if (!girEnumMember._tsData) continue
688
+ desc.push(...this.generateEnumerationMember(girEnumMember._tsData, indentCount + 1))
689
+ }
690
+ }
691
+ desc.push('}')
692
+ return desc
693
+ }
694
+
695
+ private generateEnumerationMember(tsMember: TsMember, indentCount = 1) {
696
+ const desc: string[] = []
697
+
698
+ if (!tsMember) {
699
+ this.log.warn(NO_TSDATA('generateEnumerationMember'))
700
+ return desc
701
+ }
702
+
703
+ desc.push(...this.addGirDocComment(tsMember.doc, indentCount))
704
+
705
+ const indent = generateIndent(indentCount)
706
+ desc.push(`${indent}${tsMember.name},`)
707
+ return desc
708
+ }
709
+
710
+ private generateConstant(tsConst: TsVar, namespace: string, indentCount = 0) {
711
+ const desc: string[] = []
712
+
713
+ if (!tsConst.hasUnresolvedConflict) {
714
+ desc.push(...this.addGirDocComment(tsConst.doc, indentCount))
715
+ }
716
+
717
+ const indent = generateIndent(indentCount)
718
+ const exp = !this.config.noNamespace || this.config.buildType === 'types' ? '' : 'export '
719
+ const varDesc = this.generateVariable(tsConst, namespace, 0)
720
+ desc.push(`${indent}${exp}const ${varDesc}`)
721
+ return desc
722
+ }
723
+
724
+ private generateAlias(girAlias: GirAliasElement, namespace: string, indentCount = 0) {
725
+ const desc: string[] = []
726
+
727
+ if (!girElementIsIntrospectable(girAlias)) {
728
+ return ''
729
+ }
730
+
731
+ if (!girAlias._tsData) {
732
+ this.log.warn(NO_TSDATA('generateAlias'))
733
+ return desc
734
+ }
735
+ const indent = generateIndent(indentCount)
736
+
737
+ const exp = !this.config.noNamespace || this.config.buildType === 'types' ? '' : 'export '
738
+ const type = removeNamespace(girAlias._tsData.type, namespace)
739
+
740
+ desc.push(`${indent}${exp}type ${girAlias._tsData.name} = ${type}`)
741
+ return desc
742
+ }
743
+
744
+ private generateConstructPropsInterface(
745
+ girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
746
+ namespace: string,
747
+ indentCount = 0,
748
+ ) {
749
+ const def: string[] = []
750
+
751
+ if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
752
+ throw new Error(NO_TSDATA('generateConstructPropsInterface'))
753
+ }
754
+
755
+ if (!girClass._tsData.isDerivedFromGObject) {
756
+ return def
757
+ }
758
+
759
+ const indent = generateIndent(indentCount)
760
+ const exp = !this.config.noNamespace || this.config.buildType === 'types' ? '' : 'export '
761
+ let ext = ''
762
+
763
+ if (girClass._tsData.inheritConstructPropInterfaceNames.length) {
764
+ const constructPropInterfaceNames = girClass._tsData.inheritConstructPropInterfaceNames.map((n) =>
765
+ removeNamespace(n, namespace),
766
+ )
767
+ ext = `extends ${constructPropInterfaceNames.join(', ')} `
768
+ }
769
+
770
+ // Remove namespace and class module name
771
+ const constructPropInterfaceName = removeClassModule(
772
+ removeNamespace(girClass._tsData.constructPropInterfaceName, namespace),
773
+ girClass._tsData.name,
774
+ )
775
+
776
+ def.push(...this.addInfoComment('Constructor properties interface', indentCount))
777
+
778
+ // START BODY
779
+ {
780
+ def.push(`${indent}${exp}interface ${constructPropInterfaceName} ${ext}{`)
781
+ def.push(
782
+ ...this.generateProperties(
783
+ girClass._tsData.constructProps.map((cp) => cp._tsData).filter((cp) => !!cp) as TsProperty[],
784
+ false,
785
+ namespace,
786
+ `Own constructor properties of ${girClass._module.packageName}.${girClass._fullSymName}`,
787
+ indentCount + 1,
788
+ ),
789
+ )
790
+ def.push(`${indent}}`, '')
791
+ }
792
+ // END BODY
793
+
794
+ return def
795
+ }
796
+
797
+ private generateClassFields(
798
+ girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
799
+ onlyStatic: boolean,
800
+ namespace: string,
801
+ indentCount = 1,
802
+ ) {
803
+ const def: string[] = []
804
+ if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
805
+ throw new Error(NO_TSDATA('generateClassFields'))
806
+ }
807
+
808
+ def.push(
809
+ ...this.generateProperties(
810
+ girClass._tsData.fields.map((f) => f._tsData).filter((f) => !!f) as TsProperty[],
811
+ onlyStatic,
812
+ namespace,
813
+ `Own fields of ${girClass._module.packageName}.${girClass._fullSymName}`,
814
+ indentCount,
815
+ ),
816
+ )
817
+
818
+ return def
819
+ }
820
+
821
+ private generateClassProperties(
822
+ girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
823
+ onlyStatic: boolean,
824
+ namespace: string,
825
+ indentCount = 1,
826
+ ) {
827
+ const def: string[] = []
828
+
829
+ if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
830
+ throw new Error(NO_TSDATA('generateClassProperties'))
831
+ }
832
+
833
+ def.push(
834
+ ...this.generateProperties(
835
+ girClass._tsData.properties.map((p) => p._tsData).filter((p) => !!p) as TsProperty[],
836
+ onlyStatic,
837
+ namespace,
838
+ `Own properties of ${girClass._module.packageName}.${girClass._fullSymName}`,
839
+ indentCount,
840
+ ),
841
+ )
842
+
843
+ def.push(
844
+ ...this.generateProperties(
845
+ girClass._tsData.conflictProperties,
846
+ onlyStatic,
847
+ namespace,
848
+ `Conflicting properties`,
849
+ indentCount,
850
+ ),
851
+ )
852
+
853
+ return def
854
+ }
855
+
856
+ private generateClassMethods(
857
+ girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
858
+ onlyStatic: boolean,
859
+ namespace: string,
860
+ indentCount = 1,
861
+ ) {
862
+ const def: string[] = []
863
+ if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
864
+ throw new Error(NO_TSDATA('generateClassMethods'))
865
+ }
866
+
867
+ def.push(
868
+ ...this.generateFunctions(
869
+ girClass._tsData.methods.map((girFunc) => girFunc._tsData).filter((tsFunc) => !!tsFunc) as TsFunction[],
870
+ onlyStatic,
871
+ namespace,
872
+ indentCount,
873
+ `Owm ${onlyStatic ? 'static ' : ''}methods of ${girClass._module.packageName}.${girClass._fullSymName}`,
874
+ ),
875
+ )
876
+
877
+ def.push(
878
+ ...this.generateFunctions(
879
+ girClass._tsData.conflictMethods,
880
+ onlyStatic,
881
+ namespace,
882
+ indentCount,
883
+ `Conflicting ${onlyStatic ? 'static ' : ''}methods`,
884
+ ),
885
+ )
886
+
887
+ return def
888
+ }
889
+
890
+ private generateClassConstructors(
891
+ girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
892
+ namespace: string,
893
+ indentCount = 1,
894
+ ) {
895
+ const def: string[] = []
896
+ if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
897
+ throw new Error(NO_TSDATA('generateClassConstructors'))
898
+ }
899
+
900
+ // Constructors
901
+ def.push(
902
+ ...this.generateFunctions(
903
+ girClass._tsData.constructors
904
+ .map((girFunc) => girFunc._tsData)
905
+ .filter((tsFunc) => !!tsFunc) as TsFunction[],
906
+ true,
907
+ namespace,
908
+ indentCount,
909
+ ),
910
+ )
911
+ // _init method
912
+ def.push(
913
+ ...this.generateFunctions(
914
+ girClass._tsData.constructors
915
+ .map((girFunc) => girFunc._tsData)
916
+ .filter((tsFunc) => !!tsFunc) as TsFunction[],
917
+ false,
918
+ namespace,
919
+ indentCount,
920
+ ),
921
+ )
922
+ // Pseudo constructors
923
+ def.push(
924
+ ...this.generateFunctions(
925
+ girClass._tsData.staticFunctions
926
+ .map((girFunc) => girFunc._tsData)
927
+ .filter((tsFunc) => !!tsFunc) as TsFunction[],
928
+ true,
929
+ namespace,
930
+ indentCount,
931
+ ),
932
+ )
933
+
934
+ if (def.length) {
935
+ def.unshift(
936
+ ...this.addInfoComment(
937
+ `Constructors of ${girClass._module.packageName}.${girClass._fullSymName}`,
938
+ indentCount,
939
+ ),
940
+ )
941
+ }
942
+
943
+ return def
944
+ }
945
+
946
+ /**
947
+ * Instance methods, vfunc_ prefix
948
+ * @param girClass
949
+ */
950
+ private generateClassVirtualMethods(
951
+ girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
952
+ namespace: string,
953
+ indentCount = 1,
954
+ ) {
955
+ const def: string[] = []
956
+ if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
957
+ throw new Error(NO_TSDATA('generateClassVirtualMethods'))
958
+ }
959
+
960
+ def.push(
961
+ ...this.generateFunctions(
962
+ girClass._tsData.virtualMethods
963
+ .map((girFunc) => girFunc._tsData)
964
+ .filter((tsFunc) => !!tsFunc) as TsFunction[],
965
+ false,
966
+ namespace,
967
+ indentCount,
968
+ `Own virtual methods of ${girClass._module.packageName}.${girClass._fullSymName}`,
969
+ ),
970
+ )
971
+
972
+ return def
973
+ }
974
+
975
+ private generateClassSignalInterfaces(
976
+ girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
977
+ namespace: string,
978
+ indentCount = 0,
979
+ ) {
980
+ const def: string[] = []
981
+ if (!girClass._tsData) {
982
+ throw new Error(NO_TSDATA('generateClassSignalInterface'))
983
+ }
984
+
985
+ const tsSignals = girClass._tsData.signals
986
+ .map((signal) => signal._tsData)
987
+ .filter((signal) => !!signal) as TsSignal[]
988
+
989
+ def.push(
990
+ ...this.generateCallbackInterfaces(
991
+ tsSignals,
992
+ namespace,
993
+ indentCount,
994
+ girClass._tsData.name,
995
+ 'Signal callback interfaces',
996
+ ),
997
+ )
998
+
999
+ return def
1000
+ }
1001
+
1002
+ private generateClassSignals(
1003
+ girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
1004
+ namespace: string,
1005
+ ) {
1006
+ const def: string[] = []
1007
+ if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
1008
+ throw new Error(NO_TSDATA('generateClassSignals'))
1009
+ }
1010
+
1011
+ const signalDescs = this.generateSignals(girClass._tsData.signals, girClass, namespace, 0)
1012
+
1013
+ def.push(
1014
+ ...this.mergeDescs(
1015
+ signalDescs,
1016
+ `Own signals of ${girClass._module.packageName}.${girClass._fullSymName}`,
1017
+ 1,
1018
+ ),
1019
+ )
1020
+
1021
+ return def
1022
+ }
1023
+
1024
+ private generateClassModules(
1025
+ girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
1026
+ namespace: string,
1027
+ indentCount = 0,
1028
+ ) {
1029
+ const def: string[] = []
1030
+ const bodyDef: string[] = []
1031
+ if (!girClass._tsData) return def
1032
+ const indent = generateIndent(indentCount)
1033
+
1034
+ const exp = !this.config.noNamespace || this.config.buildType === 'types' ? '' : 'export '
1035
+
1036
+ // Signal interfaces
1037
+ bodyDef.push(...this.generateClassSignalInterfaces(girClass, namespace, indentCount + 1))
1038
+
1039
+ // Properties interface for construction
1040
+ bodyDef.push(...this.generateConstructPropsInterface(girClass, namespace, indentCount + 1))
1041
+
1042
+ if (!bodyDef.length) {
1043
+ return []
1044
+ }
1045
+
1046
+ // START BODY
1047
+ {
1048
+ def.push(`${indent}${exp}module ${girClass._tsData.name} {`)
1049
+
1050
+ // Properties interface for construction
1051
+ def.push(...bodyDef)
1052
+
1053
+ def.push(`${indent}}`, '')
1054
+ }
1055
+ // END BODY
1056
+
1057
+ return def
1058
+ }
1059
+
1060
+ /**
1061
+ * In Typescript, interfaces and classes can have the same name,
1062
+ * so we use this to generate interfaces with the same name to implement multiple inheritance
1063
+ * @param girClass
1064
+ * @param namespace
1065
+ */
1066
+ private generateImplementationInterface(
1067
+ girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
1068
+ namespace: string,
1069
+ ) {
1070
+ const def: string[] = []
1071
+
1072
+ if (!girClass._tsData) return def
1073
+
1074
+ const genericParameters = this.generateGenericParameters(girClass._tsData.generics)
1075
+ const implementationNames = girClass._tsData.parents
1076
+ .filter((implementation) => implementation.type !== 'parent')
1077
+ .map((implementation) => implementation.localParentName)
1078
+ const ext = implementationNames.length ? ` extends ${implementationNames.join(', ')}` : ''
1079
+ const interfaceHead = `${girClass._tsData.name}${genericParameters}${ext}`
1080
+
1081
+ // START INTERFACE
1082
+ {
1083
+ def.push(this.generateExport('interface', interfaceHead, '{'))
1084
+
1085
+ // START BODY
1086
+ {
1087
+ // Properties
1088
+ def.push(...this.generateClassProperties(girClass, false, namespace))
1089
+
1090
+ // Fields
1091
+ def.push(...this.generateClassFields(girClass, false, namespace))
1092
+
1093
+ // Methods
1094
+ def.push(...this.generateClassMethods(girClass, false, namespace))
1095
+
1096
+ // Virtual methods
1097
+ def.push(...this.generateClassVirtualMethods(girClass, namespace))
1098
+
1099
+ // Signals
1100
+ def.push(...this.generateClassSignals(girClass, namespace))
1101
+
1102
+ // TODO: Generate `GirSignalElement`s instead of generate the signal definition strings directly
1103
+ def.push(...this.generateClassPropertySignals(girClass, namespace))
1104
+ }
1105
+ // END BODY
1106
+
1107
+ // END INTERFACE
1108
+ def.push('}')
1109
+ def.push('')
1110
+ }
1111
+
1112
+ return def
1113
+ }
1114
+
1115
+ /**
1116
+ * Represents a record, GObject class or interface as a Typescript class
1117
+ * @param girClass
1118
+ * @param namespace
1119
+ */
1120
+ private generateClass(
1121
+ girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
1122
+ namespace: string,
1123
+ ) {
1124
+ const def: string[] = []
1125
+
1126
+ if (!girClass._tsData) return def
1127
+
1128
+ def.push(...this.generateClassModules(girClass, namespace))
1129
+
1130
+ def.push(...this.generateImplementationInterface(girClass, namespace))
1131
+
1132
+ def.push(...this.addGirDocComment(girClass._tsData.doc, 0))
1133
+
1134
+ const genericParameters = this.generateGenericParameters(girClass._tsData.generics)
1135
+ const parentName = girClass._tsData.parents.find((parent) => parent.type === 'parent')?.localParentName
1136
+ const ext = parentName ? ` extends ${parentName}` : ''
1137
+ const classHead = `${girClass._tsData.name}${genericParameters}${ext}`
1138
+
1139
+ // START CLASS
1140
+ {
1141
+ if (girClass._tsData.isAbstract) {
1142
+ def.push(this.generateExport('abstract class', classHead, '{'))
1143
+ } else {
1144
+ def.push(this.generateExport('class', classHead, '{'))
1145
+ }
1146
+
1147
+ // START BODY
1148
+ {
1149
+ // Static Properties
1150
+ def.push(...this.generateClassProperties(girClass, true, namespace))
1151
+
1152
+ // Static Fields
1153
+ def.push(...this.generateClassFields(girClass, true, namespace))
1154
+
1155
+ // Constructors
1156
+ def.push(...this.generateClassConstructors(girClass, namespace))
1157
+
1158
+ // Static Methods
1159
+ def.push(...this.generateClassMethods(girClass, true, namespace))
1160
+ }
1161
+ // END BODY
1162
+
1163
+ // END CLASS
1164
+ def.push('}')
1165
+ def.push('')
1166
+ }
1167
+
1168
+ return def
1169
+ }
1170
+
1171
+ private async exportModuleJS(moduleTemplateProcessor: TemplateProcessor, girModule: GirModule): Promise<void> {
1172
+ const template = 'module.js'
1173
+ if (this.config.outdir) {
1174
+ await moduleTemplateProcessor.create(template, this.config.outdir, `${girModule.packageName}.js`)
1175
+ } else {
1176
+ const moduleContent = moduleTemplateProcessor.load(template)
1177
+ this.log.log(moduleContent)
1178
+ }
1179
+ }
1180
+
1181
+ private async exportModuleTS(moduleTemplateProcessor: TemplateProcessor, girModule: GirModule): Promise<void> {
1182
+ const template = 'module.d.ts'
1183
+ const out: string[] = []
1184
+
1185
+ out.push(...this.addTSDocCommentLines([girModule.packageName]))
1186
+
1187
+ out.push('')
1188
+
1189
+ // Module dependencies as type references or imports
1190
+ if (this.config.environment === 'gjs') {
1191
+ out.push(...this.generateModuleDependenciesImport('Gjs', 'Gjs', false))
1192
+ }
1193
+
1194
+ for (const dependency of girModule.transitiveDependencies) {
1195
+ // Don't reference yourself as a dependency
1196
+ if (girModule.packageName !== dependency.packageName) {
1197
+ if (dependency.exists) {
1198
+ out.push(
1199
+ ...this.generateModuleDependenciesImport(dependency.namespace, dependency.packageName, false),
1200
+ )
1201
+ } else {
1202
+ out.push(`// WARN: Dependency not found: '${dependency.packageName}'`)
1203
+ this.log.warn(WARN_NOT_FOUND_DEPENDENCY_GIR_FILE(dependency.filename))
1204
+ }
1205
+ }
1206
+ }
1207
+
1208
+ // START Namespace
1209
+ {
1210
+ if (this.config.buildType === 'types') {
1211
+ out.push('')
1212
+ out.push(`declare namespace ${girModule.namespace} {`)
1213
+ } else if (!this.config.noNamespace) {
1214
+ out.push('')
1215
+ out.push(`export namespace ${girModule.namespace} {`)
1216
+ }
1217
+
1218
+ // Newline
1219
+ out.push('')
1220
+
1221
+ if (girModule.ns.enumeration)
1222
+ for (const girEnum of girModule.ns.enumeration) out.push(...this.generateEnumeration(girEnum))
1223
+
1224
+ if (girModule.ns.bitfield)
1225
+ for (const girBitfield of girModule.ns.bitfield) out.push(...this.generateEnumeration(girBitfield))
1226
+
1227
+ if (girModule.ns.constant)
1228
+ for (const girConst of girModule.ns.constant) {
1229
+ if (!girConst._tsData) continue
1230
+ out.push(...this.generateConstant(girConst._tsData, girModule.namespace, 0))
1231
+ }
1232
+
1233
+ if (girModule.ns.function)
1234
+ for (const girFunc of girModule.ns.function) {
1235
+ if (!girFunc._tsData) {
1236
+ // this.log.warn(NO_TSDATA('exportModuleTS functions'))
1237
+ continue
1238
+ }
1239
+ out.push(...this.generateFunction(girFunc._tsData, false, girModule.namespace, 0))
1240
+ }
1241
+
1242
+ if (girModule.ns.callback)
1243
+ for (const girCallback of girModule.ns.callback) {
1244
+ if (!girCallback._tsData) continue
1245
+ out.push(...this.generateCallbackInterface(girCallback._tsData, girModule.namespace))
1246
+ }
1247
+
1248
+ if (girModule.ns.interface)
1249
+ for (const girIface of girModule.ns.interface)
1250
+ if (girIface._module) {
1251
+ out.push(...this.generateClass(girIface, girIface._module.namespace))
1252
+ }
1253
+
1254
+ // Extra interfaces if a template with the module name (e.g. '../templates/GObject-2.0.d.ts') is found
1255
+ // E.g. used for GObject-2.0 to help define GObject classes in js;
1256
+ // these aren't part of gi.
1257
+ if (moduleTemplateProcessor.exists(`${girModule.packageName}.d.ts`)) {
1258
+ const templatePatches = await moduleTemplateProcessor.load(`${girModule.packageName}.d.ts`)
1259
+ out.push(templatePatches)
1260
+ }
1261
+
1262
+ if (girModule.ns.class)
1263
+ for (const gitClass of girModule.ns.class)
1264
+ if (gitClass._module) {
1265
+ out.push(...this.generateClass(gitClass, gitClass._module.namespace))
1266
+ }
1267
+
1268
+ if (girModule.ns.record)
1269
+ for (const girRecord of girModule.ns.record)
1270
+ if (girRecord._module) {
1271
+ out.push(...this.generateClass(girRecord, girRecord._module.namespace))
1272
+ }
1273
+
1274
+ if (girModule.ns.union)
1275
+ for (const girUnion of girModule.ns.union)
1276
+ if (girUnion._module) {
1277
+ out.push(...this.generateClass(girUnion, girUnion._module.namespace))
1278
+ }
1279
+
1280
+ if (girModule.ns.alias)
1281
+ // GType is not a number in GJS
1282
+ for (const girAlias of girModule.ns.alias)
1283
+ if (girModule.packageName !== 'GObject-2.0' || girAlias.$.name !== 'Type')
1284
+ out.push(...this.generateAlias(girAlias, girModule.namespace, 1))
1285
+
1286
+ if (this.config.environment === 'gjs') {
1287
+ // Properties added to every GIRepositoryNamespace
1288
+ // https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L186-190
1289
+ out.push(
1290
+ ...this.generateConstant(
1291
+ {
1292
+ doc: {
1293
+ text: 'Name of the imported GIR library',
1294
+ tags: [
1295
+ {
1296
+ text: 'https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188',
1297
+ tagName: 'see',
1298
+ paramName: '',
1299
+ },
1300
+ ],
1301
+ },
1302
+ name: '__name__',
1303
+ type: [
1304
+ {
1305
+ type: 'string',
1306
+ optional: false,
1307
+ nullable: false,
1308
+ callbacks: [],
1309
+ generics: [],
1310
+ isArray: false,
1311
+ isFunction: false,
1312
+ isCallback: false,
1313
+ },
1314
+ ],
1315
+ isInjected: false,
1316
+ tsTypeName: 'constant',
1317
+ girTypeName: 'constant',
1318
+ },
1319
+ girModule.namespace,
1320
+ 0,
1321
+ ),
1322
+ ...this.generateConstant(
1323
+ {
1324
+ doc: {
1325
+ text: 'Version of the imported GIR library',
1326
+ tags: [
1327
+ {
1328
+ text: 'https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189',
1329
+ tagName: 'see',
1330
+ paramName: '',
1331
+ },
1332
+ ],
1333
+ },
1334
+ name: '__version__',
1335
+ type: [
1336
+ {
1337
+ type: 'string',
1338
+ optional: false,
1339
+ nullable: false,
1340
+ callbacks: [],
1341
+ generics: [],
1342
+ isArray: false,
1343
+ isFunction: false,
1344
+ isCallback: false,
1345
+ },
1346
+ ],
1347
+ isInjected: false,
1348
+ tsTypeName: 'constant',
1349
+ girTypeName: 'constant',
1350
+ },
1351
+ girModule.namespace,
1352
+ 0,
1353
+ ),
1354
+ )
1355
+ }
1356
+ }
1357
+ // END Namespace
1358
+ if (!this.config.noNamespace) {
1359
+ out.push(`}`)
1360
+ }
1361
+
1362
+ if (!this.config.noNamespace) {
1363
+ out.push(`export default ${girModule.namespace};`)
1364
+ }
1365
+
1366
+ const outResult = out.join('\n') // End of file
1367
+
1368
+ if (this.config.outdir) {
1369
+ await moduleTemplateProcessor.create(
1370
+ template,
1371
+ this.config.outdir,
1372
+ `${girModule.packageName}.d.ts`,
1373
+ outResult,
1374
+ )
1375
+ } else {
1376
+ const moduleContent = await moduleTemplateProcessor.load(template)
1377
+ this.log.log(moduleContent + '\n' + outResult)
1378
+ }
1379
+ }
1380
+
1381
+ private async exportModule(girModule: GirModule) {
1382
+ const moduleTemplateProcessor = new TemplateProcessor(
1383
+ {
1384
+ name: girModule.namespace,
1385
+ namespace: girModule.namespace,
1386
+ version: girModule.version,
1387
+ importName: girModule.importName,
1388
+ },
1389
+ girModule.packageName,
1390
+ this.config,
1391
+ )
1392
+
1393
+ await this.exportModuleTS(moduleTemplateProcessor, girModule)
1394
+
1395
+ if (this.config.buildType === 'lib') {
1396
+ await this.exportModuleJS(moduleTemplateProcessor, girModule)
1397
+ }
1398
+ }
1399
+
1400
+ private async exportGjs(girModules: GirModule[], girModulesGrouped: GirModulesGrouped[]) {
1401
+ if (!this.config.outdir) return
1402
+
1403
+ const templateProcessor = new TemplateProcessor(
1404
+ { girModules: girModules, girModulesGrouped, typeDir: this.config.outdir + '/Gjs' },
1405
+ 'gjs',
1406
+ this.config,
1407
+ )
1408
+
1409
+ // Types
1410
+ await templateProcessor.create('Gjs.d.ts', this.config.outdir, 'Gjs.d.ts')
1411
+ await templateProcessor.create('index.d.ts', this.config.outdir, 'index.d.ts')
1412
+ if (this.config.gnomeShellTypes) {
1413
+ await templateProcessor.create('GnomeShell.d.ts', this.config.outdir, 'GnomeShell.d.ts')
1414
+ await templateProcessor.createAll('.d.ts', 'misc', this.config.outdir, 'misc')
1415
+ await templateProcessor.createAll('.d.ts', 'ui', this.config.outdir, 'ui')
1416
+ await templateProcessor.createAll('.d.ts', 'ui/components', this.config.outdir, 'ui/components')
1417
+ }
1418
+
1419
+ // Lib
1420
+ if (this.config.buildType === 'lib') {
1421
+ await templateProcessor.create('Gjs.js', this.config.outdir, 'Gjs.js')
1422
+ await templateProcessor.create('index.js', this.config.outdir, 'index.js')
1423
+ if (this.config.gnomeShellTypes) {
1424
+ await templateProcessor.create('GnomeShell.js', this.config.outdir, 'GnomeShell.js')
1425
+ await templateProcessor.createAll('.js', 'misc', this.config.outdir, 'misc')
1426
+ await templateProcessor.createAll('.js', 'ui', this.config.outdir, 'ui')
1427
+ await templateProcessor.createAll('.js', 'ui/components', this.config.outdir, 'ui/components')
1428
+ }
1429
+ }
1430
+
1431
+ // Alias
1432
+ if (this.config.generateAlias) {
1433
+ await templateProcessor.create('tsconfig.alias.json', './', 'tsconfig.alias.json', '', false)
1434
+ }
1435
+ }
1436
+
1437
+ private async exportNodeGtk(girModules: GirModule[], girModulesGrouped: GirModulesGrouped[]) {
1438
+ if (!this.config.outdir) return
1439
+
1440
+ const templateProcessor = new TemplateProcessor({ girModules, girModulesGrouped }, 'node', this.config)
1441
+
1442
+ await templateProcessor.create('index.d.ts', this.config.outdir, 'index.d.ts')
1443
+ if (this.config.buildType === 'lib') {
1444
+ await templateProcessor.create('index.js', this.config.outdir, 'index.js')
1445
+ }
1446
+ }
1447
+
1448
+ public async start(
1449
+ girModules: GirModule[],
1450
+ girModulesGrouped?: GirModulesGrouped[],
1451
+ inheritanceTable?: InheritanceTable,
1452
+ ) {
1453
+ for (const girModule of girModules) {
1454
+ await this.exportModule(girModule)
1455
+ }
1456
+
1457
+ if (this.config.environment === 'node' && girModulesGrouped) {
1458
+ // node-gtk internal stuff
1459
+ await this.exportNodeGtk(girModules, girModulesGrouped)
1460
+ }
1461
+
1462
+ if (this.config.environment === 'gjs' && girModulesGrouped && inheritanceTable) {
1463
+ // GJS internal stuff
1464
+ await this.exportGjs(girModules, girModulesGrouped)
1465
+ }
1466
+ }
1467
+ }