@legendapp/state 3.0.0-beta.4 → 3.0.0-beta.41

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.
Files changed (79) hide show
  1. package/.DS_Store +0 -0
  2. package/README.md +2 -2
  3. package/config/enableReactComponents.js +3 -1
  4. package/config/enableReactComponents.mjs +3 -1
  5. package/config/enableReactTracking.d.mts +2 -1
  6. package/config/enableReactTracking.d.ts +2 -1
  7. package/config/enableReactTracking.js +32 -13
  8. package/config/enableReactTracking.mjs +32 -13
  9. package/index.d.mts +46 -8
  10. package/index.d.ts +46 -8
  11. package/index.js +267 -75
  12. package/index.mjs +267 -75
  13. package/package.json +35 -1
  14. package/persist-plugins/async-storage.js +17 -9
  15. package/persist-plugins/async-storage.mjs +17 -9
  16. package/persist-plugins/expo-sqlite.d.mts +19 -0
  17. package/persist-plugins/expo-sqlite.d.ts +19 -0
  18. package/persist-plugins/expo-sqlite.js +72 -0
  19. package/persist-plugins/expo-sqlite.mjs +69 -0
  20. package/persist-plugins/indexeddb.js +13 -3
  21. package/persist-plugins/indexeddb.mjs +13 -3
  22. package/react-native.d.mts +4 -0
  23. package/react-native.d.ts +4 -0
  24. package/react-native.js +53 -0
  25. package/react-native.mjs +40 -0
  26. package/react-reactive/Components.d.mts +19 -0
  27. package/react-reactive/Components.d.ts +19 -0
  28. package/react-reactive/Components.js +53 -0
  29. package/react-reactive/Components.mjs +40 -0
  30. package/react-reactive/enableReactComponents.d.mts +3 -2
  31. package/react-reactive/enableReactComponents.d.ts +3 -2
  32. package/react-reactive/enableReactComponents.js +10 -3
  33. package/react-reactive/enableReactComponents.mjs +10 -3
  34. package/react-reactive/enableReactNativeComponents.d.mts +3 -20
  35. package/react-reactive/enableReactNativeComponents.d.ts +3 -20
  36. package/react-reactive/enableReactNativeComponents.js +8 -3
  37. package/react-reactive/enableReactNativeComponents.mjs +8 -3
  38. package/react-reactive/enableReactive.js +10 -3
  39. package/react-reactive/enableReactive.mjs +10 -3
  40. package/react-reactive/enableReactive.native.js +8 -3
  41. package/react-reactive/enableReactive.native.mjs +8 -3
  42. package/react-reactive/enableReactive.web.js +8 -3
  43. package/react-reactive/enableReactive.web.mjs +8 -3
  44. package/react-web.d.mts +7 -0
  45. package/react-web.d.ts +7 -0
  46. package/react-web.js +39 -0
  47. package/react-web.mjs +37 -0
  48. package/react.d.mts +59 -26
  49. package/react.d.ts +59 -26
  50. package/react.js +136 -87
  51. package/react.mjs +135 -89
  52. package/sync-plugins/crud.d.mts +24 -9
  53. package/sync-plugins/crud.d.ts +24 -9
  54. package/sync-plugins/crud.js +267 -123
  55. package/sync-plugins/crud.mjs +268 -124
  56. package/sync-plugins/firebase.d.mts +7 -3
  57. package/sync-plugins/firebase.d.ts +7 -3
  58. package/sync-plugins/firebase.js +214 -64
  59. package/sync-plugins/firebase.mjs +215 -65
  60. package/sync-plugins/keel.d.mts +12 -13
  61. package/sync-plugins/keel.d.ts +12 -13
  62. package/sync-plugins/keel.js +60 -52
  63. package/sync-plugins/keel.mjs +61 -48
  64. package/sync-plugins/supabase.d.mts +10 -5
  65. package/sync-plugins/supabase.d.ts +10 -5
  66. package/sync-plugins/supabase.js +90 -33
  67. package/sync-plugins/supabase.mjs +91 -34
  68. package/sync-plugins/tanstack-query.d.mts +3 -3
  69. package/sync-plugins/tanstack-query.d.ts +3 -3
  70. package/sync-plugins/tanstack-query.js +1 -1
  71. package/sync-plugins/tanstack-query.mjs +1 -1
  72. package/sync.d.mts +17 -8
  73. package/sync.d.ts +17 -8
  74. package/sync.js +448 -307
  75. package/sync.mjs +446 -307
  76. package/trace.js +5 -6
  77. package/trace.mjs +5 -6
  78. package/types/reactive-native.d.ts +19 -0
  79. package/types/reactive-web.d.ts +7 -0
