@esportsplus/reactivity 0.1.7 → 0.1.8

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/build/macro.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import CustomFunction from '@esportsplus/custom-function';
2
- import { Computed, NeverAsync, Options } from './types';
2
+ import { Computed, Options } from './types';
3
3
  type Function<A extends unknown[], R> = Computed<(...args: A) => R>['fn'];
4
4
  declare class Macro<A extends unknown[], R> extends CustomFunction {
5
5
  #private;
@@ -7,6 +7,5 @@ declare class Macro<A extends unknown[], R> extends CustomFunction {
7
7
  dispose(): void;
8
8
  reset(): void;
9
9
  }
10
- declare const _default: <A extends unknown[], R>(fn: (previous: (...args: A) => R) => ((...args: A) => R) extends infer T ? T extends (...args: A) => R ? T extends (...args: unknown[]) => unknown ? NeverAsync<ReturnType<T>> extends never ? never : T : T : never : never, options?: Options) => Macro<A, R>;
10
+ declare const _default: <A extends unknown[], R>(fn: (previous: (...args: A) => R) => (...args: A) => R, options?: Options) => Macro<A, R>;
11
11
  export default _default;
12
- export { NeverAsync };
package/build/signal.d.ts CHANGED
@@ -18,7 +18,7 @@ declare class Signal<T> {
18
18
  once(event: Event, listener: Listener<any>): void;
19
19
  reset(): void;
20
20
  }
21
- declare const computed: <T>(fn: (previous: T) => NeverAsync<T>, options?: Options) => Computed<T>;
21
+ declare const computed: <T>(fn: ((previous: T) => T) extends infer T_1 ? T_1 extends (previous: T) => T ? T_1 extends (...args: unknown[]) => unknown ? (...args: Parameters<T_1>) => ReturnType<T_1> extends NeverAsync<T_1> ? NeverAsync<T_1> & ReturnType<T_1> : NeverAsync<ReturnType<T_1>> : T_1 : never : never, options?: Options) => Computed<T>;
22
22
  declare const dispose: <T extends {
23
23
  dispose: () => void;
24
24
  }>(dispose?: T | T[] | undefined) => T | T[] | undefined;
@@ -27,7 +27,7 @@ declare const read: <T>(node: Signal<T>) => T;
27
27
  declare const reset: <T extends {
28
28
  reset: () => void;
29
29
  }>(reset?: T | T[] | undefined) => T | T[] | undefined;
30
- declare function root<T>(fn: () => NeverAsync<T>, properties?: Root): NeverAsync<T>;
30
+ declare function root<T>(fn: NeverAsync<() => T>, properties?: Root): T extends () => T extends any ? T : NeverAsync<T> ? T : NeverAsync<T>;
31
31
  declare const signal: <T>(data: T, options?: Omit<Options, 'value'>) => Signal<T>;
32
32
  declare const write: <T>(node: Signal<T>, value: unknown) => T;
33
33
  export default Signal;
package/build/types.d.ts CHANGED
@@ -3,10 +3,10 @@ import { CHECK, CLEAN, COMPUTED, DIRTY, DISPOSED, EFFECT, SIGNAL } from './const
3
3
  import Signal from './signal';
4
4
  type Changed = (a: unknown, b: unknown) => boolean;
5
5
  type Computed<T> = {
6
- fn: (previous: T) => NeverAsync<T>;
6
+ fn: NeverAsync<(previous: T) => T>;
7
7
  } & Omit<Signal<T>, 'fn'>;
8
8
  type Effect = {
9
- fn: (node: Effect) => NeverAsync<void>;
9
+ fn: NeverAsync<(node: Effect) => void>;
10
10
  root: Root;
11
11
  task: Function;
12
12
  value: void;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "@esportsplus/custom-function": "^0.0.1"
5
5
  },
6
6
  "devDependencies": {
7
- "@esportsplus/typescript": "^0.0.7"
7
+ "@esportsplus/typescript": "^0.0.9"
8
8
  },
9
9
  "main": "build/index.js",
10
10
  "name": "@esportsplus/reactivity",
@@ -16,5 +16,5 @@
16
16
  "prepublishOnly": "npm run build"
17
17
  },
18
18
  "types": "build/index.d.ts",
19
- "version": "0.1.7"
19
+ "version": "0.1.8"
20
20
  }
package/src/macro.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import CustomFunction from '@esportsplus/custom-function';
2
2
  import { computed, read } from './signal';
3
- import { Computed, NeverAsync, Options } from './types';
3
+ import { Computed, Options } from './types';
4
4
 
5
5
 
6
6
  type Function<A extends unknown[], R> = Computed<(...args: A) => R>['fn'];
@@ -30,5 +30,4 @@ class Macro<A extends unknown[], R> extends CustomFunction {
30
30
 
31
31
  export default <A extends unknown[], R>(fn: Function<A,R>, options: Options = {}) => {
32
32
  return new Macro(fn, options);
33
- };
34
- export { NeverAsync };
33
+ };
package/src/signal.ts CHANGED
@@ -208,9 +208,8 @@ function update<T>(node: Signal<T>) {
208
208
  node.dispatch('update');
209
209
  node.updating = true;
210
210
 
211
- let value = (
212
- node as typeof node extends Effect ? Effect : Computed<T>
213
- ).fn.call(node, node.value);
211
+ // @ts-ignore
212
+ let value = node.fn.call(node, node.value);
214
213
 
215
214
  node.updating = null;
216
215
 
@@ -348,7 +347,7 @@ const reset = <T extends { reset: () => void }>(reset?: T[] | T) => {
348
347
  return reset;
349
348
  };
350
349
 
351
- function root<T>(fn: () => NeverAsync<T>, properties?: Root) {
350
+ function root<T>(fn: NeverAsync<() => T>, properties?: Root) {
352
351
  let o = observer,
353
352
  s = scope;
354
353
 
package/src/types.ts CHANGED
@@ -6,11 +6,11 @@ import Signal from './signal';
6
6
  type Changed = (a: unknown, b: unknown) => boolean;
7
7
 
8
8
  type Computed<T> = {
9
- fn: (previous: T) => NeverAsync<T>;
9
+ fn: NeverAsync<(previous: T) => T>;
10
10
  } & Omit<Signal<T>, 'fn'>;
11
11
 
12
12
  type Effect = {
13
- fn: (node: Effect) => NeverAsync<void>;
13
+ fn: NeverAsync<(node: Effect) => void>;
14
14
  root: Root;
15
15
  task: Function
16
16
  value: void;