@gtkx/codegen 1.0.0-rc.4 → 1.0.0

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 (410) hide show
  1. package/README.md +5 -5
  2. package/dist/analysis/descriptor-render.d.ts +8 -1
  3. package/dist/analysis/descriptor-render.d.ts.map +1 -1
  4. package/dist/analysis/descriptor-render.js +37 -24
  5. package/dist/analysis/descriptor-render.js.map +1 -1
  6. package/dist/analysis/descriptor.d.ts +1 -1
  7. package/dist/analysis/descriptor.d.ts.map +1 -1
  8. package/dist/analysis/descriptor.js.map +1 -1
  9. package/dist/analysis/inheritance.d.ts +1 -2
  10. package/dist/analysis/inheritance.d.ts.map +1 -1
  11. package/dist/analysis/inheritance.js +25 -22
  12. package/dist/analysis/inheritance.js.map +1 -1
  13. package/dist/analysis/nul-terminated-bytes.d.ts +5 -0
  14. package/dist/analysis/nul-terminated-bytes.d.ts.map +1 -0
  15. package/dist/analysis/nul-terminated-bytes.js +18 -0
  16. package/dist/analysis/nul-terminated-bytes.js.map +1 -0
  17. package/dist/analysis/param-capability.d.ts +5 -0
  18. package/dist/analysis/param-capability.d.ts.map +1 -0
  19. package/dist/analysis/param-capability.js +130 -0
  20. package/dist/analysis/param-capability.js.map +1 -0
  21. package/dist/analysis/param-structure.d.ts +11 -4
  22. package/dist/analysis/param-structure.d.ts.map +1 -1
  23. package/dist/analysis/param-structure.js +40 -14
  24. package/dist/analysis/param-structure.js.map +1 -1
  25. package/dist/analysis/type-shape.d.ts +8 -0
  26. package/dist/analysis/type-shape.d.ts.map +1 -0
  27. package/dist/analysis/type-shape.js +12 -0
  28. package/dist/analysis/type-shape.js.map +1 -0
  29. package/dist/compile.d.ts +1 -1
  30. package/dist/compile.d.ts.map +1 -1
  31. package/dist/compile.js.map +1 -1
  32. package/dist/docs/api-reference.d.ts +2 -2
  33. package/dist/docs/api-reference.d.ts.map +1 -1
  34. package/dist/docs/api-reference.js +7 -14
  35. package/dist/docs/api-reference.js.map +1 -1
  36. package/dist/docs/element-page.d.ts +4 -4
  37. package/dist/docs/element-page.d.ts.map +1 -1
  38. package/dist/docs/element-page.js +32 -20
  39. package/dist/docs/element-page.js.map +1 -1
  40. package/dist/docs/handwritten-props.d.ts +9 -0
  41. package/dist/docs/handwritten-props.d.ts.map +1 -0
  42. package/dist/docs/handwritten-props.js +149 -0
  43. package/dist/docs/handwritten-props.js.map +1 -0
  44. package/dist/docs/pipeline.js +2 -2
  45. package/dist/docs/pipeline.js.map +1 -1
  46. package/dist/docs/render.d.ts +25 -5
  47. package/dist/docs/render.d.ts.map +1 -1
  48. package/dist/docs/render.js +84 -22
  49. package/dist/docs/render.js.map +1 -1
  50. package/dist/docs/symbol-page.d.ts +17 -0
  51. package/dist/docs/symbol-page.d.ts.map +1 -1
  52. package/dist/docs/symbol-page.js +128 -43
  53. package/dist/docs/symbol-page.js.map +1 -1
  54. package/dist/fingerprint.d.ts +1 -1
  55. package/dist/fingerprint.d.ts.map +1 -1
  56. package/dist/fingerprint.js.map +1 -1
  57. package/dist/gir/ancestry.d.ts +2 -2
  58. package/dist/gir/ancestry.d.ts.map +1 -1
  59. package/dist/gir/ancestry.js +11 -1
  60. package/dist/gir/ancestry.js.map +1 -1
  61. package/dist/gir/annotations.d.ts +22 -0
  62. package/dist/gir/annotations.d.ts.map +1 -0
  63. package/dist/gir/annotations.js +15 -0
  64. package/dist/gir/annotations.js.map +1 -0
  65. package/dist/gir/callback.d.ts +1 -0
  66. package/dist/gir/callback.d.ts.map +1 -1
  67. package/dist/gir/callback.js +1 -0
  68. package/dist/gir/callback.js.map +1 -1
  69. package/dist/gir/class.d.ts +32 -1
  70. package/dist/gir/class.d.ts.map +1 -1
  71. package/dist/gir/class.js +8 -3
  72. package/dist/gir/class.js.map +1 -1
  73. package/dist/gir/enum.d.ts +21 -1
  74. package/dist/gir/enum.d.ts.map +1 -1
  75. package/dist/gir/enum.js +9 -9
  76. package/dist/gir/enum.js.map +1 -1
  77. package/dist/gir/field.d.ts +19 -3
  78. package/dist/gir/field.d.ts.map +1 -1
  79. package/dist/gir/field.js +7 -8
  80. package/dist/gir/field.js.map +1 -1
  81. package/dist/gir/function.d.ts +15 -0
  82. package/dist/gir/function.d.ts.map +1 -1
  83. package/dist/gir/function.js.map +1 -1
  84. package/dist/gir/libraries.d.ts +1 -3
  85. package/dist/gir/libraries.d.ts.map +1 -1
  86. package/dist/gir/libraries.js +0 -1
  87. package/dist/gir/libraries.js.map +1 -1
  88. package/dist/gir/library.d.ts +36 -0
  89. package/dist/gir/library.d.ts.map +1 -1
  90. package/dist/gir/library.js +34 -0
  91. package/dist/gir/library.js.map +1 -1
  92. package/dist/gir/namespace.d.ts +38 -0
  93. package/dist/gir/namespace.d.ts.map +1 -1
  94. package/dist/gir/namespace.js +4 -5
  95. package/dist/gir/namespace.js.map +1 -1
  96. package/dist/gir/parameter.d.ts +39 -0
  97. package/dist/gir/parameter.d.ts.map +1 -1
  98. package/dist/gir/parameter.js +7 -3
  99. package/dist/gir/parameter.js.map +1 -1
  100. package/dist/gir/parse.d.ts +3 -1
  101. package/dist/gir/parse.d.ts.map +1 -1
  102. package/dist/gir/parse.js +6 -3
  103. package/dist/gir/parse.js.map +1 -1
  104. package/dist/gir/primitives.d.ts +1 -0
  105. package/dist/gir/primitives.d.ts.map +1 -1
  106. package/dist/gir/primitives.js.map +1 -1
  107. package/dist/gir/property.d.ts +16 -0
  108. package/dist/gir/property.d.ts.map +1 -1
  109. package/dist/gir/property.js +3 -3
  110. package/dist/gir/property.js.map +1 -1
  111. package/dist/gir/record.d.ts +22 -0
  112. package/dist/gir/record.d.ts.map +1 -1
  113. package/dist/gir/record.js +3 -2
  114. package/dist/gir/record.js.map +1 -1
  115. package/dist/gir/size.d.ts +5 -4
  116. package/dist/gir/size.d.ts.map +1 -1
  117. package/dist/gir/size.js.map +1 -1
  118. package/dist/gir/type-id.d.ts +35 -0
  119. package/dist/gir/type-id.d.ts.map +1 -1
  120. package/dist/gir/type-id.js +1 -0
  121. package/dist/gir/type-id.js.map +1 -1
  122. package/dist/gir/type-ref.d.ts.map +1 -1
  123. package/dist/gir/type-ref.js +1 -0
  124. package/dist/gir/type-ref.js.map +1 -1
  125. package/dist/gir/type.d.ts +20 -0
  126. package/dist/gir/type.d.ts.map +1 -1
  127. package/dist/gir/type.js.map +1 -1
  128. package/dist/khronos/args.d.ts +7 -6
  129. package/dist/khronos/args.d.ts.map +1 -1
  130. package/dist/khronos/args.js +28 -6
  131. package/dist/khronos/args.js.map +1 -1
  132. package/dist/khronos/doc-context.d.ts +29 -0
  133. package/dist/khronos/doc-context.d.ts.map +1 -0
  134. package/dist/khronos/doc-context.js +29 -0
  135. package/dist/khronos/doc-context.js.map +1 -0
  136. package/dist/khronos/extensions.d.ts +13 -0
  137. package/dist/khronos/extensions.d.ts.map +1 -0
  138. package/dist/khronos/extensions.js +49 -0
  139. package/dist/khronos/extensions.js.map +1 -0
  140. package/dist/khronos/jsdoc.d.ts +17 -11
  141. package/dist/khronos/jsdoc.d.ts.map +1 -1
  142. package/dist/khronos/jsdoc.js +104 -46
  143. package/dist/khronos/jsdoc.js.map +1 -1
  144. package/dist/khronos/model.d.ts +42 -3
  145. package/dist/khronos/model.d.ts.map +1 -1
  146. package/dist/khronos/model.js +218 -63
  147. package/dist/khronos/model.js.map +1 -1
  148. package/dist/khronos/modules.d.ts +9 -6
  149. package/dist/khronos/modules.d.ts.map +1 -1
  150. package/dist/khronos/modules.js +96 -26
  151. package/dist/khronos/modules.js.map +1 -1
  152. package/dist/khronos/notes.d.ts +19 -0
  153. package/dist/khronos/notes.d.ts.map +1 -0
  154. package/dist/khronos/notes.js +35 -0
  155. package/dist/khronos/notes.js.map +1 -0
  156. package/dist/khronos/param-pair.d.ts +1 -1
  157. package/dist/khronos/param-pair.d.ts.map +1 -1
  158. package/dist/khronos/param-pair.js.map +1 -1
  159. package/dist/khronos/pipeline.d.ts +3 -1
  160. package/dist/khronos/pipeline.d.ts.map +1 -1
  161. package/dist/khronos/pipeline.js +58 -27
  162. package/dist/khronos/pipeline.js.map +1 -1
  163. package/dist/khronos/plan.d.ts +3 -3
  164. package/dist/khronos/plan.d.ts.map +1 -1
  165. package/dist/khronos/plan.js +2 -2
  166. package/dist/khronos/plan.js.map +1 -1
  167. package/dist/khronos/render.d.ts +8 -6
  168. package/dist/khronos/render.d.ts.map +1 -1
  169. package/dist/khronos/render.js +35 -26
  170. package/dist/khronos/render.js.map +1 -1
  171. package/dist/khronos/select.d.ts +21 -4
  172. package/dist/khronos/select.d.ts.map +1 -1
  173. package/dist/khronos/select.js +47 -34
  174. package/dist/khronos/select.js.map +1 -1
  175. package/dist/react/element-config.d.ts +2 -2
  176. package/dist/react/element-config.d.ts.map +1 -1
  177. package/dist/react/element-config.js.map +1 -1
  178. package/dist/runner.d.ts +1 -7
  179. package/dist/runner.d.ts.map +1 -1
  180. package/dist/runner.js.map +1 -1
  181. package/dist/store/compile-store.d.ts +1 -1
  182. package/dist/store/compile-store.d.ts.map +1 -1
  183. package/dist/store/compile-store.js.map +1 -1
  184. package/dist/store/gi/callable-doc.d.ts +11 -0
  185. package/dist/store/gi/callable-doc.d.ts.map +1 -0
  186. package/dist/store/gi/callable-doc.js +62 -0
  187. package/dist/store/gi/callable-doc.js.map +1 -0
  188. package/dist/store/gi/callables.d.ts +3 -1
  189. package/dist/store/gi/callables.d.ts.map +1 -1
  190. package/dist/store/gi/callables.js +12 -12
  191. package/dist/store/gi/callables.js.map +1 -1
  192. package/dist/store/gi/callback.d.ts.map +1 -1
  193. package/dist/store/gi/callback.js +2 -2
  194. package/dist/store/gi/callback.js.map +1 -1
  195. package/dist/store/gi/class.d.ts.map +1 -1
  196. package/dist/store/gi/class.js +5 -3
  197. package/dist/store/gi/class.js.map +1 -1
  198. package/dist/store/gi/closure-invocation.d.ts +4 -0
  199. package/dist/store/gi/closure-invocation.d.ts.map +1 -0
  200. package/dist/store/gi/closure-invocation.js +22 -0
  201. package/dist/store/gi/closure-invocation.js.map +1 -0
  202. package/dist/store/gi/constant.d.ts.map +1 -1
  203. package/dist/store/gi/constant.js +3 -2
  204. package/dist/store/gi/constant.js.map +1 -1
  205. package/dist/store/gi/constructor-props.d.ts.map +1 -1
  206. package/dist/store/gi/constructor-props.js +18 -20
  207. package/dist/store/gi/constructor-props.js.map +1 -1
  208. package/dist/store/gi/doc-spec.d.ts +14 -0
  209. package/dist/store/gi/doc-spec.d.ts.map +1 -0
  210. package/dist/store/gi/doc-spec.js +23 -0
  211. package/dist/store/gi/doc-spec.js.map +1 -0
  212. package/dist/store/gi/enum.d.ts.map +1 -1
  213. package/dist/store/gi/enum.js +29 -16
  214. package/dist/store/gi/enum.js.map +1 -1
  215. package/dist/store/gi/function.d.ts.map +1 -1
  216. package/dist/store/gi/function.js +27 -12
  217. package/dist/store/gi/function.js.map +1 -1
  218. package/dist/store/gi/interface.d.ts.map +1 -1
  219. package/dist/store/gi/interface.js +130 -16
  220. package/dist/store/gi/interface.js.map +1 -1
  221. package/dist/store/gi/item-comparators.d.ts.map +1 -1
  222. package/dist/store/gi/item-comparators.js +3 -5
  223. package/dist/store/gi/item-comparators.js.map +1 -1
  224. package/dist/store/gi/method.d.ts +9 -1
  225. package/dist/store/gi/method.d.ts.map +1 -1
  226. package/dist/store/gi/method.js +69 -26
  227. package/dist/store/gi/method.js.map +1 -1
  228. package/dist/store/gi/param-marshal.d.ts +4 -1
  229. package/dist/store/gi/param-marshal.d.ts.map +1 -1
  230. package/dist/store/gi/param-marshal.js +5 -1
  231. package/dist/store/gi/param-marshal.js.map +1 -1
  232. package/dist/store/gi/pipeline.d.ts.map +1 -1
  233. package/dist/store/gi/pipeline.js +3 -2
  234. package/dist/store/gi/pipeline.js.map +1 -1
  235. package/dist/store/gi/properties.d.ts.map +1 -1
  236. package/dist/store/gi/properties.js +2 -2
  237. package/dist/store/gi/properties.js.map +1 -1
  238. package/dist/store/gi/property-accessor.d.ts +3 -1
  239. package/dist/store/gi/property-accessor.d.ts.map +1 -1
  240. package/dist/store/gi/property-accessor.js +6 -5
  241. package/dist/store/gi/property-accessor.js.map +1 -1
  242. package/dist/store/gi/record-constructor.d.ts.map +1 -1
  243. package/dist/store/gi/record-constructor.js +3 -1
  244. package/dist/store/gi/record-constructor.js.map +1 -1
  245. package/dist/store/gi/record-field-accessor.d.ts +3 -1
  246. package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
  247. package/dist/store/gi/record-field-accessor.js +3 -2
  248. package/dist/store/gi/record-field-accessor.js.map +1 -1
  249. package/dist/store/gi/record-layout.js +1 -1
  250. package/dist/store/gi/record-layout.js.map +1 -1
  251. package/dist/store/gi/record.d.ts.map +1 -1
  252. package/dist/store/gi/record.js +3 -2
  253. package/dist/store/gi/record.js.map +1 -1
  254. package/dist/store/gi/registration.d.ts +1 -1
  255. package/dist/store/gi/registration.js +2 -2
  256. package/dist/store/gi/registration.js.map +1 -1
  257. package/dist/store/gi/runtime-override.d.ts +2 -1
  258. package/dist/store/gi/runtime-override.d.ts.map +1 -1
  259. package/dist/store/gi/runtime-override.js +8 -5
  260. package/dist/store/gi/runtime-override.js.map +1 -1
  261. package/dist/store/gi/signal.d.ts.map +1 -1
  262. package/dist/store/gi/signal.js +14 -15
  263. package/dist/store/gi/signal.js.map +1 -1
  264. package/dist/store/gi/value-marshalable.d.ts +1 -2
  265. package/dist/store/gi/value-marshalable.d.ts.map +1 -1
  266. package/dist/store/gi/value-marshalable.js +1 -1
  267. package/dist/store/gi/value-marshalable.js.map +1 -1
  268. package/dist/store/gi/vtable.d.ts +16 -1
  269. package/dist/store/gi/vtable.d.ts.map +1 -1
  270. package/dist/store/gi/vtable.js +214 -51
  271. package/dist/store/gi/vtable.js.map +1 -1
  272. package/dist/store/jsx/element-components.d.ts +1 -1
  273. package/dist/store/jsx/element-components.d.ts.map +1 -1
  274. package/dist/store/jsx/element-components.js +6 -4
  275. package/dist/store/jsx/element-components.js.map +1 -1
  276. package/dist/store/jsx/element-prop-imports.d.ts +1 -3
  277. package/dist/store/jsx/element-prop-imports.d.ts.map +1 -1
  278. package/dist/store/jsx/element-prop-imports.js.map +1 -1
  279. package/dist/store/jsx/element-prop-types.d.ts +3 -0
  280. package/dist/store/jsx/element-prop-types.d.ts.map +1 -1
  281. package/dist/store/jsx/element-prop-types.js +7 -1
  282. package/dist/store/jsx/element-prop-types.js.map +1 -1
  283. package/dist/store/jsx/intrinsic-elements.d.ts +4 -0
  284. package/dist/store/jsx/intrinsic-elements.d.ts.map +1 -1
  285. package/dist/store/jsx/intrinsic-elements.js.map +1 -1
  286. package/dist/store/jsx/jsx.d.ts.map +1 -1
  287. package/dist/store/jsx/jsx.js +7 -6
  288. package/dist/store/jsx/jsx.js.map +1 -1
  289. package/dist/store/jsx/metadata.js +2 -2
  290. package/dist/store/jsx/metadata.js.map +1 -1
  291. package/dist/store/jsx/pipeline.d.ts +1 -1
  292. package/dist/store/jsx/pipeline.d.ts.map +1 -1
  293. package/dist/store/jsx/pipeline.js.map +1 -1
  294. package/dist/store/jsx/props.d.ts +1 -7
  295. package/dist/store/jsx/props.d.ts.map +1 -1
  296. package/dist/store/jsx/props.js +14 -6
  297. package/dist/store/jsx/props.js.map +1 -1
  298. package/dist/writer/context.d.ts +2 -1
  299. package/dist/writer/context.d.ts.map +1 -1
  300. package/dist/writer/context.js +3 -0
  301. package/dist/writer/context.js.map +1 -1
  302. package/dist/writer/doc-tags.d.ts +21 -0
  303. package/dist/writer/doc-tags.d.ts.map +1 -0
  304. package/dist/writer/doc-tags.js +38 -0
  305. package/dist/writer/doc-tags.js.map +1 -0
  306. package/dist/writer/doc.d.ts +3 -1
  307. package/dist/writer/doc.d.ts.map +1 -1
  308. package/dist/writer/doc.js +19 -6
  309. package/dist/writer/doc.js.map +1 -1
  310. package/dist/writer/gtk-doc.d.ts +1 -1
  311. package/dist/writer/gtk-doc.d.ts.map +1 -1
  312. package/dist/writer/gtk-doc.js +64 -15
  313. package/dist/writer/gtk-doc.js.map +1 -1
  314. package/dist/writer/module.d.ts +8 -2
  315. package/dist/writer/module.d.ts.map +1 -1
  316. package/dist/writer/module.js +13 -1
  317. package/dist/writer/module.js.map +1 -1
  318. package/overrides/gdk/rgba.ts.ejs +26 -0
  319. package/overrides/gobject/object.ts.ejs +48 -3
  320. package/overrides/gobject/value.ts.ejs +7 -0
  321. package/overrides/graphene/structs.ts.ejs +55 -0
  322. package/package.json +4 -4
  323. package/src/analysis/descriptor-render.ts +47 -28
  324. package/src/analysis/descriptor.ts +0 -3
  325. package/src/analysis/inheritance.ts +35 -34
  326. package/src/analysis/nul-terminated-bytes.ts +31 -0
  327. package/src/analysis/param-capability.ts +172 -0
  328. package/src/analysis/param-structure.ts +83 -23
  329. package/src/analysis/type-shape.ts +24 -0
  330. package/src/compile.ts +1 -1
  331. package/src/docs/api-reference.ts +36 -25
  332. package/src/docs/element-page.ts +53 -47
  333. package/src/docs/handwritten-props.ts +230 -0
  334. package/src/docs/pipeline.ts +2 -2
  335. package/src/docs/render.ts +146 -32
  336. package/src/docs/symbol-page.ts +224 -79
  337. package/src/fingerprint.ts +0 -1
  338. package/src/gir/ancestry.ts +15 -1
  339. package/src/gir/annotations.ts +37 -0
  340. package/src/gir/callback.ts +2 -0
  341. package/src/gir/class.ts +42 -4
  342. package/src/gir/enum.ts +30 -10
  343. package/src/gir/field.ts +24 -9
  344. package/src/gir/function.ts +15 -0
  345. package/src/gir/libraries.ts +11 -3
  346. package/src/gir/library.ts +51 -2
  347. package/src/gir/namespace.ts +41 -5
  348. package/src/gir/parameter.ts +47 -3
  349. package/src/gir/parse.ts +8 -2
  350. package/src/gir/primitives.ts +1 -0
  351. package/src/gir/property.ts +18 -3
  352. package/src/gir/record.ts +24 -2
  353. package/src/gir/size.ts +8 -3
  354. package/src/gir/type-id.ts +49 -3
  355. package/src/gir/type-ref.ts +1 -0
  356. package/src/gir/type.ts +50 -6
  357. package/src/khronos/args.ts +36 -13
  358. package/src/khronos/doc-context.ts +62 -0
  359. package/src/khronos/extensions.ts +85 -0
  360. package/src/khronos/jsdoc.ts +152 -56
  361. package/src/khronos/model.ts +314 -69
  362. package/src/khronos/modules.ts +134 -40
  363. package/src/khronos/notes.ts +74 -0
  364. package/src/khronos/param-pair.ts +1 -1
  365. package/src/khronos/pipeline.ts +94 -41
  366. package/src/khronos/plan.ts +4 -5
  367. package/src/khronos/render.ts +62 -50
  368. package/src/khronos/select.ts +91 -50
  369. package/src/react/element-config.ts +2 -2
  370. package/src/runner.ts +1 -8
  371. package/src/store/compile-store.ts +1 -1
  372. package/src/store/gi/callable-doc.ts +102 -0
  373. package/src/store/gi/callables.ts +18 -12
  374. package/src/store/gi/callback.ts +3 -2
  375. package/src/store/gi/class.ts +6 -3
  376. package/src/store/gi/closure-invocation.ts +26 -0
  377. package/src/store/gi/constant.ts +3 -4
  378. package/src/store/gi/constructor-props.ts +19 -23
  379. package/src/store/gi/doc-spec.ts +38 -0
  380. package/src/store/gi/enum.ts +55 -20
  381. package/src/store/gi/function.ts +43 -21
  382. package/src/store/gi/interface.ts +214 -26
  383. package/src/store/gi/item-comparators.ts +3 -5
  384. package/src/store/gi/method.ts +98 -42
  385. package/src/store/gi/param-marshal.ts +15 -1
  386. package/src/store/gi/pipeline.ts +7 -2
  387. package/src/store/gi/properties.ts +3 -2
  388. package/src/store/gi/property-accessor.ts +9 -4
  389. package/src/store/gi/record-constructor.ts +6 -1
  390. package/src/store/gi/record-field-accessor.ts +5 -3
  391. package/src/store/gi/record-layout.ts +1 -1
  392. package/src/store/gi/record.ts +8 -2
  393. package/src/store/gi/registration.ts +3 -3
  394. package/src/store/gi/runtime-override.ts +13 -6
  395. package/src/store/gi/signal.ts +19 -20
  396. package/src/store/gi/value-marshalable.ts +1 -1
  397. package/src/store/gi/vtable.ts +361 -60
  398. package/src/store/jsx/element-components.ts +8 -5
  399. package/src/store/jsx/element-prop-imports.ts +1 -3
  400. package/src/store/jsx/element-prop-types.ts +10 -1
  401. package/src/store/jsx/intrinsic-elements.ts +4 -0
  402. package/src/store/jsx/jsx.ts +8 -6
  403. package/src/store/jsx/metadata.ts +2 -2
  404. package/src/store/jsx/pipeline.ts +1 -1
  405. package/src/store/jsx/props.ts +20 -7
  406. package/src/writer/context.ts +5 -1
  407. package/src/writer/doc-tags.ts +70 -0
  408. package/src/writer/doc.ts +29 -6
  409. package/src/writer/gtk-doc.ts +82 -15
  410. package/src/writer/module.ts +25 -2
