@esportsplus/reactivity 0.1.6 → 0.1.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/build/macro.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import CustomFunction from '@esportsplus/custom-function';
2
- import { Computed, Options } from './types';
2
+ import { Computed, NeverAsync, 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,5 +7,6 @@ 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, options?: Options) => Macro<A, R>;
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>;
11
11
  export default _default;
12
+ export { NeverAsync };
package/build/signal.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Changed, Computed, Effect, Event, Listener, Options, Root, Scheduler, State, SyncFunction, Type } from './types';
1
+ import { Changed, Computed, Effect, Event, Listener, NeverAsync, Options, Root, Scheduler, State, Type } from './types';
2
2
  declare class Signal<T> {
3
3
  changed: Changed | null;
4
4
  fn: Computed<T>['fn'] | Effect['fn'] | null;
@@ -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) => T) extends infer T_1 ? T_1 extends (previous: T) => T ? T_1 extends (...args: unknown[]) => unknown ? SyncFunction<((previous: T) => T) extends infer T_2 ? T_2 extends (previous: T) => T ? T_2 extends (...args: unknown[]) => unknown ? ReturnType<T_2> : T_2 : never : never, (((previous: T) => T) extends infer T_2 ? T_2 extends (previous: T) => T ? T_2 extends (...args: unknown[]) => unknown ? ReturnType<T_2> : T_2 : never : never) extends infer T_3 ? T_3 extends (((previous: T) => T) extends infer T_2 ? T_2 extends (previous: T) => T ? T_2 extends (...args: unknown[]) => unknown ? ReturnType<T_2> : T_2 : never : never) ? T_3 extends (...args: unknown[]) => unknown ? ReturnType<T_3> : T_3 : never : never> extends never ? never : T_1 : T_1 : never : never, options?: Options) => Computed<T>;
21
+ declare const computed: <T>(fn: (previous: T) => NeverAsync<T>, 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 const root: <T>(fn: SyncFunction<T, T extends (...args: unknown[]) => unknown ? ReturnType<T> : T> extends never ? never : () => T, properties?: Root) => T;
30
+ declare function root<T>(fn: () => NeverAsync<T>, properties?: Root): 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/signal.js CHANGED
@@ -266,7 +266,7 @@ const reset = (reset) => {
266
266
  }
267
267
  return reset;
268
268
  };
269
- const root = (fn, properties) => {
269
+ function root(fn, properties) {
270
270
  let o = observer, s = scope;
271
271
  if (properties === undefined) {
272
272
  if (scope === null) {
@@ -280,7 +280,8 @@ const root = (fn, properties) => {
280
280
  observer = o;
281
281
  scope = s;
282
282
  return result;
283
- };
283
+ }
284
+ ;
284
285
  const signal = (data, options = {}) => {
285
286
  return new Signal(data, CLEAN, SIGNAL, options);
286
287
  };
package/build/types.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { Function, Prettify, SyncFunction } from '@esportsplus/typescript';
1
+ import { Function, NeverAsync, Prettify } from '@esportsplus/typescript';
2
2
  import { CHECK, CLEAN, COMPUTED, DIRTY, DISPOSED, EFFECT, SIGNAL } from './constants';
3
3
  import Signal from './signal';
4
4
  type Changed = (a: unknown, b: unknown) => boolean;
5
5
  type Computed<T> = {
6
- fn: SyncFunction<(previous: T) => T>;
6
+ fn: (previous: T) => NeverAsync<T>;
7
7
  } & Omit<Signal<T>, 'fn'>;
8
8
  type Effect = {
9
- fn: SyncFunction<(node: Effect) => void>;
9
+ fn: (node: Effect) => NeverAsync<void>;
10
10
  root: Root;
11
11
  task: Function;
12
12
  value: void;
@@ -30,4 +30,4 @@ type Root = {
30
30
  type Scheduler = (fn: Function) => unknown;
31
31
  type State = typeof CHECK | typeof CLEAN | typeof DIRTY | typeof DISPOSED;
32
32
  type Type = typeof COMPUTED | typeof EFFECT | typeof SIGNAL;
33
- export { Changed, Computed, Effect, Event, Listener, Object, Options, Prettify, Root, Scheduler, Signal, State, SyncFunction, Type };
33
+ export { Changed, Computed, Effect, Event, Listener, Object, Options, NeverAsync, Prettify, Root, Scheduler, Signal, State, Type };
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.6"
7
+ "@esportsplus/typescript": "^0.0.7"
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.6"
19
+ "version": "0.1.7"
20
20
  }
package/src/macro.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import CustomFunction from '@esportsplus/custom-function';
2
2
  import { computed, read } from './signal';
3
- import { Computed, Options } from './types';
3
+ import { Computed, NeverAsync, Options } from './types';
4
4
 
5
5
 
6
6
  type Function<A extends unknown[], R> = Computed<(...args: A) => R>['fn'];
7
7
 
8
8
 
9
9
  class Macro<A extends unknown[], R> extends CustomFunction {
10
- #factory: Computed< ReturnType<Function<A,R>> >;
10
+ #factory: Computed<(...args: A) => R>;
11
11
 
12
12
 
13
13
  constructor(fn: Function<A,R>, options: Options = {}) {
@@ -30,4 +30,5 @@ 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
- };
33
+ };
34
+ export { NeverAsync };
package/src/signal.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CHECK, CLEAN, COMPUTED, DIRTY, DISPOSED, EFFECT, SIGNAL } from './constants';
2
- import { Changed, Computed, Effect, Event, Listener, Options, Root, Scheduler, State, SyncFunction, Type } from './types';
2
+ import { Changed, Computed, Effect, Event, Listener, NeverAsync, Options, Root, Scheduler, State, Type } from './types';
3
3
  import { isArray } from './utilities';
4
4
 
5
5
 
@@ -348,7 +348,7 @@ const reset = <T extends { reset: () => void }>(reset?: T[] | T) => {
348
348
  return reset;
349
349
  };
350
350
 
351
- const root = <T>(fn: SyncFunction<() => T>, properties?: Root) => {
351
+ function root<T>(fn: () => NeverAsync<T>, properties?: Root) {
352
352
  let o = observer,
353
353
  s = scope;
354
354
 
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Function, Prettify, SyncFunction } from '@esportsplus/typescript'
1
+ import { Function, NeverAsync, Prettify } from '@esportsplus/typescript'
2
2
  import { CHECK, CLEAN, COMPUTED, DIRTY, DISPOSED, EFFECT, SIGNAL } from './constants';
3
3
  import Signal from './signal';
4
4
 
@@ -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: SyncFunction<(previous: T) => T>;
9
+ fn: (previous: T) => NeverAsync<T>;
10
10
  } & Omit<Signal<T>, 'fn'>;
11
11
 
12
12
  type Effect = {
13
- fn: SyncFunction<(node: Effect) => void>;
13
+ fn: (node: Effect) => NeverAsync<void>;
14
14
  root: Root;
15
15
  task: Function
16
16
  value: void;
@@ -42,4 +42,4 @@ type State = typeof CHECK | typeof CLEAN | typeof DIRTY | typeof DISPOSED;
42
42
  type Type = typeof COMPUTED | typeof EFFECT | typeof SIGNAL;
43
43
 
44
44
 
45
- export { Changed, Computed, Effect, Event, Listener, Object, Options, Prettify, Root, Scheduler, Signal, State, SyncFunction, Type };
45
+ export { Changed, Computed, Effect, Event, Listener, Object, Options, NeverAsync, Prettify, Root, Scheduler, Signal, State, Type };