@gtkx/codegen 1.4.0 → 1.6.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 (180) hide show
  1. package/README.md +1 -1
  2. package/dist/analysis/descriptor-render.d.ts +1 -0
  3. package/dist/analysis/descriptor-render.d.ts.map +1 -1
  4. package/dist/analysis/descriptor-render.js +56 -28
  5. package/dist/analysis/descriptor-render.js.map +1 -1
  6. package/dist/analysis/descriptor.d.ts +3 -1
  7. package/dist/analysis/descriptor.d.ts.map +1 -1
  8. package/dist/analysis/descriptor.js +10 -9
  9. package/dist/analysis/descriptor.js.map +1 -1
  10. package/dist/compile.d.ts.map +1 -1
  11. package/dist/compile.js +24 -3
  12. package/dist/compile.js.map +1 -1
  13. package/dist/docs/api-reference.d.ts +2 -0
  14. package/dist/docs/api-reference.d.ts.map +1 -1
  15. package/dist/docs/api-reference.js +2 -1
  16. package/dist/docs/api-reference.js.map +1 -1
  17. package/dist/docs/pipeline.d.ts +3 -0
  18. package/dist/docs/pipeline.d.ts.map +1 -1
  19. package/dist/docs/pipeline.js +44 -12
  20. package/dist/docs/pipeline.js.map +1 -1
  21. package/dist/fingerprint.d.ts +3 -0
  22. package/dist/fingerprint.d.ts.map +1 -1
  23. package/dist/fingerprint.js +4 -0
  24. package/dist/fingerprint.js.map +1 -1
  25. package/dist/gi.d.ts +1 -0
  26. package/dist/gi.d.ts.map +1 -1
  27. package/dist/gi.js +4 -1
  28. package/dist/gi.js.map +1 -1
  29. package/dist/gir/libraries.d.ts +12 -5
  30. package/dist/gir/libraries.d.ts.map +1 -1
  31. package/dist/gir/libraries.js +50 -14
  32. package/dist/gir/libraries.js.map +1 -1
  33. package/dist/gir/library.d.ts +5 -0
  34. package/dist/gir/library.d.ts.map +1 -1
  35. package/dist/gir/library.js +6 -0
  36. package/dist/gir/library.js.map +1 -1
  37. package/dist/internal.d.ts +1 -0
  38. package/dist/internal.d.ts.map +1 -1
  39. package/dist/internal.js +1 -0
  40. package/dist/internal.js.map +1 -1
  41. package/dist/jsx.d.ts +1 -0
  42. package/dist/jsx.d.ts.map +1 -1
  43. package/dist/jsx.js +2 -0
  44. package/dist/jsx.js.map +1 -1
  45. package/dist/runner.d.ts +2 -0
  46. package/dist/runner.d.ts.map +1 -1
  47. package/dist/runner.js +3 -1
  48. package/dist/runner.js.map +1 -1
  49. package/dist/store/gi/bootstrap.d.ts +4 -0
  50. package/dist/store/gi/bootstrap.d.ts.map +1 -0
  51. package/dist/store/gi/bootstrap.js +48 -0
  52. package/dist/store/gi/bootstrap.js.map +1 -0
  53. package/dist/store/gi/class.d.ts.map +1 -1
  54. package/dist/store/gi/class.js +75 -28
  55. package/dist/store/gi/class.js.map +1 -1
  56. package/dist/store/gi/constructor-props.d.ts.map +1 -1
  57. package/dist/store/gi/constructor-props.js +2 -1
  58. package/dist/store/gi/constructor-props.js.map +1 -1
  59. package/dist/store/gi/enum.js +3 -3
  60. package/dist/store/gi/enum.js.map +1 -1
  61. package/dist/store/gi/folded.d.ts +14 -0
  62. package/dist/store/gi/folded.d.ts.map +1 -0
  63. package/dist/store/gi/folded.js +35 -0
  64. package/dist/store/gi/folded.js.map +1 -0
  65. package/dist/store/gi/function.d.ts.map +1 -1
  66. package/dist/store/gi/function.js +22 -3
  67. package/dist/store/gi/function.js.map +1 -1
  68. package/dist/store/gi/gtype-binding.d.ts.map +1 -1
  69. package/dist/store/gi/gtype-binding.js +11 -1
  70. package/dist/store/gi/gtype-binding.js.map +1 -1
  71. package/dist/store/gi/interface.d.ts.map +1 -1
  72. package/dist/store/gi/interface.js +43 -4
  73. package/dist/store/gi/interface.js.map +1 -1
  74. package/dist/store/gi/method.d.ts.map +1 -1
  75. package/dist/store/gi/method.js +2 -0
  76. package/dist/store/gi/method.js.map +1 -1
  77. package/dist/store/gi/pipeline.d.ts +5 -1
  78. package/dist/store/gi/pipeline.d.ts.map +1 -1
  79. package/dist/store/gi/pipeline.js +13 -1
  80. package/dist/store/gi/pipeline.js.map +1 -1
  81. package/dist/store/gi/property-accessor.js +1 -1
  82. package/dist/store/gi/property-accessor.js.map +1 -1
  83. package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
  84. package/dist/store/gi/record-field-accessor.js +3 -3
  85. package/dist/store/gi/record-field-accessor.js.map +1 -1
  86. package/dist/store/gi/record.d.ts.map +1 -1
  87. package/dist/store/gi/record.js +44 -12
  88. package/dist/store/gi/record.js.map +1 -1
  89. package/dist/store/gi/registration.js +2 -2
  90. package/dist/store/gi/registration.js.map +1 -1
  91. package/dist/store/gi/return-wrap.js +1 -1
  92. package/dist/store/gi/return-wrap.js.map +1 -1
  93. package/dist/store/gi/signal.d.ts.map +1 -1
  94. package/dist/store/gi/signal.js +7 -3
  95. package/dist/store/gi/signal.js.map +1 -1
  96. package/dist/store/gi/vtable.d.ts.map +1 -1
  97. package/dist/store/gi/vtable.js +1 -1
  98. package/dist/store/gi/vtable.js.map +1 -1
  99. package/dist/store/gi-store.d.ts +1 -0
  100. package/dist/store/gi-store.d.ts.map +1 -1
  101. package/dist/store/gi-store.js +16 -7
  102. package/dist/store/gi-store.js.map +1 -1
  103. package/dist/store/jsx/element-components.d.ts.map +1 -1
  104. package/dist/store/jsx/element-components.js +64 -10
  105. package/dist/store/jsx/element-components.js.map +1 -1
  106. package/dist/store/jsx/element-prop-types.d.ts +2 -0
  107. package/dist/store/jsx/element-prop-types.d.ts.map +1 -1
  108. package/dist/store/jsx/element-prop-types.js +2 -0
  109. package/dist/store/jsx/element-prop-types.js.map +1 -1
  110. package/dist/store/jsx/metadata.d.ts.map +1 -1
  111. package/dist/store/jsx/metadata.js +28 -1
  112. package/dist/store/jsx/metadata.js.map +1 -1
  113. package/dist/store/jsx-store.d.ts +1 -0
  114. package/dist/store/jsx-store.d.ts.map +1 -1
  115. package/dist/store/jsx-store.js +7 -2
  116. package/dist/store/jsx-store.js.map +1 -1
  117. package/dist/store/resolve-store.d.ts.map +1 -1
  118. package/dist/store/resolve-store.js +2 -0
  119. package/dist/store/resolve-store.js.map +1 -1
  120. package/dist/store/store-fs.d.ts +2 -1
  121. package/dist/store/store-fs.d.ts.map +1 -1
  122. package/dist/store/store-fs.js +1 -1
  123. package/dist/store/store-fs.js.map +1 -1
  124. package/dist/writer/context.d.ts +17 -0
  125. package/dist/writer/context.d.ts.map +1 -1
  126. package/dist/writer/context.js +83 -11
  127. package/dist/writer/context.js.map +1 -1
  128. package/dist/writer/emit.d.ts +2 -1
  129. package/dist/writer/emit.d.ts.map +1 -1
  130. package/dist/writer/emit.js +2 -1
  131. package/dist/writer/emit.js.map +1 -1
  132. package/dist/writer/imports.d.ts.map +1 -1
  133. package/dist/writer/imports.js +6 -1
  134. package/dist/writer/imports.js.map +1 -1
  135. package/dist/writer/module.d.ts +1 -0
  136. package/dist/writer/module.d.ts.map +1 -1
  137. package/dist/writer/module.js +6 -1
  138. package/dist/writer/module.js.map +1 -1
  139. package/overrides/glib/regex.ts.ejs +2 -0
  140. package/package.json +4 -4
  141. package/src/analysis/descriptor-render.ts +79 -30
  142. package/src/analysis/descriptor.ts +19 -11
  143. package/src/compile.ts +42 -3
  144. package/src/docs/api-reference.ts +4 -1
  145. package/src/docs/pipeline.ts +64 -13
  146. package/src/fingerprint.ts +7 -0
  147. package/src/gi.ts +6 -1
  148. package/src/gir/libraries.ts +64 -16
  149. package/src/gir/library.ts +9 -0
  150. package/src/internal.ts +1 -0
  151. package/src/jsx.ts +3 -0
  152. package/src/runner.ts +5 -1
  153. package/src/store/gi/bootstrap.ts +64 -0
  154. package/src/store/gi/class.ts +100 -29
  155. package/src/store/gi/constructor-props.ts +2 -1
  156. package/src/store/gi/enum.ts +4 -4
  157. package/src/store/gi/folded.ts +57 -0
  158. package/src/store/gi/function.ts +22 -3
  159. package/src/store/gi/gtype-binding.ts +15 -2
  160. package/src/store/gi/interface.ts +64 -7
  161. package/src/store/gi/method.ts +2 -0
  162. package/src/store/gi/pipeline.ts +21 -2
  163. package/src/store/gi/property-accessor.ts +1 -1
  164. package/src/store/gi/record-field-accessor.ts +5 -3
  165. package/src/store/gi/record.ts +61 -14
  166. package/src/store/gi/registration.ts +2 -2
  167. package/src/store/gi/return-wrap.ts +1 -1
  168. package/src/store/gi/signal.ts +8 -3
  169. package/src/store/gi/vtable.ts +1 -0
  170. package/src/store/gi-store.ts +19 -7
  171. package/src/store/jsx/element-components.ts +107 -10
  172. package/src/store/jsx/element-prop-types.ts +4 -0
  173. package/src/store/jsx/metadata.ts +41 -0
  174. package/src/store/jsx-store.ts +10 -4
  175. package/src/store/resolve-store.ts +2 -0
  176. package/src/store/store-fs.ts +3 -2
  177. package/src/writer/context.ts +109 -16
  178. package/src/writer/emit.ts +3 -1
  179. package/src/writer/imports.ts +9 -1
  180. package/src/writer/module.ts +9 -1
