@legendapp/state 3.0.0-beta.4 → 3.0.0-beta.40
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/.DS_Store +0 -0
- package/README.md +2 -2
- package/config/enableReactComponents.js +3 -1
- package/config/enableReactComponents.mjs +3 -1
- package/config/enableReactTracking.d.mts +2 -1
- package/config/enableReactTracking.d.ts +2 -1
- package/config/enableReactTracking.js +32 -13
- package/config/enableReactTracking.mjs +32 -13
- package/index.d.mts +46 -8
- package/index.d.ts +46 -8
- package/index.js +267 -75
- package/index.mjs +267 -75
- package/package.json +35 -1
- package/persist-plugins/async-storage.js +17 -9
- package/persist-plugins/async-storage.mjs +17 -9
- package/persist-plugins/expo-sqlite.d.mts +19 -0
- package/persist-plugins/expo-sqlite.d.ts +19 -0
- package/persist-plugins/expo-sqlite.js +72 -0
- package/persist-plugins/expo-sqlite.mjs +69 -0
- package/persist-plugins/indexeddb.js +13 -3
- package/persist-plugins/indexeddb.mjs +13 -3
- package/react-native.d.mts +4 -0
- package/react-native.d.ts +4 -0
- package/react-native.js +53 -0
- package/react-native.mjs +40 -0
- package/react-reactive/Components.d.mts +19 -0
- package/react-reactive/Components.d.ts +19 -0
- package/react-reactive/Components.js +53 -0
- package/react-reactive/Components.mjs +40 -0
- package/react-reactive/enableReactComponents.d.mts +3 -2
- package/react-reactive/enableReactComponents.d.ts +3 -2
- package/react-reactive/enableReactComponents.js +10 -3
- package/react-reactive/enableReactComponents.mjs +10 -3
- package/react-reactive/enableReactNativeComponents.d.mts +3 -20
- package/react-reactive/enableReactNativeComponents.d.ts +3 -20
- package/react-reactive/enableReactNativeComponents.js +8 -3
- package/react-reactive/enableReactNativeComponents.mjs +8 -3
- package/react-reactive/enableReactive.js +10 -3
- package/react-reactive/enableReactive.mjs +10 -3
- package/react-reactive/enableReactive.native.js +8 -3
- package/react-reactive/enableReactive.native.mjs +8 -3
- package/react-reactive/enableReactive.web.js +8 -3
- package/react-reactive/enableReactive.web.mjs +8 -3
- package/react-web.d.mts +7 -0
- package/react-web.d.ts +7 -0
- package/react-web.js +39 -0
- package/react-web.mjs +37 -0
- package/react.d.mts +59 -26
- package/react.d.ts +59 -26
- package/react.js +136 -87
- package/react.mjs +135 -89
- package/sync-plugins/crud.d.mts +24 -9
- package/sync-plugins/crud.d.ts +24 -9
- package/sync-plugins/crud.js +267 -123
- package/sync-plugins/crud.mjs +268 -124
- package/sync-plugins/firebase.d.mts +7 -3
- package/sync-plugins/firebase.d.ts +7 -3
- package/sync-plugins/firebase.js +214 -64
- package/sync-plugins/firebase.mjs +215 -65
- package/sync-plugins/keel.d.mts +12 -13
- package/sync-plugins/keel.d.ts +12 -13
- package/sync-plugins/keel.js +60 -52
- package/sync-plugins/keel.mjs +61 -48
- package/sync-plugins/supabase.d.mts +10 -5
- package/sync-plugins/supabase.d.ts +10 -5
- package/sync-plugins/supabase.js +90 -33
- package/sync-plugins/supabase.mjs +91 -34
- package/sync-plugins/tanstack-query.d.mts +3 -3
- package/sync-plugins/tanstack-query.d.ts +3 -3
- package/sync-plugins/tanstack-query.js +1 -1
- package/sync-plugins/tanstack-query.mjs +1 -1
- package/sync.d.mts +17 -8
- package/sync.d.ts +17 -8
- package/sync.js +448 -307
- package/sync.mjs +446 -307
- package/trace.js +5 -6
- package/trace.mjs +5 -6
- package/types/reactive-native.d.ts +19 -0
- 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" &&
|
|
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" &&
|
|
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
|
+
}
|