@ts-for-gir/lib 3.3.0 → 4.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 (477) hide show
  1. package/README.md +0 -1
  2. package/lib/constants.d.ts +8 -13
  3. package/lib/constants.js +79 -24
  4. package/lib/constants.js.map +1 -1
  5. package/lib/dependency-manager.d.ts +60 -16
  6. package/lib/dependency-manager.js +146 -56
  7. package/lib/dependency-manager.js.map +1 -1
  8. package/lib/formatters/default.d.ts +4 -0
  9. package/lib/formatters/default.js +7 -0
  10. package/lib/formatters/default.js.map +1 -0
  11. package/lib/formatters/formatter.d.ts +3 -0
  12. package/lib/formatters/formatter.js +3 -0
  13. package/lib/formatters/formatter.js.map +1 -0
  14. package/lib/formatters/json.d.ts +4 -0
  15. package/lib/formatters/json.js +7 -0
  16. package/lib/formatters/json.js.map +1 -0
  17. package/lib/generators/dts/glib.d.ts +2 -0
  18. package/lib/generators/dts/glib.js +514 -0
  19. package/lib/generators/dts/glib.js.map +1 -0
  20. package/lib/generators/dts/gobject.d.ts +2 -0
  21. package/lib/generators/dts/gobject.js +117 -0
  22. package/lib/generators/dts/gobject.js.map +1 -0
  23. package/lib/generators/dts-inline.d.ts +10 -0
  24. package/lib/generators/dts-inline.js +57 -0
  25. package/lib/generators/dts-inline.js.map +1 -0
  26. package/lib/generators/dts-modules.d.ts +10 -0
  27. package/lib/generators/dts-modules.js +98 -0
  28. package/lib/generators/dts-modules.js.map +1 -0
  29. package/lib/generators/dts.d.ts +45 -0
  30. package/lib/generators/dts.js +682 -0
  31. package/lib/generators/dts.js.map +1 -0
  32. package/lib/generators/generator.d.ts +45 -0
  33. package/lib/generators/generator.js +9 -0
  34. package/lib/generators/generator.js.map +1 -0
  35. package/lib/generators/index.d.ts +5 -0
  36. package/lib/generators/index.js +6 -0
  37. package/lib/generators/index.js.map +1 -0
  38. package/lib/generators/json.d.ts +258 -0
  39. package/lib/generators/json.js +867 -0
  40. package/lib/generators/json.js.map +1 -0
  41. package/lib/generics/clutter.d.ts +26 -0
  42. package/lib/generics/clutter.js +49 -0
  43. package/lib/generics/clutter.js.map +1 -0
  44. package/lib/generics/generify.d.ts +2 -0
  45. package/lib/generics/generify.js +39 -0
  46. package/lib/generics/generify.js.map +1 -0
  47. package/lib/generics/gio.d.ts +7 -0
  48. package/lib/generics/gio.js +51 -0
  49. package/lib/generics/gio.js.map +1 -0
  50. package/lib/generics/glib.d.ts +7 -0
  51. package/lib/generics/glib.js +18 -0
  52. package/lib/generics/glib.js.map +1 -0
  53. package/lib/generics/meta.d.ts +21 -0
  54. package/lib/generics/meta.js +26 -0
  55. package/lib/generics/meta.js.map +1 -0
  56. package/lib/generics/st.d.ts +16 -0
  57. package/lib/generics/st.js +92 -0
  58. package/lib/generics/st.js.map +1 -0
  59. package/lib/generics/visitor.d.ts +20 -0
  60. package/lib/generics/visitor.js +255 -0
  61. package/lib/generics/visitor.js.map +1 -0
  62. package/lib/gir/alias.d.ts +24 -0
  63. package/lib/gir/alias.js +43 -0
  64. package/lib/gir/alias.js.map +1 -0
  65. package/lib/gir/base.d.ts +62 -0
  66. package/lib/gir/base.js +95 -0
  67. package/lib/gir/base.js.map +1 -0
  68. package/lib/gir/class.d.ts +189 -0
  69. package/lib/gir/class.js +1131 -0
  70. package/lib/gir/class.js.map +1 -0
  71. package/lib/gir/const.d.ts +25 -0
  72. package/lib/gir/const.js +43 -0
  73. package/lib/gir/const.js.map +1 -0
  74. package/lib/gir/enum.d.ts +45 -0
  75. package/lib/gir/enum.js +164 -0
  76. package/lib/gir/enum.js.map +1 -0
  77. package/lib/gir/function.d.ts +199 -0
  78. package/lib/gir/function.js +683 -0
  79. package/lib/gir/function.js.map +1 -0
  80. package/lib/gir/generics.d.ts +5 -0
  81. package/lib/gir/generics.js +57 -0
  82. package/lib/gir/generics.js.map +1 -0
  83. package/lib/gir/namespace.d.ts +21 -0
  84. package/lib/gir/namespace.js +57 -0
  85. package/lib/gir/namespace.js.map +1 -0
  86. package/lib/gir/nodes.d.ts +11 -0
  87. package/lib/gir/nodes.js +12 -0
  88. package/lib/gir/nodes.js.map +1 -0
  89. package/lib/gir/property.d.ts +60 -0
  90. package/lib/gir/property.js +128 -0
  91. package/lib/gir/property.js.map +1 -0
  92. package/lib/gir/registry.d.ts +51 -0
  93. package/lib/gir/registry.js +144 -0
  94. package/lib/gir/registry.js.map +1 -0
  95. package/lib/gir/signal.d.ts +33 -0
  96. package/lib/gir/signal.js +165 -0
  97. package/lib/gir/signal.js.map +1 -0
  98. package/lib/gir/util.d.ts +49 -0
  99. package/lib/gir/util.js +559 -0
  100. package/lib/gir/util.js.map +1 -0
  101. package/lib/gir-module.d.ts +69 -241
  102. package/lib/gir-module.js +433 -2154
  103. package/lib/gir-module.js.map +1 -1
  104. package/lib/gir.d.ts +253 -0
  105. package/lib/gir.js +642 -0
  106. package/lib/gir.js.map +1 -0
  107. package/lib/index.d.ts +6 -6
  108. package/lib/index.js +8 -6
  109. package/lib/index.js.map +1 -1
  110. package/lib/injections/gee08.d.ts +7 -0
  111. package/lib/injections/gee08.js +68 -0
  112. package/lib/injections/gee08.js.map +1 -0
  113. package/lib/injections/gee1.d.ts +7 -0
  114. package/lib/injections/gee1.js +28 -0
  115. package/lib/injections/gee1.js.map +1 -0
  116. package/lib/injections/gio.d.ts +7 -0
  117. package/lib/injections/gio.js +431 -0
  118. package/lib/injections/gio.js.map +1 -0
  119. package/lib/injections/glib.d.ts +7 -0
  120. package/lib/injections/glib.js +204 -0
  121. package/lib/injections/glib.js.map +1 -0
  122. package/lib/injections/gobject.d.ts +7 -0
  123. package/lib/injections/gobject.js +479 -0
  124. package/lib/injections/gobject.js.map +1 -0
  125. package/lib/injections/inject.d.ts +4 -0
  126. package/lib/injections/inject.js +28 -0
  127. package/lib/injections/inject.js.map +1 -0
  128. package/lib/injections/tracker1.d.ts +7 -0
  129. package/lib/injections/tracker1.js +30 -0
  130. package/lib/injections/tracker1.js.map +1 -0
  131. package/lib/library-version.d.ts +2 -0
  132. package/lib/library-version.js +13 -0
  133. package/lib/library-version.js.map +1 -1
  134. package/lib/logger.d.ts +19 -19
  135. package/lib/logger.js +31 -34
  136. package/lib/logger.js.map +1 -1
  137. package/lib/messages.d.ts +1 -7
  138. package/lib/messages.js +1 -6
  139. package/lib/messages.js.map +1 -1
  140. package/lib/registry.d.ts +8 -0
  141. package/lib/registry.js +12 -0
  142. package/lib/registry.js.map +1 -0
  143. package/lib/transformation.d.ts +8 -19
  144. package/lib/transformation.js +40 -216
  145. package/lib/transformation.js.map +1 -1
  146. package/lib/types/dependency.d.ts +13 -1
  147. package/lib/types/format.d.ts +1 -0
  148. package/lib/types/format.js +2 -0
  149. package/lib/types/format.js.map +1 -0
  150. package/lib/types/gir-alias-element.d.ts +3 -12
  151. package/lib/types/gir-bitfield-element.d.ts +3 -14
  152. package/lib/types/gir-callable-param-element.d.ts +3 -31
  153. package/lib/types/gir-callable-params.d.ts +7 -0
  154. package/lib/types/gir-callable-params.js +2 -0
  155. package/lib/types/gir-callable-params.js.map +1 -0
  156. package/lib/types/gir-callable-return.d.ts +3 -20
  157. package/lib/types/gir-callback-element.d.ts +3 -12
  158. package/lib/types/gir-class-element.d.ts +3 -34
  159. package/lib/types/gir-constant-element.d.ts +3 -14
  160. package/lib/types/gir-constructor-element.d.ts +3 -5
  161. package/lib/types/gir-enum-element.d.ts +3 -16
  162. package/lib/types/gir-field-element.d.ts +3 -16
  163. package/lib/types/gir-function-element.d.ts +3 -5
  164. package/lib/types/gir-instance-parameter.d.ts +2 -17
  165. package/lib/types/gir-interface-element.d.ts +4 -19
  166. package/lib/types/gir-member-element.d.ts +4 -16
  167. package/lib/types/gir-method-element.d.ts +4 -10
  168. package/lib/types/gir-module-resolved-by.d.ts +5 -0
  169. package/lib/types/gir-namespace.d.ts +14 -17
  170. package/lib/types/gir-property-element.d.ts +3 -22
  171. package/lib/types/gir-record-element.d.ts +3 -23
  172. package/lib/types/gir-repository.d.ts +3 -14
  173. package/lib/types/gir-signal.d.ts +3 -18
  174. package/lib/types/gir-union-element.d.ts +3 -16
  175. package/lib/types/gir-virtual-method.d.ts +3 -7
  176. package/lib/types/index.d.ts +10 -56
  177. package/lib/types/index.js +10 -56
  178. package/lib/types/index.js.map +1 -1
  179. package/lib/types/metadata.d.ts +8 -0
  180. package/lib/types/metadata.js +2 -0
  181. package/lib/types/metadata.js.map +1 -0
  182. package/lib/types/options-base.d.ts +4 -0
  183. package/lib/types/options-base.js +2 -0
  184. package/lib/types/options-base.js.map +1 -0
  185. package/lib/types/options-generation.d.ts +44 -0
  186. package/lib/types/options-generation.js +2 -0
  187. package/lib/types/options-generation.js.map +1 -0
  188. package/lib/types/options-load.d.ts +5 -0
  189. package/lib/types/options-load.js +2 -0
  190. package/lib/types/options-load.js.map +1 -0
  191. package/lib/types/options-transform.d.ts +4 -0
  192. package/lib/types/options-transform.js +2 -0
  193. package/lib/types/options-transform.js.map +1 -0
  194. package/lib/types/output-format.d.ts +1 -0
  195. package/lib/types/output-format.js +2 -0
  196. package/lib/types/output-format.js.map +1 -0
  197. package/lib/types/parsed-gir.d.ts +3 -2
  198. package/lib/types/property-case.d.ts +1 -0
  199. package/lib/types/property-case.js +2 -0
  200. package/lib/types/property-case.js.map +1 -0
  201. package/lib/types/template-data.d.ts +2 -2
  202. package/lib/types/transformations.d.ts +1 -8
  203. package/lib/types/user-config.d.ts +20 -16
  204. package/lib/util.d.ts +20 -0
  205. package/lib/util.js +67 -0
  206. package/lib/util.js.map +1 -0
  207. package/lib/utils/files.d.ts +21 -0
  208. package/lib/utils/files.js +62 -0
  209. package/lib/utils/files.js.map +1 -0
  210. package/lib/utils/girs.d.ts +45 -0
  211. package/lib/utils/girs.js +101 -0
  212. package/lib/utils/girs.js.map +1 -0
  213. package/lib/utils/index.d.ts +6 -0
  214. package/lib/utils/index.js +7 -0
  215. package/lib/utils/index.js.map +1 -0
  216. package/lib/utils/numbers.d.ts +6 -0
  217. package/lib/utils/numbers.js +10 -0
  218. package/lib/utils/numbers.js.map +1 -0
  219. package/lib/utils/objects.d.ts +135 -0
  220. package/lib/utils/objects.js +122 -0
  221. package/lib/utils/objects.js.map +1 -0
  222. package/lib/utils/path.d.ts +1 -0
  223. package/lib/utils/path.js +7 -0
  224. package/lib/utils/path.js.map +1 -0
  225. package/lib/utils/strings.d.ts +74 -0
  226. package/lib/utils/strings.js +121 -0
  227. package/lib/utils/strings.js.map +1 -0
  228. package/lib/utils.d.ts +22 -44
  229. package/lib/utils.js +58 -69
  230. package/lib/utils.js.map +1 -1
  231. package/lib/validators/class.d.ts +7 -0
  232. package/lib/validators/class.js +217 -0
  233. package/lib/validators/class.js.map +1 -0
  234. package/lib/validators/interface.d.ts +5 -0
  235. package/lib/validators/interface.js +16 -0
  236. package/lib/validators/interface.js.map +1 -0
  237. package/lib/visitor.d.ts +35 -0
  238. package/lib/visitor.js +29 -0
  239. package/lib/visitor.js.map +1 -0
  240. package/package.json +20 -15
  241. package/lib/conflict-resolver.d.ts +0 -156
  242. package/lib/conflict-resolver.js +0 -1117
  243. package/lib/conflict-resolver.js.map +0 -1
  244. package/lib/gir-factory.d.ts +0 -52
  245. package/lib/gir-factory.js +0 -376
  246. package/lib/gir-factory.js.map +0 -1
  247. package/lib/gir-parser.d.ts +0 -2
  248. package/lib/gir-parser.js +0 -69
  249. package/lib/gir-parser.js.map +0 -1
  250. package/lib/injection/callbacks/gjs/Gio-2.0.d.ts +0 -2
  251. package/lib/injection/callbacks/gjs/Gio-2.0.js +0 -36
  252. package/lib/injection/callbacks/gjs/Gio-2.0.js.map +0 -1
  253. package/lib/injection/callbacks/gjs/index.d.ts +0 -2
  254. package/lib/injection/callbacks/gjs/index.js +0 -3
  255. package/lib/injection/callbacks/gjs/index.js.map +0 -1
  256. package/lib/injection/callbacks/index.d.ts +0 -4
  257. package/lib/injection/callbacks/index.js +0 -4
  258. package/lib/injection/callbacks/index.js.map +0 -1
  259. package/lib/injection/callbacks/node-gtk/index.d.ts +0 -2
  260. package/lib/injection/callbacks/node-gtk/index.js +0 -2
  261. package/lib/injection/callbacks/node-gtk/index.js.map +0 -1
  262. package/lib/injection/classes/gjs/gio-2.0.d.ts +0 -5
  263. package/lib/injection/classes/gjs/gio-2.0.js +0 -254
  264. package/lib/injection/classes/gjs/gio-2.0.js.map +0 -1
  265. package/lib/injection/classes/gjs/glib-2.0.d.ts +0 -2
  266. package/lib/injection/classes/gjs/glib-2.0.js +0 -225
  267. package/lib/injection/classes/gjs/glib-2.0.js.map +0 -1
  268. package/lib/injection/classes/gjs/gobject-2.0.d.ts +0 -2
  269. package/lib/injection/classes/gjs/gobject-2.0.js +0 -634
  270. package/lib/injection/classes/gjs/gobject-2.0.js.map +0 -1
  271. package/lib/injection/classes/gjs/index.d.ts +0 -2
  272. package/lib/injection/classes/gjs/index.js +0 -5
  273. package/lib/injection/classes/gjs/index.js.map +0 -1
  274. package/lib/injection/classes/glib-2.0.d.ts +0 -2
  275. package/lib/injection/classes/glib-2.0.js +0 -35
  276. package/lib/injection/classes/glib-2.0.js.map +0 -1
  277. package/lib/injection/classes/index.d.ts +0 -4
  278. package/lib/injection/classes/index.js +0 -5
  279. package/lib/injection/classes/index.js.map +0 -1
  280. package/lib/injection/classes/node-gtk/gdk-4.0.d.ts +0 -2
  281. package/lib/injection/classes/node-gtk/gdk-4.0.js +0 -32
  282. package/lib/injection/classes/node-gtk/gdk-4.0.js.map +0 -1
  283. package/lib/injection/classes/node-gtk/gio-2.0.d.ts +0 -2
  284. package/lib/injection/classes/node-gtk/gio-2.0.js +0 -14
  285. package/lib/injection/classes/node-gtk/gio-2.0.js.map +0 -1
  286. package/lib/injection/classes/node-gtk/glib-2.0.d.ts +0 -2
  287. package/lib/injection/classes/node-gtk/glib-2.0.js +0 -19
  288. package/lib/injection/classes/node-gtk/glib-2.0.js.map +0 -1
  289. package/lib/injection/classes/node-gtk/gobject-2.0.d.ts +0 -2
  290. package/lib/injection/classes/node-gtk/gobject-2.0.js +0 -66
  291. package/lib/injection/classes/node-gtk/gobject-2.0.js.map +0 -1
  292. package/lib/injection/classes/node-gtk/graphene-1.0.d.ts +0 -2
  293. package/lib/injection/classes/node-gtk/graphene-1.0.js +0 -133
  294. package/lib/injection/classes/node-gtk/graphene-1.0.js.map +0 -1
  295. package/lib/injection/classes/node-gtk/gtk-3.0.d.ts +0 -2
  296. package/lib/injection/classes/node-gtk/gtk-3.0.js +0 -31
  297. package/lib/injection/classes/node-gtk/gtk-3.0.js.map +0 -1
  298. package/lib/injection/classes/node-gtk/gtk-4.0.d.ts +0 -2
  299. package/lib/injection/classes/node-gtk/gtk-4.0.js +0 -52
  300. package/lib/injection/classes/node-gtk/gtk-4.0.js.map +0 -1
  301. package/lib/injection/classes/node-gtk/index.d.ts +0 -2
  302. package/lib/injection/classes/node-gtk/index.js +0 -19
  303. package/lib/injection/classes/node-gtk/index.js.map +0 -1
  304. package/lib/injection/classes/node-gtk/pango-1.0.d.ts +0 -2
  305. package/lib/injection/classes/node-gtk/pango-1.0.js +0 -31
  306. package/lib/injection/classes/node-gtk/pango-1.0.js.map +0 -1
  307. package/lib/injection/index.d.ts +0 -3
  308. package/lib/injection/index.js +0 -4
  309. package/lib/injection/index.js.map +0 -1
  310. package/lib/injection/injector.d.ts +0 -17
  311. package/lib/injection/injector.js +0 -140
  312. package/lib/injection/injector.js.map +0 -1
  313. package/lib/symtable.d.ts +0 -24
  314. package/lib/symtable.js +0 -63
  315. package/lib/symtable.js.map +0 -1
  316. package/lib/types/build-type.d.ts +0 -1
  317. package/lib/types/build-type.js +0 -2
  318. package/lib/types/build-type.js.map +0 -1
  319. package/lib/types/conflict-child-element.d.ts +0 -10
  320. package/lib/types/conflict-child-element.js +0 -2
  321. package/lib/types/conflict-child-element.js.map +0 -1
  322. package/lib/types/conflict-grouped-element.d.ts +0 -6
  323. package/lib/types/conflict-grouped-element.js +0 -2
  324. package/lib/types/conflict-grouped-element.js.map +0 -1
  325. package/lib/types/conflict-grouped-elements.d.ts +0 -4
  326. package/lib/types/conflict-grouped-elements.js +0 -2
  327. package/lib/types/conflict-grouped-elements.js.map +0 -1
  328. package/lib/types/environment.d.ts +0 -1
  329. package/lib/types/environment.js +0 -2
  330. package/lib/types/environment.js.map +0 -1
  331. package/lib/types/generate-config.d.ts +0 -41
  332. package/lib/types/generate-config.js +0 -2
  333. package/lib/types/generate-config.js.map +0 -1
  334. package/lib/types/gir-any-type.d.ts +0 -5
  335. package/lib/types/gir-any-type.js +0 -2
  336. package/lib/types/gir-any-type.js.map +0 -1
  337. package/lib/types/gir-array-type.d.ts +0 -20
  338. package/lib/types/gir-array-type.js +0 -3
  339. package/lib/types/gir-array-type.js.map +0 -1
  340. package/lib/types/gir-boolean.d.ts +0 -1
  341. package/lib/types/gir-boolean.js +0 -2
  342. package/lib/types/gir-boolean.js.map +0 -1
  343. package/lib/types/gir-boxed-element.d.ts +0 -15
  344. package/lib/types/gir-boxed-element.js +0 -2
  345. package/lib/types/gir-boxed-element.js.map +0 -1
  346. package/lib/types/gir-c-include.d.ts +0 -7
  347. package/lib/types/gir-c-include.js +0 -2
  348. package/lib/types/gir-c-include.js.map +0 -1
  349. package/lib/types/gir-callable-attrs.d.ts +0 -15
  350. package/lib/types/gir-callable-attrs.js +0 -3
  351. package/lib/types/gir-callable-attrs.js.map +0 -1
  352. package/lib/types/gir-callable-param.d.ts +0 -7
  353. package/lib/types/gir-callable-param.js +0 -2
  354. package/lib/types/gir-callable-param.js.map +0 -1
  355. package/lib/types/gir-direction.d.ts +0 -7
  356. package/lib/types/gir-direction.js +0 -9
  357. package/lib/types/gir-direction.js.map +0 -1
  358. package/lib/types/gir-doc-element.d.ts +0 -68
  359. package/lib/types/gir-doc-element.js +0 -2
  360. package/lib/types/gir-doc-element.js.map +0 -1
  361. package/lib/types/gir-implements.d.ts +0 -8
  362. package/lib/types/gir-implements.js +0 -2
  363. package/lib/types/gir-implements.js.map +0 -1
  364. package/lib/types/gir-include.d.ts +0 -9
  365. package/lib/types/gir-include.js +0 -2
  366. package/lib/types/gir-include.js.map +0 -1
  367. package/lib/types/gir-info-attrs.d.ts +0 -13
  368. package/lib/types/gir-info-attrs.js +0 -2
  369. package/lib/types/gir-info-attrs.js.map +0 -1
  370. package/lib/types/gir-info-elements.d.ts +0 -5
  371. package/lib/types/gir-info-elements.js +0 -2
  372. package/lib/types/gir-info-elements.js.map +0 -1
  373. package/lib/types/gir-package.d.ts +0 -7
  374. package/lib/types/gir-package.js +0 -2
  375. package/lib/types/gir-package.js.map +0 -1
  376. package/lib/types/gir-prerequisite.d.ts +0 -5
  377. package/lib/types/gir-prerequisite.js +0 -2
  378. package/lib/types/gir-prerequisite.js.map +0 -1
  379. package/lib/types/gir-transfer-ownership-type.d.ts +0 -5
  380. package/lib/types/gir-transfer-ownership-type.js +0 -7
  381. package/lib/types/gir-transfer-ownership-type.js.map +0 -1
  382. package/lib/types/gir-transfer-ownership.d.ts +0 -9
  383. package/lib/types/gir-transfer-ownership.js +0 -2
  384. package/lib/types/gir-transfer-ownership.js.map +0 -1
  385. package/lib/types/gir-type.d.ts +0 -14
  386. package/lib/types/gir-type.js +0 -2
  387. package/lib/types/gir-type.js.map +0 -1
  388. package/lib/types/gir-var-args.d.ts +0 -5
  389. package/lib/types/gir-var-args.js +0 -2
  390. package/lib/types/gir-var-args.js.map +0 -1
  391. package/lib/types/injection-callback.d.ts +0 -16
  392. package/lib/types/injection-callback.js +0 -2
  393. package/lib/types/injection-callback.js.map +0 -1
  394. package/lib/types/injection-class.d.ts +0 -25
  395. package/lib/types/injection-class.js +0 -2
  396. package/lib/types/injection-class.js.map +0 -1
  397. package/lib/types/injection-function.d.ts +0 -7
  398. package/lib/types/injection-function.js +0 -2
  399. package/lib/types/injection-function.js.map +0 -1
  400. package/lib/types/injection-generic-parameter.d.ts +0 -2
  401. package/lib/types/injection-generic-parameter.js +0 -2
  402. package/lib/types/injection-generic-parameter.js.map +0 -1
  403. package/lib/types/injection-instance-parameter.d.ts +0 -2
  404. package/lib/types/injection-instance-parameter.js +0 -2
  405. package/lib/types/injection-instance-parameter.js.map +0 -1
  406. package/lib/types/injection-parameter.d.ts +0 -8
  407. package/lib/types/injection-parameter.js +0 -2
  408. package/lib/types/injection-parameter.js.map +0 -1
  409. package/lib/types/injection-property.d.ts +0 -4
  410. package/lib/types/injection-property.js +0 -2
  411. package/lib/types/injection-property.js.map +0 -1
  412. package/lib/types/injection-type.d.ts +0 -2
  413. package/lib/types/injection-type.js +0 -2
  414. package/lib/types/injection-type.js.map +0 -1
  415. package/lib/types/injection.d.ts +0 -5
  416. package/lib/types/injection.js +0 -2
  417. package/lib/types/injection.js.map +0 -1
  418. package/lib/types/module-type.d.ts +0 -1
  419. package/lib/types/module-type.js +0 -2
  420. package/lib/types/module-type.js.map +0 -1
  421. package/lib/types/promisify-func.d.ts +0 -7
  422. package/lib/types/promisify-func.js +0 -2
  423. package/lib/types/promisify-func.js.map +0 -1
  424. package/lib/types/sym-table-items.d.ts +0 -4
  425. package/lib/types/sym-table-items.js +0 -2
  426. package/lib/types/sym-table-items.js.map +0 -1
  427. package/lib/types/ts-alias.d.ts +0 -10
  428. package/lib/types/ts-alias.js +0 -2
  429. package/lib/types/ts-alias.js.map +0 -1
  430. package/lib/types/ts-callback-interface.d.ts +0 -10
  431. package/lib/types/ts-callback-interface.js +0 -2
  432. package/lib/types/ts-callback-interface.js.map +0 -1
  433. package/lib/types/ts-callback.d.ts +0 -17
  434. package/lib/types/ts-callback.js +0 -2
  435. package/lib/types/ts-callback.js.map +0 -1
  436. package/lib/types/ts-class.d.ts +0 -85
  437. package/lib/types/ts-class.js +0 -2
  438. package/lib/types/ts-class.js.map +0 -1
  439. package/lib/types/ts-enum.d.ts +0 -12
  440. package/lib/types/ts-enum.js +0 -2
  441. package/lib/types/ts-enum.js.map +0 -1
  442. package/lib/types/ts-function.d.ts +0 -55
  443. package/lib/types/ts-function.js +0 -2
  444. package/lib/types/ts-function.js.map +0 -1
  445. package/lib/types/ts-generic-parameter.d.ts +0 -8
  446. package/lib/types/ts-generic-parameter.js +0 -2
  447. package/lib/types/ts-generic-parameter.js.map +0 -1
  448. package/lib/types/ts-instance-parameter.d.ts +0 -4
  449. package/lib/types/ts-instance-parameter.js +0 -2
  450. package/lib/types/ts-instance-parameter.js.map +0 -1
  451. package/lib/types/ts-member.d.ts +0 -10
  452. package/lib/types/ts-member.js +0 -2
  453. package/lib/types/ts-member.js.map +0 -1
  454. package/lib/types/ts-method.d.ts +0 -5
  455. package/lib/types/ts-method.js +0 -2
  456. package/lib/types/ts-method.js.map +0 -1
  457. package/lib/types/ts-parameter.d.ts +0 -15
  458. package/lib/types/ts-parameter.js +0 -2
  459. package/lib/types/ts-parameter.js.map +0 -1
  460. package/lib/types/ts-property.d.ts +0 -17
  461. package/lib/types/ts-property.js +0 -2
  462. package/lib/types/ts-property.js.map +0 -1
  463. package/lib/types/ts-signal.d.ts +0 -17
  464. package/lib/types/ts-signal.js +0 -2
  465. package/lib/types/ts-signal.js.map +0 -1
  466. package/lib/types/ts-type-name.d.ts +0 -1
  467. package/lib/types/ts-type-name.js +0 -2
  468. package/lib/types/ts-type-name.js.map +0 -1
  469. package/lib/types/ts-type-separator.d.ts +0 -1
  470. package/lib/types/ts-type-separator.js +0 -2
  471. package/lib/types/ts-type-separator.js.map +0 -1
  472. package/lib/types/ts-type.d.ts +0 -26
  473. package/lib/types/ts-type.js +0 -2
  474. package/lib/types/ts-type.js.map +0 -1
  475. package/lib/types/ts-var.d.ts +0 -17
  476. package/lib/types/ts-var.js +0 -2
  477. package/lib/types/ts-var.js.map +0 -1
