@legendapp/state 3.0.0-beta.2 → 3.0.0-beta.21
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/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 +13 -4
- package/index.d.ts +13 -4
- package/index.js +70 -22
- package/index.mjs +70 -22
- package/package.json +22 -1
- package/persist-plugins/async-storage.js +17 -9
- package/persist-plugins/async-storage.mjs +17 -9
- 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 +6 -0
- package/react-web.d.ts +6 -0
- package/react-web.js +39 -0
- package/react-web.mjs +37 -0
- package/react.d.mts +38 -20
- package/react.d.ts +38 -20
- package/react.js +36 -23
- package/react.mjs +37 -25
- package/sync-plugins/crud.d.mts +24 -9
- package/sync-plugins/crud.d.ts +24 -9
- package/sync-plugins/crud.js +199 -108
- package/sync-plugins/crud.mjs +200 -109
- package/sync-plugins/firebase.d.mts +7 -3
- package/sync-plugins/firebase.d.ts +7 -3
- package/sync-plugins/firebase.js +4 -2
- package/sync-plugins/firebase.mjs +4 -2
- package/sync-plugins/keel.d.mts +9 -13
- package/sync-plugins/keel.d.ts +9 -13
- package/sync-plugins/keel.js +52 -41
- package/sync-plugins/keel.mjs +53 -37
- package/sync-plugins/supabase.d.mts +7 -3
- package/sync-plugins/supabase.d.ts +7 -3
- package/sync-plugins/supabase.js +87 -31
- package/sync-plugins/supabase.mjs +88 -32
- package/sync-plugins/tanstack-query.d.mts +5 -5
- package/sync-plugins/tanstack-query.d.ts +5 -5
- package/sync-plugins/tanstack-query.js +10 -1
- package/sync-plugins/tanstack-query.mjs +10 -1
- package/sync-plugins/tanstack-react-query.d.mts +4 -2
- package/sync-plugins/tanstack-react-query.d.ts +4 -2
- package/sync.d.mts +16 -8
- package/sync.d.ts +16 -8
- package/sync.js +267 -174
- package/sync.mjs +266 -174
- 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/index.mjs
CHANGED
|
@@ -179,7 +179,7 @@ function setNodeValue(node, newValue) {
|
|
|
179
179
|
parentNode.isSetting--;
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
return { prevValue, newValue };
|
|
182
|
+
return { prevValue, newValue, parentValue };
|
|
183
183
|
}
|
|
184
184
|
var arrNodeKeys = [];
|
|
185
185
|
function getNodeValue(node) {
|
|
@@ -274,16 +274,19 @@ var ObservableHint = {
|
|
|
274
274
|
},
|
|
275
275
|
plain: function plainObject(value) {
|
|
276
276
|
return addSymbol(value, symbolPlain);
|
|
277
|
+
},
|
|
278
|
+
function: function plainObject2(value) {
|
|
279
|
+
return addSymbol(value, symbolPlain);
|
|
277
280
|
}
|
|
278
281
|
};
|
|
279
282
|
|
|
280
283
|
// src/helpers.ts
|
|
281
|
-
function computeSelector(selector, e, retainObservable) {
|
|
284
|
+
function computeSelector(selector, getOptions, e, retainObservable) {
|
|
282
285
|
let c = selector;
|
|
283
286
|
if (!isObservable(c) && isFunction(c)) {
|
|
284
287
|
c = e ? c(e) : c();
|
|
285
288
|
}
|
|
286
|
-
return isObservable(c) && !retainObservable ? c.get() : c;
|
|
289
|
+
return isObservable(c) && !retainObservable ? c.get(getOptions) : c;
|
|
287
290
|
}
|
|
288
291
|
function getObservableIndex(value$) {
|
|
289
292
|
const node = getNode(value$);
|
|
@@ -382,7 +385,7 @@ function _mergeIntoObservable(target, source, levelsDeep) {
|
|
|
382
385
|
const isSourceSet = isSet(source);
|
|
383
386
|
if (isSourceSet && isSet(targetValue)) {
|
|
384
387
|
target.set(/* @__PURE__ */ new Set([...source, ...targetValue]));
|
|
385
|
-
} else if (isTargetObj && isObject(source)
|
|
388
|
+
} else if (isTargetObj && isObject(source) || isTargetArr && targetValue.length > 0) {
|
|
386
389
|
const keys = isSourceMap || isSourceSet ? Array.from(source.keys()) : Object.keys(source);
|
|
387
390
|
for (let i = 0; i < keys.length; i++) {
|
|
388
391
|
const key = keys[i];
|
|
@@ -967,13 +970,13 @@ function updateTracking(node, track) {
|
|
|
967
970
|
}
|
|
968
971
|
|
|
969
972
|
// src/trackSelector.ts
|
|
970
|
-
function trackSelector(selector, update, observeEvent, observeOptions, createResubscribe) {
|
|
973
|
+
function trackSelector(selector, update, getOptions, observeEvent, observeOptions, createResubscribe) {
|
|
971
974
|
var _a;
|
|
972
975
|
let dispose;
|
|
973
976
|
let resubscribe;
|
|
974
977
|
let updateFn = update;
|
|
975
978
|
beginTracking();
|
|
976
|
-
const value = selector ? computeSelector(selector, observeEvent, observeOptions == null ? void 0 : observeOptions.fromComputed) : selector;
|
|
979
|
+
const value = selector ? computeSelector(selector, getOptions, observeEvent, observeOptions == null ? void 0 : observeOptions.fromComputed) : selector;
|
|
977
980
|
const tracker = tracking.current;
|
|
978
981
|
const nodes = tracker.nodes;
|
|
979
982
|
endTracking();
|
|
@@ -1021,7 +1024,11 @@ function observe(selectorOrRun, reactionOrOptions, options) {
|
|
|
1021
1024
|
beginBatch();
|
|
1022
1025
|
delete e.value;
|
|
1023
1026
|
dispose == null ? void 0 : dispose();
|
|
1024
|
-
const {
|
|
1027
|
+
const {
|
|
1028
|
+
dispose: _dispose,
|
|
1029
|
+
value,
|
|
1030
|
+
nodes
|
|
1031
|
+
} = trackSelector(selectorOrRun, update, void 0, e, options);
|
|
1025
1032
|
dispose = _dispose;
|
|
1026
1033
|
e.value = value;
|
|
1027
1034
|
e.nodes = nodes;
|
|
@@ -1066,10 +1073,13 @@ function _when(predicate, effect, checkReady) {
|
|
|
1066
1073
|
let isOk = true;
|
|
1067
1074
|
if (isArray(ret)) {
|
|
1068
1075
|
for (let i = 0; i < ret.length; i++) {
|
|
1069
|
-
|
|
1070
|
-
|
|
1076
|
+
let item = ret[i];
|
|
1077
|
+
if (isObservable(item)) {
|
|
1078
|
+
item = computeSelector(item);
|
|
1079
|
+
} else if (isFunction(item)) {
|
|
1080
|
+
item = item();
|
|
1071
1081
|
}
|
|
1072
|
-
isOk = isOk && !!(checkReady ? isObservableValueReady(
|
|
1082
|
+
isOk = isOk && !!(checkReady ? isObservableValueReady(item) : item);
|
|
1073
1083
|
}
|
|
1074
1084
|
} else {
|
|
1075
1085
|
isOk = checkReady ? isObservableValueReady(ret) : ret;
|
|
@@ -1168,8 +1178,8 @@ function collectionSetter(node, target, prop, ...args) {
|
|
|
1168
1178
|
return ret;
|
|
1169
1179
|
}
|
|
1170
1180
|
}
|
|
1171
|
-
function getKeys(obj, isArr, isMap2) {
|
|
1172
|
-
return isArr ? void 0 : obj ? isMap2 ? Array.from(obj.keys()) : Object.keys(obj) : [];
|
|
1181
|
+
function getKeys(obj, isArr, isMap2, isSet2) {
|
|
1182
|
+
return isArr ? void 0 : obj ? isSet2 ? Array.from(obj) : isMap2 ? Array.from(obj.keys()) : Object.keys(obj) : [];
|
|
1173
1183
|
}
|
|
1174
1184
|
function updateNodes(parent, obj, prevValue) {
|
|
1175
1185
|
var _a, _b, _c;
|
|
@@ -1199,9 +1209,11 @@ function updateNodes(parent, obj, prevValue) {
|
|
|
1199
1209
|
let prevChildrenById;
|
|
1200
1210
|
let moved;
|
|
1201
1211
|
const isCurMap = isMap(obj);
|
|
1212
|
+
const isCurSet = isSet(obj);
|
|
1202
1213
|
const isPrevMap = isMap(prevValue);
|
|
1203
|
-
const
|
|
1204
|
-
const
|
|
1214
|
+
const isPrevSet = isSet(prevValue);
|
|
1215
|
+
const keys = getKeys(obj, isArr, isCurMap, isCurSet);
|
|
1216
|
+
const keysPrev = getKeys(prevValue, isArr, isPrevMap, isPrevSet);
|
|
1205
1217
|
const length = ((_a = keys || obj) == null ? void 0 : _a.length) || 0;
|
|
1206
1218
|
const lengthPrev = ((_b = keysPrev || prevValue) == null ? void 0 : _b.length) || 0;
|
|
1207
1219
|
let idField;
|
|
@@ -1551,7 +1563,9 @@ var proxyHandler = {
|
|
|
1551
1563
|
if (isObservable(thisArg)) {
|
|
1552
1564
|
thisArg = thisArg.peek();
|
|
1553
1565
|
}
|
|
1554
|
-
|
|
1566
|
+
const fnRaw = getNodeValue(target);
|
|
1567
|
+
const fn = isFunction(fnRaw) ? fnRaw : target.lazyFn || target;
|
|
1568
|
+
return Reflect.apply(fn, thisArg, argArray);
|
|
1555
1569
|
}
|
|
1556
1570
|
};
|
|
1557
1571
|
function set(node, newValue) {
|
|
@@ -1583,7 +1597,7 @@ function setKey(node, key, newValue, level) {
|
|
|
1583
1597
|
if (isObservable(newValue)) {
|
|
1584
1598
|
setToObservable(childNode, newValue);
|
|
1585
1599
|
} else {
|
|
1586
|
-
const { newValue: savedValue, prevValue } = setNodeValue(childNode, newValue);
|
|
1600
|
+
const { newValue: savedValue, prevValue, parentValue } = setNodeValue(childNode, newValue);
|
|
1587
1601
|
const isPrim = isPrimitive(savedValue) || savedValue instanceof Date;
|
|
1588
1602
|
if (!isPrim) {
|
|
1589
1603
|
let parent = childNode;
|
|
@@ -1595,7 +1609,17 @@ function setKey(node, key, newValue, level) {
|
|
|
1595
1609
|
const notify2 = !equals(savedValue, prevValue);
|
|
1596
1610
|
const forceNotify = !notify2 && childNode.isComputing && !isPrim;
|
|
1597
1611
|
if (notify2 || forceNotify) {
|
|
1598
|
-
updateNodesAndNotify(
|
|
1612
|
+
updateNodesAndNotify(
|
|
1613
|
+
node,
|
|
1614
|
+
savedValue,
|
|
1615
|
+
prevValue,
|
|
1616
|
+
childNode,
|
|
1617
|
+
parentValue,
|
|
1618
|
+
isPrim,
|
|
1619
|
+
isRoot,
|
|
1620
|
+
level,
|
|
1621
|
+
forceNotify
|
|
1622
|
+
);
|
|
1599
1623
|
}
|
|
1600
1624
|
extractFunctionOrComputed(node, key, savedValue);
|
|
1601
1625
|
}
|
|
@@ -1702,7 +1726,7 @@ function handlerMapSet(node, p, value) {
|
|
|
1702
1726
|
};
|
|
1703
1727
|
}
|
|
1704
1728
|
}
|
|
1705
|
-
function updateNodesAndNotify(node, newValue, prevValue, childNode, isPrim, isRoot, level, forceNotify) {
|
|
1729
|
+
function updateNodesAndNotify(node, newValue, prevValue, childNode, parentValue, isPrim, isRoot, level, forceNotify) {
|
|
1706
1730
|
if (!childNode)
|
|
1707
1731
|
childNode = node;
|
|
1708
1732
|
beginBatch();
|
|
@@ -1711,15 +1735,29 @@ function updateNodesAndNotify(node, newValue, prevValue, childNode, isPrim, isRo
|
|
|
1711
1735
|
}
|
|
1712
1736
|
let hasADiff = forceNotify || isPrim;
|
|
1713
1737
|
let whenOptimizedOnlyIf = false;
|
|
1738
|
+
let valueAsArr;
|
|
1739
|
+
let valueAsMap;
|
|
1714
1740
|
if (!isPrim || prevValue && !isPrimitive(prevValue)) {
|
|
1715
1741
|
if ((process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") && typeof __devUpdateNodes !== "undefined") {
|
|
1716
1742
|
__devUpdateNodes.clear();
|
|
1717
1743
|
}
|
|
1718
1744
|
hasADiff = hasADiff || updateNodes(childNode, newValue, prevValue);
|
|
1719
1745
|
if (isArray(newValue)) {
|
|
1720
|
-
|
|
1746
|
+
valueAsArr = newValue;
|
|
1747
|
+
} else if (isMap(newValue) || isSet(newValue)) {
|
|
1748
|
+
valueAsMap = newValue;
|
|
1721
1749
|
}
|
|
1722
1750
|
}
|
|
1751
|
+
if (isArray(parentValue)) {
|
|
1752
|
+
valueAsArr = parentValue;
|
|
1753
|
+
} else if (isMap(parentValue) || isSet(parentValue)) {
|
|
1754
|
+
valueAsMap = parentValue;
|
|
1755
|
+
}
|
|
1756
|
+
if (valueAsArr) {
|
|
1757
|
+
whenOptimizedOnlyIf = (valueAsArr == null ? void 0 : valueAsArr.length) !== (prevValue == null ? void 0 : prevValue.length);
|
|
1758
|
+
} else if (valueAsMap) {
|
|
1759
|
+
whenOptimizedOnlyIf = (valueAsMap == null ? void 0 : valueAsMap.size) !== (prevValue == null ? void 0 : prevValue.size);
|
|
1760
|
+
}
|
|
1723
1761
|
if (isPrim || !newValue || isEmpty(newValue) && !isEmpty(prevValue) ? newValue !== prevValue : hasADiff) {
|
|
1724
1762
|
notify(
|
|
1725
1763
|
isPrim && isRoot ? node : childNode,
|
|
@@ -1786,7 +1824,7 @@ function peek(node) {
|
|
|
1786
1824
|
}
|
|
1787
1825
|
var isFlushing = false;
|
|
1788
1826
|
function peekInternal(node, activateRecursive) {
|
|
1789
|
-
var _a;
|
|
1827
|
+
var _a, _b;
|
|
1790
1828
|
isFlushing = true;
|
|
1791
1829
|
if (activateRecursive && ((_a = node.dirtyChildren) == null ? void 0 : _a.size)) {
|
|
1792
1830
|
const dirty = Array.from(node.dirtyChildren);
|
|
@@ -1801,7 +1839,10 @@ function peekInternal(node, activateRecursive) {
|
|
|
1801
1839
|
}
|
|
1802
1840
|
isFlushing = false;
|
|
1803
1841
|
let value = getNodeValue(node);
|
|
1804
|
-
if (
|
|
1842
|
+
if (((_b = node.parent) == null ? void 0 : _b.isPlain) || isHintPlain(value)) {
|
|
1843
|
+
node.isPlain = true;
|
|
1844
|
+
}
|
|
1845
|
+
if (!node.root.isLoadingLocal && !node.isPlain) {
|
|
1805
1846
|
value = checkLazy(node, value, !!activateRecursive);
|
|
1806
1847
|
}
|
|
1807
1848
|
return value;
|
|
@@ -2272,7 +2313,14 @@ function syncState(obs) {
|
|
|
2272
2313
|
syncCount: 0,
|
|
2273
2314
|
resetPersistence: void 0,
|
|
2274
2315
|
reset: () => Promise.resolve(),
|
|
2275
|
-
sync: () =>
|
|
2316
|
+
sync: () => {
|
|
2317
|
+
var _a;
|
|
2318
|
+
obs.peek();
|
|
2319
|
+
if ((_a = node.state) == null ? void 0 : _a.isGetting.peek()) {
|
|
2320
|
+
return when(node.state.isLoaded);
|
|
2321
|
+
}
|
|
2322
|
+
return Promise.resolve();
|
|
2323
|
+
},
|
|
2276
2324
|
getPendingChanges: () => ({}),
|
|
2277
2325
|
// TODOV3 remove
|
|
2278
2326
|
clearPersist: void 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/state",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.21",
|
|
4
4
|
"description": "legend-state",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"private": false,
|
|
@@ -48,6 +48,12 @@
|
|
|
48
48
|
"./types/babel": {
|
|
49
49
|
"types": "./types/babel.d.ts"
|
|
50
50
|
},
|
|
51
|
+
"./types/reactive-web": {
|
|
52
|
+
"types": "./types/reactive-web.d.ts"
|
|
53
|
+
},
|
|
54
|
+
"./types/reactive-native": {
|
|
55
|
+
"types": "./types/reactive-native.d.ts"
|
|
56
|
+
},
|
|
51
57
|
".": {
|
|
52
58
|
"import": "./index.mjs",
|
|
53
59
|
"require": "./index.js",
|
|
@@ -63,6 +69,16 @@
|
|
|
63
69
|
"require": "./react.js",
|
|
64
70
|
"types": "./react.d.ts"
|
|
65
71
|
},
|
|
72
|
+
"./react-native": {
|
|
73
|
+
"import": "./react-native.mjs",
|
|
74
|
+
"require": "./react-native.js",
|
|
75
|
+
"types": "./react-native.d.ts"
|
|
76
|
+
},
|
|
77
|
+
"./react-web": {
|
|
78
|
+
"import": "./react-web.mjs",
|
|
79
|
+
"require": "./react-web.js",
|
|
80
|
+
"types": "./react-web.d.ts"
|
|
81
|
+
},
|
|
66
82
|
"./trace": {
|
|
67
83
|
"import": "./trace.mjs",
|
|
68
84
|
"require": "./trace.js",
|
|
@@ -73,6 +89,11 @@
|
|
|
73
89
|
"require": "./react-reactive/enableReactive.js",
|
|
74
90
|
"types": "./react-reactive/enableReactive.d.ts"
|
|
75
91
|
},
|
|
92
|
+
"./react-reactive/Components": {
|
|
93
|
+
"import": "./react-reactive/Components.mjs",
|
|
94
|
+
"require": "./react-reactive/Components.js",
|
|
95
|
+
"types": "./react-reactive/Components.d.ts"
|
|
96
|
+
},
|
|
76
97
|
"./react-reactive/enableReactComponents": {
|
|
77
98
|
"import": "./react-reactive/enableReactComponents.mjs",
|
|
78
99
|
"require": "./react-reactive/enableReactComponents.js",
|
|
@@ -21,7 +21,10 @@ var ObservablePersistAsyncStorage = class {
|
|
|
21
21
|
if (preload === true) {
|
|
22
22
|
tables = await AsyncStorage.getAllKeys();
|
|
23
23
|
} else if (state.isArray(preload)) {
|
|
24
|
-
|
|
24
|
+
const metadataTables = preload.map(
|
|
25
|
+
(table) => table.endsWith(MetadataSuffix) ? void 0 : table + MetadataSuffix
|
|
26
|
+
);
|
|
27
|
+
tables = [...preload, ...metadataTables.filter(Boolean)];
|
|
25
28
|
}
|
|
26
29
|
if (tables) {
|
|
27
30
|
const values = await AsyncStorage.multiGet(tables);
|
|
@@ -38,14 +41,19 @@ var ObservablePersistAsyncStorage = class {
|
|
|
38
41
|
}
|
|
39
42
|
loadTable(table) {
|
|
40
43
|
if (this.data[table] === void 0) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
return AsyncStorage.multiGet([table, table + MetadataSuffix]).then((values) => {
|
|
45
|
+
try {
|
|
46
|
+
values.forEach(([table2, value]) => {
|
|
47
|
+
this.data[table2] = value ? safeParse(value) : void 0;
|
|
48
|
+
});
|
|
49
|
+
} catch (err) {
|
|
50
|
+
console.error("[legend-state] ObservablePersistLocalAsyncStorage failed to parse", table, err);
|
|
51
|
+
}
|
|
52
|
+
}).catch((err) => {
|
|
53
|
+
if ((err == null ? void 0 : err.message) !== "window is not defined") {
|
|
54
|
+
console.error("[legend-state] AsyncStorage.multiGet failed", table, err);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
49
57
|
}
|
|
50
58
|
}
|
|
51
59
|
// Gets
|
|
@@ -19,7 +19,10 @@ var ObservablePersistAsyncStorage = class {
|
|
|
19
19
|
if (preload === true) {
|
|
20
20
|
tables = await AsyncStorage.getAllKeys();
|
|
21
21
|
} else if (isArray(preload)) {
|
|
22
|
-
|
|
22
|
+
const metadataTables = preload.map(
|
|
23
|
+
(table) => table.endsWith(MetadataSuffix) ? void 0 : table + MetadataSuffix
|
|
24
|
+
);
|
|
25
|
+
tables = [...preload, ...metadataTables.filter(Boolean)];
|
|
23
26
|
}
|
|
24
27
|
if (tables) {
|
|
25
28
|
const values = await AsyncStorage.multiGet(tables);
|
|
@@ -36,14 +39,19 @@ var ObservablePersistAsyncStorage = class {
|
|
|
36
39
|
}
|
|
37
40
|
loadTable(table) {
|
|
38
41
|
if (this.data[table] === void 0) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
return AsyncStorage.multiGet([table, table + MetadataSuffix]).then((values) => {
|
|
43
|
+
try {
|
|
44
|
+
values.forEach(([table2, value]) => {
|
|
45
|
+
this.data[table2] = value ? safeParse(value) : void 0;
|
|
46
|
+
});
|
|
47
|
+
} catch (err) {
|
|
48
|
+
console.error("[legend-state] ObservablePersistLocalAsyncStorage failed to parse", table, err);
|
|
49
|
+
}
|
|
50
|
+
}).catch((err) => {
|
|
51
|
+
if ((err == null ? void 0 : err.message) !== "window is not defined") {
|
|
52
|
+
console.error("[legend-state] AsyncStorage.multiGet failed", table, err);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
47
55
|
}
|
|
48
56
|
}
|
|
49
57
|
// Gets
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { $ActivityIndicator, $Button, $FlatList, $Image, $Pressable, $ScrollView, $SectionList, $Switch, $Text, $TextInput, $TouchableWithoutFeedback, $View } from './react-reactive/Components.mjs';
|
|
2
|
+
import 'react';
|
|
3
|
+
import '@legendapp/state/react';
|
|
4
|
+
import 'react-native';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { $ActivityIndicator, $Button, $FlatList, $Image, $Pressable, $ScrollView, $SectionList, $Switch, $Text, $TextInput, $TouchableWithoutFeedback, $View } from './react-reactive/Components.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import '@legendapp/state/react';
|
|
4
|
+
import 'react-native';
|
package/react-native.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('@legendapp/state/react');
|
|
4
|
+
var react$1 = require('react');
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
|
|
7
|
+
// src/react-reactive/Components.ts
|
|
8
|
+
var $ActivityIndicator = react.reactive(reactNative.ActivityIndicator);
|
|
9
|
+
var $Button = react.reactive(reactNative.Button);
|
|
10
|
+
var $FlatList = react.reactive(reactNative.FlatList, void 0, {
|
|
11
|
+
data: {
|
|
12
|
+
selector: (propsOut, p) => {
|
|
13
|
+
const state = react$1.useRef(0);
|
|
14
|
+
const [renderNum, value] = react.use$(() => [state.current++, p.get(true)]);
|
|
15
|
+
propsOut.extraData = renderNum;
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
var $Image = react.reactive(reactNative.Image);
|
|
21
|
+
var $Pressable = react.reactive(reactNative.Pressable);
|
|
22
|
+
var $ScrollView = react.reactive(reactNative.ScrollView);
|
|
23
|
+
var $SectionList = react.reactive(reactNative.SectionList);
|
|
24
|
+
var $Switch = react.reactive(reactNative.Switch, void 0, {
|
|
25
|
+
value: {
|
|
26
|
+
handler: "onValueChange",
|
|
27
|
+
getValue: (e) => e,
|
|
28
|
+
defaultValue: false
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
var $Text = react.reactive(reactNative.Text);
|
|
32
|
+
var $TextInput = react.reactive(reactNative.TextInput, void 0, {
|
|
33
|
+
value: {
|
|
34
|
+
handler: "onChange",
|
|
35
|
+
getValue: (e) => e.nativeEvent.text,
|
|
36
|
+
defaultValue: ""
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
var $TouchableWithoutFeedback = react.reactive(reactNative.TouchableWithoutFeedback);
|
|
40
|
+
var $View = react.reactive(reactNative.View);
|
|
41
|
+
|
|
42
|
+
exports.$ActivityIndicator = $ActivityIndicator;
|
|
43
|
+
exports.$Button = $Button;
|
|
44
|
+
exports.$FlatList = $FlatList;
|
|
45
|
+
exports.$Image = $Image;
|
|
46
|
+
exports.$Pressable = $Pressable;
|
|
47
|
+
exports.$ScrollView = $ScrollView;
|
|
48
|
+
exports.$SectionList = $SectionList;
|
|
49
|
+
exports.$Switch = $Switch;
|
|
50
|
+
exports.$Text = $Text;
|
|
51
|
+
exports.$TextInput = $TextInput;
|
|
52
|
+
exports.$TouchableWithoutFeedback = $TouchableWithoutFeedback;
|
|
53
|
+
exports.$View = $View;
|
package/react-native.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { reactive, use$ } from '@legendapp/state/react';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
// src/react-reactive/Components.ts
|
|
6
|
+
var $ActivityIndicator = reactive(ActivityIndicator);
|
|
7
|
+
var $Button = reactive(Button);
|
|
8
|
+
var $FlatList = reactive(FlatList, void 0, {
|
|
9
|
+
data: {
|
|
10
|
+
selector: (propsOut, p) => {
|
|
11
|
+
const state = useRef(0);
|
|
12
|
+
const [renderNum, value] = use$(() => [state.current++, p.get(true)]);
|
|
13
|
+
propsOut.extraData = renderNum;
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var $Image = reactive(Image);
|
|
19
|
+
var $Pressable = reactive(Pressable);
|
|
20
|
+
var $ScrollView = reactive(ScrollView);
|
|
21
|
+
var $SectionList = reactive(SectionList);
|
|
22
|
+
var $Switch = reactive(Switch, void 0, {
|
|
23
|
+
value: {
|
|
24
|
+
handler: "onValueChange",
|
|
25
|
+
getValue: (e) => e,
|
|
26
|
+
defaultValue: false
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var $Text = reactive(Text);
|
|
30
|
+
var $TextInput = reactive(TextInput, void 0, {
|
|
31
|
+
value: {
|
|
32
|
+
handler: "onChange",
|
|
33
|
+
getValue: (e) => e.nativeEvent.text,
|
|
34
|
+
defaultValue: ""
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
var $TouchableWithoutFeedback = reactive(TouchableWithoutFeedback);
|
|
38
|
+
var $View = reactive(View);
|
|
39
|
+
|
|
40
|
+
export { $ActivityIndicator, $Button, $FlatList, $Image, $Pressable, $ScrollView, $SectionList, $Switch, $Text, $TextInput, $TouchableWithoutFeedback, $View };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as _legendapp_state_react from '@legendapp/state/react';
|
|
3
|
+
import * as react_native from 'react-native';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
|
|
6
|
+
declare const $ActivityIndicator: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ActivityIndicatorProps>, any>;
|
|
7
|
+
declare const $Button: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ButtonProps>, any>;
|
|
8
|
+
declare const $FlatList: React.FC<_legendapp_state_react.ShapeWith$<react_native.FlatListProps<unknown>>>;
|
|
9
|
+
declare const $Image: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ImageProps>, any>;
|
|
10
|
+
declare const $Pressable: React.ForwardRefExoticComponent<_legendapp_state_react.ShapeWith$<react_native.PressableProps & React.RefAttributes<View>>>;
|
|
11
|
+
declare const $ScrollView: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ScrollViewProps>, any>;
|
|
12
|
+
declare const $SectionList: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.SectionListProps<unknown, unknown>>, any>;
|
|
13
|
+
declare const $Switch: React.FC<_legendapp_state_react.ShapeWith$<react_native.SwitchProps>>;
|
|
14
|
+
declare const $Text: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.TextProps>, any>;
|
|
15
|
+
declare const $TextInput: React.FC<_legendapp_state_react.ShapeWith$<react_native.TextInputProps>>;
|
|
16
|
+
declare const $TouchableWithoutFeedback: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.TouchableWithoutFeedbackProps>, any>;
|
|
17
|
+
declare const $View: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ViewProps>, any>;
|
|
18
|
+
|
|
19
|
+
export { $ActivityIndicator, $Button, $FlatList, $Image, $Pressable, $ScrollView, $SectionList, $Switch, $Text, $TextInput, $TouchableWithoutFeedback, $View };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as _legendapp_state_react from '@legendapp/state/react';
|
|
3
|
+
import * as react_native from 'react-native';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
|
|
6
|
+
declare const $ActivityIndicator: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ActivityIndicatorProps>, any>;
|
|
7
|
+
declare const $Button: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ButtonProps>, any>;
|
|
8
|
+
declare const $FlatList: React.FC<_legendapp_state_react.ShapeWith$<react_native.FlatListProps<unknown>>>;
|
|
9
|
+
declare const $Image: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ImageProps>, any>;
|
|
10
|
+
declare const $Pressable: React.ForwardRefExoticComponent<_legendapp_state_react.ShapeWith$<react_native.PressableProps & React.RefAttributes<View>>>;
|
|
11
|
+
declare const $ScrollView: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ScrollViewProps>, any>;
|
|
12
|
+
declare const $SectionList: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.SectionListProps<unknown, unknown>>, any>;
|
|
13
|
+
declare const $Switch: React.FC<_legendapp_state_react.ShapeWith$<react_native.SwitchProps>>;
|
|
14
|
+
declare const $Text: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.TextProps>, any>;
|
|
15
|
+
declare const $TextInput: React.FC<_legendapp_state_react.ShapeWith$<react_native.TextInputProps>>;
|
|
16
|
+
declare const $TouchableWithoutFeedback: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.TouchableWithoutFeedbackProps>, any>;
|
|
17
|
+
declare const $View: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ViewProps>, any>;
|
|
18
|
+
|
|
19
|
+
export { $ActivityIndicator, $Button, $FlatList, $Image, $Pressable, $ScrollView, $SectionList, $Switch, $Text, $TextInput, $TouchableWithoutFeedback, $View };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('@legendapp/state/react');
|
|
4
|
+
var react$1 = require('react');
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
|
|
7
|
+
// src/react-reactive/Components.ts
|
|
8
|
+
var $ActivityIndicator = react.reactive(reactNative.ActivityIndicator);
|
|
9
|
+
var $Button = react.reactive(reactNative.Button);
|
|
10
|
+
var $FlatList = react.reactive(reactNative.FlatList, void 0, {
|
|
11
|
+
data: {
|
|
12
|
+
selector: (propsOut, p) => {
|
|
13
|
+
const state = react$1.useRef(0);
|
|
14
|
+
const [renderNum, value] = react.use$(() => [state.current++, p.get(true)]);
|
|
15
|
+
propsOut.extraData = renderNum;
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
var $Image = react.reactive(reactNative.Image);
|
|
21
|
+
var $Pressable = react.reactive(reactNative.Pressable);
|
|
22
|
+
var $ScrollView = react.reactive(reactNative.ScrollView);
|
|
23
|
+
var $SectionList = react.reactive(reactNative.SectionList);
|
|
24
|
+
var $Switch = react.reactive(reactNative.Switch, void 0, {
|
|
25
|
+
value: {
|
|
26
|
+
handler: "onValueChange",
|
|
27
|
+
getValue: (e) => e,
|
|
28
|
+
defaultValue: false
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
var $Text = react.reactive(reactNative.Text);
|
|
32
|
+
var $TextInput = react.reactive(reactNative.TextInput, void 0, {
|
|
33
|
+
value: {
|
|
34
|
+
handler: "onChange",
|
|
35
|
+
getValue: (e) => e.nativeEvent.text,
|
|
36
|
+
defaultValue: ""
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
var $TouchableWithoutFeedback = react.reactive(reactNative.TouchableWithoutFeedback);
|
|
40
|
+
var $View = react.reactive(reactNative.View);
|
|
41
|
+
|
|
42
|
+
exports.$ActivityIndicator = $ActivityIndicator;
|
|
43
|
+
exports.$Button = $Button;
|
|
44
|
+
exports.$FlatList = $FlatList;
|
|
45
|
+
exports.$Image = $Image;
|
|
46
|
+
exports.$Pressable = $Pressable;
|
|
47
|
+
exports.$ScrollView = $ScrollView;
|
|
48
|
+
exports.$SectionList = $SectionList;
|
|
49
|
+
exports.$Switch = $Switch;
|
|
50
|
+
exports.$Text = $Text;
|
|
51
|
+
exports.$TextInput = $TextInput;
|
|
52
|
+
exports.$TouchableWithoutFeedback = $TouchableWithoutFeedback;
|
|
53
|
+
exports.$View = $View;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { reactive, use$ } from '@legendapp/state/react';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
// src/react-reactive/Components.ts
|
|
6
|
+
var $ActivityIndicator = reactive(ActivityIndicator);
|
|
7
|
+
var $Button = reactive(Button);
|
|
8
|
+
var $FlatList = reactive(FlatList, void 0, {
|
|
9
|
+
data: {
|
|
10
|
+
selector: (propsOut, p) => {
|
|
11
|
+
const state = useRef(0);
|
|
12
|
+
const [renderNum, value] = use$(() => [state.current++, p.get(true)]);
|
|
13
|
+
propsOut.extraData = renderNum;
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var $Image = reactive(Image);
|
|
19
|
+
var $Pressable = reactive(Pressable);
|
|
20
|
+
var $ScrollView = reactive(ScrollView);
|
|
21
|
+
var $SectionList = reactive(SectionList);
|
|
22
|
+
var $Switch = reactive(Switch, void 0, {
|
|
23
|
+
value: {
|
|
24
|
+
handler: "onValueChange",
|
|
25
|
+
getValue: (e) => e,
|
|
26
|
+
defaultValue: false
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var $Text = reactive(Text);
|
|
30
|
+
var $TextInput = reactive(TextInput, void 0, {
|
|
31
|
+
value: {
|
|
32
|
+
handler: "onChange",
|
|
33
|
+
getValue: (e) => e.nativeEvent.text,
|
|
34
|
+
defaultValue: ""
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
var $TouchableWithoutFeedback = reactive(TouchableWithoutFeedback);
|
|
38
|
+
var $View = reactive(View);
|
|
39
|
+
|
|
40
|
+
export { $ActivityIndicator, $Button, $FlatList, $Image, $Pressable, $ScrollView, $SectionList, $Switch, $Text, $TextInput, $TouchableWithoutFeedback, $View };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FCReactiveObject, configureReactive } from '@legendapp/state/react';
|
|
2
2
|
|
|
3
|
-
declare function
|
|
3
|
+
declare function enableReactComponents_(config: typeof configureReactive): void;
|
|
4
|
+
|
|
4
5
|
declare module '@legendapp/state/react' {
|
|
5
6
|
interface IReactive extends FCReactiveObject<JSX.IntrinsicElements> {
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export {
|
|
10
|
+
export { enableReactComponents_ };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FCReactiveObject, configureReactive } from '@legendapp/state/react';
|
|
2
2
|
|
|
3
|
-
declare function
|
|
3
|
+
declare function enableReactComponents_(config: typeof configureReactive): void;
|
|
4
|
+
|
|
4
5
|
declare module '@legendapp/state/react' {
|
|
5
6
|
interface IReactive extends FCReactiveObject<JSX.IntrinsicElements> {
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export {
|
|
10
|
+
export { enableReactComponents_ };
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/react-reactive/enableReactComponents.ts
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
@@ -16,4 +23,4 @@ function enableReactComponents(config) {
|
|
|
16
23
|
});
|
|
17
24
|
}
|
|
18
25
|
|
|
19
|
-
exports.
|
|
26
|
+
exports.enableReactComponents_ = enableReactComponents_;
|