tsdf 12.8.0 → 14.0.0
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/dist/main.cjs +263 -114
- package/dist/main.d.cts +53 -32
- package/dist/main.d.ts +53 -32
- package/dist/main.js +263 -114
- package/package.json +2 -2
package/dist/main.cjs
CHANGED
|
@@ -878,30 +878,43 @@ function newTSDFCollectionStore({
|
|
|
878
878
|
}
|
|
879
879
|
return store.state[getItemKey(params)];
|
|
880
880
|
}
|
|
881
|
-
function useMultipleItems(
|
|
881
|
+
function useMultipleItems(items, {
|
|
882
882
|
selector,
|
|
883
|
-
|
|
884
|
-
returnIdleStatus,
|
|
885
|
-
returnRefetchingStatus,
|
|
886
|
-
disableRefetchOnMount = globalDisableRefetchOnMount,
|
|
887
|
-
isOffScreen
|
|
883
|
+
selectorUsesExternalDeps
|
|
888
884
|
} = {}) {
|
|
889
885
|
const queriesWithId = useDeepMemo(() => {
|
|
890
|
-
return
|
|
891
|
-
return {
|
|
886
|
+
return items.map((queryProps) => {
|
|
887
|
+
return {
|
|
888
|
+
itemKey: getItemKey(queryProps.payload),
|
|
889
|
+
payload: queryProps.payload,
|
|
890
|
+
disableRefetchOnMount: queryProps.disableRefetchOnMount ?? globalDisableRefetchOnMount,
|
|
891
|
+
returnIdleStatus: queryProps.returnIdleStatus,
|
|
892
|
+
returnRefetchingStatus: queryProps.returnRefetchingStatus,
|
|
893
|
+
omitPayload: queryProps.omitPayload,
|
|
894
|
+
isOffScreen: queryProps.isOffScreen,
|
|
895
|
+
queryMetadata: queryProps.queryMetadata
|
|
896
|
+
};
|
|
892
897
|
});
|
|
893
|
-
}, [
|
|
894
|
-
const dataSelector = (0, import_react7.useCallback)(
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
898
|
+
}, [items]);
|
|
899
|
+
const dataSelector = (0, import_react7.useCallback)(
|
|
900
|
+
(itemState) => {
|
|
901
|
+
if (selector)
|
|
902
|
+
return selector(itemState);
|
|
903
|
+
return itemState;
|
|
904
|
+
},
|
|
905
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
906
|
+
[selectorUsesExternalDeps ? selector : 0]
|
|
907
|
+
);
|
|
899
908
|
const resultSelector = (0, import_react7.useCallback)(
|
|
900
909
|
(state) => {
|
|
901
910
|
return queriesWithId.map(
|
|
902
911
|
({
|
|
903
912
|
itemKey,
|
|
904
|
-
payload
|
|
913
|
+
payload,
|
|
914
|
+
omitPayload,
|
|
915
|
+
returnIdleStatus,
|
|
916
|
+
returnRefetchingStatus,
|
|
917
|
+
queryMetadata
|
|
905
918
|
}) => {
|
|
906
919
|
const item = state[itemKey];
|
|
907
920
|
if (item === null) {
|
|
@@ -911,7 +924,8 @@ function newTSDFCollectionStore({
|
|
|
911
924
|
data: dataSelector(null),
|
|
912
925
|
error: null,
|
|
913
926
|
payload: omitPayload ? void 0 : payload,
|
|
914
|
-
isLoading: false
|
|
927
|
+
isLoading: false,
|
|
928
|
+
queryMetadata
|
|
915
929
|
};
|
|
916
930
|
}
|
|
917
931
|
if (!item) {
|
|
@@ -921,7 +935,8 @@ function newTSDFCollectionStore({
|
|
|
921
935
|
data: dataSelector(null),
|
|
922
936
|
error: null,
|
|
923
937
|
payload: omitPayload ? void 0 : payload,
|
|
924
|
-
isLoading: returnIdleStatus ? false : true
|
|
938
|
+
isLoading: returnIdleStatus ? false : true,
|
|
939
|
+
queryMetadata
|
|
925
940
|
};
|
|
926
941
|
}
|
|
927
942
|
let status = item.status;
|
|
@@ -934,27 +949,22 @@ function newTSDFCollectionStore({
|
|
|
934
949
|
data: dataSelector(item.data),
|
|
935
950
|
error: item.error,
|
|
936
951
|
isLoading: status === "loading",
|
|
937
|
-
payload: omitPayload ? void 0 : item.payload
|
|
952
|
+
payload: omitPayload ? void 0 : item.payload,
|
|
953
|
+
queryMetadata
|
|
938
954
|
};
|
|
939
955
|
}
|
|
940
956
|
);
|
|
941
957
|
},
|
|
942
|
-
[
|
|
943
|
-
dataSelector,
|
|
944
|
-
omitPayload,
|
|
945
|
-
queriesWithId,
|
|
946
|
-
returnIdleStatus,
|
|
947
|
-
returnRefetchingStatus
|
|
948
|
-
]
|
|
958
|
+
[dataSelector, queriesWithId]
|
|
949
959
|
);
|
|
950
960
|
const storeState = store.useSelector(resultSelector, {
|
|
951
961
|
equalityFn: import_t_state4.deepEqual,
|
|
952
962
|
useExternalDeps: true
|
|
953
963
|
});
|
|
954
964
|
(0, import_react6.useOnEvtmitterEvent)(storeEvents, "invalidateData", (event) => {
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
965
|
+
for (const { itemKey, payload, isOffScreen } of queriesWithId) {
|
|
966
|
+
if (isOffScreen)
|
|
967
|
+
continue;
|
|
958
968
|
if (itemKey !== event.itemKey)
|
|
959
969
|
continue;
|
|
960
970
|
if (!invalidationWasTriggered.has(itemKey)) {
|
|
@@ -969,15 +979,27 @@ function newTSDFCollectionStore({
|
|
|
969
979
|
}
|
|
970
980
|
}
|
|
971
981
|
});
|
|
982
|
+
const ignoreItemsInRefetchOnMount = useConst(() => /* @__PURE__ */ new Set());
|
|
972
983
|
(0, import_react7.useEffect)(() => {
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
984
|
+
const removedQueries = new Set(ignoreItemsInRefetchOnMount);
|
|
985
|
+
for (const {
|
|
986
|
+
itemKey: itemId,
|
|
987
|
+
payload,
|
|
988
|
+
isOffScreen,
|
|
989
|
+
disableRefetchOnMount
|
|
990
|
+
} of queriesWithId) {
|
|
991
|
+
removedQueries.delete(itemId);
|
|
992
|
+
if (isOffScreen)
|
|
993
|
+
continue;
|
|
976
994
|
if (itemId) {
|
|
977
995
|
const itemState = getItemState(payload);
|
|
978
996
|
const fetchType = itemState?.refetchOnMount || "lowPriority";
|
|
997
|
+
const shouldFetch = !itemState?.wasLoaded || itemState.refetchOnMount;
|
|
998
|
+
if (!shouldFetch && ignoreItemsInRefetchOnMount.has(itemId)) {
|
|
999
|
+
continue;
|
|
1000
|
+
}
|
|
1001
|
+
ignoreItemsInRefetchOnMount.add(itemId);
|
|
979
1002
|
if (disableRefetchOnMount) {
|
|
980
|
-
const shouldFetch = !itemState?.wasLoaded || itemState.refetchOnMount;
|
|
981
1003
|
if (shouldFetch) {
|
|
982
1004
|
scheduleFetch(fetchType, payload);
|
|
983
1005
|
continue;
|
|
@@ -987,16 +1009,46 @@ function newTSDFCollectionStore({
|
|
|
987
1009
|
}
|
|
988
1010
|
}
|
|
989
1011
|
}
|
|
990
|
-
|
|
1012
|
+
for (const itemId of removedQueries) {
|
|
1013
|
+
ignoreItemsInRefetchOnMount.delete(itemId);
|
|
1014
|
+
}
|
|
1015
|
+
}, [ignoreItemsInRefetchOnMount, queriesWithId]);
|
|
991
1016
|
return storeState;
|
|
992
1017
|
}
|
|
993
|
-
function useItem(payload,
|
|
994
|
-
|
|
1018
|
+
function useItem(payload, {
|
|
1019
|
+
omitPayload,
|
|
1020
|
+
selector,
|
|
1021
|
+
selectorUsesExternalDeps,
|
|
1022
|
+
ensureIsLoaded,
|
|
1023
|
+
returnRefetchingStatus,
|
|
1024
|
+
disableRefetchOnMount,
|
|
1025
|
+
returnIdleStatus,
|
|
1026
|
+
isOffScreen
|
|
1027
|
+
} = {}) {
|
|
995
1028
|
const query = (0, import_react7.useMemo)(
|
|
996
|
-
() => payload === false || payload === null || payload === void 0 ? [] : [
|
|
997
|
-
|
|
1029
|
+
() => payload === false || payload === null || payload === void 0 ? [] : [
|
|
1030
|
+
{
|
|
1031
|
+
payload,
|
|
1032
|
+
omitPayload,
|
|
1033
|
+
returnRefetchingStatus,
|
|
1034
|
+
disableRefetchOnMount,
|
|
1035
|
+
returnIdleStatus,
|
|
1036
|
+
isOffScreen
|
|
1037
|
+
}
|
|
1038
|
+
],
|
|
1039
|
+
[
|
|
1040
|
+
disableRefetchOnMount,
|
|
1041
|
+
isOffScreen,
|
|
1042
|
+
omitPayload,
|
|
1043
|
+
returnIdleStatus,
|
|
1044
|
+
returnRefetchingStatus,
|
|
1045
|
+
payload
|
|
1046
|
+
]
|
|
998
1047
|
);
|
|
999
|
-
const item = useMultipleItems(query,
|
|
1048
|
+
const item = useMultipleItems(query, {
|
|
1049
|
+
selector,
|
|
1050
|
+
selectorUsesExternalDeps
|
|
1051
|
+
});
|
|
1000
1052
|
const result = (0, import_react7.useMemo)(
|
|
1001
1053
|
() => item[0] ?? {
|
|
1002
1054
|
payload: void 0,
|
|
@@ -1004,7 +1056,8 @@ function newTSDFCollectionStore({
|
|
|
1004
1056
|
error: null,
|
|
1005
1057
|
status: "idle",
|
|
1006
1058
|
itemStateKey: "",
|
|
1007
|
-
isLoading: false
|
|
1059
|
+
isLoading: false,
|
|
1060
|
+
queryMetadata: void 0
|
|
1008
1061
|
},
|
|
1009
1062
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1010
1063
|
[item]
|
|
@@ -1504,28 +1557,36 @@ function newTSDFListQueryStore({
|
|
|
1504
1557
|
}
|
|
1505
1558
|
function useMultipleListQueries(queries, {
|
|
1506
1559
|
itemSelector = defaultItemSelector,
|
|
1507
|
-
|
|
1508
|
-
returnIdleStatus,
|
|
1509
|
-
returnRefetchingStatus,
|
|
1510
|
-
loadSize,
|
|
1511
|
-
disableRefetchOnMount = globalDisableRefetchOnMount,
|
|
1512
|
-
isOffScreen
|
|
1560
|
+
selectorUsesExternalDeps
|
|
1513
1561
|
} = {}) {
|
|
1514
1562
|
const queriesWithId = useDeepMemo(() => {
|
|
1515
|
-
return queries.map((
|
|
1563
|
+
return queries.map((item) => {
|
|
1516
1564
|
return {
|
|
1517
|
-
key: getQueryKey(payload),
|
|
1518
|
-
payload
|
|
1565
|
+
key: getQueryKey(item.payload),
|
|
1566
|
+
payload: item.payload,
|
|
1567
|
+
disableRefetchOnMount: item.disableRefetchOnMount ?? globalDisableRefetchOnMount,
|
|
1568
|
+
returnIdleStatus: item.returnIdleStatus,
|
|
1569
|
+
returnRefetchingStatus: item.returnRefetchingStatus,
|
|
1570
|
+
queryMetadata: item.queryMetadata,
|
|
1571
|
+
isOffScreen: item.isOffScreen,
|
|
1572
|
+
omitPayload: item.omitPayload,
|
|
1573
|
+
loadSize: item.loadSize
|
|
1519
1574
|
};
|
|
1520
1575
|
});
|
|
1521
1576
|
}, [queries]);
|
|
1522
|
-
const dataSelector = (0, import_react9.useCallback)(itemSelector, [
|
|
1577
|
+
const dataSelector = (0, import_react9.useCallback)(itemSelector, [
|
|
1578
|
+
selectorUsesExternalDeps ? itemSelector : 0
|
|
1579
|
+
]);
|
|
1523
1580
|
const resultSelector = (0, import_react9.useCallback)(
|
|
1524
1581
|
(state) => {
|
|
1525
1582
|
return queriesWithId.map(
|
|
1526
1583
|
({
|
|
1527
1584
|
key: queryKey,
|
|
1528
|
-
payload
|
|
1585
|
+
payload,
|
|
1586
|
+
returnIdleStatus,
|
|
1587
|
+
returnRefetchingStatus,
|
|
1588
|
+
omitPayload,
|
|
1589
|
+
queryMetadata
|
|
1529
1590
|
}) => {
|
|
1530
1591
|
const query = state.queries[queryKey];
|
|
1531
1592
|
if (!query) {
|
|
@@ -1537,7 +1598,8 @@ function newTSDFListQueryStore({
|
|
|
1537
1598
|
hasMore: false,
|
|
1538
1599
|
payload: omitPayload ? void 0 : payload,
|
|
1539
1600
|
isLoading: returnIdleStatus ? false : true,
|
|
1540
|
-
isLoadingMore: false
|
|
1601
|
+
isLoadingMore: false,
|
|
1602
|
+
queryMetadata
|
|
1541
1603
|
};
|
|
1542
1604
|
}
|
|
1543
1605
|
let status = query.status;
|
|
@@ -1552,27 +1614,22 @@ function newTSDFListQueryStore({
|
|
|
1552
1614
|
hasMore: query.hasMore,
|
|
1553
1615
|
isLoading: status === "loading",
|
|
1554
1616
|
payload: omitPayload ? void 0 : query.payload,
|
|
1555
|
-
isLoadingMore: status === "loadingMore"
|
|
1617
|
+
isLoadingMore: status === "loadingMore",
|
|
1618
|
+
queryMetadata
|
|
1556
1619
|
};
|
|
1557
1620
|
}
|
|
1558
1621
|
);
|
|
1559
1622
|
},
|
|
1560
|
-
[
|
|
1561
|
-
dataSelector,
|
|
1562
|
-
omitPayload,
|
|
1563
|
-
queriesWithId,
|
|
1564
|
-
returnIdleStatus,
|
|
1565
|
-
returnRefetchingStatus
|
|
1566
|
-
]
|
|
1623
|
+
[dataSelector, queriesWithId]
|
|
1567
1624
|
);
|
|
1568
1625
|
const storeState = store.useSelector(resultSelector, {
|
|
1569
1626
|
equalityFn: import_t_state5.deepEqual,
|
|
1570
1627
|
useExternalDeps: true
|
|
1571
1628
|
});
|
|
1572
1629
|
(0, import_react8.useOnEvtmitterEvent)(storeEvents, "invalidateQuery", (event) => {
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1630
|
+
for (const { key, payload, isOffScreen } of queriesWithId) {
|
|
1631
|
+
if (isOffScreen)
|
|
1632
|
+
continue;
|
|
1576
1633
|
if (key !== event.queryKey)
|
|
1577
1634
|
continue;
|
|
1578
1635
|
if (!queryInvalidationWasTriggered.has(key)) {
|
|
@@ -1587,35 +1644,80 @@ function newTSDFListQueryStore({
|
|
|
1587
1644
|
}
|
|
1588
1645
|
}
|
|
1589
1646
|
});
|
|
1590
|
-
const
|
|
1647
|
+
const ignoreItemsInRefetchOnMount = useConst(() => /* @__PURE__ */ new Set());
|
|
1591
1648
|
(0, import_react9.useEffect)(() => {
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1649
|
+
const removedItems = new Set(ignoreItemsInRefetchOnMount);
|
|
1650
|
+
for (const {
|
|
1651
|
+
key: itemId,
|
|
1652
|
+
payload: fetchParams,
|
|
1653
|
+
isOffScreen,
|
|
1654
|
+
loadSize,
|
|
1655
|
+
disableRefetchOnMount
|
|
1656
|
+
} of queriesWithId) {
|
|
1657
|
+
removedItems.delete(itemId);
|
|
1658
|
+
if (isOffScreen)
|
|
1659
|
+
continue;
|
|
1595
1660
|
if (itemId) {
|
|
1596
1661
|
const itemState = getQueryState(fetchParams);
|
|
1597
1662
|
const fetchType = itemState?.refetchOnMount || "lowPriority";
|
|
1663
|
+
const shouldFetch = !itemState || !itemState.wasLoaded || itemState.refetchOnMount;
|
|
1664
|
+
if (!shouldFetch && ignoreItemsInRefetchOnMount.has(itemId)) {
|
|
1665
|
+
continue;
|
|
1666
|
+
}
|
|
1667
|
+
ignoreItemsInRefetchOnMount.add(itemId);
|
|
1598
1668
|
if (disableRefetchOnMount) {
|
|
1599
|
-
const shouldFetch = !itemState || !itemState.wasLoaded || itemState.refetchOnMount;
|
|
1600
1669
|
if (shouldFetch) {
|
|
1601
|
-
scheduleListQueryFetch(fetchType, fetchParams,
|
|
1670
|
+
scheduleListQueryFetch(fetchType, fetchParams, loadSize);
|
|
1602
1671
|
continue;
|
|
1603
1672
|
}
|
|
1604
1673
|
} else {
|
|
1605
|
-
scheduleListQueryFetch(fetchType, fetchParams,
|
|
1674
|
+
scheduleListQueryFetch(fetchType, fetchParams, loadSize);
|
|
1606
1675
|
}
|
|
1607
1676
|
}
|
|
1608
1677
|
}
|
|
1609
|
-
|
|
1678
|
+
for (const itemKey of removedItems) {
|
|
1679
|
+
ignoreItemsInRefetchOnMount.delete(itemKey);
|
|
1680
|
+
}
|
|
1681
|
+
}, [ignoreItemsInRefetchOnMount, queriesWithId]);
|
|
1610
1682
|
return storeState;
|
|
1611
1683
|
}
|
|
1612
|
-
function useListQuery(payload,
|
|
1613
|
-
|
|
1684
|
+
function useListQuery(payload, {
|
|
1685
|
+
isOffScreen,
|
|
1686
|
+
itemSelector,
|
|
1687
|
+
disableRefetchOnMount,
|
|
1688
|
+
returnIdleStatus,
|
|
1689
|
+
returnRefetchingStatus,
|
|
1690
|
+
loadSize,
|
|
1691
|
+
omitPayload,
|
|
1692
|
+
ensureIsLoaded,
|
|
1693
|
+
selectorUsesExternalDeps
|
|
1694
|
+
} = {}) {
|
|
1614
1695
|
const query = (0, import_react9.useMemo)(
|
|
1615
|
-
() => payload === false || payload === null || payload === void 0 ? [] : [
|
|
1616
|
-
|
|
1696
|
+
() => payload === false || payload === null || payload === void 0 ? [] : [
|
|
1697
|
+
{
|
|
1698
|
+
payload,
|
|
1699
|
+
disableRefetchOnMount,
|
|
1700
|
+
returnIdleStatus,
|
|
1701
|
+
returnRefetchingStatus,
|
|
1702
|
+
omitPayload,
|
|
1703
|
+
isOffScreen,
|
|
1704
|
+
loadSize
|
|
1705
|
+
}
|
|
1706
|
+
],
|
|
1707
|
+
[
|
|
1708
|
+
disableRefetchOnMount,
|
|
1709
|
+
isOffScreen,
|
|
1710
|
+
loadSize,
|
|
1711
|
+
omitPayload,
|
|
1712
|
+
payload,
|
|
1713
|
+
returnIdleStatus,
|
|
1714
|
+
returnRefetchingStatus
|
|
1715
|
+
]
|
|
1617
1716
|
);
|
|
1618
|
-
const queryResult = useMultipleListQueries(query,
|
|
1717
|
+
const queryResult = useMultipleListQueries(query, {
|
|
1718
|
+
itemSelector,
|
|
1719
|
+
selectorUsesExternalDeps
|
|
1720
|
+
});
|
|
1619
1721
|
const result = (0, import_react9.useMemo)(
|
|
1620
1722
|
() => queryResult[0] ?? {
|
|
1621
1723
|
payload: void 0,
|
|
@@ -1625,7 +1727,8 @@ function newTSDFListQueryStore({
|
|
|
1625
1727
|
status: "idle",
|
|
1626
1728
|
queryKey: "",
|
|
1627
1729
|
items: [],
|
|
1628
|
-
isLoadingMore: false
|
|
1730
|
+
isLoadingMore: false,
|
|
1731
|
+
queryMetadata: void 0
|
|
1629
1732
|
},
|
|
1630
1733
|
[queryResult]
|
|
1631
1734
|
);
|
|
@@ -1833,30 +1936,37 @@ function newTSDFListQueryStore({
|
|
|
1833
1936
|
function defaultItemDataSelector(data) {
|
|
1834
1937
|
return data;
|
|
1835
1938
|
}
|
|
1836
|
-
function useMultipleItems(
|
|
1939
|
+
function useMultipleItems(items, {
|
|
1837
1940
|
selector = defaultItemDataSelector,
|
|
1838
|
-
returnIdleStatus,
|
|
1839
|
-
returnRefetchingStatus,
|
|
1840
|
-
disableRefetchOnMount,
|
|
1841
1941
|
loadFromStateOnly,
|
|
1842
|
-
|
|
1942
|
+
selectorUsesExternalDeps
|
|
1843
1943
|
} = {}) {
|
|
1844
|
-
const dataSelector = (0, import_react9.useCallback)(selector, [
|
|
1944
|
+
const dataSelector = (0, import_react9.useCallback)(selector, [
|
|
1945
|
+
selectorUsesExternalDeps ? selector : 0
|
|
1946
|
+
]);
|
|
1845
1947
|
const memoizedItemKeys = useDeepMemo(
|
|
1846
|
-
() =>
|
|
1948
|
+
() => items.map(
|
|
1847
1949
|
(itemPayload) => ({
|
|
1848
|
-
|
|
1849
|
-
|
|
1950
|
+
itemKey: getItemKey(itemPayload.payload),
|
|
1951
|
+
payload: itemPayload.payload,
|
|
1952
|
+
disableRefetchOnMount: itemPayload.disableRefetchOnMount,
|
|
1953
|
+
returnIdleStatus: itemPayload.returnIdleStatus,
|
|
1954
|
+
returnRefetchingStatus: itemPayload.returnRefetchingStatus,
|
|
1955
|
+
isOffScreen: itemPayload.isOffScreen,
|
|
1956
|
+
queryMetadata: itemPayload.queryMetadata
|
|
1850
1957
|
})
|
|
1851
1958
|
),
|
|
1852
|
-
[
|
|
1959
|
+
[items]
|
|
1853
1960
|
);
|
|
1854
1961
|
const resultSelector = (0, import_react9.useCallback)(
|
|
1855
1962
|
(state) => {
|
|
1856
1963
|
return memoizedItemKeys.map(
|
|
1857
1964
|
({
|
|
1858
1965
|
itemKey,
|
|
1859
|
-
payload
|
|
1966
|
+
payload,
|
|
1967
|
+
queryMetadata,
|
|
1968
|
+
returnRefetchingStatus,
|
|
1969
|
+
returnIdleStatus
|
|
1860
1970
|
}) => {
|
|
1861
1971
|
const itemQuery = state.itemQueries[itemKey];
|
|
1862
1972
|
const itemState = state.items[itemKey];
|
|
@@ -1866,7 +1976,8 @@ function newTSDFListQueryStore({
|
|
|
1866
1976
|
error: null,
|
|
1867
1977
|
isLoading: false,
|
|
1868
1978
|
payload,
|
|
1869
|
-
data: dataSelector(null, null)
|
|
1979
|
+
data: dataSelector(null, null),
|
|
1980
|
+
queryMetadata
|
|
1870
1981
|
};
|
|
1871
1982
|
}
|
|
1872
1983
|
if (!itemQuery) {
|
|
@@ -1875,7 +1986,8 @@ function newTSDFListQueryStore({
|
|
|
1875
1986
|
error: null,
|
|
1876
1987
|
isLoading: returnIdleStatus ? false : true,
|
|
1877
1988
|
payload,
|
|
1878
|
-
data: dataSelector(null, null)
|
|
1989
|
+
data: dataSelector(null, null),
|
|
1990
|
+
queryMetadata
|
|
1879
1991
|
};
|
|
1880
1992
|
}
|
|
1881
1993
|
let status = itemQuery.status;
|
|
@@ -1887,26 +1999,24 @@ function newTSDFListQueryStore({
|
|
|
1887
1999
|
error: itemQuery.error,
|
|
1888
2000
|
isLoading: status === "loading",
|
|
1889
2001
|
data: dataSelector(itemState ?? null, itemQuery.payload),
|
|
1890
|
-
payload
|
|
2002
|
+
payload,
|
|
2003
|
+
queryMetadata
|
|
1891
2004
|
};
|
|
1892
2005
|
}
|
|
1893
2006
|
);
|
|
1894
2007
|
},
|
|
1895
|
-
[
|
|
1896
|
-
dataSelector,
|
|
1897
|
-
memoizedItemKeys,
|
|
1898
|
-
returnIdleStatus,
|
|
1899
|
-
returnRefetchingStatus
|
|
1900
|
-
]
|
|
2008
|
+
[dataSelector, memoizedItemKeys]
|
|
1901
2009
|
);
|
|
1902
2010
|
const storeState = store.useSelector(resultSelector, {
|
|
1903
2011
|
equalityFn: import_t_state5.deepEqual,
|
|
1904
2012
|
useExternalDeps: true
|
|
1905
2013
|
});
|
|
1906
2014
|
(0, import_react8.useOnEvtmitterEvent)(storeEvents, "invalidateItem", (event) => {
|
|
1907
|
-
if (loadFromStateOnly
|
|
2015
|
+
if (loadFromStateOnly)
|
|
1908
2016
|
return;
|
|
1909
|
-
for (const { payload, itemKey } of memoizedItemKeys) {
|
|
2017
|
+
for (const { payload, itemKey, isOffScreen } of memoizedItemKeys) {
|
|
2018
|
+
if (isOffScreen)
|
|
2019
|
+
continue;
|
|
1910
2020
|
if (itemKey !== event.itemKey)
|
|
1911
2021
|
continue;
|
|
1912
2022
|
if (!itemInvalidationWasTriggered.has(itemKey)) {
|
|
@@ -1921,15 +2031,29 @@ function newTSDFListQueryStore({
|
|
|
1921
2031
|
}
|
|
1922
2032
|
}
|
|
1923
2033
|
});
|
|
2034
|
+
const ignoreItemsInRefetchOnMount = useConst(() => /* @__PURE__ */ new Set());
|
|
1924
2035
|
(0, import_react9.useEffect)(() => {
|
|
1925
|
-
if (loadFromStateOnly
|
|
2036
|
+
if (loadFromStateOnly)
|
|
1926
2037
|
return;
|
|
1927
|
-
|
|
2038
|
+
const removedItems = new Set(ignoreItemsInRefetchOnMount);
|
|
2039
|
+
for (const {
|
|
2040
|
+
payload,
|
|
2041
|
+
itemKey,
|
|
2042
|
+
isOffScreen,
|
|
2043
|
+
disableRefetchOnMount
|
|
2044
|
+
} of memoizedItemKeys) {
|
|
2045
|
+
removedItems.delete(itemKey);
|
|
2046
|
+
if (isOffScreen)
|
|
2047
|
+
continue;
|
|
1928
2048
|
if (itemKey) {
|
|
1929
2049
|
const itemState = store.state.itemQueries[itemKey];
|
|
1930
2050
|
const fetchType = itemState?.refetchOnMount || "lowPriority";
|
|
2051
|
+
const shouldFetch = !itemState || !itemState.wasLoaded || itemState.refetchOnMount;
|
|
2052
|
+
if (!shouldFetch && ignoreItemsInRefetchOnMount.has(itemKey)) {
|
|
2053
|
+
continue;
|
|
2054
|
+
}
|
|
2055
|
+
ignoreItemsInRefetchOnMount.add(itemKey);
|
|
1931
2056
|
if (disableRefetchOnMount) {
|
|
1932
|
-
const shouldFetch = !itemState || !itemState.wasLoaded || itemState.refetchOnMount;
|
|
1933
2057
|
if (shouldFetch) {
|
|
1934
2058
|
scheduleItemFetch(fetchType, payload);
|
|
1935
2059
|
return;
|
|
@@ -1939,23 +2063,47 @@ function newTSDFListQueryStore({
|
|
|
1939
2063
|
}
|
|
1940
2064
|
}
|
|
1941
2065
|
}
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
memoizedItemKeys
|
|
1947
|
-
]);
|
|
2066
|
+
for (const itemKey of removedItems) {
|
|
2067
|
+
ignoreItemsInRefetchOnMount.delete(itemKey);
|
|
2068
|
+
}
|
|
2069
|
+
}, [ignoreItemsInRefetchOnMount, loadFromStateOnly, memoizedItemKeys]);
|
|
1948
2070
|
return storeState;
|
|
1949
2071
|
}
|
|
1950
|
-
function useItem(itemPayload,
|
|
1951
|
-
|
|
2072
|
+
function useItem(itemPayload, {
|
|
2073
|
+
selector,
|
|
2074
|
+
selectorUsesExternalDeps,
|
|
2075
|
+
disableRefetchOnMount,
|
|
2076
|
+
returnIdleStatus,
|
|
2077
|
+
returnRefetchingStatus,
|
|
2078
|
+
ensureIsLoaded,
|
|
2079
|
+
loadFromStateOnly,
|
|
2080
|
+
isOffScreen
|
|
2081
|
+
} = {}) {
|
|
1952
2082
|
const query = (0, import_react9.useMemo)(
|
|
1953
|
-
() => itemPayload === false || itemPayload === null || itemPayload === void 0 ? [] : [
|
|
1954
|
-
|
|
2083
|
+
() => itemPayload === false || itemPayload === null || itemPayload === void 0 ? [] : [
|
|
2084
|
+
{
|
|
2085
|
+
payload: itemPayload,
|
|
2086
|
+
disableRefetchOnMount,
|
|
2087
|
+
isOffScreen,
|
|
2088
|
+
returnIdleStatus,
|
|
2089
|
+
returnRefetchingStatus
|
|
2090
|
+
}
|
|
2091
|
+
],
|
|
2092
|
+
[
|
|
2093
|
+
itemPayload,
|
|
2094
|
+
disableRefetchOnMount,
|
|
2095
|
+
isOffScreen,
|
|
2096
|
+
returnIdleStatus,
|
|
2097
|
+
returnRefetchingStatus
|
|
2098
|
+
]
|
|
1955
2099
|
);
|
|
1956
|
-
const queryResult = useMultipleItems(query,
|
|
2100
|
+
const queryResult = useMultipleItems(query, {
|
|
2101
|
+
selector,
|
|
2102
|
+
selectorUsesExternalDeps,
|
|
2103
|
+
loadFromStateOnly
|
|
2104
|
+
});
|
|
1957
2105
|
const memoizedSelector = (0, import_react9.useCallback)(
|
|
1958
|
-
|
|
2106
|
+
selector ?? defaultItemDataSelector,
|
|
1959
2107
|
[]
|
|
1960
2108
|
);
|
|
1961
2109
|
const result = (0, import_react9.useMemo)(
|
|
@@ -1964,7 +2112,8 @@ function newTSDFListQueryStore({
|
|
|
1964
2112
|
isLoading: false,
|
|
1965
2113
|
status: "idle",
|
|
1966
2114
|
data: memoizedSelector(null, null),
|
|
1967
|
-
payload: itemPayload || null
|
|
2115
|
+
payload: itemPayload || null,
|
|
2116
|
+
queryMetadata: void 0
|
|
1968
2117
|
},
|
|
1969
2118
|
[itemPayload, memoizedSelector, queryResult]
|
|
1970
2119
|
);
|