@gtkx/codegen 1.0.0-rc.3 → 1.0.0
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 +8 -9
- package/dist/analysis/descriptor-render.d.ts +9 -4
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +51 -61
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +7 -7
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js +7 -7
- package/dist/analysis/descriptor.js.map +1 -1
- package/dist/analysis/inheritance.d.ts +1 -2
- package/dist/analysis/inheritance.d.ts.map +1 -1
- package/dist/analysis/inheritance.js +25 -22
- package/dist/analysis/inheritance.js.map +1 -1
- package/dist/analysis/nul-terminated-bytes.d.ts +5 -0
- package/dist/analysis/nul-terminated-bytes.d.ts.map +1 -0
- package/dist/analysis/nul-terminated-bytes.js +18 -0
- package/dist/analysis/nul-terminated-bytes.js.map +1 -0
- package/dist/analysis/param-capability.d.ts +5 -0
- package/dist/analysis/param-capability.d.ts.map +1 -0
- package/dist/analysis/param-capability.js +130 -0
- package/dist/analysis/param-capability.js.map +1 -0
- package/dist/analysis/param-structure.d.ts +13 -6
- package/dist/analysis/param-structure.d.ts.map +1 -1
- package/dist/analysis/param-structure.js +44 -20
- package/dist/analysis/param-structure.js.map +1 -1
- package/dist/analysis/ts-type.d.ts +1 -1
- package/dist/analysis/ts-type.d.ts.map +1 -1
- package/dist/analysis/ts-type.js +3 -5
- package/dist/analysis/ts-type.js.map +1 -1
- package/dist/analysis/type-shape.d.ts +8 -0
- package/dist/analysis/type-shape.d.ts.map +1 -0
- package/dist/analysis/type-shape.js +12 -0
- package/dist/analysis/type-shape.js.map +1 -0
- package/dist/compile.d.ts +1 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +2 -1
- package/dist/compile.js.map +1 -1
- package/dist/docs/api-reference.d.ts +79 -3
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +68 -13
- package/dist/docs/api-reference.js.map +1 -1
- package/dist/docs/element-page.d.ts +4 -4
- package/dist/docs/element-page.d.ts.map +1 -1
- package/dist/docs/element-page.js +32 -20
- package/dist/docs/element-page.js.map +1 -1
- package/dist/docs/handwritten-props.d.ts +9 -0
- package/dist/docs/handwritten-props.d.ts.map +1 -0
- package/dist/docs/handwritten-props.js +149 -0
- package/dist/docs/handwritten-props.js.map +1 -0
- package/dist/docs/pipeline.d.ts +4 -4
- package/dist/docs/pipeline.d.ts.map +1 -1
- package/dist/docs/pipeline.js +6 -6
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/docs/render.d.ts +25 -5
- package/dist/docs/render.d.ts.map +1 -1
- package/dist/docs/render.js +90 -28
- package/dist/docs/render.js.map +1 -1
- package/dist/docs/symbol-page.d.ts +22 -0
- package/dist/docs/symbol-page.d.ts.map +1 -1
- package/dist/docs/symbol-page.js +129 -44
- package/dist/docs/symbol-page.js.map +1 -1
- package/dist/fingerprint.d.ts +3 -6
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +6 -8
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts +3 -11
- package/dist/gi.d.ts.map +1 -1
- package/dist/gi.js +0 -7
- package/dist/gi.js.map +1 -1
- package/dist/gir/ancestry.d.ts +2 -2
- package/dist/gir/ancestry.d.ts.map +1 -1
- package/dist/gir/ancestry.js +11 -1
- package/dist/gir/ancestry.js.map +1 -1
- package/dist/gir/annotations.d.ts +22 -0
- package/dist/gir/annotations.d.ts.map +1 -0
- package/dist/gir/annotations.js +15 -0
- package/dist/gir/annotations.js.map +1 -0
- package/dist/gir/callback.d.ts +1 -0
- package/dist/gir/callback.d.ts.map +1 -1
- package/dist/gir/callback.js +1 -0
- package/dist/gir/callback.js.map +1 -1
- package/dist/gir/class.d.ts +32 -1
- package/dist/gir/class.d.ts.map +1 -1
- package/dist/gir/class.js +8 -3
- package/dist/gir/class.js.map +1 -1
- package/dist/gir/enum.d.ts +21 -1
- package/dist/gir/enum.d.ts.map +1 -1
- package/dist/gir/enum.js +9 -9
- package/dist/gir/enum.js.map +1 -1
- package/dist/gir/field.d.ts +19 -4
- package/dist/gir/field.d.ts.map +1 -1
- package/dist/gir/field.js +7 -11
- package/dist/gir/field.js.map +1 -1
- package/dist/gir/function.d.ts +15 -0
- package/dist/gir/function.d.ts.map +1 -1
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/gir-path.d.ts +7 -0
- package/dist/gir/gir-path.d.ts.map +1 -1
- package/dist/gir/gir-path.js +7 -0
- package/dist/gir/gir-path.js.map +1 -1
- package/dist/gir/libraries.d.ts +13 -2
- package/dist/gir/libraries.d.ts.map +1 -1
- package/dist/gir/libraries.js +11 -0
- package/dist/gir/libraries.js.map +1 -1
- package/dist/gir/library.d.ts +36 -0
- package/dist/gir/library.d.ts.map +1 -1
- package/dist/gir/library.js +34 -0
- package/dist/gir/library.js.map +1 -1
- package/dist/gir/namespace.d.ts +38 -0
- package/dist/gir/namespace.d.ts.map +1 -1
- package/dist/gir/namespace.js +4 -5
- package/dist/gir/namespace.js.map +1 -1
- package/dist/gir/parameter.d.ts +39 -0
- package/dist/gir/parameter.d.ts.map +1 -1
- package/dist/gir/parameter.js +7 -7
- package/dist/gir/parameter.js.map +1 -1
- package/dist/gir/parse.d.ts +3 -1
- package/dist/gir/parse.d.ts.map +1 -1
- package/dist/gir/parse.js +6 -3
- package/dist/gir/parse.js.map +1 -1
- package/dist/gir/primitives.d.ts +1 -0
- package/dist/gir/primitives.d.ts.map +1 -1
- package/dist/gir/primitives.js.map +1 -1
- package/dist/gir/property.d.ts +16 -0
- package/dist/gir/property.d.ts.map +1 -1
- package/dist/gir/property.js +3 -3
- package/dist/gir/property.js.map +1 -1
- package/dist/gir/record.d.ts +22 -0
- package/dist/gir/record.d.ts.map +1 -1
- package/dist/gir/record.js +3 -2
- package/dist/gir/record.js.map +1 -1
- package/dist/gir/size.d.ts +5 -4
- package/dist/gir/size.d.ts.map +1 -1
- package/dist/gir/size.js +0 -3
- package/dist/gir/size.js.map +1 -1
- package/dist/gir/type-id.d.ts +36 -1
- package/dist/gir/type-id.d.ts.map +1 -1
- package/dist/gir/type-id.js +2 -3
- package/dist/gir/type-id.js.map +1 -1
- package/dist/gir/type-ref.d.ts.map +1 -1
- package/dist/gir/type-ref.js +2 -1
- package/dist/gir/type-ref.js.map +1 -1
- package/dist/gir/type.d.ts +20 -0
- package/dist/gir/type.d.ts.map +1 -1
- package/dist/gir/type.js.map +1 -1
- package/dist/index.d.ts +18 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +3 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +3 -0
- package/dist/internal.js.map +1 -0
- package/dist/jsx.d.ts +7 -12
- package/dist/jsx.d.ts.map +1 -1
- package/dist/jsx.js +18 -19
- package/dist/jsx.js.map +1 -1
- package/dist/khronos/args.d.ts +7 -6
- package/dist/khronos/args.d.ts.map +1 -1
- package/dist/khronos/args.js +29 -7
- package/dist/khronos/args.js.map +1 -1
- package/dist/khronos/doc-context.d.ts +29 -0
- package/dist/khronos/doc-context.d.ts.map +1 -0
- package/dist/khronos/doc-context.js +29 -0
- package/dist/khronos/doc-context.js.map +1 -0
- package/dist/khronos/extensions.d.ts +13 -0
- package/dist/khronos/extensions.d.ts.map +1 -0
- package/dist/khronos/extensions.js +49 -0
- package/dist/khronos/extensions.js.map +1 -0
- package/dist/khronos/jsdoc.d.ts +17 -11
- package/dist/khronos/jsdoc.d.ts.map +1 -1
- package/dist/khronos/jsdoc.js +104 -46
- package/dist/khronos/jsdoc.js.map +1 -1
- package/dist/khronos/model.d.ts +42 -3
- package/dist/khronos/model.d.ts.map +1 -1
- package/dist/khronos/model.js +218 -63
- package/dist/khronos/model.js.map +1 -1
- package/dist/khronos/modules.d.ts +9 -6
- package/dist/khronos/modules.d.ts.map +1 -1
- package/dist/khronos/modules.js +96 -26
- package/dist/khronos/modules.js.map +1 -1
- package/dist/khronos/notes.d.ts +19 -0
- package/dist/khronos/notes.d.ts.map +1 -0
- package/dist/khronos/notes.js +35 -0
- package/dist/khronos/notes.js.map +1 -0
- package/dist/khronos/param-pair.d.ts +1 -1
- package/dist/khronos/param-pair.d.ts.map +1 -1
- package/dist/khronos/param-pair.js.map +1 -1
- package/dist/khronos/pipeline.d.ts +3 -1
- package/dist/khronos/pipeline.d.ts.map +1 -1
- package/dist/khronos/pipeline.js +59 -28
- package/dist/khronos/pipeline.js.map +1 -1
- package/dist/khronos/plan.d.ts +5 -5
- package/dist/khronos/plan.d.ts.map +1 -1
- package/dist/khronos/plan.js +8 -8
- package/dist/khronos/plan.js.map +1 -1
- package/dist/khronos/render.d.ts +8 -6
- package/dist/khronos/render.d.ts.map +1 -1
- package/dist/khronos/render.js +35 -26
- package/dist/khronos/render.js.map +1 -1
- package/dist/khronos/select.d.ts +21 -4
- package/dist/khronos/select.d.ts.map +1 -1
- package/dist/khronos/select.js +47 -34
- package/dist/khronos/select.js.map +1 -1
- package/dist/react/element-config.d.ts +16 -10
- package/dist/react/element-config.d.ts.map +1 -1
- package/dist/react/element-config.js +22 -15
- package/dist/react/element-config.js.map +1 -1
- package/dist/runner.d.ts +33 -21
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +19 -20
- package/dist/runner.js.map +1 -1
- package/dist/store/compile-store.d.ts +2 -3
- package/dist/store/compile-store.d.ts.map +1 -1
- package/dist/store/compile-store.js +2 -2
- package/dist/store/compile-store.js.map +1 -1
- package/dist/store/gi/callable-doc.d.ts +11 -0
- package/dist/store/gi/callable-doc.d.ts.map +1 -0
- package/dist/store/gi/callable-doc.js +62 -0
- package/dist/store/gi/callable-doc.js.map +1 -0
- package/dist/store/gi/callables.d.ts +3 -1
- package/dist/store/gi/callables.d.ts.map +1 -1
- package/dist/store/gi/callables.js +16 -16
- package/dist/store/gi/callables.js.map +1 -1
- package/dist/store/gi/callback.d.ts.map +1 -1
- package/dist/store/gi/callback.js +2 -2
- package/dist/store/gi/callback.js.map +1 -1
- package/dist/store/gi/class.d.ts.map +1 -1
- package/dist/store/gi/class.js +5 -3
- package/dist/store/gi/class.js.map +1 -1
- package/dist/store/gi/closure-invocation.d.ts +4 -0
- package/dist/store/gi/closure-invocation.d.ts.map +1 -0
- package/dist/store/gi/closure-invocation.js +22 -0
- package/dist/store/gi/closure-invocation.js.map +1 -0
- package/dist/store/gi/constant.d.ts.map +1 -1
- package/dist/store/gi/constant.js +3 -4
- package/dist/store/gi/constant.js.map +1 -1
- package/dist/store/gi/constructor-props.d.ts.map +1 -1
- package/dist/store/gi/constructor-props.js +18 -20
- package/dist/store/gi/constructor-props.js.map +1 -1
- package/dist/store/gi/doc-spec.d.ts +14 -0
- package/dist/store/gi/doc-spec.d.ts.map +1 -0
- package/dist/store/gi/doc-spec.js +23 -0
- package/dist/store/gi/doc-spec.js.map +1 -0
- package/dist/store/gi/enum.d.ts.map +1 -1
- package/dist/store/gi/enum.js +29 -16
- package/dist/store/gi/enum.js.map +1 -1
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +28 -17
- package/dist/store/gi/function.js.map +1 -1
- package/dist/store/gi/interface.d.ts.map +1 -1
- package/dist/store/gi/interface.js +130 -16
- package/dist/store/gi/interface.js.map +1 -1
- package/dist/store/gi/item-comparators.d.ts.map +1 -1
- package/dist/store/gi/item-comparators.js +3 -5
- package/dist/store/gi/item-comparators.js.map +1 -1
- package/dist/store/gi/method.d.ts +9 -1
- package/dist/store/gi/method.d.ts.map +1 -1
- package/dist/store/gi/method.js +92 -47
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/param-marshal.d.ts +4 -1
- package/dist/store/gi/param-marshal.d.ts.map +1 -1
- package/dist/store/gi/param-marshal.js +5 -1
- package/dist/store/gi/param-marshal.js.map +1 -1
- package/dist/store/gi/pipeline.d.ts.map +1 -1
- package/dist/store/gi/pipeline.js +3 -2
- package/dist/store/gi/pipeline.js.map +1 -1
- package/dist/store/gi/properties.d.ts.map +1 -1
- package/dist/store/gi/properties.js +2 -2
- package/dist/store/gi/properties.js.map +1 -1
- package/dist/store/gi/property-accessor.d.ts +4 -2
- package/dist/store/gi/property-accessor.d.ts.map +1 -1
- package/dist/store/gi/property-accessor.js +10 -11
- package/dist/store/gi/property-accessor.js.map +1 -1
- package/dist/store/gi/record-constructor.d.ts.map +1 -1
- package/dist/store/gi/record-constructor.js +3 -1
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +4 -2
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +6 -11
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record-layout.d.ts.map +1 -1
- package/dist/store/gi/record-layout.js +1 -5
- package/dist/store/gi/record-layout.js.map +1 -1
- package/dist/store/gi/record.d.ts.map +1 -1
- package/dist/store/gi/record.js +3 -2
- package/dist/store/gi/record.js.map +1 -1
- package/dist/store/gi/registration.d.ts +1 -1
- package/dist/store/gi/registration.js +2 -2
- package/dist/store/gi/registration.js.map +1 -1
- package/dist/store/gi/return-wrap.d.ts +1 -1
- package/dist/store/gi/return-wrap.d.ts.map +1 -1
- package/dist/store/gi/return-wrap.js +4 -4
- package/dist/store/gi/return-wrap.js.map +1 -1
- package/dist/store/gi/runtime-override.d.ts +2 -1
- package/dist/store/gi/runtime-override.d.ts.map +1 -1
- package/dist/store/gi/runtime-override.js +8 -5
- package/dist/store/gi/runtime-override.js.map +1 -1
- package/dist/store/gi/signal.d.ts.map +1 -1
- package/dist/store/gi/signal.js +27 -31
- package/dist/store/gi/signal.js.map +1 -1
- package/dist/store/gi/value-marshalable.d.ts +1 -10
- package/dist/store/gi/value-marshalable.d.ts.map +1 -1
- package/dist/store/gi/value-marshalable.js +1 -10
- package/dist/store/gi/value-marshalable.js.map +1 -1
- package/dist/store/gi/vtable.d.ts +16 -1
- package/dist/store/gi/vtable.d.ts.map +1 -1
- package/dist/store/gi/vtable.js +214 -51
- package/dist/store/gi/vtable.js.map +1 -1
- package/dist/store/gi-store.d.ts +2 -3
- package/dist/store/gi-store.d.ts.map +1 -1
- package/dist/store/gi-store.js.map +1 -1
- package/dist/store/jsx/element-components.d.ts +1 -3
- package/dist/store/jsx/element-components.d.ts.map +1 -1
- package/dist/store/jsx/element-components.js +6 -8
- package/dist/store/jsx/element-components.js.map +1 -1
- package/dist/store/jsx/element-prop-imports.d.ts +1 -4
- package/dist/store/jsx/element-prop-imports.d.ts.map +1 -1
- package/dist/store/jsx/element-prop-imports.js +0 -2
- package/dist/store/jsx/element-prop-imports.js.map +1 -1
- package/dist/store/jsx/element-prop-types.d.ts +3 -1
- package/dist/store/jsx/element-prop-types.d.ts.map +1 -1
- package/dist/store/jsx/element-prop-types.js +7 -2
- package/dist/store/jsx/element-prop-types.js.map +1 -1
- package/dist/store/jsx/generated-elements.d.ts +29 -0
- package/dist/store/jsx/generated-elements.d.ts.map +1 -0
- package/dist/store/jsx/generated-elements.js +30 -0
- package/dist/store/jsx/generated-elements.js.map +1 -0
- package/dist/store/jsx/intrinsic-elements.d.ts +4 -0
- package/dist/store/jsx/intrinsic-elements.d.ts.map +1 -1
- package/dist/store/jsx/intrinsic-elements.js.map +1 -1
- package/dist/store/jsx/jsx.d.ts.map +1 -1
- package/dist/store/jsx/jsx.js +13 -12
- package/dist/store/jsx/jsx.js.map +1 -1
- package/dist/store/jsx/metadata.js +9 -9
- package/dist/store/jsx/metadata.js.map +1 -1
- package/dist/store/jsx/omitted-props.d.ts +2 -4
- package/dist/store/jsx/omitted-props.d.ts.map +1 -1
- package/dist/store/jsx/omitted-props.js +2 -4
- package/dist/store/jsx/omitted-props.js.map +1 -1
- package/dist/store/jsx/pipeline.d.ts +4 -2
- package/dist/store/jsx/pipeline.d.ts.map +1 -1
- package/dist/store/jsx/pipeline.js +3 -2
- package/dist/store/jsx/pipeline.js.map +1 -1
- package/dist/store/jsx/props.d.ts +1 -7
- package/dist/store/jsx/props.d.ts.map +1 -1
- package/dist/store/jsx/props.js +16 -8
- package/dist/store/jsx/props.js.map +1 -1
- package/dist/store/jsx-store.d.ts +2 -3
- package/dist/store/jsx-store.d.ts.map +1 -1
- package/dist/store/jsx-store.js +3 -3
- package/dist/store/jsx-store.js.map +1 -1
- package/dist/store/resolve-store.d.ts +28 -0
- package/dist/store/resolve-store.d.ts.map +1 -0
- package/dist/store/resolve-store.js +65 -0
- package/dist/store/resolve-store.js.map +1 -0
- package/dist/store/store-fs.d.ts +5 -1
- package/dist/store/store-fs.d.ts.map +1 -1
- package/dist/store/store-fs.js +6 -4
- package/dist/store/store-fs.js.map +1 -1
- package/dist/writer/context.d.ts +2 -1
- package/dist/writer/context.d.ts.map +1 -1
- package/dist/writer/context.js +3 -0
- package/dist/writer/context.js.map +1 -1
- package/dist/writer/doc-tags.d.ts +21 -0
- package/dist/writer/doc-tags.d.ts.map +1 -0
- package/dist/writer/doc-tags.js +38 -0
- package/dist/writer/doc-tags.js.map +1 -0
- package/dist/writer/doc.d.ts +3 -1
- package/dist/writer/doc.d.ts.map +1 -1
- package/dist/writer/doc.js +19 -6
- package/dist/writer/doc.js.map +1 -1
- package/dist/writer/gtk-doc.d.ts +1 -1
- package/dist/writer/gtk-doc.d.ts.map +1 -1
- package/dist/writer/gtk-doc.js +64 -15
- package/dist/writer/gtk-doc.js.map +1 -1
- package/dist/writer/module.d.ts +8 -2
- package/dist/writer/module.d.ts.map +1 -1
- package/dist/writer/module.js +13 -1
- package/dist/writer/module.js.map +1 -1
- package/overrides/gdk/rgba.ts.ejs +26 -0
- package/overrides/gobject/object.ts.ejs +56 -11
- package/overrides/gobject/value.ts.ejs +7 -0
- package/overrides/graphene/structs.ts.ejs +55 -0
- package/package.json +7 -11
- package/src/analysis/descriptor-render.ts +67 -73
- package/src/analysis/descriptor.ts +13 -16
- package/src/analysis/inheritance.ts +35 -34
- package/src/analysis/nul-terminated-bytes.ts +31 -0
- package/src/analysis/param-capability.ts +172 -0
- package/src/analysis/param-structure.ts +90 -32
- package/src/analysis/ts-type.ts +4 -6
- package/src/analysis/type-shape.ts +24 -0
- package/src/compile.ts +3 -2
- package/src/docs/api-reference.ts +162 -28
- package/src/docs/element-page.ts +53 -47
- package/src/docs/handwritten-props.ts +230 -0
- package/src/docs/pipeline.ts +10 -10
- package/src/docs/render.ts +153 -39
- package/src/docs/symbol-page.ts +230 -80
- package/src/fingerprint.ts +8 -14
- package/src/gi.ts +4 -11
- package/src/gir/ancestry.ts +15 -1
- package/src/gir/annotations.ts +37 -0
- package/src/gir/callback.ts +2 -0
- package/src/gir/class.ts +42 -4
- package/src/gir/enum.ts +30 -10
- package/src/gir/field.ts +24 -13
- package/src/gir/function.ts +15 -0
- package/src/gir/gir-path.ts +7 -0
- package/src/gir/libraries.ts +23 -2
- package/src/gir/library.ts +51 -2
- package/src/gir/namespace.ts +41 -5
- package/src/gir/parameter.ts +47 -7
- package/src/gir/parse.ts +8 -2
- package/src/gir/primitives.ts +1 -0
- package/src/gir/property.ts +18 -3
- package/src/gir/record.ts +24 -2
- package/src/gir/size.ts +8 -6
- package/src/gir/type-id.ts +51 -7
- package/src/gir/type-ref.ts +2 -1
- package/src/gir/type.ts +50 -6
- package/src/index.ts +18 -16
- package/src/internal.ts +2 -0
- package/src/jsx.ts +26 -26
- package/src/khronos/args.ts +37 -14
- package/src/khronos/doc-context.ts +62 -0
- package/src/khronos/extensions.ts +85 -0
- package/src/khronos/jsdoc.ts +152 -56
- package/src/khronos/model.ts +314 -69
- package/src/khronos/modules.ts +134 -40
- package/src/khronos/notes.ts +74 -0
- package/src/khronos/param-pair.ts +1 -1
- package/src/khronos/pipeline.ts +95 -42
- package/src/khronos/plan.ts +12 -13
- package/src/khronos/render.ts +62 -50
- package/src/khronos/select.ts +91 -50
- package/src/react/element-config.ts +21 -18
- package/src/runner.ts +51 -40
- package/src/store/compile-store.ts +4 -5
- package/src/store/gi/callable-doc.ts +102 -0
- package/src/store/gi/callables.ts +23 -17
- package/src/store/gi/callback.ts +3 -2
- package/src/store/gi/class.ts +6 -3
- package/src/store/gi/closure-invocation.ts +26 -0
- package/src/store/gi/constant.ts +3 -6
- package/src/store/gi/constructor-props.ts +19 -23
- package/src/store/gi/doc-spec.ts +38 -0
- package/src/store/gi/enum.ts +55 -20
- package/src/store/gi/function.ts +44 -26
- package/src/store/gi/interface.ts +214 -26
- package/src/store/gi/item-comparators.ts +3 -5
- package/src/store/gi/method.ts +126 -68
- package/src/store/gi/param-marshal.ts +15 -1
- package/src/store/gi/pipeline.ts +7 -2
- package/src/store/gi/properties.ts +3 -2
- package/src/store/gi/property-accessor.ts +14 -11
- package/src/store/gi/record-constructor.ts +6 -1
- package/src/store/gi/record-field-accessor.ts +9 -13
- package/src/store/gi/record-layout.ts +1 -5
- package/src/store/gi/record.ts +8 -2
- package/src/store/gi/registration.ts +3 -3
- package/src/store/gi/return-wrap.ts +5 -5
- package/src/store/gi/runtime-override.ts +13 -6
- package/src/store/gi/signal.ts +36 -37
- package/src/store/gi/value-marshalable.ts +1 -10
- package/src/store/gi/vtable.ts +361 -60
- package/src/store/gi-store.ts +2 -4
- package/src/store/jsx/element-components.ts +8 -11
- package/src/store/jsx/element-prop-imports.ts +6 -5
- package/src/store/jsx/element-prop-types.ts +10 -2
- package/src/store/jsx/generated-elements.ts +60 -0
- package/src/store/jsx/intrinsic-elements.ts +4 -0
- package/src/store/jsx/jsx.ts +15 -13
- package/src/store/jsx/metadata.ts +10 -10
- package/src/store/jsx/omitted-props.ts +2 -4
- package/src/store/jsx/pipeline.ts +6 -4
- package/src/store/jsx/props.ts +22 -9
- package/src/store/jsx-store.ts +5 -7
- package/src/store/resolve-store.ts +100 -0
- package/src/store/store-fs.ts +12 -5
- package/src/writer/context.ts +5 -1
- package/src/writer/doc-tags.ts +70 -0
- package/src/writer/doc.ts +29 -6
- package/src/writer/gtk-doc.ts +82 -15
- package/src/writer/module.ts +25 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/khronos/select.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/khronos/select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA+C5C,MAAM,iBAAiB,GAAG,CAAC,KAAuB,EAAE,SAAsB,EAAW,EAAE,CACnF,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,OAAO,CAAC;IACpE,CAAC,KAAK,CAAC,GAAG,KAAK,SAAS,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS,CAAC,GAAG,CAAC,CAAC;AAE7D,MAAM,SAAS,GAAG,CAAC,KAAqB,EAAE,IAAkB,EAAmC,EAAE,CAC7F,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;AAEtD,MAAM,YAAY,GAAG,CAAC,OAA2B,EAAwB,EAAE,CACvE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;AAE7C,MAAM,aAAa,GAAG,CAAC,KAAqB,EAAE,IAAY,EAAE,OAAsB,EAAQ,EAAE;IACxF,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACnB,OAAO;IACX,CAAC;IAED,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEnC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE;QACb,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,I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5C,CAAC;IAED,OAAO;QACH,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;KAC/D,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,QAAoB,EAAE,IAAY,EAAE,GAAW,EAAU,EAAE;IAC5E,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAC7B,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,KAAK,SAAS,IAAI,SAAS,CAAC,GAAG,KAAK,GAAG,CAAC,CACnG,CAAC;IAEF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,oCAAoC,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,WAAW,EAA4E,CAAC","sourcesContent":["import { sortStringsBy } from \"@gtkx/utils\";\nimport type { GlEnum, GlFeature, GlInterfaceBlock, GlRegistry } from \"./model.js\";\n\ntype GlProfile = \"core\";\n\ntype GlSelection = {\n api: string;\n version: number;\n profile: GlProfile;\n};\n\ntype GlSymbolKind = \"command\" | \"enum\";\n\ntype GlRemoval = {\n feature: string;\n comment?: string;\n};\n\ntype GlSymbolProvenance = {\n feature: string;\n requireComment?: string;\n removals: GlRemoval[];\n};\n\ntype GlRemovedSymbol = {\n name: string;\n kind: GlSymbolKind;\n feature: string;\n comment?: string;\n};\n\ntype GlSubset = {\n commands: Map<string, GlSymbolProvenance>;\n enums: Map<string, GlSymbolProvenance>;\n removed: GlRemovedSymbol[];\n};\n\ntype SelectionState = GlSubset & {\n history: Map<string, GlRemoval[]>;\n};\n\ntype MemberContext = {\n feature: GlFeature;\n block: GlInterfaceBlock;\n kind: GlSymbolKind;\n};\n\nconst isBlockApplicable = (block: GlInterfaceBlock, selection: GlSelection): boolean =>\n (block.profile === undefined || block.profile === selection.profile) &&\n (block.api === undefined || block.api === selection.api);\n\nconst targetFor = (state: SelectionState, kind: GlSymbolKind): Map<string, GlSymbolProvenance> =>\n kind === \"command\" ? state.commands : state.enums;\n\nconst commentEntry = (comment: string | undefined): { comment?: string } =>\n comment === undefined ? {} : { comment };\n\nconst requireMember = (state: SelectionState, name: string, context: MemberContext): void => {\n const target = targetFor(state, context.kind);\n\n if (target.has(name)) {\n return;\n }\n\n const { block, feature } = context;\n\n target.set(name, {\n feature: feature.name,\n ...(block.comment !== undefined && { requireComment: block.comment }),\n removals: [...(state.history.get(name) ?? [])],\n });\n};\n\nconst removeMember = (state: SelectionState, name: string, context: MemberContext): void => {\n const { block, feature, kind } = context;\n const removal: GlRemoval = { feature: feature.name, ...commentEntry(block.comment) };\n targetFor(state, kind).delete(name);\n state.history.set(name, [...(state.history.get(name) ?? []), removal]);\n state.removed.push({ name, kind, ...removal });\n};\n\nconst applyMembers = (state: SelectionState, names: string[], context: MemberContext): void => {\n const apply = context.block.kind === \"require\" ? requireMember : removeMember;\n\n for (const name of names) {\n apply(state, name, context);\n }\n};\n\nconst applyBlock = (state: SelectionState, feature: GlFeature, block: GlInterfaceBlock): void => {\n applyMembers(state, block.commands, { feature, block, kind: \"command\" });\n applyMembers(state, block.enums, { feature, block, kind: \"enum\" });\n};\n\nconst applyFeature = (state: SelectionState, feature: GlFeature, selection: GlSelection): void => {\n for (const block of feature.blocks) {\n if (isBlockApplicable(block, selection)) {\n applyBlock(state, feature, block);\n }\n }\n};\n\nconst selectSubset = (registry: GlRegistry, selection: GlSelection): GlSubset => {\n const features = registry.features\n .filter((feature) => feature.api === selection.api && feature.number <= selection.version)\n .toSorted((a, b) => a.number - b.number);\n\n const state: SelectionState = {\n commands: new Map(),\n enums: new Map(),\n removed: [],\n history: new Map(),\n };\n\n for (const feature of features) {\n applyFeature(state, feature, selection);\n }\n\n return {\n commands: state.commands,\n enums: state.enums,\n removed: sortStringsBy(state.removed, (entry) => entry.name),\n };\n};\n\nconst resolveEnum = (registry: GlRegistry, name: string, api: string): GlEnum => {\n const found = registry.enums.find(\n (candidate) => candidate.name === name && (candidate.api === undefined || candidate.api === api),\n );\n\n if (found === undefined) {\n throw new Error(`Enum token ${name} has no definition in the registry`);\n }\n\n return found;\n};\n\nexport { selectSubset, resolveEnum, type GlRemoval, type GlSelection, type GlSubset, type GlSymbolProvenance };\n"]}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import type { ModuleExport } from "@gtkx/react/config";
|
|
2
2
|
import type { OmittedProps } from "../store/jsx/omitted-props.js";
|
|
3
|
-
/** The codegen-relevant subset of a React element config; behaviors are ignored at codegen time. */
|
|
4
|
-
type BuiltinElement = {
|
|
5
|
-
component?: ModuleExport;
|
|
6
|
-
lazy?: boolean;
|
|
7
|
-
props?: ModuleExport;
|
|
8
|
-
omitProps?: string[];
|
|
9
|
-
};
|
|
10
3
|
/** The framework's built-in element config, split into the maps codegen consumes. */
|
|
11
4
|
type BuiltinElements = {
|
|
5
|
+
/** Component wrappers keyed by GLib type name; an element without one inherits its nearest ancestor's. */
|
|
12
6
|
components: Record<string, ModuleExport>;
|
|
7
|
+
/** GLib type names with no GObject of their own, exported as elements that drop their construct-only props. */
|
|
13
8
|
lazyElements: string[];
|
|
9
|
+
/** Base props interfaces the generated element props extend, keyed by GLib type name. */
|
|
14
10
|
props: Record<string, ModuleExport>;
|
|
15
|
-
|
|
11
|
+
/** Props left out of the generated element props, keyed by GLib type name. */
|
|
12
|
+
omittedProps: OmittedProps;
|
|
16
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Reads the framework's built-in element config by importing the `config` entrypoints of the installed
|
|
16
|
+
* `@gtkx/react`, skipping the per-namespace ones whose namespace the gi store does not carry. Those
|
|
17
|
+
* entrypoints are reconciler-free, so importing them resolves `@gtkx/gi` but never `virtual:gtkx-config`,
|
|
18
|
+
* which means this must run only after the gi store has been written and linked.
|
|
19
|
+
*
|
|
20
|
+
* @param reactSubexports Subexport names of the installed `@gtkx/react`, as `resolveStore` reports them.
|
|
21
|
+
* @param giStoreDir The gi store directory, whose subdirectories name the generated namespaces.
|
|
22
|
+
*/
|
|
17
23
|
declare const readBuiltinElements: (reactSubexports: string[], giStoreDir: string) => Promise<BuiltinElements>;
|
|
18
|
-
export {
|
|
19
|
-
export { readBuiltinElements, type
|
|
24
|
+
export type { ModuleExport } from "@gtkx/react/config";
|
|
25
|
+
export { readBuiltinElements, type BuiltinElements };
|
|
20
26
|
//# sourceMappingURL=element-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-config.d.ts","sourceRoot":"","sources":["../../src/react/element-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"element-config.d.ts","sourceRoot":"","sources":["../../src/react/element-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAIlE,qFAAqF;AACrF,KAAK,eAAe,GAAG;IACnB,0GAA0G;IAC1G,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACzC,+GAA+G;IAC/G,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,yFAAyF;IACzF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACpC,8EAA8E;IAC9E,YAAY,EAAE,YAAY,CAAC;CAC9B,CAAC;AA6DF;;;;;;;;GAQG;AACH,QAAA,MAAM,mBAAmB,GAAU,iBAAiB,MAAM,EAAE,EAAE,YAAY,MAAM,KAAG,OAAO,CAAC,eAAe,CAUzG,CAAC;AAEF,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,CAAC"}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
1
9
|
import { readdirSync } from "node:fs";
|
|
2
10
|
const CONFIG_ENTRYPOINT = "config";
|
|
3
11
|
const CONFIG_SUFFIX = `/${CONFIG_ENTRYPOINT}`;
|
|
@@ -11,10 +19,6 @@ const presentNamespaceDirs = (giStoreDir) => {
|
|
|
11
19
|
}
|
|
12
20
|
return dirs;
|
|
13
21
|
};
|
|
14
|
-
/**
|
|
15
|
-
* The clean, reconciler-free `@gtkx/react` config entrypoints to import: the base `config` entry plus
|
|
16
|
-
* each namespace's `<ns>/config` entry whose GIR namespace is present in the gi store.
|
|
17
|
-
*/
|
|
18
22
|
const configEntrypoints = (reactSubexports, present) => reactSubexports.filter((sub) => {
|
|
19
23
|
if (sub === CONFIG_ENTRYPOINT) {
|
|
20
24
|
return true;
|
|
@@ -23,7 +27,7 @@ const configEntrypoints = (reactSubexports, present) => reactSubexports.filter((
|
|
|
23
27
|
});
|
|
24
28
|
const importBuiltinElements = async (entrypoint) => {
|
|
25
29
|
const specifier = `@gtkx/react/${entrypoint}`;
|
|
26
|
-
const imported = (await import(/* @vite-ignore */ specifier));
|
|
30
|
+
const imported = (await import(__rewriteRelativeImportExtension(/* @vite-ignore */ specifier)));
|
|
27
31
|
return imported.BUILTIN_ELEMENTS ?? {};
|
|
28
32
|
};
|
|
29
33
|
const applyBuiltinElement = (target, type, config) => {
|
|
@@ -33,32 +37,35 @@ const applyBuiltinElement = (target, type, config) => {
|
|
|
33
37
|
if (config.props !== undefined) {
|
|
34
38
|
target.props[type] = config.props;
|
|
35
39
|
}
|
|
36
|
-
if (config.
|
|
37
|
-
target.
|
|
40
|
+
if (config.omittedProps !== undefined) {
|
|
41
|
+
target.omittedProps[type] = [...(target.omittedProps[type] ?? []), ...config.omittedProps];
|
|
38
42
|
}
|
|
39
|
-
if (config.
|
|
43
|
+
if (config.isLazy === true) {
|
|
40
44
|
target.lazyElements.push(type);
|
|
41
45
|
}
|
|
42
46
|
};
|
|
43
|
-
/**
|
|
44
|
-
* Reads the framework's built-in element config by importing the freshly linked `@gtkx/react` config
|
|
45
|
-
* entrypoints. These are reconciler-free, so importing them resolves `@gtkx/gi` but never `virtual:gtkx-config`;
|
|
46
|
-
* it must run only after the gi store has been linked.
|
|
47
|
-
*/
|
|
48
47
|
const collectBuiltinElements = (target, elements) => {
|
|
49
48
|
for (const [type, config] of Object.entries(elements)) {
|
|
50
49
|
applyBuiltinElement(target, type, config);
|
|
51
50
|
}
|
|
52
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* Reads the framework's built-in element config by importing the `config` entrypoints of the installed
|
|
54
|
+
* `@gtkx/react`, skipping the per-namespace ones whose namespace the gi store does not carry. Those
|
|
55
|
+
* entrypoints are reconciler-free, so importing them resolves `@gtkx/gi` but never `virtual:gtkx-config`,
|
|
56
|
+
* which means this must run only after the gi store has been written and linked.
|
|
57
|
+
*
|
|
58
|
+
* @param reactSubexports Subexport names of the installed `@gtkx/react`, as `resolveStore` reports them.
|
|
59
|
+
* @param giStoreDir The gi store directory, whose subdirectories name the generated namespaces.
|
|
60
|
+
*/
|
|
53
61
|
const readBuiltinElements = async (reactSubexports, giStoreDir) => {
|
|
54
62
|
const present = presentNamespaceDirs(giStoreDir);
|
|
55
63
|
const entrypoints = configEntrypoints(reactSubexports, present);
|
|
56
|
-
const result = { components: {}, lazyElements: [], props: {},
|
|
64
|
+
const result = { components: {}, lazyElements: [], props: {}, omittedProps: {} };
|
|
57
65
|
for (const entrypoint of entrypoints) {
|
|
58
66
|
collectBuiltinElements(result, await importBuiltinElements(entrypoint));
|
|
59
67
|
}
|
|
60
68
|
return result;
|
|
61
69
|
};
|
|
62
|
-
export {} from "@gtkx/react/config";
|
|
63
70
|
export { readBuiltinElements };
|
|
64
71
|
//# sourceMappingURL=element-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-config.js","sourceRoot":"","sources":["../../src/react/element-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"element-config.js","sourceRoot":"","sources":["../../src/react/element-config.ts"],"names":[],"mappings":";;;;;;;;AACA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAiBtC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AACnC,MAAM,aAAa,GAAG,IAAI,iBAAiB,EAAE,CAAC;AAE9C,MAAM,oBAAoB,GAAG,CAAC,UAAkB,EAAe,EAAE;IAC7D,MAAM,IAAI,GAAgB,IAAI,GAAG,EAAE,CAAC;IACpC,MAAM,OAAO,GAAG,WAAW,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAEjE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC1B,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACtB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,iBAAiB,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C;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;QACzB,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,MAAuB,EAAE,QAAwC,EAAQ,EAAE;IACvG,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpD,mBAAmB,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;AACL,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,mBAAmB,GAAG,KAAK,EAAE,eAAyB,EAAE,UAAkB,EAA4B,EAAE;IAC1G,MAAM,OAAO,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,iBAAiB,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IAChE,MAAM,MAAM,GAAoB,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IAElG,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACnC,sBAAsB,CAAC,MAAM,EAAE,MAAM,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAGF,OAAO,EAAE,mBAAmB,EAAwB,CAAC","sourcesContent":["import type { ModuleExport } from \"@gtkx/react/config\";\nimport { readdirSync } from \"node:fs\";\nimport type { OmittedProps } from \"../store/jsx/omitted-props.js\";\n\ntype BuiltinElement = { component?: ModuleExport; isLazy?: boolean; props?: ModuleExport; omittedProps?: string[] };\n\n/** The framework's built-in element config, split into the maps codegen consumes. */\ntype BuiltinElements = {\n /** Component wrappers keyed by GLib type name; an element without one inherits its nearest ancestor's. */\n components: Record<string, ModuleExport>;\n /** GLib type names with no GObject of their own, exported as elements that drop their construct-only props. */\n lazyElements: string[];\n /** Base props interfaces the generated element props extend, keyed by GLib type name. */\n props: Record<string, ModuleExport>;\n /** Props left out of the generated element props, keyed by GLib type name. */\n omittedProps: OmittedProps;\n};\n\nconst CONFIG_ENTRYPOINT = \"config\";\nconst CONFIG_SUFFIX = `/${CONFIG_ENTRYPOINT}`;\n\nconst presentNamespaceDirs = (giStoreDir: string): Set<string> => {\n const dirs: Set<string> = new Set();\n const entries = readdirSync(giStoreDir, { withFileTypes: true });\n\n for (const entry of entries) {\n if (entry.isDirectory()) {\n dirs.add(entry.name);\n }\n }\n\n return dirs;\n};\n\nconst configEntrypoints = (reactSubexports: string[], present: Set<string>): string[] =>\n reactSubexports.filter((sub) => {\n if (sub === CONFIG_ENTRYPOINT) {\n return true;\n }\n\n return sub.endsWith(CONFIG_SUFFIX) && present.has(sub.slice(0, sub.length - CONFIG_SUFFIX.length));\n });\n\nconst importBuiltinElements = async (entrypoint: string): Promise<Record<string, BuiltinElement>> => {\n const specifier = `@gtkx/react/${entrypoint}`;\n\n const imported = (await import(/* @vite-ignore */ specifier)) as {\n BUILTIN_ELEMENTS?: Record<string, BuiltinElement>;\n };\n\n return imported.BUILTIN_ELEMENTS ?? {};\n};\n\nconst applyBuiltinElement = (target: BuiltinElements, type: string, config: BuiltinElement): void => {\n if (config.component !== undefined) {\n target.components[type] = config.component;\n }\n\n if (config.props !== undefined) {\n target.props[type] = config.props;\n }\n\n if (config.omittedProps !== undefined) {\n target.omittedProps[type] = [...(target.omittedProps[type] ?? []), ...config.omittedProps];\n }\n\n if (config.isLazy === true) {\n target.lazyElements.push(type);\n }\n};\n\nconst collectBuiltinElements = (target: BuiltinElements, elements: Record<string, BuiltinElement>): void => {\n for (const [type, config] of Object.entries(elements)) {\n applyBuiltinElement(target, type, config);\n }\n};\n\n/**\n * Reads the framework's built-in element config by importing the `config` entrypoints of the installed\n * `@gtkx/react`, skipping the per-namespace ones whose namespace the gi store does not carry. Those\n * entrypoints are reconciler-free, so importing them resolves `@gtkx/gi` but never `virtual:gtkx-config`,\n * which means this must run only after the gi store has been written and linked.\n *\n * @param reactSubexports Subexport names of the installed `@gtkx/react`, as `resolveStore` reports them.\n * @param giStoreDir The gi store directory, whose subdirectories name the generated namespaces.\n */\nconst readBuiltinElements = async (reactSubexports: string[], giStoreDir: string): Promise<BuiltinElements> => {\n const present = presentNamespaceDirs(giStoreDir);\n const entrypoints = configEntrypoints(reactSubexports, present);\n const result: BuiltinElements = { components: {}, lazyElements: [], props: {}, omittedProps: {} };\n\n for (const entrypoint of entrypoints) {\n collectBuiltinElements(result, await importBuiltinElements(entrypoint));\n }\n\n return result;\n};\n\nexport type { ModuleExport } from \"@gtkx/react/config\";\nexport { readBuiltinElements, type BuiltinElements };\n"]}
|
package/dist/runner.d.ts
CHANGED
|
@@ -1,46 +1,58 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { JsxStoreOptions } from "./store/jsx-store.js";
|
|
1
|
+
import type { ModuleExport } from "./react/element-config.js";
|
|
3
2
|
import type { OmittedProps } from "./store/jsx/omitted-props.js";
|
|
3
|
+
import type { StoreOptions } from "./store/store-fs.js";
|
|
4
4
|
import { type GlGenerationReport } from "./khronos/pipeline.js";
|
|
5
|
-
type ModuleExport = {
|
|
6
|
-
module: string;
|
|
7
|
-
export: string;
|
|
8
|
-
};
|
|
9
5
|
type GlCodegenOptions = {
|
|
10
6
|
registryPath: string;
|
|
11
7
|
overrideExports: Set<string>;
|
|
12
8
|
outputDir: string;
|
|
13
9
|
resolveFrom: string;
|
|
14
10
|
};
|
|
11
|
+
/** What to generate and where to write it. */
|
|
15
12
|
type CodegenRunnerOptions = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
/** GIR library identifiers such as `"Gtk-4.0"`; a `"*"` selection must be expanded before it gets here. */
|
|
14
|
+
libraries: string[];
|
|
15
|
+
/** Directories to search for `.gir` files. */
|
|
16
|
+
girPath: string[];
|
|
17
|
+
/** Where to write and link the `@gtkx/gi` store. */
|
|
18
|
+
gi: StoreOptions;
|
|
19
|
+
/** Where to write and link the `@gtkx/jsx` store; omit to generate the gi store alone. */
|
|
20
|
+
jsx?: StoreOptions | undefined;
|
|
21
|
+
/** Subexport names of the installed `@gtkx/react`, whose element config shapes the jsx store. */
|
|
20
22
|
reactSubexports?: string[];
|
|
23
|
+
/** Component wrappers the project layers over the built-ins, keyed by GLib type name. */
|
|
21
24
|
userComponents?: Record<string, ModuleExport>;
|
|
25
|
+
/** GLib type names whose GObject their parent container creates, added to the framework's own. */
|
|
22
26
|
userLazyElements?: string[];
|
|
27
|
+
/** Base props interfaces the project's elements extend, keyed by GLib type name. */
|
|
23
28
|
userProps?: Record<string, ModuleExport>;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
/** Props the project drops from the generated element props, keyed by GLib type name. */
|
|
30
|
+
userOmittedProps?: OmittedProps;
|
|
31
|
+
/** Regenerates both stores even when their fingerprints are fresh. */
|
|
32
|
+
isForced?: boolean;
|
|
27
33
|
};
|
|
34
|
+
/** What a `runCodegen` run produced. */
|
|
28
35
|
type CodegenRunnerResult = {
|
|
29
|
-
|
|
36
|
+
/** Whether either store was rewritten; false means both were already fresh. */
|
|
37
|
+
isRegenerated: boolean;
|
|
38
|
+
/** How many namespaces the gi store was written with, zero when it was already fresh. */
|
|
30
39
|
namespaces: number;
|
|
40
|
+
/** How many JSX elements the jsx store binds, zero when no jsx store was requested. */
|
|
31
41
|
intrinsicElements: number;
|
|
42
|
+
/** Wall-clock duration of the run, in milliseconds. */
|
|
32
43
|
duration: number;
|
|
33
|
-
gl?: GlGenerationReport | undefined;
|
|
34
44
|
};
|
|
35
45
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
46
|
+
* Writes and links a project's `@gtkx/gi` and `@gtkx/jsx` stores from the given GObject-Introspection
|
|
47
|
+
* libraries. The gi store is rewritten only when its GIR inputs changed, and the jsx store only when the gi
|
|
48
|
+
* store or the React element config changed, unless `options.isForced` is set. Pass the spread of
|
|
49
|
+
* `resolveStore(projectRoot)` for everything but `libraries` and `girPath`.
|
|
40
50
|
*
|
|
41
|
-
* @param options
|
|
51
|
+
* @param options What to generate and where to write it.
|
|
42
52
|
* @returns A summary of what was regenerated and how long the run took.
|
|
53
|
+
* @throws If `girPath` is empty, which would otherwise generate nothing and report success.
|
|
43
54
|
*/
|
|
44
55
|
declare const runCodegen: (options: CodegenRunnerOptions) => Promise<CodegenRunnerResult>;
|
|
45
|
-
|
|
56
|
+
declare const runGlCodegen: (options: GlCodegenOptions) => GlGenerationReport;
|
|
57
|
+
export { runCodegen, runGlCodegen, type CodegenRunnerOptions, type CodegenRunnerResult };
|
|
46
58
|
//# sourceMappingURL=runner.d.ts.map
|
package/dist/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAKxD,OAAO,EAAqB,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEnF,KAAK,gBAAgB,GAAG;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,8CAA8C;AAC9C,KAAK,oBAAoB,GAAG;IACxB,2GAA2G;IAC3G,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,oDAAoD;IACpD,EAAE,EAAE,YAAY,CAAC;IACjB,0FAA0F;IAC1F,GAAG,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IAC/B,iGAAiG;IACjG,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,yFAAyF;IACzF,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC9C,kGAAkG;IAClG,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACzC,yFAAyF;IACzF,gBAAgB,CAAC,EAAE,YAAY,CAAC;IAChC,sEAAsE;IACtE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,wCAAwC;AACxC,KAAK,mBAAmB,GAAG;IACvB,+EAA+E;IAC/E,aAAa,EAAE,OAAO,CAAC;IACvB,yFAAyF;IACzF,UAAU,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAQF;;;;;;;;;GASG;AACH,QAAA,MAAM,UAAU,GAAU,SAAS,oBAAoB,KAAG,OAAO,CAAC,mBAAmB,CAUpF,CAAC;AAEF,QAAA,MAAM,YAAY,GAAI,SAAS,gBAAgB,KAAG,kBAmBjD,CAAC;AA8EF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,CAAC"}
|
package/dist/runner.js
CHANGED
|
@@ -6,27 +6,26 @@ import { runGiCodegen } from "./gi.js";
|
|
|
6
6
|
import { Library } from "./gir/library.js";
|
|
7
7
|
import { generateGlModules } from "./khronos/pipeline.js";
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* Writes and links a project's `@gtkx/gi` and `@gtkx/jsx` stores from the given GObject-Introspection
|
|
10
|
+
* libraries. The gi store is rewritten only when its GIR inputs changed, and the jsx store only when the gi
|
|
11
|
+
* store or the React element config changed, unless `options.isForced` is set. Pass the spread of
|
|
12
|
+
* `resolveStore(projectRoot)` for everything but `libraries` and `girPath`.
|
|
13
13
|
*
|
|
14
|
-
* @param options
|
|
14
|
+
* @param options What to generate and where to write it.
|
|
15
15
|
* @returns A summary of what was regenerated and how long the run took.
|
|
16
|
+
* @throws If `girPath` is empty, which would otherwise generate nothing and report success.
|
|
16
17
|
*/
|
|
17
18
|
const runCodegen = async (options) => {
|
|
18
19
|
const start = Date.now();
|
|
19
|
-
const gl = options.gl === undefined ? undefined : emitGlModules(options.gl);
|
|
20
20
|
const store = await emitStores(options);
|
|
21
21
|
return {
|
|
22
|
-
|
|
22
|
+
isRegenerated: store.isRegenerated,
|
|
23
23
|
namespaces: store.namespaces,
|
|
24
24
|
intrinsicElements: store.intrinsicElements,
|
|
25
25
|
duration: Date.now() - start,
|
|
26
|
-
gl,
|
|
27
26
|
};
|
|
28
27
|
};
|
|
29
|
-
const
|
|
28
|
+
const runGlCodegen = (options) => {
|
|
30
29
|
const { files, report } = generateGlModules({
|
|
31
30
|
registryPath: options.registryPath,
|
|
32
31
|
overrideExports: options.overrideExports,
|
|
@@ -47,21 +46,21 @@ const jsxUserOptions = (options) => ({
|
|
|
47
46
|
userComponents: options.userComponents ?? {},
|
|
48
47
|
userLazyElements: options.userLazyElements ?? [],
|
|
49
48
|
userProps: options.userProps ?? {},
|
|
50
|
-
|
|
49
|
+
userOmittedProps: options.userOmittedProps ?? {},
|
|
51
50
|
});
|
|
52
51
|
const emitJsxStore = async (input) => {
|
|
53
|
-
const { options, jsx, gi, loadLibrary,
|
|
52
|
+
const { options, jsx, gi, loadLibrary, isGiRegenerated, namespaces } = input;
|
|
54
53
|
const { runJsxCodegen } = await import("./jsx.js");
|
|
55
54
|
const jsxResult = await runJsxCodegen({
|
|
56
55
|
getLibrary: loadLibrary,
|
|
57
56
|
jsx,
|
|
58
57
|
giStoreDir: gi.storeDir,
|
|
59
58
|
...jsxUserOptions(options),
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
isGiRegenerated,
|
|
60
|
+
isForced: options.isForced === true,
|
|
62
61
|
});
|
|
63
62
|
return {
|
|
64
|
-
|
|
63
|
+
isRegenerated: isGiRegenerated || jsxResult.isRegenerated,
|
|
65
64
|
namespaces,
|
|
66
65
|
intrinsicElements: jsxResult.intrinsicElementCount,
|
|
67
66
|
};
|
|
@@ -70,21 +69,21 @@ const emitStoresWithConfig = async (config) => {
|
|
|
70
69
|
const { options, gi, jsx, libraries, girPath } = config;
|
|
71
70
|
let library;
|
|
72
71
|
const loadLibrary = () => (library ??= Library.load(libraries, girPath));
|
|
73
|
-
const isGiRegenerated = options.
|
|
72
|
+
const isGiRegenerated = options.isForced === true || !isGiStoreFresh(gi.storeDir, libraries, girPath);
|
|
74
73
|
const namespaces = isGiRegenerated
|
|
75
74
|
? runGiCodegen(loadLibrary(), { gi, libraries, girPath })
|
|
76
75
|
: 0;
|
|
77
76
|
if (jsx === undefined) {
|
|
78
|
-
return {
|
|
77
|
+
return { isRegenerated: isGiRegenerated, namespaces, intrinsicElements: 0 };
|
|
79
78
|
}
|
|
80
|
-
return emitJsxStore({ options, jsx, gi, loadLibrary,
|
|
79
|
+
return emitJsxStore({ options, jsx, gi, loadLibrary, isGiRegenerated, namespaces });
|
|
81
80
|
};
|
|
82
81
|
const emitStores = async (options) => {
|
|
83
82
|
const { gi, jsx, libraries, girPath } = options;
|
|
84
|
-
if (
|
|
85
|
-
|
|
83
|
+
if (girPath.length === 0) {
|
|
84
|
+
throw new Error("codegen needs at least one GIR search path; pass the result of resolveGirPath");
|
|
86
85
|
}
|
|
87
86
|
return emitStoresWithConfig({ options, gi, jsx, libraries, girPath });
|
|
88
87
|
};
|
|
89
|
-
export { runCodegen };
|
|
88
|
+
export { runCodegen, runGlCodegen };
|
|
90
89
|
//# sourceMappingURL=runner.js.map
|
package/dist/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAA2B,MAAM,uBAAuB,CAAC;AAuCnF;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,OAA6B,EAAgC,EAAE;IACrF,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5E,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;IAExC,OAAO;QACH,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;QAC5B,EAAE;KACL,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,OAAyB,EAAsB,EAAE;IACpE,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a,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC,CAAC;AACvG,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,KAAK,EAAE,OAA6B,EAAwB,EAAE;IAC7E,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEhD,IAAI,EAAE,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACvE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,CAAC;IACvE,CAAC;IAED,OAAO,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAA8E,CAAC","sourcesContent":["import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { GiStoreOptions } from \"./store/gi-store.js\";\nimport type { JsxStoreOptions } from \"./store/jsx-store.js\";\nimport type { OmittedProps } from \"./store/jsx/omitted-props.js\";\nimport { checkModules } from \"./compile.js\";\nimport { isGiStoreFresh } from \"./fingerprint.js\";\nimport { runGiCodegen } from \"./gi.js\";\nimport { Library } from \"./gir/library.js\";\nimport { generateGlModules, type GlGenerationReport } from \"./khronos/pipeline.js\";\n\ntype ModuleExport = { module: string; export: string };\n\ntype GlCodegenOptions = {\n registryPath: string;\n overrideExports: Set<string>;\n outputDir: string;\n resolveFrom: string;\n};\n\ntype CodegenRunnerOptions = {\n libraries?: string[];\n girPath?: string[];\n gi?: GiStoreOptions;\n jsx?: JsxStoreOptions | undefined;\n reactSubexports?: string[];\n userComponents?: Record<string, ModuleExport>;\n userLazyElements?: string[];\n userProps?: Record<string, ModuleExport>;\n userOmitProps?: OmittedProps;\n gl?: GlCodegenOptions;\n force?: boolean;\n};\n\ntype CodegenRunnerResult = {\n regenerated: boolean;\n namespaces: number;\n intrinsicElements: number;\n duration: number;\n gl?: GlGenerationReport | undefined;\n};\n\ntype StoreResult = {\n regenerated: boolean;\n namespaces: number;\n intrinsicElements: number;\n};\n\n/**\n * Runs the `@gtkx` code generators, producing the `@gtkx/gi`, `@gtkx/jsx`, and `@gtkx/gl` bindings from the\n * configured GObject-introspection libraries and OpenGL registry. The gi store is regenerated only when its\n * fingerprint is stale unless `options.force` is set, then the jsx store is regenerated when the gi store or\n * the React element config changed; the OpenGL modules are regenerated whenever `options.gl` is provided.\n *\n * @param options - What to generate and where to write it.\n * @returns A summary of what was regenerated and how long the run took.\n */\nconst runCodegen = async (options: CodegenRunnerOptions): Promise<CodegenRunnerResult> => {\n const start = Date.now();\n const gl = options.gl === undefined ? undefined : emitGlModules(options.gl);\n const store = await emitStores(options);\n\n return {\n regenerated: store.regenerated,\n namespaces: store.namespaces,\n intrinsicElements: store.intrinsicElements,\n duration: Date.now() - start,\n gl,\n };\n};\n\nconst emitGlModules = (options: GlCodegenOptions): GlGenerationReport => {\n const { files, report } = generateGlModules({\n registryPath: options.registryPath,\n overrideExports: options.overrideExports,\n });\n\n checkModules({\n modules: [...files].map(([fileName, source]) => ({ fileName, source })),\n resolveFrom: options.resolveFrom,\n label: \"the generated gl modules\",\n });\n\n mkdirSync(options.outputDir, { recursive: true });\n\n for (const [fileName, source] of files) {\n writeFileSync(join(options.outputDir, fileName), source);\n }\n\n return report;\n};\n\nconst jsxUserOptions = (\n options: CodegenRunnerOptions,\n): {\n reactSubexports: string[];\n userComponents: Record<string, ModuleExport>;\n userLazyElements: string[];\n userProps: Record<string, ModuleExport>;\n userOmitProps: OmittedProps;\n} => ({\n reactSubexports: options.reactSubexports ?? [],\n userComponents: options.userComponents ?? {},\n userLazyElements: options.userLazyElements ?? [],\n userProps: options.userProps ?? {},\n userOmitProps: options.userOmitProps ?? {},\n});\n\nconst emitJsxStore = async (input: {\n options: CodegenRunnerOptions;\n jsx: JsxStoreOptions;\n gi: GiStoreOptions;\n loadLibrary: () => Library;\n giRegenerated: boolean;\n namespaces: number;\n}): Promise<StoreResult> => {\n const { options, jsx, gi, loadLibrary, giRegenerated, namespaces } = input;\n const { runJsxCodegen } = await import(\"./jsx.js\");\n\n const jsxResult = await runJsxCodegen({\n getLibrary: loadLibrary,\n jsx,\n giStoreDir: gi.storeDir,\n ...jsxUserOptions(options),\n giRegenerated,\n force: options.force === true,\n });\n\n return {\n regenerated: giRegenerated || jsxResult.regenerated,\n namespaces,\n intrinsicElements: jsxResult.intrinsicElementCount,\n };\n};\n\nconst emitStoresWithConfig = async (config: {\n options: CodegenRunnerOptions;\n gi: GiStoreOptions;\n jsx: JsxStoreOptions | undefined;\n libraries: string[];\n girPath: string[];\n}): Promise<StoreResult> => {\n const { options, gi, jsx, libraries, girPath } = config;\n let library: Library | undefined;\n const loadLibrary = (): Library => (library ??= Library.load(libraries, girPath));\n const isGiRegenerated = options.force === true || !isGiStoreFresh(gi.storeDir, libraries, girPath);\n\n const namespaces = isGiRegenerated\n ? runGiCodegen(loadLibrary(), { gi, libraries, girPath })\n : 0;\n\n if (jsx === undefined) {\n return { regenerated: isGiRegenerated, namespaces, intrinsicElements: 0 };\n }\n\n return emitJsxStore({ options, jsx, gi, loadLibrary, giRegenerated: isGiRegenerated, namespaces });\n};\n\nconst emitStores = async (options: CodegenRunnerOptions): Promise<StoreResult> => {\n const { gi, jsx, libraries, girPath } = options;\n\n if (gi === undefined || libraries === undefined || girPath === undefined) {\n return { regenerated: false, namespaces: 0, intrinsicElements: 0 };\n }\n\n return emitStoresWithConfig({ options, gi, jsx, libraries, girPath });\n};\n\nexport { runCodegen, type GlCodegenOptions, type CodegenRunnerOptions, type CodegenRunnerResult };\n"]}
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IA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sourcesContent":["import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { ModuleExport } from \"./react/element-config.js\";\nimport type { OmittedProps } from \"./store/jsx/omitted-props.js\";\nimport type { StoreOptions } from \"./store/store-fs.js\";\nimport { checkModules } from \"./compile.js\";\nimport { isGiStoreFresh } from \"./fingerprint.js\";\nimport { runGiCodegen } from \"./gi.js\";\nimport { Library } from \"./gir/library.js\";\nimport { generateGlModules, type GlGenerationReport } from \"./khronos/pipeline.js\";\n\ntype GlCodegenOptions = {\n registryPath: string;\n overrideExports: Set<string>;\n outputDir: string;\n resolveFrom: string;\n};\n\n/** What to generate and where to write it. */\ntype CodegenRunnerOptions = {\n /** GIR library identifiers such as `\"Gtk-4.0\"`; a `\"*\"` selection must be expanded before it gets here. */\n libraries: string[];\n /** Directories to search for `.gir` files. */\n girPath: string[];\n /** Where to write and link the `@gtkx/gi` store. */\n gi: StoreOptions;\n /** Where to write and link the `@gtkx/jsx` store; omit to generate the gi store alone. */\n jsx?: StoreOptions | undefined;\n /** Subexport names of the installed `@gtkx/react`, whose element config shapes the jsx store. */\n reactSubexports?: string[];\n /** Component wrappers the project layers over the built-ins, keyed by GLib type name. */\n userComponents?: Record<string, ModuleExport>;\n /** GLib type names whose GObject their parent container creates, added to the framework's own. */\n userLazyElements?: string[];\n /** Base props interfaces the project's elements extend, keyed by GLib type name. */\n userProps?: Record<string, ModuleExport>;\n /** Props the project drops from the generated element props, keyed by GLib type name. */\n userOmittedProps?: OmittedProps;\n /** Regenerates both stores even when their fingerprints are fresh. */\n isForced?: boolean;\n};\n\n/** What a `runCodegen` run produced. */\ntype CodegenRunnerResult = {\n /** Whether either store was rewritten; false means both were already fresh. */\n isRegenerated: boolean;\n /** How many namespaces the gi store was written with, zero when it was already fresh. */\n namespaces: number;\n /** How many JSX elements the jsx store binds, zero when no jsx store was requested. */\n intrinsicElements: number;\n /** Wall-clock duration of the run, in milliseconds. */\n duration: number;\n};\n\ntype StoreResult = {\n isRegenerated: boolean;\n namespaces: number;\n intrinsicElements: number;\n};\n\n/**\n * Writes and links a project's `@gtkx/gi` and `@gtkx/jsx` stores from the given GObject-Introspection\n * libraries. The gi store is rewritten only when its GIR inputs changed, and the jsx store only when the gi\n * store or the React element config changed, unless `options.isForced` is set. Pass the spread of\n * `resolveStore(projectRoot)` for everything but `libraries` and `girPath`.\n *\n * @param options What to generate and where to write it.\n * @returns A summary of what was regenerated and how long the run took.\n * @throws If `girPath` is empty, which would otherwise generate nothing and report success.\n */\nconst runCodegen = async (options: CodegenRunnerOptions): Promise<CodegenRunnerResult> => {\n const start = Date.now();\n const store = await emitStores(options);\n\n return {\n isRegenerated: store.isRegenerated,\n namespaces: store.namespaces,\n intrinsicElements: store.intrinsicElements,\n duration: Date.now() - start,\n };\n};\n\nconst runGlCodegen = (options: GlCodegenOptions): GlGenerationReport => {\n const { files, report } = generateGlModules({\n registryPath: options.registryPath,\n overrideExports: options.overrideExports,\n });\n\n checkModules({\n modules: [...files].map(([fileName, source]) => ({ fileName, source })),\n resolveFrom: options.resolveFrom,\n label: \"the generated gl modules\",\n });\n\n mkdirSync(options.outputDir, { recursive: true });\n\n for (const [fileName, source] of files) {\n writeFileSync(join(options.outputDir, fileName), source);\n }\n\n return report;\n};\n\nconst jsxUserOptions = (\n options: CodegenRunnerOptions,\n): {\n reactSubexports: string[];\n userComponents: Record<string, ModuleExport>;\n userLazyElements: string[];\n userProps: Record<string, ModuleExport>;\n userOmittedProps: OmittedProps;\n} => ({\n reactSubexports: options.reactSubexports ?? [],\n userComponents: options.userComponents ?? {},\n userLazyElements: options.userLazyElements ?? [],\n userProps: options.userProps ?? {},\n userOmittedProps: options.userOmittedProps ?? {},\n});\n\nconst emitJsxStore = async (input: {\n options: CodegenRunnerOptions;\n jsx: StoreOptions;\n gi: StoreOptions;\n loadLibrary: () => Library;\n isGiRegenerated: boolean;\n namespaces: number;\n}): Promise<StoreResult> => {\n const { options, jsx, gi, loadLibrary, isGiRegenerated, namespaces } = input;\n const { runJsxCodegen } = await import(\"./jsx.js\");\n\n const jsxResult = await runJsxCodegen({\n getLibrary: loadLibrary,\n jsx,\n giStoreDir: gi.storeDir,\n ...jsxUserOptions(options),\n isGiRegenerated,\n isForced: options.isForced === true,\n });\n\n return {\n isRegenerated: isGiRegenerated || jsxResult.isRegenerated,\n namespaces,\n intrinsicElements: jsxResult.intrinsicElementCount,\n };\n};\n\nconst emitStoresWithConfig = async (config: {\n options: CodegenRunnerOptions;\n gi: StoreOptions;\n jsx: StoreOptions | undefined;\n libraries: string[];\n girPath: string[];\n}): Promise<StoreResult> => {\n const { options, gi, jsx, libraries, girPath } = config;\n let library: Library | undefined;\n const loadLibrary = (): Library => (library ??= Library.load(libraries, girPath));\n const isGiRegenerated = options.isForced === true || !isGiStoreFresh(gi.storeDir, libraries, girPath);\n\n const namespaces = isGiRegenerated\n ? runGiCodegen(loadLibrary(), { gi, libraries, girPath })\n : 0;\n\n if (jsx === undefined) {\n return { isRegenerated: isGiRegenerated, namespaces, intrinsicElements: 0 };\n }\n\n return emitJsxStore({ options, jsx, gi, loadLibrary, isGiRegenerated, namespaces });\n};\n\nconst emitStores = async (options: CodegenRunnerOptions): Promise<StoreResult> => {\n const { gi, jsx, libraries, girPath } = options;\n\n if (girPath.length === 0) {\n throw new Error(\"codegen needs at least one GIR search path; pass the result of resolveGirPath\");\n }\n\n return emitStoresWithConfig({ options, gi, jsx, libraries, girPath });\n};\n\nexport { runCodegen, runGlCodegen, type CodegenRunnerOptions, type CodegenRunnerResult };\n"]}
|
|
@@ -3,9 +3,8 @@ type CompileStoreParams = {
|
|
|
3
3
|
storeDir: string;
|
|
4
4
|
files: SourceModule[];
|
|
5
5
|
packageName: string;
|
|
6
|
-
|
|
7
|
-
configEnv?: boolean;
|
|
6
|
+
requiresEnvReference?: boolean;
|
|
8
7
|
};
|
|
9
8
|
declare const compileStore: (params: CompileStoreParams) => void;
|
|
10
|
-
export { compileStore
|
|
9
|
+
export { compileStore };
|
|
11
10
|
//# sourceMappingURL=compile-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-store.d.ts","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAElE,KAAK,kBAAkB,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,
|
|
1
|
+
{"version":3,"file":"compile-store.d.ts","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAElE,KAAK,kBAAkB,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAqBF,QAAA,MAAM,YAAY,GAAI,QAAQ,kBAAkB,KAAG,IAqBlD,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -18,13 +18,13 @@ const writeEnvReference = (storeDir) => {
|
|
|
18
18
|
};
|
|
19
19
|
const compileStore = (params) => {
|
|
20
20
|
const fileNames = params.files.map((file) => file.fileName);
|
|
21
|
-
const removeEnvReference = params.
|
|
21
|
+
const removeEnvReference = params.requiresEnvReference === true
|
|
22
22
|
? writeEnvReference(params.storeDir)
|
|
23
23
|
: () => undefined;
|
|
24
24
|
try {
|
|
25
25
|
compileProject({
|
|
26
26
|
projectDir: params.storeDir,
|
|
27
|
-
fileNames: params.
|
|
27
|
+
fileNames: params.requiresEnvReference === true ? [ENV_REFERENCE_FILE, ...fileNames] : fileNames,
|
|
28
28
|
compilerOptions: EMIT_OPTIONS,
|
|
29
29
|
label: `the generated ${params.packageName} store`,
|
|
30
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-store.js","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAqB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"compile-store.js","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAqB,MAAM,eAAe,CAAC;AASlE,MAAM,YAAY,GAAG;IACjB,WAAW,EAAE,IAAI;IACjB,cAAc,EAAE,KAAK;IACrB,SAAS,EAAE,KAAK;IAChB,cAAc,EAAE,KAAK;IACrB,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;CACd,CAAC;AAEF,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAE/C,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAgB,EAAE;IACzD,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,kBAAkB,CAAC,EAAE,+CAA+C,CAAC,CAAC;IAEnG,OAAO,GAAG,EAAE;QACR,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,kBAAkB,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,MAA0B,EAAQ,EAAE;IACtD,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAE5D,MAAM,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,KAAK,IAAI;QAC3D,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC;QACpC,CAAC,CAAC,GAAS,EAAE,CAAC,SAAS,CAAC;IAE5B,IAAI,CAAC;QACD,cAAc,CAAC;YACX,UAAU,EAAE,MAAM,CAAC,QAAQ;YAC3B,SAAS,EAAE,MAAM,CAAC,oBAAoB,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,kBAAkB,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS;YAChG,eAAe,EAAE,YAAY;YAC7B,KAAK,EAAE,iBAAiB,MAAM,CAAC,WAAW,QAAQ;SACrD,CAAC,CAAC;IACP,CAAC;YAAS,CAAC;QACP,kBAAkB,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { compileProject, type SourceModule } from \"../compile.js\";\n\ntype CompileStoreParams = {\n storeDir: string;\n files: SourceModule[];\n packageName: string;\n requiresEnvReference?: boolean;\n};\n\nconst EMIT_OPTIONS = {\n declaration: true,\n removeComments: false,\n sourceMap: false,\n declarationMap: false,\n rootDir: \".\",\n outDir: \".\",\n};\n\nconst ENV_REFERENCE_FILE = \"__gtkx-env__.d.ts\";\n\nconst writeEnvReference = (storeDir: string): (() => void) => {\n writeFileSync(join(storeDir, ENV_REFERENCE_FILE), \"/// <reference types=\\\"@gtkx/react/env\\\" />\\n\");\n\n return () => {\n rmSync(join(storeDir, ENV_REFERENCE_FILE), { force: true });\n };\n};\n\nconst compileStore = (params: CompileStoreParams): void => {\n const fileNames = params.files.map((file) => file.fileName);\n\n const removeEnvReference = params.requiresEnvReference === true\n ? writeEnvReference(params.storeDir)\n : (): void => undefined;\n\n try {\n compileProject({\n projectDir: params.storeDir,\n fileNames: params.requiresEnvReference === true ? [ENV_REFERENCE_FILE, ...fileNames] : fileNames,\n compilerOptions: EMIT_OPTIONS,\n label: `the generated ${params.packageName} store`,\n });\n } finally {\n removeEnvReference();\n }\n\n for (const file of params.files) {\n rmSync(join(params.storeDir, file.fileName), { force: true });\n }\n};\n\nexport { compileStore };\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { GirFunction } from "../../gir/function.js";
|
|
2
|
+
import type { ModuleContext } from "../../writer/context.js";
|
|
3
|
+
import type { JsDocSpec } from "../../writer/doc.js";
|
|
4
|
+
type CallableDocOptions = {
|
|
5
|
+
finishFn?: GirFunction | undefined;
|
|
6
|
+
renames?: Map<string, string> | undefined;
|
|
7
|
+
};
|
|
8
|
+
declare const callableSpec: (context: ModuleContext, callable: GirFunction, options: CallableDocOptions) => JsDocSpec;
|
|
9
|
+
declare const callableDoc: (context: ModuleContext, callable: GirFunction, options?: CallableDocOptions) => string;
|
|
10
|
+
export { callableDoc, callableSpec };
|
|
11
|
+
//# sourceMappingURL=callable-doc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callable-doc.d.ts","sourceRoot":"","sources":["../../../src/store/gi/callable-doc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAarD,KAAK,kBAAkB,GAAG;IACtB,QAAQ,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACnC,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CAC7C,CAAC;AAkEF,QAAA,MAAM,YAAY,GAAI,SAAS,aAAa,EAAE,UAAU,WAAW,EAAE,SAAS,kBAAkB,KAAG,SAWjG,CAAC;AAEH,QAAA,MAAM,WAAW,GAAI,SAAS,aAAa,EAAE,UAAU,WAAW,EAAE,UAAS,kBAAuB,KAAG,MACM,CAAC;AAE9G,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { shouldOmitPrimaryReturn } from "../../analysis/descriptor-render.js";
|
|
2
|
+
import { nulTerminatedByteParams } from "../../analysis/nul-terminated-bytes.js";
|
|
3
|
+
import { documentedParameters, parameterIdentifier, renamesWithInstance, } from "../../analysis/param-structure.js";
|
|
4
|
+
import { renderJsDoc } from "../../writer/doc.js";
|
|
5
|
+
import { annotationSpec, THROWS_TEXT } from "./doc-spec.js";
|
|
6
|
+
import { isCallbackParameter, returnedOutParameters } from "./method.js";
|
|
7
|
+
const WHITESPACE_RUN_PATTERN = /\s+/g;
|
|
8
|
+
const nulTerminatedNote = (context, callable) => {
|
|
9
|
+
const parameters = nulTerminatedByteParams(context.library, callable);
|
|
10
|
+
if (parameters.length === 0) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const names = parameters.map((parameter) => `\`${parameter.name}\``).join(", ");
|
|
14
|
+
return [
|
|
15
|
+
`The C function reads ${names} as a NUL-terminated string, so it stops at the`,
|
|
16
|
+
"first zero byte and drops every byte after it without reporting an error.",
|
|
17
|
+
"Pass binary data through a `GLib.Bytes` route such as `GLib.Variant.newFromBytes`",
|
|
18
|
+
"instead.",
|
|
19
|
+
].join("\n");
|
|
20
|
+
};
|
|
21
|
+
const tupleBullet = (name, doc) => {
|
|
22
|
+
const text = (doc ?? "").replaceAll(WHITESPACE_RUN_PATTERN, " ").trim();
|
|
23
|
+
return text.length === 0 ? undefined : `- \`${name}\`: ${text}`;
|
|
24
|
+
};
|
|
25
|
+
const tupleReturnsText = (primary, outs) => {
|
|
26
|
+
const bullets = [
|
|
27
|
+
tupleBullet("result", primary),
|
|
28
|
+
...outs.map(({ parameter, index }) => tupleBullet(parameterIdentifier(parameter, index), parameter.doc)),
|
|
29
|
+
].filter((bullet) => bullet !== undefined);
|
|
30
|
+
return bullets.length === 0 ? undefined : `Tuple of:\n\n${bullets.join("\n")}`;
|
|
31
|
+
};
|
|
32
|
+
const returnsText = (context, fn) => {
|
|
33
|
+
const outs = returnedOutParameters(context, fn);
|
|
34
|
+
const isPrimaryOmitted = shouldOmitPrimaryReturn(context.library, fn.returnValue);
|
|
35
|
+
const primary = isPrimaryOmitted ? undefined : fn.returnValue.doc;
|
|
36
|
+
if (outs.length === 0) {
|
|
37
|
+
return primary;
|
|
38
|
+
}
|
|
39
|
+
if (isPrimaryOmitted && outs.length === 1) {
|
|
40
|
+
return outs[0]?.parameter.doc;
|
|
41
|
+
}
|
|
42
|
+
return tupleReturnsText(primary, outs);
|
|
43
|
+
};
|
|
44
|
+
const docIdentifiers = (callable, renames) => {
|
|
45
|
+
const identifiers = renamesWithInstance(callable.parameters, callable.instance);
|
|
46
|
+
const overrides = renames ?? new Map();
|
|
47
|
+
for (const [girName, declaredName] of overrides) {
|
|
48
|
+
identifiers.set(girName, declaredName);
|
|
49
|
+
}
|
|
50
|
+
return identifiers;
|
|
51
|
+
};
|
|
52
|
+
const canCallableThrow = (callable, finishFn) => callable.throws || finishFn?.throws === true;
|
|
53
|
+
const callableSpec = (context, callable, options) => ({
|
|
54
|
+
...annotationSpec(callable.annotations),
|
|
55
|
+
identifiers: docIdentifiers(callable, options.renames),
|
|
56
|
+
params: documentedParameters(context.library, callable, (parameter) => options.finishFn !== undefined && isCallbackParameter(context, parameter), options.renames),
|
|
57
|
+
returns: returnsText(context, options.finishFn ?? callable),
|
|
58
|
+
throws: canCallableThrow(callable, options.finishFn) ? THROWS_TEXT : undefined,
|
|
59
|
+
});
|
|
60
|
+
const callableDoc = (context, callable, options = {}) => renderJsDoc(callable.doc, nulTerminatedNote(context, callable), callableSpec(context, callable, options));
|
|
61
|
+
export { callableDoc, callableSpec };
|
|
62
|
+
//# sourceMappingURL=callable-doc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callable-doc.js","sourceRoot":"","sources":["../../../src/store/gi/callable-doc.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EACH,oBAAoB,EAEpB,mBAAmB,EACnB,mBAAmB,GACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAOzE,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAEtC,MAAM,iBAAiB,GAAG,CAAC,OAAsB,EAAE,QAAqB,EAAsB,EAAE;IAC5F,MAAM,UAAU,GAAG,uBAAuB,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEtE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,KAAK,SAAS,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEhF,OAAO;QACH,wBAAwB,KAAK,iDAAiD;QAC9E,2EAA2E;QAC3E,mFAAmF;QACnF,UAAU;KACb,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,GAAuB,EAAsB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,EAAE,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC;IAC3D,MAAM,EAAE,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;CACjF,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,CAAC,OAAsB,EAAE,QAAqB,EAAE,UAA8B,EAAE,EAAU,EAAE,CAC5G,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAE9G,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import type { GirFunction } from \"../../gir/function.js\";\nimport type { GirCallable } from \"../../gir/parameter.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport type { JsDocSpec } from \"../../writer/doc.js\";\nimport { shouldOmitPrimaryReturn } from \"../../analysis/descriptor-render.js\";\nimport { nulTerminatedByteParams } from \"../../analysis/nul-terminated-bytes.js\";\nimport {\n documentedParameters,\n type InputParameter,\n parameterIdentifier,\n renamesWithInstance,\n} from \"../../analysis/param-structure.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\nimport { annotationSpec, THROWS_TEXT } from \"./doc-spec.js\";\nimport { isCallbackParameter, returnedOutParameters } from \"./method.js\";\n\ntype CallableDocOptions = {\n finishFn?: GirFunction | undefined;\n renames?: Map<string, string> | undefined;\n};\n\nconst WHITESPACE_RUN_PATTERN = /\\s+/g;\n\nconst nulTerminatedNote = (context: ModuleContext, callable: GirCallable): string | undefined => {\n const parameters = nulTerminatedByteParams(context.library, callable);\n\n if (parameters.length === 0) {\n return undefined;\n }\n\n const names = parameters.map((parameter) => `\\`${parameter.name}\\``).join(\", \");\n\n return [\n `The C function reads ${names} as a NUL-terminated string, so it stops at the`,\n \"first zero byte and drops every byte after it without reporting an error.\",\n \"Pass binary data through a `GLib.Bytes` route such as `GLib.Variant.newFromBytes`\",\n \"instead.\",\n ].join(\"\\n\");\n};\n\nconst tupleBullet = (name: string, doc: string | undefined): string | undefined => {\n const text = (doc ?? \"\").replaceAll(WHITESPACE_RUN_PATTERN, \" \").trim();\n\n return text.length === 0 ? undefined : `- \\`${name}\\`: ${text}`;\n};\n\nconst tupleReturnsText = (primary: string | undefined, outs: InputParameter[]): string | undefined => {\n const bullets = [\n tupleBullet(\"result\", primary),\n ...outs.map(({ parameter, index }) => tupleBullet(parameterIdentifier(parameter, index), parameter.doc)),\n ].filter((bullet) => bullet !== undefined);\n\n return bullets.length === 0 ? undefined : `Tuple of:\\n\\n${bullets.join(\"\\n\")}`;\n};\n\nconst returnsText = (context: ModuleContext, fn: GirFunction): string | undefined => {\n const outs = returnedOutParameters(context, fn);\n const isPrimaryOmitted = shouldOmitPrimaryReturn(context.library, fn.returnValue);\n const primary = isPrimaryOmitted ? undefined : fn.returnValue.doc;\n\n if (outs.length === 0) {\n return primary;\n }\n\n if (isPrimaryOmitted && outs.length === 1) {\n return outs[0]?.parameter.doc;\n }\n\n return tupleReturnsText(primary, outs);\n};\n\nconst docIdentifiers = (callable: GirFunction, renames: Map<string, string> | undefined): Map<string, string> => {\n const identifiers = renamesWithInstance(callable.parameters, callable.instance);\n const overrides = renames ?? new Map<string, string>();\n\n for (const [girName, declaredName] of overrides) {\n identifiers.set(girName, declaredName);\n }\n\n return identifiers;\n};\n\nconst canCallableThrow = (callable: GirFunction, finishFn: GirFunction | undefined): boolean =>\n callable.throws || finishFn?.throws === true;\n\nconst callableSpec = (context: ModuleContext, callable: GirFunction, options: CallableDocOptions): JsDocSpec => ({\n ...annotationSpec(callable.annotations),\n identifiers: docIdentifiers(callable, options.renames),\n params: documentedParameters(\n context.library,\n callable,\n (parameter) => options.finishFn !== undefined && isCallbackParameter(context, parameter),\n options.renames,\n ),\n returns: returnsText(context, options.finishFn ?? callable),\n throws: canCallableThrow(callable, options.finishFn) ? THROWS_TEXT : undefined,\n});\n\nconst callableDoc = (context: ModuleContext, callable: GirFunction, options: CallableDocOptions = {}): string =>\n renderJsDoc(callable.doc, nulTerminatedNote(context, callable), callableSpec(context, callable, options));\n\nexport { callableDoc, callableSpec };\n"]}
|