@askrjs/askr 0.2.3 → 0.3.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/CHANGELOG.md +11 -0
- package/dist/access-CEA2pOry.js +1046 -0
- package/dist/actions/index.d.ts +16 -2
- package/dist/actions/index.js +5 -5
- package/dist/{activity-ZxJXI9hF.js → activity-oy2YFTFF.js} +22 -16
- package/dist/benchmark.js +8 -9
- package/dist/boot/index.d.ts +21 -9
- package/dist/boot/index.js +1 -1
- package/dist/{boot-D4GaLA0d.js → boot-BMBMWUGI.js} +680 -440
- package/dist/capabilities-Bbf0mlp9.js +42 -0
- package/dist/components/index.d.ts +11 -8
- package/dist/components/index.js +1 -1
- package/dist/{compose-ref-Bfaf4kUC.js → compose-ref-v0qGlHoN.js} +7 -1
- package/dist/control/index.d.ts +20 -2
- package/dist/control/index.js +1 -1
- package/dist/{control-57x3wa4J.js → control-BR_mrX__.js} +4 -4
- package/dist/core.d.ts +163 -0
- package/dist/csp-nonce-BfFWcd0w.js +173 -0
- package/dist/data/index.d.ts +74 -2
- package/dist/data/index.js +3 -3
- package/dist/{data-B7XCDeC8.js → data-2edW0jhF.js} +133 -138
- package/dist/{data-runtime-7t_Y0iv3.js → data-runtime-CxoY98lX.js} +22 -15
- package/dist/{deferred-BELyvMsC.js → deferred-CbgNhf67.js} +5 -5
- package/dist/dom-renderer.d.ts +77 -0
- package/dist/domains/actions.d.ts +70 -0
- package/dist/domains/component.d.ts +119 -0
- package/dist/domains/context.d.ts +73 -0
- package/dist/domains/control.d.ts +328 -0
- package/dist/domains/data.d.ts +461 -0
- package/dist/domains/diagnostics.d.ts +21 -0
- package/dist/domains/lifecycle.d.ts +112 -0
- package/dist/domains/refs.d.ts +18 -0
- package/dist/domains/renderer.d.ts +127 -0
- package/dist/domains/routing.d.ts +501 -0
- package/dist/domains/scheduler.d.ts +79 -0
- package/dist/domains/server.d.ts +112 -0
- package/dist/domains/state.d.ts +129 -0
- package/dist/domains/telemetry.d.ts +29 -0
- package/dist/eager-control.d.ts +8 -0
- package/dist/{effect-4LwBwV58.js → effect-C3Zsc1k6.js} +14 -41
- package/dist/{types-DkVJhVs9.d.ts → elements.d.ts} +84 -42
- package/dist/{for-internal-DeoSg_AV.js → for-state-BDykeOJL.js} +623 -511
- package/dist/foundations/icon/index.d.ts +67 -16
- package/dist/foundations/icon/index.js +1 -1
- package/dist/foundations/index.d.ts +26 -3
- package/dist/foundations/index.js +1 -1
- package/dist/foundations/interactions/index.d.ts +73 -34
- package/dist/foundations/interactions/index.js +1 -1
- package/dist/foundations/state/index.d.ts +12 -5
- package/dist/foundations/state/index.js +1 -1
- package/dist/foundations/structures/index.d.ts +44 -3
- package/dist/foundations/structures/index.js +1 -1
- package/dist/foundations/utilities/index.d.ts +34 -3
- package/dist/foundations/utilities/index.js +1 -1
- package/dist/fx/index.d.ts +72 -25
- package/dist/fx/index.js +8 -8
- package/dist/index.d.ts +121 -4
- package/dist/index.js +316 -47
- package/dist/{component-internal-Dl02WQKS.js → instance-VAFYVJOa.js} +495 -283
- package/dist/{interactions-D102JxBR.js → interactions-CTeACdT_.js} +1 -1
- package/dist/jsx-dev-runtime.d.ts +51 -11
- package/dist/jsx-globals.d.ts +2 -0
- package/dist/jsx-runtime-CPJXAOBF.js +43 -0
- package/dist/jsx-runtime.d.ts +17 -3
- package/dist/jsx-runtime.js +2 -42
- package/dist/jsx.d.ts +108 -0
- package/dist/{manifest-D6rfj_jC.js → manifest-D1P3UNWV.js} +4 -9
- package/dist/{navigate-C46GtScG.js → navigate-prC5V8XV.js} +204 -476
- package/dist/{navigate-wel1e6cU.d.ts → navigation.d.ts} +10 -8
- package/dist/{readable-CEcteIDE.js → notify-DxxuDPeY.js} +96 -34
- package/dist/{query-registry-Bua3cDyb.js → query-registry-LrYpQsDJ.js} +1 -1
- package/dist/{compose-ref-DOJHoW5X.d.ts → refs.d.ts} +11 -7
- package/dist/{ssr-BaC5qHEw.js → render-resolved-BC0W7_5b.js} +165 -558
- package/dist/{renderer-BhXofszH.js → renderer-CT0HeY58.js} +6866 -5715
- package/dist/{resolution-t8J0yNaU.js → resolution-3DskUkjG.js} +189 -180
- package/dist/{resource-operation-B8q-QRUx.js → resource-18-sFRl9.js} +98 -58
- package/dist/resources/index.d.ts +64 -46
- package/dist/resources/index.js +215 -9
- package/dist/route-activity.d.ts +21 -0
- package/dist/{route-matching-Bo6UqG-5.js → route-matching-CUzZ31gT.js} +68 -82
- package/dist/router/index.d.ts +378 -79
- package/dist/router/index.js +9 -9
- package/dist/router-internal-7nuNEHfG.js +36 -0
- package/dist/scope-Cq_iYbTR.js +403 -0
- package/dist/{selector-C7rIpOnN.js → selector-BSPVkjKP.js} +41 -41
- package/dist/{shared-CGrx2AOL.js → shared-kU8yvryp.js} +3 -6
- package/dist/{snapshot-source-BB42xgwb.js → snapshot-source-An4iKajG.js} +1 -1
- package/dist/ssg/index.d.ts +51 -15
- package/dist/ssg/index.js +269 -209
- package/dist/ssr/index.d.ts +121 -68
- package/dist/ssr/index.js +2 -1
- package/dist/ssr-CiNm6Vzl.js +393 -0
- package/dist/{ssr-DSHd_Q9K.js → ssr-EPjwJH5R.js} +5 -1
- package/dist/{state-BzhOW2TX.js → state-BXJfudq1.js} +10 -15
- package/dist/{structures-BwfeO4Iz.js → structures-CjEzfj4h.js} +37 -57
- package/dist/{index-r5THqzPN.d.ts → structures.d.ts} +57 -36
- package/dist/testing/index.d.ts +125 -24
- package/dist/testing/index.js +26 -62
- package/dist/timer-C7uqnJVt.js +85 -0
- package/dist/{index-B1gu0_m0.d.ts → utilities.d.ts} +24 -13
- package/dist/{verify-hydration-_Q6avFp0.js → verify-hydration-ikaxotf7.js} +8 -5
- package/package.json +13 -15
- package/dist/access-Rr7CMa06.js +0 -507
- package/dist/activity-CAJ5eho-.d.ts +0 -14
- package/dist/benchmark.d.ts +0 -26
- package/dist/cleanup-DsrbV-rr.js +0 -535
- package/dist/component-cleanup-DjpwO9WX.js +0 -143
- package/dist/component-scope-4I3yEMkb.js +0 -195
- package/dist/control-DdFw-Caz.d.ts +0 -8
- package/dist/csp-nonce-C9OuML0U.js +0 -72
- package/dist/css-BuPaTOfe.js +0 -70
- package/dist/fastlane-Buz1Rvlr.js +0 -166
- package/dist/index-DSqXWc77.d.ts +0 -1402
- package/dist/jsx-runtime-BTzDdBJ_.d.ts +0 -2
- package/dist/jsx-runtime-Cdd6Gkb0.d.ts +0 -38
- package/dist/lifecycle-batch-Be-CLDjV.js +0 -253
- package/dist/lifecycle-operations-C5m03NQc.js +0 -195
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { d as getCurrentAppRenderRuntime, f as getCurrentComponentInstance, i as claimHookIndex } from "./
|
|
3
|
-
import {
|
|
1
|
+
import { b as ScheduledWork, f as requestRuntimeWork, v as logger } from "./access-CEA2pOry.js";
|
|
2
|
+
import { d as getCurrentAppRenderRuntime, f as getCurrentComponentInstance, i as claimHookIndex } from "./scope-Cq_iYbTR.js";
|
|
3
|
+
import { a as ownComponentCleanup, r as getComponentLifetimeIdentity } from "./capabilities-Bbf0mlp9.js";
|
|
4
|
+
import { v as recordReadableRead } from "./notify-DxxuDPeY.js";
|
|
4
5
|
import { n as getActiveRenderContext } from "./render-context-B7ohlh6t.js";
|
|
5
|
-
import {
|
|
6
|
-
import { a as getMutationSlotStore, c as resolveDataRuntimeState, i as getDefaultDataRuntime, n as ensureMutationCleanup, o as getQuerySlotStore, r as ensureQueryCleanup, s as invalidateQueriesForRuntime } from "./data-runtime-
|
|
7
|
-
import { a as normalizeAsyncDataError, i as isCurrentAsyncOperation, n as isAbortError, o as notifySource, t as createReadableSource } from "./shared-
|
|
6
|
+
import { a as routeActive, i as windowFocused, n as documentVisible, t as timer } from "./timer-C7uqnJVt.js";
|
|
7
|
+
import { a as getMutationSlotStore, c as resolveDataRuntimeState, i as getDefaultDataRuntime, n as ensureMutationCleanup, o as getQuerySlotStore, r as ensureQueryCleanup, s as invalidateQueriesForRuntime } from "./data-runtime-CxoY98lX.js";
|
|
8
|
+
import { a as normalizeAsyncDataError, i as isCurrentAsyncOperation, n as isAbortError, o as notifySource, t as createReadableSource } from "./shared-kU8yvryp.js";
|
|
8
9
|
//#region src/data/query-key.ts
|
|
9
10
|
function serializeQueryKeyNumber(part) {
|
|
10
11
|
if (Number.isNaN(part)) return "NaN";
|
|
@@ -219,16 +220,84 @@ function createMutation(options) {
|
|
|
219
220
|
return created;
|
|
220
221
|
}
|
|
221
222
|
//#endregion
|
|
223
|
+
//#region src/data/query-state.ts
|
|
224
|
+
/** Complete query states; transitions never inherit unrelated status flags. */
|
|
225
|
+
function loadingQueryState() {
|
|
226
|
+
return {
|
|
227
|
+
data: null,
|
|
228
|
+
error: null,
|
|
229
|
+
loading: true,
|
|
230
|
+
refreshing: false,
|
|
231
|
+
stale: false,
|
|
232
|
+
consistency: "fresh",
|
|
233
|
+
staleReason: null
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function freshQueryState(data) {
|
|
237
|
+
return {
|
|
238
|
+
data,
|
|
239
|
+
error: null,
|
|
240
|
+
loading: false,
|
|
241
|
+
refreshing: false,
|
|
242
|
+
stale: false,
|
|
243
|
+
consistency: "fresh",
|
|
244
|
+
staleReason: null
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function refreshingQueryState(data, consistency = "refreshing") {
|
|
248
|
+
return {
|
|
249
|
+
data,
|
|
250
|
+
error: null,
|
|
251
|
+
loading: false,
|
|
252
|
+
refreshing: true,
|
|
253
|
+
stale: true,
|
|
254
|
+
consistency,
|
|
255
|
+
staleReason: null
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function staleQueryState(data, reason) {
|
|
259
|
+
return {
|
|
260
|
+
data,
|
|
261
|
+
error: null,
|
|
262
|
+
loading: false,
|
|
263
|
+
refreshing: false,
|
|
264
|
+
stale: true,
|
|
265
|
+
consistency: "stale",
|
|
266
|
+
staleReason: reason
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function errorQueryState(data, error) {
|
|
270
|
+
return {
|
|
271
|
+
data,
|
|
272
|
+
error,
|
|
273
|
+
loading: false,
|
|
274
|
+
refreshing: false,
|
|
275
|
+
stale: true,
|
|
276
|
+
consistency: "stale",
|
|
277
|
+
staleReason: "error"
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
222
281
|
//#region src/data/query-cell.ts
|
|
223
282
|
const RECONCILE_MAX_ATTEMPTS = 3;
|
|
224
283
|
const RECONCILE_RETRY_DELAY_MS = 25;
|
|
284
|
+
var QueryStartWork = class extends ScheduledWork {
|
|
285
|
+
constructor(run, settle) {
|
|
286
|
+
super(run);
|
|
287
|
+
this.settle = settle;
|
|
288
|
+
}
|
|
289
|
+
cancel() {
|
|
290
|
+
super.cancel();
|
|
291
|
+
this.settle();
|
|
292
|
+
}
|
|
293
|
+
};
|
|
225
294
|
var QueryCell = class {
|
|
226
295
|
constructor(options, key, cache) {
|
|
227
296
|
this.source = createReadableSource();
|
|
228
297
|
this.controller = null;
|
|
229
298
|
this.generation = 0;
|
|
230
|
-
this.startQueued = false;
|
|
231
299
|
this.pendingRefresh = null;
|
|
300
|
+
this.pendingRefreshKind = null;
|
|
232
301
|
this.pendingRefreshResolve = null;
|
|
233
302
|
this.pendingRefreshToken = 0;
|
|
234
303
|
this.reconcileAttemptCount = 0;
|
|
@@ -237,27 +306,11 @@ var QueryCell = class {
|
|
|
237
306
|
this.ownerCount = 0;
|
|
238
307
|
this.owners = /* @__PURE__ */ new Map();
|
|
239
308
|
this.warnedDefinitionConflictKeys = /* @__PURE__ */ new Set();
|
|
240
|
-
this.state =
|
|
241
|
-
data: null,
|
|
242
|
-
error: null,
|
|
243
|
-
loading: true,
|
|
244
|
-
refreshing: false,
|
|
245
|
-
stale: false,
|
|
246
|
-
consistency: "fresh",
|
|
247
|
-
staleReason: null
|
|
248
|
-
};
|
|
309
|
+
this.state = loadingQueryState();
|
|
249
310
|
this.options = options;
|
|
250
311
|
this.key = key;
|
|
251
312
|
this.cache = cache;
|
|
252
|
-
if (options.initialData !== void 0) this.state =
|
|
253
|
-
data: options.initialData,
|
|
254
|
-
error: null,
|
|
255
|
-
loading: false,
|
|
256
|
-
refreshing: false,
|
|
257
|
-
stale: false,
|
|
258
|
-
consistency: "fresh",
|
|
259
|
-
staleReason: null
|
|
260
|
-
};
|
|
313
|
+
if (options.initialData !== void 0) this.state = freshQueryState(options.initialData);
|
|
261
314
|
}
|
|
262
315
|
attach(generation, hookIndex) {
|
|
263
316
|
let hooks = this.owners.get(generation);
|
|
@@ -290,7 +343,6 @@ var QueryCell = class {
|
|
|
290
343
|
this.destroyed = true;
|
|
291
344
|
this.controller?.abort();
|
|
292
345
|
this.controller = null;
|
|
293
|
-
this.startQueued = false;
|
|
294
346
|
this.reconcileAttemptCount = 0;
|
|
295
347
|
this.ownerCount = 0;
|
|
296
348
|
this.owners.clear();
|
|
@@ -334,74 +386,75 @@ var QueryCell = class {
|
|
|
334
386
|
}
|
|
335
387
|
/** @internal Whether a collection should schedule this cell's first load. */
|
|
336
388
|
needsInitialStart() {
|
|
337
|
-
return !this.destroyed && this.state.data === null && this.state.error === null && !this.pendingRefresh
|
|
389
|
+
return !this.destroyed && this.state.data === null && this.state.error === null && !this.pendingRefresh;
|
|
338
390
|
}
|
|
339
391
|
ensureStarted() {
|
|
340
|
-
if (this.destroyed || this.state.data !== null || this.pendingRefresh || this.
|
|
341
|
-
this.queueStart();
|
|
392
|
+
if (this.destroyed || this.state.data !== null || this.pendingRefresh || this.options.skipInitialFetch) return;
|
|
393
|
+
this.queueStart(void 0, "initial");
|
|
342
394
|
}
|
|
343
395
|
refresh() {
|
|
344
396
|
if (this.destroyed) return Promise.resolve();
|
|
345
|
-
if (this.pendingRefresh)
|
|
346
|
-
|
|
397
|
+
if (this.pendingRefresh) {
|
|
398
|
+
if (this.pendingRefreshKind === "invalidation") {
|
|
399
|
+
this.controller?.abort();
|
|
400
|
+
this.queueStart(void 0, "manual", true);
|
|
401
|
+
return this.pendingRefresh ?? Promise.resolve();
|
|
402
|
+
} else return this.pendingRefresh;
|
|
403
|
+
}
|
|
404
|
+
this.queueStart(void 0, "manual");
|
|
347
405
|
return this.pendingRefresh ?? Promise.resolve();
|
|
348
406
|
}
|
|
349
407
|
invalidate() {
|
|
350
408
|
if (this.destroyed) return;
|
|
351
409
|
if (this.pendingRefresh) {
|
|
352
410
|
this.controller?.abort();
|
|
353
|
-
this.
|
|
411
|
+
this.queueStart(void 0, "invalidation", true);
|
|
412
|
+
return;
|
|
354
413
|
}
|
|
355
|
-
this.queueStart();
|
|
414
|
+
this.queueStart(void 0, "invalidation");
|
|
356
415
|
}
|
|
357
416
|
markPendingWrite() {
|
|
358
417
|
if (this.destroyed) return;
|
|
359
418
|
if (this.state.data === null) return;
|
|
360
|
-
this.setState(
|
|
361
|
-
loading: false,
|
|
362
|
-
error: null,
|
|
363
|
-
refreshing: true,
|
|
364
|
-
stale: true,
|
|
365
|
-
consistency: "pending-write",
|
|
366
|
-
staleReason: null
|
|
367
|
-
});
|
|
419
|
+
this.setState(refreshingQueryState(this.state.data, "pending-write"));
|
|
368
420
|
}
|
|
369
|
-
queueStart(reconcileSequence) {
|
|
421
|
+
queueStart(reconcileSequence, kind = "manual", continuePending = false) {
|
|
370
422
|
if (this.destroyed) return;
|
|
371
423
|
const sequence = reconcileSequence ?? (() => {
|
|
372
424
|
this.reconcileAttemptCount = 0;
|
|
373
425
|
return ++this.reconcileSequence;
|
|
374
426
|
})();
|
|
375
|
-
this.
|
|
427
|
+
this.pendingRefreshKind = kind;
|
|
376
428
|
const token = ++this.pendingRefreshToken;
|
|
377
|
-
this.pendingRefresh = new Promise((resolve) => {
|
|
429
|
+
if (!continuePending || !this.pendingRefresh) this.pendingRefresh = new Promise((resolve) => {
|
|
378
430
|
this.pendingRefreshResolve = resolve;
|
|
379
|
-
enqueueRuntimeTask(() => {
|
|
380
|
-
if (token !== this.pendingRefreshToken) return;
|
|
381
|
-
this.startQueued = false;
|
|
382
|
-
if (this.destroyed) {
|
|
383
|
-
this.finishPendingRefresh(token);
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
this.start(sequence).finally(() => {
|
|
387
|
-
this.finishPendingRefresh(token);
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
431
|
});
|
|
432
|
+
requestRuntimeWork("component", new QueryStartWork(() => {
|
|
433
|
+
if (token !== this.pendingRefreshToken) return;
|
|
434
|
+
if (this.destroyed) {
|
|
435
|
+
this.finishPendingRefresh(token);
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
this.start(sequence).finally(() => {
|
|
439
|
+
this.finishPendingRefresh(token);
|
|
440
|
+
});
|
|
441
|
+
}, () => {
|
|
442
|
+
if (token !== this.pendingRefreshToken) return;
|
|
443
|
+
this.generation += 1;
|
|
444
|
+
this.finishPendingRefresh(token);
|
|
445
|
+
}));
|
|
391
446
|
}
|
|
392
447
|
finishPendingRefresh(token = this.pendingRefreshToken) {
|
|
393
448
|
if (token !== this.pendingRefreshToken) return;
|
|
394
449
|
const resolve = this.pendingRefreshResolve;
|
|
395
450
|
this.pendingRefresh = null;
|
|
451
|
+
this.pendingRefreshKind = null;
|
|
396
452
|
this.pendingRefreshResolve = null;
|
|
397
453
|
resolve?.();
|
|
398
454
|
}
|
|
399
455
|
setState(next) {
|
|
400
456
|
if (this.destroyed) return;
|
|
401
|
-
this.state =
|
|
402
|
-
...this.state,
|
|
403
|
-
...next
|
|
404
|
-
};
|
|
457
|
+
this.state = next;
|
|
405
458
|
notifySource(this.source);
|
|
406
459
|
}
|
|
407
460
|
async start(reconcileSequence) {
|
|
@@ -412,45 +465,17 @@ var QueryCell = class {
|
|
|
412
465
|
const controller = new AbortController();
|
|
413
466
|
this.controller = controller;
|
|
414
467
|
const hasData = this.state.data !== null;
|
|
415
|
-
this.setState(
|
|
416
|
-
loading: !hasData,
|
|
417
|
-
refreshing: hasData,
|
|
418
|
-
stale: hasData,
|
|
419
|
-
consistency: hasData ? "refreshing" : "fresh",
|
|
420
|
-
error: null,
|
|
421
|
-
staleReason: null
|
|
422
|
-
});
|
|
468
|
+
this.setState(hasData ? refreshingQueryState(this.state.data) : loadingQueryState());
|
|
423
469
|
let nextData;
|
|
424
470
|
try {
|
|
425
471
|
nextData = await this.options.fetch({ signal: controller.signal });
|
|
426
472
|
} catch (error) {
|
|
427
473
|
if (this.destroyed || !isCurrentAsyncOperation(this.generation, generation, this.controller, controller)) return;
|
|
428
474
|
if (isAbortError(error, controller.signal)) {
|
|
429
|
-
this.setState(hasData ?
|
|
430
|
-
loading: false,
|
|
431
|
-
refreshing: false,
|
|
432
|
-
stale: true,
|
|
433
|
-
consistency: "stale",
|
|
434
|
-
error: null,
|
|
435
|
-
staleReason: "aborted"
|
|
436
|
-
} : {
|
|
437
|
-
loading: true,
|
|
438
|
-
refreshing: false,
|
|
439
|
-
stale: false,
|
|
440
|
-
consistency: "fresh",
|
|
441
|
-
error: null,
|
|
442
|
-
staleReason: null
|
|
443
|
-
});
|
|
475
|
+
this.setState(hasData ? staleQueryState(this.state.data, "aborted") : loadingQueryState());
|
|
444
476
|
return;
|
|
445
477
|
}
|
|
446
|
-
this.setState(
|
|
447
|
-
loading: false,
|
|
448
|
-
refreshing: false,
|
|
449
|
-
stale: true,
|
|
450
|
-
consistency: "stale",
|
|
451
|
-
error: normalizeAsyncDataError(error, "Unknown query error"),
|
|
452
|
-
staleReason: "error"
|
|
453
|
-
});
|
|
478
|
+
this.setState(errorQueryState(this.state.data, normalizeAsyncDataError(error, "Unknown query error")));
|
|
454
479
|
return;
|
|
455
480
|
}
|
|
456
481
|
if (this.destroyed || !isCurrentAsyncOperation(this.generation, generation, this.controller, controller)) return;
|
|
@@ -458,66 +483,32 @@ var QueryCell = class {
|
|
|
458
483
|
try {
|
|
459
484
|
isConsistent = this.options.isConsistent?.(nextData) ?? true;
|
|
460
485
|
} catch (error) {
|
|
461
|
-
this.setState(
|
|
462
|
-
loading: false,
|
|
463
|
-
refreshing: false,
|
|
464
|
-
stale: true,
|
|
465
|
-
consistency: "stale",
|
|
466
|
-
error: normalizeAsyncDataError(error, "Query consistency check failed"),
|
|
467
|
-
staleReason: "error"
|
|
468
|
-
});
|
|
486
|
+
this.setState(errorQueryState(this.state.data, normalizeAsyncDataError(error, "Query consistency check failed")));
|
|
469
487
|
return;
|
|
470
488
|
}
|
|
471
489
|
if (!isConsistent) {
|
|
472
|
-
this.setState(
|
|
473
|
-
data: nextData,
|
|
474
|
-
loading: false,
|
|
475
|
-
refreshing: false,
|
|
476
|
-
stale: true,
|
|
477
|
-
consistency: "stale",
|
|
478
|
-
staleReason: "inconsistent"
|
|
479
|
-
});
|
|
490
|
+
this.setState(staleQueryState(nextData, "inconsistent"));
|
|
480
491
|
try {
|
|
481
492
|
await this.reconcile(nextData, generation, controller, reconcileSequence);
|
|
482
493
|
} catch (error) {
|
|
483
|
-
if (isCurrentAsyncOperation(this.generation, generation, this.controller, controller)) this.setState(
|
|
484
|
-
loading: false,
|
|
485
|
-
refreshing: false,
|
|
486
|
-
stale: true,
|
|
487
|
-
consistency: "stale",
|
|
488
|
-
error: normalizeAsyncDataError(error, "Query reconciliation failed"),
|
|
489
|
-
staleReason: "error"
|
|
490
|
-
});
|
|
494
|
+
if (isCurrentAsyncOperation(this.generation, generation, this.controller, controller)) this.setState(errorQueryState(this.state.data, normalizeAsyncDataError(error, "Query reconciliation failed")));
|
|
491
495
|
}
|
|
492
496
|
return;
|
|
493
497
|
}
|
|
494
498
|
this.reconcileAttemptCount = 0;
|
|
495
|
-
this.setState(
|
|
496
|
-
data: nextData,
|
|
497
|
-
loading: false,
|
|
498
|
-
refreshing: false,
|
|
499
|
-
stale: false,
|
|
500
|
-
consistency: "fresh",
|
|
501
|
-
error: null,
|
|
502
|
-
staleReason: null
|
|
503
|
-
});
|
|
499
|
+
this.setState(freshQueryState(nextData));
|
|
504
500
|
}
|
|
505
501
|
async reconcile(data, generation, controller, reconcileSequence) {
|
|
506
502
|
if (!await (this.options.reconcile?.(data, { key: this.options.key }) ?? false) || this.destroyed || reconcileSequence !== this.reconcileSequence || !isCurrentAsyncOperation(this.generation, generation, this.controller, controller)) return;
|
|
507
503
|
this.reconcileAttemptCount += 1;
|
|
508
504
|
if (this.reconcileAttemptCount > RECONCILE_MAX_ATTEMPTS) {
|
|
509
|
-
this.setState(
|
|
510
|
-
consistency: "stale",
|
|
511
|
-
refreshing: false,
|
|
512
|
-
staleReason: "inconsistent"
|
|
513
|
-
});
|
|
505
|
+
this.setState(staleQueryState(this.state.data, "inconsistent"));
|
|
514
506
|
return;
|
|
515
507
|
}
|
|
516
508
|
await new Promise((resolve) => setTimeout(resolve, RECONCILE_RETRY_DELAY_MS));
|
|
517
509
|
if (this.destroyed || reconcileSequence !== this.reconcileSequence || this.state.consistency === "fresh" || !isCurrentAsyncOperation(this.generation, generation, this.controller, controller)) return;
|
|
518
510
|
this.controller?.abort();
|
|
519
|
-
this.
|
|
520
|
-
this.queueStart(reconcileSequence);
|
|
511
|
+
this.queueStart(reconcileSequence, "reconcile", true);
|
|
521
512
|
}
|
|
522
513
|
};
|
|
523
514
|
function createLegacyQuery(options) {
|
|
@@ -543,7 +534,7 @@ function createLegacyQuery(options) {
|
|
|
543
534
|
existingSlot.cell.warnOnConflictingDefinition(options);
|
|
544
535
|
return existingSlot.cell;
|
|
545
536
|
}
|
|
546
|
-
if (existingSlot) existingSlot.cell.detach(instance
|
|
537
|
+
if (existingSlot) existingSlot.cell.detach(getComponentLifetimeIdentity(instance), hookIndex);
|
|
547
538
|
if (override) return override;
|
|
548
539
|
let cell = cache.get(options.key);
|
|
549
540
|
if (!cell) {
|
|
@@ -555,7 +546,7 @@ function createLegacyQuery(options) {
|
|
|
555
546
|
key: options.key,
|
|
556
547
|
cell
|
|
557
548
|
});
|
|
558
|
-
cell.attach(instance
|
|
549
|
+
cell.attach(getComponentLifetimeIdentity(instance), hookIndex);
|
|
559
550
|
return cell;
|
|
560
551
|
}
|
|
561
552
|
function createDefinedQuery(definition, input, options = {}) {
|
|
@@ -794,7 +785,7 @@ function createQueryCollection(options) {
|
|
|
794
785
|
const concurrency = normalizeQueryCollectionConcurrency(options.concurrency);
|
|
795
786
|
const inputs = options.inputs();
|
|
796
787
|
if (!Array.isArray(inputs)) throw new Error("[Askr] createQueryCollection() inputs must return a readonly array.");
|
|
797
|
-
const generation = instance
|
|
788
|
+
const generation = getComponentLifetimeIdentity(instance);
|
|
798
789
|
const runtimeState = resolveDataRuntimeState(options.runtime);
|
|
799
790
|
const store = getCollectionStore(generation);
|
|
800
791
|
let slot = store.get(hookIndex);
|
|
@@ -809,10 +800,14 @@ function createQueryCollection(options) {
|
|
|
809
800
|
collection: new QueryCollectionCell(runtimeState)
|
|
810
801
|
};
|
|
811
802
|
store.set(hookIndex, slot);
|
|
812
|
-
(instance
|
|
813
|
-
store.get(hookIndex)
|
|
814
|
-
|
|
815
|
-
|
|
803
|
+
ownComponentCleanup(instance, () => {
|
|
804
|
+
const current = store.get(hookIndex);
|
|
805
|
+
try {
|
|
806
|
+
current?.collection.dispose();
|
|
807
|
+
} finally {
|
|
808
|
+
store.delete(hookIndex);
|
|
809
|
+
if (store.size === 0 && collectionSlotsByGeneration.get(generation) === store) collectionSlotsByGeneration.delete(generation);
|
|
810
|
+
}
|
|
816
811
|
});
|
|
817
812
|
}
|
|
818
813
|
const context = getActiveRenderContext();
|
|
@@ -822,4 +817,4 @@ function createQueryCollection(options) {
|
|
|
822
817
|
return collection;
|
|
823
818
|
}
|
|
824
819
|
//#endregion
|
|
825
|
-
export {
|
|
820
|
+
export { loadingQueryState as a, createMutation as c, queryScope as d, freshQueryState as i, invalidate as l, createQuery as n, refreshingQueryState as o, errorQueryState as r, staleQueryState as s, createQueryCollection as t, invalidateOnInterval as u };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { d as getCurrentAppRenderRuntime } from "./
|
|
1
|
+
import { d as getCurrentAppRenderRuntime, w as drainOwnedCleanup } from "./scope-Cq_iYbTR.js";
|
|
2
|
+
import { a as ownComponentCleanup, r as getComponentLifetimeIdentity } from "./capabilities-Bbf0mlp9.js";
|
|
2
3
|
import { n as getActiveRenderContext } from "./render-context-B7ohlh6t.js";
|
|
3
4
|
//#region src/data/invalidation-listeners.ts
|
|
4
5
|
const invalidationListeners = /* @__PURE__ */ new Set();
|
|
@@ -84,7 +85,7 @@ function resolveDataRuntimeState(runtime) {
|
|
|
84
85
|
return runtime ? getDataRuntimeState(runtime) : getActiveDataRuntimeState();
|
|
85
86
|
}
|
|
86
87
|
function getQuerySlotStore(runtimeState, instance) {
|
|
87
|
-
const generation = instance
|
|
88
|
+
const generation = getComponentLifetimeIdentity(instance);
|
|
88
89
|
let store = runtimeState.querySlotsByGeneration.get(generation);
|
|
89
90
|
if (!store) {
|
|
90
91
|
store = /* @__PURE__ */ new Map();
|
|
@@ -93,7 +94,7 @@ function getQuerySlotStore(runtimeState, instance) {
|
|
|
93
94
|
return store;
|
|
94
95
|
}
|
|
95
96
|
function getMutationSlotStore(runtimeState, instance) {
|
|
96
|
-
const generation = instance
|
|
97
|
+
const generation = getComponentLifetimeIdentity(instance);
|
|
97
98
|
let store = runtimeState.mutationSlotsByGeneration.get(generation);
|
|
98
99
|
if (!store) {
|
|
99
100
|
store = /* @__PURE__ */ new Map();
|
|
@@ -102,27 +103,33 @@ function getMutationSlotStore(runtimeState, instance) {
|
|
|
102
103
|
return store;
|
|
103
104
|
}
|
|
104
105
|
function ensureQueryCleanup(runtimeState, instance) {
|
|
105
|
-
const generation = instance
|
|
106
|
+
const generation = getComponentLifetimeIdentity(instance);
|
|
106
107
|
if (runtimeState.queryCleanupRegistered.has(generation)) return;
|
|
107
108
|
runtimeState.queryCleanupRegistered.add(generation);
|
|
108
109
|
const slots = getQuerySlotStore(runtimeState, instance);
|
|
109
|
-
(instance
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
ownComponentCleanup(instance, () => {
|
|
111
|
+
try {
|
|
112
|
+
drainOwnedCleanup(slots, ([hookIndex, slot]) => slot.cell.detach(generation, hookIndex));
|
|
113
|
+
} finally {
|
|
114
|
+
slots.clear();
|
|
115
|
+
runtimeState.querySlotsByGeneration.delete(generation);
|
|
116
|
+
runtimeState.queryCleanupRegistered.delete(generation);
|
|
117
|
+
}
|
|
114
118
|
});
|
|
115
119
|
}
|
|
116
120
|
function ensureMutationCleanup(runtimeState, instance) {
|
|
117
|
-
const generation = instance
|
|
121
|
+
const generation = getComponentLifetimeIdentity(instance);
|
|
118
122
|
if (runtimeState.mutationCleanupRegistered.has(generation)) return;
|
|
119
123
|
runtimeState.mutationCleanupRegistered.add(generation);
|
|
120
124
|
const slots = getMutationSlotStore(runtimeState, instance);
|
|
121
|
-
(instance
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
ownComponentCleanup(instance, () => {
|
|
126
|
+
try {
|
|
127
|
+
drainOwnedCleanup(slots.values(), (slot) => slot.cell.abort());
|
|
128
|
+
} finally {
|
|
129
|
+
slots.clear();
|
|
130
|
+
runtimeState.mutationSlotsByGeneration.delete(generation);
|
|
131
|
+
runtimeState.mutationCleanupRegistered.delete(generation);
|
|
132
|
+
}
|
|
126
133
|
});
|
|
127
134
|
}
|
|
128
135
|
function invalidateQueriesForRuntime(runtimeState, prefix, markPendingWrite) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { d as getCurrentAppRenderRuntime, f as getCurrentComponentInstance } from "./
|
|
2
|
-
import { i as getExecutionModel } from "./manifest-
|
|
1
|
+
import { d as getCurrentAppRenderRuntime, f as getCurrentComponentInstance } from "./scope-Cq_iYbTR.js";
|
|
2
|
+
import { i as getExecutionModel } from "./manifest-D1P3UNWV.js";
|
|
3
3
|
import { n as getActiveRenderContext, r as getCurrentRenderData } from "./render-context-B7ohlh6t.js";
|
|
4
|
-
import { t as resource } from "./resource-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { t as resource } from "./resource-18-sFRl9.js";
|
|
5
|
+
import { S as isDeferred, b as DEFERRED_BOUNDARY, g as guardHydratedRouteData, l as createRouteHandler } from "./resolution-3DskUkjG.js";
|
|
6
|
+
import { C as getCurrentInheritedMeta, D as getCurrentPageScope, E as getCurrentPageChain, H as computeRank, I as insertRecordSorted, O as getCurrentPathPrefix, P as hasActivePageScope, R as pushRegistrationScope, S as getCurrentInheritedAuthRequirements, T as getCurrentLayoutChain, U as normalizeRouteSegmentName, W as parseSegments, g as assertRouteRegistrationUnlocked, h as addRouteToStores, j as getDefaultRouteBasePath, k as getCurrentScopeKind, w as getCurrentInheritedPolicies } from "./route-matching-CUzZ31gT.js";
|
|
7
7
|
import { allOf } from "@askrjs/auth";
|
|
8
8
|
//#region src/router/access.ts
|
|
9
9
|
function compileNodePolicies(node) {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
RuntimeRendererHost,
|
|
3
|
+
RuntimeKeyedReorderDecision,
|
|
4
|
+
} from './core.js';
|
|
5
|
+
|
|
6
|
+
declare const ownerBrand: unique symbol;
|
|
7
|
+
declare const scopeBrand: unique symbol;
|
|
8
|
+
declare const sourceBrand: unique symbol;
|
|
9
|
+
/** Opaque component identity scoped to one DOM renderer factory. */
|
|
10
|
+
export interface DOMComponentOwner {
|
|
11
|
+
readonly [ownerBrand]: never;
|
|
12
|
+
}
|
|
13
|
+
/** Opaque child scope identity scoped to one DOM renderer factory. */
|
|
14
|
+
export interface DOMChildScope {
|
|
15
|
+
readonly [scopeBrand]: never;
|
|
16
|
+
}
|
|
17
|
+
/** Opaque reactive source identity scoped to one DOM renderer factory. */
|
|
18
|
+
export interface DOMReactiveSource {
|
|
19
|
+
readonly [sourceBrand]: never;
|
|
20
|
+
}
|
|
21
|
+
/** Read-only boundary of rendered DOM output. */
|
|
22
|
+
export interface DOMRendererRange {
|
|
23
|
+
readonly start: Node;
|
|
24
|
+
readonly end: Node;
|
|
25
|
+
readonly single: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** DOM evaluation and replacement operations. */
|
|
28
|
+
export interface DOMRendererEvaluation {
|
|
29
|
+
evaluate(
|
|
30
|
+
node: unknown,
|
|
31
|
+
target: Element | null,
|
|
32
|
+
context?: object,
|
|
33
|
+
retainedOwner?: DOMComponentOwner
|
|
34
|
+
): void;
|
|
35
|
+
replaceComponentRange(
|
|
36
|
+
owner: DOMComponentOwner,
|
|
37
|
+
result: unknown,
|
|
38
|
+
host: Element | Comment
|
|
39
|
+
): Node | null;
|
|
40
|
+
}
|
|
41
|
+
/** DOM lifetime cleanup operations. */
|
|
42
|
+
export interface DOMRendererCleanup {
|
|
43
|
+
cleanupInstancesUnder(node: Node): void;
|
|
44
|
+
teardownNodeSubtree(root: Node): void;
|
|
45
|
+
}
|
|
46
|
+
/** Child scope boundary inspection. */
|
|
47
|
+
export interface DOMRendererScopes {
|
|
48
|
+
resolveChildScopeRange(scope: DOMChildScope): DOMRendererRange | null;
|
|
49
|
+
}
|
|
50
|
+
/** Keyed DOM reconciliation operations. */
|
|
51
|
+
export interface DOMRendererKeys {
|
|
52
|
+
populateKeyMapForElement(parent: Element): void;
|
|
53
|
+
getKeyMapForElement(
|
|
54
|
+
parent: Element
|
|
55
|
+
): Map<string | number, Element> | undefined;
|
|
56
|
+
isKeyedReorderFastPathEligible(
|
|
57
|
+
parent: Element,
|
|
58
|
+
children: unknown[],
|
|
59
|
+
oldKeyMap: Map<string | number, Element> | undefined
|
|
60
|
+
): RuntimeKeyedReorderDecision;
|
|
61
|
+
}
|
|
62
|
+
/** Reactive DOM invalidation operations. */
|
|
63
|
+
export interface DOMRendererReactivity {
|
|
64
|
+
markReactivePropsDirtySource(source: DOMReactiveSource): void;
|
|
65
|
+
}
|
|
66
|
+
/** Complete DOM extension roles. Delegate explicitly to the supplied native host. */
|
|
67
|
+
export interface DOMRendererHost {
|
|
68
|
+
evaluation: DOMRendererEvaluation;
|
|
69
|
+
cleanup: DOMRendererCleanup;
|
|
70
|
+
scopes: DOMRendererScopes;
|
|
71
|
+
keys: DOMRendererKeys;
|
|
72
|
+
reactivity: DOMRendererReactivity;
|
|
73
|
+
}
|
|
74
|
+
/** Construct a validated DOM adapter without installing it in a runtime. */
|
|
75
|
+
export declare function createDOMRendererHost(
|
|
76
|
+
configure: (native: DOMRendererHost) => DOMRendererHost
|
|
77
|
+
): RuntimeRendererHost;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { JSXElementType, JSXElement, Props } from '../elements.js';
|
|
2
|
+
import '../jsx-globals.js';
|
|
3
|
+
import { AuthContext, AuthRequirement } from '@askrjs/auth';
|
|
4
|
+
import { InferSchema, ObjectSchema } from '@askrjs/schema';
|
|
5
|
+
import { StateTuple, state } from './state.js';
|
|
6
|
+
import { RenderableChild } from './context.js';
|
|
7
|
+
import { on } from './lifecycle.js';
|
|
8
|
+
import { invalidate } from './data.js';
|
|
9
|
+
|
|
10
|
+
/** A declared server action, built by {@link defineAction}, bound to a form via {@link ActionForm}. */
|
|
11
|
+
interface ActionDescriptor<
|
|
12
|
+
TInput extends Record<string, unknown> = Record<string, unknown>,
|
|
13
|
+
> {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly input: ObjectSchema<TInput>;
|
|
16
|
+
readonly invalidates: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Declare a server action with a stable id, input schema, and query prefixes to invalidate on success. */
|
|
20
|
+
declare function defineAction<TInput extends Record<string, unknown>>(options: {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly input: ObjectSchema<TInput>;
|
|
23
|
+
readonly invalidates?: readonly string[];
|
|
24
|
+
}): ActionDescriptor<TInput>;
|
|
25
|
+
|
|
26
|
+
/** A native form bound to a declared action; it is not a synthetic event API. */
|
|
27
|
+
declare function ActionForm<TInput extends Record<string, unknown>>({
|
|
28
|
+
action,
|
|
29
|
+
children,
|
|
30
|
+
...props
|
|
31
|
+
}: {
|
|
32
|
+
readonly action: ActionDescriptor<TInput>;
|
|
33
|
+
readonly children?: RenderableChild;
|
|
34
|
+
readonly [key: string]: unknown;
|
|
35
|
+
}): JSXElement;
|
|
36
|
+
|
|
37
|
+
/** Server-replayed validation failure for an {@link ActionForm} submission. */
|
|
38
|
+
interface ActionValidationError {
|
|
39
|
+
readonly kind: 'invalid';
|
|
40
|
+
readonly action: string;
|
|
41
|
+
readonly values: Readonly<Record<string, unknown>>;
|
|
42
|
+
readonly issues: readonly unknown[];
|
|
43
|
+
readonly fieldErrors: Readonly<Record<string, readonly string[]>>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Pending/result/error status for an action, as reported by the `action()` hook. */
|
|
47
|
+
interface ActionStatus<TResult = unknown> {
|
|
48
|
+
readonly pending: boolean;
|
|
49
|
+
readonly result?: TResult;
|
|
50
|
+
readonly error?: unknown;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Returns a command handle, rather than a hook. */
|
|
54
|
+
declare function action<
|
|
55
|
+
TInput extends Record<string, unknown>,
|
|
56
|
+
TResult = unknown,
|
|
57
|
+
>(
|
|
58
|
+
descriptor: ActionDescriptor<TInput>
|
|
59
|
+
): {
|
|
60
|
+
state: StateTuple<ActionStatus<TResult>>;
|
|
61
|
+
submit(input: TInput): Promise<TResult>;
|
|
62
|
+
};
|
|
63
|
+
export {
|
|
64
|
+
ActionDescriptor,
|
|
65
|
+
defineAction,
|
|
66
|
+
ActionForm,
|
|
67
|
+
ActionValidationError,
|
|
68
|
+
ActionStatus,
|
|
69
|
+
action,
|
|
70
|
+
};
|