@ts-for-gir/lib 3.3.0 → 4.0.0-beta.2

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.
Files changed (313) hide show
  1. package/README.md +0 -1
  2. package/lib/conflict-resolver.d.ts +2 -39
  3. package/lib/conflict-resolver.js +4 -228
  4. package/lib/conflict-resolver.js.map +1 -1
  5. package/lib/constants.d.ts +3 -7
  6. package/lib/constants.js +6 -16
  7. package/lib/constants.js.map +1 -1
  8. package/lib/dependency-manager.d.ts +3 -5
  9. package/lib/dependency-manager.js +10 -17
  10. package/lib/dependency-manager.js.map +1 -1
  11. package/lib/formatters/default.d.ts +4 -0
  12. package/lib/formatters/default.js +7 -0
  13. package/lib/formatters/default.js.map +1 -0
  14. package/lib/formatters/formatter.d.ts +3 -0
  15. package/lib/formatters/formatter.js +3 -0
  16. package/lib/formatters/formatter.js.map +1 -0
  17. package/lib/formatters/json.d.ts +4 -0
  18. package/lib/formatters/json.js +7 -0
  19. package/lib/formatters/json.js.map +1 -0
  20. package/lib/generators/dts/gio.d.ts +2 -0
  21. package/lib/generators/dts/gio.js +9 -0
  22. package/lib/generators/dts/gio.js.map +1 -0
  23. package/lib/generators/dts/glib.d.ts +2 -0
  24. package/lib/generators/dts/glib.js +514 -0
  25. package/lib/generators/dts/glib.js.map +1 -0
  26. package/lib/generators/dts/gobject.d.ts +2 -0
  27. package/lib/generators/dts/gobject.js +117 -0
  28. package/lib/generators/dts/gobject.js.map +1 -0
  29. package/lib/generators/dts-inline.d.ts +8 -0
  30. package/lib/generators/dts-inline.js +59 -0
  31. package/lib/generators/dts-inline.js.map +1 -0
  32. package/lib/generators/dts-modules.d.ts +8 -0
  33. package/lib/generators/dts-modules.js +100 -0
  34. package/lib/generators/dts-modules.js.map +1 -0
  35. package/lib/generators/dts.d.ts +45 -0
  36. package/lib/generators/dts.js +682 -0
  37. package/lib/generators/dts.js.map +1 -0
  38. package/lib/generators/generator.d.ts +45 -0
  39. package/lib/generators/generator.js +9 -0
  40. package/lib/generators/generator.js.map +1 -0
  41. package/lib/generators/index.d.ts +5 -0
  42. package/lib/generators/index.js +6 -0
  43. package/lib/generators/index.js.map +1 -0
  44. package/lib/generators/json.d.ts +256 -0
  45. package/lib/generators/json.js +869 -0
  46. package/lib/generators/json.js.map +1 -0
  47. package/lib/generics/clutter.d.ts +26 -0
  48. package/lib/generics/clutter.js +49 -0
  49. package/lib/generics/clutter.js.map +1 -0
  50. package/lib/generics/generify.d.ts +2 -0
  51. package/lib/generics/generify.js +39 -0
  52. package/lib/generics/generify.js.map +1 -0
  53. package/lib/generics/gio.d.ts +7 -0
  54. package/lib/generics/gio.js +51 -0
  55. package/lib/generics/gio.js.map +1 -0
  56. package/lib/generics/glib.d.ts +7 -0
  57. package/lib/generics/glib.js +18 -0
  58. package/lib/generics/glib.js.map +1 -0
  59. package/lib/generics/meta.d.ts +21 -0
  60. package/lib/generics/meta.js +26 -0
  61. package/lib/generics/meta.js.map +1 -0
  62. package/lib/generics/st.d.ts +16 -0
  63. package/lib/generics/st.js +92 -0
  64. package/lib/generics/st.js.map +1 -0
  65. package/lib/generics/visitor.d.ts +20 -0
  66. package/lib/generics/visitor.js +259 -0
  67. package/lib/generics/visitor.js.map +1 -0
  68. package/lib/gir/alias.d.ts +24 -0
  69. package/lib/gir/alias.js +43 -0
  70. package/lib/gir/alias.js.map +1 -0
  71. package/lib/gir/base.d.ts +62 -0
  72. package/lib/gir/base.js +95 -0
  73. package/lib/gir/base.js.map +1 -0
  74. package/lib/gir/class.d.ts +189 -0
  75. package/lib/gir/class.js +1132 -0
  76. package/lib/gir/class.js.map +1 -0
  77. package/lib/gir/const.d.ts +25 -0
  78. package/lib/gir/const.js +43 -0
  79. package/lib/gir/const.js.map +1 -0
  80. package/lib/gir/enum.d.ts +45 -0
  81. package/lib/gir/enum.js +164 -0
  82. package/lib/gir/enum.js.map +1 -0
  83. package/lib/gir/function.d.ts +199 -0
  84. package/lib/gir/function.js +683 -0
  85. package/lib/gir/function.js.map +1 -0
  86. package/lib/gir/generics.d.ts +5 -0
  87. package/lib/gir/generics.js +57 -0
  88. package/lib/gir/generics.js.map +1 -0
  89. package/lib/gir/namespace.d.ts +21 -0
  90. package/lib/gir/namespace.js +57 -0
  91. package/lib/gir/namespace.js.map +1 -0
  92. package/lib/gir/nodes.d.ts +11 -0
  93. package/lib/gir/nodes.js +12 -0
  94. package/lib/gir/nodes.js.map +1 -0
  95. package/lib/gir/property.d.ts +60 -0
  96. package/lib/gir/property.js +128 -0
  97. package/lib/gir/property.js.map +1 -0
  98. package/lib/gir/registry.d.ts +51 -0
  99. package/lib/gir/registry.js +144 -0
  100. package/lib/gir/registry.js.map +1 -0
  101. package/lib/gir/signal.d.ts +33 -0
  102. package/lib/gir/signal.js +165 -0
  103. package/lib/gir/signal.js.map +1 -0
  104. package/lib/gir/util.d.ts +49 -0
  105. package/lib/gir/util.js +556 -0
  106. package/lib/gir/util.js.map +1 -0
  107. package/lib/gir-factory.d.ts +2 -2
  108. package/lib/gir-factory.js +8 -44
  109. package/lib/gir-factory.js.map +1 -1
  110. package/lib/gir-module.d.ts +61 -221
  111. package/lib/gir-module.js +387 -2106
  112. package/lib/gir-module.js.map +1 -1
  113. package/lib/gir.d.ts +251 -0
  114. package/lib/gir.js +638 -0
  115. package/lib/gir.js.map +1 -0
  116. package/lib/index.d.ts +5 -4
  117. package/lib/index.js +7 -4
  118. package/lib/index.js.map +1 -1
  119. package/lib/injection/callbacks/index.d.ts +0 -1
  120. package/lib/injection/callbacks/index.js +0 -1
  121. package/lib/injection/callbacks/index.js.map +1 -1
  122. package/lib/injection/classes/index.d.ts +0 -1
  123. package/lib/injection/classes/index.js +0 -1
  124. package/lib/injection/classes/index.js.map +1 -1
  125. package/lib/injection/injector.d.ts +2 -3
  126. package/lib/injection/injector.js +6 -8
  127. package/lib/injection/injector.js.map +1 -1
  128. package/lib/injections/gee08.d.ts +7 -0
  129. package/lib/injections/gee08.js +68 -0
  130. package/lib/injections/gee08.js.map +1 -0
  131. package/lib/injections/gee1.d.ts +7 -0
  132. package/lib/injections/gee1.js +28 -0
  133. package/lib/injections/gee1.js.map +1 -0
  134. package/lib/injections/gio.d.ts +7 -0
  135. package/lib/injections/gio.js +431 -0
  136. package/lib/injections/gio.js.map +1 -0
  137. package/lib/injections/glib.d.ts +7 -0
  138. package/lib/injections/glib.js +204 -0
  139. package/lib/injections/glib.js.map +1 -0
  140. package/lib/injections/gobject.d.ts +7 -0
  141. package/lib/injections/gobject.js +479 -0
  142. package/lib/injections/gobject.js.map +1 -0
  143. package/lib/injections/inject.d.ts +4 -0
  144. package/lib/injections/inject.js +28 -0
  145. package/lib/injections/inject.js.map +1 -0
  146. package/lib/injections/tracker1.d.ts +7 -0
  147. package/lib/injections/tracker1.js +30 -0
  148. package/lib/injections/tracker1.js.map +1 -0
  149. package/lib/library-version.js.map +1 -1
  150. package/lib/logger.d.ts +1 -3
  151. package/lib/logger.js +3 -8
  152. package/lib/logger.js.map +1 -1
  153. package/lib/messages.d.ts +1 -4
  154. package/lib/messages.js +1 -3
  155. package/lib/messages.js.map +1 -1
  156. package/lib/registry.d.ts +9 -0
  157. package/lib/registry.js +13 -0
  158. package/lib/registry.js.map +1 -0
  159. package/lib/symtable.js +1 -1
  160. package/lib/symtable.js.map +1 -1
  161. package/lib/transformation.d.ts +4 -5
  162. package/lib/transformation.js +31 -127
  163. package/lib/transformation.js.map +1 -1
  164. package/lib/types/generate-config.d.ts +4 -11
  165. package/lib/types/gir-alias-element.d.ts +3 -12
  166. package/lib/types/gir-bitfield-element.d.ts +3 -14
  167. package/lib/types/gir-callable-param-element.d.ts +3 -31
  168. package/lib/types/gir-callable-params.d.ts +7 -0
  169. package/lib/types/gir-callable-params.js +2 -0
  170. package/lib/types/gir-callable-params.js.map +1 -0
  171. package/lib/types/gir-callable-return.d.ts +3 -20
  172. package/lib/types/gir-callback-element.d.ts +3 -12
  173. package/lib/types/gir-class-element.d.ts +3 -34
  174. package/lib/types/gir-constant-element.d.ts +3 -14
  175. package/lib/types/gir-constructor-element.d.ts +3 -5
  176. package/lib/types/gir-enum-element.d.ts +3 -16
  177. package/lib/types/gir-field-element.d.ts +3 -16
  178. package/lib/types/gir-function-element.d.ts +3 -5
  179. package/lib/types/gir-instance-parameter.d.ts +2 -17
  180. package/lib/types/gir-interface-element.d.ts +4 -19
  181. package/lib/types/gir-member-element.d.ts +4 -16
  182. package/lib/types/gir-method-element.d.ts +4 -10
  183. package/lib/types/gir-namespace.d.ts +14 -17
  184. package/lib/types/gir-property-element.d.ts +3 -22
  185. package/lib/types/gir-record-element.d.ts +3 -23
  186. package/lib/types/gir-repository.d.ts +3 -14
  187. package/lib/types/gir-signal.d.ts +3 -18
  188. package/lib/types/gir-union-element.d.ts +3 -16
  189. package/lib/types/gir-virtual-method.d.ts +3 -7
  190. package/lib/types/index.d.ts +3 -54
  191. package/lib/types/index.js +3 -54
  192. package/lib/types/index.js.map +1 -1
  193. package/lib/types/parsed-gir.d.ts +3 -2
  194. package/lib/types/transformations.d.ts +1 -8
  195. package/lib/types/user-config.d.ts +0 -11
  196. package/lib/types.d.ts +23 -0
  197. package/lib/types.js +2 -0
  198. package/lib/types.js.map +1 -0
  199. package/lib/util.d.ts +20 -0
  200. package/lib/util.js +67 -0
  201. package/lib/util.js.map +1 -0
  202. package/lib/utils.d.ts +2 -30
  203. package/lib/utils.js +0 -56
  204. package/lib/utils.js.map +1 -1
  205. package/lib/validators/class.d.ts +7 -0
  206. package/lib/validators/class.js +217 -0
  207. package/lib/validators/class.js.map +1 -0
  208. package/lib/validators/interface.d.ts +5 -0
  209. package/lib/validators/interface.js +16 -0
  210. package/lib/validators/interface.js.map +1 -0
  211. package/lib/visitor.d.ts +35 -0
  212. package/lib/visitor.js +29 -0
  213. package/lib/visitor.js.map +1 -0
  214. package/package.json +14 -10
  215. package/lib/gir-parser.d.ts +0 -2
  216. package/lib/gir-parser.js +0 -69
  217. package/lib/gir-parser.js.map +0 -1
  218. package/lib/injection/callbacks/node-gtk/index.d.ts +0 -2
  219. package/lib/injection/callbacks/node-gtk/index.js +0 -2
  220. package/lib/injection/callbacks/node-gtk/index.js.map +0 -1
  221. package/lib/injection/classes/node-gtk/gdk-4.0.d.ts +0 -2
  222. package/lib/injection/classes/node-gtk/gdk-4.0.js +0 -32
  223. package/lib/injection/classes/node-gtk/gdk-4.0.js.map +0 -1
  224. package/lib/injection/classes/node-gtk/gio-2.0.d.ts +0 -2
  225. package/lib/injection/classes/node-gtk/gio-2.0.js +0 -14
  226. package/lib/injection/classes/node-gtk/gio-2.0.js.map +0 -1
  227. package/lib/injection/classes/node-gtk/glib-2.0.d.ts +0 -2
  228. package/lib/injection/classes/node-gtk/glib-2.0.js +0 -19
  229. package/lib/injection/classes/node-gtk/glib-2.0.js.map +0 -1
  230. package/lib/injection/classes/node-gtk/gobject-2.0.d.ts +0 -2
  231. package/lib/injection/classes/node-gtk/gobject-2.0.js +0 -66
  232. package/lib/injection/classes/node-gtk/gobject-2.0.js.map +0 -1
  233. package/lib/injection/classes/node-gtk/graphene-1.0.d.ts +0 -2
  234. package/lib/injection/classes/node-gtk/graphene-1.0.js +0 -133
  235. package/lib/injection/classes/node-gtk/graphene-1.0.js.map +0 -1
  236. package/lib/injection/classes/node-gtk/gtk-3.0.d.ts +0 -2
  237. package/lib/injection/classes/node-gtk/gtk-3.0.js +0 -31
  238. package/lib/injection/classes/node-gtk/gtk-3.0.js.map +0 -1
  239. package/lib/injection/classes/node-gtk/gtk-4.0.d.ts +0 -2
  240. package/lib/injection/classes/node-gtk/gtk-4.0.js +0 -52
  241. package/lib/injection/classes/node-gtk/gtk-4.0.js.map +0 -1
  242. package/lib/injection/classes/node-gtk/index.d.ts +0 -2
  243. package/lib/injection/classes/node-gtk/index.js +0 -19
  244. package/lib/injection/classes/node-gtk/index.js.map +0 -1
  245. package/lib/injection/classes/node-gtk/pango-1.0.d.ts +0 -2
  246. package/lib/injection/classes/node-gtk/pango-1.0.js +0 -31
  247. package/lib/injection/classes/node-gtk/pango-1.0.js.map +0 -1
  248. package/lib/types/build-type.d.ts +0 -1
  249. package/lib/types/build-type.js +0 -2
  250. package/lib/types/build-type.js.map +0 -1
  251. package/lib/types/environment.d.ts +0 -1
  252. package/lib/types/environment.js +0 -2
  253. package/lib/types/environment.js.map +0 -1
  254. package/lib/types/gir-any-type.d.ts +0 -5
  255. package/lib/types/gir-any-type.js +0 -2
  256. package/lib/types/gir-any-type.js.map +0 -1
  257. package/lib/types/gir-array-type.d.ts +0 -20
  258. package/lib/types/gir-array-type.js +0 -3
  259. package/lib/types/gir-array-type.js.map +0 -1
  260. package/lib/types/gir-boolean.d.ts +0 -1
  261. package/lib/types/gir-boolean.js +0 -2
  262. package/lib/types/gir-boolean.js.map +0 -1
  263. package/lib/types/gir-boxed-element.d.ts +0 -15
  264. package/lib/types/gir-boxed-element.js +0 -2
  265. package/lib/types/gir-boxed-element.js.map +0 -1
  266. package/lib/types/gir-c-include.d.ts +0 -7
  267. package/lib/types/gir-c-include.js +0 -2
  268. package/lib/types/gir-c-include.js.map +0 -1
  269. package/lib/types/gir-callable-attrs.d.ts +0 -15
  270. package/lib/types/gir-callable-attrs.js +0 -3
  271. package/lib/types/gir-callable-attrs.js.map +0 -1
  272. package/lib/types/gir-callable-param.d.ts +0 -7
  273. package/lib/types/gir-callable-param.js +0 -2
  274. package/lib/types/gir-callable-param.js.map +0 -1
  275. package/lib/types/gir-direction.d.ts +0 -7
  276. package/lib/types/gir-direction.js +0 -9
  277. package/lib/types/gir-direction.js.map +0 -1
  278. package/lib/types/gir-doc-element.d.ts +0 -68
  279. package/lib/types/gir-doc-element.js +0 -2
  280. package/lib/types/gir-doc-element.js.map +0 -1
  281. package/lib/types/gir-implements.d.ts +0 -8
  282. package/lib/types/gir-implements.js +0 -2
  283. package/lib/types/gir-implements.js.map +0 -1
  284. package/lib/types/gir-include.d.ts +0 -9
  285. package/lib/types/gir-include.js +0 -2
  286. package/lib/types/gir-include.js.map +0 -1
  287. package/lib/types/gir-info-attrs.d.ts +0 -13
  288. package/lib/types/gir-info-attrs.js +0 -2
  289. package/lib/types/gir-info-attrs.js.map +0 -1
  290. package/lib/types/gir-info-elements.d.ts +0 -5
  291. package/lib/types/gir-info-elements.js +0 -2
  292. package/lib/types/gir-info-elements.js.map +0 -1
  293. package/lib/types/gir-package.d.ts +0 -7
  294. package/lib/types/gir-package.js +0 -2
  295. package/lib/types/gir-package.js.map +0 -1
  296. package/lib/types/gir-prerequisite.d.ts +0 -5
  297. package/lib/types/gir-prerequisite.js +0 -2
  298. package/lib/types/gir-prerequisite.js.map +0 -1
  299. package/lib/types/gir-transfer-ownership-type.d.ts +0 -5
  300. package/lib/types/gir-transfer-ownership-type.js +0 -7
  301. package/lib/types/gir-transfer-ownership-type.js.map +0 -1
  302. package/lib/types/gir-transfer-ownership.d.ts +0 -9
  303. package/lib/types/gir-transfer-ownership.js +0 -2
  304. package/lib/types/gir-transfer-ownership.js.map +0 -1
  305. package/lib/types/gir-type.d.ts +0 -14
  306. package/lib/types/gir-type.js +0 -2
  307. package/lib/types/gir-type.js.map +0 -1
  308. package/lib/types/gir-var-args.d.ts +0 -5
  309. package/lib/types/gir-var-args.js +0 -2
  310. package/lib/types/gir-var-args.js.map +0 -1
  311. package/lib/types/module-type.d.ts +0 -1
  312. package/lib/types/module-type.js +0 -2
  313. package/lib/types/module-type.js.map +0 -1
