@askrjs/askr 0.2.4 → 0.3.1
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 +30 -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-FirwPXA_.js → activity-oy2YFTFF.js} +10 -16
- package/dist/benchmark.js +8 -9
- package/dist/boot/index.d.ts +19 -9
- package/dist/boot/index.js +1 -1
- package/dist/{boot-tWyF6121.js → boot-DLplW9h4.js} +700 -441
- 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-C-wSaq9V.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-ghKopAbp.js → data-2edW0jhF.js} +108 -122
- package/dist/{data-runtime-7t_Y0iv3.js → data-runtime-CxoY98lX.js} +22 -15
- package/dist/{deferred-CxjWCkIn.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-CNwstBBD.js → effect-C3Zsc1k6.js} +14 -41
- package/dist/{types-DWVrKn9N.d.ts → elements.d.ts} +79 -42
- package/dist/{for-internal-DyBHfKJA.js → for-state-BDykeOJL.js} +598 -494
- 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-C4hKKQBF.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-ZZu1IV0B.js → navigate-prC5V8XV.js} +125 -472
- package/dist/{navigate-F4sHgWbw.d.ts → navigation.d.ts} +8 -8
- package/dist/{readable-Di1fzSwm.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-Doog-AfJ.js → render-resolved-BC0W7_5b.js} +165 -558
- package/dist/{renderer-Cl23O0hV.js → renderer-CT0HeY58.js} +6825 -5692
- package/dist/{resolution-ClD-K7Lz.js → resolution-3DskUkjG.js} +189 -180
- package/dist/{resource-operation-Vz1S5h2k.js → resource-18-sFRl9.js} +98 -58
- package/dist/resources/index.d.ts +64 -12
- package/dist/resources/index.js +214 -8
- 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-CsKuomw0.js → selector-BSPVkjKP.js} +26 -27
- package/dist/{shared-CYBH3F8I.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-BGJgYSyQ.js → state-BXJfudq1.js} +10 -15
- package/dist/{structures-DFyK5AdQ.js → structures-CjEzfj4h.js} +37 -57
- package/dist/{index-CTpMmzgN.d.ts → structures.d.ts} +57 -36
- package/dist/testing/index.d.ts +123 -24
- package/dist/testing/index.js +24 -61
- package/dist/timer-C7uqnJVt.js +85 -0
- package/dist/{index-B1gu0_m0.d.ts → utilities.d.ts} +24 -13
- package/dist/{verify-hydration-BZPJ_kYa.js → verify-hydration-ikaxotf7.js} +8 -5
- package/package.json +12 -14
- package/dist/access-BucjYZcX.js +0 -509
- package/dist/activity-DooIuxQO.d.ts +0 -14
- package/dist/benchmark.d.ts +0 -26
- package/dist/cleanup-TXSsApEl.js +0 -535
- package/dist/component-cleanup-jdbgjkT1.js +0 -143
- package/dist/component-scope-4I3yEMkb.js +0 -195
- package/dist/control-Cxag1yqV.d.ts +0 -8
- package/dist/csp-nonce-9NFUb7hJ.js +0 -72
- package/dist/css-BuPaTOfe.js +0 -70
- package/dist/fastlane-BKZduiBQ.js +0 -166
- package/dist/index-Dgjbo2gU.d.ts +0 -1456
- package/dist/jsx-runtime-Cg7GqY1S.d.ts +0 -2
- package/dist/jsx-runtime-gVIaTPw0.d.ts +0 -38
- package/dist/lifecycle-batch-63aXFf2S.js +0 -253
- package/dist/lifecycle-operations-Q0k3EFnG.js +0 -287
|
@@ -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,15 +220,82 @@ 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;
|
|
232
300
|
this.pendingRefreshKind = null;
|
|
233
301
|
this.pendingRefreshResolve = null;
|
|
@@ -238,27 +306,11 @@ var QueryCell = class {
|
|
|
238
306
|
this.ownerCount = 0;
|
|
239
307
|
this.owners = /* @__PURE__ */ new Map();
|
|
240
308
|
this.warnedDefinitionConflictKeys = /* @__PURE__ */ new Set();
|
|
241
|
-
this.state =
|
|
242
|
-
data: null,
|
|
243
|
-
error: null,
|
|
244
|
-
loading: true,
|
|
245
|
-
refreshing: false,
|
|
246
|
-
stale: false,
|
|
247
|
-
consistency: "fresh",
|
|
248
|
-
staleReason: null
|
|
249
|
-
};
|
|
309
|
+
this.state = loadingQueryState();
|
|
250
310
|
this.options = options;
|
|
251
311
|
this.key = key;
|
|
252
312
|
this.cache = cache;
|
|
253
|
-
if (options.initialData !== void 0) this.state =
|
|
254
|
-
data: options.initialData,
|
|
255
|
-
error: null,
|
|
256
|
-
loading: false,
|
|
257
|
-
refreshing: false,
|
|
258
|
-
stale: false,
|
|
259
|
-
consistency: "fresh",
|
|
260
|
-
staleReason: null
|
|
261
|
-
};
|
|
313
|
+
if (options.initialData !== void 0) this.state = freshQueryState(options.initialData);
|
|
262
314
|
}
|
|
263
315
|
attach(generation, hookIndex) {
|
|
264
316
|
let hooks = this.owners.get(generation);
|
|
@@ -291,7 +343,6 @@ var QueryCell = class {
|
|
|
291
343
|
this.destroyed = true;
|
|
292
344
|
this.controller?.abort();
|
|
293
345
|
this.controller = null;
|
|
294
|
-
this.startQueued = false;
|
|
295
346
|
this.reconcileAttemptCount = 0;
|
|
296
347
|
this.ownerCount = 0;
|
|
297
348
|
this.owners.clear();
|
|
@@ -335,10 +386,10 @@ var QueryCell = class {
|
|
|
335
386
|
}
|
|
336
387
|
/** @internal Whether a collection should schedule this cell's first load. */
|
|
337
388
|
needsInitialStart() {
|
|
338
|
-
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;
|
|
339
390
|
}
|
|
340
391
|
ensureStarted() {
|
|
341
|
-
if (this.destroyed || this.state.data !== null || this.pendingRefresh || this.
|
|
392
|
+
if (this.destroyed || this.state.data !== null || this.pendingRefresh || this.options.skipInitialFetch) return;
|
|
342
393
|
this.queueStart(void 0, "initial");
|
|
343
394
|
}
|
|
344
395
|
refresh() {
|
|
@@ -347,7 +398,7 @@ var QueryCell = class {
|
|
|
347
398
|
if (this.pendingRefreshKind === "invalidation") {
|
|
348
399
|
this.controller?.abort();
|
|
349
400
|
this.queueStart(void 0, "manual", true);
|
|
350
|
-
return this.pendingRefresh;
|
|
401
|
+
return this.pendingRefresh ?? Promise.resolve();
|
|
351
402
|
} else return this.pendingRefresh;
|
|
352
403
|
}
|
|
353
404
|
this.queueStart(void 0, "manual");
|
|
@@ -365,14 +416,7 @@ var QueryCell = class {
|
|
|
365
416
|
markPendingWrite() {
|
|
366
417
|
if (this.destroyed) return;
|
|
367
418
|
if (this.state.data === null) return;
|
|
368
|
-
this.setState(
|
|
369
|
-
loading: false,
|
|
370
|
-
error: null,
|
|
371
|
-
refreshing: true,
|
|
372
|
-
stale: true,
|
|
373
|
-
consistency: "pending-write",
|
|
374
|
-
staleReason: null
|
|
375
|
-
});
|
|
419
|
+
this.setState(refreshingQueryState(this.state.data, "pending-write"));
|
|
376
420
|
}
|
|
377
421
|
queueStart(reconcileSequence, kind = "manual", continuePending = false) {
|
|
378
422
|
if (this.destroyed) return;
|
|
@@ -380,15 +424,13 @@ var QueryCell = class {
|
|
|
380
424
|
this.reconcileAttemptCount = 0;
|
|
381
425
|
return ++this.reconcileSequence;
|
|
382
426
|
})();
|
|
383
|
-
this.startQueued = true;
|
|
384
427
|
this.pendingRefreshKind = kind;
|
|
385
428
|
const token = ++this.pendingRefreshToken;
|
|
386
429
|
if (!continuePending || !this.pendingRefresh) this.pendingRefresh = new Promise((resolve) => {
|
|
387
430
|
this.pendingRefreshResolve = resolve;
|
|
388
431
|
});
|
|
389
|
-
|
|
432
|
+
requestRuntimeWork("component", new QueryStartWork(() => {
|
|
390
433
|
if (token !== this.pendingRefreshToken) return;
|
|
391
|
-
this.startQueued = false;
|
|
392
434
|
if (this.destroyed) {
|
|
393
435
|
this.finishPendingRefresh(token);
|
|
394
436
|
return;
|
|
@@ -396,7 +438,11 @@ var QueryCell = class {
|
|
|
396
438
|
this.start(sequence).finally(() => {
|
|
397
439
|
this.finishPendingRefresh(token);
|
|
398
440
|
});
|
|
399
|
-
})
|
|
441
|
+
}, () => {
|
|
442
|
+
if (token !== this.pendingRefreshToken) return;
|
|
443
|
+
this.generation += 1;
|
|
444
|
+
this.finishPendingRefresh(token);
|
|
445
|
+
}));
|
|
400
446
|
}
|
|
401
447
|
finishPendingRefresh(token = this.pendingRefreshToken) {
|
|
402
448
|
if (token !== this.pendingRefreshToken) return;
|
|
@@ -408,10 +454,7 @@ var QueryCell = class {
|
|
|
408
454
|
}
|
|
409
455
|
setState(next) {
|
|
410
456
|
if (this.destroyed) return;
|
|
411
|
-
this.state =
|
|
412
|
-
...this.state,
|
|
413
|
-
...next
|
|
414
|
-
};
|
|
457
|
+
this.state = next;
|
|
415
458
|
notifySource(this.source);
|
|
416
459
|
}
|
|
417
460
|
async start(reconcileSequence) {
|
|
@@ -422,45 +465,17 @@ var QueryCell = class {
|
|
|
422
465
|
const controller = new AbortController();
|
|
423
466
|
this.controller = controller;
|
|
424
467
|
const hasData = this.state.data !== null;
|
|
425
|
-
this.setState(
|
|
426
|
-
loading: !hasData,
|
|
427
|
-
refreshing: hasData,
|
|
428
|
-
stale: hasData,
|
|
429
|
-
consistency: hasData ? "refreshing" : "fresh",
|
|
430
|
-
error: null,
|
|
431
|
-
staleReason: null
|
|
432
|
-
});
|
|
468
|
+
this.setState(hasData ? refreshingQueryState(this.state.data) : loadingQueryState());
|
|
433
469
|
let nextData;
|
|
434
470
|
try {
|
|
435
471
|
nextData = await this.options.fetch({ signal: controller.signal });
|
|
436
472
|
} catch (error) {
|
|
437
473
|
if (this.destroyed || !isCurrentAsyncOperation(this.generation, generation, this.controller, controller)) return;
|
|
438
474
|
if (isAbortError(error, controller.signal)) {
|
|
439
|
-
this.setState(hasData ?
|
|
440
|
-
loading: false,
|
|
441
|
-
refreshing: false,
|
|
442
|
-
stale: true,
|
|
443
|
-
consistency: "stale",
|
|
444
|
-
error: null,
|
|
445
|
-
staleReason: "aborted"
|
|
446
|
-
} : {
|
|
447
|
-
loading: true,
|
|
448
|
-
refreshing: false,
|
|
449
|
-
stale: false,
|
|
450
|
-
consistency: "fresh",
|
|
451
|
-
error: null,
|
|
452
|
-
staleReason: null
|
|
453
|
-
});
|
|
475
|
+
this.setState(hasData ? staleQueryState(this.state.data, "aborted") : loadingQueryState());
|
|
454
476
|
return;
|
|
455
477
|
}
|
|
456
|
-
this.setState(
|
|
457
|
-
loading: false,
|
|
458
|
-
refreshing: false,
|
|
459
|
-
stale: true,
|
|
460
|
-
consistency: "stale",
|
|
461
|
-
error: normalizeAsyncDataError(error, "Unknown query error"),
|
|
462
|
-
staleReason: "error"
|
|
463
|
-
});
|
|
478
|
+
this.setState(errorQueryState(this.state.data, normalizeAsyncDataError(error, "Unknown query error")));
|
|
464
479
|
return;
|
|
465
480
|
}
|
|
466
481
|
if (this.destroyed || !isCurrentAsyncOperation(this.generation, generation, this.controller, controller)) return;
|
|
@@ -468,59 +483,26 @@ var QueryCell = class {
|
|
|
468
483
|
try {
|
|
469
484
|
isConsistent = this.options.isConsistent?.(nextData) ?? true;
|
|
470
485
|
} catch (error) {
|
|
471
|
-
this.setState(
|
|
472
|
-
loading: false,
|
|
473
|
-
refreshing: false,
|
|
474
|
-
stale: true,
|
|
475
|
-
consistency: "stale",
|
|
476
|
-
error: normalizeAsyncDataError(error, "Query consistency check failed"),
|
|
477
|
-
staleReason: "error"
|
|
478
|
-
});
|
|
486
|
+
this.setState(errorQueryState(this.state.data, normalizeAsyncDataError(error, "Query consistency check failed")));
|
|
479
487
|
return;
|
|
480
488
|
}
|
|
481
489
|
if (!isConsistent) {
|
|
482
|
-
this.setState(
|
|
483
|
-
data: nextData,
|
|
484
|
-
loading: false,
|
|
485
|
-
refreshing: false,
|
|
486
|
-
stale: true,
|
|
487
|
-
consistency: "stale",
|
|
488
|
-
staleReason: "inconsistent"
|
|
489
|
-
});
|
|
490
|
+
this.setState(staleQueryState(nextData, "inconsistent"));
|
|
490
491
|
try {
|
|
491
492
|
await this.reconcile(nextData, generation, controller, reconcileSequence);
|
|
492
493
|
} catch (error) {
|
|
493
|
-
if (isCurrentAsyncOperation(this.generation, generation, this.controller, controller)) this.setState(
|
|
494
|
-
loading: false,
|
|
495
|
-
refreshing: false,
|
|
496
|
-
stale: true,
|
|
497
|
-
consistency: "stale",
|
|
498
|
-
error: normalizeAsyncDataError(error, "Query reconciliation failed"),
|
|
499
|
-
staleReason: "error"
|
|
500
|
-
});
|
|
494
|
+
if (isCurrentAsyncOperation(this.generation, generation, this.controller, controller)) this.setState(errorQueryState(this.state.data, normalizeAsyncDataError(error, "Query reconciliation failed")));
|
|
501
495
|
}
|
|
502
496
|
return;
|
|
503
497
|
}
|
|
504
498
|
this.reconcileAttemptCount = 0;
|
|
505
|
-
this.setState(
|
|
506
|
-
data: nextData,
|
|
507
|
-
loading: false,
|
|
508
|
-
refreshing: false,
|
|
509
|
-
stale: false,
|
|
510
|
-
consistency: "fresh",
|
|
511
|
-
error: null,
|
|
512
|
-
staleReason: null
|
|
513
|
-
});
|
|
499
|
+
this.setState(freshQueryState(nextData));
|
|
514
500
|
}
|
|
515
501
|
async reconcile(data, generation, controller, reconcileSequence) {
|
|
516
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;
|
|
517
503
|
this.reconcileAttemptCount += 1;
|
|
518
504
|
if (this.reconcileAttemptCount > RECONCILE_MAX_ATTEMPTS) {
|
|
519
|
-
this.setState(
|
|
520
|
-
consistency: "stale",
|
|
521
|
-
refreshing: false,
|
|
522
|
-
staleReason: "inconsistent"
|
|
523
|
-
});
|
|
505
|
+
this.setState(staleQueryState(this.state.data, "inconsistent"));
|
|
524
506
|
return;
|
|
525
507
|
}
|
|
526
508
|
await new Promise((resolve) => setTimeout(resolve, RECONCILE_RETRY_DELAY_MS));
|
|
@@ -552,7 +534,7 @@ function createLegacyQuery(options) {
|
|
|
552
534
|
existingSlot.cell.warnOnConflictingDefinition(options);
|
|
553
535
|
return existingSlot.cell;
|
|
554
536
|
}
|
|
555
|
-
if (existingSlot) existingSlot.cell.detach(instance
|
|
537
|
+
if (existingSlot) existingSlot.cell.detach(getComponentLifetimeIdentity(instance), hookIndex);
|
|
556
538
|
if (override) return override;
|
|
557
539
|
let cell = cache.get(options.key);
|
|
558
540
|
if (!cell) {
|
|
@@ -564,7 +546,7 @@ function createLegacyQuery(options) {
|
|
|
564
546
|
key: options.key,
|
|
565
547
|
cell
|
|
566
548
|
});
|
|
567
|
-
cell.attach(instance
|
|
549
|
+
cell.attach(getComponentLifetimeIdentity(instance), hookIndex);
|
|
568
550
|
return cell;
|
|
569
551
|
}
|
|
570
552
|
function createDefinedQuery(definition, input, options = {}) {
|
|
@@ -803,7 +785,7 @@ function createQueryCollection(options) {
|
|
|
803
785
|
const concurrency = normalizeQueryCollectionConcurrency(options.concurrency);
|
|
804
786
|
const inputs = options.inputs();
|
|
805
787
|
if (!Array.isArray(inputs)) throw new Error("[Askr] createQueryCollection() inputs must return a readonly array.");
|
|
806
|
-
const generation = instance
|
|
788
|
+
const generation = getComponentLifetimeIdentity(instance);
|
|
807
789
|
const runtimeState = resolveDataRuntimeState(options.runtime);
|
|
808
790
|
const store = getCollectionStore(generation);
|
|
809
791
|
let slot = store.get(hookIndex);
|
|
@@ -818,10 +800,14 @@ function createQueryCollection(options) {
|
|
|
818
800
|
collection: new QueryCollectionCell(runtimeState)
|
|
819
801
|
};
|
|
820
802
|
store.set(hookIndex, slot);
|
|
821
|
-
(instance
|
|
822
|
-
store.get(hookIndex)
|
|
823
|
-
|
|
824
|
-
|
|
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
|
+
}
|
|
825
811
|
});
|
|
826
812
|
}
|
|
827
813
|
const context = getActiveRenderContext();
|
|
@@ -831,4 +817,4 @@ function createQueryCollection(options) {
|
|
|
831
817
|
return collection;
|
|
832
818
|
}
|
|
833
819
|
//#endregion
|
|
834
|
-
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
|
+
};
|