@tanstack/lit-query 0.2.10 → 0.2.12
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/README.md +17 -0
- package/build/legacy/index.cjs +1585 -0
- package/build/legacy/index.cjs.map +1 -0
- package/build/legacy/index.d.cts +781 -0
- package/build/legacy/index.d.cts.map +1 -0
- package/build/legacy/index.d.ts +781 -0
- package/build/legacy/index.d.ts.map +1 -0
- package/build/legacy/index.js +1561 -0
- package/build/legacy/index.js.map +1 -0
- package/build/modern/index.cjs +1569 -0
- package/build/modern/index.cjs.map +1 -0
- package/build/modern/index.d.cts +781 -0
- package/build/modern/index.d.cts.map +1 -0
- package/build/modern/index.d.ts +781 -0
- package/build/modern/index.d.ts.map +1 -0
- package/build/modern/index.js +1545 -0
- package/build/modern/index.js.map +1 -0
- package/package.json +27 -30
- package/src/createInfiniteQueryController.ts +0 -1
- package/src/createMutationController.ts +9 -7
- package/src/createQueriesController.ts +0 -2
- package/src/createQueryController.ts +0 -1
- package/src/infiniteQueryOptions.ts +10 -4
- package/dist/QueryClientProvider.d.ts +0 -85
- package/dist/QueryClientProvider.d.ts.map +0 -1
- package/dist/QueryClientProvider.js +0 -137
- package/dist/QueryClientProvider.js.map +0 -1
- package/dist/accessor.d.ts +0 -32
- package/dist/accessor.d.ts.map +0 -1
- package/dist/accessor.js +0 -12
- package/dist/accessor.js.map +0 -1
- package/dist/context.d.ts +0 -59
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js +0 -100
- package/dist/context.js.map +0 -1
- package/dist/controllers/BaseController.d.ts +0 -39
- package/dist/controllers/BaseController.d.ts.map +0 -1
- package/dist/controllers/BaseController.js +0 -213
- package/dist/controllers/BaseController.js.map +0 -1
- package/dist/createInfiniteQueryController.d.ts +0 -76
- package/dist/createInfiniteQueryController.d.ts.map +0 -1
- package/dist/createInfiniteQueryController.js +0 -248
- package/dist/createInfiniteQueryController.js.map +0 -1
- package/dist/createMutationController.d.ts +0 -79
- package/dist/createMutationController.d.ts.map +0 -1
- package/dist/createMutationController.js +0 -193
- package/dist/createMutationController.js.map +0 -1
- package/dist/createQueriesController.d.ts +0 -145
- package/dist/createQueriesController.d.ts.map +0 -1
- package/dist/createQueriesController.js +0 -367
- package/dist/createQueriesController.js.map +0 -1
- package/dist/createQueryController.d.ts +0 -67
- package/dist/createQueryController.d.ts.map +0 -1
- package/dist/createQueryController.js +0 -238
- package/dist/createQueryController.js.map +0 -1
- package/dist/index.d.ts +0 -24
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -15
- package/dist/index.js.map +0 -1
- package/dist/infiniteQueryOptions.d.ts +0 -21
- package/dist/infiniteQueryOptions.d.ts.map +0 -1
- package/dist/infiniteQueryOptions.js +0 -22
- package/dist/infiniteQueryOptions.js.map +0 -1
- package/dist/mutationOptions.d.ts +0 -19
- package/dist/mutationOptions.d.ts.map +0 -1
- package/dist/mutationOptions.js +0 -20
- package/dist/mutationOptions.js.map +0 -1
- package/dist/queryObserverResultTracker.d.ts +0 -14
- package/dist/queryObserverResultTracker.d.ts.map +0 -1
- package/dist/queryObserverResultTracker.js +0 -18
- package/dist/queryObserverResultTracker.js.map +0 -1
- package/dist/queryOptions.d.ts +0 -62
- package/dist/queryOptions.d.ts.map +0 -1
- package/dist/queryOptions.js +0 -4
- package/dist/queryOptions.js.map +0 -1
- package/dist/types.d.ts +0 -31
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/useIsFetching.d.ts +0 -45
- package/dist/useIsFetching.d.ts.map +0 -1
- package/dist/useIsFetching.js +0 -116
- package/dist/useIsFetching.js.map +0 -1
- package/dist/useIsMutating.d.ts +0 -45
- package/dist/useIsMutating.d.ts.map +0 -1
- package/dist/useIsMutating.js +0 -116
- package/dist/useIsMutating.js.map +0 -1
- package/dist/useMutationState.d.ts +0 -57
- package/dist/useMutationState.d.ts.map +0 -1
- package/dist/useMutationState.js +0 -136
- package/dist/useMutationState.js.map +0 -1
- package/dist-cjs/QueryClientProvider.d.cts +0 -84
- package/dist-cjs/QueryClientProvider.js +0 -141
- package/dist-cjs/QueryClientProvider.js.map +0 -1
- package/dist-cjs/accessor.d.cts +0 -31
- package/dist-cjs/accessor.js +0 -16
- package/dist-cjs/accessor.js.map +0 -1
- package/dist-cjs/context.d.cts +0 -58
- package/dist-cjs/context.js +0 -109
- package/dist-cjs/context.js.map +0 -1
- package/dist-cjs/controllers/BaseController.d.cts +0 -38
- package/dist-cjs/controllers/BaseController.js +0 -217
- package/dist-cjs/controllers/BaseController.js.map +0 -1
- package/dist-cjs/createInfiniteQueryController.d.cts +0 -75
- package/dist-cjs/createInfiniteQueryController.js +0 -251
- package/dist-cjs/createInfiniteQueryController.js.map +0 -1
- package/dist-cjs/createMutationController.d.cts +0 -78
- package/dist-cjs/createMutationController.js +0 -196
- package/dist-cjs/createMutationController.js.map +0 -1
- package/dist-cjs/createQueriesController.d.cts +0 -144
- package/dist-cjs/createQueriesController.js +0 -370
- package/dist-cjs/createQueriesController.js.map +0 -1
- package/dist-cjs/createQueryController.d.cts +0 -66
- package/dist-cjs/createQueryController.js +0 -241
- package/dist-cjs/createQueryController.js.map +0 -1
- package/dist-cjs/index.d.cts +0 -23
- package/dist-cjs/index.js +0 -49
- package/dist-cjs/index.js.map +0 -1
- package/dist-cjs/infiniteQueryOptions.d.cts +0 -20
- package/dist-cjs/infiniteQueryOptions.js +0 -25
- package/dist-cjs/infiniteQueryOptions.js.map +0 -1
- package/dist-cjs/mutationOptions.d.cts +0 -18
- package/dist-cjs/mutationOptions.js +0 -23
- package/dist-cjs/mutationOptions.js.map +0 -1
- package/dist-cjs/package.json +0 -3
- package/dist-cjs/queryObserverResultTracker.d.cts +0 -13
- package/dist-cjs/queryObserverResultTracker.js +0 -22
- package/dist-cjs/queryObserverResultTracker.js.map +0 -1
- package/dist-cjs/queryOptions.d.cts +0 -61
- package/dist-cjs/queryOptions.js +0 -7
- package/dist-cjs/queryOptions.js.map +0 -1
- package/dist-cjs/types.d.cts +0 -30
- package/dist-cjs/types.js +0 -3
- package/dist-cjs/types.js.map +0 -1
- package/dist-cjs/useIsFetching.d.cts +0 -44
- package/dist-cjs/useIsFetching.js +0 -119
- package/dist-cjs/useIsFetching.js.map +0 -1
- package/dist-cjs/useIsMutating.d.cts +0 -44
- package/dist-cjs/useIsMutating.js +0 -119
- package/dist-cjs/useIsMutating.js.map +0 -1
- package/dist-cjs/useMutationState.d.cts +0 -56
- package/dist-cjs/useMutationState.js +0 -139
- package/dist-cjs/useMutationState.js.map +0 -1
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { ContextProvider } from '@lit/context';
|
|
2
|
-
import { LitElement, html } from 'lit';
|
|
3
|
-
import { createMissingQueryClientError, queryClientContext, registerDefaultQueryClient, unregisterDefaultQueryClient, } from './context.js';
|
|
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 class QueryClientProvider extends LitElement {
|
|
57
|
-
/** @internal */
|
|
58
|
-
static properties = {
|
|
59
|
-
client: { attribute: false },
|
|
60
|
-
};
|
|
61
|
-
contextProvider;
|
|
62
|
-
mountedClient;
|
|
63
|
-
constructor() {
|
|
64
|
-
super();
|
|
65
|
-
this.contextProvider = new ContextProvider(this, {
|
|
66
|
-
context: queryClientContext,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/** @internal */
|
|
70
|
-
connectedCallback() {
|
|
71
|
-
super.connectedCallback();
|
|
72
|
-
const client = this.requireClient();
|
|
73
|
-
this.contextProvider.setValue(client);
|
|
74
|
-
this.mountClient(client);
|
|
75
|
-
}
|
|
76
|
-
/** @internal */
|
|
77
|
-
disconnectedCallback() {
|
|
78
|
-
this.unmountClient(this.mountedClient);
|
|
79
|
-
super.disconnectedCallback();
|
|
80
|
-
}
|
|
81
|
-
/** @internal */
|
|
82
|
-
willUpdate(changedProperties) {
|
|
83
|
-
if (!changedProperties.has('client')) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const nextClient = this.client;
|
|
87
|
-
if (!nextClient) {
|
|
88
|
-
if (this.isConnected) {
|
|
89
|
-
this.unmountClient(this.mountedClient);
|
|
90
|
-
// Sentinel: notify active consumers that the provider is now unbound.
|
|
91
|
-
this.contextProvider.setValue(undefined);
|
|
92
|
-
throw createMissingQueryClientError();
|
|
93
|
-
}
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
const previousClient = changedProperties.get('client');
|
|
97
|
-
if (previousClient && previousClient !== nextClient && this.isConnected) {
|
|
98
|
-
this.unmountClient(previousClient);
|
|
99
|
-
}
|
|
100
|
-
this.contextProvider.setValue(nextClient);
|
|
101
|
-
if (this.isConnected) {
|
|
102
|
-
this.mountClient(nextClient);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/** @internal */
|
|
106
|
-
render() {
|
|
107
|
-
return html `<slot></slot>`;
|
|
108
|
-
}
|
|
109
|
-
mountClient(client) {
|
|
110
|
-
if (this.mountedClient === client) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (this.mountedClient) {
|
|
114
|
-
this.unmountClient(this.mountedClient);
|
|
115
|
-
}
|
|
116
|
-
client.mount();
|
|
117
|
-
registerDefaultQueryClient(client);
|
|
118
|
-
this.mountedClient = client;
|
|
119
|
-
}
|
|
120
|
-
unmountClient(client) {
|
|
121
|
-
if (!client) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
client.unmount();
|
|
125
|
-
unregisterDefaultQueryClient(client);
|
|
126
|
-
if (this.mountedClient === client) {
|
|
127
|
-
this.mountedClient = undefined;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
requireClient() {
|
|
131
|
-
if (!this.client) {
|
|
132
|
-
throw createMissingQueryClientError();
|
|
133
|
-
}
|
|
134
|
-
return this.client;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
//# sourceMappingURL=QueryClientProvider.js.map
|
|
@@ -1 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EAAE,CAAA;QAChB,4BAA4B,CAAC,MAAM,CAAC,CAAA;QAEpC,IAAI,IAAI,CAAC,aAAa,KAAK,MAAM,EAAE,CAAC;YAClC,IAAI,CAAC,aAAa,GAAG,SAAS,CAAA;QAChC,CAAC;IACH,CAAC;IAEO,aAAa;QACnB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,6BAA6B,EAAE,CAAA;QACvC,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC"}
|
package/dist/accessor.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A value that can be passed directly or read from a zero-argument getter.
|
|
3
|
-
*
|
|
4
|
-
* Lit Query APIs read function accessors during host updates, so the getter can
|
|
5
|
-
* depend on reactive host state.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* const staticKey: Accessor<readonly unknown[]> = ['todos']
|
|
10
|
-
* const reactiveKey: Accessor<readonly unknown[]> = () => ['todos', this.userId]
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export type Accessor<T> = T | (() => T);
|
|
14
|
-
export declare function readAccessor<T>(value: Accessor<T>): T;
|
|
15
|
-
/**
|
|
16
|
-
* A callable accessor with a `current` property for reading the latest
|
|
17
|
-
* controller result.
|
|
18
|
-
*
|
|
19
|
-
* Controller creators and cache state helpers return this shape so render code
|
|
20
|
-
* can use either `result()` or `result.current`.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* const query = this.todos()
|
|
25
|
-
* const sameQuery = this.todos.current
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export type ValueAccessor<T> = (() => T) & {
|
|
29
|
-
readonly current: T;
|
|
30
|
-
};
|
|
31
|
-
export declare function createValueAccessor<T>(getter: () => T): ValueAccessor<T>;
|
|
32
|
-
//# sourceMappingURL=accessor.d.ts.map
|
package/dist/accessor.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accessor.d.ts","sourceRoot":"","sources":["../src/accessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;AAEvC,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAErD;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG;IACzC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;CACpB,CAAA;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAOxE"}
|
package/dist/accessor.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function readAccessor(value) {
|
|
2
|
-
return typeof value === 'function' ? value() : value;
|
|
3
|
-
}
|
|
4
|
-
export function createValueAccessor(getter) {
|
|
5
|
-
const accessor = (() => getter());
|
|
6
|
-
Object.defineProperty(accessor, 'current', {
|
|
7
|
-
get: getter,
|
|
8
|
-
enumerable: true,
|
|
9
|
-
});
|
|
10
|
-
return accessor;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=accessor.js.map
|
package/dist/accessor.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accessor.js","sourceRoot":"","sources":["../src/accessor.ts"],"names":[],"mappings":"AAcA,MAAM,UAAU,YAAY,CAAI,KAAkB;IAChD,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAE,KAAiB,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;AACnE,CAAC;AAmBD,MAAM,UAAU,mBAAmB,CAAI,MAAe;IACpD,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAqB,CAAA;IACrD,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,SAAS,EAAE;QACzC,GAAG,EAAE,MAAM;QACX,UAAU,EAAE,IAAI;KACjB,CAAC,CAAA;IACF,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
package/dist/context.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { QueryClient } from '@tanstack/query-core';
|
|
2
|
-
/**
|
|
3
|
-
* Lit context key used by `QueryClientProvider` and host-bound APIs to share a
|
|
4
|
-
* `QueryClient` through the DOM tree.
|
|
5
|
-
*
|
|
6
|
-
* Most applications use `QueryClientProvider` instead of interacting with this
|
|
7
|
-
* context directly.
|
|
8
|
-
*/
|
|
9
|
-
export declare const queryClientContext: {
|
|
10
|
-
__context__: QueryClient;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Registers a `QueryClient` as a process-local fallback for APIs that resolve a
|
|
14
|
-
* client without an explicit argument.
|
|
15
|
-
*
|
|
16
|
-
* `QueryClientProvider` calls this automatically while it is connected. Prefer
|
|
17
|
-
* passing an explicit client or rendering under a provider when possible.
|
|
18
|
-
*
|
|
19
|
-
* @param client - The query client to register as the current default.
|
|
20
|
-
*/
|
|
21
|
-
export declare function registerDefaultQueryClient(client: QueryClient): void;
|
|
22
|
-
/**
|
|
23
|
-
* Unregisters a client previously registered with
|
|
24
|
-
* `registerDefaultQueryClient`.
|
|
25
|
-
*
|
|
26
|
-
* `QueryClientProvider` calls this automatically when it disconnects.
|
|
27
|
-
*
|
|
28
|
-
* @param client - The query client registration to release.
|
|
29
|
-
*/
|
|
30
|
-
export declare function unregisterDefaultQueryClient(client: QueryClient): void;
|
|
31
|
-
/**
|
|
32
|
-
* Returns the registered default `QueryClient`, if exactly one default client is
|
|
33
|
-
* available.
|
|
34
|
-
*
|
|
35
|
-
* @returns The default query client, or `undefined` when there is no registered
|
|
36
|
-
* client or more than one registered client.
|
|
37
|
-
*/
|
|
38
|
-
export declare function getDefaultQueryClient(): QueryClient | undefined;
|
|
39
|
-
export declare function createMissingQueryClientError(): Error;
|
|
40
|
-
/**
|
|
41
|
-
* Resolves the current default `QueryClient` registered by a connected
|
|
42
|
-
* `QueryClientProvider`.
|
|
43
|
-
*
|
|
44
|
-
* This helper is useful outside a Lit reactive controller when a single
|
|
45
|
-
* provider is mounted. It throws if no client is registered or if multiple
|
|
46
|
-
* clients are mounted and the default would be ambiguous.
|
|
47
|
-
*
|
|
48
|
-
* @returns The single registered query client.
|
|
49
|
-
*/
|
|
50
|
-
export declare function useQueryClient(): QueryClient;
|
|
51
|
-
/**
|
|
52
|
-
* Resolves an explicit `QueryClient` or falls back to `useQueryClient`.
|
|
53
|
-
*
|
|
54
|
-
* @param explicit - Optional client supplied by the caller.
|
|
55
|
-
* @returns The explicit client when provided, otherwise the current default
|
|
56
|
-
* client.
|
|
57
|
-
*/
|
|
58
|
-
export declare function resolveQueryClient(explicit?: QueryClient): QueryClient;
|
|
59
|
-
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;;CAE9B,CAAA;AAUD;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAGpE;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAkBtE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,WAAW,GAAG,SAAS,CAM/D;AAED,wBAAgB,6BAA6B,IAAI,KAAK,CAErD;AAMD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAW5C;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,WAAW,CAEtE"}
|
package/dist/context.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { createContext } from '@lit/context';
|
|
2
|
-
/**
|
|
3
|
-
* Lit context key used by `QueryClientProvider` and host-bound APIs to share a
|
|
4
|
-
* `QueryClient` through the DOM tree.
|
|
5
|
-
*
|
|
6
|
-
* Most applications use `QueryClientProvider` instead of interacting with this
|
|
7
|
-
* context directly.
|
|
8
|
-
*/
|
|
9
|
-
export const queryClientContext = createContext(Symbol.for('tanstack-query-client'));
|
|
10
|
-
const missingQueryClientMessage = 'No QueryClient available. Pass one explicitly or render within QueryClientProvider.';
|
|
11
|
-
const ambiguousQueryClientMessage = 'Multiple QueryClients are mounted. Pass one explicitly instead of relying on global QueryClient helpers.';
|
|
12
|
-
const registeredClients = new Map();
|
|
13
|
-
let defaultClient;
|
|
14
|
-
/**
|
|
15
|
-
* Registers a `QueryClient` as a process-local fallback for APIs that resolve a
|
|
16
|
-
* client without an explicit argument.
|
|
17
|
-
*
|
|
18
|
-
* `QueryClientProvider` calls this automatically while it is connected. Prefer
|
|
19
|
-
* passing an explicit client or rendering under a provider when possible.
|
|
20
|
-
*
|
|
21
|
-
* @param client - The query client to register as the current default.
|
|
22
|
-
*/
|
|
23
|
-
export function registerDefaultQueryClient(client) {
|
|
24
|
-
registeredClients.set(client, (registeredClients.get(client) ?? 0) + 1);
|
|
25
|
-
defaultClient = client;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Unregisters a client previously registered with
|
|
29
|
-
* `registerDefaultQueryClient`.
|
|
30
|
-
*
|
|
31
|
-
* `QueryClientProvider` calls this automatically when it disconnects.
|
|
32
|
-
*
|
|
33
|
-
* @param client - The query client registration to release.
|
|
34
|
-
*/
|
|
35
|
-
export function unregisterDefaultQueryClient(client) {
|
|
36
|
-
const count = registeredClients.get(client);
|
|
37
|
-
if (count === undefined) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (count > 1) {
|
|
41
|
-
registeredClients.set(client, count - 1);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
registeredClients.delete(client);
|
|
45
|
-
if (defaultClient !== client) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const remaining = [...registeredClients.keys()];
|
|
49
|
-
defaultClient = remaining.at(-1);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Returns the registered default `QueryClient`, if exactly one default client is
|
|
53
|
-
* available.
|
|
54
|
-
*
|
|
55
|
-
* @returns The default query client, or `undefined` when there is no registered
|
|
56
|
-
* client or more than one registered client.
|
|
57
|
-
*/
|
|
58
|
-
export function getDefaultQueryClient() {
|
|
59
|
-
if (registeredClients.size > 1) {
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
return defaultClient;
|
|
63
|
-
}
|
|
64
|
-
export function createMissingQueryClientError() {
|
|
65
|
-
return new Error(missingQueryClientMessage);
|
|
66
|
-
}
|
|
67
|
-
function createAmbiguousQueryClientError() {
|
|
68
|
-
return new Error(ambiguousQueryClientMessage);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Resolves the current default `QueryClient` registered by a connected
|
|
72
|
-
* `QueryClientProvider`.
|
|
73
|
-
*
|
|
74
|
-
* This helper is useful outside a Lit reactive controller when a single
|
|
75
|
-
* provider is mounted. It throws if no client is registered or if multiple
|
|
76
|
-
* clients are mounted and the default would be ambiguous.
|
|
77
|
-
*
|
|
78
|
-
* @returns The single registered query client.
|
|
79
|
-
*/
|
|
80
|
-
export function useQueryClient() {
|
|
81
|
-
const client = getDefaultQueryClient();
|
|
82
|
-
if (client) {
|
|
83
|
-
return client;
|
|
84
|
-
}
|
|
85
|
-
if (registeredClients.size > 1) {
|
|
86
|
-
throw createAmbiguousQueryClientError();
|
|
87
|
-
}
|
|
88
|
-
throw createMissingQueryClientError();
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Resolves an explicit `QueryClient` or falls back to `useQueryClient`.
|
|
92
|
-
*
|
|
93
|
-
* @param explicit - Optional client supplied by the caller.
|
|
94
|
-
* @returns The explicit client when provided, otherwise the current default
|
|
95
|
-
* client.
|
|
96
|
-
*/
|
|
97
|
-
export function resolveQueryClient(explicit) {
|
|
98
|
-
return explicit ?? useQueryClient();
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=context.js.map
|
package/dist/context.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAG5C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAC7C,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CACpC,CAAA;AAED,MAAM,yBAAyB,GAC7B,qFAAqF,CAAA;AACvF,MAAM,2BAA2B,GAC/B,0GAA0G,CAAA;AAE5G,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAuB,CAAA;AACxD,IAAI,aAAsC,CAAA;AAE1C;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAAmB;IAC5D,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACvE,aAAa,GAAG,MAAM,CAAA;AACxB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAAC,MAAmB;IAC9D,MAAM,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAC3C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAM;IACR,CAAC;IAED,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,CAAA;QACxC,OAAM;IACR,CAAC;IAED,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAChC,IAAI,aAAa,KAAK,MAAM,EAAE,CAAC;QAC7B,OAAM;IACR,CAAC;IAED,MAAM,SAAS,GAAG,CAAC,GAAG,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAA;IAC/C,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;AAClC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,iBAAiB,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,OAAO,aAAa,CAAA;AACtB,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,OAAO,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;AAC7C,CAAC;AAED,SAAS,+BAA+B;IACtC,OAAO,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;AAC/C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,MAAM,GAAG,qBAAqB,EAAE,CAAA;IACtC,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,MAAM,CAAA;IACf,CAAC;IAED,IAAI,iBAAiB,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,+BAA+B,EAAE,CAAA;IACzC,CAAC;IAED,MAAM,6BAA6B,EAAE,CAAA;AACvC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAsB;IACvD,OAAO,QAAQ,IAAI,cAAc,EAAE,CAAA;AACrC,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { QueryClient } from '@tanstack/query-core';
|
|
2
|
-
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
3
|
-
export declare abstract class BaseController<TResult> implements ReactiveController {
|
|
4
|
-
protected readonly host: ReactiveControllerHost;
|
|
5
|
-
protected result: TResult;
|
|
6
|
-
private readonly explicitClient?;
|
|
7
|
-
private contextClient;
|
|
8
|
-
private contextUnsubscribe;
|
|
9
|
-
private connected;
|
|
10
|
-
private destroyed;
|
|
11
|
-
private updateQueued;
|
|
12
|
-
private clientChangeQueued;
|
|
13
|
-
private connectionAttempt;
|
|
14
|
-
private isHostUpdating;
|
|
15
|
-
private queryClientResolutionState;
|
|
16
|
-
protected constructor(host: ReactiveControllerHost, initialResult: TResult, queryClient?: QueryClient);
|
|
17
|
-
hostConnected(): void;
|
|
18
|
-
hostDisconnected(): void;
|
|
19
|
-
hostUpdate(): void;
|
|
20
|
-
destroy(): void;
|
|
21
|
-
protected tryGetQueryClient(): QueryClient | undefined;
|
|
22
|
-
protected getQueryClient(): QueryClient;
|
|
23
|
-
protected setResult(next: TResult): void;
|
|
24
|
-
get current(): TResult;
|
|
25
|
-
protected get connectedState(): boolean;
|
|
26
|
-
protected queueUpdate(): void;
|
|
27
|
-
private queueQueryClientChanged;
|
|
28
|
-
private beginContextResolution;
|
|
29
|
-
private queueContextResolution;
|
|
30
|
-
private dispatchContextRequest;
|
|
31
|
-
private queueInitialContextResolutionCompletion;
|
|
32
|
-
private clearContextClient;
|
|
33
|
-
private updateQueryClientResolutionState;
|
|
34
|
-
protected abstract onConnected(): void;
|
|
35
|
-
protected abstract onDisconnected(): void;
|
|
36
|
-
protected abstract onHostUpdate(): void;
|
|
37
|
-
protected abstract onQueryClientChanged(): void;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=BaseController.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseController.d.ts","sourceRoot":"","sources":["../../src/controllers/BaseController.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,E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AQ,CAAC,WAAW,IAAI,IAAI;IACtC,SAAS,CAAC,QAAQ,CAAC,cAAc,IAAI,IAAI;IACzC,SAAS,CAAC,QAAQ,CAAC,YAAY,IAAI,IAAI;IACvC,SAAS,CAAC,QAAQ,CAAC,oBAAoB,IAAI,IAAI;CAChD"}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { ContextEvent } from '@lit/context';
|
|
2
|
-
import { createMissingQueryClientError, queryClientContext, } from '../context.js';
|
|
3
|
-
export class BaseController {
|
|
4
|
-
host;
|
|
5
|
-
result;
|
|
6
|
-
explicitClient;
|
|
7
|
-
contextClient;
|
|
8
|
-
contextUnsubscribe;
|
|
9
|
-
connected = false;
|
|
10
|
-
destroyed = false;
|
|
11
|
-
updateQueued = false;
|
|
12
|
-
clientChangeQueued = false;
|
|
13
|
-
connectionAttempt = 0;
|
|
14
|
-
isHostUpdating = false;
|
|
15
|
-
queryClientResolutionState;
|
|
16
|
-
constructor(host, initialResult, queryClient) {
|
|
17
|
-
this.host = host;
|
|
18
|
-
this.explicitClient = queryClient;
|
|
19
|
-
this.result = initialResult;
|
|
20
|
-
this.queryClientResolutionState = queryClient ? 'bound' : 'pre-connect';
|
|
21
|
-
host.addController(this);
|
|
22
|
-
}
|
|
23
|
-
hostConnected() {
|
|
24
|
-
if (this.connected || this.destroyed) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
this.connected = true;
|
|
28
|
-
let contextResolutionAttempt;
|
|
29
|
-
if (this.explicitClient) {
|
|
30
|
-
this.queryClientResolutionState = 'bound';
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
contextResolutionAttempt = ++this.connectionAttempt;
|
|
34
|
-
this.beginContextResolution();
|
|
35
|
-
}
|
|
36
|
-
// Defer onConnected to ensure subclass constructors complete before
|
|
37
|
-
// lifecycle callbacks access subclass state. This handles the case where
|
|
38
|
-
// addController is called on an already-connected host (e.g., during
|
|
39
|
-
// willUpdate), which synchronously triggers hostConnected before
|
|
40
|
-
// subclass field initialization.
|
|
41
|
-
queueMicrotask(() => {
|
|
42
|
-
if (this.connected && !this.destroyed) {
|
|
43
|
-
this.onConnected();
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
if (contextResolutionAttempt !== undefined) {
|
|
47
|
-
// Provider-backed controllers on already-connected hosts should finish
|
|
48
|
-
// their deferred onConnected pass before a context client binds.
|
|
49
|
-
this.queueContextResolution(contextResolutionAttempt);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
hostDisconnected() {
|
|
53
|
-
if (!this.connected) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
this.connected = false;
|
|
57
|
-
if (!this.explicitClient) {
|
|
58
|
-
this.connectionAttempt += 1;
|
|
59
|
-
this.clearContextClient();
|
|
60
|
-
this.updateQueryClientResolutionState('pre-connect');
|
|
61
|
-
}
|
|
62
|
-
this.onDisconnected();
|
|
63
|
-
}
|
|
64
|
-
hostUpdate() {
|
|
65
|
-
if (this.destroyed) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
this.isHostUpdating = true;
|
|
69
|
-
try {
|
|
70
|
-
this.onHostUpdate();
|
|
71
|
-
}
|
|
72
|
-
finally {
|
|
73
|
-
this.isHostUpdating = false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
destroy() {
|
|
77
|
-
if (this.destroyed) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
this.destroyed = true;
|
|
81
|
-
this.connected = false;
|
|
82
|
-
this.connectionAttempt += 1;
|
|
83
|
-
this.clearContextClient();
|
|
84
|
-
this.queryClientResolutionState = this.explicitClient
|
|
85
|
-
? 'bound'
|
|
86
|
-
: 'pre-connect';
|
|
87
|
-
this.onDisconnected();
|
|
88
|
-
if ('removeController' in this.host) {
|
|
89
|
-
this.host.removeController(this);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
tryGetQueryClient() {
|
|
93
|
-
return this.explicitClient ?? this.contextClient;
|
|
94
|
-
}
|
|
95
|
-
getQueryClient() {
|
|
96
|
-
const client = this.tryGetQueryClient();
|
|
97
|
-
if (!client) {
|
|
98
|
-
throw createMissingQueryClientError();
|
|
99
|
-
}
|
|
100
|
-
return client;
|
|
101
|
-
}
|
|
102
|
-
setResult(next) {
|
|
103
|
-
if (Object.is(this.result, next)) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
this.result = next;
|
|
107
|
-
if (!this.isHostUpdating) {
|
|
108
|
-
this.queueUpdate();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
get current() {
|
|
112
|
-
if (this.queryClientResolutionState === 'missing') {
|
|
113
|
-
throw createMissingQueryClientError();
|
|
114
|
-
}
|
|
115
|
-
return this.result;
|
|
116
|
-
}
|
|
117
|
-
get connectedState() {
|
|
118
|
-
return this.connected;
|
|
119
|
-
}
|
|
120
|
-
queueUpdate() {
|
|
121
|
-
if (this.updateQueued) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
this.updateQueued = true;
|
|
125
|
-
queueMicrotask(() => {
|
|
126
|
-
this.updateQueued = false;
|
|
127
|
-
if (!this.destroyed) {
|
|
128
|
-
this.host.requestUpdate();
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
queueQueryClientChanged() {
|
|
133
|
-
if (this.clientChangeQueued) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
this.clientChangeQueued = true;
|
|
137
|
-
queueMicrotask(() => {
|
|
138
|
-
this.clientChangeQueued = false;
|
|
139
|
-
if (!this.destroyed) {
|
|
140
|
-
this.onQueryClientChanged();
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
beginContextResolution() {
|
|
145
|
-
this.clearContextClient();
|
|
146
|
-
this.updateQueryClientResolutionState('awaiting-context');
|
|
147
|
-
}
|
|
148
|
-
queueContextResolution(attempt) {
|
|
149
|
-
queueMicrotask(() => {
|
|
150
|
-
if (this.destroyed ||
|
|
151
|
-
!this.connected ||
|
|
152
|
-
attempt !== this.connectionAttempt ||
|
|
153
|
-
this.queryClientResolutionState !== 'awaiting-context') {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
this.dispatchContextRequest(attempt);
|
|
157
|
-
this.queueInitialContextResolutionCompletion(attempt);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
dispatchContextRequest(attempt) {
|
|
161
|
-
if (!('dispatchEvent' in this.host)) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const contextTarget = this.host;
|
|
165
|
-
contextTarget.dispatchEvent(new ContextEvent(queryClientContext, contextTarget, (value, unsubscribe) => {
|
|
166
|
-
if (this.destroyed ||
|
|
167
|
-
!this.connected ||
|
|
168
|
-
attempt !== this.connectionAttempt) {
|
|
169
|
-
unsubscribe?.();
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
if (this.contextUnsubscribe &&
|
|
173
|
-
this.contextUnsubscribe !== unsubscribe) {
|
|
174
|
-
this.contextUnsubscribe();
|
|
175
|
-
}
|
|
176
|
-
const resolutionChanged = this.updateQueryClientResolutionState(value === undefined ? 'missing' : 'bound');
|
|
177
|
-
const clientChanged = this.contextClient !== value;
|
|
178
|
-
this.contextClient = value;
|
|
179
|
-
this.contextUnsubscribe = unsubscribe;
|
|
180
|
-
if (resolutionChanged || clientChanged) {
|
|
181
|
-
this.queueUpdate();
|
|
182
|
-
this.queueQueryClientChanged();
|
|
183
|
-
}
|
|
184
|
-
}, true));
|
|
185
|
-
}
|
|
186
|
-
queueInitialContextResolutionCompletion(attempt) {
|
|
187
|
-
queueMicrotask(() => {
|
|
188
|
-
if (this.destroyed ||
|
|
189
|
-
!this.connected ||
|
|
190
|
-
attempt !== this.connectionAttempt ||
|
|
191
|
-
this.queryClientResolutionState !== 'awaiting-context') {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
if (this.updateQueryClientResolutionState('missing')) {
|
|
195
|
-
this.queueUpdate();
|
|
196
|
-
this.queueQueryClientChanged();
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
clearContextClient() {
|
|
201
|
-
this.contextUnsubscribe?.();
|
|
202
|
-
this.contextUnsubscribe = undefined;
|
|
203
|
-
this.contextClient = undefined;
|
|
204
|
-
}
|
|
205
|
-
updateQueryClientResolutionState(nextState) {
|
|
206
|
-
if (this.queryClientResolutionState === nextState) {
|
|
207
|
-
return false;
|
|
208
|
-
}
|
|
209
|
-
this.queryClientResolutionState = nextState;
|
|
210
|
-
return true;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
//# sourceMappingURL=BaseController.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseController.js","sourceRoot":"","sources":["../../src/controllers/BaseController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C,OAAO,EACL,6BAA6B,EAC7B,kBAAkB,GACnB,MAAM,eAAe,CAAA;AAQtB,MAAM,OAAgB,cAAc;IAgBb;IAfX,MAAM,CAAS;IAER,cAAc,CAAc;IACrC,aAAa,CAAyB;IACtC,kBAAkB,CAA0B;IAE5C,SAAS,GAAG,KAAK,CAAA;IACjB,SAAS,GAAG,KAAK,CAAA;IACjB,YAAY,GAAG,KAAK,CAAA;IACpB,kBAAkB,GAAG,KAAK,CAAA;IAC1B,iBAAiB,GAAG,CAAC,CAAA;IACrB,cAAc,GAAG,KAAK,CAAA;IACtB,0BAA0B,CAA4B;IAE9D,YACqB,IAA4B,EAC/C,aAAsB,EACtB,WAAyB;QAFN,SAAI,GAAJ,IAAI,CAAwB;QAI/C,IAAI,CAAC,cAAc,GAAG,WAAW,CAAA;QACjC,IAAI,CAAC,MAAM,GAAG,aAAa,CAAA;QAC3B,IAAI,CAAC,0BAA0B,GAAG,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAA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