@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
package/trace.js CHANGED
@@ -19,13 +19,12 @@ function getNodePath(node) {
19
19
  // src/trace/useTraceListeners.ts
20
20
  var { optimized, tracking } = state.internal;
21
21
  function useTraceListeners(name) {
22
- if (process.env.NODE_ENV === "development" && tracking.current) {
22
+ if ((process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") && tracking.current) {
23
23
  tracking.current.traceListeners = traceNodes.bind(this, name);
24
24
  }
25
25
  }
26
26
  function traceNodes(name, nodes) {
27
- if (process.env.NODE_ENV === "development" && tracking.current) {
28
- tracking.current.traceListeners = void 0;
27
+ if ((process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") && nodes.size) {
29
28
  const arr = [];
30
29
  if (nodes) {
31
30
  for (const tracked of nodes.values()) {
@@ -45,7 +44,7 @@ ${arr.join("\n")}`
45
44
  }
46
45
  var { tracking: tracking2 } = state.internal;
47
46
  function useTraceUpdates(name) {
48
- if (process.env.NODE_ENV === "development" && tracking2.current) {
47
+ if ((process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") && tracking2.current) {
49
48
  tracking2.current.traceUpdates = replaceUpdateFn.bind(void 0, name);
50
49
  }
51
50
  }
@@ -54,13 +53,13 @@ function replaceUpdateFn(name, updateFn) {
54
53
  }
55
54
  function onChange(name, updateFn, params) {
56
55
  const { changes } = params;
57
- if (process.env.NODE_ENV === "development") {
56
+ if (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") {
58
57
  changes.forEach(({ path, valueAtPath, prevAtPath }) => {
59
58
  console.log(`[legend-state] Rendering ${name ? name + " " : ""}because "${path}" changed:
60
59
  from: ${JSON.stringify(prevAtPath)}
61
60
  to: ${JSON.stringify(valueAtPath)}`);
62
61
  });
63
- return updateFn();
62
+ return updateFn(params);
64
63
  }
65
64
  }
66
65
  var { optimized: optimized2, tracking: tracking3 } = state.internal;
package/trace.mjs CHANGED
@@ -17,13 +17,12 @@ function getNodePath(node) {
17
17
  // src/trace/useTraceListeners.ts
18
18
  var { optimized, tracking } = internal;
19
19
  function useTraceListeners(name) {
20
- if (process.env.NODE_ENV === "development" && tracking.current) {
20
+ if ((process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") && tracking.current) {
21
21
  tracking.current.traceListeners = traceNodes.bind(this, name);
22
22
  }
23
23
  }
24
24
  function traceNodes(name, nodes) {
25
- if (process.env.NODE_ENV === "development" && tracking.current) {
26
- tracking.current.traceListeners = void 0;
25
+ if ((process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") && nodes.size) {
27
26
  const arr = [];
28
27
  if (nodes) {
29
28
  for (const tracked of nodes.values()) {
@@ -43,7 +42,7 @@ ${arr.join("\n")}`
43
42
  }
44
43
  var { tracking: tracking2 } = internal;
45
44
  function useTraceUpdates(name) {
46
- if (process.env.NODE_ENV === "development" && tracking2.current) {
45
+ if ((process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") && tracking2.current) {
47
46
  tracking2.current.traceUpdates = replaceUpdateFn.bind(void 0, name);
48
47
  }
49
48
  }
@@ -52,13 +51,13 @@ function replaceUpdateFn(name, updateFn) {
52
51
  }
53
52
  function onChange(name, updateFn, params) {
54
53
  const { changes } = params;
55
- if (process.env.NODE_ENV === "development") {
54
+ if (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") {
56
55
  changes.forEach(({ path, valueAtPath, prevAtPath }) => {
57
56
  console.log(`[legend-state] Rendering ${name ? name + " " : ""}because "${path}" changed:
58
57
  from: ${JSON.stringify(prevAtPath)}
59
58
  to: ${JSON.stringify(valueAtPath)}`);
60
59
  });
61
- return updateFn();
60
+ return updateFn(params);
62
61
  }
63
62
  }
64
63
  var { optimized: optimized2, tracking: tracking3 } = internal;
@@ -0,0 +1,19 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
+ import type { IReactive } from '@legendapp/state/react';
3
+
4
+ declare module '@legendapp/state/react' {
5
+ interface IReactive {
6
+ ActivityIndicator: FCReactive<ActivityIndicator, ActivityIndicatorProps>;
7
+ Button: FCReactive<Button, ButtonProps>;
8
+ FlatList: FCReactive<FlatList, FlatListProps<any>>;
9
+ Image: FCReactive<Image, ImageProps>;
10
+ Pressable: FCReactive<typeof Pressable, PressableProps>;
11
+ ScrollView: FCReactive<ScrollView, ScrollViewProps>;
12
+ SectionList: FCReactive<SectionList, SectionListProps<any>>;
13
+ Switch: FCReactive<Switch, SwitchProps>;
14
+ Text: FCReactive<Text, TextProps>;
15
+ TextInput: FCReactive<TextInput, TextInputProps>;
16
+ TouchableWithoutFeedback: FCReactive<TouchableWithoutFeedback, TouchableWithoutFeedbackProps>;
17
+ View: FCReactive<View, ViewProps>;
18
+ }
19
+ }
@@ -0,0 +1,7 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
+ import type { IReactive, FCReactiveObject } from '@legendapp/state/react';
3
+
4
+ declare module '@legendapp/state/react' {
5
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
6
+ interface IReactive extends FCReactiveObject<JSX.IntrinsicElements> {}
7
+ }