@gtkx/codegen 1.1.0 → 1.2.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 (149) hide show
  1. package/dist/analysis/descriptor-render.d.ts.map +1 -1
  2. package/dist/analysis/descriptor-render.js +14 -10
  3. package/dist/analysis/descriptor-render.js.map +1 -1
  4. package/dist/analysis/descriptor.d.ts +11 -5
  5. package/dist/analysis/descriptor.d.ts.map +1 -1
  6. package/dist/analysis/descriptor.js +25 -9
  7. package/dist/analysis/descriptor.js.map +1 -1
  8. package/dist/analysis/interface-conflicts.d.ts +3 -1
  9. package/dist/analysis/interface-conflicts.d.ts.map +1 -1
  10. package/dist/analysis/interface-conflicts.js +3 -8
  11. package/dist/analysis/interface-conflicts.js.map +1 -1
  12. package/dist/analysis/ts-type.d.ts +3 -2
  13. package/dist/analysis/ts-type.d.ts.map +1 -1
  14. package/dist/analysis/ts-type.js +16 -9
  15. package/dist/analysis/ts-type.js.map +1 -1
  16. package/dist/analysis/type-shape.d.ts +3 -2
  17. package/dist/analysis/type-shape.d.ts.map +1 -1
  18. package/dist/analysis/type-shape.js +2 -1
  19. package/dist/analysis/type-shape.js.map +1 -1
  20. package/dist/compile.d.ts +4 -5
  21. package/dist/compile.d.ts.map +1 -1
  22. package/dist/compile.js +56 -4
  23. package/dist/compile.js.map +1 -1
  24. package/dist/docs/api-reference.d.ts +2 -0
  25. package/dist/docs/api-reference.d.ts.map +1 -1
  26. package/dist/docs/api-reference.js +1 -1
  27. package/dist/docs/api-reference.js.map +1 -1
  28. package/dist/docs/pipeline.d.ts +1 -0
  29. package/dist/docs/pipeline.d.ts.map +1 -1
  30. package/dist/docs/pipeline.js +10 -3
  31. package/dist/docs/pipeline.js.map +1 -1
  32. package/dist/docs/symbol-page.d.ts.map +1 -1
  33. package/dist/docs/symbol-page.js +1 -3
  34. package/dist/docs/symbol-page.js.map +1 -1
  35. package/dist/fingerprint.d.ts +11 -5
  36. package/dist/fingerprint.d.ts.map +1 -1
  37. package/dist/fingerprint.js +22 -19
  38. package/dist/fingerprint.js.map +1 -1
  39. package/dist/gi.d.ts +1 -0
  40. package/dist/gi.d.ts.map +1 -1
  41. package/dist/gi.js +7 -2
  42. package/dist/gi.js.map +1 -1
  43. package/dist/gir/gir-path.d.ts +1 -1
  44. package/dist/gir/gir-path.js +1 -1
  45. package/dist/gir/gir-path.js.map +1 -1
  46. package/dist/gir/library.d.ts +5 -1
  47. package/dist/gir/library.d.ts.map +1 -1
  48. package/dist/gir/library.js +8 -1
  49. package/dist/gir/library.js.map +1 -1
  50. package/dist/gir/parse.d.ts.map +1 -1
  51. package/dist/gir/parse.js +4 -1
  52. package/dist/gir/parse.js.map +1 -1
  53. package/dist/gir/primitives.js +1 -1
  54. package/dist/gir/primitives.js.map +1 -1
  55. package/dist/khronos/args.d.ts.map +1 -1
  56. package/dist/khronos/args.js +8 -6
  57. package/dist/khronos/args.js.map +1 -1
  58. package/dist/khronos/render.d.ts.map +1 -1
  59. package/dist/khronos/render.js +8 -4
  60. package/dist/khronos/render.js.map +1 -1
  61. package/dist/runner.d.ts +2 -0
  62. package/dist/runner.d.ts.map +1 -1
  63. package/dist/runner.js +5 -3
  64. package/dist/runner.js.map +1 -1
  65. package/dist/staging.d.ts.map +1 -1
  66. package/dist/staging.js +1 -1
  67. package/dist/staging.js.map +1 -1
  68. package/dist/store/compile-store.d.ts +0 -1
  69. package/dist/store/compile-store.d.ts.map +1 -1
  70. package/dist/store/compile-store.js +7 -34
  71. package/dist/store/compile-store.js.map +1 -1
  72. package/dist/store/gi/callables.d.ts +1 -3
  73. package/dist/store/gi/callables.d.ts.map +1 -1
  74. package/dist/store/gi/callables.js +19 -4
  75. package/dist/store/gi/callables.js.map +1 -1
  76. package/dist/store/gi/class.d.ts.map +1 -1
  77. package/dist/store/gi/class.js +48 -9
  78. package/dist/store/gi/class.js.map +1 -1
  79. package/dist/store/gi/constant.js +1 -1
  80. package/dist/store/gi/constant.js.map +1 -1
  81. package/dist/store/gi/enum.d.ts.map +1 -1
  82. package/dist/store/gi/enum.js +2 -5
  83. package/dist/store/gi/enum.js.map +1 -1
  84. package/dist/store/gi/interface.js +2 -2
  85. package/dist/store/gi/interface.js.map +1 -1
  86. package/dist/store/gi/method.d.ts.map +1 -1
  87. package/dist/store/gi/method.js +4 -7
  88. package/dist/store/gi/method.js.map +1 -1
  89. package/dist/store/gi/property-accessor.d.ts +0 -3
  90. package/dist/store/gi/property-accessor.d.ts.map +1 -1
  91. package/dist/store/gi/property-accessor.js +15 -108
  92. package/dist/store/gi/property-accessor.js.map +1 -1
  93. package/dist/store/gi/record-constructor.js +3 -3
  94. package/dist/store/gi/record-constructor.js.map +1 -1
  95. package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
  96. package/dist/store/gi/record-field-accessor.js +15 -3
  97. package/dist/store/gi/record-field-accessor.js.map +1 -1
  98. package/dist/store/gi/return-wrap.js +1 -1
  99. package/dist/store/gi/return-wrap.js.map +1 -1
  100. package/dist/store/gi/signal.d.ts.map +1 -1
  101. package/dist/store/gi/signal.js +25 -4
  102. package/dist/store/gi/signal.js.map +1 -1
  103. package/dist/store/jsx-store.d.ts.map +1 -1
  104. package/dist/store/jsx-store.js +0 -1
  105. package/dist/store/jsx-store.js.map +1 -1
  106. package/dist/store/store-fs.d.ts +0 -1
  107. package/dist/store/store-fs.d.ts.map +1 -1
  108. package/dist/store/store-fs.js +2 -7
  109. package/dist/store/store-fs.js.map +1 -1
  110. package/dist/xml.d.ts +1 -0
  111. package/dist/xml.d.ts.map +1 -1
  112. package/dist/xml.js +28 -1
  113. package/dist/xml.js.map +1 -1
  114. package/overrides/gobject/object.ts.ejs +2 -0
  115. package/package.json +3 -3
  116. package/src/analysis/descriptor-render.ts +19 -10
  117. package/src/analysis/descriptor.ts +43 -9
  118. package/src/analysis/interface-conflicts.ts +6 -8
  119. package/src/analysis/ts-type.ts +30 -11
  120. package/src/analysis/type-shape.ts +5 -2
  121. package/src/compile.ts +87 -6
  122. package/src/docs/api-reference.ts +3 -1
  123. package/src/docs/pipeline.ts +13 -7
  124. package/src/docs/symbol-page.ts +0 -4
  125. package/src/fingerprint.ts +31 -38
  126. package/src/gi.ts +9 -2
  127. package/src/gir/gir-path.ts +1 -1
  128. package/src/gir/library.ts +9 -1
  129. package/src/gir/parse.ts +6 -1
  130. package/src/gir/primitives.ts +1 -1
  131. package/src/khronos/args.ts +9 -6
  132. package/src/khronos/render.ts +8 -6
  133. package/src/runner.ts +7 -3
  134. package/src/staging.ts +1 -3
  135. package/src/store/compile-store.ts +7 -40
  136. package/src/store/gi/callables.ts +26 -7
  137. package/src/store/gi/class.ts +63 -7
  138. package/src/store/gi/constant.ts +1 -1
  139. package/src/store/gi/enum.ts +2 -6
  140. package/src/store/gi/interface.ts +2 -2
  141. package/src/store/gi/method.ts +4 -9
  142. package/src/store/gi/property-accessor.ts +22 -193
  143. package/src/store/gi/record-constructor.ts +3 -3
  144. package/src/store/gi/record-field-accessor.ts +18 -3
  145. package/src/store/gi/return-wrap.ts +1 -1
  146. package/src/store/gi/signal.ts +30 -4
  147. package/src/store/jsx-store.ts +0 -1
  148. package/src/store/store-fs.ts +3 -9
  149. package/src/xml.ts +43 -1
