@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
|
@@ -1,693 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { cleanupReadableSubscriptions, finalizeReadableSubscriptions, finalizeReadableSubscriptionsFromSnapshot } from "./readable.js";
|
|
6
|
-
import { incDevCounter, setDevValue } from "./dev-namespace.js";
|
|
7
|
-
import { isPromiseLike } from "../common/promise.js";
|
|
8
|
-
import { isBulkCommitActive } from "./fastlane.js";
|
|
9
|
-
import { cleanupInstancesUnder } from "../renderer/cleanup.js";
|
|
10
|
-
import { evaluate } from "../renderer/evaluate.js";
|
|
11
|
-
import "../renderer/index.js";
|
|
12
|
-
//#region src/runtime/component.ts
|
|
13
|
-
/**
|
|
14
|
-
* Register a mount operation that will run after the component is mounted
|
|
15
|
-
* Used by operations (task, on, timer, etc) to execute after render completes
|
|
16
|
-
*/
|
|
17
|
-
function createComponentInstance(id, fn, props, target) {
|
|
18
|
-
const instance = {
|
|
19
|
-
id,
|
|
20
|
-
fn,
|
|
21
|
-
props,
|
|
22
|
-
target,
|
|
23
|
-
parentInstance: currentInstance,
|
|
24
|
-
portalScope: currentInstance?.portalScope ?? currentPortalScope ?? null,
|
|
25
|
-
mounted: false,
|
|
26
|
-
abortController: null,
|
|
27
|
-
stateValues: [],
|
|
28
|
-
evaluationGeneration: 0,
|
|
29
|
-
notifyUpdate: null,
|
|
30
|
-
_pendingFlushTask: void 0,
|
|
31
|
-
_pendingRunTask: void 0,
|
|
32
|
-
_enqueueRun: void 0,
|
|
33
|
-
stateIndexCheck: -1,
|
|
34
|
-
expectedStateIndices: [],
|
|
35
|
-
firstRenderComplete: false,
|
|
36
|
-
mountOperations: [],
|
|
37
|
-
commitOperations: [],
|
|
38
|
-
cleanupFns: [],
|
|
39
|
-
lifecycleSlots: [],
|
|
40
|
-
lifecycleGeneration: 0,
|
|
41
|
-
hasPendingUpdate: false,
|
|
42
|
-
ownerFrame: null,
|
|
43
|
-
ssr: false,
|
|
44
|
-
cleanupStrict: false,
|
|
45
|
-
isRoot: false,
|
|
46
|
-
_currentRenderToken: void 0,
|
|
47
|
-
lastRenderToken: 0,
|
|
48
|
-
_pendingReadSources: void 0,
|
|
49
|
-
_pendingReadSourceVersions: void 0,
|
|
50
|
-
_lastReadSources: void 0,
|
|
51
|
-
devWarningsEmitted: void 0
|
|
52
|
-
};
|
|
53
|
-
instance._pendingRunTask = () => {
|
|
54
|
-
instance.hasPendingUpdate = false;
|
|
55
|
-
if (instance.notifyUpdate === null) return;
|
|
56
|
-
runComponent(instance);
|
|
57
|
-
};
|
|
58
|
-
instance._enqueueRun = () => {
|
|
59
|
-
if (!instance.hasPendingUpdate) {
|
|
60
|
-
instance.hasPendingUpdate = true;
|
|
61
|
-
globalScheduler.enqueue(instance._pendingRunTask);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
instance._pendingFlushTask = instance._pendingRunTask;
|
|
65
|
-
return instance;
|
|
66
|
-
}
|
|
67
|
-
let currentInstance = null;
|
|
68
|
-
let currentPortalScope = null;
|
|
69
|
-
let stateIndex = 0;
|
|
70
|
-
function ensureAbortController(instance) {
|
|
71
|
-
let controller = instance.abortController;
|
|
72
|
-
if (!controller || controller.signal.aborted) {
|
|
73
|
-
controller = new AbortController();
|
|
74
|
-
instance.abortController = controller;
|
|
75
|
-
}
|
|
76
|
-
return controller;
|
|
77
|
-
}
|
|
78
|
-
function getCurrentComponentInstance() {
|
|
79
|
-
return currentInstance;
|
|
80
|
-
}
|
|
81
|
-
function setCurrentComponentInstance(instance) {
|
|
82
|
-
currentInstance = instance;
|
|
83
|
-
currentPortalScope = instance?.portalScope ?? null;
|
|
84
|
-
}
|
|
85
|
-
function getCurrentPortalScope() {
|
|
86
|
-
return currentInstance?.portalScope ?? currentPortalScope;
|
|
87
|
-
}
|
|
88
|
-
let currentLifecycleCommitBatch = null;
|
|
89
|
-
function beginLifecycleCommitBatch() {
|
|
90
|
-
const batch = {
|
|
91
|
-
parent: currentLifecycleCommitBatch,
|
|
92
|
-
entries: [],
|
|
93
|
-
entriesByInstance: /* @__PURE__ */ new Map(),
|
|
94
|
-
readCommits: [],
|
|
95
|
-
readCommitsByInstance: /* @__PURE__ */ new Map(),
|
|
96
|
-
renderSnapshots: [],
|
|
97
|
-
renderSnapshotsByInstance: /* @__PURE__ */ new Map(),
|
|
98
|
-
active: true
|
|
99
|
-
};
|
|
100
|
-
currentLifecycleCommitBatch = batch;
|
|
101
|
-
return batch;
|
|
102
|
-
}
|
|
103
|
-
function closeLifecycleCommitBatch(batch) {
|
|
104
|
-
if (!batch.active) return false;
|
|
105
|
-
batch.active = false;
|
|
106
|
-
currentLifecycleCommitBatch = batch.parent;
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
function enqueueLifecycleCommit(batch, instance, wasFirstMount) {
|
|
110
|
-
const existing = batch.entriesByInstance.get(instance);
|
|
111
|
-
if (existing) {
|
|
112
|
-
existing.wasFirstMount = existing.wasFirstMount || wasFirstMount;
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const entry = {
|
|
116
|
-
instance,
|
|
117
|
-
wasFirstMount
|
|
118
|
-
};
|
|
119
|
-
batch.entriesByInstance.set(instance, entry);
|
|
120
|
-
batch.entries.push(entry);
|
|
121
|
-
}
|
|
122
|
-
function enqueueReadSubscriptionCommit(batch, instance, token, pendingReadSources, pendingReadSourceVersions) {
|
|
123
|
-
const existing = batch.readCommitsByInstance.get(instance);
|
|
124
|
-
const commit = existing ?? {
|
|
125
|
-
instance,
|
|
126
|
-
token,
|
|
127
|
-
pendingReadSources,
|
|
128
|
-
pendingReadSourceVersions
|
|
129
|
-
};
|
|
130
|
-
commit.token = token;
|
|
131
|
-
commit.pendingReadSources = pendingReadSources ? new Set(pendingReadSources) : void 0;
|
|
132
|
-
commit.pendingReadSourceVersions = pendingReadSourceVersions ? new Map(pendingReadSourceVersions) : void 0;
|
|
133
|
-
if (!existing) {
|
|
134
|
-
batch.readCommitsByInstance.set(instance, commit);
|
|
135
|
-
batch.readCommits.push(commit);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function enqueueInlineRenderSnapshot(batch, snapshot) {
|
|
139
|
-
if (batch.renderSnapshotsByInstance.has(snapshot.instance)) return;
|
|
140
|
-
batch.renderSnapshotsByInstance.set(snapshot.instance, snapshot);
|
|
141
|
-
batch.renderSnapshots.push(snapshot);
|
|
142
|
-
}
|
|
143
|
-
function captureInlineRenderSnapshot(instance) {
|
|
144
|
-
if (!currentLifecycleCommitBatch?.active) return;
|
|
145
|
-
enqueueInlineRenderSnapshot(currentLifecycleCommitBatch, {
|
|
146
|
-
instance,
|
|
147
|
-
props: instance.props,
|
|
148
|
-
ownerFrame: instance.ownerFrame,
|
|
149
|
-
portalScope: instance.portalScope,
|
|
150
|
-
parentInstance: instance.parentInstance,
|
|
151
|
-
isRoot: instance.isRoot
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
function finalizeInlineReadSubscriptions(instance, token, pendingReadSources, pendingReadSourceVersions) {
|
|
155
|
-
if (currentLifecycleCommitBatch?.active) {
|
|
156
|
-
enqueueReadSubscriptionCommit(currentLifecycleCommitBatch, instance, token, pendingReadSources, pendingReadSourceVersions);
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
finalizeReadableSubscriptionsFromSnapshot(instance, token, pendingReadSources, pendingReadSourceVersions);
|
|
160
|
-
}
|
|
161
|
-
function flushLifecycleCommitBatch(batch) {
|
|
162
|
-
if (!closeLifecycleCommitBatch(batch)) return;
|
|
163
|
-
if (batch.parent?.active) {
|
|
164
|
-
for (const snapshot of batch.renderSnapshots) enqueueInlineRenderSnapshot(batch.parent, snapshot);
|
|
165
|
-
for (const commit of batch.readCommits) enqueueReadSubscriptionCommit(batch.parent, commit.instance, commit.token, commit.pendingReadSources, commit.pendingReadSourceVersions);
|
|
166
|
-
for (const entry of batch.entries) enqueueLifecycleCommit(batch.parent, entry.instance, entry.wasFirstMount);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
for (const commit of batch.readCommits) finalizeReadableSubscriptionsFromSnapshot(commit.instance, commit.token, commit.pendingReadSources, commit.pendingReadSourceVersions);
|
|
170
|
-
for (const entry of batch.entries) executeCommittedLifecycleOperations(entry.instance, entry.wasFirstMount);
|
|
171
|
-
}
|
|
172
|
-
function discardLifecycleCommitBatch(batch) {
|
|
173
|
-
if (!closeLifecycleCommitBatch(batch)) return;
|
|
174
|
-
for (let index = batch.renderSnapshots.length - 1; index >= 0; index -= 1) {
|
|
175
|
-
const snapshot = batch.renderSnapshots[index];
|
|
176
|
-
snapshot.instance.props = snapshot.props;
|
|
177
|
-
snapshot.instance.ownerFrame = snapshot.ownerFrame;
|
|
178
|
-
snapshot.instance.portalScope = snapshot.portalScope;
|
|
179
|
-
snapshot.instance.parentInstance = snapshot.parentInstance;
|
|
180
|
-
snapshot.instance.isRoot = snapshot.isRoot;
|
|
181
|
-
}
|
|
182
|
-
for (const entry of batch.entries) {
|
|
183
|
-
if (entry.wasFirstMount) entry.instance.mountOperations = [];
|
|
184
|
-
discardCommitOperations(entry.instance);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
function registerCommitOperation(operation) {
|
|
188
|
-
const instance = getCurrentComponentInstance();
|
|
189
|
-
if (instance) {
|
|
190
|
-
if (isBulkCommitActive()) {
|
|
191
|
-
if (isDevelopmentEnvironment()) throw new Error("registerCommitOperation called during bulk commit fast-lane");
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
instance.commitOperations.push(operation);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
function settleLifecycleOperationResult(instance, lifecycleGeneration, result) {
|
|
198
|
-
if (isPromiseLike(result)) Promise.resolve(result).then((cleanup) => {
|
|
199
|
-
if (typeof cleanup === "function") {
|
|
200
|
-
if (instance.lifecycleGeneration === lifecycleGeneration && instance.mounted) {
|
|
201
|
-
instance.cleanupFns.push(cleanup);
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
try {
|
|
205
|
-
cleanup();
|
|
206
|
-
} catch (err) {
|
|
207
|
-
logger.error("[Askr] async mount cleanup failed:", err);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}, (err) => {
|
|
211
|
-
logger.error("[Askr] async mount operation failed:", err);
|
|
212
|
-
});
|
|
213
|
-
else if (typeof result === "function") instance.cleanupFns.push(result);
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Execute all mount operations for a component
|
|
217
|
-
* These run after the component is rendered and mounted to the DOM
|
|
218
|
-
*/
|
|
219
|
-
function executeMountOperations(instance) {
|
|
220
|
-
const mountOperations = instance.mountOperations;
|
|
221
|
-
if (mountOperations.length === 0) return;
|
|
222
|
-
const lifecycleGeneration = instance.lifecycleGeneration;
|
|
223
|
-
for (const operation of mountOperations) settleLifecycleOperationResult(instance, lifecycleGeneration, operation());
|
|
224
|
-
instance.mountOperations = [];
|
|
225
|
-
}
|
|
226
|
-
function executeCommitOperations(instance) {
|
|
227
|
-
const commitOperations = instance.commitOperations;
|
|
228
|
-
if (commitOperations.length === 0) return;
|
|
229
|
-
instance.commitOperations = [];
|
|
230
|
-
const lifecycleGeneration = instance.lifecycleGeneration;
|
|
231
|
-
for (const operation of commitOperations) settleLifecycleOperationResult(instance, lifecycleGeneration, operation());
|
|
232
|
-
}
|
|
233
|
-
function discardCommitOperations(instance) {
|
|
234
|
-
instance.commitOperations = [];
|
|
235
|
-
}
|
|
236
|
-
function executeCommittedLifecycleOperations(instance, wasFirstMount) {
|
|
237
|
-
if (wasFirstMount && instance.mountOperations.length > 0) executeMountOperations(instance);
|
|
238
|
-
if (instance.commitOperations.length > 0) executeCommitOperations(instance);
|
|
239
|
-
}
|
|
240
|
-
function commitLifecycleForInstance(instance, wasFirstMount) {
|
|
241
|
-
if (currentLifecycleCommitBatch) {
|
|
242
|
-
enqueueLifecycleCommit(currentLifecycleCommitBatch, instance, wasFirstMount);
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
executeCommittedLifecycleOperations(instance, wasFirstMount);
|
|
246
|
-
}
|
|
247
|
-
function commitRenderedComponent(instance) {
|
|
248
|
-
if (instance.mounted && instance.commitOperations.length > 0) commitLifecycleForInstance(instance, false);
|
|
249
|
-
}
|
|
250
|
-
function mountInstanceInline(instance, target) {
|
|
251
|
-
instance.target = target;
|
|
252
|
-
try {
|
|
253
|
-
if (target instanceof Element) {
|
|
254
|
-
const host = target;
|
|
255
|
-
const nextInstances = (host.__ASKR_INSTANCES ?? []).filter((entry) => entry !== instance);
|
|
256
|
-
nextInstances.push(instance);
|
|
257
|
-
host.__ASKR_INSTANCES = nextInstances;
|
|
258
|
-
host.__ASKR_INSTANCE = nextInstances[0] ?? instance;
|
|
259
|
-
}
|
|
260
|
-
} catch (err) {}
|
|
261
|
-
instance.notifyUpdate = instance._enqueueRun;
|
|
262
|
-
const wasFirstMount = !instance.mounted;
|
|
263
|
-
instance.mounted = true;
|
|
264
|
-
commitLifecycleForInstance(instance, wasFirstMount);
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Run a component synchronously: execute function, handle result
|
|
268
|
-
* This is the internal workhorse that manages async continuations and generation tracking.
|
|
269
|
-
* Must always be called through the scheduler.
|
|
270
|
-
*
|
|
271
|
-
* ACTOR INVARIANT: This function is enqueued as a task, never called directly.
|
|
272
|
-
*/
|
|
273
|
-
let _globalRenderCounter = 0;
|
|
274
|
-
function resetRenderState(instance) {
|
|
275
|
-
instance.stateIndexCheck = -1;
|
|
276
|
-
for (const state of instance.stateValues) if (state) state._hasBeenRead = false;
|
|
277
|
-
instance._pendingReadSources = void 0;
|
|
278
|
-
instance._pendingReadSourceVersions = void 0;
|
|
279
|
-
}
|
|
280
|
-
function nextRenderToken() {
|
|
281
|
-
return ++_globalRenderCounter;
|
|
282
|
-
}
|
|
283
|
-
function renderScopedComponent(instance, startStateIndex, render) {
|
|
284
|
-
const savedInstance = currentInstance;
|
|
285
|
-
const savedPortalScope = currentPortalScope;
|
|
286
|
-
const savedStateIndex = stateIndex;
|
|
287
|
-
instance.notifyUpdate = instance._enqueueRun;
|
|
288
|
-
resetRenderState(instance);
|
|
289
|
-
instance._currentRenderToken = nextRenderToken();
|
|
290
|
-
currentInstance = instance;
|
|
291
|
-
currentPortalScope = instance.portalScope ?? savedPortalScope;
|
|
292
|
-
stateIndex = startStateIndex;
|
|
293
|
-
let didComplete = false;
|
|
294
|
-
try {
|
|
295
|
-
const result = withContext({
|
|
296
|
-
parent: instance.ownerFrame,
|
|
297
|
-
values: null
|
|
298
|
-
}, render);
|
|
299
|
-
didComplete = true;
|
|
300
|
-
return result;
|
|
301
|
-
} finally {
|
|
302
|
-
if (!didComplete) {
|
|
303
|
-
instance._pendingReadSources = void 0;
|
|
304
|
-
instance._pendingReadSourceVersions = void 0;
|
|
305
|
-
instance._currentRenderToken = void 0;
|
|
306
|
-
}
|
|
307
|
-
currentInstance = savedInstance;
|
|
308
|
-
currentPortalScope = savedPortalScope;
|
|
309
|
-
stateIndex = savedStateIndex;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
function runComponent(instance) {
|
|
313
|
-
instance.notifyUpdate = instance._enqueueRun;
|
|
314
|
-
instance._currentRenderToken = nextRenderToken();
|
|
315
|
-
instance._pendingReadSources = void 0;
|
|
316
|
-
const domSnapshot = instance.target ? instance.target.innerHTML : "";
|
|
317
|
-
let result;
|
|
318
|
-
try {
|
|
319
|
-
result = executeComponentSync(instance);
|
|
320
|
-
} catch (err) {
|
|
321
|
-
discardCommitOperations(instance);
|
|
322
|
-
throw err;
|
|
323
|
-
}
|
|
324
|
-
if (isPromiseLike(result)) throw new Error("Async components are not supported. Components must be synchronous.");
|
|
325
|
-
else {
|
|
326
|
-
const fastlaneBridge = globalThis.__ASKR_FASTLANE;
|
|
327
|
-
try {
|
|
328
|
-
if (fastlaneBridge?.tryRuntimeFastLaneSync?.(instance, result)) {
|
|
329
|
-
warnUnusedStateReads(instance);
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
} catch (err) {
|
|
333
|
-
if (isDevelopmentEnvironment()) throw err;
|
|
334
|
-
}
|
|
335
|
-
globalScheduler.enqueue(() => {
|
|
336
|
-
if (!instance.target && instance._placeholder) {
|
|
337
|
-
if (result === null || result === void 0) {
|
|
338
|
-
finalizeReadSubscriptions(instance);
|
|
339
|
-
warnUnusedStateReads(instance);
|
|
340
|
-
commitRenderedComponent(instance);
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
const placeholder = instance._placeholder;
|
|
344
|
-
const parent = placeholder.parentNode;
|
|
345
|
-
if (!parent) {
|
|
346
|
-
logger.warn("[Askr] placeholder no longer in DOM, cannot render component");
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
const host = document.createElement("div");
|
|
350
|
-
const executionFrame = {
|
|
351
|
-
parent: instance.ownerFrame,
|
|
352
|
-
values: null
|
|
353
|
-
};
|
|
354
|
-
const oldInstance = currentInstance;
|
|
355
|
-
currentInstance = instance;
|
|
356
|
-
const lifecycleBatch = beginLifecycleCommitBatch();
|
|
357
|
-
try {
|
|
358
|
-
try {
|
|
359
|
-
withContext(executionFrame, () => {
|
|
360
|
-
evaluate(result, host);
|
|
361
|
-
});
|
|
362
|
-
parent.replaceChild(host, placeholder);
|
|
363
|
-
} catch (err) {
|
|
364
|
-
discardLifecycleCommitBatch(lifecycleBatch);
|
|
365
|
-
throw err;
|
|
366
|
-
}
|
|
367
|
-
instance.target = host;
|
|
368
|
-
instance._placeholder = void 0;
|
|
369
|
-
host.__ASKR_INSTANCE = instance;
|
|
370
|
-
flushLifecycleCommitBatch(lifecycleBatch);
|
|
371
|
-
finalizeReadSubscriptions(instance);
|
|
372
|
-
warnUnusedStateReads(instance);
|
|
373
|
-
commitRenderedComponent(instance);
|
|
374
|
-
} finally {
|
|
375
|
-
currentInstance = oldInstance;
|
|
376
|
-
}
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
if (instance.target) {
|
|
380
|
-
let oldChildren = [];
|
|
381
|
-
let restoredOldChildren = false;
|
|
382
|
-
try {
|
|
383
|
-
const wasFirstMount = !instance.mounted;
|
|
384
|
-
const oldInstance = currentInstance;
|
|
385
|
-
currentInstance = instance;
|
|
386
|
-
const executionFrame = {
|
|
387
|
-
parent: instance.ownerFrame,
|
|
388
|
-
values: null
|
|
389
|
-
};
|
|
390
|
-
oldChildren = Array.from(instance.target.childNodes);
|
|
391
|
-
const lifecycleBatch = beginLifecycleCommitBatch();
|
|
392
|
-
try {
|
|
393
|
-
try {
|
|
394
|
-
withContext(executionFrame, () => {
|
|
395
|
-
evaluate(result, instance.target, void 0, instance);
|
|
396
|
-
});
|
|
397
|
-
} catch (e) {
|
|
398
|
-
discardLifecycleCommitBatch(lifecycleBatch);
|
|
399
|
-
throw e;
|
|
400
|
-
}
|
|
401
|
-
} catch (e) {
|
|
402
|
-
try {
|
|
403
|
-
const newChildren = Array.from(instance.target.childNodes);
|
|
404
|
-
const preservedChildren = new Set(oldChildren);
|
|
405
|
-
for (const n of newChildren) {
|
|
406
|
-
if (preservedChildren.has(n)) continue;
|
|
407
|
-
try {
|
|
408
|
-
cleanupInstancesUnder(n);
|
|
409
|
-
} catch (err) {
|
|
410
|
-
logger.warn("[Askr] error cleaning up failed commit children:", err);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
} catch (_err) {}
|
|
414
|
-
try {
|
|
415
|
-
incDevCounter("__DOM_REPLACE_COUNT");
|
|
416
|
-
setDevValue("__LAST_DOM_REPLACE_STACK_COMPONENT_RESTORE", (/* @__PURE__ */ new Error()).stack);
|
|
417
|
-
} catch (e) {}
|
|
418
|
-
instance.target.replaceChildren(...oldChildren);
|
|
419
|
-
restoredOldChildren = true;
|
|
420
|
-
throw e;
|
|
421
|
-
} finally {
|
|
422
|
-
currentInstance = oldInstance;
|
|
423
|
-
}
|
|
424
|
-
flushLifecycleCommitBatch(lifecycleBatch);
|
|
425
|
-
finalizeReadSubscriptions(instance);
|
|
426
|
-
warnUnusedStateReads(instance);
|
|
427
|
-
instance.mounted = true;
|
|
428
|
-
executeCommittedLifecycleOperations(instance, wasFirstMount);
|
|
429
|
-
} catch (renderError) {
|
|
430
|
-
discardCommitOperations(instance);
|
|
431
|
-
try {
|
|
432
|
-
const currentChildren = Array.from(instance.target.childNodes);
|
|
433
|
-
const preservedChildren = restoredOldChildren ? new Set(oldChildren) : null;
|
|
434
|
-
for (const n of currentChildren) {
|
|
435
|
-
if (preservedChildren?.has(n)) continue;
|
|
436
|
-
try {
|
|
437
|
-
cleanupInstancesUnder(n);
|
|
438
|
-
} catch (err) {
|
|
439
|
-
logger.warn("[Askr] error cleaning up partial children during rollback:", err);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
} catch (_err) {}
|
|
443
|
-
try {
|
|
444
|
-
incDevCounter("__DOM_REPLACE_COUNT");
|
|
445
|
-
setDevValue("__LAST_DOM_REPLACE_STACK_COMPONENT_ROLLBACK", (/* @__PURE__ */ new Error()).stack);
|
|
446
|
-
instance.target.replaceChildren(...oldChildren);
|
|
447
|
-
} catch {
|
|
448
|
-
instance.target.innerHTML = domSnapshot;
|
|
449
|
-
}
|
|
450
|
-
throw renderError;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
/**
|
|
457
|
-
* Execute a component's render function synchronously.
|
|
458
|
-
* Returns either a vnode/promise immediately (does NOT render).
|
|
459
|
-
* Rendering happens separately through runComponent.
|
|
460
|
-
*/
|
|
461
|
-
function renderComponentInline(instance) {
|
|
462
|
-
instance.notifyUpdate = instance._enqueueRun;
|
|
463
|
-
const hadToken = instance._currentRenderToken !== void 0;
|
|
464
|
-
const prevToken = instance._currentRenderToken;
|
|
465
|
-
const prevPendingReads = instance._pendingReadSources;
|
|
466
|
-
const prevPendingReadVersions = instance._pendingReadSourceVersions;
|
|
467
|
-
const savedInstance = currentInstance;
|
|
468
|
-
const savedPortalScope = currentPortalScope;
|
|
469
|
-
if (!hadToken) {
|
|
470
|
-
instance._currentRenderToken = nextRenderToken();
|
|
471
|
-
instance._pendingReadSources = void 0;
|
|
472
|
-
instance._pendingReadSourceVersions = void 0;
|
|
473
|
-
}
|
|
474
|
-
try {
|
|
475
|
-
const result = executeComponentSync(instance);
|
|
476
|
-
if (!hadToken) finalizeInlineReadSubscriptions(instance, instance._currentRenderToken, instance._pendingReadSources, instance._pendingReadSourceVersions);
|
|
477
|
-
commitRenderedComponent(instance);
|
|
478
|
-
return result;
|
|
479
|
-
} finally {
|
|
480
|
-
instance._currentRenderToken = prevToken;
|
|
481
|
-
instance._pendingReadSources = prevPendingReads;
|
|
482
|
-
instance._pendingReadSourceVersions = prevPendingReadVersions;
|
|
483
|
-
currentInstance = savedInstance;
|
|
484
|
-
currentPortalScope = savedPortalScope;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
function warnUnusedStateReads(instance) {
|
|
488
|
-
for (let i = 0; i < instance.stateValues.length; i++) {
|
|
489
|
-
const state = instance.stateValues[i];
|
|
490
|
-
const hasCommittedUsage = (state?._readers?.size ?? 0) > 0 || (state?._derivedSubscribers?.size ?? 0) > 0;
|
|
491
|
-
if (state && !state._hasBeenRead && !state._hasEverBeenRead && !hasCommittedUsage) try {
|
|
492
|
-
const name = instance.fn?.name || "<anonymous>";
|
|
493
|
-
warnInstanceOnce(instance, `unused-state:${i}`, `[askr] Unused state variable detected in ${name} at index ${i}. State should be read during render or removed.`);
|
|
494
|
-
} catch {
|
|
495
|
-
warnInstanceOnce(instance, `unused-state:${i}`, `[askr] Unused state variable detected. State should be read during render or removed.`);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
function executeComponentSync(instance) {
|
|
500
|
-
resetRenderState(instance);
|
|
501
|
-
incDevCounter("componentRuns");
|
|
502
|
-
incDevCounter("componentReruns");
|
|
503
|
-
const savedPortalScope = currentPortalScope;
|
|
504
|
-
currentInstance = instance;
|
|
505
|
-
currentPortalScope = instance.portalScope ?? savedPortalScope;
|
|
506
|
-
stateIndex = 0;
|
|
507
|
-
let didComplete = false;
|
|
508
|
-
try {
|
|
509
|
-
const renderStartTime = isDevelopmentEnvironment() ? Date.now() : 0;
|
|
510
|
-
const context = { get signal() {
|
|
511
|
-
return ensureAbortController(instance).signal;
|
|
512
|
-
} };
|
|
513
|
-
const result = withContext({
|
|
514
|
-
parent: instance.ownerFrame,
|
|
515
|
-
values: null
|
|
516
|
-
}, () => instance.fn(instance.props, context));
|
|
517
|
-
const renderTime = Date.now() - renderStartTime;
|
|
518
|
-
if (renderTime > 5) warnInstanceOnce(instance, "slow-render", `[askr] Slow render detected: ${renderTime}ms. Consider optimizing component performance.`);
|
|
519
|
-
if (!instance.firstRenderComplete) instance.firstRenderComplete = true;
|
|
520
|
-
didComplete = true;
|
|
521
|
-
return result;
|
|
522
|
-
} finally {
|
|
523
|
-
if (!didComplete) discardCommitOperations(instance);
|
|
524
|
-
currentInstance = null;
|
|
525
|
-
currentPortalScope = savedPortalScope;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
/**
|
|
529
|
-
* Public entry point: Execute component with full lifecycle (execute + render)
|
|
530
|
-
* Handles both initial mount and re-execution. Always enqueues through scheduler.
|
|
531
|
-
* Single entry point to avoid lifecycle divergence.
|
|
532
|
-
*/
|
|
533
|
-
function executeComponent(instance) {
|
|
534
|
-
instance.abortController = null;
|
|
535
|
-
instance.notifyUpdate = instance._enqueueRun;
|
|
536
|
-
globalScheduler.enqueue(instance._pendingRunTask);
|
|
537
|
-
}
|
|
538
|
-
function getCurrentInstance() {
|
|
539
|
-
return currentInstance;
|
|
540
|
-
}
|
|
541
|
-
/**
|
|
542
|
-
* Get the abort signal for the current component
|
|
543
|
-
* Used to cancel async operations on unmount/navigation
|
|
544
|
-
*
|
|
545
|
-
* The signal is guaranteed to be aborted when:
|
|
546
|
-
* - Component unmounts
|
|
547
|
-
* - Navigation occurs (different route)
|
|
548
|
-
* - Parent is destroyed
|
|
549
|
-
*
|
|
550
|
-
* IMPORTANT: getSignal() must be called during component render execution.
|
|
551
|
-
* It captures the current component instance from context.
|
|
552
|
-
*
|
|
553
|
-
* @returns AbortSignal that will be aborted when component unmounts
|
|
554
|
-
* @throws Error if called outside component execution
|
|
555
|
-
*
|
|
556
|
-
* @example
|
|
557
|
-
* ```ts
|
|
558
|
-
* // ✅ Correct: called during render, used in async operation
|
|
559
|
-
* export async function UserPage({ id }: { id: string }) {
|
|
560
|
-
* const signal = getSignal();
|
|
561
|
-
* const user = await fetch(`/api/users/${id}`, { signal });
|
|
562
|
-
* return <div>{user.name}</div>;
|
|
563
|
-
* }
|
|
564
|
-
*
|
|
565
|
-
* // ✅ Correct: passed to event handler
|
|
566
|
-
* export function Button() {
|
|
567
|
-
* const signal = getSignal();
|
|
568
|
-
* return {
|
|
569
|
-
* type: 'button',
|
|
570
|
-
* props: {
|
|
571
|
-
* onClick: async () => {
|
|
572
|
-
* const data = await fetch(url, { signal });
|
|
573
|
-
* }
|
|
574
|
-
* }
|
|
575
|
-
* };
|
|
576
|
-
* }
|
|
577
|
-
*
|
|
578
|
-
* // ❌ Wrong: called outside component context
|
|
579
|
-
* const signal = getSignal(); // Error: not in component
|
|
580
|
-
* ```
|
|
581
|
-
*/
|
|
582
|
-
function getSignal() {
|
|
583
|
-
if (!currentInstance) throw new Error("getSignal() can only be called during component render execution. Ensure you are calling this from inside your component function.");
|
|
584
|
-
return ensureAbortController(currentInstance).signal;
|
|
585
|
-
}
|
|
586
|
-
/**
|
|
587
|
-
* Finalize read subscriptions for an instance after a successful commit.
|
|
588
|
-
* - Update per-state readers map to point to this instance's last committed token
|
|
589
|
-
* - Remove this instance from states it no longer reads
|
|
590
|
-
* This is deterministic and runs synchronously with commit to ensure
|
|
591
|
-
* subscribers are only notified when they actually read a state in their
|
|
592
|
-
* last committed render.
|
|
593
|
-
*/
|
|
594
|
-
function finalizeReadSubscriptions(instance) {
|
|
595
|
-
finalizeReadableSubscriptions(instance);
|
|
596
|
-
}
|
|
597
|
-
function getNextStateIndex() {
|
|
598
|
-
return stateIndex++;
|
|
599
|
-
}
|
|
600
|
-
function claimHookIndex(instance, hookName) {
|
|
601
|
-
const index = getNextStateIndex();
|
|
602
|
-
if (index < instance.stateIndexCheck) throw new Error(`Hook index violation: ${hookName}() call at index ${index}, but previously saw index ${instance.stateIndexCheck}. This happens when render-scoped hooks are called conditionally (inside if/for/etc). Move all ${hookName}() calls to the top level of your component function, before any conditionals.`);
|
|
603
|
-
instance.stateIndexCheck = index;
|
|
604
|
-
if (instance.firstRenderComplete) {
|
|
605
|
-
if (instance.expectedStateIndices[index] !== index) throw new Error(`Hook order violation: ${hookName}() called at index ${index}, but this index was not in the first render's sequence [${instance.expectedStateIndices.join(", ")}]. This usually means ${hookName}() is inside a conditional or loop. Move all render-scoped hooks to the top level of your component function.`);
|
|
606
|
-
} else instance.expectedStateIndices.push(index);
|
|
607
|
-
return index;
|
|
608
|
-
}
|
|
609
|
-
function getCurrentStateIndex() {
|
|
610
|
-
return stateIndex;
|
|
611
|
-
}
|
|
612
|
-
/**
|
|
613
|
-
* Mount a component instance.
|
|
614
|
-
* This is just an alias to executeComponent() to maintain API compatibility.
|
|
615
|
-
* All lifecycle logic is unified in executeComponent().
|
|
616
|
-
*/
|
|
617
|
-
function mountComponent(instance) {
|
|
618
|
-
executeComponent(instance);
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* Clean up component — abort pending operations
|
|
622
|
-
* Called on unmount or route change
|
|
623
|
-
*/
|
|
624
|
-
function cleanupComponent(instance) {
|
|
625
|
-
const savedInstance = currentInstance;
|
|
626
|
-
const savedPortalScope = currentPortalScope;
|
|
627
|
-
currentInstance = null;
|
|
628
|
-
currentPortalScope = null;
|
|
629
|
-
try {
|
|
630
|
-
const cleanupErrors = [];
|
|
631
|
-
const recordCleanupError = (message, err) => {
|
|
632
|
-
if (instance.cleanupStrict) cleanupErrors.push(err);
|
|
633
|
-
else if (isDevelopmentEnvironment()) logger.warn(message, err);
|
|
634
|
-
};
|
|
635
|
-
const ownedChildScopes = instance._ownedChildScopes;
|
|
636
|
-
if (ownedChildScopes && ownedChildScopes.size > 0) {
|
|
637
|
-
instance._ownedChildScopes = /* @__PURE__ */ new Set();
|
|
638
|
-
for (const scope of ownedChildScopes) try {
|
|
639
|
-
scope.dispose();
|
|
640
|
-
} catch (err) {
|
|
641
|
-
recordCleanupError("[Askr] child scope cleanup threw:", err);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
const cleanupFns = instance.cleanupFns;
|
|
645
|
-
instance.cleanupFns = [];
|
|
646
|
-
for (const cleanup of cleanupFns) try {
|
|
647
|
-
cleanup();
|
|
648
|
-
} catch (err) {
|
|
649
|
-
recordCleanupError("[Askr] cleanup function threw:", err);
|
|
650
|
-
}
|
|
651
|
-
try {
|
|
652
|
-
cleanupReadableSubscriptions(instance);
|
|
653
|
-
} catch (err) {
|
|
654
|
-
recordCleanupError("[Askr] readable subscription cleanup threw:", err);
|
|
655
|
-
}
|
|
656
|
-
try {
|
|
657
|
-
if (instance.abortController && !instance.abortController.signal.aborted) instance.abortController.abort();
|
|
658
|
-
} catch (err) {
|
|
659
|
-
recordCleanupError("[Askr] abort controller cleanup threw:", err);
|
|
660
|
-
}
|
|
661
|
-
instance.abortController = null;
|
|
662
|
-
instance.lifecycleGeneration++;
|
|
663
|
-
instance.evaluationGeneration++;
|
|
664
|
-
instance.mountOperations = [];
|
|
665
|
-
instance.commitOperations = [];
|
|
666
|
-
instance.lifecycleSlots = [];
|
|
667
|
-
instance.hasPendingUpdate = false;
|
|
668
|
-
instance.notifyUpdate = null;
|
|
669
|
-
instance._placeholder = void 0;
|
|
670
|
-
instance.mounted = false;
|
|
671
|
-
if (cleanupErrors.length > 0) throw new AggregateError(cleanupErrors, `Cleanup failed for component ${instance.id}`);
|
|
672
|
-
} finally {
|
|
673
|
-
currentInstance = savedInstance;
|
|
674
|
-
currentPortalScope = savedPortalScope;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
function registerOwnedChildScope(instance, scope) {
|
|
678
|
-
(instance._ownedChildScopes ??= /* @__PURE__ */ new Set()).add(scope);
|
|
679
|
-
}
|
|
680
|
-
function unregisterOwnedChildScope(instance, scope) {
|
|
681
|
-
instance._ownedChildScopes?.delete(scope);
|
|
682
|
-
}
|
|
683
|
-
function warnInstanceOnce(instance, key, message) {
|
|
684
|
-
if (isProductionEnvironment()) return;
|
|
685
|
-
const warnings = instance.devWarningsEmitted ??= /* @__PURE__ */ new Set();
|
|
686
|
-
if (warnings.has(key)) return;
|
|
687
|
-
warnings.add(key);
|
|
688
|
-
logger.warn(message);
|
|
689
|
-
}
|
|
690
|
-
//#endregion
|
|
1
|
+
import { claimHookIndex, getCurrentComponentInstance, getCurrentInstance, getCurrentPortalScope, getCurrentStateIndex, getSignal, setCurrentComponentInstance } from "./component-scope.js";
|
|
2
|
+
import { cleanupComponent, registerOwnedChildScope, unregisterOwnedChildScope } from "./component-cleanup.js";
|
|
3
|
+
import { captureInlineRenderSnapshot, createComponentInstance, finalizeReadSubscriptions, mountComponent, mountInstanceInline, registerCommitOperation, renderComponentInline, renderScopedComponent, warnUnusedStateReads } from "./component-internal.js";
|
|
4
|
+
import "./component-facade.js";
|
|
691
5
|
export { captureInlineRenderSnapshot, claimHookIndex, cleanupComponent, createComponentInstance, finalizeReadSubscriptions, getCurrentComponentInstance, getCurrentInstance, getCurrentPortalScope, getCurrentStateIndex, getSignal, mountComponent, mountInstanceInline, registerCommitOperation, registerOwnedChildScope, renderComponentInline, renderScopedComponent, setCurrentComponentInstance, unregisterOwnedChildScope, warnUnusedStateReads };
|
|
692
|
-
|
|
693
|
-
//# sourceMappingURL=component.js.map
|
|
@@ -65,5 +65,5 @@ declare function getCurrentContextFrame(): ContextFrame | null;
|
|
|
65
65
|
*/
|
|
66
66
|
declare function getTopContextSnapshot(): ContextFrame | null;
|
|
67
67
|
//#endregion
|
|
68
|
-
export { Context, ContextFrame, defineContext, readContext };
|
|
68
|
+
export { Context, ContextFrame, ContextKey, defineContext, readContext };
|
|
69
69
|
//# sourceMappingURL=context.d.ts.map
|