@askrjs/askr 0.0.48 → 0.0.50
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 +6 -2
- 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 +3 -1
- package/dist/jsx/types.d.ts.map +1 -1
- package/dist/jsx/types.js +2 -1
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/jsx-dev-runtime.d.ts.map +1 -1
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/jsx-runtime2.d.ts +3 -2
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-lifecycle.js","names":[],"sources":["../../src/runtime/component-lifecycle.ts"],"sourcesContent":["import { isDevelopmentEnvironment } from '../common/env';\nimport { isPromiseLike } from '../common/promise';\nimport type { Props } from '../common/props';\nimport { logger } from '../dev/logger';\nimport type { ContextFrame } from './context';\nimport type { ComponentInstance } from './component-internal';\nimport { isBulkCommitActive } from './fastlane';\nimport {\n type ReadableSource,\n finalizeReadableSubscriptionsFromSnapshot,\n} from './readable';\n\nexport type LifecycleOperation = () =>\n | void\n | (() => void)\n | PromiseLike<void | (() => void)>;\n\ntype LifecycleCommitBatchEntry = {\n instance: ComponentInstance;\n wasFirstMount: boolean;\n};\n\ntype ReadSubscriptionCommit = {\n instance: ComponentInstance;\n token: number;\n pendingReadSources: Set<ReadableSource<unknown>> | undefined;\n pendingReadSourceVersions: Map<ReadableSource<unknown>, number> | undefined;\n};\n\ntype InlineRenderSnapshot = {\n instance: ComponentInstance;\n props: Props;\n ownerFrame: ContextFrame | null;\n portalScope: object | null;\n parentInstance: ComponentInstance | null;\n isRoot: boolean | undefined;\n};\n\nexport type LifecycleCommitBatch = {\n parent: LifecycleCommitBatch | null;\n entries: LifecycleCommitBatchEntry[];\n entriesByInstance: Map<ComponentInstance, LifecycleCommitBatchEntry>;\n readCommits: ReadSubscriptionCommit[];\n readCommitsByInstance: Map<ComponentInstance, ReadSubscriptionCommit>;\n renderSnapshots: InlineRenderSnapshot[];\n renderSnapshotsByInstance: Map<ComponentInstance, InlineRenderSnapshot>;\n active: boolean;\n};\n\nlet currentLifecycleCommitBatch: LifecycleCommitBatch | null = null;\n\nexport function beginLifecycleCommitBatch(): LifecycleCommitBatch {\n const batch: LifecycleCommitBatch = {\n parent: currentLifecycleCommitBatch,\n entries: [],\n entriesByInstance: new Map(),\n readCommits: [],\n readCommitsByInstance: new Map(),\n renderSnapshots: [],\n renderSnapshotsByInstance: new Map(),\n active: true,\n };\n currentLifecycleCommitBatch = batch;\n return batch;\n}\n\nfunction closeLifecycleCommitBatch(batch: LifecycleCommitBatch): boolean {\n if (!batch.active) {\n return false;\n }\n\n batch.active = false;\n currentLifecycleCommitBatch = batch.parent;\n return true;\n}\n\nfunction enqueueLifecycleCommit(\n batch: LifecycleCommitBatch,\n instance: ComponentInstance,\n wasFirstMount: boolean\n): void {\n const existing = batch.entriesByInstance.get(instance);\n if (existing) {\n existing.wasFirstMount = existing.wasFirstMount || wasFirstMount;\n return;\n }\n\n const entry = { instance, wasFirstMount };\n batch.entriesByInstance.set(instance, entry);\n batch.entries.push(entry);\n}\n\nfunction enqueueReadSubscriptionCommit(\n batch: LifecycleCommitBatch,\n instance: ComponentInstance,\n token: number,\n pendingReadSources: Set<ReadableSource<unknown>> | undefined,\n pendingReadSourceVersions: Map<ReadableSource<unknown>, number> | undefined\n): void {\n const existing = batch.readCommitsByInstance.get(instance);\n const commit = existing ?? {\n instance,\n token,\n pendingReadSources,\n pendingReadSourceVersions,\n };\n\n commit.token = token;\n commit.pendingReadSources = pendingReadSources\n ? new Set(pendingReadSources)\n : undefined;\n commit.pendingReadSourceVersions = pendingReadSourceVersions\n ? new Map(pendingReadSourceVersions)\n : undefined;\n\n if (!existing) {\n batch.readCommitsByInstance.set(instance, commit);\n batch.readCommits.push(commit);\n }\n}\n\nfunction enqueueInlineRenderSnapshot(\n batch: LifecycleCommitBatch,\n snapshot: InlineRenderSnapshot\n): void {\n if (batch.renderSnapshotsByInstance.has(snapshot.instance)) {\n return;\n }\n\n batch.renderSnapshotsByInstance.set(snapshot.instance, snapshot);\n batch.renderSnapshots.push(snapshot);\n}\n\nexport function captureInlineRenderSnapshot(instance: ComponentInstance): void {\n if (!currentLifecycleCommitBatch?.active) {\n return;\n }\n\n enqueueInlineRenderSnapshot(currentLifecycleCommitBatch, {\n instance,\n props: instance.props,\n ownerFrame: instance.ownerFrame,\n portalScope: instance.portalScope,\n parentInstance: instance.parentInstance,\n isRoot: instance.isRoot,\n });\n}\n\nexport function finalizeInlineReadSubscriptions(\n instance: ComponentInstance,\n token: number,\n pendingReadSources: Set<ReadableSource<unknown>> | undefined,\n pendingReadSourceVersions: Map<ReadableSource<unknown>, number> | undefined\n): void {\n if (currentLifecycleCommitBatch?.active) {\n enqueueReadSubscriptionCommit(\n currentLifecycleCommitBatch,\n instance,\n token,\n pendingReadSources,\n pendingReadSourceVersions\n );\n return;\n }\n\n finalizeReadableSubscriptionsFromSnapshot(\n instance,\n token,\n pendingReadSources,\n pendingReadSourceVersions\n );\n}\n\nexport function flushLifecycleCommitBatch(batch: LifecycleCommitBatch): void {\n if (!closeLifecycleCommitBatch(batch)) {\n return;\n }\n\n if (batch.parent?.active) {\n for (const snapshot of batch.renderSnapshots) {\n enqueueInlineRenderSnapshot(batch.parent, snapshot);\n }\n for (const commit of batch.readCommits) {\n enqueueReadSubscriptionCommit(\n batch.parent,\n commit.instance,\n commit.token,\n commit.pendingReadSources,\n commit.pendingReadSourceVersions\n );\n }\n for (const entry of batch.entries) {\n enqueueLifecycleCommit(batch.parent, entry.instance, entry.wasFirstMount);\n }\n return;\n }\n\n for (const commit of batch.readCommits) {\n finalizeReadableSubscriptionsFromSnapshot(\n commit.instance,\n commit.token,\n commit.pendingReadSources,\n commit.pendingReadSourceVersions\n );\n }\n\n for (const entry of batch.entries) {\n executeCommittedLifecycleOperations(entry.instance, entry.wasFirstMount);\n }\n}\n\nexport function discardLifecycleCommitBatch(batch: LifecycleCommitBatch): void {\n if (!closeLifecycleCommitBatch(batch)) {\n return;\n }\n\n for (let index = batch.renderSnapshots.length - 1; index >= 0; index -= 1) {\n const snapshot = batch.renderSnapshots[index]!;\n snapshot.instance.props = snapshot.props;\n snapshot.instance.ownerFrame = snapshot.ownerFrame;\n snapshot.instance.portalScope = snapshot.portalScope;\n snapshot.instance.parentInstance = snapshot.parentInstance;\n snapshot.instance.isRoot = snapshot.isRoot;\n }\n\n for (const entry of batch.entries) {\n if (entry.wasFirstMount) {\n entry.instance.mountOperations = [];\n }\n discardCommitOperations(entry.instance);\n }\n}\n\nexport function registerMountOperationForInstance(\n instance: ComponentInstance | null,\n operation: LifecycleOperation\n): void {\n if (instance) {\n // If we're in bulk-commit fast lane, registering mount operations is a\n // violation of the fast-lane preconditions. Throw in dev, otherwise ignore\n // silently in production (we must avoid scheduling work during bulk commit).\n if (isBulkCommitActive()) {\n if (isDevelopmentEnvironment()) {\n throw new Error(\n 'registerMountOperation called during bulk commit fast-lane'\n );\n }\n return;\n }\n instance.mountOperations.push(operation);\n }\n}\n\nexport function registerCommitOperationForInstance(\n instance: ComponentInstance | null,\n operation: LifecycleOperation\n): void {\n if (instance) {\n if (isBulkCommitActive()) {\n if (isDevelopmentEnvironment()) {\n throw new Error(\n 'registerCommitOperation called during bulk commit fast-lane'\n );\n }\n return;\n }\n instance.commitOperations.push(operation);\n }\n}\n\nfunction settleLifecycleOperationResult(\n instance: ComponentInstance,\n lifecycleGeneration: number,\n result: void | (() => void) | PromiseLike<void | (() => void)>\n): void {\n if (isPromiseLike(result)) {\n Promise.resolve(result).then(\n (cleanup) => {\n if (typeof cleanup === 'function') {\n if (\n instance.lifecycleGeneration === lifecycleGeneration &&\n instance.mounted\n ) {\n instance.cleanupFns.push(cleanup);\n return;\n }\n\n try {\n cleanup();\n } catch (err) {\n logger.error('[Askr] async mount cleanup failed:', err);\n }\n }\n },\n (err) => {\n logger.error('[Askr] async mount operation failed:', err);\n }\n );\n } else if (typeof result === 'function') {\n instance.cleanupFns.push(result);\n }\n}\n\nfunction executeMountOperations(instance: ComponentInstance): void {\n const mountOperations = instance.mountOperations;\n if (mountOperations.length === 0) {\n return;\n }\n\n const lifecycleGeneration = instance.lifecycleGeneration;\n\n for (const operation of mountOperations) {\n settleLifecycleOperationResult(instance, lifecycleGeneration, operation());\n }\n // Clear the operations array so they don't run again on subsequent renders\n instance.mountOperations = [];\n}\n\nfunction executeCommitOperations(instance: ComponentInstance): void {\n const commitOperations = instance.commitOperations;\n if (commitOperations.length === 0) {\n return;\n }\n\n instance.commitOperations = [];\n const lifecycleGeneration = instance.lifecycleGeneration;\n\n for (const operation of commitOperations) {\n settleLifecycleOperationResult(instance, lifecycleGeneration, operation());\n }\n}\n\nexport function discardCommitOperations(instance: ComponentInstance): void {\n instance.commitOperations = [];\n}\n\nexport function executeCommittedLifecycleOperations(\n instance: ComponentInstance,\n wasFirstMount: boolean\n): void {\n if (wasFirstMount && instance.mountOperations.length > 0) {\n executeMountOperations(instance);\n }\n if (instance.commitOperations.length > 0) {\n executeCommitOperations(instance);\n }\n}\n\nexport function commitLifecycleForInstance(\n instance: ComponentInstance,\n wasFirstMount: boolean\n): void {\n if (currentLifecycleCommitBatch) {\n enqueueLifecycleCommit(\n currentLifecycleCommitBatch,\n instance,\n wasFirstMount\n );\n return;\n }\n\n executeCommittedLifecycleOperations(instance, wasFirstMount);\n}\n\nexport function commitRenderedComponent(instance: ComponentInstance): void {\n if (instance.mounted && instance.commitOperations.length > 0) {\n commitLifecycleForInstance(instance, false);\n }\n}\n"],"mappings":";;;;;;AAiDA,IAAI,8BAA2D;AAE/D,SAAgB,4BAAkD;CAChE,MAAM,QAA8B;EAClC,QAAQ;EACR,SAAS,CAAC;EACV,mCAAmB,IAAI,IAAI;EAC3B,aAAa,CAAC;EACd,uCAAuB,IAAI,IAAI;EAC/B,iBAAiB,CAAC;EAClB,2CAA2B,IAAI,IAAI;EACnC,QAAQ;CACV;CACA,8BAA8B;CAC9B,OAAO;AACT;AAEA,SAAS,0BAA0B,OAAsC;CACvE,IAAI,CAAC,MAAM,QACT,OAAO;CAGT,MAAM,SAAS;CACf,8BAA8B,MAAM;CACpC,OAAO;AACT;AAEA,SAAS,uBACP,OACA,UACA,eACM;CACN,MAAM,WAAW,MAAM,kBAAkB,IAA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BAA2B,UAAU,KAAK;AAE9C"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ReadableSource } from "./readable.js";
|
|
2
|
+
import { ComponentInstance } from "./component-internal.js";
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/component-scope.d.ts
|
|
5
|
+
type ComponentScopeSnapshot = {
|
|
6
|
+
instance: ComponentInstance | null;
|
|
7
|
+
portalScope: object | null;
|
|
8
|
+
stateIndex: number;
|
|
9
|
+
};
|
|
10
|
+
type InstancePortalScopeSnapshot = {
|
|
11
|
+
instance: ComponentInstance | null;
|
|
12
|
+
portalScope: object | null;
|
|
13
|
+
};
|
|
14
|
+
type InlineRenderTrackingSnapshot = {
|
|
15
|
+
currentRenderToken: number | undefined;
|
|
16
|
+
pendingReadSources: Set<ReadableSource<unknown>> | undefined;
|
|
17
|
+
pendingReadSourceVersions: Map<ReadableSource<unknown>, number> | undefined;
|
|
18
|
+
};
|
|
19
|
+
declare function getCurrentComponentInstance(): ComponentInstance | null;
|
|
20
|
+
declare function getCurrentInstance(): ComponentInstance | null;
|
|
21
|
+
declare function setCurrentComponentInstance(instance: ComponentInstance | null): void;
|
|
22
|
+
declare function getCurrentPortalScope(): object | null;
|
|
23
|
+
declare function getSignalForInstance(instance: ComponentInstance): AbortSignal;
|
|
24
|
+
/**
|
|
25
|
+
* Get the abort signal for the current component.
|
|
26
|
+
*
|
|
27
|
+
* The signal is guaranteed to be aborted when:
|
|
28
|
+
* - Component unmounts
|
|
29
|
+
* - Navigation occurs (different route)
|
|
30
|
+
* - Parent is destroyed
|
|
31
|
+
*/
|
|
32
|
+
declare function getSignal(): AbortSignal;
|
|
33
|
+
declare function resetRenderState(instance: ComponentInstance): void;
|
|
34
|
+
declare function beginRenderTracking(instance: ComponentInstance): void;
|
|
35
|
+
declare function clearRenderTracking(instance: ComponentInstance): void;
|
|
36
|
+
declare function captureInlineRenderTracking(instance: ComponentInstance): InlineRenderTrackingSnapshot;
|
|
37
|
+
declare function restoreInlineRenderTracking(instance: ComponentInstance, snapshot: InlineRenderTrackingSnapshot): void;
|
|
38
|
+
declare function enterRenderScopedComponent(instance: ComponentInstance, startStateIndex: number): ComponentScopeSnapshot;
|
|
39
|
+
declare function restoreRenderScopedComponent(snapshot: ComponentScopeSnapshot): void;
|
|
40
|
+
declare function captureInlineComponentScope(): InstancePortalScopeSnapshot;
|
|
41
|
+
declare function restoreInlineComponentScope(snapshot: InstancePortalScopeSnapshot): void;
|
|
42
|
+
declare function enterComponentExecutionScope(instance: ComponentInstance): object | null;
|
|
43
|
+
declare function exitComponentExecutionScope(savedPortalScope: object | null): void;
|
|
44
|
+
declare function enterDomCommitScope(instance: ComponentInstance): ComponentInstance | null;
|
|
45
|
+
declare function restoreDomCommitScope(previousInstance: ComponentInstance | null): void;
|
|
46
|
+
declare function clearCurrentComponentScope(): ComponentScopeSnapshot;
|
|
47
|
+
declare function restoreCurrentComponentScope(snapshot: ComponentScopeSnapshot): void;
|
|
48
|
+
declare function getNextStateIndex(): number;
|
|
49
|
+
declare function claimHookIndex(instance: ComponentInstance, hookName: string): number;
|
|
50
|
+
declare function getCurrentStateIndex(): number;
|
|
51
|
+
declare function resetStateIndex(): void;
|
|
52
|
+
declare function setStateIndex(value: number): void;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { getSignal };
|
|
55
|
+
//# sourceMappingURL=component-scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-scope.d.ts","names":[],"sources":["../../src/runtime/component-scope.ts"],"mappings":";;;;KASK,sBAAA;EACH,QAAA,EAAU,iBAAiB;EAC3B,WAAA;EACA,UAAA;AAAA;AAAA,KAGG,2BAAA;EACH,QAAA,EAAU,iBAAiB;EAC3B,WAAA;AAAA;AAAA,KAGG,4BAAA;EACH,kBAAA;EACA,kBAAA,EAAoB,GAAA,CAAI,cAAA;EACxB,yBAAA,EAA2B,GAAA,CAAI,cAAA;AAAA;AAAA,iBA0CjB,2BAAA,IAA+B,iBAAiB;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
|
|
4
|
+
let stateIndex = 0;
|
|
5
|
+
let globalRenderCounter = 0;
|
|
6
|
+
function ensureAbortController(instance) {
|
|
7
|
+
let controller = instance.abortController;
|
|
8
|
+
if (!controller || controller.signal.aborted) {
|
|
9
|
+
controller = new AbortController();
|
|
10
|
+
instance.abortController = controller;
|
|
11
|
+
}
|
|
12
|
+
return controller;
|
|
13
|
+
}
|
|
14
|
+
function nextRenderToken() {
|
|
15
|
+
return ++globalRenderCounter;
|
|
16
|
+
}
|
|
17
|
+
function captureScope() {
|
|
18
|
+
return {
|
|
19
|
+
instance: currentInstance,
|
|
20
|
+
portalScope: currentPortalScope,
|
|
21
|
+
stateIndex
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function restoreScope(snapshot) {
|
|
25
|
+
currentInstance = snapshot.instance;
|
|
26
|
+
currentPortalScope = snapshot.portalScope;
|
|
27
|
+
stateIndex = snapshot.stateIndex;
|
|
28
|
+
}
|
|
29
|
+
function captureInstancePortalScope() {
|
|
30
|
+
return {
|
|
31
|
+
instance: currentInstance,
|
|
32
|
+
portalScope: currentPortalScope
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function getCurrentComponentInstance() {
|
|
36
|
+
return currentInstance;
|
|
37
|
+
}
|
|
38
|
+
function getCurrentInstance() {
|
|
39
|
+
return currentInstance;
|
|
40
|
+
}
|
|
41
|
+
function setCurrentComponentInstance(instance) {
|
|
42
|
+
currentInstance = instance;
|
|
43
|
+
currentPortalScope = instance?.portalScope ?? null;
|
|
44
|
+
}
|
|
45
|
+
function getCurrentPortalScope() {
|
|
46
|
+
return currentInstance?.portalScope ?? currentPortalScope;
|
|
47
|
+
}
|
|
48
|
+
function getSignalForInstance(instance) {
|
|
49
|
+
return ensureAbortController(instance).signal;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get the abort signal for the current component.
|
|
53
|
+
*
|
|
54
|
+
* The signal is guaranteed to be aborted when:
|
|
55
|
+
* - Component unmounts
|
|
56
|
+
* - Navigation occurs (different route)
|
|
57
|
+
* - Parent is destroyed
|
|
58
|
+
*/
|
|
59
|
+
function getSignal() {
|
|
60
|
+
if (!currentInstance) throw new Error("getSignal() can only be called during component render execution. Ensure you are calling this from inside your component function.");
|
|
61
|
+
return getSignalForInstance(currentInstance);
|
|
62
|
+
}
|
|
63
|
+
function resetRenderState(instance) {
|
|
64
|
+
instance.stateIndexCheck = -1;
|
|
65
|
+
for (const state of instance.stateValues) if (state) state._hasBeenRead = false;
|
|
66
|
+
instance._pendingReadSources = void 0;
|
|
67
|
+
instance._pendingReadSourceVersions = void 0;
|
|
68
|
+
}
|
|
69
|
+
function beginRenderTracking(instance) {
|
|
70
|
+
instance._currentRenderToken = nextRenderToken();
|
|
71
|
+
instance._pendingReadSources = void 0;
|
|
72
|
+
instance._pendingReadSourceVersions = void 0;
|
|
73
|
+
}
|
|
74
|
+
function clearRenderTracking(instance) {
|
|
75
|
+
instance._pendingReadSources = void 0;
|
|
76
|
+
instance._pendingReadSourceVersions = void 0;
|
|
77
|
+
instance._currentRenderToken = void 0;
|
|
78
|
+
}
|
|
79
|
+
function captureInlineRenderTracking(instance) {
|
|
80
|
+
return {
|
|
81
|
+
currentRenderToken: instance._currentRenderToken,
|
|
82
|
+
pendingReadSources: instance._pendingReadSources,
|
|
83
|
+
pendingReadSourceVersions: instance._pendingReadSourceVersions
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function restoreInlineRenderTracking(instance, snapshot) {
|
|
87
|
+
instance._currentRenderToken = snapshot.currentRenderToken;
|
|
88
|
+
instance._pendingReadSources = snapshot.pendingReadSources;
|
|
89
|
+
instance._pendingReadSourceVersions = snapshot.pendingReadSourceVersions;
|
|
90
|
+
}
|
|
91
|
+
function enterRenderScopedComponent(instance, startStateIndex) {
|
|
92
|
+
const savedScope = captureScope();
|
|
93
|
+
currentInstance = instance;
|
|
94
|
+
currentPortalScope = instance.portalScope ?? savedScope.portalScope;
|
|
95
|
+
stateIndex = startStateIndex;
|
|
96
|
+
return savedScope;
|
|
97
|
+
}
|
|
98
|
+
function restoreRenderScopedComponent(snapshot) {
|
|
99
|
+
restoreScope(snapshot);
|
|
100
|
+
}
|
|
101
|
+
function captureInlineComponentScope() {
|
|
102
|
+
return captureInstancePortalScope();
|
|
103
|
+
}
|
|
104
|
+
function restoreInlineComponentScope(snapshot) {
|
|
105
|
+
currentInstance = snapshot.instance;
|
|
106
|
+
currentPortalScope = snapshot.portalScope;
|
|
107
|
+
}
|
|
108
|
+
function enterComponentExecutionScope(instance) {
|
|
109
|
+
const savedPortalScope = currentPortalScope;
|
|
110
|
+
currentInstance = instance;
|
|
111
|
+
currentPortalScope = instance.portalScope ?? savedPortalScope;
|
|
112
|
+
stateIndex = 0;
|
|
113
|
+
return savedPortalScope;
|
|
114
|
+
}
|
|
115
|
+
function exitComponentExecutionScope(savedPortalScope) {
|
|
116
|
+
currentInstance = null;
|
|
117
|
+
currentPortalScope = savedPortalScope;
|
|
118
|
+
}
|
|
119
|
+
function enterDomCommitScope(instance) {
|
|
120
|
+
const previousInstance = currentInstance;
|
|
121
|
+
currentInstance = instance;
|
|
122
|
+
return previousInstance;
|
|
123
|
+
}
|
|
124
|
+
function restoreDomCommitScope(previousInstance) {
|
|
125
|
+
currentInstance = previousInstance;
|
|
126
|
+
}
|
|
127
|
+
function clearCurrentComponentScope() {
|
|
128
|
+
const savedScope = captureScope();
|
|
129
|
+
currentInstance = null;
|
|
130
|
+
currentPortalScope = null;
|
|
131
|
+
return savedScope;
|
|
132
|
+
}
|
|
133
|
+
function restoreCurrentComponentScope(snapshot) {
|
|
134
|
+
restoreScope(snapshot);
|
|
135
|
+
}
|
|
136
|
+
function getNextStateIndex() {
|
|
137
|
+
return stateIndex++;
|
|
138
|
+
}
|
|
139
|
+
function claimHookIndex(instance, hookName) {
|
|
140
|
+
const index = getNextStateIndex();
|
|
141
|
+
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.`);
|
|
142
|
+
instance.stateIndexCheck = index;
|
|
143
|
+
if (instance.firstRenderComplete) {
|
|
144
|
+
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.`);
|
|
145
|
+
} else instance.expectedStateIndices.push(index);
|
|
146
|
+
return index;
|
|
147
|
+
}
|
|
148
|
+
function getCurrentStateIndex() {
|
|
149
|
+
return stateIndex;
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
export { beginRenderTracking, captureInlineComponentScope, captureInlineRenderTracking, claimHookIndex, clearCurrentComponentScope, clearRenderTracking, enterComponentExecutionScope, enterDomCommitScope, enterRenderScopedComponent, exitComponentExecutionScope, getCurrentComponentInstance, getCurrentInstance, getCurrentPortalScope, getCurrentStateIndex, getNextStateIndex, getSignal, getSignalForInstance, resetRenderState, restoreCurrentComponentScope, restoreDomCommitScope, restoreInlineComponentScope, restoreInlineRenderTracking, restoreRenderScopedComponent, setCurrentComponentInstance };
|
|
153
|
+
|
|
154
|
+
//# sourceMappingURL=component-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-scope.js","names":[],"sources":["../../src/runtime/component-scope.ts"],"sourcesContent":["/**\n * Component render scope and hook cursor ownership.\n * Internal helpers in this module intentionally keep mutable render-scope\n * state out of component execution and cleanup orchestration.\n */\n\nimport type { ReadableSource } from './readable';\nimport type { ComponentInstance } from './component-internal';\n\ntype ComponentScopeSnapshot = {\n instance: ComponentInstance | null;\n portalScope: object | null;\n stateIndex: number;\n};\n\ntype InstancePortalScopeSnapshot = {\n instance: ComponentInstance | null;\n portalScope: object | null;\n};\n\ntype InlineRenderTrackingSnapshot = {\n currentRenderToken: number | undefined;\n pendingReadSources: Set<ReadableSource<unknown>> | undefined;\n pendingReadSourceVersions: Map<ReadableSource<unknown>, number> | undefined;\n};\n\nlet currentInstance: ComponentInstance | null = null;\nlet currentPortalScope: object | null = null;\nlet stateIndex = 0;\nlet globalRenderCounter = 0;\n\nfunction ensureAbortController(instance: ComponentInstance): AbortController {\n let controller = instance.abortController;\n if (!controller || controller.signal.aborted) {\n controller = new AbortController();\n instance.abortController = controller;\n }\n return controller;\n}\n\nfunction nextRenderToken(): number {\n return ++globalRenderCounter;\n}\n\nfunction captureScope(): ComponentScopeSnapshot {\n return {\n instance: currentInstance,\n portalScope: currentPortalScope,\n stateIndex,\n };\n}\n\nfunction restoreScope(snapshot: ComponentScopeSnapshot): void {\n currentInstance = snapshot.instance;\n currentPortalScope = snapshot.portalScope;\n stateIndex = snapshot.stateIndex;\n}\n\nfunction captureInstancePortalScope(): InstancePortalScopeSnapshot {\n return {\n instance: currentInstance,\n portalScope: currentPortalScope,\n };\n}\n\nexport function getCurrentComponentInstance(): ComponentInstance | null {\n return currentInstance;\n}\n\nexport function getCurrentInstance(): ComponentInstance | null {\n return currentInstance;\n}\n\nexport function setCurrentComponentInstance(\n instance: ComponentInstance | null\n): void {\n currentInstance = instance;\n currentPortalScope = instance?.portalScope ?? null;\n}\n\nexport function getCurrentPortalScope(): object | null {\n return currentInstance?.portalScope ?? currentPortalScope;\n}\n\nexport function getSignalForInstance(instance: ComponentInstance): AbortSignal {\n return ensureAbortController(instance).signal;\n}\n\n/**\n * Get the abort signal for the current component.\n *\n * The signal is guaranteed to be aborted when:\n * - Component unmounts\n * - Navigation occurs (different route)\n * - Parent is destroyed\n */\nexport function getSignal(): AbortSignal {\n if (!currentInstance) {\n throw new Error(\n 'getSignal() can only be called during component render execution. ' +\n 'Ensure you are calling this from inside your component function.'\n );\n }\n return getSignalForInstance(currentInstance);\n}\n\nexport function resetRenderState(instance: ComponentInstance): void {\n instance.stateIndexCheck = -1;\n\n for (const state of instance.stateValues) {\n if (state) {\n state._hasBeenRead = false;\n }\n }\n\n instance._pendingReadSources = undefined;\n instance._pendingReadSourceVersions = undefined;\n}\n\nexport function beginRenderTracking(instance: ComponentInstance): void {\n instance._currentRenderToken = nextRenderToken();\n instance._pendingReadSources = undefined;\n instance._pendingReadSourceVersions = undefined;\n}\n\nexport function clearRenderTracking(instance: ComponentInstance): void {\n instance._pendingReadSources = undefined;\n instance._pendingReadSourceVersions = undefined;\n instance._currentRenderToken = undefined;\n}\n\nexport function captureInlineRenderTracking(\n instance: ComponentInstance\n): InlineRenderTrackingSnapshot {\n return {\n currentRenderToken: instance._currentRenderToken,\n pendingReadSources: instance._pendingReadSources,\n pendingReadSourceVersions: instance._pendingReadSourceVersions,\n };\n}\n\nexport function restoreInlineRenderTracking(\n instance: ComponentInstance,\n snapshot: InlineRenderTrackingSnapshot\n): void {\n instance._currentRenderToken = snapshot.currentRenderToken;\n instance._pendingReadSources = snapshot.pendingReadSources;\n instance._pendingReadSourceVersions = snapshot.pendingReadSourceVersions;\n}\n\nexport function enterRenderScopedComponent(\n instance: ComponentInstance,\n startStateIndex: number\n): ComponentScopeSnapshot {\n const savedScope = captureScope();\n currentInstance = instance;\n currentPortalScope = instance.portalScope ?? savedScope.portalScope;\n stateIndex = startStateIndex;\n return savedScope;\n}\n\nexport function restoreRenderScopedComponent(\n snapshot: ComponentScopeSnapshot\n): void {\n restoreScope(snapshot);\n}\n\nexport function captureInlineComponentScope(): InstancePortalScopeSnapshot {\n return captureInstancePortalScope();\n}\n\nexport function restoreInlineComponentScope(\n snapshot: InstancePortalScopeSnapshot\n): void {\n currentInstance = snapshot.instance;\n currentPortalScope = snapshot.portalScope;\n}\n\nexport function enterComponentExecutionScope(\n instance: ComponentInstance\n): object | null {\n const savedPortalScope = currentPortalScope;\n currentInstance = instance;\n currentPortalScope = instance.portalScope ?? savedPortalScope;\n stateIndex = 0;\n return savedPortalScope;\n}\n\nexport function exitComponentExecutionScope(\n savedPortalScope: object | null\n): void {\n currentInstance = null;\n currentPortalScope = savedPortalScope;\n}\n\nexport function enterDomCommitScope(\n instance: ComponentInstance\n): ComponentInstance | null {\n const previousInstance = currentInstance;\n currentInstance = instance;\n return previousInstance;\n}\n\nexport function restoreDomCommitScope(\n previousInstance: ComponentInstance | null\n): void {\n currentInstance = previousInstance;\n}\n\nexport function clearCurrentComponentScope(): ComponentScopeSnapshot {\n const savedScope = captureScope();\n currentInstance = null;\n currentPortalScope = null;\n return savedScope;\n}\n\nexport function restoreCurrentComponentScope(\n snapshot: ComponentScopeSnapshot\n): void {\n restoreScope(snapshot);\n}\n\nexport function getNextStateIndex(): number {\n return stateIndex++;\n}\n\nexport function claimHookIndex(\n instance: ComponentInstance,\n hookName: string\n): number {\n const index = getNextStateIndex();\n\n if (index < instance.stateIndexCheck) {\n throw new Error(\n `Hook index violation: ${hookName}() call at index ${index}, ` +\n `but previously saw index ${instance.stateIndexCheck}. ` +\n `This happens when render-scoped hooks are called conditionally (inside if/for/etc). ` +\n `Move all ${hookName}() calls to the top level of your component function, ` +\n `before any conditionals.`\n );\n }\n\n instance.stateIndexCheck = index;\n\n if (instance.firstRenderComplete) {\n if (instance.expectedStateIndices[index] !== index) {\n throw new Error(\n `Hook order violation: ${hookName}() called at index ${index}, ` +\n `but this index was not in the first render's sequence [${instance.expectedStateIndices.join(', ')}]. ` +\n `This usually means ${hookName}() is inside a conditional or loop. ` +\n `Move all render-scoped hooks to the top level of your component function.`\n );\n }\n } else {\n instance.expectedStateIndices.push(index);\n }\n\n return index;\n}\n\nexport function getCurrentStateIndex(): number {\n return stateIndex;\n}\n\nexport function resetStateIndex(): void {\n stateIndex = 0;\n}\n\nexport function setStateIndex(value: number): void {\n stateIndex = value;\n}\n"],"mappings":";AA0BA,IAAI,kBAA4C;AAChD,IAAI,qBAAoC;AACxC,IAAI,aAAa;AACjB,IAAI,sBAAsB;AAE1B,SAAS,sBAAsB,UAA8C;CAC3E,IAAI,aAAa,SAAS;CAC1B,IAAI,CAAC,cAAc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,SAAS,8GAEnC;CACF,OAEA,SAAS,qBAAqB,KAAK,KAAK;CAG1C,OAAO;AACT;AAEA,SAAgB,uBAA+B;CAC7C,OAAO;AACT"}
|
|
@@ -1,153 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ContextFrame } from "./context.js";
|
|
1
|
+
import { cleanupComponent, registerOwnedChildScope, unregisterOwnedChildScope } from "./component-cleanup.js";
|
|
2
|
+
import { ComponentInstance } from "./component-internal.js";
|
|
3
|
+
import { getSignal } from "./component-scope.js";
|
|
5
4
|
import { ComponentFunction } from "../common/component.js";
|
|
6
|
-
|
|
7
|
-
//#region src/runtime/component.d.ts
|
|
8
|
-
interface ComponentInstance {
|
|
9
|
-
id: string;
|
|
10
|
-
fn: ComponentFunction;
|
|
11
|
-
props: Props;
|
|
12
|
-
target: Element | null;
|
|
13
|
-
parentInstance: ComponentInstance | null;
|
|
14
|
-
portalScope: object | null;
|
|
15
|
-
mounted: boolean;
|
|
16
|
-
abortController: AbortController | null;
|
|
17
|
-
ssr?: boolean;
|
|
18
|
-
cleanupStrict?: boolean;
|
|
19
|
-
stateValues: State<unknown>[];
|
|
20
|
-
evaluationGeneration: number;
|
|
21
|
-
notifyUpdate: (() => void) | null;
|
|
22
|
-
_pendingFlushTask?: () => void;
|
|
23
|
-
_pendingRunTask?: () => void;
|
|
24
|
-
_enqueueRun?: () => void;
|
|
25
|
-
stateIndexCheck: number;
|
|
26
|
-
expectedStateIndices: number[];
|
|
27
|
-
firstRenderComplete: boolean;
|
|
28
|
-
mountOperations: Array<() => void | (() => void) | PromiseLike<void | (() => void)>>;
|
|
29
|
-
commitOperations: Array<() => void | (() => void) | PromiseLike<void | (() => void)>>;
|
|
30
|
-
cleanupFns: Array<() => void>;
|
|
31
|
-
lifecycleSlots: unknown[];
|
|
32
|
-
lifecycleGeneration: number;
|
|
33
|
-
hasPendingUpdate: boolean;
|
|
34
|
-
ownerFrame: ContextFrame | null;
|
|
35
|
-
isRoot?: boolean;
|
|
36
|
-
_currentRenderToken?: number;
|
|
37
|
-
lastRenderToken?: number;
|
|
38
|
-
_pendingReadSources?: Set<ReadableSource<unknown>>;
|
|
39
|
-
_pendingReadSourceVersions?: Map<ReadableSource<unknown>, number>;
|
|
40
|
-
_lastReadSources?: Set<ReadableSource<unknown>>;
|
|
41
|
-
devWarningsEmitted?: Set<string>;
|
|
42
|
-
_placeholder?: Comment;
|
|
43
|
-
_ownedChildScopes?: Set<{
|
|
44
|
-
key: string | number;
|
|
45
|
-
dispose(): void;
|
|
46
|
-
}>;
|
|
47
|
-
errorBoundaryState?: {
|
|
48
|
-
error: unknown | null;
|
|
49
|
-
resetKey: unknown;
|
|
50
|
-
notified: boolean;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
declare function createComponentInstance(id: string, fn: ComponentFunction, props: Props, target: Element | null): ComponentInstance;
|
|
54
|
-
type OwnedChildScope = {
|
|
55
|
-
key: string | number;
|
|
56
|
-
dispose(): void;
|
|
57
|
-
};
|
|
58
|
-
declare function getCurrentComponentInstance(): ComponentInstance | null;
|
|
59
|
-
declare function setCurrentComponentInstance(instance: ComponentInstance | null): void;
|
|
60
|
-
declare function getCurrentPortalScope(): object | null;
|
|
61
|
-
type LifecycleOperation = () => void | (() => void) | PromiseLike<void | (() => void)>;
|
|
62
|
-
declare function captureInlineRenderSnapshot(instance: ComponentInstance): void;
|
|
63
|
-
declare function registerMountOperation(operation: LifecycleOperation): void;
|
|
64
|
-
declare function registerCommitOperation(operation: LifecycleOperation): void;
|
|
65
|
-
declare function commitRenderedComponent(instance: ComponentInstance): void;
|
|
66
|
-
declare function mountInstanceInline(instance: ComponentInstance, target: Element | null): void;
|
|
67
|
-
declare function renderScopedComponent<T>(instance: ComponentInstance, startStateIndex: number, render: () => T): T;
|
|
68
|
-
/**
|
|
69
|
-
* Execute a component's render function synchronously.
|
|
70
|
-
* Returns either a vnode/promise immediately (does NOT render).
|
|
71
|
-
* Rendering happens separately through runComponent.
|
|
72
|
-
*/
|
|
73
|
-
declare function renderComponentInline(instance: ComponentInstance): unknown | Promise<unknown>;
|
|
74
|
-
declare function warnUnusedStateReads(instance: ComponentInstance): void;
|
|
75
|
-
/**
|
|
76
|
-
* Public entry point: Execute component with full lifecycle (execute + render)
|
|
77
|
-
* Handles both initial mount and re-execution. Always enqueues through scheduler.
|
|
78
|
-
* Single entry point to avoid lifecycle divergence.
|
|
79
|
-
*/
|
|
80
|
-
declare function executeComponent(instance: ComponentInstance): void;
|
|
81
|
-
declare function getCurrentInstance(): ComponentInstance | null;
|
|
82
|
-
/**
|
|
83
|
-
* Get the abort signal for the current component
|
|
84
|
-
* Used to cancel async operations on unmount/navigation
|
|
85
|
-
*
|
|
86
|
-
* The signal is guaranteed to be aborted when:
|
|
87
|
-
* - Component unmounts
|
|
88
|
-
* - Navigation occurs (different route)
|
|
89
|
-
* - Parent is destroyed
|
|
90
|
-
*
|
|
91
|
-
* IMPORTANT: getSignal() must be called during component render execution.
|
|
92
|
-
* It captures the current component instance from context.
|
|
93
|
-
*
|
|
94
|
-
* @returns AbortSignal that will be aborted when component unmounts
|
|
95
|
-
* @throws Error if called outside component execution
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* ```ts
|
|
99
|
-
* // ✅ Correct: called during render, used in async operation
|
|
100
|
-
* export async function UserPage({ id }: { id: string }) {
|
|
101
|
-
* const signal = getSignal();
|
|
102
|
-
* const user = await fetch(`/api/users/${id}`, { signal });
|
|
103
|
-
* return <div>{user.name}</div>;
|
|
104
|
-
* }
|
|
105
|
-
*
|
|
106
|
-
* // ✅ Correct: passed to event handler
|
|
107
|
-
* export function Button() {
|
|
108
|
-
* const signal = getSignal();
|
|
109
|
-
* return {
|
|
110
|
-
* type: 'button',
|
|
111
|
-
* props: {
|
|
112
|
-
* onClick: async () => {
|
|
113
|
-
* const data = await fetch(url, { signal });
|
|
114
|
-
* }
|
|
115
|
-
* }
|
|
116
|
-
* };
|
|
117
|
-
* }
|
|
118
|
-
*
|
|
119
|
-
* // ❌ Wrong: called outside component context
|
|
120
|
-
* const signal = getSignal(); // Error: not in component
|
|
121
|
-
* ```
|
|
122
|
-
*/
|
|
123
|
-
declare function getSignal(): AbortSignal;
|
|
124
|
-
/**
|
|
125
|
-
* Finalize read subscriptions for an instance after a successful commit.
|
|
126
|
-
* - Update per-state readers map to point to this instance's last committed token
|
|
127
|
-
* - Remove this instance from states it no longer reads
|
|
128
|
-
* This is deterministic and runs synchronously with commit to ensure
|
|
129
|
-
* subscribers are only notified when they actually read a state in their
|
|
130
|
-
* last committed render.
|
|
131
|
-
*/
|
|
132
|
-
declare function finalizeReadSubscriptions(instance: ComponentInstance): void;
|
|
133
|
-
declare function getNextStateIndex(): number;
|
|
134
|
-
declare function claimHookIndex(instance: ComponentInstance, hookName: string): number;
|
|
135
|
-
declare function getCurrentStateIndex(): number;
|
|
136
|
-
declare function resetStateIndex(): void;
|
|
137
|
-
declare function setStateIndex(value: number): void;
|
|
138
|
-
/**
|
|
139
|
-
* Mount a component instance.
|
|
140
|
-
* This is just an alias to executeComponent() to maintain API compatibility.
|
|
141
|
-
* All lifecycle logic is unified in executeComponent().
|
|
142
|
-
*/
|
|
143
|
-
declare function mountComponent(instance: ComponentInstance): void;
|
|
144
|
-
/**
|
|
145
|
-
* Clean up component — abort pending operations
|
|
146
|
-
* Called on unmount or route change
|
|
147
|
-
*/
|
|
148
|
-
declare function cleanupComponent(instance: ComponentInstance): void;
|
|
149
|
-
declare function registerOwnedChildScope(instance: ComponentInstance, scope: OwnedChildScope): void;
|
|
150
|
-
declare function unregisterOwnedChildScope(instance: ComponentInstance, scope: OwnedChildScope): void;
|
|
151
|
-
//#endregion
|
|
152
|
-
export { ComponentInstance, getSignal };
|
|
153
|
-
//# sourceMappingURL=component.d.ts.map
|
|
5
|
+
export { type ComponentFunction, type ComponentInstance, getSignal };
|