@girs/gjs 4.0.0-beta.37 → 4.0.0-beta.39

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 (3) hide show
  1. package/README.md +1 -1
  2. package/cairo.d.ts +85 -4
  3. package/package.json +5 -5
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.37.
7
+ GJS TypeScript type definitions for Gjs using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v4.0.0-beta.39.
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
@@ -45,6 +45,23 @@ declare namespace giCairo {
45
45
  yAdvance: number;
46
46
  }
47
47
 
48
+ /**
49
+ * Font metrics in user-space coordinates (cairo_font_extents_t).
50
+ * Not present in cairo-gobject GIR; defined locally to match the C API.
51
+ */
52
+ export interface FontExtents {
53
+ /** Distance the font extends above the baseline */
54
+ ascent: number;
55
+ /** Distance the font extends below the baseline (positive for typical fonts) */
56
+ descent: number;
57
+ /** Recommended vertical distance between baselines for consecutive lines */
58
+ height: number;
59
+ /** Maximum X advance for any glyph */
60
+ max_x_advance: number;
61
+ /** Maximum Y advance for any glyph (typically 0 for horizontal text) */
62
+ max_y_advance: number;
63
+ }
64
+
48
65
  /**
49
66
  * The main Cairo drawing context
50
67
  *
@@ -533,6 +550,34 @@ declare namespace giCairo {
533
550
  */
534
551
  textExtents(utf8: string): TextExtents;
535
552
 
553
+ /**
554
+ * Gets the font extents for the currently selected font
555
+ * @returns Font extents in user-space coordinates
556
+ */
557
+ getFontExtents(): FontExtents;
558
+
559
+ /**
560
+ * Renders an array of glyphs at the current point (low-level text API)
561
+ * @param glyphs Array of glyphs to show
562
+ */
563
+ showGlyphs(glyphs: Glyph[]): void;
564
+
565
+ /**
566
+ * Renders glyphs with embedded text and cluster mapping (e.g. for PDF/PS)
567
+ * @param utf8 UTF-8 text string
568
+ * @param glyphs Array of glyphs
569
+ * @param clusters Cluster mapping (bytes to glyphs)
570
+ * @param clusterFlags Direction of cluster mapping
571
+ */
572
+ showTextGlyphs(utf8: string, glyphs: Glyph[], clusters: TextCluster[], clusterFlags: TextClusterFlags): void;
573
+
574
+ /**
575
+ * Computes the extents of an array of glyphs in user-space coordinates
576
+ * @param glyphs Array of glyphs
577
+ * @returns Extents as [x_bearing, y_bearing, width, height, x_advance, y_advance]
578
+ */
579
+ glyphExtents(glyphs: Glyph[]): TextExtents;
580
+
536
581
  /**
537
582
  * Translates the current transformation matrix
538
583
  * @param tx Translation in the X direction
@@ -608,6 +653,21 @@ declare namespace giCairo {
608
653
  * Finishes the surface and drops all references to external resources
609
654
  */
610
655
  finish(): void;
656
+
657
+ /**
658
+ * Attaches user data to the surface (C API: cairo_surface_set_user_data)
659
+ * @param key Key for the user data
660
+ * @param userData Data to attach
661
+ * @param destroy Optional callback when the surface is destroyed or data is replaced
662
+ */
663
+ set_user_data(key: UserDataKey, userData: unknown, destroy?: (data: unknown) => void): Status;
664
+
665
+ /**
666
+ * Returns user data attached to the surface (C API: cairo_surface_get_user_data)
667
+ * @param key Key used when setting the data
668
+ * @returns The attached data or null
669
+ */
670
+ get_user_data(key: UserDataKey): unknown;
611
671
  }
612
672
 
613
673
  /**
@@ -820,14 +880,35 @@ declare namespace giCairo {
820
880
  export class ScaledFont extends Cairo.ScaledFont {}
821
881
 
822
882
  /**
823
- * A glyph object used for storing and manipulating glyphs
883
+ * A glyph object used for storing and manipulating glyphs (cairo_glyph_t).
884
+ * Defined locally so the template works even when the generated cairo-1.0
885
+ * does not include this record (GIR may omit it in some setups).
824
886
  */
825
- export class Glyph extends Cairo.Glyph {}
887
+ export interface Glyph {
888
+ index: number;
889
+ x: number;
890
+ y: number;
891
+ }
826
892
 
827
893
  /**
828
- * A text cluster object used for storing and manipulating text clusters
894
+ * A text cluster object used for storing and manipulating text clusters (cairo_text_cluster_t).
895
+ * Defined locally so the template works even when the generated cairo-1.0
896
+ * does not include this record (GIR may omit it in some setups).
829
897
  */
830
- export class TextCluster extends Cairo.TextCluster {}
898
+ export interface TextCluster {
899
+ num_bytes: number;
900
+ num_glyphs: number;
901
+ }
902
+
903
+ /**
904
+ * Key for attaching user data to surfaces/contexts (cairo_user_data_key_t).
905
+ * In C only the key's address matters; in GJS any object can serve as key.
906
+ * Not in cairo-gobject GIR; defined locally for set_user_data/get_user_data.
907
+ */
908
+ export interface UserDataKey {
909
+ /** Unused in C; present only for ABI. In GJS keys are typically plain objects. */
910
+ readonly unused?: number;
911
+ }
831
912
 
832
913
  /**
833
914
  * A font options object used for storing and manipulating font options
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@girs/gjs",
3
- "version": "4.0.0-beta.37",
3
+ "version": "4.0.0-beta.39",
4
4
  "description": "GJS TypeScript type definitions for Gjs",
5
5
  "type": "module",
6
6
  "module": "gjs.js",
@@ -51,10 +51,10 @@
51
51
  "test": "tsc --project tsconfig.json"
52
52
  },
53
53
  "dependencies": {
54
- "@girs/gobject-2.0": "2.86.0-4.0.0-beta.37",
55
- "@girs/glib-2.0": "2.86.0-4.0.0-beta.37",
56
- "@girs/gio-2.0": "2.86.0-4.0.0-beta.37",
57
- "@girs/cairo-1.0": "1.0.0-4.0.0-beta.37" },
54
+ "@girs/gobject-2.0": "2.86.4-4.0.0-beta.39",
55
+ "@girs/glib-2.0": "2.86.4-4.0.0-beta.39",
56
+ "@girs/gio-2.0": "2.86.4-4.0.0-beta.39",
57
+ "@girs/cairo-1.0": "1.0.0-4.0.0-beta.39" },
58
58
  "devDependencies": {
59
59
  "typescript": "*"
60
60
  },