@girs/passim-1.0 0.1.5-4.0.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 ADDED
@@ -0,0 +1,104 @@
1
+
2
+ # Passim-1.0
3
+
4
+ ![version](https://img.shields.io/npm/v/@girs/passim-1.0)
5
+ ![downloads/week](https://img.shields.io/npm/dw/@girs/passim-1.0)
6
+
7
+
8
+ GJS TypeScript type definitions for Passim-1.0, generated from library version 0.1.5 using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v4.0.0.
9
+
10
+
11
+ ## Install
12
+
13
+ To use this type definitions, install them with NPM:
14
+ ```bash
15
+ npm install @girs/passim-1.0
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ You can import this package into your project like this:
21
+ ```ts
22
+ import Passim from '@girs/passim-1.0';
23
+ ```
24
+
25
+ Or if you prefer CommonJS, you can also use this:
26
+ ```ts
27
+ const Passim = require('@girs/passim-1.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/passim-1.0` or `@girs/passim-1.0/ambient` in your `tsconfig` or entry point Typescript file:
34
+
35
+ `index.ts`:
36
+ ```ts
37
+ import '@girs/passim-1.0'
38
+ ```
39
+
40
+ `tsconfig.json`:
41
+ ```json
42
+ {
43
+ "compilerOptions": {
44
+ ...
45
+ },
46
+ "include": ["@girs/passim-1.0"],
47
+ ...
48
+ }
49
+ ```
50
+
51
+ Now you can import the ambient module with TypeScript support:
52
+
53
+ ```ts
54
+ import Passim from 'gi://Passim?version=1.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/passim-1.0` or `@girs/passim-1.0/import` in your `tsconfig` or entry point Typescript file:
61
+
62
+ `index.ts`:
63
+ ```ts
64
+ import '@girs/passim-1.0'
65
+ ```
66
+
67
+ `tsconfig.json`:
68
+ ```json
69
+ {
70
+ "compilerOptions": {
71
+ ...
72
+ },
73
+ "include": ["@girs/passim-1.0"],
74
+ ...
75
+ }
76
+ ```
77
+
78
+ Now you have also type support for this, too:
79
+
80
+ ```ts
81
+ const Passim = imports.gi.Passim;
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/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@girs/passim-1.0",
3
+ "version": "0.1.5-4.0.0",
4
+ "description": "GJS TypeScript type definitions for Passim-1.0, generated from library version 0.1.5",
5
+ "type": "module",
6
+ "module": "passim-1.0.js",
7
+ "main": "passim-1.0.js",
8
+ "exports": {
9
+ "./ambient": {
10
+ "types": "./passim-1.0-ambient.d.ts",
11
+ "import": "./passim-1.0-ambient.js",
12
+ "default": "./passim-1.0-ambient.js"
13
+ },
14
+ "./import": {
15
+ "types": "./passim-1.0-import.d.ts",
16
+ "import": "./passim-1.0-import.js",
17
+ "default": "./passim-1.0-import.js"
18
+ },
19
+ ".": {
20
+ "types": "./passim-1.0.d.ts",
21
+ "import": "./passim-1.0.js",
22
+ "default": "./passim-1.0.js"
23
+ }
24
+ },
25
+ "scripts": {
26
+ "test": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit passim-1.0.d.ts"
27
+ },
28
+ "dependencies": {
29
+ "@girs/gio-2.0": "^2.77.0-4.0.0-beta.1",
30
+ "@girs/gjs": "^4.0.0-beta.1",
31
+ "@girs/glib-2.0": "^2.77.0-4.0.0-beta.1",
32
+ "@girs/gobject-2.0": "^2.77.0-4.0.0-beta.1"
33
+ },
34
+ "devDependencies": {
35
+ "typescript": "*"
36
+ },
37
+ "keywords": [
38
+ "Gir",
39
+ "TypeScript",
40
+ "types",
41
+ "GObject-Introspection",
42
+ "GJS",
43
+ "Passim-1.0"
44
+ ],
45
+ "author": "ts-for-gir",
46
+ "license": "MIT",
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/gjsify/ts-for-gir.git"
50
+ },
51
+ "bugs": {
52
+ "url": "https://github.com/gjsify/ts-for-gir/issues"
53
+ },
54
+ "homepage": "https://github.com/gjsify/types/tree/main/passim-1.0#readme"
55
+ }
@@ -0,0 +1,12 @@
1
+
2
+ declare module 'gi://Passim?version=1.0' {
3
+ import Passim from '@girs/passim-1.0';
4
+ export default Passim;
5
+ }
6
+
7
+ declare module 'gi://Passim' {
8
+ import Passim10 from 'gi://Passim?version=1.0';
9
+ export default Passim10;
10
+ }
11
+
12
+
@@ -0,0 +1,2 @@
1
+ export {}
2
+
@@ -0,0 +1,12 @@
1
+
2
+ import Passim10 from '@girs/passim-1.0';
3
+
4
+ declare global {
5
+ export interface GjsGiImports {
6
+ Passim: typeof Passim10;
7
+ }
8
+ }
9
+
10
+ export default GjsGiImports;
11
+
12
+
@@ -0,0 +1,3 @@
1
+ const gi = globalThis.imports?.gi || {};
2
+ export default gi;
3
+
@@ -0,0 +1,342 @@
1
+ /*
2
+ * Type Definitions for Gjs (https://gjs.guide/)
3
+ *
4
+ * These type definitions are automatically generated, do not edit them by hand.
5
+ * If you found a bug fix it in `ts-for-gir` or create a bug report on https://github.com/gjsify/ts-for-gir
6
+ */
7
+
8
+ import './passim-1.0-ambient.d.ts';
9
+
10
+ /**
11
+ * Passim-1.0
12
+ */
13
+
14
+ import type Gio from '@girs/gio-2.0';
15
+ import type GObject from '@girs/gobject-2.0';
16
+ import type GLib from '@girs/glib-2.0';
17
+
18
+ export namespace Passim {
19
+ enum Status {
20
+ UNKNOWN,
21
+ STARTING,
22
+ LOADING,
23
+ RUNNING,
24
+ DISABLED_METERED,
25
+ }
26
+ const DBUS_INTERFACE: string;
27
+ const DBUS_PATH: string;
28
+ const DBUS_SERVICE: string;
29
+ /**
30
+ * The item is not active for some reason.
31
+ */
32
+ const ITEM_FLAG_DISABLED: number;
33
+ /**
34
+ * Only register the item when the machine has been rebooted.
35
+ */
36
+ const ITEM_FLAG_NEXT_REBOOT: number;
37
+ /**
38
+ * No item flags are set.
39
+ */
40
+ const ITEM_FLAG_NONE: number;
41
+ /**
42
+ * The compile-time major version
43
+ */
44
+ const MAJOR_VERSION: number;
45
+ /**
46
+ * The compile-time micro version
47
+ */
48
+ const MICRO_VERSION: number;
49
+ /**
50
+ * The compile-time minor version
51
+ */
52
+ const MINOR_VERSION: number;
53
+ /**
54
+ * Gets the libpassim installed runtime version.
55
+ *
56
+ * This may be different to the *build-time* version if the daemon and library
57
+ * objects somehow get out of sync.
58
+ * @returns version string
59
+ */
60
+ function version_string(): string;
61
+ module Client {
62
+ // Constructor properties interface
63
+
64
+ interface ConstructorProps extends GObject.Object.ConstructorProps {}
65
+ }
66
+
67
+ /**
68
+ * A shared client.
69
+ */
70
+ class Client extends GObject.Object {
71
+ static $gtype: GObject.GType<Client>;
72
+
73
+ // Constructors of Passim.Client
74
+
75
+ constructor(properties?: Partial<Client.ConstructorProps>, ...args: any[]);
76
+
77
+ _init(...args: any[]): void;
78
+
79
+ static ['new'](): Client;
80
+
81
+ // Own methods of Passim.Client
82
+
83
+ /**
84
+ * Get items currently published by the daemon.
85
+ * @returns items, or %NULL for error
86
+ */
87
+ get_items(): Item[];
88
+ /**
89
+ * Gets the daemon status.
90
+ * @returns the #PassimStatus
91
+ */
92
+ get_status(): Status;
93
+ /**
94
+ * Gets the daemon version.
95
+ * @returns the version string, or %NULL if unset
96
+ */
97
+ get_version(): string;
98
+ /**
99
+ * Loads the client from a file on disk.
100
+ * @returns %TRUE for success
101
+ */
102
+ load(): boolean;
103
+ /**
104
+ * Connects to the remote server.
105
+ * @param item a #PassimItem
106
+ * @returns %TRUE for success
107
+ */
108
+ publish(item: Item): boolean;
109
+ /**
110
+ * Unpublish a file from the index.
111
+ * @param hash an item hash value
112
+ * @returns %TRUE for success
113
+ */
114
+ unpublish(hash: string): boolean;
115
+ }
116
+
117
+ module Item {
118
+ // Constructor properties interface
119
+
120
+ interface ConstructorProps extends GObject.Object.ConstructorProps {}
121
+ }
122
+
123
+ /**
124
+ * A shared item.
125
+ */
126
+ class Item extends GObject.Object {
127
+ static $gtype: GObject.GType<Item>;
128
+
129
+ // Constructors of Passim.Item
130
+
131
+ constructor(properties?: Partial<Item.ConstructorProps>, ...args: any[]);
132
+
133
+ _init(...args: any[]): void;
134
+
135
+ static ['new'](): Item;
136
+
137
+ // Own static methods of Passim.Item
138
+
139
+ /**
140
+ * Converts a string to an enumerated item flag.
141
+ * @param item_flag a string, e.g. `next-reboot`
142
+ */
143
+ static flag_from_string(item_flag?: string | null): ItemFlags;
144
+ /**
145
+ * Converts an enumerated item flag to a string.
146
+ * @param item_flag item flags, e.g. %PASSIM_ITEM_FLAG_NEXT_REBOOT
147
+ */
148
+ static flag_to_string(item_flag: ItemFlags): string;
149
+ /**
150
+ * Creates a new item using serialized data.
151
+ * @param value the serialized data
152
+ */
153
+ static from_variant(value: GLib.Variant): Item;
154
+
155
+ // Own methods of Passim.Item
156
+
157
+ /**
158
+ * Adds a specific item flag to the item.
159
+ * @param flag the #PassimItemFlags
160
+ */
161
+ add_flag(flag: ItemFlags): void;
162
+ /**
163
+ * Gets the current file age.
164
+ * @returns time in seconds, or 0 for invalid.
165
+ */
166
+ get_age(): number;
167
+ /**
168
+ * Gets the basename of the file that was published.
169
+ * @returns the test basename, or %NULL if unset
170
+ */
171
+ get_basename(): string;
172
+ /**
173
+ * Gets the local bytes in the cache.
174
+ * @returns a #GBytes, or %NULL if unset
175
+ */
176
+ get_bytes(): GLib.Bytes;
177
+ /**
178
+ * Gets the cmdline of the binary that published the item.
179
+ * @returns the binary name, or %NULL if unset
180
+ */
181
+ get_cmdline(): string;
182
+ /**
183
+ * Gets the creation time of the file.
184
+ * @returns the creation time, or %NULL if unset
185
+ */
186
+ get_ctime(): GLib.DateTime;
187
+ /**
188
+ * Gets the local file in the cache.
189
+ * @returns a #GFile, or %NULL if unset
190
+ */
191
+ get_file(): Gio.File;
192
+ /**
193
+ * Gets the item flags.
194
+ * @returns item flags, or 0 if unset
195
+ */
196
+ get_flags(): number;
197
+ /**
198
+ * Gets the item flags.
199
+ * @returns string
200
+ */
201
+ get_flags_as_string(): string;
202
+ /**
203
+ * Gets the file hash.
204
+ * @returns the typically in SHA-256 lowercase form, or %NULL if unset
205
+ */
206
+ get_hash(): string;
207
+ /**
208
+ * Gets the maximum permitted file age.
209
+ * @returns time in seconds
210
+ */
211
+ get_max_age(): number;
212
+ /**
213
+ * Gets the current number of times the item has been shared to other machines.
214
+ * @returns the count, or 0 if unset
215
+ */
216
+ get_share_count(): number;
217
+ /**
218
+ * Gets the maximum number of times that the file can be shared.
219
+ * @returns share limit, or 0 if unset
220
+ */
221
+ get_share_limit(): number;
222
+ /**
223
+ * Gets the size of the file in bytes.
224
+ * @returns share limit, or 0 if unset
225
+ */
226
+ get_size(): number;
227
+ /**
228
+ * Gets the input stream for the item.
229
+ * @returns a #GInputStream, or %NULL if unset
230
+ */
231
+ get_stream(): Gio.InputStream;
232
+ /**
233
+ * Finds if the item has a specific item flag.
234
+ * @param flag a item flag
235
+ * @returns %TRUE if the flag is set
236
+ */
237
+ has_flag(flag: ItemFlags): boolean;
238
+ /**
239
+ * Loads the item from a file on disk.
240
+ * @param filename a filename with full path
241
+ */
242
+ load_filename(filename: string): boolean;
243
+ /**
244
+ * Removes a specific item flag from the item.
245
+ * @param flag a item flag
246
+ */
247
+ remove_flag(flag: ItemFlags): void;
248
+ /**
249
+ * Sets the basename of the file that was published.
250
+ * @param basename the basename name
251
+ */
252
+ set_basename(basename?: string | null): void;
253
+ /**
254
+ * Sets the local bytes in the cache.
255
+ * @param bytes a #GBytes
256
+ */
257
+ set_bytes(bytes?: GLib.Bytes | null): void;
258
+ /**
259
+ * Sets the cmdline of the binary that published the item.
260
+ *
261
+ * NOTE: this is desgined as a hint, and should not be used for security. The command line is
262
+ * obtained via /proc/<pid>/cmdline and it may be possible to falsify the data by a malicious
263
+ * binary running as root under certain conditions.
264
+ * @param cmdline the binary name
265
+ */
266
+ set_cmdline(cmdline?: string | null): void;
267
+ /**
268
+ * Sets the creation time of the file.
269
+ * @param ctime a #GDateTime
270
+ */
271
+ set_ctime(ctime?: GLib.DateTime | null): void;
272
+ /**
273
+ * Sets the local file in the cache.
274
+ * @param file a #GFile
275
+ */
276
+ set_file(file?: Gio.File | null): void;
277
+ /**
278
+ * Sets the item flags.
279
+ * @param flags item flags, e.g. %PASSIM_ITEM_FLAG_NEXT_REBOOT
280
+ */
281
+ set_flags(flags: number): void;
282
+ /**
283
+ * Sets the file hash.
284
+ * @param hash the hash, typically in SHA-256 lowercase form
285
+ */
286
+ set_hash(hash?: string | null): void;
287
+ /**
288
+ * Sets the maximum permitted file age.
289
+ * @param max_age time in seconds
290
+ */
291
+ set_max_age(max_age: number): void;
292
+ /**
293
+ * Sets the current number of times the item has been shared to other machines.
294
+ * @param share_count the count, or 0 to unset
295
+ */
296
+ set_share_count(share_count: number): void;
297
+ /**
298
+ * Sets the maximum number of times that the file can be shared.
299
+ * @param share_limit the share limit, or 0
300
+ */
301
+ set_share_limit(share_limit: number): void;
302
+ /**
303
+ * Sets the size of the file in bytes.
304
+ * @param size the share limit, or 0
305
+ */
306
+ set_size(size: number): void;
307
+ /**
308
+ * Sets the input stream stream for the item.
309
+ *
310
+ * NOTE: This *MUST* be a #GUnixInputStream, or subclass thereof.
311
+ * @param stream a #GInputStream
312
+ */
313
+ set_stream(stream?: Gio.InputStream | null): void;
314
+ /**
315
+ * Builds a text representation of the object.
316
+ * @returns text, or %NULL for invalid
317
+ */
318
+ to_string(): string;
319
+ /**
320
+ * Serialize the item data.
321
+ * @returns the serialized data, or %NULL for error
322
+ */
323
+ to_variant(): GLib.Variant;
324
+ }
325
+
326
+ type ClientClass = typeof Client;
327
+ type ItemClass = typeof Item;
328
+ type ItemFlags = number;
329
+ /**
330
+ * Name of the imported GIR library
331
+ * `see` https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188
332
+ */
333
+ const __name__: string;
334
+ /**
335
+ * Version of the imported GIR library
336
+ * `see` https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189
337
+ */
338
+ const __version__: string;
339
+ }
340
+
341
+ export default Passim;
342
+ // END
package/passim-1.0.js ADDED
@@ -0,0 +1,6 @@
1
+
2
+ // @ts-expect-error
3
+ import Passim from 'gi://Passim?version=1.0';
4
+ export { Passim };
5
+ export default Passim;
6
+
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": ["./passim-1.0.d.ts"]
21
+ }
22
+
23
+
package/typedoc.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "entryPoints": ["./passim-1.0.d.ts"],
3
+ "readme": "./README.md",
4
+ "name": "Passim-1.0",
5
+ "tsconfig": "./tsconfig.json"
6
+ }
7
+