@girs/gjs 3.0.0-beta.16 → 3.0.1

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 (2) hide show
  1. package/README.md +42 -5
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
 
2
2
  # Gjs
3
3
 
4
- GJS TypeScript type definitions for Gjs using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v3.0.0-beta.16.
4
+ GJS TypeScript type definitions for Gjs using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v3.0.1.
5
+
6
+ [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.
5
7
 
6
8
  ## Install
7
9
 
@@ -10,6 +12,7 @@ To use this type definitions, install them with NPM:
10
12
  npm install @girs/gjs
11
13
  ```
12
14
 
15
+
13
16
  ## Usage
14
17
 
15
18
  You can import this package into your project like this:
@@ -22,9 +25,25 @@ Or if you prefer CommonJS, you can also use this:
22
25
  const Gjs = require('@girs/gjs');
23
26
  ```
24
27
 
28
+ ### Global types
29
+
30
+ After the import, the global types of GJS are also available:
31
+
32
+ ```ts
33
+ console.log('Hello World from console');
34
+ print('Hello World from print');
35
+
36
+ const ByteArray = imports.byteArray;
37
+
38
+ const encoder = new TextEncoder();
39
+ const encoded = encoder.encode('𝓽𝓮𝔁𝓽');
40
+
41
+ // And so on...
42
+ ```
43
+
25
44
  ### Ambient Modules
26
45
 
27
- You can import core [ambient module](https://github.com/gjsify/ts-for-gir/tree/main/packages/cli#ambient-modules) types.
46
+ You can import the built in [ambient modules](https://github.com/gjsify/ts-for-gir/tree/main/packages/cli#ambient-modules) of GJS.
28
47
  For this you need to include the `@girs/gjs` or `@girs/gjs/ambient` in your `tsconfig` or entry point Typescript file:
29
48
 
30
49
  `index.ts`:
@@ -42,18 +61,36 @@ import '@girs/gjs'
42
61
  ...
43
62
  }
44
63
  ```
45
-
46
64
 
47
- Now you can import `gettext` and `system` in ESM style with Typescript support:
65
+ Now you can import `gettext`, `system` and `cairo` in ESM style with Typescript support:
48
66
 
49
67
  ```ts
50
68
  import gettext from 'gettext';
51
69
  import system from 'system';
70
+ import cairo from 'cairo';
52
71
  ```
53
72
 
73
+ ### GIR modules
74
+
75
+ 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. [gtk-4.0](https://www.npmjs.com/package/@girs/gtk-4.0), [gio-2.0](https://www.npmjs.com/package/@girs/gio-2.0), [adw-1](https://www.npmjs.com/package/@girs/adw-1) and [much more](https://github.com/gjsify/types).
76
+
77
+ These types will then be available to you:
54
78
 
55
- If you want to have more types for GIR modules, you have to add them to your dependencies and import them as well, see the description of these modules, e.g. [Gtk-4.0](https://www.npmjs.com/package/@girs/gtk-4.0).
79
+ ```ts
80
+ import '@girs/gjs'
81
+ import '@girs/gio-2.0'
82
+ import '@girs/gtk-4.0'
83
+ import '@girs/adw-1'
56
84
 
85
+ import Gio from 'gi://Gio?version=2.0';
86
+ import Gtk from 'gi://Gtk?version=4.0';
87
+ import Adwaita from 'gi://adw?version=1';
88
+
89
+ const button = new Gtk.Button();
90
+
91
+ // ...
92
+
93
+ ```
57
94
 
58
95
  ### Bundle
59
96
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@girs/gjs",
3
- "version": "3.0.0-beta.16",
3
+ "version": "3.0.1",
4
4
  "description": "GJS TypeScript type definitions for Gjs",
5
5
  "type": "module",
6
6
  "module": "gjs.js",
@@ -60,8 +60,8 @@
60
60
  "test:cjs": "tsc --noEmit gjs.d.cts"
61
61
  },
62
62
  "dependencies": {
63
- "@girs/gobject-2.0": "^2.76.1-3.0.0-beta.16",
64
- "@girs/glib-2.0": "^2.76.1-3.0.0-beta.16"
63
+ "@girs/glib-2.0": "^2.76.1-3.0.1",
64
+ "@girs/gobject-2.0": "^2.76.1-3.0.1"
65
65
  },
66
66
  "devDependencies": {
67
67
  "typescript": "^5.0.4"