@braine/quantum-query 1.2.7 → 1.2.9
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/index.cjs +20 -7
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +20 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -591,7 +591,7 @@ function isDeepEqual(a, b) {
|
|
|
591
591
|
var QueryStorage = class {
|
|
592
592
|
// Tracks access order (least to most recent)
|
|
593
593
|
// Default configuration
|
|
594
|
-
constructor(defaultStaleTime =
|
|
594
|
+
constructor(defaultStaleTime = 5 * 60 * 1e3, defaultCacheTime = 5 * 60 * 1e3, maxSize = 100) {
|
|
595
595
|
this.defaultStaleTime = defaultStaleTime;
|
|
596
596
|
this.defaultCacheTime = defaultCacheTime;
|
|
597
597
|
this.maxSize = maxSize;
|
|
@@ -944,7 +944,7 @@ var QueryClient = class {
|
|
|
944
944
|
defaultCacheTime;
|
|
945
945
|
defaultSchema;
|
|
946
946
|
constructor(config) {
|
|
947
|
-
this.defaultStaleTime = config?.defaultStaleTime ??
|
|
947
|
+
this.defaultStaleTime = config?.defaultStaleTime ?? 5 * 60 * 1e3;
|
|
948
948
|
this.defaultCacheTime = config?.defaultCacheTime ?? 5 * 60 * 1e3;
|
|
949
949
|
this.defaultSchema = config?.defaultSchema;
|
|
950
950
|
this.storage = new QueryStorage(
|
|
@@ -1126,6 +1126,14 @@ var QueryClient = class {
|
|
|
1126
1126
|
return Date.now() - entry.timestamp > entry.staleTime;
|
|
1127
1127
|
};
|
|
1128
1128
|
getAll = () => this.storage.getAll();
|
|
1129
|
+
/**
|
|
1130
|
+
* Check if a query key exists in the cache
|
|
1131
|
+
*/
|
|
1132
|
+
has = (queryKey) => {
|
|
1133
|
+
const key = this.storage.generateKey(queryKey);
|
|
1134
|
+
const signal2 = this.storage.get(key, false);
|
|
1135
|
+
return signal2 !== void 0 && signal2.get() !== void 0;
|
|
1136
|
+
};
|
|
1129
1137
|
snapshot = () => this.storage.getSnapshot();
|
|
1130
1138
|
clear = () => this.storage.clear();
|
|
1131
1139
|
remove = (key) => this.storage.delete(this.storage.generateKey(key));
|
|
@@ -1323,8 +1331,11 @@ var FocusManager = class {
|
|
|
1323
1331
|
return this.focused;
|
|
1324
1332
|
}
|
|
1325
1333
|
setFocused(focused) {
|
|
1334
|
+
const wasUnfocused = !this.focused;
|
|
1326
1335
|
this.focused = focused;
|
|
1327
|
-
if (focused)
|
|
1336
|
+
if (focused && wasUnfocused) {
|
|
1337
|
+
this.onFocus();
|
|
1338
|
+
}
|
|
1328
1339
|
}
|
|
1329
1340
|
};
|
|
1330
1341
|
var focusManager = new FocusManager();
|
|
@@ -1588,10 +1599,12 @@ var MutationObserver = class {
|
|
|
1588
1599
|
});
|
|
1589
1600
|
this.client.mutationCache.notify(id, pendingState);
|
|
1590
1601
|
const unsubscribe = this.client.mutationCache.getSignal(id).subscribe((state) => {
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1602
|
+
untracked(() => {
|
|
1603
|
+
const current = this.signal.get();
|
|
1604
|
+
if (current.status !== state.status || current.data !== state.data || current.error !== state.error) {
|
|
1605
|
+
this.signal.set(state);
|
|
1606
|
+
}
|
|
1607
|
+
});
|
|
1595
1608
|
});
|
|
1596
1609
|
return this.executeMutation(id, variables).finally(() => {
|
|
1597
1610
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -244,6 +244,10 @@ declare class QueryClient {
|
|
|
244
244
|
use: (plugin: QueryPlugin) => this;
|
|
245
245
|
isStale: (queryKey: QueryKeyInput) => boolean;
|
|
246
246
|
getAll: () => Map<string, CacheEntry<unknown>>;
|
|
247
|
+
/**
|
|
248
|
+
* Check if a query key exists in the cache
|
|
249
|
+
*/
|
|
250
|
+
has: (queryKey: QueryKeyInput) => boolean;
|
|
247
251
|
snapshot: () => Map<string, CacheEntry<unknown>>;
|
|
248
252
|
clear: () => void;
|
|
249
253
|
remove: (key: QueryKeyInput) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -244,6 +244,10 @@ declare class QueryClient {
|
|
|
244
244
|
use: (plugin: QueryPlugin) => this;
|
|
245
245
|
isStale: (queryKey: QueryKeyInput) => boolean;
|
|
246
246
|
getAll: () => Map<string, CacheEntry<unknown>>;
|
|
247
|
+
/**
|
|
248
|
+
* Check if a query key exists in the cache
|
|
249
|
+
*/
|
|
250
|
+
has: (queryKey: QueryKeyInput) => boolean;
|
|
247
251
|
snapshot: () => Map<string, CacheEntry<unknown>>;
|
|
248
252
|
clear: () => void;
|
|
249
253
|
remove: (key: QueryKeyInput) => void;
|
package/dist/index.js
CHANGED
|
@@ -550,7 +550,7 @@ function isDeepEqual(a, b) {
|
|
|
550
550
|
var QueryStorage = class {
|
|
551
551
|
// Tracks access order (least to most recent)
|
|
552
552
|
// Default configuration
|
|
553
|
-
constructor(defaultStaleTime =
|
|
553
|
+
constructor(defaultStaleTime = 5 * 60 * 1e3, defaultCacheTime = 5 * 60 * 1e3, maxSize = 100) {
|
|
554
554
|
this.defaultStaleTime = defaultStaleTime;
|
|
555
555
|
this.defaultCacheTime = defaultCacheTime;
|
|
556
556
|
this.maxSize = maxSize;
|
|
@@ -903,7 +903,7 @@ var QueryClient = class {
|
|
|
903
903
|
defaultCacheTime;
|
|
904
904
|
defaultSchema;
|
|
905
905
|
constructor(config) {
|
|
906
|
-
this.defaultStaleTime = config?.defaultStaleTime ??
|
|
906
|
+
this.defaultStaleTime = config?.defaultStaleTime ?? 5 * 60 * 1e3;
|
|
907
907
|
this.defaultCacheTime = config?.defaultCacheTime ?? 5 * 60 * 1e3;
|
|
908
908
|
this.defaultSchema = config?.defaultSchema;
|
|
909
909
|
this.storage = new QueryStorage(
|
|
@@ -1085,6 +1085,14 @@ var QueryClient = class {
|
|
|
1085
1085
|
return Date.now() - entry.timestamp > entry.staleTime;
|
|
1086
1086
|
};
|
|
1087
1087
|
getAll = () => this.storage.getAll();
|
|
1088
|
+
/**
|
|
1089
|
+
* Check if a query key exists in the cache
|
|
1090
|
+
*/
|
|
1091
|
+
has = (queryKey) => {
|
|
1092
|
+
const key = this.storage.generateKey(queryKey);
|
|
1093
|
+
const signal2 = this.storage.get(key, false);
|
|
1094
|
+
return signal2 !== void 0 && signal2.get() !== void 0;
|
|
1095
|
+
};
|
|
1088
1096
|
snapshot = () => this.storage.getSnapshot();
|
|
1089
1097
|
clear = () => this.storage.clear();
|
|
1090
1098
|
remove = (key) => this.storage.delete(this.storage.generateKey(key));
|
|
@@ -1282,8 +1290,11 @@ var FocusManager = class {
|
|
|
1282
1290
|
return this.focused;
|
|
1283
1291
|
}
|
|
1284
1292
|
setFocused(focused) {
|
|
1293
|
+
const wasUnfocused = !this.focused;
|
|
1285
1294
|
this.focused = focused;
|
|
1286
|
-
if (focused)
|
|
1295
|
+
if (focused && wasUnfocused) {
|
|
1296
|
+
this.onFocus();
|
|
1297
|
+
}
|
|
1287
1298
|
}
|
|
1288
1299
|
};
|
|
1289
1300
|
var focusManager = new FocusManager();
|
|
@@ -1547,10 +1558,12 @@ var MutationObserver = class {
|
|
|
1547
1558
|
});
|
|
1548
1559
|
this.client.mutationCache.notify(id, pendingState);
|
|
1549
1560
|
const unsubscribe = this.client.mutationCache.getSignal(id).subscribe((state) => {
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1561
|
+
untracked(() => {
|
|
1562
|
+
const current = this.signal.get();
|
|
1563
|
+
if (current.status !== state.status || current.data !== state.data || current.error !== state.error) {
|
|
1564
|
+
this.signal.set(state);
|
|
1565
|
+
}
|
|
1566
|
+
});
|
|
1554
1567
|
});
|
|
1555
1568
|
return this.executeMutation(id, variables).finally(() => {
|
|
1556
1569
|
});
|