package/README.md CHANGED
@@ -19,4 +19,3 @@
19
19
  # Library
20
20
 
21
21
  Node.js library to generate Typescript Type Definition files for Gjs and node-gtk.
22
-
@@ -1,14 +1,8 @@
1
1
  import { LibraryVersion } from './library-version.js';
2
- import type { Environment } from './types/index.js';
3
- /**
4
- * In gjs all classes have a static name property but the classes listed below already have a static name property
5
- */
6
- export declare const STATIC_NAME_ALREADY_EXISTS: string[];
7
2
  export declare const COMMENT_REG_EXP: RegExp;
8
3
  export declare const PARAM_REG_EXP: RegExp;
9
4
  export declare const OPT_PARAM_REG_EXP: RegExp;
10
5
  export declare const NEW_LINE_REG_EXP: RegExp;
11
- export declare const MAX_CLASS_PARENT_DEPTH = 100;
12
6
  export declare const PACKAGE: {
13
7
  name: string;
14
8
  version: string;
@@ -21,10 +15,11 @@ export declare const APP_NAME = "ts-for-gir";
21
15
  export declare const APP_USAGE = "TypeScript type definition generator for GObject introspection GIR files";
22
16
  export declare const APP_SOURCE = "https://github.com/gjsify/ts-for-gir";
23
17
  export declare const APP_VERSION: string;
24
- export declare const PACKAGE_DESC: (packageName: string, environment: Environment, libraryVersion?: LibraryVersion) => string;
25
- export declare const PACKAGE_KEYWORDS: (packageName: string, environment: Environment) => string;
26
- export declare const GENERIC_NAMES: string[];
27
- export declare const SIGNAL_METHOD_NAMES_GENERAL: string[];
28
- export declare const SIGNAL_METHOD_NAMES_GJS: string[];
29
- export declare const SIGNAL_METHOD_NAMES_NODE: string[];
30
- export declare const SIGNAL_METHOD_NAMES: (env: Environment) => (string | string[])[];
18
+ export declare const PACKAGE_DESC: (packageName: string, libraryVersion?: LibraryVersion) => string;
19
+ export declare const PACKAGE_KEYWORDS: (packageName: string) => string;
20
+ /** The reserved variable names listed here cannot be resolved simply by quotation marks */
21
+ export declare const RESERVED_QUOTE_VARIABLE_NAMES: string[];
22
+ export declare const RESERVED_VARIABLE_NAMES: string[];
23
+ export declare const RESERVED_CLASS_NAMES: string[];
24
+ export declare const RESERVED_FUNCTION_NAMES: string[];
25
+ export declare const RESERVED_NAMESPACE_NAMES: {};
package/lib/constants.js CHANGED
@@ -1,38 +1,93 @@
1
- import { __dirname, readJsonFile } from './utils.js';
1
+ import { __dirname, readJsonFile } from './utils/index.js';
2
2
  import { join } from 'path';
3
- /**
4
- * In gjs all classes have a static name property but the classes listed below already have a static name property
5
- */
6
- export const STATIC_NAME_ALREADY_EXISTS = ['GMime.Charset', 'Camel.StoreInfo'];
7
3
  export const COMMENT_REG_EXP = /\/\*.*\*\//g;
8
4
  export const PARAM_REG_EXP = /[0-9a-zA-Z_]*:/g;
9
5
  export const OPT_PARAM_REG_EXP = /[0-9a-zA-Z_]*\?:/g;
10
6
  export const NEW_LINE_REG_EXP = /[\n\r]+/g;
11
- export const MAX_CLASS_PARENT_DEPTH = 100;
12
- export const PACKAGE = await readJsonFile(join(__dirname, '../package.json'));
7
+ export const PACKAGE = await readJsonFile(join(__dirname, './package.json'));
13
8
  export const APP_NAME = 'ts-for-gir';
14
9
  export const APP_USAGE = 'TypeScript type definition generator for GObject introspection GIR files';
15
10
  export const APP_SOURCE = 'https://github.com/gjsify/ts-for-gir';
16
11
  export const APP_VERSION = PACKAGE.version;
17
- export const PACKAGE_DESC = (packageName, environment, libraryVersion) => {
18
- const envStr = environment === 'node' ? 'Node.js' : 'GJS';
12
+ export const PACKAGE_DESC = (packageName, libraryVersion) => {
19
13
  if (libraryVersion) {
20
- return `${envStr} TypeScript type definitions for ${packageName}, generated from library version ${libraryVersion.toString()}`;
14
+ return `GJS TypeScript type definitions for ${packageName}, generated from library version ${libraryVersion.toString()}`;
21
15
  }
22
- return `${envStr} TypeScript type definitions for ${packageName}`;
16
+ return `GJS TypeScript type definitions for ${packageName}`;
23
17
  };
24
- export const PACKAGE_KEYWORDS = (packageName, environment) => {
25
- const envKeywords = environment === 'node' ? '"node", "node-gtk"' : '"GJS"';
26
- return `"Gir", "TypeScript", "types", "GObject-Introspection", ${envKeywords}, "${packageName}"`;
27
- };
28
- export const GENERIC_NAMES = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K'];
29
- export const SIGNAL_METHOD_NAMES_GENERAL = ['connect', 'emit', 'disconnect'];
30
- export const SIGNAL_METHOD_NAMES_GJS = ['connect_after', 'emit'];
31
- export const SIGNAL_METHOD_NAMES_NODE = ['after', 'on', 'once', 'off'];
32
- export const SIGNAL_METHOD_NAMES = (env) => {
33
- if (env === 'node') {
34
- return [...SIGNAL_METHOD_NAMES_GENERAL, SIGNAL_METHOD_NAMES_NODE];
35
- }
36
- return [...SIGNAL_METHOD_NAMES_GENERAL, SIGNAL_METHOD_NAMES_GJS];
18
+ export const PACKAGE_KEYWORDS = (packageName) => {
19
+ return `"Gir", "TypeScript", "types", "GObject-Introspection", "GJS", "${packageName}"`;
37
20
  };
21
+ /** The reserved variable names listed here cannot be resolved simply by quotation marks */
22
+ export const RESERVED_QUOTE_VARIABLE_NAMES = ['constructor'];
23
+ export const RESERVED_VARIABLE_NAMES = [
24
+ 'in',
25
+ 'function',
26
+ 'true',
27
+ 'false',
28
+ 'break',
29
+ 'arguments',
30
+ 'eval',
31
+ 'default',
32
+ 'new',
33
+ 'extends',
34
+ 'with',
35
+ 'var',
36
+ 'class',
37
+ 'delete',
38
+ 'return',
39
+ 'constructor',
40
+ 'this', // TODO check if this is used as we would use this in javascript, if so, this is only allowed as the first parameter
41
+ ];
42
+ export const RESERVED_CLASS_NAMES = [
43
+ 'break',
44
+ 'boolean',
45
+ 'case',
46
+ 'catch',
47
+ 'class',
48
+ 'const',
49
+ 'continue',
50
+ 'debugger',
51
+ 'default',
52
+ 'delete',
53
+ 'do',
54
+ 'else',
55
+ 'enum',
56
+ 'export',
57
+ 'extends',
58
+ 'false',
59
+ 'finally',
60
+ 'for',
61
+ 'function',
62
+ 'if',
63
+ 'implements',
64
+ 'import',
65
+ 'in',
66
+ 'instanceof',
67
+ 'interface',
68
+ 'let',
69
+ 'new',
70
+ 'number',
71
+ 'package',
72
+ 'private',
73
+ 'protected',
74
+ 'public',
75
+ 'return',
76
+ 'static',
77
+ 'super',
78
+ 'switch',
79
+ 'string',
80
+ 'this',
81
+ 'throw',
82
+ 'true',
83
+ 'try',
84
+ 'typeof',
85
+ 'var',
86
+ 'void',
87
+ 'while',
88
+ 'with',
89
+ 'yield',
90
+ ];
91
+ export const RESERVED_FUNCTION_NAMES = ['false', 'true', 'break'];
92
+ export const RESERVED_NAMESPACE_NAMES = {};
38
93
  //# sourceMappingURL=constants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AAI;IACJ,MAAM;IACN,MAAM;IACN,QAAQ;IACR,SAAS;IACT,OAAO;IACP,SAAS;IACT,KAAK;IACL,UAAU;IACV,IAAI;IACJ,YAAY;IACZ,QAAQ;IACR,IAAI;IACJ,YAAY;IACZ,WAAW;IACX,KAAK;IACL,KAAK;IACL,QAAQ;IACR,SAAS;IACT,SAAS;IACT,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,QAAQ;IACR,KAAK;IACL,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;CACV,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;AAEjE,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA"}
@@ -1,27 +1,50 @@
1
+ import { GirXML, GirRepository, GirNamespace } from '@gi.ts/parser';
1
2
  import { Logger } from './logger.js';
2
3
  import { Transformation } from './transformation.js';
3
- import type { Dependency, GenerateConfig, GirInclude } from './types/index.js';
4
+ import { LibraryVersion } from './library-version.js';
5
+ import type { Dependency, OptionsGeneration, GirInclude, FileInfo } from './types/index.js';
4
6
  import type { GirModule } from './gir-module.js';
5
- export declare class DependencyManager {
6
- protected readonly config: GenerateConfig;
7
+ import { GirNSRegistry } from './registry.js';
8
+ export declare class DependencyManager extends GirNSRegistry {
9
+ protected readonly config: OptionsGeneration;
7
10
  protected log: Logger;
8
11
  protected transformation: Transformation;
9
- cache: {
12
+ protected _cache: {
10
13
  [packageName: string]: Dependency;
11
14
  };
12
15
  static instances: {
13
- [env: string]: DependencyManager;
16
+ [key: string]: DependencyManager;
14
17
  };
15
- protected constructor(config: GenerateConfig);
18
+ protected constructor(config: OptionsGeneration);
16
19
  /**
17
20
  * Get the DependencyManager singleton instance
18
21
  */
19
- static getInstance(config: GenerateConfig): DependencyManager;
20
- protected parseArgs(namespaceOrPackageName: string, version?: string): {
22
+ static getInstance(config?: OptionsGeneration): DependencyManager;
23
+ protected parsePackageName(namespaceOrPackageName: string, version?: string): {
21
24
  packageName: string;
22
25
  namespace: string;
23
26
  version: string;
24
27
  };
28
+ protected parseArgs(namespaceOrPackageNameOrRepo: string | GirRepository, version?: string): {
29
+ repo: null;
30
+ namespace: string;
31
+ importNamespace: string;
32
+ version: string;
33
+ libraryVersion: LibraryVersion;
34
+ packageName: string;
35
+ importName: string;
36
+ importPath: string;
37
+ importDef: string;
38
+ girXML: GirXML | null;
39
+ path: string | null;
40
+ filename: string;
41
+ exists: boolean;
42
+ } | {
43
+ packageName: string;
44
+ namespace: string;
45
+ version: string;
46
+ repo: GirRepository | null;
47
+ };
25
48
  /**
26
49
  * Get all dependencies in the cache
27
50
  * @returns All dependencies in the cache
@@ -32,26 +55,48 @@ export declare class DependencyManager {
32
55
  * Get the core dependencies
33
56
  * @returns
34
57
  */
35
- core(): Dependency[];
36
- createImportProperties(namespace: string, packageName: string): {
58
+ core(): Promise<Dependency[]>;
59
+ createImportProperties(namespace: string, packageName: string, version: string): {
37
60
  importPath: string;
38
61
  importDef: string;
39
62
  };
40
- createImportPath(packageName: string): string;
63
+ createImportPath(packageName: string, namespace: string, version: string): string;
41
64
  createImportDef(namespace: string, importPath: string): string;
65
+ protected parseGir(path: string): Promise<{
66
+ girXML: GirXML;
67
+ repo: GirRepository;
68
+ ns: GirNamespace | undefined;
69
+ version: string | undefined;
70
+ }>;
71
+ protected parseGirAndReturnLatestVersion(filesInfo: FileInfo[]): Promise<{
72
+ libraryVersion: LibraryVersion;
73
+ girXML: GirXML;
74
+ fileInfo: FileInfo;
75
+ } | {
76
+ libraryVersion: LibraryVersion;
77
+ girXML: null;
78
+ fileInfo: FileInfo;
79
+ }>;
42
80
  /**
43
81
  * Get the dependency object by packageName
44
82
  * @param packageName The package name (with version affix) of the dependency
45
83
  * @returns The dependency object
46
84
  */
47
- get(packageName: string): Dependency;
85
+ get(packageName: string): Promise<Dependency>;
48
86
  /**
49
87
  * Get the dependency object by namespace and version
50
88
  * @param namespace The namespace of the dependency
51
89
  * @param version The version of the dependency
52
90
  * @returns The dependency object
53
91
  */
54
- get(namespace: string, version: string): Dependency;
92
+ get(namespace: string, version: string): Promise<Dependency>;
93
+ /**
94
+ * Get the dependency object by {@link GirRepository}
95
+ * @param namespace The namespace of the dependency
96
+ * @param version The version of the dependency
97
+ * @returns The dependency object
98
+ */
99
+ get(repo: GirRepository): Promise<Dependency>;
55
100
  /**
56
101
  * Get all dependencies with the given namespace
57
102
  * @param namespace The namespace of the dependency
@@ -68,13 +113,13 @@ export declare class DependencyManager {
68
113
  * Add all dependencies from an array of gir modules
69
114
  * @param girModules
70
115
  */
71
- addAll(girModules: GirModule[]): Dependency[];
116
+ addAll(girModules: GirModule[]): Promise<Dependency[]>;
72
117
  /**
73
118
  * Transforms a gir include object array to a dependency object array
74
119
  * @param girIncludes - Array of gir includes
75
120
  * @returns Array of dependencies
76
121
  */
77
- fromGirIncludes(girIncludes: GirInclude[]): Dependency[];
122
+ fromGirIncludes(girIncludes: GirInclude[]): Promise<Dependency[]>;
78
123
  /**
79
124
  * Check if multiple dependencies with the given namespace exist in the cache
80
125
  * @param namespace The namespace of the dependency
@@ -102,5 +147,4 @@ export declare class DependencyManager {
102
147
  find(namespace: string): Dependency | null;
103
148
  protected getPseudoPackage(packageName: string): Dependency;
104
149
  getGjs(): Dependency;
105
- getNodeGtk(): Dependency;
106
150
  }
@@ -1,28 +1,39 @@
1
- import { findFileInDirs, splitModuleName, pascalCase } from './utils.js';
1
+ import { parser } from '@gi.ts/parser';
2
+ import { readFile } from 'fs/promises';
3
+ import { findFilesInDirs, splitModuleName, pascalCase } from './utils/index.js';
4
+ import { sanitizeNamespace } from './gir/util.js';
2
5
  import { Logger } from './logger.js';
3
6
  import { Transformation } from './transformation.js';
4
- export class DependencyManager {
7
+ import { LibraryVersion } from './library-version.js';
8
+ import { GirNSRegistry } from './registry.js';
9
+ export class DependencyManager extends GirNSRegistry {
5
10
  config;
6
11
  log;
7
12
  transformation;
8
- cache = {};
13
+ _cache = {};
9
14
  static instances = {};
10
15
  constructor(config) {
16
+ super();
11
17
  this.config = config;
12
- this.transformation = new Transformation(config);
13
- this.log = new Logger(config.environment, config.verbose, 'DependencyManager');
18
+ this.transformation = Transformation.getSingleton(config);
19
+ this.log = new Logger(config.verbose, 'DependencyManager');
14
20
  }
15
21
  /**
16
22
  * Get the DependencyManager singleton instance
17
23
  */
18
24
  static getInstance(config) {
19
- if (this.instances[config.environment]) {
20
- return this.instances[config.environment];
25
+ const configKey = config ? JSON.stringify(config) : Object.keys(this.instances)[0];
26
+ if (this.instances[configKey]) {
27
+ return this.instances[configKey];
21
28
  }
22
- this.instances[config.environment] = new DependencyManager(config);
23
- return this.instances[config.environment];
29
+ if (!config) {
30
+ throw new Error('config parameter is required to initialize DependencyManager');
31
+ }
32
+ const instance = new DependencyManager(config);
33
+ this.instances[configKey] = instance;
34
+ return instance;
24
35
  }
25
- parseArgs(namespaceOrPackageName, version) {
36
+ parsePackageName(namespaceOrPackageName, version) {
26
37
  let packageName;
27
38
  let namespace;
28
39
  if (version) {
@@ -37,34 +48,63 @@ export class DependencyManager {
37
48
  }
38
49
  return { packageName, namespace, version };
39
50
  }
51
+ parseArgs(namespaceOrPackageNameOrRepo, version) {
52
+ let packageName;
53
+ let namespace;
54
+ let repo = null;
55
+ if (typeof namespaceOrPackageNameOrRepo === 'string') {
56
+ // Special case for Gjs
57
+ if (namespaceOrPackageNameOrRepo === 'Gjs') {
58
+ return { ...this.getGjs(), repo: null };
59
+ }
60
+ const args = this.parsePackageName(namespaceOrPackageNameOrRepo, version);
61
+ version = args.version;
62
+ packageName = args.packageName;
63
+ namespace = args.namespace;
64
+ }
65
+ else {
66
+ repo = namespaceOrPackageNameOrRepo;
67
+ const ns = repo.namespace?.[0];
68
+ if (!ns) {
69
+ throw new Error('Invalid GirRepository');
70
+ }
71
+ version = ns.$.version;
72
+ namespace = ns.$.name;
73
+ packageName = `${namespace}-${version}`;
74
+ }
75
+ return { packageName, namespace, version, repo };
76
+ }
40
77
  /**
41
78
  * Get all dependencies in the cache
42
79
  * @returns All dependencies in the cache
43
80
  */
44
81
  all() {
45
- return Object.values(this.cache);
82
+ return Object.values(this._cache);
46
83
  }
47
84
  getAllPackageNames() {
48
- return Object.keys(this.cache);
85
+ return Object.keys(this._cache);
49
86
  }
50
87
  /**
51
88
  * Get the core dependencies
52
89
  * @returns
53
90
  */
54
- core() {
55
- return [this.get('GObject-2.0'), this.get('GLib-2.0')];
91
+ async core() {
92
+ return [await this.get('GObject', '2.0'), await this.get('GLib', '2.0'), await this.get('Gio', '2.0')];
56
93
  }
57
- createImportProperties(namespace, packageName) {
58
- const importPath = this.createImportPath(packageName);
94
+ createImportProperties(namespace, packageName, version) {
95
+ const importPath = this.createImportPath(packageName, namespace, version);
59
96
  const importDef = this.createImportDef(namespace, importPath);
60
97
  return {
61
98
  importPath,
62
99
  importDef,
63
100
  };
64
101
  }
65
- createImportPath(packageName) {
102
+ createImportPath(packageName, namespace, version) {
103
+ if (!this.config.package) {
104
+ return `gi://${namespace}?version=${version}`;
105
+ }
66
106
  const importName = this.transformation.transformImportName(packageName);
67
- const importPath = this.config.package ? `${this.config.npmScope}/${importName}` : `./${importName}.js`;
107
+ const importPath = `${this.config.npmScope}/${importName}`;
68
108
  return importPath;
69
109
  }
70
110
  createImportDef(namespace, importPath) {
@@ -72,35 +112,86 @@ export class DependencyManager {
72
112
  ? `import type * as ${namespace} from '${importPath}'`
73
113
  : `import type ${namespace} from '${importPath}';`;
74
114
  }
75
- get(namespaceOrPackageName, version) {
76
- // Special case for Gjs
77
- if (namespaceOrPackageName === 'Gjs') {
78
- return this.getGjs();
115
+ async parseGir(path) {
116
+ const girXML = parser.parseGir(await readFile(path, 'utf8'));
117
+ const repo = girXML.repository[0];
118
+ const ns = repo?.namespace?.[0];
119
+ const version = ns?.$.version;
120
+ return { girXML, repo, ns, version };
121
+ }
122
+ async parseGirAndReturnLatestVersion(filesInfo) {
123
+ const libraryVersions = [];
124
+ if (filesInfo.length > 1) {
125
+ this.log.warn(`Multiple paths found for ${filesInfo[0].filename}`);
126
+ }
127
+ for (const fileInfo of filesInfo) {
128
+ if (!fileInfo.exists || !fileInfo.path) {
129
+ continue;
130
+ }
131
+ const { girXML, ns, version } = await this.parseGir(fileInfo.path);
132
+ if (!version || !ns) {
133
+ continue;
134
+ }
135
+ const libraryVersion = new LibraryVersion(ns?.constant, version);
136
+ if (filesInfo.length > 1) {
137
+ this.log.muted(` - ${fileInfo.path} (${libraryVersion.toString()})`);
138
+ }
139
+ libraryVersions.push({
140
+ libraryVersion,
141
+ girXML,
142
+ fileInfo,
143
+ });
144
+ }
145
+ // Compare all library versions and return the latest version
146
+ const latestLibraryVersion = libraryVersions.sort((a, b) => a.libraryVersion.compare(b.libraryVersion))[0];
147
+ if (!latestLibraryVersion) {
148
+ this.log.warn('No latest library version found', {
149
+ libraryVersions,
150
+ filesInfo,
151
+ });
152
+ return {
153
+ libraryVersion: new LibraryVersion(),
154
+ girXML: null,
155
+ fileInfo: filesInfo[0],
156
+ };
79
157
  }
80
- else if (namespaceOrPackageName === 'node-gtk') {
81
- return this.getNodeGtk();
158
+ if (filesInfo.length > 1) {
159
+ this.log.muted(`Use latest version ${latestLibraryVersion.libraryVersion.toString()}`);
82
160
  }
83
- const args = this.parseArgs(namespaceOrPackageName, version);
84
- version = args.version;
85
- const packageName = args.packageName;
86
- const namespace = args.namespace;
87
- if (this.cache[packageName]) {
88
- const dep = this.cache[packageName];
161
+ return latestLibraryVersion;
162
+ }
163
+ async get(namespaceOrPackageNameOrRepo, _version) {
164
+ const parsedArgs = this.parseArgs(namespaceOrPackageNameOrRepo, _version);
165
+ const { packageName, repo } = parsedArgs;
166
+ let { namespace, version } = parsedArgs;
167
+ namespace = sanitizeNamespace(namespace);
168
+ if (this._cache[packageName]) {
169
+ const dep = this._cache[packageName];
89
170
  return dep;
90
171
  }
91
172
  const filename = `${packageName}.gir`;
92
- const { exists, path } = findFileInDirs(this.config.girDirectories, filename);
173
+ const filesInfo = await findFilesInDirs(this.config.girDirectories, filename);
174
+ const { libraryVersion, girXML, fileInfo } = await this.parseGirAndReturnLatestVersion(filesInfo);
175
+ const ns = girXML?.repository[0]?.namespace?.[0] || repo?.namespace?.[0] || null;
176
+ // Use the version from the gir file if it exists
177
+ if (ns?.$.version) {
178
+ version = ns?.$.version;
179
+ }
180
+ if (ns?.$.name) {
181
+ namespace = ns?.$.name;
182
+ }
93
183
  const dependency = {
184
+ ...fileInfo,
94
185
  namespace,
95
- exists,
96
- filename,
97
- path,
98
186
  packageName,
99
187
  importName: this.transformation.transformImportName(packageName),
188
+ importNamespace: this.transformation.transformModuleNamespaceName(packageName),
100
189
  version,
101
- ...this.createImportProperties(namespace, packageName),
190
+ libraryVersion,
191
+ girXML,
192
+ ...this.createImportProperties(namespace, packageName, version),
102
193
  };
103
- this.cache[packageName] = dependency;
194
+ this._cache[packageName] = dependency;
104
195
  return dependency;
105
196
  }
106
197
  /**
@@ -111,7 +202,7 @@ export class DependencyManager {
111
202
  list(namespace) {
112
203
  const packageNames = this.all();
113
204
  const candidates = packageNames.filter((dep) => {
114
- return dep.namespace === namespace;
205
+ return dep.namespace === namespace && dep.exists;
115
206
  });
116
207
  return candidates;
117
208
  }
@@ -127,9 +218,9 @@ export class DependencyManager {
127
218
  * Add all dependencies from an array of gir modules
128
219
  * @param girModules
129
220
  */
130
- addAll(girModules) {
221
+ async addAll(girModules) {
131
222
  for (const girModule of girModules) {
132
- this.get(girModule.namespace, girModule.version || '0.0');
223
+ await this.get(girModule.namespace, girModule.version || '0.0');
133
224
  }
134
225
  return this.all();
135
226
  }
@@ -138,10 +229,10 @@ export class DependencyManager {
138
229
  * @param girIncludes - Array of gir includes
139
230
  * @returns Array of dependencies
140
231
  */
141
- fromGirIncludes(girIncludes) {
232
+ async fromGirIncludes(girIncludes) {
142
233
  const dependencies = [];
143
234
  for (const i of girIncludes) {
144
- dependencies.unshift(this.get(i.$.name, i.$.version || '0.0'));
235
+ dependencies.unshift(await this.get(i.$.name, i.$.version || '0.0'));
145
236
  }
146
237
  return dependencies;
147
238
  }
@@ -153,7 +244,7 @@ export class DependencyManager {
153
244
  hasConflict(namespace) {
154
245
  const packageNames = this.getAllPackageNames();
155
246
  const candidates = packageNames.filter((packageName) => {
156
- return packageName.startsWith(`${namespace}-`) && this.cache[packageName].namespace === namespace;
247
+ return packageName.startsWith(`${namespace}-`) && this._cache[packageName].namespace === namespace;
157
248
  });
158
249
  return candidates.length > 1;
159
250
  }
@@ -191,44 +282,43 @@ export class DependencyManager {
191
282
  if (namespace === 'Gjs') {
192
283
  return this.getGjs();
193
284
  }
194
- else if (namespace === 'node-gtk') {
195
- return this.getNodeGtk();
196
- }
197
285
  const packageNames = this.getAllPackageNames();
198
286
  const candidates = packageNames.filter((packageName) => {
199
- return packageName.startsWith(`${namespace}-`) && this.cache[packageName].namespace === namespace;
287
+ return packageName.startsWith(`${namespace}-`) && this._cache[packageName].namespace === namespace;
200
288
  });
201
289
  if (candidates.length > 1) {
202
290
  this.log.warn(`Found multiple versions of ${namespace}: ${candidates.join(', ')}`);
203
291
  }
204
292
  const latestVersion = candidates.sort().pop();
205
- if (latestVersion && this.cache[latestVersion]) {
206
- const dep = this.cache[latestVersion];
293
+ if (latestVersion && this._cache[latestVersion]) {
294
+ const dep = this._cache[latestVersion];
207
295
  return dep;
208
296
  }
209
297
  return null;
210
298
  }
211
299
  getPseudoPackage(packageName) {
212
- if (this.cache[packageName]) {
213
- return this.cache[packageName];
300
+ if (this._cache[packageName]) {
301
+ return this._cache[packageName];
214
302
  }
303
+ const namespace = pascalCase(packageName);
304
+ const version = '2.0';
215
305
  const dep = {
216
- namespace: pascalCase(packageName),
306
+ namespace,
217
307
  exists: true,
218
308
  filename: '',
219
309
  path: '',
220
310
  packageName: packageName,
221
311
  importName: this.transformation.transformImportName(packageName),
222
- version: '0.0',
223
- ...this.createImportProperties(packageName, packageName),
312
+ importNamespace: this.transformation.transformModuleNamespaceName(packageName),
313
+ version,
314
+ libraryVersion: new LibraryVersion(),
315
+ girXML: null,
316
+ ...this.createImportProperties(packageName, packageName, version),
224
317
  };
225
318
  return dep;
226
319
  }
227
320
  getGjs() {
228
321
  return this.getPseudoPackage('Gjs');
229
322
  }
230
- getNodeGtk() {
231
- return this.getPseudoPackage('node-gtk');
232
- }
233
323
  }
234
324
  //# sourceMappingURL=dependency-manager.js.map