@gtkx/codegen 0.21.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 (340) hide show
  1. package/LICENSE +373 -0
  2. package/dist/dsl/context.d.ts +104 -0
  3. package/dist/dsl/context.d.ts.map +1 -0
  4. package/dist/dsl/context.js +140 -0
  5. package/dist/dsl/context.js.map +1 -0
  6. package/dist/dsl/emit.d.ts +28 -0
  7. package/dist/dsl/emit.d.ts.map +1 -0
  8. package/dist/dsl/emit.js +41 -0
  9. package/dist/dsl/emit.js.map +1 -0
  10. package/dist/dsl/identifier.d.ts +28 -0
  11. package/dist/dsl/identifier.d.ts.map +1 -0
  12. package/dist/dsl/identifier.js +45 -0
  13. package/dist/dsl/identifier.js.map +1 -0
  14. package/dist/dsl/imports.d.ts +58 -0
  15. package/dist/dsl/imports.d.ts.map +1 -0
  16. package/dist/dsl/imports.js +107 -0
  17. package/dist/dsl/imports.js.map +1 -0
  18. package/dist/dsl/module.d.ts +53 -0
  19. package/dist/dsl/module.d.ts.map +1 -0
  20. package/dist/dsl/module.js +76 -0
  21. package/dist/dsl/module.js.map +1 -0
  22. package/dist/ffi/pipeline.d.ts +19 -0
  23. package/dist/ffi/pipeline.d.ts.map +1 -0
  24. package/dist/ffi/pipeline.js +107 -0
  25. package/dist/ffi/pipeline.js.map +1 -0
  26. package/dist/fingerprint.d.ts +30 -0
  27. package/dist/fingerprint.d.ts.map +1 -0
  28. package/dist/fingerprint.js +33 -0
  29. package/dist/fingerprint.js.map +1 -0
  30. package/dist/gi-store.d.ts +34 -0
  31. package/dist/gi-store.d.ts.map +1 -0
  32. package/dist/gi-store.js +154 -0
  33. package/dist/gi-store.js.map +1 -0
  34. package/dist/gir/boxed.d.ts +66 -0
  35. package/dist/gir/boxed.d.ts.map +1 -0
  36. package/dist/gir/boxed.js +49 -0
  37. package/dist/gir/boxed.js.map +1 -0
  38. package/dist/gir/callback.d.ts +15 -0
  39. package/dist/gir/callback.d.ts.map +1 -0
  40. package/dist/gir/callback.js +17 -0
  41. package/dist/gir/callback.js.map +1 -0
  42. package/dist/gir/class.d.ts +49 -0
  43. package/dist/gir/class.d.ts.map +1 -0
  44. package/dist/gir/class.js +42 -0
  45. package/dist/gir/class.js.map +1 -0
  46. package/dist/gir/enum.d.ts +39 -0
  47. package/dist/gir/enum.d.ts.map +1 -0
  48. package/dist/gir/enum.js +24 -0
  49. package/dist/gir/enum.js.map +1 -0
  50. package/dist/gir/field.d.ts +27 -0
  51. package/dist/gir/field.d.ts.map +1 -0
  52. package/dist/gir/field.js +19 -0
  53. package/dist/gir/field.js.map +1 -0
  54. package/dist/gir/function.d.ts +47 -0
  55. package/dist/gir/function.d.ts.map +1 -0
  56. package/dist/gir/function.js +28 -0
  57. package/dist/gir/function.js.map +1 -0
  58. package/dist/gir/namespace.d.ts +65 -0
  59. package/dist/gir/namespace.d.ts.map +1 -0
  60. package/dist/gir/namespace.js +60 -0
  61. package/dist/gir/namespace.js.map +1 -0
  62. package/dist/gir/parameter.d.ts +82 -0
  63. package/dist/gir/parameter.d.ts.map +1 -0
  64. package/dist/gir/parameter.js +66 -0
  65. package/dist/gir/parameter.js.map +1 -0
  66. package/dist/gir/parse.d.ts +78 -0
  67. package/dist/gir/parse.d.ts.map +1 -0
  68. package/dist/gir/parse.js +155 -0
  69. package/dist/gir/parse.js.map +1 -0
  70. package/dist/gir/primitives.d.ts +36 -0
  71. package/dist/gir/primitives.d.ts.map +1 -0
  72. package/dist/gir/primitives.js +109 -0
  73. package/dist/gir/primitives.js.map +1 -0
  74. package/dist/gir/property.d.ts +29 -0
  75. package/dist/gir/property.d.ts.map +1 -0
  76. package/dist/gir/property.js +16 -0
  77. package/dist/gir/property.js.map +1 -0
  78. package/dist/gir/qualified-name.d.ts +37 -0
  79. package/dist/gir/qualified-name.d.ts.map +1 -0
  80. package/dist/gir/qualified-name.js +39 -0
  81. package/dist/gir/qualified-name.js.map +1 -0
  82. package/dist/gir/qualify.d.ts +32 -0
  83. package/dist/gir/qualify.d.ts.map +1 -0
  84. package/dist/gir/qualify.js +60 -0
  85. package/dist/gir/qualify.js.map +1 -0
  86. package/dist/gir/repository.d.ts +82 -0
  87. package/dist/gir/repository.d.ts.map +1 -0
  88. package/dist/gir/repository.js +122 -0
  89. package/dist/gir/repository.js.map +1 -0
  90. package/dist/gir/signal.d.ts +22 -0
  91. package/dist/gir/signal.d.ts.map +1 -0
  92. package/dist/gir/signal.js +20 -0
  93. package/dist/gir/signal.js.map +1 -0
  94. package/dist/gir/size.d.ts +67 -0
  95. package/dist/gir/size.d.ts.map +1 -0
  96. package/dist/gir/size.js +87 -0
  97. package/dist/gir/size.js.map +1 -0
  98. package/dist/gir/type-ref.d.ts +79 -0
  99. package/dist/gir/type-ref.d.ts.map +1 -0
  100. package/dist/gir/type-ref.js +101 -0
  101. package/dist/gir/type-ref.js.map +1 -0
  102. package/dist/index.d.ts +12 -0
  103. package/dist/index.d.ts.map +1 -0
  104. package/dist/index.js +12 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/jsx-store.d.ts +22 -0
  107. package/dist/jsx-store.d.ts.map +1 -0
  108. package/dist/jsx-store.js +40 -0
  109. package/dist/jsx-store.js.map +1 -0
  110. package/dist/react/compounds-meta.d.ts +18 -0
  111. package/dist/react/compounds-meta.d.ts.map +1 -0
  112. package/dist/react/compounds-meta.js +93 -0
  113. package/dist/react/compounds-meta.js.map +1 -0
  114. package/dist/react/compounds.d.ts +27 -0
  115. package/dist/react/compounds.d.ts.map +1 -0
  116. package/dist/react/compounds.js +164 -0
  117. package/dist/react/compounds.js.map +1 -0
  118. package/dist/react/internal.d.ts +14 -0
  119. package/dist/react/internal.d.ts.map +1 -0
  120. package/dist/react/internal.js +79 -0
  121. package/dist/react/internal.js.map +1 -0
  122. package/dist/react/jsx.d.ts +22 -0
  123. package/dist/react/jsx.d.ts.map +1 -0
  124. package/dist/react/jsx.js +134 -0
  125. package/dist/react/jsx.js.map +1 -0
  126. package/dist/react/pipeline.d.ts +13 -0
  127. package/dist/react/pipeline.d.ts.map +1 -0
  128. package/dist/react/pipeline.js +25 -0
  129. package/dist/react/pipeline.js.map +1 -0
  130. package/dist/react/props.d.ts +38 -0
  131. package/dist/react/props.d.ts.map +1 -0
  132. package/dist/react/props.js +231 -0
  133. package/dist/react/props.js.map +1 -0
  134. package/dist/react/slot-props.d.ts +10 -0
  135. package/dist/react/slot-props.d.ts.map +1 -0
  136. package/dist/react/slot-props.js +56 -0
  137. package/dist/react/slot-props.js.map +1 -0
  138. package/dist/react/widgets.d.ts +83 -0
  139. package/dist/react/widgets.d.ts.map +1 -0
  140. package/dist/react/widgets.js +152 -0
  141. package/dist/react/widgets.js.map +1 -0
  142. package/dist/runner.d.ts +55 -0
  143. package/dist/runner.d.ts.map +1 -0
  144. package/dist/runner.js +60 -0
  145. package/dist/runner.js.map +1 -0
  146. package/dist/store-fs.d.ts +109 -0
  147. package/dist/store-fs.d.ts.map +1 -0
  148. package/dist/store-fs.js +98 -0
  149. package/dist/store-fs.js.map +1 -0
  150. package/dist/transpile.d.ts +32 -0
  151. package/dist/transpile.d.ts.map +1 -0
  152. package/dist/transpile.js +63 -0
  153. package/dist/transpile.js.map +1 -0
  154. package/dist/typecheck-store.d.ts +41 -0
  155. package/dist/typecheck-store.d.ts.map +1 -0
  156. package/dist/typecheck-store.js +102 -0
  157. package/dist/typecheck-store.js.map +1 -0
  158. package/dist/writers/alias.d.ts +13 -0
  159. package/dist/writers/alias.d.ts.map +1 -0
  160. package/dist/writers/alias.js +17 -0
  161. package/dist/writers/alias.js.map +1 -0
  162. package/dist/writers/async.d.ts +22 -0
  163. package/dist/writers/async.d.ts.map +1 -0
  164. package/dist/writers/async.js +48 -0
  165. package/dist/writers/async.js.map +1 -0
  166. package/dist/writers/boxed-constructor.d.ts +26 -0
  167. package/dist/writers/boxed-constructor.d.ts.map +1 -0
  168. package/dist/writers/boxed-constructor.js +85 -0
  169. package/dist/writers/boxed-constructor.js.map +1 -0
  170. package/dist/writers/boxed-field-accessor.d.ts +18 -0
  171. package/dist/writers/boxed-field-accessor.d.ts.map +1 -0
  172. package/dist/writers/boxed-field-accessor.js +260 -0
  173. package/dist/writers/boxed-field-accessor.js.map +1 -0
  174. package/dist/writers/boxed-layout.d.ts +27 -0
  175. package/dist/writers/boxed-layout.d.ts.map +1 -0
  176. package/dist/writers/boxed-layout.js +128 -0
  177. package/dist/writers/boxed-layout.js.map +1 -0
  178. package/dist/writers/boxed.d.ts +20 -0
  179. package/dist/writers/boxed.d.ts.map +1 -0
  180. package/dist/writers/boxed.js +71 -0
  181. package/dist/writers/boxed.js.map +1 -0
  182. package/dist/writers/callables.d.ts +124 -0
  183. package/dist/writers/callables.d.ts.map +1 -0
  184. package/dist/writers/callables.js +283 -0
  185. package/dist/writers/callables.js.map +1 -0
  186. package/dist/writers/callback.d.ts +16 -0
  187. package/dist/writers/callback.d.ts.map +1 -0
  188. package/dist/writers/callback.js +38 -0
  189. package/dist/writers/callback.js.map +1 -0
  190. package/dist/writers/class-struct-record.d.ts +31 -0
  191. package/dist/writers/class-struct-record.d.ts.map +1 -0
  192. package/dist/writers/class-struct-record.js +67 -0
  193. package/dist/writers/class-struct-record.js.map +1 -0
  194. package/dist/writers/class-struct.d.ts +22 -0
  195. package/dist/writers/class-struct.d.ts.map +1 -0
  196. package/dist/writers/class-struct.js +85 -0
  197. package/dist/writers/class-struct.js.map +1 -0
  198. package/dist/writers/class.d.ts +16 -0
  199. package/dist/writers/class.d.ts.map +1 -0
  200. package/dist/writers/class.js +307 -0
  201. package/dist/writers/class.js.map +1 -0
  202. package/dist/writers/constant.d.ts +15 -0
  203. package/dist/writers/constant.d.ts.map +1 -0
  204. package/dist/writers/constant.js +23 -0
  205. package/dist/writers/constant.js.map +1 -0
  206. package/dist/writers/constants.d.ts +15 -0
  207. package/dist/writers/constants.d.ts.map +1 -0
  208. package/dist/writers/constants.js +23 -0
  209. package/dist/writers/constants.js.map +1 -0
  210. package/dist/writers/constructor-props.d.ts +32 -0
  211. package/dist/writers/constructor-props.d.ts.map +1 -0
  212. package/dist/writers/constructor-props.js +110 -0
  213. package/dist/writers/constructor-props.js.map +1 -0
  214. package/dist/writers/enum.d.ts +21 -0
  215. package/dist/writers/enum.d.ts.map +1 -0
  216. package/dist/writers/enum.js +48 -0
  217. package/dist/writers/enum.js.map +1 -0
  218. package/dist/writers/function.d.ts +40 -0
  219. package/dist/writers/function.d.ts.map +1 -0
  220. package/dist/writers/function.js +127 -0
  221. package/dist/writers/function.js.map +1 -0
  222. package/dist/writers/gtype-binding.d.ts +19 -0
  223. package/dist/writers/gtype-binding.d.ts.map +1 -0
  224. package/dist/writers/gtype-binding.js +40 -0
  225. package/dist/writers/gtype-binding.js.map +1 -0
  226. package/dist/writers/inheritance.d.ts +48 -0
  227. package/dist/writers/inheritance.d.ts.map +1 -0
  228. package/dist/writers/inheritance.js +90 -0
  229. package/dist/writers/inheritance.js.map +1 -0
  230. package/dist/writers/interface.d.ts +16 -0
  231. package/dist/writers/interface.d.ts.map +1 -0
  232. package/dist/writers/interface.js +155 -0
  233. package/dist/writers/interface.js.map +1 -0
  234. package/dist/writers/method.d.ts +150 -0
  235. package/dist/writers/method.d.ts.map +1 -0
  236. package/dist/writers/method.js +510 -0
  237. package/dist/writers/method.js.map +1 -0
  238. package/dist/writers/param-classify.d.ts +93 -0
  239. package/dist/writers/param-classify.d.ts.map +1 -0
  240. package/dist/writers/param-classify.js +163 -0
  241. package/dist/writers/param-classify.js.map +1 -0
  242. package/dist/writers/property-accessor.d.ts +19 -0
  243. package/dist/writers/property-accessor.d.ts.map +1 -0
  244. package/dist/writers/property-accessor.js +117 -0
  245. package/dist/writers/property-accessor.js.map +1 -0
  246. package/dist/writers/registration.d.ts +27 -0
  247. package/dist/writers/registration.d.ts.map +1 -0
  248. package/dist/writers/registration.js +30 -0
  249. package/dist/writers/registration.js.map +1 -0
  250. package/dist/writers/return-wrap.d.ts +39 -0
  251. package/dist/writers/return-wrap.d.ts.map +1 -0
  252. package/dist/writers/return-wrap.js +152 -0
  253. package/dist/writers/return-wrap.js.map +1 -0
  254. package/dist/writers/runtime-override.d.ts +18 -0
  255. package/dist/writers/runtime-override.d.ts.map +1 -0
  256. package/dist/writers/runtime-override.js +44 -0
  257. package/dist/writers/runtime-override.js.map +1 -0
  258. package/dist/writers/signal.d.ts +21 -0
  259. package/dist/writers/signal.d.ts.map +1 -0
  260. package/dist/writers/signal.js +260 -0
  261. package/dist/writers/signal.js.map +1 -0
  262. package/dist/writers/ts-type.d.ts +50 -0
  263. package/dist/writers/ts-type.d.ts.map +1 -0
  264. package/dist/writers/ts-type.js +75 -0
  265. package/dist/writers/ts-type.js.map +1 -0
  266. package/dist/writers/types-ts.d.ts +27 -0
  267. package/dist/writers/types-ts.d.ts.map +1 -0
  268. package/dist/writers/types-ts.js +97 -0
  269. package/dist/writers/types-ts.js.map +1 -0
  270. package/dist/writers/value.d.ts +89 -0
  271. package/dist/writers/value.d.ts.map +1 -0
  272. package/dist/writers/value.js +402 -0
  273. package/dist/writers/value.js.map +1 -0
  274. package/package.json +55 -0
  275. package/src/dsl/context.ts +146 -0
  276. package/src/dsl/emit.ts +42 -0
  277. package/src/dsl/identifier.ts +52 -0
  278. package/src/dsl/imports.ts +109 -0
  279. package/src/dsl/module.ts +75 -0
  280. package/src/ffi/pipeline.ts +113 -0
  281. package/src/fingerprint.ts +50 -0
  282. package/src/gi-store.ts +199 -0
  283. package/src/gir/boxed.ts +94 -0
  284. package/src/gir/callback.ts +26 -0
  285. package/src/gir/class.ts +79 -0
  286. package/src/gir/enum.ts +55 -0
  287. package/src/gir/field.ts +40 -0
  288. package/src/gir/function.ts +67 -0
  289. package/src/gir/namespace.ts +118 -0
  290. package/src/gir/parameter.ts +120 -0
  291. package/src/gir/parse.ts +171 -0
  292. package/src/gir/primitives.ts +137 -0
  293. package/src/gir/property.ts +39 -0
  294. package/src/gir/qualified-name.ts +55 -0
  295. package/src/gir/qualify.ts +64 -0
  296. package/src/gir/repository.ts +149 -0
  297. package/src/gir/signal.ts +36 -0
  298. package/src/gir/size.ts +129 -0
  299. package/src/gir/type-ref.ts +180 -0
  300. package/src/index.ts +16 -0
  301. package/src/jsx-store.ts +53 -0
  302. package/src/react/compounds-meta.ts +99 -0
  303. package/src/react/compounds.ts +204 -0
  304. package/src/react/internal.ts +91 -0
  305. package/src/react/jsx.ts +155 -0
  306. package/src/react/pipeline.ts +29 -0
  307. package/src/react/props.ts +307 -0
  308. package/src/react/slot-props.ts +57 -0
  309. package/src/react/widgets.ts +185 -0
  310. package/src/runner.ts +89 -0
  311. package/src/store-fs.ts +157 -0
  312. package/src/transpile.ts +80 -0
  313. package/src/typecheck-store.ts +136 -0
  314. package/src/writers/alias.ts +19 -0
  315. package/src/writers/async.ts +44 -0
  316. package/src/writers/boxed-constructor.ts +105 -0
  317. package/src/writers/boxed-field-accessor.ts +306 -0
  318. package/src/writers/boxed-layout.ts +166 -0
  319. package/src/writers/boxed.ts +77 -0
  320. package/src/writers/callables.ts +339 -0
  321. package/src/writers/callback.ts +40 -0
  322. package/src/writers/class-struct-record.ts +75 -0
  323. package/src/writers/class-struct.ts +96 -0
  324. package/src/writers/class.ts +384 -0
  325. package/src/writers/constant.ts +29 -0
  326. package/src/writers/constructor-props.ts +130 -0
  327. package/src/writers/enum.ts +53 -0
  328. package/src/writers/function.ts +136 -0
  329. package/src/writers/gtype-binding.ts +48 -0
  330. package/src/writers/inheritance.ts +104 -0
  331. package/src/writers/interface.ts +168 -0
  332. package/src/writers/method.ts +678 -0
  333. package/src/writers/param-classify.ts +178 -0
  334. package/src/writers/property-accessor.ts +139 -0
  335. package/src/writers/registration.ts +42 -0
  336. package/src/writers/return-wrap.ts +180 -0
  337. package/src/writers/runtime-override.ts +59 -0
  338. package/src/writers/signal.ts +318 -0
  339. package/src/writers/ts-type.ts +115 -0
  340. package/src/writers/value.ts +485 -0
