@esportsplus/reactivity 0.4.5 → 0.4.6

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.
@@ -1,4 +1,4 @@
1
- import { Options, ReactiveArray, ReactiveObject } from '../types.js';
1
+ import { Options, Reactive } from '../types.js';
2
2
  type Guard<T> = T extends {
3
3
  dispose: any;
4
4
  } | {
@@ -6,5 +6,5 @@ type Guard<T> = T extends {
6
6
  } ? {
7
7
  never: '[ dispose, signals ] are reserved keys';
8
8
  } : T extends Record<PropertyKey, unknown> | unknown[] ? T : never;
9
- declare const _default: <T>(data: Guard<T>, options?: Options) => T extends Record<PropertyKey, unknown> ? ReactiveObject<T> : ReactiveArray<T>;
9
+ declare const _default: <T>(data: Guard<T>, options?: Options) => Reactive<T>;
10
10
  export default _default;
package/build/types.d.ts CHANGED
@@ -2,8 +2,8 @@ import { Function, NeverAsync, Prettify } from '@esportsplus/utilities';
2
2
  import { ReactiveArray } from './reactive/array.js';
3
3
  import { ReactiveObject } from './reactive/object.js';
4
4
  import { CHECK, CLEAN, COMPUTED, DIRTY, DISPOSED, EFFECT, ROOT, SIGNAL } from './constants.js';
5
- import { Reactive } from './signal.js';
6
- type Base<T> = Omit<Reactive<T>, 'changed' | 'fn' | 'get' | 'scheduler' | 'set' | 'task' | 'tracking'>;
5
+ import { Reactive as ReactiveBase } from './signal.js';
6
+ type Base<T> = Omit<ReactiveBase<T>, 'changed' | 'fn' | 'get' | 'scheduler' | 'set' | 'task' | 'tracking'>;
7
7
  type Changed = (a: unknown, b: unknown) => boolean;
8
8
  type Computed<T> = {
9
9
  changed: Changed;
@@ -26,11 +26,12 @@ type Listener<D> = {
26
26
  type Options = {
27
27
  changed?: Changed;
28
28
  };
29
+ type Reactive<T> = T extends Record<PropertyKey, unknown> ? ReactiveObject<T> : ReactiveArray<T>;
29
30
  type Root = {
30
31
  scheduler: Scheduler;
31
32
  tracking: boolean;
32
33
  value: void;
33
- } & Omit<Reactive<void>, 'root'>;
34
+ } & Omit<ReactiveBase<void>, 'root'>;
34
35
  type Scheduler = (fn: Function) => unknown;
35
36
  type Signal<T> = {
36
37
  changed: Changed;
@@ -39,4 +40,4 @@ type Signal<T> = {
39
40
  } & Base<T>;
40
41
  type State = typeof CHECK | typeof CLEAN | typeof DIRTY | typeof DISPOSED;
41
42
  type Type = typeof COMPUTED | typeof EFFECT | typeof ROOT | typeof SIGNAL;
42
- export type { Changed, Computed, Effect, Event, Function, Infer, Listener, NeverAsync, Options, Prettify, ReactiveArray, ReactiveObject, Root, Scheduler, Signal, State, Type };
43
+ export type { Changed, Computed, Effect, Event, Function, Infer, Listener, NeverAsync, Options, Prettify, Reactive, ReactiveArray, ReactiveObject, Root, Scheduler, Signal, State, Type };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "ICJR",
3
3
  "dependencies": {
4
4
  "@esportsplus/custom-function": "^0.0.12",
5
- "@esportsplus/utilities": "^0.13.2"
5
+ "@esportsplus/utilities": "^0.15.0"
6
6
  },
7
7
  "devDependencies": {
8
8
  "@esportsplus/typescript": "^0.9.1"
@@ -12,7 +12,7 @@
12
12
  "private": false,
13
13
  "type": "module",
14
14
  "types": "build/index.d.ts",
15
- "version": "0.4.5",
15
+ "version": "0.4.6",
16
16
  "scripts": {
17
17
  "build": "tsc && tsc-alias",
18
18
  "-": "-"
@@ -1,5 +1,5 @@
1
1
  import { isArray, isObject } from '@esportsplus/utilities';
2
- import { Options, ReactiveArray, ReactiveObject } from '~/types';
2
+ import { Options, Reactive } from '~/types';
3
3
  import { default as array } from './array';
4
4
  import { default as object } from './object';
5
5
 
@@ -25,7 +25,5 @@ export default <T>(data: Guard<T>, options: Options = {}) => {
25
25
  throw new Error(`Reactivity: 'reactive' received invalid input - ${JSON.stringify(data)}`);
26
26
  }
27
27
 
28
- return value as T extends Record<PropertyKey, unknown>
29
- ? ReactiveObject<T>
30
- : ReactiveArray<T>;
28
+ return value as Reactive<T>;
31
29
  };
package/src/types.ts CHANGED
@@ -2,10 +2,10 @@ import { Function, NeverAsync, Prettify } from '@esportsplus/utilities'
2
2
  import { ReactiveArray } from './reactive/array';
3
3
  import { ReactiveObject } from './reactive/object';
4
4
  import { CHECK, CLEAN, COMPUTED, DIRTY, DISPOSED, EFFECT, ROOT, SIGNAL } from './constants';
5
- import { Reactive } from './signal';
5
+ import { Reactive as ReactiveBase } from './signal';
6
6
 
7
7
 
8
- type Base<T> = Omit<Reactive<T>, 'changed' | 'fn' | 'get' | 'scheduler' | 'set' | 'task' | 'tracking'>;
8
+ type Base<T> = Omit<ReactiveBase<T>, 'changed' | 'fn' | 'get' | 'scheduler' | 'set' | 'task' | 'tracking'>;
9
9
 
10
10
  type Changed = (a: unknown, b: unknown) => boolean;
11
11
 
@@ -44,11 +44,15 @@ type Options = {
44
44
  changed?: Changed;
45
45
  };
46
46
 
47
+ type Reactive<T> = T extends Record<PropertyKey, unknown>
48
+ ? ReactiveObject<T>
49
+ : ReactiveArray<T>;
50
+
47
51
  type Root = {
48
52
  scheduler: Scheduler;
49
53
  tracking: boolean;
50
54
  value: void;
51
- } & Omit<Reactive<void>, 'root'>;
55
+ } & Omit<ReactiveBase<void>, 'root'>;
52
56
 
53
57
  type Scheduler = (fn: Function) => unknown;
54
58
 
@@ -72,7 +76,7 @@ export type {
72
76
  NeverAsync,
73
77
  Options,
74
78
  Prettify,
75
- ReactiveArray, ReactiveObject, Root,
79
+ Reactive, ReactiveArray, ReactiveObject, Root,
76
80
  Scheduler, Signal, State,
77
81
  Type
78
82
  };