gnim 1.2.3 → 1.2.5

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/dist/dbus.d.ts CHANGED
@@ -7,8 +7,9 @@
7
7
  import Gio from "gi://Gio";
8
8
  import GLib from "gi://GLib";
9
9
  import GObject from "gi://GObject";
10
- import { type InferVariant } from "./variant.js";
11
10
  import { register } from "./gobject.js";
11
+ export declare const Variant: typeof GLib.Variant;
12
+ export type Variant<T extends string> = GLib.Variant<T>;
12
13
  declare const info: unique symbol;
13
14
  declare const internals: unique symbol;
14
15
  declare const remoteMethod: unique symbol;
@@ -62,10 +63,11 @@ type DBusType = string | {
62
63
  type: string;
63
64
  name: string;
64
65
  };
66
+ type DeepInfer<T extends string> = ReturnType<GLib.Variant<T>["deepUnpack"]>;
65
67
  type InferVariantTypes<T extends Array<DBusType>> = {
66
- [K in keyof T]: T[K] extends string ? InferVariant<T[K]> : T[K] extends {
68
+ [K in keyof T]: T[K] extends string ? DeepInfer<T[K]> : T[K] extends {
67
69
  type: infer S;
68
- } ? S extends string ? InferVariant<S> : never : unknown;
70
+ } ? S extends string ? DeepInfer<S> : never : unknown;
69
71
  };
70
72
  /**
71
73
  * Registers a method.
@@ -103,21 +105,21 @@ export declare function methodAsync<const InArgs extends Array<DBusType>>(...inA
103
105
  * not emit the notify signal.
104
106
  * ```
105
107
  */
106
- export declare function property<T extends string>(type: T): (_: void, ctx: ClassFieldDecoratorContext<Service, InferVariant<T>>) => (this: Service, init: InferVariant<T>) => InferVariant<T>;
108
+ export declare function property<T extends string>(type: T): (_: void, ctx: ClassFieldDecoratorContext<Service, DeepInfer<T>>) => (this: Service, init: DeepInfer<T>) => DeepInfer<T>;
107
109
  /**
108
110
  * Registers a read-only property. Can be used in conjuction with {@link setter} to define
109
111
  * read-write properties as accessors.
110
112
  *
111
113
  * Note that you will need to explicitly emit the notify signal.
112
114
  */
113
- export declare function getter<T extends string>(type: T): (getter: (this: Service) => InferVariant<T>, ctx: ClassGetterDecoratorContext<Service, InferVariant<T>>) => (this: Service) => InferVariant<T>;
115
+ export declare function getter<T extends string>(type: T): (getter: (this: Service) => DeepInfer<T>, ctx: ClassGetterDecoratorContext<Service, DeepInfer<T>>) => (this: Service) => DeepInfer<T>;
114
116
  /**
115
117
  * Registers a write-only property. Can be used in conjuction with {@link getter} to define
116
118
  * read-write properties as accessors.
117
119
  *
118
120
  * Note that you will need to explicitly emit the notify signal.
119
121
  */
120
- export declare function setter<T extends string>(type: T): (setter: (this: Service, value: InferVariant<T>) => void, ctx: ClassSetterDecoratorContext<Service, InferVariant<T>>) => (this: Service, value: InferVariant<T>) => void;
122
+ export declare function setter<T extends string>(type: T): (setter: (this: Service, value: DeepInfer<T>) => void, ctx: ClassSetterDecoratorContext<Service, DeepInfer<T>>) => (this: Service, value: DeepInfer<T>) => void;
121
123
  /**
122
124
  * Registers a signal which when invoked will emit the signal
123
125
  * on the local object and the exported object.
@@ -125,15 +127,4 @@ export declare function setter<T extends string>(type: T): (setter: (this: Servi
125
127
  * **Note**: its not possible to emit signals on remote objects through proxies.
126
128
  */
127
129
  export declare function signal<const Params extends Array<DBusType>>(...params: Params): (method: (this: Service, ...params: InferVariantTypes<Params>) => void, ctx: ClassMethodDecoratorContext<Service, typeof method>) => typeof method;
