@ts-for-gir/cli 3.0.0-beta.8 → 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 +429 -49
- 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 -39
- package/lib/commands/generate.js +8 -25
- 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 +25 -11
- package/lib/config.js +194 -112
- package/lib/config.js.map +1 -1
- package/lib/generation-handler.d.ts +3 -4
- package/lib/generation-handler.js +8 -12
- 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 +41 -27
- package/lib/module-loader.js +54 -56
- package/lib/module-loader.js.map +1 -1
- package/lib/utils.d.ts +13 -86
- package/lib/utils.js +13 -194
- 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 -25
- package/src/commands/list.ts +8 -10
- package/src/config.ts +211 -115
- package/src/generation-handler.ts +12 -13
- package/src/index.ts +0 -12
- package/src/module-loader.ts +88 -75
- package/src/utils.ts +12 -222
- 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/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 -256
- package/lib/gir-module.js +0 -2075
- 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 -30
- package/lib/messages.js +0 -45
- 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 -75
- package/lib/template-processor.js +0 -207
- 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 -989
- 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 -11
- 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 -14
- 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/generate-config.d.ts +0 -34
- 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 -118
- package/lib/types/index.js +0 -119
- 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/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 -42
- 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/generator.ts +0 -10
- package/src/gir-factory.ts +0 -499
- package/src/gir-module.ts +0 -2816
- 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 -68
- package/src/symtable.ts +0 -70
- package/src/template-processor.ts +0 -233
- package/src/transformation.ts +0 -583
- package/src/type-definition-generator.ts +0 -1458
- package/src/types/answer-version.ts +0 -4
- package/src/types/build-type.ts +0 -1
- package/src/types/class-parent.ts +0 -12
- 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 -14
- package/src/types/environment.ts +0 -1
- package/src/types/generate-config.ts +0 -35
- 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 -118
- 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 -43
- 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 -137
- package/templates/Gjs/Gjs.js +0 -21
- package/templates/Gjs/GnomeShell.d.ts +0 -122
- 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 -49
- package/templates/Gjs/misc/fileUtils.js +0 -6
- package/templates/Gjs/misc/gnomeSession.d.ts +0 -72
- package/templates/Gjs/misc/gnomeSession.js +0 -6
- package/templates/Gjs/module.d.ts +0 -10
- package/templates/Gjs/module.js +0 -16
- package/templates/Gjs/ui/userWidget.d.ts +0 -10
- 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 -10
- package/templates/node-gtk/module.js +0 -17
|
@@ -1,989 +0,0 @@
|
|
|
1
|
-
import TemplateProcessor from './template-processor.js';
|
|
2
|
-
import { Logger } from './logger.js';
|
|
3
|
-
import { generateIndent, findFileInDirs, splitModuleName, removeNamespace, removeClassModule, girElementIsIntrospectable, typeIsOptional, } from './utils.js';
|
|
4
|
-
import { NO_TSDATA, WARN_NOT_FOUND_DEPENDENCY_GIR_FILE, WARN_IGNORE_MULTIPLE_CALLBACKS, WARN_IGNORE_MULTIPLE_FUNC_DESC, } from './messages.js';
|
|
5
|
-
export default class TypeDefinitionGenerator {
|
|
6
|
-
config;
|
|
7
|
-
log;
|
|
8
|
-
constructor(config) {
|
|
9
|
-
this.config = config;
|
|
10
|
-
this.log = new Logger(config.environment, config.verbose, TypeDefinitionGenerator.name);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param namespace E.g. 'Gtk'
|
|
15
|
-
* @param packageName E.g. 'Gtk-3.0'
|
|
16
|
-
* @param asExternType Currently only used for node type imports
|
|
17
|
-
*/
|
|
18
|
-
generateModuleDependenciesImport(namespace, packageName, asExternType = false) {
|
|
19
|
-
const def = [];
|
|
20
|
-
const sas = this.config.useNamespace && packageName !== 'Gjs' ? '' : '* as ';
|
|
21
|
-
if (this.config.buildType === 'lib') {
|
|
22
|
-
def.push(`import type ${sas}${namespace} from './${packageName}.js';`);
|
|
23
|
-
}
|
|
24
|
-
else if (this.config.buildType === 'types') {
|
|
25
|
-
if (asExternType) {
|
|
26
|
-
// def.push(`/// <reference types="${packageName}" />`)
|
|
27
|
-
def.push(`import ${namespace} from "${packageName}.js"`);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
def.push(`/// <reference path="${packageName}.d.ts" />`);
|
|
31
|
-
def.push(`import type ${sas}${namespace} from './${packageName}.js';`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return def;
|
|
35
|
-
}
|
|
36
|
-
generateExport(type, name, definition, indentCount = 0) {
|
|
37
|
-
const exp = this.config.useNamespace || this.config.buildType === 'types' ? '' : 'export ';
|
|
38
|
-
const indent = generateIndent(indentCount);
|
|
39
|
-
if (!definition.startsWith(':')) {
|
|
40
|
-
definition = ' ' + definition;
|
|
41
|
-
}
|
|
42
|
-
return `${indent}${exp}${type} ${name}${definition}`;
|
|
43
|
-
}
|
|
44
|
-
generateProperty(tsProp, onlyStatic, namespace, indentCount = 0) {
|
|
45
|
-
if (!tsProp) {
|
|
46
|
-
throw new Error('[generateProperty] Not all required properties set!');
|
|
47
|
-
}
|
|
48
|
-
const desc = [];
|
|
49
|
-
const isStatic = tsProp.isStatic;
|
|
50
|
-
if ((isStatic && !onlyStatic) || (!isStatic && onlyStatic)) {
|
|
51
|
-
return desc;
|
|
52
|
-
}
|
|
53
|
-
if (!tsProp.hasUnresolvedConflict) {
|
|
54
|
-
desc.push(...this.addGirDocComment(tsProp.doc, indentCount));
|
|
55
|
-
}
|
|
56
|
-
const indent = generateIndent(indentCount);
|
|
57
|
-
const varDesc = this.generateVariable(tsProp, namespace, 0, false);
|
|
58
|
-
const staticStr = isStatic ? 'static ' : '';
|
|
59
|
-
const readonly = tsProp.readonly ? 'readonly ' : '';
|
|
60
|
-
// temporary solution, will be solved differently later
|
|
61
|
-
const commentOut = tsProp.hasUnresolvedConflict ? '// Has conflict: ' : '';
|
|
62
|
-
desc.push(`${indent}${commentOut}${staticStr}${readonly}${varDesc}`);
|
|
63
|
-
return desc;
|
|
64
|
-
}
|
|
65
|
-
generateProperties(tsProps, onlyStatic, namespace, comment, indentCount = 0) {
|
|
66
|
-
const def = [];
|
|
67
|
-
for (const tsProp of tsProps) {
|
|
68
|
-
def.push(...this.generateProperty(tsProp, onlyStatic, namespace, indentCount));
|
|
69
|
-
}
|
|
70
|
-
if (def.length > 0) {
|
|
71
|
-
def.unshift(...this.addInfoComment(comment, indentCount));
|
|
72
|
-
}
|
|
73
|
-
return def;
|
|
74
|
-
}
|
|
75
|
-
generateVariableCallbackType(tsType, namespace) {
|
|
76
|
-
// The type of a callback is a functions definition
|
|
77
|
-
let typeStr = 'any';
|
|
78
|
-
const { callbacks } = tsType;
|
|
79
|
-
if (!callbacks.length)
|
|
80
|
-
return typeStr;
|
|
81
|
-
if (callbacks.length > 1) {
|
|
82
|
-
this.log.warn(WARN_IGNORE_MULTIPLE_CALLBACKS);
|
|
83
|
-
}
|
|
84
|
-
const girCallback = callbacks[0];
|
|
85
|
-
if (!girCallback._tsData) {
|
|
86
|
-
throw new Error(NO_TSDATA('generateVariableCallbackType'));
|
|
87
|
-
}
|
|
88
|
-
const funcDesc = this.generateFunction(girCallback._tsData, false, namespace, 0);
|
|
89
|
-
if (girCallback._tsData && funcDesc?.length) {
|
|
90
|
-
if (funcDesc.length > 1) {
|
|
91
|
-
this.log.warn(WARN_IGNORE_MULTIPLE_FUNC_DESC);
|
|
92
|
-
}
|
|
93
|
-
typeStr = funcDesc[0];
|
|
94
|
-
}
|
|
95
|
-
return typeStr;
|
|
96
|
-
}
|
|
97
|
-
generateVariable(tsVar, namespace, indentCount = 0, allowCommentOut = true) {
|
|
98
|
-
const indent = generateIndent(indentCount);
|
|
99
|
-
const name = tsVar.name;
|
|
100
|
-
const optional = typeIsOptional(tsVar.type);
|
|
101
|
-
if (!name) {
|
|
102
|
-
throw new Error('[generateVariable] "name" not set!');
|
|
103
|
-
}
|
|
104
|
-
const affix = optional ? '?' : '';
|
|
105
|
-
const typeStr = this.generateTypes(tsVar.type, namespace);
|
|
106
|
-
// temporary solution, will be solved differently later
|
|
107
|
-
const commentOut = allowCommentOut && tsVar.hasUnresolvedConflict ? '// Has conflict: ' : '';
|
|
108
|
-
return `${indent}${commentOut}${name}${affix}: ${typeStr}`;
|
|
109
|
-
}
|
|
110
|
-
generateTypes(tsTypes, namespace) {
|
|
111
|
-
let def = '';
|
|
112
|
-
for (const tsType of tsTypes) {
|
|
113
|
-
const separator = tsType.leftSeparator || '|';
|
|
114
|
-
const typeStr = this.generateType(tsType, namespace);
|
|
115
|
-
if (!def) {
|
|
116
|
-
def = typeStr;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
def += ` ${separator} ${typeStr}`;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return def;
|
|
123
|
-
}
|
|
124
|
-
generateGenericValues(tsType, namespace) {
|
|
125
|
-
// We just use the generic values here
|
|
126
|
-
const genericValues = tsType.generics.map((g) => removeNamespace(g.value || '', namespace)).filter((g) => !!g);
|
|
127
|
-
const genericStr = tsType.generics.length ? `<${genericValues.join(', ')}>` : '';
|
|
128
|
-
return genericStr;
|
|
129
|
-
}
|
|
130
|
-
generateType(tsType, namespace) {
|
|
131
|
-
let typeName = removeNamespace(tsType.type, namespace);
|
|
132
|
-
if (tsType.callbacks.length) {
|
|
133
|
-
typeName = this.generateVariableCallbackType(tsType, namespace);
|
|
134
|
-
}
|
|
135
|
-
if (!typeName) {
|
|
136
|
-
throw new Error('[generateVariable] "typeName" not set!');
|
|
137
|
-
}
|
|
138
|
-
let prefix = tsType.isArray ? '[]' : '';
|
|
139
|
-
prefix += tsType.nullable ? ' | null' : '';
|
|
140
|
-
// We just use the generic values here
|
|
141
|
-
const genericStr = this.generateGenericValues(tsType, namespace);
|
|
142
|
-
return `${typeName}${genericStr}${prefix}`;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Generates signals from all properties of a base class
|
|
146
|
-
* TODO: Build new `GirSignalElement`s in `gir-module.ts` instead of generate the strings directly
|
|
147
|
-
* @param girClass
|
|
148
|
-
* @param namespace
|
|
149
|
-
* @param indentCount
|
|
150
|
-
* @returns
|
|
151
|
-
*/
|
|
152
|
-
generateClassPropertySignals(girClass, namespace, indentCount = 1) {
|
|
153
|
-
const def = [];
|
|
154
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
155
|
-
throw new Error(NO_TSDATA('generateClassPropertySignals'));
|
|
156
|
-
}
|
|
157
|
-
if (girClass._tsData?.isDerivedFromGObject) {
|
|
158
|
-
if (girClass._tsData.propertySignalMethods.length > 0) {
|
|
159
|
-
def.push(...this.addInfoComment(`Class property signals of ${girClass._module?.packageName}.${girClass._fullSymName}`, indentCount));
|
|
160
|
-
for (const tsSignalMethod of girClass._tsData.propertySignalMethods) {
|
|
161
|
-
if (!tsSignalMethod) {
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
def.push(...this.generateFunction(tsSignalMethod, false, namespace, indentCount));
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return def;
|
|
169
|
-
}
|
|
170
|
-
generateInParameters(inParams, instanceParameters, namespace) {
|
|
171
|
-
const inParamsDef = [];
|
|
172
|
-
// TODO: Should use of a constructor, and even of an instance, be discouraged?
|
|
173
|
-
for (const instanceParameter of instanceParameters) {
|
|
174
|
-
if (instanceParameter._tsData) {
|
|
175
|
-
let { structFor } = instanceParameter._tsData;
|
|
176
|
-
const { name } = instanceParameter._tsData;
|
|
177
|
-
const gobject = namespace === 'GObject' || namespace === 'GLib' ? '' : 'GObject.';
|
|
178
|
-
structFor = removeNamespace(structFor, namespace);
|
|
179
|
-
const returnTypes = [structFor, 'Function', `${gobject}GType`];
|
|
180
|
-
inParamsDef.push(`${name}: ${returnTypes.join(' | ')}`);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
for (const inParam of inParams) {
|
|
184
|
-
if (inParam._tsData)
|
|
185
|
-
inParamsDef.push(...this.generateParameter(inParam._tsData, namespace));
|
|
186
|
-
}
|
|
187
|
-
return inParamsDef;
|
|
188
|
-
}
|
|
189
|
-
generateSignals(girSignals, girClass, namespace, indentCount = 0) {
|
|
190
|
-
const def = [];
|
|
191
|
-
for (const girSignal of girSignals) {
|
|
192
|
-
if (girSignal._tsData?.tsMethods?.length) {
|
|
193
|
-
for (const tsSignalMethod of girSignal._tsData?.tsMethods) {
|
|
194
|
-
if (!tsSignalMethod) {
|
|
195
|
-
continue;
|
|
196
|
-
}
|
|
197
|
-
def.push(...this.generateFunction(tsSignalMethod, false, namespace, indentCount));
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return def;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Adds documentation comments
|
|
205
|
-
* @see https://github.com/microsoft/tsdoc
|
|
206
|
-
* @param lines
|
|
207
|
-
* @param indentCount
|
|
208
|
-
*/
|
|
209
|
-
addTSDocCommentLines(lines, indentCount = 0) {
|
|
210
|
-
const def = [];
|
|
211
|
-
const indent = generateIndent(indentCount);
|
|
212
|
-
def.push(`${indent}/**`);
|
|
213
|
-
for (const line of lines) {
|
|
214
|
-
def.push(`${indent} * ${line}`);
|
|
215
|
-
}
|
|
216
|
-
def.push(`${indent} */`);
|
|
217
|
-
return def;
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Adds the documentation as comments
|
|
221
|
-
* @see https://github.com/microsoft/tsdoc
|
|
222
|
-
* @param girDoc
|
|
223
|
-
* @param indentCount
|
|
224
|
-
* @param overwriteDoc
|
|
225
|
-
* @returns
|
|
226
|
-
*/
|
|
227
|
-
addGirDocComment(tsDoc, indentCount = 0, overwriteDoc) {
|
|
228
|
-
const desc = [];
|
|
229
|
-
const indent = generateIndent(indentCount);
|
|
230
|
-
if (this.config.noComments) {
|
|
231
|
-
return desc;
|
|
232
|
-
}
|
|
233
|
-
const text = overwriteDoc?.text || tsDoc?.text;
|
|
234
|
-
const tags = overwriteDoc?.tags || tsDoc?.tags || [];
|
|
235
|
-
if (text) {
|
|
236
|
-
desc.push(`${indent}/**`);
|
|
237
|
-
if (text) {
|
|
238
|
-
const lines = text.split('\n');
|
|
239
|
-
if (lines.length) {
|
|
240
|
-
for (const line of lines) {
|
|
241
|
-
desc.push(`${indent} * ${line}`);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
for (const tag of tags) {
|
|
246
|
-
if (tag.paramName) {
|
|
247
|
-
desc.push(`${indent} * @${tag.tagName} ${tag.paramName} ${tag.text}`);
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
desc.push(`${indent} * @${tag.tagName} ${tag.text}`);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
desc.push(`${indent} */`);
|
|
254
|
-
}
|
|
255
|
-
return desc;
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Adds an info comment, is used for debugging the generated types
|
|
259
|
-
* @param comment
|
|
260
|
-
* @param indentCount
|
|
261
|
-
* @returns
|
|
262
|
-
*/
|
|
263
|
-
addInfoComment(comment, indentCount = 0) {
|
|
264
|
-
const def = [];
|
|
265
|
-
if (this.config.noDebugComments) {
|
|
266
|
-
return def;
|
|
267
|
-
}
|
|
268
|
-
const indent = generateIndent(indentCount);
|
|
269
|
-
if (comment) {
|
|
270
|
-
def.push('');
|
|
271
|
-
def.push(`${indent}// ${comment}`);
|
|
272
|
-
def.push('');
|
|
273
|
-
}
|
|
274
|
-
return def;
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Adds an inline info comment, is used for debugging the generated types
|
|
278
|
-
* @param comment
|
|
279
|
-
* @param indentCount
|
|
280
|
-
* @returns
|
|
281
|
-
*/
|
|
282
|
-
addInlineInfoComment(comment, indentCount = 0) {
|
|
283
|
-
const def = [];
|
|
284
|
-
if (this.config.noDebugComments) {
|
|
285
|
-
return def;
|
|
286
|
-
}
|
|
287
|
-
const indent = generateIndent(indentCount);
|
|
288
|
-
if (comment) {
|
|
289
|
-
def.push(`${indent}/* ${comment} */`);
|
|
290
|
-
}
|
|
291
|
-
return def;
|
|
292
|
-
}
|
|
293
|
-
mergeDescs(descs, comment, indentCount = 1) {
|
|
294
|
-
const def = [];
|
|
295
|
-
const indent = generateIndent(indentCount);
|
|
296
|
-
for (const desc of descs) {
|
|
297
|
-
def.push(`${indent}${desc}`);
|
|
298
|
-
}
|
|
299
|
-
if (def.length > 0) {
|
|
300
|
-
def.unshift(...this.addInfoComment(comment, indentCount));
|
|
301
|
-
}
|
|
302
|
-
return def;
|
|
303
|
-
}
|
|
304
|
-
generateParameter(tsParam, namespace) {
|
|
305
|
-
if (typeof tsParam?.name !== 'string') {
|
|
306
|
-
throw new Error(NO_TSDATA('generateParameter'));
|
|
307
|
-
}
|
|
308
|
-
const types = tsParam.type;
|
|
309
|
-
const name = tsParam.name;
|
|
310
|
-
const typeStr = this.generateTypes(types, namespace);
|
|
311
|
-
const optional = typeIsOptional(types) && !tsParam.isRest;
|
|
312
|
-
const affix = optional ? '?' : '';
|
|
313
|
-
const prefix = tsParam.isRest ? '...' : '';
|
|
314
|
-
return [`${prefix}${name}${affix}: ${typeStr}`];
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
*
|
|
318
|
-
* @param tsGenerics
|
|
319
|
-
* @param isOut If this generic parameters are out do only generate the type parameter names
|
|
320
|
-
* @returns
|
|
321
|
-
*/
|
|
322
|
-
generateGenericParameters(tsGenerics, isOut = false) {
|
|
323
|
-
const desc = [];
|
|
324
|
-
if (!tsGenerics?.length) {
|
|
325
|
-
return '';
|
|
326
|
-
}
|
|
327
|
-
for (const tsGeneric of tsGenerics) {
|
|
328
|
-
if (!tsGeneric.name) {
|
|
329
|
-
continue;
|
|
330
|
-
}
|
|
331
|
-
let genericStr = `${tsGeneric.name}`;
|
|
332
|
-
if (!isOut && tsGeneric.extends) {
|
|
333
|
-
genericStr += ` extends ${tsGeneric.extends}`;
|
|
334
|
-
}
|
|
335
|
-
if (!isOut && tsGeneric.value) {
|
|
336
|
-
genericStr += ` = ${tsGeneric.value}`;
|
|
337
|
-
}
|
|
338
|
-
desc.push(genericStr);
|
|
339
|
-
}
|
|
340
|
-
return `<${desc.join(', ')}>`;
|
|
341
|
-
}
|
|
342
|
-
generateOutParameterReturn(girParam, namespace) {
|
|
343
|
-
const desc = [];
|
|
344
|
-
if (!girParam._tsData) {
|
|
345
|
-
this.log.warn(NO_TSDATA('generateOutParameterReturn'));
|
|
346
|
-
return desc;
|
|
347
|
-
}
|
|
348
|
-
const { name } = girParam._tsData;
|
|
349
|
-
const typeStr = this.generateTypes(girParam._tsData.type, namespace);
|
|
350
|
-
desc.push(`/* ${name} */ ${typeStr}`);
|
|
351
|
-
return desc;
|
|
352
|
-
}
|
|
353
|
-
generateFunctionReturn(tsFunction, namespace) {
|
|
354
|
-
if (tsFunction.name === 'constructor') {
|
|
355
|
-
return '';
|
|
356
|
-
}
|
|
357
|
-
const overrideReturnType = tsFunction.overrideReturnType;
|
|
358
|
-
const outParams = tsFunction.outParams;
|
|
359
|
-
const retTypeIsVoid = tsFunction.retTypeIsVoid;
|
|
360
|
-
const typeStr = this.generateTypes(tsFunction.returnTypes, namespace);
|
|
361
|
-
let desc = typeStr;
|
|
362
|
-
if (overrideReturnType) {
|
|
363
|
-
desc = removeNamespace(overrideReturnType, namespace);
|
|
364
|
-
}
|
|
365
|
-
else if (outParams.length + (retTypeIsVoid ? 0 : 1) > 1) {
|
|
366
|
-
const outParamsDesc = [];
|
|
367
|
-
if (!retTypeIsVoid) {
|
|
368
|
-
outParamsDesc.push(`/* returnType */ ${typeStr}`);
|
|
369
|
-
}
|
|
370
|
-
for (const outParam of outParams) {
|
|
371
|
-
outParamsDesc.push(...this.generateOutParameterReturn(outParam, namespace));
|
|
372
|
-
}
|
|
373
|
-
desc = outParamsDesc.join(', ');
|
|
374
|
-
desc = `[ ${desc} ]`;
|
|
375
|
-
}
|
|
376
|
-
else if (outParams.length === 1 && retTypeIsVoid) {
|
|
377
|
-
desc = this.generateOutParameterReturn(outParams[0], namespace).join(' ');
|
|
378
|
-
}
|
|
379
|
-
return desc;
|
|
380
|
-
}
|
|
381
|
-
generateFunction(tsFunction,
|
|
382
|
-
/** If true only generate static functions otherwise generate only non static functions */
|
|
383
|
-
onlyStatic, namespace, indentCount = 1, overloads = true) {
|
|
384
|
-
const def = [];
|
|
385
|
-
const indent = generateIndent(indentCount);
|
|
386
|
-
if (!tsFunction) {
|
|
387
|
-
this.log.warn(NO_TSDATA('generateFunction'));
|
|
388
|
-
return def;
|
|
389
|
-
}
|
|
390
|
-
let { name } = tsFunction;
|
|
391
|
-
const { isStatic } = tsFunction;
|
|
392
|
-
const { isArrowType, isGlobal, inParams, instanceParameters } = tsFunction;
|
|
393
|
-
if ((isStatic && !onlyStatic) || (!isStatic && onlyStatic)) {
|
|
394
|
-
return def;
|
|
395
|
-
}
|
|
396
|
-
if (tsFunction.doc && !tsFunction.hasUnresolvedConflict)
|
|
397
|
-
def.push(...this.addGirDocComment(tsFunction.doc, indentCount));
|
|
398
|
-
const staticStr = isStatic && tsFunction.name !== 'constructor' ? 'static ' : '';
|
|
399
|
-
const globalStr = isGlobal ? 'function ' : '';
|
|
400
|
-
const genericStr = this.generateGenericParameters(tsFunction.generics);
|
|
401
|
-
// temporary solution, will be solved differently later
|
|
402
|
-
const commentOut = tsFunction.hasUnresolvedConflict ? '// Has conflict: ' : '';
|
|
403
|
-
let exportStr = '';
|
|
404
|
-
// `tsType === 'function'` are a global methods which can be exported
|
|
405
|
-
if (isGlobal) {
|
|
406
|
-
exportStr = this.config.useNamespace || this.config.buildType === 'types' ? '' : 'export ';
|
|
407
|
-
}
|
|
408
|
-
const returnType = this.generateFunctionReturn(tsFunction, namespace);
|
|
409
|
-
let retSep = '';
|
|
410
|
-
if (returnType) {
|
|
411
|
-
if (isArrowType) {
|
|
412
|
-
name = '';
|
|
413
|
-
retSep = ' =>';
|
|
414
|
-
}
|
|
415
|
-
else {
|
|
416
|
-
retSep = ':';
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
const inParamsDef = this.generateInParameters(inParams, instanceParameters, namespace);
|
|
420
|
-
def.push(`${indent}${commentOut}${exportStr}${staticStr}${globalStr}${name}${genericStr}(${inParamsDef.join(', ')})${retSep} ${returnType}`);
|
|
421
|
-
// Add overloaded methods
|
|
422
|
-
if (overloads && tsFunction.overloads.length > 0) {
|
|
423
|
-
def.push(...this.addInfoComment(`Overloads of ${name}`, indentCount));
|
|
424
|
-
for (const func of tsFunction.overloads) {
|
|
425
|
-
def.push(...this.generateFunction(func, onlyStatic, namespace, indentCount, false));
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
return def;
|
|
429
|
-
}
|
|
430
|
-
generateFunctions(tsFunctions, onlyStatic, namespace, indentCount = 1, comment) {
|
|
431
|
-
const def = [];
|
|
432
|
-
for (const girFunction of tsFunctions) {
|
|
433
|
-
def.push(...this.generateFunction(girFunction, onlyStatic, namespace, indentCount));
|
|
434
|
-
}
|
|
435
|
-
if (def.length > 0) {
|
|
436
|
-
def.unshift(...this.addInfoComment(comment, indentCount));
|
|
437
|
-
}
|
|
438
|
-
return def;
|
|
439
|
-
}
|
|
440
|
-
generateCallbackInterface(tsCallback, namespace, indentCount = 0, classModuleName) {
|
|
441
|
-
const def = [];
|
|
442
|
-
if (!tsCallback?.tsCallbackInterface) {
|
|
443
|
-
this.log.warn(NO_TSDATA('generateCallbackInterface'));
|
|
444
|
-
return def;
|
|
445
|
-
}
|
|
446
|
-
def.push(...this.addGirDocComment(tsCallback.doc, indentCount, tsCallback.tsCallbackInterface.overwriteDoc));
|
|
447
|
-
const indent = generateIndent(indentCount);
|
|
448
|
-
const indentBody = generateIndent(indentCount + 1);
|
|
449
|
-
const { inParams, instanceParameters } = tsCallback;
|
|
450
|
-
const returnTypeStr = this.generateTypes(tsCallback.returnTypes, namespace);
|
|
451
|
-
// Get name, remove namespace and remove module class name prefix
|
|
452
|
-
let { name } = tsCallback.tsCallbackInterface;
|
|
453
|
-
const { generics } = tsCallback.tsCallbackInterface;
|
|
454
|
-
name = removeNamespace(name, namespace);
|
|
455
|
-
if (classModuleName)
|
|
456
|
-
name = removeClassModule(name, classModuleName);
|
|
457
|
-
const genericParameters = this.generateGenericParameters(generics);
|
|
458
|
-
const inParamsDef = this.generateInParameters(inParams, instanceParameters, namespace);
|
|
459
|
-
const interfaceHead = `${name}${genericParameters}`;
|
|
460
|
-
def.push(this.generateExport('interface', `${interfaceHead}`, '{', indentCount));
|
|
461
|
-
def.push(`${indentBody}(${inParamsDef.join(', ')}): ${returnTypeStr}`);
|
|
462
|
-
def.push(indent + '}');
|
|
463
|
-
return def;
|
|
464
|
-
}
|
|
465
|
-
generateCallbackInterfaces(tsCallbacks, namespace, indentCount = 0, classModuleName, comment) {
|
|
466
|
-
const def = [];
|
|
467
|
-
for (const tsCallback of tsCallbacks) {
|
|
468
|
-
def.push(...this.generateCallbackInterface(tsCallback, namespace, indentCount, classModuleName), '');
|
|
469
|
-
}
|
|
470
|
-
if (def.length > 0) {
|
|
471
|
-
def.unshift(...this.addInfoComment(comment, indentCount));
|
|
472
|
-
}
|
|
473
|
-
return def;
|
|
474
|
-
}
|
|
475
|
-
generateEnumeration(girEnum, indentCount = 0) {
|
|
476
|
-
const desc = [];
|
|
477
|
-
if (!girElementIsIntrospectable(girEnum)) {
|
|
478
|
-
return desc;
|
|
479
|
-
}
|
|
480
|
-
if (!girEnum._tsData) {
|
|
481
|
-
this.log.warn(NO_TSDATA('generateEnumeration'));
|
|
482
|
-
return desc;
|
|
483
|
-
}
|
|
484
|
-
desc.push(...this.addGirDocComment(girEnum._tsData.doc, indentCount));
|
|
485
|
-
const { name } = girEnum._tsData;
|
|
486
|
-
desc.push(this.generateExport('enum', name, '{', indentCount));
|
|
487
|
-
if (girEnum.member) {
|
|
488
|
-
for (const girEnumMember of girEnum.member) {
|
|
489
|
-
if (!girEnumMember._tsData)
|
|
490
|
-
continue;
|
|
491
|
-
desc.push(...this.generateEnumerationMember(girEnumMember._tsData, indentCount + 1));
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
desc.push('}');
|
|
495
|
-
return desc;
|
|
496
|
-
}
|
|
497
|
-
generateEnumerationMember(tsMember, indentCount = 1) {
|
|
498
|
-
const desc = [];
|
|
499
|
-
if (!tsMember) {
|
|
500
|
-
this.log.warn(NO_TSDATA('generateEnumerationMember'));
|
|
501
|
-
return desc;
|
|
502
|
-
}
|
|
503
|
-
desc.push(...this.addGirDocComment(tsMember.doc, indentCount));
|
|
504
|
-
const indent = generateIndent(indentCount);
|
|
505
|
-
desc.push(`${indent}${tsMember.name},`);
|
|
506
|
-
return desc;
|
|
507
|
-
}
|
|
508
|
-
generateConstant(tsConst, namespace, indentCount = 0) {
|
|
509
|
-
const desc = [];
|
|
510
|
-
if (!tsConst.hasUnresolvedConflict) {
|
|
511
|
-
desc.push(...this.addGirDocComment(tsConst.doc, indentCount));
|
|
512
|
-
}
|
|
513
|
-
const indent = generateIndent(indentCount);
|
|
514
|
-
const exp = this.config.useNamespace || this.config.buildType === 'types' ? '' : 'export ';
|
|
515
|
-
const varDesc = this.generateVariable(tsConst, namespace, 0);
|
|
516
|
-
desc.push(`${indent}${exp}const ${varDesc}`);
|
|
517
|
-
return desc;
|
|
518
|
-
}
|
|
519
|
-
generateAlias(girAlias, namespace, indentCount = 0) {
|
|
520
|
-
const desc = [];
|
|
521
|
-
if (!girElementIsIntrospectable(girAlias)) {
|
|
522
|
-
return '';
|
|
523
|
-
}
|
|
524
|
-
if (!girAlias._tsData) {
|
|
525
|
-
this.log.warn(NO_TSDATA('generateAlias'));
|
|
526
|
-
return desc;
|
|
527
|
-
}
|
|
528
|
-
const indent = generateIndent(indentCount);
|
|
529
|
-
const exp = this.config.useNamespace || this.config.buildType === 'types' ? '' : 'export ';
|
|
530
|
-
const type = removeNamespace(girAlias._tsData.type, namespace);
|
|
531
|
-
desc.push(`${indent}${exp}type ${girAlias._tsData.name} = ${type}`);
|
|
532
|
-
return desc;
|
|
533
|
-
}
|
|
534
|
-
generateConstructPropsInterface(girClass, namespace, indentCount = 0) {
|
|
535
|
-
const def = [];
|
|
536
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
537
|
-
throw new Error(NO_TSDATA('generateConstructPropsInterface'));
|
|
538
|
-
}
|
|
539
|
-
if (!girClass._tsData.isDerivedFromGObject) {
|
|
540
|
-
return def;
|
|
541
|
-
}
|
|
542
|
-
const indent = generateIndent(indentCount);
|
|
543
|
-
const exp = this.config.useNamespace || this.config.buildType === 'types' ? '' : 'export ';
|
|
544
|
-
let ext = '';
|
|
545
|
-
if (girClass._tsData.inheritConstructPropInterfaceNames.length) {
|
|
546
|
-
const constructPropInterfaceNames = girClass._tsData.inheritConstructPropInterfaceNames.map((n) => removeNamespace(n, namespace));
|
|
547
|
-
ext = `extends ${constructPropInterfaceNames.join(', ')} `;
|
|
548
|
-
}
|
|
549
|
-
// Remove namespace and class module name
|
|
550
|
-
const constructPropInterfaceName = removeClassModule(removeNamespace(girClass._tsData.constructPropInterfaceName, namespace), girClass._tsData.name);
|
|
551
|
-
def.push(...this.addInfoComment('Constructor properties interface', indentCount));
|
|
552
|
-
// START BODY
|
|
553
|
-
{
|
|
554
|
-
def.push(`${indent}${exp}interface ${constructPropInterfaceName} ${ext}{`);
|
|
555
|
-
def.push(...this.generateProperties(girClass._tsData.constructProps.map((cp) => cp._tsData).filter((cp) => !!cp), false, namespace, `Own constructor properties of ${girClass._module.packageName}.${girClass._fullSymName}`, indentCount + 1));
|
|
556
|
-
def.push(`${indent}}`, '');
|
|
557
|
-
}
|
|
558
|
-
// END BODY
|
|
559
|
-
return def;
|
|
560
|
-
}
|
|
561
|
-
generateClassFields(girClass, onlyStatic, namespace, indentCount = 1) {
|
|
562
|
-
const def = [];
|
|
563
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
564
|
-
throw new Error(NO_TSDATA('generateClassFields'));
|
|
565
|
-
}
|
|
566
|
-
def.push(...this.generateProperties(girClass._tsData.fields.map((f) => f._tsData).filter((f) => !!f), onlyStatic, namespace, `Own fields of ${girClass._module.packageName}.${girClass._fullSymName}`, indentCount));
|
|
567
|
-
return def;
|
|
568
|
-
}
|
|
569
|
-
generateClassProperties(girClass, onlyStatic, namespace, indentCount = 1) {
|
|
570
|
-
const def = [];
|
|
571
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
572
|
-
throw new Error(NO_TSDATA('generateClassProperties'));
|
|
573
|
-
}
|
|
574
|
-
def.push(...this.generateProperties(girClass._tsData.properties.map((p) => p._tsData).filter((p) => !!p), onlyStatic, namespace, `Own properties of ${girClass._module.packageName}.${girClass._fullSymName}`, indentCount));
|
|
575
|
-
def.push(...this.generateProperties(girClass._tsData.conflictProperties, onlyStatic, namespace, `Conflicting properties`, indentCount));
|
|
576
|
-
return def;
|
|
577
|
-
}
|
|
578
|
-
generateClassMethods(girClass, onlyStatic, namespace, indentCount = 1) {
|
|
579
|
-
const def = [];
|
|
580
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
581
|
-
throw new Error(NO_TSDATA('generateClassMethods'));
|
|
582
|
-
}
|
|
583
|
-
def.push(...this.generateFunctions(girClass._tsData.methods.map((girFunc) => girFunc._tsData).filter((tsFunc) => !!tsFunc), onlyStatic, namespace, indentCount, `Owm ${onlyStatic ? 'static ' : ''}methods of ${girClass._module.packageName}.${girClass._fullSymName}`));
|
|
584
|
-
def.push(...this.generateFunctions(girClass._tsData.conflictMethods, onlyStatic, namespace, indentCount, `Conflicting ${onlyStatic ? 'static ' : ''}methods`));
|
|
585
|
-
return def;
|
|
586
|
-
}
|
|
587
|
-
generateClassConstructors(girClass, namespace, indentCount = 1) {
|
|
588
|
-
const def = [];
|
|
589
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
590
|
-
throw new Error(NO_TSDATA('generateClassConstructors'));
|
|
591
|
-
}
|
|
592
|
-
// Constructors
|
|
593
|
-
def.push(...this.generateFunctions(girClass._tsData.constructors
|
|
594
|
-
.map((girFunc) => girFunc._tsData)
|
|
595
|
-
.filter((tsFunc) => !!tsFunc), true, namespace, indentCount));
|
|
596
|
-
// _init method
|
|
597
|
-
def.push(...this.generateFunctions(girClass._tsData.constructors
|
|
598
|
-
.map((girFunc) => girFunc._tsData)
|
|
599
|
-
.filter((tsFunc) => !!tsFunc), false, namespace, indentCount));
|
|
600
|
-
// Pseudo constructors
|
|
601
|
-
def.push(...this.generateFunctions(girClass._tsData.staticFunctions
|
|
602
|
-
.map((girFunc) => girFunc._tsData)
|
|
603
|
-
.filter((tsFunc) => !!tsFunc), true, namespace, indentCount));
|
|
604
|
-
if (def.length) {
|
|
605
|
-
def.unshift(...this.addInfoComment(`Constructors of ${girClass._module.packageName}.${girClass._fullSymName}`, indentCount));
|
|
606
|
-
}
|
|
607
|
-
return def;
|
|
608
|
-
}
|
|
609
|
-
/**
|
|
610
|
-
* Instance methods, vfunc_ prefix
|
|
611
|
-
* @param girClass
|
|
612
|
-
*/
|
|
613
|
-
generateClassVirtualMethods(girClass, namespace, indentCount = 1) {
|
|
614
|
-
const def = [];
|
|
615
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
616
|
-
throw new Error(NO_TSDATA('generateClassVirtualMethods'));
|
|
617
|
-
}
|
|
618
|
-
def.push(...this.generateFunctions(girClass._tsData.virtualMethods
|
|
619
|
-
.map((girFunc) => girFunc._tsData)
|
|
620
|
-
.filter((tsFunc) => !!tsFunc), false, namespace, indentCount, `Own virtual methods of ${girClass._module.packageName}.${girClass._fullSymName}`));
|
|
621
|
-
return def;
|
|
622
|
-
}
|
|
623
|
-
generateClassSignalInterfaces(girClass, namespace, indentCount = 0) {
|
|
624
|
-
const def = [];
|
|
625
|
-
if (!girClass._tsData) {
|
|
626
|
-
throw new Error(NO_TSDATA('generateClassSignalInterface'));
|
|
627
|
-
}
|
|
628
|
-
const tsSignals = girClass._tsData.signals
|
|
629
|
-
.map((signal) => signal._tsData)
|
|
630
|
-
.filter((signal) => !!signal);
|
|
631
|
-
def.push(...this.generateCallbackInterfaces(tsSignals, namespace, indentCount, girClass._tsData.name, 'Signal callback interfaces'));
|
|
632
|
-
return def;
|
|
633
|
-
}
|
|
634
|
-
generateClassSignals(girClass, namespace) {
|
|
635
|
-
const def = [];
|
|
636
|
-
if (!girClass._tsData || !girClass._fullSymName || !girClass._module) {
|
|
637
|
-
throw new Error(NO_TSDATA('generateClassSignals'));
|
|
638
|
-
}
|
|
639
|
-
const signalDescs = this.generateSignals(girClass._tsData.signals, girClass, namespace, 0);
|
|
640
|
-
def.push(...this.mergeDescs(signalDescs, `Own signals of ${girClass._module.packageName}.${girClass._fullSymName}`, 1));
|
|
641
|
-
return def;
|
|
642
|
-
}
|
|
643
|
-
generateClassModules(girClass, namespace, indentCount = 0) {
|
|
644
|
-
const def = [];
|
|
645
|
-
const bodyDef = [];
|
|
646
|
-
if (!girClass._tsData)
|
|
647
|
-
return def;
|
|
648
|
-
const indent = generateIndent(indentCount);
|
|
649
|
-
const exp = this.config.useNamespace || this.config.buildType === 'types' ? '' : 'export ';
|
|
650
|
-
// Signal interfaces
|
|
651
|
-
bodyDef.push(...this.generateClassSignalInterfaces(girClass, namespace, indentCount + 1));
|
|
652
|
-
// Properties interface for construction
|
|
653
|
-
bodyDef.push(...this.generateConstructPropsInterface(girClass, namespace, indentCount + 1));
|
|
654
|
-
if (!bodyDef.length) {
|
|
655
|
-
return [];
|
|
656
|
-
}
|
|
657
|
-
// START BODY
|
|
658
|
-
{
|
|
659
|
-
def.push(`${indent}${exp}module ${girClass._tsData.name} {`);
|
|
660
|
-
// Properties interface for construction
|
|
661
|
-
def.push(...bodyDef);
|
|
662
|
-
def.push(`${indent}}`, '');
|
|
663
|
-
}
|
|
664
|
-
// END BODY
|
|
665
|
-
return def;
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
|
-
* In Typescript, interfaces and classes can have the same name,
|
|
669
|
-
* so we use this to generate interfaces with the same name to implement multiple inheritance
|
|
670
|
-
* @param girClass
|
|
671
|
-
* @param namespace
|
|
672
|
-
*/
|
|
673
|
-
generateImplementationInterface(girClass, namespace) {
|
|
674
|
-
const def = [];
|
|
675
|
-
if (!girClass._tsData)
|
|
676
|
-
return def;
|
|
677
|
-
const genericParameters = this.generateGenericParameters(girClass._tsData.generics);
|
|
678
|
-
const implementationNames = girClass._tsData.parents
|
|
679
|
-
.filter((implementation) => implementation.type !== 'parent')
|
|
680
|
-
.map((implementation) => implementation.localParentName);
|
|
681
|
-
const ext = implementationNames.length ? ` extends ${implementationNames.join(', ')}` : '';
|
|
682
|
-
const interfaceHead = `${girClass._tsData.name}${genericParameters}${ext}`;
|
|
683
|
-
// START INTERFACE
|
|
684
|
-
{
|
|
685
|
-
def.push(this.generateExport('interface', interfaceHead, '{'));
|
|
686
|
-
// START BODY
|
|
687
|
-
{
|
|
688
|
-
// Properties
|
|
689
|
-
def.push(...this.generateClassProperties(girClass, false, namespace));
|
|
690
|
-
// Fields
|
|
691
|
-
def.push(...this.generateClassFields(girClass, false, namespace));
|
|
692
|
-
// Methods
|
|
693
|
-
def.push(...this.generateClassMethods(girClass, false, namespace));
|
|
694
|
-
// Virtual methods
|
|
695
|
-
def.push(...this.generateClassVirtualMethods(girClass, namespace));
|
|
696
|
-
// Signals
|
|
697
|
-
def.push(...this.generateClassSignals(girClass, namespace));
|
|
698
|
-
// TODO: Generate `GirSignalElement`s instead of generate the signal definition strings directly
|
|
699
|
-
def.push(...this.generateClassPropertySignals(girClass, namespace));
|
|
700
|
-
}
|
|
701
|
-
// END BODY
|
|
702
|
-
// END INTERFACE
|
|
703
|
-
def.push('}');
|
|
704
|
-
def.push('');
|
|
705
|
-
}
|
|
706
|
-
return def;
|
|
707
|
-
}
|
|
708
|
-
/**
|
|
709
|
-
* Represents a record, GObject class or interface as a Typescript class
|
|
710
|
-
* @param girClass
|
|
711
|
-
* @param namespace
|
|
712
|
-
*/
|
|
713
|
-
generateClass(girClass, namespace) {
|
|
714
|
-
const def = [];
|
|
715
|
-
if (!girClass._tsData)
|
|
716
|
-
return def;
|
|
717
|
-
def.push(...this.generateClassModules(girClass, namespace));
|
|
718
|
-
def.push(...this.generateImplementationInterface(girClass, namespace));
|
|
719
|
-
def.push(...this.addGirDocComment(girClass._tsData.doc, 0));
|
|
720
|
-
const genericParameters = this.generateGenericParameters(girClass._tsData.generics);
|
|
721
|
-
const parentName = girClass._tsData.parents.find((parent) => parent.type === 'parent')?.localParentName;
|
|
722
|
-
const ext = parentName ? ` extends ${parentName}` : '';
|
|
723
|
-
const classHead = `${girClass._tsData.name}${genericParameters}${ext}`;
|
|
724
|
-
// START CLASS
|
|
725
|
-
{
|
|
726
|
-
if (girClass._tsData.isAbstract) {
|
|
727
|
-
def.push(this.generateExport('abstract class', classHead, '{'));
|
|
728
|
-
}
|
|
729
|
-
else {
|
|
730
|
-
def.push(this.generateExport('class', classHead, '{'));
|
|
731
|
-
}
|
|
732
|
-
// START BODY
|
|
733
|
-
{
|
|
734
|
-
// Static Properties
|
|
735
|
-
def.push(...this.generateClassProperties(girClass, true, namespace));
|
|
736
|
-
// Static Fields
|
|
737
|
-
def.push(...this.generateClassFields(girClass, true, namespace));
|
|
738
|
-
// Constructors
|
|
739
|
-
def.push(...this.generateClassConstructors(girClass, namespace));
|
|
740
|
-
// Static Methods
|
|
741
|
-
def.push(...this.generateClassMethods(girClass, true, namespace));
|
|
742
|
-
}
|
|
743
|
-
// END BODY
|
|
744
|
-
// END CLASS
|
|
745
|
-
def.push('}');
|
|
746
|
-
def.push('');
|
|
747
|
-
}
|
|
748
|
-
return def;
|
|
749
|
-
}
|
|
750
|
-
async exportModuleJS(moduleTemplateProcessor, girModule) {
|
|
751
|
-
const template = 'module.js';
|
|
752
|
-
if (this.config.outdir) {
|
|
753
|
-
await moduleTemplateProcessor.create(template, this.config.outdir, `${girModule.packageName}.js`);
|
|
754
|
-
}
|
|
755
|
-
else {
|
|
756
|
-
const moduleContent = moduleTemplateProcessor.load(template);
|
|
757
|
-
this.log.log(moduleContent);
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
async exportModuleTS(moduleTemplateProcessor, girModule) {
|
|
761
|
-
const template = 'module.d.ts';
|
|
762
|
-
const out = [];
|
|
763
|
-
out.push(...this.addTSDocCommentLines([girModule.packageName]));
|
|
764
|
-
out.push('');
|
|
765
|
-
const deps = girModule.transitiveDependencies;
|
|
766
|
-
// Module dependencies as type references or imports
|
|
767
|
-
if (this.config.environment === 'gjs') {
|
|
768
|
-
out.push(...this.generateModuleDependenciesImport('Gjs', 'Gjs', false));
|
|
769
|
-
}
|
|
770
|
-
for (const depPackageName of deps) {
|
|
771
|
-
// Don't reference yourself as a dependency
|
|
772
|
-
if (girModule.packageName !== depPackageName) {
|
|
773
|
-
const girFilename = `${depPackageName}.gir`;
|
|
774
|
-
const { namespace } = splitModuleName(depPackageName);
|
|
775
|
-
const depFile = findFileInDirs(this.config.girDirectories, girFilename);
|
|
776
|
-
if (depFile.exists) {
|
|
777
|
-
out.push(...this.generateModuleDependenciesImport(namespace, depPackageName, false));
|
|
778
|
-
}
|
|
779
|
-
else {
|
|
780
|
-
out.push(`// WARN: Dependency not found: '${depPackageName}'`);
|
|
781
|
-
this.log.warn(WARN_NOT_FOUND_DEPENDENCY_GIR_FILE(girFilename));
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
// START Namespace
|
|
786
|
-
{
|
|
787
|
-
if (this.config.buildType === 'types') {
|
|
788
|
-
out.push('');
|
|
789
|
-
out.push(`declare namespace ${girModule.namespace} {`);
|
|
790
|
-
}
|
|
791
|
-
else if (this.config.useNamespace) {
|
|
792
|
-
out.push('');
|
|
793
|
-
out.push(`export namespace ${girModule.namespace} {`);
|
|
794
|
-
}
|
|
795
|
-
// Newline
|
|
796
|
-
out.push('');
|
|
797
|
-
if (girModule.ns.enumeration)
|
|
798
|
-
for (const girEnum of girModule.ns.enumeration)
|
|
799
|
-
out.push(...this.generateEnumeration(girEnum));
|
|
800
|
-
if (girModule.ns.bitfield)
|
|
801
|
-
for (const girBitfield of girModule.ns.bitfield)
|
|
802
|
-
out.push(...this.generateEnumeration(girBitfield));
|
|
803
|
-
if (girModule.ns.constant)
|
|
804
|
-
for (const girConst of girModule.ns.constant) {
|
|
805
|
-
if (!girConst._tsData)
|
|
806
|
-
continue;
|
|
807
|
-
out.push(...this.generateConstant(girConst._tsData, girModule.namespace, 0));
|
|
808
|
-
}
|
|
809
|
-
if (girModule.ns.function)
|
|
810
|
-
for (const girFunc of girModule.ns.function) {
|
|
811
|
-
if (!girFunc._tsData) {
|
|
812
|
-
// this.log.warn(NO_TSDATA('exportModuleTS functions'))
|
|
813
|
-
continue;
|
|
814
|
-
}
|
|
815
|
-
out.push(...this.generateFunction(girFunc._tsData, false, girModule.namespace, 0));
|
|
816
|
-
}
|
|
817
|
-
if (girModule.ns.callback)
|
|
818
|
-
for (const girCallback of girModule.ns.callback) {
|
|
819
|
-
if (!girCallback._tsData)
|
|
820
|
-
continue;
|
|
821
|
-
out.push(...this.generateCallbackInterface(girCallback._tsData, girModule.namespace));
|
|
822
|
-
}
|
|
823
|
-
if (girModule.ns.interface)
|
|
824
|
-
for (const girIface of girModule.ns.interface)
|
|
825
|
-
if (girIface._module) {
|
|
826
|
-
out.push(...this.generateClass(girIface, girIface._module.namespace));
|
|
827
|
-
}
|
|
828
|
-
// Extra interfaces if a template with the module name (e.g. '../templates/GObject-2.0.d.ts') is found
|
|
829
|
-
// E.g. used for GObject-2.0 to help define GObject classes in js;
|
|
830
|
-
// these aren't part of gi.
|
|
831
|
-
if (moduleTemplateProcessor.exists(`${girModule.packageName}.d.ts`)) {
|
|
832
|
-
const templatePatches = await moduleTemplateProcessor.load(`${girModule.packageName}.d.ts`);
|
|
833
|
-
out.push(templatePatches);
|
|
834
|
-
}
|
|
835
|
-
if (girModule.ns.class)
|
|
836
|
-
for (const gitClass of girModule.ns.class)
|
|
837
|
-
if (gitClass._module) {
|
|
838
|
-
out.push(...this.generateClass(gitClass, gitClass._module.namespace));
|
|
839
|
-
}
|
|
840
|
-
if (girModule.ns.record)
|
|
841
|
-
for (const girRecord of girModule.ns.record)
|
|
842
|
-
if (girRecord._module) {
|
|
843
|
-
out.push(...this.generateClass(girRecord, girRecord._module.namespace));
|
|
844
|
-
}
|
|
845
|
-
if (girModule.ns.union)
|
|
846
|
-
for (const girUnion of girModule.ns.union)
|
|
847
|
-
if (girUnion._module) {
|
|
848
|
-
out.push(...this.generateClass(girUnion, girUnion._module.namespace));
|
|
849
|
-
}
|
|
850
|
-
if (girModule.ns.alias)
|
|
851
|
-
// GType is not a number in GJS
|
|
852
|
-
for (const girAlias of girModule.ns.alias)
|
|
853
|
-
if (girModule.packageName !== 'GObject-2.0' || girAlias.$.name !== 'Type')
|
|
854
|
-
out.push(...this.generateAlias(girAlias, girModule.namespace, 1));
|
|
855
|
-
if (this.config.environment === 'gjs') {
|
|
856
|
-
// Properties added to every GIRepositoryNamespace
|
|
857
|
-
// https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L186-190
|
|
858
|
-
out.push(...this.generateConstant({
|
|
859
|
-
doc: {
|
|
860
|
-
text: 'Name of the imported GIR library',
|
|
861
|
-
tags: [
|
|
862
|
-
{
|
|
863
|
-
text: 'https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188',
|
|
864
|
-
tagName: 'see',
|
|
865
|
-
paramName: '',
|
|
866
|
-
},
|
|
867
|
-
],
|
|
868
|
-
},
|
|
869
|
-
name: '__name__',
|
|
870
|
-
type: [
|
|
871
|
-
{
|
|
872
|
-
type: 'string',
|
|
873
|
-
optional: false,
|
|
874
|
-
nullable: false,
|
|
875
|
-
callbacks: [],
|
|
876
|
-
generics: [],
|
|
877
|
-
isArray: false,
|
|
878
|
-
isFunction: false,
|
|
879
|
-
isCallback: false,
|
|
880
|
-
},
|
|
881
|
-
],
|
|
882
|
-
isInjected: false,
|
|
883
|
-
tsTypeName: 'constant',
|
|
884
|
-
girTypeName: 'constant',
|
|
885
|
-
}, girModule.namespace, 0), ...this.generateConstant({
|
|
886
|
-
doc: {
|
|
887
|
-
text: 'Version of the imported GIR library',
|
|
888
|
-
tags: [
|
|
889
|
-
{
|
|
890
|
-
text: 'https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189',
|
|
891
|
-
tagName: 'see',
|
|
892
|
-
paramName: '',
|
|
893
|
-
},
|
|
894
|
-
],
|
|
895
|
-
},
|
|
896
|
-
name: '__version__',
|
|
897
|
-
type: [
|
|
898
|
-
{
|
|
899
|
-
type: 'string',
|
|
900
|
-
optional: false,
|
|
901
|
-
nullable: false,
|
|
902
|
-
callbacks: [],
|
|
903
|
-
generics: [],
|
|
904
|
-
isArray: false,
|
|
905
|
-
isFunction: false,
|
|
906
|
-
isCallback: false,
|
|
907
|
-
},
|
|
908
|
-
],
|
|
909
|
-
isInjected: false,
|
|
910
|
-
tsTypeName: 'constant',
|
|
911
|
-
girTypeName: 'constant',
|
|
912
|
-
}, girModule.namespace, 0));
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
// END Namespace
|
|
916
|
-
if (this.config.useNamespace) {
|
|
917
|
-
out.push(`}`);
|
|
918
|
-
}
|
|
919
|
-
if (this.config.useNamespace) {
|
|
920
|
-
out.push(`export default ${girModule.namespace};`);
|
|
921
|
-
}
|
|
922
|
-
const outResult = out.join('\n'); // End of file
|
|
923
|
-
if (this.config.outdir) {
|
|
924
|
-
await moduleTemplateProcessor.create(template, this.config.outdir, `${girModule.packageName}.d.ts`, outResult);
|
|
925
|
-
}
|
|
926
|
-
else {
|
|
927
|
-
const moduleContent = await moduleTemplateProcessor.load(template);
|
|
928
|
-
this.log.log(moduleContent + '\n' + outResult);
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
async exportModule(girModule) {
|
|
932
|
-
const moduleTemplateProcessor = new TemplateProcessor({
|
|
933
|
-
name: girModule.namespace,
|
|
934
|
-
namespace: girModule.namespace,
|
|
935
|
-
version: girModule.version,
|
|
936
|
-
importName: girModule.importName,
|
|
937
|
-
}, girModule.packageName, this.config);
|
|
938
|
-
await this.exportModuleTS(moduleTemplateProcessor, girModule);
|
|
939
|
-
if (this.config.buildType === 'lib') {
|
|
940
|
-
await this.exportModuleJS(moduleTemplateProcessor, girModule);
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
async exportGjs(girModules, girModulesGrouped) {
|
|
944
|
-
if (!this.config.outdir)
|
|
945
|
-
return;
|
|
946
|
-
const templateProcessor = new TemplateProcessor({ girModules: girModules, girModulesGrouped }, 'gjs', this.config);
|
|
947
|
-
// Types
|
|
948
|
-
await templateProcessor.create('Gjs.d.ts', this.config.outdir, 'Gjs.d.ts');
|
|
949
|
-
await templateProcessor.create('index.d.ts', this.config.outdir, 'index.d.ts');
|
|
950
|
-
if (this.config.gnomeShellTypes) {
|
|
951
|
-
await templateProcessor.create('GnomeShell.d.ts', this.config.outdir, 'GnomeShell.d.ts');
|
|
952
|
-
await templateProcessor.createAll('.d.ts', 'misc', this.config.outdir, 'misc');
|
|
953
|
-
await templateProcessor.createAll('.d.ts', 'ui', this.config.outdir, 'ui');
|
|
954
|
-
}
|
|
955
|
-
// Lib
|
|
956
|
-
if (this.config.buildType === 'lib') {
|
|
957
|
-
await templateProcessor.create('Gjs.js', this.config.outdir, 'Gjs.js');
|
|
958
|
-
await templateProcessor.create('index.js', this.config.outdir, 'index.js');
|
|
959
|
-
if (this.config.gnomeShellTypes) {
|
|
960
|
-
await templateProcessor.create('GnomeShell.js', this.config.outdir, 'GnomeShell.js');
|
|
961
|
-
await templateProcessor.createAll('.js', 'misc', this.config.outdir, 'misc');
|
|
962
|
-
await templateProcessor.createAll('.js', 'ui', this.config.outdir, 'ui');
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
async exportNodeGtk(girModules, girModulesGrouped) {
|
|
967
|
-
if (!this.config.outdir)
|
|
968
|
-
return;
|
|
969
|
-
const templateProcessor = new TemplateProcessor({ girModules, girModulesGrouped }, 'node', this.config);
|
|
970
|
-
await templateProcessor.create('index.d.ts', this.config.outdir, 'index.d.ts');
|
|
971
|
-
if (this.config.buildType === 'lib') {
|
|
972
|
-
await templateProcessor.create('index.js', this.config.outdir, 'index.js');
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
async start(girModules, girModulesGrouped, inheritanceTable) {
|
|
976
|
-
for (const girModule of girModules) {
|
|
977
|
-
await this.exportModule(girModule);
|
|
978
|
-
}
|
|
979
|
-
if (this.config.environment === 'node' && girModulesGrouped) {
|
|
980
|
-
// node-gtk internal stuff
|
|
981
|
-
await this.exportNodeGtk(girModules, girModulesGrouped);
|
|
982
|
-
}
|
|
983
|
-
if (this.config.environment === 'gjs' && girModulesGrouped && inheritanceTable) {
|
|
984
|
-
// GJS internal stuff
|
|
985
|
-
await this.exportGjs(girModules, girModulesGrouped);
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
//# sourceMappingURL=type-definition-generator.js.map
|