@gtkx/codegen 1.0.0-rc.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (410) hide show
  1. package/README.md +5 -5
  2. package/dist/analysis/descriptor-render.d.ts +8 -1
  3. package/dist/analysis/descriptor-render.d.ts.map +1 -1
  4. package/dist/analysis/descriptor-render.js +37 -24
  5. package/dist/analysis/descriptor-render.js.map +1 -1
  6. package/dist/analysis/descriptor.d.ts +1 -1
  7. package/dist/analysis/descriptor.d.ts.map +1 -1
  8. package/dist/analysis/descriptor.js.map +1 -1
  9. package/dist/analysis/inheritance.d.ts +1 -2
  10. package/dist/analysis/inheritance.d.ts.map +1 -1
  11. package/dist/analysis/inheritance.js +25 -22
  12. package/dist/analysis/inheritance.js.map +1 -1
  13. package/dist/analysis/nul-terminated-bytes.d.ts +5 -0
  14. package/dist/analysis/nul-terminated-bytes.d.ts.map +1 -0
  15. package/dist/analysis/nul-terminated-bytes.js +18 -0
  16. package/dist/analysis/nul-terminated-bytes.js.map +1 -0
  17. package/dist/analysis/param-capability.d.ts +5 -0
  18. package/dist/analysis/param-capability.d.ts.map +1 -0
  19. package/dist/analysis/param-capability.js +130 -0
  20. package/dist/analysis/param-capability.js.map +1 -0
  21. package/dist/analysis/param-structure.d.ts +11 -4
  22. package/dist/analysis/param-structure.d.ts.map +1 -1
  23. package/dist/analysis/param-structure.js +40 -14
  24. package/dist/analysis/param-structure.js.map +1 -1
  25. package/dist/analysis/type-shape.d.ts +8 -0
  26. package/dist/analysis/type-shape.d.ts.map +1 -0
  27. package/dist/analysis/type-shape.js +12 -0
  28. package/dist/analysis/type-shape.js.map +1 -0
  29. package/dist/compile.d.ts +1 -1
  30. package/dist/compile.d.ts.map +1 -1
  31. package/dist/compile.js.map +1 -1
  32. package/dist/docs/api-reference.d.ts +2 -2
  33. package/dist/docs/api-reference.d.ts.map +1 -1
  34. package/dist/docs/api-reference.js +7 -14
  35. package/dist/docs/api-reference.js.map +1 -1
  36. package/dist/docs/element-page.d.ts +4 -4
  37. package/dist/docs/element-page.d.ts.map +1 -1
  38. package/dist/docs/element-page.js +32 -20
  39. package/dist/docs/element-page.js.map +1 -1
  40. package/dist/docs/handwritten-props.d.ts +9 -0
  41. package/dist/docs/handwritten-props.d.ts.map +1 -0
  42. package/dist/docs/handwritten-props.js +149 -0
  43. package/dist/docs/handwritten-props.js.map +1 -0
  44. package/dist/docs/pipeline.js +2 -2
  45. package/dist/docs/pipeline.js.map +1 -1
  46. package/dist/docs/render.d.ts +25 -5
  47. package/dist/docs/render.d.ts.map +1 -1
  48. package/dist/docs/render.js +84 -22
  49. package/dist/docs/render.js.map +1 -1
  50. package/dist/docs/symbol-page.d.ts +17 -0
  51. package/dist/docs/symbol-page.d.ts.map +1 -1
  52. package/dist/docs/symbol-page.js +128 -43
  53. package/dist/docs/symbol-page.js.map +1 -1
  54. package/dist/fingerprint.d.ts +1 -1
  55. package/dist/fingerprint.d.ts.map +1 -1
  56. package/dist/fingerprint.js.map +1 -1
  57. package/dist/gir/ancestry.d.ts +2 -2
  58. package/dist/gir/ancestry.d.ts.map +1 -1
  59. package/dist/gir/ancestry.js +11 -1
  60. package/dist/gir/ancestry.js.map +1 -1
  61. package/dist/gir/annotations.d.ts +22 -0
  62. package/dist/gir/annotations.d.ts.map +1 -0
  63. package/dist/gir/annotations.js +15 -0
  64. package/dist/gir/annotations.js.map +1 -0
  65. package/dist/gir/callback.d.ts +1 -0
  66. package/dist/gir/callback.d.ts.map +1 -1
  67. package/dist/gir/callback.js +1 -0
  68. package/dist/gir/callback.js.map +1 -1
  69. package/dist/gir/class.d.ts +32 -1
  70. package/dist/gir/class.d.ts.map +1 -1
  71. package/dist/gir/class.js +8 -3
  72. package/dist/gir/class.js.map +1 -1
  73. package/dist/gir/enum.d.ts +21 -1
  74. package/dist/gir/enum.d.ts.map +1 -1
  75. package/dist/gir/enum.js +9 -9
  76. package/dist/gir/enum.js.map +1 -1
  77. package/dist/gir/field.d.ts +19 -3
  78. package/dist/gir/field.d.ts.map +1 -1
  79. package/dist/gir/field.js +7 -8
  80. package/dist/gir/field.js.map +1 -1
  81. package/dist/gir/function.d.ts +15 -0
  82. package/dist/gir/function.d.ts.map +1 -1
  83. package/dist/gir/function.js.map +1 -1
  84. package/dist/gir/libraries.d.ts +1 -3
  85. package/dist/gir/libraries.d.ts.map +1 -1
  86. package/dist/gir/libraries.js +0 -1
  87. package/dist/gir/libraries.js.map +1 -1
  88. package/dist/gir/library.d.ts +36 -0
  89. package/dist/gir/library.d.ts.map +1 -1
  90. package/dist/gir/library.js +34 -0
  91. package/dist/gir/library.js.map +1 -1
  92. package/dist/gir/namespace.d.ts +38 -0
  93. package/dist/gir/namespace.d.ts.map +1 -1
  94. package/dist/gir/namespace.js +4 -5
  95. package/dist/gir/namespace.js.map +1 -1
  96. package/dist/gir/parameter.d.ts +39 -0
  97. package/dist/gir/parameter.d.ts.map +1 -1
  98. package/dist/gir/parameter.js +7 -3
  99. package/dist/gir/parameter.js.map +1 -1
  100. package/dist/gir/parse.d.ts +3 -1
  101. package/dist/gir/parse.d.ts.map +1 -1
  102. package/dist/gir/parse.js +6 -3
  103. package/dist/gir/parse.js.map +1 -1
  104. package/dist/gir/primitives.d.ts +1 -0
  105. package/dist/gir/primitives.d.ts.map +1 -1
  106. package/dist/gir/primitives.js.map +1 -1
  107. package/dist/gir/property.d.ts +16 -0
  108. package/dist/gir/property.d.ts.map +1 -1
  109. package/dist/gir/property.js +3 -3
  110. package/dist/gir/property.js.map +1 -1
  111. package/dist/gir/record.d.ts +22 -0
  112. package/dist/gir/record.d.ts.map +1 -1
  113. package/dist/gir/record.js +3 -2
  114. package/dist/gir/record.js.map +1 -1
  115. package/dist/gir/size.d.ts +5 -4
  116. package/dist/gir/size.d.ts.map +1 -1
  117. package/dist/gir/size.js.map +1 -1
  118. package/dist/gir/type-id.d.ts +35 -0
  119. package/dist/gir/type-id.d.ts.map +1 -1
  120. package/dist/gir/type-id.js +1 -0
  121. package/dist/gir/type-id.js.map +1 -1
  122. package/dist/gir/type-ref.d.ts.map +1 -1
  123. package/dist/gir/type-ref.js +1 -0
  124. package/dist/gir/type-ref.js.map +1 -1
  125. package/dist/gir/type.d.ts +20 -0
  126. package/dist/gir/type.d.ts.map +1 -1
  127. package/dist/gir/type.js.map +1 -1
  128. package/dist/khronos/args.d.ts +7 -6
  129. package/dist/khronos/args.d.ts.map +1 -1
  130. package/dist/khronos/args.js +28 -6
  131. package/dist/khronos/args.js.map +1 -1
  132. package/dist/khronos/doc-context.d.ts +29 -0
  133. package/dist/khronos/doc-context.d.ts.map +1 -0
  134. package/dist/khronos/doc-context.js +29 -0
  135. package/dist/khronos/doc-context.js.map +1 -0
  136. package/dist/khronos/extensions.d.ts +13 -0
  137. package/dist/khronos/extensions.d.ts.map +1 -0
  138. package/dist/khronos/extensions.js +49 -0
  139. package/dist/khronos/extensions.js.map +1 -0
  140. package/dist/khronos/jsdoc.d.ts +17 -11
  141. package/dist/khronos/jsdoc.d.ts.map +1 -1
  142. package/dist/khronos/jsdoc.js +104 -46
  143. package/dist/khronos/jsdoc.js.map +1 -1
  144. package/dist/khronos/model.d.ts +42 -3
  145. package/dist/khronos/model.d.ts.map +1 -1
  146. package/dist/khronos/model.js +218 -63
  147. package/dist/khronos/model.js.map +1 -1
  148. package/dist/khronos/modules.d.ts +9 -6
  149. package/dist/khronos/modules.d.ts.map +1 -1
  150. package/dist/khronos/modules.js +96 -26
  151. package/dist/khronos/modules.js.map +1 -1
  152. package/dist/khronos/notes.d.ts +19 -0
  153. package/dist/khronos/notes.d.ts.map +1 -0
  154. package/dist/khronos/notes.js +35 -0
  155. package/dist/khronos/notes.js.map +1 -0
  156. package/dist/khronos/param-pair.d.ts +1 -1
  157. package/dist/khronos/param-pair.d.ts.map +1 -1
  158. package/dist/khronos/param-pair.js.map +1 -1
  159. package/dist/khronos/pipeline.d.ts +3 -1
  160. package/dist/khronos/pipeline.d.ts.map +1 -1
  161. package/dist/khronos/pipeline.js +58 -27
  162. package/dist/khronos/pipeline.js.map +1 -1
  163. package/dist/khronos/plan.d.ts +3 -3
  164. package/dist/khronos/plan.d.ts.map +1 -1
  165. package/dist/khronos/plan.js +2 -2
  166. package/dist/khronos/plan.js.map +1 -1
  167. package/dist/khronos/render.d.ts +8 -6
  168. package/dist/khronos/render.d.ts.map +1 -1
  169. package/dist/khronos/render.js +35 -26
  170. package/dist/khronos/render.js.map +1 -1
  171. package/dist/khronos/select.d.ts +21 -4
  172. package/dist/khronos/select.d.ts.map +1 -1
  173. package/dist/khronos/select.js +47 -34
  174. package/dist/khronos/select.js.map +1 -1
  175. package/dist/react/element-config.d.ts +2 -2
  176. package/dist/react/element-config.d.ts.map +1 -1
  177. package/dist/react/element-config.js.map +1 -1
  178. package/dist/runner.d.ts +1 -7
  179. package/dist/runner.d.ts.map +1 -1
  180. package/dist/runner.js.map +1 -1
  181. package/dist/store/compile-store.d.ts +1 -1
  182. package/dist/store/compile-store.d.ts.map +1 -1
  183. package/dist/store/compile-store.js.map +1 -1
  184. package/dist/store/gi/callable-doc.d.ts +11 -0
  185. package/dist/store/gi/callable-doc.d.ts.map +1 -0
  186. package/dist/store/gi/callable-doc.js +62 -0
  187. package/dist/store/gi/callable-doc.js.map +1 -0
  188. package/dist/store/gi/callables.d.ts +3 -1
  189. package/dist/store/gi/callables.d.ts.map +1 -1
  190. package/dist/store/gi/callables.js +12 -12
  191. package/dist/store/gi/callables.js.map +1 -1
  192. package/dist/store/gi/callback.d.ts.map +1 -1
  193. package/dist/store/gi/callback.js +2 -2
  194. package/dist/store/gi/callback.js.map +1 -1
  195. package/dist/store/gi/class.d.ts.map +1 -1
  196. package/dist/store/gi/class.js +5 -3
  197. package/dist/store/gi/class.js.map +1 -1
  198. package/dist/store/gi/closure-invocation.d.ts +4 -0
  199. package/dist/store/gi/closure-invocation.d.ts.map +1 -0
  200. package/dist/store/gi/closure-invocation.js +22 -0
  201. package/dist/store/gi/closure-invocation.js.map +1 -0
  202. package/dist/store/gi/constant.d.ts.map +1 -1
  203. package/dist/store/gi/constant.js +3 -2
  204. package/dist/store/gi/constant.js.map +1 -1
  205. package/dist/store/gi/constructor-props.d.ts.map +1 -1
  206. package/dist/store/gi/constructor-props.js +18 -20
  207. package/dist/store/gi/constructor-props.js.map +1 -1
  208. package/dist/store/gi/doc-spec.d.ts +14 -0
  209. package/dist/store/gi/doc-spec.d.ts.map +1 -0
  210. package/dist/store/gi/doc-spec.js +23 -0
  211. package/dist/store/gi/doc-spec.js.map +1 -0
  212. package/dist/store/gi/enum.d.ts.map +1 -1
  213. package/dist/store/gi/enum.js +29 -16
  214. package/dist/store/gi/enum.js.map +1 -1
  215. package/dist/store/gi/function.d.ts.map +1 -1
  216. package/dist/store/gi/function.js +27 -12
  217. package/dist/store/gi/function.js.map +1 -1
  218. package/dist/store/gi/interface.d.ts.map +1 -1
  219. package/dist/store/gi/interface.js +130 -16
  220. package/dist/store/gi/interface.js.map +1 -1
  221. package/dist/store/gi/item-comparators.d.ts.map +1 -1
  222. package/dist/store/gi/item-comparators.js +3 -5
  223. package/dist/store/gi/item-comparators.js.map +1 -1
  224. package/dist/store/gi/method.d.ts +9 -1
  225. package/dist/store/gi/method.d.ts.map +1 -1
  226. package/dist/store/gi/method.js +69 -26
  227. package/dist/store/gi/method.js.map +1 -1
  228. package/dist/store/gi/param-marshal.d.ts +4 -1
  229. package/dist/store/gi/param-marshal.d.ts.map +1 -1
  230. package/dist/store/gi/param-marshal.js +5 -1
  231. package/dist/store/gi/param-marshal.js.map +1 -1
  232. package/dist/store/gi/pipeline.d.ts.map +1 -1
  233. package/dist/store/gi/pipeline.js +3 -2
  234. package/dist/store/gi/pipeline.js.map +1 -1
  235. package/dist/store/gi/properties.d.ts.map +1 -1
  236. package/dist/store/gi/properties.js +2 -2
  237. package/dist/store/gi/properties.js.map +1 -1
  238. package/dist/store/gi/property-accessor.d.ts +3 -1
  239. package/dist/store/gi/property-accessor.d.ts.map +1 -1
  240. package/dist/store/gi/property-accessor.js +6 -5
  241. package/dist/store/gi/property-accessor.js.map +1 -1
  242. package/dist/store/gi/record-constructor.d.ts.map +1 -1
  243. package/dist/store/gi/record-constructor.js +3 -1
  244. package/dist/store/gi/record-constructor.js.map +1 -1
  245. package/dist/store/gi/record-field-accessor.d.ts +3 -1
  246. package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
  247. package/dist/store/gi/record-field-accessor.js +3 -2
  248. package/dist/store/gi/record-field-accessor.js.map +1 -1
  249. package/dist/store/gi/record-layout.js +1 -1
  250. package/dist/store/gi/record-layout.js.map +1 -1
  251. package/dist/store/gi/record.d.ts.map +1 -1
  252. package/dist/store/gi/record.js +3 -2
  253. package/dist/store/gi/record.js.map +1 -1
  254. package/dist/store/gi/registration.d.ts +1 -1
  255. package/dist/store/gi/registration.js +2 -2
  256. package/dist/store/gi/registration.js.map +1 -1
  257. package/dist/store/gi/runtime-override.d.ts +2 -1
  258. package/dist/store/gi/runtime-override.d.ts.map +1 -1
  259. package/dist/store/gi/runtime-override.js +8 -5
  260. package/dist/store/gi/runtime-override.js.map +1 -1
  261. package/dist/store/gi/signal.d.ts.map +1 -1
  262. package/dist/store/gi/signal.js +14 -15
  263. package/dist/store/gi/signal.js.map +1 -1
  264. package/dist/store/gi/value-marshalable.d.ts +1 -2
  265. package/dist/store/gi/value-marshalable.d.ts.map +1 -1
  266. package/dist/store/gi/value-marshalable.js +1 -1
  267. package/dist/store/gi/value-marshalable.js.map +1 -1
  268. package/dist/store/gi/vtable.d.ts +16 -1
  269. package/dist/store/gi/vtable.d.ts.map +1 -1
  270. package/dist/store/gi/vtable.js +214 -51
  271. package/dist/store/gi/vtable.js.map +1 -1
  272. package/dist/store/jsx/element-components.d.ts +1 -1
  273. package/dist/store/jsx/element-components.d.ts.map +1 -1
  274. package/dist/store/jsx/element-components.js +6 -4
  275. package/dist/store/jsx/element-components.js.map +1 -1
  276. package/dist/store/jsx/element-prop-imports.d.ts +1 -3
  277. package/dist/store/jsx/element-prop-imports.d.ts.map +1 -1
  278. package/dist/store/jsx/element-prop-imports.js.map +1 -1
  279. package/dist/store/jsx/element-prop-types.d.ts +3 -0
  280. package/dist/store/jsx/element-prop-types.d.ts.map +1 -1
  281. package/dist/store/jsx/element-prop-types.js +7 -1
  282. package/dist/store/jsx/element-prop-types.js.map +1 -1
  283. package/dist/store/jsx/intrinsic-elements.d.ts +4 -0
  284. package/dist/store/jsx/intrinsic-elements.d.ts.map +1 -1
  285. package/dist/store/jsx/intrinsic-elements.js.map +1 -1
  286. package/dist/store/jsx/jsx.d.ts.map +1 -1
  287. package/dist/store/jsx/jsx.js +7 -6
  288. package/dist/store/jsx/jsx.js.map +1 -1
  289. package/dist/store/jsx/metadata.js +2 -2
  290. package/dist/store/jsx/metadata.js.map +1 -1
  291. package/dist/store/jsx/pipeline.d.ts +1 -1
  292. package/dist/store/jsx/pipeline.d.ts.map +1 -1
  293. package/dist/store/jsx/pipeline.js.map +1 -1
  294. package/dist/store/jsx/props.d.ts +1 -7
  295. package/dist/store/jsx/props.d.ts.map +1 -1
  296. package/dist/store/jsx/props.js +14 -6
  297. package/dist/store/jsx/props.js.map +1 -1
  298. package/dist/writer/context.d.ts +2 -1
  299. package/dist/writer/context.d.ts.map +1 -1
  300. package/dist/writer/context.js +3 -0
  301. package/dist/writer/context.js.map +1 -1
  302. package/dist/writer/doc-tags.d.ts +21 -0
  303. package/dist/writer/doc-tags.d.ts.map +1 -0
  304. package/dist/writer/doc-tags.js +38 -0
  305. package/dist/writer/doc-tags.js.map +1 -0
  306. package/dist/writer/doc.d.ts +3 -1
  307. package/dist/writer/doc.d.ts.map +1 -1
  308. package/dist/writer/doc.js +19 -6
  309. package/dist/writer/doc.js.map +1 -1
  310. package/dist/writer/gtk-doc.d.ts +1 -1
  311. package/dist/writer/gtk-doc.d.ts.map +1 -1
  312. package/dist/writer/gtk-doc.js +64 -15
  313. package/dist/writer/gtk-doc.js.map +1 -1
  314. package/dist/writer/module.d.ts +8 -2
  315. package/dist/writer/module.d.ts.map +1 -1
  316. package/dist/writer/module.js +13 -1
  317. package/dist/writer/module.js.map +1 -1
  318. package/overrides/gdk/rgba.ts.ejs +26 -0
  319. package/overrides/gobject/object.ts.ejs +48 -3
  320. package/overrides/gobject/value.ts.ejs +7 -0
  321. package/overrides/graphene/structs.ts.ejs +55 -0
  322. package/package.json +4 -4
  323. package/src/analysis/descriptor-render.ts +47 -28
  324. package/src/analysis/descriptor.ts +0 -3
  325. package/src/analysis/inheritance.ts +35 -34
  326. package/src/analysis/nul-terminated-bytes.ts +31 -0
  327. package/src/analysis/param-capability.ts +172 -0
  328. package/src/analysis/param-structure.ts +83 -23
  329. package/src/analysis/type-shape.ts +24 -0
  330. package/src/compile.ts +1 -1
  331. package/src/docs/api-reference.ts +36 -25
  332. package/src/docs/element-page.ts +53 -47
  333. package/src/docs/handwritten-props.ts +230 -0
  334. package/src/docs/pipeline.ts +2 -2
  335. package/src/docs/render.ts +146 -32
  336. package/src/docs/symbol-page.ts +224 -79
  337. package/src/fingerprint.ts +0 -1
  338. package/src/gir/ancestry.ts +15 -1
  339. package/src/gir/annotations.ts +37 -0
  340. package/src/gir/callback.ts +2 -0
  341. package/src/gir/class.ts +42 -4
  342. package/src/gir/enum.ts +30 -10
  343. package/src/gir/field.ts +24 -9
  344. package/src/gir/function.ts +15 -0
  345. package/src/gir/libraries.ts +11 -3
  346. package/src/gir/library.ts +51 -2
  347. package/src/gir/namespace.ts +41 -5
  348. package/src/gir/parameter.ts +47 -3
  349. package/src/gir/parse.ts +8 -2
  350. package/src/gir/primitives.ts +1 -0
  351. package/src/gir/property.ts +18 -3
  352. package/src/gir/record.ts +24 -2
  353. package/src/gir/size.ts +8 -3
  354. package/src/gir/type-id.ts +49 -3
  355. package/src/gir/type-ref.ts +1 -0
  356. package/src/gir/type.ts +50 -6
  357. package/src/khronos/args.ts +36 -13
  358. package/src/khronos/doc-context.ts +62 -0
  359. package/src/khronos/extensions.ts +85 -0
  360. package/src/khronos/jsdoc.ts +152 -56
  361. package/src/khronos/model.ts +314 -69
  362. package/src/khronos/modules.ts +134 -40
  363. package/src/khronos/notes.ts +74 -0
  364. package/src/khronos/param-pair.ts +1 -1
  365. package/src/khronos/pipeline.ts +94 -41
  366. package/src/khronos/plan.ts +4 -5
  367. package/src/khronos/render.ts +62 -50
  368. package/src/khronos/select.ts +91 -50
  369. package/src/react/element-config.ts +2 -2
  370. package/src/runner.ts +1 -8
  371. package/src/store/compile-store.ts +1 -1
  372. package/src/store/gi/callable-doc.ts +102 -0
  373. package/src/store/gi/callables.ts +18 -12
  374. package/src/store/gi/callback.ts +3 -2
  375. package/src/store/gi/class.ts +6 -3
  376. package/src/store/gi/closure-invocation.ts +26 -0
  377. package/src/store/gi/constant.ts +3 -4
  378. package/src/store/gi/constructor-props.ts +19 -23
  379. package/src/store/gi/doc-spec.ts +38 -0
  380. package/src/store/gi/enum.ts +55 -20
  381. package/src/store/gi/function.ts +43 -21
  382. package/src/store/gi/interface.ts +214 -26
  383. package/src/store/gi/item-comparators.ts +3 -5
  384. package/src/store/gi/method.ts +98 -42
  385. package/src/store/gi/param-marshal.ts +15 -1
  386. package/src/store/gi/pipeline.ts +7 -2
  387. package/src/store/gi/properties.ts +3 -2
  388. package/src/store/gi/property-accessor.ts +9 -4
  389. package/src/store/gi/record-constructor.ts +6 -1
  390. package/src/store/gi/record-field-accessor.ts +5 -3
  391. package/src/store/gi/record-layout.ts +1 -1
  392. package/src/store/gi/record.ts +8 -2
  393. package/src/store/gi/registration.ts +3 -3
  394. package/src/store/gi/runtime-override.ts +13 -6
  395. package/src/store/gi/signal.ts +19 -20
  396. package/src/store/gi/value-marshalable.ts +1 -1
  397. package/src/store/gi/vtable.ts +361 -60
  398. package/src/store/jsx/element-components.ts +8 -5
  399. package/src/store/jsx/element-prop-imports.ts +1 -3
  400. package/src/store/jsx/element-prop-types.ts +10 -1
  401. package/src/store/jsx/intrinsic-elements.ts +4 -0
  402. package/src/store/jsx/jsx.ts +8 -6
  403. package/src/store/jsx/metadata.ts +2 -2
  404. package/src/store/jsx/pipeline.ts +1 -1
  405. package/src/store/jsx/props.ts +20 -7
  406. package/src/writer/context.ts +5 -1
  407. package/src/writer/doc-tags.ts +70 -0
  408. package/src/writer/doc.ts +29 -6
  409. package/src/writer/gtk-doc.ts +82 -15
  410. package/src/writer/module.ts +25 -2
