@gtkx/codegen 1.0.0-rc.1 → 1.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (521) hide show
  1. package/dist/analysis/descriptor-render.d.ts +18 -11
  2. package/dist/analysis/descriptor-render.d.ts.map +1 -1
  3. package/dist/analysis/descriptor-render.js +275 -152
  4. package/dist/analysis/descriptor-render.js.map +1 -1
  5. package/dist/analysis/descriptor.d.ts +37 -34
  6. package/dist/analysis/descriptor.d.ts.map +1 -1
  7. package/dist/analysis/descriptor.js +34 -30
  8. package/dist/analysis/descriptor.js.map +1 -1
  9. package/dist/analysis/inheritance.d.ts +16 -16
  10. package/dist/analysis/inheritance.d.ts.map +1 -1
  11. package/dist/analysis/inheritance.js +139 -84
  12. package/dist/analysis/inheritance.js.map +1 -1
  13. package/dist/analysis/param-structure.d.ts +14 -13
  14. package/dist/analysis/param-structure.d.ts.map +1 -1
  15. package/dist/analysis/param-structure.js +104 -53
  16. package/dist/analysis/param-structure.js.map +1 -1
  17. package/dist/analysis/ts-type.d.ts +6 -5
  18. package/dist/analysis/ts-type.d.ts.map +1 -1
  19. package/dist/analysis/ts-type.js +69 -23
  20. package/dist/analysis/ts-type.js.map +1 -1
  21. package/dist/compile.d.ts +5 -5
  22. package/dist/compile.d.ts.map +1 -1
  23. package/dist/compile.js +70 -63
  24. package/dist/compile.js.map +1 -1
  25. package/dist/docs/api-reference.d.ts +12 -11
  26. package/dist/docs/api-reference.d.ts.map +1 -1
  27. package/dist/docs/api-reference.js +194 -121
  28. package/dist/docs/api-reference.js.map +1 -1
  29. package/dist/docs/element-page.d.ts +6 -9
  30. package/dist/docs/element-page.d.ts.map +1 -1
  31. package/dist/docs/element-page.js +68 -133
  32. package/dist/docs/element-page.js.map +1 -1
  33. package/dist/docs/pipeline.d.ts +8 -7
  34. package/dist/docs/pipeline.d.ts.map +1 -1
  35. package/dist/docs/pipeline.js +79 -53
  36. package/dist/docs/pipeline.js.map +1 -1
  37. package/dist/docs/render.d.ts +21 -19
  38. package/dist/docs/render.d.ts.map +1 -1
  39. package/dist/docs/render.js +80 -71
  40. package/dist/docs/render.js.map +1 -1
  41. package/dist/docs/symbol-page.d.ts +6 -6
  42. package/dist/docs/symbol-page.d.ts.map +1 -1
  43. package/dist/docs/symbol-page.js +126 -84
  44. package/dist/docs/symbol-page.js.map +1 -1
  45. package/dist/fingerprint.d.ts +28 -5
  46. package/dist/fingerprint.d.ts.map +1 -1
  47. package/dist/fingerprint.js +66 -13
  48. package/dist/fingerprint.js.map +1 -1
  49. package/dist/gi.d.ts +13 -0
  50. package/dist/gi.d.ts.map +1 -0
  51. package/dist/gi.js +21 -0
  52. package/dist/gi.js.map +1 -0
  53. package/dist/gir/ancestry.d.ts +4 -3
  54. package/dist/gir/ancestry.d.ts.map +1 -1
  55. package/dist/gir/ancestry.js +12 -15
  56. package/dist/gir/ancestry.js.map +1 -1
  57. package/dist/gir/callback.d.ts +6 -11
  58. package/dist/gir/callback.d.ts.map +1 -1
  59. package/dist/gir/callback.js +6 -7
  60. package/dist/gir/callback.js.map +1 -1
  61. package/dist/gir/class.d.ts +7 -5
  62. package/dist/gir/class.d.ts.map +1 -1
  63. package/dist/gir/class.js +14 -12
  64. package/dist/gir/class.js.map +1 -1
  65. package/dist/gir/enum.d.ts +3 -3
  66. package/dist/gir/enum.d.ts.map +1 -1
  67. package/dist/gir/enum.js +7 -6
  68. package/dist/gir/enum.js.map +1 -1
  69. package/dist/gir/field.d.ts +8 -3
  70. package/dist/gir/field.d.ts.map +1 -1
  71. package/dist/gir/field.js +30 -7
  72. package/dist/gir/field.js.map +1 -1
  73. package/dist/gir/function.d.ts +6 -3
  74. package/dist/gir/function.d.ts.map +1 -1
  75. package/dist/gir/function.js +23 -7
  76. package/dist/gir/function.js.map +1 -1
  77. package/dist/gir/gir-path.d.ts +2 -1
  78. package/dist/gir/gir-path.d.ts.map +1 -1
  79. package/dist/gir/gir-path.js +26 -10
  80. package/dist/gir/gir-path.js.map +1 -1
  81. package/dist/gir/libraries.d.ts +3 -2
  82. package/dist/gir/libraries.d.ts.map +1 -1
  83. package/dist/gir/libraries.js +39 -27
  84. package/dist/gir/libraries.js.map +1 -1
  85. package/dist/gir/library.d.ts +17 -11
  86. package/dist/gir/library.d.ts.map +1 -1
  87. package/dist/gir/library.js +116 -92
  88. package/dist/gir/library.js.map +1 -1
  89. package/dist/gir/namespace.d.ts +10 -10
  90. package/dist/gir/namespace.d.ts.map +1 -1
  91. package/dist/gir/namespace.js +21 -20
  92. package/dist/gir/namespace.js.map +1 -1
  93. package/dist/gir/nullable-overrides.d.ts +3 -0
  94. package/dist/gir/nullable-overrides.d.ts.map +1 -0
  95. package/dist/gir/nullable-overrides.js +5 -0
  96. package/dist/gir/nullable-overrides.js.map +1 -0
  97. package/dist/gir/parameter.d.ts +14 -12
  98. package/dist/gir/parameter.d.ts.map +1 -1
  99. package/dist/gir/parameter.js +27 -18
  100. package/dist/gir/parameter.js.map +1 -1
  101. package/dist/gir/parse.d.ts +12 -13
  102. package/dist/gir/parse.d.ts.map +1 -1
  103. package/dist/gir/parse.js +50 -40
  104. package/dist/gir/parse.js.map +1 -1
  105. package/dist/gir/primitives.d.ts +5 -4
  106. package/dist/gir/primitives.d.ts.map +1 -1
  107. package/dist/gir/primitives.js +4 -3
  108. package/dist/gir/primitives.js.map +1 -1
  109. package/dist/gir/property.d.ts +5 -4
  110. package/dist/gir/property.d.ts.map +1 -1
  111. package/dist/gir/property.js +10 -9
  112. package/dist/gir/property.js.map +1 -1
  113. package/dist/gir/record.d.ts +5 -4
  114. package/dist/gir/record.d.ts.map +1 -1
  115. package/dist/gir/record.js +13 -12
  116. package/dist/gir/record.js.map +1 -1
  117. package/dist/gir/size.d.ts +6 -5
  118. package/dist/gir/size.d.ts.map +1 -1
  119. package/dist/gir/size.js +49 -47
  120. package/dist/gir/size.js.map +1 -1
  121. package/dist/gir/type-id.d.ts +17 -15
  122. package/dist/gir/type-id.d.ts.map +1 -1
  123. package/dist/gir/type-id.js +5 -1
  124. package/dist/gir/type-id.js.map +1 -1
  125. package/dist/gir/type-ref.d.ts +3 -2
  126. package/dist/gir/type-ref.d.ts.map +1 -1
  127. package/dist/gir/type-ref.js +36 -25
  128. package/dist/gir/type-ref.js.map +1 -1
  129. package/dist/gir/type.d.ts +3 -2
  130. package/dist/gir/type.d.ts.map +1 -1
  131. package/dist/gir/type.js.map +1 -1
  132. package/dist/index.d.ts +2 -0
  133. package/dist/index.d.ts.map +1 -1
  134. package/dist/index.js +1 -0
  135. package/dist/index.js.map +1 -1
  136. package/dist/jsx.d.ts +26 -0
  137. package/dist/jsx.d.ts.map +1 -0
  138. package/dist/jsx.js +40 -0
  139. package/dist/jsx.js.map +1 -0
  140. package/dist/khronos/args.d.ts +7 -7
  141. package/dist/khronos/args.d.ts.map +1 -1
  142. package/dist/khronos/args.js +88 -67
  143. package/dist/khronos/args.js.map +1 -1
  144. package/dist/khronos/jsdoc.d.ts +4 -4
  145. package/dist/khronos/jsdoc.d.ts.map +1 -1
  146. package/dist/khronos/jsdoc.js +29 -16
  147. package/dist/khronos/jsdoc.js.map +1 -1
  148. package/dist/khronos/model.d.ts +8 -7
  149. package/dist/khronos/model.d.ts.map +1 -1
  150. package/dist/khronos/model.js +94 -59
  151. package/dist/khronos/model.js.map +1 -1
  152. package/dist/khronos/modules.d.ts +4 -3
  153. package/dist/khronos/modules.d.ts.map +1 -1
  154. package/dist/khronos/modules.js +40 -25
  155. package/dist/khronos/modules.js.map +1 -1
  156. package/dist/khronos/param-pair.d.ts +11 -0
  157. package/dist/khronos/param-pair.d.ts.map +1 -0
  158. package/dist/khronos/param-pair.js +6 -0
  159. package/dist/khronos/param-pair.js.map +1 -0
  160. package/dist/khronos/parse.d.ts +7 -8
  161. package/dist/khronos/parse.d.ts.map +1 -1
  162. package/dist/khronos/parse.js +17 -16
  163. package/dist/khronos/parse.js.map +1 -1
  164. package/dist/khronos/pipeline.d.ts +4 -4
  165. package/dist/khronos/pipeline.d.ts.map +1 -1
  166. package/dist/khronos/pipeline.js +97 -56
  167. package/dist/khronos/pipeline.js.map +1 -1
  168. package/dist/khronos/plan.d.ts +11 -10
  169. package/dist/khronos/plan.d.ts.map +1 -1
  170. package/dist/khronos/plan.js +109 -45
  171. package/dist/khronos/plan.js.map +1 -1
  172. package/dist/khronos/render.d.ts +5 -4
  173. package/dist/khronos/render.d.ts.map +1 -1
  174. package/dist/khronos/render.js +106 -59
  175. package/dist/khronos/render.js.map +1 -1
  176. package/dist/khronos/select.d.ts +4 -4
  177. package/dist/khronos/select.d.ts.map +1 -1
  178. package/dist/khronos/select.js +30 -19
  179. package/dist/khronos/select.js.map +1 -1
  180. package/dist/react/element-config.d.ts +17 -0
  181. package/dist/react/element-config.d.ts.map +1 -0
  182. package/dist/react/element-config.js +61 -0
  183. package/dist/react/element-config.js.map +1 -0
  184. package/dist/runner.d.ts +17 -10
  185. package/dist/runner.d.ts.map +1 -1
  186. package/dist/runner.js +45 -43
  187. package/dist/runner.js.map +1 -1
  188. package/dist/store/compile-store.d.ts +5 -3
  189. package/dist/store/compile-store.d.ts.map +1 -1
  190. package/dist/store/compile-store.js +24 -22
  191. package/dist/store/compile-store.js.map +1 -1
  192. package/dist/store/gi/async.d.ts +2 -1
  193. package/dist/store/gi/async.d.ts.map +1 -1
  194. package/dist/store/gi/async.js +28 -24
  195. package/dist/store/gi/async.js.map +1 -1
  196. package/dist/store/gi/callables.d.ts +26 -20
  197. package/dist/store/gi/callables.d.ts.map +1 -1
  198. package/dist/store/gi/callables.js +162 -100
  199. package/dist/store/gi/callables.js.map +1 -1
  200. package/dist/store/gi/callback.d.ts +3 -2
  201. package/dist/store/gi/callback.d.ts.map +1 -1
  202. package/dist/store/gi/callback.js +6 -3
  203. package/dist/store/gi/callback.js.map +1 -1
  204. package/dist/store/gi/class-struct-record.d.ts +4 -3
  205. package/dist/store/gi/class-struct-record.d.ts.map +1 -1
  206. package/dist/store/gi/class-struct-record.js +33 -15
  207. package/dist/store/gi/class-struct-record.js.map +1 -1
  208. package/dist/store/gi/class.d.ts +2 -1
  209. package/dist/store/gi/class.d.ts.map +1 -1
  210. package/dist/store/gi/class.js +86 -47
  211. package/dist/store/gi/class.js.map +1 -1
  212. package/dist/store/gi/companion.d.ts +2 -1
  213. package/dist/store/gi/companion.d.ts.map +1 -1
  214. package/dist/store/gi/companion.js +8 -5
  215. package/dist/store/gi/companion.js.map +1 -1
  216. package/dist/store/gi/constant.d.ts +3 -2
  217. package/dist/store/gi/constant.d.ts.map +1 -1
  218. package/dist/store/gi/constant.js +25 -8
  219. package/dist/store/gi/constant.js.map +1 -1
  220. package/dist/store/gi/constructor-props.d.ts +3 -2
  221. package/dist/store/gi/constructor-props.d.ts.map +1 -1
  222. package/dist/store/gi/constructor-props.js +17 -10
  223. package/dist/store/gi/constructor-props.js.map +1 -1
  224. package/dist/store/gi/enum.d.ts +3 -2
  225. package/dist/store/gi/enum.d.ts.map +1 -1
  226. package/dist/store/gi/enum.js +14 -11
  227. package/dist/store/gi/enum.js.map +1 -1
  228. package/dist/store/gi/function.d.ts +5 -4
  229. package/dist/store/gi/function.d.ts.map +1 -1
  230. package/dist/store/gi/function.js +50 -23
  231. package/dist/store/gi/function.js.map +1 -1
  232. package/dist/store/gi/gtype-binding.d.ts +4 -4
  233. package/dist/store/gi/gtype-binding.d.ts.map +1 -1
  234. package/dist/store/gi/gtype-binding.js +15 -11
  235. package/dist/store/gi/gtype-binding.js.map +1 -1
  236. package/dist/store/gi/interface.d.ts +2 -1
  237. package/dist/store/gi/interface.d.ts.map +1 -1
  238. package/dist/store/gi/interface.js +36 -18
  239. package/dist/store/gi/interface.js.map +1 -1
  240. package/dist/store/gi/item-comparators.d.ts +3 -2
  241. package/dist/store/gi/item-comparators.d.ts.map +1 -1
  242. package/dist/store/gi/item-comparators.js +33 -21
  243. package/dist/store/gi/item-comparators.js.map +1 -1
  244. package/dist/store/gi/method.d.ts +13 -13
  245. package/dist/store/gi/method.d.ts.map +1 -1
  246. package/dist/store/gi/method.js +187 -130
  247. package/dist/store/gi/method.js.map +1 -1
  248. package/dist/store/gi/param-marshal.d.ts +7 -6
  249. package/dist/store/gi/param-marshal.d.ts.map +1 -1
  250. package/dist/store/gi/param-marshal.js +26 -13
  251. package/dist/store/gi/param-marshal.js.map +1 -1
  252. package/dist/store/gi/pipeline.d.ts +2 -1
  253. package/dist/store/gi/pipeline.d.ts.map +1 -1
  254. package/dist/store/gi/pipeline.js +38 -23
  255. package/dist/store/gi/pipeline.js.map +1 -1
  256. package/dist/store/gi/properties.d.ts +2 -1
  257. package/dist/store/gi/properties.d.ts.map +1 -1
  258. package/dist/store/gi/properties.js +6 -4
  259. package/dist/store/gi/properties.js.map +1 -1
  260. package/dist/store/gi/property-accessor.d.ts +11 -10
  261. package/dist/store/gi/property-accessor.d.ts.map +1 -1
  262. package/dist/store/gi/property-accessor.js +86 -60
  263. package/dist/store/gi/property-accessor.js.map +1 -1
  264. package/dist/store/gi/record-constructor.d.ts +3 -2
  265. package/dist/store/gi/record-constructor.d.ts.map +1 -1
  266. package/dist/store/gi/record-constructor.js +36 -25
  267. package/dist/store/gi/record-constructor.js.map +1 -1
  268. package/dist/store/gi/record-field-accessor.d.ts +8 -8
  269. package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
  270. package/dist/store/gi/record-field-accessor.js +171 -99
  271. package/dist/store/gi/record-field-accessor.js.map +1 -1
  272. package/dist/store/gi/record-layout.d.ts +6 -5
  273. package/dist/store/gi/record-layout.d.ts.map +1 -1
  274. package/dist/store/gi/record-layout.js +75 -39
  275. package/dist/store/gi/record-layout.js.map +1 -1
  276. package/dist/store/gi/record.d.ts +2 -1
  277. package/dist/store/gi/record.d.ts.map +1 -1
  278. package/dist/store/gi/record.js +19 -13
  279. package/dist/store/gi/record.js.map +1 -1
  280. package/dist/store/gi/registration.d.ts +3 -3
  281. package/dist/store/gi/registration.d.ts.map +1 -1
  282. package/dist/store/gi/registration.js +3 -2
  283. package/dist/store/gi/registration.js.map +1 -1
  284. package/dist/store/gi/return-wrap.d.ts +2 -2
  285. package/dist/store/gi/return-wrap.d.ts.map +1 -1
  286. package/dist/store/gi/return-wrap.js +43 -22
  287. package/dist/store/gi/return-wrap.js.map +1 -1
  288. package/dist/store/gi/runtime-override.d.ts +2 -1
  289. package/dist/store/gi/runtime-override.d.ts.map +1 -1
  290. package/dist/store/gi/runtime-override.js +6 -3
  291. package/dist/store/gi/runtime-override.js.map +1 -1
  292. package/dist/store/gi/signal.d.ts +3 -2
  293. package/dist/store/gi/signal.d.ts.map +1 -1
  294. package/dist/store/gi/signal.js +113 -66
  295. package/dist/store/gi/signal.js.map +1 -1
  296. package/dist/store/gi/vtable.d.ts +2 -1
  297. package/dist/store/gi/vtable.d.ts.map +1 -1
  298. package/dist/store/gi/vtable.js +60 -30
  299. package/dist/store/gi/vtable.js.map +1 -1
  300. package/dist/store/gi-store.d.ts +5 -4
  301. package/dist/store/gi-store.d.ts.map +1 -1
  302. package/dist/store/gi-store.js +4 -2
  303. package/dist/store/gi-store.js.map +1 -1
  304. package/dist/store/jsx/element-components.d.ts +23 -0
  305. package/dist/store/jsx/element-components.d.ts.map +1 -0
  306. package/dist/store/jsx/element-components.js +86 -0
  307. package/dist/store/jsx/element-components.js.map +1 -0
  308. package/dist/store/jsx/element-prop-imports.d.ts +17 -0
  309. package/dist/store/jsx/element-prop-imports.d.ts.map +1 -0
  310. package/dist/store/jsx/element-prop-imports.js +15 -0
  311. package/dist/store/jsx/element-prop-imports.js.map +1 -0
  312. package/dist/store/jsx/element-prop-types.d.ts +10 -0
  313. package/dist/store/jsx/element-prop-types.d.ts.map +1 -0
  314. package/dist/store/jsx/element-prop-types.js +41 -0
  315. package/dist/store/jsx/element-prop-types.js.map +1 -0
  316. package/dist/store/jsx/gir-index.d.ts +16 -0
  317. package/dist/store/jsx/gir-index.d.ts.map +1 -0
  318. package/dist/store/jsx/gir-index.js +33 -0
  319. package/dist/store/jsx/gir-index.js.map +1 -0
  320. package/dist/store/jsx/intrinsic-elements.d.ts +27 -0
  321. package/dist/store/jsx/intrinsic-elements.d.ts.map +1 -0
  322. package/dist/store/jsx/intrinsic-elements.js +128 -0
  323. package/dist/store/jsx/intrinsic-elements.js.map +1 -0
  324. package/dist/store/{react → jsx}/jsx.d.ts +2 -4
  325. package/dist/store/jsx/jsx.d.ts.map +1 -0
  326. package/dist/store/{react → jsx}/jsx.js +110 -71
  327. package/dist/store/jsx/jsx.js.map +1 -0
  328. package/dist/store/jsx/metadata.d.ts +4 -0
  329. package/dist/store/jsx/metadata.d.ts.map +1 -0
  330. package/dist/store/{react → jsx}/metadata.js +148 -69
  331. package/dist/store/jsx/metadata.js.map +1 -0
  332. package/dist/store/jsx/pipeline.d.ts +21 -0
  333. package/dist/store/jsx/pipeline.d.ts.map +1 -0
  334. package/dist/store/{react → jsx}/pipeline.js +36 -15
  335. package/dist/store/jsx/pipeline.js.map +1 -0
  336. package/dist/store/{react → jsx}/props.d.ts +9 -12
  337. package/dist/store/jsx/props.d.ts.map +1 -0
  338. package/dist/store/jsx/props.js +158 -0
  339. package/dist/store/jsx/props.js.map +1 -0
  340. package/dist/store/jsx-store.d.ts +5 -3
  341. package/dist/store/jsx-store.d.ts.map +1 -1
  342. package/dist/store/jsx-store.js +4 -1
  343. package/dist/store/jsx-store.js.map +1 -1
  344. package/dist/store/store-fs.d.ts +14 -12
  345. package/dist/store/store-fs.d.ts.map +1 -1
  346. package/dist/store/store-fs.js +9 -7
  347. package/dist/store/store-fs.js.map +1 -1
  348. package/dist/writer/context.d.ts +2 -1
  349. package/dist/writer/context.d.ts.map +1 -1
  350. package/dist/writer/context.js +12 -6
  351. package/dist/writer/context.js.map +1 -1
  352. package/dist/writer/doc.d.ts +2 -1
  353. package/dist/writer/doc.d.ts.map +1 -1
  354. package/dist/writer/doc.js +13 -7
  355. package/dist/writer/doc.js.map +1 -1
  356. package/dist/writer/emit.d.ts +8 -7
  357. package/dist/writer/emit.d.ts.map +1 -1
  358. package/dist/writer/emit.js +13 -10
  359. package/dist/writer/emit.js.map +1 -1
  360. package/dist/writer/gtk-doc.d.ts +2 -1
  361. package/dist/writer/gtk-doc.d.ts.map +1 -1
  362. package/dist/writer/gtk-doc.js +29 -18
  363. package/dist/writer/gtk-doc.js.map +1 -1
  364. package/dist/writer/imports.d.ts +4 -2
  365. package/dist/writer/imports.d.ts.map +1 -1
  366. package/dist/writer/imports.js +35 -24
  367. package/dist/writer/imports.js.map +1 -1
  368. package/dist/writer/module.d.ts +3 -2
  369. package/dist/writer/module.d.ts.map +1 -1
  370. package/dist/writer/module.js +16 -9
  371. package/dist/writer/module.js.map +1 -1
  372. package/dist/xml.d.ts +4 -0
  373. package/dist/xml.d.ts.map +1 -0
  374. package/dist/xml.js +10 -0
  375. package/dist/xml.js.map +1 -0
  376. package/overrides/cairo/context.ts.ejs +7 -7
  377. package/overrides/cairo/matrix.ts.ejs +2 -2
  378. package/overrides/cairo/recording-surface.ts.ejs +2 -2
  379. package/overrides/cairo/region.ts.ejs +1 -1
  380. package/overrides/cairo/scaled-font.ts.ejs +3 -3
  381. package/package.json +15 -9
  382. package/src/analysis/descriptor-render.ts +484 -168
  383. package/src/analysis/descriptor.ts +162 -125
  384. package/src/analysis/inheritance.ts +286 -98
  385. package/src/analysis/param-structure.ts +188 -57
  386. package/src/analysis/ts-type.ts +112 -26
  387. package/src/compile.ts +103 -76
  388. package/src/docs/api-reference.ts +340 -144
  389. package/src/docs/element-page.ts +137 -146
  390. package/src/docs/pipeline.ts +132 -73
  391. package/src/docs/render.ts +151 -87
  392. package/src/docs/symbol-page.ts +268 -123
  393. package/src/fingerprint.ts +127 -29
  394. package/src/gi.ts +26 -0
  395. package/src/gir/ancestry.ts +26 -14
  396. package/src/gir/callback.ts +10 -15
  397. package/src/gir/class.ts +20 -16
  398. package/src/gir/enum.ts +9 -7
  399. package/src/gir/field.ts +37 -8
  400. package/src/gir/function.ts +33 -9
  401. package/src/gir/gir-path.ts +36 -12
  402. package/src/gir/libraries.ts +56 -31
  403. package/src/gir/library.ts +200 -97
  404. package/src/gir/namespace.ts +42 -26
  405. package/src/gir/nullable-overrides.ts +5 -0
  406. package/src/gir/parameter.ts +80 -42
  407. package/src/gir/parse.ts +102 -47
  408. package/src/gir/primitives.ts +25 -23
  409. package/src/gir/property.ts +13 -11
  410. package/src/gir/record.ts +16 -14
  411. package/src/gir/size.ts +91 -58
  412. package/src/gir/type-id.ts +33 -18
  413. package/src/gir/type-ref.ts +62 -26
  414. package/src/gir/type.ts +10 -8
  415. package/src/index.ts +7 -0
  416. package/src/jsx.ts +70 -0
  417. package/src/khronos/args.ts +158 -89
  418. package/src/khronos/jsdoc.ts +67 -29
  419. package/src/khronos/model.ts +154 -53
  420. package/src/khronos/modules.ts +67 -27
  421. package/src/khronos/param-pair.ts +14 -0
  422. package/src/khronos/parse.ts +37 -17
  423. package/src/khronos/pipeline.ts +193 -90
  424. package/src/khronos/plan.ts +235 -86
  425. package/src/khronos/render.ts +208 -71
  426. package/src/khronos/select.ts +48 -18
  427. package/src/react/element-config.ts +91 -0
  428. package/src/runner.ts +93 -57
  429. package/src/store/compile-store.ts +32 -26
  430. package/src/store/gi/async.ts +48 -21
  431. package/src/store/gi/callables.ts +345 -136
  432. package/src/store/gi/callback.ts +13 -4
  433. package/src/store/gi/class-struct-record.ts +49 -17
  434. package/src/store/gi/class.ts +186 -64
  435. package/src/store/gi/companion.ts +15 -6
  436. package/src/store/gi/constant.ts +42 -8
  437. package/src/store/gi/constructor-props.ts +42 -16
  438. package/src/store/gi/enum.ts +28 -13
  439. package/src/store/gi/function.ts +90 -24
  440. package/src/store/gi/gtype-binding.ts +31 -18
  441. package/src/store/gi/interface.ts +101 -36
  442. package/src/store/gi/item-comparators.ts +74 -26
  443. package/src/store/gi/method.ts +376 -159
  444. package/src/store/gi/param-marshal.ts +38 -15
  445. package/src/store/gi/pipeline.ts +72 -22
  446. package/src/store/gi/properties.ts +16 -5
  447. package/src/store/gi/property-accessor.ts +192 -84
  448. package/src/store/gi/record-constructor.ts +62 -30
  449. package/src/store/gi/record-field-accessor.ts +380 -167
  450. package/src/store/gi/record-layout.ts +130 -43
  451. package/src/store/gi/record.ts +37 -14
  452. package/src/store/gi/registration.ts +15 -9
  453. package/src/store/gi/return-wrap.ts +71 -23
  454. package/src/store/gi/runtime-override.ts +13 -3
  455. package/src/store/gi/signal.ts +244 -104
  456. package/src/store/gi/vtable.ts +117 -41
  457. package/src/store/gi-store.ts +26 -13
  458. package/src/store/jsx/element-components.ts +152 -0
  459. package/src/store/jsx/element-prop-imports.ts +24 -0
  460. package/src/store/jsx/element-prop-types.ts +59 -0
  461. package/src/store/jsx/gir-index.ts +62 -0
  462. package/src/store/jsx/intrinsic-elements.ts +262 -0
  463. package/src/store/{react → jsx}/jsx.ts +213 -99
  464. package/src/store/jsx/metadata.ts +385 -0
  465. package/src/store/jsx/pipeline.ts +145 -0
  466. package/src/store/jsx/props.ts +274 -0
  467. package/src/store/jsx-store.ts +15 -3
  468. package/src/store/store-fs.ts +36 -20
  469. package/src/writer/context.ts +25 -6
  470. package/src/writer/doc.ts +19 -5
  471. package/src/writer/emit.ts +20 -11
  472. package/src/writer/gtk-doc.ts +48 -21
  473. package/src/writer/imports.ts +63 -28
  474. package/src/writer/module.ts +35 -11
  475. package/src/xml.ts +12 -0
  476. package/dist/store/react/built-ins.d.ts +0 -9
  477. package/dist/store/react/built-ins.d.ts.map +0 -1
  478. package/dist/store/react/built-ins.js +0 -226
  479. package/dist/store/react/built-ins.js.map +0 -1
  480. package/dist/store/react/element-components.d.ts +0 -15
  481. package/dist/store/react/element-components.d.ts.map +0 -1
  482. package/dist/store/react/element-components.js +0 -92
  483. package/dist/store/react/element-components.js.map +0 -1
  484. package/dist/store/react/element-prop-types.d.ts +0 -19
  485. package/dist/store/react/element-prop-types.d.ts.map +0 -1
  486. package/dist/store/react/element-prop-types.js +0 -244
  487. package/dist/store/react/element-prop-types.js.map +0 -1
  488. package/dist/store/react/element-props.d.ts +0 -4
  489. package/dist/store/react/element-props.d.ts.map +0 -1
  490. package/dist/store/react/element-props.js +0 -178
  491. package/dist/store/react/element-props.js.map +0 -1
  492. package/dist/store/react/gir-index.d.ts +0 -25
  493. package/dist/store/react/gir-index.d.ts.map +0 -1
  494. package/dist/store/react/gir-index.js +0 -55
  495. package/dist/store/react/gir-index.js.map +0 -1
  496. package/dist/store/react/intrinsic-elements.d.ts +0 -26
  497. package/dist/store/react/intrinsic-elements.d.ts.map +0 -1
  498. package/dist/store/react/intrinsic-elements.js +0 -107
  499. package/dist/store/react/intrinsic-elements.js.map +0 -1
  500. package/dist/store/react/jsx.d.ts.map +0 -1
  501. package/dist/store/react/jsx.js.map +0 -1
  502. package/dist/store/react/metadata.d.ts +0 -4
  503. package/dist/store/react/metadata.d.ts.map +0 -1
  504. package/dist/store/react/metadata.js.map +0 -1
  505. package/dist/store/react/pipeline.d.ts +0 -14
  506. package/dist/store/react/pipeline.d.ts.map +0 -1
  507. package/dist/store/react/pipeline.js.map +0 -1
  508. package/dist/store/react/props.d.ts.map +0 -1
  509. package/dist/store/react/props.js +0 -133
  510. package/dist/store/react/props.js.map +0 -1
  511. package/overrides/gtk/constants.ts.ejs +0 -3
  512. package/overrides/gtk/index.ts.ejs +0 -2
  513. package/src/store/react/built-ins.ts +0 -260
  514. package/src/store/react/element-components.ts +0 -138
  515. package/src/store/react/element-prop-types.ts +0 -280
  516. package/src/store/react/element-props.ts +0 -204
  517. package/src/store/react/gir-index.ts +0 -85
  518. package/src/store/react/intrinsic-elements.ts +0 -161
  519. package/src/store/react/metadata.ts +0 -197
  520. package/src/store/react/pipeline.ts +0 -90
  521. package/src/store/react/props.ts +0 -197
