@gtkx/codegen 0.21.0 → 1.0.0-rc.1

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 (732) hide show
  1. package/README.md +173 -0
  2. package/dist/analysis/descriptor-render.d.ts +18 -0
  3. package/dist/analysis/descriptor-render.d.ts.map +1 -0
  4. package/dist/analysis/descriptor-render.js +297 -0
  5. package/dist/analysis/descriptor-render.js.map +1 -0
  6. package/dist/analysis/descriptor.d.ts +59 -0
  7. package/dist/analysis/descriptor.d.ts.map +1 -0
  8. package/dist/analysis/descriptor.js +123 -0
  9. package/dist/analysis/descriptor.js.map +1 -0
  10. package/dist/analysis/inheritance.d.ts +38 -0
  11. package/dist/analysis/inheritance.d.ts.map +1 -0
  12. package/dist/analysis/inheritance.js +193 -0
  13. package/dist/analysis/inheritance.js.map +1 -0
  14. package/dist/analysis/param-structure.d.ts +26 -0
  15. package/dist/analysis/param-structure.d.ts.map +1 -0
  16. package/dist/analysis/param-structure.js +107 -0
  17. package/dist/analysis/param-structure.js.map +1 -0
  18. package/dist/analysis/ts-type.d.ts +19 -0
  19. package/dist/analysis/ts-type.d.ts.map +1 -0
  20. package/dist/analysis/ts-type.js +65 -0
  21. package/dist/analysis/ts-type.js.map +1 -0
  22. package/dist/compile.d.ts +18 -0
  23. package/dist/compile.d.ts.map +1 -0
  24. package/dist/compile.js +123 -0
  25. package/dist/compile.js.map +1 -0
  26. package/dist/docs/api-reference.d.ts +66 -0
  27. package/dist/docs/api-reference.d.ts.map +1 -0
  28. package/dist/docs/api-reference.js +299 -0
  29. package/dist/docs/api-reference.js.map +1 -0
  30. package/dist/docs/element-page.d.ts +15 -0
  31. package/dist/docs/element-page.d.ts.map +1 -0
  32. package/dist/docs/element-page.js +221 -0
  33. package/dist/docs/element-page.js.map +1 -0
  34. package/dist/docs/pipeline.d.ts +25 -0
  35. package/dist/docs/pipeline.d.ts.map +1 -0
  36. package/dist/docs/pipeline.js +130 -0
  37. package/dist/docs/pipeline.js.map +1 -0
  38. package/dist/docs/render.d.ts +32 -0
  39. package/dist/docs/render.d.ts.map +1 -0
  40. package/dist/docs/render.js +134 -0
  41. package/dist/docs/render.js.map +1 -0
  42. package/dist/docs/symbol-page.d.ts +41 -0
  43. package/dist/docs/symbol-page.d.ts.map +1 -0
  44. package/dist/docs/symbol-page.js +338 -0
  45. package/dist/docs/symbol-page.js.map +1 -0
  46. package/dist/fingerprint.d.ts +6 -26
  47. package/dist/fingerprint.d.ts.map +1 -1
  48. package/dist/fingerprint.js +30 -18
  49. package/dist/fingerprint.js.map +1 -1
  50. package/dist/gir/ancestry.d.ts +9 -0
  51. package/dist/gir/ancestry.d.ts.map +1 -0
  52. package/dist/gir/ancestry.js +29 -0
  53. package/dist/gir/ancestry.js.map +1 -0
  54. package/dist/gir/callback.d.ts +9 -10
  55. package/dist/gir/callback.d.ts.map +1 -1
  56. package/dist/gir/callback.js +17 -16
  57. package/dist/gir/callback.js.map +1 -1
  58. package/dist/gir/class.d.ts +22 -43
  59. package/dist/gir/class.d.ts.map +1 -1
  60. package/dist/gir/class.js +11 -23
  61. package/dist/gir/class.js.map +1 -1
  62. package/dist/gir/enum.d.ts +13 -31
  63. package/dist/gir/enum.d.ts.map +1 -1
  64. package/dist/gir/enum.js +7 -14
  65. package/dist/gir/enum.js.map +1 -1
  66. package/dist/gir/field.d.ts +10 -23
  67. package/dist/gir/field.d.ts.map +1 -1
  68. package/dist/gir/field.js +12 -18
  69. package/dist/gir/field.js.map +1 -1
  70. package/dist/gir/function.d.ts +11 -42
  71. package/dist/gir/function.d.ts.map +1 -1
  72. package/dist/gir/function.js +7 -20
  73. package/dist/gir/function.js.map +1 -1
  74. package/dist/gir/gir-path.d.ts +2 -0
  75. package/dist/gir/gir-path.d.ts.map +1 -0
  76. package/dist/gir/gir-path.js +41 -0
  77. package/dist/gir/gir-path.js.map +1 -0
  78. package/dist/gir/libraries.d.ts +4 -0
  79. package/dist/gir/libraries.d.ts.map +1 -0
  80. package/dist/gir/libraries.js +62 -0
  81. package/dist/gir/libraries.js.map +1 -0
  82. package/dist/gir/library.d.ts +37 -0
  83. package/dist/gir/library.d.ts.map +1 -0
  84. package/dist/gir/library.js +218 -0
  85. package/dist/gir/library.js.map +1 -0
  86. package/dist/gir/namespace.d.ts +36 -50
  87. package/dist/gir/namespace.d.ts.map +1 -1
  88. package/dist/gir/namespace.js +46 -36
  89. package/dist/gir/namespace.js.map +1 -1
  90. package/dist/gir/parameter.d.ts +25 -69
  91. package/dist/gir/parameter.d.ts.map +1 -1
  92. package/dist/gir/parameter.js +36 -57
  93. package/dist/gir/parameter.js.map +1 -1
  94. package/dist/gir/parse.d.ts +6 -70
  95. package/dist/gir/parse.d.ts.map +1 -1
  96. package/dist/gir/parse.js +32 -80
  97. package/dist/gir/parse.js.map +1 -1
  98. package/dist/gir/primitives.d.ts +3 -34
  99. package/dist/gir/primitives.d.ts.map +1 -1
  100. package/dist/gir/primitives.js +19 -35
  101. package/dist/gir/primitives.js.map +1 -1
  102. package/dist/gir/property.d.ts +16 -25
  103. package/dist/gir/property.d.ts.map +1 -1
  104. package/dist/gir/property.js +12 -9
  105. package/dist/gir/property.js.map +1 -1
  106. package/dist/gir/record.d.ts +27 -0
  107. package/dist/gir/record.d.ts.map +1 -0
  108. package/dist/gir/record.js +25 -0
  109. package/dist/gir/record.js.map +1 -0
  110. package/dist/gir/size.d.ts +10 -57
  111. package/dist/gir/size.d.ts.map +1 -1
  112. package/dist/gir/size.js +0 -25
  113. package/dist/gir/size.js.map +1 -1
  114. package/dist/gir/type-id.d.ts +49 -0
  115. package/dist/gir/type-id.d.ts.map +1 -0
  116. package/dist/gir/type-id.js +8 -0
  117. package/dist/gir/type-id.js.map +1 -0
  118. package/dist/gir/type-ref.d.ts +3 -77
  119. package/dist/gir/type-ref.d.ts.map +1 -1
  120. package/dist/gir/type-ref.js +35 -65
  121. package/dist/gir/type-ref.js.map +1 -1
  122. package/dist/gir/type.d.ts +33 -0
  123. package/dist/gir/type.d.ts.map +1 -0
  124. package/dist/gir/type.js +2 -0
  125. package/dist/gir/type.js.map +1 -0
  126. package/dist/index.d.ts +5 -11
  127. package/dist/index.d.ts.map +1 -1
  128. package/dist/index.js +5 -11
  129. package/dist/index.js.map +1 -1
  130. package/dist/khronos/args.d.ts +30 -0
  131. package/dist/khronos/args.d.ts.map +1 -0
  132. package/dist/khronos/args.js +150 -0
  133. package/dist/khronos/args.js.map +1 -0
  134. package/dist/khronos/jsdoc.d.ts +21 -0
  135. package/dist/khronos/jsdoc.d.ts.map +1 -0
  136. package/dist/khronos/jsdoc.js +59 -0
  137. package/dist/khronos/jsdoc.js.map +1 -0
  138. package/dist/khronos/model.d.ts +37 -0
  139. package/dist/khronos/model.d.ts.map +1 -0
  140. package/dist/khronos/model.js +132 -0
  141. package/dist/khronos/model.js.map +1 -0
  142. package/dist/khronos/modules.d.ts +11 -0
  143. package/dist/khronos/modules.d.ts.map +1 -0
  144. package/dist/khronos/modules.js +58 -0
  145. package/dist/khronos/modules.js.map +1 -0
  146. package/dist/khronos/parse.d.ts +9 -0
  147. package/dist/khronos/parse.d.ts.map +1 -0
  148. package/dist/khronos/parse.js +61 -0
  149. package/dist/khronos/parse.js.map +1 -0
  150. package/dist/khronos/pipeline.d.ts +24 -0
  151. package/dist/khronos/pipeline.d.ts.map +1 -0
  152. package/dist/khronos/pipeline.js +182 -0
  153. package/dist/khronos/pipeline.js.map +1 -0
  154. package/dist/khronos/plan.d.ts +80 -0
  155. package/dist/khronos/plan.d.ts.map +1 -0
  156. package/dist/khronos/plan.js +136 -0
  157. package/dist/khronos/plan.js.map +1 -0
  158. package/dist/khronos/render.d.ts +16 -0
  159. package/dist/khronos/render.d.ts.map +1 -0
  160. package/dist/khronos/render.js +158 -0
  161. package/dist/khronos/render.js.map +1 -0
  162. package/dist/khronos/select.d.ts +15 -0
  163. package/dist/khronos/select.d.ts.map +1 -0
  164. package/dist/khronos/select.js +45 -0
  165. package/dist/khronos/select.js.map +1 -0
  166. package/dist/runner.d.ts +29 -47
  167. package/dist/runner.d.ts.map +1 -1
  168. package/dist/runner.js +78 -53
  169. package/dist/runner.js.map +1 -1
  170. package/dist/store/compile-store.d.ts +9 -0
  171. package/dist/store/compile-store.d.ts.map +1 -0
  172. package/dist/store/compile-store.js +38 -0
  173. package/dist/store/compile-store.js.map +1 -0
  174. package/dist/store/gi/async.d.ts +4 -0
  175. package/dist/store/gi/async.d.ts.map +1 -0
  176. package/dist/store/gi/async.js +41 -0
  177. package/dist/store/gi/async.js.map +1 -0
  178. package/dist/store/gi/callables.d.ts +36 -0
  179. package/dist/store/gi/callables.d.ts.map +1 -0
  180. package/dist/store/gi/callables.js +202 -0
  181. package/dist/store/gi/callables.js.map +1 -0
  182. package/dist/store/gi/callback.d.ts +4 -0
  183. package/dist/store/gi/callback.d.ts.map +1 -0
  184. package/dist/store/gi/callback.js +14 -0
  185. package/dist/store/gi/callback.js.map +1 -0
  186. package/dist/store/gi/class-struct-record.d.ts +9 -0
  187. package/dist/store/gi/class-struct-record.d.ts.map +1 -0
  188. package/dist/store/gi/class-struct-record.js +34 -0
  189. package/dist/store/gi/class-struct-record.js.map +1 -0
  190. package/dist/store/gi/class.d.ts +4 -0
  191. package/dist/store/gi/class.d.ts.map +1 -0
  192. package/dist/store/gi/class.js +169 -0
  193. package/dist/store/gi/class.js.map +1 -0
  194. package/dist/store/gi/companion.d.ts +4 -0
  195. package/dist/store/gi/companion.d.ts.map +1 -0
  196. package/dist/store/gi/companion.js +13 -0
  197. package/dist/store/gi/companion.js.map +1 -0
  198. package/dist/store/gi/constant.d.ts +5 -0
  199. package/dist/store/gi/constant.d.ts.map +1 -0
  200. package/dist/store/gi/constant.js +18 -0
  201. package/dist/store/gi/constant.js.map +1 -0
  202. package/dist/store/gi/constructor-props.d.ts +5 -0
  203. package/dist/store/gi/constructor-props.d.ts.map +1 -0
  204. package/dist/store/gi/constructor-props.js +64 -0
  205. package/dist/store/gi/constructor-props.js.map +1 -0
  206. package/dist/store/gi/enum.d.ts +5 -0
  207. package/dist/store/gi/enum.d.ts.map +1 -0
  208. package/dist/store/gi/enum.js +38 -0
  209. package/dist/store/gi/enum.js.map +1 -0
  210. package/dist/store/gi/function.d.ts +8 -0
  211. package/dist/store/gi/function.d.ts.map +1 -0
  212. package/dist/store/gi/function.js +87 -0
  213. package/dist/store/gi/function.js.map +1 -0
  214. package/dist/store/gi/gtype-binding.d.ts +10 -0
  215. package/dist/store/gi/gtype-binding.d.ts.map +1 -0
  216. package/dist/store/gi/gtype-binding.js +20 -0
  217. package/dist/store/gi/gtype-binding.js.map +1 -0
  218. package/dist/store/gi/interface.d.ts +4 -0
  219. package/dist/store/gi/interface.d.ts.map +1 -0
  220. package/dist/store/gi/interface.js +99 -0
  221. package/dist/store/gi/interface.js.map +1 -0
  222. package/dist/store/gi/item-comparators.d.ts +6 -0
  223. package/dist/store/gi/item-comparators.d.ts.map +1 -0
  224. package/dist/store/gi/item-comparators.js +76 -0
  225. package/dist/store/gi/item-comparators.js.map +1 -0
  226. package/dist/store/gi/method.d.ts +24 -0
  227. package/dist/store/gi/method.d.ts.map +1 -0
  228. package/dist/store/gi/method.js +279 -0
  229. package/dist/store/gi/method.js.map +1 -0
  230. package/dist/store/gi/param-marshal.d.ts +9 -0
  231. package/dist/store/gi/param-marshal.d.ts.map +1 -0
  232. package/dist/store/gi/param-marshal.js +37 -0
  233. package/dist/store/gi/param-marshal.js.map +1 -0
  234. package/dist/store/gi/pipeline.d.ts +4 -0
  235. package/dist/store/gi/pipeline.d.ts.map +1 -0
  236. package/dist/store/gi/pipeline.js +80 -0
  237. package/dist/store/gi/pipeline.js.map +1 -0
  238. package/dist/store/gi/properties.d.ts +5 -0
  239. package/dist/store/gi/properties.d.ts.map +1 -0
  240. package/dist/store/gi/properties.js +30 -0
  241. package/dist/store/gi/properties.js.map +1 -0
  242. package/dist/store/gi/property-accessor.d.ts +26 -0
  243. package/dist/store/gi/property-accessor.d.ts.map +1 -0
  244. package/dist/store/gi/property-accessor.js +132 -0
  245. package/dist/store/gi/property-accessor.js.map +1 -0
  246. package/dist/store/gi/record-constructor.d.ts +5 -0
  247. package/dist/store/gi/record-constructor.d.ts.map +1 -0
  248. package/dist/store/gi/record-constructor.js +65 -0
  249. package/dist/store/gi/record-constructor.js.map +1 -0
  250. package/dist/store/gi/record-field-accessor.d.ts +25 -0
  251. package/dist/store/gi/record-field-accessor.d.ts.map +1 -0
  252. package/dist/store/gi/record-field-accessor.js +288 -0
  253. package/dist/store/gi/record-field-accessor.js.map +1 -0
  254. package/dist/store/gi/record-layout.d.ts +14 -0
  255. package/dist/store/gi/record-layout.d.ts.map +1 -0
  256. package/dist/store/gi/record-layout.js +96 -0
  257. package/dist/store/gi/record-layout.js.map +1 -0
  258. package/dist/store/gi/record.d.ts +4 -0
  259. package/dist/store/gi/record.d.ts.map +1 -0
  260. package/dist/store/gi/record.js +59 -0
  261. package/dist/store/gi/record.js.map +1 -0
  262. package/dist/store/gi/registration.d.ts +16 -0
  263. package/dist/store/gi/registration.d.ts.map +1 -0
  264. package/dist/store/gi/registration.js +20 -0
  265. package/dist/store/gi/registration.js.map +1 -0
  266. package/dist/store/gi/return-wrap.d.ts +10 -0
  267. package/dist/store/gi/return-wrap.d.ts.map +1 -0
  268. package/dist/store/gi/return-wrap.js +46 -0
  269. package/dist/store/gi/return-wrap.js.map +1 -0
  270. package/dist/store/gi/runtime-override.d.ts +3 -0
  271. package/dist/store/gi/runtime-override.d.ts.map +1 -0
  272. package/dist/{writers → store/gi}/runtime-override.js +0 -15
  273. package/dist/store/gi/runtime-override.js.map +1 -0
  274. package/dist/store/gi/signal.d.ts +5 -0
  275. package/dist/store/gi/signal.d.ts.map +1 -0
  276. package/dist/store/gi/signal.js +233 -0
  277. package/dist/store/gi/signal.js.map +1 -0
  278. package/dist/store/gi/vtable.d.ts +4 -0
  279. package/dist/store/gi/vtable.d.ts.map +1 -0
  280. package/dist/store/gi/vtable.js +78 -0
  281. package/dist/store/gi/vtable.js.map +1 -0
  282. package/dist/store/gi-store.d.ts +9 -0
  283. package/dist/store/gi-store.d.ts.map +1 -0
  284. package/dist/store/gi-store.js +57 -0
  285. package/dist/store/gi-store.js.map +1 -0
  286. package/dist/store/jsx-store.d.ts +5 -0
  287. package/dist/store/jsx-store.d.ts.map +1 -0
  288. package/dist/store/jsx-store.js +23 -0
  289. package/dist/store/jsx-store.js.map +1 -0
  290. package/dist/store/react/built-ins.d.ts +9 -0
  291. package/dist/store/react/built-ins.d.ts.map +1 -0
  292. package/dist/store/react/built-ins.js +226 -0
  293. package/dist/store/react/built-ins.js.map +1 -0
  294. package/dist/store/react/element-components.d.ts +15 -0
  295. package/dist/store/react/element-components.d.ts.map +1 -0
  296. package/dist/store/react/element-components.js +92 -0
  297. package/dist/store/react/element-components.js.map +1 -0
  298. package/dist/store/react/element-prop-types.d.ts +19 -0
  299. package/dist/store/react/element-prop-types.d.ts.map +1 -0
  300. package/dist/store/react/element-prop-types.js +244 -0
  301. package/dist/store/react/element-prop-types.js.map +1 -0
  302. package/dist/store/react/element-props.d.ts +4 -0
  303. package/dist/store/react/element-props.d.ts.map +1 -0
  304. package/dist/store/react/element-props.js +178 -0
  305. package/dist/store/react/element-props.js.map +1 -0
  306. package/dist/store/react/gir-index.d.ts +25 -0
  307. package/dist/store/react/gir-index.d.ts.map +1 -0
  308. package/dist/store/react/gir-index.js +55 -0
  309. package/dist/store/react/gir-index.js.map +1 -0
  310. package/dist/store/react/intrinsic-elements.d.ts +26 -0
  311. package/dist/store/react/intrinsic-elements.d.ts.map +1 -0
  312. package/dist/store/react/intrinsic-elements.js +107 -0
  313. package/dist/store/react/intrinsic-elements.js.map +1 -0
  314. package/dist/store/react/jsx.d.ts +18 -0
  315. package/dist/store/react/jsx.d.ts.map +1 -0
  316. package/dist/store/react/jsx.js +203 -0
  317. package/dist/store/react/jsx.js.map +1 -0
  318. package/dist/store/react/metadata.d.ts +4 -0
  319. package/dist/store/react/metadata.d.ts.map +1 -0
  320. package/dist/store/react/metadata.js +174 -0
  321. package/dist/store/react/metadata.js.map +1 -0
  322. package/dist/store/react/pipeline.d.ts +14 -0
  323. package/dist/store/react/pipeline.d.ts.map +1 -0
  324. package/dist/store/react/pipeline.js +60 -0
  325. package/dist/store/react/pipeline.js.map +1 -0
  326. package/dist/store/react/props.d.ts +36 -0
  327. package/dist/store/react/props.d.ts.map +1 -0
  328. package/dist/store/react/props.js +133 -0
  329. package/dist/store/react/props.js.map +1 -0
  330. package/dist/store/store-fs.d.ts +41 -0
  331. package/dist/store/store-fs.d.ts.map +1 -0
  332. package/dist/store/store-fs.js +71 -0
  333. package/dist/store/store-fs.js.map +1 -0
  334. package/dist/writer/context.d.ts +16 -0
  335. package/dist/writer/context.d.ts.map +1 -0
  336. package/dist/writer/context.js +44 -0
  337. package/dist/writer/context.js.map +1 -0
  338. package/dist/writer/doc.d.ts +2 -0
  339. package/dist/writer/doc.d.ts.map +1 -0
  340. package/dist/writer/doc.js +12 -0
  341. package/dist/writer/doc.js.map +1 -0
  342. package/dist/writer/emit.d.ts +8 -0
  343. package/dist/writer/emit.d.ts.map +1 -0
  344. package/dist/writer/emit.js +21 -0
  345. package/dist/writer/emit.js.map +1 -0
  346. package/dist/writer/gtk-doc.d.ts +2 -0
  347. package/dist/writer/gtk-doc.d.ts.map +1 -0
  348. package/dist/writer/gtk-doc.js +67 -0
  349. package/dist/writer/gtk-doc.js.map +1 -0
  350. package/dist/writer/imports.d.ts +10 -0
  351. package/dist/writer/imports.d.ts.map +1 -0
  352. package/dist/writer/imports.js +50 -0
  353. package/dist/writer/imports.js.map +1 -0
  354. package/dist/writer/module.d.ts +15 -0
  355. package/dist/writer/module.d.ts.map +1 -0
  356. package/dist/writer/module.js +46 -0
  357. package/dist/writer/module.js.map +1 -0
  358. package/overrides/cairo/context.ts.ejs +1269 -0
  359. package/overrides/cairo/font-face.ts.ejs +151 -0
  360. package/overrides/cairo/font-options.ts.ejs +199 -0
  361. package/overrides/cairo/image-surface.ts.ejs +132 -0
  362. package/overrides/cairo/index.ts.ejs +22 -0
  363. package/overrides/cairo/matrix.ts.ejs +171 -0
  364. package/overrides/cairo/pattern.ts.ejs +476 -0
  365. package/overrides/cairo/recording-surface.ts.ejs +102 -0
  366. package/overrides/cairo/region.ts.ejs +237 -0
  367. package/overrides/cairo/scaled-font.ts.ejs +330 -0
  368. package/overrides/cairo/surface.ts.ejs +296 -0
  369. package/overrides/gdk/index.ts.ejs +2 -0
  370. package/overrides/gdk/rgba.ts.ejs +11 -0
  371. package/overrides/gobject/index.ts.ejs +29 -0
  372. package/overrides/gobject/object.ts.ejs +51 -0
  373. package/overrides/gobject/value.ts.ejs +17 -0
  374. package/overrides/graphene/index.ts.ejs +2 -0
  375. package/overrides/graphene/structs.ts.ejs +37 -0
  376. package/overrides/gtk/constants.ts.ejs +3 -0
  377. package/overrides/gtk/index.ts.ejs +2 -0
  378. package/package.json +15 -15
  379. package/src/analysis/descriptor-render.ts +407 -0
  380. package/src/analysis/descriptor.ts +263 -0
  381. package/src/analysis/inheritance.ts +242 -0
  382. package/src/analysis/param-structure.ts +127 -0
  383. package/src/analysis/ts-type.ts +88 -0
  384. package/src/compile.ts +152 -0
  385. package/src/docs/api-reference.ts +361 -0
  386. package/src/docs/element-page.ts +290 -0
  387. package/src/docs/pipeline.ts +182 -0
  388. package/src/docs/render.ts +191 -0
  389. package/src/docs/symbol-page.ts +444 -0
  390. package/src/fingerprint.ts +40 -29
  391. package/src/gir/ancestry.ts +41 -0
  392. package/src/gir/callback.ts +25 -22
  393. package/src/gir/class.ts +31 -57
  394. package/src/gir/enum.ts +20 -38
  395. package/src/gir/field.ts +21 -36
  396. package/src/gir/function.ts +17 -56
  397. package/src/gir/gir-path.ts +49 -0
  398. package/src/gir/libraries.ts +77 -0
  399. package/src/gir/library.ts +248 -0
  400. package/src/gir/namespace.ts +85 -80
  401. package/src/gir/parameter.ts +64 -93
  402. package/src/gir/parse.ts +43 -95
  403. package/src/gir/primitives.ts +23 -45
  404. package/src/gir/property.ts +27 -29
  405. package/src/gir/record.ts +53 -0
  406. package/src/gir/size.ts +9 -56
  407. package/src/gir/type-id.ts +49 -0
  408. package/src/gir/type-ref.ts +35 -140
  409. package/src/gir/type.ts +16 -0
  410. package/src/index.ts +20 -15
  411. package/src/khronos/args.ts +202 -0
  412. package/src/khronos/jsdoc.ts +76 -0
  413. package/src/khronos/model.ts +166 -0
  414. package/src/khronos/modules.ts +75 -0
  415. package/src/khronos/parse.ts +66 -0
  416. package/src/khronos/pipeline.ts +234 -0
  417. package/src/khronos/plan.ts +191 -0
  418. package/src/khronos/registry/LICENSE +202 -0
  419. package/src/khronos/registry/gl.xml +47748 -0
  420. package/src/khronos/render.ts +193 -0
  421. package/src/khronos/select.ts +67 -0
  422. package/src/runner.ts +112 -75
  423. package/src/store/compile-store.ts +49 -0
  424. package/src/store/gi/async.ts +42 -0
  425. package/src/store/gi/callables.ts +309 -0
  426. package/src/store/gi/callback.ts +15 -0
  427. package/src/store/gi/class-struct-record.ts +40 -0
  428. package/src/store/gi/class.ts +212 -0
  429. package/src/store/gi/companion.ts +13 -0
  430. package/src/store/gi/constant.ts +24 -0
  431. package/src/store/gi/constructor-props.ts +82 -0
  432. package/src/store/gi/enum.ts +49 -0
  433. package/src/store/gi/function.ts +107 -0
  434. package/src/store/gi/gtype-binding.ts +33 -0
  435. package/src/store/gi/interface.ts +157 -0
  436. package/src/store/gi/item-comparators.ts +90 -0
  437. package/src/store/gi/method.ts +417 -0
  438. package/src/store/gi/param-marshal.ts +48 -0
  439. package/src/store/gi/pipeline.ts +85 -0
  440. package/src/store/gi/properties.ts +39 -0
  441. package/src/store/gi/property-accessor.ts +194 -0
  442. package/src/store/gi/record-constructor.ts +87 -0
  443. package/src/store/gi/record-field-accessor.ts +394 -0
  444. package/src/store/gi/record-layout.ts +134 -0
  445. package/src/store/gi/record.ts +66 -0
  446. package/src/store/gi/registration.ts +38 -0
  447. package/src/store/gi/return-wrap.ts +52 -0
  448. package/src/store/gi/runtime-override.ts +36 -0
  449. package/src/store/gi/signal.ts +310 -0
  450. package/src/store/gi/vtable.ts +99 -0
  451. package/src/store/gi-store.ts +79 -0
  452. package/src/store/jsx-store.ts +27 -0
  453. package/src/store/react/built-ins.ts +260 -0
  454. package/src/store/react/element-components.ts +138 -0
  455. package/src/store/react/element-prop-types.ts +280 -0
  456. package/src/store/react/element-props.ts +204 -0
  457. package/src/store/react/gir-index.ts +85 -0
  458. package/src/store/react/intrinsic-elements.ts +161 -0
  459. package/src/store/react/jsx.ts +294 -0
  460. package/src/store/react/metadata.ts +197 -0
  461. package/src/store/react/pipeline.ts +90 -0
  462. package/src/store/react/props.ts +197 -0
  463. package/src/store/store-fs.ts +112 -0
  464. package/src/writer/context.ts +48 -0
  465. package/src/writer/doc.ts +11 -0
  466. package/src/writer/emit.ts +26 -0
  467. package/src/writer/gtk-doc.ts +74 -0
  468. package/src/writer/imports.ts +59 -0
  469. package/src/writer/module.ts +45 -0
  470. package/LICENSE +0 -373
  471. package/dist/dsl/context.d.ts +0 -104
  472. package/dist/dsl/context.d.ts.map +0 -1
  473. package/dist/dsl/context.js +0 -140
  474. package/dist/dsl/context.js.map +0 -1
  475. package/dist/dsl/emit.d.ts +0 -28
  476. package/dist/dsl/emit.d.ts.map +0 -1
  477. package/dist/dsl/emit.js +0 -41
  478. package/dist/dsl/emit.js.map +0 -1
  479. package/dist/dsl/identifier.d.ts +0 -28
  480. package/dist/dsl/identifier.d.ts.map +0 -1
  481. package/dist/dsl/identifier.js +0 -45
  482. package/dist/dsl/identifier.js.map +0 -1
  483. package/dist/dsl/imports.d.ts +0 -58
  484. package/dist/dsl/imports.d.ts.map +0 -1
  485. package/dist/dsl/imports.js +0 -107
  486. package/dist/dsl/imports.js.map +0 -1
  487. package/dist/dsl/module.d.ts +0 -53
  488. package/dist/dsl/module.d.ts.map +0 -1
  489. package/dist/dsl/module.js +0 -76
  490. package/dist/dsl/module.js.map +0 -1
  491. package/dist/ffi/pipeline.d.ts +0 -19
  492. package/dist/ffi/pipeline.d.ts.map +0 -1
  493. package/dist/ffi/pipeline.js +0 -107
  494. package/dist/ffi/pipeline.js.map +0 -1
  495. package/dist/gi-store.d.ts +0 -34
  496. package/dist/gi-store.d.ts.map +0 -1
  497. package/dist/gi-store.js +0 -154
  498. package/dist/gi-store.js.map +0 -1
  499. package/dist/gir/boxed.d.ts +0 -66
  500. package/dist/gir/boxed.d.ts.map +0 -1
  501. package/dist/gir/boxed.js +0 -49
  502. package/dist/gir/boxed.js.map +0 -1
  503. package/dist/gir/qualified-name.d.ts +0 -37
  504. package/dist/gir/qualified-name.d.ts.map +0 -1
  505. package/dist/gir/qualified-name.js +0 -39
  506. package/dist/gir/qualified-name.js.map +0 -1
  507. package/dist/gir/qualify.d.ts +0 -32
  508. package/dist/gir/qualify.d.ts.map +0 -1
  509. package/dist/gir/qualify.js +0 -60
  510. package/dist/gir/qualify.js.map +0 -1
  511. package/dist/gir/repository.d.ts +0 -82
  512. package/dist/gir/repository.d.ts.map +0 -1
  513. package/dist/gir/repository.js +0 -122
  514. package/dist/gir/repository.js.map +0 -1
  515. package/dist/gir/signal.d.ts +0 -22
  516. package/dist/gir/signal.d.ts.map +0 -1
  517. package/dist/gir/signal.js +0 -20
  518. package/dist/gir/signal.js.map +0 -1
  519. package/dist/jsx-store.d.ts +0 -22
  520. package/dist/jsx-store.d.ts.map +0 -1
  521. package/dist/jsx-store.js +0 -40
  522. package/dist/jsx-store.js.map +0 -1
  523. package/dist/react/compounds-meta.d.ts +0 -18
  524. package/dist/react/compounds-meta.d.ts.map +0 -1
  525. package/dist/react/compounds-meta.js +0 -93
  526. package/dist/react/compounds-meta.js.map +0 -1
  527. package/dist/react/compounds.d.ts +0 -27
  528. package/dist/react/compounds.d.ts.map +0 -1
  529. package/dist/react/compounds.js +0 -164
  530. package/dist/react/compounds.js.map +0 -1
  531. package/dist/react/internal.d.ts +0 -14
  532. package/dist/react/internal.d.ts.map +0 -1
  533. package/dist/react/internal.js +0 -79
  534. package/dist/react/internal.js.map +0 -1
  535. package/dist/react/jsx.d.ts +0 -22
  536. package/dist/react/jsx.d.ts.map +0 -1
  537. package/dist/react/jsx.js +0 -134
  538. package/dist/react/jsx.js.map +0 -1
  539. package/dist/react/pipeline.d.ts +0 -13
  540. package/dist/react/pipeline.d.ts.map +0 -1
  541. package/dist/react/pipeline.js +0 -25
  542. package/dist/react/pipeline.js.map +0 -1
  543. package/dist/react/props.d.ts +0 -38
  544. package/dist/react/props.d.ts.map +0 -1
  545. package/dist/react/props.js +0 -231
  546. package/dist/react/props.js.map +0 -1
  547. package/dist/react/slot-props.d.ts +0 -10
  548. package/dist/react/slot-props.d.ts.map +0 -1
  549. package/dist/react/slot-props.js +0 -56
  550. package/dist/react/slot-props.js.map +0 -1
  551. package/dist/react/widgets.d.ts +0 -83
  552. package/dist/react/widgets.d.ts.map +0 -1
  553. package/dist/react/widgets.js +0 -152
  554. package/dist/react/widgets.js.map +0 -1
  555. package/dist/store-fs.d.ts +0 -109
  556. package/dist/store-fs.d.ts.map +0 -1
  557. package/dist/store-fs.js +0 -98
  558. package/dist/store-fs.js.map +0 -1
  559. package/dist/transpile.d.ts +0 -32
  560. package/dist/transpile.d.ts.map +0 -1
  561. package/dist/transpile.js +0 -63
  562. package/dist/transpile.js.map +0 -1
  563. package/dist/typecheck-store.d.ts +0 -41
  564. package/dist/typecheck-store.d.ts.map +0 -1
  565. package/dist/typecheck-store.js +0 -102
  566. package/dist/typecheck-store.js.map +0 -1
  567. package/dist/writers/alias.d.ts +0 -13
  568. package/dist/writers/alias.d.ts.map +0 -1
  569. package/dist/writers/alias.js +0 -17
  570. package/dist/writers/alias.js.map +0 -1
  571. package/dist/writers/async.d.ts +0 -22
  572. package/dist/writers/async.d.ts.map +0 -1
  573. package/dist/writers/async.js +0 -48
  574. package/dist/writers/async.js.map +0 -1
  575. package/dist/writers/boxed-constructor.d.ts +0 -26
  576. package/dist/writers/boxed-constructor.d.ts.map +0 -1
  577. package/dist/writers/boxed-constructor.js +0 -85
  578. package/dist/writers/boxed-constructor.js.map +0 -1
  579. package/dist/writers/boxed-field-accessor.d.ts +0 -18
  580. package/dist/writers/boxed-field-accessor.d.ts.map +0 -1
  581. package/dist/writers/boxed-field-accessor.js +0 -260
  582. package/dist/writers/boxed-field-accessor.js.map +0 -1
  583. package/dist/writers/boxed-layout.d.ts +0 -27
  584. package/dist/writers/boxed-layout.d.ts.map +0 -1
  585. package/dist/writers/boxed-layout.js +0 -128
  586. package/dist/writers/boxed-layout.js.map +0 -1
  587. package/dist/writers/boxed.d.ts +0 -20
  588. package/dist/writers/boxed.d.ts.map +0 -1
  589. package/dist/writers/boxed.js +0 -71
  590. package/dist/writers/boxed.js.map +0 -1
  591. package/dist/writers/callables.d.ts +0 -124
  592. package/dist/writers/callables.d.ts.map +0 -1
  593. package/dist/writers/callables.js +0 -283
  594. package/dist/writers/callables.js.map +0 -1
  595. package/dist/writers/callback.d.ts +0 -16
  596. package/dist/writers/callback.d.ts.map +0 -1
  597. package/dist/writers/callback.js +0 -38
  598. package/dist/writers/callback.js.map +0 -1
  599. package/dist/writers/class-struct-record.d.ts +0 -31
  600. package/dist/writers/class-struct-record.d.ts.map +0 -1
  601. package/dist/writers/class-struct-record.js +0 -67
  602. package/dist/writers/class-struct-record.js.map +0 -1
  603. package/dist/writers/class-struct.d.ts +0 -22
  604. package/dist/writers/class-struct.d.ts.map +0 -1
  605. package/dist/writers/class-struct.js +0 -85
  606. package/dist/writers/class-struct.js.map +0 -1
  607. package/dist/writers/class.d.ts +0 -16
  608. package/dist/writers/class.d.ts.map +0 -1
  609. package/dist/writers/class.js +0 -307
  610. package/dist/writers/class.js.map +0 -1
  611. package/dist/writers/constant.d.ts +0 -15
  612. package/dist/writers/constant.d.ts.map +0 -1
  613. package/dist/writers/constant.js +0 -23
  614. package/dist/writers/constant.js.map +0 -1
  615. package/dist/writers/constants.d.ts +0 -15
  616. package/dist/writers/constants.d.ts.map +0 -1
  617. package/dist/writers/constants.js +0 -23
  618. package/dist/writers/constants.js.map +0 -1
  619. package/dist/writers/constructor-props.d.ts +0 -32
  620. package/dist/writers/constructor-props.d.ts.map +0 -1
  621. package/dist/writers/constructor-props.js +0 -110
  622. package/dist/writers/constructor-props.js.map +0 -1
  623. package/dist/writers/enum.d.ts +0 -21
  624. package/dist/writers/enum.d.ts.map +0 -1
  625. package/dist/writers/enum.js +0 -48
  626. package/dist/writers/enum.js.map +0 -1
  627. package/dist/writers/function.d.ts +0 -40
  628. package/dist/writers/function.d.ts.map +0 -1
  629. package/dist/writers/function.js +0 -127
  630. package/dist/writers/function.js.map +0 -1
  631. package/dist/writers/gtype-binding.d.ts +0 -19
  632. package/dist/writers/gtype-binding.d.ts.map +0 -1
  633. package/dist/writers/gtype-binding.js +0 -40
  634. package/dist/writers/gtype-binding.js.map +0 -1
  635. package/dist/writers/inheritance.d.ts +0 -48
  636. package/dist/writers/inheritance.d.ts.map +0 -1
  637. package/dist/writers/inheritance.js +0 -90
  638. package/dist/writers/inheritance.js.map +0 -1
  639. package/dist/writers/interface.d.ts +0 -16
  640. package/dist/writers/interface.d.ts.map +0 -1
  641. package/dist/writers/interface.js +0 -155
  642. package/dist/writers/interface.js.map +0 -1
  643. package/dist/writers/method.d.ts +0 -150
  644. package/dist/writers/method.d.ts.map +0 -1
  645. package/dist/writers/method.js +0 -510
  646. package/dist/writers/method.js.map +0 -1
  647. package/dist/writers/param-classify.d.ts +0 -93
  648. package/dist/writers/param-classify.d.ts.map +0 -1
  649. package/dist/writers/param-classify.js +0 -163
  650. package/dist/writers/param-classify.js.map +0 -1
  651. package/dist/writers/property-accessor.d.ts +0 -19
  652. package/dist/writers/property-accessor.d.ts.map +0 -1
  653. package/dist/writers/property-accessor.js +0 -117
  654. package/dist/writers/property-accessor.js.map +0 -1
  655. package/dist/writers/registration.d.ts +0 -27
  656. package/dist/writers/registration.d.ts.map +0 -1
  657. package/dist/writers/registration.js +0 -30
  658. package/dist/writers/registration.js.map +0 -1
  659. package/dist/writers/return-wrap.d.ts +0 -39
  660. package/dist/writers/return-wrap.d.ts.map +0 -1
  661. package/dist/writers/return-wrap.js +0 -152
  662. package/dist/writers/return-wrap.js.map +0 -1
  663. package/dist/writers/runtime-override.d.ts +0 -18
  664. package/dist/writers/runtime-override.d.ts.map +0 -1
  665. package/dist/writers/runtime-override.js.map +0 -1
  666. package/dist/writers/signal.d.ts +0 -21
  667. package/dist/writers/signal.d.ts.map +0 -1
  668. package/dist/writers/signal.js +0 -260
  669. package/dist/writers/signal.js.map +0 -1
  670. package/dist/writers/ts-type.d.ts +0 -50
  671. package/dist/writers/ts-type.d.ts.map +0 -1
  672. package/dist/writers/ts-type.js +0 -75
  673. package/dist/writers/ts-type.js.map +0 -1
  674. package/dist/writers/types-ts.d.ts +0 -27
  675. package/dist/writers/types-ts.d.ts.map +0 -1
  676. package/dist/writers/types-ts.js +0 -97
  677. package/dist/writers/types-ts.js.map +0 -1
  678. package/dist/writers/value.d.ts +0 -89
  679. package/dist/writers/value.d.ts.map +0 -1
  680. package/dist/writers/value.js +0 -402
  681. package/dist/writers/value.js.map +0 -1
  682. package/src/dsl/context.ts +0 -146
  683. package/src/dsl/emit.ts +0 -42
  684. package/src/dsl/identifier.ts +0 -52
  685. package/src/dsl/imports.ts +0 -109
  686. package/src/dsl/module.ts +0 -75
  687. package/src/ffi/pipeline.ts +0 -113
  688. package/src/gi-store.ts +0 -199
  689. package/src/gir/boxed.ts +0 -94
  690. package/src/gir/qualified-name.ts +0 -55
  691. package/src/gir/qualify.ts +0 -64
  692. package/src/gir/repository.ts +0 -149
  693. package/src/gir/signal.ts +0 -36
  694. package/src/jsx-store.ts +0 -53
  695. package/src/react/compounds-meta.ts +0 -99
  696. package/src/react/compounds.ts +0 -204
  697. package/src/react/internal.ts +0 -91
  698. package/src/react/jsx.ts +0 -155
  699. package/src/react/pipeline.ts +0 -29
  700. package/src/react/props.ts +0 -307
  701. package/src/react/slot-props.ts +0 -57
  702. package/src/react/widgets.ts +0 -185
  703. package/src/store-fs.ts +0 -157
  704. package/src/transpile.ts +0 -80
  705. package/src/typecheck-store.ts +0 -136
  706. package/src/writers/alias.ts +0 -19
  707. package/src/writers/async.ts +0 -44
  708. package/src/writers/boxed-constructor.ts +0 -105
  709. package/src/writers/boxed-field-accessor.ts +0 -306
  710. package/src/writers/boxed-layout.ts +0 -166
  711. package/src/writers/boxed.ts +0 -77
  712. package/src/writers/callables.ts +0 -339
  713. package/src/writers/callback.ts +0 -40
  714. package/src/writers/class-struct-record.ts +0 -75
  715. package/src/writers/class-struct.ts +0 -96
  716. package/src/writers/class.ts +0 -384
  717. package/src/writers/constant.ts +0 -29
  718. package/src/writers/constructor-props.ts +0 -130
  719. package/src/writers/enum.ts +0 -53
  720. package/src/writers/function.ts +0 -136
  721. package/src/writers/gtype-binding.ts +0 -48
  722. package/src/writers/inheritance.ts +0 -104
  723. package/src/writers/interface.ts +0 -168
  724. package/src/writers/method.ts +0 -678
  725. package/src/writers/param-classify.ts +0 -178
  726. package/src/writers/property-accessor.ts +0 -139
  727. package/src/writers/registration.ts +0 -42
  728. package/src/writers/return-wrap.ts +0 -180
  729. package/src/writers/runtime-override.ts +0 -59
  730. package/src/writers/signal.ts +0 -318
  731. package/src/writers/ts-type.ts +0 -115
  732. package/src/writers/value.ts +0 -485
