@gtkx/codegen 0.21.0 → 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/README.md +173 -0
- package/dist/analysis/descriptor-render.d.ts +25 -0
- package/dist/analysis/descriptor-render.d.ts.map +1 -0
- package/dist/analysis/descriptor-render.js +420 -0
- package/dist/analysis/descriptor-render.js.map +1 -0
- package/dist/analysis/descriptor.d.ts +62 -0
- package/dist/analysis/descriptor.d.ts.map +1 -0
- package/dist/analysis/descriptor.js +127 -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 +248 -0
- package/dist/analysis/inheritance.js.map +1 -0
- package/dist/analysis/param-structure.d.ts +27 -0
- package/dist/analysis/param-structure.d.ts.map +1 -0
- package/dist/analysis/param-structure.js +158 -0
- package/dist/analysis/param-structure.js.map +1 -0
- package/dist/analysis/ts-type.d.ts +20 -0
- package/dist/analysis/ts-type.d.ts.map +1 -0
- package/dist/analysis/ts-type.js +111 -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 +130 -0
- package/dist/compile.js.map +1 -0
- package/dist/docs/api-reference.d.ts +67 -0
- package/dist/docs/api-reference.d.ts.map +1 -0
- package/dist/docs/api-reference.js +372 -0
- package/dist/docs/api-reference.js.map +1 -0
- package/dist/docs/element-page.d.ts +12 -0
- package/dist/docs/element-page.d.ts.map +1 -0
- package/dist/docs/element-page.js +156 -0
- package/dist/docs/element-page.js.map +1 -0
- package/dist/docs/pipeline.d.ts +26 -0
- package/dist/docs/pipeline.d.ts.map +1 -0
- package/dist/docs/pipeline.js +156 -0
- package/dist/docs/pipeline.js.map +1 -0
- package/dist/docs/render.d.ts +34 -0
- package/dist/docs/render.d.ts.map +1 -0
- package/dist/docs/render.js +143 -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 +380 -0
- package/dist/docs/symbol-page.js.map +1 -0
- package/dist/fingerprint.d.ts +31 -28
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +84 -19
- 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 +10 -0
- package/dist/gir/ancestry.d.ts.map +1 -0
- package/dist/gir/ancestry.js +26 -0
- package/dist/gir/ancestry.js.map +1 -0
- package/dist/gir/callback.d.ts +8 -14
- package/dist/gir/callback.d.ts.map +1 -1
- package/dist/gir/callback.js +16 -16
- package/dist/gir/callback.js.map +1 -1
- package/dist/gir/class.d.ts +25 -44
- package/dist/gir/class.d.ts.map +1 -1
- package/dist/gir/class.js +16 -26
- package/dist/gir/class.js.map +1 -1
- package/dist/gir/enum.d.ts +16 -34
- package/dist/gir/enum.d.ts.map +1 -1
- package/dist/gir/enum.js +10 -16
- package/dist/gir/enum.js.map +1 -1
- package/dist/gir/field.d.ts +16 -24
- package/dist/gir/field.d.ts.map +1 -1
- package/dist/gir/field.js +35 -18
- package/dist/gir/field.js.map +1 -1
- package/dist/gir/function.d.ts +15 -43
- package/dist/gir/function.d.ts.map +1 -1
- package/dist/gir/function.js +26 -23
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/gir-path.d.ts +3 -0
- package/dist/gir/gir-path.d.ts.map +1 -0
- package/dist/gir/gir-path.js +57 -0
- package/dist/gir/gir-path.js.map +1 -0
- package/dist/gir/libraries.d.ts +5 -0
- package/dist/gir/libraries.d.ts.map +1 -0
- package/dist/gir/libraries.js +74 -0
- package/dist/gir/libraries.js.map +1 -0
- package/dist/gir/library.d.ts +43 -0
- package/dist/gir/library.d.ts.map +1 -0
- package/dist/gir/library.js +242 -0
- package/dist/gir/library.js.map +1 -0
- package/dist/gir/namespace.d.ts +40 -54
- package/dist/gir/namespace.d.ts.map +1 -1
- package/dist/gir/namespace.js +51 -40
- 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 +34 -76
- package/dist/gir/parameter.d.ts.map +1 -1
- package/dist/gir/parameter.js +47 -59
- package/dist/gir/parameter.js.map +1 -1
- package/dist/gir/parse.d.ts +12 -77
- package/dist/gir/parse.d.ts.map +1 -1
- package/dist/gir/parse.js +65 -103
- package/dist/gir/parse.js.map +1 -1
- package/dist/gir/primitives.d.ts +5 -35
- package/dist/gir/primitives.d.ts.map +1 -1
- package/dist/gir/primitives.js +21 -36
- package/dist/gir/primitives.js.map +1 -1
- package/dist/gir/property.d.ts +18 -26
- package/dist/gir/property.d.ts.map +1 -1
- package/dist/gir/property.js +16 -12
- package/dist/gir/property.js.map +1 -1
- package/dist/gir/record.d.ts +28 -0
- package/dist/gir/record.d.ts.map +1 -0
- package/dist/gir/record.js +26 -0
- package/dist/gir/record.js.map +1 -0
- package/dist/gir/size.d.ts +15 -61
- package/dist/gir/size.d.ts.map +1 -1
- package/dist/gir/size.js +49 -72
- package/dist/gir/size.js.map +1 -1
- package/dist/gir/type-id.d.ts +51 -0
- package/dist/gir/type-id.d.ts.map +1 -0
- package/dist/gir/type-id.js +12 -0
- package/dist/gir/type-id.js.map +1 -0
- package/dist/gir/type-ref.d.ts +4 -77
- package/dist/gir/type-ref.d.ts.map +1 -1
- package/dist/gir/type-ref.js +58 -77
- package/dist/gir/type-ref.js.map +1 -1
- package/dist/gir/type.d.ts +34 -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 +7 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -11
- 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 +30 -0
- package/dist/khronos/args.d.ts.map +1 -0
- package/dist/khronos/args.js +171 -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 +72 -0
- package/dist/khronos/jsdoc.js.map +1 -0
- package/dist/khronos/model.d.ts +38 -0
- package/dist/khronos/model.d.ts.map +1 -0
- package/dist/khronos/model.js +167 -0
- package/dist/khronos/model.js.map +1 -0
- package/dist/khronos/modules.d.ts +12 -0
- package/dist/khronos/modules.d.ts.map +1 -0
- package/dist/khronos/modules.js +73 -0
- package/dist/khronos/modules.js.map +1 -0
- 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 +8 -0
- package/dist/khronos/parse.d.ts.map +1 -0
- package/dist/khronos/parse.js +62 -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 +223 -0
- package/dist/khronos/pipeline.js.map +1 -0
- package/dist/khronos/plan.d.ts +81 -0
- package/dist/khronos/plan.d.ts.map +1 -0
- package/dist/khronos/plan.js +200 -0
- package/dist/khronos/plan.js.map +1 -0
- package/dist/khronos/render.d.ts +17 -0
- package/dist/khronos/render.d.ts.map +1 -0
- package/dist/khronos/render.js +205 -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 +56 -0
- package/dist/khronos/select.js.map +1 -0
- 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 +38 -49
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +81 -54
- package/dist/runner.js.map +1 -1
- package/dist/store/compile-store.d.ts +11 -0
- package/dist/store/compile-store.d.ts.map +1 -0
- package/dist/store/compile-store.js +40 -0
- package/dist/store/compile-store.js.map +1 -0
- package/dist/store/gi/async.d.ts +5 -0
- package/dist/store/gi/async.d.ts.map +1 -0
- package/dist/store/gi/async.js +45 -0
- package/dist/store/gi/async.js.map +1 -0
- package/dist/store/gi/callables.d.ts +42 -0
- package/dist/store/gi/callables.d.ts.map +1 -0
- package/dist/store/gi/callables.js +264 -0
- package/dist/store/gi/callables.js.map +1 -0
- package/dist/store/gi/callback.d.ts +5 -0
- package/dist/store/gi/callback.d.ts.map +1 -0
- package/dist/store/gi/callback.js +17 -0
- package/dist/store/gi/callback.js.map +1 -0
- package/dist/store/gi/class-struct-record.d.ts +10 -0
- package/dist/store/gi/class-struct-record.d.ts.map +1 -0
- package/dist/store/gi/class-struct-record.js +52 -0
- package/dist/store/gi/class-struct-record.js.map +1 -0
- package/dist/store/gi/class.d.ts +5 -0
- package/dist/store/gi/class.d.ts.map +1 -0
- package/dist/store/gi/class.js +208 -0
- package/dist/store/gi/class.js.map +1 -0
- package/dist/store/gi/companion.d.ts +5 -0
- package/dist/store/gi/companion.d.ts.map +1 -0
- package/dist/store/gi/companion.js +16 -0
- package/dist/store/gi/companion.js.map +1 -0
- package/dist/store/gi/constant.d.ts +6 -0
- package/dist/store/gi/constant.d.ts.map +1 -0
- package/dist/store/gi/constant.js +35 -0
- package/dist/store/gi/constant.js.map +1 -0
- package/dist/store/gi/constructor-props.d.ts +6 -0
- package/dist/store/gi/constructor-props.d.ts.map +1 -0
- package/dist/store/gi/constructor-props.js +71 -0
- package/dist/store/gi/constructor-props.js.map +1 -0
- package/dist/store/gi/enum.d.ts +6 -0
- package/dist/store/gi/enum.d.ts.map +1 -0
- package/dist/store/gi/enum.js +41 -0
- package/dist/store/gi/enum.js.map +1 -0
- package/dist/store/gi/function.d.ts +9 -0
- package/dist/store/gi/function.d.ts.map +1 -0
- package/dist/store/gi/function.js +114 -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 +24 -0
- package/dist/store/gi/gtype-binding.js.map +1 -0
- package/dist/store/gi/interface.d.ts +5 -0
- package/dist/store/gi/interface.d.ts.map +1 -0
- package/dist/store/gi/interface.js +117 -0
- package/dist/store/gi/interface.js.map +1 -0
- package/dist/store/gi/item-comparators.d.ts +7 -0
- package/dist/store/gi/item-comparators.d.ts.map +1 -0
- package/dist/store/gi/item-comparators.js +88 -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 +336 -0
- package/dist/store/gi/method.js.map +1 -0
- package/dist/store/gi/param-marshal.d.ts +10 -0
- package/dist/store/gi/param-marshal.d.ts.map +1 -0
- package/dist/store/gi/param-marshal.js +50 -0
- package/dist/store/gi/param-marshal.js.map +1 -0
- package/dist/store/gi/pipeline.d.ts +5 -0
- package/dist/store/gi/pipeline.d.ts.map +1 -0
- package/dist/store/gi/pipeline.js +95 -0
- package/dist/store/gi/pipeline.js.map +1 -0
- package/dist/store/gi/properties.d.ts +6 -0
- package/dist/store/gi/properties.d.ts.map +1 -0
- package/dist/store/gi/properties.js +32 -0
- package/dist/store/gi/properties.js.map +1 -0
- package/dist/store/gi/property-accessor.d.ts +27 -0
- package/dist/store/gi/property-accessor.d.ts.map +1 -0
- package/dist/store/gi/property-accessor.js +158 -0
- package/dist/store/gi/property-accessor.js.map +1 -0
- package/dist/store/gi/record-constructor.d.ts +6 -0
- package/dist/store/gi/record-constructor.d.ts.map +1 -0
- package/dist/store/gi/record-constructor.js +76 -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 +360 -0
- package/dist/store/gi/record-field-accessor.js.map +1 -0
- package/dist/store/gi/record-layout.d.ts +15 -0
- package/dist/store/gi/record-layout.d.ts.map +1 -0
- package/dist/store/gi/record-layout.js +132 -0
- package/dist/store/gi/record-layout.js.map +1 -0
- package/dist/store/gi/record.d.ts +5 -0
- package/dist/store/gi/record.d.ts.map +1 -0
- package/dist/store/gi/record.js +65 -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 +21 -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 +67 -0
- package/dist/store/gi/return-wrap.js.map +1 -0
- package/dist/store/gi/runtime-override.d.ts +4 -0
- package/dist/store/gi/runtime-override.d.ts.map +1 -0
- package/dist/store/gi/runtime-override.js +32 -0
- package/dist/store/gi/runtime-override.js.map +1 -0
- package/dist/store/gi/signal.d.ts +6 -0
- package/dist/store/gi/signal.d.ts.map +1 -0
- package/dist/store/gi/signal.js +280 -0
- package/dist/store/gi/signal.js.map +1 -0
- package/dist/store/gi/vtable.d.ts +5 -0
- package/dist/store/gi/vtable.d.ts.map +1 -0
- package/dist/store/gi/vtable.js +108 -0
- package/dist/store/gi/vtable.js.map +1 -0
- package/dist/store/gi-store.d.ts +10 -0
- package/dist/store/gi-store.d.ts.map +1 -0
- package/dist/store/gi-store.js +59 -0
- package/dist/store/gi-store.js.map +1 -0
- 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/jsx/jsx.d.ts +16 -0
- package/dist/store/jsx/jsx.d.ts.map +1 -0
- package/dist/store/jsx/jsx.js +242 -0
- 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/jsx/metadata.js +253 -0
- 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/jsx/pipeline.js +81 -0
- package/dist/store/jsx/pipeline.js.map +1 -0
- package/dist/store/jsx/props.d.ts +33 -0
- 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 +7 -0
- package/dist/store/jsx-store.d.ts.map +1 -0
- package/dist/store/jsx-store.js +26 -0
- package/dist/store/jsx-store.js.map +1 -0
- package/dist/store/store-fs.d.ts +43 -0
- package/dist/store/store-fs.d.ts.map +1 -0
- package/dist/store/store-fs.js +73 -0
- package/dist/store/store-fs.js.map +1 -0
- package/dist/writer/context.d.ts +17 -0
- package/dist/writer/context.d.ts.map +1 -0
- package/dist/writer/context.js +50 -0
- package/dist/writer/context.js.map +1 -0
- package/dist/writer/doc.d.ts +3 -0
- package/dist/writer/doc.d.ts.map +1 -0
- package/dist/writer/doc.js +18 -0
- package/dist/writer/doc.js.map +1 -0
- package/dist/writer/emit.d.ts +9 -0
- package/dist/writer/emit.d.ts.map +1 -0
- package/dist/writer/emit.js +24 -0
- package/dist/writer/emit.js.map +1 -0
- package/dist/writer/gtk-doc.d.ts +3 -0
- package/dist/writer/gtk-doc.d.ts.map +1 -0
- package/dist/writer/gtk-doc.js +78 -0
- package/dist/writer/gtk-doc.js.map +1 -0
- package/dist/writer/imports.d.ts +12 -0
- package/dist/writer/imports.d.ts.map +1 -0
- package/dist/writer/imports.js +61 -0
- package/dist/writer/imports.js.map +1 -0
- package/dist/writer/module.d.ts +16 -0
- package/dist/writer/module.d.ts.map +1 -0
- package/dist/writer/module.js +53 -0
- package/dist/writer/module.js.map +1 -0
- 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 +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/package.json +21 -15
- package/src/analysis/descriptor-render.ts +723 -0
- package/src/analysis/descriptor.ts +300 -0
- package/src/analysis/inheritance.ts +430 -0
- package/src/analysis/param-structure.ts +258 -0
- package/src/analysis/ts-type.ts +174 -0
- package/src/compile.ts +179 -0
- package/src/docs/api-reference.ts +557 -0
- package/src/docs/element-page.ts +281 -0
- package/src/docs/pipeline.ts +241 -0
- package/src/docs/render.ts +255 -0
- package/src/docs/symbol-page.ts +589 -0
- package/src/fingerprint.ts +144 -35
- package/src/gi.ts +26 -0
- package/src/gir/ancestry.ts +53 -0
- package/src/gir/callback.ts +22 -24
- package/src/gir/class.ts +39 -61
- package/src/gir/enum.ts +25 -41
- package/src/gir/field.ts +51 -37
- package/src/gir/function.ts +44 -59
- package/src/gir/gir-path.ts +73 -0
- package/src/gir/libraries.ts +102 -0
- package/src/gir/library.ts +351 -0
- package/src/gir/namespace.ts +109 -88
- package/src/gir/nullable-overrides.ts +5 -0
- package/src/gir/parameter.ts +111 -102
- package/src/gir/parse.ts +124 -121
- package/src/gir/primitives.ts +43 -63
- package/src/gir/property.ts +33 -33
- package/src/gir/record.ts +55 -0
- package/src/gir/size.ts +93 -107
- package/src/gir/type-id.ts +64 -0
- package/src/gir/type-ref.ts +77 -146
- package/src/gir/type.ts +18 -0
- package/src/index.ts +27 -15
- package/src/jsx.ts +70 -0
- package/src/khronos/args.ts +271 -0
- package/src/khronos/jsdoc.ts +114 -0
- package/src/khronos/model.ts +267 -0
- package/src/khronos/modules.ts +115 -0
- package/src/khronos/param-pair.ts +14 -0
- package/src/khronos/parse.ts +86 -0
- package/src/khronos/pipeline.ts +337 -0
- package/src/khronos/plan.ts +340 -0
- package/src/khronos/registry/LICENSE +202 -0
- package/src/khronos/registry/gl.xml +47748 -0
- package/src/khronos/render.ts +330 -0
- package/src/khronos/select.ts +97 -0
- package/src/react/element-config.ts +91 -0
- package/src/runner.ts +153 -80
- package/src/store/compile-store.ts +55 -0
- package/src/store/gi/async.ts +69 -0
- package/src/store/gi/callables.ts +518 -0
- package/src/store/gi/callback.ts +24 -0
- package/src/store/gi/class-struct-record.ts +72 -0
- package/src/store/gi/class.ts +334 -0
- package/src/store/gi/companion.ts +22 -0
- package/src/store/gi/constant.ts +58 -0
- package/src/store/gi/constructor-props.ts +108 -0
- package/src/store/gi/enum.ts +64 -0
- package/src/store/gi/function.ts +173 -0
- package/src/store/gi/gtype-binding.ts +46 -0
- package/src/store/gi/interface.ts +222 -0
- package/src/store/gi/item-comparators.ts +138 -0
- package/src/store/gi/method.ts +634 -0
- package/src/store/gi/param-marshal.ts +71 -0
- package/src/store/gi/pipeline.ts +135 -0
- package/src/store/gi/properties.ts +50 -0
- package/src/store/gi/property-accessor.ts +302 -0
- package/src/store/gi/record-constructor.ts +119 -0
- package/src/store/gi/record-field-accessor.ts +607 -0
- package/src/store/gi/record-layout.ts +221 -0
- package/src/store/gi/record.ts +89 -0
- package/src/store/gi/registration.ts +44 -0
- package/src/store/gi/return-wrap.ts +100 -0
- package/src/store/gi/runtime-override.ts +46 -0
- package/src/store/gi/signal.ts +450 -0
- package/src/store/gi/vtable.ts +175 -0
- package/src/store/gi-store.ts +92 -0
- 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/jsx/jsx.ts +408 -0
- 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 +39 -0
- package/src/store/store-fs.ts +128 -0
- package/src/writer/context.ts +67 -0
- package/src/writer/doc.ts +25 -0
- package/src/writer/emit.ts +35 -0
- package/src/writer/gtk-doc.ts +101 -0
- package/src/writer/imports.ts +94 -0
- package/src/writer/module.ts +69 -0
- package/src/xml.ts +12 -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 +0 -44
- package/dist/writers/runtime-override.js.map +0 -1
- package/dist/writers/signal.d.ts +0 -21
- package/dist/writers/signal.d.ts.map +0 -1
- package/dist/writers/signal.js +0 -260
- package/dist/writers/signal.js.map +0 -1
- package/dist/writers/ts-type.d.ts +0 -50
- package/dist/writers/ts-type.d.ts.map +0 -1
- package/dist/writers/ts-type.js +0 -75
- package/dist/writers/ts-type.js.map +0 -1
- package/dist/writers/types-ts.d.ts +0 -27
- package/dist/writers/types-ts.d.ts.map +0 -1
- package/dist/writers/types-ts.js +0 -97
- package/dist/writers/types-ts.js.map +0 -1
- package/dist/writers/value.d.ts +0 -89
- package/dist/writers/value.d.ts.map +0 -1
- package/dist/writers/value.js +0 -402
- package/dist/writers/value.js.map +0 -1
- package/src/dsl/context.ts +0 -146
- package/src/dsl/emit.ts +0 -42
- package/src/dsl/identifier.ts +0 -52
- package/src/dsl/imports.ts +0 -109
- package/src/dsl/module.ts +0 -75
- package/src/ffi/pipeline.ts +0 -113
- package/src/gi-store.ts +0 -199
- package/src/gir/boxed.ts +0 -94
- package/src/gir/qualified-name.ts +0 -55
- package/src/gir/qualify.ts +0 -64
- package/src/gir/repository.ts +0 -149
- package/src/gir/signal.ts +0 -36
- package/src/jsx-store.ts +0 -53
- package/src/react/compounds-meta.ts +0 -99
- package/src/react/compounds.ts +0 -204
- package/src/react/internal.ts +0 -91
- package/src/react/jsx.ts +0 -155
- package/src/react/pipeline.ts +0 -29
- package/src/react/props.ts +0 -307
- package/src/react/slot-props.ts +0 -57
- package/src/react/widgets.ts +0 -185
- package/src/store-fs.ts +0 -157
- package/src/transpile.ts +0 -80
- package/src/typecheck-store.ts +0 -136
- package/src/writers/alias.ts +0 -19
- package/src/writers/async.ts +0 -44
- package/src/writers/boxed-constructor.ts +0 -105
- package/src/writers/boxed-field-accessor.ts +0 -306
- package/src/writers/boxed-layout.ts +0 -166
- package/src/writers/boxed.ts +0 -77
- package/src/writers/callables.ts +0 -339
- package/src/writers/callback.ts +0 -40
- package/src/writers/class-struct-record.ts +0 -75
- package/src/writers/class-struct.ts +0 -96
- package/src/writers/class.ts +0 -384
- package/src/writers/constant.ts +0 -29
- package/src/writers/constructor-props.ts +0 -130
- package/src/writers/enum.ts +0 -53
- package/src/writers/function.ts +0 -136
- package/src/writers/gtype-binding.ts +0 -48
- package/src/writers/inheritance.ts +0 -104
- package/src/writers/interface.ts +0 -168
- package/src/writers/method.ts +0 -678
- package/src/writers/param-classify.ts +0 -178
- package/src/writers/property-accessor.ts +0 -139
- package/src/writers/registration.ts +0 -42
- package/src/writers/return-wrap.ts +0 -180
- package/src/writers/runtime-override.ts +0 -59
- package/src/writers/signal.ts +0 -318
- package/src/writers/ts-type.ts +0 -115
- package/src/writers/value.ts +0 -485
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { sortStringsBy } from "@gtkx/utils";
|
|
2
|
+
import { namespaceDirectory } from "../../gir/namespace.js";
|
|
3
|
+
import { ImportsBuilder } from "../../writer/imports.js";
|
|
4
|
+
import { generateElementComponentsSection } from "./element-components.js";
|
|
5
|
+
import { setElementProps } from "./element-prop-imports.js";
|
|
6
|
+
import { lazyElementSpecs } from "./element-prop-types.js";
|
|
7
|
+
import { buildGirIndex } from "./gir-index.js";
|
|
8
|
+
import { collectIntrinsicElementClasses } from "./intrinsic-elements.js";
|
|
9
|
+
import { generateJsxSection } from "./jsx.js";
|
|
10
|
+
import { generateMetadata } from "./metadata.js";
|
|
11
|
+
const generateJsxFiles = (library, options = {}) => {
|
|
12
|
+
setElementProps(options.props ?? {});
|
|
13
|
+
const intrinsicElements = collectIntrinsicElementClasses(library);
|
|
14
|
+
const intrinsicElementByGlibName = new Map(intrinsicElements.map((entry) => [entry.glibName, entry]));
|
|
15
|
+
const girIndex = buildGirIndex(library);
|
|
16
|
+
const lazyByNamespace = lazyElementSpecs(girIndex, options.lazyElements ?? []);
|
|
17
|
+
const { namespaces, intrinsicElementCount } = generateNamespaceFiles({
|
|
18
|
+
library,
|
|
19
|
+
intrinsicElements,
|
|
20
|
+
intrinsicElementByGlibName,
|
|
21
|
+
lazyByNamespace,
|
|
22
|
+
reactSubexports: options.reactSubexports ?? [],
|
|
23
|
+
components: options.components ?? {},
|
|
24
|
+
});
|
|
25
|
+
const metadata = generateMetadata(library);
|
|
26
|
+
return { namespaces, metadata, intrinsicElementCount };
|
|
27
|
+
};
|
|
28
|
+
const orderedIntrinsicNamespaces = (intrinsicElements) => {
|
|
29
|
+
const namespacesWithIntrinsicElements = new Map();
|
|
30
|
+
for (const entry of intrinsicElements) {
|
|
31
|
+
namespacesWithIntrinsicElements.set(entry.namespace.name, entry.namespace);
|
|
32
|
+
}
|
|
33
|
+
return sortStringsBy(namespacesWithIntrinsicElements.values(), (entry) => entry.name);
|
|
34
|
+
};
|
|
35
|
+
const generateNamespaceFiles = (options) => {
|
|
36
|
+
const { library, intrinsicElements, intrinsicElementByGlibName, lazyByNamespace, reactSubexports, components } = options;
|
|
37
|
+
const namespaces = [];
|
|
38
|
+
let intrinsicElementCount = 0;
|
|
39
|
+
for (const namespace of orderedIntrinsicNamespaces(intrinsicElements)) {
|
|
40
|
+
const { source, count } = generateJsxNamespace(namespace, library, {
|
|
41
|
+
lazyElements: lazyByNamespace.get(namespace.name) ?? [],
|
|
42
|
+
intrinsicElements,
|
|
43
|
+
intrinsicElementByGlibName,
|
|
44
|
+
reactSubexports,
|
|
45
|
+
components,
|
|
46
|
+
});
|
|
47
|
+
namespaces.push({ directory: namespaceDirectory(namespace), source });
|
|
48
|
+
intrinsicElementCount += count;
|
|
49
|
+
}
|
|
50
|
+
return { namespaces, intrinsicElementCount };
|
|
51
|
+
};
|
|
52
|
+
const generateJsxNamespace = (targetNamespace, library, context) => {
|
|
53
|
+
const { lazyElements, intrinsicElements, intrinsicElementByGlibName, reactSubexports, components } = context;
|
|
54
|
+
const targetDirectory = namespaceDirectory(targetNamespace);
|
|
55
|
+
const imports = new ImportsBuilder();
|
|
56
|
+
imports.addSideEffect(`@gtkx/gi/${targetDirectory}`);
|
|
57
|
+
if (reactSubexports.includes(targetDirectory)) {
|
|
58
|
+
imports.addSideEffect(`@gtkx/react/${targetDirectory}`);
|
|
59
|
+
}
|
|
60
|
+
const elementComponents = generateElementComponentsSection(targetNamespace, library, {
|
|
61
|
+
imports,
|
|
62
|
+
lazyElements,
|
|
63
|
+
intrinsicElements,
|
|
64
|
+
components,
|
|
65
|
+
});
|
|
66
|
+
const excludeNames = new Set(elementComponents.exportedNames);
|
|
67
|
+
const { source: jsxSection, intrinsicCount } = generateJsxSection(targetNamespace, library, {
|
|
68
|
+
excludeNames,
|
|
69
|
+
imports,
|
|
70
|
+
intrinsicElements,
|
|
71
|
+
intrinsicElementByGlibName,
|
|
72
|
+
});
|
|
73
|
+
const body = [imports.toSource().trimEnd(), "", jsxSection];
|
|
74
|
+
if (elementComponents.source.length > 0) {
|
|
75
|
+
body.push("", elementComponents.source);
|
|
76
|
+
}
|
|
77
|
+
const count = elementComponents.exportedNames.size + intrinsicCount;
|
|
78
|
+
return { source: `${body.join("\n")}\n`, count };
|
|
79
|
+
};
|
|
80
|
+
export { generateJsxFiles };
|
|
81
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1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C;QACtC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,KAAK,GAAG,iBAAiB,CAAC,aAAa,CAAC,IAAI,GAAG,cAAc,CAAC;IAEpE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AACrD,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAoD,CAAC","sourcesContent":["import { sortStringsBy } from \"@gtkx/utils\";\nimport type { Library } from \"../../gir/library.js\";\nimport { type GirNamespace, namespaceDirectory } from \"../../gir/namespace.js\";\nimport { ImportsBuilder } from \"../../writer/imports.js\";\nimport { type ElementComponentOverrides, generateElementComponentsSection } from \"./element-components.js\";\nimport { type ElementProps, setElementProps } from \"./element-prop-imports.js\";\nimport { type LazyElementSpec, lazyElementSpecs } from \"./element-prop-types.js\";\nimport { buildGirIndex } from \"./gir-index.js\";\nimport { collectIntrinsicElementClasses, type GlibNamedClass } from \"./intrinsic-elements.js\";\nimport { generateJsxSection } from \"./jsx.js\";\nimport { generateMetadata } from \"./metadata.js\";\n\ntype JsxNamespaceFile = {\n directory: string;\n source: string;\n};\n\ntype JsxFiles = {\n namespaces: JsxNamespaceFile[];\n metadata: string;\n intrinsicElementCount: number;\n};\n\ntype JsxGenerationOptions = {\n reactSubexports?: string[];\n components?: ElementComponentOverrides;\n props?: ElementProps;\n lazyElements?: string[];\n};\n\ntype NamespaceFilesOptions = {\n library: Library;\n intrinsicElements: GlibNamedClass[];\n intrinsicElementByGlibName: Map<string, GlibNamedClass>;\n lazyByNamespace: Map<string, LazyElementSpec[]>;\n reactSubexports: string[];\n components: ElementComponentOverrides;\n};\n\ntype JsxNamespaceContext = {\n lazyElements: LazyElementSpec[];\n intrinsicElements: GlibNamedClass[];\n intrinsicElementByGlibName: Map<string, GlibNamedClass>;\n reactSubexports: string[];\n components: ElementComponentOverrides;\n};\n\nconst generateJsxFiles = (library: Library, options: JsxGenerationOptions = {}): JsxFiles => {\n setElementProps(options.props ?? {});\n const intrinsicElements = collectIntrinsicElementClasses(library);\n const intrinsicElementByGlibName = new Map(intrinsicElements.map((entry) => [entry.glibName, entry]));\n const girIndex = buildGirIndex(library);\n const lazyByNamespace = lazyElementSpecs(girIndex, options.lazyElements ?? []);\n\n const { namespaces, intrinsicElementCount } = generateNamespaceFiles({\n library,\n intrinsicElements,\n intrinsicElementByGlibName,\n lazyByNamespace,\n reactSubexports: options.reactSubexports ?? [],\n components: options.components ?? {},\n });\n\n const metadata = generateMetadata(library);\n\n return { namespaces, metadata, intrinsicElementCount };\n};\n\nconst orderedIntrinsicNamespaces = (intrinsicElements: GlibNamedClass[]): GirNamespace[] => {\n const namespacesWithIntrinsicElements: Map<string, GirNamespace> = new Map();\n\n for (const entry of intrinsicElements) {\n namespacesWithIntrinsicElements.set(entry.namespace.name, entry.namespace);\n }\n\n return sortStringsBy(namespacesWithIntrinsicElements.values(), (entry) => entry.name);\n};\n\nconst generateNamespaceFiles = (\n options: NamespaceFilesOptions,\n): { namespaces: JsxNamespaceFile[]; intrinsicElementCount: number } => {\n const { library, intrinsicElements, intrinsicElementByGlibName, lazyByNamespace, reactSubexports, components } =\n options;\n\n const namespaces: JsxNamespaceFile[] = [];\n let intrinsicElementCount = 0;\n\n for (const namespace of orderedIntrinsicNamespaces(intrinsicElements)) {\n const { source, count } = generateJsxNamespace(namespace, library, {\n lazyElements: lazyByNamespace.get(namespace.name) ?? [],\n intrinsicElements,\n intrinsicElementByGlibName,\n reactSubexports,\n components,\n });\n\n namespaces.push({ directory: namespaceDirectory(namespace), source });\n intrinsicElementCount += count;\n }\n\n return { namespaces, intrinsicElementCount };\n};\n\nconst generateJsxNamespace = (\n targetNamespace: GirNamespace,\n library: Library,\n context: JsxNamespaceContext,\n): { source: string; count: number } => {\n const { lazyElements, intrinsicElements, intrinsicElementByGlibName, reactSubexports, components } = context;\n const targetDirectory = namespaceDirectory(targetNamespace);\n const imports = new ImportsBuilder();\n imports.addSideEffect(`@gtkx/gi/${targetDirectory}`);\n\n if (reactSubexports.includes(targetDirectory)) {\n imports.addSideEffect(`@gtkx/react/${targetDirectory}`);\n }\n\n const elementComponents = generateElementComponentsSection(targetNamespace, library, {\n imports,\n lazyElements,\n intrinsicElements,\n components,\n });\n\n const excludeNames: Set<string> = new Set(elementComponents.exportedNames);\n\n const { source: jsxSection, intrinsicCount } = generateJsxSection(targetNamespace, library, {\n excludeNames,\n imports,\n intrinsicElements,\n intrinsicElementByGlibName,\n });\n\n const body = [imports.toSource().trimEnd(), \"\", jsxSection];\n\n if (elementComponents.source.length > 0) {\n body.push(\"\", elementComponents.source);\n }\n\n const count = elementComponents.exportedNames.size + intrinsicCount;\n\n return { source: `${body.join(\"\\n\")}\\n`, count };\n};\n\nexport { generateJsxFiles, type JsxNamespaceFile, type JsxGenerationOptions };\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { GirClass } from "../../gir/class.js";
|
|
2
|
+
import type { Library } from "../../gir/library.js";
|
|
3
|
+
import type { GirNamespace } from "../../gir/namespace.js";
|
|
4
|
+
import { type TsTypeTarget } from "../../analysis/ts-type.js";
|
|
5
|
+
import { type GirProperty } from "../../gir/property.js";
|
|
6
|
+
type IntrinsicElementPropsEntries = {
|
|
7
|
+
propLines: string[];
|
|
8
|
+
imports: Map<string, string>;
|
|
9
|
+
objectPropNames: string[];
|
|
10
|
+
};
|
|
11
|
+
type IntrinsicElementScope = {
|
|
12
|
+
library: Library;
|
|
13
|
+
klass: GirClass;
|
|
14
|
+
namespace: GirNamespace;
|
|
15
|
+
};
|
|
16
|
+
type IntrinsicElementPropsOptions = IntrinsicElementScope & {
|
|
17
|
+
isIntrinsicElementAncestor?: (candidate: GirClass) => boolean;
|
|
18
|
+
};
|
|
19
|
+
type PropTypeRenderContext = {
|
|
20
|
+
library: Library;
|
|
21
|
+
imports: Map<string, string>;
|
|
22
|
+
};
|
|
23
|
+
type InterfacePropsOptions = {
|
|
24
|
+
library: Library;
|
|
25
|
+
iface: GirClass;
|
|
26
|
+
namespace: GirNamespace;
|
|
27
|
+
};
|
|
28
|
+
declare const buildElementPropsEntries: (options: IntrinsicElementPropsOptions) => IntrinsicElementPropsEntries;
|
|
29
|
+
declare const buildInterfacePropsEntries: (options: InterfacePropsOptions) => IntrinsicElementPropsEntries;
|
|
30
|
+
declare const isObjectProp: (owner: IntrinsicElementScope, property: GirProperty, jsName: string) => boolean;
|
|
31
|
+
declare const reactTarget: (context: PropTypeRenderContext) => TsTypeTarget;
|
|
32
|
+
export { buildElementPropsEntries, buildInterfacePropsEntries, isObjectProp, reactTarget };
|
|
33
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/store/jsx/props.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAK3D,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAChG,OAAO,EAAE,KAAK,WAAW,EAA2B,MAAM,uBAAuB,CAAC;AASlF,KAAK,4BAA4B,GAAG;IAChC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,eAAe,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;AAEF,KAAK,qBAAqB,GAAG;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,QAAQ,CAAC;IAChB,SAAS,EAAE,YAAY,CAAC;CAC3B,CAAC;AAEF,KAAK,4BAA4B,GAAG,qBAAqB,GAAG;IACxD,0BAA0B,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,KAAK,OAAO,CAAC;CACjE,CAAC;AAEF,KAAK,qBAAqB,GAAG;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC,CAAC;AAwBF,KAAK,qBAAqB,GAAG;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,QAAQ,CAAC;IAChB,SAAS,EAAE,YAAY,CAAC;CAC3B,CAAC;AAkFF,QAAA,MAAM,wBAAwB,GAAI,SAAS,4BAA4B,KAAG,4BAczE,CAAC;AAEF,QAAA,MAAM,0BAA0B,GAAI,SAAS,qBAAqB,KAAG,4BAapE,CAAC;AAyCF,QAAA,MAAM,YAAY,GAAI,OAAO,qBAAqB,EAAE,UAAU,WAAW,EAAE,QAAQ,MAAM,KAAG,OAc3F,CAAC;AAqBF,QAAA,MAAM,WAAW,GAAI,SAAS,qBAAqB,KAAG,YAajD,CAAC;AAQN,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { toCamelIdentifier, upperFirst } from "@gtkx/utils";
|
|
2
|
+
import { forEachAncestor } from "../../analysis/inheritance.js";
|
|
3
|
+
import { renderHandlerParameters, renderHandlerResultType } from "../../analysis/param-structure.js";
|
|
4
|
+
import { recordTypeTarget, renderBaseType } from "../../analysis/ts-type.js";
|
|
5
|
+
import { isConstructableProperty } from "../../gir/property.js";
|
|
6
|
+
import { renderJsDoc } from "../../writer/doc.js";
|
|
7
|
+
import { giNamespaceAlias, hasExposedMethod, isIntrinsicElementClass, signalHandlerName, } from "./intrinsic-elements.js";
|
|
8
|
+
const appendPropertyLines = (state, property, jsName) => {
|
|
9
|
+
const tsType = renderReactPropType(state.types, property.type, false);
|
|
10
|
+
const doc = renderJsDoc(property.doc);
|
|
11
|
+
if (isObjectProp(state.owner, property, jsName)) {
|
|
12
|
+
state.propLines.push(`${doc}${jsName}?: ${tsType} | ReactElement | null | undefined;`);
|
|
13
|
+
state.objectPropNames.push(jsName);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const isSettable = isConstructableProperty(property);
|
|
17
|
+
if (isSettable) {
|
|
18
|
+
state.propLines.push(`${doc}${jsName}?: ${tsType} | null | undefined;`);
|
|
19
|
+
}
|
|
20
|
+
const handlerType = `((value: ${tsType} | null, self: Self) => void) | null | undefined`;
|
|
21
|
+
state.propLines.push(`${isSettable ? "" : doc}onNotify${upperFirst(jsName)}?: ${handlerType};`);
|
|
22
|
+
};
|
|
23
|
+
const acceptCollectorProperty = (state, property) => {
|
|
24
|
+
if (!property.introspectable) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const jsName = toCamelIdentifier(property.name);
|
|
28
|
+
if (state.seen.has(jsName)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
state.seen.add(jsName);
|
|
32
|
+
appendPropertyLines(state, property, jsName);
|
|
33
|
+
};
|
|
34
|
+
const acceptCollectorSignal = (state, signal) => {
|
|
35
|
+
const handlerName = signalHandlerName(signal.name);
|
|
36
|
+
if (state.seen.has(handlerName)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
state.seen.add(handlerName);
|
|
40
|
+
const signature = renderSignalHandler({ types: state.types, signal, selfType: "Self" });
|
|
41
|
+
state.propLines.push(`${renderJsDoc(signal.doc)}${handlerName}?: (${signature}) | undefined;`);
|
|
42
|
+
};
|
|
43
|
+
const createPropEntryCollector = (owner) => {
|
|
44
|
+
const { library } = owner;
|
|
45
|
+
const imports = new Map();
|
|
46
|
+
const types = { library, imports };
|
|
47
|
+
const state = {
|
|
48
|
+
owner,
|
|
49
|
+
types,
|
|
50
|
+
propLines: [],
|
|
51
|
+
objectPropNames: [],
|
|
52
|
+
seen: new Set(),
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
propLines: state.propLines,
|
|
56
|
+
imports,
|
|
57
|
+
objectPropNames: state.objectPropNames,
|
|
58
|
+
acceptProperty: (property) => {
|
|
59
|
+
acceptCollectorProperty(state, property);
|
|
60
|
+
},
|
|
61
|
+
acceptSignal: (signal) => {
|
|
62
|
+
acceptCollectorSignal(state, signal);
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const buildElementPropsEntries = (options) => {
|
|
67
|
+
const { library, klass, namespace, isIntrinsicElementAncestor = () => false } = options;
|
|
68
|
+
const collector = createPropEntryCollector({ library, klass, namespace });
|
|
69
|
+
walkIntrinsicElementMembers({
|
|
70
|
+
library,
|
|
71
|
+
klass,
|
|
72
|
+
namespace,
|
|
73
|
+
isIntrinsicElementAncestor,
|
|
74
|
+
acceptProperty: collector.acceptProperty,
|
|
75
|
+
acceptSignal: collector.acceptSignal,
|
|
76
|
+
});
|
|
77
|
+
return { propLines: collector.propLines, imports: collector.imports, objectPropNames: collector.objectPropNames };
|
|
78
|
+
};
|
|
79
|
+
const buildInterfacePropsEntries = (options) => {
|
|
80
|
+
const { library, iface, namespace } = options;
|
|
81
|
+
const collector = createPropEntryCollector({ library, klass: iface, namespace });
|
|
82
|
+
for (const property of iface.properties) {
|
|
83
|
+
collector.acceptProperty(property);
|
|
84
|
+
}
|
|
85
|
+
for (const signal of iface.signals) {
|
|
86
|
+
collector.acceptSignal(signal);
|
|
87
|
+
}
|
|
88
|
+
return { propLines: collector.propLines, imports: collector.imports, objectPropNames: collector.objectPropNames };
|
|
89
|
+
};
|
|
90
|
+
const walkIntrinsicElementMembers = (walk) => {
|
|
91
|
+
const { library, klass, namespace, isIntrinsicElementAncestor, acceptProperty, acceptSignal } = walk;
|
|
92
|
+
const visitMembers = (memberClass) => {
|
|
93
|
+
for (const property of memberClass.properties) {
|
|
94
|
+
acceptProperty(property);
|
|
95
|
+
}
|
|
96
|
+
for (const signal of memberClass.signals) {
|
|
97
|
+
acceptSignal(signal);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const ancestry = { library, namespace };
|
|
101
|
+
visitMembers(klass);
|
|
102
|
+
forEachAncestor(ancestry, klass, (ancestor) => {
|
|
103
|
+
visitMembers(ancestor.klass);
|
|
104
|
+
}, isIntrinsicElementAncestor);
|
|
105
|
+
};
|
|
106
|
+
const isGObjectType = (library, ref) => {
|
|
107
|
+
if (ref === undefined) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
const resolved = library.typeFor(ref);
|
|
111
|
+
if (resolved?.kind === "interface") {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
if (resolved?.kind !== "class") {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
return isIntrinsicElementClass(resolved.value, resolved.namespace, library);
|
|
118
|
+
};
|
|
119
|
+
const isObjectProp = (owner, property, jsName) => {
|
|
120
|
+
if (!property.writable || property.constructOnly) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
if (!isGObjectType(owner.library, property.type)) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
if (jsName === "child" && hasExposedMethod(owner.klass, owner.namespace, owner.library, "set_child")) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
};
|
|
131
|
+
const renderSignalHandler = (options) => {
|
|
132
|
+
const { types, signal, selfType } = options;
|
|
133
|
+
const params = [
|
|
134
|
+
...renderHandlerParameters(signal.parameters, (ref, nullable) => renderReactPropType(types, ref, nullable)),
|
|
135
|
+
`self: ${selfType}`,
|
|
136
|
+
];
|
|
137
|
+
const result = renderHandlerResultType({
|
|
138
|
+
library: types.library,
|
|
139
|
+
signal,
|
|
140
|
+
renderType: (ref, nullable) => renderReactPropType(types, ref, nullable),
|
|
141
|
+
includeCallerAllocated: false,
|
|
142
|
+
optOut: true,
|
|
143
|
+
});
|
|
144
|
+
return `(${params.join(", ")}) => ${result}`;
|
|
145
|
+
};
|
|
146
|
+
const reactTarget = (context) => recordTypeTarget(context.library, (name) => {
|
|
147
|
+
context.imports.set(name.namespaceName, giNamespaceAlias(name.namespaceName));
|
|
148
|
+
return `${giNamespaceAlias(name.namespaceName)}.${name.typeName}`;
|
|
149
|
+
}, () => {
|
|
150
|
+
context.imports.set("GObject", giNamespaceAlias("GObject"));
|
|
151
|
+
return `${giNamespaceAlias("GObject")}.Type`;
|
|
152
|
+
});
|
|
153
|
+
const renderReactPropType = (context, ref, isNullable) => {
|
|
154
|
+
const base = renderBaseType(context.library, reactTarget(context), ref);
|
|
155
|
+
return isNullable ? `${base} | null` : base;
|
|
156
|
+
};
|
|
157
|
+
export { buildElementPropsEntries, buildInterfacePropsEntries, isObjectProp, reactTarget };
|
|
158
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/store/jsx/props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAM5D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAqB,MAAM,2BAA2B,CAAC;AAChG,OAAO,EAAoB,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,GACpB,MAAM,yBAAyB,CAAC;AAyDjC,MAAM,mBAAmB,GAAG,CAAC,KAAyB,EAAE,QAAqB,EAAE,MAAc,EAAQ,EAAE;IACnG,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACtE,MAAM,GAAG,G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EAAgB,EAAE,CACjE,gBAAgB,CACZ,OAAO,CAAC,OAAO,EACf,CAAC,IAAI,EAAE,EAAE;IACL,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,gBAAgB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;IAE9E,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;AACtE,CAAC,EACD,GAAG,EAAE;IACD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;IAE5D,OAAO,GAAG,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC;AACjD,CAAC,CACJ,CAAC;AAEN,MAAM,mBAAmB,GAAG,CAAC,OAA8B,EAAE,GAAuB,EAAE,UAAmB,EAAU,EAAE;IACjH,MAAM,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC;IAExE,OAAO,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AAChD,CAAC,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import { toCamelIdentifier, upperFirst } from \"@gtkx/utils\";\nimport type { GirClass } from \"../../gir/class.js\";\nimport type { Library } from \"../../gir/library.js\";\nimport type { GirNamespace } from \"../../gir/namespace.js\";\nimport type { GirCallable } from \"../../gir/parameter.js\";\nimport type { TypeId } from \"../../gir/type-id.js\";\nimport { forEachAncestor } from \"../../analysis/inheritance.js\";\nimport { renderHandlerParameters, renderHandlerResultType } from \"../../analysis/param-structure.js\";\nimport { recordTypeTarget, renderBaseType, type TsTypeTarget } from \"../../analysis/ts-type.js\";\nimport { type GirProperty, isConstructableProperty } from \"../../gir/property.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\nimport {\n giNamespaceAlias,\n hasExposedMethod,\n isIntrinsicElementClass,\n signalHandlerName,\n} from \"./intrinsic-elements.js\";\n\ntype IntrinsicElementPropsEntries = {\n propLines: string[];\n imports: Map<string, string>;\n objectPropNames: string[];\n};\n\ntype IntrinsicElementScope = {\n library: Library;\n klass: GirClass;\n namespace: GirNamespace;\n};\n\ntype IntrinsicElementPropsOptions = IntrinsicElementScope & {\n isIntrinsicElementAncestor?: (candidate: GirClass) => boolean;\n};\n\ntype PropTypeRenderContext = {\n library: Library;\n imports: Map<string, string>;\n};\n\ntype SignalRenderOptions = {\n types: PropTypeRenderContext;\n signal: GirCallable;\n selfType: string;\n};\n\ntype PropEntryCollector = {\n propLines: string[];\n imports: Map<string, string>;\n objectPropNames: string[];\n acceptProperty: (property: GirProperty) => void;\n acceptSignal: (signal: GirCallable) => void;\n};\n\ntype PropCollectorState = {\n owner: IntrinsicElementScope;\n types: PropTypeRenderContext;\n propLines: string[];\n objectPropNames: string[];\n seen: Set<string>;\n};\n\ntype InterfacePropsOptions = {\n library: Library;\n iface: GirClass;\n namespace: GirNamespace;\n};\n\ntype IntrinsicElementMemberWalk = IntrinsicElementScope & {\n isIntrinsicElementAncestor: (candidate: GirClass) => boolean;\n acceptProperty: (property: GirProperty) => void;\n acceptSignal: (signal: GirCallable) => void;\n};\n\nconst appendPropertyLines = (state: PropCollectorState, property: GirProperty, jsName: string): void => {\n const tsType = renderReactPropType(state.types, property.type, false);\n const doc = renderJsDoc(property.doc);\n\n if (isObjectProp(state.owner, property, jsName)) {\n state.propLines.push(`${doc}${jsName}?: ${tsType} | ReactElement | null | undefined;`);\n state.objectPropNames.push(jsName);\n\n return;\n }\n\n const isSettable = isConstructableProperty(property);\n\n if (isSettable) {\n state.propLines.push(`${doc}${jsName}?: ${tsType} | null | undefined;`);\n }\n\n const handlerType = `((value: ${tsType} | null, self: Self) => void) | null | undefined`;\n state.propLines.push(`${isSettable ? \"\" : doc}onNotify${upperFirst(jsName)}?: ${handlerType};`);\n};\n\nconst acceptCollectorProperty = (state: PropCollectorState, property: GirProperty): void => {\n if (!property.introspectable) {\n return;\n }\n\n const jsName = toCamelIdentifier(property.name);\n\n if (state.seen.has(jsName)) {\n return;\n }\n\n state.seen.add(jsName);\n appendPropertyLines(state, property, jsName);\n};\n\nconst acceptCollectorSignal = (state: PropCollectorState, signal: GirCallable): void => {\n const handlerName = signalHandlerName(signal.name);\n\n if (state.seen.has(handlerName)) {\n return;\n }\n\n state.seen.add(handlerName);\n const signature = renderSignalHandler({ types: state.types, signal, selfType: \"Self\" });\n state.propLines.push(`${renderJsDoc(signal.doc)}${handlerName}?: (${signature}) | undefined;`);\n};\n\nconst createPropEntryCollector = (owner: IntrinsicElementScope): PropEntryCollector => {\n const { library } = owner;\n const imports: Map<string, string> = new Map();\n const types: PropTypeRenderContext = { library, imports };\n\n const state: PropCollectorState = {\n owner,\n types,\n propLines: [],\n objectPropNames: [],\n seen: new Set<string>(),\n };\n\n return {\n propLines: state.propLines,\n imports,\n objectPropNames: state.objectPropNames,\n acceptProperty: (property) => {\n acceptCollectorProperty(state, property);\n },\n acceptSignal: (signal) => {\n acceptCollectorSignal(state, signal);\n },\n };\n};\n\nconst buildElementPropsEntries = (options: IntrinsicElementPropsOptions): IntrinsicElementPropsEntries => {\n const { library, klass, namespace, isIntrinsicElementAncestor = () => false } = options;\n const collector = createPropEntryCollector({ library, klass, namespace });\n\n walkIntrinsicElementMembers({\n library,\n klass,\n namespace,\n isIntrinsicElementAncestor,\n acceptProperty: collector.acceptProperty,\n acceptSignal: collector.acceptSignal,\n });\n\n return { propLines: collector.propLines, imports: collector.imports, objectPropNames: collector.objectPropNames };\n};\n\nconst buildInterfacePropsEntries = (options: InterfacePropsOptions): IntrinsicElementPropsEntries => {\n const { library, iface, namespace } = options;\n const collector = createPropEntryCollector({ library, klass: iface, namespace });\n\n for (const property of iface.properties) {\n collector.acceptProperty(property);\n }\n\n for (const signal of iface.signals) {\n collector.acceptSignal(signal);\n }\n\n return { propLines: collector.propLines, imports: collector.imports, objectPropNames: collector.objectPropNames };\n};\n\nconst walkIntrinsicElementMembers = (walk: IntrinsicElementMemberWalk): void => {\n const { library, klass, namespace, isIntrinsicElementAncestor, acceptProperty, acceptSignal } = walk;\n\n const visitMembers = (memberClass: GirClass): void => {\n for (const property of memberClass.properties) {\n acceptProperty(property);\n }\n\n for (const signal of memberClass.signals) {\n acceptSignal(signal);\n }\n };\n\n const ancestry = { library, namespace };\n visitMembers(klass);\n\n forEachAncestor(ancestry, klass, (ancestor) => {\n visitMembers(ancestor.klass);\n }, isIntrinsicElementAncestor);\n};\n\nconst isGObjectType = (library: Library, ref: TypeId | undefined): boolean => {\n if (ref === undefined) {\n return false;\n }\n\n const resolved = library.typeFor(ref);\n\n if (resolved?.kind === \"interface\") {\n return true;\n }\n\n if (resolved?.kind !== \"class\") {\n return false;\n }\n\n return isIntrinsicElementClass(resolved.value, resolved.namespace, library);\n};\n\nconst isObjectProp = (owner: IntrinsicElementScope, property: GirProperty, jsName: string): boolean => {\n if (!property.writable || property.constructOnly) {\n return false;\n }\n\n if (!isGObjectType(owner.library, property.type)) {\n return false;\n }\n\n if (jsName === \"child\" && hasExposedMethod(owner.klass, owner.namespace, owner.library, \"set_child\")) {\n return false;\n }\n\n return true;\n};\n\nconst renderSignalHandler = (options: SignalRenderOptions): string => {\n const { types, signal, selfType } = options;\n\n const params = [\n ...renderHandlerParameters(signal.parameters, (ref, nullable) => renderReactPropType(types, ref, nullable)),\n `self: ${selfType}`,\n ];\n\n const result = renderHandlerResultType({\n library: types.library,\n signal,\n renderType: (ref, nullable) => renderReactPropType(types, ref, nullable),\n includeCallerAllocated: false,\n optOut: true,\n });\n\n return `(${params.join(\", \")}) => ${result}`;\n};\n\nconst reactTarget = (context: PropTypeRenderContext): TsTypeTarget =>\n recordTypeTarget(\n context.library,\n (name) => {\n context.imports.set(name.namespaceName, giNamespaceAlias(name.namespaceName));\n\n return `${giNamespaceAlias(name.namespaceName)}.${name.typeName}`;\n },\n () => {\n context.imports.set(\"GObject\", giNamespaceAlias(\"GObject\"));\n\n return `${giNamespaceAlias(\"GObject\")}.Type`;\n },\n );\n\nconst renderReactPropType = (context: PropTypeRenderContext, ref: TypeId | undefined, isNullable: boolean): string => {\n const base = renderBaseType(context.library, reactTarget(context), ref);\n\n return isNullable ? `${base} | null` : base;\n};\n\nexport { buildElementPropsEntries, buildInterfacePropsEntries, isObjectProp, reactTarget };\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { JsxNamespaceFile } from "./jsx/pipeline.js";
|
|
2
|
+
import type { RawFile } from "./store-fs.js";
|
|
3
|
+
import { type StoreOptions } from "./store-fs.js";
|
|
4
|
+
type JsxStoreOptions = StoreOptions;
|
|
5
|
+
declare const writeJsxStore: (options: JsxStoreOptions, namespaces: JsxNamespaceFile[], metadata: string, fingerprint: RawFile) => void;
|
|
6
|
+
export { writeJsxStore, type JsxStoreOptions };
|
|
7
|
+
//# sourceMappingURL=jsx-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-store.d.ts","sourceRoot":"","sources":["../../src/store/jsx-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAiB,KAAK,YAAY,EAA6B,MAAM,eAAe,CAAC;AAE5F,KAAK,eAAe,GAAG,YAAY,CAAC;AAEpC,QAAA,MAAM,aAAa,GACf,SAAS,eAAe,EACxB,YAAY,gBAAgB,EAAE,EAC9B,UAAU,MAAM,EAChB,aAAa,OAAO,KACrB,IAyBF,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,KAAK,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { buildManifest, subpathExport, writeStore } from "./store-fs.js";
|
|
2
|
+
const writeJsxStore = (options, namespaces, metadata, fingerprint) => {
|
|
3
|
+
const exportsMap = {
|
|
4
|
+
"./metadata": subpathExport("metadata"),
|
|
5
|
+
};
|
|
6
|
+
const files = [{ fileName: "metadata.ts", source: metadata }];
|
|
7
|
+
for (const { directory, source } of namespaces) {
|
|
8
|
+
files.push({ fileName: `${directory}/${directory}.tsx`, source });
|
|
9
|
+
exportsMap[`./${directory}`] = subpathExport(`${directory}/${directory}`);
|
|
10
|
+
}
|
|
11
|
+
writeStore({
|
|
12
|
+
storeDir: options.storeDir,
|
|
13
|
+
linkDir: options.linkDir,
|
|
14
|
+
files,
|
|
15
|
+
manifest: buildManifest({
|
|
16
|
+
name: "@gtkx/jsx",
|
|
17
|
+
version: options.version,
|
|
18
|
+
exports: exportsMap,
|
|
19
|
+
peerDependencies: { "@gtkx/gi": "*", "@gtkx/react": "*", react: "*" },
|
|
20
|
+
}),
|
|
21
|
+
rawFiles: [fingerprint],
|
|
22
|
+
configEnv: true,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export { writeJsxStore };
|
|
26
|
+
//# sourceMappingURL=jsx-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-store.js","sourceRoot":"","sources":["../../src/store/jsx-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAqB,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI5F,MAAM,aAAa,GAAG,CAClB,OAAwB,EACxB,UAA8B,EAC9B,QAAgB,EAChB,WAAoB,EAChB,EAAE;IACN,MAAM,UAAU,GAA4B;QACxC,YAAY,EAAE,aAAa,CAAC,UAAU,CAAC;KAC1C,CAAC;IAEF,MAAM,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAE9D,KAAK,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;QAC7C,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,GAAG,SAAS,IAAI,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAClE,UAAU,CAAC,KAAK,SAAS,EAAE,CAAC,GAAG,aAAa,CAAC,GAAG,SAAS,IAAI,SAAS,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,UAAU,CAAC;QACP,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,KAAK;QACL,QAAQ,EAAE,aAAa,CAAC;YACpB,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,UAAU;YACnB,gBAAgB,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE;SACxE,CAAC;QACF,QAAQ,EAAE,CAAC,WAAW,CAAC;QACvB,SAAS,EAAE,IAAI;KAClB,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EAAE,aAAa,EAAwB,CAAC","sourcesContent":["import type { JsxNamespaceFile } from \"./jsx/pipeline.js\";\nimport type { RawFile } from \"./store-fs.js\";\nimport { buildManifest, type StoreOptions, subpathExport, writeStore } from \"./store-fs.js\";\n\ntype JsxStoreOptions = StoreOptions;\n\nconst writeJsxStore = (\n options: JsxStoreOptions,\n namespaces: JsxNamespaceFile[],\n metadata: string,\n fingerprint: RawFile,\n): void => {\n const exportsMap: Record<string, unknown> = {\n \"./metadata\": subpathExport(\"metadata\"),\n };\n\n const files = [{ fileName: \"metadata.ts\", source: metadata }];\n\n for (const { directory, source } of namespaces) {\n files.push({ fileName: `${directory}/${directory}.tsx`, source });\n exportsMap[`./${directory}`] = subpathExport(`${directory}/${directory}`);\n }\n\n writeStore({\n storeDir: options.storeDir,\n linkDir: options.linkDir,\n files,\n manifest: buildManifest({\n name: \"@gtkx/jsx\",\n version: options.version,\n exports: exportsMap,\n peerDependencies: { \"@gtkx/gi\": \"*\", \"@gtkx/react\": \"*\", react: \"*\" },\n }),\n rawFiles: [fingerprint],\n configEnv: true,\n });\n};\n\nexport { writeJsxStore, type JsxStoreOptions };\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
type StoreOptions = {
|
|
2
|
+
storeDir: string;
|
|
3
|
+
linkDir: string;
|
|
4
|
+
version: string;
|
|
5
|
+
};
|
|
6
|
+
type StoreFile = {
|
|
7
|
+
fileName: string;
|
|
8
|
+
source: string;
|
|
9
|
+
};
|
|
10
|
+
type Manifest = {
|
|
11
|
+
name: string;
|
|
12
|
+
type: "module";
|
|
13
|
+
version: string;
|
|
14
|
+
sideEffects: true;
|
|
15
|
+
exports: Record<string, unknown>;
|
|
16
|
+
peerDependencies?: Record<string, string>;
|
|
17
|
+
};
|
|
18
|
+
type ManifestInput = {
|
|
19
|
+
name: string;
|
|
20
|
+
version: string;
|
|
21
|
+
exports: Record<string, unknown>;
|
|
22
|
+
peerDependencies?: Record<string, string>;
|
|
23
|
+
};
|
|
24
|
+
type RawFile = {
|
|
25
|
+
relativePath: string;
|
|
26
|
+
content: string;
|
|
27
|
+
};
|
|
28
|
+
type WriteStoreParams = {
|
|
29
|
+
storeDir: string;
|
|
30
|
+
linkDir: string;
|
|
31
|
+
files: StoreFile[];
|
|
32
|
+
manifest: Manifest;
|
|
33
|
+
rawFiles?: RawFile[];
|
|
34
|
+
configEnv?: boolean;
|
|
35
|
+
};
|
|
36
|
+
declare const subpathExport: (stem: string) => {
|
|
37
|
+
types: string;
|
|
38
|
+
default: string;
|
|
39
|
+
};
|
|
40
|
+
declare const buildManifest: (input: ManifestInput) => Manifest;
|
|
41
|
+
declare const writeStore: (params: WriteStoreParams) => void;
|
|
42
|
+
export { subpathExport, buildManifest, writeStore, type StoreOptions, type RawFile };
|
|
43
|
+
//# sourceMappingURL=store-fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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C;IAAC,OAAO,EAAE,MAAM,CAAA;CAGpE,CAAC;AAEH,QAAA,MAAM,aAAa,GAAI,OAAO,aAAa,KAAG,QAc7C,CAAC;AAEF,QAAA,MAAM,UAAU,GAAI,QAAQ,gBAAgB,KAAG,IA2B9C,CAAC;AAqCF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, mkdtempSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join, relative } from "node:path";
|
|
3
|
+
import { compileStore } from "./compile-store.js";
|
|
4
|
+
const subpathExport = (stem) => ({
|
|
5
|
+
types: `./${stem}.d.ts`,
|
|
6
|
+
default: `./${stem}.js`,
|
|
7
|
+
});
|
|
8
|
+
const buildManifest = (input) => {
|
|
9
|
+
const manifest = {
|
|
10
|
+
name: input.name,
|
|
11
|
+
type: "module",
|
|
12
|
+
version: input.version,
|
|
13
|
+
sideEffects: true,
|
|
14
|
+
exports: { "./package.json": "./package.json", ...input.exports },
|
|
15
|
+
};
|
|
16
|
+
if (input.peerDependencies) {
|
|
17
|
+
manifest.peerDependencies = input.peerDependencies;
|
|
18
|
+
}
|
|
19
|
+
return manifest;
|
|
20
|
+
};
|
|
21
|
+
const writeStore = (params) => {
|
|
22
|
+
const tmp = createTempStore(params.storeDir);
|
|
23
|
+
try {
|
|
24
|
+
for (const file of params.files) {
|
|
25
|
+
writeSourceFile(tmp, file.fileName, file.source);
|
|
26
|
+
}
|
|
27
|
+
compileStore({
|
|
28
|
+
storeDir: tmp,
|
|
29
|
+
files: params.files,
|
|
30
|
+
packageName: params.manifest.name,
|
|
31
|
+
...(params.configEnv !== undefined && { configEnv: params.configEnv }),
|
|
32
|
+
});
|
|
33
|
+
writePackageJson(tmp, params.manifest);
|
|
34
|
+
const rawFiles = params.rawFiles ?? [];
|
|
35
|
+
for (const raw of rawFiles) {
|
|
36
|
+
writeFileSync(join(tmp, raw.relativePath), raw.content);
|
|
37
|
+
}
|
|
38
|
+
symlinkRelative(join(tmp, "node_modules", ...params.manifest.name.split("/")), tmp);
|
|
39
|
+
swapStore(tmp, params.storeDir, params.linkDir);
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const writeSourceFile = (storeDir, fileName, source) => {
|
|
46
|
+
const filePath = join(storeDir, fileName);
|
|
47
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
48
|
+
writeFileSync(filePath, source);
|
|
49
|
+
};
|
|
50
|
+
const symlinkRelative = (linkPath, realTarget) => {
|
|
51
|
+
mkdirSync(dirname(linkPath), { recursive: true });
|
|
52
|
+
rmSync(linkPath, { recursive: true, force: true });
|
|
53
|
+
symlinkSync(relative(dirname(linkPath), realTarget), linkPath, "dir");
|
|
54
|
+
};
|
|
55
|
+
const writePackageJson = (storeDir, manifest) => {
|
|
56
|
+
writeFileSync(join(storeDir, "package.json"), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
57
|
+
};
|
|
58
|
+
const swapStore = (tmp, storeDir, visibleLink) => {
|
|
59
|
+
const previous = `${storeDir}.old`;
|
|
60
|
+
rmSync(previous, { recursive: true, force: true });
|
|
61
|
+
if (existsSync(storeDir)) {
|
|
62
|
+
renameSync(storeDir, previous);
|
|
63
|
+
}
|
|
64
|
+
renameSync(tmp, storeDir);
|
|
65
|
+
rmSync(previous, { recursive: true, force: true });
|
|
66
|
+
symlinkRelative(visibleLink, storeDir);
|
|
67
|
+
};
|
|
68
|
+
const createTempStore = (storeDir) => {
|
|
69
|
+
mkdirSync(dirname(storeDir), { recursive: true });
|
|
70
|
+
return mkdtempSync(`${storeDir}.tmp-`);
|
|
71
|
+
};
|
|
72
|
+
export { subpathExport, buildManifest, writeStore };
|
|
73
|
+
//# sourceMappingURL=store-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AAE;IACjD,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAElD,OAAO,WAAW,CAAC,GAAG,QAAQ,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAmC,CAAC","sourcesContent":["import { existsSync, mkdirSync, mkdtempSync, renameSync, rmSync, symlinkSync, writeFileSync } from \"node:fs\";\nimport { dirname, join, relative } from \"node:path\";\nimport { compileStore } from \"./compile-store.js\";\n\ntype StoreOptions = {\n storeDir: string;\n linkDir: string;\n version: string;\n};\n\ntype StoreFile = {\n fileName: string;\n source: string;\n};\n\ntype Manifest = {\n name: string;\n type: \"module\";\n version: string;\n sideEffects: true;\n exports: Record<string, unknown>;\n peerDependencies?: Record<string, string>;\n};\n\ntype ManifestInput = {\n name: string;\n version: string;\n exports: Record<string, unknown>;\n peerDependencies?: Record<string, string>;\n};\n\ntype RawFile = { relativePath: string; content: string };\n\ntype WriteStoreParams = {\n storeDir: string;\n linkDir: string;\n files: StoreFile[];\n manifest: Manifest;\n rawFiles?: RawFile[];\n configEnv?: boolean;\n};\n\nconst subpathExport = (stem: string): { types: string; default: string } => ({\n types: `./${stem}.d.ts`,\n default: `./${stem}.js`,\n});\n\nconst buildManifest = (input: ManifestInput): Manifest => {\n const manifest: Manifest = {\n name: input.name,\n type: \"module\",\n version: input.version,\n sideEffects: true,\n exports: { \"./package.json\": \"./package.json\", ...input.exports },\n };\n\n if (input.peerDependencies) {\n manifest.peerDependencies = input.peerDependencies;\n }\n\n return manifest;\n};\n\nconst writeStore = (params: WriteStoreParams): void => {\n const tmp = createTempStore(params.storeDir);\n\n try {\n for (const file of params.files) {\n writeSourceFile(tmp, file.fileName, file.source);\n }\n\n compileStore({\n storeDir: tmp,\n files: params.files,\n packageName: params.manifest.name,\n ...(params.configEnv !== undefined && { configEnv: params.configEnv }),\n });\n\n writePackageJson(tmp, params.manifest);\n const rawFiles = params.rawFiles ?? [];\n\n for (const raw of rawFiles) {\n writeFileSync(join(tmp, raw.relativePath), raw.content);\n }\n\n symlinkRelative(join(tmp, \"node_modules\", ...params.manifest.name.split(\"/\")), tmp);\n swapStore(tmp, params.storeDir, params.linkDir);\n } finally {\n rmSync(tmp, { recursive: true, force: true });\n }\n};\n\nconst writeSourceFile = (storeDir: string, fileName: string, source: string): void => {\n const filePath = join(storeDir, fileName);\n mkdirSync(dirname(filePath), { recursive: true });\n writeFileSync(filePath, source);\n};\n\nconst symlinkRelative = (linkPath: string, realTarget: string): void => {\n mkdirSync(dirname(linkPath), { recursive: true });\n rmSync(linkPath, { recursive: true, force: true });\n symlinkSync(relative(dirname(linkPath), realTarget), linkPath, \"dir\");\n};\n\nconst writePackageJson = (storeDir: string, manifest: Manifest): void => {\n writeFileSync(join(storeDir, \"package.json\"), `${JSON.stringify(manifest, null, 2)}\\n`);\n};\n\nconst swapStore = (tmp: string, storeDir: string, visibleLink: string): void => {\n const previous = `${storeDir}.old`;\n rmSync(previous, { recursive: true, force: true });\n\n if (existsSync(storeDir)) {\n renameSync(storeDir, previous);\n }\n\n renameSync(tmp, storeDir);\n rmSync(previous, { recursive: true, force: true });\n symlinkRelative(visibleLink, storeDir);\n};\n\nconst createTempStore = (storeDir: string): string => {\n mkdirSync(dirname(storeDir), { recursive: true });\n\n return mkdtempSync(`${storeDir}.tmp-`);\n};\n\nexport { subpathExport, buildManifest, writeStore, type StoreOptions, type RawFile };\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Library } from "../gir/library.js";
|
|
2
|
+
import type { GirNamespace } from "../gir/namespace.js";
|
|
3
|
+
import { ModuleBuilder } from "./module.js";
|
|
4
|
+
declare class ModuleContext {
|
|
5
|
+
module: ModuleBuilder;
|
|
6
|
+
namespace: GirNamespace;
|
|
7
|
+
library: Library;
|
|
8
|
+
constructor(namespace: GirNamespace, library: Library);
|
|
9
|
+
addRuntimeImport(name: string): void;
|
|
10
|
+
addRuntimeTypeImport(name: string): void;
|
|
11
|
+
hoistDescriptor(expression: string): string;
|
|
12
|
+
addGObjectBootstrapImports(): void;
|
|
13
|
+
addCrossNamespaceImport(namespaceName: string): string;
|
|
14
|
+
qualify(namespaceName: string, typeName: string): string;
|
|
15
|
+
}
|
|
16
|
+
export { ModuleContext };
|
|
17
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/writer/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,cAAM,aAAa;IACR,MAAM,EAAE,aAAa,CAAuB;IAC5C,SAAS,EAAE,YAAY,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;gBAEZ,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO;IAKrD,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIxC,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAI3C,0BAA0B,IAAI,IAAI;IAalC,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;IAkBtD,OAAO,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;CAO3D;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ModuleBuilder } from "./module.js";
|
|
2
|
+
class ModuleContext {
|
|
3
|
+
module = new ModuleBuilder();
|
|
4
|
+
namespace;
|
|
5
|
+
library;
|
|
6
|
+
constructor(namespace, library) {
|
|
7
|
+
this.namespace = namespace;
|
|
8
|
+
this.library = library;
|
|
9
|
+
}
|
|
10
|
+
addRuntimeImport(name) {
|
|
11
|
+
this.module.imports.addNamed("@gtkx/runtime", name);
|
|
12
|
+
}
|
|
13
|
+
addRuntimeTypeImport(name) {
|
|
14
|
+
this.module.imports.addNamed("@gtkx/runtime", name, true);
|
|
15
|
+
}
|
|
16
|
+
hoistDescriptor(expression) {
|
|
17
|
+
return this.module.hoistDescriptor(expression);
|
|
18
|
+
}
|
|
19
|
+
addGObjectBootstrapImports() {
|
|
20
|
+
if (this.namespace.name === "GObject") {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (this.namespace.name === "GLib") {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.module.imports.addSideEffect("../gobject/overrides/object.js");
|
|
27
|
+
this.module.imports.addSideEffect("../gobject/overrides/value.js");
|
|
28
|
+
}
|
|
29
|
+
addCrossNamespaceImport(namespaceName) {
|
|
30
|
+
if (namespaceName === this.namespace.name) {
|
|
31
|
+
return namespaceName;
|
|
32
|
+
}
|
|
33
|
+
const directory = namespaceName.toLowerCase();
|
|
34
|
+
const isFoundational = directory === "gobject" || directory === "glib";
|
|
35
|
+
const path = isFoundational ? `../${directory}/${directory}.js` : `../${directory}/index.js`;
|
|
36
|
+
if (!isFoundational) {
|
|
37
|
+
this.module.imports.addSideEffect(path);
|
|
38
|
+
}
|
|
39
|
+
this.module.imports.addNamespace(path, namespaceName);
|
|
40
|
+
return namespaceName;
|
|
41
|
+
}
|
|
42
|
+
qualify(namespaceName, typeName) {
|
|
43
|
+
if (namespaceName === this.namespace.name) {
|
|
44
|
+
return typeName;
|
|
45
|
+
}
|
|
46
|
+
return `${this.addCrossNamespaceImport(namespaceName)}.${typeName}`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export { ModuleContext };
|
|
50
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","s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AAS,KAAK,SAAS,IAAI,SAAS,KAAK,MAAM,CAAC;QACvE,MAAM,IAAI,GAAG,cAAc,CAAC,CAAC,CAAC,MAAM,SAAS,IAAI,SAAS,KAAK,CAAC,CAAC,CAAC,MAAM,SAAS,WAAW,CAAC;QAE7F,IAAI,CAAC,cAAc,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAEtD,OAAO,aAAa,CAAC;IACzB,CAAC;IAED,OAAO,CAAC,aAAqB,EAAE,QAAgB;QAC3C,IAAI,aAAa,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YACxC,OAAO,QAAQ,CAAC;QACpB,CAAC;QAED,OAAO,GAAG,IAAI,CAAC,uBAAuB,CAAC,aAAa,CAAC,IAAI,QAAQ,EAAE,CAAC;IACxE,CAAC;CACJ;AAED,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import type { Library } from \"../gir/library.js\";\nimport type { GirNamespace } from \"../gir/namespace.js\";\nimport { ModuleBuilder } from \"./module.js\";\n\nclass ModuleContext {\n public module: ModuleBuilder = new ModuleBuilder();\n public namespace: GirNamespace;\n public library: Library;\n\n constructor(namespace: GirNamespace, library: Library) {\n this.namespace = namespace;\n this.library = library;\n }\n\n addRuntimeImport(name: string): void {\n this.module.imports.addNamed(\"@gtkx/runtime\", name);\n }\n\n addRuntimeTypeImport(name: string): void {\n this.module.imports.addNamed(\"@gtkx/runtime\", name, true);\n }\n\n hoistDescriptor(expression: string): string {\n return this.module.hoistDescriptor(expression);\n }\n\n addGObjectBootstrapImports(): void {\n if (this.namespace.name === \"GObject\") {\n return;\n }\n\n if (this.namespace.name === \"GLib\") {\n return;\n }\n\n this.module.imports.addSideEffect(\"../gobject/overrides/object.js\");\n this.module.imports.addSideEffect(\"../gobject/overrides/value.js\");\n }\n\n addCrossNamespaceImport(namespaceName: string): string {\n if (namespaceName === this.namespace.name) {\n return namespaceName;\n }\n\n const directory = namespaceName.toLowerCase();\n const isFoundational = directory === \"gobject\" || directory === \"glib\";\n const path = isFoundational ? `../${directory}/${directory}.js` : `../${directory}/index.js`;\n\n if (!isFoundational) {\n this.module.imports.addSideEffect(path);\n }\n\n this.module.imports.addNamespace(path, namespaceName);\n\n return namespaceName;\n }\n\n qualify(namespaceName: string, typeName: string): string {\n if (namespaceName === this.namespace.name) {\n return typeName;\n }\n\n return `${this.addCrossNamespaceImport(namespaceName)}.${typeName}`;\n }\n}\n\nexport { ModuleContext };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../src/writer/doc.ts"],"names":[],"mappings":"AAgBA,QAAA,MAAM,WAAW,GAAI,KAAK,MAAM,GAAG,SAAS,KAAG,MAM9C,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { gtkDocToMarkdown } from "./gtk-doc.js";
|
|
2
|
+
const escapeCommentTerminators = (doc) => doc.replaceAll("*/", String.raw `*\/`);
|
|
3
|
+
const renderJsDocLines = (lines) => {
|
|
4
|
+
const [single, ...rest] = lines;
|
|
5
|
+
if (single !== undefined && rest.length === 0) {
|
|
6
|
+
return `/** ${single} */\n`;
|
|
7
|
+
}
|
|
8
|
+
const body = lines.map((line) => (line.length === 0 ? " *" : ` * ${line}`)).join("\n");
|
|
9
|
+
return `/**\n${body}\n */\n`;
|
|
10
|
+
};
|
|
11
|
+
const renderJsDoc = (doc) => {
|
|
12
|
+
if (doc === undefined || doc.length === 0) {
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
return renderJsDocLines(escapeCommentTerminators(gtkDocToMarkdown(doc)).split("\n"));
|
|
16
|
+
};
|
|
17
|
+
export { renderJsDoc };
|
|
18
|
+
//# sourceMappingURL=doc.js.map
|