@@ -1,6 +1,13 @@
1
1
  // src/react-reactive/enableReactComponents.ts
2
- function enableReactComponents(config) {
3
- const bindInfo = { value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" } };
2
+ var isEnabled = false;
3
+ function enableReactComponents_(config) {
4
+ if (isEnabled) {
5
+ return;
6
+ }
7
+ isEnabled = true;
8
+ const bindInfo = {
9
+ value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" }
10
+ };
4
11
  const bindInfoInput = Object.assign(
5
12
  { checked: { handler: "onChange", getValue: (e) => e.target.checked } },
6
13
  bindInfo
@@ -14,4 +21,4 @@ function enableReactComponents(config) {
14
21
  });
15
22
  }
16
23
 
17
- export { enableReactComponents };
24
+ export { enableReactComponents_ };
@@ -1,22 +1,5 @@
1
- import { FCReactiveObject, FCReactive, configureReactive } from '@legendapp/state/react';
2
- import { ActivityIndicator, ActivityIndicatorProps, Button, ButtonProps, FlatList, FlatListProps, Image, ImageProps, Pressable, PressableProps, ScrollView, ScrollViewProps, SectionList, SectionListProps, Switch, SwitchProps, Text, TextProps, TextInput, TextInputProps, TouchableWithoutFeedback, TouchableWithoutFeedbackProps, View, ViewProps } from 'react-native';
1
+ import { configureReactive } from '@legendapp/state/react';
3
2
 
4
- declare function enableReactNativeComponents(configure: typeof configureReactive): void;
5
- declare module '@legendapp/state/react' {
6
- interface IReactive extends FCReactiveObject<JSX.IntrinsicElements> {
7
- ActivityIndicator: FCReactive<ActivityIndicator, ActivityIndicatorProps>;
8
- Button: FCReactive<Button, ButtonProps>;
9
- FlatList: FCReactive<FlatList, FlatListProps<any>>;
10
- Image: FCReactive<Image, ImageProps>;
11
- Pressable: FCReactive<typeof Pressable, PressableProps>;
12
- ScrollView: FCReactive<ScrollView, ScrollViewProps>;
13
- SectionList: FCReactive<SectionList, SectionListProps<any>>;
14
- Switch: FCReactive<Switch, SwitchProps>;
15
- Text: FCReactive<Text, TextProps>;
16
- TextInput: FCReactive<TextInput, TextInputProps>;
17
- TouchableWithoutFeedback: FCReactive<TouchableWithoutFeedback, TouchableWithoutFeedbackProps>;
18
- View: FCReactive<View, ViewProps>;
19
- }
20
- }
3
+ declare function enableReactNativeComponents_(configure: typeof configureReactive): void;
21
4
 
22
- export { enableReactNativeComponents };
5
+ export { enableReactNativeComponents_ };
@@ -1,22 +1,5 @@
1
- import { FCReactiveObject, FCReactive, configureReactive } from '@legendapp/state/react';
2
- import { ActivityIndicator, ActivityIndicatorProps, Button, ButtonProps, FlatList, FlatListProps, Image, ImageProps, Pressable, PressableProps, ScrollView, ScrollViewProps, SectionList, SectionListProps, Switch, SwitchProps, Text, TextProps, TextInput, TextInputProps, TouchableWithoutFeedback, TouchableWithoutFeedbackProps, View, ViewProps } from 'react-native';
1
+ import { configureReactive } from '@legendapp/state/react';
3
2
 
4
- declare function enableReactNativeComponents(configure: typeof configureReactive): void;
5
- declare module '@legendapp/state/react' {
6
- interface IReactive extends FCReactiveObject<JSX.IntrinsicElements> {
7
- ActivityIndicator: FCReactive<ActivityIndicator, ActivityIndicatorProps>;
8
- Button: FCReactive<Button, ButtonProps>;
9
- FlatList: FCReactive<FlatList, FlatListProps<any>>;
10
- Image: FCReactive<Image, ImageProps>;
11
- Pressable: FCReactive<typeof Pressable, PressableProps>;
12
- ScrollView: FCReactive<ScrollView, ScrollViewProps>;
13
- SectionList: FCReactive<SectionList, SectionListProps<any>>;
14
- Switch: FCReactive<Switch, SwitchProps>;
15
- Text: FCReactive<Text, TextProps>;
16
- TextInput: FCReactive<TextInput, TextInputProps>;
17
- TouchableWithoutFeedback: FCReactive<TouchableWithoutFeedback, TouchableWithoutFeedbackProps>;
18
- View: FCReactive<View, ViewProps>;
19
- }
20
- }
3
+ declare function enableReactNativeComponents_(configure: typeof configureReactive): void;
21
4
 
22
- export { enableReactNativeComponents };
5
+ export { enableReactNativeComponents_ };
@@ -1,11 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var react = require('react');
4
3
  var react$1 = require('@legendapp/state/react');
4
+ var react = require('react');
5
5
  var reactNative = require('react-native');
6
6
 
7
7
  // src/react-reactive/enableReactNativeComponents.ts
8
- function enableReactNativeComponents(configure) {
8
+ var isEnabled = false;
9
+ function enableReactNativeComponents_(configure) {
10
+ if (isEnabled) {
11
+ return;
12
+ }
13
+ isEnabled = true;
9
14
  configure({
10
15
  components: {
11
16
  ActivityIndicator: reactNative.ActivityIndicator,
@@ -50,4 +55,4 @@ function enableReactNativeComponents(configure) {
50
55
  });
51
56
  }
52
57
 
53
- exports.enableReactNativeComponents = enableReactNativeComponents;
58
+ exports.enableReactNativeComponents_ = enableReactNativeComponents_;
@@ -1,9 +1,14 @@
1
- import { useRef } from 'react';
2
1
  import { useSelector } from '@legendapp/state/react';
2
+ import { useRef } from 'react';
3
3
  import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
4
4
 
5
5
  // src/react-reactive/enableReactNativeComponents.ts
6
- function enableReactNativeComponents(configure) {
6
+ var isEnabled = false;
7
+ function enableReactNativeComponents_(configure) {
8
+ if (isEnabled) {
9
+ return;
10
+ }
11
+ isEnabled = true;
7
12
  configure({
8
13
  components: {
9
14
  ActivityIndicator,
@@ -48,4 +53,4 @@ function enableReactNativeComponents(configure) {
48
53
  });
49
54
  }
50
55
 
51
- export { enableReactNativeComponents };
56
+ export { enableReactNativeComponents_ };
@@ -1,8 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  // src/react-reactive/enableReactComponents.ts
4
- function enableReactComponents(config) {
5
- const bindInfo = { value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" } };
4
+ var isEnabled = false;
5
+ function enableReactComponents_(config) {
6
+ if (isEnabled) {
7
+ return;
8
+ }
9
+ isEnabled = true;
10
+ const bindInfo = {
11
+ value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" }
12
+ };
6
13
  const bindInfoInput = Object.assign(
7
14
  { checked: { handler: "onChange", getValue: (e) => e.target.checked } },
8
15
  bindInfo
@@ -18,7 +25,7 @@ function enableReactComponents(config) {
18
25
 
19
26
  // src/react-reactive/enableReactive.ts
20
27
  function enableReactive(config) {
21
- enableReactComponents(config);
28
+ enableReactComponents_(config);
22
29
  }
23
30
 
24
31
  exports.enableReactive = enableReactive;
@@ -1,6 +1,13 @@
1
1
  // src/react-reactive/enableReactComponents.ts
2
- function enableReactComponents(config) {
3
- const bindInfo = { value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" } };
2
+ var isEnabled = false;
3
+ function enableReactComponents_(config) {
4
+ if (isEnabled) {
5
+ return;
6
+ }
7
+ isEnabled = true;
8
+ const bindInfo = {
9
+ value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" }
10
+ };
4
11
  const bindInfoInput = Object.assign(
5
12
  { checked: { handler: "onChange", getValue: (e) => e.target.checked } },
6
13
  bindInfo
@@ -16,7 +23,7 @@ function enableReactComponents(config) {
16
23
 
17
24
  // src/react-reactive/enableReactive.ts
18
25
  function enableReactive(config) {
19
- enableReactComponents(config);
26
+ enableReactComponents_(config);
20
27
  }
21
28
 
22
29
  export { enableReactive };
@@ -1,11 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var react = require('react');
4
3
  var react$1 = require('@legendapp/state/react');
4
+ var react = require('react');
5
5
  var reactNative = require('react-native');
6
6
 
7
7
  // src/react-reactive/enableReactNativeComponents.ts
8
- function enableReactNativeComponents(configure) {
8
+ var isEnabled = false;
9
+ function enableReactNativeComponents_(configure) {
10
+ if (isEnabled) {
11
+ return;
12
+ }
13
+ isEnabled = true;
9
14
  configure({
10
15
  components: {
11
16
  ActivityIndicator: reactNative.ActivityIndicator,
@@ -52,7 +57,7 @@ function enableReactNativeComponents(configure) {
52
57
 
53
58
  // src/react-reactive/enableReactive.native.ts
54
59
  function enableReactive(configure) {
55
- enableReactNativeComponents(configure);
60
+ enableReactNativeComponents_(configure);
56
61
  }
57
62
 
58
63
  exports.enableReactive = enableReactive;
@@ -1,9 +1,14 @@
1
- import { useRef } from 'react';
2
1
  import { useSelector } from '@legendapp/state/react';
2
+ import { useRef } from 'react';
3
3
  import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
4
4
 
5
5
  // src/react-reactive/enableReactNativeComponents.ts
6
- function enableReactNativeComponents(configure) {
6
+ var isEnabled = false;
7
+ function enableReactNativeComponents_(configure) {
8
+ if (isEnabled) {
9
+ return;
10
+ }
11
+ isEnabled = true;
7
12
  configure({
8
13
  components: {
9
14
  ActivityIndicator,
@@ -50,7 +55,7 @@ function enableReactNativeComponents(configure) {
50
55
 
51
56
  // src/react-reactive/enableReactive.native.ts
52
57
  function enableReactive(configure) {
53
- enableReactNativeComponents(configure);
58
+ enableReactNativeComponents_(configure);
54
59
  }
55
60
 
56
61
  export { enableReactive };
@@ -1,11 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var react = require('react');
4
3
  var react$1 = require('@legendapp/state/react');
4
+ var react = require('react');
5
5
  var reactNative = require('react-native');
6
6
 
7
7
  // src/react-reactive/enableReactNativeComponents.ts
8
- function enableReactNativeComponents(configure) {
8
+ var isEnabled = false;
9
+ function enableReactNativeComponents_(configure) {
10
+ if (isEnabled) {
11
+ return;
12
+ }
13
+ isEnabled = true;
9
14
  configure({
10
15
  components: {
11
16
  ActivityIndicator: reactNative.ActivityIndicator,
@@ -52,7 +57,7 @@ function enableReactNativeComponents(configure) {
52
57
 
53
58
  // src/react-reactive/enableReactive.web.ts
54
59
  function enableReactive(configure) {
55
- enableReactNativeComponents(configure);
60
+ enableReactNativeComponents_(configure);
56
61
  }
57
62
 
58
63
  exports.enableReactive = enableReactive;
@@ -1,9 +1,14 @@
1
- import { useRef } from 'react';
2
1
  import { useSelector } from '@legendapp/state/react';
2
+ import { useRef } from 'react';
3
3
  import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
4
4
 
5
5
  // src/react-reactive/enableReactNativeComponents.ts
6
- function enableReactNativeComponents(configure) {
6
+ var isEnabled = false;
7
+ function enableReactNativeComponents_(configure) {
8
+ if (isEnabled) {
9
+ return;
10
+ }
11
+ isEnabled = true;
7
12
  configure({
8
13
  components: {
9
14
  ActivityIndicator,
@@ -50,7 +55,7 @@ function enableReactNativeComponents(configure) {
50
55
 
51
56
  // src/react-reactive/enableReactive.web.ts
52
57
  function enableReactive(configure) {
53
- enableReactNativeComponents(configure);
58
+ enableReactNativeComponents_(configure);
54
59
  }
55
60
 
56
61
  export { enableReactive };
@@ -0,0 +1,7 @@
1
+ import { FCReactiveObject } from '@legendapp/state/react';
2
+ import { JSX } from 'react';
3
+
4
+ type IReactive = FCReactiveObject<JSX.IntrinsicElements>;
5
+ declare const $React: IReactive;
6
+
7
+ export { $React };
package/react-web.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { FCReactiveObject } from '@legendapp/state/react';
2
+ import { JSX } from 'react';
3
+
4
+ type IReactive = FCReactiveObject<JSX.IntrinsicElements>;
5
+ declare const $React: IReactive;
6
+
7
+ export { $React };
package/react-web.js ADDED
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ var state = require('@legendapp/state');
4
+ var react$1 = require('@legendapp/state/react');
5
+ var react = require('react');
6
+
7
+ // src/react-web/$React.tsx
8
+ var bindInfoOneWay = {
9
+ value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" }
10
+ };
11
+ var bindInfoInput = Object.assign(
12
+ { checked: { handler: "onChange", getValue: (e) => e.target.checked } },
13
+ bindInfoOneWay
14
+ );
15
+ var binders = /* @__PURE__ */ new Map([
16
+ ["input", bindInfoInput],
17
+ ["textarea", bindInfoOneWay],
18
+ ["select", bindInfoOneWay]
19
+ ]);
20
+ var $React = new Proxy(
21
+ {},
22
+ {
23
+ get(target, p) {
24
+ if (!target[p]) {
25
+ const render = react.forwardRef((props, ref) => {
26
+ const propsOut = { ...props };
27
+ if (ref && (state.isFunction(ref) || !state.isEmpty(ref))) {
28
+ propsOut.ref = ref;
29
+ }
30
+ return react.createElement(p, propsOut);
31
+ });
32
+ target[p] = react$1.reactive(render, [], binders.get(p));
33
+ }
34
+ return target[p];
35
+ }
36
+ }
37
+ );
38
+
39
+ exports.$React = $React;
package/react-web.mjs ADDED
@@ -0,0 +1,37 @@
1
+ import { isFunction, isEmpty } from '@legendapp/state';
2
+ import { reactive } from '@legendapp/state/react';
3
+ import { forwardRef, createElement } from 'react';
4
+
5
+ // src/react-web/$React.tsx
6
+ var bindInfoOneWay = {
7
+ value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" }
8
+ };
9
+ var bindInfoInput = Object.assign(
10
+ { checked: { handler: "onChange", getValue: (e) => e.target.checked } },
11
+ bindInfoOneWay
12
+ );
13
+ var binders = /* @__PURE__ */ new Map([
14
+ ["input", bindInfoInput],
15
+ ["textarea", bindInfoOneWay],
16
+ ["select", bindInfoOneWay]
17
+ ]);
18
+ var $React = new Proxy(
19
+ {},
20
+ {
21
+ get(target, p) {
22
+ if (!target[p]) {
23
+ const render = forwardRef((props, ref) => {
24
+ const propsOut = { ...props };
25
+ if (ref && (isFunction(ref) || !isEmpty(ref))) {
26
+ propsOut.ref = ref;
27
+ }
28
+ return createElement(p, propsOut);
29
+ });
30
+ target[p] = reactive(render, [], binders.get(p));
31
+ }
32
+ return target[p];
33
+ }
34
+ }
35
+ );
36
+
37
+ export { $React };
package/react.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import * as react from 'react';
2
- import { ReactNode, ReactElement, FC, LegacyRef, DependencyList, ReducerWithoutAction, ReducerStateWithoutAction, DispatchWithoutAction, Reducer, ReducerState, Dispatch, ReducerAction, ComponentClass } from 'react';
3
- import { ObservableParam, Observable, ObservableBoolean, Selector, RecursiveValueOrFunction, ObserveOptions, ObserveEvent, ObserveEventCallback } from '@legendapp/state';
1
+ import * as React from 'react';
2
+ import { ReactNode, ReactElement, FC, NamedExoticComponent, LegacyRef, DependencyList, ReducerWithoutAction, ReducerStateWithoutAction, DispatchWithoutAction, Reducer, ReducerState, Dispatch, ReducerAction, ComponentClass } from 'react';
3
+ import { ObservableParam, Observable, ObservableBoolean, Selector, GetOptions, RecursiveValueOrFunction, ObserveOptions, ObserveEvent, ObserveEventCallback } from '@legendapp/state';
4
4
 
5
5
  declare function Computed({ children }: {
6
6
  children: ObservableParam | (() => ReactNode);
@@ -22,11 +22,14 @@ declare function For<T, TProps>({ each, optimized: isOptimized, item, itemProps,
22
22
  declare function usePauseProvider(): {
23
23
  PauseProvider: ({ children }: {
24
24
  children: ReactNode;
25
- }) => react.FunctionComponentElement<react.ProviderProps<ObservableBoolean>>;
25
+ }) => React.FunctionComponentElement<React.ProviderProps<ObservableBoolean>>;
26
26
  isPaused$: ObservableBoolean;
27
27
  };
28
28
 
29
- declare const Memo: react.MemoExoticComponent<typeof Computed>;
29
+ declare const Memo: NamedExoticComponent<{
30
+ children: any;
31
+ scoped?: boolean;
32
+ }>;
30
33
 
31
34
  interface IReactive {
32
35
  }
@@ -43,7 +46,9 @@ interface PropsIfReady<T> {
43
46
  interface PropsBase<T> {
44
47
  else?: ReactNode | (() => ReactNode);
45
48
  $value?: Observable<T>;
46
- wrap?: FC;
49
+ wrap?: FC<{
50
+ children: ReactNode;
51
+ }>;
47
52
  children: ReactNode | ((value?: T) => ReactNode);
48
53
  }
49
54
  type Props<T> = PropsBase<T> & (PropsIf<T> | PropsIfReady<T>);
@@ -54,11 +59,11 @@ declare function Switch<T extends object>({ value, children, }: {
54
59
  children: Partial<Record<keyof T | 'null' | 'undefined' | 'default', () => ReactNode>>;
55
60
  }): ReactElement | null;
56
61
  declare function Switch<T extends string | number | symbol>({ value, children, }: {
57
- value?: Selector<T>;
62
+ value?: Selector<T | undefined | null>;
58
63
  children: Partial<Record<T | 'null' | 'undefined' | 'default', () => ReactNode>>;
59
64
  }): ReactElement | null;
60
65
  declare function Switch<T extends boolean>({ value, children, }: {
61
- value?: Selector<T>;
66
+ value?: Selector<T | undefined | null>;
62
67
  children: Partial<Record<'false' | 'true' | 'null' | 'undefined' | 'default', () => ReactNode>>;
63
68
  }): ReactElement | null;
64
69
  declare function Switch<T>({ value, children, }: {
@@ -71,41 +76,59 @@ type ShapeWithNew$<T> = Partial<Omit<T, 'children'>> & {
71
76
  } & {
72
77
  children?: Selector<ReactNode>;
73
78
  };
74
- interface BindKey<P> {
75
- handler?: keyof P;
76
- getValue?: (e: any) => any;
79
+ interface BindKey<P, K extends keyof P = keyof P> {
80
+ handler?: K;
81
+ getValue?: P[K] extends infer T ? T extends (...args: any) => any ? (params: Parameters<T>[0]) => any : (e: any) => any : (e: any) => any;
77
82
  defaultValue?: any;
78
83
  selector?: (propsOut: Record<string, any>, p: Observable<any>) => any;
79
84
  }
80
- type BindKeys<P = any> = Partial<Record<keyof P, BindKey<P>>>;
85
+ type BindKeys<P = any, K extends keyof P = keyof P> = Partial<Record<K, BindKey<P>>>;
81
86
  type FCReactiveObject<T> = {
82
87
  [K in keyof T]: FC<ShapeWithNew$<T[K]>>;
83
88
  };
84
89
  type FCReactive<P, P2> = P & FC<ShapeWithNew$<P2> & {
85
90
  ref?: LegacyRef<P> | undefined;
86
91
  }>;
87
- interface UseSelectorOptions {
92
+ interface UseSelectorOptions extends GetOptions {
88
93
  suspense?: boolean;
89
94
  skipCheck?: boolean;
90
95
  }
91
96
 
92
- type ShapeWithPick$<T, T2 extends keyof T = keyof T> = Partial<T> & {
93
- [K in T2 as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
94
- };
95
- type ShapeWith$<T> = Partial<T> & {
97
+ type WithSelectorChildren<T> = T extends any ? T extends {
98
+ children?: infer C;
99
+ } ? Omit<T, 'children'> & {
100
+ children?: C | Selector<C>;
101
+ } : T extends {
102
+ children: infer C;
103
+ } ? Omit<T, 'children'> & {
104
+ children: C | Selector<C>;
105
+ } : T : never;
106
+ type ShapeWith$<T> = WithSelectorChildren<Partial<T>> & {
96
107
  [K in keyof T as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
97
108
  };
98
109
  type ObjectShapeWith$<T> = {
99
110
  [K in keyof T]: T[K] extends FC<infer P> ? FC<ShapeWith$<P>> : T[K];
100
111
  };
101
- type ExtractFCPropsType<T> = T extends FC<infer P> ? P : never;
112
+ type ReactifyProps<T, K extends keyof T> = T & {
113
+ [P in K as `$${string & P}`]?: Selector<T[P]>;
114
+ };
102
115
  declare const hasSymbol: false | ((key: string) => symbol);
103
116
  declare function observer<P extends FC<any>>(component: P): P;
104
- declare function reactive<T extends FC<any>>(component: T, bindKeys?: BindKeys<ExtractFCPropsType<T>>): T | FC<ShapeWith$<ExtractFCPropsType<T>>>;
105
- declare function reactive<T extends FC<any>, T2 extends keyof ExtractFCPropsType<T>>(component: T, bindKeys?: BindKeys<ExtractFCPropsType<T>>): T | FC<ShapeWithPick$<ExtractFCPropsType<T>, T2>>;
106
- declare function reactiveObserver<T extends FC<any>>(component: T, bindKeys?: BindKeys<ExtractFCPropsType<T>>): T | FC<ShapeWith$<ExtractFCPropsType<T>>>;
107
- declare function reactiveObserver<T extends FC<any>, T2 extends keyof ExtractFCPropsType<T>>(component: T, bindKeys?: BindKeys<ExtractFCPropsType<T>>): T | FC<ShapeWithPick$<ExtractFCPropsType<T>, T2>>;
108
- declare function reactiveComponents<P extends Record<string, FC>>(components: P): ObjectShapeWith$<P>;
117
+ declare function reactive<T extends object>(component: React.ComponentClass<T>, keys: undefined | null, bindKeys?: BindKeys<T>): React.FC<ShapeWith$<T>>;
118
+ declare function reactive<T extends object>(component: React.FC<T>, keys: undefined | null, bindKeys?: BindKeys<T>): React.FC<ShapeWith$<T>>;
119
+ declare function reactive<T extends object>(component: React.ForwardRefExoticComponent<T>, keys: undefined | null, bindKeys?: BindKeys<T>): React.ForwardRefExoticComponent<ShapeWith$<T>>;
120
+ declare function reactive<T extends object, K extends keyof T>(component: React.FC<T>, keys: K[] | (keyof T)[], bindKeys?: BindKeys<T, K>): React.FC<ReactifyProps<T, K>>;
121
+ declare function reactive<T extends object, K extends keyof T>(component: React.ForwardRefExoticComponent<T>, keys: K[] | (keyof T)[], bindKeys?: BindKeys<T, K>): React.ForwardRefExoticComponent<ReactifyProps<T, K>>;
122
+ declare function reactive<T extends object>(component: React.ComponentClass<T>): React.ComponentClass<ShapeWith$<T>>;
123
+ declare function reactive<T extends object>(component: React.FC<T>): React.FC<ShapeWith$<T>>;
124
+ declare function reactive<T extends object>(component: React.ForwardRefExoticComponent<T>): React.ForwardRefExoticComponent<ShapeWith$<T>>;
125
+ declare function reactiveObserver<T extends object>(component: React.FC<T>, keys: undefined | null, bindKeys?: BindKeys<T>): React.FC<ShapeWith$<T>>;
126
+ declare function reactiveObserver<T extends object>(component: React.ForwardRefExoticComponent<T>, keys: undefined | null, bindKeys?: BindKeys<T>): React.ForwardRefExoticComponent<ShapeWith$<T>>;
127
+ declare function reactiveObserver<T extends object, K extends keyof T>(component: React.FC<T>, keys: K[] | (keyof T)[], bindKeys?: BindKeys<T, K>): React.FC<ReactifyProps<T, K>>;
128
+ declare function reactiveObserver<T extends object, K extends keyof T>(component: React.ForwardRefExoticComponent<T>, keys: K[] | (keyof T)[], bindKeys?: BindKeys<T, K>): React.ForwardRefExoticComponent<ReactifyProps<T, K>>;
129
+ declare function reactiveObserver<T extends object>(component: React.FC<T>): React.FC<ShapeWith$<T>>;
130
+ declare function reactiveObserver<T extends object>(component: React.ForwardRefExoticComponent<T>): React.ForwardRefExoticComponent<ShapeWith$<T>>;
131
+ declare function reactiveComponents<P extends Record<string, any>>(components: P): ObjectShapeWith$<P>;
109
132
 
110
133
  declare function useComputed<T>(get: () => T | Promise<T>): Observable<T>;
111
134
  declare function useComputed<T>(get: () => T | Promise<T>, deps: any[]): Observable<T>;
@@ -140,23 +163,33 @@ declare function useObservableReducer<R extends Reducer<any, any>>(reducer: R, i
140
163
  interface UseObserveOptions extends ObserveOptions {
141
164
  deps?: any[];
142
165
  }
166
+ declare function useObserve<T>(run: (e: ObserveEvent<T>) => T | void): () => void;
167
+ declare function useObserve<T>(run: (e: ObserveEvent<T>) => T | void, deps?: any[]): () => void;
143
168
  declare function useObserve<T>(run: (e: ObserveEvent<T>) => T | void, options?: UseObserveOptions): () => void;
169
+ declare function useObserve<T>(run: (e: ObserveEvent<T>) => T | void, options?: UseObserveOptions, deps?: any[]): () => void;
144
170
  declare function useObserve<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?: UseObserveOptions): () => void;
171
+ declare function useObserve<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?: UseObserveOptions, deps?: any[]): () => void;
145
172
 
173
+ declare function useObserveEffect<T>(run: (e: ObserveEvent<T>) => T | void): void;
174
+ declare function useObserveEffect<T>(run: (e: ObserveEvent<T>) => T | void, deps?: any[]): void;
146
175
  declare function useObserveEffect<T>(run: (e: ObserveEvent<T>) => T | void, options?: UseObserveOptions): void;
176
+ declare function useObserveEffect<T>(run: (e: ObserveEvent<T>) => T | void, options?: UseObserveOptions, deps?: any[]): void;
147
177
  declare function useObserveEffect<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?: UseObserveOptions): void;
178
+ declare function useObserveEffect<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?: UseObserveOptions, deps?: any[]): void;
148
179
 
149
180
  declare function useSelector<T>(selector: Selector<T>, options?: UseSelectorOptions): T;
150
181
 
151
182
  declare function useUnmount(fn: () => void): void;
152
183
  declare const useUnmountOnce: typeof useUnmount;
153
184
 
154
- declare function useWhen<T>(predicate: Selector<T>, effect: (value: T) => any | (() => any)): Promise<any>;
155
- declare function useWhenReady<T>(predicate: Selector<T>, effect: (value: T) => any | (() => any)): Promise<any>;
185
+ declare function useWhen<T>(predicate: Selector<T>): Promise<T>;
186
+ declare function useWhen<T, T2>(predicate: Selector<T>, effect: (value: T) => T2): Promise<T2>;
187
+ declare function useWhenReady<T>(predicate: Selector<T>): Promise<T>;
188
+ declare function useWhenReady<T, T2>(predicate: Selector<T>, effect: (value: T) => T2 | (() => T2)): Promise<T2>;
156
189
 
157
190
  declare function configureReactive({ components, binders, }: {
158
191
  components?: Record<string, FC | ComponentClass<any>>;
159
192
  binders?: Record<string, BindKeys>;
160
193
  }): void;
161
194
 
162
- export { type BindKey, type BindKeys, Computed, type ExtractFCPropsType, type FCReactive, type FCReactiveObject, For, type IReactive, Memo, type ObjectShapeWith$, Reactive, type ShapeWith$, type ShapeWithNew$, type ShapeWithPick$, Show, Switch, type UseObserveOptions, type UseSelectorOptions, configureReactive, hasSymbol, observer, reactive, reactiveComponents, reactiveObserver, useComputed, useEffectOnce, useIsMounted, useMount, useMountOnce, useObservable, useObservableReducer, useObserve, useObserveEffect, usePauseProvider, useSelector, useUnmount, useUnmountOnce, useWhen, useWhenReady };
195
+ export { type BindKey, type BindKeys, Computed, type FCReactive, type FCReactiveObject, For, type IReactive, Memo, type ObjectShapeWith$, type ReactifyProps, Reactive, type ShapeWith$, type ShapeWithNew$, Show, Switch, type UseObserveOptions, type UseSelectorOptions, configureReactive, hasSymbol, observer, reactive, reactiveComponents, reactiveObserver, useSelector as use$, useComputed, useEffectOnce, useIsMounted, useObservable as useLocalObservable, useMount, useMountOnce, useObservable, useObservableReducer, useObserve, useObserveEffect, usePauseProvider, useSelector, useUnmount, useUnmountOnce, useSelector as useValue, useWhen, useWhenReady };