@ts-for-gir/lib 3.0.0-beta.12 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/lib/constants.d.ts +7 -3
  2. package/lib/constants.js +14 -2
  3. package/lib/constants.js.map +1 -1
  4. package/lib/dependency-manager.d.ts +52 -3
  5. package/lib/dependency-manager.js +138 -18
  6. package/lib/dependency-manager.js.map +1 -1
  7. package/lib/gir-module.d.ts +12 -5
  8. package/lib/gir-module.js +25 -8
  9. package/lib/gir-module.js.map +1 -1
  10. package/lib/index.d.ts +3 -1
  11. package/lib/index.js +3 -1
  12. package/lib/index.js.map +1 -1
  13. package/lib/injection/classes/gjs/index.js +3 -3
  14. package/lib/injection/classes/index.js +1 -1
  15. package/lib/injection/classes/node-gtk/index.js +8 -8
  16. package/lib/messages.d.ts +0 -2
  17. package/lib/messages.js +1 -3
  18. package/lib/messages.js.map +1 -1
  19. package/lib/package-data-parser.d.ts +13 -0
  20. package/lib/package-data-parser.js +67 -0
  21. package/lib/package-data-parser.js.map +1 -0
  22. package/lib/package-data.d.ts +9 -0
  23. package/lib/package-data.js +41 -0
  24. package/lib/package-data.js.map +1 -0
  25. package/lib/symtable.js +2 -1
  26. package/lib/symtable.js.map +1 -1
  27. package/lib/template-processor.d.ts +59 -19
  28. package/lib/template-processor.js +128 -41
  29. package/lib/template-processor.js.map +1 -1
  30. package/lib/transformation.d.ts +2 -1
  31. package/lib/transformation.js +44 -26
  32. package/lib/transformation.js.map +1 -1
  33. package/lib/types/construct-name.d.ts +1 -1
  34. package/lib/types/dependency.d.ts +17 -2
  35. package/lib/types/generate-config.d.ts +9 -2
  36. package/lib/types/index.d.ts +5 -0
  37. package/lib/types/index.js +5 -0
  38. package/lib/types/index.js.map +1 -1
  39. package/lib/types/module-type.d.ts +1 -1
  40. package/lib/types/package-data-parsed.d.ts +28 -0
  41. package/lib/types/package-data-parsed.js +2 -0
  42. package/lib/types/package-data-parsed.js.map +1 -0
  43. package/lib/types/package-data.d.ts +23 -0
  44. package/lib/types/package-data.js +2 -0
  45. package/lib/types/package-data.js.map +1 -0
  46. package/lib/types/package-section-parsed.d.ts +8 -0
  47. package/lib/types/package-section-parsed.js +2 -0
  48. package/lib/types/package-section-parsed.js.map +1 -0
  49. package/lib/types/package-section.d.ts +8 -0
  50. package/lib/types/package-section.js +2 -0
  51. package/lib/types/package-section.js.map +1 -0
  52. package/lib/types/parsed-package-data.d.ts +6 -0
  53. package/lib/types/parsed-package-data.js +2 -0
  54. package/lib/types/parsed-package-data.js.map +1 -0
  55. package/lib/types/template-data.d.ts +2 -1
  56. package/lib/types/transformation-case.d.ts +1 -1
  57. package/lib/types/transformations.d.ts +1 -1
  58. package/lib/types/user-config.d.ts +6 -2
  59. package/lib/utils.d.ts +31 -16
  60. package/lib/utils.js +68 -30
  61. package/lib/utils.js.map +1 -1
  62. package/package.json +20 -19
  63. package/templates/README.md +102 -0
  64. package/templates/gjs/README-GJS.md +109 -0
  65. package/templates/gjs/ambient.d.ts +59 -0
  66. package/templates/gjs/cairo-1.0.d.ts +9 -0
  67. package/templates/gjs/cairo.d.ts +8 -0
  68. package/templates/gjs/cairo.js +11 -0
  69. package/templates/gjs/gettext.d.ts +41 -0
  70. package/templates/gjs/gettext.js +11 -0
  71. package/templates/{Gjs/Gio-2.0.d.ts → gjs/gio-2.0.d.ts} +1 -1
  72. package/templates/{Gjs/index.d.ts → gjs/gjs.d.ts} +221 -58
  73. package/templates/gjs/gjs.js +10 -0
  74. package/templates/{Gjs/GObject-2.0.d.ts → gjs/gobject-2.0.d.ts} +1 -1
  75. package/templates/gjs/module-ambient.d.ts +31 -0
  76. package/templates/gjs/module-import.d.ts +33 -0
  77. package/templates/gjs/module.append.d.ts +1 -0
  78. package/templates/gjs/module.d.ts +12 -0
  79. package/templates/gjs/module.js +17 -0
  80. package/templates/gjs/system.d.ts +32 -0
  81. package/templates/gjs/system.js +11 -0
  82. package/templates/gjs/tsconfig.alias.json +12 -0
  83. package/templates/node-gtk/README-NODE-GTK.md +71 -0
  84. package/templates/node-gtk/ambient.d.ts +19 -0
  85. package/templates/node-gtk/module-import.d.ts +29 -0
  86. package/templates/node-gtk/module.append.d.ts +1 -0
  87. package/templates/node-gtk/module.d.ts +4 -0
  88. package/templates/node-gtk/module.js +2 -1
  89. package/templates/node-gtk/node-gtk.d.ts +25 -0
  90. package/templates/node-gtk/{index.js → node-gtk.js} +0 -2
  91. package/templates/package.json +173 -0
  92. package/templates/tsconfig.doc.json +30 -0
  93. package/lib/injection/classes/GooCanvas-2.0.d.ts +0 -2
  94. package/lib/injection/classes/GooCanvas-2.0.js +0 -26
  95. package/lib/injection/classes/GooCanvas-2.0.js.map +0 -1
  96. package/lib/injection/classes/GooCanvas-3.0.d.ts +0 -2
  97. package/lib/injection/classes/GooCanvas-3.0.js +0 -26
  98. package/lib/injection/classes/GooCanvas-3.0.js.map +0 -1
  99. package/lib/injection/classes/GooCanvas-x.0.d.ts +0 -2
  100. package/lib/injection/classes/GooCanvas-x.0.js +0 -26
  101. package/lib/injection/classes/GooCanvas-x.0.js.map +0 -1
  102. package/lib/injection/classes/gjs/GooCanvas-2.0.d.ts +0 -2
  103. package/lib/injection/classes/gjs/GooCanvas-2.0.js +0 -14
  104. package/lib/injection/classes/gjs/GooCanvas-2.0.js.map +0 -1
  105. package/lib/types/library-version.d.ts +0 -7
  106. package/lib/types/library-version.js +0 -2
  107. package/lib/types/library-version.js.map +0 -1
  108. package/templates/Gjs/Gjs.d.ts +0 -204
  109. package/templates/Gjs/Gjs.js +0 -21
  110. package/templates/Gjs/GnomeShell.d.ts +0 -154
  111. package/templates/Gjs/GnomeShell.js +0 -10
  112. package/templates/Gjs/index.js +0 -4
  113. package/templates/Gjs/misc/dbusUtils.d.ts +0 -15
  114. package/templates/Gjs/misc/dbusUtils.js +0 -6
  115. package/templates/Gjs/misc/extensionUtils.d.ts +0 -99
  116. package/templates/Gjs/misc/extensionUtils.js +0 -6
  117. package/templates/Gjs/misc/fileUtils.d.ts +0 -51
  118. package/templates/Gjs/misc/fileUtils.js +0 -6
  119. package/templates/Gjs/misc/gnomeSession.d.ts +0 -74
  120. package/templates/Gjs/misc/gnomeSession.js +0 -6
  121. package/templates/Gjs/misc/parentalControlsManager.d.ts +0 -42
  122. package/templates/Gjs/misc/parentalControlsManager.js +0 -6
  123. package/templates/Gjs/misc/signals.d.ts +0 -15
  124. package/templates/Gjs/misc/signals.js +0 -6
  125. package/templates/Gjs/module.d.ts +0 -6
  126. package/templates/Gjs/module.js +0 -16
  127. package/templates/Gjs/tsconfig.alias.json +0 -10
  128. package/templates/Gjs/ui/accessDialog.d.ts +0 -19
  129. package/templates/Gjs/ui/accessDialog.js +0 -6
  130. package/templates/Gjs/ui/altTab.d.ts +0 -124
  131. package/templates/Gjs/ui/altTab.js +0 -6
  132. package/templates/Gjs/ui/animation.d.ts +0 -58
  133. package/templates/Gjs/ui/animation.js +0 -6
  134. package/templates/Gjs/ui/appDisplay.d.ts +0 -204
  135. package/templates/Gjs/ui/appDisplay.js +0 -6
  136. package/templates/Gjs/ui/appFavorites.d.ts +0 -34
  137. package/templates/Gjs/ui/appFavorites.js +0 -6
  138. package/templates/Gjs/ui/appMenu.d.ts +0 -74
  139. package/templates/Gjs/ui/appMenu.js +0 -6
  140. package/templates/Gjs/ui/audioDeviceSelection.d.ts +0 -51
  141. package/templates/Gjs/ui/audioDeviceSelection.js +0 -6
  142. package/templates/Gjs/ui/background.d.ts +0 -255
  143. package/templates/Gjs/ui/background.js +0 -5
  144. package/templates/Gjs/ui/backgroundMenu.d.ts +0 -19
  145. package/templates/Gjs/ui/backgroundMenu.js +0 -5
  146. package/templates/Gjs/ui/barLevel.d.ts +0 -42
  147. package/templates/Gjs/ui/barLevel.js +0 -5
  148. package/templates/Gjs/ui/boxpointer.d.ts +0 -103
  149. package/templates/Gjs/ui/boxpointer.js +0 -5
  150. package/templates/Gjs/ui/calendar.d.ts +0 -261
  151. package/templates/Gjs/ui/calendar.js +0 -5
  152. package/templates/Gjs/ui/checkBox.d.ts +0 -22
  153. package/templates/Gjs/ui/checkBox.js +0 -5
  154. package/templates/Gjs/ui/closeDialog.d.ts +0 -40
  155. package/templates/Gjs/ui/closeDialog.js +0 -5
  156. package/templates/Gjs/ui/components/__init__.d.ts +0 -9
  157. package/templates/Gjs/ui/components/__init__.js +0 -6
  158. package/templates/Gjs/ui/components/automountManager.d.ts +0 -8
  159. package/templates/Gjs/ui/components/automountManager.js +0 -6
  160. package/templates/Gjs/ui/components/autorunManager.d.ts +0 -8
  161. package/templates/Gjs/ui/components/autorunManager.js +0 -6
  162. package/templates/Gjs/ui/components/index.d.ts +0 -6
  163. package/templates/Gjs/ui/components/index.js +0 -6
  164. package/templates/Gjs/ui/components/keyring.d.ts +0 -19
  165. package/templates/Gjs/ui/components/keyring.js +0 -6
  166. package/templates/Gjs/ui/components/networkAgent.d.ts +0 -10
  167. package/templates/Gjs/ui/components/networkAgent.js +0 -6
  168. package/templates/Gjs/ui/components/polkitAgent.d.ts +0 -19
  169. package/templates/Gjs/ui/components/polkitAgent.js +0 -6
  170. package/templates/Gjs/ui/components/telepathyClient.d.ts +0 -10
  171. package/templates/Gjs/ui/components/telepathyClient.js +0 -6
  172. package/templates/Gjs/ui/dialog.d.ts +0 -78
  173. package/templates/Gjs/ui/dialog.js +0 -6
  174. package/templates/Gjs/ui/dnd.d.ts +0 -127
  175. package/templates/Gjs/ui/dnd.js +0 -6
  176. package/templates/Gjs/ui/iconGrid.d.ts +0 -172
  177. package/templates/Gjs/ui/iconGrid.js +0 -6
  178. package/templates/Gjs/ui/layout.d.ts +0 -311
  179. package/templates/Gjs/ui/layout.js +0 -6
  180. package/templates/Gjs/ui/main.d.ts +0 -215
  181. package/templates/Gjs/ui/main.js +0 -6
  182. package/templates/Gjs/ui/messageList.d.ts +0 -113
  183. package/templates/Gjs/ui/messageList.js +0 -6
  184. package/templates/Gjs/ui/messageTray.d.ts +0 -423
  185. package/templates/Gjs/ui/messageTray.js +0 -6
  186. package/templates/Gjs/ui/modalDialog.d.ts +0 -96
  187. package/templates/Gjs/ui/modalDialog.js +0 -6
  188. package/templates/Gjs/ui/mpris.d.ts +0 -78
  189. package/templates/Gjs/ui/mpris.js +0 -6
  190. package/templates/Gjs/ui/notificationDaemon.d.ts +0 -5
  191. package/templates/Gjs/ui/notificationDaemon.js +0 -6
  192. package/templates/Gjs/ui/panel.d.ts +0 -65
  193. package/templates/Gjs/ui/panel.js +0 -6
  194. package/templates/Gjs/ui/panelMenu.d.ts +0 -51
  195. package/templates/Gjs/ui/panelMenu.js +0 -6
  196. package/templates/Gjs/ui/popupMenu.d.ts +0 -228
  197. package/templates/Gjs/ui/popupMenu.js +0 -6
  198. package/templates/Gjs/ui/ripples.d.ts +0 -44
  199. package/templates/Gjs/ui/ripples.js +0 -6
  200. package/templates/Gjs/ui/search.d.ts +0 -158
  201. package/templates/Gjs/ui/search.js +0 -6
  202. package/templates/Gjs/ui/switcherPopup.d.ts +0 -107
  203. package/templates/Gjs/ui/switcherPopup.js +0 -6
  204. package/templates/Gjs/ui/userWidget.d.ts +0 -13
  205. package/templates/Gjs/ui/userWidget.js +0 -6
  206. package/templates/node-gtk/index.d.ts +0 -40
  207. /package/templates/{Cogl-2.0.d.ts → cogl-2-0.d.ts} +0 -0
  208. /package/templates/{Granite-1.0.d.ts → granite-1.0.d.ts} +0 -0
  209. /package/templates/{Granite-7.0.d.ts → granite-7.0.d.ts} +0 -0
  210. /package/templates/{GstBase-0.10.d.ts → gstbase-0.10.d.ts} +0 -0
  211. /package/templates/node-gtk/{GObject-2.0.d.ts → gobject-2.0.d.ts} +0 -0
  212. /package/templates/{RygelServer-2.6.d.ts → rygelserver-2.6.d.ts} +0 -0
