@askrjs/askr 0.0.48 → 0.0.49
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/dist/benchmark.js +6 -6
- package/dist/benchmark.js.map +1 -1
- package/dist/boot/hydration.js +140 -0
- package/dist/boot/hydration.js.map +1 -0
- package/dist/boot/index.d.ts +3 -56
- package/dist/boot/index.d.ts.map +1 -1
- package/dist/boot/index.js +62 -410
- package/dist/boot/index.js.map +1 -1
- package/dist/boot/root-lifecycle.d.ts +15 -0
- package/dist/boot/root-lifecycle.d.ts.map +1 -0
- package/dist/boot/root-lifecycle.js +205 -0
- package/dist/boot/root-lifecycle.js.map +1 -0
- package/dist/boot/route-startup.js +45 -0
- package/dist/boot/route-startup.js.map +1 -0
- package/dist/boot/types.d.ts +62 -0
- package/dist/boot/types.d.ts.map +1 -0
- package/dist/common/component.d.ts +3 -1
- package/dist/common/component.d.ts.map +1 -1
- package/dist/common/jsx.d.ts +1 -1
- package/dist/common/jsx.d.ts.map +1 -1
- package/dist/common/jsx.js.map +1 -1
- package/dist/common/props.d.ts +1 -1
- package/dist/common/render-context.js +55 -0
- package/dist/common/render-context.js.map +1 -0
- package/dist/common/router.d.ts +5 -1
- package/dist/common/router.d.ts.map +1 -1
- package/dist/common/ssr.d.ts +1 -1
- package/dist/common/ssr.js.map +1 -1
- package/dist/common/vnode.d.ts +5 -4
- package/dist/common/vnode.d.ts.map +1 -1
- package/dist/common/vnode.js.map +1 -1
- package/dist/components/error-boundary.d.ts +1 -1
- package/dist/components/error-boundary.js +2 -1
- package/dist/components/error-boundary.js.map +1 -1
- package/dist/components/link.js.map +1 -1
- package/dist/control/for.js +2 -1
- package/dist/control/for.js.map +1 -1
- package/dist/data/data-runtime.d.ts +28 -0
- package/dist/data/data-runtime.d.ts.map +1 -0
- package/dist/data/data-runtime.js +114 -0
- package/dist/data/data-runtime.js.map +1 -0
- package/dist/data/index.d.ts +6 -142
- package/dist/data/index.js +5 -539
- package/dist/data/invalidation.d.ts +9 -0
- package/dist/data/invalidation.d.ts.map +1 -0
- package/dist/data/invalidation.js +27 -0
- package/dist/data/invalidation.js.map +1 -0
- package/dist/data/mutation-cell.d.ts +28 -0
- package/dist/data/mutation-cell.d.ts.map +1 -0
- package/dist/data/mutation-cell.js +132 -0
- package/dist/data/mutation-cell.js.map +1 -0
- package/dist/data/query-cell.d.ts +46 -0
- package/dist/data/query-cell.d.ts.map +1 -0
- package/dist/data/query-cell.js +290 -0
- package/dist/data/query-cell.js.map +1 -0
- package/dist/data/query-key.js +42 -0
- package/dist/data/query-key.js.map +1 -0
- package/dist/data/shared.js +20 -0
- package/dist/data/shared.js.map +1 -0
- package/dist/data/types.d.ts +161 -0
- package/dist/data/types.d.ts.map +1 -0
- package/dist/foundations/icon/icon.d.ts.map +1 -1
- package/dist/foundations/icon/icon.js.map +1 -1
- package/dist/foundations/structures/portal.d.ts +1 -1
- package/dist/foundations/structures/portal.d.ts.map +1 -1
- package/dist/foundations/structures/portal.js +2 -1
- package/dist/foundations/structures/portal.js.map +1 -1
- package/dist/fx/fx.d.ts +1 -1
- package/dist/fx/fx.js +5 -4
- package/dist/fx/fx.js.map +1 -1
- package/dist/fx/timing.d.ts.map +1 -1
- package/dist/fx/timing.js +10 -6
- package/dist/fx/timing.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/jsx/index.d.ts +2 -1
- package/dist/jsx/index.js +3 -2
- package/dist/jsx/types.d.ts +2 -0
- package/dist/jsx/types.js +2 -1
- package/dist/jsx-runtime2.d.ts +2 -1
- package/dist/jsx-runtime2.js +3 -2
- package/dist/renderer/attributes.js +231 -0
- package/dist/renderer/attributes.js.map +1 -0
- package/dist/renderer/boundaries.js +266 -0
- package/dist/renderer/boundaries.js.map +1 -0
- package/dist/renderer/child-shape.js +85 -0
- package/dist/renderer/child-shape.js.map +1 -0
- package/dist/renderer/children.js +3 -2
- package/dist/renderer/children.js.map +1 -1
- package/dist/renderer/cleanup.js +2 -1
- package/dist/renderer/cleanup.js.map +1 -1
- package/dist/renderer/component-host-cleanup.js +68 -0
- package/dist/renderer/component-host-cleanup.js.map +1 -0
- package/dist/renderer/component-host-instances.js +65 -0
- package/dist/renderer/component-host-instances.js.map +1 -0
- package/dist/renderer/component-host.js +247 -0
- package/dist/renderer/component-host.js.map +1 -0
- package/dist/renderer/dom-host.js +13 -0
- package/dist/renderer/dom-host.js.map +1 -0
- package/dist/renderer/dom-internal.js +185 -0
- package/dist/renderer/dom-internal.js.map +1 -0
- package/dist/renderer/dom.js +9 -2356
- package/dist/renderer/element-children.js +279 -0
- package/dist/renderer/element-children.js.map +1 -0
- package/dist/renderer/env.js +2 -1
- package/dist/renderer/error-boundary-dom.js +29 -0
- package/dist/renderer/error-boundary-dom.js.map +1 -0
- package/dist/renderer/evaluate-dom-range.js +85 -0
- package/dist/renderer/evaluate-dom-range.js.map +1 -0
- package/dist/renderer/evaluate-reconcile.js +281 -0
- package/dist/renderer/evaluate-reconcile.js.map +1 -0
- package/dist/renderer/evaluate.js +13 -399
- package/dist/renderer/evaluate.js.map +1 -1
- package/dist/renderer/fastpath.js +6 -5
- package/dist/renderer/fastpath.js.map +1 -1
- package/dist/renderer/for-commit-dom-map.js +83 -0
- package/dist/renderer/for-commit-dom-map.js.map +1 -0
- package/dist/renderer/for-commit-removal.js +36 -0
- package/dist/renderer/for-commit-removal.js.map +1 -0
- package/dist/renderer/for-commit-reorder.js +89 -0
- package/dist/renderer/for-commit-reorder.js.map +1 -0
- package/dist/renderer/for-commit.js +6 -188
- package/dist/renderer/for-commit.js.map +1 -1
- package/dist/renderer/index.js +28 -16
- package/dist/renderer/index.js.map +1 -1
- package/dist/renderer/keyed-children.js +32 -0
- package/dist/renderer/keyed-children.js.map +1 -0
- package/dist/renderer/keyed.js +2 -15
- package/dist/renderer/keyed.js.map +1 -1
- package/dist/renderer/namespaces.js +23 -0
- package/dist/renderer/namespaces.js.map +1 -0
- package/dist/renderer/prop-bindings.js +280 -0
- package/dist/renderer/prop-bindings.js.map +1 -0
- package/dist/renderer/reactive-child-dom.js +133 -0
- package/dist/renderer/reactive-child-dom.js.map +1 -0
- package/dist/renderer/reactive-child-sources.js +184 -0
- package/dist/renderer/reactive-child-sources.js.map +1 -0
- package/dist/renderer/reactive-children.js +294 -0
- package/dist/renderer/reactive-children.js.map +1 -0
- package/dist/renderer/reconcile-commit.js +38 -0
- package/dist/renderer/reconcile-commit.js.map +1 -0
- package/dist/renderer/reconcile-fastpaths.js +106 -0
- package/dist/renderer/reconcile-fastpaths.js.map +1 -0
- package/dist/renderer/reconcile-resolution.js +187 -0
- package/dist/renderer/reconcile-resolution.js.map +1 -0
- package/dist/renderer/reconcile.js +9 -371
- package/dist/renderer/reconcile.js.map +1 -1
- package/dist/renderer/retained-element-rollback.js +276 -0
- package/dist/renderer/retained-element-rollback.js.map +1 -0
- package/dist/renderer/stable-patch.js +82 -0
- package/dist/renderer/stable-patch.js.map +1 -0
- package/dist/renderer/static-reuse.js +96 -0
- package/dist/renderer/static-reuse.js.map +1 -0
- package/dist/renderer/types.js +2 -1
- package/dist/renderer/utils.js +4 -4
- package/dist/renderer/utils.js.map +1 -1
- package/dist/resources/index.d.ts +3 -2
- package/dist/resources/index.js +5 -2
- package/dist/router/access.js +36 -0
- package/dist/router/access.js.map +1 -0
- package/dist/router/activity.d.ts +10 -0
- package/dist/router/activity.d.ts.map +1 -0
- package/dist/router/activity.js +89 -0
- package/dist/router/activity.js.map +1 -0
- package/dist/router/authoring.d.ts +22 -0
- package/dist/router/authoring.d.ts.map +1 -0
- package/dist/router/authoring.js +198 -0
- package/dist/router/authoring.js.map +1 -0
- package/dist/router/index.d.ts +12 -4
- package/dist/router/index.js +10 -3
- package/dist/router/internal-types.d.ts +31 -0
- package/dist/router/internal-types.d.ts.map +1 -0
- package/dist/router/lazy.d.ts +19 -0
- package/dist/router/lazy.d.ts.map +1 -0
- package/dist/router/lazy.js +52 -0
- package/dist/router/lazy.js.map +1 -0
- package/dist/router/manifest.d.ts +10 -0
- package/dist/router/manifest.d.ts.map +1 -0
- package/dist/router/manifest.js +49 -0
- package/dist/router/manifest.js.map +1 -0
- package/dist/router/navigate.d.ts +4 -51
- package/dist/router/navigate.d.ts.map +1 -1
- package/dist/router/navigate.js +16 -459
- package/dist/router/navigate.js.map +1 -1
- package/dist/router/navigation-registry.d.ts +32 -0
- package/dist/router/navigation-registry.d.ts.map +1 -0
- package/dist/router/navigation-registry.js +105 -0
- package/dist/router/navigation-registry.js.map +1 -0
- package/dist/router/navigation-scroll.d.ts +14 -0
- package/dist/router/navigation-scroll.d.ts.map +1 -0
- package/dist/router/navigation-scroll.js +93 -0
- package/dist/router/navigation-scroll.js.map +1 -0
- package/dist/router/navigation-targets.d.ts +31 -0
- package/dist/router/navigation-targets.d.ts.map +1 -0
- package/dist/router/navigation-targets.js +253 -0
- package/dist/router/navigation-targets.js.map +1 -0
- package/dist/router/policy.d.ts +7 -1
- package/dist/router/policy.d.ts.map +1 -1
- package/dist/router/policy.js +27 -9
- package/dist/router/policy.js.map +1 -1
- package/dist/router/rendering.d.ts +10 -0
- package/dist/router/rendering.d.ts.map +1 -0
- package/dist/router/rendering.js +45 -0
- package/dist/router/rendering.js.map +1 -0
- package/dist/router/resolution.d.ts +17 -0
- package/dist/router/resolution.d.ts.map +1 -0
- package/dist/router/resolution.js +253 -0
- package/dist/router/resolution.js.map +1 -0
- package/dist/router/route-query.d.ts +17 -0
- package/dist/router/route-query.d.ts.map +1 -0
- package/dist/router/route-query.js +47 -0
- package/dist/router/route-query.js.map +1 -0
- package/dist/router/route.d.ts +8 -149
- package/dist/router/route.js +8 -854
- package/dist/router/store.d.ts +50 -0
- package/dist/router/store.d.ts.map +1 -0
- package/dist/router/store.js +171 -0
- package/dist/router/store.js.map +1 -0
- package/dist/runtime/access.js +45 -0
- package/dist/runtime/access.js.map +1 -0
- package/dist/runtime/child-scope.d.ts +1 -1
- package/dist/runtime/child-scope.js +4 -1
- package/dist/runtime/child-scope.js.map +1 -1
- package/dist/runtime/component-cleanup.d.ts +16 -0
- package/dist/runtime/component-cleanup.d.ts.map +1 -0
- package/dist/runtime/component-cleanup.js +70 -0
- package/dist/runtime/component-cleanup.js.map +1 -0
- package/dist/runtime/component-commit.js +165 -0
- package/dist/runtime/component-commit.js.map +1 -0
- package/dist/runtime/component-contracts.js +5 -0
- package/dist/runtime/component-facade.d.ts +5 -0
- package/dist/runtime/component-facade.js +4 -0
- package/dist/runtime/component-internal.d.ts +100 -0
- package/dist/runtime/component-internal.d.ts.map +1 -0
- package/dist/runtime/component-internal.js +219 -0
- package/dist/runtime/component-internal.js.map +1 -0
- package/dist/runtime/component-lifecycle.d.ts +49 -0
- package/dist/runtime/component-lifecycle.d.ts.map +1 -0
- package/dist/runtime/component-lifecycle.js +176 -0
- package/dist/runtime/component-lifecycle.js.map +1 -0
- package/dist/runtime/component-scope.d.ts +55 -0
- package/dist/runtime/component-scope.d.ts.map +1 -0
- package/dist/runtime/component-scope.js +154 -0
- package/dist/runtime/component-scope.js.map +1 -0
- package/dist/runtime/component.d.ts +4 -152
- package/dist/runtime/component.js +4 -692
- package/dist/runtime/context.d.ts +1 -1
- package/dist/runtime/context.js +6 -4
- package/dist/runtime/context.js.map +1 -1
- package/dist/runtime/control.d.ts +3 -3
- package/dist/runtime/control.js +2 -1
- package/dist/runtime/control.js.map +1 -1
- package/dist/runtime/derive.d.ts.map +1 -1
- package/dist/runtime/derive.js +6 -5
- package/dist/runtime/derive.js.map +1 -1
- package/dist/runtime/effect.d.ts +1 -1
- package/dist/runtime/effect.d.ts.map +1 -1
- package/dist/runtime/effect.js +2 -2
- package/dist/runtime/effect.js.map +1 -1
- package/dist/runtime/events.js +3 -3
- package/dist/runtime/events.js.map +1 -1
- package/dist/runtime/fastlane.js +13 -27
- package/dist/runtime/fastlane.js.map +1 -1
- package/dist/runtime/for-bench.d.ts +1 -1
- package/dist/runtime/for-bench.js +1 -4
- package/dist/runtime/for-bench.js.map +1 -1
- package/dist/runtime/for-internal.d.ts +43 -0
- package/dist/runtime/for-internal.d.ts.map +1 -0
- package/dist/runtime/for-internal.js +98 -0
- package/dist/runtime/for-internal.js.map +1 -0
- package/dist/runtime/for-reconcile.d.ts +8 -0
- package/dist/runtime/for-reconcile.d.ts.map +1 -0
- package/dist/runtime/for-reconcile.js +389 -0
- package/dist/runtime/for-reconcile.js.map +1 -0
- package/dist/runtime/for-scopes.d.ts +26 -0
- package/dist/runtime/for-scopes.d.ts.map +1 -0
- package/dist/runtime/for-scopes.js +160 -0
- package/dist/runtime/for-scopes.js.map +1 -0
- package/dist/runtime/for-signals.d.ts +30 -0
- package/dist/runtime/for-signals.d.ts.map +1 -0
- package/dist/runtime/for-signals.js +139 -0
- package/dist/runtime/for-signals.js.map +1 -0
- package/dist/runtime/for.d.ts +4 -66
- package/dist/runtime/for.js +5 -773
- package/dist/runtime/lifecycle-operations.d.ts +31 -0
- package/dist/runtime/lifecycle-operations.d.ts.map +1 -0
- package/dist/runtime/lifecycle-operations.js +195 -0
- package/dist/runtime/lifecycle-operations.js.map +1 -0
- package/dist/runtime/operations.d.ts +3 -40
- package/dist/runtime/operations.js +2 -357
- package/dist/runtime/readable.d.ts +2 -3
- package/dist/runtime/readable.d.ts.map +1 -1
- package/dist/runtime/readable.js +6 -5
- package/dist/runtime/readable.js.map +1 -1
- package/dist/runtime/resource-cell.js +2 -2
- package/dist/runtime/resource-cell.js.map +1 -1
- package/dist/runtime/resource-operation.d.ts +13 -0
- package/dist/runtime/resource-operation.d.ts.map +1 -0
- package/dist/runtime/resource-operation.js +170 -0
- package/dist/runtime/resource-operation.js.map +1 -0
- package/dist/runtime/runtime.d.ts +42 -0
- package/dist/runtime/runtime.d.ts.map +1 -0
- package/dist/runtime/runtime.js +59 -0
- package/dist/runtime/runtime.js.map +1 -0
- package/dist/runtime/scheduler.d.ts +5 -1
- package/dist/runtime/scheduler.d.ts.map +1 -1
- package/dist/runtime/scheduler.js +17 -17
- package/dist/runtime/scheduler.js.map +1 -1
- package/dist/runtime/selector.js +4 -3
- package/dist/runtime/selector.js.map +1 -1
- package/dist/runtime/snapshot-source.d.ts +1 -1
- package/dist/runtime/snapshot-source.js +1 -1
- package/dist/runtime/state.js +2 -1
- package/dist/runtime/state.js.map +1 -1
- package/dist/ssg/batch-render.js +2 -1
- package/dist/ssg/batch-render.js.map +1 -1
- package/dist/ssg/create-static-gen.d.ts +9 -3
- package/dist/ssg/create-static-gen.d.ts.map +1 -1
- package/dist/ssg/create-static-gen.js +12 -99
- package/dist/ssg/create-static-gen.js.map +1 -1
- package/dist/ssg/generation-plan.js +70 -0
- package/dist/ssg/generation-plan.js.map +1 -0
- package/dist/ssg/incremental-manifest.js +1 -1
- package/dist/ssg/static-routes.js +101 -0
- package/dist/ssg/static-routes.js.map +1 -0
- package/dist/ssg/types.d.ts +15 -7
- package/dist/ssg/types.d.ts.map +1 -1
- package/dist/ssr/boundaries.js +113 -0
- package/dist/ssr/boundaries.js.map +1 -0
- package/dist/ssr/component-runtime.js +111 -0
- package/dist/ssr/component-runtime.js.map +1 -0
- package/dist/ssr/context.d.ts +3 -1
- package/dist/ssr/context.d.ts.map +1 -1
- package/dist/ssr/context.js +9 -2
- package/dist/ssr/context.js.map +1 -1
- package/dist/ssr/errors.d.ts +2 -0
- package/dist/ssr/errors.js +11 -1
- package/dist/ssr/errors.js.map +1 -1
- package/dist/ssr/escape.js +3 -3
- package/dist/ssr/escape.js.map +1 -1
- package/dist/ssr/hydration-data.js +10 -0
- package/dist/ssr/hydration-data.js.map +1 -0
- package/dist/ssr/hydration-verify.d.ts +12 -0
- package/dist/ssr/hydration-verify.d.ts.map +1 -0
- package/dist/ssr/hydration-verify.js +144 -0
- package/dist/ssr/hydration-verify.js.map +1 -0
- package/dist/ssr/index-internal.d.ts +15 -0
- package/dist/ssr/index-internal.d.ts.map +1 -0
- package/dist/ssr/index-internal.js +19 -0
- package/dist/ssr/index-internal.js.map +1 -0
- package/dist/ssr/index.d.ts +5 -57
- package/dist/ssr/index.js +3 -738
- package/dist/ssr/render-keys.js +9 -32
- package/dist/ssr/render-keys.js.map +1 -1
- package/dist/ssr/render-resolved.d.ts +1 -1
- package/dist/ssr/render-resolved.d.ts.map +1 -1
- package/dist/ssr/render-resolved.js +4 -2
- package/dist/ssr/render-resolved.js.map +1 -1
- package/dist/ssr/render-sync.d.ts +21 -0
- package/dist/ssr/render-sync.d.ts.map +1 -0
- package/dist/ssr/render-sync.js +275 -0
- package/dist/ssr/render-sync.js.map +1 -0
- package/dist/ssr/route-policy-resolution.js +77 -0
- package/dist/ssr/route-policy-resolution.js.map +1 -0
- package/dist/ssr/route-render.d.ts +77 -0
- package/dist/ssr/route-render.d.ts.map +1 -0
- package/dist/ssr/route-render.js +119 -0
- package/dist/ssr/route-render.js.map +1 -0
- package/dist/ssr/sink.d.ts +26 -0
- package/dist/ssr/sink.d.ts.map +1 -0
- package/dist/ssr/types.d.ts +1 -0
- package/dist/ssr/types.d.ts.map +1 -1
- package/dist/ssr/verify-hydration.js.map +1 -1
- package/dist/testing/index.d.ts +1 -2
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +2 -1
- package/dist/testing/index.js.map +1 -1
- package/package.json +4 -3
- package/dist/data/index.d.ts.map +0 -1
- package/dist/data/index.js.map +0 -1
- package/dist/renderer/dom.js.map +0 -1
- package/dist/router/route.d.ts.map +0 -1
- package/dist/router/route.js.map +0 -1
- package/dist/runtime/component.d.ts.map +0 -1
- package/dist/runtime/component.js.map +0 -1
- package/dist/runtime/for.d.ts.map +0 -1
- package/dist/runtime/for.js.map +0 -1
- package/dist/runtime/operations.d.ts.map +0 -1
- package/dist/runtime/operations.js.map +0 -1
- package/dist/runtime/ssr-bridge.js +0 -24
- package/dist/runtime/ssr-bridge.js.map +0 -1
- package/dist/ssr/index.d.ts.map +0 -1
- package/dist/ssr/index.js.map +0 -1
package/dist/data/index.js
CHANGED
|
@@ -1,539 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { emitInvalidation } from "./invalidation-listeners.js";
|
|
7
|
-
import { documentVisible, routeActive, timer, windowFocused } from "../runtime/operations.js";
|
|
8
|
-
//#region src/data/index.ts
|
|
9
|
-
const RECONCILE_MAX_ATTEMPTS = 3;
|
|
10
|
-
const RECONCILE_RETRY_DELAY_MS = 25;
|
|
11
|
-
const globalQueryCache = /* @__PURE__ */ new Map();
|
|
12
|
-
const querySlotsByInstance = /* @__PURE__ */ new WeakMap();
|
|
13
|
-
const mutationSlotsByInstance = /* @__PURE__ */ new WeakMap();
|
|
14
|
-
const queryCleanupRegistered = /* @__PURE__ */ new WeakSet();
|
|
15
|
-
const mutationCleanupRegistered = /* @__PURE__ */ new WeakSet();
|
|
16
|
-
function createReadableSource() {
|
|
17
|
-
return (() => void 0);
|
|
18
|
-
}
|
|
19
|
-
function getQueryCache() {
|
|
20
|
-
return getRenderContext()?.queryCache ?? globalQueryCache;
|
|
21
|
-
}
|
|
22
|
-
function getQuerySlotStore(instance) {
|
|
23
|
-
let store = querySlotsByInstance.get(instance);
|
|
24
|
-
if (!store) {
|
|
25
|
-
store = /* @__PURE__ */ new Map();
|
|
26
|
-
querySlotsByInstance.set(instance, store);
|
|
27
|
-
}
|
|
28
|
-
return store;
|
|
29
|
-
}
|
|
30
|
-
function getMutationSlotStore(instance) {
|
|
31
|
-
let store = mutationSlotsByInstance.get(instance);
|
|
32
|
-
if (!store) {
|
|
33
|
-
store = /* @__PURE__ */ new Map();
|
|
34
|
-
mutationSlotsByInstance.set(instance, store);
|
|
35
|
-
}
|
|
36
|
-
return store;
|
|
37
|
-
}
|
|
38
|
-
function ensureQueryCleanup(instance) {
|
|
39
|
-
if (queryCleanupRegistered.has(instance)) return;
|
|
40
|
-
queryCleanupRegistered.add(instance);
|
|
41
|
-
instance.cleanupFns.push(() => {
|
|
42
|
-
const slots = querySlotsByInstance.get(instance);
|
|
43
|
-
if (!slots) {
|
|
44
|
-
queryCleanupRegistered.delete(instance);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
for (const [hookIndex, slot] of slots) slot.cell.detach(instance, hookIndex);
|
|
48
|
-
slots.clear();
|
|
49
|
-
querySlotsByInstance.delete(instance);
|
|
50
|
-
queryCleanupRegistered.delete(instance);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
function ensureMutationCleanup(instance) {
|
|
54
|
-
if (mutationCleanupRegistered.has(instance)) return;
|
|
55
|
-
mutationCleanupRegistered.add(instance);
|
|
56
|
-
instance.cleanupFns.push(() => {
|
|
57
|
-
const slots = mutationSlotsByInstance.get(instance);
|
|
58
|
-
if (!slots) {
|
|
59
|
-
mutationCleanupRegistered.delete(instance);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
for (const cell of slots.values()) cell.abort();
|
|
63
|
-
slots.clear();
|
|
64
|
-
mutationSlotsByInstance.delete(instance);
|
|
65
|
-
mutationCleanupRegistered.delete(instance);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
function notifySource(source) {
|
|
69
|
-
markReadableDerivedSubscribersDirty(source);
|
|
70
|
-
markReactivePropsDirtySource(source);
|
|
71
|
-
notifyReadableReaders(source);
|
|
72
|
-
}
|
|
73
|
-
function isAbortError(error, signal) {
|
|
74
|
-
return signal.aborted || error instanceof Error && error.name === "AbortError" || typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError";
|
|
75
|
-
}
|
|
76
|
-
function normalizeAsyncDataError(error, fallbackMessage) {
|
|
77
|
-
return error ?? new Error(fallbackMessage);
|
|
78
|
-
}
|
|
79
|
-
function invalidateQueries(prefix, markPendingWrite) {
|
|
80
|
-
emitInvalidation({
|
|
81
|
-
prefix,
|
|
82
|
-
markPendingWrite
|
|
83
|
-
});
|
|
84
|
-
const cache = getQueryCache();
|
|
85
|
-
for (const [key, query] of cache) {
|
|
86
|
-
if (!key.startsWith(prefix)) continue;
|
|
87
|
-
if (markPendingWrite) query.markPendingWrite();
|
|
88
|
-
query.refresh();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
var QueryCell = class {
|
|
92
|
-
constructor(options, key, cache) {
|
|
93
|
-
this.source = createReadableSource();
|
|
94
|
-
this.controller = null;
|
|
95
|
-
this.generation = 0;
|
|
96
|
-
this.startQueued = false;
|
|
97
|
-
this.pendingRefresh = null;
|
|
98
|
-
this.pendingRefreshResolve = null;
|
|
99
|
-
this.reconcileAttemptCount = 0;
|
|
100
|
-
this.destroyed = false;
|
|
101
|
-
this.ownerCount = 0;
|
|
102
|
-
this.owners = /* @__PURE__ */ new Map();
|
|
103
|
-
this.warnedDefinitionConflictKeys = /* @__PURE__ */ new Set();
|
|
104
|
-
this.state = {
|
|
105
|
-
data: null,
|
|
106
|
-
error: null,
|
|
107
|
-
loading: true,
|
|
108
|
-
refreshing: false,
|
|
109
|
-
stale: false,
|
|
110
|
-
consistency: "fresh",
|
|
111
|
-
staleReason: null
|
|
112
|
-
};
|
|
113
|
-
this.options = options;
|
|
114
|
-
this.key = key;
|
|
115
|
-
this.cache = cache;
|
|
116
|
-
}
|
|
117
|
-
attach(instance, hookIndex) {
|
|
118
|
-
let hooks = this.owners.get(instance);
|
|
119
|
-
if (!hooks) {
|
|
120
|
-
hooks = /* @__PURE__ */ new Set();
|
|
121
|
-
this.owners.set(instance, hooks);
|
|
122
|
-
}
|
|
123
|
-
if (hooks.has(hookIndex)) return;
|
|
124
|
-
hooks.add(hookIndex);
|
|
125
|
-
this.ownerCount += 1;
|
|
126
|
-
}
|
|
127
|
-
detach(instance, hookIndex) {
|
|
128
|
-
const hooks = this.owners.get(instance);
|
|
129
|
-
if (!hooks || !hooks.delete(hookIndex)) return;
|
|
130
|
-
this.ownerCount -= 1;
|
|
131
|
-
if (hooks.size === 0) this.owners.delete(instance);
|
|
132
|
-
if (this.ownerCount <= 0) this.destroy();
|
|
133
|
-
}
|
|
134
|
-
warnOnConflictingDefinition(options) {
|
|
135
|
-
const conflicts = this.getDefinitionConflicts(options);
|
|
136
|
-
if (conflicts.length === 0) return;
|
|
137
|
-
const conflictKey = conflicts.join(",");
|
|
138
|
-
if (this.warnedDefinitionConflictKeys.has(conflictKey)) return;
|
|
139
|
-
this.warnedDefinitionConflictKeys.add(conflictKey);
|
|
140
|
-
const callbackLabel = conflicts.length === 1 ? `callback \`${conflicts[0]}\`` : `callbacks ${conflicts.map((field) => `\`${field}\``).join(", ")}`;
|
|
141
|
-
logger.warn(`[askr] Conflicting shared query definition for key "${this.key}". Shared queries are canonical by key, so reuse the same ${callbackLabel} for every reader of that key.`);
|
|
142
|
-
}
|
|
143
|
-
destroy() {
|
|
144
|
-
if (this.destroyed) return;
|
|
145
|
-
this.destroyed = true;
|
|
146
|
-
this.controller?.abort();
|
|
147
|
-
this.controller = null;
|
|
148
|
-
this.startQueued = false;
|
|
149
|
-
this.reconcileAttemptCount = 0;
|
|
150
|
-
this.ownerCount = 0;
|
|
151
|
-
this.owners.clear();
|
|
152
|
-
this.cache.delete(this.key);
|
|
153
|
-
this.finishPendingRefresh();
|
|
154
|
-
}
|
|
155
|
-
getDefinitionConflicts(options) {
|
|
156
|
-
const conflicts = [];
|
|
157
|
-
if (this.options.fetch !== options.fetch) conflicts.push("fetch");
|
|
158
|
-
if (this.options.isConsistent !== options.isConsistent) conflicts.push("isConsistent");
|
|
159
|
-
if (this.options.reconcile !== options.reconcile) conflicts.push("reconcile");
|
|
160
|
-
return conflicts;
|
|
161
|
-
}
|
|
162
|
-
get data() {
|
|
163
|
-
recordReadableRead(this.source);
|
|
164
|
-
return this.state.data;
|
|
165
|
-
}
|
|
166
|
-
get error() {
|
|
167
|
-
recordReadableRead(this.source);
|
|
168
|
-
return this.state.error;
|
|
169
|
-
}
|
|
170
|
-
get loading() {
|
|
171
|
-
recordReadableRead(this.source);
|
|
172
|
-
return this.state.loading;
|
|
173
|
-
}
|
|
174
|
-
get refreshing() {
|
|
175
|
-
recordReadableRead(this.source);
|
|
176
|
-
return this.state.refreshing;
|
|
177
|
-
}
|
|
178
|
-
get stale() {
|
|
179
|
-
recordReadableRead(this.source);
|
|
180
|
-
return this.state.stale;
|
|
181
|
-
}
|
|
182
|
-
get consistency() {
|
|
183
|
-
recordReadableRead(this.source);
|
|
184
|
-
return this.state.consistency;
|
|
185
|
-
}
|
|
186
|
-
get staleReason() {
|
|
187
|
-
recordReadableRead(this.source);
|
|
188
|
-
return this.state.staleReason;
|
|
189
|
-
}
|
|
190
|
-
ensureStarted() {
|
|
191
|
-
if (this.destroyed || this.state.data !== null || this.pendingRefresh || this.startQueued) return;
|
|
192
|
-
this.queueStart("initial");
|
|
193
|
-
}
|
|
194
|
-
refresh() {
|
|
195
|
-
if (this.destroyed) return Promise.resolve();
|
|
196
|
-
if (this.pendingRefresh) return this.pendingRefresh;
|
|
197
|
-
this.queueStart("manual");
|
|
198
|
-
return this.pendingRefresh ?? Promise.resolve();
|
|
199
|
-
}
|
|
200
|
-
markPendingWrite() {
|
|
201
|
-
if (this.destroyed) return;
|
|
202
|
-
if (this.state.data === null) return;
|
|
203
|
-
this.setState({
|
|
204
|
-
loading: false,
|
|
205
|
-
error: null,
|
|
206
|
-
refreshing: true,
|
|
207
|
-
stale: true,
|
|
208
|
-
consistency: "pending-write",
|
|
209
|
-
staleReason: null
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
queueStart(reason) {
|
|
213
|
-
if (this.destroyed) return;
|
|
214
|
-
this.startQueued = true;
|
|
215
|
-
this.pendingRefresh = new Promise((resolve) => {
|
|
216
|
-
this.pendingRefreshResolve = resolve;
|
|
217
|
-
globalScheduler.enqueue(() => {
|
|
218
|
-
this.startQueued = false;
|
|
219
|
-
if (this.destroyed) {
|
|
220
|
-
this.finishPendingRefresh();
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
this.start(reason).finally(() => {
|
|
224
|
-
this.finishPendingRefresh();
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
finishPendingRefresh() {
|
|
230
|
-
const resolve = this.pendingRefreshResolve;
|
|
231
|
-
this.pendingRefresh = null;
|
|
232
|
-
this.pendingRefreshResolve = null;
|
|
233
|
-
resolve?.();
|
|
234
|
-
}
|
|
235
|
-
setState(next) {
|
|
236
|
-
if (this.destroyed) return;
|
|
237
|
-
this.state = {
|
|
238
|
-
...this.state,
|
|
239
|
-
...next
|
|
240
|
-
};
|
|
241
|
-
notifySource(this.source);
|
|
242
|
-
}
|
|
243
|
-
async start(reason) {
|
|
244
|
-
if (this.destroyed) return;
|
|
245
|
-
this.generation += 1;
|
|
246
|
-
const generation = this.generation;
|
|
247
|
-
this.controller?.abort();
|
|
248
|
-
const controller = new AbortController();
|
|
249
|
-
this.controller = controller;
|
|
250
|
-
const hasData = this.state.data !== null;
|
|
251
|
-
this.setState({
|
|
252
|
-
loading: !hasData,
|
|
253
|
-
refreshing: hasData,
|
|
254
|
-
stale: hasData,
|
|
255
|
-
consistency: reason === "pending-write" ? "pending-write" : hasData ? "refreshing" : "fresh",
|
|
256
|
-
error: null,
|
|
257
|
-
staleReason: null
|
|
258
|
-
});
|
|
259
|
-
let nextData;
|
|
260
|
-
try {
|
|
261
|
-
nextData = await this.options.fetch({ signal: controller.signal });
|
|
262
|
-
} catch (error) {
|
|
263
|
-
if (this.destroyed || this.generation !== generation || this.controller !== controller) return;
|
|
264
|
-
if (isAbortError(error, controller.signal)) {
|
|
265
|
-
this.setState(hasData ? {
|
|
266
|
-
loading: false,
|
|
267
|
-
refreshing: false,
|
|
268
|
-
stale: true,
|
|
269
|
-
consistency: "stale",
|
|
270
|
-
error: null,
|
|
271
|
-
staleReason: "aborted"
|
|
272
|
-
} : {
|
|
273
|
-
loading: true,
|
|
274
|
-
refreshing: false,
|
|
275
|
-
stale: false,
|
|
276
|
-
consistency: "fresh",
|
|
277
|
-
error: null,
|
|
278
|
-
staleReason: null
|
|
279
|
-
});
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
this.setState({
|
|
283
|
-
loading: false,
|
|
284
|
-
refreshing: false,
|
|
285
|
-
stale: true,
|
|
286
|
-
consistency: "stale",
|
|
287
|
-
error: normalizeAsyncDataError(error, "Unknown query error"),
|
|
288
|
-
staleReason: "error"
|
|
289
|
-
});
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
if (this.destroyed || this.generation !== generation || this.controller !== controller) return;
|
|
293
|
-
if (!(this.options.isConsistent?.(nextData) ?? true)) {
|
|
294
|
-
this.setState({
|
|
295
|
-
data: nextData,
|
|
296
|
-
loading: false,
|
|
297
|
-
refreshing: false,
|
|
298
|
-
stale: true,
|
|
299
|
-
consistency: "stale",
|
|
300
|
-
staleReason: "inconsistent"
|
|
301
|
-
});
|
|
302
|
-
await this.reconcile(nextData);
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
this.reconcileAttemptCount = 0;
|
|
306
|
-
this.setState({
|
|
307
|
-
data: nextData,
|
|
308
|
-
loading: false,
|
|
309
|
-
refreshing: false,
|
|
310
|
-
stale: false,
|
|
311
|
-
consistency: "fresh",
|
|
312
|
-
error: null,
|
|
313
|
-
staleReason: null
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
async reconcile(data) {
|
|
317
|
-
if (!(this.options.reconcile?.(data, { key: this.options.key }) ?? false) || this.destroyed) return;
|
|
318
|
-
this.reconcileAttemptCount += 1;
|
|
319
|
-
if (this.reconcileAttemptCount > RECONCILE_MAX_ATTEMPTS) {
|
|
320
|
-
this.setState({
|
|
321
|
-
consistency: "stale",
|
|
322
|
-
refreshing: false,
|
|
323
|
-
staleReason: "inconsistent"
|
|
324
|
-
});
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
await new Promise((resolve) => setTimeout(resolve, RECONCILE_RETRY_DELAY_MS));
|
|
328
|
-
if (this.destroyed || this.state.consistency === "fresh") return;
|
|
329
|
-
await this.refresh();
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
var MutationCell = class {
|
|
333
|
-
constructor(options) {
|
|
334
|
-
this.source = createReadableSource();
|
|
335
|
-
this.controller = null;
|
|
336
|
-
this.generation = 0;
|
|
337
|
-
this.state = {
|
|
338
|
-
status: "idle",
|
|
339
|
-
error: null,
|
|
340
|
-
result: null
|
|
341
|
-
};
|
|
342
|
-
this.action = options.action;
|
|
343
|
-
this.affects = options.affects;
|
|
344
|
-
this.afterSuccess = options.afterSuccess;
|
|
345
|
-
}
|
|
346
|
-
setOptions(options) {
|
|
347
|
-
this.action = options.action;
|
|
348
|
-
this.affects = options.affects;
|
|
349
|
-
this.afterSuccess = options.afterSuccess;
|
|
350
|
-
}
|
|
351
|
-
get status() {
|
|
352
|
-
recordReadableRead(this.source);
|
|
353
|
-
return this.state.status;
|
|
354
|
-
}
|
|
355
|
-
get pending() {
|
|
356
|
-
recordReadableRead(this.source);
|
|
357
|
-
return this.state.status === "pending";
|
|
358
|
-
}
|
|
359
|
-
get error() {
|
|
360
|
-
recordReadableRead(this.source);
|
|
361
|
-
return this.state.error;
|
|
362
|
-
}
|
|
363
|
-
get result() {
|
|
364
|
-
recordReadableRead(this.source);
|
|
365
|
-
return this.state.result;
|
|
366
|
-
}
|
|
367
|
-
setState(next) {
|
|
368
|
-
this.state = {
|
|
369
|
-
...this.state,
|
|
370
|
-
...next
|
|
371
|
-
};
|
|
372
|
-
notifySource(this.source);
|
|
373
|
-
}
|
|
374
|
-
async execute(input) {
|
|
375
|
-
this.generation += 1;
|
|
376
|
-
const generation = this.generation;
|
|
377
|
-
this.controller?.abort();
|
|
378
|
-
const controller = new AbortController();
|
|
379
|
-
this.controller = controller;
|
|
380
|
-
this.setState({
|
|
381
|
-
status: "pending",
|
|
382
|
-
error: null,
|
|
383
|
-
result: null
|
|
384
|
-
});
|
|
385
|
-
let result;
|
|
386
|
-
try {
|
|
387
|
-
result = await this.action(input, { signal: controller.signal });
|
|
388
|
-
} catch (error) {
|
|
389
|
-
if (this.generation !== generation || this.controller !== controller) throw error;
|
|
390
|
-
if (isAbortError(error, controller.signal)) {
|
|
391
|
-
this.setState({
|
|
392
|
-
status: "idle",
|
|
393
|
-
error: null
|
|
394
|
-
});
|
|
395
|
-
throw error;
|
|
396
|
-
}
|
|
397
|
-
this.setState({
|
|
398
|
-
status: "error",
|
|
399
|
-
error: normalizeAsyncDataError(error, "Unknown mutation error")
|
|
400
|
-
});
|
|
401
|
-
throw error;
|
|
402
|
-
}
|
|
403
|
-
if (this.generation !== generation || this.controller !== controller) return result;
|
|
404
|
-
this.setState({
|
|
405
|
-
status: "success",
|
|
406
|
-
error: null,
|
|
407
|
-
result
|
|
408
|
-
});
|
|
409
|
-
if (this.afterSuccess === "invalidate") {
|
|
410
|
-
const prefixes = this.affects?.(input, result) ?? [];
|
|
411
|
-
for (const prefix of new Set(prefixes)) invalidateQueries(prefix, true);
|
|
412
|
-
}
|
|
413
|
-
return result;
|
|
414
|
-
}
|
|
415
|
-
abort() {
|
|
416
|
-
if (this.state.status !== "pending") return;
|
|
417
|
-
this.generation += 1;
|
|
418
|
-
this.controller?.abort();
|
|
419
|
-
this.controller = null;
|
|
420
|
-
this.setState({
|
|
421
|
-
status: "idle",
|
|
422
|
-
error: null,
|
|
423
|
-
result: null
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
reset() {
|
|
427
|
-
this.generation += 1;
|
|
428
|
-
this.controller?.abort();
|
|
429
|
-
this.controller = null;
|
|
430
|
-
this.setState({
|
|
431
|
-
status: "idle",
|
|
432
|
-
error: null,
|
|
433
|
-
result: null
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
function createQuery(options) {
|
|
438
|
-
const instance = getCurrentComponentInstance();
|
|
439
|
-
const cache = getQueryCache();
|
|
440
|
-
if (!instance) {
|
|
441
|
-
let cell = cache.get(options.key);
|
|
442
|
-
if (!cell) {
|
|
443
|
-
cell = new QueryCell(options, options.key, cache);
|
|
444
|
-
cache.set(options.key, cell);
|
|
445
|
-
cell.ensureStarted();
|
|
446
|
-
} else cell.warnOnConflictingDefinition(options);
|
|
447
|
-
return cell;
|
|
448
|
-
}
|
|
449
|
-
const hookIndex = claimHookIndex(instance, "query");
|
|
450
|
-
ensureQueryCleanup(instance);
|
|
451
|
-
const slotStore = getQuerySlotStore(instance);
|
|
452
|
-
const existingSlot = slotStore.get(hookIndex);
|
|
453
|
-
if (existingSlot && existingSlot.key === options.key) {
|
|
454
|
-
existingSlot.cell.warnOnConflictingDefinition(options);
|
|
455
|
-
return existingSlot.cell;
|
|
456
|
-
}
|
|
457
|
-
if (existingSlot) existingSlot.cell.detach(instance, hookIndex);
|
|
458
|
-
let cell = cache.get(options.key);
|
|
459
|
-
if (!cell) {
|
|
460
|
-
cell = new QueryCell(options, options.key, cache);
|
|
461
|
-
cache.set(options.key, cell);
|
|
462
|
-
cell.ensureStarted();
|
|
463
|
-
} else cell.warnOnConflictingDefinition(options);
|
|
464
|
-
slotStore.set(hookIndex, {
|
|
465
|
-
key: options.key,
|
|
466
|
-
cell
|
|
467
|
-
});
|
|
468
|
-
cell.attach(instance, hookIndex);
|
|
469
|
-
return cell;
|
|
470
|
-
}
|
|
471
|
-
function invalidate(prefix, options) {
|
|
472
|
-
invalidateQueries(prefix, options?.markPendingWrite ?? false);
|
|
473
|
-
}
|
|
474
|
-
function serializeQueryKeyNumber(part) {
|
|
475
|
-
if (Number.isNaN(part)) return "NaN";
|
|
476
|
-
if (Object.is(part, -0)) return "-0";
|
|
477
|
-
if (part === Infinity) return "Infinity";
|
|
478
|
-
if (part === -Infinity) return "-Infinity";
|
|
479
|
-
return String(part);
|
|
480
|
-
}
|
|
481
|
-
function serializeQueryKeyPart(part) {
|
|
482
|
-
if (typeof part === "symbol") throw new Error("[Askr] queryScope() key parts cannot be symbols.");
|
|
483
|
-
if (part === null) return "null";
|
|
484
|
-
if (part === void 0) return "undefined";
|
|
485
|
-
switch (typeof part) {
|
|
486
|
-
case "string": return `s=${encodeURIComponent(part)}`;
|
|
487
|
-
case "number": return `n=${serializeQueryKeyNumber(part)}`;
|
|
488
|
-
case "boolean": return `b=${part ? "1" : "0"}`;
|
|
489
|
-
case "object":
|
|
490
|
-
if (Array.isArray(part)) return `a[${part.map((item) => serializeQueryKeyPart(item)).join(",")}]`;
|
|
491
|
-
return `o{${Object.keys(part).sort().map((key) => `${encodeURIComponent(key)}=${serializeQueryKeyPart(part[key])}`).join(",")}}`;
|
|
492
|
-
default: return String(part);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
function queryScope(namespace) {
|
|
496
|
-
if (typeof namespace !== "string" || namespace.trim().length === 0) throw new Error("[Askr] queryScope() requires a non-empty namespace string.");
|
|
497
|
-
const build = (parts) => [namespace, ...parts].map(serializeQueryKeyPart).join(":") + ":";
|
|
498
|
-
return {
|
|
499
|
-
key(...parts) {
|
|
500
|
-
return build(parts);
|
|
501
|
-
},
|
|
502
|
-
prefix(...parts) {
|
|
503
|
-
return build(parts);
|
|
504
|
-
},
|
|
505
|
-
invalidate(parts, options) {
|
|
506
|
-
invalidate(build(parts), options);
|
|
507
|
-
}
|
|
508
|
-
};
|
|
509
|
-
}
|
|
510
|
-
const INVALIDATE_ON_INTERVAL_OPTIONS_ERROR = "[Askr] invalidateOnInterval() requires an options object with a finite numeric intervalMs.";
|
|
511
|
-
function invalidateOnInterval(prefix, options) {
|
|
512
|
-
if (!options || typeof options !== "object" || typeof options.intervalMs !== "number" || !Number.isFinite(options.intervalMs)) throw new Error(INVALIDATE_ON_INTERVAL_OPTIONS_ERROR);
|
|
513
|
-
const when = [];
|
|
514
|
-
if (options.activeOn) when.push(routeActive(options.activeOn));
|
|
515
|
-
if (options.visibleOnly) when.push(documentVisible());
|
|
516
|
-
if (options.focusedOnly) when.push(windowFocused());
|
|
517
|
-
timer(options.intervalMs, () => {
|
|
518
|
-
invalidate(prefix, { markPendingWrite: options.markPendingWrite });
|
|
519
|
-
}, when.length > 0 ? { when } : void 0);
|
|
520
|
-
}
|
|
521
|
-
function createMutation(options) {
|
|
522
|
-
const instance = getCurrentComponentInstance();
|
|
523
|
-
if (!instance) return new MutationCell(options);
|
|
524
|
-
const hookIndex = claimHookIndex(instance, "mutation");
|
|
525
|
-
ensureMutationCleanup(instance);
|
|
526
|
-
const slotStore = getMutationSlotStore(instance);
|
|
527
|
-
const existing = slotStore.get(hookIndex);
|
|
528
|
-
if (existing) {
|
|
529
|
-
existing.setOptions(options);
|
|
530
|
-
return existing;
|
|
531
|
-
}
|
|
532
|
-
const created = new MutationCell(options);
|
|
533
|
-
slotStore.set(hookIndex, created);
|
|
534
|
-
return created;
|
|
535
|
-
}
|
|
536
|
-
//#endregion
|
|
537
|
-
export { createMutation, createQuery, invalidate, invalidateOnInterval, queryScope };
|
|
538
|
-
|
|
539
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { createDataRuntime, getDefaultDataRuntime } from "./data-runtime.js";
|
|
2
|
+
import { invalidate, invalidateOnInterval, queryScope } from "./invalidation.js";
|
|
3
|
+
import { createMutation } from "./mutation-cell.js";
|
|
4
|
+
import { createQuery } from "./query-cell.js";
|
|
5
|
+
export { createDataRuntime, createMutation, createQuery, getDefaultDataRuntime, invalidate, invalidateOnInterval, queryScope };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InvalidateOnIntervalOptions, InvalidateOptions, QueryScope } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/data/invalidation.d.ts
|
|
4
|
+
declare function invalidate(prefix: string, options?: InvalidateOptions): void;
|
|
5
|
+
declare function queryScope(namespace: string): QueryScope;
|
|
6
|
+
declare function invalidateOnInterval(prefix: string, options: InvalidateOnIntervalOptions): void;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { invalidate, invalidateOnInterval, queryScope };
|
|
9
|
+
//# sourceMappingURL=invalidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidation.d.ts","names":[],"sources":["../../src/data/invalidation.ts"],"mappings":";;;iBAkBgB,UAAA,CAAW,MAAA,UAAgB,OAAA,GAAU,iBAAiB;AAAA,iBAQtD,UAAA,CAAW,SAAA,WAAoB,UAAU;AAAA,iBAOzC,oBAAA,CACd,MAAA,UACA,OAAA,EAAS,2BAA2B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { invalidateQueriesForRuntime, resolveDataRuntimeState } from "./data-runtime.js";
|
|
2
|
+
import { documentVisible, routeActive, timer, windowFocused } from "../runtime/lifecycle-operations.js";
|
|
3
|
+
import "../runtime/operations.js";
|
|
4
|
+
import { createQueryScope } from "./query-key.js";
|
|
5
|
+
//#region src/data/invalidation.ts
|
|
6
|
+
function invalidate(prefix, options) {
|
|
7
|
+
invalidateQueriesForRuntime(resolveDataRuntimeState(options?.runtime), prefix, options?.markPendingWrite ?? false);
|
|
8
|
+
}
|
|
9
|
+
function queryScope(namespace) {
|
|
10
|
+
return createQueryScope(namespace, invalidate);
|
|
11
|
+
}
|
|
12
|
+
const INVALIDATE_ON_INTERVAL_OPTIONS_ERROR = "[Askr] invalidateOnInterval() requires an options object with a finite numeric intervalMs.";
|
|
13
|
+
function invalidateOnInterval(prefix, options) {
|
|
14
|
+
if (!options || typeof options !== "object" || typeof options.intervalMs !== "number" || !Number.isFinite(options.intervalMs)) throw new Error(INVALIDATE_ON_INTERVAL_OPTIONS_ERROR);
|
|
15
|
+
const runtimeState = resolveDataRuntimeState(options.runtime);
|
|
16
|
+
const when = [];
|
|
17
|
+
if (options.activeOn) when.push(routeActive(options.activeOn));
|
|
18
|
+
if (options.visibleOnly) when.push(documentVisible());
|
|
19
|
+
if (options.focusedOnly) when.push(windowFocused());
|
|
20
|
+
timer(options.intervalMs, () => {
|
|
21
|
+
invalidateQueriesForRuntime(runtimeState, prefix, options.markPendingWrite ?? false);
|
|
22
|
+
}, when.length > 0 ? { when } : void 0);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { invalidate, invalidateOnInterval, queryScope };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=invalidation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidation.js","names":[],"sources":["../../src/data/invalidation.ts"],"sourcesContent":["import {\n documentVisible,\n routeActive,\n timer,\n windowFocused,\n type ActivityPredicate,\n} from '../runtime/operations';\nimport {\n invalidateQueriesForRuntime,\n resolveDataRuntimeState,\n} from './data-runtime';\nimport { createQueryScope } from './query-key';\nimport type {\n InvalidateOnIntervalOptions,\n InvalidateOptions,\n QueryScope,\n} from './types';\n\nexport function invalidate(prefix: string, options?: InvalidateOptions): void {\n invalidateQueriesForRuntime(\n resolveDataRuntimeState(options?.runtime),\n prefix,\n options?.markPendingWrite ?? false\n );\n}\n\nexport function queryScope(namespace: string): QueryScope {\n return createQueryScope(namespace, invalidate);\n}\n\nconst INVALIDATE_ON_INTERVAL_OPTIONS_ERROR =\n '[Askr] invalidateOnInterval() requires an options object with a finite numeric intervalMs.';\n\nexport function invalidateOnInterval(\n prefix: string,\n options: InvalidateOnIntervalOptions\n): void {\n if (\n !options ||\n typeof options !== 'object' ||\n typeof options.intervalMs !== 'number' ||\n !Number.isFinite(options.intervalMs)\n ) {\n throw new Error(INVALIDATE_ON_INTERVAL_OPTIONS_ERROR);\n }\n\n const runtimeState = resolveDataRuntimeState(options.runtime);\n const when: ActivityPredicate[] = [];\n\n if (options.activeOn) {\n when.push(routeActive(options.activeOn));\n }\n\n if (options.visibleOnly) {\n when.push(documentVisible());\n }\n\n if (options.focusedOnly) {\n when.push(windowFocused());\n }\n\n timer(\n options.intervalMs,\n () => {\n invalidateQueriesForRuntime(\n runtimeState,\n prefix,\n options.markPendingWrite ?? false\n );\n },\n when.length > 0 ? { when } : undefined\n );\n}\n"],"mappings":";;;;;AAkBA,SAAgB,WAAW,QAAgB,SAAmC;CAC5E,4BACE,wBAAwB,SAAS,OAAO,GACxC,QACA,SAAS,oBAAoB,KAC/B;AACF;AAEA,SAAgB,WAAW,WAA+B;CACxD,OAAO,iBAAiB,WAAW,UAAU;AAC/C;AAEA,MAAM,uCACJ;AAEF,SAAgB,qBACd,QACA,SACM;CACN,IACE,CAAC,WACD,OAAO,YAAY,YACnB,OAAO,QAAQ,eAAe,YAC9B,CAAC,OAAO,SAAS,QAAQ,UAAU,GAEnC,MAAM,IAAI,MAAM,oCAAoC;CAGtD,MAAM,eAAe,wBAAwB,QAAQ,OAAO;CAC5D,MAAM,OAA4B,CAAC;CAEnC,IAAI,QAAQ,UACV,KAAK,KAAK,YAAY,QAAQ,QAAQ,CAAC;CAGzC,IAAI,QAAQ,aACV,KAAK,KAAK,gBAAgB,CAAC;CAG7B,IAAI,QAAQ,aACV,KAAK,KAAK,cAAc,CAAC;CAG3B,MACE,QAAQ,kBACF;EACJ,4BACE,cACA,QACA,QAAQ,oBAAoB,KAC9B;CACF,GACA,KAAK,SAAS,IAAI,EAAE,KAAK,IAAI,MAC/B;AACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Mutation, MutationOptions } from "./types.js";
|
|
2
|
+
import { DataRuntimeState } from "./data-runtime.js";
|
|
3
|
+
|
|
4
|
+
//#region src/data/mutation-cell.d.ts
|
|
5
|
+
declare class MutationCell<TInput, TResult> {
|
|
6
|
+
private readonly source;
|
|
7
|
+
private readonly runtimeState;
|
|
8
|
+
private action;
|
|
9
|
+
private affects?;
|
|
10
|
+
private afterSuccess?;
|
|
11
|
+
private controller;
|
|
12
|
+
private generation;
|
|
13
|
+
private state;
|
|
14
|
+
constructor(options: MutationOptions<TInput, TResult>, runtimeState: DataRuntimeState);
|
|
15
|
+
setOptions(options: MutationOptions<TInput, TResult>): void;
|
|
16
|
+
get status(): 'idle' | 'pending' | 'success' | 'error';
|
|
17
|
+
get pending(): boolean;
|
|
18
|
+
get error(): {} | null;
|
|
19
|
+
get result(): TResult | null;
|
|
20
|
+
private setState;
|
|
21
|
+
execute(input: TInput): Promise<TResult>;
|
|
22
|
+
abort(): void;
|
|
23
|
+
reset(): void;
|
|
24
|
+
}
|
|
25
|
+
declare function createMutation<TInput, TResult>(options: MutationOptions<TInput, TResult>): Mutation<TInput, TResult>;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { MutationCell, createMutation };
|
|
28
|
+
//# sourceMappingURL=mutation-cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation-cell.d.ts","names":[],"sources":["../../src/data/mutation-cell.ts"],"mappings":";;;;cAoBa,YAAA;EAAA,iBACM,MAAA;EAAA,iBACA,YAAA;EAAA,QACT,MAAA;EAAA,QACA,OAAA;EAAA,QACA,YAAA;EAAA,QACA,UAAA;EAAA,QACA,UAAA;EAAA,QAEA,KAAA;cAON,OAAA,EAAS,eAAA,CAAgB,MAAA,EAAQ,OAAA,GACjC,YAAA,EAAc,gBAAA;EAQhB,UAAA,CAAW,OAAA,EAAS,eAAA,CAAgB,MAAA,EAAQ,OAAA;EAAA,IAMxC,MAAA;EAAA,IAKA,OAAA;EAAA,IAKA,KAAA;EAAA,IAKA,MAAA,IAAU,OAAA;EAAA,QAKN,QAAA;EAQF,OAAA,CAAQ,KAAA,EAAO,MAAA,GAAS,OAAA,CAAQ,OAAA;EA8CtC,KAAA;EAWA,KAAA;AAAA;AAAA,iBAQc,cAAA,kBACd,OAAA,EAAS,eAAA,CAAgB,MAAA,EAAQ,OAAA,IAChC,QAAA,CAAS,MAAA,EAAQ,OAAA"}
|