@girs/glibunix-2.0 2.0.0-3.3.0
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 +104 -0
- package/glibunix-2.0-ambient.d.ts +12 -0
- package/glibunix-2.0-ambient.js +2 -0
- package/glibunix-2.0-import.d.ts +12 -0
- package/glibunix-2.0-import.js +3 -0
- package/glibunix-2.0.cjs +11 -0
- package/glibunix-2.0.d.cts +88 -0
- package/glibunix-2.0.d.ts +93 -0
- package/glibunix-2.0.js +10 -0
- package/package.json +59 -0
- package/tsconfig.json +23 -0
- package/typedoc.json +7 -0
package/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
|
|
2
|
+
# GLibUnix-2.0
|
|
3
|
+
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
GJS TypeScript type definitions for GLibUnix-2.0, generated from library version 2.0.0 using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v3.3.0.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
To use this type definitions, install them with NPM:
|
|
14
|
+
```bash
|
|
15
|
+
npm install @girs/glibunix-2.0
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
You can import this package into your project like this:
|
|
21
|
+
```ts
|
|
22
|
+
import GLibUnix from '@girs/glibunix-2.0';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or if you prefer CommonJS, you can also use this:
|
|
26
|
+
```ts
|
|
27
|
+
const GLibUnix = require('@girs/glibunix-2.0');
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Ambient Modules
|
|
31
|
+
|
|
32
|
+
You can also use [ambient modules](https://github.com/gjsify/ts-for-gir/tree/main/packages/cli#ambient-modules) to import this module like you would do this in JavaScript.
|
|
33
|
+
For this you need to include `@girs/glibunix-2.0` or `@girs/glibunix-2.0/ambient` in your `tsconfig` or entry point Typescript file:
|
|
34
|
+
|
|
35
|
+
`index.ts`:
|
|
36
|
+
```ts
|
|
37
|
+
import '@girs/glibunix-2.0'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`tsconfig.json`:
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"compilerOptions": {
|
|
44
|
+
...
|
|
45
|
+
},
|
|
46
|
+
"include": ["@girs/glibunix-2.0"],
|
|
47
|
+
...
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Now you can import the ambient module with TypeScript support:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import GLibUnix from 'gi://GLibUnix?version=2.0';
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Global import
|
|
58
|
+
|
|
59
|
+
You can also import the module with Typescript support using the global `imports.gi` object of GJS.
|
|
60
|
+
For this you need to include `@girs/glibunix-2.0` or `@girs/glibunix-2.0/import` in your `tsconfig` or entry point Typescript file:
|
|
61
|
+
|
|
62
|
+
`index.ts`:
|
|
63
|
+
```ts
|
|
64
|
+
import '@girs/glibunix-2.0'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`tsconfig.json`:
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"compilerOptions": {
|
|
71
|
+
...
|
|
72
|
+
},
|
|
73
|
+
"include": ["@girs/glibunix-2.0"],
|
|
74
|
+
...
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Now you have also type support for this, too:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
const GLibUnix = imports.gi.GLibUnix;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
### ESM vs. CommonJS
|
|
86
|
+
|
|
87
|
+
GJS supports two different import syntaxes. The new modern ESM syntax and the old global imports syntax.
|
|
88
|
+
|
|
89
|
+
In TypeScript projects for GJS and GNOME Shell extensions, you have the flexibility to use `ESM` syntax and then decide the import syntax for your bundled file. If your bundler is configured to use `CommonJS`, it will convert to the GJS-specific global imports syntax, like `const moduleName = imports.gi[moduleName]`. This is different from the traditional `require` syntax seen in Node.js. The global imports syntax is chosen because it aligns with the CommonJS format supported by NPM, which is used for the generated type definitions and this package.
|
|
90
|
+
|
|
91
|
+
On the other hand, if you configure your bundler to use ESM, it will retain the ESM import syntax. It's crucial to ensure that your bundler is set up to correctly translate and bundle these imports into either CommonJS or ESM format, depending on your project's requirements.
|
|
92
|
+
|
|
93
|
+
This approach is particularly important due to the `@girs` types, which include both `*.cjs `files, using the GJS global imports syntax, and `*.js` files, which utilize the ESM syntax. By appropriately setting up your bundler, you can control which syntax—CommonJS or ESM—is used in your project. The choice of CommonJS in this context is also due to the similarity between the GJS-specific global imports and CommonJS syntax, allowing for easier management and bundling in these specific types of projects.
|
|
94
|
+
|
|
95
|
+
Since GNOME Shell 45, you should only use ESM, even for GNOME Shell extensions. Before that, extensions had to use the global import syntax, unlike normal GJS applications, where ESM has been available for some time.
|
|
96
|
+
|
|
97
|
+
### Bundle
|
|
98
|
+
|
|
99
|
+
Depending on your project configuration, it is recommended to use a bundler like [esbuild](https://esbuild.github.io/). You can find examples using different bundlers [here](https://github.com/gjsify/ts-for-gir/tree/main/examples).
|
|
100
|
+
|
|
101
|
+
## Other packages
|
|
102
|
+
|
|
103
|
+
All existing pre-generated packages can be found on [gjsify/types](https://github.com/gjsify/types).
|
|
104
|
+
|
package/glibunix-2.0.cjs
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
* Type Definitions for Gjs (https://gjs.guide/)
|
|
4
|
+
*
|
|
5
|
+
* These type definitions are automatically generated, do not edit them by hand.
|
|
6
|
+
* If you found a bug fix it in `ts-for-gir` or create a bug report on https://github.com/gjsify/ts-for-gir
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import './glibunix-2.0-ambient.d.ts';
|
|
10
|
+
import './glibunix-2.0-import.d.ts';
|
|
11
|
+
/**
|
|
12
|
+
* GLibUnix-2.0
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type GLib from '@girs/glib-2.0';
|
|
16
|
+
import type GObject from '@girs/gobject-2.0';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Mnemonic constants for the ends of a Unix pipe.
|
|
20
|
+
*/
|
|
21
|
+
export enum PipeEnd {
|
|
22
|
+
/**
|
|
23
|
+
* The readable file descriptor 0
|
|
24
|
+
*/
|
|
25
|
+
READ,
|
|
26
|
+
/**
|
|
27
|
+
* The writable file descriptor 1
|
|
28
|
+
*/
|
|
29
|
+
WRITE,
|
|
30
|
+
}
|
|
31
|
+
export function closefrom(lowfd: number): number
|
|
32
|
+
export function error_quark(): GLib.Quark
|
|
33
|
+
export function fd_add_full(priority: number, fd: number, condition: GLib.IOCondition, function_: GLib.UnixFDSourceFunc): number
|
|
34
|
+
export function fd_source_new(fd: number, condition: GLib.IOCondition): GLib.Source
|
|
35
|
+
export function fdwalk_set_cloexec(lowfd: number): number
|
|
36
|
+
export function get_passwd_entry(user_name: string): any | null
|
|
37
|
+
export function open_pipe(fds: number, flags: number): boolean
|
|
38
|
+
export function set_fd_nonblocking(fd: number, nonblock: boolean): boolean
|
|
39
|
+
export function signal_add_full(priority: number, signum: number, handler: GLib.SourceFunc): number
|
|
40
|
+
export function signal_source_new(signum: number): GLib.Source
|
|
41
|
+
/**
|
|
42
|
+
* The type of functions to be called when a UNIX fd watch source
|
|
43
|
+
* triggers.
|
|
44
|
+
* @callback
|
|
45
|
+
* @param fd the fd that triggered the event
|
|
46
|
+
* @param condition the IO conditions reported on `fd`
|
|
47
|
+
* @returns %FALSE if the source should be removed
|
|
48
|
+
*/
|
|
49
|
+
export interface FDSourceFunc {
|
|
50
|
+
(fd: number, condition: GLib.IOCondition): boolean
|
|
51
|
+
}
|
|
52
|
+
export interface Pipe {
|
|
53
|
+
|
|
54
|
+
// Own fields of GLibUnix-2.0.GLibUnix.Pipe
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A pair of file descriptors, each negative if closed or not yet opened.
|
|
58
|
+
* The file descriptor with index %G_UNIX_PIPE_END_READ is readable.
|
|
59
|
+
* The file descriptor with index %G_UNIX_PIPE_END_WRITE is writable.
|
|
60
|
+
* @field
|
|
61
|
+
*/
|
|
62
|
+
fds: number[]
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A Unix pipe. The advantage of this type over `int[2]` is that it can
|
|
67
|
+
* be closed automatically when it goes out of scope, using `g_auto(GUnixPipe)`,
|
|
68
|
+
* on compilers that support that feature.
|
|
69
|
+
* @record
|
|
70
|
+
*/
|
|
71
|
+
export class Pipe {
|
|
72
|
+
|
|
73
|
+
// Own properties of GLibUnix-2.0.GLibUnix.Pipe
|
|
74
|
+
|
|
75
|
+
static name: string
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Name of the imported GIR library
|
|
80
|
+
* @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188
|
|
81
|
+
*/
|
|
82
|
+
export const __name__: string
|
|
83
|
+
/**
|
|
84
|
+
* Version of the imported GIR library
|
|
85
|
+
* @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189
|
|
86
|
+
*/
|
|
87
|
+
export const __version__: string
|
|
88
|
+
// END
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
* Type Definitions for Gjs (https://gjs.guide/)
|
|
4
|
+
*
|
|
5
|
+
* These type definitions are automatically generated, do not edit them by hand.
|
|
6
|
+
* If you found a bug fix it in `ts-for-gir` or create a bug report on https://github.com/gjsify/ts-for-gir
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import './glibunix-2.0-ambient.d.ts';
|
|
10
|
+
import './glibunix-2.0-import.d.ts';
|
|
11
|
+
/**
|
|
12
|
+
* GLibUnix-2.0
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type GLib from '@girs/glib-2.0';
|
|
16
|
+
import type GObject from '@girs/gobject-2.0';
|
|
17
|
+
|
|
18
|
+
export namespace GLibUnix {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Mnemonic constants for the ends of a Unix pipe.
|
|
22
|
+
*/
|
|
23
|
+
enum PipeEnd {
|
|
24
|
+
/**
|
|
25
|
+
* The readable file descriptor 0
|
|
26
|
+
*/
|
|
27
|
+
READ,
|
|
28
|
+
/**
|
|
29
|
+
* The writable file descriptor 1
|
|
30
|
+
*/
|
|
31
|
+
WRITE,
|
|
32
|
+
}
|
|
33
|
+
function closefrom(lowfd: number): number
|
|
34
|
+
function error_quark(): GLib.Quark
|
|
35
|
+
function fd_add_full(priority: number, fd: number, condition: GLib.IOCondition, function_: GLib.UnixFDSourceFunc): number
|
|
36
|
+
function fd_source_new(fd: number, condition: GLib.IOCondition): GLib.Source
|
|
37
|
+
function fdwalk_set_cloexec(lowfd: number): number
|
|
38
|
+
function get_passwd_entry(user_name: string): any | null
|
|
39
|
+
function open_pipe(fds: number, flags: number): boolean
|
|
40
|
+
function set_fd_nonblocking(fd: number, nonblock: boolean): boolean
|
|
41
|
+
function signal_add_full(priority: number, signum: number, handler: GLib.SourceFunc): number
|
|
42
|
+
function signal_source_new(signum: number): GLib.Source
|
|
43
|
+
/**
|
|
44
|
+
* The type of functions to be called when a UNIX fd watch source
|
|
45
|
+
* triggers.
|
|
46
|
+
* @callback
|
|
47
|
+
* @param fd the fd that triggered the event
|
|
48
|
+
* @param condition the IO conditions reported on `fd`
|
|
49
|
+
* @returns %FALSE if the source should be removed
|
|
50
|
+
*/
|
|
51
|
+
interface FDSourceFunc {
|
|
52
|
+
(fd: number, condition: GLib.IOCondition): boolean
|
|
53
|
+
}
|
|
54
|
+
interface Pipe {
|
|
55
|
+
|
|
56
|
+
// Own fields of GLibUnix-2.0.GLibUnix.Pipe
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A pair of file descriptors, each negative if closed or not yet opened.
|
|
60
|
+
* The file descriptor with index %G_UNIX_PIPE_END_READ is readable.
|
|
61
|
+
* The file descriptor with index %G_UNIX_PIPE_END_WRITE is writable.
|
|
62
|
+
* @field
|
|
63
|
+
*/
|
|
64
|
+
fds: number[]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A Unix pipe. The advantage of this type over `int[2]` is that it can
|
|
69
|
+
* be closed automatically when it goes out of scope, using `g_auto(GUnixPipe)`,
|
|
70
|
+
* on compilers that support that feature.
|
|
71
|
+
* @record
|
|
72
|
+
*/
|
|
73
|
+
class Pipe {
|
|
74
|
+
|
|
75
|
+
// Own properties of GLibUnix-2.0.GLibUnix.Pipe
|
|
76
|
+
|
|
77
|
+
static name: string
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Name of the imported GIR library
|
|
82
|
+
* @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188
|
|
83
|
+
*/
|
|
84
|
+
const __name__: string
|
|
85
|
+
/**
|
|
86
|
+
* Version of the imported GIR library
|
|
87
|
+
* @see https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189
|
|
88
|
+
*/
|
|
89
|
+
const __version__: string
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default GLibUnix;
|
|
93
|
+
// END
|
package/glibunix-2.0.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@girs/glibunix-2.0",
|
|
3
|
+
"version": "2.0.0-3.3.0",
|
|
4
|
+
"description": "GJS TypeScript type definitions for GLibUnix-2.0, generated from library version 2.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "glibunix-2.0.js",
|
|
7
|
+
"main": "glibunix-2.0.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./ambient": {
|
|
10
|
+
"types": "./glibunix-2.0-ambient.d.ts",
|
|
11
|
+
"default": "./glibunix-2.0-ambient.js"
|
|
12
|
+
},
|
|
13
|
+
"./import": {
|
|
14
|
+
"types": "./glibunix-2.0-import.d.ts",
|
|
15
|
+
"default": "./glibunix-2.0-import.js"
|
|
16
|
+
},
|
|
17
|
+
".": {
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./glibunix-2.0.d.ts",
|
|
20
|
+
"default": "./glibunix-2.0.js"
|
|
21
|
+
},
|
|
22
|
+
"require": {
|
|
23
|
+
"types": "./glibunix-2.0.d.cts",
|
|
24
|
+
"default": "./glibunix-2.0.cjs"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"test": "yarn test:esm && yarn test:cjs",
|
|
30
|
+
"test:esm": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit glibunix-2.0.d.ts",
|
|
31
|
+
"test:cjs": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit glibunix-2.0.d.cts"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@girs/gjs": "^3.3.0",
|
|
35
|
+
"@girs/glib-2.0": "^2.78.0-3.3.0",
|
|
36
|
+
"@girs/gobject-2.0": "^2.78.0-3.3.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"typescript": "*"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"Gir",
|
|
43
|
+
"TypeScript",
|
|
44
|
+
"types",
|
|
45
|
+
"GObject-Introspection",
|
|
46
|
+
"GJS",
|
|
47
|
+
"GLibUnix-2.0"
|
|
48
|
+
],
|
|
49
|
+
"author": "ts-for-gir",
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/gjsify/ts-for-gir.git"
|
|
54
|
+
},
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/gjsify/ts-for-gir/issues"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://github.com/gjsify/types/tree/main/glibunix-2.0#readme"
|
|
59
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// General settings for code interpretation
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"lib": ["ESNext"],
|
|
7
|
+
"types": [],
|
|
8
|
+
"experimentalDecorators": true,
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"noEmit": true,
|
|
11
|
+
"noEmitOnError": false,
|
|
12
|
+
"baseUrl": "./",
|
|
13
|
+
"rootDir": ".",
|
|
14
|
+
// General settings for code generation
|
|
15
|
+
"removeComments": false,
|
|
16
|
+
"inlineSourceMap": false,
|
|
17
|
+
"inlineSources": false,
|
|
18
|
+
"newLine": "LF"
|
|
19
|
+
},
|
|
20
|
+
"include": ["./glibunix-2.0.d.ts"]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|