@esportsplus/reactivity 0.16.1 → 0.16.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.
@@ -1,10 +1,9 @@
1
1
  import array from './array.js';
2
2
  import object from './object.js';
3
3
  type API<T> = T extends Record<PropertyKey, unknown> ? ReturnType<typeof object<T>> : T extends unknown[] ? ReturnType<typeof array<T>> : never;
4
- type Input<T> = T extends {
4
+ declare const _default: <T extends Record<PropertyKey, any> | unknown[]>(input: T extends {
5
5
  dispose: any;
6
6
  } ? {
7
- never: '[ dispose, signals ] are reserved keys';
8
- } : T extends Record<PropertyKey, unknown> | unknown[] ? T : never;
9
- declare const _default: <T>(input: Input<T>) => API<T>;
7
+ never: "[ dispose ] are reserved keys";
8
+ } : T) => API<T>;
10
9
  export default _default;
package/build/system.d.ts CHANGED
@@ -7,7 +7,7 @@ declare const isSignal: (value: unknown) => value is Signal<unknown>;
7
7
  declare const onCleanup: (fn: VoidFunction) => typeof fn;
8
8
  declare const read: <T>(node: Signal<T> | Computed<T>) => T;
9
9
  declare const root: {
10
- <T>(fn: (dispose?: VoidFunction) => T): T;
10
+ <T>(fn: ((dispose: VoidFunction) => T) | (() => T)): T;
11
11
  disposables: number;
12
12
  };
13
13
  declare const set: <T>(signal: Signal<T>, value: T) => void;
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "private": false,
13
13
  "type": "module",
14
14
  "types": "build/index.d.ts",
15
- "version": "0.16.1",
15
+ "version": "0.16.3",
16
16
  "scripts": {
17
17
  "build": "tsc && tsc-alias",
18
18
  "-": "-"
@@ -11,15 +11,10 @@ type API<T> =
11
11
  ? ReturnType<typeof array<T>>
12
12
  : never;
13
13
 
14
- type Input<T> =
15
- T extends { dispose: any }
16
- ? { never: '[ dispose, signals ] are reserved keys' }
17
- : T extends Record<PropertyKey, unknown> | unknown[]
18
- ? T
19
- : never;
20
-
21
14
 
22
- export default <T>(input: Input<T>): API<T> => {
15
+ export default <T extends Record<PropertyKey, any> | unknown[]>(
16
+ input: T extends { dispose: any } ? { never: '[ dispose ] are reserved keys' } : T
17
+ ): API<T> => {
23
18
  let dispose = false,
24
19
  value = root(() => {
25
20
  let response: API<T> | undefined;
package/src/system.ts CHANGED
@@ -464,7 +464,7 @@ const read = <T>(node: Signal<T> | Computed<T>): T => {
464
464
  return node.value;
465
465
  };
466
466
 
467
- const root = <T>(fn: (dispose?: VoidFunction) => T) => {
467
+ const root = <T>(fn: ((dispose: VoidFunction) => T) | (() => T)) => {
468
468
  let c,
469
469
  d = root.disposables,
470
470
  o = observer,
@@ -478,11 +478,11 @@ const root = <T>(fn: (dispose?: VoidFunction) => T) => {
478
478
 
479
479
  if (tracking) {
480
480
  scope = self = { cleanup: null } as Computed<unknown>;
481
- value = fn( c = () => dispose(self!) );
481
+ value = (fn as (dispose: VoidFunction) => T)(c = () => dispose(self!));
482
482
  }
483
483
  else {
484
484
  scope = null;
485
- value = fn();
485
+ value = (fn as () => T)();
486
486
  }
487
487
 
488
488
  observer = o;