@gtkx/codegen 1.0.0-rc.3 → 1.0.0-rc.4
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.
- package/README.md +4 -5
- package/dist/analysis/descriptor-render.d.ts +1 -3
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +14 -37
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +6 -6
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js +7 -7
- package/dist/analysis/descriptor.js.map +1 -1
- package/dist/analysis/param-structure.d.ts +2 -2
- package/dist/analysis/param-structure.d.ts.map +1 -1
- package/dist/analysis/param-structure.js +5 -7
- package/dist/analysis/param-structure.js.map +1 -1
- package/dist/analysis/ts-type.d.ts +1 -1
- package/dist/analysis/ts-type.d.ts.map +1 -1
- package/dist/analysis/ts-type.js +3 -5
- package/dist/analysis/ts-type.js.map +1 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +2 -1
- package/dist/compile.js.map +1 -1
- package/dist/docs/api-reference.d.ts +77 -1
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +62 -0
- package/dist/docs/api-reference.js.map +1 -1
- package/dist/docs/pipeline.d.ts +4 -4
- package/dist/docs/pipeline.d.ts.map +1 -1
- package/dist/docs/pipeline.js +4 -4
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/docs/render.js +6 -6
- package/dist/docs/render.js.map +1 -1
- package/dist/docs/symbol-page.d.ts +5 -0
- package/dist/docs/symbol-page.d.ts.map +1 -1
- package/dist/docs/symbol-page.js +2 -2
- package/dist/docs/symbol-page.js.map +1 -1
- package/dist/fingerprint.d.ts +2 -5
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +6 -8
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts +3 -11
- package/dist/gi.d.ts.map +1 -1
- package/dist/gi.js +0 -7
- package/dist/gi.js.map +1 -1
- package/dist/gir/field.d.ts +0 -1
- package/dist/gir/field.d.ts.map +1 -1
- package/dist/gir/field.js +0 -3
- package/dist/gir/field.js.map +1 -1
- package/dist/gir/gir-path.d.ts +7 -0
- package/dist/gir/gir-path.d.ts.map +1 -1
- package/dist/gir/gir-path.js +7 -0
- package/dist/gir/gir-path.js.map +1 -1
- package/dist/gir/libraries.d.ts +13 -0
- package/dist/gir/libraries.d.ts.map +1 -1
- package/dist/gir/libraries.js +12 -0
- package/dist/gir/libraries.js.map +1 -1
- package/dist/gir/parameter.d.ts.map +1 -1
- package/dist/gir/parameter.js +0 -4
- package/dist/gir/parameter.js.map +1 -1
- package/dist/gir/size.d.ts.map +1 -1
- package/dist/gir/size.js +0 -3
- package/dist/gir/size.js.map +1 -1
- package/dist/gir/type-id.d.ts +1 -1
- package/dist/gir/type-id.d.ts.map +1 -1
- package/dist/gir/type-id.js +1 -3
- package/dist/gir/type-id.js.map +1 -1
- package/dist/gir/type-ref.js +1 -1
- package/dist/gir/type-ref.js.map +1 -1
- package/dist/index.d.ts +18 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +3 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +3 -0
- package/dist/internal.js.map +1 -0
- package/dist/jsx.d.ts +7 -12
- package/dist/jsx.d.ts.map +1 -1
- package/dist/jsx.js +18 -19
- package/dist/jsx.js.map +1 -1
- package/dist/khronos/args.d.ts.map +1 -1
- package/dist/khronos/args.js +1 -1
- package/dist/khronos/args.js.map +1 -1
- package/dist/khronos/pipeline.js +1 -1
- package/dist/khronos/pipeline.js.map +1 -1
- package/dist/khronos/plan.d.ts +2 -2
- package/dist/khronos/plan.d.ts.map +1 -1
- package/dist/khronos/plan.js +6 -6
- package/dist/khronos/plan.js.map +1 -1
- package/dist/react/element-config.d.ts +17 -11
- package/dist/react/element-config.d.ts.map +1 -1
- package/dist/react/element-config.js +22 -15
- package/dist/react/element-config.js.map +1 -1
- package/dist/runner.d.ts +35 -17
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +19 -20
- package/dist/runner.js.map +1 -1
- package/dist/store/compile-store.d.ts +1 -2
- package/dist/store/compile-store.d.ts.map +1 -1
- package/dist/store/compile-store.js +2 -2
- package/dist/store/compile-store.js.map +1 -1
- package/dist/store/gi/callables.js +4 -4
- package/dist/store/gi/callables.js.map +1 -1
- package/dist/store/gi/constant.d.ts.map +1 -1
- package/dist/store/gi/constant.js +0 -2
- package/dist/store/gi/constant.js.map +1 -1
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +1 -5
- package/dist/store/gi/function.js.map +1 -1
- package/dist/store/gi/method.d.ts.map +1 -1
- package/dist/store/gi/method.js +25 -23
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/property-accessor.d.ts +1 -1
- package/dist/store/gi/property-accessor.d.ts.map +1 -1
- package/dist/store/gi/property-accessor.js +5 -7
- package/dist/store/gi/property-accessor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +1 -1
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +3 -9
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record-layout.d.ts.map +1 -1
- package/dist/store/gi/record-layout.js +0 -4
- package/dist/store/gi/record-layout.js.map +1 -1
- package/dist/store/gi/return-wrap.d.ts +1 -1
- package/dist/store/gi/return-wrap.d.ts.map +1 -1
- package/dist/store/gi/return-wrap.js +4 -4
- package/dist/store/gi/return-wrap.js.map +1 -1
- package/dist/store/gi/signal.d.ts.map +1 -1
- package/dist/store/gi/signal.js +13 -16
- package/dist/store/gi/signal.js.map +1 -1
- package/dist/store/gi/value-marshalable.d.ts +0 -8
- package/dist/store/gi/value-marshalable.d.ts.map +1 -1
- package/dist/store/gi/value-marshalable.js +0 -9
- package/dist/store/gi/value-marshalable.js.map +1 -1
- package/dist/store/gi-store.d.ts +2 -3
- package/dist/store/gi-store.d.ts.map +1 -1
- package/dist/store/gi-store.js.map +1 -1
- package/dist/store/jsx/element-components.d.ts +0 -2
- package/dist/store/jsx/element-components.d.ts.map +1 -1
- package/dist/store/jsx/element-components.js +0 -4
- package/dist/store/jsx/element-components.js.map +1 -1
- package/dist/store/jsx/element-prop-imports.d.ts +2 -3
- package/dist/store/jsx/element-prop-imports.d.ts.map +1 -1
- package/dist/store/jsx/element-prop-imports.js +0 -2
- package/dist/store/jsx/element-prop-imports.js.map +1 -1
- package/dist/store/jsx/element-prop-types.d.ts +0 -1
- package/dist/store/jsx/element-prop-types.d.ts.map +1 -1
- package/dist/store/jsx/element-prop-types.js +0 -1
- package/dist/store/jsx/element-prop-types.js.map +1 -1
- package/dist/store/jsx/generated-elements.d.ts +29 -0
- package/dist/store/jsx/generated-elements.d.ts.map +1 -0
- package/dist/store/jsx/generated-elements.js +30 -0
- package/dist/store/jsx/generated-elements.js.map +1 -0
- package/dist/store/jsx/jsx.js +6 -6
- package/dist/store/jsx/jsx.js.map +1 -1
- package/dist/store/jsx/metadata.js +7 -7
- package/dist/store/jsx/metadata.js.map +1 -1
- package/dist/store/jsx/omitted-props.d.ts +2 -4
- package/dist/store/jsx/omitted-props.d.ts.map +1 -1
- package/dist/store/jsx/omitted-props.js +2 -4
- package/dist/store/jsx/omitted-props.js.map +1 -1
- package/dist/store/jsx/pipeline.d.ts +3 -1
- package/dist/store/jsx/pipeline.d.ts.map +1 -1
- package/dist/store/jsx/pipeline.js +3 -2
- package/dist/store/jsx/pipeline.js.map +1 -1
- package/dist/store/jsx/props.js +2 -2
- package/dist/store/jsx/props.js.map +1 -1
- package/dist/store/jsx-store.d.ts +2 -3
- package/dist/store/jsx-store.d.ts.map +1 -1
- package/dist/store/jsx-store.js +3 -3
- package/dist/store/jsx-store.js.map +1 -1
- package/dist/store/resolve-store.d.ts +28 -0
- package/dist/store/resolve-store.d.ts.map +1 -0
- package/dist/store/resolve-store.js +65 -0
- package/dist/store/resolve-store.js.map +1 -0
- package/dist/store/store-fs.d.ts +5 -1
- package/dist/store/store-fs.d.ts.map +1 -1
- package/dist/store/store-fs.js +6 -4
- package/dist/store/store-fs.js.map +1 -1
- package/overrides/gobject/object.ts.ejs +8 -8
- package/package.json +6 -10
- package/src/analysis/descriptor-render.ts +20 -45
- package/src/analysis/descriptor.ts +13 -13
- package/src/analysis/param-structure.ts +8 -10
- package/src/analysis/ts-type.ts +4 -6
- package/src/compile.ts +2 -1
- package/src/docs/api-reference.ts +127 -4
- package/src/docs/pipeline.ts +8 -8
- package/src/docs/render.ts +7 -7
- package/src/docs/symbol-page.ts +7 -2
- package/src/fingerprint.ts +8 -13
- package/src/gi.ts +4 -11
- package/src/gir/field.ts +0 -4
- package/src/gir/gir-path.ts +7 -0
- package/src/gir/libraries.ts +13 -0
- package/src/gir/parameter.ts +0 -4
- package/src/gir/size.ts +0 -3
- package/src/gir/type-id.ts +2 -4
- package/src/gir/type-ref.ts +1 -1
- package/src/index.ts +18 -16
- package/src/internal.ts +2 -0
- package/src/jsx.ts +26 -26
- package/src/khronos/args.ts +1 -1
- package/src/khronos/pipeline.ts +1 -1
- package/src/khronos/plan.ts +8 -8
- package/src/react/element-config.ts +22 -19
- package/src/runner.ts +57 -39
- package/src/store/compile-store.ts +3 -4
- package/src/store/gi/callables.ts +5 -5
- package/src/store/gi/constant.ts +0 -2
- package/src/store/gi/function.ts +1 -5
- package/src/store/gi/method.ts +30 -28
- package/src/store/gi/property-accessor.ts +6 -8
- package/src/store/gi/record-field-accessor.ts +4 -10
- package/src/store/gi/record-layout.ts +0 -4
- package/src/store/gi/return-wrap.ts +5 -5
- package/src/store/gi/signal.ts +17 -17
- package/src/store/gi/value-marshalable.ts +0 -9
- package/src/store/gi-store.ts +2 -4
- package/src/store/jsx/element-components.ts +0 -6
- package/src/store/jsx/element-prop-imports.ts +7 -4
- package/src/store/jsx/element-prop-types.ts +0 -1
- package/src/store/jsx/generated-elements.ts +60 -0
- package/src/store/jsx/jsx.ts +7 -7
- package/src/store/jsx/metadata.ts +8 -8
- package/src/store/jsx/omitted-props.ts +2 -4
- package/src/store/jsx/pipeline.ts +5 -3
- package/src/store/jsx/props.ts +2 -2
- package/src/store/jsx-store.ts +5 -7
- package/src/store/resolve-store.ts +100 -0
- package/src/store/store-fs.ts +12 -5
package/dist/runner.js.map
CHANGED
|
@@ -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;AAIjC,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;AAuCnF;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,OAA6B,EAAgC,EAAE;IACrF,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5E,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;IAExC,OAAO;QACH,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;QAC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IAC9E,CAAC;IAED,OAAO,YAAY,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC,CAAC;AACvG,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,EAAE,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACvE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,CAAC;IACvE,CAAC;IAED,OAAO,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAA8E,CAAC","sourcesContent":["import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { GiStoreOptions } from \"./store/gi-store.js\";\nimport type { JsxStoreOptions } from \"./store/jsx-store.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\";\n\ntype ModuleExport = { module: string; export: string };\n\ntype GlCodegenOptions = {\n registryPath: string;\n overrideExports: Set<string>;\n outputDir: string;\n resolveFrom: string;\n};\n\ntype CodegenRunnerOptions = {\n libraries?: string[];\n girPath?: string[];\n gi?: GiStoreOptions;\n jsx?: JsxStoreOptions | undefined;\n reactSubexports?: string[];\n userComponents?: Record<string, ModuleExport>;\n userLazyElements?: string[];\n userProps?: Record<string, ModuleExport>;\n userOmitProps?: OmittedProps;\n gl?: GlCodegenOptions;\n force?: boolean;\n};\n\ntype CodegenRunnerResult = {\n regenerated: boolean;\n namespaces: number;\n intrinsicElements: number;\n duration: number;\n gl?: GlGenerationReport | undefined;\n};\n\ntype StoreResult = {\n regenerated: boolean;\n namespaces: number;\n intrinsicElements: number;\n};\n\n/**\n * Runs the `@gtkx` code generators, producing the `@gtkx/gi`, `@gtkx/jsx`, and `@gtkx/gl` bindings from the\n * configured GObject-introspection libraries and OpenGL registry. The gi store is regenerated only when its\n * fingerprint is stale unless `options.force` is set, then the jsx store is regenerated when the gi store or\n * the React element config changed; the OpenGL modules are regenerated whenever `options.gl` is provided.\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 */\nconst runCodegen = async (options: CodegenRunnerOptions): Promise<CodegenRunnerResult> => {\n const start = Date.now();\n const gl = options.gl === undefined ? undefined : emitGlModules(options.gl);\n const store = await emitStores(options);\n\n return {\n regenerated: store.regenerated,\n namespaces: store.namespaces,\n intrinsicElements: store.intrinsicElements,\n duration: Date.now() - start,\n gl,\n };\n};\n\nconst emitGlModules = (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 userOmitProps: OmittedProps;\n} => ({\n reactSubexports: options.reactSubexports ?? [],\n userComponents: options.userComponents ?? {},\n userLazyElements: options.userLazyElements ?? [],\n userProps: options.userProps ?? {},\n userOmitProps: options.userOmitProps ?? {},\n});\n\nconst emitJsxStore = async (input: {\n options: CodegenRunnerOptions;\n jsx: JsxStoreOptions;\n gi: GiStoreOptions;\n loadLibrary: () => Library;\n giRegenerated: boolean;\n namespaces: number;\n}): Promise<StoreResult> => {\n const { options, jsx, gi, loadLibrary, giRegenerated, 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 giRegenerated,\n force: options.force === true,\n });\n\n return {\n regenerated: giRegenerated || jsxResult.regenerated,\n namespaces,\n intrinsicElements: jsxResult.intrinsicElementCount,\n };\n};\n\nconst emitStoresWithConfig = async (config: {\n options: CodegenRunnerOptions;\n gi: GiStoreOptions;\n jsx: JsxStoreOptions | 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.force === 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 { regenerated: isGiRegenerated, namespaces, intrinsicElements: 0 };\n }\n\n return emitJsxStore({ options, jsx, gi, loadLibrary, giRegenerated: isGiRegenerated, namespaces });\n};\n\nconst emitStores = async (options: CodegenRunnerOptions): Promise<StoreResult> => {\n const { gi, jsx, libraries, girPath } = options;\n\n if (gi === undefined || libraries === undefined || girPath === undefined) {\n return { regenerated: false, namespaces: 0, intrinsicElements: 0 };\n }\n\n return emitStoresWithConfig({ options, gi, jsx, libraries, girPath });\n};\n\nexport { runCodegen, type GlCodegenOptions, type CodegenRunnerOptions, type CodegenRunnerResult };\n"]}
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],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,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 { OmittedProps } from \"./store/jsx/omitted-props.js\";\nimport type { StoreOptions } from \"./store/store-fs.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\";\n\n/** A named export in a module, referenced as plain data (the module is never imported at runtime). */\ntype ModuleExport = {\n /** Specifier the export is imported from. */\n module: string;\n /** Identifier the module exports it under. */\n export: string;\n};\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 * @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 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 return emitStoresWithConfig({ options, gi, jsx, libraries, girPath });\n};\n\nexport { runCodegen, runGlCodegen, type CodegenRunnerOptions, type CodegenRunnerResult };\n"]}
|
|
@@ -3,8 +3,7 @@ type CompileStoreParams = {
|
|
|
3
3
|
storeDir: string;
|
|
4
4
|
files: SourceModule[];
|
|
5
5
|
packageName: string;
|
|
6
|
-
|
|
7
|
-
configEnv?: boolean;
|
|
6
|
+
requiresEnvReference?: boolean;
|
|
8
7
|
};
|
|
9
8
|
declare const compileStore: (params: CompileStoreParams) => void;
|
|
10
9
|
export { compileStore, type CompileStoreParams };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-store.d.ts","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAElE,KAAK,kBAAkB,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,
|
|
1
|
+
{"version":3,"file":"compile-store.d.ts","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAElE,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,IAqBlD,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,CAAC"}
|
|
@@ -18,13 +18,13 @@ const writeEnvReference = (storeDir) => {
|
|
|
18
18
|
};
|
|
19
19
|
const compileStore = (params) => {
|
|
20
20
|
const fileNames = params.files.map((file) => file.fileName);
|
|
21
|
-
const removeEnvReference = params.
|
|
21
|
+
const removeEnvReference = params.requiresEnvReference === true
|
|
22
22
|
? writeEnvReference(params.storeDir)
|
|
23
23
|
: () => undefined;
|
|
24
24
|
try {
|
|
25
25
|
compileProject({
|
|
26
26
|
projectDir: params.storeDir,
|
|
27
|
-
fileNames: params.
|
|
27
|
+
fileNames: params.requiresEnvReference === true ? [ENV_REFERENCE_FILE, ...fileNames] : fileNames,
|
|
28
28
|
compilerOptions: EMIT_OPTIONS,
|
|
29
29
|
label: `the generated ${params.packageName} store`,
|
|
30
30
|
});
|
|
@@ -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,EAAqB,MAAM,eAAe,CAAC;
|
|
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,EAAqB,MAAM,eAAe,CAAC;AASlE,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,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAE5D,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,IAAI,CAAC;QACD,cAAc,CAAC;YACX,UAAU,EAAE,MAAM,CAAC,QAAQ;YAC3B,SAAS,EAAE,MAAM,CAAC,oBAAoB,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,kBAAkB,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS;YAChG,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,EAA2B,CAAC","sourcesContent":["import { rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { compileProject, 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 fileNames = params.files.map((file) => file.fileName);\n\n const removeEnvReference = params.requiresEnvReference === true\n ? writeEnvReference(params.storeDir)\n : (): void => undefined;\n\n try {\n compileProject({\n projectDir: params.storeDir,\n fileNames: params.requiresEnvReference === true ? [ENV_REFERENCE_FILE, ...fileNames] : fileNames,\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, type CompileStoreParams };\n"]}
|
|
@@ -61,8 +61,8 @@ const resolveCallableMember = (context, callable, resolveName) => {
|
|
|
61
61
|
}
|
|
62
62
|
return { cIdentifier, name };
|
|
63
63
|
};
|
|
64
|
-
const runtimeOverrideMember = (callable, name, doc,
|
|
65
|
-
if (
|
|
64
|
+
const runtimeOverrideMember = (callable, name, doc, canUseRuntimeOverride) => {
|
|
65
|
+
if (canUseRuntimeOverride !== true) {
|
|
66
66
|
return undefined;
|
|
67
67
|
}
|
|
68
68
|
const override = renderRuntimeOverride(callable, name);
|
|
@@ -75,7 +75,7 @@ const renderCallableMember = (context, callable, options) => {
|
|
|
75
75
|
}
|
|
76
76
|
const { cIdentifier, name } = resolved;
|
|
77
77
|
const doc = renderJsDoc(callable.doc);
|
|
78
|
-
const override = runtimeOverrideMember(callable, name, doc, options.
|
|
78
|
+
const override = runtimeOverrideMember(callable, name, doc, options.canUseRuntimeOverride);
|
|
79
79
|
if (override !== undefined) {
|
|
80
80
|
return override;
|
|
81
81
|
}
|
|
@@ -111,7 +111,7 @@ const renderStaticEntry = (context, callable, siblings, options) => {
|
|
|
111
111
|
const renderInstanceMethod = (context, callable, nameOverride) => renderCallableMember(context, callable, {
|
|
112
112
|
resolveName: (member) => nameOverride ?? methodExportName(member),
|
|
113
113
|
isStatic: false,
|
|
114
|
-
|
|
114
|
+
canUseRuntimeOverride: true,
|
|
115
115
|
});
|
|
116
116
|
const resolveInstanceMember = (context, callable, scope, nameOverride) => {
|
|
117
117
|
if (!isEmittableCallable(context, callable)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callables.js","sourceRoot":"","sources":["../../../src/store/gi/callables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EACH,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,GAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AA8C9D,MAAM,6BAA6B,GAA2B,sBAAsB,CAChF,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CACtC,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,mBAAmB,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,GAAG,CACnG,CAAC;AAEF,MAAM,yBAAyB,GAA2B,sBAAsB,CAC5E,CAAC,OAAO,EAAE,QAAQ,EAAE,EA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CamelIdentifier, uniqBy } from \"@gtkx/utils\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { hasCallerAllocatedArrayLength } from \"../../analysis/param-structure.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\nimport { renderBlock } from \"../../writer/emit.js\";\nimport { matchAsyncFinish } from \"./async.js\";\nimport { renderFnExpression } from \"./function.js\";\nimport { gtypeMemberDeclaration } from \"./gtype-binding.js\";\nimport {\n finishCallExpression,\n methodExportName,\n renderMethodBody,\n renderMethodReturnType,\n renderMethodSignature,\n renderPromisifiedBody,\n renderPromisifiedSignature,\n} from \"./method.js\";\nimport { renderRuntimeOverride } 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 allowRuntimeOverride?: 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 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 `${renderJsDoc(callable.doc)}${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 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 renderBinding = (\n context: ModuleContext,\n callable: GirFunction,\n): { text: string; cIdentifier: string } | undefined => {\n if (!callable.introspectable) {\n return undefined;\n }\n\n if (callable.shadowedBy !== undefined) {\n return undefined;\n }\n\n const cIdentifier = callable.cIdentifier;\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 if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const cIdentifier = callable.cIdentifier;\n\n if (cIdentifier === undefined) {\n return undefined;\n }\n\n const name = resolveName(callable);\n\n if (name === undefined || name === \"constructor\") {\n return undefined;\n }\n\n return { cIdentifier, name };\n};\n\nconst runtimeOverrideMember = (\n callable: GirFunction,\n name: string,\n doc: string,\n allow: boolean | undefined,\n): string | undefined => {\n if (allow !== 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 doc = renderJsDoc(callable.doc);\n const override = runtimeOverrideMember(callable, name, doc, options.allowRuntimeOverride);\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 || name === \"constructor\") {\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 allowRuntimeOverride: true,\n });\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 (name === \"constructor\") {\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 `${renderJsDoc(callable.doc)}${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 !hasCallerAllocatedArrayLength(context.library, callable);\n\nconst constructorMemberName = (girName: string): string | undefined => {\n const camel = camelCase(girName);\n\n if (camel === \"constructor\") {\n return undefined;\n }\n\n return camel;\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 classConstructorMemberNames = (context: ModuleContext, callables: Callables): string[] => {\n const names: string[] = [];\n\n for (const callable of callables.constructors) {\n if (!isEmittableCallable(context, callable)) {\n continue;\n }\n\n const member = constructorMemberName(callable.name);\n\n if (member !== undefined) {\n names.push(member);\n }\n }\n\n return names;\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) => camelCase(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 instanceScope,\n dedupeCallables,\n generateBindings,\n matchStaticFinishFunction,\n indexMethodsByName,\n isEmittableCallable,\n renderStaticSignature,\n classConstructorMemberNames,\n renderStaticHead,\n renderPlainTypeMembers,\n type Callables,\n type InstanceScope,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"callables.js","sourceRoot":"","sources":["../../../src/store/gi/callables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OA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AAsB,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,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,gBAAgB,EAChB,sBAAsB,GAGzB,CAAC","sourcesContent":["import { camelCase, toCamelIdentifier, uniqBy } from \"@gtkx/utils\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { hasCallerAllocatedArrayLength } from \"../../analysis/param-structure.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\nimport { renderBlock } from \"../../writer/emit.js\";\nimport { matchAsyncFinish } from \"./async.js\";\nimport { renderFnExpression } from \"./function.js\";\nimport { gtypeMemberDeclaration } from \"./gtype-binding.js\";\nimport {\n finishCallExpression,\n methodExportName,\n renderMethodBody,\n renderMethodReturnType,\n renderMethodSignature,\n renderPromisifiedBody,\n renderPromisifiedSignature,\n} from \"./method.js\";\nimport { renderRuntimeOverride } 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 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 `${renderJsDoc(callable.doc)}${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 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 renderBinding = (\n context: ModuleContext,\n callable: GirFunction,\n): { text: string; cIdentifier: string } | undefined => {\n if (!callable.introspectable) {\n return undefined;\n }\n\n if (callable.shadowedBy !== undefined) {\n return undefined;\n }\n\n const cIdentifier = callable.cIdentifier;\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 if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const cIdentifier = callable.cIdentifier;\n\n if (cIdentifier === undefined) {\n return undefined;\n }\n\n const name = resolveName(callable);\n\n if (name === undefined || name === \"constructor\") {\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 doc = renderJsDoc(callable.doc);\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 || name === \"constructor\") {\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 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 (name === \"constructor\") {\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 `${renderJsDoc(callable.doc)}${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 !hasCallerAllocatedArrayLength(context.library, callable);\n\nconst constructorMemberName = (girName: string): string | undefined => {\n const camel = camelCase(girName);\n\n if (camel === \"constructor\") {\n return undefined;\n }\n\n return camel;\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 classConstructorMemberNames = (context: ModuleContext, callables: Callables): string[] => {\n const names: string[] = [];\n\n for (const callable of callables.constructors) {\n if (!isEmittableCallable(context, callable)) {\n continue;\n }\n\n const member = constructorMemberName(callable.name);\n\n if (member !== undefined) {\n names.push(member);\n }\n }\n\n return names;\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) => camelCase(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 instanceScope,\n dedupeCallables,\n generateBindings,\n matchStaticFinishFunction,\n indexMethodsByName,\n isEmittableCallable,\n renderStaticSignature,\n classConstructorMemberNames,\n renderStaticHead,\n renderPlainTypeMembers,\n type Callables,\n type InstanceScope,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/store/gi/constant.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/store/gi/constant.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAM7D,QAAA,MAAM,gBAAgB,GAAI,SAAS,aAAa,EAAE,UAAU,WAAW,KAAG,IAIzE,CAAC;AAEF,QAAA,MAAM,eAAe,GAAI,SAAS,aAAa,EAAE,UAAU,WAAW,KAAG,MAUxE,CAAC;AA6BF,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { sourceStringLiteral } from "@gtkx/utils";
|
|
2
2
|
import { renderJsDoc } from "../../writer/doc.js";
|
|
3
3
|
const TRUE_VALUES = new Set(["true", "1"]);
|
|
4
|
-
// A `gint64`/`guint64` constant is typed `bigint`, and its decimal text does not survive a double:
|
|
5
|
-
// G_MAXINT64 rounds to 2^63. The literal has to carry the BigInt suffix the type promises.
|
|
6
4
|
const BIGINT_CATEGORIES = new Set(["bigint64", "biguint64", "gtype"]);
|
|
7
5
|
const generateConstant = (context, constant) => {
|
|
8
6
|
context.module.appendDeclaration(`${renderJsDoc(constant.doc)}export const ${constant.name} = ${constantLiteral(context, constant)};`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../src/store/gi/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKlD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,WAAW,GAAgB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;AACxD,
|
|
1
|
+
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../src/store/gi/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKlD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,WAAW,GAAgB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;AACxD,MAAM,iBAAiB,GAA2B,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;AAE9F,MAAM,gBAAgB,GAAG,CAAC,OAAsB,EAAE,QAAqB,EAAQ,EAAE;IAC7E,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAC5B,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,gBAAgB,QAAQ,CAAC,IAAI,MAAM,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,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AAK,SAAS,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C,OAAO,QAAQ,EAAE,IAAI,KAAK,WAAW,IAAI,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC;AAC5E,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAExF,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { sourceStringLiteral } from \"@gtkx/utils\";\nimport type { GirConstant } from \"../../gir/namespace.js\";\nimport type { PrimitiveCategory } from \"../../gir/primitives.js\";\nimport type { TypeId } from \"../../gir/type-id.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\n\nconst TRUE_VALUES: Set<string> = new Set([\"true\", \"1\"]);\nconst BIGINT_CATEGORIES: Set<PrimitiveCategory> = new Set([\"bigint64\", \"biguint64\", \"gtype\"]);\n\nconst generateConstant = (context: ModuleContext, constant: GirConstant): void => {\n context.module.appendDeclaration(\n `${renderJsDoc(constant.doc)}export const ${constant.name} = ${constantLiteral(context, constant)};`,\n );\n};\n\nconst constantLiteral = (context: ModuleContext, constant: GirConstant): string => {\n if (hasPrimitiveCategory(context, constant.type, \"string\")) {\n return sourceStringLiteral(constant.value);\n }\n\n if (hasPrimitiveCategory(context, constant.type, \"boolean\")) {\n return TRUE_VALUES.has(constant.value) ? \"true\" : \"false\";\n }\n\n return numericConstantLiteral(context, constant);\n};\n\nconst numericConstantLiteral = (context: ModuleContext, constant: GirConstant): string => {\n if (!isNumericLiteral(constant.value)) {\n return sourceStringLiteral(constant.value);\n }\n\n return isBigIntConstant(context, constant.type) ? `${constant.value}n` : constant.value;\n};\n\nconst isBigIntConstant = (context: ModuleContext, type: TypeId | undefined): boolean =>\n [...BIGINT_CATEGORIES].some((category) => hasPrimitiveCategory(context, type, category));\n\nconst hasPrimitiveCategory = (\n context: ModuleContext,\n type: TypeId | undefined,\n category: PrimitiveCategory,\n): boolean => {\n if (type === undefined) {\n return false;\n }\n\n const resolved = context.library.typeFor(type);\n\n return resolved?.kind === \"primitive\" && resolved.category === category;\n};\n\nconst isNumericLiteral = (value: string): boolean => /^-?(?:\\d+|\\d*\\.\\d+)$/.test(value);\n\nexport { generateConstant, constantLiteral };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../../src/store/gi/function.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAgB7D,QAAA,MAAM,kBAAkB,GAAI,SAAS,aAAa,EAAE,IAAI,WAAW,KAAG,MAAM,GAAG,SAgB9E,CAAC;
|
|
1
|
+
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../../src/store/gi/function.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAgB7D,QAAA,MAAM,kBAAkB,GAAI,SAAS,aAAa,EAAE,IAAI,WAAW,KAAG,MAAM,GAAG,SAgB9E,CAAC;AA2BF,QAAA,MAAM,yBAAyB,GAAI,SAAS,aAAa,EAAE,IAAI,WAAW,KAAG,IAsB5E,CAAC;AA+BF,QAAA,MAAM,2BAA2B,GAAI,aAAa,MAAM,EAAE,SAAS,MAAM,EAAE,gBAAgB,MAAM,EAAE,KAAG,MAQrG,CAAC;AAgCF,QAAA,MAAM,0BAA0B,GAAI,SAAS,aAAa,EAAE,WAAW,YAAY,KAAG,IASrF,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,CAAC"}
|
|
@@ -16,12 +16,8 @@ const renderFnExpression = (context, fn) => {
|
|
|
16
16
|
context.addRuntimeImport("t");
|
|
17
17
|
const params = planCallArgs(context, fn).map((arg) => arg.paramLiteral);
|
|
18
18
|
const ret = renderReturnDescriptor(context, fn);
|
|
19
|
-
return tFn(library, fn.cIdentifier, { args: arrayLiteral(params), returns: ret,
|
|
19
|
+
return tFn(library, fn.cIdentifier, { args: arrayLiteral(params), returns: ret, canThrow: fn.throws });
|
|
20
20
|
};
|
|
21
|
-
// `moved-to` names the type member this function is also reachable as, so the namespace-level copy
|
|
22
|
-
// is a second export of one binding. Suppressing it is only right when that member is really
|
|
23
|
-
// emitted: 15 of Gtk-4.0's 28 `moved-to` targets are enum or error-domain members codegen emits no
|
|
24
|
-
// static for, and dropping those would delete API with nothing to replace it.
|
|
25
21
|
const isMovedOntoEmittedMember = (context, fn) => {
|
|
26
22
|
const [typeName, memberName] = fn.movedTo?.split(".") ?? [];
|
|
27
23
|
if (typeName === undefined || memberName === undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../src/store/gi/function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIhD,OAAO,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAC;AACnD,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAA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AAC","sourcesContent":["import { toCamelIdentifier } from \"@gtkx/utils\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { GirNamespace } from \"../../gir/namespace.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { tFn } from \"../../analysis/descriptor.js\";\nimport { hasCallerAllocatedArrayLength } from \"../../analysis/param-structure.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\nimport { arrayLiteral, renderBlock } from \"../../writer/emit.js\";\nimport { matchAsyncFinish } from \"./async.js\";\nimport {\n planCallArgs,\n renderMethodBody,\n renderMethodReturnType,\n renderMethodSignature,\n renderPromisifiedBody,\n renderPromisifiedSignature,\n renderReturnDescriptor,\n} from \"./method.js\";\n\nconst renderFnExpression = (context: ModuleContext, fn: GirFunction): string | undefined => {\n if (fn.cIdentifier === undefined) {\n return undefined;\n }\n\n const library = context.namespace.sharedLibrary;\n\n if (library === undefined) {\n return undefined;\n }\n\n context.addRuntimeImport(\"t\");\n const params = planCallArgs(context, fn).map((arg) => arg.paramLiteral);\n const ret = renderReturnDescriptor(context, fn);\n\n return tFn(library, fn.cIdentifier, { args: arrayLiteral(params), returns: ret, throws: fn.throws });\n};\n\n// `moved-to` names the type member this function is also reachable as, so the namespace-level copy\n// is a second export of one binding. Suppressing it is only right when that member is really\n// emitted: 15 of Gtk-4.0's 28 `moved-to` targets are enum or error-domain members codegen emits no\n// static for, and dropping those would delete API with nothing to replace it.\nconst isMovedOntoEmittedMember = (context: ModuleContext, fn: GirFunction): boolean => {\n const [typeName, memberName] = fn.movedTo?.split(\".\") ?? [];\n\n if (typeName === undefined || memberName === undefined) {\n return false;\n }\n\n const resolved = context.library.resolveType(context.namespace.name, typeName);\n\n if (resolved?.kind !== \"class\" && resolved?.kind !== \"interface\" && resolved?.kind !== \"record\") {\n return false;\n }\n\n const members = [...resolved.value.methods, ...resolved.value.functions, ...resolved.value.constructors];\n\n return members.some((member) => member.name === memberName);\n};\n\nconst canEmitNamespaceFunction = (context: ModuleContext, fn: GirFunction): boolean =>\n fn.introspectable &&\n !isMovedOntoEmittedMember(context, fn) &&\n fn.shadowedBy === undefined &&\n fn.cIdentifier !== undefined &&\n !hasCallerAllocatedArrayLength(context.library, fn);\n\nconst generateNamespaceFunction = (context: ModuleContext, fn: GirFunction): void => {\n if (!canEmitNamespaceFunction(context, fn)) {\n return;\n }\n\n const expression = renderFnExpression(context, fn);\n\n if (expression === undefined) {\n return;\n }\n\n const cIdentifier = fn.cIdentifier;\n\n if (cIdentifier === undefined) {\n return;\n }\n\n const bindingName = toCamelIdentifier(cIdentifier);\n context.module.appendBinding(`const ${bindingName} = ${expression};`, cIdentifier);\n const exportName = namespaceFunctionExportName(cIdentifier, fn.name, context.namespace.cSymbolPrefixes);\n const declaration = renderNamespaceFunctionDeclaration(context, fn, exportName, bindingName);\n context.module.appendDeclaration(`${renderJsDoc(fn.doc)}${declaration}`);\n};\n\nconst renderNamespaceFunctionDeclaration = (\n context: ModuleContext,\n fn: GirFunction,\n exportName: string,\n bindingName: string,\n): string => {\n const finishFn = matchAsyncFinish(context.library, fn, context.namespace.functions);\n const finishCIdentifier = finishFn?.cIdentifier;\n\n if (finishFn !== undefined && finishCIdentifier !== undefined && canEmitNamespaceFunction(context, finishFn)) {\n const finishExport = namespaceFunctionExportName(\n finishCIdentifier,\n finishFn.name,\n context.namespace.cSymbolPrefixes,\n );\n\n const { signature, returnType } = renderPromisifiedSignature(context, fn, finishFn);\n const body = renderPromisifiedBody(context, fn, finishExport, bindingName);\n\n return renderBlock(`export function ${exportName}(${signature}): ${returnType}`, body);\n }\n\n const signature = renderMethodSignature(context, fn);\n const returnType = renderMethodReturnType(context, fn);\n const body = renderMethodBody(context, fn, { bindingExpression: bindingName });\n\n return renderBlock(`export function ${exportName}(${signature}): ${returnType}`, body);\n};\n\nconst namespaceFunctionExportName = (cIdentifier: string, girName: string, symbolPrefixes: string[]): string => {\n if (girName.length > 0) {\n return toCamelIdentifier(girName);\n }\n\n const stripped = stripLongestPrefix(cIdentifier, symbolPrefixes);\n\n return toCamelIdentifier(stripped);\n};\n\nconst stripLongestPrefix = (input: string, prefixes: string[]): string => {\n let best = \"\";\n\n for (const prefix of prefixes) {\n const candidate = `${prefix}_`;\n\n if (input.startsWith(candidate) && candidate.length > best.length) {\n best = candidate;\n }\n }\n\n return best.length === 0 ? input : input.slice(best.length);\n};\n\nconst isBootstrapFunction = (fn: GirFunction): boolean =>\n fn.parameters.length === 0 && fn.introspectable && fn.shadowedBy === undefined && fn.cIdentifier !== undefined;\n\nconst appendBootstrapRegistration = (context: ModuleContext, fn: GirFunction, exportName: string): void => {\n if (fn.name === \"init\") {\n context.module.appendRegistration(`${exportName}();`);\n\n return;\n }\n\n if (fn.name === \"finalize\") {\n context.addRuntimeImport(\"onExit\");\n context.module.appendRegistration(`onExit(${exportName});`);\n }\n};\n\nconst generateNamespaceBootstrap = (context: ModuleContext, namespace: GirNamespace): void => {\n for (const fn of namespace.functions) {\n if (!isBootstrapFunction(fn) || fn.cIdentifier === undefined) {\n continue;\n }\n\n const exportName = namespaceFunctionExportName(fn.cIdentifier, fn.name, context.namespace.cSymbolPrefixes);\n appendBootstrapRegistration(context, fn, exportName);\n }\n};\n\nexport { renderFnExpression, generateNamespaceFunction, namespaceFunctionExportName, generateNamespaceBootstrap };\n"]}
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../src/store/gi/function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIhD,OAAO,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAC;AACnD,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACH,YAAY,EACZ,gBAAgB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Namespace } from \"../../gir/namespace.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { tFn } from \"../../analysis/descriptor.js\";\nimport { hasCallerAllocatedArrayLength } from \"../../analysis/param-structure.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\nimport { arrayLiteral, renderBlock } from \"../../writer/emit.js\";\nimport { matchAsyncFinish } from \"./async.js\";\nimport {\n planCallArgs,\n renderMethodBody,\n renderMethodReturnType,\n renderMethodSignature,\n renderPromisifiedBody,\n renderPromisifiedSignature,\n renderReturnDescriptor,\n} from \"./method.js\";\n\nconst renderFnExpression = (context: ModuleContext, fn: GirFunction): string | undefined => {\n if (fn.cIdentifier === undefined) {\n return undefined;\n }\n\n const library = context.namespace.sharedLibrary;\n\n if (library === undefined) {\n return undefined;\n }\n\n context.addRuntimeImport(\"t\");\n const params = planCallArgs(context, fn).map((arg) => arg.paramLiteral);\n const ret = renderReturnDescriptor(context, fn);\n\n return tFn(library, fn.cIdentifier, { args: arrayLiteral(params), returns: ret, canThrow: fn.throws });\n};\n\nconst isMovedOntoEmittedMember = (context: ModuleContext, fn: GirFunction): boolean => {\n const [typeName, memberName] = fn.movedTo?.split(\".\") ?? [];\n\n if (typeName === undefined || memberName === undefined) {\n return false;\n }\n\n const resolved = context.library.resolveType(context.namespace.name, typeName);\n\n if (resolved?.kind !== \"class\" && resolved?.kind !== \"interface\" && resolved?.kind !== \"record\") {\n return false;\n }\n\n const members = [...resolved.value.methods, ...resolved.value.functions, ...resolved.value.constructors];\n\n return members.some((member) => member.name === memberName);\n};\n\nconst canEmitNamespaceFunction = (context: ModuleContext, fn: GirFunction): boolean =>\n fn.introspectable &&\n !isMovedOntoEmittedMember(context, fn) &&\n fn.shadowedBy === undefined &&\n fn.cIdentifier !== undefined &&\n !hasCallerAllocatedArrayLength(context.library, fn);\n\nconst generateNamespaceFunction = (context: ModuleContext, fn: GirFunction): void => {\n if (!canEmitNamespaceFunction(context, fn)) {\n return;\n }\n\n const expression = renderFnExpression(context, fn);\n\n if (expression === undefined) {\n return;\n }\n\n const cIdentifier = fn.cIdentifier;\n\n if (cIdentifier === undefined) {\n return;\n }\n\n const bindingName = toCamelIdentifier(cIdentifier);\n context.module.appendBinding(`const ${bindingName} = ${expression};`, cIdentifier);\n const exportName = namespaceFunctionExportName(cIdentifier, fn.name, context.namespace.cSymbolPrefixes);\n const declaration = renderNamespaceFunctionDeclaration(context, fn, exportName, bindingName);\n context.module.appendDeclaration(`${renderJsDoc(fn.doc)}${declaration}`);\n};\n\nconst renderNamespaceFunctionDeclaration = (\n context: ModuleContext,\n fn: GirFunction,\n exportName: string,\n bindingName: string,\n): string => {\n const finishFn = matchAsyncFinish(context.library, fn, context.namespace.functions);\n const finishCIdentifier = finishFn?.cIdentifier;\n\n if (finishFn !== undefined && finishCIdentifier !== undefined && canEmitNamespaceFunction(context, finishFn)) {\n const finishExport = namespaceFunctionExportName(\n finishCIdentifier,\n finishFn.name,\n context.namespace.cSymbolPrefixes,\n );\n\n const { signature, returnType } = renderPromisifiedSignature(context, fn, finishFn);\n const body = renderPromisifiedBody(context, fn, finishExport, bindingName);\n\n return renderBlock(`export function ${exportName}(${signature}): ${returnType}`, body);\n }\n\n const signature = renderMethodSignature(context, fn);\n const returnType = renderMethodReturnType(context, fn);\n const body = renderMethodBody(context, fn, { bindingExpression: bindingName });\n\n return renderBlock(`export function ${exportName}(${signature}): ${returnType}`, body);\n};\n\nconst namespaceFunctionExportName = (cIdentifier: string, girName: string, symbolPrefixes: string[]): string => {\n if (girName.length > 0) {\n return toCamelIdentifier(girName);\n }\n\n const stripped = stripLongestPrefix(cIdentifier, symbolPrefixes);\n\n return toCamelIdentifier(stripped);\n};\n\nconst stripLongestPrefix = (input: string, prefixes: string[]): string => {\n let best = \"\";\n\n for (const prefix of prefixes) {\n const candidate = `${prefix}_`;\n\n if (input.startsWith(candidate) && candidate.length > best.length) {\n best = candidate;\n }\n }\n\n return best.length === 0 ? input : input.slice(best.length);\n};\n\nconst isBootstrapFunction = (fn: GirFunction): boolean =>\n fn.parameters.length === 0 && fn.introspectable && fn.shadowedBy === undefined && fn.cIdentifier !== undefined;\n\nconst appendBootstrapRegistration = (context: ModuleContext, fn: GirFunction, exportName: string): void => {\n if (fn.name === \"init\") {\n context.module.appendRegistration(`${exportName}();`);\n\n return;\n }\n\n if (fn.name === \"finalize\") {\n context.addRuntimeImport(\"onExit\");\n context.module.appendRegistration(`onExit(${exportName});`);\n }\n};\n\nconst generateNamespaceBootstrap = (context: ModuleContext, namespace: GirNamespace): void => {\n for (const fn of namespace.functions) {\n if (!isBootstrapFunction(fn) || fn.cIdentifier === undefined) {\n continue;\n }\n\n const exportName = namespaceFunctionExportName(fn.cIdentifier, fn.name, context.namespace.cSymbolPrefixes);\n appendBootstrapRegistration(context, fn, exportName);\n }\n};\n\nexport { renderFnExpression, generateNamespaceFunction, namespaceFunctionExportName, generateNamespaceBootstrap };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method.d.ts","sourceRoot":"","sources":["../../../src/store/gi/method.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AA+B7D,KAAK,sBAAsB,GAAG;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3C,CAAC;AAEF,KAAK,WAAW,GAAG;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AAsBF,QAAA,MAAM,gBAAgB,GAAI,IAAI,WAAW,KAAG,MAA4B,CAAC;AAQzE,QAAA,MAAM,qBAAqB,GAAI,SAAS,aAAa,EAAE,IAAI,WAAW,KAAG,MAMpE,CAAC;AA0CN,QAAA,MAAM,sBAAsB,GAAI,SAAS,aAAa,EAAE,IAAI,WAAW,KAAG,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AAG,MAMpE,CAAC;AA0CN,QAAA,MAAM,sBAAsB,GAAI,SAAS,aAAa,EAAE,IAAI,WAAW,KAAG,MAezE,CAAC;AAuDF,QAAA,MAAM,qBAAqB,GACvB,SAAS,aAAa,EACtB,SAAS,WAAW,EACpB,kBAAkB,MAAM,EACxB,mBAAmB,MAAM,KAC1B,MAuBF,CAAC;AAEF,QAAA,MAAM,oBAAoB,GAAI,SAAS,WAAW,EAAE,UAAU,WAAW,EAAE,WAAW,MAAM,KAAG,MAGtC,CAAC;AA2B1D,QAAA,MAAM,0BAA0B,GAC5B,SAAS,aAAa,EACtB,SAAS,WAAW,EACpB,UAAU,WAAW,KACtB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAWzC,CAAC;AAeF,QAAA,MAAM,gBAAgB,GAAI,SAAS,aAAa,EAAE,IAAI,WAAW,EAAE,SAAS,sBAAsB,KAAG,MAWpG,CAAC;AAoBF,QAAA,MAAM,sBAAsB,GAAI,SAAS,aAAa,EAAE,IAAI,WAAW,KAAG,MAQzE,CAAC;AAEF,QAAA,MAAM,YAAY,GAAI,SAAS,aAAa,EAAE,IAAI,WAAW,KAAG,WAAW,EAgC1E,CAAC;AAiRF,OAAO,EACH,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,GACf,CAAC"}
|
package/dist/store/gi/method.js
CHANGED
|
@@ -17,16 +17,16 @@ const isParameterOptional = (parameter, isOptionalExtra) => parameter.optional |
|
|
|
17
17
|
const formatParameterPart = (name, annotation, isOptional) => isOptional ? `${name}?: ${annotation}` : `${name}: ${annotation}`;
|
|
18
18
|
const renderInputParameters = (context, fn, shouldSkip, isOptionalExtra) => {
|
|
19
19
|
const parts = [];
|
|
20
|
-
let
|
|
20
|
+
let hasSeenOptional = false;
|
|
21
21
|
for (const { parameter, index } of inputParameters(context.library, fn)) {
|
|
22
22
|
if (shouldSkip(parameter)) {
|
|
23
23
|
continue;
|
|
24
24
|
}
|
|
25
25
|
const name = parameterIdentifier(parameter, index);
|
|
26
26
|
if (isParameterOptional(parameter, isOptionalExtra)) {
|
|
27
|
-
|
|
27
|
+
hasSeenOptional = true;
|
|
28
28
|
}
|
|
29
|
-
parts.push(formatParameterPart(name, parameterAnnotation(context, fn, parameter),
|
|
29
|
+
parts.push(formatParameterPart(name, parameterAnnotation(context, fn, parameter), hasSeenOptional));
|
|
30
30
|
}
|
|
31
31
|
return parts.join(", ");
|
|
32
32
|
};
|
|
@@ -47,26 +47,26 @@ const renderMethodReturnType = (context, fn) => {
|
|
|
47
47
|
};
|
|
48
48
|
const classifyPromisifiedParameter = (promisify, parameter, index, state) => {
|
|
49
49
|
if (parameter.isVarargs) {
|
|
50
|
-
return {
|
|
50
|
+
return { hasSeenOptional: state.hasSeenOptional, expression: undefined };
|
|
51
51
|
}
|
|
52
52
|
if (index === state.cancellableIndex) {
|
|
53
|
-
return {
|
|
53
|
+
return { hasSeenOptional: true, expression: undefined };
|
|
54
54
|
}
|
|
55
55
|
if (shouldSkipPromisifiedParameter(promisify, parameter, index)) {
|
|
56
|
-
return {
|
|
56
|
+
return { hasSeenOptional: state.hasSeenOptional, expression: undefined };
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
return {
|
|
58
|
+
const hasSeenOptional = state.hasSeenOptional || parameter.optional;
|
|
59
|
+
return { hasSeenOptional, expression: promisifiedArgument(promisify, parameter, index, hasSeenOptional) };
|
|
60
60
|
};
|
|
61
61
|
const collectPromisifiedArguments = (promisify, cancellableIndex) => {
|
|
62
62
|
const expressions = [];
|
|
63
|
-
let
|
|
63
|
+
let hasSeenOptional = false;
|
|
64
64
|
for (const [index, parameter] of promisify.asyncFn.parameters.entries()) {
|
|
65
65
|
const step = classifyPromisifiedParameter(promisify, parameter, index, {
|
|
66
66
|
cancellableIndex,
|
|
67
|
-
|
|
67
|
+
hasSeenOptional,
|
|
68
68
|
});
|
|
69
|
-
|
|
69
|
+
hasSeenOptional = step.hasSeenOptional;
|
|
70
70
|
if (step.expression !== undefined) {
|
|
71
71
|
expressions.push(step.expression);
|
|
72
72
|
}
|
|
@@ -142,11 +142,11 @@ const paramDescriptorLiteral = (descriptor, options) => {
|
|
|
142
142
|
if (options.direction !== undefined) {
|
|
143
143
|
parts.push(`direction: ${sourceStringLiteral(options.direction)}`);
|
|
144
144
|
}
|
|
145
|
-
if (options.
|
|
146
|
-
parts.push("
|
|
145
|
+
if (options.isCallerAllocated === true) {
|
|
146
|
+
parts.push("isCallerAllocated: true");
|
|
147
147
|
}
|
|
148
|
-
if (options.
|
|
149
|
-
parts.push("
|
|
148
|
+
if (options.isConsumed === true) {
|
|
149
|
+
parts.push("isConsumed: true");
|
|
150
150
|
}
|
|
151
151
|
return `{ ${parts.join(", ")} }`;
|
|
152
152
|
};
|
|
@@ -215,7 +215,7 @@ const planInoutArgument = (context, parameter, index, planContext) => {
|
|
|
215
215
|
return planInoutParam(context, parameter, {
|
|
216
216
|
index,
|
|
217
217
|
argIndex: planContext.argIndex,
|
|
218
|
-
|
|
218
|
+
isConsumed: folded.has(index),
|
|
219
219
|
lengthSource,
|
|
220
220
|
});
|
|
221
221
|
};
|
|
@@ -230,7 +230,7 @@ const planLengthArgument = (context, parameter, sourceIndex, planContext) => {
|
|
|
230
230
|
const planOutParam = (context, parameter, argIndex, isConsumed) => {
|
|
231
231
|
const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, argIndex);
|
|
232
232
|
return {
|
|
233
|
-
paramLiteral: paramDescriptorLiteral(descriptor, { direction: "out",
|
|
233
|
+
paramLiteral: paramDescriptorLiteral(descriptor, { direction: "out", isConsumed }),
|
|
234
234
|
inputExpr: undefined,
|
|
235
235
|
};
|
|
236
236
|
};
|
|
@@ -253,24 +253,28 @@ const planCallerOut = (context, parameter, argIndex) => {
|
|
|
253
253
|
context.addRuntimeImport("getHandle");
|
|
254
254
|
const classExpression = context.qualify(name.namespaceName, name.typeName);
|
|
255
255
|
return {
|
|
256
|
-
paramLiteral: paramDescriptorLiteral(descriptor, { direction: "out",
|
|
256
|
+
paramLiteral: paramDescriptorLiteral(descriptor, { direction: "out", isCallerAllocated: true }),
|
|
257
257
|
inputExpr: `new ${classExpression}()`,
|
|
258
258
|
};
|
|
259
259
|
}
|
|
260
260
|
return { paramLiteral: paramDescriptorLiteral(descriptor, {}), inputExpr: "undefined" };
|
|
261
261
|
};
|
|
262
262
|
const planInoutParam = (context, parameter, options) => {
|
|
263
|
-
const { index, argIndex,
|
|
263
|
+
const { index, argIndex, isConsumed, lengthSource } = options;
|
|
264
264
|
if (isHandlePassedInPlace(context, parameter)) {
|
|
265
265
|
const descriptor = renderDescriptor(context, parameter.type, "none", argIndex);
|
|
266
266
|
return {
|
|
267
|
-
paramLiteral: paramDescriptorLiteral(descriptor, {
|
|
267
|
+
paramLiteral: paramDescriptorLiteral(descriptor, {
|
|
268
|
+
direction: "inout",
|
|
269
|
+
isCallerAllocated: true,
|
|
270
|
+
isConsumed,
|
|
271
|
+
}),
|
|
268
272
|
inputExpr: parameterIdentifier(parameter, index),
|
|
269
273
|
};
|
|
270
274
|
}
|
|
271
275
|
const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, argIndex);
|
|
272
276
|
return {
|
|
273
|
-
paramLiteral: paramDescriptorLiteral(descriptor, { direction: "inout",
|
|
277
|
+
paramLiteral: paramDescriptorLiteral(descriptor, { direction: "inout", isConsumed }),
|
|
274
278
|
inputExpr: lengthSource === undefined
|
|
275
279
|
? parameterCallExpression(context, parameter, index)
|
|
276
280
|
: arrayLengthArgument(lengthSource.source, lengthSource.index),
|
|
@@ -312,8 +316,6 @@ const collectionArgument = (context, type, name, isNullable) => {
|
|
|
312
316
|
context.addRuntimeImport("getHandle");
|
|
313
317
|
return mapHandleExpression(name, isNullable);
|
|
314
318
|
};
|
|
315
|
-
// An array whose length nothing states is marshalled as the bare pointer it is, so there is nothing
|
|
316
|
-
// to map over.
|
|
317
319
|
const isMappableSequence = (context, type) => {
|
|
318
320
|
if (type?.kind === "carray") {
|
|
319
321
|
return !hasUnknownArrayLength(type) && isHandlePassing(context, type.element);
|