tsdf 10.0.0 → 11.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 CHANGED
@@ -397,7 +397,6 @@ function newTSDFDocumentStore({
397
397
  debugName,
398
398
  fetchFn,
399
399
  initialData,
400
- disableRefetchOnWindowFocus,
401
400
  disableRefetchOnMount: globalDisableRefetchOnMount,
402
401
  lowPriorityThrottleMs,
403
402
  mediumPriorityThrottleMs,
@@ -557,14 +556,6 @@ function newTSDFDocumentStore({
557
556
  { action: "update-state" }
558
557
  );
559
558
  }
560
- if (!disableRefetchOnWindowFocus) {
561
- let handleFocus2 = function() {
562
- invalidateData("lowPriority");
563
- };
564
- var handleFocus = handleFocus2;
565
- window.addEventListener("focus", handleFocus2);
566
- window.addEventListener("visibilitychange", handleFocus2);
567
- }
568
559
  return {
569
560
  store,
570
561
  awaitFetch,
@@ -632,7 +623,6 @@ var import_json = require("klona/json");
632
623
  function newTSDFCollectionStore({
633
624
  debugName,
634
625
  fetchFn,
635
- disableRefetchOnWindowFocus,
636
626
  lowPriorityThrottleMs,
637
627
  errorNormalizer,
638
628
  disableInitialDataInvalidation,
@@ -1010,14 +1000,6 @@ function newTSDFCollectionStore({
1010
1000
  );
1011
1001
  return someItemWasUpdated;
1012
1002
  }
1013
- if (!disableRefetchOnWindowFocus) {
1014
- let handleFocus2 = function() {
1015
- invalidateItem(() => true, "lowPriority");
1016
- };
1017
- var handleFocus = handleFocus2;
1018
- window.addEventListener("focus", handleFocus2);
1019
- window.addEventListener("visibilitychange", handleFocus2);
1020
- }
1021
1003
  return {
1022
1004
  store,
1023
1005
  scheduleFetch,
@@ -1062,7 +1044,6 @@ function newTSDFListQueryStore({
1062
1044
  errorNormalizer,
1063
1045
  defaultQuerySize = 50,
1064
1046
  initialData,
1065
- disableRefetchOnWindowFocus,
1066
1047
  disableRefetchOnMount: globalDisableRefetchOnMount,
1067
1048
  lowPriorityThrottleMs,
1068
1049
  disableInitialDataInvalidation,
@@ -1902,6 +1883,8 @@ function newTSDFListQueryStore({
1902
1883
  const queryState = draftState.queries[key];
1903
1884
  if (!queryState)
1904
1885
  continue;
1886
+ if (queryState.items.includes(itemKey))
1887
+ continue;
1905
1888
  if (addItemToQueries.appendTo === "start") {
1906
1889
  queryState.items.unshift(itemKey);
1907
1890
  } else if (addItemToQueries.appendTo === "end") {
@@ -1939,17 +1922,6 @@ function newTSDFListQueryStore({
1939
1922
  { action: { type: "delete-item-state", itemId } }
1940
1923
  );
1941
1924
  }
1942
- if (!disableRefetchOnWindowFocus) {
1943
- let handleFocus2 = function() {
1944
- invalidateQuery(() => true, "lowPriority");
1945
- if (fetchItemFn) {
1946
- invalidateItem(() => true, "lowPriority");
1947
- }
1948
- };
1949
- var handleFocus = handleFocus2;
1950
- window.addEventListener("focus", handleFocus2);
1951
- window.addEventListener("visibilitychange", handleFocus2);
1952
- }
1953
1925
  return {
1954
1926
  store,
1955
1927
  scheduleListQueryFetch,
package/dist/main.d.ts CHANGED
@@ -20,13 +20,12 @@ type TSDFUseDocumentReturn<Selected, NError> = {
20
20
  error: NError | null;
21
21
  isLoading: boolean;
22
22
  };
23
- declare function newTSDFDocumentStore<State extends ValidStoreState, NError>({ debugName, fetchFn, initialData, disableRefetchOnWindowFocus, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs, disableInitialDataInvalidation, errorNormalizer, }: {
23
+ declare function newTSDFDocumentStore<State extends ValidStoreState, NError>({ debugName, fetchFn, initialData, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs, disableInitialDataInvalidation, errorNormalizer, }: {
24
24
  debugName?: string;
25
25
  fetchFn: () => Promise<State>;
26
26
  initialData?: State;
27
27
  disableInitialDataInvalidation?: boolean;
28
28
  errorNormalizer: (exception: unknown) => NError;
29
- disableRefetchOnWindowFocus?: boolean;
30
29
  disableRefetchOnMount?: boolean;
31
30
  lowPriorityThrottleMs?: number;
32
31
  mediumPriorityThrottleMs?: number;
@@ -77,12 +76,11 @@ type CollectionInitialStateItem<ItemPayload extends ValidPayload, ItemState exte
77
76
  payload: ItemPayload;
78
77
  data: ItemState;
79
78
  };
80
- declare function newTSDFCollectionStore<ItemState extends ValidStoreState, NError, ItemPayload extends ValidPayload>({ debugName, fetchFn, disableRefetchOnWindowFocus, lowPriorityThrottleMs, errorNormalizer, disableInitialDataInvalidation, mediumPriorityThrottleMs, initialStateItems, disableRefetchOnMount: globalDisableRefetchOnMount, dynamicRealtimeThrottleMs, getCollectionItemKey: filterCollectionItemObjKey, }: {
79
+ declare function newTSDFCollectionStore<ItemState extends ValidStoreState, NError, ItemPayload extends ValidPayload>({ debugName, fetchFn, lowPriorityThrottleMs, errorNormalizer, disableInitialDataInvalidation, mediumPriorityThrottleMs, initialStateItems, disableRefetchOnMount: globalDisableRefetchOnMount, dynamicRealtimeThrottleMs, getCollectionItemKey: filterCollectionItemObjKey, }: {
81
80
  debugName?: string;
82
81
  fetchFn: (params: ItemPayload) => Promise<ItemState>;
83
82
  getCollectionItemKey?: (params: ItemPayload) => ValidPayload | any[];
84
83
  errorNormalizer: (exception: unknown) => NError;
85
- disableRefetchOnWindowFocus?: boolean;
86
84
  disableRefetchOnMount?: boolean;
87
85
  initialStateItems?: CollectionInitialStateItem<ItemPayload, ItemState>[];
88
86
  disableInitialDataInvalidation?: boolean;
@@ -187,7 +185,7 @@ type ListQueryStoreInitialData<ItemState extends ValidStoreState, QueryPayload e
187
185
  hasMore: boolean;
188
186
  }[];
189
187
  };
190
- declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload>({ debugName, fetchListFn, fetchItemFn, errorNormalizer, defaultQuerySize, initialData, disableRefetchOnWindowFocus, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, disableInitialDataInvalidation, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs, syncMutationsAndInvalidations, }: {
188
+ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload>({ debugName, fetchListFn, fetchItemFn, errorNormalizer, defaultQuerySize, initialData, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, disableInitialDataInvalidation, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs, syncMutationsAndInvalidations, }: {
191
189
  debugName?: string;
192
190
  fetchListFn: (payload: QueryPayload, size: number) => Promise<FetchListFnReturn<ItemState, ItemPayload>>;
193
191
  fetchItemFn?: (itemId: ItemPayload) => Promise<ItemState>;
@@ -195,7 +193,6 @@ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError
195
193
  defaultQuerySize?: number;
196
194
  initialData?: ListQueryStoreInitialData<ItemState, QueryPayload, ItemPayload>;
197
195
  disableInitialDataInvalidation?: boolean;
198
- disableRefetchOnWindowFocus?: boolean;
199
196
  syncMutationsAndInvalidations?: {
200
197
  syncQueries: (query1: QueryPayload, query2: QueryPayload) => boolean;
201
198
  syncItemAndQuery: (itemPayload: ItemPayload, query: QueryPayload) => boolean;
package/dist/main.js CHANGED
@@ -363,7 +363,6 @@ function newTSDFDocumentStore({
363
363
  debugName,
364
364
  fetchFn,
365
365
  initialData,
366
- disableRefetchOnWindowFocus,
367
366
  disableRefetchOnMount: globalDisableRefetchOnMount,
368
367
  lowPriorityThrottleMs,
369
368
  mediumPriorityThrottleMs,
@@ -523,14 +522,6 @@ function newTSDFDocumentStore({
523
522
  { action: "update-state" }
524
523
  );
525
524
  }
526
- if (!disableRefetchOnWindowFocus) {
527
- let handleFocus2 = function() {
528
- invalidateData("lowPriority");
529
- };
530
- var handleFocus = handleFocus2;
531
- window.addEventListener("focus", handleFocus2);
532
- window.addEventListener("visibilitychange", handleFocus2);
533
- }
534
525
  return {
535
526
  store,
536
527
  awaitFetch,
@@ -598,7 +589,6 @@ import { klona } from "klona/json";
598
589
  function newTSDFCollectionStore({
599
590
  debugName,
600
591
  fetchFn,
601
- disableRefetchOnWindowFocus,
602
592
  lowPriorityThrottleMs,
603
593
  errorNormalizer,
604
594
  disableInitialDataInvalidation,
@@ -976,14 +966,6 @@ function newTSDFCollectionStore({
976
966
  );
977
967
  return someItemWasUpdated;
978
968
  }
979
- if (!disableRefetchOnWindowFocus) {
980
- let handleFocus2 = function() {
981
- invalidateItem(() => true, "lowPriority");
982
- };
983
- var handleFocus = handleFocus2;
984
- window.addEventListener("focus", handleFocus2);
985
- window.addEventListener("visibilitychange", handleFocus2);
986
- }
987
969
  return {
988
970
  store,
989
971
  scheduleFetch,
@@ -1028,7 +1010,6 @@ function newTSDFListQueryStore({
1028
1010
  errorNormalizer,
1029
1011
  defaultQuerySize = 50,
1030
1012
  initialData,
1031
- disableRefetchOnWindowFocus,
1032
1013
  disableRefetchOnMount: globalDisableRefetchOnMount,
1033
1014
  lowPriorityThrottleMs,
1034
1015
  disableInitialDataInvalidation,
@@ -1868,6 +1849,8 @@ function newTSDFListQueryStore({
1868
1849
  const queryState = draftState.queries[key];
1869
1850
  if (!queryState)
1870
1851
  continue;
1852
+ if (queryState.items.includes(itemKey))
1853
+ continue;
1871
1854
  if (addItemToQueries.appendTo === "start") {
1872
1855
  queryState.items.unshift(itemKey);
1873
1856
  } else if (addItemToQueries.appendTo === "end") {
@@ -1905,17 +1888,6 @@ function newTSDFListQueryStore({
1905
1888
  { action: { type: "delete-item-state", itemId } }
1906
1889
  );
1907
1890
  }
1908
- if (!disableRefetchOnWindowFocus) {
1909
- let handleFocus2 = function() {
1910
- invalidateQuery(() => true, "lowPriority");
1911
- if (fetchItemFn) {
1912
- invalidateItem(() => true, "lowPriority");
1913
- }
1914
- };
1915
- var handleFocus = handleFocus2;
1916
- window.addEventListener("focus", handleFocus2);
1917
- window.addEventListener("visibilitychange", handleFocus2);
1918
- }
1919
1891
  return {
1920
1892
  store,
1921
1893
  scheduleListQueryFetch,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdf",
3
- "version": "10.0.0",
3
+ "version": "11.0.0",
4
4
  "description": "A data fetching solution based on t-state",
5
5
  "license": "MIT",
6
6
  "author": "Lucas Santos",