128
- declare class GLibVariant<T extends string = any> extends GLib.Variant<T> {
129
- static new<T extends string>(signature: T, value: InferVariant<T>): GLib.Variant<T>;
130
- constructor(signature: T, value: InferVariant<T>);
131
- deepUnpack<V = InferVariant<T>>(): V;
132
- deep_unpack<V = InferVariant<T>>(): V;
133
- }
134
- export declare namespace Variant {
135
- type Infer<S extends string> = InferVariant<S>;
136
- }
137
- export declare const Variant: typeof GLibVariant;
138
- export type Variant<T extends string = any> = GLibVariant<T>;
139
130
  export {};
package/dist/dbus.js CHANGED
@@ -22,6 +22,7 @@ import GObject from "gi://GObject";
22
22
  import { definePropertyGetter, kebabify, xml } from "./util.js";
23
23
  import { register, property as gproperty, signal as gsignal, getter as ggetter, setter as gsetter, } from "./gobject.js";
24
24
  const DEFAULT_TIMEOUT = 10000;
25
+ export const Variant = GLib.Variant;
25
26
  const info = Symbol("dbus interface info");
26
27
  const internals = Symbol("dbus interface internals");
27
28
  const remoteMethod = Symbol("proxy remoteMethod");
@@ -549,28 +550,3 @@ export function signal(...params) {
549
550
  };
550
551
  };
551
552
  }
552
- // HACK: how do I augment it globally?
553
- class GLibVariant extends GLib.Variant {
554
- static new(signature, value) {
555
- return GLib.Variant.new(signature, value);
556
- }
557
- constructor(signature, value) {
558
- super(signature, value);
559
- }
560
- deepUnpack() {
561
- return super.deepUnpack();
562
- }
563
- deep_unpack() {
564
- return super.deepUnpack();
565
- }
566
- }
567
- export const Variant = GLib.Variant;
568
- // FIXME: should be augmented globally
569
- // declare module "gi://GLib?version=2.0" {
570
- // export namespace GLib {
571
- // export interface Variant<T extends string = string> {
572
- // deepUnpack<V = InferVariantType<T>>(): V
573
- // deep_unpack<V = InferVariantType<T>>(): V
574
- // }
575
- // }
576
- // }
package/dist/jsx/For.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { Fragment } from "./Fragment.js";
2
2
  import { createState } from "./state.js";
3
3
  import { env } from "./env.js";
4
- import { onCleanup, Scope } from "./scope.js";
4
+ import { getScope, onCleanup, Scope } from "./scope.js";
5
5
  // TODO: support Gio.ListModel
6
6
  export function For({ each, children: mkChild, cleanup, id = (item) => item, }) {
7
+ const currentScope = getScope();
7
8
  const map = new Map();
8
9
  const fragment = new Fragment();
9
10
  function remove({ item, child, index: [index], scope }) {
@@ -44,17 +45,17 @@ export function For({ each, children: mkChild, cleanup, id = (item) => item, })
44
45
  }
45
46
  else {
46
47
  const [index, setIndex] = createState(i);
47
- const scope = new Scope(Scope.current);
48
+ const scope = new Scope(currentScope);
48
49
  const child = scope.run(() => mkChild(item, index));
49
50
  map.set(key, { item, child, index: [index, setIndex], scope });
50
51
  fragment.addChild(child);
51
52
  }
52
53
  });
53
54
  }
54
- callback(each.get());
55
55
  const dispose = each.subscribe(() => {
56
56
  callback(each.get());
57
57
  });
