@tanstack/lit-query 0.2.11 → 0.2.13

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.
Files changed (143) hide show
  1. package/README.md +17 -0
  2. package/build/legacy/index.cjs +1585 -0
  3. package/build/legacy/index.cjs.map +1 -0
  4. package/build/legacy/index.d.cts +781 -0
  5. package/build/legacy/index.d.cts.map +1 -0
  6. package/build/legacy/index.d.ts +781 -0
  7. package/build/legacy/index.d.ts.map +1 -0
  8. package/build/legacy/index.js +1561 -0
  9. package/build/legacy/index.js.map +1 -0
  10. package/build/modern/index.cjs +1569 -0
  11. package/build/modern/index.cjs.map +1 -0
  12. package/build/modern/index.d.cts +781 -0
  13. package/build/modern/index.d.cts.map +1 -0
  14. package/build/modern/index.d.ts +781 -0
  15. package/build/modern/index.d.ts.map +1 -0
  16. package/build/modern/index.js +1545 -0
  17. package/build/modern/index.js.map +1 -0
  18. package/package.json +27 -30
  19. package/src/createInfiniteQueryController.ts +0 -1
  20. package/src/createMutationController.ts +9 -7
  21. package/src/createQueriesController.ts +0 -2
  22. package/src/createQueryController.ts +0 -1
  23. package/src/infiniteQueryOptions.ts +10 -4
  24. package/dist/QueryClientProvider.d.ts +0 -85
  25. package/dist/QueryClientProvider.d.ts.map +0 -1
  26. package/dist/QueryClientProvider.js +0 -137
  27. package/dist/QueryClientProvider.js.map +0 -1
  28. package/dist/accessor.d.ts +0 -32
  29. package/dist/accessor.d.ts.map +0 -1
  30. package/dist/accessor.js +0 -12
  31. package/dist/accessor.js.map +0 -1
  32. package/dist/context.d.ts +0 -59
  33. package/dist/context.d.ts.map +0 -1
  34. package/dist/context.js +0 -100
  35. package/dist/context.js.map +0 -1
  36. package/dist/controllers/BaseController.d.ts +0 -39
  37. package/dist/controllers/BaseController.d.ts.map +0 -1
  38. package/dist/controllers/BaseController.js +0 -213
  39. package/dist/controllers/BaseController.js.map +0 -1
  40. package/dist/createInfiniteQueryController.d.ts +0 -76
  41. package/dist/createInfiniteQueryController.d.ts.map +0 -1
  42. package/dist/createInfiniteQueryController.js +0 -248
  43. package/dist/createInfiniteQueryController.js.map +0 -1
  44. package/dist/createMutationController.d.ts +0 -79
  45. package/dist/createMutationController.d.ts.map +0 -1
  46. package/dist/createMutationController.js +0 -193
  47. package/dist/createMutationController.js.map +0 -1
  48. package/dist/createQueriesController.d.ts +0 -145
  49. package/dist/createQueriesController.d.ts.map +0 -1
  50. package/dist/createQueriesController.js +0 -367
  51. package/dist/createQueriesController.js.map +0 -1
  52. package/dist/createQueryController.d.ts +0 -67
  53. package/dist/createQueryController.d.ts.map +0 -1
  54. package/dist/createQueryController.js +0 -238
  55. package/dist/createQueryController.js.map +0 -1
  56. package/dist/index.d.ts +0 -24
  57. package/dist/index.d.ts.map +0 -1
  58. package/dist/index.js +0 -15
  59. package/dist/index.js.map +0 -1
  60. package/dist/infiniteQueryOptions.d.ts +0 -21
  61. package/dist/infiniteQueryOptions.d.ts.map +0 -1
  62. package/dist/infiniteQueryOptions.js +0 -22
  63. package/dist/infiniteQueryOptions.js.map +0 -1
  64. package/dist/mutationOptions.d.ts +0 -19
  65. package/dist/mutationOptions.d.ts.map +0 -1
  66. package/dist/mutationOptions.js +0 -20
  67. package/dist/mutationOptions.js.map +0 -1
  68. package/dist/queryObserverResultTracker.d.ts +0 -14
  69. package/dist/queryObserverResultTracker.d.ts.map +0 -1
  70. package/dist/queryObserverResultTracker.js +0 -18
  71. package/dist/queryObserverResultTracker.js.map +0 -1
  72. package/dist/queryOptions.d.ts +0 -62
  73. package/dist/queryOptions.d.ts.map +0 -1
  74. package/dist/queryOptions.js +0 -4
  75. package/dist/queryOptions.js.map +0 -1
  76. package/dist/types.d.ts +0 -31
  77. package/dist/types.d.ts.map +0 -1
  78. package/dist/types.js +0 -2
  79. package/dist/types.js.map +0 -1
  80. package/dist/useIsFetching.d.ts +0 -45
  81. package/dist/useIsFetching.d.ts.map +0 -1
  82. package/dist/useIsFetching.js +0 -116
  83. package/dist/useIsFetching.js.map +0 -1
  84. package/dist/useIsMutating.d.ts +0 -45
  85. package/dist/useIsMutating.d.ts.map +0 -1
  86. package/dist/useIsMutating.js +0 -116
  87. package/dist/useIsMutating.js.map +0 -1
  88. package/dist/useMutationState.d.ts +0 -57
  89. package/dist/useMutationState.d.ts.map +0 -1
  90. package/dist/useMutationState.js +0 -136
  91. package/dist/useMutationState.js.map +0 -1
  92. package/dist-cjs/QueryClientProvider.d.cts +0 -84
  93. package/dist-cjs/QueryClientProvider.js +0 -141
  94. package/dist-cjs/QueryClientProvider.js.map +0 -1
  95. package/dist-cjs/accessor.d.cts +0 -31
  96. package/dist-cjs/accessor.js +0 -16
  97. package/dist-cjs/accessor.js.map +0 -1
  98. package/dist-cjs/context.d.cts +0 -58
  99. package/dist-cjs/context.js +0 -109
  100. package/dist-cjs/context.js.map +0 -1
  101. package/dist-cjs/controllers/BaseController.d.cts +0 -38
  102. package/dist-cjs/controllers/BaseController.js +0 -217
  103. package/dist-cjs/controllers/BaseController.js.map +0 -1
  104. package/dist-cjs/createInfiniteQueryController.d.cts +0 -75
  105. package/dist-cjs/createInfiniteQueryController.js +0 -251
  106. package/dist-cjs/createInfiniteQueryController.js.map +0 -1
  107. package/dist-cjs/createMutationController.d.cts +0 -78
  108. package/dist-cjs/createMutationController.js +0 -196
  109. package/dist-cjs/createMutationController.js.map +0 -1
  110. package/dist-cjs/createQueriesController.d.cts +0 -144
  111. package/dist-cjs/createQueriesController.js +0 -370
  112. package/dist-cjs/createQueriesController.js.map +0 -1
  113. package/dist-cjs/createQueryController.d.cts +0 -66
  114. package/dist-cjs/createQueryController.js +0 -241
  115. package/dist-cjs/createQueryController.js.map +0 -1
  116. package/dist-cjs/index.d.cts +0 -23
  117. package/dist-cjs/index.js +0 -49
  118. package/dist-cjs/index.js.map +0 -1
  119. package/dist-cjs/infiniteQueryOptions.d.cts +0 -20
  120. package/dist-cjs/infiniteQueryOptions.js +0 -25
  121. package/dist-cjs/infiniteQueryOptions.js.map +0 -1
  122. package/dist-cjs/mutationOptions.d.cts +0 -18
  123. package/dist-cjs/mutationOptions.js +0 -23
  124. package/dist-cjs/mutationOptions.js.map +0 -1
  125. package/dist-cjs/package.json +0 -3
  126. package/dist-cjs/queryObserverResultTracker.d.cts +0 -13
  127. package/dist-cjs/queryObserverResultTracker.js +0 -22
  128. package/dist-cjs/queryObserverResultTracker.js.map +0 -1
  129. package/dist-cjs/queryOptions.d.cts +0 -61
  130. package/dist-cjs/queryOptions.js +0 -7
  131. package/dist-cjs/queryOptions.js.map +0 -1
  132. package/dist-cjs/types.d.cts +0 -30
  133. package/dist-cjs/types.js +0 -3
  134. package/dist-cjs/types.js.map +0 -1
  135. package/dist-cjs/useIsFetching.d.cts +0 -44
  136. package/dist-cjs/useIsFetching.js +0 -119
  137. package/dist-cjs/useIsFetching.js.map +0 -1
  138. package/dist-cjs/useIsMutating.d.cts +0 -44
  139. package/dist-cjs/useIsMutating.js +0 -119
  140. package/dist-cjs/useIsMutating.js.map +0 -1
  141. package/dist-cjs/useMutationState.d.cts +0 -56
  142. package/dist-cjs/useMutationState.js +0 -139
  143. package/dist-cjs/useMutationState.js.map +0 -1
