@gtkx/runtime 1.2.2 → 1.4.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 (101) hide show
  1. package/README.md +6 -4
  2. package/dist/arg.d.ts +6 -1
  3. package/dist/arg.d.ts.map +1 -1
  4. package/dist/arg.js +2 -1
  5. package/dist/arg.js.map +1 -1
  6. package/dist/closure.d.ts.map +1 -1
  7. package/dist/closure.js +2 -11
  8. package/dist/closure.js.map +1 -1
  9. package/dist/descriptors.d.ts +21 -3
  10. package/dist/descriptors.d.ts.map +1 -1
  11. package/dist/descriptors.js +50 -21
  12. package/dist/descriptors.js.map +1 -1
  13. package/dist/field.d.ts +42 -0
  14. package/dist/field.d.ts.map +1 -0
  15. package/dist/field.js +41 -0
  16. package/dist/field.js.map +1 -0
  17. package/dist/fn.d.ts +2 -0
  18. package/dist/fn.d.ts.map +1 -1
  19. package/dist/fn.js +50 -10
  20. package/dist/fn.js.map +1 -1
  21. package/dist/index.d.ts +14 -6
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +13 -5
  24. package/dist/index.js.map +1 -1
  25. package/dist/mixin.d.ts +2 -1
  26. package/dist/mixin.d.ts.map +1 -1
  27. package/dist/mixin.js +1 -1
  28. package/dist/mixin.js.map +1 -1
  29. package/dist/native-value.d.ts +9 -3
  30. package/dist/native-value.d.ts.map +1 -1
  31. package/dist/native-value.js +86 -9
  32. package/dist/native-value.js.map +1 -1
  33. package/dist/object.d.ts +14 -6
  34. package/dist/object.d.ts.map +1 -1
  35. package/dist/object.js +21 -10
  36. package/dist/object.js.map +1 -1
  37. package/dist/param-spec.d.ts +32 -1
  38. package/dist/param-spec.d.ts.map +1 -1
  39. package/dist/param-spec.js +67 -5
  40. package/dist/param-spec.js.map +1 -1
  41. package/dist/promisify.d.ts +13 -1
  42. package/dist/promisify.d.ts.map +1 -1
  43. package/dist/promisify.js +14 -1
  44. package/dist/promisify.js.map +1 -1
  45. package/dist/properties.d.ts +48 -5
  46. package/dist/properties.d.ts.map +1 -1
  47. package/dist/properties.js +191 -20
  48. package/dist/properties.js.map +1 -1
  49. package/dist/regex.d.ts +25 -0
  50. package/dist/regex.d.ts.map +1 -0
  51. package/dist/regex.js +59 -0
  52. package/dist/regex.js.map +1 -0
  53. package/dist/register-class.d.ts +165 -15
  54. package/dist/register-class.d.ts.map +1 -1
  55. package/dist/register-class.js +175 -19
  56. package/dist/register-class.js.map +1 -1
  57. package/dist/registry.d.ts +48 -4
  58. package/dist/registry.d.ts.map +1 -1
  59. package/dist/registry.js +147 -3
  60. package/dist/registry.js.map +1 -1
  61. package/dist/signal.d.ts +11 -1
  62. package/dist/signal.d.ts.map +1 -1
  63. package/dist/signal.js +66 -6
  64. package/dist/signal.js.map +1 -1
  65. package/dist/t.d.ts +11 -0
  66. package/dist/t.d.ts.map +1 -1
  67. package/dist/t.js +3 -0
  68. package/dist/t.js.map +1 -1
  69. package/dist/type.d.ts +2 -1
  70. package/dist/type.d.ts.map +1 -1
  71. package/dist/type.js +5 -1
  72. package/dist/type.js.map +1 -1
  73. package/dist/value.d.ts +48 -4
  74. package/dist/value.d.ts.map +1 -1
  75. package/dist/value.js +172 -16
  76. package/dist/value.js.map +1 -1
  77. package/dist/variant.d.ts +75 -26
  78. package/dist/variant.d.ts.map +1 -1
  79. package/dist/variant.js +44 -29
  80. package/dist/variant.js.map +1 -1
  81. package/package.json +5 -5
  82. package/src/arg.ts +6 -1
  83. package/src/closure.ts +2 -14
  84. package/src/descriptors.ts +74 -21
  85. package/src/field.ts +76 -0
  86. package/src/fn.ts +73 -17
  87. package/src/index.ts +46 -5
  88. package/src/mixin.ts +1 -1
  89. package/src/native-value.ts +146 -14
  90. package/src/object.ts +23 -11
  91. package/src/param-spec.ts +96 -8
  92. package/src/promisify.ts +27 -1
  93. package/src/properties.ts +280 -32
  94. package/src/regex.ts +92 -0
  95. package/src/register-class.ts +485 -42
  96. package/src/registry.ts +219 -4
  97. package/src/signal.ts +117 -4
  98. package/src/t.ts +13 -0
  99. package/src/type.ts +7 -0
  100. package/src/value.ts +268 -14
  101. package/src/variant.ts +184 -53