58
+ callback(each.get());
58
59
  onCleanup(() => {
59
60
  dispose();
60
61
  for (const value of map.values()) {
package/dist/jsx/With.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Fragment } from "./Fragment.js";
2
2
  import { env } from "./env.js";
3
- import { onCleanup, Scope } from "./scope.js";
3
+ import { getScope, onCleanup, Scope } from "./scope.js";
4
4
  export function With({ value, children: mkChild, cleanup, }) {
5
+ const currentScope = getScope();
5
6
  const fragment = new Fragment();
6
7
  let scope;
7
8
  function callback(v) {
@@ -16,7 +17,7 @@ export function With({ value, children: mkChild, cleanup, }) {
16
17
  if (scope)
17
18
  scope.dispose();
18
19
  }
19
- scope = new Scope(Scope.current);
20
+ scope = new Scope(currentScope);
20
21
  const ch = scope.run(() => mkChild(v));
21
22
  if (ch !== "" && ch !== false && ch !== null && ch !== undefined) {
22
23
  fragment.addChild(ch);
@@ -1,11 +1,11 @@
1
1
  export declare class Scope {
2
- static current: Scope | null;
2
+ static current?: Scope | null;
3
3
  parent?: Scope | null;
4
- context?: any;
4
+ contexts: Map<Context<any>, unknown>;
5
5
  private cleanups;
6
6
  private mounts;
7
7
  private mounted;
8
- constructor(parent: Scope | null);
8
+ constructor(parent?: Scope | null);
9
9
  onCleanup(callback: () => void): void;
10
10
  onMount(callback: () => void): void;
11
11
  run<T>(fn: () => T): T;
package/dist/jsx/scope.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export class Scope {
2
2
  constructor(parent) {
3
+ this.contexts = new Map();
3
4
  this.cleanups = new Set();
4
5
  this.mounts = new Set();
5
6
  this.mounted = false;
@@ -32,8 +33,8 @@ export class Scope {
32
33
  dispose() {
33
34
  this.cleanups.forEach((cb) => cb());
34
35
  this.cleanups.clear();
36
+ this.contexts.clear();
35
37
  delete this.parent;
36
- delete this.context;
37
38
  }
38
39
  }
39
40
  /**
@@ -59,29 +60,29 @@ export class Scope {
59
60
  * ```
60
61
  */
61
62
  export function createContext(defaultValue) {
63
+ let ctx;
62
64
  function provide(value, fn) {
63
- const scope = new Scope(Scope.current);
64
- onCleanup(() => scope.dispose());
65
- scope.context = value;
65
+ const scope = getScope();
66
+ scope.contexts.set(ctx, value);
66
67
  return scope.run(fn);
67
68
  }
68
69
  function use() {
69
70
  let scope = Scope.current;
70
71
  while (scope) {
71
- const value = scope.context;
72
- if (value)
72
+ const value = scope.contexts.get(ctx);
73
+ if (value !== undefined)
73
74
  return value;
74
- scope = scope.parent ?? null;
75
+ scope = scope.parent;
75
76
  }
76
77
  return defaultValue;
77
78
  }
78
79
  function context({ value, children }) {
79
80
  return provide(value, children);
80
81
  }
81
- return Object.assign(context, {
82
+ return (ctx = Object.assign(context, {
82
83
  provide,
83
84
  use,
84
- });
85
+ }));
85
86
  }
86
87
  /**
87
88
  * Gets the scope that owns the currently running code.
@@ -1,7 +1,7 @@
1
1
  import GObject from "gi://GObject";
2
2
  import Gio from "gi://Gio";
3
+ import GLib from "gi://GLib";
3
4
  import { type Pascalify } from "../util.js";
4
- import { type InferVariantRec, type InferVariant } from "../variant.js";
5
5
  type SubscribeCallback = () => void;
6
6
  type DisposeFunction = () => void;
7
7
  type SubscribeFunction = (callback: SubscribeCallback) => DisposeFunction;
@@ -116,11 +116,13 @@ export declare function createConnection<T, O1 extends GObject.Object, S1 extend
116
116
  * @param producer The producer function which should return a cleanup function
117
117
  */
118
118
  export declare function createExternal<T>(init: T, producer: (set: Setter<T>) => DisposeFunction): Accessor<T>;
119
+ type DeepInfer<T extends string> = ReturnType<GLib.Variant<T>["deepUnpack"]>;
120
+ type RecursiveInfer<T extends string> = ReturnType<GLib.Variant<T>["recursiveUnpack"]>;
119
121
  /** @experimental */
120
122
  type Settings<T extends Record<string, string>> = {
121
- [K in keyof T as Uncapitalize<Pascalify<K>>]: Accessor<InferVariantRec<T[K]>>;
123
+ [K in keyof T as Uncapitalize<Pascalify<K>>]: Accessor<RecursiveInfer<T[K]>>;
122
124
  } & {
123
- [K in keyof T as `set${Pascalify<K>}`]: Setter<InferVariant<T[K]>>;
125
+ [K in keyof T as `set${Pascalify<K>}`]: Setter<DeepInfer<T[K]>>;
124
126
  };
125
127
  /**
126
128
  * @experimental
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gnim",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "type": "module",
5
5
  "author": "Aylur",
6
6
  "license": "MIT",
package/dist/variant.d.ts DELETED
@@ -1,77 +0,0 @@
1
- import type GLib from "gi://GLib";
2
- type Variant<S extends string = any> = GLib.Variant<S>;
3
- type CreateIndexType<Key extends string, Value> = Key extends `s` | `o` | `g` ? {
4
- [key: string]: Value;
5
- } : Key extends `n` | `q` | `t` | `d` | `u` | `i` | `x` | `y` ? {
6
- [key: number]: Value;
7
- } : never;
8
- type VariantTypeError<T extends string> = {
9
- error: true;
10
- } & T;
11
- /**
12
- * Handles the {kv} of a{kv} where k is a basic type and v is any possible variant type string.
13
- */
14
- type $ParseDeepVariantDict<State extends string, Memo extends Record<string, any> = {}> = string extends State ? VariantTypeError<"$ParseDeepVariantDict: 'string' is not a supported type."> : State extends `}${infer State}` ? [Memo, State] : State extends `${infer Key}${''}${infer State}` ? $ParseDeepVariantValue<State> extends [infer Value, `${infer State}`] ? State extends `}${infer State}` ? [CreateIndexType<Key, Value>, State] : VariantTypeError<`$ParseDeepVariantDict encountered an invalid variant string: ${State} (1)`> : VariantTypeError<`$ParseDeepVariantValue returned unexpected value for: ${State}`> : VariantTypeError<`$ParseDeepVariantDict encountered an invalid variant string: ${State} (2)`>;
15
- /**
16
- * Handles parsing values within a tuple (e.g. (vvv)) where v is any possible variant type string.
17
- */
18
- type $ParseDeepVariantArray<State extends string, Memo extends any[] = []> = string extends State ? VariantTypeError<"$ParseDeepVariantArray: 'string' is not a supported type."> : State extends `)${infer State}` ? [Memo, State] : $ParseDeepVariantValue<State> extends [infer Value, `${infer State}`] ? State extends `${infer _NextValue})${infer _NextState}` ? $ParseDeepVariantArray<State, [...Memo, Value]> : State extends `)${infer State}` ? [[...Memo, Value], State] : VariantTypeError<`1: $ParseDeepVariantArray encountered an invalid variant string: ${State}`> : VariantTypeError<`2: $ParseDeepVariantValue returned unexpected value for: ${State}`>;
19
- /**
20
- * Handles parsing {kv} without an 'a' prefix (key-value pair) where k is a basic type
21
- * and v is any possible variant type string.
22
- */
23
- type $ParseDeepVariantKeyValue<State extends string, Memo extends any[] = []> = string extends State ? VariantTypeError<"$ParseDeepVariantKeyValue: 'string' is not a supported type."> : State extends `}${infer State}` ? [Memo, State] : State extends `${infer Key}${''}${infer State}` ? $ParseDeepVariantValue<State> extends [infer Value, `${infer State}`] ? State extends `}${infer State}` ? [[...Memo, $ParseVariant<Key>, Value], State] : VariantTypeError<`$ParseDeepVariantKeyValue encountered an invalid variant string: ${State} (1)`> : VariantTypeError<`$ParseDeepVariantKeyValue returned unexpected value for: ${State}`> : VariantTypeError<`$ParseDeepVariantKeyValue encountered an invalid variant string: ${State} (2)`>;
24
- /**
25
- * Handles parsing any variant 'value' or base unit.
26
- *
27
- * - ay - Array of bytes (Uint8Array)
28
- * - a* - Array of type *
29
- * - a{k*} - Dictionary
30
- * - {k*} - KeyValue
31
- * - (**) - tuple
32
- * - s | o | g - string types
33
- * - n | q | t | d | u | i | x | y - number types
34
- * - b - boolean type
35
- * - v - unknown Variant type
36
- * - h | ? - unknown types
37
- */
38
- type $ParseDeepVariantValue<State extends string> = string extends State ? unknown : State extends `${`s` | `o` | `g`}${infer State}` ? [string, State] : State extends `${`n` | `q` | `t` | `d` | `u` | `i` | `x` | `y`}${infer State}` ? [number, State] : State extends `b${infer State}` ? [boolean, State] : State extends `v${infer State}` ? [Variant, State] : State extends `${'h' | '?'}${infer State}` ? [unknown, State] : State extends `(${infer State}` ? $ParseDeepVariantArray<State> : State extends `a{${infer State}` ? $ParseDeepVariantDict<State> : State extends `{${infer State}` ? $ParseDeepVariantKeyValue<State> : State extends `ay${infer State}` ? [
39
- Uint8Array,
40
- State
41
- ] : State extends `m${infer State}` ? $ParseDeepVariantValue<State> extends [infer Value, `${infer State}`] ? [Value | null, State] : VariantTypeError<`$ParseDeepVariantValue encountered an invalid variant string: ${State} (3)`> : State extends `a${infer State}` ? $ParseDeepVariantValue<State> extends [infer Value, `${infer State}`] ? [
42
- Value[],
43
- State
44
- ] : VariantTypeError<`$ParseDeepVariantValue encountered an invalid variant string: ${State} (1)`> : VariantTypeError<`$ParseDeepVariantValue encountered an invalid variant string: ${State} (2)`>;
45
- type $ParseDeepVariant<T extends string> = $ParseDeepVariantValue<T> extends infer Result ? Result extends [infer Value, string] ? Value : Result extends VariantTypeError<any> ? Result : VariantTypeError<"$ParseDeepVariantValue returned unexpected Result"> : VariantTypeError<"$ParseDeepVariantValue returned uninferrable Result">;
46
- type $ParseRecursiveVariantDict<State extends string, Memo extends Record<string, any> = {}> = string extends State ? VariantTypeError<"$ParseRecursiveVariantDict: 'string' is not a supported type."> : State extends `}${infer State}` ? [Memo, State] : State extends `${infer Key}${''}${infer State}` ? $ParseRecursiveVariantValue<State> extends [infer Value, `${infer State}`] ? State extends `}${infer State}` ? [CreateIndexType<Key, Value>, State] : VariantTypeError<`$ParseRecursiveVariantDict encountered an invalid variant string: ${State} (1)`> : VariantTypeError<`$ParseRecursiveVariantValue returned unexpected value for: ${State}`> : VariantTypeError<`$ParseRecursiveVariantDict encountered an invalid variant string: ${State} (2)`>;
47
- type $ParseRecursiveVariantArray<State extends string, Memo extends any[] = []> = string extends State ? VariantTypeError<"$ParseRecursiveVariantArray: 'string' is not a supported type."> : State extends `)${infer State}` ? [Memo, State] : $ParseRecursiveVariantValue<State> extends [infer Value, `${infer State}`] ? State extends `${infer _NextValue})${infer _NextState}` ? $ParseRecursiveVariantArray<State, [...Memo, Value]> : State extends `)${infer State}` ? [[...Memo, Value], State] : VariantTypeError<`$ParseRecursiveVariantArray encountered an invalid variant string: ${State} (1)`> : VariantTypeError<`$ParseRecursiveVariantValue returned unexpected value for: ${State} (2)`>;
48
- type $ParseRecursiveVariantKeyValue<State extends string, Memo extends any[] = []> = string extends State ? VariantTypeError<"$ParseRecursiveVariantKeyValue: 'string' is not a supported type."> : State extends `}${infer State}` ? [Memo, State] : State extends `${infer Key}${''}${infer State}` ? $ParseRecursiveVariantValue<State> extends [infer Value, `${infer State}`] ? State extends `}${infer State}` ? [[...Memo, Key, Value], State] : VariantTypeError<`$ParseRecursiveVariantKeyValue encountered an invalid variant string: ${State} (1)`> : VariantTypeError<`$ParseRecursiveVariantKeyValue returned unexpected value for: ${State}`> : VariantTypeError<`$ParseRecursiveVariantKeyValue encountered an invalid variant string: ${State} (2)`>;
49
- type $ParseRecursiveVariantValue<State extends string> = string extends State ? unknown : State extends `${`s` | `o` | `g`}${infer State}` ? [string, State] : State extends `${`n` | `q` | `t` | `d` | `u` | `i` | `x` | `y`}${infer State}` ? [number, State] : State extends `b${infer State}` ? [boolean, State] : State extends `v${infer State}` ? [unknown, State] : State extends `${'h' | '?'}${infer State}` ? [unknown, State] : State extends `(${infer State}` ? $ParseRecursiveVariantArray<State> : State extends `a{${infer State}` ? $ParseRecursiveVariantDict<State> : State extends `{${infer State}` ? $ParseRecursiveVariantKeyValue<State> : State extends `ay${infer State}` ? [
50
- Uint8Array,
51
- State
52
- ] : State extends `m${infer State}` ? $ParseRecursiveVariantValue<State> extends [infer Value, `${infer State}`] ? [Value | null, State] : VariantTypeError<`$ParseRecursiveVariantValue encountered an invalid variant string: ${State} (3)`> : State extends `a${infer State}` ? $ParseRecursiveVariantValue<State> extends [infer Value, `${infer State}`] ? [
53
- Value[],
54
- State
55
- ] : VariantTypeError<`$ParseRecursiveVariantValue encountered an invalid variant string: ${State} (1)`> : VariantTypeError<`$ParseRecursiveVariantValue encountered an invalid variant string: ${State} (2)`>;
56
- type $ParseRecursiveVariant<T extends string> = $ParseRecursiveVariantValue<T> extends infer Result ? Result extends [infer Value, string] ? Value : Result extends VariantTypeError<any> ? Result : never : never;
57
- type $ParseVariantDict<State extends string, Memo extends Record<string, any> = {}> = string extends State ? VariantTypeError<"$ParseVariantDict: 'string' is not a supported type."> : State extends `}${infer State}` ? [Memo, State] : State extends `${infer Key}${''}${infer State}` ? $ParseVariantValue<State> extends [infer Value, `${infer State}`] ? State extends `}${infer State}` ? [CreateIndexType<Key, Variant<Value extends string ? Value : any>>, State] : VariantTypeError<`$ParseVariantDict encountered an invalid variant string: ${State} (1)`> : VariantTypeError<`$ParseVariantValue returned unexpected value for: ${State}`> : VariantTypeError<`$ParseVariantDict encountered an invalid variant string: ${State} (2)`>;
58
- type $ParseVariantArray<State extends string, Memo extends any[] = []> = string extends State ? VariantTypeError<"$ParseVariantArray: 'string' is not a supported type."> : State extends `)${infer State}` ? [Memo, State] : $ParseVariantValue<State> extends [infer Value, `${infer State}`] ? State extends `${infer _NextValue})${infer _NextState}` ? $ParseVariantArray<State, [...Memo, Variant<Value extends string ? Value : any>]> : State extends `)${infer State}` ? [[...Memo, Variant<Value extends string ? Value : any>], State] : VariantTypeError<`$ParseVariantArray encountered an invalid variant string: ${State} (1)`> : VariantTypeError<`$ParseVariantValue returned unexpected value for: ${State} (2)`>;
59
- type $ParseVariantKeyValue<State extends string, Memo extends any[] = []> = string extends State ? VariantTypeError<"$ParseVariantKeyValue: 'string' is not a supported type."> : State extends `}${infer State}` ? [Memo, State] : State extends `${infer Key}${''}${infer State}` ? $ParseVariantValue<State> extends [infer Value, `${infer State}`] ? State extends `}${infer State}` ? [[...Memo, Variant<Key>, Variant<Value extends string ? Value : any>], State] : VariantTypeError<`$ParseVariantKeyValue encountered an invalid variant string: ${State} (1)`> : VariantTypeError<`$ParseVariantKeyValue returned unexpected value for: ${State}`> : VariantTypeError<`$ParseVariantKeyValue encountered an invalid variant string: ${State} (2)`>;
60
- type $ParseShallowRootVariantValue<State extends string> = string extends State ? unknown : State extends `${`s` | `o` | `g`}${infer State}` ? [string, State] : State extends `${`n` | `q` | `t` | `d` | `u` | `i` | `x` | `y`}${infer State}` ? [number, State] : State extends `b${infer State}` ? [boolean, State] : State extends `v${infer State}` ? [Variant, State] : State extends `h${infer State}` ? [unknown, State] : State extends `?${infer State}` ? [unknown, State] : State extends `(${infer State}` ? $ParseVariantArray<State> : State extends `a{${infer State}` ? $ParseVariantDict<State> : State extends `{${infer State}` ? $ParseVariantKeyValue<State> : State extends `ay${infer State}` ? [
61
- Uint8Array,
62
- State
63
- ] : State extends `m${infer State}` ? $ParseVariantValue<State> extends [infer Value, `${infer State}`] ? [Value | null, State] : VariantTypeError<`$ParseShallowRootVariantValue encountered an invalid variant string: ${State} (2)`> : State extends `a${infer State}` ? [
64
- Variant<State>[],
65
- State
66
- ] : VariantTypeError<`$ParseShallowRootVariantValue encountered an invalid variant string: ${State} (1)`>;
67
- type $ParseVariantValue<State extends string> = string extends State ? unknown : State extends `s${infer State}` ? ['s', State] : State extends `o${infer State}` ? ['o', State] : State extends `g${infer State}` ? ['g', State] : State extends `n${infer State}` ? ["n", State] : State extends `q${infer State}` ? ["q", State] : State extends `t${infer State}` ? ["t", State] : State extends `d${infer State}` ? ["d", State] : State extends `u${infer State}` ? ["u", State] : State extends `i${infer State}` ? ["i", State] : State extends `x${infer State}` ? ["x", State] : State extends `y${infer State}` ? ["y", State] : State extends `b${infer State}` ? ['b', State] : State extends `v${infer State}` ? ['v', State] : State extends `h${infer State}` ? ['h', State] : State extends `?${infer State}` ? ['?', State] : State extends `(${infer State}` ? $ParseVariantArray<State> : State extends `a{${infer State}` ? $ParseVariantDict<State> : State extends `{${infer State}` ? $ParseVariantKeyValue<State> : State extends `ay${infer State}` ? [
68
- Uint8Array,
69
- State
70
- ] : State extends `m${infer State}` ? $ParseVariantValue<State> extends [infer Value, `${infer State}`] ? [Value | null, State] : VariantTypeError<`$ParseVariantValue encountered an invalid variant string: ${State} (3)`> : State extends `a${infer State}` ? $ParseVariantValue<State> extends [infer Value, `${infer State}`] ? [
71
- Value[],
72
- State
73
- ] : VariantTypeError<`$ParseVariantValue encountered an invalid variant string: ${State} (1)`> : VariantTypeError<`$ParseVariantValue encountered an invalid variant string: ${State} (2)`>;
74
- type $ParseVariant<T extends string> = $ParseShallowRootVariantValue<T> extends infer Result ? Result extends [infer Value, string] ? Value : Result extends VariantTypeError<any> ? Result : never : never;
75
- export type InferVariant<S extends string> = $ParseDeepVariant<S>;
76
- export type InferVariantRec<S extends string> = $ParseRecursiveVariant<S>;
77
- export {};
package/dist/variant.js DELETED
@@ -1,4 +0,0 @@
1
- // See: https://github.com/gjsify/ts-for-gir/issues/270
2
- //
3
- // Source: https://github.com/gjsify/ts-for-gir/blob/e1bfc49d233b4f13d4a3b342d5fc636532c4f352/packages/lib/src/generators/dts/glib.ts
4
- export {};