@girs/handy-1 4.3.0 → 4.5.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 CHANGED
@@ -4,82 +4,96 @@
4
4
  ![version](https://img.shields.io/npm/v/@girs/handy-1)
5
5
  ![downloads/week](https://img.shields.io/npm/dw/@girs/handy-1)
6
6
 
7
+ GJS TypeScript type definitions for Handy-1 using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v4.5.0.
7
8
 
8
- GJS TypeScript type definitions for Handy-1 using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v4.3.0.
9
+ This package contains type declarations only. It ships no runtime code, so it adds
10
+ nothing to your program and works with any bundler or none at all.
9
11
 
10
12
  ## Install
11
13
 
12
- Install the type definitions with npm:
13
14
  ```bash
14
15
  npm install @girs/handy-1
15
16
  ```
16
17
 
17
- ## Usage
18
+ Any package manager works. The package has no dependencies beyond other `@girs/*`
19
+ type packages.
20
+
21
+ ## What it exports
22
+
23
+ | Import | What you get |
24
+ |---|---|
25
+ | `@girs/handy-1` | the namespace as a default export, plus the ambient and global declarations |
26
+ | `@girs/handy-1/ambient` | only the `gi://` module declarations |
27
+ | `@girs/handy-1/import` | only the `imports.gi` declarations |
28
+ | `@girs/handy-1/handy-1` | the namespace, without the side-effecting declarations |
29
+ | `@girs/handy-1/vocabulary` | GIR-derived widget data: settable properties, enum nicks, slot candidates |
30
+
31
+ ## Three ways to import
32
+
33
+ Which one you use depends on how you write imports elsewhere, not on your toolchain.
34
+
35
+ ### As a module
18
36
 
19
- Import it like any other module:
20
37
  ```ts
21
38
  import Handy from '@girs/handy-1';
22
39
  ```
23
40
 
24
- ### Ambient Modules
41
+ ### As `gi://`
25
42
 
26
- [Ambient modules](https://github.com/gjsify/ts-for-gir/tree/main/packages/cli#ambient-modules) let you write the same import you would in plain JavaScript.
27
- For this you need to include `@girs/handy-1` or `@girs/handy-1/ambient` in your `tsconfig` or entry point Typescript file:
43
+ GJS resolves `gi://` at runtime. To give it types, reference the package once, either
44
+ from your entry point or from `tsconfig.json`:
28
45
 
29
- `index.ts`:
30
46
  ```ts
31
- import '@girs/handy-1'
47
+ import '@girs/handy-1';
32
48
  ```
33
49
 
34
- `tsconfig.json`:
35
50
  ```json
36
- {
37
- "compilerOptions": {
38
- ...
39
- },
40
- "include": ["@girs/handy-1"],
41
- ...
42
- }
51
+ { "include": ["@girs/handy-1"] }
43
52
  ```
44
53
 
45
- The ambient module now resolves with types:
54
+ Then the runtime spelling type-checks:
46
55
 
47
56
  ```ts
48
57
  import Handy from 'gi://Handy?version=1';
49
58
  ```
50
59
 
51
- ### Global import
60
+ Referencing `@girs/handy-1/ambient` instead pulls in these declarations
61
+ alone. See [ambient modules](https://github.com/gjsify/ts-for-gir/tree/main/packages/cli#ambient-modules).
62
+
63
+ ### As `imports.gi`
52
64
 
53
- GJS's global `imports.gi` works too, with types.
54
- For this you need to include `@girs/handy-1` or `@girs/handy-1/import` in your `tsconfig` or entry point Typescript file:
65
+ GJS's global object works the same way, via `@girs/handy-1/import`:
55
66
 
56
- `index.ts`:
57
67
  ```ts
58
- import '@girs/handy-1'
68
+ const Handy = imports.gi.Handy;
59
69
  ```
60
70
 
61
- `tsconfig.json`:
62
- ```json
63
- {
64
- "compilerOptions": {
65
- ...
66
- },
67
- "include": ["@girs/handy-1"],
68
- ...
69
- }
70
- ```
71
+ ## Widget vocabulary
71
72
 
72
- That form carries types as well:
73
+ `handy-1` declares widgets, so it also carries what the GIR says about them, as
74
+ types and as values a test can read:
73
75
 
74
76
  ```ts
75
- const Handy = imports.gi.Handy;
77
+ import type { Widgets, PropsOf } from '@girs/handy-1/vocabulary';
78
+ import { OWN_PROPS, ENUM_NICKS, PROVENANCE } from '@girs/handy-1/vocabulary';
76
79
  ```
77
80
 
78
- ### Bundle
81
+ Properties are keyed the way GObject registered them, writable-only and optional, so they
82
+ match `g_object_set`, GtkBuilder XML and Blueprint. `PROVENANCE.libraryVersion` names the
83
+ library release this was generated from, which lets a check tell "newer than what is
84
+ installed" from "wrong".
79
85
 
80
- Most projects want a bundler. [esbuild](https://esbuild.github.io/) is the smallest thing that works; the [examples directory](https://github.com/gjsify/ts-for-gir/tree/main/examples) has setups for several others.
86
+ This subpath answers what the GIR says, not what the installed library has. For the
87
+ second question, ask the library.
88
+
89
+ ## Building
90
+
91
+ The declarations need no build step. If you bundle, every bundler works, since there is
92
+ no runtime code to resolve. The [examples](https://github.com/gjsify/ts-for-gir/tree/main/examples)
93
+ show working setups for several.
81
94
 
82
95
  ## Other packages
83
96
 
84
- All existing pre-generated packages can be found on [gjsify/types](https://github.com/gjsify/types).
97
+ Every pre-generated package is at [gjsify/types](https://github.com/gjsify/types).
98
+
85
99
 
@@ -1129,6 +1129,23 @@ export interface Widgets {
1129
1129
  /** Every GType this namespace can create. A consumer derives its own tag map. */
1130
1130
  export type WidgetGType = keyof Widgets;
1131
1131
 
1132
+ // ---------------------------------------------------------------------------
1133
+ // Child holders — the same shape, for objects that CARRY a widget without being one.
1134
+ //
1135
+ // `GtkListItem`, `GtkListHeader`, `GtkColumnViewCell` and `AdwToggle` descend from
1136
+ // `GObject.Object` and hold a widget through `set_child`/`get_child`. A renderer places
1137
+ // them exactly like a container, so they belong in the vocabulary; a check asking "is
1138
+ // this a widget" must still be able to say no. Hence a sibling table rather than four
1139
+ // more rows in `Widgets`: concatenate them when you mean both.
1140
+ // ---------------------------------------------------------------------------
1141
+
1142
+ export interface ChildHolders {
1143
+
1144
+ }
1145
+
1146
+ /** Every GType this namespace holds a child in without it being a widget. */
1147
+ export type ChildHolderGType = keyof ChildHolders;
1148
+
1132
1149
  /** The writable, optional, GObject-keyed property surface of one GType. */
1133
1150
  export type PropsOf<G extends WidgetGType> = Widgets[G]['props'];
1134
1151
 
@@ -1164,6 +1181,9 @@ export const OWN_SIGNALS: Readonly<Record<string, readonly string[]>>;
1164
1181
  /** Widget GType -> every declaration its members come from, self first. */
1165
1182
  export const DECLS: Readonly<Record<string, readonly string[]>>;
1166
1183
 
1184
+ /** The GTypes in `DECLS` that hold a widget without being one — see `ChildHolders`. */
1185
+ export const CHILD_HOLDERS: readonly string[];
1186
+
1167
1187
  /** Enum GType -> the nicks this surface offers. */
1168
1188
  export const ENUM_NICKS: Readonly<Record<string, readonly string[]>>;
1169
1189
 
@@ -76,6 +76,12 @@ export const DECLS = {
76
76
  HdyWindowHandle: ['HdyWindowHandle', 'GtkEventBox', 'GtkBin', 'GtkContainer', 'GtkWidget', 'GtkBuildable'],
77
77
  };
78
78
 
79
+ // The GTypes above that are NOT widgets: they hold one through `set_child`/`get_child`
80
+ // and descend from `GObject.Object`. A renderer places them like a container; a check
81
+ // asking "is this a widget" must not count them. Derived from the accessor pair, never
82
+ // from a list — the count is in the provenance line above.
83
+ export const CHILD_HOLDERS = [];
84
+
79
85
  export const ENUM_NICKS = {
80
86
  HdyCenteringPolicy: ['loose', 'strict'],
81
87
  HdyColorScheme: ['default', 'force-light', 'prefer-light', 'prefer-dark', 'force-dark'],