@@ -1 +1 @@
1
- {"version":3,"file":"libraries.js","sourceRoot":"","sources":["../../src/gir/libraries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAetC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,mBAAmB,GAAG,sCAAsC,CAAC;AACnE,MAAM,iBAAiB,GAAa,CAAC,SAAS,CAAC,CAAC;AAChD,MAAM,eAAe,GAAG,MAAM,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,CAAC,SAA2B,EAAE,OAAiB,EAAY,EAAE;IAClF,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,CAAC,GAAG,iBAAiB,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,SAAS,KAAK,kBAAkB,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAElD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CACX,gEAAgE,OAAO,CAAC,IAAI,CAAC,IAAI,CAA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,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAEtD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC7C,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAE3E,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;YACnB,OAAO,UAAU,CAAC;QACtB,CAAC;IACL,CAAC;IAED,OAAO,CAAC,CAAC;AACb,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAyB,CAAC","sourcesContent":["import { sortStrings } from \"@gtkx/utils\";\nimport { readdirSync } from \"node:fs\";\n\n/** A namespace found on the GIR path, taken from the name of its `.gir` file. */\ntype GirNamespace = {\n /** Namespace the file describes, such as `Gtk`. */\n name: string;\n /** API version the file describes, such as `4.0`. */\n version: string;\n /** Name and version joined the way a `libraries` entry spells them, such as `Gtk-4.0`. */\n identifier: string;\n};\n\n/** A `libraries` config value: an explicit list, `\"*\"` for everything installed, or absent for the default. */\ntype LibrarySelection = \"*\" | string[] | undefined;\n\nconst LIBRARIES_WILDCARD = \"*\";\nconst GIR_LIBRARY_PATTERN = /^[A-Za-z][A-Za-z0-9]*-\\d+(?:\\.\\d+)*$/;\nconst DEFAULT_LIBRARIES: string[] = [\"Gtk-4.0\"];\nconst GIR_FILE_SUFFIX = \".gir\";\n\n/**\n * Expands a `libraries` config value into the GIR identifiers to generate from: `\"Gtk-4.0\"` alone when\n * nothing is configured, everything installed for `\"*\"`, and otherwise the given list with `\"Gtk-4.0\"`\n * prepended unless it already names a Gtk version.\n *\n * @throws If `\"*\"` matched no `.gir` file anywhere on the GIR path.\n */\nconst resolveLibraries = (libraries: LibrarySelection, girPath: string[]): string[] => {\n if (libraries === undefined) {\n return [...DEFAULT_LIBRARIES];\n }\n\n if (libraries === LIBRARIES_WILDCARD) {\n const discovered = discoverGirNamespaces(girPath);\n\n if (discovered.length === 0) {\n throw new Error(\n `gtkx.config.ts: \\`libraries: \"*\"\\` matched no .gir files in [${girPath.join(\", \")}]. ` +\n \"Install gobject-introspection data packages, or list the libraries explicitly.\",\n );\n }\n\n return discovered;\n }\n\n const hasGtk = libraries.some((library) => library.startsWith(\"Gtk-\"));\n\n return [...new Set([...(hasGtk ? [] : DEFAULT_LIBRARIES), ...libraries])];\n};\n\nconst readDirEntries = (dir: string): string[] => {\n try {\n return readdirSync(dir);\n } catch {\n return [];\n }\n};\n\nconst parseGirNamespace = (entry: string): GirNamespace | undefined => {\n if (!entry.endsWith(GIR_FILE_SUFFIX)) {\n return undefined;\n }\n\n const identifier = entry.slice(0, -GIR_FILE_SUFFIX.length);\n\n if (!GIR_LIBRARY_PATTERN.test(identifier)) {\n return undefined;\n }\n\n const separator = identifier.indexOf(\"-\");\n\n return { name: identifier.slice(0, separator), version: identifier.slice(separator + 1), identifier };\n};\n\nconst recordHighest = (highestByName: Map<string, GirNamespace>, parsed: GirNamespace): void => {\n const existing = highestByName.get(parsed.name);\n\n if (existing === undefined || compareVersions(parsed.version, existing.version) > 0) {\n highestByName.set(parsed.name, parsed);\n }\n};\n\nconst collectDirNamespaces = (highestByName: Map<string, GirNamespace>, dir: string): void => {\n for (const entry of readDirEntries(dir)) {\n const parsed = parseGirNamespace(entry);\n\n if (parsed !== undefined) {\n recordHighest(highestByName, parsed);\n }\n }\n};\n\n/**\n * Every GIR library installed on the search path, as sorted `Name-Version` identifiers. A namespace found\n * in more than one version contributes only its highest, and unreadable directories are skipped.\n */\nconst discoverGirNamespaces = (girPath: string[]): string[] => {\n const highestByName: Map<string, GirNamespace> = new Map();\n\n for (const dir of girPath) {\n collectDirNamespaces(highestByName, dir);\n }\n\n return sortStrings(highestByName.values().map(({ identifier }) => identifier));\n};\n\nconst compareVersions = (a: string, b: string): number => {\n const aParts = a.split(\".\");\n const bParts = b.split(\".\");\n const length = Math.max(aParts.length, bParts.length);\n\n for (let index = 0; index < length; index += 1) {\n const difference = Number(aParts[index] ?? 0) - Number(bParts[index] ?? 0);\n\n if (difference !== 0) {\n return difference;\n }\n }\n\n return 0;\n};\n\nexport { resolveLibraries, discoverGirNamespaces, type LibrarySelection };\n"]}
1
+ {"version":3,"file":"libraries.js","sourceRoot":"","sources":["../../src/gir/libraries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAetC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,mBAAmB,GAAG,sCAAsC,CAAC;AACnE,MAAM,iBAAiB,GAAa,CAAC,SAAS,CAAC,CAAC;AAChD,MAAM,yBAAyB,GAAa,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACjE,MAAM,eAAe,GAAG,MAAM,CAAC;AAE/B;;;;;;;;;;;GAWG;AACH,MAAM,gBAAgB,GAAG,CAAC,SAA2B,EAAE,OAAiB,EAAE,gBAAgB,GAAG,KAAK,EAAY,EAAE;IAC5G,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,CAAC,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,SAAS,KAAK,kBAAkB,EAAE,CAAC;QACnC,OAAO,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,gBAAgB,EAAE,CAAC;QACnB,OAAO,aAAa,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,cAAc,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,SAA2B,EAAE,gBAAgB,GAA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aAAa,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;AACnF,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE;IACrD,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAEtD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC7C,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAE3E,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;YACnB,OAAO,UAAU,CAAC;QACtB,CAAC;IACL,CAAC;IAED,OAAO,CAAC,CAAC;AACb,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,kBAAkB,EAAyB,CAAC","sourcesContent":["import { sortStrings } from \"@gtkx/utils\";\nimport { readdirSync } from \"node:fs\";\n\n/** A namespace found on the GIR path, taken from the name of its `.gir` file. */\ntype GirNamespace = {\n /** Namespace the file describes, such as `Gtk`. */\n name: string;\n /** API version the file describes, such as `4.0`. */\n version: string;\n /** Name and version joined the way a `libraries` entry spells them, such as `Gtk-4.0`. */\n identifier: string;\n};\n\n/** A `libraries` config value: an explicit list, `\"*\"` for everything installed, or absent for the default. */\ntype LibrarySelection = \"*\" | string[] | undefined;\n\nconst LIBRARIES_WILDCARD = \"*\";\nconst GIR_LIBRARY_PATTERN = /^[A-Za-z][A-Za-z0-9]*-\\d+(?:\\.\\d+)*$/;\nconst DEFAULT_LIBRARIES: string[] = [\"Gtk-4.0\"];\nconst ADWAITA_DEFAULT_LIBRARIES: string[] = [\"Gtk-4.0\", \"Adw-1\"];\nconst GIR_FILE_SUFFIX = \".gir\";\n\n/**\n * Expands a `libraries` config value into the GIR identifiers to generate from: the mandatory set alone\n * when nothing is configured, everything installed for `\"*\"`, and otherwise the given list with the\n * mandatory set prepended.\n *\n * The mandatory set is `\"Gtk-4.0\"`, which joins a list that does not already name a Gtk version. Under\n * `isAdwaitaDefault` it is `\"Gtk-4.0\"` and `\"Adw-1\"`, and it joins `\"*\"` as well as an explicit list.\n * Each entry is mandatory by namespace rather than by version, so a list that pins another version of\n * Gtk or Adwaita keeps its pin.\n *\n * @throws If `\"*\"` matched no `.gir` file anywhere on the GIR path.\n */\nconst resolveLibraries = (libraries: LibrarySelection, girPath: string[], isAdwaitaDefault = false): string[] => {\n if (libraries === undefined) {\n return [...mandatoryLibraries(isAdwaitaDefault)];\n }\n\n if (libraries === LIBRARIES_WILDCARD) {\n return installedLibraries(girPath, isAdwaitaDefault);\n }\n\n if (isAdwaitaDefault) {\n return withMandatory(ADWAITA_DEFAULT_LIBRARIES, libraries);\n }\n\n return withDefaultGtk(libraries);\n};\n\nconst redundantLibraries = (libraries: LibrarySelection, isAdwaitaDefault = false): string[] => {\n if (!isAdwaitaDefault || !Array.isArray(libraries)) {\n return [];\n }\n\n return libraries.filter((entry) => ADWAITA_DEFAULT_LIBRARIES.includes(entry));\n};\n\nconst mandatoryLibraries = (isAdwaitaDefault: boolean): string[] =>\n isAdwaitaDefault ? ADWAITA_DEFAULT_LIBRARIES : DEFAULT_LIBRARIES;\n\nconst installedLibraries = (girPath: string[], isAdwaitaDefault: boolean): string[] => {\n const discovered = discoverGirNamespaces(girPath);\n\n if (discovered.length === 0) {\n throw new Error(\n `gtkx.config.ts: \\`libraries: \"*\"\\` matched no .gir files in [${girPath.join(\", \")}]. ` +\n \"Install gobject-introspection data packages, or list the libraries explicitly.\",\n );\n }\n\n if (isAdwaitaDefault) {\n return withMandatory(ADWAITA_DEFAULT_LIBRARIES, discovered);\n }\n\n return discovered;\n};\n\nconst getNamespace = (library: string): string => {\n const separator = library.indexOf(\"-\");\n\n return separator === -1 ? library : library.slice(0, separator);\n};\n\nconst withMandatory = (mandatory: string[], selected: string[]): string[] => {\n const named: Set<string> = new Set(selected.map((entry) => getNamespace(entry)));\n const missing = mandatory.filter((library) => !named.has(getNamespace(library)));\n\n return [...new Set([...missing, ...selected])];\n};\n\nconst withDefaultGtk = (libraries: string[]): string[] => {\n if (libraries.some((library) => library.startsWith(\"Gtk-\"))) {\n return [...new Set(libraries)];\n }\n\n return [...new Set([...DEFAULT_LIBRARIES, ...libraries])];\n};\n\nconst readDirEntries = (dir: string): string[] => {\n try {\n return readdirSync(dir);\n } catch {\n return [];\n }\n};\n\nconst parseGirNamespace = (entry: string): GirNamespace | undefined => {\n if (!entry.endsWith(GIR_FILE_SUFFIX)) {\n return undefined;\n }\n\n const identifier = entry.slice(0, -GIR_FILE_SUFFIX.length);\n\n if (!GIR_LIBRARY_PATTERN.test(identifier)) {\n return undefined;\n }\n\n const separator = identifier.indexOf(\"-\");\n\n return { name: identifier.slice(0, separator), version: identifier.slice(separator + 1), identifier };\n};\n\nconst recordHighest = (highestByName: Map<string, GirNamespace>, parsed: GirNamespace): void => {\n const existing = highestByName.get(parsed.name);\n\n if (existing === undefined || compareVersions(parsed.version, existing.version) > 0) {\n highestByName.set(parsed.name, parsed);\n }\n};\n\nconst collectDirNamespaces = (highestByName: Map<string, GirNamespace>, dir: string): void => {\n for (const entry of readDirEntries(dir)) {\n const parsed = parseGirNamespace(entry);\n\n if (parsed !== undefined) {\n recordHighest(highestByName, parsed);\n }\n }\n};\n\n/**\n * Every GIR library installed on the search path, as sorted `Name-Version` identifiers. A namespace found\n * in more than one version contributes only its highest, and unreadable directories are skipped.\n */\nconst discoverGirNamespaces = (girPath: string[]): string[] => {\n const highestByName: Map<string, GirNamespace> = new Map();\n\n for (const dir of girPath) {\n collectDirNamespaces(highestByName, dir);\n }\n\n return sortStrings(highestByName.values().map(({ identifier }) => identifier));\n};\n\nconst compareVersions = (a: string, b: string): number => {\n const aParts = a.split(\".\");\n const bParts = b.split(\".\");\n const length = Math.max(aParts.length, bParts.length);\n\n for (let index = 0; index < length; index += 1) {\n const difference = Number(aParts[index] ?? 0) - Number(bParts[index] ?? 0);\n\n if (difference !== 0) {\n return difference;\n }\n }\n\n return 0;\n};\n\nexport { resolveLibraries, redundantLibraries, discoverGirNamespaces, LIBRARIES_WILDCARD, type LibrarySelection };\n"]}
@@ -11,6 +11,8 @@ type FutureBehavior = {
11
11
  isFinishTrimmed?: boolean;
12
12
  /** Whether a handle-passing inout parameter is mutated in place rather than packed into the result. */
13
13
  isInoutInPlace?: boolean;
14
+ /** Whether registrations fold into each class so bundlers can drop unused ones. */
15
+ isTreeShaken?: boolean;
14
16
  };
15
17
  /**
16
18
  * The parsed GIR universe: every requested namespace plus everything those namespaces include,
@@ -37,6 +39,7 @@ declare class Library {
37
39
  private isValueUnwrappedValue;
38
40
  private isFinishTrimmedValue;
39
41
  private isInoutInPlaceValue;
42
+ private isTreeShakenValue;
40
43
  /** Creates a library with no namespaces loaded; {@link Library.load} builds a populated one. */
41
44
  constructor();
42
45
  private ensureNsId;
@@ -68,6 +71,8 @@ declare class Library {
68
71
  get isFinishTrimmed(): boolean;
69
72
  /** Whether a handle-passing inout parameter is mutated in place rather than packed into the result. */
70
73
  get isInoutInPlace(): boolean;
74
+ /** Whether registrations fold into each class so bundlers can drop unused ones. */
75
+ get isTreeShaken(): boolean;
71
76
  /** Paths of the `.gir` files that were read, in the order they were discovered. */
72
77
  get girFiles(): string[];
73
78
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../src/gir/library.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,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C,kBAAkB;IAa1B,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,oBAAoB;IAgB5B,OAAO,CAAC,oBAAoB;IAgB5B,OAAO,CAAC,iBAAiB;IA2BzB,OAAO,CAAC,kBAAkB;IAoB1B,oEAAoE;IACpE,IAAW,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAEjD;IAED,4EAA4E;IAC5E,IAAW,gBAAgB,IAAI,OAAO,CAErC;IAED,yGAAyG;IACzG,IAAW,gBAAgB,IAAI,OAAO,CAErC;IAED,oGAAoG;IACpG,IAAW,eAAe,IAAI,OAAO,CAEpC;IAED,uGAAuG;IACvG,IAAW,cAAc,IAAI,OAAO,CAEnC;IAED,mFAAmF;IACnF,IAAW,YAAY,IAAI,OAAO,CAEjC;IAED,mFAAmF;IACnF,IAAW,QAAQ,IAAI,MAAM,EAAE,CAE9B;IAED;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAIzC;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG;QAClB,6DAA6D;QAC7D,aAAa,EAAE,MAAM,CAAC;QACtB,kEAAkE;QAClE,QAAQ,EAAE,MAAM,CAAC;KACpB,GAAG,SAAS;IAWb;;;;;;;OAOG;IACH,WAAW,CAAC,oBAAoB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;CAsB/E;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -53,6 +53,7 @@ class Library {
53
53
  library.isValueUnwrappedValue = future.isValueUnwrapped === true;
54
54
  library.isFinishTrimmedValue = future.isFinishTrimmed === true;
55
55
  library.isInoutInPlaceValue = future.isInoutInPlace === true;
56
+ library.isTreeShakenValue = future.isTreeShaken === true;
56
57
  this.drive(library, libraries, girPath);
57
58
  return library;
58
59
  }
@@ -66,6 +67,7 @@ class Library {
66
67
  isValueUnwrappedValue = false;
67
68
  isFinishTrimmedValue = false;
68
69
  isInoutInPlaceValue = false;
70
+ isTreeShakenValue = false;
69
71
  /** Creates a library with no namespaces loaded; {@link Library.load} builds a populated one. */
70
72
  constructor() {
71
73
  this.typeTables[INTERNAL_NS_ID] = { types: [], names: [], index: new Map() };
@@ -245,6 +247,10 @@ class Library {
245
247
  get isInoutInPlace() {
246
248
  return this.isInoutInPlaceValue;
247
249
  }
250
+ /** Whether registrations fold into each class so bundlers can drop unused ones. */
251
+ get isTreeShaken() {
252
+ return this.isTreeShakenValue;
253
+ }
248
254
  /** Paths of the `.gir` files that were read, in the order they were discovered. */
249
255
  get girFiles() {
250
256
  return this.girFilesValue;
@@ -1 +1 @@
1
- {"version":3,"file":"library.js","sourceRoot":"","sources":["../../src/gir/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACH,oBAAoB,EAGpB,oBAAoB,EACpB,qBAAqB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAgB,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAgCvD,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAW,EAAE;IACjD,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IAEnC,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxD,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,2BAA2B,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,UAAqB,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,UAA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CAAC;QAEhD,IAAI,QAAQ,KAAK,SAAS,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;YACxD,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;IACvC,CAAC;IAED;;;;;;;OAOG;IACH,WAAW,CAAC,oBAA4B,EAAE,IAAY;QAClD,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAE9D,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,MAAM,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAChE,MAAM,UAAU,GAAG,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAElG,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAE9D,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YACnB,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;CACJ;AAED,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { PrimitiveCategory } from \"./primitives.js\";\nimport type { CArrayType, HashTableType, ListType, ParseContext, TypeId } from \"./type-id.js\";\nimport type { GirType } from \"./type.js\";\nimport { callbackFromNode } from \"./callback.js\";\nimport {\n createNamespaceShell,\n type GirNamespace,\n type NamespaceHeader,\n parseNamespaceHeader,\n populateNamespaceBody,\n} from \"./namespace.js\";\nimport { parseGirFile, type RawNode } from \"./parse.js\";\nimport { splitOptionalNamespace } from \"./type-ref.js\";\n\n/** The types belonging to one namespace, addressed by the id half of a {@link TypeId}. */\ntype TypeTable = {\n /** Parsed type in each slot, still `undefined` while only a forward reference to it has been seen. */\n types: (GirType | undefined)[];\n /** Declared name of each slot, `undefined` for anonymous types such as containers and inline callbacks. */\n names: (string | undefined)[];\n /** Slot id each named type occupies, so repeated references resolve to the same id. */\n index: Map<string, number>;\n};\n\n/** Behavior a project opted into ahead of the next major version, through the `future` block of its config. */\ntype FutureBehavior = {\n /** Whether byte sequences render as `Uint8Array` rather than `number[]`. */\n isByteArrayTyped?: boolean;\n /** Whether a `GObject.Value` a binding hands back surfaces as what it holds rather than as the value. */\n isValueUnwrapped?: boolean;\n /** Whether a promisified result drops the leading success boolean of a throwing finish function. */\n isFinishTrimmed?: boolean;\n /** Whether a handle-passing inout parameter is mutated in place rather than packed into the result. */\n isInoutInPlace?: boolean;\n};\n\n/** A namespace whose header has been read and whose shell is registered, before its body is parsed. */\ntype DiscoveredNamespace = {\n /** Attributes and includes read from the namespace's GIR file. */\n header: NamespaceHeader;\n /** Empty namespace registered for the header, populated once every header is known. */\n shell: GirNamespace;\n};\n\nconst INTERNAL_NS_ID = 0;\n\nconst readRepositoryNode = (path: string): RawNode => {\n const root = parseGirFile(path);\n const repository = root.repository;\n\n if (typeof repository !== \"object\" || repository === null) {\n throw new Error(`GIR file at ${path} has no <repository> root`);\n }\n\n return repository as RawNode;\n};\n\nconst locateGirFile = (identifier: string, girPath: string[]): string => {\n const filename = `${identifier}.gir`;\n\n for (const directory of girPath) {\n const candidate = join(directory, filename);\n\n if (existsSync(candidate)) {\n return candidate;\n }\n }\n\n const tried = girPath.map((directory) => join(directory, filename)).join(\", \");\n throw new Error(`GIR file ${filename} not found on girPath. Tried: ${tried}`);\n};\n\n/**\n * The parsed GIR universe: every requested namespace plus everything those namespaces include,\n * with types resolvable across namespace boundaries.\n */\nclass Library {\n private static drive(library: Library, libraries: string[], girPath: string[]): void {\n const { discovered, girFiles } = library.discoverNamespaces(libraries, girPath);\n\n for (const { header, shell } of discovered) {\n populateNamespaceBody(shell, header.namespaceNode, library.parseContext(shell.id));\n }\n\n for (const { shell } of discovered) {\n library.addDeclarations(shell);\n }\n\n library.girFilesValue = girFiles;\n }\n\n /**\n * Parses the named GIR libraries along with every namespace they transitively include.\n *\n * @param libraries GIR identifiers to load, such as `Gtk-4.0`.\n * @param girPath Directories searched, in order, for each `.gir` file.\n * @param future Behavior the project opted into ahead of the next major version.\n * @returns A library holding every namespace that was parsed.\n */\n static load(libraries: string[], girPath: string[], future: FutureBehavior = {}): Library {\n const library = new Library();\n library.isByteArrayTypedValue = future.isByteArrayTyped === true;\n library.isValueUnwrappedValue = future.isValueUnwrapped === true;\n library.isFinishTrimmedValue = future.isFinishTrimmed === true;\n library.isInoutInPlaceValue = future.isInoutInPlace === true;\n this.drive(library, libraries, girPath);\n\n return library;\n }\n\n private namespacesByName: Map<string, GirNamespace> = new Map();\n private namespaceById: (GirNamespace | undefined)[] = [];\n private nsNameById: string[] = [];\n private nsIdByName: Map<string, number> = new Map();\n private typeTables: TypeTable[] = [];\n private girFilesValue: string[] = [];\n private isByteArrayTypedValue = false;\n private isValueUnwrappedValue = false;\n private isFinishTrimmedValue = false;\n private isInoutInPlaceValue = false;\n\n /** Creates a library with no namespaces loaded; {@link Library.load} builds a populated one. */\n constructor() {\n this.typeTables[INTERNAL_NS_ID] = { types: [], names: [], index: new Map() };\n this.namespaceById[INTERNAL_NS_ID] = undefined;\n this.nsNameById[INTERNAL_NS_ID] = \"$internal\";\n }\n\n private ensureNsId(name: string): number {\n const existing = this.nsIdByName.get(name);\n\n if (existing !== undefined) {\n return existing;\n }\n\n const nsId = this.typeTables.length;\n this.typeTables[nsId] = { types: [], names: [], index: new Map() };\n this.namespaceById[nsId] = undefined;\n this.nsNameById[nsId] = name;\n this.nsIdByName.set(name, nsId);\n\n return nsId;\n }\n\n private registerNamespace(header: NamespaceHeader): GirNamespace {\n const nsId = this.ensureNsId(header.name);\n const shell = createNamespaceShell(header, nsId);\n this.namespaceById[nsId] = shell;\n this.namespacesByName.set(header.name, shell);\n\n return shell;\n }\n\n private namespaceFor(nsId: number): GirNamespace {\n const namespace = this.namespaceById[nsId];\n\n if (namespace === undefined) {\n throw new Error(`No namespace registered for type table id ${String(nsId)}`);\n }\n\n return namespace;\n }\n\n private typeTableFor(nsId: number): TypeTable {\n const typeTable = this.typeTables[nsId];\n\n if (typeTable === undefined) {\n throw new Error(`No type table for namespace id ${String(nsId)}`);\n }\n\n return typeTable;\n }\n\n private insertIntoTypeTable(\n typeTable: TypeTable,\n slot: { type: GirType | undefined; indexKey?: string; displayName?: string },\n ): number {\n const id = typeTable.types.length;\n typeTable.types.push(slot.type);\n typeTable.names.push(slot.displayName);\n\n if (slot.indexKey !== undefined) {\n typeTable.index.set(slot.indexKey, id);\n }\n\n return id;\n }\n\n private resolveTypeId(nsId: number, name: string, type: GirType | undefined): number {\n const typeTable = this.typeTableFor(nsId);\n const existing = typeTable.index.get(name);\n\n if (existing !== undefined) {\n return existing;\n }\n\n return this.insertIntoTypeTable(typeTable, { type, indexKey: name, displayName: name });\n }\n\n private addType(nsId: number, name: string, type: GirType): void {\n this.typeTableFor(nsId).types[this.resolveTypeId(nsId, name, type)] = type;\n }\n\n private findType(nsId: number, name: string): TypeId {\n return { nsId, id: this.resolveTypeId(nsId, name, undefined) };\n }\n\n private addAnonymousType(nsId: number, type: GirType): TypeId {\n const typeTable = this.typeTableFor(nsId);\n const id = this.insertIntoTypeTable(typeTable, { type });\n\n return { nsId, id };\n }\n\n private findTypeByName(currentNsId: number, name: string): TypeId {\n const [namespaceName, localName] = splitOptionalNamespace(name);\n const targetNsId = namespaceName === undefined ? currentNsId : this.ensureNsId(namespaceName);\n\n return this.findType(targetNsId, localName);\n }\n\n private parseContext(nsId: number): ParseContext {\n const context: ParseContext = {\n nsId,\n findType: (name) => this.findTypeByName(nsId, name),\n addPrimitive: (category) => this.addPrimitive(category),\n addVarargs: () => this.addVarargs(),\n addContainer: (type: CArrayType | ListType | HashTableType) => this.addAnonymousType(nsId, type),\n addAnonymousCallback: (node) =>\n this.addAnonymousType(nsId, {\n kind: \"callback\",\n namespace: this.namespaceFor(nsId),\n value: callbackFromNode(node, context),\n }),\n };\n\n return context;\n }\n\n private addPrimitive(category: PrimitiveCategory): TypeId {\n return this.findOrAddContainer(`primitive:${category}`, { kind: \"primitive\", category });\n }\n\n private addVarargs(): TypeId {\n return this.findOrAddContainer(\"varargs\", { kind: \"varargs\" });\n }\n\n private findOrAddContainer(key: string, type: GirType): TypeId {\n const typeTable = this.typeTableFor(INTERNAL_NS_ID);\n const existing = typeTable.index.get(key);\n\n if (existing !== undefined) {\n return { nsId: INTERNAL_NS_ID, id: existing };\n }\n\n const id = this.insertIntoTypeTable(typeTable, { type, indexKey: key });\n\n return { nsId: INTERNAL_NS_ID, id };\n }\n\n private addDeclarations(shell: GirNamespace): void {\n this.addClassDeclarations(shell);\n this.addValueDeclarations(shell);\n }\n\n private addClassDeclarations(shell: GirNamespace): void {\n const nsId = shell.id;\n\n for (const value of shell.classes) {\n this.addType(nsId, value.name, { kind: \"class\", namespace: shell, value });\n }\n\n for (const value of shell.interfaces) {\n this.addType(nsId, value.name, { kind: \"interface\", namespace: shell, value });\n }\n\n for (const value of shell.records) {\n this.addType(nsId, value.name, { kind: \"record\", namespace: shell, value });\n }\n }\n\n private addValueDeclarations(shell: GirNamespace): void {\n const nsId = shell.id;\n\n for (const value of shell.enums) {\n this.addType(nsId, value.name, { kind: \"enum\", namespace: shell, value });\n }\n\n for (const value of shell.callbacks) {\n this.addType(nsId, value.name, { kind: \"callback\", namespace: shell, value });\n }\n\n for (const alias of shell.aliases) {\n this.addType(nsId, alias.name, { kind: \"alias\", namespace: shell, value: alias });\n }\n }\n\n private processIdentifier(input: {\n identifier: string;\n girPath: string[];\n seen: Set<string>;\n queue: string[];\n girFiles: string[];\n discovered: DiscoveredNamespace[];\n }): void {\n const { identifier, girPath, seen, queue, girFiles, discovered } = input;\n const namespaceName = identifier.split(\"-\", 1)[0] ?? identifier;\n\n if (seen.has(namespaceName)) {\n return;\n }\n\n seen.add(namespaceName);\n const path = locateGirFile(identifier, girPath);\n girFiles.push(path);\n const header = parseNamespaceHeader(readRepositoryNode(path), path);\n const shell = this.registerNamespace(header);\n discovered.push({ header, shell });\n\n for (const include of header.includes) {\n queue.push(`${include.name}-${include.version}`);\n }\n }\n\n private discoverNamespaces(\n libraries: string[],\n girPath: string[],\n ): { discovered: DiscoveredNamespace[]; girFiles: string[] } {\n const queue: string[] = [...libraries];\n const seen: Set<string> = new Set();\n const discovered: DiscoveredNamespace[] = [];\n const girFiles: string[] = [];\n\n while (queue.length > 0) {\n const identifier = queue.shift();\n\n if (identifier !== undefined) {\n this.processIdentifier({ identifier, girPath, seen, queue, girFiles, discovered });\n }\n }\n\n return { discovered, girFiles };\n }\n\n /** The loaded namespaces, keyed by their GIR name such as `Gtk`. */\n public get namespaces(): Map<string, GirNamespace> {\n return this.namespacesByName;\n }\n\n /** Whether byte sequences render as `Uint8Array` rather than `number[]`. */\n public get isByteArrayTyped(): boolean {\n return this.isByteArrayTypedValue;\n }\n\n /** Whether a `GObject.Value` a binding hands back surfaces as what it holds rather than as the value. */\n public get isValueUnwrapped(): boolean {\n return this.isValueUnwrappedValue;\n }\n\n /** Whether a promisified result drops the leading success boolean of a throwing finish function. */\n public get isFinishTrimmed(): boolean {\n return this.isFinishTrimmedValue;\n }\n\n /** Whether a handle-passing inout parameter is mutated in place rather than packed into the result. */\n public get isInoutInPlace(): boolean {\n return this.isInoutInPlaceValue;\n }\n\n /** Paths of the `.gir` files that were read, in the order they were discovered. */\n public get girFiles(): string[] {\n return this.girFilesValue;\n }\n\n /**\n * Reads the type a {@link TypeId} points at.\n *\n * @param tid The type id to dereference.\n * @returns The parsed type, or `undefined` when nothing has been parsed into that slot.\n */\n typeFor(tid: TypeId): GirType | undefined {\n return this.typeTables[tid.nsId]?.types[tid.id];\n }\n\n /**\n * Reads the name a {@link TypeId} was registered under.\n *\n * @param tid The type id to name.\n * @returns The namespace and type name, or `undefined` for an anonymous type.\n */\n nameFor(tid: TypeId): {\n /** GIR namespace to qualify the type with, such as `Gtk`. */\n namespaceName: string;\n /** Unqualified type name as GIR declares it, such as `Widget`. */\n typeName: string;\n } | undefined {\n const typeName = this.typeTables[tid.nsId]?.names[tid.id];\n const namespaceName = this.nsNameById[tid.nsId];\n\n if (typeName === undefined || namespaceName === undefined) {\n return undefined;\n }\n\n return { namespaceName, typeName };\n }\n\n /**\n * Looks up a type by the name a GIR file writes, resolving an unqualified name against the\n * namespace it appears in and a `Namespace.Type` name against the loaded namespaces.\n *\n * @param currentNamespaceName Namespace the name is written in.\n * @param name Type name, optionally qualified with a namespace prefix.\n * @returns The parsed type, or `undefined` when the name is unknown or only a forward reference to it exists.\n */\n resolveType(currentNamespaceName: string, name: string): GirType | undefined {\n const currentNsId = this.nsIdByName.get(currentNamespaceName);\n\n if (currentNsId === undefined) {\n return undefined;\n }\n\n const [namespaceName, localName] = splitOptionalNamespace(name);\n const targetNsId = namespaceName === undefined ? currentNsId : this.nsIdByName.get(namespaceName);\n\n if (targetNsId === undefined) {\n return undefined;\n }\n\n const id = this.typeTableFor(targetNsId).index.get(localName);\n\n if (id === undefined) {\n return undefined;\n }\n\n return this.typeTableFor(targetNsId).types[id];\n }\n}\n\nexport { Library };\n"]}
1
+ {"version":3,"file":"library.js","sourceRoot":"","sources":["../../src/gir/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACH,oBAAoB,EAGpB,oBAAoB,EACpB,qBAAqB,GACxB,MAAM,gB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,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAElG,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAE9D,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YACnB,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;CACJ;AAED,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { PrimitiveCategory } from \"./primitives.js\";\nimport type { CArrayType, HashTableType, ListType, ParseContext, TypeId } from \"./type-id.js\";\nimport type { GirType } from \"./type.js\";\nimport { callbackFromNode } from \"./callback.js\";\nimport {\n createNamespaceShell,\n type GirNamespace,\n type NamespaceHeader,\n parseNamespaceHeader,\n populateNamespaceBody,\n} from \"./namespace.js\";\nimport { parseGirFile, type RawNode } from \"./parse.js\";\nimport { splitOptionalNamespace } from \"./type-ref.js\";\n\n/** The types belonging to one namespace, addressed by the id half of a {@link TypeId}. */\ntype TypeTable = {\n /** Parsed type in each slot, still `undefined` while only a forward reference to it has been seen. */\n types: (GirType | undefined)[];\n /** Declared name of each slot, `undefined` for anonymous types such as containers and inline callbacks. */\n names: (string | undefined)[];\n /** Slot id each named type occupies, so repeated references resolve to the same id. */\n index: Map<string, number>;\n};\n\n/** Behavior a project opted into ahead of the next major version, through the `future` block of its config. */\ntype FutureBehavior = {\n /** Whether byte sequences render as `Uint8Array` rather than `number[]`. */\n isByteArrayTyped?: boolean;\n /** Whether a `GObject.Value` a binding hands back surfaces as what it holds rather than as the value. */\n isValueUnwrapped?: boolean;\n /** Whether a promisified result drops the leading success boolean of a throwing finish function. */\n isFinishTrimmed?: boolean;\n /** Whether a handle-passing inout parameter is mutated in place rather than packed into the result. */\n isInoutInPlace?: boolean;\n /** Whether registrations fold into each class so bundlers can drop unused ones. */\n isTreeShaken?: boolean;\n};\n\n/** A namespace whose header has been read and whose shell is registered, before its body is parsed. */\ntype DiscoveredNamespace = {\n /** Attributes and includes read from the namespace's GIR file. */\n header: NamespaceHeader;\n /** Empty namespace registered for the header, populated once every header is known. */\n shell: GirNamespace;\n};\n\nconst INTERNAL_NS_ID = 0;\n\nconst readRepositoryNode = (path: string): RawNode => {\n const root = parseGirFile(path);\n const repository = root.repository;\n\n if (typeof repository !== \"object\" || repository === null) {\n throw new Error(`GIR file at ${path} has no <repository> root`);\n }\n\n return repository as RawNode;\n};\n\nconst locateGirFile = (identifier: string, girPath: string[]): string => {\n const filename = `${identifier}.gir`;\n\n for (const directory of girPath) {\n const candidate = join(directory, filename);\n\n if (existsSync(candidate)) {\n return candidate;\n }\n }\n\n const tried = girPath.map((directory) => join(directory, filename)).join(\", \");\n throw new Error(`GIR file ${filename} not found on girPath. Tried: ${tried}`);\n};\n\n/**\n * The parsed GIR universe: every requested namespace plus everything those namespaces include,\n * with types resolvable across namespace boundaries.\n */\nclass Library {\n private static drive(library: Library, libraries: string[], girPath: string[]): void {\n const { discovered, girFiles } = library.discoverNamespaces(libraries, girPath);\n\n for (const { header, shell } of discovered) {\n populateNamespaceBody(shell, header.namespaceNode, library.parseContext(shell.id));\n }\n\n for (const { shell } of discovered) {\n library.addDeclarations(shell);\n }\n\n library.girFilesValue = girFiles;\n }\n\n /**\n * Parses the named GIR libraries along with every namespace they transitively include.\n *\n * @param libraries GIR identifiers to load, such as `Gtk-4.0`.\n * @param girPath Directories searched, in order, for each `.gir` file.\n * @param future Behavior the project opted into ahead of the next major version.\n * @returns A library holding every namespace that was parsed.\n */\n static load(libraries: string[], girPath: string[], future: FutureBehavior = {}): Library {\n const library = new Library();\n library.isByteArrayTypedValue = future.isByteArrayTyped === true;\n library.isValueUnwrappedValue = future.isValueUnwrapped === true;\n library.isFinishTrimmedValue = future.isFinishTrimmed === true;\n library.isInoutInPlaceValue = future.isInoutInPlace === true;\n library.isTreeShakenValue = future.isTreeShaken === true;\n this.drive(library, libraries, girPath);\n\n return library;\n }\n\n private namespacesByName: Map<string, GirNamespace> = new Map();\n private namespaceById: (GirNamespace | undefined)[] = [];\n private nsNameById: string[] = [];\n private nsIdByName: Map<string, number> = new Map();\n private typeTables: TypeTable[] = [];\n private girFilesValue: string[] = [];\n private isByteArrayTypedValue = false;\n private isValueUnwrappedValue = false;\n private isFinishTrimmedValue = false;\n private isInoutInPlaceValue = false;\n private isTreeShakenValue = false;\n\n /** Creates a library with no namespaces loaded; {@link Library.load} builds a populated one. */\n constructor() {\n this.typeTables[INTERNAL_NS_ID] = { types: [], names: [], index: new Map() };\n this.namespaceById[INTERNAL_NS_ID] = undefined;\n this.nsNameById[INTERNAL_NS_ID] = \"$internal\";\n }\n\n private ensureNsId(name: string): number {\n const existing = this.nsIdByName.get(name);\n\n if (existing !== undefined) {\n return existing;\n }\n\n const nsId = this.typeTables.length;\n this.typeTables[nsId] = { types: [], names: [], index: new Map() };\n this.namespaceById[nsId] = undefined;\n this.nsNameById[nsId] = name;\n this.nsIdByName.set(name, nsId);\n\n return nsId;\n }\n\n private registerNamespace(header: NamespaceHeader): GirNamespace {\n const nsId = this.ensureNsId(header.name);\n const shell = createNamespaceShell(header, nsId);\n this.namespaceById[nsId] = shell;\n this.namespacesByName.set(header.name, shell);\n\n return shell;\n }\n\n private namespaceFor(nsId: number): GirNamespace {\n const namespace = this.namespaceById[nsId];\n\n if (namespace === undefined) {\n throw new Error(`No namespace registered for type table id ${String(nsId)}`);\n }\n\n return namespace;\n }\n\n private typeTableFor(nsId: number): TypeTable {\n const typeTable = this.typeTables[nsId];\n\n if (typeTable === undefined) {\n throw new Error(`No type table for namespace id ${String(nsId)}`);\n }\n\n return typeTable;\n }\n\n private insertIntoTypeTable(\n typeTable: TypeTable,\n slot: { type: GirType | undefined; indexKey?: string; displayName?: string },\n ): number {\n const id = typeTable.types.length;\n typeTable.types.push(slot.type);\n typeTable.names.push(slot.displayName);\n\n if (slot.indexKey !== undefined) {\n typeTable.index.set(slot.indexKey, id);\n }\n\n return id;\n }\n\n private resolveTypeId(nsId: number, name: string, type: GirType | undefined): number {\n const typeTable = this.typeTableFor(nsId);\n const existing = typeTable.index.get(name);\n\n if (existing !== undefined) {\n return existing;\n }\n\n return this.insertIntoTypeTable(typeTable, { type, indexKey: name, displayName: name });\n }\n\n private addType(nsId: number, name: string, type: GirType): void {\n this.typeTableFor(nsId).types[this.resolveTypeId(nsId, name, type)] = type;\n }\n\n private findType(nsId: number, name: string): TypeId {\n return { nsId, id: this.resolveTypeId(nsId, name, undefined) };\n }\n\n private addAnonymousType(nsId: number, type: GirType): TypeId {\n const typeTable = this.typeTableFor(nsId);\n const id = this.insertIntoTypeTable(typeTable, { type });\n\n return { nsId, id };\n }\n\n private findTypeByName(currentNsId: number, name: string): TypeId {\n const [namespaceName, localName] = splitOptionalNamespace(name);\n const targetNsId = namespaceName === undefined ? currentNsId : this.ensureNsId(namespaceName);\n\n return this.findType(targetNsId, localName);\n }\n\n private parseContext(nsId: number): ParseContext {\n const context: ParseContext = {\n nsId,\n findType: (name) => this.findTypeByName(nsId, name),\n addPrimitive: (category) => this.addPrimitive(category),\n addVarargs: () => this.addVarargs(),\n addContainer: (type: CArrayType | ListType | HashTableType) => this.addAnonymousType(nsId, type),\n addAnonymousCallback: (node) =>\n this.addAnonymousType(nsId, {\n kind: \"callback\",\n namespace: this.namespaceFor(nsId),\n value: callbackFromNode(node, context),\n }),\n };\n\n return context;\n }\n\n private addPrimitive(category: PrimitiveCategory): TypeId {\n return this.findOrAddContainer(`primitive:${category}`, { kind: \"primitive\", category });\n }\n\n private addVarargs(): TypeId {\n return this.findOrAddContainer(\"varargs\", { kind: \"varargs\" });\n }\n\n private findOrAddContainer(key: string, type: GirType): TypeId {\n const typeTable = this.typeTableFor(INTERNAL_NS_ID);\n const existing = typeTable.index.get(key);\n\n if (existing !== undefined) {\n return { nsId: INTERNAL_NS_ID, id: existing };\n }\n\n const id = this.insertIntoTypeTable(typeTable, { type, indexKey: key });\n\n return { nsId: INTERNAL_NS_ID, id };\n }\n\n private addDeclarations(shell: GirNamespace): void {\n this.addClassDeclarations(shell);\n this.addValueDeclarations(shell);\n }\n\n private addClassDeclarations(shell: GirNamespace): void {\n const nsId = shell.id;\n\n for (const value of shell.classes) {\n this.addType(nsId, value.name, { kind: \"class\", namespace: shell, value });\n }\n\n for (const value of shell.interfaces) {\n this.addType(nsId, value.name, { kind: \"interface\", namespace: shell, value });\n }\n\n for (const value of shell.records) {\n this.addType(nsId, value.name, { kind: \"record\", namespace: shell, value });\n }\n }\n\n private addValueDeclarations(shell: GirNamespace): void {\n const nsId = shell.id;\n\n for (const value of shell.enums) {\n this.addType(nsId, value.name, { kind: \"enum\", namespace: shell, value });\n }\n\n for (const value of shell.callbacks) {\n this.addType(nsId, value.name, { kind: \"callback\", namespace: shell, value });\n }\n\n for (const alias of shell.aliases) {\n this.addType(nsId, alias.name, { kind: \"alias\", namespace: shell, value: alias });\n }\n }\n\n private processIdentifier(input: {\n identifier: string;\n girPath: string[];\n seen: Set<string>;\n queue: string[];\n girFiles: string[];\n discovered: DiscoveredNamespace[];\n }): void {\n const { identifier, girPath, seen, queue, girFiles, discovered } = input;\n const namespaceName = identifier.split(\"-\", 1)[0] ?? identifier;\n\n if (seen.has(namespaceName)) {\n return;\n }\n\n seen.add(namespaceName);\n const path = locateGirFile(identifier, girPath);\n girFiles.push(path);\n const header = parseNamespaceHeader(readRepositoryNode(path), path);\n const shell = this.registerNamespace(header);\n discovered.push({ header, shell });\n\n for (const include of header.includes) {\n queue.push(`${include.name}-${include.version}`);\n }\n }\n\n private discoverNamespaces(\n libraries: string[],\n girPath: string[],\n ): { discovered: DiscoveredNamespace[]; girFiles: string[] } {\n const queue: string[] = [...libraries];\n const seen: Set<string> = new Set();\n const discovered: DiscoveredNamespace[] = [];\n const girFiles: string[] = [];\n\n while (queue.length > 0) {\n const identifier = queue.shift();\n\n if (identifier !== undefined) {\n this.processIdentifier({ identifier, girPath, seen, queue, girFiles, discovered });\n }\n }\n\n return { discovered, girFiles };\n }\n\n /** The loaded namespaces, keyed by their GIR name such as `Gtk`. */\n public get namespaces(): Map<string, GirNamespace> {\n return this.namespacesByName;\n }\n\n /** Whether byte sequences render as `Uint8Array` rather than `number[]`. */\n public get isByteArrayTyped(): boolean {\n return this.isByteArrayTypedValue;\n }\n\n /** Whether a `GObject.Value` a binding hands back surfaces as what it holds rather than as the value. */\n public get isValueUnwrapped(): boolean {\n return this.isValueUnwrappedValue;\n }\n\n /** Whether a promisified result drops the leading success boolean of a throwing finish function. */\n public get isFinishTrimmed(): boolean {\n return this.isFinishTrimmedValue;\n }\n\n /** Whether a handle-passing inout parameter is mutated in place rather than packed into the result. */\n public get isInoutInPlace(): boolean {\n return this.isInoutInPlaceValue;\n }\n\n /** Whether registrations fold into each class so bundlers can drop unused ones. */\n public get isTreeShaken(): boolean {\n return this.isTreeShakenValue;\n }\n\n /** Paths of the `.gir` files that were read, in the order they were discovered. */\n public get girFiles(): string[] {\n return this.girFilesValue;\n }\n\n /**\n * Reads the type a {@link TypeId} points at.\n *\n * @param tid The type id to dereference.\n * @returns The parsed type, or `undefined` when nothing has been parsed into that slot.\n */\n typeFor(tid: TypeId): GirType | undefined {\n return this.typeTables[tid.nsId]?.types[tid.id];\n }\n\n /**\n * Reads the name a {@link TypeId} was registered under.\n *\n * @param tid The type id to name.\n * @returns The namespace and type name, or `undefined` for an anonymous type.\n */\n nameFor(tid: TypeId): {\n /** GIR namespace to qualify the type with, such as `Gtk`. */\n namespaceName: string;\n /** Unqualified type name as GIR declares it, such as `Widget`. */\n typeName: string;\n } | undefined {\n const typeName = this.typeTables[tid.nsId]?.names[tid.id];\n const namespaceName = this.nsNameById[tid.nsId];\n\n if (typeName === undefined || namespaceName === undefined) {\n return undefined;\n }\n\n return { namespaceName, typeName };\n }\n\n /**\n * Looks up a type by the name a GIR file writes, resolving an unqualified name against the\n * namespace it appears in and a `Namespace.Type` name against the loaded namespaces.\n *\n * @param currentNamespaceName Namespace the name is written in.\n * @param name Type name, optionally qualified with a namespace prefix.\n * @returns The parsed type, or `undefined` when the name is unknown or only a forward reference to it exists.\n */\n resolveType(currentNamespaceName: string, name: string): GirType | undefined {\n const currentNsId = this.nsIdByName.get(currentNamespaceName);\n\n if (currentNsId === undefined) {\n return undefined;\n }\n\n const [namespaceName, localName] = splitOptionalNamespace(name);\n const targetNsId = namespaceName === undefined ? currentNsId : this.nsIdByName.get(namespaceName);\n\n if (targetNsId === undefined) {\n return undefined;\n }\n\n const id = this.typeTableFor(targetNsId).index.get(localName);\n\n if (id === undefined) {\n return undefined;\n }\n\n return this.typeTableFor(targetNsId).types[id];\n }\n}\n\nexport { Library };\n"]}
@@ -1,4 +1,5 @@
1
1
  export { writeDocs } from "./docs/pipeline.js";
2
+ export { LIBRARIES_WILDCARD, redundantLibraries } from "./gir/libraries.js";
2
3
  export { runGlCodegen } from "./runner.js";
3
4
  export { getShadowingStorePaths, sweepProjectStaging } from "./store/resolve-store.js";
4
5
  export { ensureStoreLinks } from "./store/store-links.js";
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/internal.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { writeDocs } from "./docs/pipeline.js";
2
+ export { LIBRARIES_WILDCARD, redundantLibraries } from "./gir/libraries.js";
2
3
  export { runGlCodegen } from "./runner.js";
3
4
  export { getShadowingStorePaths, sweepProjectStaging } from "./store/resolve-store.js";
4
5
  export { ensureStoreLinks } from "./store/store-links.js";
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { writeDocs } from \"./docs/pipeline.js\";\nexport { runGlCodegen } from \"./runner.js\";\nexport { getShadowingStorePaths, sweepProjectStaging } from \"./store/resolve-store.js\";\nexport { ensureStoreLinks } from \"./store/store-links.js\";\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { writeDocs } from \"./docs/pipeline.js\";\nexport { LIBRARIES_WILDCARD, redundantLibraries } from \"./gir/libraries.js\";\nexport { runGlCodegen } from \"./runner.js\";\nexport { getShadowingStorePaths, sweepProjectStaging } from \"./store/resolve-store.js\";\nexport { ensureStoreLinks } from \"./store/store-links.js\";\n"]}
package/dist/jsx.d.ts CHANGED
@@ -13,6 +13,7 @@ type RunJsxCodegenOptions = {
13
13
  userOmittedProps: OmittedProps;
14
14
  isGiRegenerated: boolean;
15
15
  isForced: boolean;
16
+ isTreeShaken: boolean;
16
17
  };
17
18
  type RunJsxCodegenResult = {
18
19
  isRegenerated: boolean;
package/dist/jsx.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQxD,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,2BAA2B,CAAC;AAGnF,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAGpF,KAAK,oBAAoB,GAAG;IACxB,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,GAAG,EAAE,YAAY,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC7C,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACxC,gBAAgB,EAAE,YAAY,CAAC;IAC/B,eAAe,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;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jsx.js CHANGED
@@ -18,6 +18,7 @@ const runJsxCodegen = async (options) => {
18
18
  lazyElements,
19
19
  props,
20
20
  omittedProps,
21
+ isTreeShaken: options.isTreeShaken,
21
22
  };
22
23
  if (!options.isForced && !options.isGiRegenerated) {
23
24
  const { isFresh, intrinsicElementCount } = jsxStoreFreshness(options.jsx.storeDir, fingerprintInput);
@@ -37,6 +38,7 @@ const runJsxCodegen = async (options) => {
37
38
  options: options.jsx,
38
39
  namespaces,
39
40
  metadata,
41
+ isTreeShaken: options.isTreeShaken,
40
42
  externalPackages: storeExternalPackages(library),
41
43
  rawFiles: [
42
44
  {
package/dist/jsx.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"jsx.js","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,qBAAqB,EACrB,oBAAoB,EAEpB,iBAAiB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAqB,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAqB,MAAM,8BAA8B,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAoB3D,MAAM,aAAa,GAAG,KAAK,EAAE,OAA6B,EAAgC,EAAE;IACxF,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACvF,MAAM,UAAU,GAAG,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IACxE,MAAM,YAAY,GAAG,CAAC,GAAG,OAAO,CAAC,YAAY,EAAE,GAAG,OAAO,C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IAAI,EAAE,CAAC,CAAC,IAAI;aACrG;YACD,EAAE,YAAY,EAAE,iBAAiB,EAAE,OAAO,EAAE,uBAAuB,CAAC,QAAQ,CAAC,EAAE;SAClF;KACJ,CAAC,CAAC;IAEH,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC;AAC1D,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,OAAgB,EAAY,EAAE;IACzD,MAAM,QAAQ,GAAgB,IAAI,GAAG,EAAE,CAAC;IAExC,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;QAClD,MAAM,WAAW,GAAG,kBAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAEvD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC9B,CAAC;IACL,CAAC;IAED,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;AACzB,CAAC,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import type { Library } from \"./gir/library.js\";\nimport type { StoreOptions } from \"./store/store-fs.js\";\nimport {\n computeJsxFingerprint,\n FINGERPRINT_FILENAME,\n type JsxFingerprintInput,\n jsxStoreFreshness,\n} from \"./fingerprint.js\";\nimport { externalPackageFor } from \"./gir/external-namespaces.js\";\nimport { type ModuleExport, readBuiltinElements } from \"./react/element-config.js\";\nimport { writeJsxStore } from \"./store/jsx-store.js\";\nimport { ELEMENTS_FILENAME, renderGeneratedElements } from \"./store/jsx/generated-elements.js\";\nimport { mergeOmittedProps, type OmittedProps } from \"./store/jsx/omitted-props.js\";\nimport { generateJsxFiles } from \"./store/jsx/pipeline.js\";\n\ntype RunJsxCodegenOptions = {\n getLibrary: () => Library;\n jsx: StoreOptions;\n giStoreDir: string;\n reactSubexports: string[];\n userComponents: Record<string, ModuleExport>;\n userLazyElements: string[];\n userProps: Record<string, ModuleExport>;\n userOmittedProps: OmittedProps;\n isGiRegenerated: boolean;\n isForced: boolean;\n};\n\ntype RunJsxCodegenResult = {\n isRegenerated: boolean;\n intrinsicElementCount: number;\n};\n\nconst runJsxCodegen = async (options: RunJsxCodegenOptions): Promise<RunJsxCodegenResult> => {\n const builtin = await readBuiltinElements(options.reactSubexports, options.giStoreDir);\n const components = { ...builtin.components, ...options.userComponents };\n const lazyElements = [...builtin.lazyElements, ...options.userLazyElements];\n const props = { ...builtin.props, ...options.userProps };\n const omittedProps = mergeOmittedProps(builtin.omittedProps, options.userOmittedProps);\n\n const fingerprintInput: JsxFingerprintInput = {\n reactVersion: options.jsx.version,\n reactSubexports: options.reactSubexports,\n components,\n lazyElements,\n props,\n omittedProps,\n };\n\n if (!options.isForced && !options.isGiRegenerated) {\n const { isFresh, intrinsicElementCount } = jsxStoreFreshness(options.jsx.storeDir, fingerprintInput);\n\n if (isFresh) {\n return { isRegenerated: false, intrinsicElementCount };\n }\n }\n\n const library = options.getLibrary();\n\n const { namespaces, metadata, intrinsicElementCount, elements } = generateJsxFiles(library, {\n reactSubexports: options.reactSubexports,\n components,\n lazyElements,\n props,\n omittedProps,\n });\n\n writeJsxStore({\n options: options.jsx,\n namespaces,\n metadata,\n externalPackages: storeExternalPackages(library),\n rawFiles: [\n {\n relativePath: FINGERPRINT_FILENAME,\n content:\n `${JSON.stringify(computeJsxFingerprint(fingerprintInput, intrinsicElementCount), null, 2)}\\n`,\n },\n { relativePath: ELEMENTS_FILENAME, content: renderGeneratedElements(elements) },\n ],\n });\n\n return { isRegenerated: true, intrinsicElementCount };\n};\n\nconst storeExternalPackages = (library: Library): string[] => {\n const packages: Set<string> = new Set();\n\n for (const namespace of library.namespaces.values()) {\n const packageName = externalPackageFor(namespace.name);\n\n if (packageName !== undefined) {\n packages.add(packageName);\n }\n }\n\n return [...packages];\n};\n\nexport { runJsxCodegen };\n"]}
1
+ {"version":3,"file":"jsx.js","sourceRoot":"","sources":["../src/js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AAE,CAAC;QAClD,MAAM,WAAW,GAAG,kBAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAEvD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC9B,CAAC;IACL,CAAC;IAED,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;AACzB,CAAC,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import type { Library } from \"./gir/library.js\";\nimport type { StoreOptions } from \"./store/store-fs.js\";\nimport {\n computeJsxFingerprint,\n FINGERPRINT_FILENAME,\n type JsxFingerprintInput,\n jsxStoreFreshness,\n} from \"./fingerprint.js\";\nimport { externalPackageFor } from \"./gir/external-namespaces.js\";\nimport { type ModuleExport, readBuiltinElements } from \"./react/element-config.js\";\nimport { writeJsxStore } from \"./store/jsx-store.js\";\nimport { ELEMENTS_FILENAME, renderGeneratedElements } from \"./store/jsx/generated-elements.js\";\nimport { mergeOmittedProps, type OmittedProps } from \"./store/jsx/omitted-props.js\";\nimport { generateJsxFiles } from \"./store/jsx/pipeline.js\";\n\ntype RunJsxCodegenOptions = {\n getLibrary: () => Library;\n jsx: StoreOptions;\n giStoreDir: string;\n reactSubexports: string[];\n userComponents: Record<string, ModuleExport>;\n userLazyElements: string[];\n userProps: Record<string, ModuleExport>;\n userOmittedProps: OmittedProps;\n isGiRegenerated: boolean;\n isForced: boolean;\n isTreeShaken: boolean;\n};\n\ntype RunJsxCodegenResult = {\n isRegenerated: boolean;\n intrinsicElementCount: number;\n};\n\nconst runJsxCodegen = async (options: RunJsxCodegenOptions): Promise<RunJsxCodegenResult> => {\n const builtin = await readBuiltinElements(options.reactSubexports, options.giStoreDir);\n const components = { ...builtin.components, ...options.userComponents };\n const lazyElements = [...builtin.lazyElements, ...options.userLazyElements];\n const props = { ...builtin.props, ...options.userProps };\n const omittedProps = mergeOmittedProps(builtin.omittedProps, options.userOmittedProps);\n\n const fingerprintInput: JsxFingerprintInput = {\n reactVersion: options.jsx.version,\n reactSubexports: options.reactSubexports,\n components,\n lazyElements,\n props,\n omittedProps,\n isTreeShaken: options.isTreeShaken,\n };\n\n if (!options.isForced && !options.isGiRegenerated) {\n const { isFresh, intrinsicElementCount } = jsxStoreFreshness(options.jsx.storeDir, fingerprintInput);\n\n if (isFresh) {\n return { isRegenerated: false, intrinsicElementCount };\n }\n }\n\n const library = options.getLibrary();\n\n const { namespaces, metadata, intrinsicElementCount, elements } = generateJsxFiles(library, {\n reactSubexports: options.reactSubexports,\n components,\n lazyElements,\n props,\n omittedProps,\n });\n\n writeJsxStore({\n options: options.jsx,\n namespaces,\n metadata,\n isTreeShaken: options.isTreeShaken,\n externalPackages: storeExternalPackages(library),\n rawFiles: [\n {\n relativePath: FINGERPRINT_FILENAME,\n content:\n `${JSON.stringify(computeJsxFingerprint(fingerprintInput, intrinsicElementCount), null, 2)}\\n`,\n },\n { relativePath: ELEMENTS_FILENAME, content: renderGeneratedElements(elements) },\n ],\n });\n\n return { isRegenerated: true, intrinsicElementCount };\n};\n\nconst storeExternalPackages = (library: Library): string[] => {\n const packages: Set<string> = new Set();\n\n for (const namespace of library.namespaces.values()) {\n const packageName = externalPackageFor(namespace.name);\n\n if (packageName !== undefined) {\n packages.add(packageName);\n }\n }\n\n return [...packages];\n};\n\nexport { runJsxCodegen };\n"]}
package/dist/runner.d.ts CHANGED
@@ -38,6 +38,8 @@ type CodegenRunnerOptions = {
38
38
  isFinishTrimmed?: boolean;
39
39
  /** Mutates a handle-passing inout parameter in place instead of packing it into the result; defaults to false. */
40
40
  isInoutInPlace?: boolean;
41
+ /** Folds registrations into each class so bundlers can drop unused ones; defaults to false. */
42
+ isTreeShaken?: boolean;
41
43
  };
42
44
  /** What a `runCodegen` run produced. */
43
45
  type CodegenRunnerResult = {
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAEA,OAAO,K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AAO,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,CAAC"}
package/dist/runner.js CHANGED
@@ -66,6 +66,7 @@ const emitJsxStore = async (input) => {
66
66
  ...jsxUserOptions(options),
67
67
  isGiRegenerated,
68
68
  isForced: options.isForced === true,
69
+ isTreeShaken: options.isTreeShaken === true,
69
70
  });
70
71
  return {
71
72
  isRegenerated: isGiRegenerated || jsxResult.isRegenerated,
@@ -79,7 +80,8 @@ const emitStoresWithConfig = async (config) => {
79
80
  const isValueUnwrapped = options.isValueUnwrapped === true;
80
81
  const isFinishTrimmed = options.isFinishTrimmed === true;
81
82
  const isInoutInPlace = options.isInoutInPlace === true;
82
- const future = { isByteArrayTyped, isValueUnwrapped, isFinishTrimmed, isInoutInPlace };
83
+ const isTreeShaken = options.isTreeShaken === true;
84
+ const future = { isByteArrayTyped, isValueUnwrapped, isFinishTrimmed, isInoutInPlace, isTreeShaken };
83
85
  let library;
84
86
  const loadLibrary = () => (library ??= Library.load(libraries, girPath, future));
85
87
  const giInputs = { girFiles: [], libraries, girPath, storeVersion: gi.version, ...future };
@@ -1 +1 @@
1
- {"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAA2B,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MA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AI,MAAM,EAAE,CAAC;QACzB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,SAAS;QACb,CAAC;QAED,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACjC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,KAAK,EAAE,OAA6B,EAAwB,EAAE;IAC7E,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEhD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;IACrG,CAAC;IAED,aAAa,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;IAEzB,OAAO,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAuD,CAAC","sourcesContent":["import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { ModuleExport } from \"./react/element-config.js\";\nimport type { OmittedProps } from \"./store/jsx/omitted-props.js\";\nimport { checkModules } from \"./compile.js\";\nimport { isGiStoreFresh } from \"./fingerprint.js\";\nimport { runGiCodegen } from \"./gi.js\";\nimport { Library } from \"./gir/library.js\";\nimport { generateGlModules, type GlGenerationReport } from \"./khronos/pipeline.js\";\nimport { sweepStagingDirs } from \"./staging.js\";\nimport { externalPackageNotices } from \"./store/external-package-links.js\";\nimport { ensureStoreLink, type StoreOptions } from \"./store/store-fs.js\";\n\ntype GlCodegenOptions = {\n registryPath: string;\n overrideExports: Set<string>;\n outputDir: string;\n resolveFrom: string;\n};\n\n/** What to generate and where to write it. */\ntype CodegenRunnerOptions = {\n /** GIR library identifiers such as `\"Gtk-4.0\"`; a `\"*\"` selection must be expanded before it gets here. */\n libraries: string[];\n /** Directories to search for `.gir` files. */\n girPath: string[];\n /** Where to write and link the `@gtkx/gi` store. */\n gi: StoreOptions;\n /** Where to write and link the `@gtkx/jsx` store; omit to generate the gi store alone. */\n jsx?: StoreOptions | undefined;\n /** Subexport names of the installed `@gtkx/react`, whose element config shapes the jsx store. */\n reactSubexports?: string[];\n /** Component wrappers the project layers over the built-ins, keyed by GLib type name. */\n userComponents?: Record<string, ModuleExport>;\n /** GLib type names whose GObject their parent container creates, added to the framework's own. */\n userLazyElements?: string[];\n /** Base props interfaces the project's elements extend, keyed by GLib type name. */\n userProps?: Record<string, ModuleExport>;\n /** Props the project drops from the generated element props, keyed by GLib type name. */\n userOmittedProps?: OmittedProps;\n /** Regenerates both stores even when their fingerprints are fresh. */\n isForced?: boolean;\n /** Emits GIR byte sequences as `Uint8Array` rather than `number[]`; defaults to false. */\n isByteArrayTyped?: boolean;\n /** Surfaces a `GObject.Value` a binding hands back as what it holds rather than as the value; defaults to false. */\n isValueUnwrapped?: boolean;\n /** Drops the leading success boolean from promisified results of a throwing finish; defaults to false. */\n isFinishTrimmed?: boolean;\n /** Mutates a handle-passing inout parameter in place instead of packing it into the result; defaults to false. */\n isInoutInPlace?: boolean;\n};\n\n/** What a `runCodegen` run produced. */\ntype CodegenRunnerResult = {\n /** Whether either store was rewritten; false means both were already fresh. */\n isRegenerated: boolean;\n /** How many namespaces the gi store was written with, zero when it was already fresh. */\n namespaces: number;\n /** How many JSX elements the jsx store binds, zero when no jsx store was requested. */\n intrinsicElements: number;\n /** Deprecation notices about how the store was wired, one line each; empty when nothing needs attention. */\n notices: string[];\n /** Wall-clock duration of the run, in milliseconds. */\n duration: number;\n};\n\ntype StoreResult = {\n isRegenerated: boolean;\n namespaces: number;\n intrinsicElements: number;\n};\n\n/**\n * Writes and links a project's `@gtkx/gi` and `@gtkx/jsx` stores from the given GObject-Introspection\n * libraries. The gi store is rewritten only when its GIR inputs changed, and the jsx store only when the gi\n * store or the React element config changed, unless `options.isForced` is set. Pass the spread of\n * `resolveStore(projectRoot)` for everything but `libraries` and `girPath`.\n *\n * Every store already on disk is linked at its `linkDir` before anything is generated, so a link an install\n * pruned out of `node_modules` is restored without regenerating the store, and the gi store is reachable\n * under its own specifier while the jsx store is type checked.\n *\n * @param options What to generate and where to write it.\n * @returns A summary of what was regenerated and how long the run took.\n * @throws If `girPath` is empty, which would otherwise generate nothing and report success.\n */\nconst runCodegen = async (options: CodegenRunnerOptions): Promise<CodegenRunnerResult> => {\n const start = Date.now();\n const store = await emitStores(options);\n\n return {\n isRegenerated: store.isRegenerated,\n namespaces: store.namespaces,\n intrinsicElements: store.intrinsicElements,\n notices: externalPackageNotices(options.gi),\n duration: Date.now() - start,\n };\n};\n\nconst runGlCodegen = (options: GlCodegenOptions): GlGenerationReport => {\n const { files, report } = generateGlModules({\n registryPath: options.registryPath,\n overrideExports: options.overrideExports,\n });\n\n checkModules({\n modules: [...files].map(([fileName, source]) => ({ fileName, source })),\n resolveFrom: options.resolveFrom,\n label: \"the generated gl modules\",\n });\n\n mkdirSync(options.outputDir, { recursive: true });\n\n for (const [fileName, source] of files) {\n writeFileSync(join(options.outputDir, fileName), source);\n }\n\n return report;\n};\n\nconst jsxUserOptions = (\n options: CodegenRunnerOptions,\n): {\n reactSubexports: string[];\n userComponents: Record<string, ModuleExport>;\n userLazyElements: string[];\n userProps: Record<string, ModuleExport>;\n userOmittedProps: OmittedProps;\n} => ({\n reactSubexports: options.reactSubexports ?? [],\n userComponents: options.userComponents ?? {},\n userLazyElements: options.userLazyElements ?? [],\n userProps: options.userProps ?? {},\n userOmittedProps: options.userOmittedProps ?? {},\n});\n\nconst emitJsxStore = async (input: {\n options: CodegenRunnerOptions;\n jsx: StoreOptions;\n gi: StoreOptions;\n loadLibrary: () => Library;\n isGiRegenerated: boolean;\n namespaces: number;\n}): Promise<StoreResult> => {\n const { options, jsx, gi, loadLibrary, isGiRegenerated, namespaces } = input;\n const { runJsxCodegen } = await import(\"./jsx.js\");\n\n const jsxResult = await runJsxCodegen({\n getLibrary: loadLibrary,\n jsx,\n giStoreDir: gi.storeDir,\n ...jsxUserOptions(options),\n isGiRegenerated,\n isForced: options.isForced === true,\n });\n\n return {\n isRegenerated: isGiRegenerated || jsxResult.isRegenerated,\n namespaces,\n intrinsicElements: jsxResult.intrinsicElementCount,\n };\n};\n\nconst emitStoresWithConfig = async (config: {\n options: CodegenRunnerOptions;\n gi: StoreOptions;\n jsx: StoreOptions | undefined;\n libraries: string[];\n girPath: string[];\n}): Promise<StoreResult> => {\n const { options, gi, jsx, libraries, girPath } = config;\n const isByteArrayTyped = options.isByteArrayTyped === true;\n const isValueUnwrapped = options.isValueUnwrapped === true;\n const isFinishTrimmed = options.isFinishTrimmed === true;\n const isInoutInPlace = options.isInoutInPlace === true;\n const future = { isByteArrayTyped, isValueUnwrapped, isFinishTrimmed, isInoutInPlace };\n let library: Library | undefined;\n const loadLibrary = (): Library => (library ??= Library.load(libraries, girPath, future));\n const giInputs = { girFiles: [] as string[], libraries, girPath, storeVersion: gi.version, ...future };\n const isGiRegenerated = options.isForced === true || !isGiStoreFresh(gi.storeDir, giInputs);\n\n const namespaces = isGiRegenerated\n ? runGiCodegen(loadLibrary(), { gi, libraries, girPath, ...future })\n : 0;\n\n if (jsx === undefined) {\n return { isRegenerated: isGiRegenerated, namespaces, intrinsicElements: 0 };\n }\n\n return emitJsxStore({ options, jsx, gi, loadLibrary, isGiRegenerated, namespaces });\n};\n\nconst prepareStores = (stores: (StoreOptions | undefined)[]): void => {\n for (const store of stores) {\n if (store === undefined) {\n continue;\n }\n\n sweepStagingDirs(store.storeDir);\n ensureStoreLink(store);\n }\n};\n\nconst emitStores = async (options: CodegenRunnerOptions): Promise<StoreResult> => {\n const { gi, jsx, libraries, girPath } = options;\n\n if (girPath.length === 0) {\n throw new Error(\"codegen needs at least one GIR search path; pass the result of resolveGirPath\");\n }\n\n prepareStores([gi, jsx]);\n\n return emitStoresWithConfig({ options, gi, jsx, libraries, girPath });\n};\n\nexport { runCodegen, runGlCodegen, type CodegenRunnerOptions, type CodegenRunnerResult };\n"]}
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAA2B,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAqB,MAAM,qBAAqB,CAAC;AA+DzE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,OAA6B,EAAgC,EAAE;IACrF,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;IAExC,OAAO;QACH,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,OAAO,EAAE,sBAAsB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;KAC/B,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,OAAyB,EAAsB,EAAE;IACnE,MAAM,EAAE,KAAK,EAAE,MAAM,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CAAC,CAAC,CAAC;IAEzB,OAAO,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAuD,CAAC","sourcesContent":["import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { ModuleExport } from \"./react/element-config.js\";\nimport type { OmittedProps } from \"./store/jsx/omitted-props.js\";\nimport { checkModules } from \"./compile.js\";\nimport { isGiStoreFresh } from \"./fingerprint.js\";\nimport { runGiCodegen } from \"./gi.js\";\nimport { Library } from \"./gir/library.js\";\nimport { generateGlModules, type GlGenerationReport } from \"./khronos/pipeline.js\";\nimport { sweepStagingDirs } from \"./staging.js\";\nimport { externalPackageNotices } from \"./store/external-package-links.js\";\nimport { ensureStoreLink, type StoreOptions } from \"./store/store-fs.js\";\n\ntype GlCodegenOptions = {\n registryPath: string;\n overrideExports: Set<string>;\n outputDir: string;\n resolveFrom: string;\n};\n\n/** What to generate and where to write it. */\ntype CodegenRunnerOptions = {\n /** GIR library identifiers such as `\"Gtk-4.0\"`; a `\"*\"` selection must be expanded before it gets here. */\n libraries: string[];\n /** Directories to search for `.gir` files. */\n girPath: string[];\n /** Where to write and link the `@gtkx/gi` store. */\n gi: StoreOptions;\n /** Where to write and link the `@gtkx/jsx` store; omit to generate the gi store alone. */\n jsx?: StoreOptions | undefined;\n /** Subexport names of the installed `@gtkx/react`, whose element config shapes the jsx store. */\n reactSubexports?: string[];\n /** Component wrappers the project layers over the built-ins, keyed by GLib type name. */\n userComponents?: Record<string, ModuleExport>;\n /** GLib type names whose GObject their parent container creates, added to the framework's own. */\n userLazyElements?: string[];\n /** Base props interfaces the project's elements extend, keyed by GLib type name. */\n userProps?: Record<string, ModuleExport>;\n /** Props the project drops from the generated element props, keyed by GLib type name. */\n userOmittedProps?: OmittedProps;\n /** Regenerates both stores even when their fingerprints are fresh. */\n isForced?: boolean;\n /** Emits GIR byte sequences as `Uint8Array` rather than `number[]`; defaults to false. */\n isByteArrayTyped?: boolean;\n /** Surfaces a `GObject.Value` a binding hands back as what it holds rather than as the value; defaults to false. */\n isValueUnwrapped?: boolean;\n /** Drops the leading success boolean from promisified results of a throwing finish; defaults to false. */\n isFinishTrimmed?: boolean;\n /** Mutates a handle-passing inout parameter in place instead of packing it into the result; defaults to false. */\n isInoutInPlace?: boolean;\n /** Folds registrations into each class so bundlers can drop unused ones; defaults to false. */\n isTreeShaken?: boolean;\n};\n\n/** What a `runCodegen` run produced. */\ntype CodegenRunnerResult = {\n /** Whether either store was rewritten; false means both were already fresh. */\n isRegenerated: boolean;\n /** How many namespaces the gi store was written with, zero when it was already fresh. */\n namespaces: number;\n /** How many JSX elements the jsx store binds, zero when no jsx store was requested. */\n intrinsicElements: number;\n /** Deprecation notices about how the store was wired, one line each; empty when nothing needs attention. */\n notices: string[];\n /** Wall-clock duration of the run, in milliseconds. */\n duration: number;\n};\n\ntype StoreResult = {\n isRegenerated: boolean;\n namespaces: number;\n intrinsicElements: number;\n};\n\n/**\n * Writes and links a project's `@gtkx/gi` and `@gtkx/jsx` stores from the given GObject-Introspection\n * libraries. The gi store is rewritten only when its GIR inputs changed, and the jsx store only when the gi\n * store or the React element config changed, unless `options.isForced` is set. Pass the spread of\n * `resolveStore(projectRoot)` for everything but `libraries` and `girPath`.\n *\n * Every store already on disk is linked at its `linkDir` before anything is generated, so a link an install\n * pruned out of `node_modules` is restored without regenerating the store, and the gi store is reachable\n * under its own specifier while the jsx store is type checked.\n *\n * @param options What to generate and where to write it.\n * @returns A summary of what was regenerated and how long the run took.\n * @throws If `girPath` is empty, which would otherwise generate nothing and report success.\n */\nconst runCodegen = async (options: CodegenRunnerOptions): Promise<CodegenRunnerResult> => {\n const start = Date.now();\n const store = await emitStores(options);\n\n return {\n isRegenerated: store.isRegenerated,\n namespaces: store.namespaces,\n intrinsicElements: store.intrinsicElements,\n notices: externalPackageNotices(options.gi),\n duration: Date.now() - start,\n };\n};\n\nconst runGlCodegen = (options: GlCodegenOptions): GlGenerationReport => {\n const { files, report } = generateGlModules({\n registryPath: options.registryPath,\n overrideExports: options.overrideExports,\n });\n\n checkModules({\n modules: [...files].map(([fileName, source]) => ({ fileName, source })),\n resolveFrom: options.resolveFrom,\n label: \"the generated gl modules\",\n });\n\n mkdirSync(options.outputDir, { recursive: true });\n\n for (const [fileName, source] of files) {\n writeFileSync(join(options.outputDir, fileName), source);\n }\n\n return report;\n};\n\nconst jsxUserOptions = (\n options: CodegenRunnerOptions,\n): {\n reactSubexports: string[];\n userComponents: Record<string, ModuleExport>;\n userLazyElements: string[];\n userProps: Record<string, ModuleExport>;\n userOmittedProps: OmittedProps;\n} => ({\n reactSubexports: options.reactSubexports ?? [],\n userComponents: options.userComponents ?? {},\n userLazyElements: options.userLazyElements ?? [],\n userProps: options.userProps ?? {},\n userOmittedProps: options.userOmittedProps ?? {},\n});\n\nconst emitJsxStore = async (input: {\n options: CodegenRunnerOptions;\n jsx: StoreOptions;\n gi: StoreOptions;\n loadLibrary: () => Library;\n isGiRegenerated: boolean;\n namespaces: number;\n}): Promise<StoreResult> => {\n const { options, jsx, gi, loadLibrary, isGiRegenerated, namespaces } = input;\n const { runJsxCodegen } = await import(\"./jsx.js\");\n\n const jsxResult = await runJsxCodegen({\n getLibrary: loadLibrary,\n jsx,\n giStoreDir: gi.storeDir,\n ...jsxUserOptions(options),\n isGiRegenerated,\n isForced: options.isForced === true,\n isTreeShaken: options.isTreeShaken === true,\n });\n\n return {\n isRegenerated: isGiRegenerated || jsxResult.isRegenerated,\n namespaces,\n intrinsicElements: jsxResult.intrinsicElementCount,\n };\n};\n\nconst emitStoresWithConfig = async (config: {\n options: CodegenRunnerOptions;\n gi: StoreOptions;\n jsx: StoreOptions | undefined;\n libraries: string[];\n girPath: string[];\n}): Promise<StoreResult> => {\n const { options, gi, jsx, libraries, girPath } = config;\n const isByteArrayTyped = options.isByteArrayTyped === true;\n const isValueUnwrapped = options.isValueUnwrapped === true;\n const isFinishTrimmed = options.isFinishTrimmed === true;\n const isInoutInPlace = options.isInoutInPlace === true;\n const isTreeShaken = options.isTreeShaken === true;\n const future = { isByteArrayTyped, isValueUnwrapped, isFinishTrimmed, isInoutInPlace, isTreeShaken };\n let library: Library | undefined;\n const loadLibrary = (): Library => (library ??= Library.load(libraries, girPath, future));\n const giInputs = { girFiles: [] as string[], libraries, girPath, storeVersion: gi.version, ...future };\n const isGiRegenerated = options.isForced === true || !isGiStoreFresh(gi.storeDir, giInputs);\n\n const namespaces = isGiRegenerated\n ? runGiCodegen(loadLibrary(), { gi, libraries, girPath, ...future })\n : 0;\n\n if (jsx === undefined) {\n return { isRegenerated: isGiRegenerated, namespaces, intrinsicElements: 0 };\n }\n\n return emitJsxStore({ options, jsx, gi, loadLibrary, isGiRegenerated, namespaces });\n};\n\nconst prepareStores = (stores: (StoreOptions | undefined)[]): void => {\n for (const store of stores) {\n if (store === undefined) {\n continue;\n }\n\n sweepStagingDirs(store.storeDir);\n ensureStoreLink(store);\n }\n};\n\nconst emitStores = async (options: CodegenRunnerOptions): Promise<StoreResult> => {\n const { gi, jsx, libraries, girPath } = options;\n\n if (girPath.length === 0) {\n throw new Error(\"codegen needs at least one GIR search path; pass the result of resolveGirPath\");\n }\n\n prepareStores([gi, jsx]);\n\n return emitStoresWithConfig({ options, gi, jsx, libraries, girPath });\n};\n\nexport { runCodegen, runGlCodegen, type CodegenRunnerOptions, type CodegenRunnerResult };\n"]}
@@ -0,0 +1,4 @@
1
+ import type { ModuleContext } from "../../writer/context.js";
2
+ declare const renderBootstrapModule: (context: ModuleContext) => string;
3
+ export { renderBootstrapModule };
4
+ //# sourceMappingURL=bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../src/store/gi/bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAyC7D,QAAA,MAAM,qBAAqB,GAAI,SAAS,aAAa,KAAG,MAmBvD,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { sortStrings, sourceStringLiteral } from "@gtkx/utils";
2
+ import { namespaceDirectory } from "../../gir/namespace.js";
3
+ const PATCHING_OVERRIDES = {
4
+ glib: ["./overrides/regex.js"],
5
+ gobject: ["./overrides/object.js", "./overrides/param-spec-getters.js", "./overrides/value.js"],
6
+ };
7
+ const CORE_WRAPPERS = {
8
+ glib: ["Error", "Variant"],
9
+ gobject: ["ParamSpec", "Value"],
10
+ };
11
+ const renderDependencyImports = (context) => [
12
+ ...sortStrings(context.dependencies).map((dependency) => `import "../${dependency}/bootstrap.js";`),
13
+ ...sortStrings(context.externalDependencies).map((packageName) => `import ${sourceStringLiteral(packageName)};`),
14
+ ];
15
+ const renderOverrideImports = (directory) => (PATCHING_OVERRIDES[directory] ?? []).map((override) => `import ${sourceStringLiteral(override)};`);
16
+ const renderRuntimeImport = (context, coreWrappers) => {
17
+ const runtimeImports = new Set(context.bootstrapRuntimeImports);
18
+ if (coreWrappers.length > 0) {
19
+ runtimeImports.add("retainWrapperClasses");
20
+ }
21
+ if (runtimeImports.size === 0) {
22
+ return [];
23
+ }
24
+ return [`import { ${sortStrings(runtimeImports).join(", ")} } from "@gtkx/runtime";`];
25
+ };
26
+ const renderModuleImports = (context, directory, coreWrappers) => {
27
+ const moduleImports = sortStrings(new Set([...context.bootstrapModuleExports, ...coreWrappers]));
28
+ return moduleImports.length === 0 ? [] : [`import { ${moduleImports.join(", ")} } from "./${directory}.js";`];
29
+ };
30
+ const renderBootstrapModule = (context) => {
31
+ const directory = namespaceDirectory(context.namespace);
32
+ const coreWrappers = CORE_WRAPPERS[directory] ?? [];
33
+ const retention = coreWrappers.length === 0
34
+ ? []
35
+ : [`retainWrapperClasses([${coreWrappers.join(", ")}]);`];
36
+ const lines = [
37
+ ...renderDependencyImports(context),
38
+ ...renderOverrideImports(directory),
39
+ ...renderRuntimeImport(context, coreWrappers),
40
+ ...renderModuleImports(context, directory, coreWrappers),
41
+ "",
42
+ ...retention,
43
+ ...context.bootstrapCalls,
44
+ ];
45
+ return `${lines.join("\n")}\n`;
46
+ };
47
+ export { renderBootstrapModule };
48
+ //# sourceMappingURL=bootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../../src/store/gi/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,kBAAkB,GAA6B;IACjD,IAAI,EAAE,CAAC,sBAAsB,CAAC;IAC9B,OAAO,EAAE,CAAC,uBAAuB,EAAE,mCAAmC,EAAE,sBAAsB,CAAC;CAClG,CAAC;AAEF,MAAM,aAAa,GAA6B;IAC5C,IAAI,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC;IAC1B,OAAO,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,OAAsB,EAAY,EAAE,CAAC;IAClE,GAAG,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,cAAc,UAAU,iBAAiB,CAAC;IACnG,GAAG,WAAW,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,UAAU,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC;CACnH,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,SAAiB,EAAY,EAAE,CAC1D,CAAC,kBAAkB,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,UAAU,mBAAmB,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,CAAC,CAAC;IAE9D,MAAM,KAAK,GAAG;QACV,GAAG,uBAAuB,CAAC,OAAO,CAAC;QACnC,GAAG,qBAAqB,CAAC,SAAS,CAAC;QACnC,GAAG,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC;QAC7C,GAAG,mBAAmB,CAAC,OAAO,EAAE,SAAS,EAAE,YAAY,CAAC;QACxD,EAAE;QACF,GAAG,SAAS;QACZ,GAAG,OAAO,CAAC,cAAc;KAC5B,CAAC;IAEF,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACnC,CAAC,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["import { sortStrings, sourceStringLiteral } from \"@gtkx/utils\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { namespaceDirectory } from \"../../gir/namespace.js\";\n\nconst PATCHING_OVERRIDES: Record<string, string[]> = {\n glib: [\"./overrides/regex.js\"],\n gobject: [\"./overrides/object.js\", \"./overrides/param-spec-getters.js\", \"./overrides/value.js\"],\n};\n\nconst CORE_WRAPPERS: Record<string, string[]> = {\n glib: [\"Error\", \"Variant\"],\n gobject: [\"ParamSpec\", \"Value\"],\n};\n\nconst renderDependencyImports = (context: ModuleContext): string[] => [\n ...sortStrings(context.dependencies).map((dependency) => `import \"../${dependency}/bootstrap.js\";`),\n ...sortStrings(context.externalDependencies).map((packageName) => `import ${sourceStringLiteral(packageName)};`),\n];\n\nconst renderOverrideImports = (directory: string): string[] =>\n (PATCHING_OVERRIDES[directory] ?? []).map((override) => `import ${sourceStringLiteral(override)};`);\n\nconst renderRuntimeImport = (context: ModuleContext, coreWrappers: string[]): string[] => {\n const runtimeImports = new Set(context.bootstrapRuntimeImports);\n\n if (coreWrappers.length > 0) {\n runtimeImports.add(\"retainWrapperClasses\");\n }\n\n if (runtimeImports.size === 0) {\n return [];\n }\n\n return [`import { ${sortStrings(runtimeImports).join(\", \")} } from \"@gtkx/runtime\";`];\n};\n\nconst renderModuleImports = (context: ModuleContext, directory: string, coreWrappers: string[]): string[] => {\n const moduleImports = sortStrings(new Set([...context.bootstrapModuleExports, ...coreWrappers]));\n\n return moduleImports.length === 0 ? [] : [`import { ${moduleImports.join(\", \")} } from \"./${directory}.js\";`];\n};\n\nconst renderBootstrapModule = (context: ModuleContext): string => {\n const directory = namespaceDirectory(context.namespace);\n const coreWrappers = CORE_WRAPPERS[directory] ?? [];\n\n const retention = coreWrappers.length === 0\n ? []\n : [`retainWrapperClasses([${coreWrappers.join(\", \")}]);`];\n\n const lines = [\n ...renderDependencyImports(context),\n ...renderOverrideImports(directory),\n ...renderRuntimeImport(context, coreWrappers),\n ...renderModuleImports(context, directory, coreWrappers),\n \"\",\n ...retention,\n ...context.bootstrapCalls,\n ];\n\n return `${lines.join(\"\\n\")}\\n`;\n};\n\nexport { renderBootstrapModule };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../../src/store/gi/class.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AA6E7D,QAAA,MAAM,aAAa,GAAI,SAAS,aAAa,EAAE,OAAO,QAAQ,KAAG,IAsChE,CAAC;AA8UF,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../../src/store/gi/class.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAsF7D,QAAA,MAAM,aAAa,GAAI,SAAS,aAAa,EAAE,OAAO,QAAQ,KAAG,IAgDhE,CAAC;AAkYF,OAAO,EAAE,aAAa,EAAE,CAAC"}