@ts-for-gir/lib 3.3.0 → 4.0.0-beta.10
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 +0 -1
- package/lib/constants.d.ts +8 -13
- package/lib/constants.js +79 -24
- package/lib/constants.js.map +1 -1
- package/lib/dependency-manager.d.ts +60 -16
- package/lib/dependency-manager.js +146 -56
- package/lib/dependency-manager.js.map +1 -1
- package/lib/formatters/default.d.ts +4 -0
- package/lib/formatters/default.js +7 -0
- package/lib/formatters/default.js.map +1 -0
- package/lib/formatters/formatter.d.ts +3 -0
- package/lib/formatters/formatter.js +3 -0
- package/lib/formatters/formatter.js.map +1 -0
- package/lib/formatters/json.d.ts +4 -0
- package/lib/formatters/json.js +7 -0
- package/lib/formatters/json.js.map +1 -0
- package/lib/generators/dts/glib.d.ts +2 -0
- package/lib/generators/dts/glib.js +514 -0
- package/lib/generators/dts/glib.js.map +1 -0
- package/lib/generators/dts/gobject.d.ts +2 -0
- package/lib/generators/dts/gobject.js +117 -0
- package/lib/generators/dts/gobject.js.map +1 -0
- package/lib/generators/dts-inline.d.ts +10 -0
- package/lib/generators/dts-inline.js +57 -0
- package/lib/generators/dts-inline.js.map +1 -0
- package/lib/generators/dts-modules.d.ts +10 -0
- package/lib/generators/dts-modules.js +98 -0
- package/lib/generators/dts-modules.js.map +1 -0
- package/lib/generators/dts.d.ts +45 -0
- package/lib/generators/dts.js +682 -0
- package/lib/generators/dts.js.map +1 -0
- package/lib/generators/generator.d.ts +45 -0
- package/lib/generators/generator.js +9 -0
- package/lib/generators/generator.js.map +1 -0
- package/lib/generators/index.d.ts +5 -0
- package/lib/generators/index.js +6 -0
- package/lib/generators/index.js.map +1 -0
- package/lib/generators/json.d.ts +258 -0
- package/lib/generators/json.js +867 -0
- package/lib/generators/json.js.map +1 -0
- package/lib/generics/clutter.d.ts +26 -0
- package/lib/generics/clutter.js +49 -0
- package/lib/generics/clutter.js.map +1 -0
- package/lib/generics/generify.d.ts +2 -0
- package/lib/generics/generify.js +39 -0
- package/lib/generics/generify.js.map +1 -0
- package/lib/generics/gio.d.ts +7 -0
- package/lib/generics/gio.js +51 -0
- package/lib/generics/gio.js.map +1 -0
- package/lib/generics/glib.d.ts +7 -0
- package/lib/generics/glib.js +18 -0
- package/lib/generics/glib.js.map +1 -0
- package/lib/generics/meta.d.ts +21 -0
- package/lib/generics/meta.js +26 -0
- package/lib/generics/meta.js.map +1 -0
- package/lib/generics/st.d.ts +16 -0
- package/lib/generics/st.js +92 -0
- package/lib/generics/st.js.map +1 -0
- package/lib/generics/visitor.d.ts +20 -0
- package/lib/generics/visitor.js +255 -0
- package/lib/generics/visitor.js.map +1 -0
- package/lib/gir/alias.d.ts +24 -0
- package/lib/gir/alias.js +43 -0
- package/lib/gir/alias.js.map +1 -0
- package/lib/gir/base.d.ts +62 -0
- package/lib/gir/base.js +95 -0
- package/lib/gir/base.js.map +1 -0
- package/lib/gir/class.d.ts +189 -0
- package/lib/gir/class.js +1131 -0
- package/lib/gir/class.js.map +1 -0
- package/lib/gir/const.d.ts +25 -0
- package/lib/gir/const.js +43 -0
- package/lib/gir/const.js.map +1 -0
- package/lib/gir/enum.d.ts +45 -0
- package/lib/gir/enum.js +164 -0
- package/lib/gir/enum.js.map +1 -0
- package/lib/gir/function.d.ts +199 -0
- package/lib/gir/function.js +683 -0
- package/lib/gir/function.js.map +1 -0
- package/lib/gir/generics.d.ts +5 -0
- package/lib/gir/generics.js +57 -0
- package/lib/gir/generics.js.map +1 -0
- package/lib/gir/namespace.d.ts +21 -0
- package/lib/gir/namespace.js +57 -0
- package/lib/gir/namespace.js.map +1 -0
- package/lib/gir/nodes.d.ts +11 -0
- package/lib/gir/nodes.js +12 -0
- package/lib/gir/nodes.js.map +1 -0
- package/lib/gir/property.d.ts +60 -0
- package/lib/gir/property.js +128 -0
- package/lib/gir/property.js.map +1 -0
- package/lib/gir/registry.d.ts +51 -0
- package/lib/gir/registry.js +144 -0
- package/lib/gir/registry.js.map +1 -0
- package/lib/gir/signal.d.ts +33 -0
- package/lib/gir/signal.js +165 -0
- package/lib/gir/signal.js.map +1 -0
- package/lib/gir/util.d.ts +49 -0
- package/lib/gir/util.js +559 -0
- package/lib/gir/util.js.map +1 -0
- package/lib/gir-module.d.ts +69 -241
- package/lib/gir-module.js +433 -2154
- package/lib/gir-module.js.map +1 -1
- package/lib/gir.d.ts +253 -0
- package/lib/gir.js +642 -0
- package/lib/gir.js.map +1 -0
- package/lib/index.d.ts +6 -6
- package/lib/index.js +8 -6
- package/lib/index.js.map +1 -1
- package/lib/injections/gee08.d.ts +7 -0
- package/lib/injections/gee08.js +68 -0
- package/lib/injections/gee08.js.map +1 -0
- package/lib/injections/gee1.d.ts +7 -0
- package/lib/injections/gee1.js +28 -0
- package/lib/injections/gee1.js.map +1 -0
- package/lib/injections/gio.d.ts +7 -0
- package/lib/injections/gio.js +431 -0
- package/lib/injections/gio.js.map +1 -0
- package/lib/injections/glib.d.ts +7 -0
- package/lib/injections/glib.js +204 -0
- package/lib/injections/glib.js.map +1 -0
- package/lib/injections/gobject.d.ts +7 -0
- package/lib/injections/gobject.js +479 -0
- package/lib/injections/gobject.js.map +1 -0
- package/lib/injections/inject.d.ts +4 -0
- package/lib/injections/inject.js +28 -0
- package/lib/injections/inject.js.map +1 -0
- package/lib/injections/tracker1.d.ts +7 -0
- package/lib/injections/tracker1.js +30 -0
- package/lib/injections/tracker1.js.map +1 -0
- package/lib/library-version.d.ts +2 -0
- package/lib/library-version.js +13 -0
- package/lib/library-version.js.map +1 -1
- package/lib/logger.d.ts +19 -19
- package/lib/logger.js +31 -34
- package/lib/logger.js.map +1 -1
- package/lib/messages.d.ts +1 -7
- package/lib/messages.js +1 -6
- package/lib/messages.js.map +1 -1
- package/lib/registry.d.ts +8 -0
- package/lib/registry.js +12 -0
- package/lib/registry.js.map +1 -0
- package/lib/transformation.d.ts +8 -19
- package/lib/transformation.js +40 -216
- package/lib/transformation.js.map +1 -1
- package/lib/types/dependency.d.ts +13 -1
- package/lib/types/format.d.ts +1 -0
- package/lib/types/format.js +2 -0
- package/lib/types/format.js.map +1 -0
- package/lib/types/gir-alias-element.d.ts +3 -12
- package/lib/types/gir-bitfield-element.d.ts +3 -14
- package/lib/types/gir-callable-param-element.d.ts +3 -31
- package/lib/types/gir-callable-params.d.ts +7 -0
- package/lib/types/gir-callable-params.js +2 -0
- package/lib/types/gir-callable-params.js.map +1 -0
- package/lib/types/gir-callable-return.d.ts +3 -20
- package/lib/types/gir-callback-element.d.ts +3 -12
- package/lib/types/gir-class-element.d.ts +3 -34
- package/lib/types/gir-constant-element.d.ts +3 -14
- package/lib/types/gir-constructor-element.d.ts +3 -5
- package/lib/types/gir-enum-element.d.ts +3 -16
- package/lib/types/gir-field-element.d.ts +3 -16
- package/lib/types/gir-function-element.d.ts +3 -5
- package/lib/types/gir-instance-parameter.d.ts +2 -17
- package/lib/types/gir-interface-element.d.ts +4 -19
- package/lib/types/gir-member-element.d.ts +4 -16
- package/lib/types/gir-method-element.d.ts +4 -10
- package/lib/types/gir-module-resolved-by.d.ts +5 -0
- package/lib/types/gir-namespace.d.ts +14 -17
- package/lib/types/gir-property-element.d.ts +3 -22
- package/lib/types/gir-record-element.d.ts +3 -23
- package/lib/types/gir-repository.d.ts +3 -14
- package/lib/types/gir-signal.d.ts +3 -18
- package/lib/types/gir-union-element.d.ts +3 -16
- package/lib/types/gir-virtual-method.d.ts +3 -7
- package/lib/types/index.d.ts +10 -56
- package/lib/types/index.js +10 -56
- package/lib/types/index.js.map +1 -1
- package/lib/types/metadata.d.ts +8 -0
- package/lib/types/metadata.js +2 -0
- package/lib/types/metadata.js.map +1 -0
- package/lib/types/options-base.d.ts +4 -0
- package/lib/types/options-base.js +2 -0
- package/lib/types/options-base.js.map +1 -0
- package/lib/types/options-generation.d.ts +44 -0
- package/lib/types/options-generation.js +2 -0
- package/lib/types/options-generation.js.map +1 -0
- package/lib/types/options-load.d.ts +5 -0
- package/lib/types/options-load.js +2 -0
- package/lib/types/options-load.js.map +1 -0
- package/lib/types/options-transform.d.ts +4 -0
- package/lib/types/options-transform.js +2 -0
- package/lib/types/options-transform.js.map +1 -0
- package/lib/types/output-format.d.ts +1 -0
- package/lib/types/output-format.js +2 -0
- package/lib/types/output-format.js.map +1 -0
- package/lib/types/parsed-gir.d.ts +3 -2
- package/lib/types/property-case.d.ts +1 -0
- package/lib/types/property-case.js +2 -0
- package/lib/types/property-case.js.map +1 -0
- package/lib/types/template-data.d.ts +2 -2
- package/lib/types/transformations.d.ts +1 -8
- package/lib/types/user-config.d.ts +20 -16
- package/lib/util.d.ts +20 -0
- package/lib/util.js +67 -0
- package/lib/util.js.map +1 -0
- package/lib/utils/files.d.ts +21 -0
- package/lib/utils/files.js +62 -0
- package/lib/utils/files.js.map +1 -0
- package/lib/utils/girs.d.ts +45 -0
- package/lib/utils/girs.js +101 -0
- package/lib/utils/girs.js.map +1 -0
- package/lib/utils/index.d.ts +6 -0
- package/lib/utils/index.js +7 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/numbers.d.ts +6 -0
- package/lib/utils/numbers.js +10 -0
- package/lib/utils/numbers.js.map +1 -0
- package/lib/utils/objects.d.ts +135 -0
- package/lib/utils/objects.js +122 -0
- package/lib/utils/objects.js.map +1 -0
- package/lib/utils/path.d.ts +1 -0
- package/lib/utils/path.js +7 -0
- package/lib/utils/path.js.map +1 -0
- package/lib/utils/strings.d.ts +74 -0
- package/lib/utils/strings.js +121 -0
- package/lib/utils/strings.js.map +1 -0
- package/lib/utils.d.ts +22 -44
- package/lib/utils.js +58 -69
- package/lib/utils.js.map +1 -1
- package/lib/validators/class.d.ts +7 -0
- package/lib/validators/class.js +217 -0
- package/lib/validators/class.js.map +1 -0
- package/lib/validators/interface.d.ts +5 -0
- package/lib/validators/interface.js +16 -0
- package/lib/validators/interface.js.map +1 -0
- package/lib/visitor.d.ts +35 -0
- package/lib/visitor.js +29 -0
- package/lib/visitor.js.map +1 -0
- package/package.json +20 -15
- package/lib/conflict-resolver.d.ts +0 -156
- package/lib/conflict-resolver.js +0 -1117
- package/lib/conflict-resolver.js.map +0 -1
- package/lib/gir-factory.d.ts +0 -52
- package/lib/gir-factory.js +0 -376
- package/lib/gir-factory.js.map +0 -1
- package/lib/gir-parser.d.ts +0 -2
- package/lib/gir-parser.js +0 -69
- package/lib/gir-parser.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/gjs/gio-2.0.d.ts +0 -5
- package/lib/injection/classes/gjs/gio-2.0.js +0 -254
- package/lib/injection/classes/gjs/gio-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 -225
- 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/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/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/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/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/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/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/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/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/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 -140
- package/lib/injection/injector.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/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/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/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 -41
- package/lib/types/generate-config.js +0 -2
- package/lib/types/generate-config.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-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.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-direction.d.ts +0 -7
- package/lib/types/gir-direction.js +0 -9
- 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-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-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-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 -9
- 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-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/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/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/promisify-func.d.ts +0 -7
- package/lib/types/promisify-func.js +0 -2
- package/lib/types/promisify-func.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/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-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 -55
- 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 -26
- 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
|
@@ -0,0 +1,867 @@
|
|
|
1
|
+
import { Logger } from "../logger.js";
|
|
2
|
+
import { FormatGenerator } from "./generator.js";
|
|
3
|
+
import { IntrospectedBaseClass, IntrospectedRecord, IntrospectedInterface, IntrospectedClass } from "../gir/class.js";
|
|
4
|
+
import { IntrospectedConstant } from "../gir/const.js";
|
|
5
|
+
import { IntrospectedEnum, IntrospectedError } from "../gir/enum.js";
|
|
6
|
+
import { IntrospectedSignalType } from "../gir/signal.js";
|
|
7
|
+
import { IntrospectedFunction, IntrospectedConstructor, IntrospectedFunctionParameter, IntrospectedCallback } from "../gir/function.js";
|
|
8
|
+
import { IntrospectedClassFunction, IntrospectedStaticClassFunction, IntrospectedVirtualClassFunction } from "../gir/function.js";
|
|
9
|
+
import { sanitizeIdentifierName, isInvalid, resolveDirectedType } from "../gir/util.js";
|
|
10
|
+
import { NativeType, AnyType, VoidType, StringType, NumberType, ArrayType, TypeIdentifier, OrType, TupleType, NullableType, ClosureType, AnyFunctionType, TypeConflict } from "../gir.js";
|
|
11
|
+
import { GirDirection } from "@gi.ts/parser";
|
|
12
|
+
import { IntrospectedAlias } from "../gir/alias.js";
|
|
13
|
+
function generateType(type) {
|
|
14
|
+
if (type instanceof TypeIdentifier) {
|
|
15
|
+
return {
|
|
16
|
+
kind: "identifier" /* TypeKind.identifier */,
|
|
17
|
+
name: type.name,
|
|
18
|
+
namespace: type.namespace
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
else if (type instanceof NativeType) {
|
|
22
|
+
return {
|
|
23
|
+
kind: "native" /* TypeKind.native */,
|
|
24
|
+
type: type.expression()
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
else if (type instanceof ClosureType) {
|
|
28
|
+
return {
|
|
29
|
+
kind: "closure" /* TypeKind.closure */,
|
|
30
|
+
type: generateType(type.type),
|
|
31
|
+
user_data: type.user_data
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else if (type instanceof ArrayType) {
|
|
35
|
+
return {
|
|
36
|
+
kind: "array" /* TypeKind.array */,
|
|
37
|
+
type: generateType(type.type),
|
|
38
|
+
depth: type.arrayDepth
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
else if (type instanceof NullableType) {
|
|
42
|
+
return {
|
|
43
|
+
kind: "null" /* TypeKind.nulled */,
|
|
44
|
+
type: generateType(type.type)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
else if (type instanceof TypeConflict) {
|
|
48
|
+
// Type conflicts aren't considered in JSON outputs.
|
|
49
|
+
return generateType(type.type);
|
|
50
|
+
}
|
|
51
|
+
else if (type instanceof TupleType) {
|
|
52
|
+
return {
|
|
53
|
+
kind: "tuple" /* TypeKind.tuple */,
|
|
54
|
+
types: type.types.map(t => generateType(t))
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
else if (type instanceof OrType) {
|
|
58
|
+
return {
|
|
59
|
+
kind: "or" /* TypeKind.or */,
|
|
60
|
+
types: type.types.map(t => generateType(t))
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return {
|
|
65
|
+
kind: "native" /* TypeKind.native */,
|
|
66
|
+
type: "any"
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function capitalize(str) {
|
|
71
|
+
if (str.length === 0) {
|
|
72
|
+
return "";
|
|
73
|
+
}
|
|
74
|
+
if (str.length === 1) {
|
|
75
|
+
return str[0].toUpperCase();
|
|
76
|
+
}
|
|
77
|
+
return str[0].toUpperCase() + str.substring(1).toLowerCase();
|
|
78
|
+
}
|
|
79
|
+
export class JsonGenerator extends FormatGenerator {
|
|
80
|
+
log;
|
|
81
|
+
constructor(namespace, options) {
|
|
82
|
+
super(namespace, options);
|
|
83
|
+
this.log = new Logger(options.verbose, JsonGenerator.name);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Intelligently reformats # and () references
|
|
87
|
+
* to handle c-prefixes and namespacing.
|
|
88
|
+
*
|
|
89
|
+
* @param doc
|
|
90
|
+
*/
|
|
91
|
+
generateDoc(doc) {
|
|
92
|
+
const { namespace } = this;
|
|
93
|
+
function resolveClass(ns, className) {
|
|
94
|
+
let classes = ns.getMembers(className);
|
|
95
|
+
let plural = false;
|
|
96
|
+
if (classes.length === 0 && className.endsWith("Class")) {
|
|
97
|
+
classes = ns.getMembers(className.slice(0, -5));
|
|
98
|
+
}
|
|
99
|
+
if (classes.length === 0 && className.endsWith("Iface")) {
|
|
100
|
+
classes = ns.getMembers(className.slice(0, -5));
|
|
101
|
+
}
|
|
102
|
+
if (classes.length === 0 && className.endsWith("Interface")) {
|
|
103
|
+
classes = ns.getMembers(className.slice(0, -9));
|
|
104
|
+
}
|
|
105
|
+
if (classes.length === 0 && className.endsWith("s")) {
|
|
106
|
+
plural = true;
|
|
107
|
+
classes = ns.getMembers(className.slice(0, -1));
|
|
108
|
+
}
|
|
109
|
+
return [classes[0] ?? null, plural];
|
|
110
|
+
}
|
|
111
|
+
function formatReference(identifier, member_name, punc) {
|
|
112
|
+
const parts = identifier
|
|
113
|
+
.split(/([A-Z])/)
|
|
114
|
+
.filter(p => p != "")
|
|
115
|
+
.reduce((prev, next) => {
|
|
116
|
+
if (next.toUpperCase() === next) {
|
|
117
|
+
prev.push(`${next}`);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
const lastCapital = prev.pop();
|
|
121
|
+
prev.push(`${lastCapital}${next}`);
|
|
122
|
+
}
|
|
123
|
+
return prev;
|
|
124
|
+
}, []);
|
|
125
|
+
const [base_part] = parts;
|
|
126
|
+
const [, , namespaces, className] = parts.slice(1).reduce(([underscore, camel, ns, selected], next) => {
|
|
127
|
+
const next_underscore = [underscore, next.toLowerCase()].join("_");
|
|
128
|
+
const namespaces = namespace.getImportsForCPrefix(next_underscore);
|
|
129
|
+
const nextCamel = camel + capitalize(next);
|
|
130
|
+
if (namespaces.length > 0) {
|
|
131
|
+
return [next_underscore, nextCamel, namespaces, capitalize(next)];
|
|
132
|
+
}
|
|
133
|
+
return [next_underscore, nextCamel, ns, selected + capitalize(next)];
|
|
134
|
+
}, [
|
|
135
|
+
base_part.toLowerCase(),
|
|
136
|
+
capitalize(base_part),
|
|
137
|
+
namespace.getImportsForCPrefix(base_part.toLowerCase()),
|
|
138
|
+
""
|
|
139
|
+
]);
|
|
140
|
+
let ns = namespaces.find(n => n.hasSymbol(className));
|
|
141
|
+
if (!ns) {
|
|
142
|
+
ns = namespaces.find(n => {
|
|
143
|
+
const [c] = resolveClass(n, className);
|
|
144
|
+
return c != null;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (ns) {
|
|
148
|
+
const is_prop = punc === ":";
|
|
149
|
+
const modified_name = is_prop ? member_name.replace(/[\-]/g, "_") : member_name;
|
|
150
|
+
const [clazz, plural] = resolveClass(ns, className);
|
|
151
|
+
if (clazz instanceof IntrospectedBaseClass || clazz instanceof IntrospectedEnum) {
|
|
152
|
+
const r = `#${plural ? "{" : ""}${ns.namespace}.${clazz.name}${punc ? `${punc}${modified_name}` : ""}${plural ? "}s" : ""}`;
|
|
153
|
+
return r;
|
|
154
|
+
}
|
|
155
|
+
return `#${ns.namespace}${punc ? ` (${punc}${modified_name})` : ""}`;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function formatFunctionReference(func, upper = false) {
|
|
162
|
+
// namespace_class_do_thing()
|
|
163
|
+
const parts = func.toLowerCase().split("_");
|
|
164
|
+
// ['namespace', 'class', 'do', 'thing']
|
|
165
|
+
const [base_part] = parts;
|
|
166
|
+
// ['namespace']
|
|
167
|
+
const namespaceBase = [
|
|
168
|
+
base_part.toLowerCase(),
|
|
169
|
+
capitalize(base_part),
|
|
170
|
+
namespace.getImportsForCPrefix(base_part.toLowerCase()),
|
|
171
|
+
0
|
|
172
|
+
];
|
|
173
|
+
// ['namespace', 'Namespace', { Namespace }, -1]
|
|
174
|
+
const [, , namespaces, i] = parts.slice(1).reduce(([prev, camel, currentNamespaces, selected], next, i) => {
|
|
175
|
+
const underscore = [prev, next.toLowerCase()].join("_");
|
|
176
|
+
const namespaces = namespace.getImportsForCPrefix(underscore);
|
|
177
|
+
const identifier = camel + capitalize(next);
|
|
178
|
+
// We've found namespace(s) which matches the c_prefix
|
|
179
|
+
if (namespaces.length > 0) {
|
|
180
|
+
return [underscore, identifier, namespaces, i];
|
|
181
|
+
}
|
|
182
|
+
return [underscore, identifier, currentNamespaces, selected];
|
|
183
|
+
}, namespaceBase);
|
|
184
|
+
// If no namespaces are found for the function's c_prefix, we return the original reference.
|
|
185
|
+
if (namespaces.length === 0) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
// ['class', 'do', 'thing']
|
|
189
|
+
const nameParts = parts.slice(i + 1);
|
|
190
|
+
// 'class_do_thing'
|
|
191
|
+
const functionName = nameParts.join("_");
|
|
192
|
+
const functionNamespace = namespaces.find(n => n.hasSymbol(functionName.toLowerCase()));
|
|
193
|
+
const constNamespace = namespaces.find(n => n.hasSymbol(functionName.toUpperCase()));
|
|
194
|
+
const enumNamespace = namespaces.find(n => n.enum_constants.has(func.toUpperCase()));
|
|
195
|
+
if (functionNamespace) {
|
|
196
|
+
const [member = null] = functionNamespace.getMembers(functionName.toLowerCase());
|
|
197
|
+
if (member instanceof IntrospectedFunction) {
|
|
198
|
+
return `${functionNamespace.namespace}.${member.name}`;
|
|
199
|
+
}
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
else if (constNamespace) {
|
|
203
|
+
const [member = null] = constNamespace.getMembers(functionName.toUpperCase());
|
|
204
|
+
if (member instanceof IntrospectedConstant) {
|
|
205
|
+
return `${constNamespace.namespace}.${member.name}`;
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
else if (enumNamespace) {
|
|
210
|
+
const constantInfo = enumNamespace.enum_constants.get(func.toUpperCase());
|
|
211
|
+
if (constantInfo) {
|
|
212
|
+
const [enumName, memberName] = constantInfo;
|
|
213
|
+
const [klass = null] = enumNamespace.getMembers(enumName);
|
|
214
|
+
if (klass instanceof IntrospectedEnum) {
|
|
215
|
+
return `${enumNamespace.namespace}.${klass.name}.${memberName.toUpperCase()}`;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
// ['class', 'do', 'thing']
|
|
222
|
+
const { selectedClassName, resolvedNamespace, selectedIndex } = parts.slice(i + 1).reduce(({ className, selectedClassName, resolvedNamespace, selectedIndex }, next, i) => {
|
|
223
|
+
// Class
|
|
224
|
+
const identifier = `${className}${capitalize(next)}`;
|
|
225
|
+
const withSymbol = namespaces.find(n => n.hasSymbol(identifier));
|
|
226
|
+
if (withSymbol) {
|
|
227
|
+
// { className: Class, resolvedNamespace: {Namespace}, selectedIndex: 0 }
|
|
228
|
+
return {
|
|
229
|
+
className: identifier,
|
|
230
|
+
selectedClassName: identifier,
|
|
231
|
+
resolvedNamespace: withSymbol,
|
|
232
|
+
selectedIndex: i
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
return { className: identifier, selectedClassName, resolvedNamespace, selectedIndex };
|
|
236
|
+
}, {
|
|
237
|
+
className: "",
|
|
238
|
+
selectedClassName: "",
|
|
239
|
+
resolvedNamespace: null,
|
|
240
|
+
selectedIndex: -1
|
|
241
|
+
});
|
|
242
|
+
if (resolvedNamespace && selectedIndex >= 0) {
|
|
243
|
+
const nextIndex = i + selectedIndex + 1 /* (slice omits first index) */ + 1; /* (the next index) */
|
|
244
|
+
const functionName = parts.slice(nextIndex).join("_");
|
|
245
|
+
const [klass] = resolveClass(resolvedNamespace, selectedClassName);
|
|
246
|
+
if (klass instanceof IntrospectedBaseClass || klass instanceof IntrospectedEnum) {
|
|
247
|
+
return `${resolvedNamespace.namespace}.${klass.name}.${upper ? functionName.toUpperCase() : functionName}`;
|
|
248
|
+
}
|
|
249
|
+
return `${resolvedNamespace.namespace}.${selectedClassName}.${upper ? functionName.toUpperCase() : functionName}`;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
return `${doc}`
|
|
255
|
+
.replace(/[#]{0,1}([A-Z][A-z]+)\.([a-z_]+)\(\)/g, (original, identifier, member_name) => {
|
|
256
|
+
const resolved = formatReference(identifier, member_name, ".");
|
|
257
|
+
return resolved != null ? `${resolved}()` : original;
|
|
258
|
+
})
|
|
259
|
+
.replace(/#([A-Z][A-z]*)(([:]{1,2})([a-z\-]+)){0,1}/g, (original, identifier, _, punc, member_name) => {
|
|
260
|
+
const resolved = formatReference(identifier, member_name, punc);
|
|
261
|
+
return resolved != null ? resolved : original;
|
|
262
|
+
})
|
|
263
|
+
.replace(/([A-Z][A-z]*)(([:]{1,2})([a-z\-]+))/g, (original, identifier, _, punc, member_name) => {
|
|
264
|
+
const resolved = formatReference(identifier, member_name, punc);
|
|
265
|
+
return resolved != null ? resolved : original;
|
|
266
|
+
})
|
|
267
|
+
.replace(/(\s)([a-z_]+)\(\)/g, (original, w, func) => {
|
|
268
|
+
const resolved = formatFunctionReference(func);
|
|
269
|
+
return resolved != null ? `${w}${resolved}()` : original;
|
|
270
|
+
})
|
|
271
|
+
.replace(/%([A-Z_]+)/g, (original, identifier) => {
|
|
272
|
+
const resolved = formatFunctionReference(identifier.toLowerCase(), true);
|
|
273
|
+
return resolved != null ? `%${resolved}` : original;
|
|
274
|
+
})
|
|
275
|
+
.replace(/#([A-Z_]+)/g, (original, identifier) => {
|
|
276
|
+
const resolved = formatFunctionReference(identifier.toLowerCase(), true);
|
|
277
|
+
return resolved != null ? `#${resolved}` : original;
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
generateMetadata(metadata) {
|
|
281
|
+
return { ...metadata };
|
|
282
|
+
}
|
|
283
|
+
generateParameters(parameters) {
|
|
284
|
+
const { namespace, options } = this;
|
|
285
|
+
return parameters.map(p => ({
|
|
286
|
+
kind: "parameter" /* NodeKind.parameter */,
|
|
287
|
+
direction: p.direction,
|
|
288
|
+
optional: p.isOptional,
|
|
289
|
+
varargs: p.isVarArgs,
|
|
290
|
+
name: p.name,
|
|
291
|
+
resoleNames: p.resolve_names,
|
|
292
|
+
type: generateType(p.type.resolve(namespace, options)),
|
|
293
|
+
...this._generateDocAndMetadata(p)
|
|
294
|
+
}));
|
|
295
|
+
}
|
|
296
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
297
|
+
generateCallbackType(node) {
|
|
298
|
+
return [{}, {}];
|
|
299
|
+
}
|
|
300
|
+
generateCallback(node) {
|
|
301
|
+
const { namespace, options } = this;
|
|
302
|
+
const parameters = this.generateParameters(node.parameters);
|
|
303
|
+
return {
|
|
304
|
+
kind: "callback" /* NodeKind.callback */,
|
|
305
|
+
name: node.name,
|
|
306
|
+
type: this.generateCallbackType(node),
|
|
307
|
+
parameters,
|
|
308
|
+
returnType: generateType(node.return().resolve(namespace, options)),
|
|
309
|
+
...this._generateDocAndMetadata(node)
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
generateClassCallback(node) {
|
|
313
|
+
const { namespace, options } = this;
|
|
314
|
+
const parameters = this.generateParameters(node.parameters);
|
|
315
|
+
return {
|
|
316
|
+
kind: "callback" /* NodeKind.callback */,
|
|
317
|
+
name: node.name,
|
|
318
|
+
type: this.generateCallbackType(node),
|
|
319
|
+
parameters,
|
|
320
|
+
returnType: generateType(node.return().resolve(namespace, options)),
|
|
321
|
+
...this._generateDocAndMetadata(node)
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
generateReturn(return_type, output_parameters) {
|
|
325
|
+
const { namespace, options } = this;
|
|
326
|
+
const type = return_type.resolve(namespace, options);
|
|
327
|
+
if (output_parameters.length > 0) {
|
|
328
|
+
const exclude_first = type.equals(VoidType);
|
|
329
|
+
const returns = [
|
|
330
|
+
...(exclude_first ? [] : [type]),
|
|
331
|
+
...output_parameters.map(op => op.type.resolve(namespace, options))
|
|
332
|
+
];
|
|
333
|
+
return returns.map(r => generateType(r));
|
|
334
|
+
}
|
|
335
|
+
return generateType(type);
|
|
336
|
+
}
|
|
337
|
+
generateEnum(node) {
|
|
338
|
+
return {
|
|
339
|
+
kind: "enum" /* NodeKind.enum */,
|
|
340
|
+
name: node.name,
|
|
341
|
+
members: Array.from(node.members.values()).map(member => member.asString(this)),
|
|
342
|
+
...this._generateDocAndMetadata(node)
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
generateError(node) {
|
|
346
|
+
const { namespace } = this;
|
|
347
|
+
const clazz = node.asClass();
|
|
348
|
+
clazz.members = [];
|
|
349
|
+
clazz.members.push(...Array.from(node.functions.values()));
|
|
350
|
+
const GLib = namespace.assertInstalledImport("GLib");
|
|
351
|
+
const GLibError = GLib.assertClass("Error");
|
|
352
|
+
clazz.superType = GLibError.getType();
|
|
353
|
+
// Manually construct a GLib.Error constructor.
|
|
354
|
+
clazz.mainConstructor = new IntrospectedConstructor({
|
|
355
|
+
name: "new",
|
|
356
|
+
parent: clazz,
|
|
357
|
+
parameters: [
|
|
358
|
+
new IntrospectedFunctionParameter({
|
|
359
|
+
name: "options",
|
|
360
|
+
type: NativeType.of("{ message: string, code: number}"),
|
|
361
|
+
direction: GirDirection.In
|
|
362
|
+
})
|
|
363
|
+
],
|
|
364
|
+
return_type: clazz.getType()
|
|
365
|
+
});
|
|
366
|
+
return {
|
|
367
|
+
...clazz.asString(this),
|
|
368
|
+
kind: "error" /* NodeKind.error */
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
_generateDocAndMetadata(node) {
|
|
372
|
+
const { options } = this;
|
|
373
|
+
if (!options.noComments) {
|
|
374
|
+
return {
|
|
375
|
+
private: node.isPrivate,
|
|
376
|
+
doc: this.generateDoc(node.doc ?? "") ?? null,
|
|
377
|
+
metadata: this.generateMetadata(node.metadata ?? {}) ?? null
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
return {
|
|
381
|
+
private: false,
|
|
382
|
+
doc: null,
|
|
383
|
+
metadata: null
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
generateConst(node) {
|
|
387
|
+
const { namespace, options } = this;
|
|
388
|
+
return {
|
|
389
|
+
kind: "constant" /* NodeKind.constant */,
|
|
390
|
+
name: node.name,
|
|
391
|
+
type: generateType(node.type.resolve(namespace, options)),
|
|
392
|
+
...this._generateDocAndMetadata(node)
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
implements(node) {
|
|
396
|
+
const { namespace, options } = this;
|
|
397
|
+
if (node.interfaces.length > 0) {
|
|
398
|
+
return node.interfaces
|
|
399
|
+
.map(i => i.resolveIdentifier(namespace, options))
|
|
400
|
+
.filter((i) => i != null);
|
|
401
|
+
}
|
|
402
|
+
return [];
|
|
403
|
+
}
|
|
404
|
+
extends(node) {
|
|
405
|
+
const { namespace: ns, options } = this;
|
|
406
|
+
if (node.superType) {
|
|
407
|
+
return node.superType.resolveIdentifier(ns, options);
|
|
408
|
+
}
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
411
|
+
generateInterface(node) {
|
|
412
|
+
const { namespace } = this;
|
|
413
|
+
// If an interface does not list a prerequisite type, we fill it with GObject.Object
|
|
414
|
+
if (node.superType == null) {
|
|
415
|
+
const gobject = namespace.assertInstalledImport("GObject");
|
|
416
|
+
// TODO Optimize GObject.Object
|
|
417
|
+
if (!gobject) {
|
|
418
|
+
throw new Error("GObject not generated, all interfaces extend from GObject.Object!");
|
|
419
|
+
}
|
|
420
|
+
const GObject = gobject.getClass("Object");
|
|
421
|
+
if (!GObject) {
|
|
422
|
+
throw new Error(`GObject.Object could not be found while generating ${node.namespace.namespace}.${node.name}`);
|
|
423
|
+
}
|
|
424
|
+
node.superType = GObject.getType();
|
|
425
|
+
}
|
|
426
|
+
const { name } = node;
|
|
427
|
+
const Extends = this.extends(node);
|
|
428
|
+
const Properties = node.props.map(v => v && v.asString(this));
|
|
429
|
+
const Methods = node.members
|
|
430
|
+
.filter(m => !(m instanceof IntrospectedStaticClassFunction) && !(m instanceof IntrospectedVirtualClassFunction))
|
|
431
|
+
.map(v => v && v.asString(this));
|
|
432
|
+
const StaticMethods = node.members
|
|
433
|
+
.filter((m) => m instanceof IntrospectedStaticClassFunction)
|
|
434
|
+
.map(v => v && v.asString(this));
|
|
435
|
+
const VirtualMethods = node.members
|
|
436
|
+
.filter((m) => m instanceof IntrospectedVirtualClassFunction)
|
|
437
|
+
.map(v => v && v.asString(this));
|
|
438
|
+
return {
|
|
439
|
+
kind: "interface" /* NodeKind.interface */,
|
|
440
|
+
name,
|
|
441
|
+
type: generateType(node.getType()),
|
|
442
|
+
extends: Extends ? generateType(Extends) : null,
|
|
443
|
+
props: Properties,
|
|
444
|
+
methods: Methods,
|
|
445
|
+
staticMethods: StaticMethods,
|
|
446
|
+
virtualMethods: VirtualMethods,
|
|
447
|
+
...this._generateDocAndMetadata(node)
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
generateRecord(node) {
|
|
451
|
+
const { name } = node;
|
|
452
|
+
const Extends = this.extends(node);
|
|
453
|
+
const Properties = node.props.map(v => v && v.asString(this));
|
|
454
|
+
const Fields = node.fields.map(v => v && v.asString(this));
|
|
455
|
+
const Constructors = node.constructors.map(v => v && this.generateConstructorFunction(v));
|
|
456
|
+
const Methods = node.members
|
|
457
|
+
.filter(m => !(m instanceof IntrospectedStaticClassFunction) && !(m instanceof IntrospectedVirtualClassFunction))
|
|
458
|
+
.map(v => v && v.asString(this));
|
|
459
|
+
const StaticMethods = node.members
|
|
460
|
+
.filter((m) => m instanceof IntrospectedStaticClassFunction)
|
|
461
|
+
.map(v => v && v.asString(this));
|
|
462
|
+
const VirtualMethods = node.members
|
|
463
|
+
.filter((m) => m instanceof IntrospectedVirtualClassFunction)
|
|
464
|
+
.map(v => v && v.asString(this));
|
|
465
|
+
const Callbacks = node.callbacks.map(c => c && c.asString(this));
|
|
466
|
+
return {
|
|
467
|
+
kind: "record" /* NodeKind.record */,
|
|
468
|
+
name,
|
|
469
|
+
type: generateType(node.getType()),
|
|
470
|
+
mainConstructor: node.mainConstructor?.asString(this) ?? null,
|
|
471
|
+
extends: Extends ? generateType(Extends) : null,
|
|
472
|
+
implements: [],
|
|
473
|
+
props: Properties,
|
|
474
|
+
fields: Fields,
|
|
475
|
+
constructors: Constructors,
|
|
476
|
+
methods: Methods,
|
|
477
|
+
staticMethods: StaticMethods,
|
|
478
|
+
virtualMethods: VirtualMethods,
|
|
479
|
+
callbacks: Callbacks,
|
|
480
|
+
...this._generateDocAndMetadata(node)
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
generateClass(node) {
|
|
484
|
+
const Extends = this.extends(node);
|
|
485
|
+
const Implements = this.implements(node);
|
|
486
|
+
let MainConstructor = null;
|
|
487
|
+
const ConstructorProps = node.props.map(v => this.generateProperty(v, true));
|
|
488
|
+
if (node.mainConstructor) {
|
|
489
|
+
MainConstructor = this.generateConstructor(node.mainConstructor);
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
MainConstructor = {
|
|
493
|
+
kind: "properties_constructor" /* NodeKind.propertiesConstructor */,
|
|
494
|
+
name: "new",
|
|
495
|
+
private: false,
|
|
496
|
+
properties: ConstructorProps.map(p => ({
|
|
497
|
+
kind: "parameter" /* NodeKind.parameter */,
|
|
498
|
+
private: p.private,
|
|
499
|
+
varargs: false,
|
|
500
|
+
name: p.name,
|
|
501
|
+
type: p.type,
|
|
502
|
+
doc: p.doc,
|
|
503
|
+
metadata: p.metadata,
|
|
504
|
+
optional: true
|
|
505
|
+
})),
|
|
506
|
+
doc: null,
|
|
507
|
+
metadata: null
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
const Properties = node.props.map(v => v.asString(this));
|
|
511
|
+
const Fields = node.fields.map(v => v.asString(this));
|
|
512
|
+
const Constructors = node.constructors.map(v => this.generateConstructorFunction(v));
|
|
513
|
+
const Methods = node.members
|
|
514
|
+
.filter(m => !(m instanceof IntrospectedStaticClassFunction) && !(m instanceof IntrospectedVirtualClassFunction))
|
|
515
|
+
.map(v => v && v.asString(this));
|
|
516
|
+
const StaticMethods = node.members
|
|
517
|
+
.filter((m) => m instanceof IntrospectedStaticClassFunction)
|
|
518
|
+
.map(v => v && v.asString(this));
|
|
519
|
+
const VirtualMethods = node.members
|
|
520
|
+
.filter((m) => m instanceof IntrospectedVirtualClassFunction)
|
|
521
|
+
.map(v => v && v.asString(this));
|
|
522
|
+
// TODO Move these to a cleaner place.
|
|
523
|
+
const Connect = new IntrospectedClassFunction({
|
|
524
|
+
name: "connect",
|
|
525
|
+
parent: node,
|
|
526
|
+
parameters: [
|
|
527
|
+
new IntrospectedFunctionParameter({
|
|
528
|
+
name: "id",
|
|
529
|
+
type: StringType,
|
|
530
|
+
direction: GirDirection.In
|
|
531
|
+
}),
|
|
532
|
+
new IntrospectedFunctionParameter({
|
|
533
|
+
name: "callback",
|
|
534
|
+
type: AnyFunctionType,
|
|
535
|
+
direction: GirDirection.In
|
|
536
|
+
})
|
|
537
|
+
],
|
|
538
|
+
return_type: NumberType
|
|
539
|
+
});
|
|
540
|
+
const ConnectAfter = new IntrospectedClassFunction({
|
|
541
|
+
name: "connect_after",
|
|
542
|
+
parent: node,
|
|
543
|
+
parameters: [
|
|
544
|
+
new IntrospectedFunctionParameter({
|
|
545
|
+
name: "id",
|
|
546
|
+
type: StringType,
|
|
547
|
+
direction: GirDirection.In
|
|
548
|
+
}),
|
|
549
|
+
new IntrospectedFunctionParameter({
|
|
550
|
+
name: "callback",
|
|
551
|
+
type: AnyFunctionType,
|
|
552
|
+
direction: GirDirection.In
|
|
553
|
+
})
|
|
554
|
+
],
|
|
555
|
+
return_type: NumberType
|
|
556
|
+
});
|
|
557
|
+
const Emit = new IntrospectedClassFunction({
|
|
558
|
+
name: "emit",
|
|
559
|
+
parent: node,
|
|
560
|
+
parameters: [
|
|
561
|
+
new IntrospectedFunctionParameter({
|
|
562
|
+
name: "id",
|
|
563
|
+
type: StringType,
|
|
564
|
+
direction: GirDirection.In
|
|
565
|
+
}),
|
|
566
|
+
new IntrospectedFunctionParameter({
|
|
567
|
+
name: "args",
|
|
568
|
+
isVarArgs: true,
|
|
569
|
+
type: new ArrayType(AnyType),
|
|
570
|
+
direction: GirDirection.In
|
|
571
|
+
})
|
|
572
|
+
],
|
|
573
|
+
return_type: VoidType
|
|
574
|
+
});
|
|
575
|
+
const default_signals = [];
|
|
576
|
+
let hasConnect, hasConnectAfter, hasEmit;
|
|
577
|
+
if (node.signals.length > 0) {
|
|
578
|
+
hasConnect = node.members.some(m => m.name === "connect");
|
|
579
|
+
hasConnectAfter = node.members.some(m => m.name === "connect_after");
|
|
580
|
+
hasEmit = node.members.some(m => m.name === "emit");
|
|
581
|
+
if (!hasConnect) {
|
|
582
|
+
default_signals.push(Connect);
|
|
583
|
+
}
|
|
584
|
+
if (!hasConnectAfter) {
|
|
585
|
+
default_signals.push(ConnectAfter);
|
|
586
|
+
}
|
|
587
|
+
if (!hasEmit) {
|
|
588
|
+
default_signals.push(Emit);
|
|
589
|
+
}
|
|
590
|
+
hasConnect = !default_signals.some(s => s.name === "connect");
|
|
591
|
+
hasConnectAfter = !default_signals.some(s => s.name === "connect_after");
|
|
592
|
+
hasEmit = !default_signals.some(s => s.name === "emit");
|
|
593
|
+
}
|
|
594
|
+
const SignalsList = [
|
|
595
|
+
...default_signals.map(s => s.asString(this)),
|
|
596
|
+
...node.signals
|
|
597
|
+
.map(s => {
|
|
598
|
+
const methods = [];
|
|
599
|
+
if (!hasConnect)
|
|
600
|
+
methods.push(s.asString(this, IntrospectedSignalType.CONNECT));
|
|
601
|
+
if (!hasConnectAfter)
|
|
602
|
+
methods.push(s.asString(this, IntrospectedSignalType.CONNECT_AFTER));
|
|
603
|
+
if (!hasEmit)
|
|
604
|
+
methods.push(s.asString(this, IntrospectedSignalType.EMIT));
|
|
605
|
+
return methods;
|
|
606
|
+
})
|
|
607
|
+
.flat()
|
|
608
|
+
];
|
|
609
|
+
const Signals = SignalsList;
|
|
610
|
+
return {
|
|
611
|
+
kind: "class" /* NodeKind.class */,
|
|
612
|
+
abstract: node.isAbstract,
|
|
613
|
+
type: generateType(node.getType()),
|
|
614
|
+
name: node.name,
|
|
615
|
+
mainConstructor: MainConstructor,
|
|
616
|
+
signals: Signals,
|
|
617
|
+
extends: Extends ? generateType(Extends) : null,
|
|
618
|
+
implements: Implements.map(i => generateType(i)),
|
|
619
|
+
props: Properties,
|
|
620
|
+
fields: Fields,
|
|
621
|
+
constructors: Constructors,
|
|
622
|
+
methods: Methods,
|
|
623
|
+
staticMethods: StaticMethods,
|
|
624
|
+
virtualMethods: VirtualMethods,
|
|
625
|
+
...this._generateDocAndMetadata(node)
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
generateField(node) {
|
|
629
|
+
const { namespace, options } = this;
|
|
630
|
+
const { name, computed } = node;
|
|
631
|
+
const invalid = isInvalid(name);
|
|
632
|
+
const Static = node.isStatic;
|
|
633
|
+
const ReadOnly = node.writable;
|
|
634
|
+
return {
|
|
635
|
+
kind: "field" /* NodeKind.field */,
|
|
636
|
+
readonly: ReadOnly,
|
|
637
|
+
static: Static,
|
|
638
|
+
computed,
|
|
639
|
+
type: generateType(node.type.resolve(namespace, options)),
|
|
640
|
+
name: invalid ? `"${name}"` : name,
|
|
641
|
+
...this._generateDocAndMetadata(node)
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
generateProperty(node, construct = false) {
|
|
645
|
+
const { namespace, options } = this;
|
|
646
|
+
const invalid = isInvalid(node.name);
|
|
647
|
+
const ReadOnly = node.writable || construct;
|
|
648
|
+
const Name = invalid ? `"${node.name}"` : node.name;
|
|
649
|
+
const Type = generateType(node.type.resolve(namespace, options));
|
|
650
|
+
return {
|
|
651
|
+
kind: "prop" /* NodeKind.prop */,
|
|
652
|
+
readonly: ReadOnly,
|
|
653
|
+
constructOnly: node.constructOnly,
|
|
654
|
+
readable: node.readable,
|
|
655
|
+
writable: node.writable,
|
|
656
|
+
static: false,
|
|
657
|
+
type: Type,
|
|
658
|
+
name: Name,
|
|
659
|
+
...this._generateDocAndMetadata(node)
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
generateSignal(node, type = IntrospectedSignalType.CONNECT) {
|
|
663
|
+
switch (type) {
|
|
664
|
+
case IntrospectedSignalType.CONNECT:
|
|
665
|
+
return node.asConnect(false).asString(this);
|
|
666
|
+
case IntrospectedSignalType.CONNECT_AFTER:
|
|
667
|
+
return node.asConnect(true).asString(this);
|
|
668
|
+
case IntrospectedSignalType.EMIT:
|
|
669
|
+
return node.asEmit().asString(this);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
generateEnumMember(node) {
|
|
673
|
+
const invalid = isInvalid(node.name);
|
|
674
|
+
let enumMember;
|
|
675
|
+
if (node.value != null &&
|
|
676
|
+
!Number.isNaN(Number.parseInt(node.value, 10)) &&
|
|
677
|
+
Number.isNaN(Number.parseInt(node.name, 10)) &&
|
|
678
|
+
node.name !== "NaN") {
|
|
679
|
+
enumMember = { name: invalid ? `"${node.name}"` : `${node.name}`, value: `${node.value}` };
|
|
680
|
+
}
|
|
681
|
+
else {
|
|
682
|
+
enumMember = { name: invalid ? `"${node.name}"` : `${node.name}`, value: null };
|
|
683
|
+
}
|
|
684
|
+
return {
|
|
685
|
+
kind: "enum_member" /* NodeKind.enumMember */,
|
|
686
|
+
...enumMember,
|
|
687
|
+
...this._generateDocAndMetadata(node)
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
generateParameter(node) {
|
|
691
|
+
const { namespace, options } = this;
|
|
692
|
+
const type = generateType(resolveDirectedType(node.type, node.direction)?.resolve(namespace, options) ??
|
|
693
|
+
node.type.resolve(namespace, options));
|
|
694
|
+
return {
|
|
695
|
+
kind: "parameter" /* NodeKind.parameter */,
|
|
696
|
+
name: node.name,
|
|
697
|
+
type,
|
|
698
|
+
varargs: node.isVarArgs,
|
|
699
|
+
optional: node.isOptional,
|
|
700
|
+
...this._generateDocAndMetadata(node)
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
generateFunction(node) {
|
|
704
|
+
const { namespace } = this;
|
|
705
|
+
// Register our identifier with the sanitized identifiers.
|
|
706
|
+
// We avoid doing this in fromXML because other class-level function classes
|
|
707
|
+
// depends on that code.
|
|
708
|
+
sanitizeIdentifierName(namespace.namespace, node.raw_name);
|
|
709
|
+
const Parameters = this.generateParameters(node.parameters);
|
|
710
|
+
const ReturnType = this.generateReturn(node.return(), node.output_parameters);
|
|
711
|
+
return {
|
|
712
|
+
kind: "function" /* NodeKind.function */,
|
|
713
|
+
name: node.name,
|
|
714
|
+
parameters: Parameters,
|
|
715
|
+
returnType: ReturnType,
|
|
716
|
+
...this._generateDocAndMetadata(node)
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
generateConstructorFunction(node) {
|
|
720
|
+
const { namespace, options } = this;
|
|
721
|
+
const Parameters = this.generateParameters(node.parameters);
|
|
722
|
+
return {
|
|
723
|
+
kind: "class_function" /* NodeKind.classFunction */,
|
|
724
|
+
static: true,
|
|
725
|
+
name: node.name,
|
|
726
|
+
parameters: Parameters,
|
|
727
|
+
returnType: generateType(node.return().resolve(namespace, options)),
|
|
728
|
+
...this._generateDocAndMetadata(node)
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
generateConstructor(node) {
|
|
732
|
+
return {
|
|
733
|
+
name: node.name,
|
|
734
|
+
kind: "constructor" /* NodeKind.constructor */,
|
|
735
|
+
parameters: this.generateParameters(node.parameters),
|
|
736
|
+
...this._generateDocAndMetadata(node)
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
generateDirectAllocationConstructor(node) {
|
|
740
|
+
return {
|
|
741
|
+
name: node.name,
|
|
742
|
+
kind: "constructor" /* NodeKind.constructor */,
|
|
743
|
+
parameters: this.generateParameters(node.parameters),
|
|
744
|
+
...this._generateDocAndMetadata(node)
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
generateClassFunction(node) {
|
|
748
|
+
const parameters = node.parameters.map(p => this.generateParameter(p));
|
|
749
|
+
const output_parameters = node.output_parameters;
|
|
750
|
+
const return_type = node.return();
|
|
751
|
+
const ReturnType = this.generateReturn(return_type, output_parameters);
|
|
752
|
+
return {
|
|
753
|
+
kind: "class_function" /* NodeKind.classFunction */,
|
|
754
|
+
name: node.name,
|
|
755
|
+
parameters,
|
|
756
|
+
returnType: ReturnType,
|
|
757
|
+
...this._generateDocAndMetadata(node)
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
generateStaticClassFunction(node) {
|
|
761
|
+
const parameters = node.parameters.map(p => this.generateParameter(p));
|
|
762
|
+
const output_parameters = node.output_parameters;
|
|
763
|
+
const return_type = node.return();
|
|
764
|
+
const ReturnType = this.generateReturn(return_type, output_parameters);
|
|
765
|
+
return {
|
|
766
|
+
kind: "static_class_function" /* NodeKind.staticClassFunction */,
|
|
767
|
+
name: node.name,
|
|
768
|
+
parameters,
|
|
769
|
+
returnType: ReturnType,
|
|
770
|
+
...this._generateDocAndMetadata(node)
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
generateAlias(node) {
|
|
774
|
+
const { namespace, options } = this;
|
|
775
|
+
const type = node.type.resolve(namespace, options);
|
|
776
|
+
const { name } = node;
|
|
777
|
+
return {
|
|
778
|
+
kind: "alias" /* NodeKind.alias */,
|
|
779
|
+
name,
|
|
780
|
+
type: generateType(type.resolve(namespace, options)),
|
|
781
|
+
...this._generateDocAndMetadata(node)
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
generateVirtualClassFunction(node) {
|
|
785
|
+
return {
|
|
786
|
+
...this.generateClassFunction(node),
|
|
787
|
+
kind: "virtual_class_function" /* NodeKind.virtualClassFunction */
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
generateNamespace(node) {
|
|
791
|
+
function shouldGenerate(node) {
|
|
792
|
+
return node.emit;
|
|
793
|
+
}
|
|
794
|
+
const { namespace, version } = node.dependency;
|
|
795
|
+
const members = Array.from(node.members.values())
|
|
796
|
+
.flatMap(m => m)
|
|
797
|
+
.filter(shouldGenerate);
|
|
798
|
+
const classes = members
|
|
799
|
+
.filter((m) => m instanceof IntrospectedClass)
|
|
800
|
+
.map(m => m.asString(this));
|
|
801
|
+
const interfaces = members
|
|
802
|
+
.filter((m) => m instanceof IntrospectedInterface)
|
|
803
|
+
.map(m => m.asString(this));
|
|
804
|
+
const records = members
|
|
805
|
+
.filter((m) => m instanceof IntrospectedRecord)
|
|
806
|
+
.map(m => m.asString(this));
|
|
807
|
+
const constants = members
|
|
808
|
+
.filter((m) => m instanceof IntrospectedConstant)
|
|
809
|
+
.map(m => m.asString(this));
|
|
810
|
+
const callbacks = members
|
|
811
|
+
.filter((m) => m instanceof IntrospectedCallback)
|
|
812
|
+
.map(m => m.asString(this));
|
|
813
|
+
// Functions can have overrides.
|
|
814
|
+
const functions = [
|
|
815
|
+
...members
|
|
816
|
+
.filter((m) => !(m instanceof IntrospectedCallback) && m instanceof IntrospectedFunction)
|
|
817
|
+
.reduce((prev, next) => {
|
|
818
|
+
if (!prev.has(next.name))
|
|
819
|
+
prev.set(next.name, next.asString(this));
|
|
820
|
+
return prev;
|
|
821
|
+
}, new Map())
|
|
822
|
+
.values()
|
|
823
|
+
];
|
|
824
|
+
const errors = members
|
|
825
|
+
.filter((m) => m instanceof IntrospectedError)
|
|
826
|
+
.map(m => m.asString(this));
|
|
827
|
+
const enums = members
|
|
828
|
+
.filter((m) => !(m instanceof IntrospectedError) && m instanceof IntrospectedEnum)
|
|
829
|
+
.map(m => m.asString(this));
|
|
830
|
+
const alias = members
|
|
831
|
+
.filter((m) => m instanceof IntrospectedAlias)
|
|
832
|
+
.map(m => m.asString(this));
|
|
833
|
+
// Resolve imports after we stringify everything else, sometimes we have to ad-hoc add an import.
|
|
834
|
+
const imports = [];
|
|
835
|
+
return Promise.resolve({
|
|
836
|
+
kind: "namespace" /* NodeKind.namespace */,
|
|
837
|
+
name: namespace,
|
|
838
|
+
version,
|
|
839
|
+
imports: Object.fromEntries(imports),
|
|
840
|
+
classes,
|
|
841
|
+
interfaces,
|
|
842
|
+
records,
|
|
843
|
+
constants,
|
|
844
|
+
functions,
|
|
845
|
+
callbacks,
|
|
846
|
+
errors,
|
|
847
|
+
enums,
|
|
848
|
+
alias
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
async stringifyNamespace(node) {
|
|
852
|
+
const { namespace } = this;
|
|
853
|
+
this.log.debug(`Resolving the types of ${namespace.namespace}...`);
|
|
854
|
+
try {
|
|
855
|
+
const output = await this.generateNamespace(node);
|
|
856
|
+
this.log.debug(`Printing ${namespace.namespace}...`);
|
|
857
|
+
if (!output)
|
|
858
|
+
return null;
|
|
859
|
+
return JSON.stringify(output, null, 4);
|
|
860
|
+
}
|
|
861
|
+
catch (err) {
|
|
862
|
+
this.log.error(`Failed to generate namespace: "${node.namespace}"`, err);
|
|
863
|
+
return null;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
//# sourceMappingURL=json.js.map
|