@camstack/ui-library 1.2.61 → 1.2.62
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 +13 -2
- package/dist/index.js +13 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -48360,6 +48360,8 @@ function useSystemMutation(select, opts) {
|
|
|
48360
48360
|
* — the original admin-ui copy stayed put for backward compatibility
|
|
48361
48361
|
* but new consumers should import from here.
|
|
48362
48362
|
*/
|
|
48363
|
+
/** Trailing coalesce for event-driven invalidation — see the comment inside. */
|
|
48364
|
+
var EVENT_INVALIDATION_COALESCE_MS = 1e3;
|
|
48363
48365
|
function useEventInvalidation(queryKey, categories) {
|
|
48364
48366
|
const system = useSystem();
|
|
48365
48367
|
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
@@ -48373,12 +48375,20 @@ function useEventInvalidation(queryKey, categories) {
|
|
|
48373
48375
|
const keyJson = JSON.stringify(queryKey);
|
|
48374
48376
|
(0, react$1.useEffect)(() => {
|
|
48375
48377
|
const subs = [];
|
|
48376
|
-
|
|
48378
|
+
let pending = null;
|
|
48379
|
+
const refreshNow = () => {
|
|
48377
48380
|
const raw = JSON.parse(keyJson);
|
|
48378
48381
|
const queryKeyToInvalidate = raw.length === 1 && Array.isArray(raw[0]) ? raw : [raw];
|
|
48379
48382
|
queryClient.invalidateQueries({ queryKey: queryKeyToInvalidate });
|
|
48380
48383
|
};
|
|
48381
|
-
refresh()
|
|
48384
|
+
const refresh = () => {
|
|
48385
|
+
if (pending !== null) return;
|
|
48386
|
+
pending = setTimeout(() => {
|
|
48387
|
+
pending = null;
|
|
48388
|
+
refreshNow();
|
|
48389
|
+
}, EVENT_INVALIDATION_COALESCE_MS);
|
|
48390
|
+
};
|
|
48391
|
+
refreshNow();
|
|
48382
48392
|
for (const category of key.split("|")) {
|
|
48383
48393
|
if (!category) continue;
|
|
48384
48394
|
try {
|
|
@@ -48386,6 +48396,7 @@ function useEventInvalidation(queryKey, categories) {
|
|
|
48386
48396
|
} catch {}
|
|
48387
48397
|
}
|
|
48388
48398
|
return () => {
|
|
48399
|
+
if (pending !== null) clearTimeout(pending);
|
|
48389
48400
|
for (const unsub of subs) unsub();
|
|
48390
48401
|
};
|
|
48391
48402
|
}, [
|
package/dist/index.js
CHANGED
|
@@ -48336,6 +48336,8 @@ function useSystemMutation(select, opts) {
|
|
|
48336
48336
|
* — the original admin-ui copy stayed put for backward compatibility
|
|
48337
48337
|
* but new consumers should import from here.
|
|
48338
48338
|
*/
|
|
48339
|
+
/** Trailing coalesce for event-driven invalidation — see the comment inside. */
|
|
48340
|
+
var EVENT_INVALIDATION_COALESCE_MS = 1e3;
|
|
48339
48341
|
function useEventInvalidation(queryKey, categories) {
|
|
48340
48342
|
const system = useSystem();
|
|
48341
48343
|
const queryClient = useQueryClient();
|
|
@@ -48349,12 +48351,20 @@ function useEventInvalidation(queryKey, categories) {
|
|
|
48349
48351
|
const keyJson = JSON.stringify(queryKey);
|
|
48350
48352
|
useEffect(() => {
|
|
48351
48353
|
const subs = [];
|
|
48352
|
-
|
|
48354
|
+
let pending = null;
|
|
48355
|
+
const refreshNow = () => {
|
|
48353
48356
|
const raw = JSON.parse(keyJson);
|
|
48354
48357
|
const queryKeyToInvalidate = raw.length === 1 && Array.isArray(raw[0]) ? raw : [raw];
|
|
48355
48358
|
queryClient.invalidateQueries({ queryKey: queryKeyToInvalidate });
|
|
48356
48359
|
};
|
|
48357
|
-
refresh()
|
|
48360
|
+
const refresh = () => {
|
|
48361
|
+
if (pending !== null) return;
|
|
48362
|
+
pending = setTimeout(() => {
|
|
48363
|
+
pending = null;
|
|
48364
|
+
refreshNow();
|
|
48365
|
+
}, EVENT_INVALIDATION_COALESCE_MS);
|
|
48366
|
+
};
|
|
48367
|
+
refreshNow();
|
|
48358
48368
|
for (const category of key.split("|")) {
|
|
48359
48369
|
if (!category) continue;
|
|
48360
48370
|
try {
|
|
@@ -48362,6 +48372,7 @@ function useEventInvalidation(queryKey, categories) {
|
|
|
48362
48372
|
} catch {}
|
|
48363
48373
|
}
|
|
48364
48374
|
return () => {
|
|
48375
|
+
if (pending !== null) clearTimeout(pending);
|
|
48365
48376
|
for (const unsub of subs) unsub();
|
|
48366
48377
|
};
|
|
48367
48378
|
}, [
|