@@ -1,21 +1,41 @@
1
+ import { type GirAnnotations } from "./annotations.js";
1
2
  import { type RawNode } from "./parse.js";
3
+ /** One member of a {@link GirEnum}. */
2
4
  type EnumMember = {
5
+ /** The member's GIR name, which the emitted key is derived from. */
3
6
  name: string;
7
+ /** Documentation prose from GIR, emitted as the member's JSDoc. */
4
8
  doc: string | undefined;
9
+ /** Release and deprecation annotations GIR carries on the member. */
10
+ annotations: GirAnnotations;
11
+ /** The member's numeric value, `0` when GIR declares none. */
5
12
  value: string;
13
+ /** C constant the member is exposed as, such as `GTK_ORIENTATION_HORIZONTAL`. */
6
14
  cIdentifier: string | undefined;
7
15
  };
16
+ /** Whether an enum is a plain enumeration or a bitfield of flags. */
8
17
  type EnumKind = "enumeration" | "bitfield";
18
+ /** An enumeration or bitfield declared by a GIR namespace. */
9
19
  type GirEnum = {
20
+ /** Whether the declaration is a plain enumeration or a bitfield. */
10
21
  kind: EnumKind;
22
+ /** Name the enum is exported under, without its namespace prefix. */
11
23
  name: string;
24
+ /** Documentation prose from GIR, emitted as the enum's JSDoc. */
12
25
  doc: string | undefined;
26
+ /** Release and deprecation annotations GIR carries on the enum. */
27
+ annotations: GirAnnotations;
28
+ /** GType name of the enum, absent when it is not registered with GLib. */
13
29
  glibTypeName: string | undefined;
30
+ /** C function returning the enum's GType, absent when it is not registered with GLib. */
14
31
  glibGetType: string | undefined;
32
+ /** Quark name of the GError domain the members are codes of, absent on enums that carry no domain. */
15
33
  errorDomain: string | undefined;
34
+ /** Whether the enum is introspectable; code generation skips the ones that are not. */
16
35
  introspectable: boolean;
36
+ /** The enum's members, in declaration order. */
17
37
  members: EnumMember[];
18
38
  };
