@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
package/README.md
CHANGED
package/lib/constants.d.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { LibraryVersion } from './library-version.js';
|
|
2
|
-
import type { Environment } from './types/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* In gjs all classes have a static name property but the classes listed below already have a static name property
|
|
5
|
-
*/
|
|
6
|
-
export declare const STATIC_NAME_ALREADY_EXISTS: string[];
|
|
7
2
|
export declare const COMMENT_REG_EXP: RegExp;
|
|
8
3
|
export declare const PARAM_REG_EXP: RegExp;
|
|
9
4
|
export declare const OPT_PARAM_REG_EXP: RegExp;
|
|
10
5
|
export declare const NEW_LINE_REG_EXP: RegExp;
|
|
11
|
-
export declare const MAX_CLASS_PARENT_DEPTH = 100;
|
|
12
6
|
export declare const PACKAGE: {
|
|
13
7
|
name: string;
|
|
14
8
|
version: string;
|
|
@@ -21,10 +15,11 @@ export declare const APP_NAME = "ts-for-gir";
|
|
|
21
15
|
export declare const APP_USAGE = "TypeScript type definition generator for GObject introspection GIR files";
|
|
22
16
|
export declare const APP_SOURCE = "https://github.com/gjsify/ts-for-gir";
|
|
23
17
|
export declare const APP_VERSION: string;
|
|
24
|
-
export declare const PACKAGE_DESC: (packageName: string,
|
|
25
|
-
export declare const PACKAGE_KEYWORDS: (packageName: string
|
|
26
|
-
|
|
27
|
-
export declare const
|
|
28
|
-
export declare const
|
|
29
|
-
export declare const
|
|
30
|
-
export declare const
|
|
18
|
+
export declare const PACKAGE_DESC: (packageName: string, libraryVersion?: LibraryVersion) => string;
|
|
19
|
+
export declare const PACKAGE_KEYWORDS: (packageName: string) => string;
|
|
20
|
+
/** The reserved variable names listed here cannot be resolved simply by quotation marks */
|
|
21
|
+
export declare const RESERVED_QUOTE_VARIABLE_NAMES: string[];
|
|
22
|
+
export declare const RESERVED_VARIABLE_NAMES: string[];
|
|
23
|
+
export declare const RESERVED_CLASS_NAMES: string[];
|
|
24
|
+
export declare const RESERVED_FUNCTION_NAMES: string[];
|
|
25
|
+
export declare const RESERVED_NAMESPACE_NAMES: {};
|
package/lib/constants.js
CHANGED
|
@@ -1,38 +1,93 @@
|
|
|
1
|
-
import { __dirname, readJsonFile } from './utils.js';
|
|
1
|
+
import { __dirname, readJsonFile } from './utils/index.js';
|
|
2
2
|
import { join } from 'path';
|
|
3
|
-
/**
|
|
4
|
-
* In gjs all classes have a static name property but the classes listed below already have a static name property
|
|
5
|
-
*/
|
|
6
|
-
export const STATIC_NAME_ALREADY_EXISTS = ['GMime.Charset', 'Camel.StoreInfo'];
|
|
7
3
|
export const COMMENT_REG_EXP = /\/\*.*\*\//g;
|
|
8
4
|
export const PARAM_REG_EXP = /[0-9a-zA-Z_]*:/g;
|
|
9
5
|
export const OPT_PARAM_REG_EXP = /[0-9a-zA-Z_]*\?:/g;
|
|
10
6
|
export const NEW_LINE_REG_EXP = /[\n\r]+/g;
|
|
11
|
-
export const
|
|
12
|
-
export const PACKAGE = await readJsonFile(join(__dirname, '../package.json'));
|
|
7
|
+
export const PACKAGE = await readJsonFile(join(__dirname, './package.json'));
|
|
13
8
|
export const APP_NAME = 'ts-for-gir';
|
|
14
9
|
export const APP_USAGE = 'TypeScript type definition generator for GObject introspection GIR files';
|
|
15
10
|
export const APP_SOURCE = 'https://github.com/gjsify/ts-for-gir';
|
|
16
11
|
export const APP_VERSION = PACKAGE.version;
|
|
17
|
-
export const PACKAGE_DESC = (packageName,
|
|
18
|
-
const envStr = environment === 'node' ? 'Node.js' : 'GJS';
|
|
12
|
+
export const PACKAGE_DESC = (packageName, libraryVersion) => {
|
|
19
13
|
if (libraryVersion) {
|
|
20
|
-
return
|
|
14
|
+
return `GJS TypeScript type definitions for ${packageName}, generated from library version ${libraryVersion.toString()}`;
|
|
21
15
|
}
|
|
22
|
-
return
|
|
16
|
+
return `GJS TypeScript type definitions for ${packageName}`;
|
|
23
17
|
};
|
|
24
|
-
export const PACKAGE_KEYWORDS = (packageName
|
|
25
|
-
|
|
26
|
-
return `"Gir", "TypeScript", "types", "GObject-Introspection", ${envKeywords}, "${packageName}"`;
|
|
27
|
-
};
|
|
28
|
-
export const GENERIC_NAMES = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K'];
|
|
29
|
-
export const SIGNAL_METHOD_NAMES_GENERAL = ['connect', 'emit', 'disconnect'];
|
|
30
|
-
export const SIGNAL_METHOD_NAMES_GJS = ['connect_after', 'emit'];
|
|
31
|
-
export const SIGNAL_METHOD_NAMES_NODE = ['after', 'on', 'once', 'off'];
|
|
32
|
-
export const SIGNAL_METHOD_NAMES = (env) => {
|
|
33
|
-
if (env === 'node') {
|
|
34
|
-
return [...SIGNAL_METHOD_NAMES_GENERAL, SIGNAL_METHOD_NAMES_NODE];
|
|
35
|
-
}
|
|
36
|
-
return [...SIGNAL_METHOD_NAMES_GENERAL, SIGNAL_METHOD_NAMES_GJS];
|
|
18
|
+
export const PACKAGE_KEYWORDS = (packageName) => {
|
|
19
|
+
return `"Gir", "TypeScript", "types", "GObject-Introspection", "GJS", "${packageName}"`;
|
|
37
20
|
};
|
|
21
|
+
/** The reserved variable names listed here cannot be resolved simply by quotation marks */
|
|
22
|
+
export const RESERVED_QUOTE_VARIABLE_NAMES = ['constructor'];
|
|
23
|
+
export const RESERVED_VARIABLE_NAMES = [
|
|
24
|
+
'in',
|
|
25
|
+
'function',
|
|
26
|
+
'true',
|
|
27
|
+
'false',
|
|
28
|
+
'break',
|
|
29
|
+
'arguments',
|
|
30
|
+
'eval',
|
|
31
|
+
'default',
|
|
32
|
+
'new',
|
|
33
|
+
'extends',
|
|
34
|
+
'with',
|
|
35
|
+
'var',
|
|
36
|
+
'class',
|
|
37
|
+
'delete',
|
|
38
|
+
'return',
|
|
39
|
+
'constructor',
|
|
40
|
+
'this', // TODO check if this is used as we would use this in javascript, if so, this is only allowed as the first parameter
|
|
41
|
+
];
|
|
42
|
+
export const RESERVED_CLASS_NAMES = [
|
|
43
|
+
'break',
|
|
44
|
+
'boolean',
|
|
45
|
+
'case',
|
|
46
|
+
'catch',
|
|
47
|
+
'class',
|
|
48
|
+
'const',
|
|
49
|
+
'continue',
|
|
50
|
+
'debugger',
|
|
51
|
+
'default',
|
|
52
|
+
'delete',
|
|
53
|
+
'do',
|
|
54
|
+
'else',
|
|
55
|
+
'enum',
|
|
56
|
+
'export',
|
|
57
|
+
'extends',
|
|
58
|
+
'false',
|
|
59
|
+
'finally',
|
|
60
|
+
'for',
|
|
61
|
+
'function',
|
|
62
|
+
'if',
|
|
63
|
+
'implements',
|
|
64
|
+
'import',
|
|
65
|
+
'in',
|
|
66
|
+
'instanceof',
|
|
67
|
+
'interface',
|
|
68
|
+
'let',
|
|
69
|
+
'new',
|
|
70
|
+
'number',
|
|
71
|
+
'package',
|
|
72
|
+
'private',
|
|
73
|
+
'protected',
|
|
74
|
+
'public',
|
|
75
|
+
'return',
|
|
76
|
+
'static',
|
|
77
|
+
'super',
|
|
78
|
+
'switch',
|
|
79
|
+
'string',
|
|
80
|
+
'this',
|
|
81
|
+
'throw',
|
|
82
|
+
'true',
|
|
83
|
+
'try',
|
|
84
|
+
'typeof',
|
|
85
|
+
'var',
|
|
86
|
+
'void',
|
|
87
|
+
'while',
|
|
88
|
+
'with',
|
|
89
|
+
'yield',
|
|
90
|
+
];
|
|
91
|
+
export const RESERVED_FUNCTION_NAMES = ['false', 'true', 'break'];
|
|
92
|
+
export const RESERVED_NAMESPACE_NAMES = {};
|
|
38
93
|
//# sourceMappingURL=constants.js.map
|
package/lib/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAA;AAC5C,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAA;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAA;AACpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAA;AAE1C,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,YAAY,CAOtC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAA;AAErC,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAA;AACpC,MAAM,CAAC,MAAM,SAAS,GAAG,0EAA0E,CAAA;AACnG,MAAM,CAAC,MAAM,UAAU,GAAG,sCAAsC,CAAA;AAChE,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAA;AAE1C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,WAAmB,EAAE,cAA+B,EAAE,EAAE;IACjF,IAAI,cAAc,EAAE,CAAC;QACjB,OAAO,uCAAuC,WAAW,oCAAoC,cAAc,CAAC,QAAQ,EAAE,EAAE,CAAA;IAC5H,CAAC;IACD,OAAO,uCAAuC,WAAW,EAAE,CAAA;AAC/D,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,WAAmB,EAAE,EAAE;IACpD,OAAO,kEAAkE,WAAW,GAAG,CAAA;AAC3F,CAAC,CAAA;AAED,2FAA2F;AAC3F,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,aAAa,CAAC,CAAA;AAE5D,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACnC,IAAI;IACJ,UAAU;IACV,MAAM;IACN,OAAO;IACP,OAAO;IACP,WAAW;IACX,MAAM;IACN,SAAS;IACT,KAAK;IACL,SAAS;IACT,MAAM;IACN,KAAK;IACL,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,aAAa;IACb,MAAM,EAAE,oHAAoH;CAC/H,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,OAAO;IACP,SAAS;IACT,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,UAAU;IACV,UAAU;IACV,SAAS;IACT,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,MAAM;IACN,QAAQ;IACR,SAAS;IACT,OAAO;IACP,SAAS;IACT,KAAK;IACL,UAAU;IACV,IAAI;IACJ,YAAY;IACZ,QAAQ;IACR,IAAI;IACJ,YAAY;IACZ,WAAW;IACX,KAAK;IACL,KAAK;IACL,QAAQ;IACR,SAAS;IACT,SAAS;IACT,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,QAAQ;IACR,KAAK;IACL,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;CACV,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;AAEjE,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA"}
|
|
@@ -1,27 +1,50 @@
|
|
|
1
|
+
import { GirXML, GirRepository, GirNamespace } from '@gi.ts/parser';
|
|
1
2
|
import { Logger } from './logger.js';
|
|
2
3
|
import { Transformation } from './transformation.js';
|
|
3
|
-
import
|
|
4
|
+
import { LibraryVersion } from './library-version.js';
|
|
5
|
+
import type { Dependency, OptionsGeneration, GirInclude, FileInfo } from './types/index.js';
|
|
4
6
|
import type { GirModule } from './gir-module.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
import { GirNSRegistry } from './registry.js';
|
|
8
|
+
export declare class DependencyManager extends GirNSRegistry {
|
|
9
|
+
protected readonly config: OptionsGeneration;
|
|
7
10
|
protected log: Logger;
|
|
8
11
|
protected transformation: Transformation;
|
|
9
|
-
|
|
12
|
+
protected _cache: {
|
|
10
13
|
[packageName: string]: Dependency;
|
|
11
14
|
};
|
|
12
15
|
static instances: {
|
|
13
|
-
[
|
|
16
|
+
[key: string]: DependencyManager;
|
|
14
17
|
};
|
|
15
|
-
protected constructor(config:
|
|
18
|
+
protected constructor(config: OptionsGeneration);
|
|
16
19
|
/**
|
|
17
20
|
* Get the DependencyManager singleton instance
|
|
18
21
|
*/
|
|
19
|
-
static getInstance(config
|
|
20
|
-
protected
|
|
22
|
+
static getInstance(config?: OptionsGeneration): DependencyManager;
|
|
23
|
+
protected parsePackageName(namespaceOrPackageName: string, version?: string): {
|
|
21
24
|
packageName: string;
|
|
22
25
|
namespace: string;
|
|
23
26
|
version: string;
|
|
24
27
|
};
|
|
28
|
+
protected parseArgs(namespaceOrPackageNameOrRepo: string | GirRepository, version?: string): {
|
|
29
|
+
repo: null;
|
|
30
|
+
namespace: string;
|
|
31
|
+
importNamespace: string;
|
|
32
|
+
version: string;
|
|
33
|
+
libraryVersion: LibraryVersion;
|
|
34
|
+
packageName: string;
|
|
35
|
+
importName: string;
|
|
36
|
+
importPath: string;
|
|
37
|
+
importDef: string;
|
|
38
|
+
girXML: GirXML | null;
|
|
39
|
+
path: string | null;
|
|
40
|
+
filename: string;
|
|
41
|
+
exists: boolean;
|
|
42
|
+
} | {
|
|
43
|
+
packageName: string;
|
|
44
|
+
namespace: string;
|
|
45
|
+
version: string;
|
|
46
|
+
repo: GirRepository | null;
|
|
47
|
+
};
|
|
25
48
|
/**
|
|
26
49
|
* Get all dependencies in the cache
|
|
27
50
|
* @returns All dependencies in the cache
|
|
@@ -32,26 +55,48 @@ export declare class DependencyManager {
|
|
|
32
55
|
* Get the core dependencies
|
|
33
56
|
* @returns
|
|
34
57
|
*/
|
|
35
|
-
core(): Dependency[]
|
|
36
|
-
createImportProperties(namespace: string, packageName: string): {
|
|
58
|
+
core(): Promise<Dependency[]>;
|
|
59
|
+
createImportProperties(namespace: string, packageName: string, version: string): {
|
|
37
60
|
importPath: string;
|
|
38
61
|
importDef: string;
|
|
39
62
|
};
|
|
40
|
-
createImportPath(packageName: string): string;
|
|
63
|
+
createImportPath(packageName: string, namespace: string, version: string): string;
|
|
41
64
|
createImportDef(namespace: string, importPath: string): string;
|
|
65
|
+
protected parseGir(path: string): Promise<{
|
|
66
|
+
girXML: GirXML;
|
|
67
|
+
repo: GirRepository;
|
|
68
|
+
ns: GirNamespace | undefined;
|
|
69
|
+
version: string | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
protected parseGirAndReturnLatestVersion(filesInfo: FileInfo[]): Promise<{
|
|
72
|
+
libraryVersion: LibraryVersion;
|
|
73
|
+
girXML: GirXML;
|
|
74
|
+
fileInfo: FileInfo;
|
|
75
|
+
} | {
|
|
76
|
+
libraryVersion: LibraryVersion;
|
|
77
|
+
girXML: null;
|
|
78
|
+
fileInfo: FileInfo;
|
|
79
|
+
}>;
|
|
42
80
|
/**
|
|
43
81
|
* Get the dependency object by packageName
|
|
44
82
|
* @param packageName The package name (with version affix) of the dependency
|
|
45
83
|
* @returns The dependency object
|
|
46
84
|
*/
|
|
47
|
-
get(packageName: string): Dependency
|
|
85
|
+
get(packageName: string): Promise<Dependency>;
|
|
48
86
|
/**
|
|
49
87
|
* Get the dependency object by namespace and version
|
|
50
88
|
* @param namespace The namespace of the dependency
|
|
51
89
|
* @param version The version of the dependency
|
|
52
90
|
* @returns The dependency object
|
|
53
91
|
*/
|
|
54
|
-
get(namespace: string, version: string): Dependency
|
|
92
|
+
get(namespace: string, version: string): Promise<Dependency>;
|
|
93
|
+
/**
|
|
94
|
+
* Get the dependency object by {@link GirRepository}
|
|
95
|
+
* @param namespace The namespace of the dependency
|
|
96
|
+
* @param version The version of the dependency
|
|
97
|
+
* @returns The dependency object
|
|
98
|
+
*/
|
|
99
|
+
get(repo: GirRepository): Promise<Dependency>;
|
|
55
100
|
/**
|
|
56
101
|
* Get all dependencies with the given namespace
|
|
57
102
|
* @param namespace The namespace of the dependency
|
|
@@ -68,13 +113,13 @@ export declare class DependencyManager {
|
|
|
68
113
|
* Add all dependencies from an array of gir modules
|
|
69
114
|
* @param girModules
|
|
70
115
|
*/
|
|
71
|
-
addAll(girModules: GirModule[]): Dependency[]
|
|
116
|
+
addAll(girModules: GirModule[]): Promise<Dependency[]>;
|
|
72
117
|
/**
|
|
73
118
|
* Transforms a gir include object array to a dependency object array
|
|
74
119
|
* @param girIncludes - Array of gir includes
|
|
75
120
|
* @returns Array of dependencies
|
|
76
121
|
*/
|
|
77
|
-
fromGirIncludes(girIncludes: GirInclude[]): Dependency[]
|
|
122
|
+
fromGirIncludes(girIncludes: GirInclude[]): Promise<Dependency[]>;
|
|
78
123
|
/**
|
|
79
124
|
* Check if multiple dependencies with the given namespace exist in the cache
|
|
80
125
|
* @param namespace The namespace of the dependency
|
|
@@ -102,5 +147,4 @@ export declare class DependencyManager {
|
|
|
102
147
|
find(namespace: string): Dependency | null;
|
|
103
148
|
protected getPseudoPackage(packageName: string): Dependency;
|
|
104
149
|
getGjs(): Dependency;
|
|
105
|
-
getNodeGtk(): Dependency;
|
|
106
150
|
}
|
|
@@ -1,28 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parser } from '@gi.ts/parser';
|
|
2
|
+
import { readFile } from 'fs/promises';
|
|
3
|
+
import { findFilesInDirs, splitModuleName, pascalCase } from './utils/index.js';
|
|
4
|
+
import { sanitizeNamespace } from './gir/util.js';
|
|
2
5
|
import { Logger } from './logger.js';
|
|
3
6
|
import { Transformation } from './transformation.js';
|
|
4
|
-
|
|
7
|
+
import { LibraryVersion } from './library-version.js';
|
|
8
|
+
import { GirNSRegistry } from './registry.js';
|
|
9
|
+
export class DependencyManager extends GirNSRegistry {
|
|
5
10
|
config;
|
|
6
11
|
log;
|
|
7
12
|
transformation;
|
|
8
|
-
|
|
13
|
+
_cache = {};
|
|
9
14
|
static instances = {};
|
|
10
15
|
constructor(config) {
|
|
16
|
+
super();
|
|
11
17
|
this.config = config;
|
|
12
|
-
this.transformation =
|
|
13
|
-
this.log = new Logger(config.
|
|
18
|
+
this.transformation = Transformation.getSingleton(config);
|
|
19
|
+
this.log = new Logger(config.verbose, 'DependencyManager');
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
22
|
* Get the DependencyManager singleton instance
|
|
17
23
|
*/
|
|
18
24
|
static getInstance(config) {
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
const configKey = config ? JSON.stringify(config) : Object.keys(this.instances)[0];
|
|
26
|
+
if (this.instances[configKey]) {
|
|
27
|
+
return this.instances[configKey];
|
|
21
28
|
}
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
if (!config) {
|
|
30
|
+
throw new Error('config parameter is required to initialize DependencyManager');
|
|
31
|
+
}
|
|
32
|
+
const instance = new DependencyManager(config);
|
|
33
|
+
this.instances[configKey] = instance;
|
|
34
|
+
return instance;
|
|
24
35
|
}
|
|
25
|
-
|
|
36
|
+
parsePackageName(namespaceOrPackageName, version) {
|
|
26
37
|
let packageName;
|
|
27
38
|
let namespace;
|
|
28
39
|
if (version) {
|
|
@@ -37,34 +48,63 @@ export class DependencyManager {
|
|
|
37
48
|
}
|
|
38
49
|
return { packageName, namespace, version };
|
|
39
50
|
}
|
|
51
|
+
parseArgs(namespaceOrPackageNameOrRepo, version) {
|
|
52
|
+
let packageName;
|
|
53
|
+
let namespace;
|
|
54
|
+
let repo = null;
|
|
55
|
+
if (typeof namespaceOrPackageNameOrRepo === 'string') {
|
|
56
|
+
// Special case for Gjs
|
|
57
|
+
if (namespaceOrPackageNameOrRepo === 'Gjs') {
|
|
58
|
+
return { ...this.getGjs(), repo: null };
|
|
59
|
+
}
|
|
60
|
+
const args = this.parsePackageName(namespaceOrPackageNameOrRepo, version);
|
|
61
|
+
version = args.version;
|
|
62
|
+
packageName = args.packageName;
|
|
63
|
+
namespace = args.namespace;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
repo = namespaceOrPackageNameOrRepo;
|
|
67
|
+
const ns = repo.namespace?.[0];
|
|
68
|
+
if (!ns) {
|
|
69
|
+
throw new Error('Invalid GirRepository');
|
|
70
|
+
}
|
|
71
|
+
version = ns.$.version;
|
|
72
|
+
namespace = ns.$.name;
|
|
73
|
+
packageName = `${namespace}-${version}`;
|
|
74
|
+
}
|
|
75
|
+
return { packageName, namespace, version, repo };
|
|
76
|
+
}
|
|
40
77
|
/**
|
|
41
78
|
* Get all dependencies in the cache
|
|
42
79
|
* @returns All dependencies in the cache
|
|
43
80
|
*/
|
|
44
81
|
all() {
|
|
45
|
-
return Object.values(this.
|
|
82
|
+
return Object.values(this._cache);
|
|
46
83
|
}
|
|
47
84
|
getAllPackageNames() {
|
|
48
|
-
return Object.keys(this.
|
|
85
|
+
return Object.keys(this._cache);
|
|
49
86
|
}
|
|
50
87
|
/**
|
|
51
88
|
* Get the core dependencies
|
|
52
89
|
* @returns
|
|
53
90
|
*/
|
|
54
|
-
core() {
|
|
55
|
-
return [this.get('GObject
|
|
91
|
+
async core() {
|
|
92
|
+
return [await this.get('GObject', '2.0'), await this.get('GLib', '2.0'), await this.get('Gio', '2.0')];
|
|
56
93
|
}
|
|
57
|
-
createImportProperties(namespace, packageName) {
|
|
58
|
-
const importPath = this.createImportPath(packageName);
|
|
94
|
+
createImportProperties(namespace, packageName, version) {
|
|
95
|
+
const importPath = this.createImportPath(packageName, namespace, version);
|
|
59
96
|
const importDef = this.createImportDef(namespace, importPath);
|
|
60
97
|
return {
|
|
61
98
|
importPath,
|
|
62
99
|
importDef,
|
|
63
100
|
};
|
|
64
101
|
}
|
|
65
|
-
createImportPath(packageName) {
|
|
102
|
+
createImportPath(packageName, namespace, version) {
|
|
103
|
+
if (!this.config.package) {
|
|
104
|
+
return `gi://${namespace}?version=${version}`;
|
|
105
|
+
}
|
|
66
106
|
const importName = this.transformation.transformImportName(packageName);
|
|
67
|
-
const importPath =
|
|
107
|
+
const importPath = `${this.config.npmScope}/${importName}`;
|
|
68
108
|
return importPath;
|
|
69
109
|
}
|
|
70
110
|
createImportDef(namespace, importPath) {
|
|
@@ -72,35 +112,86 @@ export class DependencyManager {
|
|
|
72
112
|
? `import type * as ${namespace} from '${importPath}'`
|
|
73
113
|
: `import type ${namespace} from '${importPath}';`;
|
|
74
114
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
115
|
+
async parseGir(path) {
|
|
116
|
+
const girXML = parser.parseGir(await readFile(path, 'utf8'));
|
|
117
|
+
const repo = girXML.repository[0];
|
|
118
|
+
const ns = repo?.namespace?.[0];
|
|
119
|
+
const version = ns?.$.version;
|
|
120
|
+
return { girXML, repo, ns, version };
|
|
121
|
+
}
|
|
122
|
+
async parseGirAndReturnLatestVersion(filesInfo) {
|
|
123
|
+
const libraryVersions = [];
|
|
124
|
+
if (filesInfo.length > 1) {
|
|
125
|
+
this.log.warn(`Multiple paths found for ${filesInfo[0].filename}`);
|
|
126
|
+
}
|
|
127
|
+
for (const fileInfo of filesInfo) {
|
|
128
|
+
if (!fileInfo.exists || !fileInfo.path) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const { girXML, ns, version } = await this.parseGir(fileInfo.path);
|
|
132
|
+
if (!version || !ns) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
const libraryVersion = new LibraryVersion(ns?.constant, version);
|
|
136
|
+
if (filesInfo.length > 1) {
|
|
137
|
+
this.log.muted(` - ${fileInfo.path} (${libraryVersion.toString()})`);
|
|
138
|
+
}
|
|
139
|
+
libraryVersions.push({
|
|
140
|
+
libraryVersion,
|
|
141
|
+
girXML,
|
|
142
|
+
fileInfo,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
// Compare all library versions and return the latest version
|
|
146
|
+
const latestLibraryVersion = libraryVersions.sort((a, b) => a.libraryVersion.compare(b.libraryVersion))[0];
|
|
147
|
+
if (!latestLibraryVersion) {
|
|
148
|
+
this.log.warn('No latest library version found', {
|
|
149
|
+
libraryVersions,
|
|
150
|
+
filesInfo,
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
libraryVersion: new LibraryVersion(),
|
|
154
|
+
girXML: null,
|
|
155
|
+
fileInfo: filesInfo[0],
|
|
156
|
+
};
|
|
79
157
|
}
|
|
80
|
-
|
|
81
|
-
|
|
158
|
+
if (filesInfo.length > 1) {
|
|
159
|
+
this.log.muted(`Use latest version ${latestLibraryVersion.libraryVersion.toString()}`);
|
|
82
160
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
161
|
+
return latestLibraryVersion;
|
|
162
|
+
}
|
|
163
|
+
async get(namespaceOrPackageNameOrRepo, _version) {
|
|
164
|
+
const parsedArgs = this.parseArgs(namespaceOrPackageNameOrRepo, _version);
|
|
165
|
+
const { packageName, repo } = parsedArgs;
|
|
166
|
+
let { namespace, version } = parsedArgs;
|
|
167
|
+
namespace = sanitizeNamespace(namespace);
|
|
168
|
+
if (this._cache[packageName]) {
|
|
169
|
+
const dep = this._cache[packageName];
|
|
89
170
|
return dep;
|
|
90
171
|
}
|
|
91
172
|
const filename = `${packageName}.gir`;
|
|
92
|
-
const
|
|
173
|
+
const filesInfo = await findFilesInDirs(this.config.girDirectories, filename);
|
|
174
|
+
const { libraryVersion, girXML, fileInfo } = await this.parseGirAndReturnLatestVersion(filesInfo);
|
|
175
|
+
const ns = girXML?.repository[0]?.namespace?.[0] || repo?.namespace?.[0] || null;
|
|
176
|
+
// Use the version from the gir file if it exists
|
|
177
|
+
if (ns?.$.version) {
|
|
178
|
+
version = ns?.$.version;
|
|
179
|
+
}
|
|
180
|
+
if (ns?.$.name) {
|
|
181
|
+
namespace = ns?.$.name;
|
|
182
|
+
}
|
|
93
183
|
const dependency = {
|
|
184
|
+
...fileInfo,
|
|
94
185
|
namespace,
|
|
95
|
-
exists,
|
|
96
|
-
filename,
|
|
97
|
-
path,
|
|
98
186
|
packageName,
|
|
99
187
|
importName: this.transformation.transformImportName(packageName),
|
|
188
|
+
importNamespace: this.transformation.transformModuleNamespaceName(packageName),
|
|
100
189
|
version,
|
|
101
|
-
|
|
190
|
+
libraryVersion,
|
|
191
|
+
girXML,
|
|
192
|
+
...this.createImportProperties(namespace, packageName, version),
|
|
102
193
|
};
|
|
103
|
-
this.
|
|
194
|
+
this._cache[packageName] = dependency;
|
|
104
195
|
return dependency;
|
|
105
196
|
}
|
|
106
197
|
/**
|
|
@@ -111,7 +202,7 @@ export class DependencyManager {
|
|
|
111
202
|
list(namespace) {
|
|
112
203
|
const packageNames = this.all();
|
|
113
204
|
const candidates = packageNames.filter((dep) => {
|
|
114
|
-
return dep.namespace === namespace;
|
|
205
|
+
return dep.namespace === namespace && dep.exists;
|
|
115
206
|
});
|
|
116
207
|
return candidates;
|
|
117
208
|
}
|
|
@@ -127,9 +218,9 @@ export class DependencyManager {
|
|
|
127
218
|
* Add all dependencies from an array of gir modules
|
|
128
219
|
* @param girModules
|
|
129
220
|
*/
|
|
130
|
-
addAll(girModules) {
|
|
221
|
+
async addAll(girModules) {
|
|
131
222
|
for (const girModule of girModules) {
|
|
132
|
-
this.get(girModule.namespace, girModule.version || '0.0');
|
|
223
|
+
await this.get(girModule.namespace, girModule.version || '0.0');
|
|
133
224
|
}
|
|
134
225
|
return this.all();
|
|
135
226
|
}
|
|
@@ -138,10 +229,10 @@ export class DependencyManager {
|
|
|
138
229
|
* @param girIncludes - Array of gir includes
|
|
139
230
|
* @returns Array of dependencies
|
|
140
231
|
*/
|
|
141
|
-
fromGirIncludes(girIncludes) {
|
|
232
|
+
async fromGirIncludes(girIncludes) {
|
|
142
233
|
const dependencies = [];
|
|
143
234
|
for (const i of girIncludes) {
|
|
144
|
-
dependencies.unshift(this.get(i.$.name, i.$.version || '0.0'));
|
|
235
|
+
dependencies.unshift(await this.get(i.$.name, i.$.version || '0.0'));
|
|
145
236
|
}
|
|
146
237
|
return dependencies;
|
|
147
238
|
}
|
|
@@ -153,7 +244,7 @@ export class DependencyManager {
|
|
|
153
244
|
hasConflict(namespace) {
|
|
154
245
|
const packageNames = this.getAllPackageNames();
|
|
155
246
|
const candidates = packageNames.filter((packageName) => {
|
|
156
|
-
return packageName.startsWith(`${namespace}-`) && this.
|
|
247
|
+
return packageName.startsWith(`${namespace}-`) && this._cache[packageName].namespace === namespace;
|
|
157
248
|
});
|
|
158
249
|
return candidates.length > 1;
|
|
159
250
|
}
|
|
@@ -191,44 +282,43 @@ export class DependencyManager {
|
|
|
191
282
|
if (namespace === 'Gjs') {
|
|
192
283
|
return this.getGjs();
|
|
193
284
|
}
|
|
194
|
-
else if (namespace === 'node-gtk') {
|
|
195
|
-
return this.getNodeGtk();
|
|
196
|
-
}
|
|
197
285
|
const packageNames = this.getAllPackageNames();
|
|
198
286
|
const candidates = packageNames.filter((packageName) => {
|
|
199
|
-
return packageName.startsWith(`${namespace}-`) && this.
|
|
287
|
+
return packageName.startsWith(`${namespace}-`) && this._cache[packageName].namespace === namespace;
|
|
200
288
|
});
|
|
201
289
|
if (candidates.length > 1) {
|
|
202
290
|
this.log.warn(`Found multiple versions of ${namespace}: ${candidates.join(', ')}`);
|
|
203
291
|
}
|
|
204
292
|
const latestVersion = candidates.sort().pop();
|
|
205
|
-
if (latestVersion && this.
|
|
206
|
-
const dep = this.
|
|
293
|
+
if (latestVersion && this._cache[latestVersion]) {
|
|
294
|
+
const dep = this._cache[latestVersion];
|
|
207
295
|
return dep;
|
|
208
296
|
}
|
|
209
297
|
return null;
|
|
210
298
|
}
|
|
211
299
|
getPseudoPackage(packageName) {
|
|
212
|
-
if (this.
|
|
213
|
-
return this.
|
|
300
|
+
if (this._cache[packageName]) {
|
|
301
|
+
return this._cache[packageName];
|
|
214
302
|
}
|
|
303
|
+
const namespace = pascalCase(packageName);
|
|
304
|
+
const version = '2.0';
|
|
215
305
|
const dep = {
|
|
216
|
-
namespace
|
|
306
|
+
namespace,
|
|
217
307
|
exists: true,
|
|
218
308
|
filename: '',
|
|
219
309
|
path: '',
|
|
220
310
|
packageName: packageName,
|
|
221
311
|
importName: this.transformation.transformImportName(packageName),
|
|
222
|
-
|
|
223
|
-
|
|
312
|
+
importNamespace: this.transformation.transformModuleNamespaceName(packageName),
|
|
313
|
+
version,
|
|
314
|
+
libraryVersion: new LibraryVersion(),
|
|
315
|
+
girXML: null,
|
|
316
|
+
...this.createImportProperties(packageName, packageName, version),
|
|
224
317
|
};
|
|
225
318
|
return dep;
|
|
226
319
|
}
|
|
227
320
|
getGjs() {
|
|
228
321
|
return this.getPseudoPackage('Gjs');
|
|
229
322
|
}
|
|
230
|
-
getNodeGtk() {
|
|
231
|
-
return this.getPseudoPackage('node-gtk');
|
|
232
|
-
}
|
|
233
323
|
}
|
|
234
324
|
//# sourceMappingURL=dependency-manager.js.map
|