@@ -1,55 +1,44 @@
1
- import type { ElementProp } from "@gtkx/config";
2
- import { sortStrings, sortStringsBy, toPascalCase } from "@gtkx/utils";
1
+ import { pascalCase, sortStrings, sortStringsBy } from "@gtkx/utils";
2
+ import type { GirClass } from "../gir/class.js";
3
+ import type { GirFunction } from "../gir/function.js";
4
+ import type { GirRecord } from "../gir/record.js";
3
5
  import { Library } from "../gir/library.js";
4
6
  import { type GirNamespace, namespaceDirectory } from "../gir/namespace.js";
5
7
  import { dedupeCallables, isEmittableCallable } from "../store/gi/callables.js";
6
8
  import { isClassStructRecord } from "../store/gi/class-struct-record.js";
7
9
  import { namespaceFunctionExportName } from "../store/gi/function.js";
8
- import { collectIntrinsicElementClasses, type GlibNamedClass } from "../store/react/intrinsic-elements.js";
10
+ import { collectIntrinsicElementClasses, type GlibNamedClass } from "../store/jsx/intrinsic-elements.js";
9
11
  import { createElementPageContext, type ElementPageContext, renderElementPage } from "./element-page.js";
10
12
  import { docsSignatureContext, firstSentence, namespaceOrder } from "./render.js";
