@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
package/src/gir/qualify.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { GirFunction } from "./function.js";
|
|
2
|
-
import type { GirParameter } from "./parameter.js";
|
|
3
|
-
import type { GirTypeRef } from "./type-ref.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Stamps a default namespace onto an unqualified `named` reference and
|
|
7
|
-
* recurses into composite (`array`, `list`, `hashtable`) references.
|
|
8
|
-
*
|
|
9
|
-
* GIR omits the namespace when a reference points to a sibling in the same
|
|
10
|
-
* file. When writers walk a class hierarchy across namespaces, the parent's
|
|
11
|
-
* references must be qualified with the parent's namespace before they can be
|
|
12
|
-
* resolved against the repository.
|
|
13
|
-
*
|
|
14
|
-
* Returns `undefined` for an `undefined` input so callers can pass through
|
|
15
|
-
* void return types unchanged.
|
|
16
|
-
*
|
|
17
|
-
* @param ref - The reference to qualify, or `undefined`
|
|
18
|
-
* @param defaultNamespace - The namespace to stamp on unqualified refs
|
|
19
|
-
*/
|
|
20
|
-
export const qualifyTypeRef = (ref: GirTypeRef | undefined, defaultNamespace: string): GirTypeRef | undefined => {
|
|
21
|
-
if (ref === undefined) return undefined;
|
|
22
|
-
switch (ref.kind) {
|
|
23
|
-
case "named":
|
|
24
|
-
return { ...ref, namespaceName: ref.namespaceName ?? defaultNamespace };
|
|
25
|
-
case "array":
|
|
26
|
-
return { ...ref, element: qualifyTypeRef(ref.element, defaultNamespace) ?? ref.element };
|
|
27
|
-
case "list":
|
|
28
|
-
return { ...ref, element: qualifyTypeRef(ref.element, defaultNamespace) ?? ref.element };
|
|
29
|
-
case "hashtable":
|
|
30
|
-
return {
|
|
31
|
-
...ref,
|
|
32
|
-
key: qualifyTypeRef(ref.key, defaultNamespace) ?? ref.key,
|
|
33
|
-
value: qualifyTypeRef(ref.value, defaultNamespace) ?? ref.value,
|
|
34
|
-
};
|
|
35
|
-
case "primitive":
|
|
36
|
-
case "callback":
|
|
37
|
-
case "varargs":
|
|
38
|
-
return ref;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const qualifyParameter = (parameter: GirParameter, defaultNamespace: string): GirParameter => ({
|
|
43
|
-
...parameter,
|
|
44
|
-
type: qualifyTypeRef(parameter.type, defaultNamespace),
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Re-roots every type reference of a callable to `defaultNamespace`.
|
|
49
|
-
*
|
|
50
|
-
* Interface methods are flattened onto each implementing class, but their
|
|
51
|
-
* GIR type references are unqualified relative to the interface's own
|
|
52
|
-
* namespace. Stamping the interface namespace onto the instance parameter,
|
|
53
|
-
* each regular parameter, and the return value lets the class writer resolve
|
|
54
|
-
* and import those references as if the method had been authored on the class.
|
|
55
|
-
*
|
|
56
|
-
* @param fn - The callable whose references to qualify
|
|
57
|
-
* @param defaultNamespace - The namespace the callable's references belong to
|
|
58
|
-
*/
|
|
59
|
-
export const qualifyFunction = (fn: GirFunction, defaultNamespace: string): GirFunction => ({
|
|
60
|
-
...fn,
|
|
61
|
-
instance: fn.instance === undefined ? undefined : qualifyParameter(fn.instance, defaultNamespace),
|
|
62
|
-
parameters: fn.parameters.map((parameter) => qualifyParameter(parameter, defaultNamespace)),
|
|
63
|
-
returnValue: { ...fn.returnValue, type: qualifyTypeRef(fn.returnValue.type, defaultNamespace) },
|
|
64
|
-
});
|
package/src/gir/repository.ts
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import type { GirBoxed } from "./boxed.js";
|
|
4
|
-
import type { GirCallback } from "./callback.js";
|
|
5
|
-
import type { GirClass } from "./class.js";
|
|
6
|
-
import type { GirEnum } from "./enum.js";
|
|
7
|
-
import { type GirNamespace, namespaceFromRepository } from "./namespace.js";
|
|
8
|
-
import { parseGirFile } from "./parse.js";
|
|
9
|
-
import type { GirTypeRef } from "./type-ref.js";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Resolved entity that a {@link GirRepository.resolveNamed} call returns.
|
|
13
|
-
*
|
|
14
|
-
* Wraps the matching entity along with the namespace it lives in, so
|
|
15
|
-
* writers can pull the namespace identifier or shared library name without
|
|
16
|
-
* a second lookup.
|
|
17
|
-
*/
|
|
18
|
-
export type ResolvedNamed =
|
|
19
|
-
| { readonly kind: "class"; readonly namespace: GirNamespace; readonly value: GirClass }
|
|
20
|
-
| { readonly kind: "interface"; readonly namespace: GirNamespace; readonly value: GirClass }
|
|
21
|
-
| { readonly kind: "boxed"; readonly namespace: GirNamespace; readonly value: GirBoxed }
|
|
22
|
-
| { readonly kind: "enum"; readonly namespace: GirNamespace; readonly value: GirEnum }
|
|
23
|
-
| { readonly kind: "callback"; readonly namespace: GirNamespace; readonly value: GirCallback }
|
|
24
|
-
| {
|
|
25
|
-
readonly kind: "alias";
|
|
26
|
-
readonly namespace: GirNamespace;
|
|
27
|
-
readonly target: string | undefined;
|
|
28
|
-
readonly targetRef: GirTypeRef | undefined;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* In-memory database of every loaded GIR namespace, indexed by name.
|
|
33
|
-
*
|
|
34
|
-
* Construct via {@link loadGirRepository}; the public API after that is the
|
|
35
|
-
* `namespaces` map and {@link resolveNamed} for cross-namespace lookups.
|
|
36
|
-
*/
|
|
37
|
-
export class GirRepository {
|
|
38
|
-
/** Namespaces keyed by their unqualified name (e.g. `"Gtk"`, `"GLib"`). */
|
|
39
|
-
public readonly namespaces: ReadonlyMap<string, GirNamespace>;
|
|
40
|
-
/** Absolute paths of every `.gir` file loaded, for staleness fingerprinting. */
|
|
41
|
-
public readonly girFiles: readonly string[];
|
|
42
|
-
private readonly entityIndex: Map<string, ResolvedNamed>;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Constructs a repository from the supplied namespace map.
|
|
46
|
-
*
|
|
47
|
-
* Callers should prefer {@link loadGirRepository} which discovers and
|
|
48
|
-
* parses files for you.
|
|
49
|
-
*
|
|
50
|
-
* @param namespaces - Namespaces keyed by unqualified name
|
|
51
|
-
* @param girFiles - Absolute paths of the `.gir` files the namespaces came from
|
|
52
|
-
*/
|
|
53
|
-
constructor(namespaces: ReadonlyMap<string, GirNamespace>, girFiles: readonly string[] = []) {
|
|
54
|
-
this.namespaces = namespaces;
|
|
55
|
-
this.girFiles = girFiles;
|
|
56
|
-
this.entityIndex = new Map();
|
|
57
|
-
for (const namespace of namespaces.values()) {
|
|
58
|
-
indexNamespace(this.entityIndex, namespace);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Looks up a type by `(namespace, name)`. Aliases are followed one step
|
|
64
|
-
* to their target. Returns `undefined` when neither the namespace nor a
|
|
65
|
-
* matching entity exists.
|
|
66
|
-
*
|
|
67
|
-
* @param namespaceName - Namespace to look in (e.g. `"GLib"`)
|
|
68
|
-
* @param typeName - Local type name within the namespace (e.g. `"Variant"`)
|
|
69
|
-
*/
|
|
70
|
-
resolveNamed(namespaceName: string, typeName: string): ResolvedNamed | undefined {
|
|
71
|
-
const key = entityKey(namespaceName, typeName);
|
|
72
|
-
const direct = this.entityIndex.get(key);
|
|
73
|
-
if (direct !== undefined) return direct;
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const entityKey = (namespaceName: string, typeName: string): string => `${namespaceName}.${typeName}`;
|
|
79
|
-
|
|
80
|
-
const indexNamespace = (index: Map<string, ResolvedNamed>, namespace: GirNamespace): void => {
|
|
81
|
-
for (const value of namespace.classes) {
|
|
82
|
-
index.set(entityKey(namespace.name, value.name), { kind: "class", namespace, value });
|
|
83
|
-
}
|
|
84
|
-
for (const value of namespace.interfaces) {
|
|
85
|
-
index.set(entityKey(namespace.name, value.name), { kind: "interface", namespace, value });
|
|
86
|
-
}
|
|
87
|
-
for (const value of namespace.boxeds) {
|
|
88
|
-
index.set(entityKey(namespace.name, value.name), { kind: "boxed", namespace, value });
|
|
89
|
-
}
|
|
90
|
-
for (const value of namespace.enums) {
|
|
91
|
-
index.set(entityKey(namespace.name, value.name), { kind: "enum", namespace, value });
|
|
92
|
-
}
|
|
93
|
-
for (const value of namespace.callbacks) {
|
|
94
|
-
index.set(entityKey(namespace.name, value.name), { kind: "callback", namespace, value });
|
|
95
|
-
}
|
|
96
|
-
for (const alias of namespace.aliases) {
|
|
97
|
-
const target = alias.target?.kind === "named" ? alias.target.typeName : undefined;
|
|
98
|
-
index.set(entityKey(namespace.name, alias.name), {
|
|
99
|
-
kind: "alias",
|
|
100
|
-
namespace,
|
|
101
|
-
target,
|
|
102
|
-
targetRef: alias.target,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Discovers and parses every GIR file needed to satisfy `libraries` and
|
|
109
|
-
* their transitive `<include>` dependencies.
|
|
110
|
-
*
|
|
111
|
-
* @param libraries - Resolved `Name-Version` namespace identifiers
|
|
112
|
-
* @param girPath - Ordered list of directories to search for `.gir` files
|
|
113
|
-
* @returns A populated {@link GirRepository}
|
|
114
|
-
* @throws If any required GIR file cannot be located on `girPath`
|
|
115
|
-
*/
|
|
116
|
-
export const loadGirRepository = (libraries: readonly string[], girPath: readonly string[]): GirRepository => {
|
|
117
|
-
const namespaces = new Map<string, GirNamespace>();
|
|
118
|
-
const girFiles: string[] = [];
|
|
119
|
-
const queue: string[] = [...libraries];
|
|
120
|
-
while (queue.length > 0) {
|
|
121
|
-
const identifier = queue.shift();
|
|
122
|
-
if (identifier === undefined) continue;
|
|
123
|
-
const namespaceName = identifier.split("-")[0] ?? identifier;
|
|
124
|
-
if (namespaces.has(namespaceName)) continue;
|
|
125
|
-
const path = locateGirFile(identifier, girPath);
|
|
126
|
-
girFiles.push(path);
|
|
127
|
-
const root = parseGirFile(path);
|
|
128
|
-
const repository = root.repository;
|
|
129
|
-
if (typeof repository !== "object" || repository === null) {
|
|
130
|
-
throw new Error(`GIR file at ${path} has no <repository> root`);
|
|
131
|
-
}
|
|
132
|
-
const namespace = namespaceFromRepository(repository as Record<string, unknown>);
|
|
133
|
-
namespaces.set(namespace.name, namespace);
|
|
134
|
-
for (const include of namespace.includes) {
|
|
135
|
-
queue.push(`${include.name}-${include.version}`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return new GirRepository(namespaces, girFiles);
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const locateGirFile = (identifier: string, girPath: readonly string[]): string => {
|
|
142
|
-
const filename = `${identifier}.gir`;
|
|
143
|
-
for (const directory of girPath) {
|
|
144
|
-
const candidate = join(directory, filename);
|
|
145
|
-
if (existsSync(candidate)) return candidate;
|
|
146
|
-
}
|
|
147
|
-
const tried = girPath.map((directory) => join(directory, filename)).join(", ");
|
|
148
|
-
throw new Error(`GIR file ${filename} not found on girPath. Tried: ${tried}`);
|
|
149
|
-
};
|
package/src/gir/signal.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { type GirParameter, type GirReturnValue, parameterFromNode, returnValueFromNode } from "./parameter.js";
|
|
2
|
-
import { attr, attrBool, childOf, childrenOf, type RawNode } from "./parse.js";
|
|
3
|
-
|
|
4
|
-
/** Emission stage (`<glib:signal when="…">`). */
|
|
5
|
-
type SignalWhen = "first" | "last" | "cleanup";
|
|
6
|
-
|
|
7
|
-
/** A GObject `<glib:signal>` declaration. */
|
|
8
|
-
export type GirSignal = {
|
|
9
|
-
/** GIR signal name, kebab-case (e.g. `"activate-link"`). */
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly parameters: readonly GirParameter[];
|
|
12
|
-
readonly returnValue: GirReturnValue;
|
|
13
|
-
readonly when: SignalWhen;
|
|
14
|
-
readonly detailed: boolean;
|
|
15
|
-
readonly action: boolean;
|
|
16
|
-
readonly noRecurse: boolean;
|
|
17
|
-
readonly noHooks: boolean;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Builds a {@link GirSignal} from a `<glib:signal>` element.
|
|
22
|
-
*/
|
|
23
|
-
export const signalFromNode = (node: RawNode): GirSignal => {
|
|
24
|
-
const parametersNode = childOf(node, "parameters");
|
|
25
|
-
const parameterNodes = childrenOf(parametersNode, "parameter");
|
|
26
|
-
return {
|
|
27
|
-
name: attr(node, "name") ?? "",
|
|
28
|
-
parameters: parameterNodes.map((parameter) => parameterFromNode(parameter, false)),
|
|
29
|
-
returnValue: returnValueFromNode(childOf(node, "return-value")),
|
|
30
|
-
when: (attr(node, "when") ?? "last") as SignalWhen,
|
|
31
|
-
detailed: attrBool(node, "detailed"),
|
|
32
|
-
action: attrBool(node, "action"),
|
|
33
|
-
noRecurse: attrBool(node, "no-recurse"),
|
|
34
|
-
noHooks: attrBool(node, "no-hooks"),
|
|
35
|
-
};
|
|
36
|
-
};
|
package/src/jsx-store.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { type StoreOptions, writeStore } from "./store-fs.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Options for assembling the injected `@gtkx/react-jsx` unit.
|
|
5
|
-
*/
|
|
6
|
-
export type JsxStoreOptions = StoreOptions & {
|
|
7
|
-
/** Absolute path to the gi store, for the unit's own `node_modules/@gtkx/gi`. */
|
|
8
|
-
readonly giStoreDir: string;
|
|
9
|
-
/** Real (symlink-resolved) directory of the installed `react` runtime. */
|
|
10
|
-
readonly realReactRuntimeDir: string;
|
|
11
|
-
/** Real (symlink-resolved) directory of the installed `@gtkx/react`. */
|
|
12
|
-
readonly realReactPackageDir: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const stem = (relativePath: string): string => relativePath.replace(/\.(tsx|ts)$/, "");
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Assembles the self-contained injected `@gtkx/react-jsx` unit: the generated
|
|
19
|
-
* `jsx`/`internal`/`compounds` modules plus a `package.json` and the unit's own
|
|
20
|
-
* `node_modules` symlinks to `@gtkx/gi` and `react`.
|
|
21
|
-
*
|
|
22
|
-
* @param options - Resolved store/link/dependency paths
|
|
23
|
-
* @param files - React pipeline output keyed by source filename
|
|
24
|
-
*/
|
|
25
|
-
export const writeJsxStore = (options: JsxStoreOptions, files: ReadonlyMap<string, string>): void => {
|
|
26
|
-
writeStore({
|
|
27
|
-
storeDir: options.storeDir,
|
|
28
|
-
linkDir: options.linkDir,
|
|
29
|
-
files: [...files].map(([relativePath, source]) => ({
|
|
30
|
-
stem: stem(relativePath),
|
|
31
|
-
fileName: relativePath,
|
|
32
|
-
source,
|
|
33
|
-
})),
|
|
34
|
-
manifest: {
|
|
35
|
-
name: "@gtkx/react-jsx",
|
|
36
|
-
type: "module",
|
|
37
|
-
version: options.version,
|
|
38
|
-
sideEffects: ["./internal.js"],
|
|
39
|
-
exports: {
|
|
40
|
-
"./package.json": "./package.json",
|
|
41
|
-
".": { types: "./jsx.d.ts", default: "./jsx.js" },
|
|
42
|
-
"./jsx": { types: "./jsx.d.ts", default: "./jsx.js" },
|
|
43
|
-
"./compounds": { types: "./compounds.d.ts", default: "./compounds.js" },
|
|
44
|
-
"./internal": { types: "./internal.d.ts", default: "./internal.js" },
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
symlinks: [
|
|
48
|
-
{ segments: ["node_modules", "@gtkx", "gi"], target: options.giStoreDir },
|
|
49
|
-
{ segments: ["node_modules", "@gtkx", "react"], target: options.realReactPackageDir },
|
|
50
|
-
{ segments: ["node_modules", "react"], target: options.realReactRuntimeDir },
|
|
51
|
-
],
|
|
52
|
-
});
|
|
53
|
-
};
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Container-slot mapping for compound widgets — JSX element name to the
|
|
3
|
-
* camelCase GTK method names that append a child onto the widget.
|
|
4
|
-
*
|
|
5
|
-
* Each method name doubles as a `ReactNode` prop on the compound and as the
|
|
6
|
-
* `<ContainerSlot id="…">` identifier the reconciler dispatches to. For
|
|
7
|
-
* example `packStart` on `AdwHeaderBar` maps to `adw_header_bar_pack_start(…)`;
|
|
8
|
-
* `<AdwHeaderBar packStart={…} />` packs the value at the start.
|
|
9
|
-
*
|
|
10
|
-
* Unlike setter slots ({@link BUILT_IN_SLOT_PROPS}), a container slot accepts
|
|
11
|
-
* multiple children and appends rather than replaces.
|
|
12
|
-
*
|
|
13
|
-
* The list is small and stable; defining it in code keeps the lookup
|
|
14
|
-
* fast and avoids one more GIR-introspection pass.
|
|
15
|
-
*/
|
|
16
|
-
const CONTAINER_SLOTS: Readonly<Record<string, readonly string[]>> = Object.freeze({
|
|
17
|
-
AdwActionRow: ["addPrefix", "addSuffix"],
|
|
18
|
-
AdwEntryRow: ["addPrefix", "addSuffix"],
|
|
19
|
-
AdwExpanderRow: ["addPrefix", "addSuffix", "addRow", "addAction"],
|
|
20
|
-
AdwHeaderBar: ["packStart", "packEnd"],
|
|
21
|
-
AdwToolbarView: ["addTopBar", "addBottomBar"],
|
|
22
|
-
GtkActionBar: ["packStart", "packEnd"],
|
|
23
|
-
GtkHeaderBar: ["packStart", "packEnd"],
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Returns the container-slot method names for a JSX element name, or an
|
|
28
|
-
* empty array if no container slots exist.
|
|
29
|
-
*
|
|
30
|
-
* @param jsxName - The JSX element name (PascalCase / GLib type name)
|
|
31
|
-
*/
|
|
32
|
-
export const containerSlotsFor = (jsxName: string): readonly string[] => CONTAINER_SLOTS[jsxName] ?? [];
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Virtual-child subcomponent mapping — JSX element name to the map of
|
|
36
|
-
* subcomponent property → virtual JSX intrinsic name it routes through.
|
|
37
|
-
*
|
|
38
|
-
* For example `GtkConstraintLayout.Constraint` renders the
|
|
39
|
-
* `<Constraint>` virtual intrinsic so the reconciler can attach a
|
|
40
|
-
* GtkConstraint to the layout. Unlike container slots, virtual
|
|
41
|
-
* subcomponents render an existing intrinsic element rather than
|
|
42
|
-
* invoking a setter on the parent widget.
|
|
43
|
-
*/
|
|
44
|
-
const VIRTUAL_SUBCOMPONENTS: Readonly<
|
|
45
|
-
Record<string, ReadonlyArray<{ readonly child: string; readonly intrinsic: string }>>
|
|
46
|
-
> = Object.freeze({
|
|
47
|
-
GtkShortcutController: [{ child: "Shortcut", intrinsic: "Shortcut" }],
|
|
48
|
-
GtkConstraintLayout: [
|
|
49
|
-
{ child: "Constraint", intrinsic: "Constraint" },
|
|
50
|
-
{ child: "Guide", intrinsic: "ConstraintGuide" },
|
|
51
|
-
{ child: "Widget", intrinsic: "ConstraintLayoutWidget" },
|
|
52
|
-
{ child: "Vfl", intrinsic: "ConstraintVfl" },
|
|
53
|
-
],
|
|
54
|
-
GtkStack: [{ child: "Page", intrinsic: "StackPage" }],
|
|
55
|
-
AdwViewStack: [{ child: "Page", intrinsic: "StackPage" }],
|
|
56
|
-
GtkNotebook: [
|
|
57
|
-
{ child: "Page", intrinsic: "NotebookPage" },
|
|
58
|
-
{ child: "PageTab", intrinsic: "NotebookPageTab" },
|
|
59
|
-
],
|
|
60
|
-
GtkGrid: [{ child: "Child", intrinsic: "GridChild" }],
|
|
61
|
-
GtkFixed: [{ child: "Child", intrinsic: "FixedChild" }],
|
|
62
|
-
GtkOverlay: [{ child: "Child", intrinsic: "OverlayChild" }],
|
|
63
|
-
GtkColumnView: [{ child: "Column", intrinsic: "ColumnViewColumn" }],
|
|
64
|
-
GtkTextView: [
|
|
65
|
-
{ child: "Tag", intrinsic: "TextTag" },
|
|
66
|
-
{ child: "Anchor", intrinsic: "TextAnchor" },
|
|
67
|
-
{ child: "Paintable", intrinsic: "TextPaintable" },
|
|
68
|
-
],
|
|
69
|
-
GtkSourceView: [
|
|
70
|
-
{ child: "Tag", intrinsic: "TextTag" },
|
|
71
|
-
{ child: "Anchor", intrinsic: "TextAnchor" },
|
|
72
|
-
{ child: "Paintable", intrinsic: "TextPaintable" },
|
|
73
|
-
],
|
|
74
|
-
GtkMenuButton: [
|
|
75
|
-
{ child: "MenuItem", intrinsic: "MenuItem" },
|
|
76
|
-
{ child: "MenuSection", intrinsic: "MenuSection" },
|
|
77
|
-
{ child: "MenuSubmenu", intrinsic: "MenuSubmenu" },
|
|
78
|
-
],
|
|
79
|
-
GtkPopoverMenu: [
|
|
80
|
-
{ child: "Item", intrinsic: "MenuItem" },
|
|
81
|
-
{ child: "Section", intrinsic: "MenuSection" },
|
|
82
|
-
{ child: "Submenu", intrinsic: "MenuSubmenu" },
|
|
83
|
-
],
|
|
84
|
-
GtkPopoverMenuBar: [
|
|
85
|
-
{ child: "Item", intrinsic: "MenuItem" },
|
|
86
|
-
{ child: "Section", intrinsic: "MenuSection" },
|
|
87
|
-
{ child: "Submenu", intrinsic: "MenuSubmenu" },
|
|
88
|
-
],
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Returns the virtual-subcomponent record for a JSX element name, or an
|
|
93
|
-
* empty array if no virtual subcomponents exist.
|
|
94
|
-
*
|
|
95
|
-
* @param jsxName - The JSX element name (PascalCase / GLib type name)
|
|
96
|
-
*/
|
|
97
|
-
export const virtualSubcomponentsFor = (
|
|
98
|
-
jsxName: string,
|
|
99
|
-
): ReadonlyArray<{ readonly child: string; readonly intrinsic: string }> => VIRTUAL_SUBCOMPONENTS[jsxName] ?? [];
|
package/src/react/compounds.ts
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { quote } from "@gtkx/utils";
|
|
2
|
-
import { indent } from "../dsl/emit.js";
|
|
3
|
-
import type { GirRepository } from "../gir/repository.js";
|
|
4
|
-
import { containerSlotsFor, virtualSubcomponentsFor } from "./compounds-meta.js";
|
|
5
|
-
import { mergeSlotProps } from "./slot-props.js";
|
|
6
|
-
import { ancestorGlibNames, isWidgetClass, iterateClassesWithGlibName, type WidgetCandidate } from "./widgets.js";
|
|
7
|
-
|
|
8
|
-
type CompoundAccumulator = {
|
|
9
|
-
readonly elementNames: Set<string>;
|
|
10
|
-
readonly compoundPropTypes: Set<string>;
|
|
11
|
-
readonly virtualPropTypes: Set<string>;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Generates `compounds.tsx` source — one statically-compiled React
|
|
16
|
-
* component per widget that has slot props, container-slot props, or
|
|
17
|
-
* virtual-child sub-components.
|
|
18
|
-
*
|
|
19
|
-
* Each component is plain JSX: it destructures its slot and container-slot
|
|
20
|
-
* props, forwards the rest to the host intrinsic, and wraps each non-null
|
|
21
|
-
* slot value in a `<Slot>` (setter) or `<ContainerSlot>` (append) element.
|
|
22
|
-
* Virtual-child sub-components (e.g. `GtkStack.Page`) are attached with
|
|
23
|
-
* `Object.assign` under an explicit intersection type so isolated
|
|
24
|
-
* declaration emit succeeds.
|
|
25
|
-
*
|
|
26
|
-
* A host intrinsic is referenced through a module-local
|
|
27
|
-
* `${Name}Element = "Name"` const so the JSX tag does not collide with the
|
|
28
|
-
* exported component of the same name. Widgets with no slots, container
|
|
29
|
-
* slots, or virtual children remain bare string-constant intrinsics in
|
|
30
|
-
* `jsx.ts`.
|
|
31
|
-
*
|
|
32
|
-
* @param repository - The loaded GIR repository
|
|
33
|
-
* @param userSlotProps - User-supplied slot-prop overrides
|
|
34
|
-
*/
|
|
35
|
-
export const generateCompounds = (
|
|
36
|
-
repository: GirRepository,
|
|
37
|
-
userSlotProps: Readonly<Record<string, readonly string[]>> | undefined,
|
|
38
|
-
): { readonly source: string; readonly exportedNames: ReadonlySet<string> } => {
|
|
39
|
-
const slotPropMap = mergeSlotProps(userSlotProps);
|
|
40
|
-
const exportedNames = new Set<string>();
|
|
41
|
-
const exportLines: string[] = [];
|
|
42
|
-
const accumulator: CompoundAccumulator = {
|
|
43
|
-
elementNames: new Set<string>(),
|
|
44
|
-
compoundPropTypes: new Set<string>(),
|
|
45
|
-
virtualPropTypes: new Set<string>(),
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
for (const { glibName, klass, namespace } of collectCompoundCandidates(repository)) {
|
|
49
|
-
const slots = resolveInheritedSlots(slotPropMap, klass, namespace, repository);
|
|
50
|
-
const containers = containerSlotsFor(glibName);
|
|
51
|
-
const virtuals = virtualSubcomponentsFor(glibName);
|
|
52
|
-
if (slots.length === 0 && containers.length === 0 && virtuals.length === 0) continue;
|
|
53
|
-
|
|
54
|
-
exportLines.push(renderCompound({ glibName, slots, containers, virtuals }, accumulator));
|
|
55
|
-
exportedNames.add(glibName);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const sections = [
|
|
59
|
-
renderImportLines(accumulator).join("\n"),
|
|
60
|
-
renderElementConsts(accumulator),
|
|
61
|
-
exportLines.join("\n\n"),
|
|
62
|
-
];
|
|
63
|
-
const source = `${sections.filter((section) => section.length > 0).join("\n\n")}\n`;
|
|
64
|
-
return { source, exportedNames };
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
type CompoundShape = {
|
|
68
|
-
readonly glibName: string;
|
|
69
|
-
readonly slots: readonly string[];
|
|
70
|
-
readonly containers: readonly string[];
|
|
71
|
-
readonly virtuals: ReadonlyArray<{ readonly child: string; readonly intrinsic: string }>;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const renderCompound = (shape: CompoundShape, accumulator: CompoundAccumulator): string => {
|
|
75
|
-
const { glibName, slots, containers, virtuals } = shape;
|
|
76
|
-
const propsType = `${glibName}Props`;
|
|
77
|
-
accumulator.compoundPropTypes.add(propsType);
|
|
78
|
-
accumulator.elementNames.add(glibName);
|
|
79
|
-
if (slots.length > 0) accumulator.elementNames.add("Slot");
|
|
80
|
-
if (containers.length > 0) accumulator.elementNames.add("ContainerSlot");
|
|
81
|
-
|
|
82
|
-
const component = renderComponentFunction(glibName, propsType, slots, containers);
|
|
83
|
-
if (virtuals.length === 0) {
|
|
84
|
-
return `export const ${glibName} = ${component};`;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const subcomponents = virtuals.map((virtual) => renderVirtualSubcomponent(virtual, accumulator));
|
|
88
|
-
const fields = subcomponents.map((sub) => ` ${sub.field};`).join("\n");
|
|
89
|
-
const impls = subcomponents.map((sub) => indent(`${sub.impl},`, 1)).join("\n");
|
|
90
|
-
return [
|
|
91
|
-
`export const ${glibName}: ((props: ${propsType}) => ReactNode) & {`,
|
|
92
|
-
fields,
|
|
93
|
-
`} = Object.assign(`,
|
|
94
|
-
`${indent(component, 1)},`,
|
|
95
|
-
" {",
|
|
96
|
-
impls,
|
|
97
|
-
" },",
|
|
98
|
-
");",
|
|
99
|
-
].join("\n");
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const renderComponentFunction = (
|
|
103
|
-
glibName: string,
|
|
104
|
-
propsType: string,
|
|
105
|
-
slots: readonly string[],
|
|
106
|
-
containers: readonly string[],
|
|
107
|
-
): string => {
|
|
108
|
-
const host = `${glibName}Element`;
|
|
109
|
-
if (slots.length === 0 && containers.length === 0) {
|
|
110
|
-
return [
|
|
111
|
-
`(props: ${propsType}): ReactNode => {`,
|
|
112
|
-
" const { children, ...rest } = props;",
|
|
113
|
-
` return <${host} {...rest}>{children}</${host}>;`,
|
|
114
|
-
"}",
|
|
115
|
-
].join("\n");
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const destructured = [...slots, ...containers, "children"].join(", ");
|
|
119
|
-
const slotChildren = [
|
|
120
|
-
...slots.map((slot) => renderSlotChild("SlotElement", slot)),
|
|
121
|
-
...containers.map((container) => renderSlotChild("ContainerSlotElement", container)),
|
|
122
|
-
];
|
|
123
|
-
return [
|
|
124
|
-
`(props: ${propsType}): ReactNode => {`,
|
|
125
|
-
` const { ${destructured}, ...rest } = props;`,
|
|
126
|
-
" return (",
|
|
127
|
-
` <${host} {...rest}>`,
|
|
128
|
-
" {children}",
|
|
129
|
-
...slotChildren.map((child) => ` ${child}`),
|
|
130
|
-
` </${host}>`,
|
|
131
|
-
" );",
|
|
132
|
-
"}",
|
|
133
|
-
].join("\n");
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const renderSlotChild = (elementConst: string, slot: string): string =>
|
|
137
|
-
`{${slot} != null && <${elementConst} id=${quote(slot)}>{${slot}}</${elementConst}>}`;
|
|
138
|
-
|
|
139
|
-
const renderVirtualSubcomponent = (
|
|
140
|
-
virtual: { readonly child: string; readonly intrinsic: string },
|
|
141
|
-
accumulator: CompoundAccumulator,
|
|
142
|
-
): { readonly field: string; readonly impl: string } => {
|
|
143
|
-
const { child, intrinsic } = virtual;
|
|
144
|
-
const propsType = `${intrinsic}Props`;
|
|
145
|
-
accumulator.virtualPropTypes.add(propsType);
|
|
146
|
-
accumulator.elementNames.add(intrinsic);
|
|
147
|
-
return {
|
|
148
|
-
field: `${child}: (props: ${propsType}) => ReactNode`,
|
|
149
|
-
impl: `${child}: (props: ${propsType}): ReactNode => <${intrinsic}Element {...props} />`,
|
|
150
|
-
};
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const renderElementConsts = (accumulator: CompoundAccumulator): string =>
|
|
154
|
-
[...accumulator.elementNames]
|
|
155
|
-
.sort((a, b) => a.localeCompare(b))
|
|
156
|
-
.map((name) => `const ${name}Element = ${quote(name)} as const;`)
|
|
157
|
-
.join("\n");
|
|
158
|
-
|
|
159
|
-
const renderImportLines = (accumulator: CompoundAccumulator): readonly string[] => {
|
|
160
|
-
const lines = ['import type { ReactNode } from "react";'];
|
|
161
|
-
const compoundPropTypes = [...accumulator.compoundPropTypes].sort((a, b) => a.localeCompare(b));
|
|
162
|
-
if (compoundPropTypes.length > 0) {
|
|
163
|
-
lines.push(`import type { ${compoundPropTypes.join(", ")} } from "./jsx.js";`);
|
|
164
|
-
}
|
|
165
|
-
const virtualPropTypes = [...accumulator.virtualPropTypes].sort((a, b) => a.localeCompare(b));
|
|
166
|
-
if (virtualPropTypes.length > 0) {
|
|
167
|
-
lines.push(`import type { ${virtualPropTypes.join(", ")} } from "@gtkx/react";`);
|
|
168
|
-
}
|
|
169
|
-
return lines;
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
const resolveInheritedSlots = (
|
|
173
|
-
slotPropMap: Readonly<Record<string, readonly string[]>>,
|
|
174
|
-
klass: WidgetCandidate["klass"],
|
|
175
|
-
namespace: WidgetCandidate["namespace"],
|
|
176
|
-
repository: GirRepository,
|
|
177
|
-
): readonly string[] => {
|
|
178
|
-
const seen = new Set<string>();
|
|
179
|
-
const slots: string[] = [];
|
|
180
|
-
for (const glibName of ancestorGlibNames(klass, namespace, repository)) {
|
|
181
|
-
for (const slot of slotPropMap[glibName] ?? []) {
|
|
182
|
-
if (seen.has(slot)) continue;
|
|
183
|
-
seen.add(slot);
|
|
184
|
-
slots.push(slot);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return slots;
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
const collectCompoundCandidates = (repository: GirRepository): readonly WidgetCandidate[] => {
|
|
191
|
-
const seen = new Set<string>();
|
|
192
|
-
const candidates: WidgetCandidate[] = [];
|
|
193
|
-
for (const candidate of iterateClassesWithGlibName(repository)) {
|
|
194
|
-
const { glibName, klass, namespace } = candidate;
|
|
195
|
-
const isWidget = isWidgetClass(klass, namespace, repository);
|
|
196
|
-
const hasContainerSlot = containerSlotsFor(glibName).length > 0;
|
|
197
|
-
const hasVirtualChild = virtualSubcomponentsFor(glibName).length > 0;
|
|
198
|
-
if (!isWidget && !hasContainerSlot && !hasVirtualChild) continue;
|
|
199
|
-
if (seen.has(glibName)) continue;
|
|
200
|
-
seen.add(glibName);
|
|
201
|
-
candidates.push(candidate);
|
|
202
|
-
}
|
|
203
|
-
return candidates.sort((a, b) => a.glibName.localeCompare(b.glibName));
|
|
204
|
-
};
|