19
39
  declare const enumFromNode: (node: RawNode, kind: EnumKind) => GirEnum;
20
- export { enumFromNode, type GirEnum };
40
+ export { enumFromNode, type EnumMember, type GirEnum };
21
41
  //# sourceMappingURL=enum.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../src/gir/enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmD,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAE3F,KAAK,UAAU,GAAG;IACd,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC,CAAC;AAEF,KAAK,QAAQ,GAAG,aAAa,GAAG,UAAU,CAAC;AAE3C,KAAK,OAAO,GAAG;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,UAAU,EAAE,CAAC;CACzB,CAAC;AAEF,QAAA,MAAM,YAAY,GAAI,MAAM,OAAO,EAAE,MAAM,QAAQ,KAAG,OAcpD,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../src/gir/enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAiC,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAEzE,uCAAuC;AACvC,KAAK,UAAU,GAAG;IACd,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,qEAAqE;IACrE,WAAW,EAAE,cAAc,CAAC;IAC5B,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC,CAAC;AAEF,qEAAqE;AACrE,KAAK,QAAQ,GAAG,aAAa,GAAG,UAAU,CAAC;AAE3C,8DAA8D;AAC9D,KAAK,OAAO,GAAG;IACX,oEAAoE;IACpE,IAAI,EAAE,QAAQ,CAAC;IACf,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,mEAAmE;IACnE,WAAW,EAAE,cAAc,CAAC;IAC5B,0EAA0E;IAC1E,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,yFAAyF;IACzF,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,sGAAsG;IACtG,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,uFAAuF;IACvF,cAAc,EAAE,OAAO,CAAC;IACxB,gDAAgD;IAChD,OAAO,EAAE,UAAU,EAAE,CAAC;CACzB,CAAC;AAQF,QAAA,MAAM,YAAY,GAAI,MAAM,OAAO,EAAE,MAAM,QAAQ,KAAG,OAQpD,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,CAAC"}
package/dist/gir/enum.js CHANGED
@@ -1,18 +1,18 @@
1
- import { attr, getChildren, getDoc, isAttrTrue, nameAttr } from "./parse.js";
1
+ import { documentedFromNode } from "./annotations.js";
2
+ import { attr, getChildren, isAttrTrue } from "./parse.js";
3
+ const enumMemberFromNode = (node) => ({
4
+ ...documentedFromNode(node),
5
+ value: attr(node, "value") ?? "0",
6
+ cIdentifier: attr(node, "c:identifier"),
7
+ });
2
8
  const enumFromNode = (node, kind) => ({
3
9
  kind,
4
- name: nameAttr(node),
5
- doc: getDoc(node),
10
+ ...documentedFromNode(node),
6
11
  glibTypeName: attr(node, "glib:type-name"),
7
12
  glibGetType: attr(node, "glib:get-type"),
8
13
  errorDomain: attr(node, "glib:error-domain"),
9
14
  introspectable: isAttrTrue(node, "introspectable", true),
10
- members: getChildren(node, "member").map((member) => ({
11
- name: nameAttr(member),
12
- doc: getDoc(member),
13
- value: attr(member, "value") ?? "0",
14
- cIdentifier: attr(member, "c:identifier"),
15
- })),
15
+ members: getChildren(node, "member").map((member) => enumMemberFromNode(member)),
16
16
  });
17
17
  export { enumFromNode };
18
18
  //# sourceMappingURL=enum.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/gir/enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAgB,MAAM,YAAY,CAAC;AAsB3F,MAAM,YAAY,GAAG,CAAC,IAAa,EAAE,IAAc,EAAW,EAAE,CAAC,CAAC;IAC9D,IAAI;IACJ,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC;IACjB,YAAY,EAAE,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAC1C,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC;IACxC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC;IAC5C,cAAc,EAAE,UAAU,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,CAAC;IACxD,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAClD,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC;QACtB,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC;QACnB,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,GAAG;QACnC,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC;KAC5C,CAAC,CAAC;CACN,CAAC,CAAC;AAEH,OAAO,EAAE,YAAY,EAAgB,CAAC","sourcesContent":["import { attr, getChildren, getDoc, isAttrTrue, nameAttr, type RawNode } from \"./parse.js\";\n\ntype EnumMember = {\n name: string;\n doc: string | undefined;\n value: string;\n cIdentifier: string | undefined;\n};\n\ntype EnumKind = \"enumeration\" | \"bitfield\";\n\ntype GirEnum = {\n kind: EnumKind;\n name: string;\n doc: string | undefined;\n glibTypeName: string | undefined;\n glibGetType: string | undefined;\n errorDomain: string | undefined;\n introspectable: boolean;\n members: EnumMember[];\n};\n\nconst enumFromNode = (node: RawNode, kind: EnumKind): GirEnum => ({\n kind,\n name: nameAttr(node),\n doc: getDoc(node),\n glibTypeName: attr(node, \"glib:type-name\"),\n glibGetType: attr(node, \"glib:get-type\"),\n errorDomain: attr(node, \"glib:error-domain\"),\n introspectable: isAttrTrue(node, \"introspectable\", true),\n members: getChildren(node, \"member\").map((member) => ({\n name: nameAttr(member),\n doc: getDoc(member),\n value: attr(member, \"value\") ?? \"0\",\n cIdentifier: attr(member, \"c:identifier\"),\n })),\n});\n\nexport { enumFromNode, type GirEnum };\n"]}
1
+ {"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/gir/enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AAyCzE,MAAM,kBAAkB,GAAG,CAAC,IAAa,EAAc,EAAE,CAAC,CAAC;IACvD,GAAG,kBAAkB,CAAC,IAAI,CAAC;IAC3B,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,GAAG;IACjC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC;CAC1C,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,CAAC,IAAa,EAAE,IAAc,EAAW,EAAE,CAAC,CAAC;IAC9D,IAAI;IACJ,GAAG,kBAAkB,CAAC,IAAI,CAAC;IAC3B,YAAY,EAAE,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAC1C,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC;IACxC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC;IAC5C,cAAc,EAAE,UAAU,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,CAAC;IACxD,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;CACnF,CAAC,CAAC;AAEH,OAAO,EAAE,YAAY,EAAiC,CAAC","sourcesContent":["import { documentedFromNode, type GirAnnotations } from \"./annotations.js\";\nimport { attr, getChildren, isAttrTrue, type RawNode } from \"./parse.js\";\n\n/** One member of a {@link GirEnum}. */\ntype EnumMember = {\n /** The member's GIR name, which the emitted key is derived from. */\n name: string;\n /** Documentation prose from GIR, emitted as the member's JSDoc. */\n doc: string | undefined;\n /** Release and deprecation annotations GIR carries on the member. */\n annotations: GirAnnotations;\n /** The member's numeric value, `0` when GIR declares none. */\n value: string;\n /** C constant the member is exposed as, such as `GTK_ORIENTATION_HORIZONTAL`. */\n cIdentifier: string | undefined;\n};\n\n/** Whether an enum is a plain enumeration or a bitfield of flags. */\ntype EnumKind = \"enumeration\" | \"bitfield\";\n\n/** An enumeration or bitfield declared by a GIR namespace. */\ntype GirEnum = {\n /** Whether the declaration is a plain enumeration or a bitfield. */\n kind: EnumKind;\n /** Name the enum is exported under, without its namespace prefix. */\n name: string;\n /** Documentation prose from GIR, emitted as the enum's JSDoc. */\n doc: string | undefined;\n /** Release and deprecation annotations GIR carries on the enum. */\n annotations: GirAnnotations;\n /** GType name of the enum, absent when it is not registered with GLib. */\n glibTypeName: string | undefined;\n /** C function returning the enum's GType, absent when it is not registered with GLib. */\n glibGetType: string | undefined;\n /** Quark name of the GError domain the members are codes of, absent on enums that carry no domain. */\n errorDomain: string | undefined;\n /** Whether the enum is introspectable; code generation skips the ones that are not. */\n introspectable: boolean;\n /** The enum's members, in declaration order. */\n members: EnumMember[];\n};\n\nconst enumMemberFromNode = (node: RawNode): EnumMember => ({\n ...documentedFromNode(node),\n value: attr(node, \"value\") ?? \"0\",\n cIdentifier: attr(node, \"c:identifier\"),\n});\n\nconst enumFromNode = (node: RawNode, kind: EnumKind): GirEnum => ({\n kind,\n ...documentedFromNode(node),\n glibTypeName: attr(node, \"glib:type-name\"),\n glibGetType: attr(node, \"glib:get-type\"),\n errorDomain: attr(node, \"glib:error-domain\"),\n introspectable: isAttrTrue(node, \"introspectable\", true),\n members: getChildren(node, \"member\").map((member) => enumMemberFromNode(member)),\n});\n\nexport { enumFromNode, type EnumMember, type GirEnum };\n"]}
@@ -1,18 +1,34 @@
1
1
  import type { ParseContext, TypeId } from "./type-id.js";
2
+ import { type GirAnnotations } from "./annotations.js";
2
3
  import { type RawNode } from "./parse.js";
4
+ /**
5
+ * One slot in a record or union layout: a named field, or a nested struct or union
6
+ * whose own members are laid out inline.
7
+ */
3
8
  type GirField = {
9
+ /** Field name as GIR spells it. */
4
10
  name: string;
11
+ /** Documentation prose from GIR, emitted as the field accessor's JSDoc. */
5
12
  doc: string | undefined;
13
+ /** Release and deprecation annotations GIR carries on the field. */
14
+ annotations: GirAnnotations;
15
+ /** The field's value type, absent for a nested struct or union and for one GIR leaves undeclared. */
6
16
  type: TypeId | undefined;
17
+ /** The C type spelled on the field, which decides whether it is read through a pointer. */
7
18
  cType: string | undefined;
19
+ /** Whether the field can be read; one that is neither readable nor writable gets no accessor at all. */
8
20
  readable: boolean;
21
+ /** Whether the field can be written, which is what earns it a setter alongside its getter. */
9
22
  writable: boolean;
23
+ /** Whether the field is private to the library, as every nested struct or union is. */
10
24
  private: boolean;
25
+ /** Width in bits when the field is a C bitfield member. */
11
26
  bits: number | undefined;
27
+ /** Members of a nested struct or union, absent for a named field. */
12
28
  inlineMembers: GirField[] | undefined;
13
- inlineIsUnion: boolean;
29
+ /** Whether {@link GirField.inlineMembers} overlap as a union rather than following one another as a struct. */
30
+ isInlineUnion: boolean;
14
31
  };
