@gtkx/codegen 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. package/LICENSE +373 -0
  2. package/dist/dsl/context.d.ts +104 -0
  3. package/dist/dsl/context.d.ts.map +1 -0
  4. package/dist/dsl/context.js +140 -0
  5. package/dist/dsl/context.js.map +1 -0
  6. package/dist/dsl/emit.d.ts +28 -0
  7. package/dist/dsl/emit.d.ts.map +1 -0
  8. package/dist/dsl/emit.js +41 -0
  9. package/dist/dsl/emit.js.map +1 -0
  10. package/dist/dsl/identifier.d.ts +28 -0
  11. package/dist/dsl/identifier.d.ts.map +1 -0
  12. package/dist/dsl/identifier.js +45 -0
  13. package/dist/dsl/identifier.js.map +1 -0
  14. package/dist/dsl/imports.d.ts +58 -0
  15. package/dist/dsl/imports.d.ts.map +1 -0
  16. package/dist/dsl/imports.js +107 -0
  17. package/dist/dsl/imports.js.map +1 -0
  18. package/dist/dsl/module.d.ts +53 -0
  19. package/dist/dsl/module.d.ts.map +1 -0
  20. package/dist/dsl/module.js +76 -0
  21. package/dist/dsl/module.js.map +1 -0
  22. package/dist/ffi/pipeline.d.ts +19 -0
  23. package/dist/ffi/pipeline.d.ts.map +1 -0
  24. package/dist/ffi/pipeline.js +107 -0
  25. package/dist/ffi/pipeline.js.map +1 -0
  26. package/dist/fingerprint.d.ts +30 -0
  27. package/dist/fingerprint.d.ts.map +1 -0
  28. package/dist/fingerprint.js +33 -0
  29. package/dist/fingerprint.js.map +1 -0
  30. package/dist/gi-store.d.ts +34 -0
  31. package/dist/gi-store.d.ts.map +1 -0
  32. package/dist/gi-store.js +154 -0
  33. package/dist/gi-store.js.map +1 -0
  34. package/dist/gir/boxed.d.ts +66 -0
  35. package/dist/gir/boxed.d.ts.map +1 -0
  36. package/dist/gir/boxed.js +49 -0
  37. package/dist/gir/boxed.js.map +1 -0
  38. package/dist/gir/callback.d.ts +15 -0
  39. package/dist/gir/callback.d.ts.map +1 -0
  40. package/dist/gir/callback.js +17 -0
  41. package/dist/gir/callback.js.map +1 -0
  42. package/dist/gir/class.d.ts +49 -0
  43. package/dist/gir/class.d.ts.map +1 -0
  44. package/dist/gir/class.js +42 -0
  45. package/dist/gir/class.js.map +1 -0
  46. package/dist/gir/enum.d.ts +39 -0
  47. package/dist/gir/enum.d.ts.map +1 -0
  48. package/dist/gir/enum.js +24 -0
  49. package/dist/gir/enum.js.map +1 -0
  50. package/dist/gir/field.d.ts +27 -0
  51. package/dist/gir/field.d.ts.map +1 -0
  52. package/dist/gir/field.js +19 -0
  53. package/dist/gir/field.js.map +1 -0
  54. package/dist/gir/function.d.ts +47 -0
  55. package/dist/gir/function.d.ts.map +1 -0
  56. package/dist/gir/function.js +28 -0
  57. package/dist/gir/function.js.map +1 -0
  58. package/dist/gir/namespace.d.ts +65 -0
  59. package/dist/gir/namespace.d.ts.map +1 -0
  60. package/dist/gir/namespace.js +60 -0
  61. package/dist/gir/namespace.js.map +1 -0
  62. package/dist/gir/parameter.d.ts +82 -0
  63. package/dist/gir/parameter.d.ts.map +1 -0
  64. package/dist/gir/parameter.js +66 -0
  65. package/dist/gir/parameter.js.map +1 -0
  66. package/dist/gir/parse.d.ts +78 -0
  67. package/dist/gir/parse.d.ts.map +1 -0
  68. package/dist/gir/parse.js +155 -0
  69. package/dist/gir/parse.js.map +1 -0
  70. package/dist/gir/primitives.d.ts +36 -0
  71. package/dist/gir/primitives.d.ts.map +1 -0
  72. package/dist/gir/primitives.js +109 -0
  73. package/dist/gir/primitives.js.map +1 -0
  74. package/dist/gir/property.d.ts +29 -0
  75. package/dist/gir/property.d.ts.map +1 -0
  76. package/dist/gir/property.js +16 -0
  77. package/dist/gir/property.js.map +1 -0
  78. package/dist/gir/qualified-name.d.ts +37 -0
  79. package/dist/gir/qualified-name.d.ts.map +1 -0
  80. package/dist/gir/qualified-name.js +39 -0
  81. package/dist/gir/qualified-name.js.map +1 -0
  82. package/dist/gir/qualify.d.ts +32 -0
  83. package/dist/gir/qualify.d.ts.map +1 -0
  84. package/dist/gir/qualify.js +60 -0
  85. package/dist/gir/qualify.js.map +1 -0
  86. package/dist/gir/repository.d.ts +82 -0
  87. package/dist/gir/repository.d.ts.map +1 -0
  88. package/dist/gir/repository.js +122 -0
  89. package/dist/gir/repository.js.map +1 -0
  90. package/dist/gir/signal.d.ts +22 -0
  91. package/dist/gir/signal.d.ts.map +1 -0
  92. package/dist/gir/signal.js +20 -0
  93. package/dist/gir/signal.js.map +1 -0
  94. package/dist/gir/size.d.ts +67 -0
  95. package/dist/gir/size.d.ts.map +1 -0
  96. package/dist/gir/size.js +87 -0
  97. package/dist/gir/size.js.map +1 -0
  98. package/dist/gir/type-ref.d.ts +79 -0
  99. package/dist/gir/type-ref.d.ts.map +1 -0
  100. package/dist/gir/type-ref.js +101 -0
  101. package/dist/gir/type-ref.js.map +1 -0
  102. package/dist/index.d.ts +12 -0
  103. package/dist/index.d.ts.map +1 -0
  104. package/dist/index.js +12 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/jsx-store.d.ts +22 -0
  107. package/dist/jsx-store.d.ts.map +1 -0
  108. package/dist/jsx-store.js +40 -0
  109. package/dist/jsx-store.js.map +1 -0
  110. package/dist/react/compounds-meta.d.ts +18 -0
  111. package/dist/react/compounds-meta.d.ts.map +1 -0
  112. package/dist/react/compounds-meta.js +93 -0
  113. package/dist/react/compounds-meta.js.map +1 -0
  114. package/dist/react/compounds.d.ts +27 -0
  115. package/dist/react/compounds.d.ts.map +1 -0
  116. package/dist/react/compounds.js +164 -0
  117. package/dist/react/compounds.js.map +1 -0
  118. package/dist/react/internal.d.ts +14 -0
  119. package/dist/react/internal.d.ts.map +1 -0
  120. package/dist/react/internal.js +79 -0
  121. package/dist/react/internal.js.map +1 -0
  122. package/dist/react/jsx.d.ts +22 -0
  123. package/dist/react/jsx.d.ts.map +1 -0
  124. package/dist/react/jsx.js +134 -0
  125. package/dist/react/jsx.js.map +1 -0
  126. package/dist/react/pipeline.d.ts +13 -0
  127. package/dist/react/pipeline.d.ts.map +1 -0
  128. package/dist/react/pipeline.js +25 -0
  129. package/dist/react/pipeline.js.map +1 -0
  130. package/dist/react/props.d.ts +38 -0
  131. package/dist/react/props.d.ts.map +1 -0
  132. package/dist/react/props.js +231 -0
  133. package/dist/react/props.js.map +1 -0
  134. package/dist/react/slot-props.d.ts +10 -0
  135. package/dist/react/slot-props.d.ts.map +1 -0
  136. package/dist/react/slot-props.js +56 -0
  137. package/dist/react/slot-props.js.map +1 -0
  138. package/dist/react/widgets.d.ts +83 -0
  139. package/dist/react/widgets.d.ts.map +1 -0
  140. package/dist/react/widgets.js +152 -0
  141. package/dist/react/widgets.js.map +1 -0
  142. package/dist/runner.d.ts +55 -0
  143. package/dist/runner.d.ts.map +1 -0
  144. package/dist/runner.js +60 -0
  145. package/dist/runner.js.map +1 -0
  146. package/dist/store-fs.d.ts +109 -0
  147. package/dist/store-fs.d.ts.map +1 -0
  148. package/dist/store-fs.js +98 -0
  149. package/dist/store-fs.js.map +1 -0
  150. package/dist/transpile.d.ts +32 -0
  151. package/dist/transpile.d.ts.map +1 -0
  152. package/dist/transpile.js +63 -0
  153. package/dist/transpile.js.map +1 -0
  154. package/dist/typecheck-store.d.ts +41 -0
  155. package/dist/typecheck-store.d.ts.map +1 -0
  156. package/dist/typecheck-store.js +102 -0
  157. package/dist/typecheck-store.js.map +1 -0
  158. package/dist/writers/alias.d.ts +13 -0
  159. package/dist/writers/alias.d.ts.map +1 -0
  160. package/dist/writers/alias.js +17 -0
  161. package/dist/writers/alias.js.map +1 -0
  162. package/dist/writers/async.d.ts +22 -0
  163. package/dist/writers/async.d.ts.map +1 -0
  164. package/dist/writers/async.js +48 -0
  165. package/dist/writers/async.js.map +1 -0
  166. package/dist/writers/boxed-constructor.d.ts +26 -0
  167. package/dist/writers/boxed-constructor.d.ts.map +1 -0
  168. package/dist/writers/boxed-constructor.js +85 -0
  169. package/dist/writers/boxed-constructor.js.map +1 -0
  170. package/dist/writers/boxed-field-accessor.d.ts +18 -0
  171. package/dist/writers/boxed-field-accessor.d.ts.map +1 -0
  172. package/dist/writers/boxed-field-accessor.js +260 -0
  173. package/dist/writers/boxed-field-accessor.js.map +1 -0
  174. package/dist/writers/boxed-layout.d.ts +27 -0
  175. package/dist/writers/boxed-layout.d.ts.map +1 -0
  176. package/dist/writers/boxed-layout.js +128 -0
  177. package/dist/writers/boxed-layout.js.map +1 -0
  178. package/dist/writers/boxed.d.ts +20 -0
  179. package/dist/writers/boxed.d.ts.map +1 -0
  180. package/dist/writers/boxed.js +71 -0
  181. package/dist/writers/boxed.js.map +1 -0
  182. package/dist/writers/callables.d.ts +124 -0
  183. package/dist/writers/callables.d.ts.map +1 -0
  184. package/dist/writers/callables.js +283 -0
  185. package/dist/writers/callables.js.map +1 -0
  186. package/dist/writers/callback.d.ts +16 -0
  187. package/dist/writers/callback.d.ts.map +1 -0
  188. package/dist/writers/callback.js +38 -0
  189. package/dist/writers/callback.js.map +1 -0
  190. package/dist/writers/class-struct-record.d.ts +31 -0
  191. package/dist/writers/class-struct-record.d.ts.map +1 -0
  192. package/dist/writers/class-struct-record.js +67 -0
  193. package/dist/writers/class-struct-record.js.map +1 -0
  194. package/dist/writers/class-struct.d.ts +22 -0
  195. package/dist/writers/class-struct.d.ts.map +1 -0
  196. package/dist/writers/class-struct.js +85 -0
  197. package/dist/writers/class-struct.js.map +1 -0
  198. package/dist/writers/class.d.ts +16 -0
  199. package/dist/writers/class.d.ts.map +1 -0
  200. package/dist/writers/class.js +307 -0
  201. package/dist/writers/class.js.map +1 -0
  202. package/dist/writers/constant.d.ts +15 -0
  203. package/dist/writers/constant.d.ts.map +1 -0
  204. package/dist/writers/constant.js +23 -0
  205. package/dist/writers/constant.js.map +1 -0
  206. package/dist/writers/constants.d.ts +15 -0
  207. package/dist/writers/constants.d.ts.map +1 -0
  208. package/dist/writers/constants.js +23 -0
  209. package/dist/writers/constants.js.map +1 -0
  210. package/dist/writers/constructor-props.d.ts +32 -0
  211. package/dist/writers/constructor-props.d.ts.map +1 -0
  212. package/dist/writers/constructor-props.js +110 -0
  213. package/dist/writers/constructor-props.js.map +1 -0
  214. package/dist/writers/enum.d.ts +21 -0
  215. package/dist/writers/enum.d.ts.map +1 -0
  216. package/dist/writers/enum.js +48 -0
  217. package/dist/writers/enum.js.map +1 -0
  218. package/dist/writers/function.d.ts +40 -0
  219. package/dist/writers/function.d.ts.map +1 -0
  220. package/dist/writers/function.js +127 -0
  221. package/dist/writers/function.js.map +1 -0
  222. package/dist/writers/gtype-binding.d.ts +19 -0
  223. package/dist/writers/gtype-binding.d.ts.map +1 -0
  224. package/dist/writers/gtype-binding.js +40 -0
  225. package/dist/writers/gtype-binding.js.map +1 -0
  226. package/dist/writers/inheritance.d.ts +48 -0
  227. package/dist/writers/inheritance.d.ts.map +1 -0
  228. package/dist/writers/inheritance.js +90 -0
  229. package/dist/writers/inheritance.js.map +1 -0
  230. package/dist/writers/interface.d.ts +16 -0
  231. package/dist/writers/interface.d.ts.map +1 -0
  232. package/dist/writers/interface.js +155 -0
  233. package/dist/writers/interface.js.map +1 -0
  234. package/dist/writers/method.d.ts +150 -0
  235. package/dist/writers/method.d.ts.map +1 -0
  236. package/dist/writers/method.js +510 -0
  237. package/dist/writers/method.js.map +1 -0
  238. package/dist/writers/param-classify.d.ts +93 -0
  239. package/dist/writers/param-classify.d.ts.map +1 -0
  240. package/dist/writers/param-classify.js +163 -0
  241. package/dist/writers/param-classify.js.map +1 -0
  242. package/dist/writers/property-accessor.d.ts +19 -0
  243. package/dist/writers/property-accessor.d.ts.map +1 -0
  244. package/dist/writers/property-accessor.js +117 -0
  245. package/dist/writers/property-accessor.js.map +1 -0
  246. package/dist/writers/registration.d.ts +27 -0
  247. package/dist/writers/registration.d.ts.map +1 -0
  248. package/dist/writers/registration.js +30 -0
  249. package/dist/writers/registration.js.map +1 -0
  250. package/dist/writers/return-wrap.d.ts +39 -0
  251. package/dist/writers/return-wrap.d.ts.map +1 -0
  252. package/dist/writers/return-wrap.js +152 -0
  253. package/dist/writers/return-wrap.js.map +1 -0
  254. package/dist/writers/runtime-override.d.ts +18 -0
  255. package/dist/writers/runtime-override.d.ts.map +1 -0
  256. package/dist/writers/runtime-override.js +44 -0
  257. package/dist/writers/runtime-override.js.map +1 -0
  258. package/dist/writers/signal.d.ts +21 -0
  259. package/dist/writers/signal.d.ts.map +1 -0
  260. package/dist/writers/signal.js +260 -0
  261. package/dist/writers/signal.js.map +1 -0
  262. package/dist/writers/ts-type.d.ts +50 -0
  263. package/dist/writers/ts-type.d.ts.map +1 -0
  264. package/dist/writers/ts-type.js +75 -0
  265. package/dist/writers/ts-type.js.map +1 -0
  266. package/dist/writers/types-ts.d.ts +27 -0
  267. package/dist/writers/types-ts.d.ts.map +1 -0
  268. package/dist/writers/types-ts.js +97 -0
  269. package/dist/writers/types-ts.js.map +1 -0
  270. package/dist/writers/value.d.ts +89 -0
  271. package/dist/writers/value.d.ts.map +1 -0
  272. package/dist/writers/value.js +402 -0
  273. package/dist/writers/value.js.map +1 -0
  274. package/package.json +55 -0
  275. package/src/dsl/context.ts +146 -0
  276. package/src/dsl/emit.ts +42 -0
  277. package/src/dsl/identifier.ts +52 -0
  278. package/src/dsl/imports.ts +109 -0
  279. package/src/dsl/module.ts +75 -0
  280. package/src/ffi/pipeline.ts +113 -0
  281. package/src/fingerprint.ts +50 -0
  282. package/src/gi-store.ts +199 -0
  283. package/src/gir/boxed.ts +94 -0
  284. package/src/gir/callback.ts +26 -0
  285. package/src/gir/class.ts +79 -0
  286. package/src/gir/enum.ts +55 -0
  287. package/src/gir/field.ts +40 -0
  288. package/src/gir/function.ts +67 -0
  289. package/src/gir/namespace.ts +118 -0
  290. package/src/gir/parameter.ts +120 -0
  291. package/src/gir/parse.ts +171 -0
  292. package/src/gir/primitives.ts +137 -0
  293. package/src/gir/property.ts +39 -0
  294. package/src/gir/qualified-name.ts +55 -0
  295. package/src/gir/qualify.ts +64 -0
  296. package/src/gir/repository.ts +149 -0
  297. package/src/gir/signal.ts +36 -0
  298. package/src/gir/size.ts +129 -0
  299. package/src/gir/type-ref.ts +180 -0
  300. package/src/index.ts +16 -0
  301. package/src/jsx-store.ts +53 -0
  302. package/src/react/compounds-meta.ts +99 -0
  303. package/src/react/compounds.ts +204 -0
  304. package/src/react/internal.ts +91 -0
  305. package/src/react/jsx.ts +155 -0
  306. package/src/react/pipeline.ts +29 -0
  307. package/src/react/props.ts +307 -0
  308. package/src/react/slot-props.ts +57 -0
  309. package/src/react/widgets.ts +185 -0
  310. package/src/runner.ts +89 -0
  311. package/src/store-fs.ts +157 -0
  312. package/src/transpile.ts +80 -0
  313. package/src/typecheck-store.ts +136 -0
  314. package/src/writers/alias.ts +19 -0
  315. package/src/writers/async.ts +44 -0
  316. package/src/writers/boxed-constructor.ts +105 -0
  317. package/src/writers/boxed-field-accessor.ts +306 -0
  318. package/src/writers/boxed-layout.ts +166 -0
  319. package/src/writers/boxed.ts +77 -0
  320. package/src/writers/callables.ts +339 -0
  321. package/src/writers/callback.ts +40 -0
  322. package/src/writers/class-struct-record.ts +75 -0
  323. package/src/writers/class-struct.ts +96 -0
  324. package/src/writers/class.ts +384 -0
  325. package/src/writers/constant.ts +29 -0
  326. package/src/writers/constructor-props.ts +130 -0
  327. package/src/writers/enum.ts +53 -0
  328. package/src/writers/function.ts +136 -0
  329. package/src/writers/gtype-binding.ts +48 -0
  330. package/src/writers/inheritance.ts +104 -0
  331. package/src/writers/interface.ts +168 -0
  332. package/src/writers/method.ts +678 -0
  333. package/src/writers/param-classify.ts +178 -0
  334. package/src/writers/property-accessor.ts +139 -0
  335. package/src/writers/registration.ts +42 -0
  336. package/src/writers/return-wrap.ts +180 -0
  337. package/src/writers/runtime-override.ts +59 -0
  338. package/src/writers/signal.ts +318 -0
  339. package/src/writers/ts-type.ts +115 -0
  340. package/src/writers/value.ts +485 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../src/fingerprint.ts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;IACpC,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { type CodegenFingerprint } from "./fingerprint.js";