@@ -0,0 +1,27 @@
1
+ import type { GirRepository } from "../gir/repository.js";
2
+ /**
3
+ * Generates `compounds.tsx` source — one statically-compiled React
4
+ * component per widget that has slot props, container-slot props, or
5
+ * virtual-child sub-components.
6
+ *
7
+ * Each component is plain JSX: it destructures its slot and container-slot
8
+ * props, forwards the rest to the host intrinsic, and wraps each non-null
9
+ * slot value in a `<Slot>` (setter) or `<ContainerSlot>` (append) element.
10
+ * Virtual-child sub-components (e.g. `GtkStack.Page`) are attached with
11
+ * `Object.assign` under an explicit intersection type so isolated
12
+ * declaration emit succeeds.
13
+ *
14
+ * A host intrinsic is referenced through a module-local
15
+ * `${Name}Element = "Name"` const so the JSX tag does not collide with the
16
+ * exported component of the same name. Widgets with no slots, container
17
+ * slots, or virtual children remain bare string-constant intrinsics in
18
+ * `jsx.ts`.
19
+ *
20
+ * @param repository - The loaded GIR repository
21
+ * @param userSlotProps - User-supplied slot-prop overrides
22
+ */
23
+ export declare const generateCompounds: (repository: GirRepository, userSlotProps: Readonly<Record<string, readonly string[]>> | undefined) => {
24
+ readonly source: string;
25
+ readonly exportedNames: ReadonlySet<string>;
26
+ };
27
+ //# sourceMappingURL=compounds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compounds.d.ts","sourceRoot":"","sources":["../../src/react/compounds.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAW1D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iBAAiB,GAC1B,YAAY,aAAa,EACzB,eAAe,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,KACvE;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CA2BxE,CAAC"}
@@ -0,0 +1,164 @@
1
+ import { quote } from "@gtkx/utils";
2
+ import { indent } from "../dsl/emit.js";
3
+ import { containerSlotsFor, virtualSubcomponentsFor } from "./compounds-meta.js";
4
+ import { mergeSlotProps } from "./slot-props.js";
5
+ import { ancestorGlibNames, isWidgetClass, iterateClassesWithGlibName } from "./widgets.js";
6
+ /**
7
+ * Generates `compounds.tsx` source — one statically-compiled React
8
+ * component per widget that has slot props, container-slot props, or
9
+ * virtual-child sub-components.
10
+ *
11
+ * Each component is plain JSX: it destructures its slot and container-slot
12
+ * props, forwards the rest to the host intrinsic, and wraps each non-null
13
+ * slot value in a `<Slot>` (setter) or `<ContainerSlot>` (append) element.
14
+ * Virtual-child sub-components (e.g. `GtkStack.Page`) are attached with
15
+ * `Object.assign` under an explicit intersection type so isolated
16
+ * declaration emit succeeds.
17
+ *
18
+ * A host intrinsic is referenced through a module-local
19
+ * `${Name}Element = "Name"` const so the JSX tag does not collide with the
20
+ * exported component of the same name. Widgets with no slots, container
21
+ * slots, or virtual children remain bare string-constant intrinsics in
22
+ * `jsx.ts`.
23
+ *
24
+ * @param repository - The loaded GIR repository
25
+ * @param userSlotProps - User-supplied slot-prop overrides
26
+ */
27
+ export const generateCompounds = (repository, userSlotProps) => {
28
+ const slotPropMap = mergeSlotProps(userSlotProps);
29
+ const exportedNames = new Set();
30
+ const exportLines = [];
31
+ const accumulator = {
32
+ elementNames: new Set(),
33
+ compoundPropTypes: new Set(),
34
+ virtualPropTypes: new Set(),
35
+ };
36
+ for (const { glibName, klass, namespace } of collectCompoundCandidates(repository)) {
37
+ const slots = resolveInheritedSlots(slotPropMap, klass, namespace, repository);
38
+ const containers = containerSlotsFor(glibName);
39
+ const virtuals = virtualSubcomponentsFor(glibName);
40
+ if (slots.length === 0 && containers.length === 0 && virtuals.length === 0)
41
+ continue;
42
+ exportLines.push(renderCompound({ glibName, slots, containers, virtuals }, accumulator));
43
+ exportedNames.add(glibName);
44
+ }
45
+ const sections = [
46
+ renderImportLines(accumulator).join("\n"),
47
+ renderElementConsts(accumulator),
48
+ exportLines.join("\n\n"),
49
+ ];
50
+ const source = `${sections.filter((section) => section.length > 0).join("\n\n")}\n`;
51
+ return { source, exportedNames };
52
+ };
53
+ const renderCompound = (shape, accumulator) => {
54
+ const { glibName, slots, containers, virtuals } = shape;
55
+ const propsType = `${glibName}Props`;
56
+ accumulator.compoundPropTypes.add(propsType);
57
+ accumulator.elementNames.add(glibName);
58
+ if (slots.length > 0)
59
+ accumulator.elementNames.add("Slot");
60
+ if (containers.length > 0)
61
+ accumulator.elementNames.add("ContainerSlot");
62
+ const component = renderComponentFunction(glibName, propsType, slots, containers);
63
+ if (virtuals.length === 0) {
64
+ return `export const ${glibName} = ${component};`;
65
+ }
66
+ const subcomponents = virtuals.map((virtual) => renderVirtualSubcomponent(virtual, accumulator));
67
+ const fields = subcomponents.map((sub) => ` ${sub.field};`).join("\n");
68
+ const impls = subcomponents.map((sub) => indent(`${sub.impl},`, 1)).join("\n");
69
+ return [
70
+ `export const ${glibName}: ((props: ${propsType}) => ReactNode) & {`,
71
+ fields,
72
+ `} = Object.assign(`,
73
+ `${indent(component, 1)},`,
74
+ " {",
75
+ impls,
76
+ " },",
77
+ ");",
78
+ ].join("\n");
79
+ };
80
+ const renderComponentFunction = (glibName, propsType, slots, containers) => {
81
+ const host = `${glibName}Element`;
82
+ if (slots.length === 0 && containers.length === 0) {
83
+ return [
84
+ `(props: ${propsType}): ReactNode => {`,
85
+ " const { children, ...rest } = props;",
86
+ ` return <${host} {...rest}>{children}</${host}>;`,
87
+ "}",
88
+ ].join("\n");
89
+ }
90
+ const destructured = [...slots, ...containers, "children"].join(", ");
91
+ const slotChildren = [
92
+ ...slots.map((slot) => renderSlotChild("SlotElement", slot)),
93
+ ...containers.map((container) => renderSlotChild("ContainerSlotElement", container)),
94
+ ];
95
+ return [
96
+ `(props: ${propsType}): ReactNode => {`,
97
+ ` const { ${destructured}, ...rest } = props;`,
98
+ " return (",
99
+ ` <${host} {...rest}>`,
100
+ " {children}",
101
+ ...slotChildren.map((child) => ` ${child}`),
102
+ ` </${host}>`,
103
+ " );",
104
+ "}",
105
+ ].join("\n");
106
+ };
107
+ const renderSlotChild = (elementConst, slot) => `{${slot} != null && <${elementConst} id=${quote(slot)}>{${slot}}</${elementConst}>}`;
108
+ const renderVirtualSubcomponent = (virtual, accumulator) => {
109
+ const { child, intrinsic } = virtual;
110
+ const propsType = `${intrinsic}Props`;
111
+ accumulator.virtualPropTypes.add(propsType);
112
+ accumulator.elementNames.add(intrinsic);
113
+ return {
114
+ field: `${child}: (props: ${propsType}) => ReactNode`,
115
+ impl: `${child}: (props: ${propsType}): ReactNode => <${intrinsic}Element {...props} />`,
116
+ };
117
+ };
118
+ const renderElementConsts = (accumulator) => [...accumulator.elementNames]
119
+ .sort((a, b) => a.localeCompare(b))
120
+ .map((name) => `const ${name}Element = ${quote(name)} as const;`)
121
+ .join("\n");
122
+ const renderImportLines = (accumulator) => {
123
+ const lines = ['import type { ReactNode } from "react";'];
124
+ const compoundPropTypes = [...accumulator.compoundPropTypes].sort((a, b) => a.localeCompare(b));
125
+ if (compoundPropTypes.length > 0) {
126
+ lines.push(`import type { ${compoundPropTypes.join(", ")} } from "./jsx.js";`);
127
+ }
128
+ const virtualPropTypes = [...accumulator.virtualPropTypes].sort((a, b) => a.localeCompare(b));
129
+ if (virtualPropTypes.length > 0) {
130
+ lines.push(`import type { ${virtualPropTypes.join(", ")} } from "@gtkx/react";`);
131
+ }
132
+ return lines;
133
+ };
134
+ const resolveInheritedSlots = (slotPropMap, klass, namespace, repository) => {
135
+ const seen = new Set();
136
+ const slots = [];
137
+ for (const glibName of ancestorGlibNames(klass, namespace, repository)) {
138
+ for (const slot of slotPropMap[glibName] ?? []) {
139
+ if (seen.has(slot))
140
+ continue;
141
+ seen.add(slot);
142
+ slots.push(slot);
143
+ }
144
+ }
145
+ return slots;
146
+ };
147
+ const collectCompoundCandidates = (repository) => {
148
+ const seen = new Set();
149
+ const candidates = [];
150
+ for (const candidate of iterateClassesWithGlibName(repository)) {
151
+ const { glibName, klass, namespace } = candidate;
152
+ const isWidget = isWidgetClass(klass, namespace, repository);
153
+ const hasContainerSlot = containerSlotsFor(glibName).length > 0;
154
+ const hasVirtualChild = virtualSubcomponentsFor(glibName).length > 0;
155
+ if (!isWidget && !hasContainerSlot && !hasVirtualChild)
156
+ continue;
157
+ if (seen.has(glibName))
158
+ continue;
159
+ seen.add(glibName);
160
+ candidates.push(candidate);
161
+ }
162
+ return candidates.sort((a, b) => a.glibName.localeCompare(b.glibName));
163
+ };
164
+ //# sourceMappingURL=compounds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compounds.js","sourceRoot":"","sources":["../../src/react/compounds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,0BAA0B,EAAwB,MAAM,cAAc,CAAC;AAQlH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC7B,UAAyB,EACzB,aAAsE,EACE,EAAE;IAC1E,MAAM,WAAW,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IACxC,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,MAAM,WAAW,GAAwB;QACrC,YAAY,EAAE,IAAI,GAAG,EAAU;QAC/B,iBAAiB,EAAE,IAAI,GAAG,EAAU;QACpC,gBAAgB,EAAE,IAAI,GAAG,EAAU;KACtC,CAAC;IAEF,KAAK,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,yBAAyB,CAAC,UAAU,CAAC,EAAE,CAAC;QACjF,MAAM,KAAK,GAAG,qBAAqB,CAAC,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,UAA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CAAC;QAChE,MAAM,eAAe,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QACrE,IAAI,CAAC,QAAQ,IAAI,CAAC,gBAAgB,IAAI,CAAC,eAAe;YAAE,SAAS;QACjE,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;YAAE,SAAS;QACjC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACnB,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC3E,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { GirRepository } from "../gir/repository.js";
2
+ /**
3
+ * Generates `internal.ts` source — the `SIGNALS` and `CONSTRUCT_ONLY_PROPS`
4
+ * tables consumed by the React metadata resolver.
5
+ *
6
+ * Walks every widget across every loaded namespace and emits one entry
7
+ * per GLib type name. Signals are mapped from kebab-case to `onCamelCase`;
8
+ * construct-only properties are surfaced as a `Set` for the runtime to
9
+ * consult on mount.
10
+ *
11
+ * @param repository - The loaded GIR repository
12
+ */
13
+ export declare const generateInternal: (repository: GirRepository) => string;
14
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/react/internal.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,GAAI,YAAY,aAAa,KAAG,MAiB5D,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { quote, toCamelCase, toIdentifier } from "@gtkx/utils";
2
+ import { implementedInterfaces, isReactNodeClass, iterateClassesWithGlibName, signalHandlerName } from "./widgets.js";
3
+ /**
4
+ * Generates `internal.ts` source — the `SIGNALS` and `CONSTRUCT_ONLY_PROPS`
5
+ * tables consumed by the React metadata resolver.
6
+ *
7
+ * Walks every widget across every loaded namespace and emits one entry
8
+ * per GLib type name. Signals are mapped from kebab-case to `onCamelCase`;
9
+ * construct-only properties are surfaced as a `Set` for the runtime to
10
+ * consult on mount.
11
+ *
12
+ * @param repository - The loaded GIR repository
13
+ */
14
+ export const generateInternal = (repository) => {
15
+ const widgets = collectWidgets(repository);
16
+ const signalsEntries = widgets.map(({ glibName, signals }) => ` "${glibName}": ${renderSignalsObject(signals)},`);
17
+ const constructOnlyEntries = widgets
18
+ .filter(({ constructOnly }) => constructOnly.length > 0)
19
+ .map(({ glibName, constructOnly }) => ` "${glibName}": new Set([${constructOnly.map(quote).join(",")}]),`);
20
+ const namespaces = [...new Set(widgets.map((widget) => widget.namespace))].sort((a, b) => a.localeCompare(b));
21
+ const preamble = namespaces.map((name) => `import "@gtkx/gi/${name.toLowerCase()}";`).join("\n");
22
+ return `${[
23
+ preamble,
24
+ `export const SIGNALS: Readonly<Record<string, Readonly<Record<string, string>>>> = {\n${signalsEntries.join("\n")}\n};`,
25
+ `export const CONSTRUCT_ONLY_PROPS: Readonly<Record<string, ReadonlySet<string>>> = {\n${constructOnlyEntries.join("\n")}\n};`,
26
+ ].join("\n\n")}\n`;
27
+ };
28
+ const collectWidgets = (repository) => {
29
+ const entries = [];
30
+ for (const { glibName, klass, namespace } of iterateClassesWithGlibName(repository)) {
31
+ if (!isReactNodeClass(klass, namespace, repository))
32
+ continue;
33
+ const sources = [klass, ...implementedInterfaces(klass, namespace, repository).map((entry) => entry.klass)];
34
+ entries.push({
35
+ glibName,
36
+ namespace: namespace.name,
37
+ signals: collectSignals(sources),
38
+ constructOnly: collectConstructOnly(sources),
39
+ });
40
+ }
41
+ return entries.sort((a, b) => a.glibName.localeCompare(b.glibName));
42
+ };
43
+ const collectSignals = (sources) => {
44
+ const seen = new Set();
45
+ const signals = [];
46
+ for (const source of sources) {
47
+ for (const signal of source.signals) {
48
+ const handlerName = signalHandlerName(signal.name);
49
+ if (seen.has(handlerName))
50
+ continue;
51
+ seen.add(handlerName);
52
+ signals.push([handlerName, signal.name]);
53
+ }
54
+ }
55
+ return signals;
56
+ };
57
+ const collectConstructOnly = (sources) => {
58
+ const seen = new Set();
59
+ const names = [];
60
+ for (const source of sources) {
61
+ for (const property of source.properties) {
62
+ if (!property.constructOnly)
63
+ continue;
64
+ const jsName = toIdentifier(toCamelCase(property.name));
65
+ if (seen.has(jsName))
66
+ continue;
67
+ seen.add(jsName);
68
+ names.push(jsName);
69
+ }
70
+ }
71
+ return names;
72
+ };
73
+ const renderSignalsObject = (entries) => {
74
+ if (entries.length === 0)
75
+ return "{}";
76
+ const lines = entries.map(([key, value]) => ` ${quote(key)}: ${quote(value)}`);
77
+ return `{\n${lines.join(",\n")}\n }`;
78
+ };
79
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/react/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG/D,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,UAAyB,EAAU,EAAE;IAClE,MAAM,OAAO,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAC9B,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,QAAQ,QAAQ,MAAM,mBAAmB,CAAC,OAAO,CAAC,GAAG,CACnF,CAAC;IACF,MAAM,oBAAoB,GAAG,OAAO;SAC/B,MAAM,CAAC,CAAC,EAAE,aAAa,EA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,QAAQ,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACvC,IAAI,CAAC,QAAQ,CAAC,aAAa;gBAAE,SAAS;YACtC,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;YACxD,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;gBAAE,SAAS;YAC/B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACjB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,OAAiD,EAAU,EAAE;IACtF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACtC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,WAAW,KAAK,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACtF,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;AAC5C,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { GirRepository } from "../gir/repository.js";
2
+ /**
3
+ * Generates `jsx.ts` source — one `export const Name = "Name"` per JSX
4
+ * intrinsic element (every GtkWidget descendant plus event controllers
5
+ * and layout managers) that is NOT exported as a slot-widget compound,
6
+ * plus an `export type NameProps` permissive prop bag per intrinsic and
7
+ * a `WidgetSlotNames` index of every widget's allowed slot names.
8
+ *
9
+ * Compounds.ts owns its widgets' runtime exports. To prevent ambiguous
10
+ * re-exports when consumers wildcard both `compounds.js` and `jsx.js`,
11
+ * widgets covered by `excludeNames` are skipped here and the consumer
12
+ * sees a single function-typed export from compounds instead of the
13
+ * string-literal constant. Prop types are still emitted for every
14
+ * widget — they live in the type namespace and never clash with
15
+ * compounds.
16
+ *
17
+ * @param repository - The loaded GIR repository
18
+ * @param excludeNames - Widgets already exported by `compounds.ts`
19
+ * @param slotPropMap - Per-widget slot prop name overrides
20
+ */
21
+ export declare const generateJsx: (repository: GirRepository, excludeNames?: ReadonlySet<string>, slotPropMap?: Readonly<Record<string, readonly string[]>>) => string;
22
+ //# sourceMappingURL=jsx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../../src/react/jsx.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAK1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW,GACpB,YAAY,aAAa,EACzB,eAAc,WAAW,CAAC,MAAM,CAAa,EAC7C,cAAa,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAM,KAC9D,MAiDF,CAAC"}
@@ -0,0 +1,134 @@
1
+ import { quote } from "@gtkx/utils";
2
+ import { splitQualifiedName } from "../gir/qualified-name.js";
3
+ import { containerSlotsFor } from "./compounds-meta.js";
4
+ import { buildWidgetPropsEntries } from "./props.js";
5
+ import { isReactNodeClass, iterateClassesWithGlibName } from "./widgets.js";
6
+ /**
7
+ * Generates `jsx.ts` source — one `export const Name = "Name"` per JSX
8
+ * intrinsic element (every GtkWidget descendant plus event controllers
9
+ * and layout managers) that is NOT exported as a slot-widget compound,
10
+ * plus an `export type NameProps` permissive prop bag per intrinsic and
11
+ * a `WidgetSlotNames` index of every widget's allowed slot names.
12
+ *
13
+ * Compounds.ts owns its widgets' runtime exports. To prevent ambiguous
14
+ * re-exports when consumers wildcard both `compounds.js` and `jsx.js`,
15
+ * widgets covered by `excludeNames` are skipped here and the consumer
16
+ * sees a single function-typed export from compounds instead of the
17
+ * string-literal constant. Prop types are still emitted for every
18
+ * widget — they live in the type namespace and never clash with
19
+ * compounds.
20
+ *
21
+ * @param repository - The loaded GIR repository
22
+ * @param excludeNames - Widgets already exported by `compounds.ts`
23
+ * @param slotPropMap - Per-widget slot prop name overrides
24
+ */
25
+ export const generateJsx = (repository, excludeNames = new Set(), slotPropMap = {}) => {
26
+ const widgets = collectWidgets(repository);
27
+ const intrinsicWidgets = widgets.filter((entry) => !excludeNames.has(entry.glibName));
28
+ const constLines = intrinsicWidgets.map((entry) => `export const ${entry.glibName} = ${quote(entry.glibName)} as const;`);
29
+ const widgetByGlibName = new Map(widgets.map((entry) => [entry.glibName, entry]));
30
+ const isWidgetAncestor = (candidate) => {
31
+ const candidateGlib = candidate.glibTypeName ?? candidate.cType;
32
+ return candidateGlib !== undefined && widgetByGlibName.has(candidateGlib);
33
+ };
34
+ const namespaceImports = new Map();
35
+ const propBlocks = ["export interface WidgetProps {\n name?: string;\n}"];
36
+ for (const entry of widgets) {
37
+ const block = renderPropBlock(repository, entry, {
38
+ slotPropMap,
39
+ isWidgetAncestor,
40
+ widgetByGlibName,
41
+ namespaceImports,
42
+ });
43
+ propBlocks.push(block);
44
+ }
45
+ const importLines = renderImportLines(namespaceImports);
46
+ const slotEntries = widgets.map((entry) => ` readonly ${quote(entry.glibName)}: string`);
47
+ const slotNamesLine = `export type WidgetSlotNames = {\n${slotEntries.join(";\n")};\n};`;
48
+ const intrinsicEntries = widgets.map((entry) => ` ${entry.glibName}: ${entry.glibName}Props;`);
49
+ const jsxAugmentation = [
50
+ "declare global {",
51
+ " namespace React.JSX {",
52
+ " interface IntrinsicElements {",
53
+ ...intrinsicEntries,
54
+ " }",
55
+ " }",
56
+ "}",
57
+ ].join("\n");
58
+ const body = [
59
+ importLines.join("\n"),
60
+ "",
61
+ constLines.join("\n"),
62
+ "",
63
+ propBlocks.join("\n\n"),
64
+ "",
65
+ slotNamesLine,
66
+ "",
67
+ jsxAugmentation,
68
+ ].join("\n");
69
+ return `${body}\n`;
70
+ };
71
+ const renderPropBlock = (repository, entry, context) => {
72
+ const slotPropNames = new Set(context.slotPropMap[entry.glibName] ?? []);
73
+ const { propLines, imports } = buildWidgetPropsEntries({
74
+ repository,
75
+ klass: entry.klass,
76
+ slotPropNames,
77
+ isWidgetAncestor: context.isWidgetAncestor,
78
+ });
79
+ for (const [namespace, alias] of imports)
80
+ context.namespaceImports.set(namespace, alias);
81
+ context.namespaceImports.set(entry.namespace.name, entry.namespace.name);
82
+ const widgetTypeRef = `${entry.namespace.name}.${entry.klass.name} | null`;
83
+ const ownerLines = [
84
+ " children?: ReactNode;",
85
+ ` ref?: Ref<${widgetTypeRef}>;`,
86
+ ...propLines.map((line) => ` ${line}`),
87
+ ...containerSlotsFor(entry.glibName).map((method) => ` ${method}?: ReactNode | null;`),
88
+ ];
89
+ const parentExtends = resolveParentPropsExtension(repository, entry, context.widgetByGlibName);
90
+ return `export interface ${entry.glibName}Props extends ${parentExtends} {\n${ownerLines.join("\n")}\n}`;
91
+ };
92
+ const renderImportLines = (namespaceImports) => {
93
+ const lines = ['import type { ReactNode, Ref } from "react";'];
94
+ for (const [namespaceName, alias] of namespaceImports) {
95
+ if (namespaceName === "")
96
+ continue;
97
+ const directory = namespaceName.toLowerCase();
98
+ lines.push(`import type * as ${alias} from "${ffiImportPath(directory)}";`);
99
+ }
100
+ return lines;
101
+ };
102
+ const collectWidgets = (repository) => {
103
+ const entries = [];
104
+ const seen = new Set();
105
+ for (const candidate of iterateClassesWithGlibName(repository)) {
106
+ const { glibName, klass, namespace } = candidate;
107
+ if (!isReactNodeClass(klass, namespace, repository))
108
+ continue;
109
+ if (seen.has(glibName))
110
+ continue;
111
+ seen.add(glibName);
112
+ entries.push(candidate);
113
+ }
114
+ return entries.sort((a, b) => a.glibName.localeCompare(b.glibName));
115
+ };
116
+ const ffiImportPath = (directory) => `@gtkx/gi/${directory}`;
117
+ const resolveParentPropsExtension = (repository, entry, widgetByGlibName) => {
118
+ const parent = entry.klass.parent;
119
+ if (parent === undefined)
120
+ return "WidgetProps";
121
+ const { namespaceName, typeName } = splitQualifiedName(parent, entry.namespace.name);
122
+ const resolved = repository.resolveNamed(namespaceName, typeName);
123
+ if (resolved === undefined)
124
+ return "WidgetProps";
125
+ if (resolved.kind !== "class" && resolved.kind !== "interface")
126
+ return "WidgetProps";
127
+ const parentGlib = resolved.value.glibTypeName ?? resolved.value.cType;
128
+ if (parentGlib === undefined)
129
+ return "WidgetProps";
130
+ if (!widgetByGlibName.has(parentGlib))
131
+ return "WidgetProps";
132
+ return `${parentGlib}Props`;
133
+ };
134
+ //# sourceMappingURL=jsx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx.js","sourceRoot":"","sources":["../../src/react/jsx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAwB,MAAM,cAAc,CAAC;AAElG;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACvB,UAAyB,EACzB,eAAoC,IAAI,GAAG,EAAE,EAC7C,cAA2D,EAAE,EACvD,EAAE;IACR,MAAM,OAAO,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtF,MAAM,UAAU,GAAG,gBAAgB,CAAC,GAAG,CACnC,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,KAAK,CAAC,QAAQ,MAAM,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CACnF,CAAC;IAEF,MAAM,gBAAgB,GAAG,IAAI,GA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import type { GirRepository } from "../gir/repository.js";
2
+ /**
3
+ * Produces the three React generated files (`jsx.ts`, `internal.ts`,
4
+ * `compounds.tsx`) plus a summary widget count for the runner result.
5
+ *
6
+ * @param repository - The loaded GIR repository
7
+ * @param userSlotProps - Slot-prop overrides from `gtkx.config.ts`
8
+ */
9
+ export declare const generateReactFiles: (repository: GirRepository, userSlotProps: Readonly<Record<string, readonly string[]>> | undefined) => {
10
+ readonly files: Map<string, string>;
11
+ readonly widgetCount: number;
12
+ };
13
+ //# sourceMappingURL=pipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/react/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAM1D;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC3B,YAAY,aAAa,EACzB,eAAe,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,KACvE;IAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAYrE,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { generateCompounds } from "./compounds.js";
2
+ import { generateInternal } from "./internal.js";
3
+ import { generateJsx } from "./jsx.js";
4
+ import { mergeSlotProps } from "./slot-props.js";
5
+ /**
6
+ * Produces the three React generated files (`jsx.ts`, `internal.ts`,
7
+ * `compounds.tsx`) plus a summary widget count for the runner result.
8
+ *
9
+ * @param repository - The loaded GIR repository
10
+ * @param userSlotProps - Slot-prop overrides from `gtkx.config.ts`
11
+ */
12
+ export const generateReactFiles = (repository, userSlotProps) => {
13
+ const slotPropMap = mergeSlotProps(userSlotProps);
14
+ const compounds = generateCompounds(repository, userSlotProps);
15
+ const jsx = generateJsx(repository, compounds.exportedNames, slotPropMap);
16
+ const internal = generateInternal(repository);
17
+ const files = new Map([
18
+ ["jsx.ts", jsx],
19
+ ["internal.ts", internal],
20
+ ["compounds.tsx", compounds.source],
21
+ ]);
22
+ const widgetCount = jsx.split("\n").filter((line) => line.startsWith("export const ")).length;
23
+ return { files, widgetCount };
24
+ };
25
+ //# sourceMappingURL=pipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/react/pipeline.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAC9B,UAAyB,EACzB,aAAsE,EACD,EAAE;IACvE,MAAM,WAAW,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,iBAAiB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAC/D,MAAM,GAAG,GAAG,WAAW,CAAC,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IAC1E,MAAM,QAAQ,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAI,GAAG,CAAiB;QAClC,CAAC,QAAQ,EAAE,GAAG,CAAC;QACf,CAAC,aAAa,EAAE,QAAQ,CAAC;QACzB,CAAC,eAAe,EAAE,SAAS,CAAC,MAAM,CAAC;KACtC,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9F,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AAClC,CAAC,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { GirClass } from "../gir/class.js";
2
+ import type { GirRepository } from "../gir/repository.js";
3
+ /**
4
+ * Rendered prop entries for a single widget's Props interface, together
5
+ * with imports the writer must request to keep type references valid.
6
+ */
7
+ export type WidgetPropsEntries = {
8
+ /** Rendered prop lines, indented one level inside the interface body. */
9
+ readonly propLines: readonly string[];
10
+ /** Cross-namespace imports the writer must add to the surrounding module. */
11
+ readonly imports: ReadonlyMap<string, string>;
12
+ };
13
+ /**
14
+ * Options for {@link buildWidgetPropsEntries}.
15
+ */
16
+ export type WidgetPropsOptions = {
17
+ /** The full GIR repository. */
18
+ readonly repository: GirRepository;
19
+ /** The widget class whose props bag is being built. */
20
+ readonly klass: GirClass;
21
+ /** Property names that should be widened to `ReactNode` slot children. */
22
+ readonly slotPropNames?: ReadonlySet<string>;
23
+ /** Returns `true` when `candidate` already has its own widget Props interface. */
24
+ readonly isWidgetAncestor?: (candidate: GirClass) => boolean;
25
+ };
26
+ /**
27
+ * Builds a typed prop bag for one widget intrinsic.
28
+ *
29
+ * Combines the widget's own properties + signal handlers with those declared
30
+ * by its directly-implemented interfaces and by every non-widget ancestor up
31
+ * to the first widget parent (whose props are inherited via `extends`).
32
+ * Property types are written as TypeScript surface types resolved against the
33
+ * loaded GIR repository.
34
+ *
35
+ * @param options - {@link WidgetPropsOptions}
36
+ */
37
+ export declare const buildWidgetPropsEntries: (options: WidgetPropsOptions) => WidgetPropsEntries;
38
+ //# sourceMappingURL=props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/react/props.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAMhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAO1D;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC7B,+BAA+B;IAC/B,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,0EAA0E;IAC1E,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7C,kFAAkF;IAClF,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,KAAK,OAAO,CAAC;CAChE,CAAC;AAYF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS,kBAAkB,KAAG,kBA0CrE,CAAC"}