15
- declare const fieldFromNode: (node: RawNode, context: ParseContext) => GirField;
16
32
  declare const collectFields: (node: RawNode, context: ParseContext) => GirField[];
17
- export { collectFields, fieldFromNode, type GirField };
33
+ export { collectFields, type GirField };
18
34
  //# sourceMappingURL=field.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/gir/field.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAsE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAG9G,KAAK,QAAQ,GAAG;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,aAAa,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;IACtC,aAAa,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,QAAA,MAAM,aAAa,GAAI,MAAM,OAAO,EAAE,SAAS,YAAY,KAAG,QAW5D,CAAC;AAeH,QAAA,MAAM,aAAa,GAAI,MAAM,OAAO,EAAE,SAAS,YAAY,KAAG,QAAQ,EAIrE,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/gir/field.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAoD,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5F;;;GAGG;AACH,KAAK,QAAQ,GAAG;IACZ,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,oEAAoE;IACpE,WAAW,EAAE,cAAc,CAAC;IAC5B,qGAAqG;IACrG,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,2FAA2F;IAC3F,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,wGAAwG;IACxG,QAAQ,EAAE,OAAO,CAAC;IAClB,8FAA8F;IAC9F,QAAQ,EAAE,OAAO,CAAC;IAClB,uFAAuF;IACvF,OAAO,EAAE,OAAO,CAAC;IACjB,2DAA2D;IAC3D,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,qEAAqE;IACrE,aAAa,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;IACtC,+GAA+G;IAC/G,aAAa,EAAE,OAAO,CAAC;CAC1B,CAAC;AA0BF,QAAA,MAAM,aAAa,GAAI,MAAM,OAAO,EAAE,SAAS,YAAY,KAAG,QAAQ,EAIrE,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,KAAK,QAAQ,EAAE,CAAC"}
package/dist/gir/field.js CHANGED
@@ -1,8 +1,8 @@
1
- import { attr, getChild, getChildren, getDoc, intAttr, isAttrTrue, nameAttr } from "./parse.js";
1
+ import { documentedFromNode } from "./annotations.js";
2
+ import { attr, getChild, getChildren, intAttr, isAttrTrue } from "./parse.js";
2
3
  import { typeRefFromNode } from "./type-ref.js";
