@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
package/dist/runner.js ADDED
@@ -0,0 +1,60 @@
1
+ import { generateNamespaceModule } from "./ffi/pipeline.js";
2
+ import { computeFingerprint } from "./fingerprint.js";
3
+ import { writeGiStore } from "./gi-store.js";
4
+ import { loadGirRepository } from "./gir/repository.js";
5
+ import { writeJsxStore } from "./jsx-store.js";
6
+ import { generateReactFiles } from "./react/pipeline.js";
7
+ /**
8
+ * Single-entry orchestrator for the GTKX codegen.
9
+ *
10
+ * Loads the GIR repository, runs the FFI pipeline per namespace, runs the
11
+ * React pipeline once, and materializes the self-contained `@gtkx/gi` (and
12
+ * optional `@gtkx/react-jsx`) packages into the project's `node_modules`.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { CodegenRunner } from "@gtkx/codegen";
17
+ *
18
+ * await new CodegenRunner({
19
+ * libraries: ["Gtk-4.0", "Adw-1"],
20
+ * girPath: ["/usr/share/gir-1.0"],
21
+ * gi: { storeDir, linkDir, realFfiDir, realNativeDir, version },
22
+ * }).run();
23
+ * ```
24
+ */
25
+ export class CodegenRunner {
26
+ options;
27
+ constructor(options) {
28
+ this.options = options;
29
+ }
30
+ /**
31
+ * Executes the full codegen pipeline and materializes the output packages.
32
+ */
33
+ async run() {
34
+ const start = Date.now();
35
+ const repository = loadGirRepository(this.options.libraries, this.options.girPath);
36
+ const namespaces = [];
37
+ for (const namespace of repository.namespaces.values()) {
38
+ const { source } = generateNamespaceModule(namespace, repository);
39
+ namespaces.push({ directory: namespace.name.toLowerCase(), rawSource: source });
40
+ }
41
+ const libraries = [...this.options.libraries];
42
+ writeGiStore(this.options.gi, namespaces, {
43
+ value: computeFingerprint(repository.girFiles, libraries),
44
+ girFiles: repository.girFiles,
45
+ libraries,
46
+ });
47
+ let widgetCount = 0;
48
+ if (this.options.jsx !== undefined) {
49
+ const reactPipeline = generateReactFiles(repository, this.options.slotProps);
50
+ writeJsxStore(this.options.jsx, reactPipeline.files);
51
+ widgetCount = reactPipeline.widgetCount;
52
+ }
53
+ return {
54
+ namespaces: repository.namespaces.size,
55
+ widgets: widgetCount,
56
+ duration: Date.now() - start,
57
+ };
58
+ }
59
+ }
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EAAE;YACtC,KAAK,EAAE,kBAAkB,CAAC,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC;YACzD,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,SAAS;SACZ,CAAC,CAAC;QAEH,IAAI,WAAW,GAAG,CAAC,CAAC;QACpB,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,aAAa,GAAG,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAC7E,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;YACrD,WAAW,GAAG,aAAa,CAAC,WAAW,CAAC;QAC5C,CAAC;QAED,OAAO;YACH,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,IAAI;YACtC,OAAO,EAAE,WAAW;YACpB,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;SAC/B,CAAC;IACN,CAAC;CACJ"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Filesystem primitives shared by the injected-package assemblers
3
+ * ({@link ../gi-store.js}, {@link ../jsx-store.js}).
4
+ */
5
+ /**
6
+ * Fields every injected-package store assembler needs: where the hidden store
7
+ * lives, the visible alias symlink, and the version stamped onto its manifest.
8
+ */
9
+ export type StoreOptions = {
10
+ /** Absolute path to the hidden store directory (e.g. `node_modules/.gtkx/gi`). */
11
+ readonly storeDir: string;
12
+ /** Absolute path to the visible alias symlink (e.g. `node_modules/@gtkx/gi`). */
13
+ readonly linkDir: string;
14
+ /** Version string copied onto the emitted package's `package.json`. */
15
+ readonly version: string;
16
+ };
17
+ /** A transpilable source destined for the store, addressed by output stem. */
18
+ export type StoreFile = {
19
+ /** Output path without extension, relative to the store root. */
20
+ readonly stem: string;
21
+ /** Source filename TypeScript uses for diagnostics. */
22
+ readonly fileName: string;
23
+ /** The TypeScript source to transpile and write. */
24
+ readonly source: string;
25
+ };
26
+ /** A symlink to create inside the store's own bundled `node_modules`. */
27
+ export type StoreSymlink = {
28
+ /** Path segments under the store root the symlink is created at. */
29
+ readonly segments: readonly string[];
30
+ /** Absolute symlink target, or `"self"` for the store root itself. */
31
+ readonly target: string | "self";
32
+ };
33
+ /**
34
+ * Assembles a store in a fresh temp directory and atomically swaps it into
35
+ * place: writes every file pair, the `package.json`, the bundled
36
+ * `node_modules` symlinks, then promotes the temp tree and re-points the
37
+ * visible alias. An optional {@link WriteStoreParams.validate} runs against the
38
+ * temp root before any file is written, so a failure aborts before the store
39
+ * goes live.
40
+ *
41
+ * @param params - {@link WriteStoreParams}
42
+ */
43
+ export declare const writeStore: (params: WriteStoreParams) => void;
44
+ /** Inputs for {@link writeStore}. */
45
+ export type WriteStoreParams = {
46
+ /** Absolute hidden store directory. */
47
+ readonly storeDir: string;
48
+ /** Absolute visible alias symlink. */
49
+ readonly linkDir: string;
50
+ /** The source files to transpile and write. */
51
+ readonly files: readonly StoreFile[];
52
+ /** The `package.json` manifest to serialize. */
53
+ readonly manifest: unknown;
54
+ /** The bundled `node_modules` symlinks to create. */
55
+ readonly symlinks: readonly StoreSymlink[];
56
+ /** Verbatim files (e.g. a fingerprint sentinel) written under the store root. */
57
+ readonly rawFiles?: readonly {
58
+ readonly relativePath: string;
59
+ readonly content: string;
60
+ }[];
61
+ /** Optional in-memory validation run on the temp root before files are written. */
62
+ readonly validate?: (tmp: string) => void;
63
+ };
64
+ /**
65
+ * Transpiles `source` and writes the resulting `.js`/`.d.ts` pair at `stem`
66
+ * (relative to `storeDir`), creating parent directories as needed.
67
+ *
68
+ * @param storeDir - Absolute store root the file is written under
69
+ * @param stem - Output path without extension, relative to `storeDir`
70
+ * @param fileName - Source filename TypeScript uses for diagnostics
71
+ * @param source - The TypeScript source to transpile
72
+ */
73
+ export declare const writeFilePair: (storeDir: string, stem: string, fileName: string, source: string) => void;
74
+ /**
75
+ * Creates (or replaces) a relative directory symlink at `linkPath` pointing at
76
+ * `realTarget`. Relative so the link survives the store being moved or cached.
77
+ *
78
+ * @param linkPath - Absolute path of the symlink to create
79
+ * @param realTarget - Absolute path the symlink resolves to
80
+ */
81
+ export declare const symlinkRelative: (linkPath: string, realTarget: string) => void;
82
+ /**
83
+ * Writes a pretty-printed `package.json` into `storeDir`.
84
+ *
85
+ * @param storeDir - Absolute directory to write `package.json` into
86
+ * @param manifest - The manifest object to serialize
87
+ */
88
+ export declare const writePackageJson: (storeDir: string, manifest: unknown) => void;
89
+ /**
90
+ * Swaps a fully-assembled temp store into place and re-points the visible alias
91
+ * at it.
92
+ *
93
+ * The live store is renamed aside and the temp store renamed in before the old
94
+ * tree is deleted, so the store is unavailable only for the duration of a single
95
+ * rename instead of a full recursive delete. Not safe against a second codegen
96
+ * run swapping the same store concurrently.
97
+ *
98
+ * @param tmp - Absolute temp store directory to promote
99
+ * @param storeDir - Absolute final store directory
100
+ * @param visibleLink - Absolute path of the visible alias symlink
101
+ */
102
+ export declare const swapStore: (tmp: string, storeDir: string, visibleLink: string) => void;
103
+ /**
104
+ * Creates a fresh, per-run temporary store directory next to `storeDir` and
105
+ * returns its path. The random suffix isolates concurrent or repeated runs so
106
+ * they cannot corrupt each other's in-progress trees.
107
+ */
108
+ export declare const tempStoreFor: (storeDir: string) => string;
109
+ //# sourceMappingURL=store-fs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-fs.d.ts","sourceRoot":"","sources":["../src/store-fs.ts"],"names":[],"mappings":"AAIA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACvB,kFAAkF;IAClF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,iFAAiF;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,SAAS,GAAG;IACpB,iEAAiE;IACjE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EF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,YAAY,MAAM,KAAG,IAItE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,EAAE,UAAU,OAAO,KAAG,IAEtE,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,EAAE,UAAU,MAAM,EAAE,aAAa,MAAM,KAAG,IAS9E,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,KAAG,MAG/C,CAAC"}
@@ -0,0 +1,98 @@
1
+ import { existsSync, mkdirSync, mkdtempSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
2
+ import { dirname, join, relative } from "node:path";
3
+ import { transpileSource } from "./transpile.js";
4
+ /**
5
+ * Assembles a store in a fresh temp directory and atomically swaps it into
6
+ * place: writes every file pair, the `package.json`, the bundled
7
+ * `node_modules` symlinks, then promotes the temp tree and re-points the
8
+ * visible alias. An optional {@link WriteStoreParams.validate} runs against the
9
+ * temp root before any file is written, so a failure aborts before the store
10
+ * goes live.
11
+ *
12
+ * @param params - {@link WriteStoreParams}
13
+ */
14
+ export const writeStore = (params) => {
15
+ const tmp = tempStoreFor(params.storeDir);
16
+ params.validate?.(tmp);
17
+ for (const file of params.files) {
18
+ writeFilePair(tmp, file.stem, file.fileName, file.source);
19
+ }
20
+ writePackageJson(tmp, params.manifest);
21
+ for (const raw of params.rawFiles ?? []) {
22
+ writeFileSync(join(tmp, raw.relativePath), raw.content);
23
+ }
24
+ for (const { segments, target } of params.symlinks) {
25
+ symlinkRelative(join(tmp, ...segments), target === "self" ? tmp : target);
26
+ }
27
+ swapStore(tmp, params.storeDir, params.linkDir);
28
+ };
29
+ /**
30
+ * Transpiles `source` and writes the resulting `.js`/`.d.ts` pair at `stem`
31
+ * (relative to `storeDir`), creating parent directories as needed.
32
+ *
33
+ * @param storeDir - Absolute store root the file is written under
34
+ * @param stem - Output path without extension, relative to `storeDir`
35
+ * @param fileName - Source filename TypeScript uses for diagnostics
36
+ * @param source - The TypeScript source to transpile
37
+ */
38
+ export const writeFilePair = (storeDir, stem, fileName, source) => {
39
+ const { js, dts } = transpileSource(fileName, source);
40
+ const jsPath = join(storeDir, `${stem}.js`);
41
+ mkdirSync(dirname(jsPath), { recursive: true });
42
+ writeFileSync(jsPath, js);
43
+ writeFileSync(join(storeDir, `${stem}.d.ts`), dts);
44
+ };
45
+ /**
46
+ * Creates (or replaces) a relative directory symlink at `linkPath` pointing at
47
+ * `realTarget`. Relative so the link survives the store being moved or cached.
48
+ *
49
+ * @param linkPath - Absolute path of the symlink to create
50
+ * @param realTarget - Absolute path the symlink resolves to
51
+ */
52
+ export const symlinkRelative = (linkPath, realTarget) => {
53
+ mkdirSync(dirname(linkPath), { recursive: true });
54
+ rmSync(linkPath, { recursive: true, force: true });
55
+ symlinkSync(relative(dirname(linkPath), realTarget), linkPath, "dir");
56
+ };
57
+ /**
58
+ * Writes a pretty-printed `package.json` into `storeDir`.
59
+ *
60
+ * @param storeDir - Absolute directory to write `package.json` into
61
+ * @param manifest - The manifest object to serialize
62
+ */
63
+ export const writePackageJson = (storeDir, manifest) => {
64
+ writeFileSync(join(storeDir, "package.json"), `${JSON.stringify(manifest, null, 2)}\n`);
65
+ };
66
+ /**
67
+ * Swaps a fully-assembled temp store into place and re-points the visible alias
68
+ * at it.
69
+ *
70
+ * The live store is renamed aside and the temp store renamed in before the old
71
+ * tree is deleted, so the store is unavailable only for the duration of a single
72
+ * rename instead of a full recursive delete. Not safe against a second codegen
73
+ * run swapping the same store concurrently.
74
+ *
75
+ * @param tmp - Absolute temp store directory to promote
76
+ * @param storeDir - Absolute final store directory
77
+ * @param visibleLink - Absolute path of the visible alias symlink
78
+ */
79
+ export const swapStore = (tmp, storeDir, visibleLink) => {
80
+ const previous = `${storeDir}.old`;
81
+ rmSync(previous, { recursive: true, force: true });
82
+ if (existsSync(storeDir)) {
83
+ renameSync(storeDir, previous);
84
+ }
85
+ renameSync(tmp, storeDir);
86
+ rmSync(previous, { recursive: true, force: true });
87
+ symlinkRelative(visibleLink, storeDir);
88
+ };
89
+ /**
90
+ * Creates a fresh, per-run temporary store directory next to `storeDir` and
91
+ * returns its path. The random suffix isolates concurrent or repeated runs so
92
+ * they cannot corrupt each other's in-progress trees.
93
+ */
94
+ export const tempStoreFor = (storeDir) => {
95
+ mkdirSync(dirname(storeDir), { recursive: true });
96
+ return mkdtempSync(`${storeDir}.tmp-`);
97
+ };
98
+ //# sourceMappingURL=store-fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-fs.js","sourceRoot":"","sources":["../src/store-fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7G,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAsCjD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAwB,EAAQ,EAAE;IACzD,MAAM,GAAG,GAAG,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IACvB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC9B,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC;IACD,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,QAAQ,IAAI,EAAE,EAAE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GAAG,QAAQ,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import ts from "typescript";
2
+ /**
3
+ * Output of a single TypeScript transpile: the stripped `.js` and the
4
+ * isolated-declaration `.d.ts` it produces.
5
+ */
6
+ export type TranspiledFile = {
7
+ /** Stripped-types JavaScript output. */
8
+ readonly js: string;
9
+ /** Generated TypeScript declaration output. */
10
+ readonly dts: string;
11
+ };
12
+ /**
13
+ * The compiler options shared by the store's two TypeScript passes — the
14
+ * single-file transpile here and the overlay type-check in `typecheck-store.ts`.
15
+ * Each pass spreads these and adds its own emit/check-specific keys.
16
+ */
17
+ export declare const baseCompilerOptions: () => ts.CompilerOptions;
18
+ /**
19
+ * Transpiles a single TypeScript source string to a `.js` / `.d.ts` pair.
20
+ *
21
+ * Uses `ts.transpileModule` for the JS half (type-stripping only, no
22
+ * type checking) and `ts.transpileDeclaration` for the declaration half
23
+ * (single-file declaration emit). Generated sources annotate every export
24
+ * for isolated-declaration emit, so `transpileDeclaration` always
25
+ * succeeds; an error-category diagnostic from it represents a writer bug
26
+ * and is surfaced rather than swallowed.
27
+ *
28
+ * @param fileName - Source filename, used by TS for path resolution
29
+ * @param source - The TypeScript source string
30
+ */
31
+ export declare const transpileSource: (fileName: string, source: string) => TranspiledFile;
32
+ //# sourceMappingURL=transpile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transpile.d.ts","sourceRoot":"","sources":["../src/transpile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IACzB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAO,EAAE,CAAC,eAOxC,CAAC;AAWH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,cA8BlE,CAAC"}
@@ -0,0 +1,63 @@
1
+ import ts from "typescript";
2
+ /**
3
+ * The compiler options shared by the store's two TypeScript passes — the
4
+ * single-file transpile here and the overlay type-check in `typecheck-store.ts`.
5
+ * Each pass spreads these and adds its own emit/check-specific keys.
6
+ */
7
+ export const baseCompilerOptions = () => ({
8
+ module: ts.ModuleKind.ESNext,
9
+ moduleResolution: ts.ModuleResolutionKind.Bundler,
10
+ target: ts.ScriptTarget.ESNext,
11
+ skipLibCheck: true,
12
+ jsx: ts.JsxEmit.ReactJSX,
13
+ jsxImportSource: "react",
14
+ });
15
+ const COMPILER_OPTIONS = {
16
+ ...baseCompilerOptions(),
17
+ declaration: true,
18
+ skipDefaultLibCheck: true,
19
+ removeComments: false,
20
+ sourceMap: false,
21
+ declarationMap: false,
22
+ };
23
+ /**
24
+ * Transpiles a single TypeScript source string to a `.js` / `.d.ts` pair.
25
+ *
26
+ * Uses `ts.transpileModule` for the JS half (type-stripping only, no
27
+ * type checking) and `ts.transpileDeclaration` for the declaration half
28
+ * (single-file declaration emit). Generated sources annotate every export
29
+ * for isolated-declaration emit, so `transpileDeclaration` always
30
+ * succeeds; an error-category diagnostic from it represents a writer bug
31
+ * and is surfaced rather than swallowed.
32
+ *
33
+ * @param fileName - Source filename, used by TS for path resolution
34
+ * @param source - The TypeScript source string
35
+ */
36
+ export const transpileSource = (fileName, source) => {
37
+ const jsResult = ts.transpileModule(source, {
38
+ compilerOptions: COMPILER_OPTIONS,
39
+ fileName,
40
+ reportDiagnostics: false,
41
+ });
42
+ const dtsResult = ts.transpileDeclaration(source, {
43
+ compilerOptions: COMPILER_OPTIONS,
44
+ fileName,
45
+ });
46
+ const errorDiagnostics = (dtsResult.diagnostics ?? []).filter((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error);
47
+ if (errorDiagnostics.length > 0) {
48
+ const messages = errorDiagnostics
49
+ .slice(0, 5)
50
+ .map((diagnostic) => {
51
+ const text = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
52
+ if (diagnostic.file && diagnostic.start !== undefined) {
53
+ const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
54
+ return `[${line + 1}:${character + 1}] ${text}`;
55
+ }
56
+ return text;
57
+ })
58
+ .join("\n");
59
+ throw new Error(`transpileDeclaration produced ${errorDiagnostics.length} diagnostic(s) for ${fileName}:\n${messages}`);
60
+ }
61
+ return { js: jsResult.outputText, dts: dtsResult.outputText };
62
+ };
63
+ //# sourceMappingURL=transpile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transpile.js","sourceRoot":"","sources":["../src/transpile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAa5B;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAuB,EAAE,CAAC,CAAC;IAC1D,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM;IAC5B,gBAAgB,EAAE,EAAE,CAAC,oBAAoB,CAAC,OAAO;IACjD,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM;IAC9B,YAAY,EAAE,IAAI;IAClB,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ;IACxB,eAAe,EAAE,OAAO;CAC3B,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAuB;IACzC,GAAG,mBAAmB,EAAE;IACxB,WAAW,EAAE,IAAI;IACjB,mBAAmB,EAAE,IAAI;IACzB,cAAc,EAAE,KAAK;IACrB,SAAS,EAAE,KAAK;IAChB,cAAc,EAAE,KAAK;CACxB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAE,MAAc,EAAkB,EAAE;IAChF,MAAM,QAAQ,GAAG,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE;QACxC,eAAe,EAAE,gBAAgB;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
@@ -0,0 +1,41 @@
1
+ /**
2
+ * One in-memory source destined for the injected `@gtkx/gi` store, plus whether
3
+ * it is a hand-written overlay (the type-check target) or a generated module
4
+ * declaration (checked against, but not reported on).
5
+ */
6
+ export type StoreSourceFile = {
7
+ /** Absolute virtual path of the source, under the store root. */
8
+ readonly path: string;
9
+ /** TypeScript source text (overlay `.ts`) or declaration text (generated `.d.ts`). */
10
+ readonly source: string;
11
+ /** Whether this is a hand-written overlay/augment source. */
12
+ readonly overlay: boolean;
13
+ };
14
+ /**
15
+ * Source entries the overlay type-check resolves the runtime packages to.
16
+ */
17
+ export type RuntimeEntries = {
18
+ /** Absolute path to `@gtkx/ffi`'s source entry (`src/index.ts`). */
19
+ readonly ffiEntry: string;
20
+ /** Absolute path to `@gtkx/native`'s declaration entry (`dist/index.d.ts`). */
21
+ readonly nativeEntry: string;
22
+ };
23
+ /**
24
+ * Type-checks the hand-written overlay sources against the freshly generated
25
+ * `@gtkx/gi` declarations, entirely in memory.
26
+ *
27
+ * The overlay augments generated classes (e.g. installs `Value.prototype.getBoxed`),
28
+ * so its correctness is only meaningful relative to the exact API codegen just
29
+ * produced. A {@link ts.Program} is assembled over the in-memory generated
30
+ * declarations and overlay sources, resolving `@gtkx/gi/*` to the generated
31
+ * declarations and `@gtkx/ffi` to its package source; every other specifier
32
+ * (`react`, lib files) resolves from the real filesystem. Semantic errors on the
33
+ * overlay sources abort codegen rather than ship broken bindings.
34
+ *
35
+ * @param storeRoot - Absolute root the virtual source paths are rooted at.
36
+ * @param files - The in-memory generated declarations and overlay sources.
37
+ * @param entries - Absolute source entries for `@gtkx/ffi` and `@gtkx/native`.
38
+ * @throws When any overlay source has a semantic type error.
39
+ */
40
+ export declare const typecheckGiStore: (storeRoot: string, files: readonly StoreSourceFile[], entries: RuntimeEntries) => void;
41
+ //# sourceMappingURL=typecheck-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typecheck-store.d.ts","sourceRoot":"","sources":["../src/typecheck-store.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sFAAsF;IACtF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC7B,CAAC;AAYF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IACzB,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAChC,CAAC;AAsEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gBAAgB,GACzB,WAAW,MAAM,EACjB,OAAO,SAAS,eAAe,EAAE,EACjC,SAAS,cAAc,KACxB,IAOF,CAAC"}
@@ -0,0 +1,102 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import ts from "typescript";
4
+ import { baseCompilerOptions } from "./transpile.js";
5
+ const GI_SPECIFIER = "@gtkx/gi/";
6
+ const COMPILER_OPTIONS = {
7
+ ...baseCompilerOptions(),
8
+ customConditions: ["source"],
9
+ strict: true,
10
+ noEmit: true,
11
+ types: [],
12
+ };
13
+ const buildCompilerHost = (storeRoot, virtualSources, entries) => {
14
+ const readSource = (fileName) => virtualSources.get(fileName) ?? (existsSync(fileName) ? readFileSync(fileName, "utf8") : undefined);
15
+ const resolveInjected = (specifier) => {
16
+ if (specifier === "@gtkx/ffi")
17
+ return entries.ffiEntry;
18
+ if (specifier === "@gtkx/native")
19
+ return entries.nativeEntry;
20
+ if (!specifier.startsWith(GI_SPECIFIER))
21
+ return undefined;
22
+ const stem = specifier.slice(GI_SPECIFIER.length).replace(/\.js$/, "");
23
+ return [`${stem}.d.ts`, `${stem}.ts`, `${stem}/index.d.ts`, `${stem}/index.ts`]
24
+ .map((candidate) => join(storeRoot, candidate))
25
+ .find((candidate) => virtualSources.has(candidate));
26
+ };
27
+ const moduleResolutionHost = {
28
+ fileExists: (fileName) => virtualSources.has(fileName) || existsSync(fileName),
29
+ readFile: readSource,
30
+ };
31
+ return {
32
+ getSourceFile: (fileName, languageVersion) => {
33
+ const source = readSource(fileName);
34
+ return source === undefined ? undefined : ts.createSourceFile(fileName, source, languageVersion, true);
35
+ },
36
+ getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
37
+ writeFile: () => { },
38
+ getCurrentDirectory: () => storeRoot,
39
+ getCanonicalFileName: (fileName) => fileName,
40
+ useCaseSensitiveFileNames: () => true,
41
+ getNewLine: () => "\n",
42
+ fileExists: (fileName) => virtualSources.has(fileName) || existsSync(fileName),
43
+ readFile: readSource,
44
+ resolveModuleNameLiterals: (literals, containingFile, _redirectedReference, options) => literals.map((literal) => {
45
+ const injected = resolveInjected(literal.text);
46
+ if (injected !== undefined) {
47
+ return { resolvedModule: { resolvedFileName: injected, extension: ts.Extension.Ts } };
48
+ }
49
+ return {
50
+ resolvedModule: ts.resolveModuleName(literal.text, containingFile, options, moduleResolutionHost)
51
+ .resolvedModule,
52
+ };
53
+ }),
54
+ };
55
+ };
56
+ const reportOverlayErrors = (program, overlayPaths, storeRoot) => {
57
+ const errors = [];
58
+ for (const path of overlayPaths) {
59
+ const sourceFile = program.getSourceFile(path);
60
+ if (!sourceFile)
61
+ continue;
62
+ for (const diagnostic of program.getSemanticDiagnostics(sourceFile)) {
63
+ if (diagnostic.category === ts.DiagnosticCategory.Error)
64
+ errors.push(diagnostic);
65
+ }
66
+ }
67
+ if (errors.length === 0)
68
+ return;
69
+ const formatted = ts.formatDiagnosticsWithColorAndContext(errors, {
70
+ getCurrentDirectory: () => storeRoot,
71
+ getCanonicalFileName: (fileName) => fileName,
72
+ getNewLine: () => "\n",
73
+ });
74
+ throw new Error(`Overlay type-check failed against the generated @gtkx/gi API:\n${formatted}`);
75
+ };
76
+ /**
77
+ * Type-checks the hand-written overlay sources against the freshly generated
78
+ * `@gtkx/gi` declarations, entirely in memory.
79
+ *
80
+ * The overlay augments generated classes (e.g. installs `Value.prototype.getBoxed`),
81
+ * so its correctness is only meaningful relative to the exact API codegen just
82
+ * produced. A {@link ts.Program} is assembled over the in-memory generated
83
+ * declarations and overlay sources, resolving `@gtkx/gi/*` to the generated
84
+ * declarations and `@gtkx/ffi` to its package source; every other specifier
85
+ * (`react`, lib files) resolves from the real filesystem. Semantic errors on the
86
+ * overlay sources abort codegen rather than ship broken bindings.
87
+ *
88
+ * @param storeRoot - Absolute root the virtual source paths are rooted at.
89
+ * @param files - The in-memory generated declarations and overlay sources.
90
+ * @param entries - Absolute source entries for `@gtkx/ffi` and `@gtkx/native`.
91
+ * @throws When any overlay source has a semantic type error.
92
+ */
93
+ export const typecheckGiStore = (storeRoot, files, entries) => {
94
+ const overlayPaths = files.filter((file) => file.overlay).map((file) => file.path);
95
+ if (overlayPaths.length === 0)
96
+ return;
97
+ const virtualSources = new Map(files.map((file) => [file.path, file.source]));
98
+ const host = buildCompilerHost(storeRoot, virtualSources, entries);
99
+ const program = ts.createProgram({ rootNames: files.map((file) => file.path), options: COMPILER_OPTIONS, host });
100
+ reportOverlayErrors(program, overlayPaths, storeRoot);
101
+ };
102
+ //# sourceMappingURL=typecheck-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typecheck-store.js","sourceRoot":"","sources":["../src/typecheck-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAgBrD,MAAM,YAAY,GAAG,WAAW,CAAC;AAEjC,MAAM,gBAAgB,GAAuB;IACzC,GAAG,mBAAmB,EAAE;IACxB,gBAAgB,EAAE,CAAC,QAAQ,C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AAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnF,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IACtC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9E,MAAM,IAAI,GAAG,iBAAiB,CAAC,SAAS,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IACnE,MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;IACjH,mBAAmB,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;AAC1D,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { ModuleContext } from "../dsl/context.js";
2
+ import type { GirAlias } from "../gir/namespace.js";
3
+ /**
4
+ * Emits an `export type` declaration for a GIR `<alias>`.
5
+ *
6
+ * The alias is exported under {@link aliasExportName} — its GIR `name`, with
7
+ * GObject's `Type` published as `GType`.
8
+ *
9
+ * @param context - The module context
10
+ * @param alias - The alias to emit
11
+ */
12
+ export declare const emitAlias: (context: ModuleContext, alias: GirAlias) => void;
13
+ //# sourceMappingURL=alias.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alias.d.ts","sourceRoot":"","sources":["../../src/writers/alias.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GAAI,SAAS,aAAa,EAAE,OAAO,QAAQ,KAAG,IAInE,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { aliasExportName } from "../dsl/identifier.js";
2
+ import { renderTsType } from "./ts-type.js";
3
+ /**
4
+ * Emits an `export type` declaration for a GIR `<alias>`.
5
+ *
6
+ * The alias is exported under {@link aliasExportName} — its GIR `name`, with
7
+ * GObject's `Type` published as `GType`.
8
+ *
9
+ * @param context - The module context
10
+ * @param alias - The alias to emit
11
+ */
12
+ export const emitAlias = (context, alias) => {
13
+ const exportName = aliasExportName(context.namespace.name, alias.name);
14
+ const targetType = renderTsType(context, alias.target);
15
+ context.module.appendDeclaration(`export type ${exportName} = ${targetType};`);
16
+ };
17
+ //# sourceMappingURL=alias.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alias.js","sourceRoot":"","sources":["../../src/writers/alias.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAsB,EAAE,KAAe,EAAQ,EAAE;IACvE,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACvE,MAAM,UAAU,GAAG,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvD,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,eAAe,UAAU,MAAM,UAAU,GAAG,CAAC,CAAC;AACnF,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { GirFunction } from "../gir/function.js";
2
+ /**
3
+ * Detects the start half of a `Gio.AsyncReady` callable pair.
4
+ *
5
+ * Pairs follow two GIR conventions: an explicit `*_async` / `*_finish`
6
+ * suffix (the older style), or a base name paired with a `<root>_finish`
7
+ * (the modern GTK 4 style, e.g. `gtk_file_dialog_open` /
8
+ * `gtk_file_dialog_open_finish`).
9
+ *
10
+ * The runtime convention is to wrap the pair with `promisify(asyncFn,
11
+ * finishFn, cancellable, { leading })`. This detector returns the
12
+ * matching finish counterpart's GIR name when one exists in the same
13
+ * set of callables, so the class writer can wire the wrapper.
14
+ *
15
+ * @param fn - The candidate async-start callable
16
+ * @param siblings - Other callables on the same type to scan for the
17
+ * matching `*_finish`
18
+ * @returns The matching `*_finish` GIR name, or `undefined` when there is
19
+ * no pair
20
+ */
21
+ export declare const matchAsyncFinishName: (fn: GirFunction, siblings: readonly GirFunction[]) => string | undefined;
22
+ //# sourceMappingURL=async.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/writers/async.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,oBAAoB,GAAI,IAAI,WAAW,EAAE,UAAU,SAAS,WAAW,EAAE,KAAG,MAAM,GAAG,SAajG,CAAC"}