@@ -1 +1 @@
1
- {"version":3,"file":"class.js","sourceRoot":"","sources":["../../../src/store/gi/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAI5D,OAAO,EACH,uBAAuB,EACvB,6BAA6B,EAC7B,8BAA8B,EAC9B,cAAc,GAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAyB,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAEH,2BAA2B,EAC3B,eAAe,EACf,gBAAgB,EAEhB,aAAa,EACb,yBAAyB,EACzB,gBAAgB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,8BAA8B,EAAE,eAAe,EAAyB,MAAM,wBAAwB,CAAC;AAChH,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE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AAU,CAAC,QAAQ,CAAC,CAAC,CAAC;AACtF,CAAC,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import { pascalCase, toCamelIdentifier } from \"@gtkx/utils\";\nimport type { GirClass } from \"../../gir/class.js\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport {\n collectInheritedMethods,\n collectInheritedPropertyTypes,\n collectInterfaceMergeOmissions,\n conflictRename,\n type InheritedMethods,\n} from \"../../analysis/inheritance.js\";\nimport { ancestorChain, type ResolvedAncestor } from \"../../gir/ancestry.js\";\nimport { splitOptionalNamespace } from \"../../gir/type-ref.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\nimport { indentMembers } from \"../../writer/emit.js\";\nimport {\n type Callables,\n classConstructorMemberNames,\n dedupeCallables,\n generateBindings,\n type InstanceScope,\n instanceScope,\n renderClassInstanceMember,\n renderStaticHead,\n} from \"./callables.js\";\nimport { renderClassConstructor, renderConstructorPropsInterface } from \"./constructor-props.js\";\nimport { gtypeMemberDeclaration, renderSourceGtype } from \"./gtype-binding.js\";\nimport { methodExportName } from \"./method.js\";\nimport { renderPropertyDeclarations } from \"./properties.js\";\nimport { renderResolvedPropertyAccessor, resolveAccessor, type ResolvedAccessor } from \"./property-accessor.js\";\nimport { appendWrapperClassRegistration } from \"./registration.js\";\nimport { renderSignalDeclarations, renderSignalMembers } from \"./signal.js\";\nimport { renderVfuncMetadata } from \"./vtable.js\";\n\ntype ImplementedRef = {\n typeRef: string;\n makerRef: string;\n interfaceKlass: GirClass;\n interfaceNamespace: string;\n};\n\ntype MemberDeclarationsOptions = {\n context: ModuleContext;\n klass: GirClass;\n className: string;\n accessors: ResolvedAccessor[];\n implemented: ImplementedRef[];\n};\n\ntype ClassMembers = { members: string[]; accessors: ResolvedAccessor[] };\n\ntype AppendInstanceMethodsOptions = {\n context: ModuleContext;\n methods: GirFunction[];\n scope: InstanceScope;\n inherited: InheritedMethods;\n members: string[];\n claimedNames: Set<string>;\n className: string;\n};\n\nconst generateClass = (context: ModuleContext, klass: GirClass): void => {\n if (!klass.introspectable) {\n return;\n }\n\n if (klass.name.length === 0) {\n return;\n }\n\n const className = pascalCase(klass.name);\n\n const callables: Callables = {\n constructors: dedupeCallables(klass.constructors),\n functions: dedupeCallables(klass.functions),\n methods: dedupeCallables(klass.methods),\n };\n\n generateBindings(context, callables);\n const parentExpression = resolveParent(context, klass);\n const extendsClause = renderExtendsClause(context, parentExpression, callables);\n const implemented = resolveImplementedRefs(context, klass);\n const typeRefs = implemented.map((ref) => ref.typeRef);\n const implementsClause = typeRefs.length === 0 ? \"\" : ` implements ${typeRefs.join(\", \")}`;\n const { members, accessors } = renderClassMembers(context, klass, callables, parentExpression !== undefined);\n const body = indentMembers(members);\n\n context.module.appendDeclaration(\n `${renderJsDoc(klass.doc)}export class ${className}${extendsClause}${implementsClause} {\\n${body}\\n}`,\n );\n\n context.module.appendDeclaration(renderConstructorPropsInterface(context, klass, className));\n appendMemberDeclarations({ context, klass, className, accessors, implemented });\n appendInstallMixins(context, className, implemented);\n appendClassRegistrations(context, klass, className);\n};\n\nconst appendMemberDeclarations = (options: MemberDeclarationsOptions): void => {\n const { context, klass, className, accessors, implemented } = options;\n\n for (const declaration of renderPropertyDeclarations(context, klass, className, accessors)) {\n context.module.appendDeclaration(declaration);\n }\n\n for (const declaration of renderSignalDeclarations(context, klass, className, false)) {\n context.module.appendDeclaration(declaration);\n }\n\n appendInterfaceMerge(context, klass, className, implemented);\n};\n\nconst appendInterfaceMerge = (\n context: ModuleContext,\n klass: GirClass,\n className: string,\n implemented: ImplementedRef[],\n): void => {\n if (implemented.length === 0) {\n return;\n }\n\n const mergeRefs = implemented.map((ref) => interfaceMergeRef(context, klass, ref));\n context.module.appendDeclaration(`export interface ${className} extends ${mergeRefs.join(\", \")} {}`);\n};\n\nconst renderClassMembers = (\n context: ModuleContext,\n klass: GirClass,\n callables: Callables,\n hasParent: boolean,\n): ClassMembers => {\n const className = pascalCase(klass.name);\n const members: string[] = [gtypeMemberDeclaration(context)];\n const constructorBlock = renderClassConstructor(context, klass, className, hasParent);\n\n if (constructorBlock !== undefined) {\n members.push(constructorBlock);\n }\n\n const claimedNames: Set<string> = new Set();\n members.push(...renderStaticHead(context, callables, className));\n const inherited = collectInheritedMethods(context, klass);\n const scope = instanceScope(className, callables);\n\n appendInstanceMethods({\n context,\n methods: callables.methods,\n scope,\n inherited,\n members,\n claimedNames,\n className,\n });\n\n const inheritedPropertyTypes = collectInheritedPropertyTypes(context, klass);\n const accessors: ResolvedAccessor[] = [];\n\n for (const property of klass.properties) {\n const inheritedType = inheritedPropertyTypes.get(toCamelIdentifier(property.name));\n\n const accessor = resolveAccessor({\n context,\n property,\n claimedNames,\n methodByName: scope.methodByName,\n inheritedType,\n });\n\n if (accessor === undefined) {\n continue;\n }\n\n accessors.push(accessor);\n members.push(renderResolvedPropertyAccessor(context, property, accessor));\n }\n\n members.push(...renderSignalMembers(context, klass));\n\n return { members, accessors };\n};\n\nconst appendInstanceMethods = (options: AppendInstanceMethodsOptions): void => {\n const { context, methods, scope, inherited, members, claimedNames, className } = options;\n\n for (const callable of methods) {\n const rename = conflictRename(context, callable, inherited, className);\n const block = renderClassInstanceMember(context, callable, scope, rename);\n\n if (block === undefined) {\n continue;\n }\n\n members.push(block);\n claimedNames.add(rename ?? methodExportName(callable));\n }\n};\n\nconst appendInstallMixins = (context: ModuleContext, className: string, implemented: ImplementedRef[]): void => {\n if (implemented.length === 0) {\n return;\n }\n\n context.addRuntimeImport(\"installMixins\");\n const makers = implemented.map((ref) => ref.makerRef).join(\", \");\n context.module.appendRegistration(`installMixins(${className}, [${makers}]);`);\n};\n\nconst appendClassRegistrations = (context: ModuleContext, klass: GirClass, className: string): void => {\n const gtypeExpr = renderSourceGtype(context, klass);\n\n appendWrapperClassRegistration(context, {\n className,\n gtypeExpr,\n vfuncs: renderVfuncMetadata(context, klass),\n });\n};\n\nconst addAncestorInterfaceKeys = (context: ModuleContext, ancestor: ResolvedAncestor, keys: Set<string>): void => {\n for (const name of ancestor.klass.implements) {\n const resolved = context.library.resolveType(ancestor.namespaceName, name);\n\n if (resolved?.kind === \"interface\") {\n keys.add(`${resolved.namespace.name}.${resolved.value.name}`);\n }\n }\n};\n\nconst inheritedInterfaceKeys = (context: ModuleContext, klass: GirClass): Set<string> => {\n const keys: Set<string> = new Set();\n\n if (klass.parent === undefined) {\n return keys;\n }\n\n const parent = context.library.resolveType(context.namespace.name, klass.parent);\n\n if (parent?.kind !== \"class\") {\n return keys;\n }\n\n for (const ancestor of ancestorChain(context.library, parent.value, parent.namespace.name)) {\n addAncestorInterfaceKeys(context, ancestor, keys);\n }\n\n return keys;\n};\n\nconst interfaceMergeRef = (context: ModuleContext, klass: GirClass, ref: ImplementedRef): string => {\n const omissions = collectInterfaceMergeOmissions(context, klass, {\n klass: ref.interfaceKlass,\n namespaceName: ref.interfaceNamespace,\n });\n\n if (omissions.length === 0) {\n return ref.typeRef;\n }\n\n const keys = omissions.map((name) => JSON.stringify(name)).join(\" | \");\n\n return `Omit<${ref.typeRef}, ${keys}>`;\n};\n\nconst implementedRefFor = (\n context: ModuleContext,\n name: string,\n inherited: Set<string>,\n): ImplementedRef | undefined => {\n const resolved = context.library.resolveType(context.namespace.name, name);\n\n if (resolved?.kind !== \"interface\") {\n return undefined;\n }\n\n if (inherited.has(`${resolved.namespace.name}.${resolved.value.name}`)) {\n return undefined;\n }\n\n const pascal = pascalCase(resolved.value.name);\n\n return {\n typeRef: context.qualify(resolved.namespace.name, pascal),\n makerRef: context.qualify(resolved.namespace.name, `make${pascal}`),\n interfaceKlass: resolved.value,\n interfaceNamespace: resolved.namespace.name,\n };\n};\n\nconst resolveImplementedRefs = (context: ModuleContext, klass: GirClass): ImplementedRef[] => {\n const inherited = inheritedInterfaceKeys(context, klass);\n const refs: ImplementedRef[] = [];\n\n for (const name of klass.implements) {\n const ref = implementedRefFor(context, name, inherited);\n\n if (ref !== undefined) {\n refs.push(ref);\n }\n }\n\n return refs;\n};\n\nconst renderExtendsClause = (\n context: ModuleContext,\n parentExpression: string | undefined,\n callables: Callables,\n): string => {\n if (parentExpression === undefined) {\n return \"\";\n }\n\n const constructorNames = classConstructorMemberNames(context, callables);\n\n if (constructorNames.length === 0) {\n return ` extends ${parentExpression}`;\n }\n\n context.addRuntimeTypeImport(\"StaticBase\");\n const omitted = constructorNames.map((name) => JSON.stringify(name)).join(\" | \");\n\n return ` extends (${parentExpression} as StaticBase<typeof ${parentExpression}, ${omitted}>)`;\n};\n\nconst resolveParent = (context: ModuleContext, klass: GirClass): string | undefined => {\n if (klass.parent === undefined) {\n return undefined;\n }\n\n const [namespace, typeName] = splitOptionalNamespace(klass.parent);\n\n return context.qualify(namespace ?? context.namespace.name, pascalCase(typeName));\n};\n\nexport { generateClass };\n"]}
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../../src/store/gi/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAI5D,OAAO,EACH,uBAAuB,EACvB,6BAA6B,EAC7B,8BAA8B,EAC9B,cAAc,GAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAyB,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAEH,2BAA2B,EAC3B,eAAe,EACf,gBAAgB,EAEhB,aAAa,EACb,yBAAyB,EACzB,gBAAgB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,gBA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CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAEjF,OAAO,aAAa,gBAAgB,yBAAyB,gBAAgB,KAAK,OAAO,IAAI,CAAC;AAClG,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,OAAsB,EAAE,KAAe,EAAsB,EAAE;IAClF,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,sBAAsB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEnE,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;AACtF,CAAC,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import { pascalCase, toCamelIdentifier } from \"@gtkx/utils\";\nimport type { GirClass } from \"../../gir/class.js\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport {\n collectInheritedMethods,\n collectInheritedPropertyTypes,\n collectInterfaceMergeOmissions,\n conflictRename,\n type InheritedMethods,\n} from \"../../analysis/inheritance.js\";\nimport { ancestorChain, type ResolvedAncestor } from \"../../gir/ancestry.js\";\nimport { splitOptionalNamespace } from \"../../gir/type-ref.js\";\nimport { indentMembers } from \"../../writer/emit.js\";\nimport {\n type Callables,\n classConstructorMemberNames,\n dedupeCallables,\n generateBindings,\n type InstanceScope,\n instanceScope,\n renderClassInstanceMember,\n renderStaticHead,\n} from \"./callables.js\";\nimport { renderClassConstructor, renderConstructorPropsInterface } from \"./constructor-props.js\";\nimport { getDoc } from \"./doc-spec.js\";\nimport { gtypeMemberDeclaration, renderSourceGtype } from \"./gtype-binding.js\";\nimport { methodExportName } from \"./method.js\";\nimport { renderPropertyDeclarations } from \"./properties.js\";\nimport { renderResolvedPropertyAccessor, resolveAccessor, type ResolvedAccessor } from \"./property-accessor.js\";\nimport { appendWrapperClassRegistration } from \"./registration.js\";\nimport { renderSignalDeclarations, renderSignalMembers } from \"./signal.js\";\nimport { renderVfuncMembers, renderVfuncMetadata } from \"./vtable.js\";\n\ntype ImplementedRef = {\n typeRef: string;\n makerRef: string;\n interfaceKlass: GirClass;\n interfaceNamespace: string;\n};\n\ntype MemberDeclarationsOptions = {\n context: ModuleContext;\n klass: GirClass;\n className: string;\n accessors: ResolvedAccessor[];\n implemented: ImplementedRef[];\n};\n\ntype ClassMembers = { members: string[]; accessors: ResolvedAccessor[] };\n\ntype AppendInstanceMethodsOptions = {\n context: ModuleContext;\n methods: GirFunction[];\n scope: InstanceScope;\n inherited: InheritedMethods;\n members: string[];\n claimedNames: Set<string>;\n className: string;\n};\n\nconst generateClass = (context: ModuleContext, klass: GirClass): void => {\n if (!klass.introspectable) {\n return;\n }\n\n if (klass.name.length === 0) {\n return;\n }\n\n const className = pascalCase(klass.name);\n\n const callables: Callables = {\n constructors: dedupeCallables(klass.constructors),\n functions: dedupeCallables(klass.functions),\n methods: dedupeCallables(klass.methods),\n };\n\n generateBindings(context, callables);\n const parentExpression = resolveParent(context, klass);\n const extendsClause = renderExtendsClause(context, parentExpression, callables);\n const implemented = resolveImplementedRefs(context, klass);\n const typeRefs = implemented.map((ref) => ref.typeRef);\n const implementsClause = typeRefs.length === 0 ? \"\" : ` implements ${typeRefs.join(\", \")}`;\n const { members, accessors } = renderClassMembers(context, klass, callables, parentExpression !== undefined);\n const body = indentMembers(members);\n const doc = getDoc(klass);\n\n context.module.appendDeclaration(\n `${doc}export class ${className}${extendsClause}${implementsClause} {\\n${body}\\n}`,\n context.declaredType(className),\n );\n\n context.module.appendDeclaration(renderConstructorPropsInterface(context, klass, className));\n appendMemberDeclarations({ context, klass, className, accessors, implemented });\n appendInstallMixins(context, className, implemented);\n appendClassRegistrations(context, klass, className);\n};\n\nconst appendMemberDeclarations = (options: MemberDeclarationsOptions): void => {\n const { context, klass, className, accessors, implemented } = options;\n\n for (const declaration of renderPropertyDeclarations(context, klass, className, accessors)) {\n context.module.appendDeclaration(declaration);\n }\n\n for (const declaration of renderSignalDeclarations(context, klass, className, false)) {\n context.module.appendDeclaration(declaration);\n }\n\n appendInterfaceMerge(context, klass, className, implemented);\n};\n\nconst appendInterfaceMerge = (\n context: ModuleContext,\n klass: GirClass,\n className: string,\n implemented: ImplementedRef[],\n): void => {\n if (implemented.length === 0) {\n return;\n }\n\n const mergeRefs = implemented.map((ref) => interfaceMergeRef(context, klass, ref));\n context.module.appendDeclaration(`export interface ${className} extends ${mergeRefs.join(\", \")} {}`);\n};\n\nconst renderClassMembers = (\n context: ModuleContext,\n klass: GirClass,\n callables: Callables,\n hasParent: boolean,\n): ClassMembers => {\n const className = pascalCase(klass.name);\n const members: string[] = [gtypeMemberDeclaration(context)];\n const constructorBlock = renderClassConstructor(context, klass, className, hasParent);\n\n if (constructorBlock !== undefined) {\n members.push(constructorBlock);\n }\n\n const claimedNames: Set<string> = new Set();\n members.push(...renderStaticHead(context, callables, className));\n const inherited = collectInheritedMethods(context, klass);\n const scope = instanceScope(className, callables);\n\n appendInstanceMethods({\n context,\n methods: callables.methods,\n scope,\n inherited,\n members,\n claimedNames,\n className,\n });\n\n members.push(...renderVfuncMembers({ context, klass, mode: \"implementation\" }));\n const inheritedPropertyTypes = collectInheritedPropertyTypes(context, klass);\n const accessors: ResolvedAccessor[] = [];\n\n for (const property of klass.properties) {\n const inheritedType = inheritedPropertyTypes.get(toCamelIdentifier(property.name));\n\n const accessor = resolveAccessor({\n context,\n property,\n claimedNames,\n methodByName: scope.methodByName,\n inheritedType,\n });\n\n if (accessor === undefined) {\n continue;\n }\n\n accessors.push(accessor);\n members.push(renderResolvedPropertyAccessor(context, property, accessor));\n }\n\n members.push(...renderSignalMembers(context, klass));\n\n return { members, accessors };\n};\n\nconst appendInstanceMethods = (options: AppendInstanceMethodsOptions): void => {\n const { context, methods, scope, inherited, members, claimedNames, className } = options;\n\n for (const callable of methods) {\n const rename = conflictRename(context, callable, inherited, className);\n const block = renderClassInstanceMember(context, callable, scope, rename);\n\n if (block === undefined) {\n continue;\n }\n\n members.push(block);\n claimedNames.add(rename ?? methodExportName(callable));\n }\n};\n\nconst appendInstallMixins = (context: ModuleContext, className: string, implemented: ImplementedRef[]): void => {\n if (implemented.length === 0) {\n return;\n }\n\n context.addRuntimeImport(\"installMixins\");\n const makers = implemented.map((ref) => ref.makerRef).join(\", \");\n context.module.appendRegistration(`installMixins(${className}, [${makers}]);`);\n};\n\nconst appendClassRegistrations = (context: ModuleContext, klass: GirClass, className: string): void => {\n const gtypeExpr = renderSourceGtype(context, klass);\n\n appendWrapperClassRegistration(context, {\n className,\n gtypeExpr,\n vfuncs: renderVfuncMetadata(context, klass),\n });\n};\n\nconst addAncestorInterfaceKeys = (context: ModuleContext, ancestor: ResolvedAncestor, keys: Set<string>): void => {\n for (const name of ancestor.klass.implements) {\n const resolved = context.library.resolveType(ancestor.namespaceName, name);\n\n if (resolved?.kind === \"interface\") {\n keys.add(`${resolved.namespace.name}.${resolved.value.name}`);\n }\n }\n};\n\nconst inheritedInterfaceKeys = (context: ModuleContext, klass: GirClass): Set<string> => {\n const keys: Set<string> = new Set();\n\n if (klass.parent === undefined) {\n return keys;\n }\n\n const parent = context.library.resolveType(context.namespace.name, klass.parent);\n\n if (parent?.kind !== \"class\") {\n return keys;\n }\n\n for (const ancestor of ancestorChain(context.library, parent.value, parent.namespace.name)) {\n addAncestorInterfaceKeys(context, ancestor, keys);\n }\n\n return keys;\n};\n\nconst interfaceMergeRef = (context: ModuleContext, klass: GirClass, ref: ImplementedRef): string => {\n const omissions = collectInterfaceMergeOmissions(context, klass, {\n klass: ref.interfaceKlass,\n namespaceName: ref.interfaceNamespace,\n });\n\n if (omissions.length === 0) {\n return ref.typeRef;\n }\n\n const keys = omissions.map((name) => JSON.stringify(name)).join(\" | \");\n\n return `Omit<${ref.typeRef}, ${keys}>`;\n};\n\nconst implementedRefFor = (\n context: ModuleContext,\n name: string,\n inherited: Set<string>,\n): ImplementedRef | undefined => {\n const resolved = context.library.resolveType(context.namespace.name, name);\n\n if (resolved?.kind !== \"interface\") {\n return undefined;\n }\n\n if (inherited.has(`${resolved.namespace.name}.${resolved.value.name}`)) {\n return undefined;\n }\n\n const pascal = pascalCase(resolved.value.name);\n\n return {\n typeRef: context.qualify(resolved.namespace.name, pascal),\n makerRef: context.qualify(resolved.namespace.name, `make${pascal}`),\n interfaceKlass: resolved.value,\n interfaceNamespace: resolved.namespace.name,\n };\n};\n\nconst resolveImplementedRefs = (context: ModuleContext, klass: GirClass): ImplementedRef[] => {\n const inherited = inheritedInterfaceKeys(context, klass);\n const refs: ImplementedRef[] = [];\n\n for (const name of klass.implements) {\n const ref = implementedRefFor(context, name, inherited);\n\n if (ref !== undefined) {\n refs.push(ref);\n }\n }\n\n return refs;\n};\n\nconst renderExtendsClause = (\n context: ModuleContext,\n parentExpression: string | undefined,\n callables: Callables,\n): string => {\n if (parentExpression === undefined) {\n return \"\";\n }\n\n const constructorNames = classConstructorMemberNames(context, callables);\n\n if (constructorNames.length === 0) {\n return ` extends ${parentExpression}`;\n }\n\n context.addRuntimeTypeImport(\"StaticBase\");\n const omitted = constructorNames.map((name) => JSON.stringify(name)).join(\" | \");\n\n return ` extends (${parentExpression} as StaticBase<typeof ${parentExpression}, ${omitted}>)`;\n};\n\nconst resolveParent = (context: ModuleContext, klass: GirClass): string | undefined => {\n if (klass.parent === undefined) {\n return undefined;\n }\n\n const [namespace, typeName] = splitOptionalNamespace(klass.parent);\n\n return context.qualify(namespace ?? context.namespace.name, pascalCase(typeName));\n};\n\nexport { generateClass };\n"]}
@@ -0,0 +1,4 @@
1
+ import type { GirFunction } from "../../gir/function.js";
2
+ declare const areClosuresInvoked: (fn: GirFunction) => boolean;
3
+ export { areClosuresInvoked };
4
+ //# sourceMappingURL=closure-invocation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"closure-invocation.d.ts","sourceRoot":"","sources":["../../../src/store/gi/closure-invocation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAsBzD,QAAA,MAAM,kBAAkB,GAAI,IAAI,WAAW,KAAG,OAC+C,CAAC;AAE9F,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,22 @@
1
+ const FUNCTIONS_INVOKING_CLOSURE_PARAMETERS = new Set([
2
+ "g_binding_group_bind_with_closures",
3
+ "g_bus_own_name_on_connection_with_closures",
4
+ "g_bus_own_name_with_closures",
5
+ "g_bus_watch_name_on_connection_with_closures",
6
+ "g_bus_watch_name_with_closures",
7
+ "g_dbus_connection_register_object_with_closures",
8
+ "g_dbus_connection_register_object_with_closures2",
9
+ "g_file_copy_async_with_closures",
10
+ "g_file_move_async_with_closures",
11
+ "g_object_bind_property_with_closures",
12
+ "g_settings_bind_with_mapping_closures",
13
+ "g_signal_connect_closure",
14
+ "g_signal_connect_closure_by_id",
15
+ "g_signal_group_connect_closure",
16
+ "g_signal_override_class_closure",
17
+ "g_source_set_closure",
18
+ "gtk_closure_expression_new",
19
+ ]);
20
+ const areClosuresInvoked = (fn) => fn.cIdentifier !== undefined && FUNCTIONS_INVOKING_CLOSURE_PARAMETERS.has(fn.cIdentifier);
21
+ export { areClosuresInvoked };
22
+ //# sourceMappingURL=closure-invocation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"closure-invocation.js","sourceRoot":"","sources":["../../../src/store/gi/closure-invocation.ts"],"names":[],"mappings":"AAEA,MAAM,qCAAqC,GAAgB,IAAI,GAAG,CAAC;IAC/D,oCAAoC;IACpC,4CAA4C;IAC5C,8BAA8B;IAC9B,8CAA8C;IAC9C,gCAAgC;IAChC,iDAAiD;IACjD,kDAAkD;IAClD,iCAAiC;IACjC,iCAAiC;IACjC,sCAAsC;IACtC,uCAAuC;IACvC,0BAA0B;IAC1B,gCAAgC;IAChC,gCAAgC;IAChC,iCAAiC;IACjC,sBAAsB;IACtB,4BAA4B;CAC/B,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,CAAC,EAAe,EAAW,EAAE,CACpD,EAAE,CAAC,WAAW,KAAK,SAAS,IAAI,qCAAqC,CAAC,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;AAE9F,OAAO,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import type { GirFunction } from \"../../gir/function.js\";\n\nconst FUNCTIONS_INVOKING_CLOSURE_PARAMETERS: Set<string> = new Set([\n \"g_binding_group_bind_with_closures\",\n \"g_bus_own_name_on_connection_with_closures\",\n \"g_bus_own_name_with_closures\",\n \"g_bus_watch_name_on_connection_with_closures\",\n \"g_bus_watch_name_with_closures\",\n \"g_dbus_connection_register_object_with_closures\",\n \"g_dbus_connection_register_object_with_closures2\",\n \"g_file_copy_async_with_closures\",\n \"g_file_move_async_with_closures\",\n \"g_object_bind_property_with_closures\",\n \"g_settings_bind_with_mapping_closures\",\n \"g_signal_connect_closure\",\n \"g_signal_connect_closure_by_id\",\n \"g_signal_group_connect_closure\",\n \"g_signal_override_class_closure\",\n \"g_source_set_closure\",\n \"gtk_closure_expression_new\",\n]);\n\nconst areClosuresInvoked = (fn: GirFunction): boolean =>\n fn.cIdentifier !== undefined && FUNCTIONS_INVOKING_CLOSURE_PARAMETERS.has(fn.cIdentifier);\n\nexport { areClosuresInvoked };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/store/gi/constant.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAM7D,QAAA,MAAM,gBAAgB,GAAI,SAAS,aAAa,EAAE,UAAU,WAAW,KAAG,IAIzE,CAAC;AAEF,QAAA,MAAM,eAAe,GAAI,SAAS,aAAa,EAAE,UAAU,WAAW,KAAG,MAUxE,CAAC;AA6BF,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/store/gi/constant.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAM7D,QAAA,MAAM,gBAAgB,GAAI,SAAS,aAAa,EAAE,UAAU,WAAW,KAAG,IAGzE,CAAC;AAEF,QAAA,MAAM,eAAe,GAAI,SAAS,aAAa,EAAE,UAAU,WAAW,KAAG,MAUxE,CAAC;AA6BF,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC"}
@@ -1,9 +1,10 @@
1
1
  import { sourceStringLiteral } from "@gtkx/utils";