3
4
  const fieldFromNode = (node, context) => ({
4
- name: nameAttr(node),
5
- doc: getDoc(node),
5
+ ...documentedFromNode(node),
6
6
  type: typeRefFromNode(node, context),
7
7
  cType: attr(getChild(node, "type"), "c:type"),
8
8
  readable: isAttrTrue(node, "readable", true),
@@ -10,11 +10,10 @@ const fieldFromNode = (node, context) => ({
10
10
  private: isAttrTrue(node, "private", false),
11
11
  bits: intAttr(node, "bits"),
12
12
  inlineMembers: undefined,
13
- inlineIsUnion: false,
13
+ isInlineUnion: false,
14
14
  });
15
15
  const anonymousMemberFromNode = (node, isUnion, context) => ({
16
- name: nameAttr(node),
17
- doc: getDoc(node),
16
+ ...documentedFromNode(node),
18
17
  type: undefined,
19
18
  cType: undefined,
20
19
  readable: false,
@@ -22,12 +21,12 @@ const anonymousMemberFromNode = (node, isUnion, context) => ({
22
21
  private: true,
23
22
  bits: undefined,
24
23
  inlineMembers: collectFields(node, context),
25
- inlineIsUnion: isUnion,
24
+ isInlineUnion: isUnion,
26
25
  });
27
26
  const collectFields = (node, context) => [
28
27
  ...getChildren(node, "field").map((field) => fieldFromNode(field, context)),
29
28
  ...getChildren(node, "union").map((member) => anonymousMemberFromNode(member, true, context)),
30
29
  ...getChildren(node, "record").map((member) => anonymousMemberFromNode(member, false, context)),
31
30
  ];
32
- export { collectFields, fieldFromNode };
31
+ export { collectFields };
33
32
  //# sourceMappingURL=field.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"field.js","sourceRoot":"","sources":["../../src/gir/field.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAgB,MAAM,YAAY,CAAC;AAC9G,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAehD,MAAM,aAAa,GAAG,CAAC,IAAa,EAAE,OAAqB,EAAY,EAAE,CAAC,CAAC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G,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,uBAAuB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7F,GAAG,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,uBAAuB,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;CAClG,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAiB,CAAC","sourcesContent":["import type { ParseContext, TypeId } from \"./type-id.js\";\nimport { attr, getChild, getChildren, getDoc, intAttr, isAttrTrue, nameAttr, type RawNode } from \"./parse.js\";\nimport { typeRefFromNode } from \"./type-ref.js\";\n\ntype GirField = {\n name: string;\n doc: string | undefined;\n type: TypeId | undefined;\n cType: string | undefined;\n readable: boolean;\n writable: boolean;\n private: boolean;\n bits: number | undefined;\n inlineMembers: GirField[] | undefined;\n inlineIsUnion: boolean;\n};\n\nconst fieldFromNode = (node: RawNode, context: ParseContext): GirField => ({\n name: nameAttr(node),\n doc: getDoc(node),\n type: typeRefFromNode(node, context),\n cType: attr(getChild(node, \"type\"), \"c:type\"),\n readable: isAttrTrue(node, \"readable\", true),\n writable: isAttrTrue(node, \"writable\", false),\n private: isAttrTrue(node, \"private\", false),\n bits: intAttr(node, \"bits\"),\n inlineMembers: undefined,\n inlineIsUnion: false,\n});\n\nconst anonymousMemberFromNode = (node: RawNode, isUnion: boolean, context: ParseContext): GirField => ({\n name: nameAttr(node),\n doc: getDoc(node),\n type: undefined,\n cType: undefined,\n readable: false,\n writable: false,\n private: true,\n bits: undefined,\n inlineMembers: collectFields(node, context),\n inlineIsUnion: isUnion,\n});\n\nconst collectFields = (node: RawNode, context: ParseContext): GirField[] => [\n ...getChildren(node, \"field\").map((field) => fieldFromNode(field, context)),\n ...getChildren(node, \"union\").map((member) => anonymousMemberFromNode(member, true, context)),\n ...getChildren(node, \"record\").map((member) => anonymousMemberFromNode(member, false, context)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AAE,OAAO;CACzB,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,CAAC,IAAa,EAAE,OAAqB,EAAc,EAAE,CAAC;IACxE,GAAG,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3E,GAAG,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,uBAAuB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7F,GAAG,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,uBAAuB,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;CAClG,CAAC;AAEF,OAAO,EAAE,aAAa,EAAiB,CAAC","sourcesContent":["import type { ParseContext, TypeId } from \"./type-id.js\";\nimport { documentedFromNode, type GirAnnotations } from \"./annotations.js\";\nimport { attr, getChild, getChildren, intAttr, isAttrTrue, type RawNode } from \"./parse.js\";\nimport { typeRefFromNode } from \"./type-ref.js\";\n\n/**\n * One slot in a record or union layout: a named field, or a nested struct or union\n * whose own members are laid out inline.\n */\ntype GirField = {\n /** Field name as GIR spells it. */\n name: string;\n /** Documentation prose from GIR, emitted as the field accessor's JSDoc. */\n doc: string | undefined;\n /** Release and deprecation annotations GIR carries on the field. */\n annotations: GirAnnotations;\n /** The field's value type, absent for a nested struct or union and for one GIR leaves undeclared. */\n type: TypeId | undefined;\n /** The C type spelled on the field, which decides whether it is read through a pointer. */\n cType: string | undefined;\n /** Whether the field can be read; one that is neither readable nor writable gets no accessor at all. */\n readable: boolean;\n /** Whether the field can be written, which is what earns it a setter alongside its getter. */\n writable: boolean;\n /** Whether the field is private to the library, as every nested struct or union is. */\n private: boolean;\n /** Width in bits when the field is a C bitfield member. */\n bits: number | undefined;\n /** Members of a nested struct or union, absent for a named field. */\n inlineMembers: GirField[] | undefined;\n /** Whether {@link GirField.inlineMembers} overlap as a union rather than following one another as a struct. */\n isInlineUnion: boolean;\n};\n\nconst fieldFromNode = (node: RawNode, context: ParseContext): GirField => ({\n ...documentedFromNode(node),\n type: typeRefFromNode(node, context),\n cType: attr(getChild(node, \"type\"), \"c:type\"),\n readable: isAttrTrue(node, \"readable\", true),\n writable: isAttrTrue(node, \"writable\", false),\n private: isAttrTrue(node, \"private\", false),\n bits: intAttr(node, \"bits\"),\n inlineMembers: undefined,\n isInlineUnion: false,\n});\n\nconst anonymousMemberFromNode = (node: RawNode, isUnion: boolean, context: ParseContext): GirField => ({\n ...documentedFromNode(node),\n type: undefined,\n cType: undefined,\n readable: false,\n writable: false,\n private: true,\n bits: undefined,\n inlineMembers: collectFields(node, context),\n isInlineUnion: isUnion,\n});\n\nconst collectFields = (node: RawNode, context: ParseContext): GirField[] => [\n ...getChildren(node, \"field\").map((field) => fieldFromNode(field, context)),\n ...getChildren(node, \"union\").map((member) => anonymousMemberFromNode(member, true, context)),\n ...getChildren(node, \"record\").map((member) => anonymousMemberFromNode(member, false, context)),\n];\n\nexport { collectFields, type GirField };\n"]}
@@ -1,17 +1,32 @@
1
+ import type { GirAnnotations } from "./annotations.js";
1
2
  import type { ParseContext } from "./type-id.js";
2
3
  import { type GirParameter, type GirReturnValue } from "./parameter.js";
3
4
  import { type RawNode } from "./parse.js";
5
+ /** A callable declared by a GIR namespace, class, or record: a function, a method, or a constructor. */
4
6
  type GirFunction = {
7
+ /** Local name within its owner, taken from the `shadows` annotation when the callable has one. */
5
8
  name: string;
9
+ /** Documentation text carried by the GIR node. */
6
10
  doc: string | undefined;
11
+ /** Release and deprecation annotations GIR carries on the callable. */
12
+ annotations: GirAnnotations;
13
+ /** C symbol the callable is invoked through. */
7
14
  cIdentifier: string | undefined;
15
+ /** Whether the C function takes a trailing `GError` out parameter and can fail. */
8
16
  throws: boolean;
17
+ /** Whether the GIR marks the callable as introspectable, and so bindable. */
9
18
  introspectable: boolean;
19
+ /** Qualified `Type.member` the GIR redirects the callable to, from its `moved-to` annotation. */
10
20
  movedTo: string | undefined;
21
+ /** Name of the callable that shadows this one, from the GIR's `shadowed-by` annotation. */
11
22
  shadowedBy: string | undefined;
23
+ /** Name of the callable that completes this asynchronous one, from the GIR's `glib:finish-func`. */
12
24
  finishFunc: string | undefined;
25
+ /** The instance the callable is invoked on, absent for constructors and namespace-level functions. */
13
26
  instance: GirParameter | undefined;
27
+ /** Parameters other than the instance one, in declaration order. */
14
28
  parameters: GirParameter[];
29
+ /** What the callable returns, with its transfer and nullability. */
15
30
  returnValue: GirReturnValue;
16
31
  };
17
32
  declare const functionFromNode: (node: RawNode, context: ParseContext) => GirFunction;
@@ -1 +1 @@
1
- {"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../src/gir/function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAoC,MAAM,gBAAgB,CAAC;AAC1G,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1D,KAAK,WAAW,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;IACnC,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,WAAW,EAAE,cAAc,CAAC;CAC/B,CAAC;AAoBF,QAAA,MAAM,gBAAgB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MAAM,CAAC,IAAI,EAAE;QACvD,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC;QACvC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC;QAC/B,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC;QACrC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,kBAAkB,CAAC;QAC1C,QAAQ,EAAE,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,YAAY,EAAE,OAAO,CAAC;KAC9F,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAoB,CAAC","sourcesContent":["import type { ParseContext } from \"./type-id.js\";\nimport { PARAMETERS_MISSING_NULLABLE_ANNOTATION } from \"./nullable-overrides.js\";\nimport { type GirParameter, type GirReturnValue, parameterFromNode, parseCallable } from \"./parameter.js\";\nimport { attr, getChild, type RawNode } from \"./parse.js\";\n\ntype GirFunction = {\n name: string;\n doc: string | undefined;\n cIdentifier: string | undefined;\n throws: boolean;\n introspectable: boolean;\n movedTo: string | undefined;\n shadowedBy: string | undefined;\n finishFunc: string | undefined;\n instance: GirParameter | undefined;\n parameters: GirParameter[];\n returnValue: GirReturnValue;\n};\n\nconst relaxParameters = (parameters: GirParameter[], names: string[]): void => {\n for (const parameter of parameters) {\n if (names.includes(parameter.name)) {\n parameter.nullable = true;\n }\n }\n};\n\nconst relaxMissingNullable = (fn: GirFunction): GirFunction => {\n const names = fn.cIdentifier === undefined ? undefined : PARAMETERS_MISSING_NULLABLE_ANNOTATION.get(fn.cIdentifier);\n\n if (names !== undefined) {\n relaxParameters(fn.parameters, names);\n }\n\n return fn;\n};\n\nconst functionFromNode = (node: RawNode, context: ParseContext): GirFunction => {\n const instanceNode = getChild(getChild(node, \"parameters\"), \"instance-parameter\");\n\n return relaxMissingNullable({\n ...parseCallable(node, context),\n name: attr(node, \"shadows\") ?? attr(node, \"name\") ?? \"\",\n cIdentifier: attr(node, \"c:identifier\"),\n movedTo: attr(node, \"moved-to\"),\n shadowedBy: attr(node, \"shadowed-by\"),\n finishFunc: attr(node, \"glib:finish-func\"),\n instance: instanceNode === undefined ? undefined : parameterFromNode(instanceNode, context),\n });\n};\n\nexport { functionFromNode, type GirFunction };\n"]}
1
+ {"version":3,"file":"function.js","sourceRoot":"","sources":["../../src/gir/function.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sCAAsC,EAAE,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAA0C,iBAAiB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC1G,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAgB,MAAM,YAAY,CAAC;AA8B1D,MAAM,eAAe,GAAG,CAAC,UAA0B,EAAE,KAAe,EAAQ,EAAE;IAC1E,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACjC,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC;QAC9B,CAAC;IACL,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,EAAe,EAAe,EAAE;IAC1D,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,sCAAsC,CAAC,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IAEpH,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,eAAe,CAAC,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,EAAE,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,IAAa,EAAE,OAAqB,EAAe,EAAE;IAC3E,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,oBAAoB,CAAC,CAAC;IAElF,OAAO,oBAAoB,CAAC;QACxB,GAAG,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC;QAC/B,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;QACvD,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC;QACvC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC;QAC/B,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC;QACrC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,kBAAkB,CAAC;QAC1C,QAAQ,EAAE,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,YAAY,EAAE,OAAO,CAAC;KAC9F,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAoB,CAAC","sourcesContent":["import type { GirAnnotations } from \"./annotations.js\";\nimport type { ParseContext } from \"./type-id.js\";\nimport { PARAMETERS_MISSING_NULLABLE_ANNOTATION } from \"./nullable-overrides.js\";\nimport { type GirParameter, type GirReturnValue, parameterFromNode, parseCallable } from \"./parameter.js\";\nimport { attr, getChild, type RawNode } from \"./parse.js\";\n\n/** A callable declared by a GIR namespace, class, or record: a function, a method, or a constructor. */\ntype GirFunction = {\n /** Local name within its owner, taken from the `shadows` annotation when the callable has one. */\n name: string;\n /** Documentation text carried by the GIR node. */\n doc: string | undefined;\n /** Release and deprecation annotations GIR carries on the callable. */\n annotations: GirAnnotations;\n /** C symbol the callable is invoked through. */\n cIdentifier: string | undefined;\n /** Whether the C function takes a trailing `GError` out parameter and can fail. */\n throws: boolean;\n /** Whether the GIR marks the callable as introspectable, and so bindable. */\n introspectable: boolean;\n /** Qualified `Type.member` the GIR redirects the callable to, from its `moved-to` annotation. */\n movedTo: string | undefined;\n /** Name of the callable that shadows this one, from the GIR's `shadowed-by` annotation. */\n shadowedBy: string | undefined;\n /** Name of the callable that completes this asynchronous one, from the GIR's `glib:finish-func`. */\n finishFunc: string | undefined;\n /** The instance the callable is invoked on, absent for constructors and namespace-level functions. */\n instance: GirParameter | undefined;\n /** Parameters other than the instance one, in declaration order. */\n parameters: GirParameter[];\n /** What the callable returns, with its transfer and nullability. */\n returnValue: GirReturnValue;\n};\n\nconst relaxParameters = (parameters: GirParameter[], names: string[]): void => {\n for (const parameter of parameters) {\n if (names.includes(parameter.name)) {\n parameter.nullable = true;\n }\n }\n};\n\nconst relaxMissingNullable = (fn: GirFunction): GirFunction => {\n const names = fn.cIdentifier === undefined ? undefined : PARAMETERS_MISSING_NULLABLE_ANNOTATION.get(fn.cIdentifier);\n\n if (names !== undefined) {\n relaxParameters(fn.parameters, names);\n }\n\n return fn;\n};\n\nconst functionFromNode = (node: RawNode, context: ParseContext): GirFunction => {\n const instanceNode = getChild(getChild(node, \"parameters\"), \"instance-parameter\");\n\n return relaxMissingNullable({\n ...parseCallable(node, context),\n name: attr(node, \"shadows\") ?? attr(node, \"name\") ?? \"\",\n cIdentifier: attr(node, \"c:identifier\"),\n movedTo: attr(node, \"moved-to\"),\n shadowedBy: attr(node, \"shadowed-by\"),\n finishFunc: attr(node, \"glib:finish-func\"),\n instance: instanceNode === undefined ? undefined : parameterFromNode(instanceNode, context),\n });\n};\n\nexport { functionFromNode, type GirFunction };\n"]}
@@ -1,7 +1,5 @@
1
1
  /** A `libraries` config value: an explicit list, `"*"` for everything installed, or absent for the default. */
2
- type LibrarySelection = typeof LIBRARIES_WILDCARD | string[] | undefined;
3
- /** The `libraries` value that stands for every GIR library installed on the search path. */
4
- declare const LIBRARIES_WILDCARD = "*";
2
+ type LibrarySelection = "*" | string[] | undefined;
5
3
  /**
6
4
  * Expands a `libraries` config value into the GIR identifiers to generate from: `"Gtk-4.0"` alone when
7
5
  * nothing is configured, everything installed for `"*"`, and otherwise the given list with `"Gtk-4.0"`
@@ -1 +1 @@
1
- {"version":3,"file":"libraries.d.ts","sourceRoot":"","sources":["../../src/gir/libraries.ts"],"names":[],"mappings":"AAIA,+GAA+G;AAC/G,KAAK,gBAAgB,GAAG,OAAO,kBAAkB,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;AAEzE,4FAA4F;AAC5F,QAAA,MAAM,kBAAkB,MAAM,CAAC;AAK/B;;;;;;GAMG;AACH,QAAA,MAAM,gBAAgB,GAAI,WAAW,gBAAgB,EAAE,SAAS,MAAM,EAAE,KAAG,MAAM,EAqBhF,CAAC;AA4CF;;;GAGG;AACH,QAAA,MAAM,qBAAqB,GAAI,SAAS,MAAM,EAAE,KAAG,MAAM,EAQxD,CAAC;AAkBF,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,KAAK,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"libraries.d.ts","sourceRoot":"","sources":["../../src/gir/libraries.ts"],"names":[],"mappings":"AAaA,+GAA+G;AAC/G,KAAK,gBAAgB,GAAG,GAAG,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;AAOnD;;;;;;GAMG;AACH,QAAA,MAAM,gBAAgB,GAAI,WAAW,gBAAgB,EAAE,SAAS,MAAM,EAAE,KAAG,MAAM,EAqBhF,CAAC;AA4CF;;;GAGG;AACH,QAAA,MAAM,qBAAqB,GAAI,SAAS,MAAM,EAAE,KAAG,MAAM,EAQxD,CAAC;AAkBF,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,KAAK,gBAAgB,EAAE,CAAC"}
@@ -1,6 +1,5 @@
1
1
  import { sortStrings } from "@gtkx/utils";
2
2
  import { readdirSync } from "node:fs";
3
- /** The `libraries` value that stands for every GIR library installed on the search path. */
4
3
  const LIBRARIES_WILDCARD = "*";
5
4
  const GIR_LIBRARY_PATTERN = /^[A-Za-z][A-Za-z0-9]*-\d+(?:\.\d+)*$/;
6
5
  const DEFAULT_LIBRARIES = ["Gtk-4.0"];
@@ -1 +1 @@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OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAyB,CAAC","sourcesContent":["import { sortStrings } from \"@gtkx/utils\";\nimport { readdirSync } from \"node:fs\";\n\ntype GirNamespace = { name: string; version: string; identifier: string };\n/** A `libraries` config value: an explicit list, `\"*\"` for everything installed, or absent for the default. */\ntype LibrarySelection = typeof LIBRARIES_WILDCARD | string[] | undefined;\n\n/** The `libraries` value that stands for every GIR library installed on the search path. */\nconst LIBRARIES_WILDCARD = \"*\";\nconst GIR_LIBRARY_PATTERN = /^[A-Za-z][A-Za-z0-9]*-\\d+(?:\\.\\d+)*$/;\nconst DEFAULT_LIBRARIES: string[] = [\"Gtk-4.0\"];\nconst GIR_FILE_SUFFIX = \".gir\";\n\n/**\n * Expands a `libraries` config value into the GIR identifiers to generate from: `\"Gtk-4.0\"` alone when\n * nothing is configured, everything installed for `\"*\"`, and otherwise the given list with `\"Gtk-4.0\"`\n * prepended unless it already names a Gtk version.\n *\n * @throws If `\"*\"` matched no `.gir` file anywhere on the GIR path.\n */\nconst resolveLibraries = (libraries: LibrarySelection, girPath: string[]): string[] => {\n if (libraries === undefined) {\n return [...DEFAULT_LIBRARIES];\n }\n\n if (libraries === LIBRARIES_WILDCARD) {\n const discovered = discoverGirNamespaces(girPath);\n\n if (discovered.length === 0) {\n throw new Error(\n `gtkx.config.ts: \\`libraries: \"*\"\\` matched no .gir files in [${girPath.join(\", \")}]. ` +\n \"Install gobject-introspection data packages, or list the libraries explicitly.\",\n );\n }\n\n return discovered;\n }\n\n const hasGtk = libraries.some((library) => library.startsWith(\"Gtk-\"));\n\n return [...new Set([...(hasGtk ? [] : DEFAULT_LIBRARIES), ...libraries])];\n};\n\nconst readDirEntries = (dir: string): string[] => {\n try {\n return readdirSync(dir);\n } catch {\n return [];\n }\n};\n\nconst parseGirNamespace = (entry: string): GirNamespace | undefined => {\n if (!entry.endsWith(GIR_FILE_SUFFIX)) {\n return undefined;\n }\n\n const identifier = entry.slice(0, -GIR_FILE_SUFFIX.length);\n\n if (!GIR_LIBRARY_PATTERN.test(identifier)) {\n return undefined;\n }\n\n const separator = identifier.indexOf(\"-\");\n\n return { name: identifier.slice(0, separator), version: identifier.slice(separator + 1), identifier };\n};\n\nconst recordHighest = (highestByName: Map<string, GirNamespace>, parsed: GirNamespace): void => {\n const existing = highestByName.get(parsed.name);\n\n if (existing === undefined || compareVersions(parsed.version, existing.version) > 0) {\n highestByName.set(parsed.name, parsed);\n }\n};\n\nconst collectDirNamespaces = (highestByName: Map<string, GirNamespace>, dir: string): void => {\n for (const entry of readDirEntries(dir)) {\n const parsed = parseGirNamespace(entry);\n\n if (parsed !== undefined) {\n recordHighest(highestByName, parsed);\n }\n }\n};\n\n/**\n * Every GIR library installed on the search path, as sorted `Name-Version` identifiers. A namespace found\n * in more than one version contributes only its highest, and unreadable directories are skipped.\n */\nconst discoverGirNamespaces = (girPath: string[]): string[] => {\n const highestByName: Map<string, GirNamespace> = new Map();\n\n for (const dir of girPath) {\n collectDirNamespaces(highestByName, dir);\n }\n\n return sortStrings(highestByName.values().map(({ identifier }) => identifier));\n};\n\nconst compareVersions = (a: string, b: string): number => {\n const aParts = a.split(\".\");\n const bParts = b.split(\".\");\n const length = Math.max(aParts.length, bParts.length);\n\n for (let index = 0; index < length; index += 1) {\n const difference = Number(aParts[index] ?? 0) - Number(bParts[index] ?? 0);\n\n if (difference !== 0) {\n return difference;\n }\n }\n\n return 0;\n};\n\nexport { resolveLibraries, discoverGirNamespaces, type LibrarySelection };\n"]}
1
+ {"version":3,"file":"libraries.js","sourceRoot":"","sources":["../../src/gir/libraries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAetC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,mBAAmB,GAAG,sCAAsC,CAAC;AACnE,MAAM,iBAAiB,GAAa,CAAC,SAAS,CAAC,CAAC;AAChD,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I,OAAO,EAAE,CAAC;QACxB,oBAAoB,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,WAAW,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;AACnF,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE;IACrD,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAEtD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC7C,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAE3E,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;YACnB,OAAO,UAAU,CAAC;QACtB,CAAC;IACL,CAAC;IAED,OAAO,CAAC,CAAC;AACb,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAyB,CAAC","sourcesContent":["import { sortStrings } from \"@gtkx/utils\";\nimport { readdirSync } from \"node:fs\";\n\n/** A namespace found on the GIR path, taken from the name of its `.gir` file. */\ntype GirNamespace = {\n /** Namespace the file describes, such as `Gtk`. */\n name: string;\n /** API version the file describes, such as `4.0`. */\n version: string;\n /** Name and version joined the way a `libraries` entry spells them, such as `Gtk-4.0`. */\n identifier: string;\n};\n\n/** A `libraries` config value: an explicit list, `\"*\"` for everything installed, or absent for the default. */\ntype LibrarySelection = \"*\" | string[] | undefined;\n\nconst LIBRARIES_WILDCARD = \"*\";\nconst GIR_LIBRARY_PATTERN = /^[A-Za-z][A-Za-z0-9]*-\\d+(?:\\.\\d+)*$/;\nconst DEFAULT_LIBRARIES: string[] = [\"Gtk-4.0\"];\nconst GIR_FILE_SUFFIX = \".gir\";\n\n/**\n * Expands a `libraries` config value into the GIR identifiers to generate from: `\"Gtk-4.0\"` alone when\n * nothing is configured, everything installed for `\"*\"`, and otherwise the given list with `\"Gtk-4.0\"`\n * prepended unless it already names a Gtk version.\n *\n * @throws If `\"*\"` matched no `.gir` file anywhere on the GIR path.\n */\nconst resolveLibraries = (libraries: LibrarySelection, girPath: string[]): string[] => {\n if (libraries === undefined) {\n return [...DEFAULT_LIBRARIES];\n }\n\n if (libraries === LIBRARIES_WILDCARD) {\n const discovered = discoverGirNamespaces(girPath);\n\n if (discovered.length === 0) {\n throw new Error(\n `gtkx.config.ts: \\`libraries: \"*\"\\` matched no .gir files in [${girPath.join(\", \")}]. ` +\n \"Install gobject-introspection data packages, or list the libraries explicitly.\",\n );\n }\n\n return discovered;\n }\n\n const hasGtk = libraries.some((library) => library.startsWith(\"Gtk-\"));\n\n return [...new Set([...(hasGtk ? [] : DEFAULT_LIBRARIES), ...libraries])];\n};\n\nconst readDirEntries = (dir: string): string[] => {\n try {\n return readdirSync(dir);\n } catch {\n return [];\n }\n};\n\nconst parseGirNamespace = (entry: string): GirNamespace | undefined => {\n if (!entry.endsWith(GIR_FILE_SUFFIX)) {\n return undefined;\n }\n\n const identifier = entry.slice(0, -GIR_FILE_SUFFIX.length);\n\n if (!GIR_LIBRARY_PATTERN.test(identifier)) {\n return undefined;\n }\n\n const separator = identifier.indexOf(\"-\");\n\n return { name: identifier.slice(0, separator), version: identifier.slice(separator + 1), identifier };\n};\n\nconst recordHighest = (highestByName: Map<string, GirNamespace>, parsed: GirNamespace): void => {\n const existing = highestByName.get(parsed.name);\n\n if (existing === undefined || compareVersions(parsed.version, existing.version) > 0) {\n highestByName.set(parsed.name, parsed);\n }\n};\n\nconst collectDirNamespaces = (highestByName: Map<string, GirNamespace>, dir: string): void => {\n for (const entry of readDirEntries(dir)) {\n const parsed = parseGirNamespace(entry);\n\n if (parsed !== undefined) {\n recordHighest(highestByName, parsed);\n }\n }\n};\n\n/**\n * Every GIR library installed on the search path, as sorted `Name-Version` identifiers. A namespace found\n * in more than one version contributes only its highest, and unreadable directories are skipped.\n */\nconst discoverGirNamespaces = (girPath: string[]): string[] => {\n const highestByName: Map<string, GirNamespace> = new Map();\n\n for (const dir of girPath) {\n collectDirNamespaces(highestByName, dir);\n }\n\n return sortStrings(highestByName.values().map(({ identifier }) => identifier));\n};\n\nconst compareVersions = (a: string, b: string): number => {\n const aParts = a.split(\".\");\n const bParts = b.split(\".\");\n const length = Math.max(aParts.length, bParts.length);\n\n for (let index = 0; index < length; index += 1) {\n const difference = Number(aParts[index] ?? 0) - Number(bParts[index] ?? 0);\n\n if (difference !== 0) {\n return difference;\n }\n }\n\n return 0;\n};\n\nexport { resolveLibraries, discoverGirNamespaces, type LibrarySelection };\n"]}
@@ -1,8 +1,19 @@
1
1
  import type { TypeId } from "./type-id.js";
2
2
  import type { GirType } from "./type.js";
3
3
  import { type GirNamespace } from "./namespace.js";
4
+ /**
5
+ * The parsed GIR universe: every requested namespace plus everything those namespaces include,
6
+ * with types resolvable across namespace boundaries.
7
+ */
4
8
  declare class Library {
5
9
  private static drive;
10
+ /**
11
+ * Parses the named GIR libraries along with every namespace they transitively include.
12
+ *
13
+ * @param libraries GIR identifiers to load, such as `Gtk-4.0`.
14
+ * @param girPath Directories searched, in order, for each `.gir` file.
15
+ * @returns A library holding every namespace that was parsed.
16
+ */
6
17
  static load(libraries: string[], girPath: string[]): Library;
7
18
  private namespacesByName;
8
19
  private namespaceById;
@@ -10,6 +21,7 @@ declare class Library {
10
21
  private nsIdByName;
11
22
  private typeTables;
12
23
  private girFilesValue;
24
+ /** Creates a library with no namespaces loaded; {@link Library.load} builds a populated one. */
13
25
  constructor();
14
26
  private ensureNsId;
15
27
  private registerNamespace;
@@ -30,13 +42,37 @@ declare class Library {
30
42
  private addValueDeclarations;
31
43
  private processIdentifier;
32
44
  private discoverNamespaces;
45
+ /** The loaded namespaces, keyed by their GIR name such as `Gtk`. */
33
46
  get namespaces(): Map<string, GirNamespace>;
47
+ /** Paths of the `.gir` files that were read, in the order they were discovered. */
34
48
  get girFiles(): string[];
49
+ /**
50
+ * Reads the type a {@link TypeId} points at.
51
+ *
52
+ * @param tid The type id to dereference.
53
+ * @returns The parsed type, or `undefined` when nothing has been parsed into that slot.
54
+ */
35
55
  typeFor(tid: TypeId): GirType | undefined;
56
+ /**
57
+ * Reads the name a {@link TypeId} was registered under.
58
+ *
59
+ * @param tid The type id to name.
60
+ * @returns The namespace and type name, or `undefined` for an anonymous type.
61
+ */
36
62
  nameFor(tid: TypeId): {
63
+ /** GIR namespace to qualify the type with, such as `Gtk`. */
37
64
  namespaceName: string;
65
+ /** Unqualified type name as GIR declares it, such as `Widget`. */
38
66
  typeName: string;
39
67
  } | undefined;
68
+ /**
69
+ * Looks up a type by the name a GIR file writes, resolving an unqualified name against the
70
+ * namespace it appears in and a `Namespace.Type` name against the loaded namespaces.
71
+ *
72
+ * @param currentNamespaceName Namespace the name is written in.
73
+ * @param name Type name, optionally qualified with a namespace prefix.
74
+ * @returns The parsed type, or `undefined` when the name is unknown or only a forward reference to it exists.
75
+ */
40
76
  resolveType(currentNamespaceName: string, name: string): GirType | undefined;
41
77
  }
42
78
  export { Library };
@@ -1 +1 @@
1
- {"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../src/gir/library.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAqD,MAAM,EAAE,MAAM,cAAc,CAAC;AAC9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAEH,KAAK,YAAY,EAIpB,MAAM,gBAAgB,CAAC;AAwCxB,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AE,YAAY,CAAC,CAEjD;IAED,mFAAmF;IACnF,IAAW,QAAQ,IAAI,MAAM,EAAE,CAE9B;IAED;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAIzC;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG;QAClB,6DAA6D;QAC7D,aAAa,EAAE,MAAM,CAAC;QACtB,kEAAkE;QAClE,QAAQ,EAAE,MAAM,CAAC;KACpB,GAAG,SAAS;IAWb;;;;;;;OAOG;IACH,WAAW,CAAC,oBAAoB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;CAsB/E;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -24,6 +24,10 @@ const locateGirFile = (identifier, girPath) => {
24
24
  const tried = girPath.map((directory) => join(directory, filename)).join(", ");
25
25
  throw new Error(`GIR file ${filename} not found on girPath. Tried: ${tried}`);
26
26
  };
27
+ /**
28
+ * The parsed GIR universe: every requested namespace plus everything those namespaces include,
29
+ * with types resolvable across namespace boundaries.
30
+ */
27
31
  class Library {
28
32
  static drive(library, libraries, girPath) {
29
33
  const { discovered, girFiles } = library.discoverNamespaces(libraries, girPath);
@@ -35,6 +39,13 @@ class Library {
35
39
  }
36
40
  library.girFilesValue = girFiles;
37
41
  }
42
+ /**
43
+ * Parses the named GIR libraries along with every namespace they transitively include.
44
+ *
45
+ * @param libraries GIR identifiers to load, such as `Gtk-4.0`.
46
+ * @param girPath Directories searched, in order, for each `.gir` file.
47
+ * @returns A library holding every namespace that was parsed.
48
+ */
38
49
  static load(libraries, girPath) {
39
50
  const library = new Library();
40
51
  this.drive(library, libraries, girPath);
@@ -46,6 +57,7 @@ class Library {
46
57
  nsIdByName = new Map();
47
58
  typeTables = [];
48
59
  girFilesValue = [];
60
+ /** Creates a library with no namespaces loaded; {@link Library.load} builds a populated one. */
49
61
  constructor() {
50
62
  this.typeTables[INTERNAL_NS_ID] = { types: [], names: [], index: new Map() };
51
63
  this.namespaceById[INTERNAL_NS_ID] = undefined;
@@ -204,15 +216,29 @@ class Library {
204
216
  }
205
217
  return { discovered, girFiles };
206
218
  }
219
+ /** The loaded namespaces, keyed by their GIR name such as `Gtk`. */
207
220
  get namespaces() {
208
221
  return this.namespacesByName;
209
222
  }
223
+ /** Paths of the `.gir` files that were read, in the order they were discovered. */
210
224
  get girFiles() {
211
225
  return this.girFilesValue;
212
226
  }
227
+ /**
228
+ * Reads the type a {@link TypeId} points at.
229
+ *
230
+ * @param tid The type id to dereference.
231
+ * @returns The parsed type, or `undefined` when nothing has been parsed into that slot.
232
+ */
213
233
  typeFor(tid) {
214
234
  return this.typeTables[tid.nsId]?.types[tid.id];
215
235
  }
236
+ /**
237
+ * Reads the name a {@link TypeId} was registered under.
238
+ *
239
+ * @param tid The type id to name.
240
+ * @returns The namespace and type name, or `undefined` for an anonymous type.
241
+ */
216
242
  nameFor(tid) {
217
243
  const typeName = this.typeTables[tid.nsId]?.names[tid.id];
218
244
  const namespaceName = this.nsNameById[tid.nsId];
@@ -221,6 +247,14 @@ class Library {
221
247
  }
222
248
  return { namespaceName, typeName };
223
249
  }
250
+ /**
251
+ * Looks up a type by the name a GIR file writes, resolving an unqualified name against the
252
+ * namespace it appears in and a `Namespace.Type` name against the loaded namespaces.
253
+ *
254
+ * @param currentNamespaceName Namespace the name is written in.
255
+ * @param name Type name, optionally qualified with a namespace prefix.
256
+ * @returns The parsed type, or `undefined` when the name is unknown or only a forward reference to it exists.
257
+ */
224
258
  resolveType(currentNamespaceName, name) {
225
259
  const currentNsId = this.nsIdByName.get(currentNamespaceName);
226
260
  if (currentNsId === undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"library.js","sourceRoot":"","sources":["../../src/gir/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAA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,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAE9D,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,MAAM,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAChE,MAAM,UAAU,GAAG,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAElG,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAE9D,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YACnB,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;CACJ;AAED,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { PrimitiveCategory } from \"./primitives.js\";\nimport type { CArrayType, HashTableType, ListType, ParseContext, TypeId } from \"./type-id.js\";\nimport type { GirType } from \"./type.js\";\nimport { callbackFromNode } from \"./callback.js\";\nimport {\n createNamespaceShell,\n type GirNamespace,\n type NamespaceHeader,\n parseNamespaceHeader,\n populateNamespaceBody,\n} from \"./namespace.js\";\nimport { parseGirFile, type RawNode } from \"./parse.js\";\nimport { splitOptionalNamespace } from \"./type-ref.js\";\n\ntype TypeTable = {\n types: (GirType | undefined)[];\n names: (string | undefined)[];\n index: Map<string, number>;\n};\n\ntype DiscoveredNamespace = { header: NamespaceHeader; shell: GirNamespace };\n\nconst INTERNAL_NS_ID = 0;\n\nconst readRepositoryNode = (path: string): RawNode => {\n const root = parseGirFile(path);\n const repository = root.repository;\n\n if (typeof repository !== \"object\" || repository === null) {\n throw new Error(`GIR file at ${path} has no <repository> root`);\n }\n\n return repository as RawNode;\n};\n\nconst locateGirFile = (identifier: string, girPath: string[]): string => {\n const filename = `${identifier}.gir`;\n\n for (const directory of girPath) {\n const candidate = join(directory, filename);\n\n if (existsSync(candidate)) {\n return candidate;\n }\n }\n\n const tried = girPath.map((directory) => join(directory, filename)).join(\", \");\n throw new Error(`GIR file ${filename} not found on girPath. Tried: ${tried}`);\n};\n\nclass Library {\n private static drive(library: Library, libraries: string[], girPath: string[]): void {\n const { discovered, girFiles } = library.discoverNamespaces(libraries, girPath);\n\n for (const { header, shell } of discovered) {\n populateNamespaceBody(shell, header.namespaceNode, library.parseContext(shell.id));\n }\n\n for (const { shell } of discovered) {\n library.addDeclarations(shell);\n }\n\n library.girFilesValue = girFiles;\n }\n\n static load(libraries: string[], girPath: string[]): Library {\n const library = new Library();\n this.drive(library, libraries, girPath);\n\n return library;\n }\n\n private namespacesByName: Map<string, GirNamespace> = new Map();\n private namespaceById: (GirNamespace | undefined)[] = [];\n private nsNameById: string[] = [];\n private nsIdByName: Map<string, number> = new Map();\n private typeTables: TypeTable[] = [];\n private girFilesValue: string[] = [];\n\n constructor() {\n this.typeTables[INTERNAL_NS_ID] = { types: [], names: [], index: new Map() };\n this.namespaceById[INTERNAL_NS_ID] = undefined;\n this.nsNameById[INTERNAL_NS_ID] = \"$internal\";\n }\n\n private ensureNsId(name: string): number {\n const existing = this.nsIdByName.get(name);\n\n if (existing !== undefined) {\n return existing;\n }\n\n const nsId = this.typeTables.length;\n this.typeTables[nsId] = { types: [], names: [], index: new Map() };\n this.namespaceById[nsId] = undefined;\n this.nsNameById[nsId] = name;\n this.nsIdByName.set(name, nsId);\n\n return nsId;\n }\n\n private registerNamespace(header: NamespaceHeader): GirNamespace {\n const nsId = this.ensureNsId(header.name);\n const shell = createNamespaceShell(header, nsId);\n this.namespaceById[nsId] = shell;\n this.namespacesByName.set(header.name, shell);\n\n return shell;\n }\n\n private namespaceFor(nsId: number): GirNamespace {\n const namespace = this.namespaceById[nsId];\n\n if (namespace === undefined) {\n throw new Error(`No namespace registered for type table id ${String(nsId)}`);\n }\n\n return namespace;\n }\n\n private typeTableFor(nsId: number): TypeTable {\n const typeTable = this.typeTables[nsId];\n\n if (typeTable === undefined) {\n throw new Error(`No type table for namespace id ${String(nsId)}`);\n }\n\n return typeTable;\n }\n\n private insertIntoTypeTable(\n typeTable: TypeTable,\n slot: { type: GirType | undefined; indexKey?: string; displayName?: string },\n ): number {\n const id = typeTable.types.length;\n typeTable.types.push(slot.type);\n typeTable.names.push(slot.displayName);\n\n if (slot.indexKey !== undefined) {\n typeTable.index.set(slot.indexKey, id);\n }\n\n return id;\n }\n\n private resolveTypeId(nsId: number, name: string, type: GirType | undefined): number {\n const typeTable = this.typeTableFor(nsId);\n const existing = typeTable.index.get(name);\n\n if (existing !== undefined) {\n return existing;\n }\n\n return this.insertIntoTypeTable(typeTable, { type, indexKey: name, displayName: name });\n }\n\n private addType(nsId: number, name: string, type: GirType): void {\n this.typeTableFor(nsId).types[this.resolveTypeId(nsId, name, type)] = type;\n }\n\n private findType(nsId: number, name: string): TypeId {\n return { nsId, id: this.resolveTypeId(nsId, name, undefined) };\n }\n\n private addAnonymousType(nsId: number, type: GirType): TypeId {\n const typeTable = this.typeTableFor(nsId);\n const id = this.insertIntoTypeTable(typeTable, { type });\n\n return { nsId, id };\n }\n\n private findTypeByName(currentNsId: number, name: string): TypeId {\n const [namespaceName, localName] = splitOptionalNamespace(name);\n const targetNsId = namespaceName === undefined ? currentNsId : this.ensureNsId(namespaceName);\n\n return this.findType(targetNsId, localName);\n }\n\n private parseContext(nsId: number): ParseContext {\n const context: ParseContext = {\n nsId,\n findType: (name) => this.findTypeByName(nsId, name),\n addPrimitive: (category) => this.addPrimitive(category),\n addVarargs: () => this.addVarargs(),\n addContainer: (type: CArrayType | ListType | HashTableType) => this.addAnonymousType(nsId, type),\n addAnonymousCallback: (node) =>\n this.addAnonymousType(nsId, {\n kind: \"callback\",\n namespace: this.namespaceFor(nsId),\n value: callbackFromNode(node, context),\n }),\n };\n\n return context;\n }\n\n private addPrimitive(category: PrimitiveCategory): TypeId {\n return this.findOrAddContainer(`primitive:${category}`, { kind: \"primitive\", category });\n }\n\n private addVarargs(): TypeId {\n return this.findOrAddContainer(\"varargs\", { kind: \"varargs\" });\n }\n\n private findOrAddContainer(key: string, type: GirType): TypeId {\n const typeTable = this.typeTableFor(INTERNAL_NS_ID);\n const existing = typeTable.index.get(key);\n\n if (existing !== undefined) {\n return { nsId: INTERNAL_NS_ID, id: existing };\n }\n\n const id = this.insertIntoTypeTable(typeTable, { type, indexKey: key });\n\n return { nsId: INTERNAL_NS_ID, id };\n }\n\n private addDeclarations(shell: GirNamespace): void {\n this.addClassDeclarations(shell);\n this.addValueDeclarations(shell);\n }\n\n private addClassDeclarations(shell: GirNamespace): void {\n const nsId = shell.id;\n\n for (const value of shell.classes) {\n this.addType(nsId, value.name, { kind: \"class\", namespace: shell, value });\n }\n\n for (const value of shell.interfaces) {\n this.addType(nsId, value.name, { kind: \"interface\", namespace: shell, value });\n }\n\n for (const value of shell.records) {\n this.addType(nsId, value.name, { kind: \"record\", namespace: shell, value });\n }\n }\n\n private addValueDeclarations(shell: GirNamespace): void {\n const nsId = shell.id;\n\n for (const value of shell.enums) {\n this.addType(nsId, value.name, { kind: \"enum\", namespace: shell, value });\n }\n\n for (const value of shell.callbacks) {\n this.addType(nsId, value.name, { kind: \"callback\", namespace: shell, value });\n }\n\n for (const alias of shell.aliases) {\n this.addType(nsId, alias.name, { kind: \"alias\", namespace: shell, value: alias });\n }\n }\n\n private processIdentifier(input: {\n identifier: string;\n girPath: string[];\n seen: Set<string>;\n queue: string[];\n girFiles: string[];\n discovered: DiscoveredNamespace[];\n }): void {\n const { identifier, girPath, seen, queue, girFiles, discovered } = input;\n const namespaceName = identifier.split(\"-\", 1)[0] ?? identifier;\n\n if (seen.has(namespaceName)) {\n return;\n }\n\n seen.add(namespaceName);\n const path = locateGirFile(identifier, girPath);\n girFiles.push(path);\n const header = parseNamespaceHeader(readRepositoryNode(path));\n const shell = this.registerNamespace(header);\n discovered.push({ header, shell });\n\n for (const include of header.includes) {\n queue.push(`${include.name}-${include.version}`);\n }\n }\n\n private discoverNamespaces(\n libraries: string[],\n girPath: string[],\n ): { discovered: DiscoveredNamespace[]; girFiles: string[] } {\n const queue: string[] = [...libraries];\n const seen: Set<string> = new Set();\n const discovered: DiscoveredNamespace[] = [];\n const girFiles: string[] = [];\n\n while (queue.length > 0) {\n const identifier = queue.shift();\n\n if (identifier !== undefined) {\n this.processIdentifier({ identifier, girPath, seen, queue, girFiles, discovered });\n }\n }\n\n return { discovered, girFiles };\n }\n\n public get namespaces(): Map<string, GirNamespace> {\n return this.namespacesByName;\n }\n\n public get girFiles(): string[] {\n return this.girFilesValue;\n }\n\n typeFor(tid: TypeId): GirType | undefined {\n return this.typeTables[tid.nsId]?.types[tid.id];\n }\n\n nameFor(tid: TypeId): { namespaceName: string; typeName: string } | undefined {\n const typeName = this.typeTables[tid.nsId]?.names[tid.id];\n const namespaceName = this.nsNameById[tid.nsId];\n\n if (typeName === undefined || namespaceName === undefined) {\n return undefined;\n }\n\n return { namespaceName, typeName };\n }\n\n resolveType(currentNamespaceName: string, name: string): GirType | undefined {\n const currentNsId = this.nsIdByName.get(currentNamespaceName);\n\n if (currentNsId === undefined) {\n return undefined;\n }\n\n const [namespaceName, localName] = splitOptionalNamespace(name);\n const targetNsId = namespaceName === undefined ? currentNsId : this.nsIdByName.get(namespaceName);\n\n if (targetNsId === undefined) {\n return undefined;\n }\n\n const id = this.typeTableFor(targetNsId).index.get(localName);\n\n if (id === undefined) {\n return undefined;\n }\n\n return this.typeTableFor(targetNsId).types[id];\n }\n}\n\nexport { Library };\n"]}
1
+ {"version":3,"file":"library.js","sourceRoot":"","sources":["../../src/gir/library.ts"],"names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,KAAK,SAAS,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;YACxD,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;IACvC,CAAC;IAED;;;;;;;OAOG;IACH,WAAW,CAAC,oBAA4B,EAAE,IAAY;QAClD,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAE9D,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,MAAM,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAChE,MAAM,UAAU,GAAG,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAElG,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAE9D,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YACnB,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;CACJ;AAED,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { PrimitiveCategory } from \"./primitives.js\";\nimport type { CArrayType, HashTableType, ListType, ParseContext, TypeId } from \"./type-id.js\";\nimport type { GirType } from \"./type.js\";\nimport { callbackFromNode } from \"./callback.js\";\nimport {\n createNamespaceShell,\n type GirNamespace,\n type NamespaceHeader,\n parseNamespaceHeader,\n populateNamespaceBody,\n} from \"./namespace.js\";\nimport { parseGirFile, type RawNode } from \"./parse.js\";\nimport { splitOptionalNamespace } from \"./type-ref.js\";\n\n/** The types belonging to one namespace, addressed by the id half of a {@link TypeId}. */\ntype TypeTable = {\n /** Parsed type in each slot, still `undefined` while only a forward reference to it has been seen. */\n types: (GirType | undefined)[];\n /** Declared name of each slot, `undefined` for anonymous types such as containers and inline callbacks. */\n names: (string | undefined)[];\n /** Slot id each named type occupies, so repeated references resolve to the same id. */\n index: Map<string, number>;\n};\n\n/** A namespace whose header has been read and whose shell is registered, before its body is parsed. */\ntype DiscoveredNamespace = {\n /** Attributes and includes read from the namespace's GIR file. */\n header: NamespaceHeader;\n /** Empty namespace registered for the header, populated once every header is known. */\n shell: GirNamespace;\n};\n\nconst INTERNAL_NS_ID = 0;\n\nconst readRepositoryNode = (path: string): RawNode => {\n const root = parseGirFile(path);\n const repository = root.repository;\n\n if (typeof repository !== \"object\" || repository === null) {\n throw new Error(`GIR file at ${path} has no <repository> root`);\n }\n\n return repository as RawNode;\n};\n\nconst locateGirFile = (identifier: string, girPath: string[]): string => {\n const filename = `${identifier}.gir`;\n\n for (const directory of girPath) {\n const candidate = join(directory, filename);\n\n if (existsSync(candidate)) {\n return candidate;\n }\n }\n\n const tried = girPath.map((directory) => join(directory, filename)).join(\", \");\n throw new Error(`GIR file ${filename} not found on girPath. Tried: ${tried}`);\n};\n\n/**\n * The parsed GIR universe: every requested namespace plus everything those namespaces include,\n * with types resolvable across namespace boundaries.\n */\nclass Library {\n private static drive(library: Library, libraries: string[], girPath: string[]): void {\n const { discovered, girFiles } = library.discoverNamespaces(libraries, girPath);\n\n for (const { header, shell } of discovered) {\n populateNamespaceBody(shell, header.namespaceNode, library.parseContext(shell.id));\n }\n\n for (const { shell } of discovered) {\n library.addDeclarations(shell);\n }\n\n library.girFilesValue = girFiles;\n }\n\n /**\n * Parses the named GIR libraries along with every namespace they transitively include.\n *\n * @param libraries GIR identifiers to load, such as `Gtk-4.0`.\n * @param girPath Directories searched, in order, for each `.gir` file.\n * @returns A library holding every namespace that was parsed.\n */\n static load(libraries: string[], girPath: string[]): Library {\n const library = new Library();\n this.drive(library, libraries, girPath);\n\n return library;\n }\n\n private namespacesByName: Map<string, GirNamespace> = new Map();\n private namespaceById: (GirNamespace | undefined)[] = [];\n private nsNameById: string[] = [];\n private nsIdByName: Map<string, number> = new Map();\n private typeTables: TypeTable[] = [];\n private girFilesValue: string[] = [];\n\n /** Creates a library with no namespaces loaded; {@link Library.load} builds a populated one. */\n constructor() {\n this.typeTables[INTERNAL_NS_ID] = { types: [], names: [], index: new Map() };\n this.namespaceById[INTERNAL_NS_ID] = undefined;\n this.nsNameById[INTERNAL_NS_ID] = \"$internal\";\n }\n\n private ensureNsId(name: string): number {\n const existing = this.nsIdByName.get(name);\n\n if (existing !== undefined) {\n return existing;\n }\n\n const nsId = this.typeTables.length;\n this.typeTables[nsId] = { types: [], names: [], index: new Map() };\n this.namespaceById[nsId] = undefined;\n this.nsNameById[nsId] = name;\n this.nsIdByName.set(name, nsId);\n\n return nsId;\n }\n\n private registerNamespace(header: NamespaceHeader): GirNamespace {\n const nsId = this.ensureNsId(header.name);\n const shell = createNamespaceShell(header, nsId);\n this.namespaceById[nsId] = shell;\n this.namespacesByName.set(header.name, shell);\n\n return shell;\n }\n\n private namespaceFor(nsId: number): GirNamespace {\n const namespace = this.namespaceById[nsId];\n\n if (namespace === undefined) {\n throw new Error(`No namespace registered for type table id ${String(nsId)}`);\n }\n\n return namespace;\n }\n\n private typeTableFor(nsId: number): TypeTable {\n const typeTable = this.typeTables[nsId];\n\n if (typeTable === undefined) {\n throw new Error(`No type table for namespace id ${String(nsId)}`);\n }\n\n return typeTable;\n }\n\n private insertIntoTypeTable(\n typeTable: TypeTable,\n slot: { type: GirType | undefined; indexKey?: string; displayName?: string },\n ): number {\n const id = typeTable.types.length;\n typeTable.types.push(slot.type);\n typeTable.names.push(slot.displayName);\n\n if (slot.indexKey !== undefined) {\n typeTable.index.set(slot.indexKey, id);\n }\n\n return id;\n }\n\n private resolveTypeId(nsId: number, name: string, type: GirType | undefined): number {\n const typeTable = this.typeTableFor(nsId);\n const existing = typeTable.index.get(name);\n\n if (existing !== undefined) {\n return existing;\n }\n\n return this.insertIntoTypeTable(typeTable, { type, indexKey: name, displayName: name });\n }\n\n private addType(nsId: number, name: string, type: GirType): void {\n this.typeTableFor(nsId).types[this.resolveTypeId(nsId, name, type)] = type;\n }\n\n private findType(nsId: number, name: string): TypeId {\n return { nsId, id: this.resolveTypeId(nsId, name, undefined) };\n }\n\n private addAnonymousType(nsId: number, type: GirType): TypeId {\n const typeTable = this.typeTableFor(nsId);\n const id = this.insertIntoTypeTable(typeTable, { type });\n\n return { nsId, id };\n }\n\n private findTypeByName(currentNsId: number, name: string): TypeId {\n const [namespaceName, localName] = splitOptionalNamespace(name);\n const targetNsId = namespaceName === undefined ? currentNsId : this.ensureNsId(namespaceName);\n\n return this.findType(targetNsId, localName);\n }\n\n private parseContext(nsId: number): ParseContext {\n const context: ParseContext = {\n nsId,\n findType: (name) => this.findTypeByName(nsId, name),\n addPrimitive: (category) => this.addPrimitive(category),\n addVarargs: () => this.addVarargs(),\n addContainer: (type: CArrayType | ListType | HashTableType) => this.addAnonymousType(nsId, type),\n addAnonymousCallback: (node) =>\n this.addAnonymousType(nsId, {\n kind: \"callback\",\n namespace: this.namespaceFor(nsId),\n value: callbackFromNode(node, context),\n }),\n };\n\n return context;\n }\n\n private addPrimitive(category: PrimitiveCategory): TypeId {\n return this.findOrAddContainer(`primitive:${category}`, { kind: \"primitive\", category });\n }\n\n private addVarargs(): TypeId {\n return this.findOrAddContainer(\"varargs\", { kind: \"varargs\" });\n }\n\n private findOrAddContainer(key: string, type: GirType): TypeId {\n const typeTable = this.typeTableFor(INTERNAL_NS_ID);\n const existing = typeTable.index.get(key);\n\n if (existing !== undefined) {\n return { nsId: INTERNAL_NS_ID, id: existing };\n }\n\n const id = this.insertIntoTypeTable(typeTable, { type, indexKey: key });\n\n return { nsId: INTERNAL_NS_ID, id };\n }\n\n private addDeclarations(shell: GirNamespace): void {\n this.addClassDeclarations(shell);\n this.addValueDeclarations(shell);\n }\n\n private addClassDeclarations(shell: GirNamespace): void {\n const nsId = shell.id;\n\n for (const value of shell.classes) {\n this.addType(nsId, value.name, { kind: \"class\", namespace: shell, value });\n }\n\n for (const value of shell.interfaces) {\n this.addType(nsId, value.name, { kind: \"interface\", namespace: shell, value });\n }\n\n for (const value of shell.records) {\n this.addType(nsId, value.name, { kind: \"record\", namespace: shell, value });\n }\n }\n\n private addValueDeclarations(shell: GirNamespace): void {\n const nsId = shell.id;\n\n for (const value of shell.enums) {\n this.addType(nsId, value.name, { kind: \"enum\", namespace: shell, value });\n }\n\n for (const value of shell.callbacks) {\n this.addType(nsId, value.name, { kind: \"callback\", namespace: shell, value });\n }\n\n for (const alias of shell.aliases) {\n this.addType(nsId, alias.name, { kind: \"alias\", namespace: shell, value: alias });\n }\n }\n\n private processIdentifier(input: {\n identifier: string;\n girPath: string[];\n seen: Set<string>;\n queue: string[];\n girFiles: string[];\n discovered: DiscoveredNamespace[];\n }): void {\n const { identifier, girPath, seen, queue, girFiles, discovered } = input;\n const namespaceName = identifier.split(\"-\", 1)[0] ?? identifier;\n\n if (seen.has(namespaceName)) {\n return;\n }\n\n seen.add(namespaceName);\n const path = locateGirFile(identifier, girPath);\n girFiles.push(path);\n const header = parseNamespaceHeader(readRepositoryNode(path));\n const shell = this.registerNamespace(header);\n discovered.push({ header, shell });\n\n for (const include of header.includes) {\n queue.push(`${include.name}-${include.version}`);\n }\n }\n\n private discoverNamespaces(\n libraries: string[],\n girPath: string[],\n ): { discovered: DiscoveredNamespace[]; girFiles: string[] } {\n const queue: string[] = [...libraries];\n const seen: Set<string> = new Set();\n const discovered: DiscoveredNamespace[] = [];\n const girFiles: string[] = [];\n\n while (queue.length > 0) {\n const identifier = queue.shift();\n\n if (identifier !== undefined) {\n this.processIdentifier({ identifier, girPath, seen, queue, girFiles, discovered });\n }\n }\n\n return { discovered, girFiles };\n }\n\n /** The loaded namespaces, keyed by their GIR name such as `Gtk`. */\n public get namespaces(): Map<string, GirNamespace> {\n return this.namespacesByName;\n }\n\n /** Paths of the `.gir` files that were read, in the order they were discovered. */\n public get girFiles(): string[] {\n return this.girFilesValue;\n }\n\n /**\n * Reads the type a {@link TypeId} points at.\n *\n * @param tid The type id to dereference.\n * @returns The parsed type, or `undefined` when nothing has been parsed into that slot.\n */\n typeFor(tid: TypeId): GirType | undefined {\n return this.typeTables[tid.nsId]?.types[tid.id];\n }\n\n /**\n * Reads the name a {@link TypeId} was registered under.\n *\n * @param tid The type id to name.\n * @returns The namespace and type name, or `undefined` for an anonymous type.\n */\n nameFor(tid: TypeId): {\n /** GIR namespace to qualify the type with, such as `Gtk`. */\n namespaceName: string;\n /** Unqualified type name as GIR declares it, such as `Widget`. */\n typeName: string;\n } | undefined {\n const typeName = this.typeTables[tid.nsId]?.names[tid.id];\n const namespaceName = this.nsNameById[tid.nsId];\n\n if (typeName === undefined || namespaceName === undefined) {\n return undefined;\n }\n\n return { namespaceName, typeName };\n }\n\n /**\n * Looks up a type by the name a GIR file writes, resolving an unqualified name against the\n * namespace it appears in and a `Namespace.Type` name against the loaded namespaces.\n *\n * @param currentNamespaceName Namespace the name is written in.\n * @param name Type name, optionally qualified with a namespace prefix.\n * @returns The parsed type, or `undefined` when the name is unknown or only a forward reference to it exists.\n */\n resolveType(currentNamespaceName: string, name: string): GirType | undefined {\n const currentNsId = this.nsIdByName.get(currentNamespaceName);\n\n if (currentNsId === undefined) {\n return undefined;\n }\n\n const [namespaceName, localName] = splitOptionalNamespace(name);\n const targetNsId = namespaceName === undefined ? currentNsId : this.nsIdByName.get(namespaceName);\n\n if (targetNsId === undefined) {\n return undefined;\n }\n\n const id = this.typeTableFor(targetNsId).index.get(localName);\n\n if (id === undefined) {\n return undefined;\n }\n\n return this.typeTableFor(targetNsId).types[id];\n }\n}\n\nexport { Library };\n"]}