@gtkx/codegen 1.0.0-rc.1 → 1.0.0-rc.2
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/dist/analysis/descriptor-render.d.ts +18 -11
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +275 -152
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +37 -34
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js +34 -30
- package/dist/analysis/descriptor.js.map +1 -1
- package/dist/analysis/inheritance.d.ts +16 -16
- package/dist/analysis/inheritance.d.ts.map +1 -1
- package/dist/analysis/inheritance.js +139 -84
- package/dist/analysis/inheritance.js.map +1 -1
- package/dist/analysis/param-structure.d.ts +14 -13
- package/dist/analysis/param-structure.d.ts.map +1 -1
- package/dist/analysis/param-structure.js +104 -53
- package/dist/analysis/param-structure.js.map +1 -1
- package/dist/analysis/ts-type.d.ts +6 -5
- package/dist/analysis/ts-type.d.ts.map +1 -1
- package/dist/analysis/ts-type.js +69 -23
- package/dist/analysis/ts-type.js.map +1 -1
- package/dist/compile.d.ts +5 -5
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +70 -63
- package/dist/compile.js.map +1 -1
- package/dist/docs/api-reference.d.ts +12 -11
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +194 -121
- package/dist/docs/api-reference.js.map +1 -1
- package/dist/docs/element-page.d.ts +6 -9
- package/dist/docs/element-page.d.ts.map +1 -1
- package/dist/docs/element-page.js +68 -133
- package/dist/docs/element-page.js.map +1 -1
- package/dist/docs/pipeline.d.ts +8 -7
- package/dist/docs/pipeline.d.ts.map +1 -1
- package/dist/docs/pipeline.js +79 -53
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/docs/render.d.ts +21 -19
- package/dist/docs/render.d.ts.map +1 -1
- package/dist/docs/render.js +80 -71
- package/dist/docs/render.js.map +1 -1
- package/dist/docs/symbol-page.d.ts +6 -6
- package/dist/docs/symbol-page.d.ts.map +1 -1
- package/dist/docs/symbol-page.js +126 -84
- package/dist/docs/symbol-page.js.map +1 -1
- package/dist/fingerprint.d.ts +28 -5
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +66 -13
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts +13 -0
- package/dist/gi.d.ts.map +1 -0
- package/dist/gi.js +21 -0
- package/dist/gi.js.map +1 -0
- package/dist/gir/ancestry.d.ts +4 -3
- package/dist/gir/ancestry.d.ts.map +1 -1
- package/dist/gir/ancestry.js +12 -15
- package/dist/gir/ancestry.js.map +1 -1
- package/dist/gir/callback.d.ts +6 -11
- package/dist/gir/callback.d.ts.map +1 -1
- package/dist/gir/callback.js +6 -7
- package/dist/gir/callback.js.map +1 -1
- package/dist/gir/class.d.ts +7 -5
- package/dist/gir/class.d.ts.map +1 -1
- package/dist/gir/class.js +14 -12
- package/dist/gir/class.js.map +1 -1
- package/dist/gir/enum.d.ts +3 -3
- package/dist/gir/enum.d.ts.map +1 -1
- package/dist/gir/enum.js +7 -6
- package/dist/gir/enum.js.map +1 -1
- package/dist/gir/field.d.ts +8 -3
- package/dist/gir/field.d.ts.map +1 -1
- package/dist/gir/field.js +30 -7
- package/dist/gir/field.js.map +1 -1
- package/dist/gir/function.d.ts +6 -3
- package/dist/gir/function.d.ts.map +1 -1
- package/dist/gir/function.js +23 -7
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/gir-path.d.ts +2 -1
- package/dist/gir/gir-path.d.ts.map +1 -1
- package/dist/gir/gir-path.js +26 -10
- package/dist/gir/gir-path.js.map +1 -1
- package/dist/gir/libraries.d.ts +3 -2
- package/dist/gir/libraries.d.ts.map +1 -1
- package/dist/gir/libraries.js +39 -27
- package/dist/gir/libraries.js.map +1 -1
- package/dist/gir/library.d.ts +17 -11
- package/dist/gir/library.d.ts.map +1 -1
- package/dist/gir/library.js +116 -92
- package/dist/gir/library.js.map +1 -1
- package/dist/gir/namespace.d.ts +10 -10
- package/dist/gir/namespace.d.ts.map +1 -1
- package/dist/gir/namespace.js +21 -20
- package/dist/gir/namespace.js.map +1 -1
- package/dist/gir/nullable-overrides.d.ts +3 -0
- package/dist/gir/nullable-overrides.d.ts.map +1 -0
- package/dist/gir/nullable-overrides.js +5 -0
- package/dist/gir/nullable-overrides.js.map +1 -0
- package/dist/gir/parameter.d.ts +14 -12
- package/dist/gir/parameter.d.ts.map +1 -1
- package/dist/gir/parameter.js +27 -18
- package/dist/gir/parameter.js.map +1 -1
- package/dist/gir/parse.d.ts +12 -13
- package/dist/gir/parse.d.ts.map +1 -1
- package/dist/gir/parse.js +50 -40
- package/dist/gir/parse.js.map +1 -1
- package/dist/gir/primitives.d.ts +5 -4
- package/dist/gir/primitives.d.ts.map +1 -1
- package/dist/gir/primitives.js +4 -3
- package/dist/gir/primitives.js.map +1 -1
- package/dist/gir/property.d.ts +5 -4
- package/dist/gir/property.d.ts.map +1 -1
- package/dist/gir/property.js +10 -9
- package/dist/gir/property.js.map +1 -1
- package/dist/gir/record.d.ts +5 -4
- package/dist/gir/record.d.ts.map +1 -1
- package/dist/gir/record.js +13 -12
- package/dist/gir/record.js.map +1 -1
- package/dist/gir/size.d.ts +6 -5
- package/dist/gir/size.d.ts.map +1 -1
- package/dist/gir/size.js +49 -47
- package/dist/gir/size.js.map +1 -1
- package/dist/gir/type-id.d.ts +17 -15
- package/dist/gir/type-id.d.ts.map +1 -1
- package/dist/gir/type-id.js +5 -1
- package/dist/gir/type-id.js.map +1 -1
- package/dist/gir/type-ref.d.ts +3 -2
- package/dist/gir/type-ref.d.ts.map +1 -1
- package/dist/gir/type-ref.js +36 -25
- package/dist/gir/type-ref.js.map +1 -1
- package/dist/gir/type.d.ts +3 -2
- package/dist/gir/type.d.ts.map +1 -1
- package/dist/gir/type.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/jsx.d.ts +26 -0
- package/dist/jsx.d.ts.map +1 -0
- package/dist/jsx.js +40 -0
- package/dist/jsx.js.map +1 -0
- package/dist/khronos/args.d.ts +7 -7
- package/dist/khronos/args.d.ts.map +1 -1
- package/dist/khronos/args.js +88 -67
- package/dist/khronos/args.js.map +1 -1
- package/dist/khronos/jsdoc.d.ts +4 -4
- package/dist/khronos/jsdoc.d.ts.map +1 -1
- package/dist/khronos/jsdoc.js +29 -16
- package/dist/khronos/jsdoc.js.map +1 -1
- package/dist/khronos/model.d.ts +8 -7
- package/dist/khronos/model.d.ts.map +1 -1
- package/dist/khronos/model.js +94 -59
- package/dist/khronos/model.js.map +1 -1
- package/dist/khronos/modules.d.ts +4 -3
- package/dist/khronos/modules.d.ts.map +1 -1
- package/dist/khronos/modules.js +40 -25
- package/dist/khronos/modules.js.map +1 -1
- package/dist/khronos/param-pair.d.ts +11 -0
- package/dist/khronos/param-pair.d.ts.map +1 -0
- package/dist/khronos/param-pair.js +6 -0
- package/dist/khronos/param-pair.js.map +1 -0
- package/dist/khronos/parse.d.ts +7 -8
- package/dist/khronos/parse.d.ts.map +1 -1
- package/dist/khronos/parse.js +17 -16
- package/dist/khronos/parse.js.map +1 -1
- package/dist/khronos/pipeline.d.ts +4 -4
- package/dist/khronos/pipeline.d.ts.map +1 -1
- package/dist/khronos/pipeline.js +97 -56
- package/dist/khronos/pipeline.js.map +1 -1
- package/dist/khronos/plan.d.ts +11 -10
- package/dist/khronos/plan.d.ts.map +1 -1
- package/dist/khronos/plan.js +109 -45
- package/dist/khronos/plan.js.map +1 -1
- package/dist/khronos/render.d.ts +5 -4
- package/dist/khronos/render.d.ts.map +1 -1
- package/dist/khronos/render.js +106 -59
- package/dist/khronos/render.js.map +1 -1
- package/dist/khronos/select.d.ts +4 -4
- package/dist/khronos/select.d.ts.map +1 -1
- package/dist/khronos/select.js +30 -19
- package/dist/khronos/select.js.map +1 -1
- package/dist/react/element-config.d.ts +17 -0
- package/dist/react/element-config.d.ts.map +1 -0
- package/dist/react/element-config.js +61 -0
- package/dist/react/element-config.js.map +1 -0
- package/dist/runner.d.ts +17 -10
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +45 -43
- package/dist/runner.js.map +1 -1
- package/dist/store/compile-store.d.ts +5 -3
- package/dist/store/compile-store.d.ts.map +1 -1
- package/dist/store/compile-store.js +24 -22
- package/dist/store/compile-store.js.map +1 -1
- package/dist/store/gi/async.d.ts +2 -1
- package/dist/store/gi/async.d.ts.map +1 -1
- package/dist/store/gi/async.js +28 -24
- package/dist/store/gi/async.js.map +1 -1
- package/dist/store/gi/callables.d.ts +26 -20
- package/dist/store/gi/callables.d.ts.map +1 -1
- package/dist/store/gi/callables.js +162 -100
- package/dist/store/gi/callables.js.map +1 -1
- package/dist/store/gi/callback.d.ts +3 -2
- package/dist/store/gi/callback.d.ts.map +1 -1
- package/dist/store/gi/callback.js +6 -3
- package/dist/store/gi/callback.js.map +1 -1
- package/dist/store/gi/class-struct-record.d.ts +4 -3
- package/dist/store/gi/class-struct-record.d.ts.map +1 -1
- package/dist/store/gi/class-struct-record.js +33 -15
- package/dist/store/gi/class-struct-record.js.map +1 -1
- package/dist/store/gi/class.d.ts +2 -1
- package/dist/store/gi/class.d.ts.map +1 -1
- package/dist/store/gi/class.js +86 -47
- package/dist/store/gi/class.js.map +1 -1
- package/dist/store/gi/companion.d.ts +2 -1
- package/dist/store/gi/companion.d.ts.map +1 -1
- package/dist/store/gi/companion.js +8 -5
- package/dist/store/gi/companion.js.map +1 -1
- package/dist/store/gi/constant.d.ts +3 -2
- package/dist/store/gi/constant.d.ts.map +1 -1
- package/dist/store/gi/constant.js +25 -8
- package/dist/store/gi/constant.js.map +1 -1
- package/dist/store/gi/constructor-props.d.ts +3 -2
- package/dist/store/gi/constructor-props.d.ts.map +1 -1
- package/dist/store/gi/constructor-props.js +17 -10
- package/dist/store/gi/constructor-props.js.map +1 -1
- package/dist/store/gi/enum.d.ts +3 -2
- package/dist/store/gi/enum.d.ts.map +1 -1
- package/dist/store/gi/enum.js +14 -11
- package/dist/store/gi/enum.js.map +1 -1
- package/dist/store/gi/function.d.ts +5 -4
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +50 -23
- package/dist/store/gi/function.js.map +1 -1
- package/dist/store/gi/gtype-binding.d.ts +4 -4
- package/dist/store/gi/gtype-binding.d.ts.map +1 -1
- package/dist/store/gi/gtype-binding.js +15 -11
- package/dist/store/gi/gtype-binding.js.map +1 -1
- package/dist/store/gi/interface.d.ts +2 -1
- package/dist/store/gi/interface.d.ts.map +1 -1
- package/dist/store/gi/interface.js +36 -18
- package/dist/store/gi/interface.js.map +1 -1
- package/dist/store/gi/item-comparators.d.ts +3 -2
- package/dist/store/gi/item-comparators.d.ts.map +1 -1
- package/dist/store/gi/item-comparators.js +33 -21
- package/dist/store/gi/item-comparators.js.map +1 -1
- package/dist/store/gi/method.d.ts +13 -13
- package/dist/store/gi/method.d.ts.map +1 -1
- package/dist/store/gi/method.js +187 -130
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/param-marshal.d.ts +7 -6
- package/dist/store/gi/param-marshal.d.ts.map +1 -1
- package/dist/store/gi/param-marshal.js +26 -13
- package/dist/store/gi/param-marshal.js.map +1 -1
- package/dist/store/gi/pipeline.d.ts +2 -1
- package/dist/store/gi/pipeline.d.ts.map +1 -1
- package/dist/store/gi/pipeline.js +38 -23
- package/dist/store/gi/pipeline.js.map +1 -1
- package/dist/store/gi/properties.d.ts +2 -1
- package/dist/store/gi/properties.d.ts.map +1 -1
- package/dist/store/gi/properties.js +6 -4
- package/dist/store/gi/properties.js.map +1 -1
- package/dist/store/gi/property-accessor.d.ts +11 -10
- package/dist/store/gi/property-accessor.d.ts.map +1 -1
- package/dist/store/gi/property-accessor.js +86 -60
- package/dist/store/gi/property-accessor.js.map +1 -1
- package/dist/store/gi/record-constructor.d.ts +3 -2
- package/dist/store/gi/record-constructor.d.ts.map +1 -1
- package/dist/store/gi/record-constructor.js +36 -25
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +8 -8
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +171 -99
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record-layout.d.ts +6 -5
- package/dist/store/gi/record-layout.d.ts.map +1 -1
- package/dist/store/gi/record-layout.js +75 -39
- package/dist/store/gi/record-layout.js.map +1 -1
- package/dist/store/gi/record.d.ts +2 -1
- package/dist/store/gi/record.d.ts.map +1 -1
- package/dist/store/gi/record.js +19 -13
- package/dist/store/gi/record.js.map +1 -1
- package/dist/store/gi/registration.d.ts +3 -3
- package/dist/store/gi/registration.d.ts.map +1 -1
- package/dist/store/gi/registration.js +3 -2
- package/dist/store/gi/registration.js.map +1 -1
- package/dist/store/gi/return-wrap.d.ts +2 -2
- package/dist/store/gi/return-wrap.d.ts.map +1 -1
- package/dist/store/gi/return-wrap.js +43 -22
- package/dist/store/gi/return-wrap.js.map +1 -1
- package/dist/store/gi/runtime-override.d.ts +2 -1
- package/dist/store/gi/runtime-override.d.ts.map +1 -1
- package/dist/store/gi/runtime-override.js +6 -3
- package/dist/store/gi/runtime-override.js.map +1 -1
- package/dist/store/gi/signal.d.ts +3 -2
- package/dist/store/gi/signal.d.ts.map +1 -1
- package/dist/store/gi/signal.js +113 -66
- package/dist/store/gi/signal.js.map +1 -1
- package/dist/store/gi/vtable.d.ts +2 -1
- package/dist/store/gi/vtable.d.ts.map +1 -1
- package/dist/store/gi/vtable.js +60 -30
- package/dist/store/gi/vtable.js.map +1 -1
- package/dist/store/gi-store.d.ts +5 -4
- package/dist/store/gi-store.d.ts.map +1 -1
- package/dist/store/gi-store.js +4 -2
- package/dist/store/gi-store.js.map +1 -1
- package/dist/store/jsx/element-components.d.ts +23 -0
- package/dist/store/jsx/element-components.d.ts.map +1 -0
- package/dist/store/jsx/element-components.js +86 -0
- package/dist/store/jsx/element-components.js.map +1 -0
- package/dist/store/jsx/element-prop-imports.d.ts +17 -0
- package/dist/store/jsx/element-prop-imports.d.ts.map +1 -0
- package/dist/store/jsx/element-prop-imports.js +15 -0
- package/dist/store/jsx/element-prop-imports.js.map +1 -0
- package/dist/store/jsx/element-prop-types.d.ts +10 -0
- package/dist/store/jsx/element-prop-types.d.ts.map +1 -0
- package/dist/store/jsx/element-prop-types.js +41 -0
- package/dist/store/jsx/element-prop-types.js.map +1 -0
- package/dist/store/jsx/gir-index.d.ts +16 -0
- package/dist/store/jsx/gir-index.d.ts.map +1 -0
- package/dist/store/jsx/gir-index.js +33 -0
- package/dist/store/jsx/gir-index.js.map +1 -0
- package/dist/store/jsx/intrinsic-elements.d.ts +27 -0
- package/dist/store/jsx/intrinsic-elements.d.ts.map +1 -0
- package/dist/store/jsx/intrinsic-elements.js +128 -0
- package/dist/store/jsx/intrinsic-elements.js.map +1 -0
- package/dist/store/{react → jsx}/jsx.d.ts +2 -4
- package/dist/store/jsx/jsx.d.ts.map +1 -0
- package/dist/store/{react → jsx}/jsx.js +110 -71
- package/dist/store/jsx/jsx.js.map +1 -0
- package/dist/store/jsx/metadata.d.ts +4 -0
- package/dist/store/jsx/metadata.d.ts.map +1 -0
- package/dist/store/{react → jsx}/metadata.js +148 -69
- package/dist/store/jsx/metadata.js.map +1 -0
- package/dist/store/jsx/pipeline.d.ts +21 -0
- package/dist/store/jsx/pipeline.d.ts.map +1 -0
- package/dist/store/{react → jsx}/pipeline.js +36 -15
- package/dist/store/jsx/pipeline.js.map +1 -0
- package/dist/store/{react → jsx}/props.d.ts +9 -12
- package/dist/store/jsx/props.d.ts.map +1 -0
- package/dist/store/jsx/props.js +158 -0
- package/dist/store/jsx/props.js.map +1 -0
- package/dist/store/jsx-store.d.ts +5 -3
- package/dist/store/jsx-store.d.ts.map +1 -1
- package/dist/store/jsx-store.js +4 -1
- package/dist/store/jsx-store.js.map +1 -1
- package/dist/store/store-fs.d.ts +14 -12
- package/dist/store/store-fs.d.ts.map +1 -1
- package/dist/store/store-fs.js +9 -7
- package/dist/store/store-fs.js.map +1 -1
- package/dist/writer/context.d.ts +2 -1
- package/dist/writer/context.d.ts.map +1 -1
- package/dist/writer/context.js +12 -6
- package/dist/writer/context.js.map +1 -1
- package/dist/writer/doc.d.ts +2 -1
- package/dist/writer/doc.d.ts.map +1 -1
- package/dist/writer/doc.js +13 -7
- package/dist/writer/doc.js.map +1 -1
- package/dist/writer/emit.d.ts +8 -7
- package/dist/writer/emit.d.ts.map +1 -1
- package/dist/writer/emit.js +13 -10
- package/dist/writer/emit.js.map +1 -1
- package/dist/writer/gtk-doc.d.ts +2 -1
- package/dist/writer/gtk-doc.d.ts.map +1 -1
- package/dist/writer/gtk-doc.js +29 -18
- package/dist/writer/gtk-doc.js.map +1 -1
- package/dist/writer/imports.d.ts +4 -2
- package/dist/writer/imports.d.ts.map +1 -1
- package/dist/writer/imports.js +35 -24
- package/dist/writer/imports.js.map +1 -1
- package/dist/writer/module.d.ts +3 -2
- package/dist/writer/module.d.ts.map +1 -1
- package/dist/writer/module.js +16 -9
- package/dist/writer/module.js.map +1 -1
- package/dist/xml.d.ts +4 -0
- package/dist/xml.d.ts.map +1 -0
- package/dist/xml.js +10 -0
- package/dist/xml.js.map +1 -0
- package/overrides/cairo/context.ts.ejs +7 -7
- package/overrides/cairo/matrix.ts.ejs +2 -2
- package/overrides/cairo/recording-surface.ts.ejs +2 -2
- package/overrides/cairo/region.ts.ejs +1 -1
- package/overrides/cairo/scaled-font.ts.ejs +3 -3
- package/package.json +15 -9
- package/src/analysis/descriptor-render.ts +484 -168
- package/src/analysis/descriptor.ts +162 -125
- package/src/analysis/inheritance.ts +286 -98
- package/src/analysis/param-structure.ts +188 -57
- package/src/analysis/ts-type.ts +112 -26
- package/src/compile.ts +103 -76
- package/src/docs/api-reference.ts +340 -144
- package/src/docs/element-page.ts +137 -146
- package/src/docs/pipeline.ts +132 -73
- package/src/docs/render.ts +151 -87
- package/src/docs/symbol-page.ts +268 -123
- package/src/fingerprint.ts +127 -29
- package/src/gi.ts +26 -0
- package/src/gir/ancestry.ts +26 -14
- package/src/gir/callback.ts +10 -15
- package/src/gir/class.ts +20 -16
- package/src/gir/enum.ts +9 -7
- package/src/gir/field.ts +37 -8
- package/src/gir/function.ts +33 -9
- package/src/gir/gir-path.ts +36 -12
- package/src/gir/libraries.ts +56 -31
- package/src/gir/library.ts +200 -97
- package/src/gir/namespace.ts +42 -26
- package/src/gir/nullable-overrides.ts +5 -0
- package/src/gir/parameter.ts +80 -42
- package/src/gir/parse.ts +102 -47
- package/src/gir/primitives.ts +25 -23
- package/src/gir/property.ts +13 -11
- package/src/gir/record.ts +16 -14
- package/src/gir/size.ts +91 -58
- package/src/gir/type-id.ts +33 -18
- package/src/gir/type-ref.ts +62 -26
- package/src/gir/type.ts +10 -8
- package/src/index.ts +7 -0
- package/src/jsx.ts +70 -0
- package/src/khronos/args.ts +158 -89
- package/src/khronos/jsdoc.ts +67 -29
- package/src/khronos/model.ts +154 -53
- package/src/khronos/modules.ts +67 -27
- package/src/khronos/param-pair.ts +14 -0
- package/src/khronos/parse.ts +37 -17
- package/src/khronos/pipeline.ts +193 -90
- package/src/khronos/plan.ts +235 -86
- package/src/khronos/render.ts +208 -71
- package/src/khronos/select.ts +48 -18
- package/src/react/element-config.ts +91 -0
- package/src/runner.ts +93 -57
- package/src/store/compile-store.ts +32 -26
- package/src/store/gi/async.ts +48 -21
- package/src/store/gi/callables.ts +345 -136
- package/src/store/gi/callback.ts +13 -4
- package/src/store/gi/class-struct-record.ts +49 -17
- package/src/store/gi/class.ts +186 -64
- package/src/store/gi/companion.ts +15 -6
- package/src/store/gi/constant.ts +42 -8
- package/src/store/gi/constructor-props.ts +42 -16
- package/src/store/gi/enum.ts +28 -13
- package/src/store/gi/function.ts +90 -24
- package/src/store/gi/gtype-binding.ts +31 -18
- package/src/store/gi/interface.ts +101 -36
- package/src/store/gi/item-comparators.ts +74 -26
- package/src/store/gi/method.ts +376 -159
- package/src/store/gi/param-marshal.ts +38 -15
- package/src/store/gi/pipeline.ts +72 -22
- package/src/store/gi/properties.ts +16 -5
- package/src/store/gi/property-accessor.ts +192 -84
- package/src/store/gi/record-constructor.ts +62 -30
- package/src/store/gi/record-field-accessor.ts +380 -167
- package/src/store/gi/record-layout.ts +130 -43
- package/src/store/gi/record.ts +37 -14
- package/src/store/gi/registration.ts +15 -9
- package/src/store/gi/return-wrap.ts +71 -23
- package/src/store/gi/runtime-override.ts +13 -3
- package/src/store/gi/signal.ts +244 -104
- package/src/store/gi/vtable.ts +117 -41
- package/src/store/gi-store.ts +26 -13
- package/src/store/jsx/element-components.ts +152 -0
- package/src/store/jsx/element-prop-imports.ts +24 -0
- package/src/store/jsx/element-prop-types.ts +59 -0
- package/src/store/jsx/gir-index.ts +62 -0
- package/src/store/jsx/intrinsic-elements.ts +262 -0
- package/src/store/{react → jsx}/jsx.ts +213 -99
- package/src/store/jsx/metadata.ts +385 -0
- package/src/store/jsx/pipeline.ts +145 -0
- package/src/store/jsx/props.ts +274 -0
- package/src/store/jsx-store.ts +15 -3
- package/src/store/store-fs.ts +36 -20
- package/src/writer/context.ts +25 -6
- package/src/writer/doc.ts +19 -5
- package/src/writer/emit.ts +20 -11
- package/src/writer/gtk-doc.ts +48 -21
- package/src/writer/imports.ts +63 -28
- package/src/writer/module.ts +35 -11
- package/src/xml.ts +12 -0
- package/dist/store/react/built-ins.d.ts +0 -9
- package/dist/store/react/built-ins.d.ts.map +0 -1
- package/dist/store/react/built-ins.js +0 -226
- package/dist/store/react/built-ins.js.map +0 -1
- package/dist/store/react/element-components.d.ts +0 -15
- package/dist/store/react/element-components.d.ts.map +0 -1
- package/dist/store/react/element-components.js +0 -92
- package/dist/store/react/element-components.js.map +0 -1
- package/dist/store/react/element-prop-types.d.ts +0 -19
- package/dist/store/react/element-prop-types.d.ts.map +0 -1
- package/dist/store/react/element-prop-types.js +0 -244
- package/dist/store/react/element-prop-types.js.map +0 -1
- package/dist/store/react/element-props.d.ts +0 -4
- package/dist/store/react/element-props.d.ts.map +0 -1
- package/dist/store/react/element-props.js +0 -178
- package/dist/store/react/element-props.js.map +0 -1
- package/dist/store/react/gir-index.d.ts +0 -25
- package/dist/store/react/gir-index.d.ts.map +0 -1
- package/dist/store/react/gir-index.js +0 -55
- package/dist/store/react/gir-index.js.map +0 -1
- package/dist/store/react/intrinsic-elements.d.ts +0 -26
- package/dist/store/react/intrinsic-elements.d.ts.map +0 -1
- package/dist/store/react/intrinsic-elements.js +0 -107
- package/dist/store/react/intrinsic-elements.js.map +0 -1
- package/dist/store/react/jsx.d.ts.map +0 -1
- package/dist/store/react/jsx.js.map +0 -1
- package/dist/store/react/metadata.d.ts +0 -4
- package/dist/store/react/metadata.d.ts.map +0 -1
- package/dist/store/react/metadata.js.map +0 -1
- package/dist/store/react/pipeline.d.ts +0 -14
- package/dist/store/react/pipeline.d.ts.map +0 -1
- package/dist/store/react/pipeline.js.map +0 -1
- package/dist/store/react/props.d.ts.map +0 -1
- package/dist/store/react/props.js +0 -133
- package/dist/store/react/props.js.map +0 -1
- package/overrides/gtk/constants.ts.ejs +0 -3
- package/overrides/gtk/index.ts.ejs +0 -2
- package/src/store/react/built-ins.ts +0 -260
- package/src/store/react/element-components.ts +0 -138
- package/src/store/react/element-prop-types.ts +0 -280
- package/src/store/react/element-props.ts +0 -204
- package/src/store/react/gir-index.ts +0 -85
- package/src/store/react/intrinsic-elements.ts +0 -161
- package/src/store/react/metadata.ts +0 -197
- package/src/store/react/pipeline.ts +0 -90
- package/src/store/react/props.ts +0 -197
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
import type { Call, ContainerProp, ElementProp } from "@gtkx/config";
|
|
2
|
-
|
|
3
|
-
export type ElementComponent = { types: string[]; module: string; export: string };
|
|
4
|
-
type ManyMethods = Pick<ContainerProp, "append" | "remove">;
|
|
5
|
-
|
|
6
|
-
const container = (
|
|
7
|
-
prop: string,
|
|
8
|
-
child: string,
|
|
9
|
-
methods: Omit<ContainerProp, "kind" | "prop" | "child">,
|
|
10
|
-
): ElementProp => ({
|
|
11
|
-
kind: "container",
|
|
12
|
-
prop,
|
|
13
|
-
child,
|
|
14
|
-
...methods,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
const nullSetter = (method: string): Call => ({ method, args: [{ literal: null }] });
|
|
18
|
-
|
|
19
|
-
const singleChild = (): ElementProp =>
|
|
20
|
-
container("children", "GtkWidget", { append: "setChild", remove: nullSetter("setChild") });
|
|
21
|
-
|
|
22
|
-
const singleContent = (): ElementProp =>
|
|
23
|
-
container("children", "GtkWidget", { append: "setContent", remove: nullSetter("setContent") });
|
|
24
|
-
|
|
25
|
-
const boxChildren = (): ElementProp =>
|
|
26
|
-
container("children", "GtkWidget", {
|
|
27
|
-
append: "append",
|
|
28
|
-
remove: "remove",
|
|
29
|
-
insert: { method: "insertChildAfter", args: ["child", "sibling"] },
|
|
30
|
-
reorder: { method: "reorderChildAfter", args: ["child", "sibling"] },
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const indexedChildren = (append: string, reorder?: string): ElementProp =>
|
|
34
|
-
container("children", "GtkWidget", {
|
|
35
|
-
append,
|
|
36
|
-
remove: "remove",
|
|
37
|
-
insert: { method: "insert", args: ["child", "index"] },
|
|
38
|
-
...(reorder !== undefined ? { reorder: { method: reorder, args: ["child", "index"] } } : {}),
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const addRemoveChildren = (): ElementProp => container("children", "GtkWidget", { append: "add", remove: "remove" });
|
|
42
|
-
|
|
43
|
-
const prefixSuffixProps = (): ElementProp[] => [
|
|
44
|
-
container("prefix", "GtkWidget", { append: "addPrefix" }),
|
|
45
|
-
container("suffix", "GtkWidget", { append: "addSuffix" }),
|
|
46
|
-
];
|
|
47
|
-
|
|
48
|
-
const packProps = (): ElementProp[] => [
|
|
49
|
-
container("start", "GtkWidget", { append: "packStart" }),
|
|
50
|
-
container("end", "GtkWidget", { append: "packEnd" }),
|
|
51
|
-
];
|
|
52
|
-
|
|
53
|
-
const autowrapProp = (wrapper: string): ElementProp =>
|
|
54
|
-
container("children", "GtkWidget", {
|
|
55
|
-
append: "append",
|
|
56
|
-
remove: "remove",
|
|
57
|
-
insert: { method: "insert", args: ["child", "index"] },
|
|
58
|
-
autowrap: wrapper,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const forEach = (types: string[], build: () => ElementProp[]): Record<string, ElementProp[]> =>
|
|
62
|
-
Object.fromEntries(types.map((type) => [type, build()]));
|
|
63
|
-
|
|
64
|
-
export const BUILT_IN_ELEMENT_COMPONENTS: ElementComponent[] = [
|
|
65
|
-
{ types: ["GtkApplication"], module: "@gtkx/react/internal", export: "createApplicationComponent" },
|
|
66
|
-
{ types: ["GtkWindow"], module: "@gtkx/react/internal", export: "createWindowComponent" },
|
|
67
|
-
{ types: ["AdwDialog"], module: "@gtkx/react/adw", export: "createDialogComponent" },
|
|
68
|
-
];
|
|
69
|
-
|
|
70
|
-
const CONTROLLER_METHODS = { append: "addController", remove: "removeController" } satisfies ManyMethods;
|
|
71
|
-
const SHORTCUT_METHODS = { append: "addShortcut", remove: "removeShortcut" } satisfies ManyMethods;
|
|
72
|
-
|
|
73
|
-
const ACTION_METHODS = {
|
|
74
|
-
append: "addAction",
|
|
75
|
-
remove: { method: "removeAction", args: [{ prop: "name" }] },
|
|
76
|
-
} satisfies ManyMethods;
|
|
77
|
-
|
|
78
|
-
const ACTION_GROUP_METHODS = {
|
|
79
|
-
append: { method: "insertActionGroup", args: [{ prop: "prefix" }, "child"] },
|
|
80
|
-
remove: { method: "insertActionGroup", args: [{ prop: "prefix" }, { literal: null }] },
|
|
81
|
-
} satisfies ManyMethods;
|
|
82
|
-
|
|
83
|
-
const SINGLE_CHILD_TYPES = [
|
|
84
|
-
"AdwBin",
|
|
85
|
-
"AdwBreakpointBin",
|
|
86
|
-
"AdwClamp",
|
|
87
|
-
"AdwClampScrollable",
|
|
88
|
-
"AdwDialog",
|
|
89
|
-
"AdwNavigationPage",
|
|
90
|
-
"AdwSplitButton",
|
|
91
|
-
"AdwStatusPage",
|
|
92
|
-
"AdwTabOverview",
|
|
93
|
-
"AdwToastOverlay",
|
|
94
|
-
"AdwToggle",
|
|
95
|
-
"GtkAspectFrame",
|
|
96
|
-
"GtkButton",
|
|
97
|
-
"GtkCheckButton",
|
|
98
|
-
"GtkComboBox",
|
|
99
|
-
"GtkDragIcon",
|
|
100
|
-
"GtkExpander",
|
|
101
|
-
"GtkFlowBoxChild",
|
|
102
|
-
"GtkFrame",
|
|
103
|
-
"GtkGraphicsOffload",
|
|
104
|
-
"GtkListBoxRow",
|
|
105
|
-
"GtkListHeader",
|
|
106
|
-
"GtkListItem",
|
|
107
|
-
"GtkMenuButton",
|
|
108
|
-
"GtkOverlay",
|
|
109
|
-
"GtkPopover",
|
|
110
|
-
"GtkPopoverBin",
|
|
111
|
-
"GtkRevealer",
|
|
112
|
-
"GtkScrolledWindow",
|
|
113
|
-
"GtkSearchBar",
|
|
114
|
-
"GtkTreeExpander",
|
|
115
|
-
"GtkViewport",
|
|
116
|
-
"GtkWindow",
|
|
117
|
-
"GtkWindowHandle",
|
|
118
|
-
];
|
|
119
|
-
|
|
120
|
-
const SINGLE_CONTENT_TYPES = [
|
|
121
|
-
"AdwApplicationWindow",
|
|
122
|
-
"AdwBottomSheet",
|
|
123
|
-
"AdwFlap",
|
|
124
|
-
"AdwNavigationSplitView",
|
|
125
|
-
"AdwOverlaySplitView",
|
|
126
|
-
"AdwWindow",
|
|
127
|
-
];
|
|
128
|
-
|
|
129
|
-
const BOX_TYPES = ["AdwLeaflet", "AdwWrapBox", "GtkBox"];
|
|
130
|
-
|
|
131
|
-
const ADD_REMOVE_TYPES = [
|
|
132
|
-
"AdwNavigationView",
|
|
133
|
-
"AdwPreferencesDialog",
|
|
134
|
-
"AdwPreferencesGroup",
|
|
135
|
-
"AdwPreferencesWindow",
|
|
136
|
-
"AdwSqueezer",
|
|
137
|
-
];
|
|
138
|
-
|
|
139
|
-
const withBreakpoints = (props: Record<string, ElementProp[]>): Record<string, ElementProp[]> => {
|
|
140
|
-
for (const type of ["AdwApplicationWindow", "AdwWindow", "AdwDialog"]) {
|
|
141
|
-
props[type] = [...(props[type] ?? []), container("breakpoints", "AdwBreakpoint", { append: "addBreakpoint" })];
|
|
142
|
-
}
|
|
143
|
-
props.AdwBreakpointBin = [
|
|
144
|
-
...(props.AdwBreakpointBin ?? []),
|
|
145
|
-
container("breakpoints", "AdwBreakpoint", { append: "addBreakpoint", remove: "removeBreakpoint" }),
|
|
146
|
-
];
|
|
147
|
-
return props;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
export const BUILT_IN_ELEMENT_PROPS: Record<string, ElementProp[]> = withBreakpoints({
|
|
151
|
-
...forEach(SINGLE_CHILD_TYPES, () => [singleChild()]),
|
|
152
|
-
...forEach(SINGLE_CONTENT_TYPES, () => [singleContent()]),
|
|
153
|
-
...forEach(BOX_TYPES, () => [boxChildren()]),
|
|
154
|
-
...forEach(ADD_REMOVE_TYPES, () => [addRemoveChildren()]),
|
|
155
|
-
GtkWidget: [
|
|
156
|
-
container("controllers", "GtkEventController", CONTROLLER_METHODS),
|
|
157
|
-
container("layoutManager", "GtkLayoutManager", {
|
|
158
|
-
append: "setLayoutManager",
|
|
159
|
-
remove: { method: "setLayoutManager", args: [{ literal: null }] },
|
|
160
|
-
}),
|
|
161
|
-
container("actionGroups", "GActionGroup", ACTION_GROUP_METHODS),
|
|
162
|
-
],
|
|
163
|
-
GtkShortcutController: [container("shortcuts", "GtkShortcut", SHORTCUT_METHODS)],
|
|
164
|
-
GtkTextView: [
|
|
165
|
-
container("children", "GtkTextBuffer", {
|
|
166
|
-
append: "setBuffer",
|
|
167
|
-
remove: { method: "setBuffer", args: [{ literal: null }] },
|
|
168
|
-
}),
|
|
169
|
-
container("children", "GtkWidget", { remove: "remove" }),
|
|
170
|
-
],
|
|
171
|
-
GActionMap: [container("actions", "GAction", ACTION_METHODS)],
|
|
172
|
-
GtkColumnView: [
|
|
173
|
-
container("children", "GtkColumnViewColumn", {
|
|
174
|
-
append: "appendColumn",
|
|
175
|
-
remove: "removeColumn",
|
|
176
|
-
insert: { method: "insertColumn", args: ["index", "child"] },
|
|
177
|
-
}),
|
|
178
|
-
],
|
|
179
|
-
AdwShortcutsDialog: [container("children", "AdwShortcutsSection", { append: "add" })],
|
|
180
|
-
AdwShortcutsSection: [container("children", "AdwShortcutsItem", { append: "add" })],
|
|
181
|
-
AdwActionRow: prefixSuffixProps(),
|
|
182
|
-
AdwEntryRow: prefixSuffixProps(),
|
|
183
|
-
AdwExpanderRow: [
|
|
184
|
-
...prefixSuffixProps(),
|
|
185
|
-
container("rows", "GtkWidget", { append: "addRow" }),
|
|
186
|
-
container("actions", "GtkWidget", { append: "addAction" }),
|
|
187
|
-
],
|
|
188
|
-
AdwHeaderBar: packProps(),
|
|
189
|
-
GtkHeaderBar: packProps(),
|
|
190
|
-
GtkActionBar: packProps(),
|
|
191
|
-
AdwToolbarView: [
|
|
192
|
-
container("topBar", "GtkWidget", { append: "addTopBar" }),
|
|
193
|
-
container("bottomBar", "GtkWidget", { append: "addBottomBar" }),
|
|
194
|
-
singleContent(),
|
|
195
|
-
],
|
|
196
|
-
AdwCarousel: [indexedChildren("append", "reorder")],
|
|
197
|
-
AdwPreferencesPage: [indexedChildren("add")],
|
|
198
|
-
AdwTabView: [
|
|
199
|
-
container("children", "GtkWidget", {
|
|
200
|
-
append: "append",
|
|
201
|
-
insert: { method: "insert", args: ["child", "index"] },
|
|
202
|
-
reorder: { method: "reorderPage", args: ["adopted", "index"] },
|
|
203
|
-
remove: { method: "closePage", args: ["adopted"] },
|
|
204
|
-
adopt: "getPage",
|
|
205
|
-
}),
|
|
206
|
-
],
|
|
207
|
-
GtkListBox: [autowrapProp("GtkListBoxRow")],
|
|
208
|
-
GtkFlowBox: [autowrapProp("GtkFlowBoxChild")],
|
|
209
|
-
GtkStack: [
|
|
210
|
-
container("children", "GtkWidget", { append: "addChild", remove: "remove", adopt: true }),
|
|
211
|
-
{ kind: "lazy", prop: "visibleChildName", lookup: "getChildByName" },
|
|
212
|
-
],
|
|
213
|
-
AdwViewStack: [
|
|
214
|
-
container("children", "GtkWidget", { append: "add", remove: "remove", adopt: true }),
|
|
215
|
-
{ kind: "lazy", prop: "visibleChildName", lookup: "getChildByName" },
|
|
216
|
-
],
|
|
217
|
-
GtkNotebook: [
|
|
218
|
-
container("children", "GtkWidget", {
|
|
219
|
-
append: { method: "appendPage", args: ["child", { literal: null }] },
|
|
220
|
-
insert: { method: "insertPage", args: ["child", { literal: null }, "index"] },
|
|
221
|
-
reorder: { method: "reorderChild", args: ["child", "index"] },
|
|
222
|
-
remove: "detachTab",
|
|
223
|
-
adopt: "getPage",
|
|
224
|
-
}),
|
|
225
|
-
],
|
|
226
|
-
AdwToggleGroup: [
|
|
227
|
-
container("children", "AdwToggle", { append: "add", remove: "remove" }),
|
|
228
|
-
{ kind: "lazy", prop: "activeName", lookup: "getToggleByName" },
|
|
229
|
-
{ kind: "lazy", prop: "active" },
|
|
230
|
-
],
|
|
231
|
-
GtkDropTarget: [{ kind: "value", prop: "types", call: "setGtypes" }],
|
|
232
|
-
GtkDrawingArea: [{ kind: "value", prop: "drawFunc", call: "setDrawFunc", after: "queueDraw" }],
|
|
233
|
-
GtkDragSource: [{ kind: "value", prop: "icon", call: "setIcon" }],
|
|
234
|
-
GtkEditable: [{ kind: "controlled-text", prop: "text" }],
|
|
235
|
-
GtkScale: [{ kind: "list", prop: "marks", add: "addMark", clear: "clearMarks" }],
|
|
236
|
-
GtkCalendar: [{ kind: "list", prop: "markedDays", add: "markDay", clear: "clearMarks" }],
|
|
237
|
-
GtkLevelBar: [{ kind: "list", prop: "offsets", add: "addOffsetValue", remove: "removeOffsetValue" }],
|
|
238
|
-
GtkApplication: [
|
|
239
|
-
container("children", "GtkWindow", { append: "addWindow", remove: "removeWindow" }),
|
|
240
|
-
{
|
|
241
|
-
kind: "list",
|
|
242
|
-
prop: "actionAccels",
|
|
243
|
-
add: "setAccelsForAction",
|
|
244
|
-
remove: { method: "setAccelsForAction", args: [{ field: "detailedActionName" }, { literal: [] }] },
|
|
245
|
-
},
|
|
246
|
-
],
|
|
247
|
-
GtkAboutDialog: [{ kind: "list", prop: "creditSections", add: "addCreditSection" }],
|
|
248
|
-
AdwAlertDialog: [
|
|
249
|
-
{
|
|
250
|
-
kind: "list",
|
|
251
|
-
prop: "responses",
|
|
252
|
-
add: [
|
|
253
|
-
"addResponse",
|
|
254
|
-
{ method: "setResponseAppearance", args: [{ field: "id" }, { field: "appearance", or: 0 }] },
|
|
255
|
-
{ method: "setResponseEnabled", args: [{ field: "id" }, { field: "enabled", or: true }] },
|
|
256
|
-
],
|
|
257
|
-
remove: "removeResponse",
|
|
258
|
-
},
|
|
259
|
-
],
|
|
260
|
-
});
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { sourceStringLiteral } from "@gtkx/utils";
|
|
2
|
-
import type { Library } from "../../gir/library.js";
|
|
3
|
-
import type { GirNamespace } from "../../gir/namespace.js";
|
|
4
|
-
import { renderJsDoc } from "../../writer/doc.js";
|
|
5
|
-
import type { ImportsBuilder } from "../../writer/imports.js";
|
|
6
|
-
import { BUILT_IN_ELEMENT_COMPONENTS, type ElementComponent } from "./built-ins.js";
|
|
7
|
-
import type { ElementPropTypegen, LazyElementSpec } from "./element-prop-types.js";
|
|
8
|
-
import { ancestorGlibNames, type GlibNamedClass } from "./intrinsic-elements.js";
|
|
9
|
-
|
|
10
|
-
type TextNodeElement = {
|
|
11
|
-
flatName: string;
|
|
12
|
-
kind: string;
|
|
13
|
-
propsType: string;
|
|
14
|
-
parent: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const TEXT_NODE_ELEMENTS: TextNodeElement[] = [
|
|
18
|
-
{ flatName: "GtkTextAnchor", kind: "text-anchor", propsType: "TextAnchorProps", parent: "GtkTextView" },
|
|
19
|
-
{ flatName: "GtkTextPaintable", kind: "text-paintable", propsType: "TextPaintableProps", parent: "GtkTextView" },
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
type ExportCollector = {
|
|
23
|
-
imports: ImportsBuilder;
|
|
24
|
-
exportedNames: Set<string>;
|
|
25
|
-
exportLines: string[];
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const generateElementComponentsSection = (
|
|
29
|
-
targetNamespace: GirNamespace,
|
|
30
|
-
library: Library,
|
|
31
|
-
options: {
|
|
32
|
-
imports: ImportsBuilder;
|
|
33
|
-
typegen: ElementPropTypegen;
|
|
34
|
-
intrinsicElements: GlibNamedClass[];
|
|
35
|
-
intrinsicElementByGlibName: Map<string, GlibNamedClass>;
|
|
36
|
-
},
|
|
37
|
-
): { source: string; exportedNames: Set<string> } => {
|
|
38
|
-
const collector: ExportCollector = { imports: options.imports, exportedNames: new Set(), exportLines: [] };
|
|
39
|
-
|
|
40
|
-
const inTargetNamespace = (parentGlibName: string): boolean =>
|
|
41
|
-
options.intrinsicElementByGlibName.get(parentGlibName)?.namespace.name === targetNamespace.name;
|
|
42
|
-
|
|
43
|
-
const lazyElements = options.typegen.lazyElementExports(targetNamespace.name);
|
|
44
|
-
const textNodes = TEXT_NODE_ELEMENTS.filter((node) => inTargetNamespace(node.parent));
|
|
45
|
-
const virtualNames = new Set([
|
|
46
|
-
...lazyElements.map((entry) => entry.element),
|
|
47
|
-
...textNodes.map((node) => node.flatName),
|
|
48
|
-
]);
|
|
49
|
-
|
|
50
|
-
collectCandidateExports(collector, {
|
|
51
|
-
targetNamespace,
|
|
52
|
-
library,
|
|
53
|
-
virtualNames,
|
|
54
|
-
intrinsicElements: options.intrinsicElements,
|
|
55
|
-
});
|
|
56
|
-
collectLazyElementExports(collector, lazyElements);
|
|
57
|
-
collectTextNodeExports(collector, textNodes);
|
|
58
|
-
|
|
59
|
-
if (textNodes.length > 0) {
|
|
60
|
-
collector.imports.addNamed("@gtkx/react/internal", "WRAPPER_NODE_ELEMENT", false);
|
|
61
|
-
}
|
|
62
|
-
const source = collector.exportLines.join("\n\n");
|
|
63
|
-
return { source, exportedNames: collector.exportedNames };
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
type CandidateExportOptions = {
|
|
67
|
-
targetNamespace: GirNamespace;
|
|
68
|
-
library: Library;
|
|
69
|
-
virtualNames: Set<string>;
|
|
70
|
-
intrinsicElements: GlibNamedClass[];
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const collectCandidateExports = (
|
|
74
|
-
collector: ExportCollector,
|
|
75
|
-
{ targetNamespace, library, virtualNames, intrinsicElements }: CandidateExportOptions,
|
|
76
|
-
): void => {
|
|
77
|
-
for (const candidate of intrinsicElements) {
|
|
78
|
-
if (candidate.namespace.name !== targetNamespace.name) continue;
|
|
79
|
-
if (virtualNames.has(candidate.glibName)) continue;
|
|
80
|
-
const line = renderCandidateExport(candidate, library, collector.imports);
|
|
81
|
-
if (line === null) continue;
|
|
82
|
-
collector.exportLines.push(line);
|
|
83
|
-
collector.exportedNames.add(candidate.glibName);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const collectLazyElementExports = (collector: ExportCollector, lazyElements: LazyElementSpec[]): void => {
|
|
88
|
-
for (const spec of lazyElements) {
|
|
89
|
-
collector.imports.addNamed("@gtkx/react/internal", "createLazyElementComponent", false);
|
|
90
|
-
collector.imports.addNamed("react", "ReactNode", true);
|
|
91
|
-
collector.exportLines.push(renderLazyElementExport(spec));
|
|
92
|
-
collector.exportedNames.add(spec.element);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const collectTextNodeExports = (collector: ExportCollector, textNodes: TextNodeElement[]): void => {
|
|
97
|
-
for (const node of textNodes) {
|
|
98
|
-
collector.imports.addNamed("@gtkx/react", node.propsType, true);
|
|
99
|
-
collector.imports.addNamed("react", "ReactNode", true);
|
|
100
|
-
collector.exportLines.push(renderTextNodeExport(node));
|
|
101
|
-
collector.exportedNames.add(node.flatName);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const renderLazyElementExport = (spec: LazyElementSpec): string => {
|
|
106
|
-
const factory = `createLazyElementComponent<${spec.typeName}>()`;
|
|
107
|
-
const component = `export const ${spec.element}: (props: ${spec.typeName}) => ReactNode = ${factory};`;
|
|
108
|
-
return `${spec.typeSource}\n\n${component}`;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const renderTextNodeExport = (node: TextNodeElement): string =>
|
|
112
|
-
`export const ${node.flatName} = (props: ${node.propsType}): ReactNode => (\n <WRAPPER_NODE_ELEMENT kind=${sourceStringLiteral(node.kind)} {...props} />\n);`;
|
|
113
|
-
|
|
114
|
-
const renderCandidateExport = (candidate: GlibNamedClass, library: Library, imports: ImportsBuilder): string | null => {
|
|
115
|
-
const { glibName, klass, namespace } = candidate;
|
|
116
|
-
const ancestry = new Set(ancestorGlibNames(klass, namespace, library));
|
|
117
|
-
const wrapper = resolveElementComponent(ancestry);
|
|
118
|
-
imports.addNamed("@gtkx/react/internal", "createElementComponent", false);
|
|
119
|
-
imports.addNamed("react", "ReactNode", true);
|
|
120
|
-
if (wrapper !== undefined) imports.addNamed(wrapper.module, wrapper.export, false);
|
|
121
|
-
return `${renderJsDoc(klass.doc)}${renderElementComponentExport(glibName, wrapper)}`;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const resolveElementComponent = (types: Set<string>): ElementComponent | undefined => {
|
|
125
|
-
for (const entry of BUILT_IN_ELEMENT_COMPONENTS) {
|
|
126
|
-
if (entry.types.some((type) => types.has(type))) return entry;
|
|
127
|
-
}
|
|
128
|
-
return undefined;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const renderElementComponentExport = (glibName: string, wrapper: ElementComponent | undefined): string => {
|
|
132
|
-
const propsType = `${glibName}Props`;
|
|
133
|
-
if (wrapper === undefined) {
|
|
134
|
-
return `export const ${glibName}: (props: ${propsType}) => ReactNode = createElementComponent(${sourceStringLiteral(glibName)});`;
|
|
135
|
-
}
|
|
136
|
-
const annotation = `(props: ${propsType}) => ReactNode`;
|
|
137
|
-
return `export const ${glibName}: ${annotation} = ${wrapper.export}(createElementComponent(${sourceStringLiteral(glibName)}));`;
|
|
138
|
-
};
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import type { AppliedProp, Call, ContainerProp, ElementProp } from "@gtkx/config";
|
|
2
|
-
import { toCamelIdentifier } from "@gtkx/utils";
|
|
3
|
-
import { renderBaseTypeFor } from "../../analysis/ts-type.js";
|
|
4
|
-
import type { GirClass } from "../../gir/class.js";
|
|
5
|
-
import type { GirNamespace } from "../../gir/namespace.js";
|
|
6
|
-
import type { GirParameter } from "../../gir/parameter.js";
|
|
7
|
-
import { chainOf, findMethod, type GirIndex, type GirTypeEntry, hasProperty } from "./gir-index.js";
|
|
8
|
-
import { glibNameOf } from "./intrinsic-elements.js";
|
|
9
|
-
import { reactTarget } from "./props.js";
|
|
10
|
-
|
|
11
|
-
type TypeImports = Map<string, string>;
|
|
12
|
-
|
|
13
|
-
type PropContribution = {
|
|
14
|
-
child: string;
|
|
15
|
-
prop: string;
|
|
16
|
-
param: GirParameter;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type LazyElementSpec = {
|
|
20
|
-
element: string;
|
|
21
|
-
typeName: string;
|
|
22
|
-
typeSource: string;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type ElementPropTypegen = {
|
|
26
|
-
classPropLines: (glibName: string, klass: GirClass, namespace: GirNamespace, imports: TypeImports) => string[];
|
|
27
|
-
lazyElementExports: (namespaceName: string) => LazyElementSpec[];
|
|
28
|
-
containerPropNamesFor: (glibName: string) => string[];
|
|
29
|
-
acceptsChildren: (glibName: string) => boolean;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const forEachContainer = (
|
|
33
|
-
elementProps: Record<string, ElementProp[]>,
|
|
34
|
-
visit: (type: string, prop: ContainerProp) => void,
|
|
35
|
-
): void => {
|
|
36
|
-
for (const [type, props] of Object.entries(elementProps)) {
|
|
37
|
-
for (const prop of props) {
|
|
38
|
-
if (prop.kind === "container") visit(type, prop);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const renderParamType = (context: GirIndex, imports: TypeImports, param: GirParameter | undefined): string => {
|
|
44
|
-
if (param === undefined) return "unknown";
|
|
45
|
-
const base = renderBaseTypeFor(context.library, reactTarget({ library: context.library, imports }), param.type);
|
|
46
|
-
return param.nullable || param.optional ? `${base} | null` : base;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const optionalLine = (prop: string, type: string): string => {
|
|
50
|
-
const withNull = type.endsWith(" | null") ? type : `${type} | null`;
|
|
51
|
-
return `${prop}?: ${withNull} | undefined;`;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
type FieldLine = { field: string; text: string };
|
|
55
|
-
|
|
56
|
-
const callFieldLines = (context: GirIndex, imports: TypeImports, type: string, call: Call): FieldLine[] => {
|
|
57
|
-
if (typeof call === "string") return [];
|
|
58
|
-
const method = findMethod(context, type, call.method);
|
|
59
|
-
const lines: FieldLine[] = [];
|
|
60
|
-
call.args.forEach((arg, positionIndex) => {
|
|
61
|
-
if (typeof arg !== "object" || !("field" in arg)) return;
|
|
62
|
-
const param = method?.params[positionIndex];
|
|
63
|
-
const optional = "or" in arg || param?.nullable === true || param?.optional === true;
|
|
64
|
-
lines.push({
|
|
65
|
-
field: arg.field,
|
|
66
|
-
text: `${arg.field}${optional ? "?" : ""}: ${renderParamType(context, imports, param)};`,
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
return lines;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const mergedFieldsType = (lines: FieldLine[]): string => {
|
|
73
|
-
const seen = new Set<string>();
|
|
74
|
-
const texts: string[] = [];
|
|
75
|
-
for (const line of lines) {
|
|
76
|
-
if (seen.has(line.field)) continue;
|
|
77
|
-
seen.add(line.field);
|
|
78
|
-
texts.push(line.text);
|
|
79
|
-
}
|
|
80
|
-
return `{ ${texts.join(" ")} }`;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const callFieldsType = (context: GirIndex, imports: TypeImports, type: string, call: Call | Call[]): string => {
|
|
84
|
-
if (Array.isArray(call))
|
|
85
|
-
return mergedFieldsType(call.flatMap((entry) => callFieldLines(context, imports, type, entry)));
|
|
86
|
-
if (typeof call === "string") {
|
|
87
|
-
const method = findMethod(context, type, call);
|
|
88
|
-
return renderParamType(context, imports, method?.params[0]);
|
|
89
|
-
}
|
|
90
|
-
const lines = callFieldLines(context, imports, type, call);
|
|
91
|
-
if (lines.length > 0) return mergedFieldsType(lines);
|
|
92
|
-
const method = findMethod(context, type, call.method);
|
|
93
|
-
return renderParamType(context, imports, method?.params[0]);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const appliedPropLine = (context: GirIndex, imports: TypeImports, type: string, prop: AppliedProp): string | null => {
|
|
97
|
-
if (hasProperty(context, type, prop.prop)) return null;
|
|
98
|
-
if (prop.kind === "value") return optionalLine(prop.prop, callFieldsType(context, imports, type, prop.call));
|
|
99
|
-
if (prop.kind === "list") return optionalLine(prop.prop, `${callFieldsType(context, imports, type, prop.add)}[]`);
|
|
100
|
-
return null;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const collectCallContributions = (
|
|
104
|
-
context: GirIndex,
|
|
105
|
-
contributions: PropContribution[],
|
|
106
|
-
container: { parent: string; child: string },
|
|
107
|
-
call: Exclude<ContainerProp["append"], string | undefined>,
|
|
108
|
-
): void => {
|
|
109
|
-
const method = findMethod(context, container.parent, call.method);
|
|
110
|
-
call.args.forEach((arg, positionIndex) => {
|
|
111
|
-
if (typeof arg !== "object" || !("prop" in arg)) return;
|
|
112
|
-
const param = method?.params[positionIndex];
|
|
113
|
-
if (param === undefined) return;
|
|
114
|
-
if (hasProperty(context, container.child, arg.prop)) return;
|
|
115
|
-
if (contributions.some((entry) => entry.child === container.child && entry.prop === arg.prop)) return;
|
|
116
|
-
contributions.push({ child: container.child, prop: arg.prop, param });
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const collectPropContributions = (
|
|
121
|
-
context: GirIndex,
|
|
122
|
-
elementProps: Record<string, ElementProp[]>,
|
|
123
|
-
): PropContribution[] => {
|
|
124
|
-
const contributions: PropContribution[] = [];
|
|
125
|
-
forEachContainer(elementProps, (parent, cp) => {
|
|
126
|
-
for (const call of [cp.append, cp.remove, cp.insert, cp.reorder]) {
|
|
127
|
-
if (call === undefined || typeof call === "string") continue;
|
|
128
|
-
collectCallContributions(context, contributions, { parent, child: cp.child }, call);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
return contributions;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
const directTypeNames = (context: GirIndex, klass: GirClass, namespace: GirNamespace): Set<string> => {
|
|
135
|
-
const names = new Set<string>();
|
|
136
|
-
const glibName = glibNameOf(klass);
|
|
137
|
-
if (glibName !== undefined) names.add(glibName);
|
|
138
|
-
for (const name of klass.implements) {
|
|
139
|
-
const resolved = context.library.resolveType(namespace.name, name);
|
|
140
|
-
if (resolved === undefined || resolved.kind !== "interface") continue;
|
|
141
|
-
const ifaceGlib = glibNameOf(resolved.value);
|
|
142
|
-
if (ifaceGlib !== undefined) names.add(ifaceGlib);
|
|
143
|
-
}
|
|
144
|
-
return names;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const constructOnlyNames = (context: GirIndex, entry: GirTypeEntry): string[] => {
|
|
148
|
-
const names: string[] = [];
|
|
149
|
-
for (const klass of chainOf(context, entry)) {
|
|
150
|
-
for (const property of klass.properties) {
|
|
151
|
-
if (property.constructOnly) names.push(toCamelIdentifier(property.name));
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return names;
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
const methodReturnGlib = (context: GirIndex, typeName: string, methodCamel: string): string | undefined => {
|
|
158
|
-
const method = findMethod(context, typeName, methodCamel);
|
|
159
|
-
const ref = method?.fn.returnValue.type;
|
|
160
|
-
if (ref === undefined) return undefined;
|
|
161
|
-
const resolved = context.library.typeOf(ref);
|
|
162
|
-
if (resolved === undefined || resolved.kind !== "class") return undefined;
|
|
163
|
-
return glibNameOf(resolved.value);
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
const resolveAdoptElement = (context: GirIndex, parent: string, cp: ContainerProp): string | undefined => {
|
|
167
|
-
if (cp.adopt === undefined) return undefined;
|
|
168
|
-
const source = typeof cp.adopt === "string" ? cp.adopt : cp.append;
|
|
169
|
-
if (source === undefined) return undefined;
|
|
170
|
-
const method = typeof source === "string" ? source : source.method;
|
|
171
|
-
return methodReturnGlib(context, parent, method);
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const lazyElementExportOf = (context: GirIndex, element: string): LazyElementSpec => {
|
|
175
|
-
const typeName = `${element}ElementProps`;
|
|
176
|
-
const elementClass = context.index.get(element);
|
|
177
|
-
if (elementClass === undefined) {
|
|
178
|
-
return { element, typeName, typeSource: `export type ${typeName} = { children?: ReactNode };` };
|
|
179
|
-
}
|
|
180
|
-
const baseName = glibNameOf(elementClass.klass) ?? element;
|
|
181
|
-
const omitted = constructOnlyNames(context, elementClass);
|
|
182
|
-
const omitUnion = omitted.map((name) => JSON.stringify(name)).join(" | ");
|
|
183
|
-
const base = omitted.length === 0 ? `${baseName}Props` : `Omit<${baseName}Props, ${omitUnion}>`;
|
|
184
|
-
return { element, typeName, typeSource: `export type ${typeName} = ${base};` };
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const collectLazyElementSpecs = (
|
|
188
|
-
context: GirIndex,
|
|
189
|
-
elementProps: Record<string, ElementProp[]>,
|
|
190
|
-
): Map<string, LazyElementSpec[]> => {
|
|
191
|
-
const specs = new Map<string, LazyElementSpec[]>();
|
|
192
|
-
forEachContainer(elementProps, (parent, cp) => {
|
|
193
|
-
const parentEntry = context.index.get(parent);
|
|
194
|
-
if (parentEntry === undefined) return;
|
|
195
|
-
const element = resolveAdoptElement(context, parent, cp);
|
|
196
|
-
if (element === undefined) return;
|
|
197
|
-
const spec = lazyElementExportOf(context, element);
|
|
198
|
-
const list = specs.get(parentEntry.namespace.name) ?? [];
|
|
199
|
-
if (!list.some((existing) => existing.element === spec.element)) list.push(spec);
|
|
200
|
-
specs.set(parentEntry.namespace.name, list);
|
|
201
|
-
});
|
|
202
|
-
return specs;
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
const collectContainerPropNames = (elementProps: Record<string, ElementProp[]>): Map<string, string[]> => {
|
|
206
|
-
const containerPropNamesByParent = new Map<string, string[]>();
|
|
207
|
-
forEachContainer(elementProps, (parent, cp) => {
|
|
208
|
-
if (cp.prop === "children") return;
|
|
209
|
-
const names = containerPropNamesByParent.get(parent) ?? [];
|
|
210
|
-
if (!names.includes(cp.prop)) names.push(cp.prop);
|
|
211
|
-
containerPropNamesByParent.set(parent, names);
|
|
212
|
-
});
|
|
213
|
-
return containerPropNamesByParent;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
const TEXT_CONTAINERS = ["GtkLabel", "GtkTextBuffer", "GtkTextTag", "GtkTextView"];
|
|
217
|
-
|
|
218
|
-
export const createElementPropTypegen = (
|
|
219
|
-
context: GirIndex,
|
|
220
|
-
elementProps: Record<string, ElementProp[]>,
|
|
221
|
-
): ElementPropTypegen => {
|
|
222
|
-
const appliedByType = new Map<string, AppliedProp[]>();
|
|
223
|
-
for (const [type, props] of Object.entries(elementProps)) {
|
|
224
|
-
for (const prop of props) {
|
|
225
|
-
if (prop.kind === "container") continue;
|
|
226
|
-
const list = appliedByType.get(type) ?? [];
|
|
227
|
-
list.push(prop);
|
|
228
|
-
appliedByType.set(type, list);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const propContributions = collectPropContributions(context, elementProps);
|
|
233
|
-
const lazyElementSpecs = collectLazyElementSpecs(context, elementProps);
|
|
234
|
-
const containerPropNamesByParent = collectContainerPropNames(elementProps);
|
|
235
|
-
|
|
236
|
-
const childrenContainers = new Set<string>(TEXT_CONTAINERS);
|
|
237
|
-
forEachContainer(elementProps, (parent, cp) => {
|
|
238
|
-
if (cp.prop === "children") childrenContainers.add(parent);
|
|
239
|
-
const element = resolveAdoptElement(context, parent, cp);
|
|
240
|
-
if (element !== undefined) childrenContainers.add(element);
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
const acceptsChildren = (glibName: string): boolean => {
|
|
244
|
-
if (childrenContainers.has(glibName)) return true;
|
|
245
|
-
const entry = context.index.get(glibName);
|
|
246
|
-
if (entry === undefined) return false;
|
|
247
|
-
const chain = chainOf(context, entry);
|
|
248
|
-
if (chain.some((klass) => glibNameOf(klass) === "GtkWidget")) return true;
|
|
249
|
-
return chain.some((klass) => {
|
|
250
|
-
const name = glibNameOf(klass);
|
|
251
|
-
return name !== undefined && childrenContainers.has(name);
|
|
252
|
-
});
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
const classPropLines = (
|
|
256
|
-
glibName: string,
|
|
257
|
-
klass: GirClass,
|
|
258
|
-
namespace: GirNamespace,
|
|
259
|
-
imports: TypeImports,
|
|
260
|
-
): string[] => {
|
|
261
|
-
const lines: string[] = [];
|
|
262
|
-
for (const prop of appliedByType.get(glibName) ?? []) {
|
|
263
|
-
const line = appliedPropLine(context, imports, glibName, prop);
|
|
264
|
-
if (line !== null) lines.push(line);
|
|
265
|
-
}
|
|
266
|
-
const direct = directTypeNames(context, klass, namespace);
|
|
267
|
-
for (const contribution of propContributions) {
|
|
268
|
-
if (!direct.has(contribution.child)) continue;
|
|
269
|
-
lines.push(optionalLine(contribution.prop, renderParamType(context, imports, contribution.param)));
|
|
270
|
-
}
|
|
271
|
-
return lines;
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
return {
|
|
275
|
-
classPropLines,
|
|
276
|
-
lazyElementExports: (namespaceName) => lazyElementSpecs.get(namespaceName) ?? [],
|
|
277
|
-
containerPropNamesFor: (glibName) => containerPropNamesByParent.get(glibName) ?? [],
|
|
278
|
-
acceptsChildren,
|
|
279
|
-
};
|
|
280
|
-
};
|