2
- import { renderJsDoc } from "../../writer/doc.js";
2
+ import { getDoc } from "./doc-spec.js";
3
3
  const TRUE_VALUES = new Set(["true", "1"]);
4
4
  const BIGINT_CATEGORIES = new Set(["bigint64", "biguint64", "gtype"]);
5
5
  const generateConstant = (context, constant) => {
6
- context.module.appendDeclaration(`${renderJsDoc(constant.doc)}export const ${constant.name} = ${constantLiteral(context, constant)};`);
6
+ const doc = getDoc(constant);
7
+ context.module.appendDeclaration(`${doc}export const ${constant.name} = ${constantLiteral(context, constant)};`);
7
8
  };
8
9
  const constantLiteral = (context, constant) => {
9
10
  if (hasPrimitiveCategory(context, constant.type, "string")) {
@@ -1 +1 @@
1
- {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../src/store/gi/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKlD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,WAAW,GAAgB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;AACxD,M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AAC5F,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,OAAsB,EAAE,IAAwB,EAAW,EAAE,CACnF,CAAC,GAAG,iBAAiB,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,oBAAoB,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE7F,MAAM,oBAAoB,GAAG,CACzB,OAAsB,EACtB,IAAwB,EACxB,QAA2B,EACpB,EAAE;IACT,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C,OAAO,QAAQ,EAAE,IAAI,KAAK,WAAW,IAAI,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC;AAC5E,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAExF,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { sourceStringLiteral } from \"@gtkx/utils\";\nimport type { GirConstant } from \"../../gir/namespace.js\";\nimport type { PrimitiveCategory } from \"../../gir/primitives.js\";\nimport type { TypeId } from \"../../gir/type-id.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\n\nconst TRUE_VALUES: Set<string> = new Set([\"true\", \"1\"]);\nconst BIGINT_CATEGORIES: Set<PrimitiveCategory> = new Set([\"bigint64\", \"biguint64\", \"gtype\"]);\n\nconst generateConstant = (context: ModuleContext, constant: GirConstant): void => {\n context.module.appendDeclaration(\n `${renderJsDoc(constant.doc)}export const ${constant.name} = ${constantLiteral(context, constant)};`,\n );\n};\n\nconst constantLiteral = (context: ModuleContext, constant: GirConstant): string => {\n if (hasPrimitiveCategory(context, constant.type, \"string\")) {\n return sourceStringLiteral(constant.value);\n }\n\n if (hasPrimitiveCategory(context, constant.type, \"boolean\")) {\n return TRUE_VALUES.has(constant.value) ? \"true\" : \"false\";\n }\n\n return numericConstantLiteral(context, constant);\n};\n\nconst numericConstantLiteral = (context: ModuleContext, constant: GirConstant): string => {\n if (!isNumericLiteral(constant.value)) {\n return sourceStringLiteral(constant.value);\n }\n\n return isBigIntConstant(context, constant.type) ? `${constant.value}n` : constant.value;\n};\n\nconst isBigIntConstant = (context: ModuleContext, type: TypeId | undefined): boolean =>\n [...BIGINT_CATEGORIES].some((category) => hasPrimitiveCategory(context, type, category));\n\nconst hasPrimitiveCategory = (\n context: ModuleContext,\n type: TypeId | undefined,\n category: PrimitiveCategory,\n): boolean => {\n if (type === undefined) {\n return false;\n }\n\n const resolved = context.library.typeFor(type);\n\n return resolved?.kind === \"primitive\" && resolved.category === category;\n};\n\nconst isNumericLiteral = (value: string): boolean => /^-?(?:\\d+|\\d*\\.\\d+)$/.test(value);\n\nexport { generateConstant, constantLiteral };\n"]}
1
+ {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../src/store/gi/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKlD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,MAAM,WAAW,GAAgB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;AACxD,MAAM,iBAAiB,GAA2B,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;AAE9F,MAAM,gBAAgB,GAAG,CAAC,OAAsB,EAAE,QAAqB,EAAQ,EAAE;IAC7E,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC7B,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,GAAG,GAAG,gBAAgB,QAAQ,CAAC,IAAI,MAAM,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,EACxB,QAA2B,EACpB,EAAE;IACT,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C,OAAO,QAAQ,EAAE,IAAI,KAAK,WAAW,IAAI,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC;AAC5E,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAExF,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { sourceStringLiteral } from \"@gtkx/utils\";\nimport type { GirConstant } from \"../../gir/namespace.js\";\nimport type { PrimitiveCategory } from \"../../gir/primitives.js\";\nimport type { TypeId } from \"../../gir/type-id.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { getDoc } from \"./doc-spec.js\";\n\nconst TRUE_VALUES: Set<string> = new Set([\"true\", \"1\"]);\nconst BIGINT_CATEGORIES: Set<PrimitiveCategory> = new Set([\"bigint64\", \"biguint64\", \"gtype\"]);\n\nconst generateConstant = (context: ModuleContext, constant: GirConstant): void => {\n const doc = getDoc(constant);\n context.module.appendDeclaration(`${doc}export const ${constant.name} = ${constantLiteral(context, constant)};`);\n};\n\nconst constantLiteral = (context: ModuleContext, constant: GirConstant): string => {\n if (hasPrimitiveCategory(context, constant.type, \"string\")) {\n return sourceStringLiteral(constant.value);\n }\n\n if (hasPrimitiveCategory(context, constant.type, \"boolean\")) {\n return TRUE_VALUES.has(constant.value) ? \"true\" : \"false\";\n }\n\n return numericConstantLiteral(context, constant);\n};\n\nconst numericConstantLiteral = (context: ModuleContext, constant: GirConstant): string => {\n if (!isNumericLiteral(constant.value)) {\n return sourceStringLiteral(constant.value);\n }\n\n return isBigIntConstant(context, constant.type) ? `${constant.value}n` : constant.value;\n};\n\nconst isBigIntConstant = (context: ModuleContext, type: TypeId | undefined): boolean =>\n [...BIGINT_CATEGORIES].some((category) => hasPrimitiveCategory(context, type, category));\n\nconst hasPrimitiveCategory = (\n context: ModuleContext,\n type: TypeId | undefined,\n category: PrimitiveCategory,\n): boolean => {\n if (type === undefined) {\n return false;\n }\n\n const resolved = context.library.typeFor(type);\n\n return resolved?.kind === \"primitive\" && resolved.category === category;\n};\n\nconst isNumericLiteral = (value: string): boolean => /^-?(?:\\d+|\\d*\\.\\d+)$/.test(value);\n\nexport { generateConstant, constantLiteral };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"constructor-props.d.ts","sourceRoot":"","sources":["../../../src/store/gi/constructor-props.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAyC7D,QAAA,MAAM,+BAA+B,GAAI,SAAS,aAAa,EAAE,OAAO,QAAQ,EAAE,WAAW,MAAM,KAAG,MAUrG,CAAC;AAEF,QAAA,MAAM,sBAAsB,GACxB,SAAS,aAAa,EACtB,OAAO,QAAQ,EACf,WAAW,MAAM,EACjB,WAAW,OAAO,KACnB,MAAM,GAAG,SAYX,CAAC;AAmCF,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,CAAC"}
1
+ {"version":3,"file":"constructor-props.d.ts","sourceRoot":"","sources":["../../../src/store/gi/constructor-props.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAwC7D,QAAA,MAAM,+BAA+B,GAAI,SAAS,aAAa,EAAE,OAAO,QAAQ,EAAE,WAAW,MAAM,KAAG,MAWrG,CAAC;AAEF,QAAA,MAAM,sBAAsB,GACxB,SAAS,aAAa,EACtB,OAAO,QAAQ,EACf,WAAW,MAAM,EACjB,WAAW,OAAO,KACnB,MAAM,GAAG,SAYX,CAAC;AA+BF,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,CAAC"}
@@ -6,7 +6,7 @@ import { ancestorChain } from "../../gir/ancestry.js";
6
6
  import { isConstructableProperty } from "../../gir/property.js";
7
7
  import { renderBlock, renderBraced, renderBracedOrEmpty } from "../../writer/emit.js";
8
8
  import { parentCompanionRef } from "./companion.js";
9
- const PROPS_RECORD = "Record<string, unknown>";
9
+ import { propertyDoc } from "./property-accessor.js";
10
10
  const constructablePropNames = (klass) => klass.properties.filter(isConstructableProperty).map((property) => toCamelIdentifier(property.name));
11
11
  const ancestorConstructablePropNames = (context, klass) => {
12
12
  const names = new Set();
@@ -29,7 +29,8 @@ const collectConstructableProps = (context, klass) => {
29
29
  const renderConstructorPropsInterface = (context, klass, className) => {
30
30
  const parentRef = parentCompanionRef(context, klass, "ConstructorProps");
31
31
  const extendsClause = parentRef === undefined ? "" : ` extends ${parentRef}`;
32
- const lines = collectConstructableProps(context, klass).map((property) => `${toCamelIdentifier(property.name)}?: ${renderTsType(context, property.type, true)} | undefined;`);
32
+ const lines = collectConstructableProps(context, klass).map((property) => `${propertyDoc(property)}${toCamelIdentifier(property.name)}?: ` +
33
+ `${renderTsType(context, property.type, true)} | undefined;`);
33
34
  return renderBracedOrEmpty(`export interface ${className}ConstructorProps${extendsClause}`, lines.join("\n"));
34
35
  };
35
36
  const renderClassConstructor = (context, klass, className, hasParent) => {
@@ -43,29 +44,26 @@ const renderClassConstructor = (context, klass, className, hasParent) => {
43
44
  return renderTranslatingConstructor(context, props, className);
44
45
  };
45
46
  const renderRootConstructor = (context) => {
46
- context.addRuntimeImport("getInstanceType");
47
+ context.addRuntimeTypeImport("AnyClass");
48
+ context.addRuntimeImport("getClassType");
47
49
  context.addRuntimeImport("newObjectWithProperties");
48
- context.addRuntimeImport("setHandle");
49
- context.addRuntimeImport("setWrapper");
50
- const body = [
51
- "const handle = newObjectWithProperties(getInstanceType(this), props);",
52
- "setHandle(this, handle);",
53
- "setWrapper(handle, this);",
54
- ].join("\n");
55
- return renderBlock(`constructor(props: ${PROPS_RECORD} = {})`, body);
50
+ const body = "newObjectWithProperties(getClassType(this.constructor as AnyClass), props, this);";
51
+ return renderBlock("constructor(props: object = {})", body);
56
52
  };
57
- const renderTranslatingConstructor = (context, props, className) => {
58
- context.addRuntimeImport("t");
59
- const destructured = props.map((property) => toCamelIdentifier(property.name));
60
- const pattern = `{ ${[...destructured, "...rest"].join(", ")} }`;
53
+ const renderConstructBindings = (context, props) => {
61
54
  const entries = props.map((property) => {
62
55
  const descriptor = renderDescriptor(context, property.type, property.transferOwnership);
63
- return `${sourceStringLiteral(property.name)}: [${descriptor}, ${toCamelIdentifier(property.name)}],`;
56
+ const key = sourceStringLiteral(toCamelIdentifier(property.name));
57
+ return `${key}: [${sourceStringLiteral(property.name)}, ${descriptor}],`;
64
58
  });
65
- const recordLiteral = renderBraced(entries.join("\n"));
66
- const lines = [`const props: ${PROPS_RECORD} = ${recordLiteral};`, "super({ ...props, ...rest });"];
67
- const body = lines.join("\n");
68
- return renderBlock(`constructor(${pattern}: ${className}ConstructorProps = {})`, body);
59
+ return renderBraced(entries.join("\n"));
60
+ };
61
+ const renderTranslatingConstructor = (context, props, className) => {
62
+ context.addRuntimeImport("t");
63
+ context.addRuntimeImport("registerConstructProperties");
64
+ const bindings = renderConstructBindings(context, props);
65
+ context.module.appendRegistration(`registerConstructProperties(${className}, ${bindings});`);
66
+ return renderBlock(`constructor(props: ${className}ConstructorProps = {})`, "super(props);");
69
67
  };
70
68
  export { renderConstructorPropsInterface, renderClassConstructor };
71
69
  //# sourceMappingURL=constructor-props.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constructor-props.js","sourceRoot":"","sources":["../../../src/store/gi/constructor-props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA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C,CAAC,QAAQ,EAAE,EAAE;QACnC,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC;QAExF,OAAO,GAAG,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,UAAU,KAAK,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;IAC1G,CAAC,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,CAAC,gBAAgB,YAAY,MAAM,aAAa,GAAG,EAAE,+BAA+B,CAAC,CAAC;IACpG,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE9B,OAAO,WAAW,CAAC,eAAe,OAAO,KAAK,SAAS,wBAAwB,EAAE,IAAI,CAAC,CAAC;AAC3F,CAAC,CAAC;AAEF,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["import { sourceStringLiteral, toCamelIdentifier, uniqBy } from \"@gtkx/utils\";\nimport type { GirClass } from \"../../gir/class.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { renderDescriptor } from \"../../analysis/descriptor-render.js\";\nimport { collectInterfaceProperties } from \"../../analysis/inheritance.js\";\nimport { renderTsType } from \"../../analysis/ts-type.js\";\nimport { ancestorChain } from \"../../gir/ancestry.js\";\nimport { type GirProperty, isConstructableProperty } from \"../../gir/property.js\";\nimport { renderBlock, renderBraced, renderBracedOrEmpty } from \"../../writer/emit.js\";\nimport { parentCompanionRef } from \"./companion.js\";\n\nconst PROPS_RECORD = \"Record<string, unknown>\";\n\nconst constructablePropNames = (klass: GirClass): string[] =>\n klass.properties.filter(isConstructableProperty).map((property) => toCamelIdentifier(property.name));\n\nconst ancestorConstructablePropNames = (context: ModuleContext, klass: GirClass): Set<string> => {\n const names: Set<string> = new Set();\n\n for (const { klass: ancestor } of ancestorChain(context.library, klass, context.namespace.name)) {\n if (ancestor === klass) {\n continue;\n }\n\n for (const name of constructablePropNames(ancestor)) {\n names.add(name);\n }\n }\n\n return names;\n};\n\nconst collectConstructableProps = (context: ModuleContext, klass: GirClass): GirProperty[] => {\n const inherited = ancestorConstructablePropNames(context, klass);\n\n return uniqBy(\n [...klass.properties, ...collectInterfaceProperties(context, klass).map((entry) => entry.property)]\n .filter(isConstructableProperty)\n .filter((property) => !inherited.has(toCamelIdentifier(property.name))),\n (property) => toCamelIdentifier(property.name),\n );\n};\n\nconst renderConstructorPropsInterface = (context: ModuleContext, klass: GirClass, className: string): string => {\n const parentRef = parentCompanionRef(context, klass, \"ConstructorProps\");\n const extendsClause = parentRef === undefined ? \"\" : ` extends ${parentRef}`;\n\n const lines = collectConstructableProps(context, klass).map(\n (property) =>\n `${toCamelIdentifier(property.name)}?: ${renderTsType(context, property.type, true)} | undefined;`,\n );\n\n return renderBracedOrEmpty(`export interface ${className}ConstructorProps${extendsClause}`, lines.join(\"\\n\"));\n};\n\nconst renderClassConstructor = (\n context: ModuleContext,\n klass: GirClass,\n className: string,\n hasParent: boolean,\n): string | undefined => {\n if (!hasParent) {\n return renderRootConstructor(context);\n }\n\n const props = collectConstructableProps(context, klass);\n\n if (props.length === 0) {\n return undefined;\n }\n\n return renderTranslatingConstructor(context, props, className);\n};\n\nconst renderRootConstructor = (context: ModuleContext): string => {\n context.addRuntimeImport(\"getInstanceType\");\n context.addRuntimeImport(\"newObjectWithProperties\");\n context.addRuntimeImport(\"setHandle\");\n context.addRuntimeImport(\"setWrapper\");\n\n const body = [\n \"const handle = newObjectWithProperties(getInstanceType(this), props);\",\n \"setHandle(this, handle);\",\n \"setWrapper(handle, this);\",\n ].join(\"\\n\");\n\n return renderBlock(`constructor(props: ${PROPS_RECORD} = {})`, body);\n};\n\nconst renderTranslatingConstructor = (context: ModuleContext, props: GirProperty[], className: string): string => {\n context.addRuntimeImport(\"t\");\n const destructured = props.map((property) => toCamelIdentifier(property.name));\n const pattern = `{ ${[...destructured, \"...rest\"].join(\", \")} }`;\n\n const entries = props.map((property) => {\n const descriptor = renderDescriptor(context, property.type, property.transferOwnership);\n\n return `${sourceStringLiteral(property.name)}: [${descriptor}, ${toCamelIdentifier(property.name)}],`;\n });\n\n const recordLiteral = renderBraced(entries.join(\"\\n\"));\n const lines = [`const props: ${PROPS_RECORD} = ${recordLiteral};`, \"super({ ...props, ...rest });\"];\n const body = lines.join(\"\\n\");\n\n return renderBlock(`constructor(${pattern}: ${className}ConstructorProps = {})`, body);\n};\n\nexport { renderConstructorPropsInterface, renderClassConstructor };\n"]}
1
+ {"version":3,"file":"constructor-props.js","sourceRoot":"","sources":["../../../src/store/gi/constructor-props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAoB,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,sBAAsB,GAAG,CAAC,KAAe,EAAY,EAAE,CACzD,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAA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mF,CAAC;IAEjG,OAAO,WAAW,CAAC,iCAAiC,EAAE,IAAI,CAAC,CAAC;AAChE,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,OAAsB,EAAE,KAAoB,EAAU,EAAE;IACrF,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QACnC,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC;QACxF,MAAM,GAAG,GAAG,mBAAmB,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QAElE,OAAO,GAAG,GAAG,MAAM,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,UAAU,IAAI,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF,MAAM,4BAA4B,GAAG,CAAC,OAAsB,EAAE,KAAoB,EAAE,SAAiB,EAAU,EAAE;IAC7G,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO,CAAC,gBAAgB,CAAC,6BAA6B,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,uBAAuB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACzD,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,+BAA+B,SAAS,KAAK,QAAQ,IAAI,CAAC,CAAC;IAE7F,OAAO,WAAW,CAAC,sBAAsB,SAAS,wBAAwB,EAAE,eAAe,CAAC,CAAC;AACjG,CAAC,CAAC;AAEF,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["import { sourceStringLiteral, toCamelIdentifier, uniqBy } from \"@gtkx/utils\";\nimport type { GirClass } from \"../../gir/class.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { renderDescriptor } from \"../../analysis/descriptor-render.js\";\nimport { collectInterfaceProperties } from \"../../analysis/inheritance.js\";\nimport { renderTsType } from \"../../analysis/ts-type.js\";\nimport { ancestorChain } from \"../../gir/ancestry.js\";\nimport { type GirProperty, isConstructableProperty } from \"../../gir/property.js\";\nimport { renderBlock, renderBraced, renderBracedOrEmpty } from \"../../writer/emit.js\";\nimport { parentCompanionRef } from \"./companion.js\";\nimport { propertyDoc } from \"./property-accessor.js\";\n\nconst constructablePropNames = (klass: GirClass): string[] =>\n klass.properties.filter(isConstructableProperty).map((property) => toCamelIdentifier(property.name));\n\nconst ancestorConstructablePropNames = (context: ModuleContext, klass: GirClass): Set<string> => {\n const names: Set<string> = new Set();\n\n for (const { klass: ancestor } of ancestorChain(context.library, klass, context.namespace.name)) {\n if (ancestor === klass) {\n continue;\n }\n\n for (const name of constructablePropNames(ancestor)) {\n names.add(name);\n }\n }\n\n return names;\n};\n\nconst collectConstructableProps = (context: ModuleContext, klass: GirClass): GirProperty[] => {\n const inherited = ancestorConstructablePropNames(context, klass);\n\n return uniqBy(\n [...klass.properties, ...collectInterfaceProperties(context, klass).map((entry) => entry.property)]\n .filter(isConstructableProperty)\n .filter((property) => !inherited.has(toCamelIdentifier(property.name))),\n (property) => toCamelIdentifier(property.name),\n );\n};\n\nconst renderConstructorPropsInterface = (context: ModuleContext, klass: GirClass, className: string): string => {\n const parentRef = parentCompanionRef(context, klass, \"ConstructorProps\");\n const extendsClause = parentRef === undefined ? \"\" : ` extends ${parentRef}`;\n\n const lines = collectConstructableProps(context, klass).map(\n (property) =>\n `${propertyDoc(property)}${toCamelIdentifier(property.name)}?: ` +\n `${renderTsType(context, property.type, true)} | undefined;`,\n );\n\n return renderBracedOrEmpty(`export interface ${className}ConstructorProps${extendsClause}`, lines.join(\"\\n\"));\n};\n\nconst renderClassConstructor = (\n context: ModuleContext,\n klass: GirClass,\n className: string,\n hasParent: boolean,\n): string | undefined => {\n if (!hasParent) {\n return renderRootConstructor(context);\n }\n\n const props = collectConstructableProps(context, klass);\n\n if (props.length === 0) {\n return undefined;\n }\n\n return renderTranslatingConstructor(context, props, className);\n};\n\nconst renderRootConstructor = (context: ModuleContext): string => {\n context.addRuntimeTypeImport(\"AnyClass\");\n context.addRuntimeImport(\"getClassType\");\n context.addRuntimeImport(\"newObjectWithProperties\");\n const body = \"newObjectWithProperties(getClassType(this.constructor as AnyClass), props, this);\";\n\n return renderBlock(\"constructor(props: object = {})\", body);\n};\n\nconst renderConstructBindings = (context: ModuleContext, props: GirProperty[]): string => {\n const entries = props.map((property) => {\n const descriptor = renderDescriptor(context, property.type, property.transferOwnership);\n const key = sourceStringLiteral(toCamelIdentifier(property.name));\n\n return `${key}: [${sourceStringLiteral(property.name)}, ${descriptor}],`;\n });\n\n return renderBraced(entries.join(\"\\n\"));\n};\n\nconst renderTranslatingConstructor = (context: ModuleContext, props: GirProperty[], className: string): string => {\n context.addRuntimeImport(\"t\");\n context.addRuntimeImport(\"registerConstructProperties\");\n const bindings = renderConstructBindings(context, props);\n context.module.appendRegistration(`registerConstructProperties(${className}, ${bindings});`);\n\n return renderBlock(`constructor(props: ${className}ConstructorProps = {})`, \"super(props);\");\n};\n\nexport { renderConstructorPropsInterface, renderClassConstructor };\n"]}
@@ -0,0 +1,14 @@
1
+ import type { GirAnnotations } from "../../gir/annotations.js";
2
+ import type { GirCallable, GirParameter } from "../../gir/parameter.js";
3
+ import type { JsDocSpec } from "../../writer/doc.js";
4
+ type DocumentedNode = {
5
+ doc: string | undefined;
6
+ annotations: GirAnnotations;
7
+ };
8
+ declare const THROWS_TEXT = "A `GLib.Error` carrying the failing operation's domain, code, and message.";
9
+ declare const annotationSpec: (annotations: GirAnnotations) => JsDocSpec;
10
+ declare const getDoc: (node: DocumentedNode) => string;
11
+ declare const handlerSpec: (callable: GirCallable, parameters: GirParameter[], identifiers?: Map<string, string>) => JsDocSpec;
12
+ declare const selfHandlerSpec: (signal: GirCallable) => JsDocSpec;
13
+ export { annotationSpec, getDoc, handlerSpec, selfHandlerSpec, THROWS_TEXT };
14
+ //# sourceMappingURL=doc-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doc-spec.d.ts","sourceRoot":"","sources":["../../../src/store/gi/doc-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD,KAAK,cAAc,GAAG;IAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,WAAW,EAAE,cAAc,CAAA;CAAE,CAAC;AAG/E,QAAA,MAAM,WAAW,+EAA+E,CAAC;AAEjG,QAAA,MAAM,cAAc,GAAI,aAAa,cAAc,KAAG,SAKpD,CAAC;AAEH,QAAA,MAAM,MAAM,GAAI,MAAM,cAAc,KAAG,MAA4E,CAAC;AAEpH,QAAA,MAAM,WAAW,GACb,UAAU,WAAW,EACrB,YAAY,YAAY,EAAE,EAC1B,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAClC,SAKD,CAAC;AAEH,QAAA,MAAM,eAAe,GAAI,QAAQ,WAAW,KAAG,SAI9C,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { documentedHandlerParameters, handlerRenames } from "../../analysis/param-structure.js";
2
+ import { renderJsDoc } from "../../writer/doc.js";
3
+ const SELF_PARAM_DOC = "The instance the signal was emitted on.";
4
+ const THROWS_TEXT = "A `GLib.Error` carrying the failing operation's domain, code, and message.";
5
+ const annotationSpec = (annotations) => ({
6
+ deprecated: annotations.isDeprecated
7
+ ? { since: annotations.deprecatedSince, doc: annotations.deprecationDoc }
8
+ : undefined,
9
+ since: annotations.since,
10
+ });
11
+ const getDoc = (node) => renderJsDoc(node.doc, undefined, annotationSpec(node.annotations));
12
+ const handlerSpec = (callable, parameters, identifiers) => ({
13
+ ...annotationSpec(callable.annotations),
14
+ identifiers: identifiers ?? handlerRenames(parameters),
15
+ params: documentedHandlerParameters(parameters),
16
+ returns: callable.returnValue.doc,
17
+ });
18
+ const selfHandlerSpec = (signal) => {
19
+ const spec = handlerSpec(signal, signal.parameters);
20
+ return { ...spec, params: [...(spec.params ?? []), { name: "self", doc: SELF_PARAM_DOC }] };
21
+ };
22
+ export { annotationSpec, getDoc, handlerSpec, selfHandlerSpec, THROWS_TEXT };
23
+ //# sourceMappingURL=doc-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doc-spec.js","sourceRoot":"","sources":["../../../src/store/gi/doc-spec.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIlD,MAAM,cAAc,GAAG,yCAAyC,CAAC;AACjE,MAAM,WAAW,GAAG,4EAA4E,CAAC;AAEjG,MAAM,cAAc,GAAG,CAAC,WAA2B,EAAa,EAAE,CAAC,CAAC;IAChE,UAAU,EAAE,WAAW,CAAC,YAAY;QAChC,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,eAAe,EAAE,GAAG,EAAE,WAAW,CAAC,cAAc,EAAE;QACzE,CAAC,CAAC,SAAS;IACf,KAAK,EAAE,WAAW,CAAC,KAAK;CAC3B,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,CAAC,IAAoB,EAAU,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;AAEpH,MAAM,WAAW,GAAG,CAChB,QAAqB,EACrB,UAA0B,EAC1B,WAAiC,EACxB,EAAE,CAAC,CAAC;IACb,GAAG,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC;IACvC,WAAW,EAAE,WAAW,IAAI,cAAc,CAAC,UAAU,CAAC;IACtD,MAAM,EAAE,2BAA2B,CAAC,UAAU,CAAC;IAC/C,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG;CACpC,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,CAAC,MAAmB,EAAa,EAAE;IACvD,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IAEpD,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC;AAChG,CAAC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import type { GirAnnotations } from \"../../gir/annotations.js\";\nimport type { GirCallable, GirParameter } from \"../../gir/parameter.js\";\nimport type { JsDocSpec } from \"../../writer/doc.js\";\nimport { documentedHandlerParameters, handlerRenames } from \"../../analysis/param-structure.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\n\ntype DocumentedNode = { doc: string | undefined; annotations: GirAnnotations };\n\nconst SELF_PARAM_DOC = \"The instance the signal was emitted on.\";\nconst THROWS_TEXT = \"A `GLib.Error` carrying the failing operation's domain, code, and message.\";\n\nconst annotationSpec = (annotations: GirAnnotations): JsDocSpec => ({\n deprecated: annotations.isDeprecated\n ? { since: annotations.deprecatedSince, doc: annotations.deprecationDoc }\n : undefined,\n since: annotations.since,\n});\n\nconst getDoc = (node: DocumentedNode): string => renderJsDoc(node.doc, undefined, annotationSpec(node.annotations));\n\nconst handlerSpec = (\n callable: GirCallable,\n parameters: GirParameter[],\n identifiers?: Map<string, string>,\n): JsDocSpec => ({\n ...annotationSpec(callable.annotations),\n identifiers: identifiers ?? handlerRenames(parameters),\n params: documentedHandlerParameters(parameters),\n returns: callable.returnValue.doc,\n});\n\nconst selfHandlerSpec = (signal: GirCallable): JsDocSpec => {\n const spec = handlerSpec(signal, signal.parameters);\n\n return { ...spec, params: [...(spec.params ?? []), { name: \"self\", doc: SELF_PARAM_DOC }] };\n};\n\nexport { annotationSpec, getDoc, handlerSpec, selfHandlerSpec, THROWS_TEXT };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../../src/store/gi/enum.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAI7D,QAAA,MAAM,YAAY,GAAI,SAAS,aAAa,EAAE,aAAa,OAAO,KAAG,IAuCpE,CAAC;AAEF,QAAA,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAIrC,CAAC;AAYF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../../src/store/gi/enum.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAa7D,QAAA,MAAM,YAAY,GAAI,SAAS,aAAa,EAAE,aAAa,OAAO,KAAG,IAepE,CAAC;AAoDF,QAAA,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAIrC,CAAC;AAYF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC"}
@@ -1,30 +1,43 @@
1
1
  import { sourceStringLiteral } from "@gtkx/utils";
2
- import { renderJsDoc } from "../../writer/doc.js";
2
+ import { hasAnnotations } from "../../gir/annotations.js";
3
3
  import { indent } from "../../writer/emit.js";
4
+ import { getDoc } from "./doc-spec.js";
5
+ const memberDoc = (member) => getDoc(member);
6
+ const enumDoc = (enumeration) => getDoc(enumeration);
4
7
  const generateEnum = (context, enumeration) => {
5
8
  if (!enumeration.introspectable) {
6
9
  return;
7
10
  }
8
- const name = enumeration.name;
9
11
  const members = enumeration.members.map((member) => ({ ...member, key: enumMemberKey(member.name) }));
10
- if (enumeration.errorDomain !== undefined) {
11
- const memberEntries = members.map((member) => `${member.key}: ${member.value}`);
12
- const typeFields = members.map((member) => `${member.key}: number`).join("; ");
13
- context.addRuntimeImport("createErrorDomain");
14
- context.addRuntimeImport("ErrorDomain");
15
- const quarkExpression = renderQuarkExpression(context, enumeration.errorDomain);
16
- context.module.appendDeclaration(`${renderJsDoc(enumeration.doc)}export type ${name} = number;`);
17
- context.module.appendDeclaration(`export const ${name}: ErrorDomain<{ ${typeFields} }> = ` +
18
- `createErrorDomain(${quarkExpression}, { ${memberEntries.join(", ")} });`);
12
+ const errorDomain = enumeration.errorDomain;
13
+ if (errorDomain !== undefined) {
14
+ appendErrorDomain(context, enumeration, members, errorDomain);
19
15
  return;
20
16
  }
21
- if (members.some((member) => member.doc !== undefined)) {
22
- const memberBlocks = members.map((member) => `${renderJsDoc(member.doc)}${member.key} = ${member.value},`);
23
- context.module.appendDeclaration(`${renderJsDoc(enumeration.doc)}export enum ${name} {\n${indent(memberBlocks.join("\n"), 1)}\n}`);
17
+ appendEnumDeclaration(context, enumeration, members);
18
+ };
19
+ const appendErrorDomain = (context, enumeration, members, errorDomain) => {
20
+ const memberEntries = members.map((member) => `${member.key}: ${member.value}`);
21
+ const typeFields = members.map((member) => `${memberDoc(member)}${member.key}: number;`);
22
+ context.addRuntimeImport("createErrorDomain");
23
+ context.addRuntimeImport("ErrorDomain");
24
+ const quarkExpression = renderQuarkExpression(context, errorDomain);
25
+ const doc = enumDoc(enumeration);
26
+ const shape = typeFields.length === 0 ? "{}" : `{\n${indent(typeFields.join("\n"), 1)}\n}`;
27
+ context.module.appendDeclaration(`${doc}export type ${enumeration.name} = number;`, context.declaredType(enumeration.name));
28
+ context.module.appendDeclaration(`${doc}export const ${enumeration.name}: ErrorDomain<${shape}> = ` +
29
+ `createErrorDomain(${quarkExpression}, { ${memberEntries.join(", ")} });`);
30
+ };
31
+ const isMemberDocumented = (member) => member.doc !== undefined || hasAnnotations(member.annotations);
32
+ const appendEnumDeclaration = (context, enumeration, members) => {
33
+ const doc = enumDoc(enumeration);
34
+ if (members.some((member) => isMemberDocumented(member))) {
35
+ const blocks = members.map((member) => `${memberDoc(member)}${member.key} = ${member.value},`);
36
+ context.module.appendDeclaration(`${doc}export enum ${enumeration.name} {\n${indent(blocks.join("\n"), 1)}\n}`, context.declaredType(enumeration.name));
24
37
  return;
25
38
  }
26
- const memberDeclarations = members.map((member) => `${member.key} = ${member.value}`);
27
- context.module.appendDeclaration(`${renderJsDoc(enumeration.doc)}export enum ${name} { ${memberDeclarations.join(", ")} }`);
39
+ const declarations = members.map((member) => `${member.key} = ${member.value}`);
40
+ context.module.appendDeclaration(`${doc}export enum ${enumeration.name} { ${declarations.join(", ")} }`, context.declaredType(enumeration.name));
28
41
  };
29
42
  const enumMemberKey = (name) => {
30
43
  const upper = name.toUpperCase().replaceAll("-", "_");
@@ -1 +1 @@
1
- {"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../src/store/gi/enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,YAAY,GAAG,CAAC,OAAsB,EAAE,WAAoB,EAAQ,EAAE;IACxE,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC;QAC9B,OAAO;IACX,CAAC;IAED,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;IAC9B,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,G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AAEF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import { sourceStringLiteral } from \"@gtkx/utils\";\nimport type { GirEnum } from \"../../gir/enum.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\nimport { indent } from \"../../writer/emit.js\";\n\nconst generateEnum = (context: ModuleContext, enumeration: GirEnum): void => {\n if (!enumeration.introspectable) {\n return;\n }\n\n const name = enumeration.name;\n const members = enumeration.members.map((member) => ({ ...member, key: enumMemberKey(member.name) }));\n\n if (enumeration.errorDomain !== undefined) {\n const memberEntries = members.map((member) => `${member.key}: ${member.value}`);\n const typeFields = members.map((member) => `${member.key}: number`).join(\"; \");\n context.addRuntimeImport(\"createErrorDomain\");\n context.addRuntimeImport(\"ErrorDomain\");\n const quarkExpression = renderQuarkExpression(context, enumeration.errorDomain);\n context.module.appendDeclaration(`${renderJsDoc(enumeration.doc)}export type ${name} = number;`);\n\n context.module.appendDeclaration(\n `export const ${name}: ErrorDomain<{ ${typeFields} }> = ` +\n `createErrorDomain(${quarkExpression}, { ${memberEntries.join(\", \")} });`,\n );\n\n return;\n }\n\n if (members.some((member) => member.doc !== undefined)) {\n const memberBlocks = members.map((member) => `${renderJsDoc(member.doc)}${member.key} = ${member.value},`);\n\n context.module.appendDeclaration(\n `${renderJsDoc(enumeration.doc)}export enum ${name} {\\n${indent(memberBlocks.join(\"\\n\"), 1)}\\n}`,\n );\n\n return;\n }\n\n const memberDeclarations = members.map((member) => `${member.key} = ${member.value}`);\n\n context.module.appendDeclaration(\n `${renderJsDoc(enumeration.doc)}export enum ${name} { ${memberDeclarations.join(\", \")} }`,\n );\n};\n\nconst enumMemberKey = (name: string): string => {\n const upper = name.toUpperCase().replaceAll(\"-\", \"_\");\n\n return /^\\d/.test(upper) ? `_${upper}` : upper;\n};\n\nconst renderQuarkExpression = (context: ModuleContext, errorDomain: string): string => {\n if (context.namespace.name === \"GLib\") {\n return `() => quarkFromString(${sourceStringLiteral(errorDomain)})`;\n }\n\n const alias = context.addCrossNamespaceImport(\"GLib\");\n\n return `() => ${alias}.quarkFromString(${sourceStringLiteral(errorDomain)})`;\n};\n\nexport { generateEnum, enumMemberKey };\n"]}
1
+ {"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../src/store/gi/enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIvC,MAAM,SAAS,GAAG,CAAC,MAAmB,EAAU,EAAE,CAC9C,MAAM,CAAC,MAAM,CAAC,CAAC;AAEnB,MAAM,OAAO,GAAG,CAAC,WAAoB,EAAU,EAAE,CAC7C,MAAM,CAAC,WAAW,CAAC,CAAC;AAExB,MAAM,YAAY,GAAG,CAAC,OAAsB,EAAE,WAAoB,EAAQ,EAAE;IACxE,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC;QAC9B,OAAO;IACX,CAAC;IAED,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACtG,MAAM,WAAW,GAAG,WAAW,CAAC,WAAW,CAAC;IAE5C,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC5B,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QAE9D,OAAO;IACX,CAAC;IAED,qBAAqB,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CACtB,OAA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AAK,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,OAAsB,EAAE,WAAmB,EAAU,EAAE;IAClF,IAAI,OAAO,CAAC,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACpC,OAAO,yBAAyB,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC;IACxE,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAEtD,OAAO,SAAS,KAAK,oBAAoB,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC;AACjF,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import { sourceStringLiteral } from \"@gtkx/utils\";\nimport type { EnumMember, GirEnum } from \"../../gir/enum.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { hasAnnotations } from \"../../gir/annotations.js\";\nimport { indent } from \"../../writer/emit.js\";\nimport { getDoc } from \"./doc-spec.js\";\n\ntype KeyedMember = EnumMember & { key: string };\n\nconst memberDoc = (member: KeyedMember): string =>\n getDoc(member);\n\nconst enumDoc = (enumeration: GirEnum): string =>\n getDoc(enumeration);\n\nconst generateEnum = (context: ModuleContext, enumeration: GirEnum): void => {\n if (!enumeration.introspectable) {\n return;\n }\n\n const members = enumeration.members.map((member) => ({ ...member, key: enumMemberKey(member.name) }));\n const errorDomain = enumeration.errorDomain;\n\n if (errorDomain !== undefined) {\n appendErrorDomain(context, enumeration, members, errorDomain);\n\n return;\n }\n\n appendEnumDeclaration(context, enumeration, members);\n};\n\nconst appendErrorDomain = (\n context: ModuleContext,\n enumeration: GirEnum,\n members: KeyedMember[],\n errorDomain: string,\n): void => {\n const memberEntries = members.map((member) => `${member.key}: ${member.value}`);\n const typeFields = members.map((member) => `${memberDoc(member)}${member.key}: number;`);\n context.addRuntimeImport(\"createErrorDomain\");\n context.addRuntimeImport(\"ErrorDomain\");\n const quarkExpression = renderQuarkExpression(context, errorDomain);\n const doc = enumDoc(enumeration);\n const shape = typeFields.length === 0 ? \"{}\" : `{\\n${indent(typeFields.join(\"\\n\"), 1)}\\n}`;\n\n context.module.appendDeclaration(\n `${doc}export type ${enumeration.name} = number;`,\n context.declaredType(enumeration.name),\n );\n\n context.module.appendDeclaration(\n `${doc}export const ${enumeration.name}: ErrorDomain<${shape}> = ` +\n `createErrorDomain(${quarkExpression}, { ${memberEntries.join(\", \")} });`,\n );\n};\n\nconst isMemberDocumented = (member: KeyedMember): boolean =>\n member.doc !== undefined || hasAnnotations(member.annotations);\n\nconst appendEnumDeclaration = (context: ModuleContext, enumeration: GirEnum, members: KeyedMember[]): void => {\n const doc = enumDoc(enumeration);\n\n if (members.some((member) => isMemberDocumented(member))) {\n const blocks = members.map((member) => `${memberDoc(member)}${member.key} = ${member.value},`);\n\n context.module.appendDeclaration(\n `${doc}export enum ${enumeration.name} {\\n${indent(blocks.join(\"\\n\"), 1)}\\n}`,\n context.declaredType(enumeration.name),\n );\n\n return;\n }\n\n const declarations = members.map((member) => `${member.key} = ${member.value}`);\n\n context.module.appendDeclaration(\n `${doc}export enum ${enumeration.name} { ${declarations.join(\", \")} }`,\n context.declaredType(enumeration.name),\n );\n};\n\nconst enumMemberKey = (name: string): string => {\n const upper = name.toUpperCase().replaceAll(\"-\", \"_\");\n\n return /^\\d/.test(upper) ? `_${upper}` : upper;\n};\n\nconst renderQuarkExpression = (context: ModuleContext, errorDomain: string): string => {\n if (context.namespace.name === \"GLib\") {\n return `() => quarkFromString(${sourceStringLiteral(errorDomain)})`;\n }\n\n const alias = context.addCrossNamespaceImport(\"GLib\");\n\n return `() => ${alias}.quarkFromString(${sourceStringLiteral(errorDomain)})`;\n};\n\nexport { generateEnum, enumMemberKey };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../../src/store/gi/function.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AAW,YAAY,KAAG,IASrF,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import { toCamelIdentifier } from "@gtkx/utils";
2
2
  import { tFn } from "../../analysis/descriptor.js";
3
- import { hasCallerAllocatedArrayLength } from "../../analysis/param-structure.js";
4
- import { renderJsDoc } from "../../writer/doc.js";
3
+ import { hasUnmarshalableParam } from "../../analysis/param-capability.js";
5
4
  import { arrayLiteral, renderBlock } from "../../writer/emit.js";
6
5
  import { matchAsyncFinish } from "./async.js";
6
+ import { callableDoc } from "./callable-doc.js";
7
7
  import { planCallArgs, renderMethodBody, renderMethodReturnType, renderMethodSignature, renderPromisifiedBody, renderPromisifiedSignature, renderReturnDescriptor, } from "./method.js";
8
8
  const renderFnExpression = (context, fn) => {
9
9
  if (fn.cIdentifier === undefined) {
@@ -34,7 +34,7 @@ const canEmitNamespaceFunction = (context, fn) => fn.introspectable &&
34
34
  !isMovedOntoEmittedMember(context, fn) &&
35
35
  fn.shadowedBy === undefined &&
36
36
  fn.cIdentifier !== undefined &&
37
- !hasCallerAllocatedArrayLength(context.library, fn);
37
+ !hasUnmarshalableParam(context, fn);
38
38
  const generateNamespaceFunction = (context, fn) => {
39
39
  if (!canEmitNamespaceFunction(context, fn)) {
40
40
  return;
@@ -50,17 +50,32 @@ const generateNamespaceFunction = (context, fn) => {
50
50
  const bindingName = toCamelIdentifier(cIdentifier);
51
51
  context.module.appendBinding(`const ${bindingName} = ${expression};`, cIdentifier);
52
52
  const exportName = namespaceFunctionExportName(cIdentifier, fn.name, context.namespace.cSymbolPrefixes);
53
- const declaration = renderNamespaceFunctionDeclaration(context, fn, exportName, bindingName);
54
- context.module.appendDeclaration(`${renderJsDoc(fn.doc)}${declaration}`);
53
+ const finish = matchNamespaceFinish(context, fn);
54
+ const declaration = renderNamespaceFunctionDeclaration({ context, fn, finish, exportName, bindingName });
55
+ const doc = callableDoc(context, fn, { finishFn: finish?.fn });
56
+ context.module.appendDeclaration(`${doc}${declaration}`);
55
57
  };
56
- const renderNamespaceFunctionDeclaration = (context, fn, exportName, bindingName) => {
58
+ const matchNamespaceFinish = (context, fn) => {
57
59
  const finishFn = matchAsyncFinish(context.library, fn, context.namespace.functions);
58
- const finishCIdentifier = finishFn?.cIdentifier;
59
- if (finishFn !== undefined && finishCIdentifier !== undefined && canEmitNamespaceFunction(context, finishFn)) {
60
- const finishExport = namespaceFunctionExportName(finishCIdentifier, finishFn.name, context.namespace.cSymbolPrefixes);
61
- const { signature, returnType } = renderPromisifiedSignature(context, fn, finishFn);
62
- const body = renderPromisifiedBody(context, fn, finishExport, bindingName);
63
- return renderBlock(`export function ${exportName}(${signature}): ${returnType}`, body);
60
+ const cIdentifier = finishFn?.cIdentifier;
61
+ if (finishFn === undefined || cIdentifier === undefined || !canEmitNamespaceFunction(context, finishFn)) {
62
+ return undefined;
63
+ }
64
+ return {
65
+ fn: finishFn,
66
+ exportName: namespaceFunctionExportName(cIdentifier, finishFn.name, context.namespace.cSymbolPrefixes),
67
+ };
68
+ };
69
+ const renderPromisifiedNamespaceFunction = (options, finish) => {
70
+ const { context, fn, exportName, bindingName } = options;
71
+ const { signature, returnType } = renderPromisifiedSignature(context, fn, finish.fn);
72
+ const body = renderPromisifiedBody(context, fn, finish.exportName, bindingName);
73
+ return renderBlock(`export function ${exportName}(${signature}): ${returnType}`, body);
74
+ };
75
+ const renderNamespaceFunctionDeclaration = (options) => {
76
+ const { context, fn, finish, exportName, bindingName } = options;
77
+ if (finish !== undefined) {
78
+ return renderPromisifiedNamespaceFunction(options, finish);
64
79
  }
65
80
  const signature = renderMethodSignature(context, fn);
66
81
  const returnType = renderMethodReturnType(context, fn);