@rozenite/tanstack-query-plugin 1.7.0 → 1.8.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.
@@ -1,32 +1,33 @@
1
- import { useRozeniteDevToolsClient as R } from "@rozenite/plugin-bridge";
2
- import { useEffect as S, useRef as k, useMemo as E } from "react";
3
- import { onlineManager as g } from "@tanstack/react-query";
4
- import D from "fast-deep-equal";
5
- import { useRozenitePluginAgentTool as c } from "@rozenite/agent-bridge";
6
- const w = (e) => {
7
- S(() => {
1
+ import { useRozeniteDevToolsClient as D } from "@rozenite/plugin-bridge";
2
+ import { useEffect as A, useRef as w, useMemo as I } from "react";
3
+ import { onlineManager as S } from "@tanstack/react-query";
4
+ import C from "fast-deep-equal";
5
+ import { useRozenitePluginAgentTool as i } from "@rozenite/agent-bridge";
6
+ import { defineAgentToolContract as c } from "@rozenite/agent-shared";
7
+ const _ = (e) => {
8
+ A(() => {
8
9
  if (!e)
9
10
  return;
10
- const r = g.subscribe((a) => {
11
+ const r = S.subscribe((a) => {
11
12
  e.send("online-status-changed", { online: a });
12
13
  }), t = e.onMessage(
13
14
  "online-status-changed",
14
15
  ({ online: a }) => {
15
- g.setOnline(a);
16
+ S.setOnline(a);
16
17
  }
17
18
  );
18
19
  return () => {
19
20
  r(), t.remove();
20
21
  };
21
22
  }, [e]);
22
- }, p = (e, r) => {
23
+ }, m = (e, r) => {
23
24
  if (!r)
24
25
  throw new Error("queryHash is required for this TanStack Query action.");
25
26
  const t = e.getQueryCache().get(r);
26
27
  if (!t)
27
28
  throw new Error(`No active query found for hash: ${r}`);
28
29
  return t;
29
- }, l = async (e, r) => {
30
+ }, f = async (e, r) => {
30
31
  switch (r.type) {
31
32
  case "CLEAR_QUERY_CACHE": {
32
33
  const t = e.getQueryCache().getAll().length;
@@ -49,7 +50,7 @@ const w = (e) => {
49
50
  };
50
51
  }
51
52
  case "SET_QUERY_DATA": {
52
- const t = p(e, r.queryHash);
53
+ const t = m(e, r.queryHash);
53
54
  return e.setQueryData(t.queryKey, r.metadata?.data), {
54
55
  applied: !0,
55
56
  action: r.type,
@@ -57,7 +58,7 @@ const w = (e) => {
57
58
  };
58
59
  }
59
60
  case "TRIGGER_ERROR": {
60
- const t = p(e, r.queryHash), a = t.options, n = new Error("Unknown error from devtools");
61
+ const t = m(e, r.queryHash), a = t.options, n = new Error("Unknown error from devtools");
61
62
  return t.setState({
62
63
  status: "error",
63
64
  error: n,
@@ -73,7 +74,7 @@ const w = (e) => {
73
74
  };
74
75
  }
75
76
  case "RESTORE_ERROR": {
76
- const t = p(e, r.queryHash);
77
+ const t = m(e, r.queryHash);
77
78
  return await e.resetQueries(t), {
78
79
  applied: !0,
79
80
  action: r.type,
@@ -81,7 +82,7 @@ const w = (e) => {
81
82
  };
82
83
  }
83
84
  case "TRIGGER_LOADING": {
84
- const t = p(e, r.queryHash), a = t.options;
85
+ const t = m(e, r.queryHash), a = t.options;
85
86
  return t.fetch({
86
87
  ...a,
87
88
  queryFn: () => new Promise(() => {
@@ -102,7 +103,7 @@ const w = (e) => {
102
103
  };
103
104
  }
104
105
  case "RESTORE_LOADING": {
105
- const t = p(e, r.queryHash), a = t.state, n = t.state.fetchMeta ? t.state.fetchMeta.__previousQueryOptions : null;
106
+ const t = m(e, r.queryHash), a = t.state, n = t.state.fetchMeta ? t.state.fetchMeta.__previousQueryOptions : null;
106
107
  return t.cancel({ silent: !0 }), t.setState({
107
108
  ...a,
108
109
  fetchStatus: "idle",
@@ -114,7 +115,7 @@ const w = (e) => {
114
115
  };
115
116
  }
116
117
  case "RESET": {
117
- const t = p(e, r.queryHash);
118
+ const t = m(e, r.queryHash);
118
119
  return await e.resetQueries(t), {
119
120
  applied: !0,
120
121
  action: r.type,
@@ -122,7 +123,7 @@ const w = (e) => {
122
123
  };
123
124
  }
124
125
  case "REMOVE": {
125
- const t = p(e, r.queryHash);
126
+ const t = m(e, r.queryHash);
126
127
  return e.removeQueries(t), {
127
128
  applied: !0,
128
129
  action: r.type,
@@ -130,7 +131,7 @@ const w = (e) => {
130
131
  };
131
132
  }
132
133
  case "REFETCH": {
133
- const t = p(e, r.queryHash);
134
+ const t = m(e, r.queryHash);
134
135
  return await t.fetch().catch(() => {
135
136
  }), {
136
137
  applied: !0,
@@ -139,7 +140,7 @@ const w = (e) => {
139
140
  };
140
141
  }
141
142
  case "INVALIDATE": {
142
- const t = p(e, r.queryHash);
143
+ const t = m(e, r.queryHash);
143
144
  return await e.invalidateQueries(t), {
144
145
  applied: !0,
145
146
  action: r.type,
@@ -147,19 +148,19 @@ const w = (e) => {
147
148
  };
148
149
  }
149
150
  }
150
- }, _ = (e, r) => {
151
- S(() => {
151
+ }, U = (e, r) => {
152
+ A(() => {
152
153
  if (!r)
153
154
  return;
154
155
  const t = r.onMessage(
155
156
  "devtools-action",
156
- ({ type: a, queryHash: n, metadata: d }) => {
157
- l(e, {
157
+ ({ type: a, queryHash: n, metadata: h }) => {
158
+ f(e, {
158
159
  type: a,
159
160
  queryHash: n,
160
- metadata: d
161
- }).catch((y) => {
162
- const s = y instanceof Error ? y.message : String(y);
161
+ metadata: h
162
+ }).catch((p) => {
163
+ const s = p instanceof Error ? p.message : String(p);
163
164
  console.warn(
164
165
  `[Rozenite, tanstack-query-plugin] Failed to apply devtools action "${a}": ${s}`
165
166
  );
@@ -170,41 +171,41 @@ const w = (e) => {
170
171
  t.remove();
171
172
  };
172
173
  }, [r]);
173
- }, M = (e) => e.observers.map((r) => ({
174
+ }, R = (e) => e.observers.map((r) => ({
174
175
  queryHash: e.queryHash,
175
176
  options: r.options
176
- })), q = (e) => {
177
- const r = M(e);
177
+ })), H = (e) => {
178
+ const r = R(e);
178
179
  return {
179
180
  state: e.state,
180
181
  queryKey: e.queryKey,
181
182
  queryHash: e.queryHash,
182
183
  observers: r
183
184
  };
184
- }, O = (e) => ({
185
+ }, k = (e) => ({
185
186
  mutationId: e.mutationId,
186
187
  state: e.state,
187
188
  options: e.options
188
- }), U = (e) => ({
189
- queries: e.getQueryCache().getAll().map(q),
190
- mutations: e.getMutationCache().getAll().map(O)
191
- }), C = (e, r) => {
192
- const t = k(
189
+ }), G = (e) => ({
190
+ queries: e.getQueryCache().getAll().map(H),
191
+ mutations: e.getMutationCache().getAll().map(k)
192
+ }), j = (e, r) => {
193
+ const t = w(
193
194
  /* @__PURE__ */ new Map()
194
- ), a = E(() => (n) => {
195
+ ), a = I(() => (n) => {
195
196
  if (!r || n.type === "observerResultsUpdated")
196
197
  return;
197
198
  if ("query" in n) {
198
- const { query: s, type: h } = n;
199
- if (h === "added" || h === "removed") {
200
- h === "removed" && t.current.delete(s.queryHash);
201
- const m = q(s);
202
- r.send("sync-query-event", { type: h, data: m });
199
+ const { query: s, type: l } = n;
200
+ if (l === "added" || l === "removed") {
201
+ l === "removed" && t.current.delete(s.queryHash);
202
+ const g = H(s);
203
+ r.send("sync-query-event", { type: l, data: g });
203
204
  return;
204
205
  }
205
- if (h === "updated" && "action" in n) {
206
- const m = n.action;
207
- switch (m.type) {
206
+ if (l === "updated" && "action" in n) {
207
+ const g = n.action;
208
+ switch (g.type) {
208
209
  case "fetch": {
209
210
  const u = {
210
211
  queryHash: s.queryHash,
@@ -262,7 +263,7 @@ const w = (e) => {
262
263
  case "setState": {
263
264
  const u = {
264
265
  queryHash: s.queryHash,
265
- state: m.state
266
+ state: g.state
266
267
  // Only the changed state parts
267
268
  };
268
269
  r.send("sync-query-event", {
@@ -315,61 +316,218 @@ const w = (e) => {
315
316
  break;
316
317
  }
317
318
  default: {
318
- const u = q(s);
319
- r.send("sync-query-event", { type: h, data: u });
319
+ const u = H(s);
320
+ r.send("sync-query-event", { type: l, data: u });
320
321
  }
321
322
  }
322
323
  return;
323
324
  }
324
- if (h === "observerAdded" || h === "observerRemoved" || h === "observerOptionsUpdated") {
325
- const m = M(s), u = t.current.get(
325
+ if (l === "observerAdded" || l === "observerRemoved" || l === "observerOptionsUpdated") {
326
+ const g = R(s), u = t.current.get(
326
327
  s.queryHash
327
328
  );
328
- if (h === "observerOptionsUpdated" && u && D(u, m))
329
+ if (l === "observerOptionsUpdated" && u && C(u, g))
329
330
  return;
330
331
  t.current.set(
331
332
  s.queryHash,
332
- m
333
+ g
333
334
  ), r.send("sync-query-event", {
334
- type: h,
335
+ type: l,
335
336
  data: {
336
337
  queryHash: s.queryHash,
337
- observers: m
338
+ observers: g
338
339
  }
339
340
  });
340
341
  return;
341
342
  }
342
343
  }
343
- const { mutation: d, type: y } = n;
344
- if (d) {
345
- const s = O(d);
344
+ const { mutation: h, type: p } = n;
345
+ if (h) {
346
+ const s = k(h);
346
347
  r.send("sync-mutation-event", {
347
- type: y,
348
+ type: p,
348
349
  data: s
349
350
  });
350
351
  }
351
352
  }, [r]);
352
- S(() => {
353
+ A(() => {
353
354
  if (!r)
354
355
  return;
355
- const n = e.getMutationCache().subscribe(a), d = e.getQueryCache().subscribe(a);
356
+ const n = e.getMutationCache().subscribe(a), h = e.getQueryCache().subscribe(a);
356
357
  return () => {
357
- n(), d();
358
+ n(), h();
358
359
  };
359
360
  }, [r, e, a]);
360
- }, G = (e, r) => {
361
- S(() => {
361
+ }, N = (e, r) => {
362
+ A(() => {
362
363
  if (!r)
363
364
  return;
364
365
  const t = r.onMessage("request-initial-data", () => {
365
- const a = U(e);
366
+ const a = G(e);
366
367
  r.send("sync-data", { data: a });
367
368
  });
368
369
  return () => {
369
370
  t.remove();
370
371
  };
371
372
  }, [r, e]);
372
- }, j = "@rozenite/tanstack-query-plugin", N = 20, L = 100, F = (e) => !!e && typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype, o = (e, r = /* @__PURE__ */ new WeakSet()) => {
373
+ }, d = "@rozenite/tanstack-query-plugin", b = {
374
+ queryHash: {
375
+ type: "string",
376
+ description: "TanStack Query queryHash identifying the query."
377
+ }
378
+ }, L = {
379
+ mutationId: {
380
+ type: "number",
381
+ description: "TanStack Query mutationId identifying the mutation."
382
+ }
383
+ }, v = {
384
+ limit: {
385
+ type: "number",
386
+ description: "Maximum number of items to return. Defaults to 20. Maximum 100."
387
+ },
388
+ cursor: {
389
+ type: "string",
390
+ description: "Opaque pagination cursor from a previous list call."
391
+ }
392
+ }, q = {
393
+ type: "object",
394
+ properties: {}
395
+ }, y = {
396
+ getCacheSummary: c({
397
+ name: "get-cache-summary",
398
+ description: "Return aggregate TanStack Query cache health and count information.",
399
+ inputSchema: q
400
+ }),
401
+ getOnlineStatus: c({
402
+ name: "get-online-status",
403
+ description: "Return the current TanStack Query onlineManager status.",
404
+ inputSchema: q
405
+ }),
406
+ setOnlineStatus: c({
407
+ name: "set-online-status",
408
+ description: "Set the TanStack Query onlineManager status for testing offline/online behavior.",
409
+ inputSchema: {
410
+ type: "object",
411
+ properties: {
412
+ online: {
413
+ type: "boolean",
414
+ description: "Whether the TanStack Query onlineManager should be online."
415
+ }
416
+ },
417
+ required: ["online"]
418
+ }
419
+ }),
420
+ listQueries: c({
421
+ name: "list-queries",
422
+ description: "List TanStack Query query summaries using cursor pagination.",
423
+ inputSchema: {
424
+ type: "object",
425
+ properties: v
426
+ }
427
+ }),
428
+ getQueryDetails: c({
429
+ name: "get-query-details",
430
+ description: "Return a JSON-safe TanStack Query query snapshot and observer summary.",
431
+ inputSchema: {
432
+ type: "object",
433
+ properties: b,
434
+ required: ["queryHash"]
435
+ }
436
+ }),
437
+ refetchQuery: c({
438
+ name: "refetch-query",
439
+ description: "Refetch a TanStack Query query by queryHash.",
440
+ inputSchema: {
441
+ type: "object",
442
+ properties: b,
443
+ required: ["queryHash"]
444
+ }
445
+ }),
446
+ setQueryLoading: c({
447
+ name: "set-query-loading",
448
+ description: "Enable or disable TanStack Query loading-state simulation for a query by queryHash.",
449
+ inputSchema: {
450
+ type: "object",
451
+ properties: {
452
+ ...b,
453
+ enabled: {
454
+ type: "boolean",
455
+ description: "Whether the loading-state simulation should be enabled."
456
+ }
457
+ },
458
+ required: ["queryHash", "enabled"]
459
+ }
460
+ }),
461
+ setQueryError: c({
462
+ name: "set-query-error",
463
+ description: "Enable or disable TanStack Query error-state simulation for a query by queryHash.",
464
+ inputSchema: {
465
+ type: "object",
466
+ properties: {
467
+ ...b,
468
+ enabled: {
469
+ type: "boolean",
470
+ description: "Whether the error-state simulation should be enabled."
471
+ }
472
+ },
473
+ required: ["queryHash", "enabled"]
474
+ }
475
+ }),
476
+ invalidateQuery: c({
477
+ name: "invalidate-query",
478
+ description: "Invalidate a TanStack Query query by queryHash.",
479
+ inputSchema: {
480
+ type: "object",
481
+ properties: b,
482
+ required: ["queryHash"]
483
+ }
484
+ }),
485
+ resetQuery: c({
486
+ name: "reset-query",
487
+ description: "Reset a TanStack Query query by queryHash.",
488
+ inputSchema: {
489
+ type: "object",
490
+ properties: b,
491
+ required: ["queryHash"]
492
+ }
493
+ }),
494
+ removeQuery: c({
495
+ name: "remove-query",
496
+ description: "Remove a TanStack Query query from the cache by queryHash.",
497
+ inputSchema: {
498
+ type: "object",
499
+ properties: b,
500
+ required: ["queryHash"]
501
+ }
502
+ }),
503
+ clearQueryCache: c({
504
+ name: "clear-query-cache",
505
+ description: "Clear the full TanStack Query query cache.",
506
+ inputSchema: q
507
+ }),
508
+ listMutations: c({
509
+ name: "list-mutations",
510
+ description: "List TanStack Query mutation summaries using cursor pagination.",
511
+ inputSchema: {
512
+ type: "object",
513
+ properties: v
514
+ }
515
+ }),
516
+ getMutationDetails: c({
517
+ name: "get-mutation-details",
518
+ description: "Return a JSON-safe TanStack Query mutation snapshot for a mutationId.",
519
+ inputSchema: {
520
+ type: "object",
521
+ properties: L,
522
+ required: ["mutationId"]
523
+ }
524
+ }),
525
+ clearMutationCache: c({
526
+ name: "clear-mutation-cache",
527
+ description: "Clear the full TanStack Query mutation cache.",
528
+ inputSchema: q
529
+ })
530
+ }, F = 20, P = 100, $ = (e) => !!e && typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype, o = (e, r = /* @__PURE__ */ new WeakSet()) => {
373
531
  if (e == null)
374
532
  return null;
375
533
  if (typeof e == "string" || typeof e == "boolean")
@@ -403,7 +561,7 @@ const w = (e) => {
403
561
  if (typeof e == "object") {
404
562
  if (r.has(e))
405
563
  return "[circular]";
406
- if (r.add(e), !F(e))
564
+ if (r.add(e), !$(e))
407
565
  return `[non-serializable:${e.constructor?.name ?? "Object"}]`;
408
566
  const t = Object.entries(e).map(([a, n]) => [
409
567
  a,
@@ -412,160 +570,31 @@ const w = (e) => {
412
570
  return Object.fromEntries(t);
413
571
  }
414
572
  return String(e);
415
- }, P = (e) => typeof e != "number" || !Number.isFinite(e) || !Number.isInteger(e) || e < 1 ? N : Math.min(e, L), $ = (e, r, t) => `${e}:${r}:${t}`, K = (e, r, t) => {
416
- const [a, n, d] = e.split(":", 3);
417
- if (a !== r || !n || !d)
573
+ }, K = (e) => typeof e != "number" || !Number.isFinite(e) || !Number.isInteger(e) || e < 1 ? F : Math.min(e, P), x = (e, r, t) => `${e}:${r}:${t}`, z = (e, r, t) => {
574
+ const [a, n, h] = e.split(":", 3);
575
+ if (a !== r || !n || !h)
418
576
  throw new Error(
419
577
  "Cursor does not match the requested listing. Run the command again."
420
578
  );
421
- const y = Number(n), s = Number(d);
422
- if (!Number.isInteger(y) || y !== t)
579
+ const p = Number(n), s = Number(h);
580
+ if (!Number.isInteger(p) || p !== t)
423
581
  throw new Error(
424
582
  "Cursor does not match the requested listing. Run the command again."
425
583
  );
426
584
  if (!Number.isInteger(s) || s < 0)
427
585
  throw new Error("Cursor is invalid. Run the command again.");
428
586
  return s;
429
- }, A = (e, r, t, a) => {
430
- const n = P(a.limit), d = a.cursor ? K(a.cursor, r, t) : 0, y = Math.min(d + n, e.length), s = y < e.length;
587
+ }, M = (e, r, t, a) => {
588
+ const n = K(a.limit), h = a.cursor ? z(a.cursor, r, t) : 0, p = Math.min(h + n, e.length), s = p < e.length;
431
589
  return {
432
- items: e.slice(d, y),
590
+ items: e.slice(h, p),
433
591
  page: {
434
592
  limit: n,
435
593
  hasMore: s,
436
- ...s ? { nextCursor: $(r, t, y) } : {}
594
+ ...s ? { nextCursor: x(r, t, p) } : {}
437
595
  }
438
596
  };
439
- }, f = {
440
- queryHash: {
441
- type: "string",
442
- description: "TanStack Query queryHash identifying the query."
443
- }
444
- }, x = {
445
- mutationId: {
446
- type: "number",
447
- description: "TanStack Query mutationId identifying the mutation."
448
- }
449
- }, I = {
450
- limit: {
451
- type: "number",
452
- description: "Maximum number of items to return. Defaults to 20. Maximum 100."
453
- },
454
- cursor: {
455
- type: "string",
456
- description: "Opaque pagination cursor from a previous list call."
457
- }
458
- }, Q = {
459
- type: "object",
460
- properties: {}
461
- }, z = {
462
- name: "get-cache-summary",
463
- description: "Return aggregate TanStack Query cache health and count information.",
464
- inputSchema: Q
465
- }, V = {
466
- name: "get-online-status",
467
- description: "Return the current TanStack Query onlineManager status.",
468
- inputSchema: Q
469
- }, B = {
470
- name: "set-online-status",
471
- description: "Set the TanStack Query onlineManager status for testing offline/online behavior.",
472
- inputSchema: {
473
- type: "object",
474
- properties: {
475
- online: {
476
- type: "boolean",
477
- description: "Whether the TanStack Query onlineManager should be online."
478
- }
479
- },
480
- required: ["online"]
481
- }
482
- }, W = {
483
- name: "list-queries",
484
- description: "List TanStack Query query summaries using cursor pagination.",
485
- inputSchema: {
486
- type: "object",
487
- properties: I
488
- }
489
- }, Y = {
490
- name: "get-query-details",
491
- description: "Return a JSON-safe TanStack Query query snapshot and observer summary.",
492
- inputSchema: {
493
- type: "object",
494
- properties: f,
495
- required: ["queryHash"]
496
- }
497
- }, J = {
498
- name: "refetch-query",
499
- description: "Refetch a TanStack Query query by queryHash.",
500
- inputSchema: {
501
- type: "object",
502
- properties: f,
503
- required: ["queryHash"]
504
- }
505
- }, X = {
506
- name: "set-query-loading",
507
- description: "Enable or disable TanStack Query loading-state simulation for a query by queryHash.",
508
- inputSchema: {
509
- type: "object",
510
- properties: f,
511
- required: ["queryHash", "enabled"]
512
- }
513
- }, Z = {
514
- name: "set-query-error",
515
- description: "Enable or disable TanStack Query error-state simulation for a query by queryHash.",
516
- inputSchema: {
517
- type: "object",
518
- properties: f,
519
- required: ["queryHash", "enabled"]
520
- }
521
- }, ee = {
522
- name: "invalidate-query",
523
- description: "Invalidate a TanStack Query query by queryHash.",
524
- inputSchema: {
525
- type: "object",
526
- properties: f,
527
- required: ["queryHash"]
528
- }
529
- }, te = {
530
- name: "reset-query",
531
- description: "Reset a TanStack Query query by queryHash.",
532
- inputSchema: {
533
- type: "object",
534
- properties: f,
535
- required: ["queryHash"]
536
- }
537
- }, re = {
538
- name: "remove-query",
539
- description: "Remove a TanStack Query query from the cache by queryHash.",
540
- inputSchema: {
541
- type: "object",
542
- properties: f,
543
- required: ["queryHash"]
544
- }
545
- }, ae = {
546
- name: "clear-query-cache",
547
- description: "Clear the full TanStack Query query cache.",
548
- inputSchema: Q
549
- }, se = {
550
- name: "list-mutations",
551
- description: "List TanStack Query mutation summaries using cursor pagination.",
552
- inputSchema: {
553
- type: "object",
554
- properties: I
555
- }
556
- }, ne = {
557
- name: "get-mutation-details",
558
- description: "Return a JSON-safe TanStack Query mutation snapshot for a mutationId.",
559
- inputSchema: {
560
- type: "object",
561
- properties: x,
562
- required: ["mutationId"]
563
- }
564
- }, oe = {
565
- name: "clear-mutation-cache",
566
- description: "Clear the full TanStack Query mutation cache.",
567
- inputSchema: Q
568
- }, ue = (e) => e ? {
597
+ }, W = (e) => e ? {
569
598
  enabled: o(e.enabled),
570
599
  networkMode: o(e.networkMode),
571
600
  staleTime: o(e.staleTime),
@@ -582,7 +611,7 @@ const w = (e) => {
582
611
  hasSelect: typeof e.select == "function",
583
612
  hasPlaceholderData: "placeholderData" in e,
584
613
  hasInitialData: "initialData" in e
585
- } : null, ce = (e) => ({
614
+ } : null, V = (e) => ({
586
615
  mutationKey: o(e.mutationKey),
587
616
  networkMode: o(e.networkMode),
588
617
  gcTime: o(e.gcTime),
@@ -595,7 +624,7 @@ const w = (e) => {
595
624
  hasOnSuccess: typeof e.onSuccess == "function",
596
625
  hasOnError: typeof e.onError == "function",
597
626
  hasOnSettled: typeof e.onSettled == "function"
598
- }), H = (e) => Math.max(e.state.dataUpdatedAt, e.state.errorUpdatedAt), ie = (e, r) => H(r) - H(e) || r.getObserversCount() - e.getObserversCount() || String(r.queryHash).localeCompare(String(e.queryHash)), de = (e, r) => r.state.submittedAt - e.state.submittedAt || r.mutationId - e.mutationId, T = (e) => ({
627
+ }), E = (e) => Math.max(e.state.dataUpdatedAt, e.state.errorUpdatedAt), B = (e, r) => E(r) - E(e) || r.getObserversCount() - e.getObserversCount() || String(r.queryHash).localeCompare(String(e.queryHash)), Y = (e, r) => r.state.submittedAt - e.state.submittedAt || r.mutationId - e.mutationId, O = (e) => ({
599
628
  queryHash: e.queryHash,
600
629
  queryKey: o(e.queryKey),
601
630
  status: e.state.status,
@@ -606,16 +635,16 @@ const w = (e) => {
606
635
  errorUpdatedAt: e.state.errorUpdatedAt,
607
636
  hasData: e.state.data !== void 0,
608
637
  hasError: e.state.error != null
609
- }), ye = (e) => e.status, v = (e) => ({
638
+ }), J = (e) => e.status, T = (e) => ({
610
639
  mutationId: e.mutationId,
611
640
  mutationKey: o(e.options.mutationKey),
612
- status: ye(e.state),
641
+ status: J(e.state),
613
642
  isPaused: e.state.isPaused,
614
643
  submittedAt: e.state.submittedAt,
615
644
  failureCount: e.state.failureCount,
616
645
  hasData: e.state.data !== void 0,
617
646
  hasError: e.state.error != null
618
- }), he = (e, r) => {
647
+ }), X = (e, r) => {
619
648
  const t = e.getQueryCache().get(r);
620
649
  if (!t) {
621
650
  const a = e.getQueryCache().getAll().map((n) => n.queryHash).join(", ");
@@ -624,7 +653,7 @@ const w = (e) => {
624
653
  );
625
654
  }
626
655
  return t;
627
- }, pe = (e, r) => {
656
+ }, Z = (e, r) => {
628
657
  const t = e.getMutationCache().getAll().find((a) => a.mutationId === r);
629
658
  if (!t) {
630
659
  const a = e.getMutationCache().getAll().map((n) => n.mutationId).join(", ");
@@ -633,10 +662,10 @@ const w = (e) => {
633
662
  );
634
663
  }
635
664
  return t;
636
- }, b = (e) => {
665
+ }, Q = (e) => {
637
666
  const r = e.getQueryCache().getAll(), t = e.getMutationCache().getAll();
638
667
  return {
639
- online: g.isOnline(),
668
+ online: S.isOnline(),
640
669
  queries: {
641
670
  total: r.length,
642
671
  active: r.filter((a) => a.getObserversCount() > 0).length,
@@ -660,7 +689,7 @@ const w = (e) => {
660
689
  paused: t.filter((a) => a.state.isPaused).length
661
690
  }
662
691
  };
663
- }, le = (e) => {
692
+ }, ee = (e) => {
664
693
  const r = {
665
694
  queriesGeneration: 0,
666
695
  mutationsGeneration: 0
@@ -673,25 +702,25 @@ const w = (e) => {
673
702
  (t.type === "added" || t.type === "removed") && (r.mutationsGeneration += 1);
674
703
  },
675
704
  getCacheSummary() {
676
- return b(e);
705
+ return Q(e);
677
706
  },
678
707
  getOnlineStatus() {
679
708
  return {
680
- online: g.isOnline()
709
+ online: S.isOnline()
681
710
  };
682
711
  },
683
712
  setOnlineStatus({ online: t }) {
684
- return g.setOnline(t), {
685
- online: g.isOnline()
713
+ return S.setOnline(t), {
714
+ online: S.isOnline()
686
715
  };
687
716
  },
688
717
  listQueries(t = {}) {
689
- const a = [...e.getQueryCache().getAll()].sort(ie);
718
+ const a = [...e.getQueryCache().getAll()].sort(B);
690
719
  return {
691
- ...b(e),
720
+ ...Q(e),
692
721
  total: a.length,
693
- ...A(
694
- a.map(T),
722
+ ...M(
723
+ a.map(O),
695
724
  "queries",
696
725
  r.queriesGeneration,
697
726
  t
@@ -699,16 +728,16 @@ const w = (e) => {
699
728
  };
700
729
  },
701
730
  getQueryDetails({ queryHash: t }) {
702
- const a = he(e, t);
731
+ const a = X(e, t);
703
732
  return {
704
- summary: b(e),
733
+ summary: Q(e),
705
734
  query: {
706
- ...T(a),
735
+ ...O(a),
707
736
  data: o(a.state.data),
708
737
  error: o(a.state.error),
709
738
  observers: a.observers.map((n) => ({
710
739
  queryHash: a.queryHash,
711
- options: ue(
740
+ options: W(
712
741
  n.options
713
742
  )
714
743
  }))
@@ -716,55 +745,55 @@ const w = (e) => {
716
745
  };
717
746
  },
718
747
  async refetchQuery({ queryHash: t }) {
719
- return l(e, {
748
+ return f(e, {
720
749
  type: "REFETCH",
721
750
  queryHash: t
722
751
  });
723
752
  },
724
753
  async setQueryLoading({ queryHash: t, enabled: a }) {
725
- return l(e, {
754
+ return f(e, {
726
755
  type: a ? "TRIGGER_LOADING" : "RESTORE_LOADING",
727
756
  queryHash: t
728
757
  });
729
758
  },
730
759
  async setQueryError({ queryHash: t, enabled: a }) {
731
- return l(e, {
760
+ return f(e, {
732
761
  type: a ? "TRIGGER_ERROR" : "RESTORE_ERROR",
733
762
  queryHash: t
734
763
  });
735
764
  },
736
765
  async invalidateQuery({ queryHash: t }) {
737
- return l(e, {
766
+ return f(e, {
738
767
  type: "INVALIDATE",
739
768
  queryHash: t
740
769
  });
741
770
  },
742
771
  async resetQuery({ queryHash: t }) {
743
- return l(e, {
772
+ return f(e, {
744
773
  type: "RESET",
745
774
  queryHash: t
746
775
  });
747
776
  },
748
777
  async removeQuery({ queryHash: t }) {
749
- return l(e, {
778
+ return f(e, {
750
779
  type: "REMOVE",
751
780
  queryHash: t
752
781
  });
753
782
  },
754
783
  async clearQueryCache() {
755
- return l(e, {
784
+ return f(e, {
756
785
  type: "CLEAR_QUERY_CACHE"
757
786
  });
758
787
  },
759
788
  listMutations(t = {}) {
760
789
  const a = [...e.getMutationCache().getAll()].sort(
761
- de
790
+ Y
762
791
  );
763
792
  return {
764
- ...b(e),
793
+ ...Q(e),
765
794
  total: a.length,
766
- ...A(
767
- a.map(v),
795
+ ...M(
796
+ a.map(T),
768
797
  "mutations",
769
798
  r.mutationsGeneration,
770
799
  t
@@ -772,103 +801,103 @@ const w = (e) => {
772
801
  };
773
802
  },
774
803
  getMutationDetails({ mutationId: t }) {
775
- const a = pe(e, t);
804
+ const a = Z(e, t);
776
805
  return {
777
- summary: b(e),
806
+ summary: Q(e),
778
807
  mutation: {
779
- ...v(a),
808
+ ...T(a),
780
809
  variables: o(a.state.variables),
781
810
  data: o(a.state.data),
782
811
  error: o(a.state.error),
783
812
  context: o(a.state.context),
784
813
  failureReason: o(a.state.failureReason),
785
- options: ce(a.options)
814
+ options: V(a.options)
786
815
  }
787
816
  };
788
817
  },
789
818
  async clearMutationCache() {
790
- return l(e, {
819
+ return f(e, {
791
820
  type: "CLEAR_MUTATION_CACHE"
792
821
  });
793
822
  }
794
823
  };
795
- }, i = j, me = (e) => {
796
- const r = E(
797
- () => le(e),
824
+ }, te = (e) => {
825
+ const r = I(
826
+ () => ee(e),
798
827
  [e]
799
828
  );
800
- S(() => {
829
+ A(() => {
801
830
  const t = e.getQueryCache().subscribe((n) => r.handleQueryCacheEvent(n)), a = e.getMutationCache().subscribe((n) => r.handleMutationCacheEvent(n));
802
831
  return () => {
803
832
  t(), a();
804
833
  };
805
- }, [r, e]), c({
806
- pluginId: i,
807
- tool: z,
834
+ }, [r, e]), i({
835
+ pluginId: d,
836
+ tool: y.getCacheSummary,
808
837
  handler: () => r.getCacheSummary()
809
- }), c({
810
- pluginId: i,
811
- tool: V,
838
+ }), i({
839
+ pluginId: d,
840
+ tool: y.getOnlineStatus,
812
841
  handler: () => r.getOnlineStatus()
813
- }), c({
814
- pluginId: i,
815
- tool: B,
842
+ }), i({
843
+ pluginId: d,
844
+ tool: y.setOnlineStatus,
816
845
  handler: (t) => r.setOnlineStatus(t)
817
- }), c({
818
- pluginId: i,
819
- tool: W,
846
+ }), i({
847
+ pluginId: d,
848
+ tool: y.listQueries,
820
849
  handler: (t = {}) => r.listQueries(t)
821
- }), c({
822
- pluginId: i,
823
- tool: Y,
850
+ }), i({
851
+ pluginId: d,
852
+ tool: y.getQueryDetails,
824
853
  handler: (t) => r.getQueryDetails(t)
825
- }), c({
826
- pluginId: i,
827
- tool: J,
854
+ }), i({
855
+ pluginId: d,
856
+ tool: y.refetchQuery,
828
857
  handler: (t) => r.refetchQuery(t)
829
- }), c({
830
- pluginId: i,
831
- tool: X,
858
+ }), i({
859
+ pluginId: d,
860
+ tool: y.setQueryLoading,
832
861
  handler: (t) => r.setQueryLoading(t)
833
- }), c({
834
- pluginId: i,
835
- tool: Z,
862
+ }), i({
863
+ pluginId: d,
864
+ tool: y.setQueryError,
836
865
  handler: (t) => r.setQueryError(t)
837
- }), c({
838
- pluginId: i,
839
- tool: ee,
866
+ }), i({
867
+ pluginId: d,
868
+ tool: y.invalidateQuery,
840
869
  handler: (t) => r.invalidateQuery(t)
841
- }), c({
842
- pluginId: i,
843
- tool: te,
870
+ }), i({
871
+ pluginId: d,
872
+ tool: y.resetQuery,
844
873
  handler: (t) => r.resetQuery(t)
845
- }), c({
846
- pluginId: i,
847
- tool: re,
874
+ }), i({
875
+ pluginId: d,
876
+ tool: y.removeQuery,
848
877
  handler: (t) => r.removeQuery(t)
849
- }), c({
850
- pluginId: i,
851
- tool: ae,
878
+ }), i({
879
+ pluginId: d,
880
+ tool: y.clearQueryCache,
852
881
  handler: () => r.clearQueryCache()
853
- }), c({
854
- pluginId: i,
855
- tool: se,
882
+ }), i({
883
+ pluginId: d,
884
+ tool: y.listMutations,
856
885
  handler: (t = {}) => r.listMutations(t)
857
- }), c({
858
- pluginId: i,
859
- tool: ne,
886
+ }), i({
887
+ pluginId: d,
888
+ tool: y.getMutationDetails,
860
889
  handler: (t) => r.getMutationDetails(t)
861
- }), c({
862
- pluginId: i,
863
- tool: oe,
890
+ }), i({
891
+ pluginId: d,
892
+ tool: y.clearMutationCache,
864
893
  handler: () => r.clearMutationCache()
865
894
  });
866
- }, qe = (e) => {
867
- const r = R({
895
+ }, ie = (e) => {
896
+ const r = D({
868
897
  pluginId: "@rozenite/tanstack-query-plugin"
869
898
  });
870
- w(r), _(e, r), C(e, r), G(e, r), me(e);
899
+ _(r), U(e, r), j(e, r), N(e, r), te(e);
871
900
  };
872
901
  export {
873
- qe as useTanStackQueryDevTools
902
+ ie as useTanStackQueryDevTools
874
903
  };