@gtkx/react 1.0.0-rc.4 → 1.1.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.
Files changed (155) hide show
  1. package/README.md +5 -5
  2. package/dist/adw/dialog.d.ts +3 -4
  3. package/dist/adw/dialog.d.ts.map +1 -1
  4. package/dist/adw/dialog.js +18 -21
  5. package/dist/adw/dialog.js.map +1 -1
  6. package/dist/adw/element-behaviors.js +102 -54
  7. package/dist/adw/element-behaviors.js.map +1 -1
  8. package/dist/adw/element-config.d.ts +0 -6
  9. package/dist/adw/element-config.d.ts.map +1 -1
  10. package/dist/adw/element-config.js +15 -17
  11. package/dist/adw/element-config.js.map +1 -1
  12. package/dist/adw/prop-types.d.ts +34 -3
  13. package/dist/adw/prop-types.d.ts.map +1 -1
  14. package/dist/adw/prop-types.js.map +1 -1
  15. package/dist/components/application-window.d.ts +5 -0
  16. package/dist/components/application-window.d.ts.map +1 -0
  17. package/dist/components/application-window.js +7 -0
  18. package/dist/components/application-window.js.map +1 -0
  19. package/dist/components/application.d.ts +2 -8
  20. package/dist/components/application.d.ts.map +1 -1
  21. package/dist/components/application.js +31 -7
  22. package/dist/components/application.js.map +1 -1
  23. package/dist/components/element.d.ts +13 -1
  24. package/dist/components/element.d.ts.map +1 -1
  25. package/dist/components/element.js +39 -14
  26. package/dist/components/element.js.map +1 -1
  27. package/dist/components/portaled.d.ts +5 -0
  28. package/dist/components/portaled.d.ts.map +1 -0
  29. package/dist/components/portaled.js +8 -0
  30. package/dist/components/portaled.js.map +1 -0
  31. package/dist/components/window.d.ts +5 -5
  32. package/dist/components/window.d.ts.map +1 -1
  33. package/dist/components/window.js +16 -16
  34. package/dist/components/window.js.map +1 -1
  35. package/dist/config.d.ts +3 -1
  36. package/dist/config.d.ts.map +1 -1
  37. package/dist/config.js +2 -0
  38. package/dist/config.js.map +1 -1
  39. package/dist/element-behaviors.js +11 -1
  40. package/dist/element-behaviors.js.map +1 -1
  41. package/dist/element-config.d.ts.map +1 -1
  42. package/dist/element-config.js +7 -4
  43. package/dist/element-config.js.map +1 -1
  44. package/dist/hooks/use-merged-refs.d.ts +1 -4
  45. package/dist/hooks/use-merged-refs.d.ts.map +1 -1
  46. package/dist/hooks/use-merged-refs.js +1 -1
  47. package/dist/hooks/use-merged-refs.js.map +1 -1
  48. package/dist/hooks/use-presented-instance.d.ts +12 -0
  49. package/dist/hooks/use-presented-instance.d.ts.map +1 -0
  50. package/dist/hooks/use-presented-instance.js +27 -0
  51. package/dist/hooks/use-presented-instance.js.map +1 -0
  52. package/dist/hooks/use-property.d.ts +2 -1
  53. package/dist/hooks/use-property.d.ts.map +1 -1
  54. package/dist/hooks/use-property.js.map +1 -1
  55. package/dist/hooks/use-signal.d.ts +2 -1
  56. package/dist/hooks/use-signal.d.ts.map +1 -1
  57. package/dist/hooks/use-signal.js.map +1 -1
  58. package/dist/internal.d.ts +5 -3
  59. package/dist/internal.d.ts.map +1 -1
  60. package/dist/internal.js +5 -2
  61. package/dist/internal.js.map +1 -1
  62. package/dist/prop-types.d.ts +29 -5
  63. package/dist/prop-types.d.ts.map +1 -1
  64. package/dist/prop-types.js.map +1 -1
  65. package/dist/reconciler/apply-props.d.ts +4 -4
  66. package/dist/reconciler/apply-props.d.ts.map +1 -1
  67. package/dist/reconciler/apply-props.js +62 -20
  68. package/dist/reconciler/apply-props.js.map +1 -1
  69. package/dist/reconciler/behaviors.d.ts +9 -5
  70. package/dist/reconciler/behaviors.d.ts.map +1 -1
  71. package/dist/reconciler/behaviors.js +40 -22
  72. package/dist/reconciler/behaviors.js.map +1 -1
  73. package/dist/reconciler/devtools.d.ts +6 -0
  74. package/dist/reconciler/devtools.d.ts.map +1 -0
  75. package/dist/reconciler/devtools.js +11 -0
  76. package/dist/reconciler/devtools.js.map +1 -0
  77. package/dist/reconciler/host-config.d.ts.map +1 -1
  78. package/dist/reconciler/host-config.js +18 -25
  79. package/dist/reconciler/host-config.js.map +1 -1
  80. package/dist/reconciler/instance.d.ts.map +1 -1
  81. package/dist/reconciler/instance.js +5 -3
  82. package/dist/reconciler/instance.js.map +1 -1
  83. package/dist/reconciler/metadata.d.ts +1 -1
  84. package/dist/reconciler/metadata.d.ts.map +1 -1
  85. package/dist/reconciler/metadata.js +2 -4
  86. package/dist/reconciler/metadata.js.map +1 -1
  87. package/dist/reconciler/node.d.ts +3 -2
  88. package/dist/reconciler/node.d.ts.map +1 -1
  89. package/dist/reconciler/node.js +7 -6
  90. package/dist/reconciler/node.js.map +1 -1
  91. package/dist/reconciler/placement.js +20 -20
  92. package/dist/reconciler/placement.js.map +1 -1
  93. package/dist/reconciler/registry.d.ts +9 -7
  94. package/dist/reconciler/registry.d.ts.map +1 -1
  95. package/dist/reconciler/registry.js.map +1 -1
  96. package/dist/reconciler/root-element.d.ts +1 -0
  97. package/dist/reconciler/root-element.d.ts.map +1 -1
  98. package/dist/reconciler/root-element.js.map +1 -1
  99. package/dist/reconciler/root.d.ts +17 -3
  100. package/dist/reconciler/root.d.ts.map +1 -1
  101. package/dist/reconciler/root.js +22 -8
  102. package/dist/reconciler/root.js.map +1 -1
  103. package/dist/reconciler/signals.d.ts +1 -2
  104. package/dist/reconciler/signals.d.ts.map +1 -1
  105. package/dist/reconciler/signals.js +1 -1
  106. package/dist/reconciler/signals.js.map +1 -1
  107. package/dist/utils/accessible-props.d.ts +8 -8
  108. package/dist/utils/accessible-props.d.ts.map +1 -1
  109. package/dist/utils/accessible-props.js +11 -13
  110. package/dist/utils/accessible-props.js.map +1 -1
  111. package/dist/utils/settings.d.ts +2 -1
  112. package/dist/utils/settings.d.ts.map +1 -1
  113. package/dist/utils/settings.js.map +1 -1
  114. package/dist/utils/variant.d.ts +33 -1
  115. package/dist/utils/variant.d.ts.map +1 -1
  116. package/dist/utils/variant.js.map +1 -1
  117. package/package.json +14 -4
  118. package/src/adw/dialog.tsx +25 -25
  119. package/src/adw/element-behaviors.ts +129 -57
  120. package/src/adw/element-config.ts +15 -17
  121. package/src/adw/prop-types.ts +35 -2
  122. package/src/components/application-window.tsx +10 -0
  123. package/src/components/application.tsx +45 -6
  124. package/src/components/element.tsx +52 -16
  125. package/src/components/portaled.tsx +14 -0
  126. package/src/components/window.tsx +24 -23
  127. package/src/config.ts +10 -1
  128. package/src/element-behaviors.ts +20 -0
  129. package/src/element-config.ts +7 -4
  130. package/src/hooks/use-merged-refs.ts +1 -1
  131. package/src/hooks/use-presented-instance.tsx +50 -0
  132. package/src/hooks/use-property.ts +2 -1
  133. package/src/hooks/use-signal.ts +2 -1
  134. package/src/internal.ts +5 -3
  135. package/src/prop-types.ts +34 -7
  136. package/src/reconciler/apply-props.ts +77 -24
  137. package/src/reconciler/behaviors.ts +72 -30
  138. package/src/reconciler/devtools.ts +18 -0
  139. package/src/reconciler/host-config.ts +20 -30
  140. package/src/reconciler/instance.ts +6 -3
  141. package/src/reconciler/metadata.ts +3 -6
  142. package/src/reconciler/node.ts +10 -7
  143. package/src/reconciler/placement.ts +25 -25
  144. package/src/reconciler/registry.ts +9 -7
  145. package/src/reconciler/root-element.ts +4 -1
  146. package/src/reconciler/root.ts +38 -12
  147. package/src/reconciler/signals.ts +0 -1
  148. package/src/utils/accessible-props.ts +21 -24
  149. package/src/utils/settings.ts +2 -1
  150. package/src/utils/variant.ts +33 -1
  151. package/dist/utils/accessible-metadata.d.ts +0 -5
  152. package/dist/utils/accessible-metadata.d.ts.map +0 -1
  153. package/dist/utils/accessible-metadata.js +0 -18
  154. package/dist/utils/accessible-metadata.js.map +0 -1
  155. package/src/utils/accessible-metadata.ts +0 -24
