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

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