@gtkx/codegen 1.0.0-rc.4 → 1.1.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 (523) hide show
  1. package/README.md +5 -5
  2. package/dist/analysis/descriptor-render.d.ts +13 -9
  3. package/dist/analysis/descriptor-render.d.ts.map +1 -1
  4. package/dist/analysis/descriptor-render.js +80 -50
  5. package/dist/analysis/descriptor-render.js.map +1 -1
  6. package/dist/analysis/descriptor.d.ts +16 -7
  7. package/dist/analysis/descriptor.d.ts.map +1 -1
  8. package/dist/analysis/descriptor.js +15 -3
  9. package/dist/analysis/descriptor.js.map +1 -1
  10. package/dist/analysis/inheritance.d.ts +4 -3
  11. package/dist/analysis/inheritance.d.ts.map +1 -1
  12. package/dist/analysis/inheritance.js +103 -58
  13. package/dist/analysis/inheritance.js.map +1 -1
  14. package/dist/analysis/interface-conflicts.d.ts +23 -0
  15. package/dist/analysis/interface-conflicts.d.ts.map +1 -0
  16. package/dist/analysis/interface-conflicts.js +144 -0
  17. package/dist/analysis/interface-conflicts.js.map +1 -0
  18. package/dist/analysis/nul-terminated-bytes.d.ts +5 -0
  19. package/dist/analysis/nul-terminated-bytes.d.ts.map +1 -0
  20. package/dist/analysis/nul-terminated-bytes.js +18 -0
  21. package/dist/analysis/nul-terminated-bytes.js.map +1 -0
  22. package/dist/analysis/param-capability.d.ts +5 -0
  23. package/dist/analysis/param-capability.d.ts.map +1 -0
  24. package/dist/analysis/param-capability.js +129 -0
  25. package/dist/analysis/param-capability.js.map +1 -0
  26. package/dist/analysis/param-structure.d.ts +11 -4
  27. package/dist/analysis/param-structure.d.ts.map +1 -1
  28. package/dist/analysis/param-structure.js +42 -16
  29. package/dist/analysis/param-structure.js.map +1 -1
  30. package/dist/analysis/ts-type.d.ts.map +1 -1
  31. package/dist/analysis/ts-type.js +10 -17
  32. package/dist/analysis/ts-type.js.map +1 -1
  33. package/dist/analysis/type-key.d.ts +5 -0
  34. package/dist/analysis/type-key.d.ts.map +1 -0
  35. package/dist/analysis/type-key.js +9 -0
  36. package/dist/analysis/type-key.js.map +1 -0
  37. package/dist/analysis/type-shape.d.ts +8 -0
  38. package/dist/analysis/type-shape.d.ts.map +1 -0
  39. package/dist/analysis/type-shape.js +12 -0
  40. package/dist/analysis/type-shape.js.map +1 -0
  41. package/dist/compile.d.ts +12 -3
  42. package/dist/compile.d.ts.map +1 -1
  43. package/dist/compile.js +73 -24
  44. package/dist/compile.js.map +1 -1
  45. package/dist/docs/api-reference.d.ts +2 -2
  46. package/dist/docs/api-reference.d.ts.map +1 -1
  47. package/dist/docs/api-reference.js +17 -23
  48. package/dist/docs/api-reference.js.map +1 -1
  49. package/dist/docs/element-page.d.ts +4 -4
  50. package/dist/docs/element-page.d.ts.map +1 -1
  51. package/dist/docs/element-page.js +36 -22
  52. package/dist/docs/element-page.js.map +1 -1
  53. package/dist/docs/handwritten-props.d.ts +9 -0
  54. package/dist/docs/handwritten-props.d.ts.map +1 -0
  55. package/dist/docs/handwritten-props.js +149 -0
  56. package/dist/docs/handwritten-props.js.map +1 -0
  57. package/dist/docs/pipeline.d.ts.map +1 -1
  58. package/dist/docs/pipeline.js +87 -20
  59. package/dist/docs/pipeline.js.map +1 -1
  60. package/dist/docs/render.d.ts +26 -5
  61. package/dist/docs/render.d.ts.map +1 -1
  62. package/dist/docs/render.js +88 -25
  63. package/dist/docs/render.js.map +1 -1
  64. package/dist/docs/symbol-page.d.ts +17 -0
  65. package/dist/docs/symbol-page.d.ts.map +1 -1
  66. package/dist/docs/symbol-page.js +132 -44
  67. package/dist/docs/symbol-page.js.map +1 -1
  68. package/dist/fingerprint.d.ts +12 -1
  69. package/dist/fingerprint.d.ts.map +1 -1
  70. package/dist/fingerprint.js +44 -28
  71. package/dist/fingerprint.js.map +1 -1
  72. package/dist/gi.d.ts.map +1 -1
  73. package/dist/gi.js +1 -0
  74. package/dist/gi.js.map +1 -1
  75. package/dist/gir/ancestry.d.ts +8 -2
  76. package/dist/gir/ancestry.d.ts.map +1 -1
  77. package/dist/gir/ancestry.js +19 -1
  78. package/dist/gir/ancestry.js.map +1 -1
  79. package/dist/gir/annotations.d.ts +21 -0
  80. package/dist/gir/annotations.d.ts.map +1 -0
  81. package/dist/gir/annotations.js +15 -0
  82. package/dist/gir/annotations.js.map +1 -0
  83. package/dist/gir/callback.d.ts +1 -0
  84. package/dist/gir/callback.d.ts.map +1 -1
  85. package/dist/gir/callback.js +1 -0
  86. package/dist/gir/callback.js.map +1 -1
  87. package/dist/gir/class.d.ts +32 -1
  88. package/dist/gir/class.d.ts.map +1 -1
  89. package/dist/gir/class.js +8 -3
  90. package/dist/gir/class.js.map +1 -1
  91. package/dist/gir/cursor-overrides.d.ts +8 -0
  92. package/dist/gir/cursor-overrides.d.ts.map +1 -0
  93. package/dist/gir/cursor-overrides.js +6 -0
  94. package/dist/gir/cursor-overrides.js.map +1 -0
  95. package/dist/gir/emittable.d.ts +7 -0
  96. package/dist/gir/emittable.d.ts.map +1 -0
  97. package/dist/gir/emittable.js +3 -0
  98. package/dist/gir/emittable.js.map +1 -0
  99. package/dist/gir/enum.d.ts +21 -1
  100. package/dist/gir/enum.d.ts.map +1 -1
  101. package/dist/gir/enum.js +9 -9
  102. package/dist/gir/enum.js.map +1 -1
  103. package/dist/gir/field.d.ts +19 -3
  104. package/dist/gir/field.d.ts.map +1 -1
  105. package/dist/gir/field.js +7 -8
  106. package/dist/gir/field.js.map +1 -1
  107. package/dist/gir/function.d.ts +15 -0
  108. package/dist/gir/function.d.ts.map +1 -1
  109. package/dist/gir/function.js +28 -2
  110. package/dist/gir/function.js.map +1 -1
  111. package/dist/gir/libraries.d.ts +1 -3
  112. package/dist/gir/libraries.d.ts.map +1 -1
  113. package/dist/gir/libraries.js +0 -1
  114. package/dist/gir/libraries.js.map +1 -1
  115. package/dist/gir/library.d.ts +36 -0
  116. package/dist/gir/library.d.ts.map +1 -1
  117. package/dist/gir/library.js +35 -1
  118. package/dist/gir/library.js.map +1 -1
  119. package/dist/gir/namespace.d.ts +43 -1
  120. package/dist/gir/namespace.d.ts.map +1 -1
  121. package/dist/gir/namespace.js +8 -7
  122. package/dist/gir/namespace.js.map +1 -1
  123. package/dist/gir/parameter.d.ts +52 -1
  124. package/dist/gir/parameter.d.ts.map +1 -1
  125. package/dist/gir/parameter.js +8 -3
  126. package/dist/gir/parameter.js.map +1 -1
  127. package/dist/gir/parse.d.ts +3 -1
  128. package/dist/gir/parse.d.ts.map +1 -1
  129. package/dist/gir/parse.js +9 -9
  130. package/dist/gir/parse.js.map +1 -1
  131. package/dist/gir/primitives.d.ts +1 -0
  132. package/dist/gir/primitives.d.ts.map +1 -1
  133. package/dist/gir/primitives.js.map +1 -1
  134. package/dist/gir/property.d.ts +16 -0
  135. package/dist/gir/property.d.ts.map +1 -1
  136. package/dist/gir/property.js +3 -3
  137. package/dist/gir/property.js.map +1 -1
  138. package/dist/gir/record.d.ts +22 -0
  139. package/dist/gir/record.d.ts.map +1 -1
  140. package/dist/gir/record.js +3 -2
  141. package/dist/gir/record.js.map +1 -1
  142. package/dist/gir/size.d.ts +5 -4
  143. package/dist/gir/size.d.ts.map +1 -1
  144. package/dist/gir/size.js.map +1 -1
  145. package/dist/gir/type-id.d.ts +35 -0
  146. package/dist/gir/type-id.d.ts.map +1 -1
  147. package/dist/gir/type-id.js +1 -0
  148. package/dist/gir/type-id.js.map +1 -1
  149. package/dist/gir/type-ref.d.ts.map +1 -1
  150. package/dist/gir/type-ref.js +1 -0
  151. package/dist/gir/type-ref.js.map +1 -1
  152. package/dist/gir/type.d.ts +20 -0
  153. package/dist/gir/type.d.ts.map +1 -1
  154. package/dist/gir/type.js.map +1 -1
  155. package/dist/guards.d.ts +16 -0
  156. package/dist/guards.d.ts.map +1 -0
  157. package/dist/guards.js +11 -0
  158. package/dist/guards.js.map +1 -0
  159. package/dist/internal.d.ts +2 -0
  160. package/dist/internal.d.ts.map +1 -1
  161. package/dist/internal.js +2 -0
  162. package/dist/internal.js.map +1 -1
  163. package/dist/json.d.ts +3 -0
  164. package/dist/json.d.ts.map +1 -0
  165. package/dist/json.js +11 -0
  166. package/dist/json.js.map +1 -0
  167. package/dist/khronos/args.d.ts +7 -6
  168. package/dist/khronos/args.d.ts.map +1 -1
  169. package/dist/khronos/args.js +28 -6
  170. package/dist/khronos/args.js.map +1 -1
  171. package/dist/khronos/doc-context.d.ts +29 -0
  172. package/dist/khronos/doc-context.d.ts.map +1 -0
  173. package/dist/khronos/doc-context.js +29 -0
  174. package/dist/khronos/doc-context.js.map +1 -0
  175. package/dist/khronos/extensions.d.ts +13 -0
  176. package/dist/khronos/extensions.d.ts.map +1 -0
  177. package/dist/khronos/extensions.js +49 -0
  178. package/dist/khronos/extensions.js.map +1 -0
  179. package/dist/khronos/jsdoc.d.ts +17 -11
  180. package/dist/khronos/jsdoc.d.ts.map +1 -1
  181. package/dist/khronos/jsdoc.js +104 -46
  182. package/dist/khronos/jsdoc.js.map +1 -1
  183. package/dist/khronos/model.d.ts +42 -3
  184. package/dist/khronos/model.d.ts.map +1 -1
  185. package/dist/khronos/model.js +218 -63
  186. package/dist/khronos/model.js.map +1 -1
  187. package/dist/khronos/modules.d.ts +9 -6
  188. package/dist/khronos/modules.d.ts.map +1 -1
  189. package/dist/khronos/modules.js +112 -27
  190. package/dist/khronos/modules.js.map +1 -1
  191. package/dist/khronos/notes.d.ts +19 -0
  192. package/dist/khronos/notes.d.ts.map +1 -0
  193. package/dist/khronos/notes.js +35 -0
  194. package/dist/khronos/notes.js.map +1 -0
  195. package/dist/khronos/param-pair.d.ts +1 -1
  196. package/dist/khronos/param-pair.d.ts.map +1 -1
  197. package/dist/khronos/param-pair.js.map +1 -1
  198. package/dist/khronos/parse.d.ts.map +1 -1
  199. package/dist/khronos/parse.js +3 -4
  200. package/dist/khronos/parse.js.map +1 -1
  201. package/dist/khronos/pipeline.d.ts +4 -2
  202. package/dist/khronos/pipeline.d.ts.map +1 -1
  203. package/dist/khronos/pipeline.js +58 -27
  204. package/dist/khronos/pipeline.js.map +1 -1
  205. package/dist/khronos/plan.d.ts +3 -9
  206. package/dist/khronos/plan.d.ts.map +1 -1
  207. package/dist/khronos/plan.js +3 -3
  208. package/dist/khronos/plan.js.map +1 -1
  209. package/dist/khronos/render.d.ts +8 -6
  210. package/dist/khronos/render.d.ts.map +1 -1
  211. package/dist/khronos/render.js +35 -26
  212. package/dist/khronos/render.js.map +1 -1
  213. package/dist/khronos/select.d.ts +21 -4
  214. package/dist/khronos/select.d.ts.map +1 -1
  215. package/dist/khronos/select.js +47 -34
  216. package/dist/khronos/select.js.map +1 -1
  217. package/dist/react/element-config.d.ts +2 -2
  218. package/dist/react/element-config.d.ts.map +1 -1
  219. package/dist/react/element-config.js.map +1 -1
  220. package/dist/runner.d.ts +6 -8
  221. package/dist/runner.d.ts.map +1 -1
  222. package/dist/runner.js +16 -0
  223. package/dist/runner.js.map +1 -1
  224. package/dist/staging.d.ts +5 -0
  225. package/dist/staging.d.ts.map +1 -0
  226. package/dist/staging.js +57 -0
  227. package/dist/staging.js.map +1 -0
  228. package/dist/store/compile-store.d.ts +1 -1
  229. package/dist/store/compile-store.d.ts.map +1 -1
  230. package/dist/store/compile-store.js +4 -2
  231. package/dist/store/compile-store.js.map +1 -1
  232. package/dist/store/gi/callable-doc.d.ts +11 -0
  233. package/dist/store/gi/callable-doc.d.ts.map +1 -0
  234. package/dist/store/gi/callable-doc.js +62 -0
  235. package/dist/store/gi/callable-doc.js.map +1 -0
  236. package/dist/store/gi/callables.d.ts +9 -2
  237. package/dist/store/gi/callables.d.ts.map +1 -1
  238. package/dist/store/gi/callables.js +35 -40
  239. package/dist/store/gi/callables.js.map +1 -1
  240. package/dist/store/gi/callback.d.ts.map +1 -1
  241. package/dist/store/gi/callback.js +10 -6
  242. package/dist/store/gi/callback.js.map +1 -1
  243. package/dist/store/gi/class.d.ts.map +1 -1
  244. package/dist/store/gi/class.js +63 -40
  245. package/dist/store/gi/class.js.map +1 -1
  246. package/dist/store/gi/closure-invocation.d.ts +4 -0
  247. package/dist/store/gi/closure-invocation.d.ts.map +1 -0
  248. package/dist/store/gi/closure-invocation.js +22 -0
  249. package/dist/store/gi/closure-invocation.js.map +1 -0
  250. package/dist/store/gi/companion.d.ts.map +1 -1
  251. package/dist/store/gi/companion.js +6 -6
  252. package/dist/store/gi/companion.js.map +1 -1
  253. package/dist/store/gi/constant.d.ts.map +1 -1
  254. package/dist/store/gi/constant.js +12 -3
  255. package/dist/store/gi/constant.js.map +1 -1
  256. package/dist/store/gi/constructor-props.d.ts.map +1 -1
  257. package/dist/store/gi/constructor-props.js +18 -20
  258. package/dist/store/gi/constructor-props.js.map +1 -1
  259. package/dist/store/gi/doc-spec.d.ts +14 -0
  260. package/dist/store/gi/doc-spec.d.ts.map +1 -0
  261. package/dist/store/gi/doc-spec.js +23 -0
  262. package/dist/store/gi/doc-spec.js.map +1 -0
  263. package/dist/store/gi/enum.d.ts.map +1 -1
  264. package/dist/store/gi/enum.js +52 -19
  265. package/dist/store/gi/enum.js.map +1 -1
  266. package/dist/store/gi/function.d.ts +1 -3
  267. package/dist/store/gi/function.d.ts.map +1 -1
  268. package/dist/store/gi/function.js +50 -29
  269. package/dist/store/gi/function.js.map +1 -1
  270. package/dist/store/gi/gtype-binding.d.ts.map +1 -1
  271. package/dist/store/gi/gtype-binding.js +4 -1
  272. package/dist/store/gi/gtype-binding.js.map +1 -1
  273. package/dist/store/gi/interface.d.ts.map +1 -1
  274. package/dist/store/gi/interface.js +155 -26
  275. package/dist/store/gi/interface.js.map +1 -1
  276. package/dist/store/gi/item-comparators.d.ts.map +1 -1
  277. package/dist/store/gi/item-comparators.js +3 -5
  278. package/dist/store/gi/item-comparators.js.map +1 -1
  279. package/dist/store/gi/method.d.ts +11 -2
  280. package/dist/store/gi/method.d.ts.map +1 -1
  281. package/dist/store/gi/method.js +80 -45
  282. package/dist/store/gi/method.js.map +1 -1
  283. package/dist/store/gi/param-marshal.d.ts +6 -2
  284. package/dist/store/gi/param-marshal.d.ts.map +1 -1
  285. package/dist/store/gi/param-marshal.js +54 -5
  286. package/dist/store/gi/param-marshal.js.map +1 -1
  287. package/dist/store/gi/pipeline.d.ts.map +1 -1
  288. package/dist/store/gi/pipeline.js +23 -11
  289. package/dist/store/gi/pipeline.js.map +1 -1
  290. package/dist/store/gi/properties.d.ts +2 -1
  291. package/dist/store/gi/properties.d.ts.map +1 -1
  292. package/dist/store/gi/properties.js +7 -4
  293. package/dist/store/gi/properties.js.map +1 -1
  294. package/dist/store/gi/property-accessor.d.ts +12 -5
  295. package/dist/store/gi/property-accessor.d.ts.map +1 -1
  296. package/dist/store/gi/property-accessor.js +98 -46
  297. package/dist/store/gi/property-accessor.js.map +1 -1
  298. package/dist/store/gi/record-constructor.d.ts +8 -1
  299. package/dist/store/gi/record-constructor.d.ts.map +1 -1
  300. package/dist/store/gi/record-constructor.js +34 -11
  301. package/dist/store/gi/record-constructor.js.map +1 -1
  302. package/dist/store/gi/record-field-accessor.d.ts +3 -1
  303. package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
  304. package/dist/store/gi/record-field-accessor.js +8 -3
  305. package/dist/store/gi/record-field-accessor.js.map +1 -1
  306. package/dist/store/gi/record-layout.d.ts +6 -1
  307. package/dist/store/gi/record-layout.d.ts.map +1 -1
  308. package/dist/store/gi/record-layout.js +9 -2
  309. package/dist/store/gi/record-layout.js.map +1 -1
  310. package/dist/store/gi/record.d.ts.map +1 -1
  311. package/dist/store/gi/record.js +21 -9
  312. package/dist/store/gi/record.js.map +1 -1
  313. package/dist/store/gi/registration.d.ts +1 -1
  314. package/dist/store/gi/registration.js +4 -4
  315. package/dist/store/gi/registration.js.map +1 -1
  316. package/dist/store/gi/runtime-override.d.ts +2 -1
  317. package/dist/store/gi/runtime-override.d.ts.map +1 -1
  318. package/dist/store/gi/runtime-override.js +8 -5
  319. package/dist/store/gi/runtime-override.js.map +1 -1
  320. package/dist/store/gi/signal.d.ts +2 -1
  321. package/dist/store/gi/signal.d.ts.map +1 -1
  322. package/dist/store/gi/signal.js +42 -37
  323. package/dist/store/gi/signal.js.map +1 -1
  324. package/dist/store/gi/value-marshalable.d.ts +1 -2
  325. package/dist/store/gi/value-marshalable.d.ts.map +1 -1
  326. package/dist/store/gi/value-marshalable.js +3 -2
  327. package/dist/store/gi/value-marshalable.js.map +1 -1
  328. package/dist/store/gi/vtable.d.ts +19 -1
  329. package/dist/store/gi/vtable.d.ts.map +1 -1
  330. package/dist/store/gi/vtable.js +257 -51
  331. package/dist/store/gi/vtable.js.map +1 -1
  332. package/dist/store/gi-store.d.ts +1 -0
  333. package/dist/store/gi-store.d.ts.map +1 -1
  334. package/dist/store/gi-store.js +15 -20
  335. package/dist/store/gi-store.js.map +1 -1
  336. package/dist/store/jsx/element-components.d.ts +1 -1
  337. package/dist/store/jsx/element-components.d.ts.map +1 -1
  338. package/dist/store/jsx/element-components.js +6 -4
  339. package/dist/store/jsx/element-components.js.map +1 -1
  340. package/dist/store/jsx/element-prop-imports.d.ts +1 -3
  341. package/dist/store/jsx/element-prop-imports.d.ts.map +1 -1
  342. package/dist/store/jsx/element-prop-imports.js.map +1 -1
  343. package/dist/store/jsx/element-prop-types.d.ts +3 -0
  344. package/dist/store/jsx/element-prop-types.d.ts.map +1 -1
  345. package/dist/store/jsx/element-prop-types.js +7 -1
  346. package/dist/store/jsx/element-prop-types.js.map +1 -1
  347. package/dist/store/jsx/generated-elements.d.ts +2 -1
  348. package/dist/store/jsx/generated-elements.d.ts.map +1 -1
  349. package/dist/store/jsx/generated-elements.js +13 -7
  350. package/dist/store/jsx/generated-elements.js.map +1 -1
  351. package/dist/store/jsx/intrinsic-elements.d.ts +4 -0
  352. package/dist/store/jsx/intrinsic-elements.d.ts.map +1 -1
  353. package/dist/store/jsx/intrinsic-elements.js.map +1 -1
  354. package/dist/store/jsx/jsx.d.ts.map +1 -1
  355. package/dist/store/jsx/jsx.js +10 -9
  356. package/dist/store/jsx/jsx.js.map +1 -1
  357. package/dist/store/jsx/metadata.d.ts.map +1 -1
  358. package/dist/store/jsx/metadata.js +5 -3
  359. package/dist/store/jsx/metadata.js.map +1 -1
  360. package/dist/store/jsx/pipeline.d.ts +1 -1
  361. package/dist/store/jsx/pipeline.d.ts.map +1 -1
  362. package/dist/store/jsx/pipeline.js.map +1 -1
  363. package/dist/store/jsx/props.d.ts +1 -7
  364. package/dist/store/jsx/props.d.ts.map +1 -1
  365. package/dist/store/jsx/props.js +14 -6
  366. package/dist/store/jsx/props.js.map +1 -1
  367. package/dist/store/jsx-store.d.ts.map +1 -1
  368. package/dist/store/jsx-store.js +3 -3
  369. package/dist/store/jsx-store.js.map +1 -1
  370. package/dist/store/resolve-store.d.ts +14 -3
  371. package/dist/store/resolve-store.d.ts.map +1 -1
  372. package/dist/store/resolve-store.js +98 -15
  373. package/dist/store/resolve-store.js.map +1 -1
  374. package/dist/store/store-fs.d.ts +9 -6
  375. package/dist/store/store-fs.d.ts.map +1 -1
  376. package/dist/store/store-fs.js +59 -25
  377. package/dist/store/store-fs.js.map +1 -1
  378. package/dist/store/store-links.d.ts +3 -0
  379. package/dist/store/store-links.d.ts.map +1 -0
  380. package/dist/store/store-links.js +39 -0
  381. package/dist/store/store-links.js.map +1 -0
  382. package/dist/writer/comparison-context.d.ts +4 -0
  383. package/dist/writer/comparison-context.d.ts.map +1 -0
  384. package/dist/writer/comparison-context.js +13 -0
  385. package/dist/writer/comparison-context.js.map +1 -0
  386. package/dist/writer/context.d.ts +3 -2
  387. package/dist/writer/context.d.ts.map +1 -1
  388. package/dist/writer/context.js +11 -3
  389. package/dist/writer/context.js.map +1 -1
  390. package/dist/writer/doc-tags.d.ts +21 -0
  391. package/dist/writer/doc-tags.d.ts.map +1 -0
  392. package/dist/writer/doc-tags.js +38 -0
  393. package/dist/writer/doc-tags.js.map +1 -0
  394. package/dist/writer/doc.d.ts +3 -1
  395. package/dist/writer/doc.d.ts.map +1 -1
  396. package/dist/writer/doc.js +19 -6
  397. package/dist/writer/doc.js.map +1 -1
  398. package/dist/writer/gtk-doc.d.ts +1 -1
  399. package/dist/writer/gtk-doc.d.ts.map +1 -1
  400. package/dist/writer/gtk-doc.js +64 -15
  401. package/dist/writer/gtk-doc.js.map +1 -1
  402. package/dist/writer/module.d.ts +17 -3
  403. package/dist/writer/module.d.ts.map +1 -1
  404. package/dist/writer/module.js +72 -3
  405. package/dist/writer/module.js.map +1 -1
  406. package/dist/xml.d.ts +7 -1
  407. package/dist/xml.d.ts.map +1 -1
  408. package/dist/xml.js +43 -1
  409. package/dist/xml.js.map +1 -1
  410. package/overrides/gdk/rgba.ts.ejs +26 -0
  411. package/overrides/gobject/object.ts.ejs +48 -3
  412. package/overrides/gobject/value.ts.ejs +7 -0
  413. package/overrides/graphene/structs.ts.ejs +55 -0
  414. package/package.json +15 -4
  415. package/src/analysis/descriptor-render.ts +130 -66
  416. package/src/analysis/descriptor.ts +35 -11
  417. package/src/analysis/inheritance.ts +166 -75
  418. package/src/analysis/interface-conflicts.ts +237 -0
  419. package/src/analysis/nul-terminated-bytes.ts +31 -0
  420. package/src/analysis/param-capability.ts +169 -0
  421. package/src/analysis/param-structure.ts +85 -25
  422. package/src/analysis/ts-type.ts +13 -17
  423. package/src/analysis/type-key.ts +14 -0
  424. package/src/analysis/type-shape.ts +24 -0
  425. package/src/compile.ts +110 -26
  426. package/src/docs/api-reference.ts +46 -34
  427. package/src/docs/element-page.ts +58 -49
  428. package/src/docs/handwritten-props.ts +230 -0
  429. package/src/docs/pipeline.ts +131 -21
  430. package/src/docs/render.ts +153 -35
  431. package/src/docs/symbol-page.ts +230 -80
  432. package/src/fingerprint.ts +86 -32
  433. package/src/gi.ts +1 -0
  434. package/src/gir/ancestry.ts +31 -1
  435. package/src/gir/annotations.ts +37 -0
  436. package/src/gir/callback.ts +2 -0
  437. package/src/gir/class.ts +42 -4
  438. package/src/gir/cursor-overrides.ts +12 -0
  439. package/src/gir/emittable.ts +8 -0
  440. package/src/gir/enum.ts +30 -10
  441. package/src/gir/field.ts +24 -9
  442. package/src/gir/function.ts +60 -9
  443. package/src/gir/libraries.ts +11 -3
  444. package/src/gir/library.ts +52 -3
  445. package/src/gir/namespace.ts +49 -7
  446. package/src/gir/parameter.ts +62 -3
  447. package/src/gir/parse.ts +13 -9
  448. package/src/gir/primitives.ts +1 -0
  449. package/src/gir/property.ts +18 -3
  450. package/src/gir/record.ts +24 -2
  451. package/src/gir/size.ts +8 -3
  452. package/src/gir/type-id.ts +49 -3
  453. package/src/gir/type-ref.ts +1 -0
  454. package/src/gir/type.ts +50 -6
  455. package/src/guards.ts +23 -0
  456. package/src/internal.ts +2 -0
  457. package/src/json.ts +11 -0
  458. package/src/khronos/args.ts +36 -13
  459. package/src/khronos/doc-context.ts +62 -0
  460. package/src/khronos/extensions.ts +85 -0
  461. package/src/khronos/jsdoc.ts +152 -56
  462. package/src/khronos/model.ts +314 -69
  463. package/src/khronos/modules.ts +150 -40
  464. package/src/khronos/notes.ts +74 -0
  465. package/src/khronos/param-pair.ts +1 -1
  466. package/src/khronos/parse.ts +3 -4
  467. package/src/khronos/pipeline.ts +95 -42
  468. package/src/khronos/plan.ts +4 -6
  469. package/src/khronos/render.ts +62 -50
  470. package/src/khronos/select.ts +91 -50
  471. package/src/react/element-config.ts +2 -2
  472. package/src/runner.ts +20 -9
  473. package/src/staging.ts +69 -0
  474. package/src/store/compile-store.ts +7 -5
  475. package/src/store/gi/callable-doc.ts +102 -0
  476. package/src/store/gi/callables.ts +58 -44
  477. package/src/store/gi/callback.ts +10 -9
  478. package/src/store/gi/class.ts +83 -49
  479. package/src/store/gi/closure-invocation.ts +26 -0
  480. package/src/store/gi/companion.ts +7 -6
  481. package/src/store/gi/constant.ts +14 -5
  482. package/src/store/gi/constructor-props.ts +19 -23
  483. package/src/store/gi/doc-spec.ts +38 -0
  484. package/src/store/gi/enum.ts +75 -26
  485. package/src/store/gi/function.ts +72 -44
  486. package/src/store/gi/gtype-binding.ts +7 -2
  487. package/src/store/gi/interface.ts +244 -37
  488. package/src/store/gi/item-comparators.ts +3 -5
  489. package/src/store/gi/method.ts +124 -69
  490. package/src/store/gi/param-marshal.ts +91 -6
  491. package/src/store/gi/pipeline.ts +28 -13
  492. package/src/store/gi/properties.ts +10 -5
  493. package/src/store/gi/property-accessor.ts +163 -75
  494. package/src/store/gi/record-constructor.ts +56 -19
  495. package/src/store/gi/record-field-accessor.ts +13 -4
  496. package/src/store/gi/record-layout.ts +12 -2
  497. package/src/store/gi/record.ts +24 -10
  498. package/src/store/gi/registration.ts +5 -5
  499. package/src/store/gi/runtime-override.ts +13 -6
  500. package/src/store/gi/signal.ts +54 -57
  501. package/src/store/gi/value-marshalable.ts +4 -2
  502. package/src/store/gi/vtable.ts +439 -61
  503. package/src/store/gi-store.ts +26 -31
  504. package/src/store/jsx/element-components.ts +8 -5
  505. package/src/store/jsx/element-prop-imports.ts +1 -3
  506. package/src/store/jsx/element-prop-types.ts +10 -1
  507. package/src/store/jsx/generated-elements.ts +17 -8
  508. package/src/store/jsx/intrinsic-elements.ts +4 -0
  509. package/src/store/jsx/jsx.ts +11 -9
  510. package/src/store/jsx/metadata.ts +6 -3
  511. package/src/store/jsx/pipeline.ts +1 -1
  512. package/src/store/jsx/props.ts +20 -7
  513. package/src/store/jsx-store.ts +3 -3
  514. package/src/store/resolve-store.ts +133 -18
  515. package/src/store/store-fs.ts +87 -34
  516. package/src/store/store-links.ts +49 -0
  517. package/src/writer/comparison-context.ts +18 -0
  518. package/src/writer/context.ts +14 -4
  519. package/src/writer/doc-tags.ts +70 -0
  520. package/src/writer/doc.ts +29 -6
  521. package/src/writer/gtk-doc.ts +82 -15
  522. package/src/writer/module.ts +114 -4
  523. package/src/xml.ts +61 -1