@@ -2,6 +2,7 @@ import type { ErrorInfo, ReactNode, ReactPortal } from "react";
2
2
  import * as Gdk from "@gtkx/gi/gdk";
3
3
  import { createLogger, type Logger } from "@gtkx/utils";
4
4
  import { ConcurrentRoot } from "react-reconciler/constants.js";
5
+ import { injectIntoDevTools } from "./devtools.js";
5
6
  import { type Container, reconciler } from "./host-config.js";
6
7
  import { rootElement } from "./root-element.js";
7
8
 
@@ -15,14 +16,23 @@ type RootErrorCallbacks = {
15
16
 
16
17
  type ReconcilerRootOptions = RootErrorCallbacks & { containerInfo: Container };
17
18
 
19
+ /** A render root whose updates and teardown the caller drives, with error handling left to it. */
18
20
  type ReconcilerRoot = {
21
+ /**
22
+ * Mounts an element tree into the container, or updates the tree already mounted there. Passing `null` unmounts
23
+ * the container instead.
24
+ */
19
25
  update: (element: ReactNode) => void;
26
+ /** Hands the root to `teardown`, then stops {@link quit} from unmounting the container. */
20
27
  unmount: (teardown: (root: ReconcilerRoot) => Promise<void>) => Promise<void>;
21
28
  };
22
29
 
23
30
  /** The object {@link createRoot} returns: it renders an element tree into a container and can tear it down. */
24
31
  type Root = {
25
- /** Mounts an element tree into the container, or updates the tree already mounted there. */
32
+ /**
33
+ * Mounts an element tree into the container, or updates the tree already mounted there. Rendering `null` unmounts
34
+ * the container instead.
35
+ */
26
36
  render: (element: ReactNode) => void;
27
37
  /** Unmounts the rendered tree and runs its effect cleanups. */
28
38
  unmount: () => void;
@@ -61,7 +71,9 @@ const logCaughtRenderError = (error: unknown): void => {
61
71
  };
62
72
 
63
73
  const openContainer = (containerInfo: Container, callbacks: RootErrorCallbacks): OpaqueRoot => {
64
- const container = reconciler.createContainer(
74
+ injectIntoDevTools(reconciler);
75
+
76
+ return reconciler.createContainer(
65
77
  containerInfo,
66
78
  ConcurrentRoot,
67
79
  null,
@@ -81,10 +93,6 @@ const openContainer = (containerInfo: Container, callbacks: RootErrorCallbacks):
81
93
  },
82
94
  (): void => undefined,
83
95
  ) as OpaqueRoot;
84
-
85
- activeRoots.add(container);
86
-
87
- return container;
88
96
  };
89
97
 
90
98
  const unmountContainer = (container: OpaqueRoot): void => {
@@ -92,12 +100,23 @@ const unmountContainer = (container: OpaqueRoot): void => {
92
100
  activeRoots.delete(container);
93
101
  };
94
102
 
103
+ const mountContainer = (container: OpaqueRoot, element: ReactNode): void => {
104
+ if (element === null) {
105
+ unmountContainer(container);
106
+
107
+ return;
108
+ }
109
+
110
+ activeRoots.add(container);
111
+ reconciler.updateContainer(element, container, null, null);
112
+ };
113
+
95
114
  const createReconcilerRoot = (options: ReconcilerRootOptions): ReconcilerRoot => {
96
115
  const container = openContainer(options.containerInfo, options);
97
116
 
98
117
  const root: ReconcilerRoot = {
99
118
  update: (element) => {
100
- reconciler.updateContainer(element, container, null, null);
119
+ mountContainer(container, element);
101
120
  },
102
121
  unmount: async (teardown) => {
103
122
  await teardown(root);
@@ -122,7 +141,7 @@ const createRoot = (container: Container = rootElement): Root => {
122
141
 
123
142
  return {
124
143
  render: (element) => {
125
- reconciler.updateContainer(element, opaque, null, null);
144
+ mountContainer(opaque, element);
126
145
  },
127
146
  unmount: () => {
128
147
  unmountContainer(opaque);
@@ -130,13 +149,20 @@ const createRoot = (container: Container = rootElement): Root => {
130
149
  };
131
150
  };
132
151
 
133
- /** Unmounts every active render root and stops the originating signal from propagating further. */
134
- const quit = (): typeof Gdk.EVENT_STOP => {
135
- for (const container of activeRoots) {
152
+ /**
153
+ * Unmounts every render root that currently holds a mounted tree.
154
+ *
155
+ * @returns `Gdk.EVENT_STOP` when at least one root came down, so a close-request handler keeps GTK4 from closing the
156
+ * window itself, and `Gdk.EVENT_PROPAGATE` when there was nothing to unmount, so the default handler still runs.
157
+ */
158
+ const quit = (): typeof Gdk.EVENT_PROPAGATE | typeof Gdk.EVENT_STOP => {
159
+ const containers = [...activeRoots];
160
+
161
+ for (const container of containers) {
136
162
  unmountContainer(container);
137
163
  }
138
164
 
139
- return Gdk.EVENT_STOP;
165
+ return containers.length > 0 ? Gdk.EVENT_STOP : Gdk.EVENT_PROPAGATE;
140
166
  };
141
167
 
142
168
  /**
@@ -85,7 +85,6 @@ const disconnectAllHandlers = (target: SignalTarget): void => {
85
85
 
86
86
  export {
87
87
  applyWrite,
88
- isApplyingWrite,
89
88
  connectHandler,
90
89
  disconnectHandler,
91
90
  disconnectAllHandlers,
@@ -1,7 +1,6 @@
1
1
  import * as GObject from "@gtkx/gi/gobject";
2
2
  import * as Gtk from "@gtkx/gi/gtk";
3
3
  import type { Props } from "../reconciler/registry.js";
4
- import { deleteAccessibleMetadata, setAccessibleMetadata } from "./accessible-metadata.js";
5
4
 
6
5
  /**
7
6
  * Accessibility props available on every widget. Each member maps to a GTK4 accessible attribute
@@ -69,7 +68,7 @@ type AccessibleProps = {
69
68
  /** Whether the link has already been followed. */
70
69
  accessibleVisited?: boolean | null | undefined;
71
70
  /** Descendant that holds the focus while the widget itself keeps it. */
72
- accessibleActiveDescendant?: Gtk.Widget | null | undefined;
71
+ accessibleActiveDescendant?: Gtk.Accessible | null | undefined;
73
72
  /** Total number of columns in the table, including any that are not rendered. */
74
73
  accessibleColCount?: number | null | undefined;
75
74
  /** One-based column position of the cell within its table. */
@@ -79,19 +78,19 @@ type AccessibleProps = {
79
78
  /** Number of columns the cell spans. */
80
79
  accessibleColSpan?: number | null | undefined;
81
80
  /** Widgets whose content or presence this widget controls. */
82
- accessibleControls?: Gtk.Widget[] | null | undefined;
81
+ accessibleControls?: Gtk.Accessible[] | null | undefined;
83
82
  /** Widgets that describe this one. */
84
- accessibleDescribedBy?: Gtk.Widget[] | null | undefined;
83
+ accessibleDescribedBy?: Gtk.Accessible[] | null | undefined;
85
84
  /** Widgets holding extended detail about this one. */
86
- accessibleDetails?: Gtk.Widget[] | null | undefined;
85
+ accessibleDetails?: Gtk.Accessible[] | null | undefined;
87
86
  /** Widgets holding the message that explains why the value is invalid. */
88
- accessibleErrorMessage?: Gtk.Widget[] | null | undefined;
87
+ accessibleErrorMessage?: Gtk.Accessible[] | null | undefined;
89
88
  /** Widgets to read next, overriding the default reading order. */
90
- accessibleFlowTo?: Gtk.Widget[] | null | undefined;
89
+ accessibleFlowTo?: Gtk.Accessible[] | null | undefined;
91
90
  /** Widgets that label this one. */
92
- accessibleLabelledBy?: Gtk.Widget[] | null | undefined;
91
+ accessibleLabelledBy?: Gtk.Accessible[] | null | undefined;
93
92
  /** Widgets this one owns that the widget hierarchy does not already imply. */
94
- accessibleOwns?: Gtk.Widget[] | null | undefined;
93
+ accessibleOwns?: Gtk.Accessible[] | null | undefined;
95
94
  /** One-based position of the widget within its set. */
96
95
  accessiblePosInSet?: number | null | undefined;
97
96
  /** Total number of rows in the table, including any that are not rendered. */
@@ -106,7 +105,7 @@ type AccessibleProps = {
106
105
  accessibleSetSize?: number | null | undefined;
107
106
  };
108
107
 
109
- type AccessibleValueType = "string" | "boolean" | "int" | "double" | "object" | "list";
108
+ type AccessibleValueType = "string" | "boolean" | "optionalBoolean" | "int" | "double" | "object" | "list";
110
109
 
111
110
  type AccessiblePropertyDescriptor = {
112
111
  kind: "property";
@@ -152,12 +151,12 @@ const ACCESSIBLE_PROP_MAP: Record<keyof AccessibleProps, AccessibleDescriptor> =
152
151
  accessibleBusy: buildState(Gtk.AccessibleState.BUSY, "boolean"),
153
152
  accessibleChecked: buildState(Gtk.AccessibleState.CHECKED, "int"),
154
153
  accessibleDisabled: buildState(Gtk.AccessibleState.DISABLED, "boolean"),
155
- accessibleExpanded: buildState(Gtk.AccessibleState.EXPANDED, "int"),
154
+ accessibleExpanded: buildState(Gtk.AccessibleState.EXPANDED, "optionalBoolean"),
156
155
  accessibleHidden: buildState(Gtk.AccessibleState.HIDDEN, "boolean"),
157
156
  accessibleInvalid: buildState(Gtk.AccessibleState.INVALID, "int"),
158
157
  accessiblePressed: buildState(Gtk.AccessibleState.PRESSED, "int"),
159
- accessibleSelected: buildState(Gtk.AccessibleState.SELECTED, "int"),
160
- accessibleVisited: buildState(Gtk.AccessibleState.VISITED, "int"),
158
+ accessibleSelected: buildState(Gtk.AccessibleState.SELECTED, "optionalBoolean"),
159
+ accessibleVisited: buildState(Gtk.AccessibleState.VISITED, "optionalBoolean"),
161
160
  accessibleActiveDescendant: buildRelation(Gtk.AccessibleRelation.ACTIVE_DESCENDANT, "object"),
162
161
  accessibleColCount: buildRelation(Gtk.AccessibleRelation.COL_COUNT, "int"),
163
162
  accessibleColIndex: buildRelation(Gtk.AccessibleRelation.COL_INDEX, "int"),
@@ -214,6 +213,11 @@ const buildValue = (descriptor: AccessibleDescriptor, jsValue: unknown): GObject
214
213
  v.setBoolean(jsValue as boolean);
215
214
  });
216
215
  }
216
+ case "optionalBoolean": {
217
+ return GObject.buildValue(GObject.TYPE_INT, (v) => {
218
+ v.setInt(jsValue === true ? 1 : 0);
219
+ });
220
+ }
217
221
  case "int": {
218
222
  return GObject.buildValue(GObject.TYPE_INT, (v) => {
219
223
  v.setInt(jsValue as number);
@@ -230,7 +234,7 @@ const buildValue = (descriptor: AccessibleDescriptor, jsValue: unknown): GObject
230
234
  });
231
235
  }
232
236
  case "list": {
233
- const list = Gtk.AccessibleList.newFromList(jsValue as Gtk.Widget[]);
237
+ const list = Gtk.AccessibleList.newFromList(jsValue as Gtk.Accessible[]);
234
238
 
235
239
  return GObject.buildValue(Gtk.AccessibleList.prototype.__type__, (v) => {
236
240
  v.setBoxed(list);
@@ -281,24 +285,18 @@ function resetDescriptor(widget: Gtk.Accessible, descriptor: AccessibleDescripto
281
285
  const applyChangedProp = (widget: Gtk.Accessible, name: keyof AccessibleProps, newValue: unknown): void => {
282
286
  if (newValue == null) {
283
287
  resetDescriptor(widget, ACCESSIBLE_PROP_MAP[name]);
284
- deleteAccessibleMetadata(widget, name);
285
288
  } else {
286
289
  applyDescriptor(widget, ACCESSIBLE_PROP_MAP[name], newValue);
287
- setAccessibleMetadata(widget, name, newValue);
288
290
  }
289
291
  };
290
292
 
291
- const applyChangedProps = (widget: Gtk.Accessible, oldProps: Props | null, newProps: Props): void => {
293
+ const applyChangedProps = (widget: Gtk.Accessible, newProps: Props): void => {
292
294
  for (const name in newProps) {
293
295
  if (!isAccessibleProp(name)) {
294
296
  continue;
295
297
  }
296
298
 
297
- const newValue = newProps[name];
298
-
299
- if (oldProps?.[name] !== newValue) {
300
- applyChangedProp(widget, name, newValue);
301
- }
299
+ applyChangedProp(widget, name, newProps[name]);
302
300
  }
303
301
  };
304
302
 
@@ -312,12 +310,11 @@ const resetRemovedProps = (widget: Gtk.Accessible, oldProps: Props, newProps: Pr
312
310
  }
313
311
 
314
312
  resetDescriptor(widget, ACCESSIBLE_PROP_MAP[name]);
315
- deleteAccessibleMetadata(widget, name);
316
313
  }
317
314
  };
318
315
 
319
316
  const applyAccessibleProps = (widget: Gtk.Accessible, oldProps: Props | null, newProps: Props): void => {
320
- applyChangedProps(widget, oldProps, newProps);
317
+ applyChangedProps(widget, newProps);
321
318
 
322
319
  if (oldProps) {
323
320
  resetRemovedProps(widget, oldProps, newProps);
@@ -3,8 +3,9 @@ import { packVariant, parseVariantType, unpackVariant, type VariantValue } from
3
3
 
4
4
  /** Maps each key of a GSettings schema to its kind: a GVariant type string, or `enum` or `flags`. */
5
5
  type SettingsSchemaKeys = Record<string, string>;
6
+ /** Value type a key kind stands for: `number` for `enum` and `flags`, otherwise the unpacked GVariant. */
6
7
  type SettingKindValue<S extends string> = S extends "enum" | "flags" ? number : VariantValue<S>;
7
- /** The JavaScript type key `P` holds: `number` for `enum` and `flags`, otherwise the unpacked GVariant. */
8
+ /** Value type of key `P`, looked up by its kind in schema `K`, that reads and writes of that key take. */
8
9
  type SettingValue<K extends SettingsSchemaKeys, P extends keyof K> = SettingKindValue<K[P] & string>;
9
10
 
10
11
  /** A GSettings schema, as described by the modules GTKX generates from a project's `.gschema.xml` files. */
@@ -1,26 +1,45 @@
1
1
  import * as GLib from "@gtkx/gi/glib";
2
2
 
3
+ /** JavaScript type every GVariant basic type code unpacks to. */
3
4
  type BasicValueMap = {
5
+ /** Boolean, held as a single byte reading 0 or 1. */
4
6
  b: boolean;
7
+ /** Unsigned byte. */
5
8
  y: number;
9
+ /** Signed 16-bit integer. */
6
10
  n: number;
11
+ /** Unsigned 16-bit integer. */
7
12
  q: number;
13
+ /** Signed 32-bit integer. */
8
14
  i: number;
15
+ /** Unsigned 32-bit integer. */
9
16
  u: number;
17
+ /** Index into the file descriptor list a message carries. */
10
18
  h: number;
19
+ /** Double precision floating point number. */
11
20
  d: number;
21
+ /** Signed 64-bit integer. */
12
22
  x: bigint;
23
+ /** Unsigned 64-bit integer. */
13
24
  t: bigint;
25
+ /** UTF-8 string, under no further constraint on what it holds. */
14
26
  s: string;
27
+ /** D-Bus object path. */
15
28
  o: string;
29
+ /** GVariant type signature. */
16
30
  g: string;
31
+ /** Boxed variant holding a value of any type. */
17
32
  v: GLib.Variant;
18
33
  };
19
34
 
35
+ /** Single-character code of one of the GVariant basic types in {@link BasicValueMap}. */
20
36
  type BasicCode = keyof BasicValueMap;
37
+ /** Parses the element type of an array, yielding the array type it produces and the rest of the string. */
21
38
  type ParseArray<S extends string> = Parse<S> extends [infer V, infer R extends string] ? [V[], R] : never;
39
+ /** Parses the element type of a maybe, yielding the nullable type it produces and the rest of the string. */
22
40
  type ParseMaybe<S extends string> = Parse<S> extends [infer V, infer R extends string] ? [V | null, R] : never;
23
41
 
42
+ /** Collects tuple member types into `Acc` up to the closing parenthesis, yielding them and the rest of the string. */
24
43
  type ParseTuple<S extends string, Acc extends unknown[]> = S extends `)${infer Rest}`
25
44
  ? [Acc, Rest]
26
45
  : [Parse<S>] extends [never]
@@ -29,8 +48,10 @@ type ParseTuple<S extends string, Acc extends unknown[]> = S extends `)${infer R
29
48
  ? ParseTuple<R, [...Acc, V]>
30
49
  : never;
31
50
 
51
+ /** Types a dictionary entry key can hold. */
32
52
  type DictKey = string | number | bigint | boolean;
33
53
 
54
+ /** Parses the key and value types of a dictionary entry, yielding them and the rest of the string after its brace. */
34
55
  type ParsePair<S extends string> =
35
56
  Parse<S> extends [infer K, infer R1 extends string]
36
57
  ? Parse<R1> extends [infer V, infer R2 extends string]
@@ -42,16 +63,26 @@ type ParsePair<S extends string> =
42
63
  : never
43
64
  : never;
44
65
 
66
+ /**
67
+ * Parses a dictionary entry into the collection an array of those entries unpacks to, a record for string keys and a
68
+ * `Map` otherwise, plus the rest of the string.
69
+ */
45
70
  type ParseDict<S extends string> =
46
71
  ParsePair<S> extends [infer K, infer V, infer R extends string]
47
72
  ? [[K] extends [string] ? Record<string, V> : Map<K, V>, R]
48
73
  : never;
49
74
 
75
+ /** Parses a standalone dictionary entry into a key and value pair, yielding it and the rest of the string. */
50
76
  type ParseEntry<S extends string> =
51
77
  ParsePair<S> extends [infer K, infer V, infer R extends string] ? [[K, V], R] : never;
52
78
 
79
+ /** Parses what follows an `a` as a dictionary when it opens an entry, and as a plain array otherwise. */
53
80
  type ParseArrayOrDict<S extends string> = S extends `{${infer Rest}` ? ParseDict<Rest> : ParseArray<S>;
54
81
 
82
+ /**
83
+ * Parses the type at the head of `S`, yielding the JavaScript type it unpacks to and the rest of the string, or
84
+ * `never` when the string is malformed.
85
+ */
55
86
  type Parse<S extends string> = S extends `a${infer Rest}`
56
87
  ? ParseArrayOrDict<Rest>
57
88
  : S extends `m${infer Rest}`
@@ -66,6 +97,7 @@ type Parse<S extends string> = S extends `a${infer Rest}`
66
97
  : never
67
98
  : never;
68
99
 
100
+ /** JavaScript type a variant of type string `S` unpacks to, or `unknown` when `S` is not one complete type. */
69
101
  type VariantValue<S extends string> = [Parse<S>] extends [never]
70
102
  ? unknown
71
103
  : Parse<S> extends [infer V, ""]
@@ -365,4 +397,4 @@ const packVariant = (node: VariantTypeNode, value: unknown): GLib.Variant => {
365
397
  }
366
398
  };
367
399
 
368
- export { parseVariantType, unpackVariant, packVariant, type VariantValue, type VariantTypeNode };
400
+ export { parseVariantType, unpackVariant, packVariant, type VariantValue };
@@ -1,5 +0,0 @@
1
- declare const setAccessibleMetadata: (widget: object, name: string, value: unknown) => void;
2
- declare const deleteAccessibleMetadata: (widget: object, name: string) => void;
3
- declare const getAccessibleMetadata: (widget: object, name: string) => unknown;
4
- export { setAccessibleMetadata, deleteAccessibleMetadata, getAccessibleMetadata };
5
- //# sourceMappingURL=accessible-metadata.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"accessible-metadata.d.ts","sourceRoot":"","sources":["../../src/utils/accessible-metadata.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,qBAAqB,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,EAAE,OAAO,OAAO,KAAG,IAS7E,CAAC;AAEF,QAAA,MAAM,wBAAwB,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,IAEhE,CAAC;AAEF,QAAA,MAAM,qBAAqB,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,OAI7D,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,CAAC"}
@@ -1,18 +0,0 @@
1
- const metadataStore = new WeakMap();
2
- const setAccessibleMetadata = (widget, name, value) => {
3
- let entries = metadataStore.get(widget);
4
- if (entries === undefined) {
5
- entries = new Map();
6
- metadataStore.set(widget, entries);
7
- }
8
- entries.set(name, value);
9
- };
10
- const deleteAccessibleMetadata = (widget, name) => {
11
- metadataStore.get(widget)?.delete(name);
12
- };
13
- const getAccessibleMetadata = (widget, name) => {
14
- const value = metadataStore.get(widget)?.get(name);
15
- return value === undefined ? null : value;
16
- };
17
- export { setAccessibleMetadata, deleteAccessibleMetadata, getAccessibleMetadata };
18
- //# sourceMappingURL=accessible-metadata.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"accessible-metadata.js","sourceRoot":"","sources":["../../src/utils/accessible-metadata.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAA0C,IAAI,OAAO,EAAE,CAAC;AAE3E,MAAM,qBAAqB,GAAG,CAAC,MAAc,EAAE,IAAY,EAAE,KAAc,EAAQ,EAAE;IACjF,IAAI,OAAO,GAAG,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAExC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACpB,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC7B,CAAC,CAAC;AAEF,MAAM,wBAAwB,GAAG,CAAC,MAAc,EAAE,IAAY,EAAQ,EAAE;IACpE,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,MAAc,EAAE,IAAY,EAAW,EAAE;IACpE,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IAEnD,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["const metadataStore: WeakMap<object, Map<string, unknown>> = new WeakMap();\n\nconst setAccessibleMetadata = (widget: object, name: string, value: unknown): void => {\n let entries = metadataStore.get(widget);\n\n if (entries === undefined) {\n entries = new Map();\n metadataStore.set(widget, entries);\n }\n\n entries.set(name, value);\n};\n\nconst deleteAccessibleMetadata = (widget: object, name: string): void => {\n metadataStore.get(widget)?.delete(name);\n};\n\nconst getAccessibleMetadata = (widget: object, name: string): unknown => {\n const value = metadataStore.get(widget)?.get(name);\n\n return value === undefined ? null : value;\n};\n\nexport { setAccessibleMetadata, deleteAccessibleMetadata, getAccessibleMetadata };\n"]}
@@ -1,24 +0,0 @@
1
- const metadataStore: WeakMap<object, Map<string, unknown>> = new WeakMap();
2
-
3
- const setAccessibleMetadata = (widget: object, name: string, value: unknown): void => {
4
- let entries = metadataStore.get(widget);
5
-
6
- if (entries === undefined) {
7
- entries = new Map();
8
- metadataStore.set(widget, entries);
9
- }
10
-
11
- entries.set(name, value);
12
- };
13
-
14
- const deleteAccessibleMetadata = (widget: object, name: string): void => {
15
- metadataStore.get(widget)?.delete(name);
16
- };
17
-
18
- const getAccessibleMetadata = (widget: object, name: string): unknown => {
19
- const value = metadataStore.get(widget)?.get(name);
20
-
21
- return value === undefined ? null : value;
22
- };
23
-
24
- export { setAccessibleMetadata, deleteAccessibleMetadata, getAccessibleMetadata };