@@ -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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,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAuD,CAAC","sourcesContent":["import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { ModuleExport } from \"./react/element-config.js\";\nimport type { OmittedProps } from \"./store/jsx/omitted-props.js\";\nimport { checkModules } from \"./compile.js\";\nimport { isGiStoreFresh } from \"./fingerprint.js\";\nimport { runGiCodegen } from \"./gi.js\";\nimport { Library } from \"./gir/library.js\";\nimport { generateGlModules, type GlGenerationReport } from \"./khronos/pipeline.js\";\nimport { sweepStagingDirs } from \"./staging.js\";\nimport { ensureStoreLink, type StoreOptions } from \"./store/store-fs.js\";\n\ntype GlCodegenOptions = {\n registryPath: string;\n overrideExports: Set<string>;\n outputDir: string;\n resolveFrom: string;\n};\n\n/** What to generate and where to write it. */\ntype CodegenRunnerOptions = {\n /** GIR library identifiers such as `\"Gtk-4.0\"`; a `\"*\"` selection must be expanded before it gets here. */\n libraries: string[];\n /** Directories to search for `.gir` files. */\n girPath: string[];\n /** Where to write and link the `@gtkx/gi` store. */\n gi: StoreOptions;\n /** Where to write and link the `@gtkx/jsx` store; omit to generate the gi store alone. */\n jsx?: StoreOptions | undefined;\n /** Subexport names of the installed `@gtkx/react`, whose element config shapes the jsx store. */\n reactSubexports?: string[];\n /** Component wrappers the project layers over the built-ins, keyed by GLib type name. */\n userComponents?: Record<string, ModuleExport>;\n /** GLib type names whose GObject their parent container creates, added to the framework's own. */\n userLazyElements?: string[];\n /** Base props interfaces the project's elements extend, keyed by GLib type name. */\n userProps?: Record<string, ModuleExport>;\n /** Props the project drops from the generated element props, keyed by GLib type name. */\n userOmittedProps?: OmittedProps;\n /** Regenerates both stores even when their fingerprints are fresh. */\n isForced?: boolean;\n};\n\n/** What a `runCodegen` run produced. */\ntype CodegenRunnerResult = {\n /** Whether either store was rewritten; false means both were already fresh. */\n isRegenerated: boolean;\n /** How many namespaces the gi store was written with, zero when it was already fresh. */\n namespaces: number;\n /** How many JSX elements the jsx store binds, zero when no jsx store was requested. */\n intrinsicElements: number;\n /** Wall-clock duration of the run, in milliseconds. */\n duration: number;\n};\n\ntype StoreResult = {\n isRegenerated: boolean;\n namespaces: number;\n intrinsicElements: number;\n};\n\n/**\n * Writes and links a project's `@gtkx/gi` and `@gtkx/jsx` stores from the given GObject-Introspection\n * libraries. The gi store is rewritten only when its GIR inputs changed, and the jsx store only when the gi\n * store or the React element config changed, unless `options.isForced` is set. Pass the spread of\n * `resolveStore(projectRoot)` for everything but `libraries` and `girPath`.\n *\n * Every store already on disk is linked at its `linkDir` before anything is generated, so a link an install\n * pruned out of `node_modules` is restored without regenerating the store, and the gi store is reachable\n * under its own specifier while the jsx store is type checked.\n *\n * @param options What to generate and where to write it.\n * @returns A summary of what was regenerated and how long the run took.\n * @throws If `girPath` is empty, which would otherwise generate nothing and report success.\n */\nconst runCodegen = async (options: CodegenRunnerOptions): Promise<CodegenRunnerResult> => {\n const start = Date.now();\n const store = await emitStores(options);\n\n return {\n isRegenerated: store.isRegenerated,\n namespaces: store.namespaces,\n intrinsicElements: store.intrinsicElements,\n duration: Date.now() - start,\n };\n};\n\nconst runGlCodegen = (options: GlCodegenOptions): GlGenerationReport => {\n const { files, report } = generateGlModules({\n registryPath: options.registryPath,\n overrideExports: options.overrideExports,\n });\n\n checkModules({\n modules: [...files].map(([fileName, source]) => ({ fileName, source })),\n resolveFrom: options.resolveFrom,\n label: \"the generated gl modules\",\n });\n\n mkdirSync(options.outputDir, { recursive: true });\n\n for (const [fileName, source] of files) {\n writeFileSync(join(options.outputDir, fileName), source);\n }\n\n return report;\n};\n\nconst jsxUserOptions = (\n options: CodegenRunnerOptions,\n): {\n reactSubexports: string[];\n userComponents: Record<string, ModuleExport>;\n userLazyElements: string[];\n userProps: Record<string, ModuleExport>;\n userOmittedProps: OmittedProps;\n} => ({\n reactSubexports: options.reactSubexports ?? [],\n userComponents: options.userComponents ?? {},\n userLazyElements: options.userLazyElements ?? [],\n userProps: options.userProps ?? {},\n userOmittedProps: options.userOmittedProps ?? {},\n});\n\nconst emitJsxStore = async (input: {\n options: CodegenRunnerOptions;\n jsx: StoreOptions;\n gi: StoreOptions;\n loadLibrary: () => Library;\n isGiRegenerated: boolean;\n namespaces: number;\n}): Promise<StoreResult> => {\n const { options, jsx, gi, loadLibrary, isGiRegenerated, namespaces } = input;\n const { runJsxCodegen } = await import(\"./jsx.js\");\n\n const jsxResult = await runJsxCodegen({\n getLibrary: loadLibrary,\n jsx,\n giStoreDir: gi.storeDir,\n ...jsxUserOptions(options),\n isGiRegenerated,\n isForced: options.isForced === true,\n });\n\n return {\n isRegenerated: isGiRegenerated || jsxResult.isRegenerated,\n namespaces,\n intrinsicElements: jsxResult.intrinsicElementCount,\n };\n};\n\nconst emitStoresWithConfig = async (config: {\n options: CodegenRunnerOptions;\n gi: StoreOptions;\n jsx: StoreOptions | undefined;\n libraries: string[];\n girPath: string[];\n}): Promise<StoreResult> => {\n const { options, gi, jsx, libraries, girPath } = config;\n let library: Library | undefined;\n const loadLibrary = (): Library => (library ??= Library.load(libraries, girPath));\n const isGiRegenerated = options.isForced === true || !isGiStoreFresh(gi.storeDir, libraries, girPath);\n\n const namespaces = isGiRegenerated\n ? runGiCodegen(loadLibrary(), { gi, libraries, girPath })\n : 0;\n\n if (jsx === undefined) {\n return { isRegenerated: isGiRegenerated, namespaces, intrinsicElements: 0 };\n }\n\n return emitJsxStore({ options, jsx, gi, loadLibrary, isGiRegenerated, namespaces });\n};\n\nconst prepareStores = (stores: (StoreOptions | undefined)[]): void => {\n for (const store of stores) {\n if (store === undefined) {\n continue;\n }\n\n sweepStagingDirs(store.storeDir);\n ensureStoreLink(store);\n }\n};\n\nconst emitStores = async (options: CodegenRunnerOptions): Promise<StoreResult> => {\n const { gi, jsx, libraries, girPath } = options;\n\n if (girPath.length === 0) {\n throw new Error(\"codegen needs at least one GIR search path; pass the result of resolveGirPath\");\n }\n\n prepareStores([gi, jsx]);\n\n return emitStoresWithConfig({ options, gi, jsx, libraries, girPath });\n};\n\nexport { runCodegen, runGlCodegen, type CodegenRunnerOptions, type CodegenRunnerResult };\n"]}
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,eAAe,EAAqB,MAAM,qBAAqB,CAAC;AAqDzE;;;;;;;;;;;;;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,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,EAAE,GAAG,iBAAiB,CAAC;QACxC,YAAY,EAAE,OAAO,CAAC,YAA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AE,CAAC;IAChF,CAAC;IAED,OAAO,YAAY,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC,CAAC;AACxF,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,MAAoC,EAAQ,EAAE;IACjE,KAAK,MAAM,KAAK,IAAI,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 { 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};\n\n/** What a `runCodegen` run produced. */\ntype CodegenRunnerResult = {\n /** Whether either store was rewritten; false means both were already fresh. */\n isRegenerated: boolean;\n /** How many namespaces the gi store was written with, zero when it was already fresh. */\n namespaces: number;\n /** How many JSX elements the jsx store binds, zero when no jsx store was requested. */\n intrinsicElements: number;\n /** Wall-clock duration of the run, in milliseconds. */\n duration: number;\n};\n\ntype StoreResult = {\n isRegenerated: boolean;\n namespaces: number;\n intrinsicElements: number;\n};\n\n/**\n * Writes and links a project's `@gtkx/gi` and `@gtkx/jsx` stores from the given GObject-Introspection\n * libraries. The gi store is rewritten only when its GIR inputs changed, and the jsx store only when the gi\n * store or the React element config changed, unless `options.isForced` is set. Pass the spread of\n * `resolveStore(projectRoot)` for everything but `libraries` and `girPath`.\n *\n * Every store already on disk is linked at its `linkDir` before anything is generated, so a link an install\n * pruned out of `node_modules` is restored without regenerating the store, and the gi store is reachable\n * under its own specifier while the jsx store is type checked.\n *\n * @param options What to generate and where to write it.\n * @returns A summary of what was regenerated and how long the run took.\n * @throws If `girPath` is empty, which would otherwise generate nothing and report success.\n */\nconst runCodegen = async (options: CodegenRunnerOptions): Promise<CodegenRunnerResult> => {\n const start = Date.now();\n const store = await emitStores(options);\n\n return {\n isRegenerated: store.isRegenerated,\n namespaces: store.namespaces,\n intrinsicElements: store.intrinsicElements,\n duration: Date.now() - start,\n };\n};\n\nconst runGlCodegen = (options: GlCodegenOptions): GlGenerationReport => {\n const { files, report } = generateGlModules({\n registryPath: options.registryPath,\n overrideExports: options.overrideExports,\n });\n\n checkModules({\n modules: [...files].map(([fileName, source]) => ({ fileName, source })),\n resolveFrom: options.resolveFrom,\n label: \"the generated gl modules\",\n });\n\n mkdirSync(options.outputDir, { recursive: true });\n\n for (const [fileName, source] of files) {\n writeFileSync(join(options.outputDir, fileName), source);\n }\n\n return report;\n};\n\nconst jsxUserOptions = (\n options: CodegenRunnerOptions,\n): {\n reactSubexports: string[];\n userComponents: Record<string, ModuleExport>;\n userLazyElements: string[];\n userProps: Record<string, ModuleExport>;\n userOmittedProps: OmittedProps;\n} => ({\n reactSubexports: options.reactSubexports ?? [],\n userComponents: options.userComponents ?? {},\n userLazyElements: options.userLazyElements ?? [],\n userProps: options.userProps ?? {},\n userOmittedProps: options.userOmittedProps ?? {},\n});\n\nconst emitJsxStore = async (input: {\n options: CodegenRunnerOptions;\n jsx: StoreOptions;\n gi: StoreOptions;\n loadLibrary: () => Library;\n isGiRegenerated: boolean;\n namespaces: number;\n}): Promise<StoreResult> => {\n const { options, jsx, gi, loadLibrary, isGiRegenerated, namespaces } = input;\n const { runJsxCodegen } = await import(\"./jsx.js\");\n\n const jsxResult = await runJsxCodegen({\n getLibrary: loadLibrary,\n jsx,\n giStoreDir: gi.storeDir,\n ...jsxUserOptions(options),\n isGiRegenerated,\n isForced: options.isForced === true,\n });\n\n return {\n isRegenerated: isGiRegenerated || jsxResult.isRegenerated,\n namespaces,\n intrinsicElements: jsxResult.intrinsicElementCount,\n };\n};\n\nconst emitStoresWithConfig = async (config: {\n options: CodegenRunnerOptions;\n gi: StoreOptions;\n jsx: StoreOptions | undefined;\n libraries: string[];\n girPath: string[];\n}): Promise<StoreResult> => {\n const { options, gi, jsx, libraries, girPath } = config;\n const isByteArrayTyped = options.isByteArrayTyped === true;\n let library: Library | undefined;\n const loadLibrary = (): Library => (library ??= Library.load(libraries, girPath, isByteArrayTyped));\n const giInputs = { girFiles: [] as string[], libraries, girPath, isByteArrayTyped };\n const isGiRegenerated = options.isForced === true || !isGiStoreFresh(gi.storeDir, giInputs);\n\n const namespaces = isGiRegenerated\n ? runGiCodegen(loadLibrary(), { gi, libraries, girPath, isByteArrayTyped })\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 +1 @@
1
- {"version":3,"file":"staging.d.ts","sourceRoot":"","sources":["../src/staging.ts"],"names":[],"mappings":"AAiDA,QAAA,MAAM,iBAAiB,GAAI,WAAW,MAAM,EAAE,QAAQ,MAAM,KAAG,IAM9D,CAAC;AAEF,QAAA,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,IAE1C,CAAC;AAEF,QAAA,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,MAK1C,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"staging.d.ts","sourceRoot":"","sources":["../src/staging.ts"],"names":[],"mappings":"AA+CA,QAAA,MAAM,iBAAiB,GAAI,WAAW,MAAM,EAAE,QAAQ,MAAM,KAAG,IAM9D,CAAC;AAEF,QAAA,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,IAE1C,CAAC;AAEF,QAAA,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,MAK1C,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC"}
package/dist/staging.js CHANGED
@@ -1,8 +1,8 @@
1
+ import { errorCode } from "@gtkx/utils";
1
2
  import { mkdirSync, mkdtempSync, readdirSync, rmSync } from "node:fs";
2
3
  import { basename, dirname, join } from "node:path";
3
4
  const STAGING_SUFFIX = ".tmp-";
4
5
  const OWNER_PATTERN = /^(?<pid>\d+)-/;
5
- const errorCode = (error) => error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : undefined;
6
6
  const isOwnerRunning = (pid) => {
7
7
  if (!Number.isSafeInteger(pid) || pid <= 0) {
8
8
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"staging.js","sourceRoot":"","sources":["../src/staging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,cAAc,GAAG,OAAO,CAAC;AAC/B,MAAM,aAAa,G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iBAAiB,GAAG,CAAC,IAAY,EAAQ,EAAE;IAC7C,IAAI,CAAC;QACD,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;IAAC,MAAM,CAAC;QACL,OAAO;IACX,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAE,MAAc,EAAQ,EAAE;IAClE,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QACzC,IAAI,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;YAC5B,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;QAC9C,CAAC;IACL,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAQ,EAAE;IAC9C,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,cAAc,EAAE,CAAC,CAAC;AAC/E,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAU,EAAE;IAChD,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEzB,OAAO,WAAW,CAAC,GAAG,MAAM,GAAG,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC5E,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { mkdirSync, mkdtempSync, readdirSync, rmSync } from \"node:fs\";\nimport { basename, dirname, join } from \"node:path\";\n\nconst STAGING_SUFFIX = \".tmp-\";\nconst OWNER_PATTERN = /^(?<pid>\\d+)-/;\n\nconst errorCode = (error: unknown): string | undefined =>\n error instanceof Error && \"code\" in error && typeof error.code === \"string\" ? error.code : undefined;\n\nconst isOwnerRunning = (pid: number): boolean => {\n if (!Number.isSafeInteger(pid) || pid <= 0) {\n return false;\n }\n\n try {\n process.kill(pid, 0);\n\n return true;\n } catch (error) {\n return errorCode(error) === \"EPERM\";\n }\n};\n\nconst isStranded = (entry: string, prefix: string): boolean => {\n if (!entry.startsWith(prefix)) {\n return false;\n }\n\n const owner = OWNER_PATTERN.exec(entry.slice(prefix.length))?.groups?.pid;\n\n return owner === undefined || !isOwnerRunning(Number(owner));\n};\n\nconst readEntries = (parentDir: string): string[] => {\n try {\n return readdirSync(parentDir);\n } catch {\n return [];\n }\n};\n\nconst removeStrandedDir = (path: string): void => {\n try {\n rmSync(path, { recursive: true, force: true });\n } catch {\n return;\n }\n};\n\nconst sweepStrandedDirs = (parentDir: string, prefix: string): void => {\n for (const entry of readEntries(parentDir)) {\n if (isStranded(entry, prefix)) {\n removeStrandedDir(join(parentDir, entry));\n }\n }\n};\n\nconst sweepStagingDirs = (target: string): void => {\n sweepStrandedDirs(dirname(target), `${basename(target)}${STAGING_SUFFIX}`);\n};\n\nconst createStagingDir = (target: string): string => {\n mkdirSync(dirname(target), { recursive: true });\n sweepStagingDirs(target);\n\n return mkdtempSync(`${target}${STAGING_SUFFIX}${String(process.pid)}-`);\n};\n\nexport { createStagingDir, sweepStagingDirs, sweepStrandedDirs };\n"]}
1
+ {"version":3,"file":"staging.js","sourceRoot":"","sources":["../src/staging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,cAAc,GAAG,OAAO,CAAC;AAC/B,MAAM,aAAa,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ACL,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAE,MAAc,EAAQ,EAAE;IAClE,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QACzC,IAAI,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;YAC5B,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;QAC9C,CAAC;IACL,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAQ,EAAE;IAC9C,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,cAAc,EAAE,CAAC,CAAC;AAC/E,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAU,EAAE;IAChD,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEzB,OAAO,WAAW,CAAC,GAAG,MAAM,GAAG,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC5E,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { errorCode } from \"@gtkx/utils\";\nimport { mkdirSync, mkdtempSync, readdirSync, rmSync } from \"node:fs\";\nimport { basename, dirname, join } from \"node:path\";\n\nconst STAGING_SUFFIX = \".tmp-\";\nconst OWNER_PATTERN = /^(?<pid>\\d+)-/;\n\nconst isOwnerRunning = (pid: number): boolean => {\n if (!Number.isSafeInteger(pid) || pid <= 0) {\n return false;\n }\n\n try {\n process.kill(pid, 0);\n\n return true;\n } catch (error) {\n return errorCode(error) === \"EPERM\";\n }\n};\n\nconst isStranded = (entry: string, prefix: string): boolean => {\n if (!entry.startsWith(prefix)) {\n return false;\n }\n\n const owner = OWNER_PATTERN.exec(entry.slice(prefix.length))?.groups?.pid;\n\n return owner === undefined || !isOwnerRunning(Number(owner));\n};\n\nconst readEntries = (parentDir: string): string[] => {\n try {\n return readdirSync(parentDir);\n } catch {\n return [];\n }\n};\n\nconst removeStrandedDir = (path: string): void => {\n try {\n rmSync(path, { recursive: true, force: true });\n } catch {\n return;\n }\n};\n\nconst sweepStrandedDirs = (parentDir: string, prefix: string): void => {\n for (const entry of readEntries(parentDir)) {\n if (isStranded(entry, prefix)) {\n removeStrandedDir(join(parentDir, entry));\n }\n }\n};\n\nconst sweepStagingDirs = (target: string): void => {\n sweepStrandedDirs(dirname(target), `${basename(target)}${STAGING_SUFFIX}`);\n};\n\nconst createStagingDir = (target: string): string => {\n mkdirSync(dirname(target), { recursive: true });\n sweepStagingDirs(target);\n\n return mkdtempSync(`${target}${STAGING_SUFFIX}${String(process.pid)}-`);\n};\n\nexport { createStagingDir, sweepStagingDirs, sweepStrandedDirs };\n"]}
@@ -3,7 +3,6 @@ type CompileStoreParams = {
3
3
  storeDir: string;
4
4
  files: SourceModule[];
5
5
  packageName: string;
6
- requiresEnvReference?: boolean;
7
6
  };
8
7
  declare const compileStore: (params: CompileStoreParams) => void;
9
8
  export { compileStore };
@@ -1 +1 @@
1
- {"version":3,"file":"compile-store.d.ts","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAEpF,KAAK,kBAAkB,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAqBF,QAAA,MAAM,YAAY,GAAI,QAAQ,kBAAkB,KAAG,IAuBlD,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"compile-store.d.ts","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAE/D,KAAK,kBAAkB,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,QAAA,MAAM,YAAY,GAAI,QAAQ,kBAAkB,KAAG,IAUlD,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -1,39 +1,12 @@
1
- import { rmSync, writeFileSync } from "node:fs";
1
+ import { rmSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { compileProject } from "../compile.js";
4
- const EMIT_OPTIONS = {
5
- declaration: true,
6
- removeComments: false,
7
- sourceMap: false,
8
- declarationMap: false,
9
- rootDir: ".",
10
- outDir: ".",
11
- };
12
- const ENV_REFERENCE_FILE = "__gtkx-env__.d.ts";
13
- const writeEnvReference = (storeDir) => {
14
- writeFileSync(join(storeDir, ENV_REFERENCE_FILE), "/// <reference types=\"@gtkx/react/env\" />\n");
15
- return () => {
16
- rmSync(join(storeDir, ENV_REFERENCE_FILE), { force: true });
17
- };
18
- };
3
+ import { emitModules } from "../compile.js";
19
4
  const compileStore = (params) => {
20
- const removeEnvReference = params.requiresEnvReference === true
21
- ? writeEnvReference(params.storeDir)
22
- : () => undefined;
23
- const files = params.requiresEnvReference === true
24
- ? [{ fileName: ENV_REFERENCE_FILE }, ...params.files]
25
- : params.files;
26
- try {
27
- compileProject({
28
- projectDir: params.storeDir,
29
- files,
30
- compilerOptions: EMIT_OPTIONS,
31
- label: `the generated ${params.packageName} store`,
32
- });
33
- }
34
- finally {
35
- removeEnvReference();
36
- }
5
+ emitModules({
6
+ projectDir: params.storeDir,
7
+ files: params.files,
8
+ label: `the generated ${params.packageName} store`,
9
+ });
37
10
  for (const file of params.files) {
38
11
  rmSync(join(params.storeDir, file.fileName), { force: true });
39
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"compile-store.js","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAuC,MAAM,eAAe,CAAC;AASpF,MAAM,YAAY,GAAG;IACjB,WAAW,EAAE,IAAI;IACjB,cAAc,EAAE,KAAK;IACrB,SAAS,EAAE,KAAK;IAChB,cAAc,EAAE,KAAK;IACrB,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;CACd,CAAC;AAEF,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAE/C,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAgB,EAAE;IACzD,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,kBAAkB,CAAC,EAAE,+CAA+C,CAAC,CAAC;IAEnG,OAAO,GAAG,EAAE;QACR,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,kBAAkB,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,MAA0B,EAAQ,EAAE;IACtD,MAAM,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,KAAK,IAAI;QAC3D,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC;QACpC,CAAC,CAAC,GAAS,EAAE,CAAC,SAAS,CAAC;IAE5B,MAAM,KAAK,GAAkB,MAAM,CAAC,oBAAoB,KAAK,IAAI;QAC7D,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC;QACrD,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IAEnB,IAAI,CAAC;QACD,cAAc,CAAC;YACX,UAAU,EAAE,MAAM,CAAC,QAAQ;YAC3B,KAAK;YACL,eAAe,EAAE,YAAY;YAC7B,KAAK,EAAE,iBAAiB,MAAM,CAAC,WAAW,QAAQ;SACrD,CAAC,CAAC;IACP,CAAC;YAAS,CAAC;QACP,kBAAkB,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { compileProject, type ProjectFile, type SourceModule } from \"../compile.js\";\n\ntype CompileStoreParams = {\n storeDir: string;\n files: SourceModule[];\n packageName: string;\n requiresEnvReference?: boolean;\n};\n\nconst EMIT_OPTIONS = {\n declaration: true,\n removeComments: false,\n sourceMap: false,\n declarationMap: false,\n rootDir: \".\",\n outDir: \".\",\n};\n\nconst ENV_REFERENCE_FILE = \"__gtkx-env__.d.ts\";\n\nconst writeEnvReference = (storeDir: string): (() => void) => {\n writeFileSync(join(storeDir, ENV_REFERENCE_FILE), \"/// <reference types=\\\"@gtkx/react/env\\\" />\\n\");\n\n return () => {\n rmSync(join(storeDir, ENV_REFERENCE_FILE), { force: true });\n };\n};\n\nconst compileStore = (params: CompileStoreParams): void => {\n const removeEnvReference = params.requiresEnvReference === true\n ? writeEnvReference(params.storeDir)\n : (): void => undefined;\n\n const files: ProjectFile[] = params.requiresEnvReference === true\n ? [{ fileName: ENV_REFERENCE_FILE }, ...params.files]\n : params.files;\n\n try {\n compileProject({\n projectDir: params.storeDir,\n files,\n compilerOptions: EMIT_OPTIONS,\n label: `the generated ${params.packageName} store`,\n });\n } finally {\n removeEnvReference();\n }\n\n for (const file of params.files) {\n rmSync(join(params.storeDir, file.fileName), { force: true });\n }\n};\n\nexport { compileStore };\n"]}
1
+ {"version":3,"file":"compile-store.js","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAqB,MAAM,eAAe,CAAC;AAQ/D,MAAM,YAAY,GAAG,CAAC,MAA0B,EAAQ,EAAE;IACtD,WAAW,CAAC;QACR,UAAU,EAAE,MAAM,CAAC,QAAQ;QAC3B,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,KAAK,EAAE,iBAAiB,MAAM,CAAC,WAAW,QAAQ;KACrD,CAAC,CAAC;IAEH,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { rmSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { emitModules, type SourceModule } from \"../compile.js\";\n\ntype CompileStoreParams = {\n storeDir: string;\n files: SourceModule[];\n packageName: string;\n};\n\nconst compileStore = (params: CompileStoreParams): void => {\n emitModules({\n projectDir: params.storeDir,\n files: params.files,\n label: `the generated ${params.packageName} store`,\n });\n\n for (const file of params.files) {\n rmSync(join(params.storeDir, file.fileName), { force: true });\n }\n};\n\nexport { compileStore };\n"]}
@@ -29,7 +29,6 @@ declare const instanceScope: (ownerName: string, callables: Callables) => Instan
29
29
  declare const dedupeCallables: (callables: GirFunction[]) => GirFunction[];
30
30
  declare const generateBindings: (context: ModuleContext, callables: Callables) => void;
31
31
  declare const matchStaticFinishFunction: (context: ModuleContext, callable: GirFunction, siblings: GirFunction[]) => GirFunction | undefined;
32
- declare const indexMethodsByName: (methods: GirFunction[]) => Map<string, GirFunction>;
33
32
  declare const isEmittableCallable: (context: ModuleContext, callable: GirFunction) => boolean;
34
33
  declare const renderStaticSignature: (context: ModuleContext, callable: GirFunction, options?: {
35
34
  returnTypeOverride?: string | undefined;
@@ -39,11 +38,10 @@ declare const renderStaticSignature: (context: ModuleContext, callable: GirFunct
39
38
  signature: string;
40
39
  } | undefined;
41
40
  declare const staticMembers: (context: ModuleContext, callables: Callables) => StaticMember[];
42
- declare const constructorMemberNames: (context: ModuleContext, constructors: GirFunction[]) => string[];
43
41
  declare const renderStaticHead: (context: ModuleContext, callables: Callables, ownerClassName: string) => string[];
44
42
  declare const renderPlainTypeMembers: (options: PlainTypeMembersOptions) => {
45
43
  members: string[];
46
44
  claimedNames: Set<string>;
47
45
  };
48
- export { renderInstanceMethodSignature, renderClassInstanceMember, instanceMemberSpec, instanceScope, dedupeCallables, generateBindings, matchStaticFinishFunction, indexMethodsByName, isEmittableCallable, renderStaticSignature, constructorMemberNames, renderStaticHead, renderPlainTypeMembers, staticMembers, type Callables, type InstanceMemberRenderer, type InstanceScope, };
46
+ export { renderInstanceMethodSignature, renderClassInstanceMember, instanceMemberSpec, instanceScope, dedupeCallables, generateBindings, matchStaticFinishFunction, isEmittableCallable, renderStaticSignature, renderStaticHead, renderPlainTypeMembers, staticMembers, type Callables, type InstanceMemberRenderer, type InstanceScope, };
49
47
  //# sourceMappingURL=callables.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"callables.d.ts","sourceRoot":"","sources":["../../../src/store/gi/callables.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAq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,aAAa,GACrB,CAAC"}
@@ -7,6 +7,14 @@ import { renderFnExpression } from "./function.js";
7
7
  import { gtypeMemberDeclaration } from "./gtype-binding.js";
8
8
  import { finishCallExpression, memberName, methodExportName, renderMethodBody, renderMethodReturnType, renderMethodSignature, renderPromisifiedBody, renderPromisifiedSignature, } from "./method.js";
9
9
  import { renderRuntimeOverride, runtimeOverrideRenames } from "./runtime-override.js";
10
+ const RUNTIME_OWNED_LIFETIME_METHODS = new Set([
11
+ "force_floating",
12
+ "free",
13
+ "ref",
14
+ "ref_sink",
15
+ "take_ref",
16
+ "unref",
17
+ ]);
10
18
  const renderInstanceMethodSignature = instanceMemberRenderer((context, callable, { name, finishFn }) => `${memberDoc(context, callable, finishFn)}${memberSignatureText(context, callable, name, { finishFn })};`);
11
19
  const renderClassInstanceMember = instanceMemberRenderer((context, callable, { name, finishFn }, scope) => finishFn === undefined
12
20
  ? renderInstanceMethod(context, callable, name)
@@ -167,6 +175,7 @@ const indexMethodsByName = (methods) => {
167
175
  const isEmittableCallable = (context, callable) => callable.introspectable &&
168
176
  callable.shadowedBy === undefined &&
169
177
  callable.cIdentifier !== undefined &&
178
+ !RUNTIME_OWNED_LIFETIME_METHODS.has(callable.name) &&
170
179
  !hasUnmarshalableParam(context, callable);
171
180
  const constructorMemberName = (girName) => {
172
181
  const camel = memberName(girName);
@@ -189,10 +198,17 @@ const renderStaticSignature = (context, callable, options) => {
189
198
  }),
190
199
  };
191
200
  };
201
+ const staticMemberName = (context, callable, resolveName) => {
202
+ if (!isEmittableCallable(context, callable)) {
203
+ return undefined;
204
+ }
205
+ const name = resolveName(callable.name);
206
+ return name !== undefined && isEmittableMemberName(name) ? name : undefined;
207
+ };
192
208
  const collectStaticMembers = (context, group, resolveName) => {
193
209
  const members = [];
194
210
  for (const callable of group) {
195
- const name = isEmittableCallable(context, callable) ? resolveName(callable.name) : undefined;
211
+ const name = staticMemberName(context, callable, resolveName);
196
212
  if (name !== undefined) {
197
213
  members.push({ callable, name });
198
214
  }
@@ -200,10 +216,9 @@ const collectStaticMembers = (context, group, resolveName) => {
200
216
  return members;
201
217
  };
202
218
  const staticMembers = (context, callables) => [
203
- ...collectStaticMembers(context, callables.constructors, constructorMemberName),
219
+ ...collectStaticMembers(context, callables.constructors, memberName),
204
220
  ...collectStaticMembers(context, callables.functions, memberName),
205
221
  ];
206
- const constructorMemberNames = (context, constructors) => collectStaticMembers(context, constructors, constructorMemberName).map((member) => member.name);
207
222
  const collectStaticEntries = (context, group, siblings, options) => {
208
223
  const blocks = [];
209
224
  for (const callable of group) {
@@ -250,5 +265,5 @@ const renderPlainTypeMembers = (options) => {
250
265
  ];
251
266
  return { members, claimedNames };
252
267
  };
253
- export { renderInstanceMethodSignature, renderClassInstanceMember, instanceMemberSpec, instanceScope, dedupeCallables, generateBindings, matchStaticFinishFunction, indexMethodsByName, isEmittableCallable, renderStaticSignature, constructorMemberNames, renderStaticHead, renderPlainTypeMembers, staticMembers, };
268
+ export { renderInstanceMethodSignature, renderClassInstanceMember, instanceMemberSpec, instanceScope, dedupeCallables, generateBindings, matchStaticFinishFunction, isEmittableCallable, renderStaticSignature, renderStaticHead, renderPlainTypeMembers, staticMembers, };
254
269
  //# sourceMappingURL=callables.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"callables.js","sourceRoot":"","sources":["../../../src/store/gi/callables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAA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gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC;QAClD,GAAG,0BAA0B,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC;KAC1E,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;AACrC,CAAC,CAAC;AAEF,OAAO,EACH,6BAA6B,EAC7B,yBAAyB,EACzB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,aAAa,GAIhB,CAAC","sourcesContent":["import { toCamelIdentifier, uniqBy } from \"@gtkx/utils\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport type { JsDocSpec } from \"../../writer/doc.js\";\nimport { hasUnmarshalableParam } from \"../../analysis/param-capability.js\";\nimport { renderBlock } from \"../../writer/emit.js\";\nimport { matchAsyncFinish } from \"./async.js\";\nimport { callableDoc, callableSpec } from \"./callable-doc.js\";\nimport { renderFnExpression } from \"./function.js\";\nimport { gtypeMemberDeclaration } from \"./gtype-binding.js\";\nimport {\n finishCallExpression,\n memberName,\n methodExportName,\n renderMethodBody,\n renderMethodReturnType,\n renderMethodSignature,\n renderPromisifiedBody,\n renderPromisifiedSignature,\n} from \"./method.js\";\nimport { renderRuntimeOverride, runtimeOverrideRenames } from \"./runtime-override.js\";\n\ntype Callables = {\n constructors: GirFunction[];\n functions: GirFunction[];\n methods: GirFunction[];\n};\n\ntype InstanceScope = {\n ownerName: string;\n methodByName: Map<string, GirFunction>;\n statics: GirFunction[];\n};\n\ntype CallableMemberOptions = {\n resolveName: (callable: GirFunction) => string | undefined;\n isStatic: boolean;\n returnTypeOverride?: string | undefined;\n canUseRuntimeOverride?: boolean;\n};\n\ntype StaticEntryOptions = {\n resolveName: (callable: GirFunction) => string | undefined;\n ownerName: string;\n returnTypeOverride?: string | undefined;\n};\n\ntype ResolvedInstanceMember = {\n name: string;\n finishFn: GirFunction | undefined;\n};\n\ntype StaticMember = {\n callable: GirFunction;\n name: string;\n};\n\ntype InstanceMemberRenderer = (\n context: ModuleContext,\n callable: GirFunction,\n scope: InstanceScope,\n nameOverride?: string,\n) => string | undefined;\n\ntype PlainTypeMembersOptions = {\n context: ModuleContext;\n className: string;\n callables: Callables;\n hasGtype: boolean;\n};\n\nconst renderInstanceMethodSignature: InstanceMemberRenderer = instanceMemberRenderer(\n (context, callable, { name, finishFn }) =>\n `${memberDoc(context, callable, finishFn)}${memberSignatureText(context, callable, name, { finishFn })};`,\n);\n\nconst renderClassInstanceMember: InstanceMemberRenderer = instanceMemberRenderer(\n (context, callable, { name, finishFn }, scope) =>\n finishFn === undefined\n ? renderInstanceMethod(context, callable, name)\n : renderPromisifiedCallable(context, callable, finishFn, {\n name,\n isStatic: false,\n ownerName: scope.ownerName,\n }),\n);\n\nconst memberDoc = (context: ModuleContext, callable: GirFunction, finishFn: GirFunction | undefined): string =>\n callableDoc(context, callable, { finishFn });\n\nconst instanceMemberSpec = (context: ModuleContext, callable: GirFunction, scope: InstanceScope): JsDocSpec =>\n callableSpec(context, callable, { finishFn: matchFinishFunction(context, callable, scope) });\n\nconst instanceScope = (ownerName: string, callables: Callables): InstanceScope => ({\n ownerName,\n methodByName: indexMethodsByName(callables.methods),\n statics: [...callables.constructors, ...callables.functions],\n});\n\nconst dedupeCallables = (callables: GirFunction[]): GirFunction[] =>\n uniqBy(\n callables.filter(\n (callable): callable is GirFunction & { cIdentifier: string } => callable.cIdentifier !== undefined,\n ),\n (callable) => callable.cIdentifier,\n );\n\nconst getEmittableCIdentifier = (context: ModuleContext, callable: GirFunction): string | undefined =>\n isEmittableCallable(context, callable) ? callable.cIdentifier : undefined;\n\nconst renderBinding = (\n context: ModuleContext,\n callable: GirFunction,\n): { text: string; cIdentifier: string } | undefined => {\n const cIdentifier = getEmittableCIdentifier(context, callable);\n\n if (cIdentifier === undefined) {\n return undefined;\n }\n\n const expression = renderFnExpression(context, callable);\n\n if (expression === undefined) {\n return undefined;\n }\n\n return { text: `const ${toCamelIdentifier(cIdentifier)} = ${expression};`, cIdentifier };\n};\n\nconst generateBindings = (context: ModuleContext, callables: Callables): void => {\n const all = [...callables.constructors, ...callables.functions, ...callables.methods];\n\n for (const callable of all) {\n const binding = renderBinding(context, callable);\n\n if (binding !== undefined) {\n context.module.appendBinding(binding.text, binding.cIdentifier);\n }\n }\n};\n\nconst resolveCallableMember = (\n context: ModuleContext,\n callable: GirFunction,\n resolveName: (callable: GirFunction) => string | undefined,\n): { cIdentifier: string; name: string } | undefined => {\n const cIdentifier = getEmittableCIdentifier(context, callable);\n\n if (cIdentifier === undefined) {\n return undefined;\n }\n\n const name = resolveName(callable);\n\n if (name === undefined || !isEmittableMemberName(name)) {\n return undefined;\n }\n\n return { cIdentifier, name };\n};\n\nconst runtimeOverrideMember = (\n callable: GirFunction,\n name: string,\n doc: string,\n canUseRuntimeOverride: boolean | undefined,\n): string | undefined => {\n if (canUseRuntimeOverride !== true) {\n return undefined;\n }\n\n const override = renderRuntimeOverride(callable, name);\n\n return override === undefined ? undefined : `${doc}${override}`;\n};\n\nconst renderCallableMember = (\n context: ModuleContext,\n callable: GirFunction,\n options: CallableMemberOptions,\n): string | undefined => {\n const resolved = resolveCallableMember(context, callable, options.resolveName);\n\n if (resolved === undefined) {\n return undefined;\n }\n\n const { cIdentifier, name } = resolved;\n const renames = options.canUseRuntimeOverride === true ? runtimeOverrideRenames(callable) : undefined;\n const doc = callableDoc(context, callable, { renames });\n const override = runtimeOverrideMember(callable, name, doc, options.canUseRuntimeOverride);\n\n if (override !== undefined) {\n return override;\n }\n\n const signature = renderMethodSignature(context, callable);\n const returnType = options.returnTypeOverride ?? renderMethodReturnType(context, callable);\n\n const body = renderMethodBody(context, callable, {\n bindingExpression: toCamelIdentifier(cIdentifier),\n returnTypeOverride: options.returnTypeOverride,\n });\n\n const prefix = options.isStatic ? \"static \" : \"\";\n const header = `${prefix}${name}(${signature}): ${returnType}`;\n\n return `${doc}${renderBlock(header, body)}`;\n};\n\nconst renderStaticEntry = (\n context: ModuleContext,\n callable: GirFunction,\n siblings: GirFunction[],\n options: StaticEntryOptions,\n): string | undefined => {\n const finishFn = matchStaticFinishFunction(context, callable, siblings);\n\n if (finishFn !== undefined) {\n const name = options.resolveName(callable);\n\n if (name === undefined || !isEmittableMemberName(name)) {\n return undefined;\n }\n\n return renderPromisifiedCallable(context, callable, finishFn, {\n name,\n isStatic: true,\n ownerName: options.ownerName,\n });\n }\n\n return renderCallableMember(context, callable, {\n resolveName: options.resolveName,\n isStatic: true,\n returnTypeOverride: options.returnTypeOverride,\n });\n};\n\nconst renderInstanceMethod = (\n context: ModuleContext,\n callable: GirFunction,\n nameOverride?: string,\n): string | undefined =>\n renderCallableMember(context, callable, {\n resolveName: (member) => nameOverride ?? methodExportName(member),\n isStatic: false,\n canUseRuntimeOverride: true,\n });\n\nconst isEmittableMemberName = (name: string): boolean => name !== \"constructor\" && name.length > 0;\n\nconst resolveInstanceMember = (\n context: ModuleContext,\n callable: GirFunction,\n scope: InstanceScope,\n nameOverride?: string,\n): ResolvedInstanceMember | undefined => {\n if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const name = nameOverride ?? methodExportName(callable);\n\n if (!isEmittableMemberName(name)) {\n return undefined;\n }\n\n const finishFn = matchFinishFunction(context, callable, scope);\n\n if (finishFn !== undefined && !isEmittableCallable(context, finishFn)) {\n return undefined;\n }\n\n return { name, finishFn };\n};\n\nfunction instanceMemberRenderer(\n render: (\n context: ModuleContext,\n callable: GirFunction,\n member: ResolvedInstanceMember,\n scope: InstanceScope,\n ) => string | undefined,\n): InstanceMemberRenderer {\n return (context, callable, scope, nameOverride) => {\n const member = resolveInstanceMember(context, callable, scope, nameOverride);\n\n return member === undefined ? undefined : render(context, callable, member, scope);\n };\n}\n\nconst memberSignatureText = (\n context: ModuleContext,\n callable: GirFunction,\n name: string,\n options: { finishFn: GirFunction | undefined; returnTypeOverride?: string | undefined },\n): string => {\n const promisified =\n options.finishFn === undefined ? undefined : renderPromisifiedSignature(context, callable, options.finishFn);\n\n const signature = promisified?.signature ?? renderMethodSignature(context, callable);\n\n const returnType =\n promisified?.returnType ?? options.returnTypeOverride ?? renderMethodReturnType(context, callable);\n\n return `${name}(${signature}): ${returnType}`;\n};\n\nconst matchFinishFunction = (\n context: ModuleContext,\n callable: GirFunction,\n scope: InstanceScope,\n): GirFunction | undefined =>\n matchAsyncFinish(context.library, callable, [...scope.methodByName.values(), ...scope.statics]);\n\nconst matchStaticFinishFunction = (\n context: ModuleContext,\n callable: GirFunction,\n siblings: GirFunction[],\n): GirFunction | undefined => {\n if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const finishFn = matchAsyncFinish(context.library, callable, siblings);\n\n if (finishFn === undefined || !isEmittableCallable(context, finishFn)) {\n return undefined;\n }\n\n return finishFn;\n};\n\nconst renderPromisifiedCallable = (\n context: ModuleContext,\n callable: GirFunction,\n finishFn: GirFunction,\n member: { name: string; isStatic: boolean; ownerName: string },\n): string | undefined => {\n const cIdentifier = callable.cIdentifier;\n\n if (cIdentifier === undefined) {\n return undefined;\n }\n\n const { signature, returnType } = renderPromisifiedSignature(context, callable, finishFn);\n\n const body = renderPromisifiedBody(\n context,\n callable,\n finishCallExpression(callable, finishFn, member.ownerName),\n toCamelIdentifier(cIdentifier),\n );\n\n const prefix = member.isStatic ? \"static \" : \"\";\n const header = `${prefix}${member.name}(${signature}): ${returnType}`;\n\n return `${memberDoc(context, callable, finishFn)}${renderBlock(header, body)}`;\n};\n\nconst indexMethodsByName = (methods: GirFunction[]): Map<string, GirFunction> => {\n const map: Map<string, GirFunction> = new Map();\n\n for (const callable of methods) {\n map.set(callable.name, callable);\n }\n\n return map;\n};\n\nconst isEmittableCallable = (context: ModuleContext, callable: GirFunction): boolean =>\n callable.introspectable &&\n callable.shadowedBy === undefined &&\n callable.cIdentifier !== undefined &&\n !hasUnmarshalableParam(context, callable);\n\nconst constructorMemberName = (girName: string): string | undefined => {\n const camel = memberName(girName);\n\n return isEmittableMemberName(camel) ? camel : undefined;\n};\n\nconst renderStaticSignature = (\n context: ModuleContext,\n callable: GirFunction,\n options?: { returnTypeOverride?: string | undefined; siblings?: GirFunction[] | undefined },\n): { name: string; signature: string } | undefined => {\n if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const name = constructorMemberName(callable.name);\n\n if (name === undefined) {\n return undefined;\n }\n\n const finishFn =\n options?.siblings === undefined ? undefined : matchStaticFinishFunction(context, callable, options.siblings);\n\n return {\n name,\n signature: memberSignatureText(context, callable, name, {\n finishFn,\n returnTypeOverride: options?.returnTypeOverride,\n }),\n };\n};\n\nconst collectStaticMembers = (\n context: ModuleContext,\n group: GirFunction[],\n resolveName: (girName: string) => string | undefined,\n): StaticMember[] => {\n const members: StaticMember[] = [];\n\n for (const callable of group) {\n const name = isEmittableCallable(context, callable) ? resolveName(callable.name) : undefined;\n\n if (name !== undefined) {\n members.push({ callable, name });\n }\n }\n\n return members;\n};\n\nconst staticMembers = (context: ModuleContext, callables: Callables): StaticMember[] => [\n ...collectStaticMembers(context, callables.constructors, constructorMemberName),\n ...collectStaticMembers(context, callables.functions, memberName),\n];\n\nconst constructorMemberNames = (context: ModuleContext, constructors: GirFunction[]): string[] =>\n collectStaticMembers(context, constructors, constructorMemberName).map((member) => member.name);\n\nconst collectStaticEntries = (\n context: ModuleContext,\n group: GirFunction[],\n siblings: GirFunction[],\n options: StaticEntryOptions,\n): string[] => {\n const blocks: string[] = [];\n\n for (const callable of group) {\n const block = renderStaticEntry(context, callable, siblings, options);\n\n if (block !== undefined) {\n blocks.push(block);\n }\n }\n\n return blocks;\n};\n\nconst renderStaticHead = (context: ModuleContext, callables: Callables, ownerClassName: string): string[] => {\n const siblings = [...callables.constructors, ...callables.functions];\n\n return [\n ...collectStaticEntries(context, callables.constructors, siblings, {\n resolveName: (member) => constructorMemberName(member.name),\n ownerName: ownerClassName,\n returnTypeOverride: ownerClassName,\n }),\n ...collectStaticEntries(context, callables.functions, siblings, {\n resolveName: (member) => memberName(member.name),\n ownerName: ownerClassName,\n }),\n ];\n};\n\nconst renderPlainInstanceMethods = (\n context: ModuleContext,\n methods: GirFunction[],\n claimedNames: Set<string>,\n): string[] => {\n const blocks: string[] = [];\n\n for (const callable of methods) {\n const block = renderInstanceMethod(context, callable);\n\n if (block === undefined) {\n continue;\n }\n\n blocks.push(block);\n claimedNames.add(methodExportName(callable));\n }\n\n return blocks;\n};\n\nconst renderPlainTypeMembers = (\n options: PlainTypeMembersOptions,\n): { members: string[]; claimedNames: Set<string> } => {\n const { context, className, callables, hasGtype } = options;\n const claimedNames: Set<string> = new Set();\n\n const members: string[] = [\n ...(hasGtype ? [gtypeMemberDeclaration(context)] : []),\n ...renderStaticHead(context, callables, className),\n ...renderPlainInstanceMethods(context, callables.methods, claimedNames),\n ];\n\n return { members, claimedNames };\n};\n\nexport {\n renderInstanceMethodSignature,\n renderClassInstanceMember,\n instanceMemberSpec,\n instanceScope,\n dedupeCallables,\n generateBindings,\n matchStaticFinishFunction,\n indexMethodsByName,\n isEmittableCallable,\n renderStaticSignature,\n constructorMemberNames,\n renderStaticHead,\n renderPlainTypeMembers,\n staticMembers,\n type Callables,\n type InstanceMemberRenderer,\n type InstanceScope,\n};\n"]}
1
+ {"version":3,"file":"callables.js","sourceRoot":"","sources":["../../../src/store/gi/callables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,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ACjD,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAC3B,OAAgC,EACgB,EAAE;IAClD,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC5D,MAAM,YAAY,GAAgB,IAAI,GAAG,EAAE,CAAC;IAE5C,MAAM,OAAO,GAAa;QACtB,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,GAAG,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC;QAClD,GAAG,0BAA0B,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC;KAC1E,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;AACrC,CAAC,CAAC;AAEF,OAAO,EACH,6BAA6B,EAC7B,yBAAyB,EACzB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,aAAa,GAIhB,CAAC","sourcesContent":["import { toCamelIdentifier, uniqBy } from \"@gtkx/utils\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport type { JsDocSpec } from \"../../writer/doc.js\";\nimport { hasUnmarshalableParam } from \"../../analysis/param-capability.js\";\nimport { renderBlock } from \"../../writer/emit.js\";\nimport { matchAsyncFinish } from \"./async.js\";\nimport { callableDoc, callableSpec } from \"./callable-doc.js\";\nimport { renderFnExpression } from \"./function.js\";\nimport { gtypeMemberDeclaration } from \"./gtype-binding.js\";\nimport {\n finishCallExpression,\n memberName,\n methodExportName,\n renderMethodBody,\n renderMethodReturnType,\n renderMethodSignature,\n renderPromisifiedBody,\n renderPromisifiedSignature,\n} from \"./method.js\";\nimport { renderRuntimeOverride, runtimeOverrideRenames } from \"./runtime-override.js\";\n\ntype Callables = {\n constructors: GirFunction[];\n functions: GirFunction[];\n methods: GirFunction[];\n};\n\ntype InstanceScope = {\n ownerName: string;\n methodByName: Map<string, GirFunction>;\n statics: GirFunction[];\n};\n\ntype CallableMemberOptions = {\n resolveName: (callable: GirFunction) => string | undefined;\n isStatic: boolean;\n returnTypeOverride?: string | undefined;\n canUseRuntimeOverride?: boolean;\n};\n\ntype StaticEntryOptions = {\n resolveName: (callable: GirFunction) => string | undefined;\n ownerName: string;\n returnTypeOverride?: string | undefined;\n};\n\ntype ResolvedInstanceMember = {\n name: string;\n finishFn: GirFunction | undefined;\n};\n\ntype StaticMember = {\n callable: GirFunction;\n name: string;\n};\n\ntype InstanceMemberRenderer = (\n context: ModuleContext,\n callable: GirFunction,\n scope: InstanceScope,\n nameOverride?: string,\n) => string | undefined;\n\ntype PlainTypeMembersOptions = {\n context: ModuleContext;\n className: string;\n callables: Callables;\n hasGtype: boolean;\n};\n\nconst RUNTIME_OWNED_LIFETIME_METHODS: Set<string> = new Set([\n \"force_floating\",\n \"free\",\n \"ref\",\n \"ref_sink\",\n \"take_ref\",\n \"unref\",\n]);\n\nconst renderInstanceMethodSignature: InstanceMemberRenderer = instanceMemberRenderer(\n (context, callable, { name, finishFn }) =>\n `${memberDoc(context, callable, finishFn)}${memberSignatureText(context, callable, name, { finishFn })};`,\n);\n\nconst renderClassInstanceMember: InstanceMemberRenderer = instanceMemberRenderer(\n (context, callable, { name, finishFn }, scope) =>\n finishFn === undefined\n ? renderInstanceMethod(context, callable, name)\n : renderPromisifiedCallable(context, callable, finishFn, {\n name,\n isStatic: false,\n ownerName: scope.ownerName,\n }),\n);\n\nconst memberDoc = (context: ModuleContext, callable: GirFunction, finishFn: GirFunction | undefined): string =>\n callableDoc(context, callable, { finishFn });\n\nconst instanceMemberSpec = (context: ModuleContext, callable: GirFunction, scope: InstanceScope): JsDocSpec =>\n callableSpec(context, callable, { finishFn: matchFinishFunction(context, callable, scope) });\n\nconst instanceScope = (ownerName: string, callables: Callables): InstanceScope => ({\n ownerName,\n methodByName: indexMethodsByName(callables.methods),\n statics: [...callables.constructors, ...callables.functions],\n});\n\nconst dedupeCallables = (callables: GirFunction[]): GirFunction[] =>\n uniqBy(\n callables.filter(\n (callable): callable is GirFunction & { cIdentifier: string } => callable.cIdentifier !== undefined,\n ),\n (callable) => callable.cIdentifier,\n );\n\nconst getEmittableCIdentifier = (context: ModuleContext, callable: GirFunction): string | undefined =>\n isEmittableCallable(context, callable) ? callable.cIdentifier : undefined;\n\nconst renderBinding = (\n context: ModuleContext,\n callable: GirFunction,\n): { text: string; cIdentifier: string } | undefined => {\n const cIdentifier = getEmittableCIdentifier(context, callable);\n\n if (cIdentifier === undefined) {\n return undefined;\n }\n\n const expression = renderFnExpression(context, callable);\n\n if (expression === undefined) {\n return undefined;\n }\n\n return { text: `const ${toCamelIdentifier(cIdentifier)} = ${expression};`, cIdentifier };\n};\n\nconst generateBindings = (context: ModuleContext, callables: Callables): void => {\n const all = [...callables.constructors, ...callables.functions, ...callables.methods];\n\n for (const callable of all) {\n const binding = renderBinding(context, callable);\n\n if (binding !== undefined) {\n context.module.appendBinding(binding.text, binding.cIdentifier);\n }\n }\n};\n\nconst resolveCallableMember = (\n context: ModuleContext,\n callable: GirFunction,\n resolveName: (callable: GirFunction) => string | undefined,\n): { cIdentifier: string; name: string } | undefined => {\n const cIdentifier = getEmittableCIdentifier(context, callable);\n\n if (cIdentifier === undefined) {\n return undefined;\n }\n\n const name = resolveName(callable);\n\n if (name === undefined || !isEmittableMemberName(name)) {\n return undefined;\n }\n\n return { cIdentifier, name };\n};\n\nconst runtimeOverrideMember = (\n callable: GirFunction,\n name: string,\n doc: string,\n canUseRuntimeOverride: boolean | undefined,\n): string | undefined => {\n if (canUseRuntimeOverride !== true) {\n return undefined;\n }\n\n const override = renderRuntimeOverride(callable, name);\n\n return override === undefined ? undefined : `${doc}${override}`;\n};\n\nconst renderCallableMember = (\n context: ModuleContext,\n callable: GirFunction,\n options: CallableMemberOptions,\n): string | undefined => {\n const resolved = resolveCallableMember(context, callable, options.resolveName);\n\n if (resolved === undefined) {\n return undefined;\n }\n\n const { cIdentifier, name } = resolved;\n const renames = options.canUseRuntimeOverride === true ? runtimeOverrideRenames(callable) : undefined;\n const doc = callableDoc(context, callable, { renames });\n const override = runtimeOverrideMember(callable, name, doc, options.canUseRuntimeOverride);\n\n if (override !== undefined) {\n return override;\n }\n\n const signature = renderMethodSignature(context, callable);\n const returnType = options.returnTypeOverride ?? renderMethodReturnType(context, callable);\n\n const body = renderMethodBody(context, callable, {\n bindingExpression: toCamelIdentifier(cIdentifier),\n returnTypeOverride: options.returnTypeOverride,\n });\n\n const prefix = options.isStatic ? \"static \" : \"\";\n const header = `${prefix}${name}(${signature}): ${returnType}`;\n\n return `${doc}${renderBlock(header, body)}`;\n};\n\nconst renderStaticEntry = (\n context: ModuleContext,\n callable: GirFunction,\n siblings: GirFunction[],\n options: StaticEntryOptions,\n): string | undefined => {\n const finishFn = matchStaticFinishFunction(context, callable, siblings);\n\n if (finishFn !== undefined) {\n const name = options.resolveName(callable);\n\n if (name === undefined || !isEmittableMemberName(name)) {\n return undefined;\n }\n\n return renderPromisifiedCallable(context, callable, finishFn, {\n name,\n isStatic: true,\n ownerName: options.ownerName,\n });\n }\n\n return renderCallableMember(context, callable, {\n resolveName: options.resolveName,\n isStatic: true,\n returnTypeOverride: options.returnTypeOverride,\n });\n};\n\nconst renderInstanceMethod = (\n context: ModuleContext,\n callable: GirFunction,\n nameOverride?: string,\n): string | undefined =>\n renderCallableMember(context, callable, {\n resolveName: (member) => nameOverride ?? methodExportName(member),\n isStatic: false,\n canUseRuntimeOverride: true,\n });\n\nconst isEmittableMemberName = (name: string): boolean => name !== \"constructor\" && name.length > 0;\n\nconst resolveInstanceMember = (\n context: ModuleContext,\n callable: GirFunction,\n scope: InstanceScope,\n nameOverride?: string,\n): ResolvedInstanceMember | undefined => {\n if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const name = nameOverride ?? methodExportName(callable);\n\n if (!isEmittableMemberName(name)) {\n return undefined;\n }\n\n const finishFn = matchFinishFunction(context, callable, scope);\n\n if (finishFn !== undefined && !isEmittableCallable(context, finishFn)) {\n return undefined;\n }\n\n return { name, finishFn };\n};\n\nfunction instanceMemberRenderer(\n render: (\n context: ModuleContext,\n callable: GirFunction,\n member: ResolvedInstanceMember,\n scope: InstanceScope,\n ) => string | undefined,\n): InstanceMemberRenderer {\n return (context, callable, scope, nameOverride) => {\n const member = resolveInstanceMember(context, callable, scope, nameOverride);\n\n return member === undefined ? undefined : render(context, callable, member, scope);\n };\n}\n\nconst memberSignatureText = (\n context: ModuleContext,\n callable: GirFunction,\n name: string,\n options: { finishFn: GirFunction | undefined; returnTypeOverride?: string | undefined },\n): string => {\n const promisified =\n options.finishFn === undefined ? undefined : renderPromisifiedSignature(context, callable, options.finishFn);\n\n const signature = promisified?.signature ?? renderMethodSignature(context, callable);\n\n const returnType =\n promisified?.returnType ?? options.returnTypeOverride ?? renderMethodReturnType(context, callable);\n\n return `${name}(${signature}): ${returnType}`;\n};\n\nconst matchFinishFunction = (\n context: ModuleContext,\n callable: GirFunction,\n scope: InstanceScope,\n): GirFunction | undefined =>\n matchAsyncFinish(context.library, callable, [...scope.methodByName.values(), ...scope.statics]);\n\nconst matchStaticFinishFunction = (\n context: ModuleContext,\n callable: GirFunction,\n siblings: GirFunction[],\n): GirFunction | undefined => {\n if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const finishFn = matchAsyncFinish(context.library, callable, siblings);\n\n if (finishFn === undefined || !isEmittableCallable(context, finishFn)) {\n return undefined;\n }\n\n return finishFn;\n};\n\nconst renderPromisifiedCallable = (\n context: ModuleContext,\n callable: GirFunction,\n finishFn: GirFunction,\n member: { name: string; isStatic: boolean; ownerName: string },\n): string | undefined => {\n const cIdentifier = callable.cIdentifier;\n\n if (cIdentifier === undefined) {\n return undefined;\n }\n\n const { signature, returnType } = renderPromisifiedSignature(context, callable, finishFn);\n\n const body = renderPromisifiedBody(\n context,\n callable,\n finishCallExpression(callable, finishFn, member.ownerName),\n toCamelIdentifier(cIdentifier),\n );\n\n const prefix = member.isStatic ? \"static \" : \"\";\n const header = `${prefix}${member.name}(${signature}): ${returnType}`;\n\n return `${memberDoc(context, callable, finishFn)}${renderBlock(header, body)}`;\n};\n\nconst indexMethodsByName = (methods: GirFunction[]): Map<string, GirFunction> => {\n const map: Map<string, GirFunction> = new Map();\n\n for (const callable of methods) {\n map.set(callable.name, callable);\n }\n\n return map;\n};\n\nconst isEmittableCallable = (context: ModuleContext, callable: GirFunction): boolean =>\n callable.introspectable &&\n callable.shadowedBy === undefined &&\n callable.cIdentifier !== undefined &&\n !RUNTIME_OWNED_LIFETIME_METHODS.has(callable.name) &&\n !hasUnmarshalableParam(context, callable);\n\nconst constructorMemberName = (girName: string): string | undefined => {\n const camel = memberName(girName);\n\n return isEmittableMemberName(camel) ? camel : undefined;\n};\n\nconst renderStaticSignature = (\n context: ModuleContext,\n callable: GirFunction,\n options?: { returnTypeOverride?: string | undefined; siblings?: GirFunction[] | undefined },\n): { name: string; signature: string } | undefined => {\n if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const name = constructorMemberName(callable.name);\n\n if (name === undefined) {\n return undefined;\n }\n\n const finishFn =\n options?.siblings === undefined ? undefined : matchStaticFinishFunction(context, callable, options.siblings);\n\n return {\n name,\n signature: memberSignatureText(context, callable, name, {\n finishFn,\n returnTypeOverride: options?.returnTypeOverride,\n }),\n };\n};\n\nconst staticMemberName = (\n context: ModuleContext,\n callable: GirFunction,\n resolveName: (girName: string) => string | undefined,\n): string | undefined => {\n if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const name = resolveName(callable.name);\n\n return name !== undefined && isEmittableMemberName(name) ? name : undefined;\n};\n\nconst collectStaticMembers = (\n context: ModuleContext,\n group: GirFunction[],\n resolveName: (girName: string) => string | undefined,\n): StaticMember[] => {\n const members: StaticMember[] = [];\n\n for (const callable of group) {\n const name = staticMemberName(context, callable, resolveName);\n\n if (name !== undefined) {\n members.push({ callable, name });\n }\n }\n\n return members;\n};\n\nconst staticMembers = (context: ModuleContext, callables: Callables): StaticMember[] => [\n ...collectStaticMembers(context, callables.constructors, memberName),\n ...collectStaticMembers(context, callables.functions, memberName),\n];\n\nconst collectStaticEntries = (\n context: ModuleContext,\n group: GirFunction[],\n siblings: GirFunction[],\n options: StaticEntryOptions,\n): string[] => {\n const blocks: string[] = [];\n\n for (const callable of group) {\n const block = renderStaticEntry(context, callable, siblings, options);\n\n if (block !== undefined) {\n blocks.push(block);\n }\n }\n\n return blocks;\n};\n\nconst renderStaticHead = (context: ModuleContext, callables: Callables, ownerClassName: string): string[] => {\n const siblings = [...callables.constructors, ...callables.functions];\n\n return [\n ...collectStaticEntries(context, callables.constructors, siblings, {\n resolveName: (member) => constructorMemberName(member.name),\n ownerName: ownerClassName,\n returnTypeOverride: ownerClassName,\n }),\n ...collectStaticEntries(context, callables.functions, siblings, {\n resolveName: (member) => memberName(member.name),\n ownerName: ownerClassName,\n }),\n ];\n};\n\nconst renderPlainInstanceMethods = (\n context: ModuleContext,\n methods: GirFunction[],\n claimedNames: Set<string>,\n): string[] => {\n const blocks: string[] = [];\n\n for (const callable of methods) {\n const block = renderInstanceMethod(context, callable);\n\n if (block === undefined) {\n continue;\n }\n\n blocks.push(block);\n claimedNames.add(methodExportName(callable));\n }\n\n return blocks;\n};\n\nconst renderPlainTypeMembers = (\n options: PlainTypeMembersOptions,\n): { members: string[]; claimedNames: Set<string> } => {\n const { context, className, callables, hasGtype } = options;\n const claimedNames: Set<string> = new Set();\n\n const members: string[] = [\n ...(hasGtype ? [gtypeMemberDeclaration(context)] : []),\n ...renderStaticHead(context, callables, className),\n ...renderPlainInstanceMethods(context, callables.methods, claimedNames),\n ];\n\n return { members, claimedNames };\n};\n\nexport {\n renderInstanceMethodSignature,\n renderClassInstanceMember,\n instanceMemberSpec,\n instanceScope,\n dedupeCallables,\n generateBindings,\n matchStaticFinishFunction,\n isEmittableCallable,\n renderStaticSignature,\n renderStaticHead,\n renderPlainTypeMembers,\n staticMembers,\n type Callables,\n type InstanceMemberRenderer,\n type InstanceScope,\n};\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;AA2E7D,QAAA,MAAM,aAAa,GAAI,SAAS,aAAa,EAAE,OAAO,QAAQ,KAAG,IAsChE,CAAC;AA2PF,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;AA6E7D,QAAA,MAAM,aAAa,GAAI,SAAS,aAAa,EAAE,OAAO,QAAQ,KAAG,IAsChE,CAAC;AAiTF,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import { sanitizeTypeIdentifier, toCamelIdentifier } from "@gtkx/utils";
2
2
  import { ancestorClassMethodNames, collectInheritedMethods, collectInheritedPropertyTypes, collectInterfaceMergeOmissions, conflictRename, } from "../../analysis/inheritance.js";
3
- import { claimInterfaceMembers, inheritedMembers, interfaceConflicts, omittedTypeRef, } from "../../analysis/interface-conflicts.js";
3
+ import { areCallablesAssignable, claimInterfaceMembers, inheritedMembers, interfaceConflicts, omittedKeys, omittedTypeRef, } from "../../analysis/interface-conflicts.js";
4
4
  import { ancestorChain, getParentRef } from "../../gir/ancestry.js";
5
5
  import { isEmittableEntity } from "../../gir/emittable.js";
6
6
  import { indentMembers } from "../../writer/emit.js";
7
- import { constructorMemberNames, dedupeCallables, generateBindings, instanceScope, renderClassInstanceMember, renderStaticHead, } from "./callables.js";
7
+ import { dedupeCallables, generateBindings, instanceScope, renderClassInstanceMember, renderStaticHead, staticMembers, } from "./callables.js";
8
8
  import { renderClassConstructor, renderConstructorPropsInterface } from "./constructor-props.js";
9
9
  import { getDoc } from "./doc-spec.js";
10
10
  import { gtypeMemberDeclaration, renderSourceGtype } from "./gtype-binding.js";
@@ -26,7 +26,7 @@ const generateClass = (context, klass) => {
26
26
  };
27
27
  generateBindings(context, callables);
28
28
  const parentExpression = resolveParent(context, klass);
29
- const extendsClause = renderExtendsClause(context, parentExpression, callables);
29
+ const extendsClause = renderExtendsClause(context, parentExpression, klass, callables);
30
30
  const implemented = resolveImplementedRefs(context, klass);
31
31
  const typeRefs = implemented.map((ref) => omittedTypeRef(ref.typeRef, ref.conflicts));
32
32
  const implementsClause = typeRefs.length === 0 ? "" : ` implements ${typeRefs.join(", ")}`;
@@ -97,7 +97,6 @@ const renderClassMembers = (context, klass, callables, hasParent) => {
97
97
  context,
98
98
  property,
99
99
  claimedNames,
100
- methodByName: scope.methodByName,
101
100
  inheritedTypes,
102
101
  inheritedNames,
103
102
  });
@@ -209,17 +208,57 @@ const resolveImplementedRefs = (context, klass) => {
209
208
  }
210
209
  return refs;
211
210
  };
212
- const renderExtendsClause = (context, parentExpression, callables) => {
211
+ const classCallables = (klass) => ({
212
+ constructors: klass.constructors,
213
+ functions: klass.functions,
214
+ methods: klass.methods,
215
+ });
216
+ const resolveParentClass = (context, klass) => {
217
+ const parent = getParentRef(klass);
218
+ if (parent === undefined) {
219
+ return undefined;
220
+ }
221
+ const resolved = context.library.resolveType(parent.namespaceName ?? context.namespace.name, parent.typeName);
222
+ return resolved?.kind === "class" ? { klass: resolved.value, namespaceName: resolved.namespace.name } : undefined;
223
+ };
224
+ const addAncestorStatics = (context, klass, table) => {
225
+ const members = staticMembers(context, classCallables(klass));
226
+ for (const member of members) {
227
+ if (!table.has(member.name)) {
228
+ table.set(member.name, member.callable);
229
+ }
230
+ }
231
+ };
232
+ const inheritedStatics = (context, klass) => {
233
+ const table = new Map();
234
+ const parent = resolveParentClass(context, klass);
235
+ if (parent === undefined) {
236
+ return table;
237
+ }
238
+ for (const ancestor of ancestorChain(context.library, parent.klass, parent.namespaceName)) {
239
+ addAncestorStatics(context, ancestor.klass, table);
240
+ }
241
+ return table;
242
+ };
243
+ const shadowedStaticNames = (context, klass, callables) => {
244
+ const inherited = inheritedStatics(context, klass);
245
+ return staticMembers(context, callables)
246
+ .filter((member) => {
247
+ const shadowed = inherited.get(member.name);
248
+ return shadowed !== undefined && !areCallablesAssignable(context.library, member.callable, shadowed);
249
+ })
250
+ .map((member) => member.name);
251
+ };
252
+ const renderExtendsClause = (context, parentExpression, klass, callables) => {
213
253
  if (parentExpression === undefined) {
214
254
  return "";
215
255
  }
216
- const constructorNames = constructorMemberNames(context, callables.constructors);
217
- if (constructorNames.length === 0) {
256
+ const staticNames = shadowedStaticNames(context, klass, callables);
257
+ if (staticNames.length === 0) {
218
258
  return ` extends ${parentExpression}`;
219
259
  }
220
260
  context.addRuntimeTypeImport("StaticBase");
221
- const omitted = constructorNames.map((name) => JSON.stringify(name)).join(" | ");
222
- return ` extends (${parentExpression} as StaticBase<typeof ${parentExpression}, ${omitted}>)`;
261
+ return ` extends (${parentExpression} as StaticBase<typeof ${parentExpression}, ${omittedKeys(staticNames)}>)`;
223
262
  };
224
263
  const resolveParent = (context, klass) => {
225
264
  const parent = getParentRef(klass);