@girs/gjs 4.0.0-beta.5 → 4.0.0-beta.7

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 CHANGED
@@ -4,7 +4,7 @@
4
4
  ![version](https://img.shields.io/npm/v/@girs/gjs)
5
5
  ![downloads/week](https://img.shields.io/npm/dw/@girs/gjs)
6
6
 
7
- GJS TypeScript type definitions for Gjs using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v4.0.0-beta.5.
7
+ GJS TypeScript type definitions for Gjs using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v4.0.0-beta.7.
8
8
 
9
9
  [GJS](https://gitlab.gnome.org/GNOME/gjs) is a JavaScript runtime for the GNOME ecosystem. Using GJS and 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
10
 
package/cairo.d.ts CHANGED
@@ -2,5 +2,3 @@
2
2
  declare const Cairo: any;
3
3
 
4
4
  export default Cairo;
5
-
6
-
package/dom.d.ts CHANGED
@@ -2,16 +2,16 @@
2
2
  * Gjs has implemented some functionality from the DOM API,
3
3
  * this leads to a conflict when all DOM (`lib.dom.d.ts`) should be used.
4
4
  * This should normally not be the case, since the other - not yet reimplemented - API's cannot be used in GJS anyway.
5
- * In particular, Gjsify tries to rebuild the DOM API and therefore does not need these types.
6
- * For this reason they are stored in this separate file to make them optional.
7
- *
5
+ *
6
+ * If for some reason the entire DOM types should still be used,
7
+ * this file can be ignored and `lib.dom.d.ts` used instead, otherwise this file should be imported in your project.
8
+ *
8
9
  * See also https://github.com/microsoft/TypeScript/blob/main/lib/lib.dom.d.ts
9
10
  */
10
11
 
11
12
  import type GLib from '@girs/glib-2.0';
12
13
 
13
14
  declare global {
14
-
15
15
  interface ImportMeta {
16
16
  /**
17
17
  * The absolute file: or resource: URL of the module.
@@ -30,7 +30,7 @@ declare global {
30
30
  * @param delay the duration in milliseconds to wait before running callback
31
31
  * @param args arguments to pass to callback
32
32
  */
33
- function setTimeout(callback: (...args: any[]) => any, delay?: number, ...args: any[]): GLib.Source
33
+ function setTimeout(callback: (...args: any[]) => any, delay?: number, ...args: any[]): GLib.Source;
34
34
 
35
35
  /**
36
36
  * @version Gjs 1.71.1
@@ -38,19 +38,19 @@ declare global {
38
38
  * @param delay the duration in milliseconds to wait between calling callback
39
39
  * @param args arguments to pass to callback
40
40
  */
41
- function setInterval(callback: (...args: any[]) => any, delay?: number, ...args: any[]): GLib.Source
41
+ function setInterval(callback: (...args: any[]) => any, delay?: number, ...args: any[]): GLib.Source;
42
42
 
43
43
  /**
44
44
  * @version Gjs 1.71.1
45
45
  * @param timeout the timeout to clear
46
46
  */
47
- function clearTimeout(timeout: GLib.Source): void
47
+ function clearTimeout(timeout: GLib.Source): void;
48
48
 
49
49
  /**
50
50
  * @version Gjs 1.71.1
51
51
  * @param timeout the timeout to clear
52
52
  */
53
- function clearInterval(timeout: GLib.Source): void
53
+ function clearInterval(timeout: GLib.Source): void;
54
54
 
55
55
  interface Console {
56
56
  /**
@@ -62,7 +62,7 @@ declare global {
62
62
  * @param data formatting substitutions, if applicable
63
63
  * @returns
64
64
  */
65
- assert(condition: boolean, ...data: any[]): void
65
+ assert(condition: boolean, ...data: any[]): void;
66
66
 
67
67
  /**
68
68
  * Resets grouping and clears the terminal on systems supporting ANSI
@@ -72,14 +72,14 @@ declare global {
72
72
  * console.clear() has no visual effect.
73
73
  *
74
74
  */
75
- clear(): void
75
+ clear(): void;
76
76
 
77
77
  /**
78
78
  * Logs a message with severity equal to {@link GLib.LogLevelFlags.DEBUG}.
79
79
  *
80
80
  * @param {...any} data formatting substitutions, if applicable
81
81
  */
82
- debug(...data: any[]): void
82
+ debug(...data: any[]): void;
83
83
 
84
84
  /**
85
85
  * Logs a message with severity equal to {@link GLib.LogLevelFlags.CRITICAL}.
@@ -88,46 +88,46 @@ declare global {
88
88
  *
89
89
  * @param data formatting substitutions, if applicable
90
90
  */
91
- error(...data: any[]): void
91
+ error(...data: any[]): void;
92
92
 
93
93
  /**
94
94
  * Logs a message with severity equal to {@link GLib.LogLevelFlags.INFO}.
95
95
  *
96
96
  * @param data formatting substitutions, if applicable
97
97
  */
98
- info(...data: any[]): void
98
+ info(...data: any[]): void;
99
99
 
100
100
  /**
101
101
  * Logs a message with severity equal to {@link GLib.LogLevelFlags.MESSAGE}.
102
102
  *
103
103
  * @param data formatting substitutions, if applicable
104
104
  */
105
- log(...data: any[]): void
105
+ log(...data: any[]): void;
106
106
 
107
107
  // 1.1.7 table(tabularData, properties)
108
- table(tabularData: any, _properties: never): void
108
+ table(tabularData: any, _properties: never): void;
109
109
 
110
110
  /**
111
111
  * @param data formatting substitutions, if applicable
112
112
  */
113
- trace(...data: any[]): void
113
+ trace(...data: any[]): void;
114
114
 
115
115
  /**
116
116
  * @param data formatting substitutions, if applicable
117
117
  */
118
- warn(...data: any[]): void
118
+ warn(...data: any[]): void;
119
119
 
120
120
  /**
121
121
  * @param item an item to format generically
122
122
  * @param [options] any additional options for the formatter. Unused
123
123
  * in our implementation.
124
124
  */
125
- dir(item: object, options: never): void
125
+ dir(item: object, options: never): void;
126
126
 
127
127
  /**
128
128
  * @param data formatting substitutions, if applicable
129
129
  */
130
- dirxml(...data: any[]): void
130
+ dirxml(...data: any[]): void;
131
131
 
132
132
  // 1.2 Counting functions
133
133
  // https://console.spec.whatwg.org/#counting
@@ -139,12 +139,12 @@ declare global {
139
139
  *
140
140
  * @param label unique identifier for this action
141
141
  */
142
- count(label: string): void
142
+ count(label: string): void;
143
143
 
144
144
  /**
145
145
  * @param label the unique label to reset the count for
146
146
  */
147
- countReset(label: string): void
147
+ countReset(label: string): void;
148
148
 
149
149
  // 1.3 Grouping functions
150
150
  // https://console.spec.whatwg.org/#grouping
@@ -152,18 +152,18 @@ declare global {
152
152
  /**
153
153
  * @param data formatting substitutions, if applicable
154
154
  */
155
- group(...data: any[]): void
155
+ group(...data: any[]): void;
156
156
 
157
157
  /**
158
158
  * Alias for console.group()
159
159
  *
160
160
  * @param {...any} data formatting substitutions, if applicable
161
161
  */
162
- groupCollapsed(...data: any[]): void
162
+ groupCollapsed(...data: any[]): void;
163
163
 
164
164
  /**
165
165
  */
166
- groupEnd(): void
166
+ groupEnd(): void;
167
167
 
168
168
  // 1.4 Timing functions
169
169
  // https://console.spec.whatwg.org/#timing
@@ -172,7 +172,7 @@ declare global {
172
172
  * @param label unique identifier for this action, pass to
173
173
  * console.timeEnd() to complete
174
174
  */
175
- time(label: string): void
175
+ time(label: string): void;
176
176
 
177
177
  /**
178
178
  * Logs the time since the last call to console.time(label) where label is
@@ -182,7 +182,7 @@ declare global {
182
182
  * console.timeEnd() to complete
183
183
  * @param data string substitutions, if applicable
184
184
  */
185
- timeLog(label: string, ...data: any[]): void
185
+ timeLog(label: string, ...data: any[]): void;
186
186
 
187
187
  /**
188
188
  * Logs the time since the last call to console.time(label) and completes
@@ -191,7 +191,7 @@ declare global {
191
191
  *
192
192
  * @param label unique identifier for this action
193
193
  */
194
- timeEnd(label: string): void
194
+ timeEnd(label: string): void;
195
195
 
196
196
  // Non-standard functions which are de-facto standards.
197
197
  // Similar to Node, we define these as no-ops for now.
@@ -202,21 +202,21 @@ declare global {
202
202
  * @param _label unique identifier for this action, pass to
203
203
  * console.profileEnd to complete
204
204
  */
205
- profile(_label: string): void
205
+ profile(_label: string): void;
206
206
 
207
207
  /**
208
208
  * @deprecated Not implemented in GJS
209
209
  *
210
210
  * @param _label unique identifier for this action
211
211
  */
212
- profileEnd(_label: string): void
212
+ profileEnd(_label: string): void;
213
213
 
214
214
  /**
215
215
  * @deprecated Not implemented in GJS
216
216
  *
217
217
  * @param _label unique identifier for this action
218
218
  */
219
- timeStamp(_label: string): void
219
+ timeStamp(_label: string): void;
220
220
 
221
221
  // GJS-specific extensions for integrating with GLib structured logging
222
222
 
@@ -224,11 +224,11 @@ declare global {
224
224
  * @param logDomain the GLib log domain this Console should print
225
225
  * with. Defaults to 'Gjs-Console'.
226
226
  */
227
- setLogDomain(logDomain: string): void
227
+ setLogDomain(logDomain: string): void;
228
228
 
229
- logDomain: string
229
+ logDomain: string;
230
230
 
231
- interact(): void
231
+ interact(): void;
232
232
  }
233
233
 
234
234
  interface TextDecodeOptions {
@@ -238,9 +238,9 @@ declare global {
238
238
 
239
239
  interface TextDecoderOptions {
240
240
  /** Indicates whether the error mode is fatal. */
241
- fatal?: boolean
241
+ fatal?: boolean;
242
242
  /** Indicates whether whether the byte order mark is ignored. */
243
- ignoreBOM?: boolean
243
+ ignoreBOM?: boolean;
244
244
  }
245
245
 
246
246
  /**
@@ -251,11 +251,11 @@ declare global {
251
251
  */
252
252
  interface TextDecoder {
253
253
  /** A string containing the name of the decoder, that is a string describing the method the TextDecoder will use. */
254
- readonly encoding: TextDecoderEncoding
254
+ readonly encoding: TextDecoderEncoding;
255
255
  /** A Boolean indicating whether the error mode is fatal. */
256
- readonly fatal: boolean
256
+ readonly fatal: boolean;
257
257
  /** A Boolean indicating whether the byte order mark is ignored. */
258
- readonly ignoreBOM: boolean
258
+ readonly ignoreBOM: boolean;
259
259
 
260
260
  /**
261
261
  * Returns a string containing the text decoded with the method of the specific TextDecoder object.
@@ -265,12 +265,12 @@ declare global {
265
265
  * @param input Buffer containing the text to decode
266
266
  * @param options Object defining the decode options
267
267
  */
268
- decode(input?: ArrayBufferView | ArrayBuffer, options?: TextDecodeOptions): string
268
+ decode(input?: ArrayBufferView | ArrayBuffer, options?: TextDecodeOptions): string;
269
269
  }
270
270
 
271
271
  interface TextEncoderEncodeIntoResult {
272
- read?: number
273
- written?: number
272
+ read?: number;
273
+ written?: number;
274
274
  }
275
275
 
276
276
  /**
@@ -279,14 +279,14 @@ declare global {
279
279
  * @version Gjs 1.69.2
280
280
  */
281
281
  interface TextEncoder {
282
- readonly encoding: 'utf-8'
282
+ readonly encoding: 'utf-8';
283
283
 
284
284
  /**
285
285
  * Takes a string as input, and returns a buffer containing the text given in parameters encoded with the UTF-8 method.
286
286
  *
287
287
  * @param input Text to encode.
288
288
  */
289
- encode(input?: string): Uint8Array
289
+ encode(input?: string): Uint8Array;
290
290
  /**
291
291
  * Takes a string to encode and a destination Uint8Array to put resulting UTF-8 encoded text into,
292
292
  * and returns a dictionary object indicating the progress of the encoding.
@@ -296,21 +296,20 @@ declare global {
296
296
  * @param source Text to encode.
297
297
  * @param destination Buffer where to place the resulting UTF-8 encoded text into.
298
298
  */
299
- encodeInto(source: string, destination: Uint8Array): TextEncoderEncodeIntoResult
299
+ encodeInto(source: string, destination: Uint8Array): TextEncoderEncodeIntoResult;
300
300
  }
301
301
 
302
- const console: Console
302
+ const console: Console;
303
303
 
304
304
  const TextDecoder: {
305
- prototype: TextDecoder
306
- new (label?: TextDecoderEncoding, options?: TextDecoderOptions): TextDecoder
307
- }
305
+ prototype: TextDecoder;
306
+ new (label?: TextDecoderEncoding, options?: TextDecoderOptions): TextDecoder;
307
+ };
308
308
 
309
309
  const TextEncoder: {
310
- prototype: TextEncoder
311
- new (): TextEncoder
312
- }
310
+ prototype: TextEncoder;
311
+ new (): TextEncoder;
312
+ };
313
313
  }
314
314
 
315
- export {}
316
-
315
+ export {};
package/gettext.d.ts CHANGED
@@ -7,36 +7,35 @@ export enum LocaleCategory {
7
7
  NUMERIC,
8
8
  TIME,
9
9
  }
10
- export function setlocale(category: number, locale: string | null): string
11
- export function textdomain(domainname: string | null): string
12
- export function bindtextdomain(domainname: string, dirname: string | null): string
13
- export function gettext(msgid: string): string
14
- export function dgettext(domainname: string | null, msgid: string): string
15
- export function dcgettext(domainname: string | null, msgid: string, category: number): string
16
- export function ngettext(msgid: string, msgid_plural: string, n: number): string
17
- export function dngettext(domainname: string, msgid: string, msgid_plural: string, n: number): string
18
- export function pgettext(context: string, msgid: string): string
19
- export function dpgettext(dom: string | null, context: string, msgid: string): string
10
+ export function setlocale(category: number, locale: string | null): string;
11
+ export function textdomain(domainname: string | null): string;
12
+ export function bindtextdomain(domainname: string, dirname: string | null): string;
13
+ export function gettext(msgid: string): string;
14
+ export function dgettext(domainname: string | null, msgid: string): string;
15
+ export function dcgettext(domainname: string | null, msgid: string, category: number): string;
16
+ export function ngettext(msgid: string, msgid_plural: string, n: number): string;
17
+ export function dngettext(domainname: string, msgid: string, msgid_plural: string, n: number): string;
18
+ export function pgettext(context: string, msgid: string): string;
19
+ export function dpgettext(dom: string | null, context: string, msgid: string): string;
20
20
  export function domain(domainName: string): {
21
- gettext: (msgid: string) => string
22
- ngettext: (msgid: string, msgid_plural: string, n: number) => string
23
- pgettext: (context: string, msgid: string) => string
24
- }
21
+ gettext: (msgid: string) => string;
22
+ ngettext: (msgid: string, msgid_plural: string, n: number) => string;
23
+ pgettext: (context: string, msgid: string) => string;
24
+ };
25
25
 
26
26
  declare const Gettext: {
27
- LocaleCategory: typeof LocaleCategory,
28
- setlocale: typeof setlocale,
29
- textdomain: typeof textdomain,
30
- bindtextdomain: typeof bindtextdomain,
31
- gettext: typeof gettext,
32
- dgettext: typeof dgettext,
33
- dcgettext: typeof dcgettext,
34
- ngettext: typeof ngettext,
35
- dngettext: typeof dngettext,
36
- pgettext: typeof pgettext,
37
- dpgettext: typeof dpgettext,
38
- domain: typeof domain,
39
- }
40
-
41
- export default Gettext
27
+ LocaleCategory: typeof LocaleCategory;
28
+ setlocale: typeof setlocale;
29
+ textdomain: typeof textdomain;
30
+ bindtextdomain: typeof bindtextdomain;
31
+ gettext: typeof gettext;
32
+ dgettext: typeof dgettext;
33
+ dcgettext: typeof dcgettext;
34
+ ngettext: typeof ngettext;
35
+ dngettext: typeof dngettext;
36
+ pgettext: typeof pgettext;
37
+ dpgettext: typeof dpgettext;
38
+ domain: typeof domain;
39
+ };
42
40
 
41
+ export default Gettext;
@@ -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
+
4
+ declare module 'gettext' {
5
+ export * from '@girs/gjs/gettext';
6
+ import Gettext from '@girs/gjs/gettext';
7
+ export default Gettext;
8
+ }
9
+
10
+ declare module 'system' {
11
+ export * from '@girs/gjs/system';
12
+ import System from '@girs/gjs/system';
13
+ export default System;
14
+ }
15
+
16
+ declare module 'cairo' {
17
+ import Cairo from '@girs/gjs/cairo';
18
+ export default Cairo;
19
+ }
package/gjs.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- /*
1
+ /**
2
2
  * Type Definitions for Gjs (https://gjs.guide/)
3
3
  *
4
4
  * These type definitions are automatically generated, do not edit them by hand.
5
5
  * If you found a bug fix it in ts-for-gir itself or create a bug report on https://github.com/gjsify/ts-for-gir
6
6
  */
7
- import './ambient.d.ts';
8
7
 
9
8
  import type GObject from '@girs/gobject-2.0';
10
9
  import type GLib from '@girs/glib-2.0';
10
+
11
11
  import gettext from './gettext.js';
12
12
  import system from './system.js';
13
13
  import cairo from './cairo.js';
@@ -20,73 +20,73 @@ declare namespace package {
20
20
  * and all the other have their values derived from them.
21
21
  */
22
22
  interface PackageInitParams {
23
- name: string
24
- version: string
25
- prefix: string
26
- libdir: string
23
+ name: string;
24
+ version: string;
25
+ prefix: string;
26
+ libdir: string;
27
27
  }
28
28
 
29
- export const name: string | undefined
30
- export const version: string | undefined
31
- export const prefix: string | undefined
32
- export const datadir: string | undefined
33
- export const libdir: string | undefined
34
- export const pkgdatadir: string | undefined
35
- export const pkglibdir: string | undefined
36
- export const moduledir: string | undefined
37
- export const localedir: string | undefined
29
+ export const name: string | undefined;
30
+ export const version: string | undefined;
31
+ export const prefix: string | undefined;
32
+ export const datadir: string | undefined;
33
+ export const libdir: string | undefined;
34
+ export const pkgdatadir: string | undefined;
35
+ export const pkglibdir: string | undefined;
36
+ export const moduledir: string | undefined;
37
+ export const localedir: string | undefined;
38
38
 
39
- export function init(params: PackageInitParams): void
40
- export function run(module: { main: (argv: string[]) => void }): void
39
+ export function init(params: PackageInitParams): void;
40
+ export function run(module: { main: (argv: string[]) => void }): void;
41
41
  /** shortcut to init+run */
42
- export function start(params: PackageInitParams): void
43
- export function require(libs: Record<string, string>): void
44
- export function requireSymbol(lib: string, ver: string, symbol: string): void
45
- export function checkSymbol(lib: string, ver: string, symbol: string): void
46
- export function initGettext(): void
42
+ export function start(params: PackageInitParams): void;
43
+ export function require(libs: Record<string, string>): void;
44
+ export function requireSymbol(lib: string, ver: string, symbol: string): void;
45
+ export function checkSymbol(lib: string, ver: string, symbol: string): void;
46
+ export function initGettext(): void;
47
47
  /** @deprecated Use JS string interpolation */
48
- export function initFormat(): void
49
- export function initSubmodule(module: string): void
48
+ export function initFormat(): void;
49
+ export function initSubmodule(module: string): void;
50
50
  }
51
51
 
52
52
  declare namespace byteArray {
53
53
  export class ByteArray {
54
- static get(target: any, property: string, receiver: any): any
55
- static set(target: any, property: string, value: any, receiver: any): boolean
54
+ static get(target: any, property: string, receiver: any): any;
55
+ static set(target: any, property: string, value: any, receiver: any): boolean;
56
56
 
57
- length: number
58
- protected _array: Uint8Array
57
+ length: number;
58
+ protected _array: Uint8Array;
59
59
 
60
- constructor(x: Uint8Array | number)
61
- toString(encoding?: TextDecoderEncoding): string
62
- fromString(input: string, encoding?: TextDecoderEncoding): ByteArray
63
- toGBytes(): GLib.Bytes
60
+ constructor(x: Uint8Array | number);
61
+ toString(encoding?: TextDecoderEncoding): string;
62
+ fromString(input: string, encoding?: TextDecoderEncoding): ByteArray;
63
+ toGBytes(): GLib.Bytes;
64
64
  }
65
65
 
66
66
  /** @deprecated Use {@link TextEncoder.encode} instead */
67
- export function fromString(input: string, encoding?: TextDecoderEncoding): Uint8Array
67
+ export function fromString(input: string, encoding?: TextDecoderEncoding): Uint8Array;
68
68
 
69
69
  /** @deprecated Use {@link GLib.Bytes.toArray} instead */
70
- export function fromGBytes(input: GLib.Bytes): Uint8Array
70
+ export function fromGBytes(input: GLib.Bytes): Uint8Array;
71
71
 
72
72
  /** @deprecated Use {@link TextDecoder.decode} instead */
73
- export function toString(x: Uint8Array, encoding?: TextDecoderEncoding): string
73
+ export function toString(x: Uint8Array, encoding?: TextDecoderEncoding): string;
74
74
 
75
75
  /** @deprecated Use {@link GLib.Bytes new GLib.Bytes() } instead */
76
- export function toGBytes(x: Uint8Array): GLib.Bytes
76
+ export function toGBytes(x: Uint8Array): GLib.Bytes;
77
77
 
78
78
  /** @deprecated Use {@link ByteArray new ByteArray()} instead */
79
- export function fromArray(array: Iterable<number>): ByteArray
79
+ export function fromArray(array: Iterable<number>): ByteArray;
80
80
  }
81
81
 
82
82
  declare namespace lang {
83
83
  // TODO: There is a lot more in Lang
84
- export function Class(props: any): void
84
+ export function Class(props: any): void;
85
85
  }
86
86
 
87
87
  declare namespace format {
88
- export function vprintf(str: string, args: string[]): string
89
- export function printf(fmt: string, ...args: any[]): void
88
+ export function vprintf(str: string, args: string[]): string;
89
+ export function printf(fmt: string, ...args: any[]): void;
90
90
  // Following docs from gjs/modules/format.js
91
91
  /**
92
92
  * This function is intended to extend the String object and provide
@@ -99,19 +99,19 @@ declare namespace format {
99
99
  * field width, e.g. "%5s".format("foo"). Unless the width is prefixed
100
100
  * with '0', the formatted string will be padded with spaces.
101
101
  */
102
- export function format(fmt: string, ...args: any[]): string
102
+ export function format(fmt: string, ...args: any[]): string;
103
103
  }
104
104
 
105
105
  declare namespace mainloop {
106
- export function quit(name: string): void
107
- export function idle_source(handler: any, priority?: number): any
108
- export function idle_add(handler: any, priority?: number): any
109
- export function timeout_source(timeout: any, handler: any, priority?: number): any
110
- export function timeout_seconds_source(timeout: any, handler: any, priority?: number): any
111
- export function timeout_add(timeout: any, handler: any, priority?: number): any
112
- export function timeout_add_seconds(timeout: any, handler: any, priority?: number): any
113
- export function source_remove(id: any): any
114
- export function run(name: string): void
106
+ export function quit(name: string): void;
107
+ export function idle_source(handler: any, priority?: number): any;
108
+ export function idle_add(handler: any, priority?: number): any;
109
+ export function timeout_source(timeout: any, handler: any, priority?: number): any;
110
+ export function timeout_seconds_source(timeout: any, handler: any, priority?: number): any;
111
+ export function timeout_add(timeout: any, handler: any, priority?: number): any;
112
+ export function timeout_add_seconds(timeout: any, handler: any, priority?: number): any;
113
+ export function source_remove(id: any): any;
114
+ export function run(name: string): void;
115
115
  }
116
116
 
117
117
  /**
@@ -121,15 +121,15 @@ declare namespace mainloop {
121
121
  * @example
122
122
  * ```ts
123
123
  * const Signals = imports.signals;
124
- *
124
+ *
125
125
  * // Define an interface with the same name of your class to make the methods known
126
126
  * interface Events extends Signals.Methods {}
127
- *
127
+ *
128
128
  * class Events {}
129
129
  * Signals.addSignalMethods(Events.prototype);
130
- *
130
+ *
131
131
  * const events = new Events();
132
- *
132
+ *
133
133
  * // Typescript will not complain here
134
134
  * events.emit("test-signal", "test argument");
135
135
  * ```
@@ -138,13 +138,13 @@ export interface SignalMethods {
138
138
  /**
139
139
  * Connects a callback to a signal for an object. Pass the returned ID to
140
140
  * `disconnect()` to remove the handler.
141
- *
141
+ *
142
142
  * If `callback` returns `true`, emission will stop and no other handlers will be
143
143
  * invoked.
144
- *
144
+ *
145
145
  * > Warning: Unlike GObject signals, `this` within a signal callback will always
146
146
  * > refer to the global object (ie. `globalThis`).
147
- *
147
+ *
148
148
  * @param sigName A signal name
149
149
  * @param callback A callback function
150
150
  * @returns A handler ID
@@ -152,7 +152,7 @@ export interface SignalMethods {
152
152
  connect(sigName: string, callback: (self: any, ...args: any[]) => void): number;
153
153
  /**
154
154
  * Emits a signal for an object. Emission stops if a signal handler returns `true`.
155
- *
155
+ *
156
156
  * Unlike GObject signals, it is not necessary to declare signals or define their
157
157
  * signature. Simply call `emit()` with whatever signal name you wish, with
158
158
  * whatever arguments you wish.
@@ -168,7 +168,7 @@ export interface SignalMethods {
168
168
  /**
169
169
  * Disconnects all signal handlers for an object.
170
170
  */
171
- disconnectAll(): void
171
+ disconnectAll(): void;
172
172
  /**
173
173
  * Checks if a handler ID is connected.
174
174
  * @param id The ID of the handler to be disconnected
@@ -182,7 +182,6 @@ declare namespace signals {
182
182
  }
183
183
 
184
184
  declare global {
185
-
186
185
  // https://gitlab.gnome.org/GNOME/gjs/-/blob/1.73.2/modules/esm/_encoding/encodingMap.js#L7-232
187
186
  type TextDecoderEncoding =
188
187
  | 'unicode-1-1-utf-8'
@@ -404,56 +403,54 @@ declare global {
404
403
  | 'unicode'
405
404
  | 'unicodefeff'
406
405
  | 'utf-16'
407
- | 'utf-16le'
406
+ | 'utf-16le';
408
407
 
409
408
  interface GjsGiImports {
410
409
  // Will be extended by the import of more gir types
411
410
  versions: {
412
- [namespace: string]: string
413
- }
411
+ [namespace: string]: string;
412
+ };
414
413
  }
415
-
414
+
416
415
  interface GjsImports {
417
- gi: GjsGiImports
418
- lang: typeof lang
419
- system: typeof system
420
- signals: typeof signals
421
- package: typeof package
422
- mainloop: typeof mainloop
423
- searchPath: string[]
424
- gettext: typeof gettext
425
- byteArray: typeof byteArray
426
- format: typeof format
427
- cairo: typeof cairo
416
+ gi: GjsGiImports;
417
+ lang: typeof lang;
418
+ system: typeof system;
419
+ signals: typeof signals;
420
+ package: typeof package;
421
+ mainloop: typeof mainloop;
422
+ searchPath: string[];
423
+ gettext: typeof gettext;
424
+ byteArray: typeof byteArray;
425
+ format: typeof format;
426
+ cairo: typeof cairo;
428
427
  }
429
428
 
430
- function print(...args: any[]): void
431
- function printerr(...args: any[]): void
432
- function log(message: any): void
433
- function logError(exception: object, message?: any): void
434
- function logError(message?: any): void
429
+ function print(...args: any[]): void;
430
+ function printerr(...args: any[]): void;
431
+ function log(message: any): void;
432
+ function logError(exception: object, message?: any): void;
433
+ function logError(message?: any): void;
435
434
 
436
- const pkg: typeof package
435
+ const pkg: typeof package;
437
436
 
438
437
  interface BooleanConstructor {
439
- $gtype: GObject.GType<boolean>
438
+ $gtype: GObject.GType<boolean>;
440
439
  }
441
440
 
442
441
  interface NumberConstructor {
443
- $gtype: GObject.GType<number>
442
+ $gtype: GObject.GType<number>;
444
443
  }
445
444
 
446
445
  interface StringConstructor {
447
- $gtype: GObject.GType<string>
446
+ $gtype: GObject.GType<string>;
448
447
  }
449
448
 
450
- const imports: GjsImports
449
+ const imports: GjsImports;
451
450
 
452
- const ARGV: string[]
451
+ const ARGV: string[];
453
452
  }
454
453
 
455
- declare const _imports: GjsImports
456
- export default _imports
457
- export { _imports as imports }
458
-
459
-
454
+ declare const _imports: GjsImports;
455
+ export default _imports;
456
+ export { _imports as imports };
package/index.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Type Definitions for Gjs (https://gjs.guide/)
3
+ *
4
+ * These type definitions are automatically generated, do not edit them by hand.
5
+ * If you found a bug fix it in `ts-for-gir` or create a bug report on https://github.com/gjsify/ts-for-gir
6
+ *
7
+ * This template is used to generate the index.d.ts file of each GIR module like Gtk-4.0, GObject-2.0, ...
8
+ */
9
+
10
+ import './gjs-ambient.d.ts';
11
+
12
+ import gjs from './gjs.js';
13
+ export default gjs;
package/index.js ADDED
@@ -0,0 +1,5 @@
1
+
2
+ // @ts-expect-error
3
+ import gjs from './gjs.js';
4
+ export default gjs;
5
+
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@girs/gjs",
3
- "version": "4.0.0-beta.5",
3
+ "version": "4.0.0-beta.7",
4
4
  "description": "GJS TypeScript type definitions for Gjs",
5
5
  "type": "module",
6
6
  "module": "gjs.js",
7
7
  "main": "gjs.js",
8
8
  "exports": {
9
9
  "./ambient": {
10
- "types": "./ambient.d.ts",
11
- "import": "./ambient.js",
12
- "default": "./ambient.js"
10
+ "types": "./gjs-ambient.d.ts",
11
+ "import": "./gjs-ambient.js",
12
+ "default": "./gjs-ambient.js"
13
13
  },
14
14
  "./dom": {
15
15
  "types": "./dom.d.ts",
@@ -31,19 +31,24 @@
31
31
  "import": "./cairo.js",
32
32
  "default": "./cairo.js"
33
33
  },
34
- ".": {
34
+ "./gjs": {
35
35
  "types": "./gjs.d.ts",
36
36
  "import": "./gjs.js",
37
37
  "default": "./gjs.js"
38
+ },
39
+ ".": {
40
+ "types": "./index.d.ts",
41
+ "import": "./index.js",
42
+ "default": "./index.js"
38
43
  }
39
44
  },
40
45
  "scripts": {
41
- "test": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit gjs.d.ts"
46
+ "test": "tsc --project tsconfig.json"
42
47
  },
43
48
  "dependencies": {
44
- "@girs/gio-2.0": "^2.80.0-4.0.0-beta.5",
45
- "@girs/glib-2.0": "^2.80.0-4.0.0-beta.5",
46
- "@girs/gobject-2.0": "^2.80.0-4.0.0-beta.5"
49
+ "@girs/gio-2.0": "^2.80.2-4.0.0-beta.7",
50
+ "@girs/glib-2.0": "^2.80.2-4.0.0-beta.7",
51
+ "@girs/gobject-2.0": "^2.80.2-4.0.0-beta.7"
47
52
  },
48
53
  "devDependencies": {
49
54
  "typescript": "*"
package/system.d.ts CHANGED
@@ -7,18 +7,18 @@ import type GObject from '@girs/gobject-2.0';
7
7
  * subsequent command-line arguments. In other words, `ARGV[0]` in GJS is the same as `argv[1]` in C.
8
8
  * @version Gjs 1.68
9
9
  */
10
- export const programInvocationName: string
10
+ export const programInvocationName: string;
11
11
 
12
12
  /**
13
13
  * This property contains version information about GJS.
14
14
  */
15
- export const version: number
15
+ export const version: number;
16
16
 
17
17
  /**
18
18
  * The full path of the executed program.
19
19
  * @version Gjs 1.68
20
20
  */
21
- export const programPath: string | null
21
+ export const programPath: string | null;
22
22
 
23
23
  /**
24
24
  * A list of arguments passed to the current process.
@@ -26,7 +26,7 @@ export const programPath: string | null
26
26
  * it is not equivalent to the platform'`s` argv.
27
27
  * @version Gjs 1.68
28
28
  */
29
- export const programArgs: string[]
29
+ export const programArgs: string[];
30
30
 
31
31
  /**
32
32
  * Return the memory address of any object as a string.
@@ -39,7 +39,7 @@ export const programArgs: string[]
39
39
  * @param o Any Object
40
40
  * @returns A hexadecimal string (e.g. `0xb4f170f0`)
41
41
  */
42
- export function addressOf(o: any): string
42
+ export function addressOf(o: any): string;
43
43
 
44
44
  /**
45
45
  * Return the memory address of any GObject as a string.
@@ -48,7 +48,7 @@ export function addressOf(o: any): string
48
48
  * @returns A hexadecimal string (e.g. `0xb4f170f0`)
49
49
  * @version Gjs 1.58
50
50
  */
51
- export function addressOfGObject(o: GObject.Object): string
51
+ export function addressOfGObject(o: GObject.Object): string;
52
52
 
53
53
  /**
54
54
  * Inserts a breakpoint instruction into the code.
@@ -81,30 +81,30 @@ export function addressOfGObject(o: GObject.Object): string
81
81
  * breakpoint, so make sure to remove any calls to `System.breakpoint()` when
82
82
  * you're done debugging.
83
83
  */
84
- export function breakpoint(): void
84
+ export function breakpoint(): void;
85
85
 
86
86
  /**
87
87
  * Clears the timezone cache.
88
88
  * This is a workaround for SpiderMonkey Bug [#1004706](https://bugzilla.mozilla.org/show_bug.cgi?id=1004706).
89
89
  */
90
- export function clearDateCaches(): void
90
+ export function clearDateCaches(): void;
91
91
 
92
92
  /** Runs the garbage collector */
93
- export function gc(): void
93
+ export function gc(): void;
94
94
 
95
95
  /**
96
96
  * Return the reference count of any GObject-derived type. When an object's
97
97
  * reference count is zero, it is cleaned up and erased from memory.
98
98
  * @param o A {@link GObject.Object}
99
99
  */
100
- export function refcount(o: GObject.Object): number
100
+ export function refcount(o: GObject.Object): number;
101
101
  /**
102
102
  * See also: The [heapgraph](https://gitlab.gnome.org/GNOME/gjs/blob/HEAD/tools/heapgraph.md) utility in the GJS repository.
103
103
  * Dump a representation of internal heap memory. If `path` is not given, GJS will
104
104
  * write the contents to `stdout`.
105
105
  * @param path Optional file path
106
106
  */
107
- export function dumpHeap(path?: string): void
107
+ export function dumpHeap(path?: string): void;
108
108
 
109
109
  /**
110
110
  * Dump internal garbage collector statistics. If `path` is not given, GJS will
@@ -132,44 +132,43 @@ export function dumpHeap(path?: string): void
132
132
  * }
133
133
  * }
134
134
  * ```
135
- *
135
+ *
136
136
  */
137
- export function dumpMemoryInfo(path?: string): void
137
+ export function dumpMemoryInfo(path?: string): void;
138
138
 
139
139
  /**
140
140
  * This works the same as C's exit() function; exits the program, passing a
141
141
  * certain error code to the shell. The shell expects the error code to be zero if
142
142
  * there was no error, or non-zero (any value you please) to indicate an error.
143
- *
143
+ *
144
144
  * This value is used by other tools such as `make`; if `make` calls a program that
145
145
  * returns a non-zero error code, then `make` aborts the build.
146
146
  * @param code An exit code
147
147
  */
148
- export function exit(code: number): void
148
+ export function exit(code: number): void;
149
149
 
150
150
  /**
151
151
  * The System module provides common low-level facilities such as access to
152
152
  * process arguments and exit(), as well as a number of useful functions and
153
153
  * properties for debugging.
154
- *
154
+ *
155
155
  * Note that the majority of the functions and properties in this module should not
156
156
  * be used in normal operation of a GJS application.
157
157
  */
158
158
  declare const System: {
159
- programInvocationName: typeof programInvocationName,
160
- version: typeof version,
161
- programPath: typeof programPath,
162
- programArgs: typeof programArgs,
163
- addressOf: typeof addressOf,
164
- addressOfGObject: typeof addressOfGObject,
165
- breakpoint: typeof breakpoint,
166
- clearDateCaches: typeof clearDateCaches,
167
- gc: typeof gc,
168
- refcount: typeof refcount,
169
- dumpHeap: typeof dumpHeap,
170
- dumpMemoryInfo: typeof dumpMemoryInfo,
171
- exit: typeof exit,
172
- }
173
-
174
- export default System
159
+ programInvocationName: typeof programInvocationName;
160
+ version: typeof version;
161
+ programPath: typeof programPath;
162
+ programArgs: typeof programArgs;
163
+ addressOf: typeof addressOf;
164
+ addressOfGObject: typeof addressOfGObject;
165
+ breakpoint: typeof breakpoint;
166
+ clearDateCaches: typeof clearDateCaches;
167
+ gc: typeof gc;
168
+ refcount: typeof refcount;
169
+ dumpHeap: typeof dumpHeap;
170
+ dumpMemoryInfo: typeof dumpMemoryInfo;
171
+ exit: typeof exit;
172
+ };
175
173
 
174
+ export default System;
package/tsconfig.json CHANGED
@@ -2,11 +2,11 @@
2
2
  "compilerOptions": {
3
3
  // General settings for code interpretation
4
4
  "target": "ESNext",
5
- "module": "ESNext",
5
+ "module": "NodeNext",
6
6
  "lib": ["ESNext"],
7
7
  "types": [],
8
8
  "experimentalDecorators": true,
9
- "moduleResolution": "node",
9
+ "moduleResolution": "NodeNext",
10
10
  "noEmit": true,
11
11
  "noEmitOnError": false,
12
12
  "baseUrl": "./",
package/ambient.d.ts DELETED
@@ -1,20 +0,0 @@
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
-
4
- declare module 'gettext' {
5
- export * from '@girs/gjs/gettext';
6
- import Gettext from '@girs/gjs/gettext';
7
- export default Gettext;
8
- }
9
-
10
- declare module 'system' {
11
- export * from '@girs/gjs/system';
12
- import System from '@girs/gjs/system';
13
- export default System;
14
- }
15
-
16
- declare module 'cairo' {
17
- import Cairo from '@girs/gjs/cairo';
18
- export default Cairo;
19
- }
20
-
File without changes