@esportsplus/reactivity 0.2.1 → 0.2.3

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.
@@ -4,7 +4,7 @@ import { ReactiveArray } from './array';
4
4
  import { ReactiveObject } from './object';
5
5
  type Guard<T> = T extends Record<PropertyKey, unknown> ? {
6
6
  [K in keyof T]: Never<K, Guard<T[K]>>;
7
- } : T extends unknown[] ? T : never;
7
+ } : T extends unknown[] ? T : T extends Function ? never : T;
8
8
  type Infer<T> = T extends (...args: unknown[]) => unknown ? ReturnType<T> : T extends (infer U)[] ? Prettify<Omit<U[], 'map'> & Pick<ReactiveArray<U>, 'dispatch' | 'dispose' | 'map' | 'on' | 'once'>> : T extends Record<PropertyKey, unknown> ? {
9
9
  [K in keyof T]: T[K];
10
10
  } : T;
@@ -10,7 +10,7 @@ export default (data, options = {}) => {
10
10
  value = object(data, options);
11
11
  }
12
12
  else {
13
- throw new Error('Reactivity: received invalid input for `reactive()`', data);
13
+ throw new Error(`Reactivity: 'reactive' received invalid input - ${JSON.stringify(data)}`);
14
14
  }
15
15
  return value;
16
16
  };
package/build/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Function, NeverAsync, Prettify } from '@esportsplus/typescript';
2
+ import { ReactiveArray } from './reactive/array';
2
3
  import { CHECK, CLEAN, COMPUTED, DIRTY, DISPOSED, EFFECT, ROOT, SIGNAL } from './constants';
3
4
  import { Reactive } from './signal';
4
5
  type Base<T> = Omit<Reactive<T>, 'changed' | 'fn' | 'get' | 'scheduler' | 'set' | 'task' | 'tracking'>;
@@ -37,4 +38,4 @@ type Signal<T> = {
37
38
  } & Base<T>;
38
39
  type State = typeof CHECK | typeof CLEAN | typeof DIRTY | typeof DISPOSED;
39
40
  type Type = typeof COMPUTED | typeof EFFECT | typeof ROOT | typeof SIGNAL;
40
- export type { Changed, Computed, Effect, Event, Function, Listener, NeverAsync, Options, Prettify, Root, Scheduler, Signal, State, Type };
41
+ export type { Changed, Computed, Effect, Event, Function, Listener, NeverAsync, Options, Prettify, ReactiveArray, Root, Scheduler, Signal, State, Type };
package/package.json CHANGED
@@ -17,5 +17,5 @@
17
17
  "prepublishOnly": "npm run build"
18
18
  },
19
19
  "types": "build/index.d.ts",
20
- "version": "0.2.1"
20
+ "version": "0.2.3"
21
21
  }
@@ -10,7 +10,9 @@ type Guard<T> =
10
10
  ? { [K in keyof T]: Never<K, Guard<T[K]>> }
11
11
  : T extends unknown[]
12
12
  ? T
13
- : never;
13
+ : T extends Function
14
+ ? never
15
+ : T;
14
16
 
15
17
  type Infer<T> =
16
18
  T extends (...args: unknown[]) => unknown
@@ -34,7 +36,7 @@ export default <T>(data: Guard<T>, options: Options = {}) => {
34
36
  value = object(data as { [K in keyof T]: T[K] }, options);
35
37
  }
36
38
  else {
37
- throw new Error('Reactivity: received invalid input for `reactive()`', data);
39
+ throw new Error(`Reactivity: 'reactive' received invalid input - ${JSON.stringify(data)}`);
38
40
  }
39
41
 
40
42
  return value as T extends Record<PropertyKey, unknown> ? { [K in keyof T]: Infer<T[K]> } : Infer<T>;
package/src/types.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Function, NeverAsync, Prettify } from '@esportsplus/typescript'
2
+ import { ReactiveArray } from './reactive/array';
2
3
  import { CHECK, CLEAN, COMPUTED, DIRTY, DISPOSED, EFFECT, ROOT, SIGNAL } from './constants';
3
4
  import { Reactive } from './signal';
4
5
 
@@ -58,6 +59,7 @@ export type {
58
59
  NeverAsync,
59
60
  Options,
60
61
  Prettify,
62
+ ReactiveArray,
61
63
  Root,
62
64
  Scheduler, Signal, State,
63
65
  Type