@@ -0,0 +1,682 @@
1
+ import { FormatGenerator } from "./generator.js";
2
+ import { IntrospectedInterface, filterConflicts, filterFunctionConflict, FilterBehavior, promisifyFunctions } from "../gir/class.js";
3
+ import { IntrospectedSignalType } from "../gir/signal.js";
4
+ import { IntrospectedConstructor, IntrospectedFunctionParameter } from "../gir/function.js";
5
+ import { IntrospectedClassFunction, IntrospectedStaticClassFunction } from "../gir/function.js";
6
+ import { sanitizeIdentifierName, isInvalid, resolveDirectedType } from "../gir/util.js";
7
+ import { NativeType, AnyType, VoidType, StringType, NumberType, ArrayType, AnyFunctionType, ConflictType, TypeConflict, BinaryType } from "../gir.js";
8
+ import { GirDirection } from "@gi.ts/parser";
9
+ export function versionImportFormat(versionFormat, namespace, version) {
10
+ const versionSlug = version.toLowerCase().split(".")[0];
11
+ const namespaceLowercase = namespace.toLowerCase();
12
+ return `${versionFormat
13
+ .replace("{version}", version)
14
+ .replace("{version-slug}", versionSlug)
15
+ .replace("{namespace}", namespace)
16
+ .replace("{namespace-lower}", namespaceLowercase)}`;
17
+ }
18
+ export class DtsGenerator extends FormatGenerator {
19
+ constructor(namespace, options) {
20
+ super(namespace, options);
21
+ }
22
+ generateParameters(parameters) {
23
+ return parameters
24
+ .map(p => {
25
+ return p.asString(this);
26
+ })
27
+ .join(", ");
28
+ }
29
+ generateGenerics(nodes, withDefaults = true) {
30
+ const { namespace, options } = this;
31
+ const list = nodes.map(generic => {
32
+ const Type = generic.type.rootPrint(namespace, options);
33
+ if (generic.defaultType && withDefaults) {
34
+ const defaultType = generic.defaultType.rootPrint(namespace, options);
35
+ if (generic.constraint) {
36
+ const constraint = generic.constraint.rootPrint(namespace, options);
37
+ return `${Type} extends ${constraint} = ${defaultType}`;
38
+ }
39
+ return `${Type} = ${defaultType}`;
40
+ }
41
+ else if (generic.constraint && withDefaults) {
42
+ const constraint = generic.constraint.rootPrint(namespace, options);
43
+ return `${Type} extends ${constraint}`;
44
+ }
45
+ else {
46
+ return `${Type}`;
47
+ }
48
+ });
49
+ if (list.length > 0) {
50
+ return `<${list.join(", ")}>`;
51
+ }
52
+ return "";
53
+ }
54
+ generateCallbackType(node) {
55
+ const { namespace, options } = this;
56
+ const Parameters = this.generateParameters(node.parameters);
57
+ if (node.generics.length > 0) {
58
+ const GenericDefinitions = this.generateGenerics(node.generics);
59
+ return [
60
+ `${GenericDefinitions}`,
61
+ `(${Parameters}) => ${node.return().resolve(namespace, options).print(namespace, options)}`
62
+ ];
63
+ }
64
+ return ["", `(${Parameters}) => ${node.return().resolve(namespace, options).print(namespace, options)}`];
65
+ }
66
+ generateCallback(node) {
67
+ return `${this.docString(node)}export type ${node.name}${this.generateCallbackType(node).join(" = ")};`;
68
+ }
69
+ generateClassCallback(node) {
70
+ return this.generateCallback(node);
71
+ }
72
+ generateReturn(return_type, output_parameters) {
73
+ const { namespace, options } = this;
74
+ const resolved_return_type = resolveDirectedType(return_type, GirDirection.Out)?.resolve(namespace, options) ??
75
+ return_type.resolve(namespace, options);
76
+ const type = resolved_return_type.rootPrint(namespace, options);
77
+ if (output_parameters.length > 0) {
78
+ const exclude_first = type === "void" || type === "";
79
+ const returns = [
80
+ ...(exclude_first ? [] : [`${type}`]),
81
+ ...output_parameters
82
+ .map(op => {
83
+ return (resolveDirectedType(op.type, GirDirection.Out)?.resolve(namespace, options) ??
84
+ op.type.resolve(namespace, options));
85
+ })
86
+ .map(p => p.rootPrint(namespace, options))
87
+ ];
88
+ if (returns.length > 1) {
89
+ return `[${returns.join(", ")}]`;
90
+ }
91
+ else {
92
+ return `${returns[0]}`;
93
+ }
94
+ }
95
+ return type;
96
+ }
97
+ generateEnum(node) {
98
+ const { namespace } = this;
99
+ const isInvalidEnum = Array.from(node.members.keys()).some(name => name.match(/^[0-9]+$/) || name === "NaN" || name === "Infinity");
100
+ if (isInvalidEnum) {
101
+ return node.asClass().asString(this);
102
+ }
103
+ // So we can use GObject.GType
104
+ this.namespace.assertInstalledImport("GObject");
105
+ return `
106
+ export namespace ${node.name} {
107
+ export const $gtype: ${namespace.name !== "GObject" ? "GObject." : ""}GType<${node.name}>;
108
+ }
109
+
110
+ ${this.docString(node)}export enum ${node.name} {
111
+ ${Array.from(node.members.values())
112
+ .map(member => `${member.asString(this)}`)
113
+ .join("\n ")}
114
+ }`;
115
+ }
116
+ generateError(node) {
117
+ const { namespace } = this;
118
+ const clazz = node.asClass();
119
+ clazz.members = [];
120
+ clazz.members.push(...Array.from(node.functions.values()));
121
+ const GLib = namespace.assertInstalledImport("GLib");
122
+ const GLibError = GLib.assertClass("Error");
123
+ clazz.superType = GLibError.getType();
124
+ // Manually construct a GLib.Error constructor.
125
+ clazz.mainConstructor = new IntrospectedConstructor({
126
+ name: "new",
127
+ parent: clazz,
128
+ parameters: [
129
+ new IntrospectedFunctionParameter({
130
+ name: "options",
131
+ type: NativeType.of("{ message: string, code: number}"),
132
+ direction: GirDirection.In
133
+ })
134
+ ],
135
+ return_type: clazz.getType()
136
+ });
137
+ return clazz.asString(this);
138
+ }
139
+ generateConst(node) {
140
+ const { namespace, options } = this;
141
+ return `${this.docString(node)}export const ${node.name}: ${node.type
142
+ .resolve(namespace, options)
143
+ .print(namespace, options)};`;
144
+ }
145
+ implements(node) {
146
+ const { namespace, options } = this;
147
+ const interfaces = node.interfaces.map(i => {
148
+ const identifier = i.resolveIdentifier(namespace, options);
149
+ if (!identifier) {
150
+ throw new Error(`Unable to resolve type: ${i.name} from ${i.namespace} in ${node.namespace.name} ${node.namespace.version}`);
151
+ }
152
+ return identifier;
153
+ });
154
+ if (interfaces.length > 0) {
155
+ return ` implements ${interfaces
156
+ .map(i => {
157
+ const Type = i.print(namespace, options);
158
+ return `${Type}`;
159
+ })
160
+ .join(", ")}`;
161
+ }
162
+ return "";
163
+ }
164
+ extends(node) {
165
+ const { namespace: ns, options } = this;
166
+ if (node.superType) {
167
+ const ResolvedType = node.superType.resolveIdentifier(ns, options);
168
+ const Type = ResolvedType?.print(ns, options);
169
+ if (Type) {
170
+ return ` extends ${Type}`;
171
+ }
172
+ throw new Error(`Unable to resolve type: ${node.superType.name} from ${node.superType.namespace} in ${node.namespace.name} ${node.namespace.version}`);
173
+ }
174
+ return "";
175
+ }
176
+ generateInterface(node) {
177
+ const { namespace, options } = this;
178
+ const isGObject = node.someParent(p => p.namespace.name === "GObject" && p.name === "Object");
179
+ const name = node.name;
180
+ const generics = node.generics;
181
+ let Generics = "";
182
+ let GenericTypes = "";
183
+ if (generics.length > 0) {
184
+ Generics = `${this.generateGenerics(generics)}`;
185
+ GenericTypes = `${this.generateGenerics(generics, false)}`;
186
+ }
187
+ const Extends = this.extends(node);
188
+ const filteredFunctions = filterFunctionConflict(node.namespace, node, node.members, []);
189
+ const functions = options.promisify ? promisifyFunctions(filteredFunctions) : filteredFunctions;
190
+ const staticFunctions = functions.filter(f => f instanceof IntrospectedStaticClassFunction);
191
+ const staticFields = node.fields
192
+ .filter(f => f.isStatic)
193
+ .map(f => f.copy({
194
+ isStatic: false
195
+ }));
196
+ const nonStaticFunctions = functions.filter(f => !(f instanceof IntrospectedStaticClassFunction));
197
+ const nonStaticFields = node.fields.filter(f => !f.isStatic);
198
+ const hasNamespace = isGObject || staticFunctions.length > 0 || node.callbacks.length > 0;
199
+ if (isGObject) {
200
+ // So we can use GObject.GType
201
+ this.namespace.assertInstalledImport("GObject");
202
+ }
203
+ return `
204
+ ${node.callbacks.length > 0
205
+ ? `export module ${name} {
206
+ ${node.callbacks.map(c => c.asString(this)).join("\n")}
207
+ }`
208
+ : ""}
209
+ ${hasNamespace
210
+ ? `${this.docString(node)}export interface ${name}Namespace {
211
+ ${isGObject ? `$gtype: ${namespace.name !== "GObject" ? "GObject." : ""}GType<${name}>;` : ""}
212
+ prototype: ${name}Prototype;
213
+ ${staticFields.length > 0 ? staticFields.map(sf => sf.asString(this)).join("\n") : ""}
214
+ ${staticFunctions.length > 0
215
+ ? staticFunctions.map(sf => IntrospectedClassFunction.prototype.asString.call(sf, this)).join("\n")
216
+ : ""}
217
+ }`
218
+ : ""}
219
+ export type ${name}${Generics} = ${name}Prototype${GenericTypes};
220
+ export interface ${name}Prototype${Generics}${Extends} {${node.__ts__indexSignature ? `\n${node.__ts__indexSignature}\n` : ""}
221
+ ${node.props.length > 0 ? "// Properties" : ""}
222
+ ${filterConflicts(node.namespace, node, node.props)
223
+ .map(p => p.asString(this))
224
+ .join("\n")}
225
+ ${nonStaticFields.length > 0 ? "// Fields" : ""}
226
+ ${filterConflicts(node.namespace, node, nonStaticFields)
227
+ .map(p => p.asString(this))
228
+ .join("\n")}
229
+ ${nonStaticFunctions.length > 0 ? "// Members\n" : ""}
230
+ ${nonStaticFunctions.map(m => m.asString(this)).join("\n")}
231
+ }${hasNamespace ? `\n\nexport const ${name}: ${name}Namespace;\n` : ""}`;
232
+ }
233
+ generateRecord(node) {
234
+ const { options, namespace } = this;
235
+ const { name } = node;
236
+ const Extends = this.extends(node);
237
+ let Generics = "";
238
+ if (node.generics.length > 0) {
239
+ Generics = `${this.generateGenerics(node.generics)}`;
240
+ }
241
+ let MainConstructor = "";
242
+ if (node.isForeign()) {
243
+ MainConstructor = "";
244
+ }
245
+ else if (node.mainConstructor) {
246
+ MainConstructor = node.mainConstructor.asString(this);
247
+ }
248
+ const hasCallbacks = node.callbacks.length > 0;
249
+ const Properties = filterConflicts(node.namespace, node, node.props)
250
+ .map(v => v.asString(this))
251
+ .join("\n");
252
+ const Fields = filterConflicts(node.namespace, node, node.fields)
253
+ .map(v => v.asString(this))
254
+ .join("\n");
255
+ const Constructors = filterConflicts(node.namespace, node, node.constructors)
256
+ .map(v => this.generateConstructorFunction(v))
257
+ .join("\n");
258
+ const FilteredMembers = filterFunctionConflict(node.namespace, node, node.members, []);
259
+ const Members = (options.promisify ? promisifyFunctions(FilteredMembers) : FilteredMembers)
260
+ .map(v => v.asString(this))
261
+ .join("\n");
262
+ // So we can use GObject.GType
263
+ this.namespace.assertInstalledImport("GObject");
264
+ return `${hasCallbacks
265
+ ? `export module ${name} {
266
+ ${node.callbacks.map(c => c.asString(this)).join("\n")}
267
+ }`
268
+ : ""}
269
+
270
+ ${this.docString(node)}export class ${name}${Generics}${Extends} {${node.__ts__indexSignature ? `\n${node.__ts__indexSignature}\n` : ""}
271
+ static $gtype: ${namespace.name !== "GObject" ? "GObject." : ""}GType<${name}>;
272
+
273
+ ${MainConstructor}
274
+ constructor(copy: ${node.name});
275
+
276
+ ${node.props.length > 0 ? "// Properties" : ""}
277
+ ${Properties}
278
+
279
+ ${node.fields.length > 0 ? "// Fields" : ""}
280
+ ${Fields}
281
+
282
+ ${node.constructors.length > 0 ? "// Constructors" : ""}
283
+ ${Constructors}
284
+
285
+ ${node.members.length > 0 ? "// Members" : ""}
286
+ ${Members}
287
+ }`;
288
+ }
289
+ generateClass(node) {
290
+ const { options, namespace } = this;
291
+ const name = node.name;
292
+ const injectConstructorBucket = !node.mainConstructor;
293
+ let Generics = "";
294
+ let GenericTypes = "";
295
+ if (node.generics.length > 0) {
296
+ Generics = `${this.generateGenerics(node.generics)}`;
297
+ GenericTypes = `${this.generateGenerics(node.generics, false)}`;
298
+ }
299
+ const Extends = this.extends(node);
300
+ const Implements = this.implements(node);
301
+ const implementedProperties = node.implementedProperties();
302
+ const implementedMethods = node.implementedMethods(implementedProperties);
303
+ let MainConstructor = "";
304
+ if (node.mainConstructor) {
305
+ MainConstructor = `\n${node.mainConstructor.asString(this)}`;
306
+ }
307
+ else {
308
+ MainConstructor = `\nconstructor(properties?: Partial<${name}.ConstructorProperties${GenericTypes}>, ...args: any[]);\n`;
309
+ // TODO: options migration
310
+ //if (!options.noInitTypes) {
311
+ // MainConstructor += `_init(properties?: Partial<${name}.ConstructorProperties${GenericTypes}>, ...args: any[]): void;\n`;
312
+ //} else {
313
+ MainConstructor += "_init(...args: any[]): void;\n";
314
+ //}
315
+ }
316
+ const ConstructorProps = filterConflicts(node.namespace, node,
317
+ // TODO: Include properties from interface parents too.
318
+ node.props)
319
+ .map(v => v.asString(this, true))
320
+ .join("\n ");
321
+ const Properties = filterConflicts(node.namespace, node, node.props)
322
+ .map(v => v.asString(this))
323
+ .join("\n ");
324
+ const Fields = filterConflicts(node.namespace, node, node.fields)
325
+ .map(v => v.asString(this))
326
+ .join("\n ");
327
+ const Constructors = filterFunctionConflict(node.namespace, node, node.constructors, [])
328
+ .map(v => this.generateConstructorFunction(v))
329
+ .join("\n ");
330
+ const FilteredMembers = filterFunctionConflict(node.namespace, node, node.members, []);
331
+ const Members = (options.promisify ? promisifyFunctions(FilteredMembers) : FilteredMembers)
332
+ .map(v => v.asString(this))
333
+ .join("\n ");
334
+ const ImplementedProperties = filterConflicts(node.namespace, node, implementedProperties)
335
+ .map(m => m.asString(this))
336
+ .join("\n ");
337
+ const FilteredImplMethods = filterFunctionConflict(node.namespace, node, implementedMethods, []);
338
+ const ImplementedMethods = (options.promisify ? promisifyFunctions(FilteredImplMethods) : FilteredImplMethods)
339
+ .map(m => m.asString(this))
340
+ .join("\n ");
341
+ // TODO Move these to a cleaner place.
342
+ const Connect = new IntrospectedClassFunction({
343
+ name: "connect",
344
+ parent: node,
345
+ parameters: [
346
+ new IntrospectedFunctionParameter({
347
+ name: "id",
348
+ type: StringType,
349
+ direction: GirDirection.In
350
+ }),
351
+ new IntrospectedFunctionParameter({
352
+ name: "callback",
353
+ type: AnyFunctionType,
354
+ direction: GirDirection.In
355
+ })
356
+ ],
357
+ return_type: NumberType
358
+ });
359
+ const ConnectAfter = new IntrospectedClassFunction({
360
+ name: "connect_after",
361
+ parent: node,
362
+ parameters: [
363
+ new IntrospectedFunctionParameter({
364
+ name: "id",
365
+ type: StringType,
366
+ direction: GirDirection.In
367
+ }),
368
+ new IntrospectedFunctionParameter({
369
+ name: "callback",
370
+ type: AnyFunctionType,
371
+ direction: GirDirection.In
372
+ })
373
+ ],
374
+ return_type: NumberType
375
+ });
376
+ const Emit = new IntrospectedClassFunction({
377
+ name: "emit",
378
+ parent: node,
379
+ parameters: [
380
+ new IntrospectedFunctionParameter({
381
+ name: "id",
382
+ type: StringType,
383
+ direction: GirDirection.In
384
+ }),
385
+ new IntrospectedFunctionParameter({
386
+ name: "args",
387
+ isVarArgs: true,
388
+ type: new ArrayType(AnyType),
389
+ direction: GirDirection.In
390
+ })
391
+ ],
392
+ return_type: VoidType
393
+ });
394
+ let default_signals = [];
395
+ let hasConnect, hasConnectAfter, hasEmit;
396
+ if (node.signals.length > 0) {
397
+ hasConnect = node.members.some(m => m.name === "connect");
398
+ hasConnectAfter = node.members.some(m => m.name === "connect_after");
399
+ hasEmit = node.members.some(m => m.name === "emit");
400
+ if (!hasConnect) {
401
+ default_signals.push(Connect);
402
+ }
403
+ if (!hasConnectAfter) {
404
+ default_signals.push(ConnectAfter);
405
+ }
406
+ if (!hasEmit) {
407
+ default_signals.push(Emit);
408
+ }
409
+ default_signals = filterConflicts(namespace, node, default_signals, FilterBehavior.DELETE);
410
+ hasConnect = !default_signals.some(s => s.name === "connect");
411
+ hasConnectAfter = !default_signals.some(s => s.name === "connect_after");
412
+ hasEmit = !default_signals.some(s => s.name === "emit");
413
+ }
414
+ const SignalsList = [
415
+ // TODO Relocate these.
416
+ ...default_signals.map(s => s.asString(this)),
417
+ ...node.signals
418
+ .map(s => {
419
+ const methods = [];
420
+ if (!hasConnect)
421
+ methods.push(s.asString(this, IntrospectedSignalType.CONNECT));
422
+ if (!hasConnectAfter)
423
+ methods.push(s.asString(this, IntrospectedSignalType.CONNECT_AFTER));
424
+ if (!hasEmit)
425
+ methods.push(s.asString(this, IntrospectedSignalType.EMIT));
426
+ return methods;
427
+ })
428
+ .flat()
429
+ ];
430
+ const hasSignals = SignalsList.length > 0;
431
+ const Signals = SignalsList.join("\n");
432
+ const hasCallbacks = node.callbacks.length > 0;
433
+ const hasModule = injectConstructorBucket || hasCallbacks;
434
+ // So we can use GObject.GType
435
+ this.namespace.assertInstalledImport("GObject");
436
+ const parts = Extends.split("<");
437
+ const ExtendsInterface = parts[0];
438
+ let ExtendsGenerics = parts[1] ?? "";
439
+ if (ExtendsGenerics.length > 0) {
440
+ ExtendsGenerics = `<${ExtendsGenerics}`;
441
+ }
442
+ return `${hasModule
443
+ ? `export module ${name} {
444
+ ${hasCallbacks ? node.callbacks.map(c => c.asString(this)).join("\n") : ""}
445
+ ${injectConstructorBucket
446
+ ? `export interface ConstructorProperties${Generics}${Extends ? `${ExtendsInterface}.ConstructorProperties${ExtendsGenerics}` : ""} {
447
+ [key: string]: any;
448
+ ${ConstructorProps}
449
+ }`
450
+ : ""}
451
+ }`
452
+ : ""}
453
+ export ${node.isAbstract ? "abstract " : ""}class ${name}${Generics}${Extends}${Implements} {${node.__ts__indexSignature ? `\n${node.__ts__indexSignature}\n` : ""}
454
+ static $gtype: ${namespace.name !== "GObject" ? "GObject." : ""}GType<${name}>;
455
+
456
+ ${MainConstructor}
457
+
458
+ ${node.props.length > 0 ? "// Properties" : ""}
459
+ ${Properties}
460
+
461
+ ${node.fields.length > 0 ? "// Fields" : ""}
462
+ ${Fields}
463
+
464
+ ${hasSignals ? "// Signals\n" : ""}
465
+ ${Signals}
466
+
467
+ ${implementedProperties.length > 0 ? "// Implemented Properties\n" : ""}
468
+ ${ImplementedProperties}
469
+
470
+ ${node.constructors.length > 0 ? "// Constructors\n" : ""}
471
+ ${Constructors}
472
+
473
+ ${node.members.length > 0 ? "// Members\n" : ""}
474
+ ${Members}
475
+
476
+ ${implementedMethods.length > 0 ? "// Implemented Members\n" : ""}
477
+ ${ImplementedMethods}
478
+ }`;
479
+ }
480
+ generateField(node) {
481
+ const { namespace, options } = this;
482
+ const { name, computed } = node;
483
+ const invalid = isInvalid(name);
484
+ const Static = node.isStatic ? "static" : "";
485
+ const ReadOnly = node.writable ? "" : "readonly";
486
+ const Modifier = [Static, ReadOnly].filter(a => a !== "").join(" ");
487
+ const Name = computed ? `[${name}]` : invalid ? `"${name}"` : name;
488
+ let { type } = node;
489
+ let fieldAnnotation = "";
490
+ if (type instanceof TypeConflict) {
491
+ if (type.conflictType === ConflictType.PROPERTY_ACCESSOR_CONFLICT) {
492
+ fieldAnnotation = `// This accessor conflicts with a property, field, or function name in a parent class or interface.
493
+ // @ts-expect-error\n`;
494
+ }
495
+ type = new BinaryType(type.unwrap(), AnyType);
496
+ }
497
+ return `${this.docString(node)}${fieldAnnotation}${Modifier} ${Name}${node.optional ? "?" : ""}: ${type
498
+ .resolve(namespace, options)
499
+ .rootPrint(namespace, options)};`;
500
+ }
501
+ generateProperty(node, construct = false) {
502
+ const { namespace, options } = this;
503
+ const invalid = isInvalid(node.name);
504
+ const Name = invalid ? `"${node.name}"` : node.name;
505
+ let type = node.type;
506
+ let getterAnnotation = "";
507
+ let setterAnnotation = "";
508
+ let getterSetterAnnotation = "";
509
+ if (type instanceof TypeConflict) {
510
+ switch (type.conflictType) {
511
+ case ConflictType.FUNCTION_NAME_CONFLICT:
512
+ case ConflictType.FIELD_NAME_CONFLICT:
513
+ getterSetterAnnotation = setterAnnotation =
514
+ "// This accessor conflicts with a property, field, or function name in a parent class or interface.\n";
515
+ case ConflictType.ACCESSOR_PROPERTY_CONFLICT:
516
+ getterSetterAnnotation = getterAnnotation =
517
+ "// This accessor conflicts with a property, field, or function name in a parent class or interface.\n";
518
+ type = new BinaryType(type.unwrap(), AnyType);
519
+ break;
520
+ case ConflictType.PROPERTY_ACCESSOR_CONFLICT:
521
+ type = new BinaryType(type.unwrap(), AnyType);
522
+ break;
523
+ case ConflictType.PROPERTY_NAME_CONFLICT:
524
+ getterSetterAnnotation =
525
+ setterAnnotation =
526
+ getterAnnotation =
527
+ "// This accessor conflicts with another accessor's type in a parent class or interface.\n";
528
+ type = new BinaryType(type.unwrap(), AnyType);
529
+ break;
530
+ }
531
+ if (construct && !(type instanceof BinaryType)) {
532
+ // For constructor properties we just convert to any.
533
+ type = new BinaryType(type, AnyType);
534
+ }
535
+ }
536
+ const Type = type.resolve(namespace, options).rootPrint(namespace, options) || "any";
537
+ if (construct) {
538
+ return `${Name}: ${Type};`;
539
+ }
540
+ const { readable, writable, constructOnly } = node;
541
+ const hasGetter = readable;
542
+ const hasSetter = writable && !constructOnly;
543
+ if (node.parent instanceof IntrospectedInterface) {
544
+ if (!hasSetter && hasGetter) {
545
+ return `readonly ${Name}: ${Type};`;
546
+ }
547
+ else {
548
+ return `${Name}: ${Type};`;
549
+ }
550
+ }
551
+ if (hasGetter && hasSetter) {
552
+ return `${getterAnnotation} get ${Name}(): ${Type};
553
+ ${setterAnnotation} set ${Name}(val: ${Type});`;
554
+ }
555
+ else if (hasGetter) {
556
+ return `${getterSetterAnnotation} get ${Name}(): ${Type};`;
557
+ }
558
+ else {
559
+ return `${getterSetterAnnotation} set ${Name}(val: ${Type});`;
560
+ }
561
+ }
562
+ generateSignal(node, type = IntrospectedSignalType.CONNECT) {
563
+ switch (type) {
564
+ case IntrospectedSignalType.CONNECT:
565
+ return node.asConnect(false).asString(this);
566
+ case IntrospectedSignalType.CONNECT_AFTER:
567
+ return node.asConnect(true).asString(this);
568
+ case IntrospectedSignalType.EMIT:
569
+ return node.asEmit().asString(this);
570
+ }
571
+ }
572
+ generateEnumMember(node) {
573
+ const invalid = isInvalid(node.name);
574
+ if (node.value != null && !Number.isNaN(Number.parseInt(node.value, 10))) {
575
+ return invalid
576
+ ? `${this.docString(node)}"${node.name}" = ${node.value},`
577
+ : `${this.docString(node)}${node.name} = ${node.value},`;
578
+ }
579
+ else {
580
+ return invalid ? `${this.docString(node)}"${node.name}",` : `${this.docString(node)}${node.name},`;
581
+ }
582
+ }
583
+ generateParameter(node) {
584
+ const { namespace, options } = this;
585
+ const type = resolveDirectedType(node.type, node.direction)?.resolve(namespace, options).rootPrint(namespace, options) ??
586
+ node.type.resolve(namespace, options).rootPrint(namespace, options);
587
+ if (node.isVarArgs) {
588
+ return `...args: ${type}`;
589
+ }
590
+ if (node.isOptional) {
591
+ return `${node.name}?: ${type}`;
592
+ }
593
+ else {
594
+ return `${node.name}: ${type}`;
595
+ }
596
+ }
597
+ docString(node) {
598
+ // TODO: Support node.doc not being a string?
599
+ return typeof node.doc === "string" && !this.options.noComments
600
+ ? `/**
601
+ ${node.doc
602
+ .split("\n")
603
+ .map(line => ` * ${line
604
+ .trim()
605
+ .replace("*/", "*\\/")
606
+ .replace(/@([a-z_]+?)([. ])/g, "`$1$2`")}`.replace(/@([a-z])/g, "$1"))
607
+ .join("\n")}
608
+ */\n`
609
+ : "";
610
+ }
611
+ generateFunction(node) {
612
+ const { namespace } = this;
613
+ // Register our identifier with the sanitized identifiers.
614
+ // We avoid doing this in fromXML because other class-level function classes
615
+ // depends on that code.
616
+ sanitizeIdentifierName(namespace.name, node.raw_name);
617
+ const Parameters = this.generateParameters(node.parameters);
618
+ const ReturnType = this.generateReturn(node.return(), node.output_parameters);
619
+ const Generics = this.generateGenerics(node.generics);
620
+ return `${this.docString(node)}export function ${node.name}${Generics}(${Parameters}): ${ReturnType};`;
621
+ }
622
+ generateConstructorFunction(node) {
623
+ const { namespace, options } = this;
624
+ const Parameters = this.generateParameters(node.parameters);
625
+ const invalid = isInvalid(node.name);
626
+ const name = invalid ? `["${node.name}"]` : node.name;
627
+ const warning = node.getWarning();
628
+ return `${warning ? `${warning}\n` : ""}${this.docString(node)}static ${name}(${Parameters}): ${node
629
+ .return()
630
+ .resolve(namespace, options)
631
+ .rootPrint(namespace, options)};`;
632
+ }
633
+ generateConstructor(node) {
634
+ const Parameters = this.generateParameters(node.parameters);
635
+ return `constructor(${Parameters});`;
636
+ }
637
+ generateDirectAllocationConstructor(node) {
638
+ const ConstructorFields = node.parameters.map(param => param.asField().asString(this)).join("\n");
639
+ return `
640
+ constructor(properties?: Partial<{
641
+ ${ConstructorFields}
642
+ }>);`;
643
+ }
644
+ generateClassFunction(node) {
645
+ const invalid = isInvalid(node.name);
646
+ const parameters = node.parameters;
647
+ const output_parameters = node.output_parameters;
648
+ const return_type = node.return();
649
+ const Parameters = this.generateParameters(parameters);
650
+ const ReturnType = this.generateReturn(return_type, output_parameters);
651
+ const Generics = this.generateGenerics(node.generics);
652
+ if (node.shouldAnyify()) {
653
+ return `${invalid ? `["${node.name}"]` : node.name}: ${Generics}((${Parameters}) => ${ReturnType}) | any;`;
654
+ }
655
+ const warning = node.getWarning();
656
+ return `${warning ? `${warning}\n` : ""}${this.docString(node)}${invalid ? `["${node.name}"]` : node.name}${Generics}(${Parameters}): ${ReturnType};`;
657
+ }
658
+ generateStaticClassFunction(node) {
659
+ const Generics = this.generateGenerics(node.generics);
660
+ const ReturnType = this.generateReturn(node.return(), node.output_parameters);
661
+ const warning = node.getWarning();
662
+ return `${warning ? `${warning}\n` : ""}${this.docString(node)}static ${node.name}${Generics}(${this.generateParameters(node.parameters)}): ${ReturnType};`;
663
+ }
664
+ generateAlias(node) {
665
+ const { namespace, options } = this;
666
+ const Type = node.type.resolve(namespace, options).print(namespace, options);
667
+ const GenericBase = node.generics
668
+ .map(g => {
669
+ if (g.type) {
670
+ return `${g.name} = ${g.type.resolve(namespace, options).rootPrint(namespace, options)}`;
671
+ }
672
+ return `${g.name}`;
673
+ })
674
+ .join(", ");
675
+ const Generic = GenericBase ? `<${GenericBase}>` : "";
676
+ return `${this.docString(node)}export type ${node.name}${Generic} = ${Type};`;
677
+ }
678
+ generateVirtualClassFunction(node) {
679
+ return this.generateClassFunction(node);
680
+ }
681
+ }
682
+ //# sourceMappingURL=dts.js.map