@rozenite/tanstack-query-plugin 1.13.0 → 2.1.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/CHANGELOG.md +22 -0
- package/dist/devtools/assets/{CXEL7IU7-DmbowaBr.js → CXEL7IU7-BWccRGN3.js} +1 -1
- package/dist/devtools/assets/{tanstack-query-DRBLkSCy.js → tanstack-query-CbF_imft.js} +13 -13
- package/dist/devtools/tanstack-query.html +1 -1
- package/dist/react-native/chunks/useTanStackQueryDevTools.require.cjs +1 -1
- package/dist/react-native/chunks/useTanStackQueryDevTools.require.js +165 -173
- package/dist/rozenite.json +1 -1
- package/dist/sdk/index.cjs +1 -1
- package/dist/sdk/index.js +65 -33
- package/package.json +30 -34
- package/sdk.ts +1 -4
- package/src/react-native/agent/__tests__/tanstack-query-agent.test.ts +32 -31
- package/src/react-native/agent/tanstack-query-agent.ts +33 -97
- package/src/react-native/agent/useTanStackQueryAgentTools.ts +2 -7
- package/src/react-native/devtools-actions.ts +3 -10
- package/src/react-native/useHandleDevToolsMessages.ts +12 -16
- package/src/react-native/useHandleInitialData.ts +8 -1
- package/src/react-native/useSyncTanStackCache.ts +7 -22
- package/src/shared/agent-tools.ts +59 -44
- package/src/shared/dehydrate.ts +1 -3
- package/src/shared/hydrate.ts +11 -21
- package/src/shared/messaging.ts +8 -2
- package/src/shared/query-data-sync.test.ts +1 -5
- package/src/shared/query-data-sync.ts +8 -35
- package/src/shared/useSyncOnlineStatus.ts +4 -9
- package/src/ui/useHandleSyncMessages.ts +23 -31
- package/src/ui/useSyncDevToolsEvents.ts +4 -13
- package/src/ui/useSyncInitialData.test.tsx +76 -0
- package/src/ui/useSyncInitialData.ts +17 -4
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { useRozeniteDevToolsClient as
|
|
2
|
-
import { useEffect as A, useRef as
|
|
1
|
+
import { useRozeniteDevToolsClient as w } from "@rozenite/plugin-bridge";
|
|
2
|
+
import { useEffect as A, useRef as C, useMemo as R } from "react";
|
|
3
3
|
import { onlineManager as S } from "@tanstack/react-query";
|
|
4
|
-
import
|
|
4
|
+
import U from "fast-deep-equal";
|
|
5
5
|
import { useRozenitePluginAgentTool as i } from "@rozenite/agent-bridge";
|
|
6
|
-
import { defineAgentToolContract as
|
|
6
|
+
import { defineAgentToolContract as y, definePaginatedAgentToolContract as v } from "@rozenite/agent-shared";
|
|
7
7
|
const _ = (e) => {
|
|
8
8
|
A(() => {
|
|
9
9
|
if (!e)
|
|
10
10
|
return;
|
|
11
11
|
const r = S.subscribe((a) => {
|
|
12
12
|
e.send("online-status-changed", { online: a });
|
|
13
|
-
}), t = e.onMessage(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
S.setOnline(a);
|
|
17
|
-
}
|
|
18
|
-
);
|
|
13
|
+
}), t = e.onMessage("online-status-changed", ({ online: a }) => {
|
|
14
|
+
S.setOnline(a);
|
|
15
|
+
});
|
|
19
16
|
return () => {
|
|
20
17
|
r(), t.remove();
|
|
21
18
|
};
|
|
@@ -148,51 +145,46 @@ const _ = (e) => {
|
|
|
148
145
|
};
|
|
149
146
|
}
|
|
150
147
|
}
|
|
151
|
-
},
|
|
148
|
+
}, G = (e, r) => {
|
|
152
149
|
A(() => {
|
|
153
150
|
if (!r)
|
|
154
151
|
return;
|
|
155
|
-
const t = r.onMessage(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
);
|
|
152
|
+
const t = r.onMessage("devtools-action", ({ type: a, queryHash: n, metadata: h }) => {
|
|
153
|
+
f(e, {
|
|
154
|
+
type: a,
|
|
155
|
+
queryHash: n,
|
|
156
|
+
metadata: h
|
|
157
|
+
}).catch((p) => {
|
|
158
|
+
const s = p instanceof Error ? p.message : String(p);
|
|
159
|
+
console.warn(
|
|
160
|
+
`[Rozenite, tanstack-query-plugin] Failed to apply devtools action "${a}": ${s}`
|
|
161
|
+
);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
170
164
|
return () => {
|
|
171
165
|
t.remove();
|
|
172
166
|
};
|
|
173
167
|
}, [r]);
|
|
174
|
-
},
|
|
168
|
+
}, k = (e) => e.observers.map((r) => ({
|
|
175
169
|
queryHash: e.queryHash,
|
|
176
170
|
options: r.options
|
|
177
171
|
})), H = (e) => {
|
|
178
|
-
const r =
|
|
172
|
+
const r = k(e);
|
|
179
173
|
return {
|
|
180
174
|
state: e.state,
|
|
181
175
|
queryKey: e.queryKey,
|
|
182
176
|
queryHash: e.queryHash,
|
|
183
177
|
observers: r
|
|
184
178
|
};
|
|
185
|
-
},
|
|
179
|
+
}, D = (e) => ({
|
|
186
180
|
mutationId: e.mutationId,
|
|
187
181
|
state: e.state,
|
|
188
182
|
options: e.options
|
|
189
|
-
}),
|
|
183
|
+
}), j = (e) => ({
|
|
190
184
|
queries: e.getQueryCache().getAll().map(H),
|
|
191
|
-
mutations: e.getMutationCache().getAll().map(
|
|
192
|
-
}),
|
|
193
|
-
const t =
|
|
194
|
-
/* @__PURE__ */ new Map()
|
|
195
|
-
), a = I(() => (n) => {
|
|
185
|
+
mutations: e.getMutationCache().getAll().map(D)
|
|
186
|
+
}), N = (e, r) => {
|
|
187
|
+
const t = C(/* @__PURE__ */ new Map()), a = R(() => (n) => {
|
|
196
188
|
if (!r || n.type === "observerResultsUpdated")
|
|
197
189
|
return;
|
|
198
190
|
if ("query" in n) {
|
|
@@ -323,15 +315,10 @@ const _ = (e) => {
|
|
|
323
315
|
return;
|
|
324
316
|
}
|
|
325
317
|
if (l === "observerAdded" || l === "observerRemoved" || l === "observerOptionsUpdated") {
|
|
326
|
-
const g =
|
|
327
|
-
|
|
328
|
-
);
|
|
329
|
-
if (l === "observerOptionsUpdated" && u && C(u, g))
|
|
318
|
+
const g = k(s), u = t.current.get(s.queryHash);
|
|
319
|
+
if (l === "observerOptionsUpdated" && u && U(u, g))
|
|
330
320
|
return;
|
|
331
|
-
t.current.set(
|
|
332
|
-
s.queryHash,
|
|
333
|
-
g
|
|
334
|
-
), r.send("sync-query-event", {
|
|
321
|
+
t.current.set(s.queryHash, g), r.send("sync-query-event", {
|
|
335
322
|
type: l,
|
|
336
323
|
data: {
|
|
337
324
|
queryHash: s.queryHash,
|
|
@@ -343,7 +330,7 @@ const _ = (e) => {
|
|
|
343
330
|
}
|
|
344
331
|
const { mutation: h, type: p } = n;
|
|
345
332
|
if (h) {
|
|
346
|
-
const s =
|
|
333
|
+
const s = D(h);
|
|
347
334
|
r.send("sync-mutation-event", {
|
|
348
335
|
type: p,
|
|
349
336
|
data: s
|
|
@@ -358,29 +345,29 @@ const _ = (e) => {
|
|
|
358
345
|
n(), h();
|
|
359
346
|
};
|
|
360
347
|
}, [r, e, a]);
|
|
361
|
-
},
|
|
348
|
+
}, L = (e, r) => {
|
|
362
349
|
A(() => {
|
|
363
350
|
if (!r)
|
|
364
351
|
return;
|
|
365
352
|
const t = r.onMessage("request-initial-data", () => {
|
|
366
|
-
const a =
|
|
353
|
+
const a = j(e);
|
|
367
354
|
r.send("sync-data", { data: a });
|
|
368
355
|
});
|
|
369
|
-
return () => {
|
|
356
|
+
return r.send("device-ready", {}), () => {
|
|
370
357
|
t.remove();
|
|
371
358
|
};
|
|
372
359
|
}, [r, e]);
|
|
373
|
-
},
|
|
360
|
+
}, c = "@rozenite/tanstack-query-plugin", b = {
|
|
374
361
|
queryHash: {
|
|
375
362
|
type: "string",
|
|
376
363
|
description: "TanStack Query queryHash identifying the query."
|
|
377
364
|
}
|
|
378
|
-
},
|
|
365
|
+
}, F = {
|
|
379
366
|
mutationId: {
|
|
380
367
|
type: "number",
|
|
381
368
|
description: "TanStack Query mutationId identifying the mutation."
|
|
382
369
|
}
|
|
383
|
-
},
|
|
370
|
+
}, E = {
|
|
384
371
|
limit: {
|
|
385
372
|
type: "number",
|
|
386
373
|
description: "Maximum number of items to return. Defaults to 20. Maximum 100."
|
|
@@ -392,18 +379,18 @@ const _ = (e) => {
|
|
|
392
379
|
}, q = {
|
|
393
380
|
type: "object",
|
|
394
381
|
properties: {}
|
|
395
|
-
},
|
|
396
|
-
getCacheSummary:
|
|
382
|
+
}, d = {
|
|
383
|
+
getCacheSummary: y({
|
|
397
384
|
name: "get-cache-summary",
|
|
398
385
|
description: "Return aggregate TanStack Query cache health and count information.",
|
|
399
386
|
inputSchema: q
|
|
400
387
|
}),
|
|
401
|
-
getOnlineStatus:
|
|
388
|
+
getOnlineStatus: y({
|
|
402
389
|
name: "get-online-status",
|
|
403
390
|
description: "Return the current TanStack Query onlineManager status.",
|
|
404
391
|
inputSchema: q
|
|
405
392
|
}),
|
|
406
|
-
setOnlineStatus:
|
|
393
|
+
setOnlineStatus: y({
|
|
407
394
|
name: "set-online-status",
|
|
408
395
|
description: "Set the TanStack Query onlineManager status for testing offline/online behavior.",
|
|
409
396
|
inputSchema: {
|
|
@@ -417,15 +404,31 @@ const _ = (e) => {
|
|
|
417
404
|
required: ["online"]
|
|
418
405
|
}
|
|
419
406
|
}),
|
|
420
|
-
listQueries:
|
|
407
|
+
listQueries: v({
|
|
421
408
|
name: "list-queries",
|
|
422
409
|
description: "List TanStack Query query summaries using cursor pagination.",
|
|
423
410
|
inputSchema: {
|
|
424
411
|
type: "object",
|
|
425
|
-
properties:
|
|
412
|
+
properties: E
|
|
413
|
+
},
|
|
414
|
+
pagination: {
|
|
415
|
+
kind: "cursor",
|
|
416
|
+
fields: [
|
|
417
|
+
"queryHash",
|
|
418
|
+
"queryKey",
|
|
419
|
+
"status",
|
|
420
|
+
"fetchStatus",
|
|
421
|
+
"observersCount",
|
|
422
|
+
"isInvalidated",
|
|
423
|
+
"dataUpdatedAt",
|
|
424
|
+
"errorUpdatedAt",
|
|
425
|
+
"hasData",
|
|
426
|
+
"hasError"
|
|
427
|
+
],
|
|
428
|
+
defaultFields: ["queryHash", "queryKey", "status", "fetchStatus", "hasError"]
|
|
426
429
|
}
|
|
427
430
|
}),
|
|
428
|
-
getQueryDetails:
|
|
431
|
+
getQueryDetails: y({
|
|
429
432
|
name: "get-query-details",
|
|
430
433
|
description: "Return a JSON-safe TanStack Query query snapshot and observer summary.",
|
|
431
434
|
inputSchema: {
|
|
@@ -434,7 +437,7 @@ const _ = (e) => {
|
|
|
434
437
|
required: ["queryHash"]
|
|
435
438
|
}
|
|
436
439
|
}),
|
|
437
|
-
refetchQuery:
|
|
440
|
+
refetchQuery: y({
|
|
438
441
|
name: "refetch-query",
|
|
439
442
|
description: "Refetch a TanStack Query query by queryHash.",
|
|
440
443
|
inputSchema: {
|
|
@@ -443,7 +446,7 @@ const _ = (e) => {
|
|
|
443
446
|
required: ["queryHash"]
|
|
444
447
|
}
|
|
445
448
|
}),
|
|
446
|
-
setQueryLoading:
|
|
449
|
+
setQueryLoading: y({
|
|
447
450
|
name: "set-query-loading",
|
|
448
451
|
description: "Enable or disable TanStack Query loading-state simulation for a query by queryHash.",
|
|
449
452
|
inputSchema: {
|
|
@@ -458,22 +461,24 @@ const _ = (e) => {
|
|
|
458
461
|
required: ["queryHash", "enabled"]
|
|
459
462
|
}
|
|
460
463
|
}),
|
|
461
|
-
setQueryError:
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
464
|
+
setQueryError: y(
|
|
465
|
+
{
|
|
466
|
+
name: "set-query-error",
|
|
467
|
+
description: "Enable or disable TanStack Query error-state simulation for a query by queryHash.",
|
|
468
|
+
inputSchema: {
|
|
469
|
+
type: "object",
|
|
470
|
+
properties: {
|
|
471
|
+
...b,
|
|
472
|
+
enabled: {
|
|
473
|
+
type: "boolean",
|
|
474
|
+
description: "Whether the error-state simulation should be enabled."
|
|
475
|
+
}
|
|
476
|
+
},
|
|
477
|
+
required: ["queryHash", "enabled"]
|
|
478
|
+
}
|
|
474
479
|
}
|
|
475
|
-
|
|
476
|
-
invalidateQuery:
|
|
480
|
+
),
|
|
481
|
+
invalidateQuery: y({
|
|
477
482
|
name: "invalidate-query",
|
|
478
483
|
description: "Invalidate a TanStack Query query by queryHash.",
|
|
479
484
|
inputSchema: {
|
|
@@ -482,7 +487,7 @@ const _ = (e) => {
|
|
|
482
487
|
required: ["queryHash"]
|
|
483
488
|
}
|
|
484
489
|
}),
|
|
485
|
-
resetQuery:
|
|
490
|
+
resetQuery: y({
|
|
486
491
|
name: "reset-query",
|
|
487
492
|
description: "Reset a TanStack Query query by queryHash.",
|
|
488
493
|
inputSchema: {
|
|
@@ -491,7 +496,7 @@ const _ = (e) => {
|
|
|
491
496
|
required: ["queryHash"]
|
|
492
497
|
}
|
|
493
498
|
}),
|
|
494
|
-
removeQuery:
|
|
499
|
+
removeQuery: y({
|
|
495
500
|
name: "remove-query",
|
|
496
501
|
description: "Remove a TanStack Query query from the cache by queryHash.",
|
|
497
502
|
inputSchema: {
|
|
@@ -500,34 +505,48 @@ const _ = (e) => {
|
|
|
500
505
|
required: ["queryHash"]
|
|
501
506
|
}
|
|
502
507
|
}),
|
|
503
|
-
clearQueryCache:
|
|
508
|
+
clearQueryCache: y({
|
|
504
509
|
name: "clear-query-cache",
|
|
505
510
|
description: "Clear the full TanStack Query query cache.",
|
|
506
511
|
inputSchema: q
|
|
507
512
|
}),
|
|
508
|
-
listMutations:
|
|
513
|
+
listMutations: v({
|
|
509
514
|
name: "list-mutations",
|
|
510
515
|
description: "List TanStack Query mutation summaries using cursor pagination.",
|
|
511
516
|
inputSchema: {
|
|
512
517
|
type: "object",
|
|
513
|
-
properties:
|
|
518
|
+
properties: E
|
|
519
|
+
},
|
|
520
|
+
pagination: {
|
|
521
|
+
kind: "cursor",
|
|
522
|
+
fields: [
|
|
523
|
+
"mutationId",
|
|
524
|
+
"mutationKey",
|
|
525
|
+
"status",
|
|
526
|
+
"isPaused",
|
|
527
|
+
"submittedAt",
|
|
528
|
+
"failureCount",
|
|
529
|
+
"hasData",
|
|
530
|
+
"hasError"
|
|
531
|
+
],
|
|
532
|
+
defaultFields: ["mutationId", "mutationKey", "status", "hasError"]
|
|
514
533
|
}
|
|
515
534
|
}),
|
|
516
|
-
getMutationDetails:
|
|
535
|
+
getMutationDetails: y({
|
|
517
536
|
name: "get-mutation-details",
|
|
518
537
|
description: "Return a JSON-safe TanStack Query mutation snapshot for a mutationId.",
|
|
519
538
|
inputSchema: {
|
|
520
539
|
type: "object",
|
|
521
|
-
properties:
|
|
540
|
+
properties: F,
|
|
522
541
|
required: ["mutationId"]
|
|
523
542
|
}
|
|
524
543
|
}),
|
|
525
|
-
clearMutationCache:
|
|
544
|
+
clearMutationCache: y({
|
|
526
545
|
name: "clear-mutation-cache",
|
|
527
546
|
description: "Clear the full TanStack Query mutation cache.",
|
|
528
547
|
inputSchema: q
|
|
529
548
|
})
|
|
530
|
-
},
|
|
549
|
+
}, P = 20, K = 100, $ = (e) => !!e && typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype, o = (e, r = /* @__PURE__ */ new WeakSet()) => {
|
|
531
550
|
if (e == null)
|
|
532
551
|
return null;
|
|
533
552
|
if (typeof e == "string" || typeof e == "boolean")
|
|
@@ -545,10 +564,7 @@ const _ = (e) => {
|
|
|
545
564
|
name: e.name,
|
|
546
565
|
message: e.message,
|
|
547
566
|
stack: e.stack ?? null,
|
|
548
|
-
cause: o(
|
|
549
|
-
e.cause,
|
|
550
|
-
r
|
|
551
|
-
)
|
|
567
|
+
cause: o(e.cause, r)
|
|
552
568
|
};
|
|
553
569
|
if (Array.isArray(e))
|
|
554
570
|
return e.map((t) => o(t, r));
|
|
@@ -570,31 +586,27 @@ const _ = (e) => {
|
|
|
570
586
|
return Object.fromEntries(t);
|
|
571
587
|
}
|
|
572
588
|
return String(e);
|
|
573
|
-
},
|
|
589
|
+
}, x = (e) => typeof e != "number" || !Number.isFinite(e) || !Number.isInteger(e) || e < 1 ? P : Math.min(e, K), z = (e, r, t) => `${e}:${r}:${t}`, W = (e, r, t) => {
|
|
574
590
|
const [a, n, h] = e.split(":", 3);
|
|
575
591
|
if (a !== r || !n || !h)
|
|
576
|
-
throw new Error(
|
|
577
|
-
"Cursor does not match the requested listing. Run the command again."
|
|
578
|
-
);
|
|
592
|
+
throw new Error("Cursor does not match the requested listing. Run the command again.");
|
|
579
593
|
const p = Number(n), s = Number(h);
|
|
580
594
|
if (!Number.isInteger(p) || p !== t)
|
|
581
|
-
throw new Error(
|
|
582
|
-
"Cursor does not match the requested listing. Run the command again."
|
|
583
|
-
);
|
|
595
|
+
throw new Error("Cursor does not match the requested listing. Run the command again.");
|
|
584
596
|
if (!Number.isInteger(s) || s < 0)
|
|
585
597
|
throw new Error("Cursor is invalid. Run the command again.");
|
|
586
598
|
return s;
|
|
587
599
|
}, M = (e, r, t, a) => {
|
|
588
|
-
const n =
|
|
600
|
+
const n = x(a.limit), h = a.cursor ? W(a.cursor, r, t) : 0, p = Math.min(h + n, e.length), s = p < e.length;
|
|
589
601
|
return {
|
|
590
602
|
items: e.slice(h, p),
|
|
591
603
|
page: {
|
|
592
604
|
limit: n,
|
|
593
605
|
hasMore: s,
|
|
594
|
-
...s ? { nextCursor:
|
|
606
|
+
...s ? { nextCursor: z(r, t, p) } : {}
|
|
595
607
|
}
|
|
596
608
|
};
|
|
597
|
-
},
|
|
609
|
+
}, V = (e) => e ? {
|
|
598
610
|
enabled: o(e.enabled),
|
|
599
611
|
networkMode: o(e.networkMode),
|
|
600
612
|
staleTime: o(e.staleTime),
|
|
@@ -611,7 +623,7 @@ const _ = (e) => {
|
|
|
611
623
|
hasSelect: typeof e.select == "function",
|
|
612
624
|
hasPlaceholderData: "placeholderData" in e,
|
|
613
625
|
hasInitialData: "initialData" in e
|
|
614
|
-
} : null,
|
|
626
|
+
} : null, B = (e) => ({
|
|
615
627
|
mutationKey: o(e.mutationKey),
|
|
616
628
|
networkMode: o(e.networkMode),
|
|
617
629
|
gcTime: o(e.gcTime),
|
|
@@ -624,7 +636,7 @@ const _ = (e) => {
|
|
|
624
636
|
hasOnSuccess: typeof e.onSuccess == "function",
|
|
625
637
|
hasOnError: typeof e.onError == "function",
|
|
626
638
|
hasOnSettled: typeof e.onSettled == "function"
|
|
627
|
-
}),
|
|
639
|
+
}), O = (e) => Math.max(e.state.dataUpdatedAt, e.state.errorUpdatedAt), Y = (e, r) => O(r) - O(e) || r.getObserversCount() - e.getObserversCount() || String(r.queryHash).localeCompare(String(e.queryHash)), J = (e, r) => r.state.submittedAt - e.state.submittedAt || r.mutationId - e.mutationId, I = (e) => ({
|
|
628
640
|
queryHash: e.queryHash,
|
|
629
641
|
queryKey: o(e.queryKey),
|
|
630
642
|
status: e.state.status,
|
|
@@ -635,31 +647,27 @@ const _ = (e) => {
|
|
|
635
647
|
errorUpdatedAt: e.state.errorUpdatedAt,
|
|
636
648
|
hasData: e.state.data !== void 0,
|
|
637
649
|
hasError: e.state.error != null
|
|
638
|
-
}),
|
|
650
|
+
}), X = (e) => e.status, T = (e) => ({
|
|
639
651
|
mutationId: e.mutationId,
|
|
640
652
|
mutationKey: o(e.options.mutationKey),
|
|
641
|
-
status:
|
|
653
|
+
status: X(e.state),
|
|
642
654
|
isPaused: e.state.isPaused,
|
|
643
655
|
submittedAt: e.state.submittedAt,
|
|
644
656
|
failureCount: e.state.failureCount,
|
|
645
657
|
hasData: e.state.data !== void 0,
|
|
646
658
|
hasError: e.state.error != null
|
|
647
|
-
}),
|
|
659
|
+
}), Z = (e, r) => {
|
|
648
660
|
const t = e.getQueryCache().get(r);
|
|
649
661
|
if (!t) {
|
|
650
662
|
const a = e.getQueryCache().getAll().map((n) => n.queryHash).join(", ");
|
|
651
|
-
throw new Error(
|
|
652
|
-
`Unknown queryHash "${r}". Available: ${a || "(none)"}`
|
|
653
|
-
);
|
|
663
|
+
throw new Error(`Unknown queryHash "${r}". Available: ${a || "(none)"}`);
|
|
654
664
|
}
|
|
655
665
|
return t;
|
|
656
|
-
},
|
|
666
|
+
}, ee = (e, r) => {
|
|
657
667
|
const t = e.getMutationCache().getAll().find((a) => a.mutationId === r);
|
|
658
668
|
if (!t) {
|
|
659
669
|
const a = e.getMutationCache().getAll().map((n) => n.mutationId).join(", ");
|
|
660
|
-
throw new Error(
|
|
661
|
-
`Unknown mutationId "${r}". Available: ${a || "(none)"}`
|
|
662
|
-
);
|
|
670
|
+
throw new Error(`Unknown mutationId "${r}". Available: ${a || "(none)"}`);
|
|
663
671
|
}
|
|
664
672
|
return t;
|
|
665
673
|
}, Q = (e) => {
|
|
@@ -669,9 +677,7 @@ const _ = (e) => {
|
|
|
669
677
|
queries: {
|
|
670
678
|
total: r.length,
|
|
671
679
|
active: r.filter((a) => a.getObserversCount() > 0).length,
|
|
672
|
-
fetching: r.filter(
|
|
673
|
-
(a) => a.state.fetchStatus === "fetching"
|
|
674
|
-
).length,
|
|
680
|
+
fetching: r.filter((a) => a.state.fetchStatus === "fetching").length,
|
|
675
681
|
pending: r.filter((a) => a.state.status === "pending").length,
|
|
676
682
|
success: r.filter((a) => a.state.status === "success").length,
|
|
677
683
|
error: r.filter((a) => a.state.status === "error").length,
|
|
@@ -679,17 +685,13 @@ const _ = (e) => {
|
|
|
679
685
|
},
|
|
680
686
|
mutations: {
|
|
681
687
|
total: t.length,
|
|
682
|
-
pending: t.filter(
|
|
683
|
-
|
|
684
|
-
).length,
|
|
685
|
-
success: t.filter(
|
|
686
|
-
(a) => a.state.status === "success"
|
|
687
|
-
).length,
|
|
688
|
+
pending: t.filter((a) => a.state.status === "pending").length,
|
|
689
|
+
success: t.filter((a) => a.state.status === "success").length,
|
|
688
690
|
error: t.filter((a) => a.state.status === "error").length,
|
|
689
691
|
paused: t.filter((a) => a.state.isPaused).length
|
|
690
692
|
}
|
|
691
693
|
};
|
|
692
|
-
},
|
|
694
|
+
}, te = (e) => {
|
|
693
695
|
const r = {
|
|
694
696
|
queriesGeneration: 0,
|
|
695
697
|
mutationsGeneration: 0
|
|
@@ -715,29 +717,24 @@ const _ = (e) => {
|
|
|
715
717
|
};
|
|
716
718
|
},
|
|
717
719
|
listQueries(t = {}) {
|
|
718
|
-
const a = [...e.getQueryCache().getAll()].sort(
|
|
720
|
+
const a = [...e.getQueryCache().getAll()].sort(Y);
|
|
719
721
|
return {
|
|
720
722
|
...Q(e),
|
|
721
723
|
total: a.length,
|
|
722
|
-
...M(
|
|
723
|
-
a.map(O),
|
|
724
|
-
"queries",
|
|
725
|
-
r.queriesGeneration,
|
|
726
|
-
t
|
|
727
|
-
)
|
|
724
|
+
...M(a.map(I), "queries", r.queriesGeneration, t)
|
|
728
725
|
};
|
|
729
726
|
},
|
|
730
727
|
getQueryDetails({ queryHash: t }) {
|
|
731
|
-
const a =
|
|
728
|
+
const a = Z(e, t);
|
|
732
729
|
return {
|
|
733
730
|
summary: Q(e),
|
|
734
731
|
query: {
|
|
735
|
-
...
|
|
732
|
+
...I(a),
|
|
736
733
|
data: o(a.state.data),
|
|
737
734
|
error: o(a.state.error),
|
|
738
735
|
observers: a.observers.map((n) => ({
|
|
739
736
|
queryHash: a.queryHash,
|
|
740
|
-
options:
|
|
737
|
+
options: V(
|
|
741
738
|
n.options
|
|
742
739
|
)
|
|
743
740
|
}))
|
|
@@ -786,9 +783,7 @@ const _ = (e) => {
|
|
|
786
783
|
});
|
|
787
784
|
},
|
|
788
785
|
listMutations(t = {}) {
|
|
789
|
-
const a = [...e.getMutationCache().getAll()].sort(
|
|
790
|
-
Y
|
|
791
|
-
);
|
|
786
|
+
const a = [...e.getMutationCache().getAll()].sort(J);
|
|
792
787
|
return {
|
|
793
788
|
...Q(e),
|
|
794
789
|
total: a.length,
|
|
@@ -801,7 +796,7 @@ const _ = (e) => {
|
|
|
801
796
|
};
|
|
802
797
|
},
|
|
803
798
|
getMutationDetails({ mutationId: t }) {
|
|
804
|
-
const a =
|
|
799
|
+
const a = ee(e, t);
|
|
805
800
|
return {
|
|
806
801
|
summary: Q(e),
|
|
807
802
|
mutation: {
|
|
@@ -811,7 +806,7 @@ const _ = (e) => {
|
|
|
811
806
|
error: o(a.state.error),
|
|
812
807
|
context: o(a.state.context),
|
|
813
808
|
failureReason: o(a.state.failureReason),
|
|
814
|
-
options:
|
|
809
|
+
options: B(a.options)
|
|
815
810
|
}
|
|
816
811
|
};
|
|
817
812
|
},
|
|
@@ -821,83 +816,80 @@ const _ = (e) => {
|
|
|
821
816
|
});
|
|
822
817
|
}
|
|
823
818
|
};
|
|
824
|
-
},
|
|
825
|
-
const r =
|
|
826
|
-
() => ee(e),
|
|
827
|
-
[e]
|
|
828
|
-
);
|
|
819
|
+
}, re = (e) => {
|
|
820
|
+
const r = R(() => te(e), [e]);
|
|
829
821
|
A(() => {
|
|
830
822
|
const t = e.getQueryCache().subscribe((n) => r.handleQueryCacheEvent(n)), a = e.getMutationCache().subscribe((n) => r.handleMutationCacheEvent(n));
|
|
831
823
|
return () => {
|
|
832
824
|
t(), a();
|
|
833
825
|
};
|
|
834
826
|
}, [r, e]), i({
|
|
835
|
-
pluginId:
|
|
836
|
-
tool:
|
|
827
|
+
pluginId: c,
|
|
828
|
+
tool: d.getCacheSummary,
|
|
837
829
|
handler: () => r.getCacheSummary()
|
|
838
830
|
}), i({
|
|
839
|
-
pluginId:
|
|
840
|
-
tool:
|
|
831
|
+
pluginId: c,
|
|
832
|
+
tool: d.getOnlineStatus,
|
|
841
833
|
handler: () => r.getOnlineStatus()
|
|
842
834
|
}), i({
|
|
843
|
-
pluginId:
|
|
844
|
-
tool:
|
|
835
|
+
pluginId: c,
|
|
836
|
+
tool: d.setOnlineStatus,
|
|
845
837
|
handler: (t) => r.setOnlineStatus(t)
|
|
846
838
|
}), i({
|
|
847
|
-
pluginId:
|
|
848
|
-
tool:
|
|
839
|
+
pluginId: c,
|
|
840
|
+
tool: d.listQueries,
|
|
849
841
|
handler: (t = {}) => r.listQueries(t)
|
|
850
842
|
}), i({
|
|
851
|
-
pluginId:
|
|
852
|
-
tool:
|
|
843
|
+
pluginId: c,
|
|
844
|
+
tool: d.getQueryDetails,
|
|
853
845
|
handler: (t) => r.getQueryDetails(t)
|
|
854
846
|
}), i({
|
|
855
|
-
pluginId:
|
|
856
|
-
tool:
|
|
847
|
+
pluginId: c,
|
|
848
|
+
tool: d.refetchQuery,
|
|
857
849
|
handler: (t) => r.refetchQuery(t)
|
|
858
850
|
}), i({
|
|
859
|
-
pluginId:
|
|
860
|
-
tool:
|
|
851
|
+
pluginId: c,
|
|
852
|
+
tool: d.setQueryLoading,
|
|
861
853
|
handler: (t) => r.setQueryLoading(t)
|
|
862
854
|
}), i({
|
|
863
|
-
pluginId:
|
|
864
|
-
tool:
|
|
855
|
+
pluginId: c,
|
|
856
|
+
tool: d.setQueryError,
|
|
865
857
|
handler: (t) => r.setQueryError(t)
|
|
866
858
|
}), i({
|
|
867
|
-
pluginId:
|
|
868
|
-
tool:
|
|
859
|
+
pluginId: c,
|
|
860
|
+
tool: d.invalidateQuery,
|
|
869
861
|
handler: (t) => r.invalidateQuery(t)
|
|
870
862
|
}), i({
|
|
871
|
-
pluginId:
|
|
872
|
-
tool:
|
|
863
|
+
pluginId: c,
|
|
864
|
+
tool: d.resetQuery,
|
|
873
865
|
handler: (t) => r.resetQuery(t)
|
|
874
866
|
}), i({
|
|
875
|
-
pluginId:
|
|
876
|
-
tool:
|
|
867
|
+
pluginId: c,
|
|
868
|
+
tool: d.removeQuery,
|
|
877
869
|
handler: (t) => r.removeQuery(t)
|
|
878
870
|
}), i({
|
|
879
|
-
pluginId:
|
|
880
|
-
tool:
|
|
871
|
+
pluginId: c,
|
|
872
|
+
tool: d.clearQueryCache,
|
|
881
873
|
handler: () => r.clearQueryCache()
|
|
882
874
|
}), i({
|
|
883
|
-
pluginId:
|
|
884
|
-
tool:
|
|
875
|
+
pluginId: c,
|
|
876
|
+
tool: d.listMutations,
|
|
885
877
|
handler: (t = {}) => r.listMutations(t)
|
|
886
878
|
}), i({
|
|
887
|
-
pluginId:
|
|
888
|
-
tool:
|
|
879
|
+
pluginId: c,
|
|
880
|
+
tool: d.getMutationDetails,
|
|
889
881
|
handler: (t) => r.getMutationDetails(t)
|
|
890
882
|
}), i({
|
|
891
|
-
pluginId:
|
|
892
|
-
tool:
|
|
883
|
+
pluginId: c,
|
|
884
|
+
tool: d.clearMutationCache,
|
|
893
885
|
handler: () => r.clearMutationCache()
|
|
894
886
|
});
|
|
895
|
-
},
|
|
896
|
-
const r =
|
|
887
|
+
}, ce = (e) => {
|
|
888
|
+
const r = w({
|
|
897
889
|
pluginId: "@rozenite/tanstack-query-plugin"
|
|
898
890
|
});
|
|
899
|
-
_(r),
|
|
891
|
+
_(r), G(e, r), N(e, r), L(e, r), re(e);
|
|
900
892
|
};
|
|
901
893
|
export {
|
|
902
|
-
|
|
894
|
+
ce as useTanStackQueryDevTools
|
|
903
895
|
};
|
package/dist/rozenite.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@rozenite/tanstack-query-plugin","version":"1.
|
|
1
|
+
{"name":"@rozenite/tanstack-query-plugin","version":"2.1.0","description":"TanStack Query for Rozenite.","panels":[{"name":"Tanstack Query","source":"/devtools/tanstack-query.html"}]}
|