@tanstack/lit-query 0.2.26 → 0.2.27

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/lit-query",
3
- "version": "0.2.26",
3
+ "version": "0.2.27",
4
4
  "description": "Lit adapter for TanStack Query Core",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -40,28 +40,29 @@
40
40
  ],
41
41
  "dependencies": {
42
42
  "@lit/context": "^1.1.6",
43
- "@tanstack/query-core": "5.104.1",
43
+ "@tanstack/query-core": "5.104.2",
44
44
  "lit": "^3.3.3"
45
45
  },
46
46
  "devDependencies": {
47
+ "@lit-labs/ssr": "^3.3.1",
47
48
  "@tanstack/query-test-utils": "0.0.0",
48
49
  "typescript": "6.0.3"
49
50
  },
50
51
  "peerDependencies": {
51
- "@tanstack/query-core": "^5.104.1",
52
+ "@tanstack/query-core": "^5.104.2",
52
53
  "lit": ">=2.8.0 <4"
53
54
  },
54
55
  "scripts": {
55
56
  "clean": "premove ./build ./coverage ./dist-ts ./.cache/test-types",
56
57
  "compile": "tsc --project tsconfig.json",
57
- "test:eslint": "eslint --concurrency=auto ./src",
58
+ "test:oxlint": "oxlint ./src",
58
59
  "test:types": "npm-run-all --serial test:types:*",
59
- "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts56 --tsBuildInfoFile .cache/test-types/ts56.tsbuildinfo",
60
60
  "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts57 --tsBuildInfoFile .cache/test-types/ts57.tsbuildinfo",
61
61
  "test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts58 --tsBuildInfoFile .cache/test-types/ts58.tsbuildinfo",
62
62
  "test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts59 --tsBuildInfoFile .cache/test-types/ts59.tsbuildinfo",
63
63
  "test:types:tscurrent": "tsc --project tsconfig.json --outDir .cache/test-types/tscurrent --tsBuildInfoFile .cache/test-types/tscurrent.tsbuildinfo",
64
64
  "test:types:ts70": "node ../../node_modules/typescript70/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts70 --tsBuildInfoFile .cache/test-types/ts70.tsbuildinfo",
65
+ "test:types:ts71": "node ../../node_modules/typescript71/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts71 --tsBuildInfoFile .cache/test-types/ts71.tsbuildinfo",
65
66
  "test:lib": "vitest",
66
67
  "test:lib:dev": "pnpm run test:lib --watch",
67
68
  "test:build": "publint --strict && attw --pack",
@@ -21,7 +21,6 @@ import type { TemplateResult } from 'lit'
21
21
  * This class is not registered as a custom element by the package. Applications
22
22
  * must register either a subclass or the class itself with
23
23
  * `customElements.define`.
24
- *
25
24
  * @example
26
25
  * ```ts
27
26
  * import { html, LitElement } from 'lit'
@@ -44,7 +43,6 @@ import type { TemplateResult } from 'lit'
44
43
  * }
45
44
  * }
46
45
  * ```
47
- *
48
46
  * @example
49
47
  * ```ts
50
48
  * import { html } from 'lit'
@@ -63,7 +61,7 @@ import type { TemplateResult } from 'lit'
63
61
  */
64
62
  export class QueryClientProvider extends LitElement {
65
63
  /** @internal */
66
- static properties = {
64
+ static override properties = {
67
65
  client: { attribute: false },
68
66
  }
69
67
 
@@ -86,28 +84,43 @@ export class QueryClientProvider extends LitElement {
86
84
  })
87
85
  }
88
86
 
89
- /** @internal */
90
- connectedCallback(): void {
87
+ /**
88
+ * Provides the client to descendants and mounts it when the element is
89
+ * connected.
90
+ * @internal
91
+ */
92
+ override connectedCallback(): void {
91
93
  super.connectedCallback()
92
94
  const client = this.requireClient()
93
95
  this.contextProvider.setValue(client)
94
96
  this.mountClient(client)
95
97
  }
96
98
 
97
- /** @internal */
98
- disconnectedCallback(): void {
99
+ /**
100
+ * Unmounts the client when the element is disconnected.
101
+ * @internal
102
+ */
103
+ override disconnectedCallback(): void {
99
104
  this.unmountClient(this.mountedClient)
100
105
  super.disconnectedCallback()
101
106
  }
102
107
 
103
- /** @internal */
104
- protected willUpdate(changedProperties: Map<PropertyKey, unknown>): void {
108
+ /**
109
+ * Swaps the provided and mounted client when `client` changes.
110
+ * @internal
111
+ * @param changedProperties - The properties that changed. When `client` changes, the previous
112
+ * client is unmounted and the new one is provided and mounted.
113
+ * @throws {Error} If `client` is unset while the provider is connected.
114
+ */
115
+ protected override willUpdate(
116
+ changedProperties: Map<PropertyKey, unknown>,
117
+ ): void {
105
118
  if (!changedProperties.has('client')) {
106
119
  return
107
120
  }
108
121
 
109
122
  const nextClient = this.client
110
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
123
+ // oxlint-disable-next-line typescript/no-unnecessary-condition
111
124
  if (!nextClient) {
112
125
  if (this.isConnected) {
113
126
  this.unmountClient(this.mountedClient)
@@ -120,7 +133,8 @@ export class QueryClientProvider extends LitElement {
120
133
  }
121
134
 
122
135
  const previousClient = changedProperties.get('client') as
123
- QueryClient | undefined
136
+ | QueryClient
137
+ | undefined
124
138
  if (previousClient && previousClient !== nextClient && this.isConnected) {
125
139
  this.unmountClient(previousClient)
126
140
  }
@@ -132,8 +146,12 @@ export class QueryClientProvider extends LitElement {
132
146
  }
133
147
  }
134
148
 
135
- /** @internal */
136
- render(): TemplateResult {
149
+ /**
150
+ * Renders the provider's children.
151
+ * @internal
152
+ * @returns A `<slot>` that renders the provider's children.
153
+ */
154
+ override render(): TemplateResult {
137
155
  return html`<slot></slot>`
138
156
  }
139
157
 
@@ -165,7 +183,7 @@ export class QueryClientProvider extends LitElement {
165
183
  }
166
184
 
167
185
  private requireClient(): QueryClient {
168
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
186
+ // oxlint-disable-next-line typescript/no-unnecessary-condition
169
187
  if (!this.client) {
170
188
  throw createMissingQueryClientError()
171
189
  }
package/src/accessor.ts CHANGED
@@ -3,7 +3,6 @@
3
3
  *
4
4
  * Lit Query APIs read function accessors during host updates, so the getter can
5
5
  * depend on reactive host state.
6
- *
7
6
  * @example
8
7
  * ```ts
9
8
  * const staticKey: Accessor<readonly unknown[]> = ['todos']
@@ -12,6 +11,11 @@
12
11
  */
13
12
  export type Accessor<T> = T | (() => T)
14
13
 
14
+ /**
15
+ * Reads an {@link Accessor}: calls it if it is a function, otherwise returns it as is.
16
+ * @param value - The value, or a getter that returns it.
17
+ * @returns The value.
18
+ */
15
19
  export function readAccessor<T>(value: Accessor<T>): T {
16
20
  return typeof value === 'function' ? (value as () => T)() : value
17
21
  }
@@ -22,7 +26,6 @@ export function readAccessor<T>(value: Accessor<T>): T {
22
26
  *
23
27
  * Controller creators and cache state helpers return this shape so render code
24
28
  * can use either `result()` or `result.current`.
25
- *
26
29
  * @example
27
30
  * ```ts
28
31
  * const query = this.todos()
@@ -33,6 +36,12 @@ export type ValueAccessor<T> = (() => T) & {
33
36
  readonly current: T
34
37
  }
35
38
 
39
+ /**
40
+ * Creates a {@link ValueAccessor} that reads its value from `getter`, both when called and through
41
+ * its `current` property.
42
+ * @param getter - Returns the latest value.
43
+ * @returns A function that returns the latest value, which is also available on `current`.
44
+ */
36
45
  export function createValueAccessor<T>(getter: () => T): ValueAccessor<T> {
37
46
  const accessor = (() => getter()) as ValueAccessor<T>
38
47
  Object.defineProperty(accessor, 'current', {
package/src/context.ts CHANGED
@@ -26,7 +26,6 @@ let defaultClient: QueryClient | undefined
26
26
  *
27
27
  * `QueryClientProvider` calls this automatically while it is connected. Prefer
28
28
  * passing an explicit client or rendering under a provider when possible.
29
- *
30
29
  * @param client - The query client to register as the current default.
31
30
  */
32
31
  export function registerDefaultQueryClient(client: QueryClient): void {
@@ -39,7 +38,6 @@ export function registerDefaultQueryClient(client: QueryClient): void {
39
38
  * `registerDefaultQueryClient`.
40
39
  *
41
40
  * `QueryClientProvider` calls this automatically when it disconnects.
42
- *
43
41
  * @param client - The query client registration to release.
44
42
  */
45
43
  export function unregisterDefaultQueryClient(client: QueryClient): void {
@@ -65,7 +63,6 @@ export function unregisterDefaultQueryClient(client: QueryClient): void {
65
63
  /**
66
64
  * Returns the registered default `QueryClient`, if exactly one default client is
67
65
  * available.
68
- *
69
66
  * @returns The default query client, or `undefined` when there is no registered
70
67
  * client or more than one registered client.
71
68
  */
@@ -77,10 +74,19 @@ export function getDefaultQueryClient(): QueryClient | undefined {
77
74
  return defaultClient
78
75
  }
79
76
 
77
+ /**
78
+ * Creates the error thrown when no `QueryClient` is available.
79
+ * @returns A new `Error` explaining that no `QueryClient` is available.
80
+ */
80
81
  export function createMissingQueryClientError(): Error {
81
82
  return new Error(missingQueryClientMessage)
82
83
  }
83
84
 
85
+ /**
86
+ * Creates the error thrown when multiple `QueryClient`s are mounted and the default one would be
87
+ * ambiguous.
88
+ * @returns A new `Error` explaining that the default `QueryClient` is ambiguous.
89
+ */
84
90
  function createAmbiguousQueryClientError(): Error {
85
91
  return new Error(ambiguousQueryClientMessage)
86
92
  }
@@ -92,8 +98,9 @@ function createAmbiguousQueryClientError(): Error {
92
98
  * This helper is useful outside a Lit reactive controller when a single
93
99
  * provider is mounted. It throws if no client is registered or if multiple
94
100
  * clients are mounted and the default would be ambiguous.
95
- *
96
101
  * @returns The single registered query client.
102
+ * @throws {Error} If no `QueryClient` is registered, or if multiple are
103
+ * mounted and the default is ambiguous.
97
104
  */
98
105
  export function useQueryClient(): QueryClient {
99
106
  const client = getDefaultQueryClient()
@@ -110,7 +117,6 @@ export function useQueryClient(): QueryClient {
110
117
 
111
118
  /**
112
119
  * Resolves an explicit `QueryClient` or falls back to `useQueryClient`.
113
- *
114
120
  * @param explicit - Optional client supplied by the caller.
115
121
  * @returns The explicit client when provided, otherwise the current default
116
122
  * client.
@@ -7,8 +7,17 @@ import type { QueryClient } from '@tanstack/query-core'
7
7
  import type { ReactiveController, ReactiveControllerHost } from 'lit'
8
8
 
9
9
  type QueryClientResolutionState =
10
- 'pre-connect' | 'awaiting-context' | 'bound' | 'missing'
11
-
10
+ | 'pre-connect'
11
+ | 'awaiting-context'
12
+ | 'bound'
13
+ | 'missing'
14
+
15
+ /**
16
+ * Base class of the query controllers. It resolves the `QueryClient`, either
17
+ * passed explicitly or provided through context by a `QueryClientProvider`,
18
+ * follows the host's lifecycle, and requests a host update when the result
19
+ * changes.
20
+ */
12
21
  export abstract class BaseController<TResult> implements ReactiveController {
13
22
  protected result: TResult
14
23
 
@@ -36,6 +45,11 @@ export abstract class BaseController<TResult> implements ReactiveController {
36
45
  host.addController(this)
37
46
  }
38
47
 
48
+ /**
49
+ * Starts resolving the `QueryClient` from context, unless one was passed
50
+ * explicitly, and calls `onConnected` in a microtask so subclass fields are
51
+ * initialized first.
52
+ */
39
53
  hostConnected(): void {
40
54
  if (this.connected || this.destroyed) {
41
55
  return
@@ -69,6 +83,10 @@ export abstract class BaseController<TResult> implements ReactiveController {
69
83
  }
70
84
  }
71
85
 
86
+ /**
87
+ * Releases the context `QueryClient`, unless one was passed explicitly, and
88
+ * calls `onDisconnected`.
89
+ */
72
90
  hostDisconnected(): void {
73
91
  if (!this.connected) {
74
92
  return
@@ -85,6 +103,10 @@ export abstract class BaseController<TResult> implements ReactiveController {
85
103
  this.onDisconnected()
86
104
  }
87
105
 
106
+ /**
107
+ * Calls `onHostUpdate` before the host renders. Results set during this call
108
+ * don't request another update.
109
+ */
88
110
  hostUpdate(): void {
89
111
  if (this.destroyed) {
90
112
  return
@@ -98,6 +120,11 @@ export abstract class BaseController<TResult> implements ReactiveController {
98
120
  }
99
121
  }
100
122
 
123
+ /**
124
+ * Permanently disconnects the controller and removes it from its host, if
125
+ * the host supports `removeController`. The controller ignores later
126
+ * lifecycle callbacks.
127
+ */
101
128
  destroy(): void {
102
129
  if (this.destroyed) {
103
130
  return
@@ -117,10 +144,20 @@ export abstract class BaseController<TResult> implements ReactiveController {
117
144
  }
118
145
  }
119
146
 
147
+ /**
148
+ * Returns the `QueryClient` without throwing when none is available.
149
+ * @returns The explicitly passed client, otherwise the client from context,
150
+ * or `undefined` if neither is available.
151
+ */
120
152
  protected tryGetQueryClient(): QueryClient | undefined {
121
153
  return this.explicitClient ?? this.contextClient
122
154
  }
123
155
 
156
+ /**
157
+ * Returns the `QueryClient`, throwing when none is available.
158
+ * @returns The explicitly passed client, otherwise the client from context.
159
+ * @throws {Error} If no `QueryClient` is available.
160
+ */
124
161
  protected getQueryClient(): QueryClient {
125
162
  const client = this.tryGetQueryClient()
126
163
  if (!client) {
@@ -130,6 +167,11 @@ export abstract class BaseController<TResult> implements ReactiveController {
130
167
  return client
131
168
  }
132
169
 
170
+ /**
171
+ * Stores a new result and requests a host update, unless it is the same
172
+ * result or the host is already updating.
173
+ * @param next - The new result.
174
+ */
133
175
  protected setResult(next: TResult): void {
134
176
  if (Object.is(this.result, next)) {
135
177
  return
@@ -141,6 +183,11 @@ export abstract class BaseController<TResult> implements ReactiveController {
141
183
  }
142
184
  }
143
185
 
186
+ /**
187
+ * The latest result of the controller.
188
+ * @returns The latest result.
189
+ * @throws {Error} If no `QueryClient` could be resolved from context.
190
+ */
144
191
  get current(): TResult {
145
192
  if (this.queryClientResolutionState === 'missing') {
146
193
  throw createMissingQueryClientError()
@@ -149,10 +196,17 @@ export abstract class BaseController<TResult> implements ReactiveController {
149
196
  return this.result
150
197
  }
151
198
 
199
+ /**
200
+ * Whether the controller's host is connected.
201
+ * @returns `true` while the host is connected.
202
+ */
152
203
  protected get connectedState(): boolean {
153
204
  return this.connected
154
205
  }
155
206
 
207
+ /**
208
+ * Requests a host update in a microtask, batching multiple calls into one.
209
+ */
156
210
  protected queueUpdate(): void {
157
211
  if (this.updateQueued) {
158
212
  return
@@ -230,7 +284,7 @@ export abstract class BaseController<TResult> implements ReactiveController {
230
284
  }
231
285
 
232
286
  const resolutionChanged = this.updateQueryClientResolutionState(
233
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
287
+ // oxlint-disable-next-line typescript/no-unnecessary-condition
234
288
  value === undefined ? 'missing' : 'bound',
235
289
  )
236
290
  const clientChanged = this.contextClient !== value
@@ -283,8 +337,26 @@ export abstract class BaseController<TResult> implements ReactiveController {
283
337
  return true
284
338
  }
285
339
 
340
+ /**
341
+ * Called in a microtask after the host connects, once the subclass fields
342
+ * are initialized. Subclasses subscribe to the `QueryClient` here, if one is
343
+ * available.
344
+ */
286
345
  protected abstract onConnected(): void
346
+ /**
347
+ * Called when the host disconnects or the controller is destroyed.
348
+ * Subclasses unsubscribe here.
349
+ */
287
350
  protected abstract onDisconnected(): void
351
+ /**
352
+ * Called before each host update. Subclasses refresh their options here.
353
+ */
288
354
  protected abstract onHostUpdate(): void
355
+ /**
356
+ * Called in a microtask when the `QueryClient` from context changes, or when
357
+ * resolving it finishes without finding one (`tryGetQueryClient` then returns
358
+ * `undefined`). Subclasses resubscribe to the new client here, if there is
359
+ * one.
360
+ */
289
361
  protected abstract onQueryClientChanged(): void
290
362
  }
@@ -58,6 +58,11 @@ export type InfiniteQueryResultAccessor<TData, TError> = ValueAccessor<
58
58
  destroy: () => void
59
59
  }
60
60
 
61
+ /**
62
+ * Returns the result used while no `QueryClient` is available: `'pending'` and idle, with methods
63
+ * that reject with the missing client error.
64
+ * @returns A new result object in that state.
65
+ */
61
66
  function createPendingInfiniteQueryResult<
62
67
  TData,
63
68
  TError,
@@ -164,7 +169,7 @@ class InfiniteQueryController<
164
169
  this.assignObserverResult(observer.getOptimisticResult(defaulted))
165
170
  }
166
171
 
167
- protected onConnected(): void {
172
+ protected override onConnected(): void {
168
173
  if (!this.syncClient()) {
169
174
  return
170
175
  }
@@ -177,12 +182,12 @@ class InfiniteQueryController<
177
182
  }
178
183
  }
179
184
 
180
- protected onDisconnected(): void {
185
+ protected override onDisconnected(): void {
181
186
  this.unsubscribeObserver()
182
187
  this.syncClient()
183
188
  }
184
189
 
185
- protected onHostUpdate(): void {
190
+ protected override onHostUpdate(): void {
186
191
  if (typeof this.options !== 'function') {
187
192
  return
188
193
  }
@@ -190,7 +195,7 @@ class InfiniteQueryController<
190
195
  this.refreshOptions()
191
196
  }
192
197
 
193
- protected onQueryClientChanged(): void {
198
+ protected override onQueryClientChanged(): void {
194
199
  if (!this.syncClient() || !this.connectedState) {
195
200
  return
196
201
  }
@@ -360,7 +365,6 @@ class InfiniteQueryController<
360
365
  *
361
366
  * If `queryClient` is omitted, the controller resolves the client from the
362
367
  * nearest connected `QueryClientProvider`.
363
- *
364
368
  * @param host - The Lit reactive controller host that owns the infinite query
365
369
  * subscription.
366
370
  * @param options - Infinite query observer options, or a getter that returns
@@ -369,7 +373,6 @@ class InfiniteQueryController<
369
373
  * controllers that should not resolve a client from Lit context.
370
374
  * @returns An accessor for the latest infinite query result with page helper
371
375
  * methods.
372
- *
373
376
  * @example
374
377
  * ```ts
375
378
  * import { LitElement, html } from 'lit'
@@ -67,6 +67,11 @@ export type MutationResultAccessor<TData, TError, TVariables, TOnMutateResult> =
67
67
  destroy: () => void
68
68
  }
69
69
 
70
+ /**
71
+ * Returns the result used while no `QueryClient` is available: `'idle'`, with a `mutate` that
72
+ * rejects with the missing client error.
73
+ * @returns A new result object in that state.
74
+ */
70
75
  function createIdleMutationResult<
71
76
  TData,
72
77
  TError,
@@ -104,7 +109,8 @@ class MutationController<
104
109
  CreateMutationOptions<TData, TError, TVariables, TOnMutateResult>
105
110
  >
106
111
  private observer:
107
- MutationObserver<TData, TError, TVariables, TOnMutateResult> | undefined
112
+ | MutationObserver<TData, TError, TVariables, TOnMutateResult>
113
+ | undefined
108
114
  private unsubscribe: (() => void) | undefined
109
115
  private queryClient: QueryClient | undefined
110
116
 
@@ -135,7 +141,7 @@ class MutationController<
135
141
  this.result = observer.getCurrentResult()
136
142
  }