2
+ import { type StoreOptions } from "./store-fs.js";
3
+ /**
4
+ * Options for assembling the injected `@gtkx/gi` package.
5
+ */
6
+ export type GiStoreOptions = StoreOptions & {
7
+ /** Real (symlink-resolved) directory of the installed `@gtkx/ffi`. */
8
+ readonly realFfiDir: string;
9
+ /** Real (symlink-resolved) directory of the installed `@gtkx/native`. */
10
+ readonly realNativeDir: string;
11
+ };
12
+ /** Per-namespace inputs the store assembler turns into gi modules. */
13
+ export type GiNamespaceInput = {
14
+ /** Lowercased namespace directory name (e.g. `"gtk"`). */
15
+ readonly directory: string;
16
+ /** Transpilable raw module source, or `null` for augment-only namespaces (gl). */
17
+ readonly rawSource: string | null;
18
+ };
19
+ /**
20
+ * Assembles the self-contained injected `@gtkx/gi` package.
21
+ *
22
+ * Writes every namespace's raw generated module, its augment overlay, and its
23
+ * barrel into a temporary store, emits the `package.json` and gi's own
24
+ * `node_modules/@gtkx/{ffi,gi}` symlinks — the self-referential `@gtkx/gi` link
25
+ * lets augment modules resolve sibling namespaces without relying on the
26
+ * project's top-level alias — swaps it into place, and points the visible
27
+ * `node_modules/@gtkx/gi` alias at it.
28
+ *
29
+ * @param options - Resolved store/link/dependency paths
30
+ * @param namespaces - Per-namespace raw module inputs
31
+ * @param fingerprint - Staleness sentinel written into the store, when provided
32
+ */
33
+ export declare const writeGiStore: (options: GiStoreOptions, namespaces: readonly GiNamespaceInput[], fingerprint?: CodegenFingerprint) => void;
34
+ //# sourceMappingURL=gi-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gi-store.d.ts","sourceRoot":"","sources":["../src/gi-store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,kBAAkB,EAAwB,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,KAAK,YAAY,EAAc,MAAM,eAAe,CAAC;AAY9D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG;IACxC,sEAAsE;IACtE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,yEAAyE;IACzE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,sEAAsE;AACtE,MAAM,MAAM,gBAAgB,GAAG;IAC3B,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,kFAAkF;IAClF,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC,CAAC;AAsGF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,GACrB,SAAS,cAAc,EACvB,YAAY,SAAS,gBAAgB,EAAE,EACvC,cAAc,kBAAkB,KACjC,IA8CF,CAAC"}
@@ -0,0 +1,154 @@
1
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
2
+ import { dirname, join, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { FINGERPRINT_FILENAME } from "./fingerprint.js";
5
+ import { writeStore } from "./store-fs.js";
6
+ import { transpileSource } from "./transpile.js";
7
+ import { typecheckGiStore } from "./typecheck-store.js";
8
+ /**
9
+ * Absolute path to the hand-written augment overlay shipped with `@gtkx/codegen`.
10
+ *
11
+ * Resolves the same way whether codegen runs from `src/` (tsx) or `dist/`,
12
+ * since `overlay/` sits at the package root next to both.
13
+ */
14
+ const OVERLAY_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..", "overlay");
15
+ /** Returns the augment `.ts` files for a namespace, or `[]` when it is pure pass-through. */
16
+ const overlayFiles = (directory) => {
17
+ const dir = join(OVERLAY_ROOT, directory);
18
+ if (!existsSync(dir))
19
+ return [];
20
+ return readdirSync(dir).filter((name) => name.endsWith(".ts") && name !== "index.ts");
21
+ };
22
+ const isAugmented = (directory) => existsSync(join(OVERLAY_ROOT, directory, "index.ts"));
23
+ /**
24
+ * Whether an augmented namespace's barrel re-exports a generated module (and so
25
+ * may only be emitted when that namespace is generated), as opposed to a
26
+ * standalone overlay like `gl` that has no GIR backing.
27
+ */
28
+ const barrelNeedsGenerated = (directory) => readFileSync(join(OVERLAY_ROOT, directory, "index.ts"), "utf8").includes("../generated/");
29
+ /**
30
+ * Retargets a barrel-template specifier from its source layout (under
31
+ * `overlay/<ns>/`) to its emitted layout (under `gi/<ns>/`): the namespace's
32
+ * own generated module becomes a sibling, augment files move under `augment/`,
33
+ * and relative runtime modules collapse to the `@gtkx/ffi` barrel. The
34
+ * `@gtkx/native` specifier passes through so low-level primitives resolve
35
+ * straight to the native package.
36
+ */
37
+ const retargetBarrelSpecifier = (spec, directory) => {
38
+ const generated = spec.match(/^\.\.\/generated\/[a-z0-9]+\/([a-z0-9]+)\.js$/);
39
+ if (generated)
40
+ return `./${generated[1]}.js`;
41
+ if (spec.startsWith("../"))
42
+ return "@gtkx/ffi";
43
+ const sibling = spec.match(/^\.\/([a-z0-9-]+)\.js$/);
44
+ if (sibling) {
45
+ return existsSync(join(OVERLAY_ROOT, directory, `${sibling[1]}.ts`))
46
+ ? `./augment/${sibling[1]}.js`
47
+ : "@gtkx/ffi";
48
+ }
49
+ return spec;
50
+ };
51
+ const barrelSource = (directory) => {
52
+ if (!isAugmented(directory)) {
53
+ return `export * from "./${directory}.js";\n`;
54
+ }
55
+ const template = readFileSync(join(OVERLAY_ROOT, directory, "index.ts"), "utf8");
56
+ return template.replace(/"([^"]+)"/g, (_match, spec) => `"${retargetBarrelSpecifier(spec, directory)}"`);
57
+ };
58
+ /**
59
+ * Gathers the per-namespace generated module, augment overlay, and barrel
60
+ * sources into a flat file list, building the package `exports` map alongside.
61
+ */
62
+ const collectStoreSources = (directories, standaloneSet, rawByDirectory) => {
63
+ const exportsMap = { "./package.json": "./package.json" };
64
+ const collected = [];
65
+ for (const directory of directories) {
66
+ const rawSource = standaloneSet.has(directory) ? null : (rawByDirectory.get(directory) ?? null);
67
+ if (rawSource !== null) {
68
+ collected.push({
69
+ stem: `${directory}/${directory}`,
70
+ fileName: `${directory}/${directory}.ts`,
71
+ source: rawSource,
72
+ overlay: false,
73
+ });
74
+ exportsMap[`./${directory}/${directory}.js`] = {
75
+ types: `./${directory}/${directory}.d.ts`,
76
+ default: `./${directory}/${directory}.js`,
77
+ };
78
+ }
79
+ for (const file of overlayFiles(directory)) {
80
+ collected.push({
81
+ stem: `${directory}/augment/${file.slice(0, -".ts".length)}`,
82
+ fileName: `${directory}/augment/${file}`,
83
+ source: readFileSync(join(OVERLAY_ROOT, directory, file), "utf8"),
84
+ overlay: true,
85
+ });
86
+ }
87
+ collected.push({
88
+ stem: `${directory}/index`,
89
+ fileName: `${directory}/index.ts`,
90
+ source: barrelSource(directory),
91
+ overlay: false,
92
+ });
93
+ exportsMap[`./${directory}`] = {
94
+ types: `./${directory}/index.d.ts`,
95
+ default: `./${directory}/index.js`,
96
+ };
97
+ }
98
+ return { collected, exportsMap };
99
+ };
100
+ /**
101
+ * Assembles the self-contained injected `@gtkx/gi` package.
102
+ *
103
+ * Writes every namespace's raw generated module, its augment overlay, and its
104
+ * barrel into a temporary store, emits the `package.json` and gi's own
105
+ * `node_modules/@gtkx/{ffi,gi}` symlinks — the self-referential `@gtkx/gi` link
106
+ * lets augment modules resolve sibling namespaces without relying on the
107
+ * project's top-level alias — swaps it into place, and points the visible
108
+ * `node_modules/@gtkx/gi` alias at it.
109
+ *
110
+ * @param options - Resolved store/link/dependency paths
111
+ * @param namespaces - Per-namespace raw module inputs
112
+ * @param fingerprint - Staleness sentinel written into the store, when provided
113
+ */
114
+ export const writeGiStore = (options, namespaces, fingerprint) => {
115
+ const standaloneOverlays = readdirSync(OVERLAY_ROOT).filter((name) => isAugmented(name) && !barrelNeedsGenerated(name));
116
+ const standaloneSet = new Set(standaloneOverlays);
117
+ const directories = new Set([...namespaces.map((n) => n.directory), ...standaloneOverlays]);
118
+ const rawByDirectory = new Map(namespaces.map((n) => [n.directory, n.rawSource]));
119
+ const { collected, exportsMap } = collectStoreSources(directories, standaloneSet, rawByDirectory);
120
+ writeStore({
121
+ storeDir: options.storeDir,
122
+ linkDir: options.linkDir,
123
+ files: collected.map((file) => ({ stem: file.stem, fileName: file.fileName, source: file.source })),
124
+ manifest: {
125
+ name: "@gtkx/gi",
126
+ type: "module",
127
+ version: options.version,
128
+ sideEffects: true,
129
+ exports: exportsMap,
130
+ },
131
+ rawFiles: fingerprint === undefined
132
+ ? []
133
+ : [{ relativePath: FINGERPRINT_FILENAME, content: `${JSON.stringify(fingerprint, null, 2)}\n` }],
134
+ symlinks: [
135
+ { segments: ["node_modules", "@gtkx", "ffi"], target: options.realFfiDir },
136
+ { segments: ["node_modules", "@gtkx", "native"], target: options.realNativeDir },
137
+ { segments: ["node_modules", "@gtkx", "gi"], target: "self" },
138
+ ],
139
+ validate: (tmp) => {
140
+ const sources = collected.map((file) => file.overlay
141
+ ? { path: join(tmp, file.fileName), source: file.source, overlay: true }
142
+ : {
143
+ path: join(tmp, `${file.stem}.d.ts`),
144
+ source: transpileSource(file.fileName, file.source).dts,
145
+ overlay: false,
146
+ });
147
+ typecheckGiStore(tmp, sources, {
148
+ ffiEntry: join(options.realFfiDir, "src", "index.ts"),
149
+ nativeEntry: join(options.realNativeDir, "dist", "index.d.ts"),
150
+ });
151
+ },
152
+ });
153
+ };
154
+ //# sourceMappingURL=gi-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gi-store.js","sourceRoot":"","sources":["../src/gi-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAA2B,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAqB,UAAU,EAA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W,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,CAAC;aACjE,CAAC,CAAC;QACP,CAAC;KACJ,CAAC,CAAC;AACP,CAAC,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { type GirField } from "./field.js";
2
+ import { type GirFunction } from "./function.js";
3
+ import { type RawNode } from "./parse.js";
4
+ /**
5
+ * Discriminator for the different shapes a `<record>` (or `<glib:boxed>`)
6
+ * can take in GIR.
7
+ *
8
+ * - `boxed` — a record with a `glib:get-type`; registers as a GObject boxed.
9
+ * - `plain-struct` — a record without GType; passed by pointer using
10
+ * `t.struct(ownership)`.
11
+ * - `vtable` — a record carrying `glib:is-gtype-struct-for`; its fields are
12
+ * function pointers consumed by the class struct registration.
13
+ * - `glib-boxed` — a top-level `<glib:boxed>` element with no struct body.
14
+ */
15
+ export type BoxedKind = "boxed" | "plain-struct" | "vtable" | "glib-boxed";
16
+ /** A `<record>`, `<glib:boxed>`, or `<union>` declaration. */
17
+ export type GirBoxed = {
18
+ readonly kind: BoxedKind;
19
+ /** Local name inside the namespace (no prefix). */
20
+ readonly name: string;
21
+ readonly cType: string | undefined;
22
+ /** GLib type name (e.g. `"GtkBorder"`); absent on plain structs. */
23
+ readonly glibTypeName: string | undefined;
24
+ /** GLib get-type C symbol; absent on plain structs. */
25
+ readonly glibGetType: string | undefined;
26
+ /** Class name this record is the vtable for (`glib:is-gtype-struct-for`). */
27
+ readonly glibIsGTypeStructFor: string | undefined;
28
+ /** GLib ref/unref/etc. function names on fundamentals. */
29
+ readonly glibRefFunc: string | undefined;
30
+ readonly glibUnrefFunc: string | undefined;
31
+ readonly glibSetValueFunc: string | undefined;
32
+ readonly glibGetValueFunc: string | undefined;
33
+ /** `copy-function`/`free-function` — the ref/unref pair for records that are reference-counted rather than g_boxed-copyable. */
34
+ readonly copyFunc: string | undefined;
35
+ readonly freeFunc: string | undefined;
36
+ /** `disguised="1"` — record has no introspectable fields. */
37
+ readonly disguised: boolean;
38
+ /** `opaque="1"` — record is opaque to callers. */
39
+ readonly opaque: boolean;
40
+ readonly introspectable: boolean;
41
+ readonly fields: readonly GirField[];
42
+ readonly methods: readonly GirFunction[];
43
+ readonly constructors: readonly GirFunction[];
44
+ readonly functions: readonly GirFunction[];
45
+ /** `true` when the source element was `<union>` rather than `<record>`. */
46
+ readonly isUnion: boolean;
47
+ };
48
+ /**
49
+ * Builds a {@link GirBoxed} from a `<record>`, `<union>`, or `<glib:boxed>` element.
50
+ *
51
+ * @param node - The XML element
52
+ * @param kind - The kind inferred from element name and attribute set
53
+ * @param isUnion - `true` when the source element was `<union>`
54
+ */
55
+ export declare const boxedFromNode: (node: RawNode, kind: BoxedKind, isUnion: boolean) => GirBoxed;
56
+ /**
57
+ * Decides which {@link BoxedKind} applies to a `<record>` or `<union>` element.
58
+ *
59
+ * Vtable records (`glib:is-gtype-struct-for`) take precedence; otherwise a
60
+ * `glib:get-type` flips the record to a registered boxed; otherwise it's a
61
+ * plain struct.
62
+ *
63
+ * @param node - The `<record>` or `<union>` element
64
+ */
65
+ export declare const boxedKind: (node: RawNode) => BoxedKind;
66
+ //# sourceMappingURL=boxed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boxed.d.ts","sourceRoot":"","sources":["../../src/gir/boxed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAmD,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAE3F;;;;;;;;;;GAUG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,cAAc,GAAG,QAAQ,GAAG,YAAY,CAAC;AAE3E,8DAA8D;AAC9D,MAAM,MAAM,QAAQ,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CA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;;GAQG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,OAAO,KAAG,SAIzC,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { fieldFromNode } from "./field.js";
2
+ import { functionFromNode } from "./function.js";
3
+ import { attr, attrBool, childrenOf, GIR_CONSTRUCTOR_TAG } from "./parse.js";
4
+ /**
5
+ * Builds a {@link GirBoxed} from a `<record>`, `<union>`, or `<glib:boxed>` element.
6
+ *
7
+ * @param node - The XML element
8
+ * @param kind - The kind inferred from element name and attribute set
9
+ * @param isUnion - `true` when the source element was `<union>`
10
+ */
11
+ export const boxedFromNode = (node, kind, isUnion) => ({
12
+ kind,
13
+ name: attr(node, "name") ?? attr(node, "glib:name") ?? "",
14
+ cType: attr(node, "c:type"),
15
+ glibTypeName: attr(node, "glib:type-name"),
16
+ glibGetType: attr(node, "glib:get-type"),
17
+ glibIsGTypeStructFor: attr(node, "glib:is-gtype-struct-for"),
18
+ glibRefFunc: attr(node, "glib:ref-func"),
19
+ glibUnrefFunc: attr(node, "glib:unref-func"),
20
+ glibSetValueFunc: attr(node, "glib:set-value-func"),
21
+ glibGetValueFunc: attr(node, "glib:get-value-func"),
22
+ copyFunc: attr(node, "copy-function"),
23
+ freeFunc: attr(node, "free-function"),
24
+ disguised: attrBool(node, "disguised"),
25
+ opaque: attrBool(node, "opaque"),
26
+ introspectable: attr(node, "introspectable") !== "0",
27
+ fields: childrenOf(node, "field").map(fieldFromNode),
28
+ methods: childrenOf(node, "method").map((method) => functionFromNode(method, "method")),
29
+ constructors: childrenOf(node, GIR_CONSTRUCTOR_TAG).map((ctor) => functionFromNode(ctor, "constructor")),
30
+ functions: childrenOf(node, "function").map((function_) => functionFromNode(function_, "function")),
31
+ isUnion,
32
+ });
33
+ /**
34
+ * Decides which {@link BoxedKind} applies to a `<record>` or `<union>` element.
35
+ *
36
+ * Vtable records (`glib:is-gtype-struct-for`) take precedence; otherwise a
37
+ * `glib:get-type` flips the record to a registered boxed; otherwise it's a
38
+ * plain struct.
39
+ *
40
+ * @param node - The `<record>` or `<union>` element
41
+ */
42
+ export const boxedKind = (node) => {
43
+ if (attr(node, "glib:is-gtype-struct-for") !== undefined)
44
+ return "vtable";
45
+ if (attr(node, "glib:get-type") !== undefined)
46
+ return "boxed";
47
+ return "plain-struct";
48
+ };
49
+ //# sourceMappingURL=boxed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boxed.js","sourceRoot":"","sources":["../../src/gir/boxed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAoB,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,mBAAmB,EAAgB,MAAM,YAAY,CAAC;AAgD3F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAa,EAAE,IAAe,EAAE,OAAgB,EAAY,EAAE,CAAC,CAAC;IAC1F,IAAI;IACJ,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE;IACzD,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC;IAC3B,YAAY,EAAE,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAC1C,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC;IACxC,oBAAoB,EAAE,IAAI,CAAC,IAAI,EAAE,0BAA0B,CAAC;IAC5D,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC;IACxC,aAAa,EAAE,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAC5C,gBAAgB,EAAE,IAAI,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACnD,gBAAgB,EAAE,IAAI,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACnD,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC;IACrC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC;IACrC,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IACtC,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAChC,cAAc,EAAE,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,KAAK,GAAG;IACpD,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC;IACpD,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACvF,YAAY,EAAE,UAAU,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IACxG,SAAS,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACnG,OAAO;CACV,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAa,EAAa,EAAE;IAClD,IAAI,IAAI,CAAC,IAAI,EAAE,0BAA0B,CAAC,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAC1E,IAAI,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC;IAC9D,OAAO,cAAc,CAAC;AAC1B,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type GirParameter, type GirReturnValue } from "./parameter.js";
2
+ import { type RawNode } from "./parse.js";
3
+ /** A `<callback>` declaration (top-level inside a namespace or nested in a field). */
4
+ export type GirCallback = {
5
+ readonly name: string;
6
+ readonly cType: string | undefined;
7
+ readonly parameters: readonly GirParameter[];
8
+ readonly returnValue: GirReturnValue;
9
+ readonly introspectable: boolean;
10
+ };
11
+ /**
12
+ * Builds a {@link GirCallback} from a `<callback>` element.
13
+ */
14
+ export declare const callbackFromNode: (node: RawNode) => GirCallback;
15
+ //# sourceMappingURL=callback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../src/gir/callback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAA0C,MAAM,gBAAgB,CAAC;AAChH,OAAO,EAA6B,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAErE,sFAAsF;AACtF,MAAM,MAAM,WAAW,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,SAAS,YAAY,EAAE,CAAC;IAC7C,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC;IACrC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,OAAO,KAAG,WAUhD,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { parameterFromNode, returnValueFromNode } from "./parameter.js";
2
+ import { attr, childOf, childrenOf } from "./parse.js";
3
+ /**
4
+ * Builds a {@link GirCallback} from a `<callback>` element.
5
+ */
6
+ export const callbackFromNode = (node) => {
7
+ const parametersNode = childOf(node, "parameters");
8
+ const parameterNodes = childrenOf(parametersNode, "parameter");
9
+ return {
10
+ name: attr(node, "name") ?? "",
11
+ cType: attr(node, "c:type"),
12
+ parameters: parameterNodes.map((parameter) => parameterFromNode(parameter, false)),
13
+ returnValue: returnValueFromNode(childOf(node, "return-value")),
14
+ introspectable: attr(node, "introspectable") !== "0",
15
+ };
16
+ };
17
+ //# sourceMappingURL=callback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callback.js","sourceRoot":"","sources":["../../src/gir/callback.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAChH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AAWrE;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAa,EAAe,EAAE;IAC3D,MAAM,cAAc,GAAG,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACnD,MAAM,cAAc,GAAG,UAAU,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAC/D,OAAO;QACH,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;QAC9B,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC;QAC3B,UAAU,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAClF,WAAW,EAAE,mBAAmB,CAAC,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAC/D,cAAc,EAAE,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,KAAK,GAAG;KACvD,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { type GirField } from "./field.js";
2
+ import { type GirFunction } from "./function.js";
3
+ import { type RawNode } from "./parse.js";
4
+ import { type GirProperty } from "./property.js";
5
+ import { type GirSignal } from "./signal.js";
6
+ /** A `<class>` or `<interface>` declaration. */
7
+ export type GirClass = {
8
+ /** Local name inside the namespace (no prefix). */
9
+ readonly name: string;
10
+ readonly cType: string | undefined;
11
+ /** GIR `parent`, possibly cross-namespace (e.g. `"GObject.InitiallyUnowned"`). */
12
+ readonly parent: string | undefined;
13
+ /** GLib type name (e.g. `"GtkWidget"`). */
14
+ readonly glibTypeName: string | undefined;
15
+ /** C symbol that returns the GType integer (e.g. `"gtk_widget_get_type"`). */
16
+ readonly glibGetType: string | undefined;
17
+ /** Local record name that holds this class's vtable (`glib:type-struct`). */
18
+ readonly glibTypeStruct: string | undefined;
19
+ /** Glib ref/unref/etc. function names on fundamentals; not used for GObject subclasses. */
20
+ readonly glibRefFunc: string | undefined;
21
+ readonly glibUnrefFunc: string | undefined;
22
+ readonly glibSetValueFunc: string | undefined;
23
+ readonly glibGetValueFunc: string | undefined;
24
+ /** `glib:fundamental="1"` — a non-GObject fundamental type (e.g. `GdkEvent`, `GskRenderNode`). */
25
+ readonly fundamental: boolean;
26
+ readonly abstract: boolean;
27
+ readonly final: boolean;
28
+ readonly isInterface: boolean;
29
+ readonly introspectable: boolean;
30
+ /** Names of interfaces this class implements (cross-namespace possible). */
31
+ readonly implements: readonly string[];
32
+ /** Names of interfaces a `<interface>` requires (`<prerequisite>` elements). */
33
+ readonly prerequisites: readonly string[];
34
+ readonly methods: readonly GirFunction[];
35
+ readonly constructors: readonly GirFunction[];
36
+ readonly functions: readonly GirFunction[];
37
+ readonly virtualMethods: readonly GirFunction[];
38
+ readonly properties: readonly GirProperty[];
39
+ readonly signals: readonly GirSignal[];
40
+ readonly fields: readonly GirField[];
41
+ };
42
+ /**
43
+ * Builds a {@link GirClass} from a `<class>` or `<interface>` element.
44
+ *
45
+ * @param node - The XML element
46
+ * @param isInterface - `true` when the source element was `<interface>`
47
+ */
48
+ export declare const classFromNode: (node: RawNode, isInterface: boolean) => GirClass;
49
+ //# sourceMappingURL=class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/gir/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,e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,EAAE,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IACzC,QAAQ,CAAC,YAAY,EAAE,SAAS,WAAW,EAAE,CAAC;IAC9C,QAAQ,CAAC,SAAS,EAAE,SAAS,WAAW,EAAE,CAAC;IAC3C,QAAQ,CAAC,cAAc,EAAE,SAAS,WAAW,EAAE,CAAC;IAChD,QAAQ,CAAC,UAAU,EAAE,SAAS,WAAW,EAAE,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC;CACxC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,OAAO,EAAE,aAAa,OAAO,KAAG,QA6BlE,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { fieldFromNode } from "./field.js";
2
+ import { functionFromNode } from "./function.js";
3
+ import { attr, attrBool, childrenOf, GIR_CONSTRUCTOR_TAG } from "./parse.js";
4
+ import { propertyFromNode } from "./property.js";
5
+ import { signalFromNode } from "./signal.js";
6
+ /**
7
+ * Builds a {@link GirClass} from a `<class>` or `<interface>` element.
8
+ *
9
+ * @param node - The XML element
10
+ * @param isInterface - `true` when the source element was `<interface>`
11
+ */
12
+ export const classFromNode = (node, isInterface) => ({
13
+ name: attr(node, "name") ?? "",
14
+ cType: attr(node, "c:type"),
15
+ parent: attr(node, "parent"),
16
+ glibTypeName: attr(node, "glib:type-name"),
17
+ glibGetType: attr(node, "glib:get-type"),
18
+ glibTypeStruct: attr(node, "glib:type-struct"),
19
+ glibRefFunc: attr(node, "glib:ref-func"),
20
+ glibUnrefFunc: attr(node, "glib:unref-func"),
21
+ glibSetValueFunc: attr(node, "glib:set-value-func"),
22
+ glibGetValueFunc: attr(node, "glib:get-value-func"),
23
+ fundamental: attrBool(node, "glib:fundamental"),
24
+ abstract: attrBool(node, "abstract"),
25
+ final: attrBool(node, "final"),
26
+ isInterface,
27
+ introspectable: attr(node, "introspectable") !== "0",
28
+ implements: childrenOf(node, "implements")
29
+ .map((implement) => attr(implement, "name"))
30
+ .filter((name) => name !== undefined),
31
+ prerequisites: childrenOf(node, "prerequisite")
32
+ .map((prerequisite) => attr(prerequisite, "name"))
33
+ .filter((name) => name !== undefined),
34
+ methods: childrenOf(node, "method").map((method) => functionFromNode(method, "method")),
35
+ constructors: childrenOf(node, GIR_CONSTRUCTOR_TAG).map((ctor) => functionFromNode(ctor, "constructor")),
36
+ functions: childrenOf(node, "function").map((function_) => functionFromNode(function_, "function")),
37
+ virtualMethods: childrenOf(node, "virtual-method").map((vmethod) => functionFromNode(vmethod, "virtual-method")),
38
+ properties: childrenOf(node, "property").map(propertyFromNode),
39
+ signals: childrenOf(node, "glib:signal").map(signalFromNode),
40
+ fields: childrenOf(node, "field").map(fieldFromNode),
41
+ });
42
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/gir/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAoB,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,mBAAmB,EAAgB,MAAM,YAAY,CAAC;AAC3F,OAAO,EAAoB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAkB,cAAc,EAAE,MAAM,aAAa,CAAC;AAuC7D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAa,EAAE,WAAoB,EAAY,EAAE,CAAC,CAAC;IAC7E,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;IAC9B,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC;IAC3B,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAA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AC,CAAC;IACvF,YAAY,EAAE,UAAU,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IACxG,SAAS,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACnG,cAAc,EAAE,UAAU,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IAChH,UAAU,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAC9D,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC;IAC5D,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC;CACvD,CAAC,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { type GirFunction } from "./function.js";
2
+ import { type RawNode } from "./parse.js";
3
+ /** A single `<member>` of an `<enumeration>` or `<bitfield>`. */
4
+ type EnumMember = {
5
+ /** GIR `name`, snake_case lowercase (e.g. `"fill"`). */
6
+ readonly name: string;
7
+ /** GIR `c:identifier`, SCREAMING_SNAKE_CASE (e.g. `"GTK_ALIGN_FILL"`). */
8
+ readonly cIdentifier: string | undefined;
9
+ /** Numeric value as a string; preserved verbatim from GIR. */
10
+ readonly value: string;
11
+ };
12
+ /** Discriminator for enums vs bitfields. */
13
+ export type EnumKind = "enumeration" | "bitfield";
14
+ /** An `<enumeration>` or `<bitfield>` declaration. */
15
+ export type GirEnum = {
16
+ readonly kind: EnumKind;
17
+ /** Local name within the namespace (no namespace prefix). */
18
+ readonly name: string;
19
+ readonly cType: string | undefined;
20
+ /** GLib type name (e.g. `"GtkAlign"`); absent for unregistered enums. */
21
+ readonly glibTypeName: string | undefined;
22
+ /** GLib get-type C symbol; absent for unregistered enums. */
23
+ readonly glibGetType: string | undefined;
24
+ /** Optional `glib:error-domain` marker; presence flips emission to `createErrorDomain`. */
25
+ readonly errorDomain: string | undefined;
26
+ readonly introspectable: boolean;
27
+ readonly members: readonly EnumMember[];
28
+ /** Free functions nested inside the enum (e.g. error quark accessors). */
29
+ readonly functions: readonly GirFunction[];
30
+ };
31
+ /**
32
+ * Builds a {@link GirEnum} from an `<enumeration>` or `<bitfield>` element.
33
+ *
34
+ * @param node - The XML element
35
+ * @param kind - `"enumeration"` or `"bitfield"`, matching the element name
36
+ */
37
+ export declare const enumFromNode: (node: RawNode, kind: EnumKind) => GirEnum;
38
+ export {};
39
+ //# sourceMappingURL=enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../src/gir/enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5D,iEAAiE;AACjE,KAAK,UAAU,GAAG;IACd,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,QAAQ,GAAG,aAAa,GAAG,UAAU,CAAC;AAElD,sDAAsD;AACtD,MAAM,MAAM,OAAO,GAAG;IAClB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,yEAAyE;IACzE,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,6DAA6D;IAC7D,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,2FAA2F;IAC3F,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IACxC,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,SAAS,WAAW,EAAE,CAAC;CAC9C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,OAAO,EAAE,MAAM,QAAQ,KAAG,OAc3D,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { functionFromNode } from "./function.js";
2
+ import { attr, childrenOf } from "./parse.js";
3
+ /**
4
+ * Builds a {@link GirEnum} from an `<enumeration>` or `<bitfield>` element.
5
+ *
6
+ * @param node - The XML element
7
+ * @param kind - `"enumeration"` or `"bitfield"`, matching the element name
8
+ */
9
+ export const enumFromNode = (node, kind) => ({
10
+ kind,
11
+ name: attr(node, "name") ?? "",
12
+ cType: attr(node, "c:type"),
13
+ glibTypeName: attr(node, "glib:type-name"),
14
+ glibGetType: attr(node, "glib:get-type"),
15
+ errorDomain: attr(node, "glib:error-domain"),
16
+ introspectable: attr(node, "introspectable") !== "0",
17
+ members: childrenOf(node, "member").map((member) => ({
18
+ name: attr(member, "name") ?? "",
19
+ cIdentifier: attr(member, "c:identifier"),
20
+ value: attr(member, "value") ?? "0",
21
+ })),
22
+ functions: childrenOf(node, "function").map((function_) => functionFromNode(function_, "function")),
23
+ });
24
+ //# sourceMappingURL=enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/gir/enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAoB,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AAiC5D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAa,EAAE,IAAc,EAAW,EAAE,CAAC,CAAC;IACrE,IAAI;IACJ,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;IAC9B,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC;IAC3B,YAAY,EAAE,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAC1C,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC;IACxC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC;IAC5C,cAAc,EAAE,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,KAAK,GAAG;IACpD,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACjD,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE;QAChC,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC;QACzC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,GAAG;KACtC,CAAC,CAAC;IACH,SAAS,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;CACtG,CAAC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { type RawNode } from "./parse.js";
2
+ import { type GirTypeRef } from "./type-ref.js";
3
+ /**
4
+ * A `<field>` inside a class, interface, record, or union.
5
+ *
6
+ * Vtable slots (fields holding `<callback>` children inside a
7
+ * `glib:is-gtype-struct-for` record) keep `callback` populated; ordinary
8
+ * data fields keep `type`. The two are mutually exclusive.
9
+ */
10
+ export type GirField = {
11
+ /** GIR field name, snake_case. */
12
+ readonly name: string;
13
+ /** Field type, or `undefined` when the field is a vtable callback slot. */
14
+ readonly type: GirTypeRef | undefined;
15
+ /** Inline callback for vtable slots; `undefined` for data fields. */
16
+ readonly callback: RawNode | undefined;
17
+ readonly readable: boolean;
18
+ readonly writable: boolean;
19
+ readonly private: boolean;
20
+ /** GIR `bits` attribute width when the field is a bitfield member. */
21
+ readonly bits: number | undefined;
22
+ };
23
+ /**
24
+ * Builds a {@link GirField} from a `<field>` element.
25
+ */
26
+ export declare const fieldFromNode: (node: RawNode) => GirField;
27
+ //# sourceMappingURL=field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/gir/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,KAAK,UAAU,EAAmB,MAAM,eAAe,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG;IACnB,kCAAkC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IACtC,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,OAAO,KAAG,QAY7C,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { attr, attrBool, childOf } from "./parse.js";
2
+ import { typeRefFromSlot } from "./type-ref.js";
3
+ /**
4
+ * Builds a {@link GirField} from a `<field>` element.
5
+ */
6
+ export const fieldFromNode = (node) => {
7
+ const callback = childOf(node, "callback");
8
+ const bitsAttr = attr(node, "bits");
9
+ return {
10
+ name: attr(node, "name") ?? "",
11
+ type: callback === undefined ? typeRefFromSlot(node) : undefined,
12
+ callback,
13
+ readable: attrBool(node, "readable", true),
14
+ writable: attrBool(node, "writable", false),
15
+ private: attrBool(node, "private", false),
16
+ bits: bitsAttr === undefined ? undefined : Number.parseInt(bitsAttr, 10),
17
+ };
18
+ };
19
+ //# sourceMappingURL=field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.js","sourceRoot":"","sources":["../../src/gir/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAgB,MAAM,YAAY,CAAC;AACnE,OAAO,EAAmB,eAAe,EAAE,MAAM,eAAe,CAAC;AAuBjE;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAa,EAAY,EAAE;IACrD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,OAAO;QACH,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;QAC9B,IAAI,EAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;QAChE,QAAQ;QACR,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC;QAC1C,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC;QAC3C,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC;QACzC,IAAI,EAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC;KAC3E,CAAC;AACN,CAAC,CAAC"}