@gtkx/codegen 1.0.0-rc.4 → 1.1.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 +5 -5
- package/dist/analysis/descriptor-render.d.ts +13 -9
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +80 -50
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +16 -7
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js +15 -3
- package/dist/analysis/descriptor.js.map +1 -1
- package/dist/analysis/inheritance.d.ts +4 -3
- package/dist/analysis/inheritance.d.ts.map +1 -1
- package/dist/analysis/inheritance.js +103 -58
- package/dist/analysis/inheritance.js.map +1 -1
- package/dist/analysis/interface-conflicts.d.ts +23 -0
- package/dist/analysis/interface-conflicts.d.ts.map +1 -0
- package/dist/analysis/interface-conflicts.js +144 -0
- package/dist/analysis/interface-conflicts.js.map +1 -0
- 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 +129 -0
- package/dist/analysis/param-capability.js.map +1 -0
- package/dist/analysis/param-structure.d.ts +11 -4
- package/dist/analysis/param-structure.d.ts.map +1 -1
- package/dist/analysis/param-structure.js +42 -16
- package/dist/analysis/param-structure.js.map +1 -1
- package/dist/analysis/ts-type.d.ts.map +1 -1
- package/dist/analysis/ts-type.js +10 -17
- package/dist/analysis/ts-type.js.map +1 -1
- package/dist/analysis/type-key.d.ts +5 -0
- package/dist/analysis/type-key.d.ts.map +1 -0
- package/dist/analysis/type-key.js +9 -0
- package/dist/analysis/type-key.js.map +1 -0
- 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 +12 -3
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +73 -24
- package/dist/compile.js.map +1 -1
- package/dist/docs/api-reference.d.ts +2 -2
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +17 -23
- 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 +36 -22
- 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.map +1 -1
- package/dist/docs/pipeline.js +87 -20
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/docs/render.d.ts +26 -5
- package/dist/docs/render.d.ts.map +1 -1
- package/dist/docs/render.js +88 -25
- package/dist/docs/render.js.map +1 -1
- package/dist/docs/symbol-page.d.ts +17 -0
- package/dist/docs/symbol-page.d.ts.map +1 -1
- package/dist/docs/symbol-page.js +132 -44
- package/dist/docs/symbol-page.js.map +1 -1
- package/dist/fingerprint.d.ts +12 -1
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +44 -28
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts.map +1 -1
- package/dist/gi.js +1 -0
- package/dist/gi.js.map +1 -1
- package/dist/gir/ancestry.d.ts +8 -2
- package/dist/gir/ancestry.d.ts.map +1 -1
- package/dist/gir/ancestry.js +19 -1
- package/dist/gir/ancestry.js.map +1 -1
- package/dist/gir/annotations.d.ts +21 -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/cursor-overrides.d.ts +8 -0
- package/dist/gir/cursor-overrides.d.ts.map +1 -0
- package/dist/gir/cursor-overrides.js +6 -0
- package/dist/gir/cursor-overrides.js.map +1 -0
- package/dist/gir/emittable.d.ts +7 -0
- package/dist/gir/emittable.d.ts.map +1 -0
- package/dist/gir/emittable.js +3 -0
- package/dist/gir/emittable.js.map +1 -0
- 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 -3
- package/dist/gir/field.d.ts.map +1 -1
- package/dist/gir/field.js +7 -8
- 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 +28 -2
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/libraries.d.ts +1 -3
- package/dist/gir/libraries.d.ts.map +1 -1
- package/dist/gir/libraries.js +0 -1
- 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 +35 -1
- package/dist/gir/library.js.map +1 -1
- package/dist/gir/namespace.d.ts +43 -1
- package/dist/gir/namespace.d.ts.map +1 -1
- package/dist/gir/namespace.js +8 -7
- package/dist/gir/namespace.js.map +1 -1
- package/dist/gir/parameter.d.ts +52 -1
- package/dist/gir/parameter.d.ts.map +1 -1
- package/dist/gir/parameter.js +8 -3
- 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 +9 -9
- 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.map +1 -1
- package/dist/gir/type-id.d.ts +35 -0
- package/dist/gir/type-id.d.ts.map +1 -1
- package/dist/gir/type-id.js +1 -0
- 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 +1 -0
- 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/guards.d.ts +16 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/guards.js +11 -0
- package/dist/guards.js.map +1 -0
- package/dist/internal.d.ts +2 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -0
- package/dist/internal.js.map +1 -1
- package/dist/json.d.ts +3 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +11 -0
- package/dist/json.js.map +1 -0
- package/dist/khronos/args.d.ts +7 -6
- package/dist/khronos/args.d.ts.map +1 -1
- package/dist/khronos/args.js +28 -6
- 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 +112 -27
- 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/parse.d.ts.map +1 -1
- package/dist/khronos/parse.js +3 -4
- package/dist/khronos/parse.js.map +1 -1
- package/dist/khronos/pipeline.d.ts +4 -2
- package/dist/khronos/pipeline.d.ts.map +1 -1
- package/dist/khronos/pipeline.js +58 -27
- package/dist/khronos/pipeline.js.map +1 -1
- package/dist/khronos/plan.d.ts +3 -9
- package/dist/khronos/plan.d.ts.map +1 -1
- package/dist/khronos/plan.js +3 -3
- 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 +2 -2
- package/dist/react/element-config.d.ts.map +1 -1
- package/dist/react/element-config.js.map +1 -1
- package/dist/runner.d.ts +6 -8
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +16 -0
- package/dist/runner.js.map +1 -1
- package/dist/staging.d.ts +5 -0
- package/dist/staging.d.ts.map +1 -0
- package/dist/staging.js +57 -0
- package/dist/staging.js.map +1 -0
- package/dist/store/compile-store.d.ts +1 -1
- package/dist/store/compile-store.d.ts.map +1 -1
- package/dist/store/compile-store.js +4 -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 +9 -2
- package/dist/store/gi/callables.d.ts.map +1 -1
- package/dist/store/gi/callables.js +35 -40
- 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 +10 -6
- 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 +63 -40
- 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/companion.d.ts.map +1 -1
- package/dist/store/gi/companion.js +6 -6
- package/dist/store/gi/companion.js.map +1 -1
- package/dist/store/gi/constant.d.ts.map +1 -1
- package/dist/store/gi/constant.js +12 -3
- 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 +52 -19
- package/dist/store/gi/enum.js.map +1 -1
- package/dist/store/gi/function.d.ts +1 -3
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +50 -29
- package/dist/store/gi/function.js.map +1 -1
- package/dist/store/gi/gtype-binding.d.ts.map +1 -1
- package/dist/store/gi/gtype-binding.js +4 -1
- package/dist/store/gi/gtype-binding.js.map +1 -1
- package/dist/store/gi/interface.d.ts.map +1 -1
- package/dist/store/gi/interface.js +155 -26
- 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 +11 -2
- package/dist/store/gi/method.d.ts.map +1 -1
- package/dist/store/gi/method.js +80 -45
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/param-marshal.d.ts +6 -2
- package/dist/store/gi/param-marshal.d.ts.map +1 -1
- package/dist/store/gi/param-marshal.js +54 -5
- 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 +23 -11
- package/dist/store/gi/pipeline.js.map +1 -1
- package/dist/store/gi/properties.d.ts +2 -1
- package/dist/store/gi/properties.d.ts.map +1 -1
- package/dist/store/gi/properties.js +7 -4
- package/dist/store/gi/properties.js.map +1 -1
- package/dist/store/gi/property-accessor.d.ts +12 -5
- package/dist/store/gi/property-accessor.d.ts.map +1 -1
- package/dist/store/gi/property-accessor.js +98 -46
- package/dist/store/gi/property-accessor.js.map +1 -1
- package/dist/store/gi/record-constructor.d.ts +8 -1
- package/dist/store/gi/record-constructor.d.ts.map +1 -1
- package/dist/store/gi/record-constructor.js +34 -11
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +3 -1
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +8 -3
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record-layout.d.ts +6 -1
- package/dist/store/gi/record-layout.d.ts.map +1 -1
- package/dist/store/gi/record-layout.js +9 -2
- 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 +21 -9
- package/dist/store/gi/record.js.map +1 -1
- package/dist/store/gi/registration.d.ts +1 -1
- package/dist/store/gi/registration.js +4 -4
- package/dist/store/gi/registration.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 +2 -1
- package/dist/store/gi/signal.d.ts.map +1 -1
- package/dist/store/gi/signal.js +42 -37
- package/dist/store/gi/signal.js.map +1 -1
- package/dist/store/gi/value-marshalable.d.ts +1 -2
- package/dist/store/gi/value-marshalable.d.ts.map +1 -1
- package/dist/store/gi/value-marshalable.js +3 -2
- package/dist/store/gi/value-marshalable.js.map +1 -1
- package/dist/store/gi/vtable.d.ts +19 -1
- package/dist/store/gi/vtable.d.ts.map +1 -1
- package/dist/store/gi/vtable.js +257 -51
- package/dist/store/gi/vtable.js.map +1 -1
- package/dist/store/gi-store.d.ts +1 -0
- package/dist/store/gi-store.d.ts.map +1 -1
- package/dist/store/gi-store.js +15 -20
- package/dist/store/gi-store.js.map +1 -1
- package/dist/store/jsx/element-components.d.ts +1 -1
- package/dist/store/jsx/element-components.d.ts.map +1 -1
- package/dist/store/jsx/element-components.js +6 -4
- package/dist/store/jsx/element-components.js.map +1 -1
- package/dist/store/jsx/element-prop-imports.d.ts +1 -3
- package/dist/store/jsx/element-prop-imports.d.ts.map +1 -1
- package/dist/store/jsx/element-prop-imports.js.map +1 -1
- package/dist/store/jsx/element-prop-types.d.ts +3 -0
- package/dist/store/jsx/element-prop-types.d.ts.map +1 -1
- package/dist/store/jsx/element-prop-types.js +7 -1
- package/dist/store/jsx/element-prop-types.js.map +1 -1
- package/dist/store/jsx/generated-elements.d.ts +2 -1
- package/dist/store/jsx/generated-elements.d.ts.map +1 -1
- package/dist/store/jsx/generated-elements.js +13 -7
- package/dist/store/jsx/generated-elements.js.map +1 -1
- 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 +10 -9
- package/dist/store/jsx/jsx.js.map +1 -1
- package/dist/store/jsx/metadata.d.ts.map +1 -1
- package/dist/store/jsx/metadata.js +5 -3
- package/dist/store/jsx/metadata.js.map +1 -1
- package/dist/store/jsx/pipeline.d.ts +1 -1
- package/dist/store/jsx/pipeline.d.ts.map +1 -1
- 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 +14 -6
- package/dist/store/jsx/props.js.map +1 -1
- 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 +14 -3
- package/dist/store/resolve-store.d.ts.map +1 -1
- package/dist/store/resolve-store.js +98 -15
- package/dist/store/resolve-store.js.map +1 -1
- package/dist/store/store-fs.d.ts +9 -6
- package/dist/store/store-fs.d.ts.map +1 -1
- package/dist/store/store-fs.js +59 -25
- package/dist/store/store-fs.js.map +1 -1
- package/dist/store/store-links.d.ts +3 -0
- package/dist/store/store-links.d.ts.map +1 -0
- package/dist/store/store-links.js +39 -0
- package/dist/store/store-links.js.map +1 -0
- package/dist/writer/comparison-context.d.ts +4 -0
- package/dist/writer/comparison-context.d.ts.map +1 -0
- package/dist/writer/comparison-context.js +13 -0
- package/dist/writer/comparison-context.js.map +1 -0
- package/dist/writer/context.d.ts +3 -2
- package/dist/writer/context.d.ts.map +1 -1
- package/dist/writer/context.js +11 -3
- 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 +17 -3
- package/dist/writer/module.d.ts.map +1 -1
- package/dist/writer/module.js +72 -3
- package/dist/writer/module.js.map +1 -1
- package/dist/xml.d.ts +7 -1
- package/dist/xml.d.ts.map +1 -1
- package/dist/xml.js +43 -1
- package/dist/xml.js.map +1 -1
- package/overrides/gdk/rgba.ts.ejs +26 -0
- package/overrides/gobject/object.ts.ejs +48 -3
- package/overrides/gobject/value.ts.ejs +7 -0
- package/overrides/graphene/structs.ts.ejs +55 -0
- package/package.json +15 -4
- package/src/analysis/descriptor-render.ts +130 -66
- package/src/analysis/descriptor.ts +35 -11
- package/src/analysis/inheritance.ts +166 -75
- package/src/analysis/interface-conflicts.ts +237 -0
- package/src/analysis/nul-terminated-bytes.ts +31 -0
- package/src/analysis/param-capability.ts +169 -0
- package/src/analysis/param-structure.ts +85 -25
- package/src/analysis/ts-type.ts +13 -17
- package/src/analysis/type-key.ts +14 -0
- package/src/analysis/type-shape.ts +24 -0
- package/src/compile.ts +110 -26
- package/src/docs/api-reference.ts +46 -34
- package/src/docs/element-page.ts +58 -49
- package/src/docs/handwritten-props.ts +230 -0
- package/src/docs/pipeline.ts +131 -21
- package/src/docs/render.ts +153 -35
- package/src/docs/symbol-page.ts +230 -80
- package/src/fingerprint.ts +86 -32
- package/src/gi.ts +1 -0
- package/src/gir/ancestry.ts +31 -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/cursor-overrides.ts +12 -0
- package/src/gir/emittable.ts +8 -0
- package/src/gir/enum.ts +30 -10
- package/src/gir/field.ts +24 -9
- package/src/gir/function.ts +60 -9
- package/src/gir/libraries.ts +11 -3
- package/src/gir/library.ts +52 -3
- package/src/gir/namespace.ts +49 -7
- package/src/gir/parameter.ts +62 -3
- package/src/gir/parse.ts +13 -9
- 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 -3
- package/src/gir/type-id.ts +49 -3
- package/src/gir/type-ref.ts +1 -0
- package/src/gir/type.ts +50 -6
- package/src/guards.ts +23 -0
- package/src/internal.ts +2 -0
- package/src/json.ts +11 -0
- package/src/khronos/args.ts +36 -13
- 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 +150 -40
- package/src/khronos/notes.ts +74 -0
- package/src/khronos/param-pair.ts +1 -1
- package/src/khronos/parse.ts +3 -4
- package/src/khronos/pipeline.ts +95 -42
- package/src/khronos/plan.ts +4 -6
- package/src/khronos/render.ts +62 -50
- package/src/khronos/select.ts +91 -50
- package/src/react/element-config.ts +2 -2
- package/src/runner.ts +20 -9
- package/src/staging.ts +69 -0
- package/src/store/compile-store.ts +7 -5
- package/src/store/gi/callable-doc.ts +102 -0
- package/src/store/gi/callables.ts +58 -44
- package/src/store/gi/callback.ts +10 -9
- package/src/store/gi/class.ts +83 -49
- package/src/store/gi/closure-invocation.ts +26 -0
- package/src/store/gi/companion.ts +7 -6
- package/src/store/gi/constant.ts +14 -5
- package/src/store/gi/constructor-props.ts +19 -23
- package/src/store/gi/doc-spec.ts +38 -0
- package/src/store/gi/enum.ts +75 -26
- package/src/store/gi/function.ts +72 -44
- package/src/store/gi/gtype-binding.ts +7 -2
- package/src/store/gi/interface.ts +244 -37
- package/src/store/gi/item-comparators.ts +3 -5
- package/src/store/gi/method.ts +124 -69
- package/src/store/gi/param-marshal.ts +91 -6
- package/src/store/gi/pipeline.ts +28 -13
- package/src/store/gi/properties.ts +10 -5
- package/src/store/gi/property-accessor.ts +163 -75
- package/src/store/gi/record-constructor.ts +56 -19
- package/src/store/gi/record-field-accessor.ts +13 -4
- package/src/store/gi/record-layout.ts +12 -2
- package/src/store/gi/record.ts +24 -10
- package/src/store/gi/registration.ts +5 -5
- package/src/store/gi/runtime-override.ts +13 -6
- package/src/store/gi/signal.ts +54 -57
- package/src/store/gi/value-marshalable.ts +4 -2
- package/src/store/gi/vtable.ts +439 -61
- package/src/store/gi-store.ts +26 -31
- package/src/store/jsx/element-components.ts +8 -5
- package/src/store/jsx/element-prop-imports.ts +1 -3
- package/src/store/jsx/element-prop-types.ts +10 -1
- package/src/store/jsx/generated-elements.ts +17 -8
- package/src/store/jsx/intrinsic-elements.ts +4 -0
- package/src/store/jsx/jsx.ts +11 -9
- package/src/store/jsx/metadata.ts +6 -3
- package/src/store/jsx/pipeline.ts +1 -1
- package/src/store/jsx/props.ts +20 -7
- package/src/store/jsx-store.ts +3 -3
- package/src/store/resolve-store.ts +133 -18
- package/src/store/store-fs.ts +87 -34
- package/src/store/store-links.ts +49 -0
- package/src/writer/comparison-context.ts +18 -0
- package/src/writer/context.ts +14 -4
- 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 +114 -4
- package/src/xml.ts +61 -1
|
@@ -3,7 +3,7 @@ import type { Library } from "../../gir/library.js";
|
|
|
3
3
|
import type { GirNamespace } from "../../gir/namespace.js";
|
|
4
4
|
import type { ImportsBuilder } from "../../writer/imports.js";
|
|
5
5
|
import type { LazyElementSpec } from "./element-prop-types.js";
|
|
6
|
-
import {
|
|
6
|
+
import { getDoc } from "../gi/doc-spec.js";
|
|
7
7
|
import { ancestorGlibNames, type GlibNamedClass } from "./intrinsic-elements.js";
|
|
8
8
|
|
|
9
9
|
type ElementComponent = { module: string; export: string };
|
|
@@ -91,10 +91,11 @@ const collectLazyElementExports = (collector: ExportCollector, lazyElements: Laz
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
const renderLazyElementExport = (spec: LazyElementSpec): string => {
|
|
94
|
+
const doc = getDoc(spec);
|
|
94
95
|
const factory = `createElementComponent(${sourceStringLiteral(spec.element)})`;
|
|
95
|
-
const component =
|
|
96
|
+
const component = `${doc}export const ${spec.element}: (props: ${spec.typeName}) => ReactNode = ${factory};`;
|
|
96
97
|
|
|
97
|
-
return `${spec.typeSource}\n\n${component}`;
|
|
98
|
+
return `${doc}${spec.typeSource}\n\n${component}`;
|
|
98
99
|
};
|
|
99
100
|
|
|
100
101
|
const renderCandidateExport = (
|
|
@@ -113,7 +114,9 @@ const renderCandidateExport = (
|
|
|
113
114
|
imports.addNamed(component.module, component.export, false);
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
|
|
117
|
+
const doc = getDoc(klass);
|
|
118
|
+
|
|
119
|
+
return `${doc}${renderElementComponentExport(glibName, component)}`;
|
|
117
120
|
};
|
|
118
121
|
|
|
119
122
|
const resolveElementComponent = (
|
|
@@ -143,4 +146,4 @@ const renderElementComponentExport = (glibName: string, component: ElementCompon
|
|
|
143
146
|
return `export const ${glibName}: ${annotation} = ${component.export}(${factoryCall});`;
|
|
144
147
|
};
|
|
145
148
|
|
|
146
|
-
export { generateElementComponentsSection, type
|
|
149
|
+
export { generateElementComponentsSection, type ElementComponentOverrides };
|
|
@@ -2,9 +2,7 @@ type ElementPropTypeRef = { type: string; module: string; export: string };
|
|
|
2
2
|
|
|
3
3
|
/** Base props interface each element extends, keyed by GLib type name (the module exports it). */
|
|
4
4
|
type ElementProps = Record<string, {
|
|
5
|
-
/** Specifier the props interface is imported from. */
|
|
6
5
|
module: string;
|
|
7
|
-
/** Identifier the module exports it under. */
|
|
8
6
|
export: string;
|
|
9
7
|
}>;
|
|
10
8
|
|
|
@@ -24,4 +22,4 @@ const elementPropTypeFor = (glibName: string): ElementPropTypeRef | undefined =>
|
|
|
24
22
|
return ref === undefined ? undefined : { type: glibName, module: ref.module, export: ref.export };
|
|
25
23
|
};
|
|
26
24
|
|
|
27
|
-
export { setElementProps, elementPropTypeFor, type
|
|
25
|
+
export { setElementProps, elementPropTypeFor, type ElementProps };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { toCamelIdentifier } from "@gtkx/utils";
|
|
2
|
+
import type { GirAnnotations } from "../../gir/annotations.js";
|
|
2
3
|
import type { GirClass } from "../../gir/class.js";
|
|
3
4
|
import { getChain, type GirIndex, type GirTypeEntry } from "./gir-index.js";
|
|
4
5
|
import { getGlibName } from "./intrinsic-elements.js";
|
|
@@ -7,6 +8,8 @@ type LazyElementSpec = {
|
|
|
7
8
|
element: string;
|
|
8
9
|
typeName: string;
|
|
9
10
|
typeSource: string;
|
|
11
|
+
doc: string | undefined;
|
|
12
|
+
annotations: GirAnnotations;
|
|
10
13
|
};
|
|
11
14
|
|
|
12
15
|
const appendConstructOnlyNames = (klass: GirClass, names: string[]): void => {
|
|
@@ -34,7 +37,13 @@ const createLazyElementSpec = (context: GirIndex, element: string, entry: GirTyp
|
|
|
34
37
|
const omitUnion = omitted.map((name) => JSON.stringify(name)).join(" | ");
|
|
35
38
|
const base = omitted.length === 0 ? `${baseName}Props` : `Omit<${baseName}Props, ${omitUnion}>`;
|
|
36
39
|
|
|
37
|
-
return {
|
|
40
|
+
return {
|
|
41
|
+
element,
|
|
42
|
+
typeName,
|
|
43
|
+
typeSource: `export type ${typeName} = ${base} & { children?: ReactNode };`,
|
|
44
|
+
doc: entry.klass.doc,
|
|
45
|
+
annotations: entry.klass.annotations,
|
|
46
|
+
};
|
|
38
47
|
};
|
|
39
48
|
|
|
40
49
|
const lazyElementSpecs = (context: GirIndex, lazyElements: string[]): Map<string, LazyElementSpec[]> => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
1
|
import { join } from "node:path";
|
|
3
2
|
import type { GlibNamedClass } from "./intrinsic-elements.js";
|
|
4
3
|
import { namespaceDirectory } from "../../gir/namespace.js";
|
|
4
|
+
import { arrayGuard, hasFields, isBoolean, isString } from "../../guards.js";
|
|
5
|
+
import { readJsonFile } from "../../json.js";
|
|
5
6
|
|
|
6
7
|
/** One element the `@gtkx/jsx` store binds. */
|
|
7
8
|
type GeneratedElement = {
|
|
@@ -33,22 +34,30 @@ const collectGeneratedElements = (intrinsicElements: GlibNamedClass[]): Generate
|
|
|
33
34
|
const renderGeneratedElements = (elements: GeneratedElement[]): string =>
|
|
34
35
|
`${JSON.stringify(elements, null, 2)}\n`;
|
|
35
36
|
|
|
37
|
+
const isGeneratedElement = (value: unknown): value is GeneratedElement =>
|
|
38
|
+
hasFields<GeneratedElement>(value, {
|
|
39
|
+
namespace: isString,
|
|
40
|
+
directory: isString,
|
|
41
|
+
glibName: isString,
|
|
42
|
+
isMountable: isBoolean,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const isGeneratedInventory = (value: unknown): value is GeneratedElement[] =>
|
|
46
|
+
arrayGuard(isGeneratedElement)(value);
|
|
47
|
+
|
|
36
48
|
/**
|
|
37
49
|
* Reads the inventory of elements the `@gtkx/jsx` store binds, written into the store by codegen. Answers
|
|
38
50
|
* "what does this project's JSX layer cover" without loading the store, which resolves `virtual:` specifiers
|
|
39
51
|
* that only exist inside a Vite or Vitest build.
|
|
40
52
|
*
|
|
41
53
|
* @param jsxStoreDir The jsx store directory, as given by `resolveStore(projectRoot).jsx.storeDir`.
|
|
42
|
-
* @returns Every bound element, sorted by GLib type name, or an empty array when the store
|
|
54
|
+
* @returns Every bound element, sorted by GLib type name, or an empty array when the store holds no inventory
|
|
55
|
+
* codegen wrote, which covers an absent, unreadable, unparseable and structurally foreign store file alike.
|
|
43
56
|
*/
|
|
44
57
|
const readGeneratedElements = (jsxStoreDir: string): GeneratedElement[] => {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
if (!existsSync(path)) {
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
58
|
+
const parsed = readJsonFile(join(jsxStoreDir, ELEMENTS_FILENAME));
|
|
50
59
|
|
|
51
|
-
return
|
|
60
|
+
return isGeneratedInventory(parsed) ? parsed : [];
|
|
52
61
|
};
|
|
53
62
|
|
|
54
63
|
export {
|
|
@@ -4,9 +4,13 @@ import type { Library } from "../../gir/library.js";
|
|
|
4
4
|
import type { GirNamespace } from "../../gir/namespace.js";
|
|
5
5
|
import { ancestorChain } from "../../gir/ancestry.js";
|
|
6
6
|
|
|
7
|
+
/** A GIR class paired with the GLib type name it is bound under. */
|
|
7
8
|
type GlibNamedClass = {
|
|
9
|
+
/** GLib type name, such as `"GtkButton"`, falling back to the C type when the GIR declares none. */
|
|
8
10
|
glibName: string;
|
|
11
|
+
/** Parsed class the name belongs to. */
|
|
9
12
|
klass: GirClass;
|
|
13
|
+
/** Namespace declaring the class. */
|
|
10
14
|
namespace: GirNamespace;
|
|
11
15
|
};
|
|
12
16
|
|
package/src/store/jsx/jsx.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { sourceStringLiteral } from "@gtkx/utils";
|
|
1
|
+
import { sanitizeTypeIdentifier, sourceStringLiteral } from "@gtkx/utils";
|
|
2
2
|
import type { GirClass } from "../../gir/class.js";
|
|
3
3
|
import type { Library } from "../../gir/library.js";
|
|
4
4
|
import type { GirNamespace } from "../../gir/namespace.js";
|
|
5
5
|
import type { ImportsBuilder } from "../../writer/imports.js";
|
|
6
|
-
import { renderJsDoc } from "../../writer/doc.js";
|
|
7
6
|
import { renderBlock } from "../../writer/emit.js";
|
|
7
|
+
import { getDoc } from "../gi/doc-spec.js";
|
|
8
8
|
import { elementPropTypeFor } from "./element-prop-imports.js";
|
|
9
9
|
import {
|
|
10
10
|
collectInterfacePropsClasses,
|
|
@@ -97,7 +97,9 @@ const generateJsxSection = (
|
|
|
97
97
|
const intrinsicElementConsts = namespaceElements.filter((entry) => !excludeNames.has(entry.glibName));
|
|
98
98
|
|
|
99
99
|
const constLines = intrinsicElementConsts.map(
|
|
100
|
-
(entry) =>
|
|
100
|
+
(entry) =>
|
|
101
|
+
`${getDoc(entry.klass)}export const ${entry.glibName} = ` +
|
|
102
|
+
`${sourceStringLiteral(entry.glibName)} as const;`,
|
|
101
103
|
);
|
|
102
104
|
|
|
103
105
|
const isIntrinsicElementAncestor = (candidate: GirClass): boolean => {
|
|
@@ -135,7 +137,7 @@ const generateJsxSection = (
|
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
const source = [
|
|
138
|
-
constLines.join("\n"),
|
|
140
|
+
constLines.join("\n\n"),
|
|
139
141
|
"",
|
|
140
142
|
propBlocks.join("\n\n"),
|
|
141
143
|
"",
|
|
@@ -283,9 +285,9 @@ const renderInterfacePropsBlock = (
|
|
|
283
285
|
|
|
284
286
|
const extendsClause = prerequisiteExtends.length === 0 ? "" : ` extends ${prerequisiteExtends.join(", ")}`;
|
|
285
287
|
addGiNamespace(imports, iface.namespace.name, giNamespaceAlias(iface.namespace.name));
|
|
286
|
-
const selfDefault = `${giNamespaceAlias(iface.namespace.name)}.${iface.klass.name}`;
|
|
288
|
+
const selfDefault = `${giNamespaceAlias(iface.namespace.name)}.${sanitizeTypeIdentifier(iface.klass.name)}`;
|
|
287
289
|
const signature = `export interface ${glib}Props<Self = ${selfDefault}>${extendsClause}`;
|
|
288
|
-
const block = `${
|
|
290
|
+
const block = `${getDoc(iface.klass)}${renderBlock(signature, ownerLines.join("\n"))}`;
|
|
289
291
|
|
|
290
292
|
return { block, objectPropNames };
|
|
291
293
|
};
|
|
@@ -293,7 +295,7 @@ const renderInterfacePropsBlock = (
|
|
|
293
295
|
const renderJsxAugmentation = (namespaceElements: GlibNamedClass[]): string => {
|
|
294
296
|
const elementLines = namespaceElements
|
|
295
297
|
.filter((entry) => !entry.klass.isAbstract)
|
|
296
|
-
.map((entry) => `${entry.glibName}: ${entry.glibName}Props;`)
|
|
298
|
+
.map((entry) => `${getDoc(entry.klass)}${entry.glibName}: ${entry.glibName}Props;`)
|
|
297
299
|
.join("\n");
|
|
298
300
|
|
|
299
301
|
const intrinsicInterface = renderBlock("interface IntrinsicElements", elementLines);
|
|
@@ -322,9 +324,9 @@ const renderPropBlock = (
|
|
|
322
324
|
const ownerLines = dedupePropLines(["ref?: Ref<Self | null> | undefined;", ...propLines]);
|
|
323
325
|
const extendsList = resolveElementExtends(library, entry, context);
|
|
324
326
|
const extendsClause = extendsList.length === 0 ? "" : ` extends ${extendsList.join(", ")}`;
|
|
325
|
-
const selfDefault = `${giNamespaceAlias(entry.namespace.name)}.${entry.klass.name}`;
|
|
327
|
+
const selfDefault = `${giNamespaceAlias(entry.namespace.name)}.${sanitizeTypeIdentifier(entry.klass.name)}`;
|
|
326
328
|
|
|
327
|
-
const block = `${
|
|
329
|
+
const block = `${getDoc(entry.klass)}${renderBlock(
|
|
328
330
|
`export interface ${entry.glibName}Props<Self = ${selfDefault}>${extendsClause}`,
|
|
329
331
|
ownerLines.join("\n"),
|
|
330
332
|
)}`;
|
|
@@ -66,12 +66,15 @@ const generateMetadata = (library: Library): string => {
|
|
|
66
66
|
|
|
67
67
|
const collectIntrinsicElements = (library: Library): IntrinsicElementEntry[] => {
|
|
68
68
|
const entries: IntrinsicElementEntry[] = [];
|
|
69
|
+
const seen: Set<string> = new Set();
|
|
69
70
|
|
|
70
71
|
for (const { glibName, klass, namespace } of iterateClassesWithGlibName(library)) {
|
|
71
|
-
if (!isIntrinsicElementClass(klass, namespace, library)) {
|
|
72
|
+
if (!isIntrinsicElementClass(klass, namespace, library) || seen.has(glibName)) {
|
|
72
73
|
continue;
|
|
73
74
|
}
|
|
74
75
|
|
|
76
|
+
seen.add(glibName);
|
|
77
|
+
|
|
75
78
|
const sources: GirClass[] = [
|
|
76
79
|
klass,
|
|
77
80
|
...implementedInterfaces(klass, namespace, library).map((entry) => entry.klass),
|
|
@@ -362,9 +365,9 @@ const primitiveDefaultLiteral = (category: PrimitiveCategory, raw: string): stri
|
|
|
362
365
|
};
|
|
363
366
|
|
|
364
367
|
const bigintDefaultLiteral = (raw: string): string | undefined => {
|
|
365
|
-
const
|
|
368
|
+
const integer = integerDefaultLiteral(raw);
|
|
366
369
|
|
|
367
|
-
return
|
|
370
|
+
return integer === undefined ? undefined : `${integer}n`;
|
|
368
371
|
};
|
|
369
372
|
|
|
370
373
|
const enumDefaultLiteral = (enumType: GirEnum, raw: string): string | undefined => {
|
package/src/store/jsx/props.ts
CHANGED
|
@@ -4,11 +4,13 @@ import type { Library } from "../../gir/library.js";
|
|
|
4
4
|
import type { GirNamespace } from "../../gir/namespace.js";
|
|
5
5
|
import type { GirCallable } from "../../gir/parameter.js";
|
|
6
6
|
import type { TypeId } from "../../gir/type-id.js";
|
|
7
|
+
import type { JsDocSpec } from "../../writer/doc.js";
|
|
7
8
|
import { forEachAncestor } from "../../analysis/inheritance.js";
|
|
8
9
|
import { renderHandlerParameters, renderHandlerResultType } from "../../analysis/param-structure.js";
|
|
9
10
|
import { recordTypeTarget, renderBaseType, type TsTypeTarget } from "../../analysis/ts-type.js";
|
|
10
11
|
import { type GirProperty, isConstructableProperty } from "../../gir/property.js";
|
|
11
12
|
import { renderJsDoc } from "../../writer/doc.js";
|
|
13
|
+
import { annotationSpec, selfHandlerSpec } from "../gi/doc-spec.js";
|
|
12
14
|
import { getGlibName, giNamespaceAlias, isIntrinsicElementClass, signalHandlerName } from "./intrinsic-elements.js";
|
|
13
15
|
import { isOmittedProp } from "./omitted-props.js";
|
|
14
16
|
|
|
@@ -67,9 +69,18 @@ type IntrinsicElementMemberWalk = IntrinsicElementScope & {
|
|
|
67
69
|
acceptSignal: (signal: GirCallable) => void;
|
|
68
70
|
};
|
|
69
71
|
|
|
72
|
+
const notifyDoc = (property: GirProperty, jsName: string, spec: JsDocSpec): string => {
|
|
73
|
+
const note = `Called with the new value when \`${jsName}\` changes.`;
|
|
74
|
+
const doc = property.doc;
|
|
75
|
+
const text = doc === undefined || doc.length === 0 ? note : `${note}\n\n${doc}`;
|
|
76
|
+
|
|
77
|
+
return renderJsDoc(text, undefined, spec);
|
|
78
|
+
};
|
|
79
|
+
|
|
70
80
|
const appendPropertyLines = (state: PropCollectorState, property: GirProperty, jsName: string): void => {
|
|
71
81
|
const tsType = renderReactPropType(state.types, property.type, false);
|
|
72
|
-
const
|
|
82
|
+
const spec = annotationSpec(property.annotations);
|
|
83
|
+
const doc = renderJsDoc(property.doc, undefined, spec);
|
|
73
84
|
|
|
74
85
|
if (isObjectProp(state.owner.library, property)) {
|
|
75
86
|
state.propLines.push(`${doc}${jsName}?: ${tsType} | ReactElement | null | undefined;`);
|
|
@@ -78,14 +89,15 @@ const appendPropertyLines = (state: PropCollectorState, property: GirProperty, j
|
|
|
78
89
|
return;
|
|
79
90
|
}
|
|
80
91
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (isSettable) {
|
|
92
|
+
if (isConstructableProperty(property)) {
|
|
84
93
|
state.propLines.push(`${doc}${jsName}?: ${tsType} | null | undefined;`);
|
|
85
94
|
}
|
|
86
95
|
|
|
87
96
|
const handlerType = `((value: ${tsType} | null, self: Self) => void) | null | undefined`;
|
|
88
|
-
|
|
97
|
+
|
|
98
|
+
state.propLines.push(
|
|
99
|
+
`${notifyDoc(property, jsName, spec)}onNotify${upperFirst(jsName)}?: ${handlerType};`,
|
|
100
|
+
);
|
|
89
101
|
};
|
|
90
102
|
|
|
91
103
|
const acceptCollectorProperty = (state: PropCollectorState, property: GirProperty): void => {
|
|
@@ -112,7 +124,8 @@ const acceptCollectorSignal = (state: PropCollectorState, signal: GirCallable):
|
|
|
112
124
|
|
|
113
125
|
state.seen.add(handlerName);
|
|
114
126
|
const signature = renderSignalHandler({ types: state.types, signal, selfType: "Self" });
|
|
115
|
-
|
|
127
|
+
const doc = renderJsDoc(signal.doc, undefined, selfHandlerSpec(signal));
|
|
128
|
+
state.propLines.push(`${doc}${handlerName}?: (${signature}) | undefined;`);
|
|
116
129
|
};
|
|
117
130
|
|
|
118
131
|
const createPropEntryCollector = (owner: IntrinsicElementScope): PropEntryCollector => {
|
|
@@ -259,4 +272,4 @@ const renderReactPropType = (context: PropTypeRenderContext, ref: TypeId | undef
|
|
|
259
272
|
return isNullable ? `${base} | null` : base;
|
|
260
273
|
};
|
|
261
274
|
|
|
262
|
-
export { buildElementPropsEntries, buildInterfacePropsEntries, isObjectProp
|
|
275
|
+
export { buildElementPropsEntries, buildInterfacePropsEntries, isObjectProp };
|
package/src/store/jsx-store.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JsxNamespaceFile } from "./jsx/pipeline.js";
|
|
2
2
|
import type { RawFile } from "./store-fs.js";
|
|
3
|
-
import { buildManifest, type StoreOptions, subpathExport, writeStore } from "./store-fs.js";
|
|
3
|
+
import { buildManifest, namespaceBarrel, type StoreOptions, subpathExport, writeStore } from "./store-fs.js";
|
|
4
4
|
|
|
5
5
|
const writeJsxStore = (
|
|
6
6
|
options: StoreOptions,
|
|
@@ -15,8 +15,8 @@ const writeJsxStore = (
|
|
|
15
15
|
const files = [{ fileName: "metadata.ts", source: metadata }];
|
|
16
16
|
|
|
17
17
|
for (const { directory, source } of namespaces) {
|
|
18
|
-
files.push({ fileName: `${directory}/${directory}.tsx`, source });
|
|
19
|
-
exportsMap[`./${directory}`] = subpathExport(`${directory}
|
|
18
|
+
files.push({ fileName: `${directory}/${directory}.tsx`, source }, namespaceBarrel(directory));
|
|
19
|
+
exportsMap[`./${directory}`] = subpathExport(`${directory}/index`);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
writeStore({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
2
|
-
import { dirname, join, parse } from "node:path";
|
|
2
|
+
import { dirname, join, parse, relative, sep } from "node:path";
|
|
3
3
|
import type { StoreOptions } from "./store-fs.js";
|
|
4
|
+
import { sweepStagingDirs } from "../staging.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Where a project's generated stores live, ready to spread into `runCodegen`. `jsx` is null when the
|
|
@@ -15,10 +16,20 @@ type ResolvedStore = {
|
|
|
15
16
|
reactSubexports: string[];
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
type ResolvedPackage = { dir: string; version: string };
|
|
19
|
+
type ResolvedPackage = { dir: string; nodeModules: string; version: string };
|
|
20
|
+
type StoreConsumer = { name: string; nodeModules: string };
|
|
19
21
|
|
|
20
22
|
const STORE_DIR = ".gtkx";
|
|
21
23
|
const SCOPE = "@gtkx";
|
|
24
|
+
const STORE_NAMES: string[] = ["gi", "jsx"];
|
|
25
|
+
|
|
26
|
+
const STORE_CONSUMERS: string[] = [
|
|
27
|
+
"@gtkx/cli",
|
|
28
|
+
"@gtkx/components",
|
|
29
|
+
"@gtkx/css",
|
|
30
|
+
"@gtkx/react",
|
|
31
|
+
"@gtkx/testing",
|
|
32
|
+
];
|
|
22
33
|
|
|
23
34
|
const readManifest = (path: string): { version?: string; exports?: Record<string, unknown> } =>
|
|
24
35
|
JSON.parse(readFileSync(path, "utf8")) as { version?: string; exports?: Record<string, unknown> };
|
|
@@ -28,14 +39,14 @@ const subexportNames = (packageDir: string): string[] =>
|
|
|
28
39
|
.filter((key) => key.startsWith("./") && key !== "./package.json")
|
|
29
40
|
.map((key) => key.slice(2));
|
|
30
41
|
|
|
31
|
-
const loadPackage = (manifest: string): ResolvedPackage | null => {
|
|
42
|
+
const loadPackage = (manifest: string, nodeModules: string): ResolvedPackage | null => {
|
|
32
43
|
if (!existsSync(manifest)) {
|
|
33
44
|
return null;
|
|
34
45
|
}
|
|
35
46
|
|
|
36
47
|
const real = realpathSync(manifest);
|
|
37
48
|
|
|
38
|
-
return { dir: dirname(real), version: readManifest(real).version ?? "0.0.0" };
|
|
49
|
+
return { dir: dirname(real), nodeModules, version: readManifest(real).version ?? "0.0.0" };
|
|
39
50
|
};
|
|
40
51
|
|
|
41
52
|
const nodeModulesChain = function* (projectRoot: string): Generator<string> {
|
|
@@ -52,49 +63,153 @@ const nodeModulesChain = function* (projectRoot: string): Generator<string> {
|
|
|
52
63
|
|
|
53
64
|
const resolvePackage = (projectRoot: string, packageName: string): ResolvedPackage | null => {
|
|
54
65
|
for (const nodeModules of nodeModulesChain(projectRoot)) {
|
|
55
|
-
const found = loadPackage(join(nodeModules, packageName, "package.json"));
|
|
66
|
+
const found = loadPackage(join(nodeModules, packageName, "package.json"), nodeModules);
|
|
56
67
|
|
|
57
68
|
if (found !== null) {
|
|
58
69
|
return found;
|
|
59
70
|
}
|
|
60
71
|
}
|
|
61
72
|
|
|
62
|
-
|
|
73
|
+
const unscoped = packageName.replace(/^@[^/]+\//, "");
|
|
74
|
+
|
|
75
|
+
return loadPackage(join(projectRoot, "packages", unscoped, "package.json"), join(projectRoot, "node_modules"));
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const isWithin = (parent: string, child: string): boolean => {
|
|
79
|
+
const path = relative(parent, child);
|
|
80
|
+
|
|
81
|
+
return path === "" || (path !== ".." && !path.startsWith(`..${sep}`));
|
|
63
82
|
};
|
|
64
83
|
|
|
84
|
+
const canImport = (fromNodeModules: string, targetNodeModules: string): boolean =>
|
|
85
|
+
isWithin(dirname(targetNodeModules), dirname(fromNodeModules));
|
|
86
|
+
|
|
65
87
|
const storeOptions = (nodeModules: string, name: string, version: string): StoreOptions => ({
|
|
66
88
|
storeDir: join(nodeModules, STORE_DIR, name),
|
|
67
89
|
linkDir: join(nodeModules, SCOPE, name),
|
|
68
90
|
version,
|
|
69
91
|
});
|
|
70
92
|
|
|
93
|
+
const resolveRuntime = (projectRoot: string): ResolvedPackage => {
|
|
94
|
+
const runtime = resolvePackage(projectRoot, "@gtkx/runtime");
|
|
95
|
+
|
|
96
|
+
if (runtime === null) {
|
|
97
|
+
throw new Error(`Cannot resolve @gtkx/runtime from ${projectRoot}; is it installed?`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return runtime;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const storeNodeModules = (runtime: ResolvedPackage, react: ResolvedPackage | null): string => {
|
|
104
|
+
if (react !== null && canImport(react.nodeModules, runtime.nodeModules)) {
|
|
105
|
+
return react.nodeModules;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return runtime.nodeModules;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const findUnreachableConsumer = (projectRoot: string, nodeModules: string): StoreConsumer | null => {
|
|
112
|
+
for (const name of STORE_CONSUMERS) {
|
|
113
|
+
const consumer = resolvePackage(projectRoot, name);
|
|
114
|
+
|
|
115
|
+
if (consumer !== null && !canImport(consumer.nodeModules, nodeModules)) {
|
|
116
|
+
return { name, nodeModules: consumer.nodeModules };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return null;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const unreachableConsumerMessage = (consumer: StoreConsumer, nodeModules: string): string =>
|
|
124
|
+
`Cannot write the generated store to ${nodeModules}: ${consumer.name} is installed in ` +
|
|
125
|
+
`${consumer.nodeModules}, above it, so that copy can never import the generated @gtkx/gi. Install every ` +
|
|
126
|
+
"@gtkx package in one node_modules, then run gtkx codegen again.";
|
|
127
|
+
|
|
128
|
+
const checkConsumers = (projectRoot: string, nodeModules: string): void => {
|
|
129
|
+
const consumer = findUnreachableConsumer(projectRoot, nodeModules);
|
|
130
|
+
|
|
131
|
+
if (consumer !== null) {
|
|
132
|
+
throw new Error(unreachableConsumerMessage(consumer, nodeModules));
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const jsxOptions = (react: ResolvedPackage | null, nodeModules: string): StoreOptions | null =>
|
|
137
|
+
react === null ? null : storeOptions(nodeModules, "jsx", react.version);
|
|
138
|
+
|
|
139
|
+
const getReactSubexports = (react: ResolvedPackage | null): string[] =>
|
|
140
|
+
react === null ? [] : subexportNames(react.dir);
|
|
141
|
+
|
|
142
|
+
const storePaths = (nodeModules: string): string[] =>
|
|
143
|
+
STORE_NAMES.flatMap((name) => [join(nodeModules, STORE_DIR, name), join(nodeModules, SCOPE, name)]);
|
|
144
|
+
|
|
145
|
+
const findStoreNodeModules = (projectRoot: string): string | null => {
|
|
146
|
+
const runtime = resolvePackage(projectRoot, "@gtkx/runtime");
|
|
147
|
+
|
|
148
|
+
if (runtime === null) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return storeNodeModules(runtime, resolvePackage(projectRoot, "@gtkx/react"));
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const getShadowingStorePaths = (projectRoot: string): string[] => {
|
|
156
|
+
const nodeModules = join(projectRoot, "node_modules");
|
|
157
|
+
const anchored = findStoreNodeModules(projectRoot);
|
|
158
|
+
|
|
159
|
+
if (anchored === null || anchored === nodeModules) {
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return storePaths(nodeModules);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const stagingRoots = (projectRoot: string): string[] => {
|
|
167
|
+
const nodeModules = join(projectRoot, "node_modules");
|
|
168
|
+
const anchored = findStoreNodeModules(projectRoot);
|
|
169
|
+
|
|
170
|
+
return anchored === null || anchored === nodeModules ? [nodeModules] : [nodeModules, anchored];
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const sweepProjectStaging = (projectRoot: string): void => {
|
|
174
|
+
for (const nodeModules of stagingRoots(projectRoot)) {
|
|
175
|
+
for (const name of STORE_NAMES) {
|
|
176
|
+
sweepStagingDirs(join(nodeModules, STORE_DIR, name));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
71
181
|
/**
|
|
72
182
|
* Resolves where a project's `@gtkx/gi` and `@gtkx/jsx` stores belong, from the project root alone. The
|
|
73
183
|
* result supplies every `runCodegen` input except `libraries` and `girPath`, so a caller that has
|
|
74
184
|
* already resolved those can spread it straight into the call.
|
|
75
185
|
*
|
|
186
|
+
* Both stores go in one `node_modules`, found by walking the project's `node_modules` chain upwards:
|
|
187
|
+
* the one `@gtkx/react` resolves from, or `@gtkx/runtime`'s when no React is installed. That is the
|
|
188
|
+
* project's own directory when it installs those packages itself, and the workspace root when npm or
|
|
189
|
+
* yarn hoisted them there. Keeping the pair together is what lets the jsx store import the gi store, and
|
|
190
|
+
* anchoring them where the `@gtkx` packages sit is what lets `@gtkx/react`, the CLI, and the project's
|
|
191
|
+
* sources all reach the bindings. A package manager that hoists therefore gives every project sharing
|
|
192
|
+
* that `node_modules` one shared store.
|
|
193
|
+
*
|
|
76
194
|
* Store versions come from the installed `@gtkx/runtime` and `@gtkx/react`, so a dependency upgrade
|
|
77
195
|
* invalidates the stores. Pass explicit `gi` or `jsx` options to `runCodegen` to override any of it.
|
|
78
196
|
*
|
|
79
|
-
* @param projectRoot Directory holding the project's `package.json
|
|
197
|
+
* @param projectRoot Directory holding the project's `package.json`, whose `node_modules` chain is walked.
|
|
80
198
|
* @returns The store locations and the React subexports that shape the jsx store.
|
|
81
|
-
* @throws If `@gtkx/runtime` cannot be resolved from the project
|
|
199
|
+
* @throws If `@gtkx/runtime` cannot be resolved from the project, or a `@gtkx` package that imports the
|
|
200
|
+
* bindings is installed above the `node_modules` the stores would go in, since it could not reach them.
|
|
82
201
|
*/
|
|
83
202
|
const resolveStore = (projectRoot: string): ResolvedStore => {
|
|
84
|
-
const runtime =
|
|
85
|
-
|
|
86
|
-
if (runtime === null) {
|
|
87
|
-
throw new Error(`Cannot resolve @gtkx/runtime from ${projectRoot}; is it installed?`);
|
|
88
|
-
}
|
|
89
|
-
|
|
203
|
+
const runtime = resolveRuntime(projectRoot);
|
|
90
204
|
const react = resolvePackage(projectRoot, "@gtkx/react");
|
|
91
|
-
const nodeModules =
|
|
205
|
+
const nodeModules = storeNodeModules(runtime, react);
|
|
206
|
+
checkConsumers(projectRoot, nodeModules);
|
|
92
207
|
|
|
93
208
|
return {
|
|
94
209
|
gi: storeOptions(nodeModules, "gi", runtime.version),
|
|
95
|
-
jsx: react
|
|
96
|
-
reactSubexports:
|
|
210
|
+
jsx: jsxOptions(react, nodeModules),
|
|
211
|
+
reactSubexports: getReactSubexports(react),
|
|
97
212
|
};
|
|
98
213
|
};
|
|
99
214
|
|
|
100
|
-
export { resolveStore, type ResolvedStore };
|
|
215
|
+
export { getShadowingStorePaths, resolveStore, sweepProjectStaging, type ResolvedStore };
|