@gtkx/codegen 0.21.0 → 1.0.0-rc.1
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 +173 -0
- package/dist/analysis/descriptor-render.d.ts +18 -0
- package/dist/analysis/descriptor-render.d.ts.map +1 -0
- package/dist/analysis/descriptor-render.js +297 -0
- package/dist/analysis/descriptor-render.js.map +1 -0
- package/dist/analysis/descriptor.d.ts +59 -0
- package/dist/analysis/descriptor.d.ts.map +1 -0
- package/dist/analysis/descriptor.js +123 -0
- package/dist/analysis/descriptor.js.map +1 -0
- package/dist/analysis/inheritance.d.ts +38 -0
- package/dist/analysis/inheritance.d.ts.map +1 -0
- package/dist/analysis/inheritance.js +193 -0
- package/dist/analysis/inheritance.js.map +1 -0
- package/dist/analysis/param-structure.d.ts +26 -0
- package/dist/analysis/param-structure.d.ts.map +1 -0
- package/dist/analysis/param-structure.js +107 -0
- package/dist/analysis/param-structure.js.map +1 -0
- package/dist/analysis/ts-type.d.ts +19 -0
- package/dist/analysis/ts-type.d.ts.map +1 -0
- package/dist/analysis/ts-type.js +65 -0
- package/dist/analysis/ts-type.js.map +1 -0
- package/dist/compile.d.ts +18 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +123 -0
- package/dist/compile.js.map +1 -0
- package/dist/docs/api-reference.d.ts +66 -0
- package/dist/docs/api-reference.d.ts.map +1 -0
- package/dist/docs/api-reference.js +299 -0
- package/dist/docs/api-reference.js.map +1 -0
- package/dist/docs/element-page.d.ts +15 -0
- package/dist/docs/element-page.d.ts.map +1 -0
- package/dist/docs/element-page.js +221 -0
- package/dist/docs/element-page.js.map +1 -0
- package/dist/docs/pipeline.d.ts +25 -0
- package/dist/docs/pipeline.d.ts.map +1 -0
- package/dist/docs/pipeline.js +130 -0
- package/dist/docs/pipeline.js.map +1 -0
- package/dist/docs/render.d.ts +32 -0
- package/dist/docs/render.d.ts.map +1 -0
- package/dist/docs/render.js +134 -0
- package/dist/docs/render.js.map +1 -0
- package/dist/docs/symbol-page.d.ts +41 -0
- package/dist/docs/symbol-page.d.ts.map +1 -0
- package/dist/docs/symbol-page.js +338 -0
- package/dist/docs/symbol-page.js.map +1 -0
- package/dist/fingerprint.d.ts +6 -26
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +30 -18
- package/dist/fingerprint.js.map +1 -1
- package/dist/gir/ancestry.d.ts +9 -0
- package/dist/gir/ancestry.d.ts.map +1 -0
- package/dist/gir/ancestry.js +29 -0
- package/dist/gir/ancestry.js.map +1 -0
- package/dist/gir/callback.d.ts +9 -10
- package/dist/gir/callback.d.ts.map +1 -1
- package/dist/gir/callback.js +17 -16
- package/dist/gir/callback.js.map +1 -1
- package/dist/gir/class.d.ts +22 -43
- package/dist/gir/class.d.ts.map +1 -1
- package/dist/gir/class.js +11 -23
- package/dist/gir/class.js.map +1 -1
- package/dist/gir/enum.d.ts +13 -31
- package/dist/gir/enum.d.ts.map +1 -1
- package/dist/gir/enum.js +7 -14
- package/dist/gir/enum.js.map +1 -1
- package/dist/gir/field.d.ts +10 -23
- package/dist/gir/field.d.ts.map +1 -1
- package/dist/gir/field.js +12 -18
- package/dist/gir/field.js.map +1 -1
- package/dist/gir/function.d.ts +11 -42
- package/dist/gir/function.d.ts.map +1 -1
- package/dist/gir/function.js +7 -20
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/gir-path.d.ts +2 -0
- package/dist/gir/gir-path.d.ts.map +1 -0
- package/dist/gir/gir-path.js +41 -0
- package/dist/gir/gir-path.js.map +1 -0
- package/dist/gir/libraries.d.ts +4 -0
- package/dist/gir/libraries.d.ts.map +1 -0
- package/dist/gir/libraries.js +62 -0
- package/dist/gir/libraries.js.map +1 -0
- package/dist/gir/library.d.ts +37 -0
- package/dist/gir/library.d.ts.map +1 -0
- package/dist/gir/library.js +218 -0
- package/dist/gir/library.js.map +1 -0
- package/dist/gir/namespace.d.ts +36 -50
- package/dist/gir/namespace.d.ts.map +1 -1
- package/dist/gir/namespace.js +46 -36
- package/dist/gir/namespace.js.map +1 -1
- package/dist/gir/parameter.d.ts +25 -69
- package/dist/gir/parameter.d.ts.map +1 -1
- package/dist/gir/parameter.js +36 -57
- package/dist/gir/parameter.js.map +1 -1
- package/dist/gir/parse.d.ts +6 -70
- package/dist/gir/parse.d.ts.map +1 -1
- package/dist/gir/parse.js +32 -80
- package/dist/gir/parse.js.map +1 -1
- package/dist/gir/primitives.d.ts +3 -34
- package/dist/gir/primitives.d.ts.map +1 -1
- package/dist/gir/primitives.js +19 -35
- package/dist/gir/primitives.js.map +1 -1
- package/dist/gir/property.d.ts +16 -25
- package/dist/gir/property.d.ts.map +1 -1
- package/dist/gir/property.js +12 -9
- package/dist/gir/property.js.map +1 -1
- package/dist/gir/record.d.ts +27 -0
- package/dist/gir/record.d.ts.map +1 -0
- package/dist/gir/record.js +25 -0
- package/dist/gir/record.js.map +1 -0
- package/dist/gir/size.d.ts +10 -57
- package/dist/gir/size.d.ts.map +1 -1
- package/dist/gir/size.js +0 -25
- package/dist/gir/size.js.map +1 -1
- package/dist/gir/type-id.d.ts +49 -0
- package/dist/gir/type-id.d.ts.map +1 -0
- package/dist/gir/type-id.js +8 -0
- package/dist/gir/type-id.js.map +1 -0
- package/dist/gir/type-ref.d.ts +3 -77
- package/dist/gir/type-ref.d.ts.map +1 -1
- package/dist/gir/type-ref.js +35 -65
- package/dist/gir/type-ref.js.map +1 -1
- package/dist/gir/type.d.ts +33 -0
- package/dist/gir/type.d.ts.map +1 -0
- package/dist/gir/type.js +2 -0
- package/dist/gir/type.js.map +1 -0
- package/dist/index.d.ts +5 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -11
- package/dist/index.js.map +1 -1
- package/dist/khronos/args.d.ts +30 -0
- package/dist/khronos/args.d.ts.map +1 -0
- package/dist/khronos/args.js +150 -0
- package/dist/khronos/args.js.map +1 -0
- package/dist/khronos/jsdoc.d.ts +21 -0
- package/dist/khronos/jsdoc.d.ts.map +1 -0
- package/dist/khronos/jsdoc.js +59 -0
- package/dist/khronos/jsdoc.js.map +1 -0
- package/dist/khronos/model.d.ts +37 -0
- package/dist/khronos/model.d.ts.map +1 -0
- package/dist/khronos/model.js +132 -0
- package/dist/khronos/model.js.map +1 -0
- package/dist/khronos/modules.d.ts +11 -0
- package/dist/khronos/modules.d.ts.map +1 -0
- package/dist/khronos/modules.js +58 -0
- package/dist/khronos/modules.js.map +1 -0
- package/dist/khronos/parse.d.ts +9 -0
- package/dist/khronos/parse.d.ts.map +1 -0
- package/dist/khronos/parse.js +61 -0
- package/dist/khronos/parse.js.map +1 -0
- package/dist/khronos/pipeline.d.ts +24 -0
- package/dist/khronos/pipeline.d.ts.map +1 -0
- package/dist/khronos/pipeline.js +182 -0
- package/dist/khronos/pipeline.js.map +1 -0
- package/dist/khronos/plan.d.ts +80 -0
- package/dist/khronos/plan.d.ts.map +1 -0
- package/dist/khronos/plan.js +136 -0
- package/dist/khronos/plan.js.map +1 -0
- package/dist/khronos/render.d.ts +16 -0
- package/dist/khronos/render.d.ts.map +1 -0
- package/dist/khronos/render.js +158 -0
- package/dist/khronos/render.js.map +1 -0
- package/dist/khronos/select.d.ts +15 -0
- package/dist/khronos/select.d.ts.map +1 -0
- package/dist/khronos/select.js +45 -0
- package/dist/khronos/select.js.map +1 -0
- package/dist/runner.d.ts +29 -47
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +78 -53
- package/dist/runner.js.map +1 -1
- package/dist/store/compile-store.d.ts +9 -0
- package/dist/store/compile-store.d.ts.map +1 -0
- package/dist/store/compile-store.js +38 -0
- package/dist/store/compile-store.js.map +1 -0
- package/dist/store/gi/async.d.ts +4 -0
- package/dist/store/gi/async.d.ts.map +1 -0
- package/dist/store/gi/async.js +41 -0
- package/dist/store/gi/async.js.map +1 -0
- package/dist/store/gi/callables.d.ts +36 -0
- package/dist/store/gi/callables.d.ts.map +1 -0
- package/dist/store/gi/callables.js +202 -0
- package/dist/store/gi/callables.js.map +1 -0
- package/dist/store/gi/callback.d.ts +4 -0
- package/dist/store/gi/callback.d.ts.map +1 -0
- package/dist/store/gi/callback.js +14 -0
- package/dist/store/gi/callback.js.map +1 -0
- package/dist/store/gi/class-struct-record.d.ts +9 -0
- package/dist/store/gi/class-struct-record.d.ts.map +1 -0
- package/dist/store/gi/class-struct-record.js +34 -0
- package/dist/store/gi/class-struct-record.js.map +1 -0
- package/dist/store/gi/class.d.ts +4 -0
- package/dist/store/gi/class.d.ts.map +1 -0
- package/dist/store/gi/class.js +169 -0
- package/dist/store/gi/class.js.map +1 -0
- package/dist/store/gi/companion.d.ts +4 -0
- package/dist/store/gi/companion.d.ts.map +1 -0
- package/dist/store/gi/companion.js +13 -0
- package/dist/store/gi/companion.js.map +1 -0
- package/dist/store/gi/constant.d.ts +5 -0
- package/dist/store/gi/constant.d.ts.map +1 -0
- package/dist/store/gi/constant.js +18 -0
- package/dist/store/gi/constant.js.map +1 -0
- package/dist/store/gi/constructor-props.d.ts +5 -0
- package/dist/store/gi/constructor-props.d.ts.map +1 -0
- package/dist/store/gi/constructor-props.js +64 -0
- package/dist/store/gi/constructor-props.js.map +1 -0
- package/dist/store/gi/enum.d.ts +5 -0
- package/dist/store/gi/enum.d.ts.map +1 -0
- package/dist/store/gi/enum.js +38 -0
- package/dist/store/gi/enum.js.map +1 -0
- package/dist/store/gi/function.d.ts +8 -0
- package/dist/store/gi/function.d.ts.map +1 -0
- package/dist/store/gi/function.js +87 -0
- package/dist/store/gi/function.js.map +1 -0
- package/dist/store/gi/gtype-binding.d.ts +10 -0
- package/dist/store/gi/gtype-binding.d.ts.map +1 -0
- package/dist/store/gi/gtype-binding.js +20 -0
- package/dist/store/gi/gtype-binding.js.map +1 -0
- package/dist/store/gi/interface.d.ts +4 -0
- package/dist/store/gi/interface.d.ts.map +1 -0
- package/dist/store/gi/interface.js +99 -0
- package/dist/store/gi/interface.js.map +1 -0
- package/dist/store/gi/item-comparators.d.ts +6 -0
- package/dist/store/gi/item-comparators.d.ts.map +1 -0
- package/dist/store/gi/item-comparators.js +76 -0
- package/dist/store/gi/item-comparators.js.map +1 -0
- package/dist/store/gi/method.d.ts +24 -0
- package/dist/store/gi/method.d.ts.map +1 -0
- package/dist/store/gi/method.js +279 -0
- package/dist/store/gi/method.js.map +1 -0
- package/dist/store/gi/param-marshal.d.ts +9 -0
- package/dist/store/gi/param-marshal.d.ts.map +1 -0
- package/dist/store/gi/param-marshal.js +37 -0
- package/dist/store/gi/param-marshal.js.map +1 -0
- package/dist/store/gi/pipeline.d.ts +4 -0
- package/dist/store/gi/pipeline.d.ts.map +1 -0
- package/dist/store/gi/pipeline.js +80 -0
- package/dist/store/gi/pipeline.js.map +1 -0
- package/dist/store/gi/properties.d.ts +5 -0
- package/dist/store/gi/properties.d.ts.map +1 -0
- package/dist/store/gi/properties.js +30 -0
- package/dist/store/gi/properties.js.map +1 -0
- package/dist/store/gi/property-accessor.d.ts +26 -0
- package/dist/store/gi/property-accessor.d.ts.map +1 -0
- package/dist/store/gi/property-accessor.js +132 -0
- package/dist/store/gi/property-accessor.js.map +1 -0
- package/dist/store/gi/record-constructor.d.ts +5 -0
- package/dist/store/gi/record-constructor.d.ts.map +1 -0
- package/dist/store/gi/record-constructor.js +65 -0
- package/dist/store/gi/record-constructor.js.map +1 -0
- package/dist/store/gi/record-field-accessor.d.ts +25 -0
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -0
- package/dist/store/gi/record-field-accessor.js +288 -0
- package/dist/store/gi/record-field-accessor.js.map +1 -0
- package/dist/store/gi/record-layout.d.ts +14 -0
- package/dist/store/gi/record-layout.d.ts.map +1 -0
- package/dist/store/gi/record-layout.js +96 -0
- package/dist/store/gi/record-layout.js.map +1 -0
- package/dist/store/gi/record.d.ts +4 -0
- package/dist/store/gi/record.d.ts.map +1 -0
- package/dist/store/gi/record.js +59 -0
- package/dist/store/gi/record.js.map +1 -0
- package/dist/store/gi/registration.d.ts +16 -0
- package/dist/store/gi/registration.d.ts.map +1 -0
- package/dist/store/gi/registration.js +20 -0
- package/dist/store/gi/registration.js.map +1 -0
- package/dist/store/gi/return-wrap.d.ts +10 -0
- package/dist/store/gi/return-wrap.d.ts.map +1 -0
- package/dist/store/gi/return-wrap.js +46 -0
- package/dist/store/gi/return-wrap.js.map +1 -0
- package/dist/store/gi/runtime-override.d.ts +3 -0
- package/dist/store/gi/runtime-override.d.ts.map +1 -0
- package/dist/{writers → store/gi}/runtime-override.js +0 -15
- package/dist/store/gi/runtime-override.js.map +1 -0
- package/dist/store/gi/signal.d.ts +5 -0
- package/dist/store/gi/signal.d.ts.map +1 -0
- package/dist/store/gi/signal.js +233 -0
- package/dist/store/gi/signal.js.map +1 -0
- package/dist/store/gi/vtable.d.ts +4 -0
- package/dist/store/gi/vtable.d.ts.map +1 -0
- package/dist/store/gi/vtable.js +78 -0
- package/dist/store/gi/vtable.js.map +1 -0
- package/dist/store/gi-store.d.ts +9 -0
- package/dist/store/gi-store.d.ts.map +1 -0
- package/dist/store/gi-store.js +57 -0
- package/dist/store/gi-store.js.map +1 -0
- package/dist/store/jsx-store.d.ts +5 -0
- package/dist/store/jsx-store.d.ts.map +1 -0
- package/dist/store/jsx-store.js +23 -0
- package/dist/store/jsx-store.js.map +1 -0
- package/dist/store/react/built-ins.d.ts +9 -0
- package/dist/store/react/built-ins.d.ts.map +1 -0
- package/dist/store/react/built-ins.js +226 -0
- package/dist/store/react/built-ins.js.map +1 -0
- package/dist/store/react/element-components.d.ts +15 -0
- package/dist/store/react/element-components.d.ts.map +1 -0
- package/dist/store/react/element-components.js +92 -0
- package/dist/store/react/element-components.js.map +1 -0
- package/dist/store/react/element-prop-types.d.ts +19 -0
- package/dist/store/react/element-prop-types.d.ts.map +1 -0
- package/dist/store/react/element-prop-types.js +244 -0
- package/dist/store/react/element-prop-types.js.map +1 -0
- package/dist/store/react/element-props.d.ts +4 -0
- package/dist/store/react/element-props.d.ts.map +1 -0
- package/dist/store/react/element-props.js +178 -0
- package/dist/store/react/element-props.js.map +1 -0
- package/dist/store/react/gir-index.d.ts +25 -0
- package/dist/store/react/gir-index.d.ts.map +1 -0
- package/dist/store/react/gir-index.js +55 -0
- package/dist/store/react/gir-index.js.map +1 -0
- package/dist/store/react/intrinsic-elements.d.ts +26 -0
- package/dist/store/react/intrinsic-elements.d.ts.map +1 -0
- package/dist/store/react/intrinsic-elements.js +107 -0
- package/dist/store/react/intrinsic-elements.js.map +1 -0
- package/dist/store/react/jsx.d.ts +18 -0
- package/dist/store/react/jsx.d.ts.map +1 -0
- package/dist/store/react/jsx.js +203 -0
- package/dist/store/react/jsx.js.map +1 -0
- package/dist/store/react/metadata.d.ts +4 -0
- package/dist/store/react/metadata.d.ts.map +1 -0
- package/dist/store/react/metadata.js +174 -0
- package/dist/store/react/metadata.js.map +1 -0
- package/dist/store/react/pipeline.d.ts +14 -0
- package/dist/store/react/pipeline.d.ts.map +1 -0
- package/dist/store/react/pipeline.js +60 -0
- package/dist/store/react/pipeline.js.map +1 -0
- package/dist/store/react/props.d.ts +36 -0
- package/dist/store/react/props.d.ts.map +1 -0
- package/dist/store/react/props.js +133 -0
- package/dist/store/react/props.js.map +1 -0
- package/dist/store/store-fs.d.ts +41 -0
- package/dist/store/store-fs.d.ts.map +1 -0
- package/dist/store/store-fs.js +71 -0
- package/dist/store/store-fs.js.map +1 -0
- package/dist/writer/context.d.ts +16 -0
- package/dist/writer/context.d.ts.map +1 -0
- package/dist/writer/context.js +44 -0
- package/dist/writer/context.js.map +1 -0
- package/dist/writer/doc.d.ts +2 -0
- package/dist/writer/doc.d.ts.map +1 -0
- package/dist/writer/doc.js +12 -0
- package/dist/writer/doc.js.map +1 -0
- package/dist/writer/emit.d.ts +8 -0
- package/dist/writer/emit.d.ts.map +1 -0
- package/dist/writer/emit.js +21 -0
- package/dist/writer/emit.js.map +1 -0
- package/dist/writer/gtk-doc.d.ts +2 -0
- package/dist/writer/gtk-doc.d.ts.map +1 -0
- package/dist/writer/gtk-doc.js +67 -0
- package/dist/writer/gtk-doc.js.map +1 -0
- package/dist/writer/imports.d.ts +10 -0
- package/dist/writer/imports.d.ts.map +1 -0
- package/dist/writer/imports.js +50 -0
- package/dist/writer/imports.js.map +1 -0
- package/dist/writer/module.d.ts +15 -0
- package/dist/writer/module.d.ts.map +1 -0
- package/dist/writer/module.js +46 -0
- package/dist/writer/module.js.map +1 -0
- package/overrides/cairo/context.ts.ejs +1269 -0
- package/overrides/cairo/font-face.ts.ejs +151 -0
- package/overrides/cairo/font-options.ts.ejs +199 -0
- package/overrides/cairo/image-surface.ts.ejs +132 -0
- package/overrides/cairo/index.ts.ejs +22 -0
- package/overrides/cairo/matrix.ts.ejs +171 -0
- package/overrides/cairo/pattern.ts.ejs +476 -0
- package/overrides/cairo/recording-surface.ts.ejs +102 -0
- package/overrides/cairo/region.ts.ejs +237 -0
- package/overrides/cairo/scaled-font.ts.ejs +330 -0
- package/overrides/cairo/surface.ts.ejs +296 -0
- package/overrides/gdk/index.ts.ejs +2 -0
- package/overrides/gdk/rgba.ts.ejs +11 -0
- package/overrides/gobject/index.ts.ejs +29 -0
- package/overrides/gobject/object.ts.ejs +51 -0
- package/overrides/gobject/value.ts.ejs +17 -0
- package/overrides/graphene/index.ts.ejs +2 -0
- package/overrides/graphene/structs.ts.ejs +37 -0
- package/overrides/gtk/constants.ts.ejs +3 -0
- package/overrides/gtk/index.ts.ejs +2 -0
- package/package.json +15 -15
- package/src/analysis/descriptor-render.ts +407 -0
- package/src/analysis/descriptor.ts +263 -0
- package/src/analysis/inheritance.ts +242 -0
- package/src/analysis/param-structure.ts +127 -0
- package/src/analysis/ts-type.ts +88 -0
- package/src/compile.ts +152 -0
- package/src/docs/api-reference.ts +361 -0
- package/src/docs/element-page.ts +290 -0
- package/src/docs/pipeline.ts +182 -0
- package/src/docs/render.ts +191 -0
- package/src/docs/symbol-page.ts +444 -0
- package/src/fingerprint.ts +40 -29
- package/src/gir/ancestry.ts +41 -0
- package/src/gir/callback.ts +25 -22
- package/src/gir/class.ts +31 -57
- package/src/gir/enum.ts +20 -38
- package/src/gir/field.ts +21 -36
- package/src/gir/function.ts +17 -56
- package/src/gir/gir-path.ts +49 -0
- package/src/gir/libraries.ts +77 -0
- package/src/gir/library.ts +248 -0
- package/src/gir/namespace.ts +85 -80
- package/src/gir/parameter.ts +64 -93
- package/src/gir/parse.ts +43 -95
- package/src/gir/primitives.ts +23 -45
- package/src/gir/property.ts +27 -29
- package/src/gir/record.ts +53 -0
- package/src/gir/size.ts +9 -56
- package/src/gir/type-id.ts +49 -0
- package/src/gir/type-ref.ts +35 -140
- package/src/gir/type.ts +16 -0
- package/src/index.ts +20 -15
- package/src/khronos/args.ts +202 -0
- package/src/khronos/jsdoc.ts +76 -0
- package/src/khronos/model.ts +166 -0
- package/src/khronos/modules.ts +75 -0
- package/src/khronos/parse.ts +66 -0
- package/src/khronos/pipeline.ts +234 -0
- package/src/khronos/plan.ts +191 -0
- package/src/khronos/registry/LICENSE +202 -0
- package/src/khronos/registry/gl.xml +47748 -0
- package/src/khronos/render.ts +193 -0
- package/src/khronos/select.ts +67 -0
- package/src/runner.ts +112 -75
- package/src/store/compile-store.ts +49 -0
- package/src/store/gi/async.ts +42 -0
- package/src/store/gi/callables.ts +309 -0
- package/src/store/gi/callback.ts +15 -0
- package/src/store/gi/class-struct-record.ts +40 -0
- package/src/store/gi/class.ts +212 -0
- package/src/store/gi/companion.ts +13 -0
- package/src/store/gi/constant.ts +24 -0
- package/src/store/gi/constructor-props.ts +82 -0
- package/src/store/gi/enum.ts +49 -0
- package/src/store/gi/function.ts +107 -0
- package/src/store/gi/gtype-binding.ts +33 -0
- package/src/store/gi/interface.ts +157 -0
- package/src/store/gi/item-comparators.ts +90 -0
- package/src/store/gi/method.ts +417 -0
- package/src/store/gi/param-marshal.ts +48 -0
- package/src/store/gi/pipeline.ts +85 -0
- package/src/store/gi/properties.ts +39 -0
- package/src/store/gi/property-accessor.ts +194 -0
- package/src/store/gi/record-constructor.ts +87 -0
- package/src/store/gi/record-field-accessor.ts +394 -0
- package/src/store/gi/record-layout.ts +134 -0
- package/src/store/gi/record.ts +66 -0
- package/src/store/gi/registration.ts +38 -0
- package/src/store/gi/return-wrap.ts +52 -0
- package/src/store/gi/runtime-override.ts +36 -0
- package/src/store/gi/signal.ts +310 -0
- package/src/store/gi/vtable.ts +99 -0
- package/src/store/gi-store.ts +79 -0
- package/src/store/jsx-store.ts +27 -0
- package/src/store/react/built-ins.ts +260 -0
- package/src/store/react/element-components.ts +138 -0
- package/src/store/react/element-prop-types.ts +280 -0
- package/src/store/react/element-props.ts +204 -0
- package/src/store/react/gir-index.ts +85 -0
- package/src/store/react/intrinsic-elements.ts +161 -0
- package/src/store/react/jsx.ts +294 -0
- package/src/store/react/metadata.ts +197 -0
- package/src/store/react/pipeline.ts +90 -0
- package/src/store/react/props.ts +197 -0
- package/src/store/store-fs.ts +112 -0
- package/src/writer/context.ts +48 -0
- package/src/writer/doc.ts +11 -0
- package/src/writer/emit.ts +26 -0
- package/src/writer/gtk-doc.ts +74 -0
- package/src/writer/imports.ts +59 -0
- package/src/writer/module.ts +45 -0
- package/LICENSE +0 -373
- package/dist/dsl/context.d.ts +0 -104
- package/dist/dsl/context.d.ts.map +0 -1
- package/dist/dsl/context.js +0 -140
- package/dist/dsl/context.js.map +0 -1
- package/dist/dsl/emit.d.ts +0 -28
- package/dist/dsl/emit.d.ts.map +0 -1
- package/dist/dsl/emit.js +0 -41
- package/dist/dsl/emit.js.map +0 -1
- package/dist/dsl/identifier.d.ts +0 -28
- package/dist/dsl/identifier.d.ts.map +0 -1
- package/dist/dsl/identifier.js +0 -45
- package/dist/dsl/identifier.js.map +0 -1
- package/dist/dsl/imports.d.ts +0 -58
- package/dist/dsl/imports.d.ts.map +0 -1
- package/dist/dsl/imports.js +0 -107
- package/dist/dsl/imports.js.map +0 -1
- package/dist/dsl/module.d.ts +0 -53
- package/dist/dsl/module.d.ts.map +0 -1
- package/dist/dsl/module.js +0 -76
- package/dist/dsl/module.js.map +0 -1
- package/dist/ffi/pipeline.d.ts +0 -19
- package/dist/ffi/pipeline.d.ts.map +0 -1
- package/dist/ffi/pipeline.js +0 -107
- package/dist/ffi/pipeline.js.map +0 -1
- package/dist/gi-store.d.ts +0 -34
- package/dist/gi-store.d.ts.map +0 -1
- package/dist/gi-store.js +0 -154
- package/dist/gi-store.js.map +0 -1
- package/dist/gir/boxed.d.ts +0 -66
- package/dist/gir/boxed.d.ts.map +0 -1
- package/dist/gir/boxed.js +0 -49
- package/dist/gir/boxed.js.map +0 -1
- package/dist/gir/qualified-name.d.ts +0 -37
- package/dist/gir/qualified-name.d.ts.map +0 -1
- package/dist/gir/qualified-name.js +0 -39
- package/dist/gir/qualified-name.js.map +0 -1
- package/dist/gir/qualify.d.ts +0 -32
- package/dist/gir/qualify.d.ts.map +0 -1
- package/dist/gir/qualify.js +0 -60
- package/dist/gir/qualify.js.map +0 -1
- package/dist/gir/repository.d.ts +0 -82
- package/dist/gir/repository.d.ts.map +0 -1
- package/dist/gir/repository.js +0 -122
- package/dist/gir/repository.js.map +0 -1
- package/dist/gir/signal.d.ts +0 -22
- package/dist/gir/signal.d.ts.map +0 -1
- package/dist/gir/signal.js +0 -20
- package/dist/gir/signal.js.map +0 -1
- package/dist/jsx-store.d.ts +0 -22
- package/dist/jsx-store.d.ts.map +0 -1
- package/dist/jsx-store.js +0 -40
- package/dist/jsx-store.js.map +0 -1
- package/dist/react/compounds-meta.d.ts +0 -18
- package/dist/react/compounds-meta.d.ts.map +0 -1
- package/dist/react/compounds-meta.js +0 -93
- package/dist/react/compounds-meta.js.map +0 -1
- package/dist/react/compounds.d.ts +0 -27
- package/dist/react/compounds.d.ts.map +0 -1
- package/dist/react/compounds.js +0 -164
- package/dist/react/compounds.js.map +0 -1
- package/dist/react/internal.d.ts +0 -14
- package/dist/react/internal.d.ts.map +0 -1
- package/dist/react/internal.js +0 -79
- package/dist/react/internal.js.map +0 -1
- package/dist/react/jsx.d.ts +0 -22
- package/dist/react/jsx.d.ts.map +0 -1
- package/dist/react/jsx.js +0 -134
- package/dist/react/jsx.js.map +0 -1
- package/dist/react/pipeline.d.ts +0 -13
- package/dist/react/pipeline.d.ts.map +0 -1
- package/dist/react/pipeline.js +0 -25
- package/dist/react/pipeline.js.map +0 -1
- package/dist/react/props.d.ts +0 -38
- package/dist/react/props.d.ts.map +0 -1
- package/dist/react/props.js +0 -231
- package/dist/react/props.js.map +0 -1
- package/dist/react/slot-props.d.ts +0 -10
- package/dist/react/slot-props.d.ts.map +0 -1
- package/dist/react/slot-props.js +0 -56
- package/dist/react/slot-props.js.map +0 -1
- package/dist/react/widgets.d.ts +0 -83
- package/dist/react/widgets.d.ts.map +0 -1
- package/dist/react/widgets.js +0 -152
- package/dist/react/widgets.js.map +0 -1
- package/dist/store-fs.d.ts +0 -109
- package/dist/store-fs.d.ts.map +0 -1
- package/dist/store-fs.js +0 -98
- package/dist/store-fs.js.map +0 -1
- package/dist/transpile.d.ts +0 -32
- package/dist/transpile.d.ts.map +0 -1
- package/dist/transpile.js +0 -63
- package/dist/transpile.js.map +0 -1
- package/dist/typecheck-store.d.ts +0 -41
- package/dist/typecheck-store.d.ts.map +0 -1
- package/dist/typecheck-store.js +0 -102
- package/dist/typecheck-store.js.map +0 -1
- package/dist/writers/alias.d.ts +0 -13
- package/dist/writers/alias.d.ts.map +0 -1
- package/dist/writers/alias.js +0 -17
- package/dist/writers/alias.js.map +0 -1
- package/dist/writers/async.d.ts +0 -22
- package/dist/writers/async.d.ts.map +0 -1
- package/dist/writers/async.js +0 -48
- package/dist/writers/async.js.map +0 -1
- package/dist/writers/boxed-constructor.d.ts +0 -26
- package/dist/writers/boxed-constructor.d.ts.map +0 -1
- package/dist/writers/boxed-constructor.js +0 -85
- package/dist/writers/boxed-constructor.js.map +0 -1
- package/dist/writers/boxed-field-accessor.d.ts +0 -18
- package/dist/writers/boxed-field-accessor.d.ts.map +0 -1
- package/dist/writers/boxed-field-accessor.js +0 -260
- package/dist/writers/boxed-field-accessor.js.map +0 -1
- package/dist/writers/boxed-layout.d.ts +0 -27
- package/dist/writers/boxed-layout.d.ts.map +0 -1
- package/dist/writers/boxed-layout.js +0 -128
- package/dist/writers/boxed-layout.js.map +0 -1
- package/dist/writers/boxed.d.ts +0 -20
- package/dist/writers/boxed.d.ts.map +0 -1
- package/dist/writers/boxed.js +0 -71
- package/dist/writers/boxed.js.map +0 -1
- package/dist/writers/callables.d.ts +0 -124
- package/dist/writers/callables.d.ts.map +0 -1
- package/dist/writers/callables.js +0 -283
- package/dist/writers/callables.js.map +0 -1
- package/dist/writers/callback.d.ts +0 -16
- package/dist/writers/callback.d.ts.map +0 -1
- package/dist/writers/callback.js +0 -38
- package/dist/writers/callback.js.map +0 -1
- package/dist/writers/class-struct-record.d.ts +0 -31
- package/dist/writers/class-struct-record.d.ts.map +0 -1
- package/dist/writers/class-struct-record.js +0 -67
- package/dist/writers/class-struct-record.js.map +0 -1
- package/dist/writers/class-struct.d.ts +0 -22
- package/dist/writers/class-struct.d.ts.map +0 -1
- package/dist/writers/class-struct.js +0 -85
- package/dist/writers/class-struct.js.map +0 -1
- package/dist/writers/class.d.ts +0 -16
- package/dist/writers/class.d.ts.map +0 -1
- package/dist/writers/class.js +0 -307
- package/dist/writers/class.js.map +0 -1
- package/dist/writers/constant.d.ts +0 -15
- package/dist/writers/constant.d.ts.map +0 -1
- package/dist/writers/constant.js +0 -23
- package/dist/writers/constant.js.map +0 -1
- package/dist/writers/constants.d.ts +0 -15
- package/dist/writers/constants.d.ts.map +0 -1
- package/dist/writers/constants.js +0 -23
- package/dist/writers/constants.js.map +0 -1
- package/dist/writers/constructor-props.d.ts +0 -32
- package/dist/writers/constructor-props.d.ts.map +0 -1
- package/dist/writers/constructor-props.js +0 -110
- package/dist/writers/constructor-props.js.map +0 -1
- package/dist/writers/enum.d.ts +0 -21
- package/dist/writers/enum.d.ts.map +0 -1
- package/dist/writers/enum.js +0 -48
- package/dist/writers/enum.js.map +0 -1
- package/dist/writers/function.d.ts +0 -40
- package/dist/writers/function.d.ts.map +0 -1
- package/dist/writers/function.js +0 -127
- package/dist/writers/function.js.map +0 -1
- package/dist/writers/gtype-binding.d.ts +0 -19
- package/dist/writers/gtype-binding.d.ts.map +0 -1
- package/dist/writers/gtype-binding.js +0 -40
- package/dist/writers/gtype-binding.js.map +0 -1
- package/dist/writers/inheritance.d.ts +0 -48
- package/dist/writers/inheritance.d.ts.map +0 -1
- package/dist/writers/inheritance.js +0 -90
- package/dist/writers/inheritance.js.map +0 -1
- package/dist/writers/interface.d.ts +0 -16
- package/dist/writers/interface.d.ts.map +0 -1
- package/dist/writers/interface.js +0 -155
- package/dist/writers/interface.js.map +0 -1
- package/dist/writers/method.d.ts +0 -150
- package/dist/writers/method.d.ts.map +0 -1
- package/dist/writers/method.js +0 -510
- package/dist/writers/method.js.map +0 -1
- package/dist/writers/param-classify.d.ts +0 -93
- package/dist/writers/param-classify.d.ts.map +0 -1
- package/dist/writers/param-classify.js +0 -163
- package/dist/writers/param-classify.js.map +0 -1
- package/dist/writers/property-accessor.d.ts +0 -19
- package/dist/writers/property-accessor.d.ts.map +0 -1
- package/dist/writers/property-accessor.js +0 -117
- package/dist/writers/property-accessor.js.map +0 -1
- package/dist/writers/registration.d.ts +0 -27
- package/dist/writers/registration.d.ts.map +0 -1
- package/dist/writers/registration.js +0 -30
- package/dist/writers/registration.js.map +0 -1
- package/dist/writers/return-wrap.d.ts +0 -39
- package/dist/writers/return-wrap.d.ts.map +0 -1
- package/dist/writers/return-wrap.js +0 -152
- package/dist/writers/return-wrap.js.map +0 -1
- package/dist/writers/runtime-override.d.ts +0 -18
- package/dist/writers/runtime-override.d.ts.map +0 -1
- package/dist/writers/runtime-override.js.map +0 -1
- package/dist/writers/signal.d.ts +0 -21
- package/dist/writers/signal.d.ts.map +0 -1
- package/dist/writers/signal.js +0 -260
- package/dist/writers/signal.js.map +0 -1
- package/dist/writers/ts-type.d.ts +0 -50
- package/dist/writers/ts-type.d.ts.map +0 -1
- package/dist/writers/ts-type.js +0 -75
- package/dist/writers/ts-type.js.map +0 -1
- package/dist/writers/types-ts.d.ts +0 -27
- package/dist/writers/types-ts.d.ts.map +0 -1
- package/dist/writers/types-ts.js +0 -97
- package/dist/writers/types-ts.js.map +0 -1
- package/dist/writers/value.d.ts +0 -89
- package/dist/writers/value.d.ts.map +0 -1
- package/dist/writers/value.js +0 -402
- package/dist/writers/value.js.map +0 -1
- package/src/dsl/context.ts +0 -146
- package/src/dsl/emit.ts +0 -42
- package/src/dsl/identifier.ts +0 -52
- package/src/dsl/imports.ts +0 -109
- package/src/dsl/module.ts +0 -75
- package/src/ffi/pipeline.ts +0 -113
- package/src/gi-store.ts +0 -199
- package/src/gir/boxed.ts +0 -94
- package/src/gir/qualified-name.ts +0 -55
- package/src/gir/qualify.ts +0 -64
- package/src/gir/repository.ts +0 -149
- package/src/gir/signal.ts +0 -36
- package/src/jsx-store.ts +0 -53
- package/src/react/compounds-meta.ts +0 -99
- package/src/react/compounds.ts +0 -204
- package/src/react/internal.ts +0 -91
- package/src/react/jsx.ts +0 -155
- package/src/react/pipeline.ts +0 -29
- package/src/react/props.ts +0 -307
- package/src/react/slot-props.ts +0 -57
- package/src/react/widgets.ts +0 -185
- package/src/store-fs.ts +0 -157
- package/src/transpile.ts +0 -80
- package/src/typecheck-store.ts +0 -136
- package/src/writers/alias.ts +0 -19
- package/src/writers/async.ts +0 -44
- package/src/writers/boxed-constructor.ts +0 -105
- package/src/writers/boxed-field-accessor.ts +0 -306
- package/src/writers/boxed-layout.ts +0 -166
- package/src/writers/boxed.ts +0 -77
- package/src/writers/callables.ts +0 -339
- package/src/writers/callback.ts +0 -40
- package/src/writers/class-struct-record.ts +0 -75
- package/src/writers/class-struct.ts +0 -96
- package/src/writers/class.ts +0 -384
- package/src/writers/constant.ts +0 -29
- package/src/writers/constructor-props.ts +0 -130
- package/src/writers/enum.ts +0 -53
- package/src/writers/function.ts +0 -136
- package/src/writers/gtype-binding.ts +0 -48
- package/src/writers/inheritance.ts +0 -104
- package/src/writers/interface.ts +0 -168
- package/src/writers/method.ts +0 -678
- package/src/writers/param-classify.ts +0 -178
- package/src/writers/property-accessor.ts +0 -139
- package/src/writers/registration.ts +0 -42
- package/src/writers/return-wrap.ts +0 -180
- package/src/writers/runtime-override.ts +0 -59
- package/src/writers/signal.ts +0 -318
- package/src/writers/ts-type.ts +0 -115
- package/src/writers/value.ts +0 -485
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import { sortStringsBy, toPascalCase } from "@gtkx/utils";
|
|
2
|
+
import { reservedSignalMemberRename } from "../analysis/inheritance.js";
|
|
3
|
+
import { renderTsType } from "../analysis/ts-type.js";
|
|
4
|
+
import { ancestorChain } from "../gir/ancestry.js";
|
|
5
|
+
import { callbackAsFunction, type GirCallback } from "../gir/callback.js";
|
|
6
|
+
import type { GirClass } from "../gir/class.js";
|
|
7
|
+
import type { GirEnum } from "../gir/enum.js";
|
|
8
|
+
import type { GirFunction } from "../gir/function.js";
|
|
9
|
+
import type { Library } from "../gir/library.js";
|
|
10
|
+
import { type GirAlias, type GirConstant, type GirNamespace, namespaceDirectory } from "../gir/namespace.js";
|
|
11
|
+
import { PRIMITIVE_TS_TYPE, primitiveCategory } from "../gir/primitives.js";
|
|
12
|
+
import type { GirProperty } from "../gir/property.js";
|
|
13
|
+
import type { GirRecord } from "../gir/record.js";
|
|
14
|
+
import {
|
|
15
|
+
dedupeCallables,
|
|
16
|
+
indexMethodsByName,
|
|
17
|
+
matchStaticFinishFunction,
|
|
18
|
+
renderInstanceMethodSignature,
|
|
19
|
+
renderStaticSignature,
|
|
20
|
+
} from "../store/gi/callables.js";
|
|
21
|
+
import { constantLiteral } from "../store/gi/constant.js";
|
|
22
|
+
import { enumMemberKey } from "../store/gi/enum.js";
|
|
23
|
+
import {
|
|
24
|
+
methodExportName,
|
|
25
|
+
renderMethodReturnType,
|
|
26
|
+
renderMethodSignature,
|
|
27
|
+
renderPromisifiedSignature,
|
|
28
|
+
} from "../store/gi/method.js";
|
|
29
|
+
import { type ResolvedAccessor, resolveAccessor } from "../store/gi/property-accessor.js";
|
|
30
|
+
import { resolveRecordFieldEntry } from "../store/gi/record-field-accessor.js";
|
|
31
|
+
import { computeRecordFieldSlots } from "../store/gi/record-layout.js";
|
|
32
|
+
import { implementedInterfaces, newlyImplementedInterfaces } from "../store/react/intrinsic-elements.js";
|
|
33
|
+
import type { ModuleContext } from "../writer/context.js";
|
|
34
|
+
import {
|
|
35
|
+
classMethodEntries,
|
|
36
|
+
docMarkdown,
|
|
37
|
+
docsDefaultValue,
|
|
38
|
+
docsSignatureContext,
|
|
39
|
+
firstSentence,
|
|
40
|
+
joinSections,
|
|
41
|
+
metaBlock,
|
|
42
|
+
methodsSectionBlocks,
|
|
43
|
+
originSignatureBlocks,
|
|
44
|
+
renderDocsSignalHandlerType,
|
|
45
|
+
renderDocsType,
|
|
46
|
+
type SignatureEntry,
|
|
47
|
+
signatureBlock,
|
|
48
|
+
} from "./render.js";
|
|
49
|
+
|
|
50
|
+
type GiSymbolBase = {
|
|
51
|
+
namespace: GirNamespace;
|
|
52
|
+
name: string;
|
|
53
|
+
doc: string | undefined;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type GiSymbolEntry =
|
|
57
|
+
| (GiSymbolBase & { kind: "class" | "interface"; klass: GirClass })
|
|
58
|
+
| (GiSymbolBase & { kind: "record"; record: GirRecord })
|
|
59
|
+
| (GiSymbolBase & { kind: "enum"; enumeration: GirEnum })
|
|
60
|
+
| (GiSymbolBase & { kind: "callback"; callback: GirCallback })
|
|
61
|
+
| (GiSymbolBase & { kind: "alias"; alias: GirAlias })
|
|
62
|
+
| (GiSymbolBase & { kind: "function"; fn: GirFunction })
|
|
63
|
+
| (GiSymbolBase & { kind: "constant"; constant: GirConstant });
|
|
64
|
+
|
|
65
|
+
export type SymbolPageOptions = {
|
|
66
|
+
library: Library;
|
|
67
|
+
elementNameFor: (namespaceName: string, className: string) => string | undefined;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const qualifiedName = (entry: GiSymbolBase): string => `${entry.namespace.name}.${entry.name}`;
|
|
71
|
+
|
|
72
|
+
const frontmatter = (entry: GiSymbolBase, kindLabel: string): string => {
|
|
73
|
+
const sentence = firstSentence(entry.doc);
|
|
74
|
+
const description = sentence.length > 0 ? sentence : `API reference for the ${qualifiedName(entry)} ${kindLabel}.`;
|
|
75
|
+
return `---\ndescription: ${JSON.stringify(description)}\n---`;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const kindLine = (kindLabel: string, namespace: GirNamespace): string =>
|
|
79
|
+
`\`${kindLabel}\` in \`@gtkx/gi/${namespaceDirectory(namespace)}\``;
|
|
80
|
+
|
|
81
|
+
const importBlock = (entry: GiSymbolBase): string =>
|
|
82
|
+
`\`\`\`ts\nimport * as ${entry.namespace.name} from "@gtkx/gi/${namespaceDirectory(entry.namespace)}";\n\`\`\``;
|
|
83
|
+
|
|
84
|
+
const pageHeader = (entry: GiSymbolEntry, kindLabel: string): string[] => [
|
|
85
|
+
frontmatter(entry, kindLabel),
|
|
86
|
+
`# ${qualifiedName(entry)}`,
|
|
87
|
+
kindLine(kindLabel, entry.namespace),
|
|
88
|
+
docMarkdown(entry.doc),
|
|
89
|
+
importBlock(entry),
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
const qualifiedClassName = (namespaceName: string, className: string): string =>
|
|
93
|
+
`${namespaceName}.${toPascalCase(className)}`;
|
|
94
|
+
|
|
95
|
+
const elementNote = (entry: GiSymbolBase & { klass: GirClass }, options: SymbolPageOptions): string[] => {
|
|
96
|
+
const glibName = options.elementNameFor(entry.namespace.name, entry.klass.name);
|
|
97
|
+
if (glibName === undefined) return [];
|
|
98
|
+
return [
|
|
99
|
+
`Also available as the \`${glibName}\` JSX element from \`@gtkx/jsx/${namespaceDirectory(entry.namespace)}\`; the \`${glibName}\` element page documents the JSX props.`,
|
|
100
|
+
];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const hierarchySection = (entry: GiSymbolBase & { klass: GirClass }, library: Library): string[] => {
|
|
104
|
+
const ancestors = [...ancestorChain(library, entry.klass, entry.namespace.name)].slice(1).reverse();
|
|
105
|
+
const interfaces = implementedInterfaces(entry.klass, entry.namespace, library).map((iface) =>
|
|
106
|
+
qualifiedClassName(iface.namespace.name, iface.klass.name),
|
|
107
|
+
);
|
|
108
|
+
if (ancestors.length === 0 && interfaces.length === 0) return [];
|
|
109
|
+
const lines = ["## Hierarchy"];
|
|
110
|
+
if (ancestors.length > 0) {
|
|
111
|
+
const parts = ancestors.map(
|
|
112
|
+
(ancestor) => `\`${qualifiedClassName(ancestor.namespaceName, ancestor.klass.name)}\``,
|
|
113
|
+
);
|
|
114
|
+
parts.push(`**${qualifiedName(entry)}**`);
|
|
115
|
+
lines.push(parts.join(" → "));
|
|
116
|
+
}
|
|
117
|
+
if (interfaces.length > 0) {
|
|
118
|
+
lines.push(`Implements ${interfaces.map((name) => `\`${name}\``).join(", ")}.`);
|
|
119
|
+
}
|
|
120
|
+
return lines;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const prerequisitesLine = (entry: GiSymbolBase & { klass: GirClass }, library: Library): string[] => {
|
|
124
|
+
const names = entry.klass.prerequisites.map((name) => {
|
|
125
|
+
const resolved = library.resolveType(entry.namespace.name, name);
|
|
126
|
+
if (resolved === undefined || (resolved.kind !== "class" && resolved.kind !== "interface")) {
|
|
127
|
+
return `\`${name}\``;
|
|
128
|
+
}
|
|
129
|
+
return `\`${qualifiedClassName(resolved.namespace.name, resolved.value.name)}\``;
|
|
130
|
+
});
|
|
131
|
+
if (names.length === 0) return [];
|
|
132
|
+
return [`Requires ${names.join(", ")}.`];
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
type StaticSectionOptions = {
|
|
136
|
+
title: string;
|
|
137
|
+
intro: string;
|
|
138
|
+
context: ModuleContext;
|
|
139
|
+
callables: GirFunction[];
|
|
140
|
+
siblings: GirFunction[];
|
|
141
|
+
returnTypeOverride?: string;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const staticSection = (options: StaticSectionOptions): string[] => {
|
|
145
|
+
const rendered: { name: string; block: string }[] = [];
|
|
146
|
+
for (const callable of dedupeCallables(options.callables)) {
|
|
147
|
+
const signature = renderStaticSignature(options.context, callable, {
|
|
148
|
+
returnTypeOverride: options.returnTypeOverride,
|
|
149
|
+
siblings: options.siblings,
|
|
150
|
+
});
|
|
151
|
+
if (signature === undefined) continue;
|
|
152
|
+
rendered.push({
|
|
153
|
+
name: signature.name,
|
|
154
|
+
block: signatureBlock(signature.name, signature.signature, [docMarkdown(callable.doc)]),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (rendered.length === 0) return [];
|
|
158
|
+
return [options.title, options.intro, ...sortStringsBy(rendered, (item) => item.name).map((item) => item.block)];
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
type MemberOwner = {
|
|
162
|
+
klass: GirClass;
|
|
163
|
+
namespace: GirNamespace;
|
|
164
|
+
origin: string | undefined;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const memberOwners = (entry: GiSymbolBase & { klass: GirClass }, library: Library): MemberOwner[] => [
|
|
168
|
+
{ klass: entry.klass, namespace: entry.namespace, origin: undefined },
|
|
169
|
+
...newlyImplementedInterfaces(entry.klass, entry.namespace, library).map((iface) => ({
|
|
170
|
+
klass: iface.klass,
|
|
171
|
+
namespace: iface.namespace,
|
|
172
|
+
origin: qualifiedClassName(iface.namespace.name, iface.klass.name),
|
|
173
|
+
})),
|
|
174
|
+
];
|
|
175
|
+
|
|
176
|
+
const interfaceMethodNames = (library: Library, owner: MemberOwner): string[] => {
|
|
177
|
+
const context = docsSignatureContext(owner.namespace, library);
|
|
178
|
+
const className = toPascalCase(owner.klass.name);
|
|
179
|
+
const methods = dedupeCallables(owner.klass.methods);
|
|
180
|
+
const methodByName = indexMethodsByName(methods);
|
|
181
|
+
const names: string[] = [];
|
|
182
|
+
for (const callable of methods) {
|
|
183
|
+
const rename = reservedSignalMemberRename(className, callable);
|
|
184
|
+
const rendered = renderInstanceMethodSignature(context, { ...callable, doc: undefined }, methodByName, rename);
|
|
185
|
+
if (rendered === undefined) continue;
|
|
186
|
+
names.push(rename ?? methodExportName(callable));
|
|
187
|
+
}
|
|
188
|
+
return names;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
type PropertyAccessorSetup = {
|
|
192
|
+
context: ModuleContext;
|
|
193
|
+
claimedNames: Set<string>;
|
|
194
|
+
methodByName: Map<string, GirFunction>;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const propertyAccessorSetup = (
|
|
198
|
+
owner: MemberOwner,
|
|
199
|
+
library: Library,
|
|
200
|
+
useClassRenames: boolean,
|
|
201
|
+
): PropertyAccessorSetup => {
|
|
202
|
+
const claimedNames = new Set(
|
|
203
|
+
useClassRenames
|
|
204
|
+
? classMethodEntries(library, owner.namespace, owner.klass).map((item) => item.name)
|
|
205
|
+
: interfaceMethodNames(library, owner),
|
|
206
|
+
);
|
|
207
|
+
return {
|
|
208
|
+
context: docsSignatureContext(owner.namespace, library),
|
|
209
|
+
claimedNames,
|
|
210
|
+
methodByName: indexMethodsByName(dedupeCallables(owner.klass.methods)),
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const propertyMeta = (property: GirProperty, accessor: ResolvedAccessor, origin: string | undefined): string => {
|
|
215
|
+
const meta: string[] = [`\`${accessor.tsType}\``];
|
|
216
|
+
if (property.defaultValue !== undefined) meta.push(`default \`${docsDefaultValue(property.defaultValue)}\``);
|
|
217
|
+
if (property.constructOnly) meta.push("construct-only");
|
|
218
|
+
if (!accessor.writable) meta.push("read-only");
|
|
219
|
+
else if (!accessor.hasGetter) meta.push("write-only");
|
|
220
|
+
if (origin !== undefined) meta.push(`from \`${origin}\``);
|
|
221
|
+
return meta.join(" · ");
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const propertiesSection = (
|
|
225
|
+
entry: GiSymbolBase & { kind: "class" | "interface"; klass: GirClass },
|
|
226
|
+
library: Library,
|
|
227
|
+
): string[] => {
|
|
228
|
+
const seen = new Set<string>();
|
|
229
|
+
const entries: { name: string; meta: string; doc: string }[] = [];
|
|
230
|
+
for (const [index, owner] of memberOwners(entry, library).entries()) {
|
|
231
|
+
const setup = propertyAccessorSetup(owner, library, index === 0 && entry.kind === "class");
|
|
232
|
+
for (const property of owner.klass.properties) {
|
|
233
|
+
const accessor = resolveAccessor({
|
|
234
|
+
context: setup.context,
|
|
235
|
+
property,
|
|
236
|
+
claimedNames: setup.claimedNames,
|
|
237
|
+
methodByName: setup.methodByName,
|
|
238
|
+
});
|
|
239
|
+
if (accessor === undefined || seen.has(accessor.jsName)) continue;
|
|
240
|
+
seen.add(accessor.jsName);
|
|
241
|
+
entries.push({
|
|
242
|
+
name: accessor.jsName,
|
|
243
|
+
meta: propertyMeta(property, accessor, owner.origin),
|
|
244
|
+
doc: docMarkdown(property.doc),
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (entries.length === 0) return [];
|
|
249
|
+
const intro = `Properties are read and written as instance fields; changes can be observed with \`connect("notify::<property-name>", handler)\`. Properties inherited from ancestors are documented on their own pages.`;
|
|
250
|
+
const blocks = sortStringsBy(entries, (item) => item.name).map((item) => metaBlock(item.name, item.meta, item.doc));
|
|
251
|
+
return ["## Properties", intro, ...blocks];
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
const signalsSection = (entry: GiSymbolBase & { klass: GirClass }, library: Library): string[] => {
|
|
255
|
+
const seen = new Set<string>();
|
|
256
|
+
const entries: { name: string; signature: string; doc: string; origin: string | undefined }[] = [];
|
|
257
|
+
for (const owner of memberOwners(entry, library)) {
|
|
258
|
+
for (const signal of owner.klass.signals) {
|
|
259
|
+
if (seen.has(signal.name)) continue;
|
|
260
|
+
seen.add(signal.name);
|
|
261
|
+
entries.push({
|
|
262
|
+
name: signal.name,
|
|
263
|
+
signature: renderDocsSignalHandlerType(library, signal),
|
|
264
|
+
doc: docMarkdown(signal.doc),
|
|
265
|
+
origin: owner.origin,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (entries.length === 0) return [];
|
|
270
|
+
const intro = `Connect with \`instance.connect("<signal>", handler)\` or \`instance.on("<signal>", handler)\`. Signals inherited from ancestors are documented on their own pages.`;
|
|
271
|
+
return ["## Signals", intro, ...originSignatureBlocks(entries)];
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
const classMethodsSection = (entry: GiSymbolBase & { klass: GirClass }, library: Library): string[] =>
|
|
275
|
+
methodsSectionBlocks(
|
|
276
|
+
classMethodEntries(library, entry.namespace, entry.klass),
|
|
277
|
+
"Methods are called on instances. Methods inherited from ancestors are documented on their own pages.",
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
const classPage = (
|
|
281
|
+
entry: GiSymbolBase & { kind: "class" | "interface"; klass: GirClass },
|
|
282
|
+
options: SymbolPageOptions,
|
|
283
|
+
): string => {
|
|
284
|
+
const { library } = options;
|
|
285
|
+
const qualified = qualifiedName(entry);
|
|
286
|
+
const docsContext = docsSignatureContext(entry.namespace, library);
|
|
287
|
+
const constructorsIntro = `Constructors are called on the class: \`${qualified}.new(...)\`.`;
|
|
288
|
+
const staticIntro = `Static methods are called on the class: \`${qualified}.<method>(...)\`.`;
|
|
289
|
+
const staticSiblings = [...entry.klass.constructors, ...entry.klass.functions];
|
|
290
|
+
return joinSections([
|
|
291
|
+
...pageHeader(entry, entry.kind),
|
|
292
|
+
...elementNote(entry, options),
|
|
293
|
+
...(entry.kind === "interface" ? prerequisitesLine(entry, library) : hierarchySection(entry, library)),
|
|
294
|
+
...staticSection({
|
|
295
|
+
title: "## Constructors",
|
|
296
|
+
intro: constructorsIntro,
|
|
297
|
+
context: docsContext,
|
|
298
|
+
callables: entry.klass.constructors,
|
|
299
|
+
siblings: staticSiblings,
|
|
300
|
+
returnTypeOverride: qualified,
|
|
301
|
+
}),
|
|
302
|
+
...staticSection({
|
|
303
|
+
title: "## Static methods",
|
|
304
|
+
intro: staticIntro,
|
|
305
|
+
context: docsContext,
|
|
306
|
+
callables: entry.klass.functions,
|
|
307
|
+
siblings: staticSiblings,
|
|
308
|
+
}),
|
|
309
|
+
...propertiesSection(entry, library),
|
|
310
|
+
...signalsSection(entry, library),
|
|
311
|
+
...classMethodsSection(entry, library),
|
|
312
|
+
]);
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
export const renderSymbolPage = (entry: GiSymbolEntry, options: SymbolPageOptions): string => {
|
|
316
|
+
switch (entry.kind) {
|
|
317
|
+
case "class":
|
|
318
|
+
case "interface":
|
|
319
|
+
return classPage(entry, options);
|
|
320
|
+
case "record":
|
|
321
|
+
return recordPage(entry, options.library);
|
|
322
|
+
case "enum":
|
|
323
|
+
return enumPage(entry);
|
|
324
|
+
case "callback":
|
|
325
|
+
return callbackPage(entry, options.library);
|
|
326
|
+
case "alias":
|
|
327
|
+
return aliasPage(entry, options.library);
|
|
328
|
+
case "function":
|
|
329
|
+
return functionPage(entry, options.library);
|
|
330
|
+
case "constant":
|
|
331
|
+
return constantPage(entry, options.library);
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
const recordInstanceEntries = (context: ModuleContext, record: GirRecord): SignatureEntry[] => {
|
|
336
|
+
const entries: SignatureEntry[] = [];
|
|
337
|
+
for (const callable of dedupeCallables(record.methods)) {
|
|
338
|
+
const rendered = renderStaticSignature(context, callable);
|
|
339
|
+
if (rendered === undefined) continue;
|
|
340
|
+
entries.push({ name: rendered.name, signature: rendered.signature, doc: docMarkdown(callable.doc) });
|
|
341
|
+
}
|
|
342
|
+
return sortStringsBy(entries, (item) => item.name);
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
const recordPage = (entry: GiSymbolBase & { kind: "record"; record: GirRecord }, library: Library): string => {
|
|
346
|
+
const docsContext = docsSignatureContext(entry.namespace, library);
|
|
347
|
+
const qualified = qualifiedName(entry);
|
|
348
|
+
const constructorsIntro = `Constructors are called on the class: \`${qualified}.new(...)\`.`;
|
|
349
|
+
const staticIntro = `Static methods are called on the class: \`${qualified}.<method>(...)\`.`;
|
|
350
|
+
const methodEntries = recordInstanceEntries(docsContext, entry.record);
|
|
351
|
+
const claimedNames = new Set(methodEntries.map((item) => item.name));
|
|
352
|
+
const staticSiblings = [...entry.record.constructors, ...entry.record.functions];
|
|
353
|
+
return joinSections([
|
|
354
|
+
...pageHeader(entry, entry.record.isUnion ? "union" : "record"),
|
|
355
|
+
...staticSection({
|
|
356
|
+
title: "## Constructors",
|
|
357
|
+
intro: constructorsIntro,
|
|
358
|
+
context: docsContext,
|
|
359
|
+
callables: entry.record.constructors,
|
|
360
|
+
siblings: staticSiblings,
|
|
361
|
+
returnTypeOverride: qualified,
|
|
362
|
+
}),
|
|
363
|
+
...staticSection({
|
|
364
|
+
title: "## Static methods",
|
|
365
|
+
intro: staticIntro,
|
|
366
|
+
context: docsContext,
|
|
367
|
+
callables: entry.record.functions,
|
|
368
|
+
siblings: staticSiblings,
|
|
369
|
+
}),
|
|
370
|
+
...fieldsSection(entry.record, docsContext, claimedNames),
|
|
371
|
+
...methodsSectionBlocks(methodEntries, "Methods are called on instances."),
|
|
372
|
+
]);
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
const fieldsSection = (record: GirRecord, context: ModuleContext, claimedNames: Set<string>): string[] => {
|
|
376
|
+
const { slots } = computeRecordFieldSlots(context, record.fields, record.isUnion);
|
|
377
|
+
const entries: { name: string; meta: string; doc: string }[] = [];
|
|
378
|
+
for (const slot of slots) {
|
|
379
|
+
const field = resolveRecordFieldEntry(context, slot, claimedNames);
|
|
380
|
+
if (field === undefined) continue;
|
|
381
|
+
entries.push({
|
|
382
|
+
name: field.jsName,
|
|
383
|
+
meta: [`\`${field.tsType}\``, ...(field.writable ? [] : ["read-only"])].join(" · "),
|
|
384
|
+
doc: docMarkdown(field.doc),
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
if (entries.length === 0) return [];
|
|
388
|
+
const blocks = sortStringsBy(entries, (item) => item.name).map((item) => metaBlock(item.name, item.meta, item.doc));
|
|
389
|
+
return ["## Fields", ...blocks];
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
const enumPage = (entry: GiSymbolBase & { kind: "enum"; enumeration: GirEnum }): string => {
|
|
393
|
+
const { enumeration } = entry;
|
|
394
|
+
const kindLabel = enumeration.errorDomain !== undefined ? "error domain" : enumeration.kind;
|
|
395
|
+
const qualified = qualifiedName(entry);
|
|
396
|
+
const rows = enumeration.members.map((member) => {
|
|
397
|
+
const description = firstSentence(member.doc).replaceAll("|", "\\|");
|
|
398
|
+
return `| \`${enumMemberKey(member.name)}\` | \`${member.value}\` | ${description} |`;
|
|
399
|
+
});
|
|
400
|
+
const usage =
|
|
401
|
+
enumeration.errorDomain !== undefined
|
|
402
|
+
? `Members are error codes for the \`${enumeration.errorDomain}\` GError domain, accessed as \`${qualified}.<member>\`.`
|
|
403
|
+
: `Members are accessed as \`${qualified}.<member>\`.`;
|
|
404
|
+
const table = ["| Member | Value | Description |", "| --- | --- | --- |", ...rows].join("\n");
|
|
405
|
+
return joinSections([...pageHeader(entry, kindLabel), "## Members", usage, table]);
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
const callbackPage = (entry: GiSymbolBase & { kind: "callback"; callback: GirCallback }, library: Library): string => {
|
|
409
|
+
const docsContext = docsSignatureContext(entry.namespace, library);
|
|
410
|
+
const fn = callbackAsFunction(entry.callback);
|
|
411
|
+
const signature = `type ${entry.name} = (${renderMethodSignature(docsContext, fn)}) => ${renderMethodReturnType(docsContext, fn)}`;
|
|
412
|
+
return joinSections([...pageHeader(entry, "callback"), "## Signature", `\`\`\`ts\n${signature}\n\`\`\``]);
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
const aliasPage = (entry: GiSymbolBase & { kind: "alias"; alias: GirAlias }, library: Library): string => {
|
|
416
|
+
const docsContext = docsSignatureContext(entry.namespace, library);
|
|
417
|
+
const category = entry.alias.cType === undefined ? undefined : primitiveCategory(entry.alias.cType);
|
|
418
|
+
const target = category === "gtype" ? PRIMITIVE_TS_TYPE.gtype : renderTsType(docsContext, entry.alias.target);
|
|
419
|
+
return joinSections([...pageHeader(entry, "alias"), `\`\`\`ts\ntype ${entry.name} = ${target}\n\`\`\``]);
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
const functionSignature = (context: ModuleContext, name: string, fn: GirFunction, siblings: GirFunction[]): string => {
|
|
423
|
+
const finishFn = matchStaticFinishFunction(context, fn, siblings);
|
|
424
|
+
if (finishFn !== undefined) {
|
|
425
|
+
const { signature, returnType } = renderPromisifiedSignature(context, fn, finishFn);
|
|
426
|
+
return `function ${name}(${signature}): ${returnType}`;
|
|
427
|
+
}
|
|
428
|
+
return `function ${name}(${renderMethodSignature(context, fn)}): ${renderMethodReturnType(context, fn)}`;
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
const functionPage = (entry: GiSymbolBase & { kind: "function"; fn: GirFunction }, library: Library): string => {
|
|
432
|
+
const docsContext = docsSignatureContext(entry.namespace, library);
|
|
433
|
+
const signature = functionSignature(docsContext, entry.name, entry.fn, entry.namespace.functions);
|
|
434
|
+
return joinSections([...pageHeader(entry, "function"), `\`\`\`ts\n${signature}\n\`\`\``]);
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
const constantPage = (entry: GiSymbolBase & { kind: "constant"; constant: GirConstant }, library: Library): string => {
|
|
438
|
+
const docsContext = docsSignatureContext(entry.namespace, library);
|
|
439
|
+
const type = renderDocsType(library, entry.constant.type, false);
|
|
440
|
+
return joinSections([
|
|
441
|
+
...pageHeader(entry, "constant"),
|
|
442
|
+
`\`\`\`ts\nconst ${entry.name}: ${type} = ${constantLiteral(docsContext, entry.constant)}\n\`\`\``,
|
|
443
|
+
]);
|
|
444
|
+
};
|
package/src/fingerprint.ts
CHANGED
|
@@ -1,46 +1,34 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import type { ElementProp } from "@gtkx/config";
|
|
6
|
+
import { sortStrings } from "@gtkx/utils";
|
|
4
7
|
|
|
5
8
|
const require = createRequire(import.meta.url);
|
|
6
9
|
|
|
7
|
-
/** Filename of the staleness sentinel written into the `@gtkx/gi` store root. */
|
|
8
10
|
export const FINGERPRINT_FILENAME = ".codegen-fingerprint.json";
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
* The `@gtkx/codegen` package version, mixed into the store fingerprint so a
|
|
12
|
-
* codegen upgrade invalidates a previously-generated store.
|
|
13
|
-
*/
|
|
14
|
-
export const CODEGEN_VERSION: string = (require("../package.json") as { version: string }).version;
|
|
12
|
+
const CODEGEN_VERSION: string = (require("../package.json") as { version: string }).version;
|
|
15
13
|
|
|
16
|
-
/**
|
|
17
|
-
* The staleness sentinel written into the generated `@gtkx/gi` store: the
|
|
18
|
-
* fingerprint value plus the inputs that produced it, so a consumer can
|
|
19
|
-
* recompute and compare without reloading the GIR repository.
|
|
20
|
-
*/
|
|
21
14
|
export type CodegenFingerprint = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
readonly girFiles: readonly string[];
|
|
26
|
-
/** The resolved `Name-Version` library identifiers the store was built for. */
|
|
27
|
-
readonly libraries: readonly string[];
|
|
15
|
+
value: string;
|
|
16
|
+
girFiles: string[];
|
|
17
|
+
libraries: string[];
|
|
28
18
|
};
|
|
29
19
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* @param girFiles - Absolute paths of the loaded `.gir` files
|
|
36
|
-
* @param libraries - The resolved `Name-Version` library identifiers
|
|
37
|
-
*/
|
|
38
|
-
export const computeFingerprint = (girFiles: readonly string[], libraries: readonly string[]): string => {
|
|
20
|
+
export const computeFingerprint = (
|
|
21
|
+
girFiles: string[],
|
|
22
|
+
libraries: string[],
|
|
23
|
+
elementProps: Record<string, ElementProp[]>,
|
|
24
|
+
): string => {
|
|
39
25
|
const hash = createHash("sha256");
|
|
40
26
|
hash.update(CODEGEN_VERSION);
|
|
41
27
|
hash.update("\n");
|
|
42
|
-
hash.update(
|
|
43
|
-
|
|
28
|
+
hash.update(JSON.stringify(elementProps));
|
|
29
|
+
hash.update("\n");
|
|
30
|
+
hash.update(sortStrings(libraries).join(","));
|
|
31
|
+
for (const file of sortStrings(girFiles)) {
|
|
44
32
|
hash.update("\n");
|
|
45
33
|
hash.update(file);
|
|
46
34
|
hash.update("\0");
|
|
@@ -48,3 +36,26 @@ export const computeFingerprint = (girFiles: readonly string[], libraries: reado
|
|
|
48
36
|
}
|
|
49
37
|
return hash.digest("hex");
|
|
50
38
|
};
|
|
39
|
+
|
|
40
|
+
const sortAlpha = (values: string[]): string => sortStrings(values).join(",");
|
|
41
|
+
|
|
42
|
+
export const isStoreFresh = (
|
|
43
|
+
giStoreDir: string,
|
|
44
|
+
libraries: string[],
|
|
45
|
+
elementProps: Record<string, ElementProp[]>,
|
|
46
|
+
): boolean => {
|
|
47
|
+
const sentinelPath = join(giStoreDir, FINGERPRINT_FILENAME);
|
|
48
|
+
if (!existsSync(sentinelPath)) return false;
|
|
49
|
+
let sentinel: CodegenFingerprint;
|
|
50
|
+
try {
|
|
51
|
+
sentinel = JSON.parse(readFileSync(sentinelPath, "utf8")) as CodegenFingerprint;
|
|
52
|
+
} catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
if (sortAlpha(sentinel.libraries) !== sortAlpha(libraries)) return false;
|
|
56
|
+
try {
|
|
57
|
+
return computeFingerprint(sentinel.girFiles, sentinel.libraries, elementProps) === sentinel.value;
|
|
58
|
+
} catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { GirClass } from "./class.js";
|
|
2
|
+
import type { Library } from "./library.js";
|
|
3
|
+
|
|
4
|
+
export type ResolvedAncestor = {
|
|
5
|
+
klass: GirClass;
|
|
6
|
+
namespaceName: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const resolveClassOrInterface = (
|
|
10
|
+
library: Library,
|
|
11
|
+
defaultNamespace: string,
|
|
12
|
+
name: string,
|
|
13
|
+
): ResolvedAncestor | undefined => {
|
|
14
|
+
const resolved = library.resolveType(defaultNamespace, name);
|
|
15
|
+
if (resolved === undefined) return undefined;
|
|
16
|
+
if (resolved.kind !== "class" && resolved.kind !== "interface") return undefined;
|
|
17
|
+
return { klass: resolved.value, namespaceName: resolved.namespace.name };
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const resolveInterface = (
|
|
21
|
+
library: Library,
|
|
22
|
+
defaultNamespace: string,
|
|
23
|
+
name: string,
|
|
24
|
+
): ResolvedAncestor | undefined => {
|
|
25
|
+
const resolved = library.resolveType(defaultNamespace, name);
|
|
26
|
+
if (resolved?.kind !== "interface") return undefined;
|
|
27
|
+
return { klass: resolved.value, namespaceName: resolved.namespace.name };
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export function* ancestorChain(library: Library, klass: GirClass, namespaceName: string): Generator<ResolvedAncestor> {
|
|
31
|
+
const visited = new Set<string>();
|
|
32
|
+
let current: ResolvedAncestor | undefined = { klass, namespaceName };
|
|
33
|
+
while (current !== undefined) {
|
|
34
|
+
const key = `${current.namespaceName}.${current.klass.name}`;
|
|
35
|
+
if (visited.has(key)) return;
|
|
36
|
+
visited.add(key);
|
|
37
|
+
yield current;
|
|
38
|
+
if (current.klass.parent === undefined) return;
|
|
39
|
+
current = resolveClassOrInterface(library, current.namespaceName, current.klass.parent);
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/gir/callback.ts
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import type { GirFunction } from "./function.js";
|
|
2
|
+
import { type GirParameter, type GirReturnValue, parseCallable } from "./parameter.js";
|
|
3
|
+
import { attrBool, type RawNode } from "./parse.js";
|
|
4
|
+
import type { ParseContext } from "./type-id.js";
|
|
3
5
|
|
|
4
|
-
/** A `<callback>` declaration (top-level inside a namespace or nested in a field). */
|
|
5
6
|
export type GirCallback = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
name: string;
|
|
8
|
+
doc: string | undefined;
|
|
9
|
+
parameters: GirParameter[];
|
|
10
|
+
returnValue: GirReturnValue;
|
|
11
|
+
introspectable: boolean;
|
|
11
12
|
};
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
export const callbackFromNode = (node: RawNode, context: ParseContext): GirCallback => ({
|
|
15
|
+
...parseCallable(node, context),
|
|
16
|
+
introspectable: attrBool(node, "introspectable", true),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const callbackAsFunction = (callback: GirCallback): GirFunction => ({
|
|
20
|
+
name: callback.name,
|
|
21
|
+
doc: callback.doc,
|
|
22
|
+
cIdentifier: undefined,
|
|
23
|
+
throws: false,
|
|
24
|
+
introspectable: callback.introspectable,
|
|
25
|
+
shadowedBy: undefined,
|
|
26
|
+
instance: undefined,
|
|
27
|
+
parameters: callback.parameters,
|
|
28
|
+
returnValue: callback.returnValue,
|
|
29
|
+
});
|