package/src/variant.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as GLib from "@gtkx/gi/glib";
2
2
 
3
- /** JavaScript type every GVariant basic type code unpacks to. */
4
- type BasicValueMap = {
3
+ /** JavaScript type every GVariant basic type code unpacks to, with a nested variant held as `Nested`. */
4
+ type BasicValueMap<Nested> = {
5
5
  /** Boolean, held as a single byte reading 0 or 1. */
6
6
  b: boolean;
7
7
  /** Unsigned byte. */
@@ -29,32 +29,49 @@ type BasicValueMap = {
29
29
  /** GVariant type signature. */
30
30
  g: string;
31
31
  /** Boxed variant holding a value of any type. */
32
- v: GLib.Variant;
32
+ v: Nested;
33
33
  };
34
34
 
35
35
  /** Single-character code of one of the GVariant basic types in {@link BasicValueMap}. */
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. */
38
- type ParseArray<S extends string> = Parse<S> extends [infer V, infer R extends string] ? [V[], R] : never;
36
+ type BasicCode = keyof BasicValueMap<unknown>;
37
+ /**
38
+ * JavaScript type a byte array (`ay`) unpacks to: the same one the generated bindings use for byte sequences, so a
39
+ * `Uint8Array` under the `v2ByteArrays` future flag and a `number[]` otherwise.
40
+ */
41
+ type ByteArray = ReturnType<GLib.Bytes["unrefToArray"]>;
42
+ /** Values a byte array (`ay`) packs from. */
43
+ type ByteArrayInput = Uint8Array | number[];
44
+
45
+ /**
46
+ * Parses the element type of an array, yielding the array type it produces and the rest of the string. An array of
47
+ * bytes yields the byte array type instead of `number[]`.
48
+ */
49
+ type ParseArray<S extends string, Bytes, Nested> = S extends `y${infer Rest}`
50
+ ? [Bytes, Rest]
51
+ : Parse<S, Bytes, Nested> extends [infer V, infer R extends string]
52
+ ? [V[], R]
53
+ : never;
54
+
39
55
  /** Parses the element type of a maybe, yielding the nullable type it produces and the rest of the string. */
40
- type ParseMaybe<S extends string> = Parse<S> extends [infer V, infer R extends string] ? [V | null, R] : never;
56
+ type ParseMaybe<S extends string, Bytes, Nested> =
57
+ Parse<S, Bytes, Nested> extends [infer V, infer R extends string] ? [V | null, R] : never;
41
58
 
42
59
  /** Collects tuple member types into `Acc` up to the closing parenthesis, yielding them and the rest of the string. */
43
- type ParseTuple<S extends string, Acc extends unknown[]> = S extends `)${infer Rest}`
60
+ type ParseTuple<S extends string, Bytes, Nested, Acc extends unknown[]> = S extends `)${infer Rest}`
44
61
  ? [Acc, Rest]
45
- : [Parse<S>] extends [never]
62
+ : [Parse<S, Bytes, Nested>] extends [never]
46
63
  ? never
47
- : Parse<S> extends [infer V, infer R extends string]
48
- ? ParseTuple<R, [...Acc, V]>
64
+ : Parse<S, Bytes, Nested> extends [infer V, infer R extends string]
65
+ ? ParseTuple<R, Bytes, Nested, [...Acc, V]>
49
66
  : never;
50
67
 
51
68
  /** Types a dictionary entry key can hold. */
52
69
  type DictKey = string | number | bigint | boolean;
53
70
 
54
71
  /** Parses the key and value types of a dictionary entry, yielding them and the rest of the string after its brace. */
55
- type ParsePair<S extends string> =
56
- Parse<S> extends [infer K, infer R1 extends string]
57
- ? Parse<R1> extends [infer V, infer R2 extends string]
72
+ type ParsePair<S extends string, Bytes, Nested> =
73
+ Parse<S, Bytes, Nested> extends [infer K, infer R1 extends string]
74
+ ? Parse<R1, Bytes, Nested> extends [infer V, infer R2 extends string]
58
75
  ? R2 extends `}${infer R3}`
59
76
  ? [K] extends [DictKey]
60
77
  ? [K, V, R3]
@@ -67,43 +84,76 @@ type ParsePair<S extends string> =
67
84
  * Parses a dictionary entry into the collection an array of those entries unpacks to, a record for string keys and a
68
85
  * `Map` otherwise, plus the rest of the string.
69
86
  */
70
- type ParseDict<S extends string> =
71
- ParsePair<S> extends [infer K, infer V, infer R extends string]
87
+ type ParseDict<S extends string, Bytes, Nested> =
88
+ ParsePair<S, Bytes, Nested> extends [infer K, infer V, infer R extends string]
72
89
  ? [[K] extends [string] ? Record<string, V> : Map<K, V>, R]
73
90
  : never;
74
91
 
75
92
  /** Parses a standalone dictionary entry into a key and value pair, yielding it and the rest of the string. */
76
- type ParseEntry<S extends string> =
77
- ParsePair<S> extends [infer K, infer V, infer R extends string] ? [[K, V], R] : never;
93
+ type ParseEntry<S extends string, Bytes, Nested> =
94
+ ParsePair<S, Bytes, Nested> extends [infer K, infer V, infer R extends string] ? [[K, V], R] : never;
78
95
 
79
96
  /** Parses what follows an `a` as a dictionary when it opens an entry, and as a plain array otherwise. */
80
- type ParseArrayOrDict<S extends string> = S extends `{${infer Rest}` ? ParseDict<Rest> : ParseArray<S>;
97
+ type ParseArrayOrDict<S extends string, Bytes, Nested> = S extends `{${infer Rest}`
98
+ ? ParseDict<Rest, Bytes, Nested>
99
+ : ParseArray<S, Bytes, Nested>;
81
100
 
82
101
  /**
83
102
  * Parses the type at the head of `S`, yielding the JavaScript type it unpacks to and the rest of the string, or
84
103
  * `never` when the string is malformed.
85
104
  */
86
- type Parse<S extends string> = S extends `a${infer Rest}`
87
- ? ParseArrayOrDict<Rest>
105
+ type Parse<S extends string, Bytes, Nested> = S extends `a${infer Rest}`
106
+ ? ParseArrayOrDict<Rest, Bytes, Nested>
88
107
  : S extends `m${infer Rest}`
89
- ? ParseMaybe<Rest>
108
+ ? ParseMaybe<Rest, Bytes, Nested>
90
109
  : S extends `(${infer Rest}`
91
- ? ParseTuple<Rest, []>
110
+ ? ParseTuple<Rest, Bytes, Nested, []>
92
111
  : S extends `{${infer Rest}`
93
- ? ParseEntry<Rest>
112
+ ? ParseEntry<Rest, Bytes, Nested>
94
113
  : S extends `${infer C}${infer Rest}`
95
114
  ? C extends BasicCode
96
- ? [BasicValueMap[C], Rest]
115
+ ? [BasicValueMap<Nested>[C], Rest]
97
116
  : never
98
117
  : never;
99
118
 
100
- /** JavaScript type a variant of type string `S` unpacks to, or `unknown` when `S` is not one complete type. */
101
- type VariantValue<S extends string> = [Parse<S>] extends [never]
119
+ /** JavaScript type a type string `S` describes, or `unknown` when `S` is not one complete type. */
120
+ type ParsedValue<S extends string, Bytes, Nested> = [Parse<S, Bytes, Nested>] extends [never]
102
121
  ? unknown
103
- : Parse<S> extends [infer V, ""]
122
+ : Parse<S, Bytes, Nested> extends [infer V, ""]
104
123
  ? V
105
124
  : unknown;
106
125
 
126
+ /**
127
+ * JavaScript type a variant of type string `S` unpacks to, or `unknown` when `S` is not one complete type. A byte
128
+ * array (`ay`) unpacks to {@link ByteArray} and a nested variant (`v`) to the `GLib.Variant` itself.
129
+ */
130
+ type VariantValue<S extends string> = ParsedValue<S, ByteArray, GLib.Variant>;
131
+ /**
132
+ * JavaScript type {@link toVariant} packs into a variant of type string `S`, or `unknown` when `S` is not one
133
+ * complete type. The same as {@link VariantValue}, except that a byte array (`ay`) also packs from a `number[]`.
134
+ */
135
+ type VariantInput<S extends string> = ParsedValue<S, ByteArrayInput, GLib.Variant>;
136
+ /**
137
+ * JavaScript type a variant of type string `S` unpacks to when every nested variant is unwrapped as well, so a `v`
138
+ * reads as `unknown`.
139
+ */
140
+ type RecursiveVariantValue<S extends string> = ParsedValue<S, ByteArray, unknown>;
141
+
142
+ /** Options {@link fromVariant} reads. */
143
+ type FromVariantOptions = {
144
+ /**
145
+ * Whether to unwrap every nested variant (`v`) into the value it holds, all the way down, instead of handing back
146
+ * the `GLib.Variant` itself. Discards the type information those variants carry.
147
+ */
148
+ recursive?: boolean;
149
+ };
150
+
151
+ /** {@link FromVariantOptions} with recursive unwrapping selected, typing the result accordingly. */
152
+ type RecursiveFromVariantOptions = {
153
+ /** Unwraps every nested variant (`v`) into the value it holds, all the way down. */
154
+ recursive: true;
155
+ };
156
+
107
157
  type VariantTypeNode =
108
158
  | { kind: "basic"; code: BasicCode } |
109
159
  { kind: "array"; elementTypeString: string; element: VariantTypeNode } |
@@ -123,6 +173,7 @@ const CONTAINER_PARSERS: Record<string, (source: string, start: number) => [Vari
123
173
  };
124
174
 
125
175
  const parsedTypes: Map<string, VariantTypeNode> = new Map();
176
+ const BYTE_ARRAY_TYPE_STRING = "ay";
126
177
 
127
178
  const unpackBasic: Record<BasicCode, (variant: GLib.Variant) => unknown> = {
128
179
  b: (variant) => variant.getBoolean(),
@@ -257,6 +308,9 @@ const parseVariantType = (typeString: string): VariantTypeNode => {
257
308
  return node;
258
309
  };
259
310
 
311
+ const isByteArray = (node: VariantTypeNode): boolean =>
312
+ node.kind === "array" && node.element.kind === "basic" && node.element.code === "y";
313
+
260
314
  const unpackChildren = (variant: GLib.Variant, unpackChild: (child: GLib.Variant) => unknown): unknown[] => {
261
315
  const children: unknown[] = [];
262
316
  const count = variant.nChildren();
@@ -268,16 +322,25 @@ const unpackChildren = (variant: GLib.Variant, unpackChild: (child: GLib.Variant
268
322
  return children;
269
323
  };
270
324
 
271
- const unpackPair = (key: VariantTypeNode, value: VariantTypeNode, entry: GLib.Variant): [unknown, unknown] => [
272
- unpackNode(key, entry.getChildValue(0)),
273
- unpackNode(value, entry.getChildValue(1)),
325
+ const unpackPair = (
326
+ key: VariantTypeNode,
327
+ value: VariantTypeNode,
328
+ entry: GLib.Variant,
329
+ isRecursive: boolean,
330
+ ): [unknown, unknown] => [
331
+ unpackNode(key, entry.getChildValue(0), isRecursive),
332
+ unpackNode(value, entry.getChildValue(1), isRecursive),
274
333
  ];
275
334
 
276
335
  const unpackDict = (
277
336
  node: { key: VariantTypeNode; value: VariantTypeNode },
278
337
  variant: GLib.Variant,
338
+ isRecursive: boolean,
279
339
  ): Record<string, unknown> | Map<unknown, unknown> => {
280
- const entries = unpackChildren(variant, (entry) => unpackPair(node.key, node.value, entry)) as [unknown, unknown][];
340
+ const entries = unpackChildren(variant, (entry) => unpackPair(node.key, node.value, entry, isRecursive)) as [
341
+ unknown,
342
+ unknown,
343
+ ][];
281
344
 
282
345
  if (!isStringKeyed(node.key)) {
283
346
  return new Map(entries);
@@ -288,31 +351,39 @@ const unpackDict = (
288
351
  return Object.fromEntries(stringEntries);
289
352
  };
290
353
 
291
- const unpackMaybe = (element: VariantTypeNode, variant: GLib.Variant): unknown => {
354
+ const unpackMaybe = (element: VariantTypeNode, variant: GLib.Variant, isRecursive: boolean): unknown => {
292
355
  const child = variant.getMaybe();
293
356
 
294
- return child === null ? null : unpackNode(element, child);
357
+ return child === null ? null : unpackNode(element, child, isRecursive);
295
358
  };
296
359
 
297
- const unpackNode = (node: VariantTypeNode, variant: GLib.Variant): unknown => {
360
+ const unpackNested = (variant: GLib.Variant, isRecursive: boolean): unknown => {
361
+ const held = variant.getVariant();
362
+
363
+ return isRecursive ? unpackNode(parseVariantType(held.getTypeString()), held, true) : held;
364
+ };
365
+
366
+ const unpackNode = (node: VariantTypeNode, variant: GLib.Variant, isRecursive: boolean): unknown => {
298
367
  switch (node.kind) {
299
368
  case "basic": {
300
- return unpackBasic[node.code](variant);
369
+ return node.code === "v" ? unpackNested(variant, isRecursive) : unpackBasic[node.code](variant);
301
370
  }
302
371
  case "array": {
303
- return unpackChildren(variant, (child) => unpackNode(node.element, child));
372
+ return isByteArray(node)
373
+ ? variant.getDataAsBytes().unrefToArray()
374
+ : unpackChildren(variant, (child) => unpackNode(node.element, child, isRecursive));
304
375
  }
305
376
  case "dict": {
306
- return unpackDict(node, variant);
377
+ return unpackDict(node, variant, isRecursive);
307
378
  }
308
379
  case "entry": {
309
- return unpackPair(node.key, node.value, variant);
380
+ return unpackPair(node.key, node.value, variant, isRecursive);
310
381
  }
311
382
  case "tuple": {
312
- return node.items.map((item, index) => unpackNode(item, variant.getChildValue(index)));
383
+ return node.items.map((item, index) => unpackNode(item, variant.getChildValue(index), isRecursive));
313
384
  }
314
385
  case "maybe": {
315
- return unpackMaybe(node.element, variant);
386
+ return unpackMaybe(node.element, variant, isRecursive);
316
387
  }
317
388
  }
318
389
  };
@@ -369,12 +440,28 @@ const packMaybe = (node: { elementTypeString: string; element: VariantTypeNode }
369
440
  value === null ? null : packNode(node.element, value),
370
441
  );
371
442
 
443
+ const packByteArray = (value: unknown): GLib.Variant => {
444
+ if (!(value instanceof Uint8Array) && !Array.isArray(value)) {
445
+ throw new TypeError("Expected a Uint8Array or an array of byte values for a byte array (ay)");
446
+ }
447
+
448
+ return GLib.Variant.newFromBytes(
449
+ GLib.VariantType.new(BYTE_ARRAY_TYPE_STRING),
450
+ GLib.Bytes.new(value as ByteArrayInput),
451
+ true,
452
+ );
453
+ };
454
+
372
455
  const packNode = (node: VariantTypeNode, value: unknown): GLib.Variant => {
373
456
  switch (node.kind) {
374
457
  case "basic": {
375
458
  return packBasic[node.code](value);
376
459
  }
377
460
  case "array": {
461
+ if (isByteArray(node)) {
462
+ return packByteArray(value);
463
+ }
464
+
378
465
  return GLib.Variant.newArray(
379
466
  GLib.VariantType.new(node.elementTypeString),
380
467
  (value as unknown[]).map((item) => packNode(node.element, item)),
@@ -401,27 +488,71 @@ const packNode = (node: VariantTypeNode, value: unknown): GLib.Variant => {
401
488
  * Packs a JavaScript value into the `GLib.Variant` a GVariant type string describes, building the
402
489
  * nested arrays, dictionaries, tuples and maybes the type calls for. A type string given as a
403
490
  * literal also types `value`, so `"as"` takes an array of strings, `"a{sv}"` a record of variants,
404
- * `"(si)"` a string and a number pair, and a 64-bit type a `bigint`.
491
+ * `"(si)"` a string and a number pair, a 64-bit type a `bigint`, and `"ay"` a `Uint8Array` or an
492
+ * array of byte values.
405
493
  * @param typeString GVariant type of the variant to build, such as `"a{sv}"`.
406
494
  * @param value Value to pack, shaped the way `typeString` describes.
407
495
  * @returns The packed variant.
408
- * @throws {Error} When the type string is not one complete GVariant type, or when a value packed as
409
- * an object path or a type signature is not a valid one.
496
+ * @throws {Error} When the type string is not one complete GVariant type, when a value packed as
497
+ * an object path or a type signature is not a valid one, or when a byte array is packed from
498
+ * anything but a `Uint8Array` or an array of byte values.
410
499
  */
411
- const toVariant = <S extends string>(typeString: S, value: VariantValue<S>): GLib.Variant =>
500
+ const toVariant = <S extends string>(typeString: S, value: VariantInput<S>): GLib.Variant =>
412
501
  packNode(parseVariantType(typeString), value);
413
502
 
414
503
  /**
415
- * Unpacks a `GLib.Variant` into the JavaScript value a GVariant type string describes, the inverse
416
- * of {@link toVariant}. A dictionary keyed by strings unpacks to a record and one keyed by anything
417
- * else to a `Map`, an array to an array, a tuple to an array of its members, a maybe to its value or
418
- * `null`, and a nested variant to the `GLib.Variant` itself.
504
+ * Unpacks a `GLib.Variant` into the JavaScript value its GVariant type describes, the inverse of
505
+ * {@link toVariant}. A dictionary keyed by strings unpacks to a record and one keyed by anything
506
+ * else to a `Map`, an array to an array, a byte array (`ay`) to the byte array type the generated
507
+ * bindings use (`Uint8Array` under the `v2ByteArrays` future flag, `number[]` otherwise), a tuple
508
+ * to an array of its members, a maybe to its value or `null`, and a nested variant to the
509
+ * `GLib.Variant` itself unless `recursive` is set, in which case it is unwrapped all the way down.
510
+ *
511
+ * The type string is optional: without one the variant's own type is read, and the result is
512
+ * `unknown`. With one given as a literal, the result is typed from it.
419
513
  * @param typeString GVariant type the variant holds, such as `"a{sv}"`.
420
514
  * @param variant Variant to read, which has to hold that type.
421
- * @returns The unpacked value, typed from `typeString` when it is given as a literal.
515
+ * @param options Whether to unwrap nested variants recursively.
516
+ * @returns The unpacked value.
422
517
  * @throws {Error} When the type string is not one complete GVariant type.
423
518
  */
424
- const fromVariant = <S extends string>(typeString: S, variant: GLib.Variant): VariantValue<S> =>
425
- unpackNode(parseVariantType(typeString), variant) as VariantValue<S>;
519
+ function fromVariant<S extends string>(typeString: S, variant: GLib.Variant): VariantValue<S>;
426
520
 
427
- export { fromVariant, toVariant, type VariantValue };
521
+ function fromVariant<S extends string>(
522
+ typeString: S,
523
+ variant: GLib.Variant,
524
+ options: RecursiveFromVariantOptions,
525
+ ): RecursiveVariantValue<S>;
526
+
527
+ function fromVariant<S extends string>(
528
+ typeString: S,
529
+ variant: GLib.Variant,
530
+ options: FromVariantOptions,
531
+ ): VariantValue<S> | RecursiveVariantValue<S>;
532
+
533
+ function fromVariant(variant: GLib.Variant, options?: FromVariantOptions): unknown;
534
+
535
+ function fromVariant(
536
+ first: string | GLib.Variant,
537
+ second?: GLib.Variant | FromVariantOptions,
538
+ third?: FromVariantOptions,
539
+ ): unknown {
540
+ if (typeof first === "string") {
541
+ return unpackNode(parseVariantType(first), second as GLib.Variant, third?.recursive === true);
542
+ }
543
+
544
+ const options = second as FromVariantOptions | undefined;
545
+
546
+ return unpackNode(parseVariantType(first.getTypeString()), first, options?.recursive === true);
547
+ }
548
+
549
+ export {
550
+ type ByteArray,
551
+ type FromVariantOptions,
552
+ fromVariant,
553
+ type RecursiveFromVariantOptions,
554
+ type RecursiveVariantValue,
555
+ toVariant,
556
+ type VariantInput,
557
+ type VariantValue,
558
+ };