@@ -0,0 +1,244 @@
1
+ import { toCamelIdentifier } from "@gtkx/utils";
2
+ import { renderBaseTypeFor } from "../../analysis/ts-type.js";
3
+ import { chainOf, findMethod, hasProperty } from "./gir-index.js";
4
+ import { glibNameOf } from "./intrinsic-elements.js";
5
+ import { reactTarget } from "./props.js";
6
+ const forEachContainer = (elementProps, visit) => {
7
+ for (const [type, props] of Object.entries(elementProps)) {
8
+ for (const prop of props) {
9
+ if (prop.kind === "container")
10
+ visit(type, prop);
11
+ }
12
+ }
13
+ };
14
+ const renderParamType = (context, imports, param) => {
15
+ if (param === undefined)
16
+ return "unknown";
17
+ const base = renderBaseTypeFor(context.library, reactTarget({ library: context.library, imports }), param.type);
18
+ return param.nullable || param.optional ? `${base} | null` : base;
19
+ };
20
+ const optionalLine = (prop, type) => {
21
+ const withNull = type.endsWith(" | null") ? type : `${type} | null`;
22
+ return `${prop}?: ${withNull} | undefined;`;
23
+ };
24
+ const callFieldLines = (context, imports, type, call) => {
25
+ if (typeof call === "string")
26
+ return [];
27
+ const method = findMethod(context, type, call.method);
28
+ const lines = [];
29
+ call.args.forEach((arg, positionIndex) => {
30
+ if (typeof arg !== "object" || !("field" in arg))
31
+ return;
32
+ const param = method?.params[positionIndex];
33
+ const optional = "or" in arg || param?.nullable === true || param?.optional === true;
34
+ lines.push({
35
+ field: arg.field,
36
+ text: `${arg.field}${optional ? "?" : ""}: ${renderParamType(context, imports, param)};`,
37
+ });
38
+ });
39
+ return lines;
40
+ };
41
+ const mergedFieldsType = (lines) => {
42
+ const seen = new Set();
43
+ const texts = [];
44
+ for (const line of lines) {
45
+ if (seen.has(line.field))
46
+ continue;
47
+ seen.add(line.field);
48
+ texts.push(line.text);
49
+ }
50
+ return `{ ${texts.join(" ")} }`;
51
+ };
52
+ const callFieldsType = (context, imports, type, call) => {
53
+ if (Array.isArray(call))
54
+ return mergedFieldsType(call.flatMap((entry) => callFieldLines(context, imports, type, entry)));
55
+ if (typeof call === "string") {
56
+ const method = findMethod(context, type, call);
57
+ return renderParamType(context, imports, method?.params[0]);
58
+ }
59
+ const lines = callFieldLines(context, imports, type, call);
60
+ if (lines.length > 0)
61
+ return mergedFieldsType(lines);
62
+ const method = findMethod(context, type, call.method);
63
+ return renderParamType(context, imports, method?.params[0]);
64
+ };
65
+ const appliedPropLine = (context, imports, type, prop) => {
66
+ if (hasProperty(context, type, prop.prop))
67
+ return null;
68
+ if (prop.kind === "value")
69
+ return optionalLine(prop.prop, callFieldsType(context, imports, type, prop.call));
70
+ if (prop.kind === "list")
71
+ return optionalLine(prop.prop, `${callFieldsType(context, imports, type, prop.add)}[]`);
72
+ return null;
73
+ };
74
+ const collectCallContributions = (context, contributions, container, call) => {
75
+ const method = findMethod(context, container.parent, call.method);
76
+ call.args.forEach((arg, positionIndex) => {
77
+ if (typeof arg !== "object" || !("prop" in arg))
78
+ return;
79
+ const param = method?.params[positionIndex];
80
+ if (param === undefined)
81
+ return;
82
+ if (hasProperty(context, container.child, arg.prop))
83
+ return;
84
+ if (contributions.some((entry) => entry.child === container.child && entry.prop === arg.prop))
85
+ return;
86
+ contributions.push({ child: container.child, prop: arg.prop, param });
87
+ });
88
+ };
89
+ const collectPropContributions = (context, elementProps) => {
90
+ const contributions = [];
91
+ forEachContainer(elementProps, (parent, cp) => {
92
+ for (const call of [cp.append, cp.remove, cp.insert, cp.reorder]) {
93
+ if (call === undefined || typeof call === "string")
94
+ continue;
95
+ collectCallContributions(context, contributions, { parent, child: cp.child }, call);
96
+ }
97
+ });
98
+ return contributions;
99
+ };
100
+ const directTypeNames = (context, klass, namespace) => {
101
+ const names = new Set();
102
+ const glibName = glibNameOf(klass);
103
+ if (glibName !== undefined)
104
+ names.add(glibName);
105
+ for (const name of klass.implements) {
106
+ const resolved = context.library.resolveType(namespace.name, name);
107
+ if (resolved === undefined || resolved.kind !== "interface")
108
+ continue;
109
+ const ifaceGlib = glibNameOf(resolved.value);
110
+ if (ifaceGlib !== undefined)
111
+ names.add(ifaceGlib);
112
+ }
113
+ return names;
114
+ };
115
+ const constructOnlyNames = (context, entry) => {
116
+ const names = [];
117
+ for (const klass of chainOf(context, entry)) {
118
+ for (const property of klass.properties) {
119
+ if (property.constructOnly)
120
+ names.push(toCamelIdentifier(property.name));
121
+ }
122
+ }
123
+ return names;
124
+ };
125
+ const methodReturnGlib = (context, typeName, methodCamel) => {
126
+ const method = findMethod(context, typeName, methodCamel);
127
+ const ref = method?.fn.returnValue.type;
128
+ if (ref === undefined)
129
+ return undefined;
130
+ const resolved = context.library.typeOf(ref);
131
+ if (resolved === undefined || resolved.kind !== "class")
132
+ return undefined;
133
+ return glibNameOf(resolved.value);
134
+ };
135
+ const resolveAdoptElement = (context, parent, cp) => {
136
+ if (cp.adopt === undefined)
137
+ return undefined;
138
+ const source = typeof cp.adopt === "string" ? cp.adopt : cp.append;
139
+ if (source === undefined)
140
+ return undefined;
141
+ const method = typeof source === "string" ? source : source.method;
142
+ return methodReturnGlib(context, parent, method);
143
+ };
144
+ const lazyElementExportOf = (context, element) => {
145
+ const typeName = `${element}ElementProps`;
146
+ const elementClass = context.index.get(element);
147
+ if (elementClass === undefined) {
148
+ return { element, typeName, typeSource: `export type ${typeName} = { children?: ReactNode };` };
149
+ }
150
+ const baseName = glibNameOf(elementClass.klass) ?? element;
151
+ const omitted = constructOnlyNames(context, elementClass);
152
+ const omitUnion = omitted.map((name) => JSON.stringify(name)).join(" | ");
153
+ const base = omitted.length === 0 ? `${baseName}Props` : `Omit<${baseName}Props, ${omitUnion}>`;
154
+ return { element, typeName, typeSource: `export type ${typeName} = ${base};` };
155
+ };
156
+ const collectLazyElementSpecs = (context, elementProps) => {
157
+ const specs = new Map();
158
+ forEachContainer(elementProps, (parent, cp) => {
159
+ const parentEntry = context.index.get(parent);
160
+ if (parentEntry === undefined)
161
+ return;
162
+ const element = resolveAdoptElement(context, parent, cp);
163
+ if (element === undefined)
164
+ return;
165
+ const spec = lazyElementExportOf(context, element);
166
+ const list = specs.get(parentEntry.namespace.name) ?? [];
167
+ if (!list.some((existing) => existing.element === spec.element))
168
+ list.push(spec);
169
+ specs.set(parentEntry.namespace.name, list);
170
+ });
171
+ return specs;
172
+ };
173
+ const collectContainerPropNames = (elementProps) => {
174
+ const containerPropNamesByParent = new Map();
175
+ forEachContainer(elementProps, (parent, cp) => {
176
+ if (cp.prop === "children")
177
+ return;
178
+ const names = containerPropNamesByParent.get(parent) ?? [];
179
+ if (!names.includes(cp.prop))
180
+ names.push(cp.prop);
181
+ containerPropNamesByParent.set(parent, names);
182
+ });
183
+ return containerPropNamesByParent;
184
+ };
185
+ const TEXT_CONTAINERS = ["GtkLabel", "GtkTextBuffer", "GtkTextTag", "GtkTextView"];
186
+ export const createElementPropTypegen = (context, elementProps) => {
187
+ const appliedByType = new Map();
188
+ for (const [type, props] of Object.entries(elementProps)) {
189
+ for (const prop of props) {
190
+ if (prop.kind === "container")
191
+ continue;
192
+ const list = appliedByType.get(type) ?? [];
193
+ list.push(prop);
194
+ appliedByType.set(type, list);
195
+ }
196
+ }
197
+ const propContributions = collectPropContributions(context, elementProps);
198
+ const lazyElementSpecs = collectLazyElementSpecs(context, elementProps);
199
+ const containerPropNamesByParent = collectContainerPropNames(elementProps);
200
+ const childrenContainers = new Set(TEXT_CONTAINERS);
201
+ forEachContainer(elementProps, (parent, cp) => {
202
+ if (cp.prop === "children")
203
+ childrenContainers.add(parent);
204
+ const element = resolveAdoptElement(context, parent, cp);
205
+ if (element !== undefined)
206
+ childrenContainers.add(element);
207
+ });
208
+ const acceptsChildren = (glibName) => {
209
+ if (childrenContainers.has(glibName))
210
+ return true;
211
+ const entry = context.index.get(glibName);
212
+ if (entry === undefined)
213
+ return false;
214
+ const chain = chainOf(context, entry);
215
+ if (chain.some((klass) => glibNameOf(klass) === "GtkWidget"))
216
+ return true;
217
+ return chain.some((klass) => {
218
+ const name = glibNameOf(klass);
219
+ return name !== undefined && childrenContainers.has(name);
220
+ });
221
+ };
222
+ const classPropLines = (glibName, klass, namespace, imports) => {
223
+ const lines = [];
224
+ for (const prop of appliedByType.get(glibName) ?? []) {
225
+ const line = appliedPropLine(context, imports, glibName, prop);
226
+ if (line !== null)
227
+ lines.push(line);
228
+ }
229
+ const direct = directTypeNames(context, klass, namespace);
230
+ for (const contribution of propContributions) {
231
+ if (!direct.has(contribution.child))
232
+ continue;
233
+ lines.push(optionalLine(contribution.prop, renderParamType(context, imports, contribution.param)));
234
+ }
235
+ return lines;
236
+ };
237
+ return {
238
+ classPropLines,
239
+ lazyElementExports: (namespaceName) => lazyElementSpecs.get(namespaceName) ?? [],
240
+ containerPropNamesFor: (glibName) => containerPropNamesByParent.get(glibName) ?? [],
241
+ acceptsChildren,
242
+ };
243
+ };
244
+ //# sourceMappingURL=element-prop-types.js.map
@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entifier } from \"@gtkx/utils\";\nimport { renderBaseTypeFor } from \"../../analysis/ts-type.js\";\nimport type { GirClass } from \"../../gir/class.js\";\nimport type { GirNamespace } from \"../../gir/namespace.js\";\nimport type { GirParameter } from \"../../gir/parameter.js\";\nimport { chainOf, findMethod, type GirIndex, type GirTypeEntry, hasProperty } from \"./gir-index.js\";\nimport { glibNameOf } from \"./intrinsic-elements.js\";\nimport { reactTarget } from \"./props.js\";\n\ntype TypeImports = Map<string, string>;\n\ntype PropContribution = {\n child: string;\n prop: string;\n param: GirParameter;\n};\n\nexport type LazyElementSpec = {\n element: string;\n typeName: string;\n typeSource: string;\n};\n\nexport type ElementPropTypegen = {\n classPropLines: (glibName: string, klass: GirClass, namespace: GirNamespace, imports: TypeImports) => string[];\n lazyElementExports: (namespaceName: string) => LazyElementSpec[];\n containerPropNamesFor: (glibName: string) => string[];\n acceptsChildren: (glibName: string) => boolean;\n};\n\nconst forEachContainer = (\n elementProps: Record<string, ElementProp[]>,\n visit: (type: string, prop: ContainerProp) => void,\n): void => {\n for (const [type, props] of Object.entries(elementProps)) {\n for (const prop of props) {\n if (prop.kind === \"container\") visit(type, prop);\n }\n }\n};\n\nconst renderParamType = (context: GirIndex, imports: TypeImports, param: GirParameter | undefined): string => {\n if (param === undefined) return \"unknown\";\n const base = renderBaseTypeFor(context.library, reactTarget({ library: context.library, imports }), param.type);\n return param.nullable || param.optional ? `${base} | null` : base;\n};\n\nconst optionalLine = (prop: string, type: string): string => {\n const withNull = type.endsWith(\" | null\") ? type : `${type} | null`;\n return `${prop}?: ${withNull} | undefined;`;\n};\n\ntype FieldLine = { field: string; text: string };\n\nconst callFieldLines = (context: GirIndex, imports: TypeImports, type: string, call: Call): FieldLine[] => {\n if (typeof call === \"string\") return [];\n const method = findMethod(context, type, call.method);\n const lines: FieldLine[] = [];\n call.args.forEach((arg, positionIndex) => {\n if (typeof arg !== \"object\" || !(\"field\" in arg)) return;\n const param = method?.params[positionIndex];\n const optional = \"or\" in arg || param?.nullable === true || param?.optional === true;\n lines.push({\n field: arg.field,\n text: `${arg.field}${optional ? \"?\" : \"\"}: ${renderParamType(context, imports, param)};`,\n });\n });\n return lines;\n};\n\nconst mergedFieldsType = (lines: FieldLine[]): string => {\n const seen = new Set<string>();\n const texts: string[] = [];\n for (const line of lines) {\n if (seen.has(line.field)) continue;\n seen.add(line.field);\n texts.push(line.text);\n }\n return `{ ${texts.join(\" \")} }`;\n};\n\nconst callFieldsType = (context: GirIndex, imports: TypeImports, type: string, call: Call | Call[]): string => {\n if (Array.isArray(call))\n return mergedFieldsType(call.flatMap((entry) => callFieldLines(context, imports, type, entry)));\n if (typeof call === \"string\") {\n const method = findMethod(context, type, call);\n return renderParamType(context, imports, method?.params[0]);\n }\n const lines = callFieldLines(context, imports, type, call);\n if (lines.length > 0) return mergedFieldsType(lines);\n const method = findMethod(context, type, call.method);\n return renderParamType(context, imports, method?.params[0]);\n};\n\nconst appliedPropLine = (context: GirIndex, imports: TypeImports, type: string, prop: AppliedProp): string | null => {\n if (hasProperty(context, type, prop.prop)) return null;\n if (prop.kind === \"value\") return optionalLine(prop.prop, callFieldsType(context, imports, type, prop.call));\n if (prop.kind === \"list\") return optionalLine(prop.prop, `${callFieldsType(context, imports, type, prop.add)}[]`);\n return null;\n};\n\nconst collectCallContributions = (\n context: GirIndex,\n contributions: PropContribution[],\n container: { parent: string; child: string },\n call: Exclude<ContainerProp[\"append\"], string | undefined>,\n): void => {\n const method = findMethod(context, container.parent, call.method);\n call.args.forEach((arg, positionIndex) => {\n if (typeof arg !== \"object\" || !(\"prop\" in arg)) return;\n const param = method?.params[positionIndex];\n if (param === undefined) return;\n if (hasProperty(context, container.child, arg.prop)) return;\n if (contributions.some((entry) => entry.child === container.child && entry.prop === arg.prop)) return;\n contributions.push({ child: container.child, prop: arg.prop, param });\n });\n};\n\nconst collectPropContributions = (\n context: GirIndex,\n elementProps: Record<string, ElementProp[]>,\n): PropContribution[] => {\n const contributions: PropContribution[] = [];\n forEachContainer(elementProps, (parent, cp) => {\n for (const call of [cp.append, cp.remove, cp.insert, cp.reorder]) {\n if (call === undefined || typeof call === \"string\") continue;\n collectCallContributions(context, contributions, { parent, child: cp.child }, call);\n }\n });\n return contributions;\n};\n\nconst directTypeNames = (context: GirIndex, klass: GirClass, namespace: GirNamespace): Set<string> => {\n const names = new Set<string>();\n const glibName = glibNameOf(klass);\n if (glibName !== undefined) names.add(glibName);\n for (const name of klass.implements) {\n const resolved = context.library.resolveType(namespace.name, name);\n if (resolved === undefined || resolved.kind !== \"interface\") continue;\n const ifaceGlib = glibNameOf(resolved.value);\n if (ifaceGlib !== undefined) names.add(ifaceGlib);\n }\n return names;\n};\n\nconst constructOnlyNames = (context: GirIndex, entry: GirTypeEntry): string[] => {\n const names: string[] = [];\n for (const klass of chainOf(context, entry)) {\n for (const property of klass.properties) {\n if (property.constructOnly) names.push(toCamelIdentifier(property.name));\n }\n }\n return names;\n};\n\nconst methodReturnGlib = (context: GirIndex, typeName: string, methodCamel: string): string | undefined => {\n const method = findMethod(context, typeName, methodCamel);\n const ref = method?.fn.returnValue.type;\n if (ref === undefined) return undefined;\n const resolved = context.library.typeOf(ref);\n if (resolved === undefined || resolved.kind !== \"class\") return undefined;\n return glibNameOf(resolved.value);\n};\n\nconst resolveAdoptElement = (context: GirIndex, parent: string, cp: ContainerProp): string | undefined => {\n if (cp.adopt === undefined) return undefined;\n const source = typeof cp.adopt === \"string\" ? cp.adopt : cp.append;\n if (source === undefined) return undefined;\n const method = typeof source === \"string\" ? source : source.method;\n return methodReturnGlib(context, parent, method);\n};\n\nconst lazyElementExportOf = (context: GirIndex, element: string): LazyElementSpec => {\n const typeName = `${element}ElementProps`;\n const elementClass = context.index.get(element);\n if (elementClass === undefined) {\n return { element, typeName, typeSource: `export type ${typeName} = { children?: ReactNode };` };\n }\n const baseName = glibNameOf(elementClass.klass) ?? element;\n const omitted = constructOnlyNames(context, elementClass);\n const omitUnion = omitted.map((name) => JSON.stringify(name)).join(\" | \");\n const base = omitted.length === 0 ? `${baseName}Props` : `Omit<${baseName}Props, ${omitUnion}>`;\n return { element, typeName, typeSource: `export type ${typeName} = ${base};` };\n};\n\nconst collectLazyElementSpecs = (\n context: GirIndex,\n elementProps: Record<string, ElementProp[]>,\n): Map<string, LazyElementSpec[]> => {\n const specs = new Map<string, LazyElementSpec[]>();\n forEachContainer(elementProps, (parent, cp) => {\n const parentEntry = context.index.get(parent);\n if (parentEntry === undefined) return;\n const element = resolveAdoptElement(context, parent, cp);\n if (element === undefined) return;\n const spec = lazyElementExportOf(context, element);\n const list = specs.get(parentEntry.namespace.name) ?? [];\n if (!list.some((existing) => existing.element === spec.element)) list.push(spec);\n specs.set(parentEntry.namespace.name, list);\n });\n return specs;\n};\n\nconst collectContainerPropNames = (elementProps: Record<string, ElementProp[]>): Map<string, string[]> => {\n const containerPropNamesByParent = new Map<string, string[]>();\n forEachContainer(elementProps, (parent, cp) => {\n if (cp.prop === \"children\") return;\n const names = containerPropNamesByParent.get(parent) ?? [];\n if (!names.includes(cp.prop)) names.push(cp.prop);\n containerPropNamesByParent.set(parent, names);\n });\n return containerPropNamesByParent;\n};\n\nconst TEXT_CONTAINERS = [\"GtkLabel\", \"GtkTextBuffer\", \"GtkTextTag\", \"GtkTextView\"];\n\nexport const createElementPropTypegen = (\n context: GirIndex,\n elementProps: Record<string, ElementProp[]>,\n): ElementPropTypegen => {\n const appliedByType = new Map<string, AppliedProp[]>();\n for (const [type, props] of Object.entries(elementProps)) {\n for (const prop of props) {\n if (prop.kind === \"container\") continue;\n const list = appliedByType.get(type) ?? [];\n list.push(prop);\n appliedByType.set(type, list);\n }\n }\n\n const propContributions = collectPropContributions(context, elementProps);\n const lazyElementSpecs = collectLazyElementSpecs(context, elementProps);\n const containerPropNamesByParent = collectContainerPropNames(elementProps);\n\n const childrenContainers = new Set<string>(TEXT_CONTAINERS);\n forEachContainer(elementProps, (parent, cp) => {\n if (cp.prop === \"children\") childrenContainers.add(parent);\n const element = resolveAdoptElement(context, parent, cp);\n if (element !== undefined) childrenContainers.add(element);\n });\n\n const acceptsChildren = (glibName: string): boolean => {\n if (childrenContainers.has(glibName)) return true;\n const entry = context.index.get(glibName);\n if (entry === undefined) return false;\n const chain = chainOf(context, entry);\n if (chain.some((klass) => glibNameOf(klass) === \"GtkWidget\")) return true;\n return chain.some((klass) => {\n const name = glibNameOf(klass);\n return name !== undefined && childrenContainers.has(name);\n });\n };\n\n const classPropLines = (\n glibName: string,\n klass: GirClass,\n namespace: GirNamespace,\n imports: TypeImports,\n ): string[] => {\n const lines: string[] = [];\n for (const prop of appliedByType.get(glibName) ?? []) {\n const line = appliedPropLine(context, imports, glibName, prop);\n if (line !== null) lines.push(line);\n }\n const direct = directTypeNames(context, klass, namespace);\n for (const contribution of propContributions) {\n if (!direct.has(contribution.child)) continue;\n lines.push(optionalLine(contribution.prop, renderParamType(context, imports, contribution.param)));\n }\n return lines;\n };\n\n return {\n classPropLines,\n lazyElementExports: (namespaceName) => lazyElementSpecs.get(namespaceName) ?? [],\n containerPropNamesFor: (glibName) => containerPropNamesByParent.get(glibName) ?? [],\n acceptsChildren,\n };\n};\n"]}
@@ -0,0 +1,4 @@
1
+ import type { ElementProp } from "@gtkx/config";
2
+ import { type GirIndex } from "./gir-index.js";
3
+ export declare const assembleElementProps: (context: GirIndex, userElementProps: Record<string, ElementProp[]>) => Record<string, ElementProp[]>;
4
+ //# sourceMappingURL=element-props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"element-props.d.ts","sourceRoot":"","sources":["../../../src/store/react/element-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA4B,WAAW,EAAuB,MAAM,cAAc,CAAC;AAK/F,OAAO,EAAc,KAAK,QAAQ,EAA0B,MAAM,gBAAgB,CAAC;AA4LnF,eAAO,MAAM,oBAAoB,YACpB,QAAQ,oBACC,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,KAChD,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,CAO9B,CAAC"}
@@ -0,0 +1,178 @@
1
+ import { toCamelIdentifier } from "@gtkx/utils";
2
+ import { PRIMITIVE_TS_TYPE } from "../../gir/primitives.js";
3
+ import { BUILT_IN_ELEMENT_PROPS } from "./built-ins.js";
4
+ import { findMethod, hasMethod, hasProperty } from "./gir-index.js";
5
+ const callMethodName = (call) => (typeof call === "string" ? call : call.method);
6
+ const containerTypeNames = (parent, prop) => {
7
+ const names = [parent, prop.child];
8
+ if (prop.autowrap !== undefined)
9
+ names.push(prop.autowrap);
10
+ return names;
11
+ };
12
+ const containerCalls = (prop) => {
13
+ const calls = [prop.append, prop.remove, prop.insert, prop.reorder].filter((call) => call !== undefined);
14
+ if (typeof prop.adopt === "string")
15
+ calls.push(prop.adopt);
16
+ return calls;
17
+ };
18
+ const knownTypes = (context, names) => names.every((name) => context.index.has(name));
19
+ const elementPropError = (path, message) => new Error(`gtkx.config.ts: \`${path}\` ${message}`);
20
+ const validateTypeNames = (context, path, names) => {
21
+ for (const name of names) {
22
+ if (!context.index.has(name)) {
23
+ throw elementPropError(path, `references "${name}", which is not a type in the generated libraries`);
24
+ }
25
+ }
26
+ };
27
+ const validateCalls = (context, path, host, calls) => {
28
+ for (const call of calls) {
29
+ const method = callMethodName(call);
30
+ if (!hasMethod(context, host, method)) {
31
+ throw elementPropError(path, `references method "${method}", which does not exist on ${host}`);
32
+ }
33
+ }
34
+ };
35
+ const validateMember = (context, path, host, name) => {
36
+ if (!hasProperty(context, host, name)) {
37
+ throw elementPropError(path, `references "${name}", which is not a property of ${host}`);
38
+ }
39
+ };
40
+ const validateUserElementProp = (context, type, path, prop) => {
41
+ switch (prop.kind) {
42
+ case "container":
43
+ validateTypeNames(context, path, containerTypeNames(type, prop));
44
+ validateCalls(context, path, type, containerCalls(prop));
45
+ return;
46
+ case "value":
47
+ validateTypeNames(context, path, [type]);
48
+ validateCalls(context, path, type, prop.after === undefined ? [prop.call] : [prop.call, prop.after]);
49
+ return;
50
+ case "controlled-text":
51
+ validateTypeNames(context, path, [type]);
52
+ validateMember(context, path, type, prop.prop);
53
+ return;
54
+ case "lazy":
55
+ validateTypeNames(context, path, [type]);
56
+ validateMember(context, path, type, prop.prop);
57
+ if (prop.lookup !== undefined)
58
+ validateCalls(context, path, type, [prop.lookup]);
59
+ return;
60
+ case "list":
61
+ validateTypeNames(context, path, [type]);
62
+ validateCalls(context, path, type, listCalls(prop));
63
+ return;
64
+ }
65
+ };
66
+ const addCalls = (add) => (Array.isArray(add) ? add : [add]);
67
+ const listCalls = (prop) => {
68
+ const calls = addCalls(prop.add);
69
+ if (prop.remove !== undefined)
70
+ calls.push(prop.remove);
71
+ if (prop.clear !== undefined)
72
+ calls.push(prop.clear);
73
+ return calls;
74
+ };
75
+ const NO_DEFAULT = Symbol("gtkx.no-default");
76
+ const inferredDefault = (context, param) => {
77
+ if (param.nullable)
78
+ return null;
79
+ const type = param.type === undefined ? undefined : context.library.typeOf(param.type);
80
+ if (type?.kind !== "primitive")
81
+ return NO_DEFAULT;
82
+ switch (PRIMITIVE_TS_TYPE[type.category]) {
83
+ case "number":
84
+ return 0;
85
+ case "boolean":
86
+ return false;
87
+ default:
88
+ return NO_DEFAULT;
89
+ }
90
+ };
91
+ const argForParameter = (context, param) => {
92
+ const field = toCamelIdentifier(param.name);
93
+ const or = inferredDefault(context, param);
94
+ return or === NO_DEFAULT ? { field } : { field, or };
95
+ };
96
+ const callArity = (context, type, call) => typeof call === "string" ? findMethod(context, type, call)?.params.length : undefined;
97
+ const expandCall = (context, type, call, scalar) => {
98
+ if (typeof call !== "string" || scalar)
99
+ return call;
100
+ const method = findMethod(context, type, call);
101
+ if (method === undefined || method.params.length === 0)
102
+ return call;
103
+ return { method: call, args: method.params.map((param) => argForParameter(context, param)) };
104
+ };
105
+ const expandListProp = (context, type, prop) => {
106
+ const scalar = !Array.isArray(prop.add) && callArity(context, type, prop.add) === 1;
107
+ const add = Array.isArray(prop.add)
108
+ ? prop.add.map((call) => expandCall(context, type, call, false))
109
+ : expandCall(context, type, prop.add, scalar);
110
+ return {
111
+ ...prop,
112
+ add,
113
+ remove: prop.remove === undefined ? undefined : expandCall(context, type, prop.remove, scalar),
114
+ };
115
+ };
116
+ const expandValueProp = (context, type, prop) => {
117
+ const arity = callArity(context, type, prop.call);
118
+ return { ...prop, call: expandCall(context, type, prop.call, arity === undefined || arity <= 1) };
119
+ };
120
+ const expandAppliedProps = (context, elementProps) => {
121
+ const result = {};
122
+ for (const [type, props] of Object.entries(elementProps)) {
123
+ result[type] = props.map((prop) => {
124
+ if (prop.kind === "list")
125
+ return expandListProp(context, type, prop);
126
+ if (prop.kind === "value")
127
+ return expandValueProp(context, type, prop);
128
+ return prop;
129
+ });
130
+ }
131
+ return result;
132
+ };
133
+ const validateUserElementProps = (context, elementProps) => {
134
+ for (const [type, props] of Object.entries(elementProps)) {
135
+ props.forEach((prop, index) => {
136
+ validateUserElementProp(context, type, `elementProps.${type}[${index}]`, prop);
137
+ });
138
+ }
139
+ };
140
+ const elementPropKey = (prop) => prop.kind === "container" ? `container:${prop.prop}:${prop.child}` : `applied:${prop.prop}`;
141
+ const mergeElementProps = (layers) => {
142
+ const byType = new Map();
143
+ for (const layer of layers) {
144
+ for (const [type, props] of Object.entries(layer)) {
145
+ const merged = byType.get(type) ?? new Map();
146
+ for (const prop of props) {
147
+ const key = elementPropKey(prop);
148
+ merged.delete(key);
149
+ merged.set(key, prop);
150
+ }
151
+ byType.set(type, merged);
152
+ }
153
+ }
154
+ const result = {};
155
+ for (const [type, merged] of byType)
156
+ result[type] = [...merged.values()];
157
+ return result;
158
+ };
159
+ const filterKnownElementProps = (context, map) => {
160
+ const result = {};
161
+ for (const [type, props] of Object.entries(map)) {
162
+ if (!context.index.has(type))
163
+ continue;
164
+ const kept = props.filter((prop) => prop.kind !== "container" || knownTypes(context, containerTypeNames(type, prop)));
165
+ if (kept.length > 0)
166
+ result[type] = kept;
167
+ }
168
+ return result;
169
+ };
170
+ export const assembleElementProps = (context, userElementProps) => {
171
+ validateUserElementProps(context, userElementProps);
172
+ const merged = mergeElementProps([
173
+ filterKnownElementProps(context, BUILT_IN_ELEMENT_PROPS),
174
+ filterKnownElementProps(context, userElementProps),
175
+ ]);
176
+ return expandAppliedProps(context, merged);
177
+ };
178
+ //# sourceMappingURL=element-props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"element-props.js","sourceRoot":"","sources":["../../../src/store/react/element-props.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAiB,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEnF,MAAM,cAAc,GAAG,CAAC,IAAU,EAAU,EAAE,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAE/F,MAAM,kBAAkB,GAAG,CAAC,MAAc,EAAE,IAAmB,EAAY,EAAE;IACzE,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3D,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,IAAmB,EAAU,EAAE;IACnD,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CACtE,CAAC,IAAI,EAAgB,EAAE,CAAC,IAAI,KAAK,SAAS,CAC7C,CAAC;IACF,IAAI,OAAO,IAAI,CAAC,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AM,CACrB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,UAAU,CAAC,OAAO,EAAE,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAC7F,CAAC;QACF,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC7C,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAChC,OAAiB,EACjB,gBAA+C,EAClB,EAAE;IAC/B,wBAAwB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,iBAAiB,CAAC;QAC7B,uBAAuB,CAAC,OAAO,EAAE,sBAAsB,CAAC;QACxD,uBAAuB,CAAC,OAAO,EAAE,gBAAgB,CAAC;KACrD,CAAC,CAAC;IACH,OAAO,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC,CAAC","sourcesContent":["import type { Arg, Call, ContainerProp, ElementProp, ListProp, ValueProp } from \"@gtkx/config\";\nimport { toCamelIdentifier } from \"@gtkx/utils\";\nimport type { GirParameter } from \"../../gir/parameter.js\";\nimport { PRIMITIVE_TS_TYPE } from \"../../gir/primitives.js\";\nimport { BUILT_IN_ELEMENT_PROPS } from \"./built-ins.js\";\nimport { findMethod, type GirIndex, hasMethod, hasProperty } from \"./gir-index.js\";\n\nconst callMethodName = (call: Call): string => (typeof call === \"string\" ? call : call.method);\n\nconst containerTypeNames = (parent: string, prop: ContainerProp): string[] => {\n const names = [parent, prop.child];\n if (prop.autowrap !== undefined) names.push(prop.autowrap);\n return names;\n};\n\nconst containerCalls = (prop: ContainerProp): Call[] => {\n const calls = [prop.append, prop.remove, prop.insert, prop.reorder].filter(\n (call): call is Call => call !== undefined,\n );\n if (typeof prop.adopt === \"string\") calls.push(prop.adopt);\n return calls;\n};\n\nconst knownTypes = (context: GirIndex, names: string[]): boolean => names.every((name) => context.index.has(name));\n\nconst elementPropError = (path: string, message: string): Error => new Error(`gtkx.config.ts: \\`${path}\\` ${message}`);\n\nconst validateTypeNames = (context: GirIndex, path: string, names: string[]): void => {\n for (const name of names) {\n if (!context.index.has(name)) {\n throw elementPropError(path, `references \"${name}\", which is not a type in the generated libraries`);\n }\n }\n};\n\nconst validateCalls = (context: GirIndex, path: string, host: string, calls: Call[]): void => {\n for (const call of calls) {\n const method = callMethodName(call);\n if (!hasMethod(context, host, method)) {\n throw elementPropError(path, `references method \"${method}\", which does not exist on ${host}`);\n }\n }\n};\n\nconst validateMember = (context: GirIndex, path: string, host: string, name: string): void => {\n if (!hasProperty(context, host, name)) {\n throw elementPropError(path, `references \"${name}\", which is not a property of ${host}`);\n }\n};\n\nconst validateUserElementProp = (context: GirIndex, type: string, path: string, prop: ElementProp): void => {\n switch (prop.kind) {\n case \"container\":\n validateTypeNames(context, path, containerTypeNames(type, prop));\n validateCalls(context, path, type, containerCalls(prop));\n return;\n case \"value\":\n validateTypeNames(context, path, [type]);\n validateCalls(context, path, type, prop.after === undefined ? [prop.call] : [prop.call, prop.after]);\n return;\n case \"controlled-text\":\n validateTypeNames(context, path, [type]);\n validateMember(context, path, type, prop.prop);\n return;\n case \"lazy\":\n validateTypeNames(context, path, [type]);\n validateMember(context, path, type, prop.prop);\n if (prop.lookup !== undefined) validateCalls(context, path, type, [prop.lookup]);\n return;\n case \"list\":\n validateTypeNames(context, path, [type]);\n validateCalls(context, path, type, listCalls(prop));\n return;\n }\n};\n\nconst addCalls = (add: ListProp[\"add\"]): Call[] => (Array.isArray(add) ? add : [add]);\n\nconst listCalls = (prop: ListProp): Call[] => {\n const calls = addCalls(prop.add);\n if (prop.remove !== undefined) calls.push(prop.remove);\n if (prop.clear !== undefined) calls.push(prop.clear);\n return calls;\n};\n\nconst NO_DEFAULT = Symbol(\"gtkx.no-default\");\n\nconst inferredDefault = (context: GirIndex, param: GirParameter): null | number | boolean | typeof NO_DEFAULT => {\n if (param.nullable) return null;\n const type = param.type === undefined ? undefined : context.library.typeOf(param.type);\n if (type?.kind !== \"primitive\") return NO_DEFAULT;\n switch (PRIMITIVE_TS_TYPE[type.category]) {\n case \"number\":\n return 0;\n case \"boolean\":\n return false;\n default:\n return NO_DEFAULT;\n }\n};\n\nconst argForParameter = (context: GirIndex, param: GirParameter): Arg => {\n const field = toCamelIdentifier(param.name);\n const or = inferredDefault(context, param);\n return or === NO_DEFAULT ? { field } : { field, or };\n};\n\nconst callArity = (context: GirIndex, type: string, call: Call): number | undefined =>\n typeof call === \"string\" ? findMethod(context, type, call)?.params.length : undefined;\n\nconst expandCall = (context: GirIndex, type: string, call: Call, scalar: boolean): Call => {\n if (typeof call !== \"string\" || scalar) return call;\n const method = findMethod(context, type, call);\n if (method === undefined || method.params.length === 0) return call;\n return { method: call, args: method.params.map((param) => argForParameter(context, param)) };\n};\n\nconst expandListProp = (context: GirIndex, type: string, prop: ListProp): ListProp => {\n const scalar = !Array.isArray(prop.add) && callArity(context, type, prop.add) === 1;\n const add = Array.isArray(prop.add)\n ? prop.add.map((call) => expandCall(context, type, call, false))\n : expandCall(context, type, prop.add, scalar);\n return {\n ...prop,\n add,\n remove: prop.remove === undefined ? undefined : expandCall(context, type, prop.remove, scalar),\n };\n};\n\nconst expandValueProp = (context: GirIndex, type: string, prop: ValueProp): ValueProp => {\n const arity = callArity(context, type, prop.call);\n return { ...prop, call: expandCall(context, type, prop.call, arity === undefined || arity <= 1) };\n};\n\nconst expandAppliedProps = (\n context: GirIndex,\n elementProps: Record<string, ElementProp[]>,\n): Record<string, ElementProp[]> => {\n const result: Record<string, ElementProp[]> = {};\n for (const [type, props] of Object.entries(elementProps)) {\n result[type] = props.map((prop) => {\n if (prop.kind === \"list\") return expandListProp(context, type, prop);\n if (prop.kind === \"value\") return expandValueProp(context, type, prop);\n return prop;\n });\n }\n return result;\n};\n\nconst validateUserElementProps = (context: GirIndex, elementProps: Record<string, ElementProp[]>): void => {\n for (const [type, props] of Object.entries(elementProps)) {\n props.forEach((prop, index) => {\n validateUserElementProp(context, type, `elementProps.${type}[${index}]`, prop);\n });\n }\n};\n\nconst elementPropKey = (prop: ElementProp): string =>\n prop.kind === \"container\" ? `container:${prop.prop}:${prop.child}` : `applied:${prop.prop}`;\n\nconst mergeElementProps = (layers: Record<string, ElementProp[]>[]): Record<string, ElementProp[]> => {\n const byType = new Map<string, Map<string, ElementProp>>();\n for (const layer of layers) {\n for (const [type, props] of Object.entries(layer)) {\n const merged = byType.get(type) ?? new Map<string, ElementProp>();\n for (const prop of props) {\n const key = elementPropKey(prop);\n merged.delete(key);\n merged.set(key, prop);\n }\n byType.set(type, merged);\n }\n }\n const result: Record<string, ElementProp[]> = {};\n for (const [type, merged] of byType) result[type] = [...merged.values()];\n return result;\n};\n\nconst filterKnownElementProps = (\n context: GirIndex,\n map: Record<string, ElementProp[]>,\n): Record<string, ElementProp[]> => {\n const result: Record<string, ElementProp[]> = {};\n for (const [type, props] of Object.entries(map)) {\n if (!context.index.has(type)) continue;\n const kept = props.filter(\n (prop) => prop.kind !== \"container\" || knownTypes(context, containerTypeNames(type, prop)),\n );\n if (kept.length > 0) result[type] = kept;\n }\n return result;\n};\n\nexport const assembleElementProps = (\n context: GirIndex,\n userElementProps: Record<string, ElementProp[]>,\n): Record<string, ElementProp[]> => {\n validateUserElementProps(context, userElementProps);\n const merged = mergeElementProps([\n filterKnownElementProps(context, BUILT_IN_ELEMENT_PROPS),\n filterKnownElementProps(context, userElementProps),\n ]);\n return expandAppliedProps(context, merged);\n};\n"]}
@@ -0,0 +1,25 @@
1
+ import type { GirClass } from "../../gir/class.js";
2
+ import type { GirFunction } from "../../gir/function.js";
3
+ import type { Library } from "../../gir/library.js";
4
+ import type { GirNamespace } from "../../gir/namespace.js";
5
+ import type { GirParameter } from "../../gir/parameter.js";
6
+ export type GirTypeEntry = {
7
+ klass: GirClass;
8
+ namespace: GirNamespace;
9
+ isInterface: boolean;
10
+ };
11
+ export type GirIndex = {
12
+ library: Library;
13
+ index: Map<string, GirTypeEntry>;
14
+ };
15
+ export declare const buildGirIndex: (library: Library) => GirIndex;
16
+ export declare const chainOf: (context: GirIndex, entry: GirTypeEntry) => GirClass[];
17
+ type ResolvedMethod = {
18
+ fn: GirFunction;
19
+ params: GirParameter[];
20
+ };
21
+ export declare const findMethod: (context: GirIndex, typeName: string, camelName: string) => ResolvedMethod | undefined;
22
+ export declare const hasMethod: (context: GirIndex, typeName: string, camelName: string) => boolean;
23
+ export declare const hasProperty: (context: GirIndex, typeName: string, camelName: string) => boolean;
24
+ export {};
25
+ //# sourceMappingURL=gir-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gir-index.d.ts","sourceRoot":"","sources":["../../../src/store/react/gir-index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3D,MAAM,MAAM,YAAY,GAAG;IACvB,KAAK,EAAE,QAAQ,CAAC;IAChB,SAAS,EAAE,YAAY,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,aAAa,YAAa,OAAO,KAAG,QAiBhD,CAAC;AAEF,eAAO,MAAM,OAAO,YAAa,QAAQ,SAAS,YAAY,KAAG,QAAQ,EAMxE,CAAC;AAEF,KAAK,cAAc,GAAG;IAClB,EAAE,EAAE,WAAW,CAAC;IAChB,MAAM,EAAE,YAAY,EAAE,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,UAAU,YAAa,QAAQ,YAAY,MAAM,aAAa,MAAM,KAAG,cAAc,GAAG,SAepG,CAAC;AAQF,eAAO,MAAM,SAAS,YAAa,QAAQ,YAAY,MAAM,aAAa,MAAM,KAAG,OAG9E,CAAC;AAEN,eAAO,MAAM,WAAW,YAAa,QAAQ,YAAY,MAAM,aAAa,MAAM,KAAG,OAGhF,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { toCamelIdentifier } from "@gtkx/utils";
2
+ import { inputParameters } from "../../analysis/param-structure.js";
3
+ import { ancestorChain } from "../../gir/ancestry.js";
4
+ import { glibNameOf, implementedInterfaces } from "./intrinsic-elements.js";
5
+ export const buildGirIndex = (library) => {
6
+ const index = new Map();
7
+ for (const namespace of library.namespaces.values()) {
8
+ for (const klass of namespace.classes) {
9
+ const glibName = glibNameOf(klass);
10
+ if (glibName !== undefined && !index.has(glibName)) {
11
+ index.set(glibName, { klass, namespace, isInterface: false });
12
+ }
13
+ }
14
+ for (const klass of namespace.interfaces) {
15
+ const glibName = glibNameOf(klass);
16
+ if (glibName !== undefined && !index.has(glibName)) {
17
+ index.set(glibName, { klass, namespace, isInterface: true });
18
+ }
19
+ }
20
+ }
21
+ return { library, index };
22
+ };
23
+ export const chainOf = (context, entry) => {
24
+ if (entry.isInterface)
25
+ return [entry.klass];
26
+ const chain = [];
27
+ for (const { klass } of ancestorChain(context.library, entry.klass, entry.namespace.name))
28
+ chain.push(klass);
29
+ for (const iface of implementedInterfaces(entry.klass, entry.namespace, context.library))
30
+ chain.push(iface.klass);
31
+ return chain;
32
+ };
33
+ export const findMethod = (context, typeName, camelName) => {
34
+ const entry = context.index.get(typeName);
35
+ if (entry === undefined)
36
+ return undefined;
37
+ for (const klass of chainOf(context, entry)) {
38
+ const fn = klass.methods.find((method) => method.introspectable &&
39
+ method.shadowedBy === undefined &&
40
+ toCamelIdentifier(method.name) === camelName);
41
+ if (fn !== undefined) {
42
+ return { fn, params: inputParameters(context.library, fn).map((input) => input.parameter) };
43
+ }
44
+ }
45
+ return undefined;
46
+ };
47
+ const chainSome = (context, typeName, predicate) => {
48
+ const entry = context.index.get(typeName);
49
+ if (entry === undefined)
50
+ return false;
51
+ return chainOf(context, entry).some(predicate);
52
+ };
53
+ export const hasMethod = (context, typeName, camelName) => chainSome(context, typeName, (klass) => klass.methods.some((method) => method.introspectable && toCamelIdentifier(method.name) === camelName));
54
+ export const hasProperty = (context, typeName, camelName) => chainSome(context, typeName, (klass) => klass.properties.some((property) => toCamelIdentifier(property.name) === camelName));
55
+ //# sourceMappingURL=gir-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gir-index.js","sourceRoot":"","sources":["../../../src/store/react/gir-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAMtD,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAa5E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAgB,EAAY,EAAE;IACxD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC9C,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;QAClD,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;YACpC,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;YACnC,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACjD,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAA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C,KAAK,SAAS,CAAC,CACxG,CAAC;AAEN,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAiB,EAAE,QAAgB,EAAE,SAAiB,EAAW,EAAE,CAC3F,SAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CACnC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,CACtF,CAAC","sourcesContent":["import { toCamelIdentifier } from \"@gtkx/utils\";\nimport { inputParameters } from \"../../analysis/param-structure.js\";\nimport { ancestorChain } from \"../../gir/ancestry.js\";\nimport type { GirClass } from \"../../gir/class.js\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { Library } from \"../../gir/library.js\";\nimport type { GirNamespace } from \"../../gir/namespace.js\";\nimport type { GirParameter } from \"../../gir/parameter.js\";\nimport { glibNameOf, implementedInterfaces } from \"./intrinsic-elements.js\";\n\nexport type GirTypeEntry = {\n klass: GirClass;\n namespace: GirNamespace;\n isInterface: boolean;\n};\n\nexport type GirIndex = {\n library: Library;\n index: Map<string, GirTypeEntry>;\n};\n\nexport const buildGirIndex = (library: Library): GirIndex => {\n const index = new Map<string, GirTypeEntry>();\n for (const namespace of library.namespaces.values()) {\n for (const klass of namespace.classes) {\n const glibName = glibNameOf(klass);\n if (glibName !== undefined && !index.has(glibName)) {\n index.set(glibName, { klass, namespace, isInterface: false });\n }\n }\n for (const klass of namespace.interfaces) {\n const glibName = glibNameOf(klass);\n if (glibName !== undefined && !index.has(glibName)) {\n index.set(glibName, { klass, namespace, isInterface: true });\n }\n }\n }\n return { library, index };\n};\n\nexport const chainOf = (context: GirIndex, entry: GirTypeEntry): GirClass[] => {\n if (entry.isInterface) return [entry.klass];\n const chain: GirClass[] = [];\n for (const { klass } of ancestorChain(context.library, entry.klass, entry.namespace.name)) chain.push(klass);\n for (const iface of implementedInterfaces(entry.klass, entry.namespace, context.library)) chain.push(iface.klass);\n return chain;\n};\n\ntype ResolvedMethod = {\n fn: GirFunction;\n params: GirParameter[];\n};\n\nexport const findMethod = (context: GirIndex, typeName: string, camelName: string): ResolvedMethod | undefined => {\n const entry = context.index.get(typeName);\n if (entry === undefined) return undefined;\n for (const klass of chainOf(context, entry)) {\n const fn = klass.methods.find(\n (method) =>\n method.introspectable &&\n method.shadowedBy === undefined &&\n toCamelIdentifier(method.name) === camelName,\n );\n if (fn !== undefined) {\n return { fn, params: inputParameters(context.library, fn).map((input) => input.parameter) };\n }\n }\n return undefined;\n};\n\nconst chainSome = (context: GirIndex, typeName: string, predicate: (klass: GirClass) => boolean): boolean => {\n const entry = context.index.get(typeName);\n if (entry === undefined) return false;\n return chainOf(context, entry).some(predicate);\n};\n\nexport const hasMethod = (context: GirIndex, typeName: string, camelName: string): boolean =>\n chainSome(context, typeName, (klass) =>\n klass.methods.some((method) => method.introspectable && toCamelIdentifier(method.name) === camelName),\n );\n\nexport const hasProperty = (context: GirIndex, typeName: string, camelName: string): boolean =>\n chainSome(context, typeName, (klass) =>\n klass.properties.some((property) => toCamelIdentifier(property.name) === camelName),\n );\n"]}