137
143
 
138
- protected onConnected(): void {
144
+ protected override onConnected(): void {
139
145
  if (!this.syncClient()) {
140
146
  return
141
147
  }
@@ -147,12 +153,12 @@ class MutationController<
147
153
  }
148
154
  }
149
155
 
150
- protected onDisconnected(): void {
156
+ protected override onDisconnected(): void {
151
157
  this.unsubscribeObserver()
152
158
  this.syncClient()
153
159
  }
154
160
 
155
- protected onHostUpdate(): void {
161
+ protected override onHostUpdate(): void {
156
162
  if (typeof this.options !== 'function') {
157
163
  return
158
164
  }
@@ -160,7 +166,7 @@ class MutationController<
160
166
  this.refreshOptions()
161
167
  }
162
168
 
163
- protected onQueryClientChanged(): void {
169
+ protected override onQueryClientChanged(): void {
164
170
  if (!this.syncClient() || !this.connectedState) {
165
171
  return
166
172
  }
@@ -287,7 +293,6 @@ class MutationController<
287
293
  *
288
294
  * If `queryClient` is omitted, the controller resolves the client from the
289
295
  * nearest connected `QueryClientProvider`.
290
- *
291
296
  * @param host - The Lit reactive controller host that owns the mutation
292
297
  * subscription.
293
298
  * @param options - Mutation observer options, or a getter that returns options.
@@ -295,7 +300,6 @@ class MutationController<
295
300
  * controllers that should not resolve a client from Lit context.
296
301
  * @returns An accessor for the latest mutation result with mutation helper
297
302
  * methods.
298
- *
299
303
  * @example
300
304
  * ```ts
301
305
  * import { LitElement, html } from 'lit'
@@ -216,6 +216,11 @@ export type QueriesResultAccessor<TCombinedResult> =
216
216
  destroy: () => void
217
217
  }
218
218
 
219
+ /**
220
+ * Returns the result used while no `QueryClient` is available: `'pending'` and idle, with methods
221
+ * that reject with the missing client error.
222
+ * @returns A new result object in that state.
223
+ */
219
224
  function createPendingQueryObserverResult(): QueryObserverResult {
220
225
  return {
221
226
  data: undefined,
@@ -249,6 +254,12 @@ function createPendingQueryObserverResult(): QueryObserverResult {
249
254
  } as unknown as QueryObserverResult
250
255
  }
251
256
 
257
+ /**
258
+ * Returns the result of a query used while no `QueryClient` is available: a `'success'` result with
259
+ * the query's `initialData` (after `select`), or the pending result if there is no `initialData`.
260
+ * @param query - The query options.
261
+ * @returns The `'success'` result with `initialData`, or a pending one.
262
+ */
252
263
  function createPlaceholderQueryObserverResult(
253
264
  query: QueryObserverOptions,
254
265
  ): QueryObserverResult {
@@ -279,6 +290,12 @@ function createPlaceholderQueryObserverResult(
279
290
  } as QueryObserverResult
280
291
  }
281
292
 
293
+ /**
294
+ * Reads the controller's options and defaults each query with the client.
295
+ * @param optionsAccessor - The options, or a getter that returns them.
296
+ * @param client - The client used to default the query options.
297
+ * @returns The defaulted query options and the `combine` function.
298
+ */
282
299
  function resolveQueriesOptions<TCombinedResult>(
283
300
  optionsAccessor: Accessor<
284
301
  CreateQueriesControllerOptions<any, TCombinedResult>
@@ -349,7 +366,7 @@ class QueriesController<
349
366
  this.tryInitializeExplicitClient(queryClient)
350
367
  }
351
368
 
352
- protected onConnected(): void {
369
+ protected override onConnected(): void {
353
370
  if (!this.syncClient()) {
354
371
  return
355
372
  }
@@ -358,12 +375,12 @@ class QueriesController<
358
375
  this.subscribe()
359
376
  }
360
377
 
361
- protected onDisconnected(): void {
378
+ protected override onDisconnected(): void {
362
379
  this.unsubscribeObserver()
363
380
  this.syncClient()
364
381
  }
365
382
 
366
- protected onHostUpdate(): void {
383
+ protected override onHostUpdate(): void {
367
384
  if (!this.shouldRefreshOnHostUpdate()) {
368
385
  return
369
386
  }
@@ -373,7 +390,7 @@ class QueriesController<
373
390
  }
374
391
  }
375
392
 
376
- protected onQueryClientChanged(): void {
393
+ protected override onQueryClientChanged(): void {
377
394
  if (!this.syncClient() || !this.connectedState) {
378
395
  return
379
396
  }
@@ -659,7 +676,6 @@ class QueriesController<
659
676
  *
660
677
  * If `queryClient` is omitted, the controller resolves the client from the
661
678
  * nearest connected `QueryClientProvider`.
662
- *
663
679
  * @param host - The Lit reactive controller host that owns the queries
664
680
  * subscription.
665
681
  * @param options - Queries controller options, or a getter that returns options.
@@ -667,7 +683,6 @@ class QueriesController<
667
683
  * controllers that should not resolve a client from Lit context.
668
684
  * @returns An accessor for the latest query results, or the value returned by
669
685
  * `combine`.
670
- *
671
686
  * @example
672
687
  * ```ts
673
688
  * import { LitElement, html } from 'lit'
@@ -46,6 +46,11 @@ export type QueryResultAccessor<TData, TError> = ValueAccessor<
46
46
  destroy: () => void
47
47
  }
48
48
 
49
+ /**
50
+ * Returns the result used while no `QueryClient` is available: `'pending'` and idle, with methods
51
+ * that reject with the missing client error.
52
+ * @returns A new result object in that state.
53
+ */
49
54
  function createPendingQueryResult<TData, TError>(): QueryObserverResult<
50
55
  TData,
51
56
  TError
@@ -128,7 +133,7 @@ class QueryController<
128
133
  this.assignObserverResult(observer.getOptimisticResult(defaulted))
129
134
  }
130
135
 
131
- protected onConnected(): void {
136
+ protected override onConnected(): void {
132
137
  if (!this.syncClient()) {
133
138
  return
134
139
  }
@@ -141,12 +146,12 @@ class QueryController<
141
146
  }
142
147
  }
143
148
 
144
- protected onDisconnected(): void {
149
+ protected override onDisconnected(): void {
145
150
  this.unsubscribeObserver()
146
151
  this.syncClient()
147
152
  }
148
153
 
149
- protected onHostUpdate(): void {
154
+ protected override onHostUpdate(): void {
150
155
  if (typeof this.options !== 'function') {
151
156
  return
152
157
  }
@@ -154,7 +159,7 @@ class QueryController<
154
159
  this.refreshOptions()
155
160
  }
156
161
 
157
- protected onQueryClientChanged(): void {
162
+ protected override onQueryClientChanged(): void {
158
163
  if (!this.syncClient()) {
159
164
  return
160
165
  }
@@ -312,14 +317,12 @@ class QueryController<
312
317
  *
313
318
  * If `queryClient` is omitted, the controller resolves the client from the
314
319
  * nearest connected `QueryClientProvider`.
315
- *
316
320
  * @param host - The Lit reactive controller host that owns the query
317
321
  * subscription.
318
322
  * @param options - Query observer options, or a getter that returns options.
319
323
  * @param queryClient - Optional explicit query client. Provide this for
320
324
  * controllers that should not resolve a client from Lit context.
321
325
  * @returns An accessor for the latest query result with query helper methods.
322
- *
323
326
  * @example
324
327
  * ```ts
325
328
  * import { LitElement, html } from 'lit'