@nisli/core 0.54.0 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -3
- package/dist/component.js +146 -5
- package/dist/component.js.map +1 -1
- package/dist/diagnostics.d.ts +48 -0
- package/dist/diagnostics.js +118 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/disposable.d.ts +14 -0
- package/dist/disposable.js +8 -0
- package/dist/disposable.js.map +1 -0
- package/dist/emitter.d.ts +2 -1
- package/dist/emitter.js +2 -1
- package/dist/emitter.js.map +1 -1
- package/dist/hmr/registry.js +8 -1
- package/dist/hmr/registry.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/injector.d.ts +9 -2
- package/dist/injector.js +18 -0
- package/dist/injector.js.map +1 -1
- package/dist/lifecycle.d.ts +9 -0
- package/dist/lifecycle.js +17 -7
- package/dist/lifecycle.js.map +1 -1
- package/dist/projection.js +27 -10
- package/dist/projection.js.map +1 -1
- package/dist/query.d.ts +134 -55
- package/dist/query.js +379 -188
- package/dist/query.js.map +1 -1
- package/dist/resource.d.ts +2 -1
- package/dist/resource.js +21 -4
- package/dist/resource.js.map +1 -1
- package/dist/settle.d.ts +61 -0
- package/dist/settle.js +106 -0
- package/dist/settle.js.map +1 -0
- package/dist/signal.d.ts +42 -7
- package/dist/signal.js +248 -68
- package/dist/signal.js.map +1 -1
- package/dist/template-audit.d.ts +64 -0
- package/dist/template-audit.js +246 -0
- package/dist/template-audit.js.map +1 -0
- package/dist/template.d.ts +70 -1
- package/dist/template.js +477 -218
- package/dist/template.js.map +1 -1
- package/dist/view-transition.d.ts +70 -0
- package/dist/view-transition.js +98 -0
- package/dist/view-transition.js.map +1 -0
- package/package.json +1 -1
package/dist/query.js
CHANGED
|
@@ -1,238 +1,429 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* query.ts —
|
|
2
|
+
* query.ts — Keyed logical-request store (ADR 0030.2 T1).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* The cache unit is a per-key RECORD living in `QueryClient`:
|
|
5
|
+
* `{data, error, status, fetchedAt}` as signals, plus exactly one `run()`
|
|
6
|
+
* owning the retry loop, a per-run `AbortController` handed to the fetcher,
|
|
7
|
+
* and the cache commit. `query()` is a thin OBSERVER: an effect keeps it
|
|
8
|
+
* registered on the record its current key points at, and its outputs are
|
|
9
|
+
* `computed()` views over that record. Dedup unit = logical request, by
|
|
10
|
+
* construction (issues 0005–0009 close as a class).
|
|
8
11
|
*
|
|
9
12
|
* ```ts
|
|
10
13
|
* const tasks = query(
|
|
11
14
|
* () => ['tasks', scopeId.value],
|
|
12
|
-
* () => api.getTasks(scopeId.value),
|
|
15
|
+
* (signal) => api.getTasks(scopeId.value, { signal }),
|
|
13
16
|
* );
|
|
14
|
-
* tasks.data //
|
|
15
|
-
* tasks.loading //
|
|
16
|
-
* tasks.error //
|
|
17
|
-
* tasks.
|
|
17
|
+
* tasks.data // ReadonlySignal<Task[] | undefined>
|
|
18
|
+
* tasks.loading // ReadonlySignal<boolean>
|
|
19
|
+
* tasks.error // ReadonlySignal<Error | null>
|
|
20
|
+
* tasks.status // ReadonlySignal<'idle' | 'loading' | 'success' | 'error'>
|
|
21
|
+
* tasks.refetch() // force a refetch (joins an in-flight run)
|
|
22
|
+
* tasks.dispose() // standalone callers; component setup auto-disposes
|
|
18
23
|
* ```
|
|
24
|
+
*
|
|
25
|
+
* Ownership rules (ADR 0030.2 §8, binding):
|
|
26
|
+
* - The most-recently-mounted enabled observer's fetcher/options own the
|
|
27
|
+
* next run for a shared key; `staleTime` freshness is per-observer POLICY
|
|
28
|
+
* (it decides whether *that* observer triggers a run), while the record
|
|
29
|
+
* state is shared truth.
|
|
30
|
+
* - `invalidate()` marks records stale and reruns only records with ≥1
|
|
31
|
+
* enabled observer; disabled observers revalidate on re-enable.
|
|
32
|
+
* - A zero-observer record's in-flight run completes and commits.
|
|
33
|
+
* - Records are NEVER garbage-collected: the cache is unbounded for the
|
|
34
|
+
* life of the client (restates today's unbounded-cache bound). Bound it
|
|
35
|
+
* operationally with `clear()` or a fresh client per app lifetime.
|
|
36
|
+
*
|
|
37
|
+
* Key contract: keys are FLAT — `readonly (string|number|boolean|null)[]`.
|
|
38
|
+
* Objects and `undefined` are rejected with coded error N602 (`null` is
|
|
39
|
+
* the optional sentinel). Flat keys are order-sensitive: prefer
|
|
40
|
+
* per-endpoint key-builder helpers — a reordered key is a silent cache
|
|
41
|
+
* *miss*, benign relative to a collision, but a miss.
|
|
42
|
+
*
|
|
43
|
+
* SSG stance (documented, not built): under core-render, records fetch
|
|
44
|
+
* into the build-lifetime client and must TERMINATE before snapshot —
|
|
45
|
+
* `await settle()` is the barrier. Otherwise queries must be statically
|
|
46
|
+
* disabled for the build.
|
|
19
47
|
*/
|
|
20
|
-
import { signal, effect, computed } from './signal.js';
|
|
48
|
+
import { signal, effect, computed, untrack, } from './signal.js';
|
|
21
49
|
import { hasContext, getCurrentComponent } from './context.js';
|
|
50
|
+
import { disposable } from './disposable.js';
|
|
22
51
|
import { inject } from './injector.js';
|
|
52
|
+
import { __enrollPending } from './settle.js';
|
|
53
|
+
import { formatDiag } from './diagnostics.js';
|
|
54
|
+
// Diagnostics go through the core leaf (diagnostics.ts). Codes N602–N603
|
|
55
|
+
// belong to the query/async cluster (N601 retired before release — see
|
|
56
|
+
// the eliminated-class note below).
|
|
57
|
+
/** Build the coded error for key-contract violations. Always thrown —
|
|
58
|
+
* key validity is a contract, not an advisory diagnostic. */
|
|
59
|
+
function keyError(detail) {
|
|
60
|
+
return new Error(formatDiag('N602', `invalid query key: ${detail}. Keys must be flat `
|
|
61
|
+
+ 'readonly (string | number | boolean | null)[] arrays — spread '
|
|
62
|
+
+ 'object params into tuple elements; null is the optional sentinel.'));
|
|
63
|
+
}
|
|
23
64
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
65
|
+
* Validate a key against the flat contract and return a detached copy
|
|
66
|
+
* (callers may mutate their array; records must not observe that).
|
|
67
|
+
* Rejects objects, arrays, functions, undefined, and non-finite numbers
|
|
68
|
+
* (NaN/Infinity JSON-serialize as null and would collide) with N602.
|
|
26
69
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/** Check if a cache entry is fresh */
|
|
31
|
-
isFresh(key, staleTime) {
|
|
32
|
-
const entry = this.cache.get(key);
|
|
33
|
-
if (!entry)
|
|
34
|
-
return false;
|
|
35
|
-
return Date.now() - entry.fetchedAt < staleTime;
|
|
70
|
+
function validateKey(raw) {
|
|
71
|
+
if (!Array.isArray(raw)) {
|
|
72
|
+
throw keyError(`expected an array, got ${typeof raw}`);
|
|
36
73
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
74
|
+
for (let i = 0; i < raw.length; i++) {
|
|
75
|
+
const el = raw[i];
|
|
76
|
+
if (el === null)
|
|
77
|
+
continue;
|
|
78
|
+
const t = typeof el;
|
|
79
|
+
if (t === 'string' || t === 'boolean')
|
|
80
|
+
continue;
|
|
81
|
+
if (t === 'number') {
|
|
82
|
+
if (Number.isFinite(el))
|
|
83
|
+
continue;
|
|
84
|
+
throw keyError(`non-finite number at index ${i} (would collide with null)`);
|
|
85
|
+
}
|
|
86
|
+
if (el === undefined) {
|
|
87
|
+
throw keyError(`undefined at index ${i}`);
|
|
88
|
+
}
|
|
89
|
+
throw keyError(`${t} at index ${i}`);
|
|
40
90
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
91
|
+
return raw.slice();
|
|
92
|
+
}
|
|
93
|
+
/** THE one serializer: JSON.stringify of the validated flat array. */
|
|
94
|
+
function serializeKey(key) {
|
|
95
|
+
return JSON.stringify(key);
|
|
96
|
+
}
|
|
97
|
+
/** Element-wise prefix match over validated keys (=== is sound: elements
|
|
98
|
+
* are primitives and NaN is rejected by the contract). */
|
|
99
|
+
function matchesPrefix(key, prefix) {
|
|
100
|
+
if (prefix.length > key.length)
|
|
101
|
+
return false;
|
|
102
|
+
for (let i = 0; i < prefix.length; i++) {
|
|
103
|
+
if (key[i] !== prefix[i])
|
|
104
|
+
return false;
|
|
44
105
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
/** Monotonic mount counter — "most recently mounted" is decided by
|
|
109
|
+
* query() construction order, not re-registration order. */
|
|
110
|
+
let nextMountIndex = 0;
|
|
111
|
+
/** Read a record signal without tracking it into the ambient observer —
|
|
112
|
+
* the observer effect must depend on keys/enabled/version ONLY, never on
|
|
113
|
+
* record state (that is what keeps refetch loops unrepresentable). */
|
|
114
|
+
function peek(s) {
|
|
115
|
+
let v;
|
|
116
|
+
untrack(() => { v = s.value; });
|
|
117
|
+
return v;
|
|
118
|
+
}
|
|
119
|
+
function toError(cause) {
|
|
120
|
+
if (cause instanceof Error)
|
|
121
|
+
return cause;
|
|
122
|
+
try {
|
|
123
|
+
return new Error(String(cause));
|
|
48
124
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// Attach a catch handler to prevent unhandled rejection on the stored promise.
|
|
52
|
-
// Callers who await this promise get the original behavior from their own try/catch.
|
|
53
|
-
const handled = promise.catch(() => { });
|
|
54
|
-
this.inFlight.set(key, promise);
|
|
55
|
-
// Clean up when done
|
|
56
|
-
handled.finally(() => {
|
|
57
|
-
if (this.inFlight.get(key) === promise) {
|
|
58
|
-
this.inFlight.delete(key);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
125
|
+
catch {
|
|
126
|
+
return new Error('Unknown error');
|
|
61
127
|
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Global keyed logical-request store. One per app: resolved via
|
|
131
|
+
* `inject(QueryClient)` (auto-singleton; override with
|
|
132
|
+
* `provide(QueryClient, ...)` BEFORE the first query() call).
|
|
133
|
+
*
|
|
134
|
+
* Records are never GC'd — see the module doc for the bound.
|
|
135
|
+
*/
|
|
136
|
+
export class QueryClient {
|
|
137
|
+
/** @internal */ _records = new Map();
|
|
138
|
+
/** @internal clear() bumps this; observer effects track it and re-resolve. */
|
|
139
|
+
_version = signal(0);
|
|
140
|
+
/** @internal live observer count (N601 mixed-client diagnostic). */
|
|
141
|
+
_observers = 0;
|
|
62
142
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
143
|
+
* Mark records matching the key prefix stale and rerun those with ≥1
|
|
144
|
+
* enabled observer (using the owning observer's fetcher/options).
|
|
145
|
+
* Disabled observers revalidate on re-enable; a record with only
|
|
146
|
+
* disabled/no observers stays stale until one arrives. Returns the
|
|
147
|
+
* number of records invalidated.
|
|
65
148
|
*
|
|
66
|
-
* invalidate(['tasks']) matches ['tasks'], ['tasks', '1'], ['tasks', '2', 'x']
|
|
149
|
+
* invalidate(['tasks']) matches ['tasks'], ['tasks', '1'], ['tasks', '2', 'x'].
|
|
67
150
|
*/
|
|
68
151
|
invalidate(keyPrefix) {
|
|
152
|
+
const prefix = validateKey(keyPrefix);
|
|
69
153
|
let count = 0;
|
|
70
|
-
for (const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
catch {
|
|
79
|
-
// Skip invalid keys
|
|
80
|
-
}
|
|
154
|
+
for (const rec of this._records.values()) {
|
|
155
|
+
if (!matchesPrefix(rec.key, prefix))
|
|
156
|
+
continue;
|
|
157
|
+
count++;
|
|
158
|
+
rec.stale = true;
|
|
159
|
+
const owner = ownerOf(rec, /* requireEnabled */ true);
|
|
160
|
+
if (owner)
|
|
161
|
+
startRun(rec, owner.fetcher, owner.retry);
|
|
81
162
|
}
|
|
82
163
|
return count;
|
|
83
164
|
}
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const data = await fetcher();
|
|
90
|
-
this.set(serialized, data, staleTime);
|
|
91
|
-
}
|
|
92
|
-
/** Clear all cache */
|
|
165
|
+
/**
|
|
166
|
+
* Drop every record. In-flight runs are aborted (a settle() termination).
|
|
167
|
+
* Live observers re-resolve fresh records on the version bump — enabled
|
|
168
|
+
* ones revalidate immediately.
|
|
169
|
+
*/
|
|
93
170
|
clear() {
|
|
94
|
-
this.
|
|
95
|
-
|
|
171
|
+
for (const rec of this._records.values()) {
|
|
172
|
+
rec.generation++;
|
|
173
|
+
rec.controller?.abort();
|
|
174
|
+
rec.terminate?.();
|
|
175
|
+
rec.controller = null;
|
|
176
|
+
rec.terminate = null;
|
|
177
|
+
rec.runPromise = null;
|
|
178
|
+
rec.running = false;
|
|
179
|
+
rec.observers.clear();
|
|
180
|
+
}
|
|
181
|
+
this._records.clear();
|
|
182
|
+
this._version.value++;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Imperatively warm a record. Joins an in-flight run; a fresh record
|
|
186
|
+
* (per the given staleTime) is a no-op. Otherwise starts a run with THE
|
|
187
|
+
* GIVEN fetcher — an explicit imperative is its own owner. The run
|
|
188
|
+
* commits even with zero observers. Resolves at run termination.
|
|
189
|
+
*/
|
|
190
|
+
prefetch(key, fetcher, staleTime = 0) {
|
|
191
|
+
const rec = resolveRecord(this, key);
|
|
192
|
+
if (rec.running)
|
|
193
|
+
return rec.runPromise ?? Promise.resolve();
|
|
194
|
+
if (!rec.stale && peek(rec.status) === 'success' && staleTime > 0
|
|
195
|
+
&& Date.now() - peek(rec.fetchedAt) < staleTime) {
|
|
196
|
+
return Promise.resolve();
|
|
197
|
+
}
|
|
198
|
+
return startRun(rec, fetcher, 0);
|
|
96
199
|
}
|
|
97
200
|
}
|
|
98
|
-
|
|
99
|
-
function
|
|
100
|
-
|
|
201
|
+
/** Get-or-create the record for a key. Validation throws N602. */
|
|
202
|
+
function resolveRecord(client, rawKey) {
|
|
203
|
+
const key = validateKey(rawKey);
|
|
204
|
+
const serialized = serializeKey(key);
|
|
205
|
+
let rec = client._records.get(serialized);
|
|
206
|
+
if (!rec) {
|
|
207
|
+
rec = {
|
|
208
|
+
key,
|
|
209
|
+
serialized,
|
|
210
|
+
data: signal(undefined),
|
|
211
|
+
error: signal(null),
|
|
212
|
+
status: signal('idle'),
|
|
213
|
+
fetchedAt: signal(0),
|
|
214
|
+
stale: false,
|
|
215
|
+
running: false,
|
|
216
|
+
generation: 0,
|
|
217
|
+
controller: null,
|
|
218
|
+
runPromise: null,
|
|
219
|
+
terminate: null,
|
|
220
|
+
observers: new Set(),
|
|
221
|
+
};
|
|
222
|
+
client._records.set(serialized, rec); // never deleted — documented bound
|
|
223
|
+
}
|
|
224
|
+
return rec;
|
|
101
225
|
}
|
|
102
|
-
|
|
226
|
+
/** The observer whose fetcher/options own the next run: most recently
|
|
227
|
+
* mounted, preferring enabled observers (a disabled observer asked not
|
|
228
|
+
* to fetch — its fetcher should not fire). */
|
|
229
|
+
function ownerOf(rec, requireEnabled = false) {
|
|
230
|
+
let best;
|
|
231
|
+
let bestDisabled;
|
|
232
|
+
for (const obs of rec.observers) {
|
|
233
|
+
if (obs.enabled) {
|
|
234
|
+
if (!best || obs.mountIndex > best.mountIndex)
|
|
235
|
+
best = obs;
|
|
236
|
+
}
|
|
237
|
+
else if (!requireEnabled) {
|
|
238
|
+
if (!bestDisabled || obs.mountIndex > bestDisabled.mountIndex)
|
|
239
|
+
bestDisabled = obs;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return best ?? bestDisabled;
|
|
243
|
+
}
|
|
244
|
+
/** Does this record need a run, per THIS observer's freshness policy?
|
|
245
|
+
* Called only on real transitions (registration, re-enable, clear());
|
|
246
|
+
* record reads are untracked, so commits never re-trigger observers. */
|
|
247
|
+
function needsRun(rec, observer) {
|
|
248
|
+
if (rec.running)
|
|
249
|
+
return false; // join the in-flight logical request
|
|
250
|
+
if (rec.stale)
|
|
251
|
+
return true;
|
|
252
|
+
const status = peek(rec.status);
|
|
253
|
+
if (status === 'idle' || status === 'error')
|
|
254
|
+
return true;
|
|
255
|
+
if (observer.staleTime <= 0)
|
|
256
|
+
return true;
|
|
257
|
+
return Date.now() - peek(rec.fetchedAt) >= observer.staleTime;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* THE run: one logical request owning the retry loop and the commit.
|
|
261
|
+
* Supersedes (aborts) any in-flight run for the record. Enrolls in the
|
|
262
|
+
* settle() registry on start and terminates it at commit, terminal error,
|
|
263
|
+
* or abort — never at raw promise settlement.
|
|
264
|
+
*/
|
|
265
|
+
function startRun(rec, fetcher, retry) {
|
|
266
|
+
// Supersede: abort IS the superseded run's termination.
|
|
267
|
+
rec.controller?.abort();
|
|
268
|
+
rec.terminate?.();
|
|
269
|
+
const generation = ++rec.generation;
|
|
270
|
+
const controller = new AbortController();
|
|
271
|
+
const terminate = __enrollPending();
|
|
272
|
+
rec.controller = controller;
|
|
273
|
+
rec.terminate = terminate;
|
|
274
|
+
rec.running = true;
|
|
275
|
+
rec.stale = false;
|
|
276
|
+
rec.status.value = 'loading';
|
|
277
|
+
rec.error.value = null;
|
|
278
|
+
const run = (async () => {
|
|
279
|
+
try {
|
|
280
|
+
let lastError = null;
|
|
281
|
+
for (let attempt = 0; attempt <= retry; attempt++) {
|
|
282
|
+
if (generation !== rec.generation)
|
|
283
|
+
return; // superseded
|
|
284
|
+
try {
|
|
285
|
+
// The microtask hop makes a synchronous fetcher throw a normal
|
|
286
|
+
// rejection — it enters the same retry/terminal path (issue 0008).
|
|
287
|
+
const result = await Promise.resolve().then(() => fetcher(controller.signal));
|
|
288
|
+
if (generation !== rec.generation)
|
|
289
|
+
return;
|
|
290
|
+
rec.data.value = result;
|
|
291
|
+
rec.error.value = null;
|
|
292
|
+
rec.fetchedAt.value = Date.now();
|
|
293
|
+
rec.status.value = 'success';
|
|
294
|
+
return; // commit
|
|
295
|
+
}
|
|
296
|
+
catch (cause) {
|
|
297
|
+
lastError = toError(cause);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (generation !== rec.generation)
|
|
301
|
+
return;
|
|
302
|
+
rec.error.value = lastError;
|
|
303
|
+
rec.status.value = 'error'; // terminal error after retries
|
|
304
|
+
}
|
|
305
|
+
finally {
|
|
306
|
+
if (generation === rec.generation) {
|
|
307
|
+
rec.running = false;
|
|
308
|
+
rec.controller = null;
|
|
309
|
+
rec.runPromise = null;
|
|
310
|
+
rec.terminate = null;
|
|
311
|
+
}
|
|
312
|
+
terminate(); // idempotent — superseded runs already terminated at abort
|
|
313
|
+
}
|
|
314
|
+
})();
|
|
315
|
+
rec.runPromise = run;
|
|
316
|
+
return run;
|
|
317
|
+
}
|
|
318
|
+
// ── Mixed clients: an eliminated class (formerly N601) ──────────────
|
|
319
|
+
// With inject() as the single resolution path, the only way two clients
|
|
320
|
+
// could mix was provide(QueryClient, ...) landing after queries already
|
|
321
|
+
// bound the auto-created singleton. The injector now throws N501 at that
|
|
322
|
+
// exact provide() (DI freeze, ADR 0030.2 T6), so the split-brain state is
|
|
323
|
+
// unrepresentable in dev and was always silent in prod — the symptom-side
|
|
324
|
+
// warning this block used to hold (N601) died with its cause. Retired
|
|
325
|
+
// before release; the code number is not reused.
|
|
326
|
+
// ── query() — the thin observer ─────────────────────────────────────
|
|
103
327
|
/**
|
|
104
|
-
*
|
|
328
|
+
* Observe the record the reactive key points at.
|
|
105
329
|
*
|
|
106
|
-
* @param keyFn - Returns
|
|
107
|
-
*
|
|
108
|
-
* @param
|
|
330
|
+
* @param keyFn - Returns the flat cache key. Signal reads are tracked; a
|
|
331
|
+
* key change re-registers the observer on the new record.
|
|
332
|
+
* @param fetcher - Fetches the data; receives the run's AbortSignal.
|
|
333
|
+
* @param options - staleTime / retry / enabled / initialData.
|
|
334
|
+
* @throws N602 synchronously when the initial key violates the contract.
|
|
109
335
|
*/
|
|
110
336
|
export function query(keyFn, fetcher, options = {}) {
|
|
111
|
-
const { staleTime = 0, retry = 0, enabled, initialData
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
337
|
+
const { staleTime = 0, retry = 0, enabled, initialData } = options;
|
|
338
|
+
const client = inject(QueryClient);
|
|
339
|
+
// Surface key-contract violations at the call site: the observer effect
|
|
340
|
+
// is error-contained (a later reactive key going invalid is logged with
|
|
341
|
+
// the same coded message), so the construction-time key must be checked
|
|
342
|
+
// synchronously. untrack: query() may run under an ambient observer
|
|
343
|
+
// (component setup) and key signals must not widen its dependencies.
|
|
344
|
+
untrack(() => { validateKey(keyFn()); });
|
|
345
|
+
const observer = {
|
|
346
|
+
mountIndex: nextMountIndex++,
|
|
347
|
+
fetcher: fetcher,
|
|
348
|
+
staleTime,
|
|
349
|
+
retry,
|
|
350
|
+
enabled: true,
|
|
351
|
+
record: null,
|
|
352
|
+
};
|
|
353
|
+
client._observers++;
|
|
354
|
+
const recSig = signal(null);
|
|
355
|
+
const enabledSig = signal(true);
|
|
126
356
|
let disposed = false;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
|
|
134
|
-
const doFetch = async (force = false) => {
|
|
357
|
+
let prevEnabled = null;
|
|
358
|
+
let prevVersion = -1;
|
|
359
|
+
// The registration effect — depends on keyFn signals, enabled() signals,
|
|
360
|
+
// and the client version. NEVER on record state (all record reads are
|
|
361
|
+
// untracked), so commits cannot re-trigger it: run starts happen only on
|
|
362
|
+
// the real transitions listed in needsRun()'s doc.
|
|
363
|
+
const stopEffect = effect(() => {
|
|
135
364
|
if (disposed)
|
|
136
365
|
return;
|
|
137
|
-
|
|
138
|
-
if (enabled && !enabled())
|
|
139
|
-
return;
|
|
366
|
+
const version = client._version.value;
|
|
140
367
|
const key = keyFn();
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
368
|
+
const on = enabled ? !!enabled() : true;
|
|
369
|
+
const rec = resolveRecord(client, key);
|
|
370
|
+
observer.enabled = on;
|
|
371
|
+
enabledSig.value = on;
|
|
372
|
+
const moved = rec !== observer.record;
|
|
373
|
+
if (moved) {
|
|
374
|
+
observer.record?.observers.delete(observer);
|
|
375
|
+
rec.observers.add(observer);
|
|
376
|
+
observer.record = rec;
|
|
377
|
+
if (initialData !== undefined && peek(rec.status) === 'idle'
|
|
378
|
+
&& peek(rec.data) === undefined) {
|
|
379
|
+
rec.data.value = initialData; // seed; not a fetch — status stays idle
|
|
149
380
|
}
|
|
381
|
+
recSig.value = rec;
|
|
150
382
|
}
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
data.value = result;
|
|
159
|
-
error.value = null;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
catch (e) {
|
|
163
|
-
if (generation === fetchGeneration && !disposed) {
|
|
164
|
-
error.value = e instanceof Error ? e : new Error(String(e));
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
finally {
|
|
168
|
-
if (generation === fetchGeneration && !disposed) {
|
|
169
|
-
loading.value = false;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
loading.value = true;
|
|
175
|
-
error.value = null;
|
|
176
|
-
let lastError = null;
|
|
177
|
-
const attempts = retry + 1;
|
|
178
|
-
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
179
|
-
if (disposed || generation !== fetchGeneration)
|
|
180
|
-
return;
|
|
181
|
-
const promise = fetcher();
|
|
182
|
-
// Prevent unhandled rejection on the shared in-flight reference
|
|
183
|
-
promise.catch(() => { });
|
|
184
|
-
client.setInFlight(serialized, promise);
|
|
185
|
-
try {
|
|
186
|
-
const result = await promise;
|
|
187
|
-
// Guard against stale responses
|
|
188
|
-
if (generation === fetchGeneration && !disposed) {
|
|
189
|
-
data.value = result;
|
|
190
|
-
error.value = null;
|
|
191
|
-
loading.value = false;
|
|
192
|
-
client.set(serialized, result, staleTime);
|
|
193
|
-
onSuccess?.(result);
|
|
194
|
-
}
|
|
195
|
-
return; // success
|
|
196
|
-
}
|
|
197
|
-
catch (e) {
|
|
198
|
-
lastError = e instanceof Error ? e : new Error(String(e));
|
|
199
|
-
// Continue to next retry attempt
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
// All retries exhausted
|
|
203
|
-
if (generation === fetchGeneration && !disposed) {
|
|
204
|
-
error.value = lastError;
|
|
205
|
-
loading.value = false;
|
|
206
|
-
if (lastError)
|
|
207
|
-
onError?.(lastError);
|
|
383
|
+
const reEnabled = prevEnabled === false && on;
|
|
384
|
+
const versionChanged = version !== prevVersion;
|
|
385
|
+
prevEnabled = on;
|
|
386
|
+
prevVersion = version;
|
|
387
|
+
if (on && (moved || reEnabled || versionChanged) && needsRun(rec, observer)) {
|
|
388
|
+
const owner = ownerOf(rec) ?? observer;
|
|
389
|
+
startRun(rec, owner.fetcher, owner.retry);
|
|
208
390
|
}
|
|
209
|
-
};
|
|
210
|
-
// Auto-fetch on mount and when dependencies change
|
|
211
|
-
const disposeEffect = effect(() => {
|
|
212
|
-
// Reading keyFn() inside the effect tracks signal dependencies
|
|
213
|
-
const _key = keyFn();
|
|
214
|
-
// Also track enabled()
|
|
215
|
-
if (enabled)
|
|
216
|
-
enabled();
|
|
217
|
-
// Schedule the async fetch — catch to prevent unhandled promise rejection
|
|
218
|
-
doFetch().catch(() => { });
|
|
219
391
|
});
|
|
220
|
-
|
|
392
|
+
const dispose = () => {
|
|
393
|
+
if (disposed)
|
|
394
|
+
return;
|
|
395
|
+
disposed = true;
|
|
396
|
+
observer.record?.observers.delete(observer);
|
|
397
|
+
observer.record = null;
|
|
398
|
+
client._observers--;
|
|
399
|
+
stopEffect();
|
|
400
|
+
// NOTE: no abort — a zero-observer in-flight run completes and commits.
|
|
401
|
+
};
|
|
221
402
|
if (hasContext()) {
|
|
222
|
-
getCurrentComponent().addDisposer(
|
|
223
|
-
disposed = true;
|
|
224
|
-
disposeEffect();
|
|
225
|
-
});
|
|
403
|
+
getCurrentComponent().addDisposer(dispose);
|
|
226
404
|
}
|
|
227
405
|
const refetch = () => {
|
|
228
|
-
|
|
229
|
-
|
|
406
|
+
if (disposed)
|
|
407
|
+
return;
|
|
408
|
+
const rec = observer.record;
|
|
409
|
+
if (!rec || !observer.enabled)
|
|
410
|
+
return;
|
|
411
|
+
if (rec.running)
|
|
412
|
+
return; // join the in-flight logical request (dedup)
|
|
413
|
+
const owner = ownerOf(rec) ?? observer;
|
|
414
|
+
startRun(rec, owner.fetcher, owner.retry);
|
|
230
415
|
};
|
|
231
|
-
|
|
232
|
-
data
|
|
233
|
-
|
|
234
|
-
|
|
416
|
+
const result = {
|
|
417
|
+
data: computed(() => {
|
|
418
|
+
const rec = recSig.value;
|
|
419
|
+
return (rec ? rec.data.value : initialData);
|
|
420
|
+
}),
|
|
421
|
+
loading: computed(() => enabledSig.value && recSig.value?.status.value === 'loading'),
|
|
422
|
+
error: computed(() => recSig.value?.error.value ?? null),
|
|
423
|
+
status: computed(() => recSig.value?.status.value ?? 'idle'),
|
|
235
424
|
refetch,
|
|
425
|
+
dispose,
|
|
236
426
|
};
|
|
427
|
+
return disposable(result, dispose);
|
|
237
428
|
}
|
|
238
429
|
//# sourceMappingURL=query.js.map
|
package/dist/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAoC,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,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