@ts-for-gir/templates 4.0.0-beta.44 → 4.0.0-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-for-gir/templates",
3
- "version": "4.0.0-beta.44",
3
+ "version": "4.0.0-rc.10",
4
4
  "description": "Templates for ts-for-gir",
5
5
  "type": "module",
6
6
  "main": "package.json",
@@ -31,7 +31,7 @@
31
31
  * ```
32
32
  *
33
33
  */
34
- export function _promisify(proto: any, asyncFunc: string, finishFunc?: string): void
34
+ export function _promisify(proto: any, asyncFunc: string, finishFunc?: string): void;
35
35
 
36
36
  /** Temporary Gio.File.prototype fix */
37
- export const _LocalFilePrototype: typeof File.prototype
37
+ export const _LocalFilePrototype: typeof File.prototype;
@@ -64,9 +64,9 @@ import Cairo from '<%- Cairo.importPath %>';
64
64
  /** Recommended vertical distance between baselines for consecutive lines */
65
65
  height: number;
66
66
  /** Maximum X advance for any glyph */
67
- max_x_advance: number;
67
+ maxXAdvance: number;
68
68
  /** Maximum Y advance for any glyph (typically 0 for horizontal text) */
69
- max_y_advance: number;
69
+ maxYAdvance: number;
70
70
  }
71
71
 
72
72
  /**
@@ -533,6 +533,13 @@ import Cairo from '<%- Cairo.importPath %>';
533
533
  */
534
534
  showText(utf8: string): void;
535
535
 
536
+ /**
537
+ * Adds the text outline to the current path (cairo_text_path).
538
+ * After this call the context will have a current point.
539
+ * @param utf8 A string of text encoded in UTF-8
540
+ */
541
+ textPath(utf8: string): void;
542
+
536
543
  /**
537
544
  * Strokes the current path using the current line width, line join,
538
545
  * line cap, and dash settings, then clears the path
@@ -561,7 +568,7 @@ import Cairo from '<%- Cairo.importPath %>';
561
568
  * Gets the font extents for the currently selected font
562
569
  * @returns Font extents in user-space coordinates
563
570
  */
564
- getFontExtents(): FontExtents;
571
+ fontExtents(): FontExtents;
565
572
 
566
573
  /**
567
574
  * Renders an array of glyphs at the current point (low-level text API)
@@ -40,7 +40,7 @@ export interface MetaInfo<Props, Interfaces, Sigs> {
40
40
 
41
41
  export type Property<K extends ParamSpec> = K extends ParamSpec<infer T> ? T : any
42
42
 
43
- <% if (!noAdvancedVariants) { %>
43
+ <%_ if (!noAdvancedVariants) { _%>
44
44
  // Advanced type inference for GObject class registration
45
45
  // String conversion utilities for property names
46
46
  type SnakeToUnderscoreCase<S extends string> = S extends `${infer T}-${infer U}`
@@ -111,7 +111,7 @@ export type SignalDefinitionType = {
111
111
  param_types?: readonly GTypeInput[]
112
112
  [key: string]: any
113
113
  }
114
- <% } %>
114
+ <%_ } _%>
115
115
 
116
116
  // Correctly types interface checks.
117
117
  export function type_is_a<T extends Object>(obj: Object, is_a_type: { $gtype: GType<T> }): obj is T
@@ -336,7 +336,7 @@ export function registerClass<
336
336
  },
337
337
  >(options: MetaInfo<Props, Interfaces, Sigs>, cls: T): T
338
338
 
339
- <% if (!noAdvancedVariants) { %>
339
+ <%_ if (!noAdvancedVariants) { _%>
340
340
  // Enhanced registerClass overloads with advanced type inference
341
341
 
342
342
  export function registerClass<P extends {}, T extends new (...args: any[]) => P>(
@@ -367,4 +367,4 @@ export function registerClass<
367
367
  },
368
368
  klass: T,
369
369
  ): RegisteredClass<T, Props, Interfaces>
370
- <% } %>
370
+ <%_ } _%>
@@ -2,5 +2,5 @@
2
2
  // Workaround
3
3
  /** @ignore */
4
4
  export module BaseSink {
5
- export type ConstructorProps = Gst.BaseSink.ConstructorProps
5
+ export type ConstructorProps = Gst.BaseSink.ConstructorProps;
6
6
  }
@@ -0,0 +1,44 @@
1
+ // @ts-nocheck
2
+
3
+ /**
4
+ * GJS replaces `Gtk.Builder` with a JS subclass (`GtkJSBuilder`) whose constructor
5
+ * accepts five additional, JS-only properties on top of the GIR-derived ones:
6
+ * `data`, `filename`, `resource`, `callbacks`, and `objects`. They are consumed at
7
+ * construction time (used to call `add_from_string` / `add_from_file` /
8
+ * `add_from_resource`, set up a callback scope, and register named objects), so
9
+ * they appear only in the constructor signature, not as instance accessors.
10
+ *
11
+ * @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/modules/core/overrides/Gtk.js
12
+ * @example
13
+ * ```ts
14
+ * const builder = new Gtk.Builder({
15
+ * filename: "window.ui",
16
+ * callbacks: { on_clicked: () => print("clicked") },
17
+ * objects: { existing: someExistingWidget },
18
+ * });
19
+ * ```
20
+ */
21
+ export namespace Builder {
22
+ interface ConstructorProps {
23
+ /** Inline XML interface description. Calls `add_from_string` on construction. */
24
+ data?: string | Uint8Array;
25
+ /** Path to a UI file. Calls `add_from_file` on construction. */
26
+ filename?: string;
27
+ /** Resource path to a UI file. Calls `add_from_resource` on construction. */
28
+ resource?: string;
29
+ /** Named signal callbacks resolved against `<signal>` `handler` attributes. */
30
+ callbacks?: Record<string, (...args: any[]) => any>;
31
+ /** Pre-existing objects exposed to the UI via {@link Builder.exposeObjects}. */
32
+ objects?: Record<string, GObject.Object>;
33
+ }
34
+ }
35
+
36
+ /**
37
+ * GJS-only convenience method on {@link Builder}: registers every entry of
38
+ * `objects` so the UI XML can reference them by name.
39
+ *
40
+ * @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/modules/core/overrides/Gtk.js
41
+ */
42
+ export interface Builder {
43
+ exposeObjects(objects: Record<string, GObject.Object>): void;
44
+ }
@@ -1,17 +1,17 @@
1
- <%_ if(!noNamespace){ -%>
2
- }
1
+ <%_ if (!noNamespace) { _%>
2
+ }
3
3
 
4
- export default <%- girModule.namespace %>;
5
- <%_ } -%>
4
+ export default <%- girModule.namespace %>;
5
+ <%_ } _%>
6
6
 
7
- <%_ if(!package){ -%>
8
- }
7
+ <%_ if (!package) { _%>
8
+ }
9
9
 
10
- <%_ if(!onlyVersionPrefix){ -%>
11
- declare module 'gi://<%- girModule.namespace %>' {
12
- import <%- girModule.importNamespace %> from 'gi://<%- girModule.namespace %>?version=<%- girModule.version %>';
13
- export default <%- girModule.importNamespace %>;
14
- }
15
- <% } -%>
16
- <%_ } -%>
17
- // END
10
+ <%_ if (!onlyVersionPrefix) { _%>
11
+ declare module 'gi://<%- girModule.namespace %>' {
12
+ import <%- girModule.importNamespace %> from 'gi://<%- girModule.namespace %>?version=<%- girModule.version %>';
13
+ export default <%- girModule.importNamespace %>;
14
+ }
15
+ <%_ } _%>
16
+ <%_ } _%>
17
+ // END
@@ -1,53 +1,53 @@
1
- <%_ if(!package){ -%>
2
- <%_ girModule.transitiveDependencies.forEach(dependency => { -%>
3
- <%_ if (girModule.packageName !== dependency.packageName) { -%>
4
- <%_ if (dependency.exists) { -%>
5
- /// <reference path="./<%- dependency.importName %>.d.ts" />
6
- <%_ if (dependency.packageName === 'cairo-1.0') { -%>
7
- /// <reference path="./cairo.d.ts" />
8
- <%_ } -%>
9
- <%_ } -%>
10
- <%_ } -%>
11
- <%_ }) -%>
12
- <% } -%>
1
+ <%_ if (!package && !externalDeps) { _%>
2
+ <%_ girModule.transitiveDependencies.forEach(dependency => { _%>
3
+ <%_ if (girModule.packageName !== dependency.packageName) { _%>
4
+ <%_ if (dependency.exists) { _%>
5
+ /// <reference path="./<%- dependency.importName %>.d.ts" />
6
+ <%_ if (dependency.packageName === 'cairo-1.0') { _%>
7
+ /// <reference path="./cairo.d.ts" />
8
+ <%_ } _%>
9
+ <%_ } _%>
10
+ <%_ } _%>
11
+ <%_ }) _%>
12
+ <%_ } _%>
13
13
 
14
14
  /**
15
15
  * Type Definitions for Gjs (https://gjs.guide/)
16
16
  *
17
17
  * These type definitions are automatically generated, do not edit them by hand.
18
18
  * If you found a bug fix it in `<%- APP_NAME %>` or create a bug report on <%- APP_SOURCE %>
19
- *
19
+ *
20
20
  * The based EJS template file is used for the generated .d.ts file of each GIR module like Gtk-4.0, GObject-2.0, ...
21
21
  */
22
22
 
23
- <%_ if(!package){ -%>
24
- declare module 'gi://<%- girModule.namespace %>?version=<%- girModule.version %>' {
25
- <% } -%>
23
+ <%_ if (!package) { _%>
24
+ declare module 'gi://<%- girModule.namespace %>?version=<%- girModule.version %>' {
26
25
 
27
- <%_ if(package){ -%>
28
- <%_ const Gjs = await dep.getGjs() -%>
29
- import '<%- Gjs.importPath %>';
30
- <% } -%>
26
+ <%_ } _%>
27
+ <%_ if (package) { _%>
28
+ <%_ const Gjs = await dep.getGjs() _%>
29
+ import '<%- Gjs.importPath %>';
31
30
 
31
+ <%_ } _%>
32
32
  // Module dependencies
33
- <%_ girModule.transitiveDependencies.forEach(dependency => { -%>
34
- <%_ if (girModule.packageName !== dependency.packageName) { -%>
35
- <%_ if (dependency.exists) { -%>
36
- <%_ if (girModule.hasSymbol(dependency.namespace)) { -%>
37
- <%_ if (noNamespace) { -%>
38
- import * as <%- dependency.namespace %>__ from '<%- dependency.importPath %>';
39
- <%_ } else { %>
40
- import <%- dependency.namespace %>__ from '<%- dependency.importPath %>';
41
- <%_ } -%>
42
- <%_ } else { -%>
43
- <%- dependency.importDef %>
44
- <%_ } -%>
45
- <%_ } else { -%>
46
- // WARN: Dependency not found: '<%- dependency.packageName %>'
47
- <%_ } -%>
48
- <%_ } -%>
49
- <%_ }) -%>
33
+ <%_ girModule.transitiveDependencies.forEach(dependency => { _%>
34
+ <%_ if (girModule.packageName !== dependency.packageName) { _%>
35
+ <%_ if (dependency.exists || externalDeps) { _%>
36
+ <%_ if (dependency.exists && girModule.hasSymbol(dependency.namespace)) { _%>
37
+ <%_ if (noNamespace) { _%>
38
+ import * as <%- dependency.namespace %>__ from '<%- dependency.importPath %>';
39
+ <%_ } else { _%>
40
+ import <%- dependency.namespace %>__ from '<%- dependency.importPath %>';
41
+ <%_ } _%>
42
+ <%_ } else { _%>
43
+ <%- dependency.importDef %>
44
+ <%_ } _%>
45
+ <%_ } else { _%>
46
+ // WARN: Dependency not found: '<%- dependency.packageName %>'
47
+ <%_ } _%>
48
+ <%_ } _%>
49
+ <%_ }) _%>
50
+ <%_ if (!noNamespace) { _%>
50
51
 
51
- <%_ if(!noNamespace){ -%>
52
- export namespace <%- girModule.namespace %> {
53
- <% } -%>
52
+ export namespace <%- girModule.namespace %> {
53
+ <%_ } _%>
@@ -4,7 +4,6 @@ let entryPointName = importName
4
4
  if (packageName === 'Gjs') {
5
5
  entryPointName = 'gjs'
6
6
  }
7
- let depVersion = workspace ? 'workspace:^' : APP_VERSION
8
7
  _%>
9
8
  {
10
9
  "name": "<%- npmScope %>/<%- importName %>",
@@ -77,7 +76,7 @@ _%>
77
76
  },
78
77
  "dependencies": {
79
78
  <%_ if (packageName !== 'Gjs') { _%>
80
- "<%- npmScope %>/gjs": "<%- depVersion %>"<%_ if(deps.length > 0 ) { _%>,
79
+ <%- dep.createPackageJsonImport(npmScope + '/gjs') %><%_ if(deps.length > 0 ) { _%>,
81
80
  <%_ } _%>
82
81
  <%_ } _%>
83
82
  <%_ for (let i = 0; i < deps.length; i++ ) { _%>