@@ -1,52 +1,65 @@
1
- const isBlockApplicable = (block, selection) => block.profile === undefined || block.profile === selection.profile;
2
- const addMissing = (target, names, value) => {
3
- for (const name of names) {
4
- if (!target.has(name)) {
5
- target.set(name, value);
6
- }
1
+ import { sortStringsBy } from "@gtkx/utils";
2
+ const isBlockApplicable = (block, selection) => (block.profile === undefined || block.profile === selection.profile) &&
3
+ (block.api === undefined || block.api === selection.api);
4
+ const targetFor = (state, kind) => kind === "command" ? state.commands : state.enums;
5
+ const commentEntry = (comment) => comment === undefined ? {} : { comment };
6
+ const requireMember = (state, name, context) => {
7
+ const target = targetFor(state, context.kind);
8
+ if (target.has(name)) {
9
+ return;
7
10
  }
11
+ const { block, feature } = context;
12
+ target.set(name, {
13
+ feature: feature.name,
14
+ ...(block.comment !== undefined && { requireComment: block.comment }),
15
+ removals: [...(state.history.get(name) ?? [])],
16
+ });
8
17
  };
9
- const applyRequires = (feature, selection, commands, enums) => {
10
- for (const block of feature.requires) {
11
- if (!isBlockApplicable(block, selection)) {
12
- continue;
13
- }
14
- addMissing(commands, block.commands, feature.name);
15
- addMissing(enums, block.enums, feature.name);
16
- }
18
+ const removeMember = (state, name, context) => {
19
+ const { block, feature, kind } = context;
20
+ const removal = { feature: feature.name, ...commentEntry(block.comment) };
21
+ targetFor(state, kind).delete(name);
22
+ state.history.set(name, [...(state.history.get(name) ?? []), removal]);
23
+ state.removed.push({ name, kind, ...removal });
17
24
  };
18
- const removeBlock = (block, commands, enums) => {
19
- for (const name of block.commands) {
20
- commands.delete(name);
21
- }
22
- for (const name of block.enums) {
23
- enums.delete(name);
25
+ const applyMembers = (state, names, context) => {
26
+ const apply = context.block.kind === "require" ? requireMember : removeMember;
27
+ for (const name of names) {
28
+ apply(state, name, context);
24
29
  }
25
30
  };
26
- const applyRemoves = (feature, selection, commands, enums) => {
27
- for (const block of feature.removes) {
28
- if (!isBlockApplicable(block, selection)) {
29
- continue;
31
+ const applyBlock = (state, feature, block) => {
32
+ applyMembers(state, block.commands, { feature, block, kind: "command" });
33
+ applyMembers(state, block.enums, { feature, block, kind: "enum" });
34
+ };
35
+ const applyFeature = (state, feature, selection) => {
36
+ for (const block of feature.blocks) {
37
+ if (isBlockApplicable(block, selection)) {
38
+ applyBlock(state, feature, block);
30
39
  }
31
- removeBlock(block, commands, enums);
32
40
  }
33
41
  };
34
42
  const selectSubset = (registry, selection) => {
35
43
  const features = registry.features
36
44
  .filter((feature) => feature.api === selection.api && feature.number <= selection.version)
37
45
  .toSorted((a, b) => a.number - b.number);
38
- const commands = new Map();
39
- const enums = new Map();
40
- for (const feature of features) {
41
- applyRequires(feature, selection, commands, enums);
42
- }
46
+ const state = {
47
+ commands: new Map(),
48
+ enums: new Map(),
49
+ removed: [],
50
+ history: new Map(),
51
+ };
43
52
  for (const feature of features) {
44
- applyRemoves(feature, selection, commands, enums);
53
+ applyFeature(state, feature, selection);
45
54
  }
46
- return { commands, enums };
55
+ return {
56
+ commands: state.commands,
57
+ enums: state.enums,
58
+ removed: sortStringsBy(state.removed, (entry) => entry.name),
59
+ };
47
60
  };
48
- const resolveEnum = (registry, name) => {
49
- const found = registry.enums.find((candidate) => candidate.name === name);
61
+ const resolveEnum = (registry, name, api) => {
62
+ const found = registry.enums.find((candidate) => candidate.name === name && (candidate.api === undefined || candidate.api === api));
50
63
  if (found === undefined) {
51
64
  throw new Error(`Enum token ${name} has no definition in the registry`);
52
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/khronos/select.ts"],"names":[],"mappings":"AAeA,MAAM,iBAAiB,GAAG,CAAC,KAAuB,EAAE,SAAsB,EAAW,EAAE,CACnF,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,OAAO,CAAC;AAEvE,MAAM,UAAU,GAAG,CAAC,MAA2B,EAAE,KAAe,EAAE,KAAa,EAAQ,EAAE;IACrF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACpB,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC5B,CAAC;IACL,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAClB,OAAkB,EAClB,SAAsB,E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G,KAAK,SAAS,CAAC,GAAG,IAAI,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC,OAAO,CAAC;SACzF,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IAE7C,MAAM,QAAQ,GAAwB,IAAI,GAAG,EAAE,CAAC;IAChD,MAAM,KAAK,GAAwB,IAAI,GAAG,EAAE,CAAC;IAE7C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC7B,aAAa,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC7B,YAAY,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAC/B,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,QAAoB,EAAE,IAAY,EAAU,EAAE;IAC/D,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAE1E,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,oCAAoC,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAoB,CAAC","sourcesContent":["import type { GlEnum, GlFeature, GlInterfaceBlock, GlRegistry } from \"./model.js\";\n\ntype GlProfile = \"core\";\n\ntype GlSelection = {\n api: string;\n version: number;\n profile: GlProfile;\n};\n\ntype GlSubset = {\n commands: Map<string, string>;\n enums: Map<string, string>;\n};\n\nconst isBlockApplicable = (block: GlInterfaceBlock, selection: GlSelection): boolean =>\n block.profile === undefined || block.profile === selection.profile;\n\nconst addMissing = (target: Map<string, string>, names: string[], value: string): void => {\n for (const name of names) {\n if (!target.has(name)) {\n target.set(name, value);\n }\n }\n};\n\nconst applyRequires = (\n feature: GlFeature,\n selection: GlSelection,\n commands: Map<string, string>,\n enums: Map<string, string>,\n): void => {\n for (const block of feature.requires) {\n if (!isBlockApplicable(block, selection)) {\n continue;\n }\n\n addMissing(commands, block.commands, feature.name);\n addMissing(enums, block.enums, feature.name);\n }\n};\n\nconst removeBlock = (block: GlInterfaceBlock, commands: Map<string, string>, enums: Map<string, string>): void => {\n for (const name of block.commands) {\n commands.delete(name);\n }\n\n for (const name of block.enums) {\n enums.delete(name);\n }\n};\n\nconst applyRemoves = (\n feature: GlFeature,\n selection: GlSelection,\n commands: Map<string, string>,\n enums: Map<string, string>,\n): void => {\n for (const block of feature.removes) {\n if (!isBlockApplicable(block, selection)) {\n continue;\n }\n\n removeBlock(block, commands, enums);\n }\n};\n\nconst selectSubset = (registry: GlRegistry, selection: GlSelection): GlSubset => {\n const features = registry.features\n .filter((feature) => feature.api === selection.api && feature.number <= selection.version)\n .toSorted((a, b) => a.number - b.number);\n\n const commands: Map<string, string> = new Map();\n const enums: Map<string, string> = new Map();\n\n for (const feature of features) {\n applyRequires(feature, selection, commands, enums);\n }\n\n for (const feature of features) {\n applyRemoves(feature, selection, commands, enums);\n }\n\n return { commands, enums };\n};\n\nconst resolveEnum = (registry: GlRegistry, name: string): GlEnum => {\n const found = registry.enums.find((candidate) => candidate.name === name);\n\n if (found === undefined) {\n throw new Error(`Enum token ${name} has no definition in the registry`);\n }\n\n return found;\n};\n\nexport { selectSubset, resolveEnum, type GlSelection };\n"]}
1
+ {"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/khronos/select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA+C5C,MAAM,iBAAiB,GAAG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CAAC,QAAoB,EAAE,IAAY,EAAE,GAAW,EAAU,EAAE;IAC5E,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAC7B,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,KAAK,SAAS,IAAI,SAAS,CAAC,GAAG,KAAK,GAAG,CAAC,CACnG,CAAC;IAEF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,oCAAoC,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,WAAW,EAA4E,CAAC","sourcesContent":["import { sortStringsBy } from \"@gtkx/utils\";\nimport type { GlEnum, GlFeature, GlInterfaceBlock, GlRegistry } from \"./model.js\";\n\ntype GlProfile = \"core\";\n\ntype GlSelection = {\n api: string;\n version: number;\n profile: GlProfile;\n};\n\ntype GlSymbolKind = \"command\" | \"enum\";\n\ntype GlRemoval = {\n feature: string;\n comment?: string;\n};\n\ntype GlSymbolProvenance = {\n feature: string;\n requireComment?: string;\n removals: GlRemoval[];\n};\n\ntype GlRemovedSymbol = {\n name: string;\n kind: GlSymbolKind;\n feature: string;\n comment?: string;\n};\n\ntype GlSubset = {\n commands: Map<string, GlSymbolProvenance>;\n enums: Map<string, GlSymbolProvenance>;\n removed: GlRemovedSymbol[];\n};\n\ntype SelectionState = GlSubset & {\n history: Map<string, GlRemoval[]>;\n};\n\ntype MemberContext = {\n feature: GlFeature;\n block: GlInterfaceBlock;\n kind: GlSymbolKind;\n};\n\nconst isBlockApplicable = (block: GlInterfaceBlock, selection: GlSelection): boolean =>\n (block.profile === undefined || block.profile === selection.profile) &&\n (block.api === undefined || block.api === selection.api);\n\nconst targetFor = (state: SelectionState, kind: GlSymbolKind): Map<string, GlSymbolProvenance> =>\n kind === \"command\" ? state.commands : state.enums;\n\nconst commentEntry = (comment: string | undefined): { comment?: string } =>\n comment === undefined ? {} : { comment };\n\nconst requireMember = (state: SelectionState, name: string, context: MemberContext): void => {\n const target = targetFor(state, context.kind);\n\n if (target.has(name)) {\n return;\n }\n\n const { block, feature } = context;\n\n target.set(name, {\n feature: feature.name,\n ...(block.comment !== undefined && { requireComment: block.comment }),\n removals: [...(state.history.get(name) ?? [])],\n });\n};\n\nconst removeMember = (state: SelectionState, name: string, context: MemberContext): void => {\n const { block, feature, kind } = context;\n const removal: GlRemoval = { feature: feature.name, ...commentEntry(block.comment) };\n targetFor(state, kind).delete(name);\n state.history.set(name, [...(state.history.get(name) ?? []), removal]);\n state.removed.push({ name, kind, ...removal });\n};\n\nconst applyMembers = (state: SelectionState, names: string[], context: MemberContext): void => {\n const apply = context.block.kind === \"require\" ? requireMember : removeMember;\n\n for (const name of names) {\n apply(state, name, context);\n }\n};\n\nconst applyBlock = (state: SelectionState, feature: GlFeature, block: GlInterfaceBlock): void => {\n applyMembers(state, block.commands, { feature, block, kind: \"command\" });\n applyMembers(state, block.enums, { feature, block, kind: \"enum\" });\n};\n\nconst applyFeature = (state: SelectionState, feature: GlFeature, selection: GlSelection): void => {\n for (const block of feature.blocks) {\n if (isBlockApplicable(block, selection)) {\n applyBlock(state, feature, block);\n }\n }\n};\n\nconst selectSubset = (registry: GlRegistry, selection: GlSelection): GlSubset => {\n const features = registry.features\n .filter((feature) => feature.api === selection.api && feature.number <= selection.version)\n .toSorted((a, b) => a.number - b.number);\n\n const state: SelectionState = {\n commands: new Map(),\n enums: new Map(),\n removed: [],\n history: new Map(),\n };\n\n for (const feature of features) {\n applyFeature(state, feature, selection);\n }\n\n return {\n commands: state.commands,\n enums: state.enums,\n removed: sortStringsBy(state.removed, (entry) => entry.name),\n };\n};\n\nconst resolveEnum = (registry: GlRegistry, name: string, api: string): GlEnum => {\n const found = registry.enums.find(\n (candidate) => candidate.name === name && (candidate.api === undefined || candidate.api === api),\n );\n\n if (found === undefined) {\n throw new Error(`Enum token ${name} has no definition in the registry`);\n }\n\n return found;\n};\n\nexport { selectSubset, resolveEnum, type GlRemoval, type GlSelection, type GlSubset, type GlSymbolProvenance };\n"]}
@@ -1,4 +1,4 @@
1
- import type { ModuleExport } from "@gtkx/react/internal";
1
+ import type { ModuleExport } from "@gtkx/react/config";
2
2
  import type { OmittedProps } from "../store/jsx/omitted-props.js";
3
3
  /** The framework's built-in element config, split into the maps codegen consumes. */
4
4
  type BuiltinElements = {
@@ -21,6 +21,6 @@ type BuiltinElements = {
21
21
  * @param giStoreDir The gi store directory, whose subdirectories name the generated namespaces.
22
22
  */
23
23
  declare const readBuiltinElements: (reactSubexports: string[], giStoreDir: string) => Promise<BuiltinElements>;
24
- export type { ModuleExport } from "@gtkx/react/internal";
24
+ export type { ModuleExport } from "@gtkx/react/config";
25
25
  export { readBuiltinElements, type BuiltinElements };
26
26
  //# sourceMappingURL=element-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"element-config.d.ts","sourceRoot":"","sources":["../../src/react/element-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAIlE,qFAAqF;AACrF,KAAK,eAAe,GAAG;IACnB,0GAA0G;IAC1G,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACzC,+GAA+G;IAC/G,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,yFAAyF;IACzF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACpC,8EAA8E;IAC9E,YAAY,EAAE,YAAY,CAAC;CAC9B,CAAC;AA6DF;;;;;;;;GAQG;AACH,QAAA,MAAM,mBAAmB,GAAU,iBAAiB,MAAM,EAAE,EAAE,YAAY,MAAM,KAAG,OAAO,CAAC,eAAe,CAUzG,CAAC;AAEF,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"element-config.d.ts","sourceRoot":"","sources":["../../src/react/element-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAIlE,qFAAqF;AACrF,KAAK,eAAe,GAAG;IACnB,0GAA0G;IAC1G,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACzC,+GAA+G;IAC/G,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,yFAAyF;IACzF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACpC,8EAA8E;IAC9E,YAAY,EAAE,YAAY,CAAC;CAC9B,CAAC;AA6DF;;;;;;;;GAQG;AACH,QAAA,MAAM,mBAAmB,GAAU,iBAAiB,MAAM,EAAE,EAAE,YAAY,MAAM,KAAG,OAAO,CAAC,eAAe,CAUzG,CAAC;AAEF,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"element-config.js","sourceRoot":"","sources":["../../src/react/element-config.ts"],"names":[],"mappings":";;;;;;;;AACA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAiBtC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AACnC,MAAM,aAAa,GAAG,IAAI,iBAAiB,EAAE,CAAC;AAE9C,MAAM,oBAAoB,GAAG,CAAC,UAAkB,EAAe,EAAE;IAC7D,MAAM,IAAI,GAAgB,IAAI,GAAG,EAAE,CAAC;IACpC,MAAM,OAAO,GAAG,WAAW,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CA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cesContent":["import type { ModuleExport } from \"@gtkx/react/internal\";\nimport { readdirSync } from \"node:fs\";\nimport type { OmittedProps } from \"../store/jsx/omitted-props.js\";\n\ntype BuiltinElement = { component?: ModuleExport; isLazy?: boolean; props?: ModuleExport; omittedProps?: string[] };\n\n/** The framework's built-in element config, split into the maps codegen consumes. */\ntype BuiltinElements = {\n /** Component wrappers keyed by GLib type name; an element without one inherits its nearest ancestor's. */\n components: Record<string, ModuleExport>;\n /** GLib type names with no GObject of their own, exported as elements that drop their construct-only props. */\n lazyElements: string[];\n /** Base props interfaces the generated element props extend, keyed by GLib type name. */\n props: Record<string, ModuleExport>;\n /** Props left out of the generated element props, keyed by GLib type name. */\n omittedProps: OmittedProps;\n};\n\nconst CONFIG_ENTRYPOINT = \"config\";\nconst CONFIG_SUFFIX = `/${CONFIG_ENTRYPOINT}`;\n\nconst presentNamespaceDirs = (giStoreDir: string): Set<string> => {\n const dirs: Set<string> = new Set();\n const entries = readdirSync(giStoreDir, { withFileTypes: true });\n\n for (const entry of entries) {\n if (entry.isDirectory()) {\n dirs.add(entry.name);\n }\n }\n\n return dirs;\n};\n\nconst configEntrypoints = (reactSubexports: string[], present: Set<string>): string[] =>\n reactSubexports.filter((sub) => {\n if (sub === CONFIG_ENTRYPOINT) {\n return true;\n }\n\n return sub.endsWith(CONFIG_SUFFIX) && present.has(sub.slice(0, sub.length - CONFIG_SUFFIX.length));\n });\n\nconst importBuiltinElements = async (entrypoint: string): Promise<Record<string, BuiltinElement>> => {\n const specifier = `@gtkx/react/${entrypoint}`;\n\n const imported = (await import(/* @vite-ignore */ specifier)) as {\n BUILTIN_ELEMENTS?: Record<string, BuiltinElement>;\n };\n\n return imported.BUILTIN_ELEMENTS ?? {};\n};\n\nconst applyBuiltinElement = (target: BuiltinElements, type: string, config: BuiltinElement): void => {\n if (config.component !== undefined) {\n target.components[type] = config.component;\n }\n\n if (config.props !== undefined) {\n target.props[type] = config.props;\n }\n\n if (config.omittedProps !== undefined) {\n target.omittedProps[type] = [...(target.omittedProps[type] ?? []), ...config.omittedProps];\n }\n\n if (config.isLazy === true) {\n target.lazyElements.push(type);\n }\n};\n\nconst collectBuiltinElements = (target: BuiltinElements, elements: Record<string, BuiltinElement>): void => {\n for (const [type, config] of Object.entries(elements)) {\n applyBuiltinElement(target, type, config);\n }\n};\n\n/**\n * Reads the framework's built-in element config by importing the `config` entrypoints of the installed\n * `@gtkx/react`, skipping the per-namespace ones whose namespace the gi store does not carry. Those\n * entrypoints are reconciler-free, so importing them resolves `@gtkx/gi` but never `virtual:gtkx-config`,\n * which means this must run only after the gi store has been written and linked.\n *\n * @param reactSubexports Subexport names of the installed `@gtkx/react`, as `resolveStore` reports them.\n * @param giStoreDir The gi store directory, whose subdirectories name the generated namespaces.\n */\nconst readBuiltinElements = async (reactSubexports: string[], giStoreDir: string): Promise<BuiltinElements> => {\n const present = presentNamespaceDirs(giStoreDir);\n const entrypoints = configEntrypoints(reactSubexports, present);\n const result: BuiltinElements = { components: {}, lazyElements: [], props: {}, omittedProps: {} };\n\n for (const entrypoint of entrypoints) {\n collectBuiltinElements(result, await importBuiltinElements(entrypoint));\n }\n\n return result;\n};\n\nexport type { ModuleExport } from \"@gtkx/react/internal\";\nexport { readBuiltinElements, type BuiltinElements };\n"]}
1
+ {"version":3,"file":"element-config.js","sourceRoot":"","sources":["../../src/react/element-config.ts"],"names":[],"mappings":";;;;;;;;AACA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAiBtC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AACnC,MAAM,aAAa,GAAG,IAAI,iBAAiB,EAAE,CAAC;AAE9C,MAAM,oBAAoB,GAAG,CAAC,UAAkB,EAAe,EAAE;IAC7D,MAAM,IAAI,GAAgB,IAAI,GAAG,EAAE,CAAC;IACpC,MAAM,OAAO,GAAG,WAAW,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAEjE,KAAK,MAAM,KAAK,IAAI,OA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dirSync } from \"node:fs\";\nimport type { OmittedProps } from \"../store/jsx/omitted-props.js\";\n\ntype BuiltinElement = { component?: ModuleExport; isLazy?: boolean; props?: ModuleExport; omittedProps?: string[] };\n\n/** The framework's built-in element config, split into the maps codegen consumes. */\ntype BuiltinElements = {\n /** Component wrappers keyed by GLib type name; an element without one inherits its nearest ancestor's. */\n components: Record<string, ModuleExport>;\n /** GLib type names with no GObject of their own, exported as elements that drop their construct-only props. */\n lazyElements: string[];\n /** Base props interfaces the generated element props extend, keyed by GLib type name. */\n props: Record<string, ModuleExport>;\n /** Props left out of the generated element props, keyed by GLib type name. */\n omittedProps: OmittedProps;\n};\n\nconst CONFIG_ENTRYPOINT = \"config\";\nconst CONFIG_SUFFIX = `/${CONFIG_ENTRYPOINT}`;\n\nconst presentNamespaceDirs = (giStoreDir: string): Set<string> => {\n const dirs: Set<string> = new Set();\n const entries = readdirSync(giStoreDir, { withFileTypes: true });\n\n for (const entry of entries) {\n if (entry.isDirectory()) {\n dirs.add(entry.name);\n }\n }\n\n return dirs;\n};\n\nconst configEntrypoints = (reactSubexports: string[], present: Set<string>): string[] =>\n reactSubexports.filter((sub) => {\n if (sub === CONFIG_ENTRYPOINT) {\n return true;\n }\n\n return sub.endsWith(CONFIG_SUFFIX) && present.has(sub.slice(0, sub.length - CONFIG_SUFFIX.length));\n });\n\nconst importBuiltinElements = async (entrypoint: string): Promise<Record<string, BuiltinElement>> => {\n const specifier = `@gtkx/react/${entrypoint}`;\n\n const imported = (await import(/* @vite-ignore */ specifier)) as {\n BUILTIN_ELEMENTS?: Record<string, BuiltinElement>;\n };\n\n return imported.BUILTIN_ELEMENTS ?? {};\n};\n\nconst applyBuiltinElement = (target: BuiltinElements, type: string, config: BuiltinElement): void => {\n if (config.component !== undefined) {\n target.components[type] = config.component;\n }\n\n if (config.props !== undefined) {\n target.props[type] = config.props;\n }\n\n if (config.omittedProps !== undefined) {\n target.omittedProps[type] = [...(target.omittedProps[type] ?? []), ...config.omittedProps];\n }\n\n if (config.isLazy === true) {\n target.lazyElements.push(type);\n }\n};\n\nconst collectBuiltinElements = (target: BuiltinElements, elements: Record<string, BuiltinElement>): void => {\n for (const [type, config] of Object.entries(elements)) {\n applyBuiltinElement(target, type, config);\n }\n};\n\n/**\n * Reads the framework's built-in element config by importing the `config` entrypoints of the installed\n * `@gtkx/react`, skipping the per-namespace ones whose namespace the gi store does not carry. Those\n * entrypoints are reconciler-free, so importing them resolves `@gtkx/gi` but never `virtual:gtkx-config`,\n * which means this must run only after the gi store has been written and linked.\n *\n * @param reactSubexports Subexport names of the installed `@gtkx/react`, as `resolveStore` reports them.\n * @param giStoreDir The gi store directory, whose subdirectories name the generated namespaces.\n */\nconst readBuiltinElements = async (reactSubexports: string[], giStoreDir: string): Promise<BuiltinElements> => {\n const present = presentNamespaceDirs(giStoreDir);\n const entrypoints = configEntrypoints(reactSubexports, present);\n const result: BuiltinElements = { components: {}, lazyElements: [], props: {}, omittedProps: {} };\n\n for (const entrypoint of entrypoints) {\n collectBuiltinElements(result, await importBuiltinElements(entrypoint));\n }\n\n return result;\n};\n\nexport type { ModuleExport } from \"@gtkx/react/config\";\nexport { readBuiltinElements, type BuiltinElements };\n"]}
package/dist/runner.d.ts CHANGED
@@ -1,13 +1,7 @@
1
+ import type { ModuleExport } from "./react/element-config.js";
1
2
  import type { OmittedProps } from "./store/jsx/omitted-props.js";
2
- import type { StoreOptions } from "./store/store-fs.js";
3
3
  import { type GlGenerationReport } from "./khronos/pipeline.js";
4
- /** A named export in a module, referenced as plain data (the module is never imported at runtime). */
5
- type ModuleExport = {
6
- /** Specifier the export is imported from. */
7
- module: string;
8
- /** Identifier the module exports it under. */
9
- export: string;
10
- };
4
+ import { type StoreOptions } from "./store/store-fs.js";
11
5
  type GlCodegenOptions = {
12
6
  registryPath: string;
13
7
  overrideExports: Set<string>;
@@ -54,6 +48,10 @@ type CodegenRunnerResult = {
54
48
  * store or the React element config changed, unless `options.isForced` is set. Pass the spread of
55
49
  * `resolveStore(projectRoot)` for everything but `libraries` and `girPath`.
56
50
  *
51
+ * Every store already on disk is linked at its `linkDir` before anything is generated, so a link an install
52
+ * pruned out of `node_modules` is restored without regenerating the store, and the gi store is reachable
53
+ * under its own specifier while the jsx store is type checked.
54
+ *
57
55
  * @param options What to generate and where to write it.
58
56
  * @returns A summary of what was regenerated and how long the run took.
59
57
  * @throws If `girPath` is empty, which would otherwise generate nothing and report success.
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAKxD,OAAO,EAAqB,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEnF,sGAAsG;AACtG,KAAK,YAAY,GAAG;IAChB,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,8CAA8C;AAC9C,KAAK,oBAAoB,GAAG;IACxB,2GAA2G;IAC3G,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,oDAAoD;IACpD,EAAE,EAAE,YAAY,CAAC;IACjB,0FAA0F;IAC1F,GAAG,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IAC/B,iGAAiG;IACjG,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,yFAAyF;IACzF,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC9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import { runGiCodegen } from "./gi.js";
6
6
  import { Library } from "./gir/library.js";
7
7
  import { generateGlModules } from "./khronos/pipeline.js";
8
+ import { sweepStagingDirs } from "./staging.js";
9
+ import { ensureStoreLink } from "./store/store-fs.js";
8
10
  /**
9
11
  * Writes and links a project's `@gtkx/gi` and `@gtkx/jsx` stores from the given GObject-Introspection
10
12
  * libraries. The gi store is rewritten only when its GIR inputs changed, and the jsx store only when the gi
11
13
  * store or the React element config changed, unless `options.isForced` is set. Pass the spread of
12
14
  * `resolveStore(projectRoot)` for everything but `libraries` and `girPath`.
13
15
  *
16
+ * Every store already on disk is linked at its `linkDir` before anything is generated, so a link an install
17
+ * pruned out of `node_modules` is restored without regenerating the store, and the gi store is reachable
18
+ * under its own specifier while the jsx store is type checked.
19
+ *
14
20
  * @param options What to generate and where to write it.
15
21
  * @returns A summary of what was regenerated and how long the run took.
16
22
  * @throws If `girPath` is empty, which would otherwise generate nothing and report success.
@@ -78,11 +84,21 @@ const emitStoresWithConfig = async (config) => {
78
84
  }
79
85
  return emitJsxStore({ options, jsx, gi, loadLibrary, isGiRegenerated, namespaces });
80
86
  };
87
+ const prepareStores = (stores) => {
88
+ for (const store of stores) {
89
+ if (store === undefined) {
90
+ continue;
91
+ }
92
+ sweepStagingDirs(store.storeDir);
93
+ ensureStoreLink(store);
94
+ }
95
+ };
81
96
  const emitStores = async (options) => {
82
97
  const { gi, jsx, libraries, girPath } = options;
83
98
  if (girPath.length === 0) {
84
99
  throw new Error("codegen needs at least one GIR search path; pass the result of resolveGirPath");
85
100
  }
101
+ prepareStores([gi, jsx]);
86
102
  return emitStoresWithConfig({ options, gi, jsx, libraries, girPath });
87
103
  };
88
104
  export { runCodegen, runGlCodegen };
@@ -1 +1 @@
1
- {"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MA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mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { OmittedProps } from \"./store/jsx/omitted-props.js\";\nimport type { StoreOptions } from \"./store/store-fs.js\";\nimport { checkModules } from \"./compile.js\";\nimport { isGiStoreFresh } from \"./fingerprint.js\";\nimport { runGiCodegen } from \"./gi.js\";\nimport { Library } from \"./gir/library.js\";\nimport { generateGlModules, type GlGenerationReport } from \"./khronos/pipeline.js\";\n\n/** A named export in a module, referenced as plain data (the module is never imported at runtime). */\ntype ModuleExport = {\n /** Specifier the export is imported from. */\n module: string;\n /** Identifier the module exports it under. */\n export: string;\n};\n\ntype GlCodegenOptions = {\n registryPath: string;\n overrideExports: Set<string>;\n outputDir: string;\n resolveFrom: string;\n};\n\n/** What to generate and where to write it. */\ntype CodegenRunnerOptions = {\n /** GIR library identifiers such as `\"Gtk-4.0\"`; a `\"*\"` selection must be expanded before it gets here. */\n libraries: string[];\n /** Directories to search for `.gir` files. */\n girPath: string[];\n /** Where to write and link the `@gtkx/gi` store. */\n gi: StoreOptions;\n /** Where to write and link the `@gtkx/jsx` store; omit to generate the gi store alone. */\n jsx?: StoreOptions | undefined;\n /** Subexport names of the installed `@gtkx/react`, whose element config shapes the jsx store. */\n reactSubexports?: string[];\n /** Component wrappers the project layers over the built-ins, keyed by GLib type name. */\n userComponents?: Record<string, ModuleExport>;\n /** GLib type names whose GObject their parent container creates, added to the framework's own. */\n userLazyElements?: string[];\n /** Base props interfaces the project's elements extend, keyed by GLib type name. */\n userProps?: Record<string, ModuleExport>;\n /** Props the project drops from the generated element props, keyed by GLib type name. */\n userOmittedProps?: OmittedProps;\n /** Regenerates both stores even when their fingerprints are fresh. */\n isForced?: boolean;\n};\n\n/** What a `runCodegen` run produced. */\ntype CodegenRunnerResult = {\n /** Whether either store was rewritten; false means both were already fresh. */\n isRegenerated: boolean;\n /** How many namespaces the gi store was written with, zero when it was already fresh. */\n namespaces: number;\n /** How many JSX elements the jsx store binds, zero when no jsx store was requested. */\n intrinsicElements: number;\n /** Wall-clock duration of the run, in milliseconds. */\n duration: number;\n};\n\ntype StoreResult = {\n isRegenerated: boolean;\n namespaces: number;\n intrinsicElements: number;\n};\n\n/**\n * Writes and links a project's `@gtkx/gi` and `@gtkx/jsx` stores from the given GObject-Introspection\n * libraries. The gi store is rewritten only when its GIR inputs changed, and the jsx store only when the gi\n * store or the React element config changed, unless `options.isForced` is set. Pass the spread of\n * `resolveStore(projectRoot)` for everything but `libraries` and `girPath`.\n *\n * @param options What to generate and where to write it.\n * @returns A summary of what was regenerated and how long the run took.\n * @throws If `girPath` is empty, which would otherwise generate nothing and report success.\n */\nconst runCodegen = async (options: CodegenRunnerOptions): Promise<CodegenRunnerResult> => {\n const start = Date.now();\n const store = await emitStores(options);\n\n return {\n isRegenerated: store.isRegenerated,\n namespaces: store.namespaces,\n intrinsicElements: store.intrinsicElements,\n duration: Date.now() - start,\n };\n};\n\nconst runGlCodegen = (options: GlCodegenOptions): GlGenerationReport => {\n const { files, report } = generateGlModules({\n registryPath: options.registryPath,\n overrideExports: options.overrideExports,\n });\n\n checkModules({\n modules: [...files].map(([fileName, source]) => ({ fileName, source })),\n resolveFrom: options.resolveFrom,\n label: \"the generated gl modules\",\n });\n\n mkdirSync(options.outputDir, { recursive: true });\n\n for (const [fileName, source] of files) {\n writeFileSync(join(options.outputDir, fileName), source);\n }\n\n return report;\n};\n\nconst jsxUserOptions = (\n options: CodegenRunnerOptions,\n): {\n reactSubexports: string[];\n userComponents: Record<string, ModuleExport>;\n userLazyElements: string[];\n userProps: Record<string, ModuleExport>;\n userOmittedProps: OmittedProps;\n} => ({\n reactSubexports: options.reactSubexports ?? [],\n userComponents: options.userComponents ?? {},\n userLazyElements: options.userLazyElements ?? [],\n userProps: options.userProps ?? {},\n userOmittedProps: options.userOmittedProps ?? {},\n});\n\nconst emitJsxStore = async (input: {\n options: CodegenRunnerOptions;\n jsx: StoreOptions;\n gi: StoreOptions;\n loadLibrary: () => Library;\n isGiRegenerated: boolean;\n namespaces: number;\n}): Promise<StoreResult> => {\n const { options, jsx, gi, loadLibrary, isGiRegenerated, namespaces } = input;\n const { runJsxCodegen } = await import(\"./jsx.js\");\n\n const jsxResult = await runJsxCodegen({\n getLibrary: loadLibrary,\n jsx,\n giStoreDir: gi.storeDir,\n ...jsxUserOptions(options),\n isGiRegenerated,\n isForced: options.isForced === true,\n });\n\n return {\n isRegenerated: isGiRegenerated || jsxResult.isRegenerated,\n namespaces,\n intrinsicElements: jsxResult.intrinsicElementCount,\n };\n};\n\nconst emitStoresWithConfig = async (config: {\n options: CodegenRunnerOptions;\n gi: StoreOptions;\n jsx: StoreOptions | undefined;\n libraries: string[];\n girPath: string[];\n}): Promise<StoreResult> => {\n const { options, gi, jsx, libraries, girPath } = config;\n let library: Library | undefined;\n const loadLibrary = (): Library => (library ??= Library.load(libraries, girPath));\n const isGiRegenerated = options.isForced === true || !isGiStoreFresh(gi.storeDir, libraries, girPath);\n\n const namespaces = isGiRegenerated\n ? runGiCodegen(loadLibrary(), { gi, libraries, girPath })\n : 0;\n\n if (jsx === undefined) {\n return { isRegenerated: isGiRegenerated, namespaces, intrinsicElements: 0 };\n }\n\n return emitJsxStore({ options, jsx, gi, loadLibrary, isGiRegenerated, namespaces });\n};\n\nconst emitStores = async (options: CodegenRunnerOptions): Promise<StoreResult> => {\n const { gi, jsx, libraries, girPath } = options;\n\n if (girPath.length === 0) {\n throw new Error(\"codegen needs at least one GIR search path; pass the result of resolveGirPath\");\n }\n\n return emitStoresWithConfig({ options, gi, jsx, libraries, girPath });\n};\n\nexport { runCodegen, runGlCodegen, type CodegenRunnerOptions, type CodegenRunnerResult };\n"]}
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,cAA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OAAO,EAAE,GAAG,OAAO,CAAC;IAEhD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;IACrG,CAAC;IAED,aAAa,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;IAEzB,OAAO,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAuD,CAAC","sourcesContent":["import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { ModuleExport } from \"./react/element-config.js\";\nimport type { OmittedProps } from \"./store/jsx/omitted-props.js\";\nimport { checkModules } from \"./compile.js\";\nimport { isGiStoreFresh } from \"./fingerprint.js\";\nimport { runGiCodegen } from \"./gi.js\";\nimport { Library } from \"./gir/library.js\";\nimport { generateGlModules, type GlGenerationReport } from \"./khronos/pipeline.js\";\nimport { sweepStagingDirs } from \"./staging.js\";\nimport { ensureStoreLink, type StoreOptions } from \"./store/store-fs.js\";\n\ntype GlCodegenOptions = {\n registryPath: string;\n overrideExports: Set<string>;\n outputDir: string;\n resolveFrom: string;\n};\n\n/** What to generate and where to write it. */\ntype CodegenRunnerOptions = {\n /** GIR library identifiers such as `\"Gtk-4.0\"`; a `\"*\"` selection must be expanded before it gets here. */\n libraries: string[];\n /** Directories to search for `.gir` files. */\n girPath: string[];\n /** Where to write and link the `@gtkx/gi` store. */\n gi: StoreOptions;\n /** Where to write and link the `@gtkx/jsx` store; omit to generate the gi store alone. */\n jsx?: StoreOptions | undefined;\n /** Subexport names of the installed `@gtkx/react`, whose element config shapes the jsx store. */\n reactSubexports?: string[];\n /** Component wrappers the project layers over the built-ins, keyed by GLib type name. */\n userComponents?: Record<string, ModuleExport>;\n /** GLib type names whose GObject their parent container creates, added to the framework's own. */\n userLazyElements?: string[];\n /** Base props interfaces the project's elements extend, keyed by GLib type name. */\n userProps?: Record<string, ModuleExport>;\n /** Props the project drops from the generated element props, keyed by GLib type name. */\n userOmittedProps?: OmittedProps;\n /** Regenerates both stores even when their fingerprints are fresh. */\n isForced?: boolean;\n};\n\n/** What a `runCodegen` run produced. */\ntype CodegenRunnerResult = {\n /** Whether either store was rewritten; false means both were already fresh. */\n isRegenerated: boolean;\n /** How many namespaces the gi store was written with, zero when it was already fresh. */\n namespaces: number;\n /** How many JSX elements the jsx store binds, zero when no jsx store was requested. */\n intrinsicElements: number;\n /** Wall-clock duration of the run, in milliseconds. */\n duration: number;\n};\n\ntype StoreResult = {\n isRegenerated: boolean;\n namespaces: number;\n intrinsicElements: number;\n};\n\n/**\n * Writes and links a project's `@gtkx/gi` and `@gtkx/jsx` stores from the given GObject-Introspection\n * libraries. The gi store is rewritten only when its GIR inputs changed, and the jsx store only when the gi\n * store or the React element config changed, unless `options.isForced` is set. Pass the spread of\n * `resolveStore(projectRoot)` for everything but `libraries` and `girPath`.\n *\n * Every store already on disk is linked at its `linkDir` before anything is generated, so a link an install\n * pruned out of `node_modules` is restored without regenerating the store, and the gi store is reachable\n * under its own specifier while the jsx store is type checked.\n *\n * @param options What to generate and where to write it.\n * @returns A summary of what was regenerated and how long the run took.\n * @throws If `girPath` is empty, which would otherwise generate nothing and report success.\n */\nconst runCodegen = async (options: CodegenRunnerOptions): Promise<CodegenRunnerResult> => {\n const start = Date.now();\n const store = await emitStores(options);\n\n return {\n isRegenerated: store.isRegenerated,\n namespaces: store.namespaces,\n intrinsicElements: store.intrinsicElements,\n duration: Date.now() - start,\n };\n};\n\nconst runGlCodegen = (options: GlCodegenOptions): GlGenerationReport => {\n const { files, report } = generateGlModules({\n registryPath: options.registryPath,\n overrideExports: options.overrideExports,\n });\n\n checkModules({\n modules: [...files].map(([fileName, source]) => ({ fileName, source })),\n resolveFrom: options.resolveFrom,\n label: \"the generated gl modules\",\n });\n\n mkdirSync(options.outputDir, { recursive: true });\n\n for (const [fileName, source] of files) {\n writeFileSync(join(options.outputDir, fileName), source);\n }\n\n return report;\n};\n\nconst jsxUserOptions = (\n options: CodegenRunnerOptions,\n): {\n reactSubexports: string[];\n userComponents: Record<string, ModuleExport>;\n userLazyElements: string[];\n userProps: Record<string, ModuleExport>;\n userOmittedProps: OmittedProps;\n} => ({\n reactSubexports: options.reactSubexports ?? [],\n userComponents: options.userComponents ?? {},\n userLazyElements: options.userLazyElements ?? [],\n userProps: options.userProps ?? {},\n userOmittedProps: options.userOmittedProps ?? {},\n});\n\nconst emitJsxStore = async (input: {\n options: CodegenRunnerOptions;\n jsx: StoreOptions;\n gi: StoreOptions;\n loadLibrary: () => Library;\n isGiRegenerated: boolean;\n namespaces: number;\n}): Promise<StoreResult> => {\n const { options, jsx, gi, loadLibrary, isGiRegenerated, namespaces } = input;\n const { runJsxCodegen } = await import(\"./jsx.js\");\n\n const jsxResult = await runJsxCodegen({\n getLibrary: loadLibrary,\n jsx,\n giStoreDir: gi.storeDir,\n ...jsxUserOptions(options),\n isGiRegenerated,\n isForced: options.isForced === true,\n });\n\n return {\n isRegenerated: isGiRegenerated || jsxResult.isRegenerated,\n namespaces,\n intrinsicElements: jsxResult.intrinsicElementCount,\n };\n};\n\nconst emitStoresWithConfig = async (config: {\n options: CodegenRunnerOptions;\n gi: StoreOptions;\n jsx: StoreOptions | undefined;\n libraries: string[];\n girPath: string[];\n}): Promise<StoreResult> => {\n const { options, gi, jsx, libraries, girPath } = config;\n let library: Library | undefined;\n const loadLibrary = (): Library => (library ??= Library.load(libraries, girPath));\n const isGiRegenerated = options.isForced === true || !isGiStoreFresh(gi.storeDir, libraries, girPath);\n\n const namespaces = isGiRegenerated\n ? runGiCodegen(loadLibrary(), { gi, libraries, girPath })\n : 0;\n\n if (jsx === undefined) {\n return { isRegenerated: isGiRegenerated, namespaces, intrinsicElements: 0 };\n }\n\n return emitJsxStore({ options, jsx, gi, loadLibrary, isGiRegenerated, namespaces });\n};\n\nconst prepareStores = (stores: (StoreOptions | undefined)[]): void => {\n for (const store of stores) {\n if (store === undefined) {\n continue;\n }\n\n sweepStagingDirs(store.storeDir);\n ensureStoreLink(store);\n }\n};\n\nconst emitStores = async (options: CodegenRunnerOptions): Promise<StoreResult> => {\n const { gi, jsx, libraries, girPath } = options;\n\n if (girPath.length === 0) {\n throw new Error(\"codegen needs at least one GIR search path; pass the result of resolveGirPath\");\n }\n\n prepareStores([gi, jsx]);\n\n return emitStoresWithConfig({ options, gi, jsx, libraries, girPath });\n};\n\nexport { runCodegen, runGlCodegen, type CodegenRunnerOptions, type CodegenRunnerResult };\n"]}
@@ -0,0 +1,5 @@
1
+ declare const sweepStrandedDirs: (parentDir: string, prefix: string) => void;
2
+ declare const sweepStagingDirs: (target: string) => void;
3
+ declare const createStagingDir: (target: string) => string;
4
+ export { createStagingDir, sweepStagingDirs, sweepStrandedDirs };
5
+ //# sourceMappingURL=staging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staging.d.ts","sourceRoot":"","sources":["../src/staging.ts"],"names":[],"mappings":"AAiDA,QAAA,MAAM,iBAAiB,GAAI,WAAW,MAAM,EAAE,QAAQ,MAAM,KAAG,IAM9D,CAAC;AAEF,QAAA,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,IAE1C,CAAC;AAEF,QAAA,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,MAK1C,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { mkdirSync, mkdtempSync, readdirSync, rmSync } from "node:fs";
2
+ import { basename, dirname, join } from "node:path";
3
+ const STAGING_SUFFIX = ".tmp-";
4
+ const OWNER_PATTERN = /^(?<pid>\d+)-/;
5
+ const errorCode = (error) => error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : undefined;
6
+ const isOwnerRunning = (pid) => {
7
+ if (!Number.isSafeInteger(pid) || pid <= 0) {
8
+ return false;
9
+ }
10
+ try {
11
+ process.kill(pid, 0);
12
+ return true;
13
+ }
14
+ catch (error) {
15
+ return errorCode(error) === "EPERM";
16
+ }
17
+ };
18
+ const isStranded = (entry, prefix) => {
19
+ if (!entry.startsWith(prefix)) {
20
+ return false;
21
+ }
22
+ const owner = OWNER_PATTERN.exec(entry.slice(prefix.length))?.groups?.pid;
23
+ return owner === undefined || !isOwnerRunning(Number(owner));
24
+ };
25
+ const readEntries = (parentDir) => {
26
+ try {
27
+ return readdirSync(parentDir);
28
+ }
29
+ catch {
30
+ return [];
31
+ }
32
+ };
33
+ const removeStrandedDir = (path) => {
34
+ try {
35
+ rmSync(path, { recursive: true, force: true });
36
+ }
37
+ catch {
38
+ return;
39
+ }
40
+ };
41
+ const sweepStrandedDirs = (parentDir, prefix) => {
42
+ for (const entry of readEntries(parentDir)) {
43
+ if (isStranded(entry, prefix)) {
44
+ removeStrandedDir(join(parentDir, entry));
45
+ }
46
+ }
47
+ };
48
+ const sweepStagingDirs = (target) => {
49
+ sweepStrandedDirs(dirname(target), `${basename(target)}${STAGING_SUFFIX}`);
50
+ };
51
+ const createStagingDir = (target) => {
52
+ mkdirSync(dirname(target), { recursive: true });
53
+ sweepStagingDirs(target);
54
+ return mkdtempSync(`${target}${STAGING_SUFFIX}${String(process.pid)}-`);
55
+ };
56
+ export { createStagingDir, sweepStagingDirs, sweepStrandedDirs };
57
+ //# sourceMappingURL=staging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staging.js","sourceRoot":"","sources":["../src/staging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,cAAc,GAAG,OAAO,CAAC;AAC/B,MAAM,aAAa,GAAG,eAAe,CAAC;AAEtC,MAAM,S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,EAAE;IAC7C,IAAI,CAAC;QACD,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;IAAC,MAAM,CAAC;QACL,OAAO;IACX,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAE,MAAc,EAAQ,EAAE;IAClE,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QACzC,IAAI,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;YAC5B,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;QAC9C,CAAC;IACL,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAQ,EAAE;IAC9C,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,cAAc,EAAE,CAAC,CAAC;AAC/E,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAU,EAAE;IAChD,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEzB,OAAO,WAAW,CAAC,GAAG,MAAM,GAAG,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC5E,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { mkdirSync, mkdtempSync, readdirSync, rmSync } from \"node:fs\";\nimport { basename, dirname, join } from \"node:path\";\n\nconst STAGING_SUFFIX = \".tmp-\";\nconst OWNER_PATTERN = /^(?<pid>\\d+)-/;\n\nconst errorCode = (error: unknown): string | undefined =>\n error instanceof Error && \"code\" in error && typeof error.code === \"string\" ? error.code : undefined;\n\nconst isOwnerRunning = (pid: number): boolean => {\n if (!Number.isSafeInteger(pid) || pid <= 0) {\n return false;\n }\n\n try {\n process.kill(pid, 0);\n\n return true;\n } catch (error) {\n return errorCode(error) === \"EPERM\";\n }\n};\n\nconst isStranded = (entry: string, prefix: string): boolean => {\n if (!entry.startsWith(prefix)) {\n return false;\n }\n\n const owner = OWNER_PATTERN.exec(entry.slice(prefix.length))?.groups?.pid;\n\n return owner === undefined || !isOwnerRunning(Number(owner));\n};\n\nconst readEntries = (parentDir: string): string[] => {\n try {\n return readdirSync(parentDir);\n } catch {\n return [];\n }\n};\n\nconst removeStrandedDir = (path: string): void => {\n try {\n rmSync(path, { recursive: true, force: true });\n } catch {\n return;\n }\n};\n\nconst sweepStrandedDirs = (parentDir: string, prefix: string): void => {\n for (const entry of readEntries(parentDir)) {\n if (isStranded(entry, prefix)) {\n removeStrandedDir(join(parentDir, entry));\n }\n }\n};\n\nconst sweepStagingDirs = (target: string): void => {\n sweepStrandedDirs(dirname(target), `${basename(target)}${STAGING_SUFFIX}`);\n};\n\nconst createStagingDir = (target: string): string => {\n mkdirSync(dirname(target), { recursive: true });\n sweepStagingDirs(target);\n\n return mkdtempSync(`${target}${STAGING_SUFFIX}${String(process.pid)}-`);\n};\n\nexport { createStagingDir, sweepStagingDirs, sweepStrandedDirs };\n"]}
@@ -6,5 +6,5 @@ type CompileStoreParams = {
6
6
  requiresEnvReference?: boolean;
7
7
  };
8
8
  declare const compileStore: (params: CompileStoreParams) => void;
9
- export { compileStore, type CompileStoreParams };
9
+ export { compileStore };
10
10
  //# sourceMappingURL=compile-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile-store.d.ts","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAElE,KAAK,kBAAkB,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAqBF,QAAA,MAAM,YAAY,GAAI,QAAQ,kBAAkB,KAAG,IAqBlD,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"compile-store.d.ts","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAEpF,KAAK,kBAAkB,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAqBF,QAAA,MAAM,YAAY,GAAI,QAAQ,kBAAkB,KAAG,IAuBlD,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -17,14 +17,16 @@ const writeEnvReference = (storeDir) => {
17
17
  };
18
18
  };
19
19
  const compileStore = (params) => {
20
- const fileNames = params.files.map((file) => file.fileName);
21
20
  const removeEnvReference = params.requiresEnvReference === true
22
21
  ? writeEnvReference(params.storeDir)
23
22
  : () => undefined;
23
+ const files = params.requiresEnvReference === true
24
+ ? [{ fileName: ENV_REFERENCE_FILE }, ...params.files]
25
+ : params.files;
24
26
  try {
25
27
  compileProject({
26
28
  projectDir: params.storeDir,
27
- fileNames: params.requiresEnvReference === true ? [ENV_REFERENCE_FILE, ...fileNames] : fileNames,
29
+ files,
28
30
  compilerOptions: EMIT_OPTIONS,
29
31
  label: `the generated ${params.packageName} store`,
30
32
  });
@@ -1 +1 @@
1
- {"version":3,"file":"compile-store.js","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EA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AK,EAAE,iBAAiB,MAAM,CAAC,WAAW,QAAQ;SACrD,CAAC,CAAC;IACP,CAAC;YAAS,CAAC;QACP,kBAAkB,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAA2B,CAAC","sourcesContent":["import { rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { compileProject, type SourceModule } from \"../compile.js\";\n\ntype CompileStoreParams = {\n storeDir: string;\n files: SourceModule[];\n packageName: string;\n requiresEnvReference?: boolean;\n};\n\nconst EMIT_OPTIONS = {\n declaration: true,\n removeComments: false,\n sourceMap: false,\n declarationMap: false,\n rootDir: \".\",\n outDir: \".\",\n};\n\nconst ENV_REFERENCE_FILE = \"__gtkx-env__.d.ts\";\n\nconst writeEnvReference = (storeDir: string): (() => void) => {\n writeFileSync(join(storeDir, ENV_REFERENCE_FILE), \"/// <reference types=\\\"@gtkx/react/env\\\" />\\n\");\n\n return () => {\n rmSync(join(storeDir, ENV_REFERENCE_FILE), { force: true });\n };\n};\n\nconst compileStore = (params: CompileStoreParams): void => {\n const fileNames = params.files.map((file) => file.fileName);\n\n const removeEnvReference = params.requiresEnvReference === true\n ? writeEnvReference(params.storeDir)\n : (): void => undefined;\n\n try {\n compileProject({\n projectDir: params.storeDir,\n fileNames: params.requiresEnvReference === true ? [ENV_REFERENCE_FILE, ...fileNames] : fileNames,\n compilerOptions: EMIT_OPTIONS,\n label: `the generated ${params.packageName} store`,\n });\n } finally {\n removeEnvReference();\n }\n\n for (const file of params.files) {\n rmSync(join(params.storeDir, file.fileName), { force: true });\n }\n};\n\nexport { compileStore, type CompileStoreParams };\n"]}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QAAQ;YAC3B,KAAK;YACL,eAAe,EAAE,YAAY;YAC7B,KAAK,EAAE,iBAAiB,MAAM,CAAC,WAAW,QAAQ;SACrD,CAAC,CAAC;IACP,CAAC;YAAS,CAAC;QACP,kBAAkB,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { compileProject, type ProjectFile, type SourceModule } from \"../compile.js\";\n\ntype CompileStoreParams = {\n storeDir: string;\n files: SourceModule[];\n packageName: string;\n requiresEnvReference?: boolean;\n};\n\nconst EMIT_OPTIONS = {\n declaration: true,\n removeComments: false,\n sourceMap: false,\n declarationMap: false,\n rootDir: \".\",\n outDir: \".\",\n};\n\nconst ENV_REFERENCE_FILE = \"__gtkx-env__.d.ts\";\n\nconst writeEnvReference = (storeDir: string): (() => void) => {\n writeFileSync(join(storeDir, ENV_REFERENCE_FILE), \"/// <reference types=\\\"@gtkx/react/env\\\" />\\n\");\n\n return () => {\n rmSync(join(storeDir, ENV_REFERENCE_FILE), { force: true });\n };\n};\n\nconst compileStore = (params: CompileStoreParams): void => {\n const removeEnvReference = params.requiresEnvReference === true\n ? writeEnvReference(params.storeDir)\n : (): void => undefined;\n\n const files: ProjectFile[] = params.requiresEnvReference === true\n ? [{ fileName: ENV_REFERENCE_FILE }, ...params.files]\n : params.files;\n\n try {\n compileProject({\n projectDir: params.storeDir,\n files,\n compilerOptions: EMIT_OPTIONS,\n label: `the generated ${params.packageName} store`,\n });\n } finally {\n removeEnvReference();\n }\n\n for (const file of params.files) {\n rmSync(join(params.storeDir, file.fileName), { force: true });\n }\n};\n\nexport { compileStore };\n"]}
@@ -0,0 +1,11 @@
1
+ import type { GirFunction } from "../../gir/function.js";
2
+ import type { ModuleContext } from "../../writer/context.js";
3
+ import type { JsDocSpec } from "../../writer/doc.js";
4
+ type CallableDocOptions = {
5
+ finishFn?: GirFunction | undefined;
6
+ renames?: Map<string, string> | undefined;
7
+ };
8
+ declare const callableSpec: (context: ModuleContext, callable: GirFunction, options: CallableDocOptions) => JsDocSpec;
9
+ declare const callableDoc: (context: ModuleContext, callable: GirFunction, options?: CallableDocOptions) => string;
10
+ export { callableDoc, callableSpec };
11
+ //# sourceMappingURL=callable-doc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callable-doc.d.ts","sourceRoot":"","sources":["../../../src/store/gi/callable-doc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAarD,KAAK,kBAAkB,GAAG;IACtB,QAAQ,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACnC,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CAC7C,CAAC;AAkEF,QAAA,MAAM,YAAY,GAAI,SAAS,aAAa,EAAE,UAAU,WAAW,EAAE,SAAS,kBAAkB,KAAG,SAWjG,CAAC;AAEH,QAAA,MAAM,WAAW,GAAI,SAAS,aAAa,EAAE,UAAU,WAAW,EAAE,UAAS,kBAAuB,KAAG,MACM,CAAC;AAE9G,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { shouldOmitPrimaryReturn } from "../../analysis/descriptor-render.js";
2
+ import { nulTerminatedByteParams } from "../../analysis/nul-terminated-bytes.js";
3
+ import { documentedParameters, parameterIdentifier, renamesWithInstance, } from "../../analysis/param-structure.js";
4
+ import { renderJsDoc } from "../../writer/doc.js";
5
+ import { annotationSpec, THROWS_TEXT } from "./doc-spec.js";
6
+ import { isCallbackParameter, returnedOutParameters } from "./method.js";
7
+ const WHITESPACE_RUN_PATTERN = /\s+/g;
8
+ const nulTerminatedNote = (context, callable) => {
9
+ const parameters = nulTerminatedByteParams(context.library, callable);
10
+ if (parameters.length === 0) {
11
+ return undefined;
12
+ }
13
+ const names = parameters.map((parameter) => `\`${parameter.name}\``).join(", ");
14
+ return [
15
+ `The C function reads ${names} as a NUL-terminated string, so it stops at the`,
16
+ "first zero byte and drops every byte after it without reporting an error.",
17
+ "Pass binary data through a `GLib.Bytes` route such as `GLib.Variant.newFromBytes`",
18
+ "instead.",
19
+ ].join("\n");
20
+ };
21
+ const tupleBullet = (name, doc) => {
22
+ const text = (doc ?? "").replaceAll(WHITESPACE_RUN_PATTERN, " ").trim();
23
+ return text.length === 0 ? undefined : `- \`${name}\`: ${text}`;
24
+ };
25
+ const tupleReturnsText = (primary, outs) => {
26
+ const bullets = [
27
+ tupleBullet("result", primary),
28
+ ...outs.map(({ parameter, index }) => tupleBullet(parameterIdentifier(parameter, index), parameter.doc)),
29
+ ].filter((bullet) => bullet !== undefined);
30
+ return bullets.length === 0 ? undefined : `Tuple of:\n\n${bullets.join("\n")}`;
31
+ };
32
+ const returnsText = (context, fn) => {
33
+ const outs = returnedOutParameters(context, fn);
34
+ const isPrimaryOmitted = shouldOmitPrimaryReturn(context.library, fn.returnValue);
35
+ const primary = isPrimaryOmitted ? undefined : fn.returnValue.doc;
36
+ if (outs.length === 0) {
37
+ return primary;
38
+ }
39
+ if (isPrimaryOmitted && outs.length === 1) {
40
+ return outs[0]?.parameter.doc;
41
+ }
42
+ return tupleReturnsText(primary, outs);
43
+ };
44
+ const docIdentifiers = (callable, renames) => {
45
+ const identifiers = renamesWithInstance(callable.parameters, callable.instance);
46
+ const overrides = renames ?? new Map();
47
+ for (const [girName, declaredName] of overrides) {
48
+ identifiers.set(girName, declaredName);
49
+ }
50
+ return identifiers;
51
+ };
52
+ const canCallableThrow = (callable, finishFn) => callable.throws || finishFn?.throws === true;
53
+ const callableSpec = (context, callable, options) => ({
54
+ ...annotationSpec(callable.annotations),
55
+ identifiers: docIdentifiers(callable, options.renames),
56
+ params: documentedParameters(context.library, callable, (parameter) => options.finishFn !== undefined && isCallbackParameter(context, parameter), options.renames),
57
+ returns: returnsText(context, options.finishFn ?? callable),
58
+ throws: canCallableThrow(callable, options.finishFn) ? THROWS_TEXT : undefined,
59
+ });
60
+ const callableDoc = (context, callable, options = {}) => renderJsDoc(callable.doc, nulTerminatedNote(context, callable), callableSpec(context, callable, options));
61
+ export { callableDoc, callableSpec };
62
+ //# sourceMappingURL=callable-doc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callable-doc.js","sourceRoot":"","sources":["../../../src/store/gi/callable-doc.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EACH,oBAAoB,EAEpB,mBAAmB,EACnB,mBAAmB,GACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAOzE,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAEtC,MAAM,iBAAiB,GAAG,CAAC,OAAsB,EAAE,QAAqB,EAAsB,EAAE;IAC5F,MAAM,UAAU,GAAG,uBAAuB,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEtE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,SAAS,C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AC,CAAC;IAC7G,GAAG,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC;IACvC,WAAW,EAAE,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC;IACtD,MAAM,EAAE,oBAAoB,CACxB,OAAO,CAAC,OAAO,EACf,QAAQ,EACR,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,IAAI,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,EACxF,OAAO,CAAC,OAAO,CAClB;IACD,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC;IAC3D,MAAM,EAAE,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;CACjF,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,CAAC,OAAsB,EAAE,QAAqB,EAAE,UAA8B,EAAE,EAAU,EAAE,CAC5G,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAE9G,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import type { GirFunction } from \"../../gir/function.js\";\nimport type { GirCallable } from \"../../gir/parameter.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport type { JsDocSpec } from \"../../writer/doc.js\";\nimport { shouldOmitPrimaryReturn } from \"../../analysis/descriptor-render.js\";\nimport { nulTerminatedByteParams } from \"../../analysis/nul-terminated-bytes.js\";\nimport {\n documentedParameters,\n type InputParameter,\n parameterIdentifier,\n renamesWithInstance,\n} from \"../../analysis/param-structure.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\nimport { annotationSpec, THROWS_TEXT } from \"./doc-spec.js\";\nimport { isCallbackParameter, returnedOutParameters } from \"./method.js\";\n\ntype CallableDocOptions = {\n finishFn?: GirFunction | undefined;\n renames?: Map<string, string> | undefined;\n};\n\nconst WHITESPACE_RUN_PATTERN = /\\s+/g;\n\nconst nulTerminatedNote = (context: ModuleContext, callable: GirCallable): string | undefined => {\n const parameters = nulTerminatedByteParams(context.library, callable);\n\n if (parameters.length === 0) {\n return undefined;\n }\n\n const names = parameters.map((parameter) => `\\`${parameter.name}\\``).join(\", \");\n\n return [\n `The C function reads ${names} as a NUL-terminated string, so it stops at the`,\n \"first zero byte and drops every byte after it without reporting an error.\",\n \"Pass binary data through a `GLib.Bytes` route such as `GLib.Variant.newFromBytes`\",\n \"instead.\",\n ].join(\"\\n\");\n};\n\nconst tupleBullet = (name: string, doc: string | undefined): string | undefined => {\n const text = (doc ?? \"\").replaceAll(WHITESPACE_RUN_PATTERN, \" \").trim();\n\n return text.length === 0 ? undefined : `- \\`${name}\\`: ${text}`;\n};\n\nconst tupleReturnsText = (primary: string | undefined, outs: InputParameter[]): string | undefined => {\n const bullets = [\n tupleBullet(\"result\", primary),\n ...outs.map(({ parameter, index }) => tupleBullet(parameterIdentifier(parameter, index), parameter.doc)),\n ].filter((bullet) => bullet !== undefined);\n\n return bullets.length === 0 ? undefined : `Tuple of:\\n\\n${bullets.join(\"\\n\")}`;\n};\n\nconst returnsText = (context: ModuleContext, fn: GirFunction): string | undefined => {\n const outs = returnedOutParameters(context, fn);\n const isPrimaryOmitted = shouldOmitPrimaryReturn(context.library, fn.returnValue);\n const primary = isPrimaryOmitted ? undefined : fn.returnValue.doc;\n\n if (outs.length === 0) {\n return primary;\n }\n\n if (isPrimaryOmitted && outs.length === 1) {\n return outs[0]?.parameter.doc;\n }\n\n return tupleReturnsText(primary, outs);\n};\n\nconst docIdentifiers = (callable: GirFunction, renames: Map<string, string> | undefined): Map<string, string> => {\n const identifiers = renamesWithInstance(callable.parameters, callable.instance);\n const overrides = renames ?? new Map<string, string>();\n\n for (const [girName, declaredName] of overrides) {\n identifiers.set(girName, declaredName);\n }\n\n return identifiers;\n};\n\nconst canCallableThrow = (callable: GirFunction, finishFn: GirFunction | undefined): boolean =>\n callable.throws || finishFn?.throws === true;\n\nconst callableSpec = (context: ModuleContext, callable: GirFunction, options: CallableDocOptions): JsDocSpec => ({\n ...annotationSpec(callable.annotations),\n identifiers: docIdentifiers(callable, options.renames),\n params: documentedParameters(\n context.library,\n callable,\n (parameter) => options.finishFn !== undefined && isCallbackParameter(context, parameter),\n options.renames,\n ),\n returns: returnsText(context, options.finishFn ?? callable),\n throws: canCallableThrow(callable, options.finishFn) ? THROWS_TEXT : undefined,\n});\n\nconst callableDoc = (context: ModuleContext, callable: GirFunction, options: CallableDocOptions = {}): string =>\n renderJsDoc(callable.doc, nulTerminatedNote(context, callable), callableSpec(context, callable, options));\n\nexport { callableDoc, callableSpec };\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { GirFunction } from "../../gir/function.js";
2
2
  import type { ModuleContext } from "../../writer/context.js";
3
+ import type { JsDocSpec } from "../../writer/doc.js";
3
4
  type Callables = {
4
5
  constructors: GirFunction[];
5
6
  functions: GirFunction[];
@@ -10,6 +11,10 @@ type InstanceScope = {
10
11
  methodByName: Map<string, GirFunction>;
11
12
  statics: GirFunction[];
12
13
  };
14
+ type StaticMember = {
15
+ callable: GirFunction;
16
+ name: string;
17
+ };
13
18
  type InstanceMemberRenderer = (context: ModuleContext, callable: GirFunction, scope: InstanceScope, nameOverride?: string) => string | undefined;
14
19
  type PlainTypeMembersOptions = {
15
20
  context: ModuleContext;
@@ -19,6 +24,7 @@ type PlainTypeMembersOptions = {
19
24
  };
20
25
  declare const renderInstanceMethodSignature: InstanceMemberRenderer;
21
26
  declare const renderClassInstanceMember: InstanceMemberRenderer;
27
+ declare const instanceMemberSpec: (context: ModuleContext, callable: GirFunction, scope: InstanceScope) => JsDocSpec;
22
28
  declare const instanceScope: (ownerName: string, callables: Callables) => InstanceScope;
23
29
  declare const dedupeCallables: (callables: GirFunction[]) => GirFunction[];
24
30
  declare const generateBindings: (context: ModuleContext, callables: Callables) => void;
@@ -32,11 +38,12 @@ declare const renderStaticSignature: (context: ModuleContext, callable: GirFunct
32
38
  name: string;
33
39
  signature: string;
34
40
  } | undefined;
35
- declare const classConstructorMemberNames: (context: ModuleContext, callables: Callables) => string[];
41
+ declare const staticMembers: (context: ModuleContext, callables: Callables) => StaticMember[];
42
+ declare const constructorMemberNames: (context: ModuleContext, constructors: GirFunction[]) => string[];
36
43
  declare const renderStaticHead: (context: ModuleContext, callables: Callables, ownerClassName: string) => string[];
37
44
  declare const renderPlainTypeMembers: (options: PlainTypeMembersOptions) => {
38
45
  members: string[];
39
46
  claimedNames: Set<string>;
40
47
  };
41
- export { renderInstanceMethodSignature, renderClassInstanceMember, instanceScope, dedupeCallables, generateBindings, matchStaticFinishFunction, indexMethodsByName, isEmittableCallable, renderStaticSignature, classConstructorMemberNames, renderStaticHead, renderPlainTypeMembers, type Callables, type InstanceScope, };
48
+ export { renderInstanceMethodSignature, renderClassInstanceMember, instanceMemberSpec, instanceScope, dedupeCallables, generateBindings, matchStaticFinishFunction, indexMethodsByName, isEmittableCallable, renderStaticSignature, constructorMemberNames, renderStaticHead, renderPlainTypeMembers, staticMembers, type Callables, type InstanceMemberRenderer, type InstanceScope, };
42
49
  //# sourceMappingURL=callables.d.ts.map