@@ -1,116 +0,0 @@
1
- import { createValueAccessor, readAccessor, } from './accessor.js';
2
- import { BaseController } from './controllers/BaseController.js';
3
- class IsFetchingController extends BaseController {
4
- filters;
5
- queryClient;
6
- unsubscribe;
7
- constructor(host, filters = {}, queryClient) {
8
- super(host, 0, queryClient);
9
- this.filters = filters;
10
- if (!queryClient) {
11
- return;
12
- }
13
- this.queryClient = queryClient;
14
- this.result = this.computeValue();
15
- }
16
- onConnected() {
17
- if (!this.syncClient()) {
18
- this.setResult(0);
19
- return;
20
- }
21
- this.subscribe();
22
- this.setResult(this.computeValue());
23
- }
24
- onDisconnected() {
25
- this.unsubscribe?.();
26
- this.unsubscribe = undefined;
27
- this.syncClient();
28
- }
29
- onHostUpdate() {
30
- if (typeof this.filters !== 'function') {
31
- return;
32
- }
33
- this.setResult(this.syncClient() ? this.computeValue() : 0);
34
- }
35
- onQueryClientChanged() {
36
- if (!this.syncClient()) {
37
- this.setResult(0);
38
- return;
39
- }
40
- if (this.connectedState) {
41
- this.subscribe();
42
- this.setResult(this.computeValue());
43
- }
44
- }
45
- syncClient() {
46
- const nextClient = this.tryGetQueryClient();
47
- if (!nextClient) {
48
- this.unsubscribe?.();
49
- this.unsubscribe = undefined;
50
- this.queryClient = undefined;
51
- return false;
52
- }
53
- if (nextClient === this.queryClient) {
54
- return true;
55
- }
56
- this.unsubscribe?.();
57
- this.unsubscribe = undefined;
58
- this.queryClient = nextClient;
59
- return true;
60
- }
61
- subscribe() {
62
- if (!this.queryClient) {
63
- return;
64
- }
65
- if (this.unsubscribe) {
66
- return;
67
- }
68
- this.unsubscribe = this.queryClient.getQueryCache().subscribe(() => {
69
- this.setResult(this.computeValue());
70
- });
71
- }
72
- computeValue() {
73
- if (!this.queryClient) {
74
- return 0;
75
- }
76
- return this.queryClient.isFetching(readAccessor(this.filters));
77
- }
78
- }
79
- /**
80
- * Creates a Lit reactive controller that tracks how many matching queries are
81
- * currently fetching.
82
- *
83
- * When `filters` is a function, it is re-read during host updates so the count
84
- * can follow reactive host state. If `queryClient` is omitted, the controller
85
- * resolves the client from the nearest connected `QueryClientProvider`.
86
- *
87
- * @param host - The Lit reactive controller host that owns the cache
88
- * subscription.
89
- * @param filters - Query filters, or a getter that returns query filters.
90
- * @param queryClient - Optional explicit query client. Provide this for
91
- * controllers that should not resolve a client from Lit context.
92
- * @returns An accessor for the current number of matching fetching queries.
93
- *
94
- * @example
95
- * ```ts
96
- * import { LitElement, html } from 'lit'
97
- * import { useIsFetching } from '@tanstack/lit-query'
98
- *
99
- * class TodosStatus extends LitElement {
100
- * private readonly todosFetching = useIsFetching(this, {
101
- * queryKey: ['todos'],
102
- * })
103
- *
104
- * render() {
105
- * return html`<span>${this.todosFetching()} active todo fetches</span>`
106
- * }
107
- * }
108
- * ```
109
- */
110
- export function useIsFetching(host, filters = {}, queryClient) {
111
- const controller = new IsFetchingController(host, filters, queryClient);
112
- return Object.assign(createValueAccessor(() => controller.current), {
113
- destroy: () => controller.destroy(),
114
- });
115
- }
116
- //# sourceMappingURL=useIsFetching.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIsFetching.js","sourceRoot":"","sources":["../src/useIsFetching.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,YAAY,GAGb,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAUhE,MAAM,oBAAqB,SAAQ,cAAsB;IAMpC;IALX,WAAW,CAAyB;IACpC,WAAW,CAA0B;IAE7C,YACE,IAA4B,EACX,UAAkC,EAAE,EACrD,WAAyB;QAEzB,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC,CAAA;QAHV,YAAO,GAAP,OAAO,CAA6B;QAKrD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAM;QACR,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAA;IACnC,CAAC;IAES,WAAW;QACnB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;YACvB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;YACjB,OAAM;QACR,CAAC;QAED,IAAI,CAAC,SAAS,EAAE,CAAA;QAChB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAA;IACrC,CAAC;IAES,cAAc;QACtB,IAAI,CAAC,WAAW,EAAE,EAAE,CAAA;QACpB,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;QAC5B,IAAI,CAAC,UAAU,EAAE,CAAA;IACnB,CAAC;IAES,YAAY;QACpB,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YACvC,OAAM;QACR,CAAC;QAED,IAAI,CAA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CAAC,YAAY,EAAE,CAAC,CAAA;QACrC,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,YAAY;QAClB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,OAAO,CAAC,CAAA;QACV,CAAC;QAED,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;IAChE,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,aAAa,CAC3B,IAA4B,EAC5B,UAAkC,EAAE,EACpC,WAAyB;IAEzB,MAAM,UAAU,GAAG,IAAI,oBAAoB,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,CAAA;IACvE,OAAO,MAAM,CAAC,MAAM,CAClB,mBAAmB,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAC7C;QACE,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE;KACpC,CACF,CAAA;AACH,CAAC"}
@@ -1,45 +0,0 @@
1
- import type { MutationFilters, QueryClient } from '@tanstack/query-core';
2
- import type { ReactiveControllerHost } from 'lit';
3
- import { type Accessor, type ValueAccessor } from './accessor.js';
4
- /**
5
- * Accessor returned by `useIsMutating`.
6
- *
7
- * Call the accessor or read its `current` property to get the number of
8
- * currently pending mutations that match the filters.
9
- */
10
- export type IsMutatingAccessor = ValueAccessor<number> & {
11
- destroy: () => void;
12
- };
13
- /**
14
- * Creates a Lit reactive controller that tracks how many matching mutations are
15
- * currently pending.
16
- *
17
- * When `filters` is a function, it is re-read during host updates so the count
18
- * can follow reactive host state. If `queryClient` is omitted, the controller
19
- * resolves the client from the nearest connected `QueryClientProvider`.
20
- *
21
- * @param host - The Lit reactive controller host that owns the cache
22
- * subscription.
23
- * @param filters - Mutation filters, or a getter that returns mutation filters.
24
- * @param queryClient - Optional explicit query client. Provide this for
25
- * controllers that should not resolve a client from Lit context.
26
- * @returns An accessor for the current number of matching pending mutations.
27
- *
28
- * @example
29
- * ```ts
30
- * import { LitElement, html } from 'lit'
31
- * import { useIsMutating } from '@tanstack/lit-query'
32
- *
33
- * class MutationStatus extends LitElement {
34
- * private readonly savesPending = useIsMutating(this, {
35
- * mutationKey: ['save-project'],
36
- * })
37
- *
38
- * render() {
39
- * return html`<span>${this.savesPending()} saves pending</span>`
40
- * }
41
- * }
42
- * ```
43
- */
44
- export declare function useIsMutating(host: ReactiveControllerHost, filters?: Accessor<MutationFilters>, queryClient?: QueryClient): IsMutatingAccessor;
45
- //# sourceMappingURL=useIsMutating.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIsMutating.d.ts","sourceRoot":"","sources":["../src/useIsMutating.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,KAAK,CAAA;AACjD,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,aAAa,EACnB,MAAM,eAAe,CAAA;AAGtB;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAAA;AAmGhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,sBAAsB,EAC5B,OAAO,GAAE,QAAQ,CAAC,eAAe,CAAM,EACvC,WAAW,CAAC,EAAE,WAAW,GACxB,kBAAkB,CAQpB"}
@@ -1,116 +0,0 @@
1
- import { createValueAccessor, readAccessor, } from './accessor.js';
2
- import { BaseController } from './controllers/BaseController.js';
3
- class IsMutatingController extends BaseController {
4
- filters;
5
- queryClient;
6
- unsubscribe;
7
- constructor(host, filters = {}, queryClient) {
8
- super(host, 0, queryClient);
9
- this.filters = filters;
10
- if (!queryClient) {
11
- return;
12
- }
13
- this.queryClient = queryClient;
14
- this.result = this.computeValue();
15
- }
16
- onConnected() {
17
- if (!this.syncClient()) {
18
- this.setResult(0);
19
- return;
20
- }
21
- this.subscribe();
22
- this.setResult(this.computeValue());
23
- }
24
- onDisconnected() {
25
- this.unsubscribe?.();
26
- this.unsubscribe = undefined;
27
- this.syncClient();
28
- }
29
- onHostUpdate() {
30
- if (typeof this.filters !== 'function') {
31
- return;
32
- }
33
- this.setResult(this.syncClient() ? this.computeValue() : 0);
34
- }
35
- onQueryClientChanged() {
36
- if (!this.syncClient()) {
37
- this.setResult(0);
38
- return;
39
- }
40
- if (this.connectedState) {
41
- this.subscribe();
42
- this.setResult(this.computeValue());
43
- }
44
- }
45
- syncClient() {
46
- const nextClient = this.tryGetQueryClient();
47
- if (!nextClient) {
48
- this.unsubscribe?.();
49
- this.unsubscribe = undefined;
50
- this.queryClient = undefined;
51
- return false;
52
- }
53
- if (nextClient === this.queryClient) {
54
- return true;
55
- }
56
- this.unsubscribe?.();
57
- this.unsubscribe = undefined;
58
- this.queryClient = nextClient;
59
- return true;
60
- }
61
- subscribe() {
62
- if (!this.queryClient) {
63
- return;
64
- }
65
- if (this.unsubscribe) {
66
- return;
67
- }
68
- this.unsubscribe = this.queryClient.getMutationCache().subscribe(() => {
69
- this.setResult(this.computeValue());
70
- });
71
- }
72
- computeValue() {
73
- if (!this.queryClient) {
74
- return 0;
75
- }
76
- return this.queryClient.isMutating(readAccessor(this.filters));
77
- }
78
- }
79
- /**
80
- * Creates a Lit reactive controller that tracks how many matching mutations are
81
- * currently pending.
82
- *
83
- * When `filters` is a function, it is re-read during host updates so the count
84
- * can follow reactive host state. If `queryClient` is omitted, the controller
85
- * resolves the client from the nearest connected `QueryClientProvider`.
86
- *
87
- * @param host - The Lit reactive controller host that owns the cache
88
- * subscription.
89
- * @param filters - Mutation filters, or a getter that returns mutation filters.
90
- * @param queryClient - Optional explicit query client. Provide this for
91
- * controllers that should not resolve a client from Lit context.
92
- * @returns An accessor for the current number of matching pending mutations.
93
- *
94
- * @example
95
- * ```ts
96
- * import { LitElement, html } from 'lit'
97
- * import { useIsMutating } from '@tanstack/lit-query'
98
- *
99
- * class MutationStatus extends LitElement {
100
- * private readonly savesPending = useIsMutating(this, {
101
- * mutationKey: ['save-project'],
102
- * })
103
- *
104
- * render() {
105
- * return html`<span>${this.savesPending()} saves pending</span>`
106
- * }
107
- * }
108
- * ```
109
- */
110
- export function useIsMutating(host, filters = {}, queryClient) {
111
- const controller = new IsMutatingController(host, filters, queryClient);
112
- return Object.assign(createValueAccessor(() => controller.current), {
113
- destroy: () => controller.destroy(),
114
- });
115
- }
116
- //# sourceMappingURL=useIsMutating.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIsMutating.js","sourceRoot":"","sources":["../src/useIsMutating.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,YAAY,GAGb,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAUhE,MAAM,oBAAqB,SAAQ,cAAsB;IAMpC;IALX,WAAW,CAAyB;IACpC,WAAW,CAA0B;IAE7C,YACE,IAA4B,EACX,UAAqC,EAAE,EACxD,WAAyB;QAEzB,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC,CAAA;QAHV,YAAO,GAAP,OAAO,CAAgC;QAKxD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAM;QACR,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAA;IACnC,CAAC;IAES,WAAW;QACnB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;YACvB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;YACjB,OAAM;QACR,CAAC;QAED,IAAI,CAAC,SAAS,EAAE,CAAA;QAChB,IAAI,CAAC,SAAS,CAAC,IAA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AI,CAAA;IACb,CAAC;IAEO,SAAS;QACf,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,OAAM;QACR,CAAC;QAED,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,OAAM;QACR,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE;YACpE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAA;QACrC,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,YAAY;QAClB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,OAAO,CAAC,CAAA;QACV,CAAC;QAED,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;IAChE,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,aAAa,CAC3B,IAA4B,EAC5B,UAAqC,EAAE,EACvC,WAAyB;IAEzB,MAAM,UAAU,GAAG,IAAI,oBAAoB,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,CAAA;IACvE,OAAO,MAAM,CAAC,MAAM,CAClB,mBAAmB,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAC7C;QACE,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE;KACpC,CACF,CAAA;AACH,CAAC"}
@@ -1,57 +0,0 @@
1
- import { type Mutation, type MutationFilters, type MutationState, type QueryClient } from '@tanstack/query-core';
2
- import type { ReactiveControllerHost } from 'lit';
3
- import { type Accessor, type ValueAccessor } from './accessor.js';
4
- /**
5
- * Options accepted by `useMutationState`.
6
- */
7
- export type MutationStateOptions<TResult> = {
8
- /** Filters used to select mutations from the mutation cache. */
9
- filters?: Accessor<MutationFilters>;
10
- /** Maps each matching mutation to the value returned by the accessor. */
11
- select?: (mutation: Mutation) => TResult;
12
- };
13
- /**
14
- * Accessor returned by `useMutationState`.
15
- *
16
- * Call the accessor or read its `current` property to get the selected state for
17
- * matching mutations.
18
- */
19
- export type MutationStateAccessor<TResult> = ValueAccessor<TResult[]> & {
20
- /** Removes the controller from its Lit host and unsubscribes observers. */
21
- destroy: () => void;
22
- };
23
- /**
24
- * Creates a Lit reactive controller that selects state from matching mutations
25
- * in the mutation cache.
26
- *
27
- * When `options.filters` is a function, it is re-read during host updates so
28
- * the selection can follow reactive host state. If `queryClient` is omitted,
29
- * the controller resolves the client from the nearest connected
30
- * `QueryClientProvider`.
31
- *
32
- * @param host - The Lit reactive controller host that owns the mutation cache
33
- * subscription.
34
- * @param options - Mutation state filters and optional selector.
35
- * @param queryClient - Optional explicit query client. Provide this for
36
- * controllers that should not resolve a client from Lit context.
37
- * @returns An accessor for the selected mutation state array.
38
- *
39
- * @example
40
- * ```ts
41
- * import { LitElement, html } from 'lit'
42
- * import { useMutationState } from '@tanstack/lit-query'
43
- *
44
- * class PendingUploads extends LitElement {
45
- * private readonly uploads = useMutationState(this, {
46
- * filters: { mutationKey: ['upload'], status: 'pending' },
47
- * select: (mutation) => mutation.state.variables as File,
48
- * })
49
- *
50
- * render() {
51
- * return html`<span>${this.uploads().length} uploads pending</span>`
52
- * }
53
- * }
54
- * ```
55
- */
56
- export declare function useMutationState<TResult = MutationState<unknown, unknown, unknown, unknown>>(host: ReactiveControllerHost, options?: MutationStateOptions<TResult>, queryClient?: QueryClient): MutationStateAccessor<TResult>;
57
- //# sourceMappingURL=useMutationState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMutationState.d.ts","sourceRoot":"","sources":["../src/useMutationState.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,KAAK,CAAA;AACjD,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,aAAa,EACnB,MAAM,eAAe,CAAA;AAGtB;;GAEG;AACH,MAAM,MAAM,oBAAoB,CAAC,OAAO,IAAI;IAC1C,gEAAgE;IAChE,OAAO,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAA;IACnC,yEAAyE;IACzE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAA;CACzC,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,CAAC,OAAO,IAAI,aAAa,CAAC,OAAO,EAAE,CAAC,GAAG;IACtE,2EAA2E;IAC3E,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,CAAA;AA2HD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAG,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAE3D,IAAI,EAAE,sBAAsB,EAC5B,OAAO,GAAE,oBAAoB,CAAC,OAAO,CAAM,EAC3C,WAAW,CAAC,EAAE,WAAW,GACxB,qBAAqB,CAAC,OAAO,CAAC,CAQhC"}
@@ -1,136 +0,0 @@
1
- import { replaceEqualDeep, } from '@tanstack/query-core';
2
- import { createValueAccessor, readAccessor, } from './accessor.js';
3
- import { BaseController } from './controllers/BaseController.js';
4
- class MutationStateController extends BaseController {
5
- options;
6
- queryClient;
7
- unsubscribe;
8
- constructor(host, options, queryClient) {
9
- super(host, [], queryClient);
10
- this.options = options;
11
- if (!queryClient) {
12
- return;
13
- }
14
- this.queryClient = queryClient;
15
- this.result = this.computeState();
16
- }
17
- onConnected() {
18
- if (!this.syncClient()) {
19
- this.setMutationState([]);
20
- return;
21
- }
22
- this.subscribe();
23
- this.setMutationState(this.computeState());
24
- }
25
- onDisconnected() {
26
- this.unsubscribe?.();
27
- this.unsubscribe = undefined;
28
- this.syncClient();
29
- }
30
- onHostUpdate() {
31
- if (!this.shouldRefreshOnHostUpdate()) {
32
- return;
33
- }
34
- this.setMutationState(this.syncClient() ? this.computeState() : []);
35
- }
36
- onQueryClientChanged() {
37
- if (!this.syncClient()) {
38
- this.setMutationState([]);
39
- return;
40
- }
41
- if (this.connectedState) {
42
- this.subscribe();
43
- this.setMutationState(this.computeState());
44
- }
45
- }
46
- syncClient() {
47
- const nextClient = this.tryGetQueryClient();
48
- if (!nextClient) {
49
- this.unsubscribe?.();
50
- this.unsubscribe = undefined;
51
- this.queryClient = undefined;
52
- return false;
53
- }
54
- if (nextClient === this.queryClient) {
55
- return true;
56
- }
57
- this.unsubscribe?.();
58
- this.unsubscribe = undefined;
59
- this.queryClient = nextClient;
60
- return true;
61
- }
62
- subscribe() {
63
- if (!this.queryClient) {
64
- return;
65
- }
66
- if (this.unsubscribe) {
67
- return;
68
- }
69
- this.unsubscribe = this.queryClient.getMutationCache().subscribe(() => {
70
- this.setMutationState(this.computeState());
71
- });
72
- }
73
- setMutationState(next) {
74
- this.setResult(replaceEqualDeep(this.result, next));
75
- }
76
- shouldRefreshOnHostUpdate() {
77
- return (typeof this.options.filters === 'function' ||
78
- typeof this.options.select === 'function');
79
- }
80
- computeState() {
81
- if (!this.queryClient) {
82
- return [];
83
- }
84
- const filters = this.options.filters
85
- ? readAccessor(this.options.filters)
86
- : undefined;
87
- const select = this.options.select;
88
- const mutations = this.queryClient.getMutationCache().findAll(filters);
89
- return mutations.map((mutation) => {
90
- if (select) {
91
- return select(mutation);
92
- }
93
- return mutation.state;
94
- });
95
- }
96
- }
97
- /**
98
- * Creates a Lit reactive controller that selects state from matching mutations
99
- * in the mutation cache.
100
- *
101
- * When `options.filters` is a function, it is re-read during host updates so
102
- * the selection can follow reactive host state. If `queryClient` is omitted,
103
- * the controller resolves the client from the nearest connected
104
- * `QueryClientProvider`.
105
- *
106
- * @param host - The Lit reactive controller host that owns the mutation cache
107
- * subscription.
108
- * @param options - Mutation state filters and optional selector.
109
- * @param queryClient - Optional explicit query client. Provide this for
110
- * controllers that should not resolve a client from Lit context.
111
- * @returns An accessor for the selected mutation state array.
112
- *
113
- * @example
114
- * ```ts
115
- * import { LitElement, html } from 'lit'
116
- * import { useMutationState } from '@tanstack/lit-query'
117
- *
118
- * class PendingUploads extends LitElement {
119
- * private readonly uploads = useMutationState(this, {
120
- * filters: { mutationKey: ['upload'], status: 'pending' },
121
- * select: (mutation) => mutation.state.variables as File,
122
- * })
123
- *
124
- * render() {
125
- * return html`<span>${this.uploads().length} uploads pending</span>`
126
- * }
127
- * }
128
- * ```
129
- */
130
- export function useMutationState(host, options = {}, queryClient) {
131
- const controller = new MutationStateController(host, options, queryClient);
132
- return Object.assign(createValueAccessor(() => controller.current), {
133
- destroy: () => controller.destroy(),
134
- });
135
- }
136
- //# sourceMappingURL=useMutationState.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMutationState.js","sourceRoot":"","sources":["../src/useMutationState.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAKjB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EACL,mBAAmB,EACnB,YAAY,GAGb,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAuBhE,MAAM,uBAAiC,SAAQ,cAAyB;IAMnD;IALX,WAAW,CAAyB;IACpC,WAAW,CAA0B;IAE7C,YACE,IAA4B,EACX,OAAsC,EACvD,WAAyB;QAEzB,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,WAAW,CAAC,CAAA;QAHX,YAAO,GAAP,OAAO,CAA+B;QAKvD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAM;QACR,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAA;IACnC,CAAC;IAES,WAAW;QACnB,IAAI,CAAC,IAAI,CAAC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CAAA;QAEtE,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YAChC,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAA;YACzB,CAAC;YAED,OAAO,QAAQ,CAAC,KAAgB,CAAA;QAClC,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,UAAU,gBAAgB,CAG9B,IAA4B,EAC5B,UAAyC,EAAE,EAC3C,WAAyB;IAEzB,MAAM,UAAU,GAAG,IAAI,uBAAuB,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,CAAA;IAC1E,OAAO,MAAM,CAAC,MAAM,CAClB,mBAAmB,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAC7C;QACE,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE;KACpC,CACF,CAAA;AACH,CAAC"}
@@ -1,84 +0,0 @@
1
- import type { QueryClient } from '@tanstack/query-core';
2
- import type { TemplateResult } from 'lit' with { "resolution-mode": "import" };
3
- import type { LitElement } from 'lit' with { "resolution-mode": "import" };
4
- /**
5
- * Lit element that provides a `QueryClient` to descendant Lit Query
6
- * controllers through Lit context.
7
- *
8
- * The `client` is a property, not an attribute. When rendering this element in
9
- * a Lit template, bind it with property binding: `.client=${queryClient}`.
10
- * The provider throws if it connects without a client, or if an already
11
- * connected provider has its client cleared.
12
- *
13
- * This class is not registered as a custom element by the package. Applications
14
- * must register either a subclass or the class itself with
15
- * `customElements.define`.
16
- *
17
- * @example
18
- * ```ts
19
- * import { html, LitElement } from 'lit'
20
- * import { QueryClient, QueryClientProvider } from '@tanstack/lit-query'
21
- *
22
- * const queryClient = new QueryClient()
23
- *
24
- * class AppQueryProvider extends QueryClientProvider {
25
- * constructor() {
26
- * super()
27
- * this.client = queryClient
28
- * }
29
- * }
30
- *
31
- * customElements.define('app-query-provider', AppQueryProvider)
32
- *
33
- * class AppRoot extends LitElement {
34
- * render() {
35
- * return html`<app-query-provider><todos-view></todos-view></app-query-provider>`
36
- * }
37
- * }
38
- * ```
39
- *
40
- * @example
41
- * ```ts
42
- * import { html } from 'lit'
43
- * import { QueryClient, QueryClientProvider } from '@tanstack/lit-query'
44
- *
45
- * const queryClient = new QueryClient()
46
- *
47
- * customElements.define('query-client-provider', QueryClientProvider)
48
- *
49
- * const view = html`
50
- * <query-client-provider .client=${queryClient}>
51
- * <todos-view></todos-view>
52
- * </query-client-provider>
53
- * `
54
- * ```
55
- */
56
- export declare class QueryClientProvider extends LitElement {
57
- /** @internal */
58
- static properties: {
59
- client: {
60
- attribute: boolean;
61
- };
62
- };
63
- /**
64
- * The `QueryClient` provided to descendant controllers and global fallback
65
- * helpers while this provider is connected.
66
- *
67
- * Bind this as a property in Lit templates with `.client=${queryClient}`.
68
- */
69
- client: QueryClient;
70
- private readonly contextProvider;
71
- private mountedClient;
72
- constructor();
73
- /** @internal */
74
- connectedCallback(): void;
75
- /** @internal */
76
- disconnectedCallback(): void;
77
- /** @internal */
78
- protected willUpdate(changedProperties: Map<PropertyKey, unknown>): void;
79
- /** @internal */
80
- render(): TemplateResult;
81
- private mountClient;
82
- private unmountClient;
83
- private requireClient;
84
- }