@@ -4,27 +4,220 @@
4
4
  * These type definitions are automatically generated, do not edit them by hand.
5
5
  * If you found a bug fix it in <%= APP_NAME %> itself or create a bug report on <%= APP_SOURCE %>
6
6
  */
7
+ import './ambient.d.ts';
8
+
9
+ <%_ const GObject = dep.find('GObject') _%>
10
+ <%_ const GLib = dep.find('GLib') _%>
11
+ <%- GObject ? GObject.importDef : '' %>
12
+ <%- GLib ? GLib.importDef : '' %>
13
+ import gettext from './gettext.js';
14
+ import system from './system.js';
15
+ import cairo from './cairo.js';
16
+
17
+ // https://gitlab.gnome.org/GNOME/gjs/-/blob/1.72.0/modules/script/package.js
18
+ declare namespace package {
19
+ /**
20
+ * Although there are references in the documentation of more properties that
21
+ * this object should accepts, only the following are actually used in the init code,
22
+ * and all the other have their values derived from them.
23
+ */
24
+ interface PackageInitParams {
25
+ name: string
26
+ version: string
27
+ prefix: string
28
+ libdir: string
29
+ }
7
30
 
8
- import type * as Gjs from './Gjs.js'
9
- <%_ if(gnomeShellTypes){ _%>
10
- import type * as GnomeShell from './GnomeShell.js'
11
- <%_ } _%>
12
- <%_ for (const girModule of girModules) { _%>
13
- <%_ if(noNamespace){ _%>
14
- import type * as <%= girModule.importName %> from "./<%= girModule.packageName %>.js";
15
- <%_ } else { _%>
16
- import type <%= girModule.importName %> from "./<%= girModule.packageName %>.js";
17
- <%_ } _%>
18
- <%_ } _%>
31
+ export const name: string | undefined
32
+ export const version: string | undefined
33
+ export const prefix: string | undefined
34
+ export const datadir: string | undefined
35
+ export const libdir: string | undefined
36
+ export const pkgdatadir: string | undefined
37
+ export const pkglibdir: string | undefined
38
+ export const moduledir: string | undefined
39
+ export const localedir: string | undefined
40
+
41
+ export function init(params: PackageInitParams): void
42
+ export function run(module: { main: (argv: string[]) => void }): void
43
+ /** shortcut to init+run */
44
+ export function start(params: PackageInitParams): void
45
+ export function require(libs: Record<string, string>): void
46
+ export function requireSymbol(lib: string, ver: string, symbol: string): void
47
+ export function checkSymbol(lib: string, ver: string, symbol: string): void
48
+ export function initGettext(): void
49
+ /** @deprecated Use JS string interpolation */
50
+ export function initFormat(): void
51
+ export function initSubmodule(module: string): void
52
+ }
53
+
54
+ declare namespace byteArray {
55
+ export class ByteArray {
56
+ static get(target: any, property: string, receiver: any): any
57
+ static set(target: any, property: string, value: any, receiver: any): boolean
58
+
59
+ length: number
60
+ protected _array: Uint8Array
61
+
62
+ constructor(x: Uint8Array | number)
63
+ toString(encoding?: TextDecoderEncoding): string
64
+ fromString(input: string, encoding?: TextDecoderEncoding): ByteArray
65
+ toGBytes(): GLib.Bytes
66
+ }
67
+
68
+ /** @deprecated Use {@link TextEncoder.encode} instead */
69
+ export function fromString(input: string, encoding?: TextDecoderEncoding): Uint8Array
70
+
71
+ /** @deprecated Use {@link GLib.Bytes.toArray} instead */
72
+ export function fromGBytes(input: GLib.Bytes): Uint8Array
73
+
74
+ /** @deprecated Use {@link TextEncoder.encode} instead */
75
+ export function toString(x: Uint8Array, encoding?: TextDecoderEncoding): string
76
+
77
+ /** @deprecated Use {@link GLib.Bytes new GLib.Bytes() } instead */
78
+ export function toGBytes(x: Uint8Array): GLib.Bytes
79
+
80
+ /** @deprecated Use {@link ByteArray new ByteArray()} instead */
81
+ export function fromArray(array: Iterable<number>): ByteArray
82
+ }
83
+
84
+ declare namespace console {
85
+ export function interact(): void
86
+ }
87
+
88
+ declare namespace lang {
89
+ // TODO: There is a lot more in Lang
90
+ export function Class(props: any): void
91
+ }
92
+
93
+ declare namespace format {
94
+ export function vprintf(str: string, args: string[]): string
95
+ export function printf(fmt: string, ...args: any[]): void
96
+ // Following docs from gjs/modules/format.js
97
+ /**
98
+ * This function is intended to extend the String object and provide
99
+ * an String.format API for string formatting.
100
+ * It has to be set up using String.prototype.format = Format.format;
101
+ * Usage:
102
+ * "somestring %s %d".format('hello', 5);
103
+ * It supports %s, %d, %x and %f, for %f it also support precisions like
104
+ * "%.2f".format(1.526). All specifiers can be prefixed with a minimum
105
+ * field width, e.g. "%5s".format("foo"). Unless the width is prefixed
106
+ * with '0', the formatted string will be padded with spaces.
107
+ */
108
+ export function format(fmt: string, ...args: any[]): string
109
+ }
110
+
111
+ declare namespace mainloop {
112
+ export function quit(name: string): void
113
+ export function idle_source(handler: any, priority?: number): any
114
+ export function idle_add(handler: any, priority?: number): any
115
+ export function timeout_source(timeout: any, handler: any, priority?: number): any
116
+ export function timeout_seconds_source(timeout: any, handler: any, priority?: number): any
117
+ export function timeout_add(timeout: any, handler: any, priority?: number): any
118
+ export function timeout_add_seconds(timeout: any, handler: any, priority?: number): any
119
+ export function source_remove(id: any): any
120
+ export function run(name: string): void
121
+ }
122
+
123
+ /**
124
+ * You can use the `Signals.addSignalMethods` method to apply the `Signals` convenience methods to an `Object`.
125
+ * Generally, this is called on an object prototype, but may also be called on an object instance.
126
+ * You can use this Interface for this object or prototype to make the methods in typescript known
127
+ * @example
128
+ * ```ts
129
+ * const Signals = imports.signals;
130
+ *
131
+ * // Define an interface with the same name of your class to make the methods known
132
+ * interface Events extends Signals.Methods {}
133
+ *
134
+ * class Events {}
135
+ * Signals.addSignalMethods(Events.prototype);
136
+ *
137
+ * const events = new Events();
138
+ *
139
+ * // Typescript will not complain here
140
+ * events.emit("test-signal", "test argument");
141
+ * ```
142
+ */
143
+ export interface SignalMethods {
144
+ /**
145
+ * Connects a callback to a signal for an object. Pass the returned ID to
146
+ * `disconect()` to remove the handler.
147
+ *
148
+ * If `callback` returns `true`, emission will stop and no other handlers will be
149
+ * invoked.
150
+ *
151
+ * > Warning: Unlike GObject signals, `this` within a signal callback will always
152
+ * > refer to the global object (ie. `globalThis`).
153
+ *
154
+ * @param sigName A signal name
155
+ * @param callback A callback function
156
+ * @returns A handler ID
157
+ */
158
+ connect(sigName: string, callback: (self: any, ...args: any[]) => void): number;
159
+ /**
160
+ * Emits a signal for an object. Emission stops if a signal handler returns `true`.
161
+ *
162
+ * Unlike GObject signals, it is not necessary to declare signals or define their
163
+ * signature. Simply call `emit()` with whatever signal name you wish, with
164
+ * whatever arguments you wish.
165
+ * @param sigName A signal name
166
+ * @param args Any number of arguments, of any type
167
+ */
168
+ emit(sigName: string, ...args: any[]): void;
169
+ /**
170
+ * Disconnects a handler for a signal.
171
+ * @param id The ID of the handler to be disconnected
172
+ */
173
+ disconnect(id: number): void;
174
+ /**
175
+ * Disconnects all signal handlers for an object.
176
+ */
177
+ disconnectAll(): void
178
+ /**
179
+ * Checks if a handler ID is connected.
180
+ * @param id The ID of the handler to be disconnected
181
+ * @returns `true` if connected, or `false` if not
182
+ */
183
+ signalHandlerIsConnected(id: number): boolean;
184
+ }
185
+
186
+ declare namespace signals {
187
+ export function addSignalMethods<T = any>(proto: T): proto is T & SignalMethods;
188
+ }
19
189
 
