@ts-for-gir/templates 4.0.0-beta.40 → 4.0.0-beta.42

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-for-gir/templates",
3
- "version": "4.0.0-beta.40",
3
+ "version": "4.0.0-beta.42",
4
4
  "description": "Templates for ts-for-gir",
5
5
  "type": "module",
6
6
  "main": "package.json",
@@ -13,7 +13,7 @@
13
13
  * @param asyncFunc - The name of the asynchronous function.
14
14
  * @param finishFunc - The name of the "finish" function that is used to retrieve the result of the asynchronous function.
15
15
  *
16
- * @version Gjs 1.54
16
+ * @since 1.54
17
17
  * @see https://gjs.guide/guides/gjs/asynchronous-programming.html#promisify-helper
18
18
  *
19
19
  * @example
@@ -34,7 +34,7 @@ declare global {
34
34
  // See https://gitlab.gnome.org/GNOME/gjs/-/blob/master/modules/esm/_timers.js
35
35
 
36
36
  /**
37
- * @version Gjs 1.71.1
37
+ * @since 1.71.1
38
38
  * @param callback a callback function
39
39
  * @param delay the duration in milliseconds to wait before running callback
40
40
  * @param args arguments to pass to callback
@@ -42,7 +42,7 @@ declare global {
42
42
  function setTimeout(callback: (...args: any[]) => any, delay?: number, ...args: any[]): GLib.Source
43
43
 
44
44
  /**
45
- * @version Gjs 1.71.1
45
+ * @since 1.71.1
46
46
  * @param callback a callback function
47
47
  * @param delay the duration in milliseconds to wait between calling callback
48
48
  * @param args arguments to pass to callback
@@ -50,13 +50,13 @@ declare global {
50
50
  function setInterval(callback: (...args: any[]) => any, delay?: number, ...args: any[]): GLib.Source
51
51
 
52
52
  /**
53
- * @version Gjs 1.71.1
53
+ * @since 1.71.1
54
54
  * @param timeout the timeout to clear
55
55
  */
56
56
  function clearTimeout(timeout: GLib.Source): void
57
57
 
58
58
  /**
59
- * @version Gjs 1.71.1
59
+ * @since 1.71.1
60
60
  * @param timeout the timeout to clear
61
61
  */
62
62
  function clearInterval(timeout: GLib.Source): void
@@ -244,7 +244,7 @@ declare global {
244
244
  * The TextDecoder interface represents a decoder for a specific text encoding.
245
245
  * It takes a stream of bytes as input and emits a stream of code points.
246
246
  *
247
- * @version Gjs 1.69.2
247
+ * @since 1.69.2
248
248
  */
249
249
  interface TextDecoder {
250
250
  /** A string containing the name of the decoder, that is a string describing the method the TextDecoder will use. */
@@ -273,7 +273,7 @@ declare global {
273
273
  /**
274
274
  * TextEncoder takes a stream of code points as input and emits a stream of bytes.
275
275
  *
276
- * @version Gjs 1.69.2
276
+ * @since 1.69.2
277
277
  */
278
278
  interface TextEncoder {
279
279
  readonly encoding: 'utf-8'
@@ -0,0 +1,36 @@
1
+ <%_ if(!package){ -%>
2
+ declare module 'gi' {
3
+ <% } -%>
4
+
5
+ /**
6
+ * Requires a GObject Introspection namespace, optionally at a specific version.
7
+ * If a version is specified and a different version of the same namespace is
8
+ * already loaded, an error will be thrown.
9
+ *
10
+ * @param namespace The GI namespace to import (e.g. 'Gtk', 'GLib')
11
+ * @param version The version of the namespace (e.g. '4.0', '2.0')
12
+ * @returns The imported namespace module
13
+ */
14
+ export function require(namespace: string, version?: string): any
15
+
16
+ /**
17
+ * The `gi` module provides a single entry point for importing GObject
18
+ * Introspection namespaces in GJS ESM modules.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import Gi from 'gi';
23
+ * Gi.require('Gtk', '4.0');
24
+ * ```
25
+ *
26
+ * @see https://gjs-docs.gnome.org/gjs/overrides.md#gi-require
27
+ */
28
+ <%- package ? 'declare' : '' %> const Gi: {
29
+ readonly require: typeof require;
30
+ }
31
+
32
+ export default Gi
33
+
34
+ <%_ if(!package){ -%>
35
+ }
36
+ <% } -%>
@@ -0,0 +1,4 @@
1
+ import Gi, { require } from 'gi';
2
+
3
+ export { require };
4
+ export default Gi;
@@ -24,3 +24,9 @@ declare module 'console' {
24
24
  export { setConsoleLogDomain, getConsoleLogDomain, DEFAULT_LOG_DOMAIN }
25
25
  export default Console
26
26
  }
27
+
28
+ declare module 'gi' {
29
+ import Gi, { require } from '@girs/gjs/gi'
30
+ export { require }
31
+ export default Gi
32
+ }
@@ -10,6 +10,7 @@
10
10
  /// <reference path="./gettext.d.ts" />
11
11
  /// <reference path="./system.d.ts" />
12
12
  /// <reference path="./cairo.d.ts" />
13
+ /// <reference path="./gi.d.ts" />
13
14
  <% } -%>
14
15
 
15
16
  /**
@@ -718,34 +719,50 @@ declare global {
718
719
  /**
719
720
  * Formats a string with the given arguments.
720
721
  * This method is made available by calling `pkg.initFormat()`.
721
- *
722
+ *
722
723
  * Supported format specifiers:
723
724
  * - %s: Formats as a string
724
725
  * - %d: Formats as an integer
725
726
  * - %x: Formats as a hexadecimal number
726
727
  * - %f: Formats as a floating point number, optionally with precision (e.g. %.2f)
727
- *
728
+ *
728
729
  * All specifiers can be prefixed with a minimum field width, e.g. "%5s" will pad with spaces.
729
730
  * If the width is prefixed with '0', it will pad with zeroes instead of spaces.
730
- *
731
+ *
731
732
  * @example
732
733
  * ```ts
733
734
  * // After calling pkg.initFormat()
734
735
  * "Hello %s, you have %d items".format("User", 5);
735
736
  * // Returns: "Hello User, you have 5 items"
736
- *
737
+ *
737
738
  * "Price: $%.2f".format(10.5);
738
739
  * // Returns: "Price: $10.50"
739
- *
740
+ *
740
741
  * "ID: %05d".format(42);
741
742
  * // Returns: "ID: 00042"
742
743
  * ```
743
- *
744
+ *
744
745
  * @param args The arguments to format the string with
745
746
  * @returns The formatted string
746
747
  */
747
748
  format(...args: (string | number | boolean | null | undefined)[]): string;
748
749
  }
750
+
751
+ interface Error {
752
+ /**
753
+ * Checks if this error matches a GLib error domain and code.
754
+ *
755
+ * Added to the global `Error` prototype by the GLib override so that
756
+ * `e.matches(Ns.FooError, Ns.FooError.SOME_CODE)` works without an
757
+ * `instanceof` check. Always returns `false` for standard JavaScript
758
+ * errors; only `GLib.Error` instances provide a meaningful implementation.
759
+ *
760
+ * @param domain A GLib error domain (error class constructor or quark)
761
+ * @param code The error code to match against
762
+ * @returns `false` for native JS errors, `true` if a GLib.Error matches
763
+ */
764
+ matches(domain: unknown, code: number): boolean;
765
+ }
749
766
  }
750
767
 
751
768
  declare const _imports: GjsImports
@@ -14,7 +14,7 @@ declare module 'system' {
14
14
  * line. In C and other languages, this information is contained in the first element of
15
15
  * the platform's equivalent of argv, but GJS's ARGV only contains the
16
16
  * subsequent command-line arguments. In other words, `ARGV[0]` in GJS is the same as `argv[1]` in C.
17
- * @version Gjs 1.68
17
+ * @since 1.68
18
18
  */
19
19
  export const programInvocationName: string
20
20
 
@@ -25,7 +25,7 @@ export const version: number
25
25
 
26
26
  /**
27
27
  * The full path of the executed program.
28
- * @version Gjs 1.68
28
+ * @since 1.68
29
29
  */
30
30
  export const programPath: string | null
31
31
 
@@ -33,7 +33,7 @@ export const programPath: string | null
33
33
  * A list of arguments passed to the current process.
34
34
  * This is effectively an alias for the global `ARGV`, which is misleading in that
35
35
  * it is not equivalent to the platform'`s` argv.
36
- * @version Gjs 1.68
36
+ * @since 1.68
37
37
  */
38
38
  export const programArgs: string[]
39
39
 
@@ -55,7 +55,7 @@ export function addressOf(o: object): string
55
55
  * See also {@link addressOf}
56
56
  * @param o Any {@link GObject.Object}-derived instance
57
57
  * @returns A hexadecimal string (e.g. `0xb4f170f0`)
58
- * @version Gjs 1.58
58
+ * @since 1.58
59
59
  */
60
60
  export function addressOfGObject(o: GObject.Object): string
61
61
 
@@ -119,7 +119,7 @@ export function dumpHeap(path?: string): void
119
119
  * Dump internal garbage collector statistics. If `path` is not given, GJS will
120
120
  * write the contents to `stdout`.
121
121
  * @param path Optional file path
122
- * @version Gjs 1.70
122
+ * @since 1.70
123
123
  * @example Output:
124
124
  * ```json
125
125
  * {
@@ -989,7 +989,7 @@ export class Variant<S extends string = any> {
989
989
  * @returns The recursively unpacked JavaScript value with all Variants converted to native types
990
990
  * @see {@link deepUnpack} for one-level unpacking with type preservation
991
991
  * @see {@link unpack} for shallow unpacking only
992
- * @since GJS 1.64 (GNOME 3.36)
992
+ * @since 1.64
993
993
  */
994
994
  recursiveUnpack(): $ParseRecursiveVariant<S>;
995
995
  recursiveUnpack<T>(): T;
@@ -49,6 +49,11 @@ _%>
49
49
  "import": "./console.js",
50
50
  "default": "./console.js"
51
51
  },
52
+ "./gi": {
53
+ "types": "./gi.d.ts",
54
+ "import": "./gi.js",
55
+ "default": "./gi.js"
56
+ },
52
57
  <%_ } else {_%>
53
58
  "./import": {
54
59
  "types": "./<%- entryPointName %>-import.d.ts",
@@ -3,9 +3,31 @@ let includes = []
3
3
  let entryPointName = importName
4
4
  if (packageName === 'Gjs') {
5
5
  entryPointName = 'gjs'
6
- includes.push(`./dom.d.ts`)
6
+ includes.push('./dom.d.ts')
7
+ includes.push('./cairo.d.ts')
8
+ includes.push('./gettext.d.ts')
9
+ includes.push('./system.d.ts')
10
+ includes.push('./console.d.ts')
11
+ includes.push('./gjs-ambient.d.ts')
7
12
  }
8
13
  includes.push(`./${entryPointName}.d.ts`)
14
+
15
+ // Build paths mappings for cross-package type resolution (needed for TypeDoc inheritance)
16
+ let paths = {}
17
+ if (typeof girModule !== 'undefined' && girModule && girModule.transitiveDependencies) {
18
+ girModule.transitiveDependencies.forEach(dependency => {
19
+ if (girModule.packageName !== dependency.packageName && dependency.exists) {
20
+ paths[dependency.importPath] = [`../${dependency.importName}/index.d.ts`]
21
+ }
22
+ })
23
+ }
24
+ if (packageName !== 'Gjs' && typeof dep !== 'undefined' && dep) {
25
+ const Gjs = await dep.getGjs()
26
+ if (Gjs && Gjs.importPath) {
27
+ paths[Gjs.importPath] = [`../gjs/index.d.ts`]
28
+ }
29
+ }
30
+ const hasPaths = Object.keys(paths).length > 0
9
31
  _%>
10
32
  {
11
33
  "compilerOptions": {
@@ -26,7 +48,9 @@ _%>
26
48
  "inlineSources": false,
27
49
  "newLine": "LF",
28
50
  // Show diagnostics
29
- "diagnostics": true
51
+ "diagnostics": true<%_ if (hasPaths) { _%>,
52
+ "paths": <%- JSON.stringify(paths, null, 6) %>
53
+ <%_ } _%>
30
54
  },
31
55
  "include": <%- JSON.stringify(includes) %>
32
56
  }
@@ -7,11 +7,11 @@ if (packageName === 'Gjs') {
7
7
  let entryPoints = [`./${entryPointName}.d.ts`]
8
8
 
9
9
  if (packageName === 'Gjs') {
10
- // entryPoints.push(`./ambient.d.ts`)
11
- // entryPoints.push(`./cairo.d.ts`)
12
- // entryPoints.push(`./gettext.d.ts`)
13
- // entryPoints.push(`./system.d.ts`)
14
- // entryPoints.push('./dom.d.ts')
10
+ entryPoints.push('./cairo.d.ts')
11
+ entryPoints.push('./gettext.d.ts')
12
+ entryPoints.push('./system.d.ts')
13
+ entryPoints.push('./dom.d.ts')
14
+ entryPoints.push('./console.d.ts')
15
15
  } else {
16
16
  // entryPoints.push(`./${entryPointName}-ambient.d.ts`)
17
17
  // entryPoints.push(`./${entryPointName}-import.d.ts`)
@@ -22,5 +22,7 @@ _%>
22
22
  "entryPoints": <%- JSON.stringify(entryPoints) %>,
23
23
  "readme": "./README.md",
24
24
  "name": "<%- packageName %>",
25
- "tsconfig": "./tsconfig.json"
25
+ "tsconfig": "./tsconfig.json",
26
+ "skipErrorChecking": true,
27
+ "highlightLanguages": ["typescript", "javascript", "c", "cpp", "xml", "bash", "json", "css"]
26
28
  }