@ts-for-gir/cli 3.0.0-beta.9 → 3.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 +160 -35
- package/lib/commands/doc.d.ts +1 -17
- package/lib/commands/doc.js +7 -13
- package/lib/commands/doc.js.map +1 -1
- package/lib/commands/generate.d.ts +1 -37
- package/lib/commands/generate.js +8 -24
- package/lib/commands/generate.js.map +1 -1
- package/lib/commands/list.d.ts +1 -11
- package/lib/commands/list.js +6 -10
- package/lib/commands/list.js.map +1 -1
- package/lib/config.d.ts +21 -5
- package/lib/config.js +164 -86
- package/lib/config.js.map +1 -1
- package/lib/generation-handler.d.ts +3 -4
- package/lib/generation-handler.js +7 -11
- package/lib/generation-handler.js.map +1 -1
- package/lib/index.d.ts +0 -12
- package/lib/index.js +0 -12
- package/lib/index.js.map +1 -1
- package/lib/module-loader.d.ts +35 -24
- package/lib/module-loader.js +3 -8
- package/lib/module-loader.js.map +1 -1
- package/lib/utils.d.ts +0 -262
- package/lib/utils.js +8 -371
- package/lib/utils.js.map +1 -1
- package/package.json +32 -37
- package/src/commands/doc.ts +9 -14
- package/src/commands/generate.ts +10 -24
- package/src/commands/list.ts +8 -10
- package/src/config.ts +178 -92
- package/src/generation-handler.ts +11 -12
- package/src/index.ts +0 -12
- package/src/module-loader.ts +39 -31
- package/src/utils.ts +8 -401
- package/lib/conflict-resolver.d.ts +0 -155
- package/lib/conflict-resolver.js +0 -1103
- package/lib/conflict-resolver.js.map +0 -1
- package/lib/constants.d.ts +0 -18
- package/lib/constants.js +0 -23
- package/lib/constants.js.map +0 -1
- package/lib/dependency-manager.d.ts +0 -34
- package/lib/dependency-manager.js +0 -78
- package/lib/dependency-manager.js.map +0 -1
- package/lib/generator.d.ts +0 -5
- package/lib/generator.js +0 -2
- package/lib/generator.js.map +0 -1
- package/lib/gir-factory.d.ts +0 -51
- package/lib/gir-factory.js +0 -361
- package/lib/gir-factory.js.map +0 -1
- package/lib/gir-module.d.ts +0 -257
- package/lib/gir-module.js +0 -2086
- package/lib/gir-module.js.map +0 -1
- package/lib/html-doc-generator.d.ts +0 -13
- package/lib/html-doc-generator.js +0 -18
- package/lib/html-doc-generator.js.map +0 -1
- package/lib/injection/callbacks/gjs/Gio-2.0.d.ts +0 -2
- package/lib/injection/callbacks/gjs/Gio-2.0.js +0 -36
- package/lib/injection/callbacks/gjs/Gio-2.0.js.map +0 -1
- package/lib/injection/callbacks/gjs/index.d.ts +0 -2
- package/lib/injection/callbacks/gjs/index.js +0 -3
- package/lib/injection/callbacks/gjs/index.js.map +0 -1
- package/lib/injection/callbacks/index.d.ts +0 -4
- package/lib/injection/callbacks/index.js +0 -4
- package/lib/injection/callbacks/index.js.map +0 -1
- package/lib/injection/callbacks/node-gtk/index.d.ts +0 -2
- package/lib/injection/callbacks/node-gtk/index.js +0 -2
- package/lib/injection/callbacks/node-gtk/index.js.map +0 -1
- package/lib/injection/classes/GLib-2-0.d.ts +0 -2
- package/lib/injection/classes/GLib-2-0.js +0 -35
- package/lib/injection/classes/GLib-2-0.js.map +0 -1
- package/lib/injection/classes/gjs/GLib-2.0.d.ts +0 -2
- package/lib/injection/classes/gjs/GLib-2.0.js +0 -200
- package/lib/injection/classes/gjs/GLib-2.0.js.map +0 -1
- package/lib/injection/classes/gjs/GObject-2.0.d.ts +0 -2
- package/lib/injection/classes/gjs/GObject-2.0.js +0 -634
- package/lib/injection/classes/gjs/GObject-2.0.js.map +0 -1
- package/lib/injection/classes/gjs/Gio-2.0.d.ts +0 -5
- package/lib/injection/classes/gjs/Gio-2.0.js +0 -218
- package/lib/injection/classes/gjs/Gio-2.0.js.map +0 -1
- package/lib/injection/classes/gjs/index.d.ts +0 -2
- package/lib/injection/classes/gjs/index.js +0 -5
- package/lib/injection/classes/gjs/index.js.map +0 -1
- package/lib/injection/classes/index.d.ts +0 -4
- package/lib/injection/classes/index.js +0 -5
- package/lib/injection/classes/index.js.map +0 -1
- package/lib/injection/classes/node-gtk/GLib-2.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/GLib-2.0.js +0 -19
- package/lib/injection/classes/node-gtk/GLib-2.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/GObject-2.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/GObject-2.0.js +0 -66
- package/lib/injection/classes/node-gtk/GObject-2.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/Gdk-4.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/Gdk-4.0.js +0 -32
- package/lib/injection/classes/node-gtk/Gdk-4.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/Gio-2.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/Gio-2.0.js +0 -14
- package/lib/injection/classes/node-gtk/Gio-2.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/Graphene-1.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/Graphene-1.0.js +0 -133
- package/lib/injection/classes/node-gtk/Graphene-1.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/Gtk-3.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/Gtk-3.0.js +0 -31
- package/lib/injection/classes/node-gtk/Gtk-3.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/Gtk-4.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/Gtk-4.0.js +0 -52
- package/lib/injection/classes/node-gtk/Gtk-4.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/Pango-1.0.d.ts +0 -2
- package/lib/injection/classes/node-gtk/Pango-1.0.js +0 -31
- package/lib/injection/classes/node-gtk/Pango-1.0.js.map +0 -1
- package/lib/injection/classes/node-gtk/index.d.ts +0 -2
- package/lib/injection/classes/node-gtk/index.js +0 -19
- package/lib/injection/classes/node-gtk/index.js.map +0 -1
- package/lib/injection/index.d.ts +0 -3
- package/lib/injection/index.js +0 -4
- package/lib/injection/index.js.map +0 -1
- package/lib/injection/injector.d.ts +0 -17
- package/lib/injection/injector.js +0 -139
- package/lib/injection/injector.js.map +0 -1
- package/lib/logger.d.ts +0 -36
- package/lib/logger.js +0 -137
- package/lib/logger.js.map +0 -1
- package/lib/messages.d.ts +0 -31
- package/lib/messages.js +0 -46
- package/lib/messages.js.map +0 -1
- package/lib/symtable.d.ts +0 -24
- package/lib/symtable.js +0 -63
- package/lib/symtable.js.map +0 -1
- package/lib/template-processor.d.ts +0 -74
- package/lib/template-processor.js +0 -165
- package/lib/template-processor.js.map +0 -1
- package/lib/transformation.d.ts +0 -156
- package/lib/transformation.js +0 -523
- package/lib/transformation.js.map +0 -1
- package/lib/type-definition-generator.d.ts +0 -116
- package/lib/type-definition-generator.js +0 -991
- package/lib/type-definition-generator.js.map +0 -1
- package/lib/types/answer-version.d.ts +0 -4
- package/lib/types/answer-version.js +0 -2
- package/lib/types/answer-version.js.map +0 -1
- package/lib/types/build-type.d.ts +0 -1
- package/lib/types/build-type.js +0 -2
- package/lib/types/build-type.js.map +0 -1
- package/lib/types/class-parent.d.ts +0 -13
- package/lib/types/class-parent.js +0 -2
- package/lib/types/class-parent.js.map +0 -1
- package/lib/types/config-flags.d.ts +0 -4
- package/lib/types/config-flags.js +0 -2
- package/lib/types/config-flags.js.map +0 -1
- package/lib/types/conflict-child-element.d.ts +0 -10
- package/lib/types/conflict-child-element.js +0 -2
- package/lib/types/conflict-child-element.js.map +0 -1
- package/lib/types/conflict-grouped-element.d.ts +0 -6
- package/lib/types/conflict-grouped-element.js +0 -2
- package/lib/types/conflict-grouped-element.js.map +0 -1
- package/lib/types/conflict-grouped-elements.d.ts +0 -4
- package/lib/types/conflict-grouped-elements.js +0 -2
- package/lib/types/conflict-grouped-elements.js.map +0 -1
- package/lib/types/construct-name.d.ts +0 -1
- package/lib/types/construct-name.js +0 -2
- package/lib/types/construct-name.js.map +0 -1
- package/lib/types/dependency-map.d.ts +0 -4
- package/lib/types/dependency-map.js +0 -2
- package/lib/types/dependency-map.js.map +0 -1
- package/lib/types/dependency.d.ts +0 -15
- package/lib/types/dependency.js +0 -2
- package/lib/types/dependency.js.map +0 -1
- package/lib/types/environment.d.ts +0 -1
- package/lib/types/environment.js +0 -2
- package/lib/types/environment.js.map +0 -1
- package/lib/types/file-info.d.ts +0 -14
- package/lib/types/file-info.js +0 -2
- package/lib/types/file-info.js.map +0 -1
- package/lib/types/generate-config.d.ts +0 -32
- package/lib/types/generate-config.js +0 -2
- package/lib/types/generate-config.js.map +0 -1
- package/lib/types/generator-type.d.ts +0 -4
- package/lib/types/generator-type.js +0 -6
- package/lib/types/generator-type.js.map +0 -1
- package/lib/types/gir-alias-element.d.ts +0 -13
- package/lib/types/gir-alias-element.js +0 -2
- package/lib/types/gir-alias-element.js.map +0 -1
- package/lib/types/gir-annotation.d.ts +0 -9
- package/lib/types/gir-annotation.js +0 -2
- package/lib/types/gir-annotation.js.map +0 -1
- package/lib/types/gir-any-element.d.ts +0 -2
- package/lib/types/gir-any-element.js +0 -2
- package/lib/types/gir-any-element.js.map +0 -1
- package/lib/types/gir-any-type.d.ts +0 -5
- package/lib/types/gir-any-type.js +0 -2
- package/lib/types/gir-any-type.js.map +0 -1
- package/lib/types/gir-array-type.d.ts +0 -20
- package/lib/types/gir-array-type.js +0 -3
- package/lib/types/gir-array-type.js.map +0 -1
- package/lib/types/gir-bitfield-element.d.ts +0 -17
- package/lib/types/gir-bitfield-element.js +0 -2
- package/lib/types/gir-bitfield-element.js.map +0 -1
- package/lib/types/gir-boolean.d.ts +0 -1
- package/lib/types/gir-boolean.js +0 -2
- package/lib/types/gir-boolean.js.map +0 -1
- package/lib/types/gir-boxed-element.d.ts +0 -15
- package/lib/types/gir-boxed-element.js +0 -2
- package/lib/types/gir-boxed-element.js.map +0 -1
- package/lib/types/gir-c-include.d.ts +0 -7
- package/lib/types/gir-c-include.js +0 -2
- package/lib/types/gir-c-include.js.map +0 -1
- package/lib/types/gir-callable-attrs.d.ts +0 -15
- package/lib/types/gir-callable-attrs.js +0 -3
- package/lib/types/gir-callable-attrs.js.map +0 -1
- package/lib/types/gir-callable-param-element.d.ts +0 -30
- package/lib/types/gir-callable-param-element.js +0 -2
- package/lib/types/gir-callable-param-element.js.map +0 -1
- package/lib/types/gir-callable-param.d.ts +0 -7
- package/lib/types/gir-callable-param.js +0 -2
- package/lib/types/gir-callable-param.js.map +0 -1
- package/lib/types/gir-callable-return.d.ts +0 -22
- package/lib/types/gir-callable-return.js +0 -2
- package/lib/types/gir-callable-return.js.map +0 -1
- package/lib/types/gir-callback-element.d.ts +0 -15
- package/lib/types/gir-callback-element.js +0 -2
- package/lib/types/gir-callback-element.js.map +0 -1
- package/lib/types/gir-class-element.d.ts +0 -48
- package/lib/types/gir-class-element.js +0 -2
- package/lib/types/gir-class-element.js.map +0 -1
- package/lib/types/gir-constant-element.d.ts +0 -15
- package/lib/types/gir-constant-element.js +0 -2
- package/lib/types/gir-constant-element.js.map +0 -1
- package/lib/types/gir-constructor-element.d.ts +0 -8
- package/lib/types/gir-constructor-element.js +0 -2
- package/lib/types/gir-constructor-element.js.map +0 -1
- package/lib/types/gir-direction.d.ts +0 -5
- package/lib/types/gir-direction.js +0 -7
- package/lib/types/gir-direction.js.map +0 -1
- package/lib/types/gir-doc-element.d.ts +0 -68
- package/lib/types/gir-doc-element.js +0 -2
- package/lib/types/gir-doc-element.js.map +0 -1
- package/lib/types/gir-enum-element.d.ts +0 -19
- package/lib/types/gir-enum-element.js +0 -2
- package/lib/types/gir-enum-element.js.map +0 -1
- package/lib/types/gir-field-element.d.ts +0 -18
- package/lib/types/gir-field-element.js +0 -2
- package/lib/types/gir-field-element.js.map +0 -1
- package/lib/types/gir-function-element.d.ts +0 -8
- package/lib/types/gir-function-element.js +0 -2
- package/lib/types/gir-function-element.js.map +0 -1
- package/lib/types/gir-implements.d.ts +0 -8
- package/lib/types/gir-implements.js +0 -2
- package/lib/types/gir-implements.js.map +0 -1
- package/lib/types/gir-include.d.ts +0 -9
- package/lib/types/gir-include.js +0 -2
- package/lib/types/gir-include.js.map +0 -1
- package/lib/types/gir-info-attrs.d.ts +0 -13
- package/lib/types/gir-info-attrs.js +0 -2
- package/lib/types/gir-info-attrs.js.map +0 -1
- package/lib/types/gir-info-elements.d.ts +0 -5
- package/lib/types/gir-info-elements.js +0 -2
- package/lib/types/gir-info-elements.js.map +0 -1
- package/lib/types/gir-instance-parameter.d.ts +0 -21
- package/lib/types/gir-instance-parameter.js +0 -2
- package/lib/types/gir-instance-parameter.js.map +0 -1
- package/lib/types/gir-interface-element.d.ts +0 -31
- package/lib/types/gir-interface-element.js +0 -2
- package/lib/types/gir-interface-element.js.map +0 -1
- package/lib/types/gir-member-element.d.ts +0 -17
- package/lib/types/gir-member-element.js +0 -2
- package/lib/types/gir-member-element.js.map +0 -1
- package/lib/types/gir-method-element.d.ts +0 -13
- package/lib/types/gir-method-element.js +0 -2
- package/lib/types/gir-method-element.js.map +0 -1
- package/lib/types/gir-module-resolved-by.d.ts +0 -10
- package/lib/types/gir-module-resolved-by.js +0 -2
- package/lib/types/gir-module-resolved-by.js.map +0 -1
- package/lib/types/gir-modules-grouped-map.d.ts +0 -4
- package/lib/types/gir-modules-grouped-map.js +0 -2
- package/lib/types/gir-modules-grouped-map.js.map +0 -1
- package/lib/types/gir-modules-grouped.d.ts +0 -12
- package/lib/types/gir-modules-grouped.js +0 -2
- package/lib/types/gir-modules-grouped.js.map +0 -1
- package/lib/types/gir-namespace.d.ts +0 -30
- package/lib/types/gir-namespace.js +0 -2
- package/lib/types/gir-namespace.js.map +0 -1
- package/lib/types/gir-package.d.ts +0 -7
- package/lib/types/gir-package.js +0 -2
- package/lib/types/gir-package.js.map +0 -1
- package/lib/types/gir-prerequisite.d.ts +0 -5
- package/lib/types/gir-prerequisite.js +0 -2
- package/lib/types/gir-prerequisite.js.map +0 -1
- package/lib/types/gir-property-element.d.ts +0 -21
- package/lib/types/gir-property-element.js +0 -2
- package/lib/types/gir-property-element.js.map +0 -1
- package/lib/types/gir-record-element.d.ts +0 -30
- package/lib/types/gir-record-element.js +0 -2
- package/lib/types/gir-record-element.js.map +0 -1
- package/lib/types/gir-repository.d.ts +0 -16
- package/lib/types/gir-repository.js +0 -2
- package/lib/types/gir-repository.js.map +0 -1
- package/lib/types/gir-signal.d.ts +0 -25
- package/lib/types/gir-signal.js +0 -2
- package/lib/types/gir-signal.js.map +0 -1
- package/lib/types/gir-transfer-ownership-type.d.ts +0 -5
- package/lib/types/gir-transfer-ownership-type.js +0 -7
- package/lib/types/gir-transfer-ownership-type.js.map +0 -1
- package/lib/types/gir-transfer-ownership.d.ts +0 -5
- package/lib/types/gir-transfer-ownership.js +0 -2
- package/lib/types/gir-transfer-ownership.js.map +0 -1
- package/lib/types/gir-type.d.ts +0 -14
- package/lib/types/gir-type.js +0 -2
- package/lib/types/gir-type.js.map +0 -1
- package/lib/types/gir-union-element.d.ts +0 -22
- package/lib/types/gir-union-element.js +0 -2
- package/lib/types/gir-union-element.js.map +0 -1
- package/lib/types/gir-unparsed-number.d.ts +0 -2
- package/lib/types/gir-unparsed-number.js +0 -2
- package/lib/types/gir-unparsed-number.js.map +0 -1
- package/lib/types/gir-var-args.d.ts +0 -5
- package/lib/types/gir-var-args.js +0 -2
- package/lib/types/gir-var-args.js.map +0 -1
- package/lib/types/gir-virtual-method.d.ts +0 -10
- package/lib/types/gir-virtual-method.js +0 -2
- package/lib/types/gir-virtual-method.js.map +0 -1
- package/lib/types/index.d.ts +0 -119
- package/lib/types/index.js +0 -120
- package/lib/types/index.js.map +0 -1
- package/lib/types/inheritance-table.d.ts +0 -3
- package/lib/types/inheritance-table.js +0 -2
- package/lib/types/inheritance-table.js.map +0 -1
- package/lib/types/injection-callback.d.ts +0 -16
- package/lib/types/injection-callback.js +0 -2
- package/lib/types/injection-callback.js.map +0 -1
- package/lib/types/injection-class.d.ts +0 -25
- package/lib/types/injection-class.js +0 -2
- package/lib/types/injection-class.js.map +0 -1
- package/lib/types/injection-function.d.ts +0 -7
- package/lib/types/injection-function.js +0 -2
- package/lib/types/injection-function.js.map +0 -1
- package/lib/types/injection-generic-parameter.d.ts +0 -2
- package/lib/types/injection-generic-parameter.js +0 -2
- package/lib/types/injection-generic-parameter.js.map +0 -1
- package/lib/types/injection-instance-parameter.d.ts +0 -2
- package/lib/types/injection-instance-parameter.js +0 -2
- package/lib/types/injection-instance-parameter.js.map +0 -1
- package/lib/types/injection-parameter.d.ts +0 -8
- package/lib/types/injection-parameter.js +0 -2
- package/lib/types/injection-parameter.js.map +0 -1
- package/lib/types/injection-property.d.ts +0 -4
- package/lib/types/injection-property.js +0 -2
- package/lib/types/injection-property.js.map +0 -1
- package/lib/types/injection-type.d.ts +0 -2
- package/lib/types/injection-type.js +0 -2
- package/lib/types/injection-type.js.map +0 -1
- package/lib/types/injection.d.ts +0 -5
- package/lib/types/injection.js +0 -2
- package/lib/types/injection.js.map +0 -1
- package/lib/types/local-name-check.d.ts +0 -4
- package/lib/types/local-name-check.js +0 -2
- package/lib/types/local-name-check.js.map +0 -1
- package/lib/types/local-name-type.d.ts +0 -1
- package/lib/types/local-name-type.js +0 -2
- package/lib/types/local-name-type.js.map +0 -1
- package/lib/types/local-name.d.ts +0 -7
- package/lib/types/local-name.js +0 -2
- package/lib/types/local-name.js.map +0 -1
- package/lib/types/local-names.d.ts +0 -4
- package/lib/types/local-names.js +0 -2
- package/lib/types/local-names.js.map +0 -1
- package/lib/types/module-type.d.ts +0 -1
- package/lib/types/module-type.js +0 -2
- package/lib/types/module-type.js.map +0 -1
- package/lib/types/parsed-gir.d.ts +0 -4
- package/lib/types/parsed-gir.js +0 -2
- package/lib/types/parsed-gir.js.map +0 -1
- package/lib/types/part-of-class.d.ts +0 -7
- package/lib/types/part-of-class.js +0 -2
- package/lib/types/part-of-class.js.map +0 -1
- package/lib/types/part-of-module.d.ts +0 -6
- package/lib/types/part-of-module.js +0 -2
- package/lib/types/part-of-module.js.map +0 -1
- package/lib/types/promisify-func.d.ts +0 -5
- package/lib/types/promisify-func.js +0 -2
- package/lib/types/promisify-func.js.map +0 -1
- package/lib/types/resolve-type.d.ts +0 -4
- package/lib/types/resolve-type.js +0 -6
- package/lib/types/resolve-type.js.map +0 -1
- package/lib/types/sym-table-items.d.ts +0 -4
- package/lib/types/sym-table-items.js +0 -2
- package/lib/types/sym-table-items.js.map +0 -1
- package/lib/types/transformation-case.d.ts +0 -1
- package/lib/types/transformation-case.js +0 -2
- package/lib/types/transformation-case.js.map +0 -1
- package/lib/types/transformations.d.ts +0 -11
- package/lib/types/transformations.js +0 -2
- package/lib/types/transformations.js.map +0 -1
- package/lib/types/ts-alias.d.ts +0 -10
- package/lib/types/ts-alias.js +0 -2
- package/lib/types/ts-alias.js.map +0 -1
- package/lib/types/ts-callback-interface.d.ts +0 -10
- package/lib/types/ts-callback-interface.js +0 -2
- package/lib/types/ts-callback-interface.js.map +0 -1
- package/lib/types/ts-callback.d.ts +0 -17
- package/lib/types/ts-callback.js +0 -2
- package/lib/types/ts-callback.js.map +0 -1
- package/lib/types/ts-class.d.ts +0 -85
- package/lib/types/ts-class.js +0 -2
- package/lib/types/ts-class.js.map +0 -1
- package/lib/types/ts-doc-tag.d.ts +0 -21
- package/lib/types/ts-doc-tag.js +0 -2
- package/lib/types/ts-doc-tag.js.map +0 -1
- package/lib/types/ts-doc.d.ts +0 -20
- package/lib/types/ts-doc.js +0 -2
- package/lib/types/ts-doc.js.map +0 -1
- package/lib/types/ts-enum.d.ts +0 -12
- package/lib/types/ts-enum.js +0 -2
- package/lib/types/ts-enum.js.map +0 -1
- package/lib/types/ts-function.d.ts +0 -44
- package/lib/types/ts-function.js +0 -2
- package/lib/types/ts-function.js.map +0 -1
- package/lib/types/ts-generic-parameter.d.ts +0 -8
- package/lib/types/ts-generic-parameter.js +0 -2
- package/lib/types/ts-generic-parameter.js.map +0 -1
- package/lib/types/ts-instance-parameter.d.ts +0 -4
- package/lib/types/ts-instance-parameter.js +0 -2
- package/lib/types/ts-instance-parameter.js.map +0 -1
- package/lib/types/ts-member.d.ts +0 -10
- package/lib/types/ts-member.js +0 -2
- package/lib/types/ts-member.js.map +0 -1
- package/lib/types/ts-method.d.ts +0 -5
- package/lib/types/ts-method.js +0 -2
- package/lib/types/ts-method.js.map +0 -1
- package/lib/types/ts-parameter.d.ts +0 -15
- package/lib/types/ts-parameter.js +0 -2
- package/lib/types/ts-parameter.js.map +0 -1
- package/lib/types/ts-property.d.ts +0 -17
- package/lib/types/ts-property.js +0 -2
- package/lib/types/ts-property.js.map +0 -1
- package/lib/types/ts-signal.d.ts +0 -17
- package/lib/types/ts-signal.js +0 -2
- package/lib/types/ts-signal.js.map +0 -1
- package/lib/types/ts-type-name.d.ts +0 -1
- package/lib/types/ts-type-name.js +0 -2
- package/lib/types/ts-type-name.js.map +0 -1
- package/lib/types/ts-type-separator.d.ts +0 -1
- package/lib/types/ts-type-separator.js +0 -2
- package/lib/types/ts-type-separator.js.map +0 -1
- package/lib/types/ts-type.d.ts +0 -22
- package/lib/types/ts-type.js +0 -2
- package/lib/types/ts-type.js.map +0 -1
- package/lib/types/ts-var.d.ts +0 -17
- package/lib/types/ts-var.js +0 -2
- package/lib/types/ts-var.js.map +0 -1
- package/lib/types/type-gir-alias.d.ts +0 -2
- package/lib/types/type-gir-alias.js +0 -2
- package/lib/types/type-gir-alias.js.map +0 -1
- package/lib/types/type-gir-class.d.ts +0 -2
- package/lib/types/type-gir-class.js +0 -2
- package/lib/types/type-gir-class.js.map +0 -1
- package/lib/types/type-gir-element.d.ts +0 -3
- package/lib/types/type-gir-element.js +0 -2
- package/lib/types/type-gir-element.js.map +0 -1
- package/lib/types/type-gir-enumeration-member.d.ts +0 -2
- package/lib/types/type-gir-enumeration-member.js +0 -2
- package/lib/types/type-gir-enumeration-member.js.map +0 -1
- package/lib/types/type-gir-enumeration.d.ts +0 -2
- package/lib/types/type-gir-enumeration.js +0 -2
- package/lib/types/type-gir-enumeration.js.map +0 -1
- package/lib/types/type-gir-function.d.ts +0 -1
- package/lib/types/type-gir-function.js +0 -2
- package/lib/types/type-gir-function.js.map +0 -1
- package/lib/types/type-gir-interface.d.ts +0 -2
- package/lib/types/type-gir-interface.js +0 -2
- package/lib/types/type-gir-interface.js.map +0 -1
- package/lib/types/type-gir-method.d.ts +0 -2
- package/lib/types/type-gir-method.js +0 -2
- package/lib/types/type-gir-method.js.map +0 -1
- package/lib/types/type-gir-parameter.d.ts +0 -1
- package/lib/types/type-gir-parameter.js +0 -2
- package/lib/types/type-gir-parameter.js.map +0 -1
- package/lib/types/type-gir-property.d.ts +0 -2
- package/lib/types/type-gir-property.js +0 -2
- package/lib/types/type-gir-property.js.map +0 -1
- package/lib/types/type-gir-variable.d.ts +0 -1
- package/lib/types/type-gir-variable.js +0 -2
- package/lib/types/type-gir-variable.js.map +0 -1
- package/lib/types/type-ts-element.d.ts +0 -3
- package/lib/types/type-ts-element.js +0 -2
- package/lib/types/type-ts-element.js.map +0 -1
- package/lib/types/type-ts-enumeration-member.d.ts +0 -2
- package/lib/types/type-ts-enumeration-member.js +0 -2
- package/lib/types/type-ts-enumeration-member.js.map +0 -1
- package/lib/types/type-ts-function.d.ts +0 -1
- package/lib/types/type-ts-function.js +0 -2
- package/lib/types/type-ts-function.js.map +0 -1
- package/lib/types/type-ts-property.d.ts +0 -1
- package/lib/types/type-ts-property.js +0 -2
- package/lib/types/type-ts-property.js.map +0 -1
- package/lib/types/user-config-load-result.d.ts +0 -6
- package/lib/types/user-config-load-result.js +0 -2
- package/lib/types/user-config-load-result.js.map +0 -1
- package/lib/types/user-config.d.ts +0 -40
- package/lib/types/user-config.js +0 -2
- package/lib/types/user-config.js.map +0 -1
- package/src/conflict-resolver.ts +0 -1358
- package/src/constants.ts +0 -29
- package/src/dependency-manager.ts +0 -91
- package/src/generator.ts +0 -10
- package/src/gir-factory.ts +0 -499
- package/src/gir-module.ts +0 -2827
- package/src/html-doc-generator.ts +0 -23
- package/src/injection/callbacks/gjs/Gio-2.0.ts +0 -37
- package/src/injection/callbacks/gjs/index.ts +0 -5
- package/src/injection/callbacks/index.ts +0 -6
- package/src/injection/callbacks/node-gtk/index.ts +0 -3
- package/src/injection/classes/GLib-2-0.ts +0 -36
- package/src/injection/classes/gjs/GLib-2.0.ts +0 -201
- package/src/injection/classes/gjs/GObject-2.0.ts +0 -635
- package/src/injection/classes/gjs/Gio-2.0.ts +0 -219
- package/src/injection/classes/gjs/index.ts +0 -7
- package/src/injection/classes/index.ts +0 -7
- package/src/injection/classes/node-gtk/GLib-2.0.ts +0 -20
- package/src/injection/classes/node-gtk/GObject-2.0.ts +0 -67
- package/src/injection/classes/node-gtk/Gdk-4.0.ts +0 -33
- package/src/injection/classes/node-gtk/Gio-2.0.ts +0 -15
- package/src/injection/classes/node-gtk/Graphene-1.0.ts +0 -134
- package/src/injection/classes/node-gtk/Gtk-3.0.ts +0 -32
- package/src/injection/classes/node-gtk/Gtk-4.0.ts +0 -53
- package/src/injection/classes/node-gtk/Pango-1.0.ts +0 -32
- package/src/injection/classes/node-gtk/index.ts +0 -21
- package/src/injection/index.ts +0 -3
- package/src/injection/injector.ts +0 -184
- package/src/logger.ts +0 -134
- package/src/messages.ts +0 -69
- package/src/symtable.ts +0 -72
- package/src/template-processor.ts +0 -199
- package/src/transformation.ts +0 -583
- package/src/type-definition-generator.ts +0 -1460
- package/src/types/answer-version.ts +0 -4
- package/src/types/build-type.ts +0 -1
- package/src/types/class-parent.ts +0 -14
- package/src/types/config-flags.ts +0 -5
- package/src/types/conflict-child-element.ts +0 -11
- package/src/types/conflict-grouped-element.ts +0 -7
- package/src/types/conflict-grouped-elements.ts +0 -5
- package/src/types/construct-name.ts +0 -11
- package/src/types/dependency-map.ts +0 -4
- package/src/types/dependency.ts +0 -16
- package/src/types/environment.ts +0 -1
- package/src/types/file-info.ts +0 -14
- package/src/types/generate-config.ts +0 -33
- package/src/types/generator-type.ts +0 -4
- package/src/types/gir-alias-element.ts +0 -15
- package/src/types/gir-annotation.ts +0 -10
- package/src/types/gir-any-element.ts +0 -35
- package/src/types/gir-any-type.ts +0 -7
- package/src/types/gir-array-type.ts +0 -23
- package/src/types/gir-bitfield-element.ts +0 -20
- package/src/types/gir-boolean.ts +0 -1
- package/src/types/gir-boxed-element.ts +0 -19
- package/src/types/gir-c-include.ts +0 -7
- package/src/types/gir-callable-attrs.ts +0 -19
- package/src/types/gir-callable-param-element.ts +0 -45
- package/src/types/gir-callable-param.ts +0 -9
- package/src/types/gir-callable-return.ts +0 -25
- package/src/types/gir-callback-element.ts +0 -28
- package/src/types/gir-class-element.ts +0 -71
- package/src/types/gir-constant-element.ts +0 -17
- package/src/types/gir-constructor-element.ts +0 -18
- package/src/types/gir-direction.ts +0 -5
- package/src/types/gir-doc-element.ts +0 -73
- package/src/types/gir-enum-element.ts +0 -28
- package/src/types/gir-field-element.ts +0 -31
- package/src/types/gir-function-element.ts +0 -19
- package/src/types/gir-implements.ts +0 -9
- package/src/types/gir-include.ts +0 -9
- package/src/types/gir-info-attrs.ts +0 -16
- package/src/types/gir-info-elements.ts +0 -8
- package/src/types/gir-instance-parameter.ts +0 -25
- package/src/types/gir-interface-element.ts +0 -53
- package/src/types/gir-member-element.ts +0 -19
- package/src/types/gir-method-element.ts +0 -25
- package/src/types/gir-module-resolved-by.ts +0 -11
- package/src/types/gir-modules-grouped-map.ts +0 -5
- package/src/types/gir-modules-grouped.ts +0 -13
- package/src/types/gir-namespace.ts +0 -47
- package/src/types/gir-package.ts +0 -7
- package/src/types/gir-prerequisite.ts +0 -5
- package/src/types/gir-property-element.ts +0 -31
- package/src/types/gir-record-element.ts +0 -47
- package/src/types/gir-repository.ts +0 -20
- package/src/types/gir-signal.ts +0 -43
- package/src/types/gir-transfer-ownership-type.ts +0 -5
- package/src/types/gir-transfer-ownership.ts +0 -6
- package/src/types/gir-type.ts +0 -16
- package/src/types/gir-union-element.ts +0 -35
- package/src/types/gir-unparsed-number.ts +0 -2
- package/src/types/gir-var-args.ts +0 -6
- package/src/types/gir-virtual-method.ts +0 -22
- package/src/types/index.ts +0 -119
- package/src/types/inheritance-table.ts +0 -3
- package/src/types/injection-callback.ts +0 -20
- package/src/types/injection-class.ts +0 -30
- package/src/types/injection-function.ts +0 -23
- package/src/types/injection-generic-parameter.ts +0 -3
- package/src/types/injection-instance-parameter.ts +0 -3
- package/src/types/injection-parameter.ts +0 -9
- package/src/types/injection-property.ts +0 -7
- package/src/types/injection-type.ts +0 -3
- package/src/types/injection.ts +0 -6
- package/src/types/local-name-check.ts +0 -5
- package/src/types/local-name-type.ts +0 -1
- package/src/types/local-name.ts +0 -8
- package/src/types/local-names.ts +0 -5
- package/src/types/module-type.ts +0 -1
- package/src/types/parsed-gir.ts +0 -5
- package/src/types/part-of-class.ts +0 -9
- package/src/types/part-of-module.ts +0 -8
- package/src/types/resolve-type.ts +0 -4
- package/src/types/sym-table-items.ts +0 -5
- package/src/types/transformation-case.ts +0 -7
- package/src/types/transformations.ts +0 -12
- package/src/types/ts-alias.ts +0 -11
- package/src/types/ts-callback-interface.ts +0 -11
- package/src/types/ts-callback.ts +0 -21
- package/src/types/ts-class.ts +0 -109
- package/src/types/ts-doc-tag.ts +0 -23
- package/src/types/ts-doc.ts +0 -23
- package/src/types/ts-enum.ts +0 -15
- package/src/types/ts-function.ts +0 -59
- package/src/types/ts-generic-parameter.ts +0 -8
- package/src/types/ts-instance-parameter.ts +0 -4
- package/src/types/ts-member.ts +0 -11
- package/src/types/ts-method.ts +0 -6
- package/src/types/ts-parameter.ts +0 -20
- package/src/types/ts-property.ts +0 -22
- package/src/types/ts-signal.ts +0 -21
- package/src/types/ts-type-name.ts +0 -1
- package/src/types/ts-type-separator.ts +0 -1
- package/src/types/ts-type.ts +0 -25
- package/src/types/ts-var.ts +0 -21
- package/src/types/type-gir-alias.ts +0 -2
- package/src/types/type-gir-class.ts +0 -2
- package/src/types/type-gir-element.ts +0 -25
- package/src/types/type-gir-enumeration-member.ts +0 -2
- package/src/types/type-gir-enumeration.ts +0 -2
- package/src/types/type-gir-function.ts +0 -8
- package/src/types/type-gir-interface.ts +0 -2
- package/src/types/type-gir-method.ts +0 -2
- package/src/types/type-gir-parameter.ts +0 -1
- package/src/types/type-gir-property.ts +0 -2
- package/src/types/type-gir-variable.ts +0 -1
- package/src/types/type-ts-element.ts +0 -13
- package/src/types/type-ts-enumeration-member.ts +0 -2
- package/src/types/type-ts-function.ts +0 -1
- package/src/types/type-ts-property.ts +0 -1
- package/src/types/user-config-load-result.ts +0 -6
- package/src/types/user-config.ts +0 -41
- package/templates/Cogl-2.0.d.ts +0 -0
- package/templates/Gjs/GObject-2.0.d.ts +0 -238
- package/templates/Gjs/Gio-2.0.d.ts +0 -64
- package/templates/Gjs/Gjs.d.ts +0 -204
- package/templates/Gjs/Gjs.js +0 -21
- package/templates/Gjs/GnomeShell.d.ts +0 -152
- package/templates/Gjs/GnomeShell.js +0 -10
- package/templates/Gjs/index.d.ts +0 -594
- package/templates/Gjs/index.js +0 -4
- package/templates/Gjs/misc/dbusUtils.d.ts +0 -15
- package/templates/Gjs/misc/dbusUtils.js +0 -6
- package/templates/Gjs/misc/extensionUtils.d.ts +0 -99
- package/templates/Gjs/misc/extensionUtils.js +0 -6
- package/templates/Gjs/misc/fileUtils.d.ts +0 -51
- package/templates/Gjs/misc/fileUtils.js +0 -6
- package/templates/Gjs/misc/gnomeSession.d.ts +0 -74
- package/templates/Gjs/misc/gnomeSession.js +0 -6
- package/templates/Gjs/misc/parentalControlsManager.d.ts +0 -42
- package/templates/Gjs/misc/parentalControlsManager.js +0 -6
- package/templates/Gjs/misc/signals.d.ts +0 -15
- package/templates/Gjs/misc/signals.js +0 -6
- package/templates/Gjs/module.d.ts +0 -6
- package/templates/Gjs/module.js +0 -16
- package/templates/Gjs/tsconfig.alias.json +0 -10
- package/templates/Gjs/ui/accessDialog.d.ts +0 -19
- package/templates/Gjs/ui/accessDialog.js +0 -6
- package/templates/Gjs/ui/altTab.d.ts +0 -124
- package/templates/Gjs/ui/altTab.js +0 -6
- package/templates/Gjs/ui/animation.d.ts +0 -58
- package/templates/Gjs/ui/animation.js +0 -6
- package/templates/Gjs/ui/appDisplay.d.ts +0 -204
- package/templates/Gjs/ui/appDisplay.js +0 -6
- package/templates/Gjs/ui/appFavorites.d.ts +0 -34
- package/templates/Gjs/ui/appFavorites.js +0 -6
- package/templates/Gjs/ui/appMenu.d.ts +0 -74
- package/templates/Gjs/ui/appMenu.js +0 -6
- package/templates/Gjs/ui/audioDeviceSelection.d.ts +0 -51
- package/templates/Gjs/ui/audioDeviceSelection.js +0 -6
- package/templates/Gjs/ui/background.d.ts +0 -255
- package/templates/Gjs/ui/background.js +0 -5
- package/templates/Gjs/ui/backgroundMenu.d.ts +0 -19
- package/templates/Gjs/ui/backgroundMenu.js +0 -5
- package/templates/Gjs/ui/barLevel.d.ts +0 -42
- package/templates/Gjs/ui/barLevel.js +0 -5
- package/templates/Gjs/ui/boxpointer.d.ts +0 -103
- package/templates/Gjs/ui/boxpointer.js +0 -5
- package/templates/Gjs/ui/calendar.d.ts +0 -261
- package/templates/Gjs/ui/calendar.js +0 -5
- package/templates/Gjs/ui/components/__init__.d.ts +0 -9
- package/templates/Gjs/ui/components/__init__.js +0 -6
- package/templates/Gjs/ui/components/automountManager.d.ts +0 -8
- package/templates/Gjs/ui/components/automountManager.js +0 -6
- package/templates/Gjs/ui/components/autorunManager.d.ts +0 -8
- package/templates/Gjs/ui/components/autorunManager.js +0 -6
- package/templates/Gjs/ui/components/index.d.ts +0 -6
- package/templates/Gjs/ui/components/index.js +0 -6
- package/templates/Gjs/ui/components/keyring.d.ts +0 -19
- package/templates/Gjs/ui/components/keyring.js +0 -6
- package/templates/Gjs/ui/components/networkAgent.d.ts +0 -10
- package/templates/Gjs/ui/components/networkAgent.js +0 -6
- package/templates/Gjs/ui/components/polkitAgent.d.ts +0 -19
- package/templates/Gjs/ui/components/polkitAgent.js +0 -6
- package/templates/Gjs/ui/components/telepathyClient.d.ts +0 -10
- package/templates/Gjs/ui/components/telepathyClient.js +0 -6
- package/templates/Gjs/ui/dialog.d.ts +0 -78
- package/templates/Gjs/ui/dialog.js +0 -0
- package/templates/Gjs/ui/dnd.d.ts +0 -127
- package/templates/Gjs/ui/dnd.js +0 -6
- package/templates/Gjs/ui/iconGrid.d.ts +0 -172
- package/templates/Gjs/ui/iconGrid.js +0 -6
- package/templates/Gjs/ui/layout.d.ts +0 -311
- package/templates/Gjs/ui/layout.js +0 -6
- package/templates/Gjs/ui/main.d.ts +0 -215
- package/templates/Gjs/ui/main.js +0 -6
- package/templates/Gjs/ui/messageList.d.ts +0 -113
- package/templates/Gjs/ui/messageList.js +0 -6
- package/templates/Gjs/ui/messageTray.d.ts +0 -423
- package/templates/Gjs/ui/messageTray.js +0 -6
- package/templates/Gjs/ui/modalDialog.d.ts +0 -96
- package/templates/Gjs/ui/modalDialog.js +0 -6
- package/templates/Gjs/ui/mpris.d.ts +0 -78
- package/templates/Gjs/ui/mpris.js +0 -6
- package/templates/Gjs/ui/notificationDaemon.d.ts +0 -5
- package/templates/Gjs/ui/notificationDaemon.js +0 -6
- package/templates/Gjs/ui/panel.d.ts +0 -65
- package/templates/Gjs/ui/panel.js +0 -6
- package/templates/Gjs/ui/panelMenu.d.ts +0 -51
- package/templates/Gjs/ui/panelMenu.js +0 -6
- package/templates/Gjs/ui/popupMenu.d.ts +0 -228
- package/templates/Gjs/ui/popupMenu.js +0 -6
- package/templates/Gjs/ui/ripples.d.ts +0 -44
- package/templates/Gjs/ui/ripples.js +0 -6
- package/templates/Gjs/ui/search.d.ts +0 -158
- package/templates/Gjs/ui/search.js +0 -6
- package/templates/Gjs/ui/switcherPopup.d.ts +0 -107
- package/templates/Gjs/ui/switcherPopup.js +0 -6
- package/templates/Gjs/ui/userWidget.d.ts +0 -13
- package/templates/Gjs/ui/userWidget.js +0 -6
- package/templates/Granite-1.0.d.ts +0 -7
- package/templates/Granite-7.0.d.ts +0 -7
- package/templates/GstBase-0.10.d.ts +0 -5
- package/templates/RygelServer-2.6.d.ts +0 -3
- package/templates/node-gtk/GObject-2.0.d.ts +0 -57
- package/templates/node-gtk/index.d.ts +0 -40
- package/templates/node-gtk/index.js +0 -9
- package/templates/node-gtk/module.d.ts +0 -6
- package/templates/node-gtk/module.js +0 -17
|
@@ -1,1460 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
GenerateConfig,
|
|
3
|
-
InheritanceTable,
|
|
4
|
-
GirClassElement,
|
|
5
|
-
GirCallableParamElement,
|
|
6
|
-
GirSignalElement,
|
|
7
|
-
GirEnumElement,
|
|
8
|
-
GirAliasElement,
|
|
9
|
-
GirInterfaceElement,
|
|
10
|
-
GirUnionElement,
|
|
11
|
-
GirModulesGrouped,
|
|
12
|
-
GirRecordElement,
|
|
13
|
-
GirBitfieldElement,
|
|
14
|
-
GirInstanceParameter,
|
|
15
|
-
TsGenericParameter,
|
|
16
|
-
TsType,
|
|
17
|
-
TsDoc,
|
|
18
|
-
TsFunction,
|
|
19
|
-
TsCallback,
|
|
20
|
-
TsSignal,
|
|
21
|
-
TsMember,
|
|
22
|
-
TsVar,
|
|
23
|
-
TsProperty,
|
|
24
|
-
TsParameter,
|
|
25
|
-
} from './types/index.js'
|
|
26
|
-
import { Generator } from './generator.js'
|
|
27
|
-
import type { GirModule } from './gir-module.js'
|
|
28
|
-
import TemplateProcessor from './template-processor.js'
|
|
29
|
-
import { Logger } from './logger.js'
|
|
30
|
-
import {
|
|
31
|
-
generateIndent,
|
|
32
|
-
removeNamespace,
|
|
33
|
-
removeClassModule,
|
|
34
|
-
girElementIsIntrospectable,
|
|
35
|
-
typeIsOptional,
|
|
36
|
-
} from './utils.js'
|
|
37
|
-
import {
|
|
38
|
-
NO_TSDATA,
|
|
39
|
-
WARN_NOT_FOUND_DEPENDENCY_GIR_FILE,
|
|
40
|
-
WARN_IGNORE_MULTIPLE_CALLBACKS,
|
|
41
|
-
WARN_IGNORE_MULTIPLE_FUNC_DESC,
|
|
42
|
-
} from './messages.js'
|
|
43
|
-
|
|
44
|
-
export default class TypeDefinitionGenerator implements Generator {
|
|
45
|
-
protected log: Logger
|
|
46
|
-
constructor(protected readonly config: GenerateConfig) {
|
|
47
|
-
this.log = new Logger(config.environment, config.verbose, TypeDefinitionGenerator.name)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
* @param namespace E.g. 'Gtk'
|
|
53
|
-
* @param packageName E.g. 'Gtk-3.0'
|
|
54
|
-
* @param asExternType Currently only used for node type imports
|
|
55
|
-
*/
|
|
56
|
-
private generateModuleDependenciesImport(namespace: string, packageName: string, asExternType = false): string[] {
|
|
57
|
-
const def: string[] = []
|
|
58
|
-
const sas = !this.config.noNamespace && packageName !== 'Gjs' ? '' : '* as '
|
|
59
|
-
if (this.config.buildType === 'lib') {
|
|
60
|
-
def.push(`import type ${sas}${namespace} from './${packageName}.js';`)
|
|
61
|
-
} else if (this.config.buildType === 'types') {
|
|
62
|
-
if (asExternType) {
|
|
63
|
-
// def.push(`/// <reference types="${packageName}" />`)
|
|
64
|
-
def.push(`import ${namespace} from "${packageName}.js"`)
|
|
65
|
-
} else {
|
|
66
|
-
def.push(`/// <reference path="${packageName}.d.ts" />`)
|
|
67
|
-
def.push(`import type ${sas}${namespace} from './${packageName}.js';`)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return def
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
private generateExport(type: string, name: string, definition: string, indentCount = 0) {
|
|
74
|
-
const exp = !this.config.noNamespace || this.config.buildType === 'types' ? '' : 'export '
|
|
75
|
-
const indent = generateIndent(indentCount)
|
|
76
|
-
if (!definition.startsWith(':')) {
|
|
77
|
-
definition = ' ' + definition
|
|
78
|
-
}
|
|
79
|
-
return `${indent}${exp}${type} ${name}${definition}`
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private generateProperty(tsProp: TsProperty, onlyStatic: boolean, namespace: string, indentCount = 0) {
|
|
83
|
-
if (!tsProp) {
|
|
84
|
-
throw new Error('[generateProperty] Not all required properties set!')
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const desc: string[] = []
|
|
88
|
-
const isStatic = tsProp.isStatic
|
|
89
|
-
|
|
90
|
-
if ((isStatic && !onlyStatic) || (!isStatic && onlyStatic)) {
|
|
91
|
-
return desc
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (!tsProp.hasUnresolvedConflict) {
|
|
95
|
-
desc.push(...this.addGirDocComment(tsProp.doc, indentCount))
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const indent = generateIndent(indentCount)
|
|
99
|
-
const varDesc = this.generateVariable(tsProp, namespace, 0, false)
|
|
100
|
-
const staticStr = isStatic ? 'static ' : ''
|
|
101
|
-
const readonly = tsProp.readonly ? 'readonly ' : ''
|
|
102
|
-
|
|
103
|
-
// temporary solution, will be solved differently later
|
|
104
|
-
const commentOut = tsProp.hasUnresolvedConflict ? '// Has conflict: ' : ''
|
|
105
|
-
|
|
106
|
-
desc.push(`${indent}${commentOut}${staticStr}${readonly}${varDesc}`)
|
|
107
|
-
return desc
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
private generateProperties(
|
|
111
|
-
tsProps: TsProperty[],
|
|
112
|
-
onlyStatic: boolean,
|
|
113
|
-
namespace: string,
|
|
114
|
-
comment: string,
|
|
115
|
-
indentCount = 0,
|
|
116
|
-
) {
|
|
117
|
-
const def: string[] = []
|
|
118
|
-
for (const tsProp of tsProps) {
|
|
119
|
-
def.push(...this.generateProperty(tsProp, onlyStatic, namespace, indentCount))
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (def.length > 0) {
|
|
123
|
-
def.unshift(...this.addInfoComment(comment, indentCount))
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return def
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
private generateVariableCallbackType(tsType: TsType, namespace: string) {
|
|
130
|
-
// The type of a callback is a functions definition
|
|
131
|
-
|
|
132
|
-
let typeStr = 'any'
|
|
133
|
-
|
|
134
|
-
const { callbacks } = tsType
|
|
135
|
-
|
|
136
|
-
if (!callbacks.length) return typeStr
|
|
137
|
-
|
|
138
|
-
if (callbacks.length > 1) {
|
|
139
|
-
this.log.warn(WARN_IGNORE_MULTIPLE_CALLBACKS)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const girCallback = callbacks[0]
|
|
143
|
-
|
|
144
|
-
if (!girCallback._tsData) {
|
|
145
|
-
throw new Error(NO_TSDATA('generateVariableCallbackType'))
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const funcDesc = this.generateFunction(girCallback._tsData, false, namespace, 0)
|
|
149
|
-
|
|
150
|
-
if (girCallback._tsData && funcDesc?.length) {
|
|
151
|
-
if (funcDesc.length > 1) {
|
|
152
|
-
this.log.warn(WARN_IGNORE_MULTIPLE_FUNC_DESC)
|
|
153
|
-
}
|
|
154
|
-
typeStr = funcDesc[0]
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return typeStr
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
private generateVariable(tsVar: TsProperty | TsVar, namespace: string, indentCount = 0, allowCommentOut = true) {
|
|
161
|
-
const indent = generateIndent(indentCount)
|
|
162
|
-
const name = tsVar.name
|
|
163
|
-
const optional = typeIsOptional(tsVar.type)
|
|
164
|
-
|
|
165
|
-
if (!name) {
|
|
166
|
-
throw new Error('[generateVariable] "name" not set!')
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const affix = optional ? '?' : ''
|
|
170
|
-
const typeStr = this.generateTypes(tsVar.type, namespace)
|
|
171
|
-
|
|
172
|
-
// temporary solution, will be solved differently later
|
|
173
|
-
const commentOut = allowCommentOut && tsVar.hasUnresolvedConflict ? '// Has conflict: ' : ''
|
|
174
|
-
|
|
175
|
-
return `${indent}${commentOut}${name}${affix}: ${typeStr}`
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
private generateTypes(tsTypes: TsType[], namespace: string) {
|
|
179
|
-
let def = ''
|
|
180
|
-
for (const tsType of tsTypes) {
|
|
181
|
-
const separator = tsType.leftSeparator || '|'
|
|
182
|
-
const typeStr = this.generateType(tsType, namespace)
|
|
183
|
-
if (!def) {
|
|
184
|
-
def = typeStr
|
|
185
|
-
} else {
|
|
186
|
-
def += ` ${separator} ${typeStr}`
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return def
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
private generateGenericValues(tsType: TsType, namespace: string) {
|
|
193
|
-
// We just use the generic values here
|
|
194
|
-
const genericValues = tsType.generics.map((g) => removeNamespace(g.value || '', namespace)).filter((g) => !!g)
|
|
195
|
-
const genericStr = tsType.generics.length ? `<${genericValues.join(', ')}>` : ''
|
|
196
|
-
return genericStr
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
private generateType(tsType: TsType, namespace: string) {
|
|
200
|
-
let typeName = removeNamespace(tsType.type, namespace)
|
|
201
|
-
|
|
202
|
-
if (tsType.callbacks.length) {
|
|
203
|
-
typeName = this.generateVariableCallbackType(tsType, namespace)
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (!typeName) {
|
|
207
|
-
throw new Error('[generateVariable] "typeName" not set!')
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
let prefix = tsType.isArray ? '[]' : ''
|
|
211
|
-
prefix += tsType.nullable ? ' | null' : ''
|
|
212
|
-
|
|
213
|
-
// We just use the generic values here
|
|
214
|
-
const genericStr = this.generateGenericValues(tsType, namespace)
|
|
215
|
-
|
|
216
|
-
return `${typeName}${genericStr}${prefix}`
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Generates signals from all properties of a base class
|
|
221
|
-
* TODO: Build new `GirSignalElement`s in `gir-module.ts` instead of generate the strings directly
|
|
222
|
-
* @param girClass
|
|
223
|
-
* @param namespace
|
|
224
|
-
* @param indentCount
|
|
225
|
-
* @returns
|
|
226
|
-
*/
|
|
227
|
-
private generateClassPropertySignals(
|
|
228
|
-
girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
|
|
229
|
-
namespace: string,
|
|
230
|
-
indentCount = 1,
|
|
231
|
-
) {
|
|
232
|
-
const def: string[] = []
|
|
233
|
-
|
|
234
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
235
|
-
throw new Error(NO_TSDATA('generateClassPropertySignals'))
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (girClass._tsData?.isDerivedFromGObject) {
|
|
239
|
-
if (girClass._tsData.propertySignalMethods.length > 0) {
|
|
240
|
-
def.push(
|
|
241
|
-
...this.addInfoComment(
|
|
242
|
-
`Class property signals of ${girClass._module?.packageName}.${girClass._fullSymName}`,
|
|
243
|
-
indentCount,
|
|
244
|
-
),
|
|
245
|
-
)
|
|
246
|
-
for (const tsSignalMethod of girClass._tsData.propertySignalMethods) {
|
|
247
|
-
if (!tsSignalMethod) {
|
|
248
|
-
continue
|
|
249
|
-
}
|
|
250
|
-
def.push(...this.generateFunction(tsSignalMethod, false, namespace, indentCount))
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
return def
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
private generateInParameters(
|
|
258
|
-
inParams: GirCallableParamElement[],
|
|
259
|
-
instanceParameters: GirInstanceParameter[],
|
|
260
|
-
namespace: string,
|
|
261
|
-
) {
|
|
262
|
-
const inParamsDef: string[] = []
|
|
263
|
-
|
|
264
|
-
// TODO: Should use of a constructor, and even of an instance, be discouraged?
|
|
265
|
-
for (const instanceParameter of instanceParameters) {
|
|
266
|
-
if (instanceParameter._tsData) {
|
|
267
|
-
let { structFor } = instanceParameter._tsData
|
|
268
|
-
const { name } = instanceParameter._tsData
|
|
269
|
-
const gobject = namespace === 'GObject' || namespace === 'GLib' ? '' : 'GObject.'
|
|
270
|
-
|
|
271
|
-
structFor = removeNamespace(structFor, namespace)
|
|
272
|
-
|
|
273
|
-
const returnTypes = [structFor, 'Function', `${gobject}GType`]
|
|
274
|
-
inParamsDef.push(`${name}: ${returnTypes.join(' | ')}`)
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
for (const inParam of inParams) {
|
|
279
|
-
if (inParam._tsData) inParamsDef.push(...this.generateParameter(inParam._tsData, namespace))
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
return inParamsDef
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
private generateSignals(
|
|
286
|
-
girSignals: GirSignalElement[],
|
|
287
|
-
girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
|
|
288
|
-
namespace: string,
|
|
289
|
-
indentCount = 0,
|
|
290
|
-
) {
|
|
291
|
-
const def: string[] = []
|
|
292
|
-
|
|
293
|
-
for (const girSignal of girSignals) {
|
|
294
|
-
if (girSignal._tsData?.tsMethods?.length) {
|
|
295
|
-
for (const tsSignalMethod of girSignal._tsData?.tsMethods) {
|
|
296
|
-
if (!tsSignalMethod) {
|
|
297
|
-
continue
|
|
298
|
-
}
|
|
299
|
-
def.push(...this.generateFunction(tsSignalMethod, false, namespace, indentCount))
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return def
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Adds documentation comments
|
|
308
|
-
* @see https://github.com/microsoft/tsdoc
|
|
309
|
-
* @param lines
|
|
310
|
-
* @param indentCount
|
|
311
|
-
*/
|
|
312
|
-
private addTSDocCommentLines(lines: string[], indentCount = 0): string[] {
|
|
313
|
-
const def: string[] = []
|
|
314
|
-
const indent = generateIndent(indentCount)
|
|
315
|
-
def.push(`${indent}/**`)
|
|
316
|
-
for (const line of lines) {
|
|
317
|
-
def.push(`${indent} * ${line}`)
|
|
318
|
-
}
|
|
319
|
-
def.push(`${indent} */`)
|
|
320
|
-
return def
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Adds the documentation as comments
|
|
325
|
-
* @see https://github.com/microsoft/tsdoc
|
|
326
|
-
* @param girDoc
|
|
327
|
-
* @param indentCount
|
|
328
|
-
* @param overwriteDoc
|
|
329
|
-
* @returns
|
|
330
|
-
*/
|
|
331
|
-
private addGirDocComment(tsDoc: TsDoc | undefined, indentCount = 0, overwriteDoc?: Partial<TsDoc>) {
|
|
332
|
-
const desc: string[] = []
|
|
333
|
-
const indent = generateIndent(indentCount)
|
|
334
|
-
if (this.config.noComments) {
|
|
335
|
-
return desc
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
const text = overwriteDoc?.text || tsDoc?.text
|
|
339
|
-
const tags = overwriteDoc?.tags || tsDoc?.tags || []
|
|
340
|
-
|
|
341
|
-
if (text) {
|
|
342
|
-
desc.push(`${indent}/**`)
|
|
343
|
-
|
|
344
|
-
if (text) {
|
|
345
|
-
const lines = text.split('\n')
|
|
346
|
-
if (lines.length) {
|
|
347
|
-
for (const line of lines) {
|
|
348
|
-
desc.push(`${indent} * ${line}`)
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
for (const tag of tags) {
|
|
354
|
-
if (tag.paramName) {
|
|
355
|
-
desc.push(`${indent} * @${tag.tagName} ${tag.paramName} ${tag.text}`)
|
|
356
|
-
} else {
|
|
357
|
-
desc.push(`${indent} * @${tag.tagName} ${tag.text}`)
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
desc.push(`${indent} */`)
|
|
361
|
-
}
|
|
362
|
-
return desc
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Adds an info comment, is used for debugging the generated types
|
|
367
|
-
* @param comment
|
|
368
|
-
* @param indentCount
|
|
369
|
-
* @returns
|
|
370
|
-
*/
|
|
371
|
-
private addInfoComment(comment?: string, indentCount = 0) {
|
|
372
|
-
const def: string[] = []
|
|
373
|
-
if (this.config.noDebugComments) {
|
|
374
|
-
return def
|
|
375
|
-
}
|
|
376
|
-
const indent = generateIndent(indentCount)
|
|
377
|
-
if (comment) {
|
|
378
|
-
def.push('')
|
|
379
|
-
def.push(`${indent}// ${comment}`)
|
|
380
|
-
def.push('')
|
|
381
|
-
}
|
|
382
|
-
return def
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* Adds an inline info comment, is used for debugging the generated types
|
|
387
|
-
* @param comment
|
|
388
|
-
* @param indentCount
|
|
389
|
-
* @returns
|
|
390
|
-
*/
|
|
391
|
-
private addInlineInfoComment(comment?: string, indentCount = 0) {
|
|
392
|
-
const def: string[] = []
|
|
393
|
-
if (this.config.noDebugComments) {
|
|
394
|
-
return def
|
|
395
|
-
}
|
|
396
|
-
const indent = generateIndent(indentCount)
|
|
397
|
-
if (comment) {
|
|
398
|
-
def.push(`${indent}/* ${comment} */`)
|
|
399
|
-
}
|
|
400
|
-
return def
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
private mergeDescs(descs: string[], comment?: string, indentCount = 1) {
|
|
404
|
-
const def: string[] = []
|
|
405
|
-
const indent = generateIndent(indentCount)
|
|
406
|
-
|
|
407
|
-
for (const desc of descs) {
|
|
408
|
-
def.push(`${indent}${desc}`)
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
if (def.length > 0) {
|
|
412
|
-
def.unshift(...this.addInfoComment(comment, indentCount))
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
return def
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
private generateParameter(tsParam: TsParameter, namespace: string) {
|
|
419
|
-
if (typeof tsParam?.name !== 'string') {
|
|
420
|
-
throw new Error(NO_TSDATA('generateParameter'))
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
const types = tsParam.type
|
|
424
|
-
const name = tsParam.name
|
|
425
|
-
const typeStr = this.generateTypes(types, namespace)
|
|
426
|
-
const optional = typeIsOptional(types) && !tsParam.isRest
|
|
427
|
-
const affix = optional ? '?' : ''
|
|
428
|
-
const prefix = tsParam.isRest ? '...' : ''
|
|
429
|
-
|
|
430
|
-
return [`${prefix}${name}${affix}: ${typeStr}`]
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
*
|
|
435
|
-
* @param tsGenerics
|
|
436
|
-
* @param isOut If this generic parameters are out do only generate the type parameter names
|
|
437
|
-
* @returns
|
|
438
|
-
*/
|
|
439
|
-
private generateGenericParameters(tsGenerics?: TsGenericParameter[], isOut = false) {
|
|
440
|
-
const desc: string[] = []
|
|
441
|
-
if (!tsGenerics?.length) {
|
|
442
|
-
return ''
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
for (const tsGeneric of tsGenerics) {
|
|
446
|
-
if (!tsGeneric.name) {
|
|
447
|
-
continue
|
|
448
|
-
}
|
|
449
|
-
let genericStr = `${tsGeneric.name}`
|
|
450
|
-
if (!isOut && tsGeneric.extends) {
|
|
451
|
-
genericStr += ` extends ${tsGeneric.extends}`
|
|
452
|
-
}
|
|
453
|
-
if (!isOut && tsGeneric.value) {
|
|
454
|
-
genericStr += ` = ${tsGeneric.value}`
|
|
455
|
-
}
|
|
456
|
-
desc.push(genericStr)
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
return `<${desc.join(', ')}>`
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
private generateOutParameterReturn(girParam: GirCallableParamElement, namespace: string) {
|
|
463
|
-
const desc: string[] = []
|
|
464
|
-
|
|
465
|
-
if (!girParam._tsData) {
|
|
466
|
-
this.log.warn(NO_TSDATA('generateOutParameterReturn'))
|
|
467
|
-
return desc
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
const { name } = girParam._tsData
|
|
471
|
-
const typeStr = this.generateTypes(girParam._tsData.type, namespace)
|
|
472
|
-
|
|
473
|
-
desc.push(`/* ${name} */ ${typeStr}`)
|
|
474
|
-
return desc
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
private generateFunctionReturn(tsFunction: TsFunction | TsCallback | TsSignal, namespace: string) {
|
|
478
|
-
if (tsFunction.name === 'constructor') {
|
|
479
|
-
return ''
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
const overrideReturnType = tsFunction.overrideReturnType
|
|
483
|
-
const outParams = tsFunction.outParams
|
|
484
|
-
const retTypeIsVoid = tsFunction.retTypeIsVoid
|
|
485
|
-
const typeStr = this.generateTypes(tsFunction.returnTypes, namespace)
|
|
486
|
-
|
|
487
|
-
let desc = typeStr
|
|
488
|
-
|
|
489
|
-
if (overrideReturnType) {
|
|
490
|
-
desc = removeNamespace(overrideReturnType, namespace)
|
|
491
|
-
} else if (outParams.length + (retTypeIsVoid ? 0 : 1) > 1) {
|
|
492
|
-
const outParamsDesc: string[] = []
|
|
493
|
-
|
|
494
|
-
if (!retTypeIsVoid) {
|
|
495
|
-
outParamsDesc.push(`/* returnType */ ${typeStr}`)
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
for (const outParam of outParams) {
|
|
499
|
-
outParamsDesc.push(...this.generateOutParameterReturn(outParam, namespace))
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
desc = outParamsDesc.join(', ')
|
|
503
|
-
desc = `[ ${desc} ]`
|
|
504
|
-
} else if (outParams.length === 1 && retTypeIsVoid) {
|
|
505
|
-
desc = this.generateOutParameterReturn(outParams[0], namespace).join(' ')
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
return desc
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
private generateFunction(
|
|
512
|
-
tsFunction: TsFunction | TsCallback | TsSignal | undefined,
|
|
513
|
-
/** If true only generate static functions otherwise generate only non static functions */
|
|
514
|
-
onlyStatic: boolean,
|
|
515
|
-
namespace: string,
|
|
516
|
-
indentCount = 1,
|
|
517
|
-
overloads = true,
|
|
518
|
-
) {
|
|
519
|
-
const def: string[] = []
|
|
520
|
-
const indent = generateIndent(indentCount)
|
|
521
|
-
|
|
522
|
-
if (!tsFunction) {
|
|
523
|
-
this.log.warn(NO_TSDATA('generateFunction'))
|
|
524
|
-
return def
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
let { name } = tsFunction
|
|
528
|
-
const { isStatic } = tsFunction
|
|
529
|
-
|
|
530
|
-
const { isArrowType, isGlobal, inParams, instanceParameters } = tsFunction
|
|
531
|
-
|
|
532
|
-
if ((isStatic && !onlyStatic) || (!isStatic && onlyStatic)) {
|
|
533
|
-
return def
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
if (tsFunction.doc && !tsFunction.hasUnresolvedConflict)
|
|
537
|
-
def.push(...this.addGirDocComment(tsFunction.doc, indentCount))
|
|
538
|
-
|
|
539
|
-
const staticStr = isStatic && tsFunction.name !== 'constructor' ? 'static ' : ''
|
|
540
|
-
|
|
541
|
-
const globalStr = isGlobal ? 'function ' : ''
|
|
542
|
-
const genericStr = this.generateGenericParameters(tsFunction.generics)
|
|
543
|
-
|
|
544
|
-
// temporary solution, will be solved differently later
|
|
545
|
-
const commentOut = tsFunction.hasUnresolvedConflict ? '// Has conflict: ' : ''
|
|
546
|
-
|
|
547
|
-
let exportStr = ''
|
|
548
|
-
// `tsType === 'function'` are a global methods which can be exported
|
|
549
|
-
if (isGlobal) {
|
|
550
|
-
exportStr = !this.config.noNamespace || this.config.buildType === 'types' ? '' : 'export '
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
const returnType = this.generateFunctionReturn(tsFunction, namespace)
|
|
554
|
-
|
|
555
|
-
let retSep = ''
|
|
556
|
-
if (returnType) {
|
|
557
|
-
if (isArrowType) {
|
|
558
|
-
name = ''
|
|
559
|
-
retSep = ' =>'
|
|
560
|
-
} else {
|
|
561
|
-
retSep = ':'
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
const inParamsDef: string[] = this.generateInParameters(inParams, instanceParameters, namespace)
|
|
566
|
-
|
|
567
|
-
def.push(
|
|
568
|
-
`${indent}${commentOut}${exportStr}${staticStr}${globalStr}${name}${genericStr}(${inParamsDef.join(
|
|
569
|
-
', ',
|
|
570
|
-
)})${retSep} ${returnType}`,
|
|
571
|
-
)
|
|
572
|
-
|
|
573
|
-
// Add overloaded methods
|
|
574
|
-
if (overloads && tsFunction.overloads.length > 0) {
|
|
575
|
-
def.push(...this.addInfoComment(`Overloads of ${name}`, indentCount))
|
|
576
|
-
for (const func of tsFunction.overloads) {
|
|
577
|
-
def.push(...this.generateFunction(func, onlyStatic, namespace, indentCount, false))
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
return def
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
private generateFunctions(
|
|
585
|
-
tsFunctions: TsFunction[],
|
|
586
|
-
onlyStatic: boolean,
|
|
587
|
-
namespace: string,
|
|
588
|
-
indentCount = 1,
|
|
589
|
-
comment?: string,
|
|
590
|
-
) {
|
|
591
|
-
const def: string[] = []
|
|
592
|
-
|
|
593
|
-
for (const girFunction of tsFunctions) {
|
|
594
|
-
def.push(...this.generateFunction(girFunction, onlyStatic, namespace, indentCount))
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
if (def.length > 0) {
|
|
598
|
-
def.unshift(...this.addInfoComment(comment, indentCount))
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
return def
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
private generateCallbackInterface(
|
|
605
|
-
tsCallback: TsCallback | TsSignal,
|
|
606
|
-
namespace: string,
|
|
607
|
-
indentCount = 0,
|
|
608
|
-
classModuleName?: string,
|
|
609
|
-
) {
|
|
610
|
-
const def: string[] = []
|
|
611
|
-
|
|
612
|
-
if (!tsCallback?.tsCallbackInterface) {
|
|
613
|
-
this.log.warn(NO_TSDATA('generateCallbackInterface'))
|
|
614
|
-
return def
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
def.push(...this.addGirDocComment(tsCallback.doc, indentCount, tsCallback.tsCallbackInterface.overwriteDoc))
|
|
618
|
-
|
|
619
|
-
const indent = generateIndent(indentCount)
|
|
620
|
-
const indentBody = generateIndent(indentCount + 1)
|
|
621
|
-
const { inParams, instanceParameters } = tsCallback
|
|
622
|
-
const returnTypeStr = this.generateTypes(tsCallback.returnTypes, namespace)
|
|
623
|
-
|
|
624
|
-
// Get name, remove namespace and remove module class name prefix
|
|
625
|
-
let { name } = tsCallback.tsCallbackInterface
|
|
626
|
-
const { generics } = tsCallback.tsCallbackInterface
|
|
627
|
-
name = removeNamespace(name, namespace)
|
|
628
|
-
if (classModuleName) name = removeClassModule(name, classModuleName)
|
|
629
|
-
const genericParameters = this.generateGenericParameters(generics)
|
|
630
|
-
|
|
631
|
-
const inParamsDef: string[] = this.generateInParameters(inParams, instanceParameters, namespace)
|
|
632
|
-
|
|
633
|
-
const interfaceHead = `${name}${genericParameters}`
|
|
634
|
-
|
|
635
|
-
def.push(this.generateExport('interface', `${interfaceHead}`, '{', indentCount))
|
|
636
|
-
def.push(`${indentBody}(${inParamsDef.join(', ')}): ${returnTypeStr}`)
|
|
637
|
-
def.push(indent + '}')
|
|
638
|
-
|
|
639
|
-
return def
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
private generateCallbackInterfaces(
|
|
643
|
-
tsCallbacks: Array<TsCallback | TsSignal>,
|
|
644
|
-
namespace: string,
|
|
645
|
-
indentCount = 0,
|
|
646
|
-
classModuleName: string,
|
|
647
|
-
comment?: string,
|
|
648
|
-
) {
|
|
649
|
-
const def: string[] = []
|
|
650
|
-
|
|
651
|
-
for (const tsCallback of tsCallbacks) {
|
|
652
|
-
def.push(...this.generateCallbackInterface(tsCallback, namespace, indentCount, classModuleName), '')
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
if (def.length > 0) {
|
|
656
|
-
def.unshift(...this.addInfoComment(comment, indentCount))
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
return def
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
private generateEnumeration(girEnum: GirEnumElement | GirBitfieldElement, indentCount = 0) {
|
|
663
|
-
const desc: string[] = []
|
|
664
|
-
|
|
665
|
-
if (!girElementIsIntrospectable(girEnum)) {
|
|
666
|
-
return desc
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
if (!girEnum._tsData) {
|
|
670
|
-
this.log.warn(NO_TSDATA('generateEnumeration'))
|
|
671
|
-
return desc
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
desc.push(...this.addGirDocComment(girEnum._tsData.doc, indentCount))
|
|
675
|
-
|
|
676
|
-
const { name } = girEnum._tsData
|
|
677
|
-
desc.push(this.generateExport('enum', name, '{', indentCount))
|
|
678
|
-
if (girEnum.member) {
|
|
679
|
-
for (const girEnumMember of girEnum.member) {
|
|
680
|
-
if (!girEnumMember._tsData) continue
|
|
681
|
-
desc.push(...this.generateEnumerationMember(girEnumMember._tsData, indentCount + 1))
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
desc.push('}')
|
|
685
|
-
return desc
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
private generateEnumerationMember(tsMember: TsMember, indentCount = 1) {
|
|
689
|
-
const desc: string[] = []
|
|
690
|
-
|
|
691
|
-
if (!tsMember) {
|
|
692
|
-
this.log.warn(NO_TSDATA('generateEnumerationMember'))
|
|
693
|
-
return desc
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
desc.push(...this.addGirDocComment(tsMember.doc, indentCount))
|
|
697
|
-
|
|
698
|
-
const indent = generateIndent(indentCount)
|
|
699
|
-
desc.push(`${indent}${tsMember.name},`)
|
|
700
|
-
return desc
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
private generateConstant(tsConst: TsVar, namespace: string, indentCount = 0) {
|
|
704
|
-
const desc: string[] = []
|
|
705
|
-
|
|
706
|
-
if (!tsConst.hasUnresolvedConflict) {
|
|
707
|
-
desc.push(...this.addGirDocComment(tsConst.doc, indentCount))
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
const indent = generateIndent(indentCount)
|
|
711
|
-
const exp = !this.config.noNamespace || this.config.buildType === 'types' ? '' : 'export '
|
|
712
|
-
const varDesc = this.generateVariable(tsConst, namespace, 0)
|
|
713
|
-
desc.push(`${indent}${exp}const ${varDesc}`)
|
|
714
|
-
return desc
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
private generateAlias(girAlias: GirAliasElement, namespace: string, indentCount = 0) {
|
|
718
|
-
const desc: string[] = []
|
|
719
|
-
|
|
720
|
-
if (!girElementIsIntrospectable(girAlias)) {
|
|
721
|
-
return ''
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
if (!girAlias._tsData) {
|
|
725
|
-
this.log.warn(NO_TSDATA('generateAlias'))
|
|
726
|
-
return desc
|
|
727
|
-
}
|
|
728
|
-
const indent = generateIndent(indentCount)
|
|
729
|
-
|
|
730
|
-
const exp = !this.config.noNamespace || this.config.buildType === 'types' ? '' : 'export '
|
|
731
|
-
const type = removeNamespace(girAlias._tsData.type, namespace)
|
|
732
|
-
|
|
733
|
-
desc.push(`${indent}${exp}type ${girAlias._tsData.name} = ${type}`)
|
|
734
|
-
return desc
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
private generateConstructPropsInterface(
|
|
738
|
-
girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
|
|
739
|
-
namespace: string,
|
|
740
|
-
indentCount = 0,
|
|
741
|
-
) {
|
|
742
|
-
const def: string[] = []
|
|
743
|
-
|
|
744
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
745
|
-
throw new Error(NO_TSDATA('generateConstructPropsInterface'))
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
if (!girClass._tsData.isDerivedFromGObject) {
|
|
749
|
-
return def
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
const indent = generateIndent(indentCount)
|
|
753
|
-
const exp = !this.config.noNamespace || this.config.buildType === 'types' ? '' : 'export '
|
|
754
|
-
let ext = ''
|
|
755
|
-
|
|
756
|
-
if (girClass._tsData.inheritConstructPropInterfaceNames.length) {
|
|
757
|
-
const constructPropInterfaceNames = girClass._tsData.inheritConstructPropInterfaceNames.map((n) =>
|
|
758
|
-
removeNamespace(n, namespace),
|
|
759
|
-
)
|
|
760
|
-
ext = `extends ${constructPropInterfaceNames.join(', ')} `
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
// Remove namespace and class module name
|
|
764
|
-
const constructPropInterfaceName = removeClassModule(
|
|
765
|
-
removeNamespace(girClass._tsData.constructPropInterfaceName, namespace),
|
|
766
|
-
girClass._tsData.name,
|
|
767
|
-
)
|
|
768
|
-
|
|
769
|
-
def.push(...this.addInfoComment('Constructor properties interface', indentCount))
|
|
770
|
-
|
|
771
|
-
// START BODY
|
|
772
|
-
{
|
|
773
|
-
def.push(`${indent}${exp}interface ${constructPropInterfaceName} ${ext}{`)
|
|
774
|
-
def.push(
|
|
775
|
-
...this.generateProperties(
|
|
776
|
-
girClass._tsData.constructProps.map((cp) => cp._tsData).filter((cp) => !!cp) as TsProperty[],
|
|
777
|
-
false,
|
|
778
|
-
namespace,
|
|
779
|
-
`Own constructor properties of ${girClass._module.packageName}.${girClass._fullSymName}`,
|
|
780
|
-
indentCount + 1,
|
|
781
|
-
),
|
|
782
|
-
)
|
|
783
|
-
def.push(`${indent}}`, '')
|
|
784
|
-
}
|
|
785
|
-
// END BODY
|
|
786
|
-
|
|
787
|
-
return def
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
private generateClassFields(
|
|
791
|
-
girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
|
|
792
|
-
onlyStatic: boolean,
|
|
793
|
-
namespace: string,
|
|
794
|
-
indentCount = 1,
|
|
795
|
-
) {
|
|
796
|
-
const def: string[] = []
|
|
797
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
798
|
-
throw new Error(NO_TSDATA('generateClassFields'))
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
def.push(
|
|
802
|
-
...this.generateProperties(
|
|
803
|
-
girClass._tsData.fields.map((f) => f._tsData).filter((f) => !!f) as TsProperty[],
|
|
804
|
-
onlyStatic,
|
|
805
|
-
namespace,
|
|
806
|
-
`Own fields of ${girClass._module.packageName}.${girClass._fullSymName}`,
|
|
807
|
-
indentCount,
|
|
808
|
-
),
|
|
809
|
-
)
|
|
810
|
-
|
|
811
|
-
return def
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
private generateClassProperties(
|
|
815
|
-
girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
|
|
816
|
-
onlyStatic: boolean,
|
|
817
|
-
namespace: string,
|
|
818
|
-
indentCount = 1,
|
|
819
|
-
) {
|
|
820
|
-
const def: string[] = []
|
|
821
|
-
|
|
822
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
823
|
-
throw new Error(NO_TSDATA('generateClassProperties'))
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
def.push(
|
|
827
|
-
...this.generateProperties(
|
|
828
|
-
girClass._tsData.properties.map((p) => p._tsData).filter((p) => !!p) as TsProperty[],
|
|
829
|
-
onlyStatic,
|
|
830
|
-
namespace,
|
|
831
|
-
`Own properties of ${girClass._module.packageName}.${girClass._fullSymName}`,
|
|
832
|
-
indentCount,
|
|
833
|
-
),
|
|
834
|
-
)
|
|
835
|
-
|
|
836
|
-
def.push(
|
|
837
|
-
...this.generateProperties(
|
|
838
|
-
girClass._tsData.conflictProperties,
|
|
839
|
-
onlyStatic,
|
|
840
|
-
namespace,
|
|
841
|
-
`Conflicting properties`,
|
|
842
|
-
indentCount,
|
|
843
|
-
),
|
|
844
|
-
)
|
|
845
|
-
|
|
846
|
-
return def
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
private generateClassMethods(
|
|
850
|
-
girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
|
|
851
|
-
onlyStatic: boolean,
|
|
852
|
-
namespace: string,
|
|
853
|
-
indentCount = 1,
|
|
854
|
-
) {
|
|
855
|
-
const def: string[] = []
|
|
856
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
857
|
-
throw new Error(NO_TSDATA('generateClassMethods'))
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
def.push(
|
|
861
|
-
...this.generateFunctions(
|
|
862
|
-
girClass._tsData.methods.map((girFunc) => girFunc._tsData).filter((tsFunc) => !!tsFunc) as TsFunction[],
|
|
863
|
-
onlyStatic,
|
|
864
|
-
namespace,
|
|
865
|
-
indentCount,
|
|
866
|
-
`Owm ${onlyStatic ? 'static ' : ''}methods of ${girClass._module.packageName}.${girClass._fullSymName}`,
|
|
867
|
-
),
|
|
868
|
-
)
|
|
869
|
-
|
|
870
|
-
def.push(
|
|
871
|
-
...this.generateFunctions(
|
|
872
|
-
girClass._tsData.conflictMethods,
|
|
873
|
-
onlyStatic,
|
|
874
|
-
namespace,
|
|
875
|
-
indentCount,
|
|
876
|
-
`Conflicting ${onlyStatic ? 'static ' : ''}methods`,
|
|
877
|
-
),
|
|
878
|
-
)
|
|
879
|
-
|
|
880
|
-
return def
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
private generateClassConstructors(
|
|
884
|
-
girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
|
|
885
|
-
namespace: string,
|
|
886
|
-
indentCount = 1,
|
|
887
|
-
) {
|
|
888
|
-
const def: string[] = []
|
|
889
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
890
|
-
throw new Error(NO_TSDATA('generateClassConstructors'))
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
// Constructors
|
|
894
|
-
def.push(
|
|
895
|
-
...this.generateFunctions(
|
|
896
|
-
girClass._tsData.constructors
|
|
897
|
-
.map((girFunc) => girFunc._tsData)
|
|
898
|
-
.filter((tsFunc) => !!tsFunc) as TsFunction[],
|
|
899
|
-
true,
|
|
900
|
-
namespace,
|
|
901
|
-
indentCount,
|
|
902
|
-
),
|
|
903
|
-
)
|
|
904
|
-
// _init method
|
|
905
|
-
def.push(
|
|
906
|
-
...this.generateFunctions(
|
|
907
|
-
girClass._tsData.constructors
|
|
908
|
-
.map((girFunc) => girFunc._tsData)
|
|
909
|
-
.filter((tsFunc) => !!tsFunc) as TsFunction[],
|
|
910
|
-
false,
|
|
911
|
-
namespace,
|
|
912
|
-
indentCount,
|
|
913
|
-
),
|
|
914
|
-
)
|
|
915
|
-
// Pseudo constructors
|
|
916
|
-
def.push(
|
|
917
|
-
...this.generateFunctions(
|
|
918
|
-
girClass._tsData.staticFunctions
|
|
919
|
-
.map((girFunc) => girFunc._tsData)
|
|
920
|
-
.filter((tsFunc) => !!tsFunc) as TsFunction[],
|
|
921
|
-
true,
|
|
922
|
-
namespace,
|
|
923
|
-
indentCount,
|
|
924
|
-
),
|
|
925
|
-
)
|
|
926
|
-
|
|
927
|
-
if (def.length) {
|
|
928
|
-
def.unshift(
|
|
929
|
-
...this.addInfoComment(
|
|
930
|
-
`Constructors of ${girClass._module.packageName}.${girClass._fullSymName}`,
|
|
931
|
-
indentCount,
|
|
932
|
-
),
|
|
933
|
-
)
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
return def
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
/**
|
|
940
|
-
* Instance methods, vfunc_ prefix
|
|
941
|
-
* @param girClass
|
|
942
|
-
*/
|
|
943
|
-
private generateClassVirtualMethods(
|
|
944
|
-
girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
|
|
945
|
-
namespace: string,
|
|
946
|
-
indentCount = 1,
|
|
947
|
-
) {
|
|
948
|
-
const def: string[] = []
|
|
949
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
950
|
-
throw new Error(NO_TSDATA('generateClassVirtualMethods'))
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
def.push(
|
|
954
|
-
...this.generateFunctions(
|
|
955
|
-
girClass._tsData.virtualMethods
|
|
956
|
-
.map((girFunc) => girFunc._tsData)
|
|
957
|
-
.filter((tsFunc) => !!tsFunc) as TsFunction[],
|
|
958
|
-
false,
|
|
959
|
-
namespace,
|
|
960
|
-
indentCount,
|
|
961
|
-
`Own virtual methods of ${girClass._module.packageName}.${girClass._fullSymName}`,
|
|
962
|
-
),
|
|
963
|
-
)
|
|
964
|
-
|
|
965
|
-
return def
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
private generateClassSignalInterfaces(
|
|
969
|
-
girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
|
|
970
|
-
namespace: string,
|
|
971
|
-
indentCount = 0,
|
|
972
|
-
) {
|
|
973
|
-
const def: string[] = []
|
|
974
|
-
if (!girClass._tsData) {
|
|
975
|
-
throw new Error(NO_TSDATA('generateClassSignalInterface'))
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
const tsSignals = girClass._tsData.signals
|
|
979
|
-
.map((signal) => signal._tsData)
|
|
980
|
-
.filter((signal) => !!signal) as TsSignal[]
|
|
981
|
-
|
|
982
|
-
def.push(
|
|
983
|
-
...this.generateCallbackInterfaces(
|
|
984
|
-
tsSignals,
|
|
985
|
-
namespace,
|
|
986
|
-
indentCount,
|
|
987
|
-
girClass._tsData.name,
|
|
988
|
-
'Signal callback interfaces',
|
|
989
|
-
),
|
|
990
|
-
)
|
|
991
|
-
|
|
992
|
-
return def
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
private generateClassSignals(
|
|
996
|
-
girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
|
|
997
|
-
namespace: string,
|
|
998
|
-
) {
|
|
999
|
-
const def: string[] = []
|
|
1000
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
1001
|
-
throw new Error(NO_TSDATA('generateClassSignals'))
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
const signalDescs = this.generateSignals(girClass._tsData.signals, girClass, namespace, 0)
|
|
1005
|
-
|
|
1006
|
-
def.push(
|
|
1007
|
-
...this.mergeDescs(
|
|
1008
|
-
signalDescs,
|
|
1009
|
-
`Own signals of ${girClass._module.packageName}.${girClass._fullSymName}`,
|
|
1010
|
-
1,
|
|
1011
|
-
),
|
|
1012
|
-
)
|
|
1013
|
-
|
|
1014
|
-
return def
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
private generateClassModules(
|
|
1018
|
-
girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
|
|
1019
|
-
namespace: string,
|
|
1020
|
-
indentCount = 0,
|
|
1021
|
-
) {
|
|
1022
|
-
const def: string[] = []
|
|
1023
|
-
const bodyDef: string[] = []
|
|
1024
|
-
if (!girClass._tsData) return def
|
|
1025
|
-
const indent = generateIndent(indentCount)
|
|
1026
|
-
|
|
1027
|
-
const exp = !this.config.noNamespace || this.config.buildType === 'types' ? '' : 'export '
|
|
1028
|
-
|
|
1029
|
-
// Signal interfaces
|
|
1030
|
-
bodyDef.push(...this.generateClassSignalInterfaces(girClass, namespace, indentCount + 1))
|
|
1031
|
-
|
|
1032
|
-
// Properties interface for construction
|
|
1033
|
-
bodyDef.push(...this.generateConstructPropsInterface(girClass, namespace, indentCount + 1))
|
|
1034
|
-
|
|
1035
|
-
if (!bodyDef.length) {
|
|
1036
|
-
return []
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
// START BODY
|
|
1040
|
-
{
|
|
1041
|
-
def.push(`${indent}${exp}module ${girClass._tsData.name} {`)
|
|
1042
|
-
|
|
1043
|
-
// Properties interface for construction
|
|
1044
|
-
def.push(...bodyDef)
|
|
1045
|
-
|
|
1046
|
-
def.push(`${indent}}`, '')
|
|
1047
|
-
}
|
|
1048
|
-
// END BODY
|
|
1049
|
-
|
|
1050
|
-
return def
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
/**
|
|
1054
|
-
* In Typescript, interfaces and classes can have the same name,
|
|
1055
|
-
* so we use this to generate interfaces with the same name to implement multiple inheritance
|
|
1056
|
-
* @param girClass
|
|
1057
|
-
* @param namespace
|
|
1058
|
-
*/
|
|
1059
|
-
private generateImplementationInterface(
|
|
1060
|
-
girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
|
|
1061
|
-
namespace: string,
|
|
1062
|
-
) {
|
|
1063
|
-
const def: string[] = []
|
|
1064
|
-
|
|
1065
|
-
if (!girClass._tsData) return def
|
|
1066
|
-
|
|
1067
|
-
const genericParameters = this.generateGenericParameters(girClass._tsData.generics)
|
|
1068
|
-
const implementationNames = girClass._tsData.parents
|
|
1069
|
-
.filter((implementation) => implementation.type !== 'parent')
|
|
1070
|
-
.map((implementation) => implementation.localParentName)
|
|
1071
|
-
const ext = implementationNames.length ? ` extends ${implementationNames.join(', ')}` : ''
|
|
1072
|
-
const interfaceHead = `${girClass._tsData.name}${genericParameters}${ext}`
|
|
1073
|
-
|
|
1074
|
-
// START INTERFACE
|
|
1075
|
-
{
|
|
1076
|
-
def.push(this.generateExport('interface', interfaceHead, '{'))
|
|
1077
|
-
|
|
1078
|
-
// START BODY
|
|
1079
|
-
{
|
|
1080
|
-
// Properties
|
|
1081
|
-
def.push(...this.generateClassProperties(girClass, false, namespace))
|
|
1082
|
-
|
|
1083
|
-
// Fields
|
|
1084
|
-
def.push(...this.generateClassFields(girClass, false, namespace))
|
|
1085
|
-
|
|
1086
|
-
// Methods
|
|
1087
|
-
def.push(...this.generateClassMethods(girClass, false, namespace))
|
|
1088
|
-
|
|
1089
|
-
// Virtual methods
|
|
1090
|
-
def.push(...this.generateClassVirtualMethods(girClass, namespace))
|
|
1091
|
-
|
|
1092
|
-
// Signals
|
|
1093
|
-
def.push(...this.generateClassSignals(girClass, namespace))
|
|
1094
|
-
|
|
1095
|
-
// TODO: Generate `GirSignalElement`s instead of generate the signal definition strings directly
|
|
1096
|
-
def.push(...this.generateClassPropertySignals(girClass, namespace))
|
|
1097
|
-
}
|
|
1098
|
-
// END BODY
|
|
1099
|
-
|
|
1100
|
-
// END INTERFACE
|
|
1101
|
-
def.push('}')
|
|
1102
|
-
def.push('')
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
return def
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
/**
|
|
1109
|
-
* Represents a record, GObject class or interface as a Typescript class
|
|
1110
|
-
* @param girClass
|
|
1111
|
-
* @param namespace
|
|
1112
|
-
*/
|
|
1113
|
-
private generateClass(
|
|
1114
|
-
girClass: GirClassElement | GirUnionElement | GirInterfaceElement | GirRecordElement,
|
|
1115
|
-
namespace: string,
|
|
1116
|
-
) {
|
|
1117
|
-
const def: string[] = []
|
|
1118
|
-
|
|
1119
|
-
if (!girClass._tsData) return def
|
|
1120
|
-
|
|
1121
|
-
def.push(...this.generateClassModules(girClass, namespace))
|
|
1122
|
-
|
|
1123
|
-
def.push(...this.generateImplementationInterface(girClass, namespace))
|
|
1124
|
-
|
|
1125
|
-
def.push(...this.addGirDocComment(girClass._tsData.doc, 0))
|
|
1126
|
-
|
|
1127
|
-
const genericParameters = this.generateGenericParameters(girClass._tsData.generics)
|
|
1128
|
-
const parentName = girClass._tsData.parents.find((parent) => parent.type === 'parent')?.localParentName
|
|
1129
|
-
const ext = parentName ? ` extends ${parentName}` : ''
|
|
1130
|
-
const classHead = `${girClass._tsData.name}${genericParameters}${ext}`
|
|
1131
|
-
|
|
1132
|
-
// START CLASS
|
|
1133
|
-
{
|
|
1134
|
-
if (girClass._tsData.isAbstract) {
|
|
1135
|
-
def.push(this.generateExport('abstract class', classHead, '{'))
|
|
1136
|
-
} else {
|
|
1137
|
-
def.push(this.generateExport('class', classHead, '{'))
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
// START BODY
|
|
1141
|
-
{
|
|
1142
|
-
// Static Properties
|
|
1143
|
-
def.push(...this.generateClassProperties(girClass, true, namespace))
|
|
1144
|
-
|
|
1145
|
-
// Static Fields
|
|
1146
|
-
def.push(...this.generateClassFields(girClass, true, namespace))
|
|
1147
|
-
|
|
1148
|
-
// Constructors
|
|
1149
|
-
def.push(...this.generateClassConstructors(girClass, namespace))
|
|
1150
|
-
|
|
1151
|
-
// Static Methods
|
|
1152
|
-
def.push(...this.generateClassMethods(girClass, true, namespace))
|
|
1153
|
-
}
|
|
1154
|
-
// END BODY
|
|
1155
|
-
|
|
1156
|
-
// END CLASS
|
|
1157
|
-
def.push('}')
|
|
1158
|
-
def.push('')
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
return def
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
private async exportModuleJS(moduleTemplateProcessor: TemplateProcessor, girModule: GirModule): Promise<void> {
|
|
1165
|
-
const template = 'module.js'
|
|
1166
|
-
if (this.config.outdir) {
|
|
1167
|
-
await moduleTemplateProcessor.create(template, this.config.outdir, `${girModule.packageName}.js`)
|
|
1168
|
-
} else {
|
|
1169
|
-
const moduleContent = moduleTemplateProcessor.load(template)
|
|
1170
|
-
this.log.log(moduleContent)
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
private async exportModuleTS(moduleTemplateProcessor: TemplateProcessor, girModule: GirModule): Promise<void> {
|
|
1175
|
-
const template = 'module.d.ts'
|
|
1176
|
-
const out: string[] = []
|
|
1177
|
-
|
|
1178
|
-
out.push(...this.addTSDocCommentLines([girModule.packageName]))
|
|
1179
|
-
|
|
1180
|
-
out.push('')
|
|
1181
|
-
|
|
1182
|
-
// Module dependencies as type references or imports
|
|
1183
|
-
if (this.config.environment === 'gjs') {
|
|
1184
|
-
out.push(...this.generateModuleDependenciesImport('Gjs', 'Gjs', false))
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
for (const dependency of girModule.transitiveDependencies) {
|
|
1188
|
-
// Don't reference yourself as a dependency
|
|
1189
|
-
if (girModule.packageName !== dependency.packageName) {
|
|
1190
|
-
if (dependency.exists) {
|
|
1191
|
-
out.push(
|
|
1192
|
-
...this.generateModuleDependenciesImport(dependency.namespace, dependency.packageName, false),
|
|
1193
|
-
)
|
|
1194
|
-
} else {
|
|
1195
|
-
out.push(`// WARN: Dependency not found: '${dependency.packageName}'`)
|
|
1196
|
-
this.log.warn(WARN_NOT_FOUND_DEPENDENCY_GIR_FILE(dependency.filename))
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
// START Namespace
|
|
1202
|
-
{
|
|
1203
|
-
if (this.config.buildType === 'types') {
|
|
1204
|
-
out.push('')
|
|
1205
|
-
out.push(`declare namespace ${girModule.namespace} {`)
|
|
1206
|
-
} else if (!this.config.noNamespace) {
|
|
1207
|
-
out.push('')
|
|
1208
|
-
out.push(`export namespace ${girModule.namespace} {`)
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
// Newline
|
|
1212
|
-
out.push('')
|
|
1213
|
-
|
|
1214
|
-
if (girModule.ns.enumeration)
|
|
1215
|
-
for (const girEnum of girModule.ns.enumeration) out.push(...this.generateEnumeration(girEnum))
|
|
1216
|
-
|
|
1217
|
-
if (girModule.ns.bitfield)
|
|
1218
|
-
for (const girBitfield of girModule.ns.bitfield) out.push(...this.generateEnumeration(girBitfield))
|
|
1219
|
-
|
|
1220
|
-
if (girModule.ns.constant)
|
|
1221
|
-
for (const girConst of girModule.ns.constant) {
|
|
1222
|
-
if (!girConst._tsData) continue
|
|
1223
|
-
out.push(...this.generateConstant(girConst._tsData, girModule.namespace, 0))
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1226
|
-
if (girModule.ns.function)
|
|
1227
|
-
for (const girFunc of girModule.ns.function) {
|
|
1228
|
-
if (!girFunc._tsData) {
|
|
1229
|
-
// this.log.warn(NO_TSDATA('exportModuleTS functions'))
|
|
1230
|
-
continue
|
|
1231
|
-
}
|
|
1232
|
-
out.push(...this.generateFunction(girFunc._tsData, false, girModule.namespace, 0))
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
if (girModule.ns.callback)
|
|
1236
|
-
for (const girCallback of girModule.ns.callback) {
|
|
1237
|
-
if (!girCallback._tsData) continue
|
|
1238
|
-
out.push(...this.generateCallbackInterface(girCallback._tsData, girModule.namespace))
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
if (girModule.ns.interface)
|
|
1242
|
-
for (const girIface of girModule.ns.interface)
|
|
1243
|
-
if (girIface._module) {
|
|
1244
|
-
out.push(...this.generateClass(girIface, girIface._module.namespace))
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
// Extra interfaces if a template with the module name (e.g. '../templates/GObject-2.0.d.ts') is found
|
|
1248
|
-
// E.g. used for GObject-2.0 to help define GObject classes in js;
|
|
1249
|
-
// these aren't part of gi.
|
|
1250
|
-
if (moduleTemplateProcessor.exists(`${girModule.packageName}.d.ts`)) {
|
|
1251
|
-
const templatePatches = await moduleTemplateProcessor.load(`${girModule.packageName}.d.ts`)
|
|
1252
|
-
out.push(templatePatches)
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
if (girModule.ns.class)
|
|
1256
|
-
for (const gitClass of girModule.ns.class)
|
|
1257
|
-
if (gitClass._module) {
|
|
1258
|
-
out.push(...this.generateClass(gitClass, gitClass._module.namespace))
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
if (girModule.ns.record)
|
|
1262
|
-
for (const girRecord of girModule.ns.record)
|
|
1263
|
-
if (girRecord._module) {
|
|
1264
|
-
out.push(...this.generateClass(girRecord, girRecord._module.namespace))
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
if (girModule.ns.union)
|
|
1268
|
-
for (const girUnion of girModule.ns.union)
|
|
1269
|
-
if (girUnion._module) {
|
|
1270
|
-
out.push(...this.generateClass(girUnion, girUnion._module.namespace))
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
if (girModule.ns.alias)
|
|
1274
|
-
// GType is not a number in GJS
|
|
1275
|
-
for (const girAlias of girModule.ns.alias)
|
|
1276
|
-
if (girModule.packageName !== 'GObject-2.0' || girAlias.$.name !== 'Type')
|
|
1277
|
-
out.push(...this.generateAlias(girAlias, girModule.namespace, 1))
|
|
1278
|
-
|
|
1279
|
-
if (this.config.environment === 'gjs') {
|
|
1280
|
-
// Properties added to every GIRepositoryNamespace
|
|
1281
|
-
// https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L186-190
|
|
1282
|
-
out.push(
|
|
1283
|
-
...this.generateConstant(
|
|
1284
|
-
{
|
|
1285
|
-
doc: {
|
|
1286
|
-
text: 'Name of the imported GIR library',
|
|
1287
|
-
tags: [
|
|
1288
|
-
{
|
|
1289
|
-
text: 'https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188',
|
|
1290
|
-
tagName: 'see',
|
|
1291
|
-
paramName: '',
|
|
1292
|
-
},
|
|
1293
|
-
],
|
|
1294
|
-
},
|
|
1295
|
-
name: '__name__',
|
|
1296
|
-
type: [
|
|
1297
|
-
{
|
|
1298
|
-
type: 'string',
|
|
1299
|
-
optional: false,
|
|
1300
|
-
nullable: false,
|
|
1301
|
-
callbacks: [],
|
|
1302
|
-
generics: [],
|
|
1303
|
-
isArray: false,
|
|
1304
|
-
isFunction: false,
|
|
1305
|
-
isCallback: false,
|
|
1306
|
-
},
|
|
1307
|
-
],
|
|
1308
|
-
isInjected: false,
|
|
1309
|
-
tsTypeName: 'constant',
|
|
1310
|
-
girTypeName: 'constant',
|
|
1311
|
-
},
|
|
1312
|
-
girModule.namespace,
|
|
1313
|
-
0,
|
|
1314
|
-
),
|
|
1315
|
-
...this.generateConstant(
|
|
1316
|
-
{
|
|
1317
|
-
doc: {
|
|
1318
|
-
text: 'Version of the imported GIR library',
|
|
1319
|
-
tags: [
|
|
1320
|
-
{
|
|
1321
|
-
text: 'https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189',
|
|
1322
|
-
tagName: 'see',
|
|
1323
|
-
paramName: '',
|
|
1324
|
-
},
|
|
1325
|
-
],
|
|
1326
|
-
},
|
|
1327
|
-
name: '__version__',
|
|
1328
|
-
type: [
|
|
1329
|
-
{
|
|
1330
|
-
type: 'string',
|
|
1331
|
-
optional: false,
|
|
1332
|
-
nullable: false,
|
|
1333
|
-
callbacks: [],
|
|
1334
|
-
generics: [],
|
|
1335
|
-
isArray: false,
|
|
1336
|
-
isFunction: false,
|
|
1337
|
-
isCallback: false,
|
|
1338
|
-
},
|
|
1339
|
-
],
|
|
1340
|
-
isInjected: false,
|
|
1341
|
-
tsTypeName: 'constant',
|
|
1342
|
-
girTypeName: 'constant',
|
|
1343
|
-
},
|
|
1344
|
-
girModule.namespace,
|
|
1345
|
-
0,
|
|
1346
|
-
),
|
|
1347
|
-
)
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
// END Namespace
|
|
1351
|
-
if (!this.config.noNamespace) {
|
|
1352
|
-
out.push(`}`)
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
if (!this.config.noNamespace) {
|
|
1356
|
-
out.push(`export default ${girModule.namespace};`)
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
const outResult = out.join('\n') // End of file
|
|
1360
|
-
|
|
1361
|
-
if (this.config.outdir) {
|
|
1362
|
-
await moduleTemplateProcessor.create(
|
|
1363
|
-
template,
|
|
1364
|
-
this.config.outdir,
|
|
1365
|
-
`${girModule.packageName}.d.ts`,
|
|
1366
|
-
outResult,
|
|
1367
|
-
)
|
|
1368
|
-
} else {
|
|
1369
|
-
const moduleContent = await moduleTemplateProcessor.load(template)
|
|
1370
|
-
this.log.log(moduleContent + '\n' + outResult)
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
private async exportModule(girModule: GirModule) {
|
|
1375
|
-
const moduleTemplateProcessor = new TemplateProcessor(
|
|
1376
|
-
{
|
|
1377
|
-
name: girModule.namespace,
|
|
1378
|
-
namespace: girModule.namespace,
|
|
1379
|
-
version: girModule.version,
|
|
1380
|
-
importName: girModule.importName,
|
|
1381
|
-
},
|
|
1382
|
-
girModule.packageName,
|
|
1383
|
-
this.config,
|
|
1384
|
-
)
|
|
1385
|
-
|
|
1386
|
-
await this.exportModuleTS(moduleTemplateProcessor, girModule)
|
|
1387
|
-
|
|
1388
|
-
if (this.config.buildType === 'lib') {
|
|
1389
|
-
await this.exportModuleJS(moduleTemplateProcessor, girModule)
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
private async exportGjs(girModules: GirModule[], girModulesGrouped: GirModulesGrouped[]) {
|
|
1394
|
-
if (!this.config.outdir) return
|
|
1395
|
-
|
|
1396
|
-
const templateProcessor = new TemplateProcessor(
|
|
1397
|
-
{ girModules: girModules, girModulesGrouped, typeDir: this.config.outdir + '/Gjs' },
|
|
1398
|
-
'gjs',
|
|
1399
|
-
this.config,
|
|
1400
|
-
)
|
|
1401
|
-
|
|
1402
|
-
// Types
|
|
1403
|
-
await templateProcessor.create('Gjs.d.ts', this.config.outdir, 'Gjs.d.ts')
|
|
1404
|
-
await templateProcessor.create('index.d.ts', this.config.outdir, 'index.d.ts')
|
|
1405
|
-
if (this.config.gnomeShellTypes) {
|
|
1406
|
-
await templateProcessor.create('GnomeShell.d.ts', this.config.outdir, 'GnomeShell.d.ts')
|
|
1407
|
-
await templateProcessor.createAll('.d.ts', 'misc', this.config.outdir, 'misc')
|
|
1408
|
-
await templateProcessor.createAll('.d.ts', 'ui', this.config.outdir, 'ui')
|
|
1409
|
-
await templateProcessor.createAll('.d.ts', 'ui/components', this.config.outdir, 'ui/components')
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
// Lib
|
|
1413
|
-
if (this.config.buildType === 'lib') {
|
|
1414
|
-
await templateProcessor.create('Gjs.js', this.config.outdir, 'Gjs.js')
|
|
1415
|
-
await templateProcessor.create('index.js', this.config.outdir, 'index.js')
|
|
1416
|
-
if (this.config.gnomeShellTypes) {
|
|
1417
|
-
await templateProcessor.create('GnomeShell.js', this.config.outdir, 'GnomeShell.js')
|
|
1418
|
-
await templateProcessor.createAll('.js', 'misc', this.config.outdir, 'misc')
|
|
1419
|
-
await templateProcessor.createAll('.js', 'ui', this.config.outdir, 'ui')
|
|
1420
|
-
await templateProcessor.createAll('.js', 'ui/components', this.config.outdir, 'ui/components')
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
// Alias
|
|
1425
|
-
if (this.config.generateAlias) {
|
|
1426
|
-
await templateProcessor.create('tsconfig.alias.json', './', 'tsconfig.alias.json', '', false)
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
|
-
private async exportNodeGtk(girModules: GirModule[], girModulesGrouped: GirModulesGrouped[]) {
|
|
1431
|
-
if (!this.config.outdir) return
|
|
1432
|
-
|
|
1433
|
-
const templateProcessor = new TemplateProcessor({ girModules, girModulesGrouped }, 'node', this.config)
|
|
1434
|
-
|
|
1435
|
-
await templateProcessor.create('index.d.ts', this.config.outdir, 'index.d.ts')
|
|
1436
|
-
if (this.config.buildType === 'lib') {
|
|
1437
|
-
await templateProcessor.create('index.js', this.config.outdir, 'index.js')
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
public async start(
|
|
1442
|
-
girModules: GirModule[],
|
|
1443
|
-
girModulesGrouped?: GirModulesGrouped[],
|
|
1444
|
-
inheritanceTable?: InheritanceTable,
|
|
1445
|
-
) {
|
|
1446
|
-
for (const girModule of girModules) {
|
|
1447
|
-
await this.exportModule(girModule)
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
if (this.config.environment === 'node' && girModulesGrouped) {
|
|
1451
|
-
// node-gtk internal stuff
|
|
1452
|
-
await this.exportNodeGtk(girModules, girModulesGrouped)
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
if (this.config.environment === 'gjs' && girModulesGrouped && inheritanceTable) {
|
|
1456
|
-
// GJS internal stuff
|
|
1457
|
-
await this.exportGjs(girModules, girModulesGrouped)
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
}
|