@gtkx/codegen 1.2.2 → 1.4.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 (218) hide show
  1. package/README.md +6 -4
  2. package/dist/analysis/descriptor-render.d.ts +7 -1
  3. package/dist/analysis/descriptor-render.d.ts.map +1 -1
  4. package/dist/analysis/descriptor-render.js +37 -15
  5. package/dist/analysis/descriptor-render.js.map +1 -1
  6. package/dist/analysis/descriptor.d.ts +5 -1
  7. package/dist/analysis/descriptor.d.ts.map +1 -1
  8. package/dist/analysis/descriptor.js +12 -2
  9. package/dist/analysis/descriptor.js.map +1 -1
  10. package/dist/analysis/param-capability.d.ts +5 -2
  11. package/dist/analysis/param-capability.d.ts.map +1 -1
  12. package/dist/analysis/param-capability.js +36 -4
  13. package/dist/analysis/param-capability.js.map +1 -1
  14. package/dist/analysis/param-structure.d.ts +1 -1
  15. package/dist/analysis/param-structure.d.ts.map +1 -1
  16. package/dist/analysis/param-structure.js.map +1 -1
  17. package/dist/analysis/ts-type.d.ts +1 -1
  18. package/dist/analysis/ts-type.d.ts.map +1 -1
  19. package/dist/analysis/ts-type.js +28 -10
  20. package/dist/analysis/ts-type.js.map +1 -1
  21. package/dist/compile.js +1 -1
  22. package/dist/compile.js.map +1 -1
  23. package/dist/docs/api-reference.d.ts +6 -0
  24. package/dist/docs/api-reference.d.ts.map +1 -1
  25. package/dist/docs/api-reference.js +11 -2
  26. package/dist/docs/api-reference.js.map +1 -1
  27. package/dist/docs/pipeline.d.ts +3 -0
  28. package/dist/docs/pipeline.d.ts.map +1 -1
  29. package/dist/docs/pipeline.js +10 -1
  30. package/dist/docs/pipeline.js.map +1 -1
  31. package/dist/fingerprint.d.ts +5 -0
  32. package/dist/fingerprint.d.ts.map +1 -1
  33. package/dist/fingerprint.js +111 -15
  34. package/dist/fingerprint.js.map +1 -1
  35. package/dist/gi.d.ts +3 -0
  36. package/dist/gi.d.ts.map +1 -1
  37. package/dist/gi.js +33 -7
  38. package/dist/gi.js.map +1 -1
  39. package/dist/gir/external-namespaces.d.ts +8 -0
  40. package/dist/gir/external-namespaces.d.ts.map +1 -0
  41. package/dist/gir/external-namespaces.js +4 -0
  42. package/dist/gir/external-namespaces.js.map +1 -0
  43. package/dist/gir/finish-overrides.d.ts +3 -0
  44. package/dist/gir/finish-overrides.d.ts.map +1 -0
  45. package/dist/gir/finish-overrides.js +5 -0
  46. package/dist/gir/finish-overrides.js.map +1 -0
  47. package/dist/gir/function.d.ts +5 -2
  48. package/dist/gir/function.d.ts.map +1 -1
  49. package/dist/gir/function.js +34 -5
  50. package/dist/gir/function.js.map +1 -1
  51. package/dist/gir/hidden-symbols.d.ts +3 -0
  52. package/dist/gir/hidden-symbols.d.ts.map +1 -0
  53. package/dist/gir/hidden-symbols.js +39 -0
  54. package/dist/gir/hidden-symbols.js.map +1 -0
  55. package/dist/gir/library.d.ts +22 -2
  56. package/dist/gir/library.d.ts.map +1 -1
  57. package/dist/gir/library.js +21 -3
  58. package/dist/gir/library.js.map +1 -1
  59. package/dist/gir/ucs4-overrides.d.ts +3 -0
  60. package/dist/gir/ucs4-overrides.d.ts.map +1 -0
  61. package/dist/gir/ucs4-overrides.js +7 -0
  62. package/dist/gir/ucs4-overrides.js.map +1 -0
  63. package/dist/guards.d.ts +2 -1
  64. package/dist/guards.d.ts.map +1 -1
  65. package/dist/guards.js +3 -1
  66. package/dist/guards.js.map +1 -1
  67. package/dist/index.d.ts +2 -0
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +2 -0
  70. package/dist/index.js.map +1 -1
  71. package/dist/jsx.d.ts.map +1 -1
  72. package/dist/jsx.js +27 -8
  73. package/dist/jsx.js.map +1 -1
  74. package/dist/runner.d.ts +8 -0
  75. package/dist/runner.d.ts.map +1 -1
  76. package/dist/runner.js +9 -3
  77. package/dist/runner.js.map +1 -1
  78. package/dist/store/external-package-links.d.ts +6 -0
  79. package/dist/store/external-package-links.d.ts.map +1 -0
  80. package/dist/store/external-package-links.js +158 -0
  81. package/dist/store/external-package-links.js.map +1 -0
  82. package/dist/store/gi/callable-doc.d.ts.map +1 -1
  83. package/dist/store/gi/callable-doc.js +4 -4
  84. package/dist/store/gi/callable-doc.js.map +1 -1
  85. package/dist/store/gi/callables.js +1 -1
  86. package/dist/store/gi/callables.js.map +1 -1
  87. package/dist/store/gi/class.d.ts.map +1 -1
  88. package/dist/store/gi/class.js +17 -0
  89. package/dist/store/gi/class.js.map +1 -1
  90. package/dist/store/gi/constructor-props.js +1 -1
  91. package/dist/store/gi/constructor-props.js.map +1 -1
  92. package/dist/store/gi/function.d.ts.map +1 -1
  93. package/dist/store/gi/function.js +2 -1
  94. package/dist/store/gi/function.js.map +1 -1
  95. package/dist/store/gi/generated-libraries.d.ts +26 -0
  96. package/dist/store/gi/generated-libraries.d.ts.map +1 -0
  97. package/dist/store/gi/generated-libraries.js +53 -0
  98. package/dist/store/gi/generated-libraries.js.map +1 -0
  99. package/dist/store/gi/gtype-binding.d.ts +2 -1
  100. package/dist/store/gi/gtype-binding.d.ts.map +1 -1
  101. package/dist/store/gi/gtype-binding.js +6 -1
  102. package/dist/store/gi/gtype-binding.js.map +1 -1
  103. package/dist/store/gi/method.d.ts +7 -2
  104. package/dist/store/gi/method.d.ts.map +1 -1
  105. package/dist/store/gi/method.js +126 -30
  106. package/dist/store/gi/method.js.map +1 -1
  107. package/dist/store/gi/param-marshal.d.ts +8 -1
  108. package/dist/store/gi/param-marshal.d.ts.map +1 -1
  109. package/dist/store/gi/param-marshal.js +52 -4
  110. package/dist/store/gi/param-marshal.js.map +1 -1
  111. package/dist/store/gi/record-constructor.d.ts.map +1 -1
  112. package/dist/store/gi/record-constructor.js +2 -3
  113. package/dist/store/gi/record-constructor.js.map +1 -1
  114. package/dist/store/gi/record-field-accessor.d.ts +2 -1
  115. package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
  116. package/dist/store/gi/record-field-accessor.js +9 -3
  117. package/dist/store/gi/record-field-accessor.js.map +1 -1
  118. package/dist/store/gi/runtime-override.js +1 -1
  119. package/dist/store/gi/runtime-override.js.map +1 -1
  120. package/dist/store/gi/signal.js +2 -2
  121. package/dist/store/gi/signal.js.map +1 -1
  122. package/dist/store/gi/vtable.d.ts.map +1 -1
  123. package/dist/store/gi/vtable.js +82 -12
  124. package/dist/store/gi/vtable.js.map +1 -1
  125. package/dist/store/gi-store.d.ts +12 -2
  126. package/dist/store/gi-store.d.ts.map +1 -1
  127. package/dist/store/gi-store.js +24 -5
  128. package/dist/store/gi-store.js.map +1 -1
  129. package/dist/store/jsx/jsx.d.ts.map +1 -1
  130. package/dist/store/jsx/jsx.js +3 -1
  131. package/dist/store/jsx/jsx.js.map +1 -1
  132. package/dist/store/jsx/metadata.d.ts.map +1 -1
  133. package/dist/store/jsx/metadata.js +35 -60
  134. package/dist/store/jsx/metadata.js.map +1 -1
  135. package/dist/store/jsx-store.d.ts +8 -1
  136. package/dist/store/jsx-store.d.ts.map +1 -1
  137. package/dist/store/jsx-store.js +9 -2
  138. package/dist/store/jsx-store.js.map +1 -1
  139. package/dist/store/resolve-store.d.ts +2 -1
  140. package/dist/store/resolve-store.d.ts.map +1 -1
  141. package/dist/store/resolve-store.js +3 -1
  142. package/dist/store/resolve-store.js.map +1 -1
  143. package/dist/store/store-fs.d.ts +2 -1
  144. package/dist/store/store-fs.d.ts.map +1 -1
  145. package/dist/store/store-fs.js +8 -3
  146. package/dist/store/store-fs.js.map +1 -1
  147. package/dist/writer/context.d.ts.map +1 -1
  148. package/dist/writer/context.js +8 -0
  149. package/dist/writer/context.js.map +1 -1
  150. package/dist/writer/gtk-doc.d.ts.map +1 -1
  151. package/dist/writer/gtk-doc.js +27 -1
  152. package/dist/writer/gtk-doc.js.map +1 -1
  153. package/overrides/gdk/rgba.ts.ejs +15 -1
  154. package/overrides/glib/index.ts.ejs +3 -0
  155. package/overrides/glib/regex.ts.ejs +66 -0
  156. package/overrides/gobject/index.ts.ejs +3 -0
  157. package/overrides/gobject/object-class.ts.ejs +27 -0
  158. package/overrides/gobject/param-spec-getters.ts.ejs +57 -0
  159. package/overrides/gobject/param-spec.ts.ejs +21 -0
  160. package/overrides/gobject/value.ts.ejs +6 -1
  161. package/overrides/graphene/structs.ts.ejs +38 -3
  162. package/overrides/gtk/index.ts.ejs +2 -0
  163. package/overrides/gtk/widget-class.ts.ejs +28 -0
  164. package/package.json +7 -6
  165. package/src/analysis/descriptor-render.ts +60 -16
  166. package/src/analysis/descriptor.ts +17 -3
  167. package/src/analysis/param-capability.ts +68 -5
  168. package/src/analysis/param-structure.ts +1 -1
  169. package/src/analysis/ts-type.ts +45 -11
  170. package/src/compile.ts +1 -1
  171. package/src/docs/api-reference.ts +20 -2
  172. package/src/docs/pipeline.ts +15 -1
  173. package/src/fingerprint.ts +151 -16
  174. package/src/gi.ts +48 -9
  175. package/src/gir/external-namespaces.ts +8 -0
  176. package/src/gir/finish-overrides.ts +5 -0
  177. package/src/gir/function.ts +52 -14
  178. package/src/gir/hidden-symbols.ts +39 -0
  179. package/src/gir/library.ts +36 -3
  180. package/src/gir/ucs4-overrides.ts +7 -0
  181. package/src/guards.ts +6 -1
  182. package/src/index.ts +2 -0
  183. package/src/jsx.ts +33 -8
  184. package/src/runner.ts +17 -3
  185. package/src/store/external-package-links.ts +226 -0
  186. package/src/store/gi/callable-doc.ts +8 -4
  187. package/src/store/gi/callables.ts +1 -1
  188. package/src/store/gi/class.ts +29 -0
  189. package/src/store/gi/constructor-props.ts +1 -1
  190. package/src/store/gi/function.ts +2 -1
  191. package/src/store/gi/generated-libraries.ts +91 -0
  192. package/src/store/gi/gtype-binding.ts +8 -1
  193. package/src/store/gi/method.ts +189 -36
  194. package/src/store/gi/param-marshal.ts +67 -4
  195. package/src/store/gi/record-constructor.ts +8 -3
  196. package/src/store/gi/record-field-accessor.ts +11 -2
  197. package/src/store/gi/runtime-override.ts +1 -1
  198. package/src/store/gi/signal.ts +2 -2
  199. package/src/store/gi/vtable.ts +118 -11
  200. package/src/store/gi-store.ts +48 -5
  201. package/src/store/jsx/jsx.ts +3 -1
  202. package/src/store/jsx/metadata.ts +46 -99
  203. package/src/store/jsx-store.ts +23 -7
  204. package/src/store/resolve-store.ts +3 -1
  205. package/src/store/store-fs.ts +10 -2
  206. package/src/writer/context.ts +11 -0
  207. package/src/writer/gtk-doc.ts +38 -1
  208. package/overrides/cairo/context.ts.ejs +0 -1269
  209. package/overrides/cairo/font-face.ts.ejs +0 -151
  210. package/overrides/cairo/font-options.ts.ejs +0 -199
  211. package/overrides/cairo/image-surface.ts.ejs +0 -132
  212. package/overrides/cairo/index.ts.ejs +0 -22
  213. package/overrides/cairo/matrix.ts.ejs +0 -171
  214. package/overrides/cairo/pattern.ts.ejs +0 -476
  215. package/overrides/cairo/recording-surface.ts.ejs +0 -102
  216. package/overrides/cairo/region.ts.ejs +0 -237
  217. package/overrides/cairo/scaled-font.ts.ejs +0 -330
  218. package/overrides/cairo/surface.ts.ejs +0 -296
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-store.js","sourceRoot":"","sources":["../../src/store/resolve-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAkBjD,MAAM,SAAS,GAAG,OAAO,CAAC;AAC1B,MAAM,KAAK,GAAG,OAAO,CAAC;AACtB,MAAM,WAAW,GAAa,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAE5C,MAAM,eAAe,GAAa;IAC9B,WAAW;IACX,kBAAkB;IAClB,WAAW;IACX,aAAa;IACb,eAAe;IACf,eAAe;CAClB,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,IAAY,EAA2D,EAAE,CAC3F,IAAI,CAAC,KAAK,CAAC,YAAY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O,CAAC;QACpD,GAAG,EAAE,UAAU,CAAC,KAAK,EAAE,WAAW,CAAC;QACnC,eAAe,EAAE,kBAAkB,CAAC,KAAK,CAAC;KAC7C,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,mBAAmB,EAAsB,CAAC","sourcesContent":["import { existsSync, readFileSync, realpathSync } from \"node:fs\";\nimport { dirname, join, parse, relative, sep } from \"node:path\";\nimport type { StoreOptions } from \"./store-fs.js\";\nimport { sweepStagingDirs } from \"../staging.js\";\n\n/**\n * Where a project's generated stores live, ready to spread into `runCodegen`. `jsx` is null when the\n * project has no `@gtkx/react` installed, in which case only the `@gtkx/gi` store can be generated.\n */\ntype ResolvedStore = {\n /** Where the `@gtkx/gi` store goes, versioned by the installed `@gtkx/runtime`. */\n gi: StoreOptions;\n /** Where the `@gtkx/jsx` store goes, versioned by the installed `@gtkx/react`; null when it is absent. */\n jsx: StoreOptions | null;\n /** Subexport names of the installed `@gtkx/react`, empty when it is absent. */\n reactSubexports: string[];\n};\n\ntype ResolvedPackage = { dir: string; nodeModules: string; version: string };\ntype StoreConsumer = { name: string; nodeModules: string };\n\nconst STORE_DIR = \".gtkx\";\nconst SCOPE = \"@gtkx\";\nconst STORE_NAMES: string[] = [\"gi\", \"jsx\"];\n\nconst STORE_CONSUMERS: string[] = [\n \"@gtkx/cli\",\n \"@gtkx/components\",\n \"@gtkx/css\",\n \"@gtkx/react\",\n \"@gtkx/runtime\",\n \"@gtkx/testing\",\n];\n\nconst readManifest = (path: string): { version?: string; exports?: Record<string, unknown> } =>\n JSON.parse(readFileSync(path, \"utf8\")) as { version?: string; exports?: Record<string, unknown> };\n\nconst subexportNames = (packageDir: string): string[] =>\n Object.keys(readManifest(join(packageDir, \"package.json\")).exports ?? {})\n .filter((key) => key.startsWith(\"./\") && key !== \"./package.json\")\n .map((key) => key.slice(2));\n\nconst loadPackage = (manifest: string, nodeModules: string): ResolvedPackage | null => {\n if (!existsSync(manifest)) {\n return null;\n }\n\n const real = realpathSync(manifest);\n\n return { dir: dirname(real), nodeModules, version: readManifest(real).version ?? \"0.0.0\" };\n};\n\nconst nodeModulesChain = function* (projectRoot: string): Generator<string> {\n const { root } = parse(projectRoot);\n let current = projectRoot;\n\n while (current !== root) {\n yield join(current, \"node_modules\");\n current = dirname(current);\n }\n\n yield join(root, \"node_modules\");\n};\n\nconst resolvePackage = (projectRoot: string, packageName: string): ResolvedPackage | null => {\n for (const nodeModules of nodeModulesChain(projectRoot)) {\n const found = loadPackage(join(nodeModules, packageName, \"package.json\"), nodeModules);\n\n if (found !== null) {\n return found;\n }\n }\n\n const unscoped = packageName.replace(/^@[^/]+\\//, \"\");\n\n return loadPackage(join(projectRoot, \"packages\", unscoped, \"package.json\"), join(projectRoot, \"node_modules\"));\n};\n\nconst isWithin = (parent: string, child: string): boolean => {\n const path = relative(parent, child);\n\n return path === \"\" || (path !== \"..\" && !path.startsWith(`..${sep}`));\n};\n\nconst canImport = (fromNodeModules: string, targetNodeModules: string): boolean =>\n isWithin(dirname(targetNodeModules), dirname(fromNodeModules));\n\nconst storeOptions = (nodeModules: string, name: string, version: string): StoreOptions => ({\n storeDir: join(nodeModules, STORE_DIR, name),\n linkDir: join(nodeModules, SCOPE, name),\n version,\n});\n\nconst resolveRuntime = (projectRoot: string): ResolvedPackage => {\n const runtime = resolvePackage(projectRoot, \"@gtkx/runtime\");\n\n if (runtime === null) {\n throw new Error(`Cannot resolve @gtkx/runtime from ${projectRoot}; is it installed?`);\n }\n\n return runtime;\n};\n\nconst storeNodeModules = (runtime: ResolvedPackage, react: ResolvedPackage | null): string => {\n if (react !== null && canImport(react.nodeModules, runtime.nodeModules)) {\n return react.nodeModules;\n }\n\n return runtime.nodeModules;\n};\n\nconst findUnreachableConsumer = (projectRoot: string, nodeModules: string): StoreConsumer | null => {\n for (const name of STORE_CONSUMERS) {\n const consumer = resolvePackage(projectRoot, name);\n\n if (consumer !== null && !canImport(consumer.nodeModules, nodeModules)) {\n return { name, nodeModules: consumer.nodeModules };\n }\n }\n\n return null;\n};\n\nconst unreachableConsumerMessage = (consumer: StoreConsumer, nodeModules: string): string =>\n `Cannot write the generated store to ${nodeModules}: ${consumer.name} is installed in ` +\n `${consumer.nodeModules}, above it, so that copy can never import the generated @gtkx/gi. Install every ` +\n \"@gtkx package in one node_modules, then run gtkx codegen again.\";\n\nconst checkConsumers = (projectRoot: string, nodeModules: string): void => {\n const consumer = findUnreachableConsumer(projectRoot, nodeModules);\n\n if (consumer !== null) {\n throw new Error(unreachableConsumerMessage(consumer, nodeModules));\n }\n};\n\nconst jsxOptions = (react: ResolvedPackage | null, nodeModules: string): StoreOptions | null =>\n react === null ? null : storeOptions(nodeModules, \"jsx\", react.version);\n\nconst getReactSubexports = (react: ResolvedPackage | null): string[] =>\n react === null ? [] : subexportNames(react.dir);\n\nconst storePaths = (nodeModules: string): string[] =>\n STORE_NAMES.flatMap((name) => [join(nodeModules, STORE_DIR, name), join(nodeModules, SCOPE, name)]);\n\nconst findStoreNodeModules = (projectRoot: string): string | null => {\n const runtime = resolvePackage(projectRoot, \"@gtkx/runtime\");\n\n if (runtime === null) {\n return null;\n }\n\n return storeNodeModules(runtime, resolvePackage(projectRoot, \"@gtkx/react\"));\n};\n\nconst getShadowingStorePaths = (projectRoot: string): string[] => {\n const nodeModules = join(projectRoot, \"node_modules\");\n const anchored = findStoreNodeModules(projectRoot);\n\n if (anchored === null || anchored === nodeModules) {\n return [];\n }\n\n return storePaths(nodeModules);\n};\n\nconst stagingRoots = (projectRoot: string): string[] => {\n const nodeModules = join(projectRoot, \"node_modules\");\n const anchored = findStoreNodeModules(projectRoot);\n\n return anchored === null || anchored === nodeModules ? [nodeModules] : [nodeModules, anchored];\n};\n\nconst sweepProjectStaging = (projectRoot: string): void => {\n for (const nodeModules of stagingRoots(projectRoot)) {\n for (const name of STORE_NAMES) {\n sweepStagingDirs(join(nodeModules, STORE_DIR, name));\n }\n }\n};\n\n/**\n * Resolves where a project's `@gtkx/gi` and `@gtkx/jsx` stores belong, from the project root alone. The\n * result supplies every `runCodegen` input except `libraries` and `girPath`, so a caller that has\n * already resolved those can spread it straight into the call.\n *\n * Both stores go in one `node_modules`, found by walking the project's `node_modules` chain upwards:\n * the one `@gtkx/react` resolves from, or `@gtkx/runtime`'s when no React is installed. That is the\n * project's own directory when it installs those packages itself, and the workspace root when npm or\n * yarn hoisted them there. Keeping the pair together is what lets the jsx store import the gi store, and\n * anchoring them where the `@gtkx` packages sit is what lets `@gtkx/react`, the CLI, and the project's\n * sources all reach the bindings. A package manager that hoists therefore gives every project sharing\n * that `node_modules` one shared store.\n *\n * Store versions come from the installed `@gtkx/runtime` and `@gtkx/react`, so a dependency upgrade\n * invalidates the stores. Pass explicit `gi` or `jsx` options to `runCodegen` to override any of it.\n *\n * @param projectRoot Directory holding the project's `package.json`, whose `node_modules` chain is walked.\n * @returns The store locations and the React subexports that shape the jsx store.\n * @throws If `@gtkx/runtime` cannot be resolved from the project, or a `@gtkx` package that imports the\n * bindings is installed above the `node_modules` the stores would go in, since it could not reach them.\n */\nconst resolveStore = (projectRoot: string): ResolvedStore => {\n const runtime = resolveRuntime(projectRoot);\n const react = resolvePackage(projectRoot, \"@gtkx/react\");\n const nodeModules = storeNodeModules(runtime, react);\n checkConsumers(projectRoot, nodeModules);\n\n return {\n gi: storeOptions(nodeModules, \"gi\", runtime.version),\n jsx: jsxOptions(react, nodeModules),\n reactSubexports: getReactSubexports(react),\n };\n};\n\nexport { getShadowingStorePaths, resolveStore, sweepProjectStaging, type ResolvedStore };\n"]}
1
+ {"version":3,"file":"resolve-store.js","sourceRoot":"","sources":["../../src/store/resolve-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhE,OAAO,EAAE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;;;;;;;;;;;;;GAoBG;AACH,MAAM,YAAY,GAAG,CAAC,WAAmB,EAAiB,EAAE;IACxD,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,cAAc,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IACzD,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACrD,cAAc,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAEzC,OAAO;QACH,EAAE,EAAE,YAAY,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC;QACpD,GAAG,EAAE,UAAU,CAAC,KAAK,EAAE,WAAW,CAAC;QACnC,eAAe,EAAE,kBAAkB,CAAC,KAAK,CAAC;KAC7C,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,YAAY,EAAE,mBAAmB,EAAsB,CAAC","sourcesContent":["import { existsSync, readFileSync, realpathSync } from \"node:fs\";\nimport { dirname, join, parse, relative, sep } from \"node:path\";\nimport type { StoreOptions } from \"./store-fs.js\";\nimport { sweepStagingDirs } from \"../staging.js\";\n\n/**\n * Where a project's generated stores live, ready to spread into `runCodegen`. `jsx` is null when the\n * project has no `@gtkx/react` installed, in which case only the `@gtkx/gi` store can be generated.\n */\ntype ResolvedStore = {\n /** Where the `@gtkx/gi` store goes, versioned by the installed `@gtkx/runtime`. */\n gi: StoreOptions;\n /** Where the `@gtkx/jsx` store goes, versioned by the installed `@gtkx/react`; null when it is absent. */\n jsx: StoreOptions | null;\n /** Subexport names of the installed `@gtkx/react`, empty when it is absent. */\n reactSubexports: string[];\n};\n\ntype ResolvedPackage = { dir: string; nodeModules: string; version: string };\ntype StoreConsumer = { name: string; nodeModules: string };\n\nconst STORE_DIR = \".gtkx\";\nconst SCOPE = \"@gtkx\";\nconst STORE_NAMES: string[] = [\"gi\", \"jsx\"];\n\nconst STORE_CONSUMERS: string[] = [\n \"@gtkx/animated\",\n \"@gtkx/cli\",\n \"@gtkx/components\",\n \"@gtkx/css\",\n \"@gtkx/navigation\",\n \"@gtkx/react\",\n \"@gtkx/runtime\",\n \"@gtkx/testing\",\n];\n\nconst readManifest = (path: string): { version?: string; exports?: Record<string, unknown> } =>\n JSON.parse(readFileSync(path, \"utf8\")) as { version?: string; exports?: Record<string, unknown> };\n\nconst subexportNames = (packageDir: string): string[] =>\n Object.keys(readManifest(join(packageDir, \"package.json\")).exports ?? {})\n .filter((key) => key.startsWith(\"./\") && key !== \"./package.json\")\n .map((key) => key.slice(2));\n\nconst loadPackage = (manifest: string, nodeModules: string): ResolvedPackage | null => {\n if (!existsSync(manifest)) {\n return null;\n }\n\n const real = realpathSync(manifest);\n\n return { dir: dirname(real), nodeModules, version: readManifest(real).version ?? \"0.0.0\" };\n};\n\nconst nodeModulesChain = function* (projectRoot: string): Generator<string> {\n const { root } = parse(projectRoot);\n let current = projectRoot;\n\n while (current !== root) {\n yield join(current, \"node_modules\");\n current = dirname(current);\n }\n\n yield join(root, \"node_modules\");\n};\n\nconst resolvePackage = (projectRoot: string, packageName: string): ResolvedPackage | null => {\n for (const nodeModules of nodeModulesChain(projectRoot)) {\n const found = loadPackage(join(nodeModules, packageName, \"package.json\"), nodeModules);\n\n if (found !== null) {\n return found;\n }\n }\n\n const unscoped = packageName.replace(/^@[^/]+\\//, \"\");\n\n return loadPackage(join(projectRoot, \"packages\", unscoped, \"package.json\"), join(projectRoot, \"node_modules\"));\n};\n\nconst isWithin = (parent: string, child: string): boolean => {\n const path = relative(parent, child);\n\n return path === \"\" || (path !== \"..\" && !path.startsWith(`..${sep}`));\n};\n\nconst canImport = (fromNodeModules: string, targetNodeModules: string): boolean =>\n isWithin(dirname(targetNodeModules), dirname(fromNodeModules));\n\nconst storeOptions = (nodeModules: string, name: string, version: string): StoreOptions => ({\n storeDir: join(nodeModules, STORE_DIR, name),\n linkDir: join(nodeModules, SCOPE, name),\n version,\n});\n\nconst resolveRuntime = (projectRoot: string): ResolvedPackage => {\n const runtime = resolvePackage(projectRoot, \"@gtkx/runtime\");\n\n if (runtime === null) {\n throw new Error(`Cannot resolve @gtkx/runtime from ${projectRoot}; is it installed?`);\n }\n\n return runtime;\n};\n\nconst storeNodeModules = (runtime: ResolvedPackage, react: ResolvedPackage | null): string => {\n if (react !== null && canImport(react.nodeModules, runtime.nodeModules)) {\n return react.nodeModules;\n }\n\n return runtime.nodeModules;\n};\n\nconst findUnreachableConsumer = (projectRoot: string, nodeModules: string): StoreConsumer | null => {\n for (const name of STORE_CONSUMERS) {\n const consumer = resolvePackage(projectRoot, name);\n\n if (consumer !== null && !canImport(consumer.nodeModules, nodeModules)) {\n return { name, nodeModules: consumer.nodeModules };\n }\n }\n\n return null;\n};\n\nconst unreachableConsumerMessage = (consumer: StoreConsumer, nodeModules: string): string =>\n `Cannot write the generated store to ${nodeModules}: ${consumer.name} is installed in ` +\n `${consumer.nodeModules}, above it, so that copy can never import the generated @gtkx/gi. Install every ` +\n \"@gtkx package in one node_modules, then run gtkx codegen again.\";\n\nconst checkConsumers = (projectRoot: string, nodeModules: string): void => {\n const consumer = findUnreachableConsumer(projectRoot, nodeModules);\n\n if (consumer !== null) {\n throw new Error(unreachableConsumerMessage(consumer, nodeModules));\n }\n};\n\nconst jsxOptions = (react: ResolvedPackage | null, nodeModules: string): StoreOptions | null =>\n react === null ? null : storeOptions(nodeModules, \"jsx\", react.version);\n\nconst getReactSubexports = (react: ResolvedPackage | null): string[] =>\n react === null ? [] : subexportNames(react.dir);\n\nconst storePaths = (nodeModules: string): string[] =>\n STORE_NAMES.flatMap((name) => [join(nodeModules, STORE_DIR, name), join(nodeModules, SCOPE, name)]);\n\nconst findStoreNodeModules = (projectRoot: string): string | null => {\n const runtime = resolvePackage(projectRoot, \"@gtkx/runtime\");\n\n if (runtime === null) {\n return null;\n }\n\n return storeNodeModules(runtime, resolvePackage(projectRoot, \"@gtkx/react\"));\n};\n\nconst getShadowingStorePaths = (projectRoot: string): string[] => {\n const nodeModules = join(projectRoot, \"node_modules\");\n const anchored = findStoreNodeModules(projectRoot);\n\n if (anchored === null || anchored === nodeModules) {\n return [];\n }\n\n return storePaths(nodeModules);\n};\n\nconst stagingRoots = (projectRoot: string): string[] => {\n const nodeModules = join(projectRoot, \"node_modules\");\n const anchored = findStoreNodeModules(projectRoot);\n\n return anchored === null || anchored === nodeModules ? [nodeModules] : [nodeModules, anchored];\n};\n\nconst sweepProjectStaging = (projectRoot: string): void => {\n for (const nodeModules of stagingRoots(projectRoot)) {\n for (const name of STORE_NAMES) {\n sweepStagingDirs(join(nodeModules, STORE_DIR, name));\n }\n }\n};\n\n/**\n * Resolves where a project's `@gtkx/gi` and `@gtkx/jsx` stores belong, from the project root alone. The\n * result supplies every `runCodegen` input except `libraries` and `girPath`, so a caller that has\n * already resolved those can spread it straight into the call.\n *\n * Both stores go in one `node_modules`, found by walking the project's `node_modules` chain upwards:\n * the one `@gtkx/react` resolves from, or `@gtkx/runtime`'s when no React is installed. That is the\n * project's own directory when it installs those packages itself, and the workspace root when npm or\n * yarn hoisted them there. Keeping the pair together is what lets the jsx store import the gi store, and\n * anchoring them where the `@gtkx` packages sit is what lets `@gtkx/react`, the CLI, and the project's\n * sources all reach the bindings. A package manager that hoists therefore gives every project sharing\n * that `node_modules` one shared store.\n *\n * Store versions come from the installed `@gtkx/runtime` and `@gtkx/react`, so a dependency upgrade\n * invalidates the stores. Pass explicit `gi` or `jsx` options to `runCodegen` to override any of it.\n *\n * @param projectRoot Directory holding the project's `package.json`, whose `node_modules` chain is walked.\n * @returns The store locations and the React subexports that shape the jsx store.\n * @throws If `@gtkx/runtime` cannot be resolved from the project, or a `@gtkx` package that imports the\n * bindings is installed above the `node_modules` the stores would go in, since it could not reach them.\n */\nconst resolveStore = (projectRoot: string): ResolvedStore => {\n const runtime = resolveRuntime(projectRoot);\n const react = resolvePackage(projectRoot, \"@gtkx/react\");\n const nodeModules = storeNodeModules(runtime, react);\n checkConsumers(projectRoot, nodeModules);\n\n return {\n gi: storeOptions(nodeModules, \"gi\", runtime.version),\n jsx: jsxOptions(react, nodeModules),\n reactSubexports: getReactSubexports(react),\n };\n};\n\nexport { getShadowingStorePaths, nodeModulesChain, resolveStore, sweepProjectStaging, type ResolvedStore };\n"]}
@@ -44,6 +44,7 @@ declare const namespaceBarrel: (directory: string) => {
44
44
  };
45
45
  declare const buildManifest: (input: ManifestInput) => Manifest;
46
46
  declare const writeStore: (params: WriteStoreParams) => void;
47
+ declare const symlinkRelative: (linkPath: string, realTarget: string) => void;
47
48
  declare const ensureStoreLink: (link: StoreLink) => void;
48
- export { subpathExport, buildManifest, ensureStoreLink, namespaceBarrel, writeStore, type StoreOptions, type RawFile, };
49
+ export { subpathExport, buildManifest, ensureStoreLink, namespaceBarrel, symlinkRelative, writeStore, type StoreLink, type StoreOptions, type RawFile, };
49
50
  //# sourceMappingURL=store-fs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"store-fs.d.ts","sourceRoot":"","sources":["../../src/store/store-fs.ts"],"names":[],"mappings":"AAYA,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAIrE,kEAAkE;AAClE,KAAK,YAAY,GAAG;IAChB,sFAAsF;IACtF,QAAQ,EAAE,MAAM,CAAC;IACjB,uGAAuG;IACvG,OAAO,EAAE,MAAM,CAAC;IAChB,2GAA2G;IAC3G,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,SAAS,CAAC,CAAC;AAE5D,KAAK,QAAQ,GAAG;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAA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AAC;AAEH,QAAA,MAAM,eAAe,GAAI,WAAW,MAAM,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAG7E,CAAC;AAEH,QAAA,MAAM,aAAa,GAAI,OAAO,aAAa,KAAG,QAc7C,CAAC;AAEF,QAAA,MAAM,UAAU,GAAI,QAAQ,gBAAgB,KAAG,IAc9C,CAAC;AAuBF,QAAA,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,YAAY,MAAM,KAAG,IAI/D,CAAC;AA0BF,QAAA,MAAM,eAAe,GAAI,MAAM,SAAS,KAAG,IAU1C,CAAC;AAkBF,OAAO,EACH,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,EACf,eAAe,EACf,UAAU,EACV,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,OAAO,GACf,CAAC"}
@@ -4,6 +4,7 @@ import { dirname, join, relative } from "node:path";
4
4
  import { keepFailedProject } from "../compile.js";
5
5
  import { createStagingDir } from "../staging.js";
6
6
  import { compileStore } from "./compile-store.js";
7
+ import { ensureExternalPackageLinks, resetExternalPackageLinks } from "./external-package-links.js";
7
8
  const STORE_DIR_MODE = 0o755;
8
9
  const FAILED_STORE_SUFFIX = ".failed";
9
10
  const subpathExport = (stem) => ({
@@ -33,6 +34,7 @@ const writeStore = (params) => {
33
34
  try {
34
35
  buildTempStore(tmp, params);
35
36
  swapStore(tmp, params.storeDir);
37
+ resetExternalPackageLinks(params.storeDir);
36
38
  ensureStoreLink(params);
37
39
  }
38
40
  catch (error) {
@@ -82,10 +84,13 @@ const isStoreLinked = (link) => {
82
84
  }
83
85
  };
84
86
  const ensureStoreLink = (link) => {
85
- if (!existsSync(join(link.storeDir, "package.json")) || isStoreLinked(link)) {
87
+ if (!existsSync(join(link.storeDir, "package.json"))) {
86
88
  return;
87
89
  }
88
- symlinkRelative(link.linkDir, link.storeDir);
90
+ if (!isStoreLinked(link)) {
91
+ symlinkRelative(link.linkDir, link.storeDir);
92
+ }
93
+ ensureExternalPackageLinks(link);
89
94
  };
90
95
  const storeWriteMessage = (storeDir, error) => `Cannot write the generated store to ${storeDir}: ${errorMessage(error)}. ` +
91
96
  "Codegen writes the store into the node_modules the @gtkx packages resolve from, " +
@@ -100,5 +105,5 @@ const createTempStore = (storeDir) => {
100
105
  throw new Error(storeWriteMessage(storeDir, error), { cause: error });
101
106
  }
102
107
  };
103
- export { subpathExport, buildManifest, ensureStoreLink, namespaceBarrel, writeStore, };
108
+ export { subpathExport, buildManifest, ensureStoreLink, namespaceBarrel, symlinkRelative, writeStore, };
104
109
  //# sourceMappingURL=store-fs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"store-fs.js","sourceRoot":"","sources":["../../src/store/store-fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACH,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,MAAM,EACN,WAAW,EACX,aAAa,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAqB,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAwClD,MAAM,cAAc,GAAG,KAAK,CAAC;AAC7B,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAEtC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAsC,EAAE,CAAC,CAAC;IACzE,KAAK,EAAE,KAAK,IAAI,OAAO;IACvB,OAAO,EAAE,KAAK,IAAI,KAAK;CAC1B,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,CAAC,SAAiB,EAAwC,EAAE,CAAC,CAAC;IAClF,QAAQ,EAAE,GAAG,SAAS,WAAW;IACjC,MAAM,EAAE,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AAQ,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAE,KAAc,EAAU,EAAE,CACnE,uCAAuC,QAAQ,KAAK,YAAY,CAAC,KAAK,CAAC,IAAI;IAC3E,kFAAkF;IAClF,MAAM,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAC;AAElD,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAU,EAAE;IACjD,IAAI,CAAC;QACD,MAAM,GAAG,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACvC,SAAS,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1E,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EACH,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,EACf,UAAU,GAGb,CAAC","sourcesContent":["import { errorMessage } from \"@gtkx/utils\";\nimport {\n chmodSync,\n existsSync,\n mkdirSync,\n realpathSync,\n renameSync,\n rmSync,\n symlinkSync,\n writeFileSync,\n} from \"node:fs\";\nimport { dirname, join, relative } from \"node:path\";\nimport { keepFailedProject, type SourceModule } from \"../compile.js\";\nimport { createStagingDir } from \"../staging.js\";\nimport { compileStore } from \"./compile-store.js\";\n\n/** Where one generated store is written and how it is reached. */\ntype StoreOptions = {\n /** Directory the generated package is written to, replaced atomically on each run. */\n storeDir: string;\n /** Path the store is symlinked at, which is the specifier's resolution target under `node_modules`. */\n linkDir: string;\n /** Version stamped on the store's `package.json`, taken from the dependency the store is generated for. */\n version: string;\n};\n\ntype StoreLink = Pick<StoreOptions, \"storeDir\" | \"linkDir\">;\n\ntype Manifest = {\n name: string;\n type: \"module\";\n version: string;\n sideEffects: true;\n exports: Record<string, unknown>;\n peerDependencies?: Record<string, string>;\n};\n\ntype ManifestInput = {\n name: string;\n version: string;\n exports: Record<string, unknown>;\n peerDependencies?: Record<string, string>;\n};\n\ntype RawFile = { relativePath: string; content: string };\n\ntype WriteStoreParams = {\n storeDir: string;\n linkDir: string;\n files: SourceModule[];\n manifest: Manifest;\n rawFiles?: RawFile[];\n};\n\nconst STORE_DIR_MODE = 0o755;\nconst FAILED_STORE_SUFFIX = \".failed\";\n\nconst subpathExport = (stem: string): { types: string; default: string } => ({\n types: `./${stem}.d.ts`,\n default: `./${stem}.js`,\n});\n\nconst namespaceBarrel = (directory: string): { fileName: string; source: string } => ({\n fileName: `${directory}/index.ts`,\n source: `export * from \"./${directory}.js\";\\n`,\n});\n\nconst buildManifest = (input: ManifestInput): Manifest => {\n const manifest: Manifest = {\n name: input.name,\n type: \"module\",\n version: input.version,\n sideEffects: true,\n exports: { \"./package.json\": \"./package.json\", ...input.exports },\n };\n\n if (input.peerDependencies) {\n manifest.peerDependencies = input.peerDependencies;\n }\n\n return manifest;\n};\n\nconst writeStore = (params: WriteStoreParams): void => {\n const tmp = createTempStore(params.storeDir);\n const keepAt = `${params.storeDir}${FAILED_STORE_SUFFIX}`;\n\n try {\n buildTempStore(tmp, params);\n swapStore(tmp, params.storeDir);\n ensureStoreLink(params);\n } catch (error) {\n throw keepFailedProject({ projectDir: tmp, keepAt, error });\n }\n\n rmSync(keepAt, { recursive: true, force: true });\n};\n\nconst buildTempStore = (tmp: string, params: WriteStoreParams): void => {\n writePackageJson(tmp, params.manifest);\n\n for (const file of params.files) {\n writeSourceFile(tmp, file.fileName, file.source);\n }\n\n compileStore({ storeDir: tmp, files: params.files, packageName: params.manifest.name });\n const rawFiles = params.rawFiles ?? [];\n\n for (const raw of rawFiles) {\n writeFileSync(join(tmp, raw.relativePath), raw.content);\n }\n};\n\nconst writeSourceFile = (storeDir: string, fileName: string, source: string): void => {\n const filePath = join(storeDir, fileName);\n mkdirSync(dirname(filePath), { recursive: true });\n writeFileSync(filePath, source);\n};\n\nconst symlinkRelative = (linkPath: string, realTarget: string): void => {\n mkdirSync(dirname(linkPath), { recursive: true });\n rmSync(linkPath, { recursive: true, force: true });\n symlinkSync(relative(dirname(linkPath), realTarget), linkPath, \"dir\");\n};\n\nconst writePackageJson = (storeDir: string, manifest: Manifest): void => {\n writeFileSync(join(storeDir, \"package.json\"), `${JSON.stringify(manifest, null, 2)}\\n`);\n};\n\nconst swapStore = (tmp: string, storeDir: string): void => {\n const previous = `${storeDir}.old`;\n rmSync(previous, { recursive: true, force: true });\n\n if (existsSync(storeDir)) {\n renameSync(storeDir, previous);\n }\n\n renameSync(tmp, storeDir);\n rmSync(previous, { recursive: true, force: true });\n};\n\nconst isStoreLinked = (link: StoreLink): boolean => {\n try {\n return realpathSync(link.linkDir) === realpathSync(link.storeDir);\n } catch {\n return false;\n }\n};\n\nconst ensureStoreLink = (link: StoreLink): void => {\n if (!existsSync(join(link.storeDir, \"package.json\")) || isStoreLinked(link)) {\n return;\n }\n\n symlinkRelative(link.linkDir, link.storeDir);\n};\n\nconst storeWriteMessage = (storeDir: string, error: unknown): string =>\n `Cannot write the generated store to ${storeDir}: ${errorMessage(error)}. ` +\n \"Codegen writes the store into the node_modules the @gtkx packages resolve from, \" +\n `so ${dirname(storeDir)} has to be writable.`;\n\nconst createTempStore = (storeDir: string): string => {\n try {\n const tmp = createStagingDir(storeDir);\n chmodSync(tmp, STORE_DIR_MODE);\n\n return tmp;\n } catch (error) {\n throw new Error(storeWriteMessage(storeDir, error), { cause: error });\n }\n};\n\nexport {\n subpathExport,\n buildManifest,\n ensureStoreLink,\n namespaceBarrel,\n writeStore,\n type StoreOptions,\n type RawFile,\n};\n"]}
1
+ {"version":3,"file":"store-fs.js","sourceRoot":"","sources":["../../src/store/store-fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACH,SAAS,EACT,UAAU,EACV,SAAS,EACT,YA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CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1E,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EACH,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,EACf,eAAe,EACf,UAAU,GAIb,CAAC","sourcesContent":["import { errorMessage } from \"@gtkx/utils\";\nimport {\n chmodSync,\n existsSync,\n mkdirSync,\n realpathSync,\n renameSync,\n rmSync,\n symlinkSync,\n writeFileSync,\n} from \"node:fs\";\nimport { dirname, join, relative } from \"node:path\";\nimport { keepFailedProject, type SourceModule } from \"../compile.js\";\nimport { createStagingDir } from \"../staging.js\";\nimport { compileStore } from \"./compile-store.js\";\nimport { ensureExternalPackageLinks, resetExternalPackageLinks } from \"./external-package-links.js\";\n\n/** Where one generated store is written and how it is reached. */\ntype StoreOptions = {\n /** Directory the generated package is written to, replaced atomically on each run. */\n storeDir: string;\n /** Path the store is symlinked at, which is the specifier's resolution target under `node_modules`. */\n linkDir: string;\n /** Version stamped on the store's `package.json`, taken from the dependency the store is generated for. */\n version: string;\n};\n\ntype StoreLink = Pick<StoreOptions, \"storeDir\" | \"linkDir\">;\n\ntype Manifest = {\n name: string;\n type: \"module\";\n version: string;\n sideEffects: true;\n exports: Record<string, unknown>;\n peerDependencies?: Record<string, string>;\n};\n\ntype ManifestInput = {\n name: string;\n version: string;\n exports: Record<string, unknown>;\n peerDependencies?: Record<string, string>;\n};\n\ntype RawFile = { relativePath: string; content: string };\n\ntype WriteStoreParams = {\n storeDir: string;\n linkDir: string;\n files: SourceModule[];\n manifest: Manifest;\n rawFiles?: RawFile[];\n};\n\nconst STORE_DIR_MODE = 0o755;\nconst FAILED_STORE_SUFFIX = \".failed\";\n\nconst subpathExport = (stem: string): { types: string; default: string } => ({\n types: `./${stem}.d.ts`,\n default: `./${stem}.js`,\n});\n\nconst namespaceBarrel = (directory: string): { fileName: string; source: string } => ({\n fileName: `${directory}/index.ts`,\n source: `export * from \"./${directory}.js\";\\n`,\n});\n\nconst buildManifest = (input: ManifestInput): Manifest => {\n const manifest: Manifest = {\n name: input.name,\n type: \"module\",\n version: input.version,\n sideEffects: true,\n exports: { \"./package.json\": \"./package.json\", ...input.exports },\n };\n\n if (input.peerDependencies) {\n manifest.peerDependencies = input.peerDependencies;\n }\n\n return manifest;\n};\n\nconst writeStore = (params: WriteStoreParams): void => {\n const tmp = createTempStore(params.storeDir);\n const keepAt = `${params.storeDir}${FAILED_STORE_SUFFIX}`;\n\n try {\n buildTempStore(tmp, params);\n swapStore(tmp, params.storeDir);\n resetExternalPackageLinks(params.storeDir);\n ensureStoreLink(params);\n } catch (error) {\n throw keepFailedProject({ projectDir: tmp, keepAt, error });\n }\n\n rmSync(keepAt, { recursive: true, force: true });\n};\n\nconst buildTempStore = (tmp: string, params: WriteStoreParams): void => {\n writePackageJson(tmp, params.manifest);\n\n for (const file of params.files) {\n writeSourceFile(tmp, file.fileName, file.source);\n }\n\n compileStore({ storeDir: tmp, files: params.files, packageName: params.manifest.name });\n const rawFiles = params.rawFiles ?? [];\n\n for (const raw of rawFiles) {\n writeFileSync(join(tmp, raw.relativePath), raw.content);\n }\n};\n\nconst writeSourceFile = (storeDir: string, fileName: string, source: string): void => {\n const filePath = join(storeDir, fileName);\n mkdirSync(dirname(filePath), { recursive: true });\n writeFileSync(filePath, source);\n};\n\nconst symlinkRelative = (linkPath: string, realTarget: string): void => {\n mkdirSync(dirname(linkPath), { recursive: true });\n rmSync(linkPath, { recursive: true, force: true });\n symlinkSync(relative(dirname(linkPath), realTarget), linkPath, \"dir\");\n};\n\nconst writePackageJson = (storeDir: string, manifest: Manifest): void => {\n writeFileSync(join(storeDir, \"package.json\"), `${JSON.stringify(manifest, null, 2)}\\n`);\n};\n\nconst swapStore = (tmp: string, storeDir: string): void => {\n const previous = `${storeDir}.old`;\n rmSync(previous, { recursive: true, force: true });\n\n if (existsSync(storeDir)) {\n renameSync(storeDir, previous);\n }\n\n renameSync(tmp, storeDir);\n rmSync(previous, { recursive: true, force: true });\n};\n\nconst isStoreLinked = (link: StoreLink): boolean => {\n try {\n return realpathSync(link.linkDir) === realpathSync(link.storeDir);\n } catch {\n return false;\n }\n};\n\nconst ensureStoreLink = (link: StoreLink): void => {\n if (!existsSync(join(link.storeDir, \"package.json\"))) {\n return;\n }\n\n if (!isStoreLinked(link)) {\n symlinkRelative(link.linkDir, link.storeDir);\n }\n\n ensureExternalPackageLinks(link);\n};\n\nconst storeWriteMessage = (storeDir: string, error: unknown): string =>\n `Cannot write the generated store to ${storeDir}: ${errorMessage(error)}. ` +\n \"Codegen writes the store into the node_modules the @gtkx packages resolve from, \" +\n `so ${dirname(storeDir)} has to be writable.`;\n\nconst createTempStore = (storeDir: string): string => {\n try {\n const tmp = createStagingDir(storeDir);\n chmodSync(tmp, STORE_DIR_MODE);\n\n return tmp;\n } catch (error) {\n throw new Error(storeWriteMessage(storeDir, error), { cause: error });\n }\n};\n\nexport {\n subpathExport,\n buildManifest,\n ensureStoreLink,\n namespaceBarrel,\n symlinkRelative,\n writeStore,\n type StoreLink,\n type StoreOptions,\n type RawFile,\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/writer/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE9D,cAAM,aAAa;IACR,MAAM,EAAE,aAAa,CAAuB;IAC5C,SAAS,EAAE,YAAY,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;gBAEZ,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,OA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1
+ import { externalPackageFor } from "../gir/external-namespaces.js";
1
2
  import { ModuleBuilder } from "./module.js";
2
3
  class ModuleContext {
3
4
  module = new ModuleBuilder();
@@ -24,12 +25,19 @@ class ModuleContext {
24
25
  return;
25
26
  }
26
27
  this.module.imports.addSideEffect("../gobject/overrides/object.js");
28
+ this.module.imports.addSideEffect("../gobject/overrides/param-spec-getters.js");
27
29
  this.module.imports.addSideEffect("../gobject/overrides/value.js");
28
30
  }
29
31
  addCrossNamespaceImport(namespaceName) {
30
32
  if (namespaceName === this.namespace.name) {
31
33
  return namespaceName;
32
34
  }
35
+ const packageName = externalPackageFor(namespaceName);
36
+ if (packageName !== undefined) {
37
+ this.module.imports.addSideEffect(packageName);
38
+ this.module.imports.addNamespace(packageName, namespaceName);
39
+ return namespaceName;
40
+ }
33
41
  const directory = namespaceName.toLowerCase();
34
42
  const isFoundational = directory === "gobject" || directory === "glib";
35
43
  const path = isFoundational ? `../${directory}/${directory}.js` : `../${directory}/index.js`;
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/writer/context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,aAAa,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,aAAa;IACR,MAAM,GAAkB,IAAI,aAAa,EAAE,CAAC;IAC5C,SAAS,CAAe;IACxB,OAAO,CAAU;IAExB,YAAY,SAAuB,EAAE,OAAgB;QACjD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED,gBAAgB,CAAC,IAAY;QACzB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,oBAAoB,CAAC,IAAY;QAC7B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9D,CAAC;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,IAAI;YACJ,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,KAAK,EAAE;SAC7E,CAAC,CAAC;IACP,CAAC;IAED,OAAO,CAAC,aAAqB,EAAE,IAAY;QACvC,IAAI,aAAa,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,GAAG,IAAI,CAAC,uBAAuB,CAAC,aAAa,CAAC,IAAI,IAAI,EAAE,CAAC;IACpE,CAAC;CACJ;AAED,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import type { Library } from \"../gir/library.js\";\nimport type { GirNamespace } from \"../gir/namespace.js\";\nimport { type Declaration, ModuleBuilder } from \"./module.js\";\n\nclass ModuleContext {\n public module: ModuleBuilder = new ModuleBuilder();\n public namespace: GirNamespace;\n public library: Library;\n\n constructor(namespace: GirNamespace, library: Library) {\n this.namespace = namespace;\n this.library = library;\n }\n\n addRuntimeImport(name: string): void {\n this.module.imports.addNamed(\"@gtkx/runtime\", name);\n }\n\n addRuntimeTypeImport(name: string): void {\n this.module.imports.addNamed(\"@gtkx/runtime\", name, true);\n }\n\n hoistDescriptor(expression: string): string {\n return this.module.hoistDescriptor(expression);\n }\n\n addGObjectBootstrapImports(): void {\n if (this.namespace.name === \"GObject\") {\n return;\n }\n\n if (this.namespace.name === \"GLib\") {\n return;\n }\n\n this.module.imports.addSideEffect(\"../gobject/overrides/object.js\");\n this.module.imports.addSideEffect(\"../gobject/overrides/value.js\");\n }\n\n addCrossNamespaceImport(namespaceName: string): string {\n if (namespaceName === this.namespace.name) {\n return namespaceName;\n }\n\n const directory = namespaceName.toLowerCase();\n const isFoundational = directory === \"gobject\" || directory === \"glib\";\n const path = isFoundational ? `../${directory}/${directory}.js` : `../${directory}/index.js`;\n\n if (!isFoundational) {\n this.module.imports.addSideEffect(path);\n }\n\n this.module.imports.addNamespace(path, namespaceName);\n\n return namespaceName;\n }\n\n declare(declaration: Declaration): void {\n const { name, code, owner } = declaration;\n\n this.module.appendDeclaration({\n name,\n code,\n owner: owner === undefined ? undefined : `${this.namespace.name}.${owner}`,\n });\n }\n\n qualify(namespaceName: string, name: string): string {\n if (namespaceName === this.namespace.name) {\n return name;\n }\n\n return `${this.addCrossNamespaceImport(namespaceName)}.${name}`;\n }\n}\n\nexport { ModuleContext };\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/writer/context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAoB,aAAa,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,aAAa;IACR,MAAM,GAAkB,IAAI,aAAa,EAAE,CAAC;IAC5C,SAAS,CAAe;IACxB,OAAO,CAAU;IAExB,YAAY,SAAuB,EAAE,OAAgB;QACjD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED,gBAAgB,CAAC,IAAY;QACzB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,oBAAoB,CAAC,IAAY;QAC7B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9D,CAAC;IAED,eAAe,CAAC,UAAkB;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;IAED,0BAA0B;QACtB,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YACpC,OAAO;QACX,CAAC;QAED,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC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,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC;QAE1C,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;YAC1B,IAAI;YACJ,IAAI;YACJ,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,KAAK,EAAE;SAC7E,CAAC,CAAC;IACP,CAAC;IAED,OAAO,CAAC,aAAqB,EAAE,IAAY;QACvC,IAAI,aAAa,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,GAAG,IAAI,CAAC,uBAAuB,CAAC,aAAa,CAAC,IAAI,IAAI,EAAE,CAAC;IACpE,CAAC;CACJ;AAED,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import type { Library } from \"../gir/library.js\";\nimport type { GirNamespace } from \"../gir/namespace.js\";\nimport { externalPackageFor } from \"../gir/external-namespaces.js\";\nimport { type Declaration, ModuleBuilder } from \"./module.js\";\n\nclass ModuleContext {\n public module: ModuleBuilder = new ModuleBuilder();\n public namespace: GirNamespace;\n public library: Library;\n\n constructor(namespace: GirNamespace, library: Library) {\n this.namespace = namespace;\n this.library = library;\n }\n\n addRuntimeImport(name: string): void {\n this.module.imports.addNamed(\"@gtkx/runtime\", name);\n }\n\n addRuntimeTypeImport(name: string): void {\n this.module.imports.addNamed(\"@gtkx/runtime\", name, true);\n }\n\n hoistDescriptor(expression: string): string {\n return this.module.hoistDescriptor(expression);\n }\n\n addGObjectBootstrapImports(): void {\n if (this.namespace.name === \"GObject\") {\n return;\n }\n\n if (this.namespace.name === \"GLib\") {\n return;\n }\n\n this.module.imports.addSideEffect(\"../gobject/overrides/object.js\");\n this.module.imports.addSideEffect(\"../gobject/overrides/param-spec-getters.js\");\n this.module.imports.addSideEffect(\"../gobject/overrides/value.js\");\n }\n\n addCrossNamespaceImport(namespaceName: string): string {\n if (namespaceName === this.namespace.name) {\n return namespaceName;\n }\n\n const packageName = externalPackageFor(namespaceName);\n\n if (packageName !== undefined) {\n this.module.imports.addSideEffect(packageName);\n this.module.imports.addNamespace(packageName, namespaceName);\n\n return namespaceName;\n }\n\n const directory = namespaceName.toLowerCase();\n const isFoundational = directory === \"gobject\" || directory === \"glib\";\n const path = isFoundational ? `../${directory}/${directory}.js` : `../${directory}/index.js`;\n\n if (!isFoundational) {\n this.module.imports.addSideEffect(path);\n }\n\n this.module.imports.addNamespace(path, namespaceName);\n\n return namespaceName;\n }\n\n declare(declaration: Declaration): void {\n const { name, code, owner } = declaration;\n\n this.module.appendDeclaration({\n name,\n code,\n owner: owner === undefined ? undefined : `${this.namespace.name}.${owner}`,\n });\n }\n\n qualify(namespaceName: string, name: string): string {\n if (namespaceName === this.namespace.name) {\n return name;\n }\n\n return `${this.addCrossNamespaceImport(namespaceName)}.${name}`;\n }\n}\n\nexport { ModuleContext };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"gtk-doc.d.ts","sourceRoot":"","sources":["../../src/writer/gtk-doc.ts"],"names":[],"mappings":"AAsIA,QAAA,MAAM,gBAAgB,GAAI,KAAK,MAAM,EAAE,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,MA+B1E,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"gtk-doc.d.ts","sourceRoot":"","sources":["../../src/writer/gtk-doc.ts"],"names":[],"mappings":"AA2KA,QAAA,MAAM,gBAAgB,GAAI,KAAK,MAAM,EAAE,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,MA+B1E,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -1,5 +1,11 @@
1
- import { camelCase } from "@gtkx/utils";
1
+ import { camelCase, kebabCase } from "@gtkx/utils";
2
+ import { HIDDEN_SYMBOLS } from "../gir/hidden-symbols.js";
2
3
  const CONSTANT_MAP = { TRUE: "true", FALSE: "false", NULL: "null" };
4
+ const HIDDEN_LINK_PREFIXES = new Map([
5
+ ["GLib", "g"],
6
+ ["GObject", "g"],
7
+ ["Gio", "g"],
8
+ ]);
3
9
  const CALLABLE_LINK_KINDS = new Set(["method", "func", "ctor", "vfunc", "id"]);
4
10
  const SENTINEL = String.fromCodePoint(0xE0_00);
5
11
  const CODE_BLOCK_OPEN = "|[";
@@ -25,8 +31,28 @@ const DOCBOOK_LITERAL_PATTERN = /<literal>([\s\S]*?)<\/literal>/g;
25
31
  const DOCBOOK_LIST_PATTERN = /<\/?itemizedlist>\s*/g;
26
32
  const DOCBOOK_PARA_PATTERN = /<\/?para>\s*/g;
27
33
  const BLANK_LINE_RUN_PATTERN = /\n{3,}/g;
34
+ const cSymbolSegment = (segment) => kebabCase(segment).replaceAll("-", "_");
35
+ const hiddenLinkCandidate = (segments) => {
36
+ const [namespace, ...rest] = segments;
37
+ const prefix = namespace === undefined ? undefined : HIDDEN_LINK_PREFIXES.get(namespace);
38
+ if (prefix === undefined || rest.length === 0) {
39
+ return undefined;
40
+ }
41
+ return [prefix, ...rest.map((segment) => cSymbolSegment(segment))].join("_");
42
+ };
43
+ const hiddenCIdentifier = (kind, target, segments) => {
44
+ if (!CALLABLE_LINK_KINDS.has(kind)) {
45
+ return undefined;
46
+ }
47
+ const candidate = kind === "id" ? target : hiddenLinkCandidate(segments);
48
+ return candidate !== undefined && HIDDEN_SYMBOLS.has(candidate) ? candidate : undefined;
49
+ };
28
50
  const renderLink = (kind, target) => {
29
51
  const segments = target.split(/::|[.:]/);
52
+ const hidden = hiddenCIdentifier(kind, target, segments);
53
+ if (hidden !== undefined) {
54
+ return `\`${hidden}()\``;
55
+ }
30
56
  const lastIndex = segments.length - 1;
31
57
  if (kind === "property" || CALLABLE_LINK_KINDS.has(kind)) {
32
58
  segments[lastIndex] = camelCase(segments[lastIndex] ?? "");
@@ -1 +1 @@
1
- {"version":3,"file":"gtk-doc.js","sourceRoot":"","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AI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACxD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACjC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import { camelCase } from \"@gtkx/utils\";\n\nconst CONSTANT_MAP: Record<string, string> = { TRUE: \"true\", FALSE: \"false\", NULL: \"null\" };\nconst CALLABLE_LINK_KINDS: Set<string> = new Set([\"method\", \"func\", \"ctor\", \"vfunc\", \"id\"]);\nconst SENTINEL = String.fromCodePoint(0xE0_00);\nconst CODE_BLOCK_OPEN = \"|[\";\nconst CODE_BLOCK_CLOSE = \"]|\";\nconst CODE_LANGUAGE_PATTERN = /^\\s*<!--\\s*language=\"([^\"]*)\"\\s*-->/;\nconst FENCED_BLOCK_PATTERN = /```[\\s\\S]*?```/g;\nconst INLINE_CODE_PATTERN = /`[^`\\n]*`/g;\nconst LINK_PATTERN = /\\[(\\w+)@([\\w.:%#-]+)\\]/g;\nconst CONSTANT_PATTERN = /(?<![\\w\\\\])%(\\w+)/g;\nconst ESCAPED_CONSTANT_PATTERN = /\\\\%/g;\nconst TYPE_REF_PATTERN = /(?<!\\w)#(\\w+)(::[\\w-]+|:[\\w-]+)?/g;\nconst PARAM_REF_PATTERN = /(?<!\\w)@(\\w+)/g;\nconst FUNCTION_REF_PATTERN = /\\b([a-z_][a-z0-9_]*)\\(\\)/g;\nconst HTML_COMMENT_PATTERN = /<!--[\\s\\S]*?-->/g;\nconst DOCBOOK_TAG_PATTERN = /<\\/?(?:itemizedlist|listitem|para|literal|link|informalexample|programlisting)[\\s>]/;\nconst DOCBOOK_LISTING_OPEN = \"<programlisting>\";\nconst DOCBOOK_LISTING_CLOSE = \"</programlisting>\";\nconst DOCBOOK_EXAMPLE_PATTERN = /<\\/?informalexample>\\s*/g;\nconst DOCBOOK_ITEM_OPEN_PATTERN = /<listitem>\\s*(?:<para>\\s*)?/g;\nconst DOCBOOK_ITEM_CLOSE_PATTERN = /(?:<\\/para>\\s*)?<\\/listitem>\\s*/g;\nconst DOCBOOK_LINK_PATTERN = /<link\\s+linkend=\"[^\"]*\">([\\s\\S]*?)<\\/link>/g;\nconst DOCBOOK_LITERAL_PATTERN = /<literal>([\\s\\S]*?)<\\/literal>/g;\nconst DOCBOOK_LIST_PATTERN = /<\\/?itemizedlist>\\s*/g;\nconst DOCBOOK_PARA_PATTERN = /<\\/?para>\\s*/g;\nconst BLANK_LINE_RUN_PATTERN = /\\n{3,}/g;\n\nconst renderLink = (kind: string, target: string): string => {\n const segments = target.split(/::|[.:]/);\n const lastIndex = segments.length - 1;\n\n if (kind === \"property\" || CALLABLE_LINK_KINDS.has(kind)) {\n segments[lastIndex] = camelCase(segments[lastIndex] ?? \"\");\n }\n\n const symbol = segments.join(\".\");\n\n return `\\`${symbol}${CALLABLE_LINK_KINDS.has(kind) ? \"()\" : \"\"}\\``;\n};\n\nconst renderTypeRef = (name: string, member: string | undefined): string => {\n if (member === undefined) {\n return `\\`${name}\\``;\n }\n\n return renderLink(member.startsWith(\"::\") ? \"signal\" : \"property\", `${name}${member}`);\n};\n\nconst renderParamRef = (name: string, identifiers: Map<string, string> | undefined): string =>\n `\\`${identifiers?.get(name) ?? name}\\``;\n\nconst trimTrailingNewlines = (value: string): string => {\n let end = value.length;\n\n while (end > 0 && value[end - 1] === \"\\n\") {\n end -= 1;\n }\n\n return value.slice(0, end);\n};\n\nconst renderCodeFence = (body: string): string => {\n const languageMatch = CODE_LANGUAGE_PATTERN.exec(body);\n const fence = (languageMatch?.[1] ?? \"\").trim().toLowerCase();\n const rest = languageMatch === null ? body : body.slice(languageMatch[0].length);\n const code = trimTrailingNewlines(rest.trimStart());\n\n return `\\`\\`\\`${fence}\\n${code}\\n\\`\\`\\``;\n};\n\nconst renderListing = (code: string): string => `\\n\\`\\`\\`\\n${code.trim()}\\n\\`\\`\\`\\n`;\n\nconst replaceDocBookTags = (text: string): string =>\n replaceDelimited(text, [DOCBOOK_LISTING_OPEN, DOCBOOK_LISTING_CLOSE], renderListing)\n .replaceAll(DOCBOOK_EXAMPLE_PATTERN, \"\\n\")\n .replaceAll(DOCBOOK_ITEM_OPEN_PATTERN, \"\\n- \")\n .replaceAll(DOCBOOK_ITEM_CLOSE_PATTERN, \"\\n\")\n .replaceAll(DOCBOOK_LINK_PATTERN, (_match, label: string) => label)\n .replaceAll(DOCBOOK_LITERAL_PATTERN, (_match, literal: string) => `\\`${literal}\\``)\n .replaceAll(DOCBOOK_LIST_PATTERN, \"\\n\\n\")\n .replaceAll(DOCBOOK_PARA_PATTERN, \"\\n\\n\");\n\nconst docBookToMarkdown = (text: string): string => {\n if (!DOCBOOK_TAG_PATTERN.test(text)) {\n return text;\n }\n\n return replaceDocBookTags(text).replaceAll(BLANK_LINE_RUN_PATTERN, \"\\n\\n\").trim();\n};\n\nconst replaceDelimited = (raw: string, bounds: [string, string], render: (body: string) => string): string => {\n const [open, close] = bounds;\n let result = \"\";\n let cursor = 0;\n\n while (cursor < raw.length) {\n const start = raw.indexOf(open, cursor);\n\n if (start === -1) {\n break;\n }\n\n const end = raw.indexOf(close, start + open.length);\n\n if (end === -1) {\n break;\n }\n\n result += raw.slice(cursor, start);\n result += render(raw.slice(start + open.length, end));\n cursor = end + close.length;\n }\n\n return result + raw.slice(cursor);\n};\n\nconst protectCodeBlocks = (raw: string, protect: (value: string) => string): string =>\n replaceDelimited(raw, [CODE_BLOCK_OPEN, CODE_BLOCK_CLOSE], (body) => protect(renderCodeFence(body)));\n\nconst stripHtmlComments = (text: string): string => {\n let current = text;\n let previous = \"\";\n\n while (current !== previous) {\n previous = current;\n current = current.replaceAll(HTML_COMMENT_PATTERN, \"\");\n }\n\n return current;\n};\n\n// eslint-disable-next-line gtkx/no-library-prefix\nconst gtkDocToMarkdown = (raw: string, identifiers?: Map<string, string>): string => {\n const stash: string[] = [];\n\n const protect = (value: string): string => {\n const token = `${SENTINEL}${String(stash.length)}${SENTINEL}`;\n stash.push(value);\n\n return token;\n };\n\n let text = protectCodeBlocks(docBookToMarkdown(raw), protect);\n text = text.replaceAll(FENCED_BLOCK_PATTERN, (block) => protect(block));\n text = text.replaceAll(INLINE_CODE_PATTERN, (span) => protect(span));\n text = text.replaceAll(LINK_PATTERN, (_match, kind: string, target: string) => protect(renderLink(kind, target)));\n text = text.replaceAll(CONSTANT_PATTERN, (_match, name: string) => protect(`\\`${CONSTANT_MAP[name] ?? name}\\``));\n text = text.replaceAll(ESCAPED_CONSTANT_PATTERN, \"%\");\n\n text = text.replaceAll(TYPE_REF_PATTERN, (_match, name: string, member: string | undefined) =>\n protect(renderTypeRef(name, member)),\n );\n\n text = text.replaceAll(PARAM_REF_PATTERN, (_match, name: string) => protect(renderParamRef(name, identifiers)));\n text = text.replaceAll(FUNCTION_REF_PATTERN, (_match, name: string) => protect(`\\`${name}()\\``));\n text = stripHtmlComments(text);\n\n for (let index = stash.length - 1; index >= 0; index -= 1) {\n const value = stash[index] ?? \"\";\n text = text.replaceAll(`${SENTINEL}${String(index)}${SENTINEL}`, () => value);\n }\n\n return text;\n};\n\nexport { gtkDocToMarkdown };\n"]}
1
+ {"version":3,"file":"gtk-doc.js","sourceRoot":"","sources":["../../src/writer/gtk-doc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,YAAY,GAA2B,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAE5F,MAAM,oBAAoB,GAAwB,IAAI,GAAG,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,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACxD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACjC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import { camelCase, kebabCase } from \"@gtkx/utils\";\nimport { HIDDEN_SYMBOLS } from \"../gir/hidden-symbols.js\";\n\nconst CONSTANT_MAP: Record<string, string> = { TRUE: \"true\", FALSE: \"false\", NULL: \"null\" };\n\nconst HIDDEN_LINK_PREFIXES: Map<string, string> = new Map([\n [\"GLib\", \"g\"],\n [\"GObject\", \"g\"],\n [\"Gio\", \"g\"],\n]);\n\nconst CALLABLE_LINK_KINDS: Set<string> = new Set([\"method\", \"func\", \"ctor\", \"vfunc\", \"id\"]);\nconst SENTINEL = String.fromCodePoint(0xE0_00);\nconst CODE_BLOCK_OPEN = \"|[\";\nconst CODE_BLOCK_CLOSE = \"]|\";\nconst CODE_LANGUAGE_PATTERN = /^\\s*<!--\\s*language=\"([^\"]*)\"\\s*-->/;\nconst FENCED_BLOCK_PATTERN = /```[\\s\\S]*?```/g;\nconst INLINE_CODE_PATTERN = /`[^`\\n]*`/g;\nconst LINK_PATTERN = /\\[(\\w+)@([\\w.:%#-]+)\\]/g;\nconst CONSTANT_PATTERN = /(?<![\\w\\\\])%(\\w+)/g;\nconst ESCAPED_CONSTANT_PATTERN = /\\\\%/g;\nconst TYPE_REF_PATTERN = /(?<!\\w)#(\\w+)(::[\\w-]+|:[\\w-]+)?/g;\nconst PARAM_REF_PATTERN = /(?<!\\w)@(\\w+)/g;\nconst FUNCTION_REF_PATTERN = /\\b([a-z_][a-z0-9_]*)\\(\\)/g;\nconst HTML_COMMENT_PATTERN = /<!--[\\s\\S]*?-->/g;\nconst DOCBOOK_TAG_PATTERN = /<\\/?(?:itemizedlist|listitem|para|literal|link|informalexample|programlisting)[\\s>]/;\nconst DOCBOOK_LISTING_OPEN = \"<programlisting>\";\nconst DOCBOOK_LISTING_CLOSE = \"</programlisting>\";\nconst DOCBOOK_EXAMPLE_PATTERN = /<\\/?informalexample>\\s*/g;\nconst DOCBOOK_ITEM_OPEN_PATTERN = /<listitem>\\s*(?:<para>\\s*)?/g;\nconst DOCBOOK_ITEM_CLOSE_PATTERN = /(?:<\\/para>\\s*)?<\\/listitem>\\s*/g;\nconst DOCBOOK_LINK_PATTERN = /<link\\s+linkend=\"[^\"]*\">([\\s\\S]*?)<\\/link>/g;\nconst DOCBOOK_LITERAL_PATTERN = /<literal>([\\s\\S]*?)<\\/literal>/g;\nconst DOCBOOK_LIST_PATTERN = /<\\/?itemizedlist>\\s*/g;\nconst DOCBOOK_PARA_PATTERN = /<\\/?para>\\s*/g;\nconst BLANK_LINE_RUN_PATTERN = /\\n{3,}/g;\n\nconst cSymbolSegment = (segment: string): string => kebabCase(segment).replaceAll(\"-\", \"_\");\n\nconst hiddenLinkCandidate = (segments: string[]): string | undefined => {\n const [namespace, ...rest] = segments;\n const prefix = namespace === undefined ? undefined : HIDDEN_LINK_PREFIXES.get(namespace);\n\n if (prefix === undefined || rest.length === 0) {\n return undefined;\n }\n\n return [prefix, ...rest.map((segment) => cSymbolSegment(segment))].join(\"_\");\n};\n\nconst hiddenCIdentifier = (kind: string, target: string, segments: string[]): string | undefined => {\n if (!CALLABLE_LINK_KINDS.has(kind)) {\n return undefined;\n }\n\n const candidate = kind === \"id\" ? target : hiddenLinkCandidate(segments);\n\n return candidate !== undefined && HIDDEN_SYMBOLS.has(candidate) ? candidate : undefined;\n};\n\nconst renderLink = (kind: string, target: string): string => {\n const segments = target.split(/::|[.:]/);\n const hidden = hiddenCIdentifier(kind, target, segments);\n\n if (hidden !== undefined) {\n return `\\`${hidden}()\\``;\n }\n\n const lastIndex = segments.length - 1;\n\n if (kind === \"property\" || CALLABLE_LINK_KINDS.has(kind)) {\n segments[lastIndex] = camelCase(segments[lastIndex] ?? \"\");\n }\n\n const symbol = segments.join(\".\");\n\n return `\\`${symbol}${CALLABLE_LINK_KINDS.has(kind) ? \"()\" : \"\"}\\``;\n};\n\nconst renderTypeRef = (name: string, member: string | undefined): string => {\n if (member === undefined) {\n return `\\`${name}\\``;\n }\n\n return renderLink(member.startsWith(\"::\") ? \"signal\" : \"property\", `${name}${member}`);\n};\n\nconst renderParamRef = (name: string, identifiers: Map<string, string> | undefined): string =>\n `\\`${identifiers?.get(name) ?? name}\\``;\n\nconst trimTrailingNewlines = (value: string): string => {\n let end = value.length;\n\n while (end > 0 && value[end - 1] === \"\\n\") {\n end -= 1;\n }\n\n return value.slice(0, end);\n};\n\nconst renderCodeFence = (body: string): string => {\n const languageMatch = CODE_LANGUAGE_PATTERN.exec(body);\n const fence = (languageMatch?.[1] ?? \"\").trim().toLowerCase();\n const rest = languageMatch === null ? body : body.slice(languageMatch[0].length);\n const code = trimTrailingNewlines(rest.trimStart());\n\n return `\\`\\`\\`${fence}\\n${code}\\n\\`\\`\\``;\n};\n\nconst renderListing = (code: string): string => `\\n\\`\\`\\`\\n${code.trim()}\\n\\`\\`\\`\\n`;\n\nconst replaceDocBookTags = (text: string): string =>\n replaceDelimited(text, [DOCBOOK_LISTING_OPEN, DOCBOOK_LISTING_CLOSE], renderListing)\n .replaceAll(DOCBOOK_EXAMPLE_PATTERN, \"\\n\")\n .replaceAll(DOCBOOK_ITEM_OPEN_PATTERN, \"\\n- \")\n .replaceAll(DOCBOOK_ITEM_CLOSE_PATTERN, \"\\n\")\n .replaceAll(DOCBOOK_LINK_PATTERN, (_match, label: string) => label)\n .replaceAll(DOCBOOK_LITERAL_PATTERN, (_match, literal: string) => `\\`${literal}\\``)\n .replaceAll(DOCBOOK_LIST_PATTERN, \"\\n\\n\")\n .replaceAll(DOCBOOK_PARA_PATTERN, \"\\n\\n\");\n\nconst docBookToMarkdown = (text: string): string => {\n if (!DOCBOOK_TAG_PATTERN.test(text)) {\n return text;\n }\n\n return replaceDocBookTags(text).replaceAll(BLANK_LINE_RUN_PATTERN, \"\\n\\n\").trim();\n};\n\nconst replaceDelimited = (raw: string, bounds: [string, string], render: (body: string) => string): string => {\n const [open, close] = bounds;\n let result = \"\";\n let cursor = 0;\n\n while (cursor < raw.length) {\n const start = raw.indexOf(open, cursor);\n\n if (start === -1) {\n break;\n }\n\n const end = raw.indexOf(close, start + open.length);\n\n if (end === -1) {\n break;\n }\n\n result += raw.slice(cursor, start);\n result += render(raw.slice(start + open.length, end));\n cursor = end + close.length;\n }\n\n return result + raw.slice(cursor);\n};\n\nconst protectCodeBlocks = (raw: string, protect: (value: string) => string): string =>\n replaceDelimited(raw, [CODE_BLOCK_OPEN, CODE_BLOCK_CLOSE], (body) => protect(renderCodeFence(body)));\n\nconst stripHtmlComments = (text: string): string => {\n let current = text;\n let previous = \"\";\n\n while (current !== previous) {\n previous = current;\n current = current.replaceAll(HTML_COMMENT_PATTERN, \"\");\n }\n\n return current;\n};\n\n// eslint-disable-next-line gtkx/no-library-prefix\nconst gtkDocToMarkdown = (raw: string, identifiers?: Map<string, string>): string => {\n const stash: string[] = [];\n\n const protect = (value: string): string => {\n const token = `${SENTINEL}${String(stash.length)}${SENTINEL}`;\n stash.push(value);\n\n return token;\n };\n\n let text = protectCodeBlocks(docBookToMarkdown(raw), protect);\n text = text.replaceAll(FENCED_BLOCK_PATTERN, (block) => protect(block));\n text = text.replaceAll(INLINE_CODE_PATTERN, (span) => protect(span));\n text = text.replaceAll(LINK_PATTERN, (_match, kind: string, target: string) => protect(renderLink(kind, target)));\n text = text.replaceAll(CONSTANT_PATTERN, (_match, name: string) => protect(`\\`${CONSTANT_MAP[name] ?? name}\\``));\n text = text.replaceAll(ESCAPED_CONSTANT_PATTERN, \"%\");\n\n text = text.replaceAll(TYPE_REF_PATTERN, (_match, name: string, member: string | undefined) =>\n protect(renderTypeRef(name, member)),\n );\n\n text = text.replaceAll(PARAM_REF_PATTERN, (_match, name: string) => protect(renderParamRef(name, identifiers)));\n text = text.replaceAll(FUNCTION_REF_PATTERN, (_match, name: string) => protect(`\\`${name}()\\``));\n text = stripHtmlComments(text);\n\n for (let index = stash.length - 1; index >= 0; index -= 1) {\n const value = stash[index] ?? \"\";\n text = text.replaceAll(`${SENTINEL}${String(index)}${SENTINEL}`, () => value);\n }\n\n return text;\n};\n\nexport { gtkDocToMarkdown };\n"]}
@@ -5,6 +5,9 @@ import { RGBA as GeneratedRGBA } from "../gdk.js";
5
5
  *
6
6
  * @param value a CSS color string, such as `#rgb`, `rgb(r,g,b)`, or a named color
7
7
  * @returns the parsed color
8
+ * @deprecated Since 1.3. Use `new RGBA()` and `parse`, checking what `parse` returns so a string GDK cannot
9
+ * read is rejected rather than left as transparent black, or `new RGBA({ red, green, blue, alpha })` when the
10
+ * components are known. Removed in v2.
8
11
  */
9
12
  const create = (value: string): GeneratedRGBA => {
10
13
  const rgba = new GeneratedRGBA();
@@ -22,7 +25,18 @@ const create = (value: string): GeneratedRGBA => {
22
25
  * (1.0, 1.0, 1.0, 1.0) is opaque white. Other values will
23
26
  * be clamped to this range when drawing.
24
27
  */
25
- export const RGBA: typeof GeneratedRGBA & { create: typeof create } = Object.assign(GeneratedRGBA, { create });
28
+ export const RGBA: typeof GeneratedRGBA & {
29
+ /**
30
+ * Parses a CSS color string into a new `RGBA`.
31
+ *
32
+ * @param value a CSS color string, such as `#rgb`, `rgb(r,g,b)`, or a named color
33
+ * @returns the parsed color
34
+ * @deprecated Since 1.3. Use `new RGBA()` and `parse`, checking what `parse` returns so a string GDK cannot
35
+ * read is rejected rather than left as transparent black, or `new RGBA({ red, green, blue, alpha })` when the
36
+ * components are known. Removed in v2.
37
+ */
38
+ create: typeof create;
39
+ } = Object.assign(GeneratedRGBA, { create });
26
40
 
27
41
  /**
28
42
  * Represents a color, in a way that is compatible with cairo's notion of color.
@@ -0,0 +1,3 @@
1
+ export * from "./glib.js";
2
+
3
+ import "./overrides/regex.js";
@@ -0,0 +1,66 @@
1
+ import { matchAllRegex, matchRegex } from "@gtkx/runtime";
2
+ import { type MatchInfo, Regex, type RegexMatchFlags } from "../glib.js";
3
+
4
+ declare module "../glib.js" {
5
+ interface Regex {
6
+ /**
7
+ * Scans for a match in `string` for the pattern in `this`.
8
+ *
9
+ * The returned `MatchInfo` keeps the searched string alive, so its fetch
10
+ * methods stay valid for as long as the `MatchInfo` is reachable.
11
+ *
12
+ * @param string the string to scan for matches
13
+ * @param startPosition starting index of the string to match, in bytes
14
+ * @param matchOptions match options
15
+ * @returns Tuple of:
16
+ *
17
+ * - `result`: `true` if the string matched, `false` otherwise
18
+ * - `matchInfo`: pointer to location where to store the `GMatchInfo`, or `null` if you do not need it
19
+ * @throws A `GLib.Error` carrying the failing operation's domain, code, and message.
20
+ * @since 2.14
21
+ */
22
+ matchFull(string: string, startPosition: number, matchOptions: RegexMatchFlags): [boolean, MatchInfo];
23
+ /**
24
+ * Using the DFA algorithm, scans for all the possible matches in `string`,
25
+ * including overlapping ones.
26
+ *
27
+ * The returned `MatchInfo` keeps the searched string alive, so its fetch
28
+ * methods stay valid for as long as the `MatchInfo` is reachable.
29
+ *
30
+ * @param string the string to scan for matches
31
+ * @param startPosition starting index of the string to match, in bytes
32
+ * @param matchOptions match options
33
+ * @returns Tuple of:
34
+ *
35
+ * - `result`: `true` if the string matched, `false` otherwise
36
+ * - `matchInfo`: pointer to location where to store the `GMatchInfo`, or `null` if you do not need it
37
+ * @throws A `GLib.Error` carrying the failing operation's domain, code, and message.
38
+ * @since 2.14
39
+ */
40
+ matchAllFull(string: string, startPosition: number, matchOptions: RegexMatchFlags): [boolean, MatchInfo];
41
+ }
42
+ }
43
+
44
+ Regex.prototype.match = function match(string: string, matchOptions: RegexMatchFlags): [boolean, MatchInfo] {
45
+ return matchRegex<MatchInfo>(this, string, 0, matchOptions);
46
+ };
47
+
48
+ Regex.prototype.matchAll = function matchAll(string: string, matchOptions: RegexMatchFlags): [boolean, MatchInfo] {
49
+ return matchAllRegex<MatchInfo>(this, string, 0, matchOptions);
50
+ };
51
+
52
+ Regex.prototype.matchFull = function matchFull(
53
+ string: string | string[],
54
+ startPosition: number,
55
+ matchOptions: RegexMatchFlags,
56
+ ): [boolean, MatchInfo] {
57
+ return matchRegex<MatchInfo>(this, string, startPosition, matchOptions);
58
+ };
59
+
60
+ Regex.prototype.matchAllFull = function matchAllFull(
61
+ string: string | string[],
62
+ startPosition: number,
63
+ matchOptions: RegexMatchFlags,
64
+ ): [boolean, MatchInfo] {
65
+ return matchAllRegex<MatchInfo>(this, string, startPosition, matchOptions);
66
+ };
@@ -26,4 +26,7 @@ export {
26
26
  } from "@gtkx/runtime";
27
27
  export * from "./gobject.js";
28
28
  export * from "./overrides/object.js";
29
+ export { ObjectClass } from "./overrides/object-class.js";
30
+ export * from "./overrides/param-spec.js";
31
+ export * from "./overrides/param-spec-getters.js";
29
32
  export * from "./overrides/value.js";
@@ -0,0 +1,27 @@
1
+ import { type AnyClass, peekTypeClass } from "@gtkx/runtime";
2
+ import { ObjectClass as GeneratedObjectClass, type Type } from "../gobject.js";
3
+
4
+ const peek = (type: Type | AnyClass): GeneratedObjectClass => peekTypeClass(type) as GeneratedObjectClass;
5
+
6
+ /**
7
+ * The class structure for the GObject type, with a static `peek` that hands back the class struct
8
+ * of any GObject type so class-level introspection such as `findProperty` and `listProperties`
9
+ * works outside a `classInit` hook.
10
+ */
11
+ export const ObjectClass: typeof GeneratedObjectClass & {
12
+ /**
13
+ * Returns the class struct of a GObject type, referencing the class so it exists even before
14
+ * the type's first instance. The reference is deliberately never released: once created, a
15
+ * class struct lives for the rest of the process.
16
+ *
17
+ * @param type GType to peek the class struct of, or a registered wrapper class of the type.
18
+ * @returns the type's class struct
19
+ * @throws when `type` is not a GObject type
20
+ */
21
+ peek: typeof peek;
22
+ } = Object.assign(GeneratedObjectClass, { peek });
23
+
24
+ /**
25
+ * The class structure for the GObject type.
26
+ */
27
+ export type ObjectClass = GeneratedObjectClass;
@@ -0,0 +1,57 @@
1
+ import { getParamSpecFlags, getParamSpecOwnerType, getParamSpecValueType } from "@gtkx/runtime";
2
+ import { type ParamFlags, ParamSpec, type Type } from "../gobject.js";
3
+
4
+ declare module "../gobject.js" {
5
+ interface ParamSpec {
6
+ /** The `GParamFlags` the spec was created with, such as `ParamFlags.READWRITE` or `ParamFlags.CONSTRUCT_ONLY`. */
7
+ readonly flags: ParamFlags;
8
+
9
+ /** GType of the values the spec describes, such as `TYPE_INT` for a `paramSpecInt` spec. */
10
+ readonly valueType: Type;
11
+
12
+ /** GType the spec is installed on, or `TYPE_INVALID` while it is not installed on any type. */
13
+ readonly ownerType: Type;
14
+
15
+ /** Canonical name of the spec, as `getName` returns it. */
16
+ readonly name: string;
17
+
18
+ /** Nickname of the spec, as `getNick` returns it. */
19
+ readonly nick: string;
20
+
21
+ /** Short description of the spec, as `getBlurb` returns it. */
22
+ readonly blurb: string | null;
23
+ }
24
+ }
25
+
26
+ Object.defineProperties(ParamSpec.prototype, {
27
+ flags: {
28
+ get(this: ParamSpec): ParamFlags {
29
+ return getParamSpecFlags(this) as ParamFlags;
30
+ },
31
+ },
32
+ valueType: {
33
+ get(this: ParamSpec): Type {
34
+ return getParamSpecValueType(this);
35
+ },
36
+ },
37
+ ownerType: {
38
+ get(this: ParamSpec): Type {
39
+ return getParamSpecOwnerType(this);
40
+ },
41
+ },
42
+ name: {
43
+ get(this: ParamSpec): string {
44
+ return this.getName();
45
+ },
46
+ },
47
+ nick: {
48
+ get(this: ParamSpec): string {
49
+ return this.getNick();
50
+ },
51
+ },
52
+ blurb: {
53
+ get(this: ParamSpec): string | null {
54
+ return this.getBlurb();
55
+ },
56
+ },
57
+ });
@@ -0,0 +1,21 @@
1
+ import { type AnyClass, newParamSpecOverride, wrapHandle } from "@gtkx/runtime";
2
+ import { ParamSpec, type Type } from "../gobject.js";
3
+
4
+ /**
5
+ * Creates a `ParamSpec` that redirects to the property `source` declares under `name`, for
6
+ * redeclaring in a subclass a property a parent class or an implemented interface already
7
+ * carries — the equivalent of `g_param_spec_override`, which introspection does not expose.
8
+ *
9
+ * Installing the returned spec through the `properties` option of `registerClass` gives the
10
+ * subclass its own storage and change notification for the property, while its value type,
11
+ * flags and default stay the ones the overridden spec declares.
12
+ *
13
+ * Throws when `source` is neither a GType nor a registered class or interface, and when it
14
+ * declares no property under `name`.
15
+ *
16
+ * @param name Canonical name of the property to override.
17
+ * @param source The GType, wrapper class or interface declaring the property.
18
+ * @returns The override spec, ready to install on a subclass.
19
+ */
20
+ export const paramSpecOverride = (name: string, source: Type | AnyClass): ParamSpec =>
21
+ wrapHandle(newParamSpecOverride(name, source), ParamSpec);
@@ -7,6 +7,8 @@ import { type Type, Value } from "../gobject.js";
7
7
  * @param gtype GType the value holds.
8
8
  * @param populate Called with the initialized value to write the contents.
9
9
  * @returns The populated value.
10
+ * @deprecated Since 1.3. Pass the value itself where a `Value` is expected, or build one with `new Value()`
11
+ * and `init` when it has to hold a GType inference cannot name. Removed in v2.
10
12
  */
11
13
  export const buildValue = (gtype: Type, populate: (value: Value) => void): Value => {
12
14
  const value = new Value();
@@ -19,6 +21,9 @@ Value.prototype.getBoxed = function <T = unknown>(this: Value): T {
19
21
  return getBoxedValue(getHandle(this)) as T;
20
22
  };
21
23
 
22
- Value.prototype.setBoxed = function (this: Value, boxed: object | null): void {
24
+ Value.prototype.setBoxed = function (
25
+ this: Value,
26
+ boxed: object | string | number | bigint | boolean | null,
27
+ ): void {
23
28
  setBoxedValue(getHandle(this), boxed);
24
29
  };