@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/react/widgets.ts
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { toCamelCase, toIdentifier, toUpperFirst } from "@gtkx/utils";
|
|
2
|
-
import type { GirClass } from "../gir/class.js";
|
|
3
|
-
import type { GirNamespace } from "../gir/namespace.js";
|
|
4
|
-
import { splitQualifiedName } from "../gir/qualified-name.js";
|
|
5
|
-
import type { GirRepository } from "../gir/repository.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Maps a kebab-case signal name to its `on`-prefixed camelCase handler prop
|
|
9
|
-
* name (e.g. `value-changed` → `onValueChanged`).
|
|
10
|
-
*
|
|
11
|
-
* @param signalName - The GIR signal name
|
|
12
|
-
*/
|
|
13
|
-
export const signalHandlerName = (signalName: string): string =>
|
|
14
|
-
`on${toUpperFirst(toIdentifier(toCamelCase(signalName)))}`;
|
|
15
|
-
|
|
16
|
-
/** A class qualified by its declaring namespace and the GLib type name it exposes. */
|
|
17
|
-
export type WidgetCandidate = {
|
|
18
|
-
readonly glibName: string;
|
|
19
|
-
readonly klass: GirClass;
|
|
20
|
-
readonly namespace: GirNamespace;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Iterates every `(class, namespace, glibName)` triple in the repository whose
|
|
25
|
-
* `glib:type-name` (or C type fallback) is defined.
|
|
26
|
-
*
|
|
27
|
-
* The order follows GIR file order within a namespace and `namespaces` map
|
|
28
|
-
* iteration order between namespaces; callers that need stable output should
|
|
29
|
-
* sort the result themselves.
|
|
30
|
-
*
|
|
31
|
-
* @param repository - The repository to walk
|
|
32
|
-
*/
|
|
33
|
-
export function* iterateClassesWithGlibName(repository: GirRepository): IterableIterator<WidgetCandidate> {
|
|
34
|
-
for (const namespace of repository.namespaces.values()) {
|
|
35
|
-
for (const klass of namespace.classes) {
|
|
36
|
-
const glibName = klass.glibTypeName ?? klass.cType;
|
|
37
|
-
if (glibName === undefined) continue;
|
|
38
|
-
yield { glibName, klass, namespace };
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const resolveParentClass = (
|
|
44
|
-
repository: GirRepository,
|
|
45
|
-
parent: string,
|
|
46
|
-
namespace: GirNamespace,
|
|
47
|
-
): { readonly klass: GirClass; readonly namespace: GirNamespace } | undefined => {
|
|
48
|
-
const { namespaceName, typeName } = splitQualifiedName(parent, namespace.name);
|
|
49
|
-
const resolved = repository.resolveNamed(namespaceName, typeName);
|
|
50
|
-
if (resolved === undefined || (resolved.kind !== "class" && resolved.kind !== "interface")) return undefined;
|
|
51
|
-
return { klass: resolved.value, namespace: resolved.namespace };
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/** A resolved interface qualified by the namespace that declares it. */
|
|
55
|
-
export type ResolvedQualifiedInterface = { readonly klass: GirClass; readonly namespace: GirNamespace };
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Resolves every interface a class implements, including the transitive
|
|
59
|
-
* prerequisite interfaces of those interfaces, nearest first.
|
|
60
|
-
*
|
|
61
|
-
* Interfaces never appear in the GObject type-parent chain, so the React
|
|
62
|
-
* runtime cannot reach an interface's signals or properties by walking a
|
|
63
|
-
* widget's ancestors. Each implementing class must therefore carry its
|
|
64
|
-
* interfaces' metadata directly. Prerequisite interfaces (e.g. a
|
|
65
|
-
* `Gtk.SelectionModel`'s `Gio.ListModel`) are folded in transitively; class
|
|
66
|
-
* prerequisites are ignored because their metadata is reachable through the
|
|
67
|
-
* type-parent chain.
|
|
68
|
-
*
|
|
69
|
-
* @param klass - The class whose interfaces to resolve
|
|
70
|
-
* @param namespace - The namespace the class lives in
|
|
71
|
-
* @param repository - The repository for cross-namespace lookups
|
|
72
|
-
*/
|
|
73
|
-
export const implementedInterfaces = (
|
|
74
|
-
klass: GirClass,
|
|
75
|
-
namespace: GirNamespace,
|
|
76
|
-
repository: GirRepository,
|
|
77
|
-
): readonly ResolvedQualifiedInterface[] => {
|
|
78
|
-
const result: ResolvedQualifiedInterface[] = [];
|
|
79
|
-
const visited = new Set<string>();
|
|
80
|
-
const visit = (names: readonly string[], fromNamespace: GirNamespace): void => {
|
|
81
|
-
for (const name of names) {
|
|
82
|
-
const { namespaceName, typeName } = splitQualifiedName(name, fromNamespace.name);
|
|
83
|
-
const resolved = repository.resolveNamed(namespaceName, typeName);
|
|
84
|
-
if (resolved === undefined || resolved.kind !== "interface") continue;
|
|
85
|
-
const key = `${resolved.namespace.name}.${resolved.value.name}`;
|
|
86
|
-
if (visited.has(key)) continue;
|
|
87
|
-
visited.add(key);
|
|
88
|
-
result.push({ klass: resolved.value, namespace: resolved.namespace });
|
|
89
|
-
visit(resolved.value.prerequisites, resolved.namespace);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
visit(klass.implements, namespace);
|
|
93
|
-
return result;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Returns the GLib type names of a class and every ancestor it descends from,
|
|
98
|
-
* nearest first. Used to let a subclass inherit slot-prop declarations made on
|
|
99
|
-
* its ancestors.
|
|
100
|
-
*
|
|
101
|
-
* @param klass - The class to start from
|
|
102
|
-
* @param namespace - The namespace the class lives in
|
|
103
|
-
* @param repository - The repository for cross-namespace parent lookups
|
|
104
|
-
*/
|
|
105
|
-
export const ancestorGlibNames = (
|
|
106
|
-
klass: GirClass,
|
|
107
|
-
namespace: GirNamespace,
|
|
108
|
-
repository: GirRepository,
|
|
109
|
-
): readonly string[] => {
|
|
110
|
-
const names: string[] = [];
|
|
111
|
-
let currentClass: GirClass | undefined = klass;
|
|
112
|
-
let currentNamespace: GirNamespace | undefined = namespace;
|
|
113
|
-
while (currentClass !== undefined && currentNamespace !== undefined) {
|
|
114
|
-
const glibName = currentClass.glibTypeName ?? currentClass.cType;
|
|
115
|
-
if (glibName !== undefined) names.push(glibName);
|
|
116
|
-
if (currentClass.parent === undefined) break;
|
|
117
|
-
const next = resolveParentClass(repository, currentClass.parent, currentNamespace);
|
|
118
|
-
if (next === undefined) break;
|
|
119
|
-
currentClass = next.klass;
|
|
120
|
-
currentNamespace = next.namespace;
|
|
121
|
-
}
|
|
122
|
-
return names;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const descendsFrom = (
|
|
126
|
-
klass: GirClass,
|
|
127
|
-
namespace: GirNamespace,
|
|
128
|
-
repository: GirRepository,
|
|
129
|
-
matches: (glibName: string) => boolean,
|
|
130
|
-
): boolean => {
|
|
131
|
-
let currentClass: GirClass | undefined = klass;
|
|
132
|
-
let currentNamespace: GirNamespace | undefined = namespace;
|
|
133
|
-
while (currentClass !== undefined && currentNamespace !== undefined) {
|
|
134
|
-
const glibName = currentClass.glibTypeName ?? currentClass.cType ?? "";
|
|
135
|
-
if (matches(glibName)) return true;
|
|
136
|
-
if (currentClass.parent === undefined) return false;
|
|
137
|
-
const next = resolveParentClass(repository, currentClass.parent, currentNamespace);
|
|
138
|
-
if (next === undefined) return false;
|
|
139
|
-
currentClass = next.klass;
|
|
140
|
-
currentNamespace = next.namespace;
|
|
141
|
-
}
|
|
142
|
-
return false;
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Decides whether a `<class>` is a "widget" for the React reconciler — a
|
|
147
|
-
* descendant (direct or transitive) of `GtkWidget`.
|
|
148
|
-
*
|
|
149
|
-
* Walks the parent chain across namespaces. Returns `false` if any
|
|
150
|
-
* ancestor cannot be resolved (which is preferable to silently treating
|
|
151
|
-
* an unknown type as a widget).
|
|
152
|
-
*
|
|
153
|
-
* @param klass - The class to inspect
|
|
154
|
-
* @param namespace - The namespace the class lives in
|
|
155
|
-
* @param repository - The repository for cross-namespace parent lookups
|
|
156
|
-
*/
|
|
157
|
-
export const isWidgetClass = (klass: GirClass, namespace: GirNamespace, repository: GirRepository): boolean =>
|
|
158
|
-
descendsFrom(klass, namespace, repository, (glibName) => glibName === "GtkWidget");
|
|
159
|
-
|
|
160
|
-
const AUXILIARY_BASE_TYPES: ReadonlySet<string> = new Set(["GtkEventController", "GtkGesture", "GtkLayoutManager"]);
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Decides whether a `<class>` is a non-widget React reconciler node — an event
|
|
164
|
-
* controller, gesture, or layout manager (direct or transitive descendant of
|
|
165
|
-
* `GtkEventController`, `GtkGesture`, or `GtkLayoutManager`). These are JSX
|
|
166
|
-
* elements that need the same prop/signal metadata as widgets.
|
|
167
|
-
*
|
|
168
|
-
* @param klass - The class to inspect
|
|
169
|
-
* @param namespace - The namespace the class lives in
|
|
170
|
-
* @param repository - The repository for cross-namespace parent lookups
|
|
171
|
-
*/
|
|
172
|
-
const isAuxiliaryReactType = (klass: GirClass, namespace: GirNamespace, repository: GirRepository): boolean =>
|
|
173
|
-
descendsFrom(klass, namespace, repository, (glibName) => AUXILIARY_BASE_TYPES.has(glibName));
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Decides whether a `<class>` is any React reconciler node — a widget or one
|
|
177
|
-
* of the auxiliary node kinds. This is the set of classes that need generated
|
|
178
|
-
* prop, signal, and construct-only metadata.
|
|
179
|
-
*
|
|
180
|
-
* @param klass - The class to inspect
|
|
181
|
-
* @param namespace - The namespace the class lives in
|
|
182
|
-
* @param repository - The repository for cross-namespace parent lookups
|
|
183
|
-
*/
|
|
184
|
-
export const isReactNodeClass = (klass: GirClass, namespace: GirNamespace, repository: GirRepository): boolean =>
|
|
185
|
-
isWidgetClass(klass, namespace, repository) || isAuxiliaryReactType(klass, namespace, repository);
|
package/src/store-fs.ts
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, mkdtempSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { dirname, join, relative } from "node:path";
|
|
3
|
-
import { transpileSource } from "./transpile.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Filesystem primitives shared by the injected-package assemblers
|
|
7
|
-
* ({@link ../gi-store.js}, {@link ../jsx-store.js}).
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Fields every injected-package store assembler needs: where the hidden store
|
|
12
|
-
* lives, the visible alias symlink, and the version stamped onto its manifest.
|
|
13
|
-
*/
|
|
14
|
-
export type StoreOptions = {
|
|
15
|
-
/** Absolute path to the hidden store directory (e.g. `node_modules/.gtkx/gi`). */
|
|
16
|
-
readonly storeDir: string;
|
|
17
|
-
/** Absolute path to the visible alias symlink (e.g. `node_modules/@gtkx/gi`). */
|
|
18
|
-
readonly linkDir: string;
|
|
19
|
-
/** Version string copied onto the emitted package's `package.json`. */
|
|
20
|
-
readonly version: string;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/** A transpilable source destined for the store, addressed by output stem. */
|
|
24
|
-
export type StoreFile = {
|
|
25
|
-
/** Output path without extension, relative to the store root. */
|
|
26
|
-
readonly stem: string;
|
|
27
|
-
/** Source filename TypeScript uses for diagnostics. */
|
|
28
|
-
readonly fileName: string;
|
|
29
|
-
/** The TypeScript source to transpile and write. */
|
|
30
|
-
readonly source: string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/** A symlink to create inside the store's own bundled `node_modules`. */
|
|
34
|
-
export type StoreSymlink = {
|
|
35
|
-
/** Path segments under the store root the symlink is created at. */
|
|
36
|
-
readonly segments: readonly string[];
|
|
37
|
-
/** Absolute symlink target, or `"self"` for the store root itself. */
|
|
38
|
-
readonly target: string | "self";
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Assembles a store in a fresh temp directory and atomically swaps it into
|
|
43
|
-
* place: writes every file pair, the `package.json`, the bundled
|
|
44
|
-
* `node_modules` symlinks, then promotes the temp tree and re-points the
|
|
45
|
-
* visible alias. An optional {@link WriteStoreParams.validate} runs against the
|
|
46
|
-
* temp root before any file is written, so a failure aborts before the store
|
|
47
|
-
* goes live.
|
|
48
|
-
*
|
|
49
|
-
* @param params - {@link WriteStoreParams}
|
|
50
|
-
*/
|
|
51
|
-
export const writeStore = (params: WriteStoreParams): void => {
|
|
52
|
-
const tmp = tempStoreFor(params.storeDir);
|
|
53
|
-
params.validate?.(tmp);
|
|
54
|
-
for (const file of params.files) {
|
|
55
|
-
writeFilePair(tmp, file.stem, file.fileName, file.source);
|
|
56
|
-
}
|
|
57
|
-
writePackageJson(tmp, params.manifest);
|
|
58
|
-
for (const raw of params.rawFiles ?? []) {
|
|
59
|
-
writeFileSync(join(tmp, raw.relativePath), raw.content);
|
|
60
|
-
}
|
|
61
|
-
for (const { segments, target } of params.symlinks) {
|
|
62
|
-
symlinkRelative(join(tmp, ...segments), target === "self" ? tmp : target);
|
|
63
|
-
}
|
|
64
|
-
swapStore(tmp, params.storeDir, params.linkDir);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
/** Inputs for {@link writeStore}. */
|
|
68
|
-
export type WriteStoreParams = {
|
|
69
|
-
/** Absolute hidden store directory. */
|
|
70
|
-
readonly storeDir: string;
|
|
71
|
-
/** Absolute visible alias symlink. */
|
|
72
|
-
readonly linkDir: string;
|
|
73
|
-
/** The source files to transpile and write. */
|
|
74
|
-
readonly files: readonly StoreFile[];
|
|
75
|
-
/** The `package.json` manifest to serialize. */
|
|
76
|
-
readonly manifest: unknown;
|
|
77
|
-
/** The bundled `node_modules` symlinks to create. */
|
|
78
|
-
readonly symlinks: readonly StoreSymlink[];
|
|
79
|
-
/** Verbatim files (e.g. a fingerprint sentinel) written under the store root. */
|
|
80
|
-
readonly rawFiles?: readonly { readonly relativePath: string; readonly content: string }[];
|
|
81
|
-
/** Optional in-memory validation run on the temp root before files are written. */
|
|
82
|
-
readonly validate?: (tmp: string) => void;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Transpiles `source` and writes the resulting `.js`/`.d.ts` pair at `stem`
|
|
87
|
-
* (relative to `storeDir`), creating parent directories as needed.
|
|
88
|
-
*
|
|
89
|
-
* @param storeDir - Absolute store root the file is written under
|
|
90
|
-
* @param stem - Output path without extension, relative to `storeDir`
|
|
91
|
-
* @param fileName - Source filename TypeScript uses for diagnostics
|
|
92
|
-
* @param source - The TypeScript source to transpile
|
|
93
|
-
*/
|
|
94
|
-
export const writeFilePair = (storeDir: string, stem: string, fileName: string, source: string): void => {
|
|
95
|
-
const { js, dts } = transpileSource(fileName, source);
|
|
96
|
-
const jsPath = join(storeDir, `${stem}.js`);
|
|
97
|
-
mkdirSync(dirname(jsPath), { recursive: true });
|
|
98
|
-
writeFileSync(jsPath, js);
|
|
99
|
-
writeFileSync(join(storeDir, `${stem}.d.ts`), dts);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Creates (or replaces) a relative directory symlink at `linkPath` pointing at
|
|
104
|
-
* `realTarget`. Relative so the link survives the store being moved or cached.
|
|
105
|
-
*
|
|
106
|
-
* @param linkPath - Absolute path of the symlink to create
|
|
107
|
-
* @param realTarget - Absolute path the symlink resolves to
|
|
108
|
-
*/
|
|
109
|
-
export const symlinkRelative = (linkPath: string, realTarget: string): void => {
|
|
110
|
-
mkdirSync(dirname(linkPath), { recursive: true });
|
|
111
|
-
rmSync(linkPath, { recursive: true, force: true });
|
|
112
|
-
symlinkSync(relative(dirname(linkPath), realTarget), linkPath, "dir");
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Writes a pretty-printed `package.json` into `storeDir`.
|
|
117
|
-
*
|
|
118
|
-
* @param storeDir - Absolute directory to write `package.json` into
|
|
119
|
-
* @param manifest - The manifest object to serialize
|
|
120
|
-
*/
|
|
121
|
-
export const writePackageJson = (storeDir: string, manifest: unknown): void => {
|
|
122
|
-
writeFileSync(join(storeDir, "package.json"), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Swaps a fully-assembled temp store into place and re-points the visible alias
|
|
127
|
-
* at it.
|
|
128
|
-
*
|
|
129
|
-
* The live store is renamed aside and the temp store renamed in before the old
|
|
130
|
-
* tree is deleted, so the store is unavailable only for the duration of a single
|
|
131
|
-
* rename instead of a full recursive delete. Not safe against a second codegen
|
|
132
|
-
* run swapping the same store concurrently.
|
|
133
|
-
*
|
|
134
|
-
* @param tmp - Absolute temp store directory to promote
|
|
135
|
-
* @param storeDir - Absolute final store directory
|
|
136
|
-
* @param visibleLink - Absolute path of the visible alias symlink
|
|
137
|
-
*/
|
|
138
|
-
export const swapStore = (tmp: string, storeDir: string, visibleLink: string): void => {
|
|
139
|
-
const previous = `${storeDir}.old`;
|
|
140
|
-
rmSync(previous, { recursive: true, force: true });
|
|
141
|
-
if (existsSync(storeDir)) {
|
|
142
|
-
renameSync(storeDir, previous);
|
|
143
|
-
}
|
|
144
|
-
renameSync(tmp, storeDir);
|
|
145
|
-
rmSync(previous, { recursive: true, force: true });
|
|
146
|
-
symlinkRelative(visibleLink, storeDir);
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Creates a fresh, per-run temporary store directory next to `storeDir` and
|
|
151
|
-
* returns its path. The random suffix isolates concurrent or repeated runs so
|
|
152
|
-
* they cannot corrupt each other's in-progress trees.
|
|
153
|
-
*/
|
|
154
|
-
export const tempStoreFor = (storeDir: string): string => {
|
|
155
|
-
mkdirSync(dirname(storeDir), { recursive: true });
|
|
156
|
-
return mkdtempSync(`${storeDir}.tmp-`);
|
|
157
|
-
};
|
package/src/transpile.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Output of a single TypeScript transpile: the stripped `.js` and the
|
|
5
|
-
* isolated-declaration `.d.ts` it produces.
|
|
6
|
-
*/
|
|
7
|
-
export type TranspiledFile = {
|
|
8
|
-
/** Stripped-types JavaScript output. */
|
|
9
|
-
readonly js: string;
|
|
10
|
-
/** Generated TypeScript declaration output. */
|
|
11
|
-
readonly dts: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The compiler options shared by the store's two TypeScript passes — the
|
|
16
|
-
* single-file transpile here and the overlay type-check in `typecheck-store.ts`.
|
|
17
|
-
* Each pass spreads these and adds its own emit/check-specific keys.
|
|
18
|
-
*/
|
|
19
|
-
export const baseCompilerOptions = (): ts.CompilerOptions => ({
|
|
20
|
-
module: ts.ModuleKind.ESNext,
|
|
21
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
22
|
-
target: ts.ScriptTarget.ESNext,
|
|
23
|
-
skipLibCheck: true,
|
|
24
|
-
jsx: ts.JsxEmit.ReactJSX,
|
|
25
|
-
jsxImportSource: "react",
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const COMPILER_OPTIONS: ts.CompilerOptions = {
|
|
29
|
-
...baseCompilerOptions(),
|
|
30
|
-
declaration: true,
|
|
31
|
-
skipDefaultLibCheck: true,
|
|
32
|
-
removeComments: false,
|
|
33
|
-
sourceMap: false,
|
|
34
|
-
declarationMap: false,
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Transpiles a single TypeScript source string to a `.js` / `.d.ts` pair.
|
|
39
|
-
*
|
|
40
|
-
* Uses `ts.transpileModule` for the JS half (type-stripping only, no
|
|
41
|
-
* type checking) and `ts.transpileDeclaration` for the declaration half
|
|
42
|
-
* (single-file declaration emit). Generated sources annotate every export
|
|
43
|
-
* for isolated-declaration emit, so `transpileDeclaration` always
|
|
44
|
-
* succeeds; an error-category diagnostic from it represents a writer bug
|
|
45
|
-
* and is surfaced rather than swallowed.
|
|
46
|
-
*
|
|
47
|
-
* @param fileName - Source filename, used by TS for path resolution
|
|
48
|
-
* @param source - The TypeScript source string
|
|
49
|
-
*/
|
|
50
|
-
export const transpileSource = (fileName: string, source: string): TranspiledFile => {
|
|
51
|
-
const jsResult = ts.transpileModule(source, {
|
|
52
|
-
compilerOptions: COMPILER_OPTIONS,
|
|
53
|
-
fileName,
|
|
54
|
-
reportDiagnostics: false,
|
|
55
|
-
});
|
|
56
|
-
const dtsResult = ts.transpileDeclaration(source, {
|
|
57
|
-
compilerOptions: COMPILER_OPTIONS,
|
|
58
|
-
fileName,
|
|
59
|
-
});
|
|
60
|
-
const errorDiagnostics = (dtsResult.diagnostics ?? []).filter(
|
|
61
|
-
(diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error,
|
|
62
|
-
);
|
|
63
|
-
if (errorDiagnostics.length > 0) {
|
|
64
|
-
const messages = errorDiagnostics
|
|
65
|
-
.slice(0, 5)
|
|
66
|
-
.map((diagnostic) => {
|
|
67
|
-
const text = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
68
|
-
if (diagnostic.file && diagnostic.start !== undefined) {
|
|
69
|
-
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
70
|
-
return `[${line + 1}:${character + 1}] ${text}`;
|
|
71
|
-
}
|
|
72
|
-
return text;
|
|
73
|
-
})
|
|
74
|
-
.join("\n");
|
|
75
|
-
throw new Error(
|
|
76
|
-
`transpileDeclaration produced ${errorDiagnostics.length} diagnostic(s) for ${fileName}:\n${messages}`,
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
return { js: jsResult.outputText, dts: dtsResult.outputText };
|
|
80
|
-
};
|
package/src/typecheck-store.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import ts from "typescript";
|
|
4
|
-
import { baseCompilerOptions } from "./transpile.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* One in-memory source destined for the injected `@gtkx/gi` store, plus whether
|
|
8
|
-
* it is a hand-written overlay (the type-check target) or a generated module
|
|
9
|
-
* declaration (checked against, but not reported on).
|
|
10
|
-
*/
|
|
11
|
-
export type StoreSourceFile = {
|
|
12
|
-
/** Absolute virtual path of the source, under the store root. */
|
|
13
|
-
readonly path: string;
|
|
14
|
-
/** TypeScript source text (overlay `.ts`) or declaration text (generated `.d.ts`). */
|
|
15
|
-
readonly source: string;
|
|
16
|
-
/** Whether this is a hand-written overlay/augment source. */
|
|
17
|
-
readonly overlay: boolean;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const GI_SPECIFIER = "@gtkx/gi/";
|
|
21
|
-
|
|
22
|
-
const COMPILER_OPTIONS: ts.CompilerOptions = {
|
|
23
|
-
...baseCompilerOptions(),
|
|
24
|
-
customConditions: ["source"],
|
|
25
|
-
strict: true,
|
|
26
|
-
noEmit: true,
|
|
27
|
-
types: [],
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Source entries the overlay type-check resolves the runtime packages to.
|
|
32
|
-
*/
|
|
33
|
-
export type RuntimeEntries = {
|
|
34
|
-
/** Absolute path to `@gtkx/ffi`'s source entry (`src/index.ts`). */
|
|
35
|
-
readonly ffiEntry: string;
|
|
36
|
-
/** Absolute path to `@gtkx/native`'s declaration entry (`dist/index.d.ts`). */
|
|
37
|
-
readonly nativeEntry: string;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const buildCompilerHost = (
|
|
41
|
-
storeRoot: string,
|
|
42
|
-
virtualSources: ReadonlyMap<string, string>,
|
|
43
|
-
entries: RuntimeEntries,
|
|
44
|
-
): ts.CompilerHost => {
|
|
45
|
-
const readSource = (fileName: string): string | undefined =>
|
|
46
|
-
virtualSources.get(fileName) ?? (existsSync(fileName) ? readFileSync(fileName, "utf8") : undefined);
|
|
47
|
-
|
|
48
|
-
const resolveInjected = (specifier: string): string | undefined => {
|
|
49
|
-
if (specifier === "@gtkx/ffi") return entries.ffiEntry;
|
|
50
|
-
if (specifier === "@gtkx/native") return entries.nativeEntry;
|
|
51
|
-
if (!specifier.startsWith(GI_SPECIFIER)) return undefined;
|
|
52
|
-
const stem = specifier.slice(GI_SPECIFIER.length).replace(/\.js$/, "");
|
|
53
|
-
return [`${stem}.d.ts`, `${stem}.ts`, `${stem}/index.d.ts`, `${stem}/index.ts`]
|
|
54
|
-
.map((candidate) => join(storeRoot, candidate))
|
|
55
|
-
.find((candidate) => virtualSources.has(candidate));
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const moduleResolutionHost: ts.ModuleResolutionHost = {
|
|
59
|
-
fileExists: (fileName) => virtualSources.has(fileName) || existsSync(fileName),
|
|
60
|
-
readFile: readSource,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
getSourceFile: (fileName, languageVersion) => {
|
|
65
|
-
const source = readSource(fileName);
|
|
66
|
-
return source === undefined ? undefined : ts.createSourceFile(fileName, source, languageVersion, true);
|
|
67
|
-
},
|
|
68
|
-
getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
|
|
69
|
-
writeFile: () => {},
|
|
70
|
-
getCurrentDirectory: () => storeRoot,
|
|
71
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
72
|
-
useCaseSensitiveFileNames: () => true,
|
|
73
|
-
getNewLine: () => "\n",
|
|
74
|
-
fileExists: (fileName) => virtualSources.has(fileName) || existsSync(fileName),
|
|
75
|
-
readFile: readSource,
|
|
76
|
-
resolveModuleNameLiterals: (literals, containingFile, _redirectedReference, options) =>
|
|
77
|
-
literals.map((literal) => {
|
|
78
|
-
const injected = resolveInjected(literal.text);
|
|
79
|
-
if (injected !== undefined) {
|
|
80
|
-
return { resolvedModule: { resolvedFileName: injected, extension: ts.Extension.Ts } };
|
|
81
|
-
}
|
|
82
|
-
return {
|
|
83
|
-
resolvedModule: ts.resolveModuleName(literal.text, containingFile, options, moduleResolutionHost)
|
|
84
|
-
.resolvedModule,
|
|
85
|
-
};
|
|
86
|
-
}),
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const reportOverlayErrors = (program: ts.Program, overlayPaths: readonly string[], storeRoot: string): void => {
|
|
91
|
-
const errors: ts.Diagnostic[] = [];
|
|
92
|
-
for (const path of overlayPaths) {
|
|
93
|
-
const sourceFile = program.getSourceFile(path);
|
|
94
|
-
if (!sourceFile) continue;
|
|
95
|
-
for (const diagnostic of program.getSemanticDiagnostics(sourceFile)) {
|
|
96
|
-
if (diagnostic.category === ts.DiagnosticCategory.Error) errors.push(diagnostic);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (errors.length === 0) return;
|
|
100
|
-
const formatted = ts.formatDiagnosticsWithColorAndContext(errors, {
|
|
101
|
-
getCurrentDirectory: () => storeRoot,
|
|
102
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
103
|
-
getNewLine: () => "\n",
|
|
104
|
-
});
|
|
105
|
-
throw new Error(`Overlay type-check failed against the generated @gtkx/gi API:\n${formatted}`);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Type-checks the hand-written overlay sources against the freshly generated
|
|
110
|
-
* `@gtkx/gi` declarations, entirely in memory.
|
|
111
|
-
*
|
|
112
|
-
* The overlay augments generated classes (e.g. installs `Value.prototype.getBoxed`),
|
|
113
|
-
* so its correctness is only meaningful relative to the exact API codegen just
|
|
114
|
-
* produced. A {@link ts.Program} is assembled over the in-memory generated
|
|
115
|
-
* declarations and overlay sources, resolving `@gtkx/gi/*` to the generated
|
|
116
|
-
* declarations and `@gtkx/ffi` to its package source; every other specifier
|
|
117
|
-
* (`react`, lib files) resolves from the real filesystem. Semantic errors on the
|
|
118
|
-
* overlay sources abort codegen rather than ship broken bindings.
|
|
119
|
-
*
|
|
120
|
-
* @param storeRoot - Absolute root the virtual source paths are rooted at.
|
|
121
|
-
* @param files - The in-memory generated declarations and overlay sources.
|
|
122
|
-
* @param entries - Absolute source entries for `@gtkx/ffi` and `@gtkx/native`.
|
|
123
|
-
* @throws When any overlay source has a semantic type error.
|
|
124
|
-
*/
|
|
125
|
-
export const typecheckGiStore = (
|
|
126
|
-
storeRoot: string,
|
|
127
|
-
files: readonly StoreSourceFile[],
|
|
128
|
-
entries: RuntimeEntries,
|
|
129
|
-
): void => {
|
|
130
|
-
const overlayPaths = files.filter((file) => file.overlay).map((file) => file.path);
|
|
131
|
-
if (overlayPaths.length === 0) return;
|
|
132
|
-
const virtualSources = new Map(files.map((file) => [file.path, file.source]));
|
|
133
|
-
const host = buildCompilerHost(storeRoot, virtualSources, entries);
|
|
134
|
-
const program = ts.createProgram({ rootNames: files.map((file) => file.path), options: COMPILER_OPTIONS, host });
|
|
135
|
-
reportOverlayErrors(program, overlayPaths, storeRoot);
|
|
136
|
-
};
|
package/src/writers/alias.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ModuleContext } from "../dsl/context.js";
|
|
2
|
-
import { aliasExportName } from "../dsl/identifier.js";
|
|
3
|
-
import type { GirAlias } from "../gir/namespace.js";
|
|
4
|
-
import { renderTsType } from "./ts-type.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Emits an `export type` declaration for a GIR `<alias>`.
|
|
8
|
-
*
|
|
9
|
-
* The alias is exported under {@link aliasExportName} — its GIR `name`, with
|
|
10
|
-
* GObject's `Type` published as `GType`.
|
|
11
|
-
*
|
|
12
|
-
* @param context - The module context
|
|
13
|
-
* @param alias - The alias to emit
|
|
14
|
-
*/
|
|
15
|
-
export const emitAlias = (context: ModuleContext, alias: GirAlias): void => {
|
|
16
|
-
const exportName = aliasExportName(context.namespace.name, alias.name);
|
|
17
|
-
const targetType = renderTsType(context, alias.target);
|
|
18
|
-
context.module.appendDeclaration(`export type ${exportName} = ${targetType};`);
|
|
19
|
-
};
|
package/src/writers/async.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { GirFunction } from "../gir/function.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Detects the start half of a `Gio.AsyncReady` callable pair.
|
|
5
|
-
*
|
|
6
|
-
* Pairs follow two GIR conventions: an explicit `*_async` / `*_finish`
|
|
7
|
-
* suffix (the older style), or a base name paired with a `<root>_finish`
|
|
8
|
-
* (the modern GTK 4 style, e.g. `gtk_file_dialog_open` /
|
|
9
|
-
* `gtk_file_dialog_open_finish`).
|
|
10
|
-
*
|
|
11
|
-
* The runtime convention is to wrap the pair with `promisify(asyncFn,
|
|
12
|
-
* finishFn, cancellable, { leading })`. This detector returns the
|
|
13
|
-
* matching finish counterpart's GIR name when one exists in the same
|
|
14
|
-
* set of callables, so the class writer can wire the wrapper.
|
|
15
|
-
*
|
|
16
|
-
* @param fn - The candidate async-start callable
|
|
17
|
-
* @param siblings - Other callables on the same type to scan for the
|
|
18
|
-
* matching `*_finish`
|
|
19
|
-
* @returns The matching `*_finish` GIR name, or `undefined` when there is
|
|
20
|
-
* no pair
|
|
21
|
-
*/
|
|
22
|
-
export const matchAsyncFinishName = (fn: GirFunction, siblings: readonly GirFunction[]): string | undefined => {
|
|
23
|
-
if (fn.name.endsWith("_async")) {
|
|
24
|
-
const root = fn.name.slice(0, -"_async".length);
|
|
25
|
-
const finishName = `${root}_finish`;
|
|
26
|
-
const match = siblings.find((sibling) => sibling.name === finishName);
|
|
27
|
-
return match === undefined ? undefined : finishName;
|
|
28
|
-
}
|
|
29
|
-
if (fn.name.endsWith("_finish")) return undefined;
|
|
30
|
-
const finishName = `${fn.name}_finish`;
|
|
31
|
-
const match = siblings.find((sibling) => sibling.name === finishName);
|
|
32
|
-
if (match === undefined) return undefined;
|
|
33
|
-
if (!hasAsyncReadyCallbackParameter(fn)) return undefined;
|
|
34
|
-
return finishName;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const hasAsyncReadyCallbackParameter = (fn: GirFunction): boolean => {
|
|
38
|
-
for (const parameter of fn.parameters) {
|
|
39
|
-
if (parameter.scope !== undefined) return true;
|
|
40
|
-
if (parameter.type?.kind !== "named") continue;
|
|
41
|
-
if (parameter.type.typeName === "AsyncReadyCallback") return true;
|
|
42
|
-
}
|
|
43
|
-
return false;
|
|
44
|
-
};
|