@gi-tcg/gts-runtime 0.6.5 → 0.6.7

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/index.d.ts CHANGED
@@ -256,13 +256,14 @@ interface SimpleViewModelOptions {
256
256
  booleanSwitch?: boolean;
257
257
  }
258
258
  type ExtractObject<T> = T extends object ? T : never;
259
+ type IfAll<T extends (boolean | undefined)[], TrueT, FalseT> = T[number] extends true ? TrueT : FalseT;
259
260
  type SimpleViewModelAttribute<ValueT, Options extends SimpleViewModelOptions> = {
260
261
  (value: ValueT): AttributeReturn.Done;
261
- } & (Options["recursive"] extends true ? IsSingleton<ExtractObject<ValueT>> extends true ? {
262
+ } & IfAll<[Options["recursive"], IsSingleton<ExtractObject<ValueT>>], {
262
263
  (): AttributeReturn.With<SimpleViewModel<ExtractObject<ValueT>, Options>>;
263
- } : Options["booleanSwitch"] extends true ? [true] extends [ValueT] ? {
264
+ }, IfAll<[Options["booleanSwitch"], true extends ValueT ? true : false], {
264
265
  (): AttributeReturn.Done;
265
- } : {} : {} : {});
266
+ }, {}>>;
266
267
  interface SimpleViewModel<T, Options extends SimpleViewModelOptions = {}> extends IViewModel<T, { [K in keyof T]-?: SimpleViewModelAttribute<T[K], Options> & {
267
268
  uniqueKey(): K;
268
269
  required(): {} extends Pick<T, K> ? false : true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gi-tcg/gts-runtime",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/piovium/gts.git"
@@ -25,24 +25,28 @@ export interface SimpleViewModelOptions {
25
25
 
26
26
  type ExtractObject<T> = T extends object ? T : never;
27
27
 
28
+ type IfAll<
29
+ T extends (boolean | undefined)[],
30
+ TrueT,
31
+ FalseT,
32
+ > = T[number] extends true ? TrueT : FalseT;
33
+
28
34
  type SimpleViewModelAttribute<
29
35
  ValueT,
30
36
  Options extends SimpleViewModelOptions,
31
37
  > = {
32
38
  (value: ValueT): AttributeReturn.Done;
33
- } & (Options["recursive"] extends true
34
- ? IsSingleton<ExtractObject<ValueT>> extends true
35
- ? {
36
- (): AttributeReturn.With<
37
- SimpleViewModel<ExtractObject<ValueT>, Options>
38
- >;
39
- }
40
- : Options["booleanSwitch"] extends true
41
- ? [true] extends [ValueT]
42
- ? { (): AttributeReturn.Done }
43
- : {}
44
- : {}
45
- : {});
39
+ } & IfAll<
40
+ [Options["recursive"], IsSingleton<ExtractObject<ValueT>>],
41
+ {
42
+ (): AttributeReturn.With<SimpleViewModel<ExtractObject<ValueT>, Options>>;
43
+ },
44
+ IfAll<
45
+ [Options["booleanSwitch"], true extends ValueT ? true : false],
46
+ { (): AttributeReturn.Done },
47
+ {}
48
+ >
49
+ >;
46
50
 
47
51
  export interface SimpleViewModel<
48
52
  T,