11
13
  import { type GiSymbolEntry, renderSymbolPage, type SymbolPageOptions } from "./symbol-page.js";
12
14
 
13
- export type ApiReferenceOptions = {
15
+ type ApiReferenceOptions = {
14
16
  libraries: string[];
15
17
  girPath: string[];
16
- elementProps?: Record<string, ElementProp[]>;
17
18
  };
18
19
 
19
- export type ApiSymbolKind = GiSymbolEntry["kind"] | "element";
20
+ type ApiSymbolKind = GiSymbolEntry["kind"] | "element";
20
21
 
21
- export const API_SYMBOL_KINDS: ApiSymbolKind[] = [
22
- "element",
23
- "class",
24
- "interface",
25
- "record",
26
- "enum",
27
- "callback",
28
- "alias",
29
- "function",
30
- "constant",
31
- ];
32
-
33
- export type ApiSymbol = {
22
+ type ApiSymbol = {
34
23
  namespace: string;
35
24
  name: string;
36
25
  kind: ApiSymbolKind;
37
26
  summary: string;
38
27
  };
39
28
 
40
- export type ApiNamespaceSummary = {
29
+ type ApiNamespaceSummary = {
41
30
  name: string;
42
31
  importPath: string;
43
32
  symbols: number;
44
33
  elements: number;
45
34
  };
46
35
 
47
- export type ApiLookupResult =
48
- | { outcome: "page"; symbol: ApiSymbol; markdown: string }
49
- | { outcome: "ambiguous"; candidates: ApiSymbol[] }
50
- | { outcome: "notFound" };
36
+ type ApiLookupResult =
37
+ | { outcome: "page"; symbol: ApiSymbol; markdown: string } |
38
+ { outcome: "ambiguous"; candidates: ApiSymbol[] } |
39
+ { outcome: "notFound" };
51
40
 
52
- export type ApiSearchOptions = {
41
+ type ApiSearchOptions = {
53
42
  query: string;
54
43
  namespace?: string;
55
44
  kinds?: ApiSymbolKind[];
@@ -65,6 +54,19 @@ type ElementEntry = {
65
54
  };
66
55
 
67
56
  type SymbolEntry = GiSymbolEntry | ElementEntry;
57
+ type ScoredEntry = { score: number; entry: SymbolEntry };
58
+
59
+ const API_SYMBOL_KINDS: ApiSymbolKind[] = [
60
+ "element",
61
+ "class",
62
+ "interface",
63
+ "record",
64
+ "enum",
65
+ "callback",
66
+ "alias",
67
+ "function",
68
+ "constant",
69
+ ];
68
70
 
69
71
  const KIND_SECTION_TITLES: Record<ApiSymbolKind, string> = {
70
72
  element: "JSX elements",
@@ -80,36 +82,220 @@ const KIND_SECTION_TITLES: Record<ApiSymbolKind, string> = {
80
82
 
81
83
  const DEFAULT_SEARCH_LIMIT = 20;
82
84
 
83
- const compareNames = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);
85
+ const compareNames = (a: string, b: string): number => {
86
+ if (a < b) {
87
+ return -1;
88
+ }
89
+
90
+ return a > b ? 1 : 0;
91
+ };
92
+
93
+ const loadApiReference = (options: ApiReferenceOptions): ApiReference => new ApiReference(options);
94
+
95
+ const functionEntry = (
96
+ namespace: GirNamespace,
97
+ docsContext: ReturnType<typeof docsSignatureContext>,
98
+ fn: GirFunction,
99
+ ): GiSymbolEntry | undefined => {
100
+ if (!isEmittableCallable(docsContext, fn)) {
101
+ return undefined;
102
+ }
103
+
104
+ const cIdentifier = fn.cIdentifier;
105
+
106
+ if (cIdentifier === undefined) {
107
+ return undefined;
108
+ }
109
+
110
+ const name = namespaceFunctionExportName(cIdentifier, fn.name, namespace.cSymbolPrefixes);
111
+
112
+ return { kind: "function", namespace, name, doc: fn.doc, fn };
113
+ };
114
+
115
+ const classEntry = (namespace: GirNamespace, klass: GirClass): GiSymbolEntry | undefined => {
116
+ if (!klass.introspectable || klass.name.length === 0) {
117
+ return undefined;
118
+ }
119
+
120
+ const kind = klass.isInterface ? "interface" : "class";
121
+
122
+ return { kind, namespace, name: pascalCase(klass.name), doc: klass.doc, klass };
123
+ };
124
+
125
+ const classEntries = (namespace: GirNamespace): GiSymbolEntry[] => {
126
+ const entries: GiSymbolEntry[] = [];
127
+
128
+ for (const klass of [...namespace.classes, ...namespace.interfaces]) {
129
+ const entry = classEntry(namespace, klass);
130
+
131
+ if (entry !== undefined) {
132
+ entries.push(entry);
133
+ }
134
+ }
135
+
136
+ return entries;
137
+ };
138
+
139
+ const recordEntry = (library: Library, namespace: GirNamespace, record: GirRecord): GiSymbolEntry | undefined => {
140
+ if (!record.introspectable || record.isVtable || record.name.length === 0) {
141
+ return undefined;
142
+ }
143
+
144
+ if (isClassStructRecord(library, namespace.name, record)) {
145
+ return undefined;
146
+ }
147
+
148
+ return { kind: "record", namespace, name: record.name, doc: record.doc, record };
149
+ };
150
+
151
+ const recordEntries = (library: Library, namespace: GirNamespace): GiSymbolEntry[] => {
152
+ const entries: GiSymbolEntry[] = [];
153
+
154
+ for (const record of namespace.records) {
155
+ const entry = recordEntry(library, namespace, record);
156
+
157
+ if (entry !== undefined) {
158
+ entries.push(entry);
159
+ }
160
+ }
161
+
162
+ return entries;
163
+ };
164
+
165
+ const valueEntries = (namespace: GirNamespace): GiSymbolEntry[] => [
166
+ ...namespace.enums
167
+ .filter((enumeration) => enumeration.introspectable)
168
+ .map<GiSymbolEntry>((enumeration) => ({
169
+ kind: "enum",
170
+ namespace,
171
+ name: enumeration.name,
172
+ doc: enumeration.doc,
173
+ enumeration,
174
+ })),
175
+ ...namespace.callbacks
176
+ .filter((callback) => callback.introspectable)
177
+ .map<GiSymbolEntry>((callback) => ({
178
+ kind: "callback",
179
+ namespace,
180
+ name: callback.name,
181
+ doc: callback.doc,
182
+ callback,
183
+ })),
184
+ ...namespace.aliases.map<GiSymbolEntry>((alias) => ({
185
+ kind: "alias",
186
+ namespace,
187
+ name: alias.name,
188
+ doc: alias.doc,
189
+ alias,
190
+ })),
191
+ ...namespace.constants.map<GiSymbolEntry>((constant) => ({
192
+ kind: "constant",
193
+ namespace,
194
+ name: constant.name,
195
+ doc: constant.doc,
196
+ constant,
197
+ })),
198
+ ];
199
+
200
+ const narrowToExactMatches = (candidates: SymbolEntry[], trimmed: string, isQualified: boolean): SymbolEntry[] => {
201
+ if (candidates.length <= 1) {
202
+ return candidates;
203
+ }
204
+
205
+ const exact = candidates.filter(
206
+ (entry) => (isQualified ? `${entry.namespace.name}.${entry.name}` : entry.name) === trimmed,
207
+ );
208
+
209
+ return exact.length > 0 ? exact : candidates;
210
+ };
211
+
212
+ const isSearchFilterMatch = (
213
+ entry: SymbolEntry,
214
+ namespaceFilter: string | undefined,
215
+ kinds: ApiSymbolKind[] | undefined,
216
+ ): boolean => {
217
+ if (namespaceFilter !== undefined && entry.namespace.name.toLowerCase() !== namespaceFilter) {
218
+ return false;
219
+ }
220
+
221
+ if (kinds !== undefined && !kinds.includes(entry.kind)) {
222
+ return false;
223
+ }
224
+
225
+ return true;
226
+ };
227
+
228
+ const getScoredEntry = (
229
+ entry: SymbolEntry,
230
+ query: string,
231
+ namespaceFilter: string | undefined,
232
+ kinds: ApiSymbolKind[] | undefined,
233
+ ): ScoredEntry | undefined => {
234
+ if (!isSearchFilterMatch(entry, namespaceFilter, kinds)) {
235
+ return undefined;
236
+ }
237
+
238
+ const score = searchScore(entry, query);
239
+
240
+ if (score === 0) {
241
+ return undefined;
242
+ }
243
+
244
+ return { score, entry };
245
+ };
246
+
247
+ const compareScoredEntries = (a: ScoredEntry, b: ScoredEntry): number =>
248
+ b.score - a.score ||
249
+ a.entry.name.length - b.entry.name.length ||
250
+ compareNames(a.entry.name, b.entry.name) ||
251
+ compareNames(namespaceOrder(a.entry.namespace.name), namespaceOrder(b.entry.namespace.name)) ||
252
+ compareNames(a.entry.kind, b.entry.kind);
253
+
254
+ const searchScore = (entry: SymbolEntry, query: string): number => {
255
+ const name = entry.name.toLowerCase();
256
+ const qualified = `${entry.namespace.name.toLowerCase()}.${name}`;
257
+
258
+ if (name === query || qualified === query) {
259
+ return 3;
260
+ }
261
+
262
+ if (name.startsWith(query)) {
263
+ return 2;
264
+ }
265
+
266
+ if (name.includes(query) || qualified.includes(query)) {
267
+ return 1;
268
+ }
269
+
270
+ return 0;
271
+ };
84
272
 
85
273
  class ApiReference {
86
274
  private library: Library;
87
275
  private libraries: string[];
88
276
  private elementContext: ElementPageContext;
89
277
  private entries: SymbolEntry[] = [];
90
- private byQualified = new Map<string, SymbolEntry[]>();
91
- private byName = new Map<string, SymbolEntry[]>();
92
- private byNamespace = new Map<string, SymbolEntry[]>();
93
- private elementsByClass = new Map<string, string>();
278
+ private byQualified: Map<string, SymbolEntry[]> = new Map();
279
+ private byName: Map<string, SymbolEntry[]> = new Map();
280
+ private byNamespace: Map<string, SymbolEntry[]> = new Map();
281
+ private elementsByClass: Map<string, string> = new Map();
94
282
 
95
283
  constructor(options: ApiReferenceOptions) {
96
284
  this.libraries = options.libraries;
97
285
  this.library = Library.load(options.libraries, options.girPath);
98
- this.elementContext = createElementPageContext(this.library, options.elementProps ?? {}, () => undefined);
286
+ this.elementContext = createElementPageContext(this.library, (): string | undefined => undefined);
99
287
  this.buildIndex();
100
288
  }
101
289
 
102
- get girFiles(): string[] {
103
- return this.library.girFiles;
104
- }
105
-
106
290
  private add(entry: SymbolEntry): void {
107
291
  this.entries.push(entry);
292
+
108
293
  const push = (map: Map<string, SymbolEntry[]>, key: string): void => {
109
294
  const list = map.get(key) ?? [];
110
295
  list.push(entry);
111
296
  map.set(key, list);
112
297
  };
298
+
113
299
  push(this.byQualified, `${entry.namespace.name}.${entry.name}`.toLowerCase());
114
300
  push(this.byName, entry.name.toLowerCase());
115
301
  push(this.byNamespace, entry.namespace.name);
@@ -119,6 +305,7 @@ class ApiReference {
119
305
  for (const namespace of this.library.namespaces.values()) {
120
306
  this.indexNamespace(namespace);
121
307
  }
308
+
122
309
  for (const element of collectIntrinsicElementClasses(this.library)) {
123
310
  this.add({
124
311
  kind: "element",
@@ -127,6 +314,7 @@ class ApiReference {
127
314
  doc: element.klass.doc,
128
315
  element,
129
316
  });
317
+
130
318
  this.elementsByClass.set(`${element.namespace.name}.${element.klass.name}`, element.glibName);
131
319
  }
132
320
  }
@@ -137,21 +325,27 @@ class ApiReference {
137
325
  ...recordEntries(this.library, namespace),
138
326
  ...valueEntries(namespace),
139
327
  ];
328
+
140
329
  for (const entry of entries) {
141
330
  this.add(entry);
142
331
  }
332
+
143
333
  this.indexFunctions(namespace);
144
334
  }
145
335
 
146
336
  private indexFunctions(namespace: GirNamespace): void {
147
- if (namespace.sharedLibrary === undefined) return;
337
+ if (namespace.sharedLibrary === undefined) {
338
+ return;
339
+ }
340
+
148
341
  const docsContext = docsSignatureContext(namespace, this.library);
342
+
149
343
  for (const fn of dedupeCallables(namespace.functions)) {
150
- if (!isEmittableCallable(docsContext, fn)) continue;
151
- const cIdentifier = fn.cIdentifier;
152
- if (cIdentifier === undefined) continue;
153
- const name = namespaceFunctionExportName(cIdentifier, fn.name, namespace.cSymbolPrefixes);
154
- this.add({ kind: "function", namespace, name, doc: fn.doc, fn });
344
+ const entry = functionEntry(namespace, docsContext, fn);
345
+
346
+ if (entry !== undefined) {
347
+ this.add(entry);
348
+ }
155
349
  }
156
350
  }
157
351
 
@@ -172,91 +366,137 @@ class ApiReference {
172
366
  }
173
367
 
174
368
  private renderPage(entry: SymbolEntry): string {
175
- if (entry.kind === "element") return renderElementPage(entry.element, this.elementContext);
369
+ if (entry.kind === "element") {
370
+ return renderElementPage(entry.element, this.elementContext);
371
+ }
372
+
176
373
  return renderSymbolPage(entry, this.symbolPageOptions());
177
374
  }
178
375
 
179
376
  private findNamespace(name: string): GirNamespace | undefined {
180
377
  const lower = name.toLowerCase();
378
+
181
379
  for (const namespace of this.library.namespaces.values()) {
182
- if (namespace.name.toLowerCase() === lower) return namespace;
380
+ if (namespace.name.toLowerCase() === lower) {
381
+ return namespace;
382
+ }
183
383
  }
384
+
184
385
  return undefined;
185
386
  }
186
387
 
388
+ private lookupCandidates(trimmed: string, kind: ApiSymbolKind | undefined): SymbolEntry[] {
389
+ const isQualified = trimmed.includes(".");
390
+ const map = isQualified ? this.byQualified : this.byName;
391
+ let candidates = map.get(trimmed.toLowerCase()) ?? [];
392
+
393
+ if (kind !== undefined) {
394
+ candidates = candidates.filter((entry) => entry.kind === kind);
395
+ }
396
+
397
+ return narrowToExactMatches(candidates, trimmed, isQualified);
398
+ }
399
+
400
+ private scoreEntries(
401
+ query: string,
402
+ namespaceFilter: string | undefined,
403
+ kinds: ApiSymbolKind[] | undefined,
404
+ ): ScoredEntry[] {
405
+ const scored: ScoredEntry[] = [];
406
+
407
+ for (const entry of this.entries) {
408
+ const item = getScoredEntry(entry, query, namespaceFilter, kinds);
409
+
410
+ if (item !== undefined) {
411
+ scored.push(item);
412
+ }
413
+ }
414
+
415
+ return scored;
416
+ }
417
+
418
+ get girFiles(): string[] {
419
+ return this.library.girFiles;
420
+ }
421
+
187
422
  lookup(query: string, kind?: ApiSymbolKind): ApiLookupResult {
188
423
  const trimmed = query.trim();
189
- if (trimmed.length === 0) return { outcome: "notFound" };
190
- const qualified = trimmed.includes(".");
191
- const map = qualified ? this.byQualified : this.byName;
192
- let candidates = map.get(trimmed.toLowerCase()) ?? [];
193
- if (kind !== undefined) candidates = candidates.filter((entry) => entry.kind === kind);
194
- if (candidates.length > 1) {
195
- const exact = candidates.filter((entry) =>
196
- qualified ? `${entry.namespace.name}.${entry.name}` === trimmed : entry.name === trimmed,
197
- );
198
- if (exact.length > 0) candidates = exact;
424
+
425
+ if (trimmed.length === 0) {
426
+ return { outcome: "notFound" };
199
427
  }
428
+
429
+ const candidates = this.lookupCandidates(trimmed, kind);
200
430
  const entry = candidates[0];
201
- if (entry === undefined) return { outcome: "notFound" };
431
+
432
+ if (entry === undefined) {
433
+ return { outcome: "notFound" };
434
+ }
435
+
202
436
  if (candidates.length > 1) {
203
437
  return { outcome: "ambiguous", candidates: candidates.map((candidate) => this.toApiSymbol(candidate)) };
204
438
  }
439
+
205
440
  return { outcome: "page", symbol: this.toApiSymbol(entry), markdown: this.renderPage(entry) };
206
441
  }
207
442
 
208
443
  search(options: ApiSearchOptions): ApiSymbol[] {
209
444
  const query = options.query.trim().toLowerCase();
210
- if (query.length === 0) return [];
445
+
446
+ if (query.length === 0) {
447
+ return [];
448
+ }
449
+
211
450
  const limit = Math.max(1, Math.floor(options.limit ?? DEFAULT_SEARCH_LIMIT));
212
451
  const namespaceFilter = options.namespace?.toLowerCase();
213
- const scored: { score: number; entry: SymbolEntry }[] = [];
214
- for (const entry of this.entries) {
215
- if (namespaceFilter !== undefined && entry.namespace.name.toLowerCase() !== namespaceFilter) continue;
216
- if (options.kinds !== undefined && !options.kinds.includes(entry.kind)) continue;
217
- const score = searchScore(entry, query);
218
- if (score === 0) continue;
219
- scored.push({ score, entry });
220
- }
221
- scored.sort(
222
- (a, b) =>
223
- b.score - a.score ||
224
- a.entry.name.length - b.entry.name.length ||
225
- compareNames(a.entry.name, b.entry.name) ||
226
- compareNames(namespaceOrder(a.entry.namespace.name), namespaceOrder(b.entry.namespace.name)) ||
227
- compareNames(a.entry.kind, b.entry.kind),
228
- );
452
+ const scored = this.scoreEntries(query, namespaceFilter, options.kinds);
453
+ scored.sort(compareScoredEntries);
454
+
229
455
  return scored.slice(0, limit).map((item) => this.toApiSymbol(item.entry));
230
456
  }
231
457
 
232
458
  namespaces(): ApiNamespaceSummary[] {
233
- const summaries = [...this.byNamespace.entries()].map(([name, entries]) => ({
459
+ const summaries = [...this.byNamespace].map(([name, entries]) => ({
234
460
  name,
235
461
  importPath: `@gtkx/gi/${namespaceDirectory({ name })}`,
236
462
  symbols: entries.filter((entry) => entry.kind !== "element").length,
237
463
  elements: entries.filter((entry) => entry.kind === "element").length,
238
464
  }));
465
+
239
466
  return sortStringsBy(summaries, (summary) => namespaceOrder(summary.name));
240
467
  }
241
468
 
242
469
  symbolNames(namespaceName: string): string[] {
243
470
  const namespace = this.findNamespace(namespaceName);
244
- if (namespace === undefined) return [];
471
+
472
+ if (namespace === undefined) {
473
+ return [];
474
+ }
475
+
245
476
  const entries = this.byNamespace.get(namespace.name) ?? [];
477
+
246
478
  return sortStrings(entries.map((entry) => entry.name));
247
479
  }
248
480
 
249
481
  overview(): string {
250
482
  const rows = this.namespaces().map(
251
- (summary) => `| ${summary.name} | \`${summary.importPath}\` | ${summary.symbols} | ${summary.elements} |`,
483
+ (summary) =>
484
+ `| ${summary.name} | \`${summary.importPath}\` | ${String(summary.symbols)} | ` +
485
+ `${String(summary.elements)} |`,
252
486
  );
487
+
253
488
  const librariesList = this.libraries.map((library) => `\`${library}\``).join(", ");
489
+
254
490
  return [
255
491
  "# API Reference",
256
492
  "",
257
- `Generated bindings for ${librariesList} and the namespaces they pull in. Classes, interfaces, records, enums, callbacks, aliases, functions, and constants are imported from \`@gtkx/gi/<namespace>\`; JSX elements are imported from \`@gtkx/jsx/<namespace>\`.`,
493
+ `Generated bindings for ${librariesList} and the namespaces they pull in. Classes, interfaces, ` +
494
+ "records, enums, callbacks, aliases, functions, and constants are imported from " +
495
+ "`@gtkx/gi/<namespace>`; JSX elements are imported from `@gtkx/jsx/<namespace>`.",
258
496
  "",
259
- "Every symbol has a reference page addressed by its qualified name (for example `Gtk.Button`, `Gtk.Orientation`, `GLib.idleAdd`) and every JSX element by its element name (for example `GtkButton`).",
497
+ "Every symbol has a reference page addressed by its qualified name (for example `Gtk.Button`, " +
498
+ "`Gtk.Orientation`, `GLib.idleAdd`) and every JSX element by its element name " +
499
+ "(for example `GtkButton`).",
260
500
  "",
261
501
  "| Namespace | Import | Symbols | JSX elements |",
262
502
  "| --- | --- | --- | --- |",
@@ -267,95 +507,51 @@ class ApiReference {
267
507
 
268
508
  namespaceOverview(name: string): string | undefined {
269
509
  const namespace = this.findNamespace(name);
270
- if (namespace === undefined) return undefined;
510
+
511
+ if (namespace === undefined) {
512
+ return undefined;
513
+ }
514
+
271
515
  const entries = this.byNamespace.get(namespace.name) ?? [];
272
516
  const directory = namespaceDirectory(namespace);
517
+
273
518
  const lines = [
274
519
  `# ${namespace.name}`,
275
520
  "",
276
521
  `\`\`\`ts\nimport * as ${namespace.name} from "@gtkx/gi/${directory}";\n\`\`\``,
277
522
  ];
523
+
278
524
  for (const kind of API_SYMBOL_KINDS) {
279
525
  const names = entries.filter((entry) => entry.kind === kind).map((entry) => entry.name);
280
- if (names.length === 0) continue;
526
+
527
+ if (names.length === 0) {
528
+ continue;
529
+ }
530
+
281
531
  lines.push(
282
532
  "",
283
- `## ${KIND_SECTION_TITLES[kind]} (${names.length})`,
533
+ `## ${KIND_SECTION_TITLES[kind]} (${String(names.length)})`,
284
534
  "",
285
535
  sortStrings(names)
286
536
  .map((symbolName) => `\`${symbolName}\``)
287
537
  .join(", "),
288
538
  );
289
539
  }
540
+
290
541
  lines.push("");
542
+
291
543
  return lines.join("\n");
292
544
  }
293
545
  }
294
546
 
295
547
  export type { ApiReference };
296
-
297
- export const loadApiReference = (options: ApiReferenceOptions): ApiReference => new ApiReference(options);
298
-
299
- const classEntries = (namespace: GirNamespace): GiSymbolEntry[] => {
300
- const entries: GiSymbolEntry[] = [];
301
- for (const klass of [...namespace.classes, ...namespace.interfaces]) {
302
- if (!klass.introspectable || klass.name.length === 0) continue;
303
- const kind = klass.isInterface ? "interface" : "class";
304
- entries.push({ kind, namespace, name: toPascalCase(klass.name), doc: klass.doc, klass });
305
- }
306
- return entries;
307
- };
308
-
309
- const recordEntries = (library: Library, namespace: GirNamespace): GiSymbolEntry[] => {
310
- const entries: GiSymbolEntry[] = [];
311
- for (const record of namespace.records) {
312
- if (!record.introspectable || record.isVtable || record.name.length === 0) continue;
313
- if (isClassStructRecord(library, namespace.name, record)) continue;
314
- entries.push({ kind: "record", namespace, name: record.name, doc: record.doc, record });
315
- }
316
- return entries;
317
- };
318
-
319
- const valueEntries = (namespace: GirNamespace): GiSymbolEntry[] => [
320
- ...namespace.enums
321
- .filter((enumeration) => enumeration.introspectable)
322
- .map<GiSymbolEntry>((enumeration) => ({
323
- kind: "enum",
324
- namespace,
325
- name: enumeration.name,
326
- doc: enumeration.doc,
327
- enumeration,
328
- })),
329
- ...namespace.callbacks
330
- .filter((callback) => callback.introspectable)
331
- .map<GiSymbolEntry>((callback) => ({
332
- kind: "callback",
333
- namespace,
334
- name: callback.name,
335
- doc: callback.doc,
336
- callback,
337
- })),
338
- ...namespace.aliases.map<GiSymbolEntry>((alias) => ({
339
- kind: "alias",
340
- namespace,
341
- name: alias.name,
342
- doc: alias.doc,
343
- alias,
344
- })),
345
- ...namespace.constants.map<GiSymbolEntry>((constant) => ({
346
- kind: "constant",
347
- namespace,
348
- name: constant.name,
349
- doc: constant.doc,
350
- constant,
351
- })),
352
- ];
353
-
354
- const searchScore = (entry: SymbolEntry, query: string): number => {
355
- const name = entry.name.toLowerCase();
356
- const qualified = `${entry.namespace.name.toLowerCase()}.${name}`;
357
- if (name === query || qualified === query) return 3;
358
- if (name.startsWith(query)) return 2;
359
- if (name.includes(query) || qualified.includes(query)) return 1;
360
- return 0;
548
+ export {
549
+ API_SYMBOL_KINDS,
550
+ loadApiReference,
551
+ type ApiReferenceOptions,
552
+ type ApiSymbolKind,
553
+ type ApiSymbol,
554
+ type ApiNamespaceSummary,
555
+ type ApiLookupResult,
556
+ type ApiSearchOptions,
361
557
  };