20
190
  // See also https://github.com/microsoft/TypeScript/blob/main/lib/lib.dom.d.ts
21
191
  declare global {
192
+
193
+ interface GjsGiImports {
194
+ // Will be extended by the import of more gir types
195
+ versions: {
196
+ [namespace: string]: string
197
+ }
198
+ }
199
+
200
+ interface GjsImports {
201
+ gi: GjsGiImports
202
+ lang: typeof lang
203
+ system: typeof system
204
+ signals: typeof signals
205
+ package: typeof package
206
+ mainloop: typeof mainloop
207
+ searchPath: string[]
208
+ gettext: typeof gettext
209
+ byteArray: typeof byteArray
210
+ format: typeof format
211
+ cairo: typeof cairo
212
+ }
213
+
22
214
  function print(...args: any[]): void
23
215
  function printerr(...args: any[]): void
24
216
  function log(message: any): void
25
217
  function logError(exception: object, message?: any): void
26
218
  function logError(message?: any): void
27
219
 
220
+ const pkg: typeof package
28
221
  interface Console {
29
222
  /**
30
223
  * Logs a critical message if the condition is not truthy.
@@ -48,15 +241,15 @@ declare global {
48
241
  clear(): void
49
242
 
50
243
  /**
51
- * Logs a message with severity equal to {@link GLib20.LogLevelFlags.DEBUG}.
244
+ * Logs a message with severity equal to {@link GLib.LogLevelFlags.DEBUG}.
52
245
  *
53
246
  * @param {...any} data formatting substitutions, if applicable
54
247
  */
55
248
  debug(...data: any[]): void
56
249
 
57
250
  /**
58
- * Logs a message with severity equal to {@link GLib20.LogLevelFlags.CRITICAL}.
59
- * Does not use {@link GLib20.LogLevelFlags.ERROR} to avoid asserting and
251
+ * Logs a message with severity equal to {@link GLib.LogLevelFlags.CRITICAL}.
252
+ * Does not use {@link GLib.LogLevelFlags.ERROR} to avoid asserting and
60
253
  * forcibly shutting down the application.
61
254
  *
62
255
  * @param data formatting substitutions, if applicable
@@ -64,14 +257,14 @@ declare global {
64
257
  error(...data: any[]): void
65
258
 
66
259
  /**
67
- * Logs a message with severity equal to {@link GLib20.LogLevelFlags.INFO}.
260
+ * Logs a message with severity equal to {@link GLib.LogLevelFlags.INFO}.
68
261
  *
69
262
  * @param data formatting substitutions, if applicable
70
263
  */
71
264
  info(...data: any[]): void
72
265
 
73
266
  /**
74
- * Logs a message with severity equal to {@link GLib20.LogLevelFlags.MESSAGE}.
267
+ * Logs a message with severity equal to {@link GLib.LogLevelFlags.MESSAGE}.
75
268
  *
76
269
  * @param data formatting substitutions, if applicable
77
270
  */
@@ -203,7 +396,7 @@ declare global {
203
396
  }
204
397
 
205
398
  <% if(!noDOMLib){ %>
206
- const console: Console
399
+ const console: Console
207
400
  <% } %>
208
401
 
209
402
  // https://gitlab.gnome.org/GNOME/gjs/-/blob/1.73.2/modules/esm/_encoding/encodingMap.js#L7-232
@@ -512,15 +705,15 @@ declare global {
512
705
  <% } %>
513
706
 
514
707
  interface BooleanConstructor {
515
- $gtype: GObject20.GType<boolean>
708
+ $gtype: GObject.GType<boolean>
516
709
  }
517
710
 
518
711
  interface NumberConstructor {
519
- $gtype: GObject20.GType<number>
712
+ $gtype: GObject.GType<number>
520
713
  }
521
714
 
522
715
  interface StringConstructor {
523
- $gtype: GObject20.GType<string>
716
+ $gtype: GObject.GType<string>
524
717
  }
525
718
 
526
719
  const ARGV: string[]
@@ -534,7 +727,7 @@ declare global {
534
727
  * @param delay the duration in milliseconds to wait before running callback
535
728
  * @param args arguments to pass to callback
536
729
  */
537
- function setTimeout(callback: (...args: any[]) => any, delay?: number, ...args: any[]): GLib20.Source
730
+ function setTimeout(callback: (...args: any[]) => any, delay?: number, ...args: any[]): GLib.Source
538
731
 
539
732
  /**
540
733
  * @version Gjs 1.71.1
@@ -542,53 +735,23 @@ declare global {
542
735
  * @param delay the duration in milliseconds to wait between calling callback
543
736
  * @param args arguments to pass to callback
544
737
  */
545
- function setInterval(callback: (...args: any[]) => any, delay?: number, ...args: any[]): GLib20.Source
738
+ function setInterval(callback: (...args: any[]) => any, delay?: number, ...args: any[]): GLib.Source
546
739
 
547
740
  /**
548
741
  * @version Gjs 1.71.1
549
742
  * @param timeout the timeout to clear
550
743
  */
551
- function clearTimeout(timeout: GLib20.Source): void
744
+ function clearTimeout(timeout: GLib.Source): void
552
745
 
553
746
  /**
554
747
  * @version Gjs 1.71.1
555
748
  * @param timeout the timeout to clear
556
749
  */
557
- function clearInterval(timeout: GLib20.Source): void
558
-
559
- const imports: typeof Gjs & {
560
- gi: {
561
- <%_ for (const girModuleGroup of girModulesGrouped) { _%>
562
- <%= girModuleGroup.namespace %>: <%_ for (const [i, girModule] of girModuleGroup.modules.entries()) { _%>
563
- typeof <%= girModule.module.importName %>
564
- <%_ if (i !== girModuleGroup.modules.length - 1) { _%>
565
- |
566
- <%_ } _%>
567
- <%_ } _%>
568
- <%_ } _%>
569
- versions: {
570
- <%_ for (const girModuleGroup of girModulesGrouped) { _%>
571
- <%= girModuleGroup.namespace %>: <%_ for (const [i, girModule] of girModuleGroup.modules.entries()) { _%>
572
- '<%= girModule.module.version %>'
573
- <%_ if (i !== girModuleGroup.modules.length - 1) { _%>
574
- |
575
- <%_ } _%>
576
- <%_ } _%>
577
- <%_ } _%>
578
- }
579
- }
580
- lang: typeof Gjs.Lang
581
- system: typeof Gjs.System
582
- signals: typeof Gjs.Signals
583
- package: typeof Gjs.Package
584
- mainloop: typeof Gjs.Mainloop
585
- searchPath: string[]
586
- <%_ if(gnomeShellTypes){ _%>
587
- misc: typeof GnomeShell.misc
588
- ui: typeof GnomeShell.ui
589
- <%_ } _%>
590
- }
750
+ function clearInterval(timeout: GLib.Source): void
751
+
752
+ const imports: GjsImports
591
753
  }
592
754
 
593
- declare const _imports: typeof imports
755
+ declare const _imports: GjsImports
594
756
  export default _imports
757
+ export { _imports as imports }
@@ -0,0 +1,10 @@
1
+ const imports = globalThis.imports || {};
2
+
3
+ <%_ if(moduleType === 'esm') { _%>
4
+ export { imports }
5
+ export default imports;
6
+ <%_ } else { _%>
7
+ module.exports = imports;
8
+ exports.default = imports;
9
+ <%_ } _%>
10
+
@@ -23,7 +23,7 @@ export interface MetaInfo<Props, Interfaces, Sigs> {
23
23
  Signals?: Sigs
24
24
  Implements?: Interfaces
25
25
  CssName?: string
26
- Template?: Uint8Array | GLib.Bytes
26
+ Template?: Uint8Array | GLib.Bytes | string
27
27
  Children?: string[]
28
28
  InternalChildren?: string[]
29
29
  }
@@ -0,0 +1,31 @@
1
+ <%#
2
+ This EJS template is used for the generated .d.ts files for ambient typescript module support.
3
+ See https://www.typescriptlang.org/docs/handbook/modules.html#ambient-modules
4
+ %>
5
+ <%_ const pkg = dep.get(girModule.namespace, girModule.version) _%>
6
+ <%_ let moduleImportStr = ""; _%>
7
+ <%_ if(package){ _%>
8
+ <%_ if(noNamespace){ _%>
9
+ <%_ moduleImportStr = `import * as ${girModule.importNamespace} from '${pkg.importPath}'`; _%>
10
+ <%_ } else { _%>
11
+ <%_ moduleImportStr = `import ${girModule.importNamespace} from '${pkg.importPath}'`; _%>
12
+ <%_ } _%>
13
+ <%_ } else { _%>
14
+ <%_ if(noNamespace){ _%>
15
+ <%_ moduleImportStr = `const ${girModule.importNamespace}: typeof import('${pkg.importPath}')`; _%>
16
+ <%_ } else { _%>
17
+ <%_ moduleImportStr = `const ${girModule.importNamespace}: typeof import('${pkg.importPath}').default`; _%>
18
+ <%_ } _%>
19
+ <%_ } _%>
20
+
21
+ declare module 'gi://<%= name %>?version=<%= version %>' {
22
+ <%- moduleImportStr %>;
23
+ export default <%- girModule.importNamespace -%>;
24
+ }
25
+
26
+ <%_ if(!dep.hasConflict(name, version)){ _%>
27
+ declare module 'gi://<%= name %>' {
28
+ <%- moduleImportStr %>;
29
+ export default <%- girModule.importNamespace -%>;
30
+ }
31
+ <%_ } _%>
@@ -0,0 +1,33 @@
1
+ <%#
2
+ This EJS template is used to extend the global GjsGiImports interface with the GIR module, for `imports.gi[namespace] GJS GIR types`
3
+ %>
4
+ <%_ if(!package && !dep.isLatestVersion(girModule.namespace, girModule.version)){ _%>
5
+ <%_ return `// Module import type definition not generated, otherwise this would cause a type conflict, this is because several GIR modules were generated with the same namespace: "${ girModule.namespace }"` _%>
6
+ <%_ } _%>
7
+
8
+ <%_ const pkg = dep.get(girModule.namespace, girModule.version) _%>
9
+ <%_ if(package){ _%>
10
+ <%_ if(noNamespace){ _%>
11
+ import * as <%= girModule.importNamespace %> from '<%= pkg.importPath %>';
12
+ <%_ } else { _%>
13
+ import <%= girModule.importNamespace %> from '<%= pkg.importPath %>';
14
+ <%_ } _%>
15
+ <%_ } else { _%>
16
+ <%_ if(noNamespace){ _%>
17
+ type <%= girModule.importNamespace %> = typeof import('<%= pkg.importPath %>');
18
+ <%_ } else { _%>
19
+ type <%= girModule.importNamespace %> = typeof import('<%= pkg.importPath %>').default;
20
+ <%_ } _%>
21
+ <%_ } _%>
22
+
23
+ declare global {
24
+ export interface GjsGiImports {
25
+ <%_ if(package){ _%>
26
+ <%= name %>: typeof <%= girModule.importNamespace %>;
27
+ <%_ } else { _%>
28
+ <%= name %>: <%= girModule.importNamespace %>;
29
+ <%_ } _%>
30
+ }
31
+ }
32
+
33
+ export default GjsGiImports;
@@ -0,0 +1 @@
1
+ // END
@@ -0,0 +1,12 @@
1
+ <%# This EJS template is used for the generated .d.ts file of each GIR module like Gtk-4.0, GObject-2.0, ... %>
2
+ /*
3
+ * Type Definitions for Gjs (https://gjs.guide/)
4
+ *
5
+ * These type definitions are automatically generated, do not edit them by hand.
6
+ * If you found a bug fix it in `<%= APP_NAME %>` or create a bug report on <%= APP_SOURCE %>
7
+ */
8
+
9
+ <%_ if(package){ _%>
10
+ import './<%= importName %>-ambient.d.ts';
11
+ <%_ } _%>
12
+ import './<%= importName %>-import.d.ts';
@@ -0,0 +1,17 @@
1
+ <%# This template is used for the generated `.js` file of each GIR module like Gtk-4.0, GObject-2.0, ... %>
2
+ <% if(moduleType === 'esm'){ %>
3
+ // @ts-expect-error
4
+ import <%= name %> from 'gi://<%= name %>?version=<%= version %>';
5
+ export { <%= name %> };
6
+ export default <%= name %>;
7
+ <% } else { %>
8
+ imports.gi.versions.<%= name %> = '<%= version %>'
9
+ const <%= name %> = imports.gi.<%= name %>;
10
+ <% if(!noNamespace){ %>
11
+ module.exports = { <%= name %> };
12
+ exports.default = <%= name %>;
13
+ <% } else { %>
14
+ module.exports = <%= name %>;
15
+ <% } %>
16
+ <% } %>
17
+
@@ -0,0 +1,32 @@
1
+ <%_ const GObject = dep.find('GObject') _%>
2
+ <%- GObject ? GObject.importDef : '' %>
3
+
4
+ export const programInvocationName: string
5
+ export const version: number
6
+ export const programPath: string | null
7
+ /** Equal to ARGV */
8
+ export const programArgs: string[]
9
+ export function exit(code: number): void
10
+ export function addressOfGObject(o: GObject.Object): object
11
+ export function addressOf(o: any): object
12
+ /** Runs the garbage collector */
13
+ export function gc(): void
14
+ export function refcount(o: GObject.Object): number
15
+ export function dumpHeap(path: string): void
16
+ export function dumpMemoryInfo(path: string): void
17
+
18
+ declare const System: {
19
+ programInvocationName: typeof programInvocationName,
20
+ version: typeof version,
21
+ programPath: typeof programPath,
22
+ programArgs: typeof programArgs,
23
+ exit: typeof exit,
24
+ addressOfGObject: typeof addressOfGObject,
25
+ addressOf: typeof addressOf,
26
+ gc: typeof gc,
27
+ refcount: typeof refcount,
28
+ dumpHeap: typeof dumpHeap,
29
+ dumpMemoryInfo: typeof dumpMemoryInfo,
30
+ }
31
+
32
+ export default System
@@ -0,0 +1,11 @@
1
+ <% if(moduleType === 'esm') { %>
2
+ import System, { programInvocationName, version, programPath, programArgs, exit, addressOfGObject, addressOf, gc, refcount, dumpHeap, dumpMemoryInfo } from 'system';
3
+
4
+ export { programInvocationName, version, programPath, programArgs, exit, addressOfGObject, addressOf, gc, refcount, dumpHeap, dumpMemoryInfo };
5
+ export default System;
6
+ <% } else { %>
7
+ const System = imports.system;
8
+
9
+ module.exports = System;
10
+ exports.default = System;
11
+ <% } %>
@@ -0,0 +1,12 @@
1
+ <%# This template is used if the Option `generateAlias` is enabled %>
2
+ {
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "paths": { <% girModules.forEach(function(module, idx) { %>
6
+ <%_ const pkg = dep.get(module.namespace, module.version) _%>
7
+ <%_ const path = package ? join(typeDir, pkg.importName, pkg.importName) : join(typeDir, pkg.importName) _%>
8
+ "gi://<%= module.namespace %>?version=<%= module.version %>": ["<%= path %>.d.ts"]<% if (idx < girModules.length - 1) { %>,<% } %><% }); %>
9
+ }
10
+ },
11
+ "include": ["<%= typeDir %>/*.ts"]
12
+ }
@@ -0,0 +1,71 @@
1
+ <%# This template is used if the Option `package` is enabled %>
2
+ # <%- packageName %>
3
+
4
+ <%- PACKAGE_DESC %> using [<%- APP_NAME %>](<%- APP_SOURCE %>) v<%- APP_VERSION %>.
5
+
6
+ <%_ if (typeof pkgData !== 'undefined' && pkgData.description) { _%>
7
+ <%- pkgData.description %>
8
+ <%_ } else { _%>
9
+ [node-gtk](https://github.com/romgrk/node-gtk) is a [GObject Introspection](https://gi.readthedocs.io/en/latest/) import library for Node.js. Using node-gtk with the type definitions in this NPM package, you can build GTK applications in JavaScript or TypeScript with type checking, better autocompletion and inline documentations.
10
+ <%_ } _%>
11
+
12
+ ## Install
13
+
14
+ To use this type definitions, install them with NPM:
15
+ ```bash
16
+ npm install <%- npmScope %>/<%- importName %>
17
+ ```
18
+
19
+ <%_ const pkg = dep.get(packageName) _%>
20
+ <%_ if(!pkg){ _%>
21
+ <%_ return `Package with package name "${packageName}" not found!` _%>
22
+ <%_ } _%>
23
+
24
+ ## Usage
25
+
26
+ You can import this package into your project like this:
27
+ ```ts
28
+ import <%- pkg.namespace %> from '<%- pkg.importPath %>';
29
+ ```
30
+
31
+ Or if you prefer CommonJS, you can also use this:
32
+ ```ts
33
+ const <%- pkg.namespace %> = require('<%- pkg.importPath %>');
34
+ ```
35
+
36
+ ### Ambient Modules
37
+
38
+ You can import core [ambient module](https://github.com/gjsify/ts-for-gir/tree/main/packages/cli#ambient-modules) types.
39
+ For this you need to include the `<%- npmScope %>/<%- importName %>` or `<%- npmScope %>/<%- importName %>/ambient` in your `tsconfig` or entry point Typescript file:
40
+
41
+ `index.ts`:
42
+ ```ts
43
+ import '<%- npmScope %>/<%- importName %>'
44
+ ```
45
+
46
+ `tsconfig.json`:
47
+ ```json
48
+ {
49
+ "compilerOptions": {
50
+ ...
51
+ },
52
+ "include": ["<%- npmScope %>/<%- importName %>"],
53
+ ...
54
+ }
55
+ ```
56
+
57
+ Now you can import `node-gtk` with Typescript support:
58
+ ```ts
59
+ const gi = require('node-gtk');
60
+ gi.startLoop();
61
+ ```
62
+
63
+ If you want to have types for [GObject Introspection](https://gi.readthedocs.io/en/latest/) modules, you have to add them to your dependencies and import them as well, see the description of these modules, e.g. [node-gtk-4.0](https://www.npmjs.com/package/@girs/node-gtk-4.0), [node-gio-2.0](https://www.npmjs.com/package/@girs/node-gio-2.0), [node-adw-1](https://www.npmjs.com/package/@girs/node-adw-1) and [much more](https://github.com/gjsify/types).
64
+
65
+ ### Bundle
66
+
67
+ Depending on your project configuration, it is recommended to use a bundler like [esbuild](https://esbuild.github.io/). You can find examples using different bundlers [here](https://github.com/gjsify/ts-for-gir/tree/main/examples).
68
+
69
+ ## Other packages
70
+
71
+ All existing pre-generated packages can be found on [gjsify/types](https://github.com/gjsify/types).
@@ -0,0 +1,19 @@
1
+ // https://www.typescriptlang.org/docs/handbook/modules.html#ambient-modules
2
+ // https://stackoverflow.com/questions/45099605/ambient-declaration-with-an-imported-type-in-typescript
3
+ declare module 'node-gtk' {
4
+ <%_ const pkg = dep.getNodeGtk() _%>
5
+ <%_ if(package){ _%>
6
+ <% if(moduleType === 'esm'){ %>
7
+ import gi from '<%= pkg.importPath %>';
8
+ <% } else { %>
9
+ import * as gi from '<%= pkg.importPath %>';
10
+ <% } %>
11
+ <%_ } else { _%>
12
+ <% if(moduleType === 'esm'){ %>
13
+ const gi: typeof import('<%= pkg.importPath %>').default;
14
+ <% } else { %>
15
+ const gi: typeof import('<%= pkg.importPath %>');
16
+ <% } %>
17
+ <%_ } _%>
18
+ export = gi;
19
+ }
@@ -0,0 +1,29 @@
1
+ <%#
2
+ This EJS template is used to extend the global NodeGtkGi interface with the GIR module, for `gi.require(namespace) node-gtk GIR types`
3
+ %>
4
+ <%_ const pkg = dep.get(girModule.namespace, girModule.version) _%>
5
+ <%_ if(package){ _%>
6
+ <%_ if(noNamespace){ _%>
7
+ import * as <%= girModule.importNamespace %> from '<%= pkg.importPath %>';
8
+ <%_ } else { _%>
9
+ import <%= girModule.importNamespace %> from '<%= pkg.importPath %>';
10
+ <%_ } _%>
11
+ <%_ } else { _%>
12
+ <%_ if(noNamespace){ _%>
13
+ type <%= girModule.importNamespace %> = typeof import('<%= pkg.importPath %>');
14
+ <%_ } else { _%>
15
+ type <%= girModule.importNamespace %> = typeof import('<%= pkg.importPath %>').default;
16
+ <%_ } _%>
17
+ <%_ } _%>
18
+
19
+ declare global {
20
+ interface NodeGtkGi {
21
+ <%_ if(package){ _%>
22
+ require(ns: '<%= girModule.namespace %>', ver?: '<%= girModule.version %>'): typeof <%= girModule.importNamespace %>;
23
+ <%_ } else { _%>
24
+ require(ns: '<%= girModule.namespace %>', ver?: '<%= girModule.version %>'): <%= girModule.importNamespace %>;
25
+ <%_ } _%>
26
+ }
27
+ }
28
+
29
+ export default NodeGtkGi;
@@ -0,0 +1 @@
1
+ // END