@real-router/core 0.78.0 → 0.79.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/Router-DGUed2F4.js +2 -0
- package/dist/cjs/Router-DGUed2F4.js.map +1 -0
- package/dist/cjs/{Router-BG5yNYUG.d.ts → Router.d.ts} +5 -4
- package/dist/cjs/Router.d.ts.map +1 -0
- package/dist/cjs/Router.js +2 -0
- package/dist/cjs/Router.js.map +1 -0
- package/dist/cjs/RouterError.d.ts +182 -0
- package/dist/cjs/RouterError.d.ts.map +1 -0
- package/dist/cjs/RouterError.js +2 -0
- package/dist/cjs/RouterError.js.map +1 -0
- package/dist/cjs/api/cloneRouter.d.ts +86 -0
- package/dist/cjs/api/cloneRouter.d.ts.map +1 -0
- package/dist/cjs/api/cloneRouter.js +2 -0
- package/dist/cjs/api/cloneRouter.js.map +1 -0
- package/dist/cjs/api/getDependenciesApi.d.ts +7 -0
- package/dist/cjs/api/getDependenciesApi.d.ts.map +1 -0
- package/dist/cjs/api/getDependenciesApi.js +2 -0
- package/dist/cjs/api/getDependenciesApi.js.map +1 -0
- package/dist/cjs/api/getLifecycleApi.d.ts +7 -0
- package/dist/cjs/api/getLifecycleApi.d.ts.map +1 -0
- package/dist/cjs/api/getLifecycleApi.js +2 -0
- package/dist/cjs/api/getLifecycleApi.js.map +1 -0
- package/dist/cjs/api/getPluginApi.d.ts +7 -0
- package/dist/cjs/api/getPluginApi.d.ts.map +1 -0
- package/dist/cjs/api/getPluginApi.js +2 -0
- package/dist/cjs/api/getPluginApi.js.map +1 -0
- package/dist/cjs/api/getRoutesApi.d.ts +7 -0
- package/dist/cjs/api/getRoutesApi.d.ts.map +1 -0
- package/dist/cjs/api/getRoutesApi.js +2 -0
- package/dist/cjs/api/getRoutesApi.js.map +1 -0
- package/dist/cjs/api/helpers.js +2 -0
- package/dist/cjs/api/helpers.js.map +1 -0
- package/dist/cjs/api/types.d.ts +9 -0
- package/dist/cjs/api/types.d.ts.map +1 -0
- package/dist/cjs/api.d.ts +8 -105
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/api.js.map +1 -1
- package/dist/cjs/buildParamMeta-DniluAIV.js +2 -0
- package/dist/cjs/buildParamMeta-DniluAIV.js.map +1 -0
- package/dist/cjs/{cloneRouter-a6LJt-zh.js → cloneRouter-Ch25z3Z2.js} +2 -2
- package/dist/cjs/{cloneRouter-a6LJt-zh.js.map → cloneRouter-Ch25z3Z2.js.map} +1 -1
- package/dist/cjs/constants.d.ts +25 -0
- package/dist/cjs/constants.d.ts.map +1 -0
- package/dist/cjs/constants.js +2 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/createRouter.d.ts +23 -0
- package/dist/cjs/createRouter.d.ts.map +1 -0
- package/dist/cjs/createRouter.js +2 -0
- package/dist/cjs/createRouter.js.map +1 -0
- package/dist/cjs/engine/builder/buildTree.js +2 -0
- package/dist/cjs/engine/builder/buildTree.js.map +1 -0
- package/dist/cjs/engine/builder/computeCaches.js +2 -0
- package/dist/cjs/engine/builder/computeCaches.js.map +1 -0
- package/dist/cjs/engine/builder/createRouteTree.js +2 -0
- package/dist/cjs/engine/builder/createRouteTree.js.map +1 -0
- package/dist/cjs/engine/builder/types.d.ts +48 -0
- package/dist/cjs/engine/builder/types.d.ts.map +1 -0
- package/dist/cjs/engine/createMatcher.d.ts +29 -0
- package/dist/cjs/engine/createMatcher.d.ts.map +1 -0
- package/dist/cjs/engine/createMatcher.js +2 -0
- package/dist/cjs/engine/createMatcher.js.map +1 -0
- package/dist/cjs/engine/operations/routeTreeToDefinitions.js +2 -0
- package/dist/cjs/engine/operations/routeTreeToDefinitions.js.map +1 -0
- package/dist/cjs/engine/path-matcher/SegmentMatcher.d.ts +16 -0
- package/dist/cjs/engine/path-matcher/SegmentMatcher.d.ts.map +1 -0
- package/dist/cjs/engine/path-matcher/SegmentMatcher.js +2 -0
- package/dist/cjs/engine/path-matcher/SegmentMatcher.js.map +1 -0
- package/dist/cjs/engine/path-matcher/buildParamMeta.js +2 -0
- package/dist/cjs/engine/path-matcher/buildParamMeta.js.map +1 -0
- package/dist/cjs/engine/path-matcher/encoding.js +2 -0
- package/dist/cjs/engine/path-matcher/encoding.js.map +1 -0
- package/dist/cjs/engine/path-matcher/parseSegment.js +2 -0
- package/dist/cjs/engine/path-matcher/parseSegment.js.map +1 -0
- package/dist/cjs/engine/path-matcher/pathUtils.js +2 -0
- package/dist/cjs/engine/path-matcher/pathUtils.js.map +1 -0
- package/dist/cjs/engine/path-matcher/percentEncoding.js +2 -0
- package/dist/cjs/engine/path-matcher/percentEncoding.js.map +1 -0
- package/dist/cjs/engine/path-matcher/registration/buildParts.js +2 -0
- package/dist/cjs/engine/path-matcher/registration/buildParts.js.map +1 -0
- package/dist/cjs/engine/path-matcher/registration/context.js +2 -0
- package/dist/cjs/engine/path-matcher/registration/context.js.map +1 -0
- package/dist/cjs/engine/path-matcher/registration/errors.js +2 -0
- package/dist/cjs/engine/path-matcher/registration/errors.js.map +1 -0
- package/dist/cjs/engine/path-matcher/registration/index.js +2 -0
- package/dist/cjs/engine/path-matcher/registration/index.js.map +1 -0
- package/dist/cjs/engine/path-matcher/registration/trie.js +2 -0
- package/dist/cjs/engine/path-matcher/registration/trie.js.map +1 -0
- package/dist/cjs/engine/path-matcher/registration/trieNodes.js +2 -0
- package/dist/cjs/engine/path-matcher/registration/trieNodes.js.map +1 -0
- package/dist/cjs/{types-xg2zHVF6.d.ts → engine/path-matcher/types.d.ts} +2 -80
- package/dist/cjs/engine/path-matcher/types.d.ts.map +1 -0
- package/dist/cjs/engine/search-params/decode.js +2 -0
- package/dist/cjs/engine/search-params/decode.js.map +1 -0
- package/dist/cjs/engine/search-params/encode.js +2 -0
- package/dist/cjs/engine/search-params/encode.js.map +1 -0
- package/dist/cjs/engine/search-params/searchParams.js +2 -0
- package/dist/cjs/engine/search-params/searchParams.js.map +1 -0
- package/dist/cjs/engine/search-params/strategies/array.js +2 -0
- package/dist/cjs/engine/search-params/strategies/array.js.map +1 -0
- package/dist/cjs/engine/search-params/strategies/boolean.js +2 -0
- package/dist/cjs/engine/search-params/strategies/boolean.js.map +1 -0
- package/dist/cjs/engine/search-params/strategies/index.js +2 -0
- package/dist/cjs/engine/search-params/strategies/index.js.map +1 -0
- package/dist/cjs/engine/search-params/strategies/null.js +2 -0
- package/dist/cjs/engine/search-params/strategies/null.js.map +1 -0
- package/dist/cjs/engine/search-params/strategies/number.js +2 -0
- package/dist/cjs/engine/search-params/strategies/number.js.map +1 -0
- package/dist/cjs/engine/search-params/types.d.ts +72 -0
- package/dist/cjs/engine/search-params/types.d.ts.map +1 -0
- package/dist/cjs/engine/search-params/utils.js +2 -0
- package/dist/cjs/engine/search-params/utils.js.map +1 -0
- package/dist/cjs/engine/validation/route-batch.d.ts +38 -0
- package/dist/cjs/engine/validation/route-batch.d.ts.map +1 -0
- package/dist/cjs/engine/validation/route-batch.js +2 -0
- package/dist/cjs/engine/validation/route-batch.js.map +1 -0
- package/dist/cjs/engine/validation/routes.js +2 -0
- package/dist/cjs/engine/validation/routes.js.map +1 -0
- package/dist/cjs/foundation/event-emitter/EventEmitter.js +2 -0
- package/dist/cjs/foundation/event-emitter/EventEmitter.js.map +1 -0
- package/dist/cjs/foundation/fsm/fsm.js +2 -0
- package/dist/cjs/foundation/fsm/fsm.js.map +1 -0
- package/dist/cjs/foundation/logger/RouterLogger.js +2 -0
- package/dist/cjs/foundation/logger/RouterLogger.js.map +1 -0
- package/dist/cjs/foundation/logger/constants.js +2 -0
- package/dist/cjs/foundation/logger/constants.js.map +1 -0
- package/dist/cjs/getNavigator.d.ts +6 -0
- package/dist/cjs/getNavigator.d.ts.map +1 -0
- package/dist/cjs/getNavigator.js +2 -0
- package/dist/cjs/getNavigator.js.map +1 -0
- package/dist/cjs/guards.js +2 -0
- package/dist/cjs/guards.js.map +1 -0
- package/dist/cjs/helpers.js +2 -0
- package/dist/cjs/helpers.js.map +1 -0
- package/dist/cjs/index.d.ts +17 -239
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/internals.d.ts +99 -0
- package/dist/cjs/internals.d.ts.map +1 -0
- package/dist/cjs/internals.js +2 -0
- package/dist/cjs/internals.js.map +1 -0
- package/dist/cjs/namespaces/DependenciesNamespace/dependenciesStore.d.ts +10 -0
- package/dist/cjs/namespaces/DependenciesNamespace/dependenciesStore.d.ts.map +1 -0
- package/dist/cjs/namespaces/DependenciesNamespace/dependenciesStore.js +2 -0
- package/dist/cjs/namespaces/DependenciesNamespace/dependenciesStore.js.map +1 -0
- package/dist/cjs/namespaces/EventBusNamespace/EventBusNamespace.js +2 -0
- package/dist/cjs/namespaces/EventBusNamespace/EventBusNamespace.js.map +1 -0
- package/dist/cjs/namespaces/NavigationNamespace/NavigationNamespace.js +2 -0
- package/dist/cjs/namespaces/NavigationNamespace/NavigationNamespace.js.map +1 -0
- package/dist/cjs/namespaces/NavigationNamespace/constants.js +2 -0
- package/dist/cjs/namespaces/NavigationNamespace/constants.js.map +1 -0
- package/dist/cjs/namespaces/NavigationNamespace/transition/completeTransition.js +2 -0
- package/dist/cjs/namespaces/NavigationNamespace/transition/completeTransition.js.map +1 -0
- package/dist/cjs/namespaces/NavigationNamespace/transition/errorHandling.js +2 -0
- package/dist/cjs/namespaces/NavigationNamespace/transition/errorHandling.js.map +1 -0
- package/dist/cjs/namespaces/NavigationNamespace/transition/guardPhase.js +2 -0
- package/dist/cjs/namespaces/NavigationNamespace/transition/guardPhase.js.map +1 -0
- package/dist/cjs/namespaces/OptionsNamespace/OptionsNamespace.js +2 -0
- package/dist/cjs/namespaces/OptionsNamespace/OptionsNamespace.js.map +1 -0
- package/dist/cjs/namespaces/OptionsNamespace/constants.js +2 -0
- package/dist/cjs/namespaces/OptionsNamespace/constants.js.map +1 -0
- package/dist/cjs/namespaces/OptionsNamespace/helpers.js +2 -0
- package/dist/cjs/namespaces/OptionsNamespace/helpers.js.map +1 -0
- package/dist/cjs/namespaces/OptionsNamespace/validators.js +2 -0
- package/dist/cjs/namespaces/OptionsNamespace/validators.js.map +1 -0
- package/dist/cjs/namespaces/PluginsNamespace/PluginsNamespace.js +2 -0
- package/dist/cjs/namespaces/PluginsNamespace/PluginsNamespace.js.map +1 -0
- package/dist/cjs/namespaces/PluginsNamespace/constants.js +2 -0
- package/dist/cjs/namespaces/PluginsNamespace/constants.js.map +1 -0
- package/dist/cjs/namespaces/PluginsNamespace/validators.js +2 -0
- package/dist/cjs/namespaces/PluginsNamespace/validators.js.map +1 -0
- package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.ts +174 -0
- package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.ts.map +1 -0
- package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.js +2 -0
- package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.js.map +1 -0
- package/dist/cjs/namespaces/RouteLifecycleNamespace/types.d.ts +17 -0
- package/dist/cjs/namespaces/RouteLifecycleNamespace/types.d.ts.map +1 -0
- package/dist/cjs/namespaces/RouterLifecycleNamespace/RouterLifecycleNamespace.js +2 -0
- package/dist/cjs/namespaces/RouterLifecycleNamespace/RouterLifecycleNamespace.js.map +1 -0
- package/dist/cjs/namespaces/RouterLifecycleNamespace/constants.js +2 -0
- package/dist/cjs/namespaces/RouterLifecycleNamespace/constants.js.map +1 -0
- package/dist/cjs/namespaces/RoutesNamespace/RoutesNamespace.js +2 -0
- package/dist/cjs/namespaces/RoutesNamespace/RoutesNamespace.js.map +1 -0
- package/dist/cjs/namespaces/RoutesNamespace/constants.js +2 -0
- package/dist/cjs/namespaces/RoutesNamespace/constants.js.map +1 -0
- package/dist/cjs/namespaces/RoutesNamespace/forwardChain.d.ts +5 -0
- package/dist/cjs/namespaces/RoutesNamespace/forwardChain.d.ts.map +1 -0
- package/dist/cjs/namespaces/RoutesNamespace/forwardChain.js +2 -0
- package/dist/cjs/namespaces/RoutesNamespace/forwardChain.js.map +1 -0
- package/dist/cjs/namespaces/RoutesNamespace/helpers.js +2 -0
- package/dist/cjs/namespaces/RoutesNamespace/helpers.js.map +1 -0
- package/dist/cjs/namespaces/RoutesNamespace/routeGuards.js +2 -0
- package/dist/cjs/namespaces/RoutesNamespace/routeGuards.js.map +1 -0
- package/dist/cjs/namespaces/RoutesNamespace/routesStore.d.ts +42 -0
- package/dist/cjs/namespaces/RoutesNamespace/routesStore.d.ts.map +1 -0
- package/dist/cjs/namespaces/RoutesNamespace/routesStore.js +2 -0
- package/dist/cjs/namespaces/RoutesNamespace/routesStore.js.map +1 -0
- package/dist/cjs/namespaces/RoutesNamespace/types.d.ts +57 -0
- package/dist/cjs/namespaces/RoutesNamespace/types.d.ts.map +1 -0
- package/dist/cjs/namespaces/StateNamespace/StateNamespace.js +2 -0
- package/dist/cjs/namespaces/StateNamespace/StateNamespace.js.map +1 -0
- package/dist/cjs/namespaces/StateNamespace/helpers.js +2 -0
- package/dist/cjs/namespaces/StateNamespace/helpers.js.map +1 -0
- package/dist/cjs/routerFSM.js +2 -0
- package/dist/cjs/routerFSM.js.map +1 -0
- package/dist/cjs/stateMetaStore.js +2 -0
- package/dist/cjs/stateMetaStore.js.map +1 -0
- package/dist/cjs/transitionPath.js +2 -0
- package/dist/cjs/transitionPath.js.map +1 -0
- package/dist/cjs/{RouterValidator-CZ8kPkrI.d.ts → types/RouterValidator.d.ts} +2 -2
- package/dist/cjs/types/RouterValidator.d.ts.map +1 -0
- package/dist/cjs/types/api.d.ts +184 -0
- package/dist/cjs/types/api.d.ts.map +1 -0
- package/dist/cjs/types/base.d.ts +86 -0
- package/dist/cjs/types/base.d.ts.map +1 -0
- package/dist/cjs/types/constants.d.ts +72 -0
- package/dist/cjs/types/constants.d.ts.map +1 -0
- package/dist/cjs/types/internal.d.ts +9 -0
- package/dist/cjs/types/internal.d.ts.map +1 -0
- package/dist/cjs/types/limits.d.ts +45 -0
- package/dist/cjs/types/limits.d.ts.map +1 -0
- package/dist/cjs/types/route-node-types.d.ts +46 -0
- package/dist/cjs/types/route-node-types.d.ts.map +1 -0
- package/dist/cjs/types/router.d.ts +313 -0
- package/dist/cjs/types/router.d.ts.map +1 -0
- package/dist/cjs/types/tree-changed.d.ts +55 -0
- package/dist/cjs/types/tree-changed.d.ts.map +1 -0
- package/dist/cjs/types.d.ts +208 -2
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/utils/createRequestScope.d.ts +111 -0
- package/dist/cjs/utils/createRequestScope.d.ts.map +1 -0
- package/dist/cjs/utils/createRequestScope.js +2 -0
- package/dist/cjs/utils/createRequestScope.js.map +1 -0
- package/dist/cjs/utils/getStaticPaths.d.ts +7 -0
- package/dist/cjs/utils/getStaticPaths.d.ts.map +1 -0
- package/dist/cjs/utils/getStaticPaths.js +2 -0
- package/dist/cjs/utils/getStaticPaths.js.map +1 -0
- package/dist/cjs/utils/hydrateRouter.d.ts +69 -0
- package/dist/cjs/utils/hydrateRouter.d.ts.map +1 -0
- package/dist/cjs/utils/hydrateRouter.js +2 -0
- package/dist/cjs/utils/hydrateRouter.js.map +1 -0
- package/dist/cjs/utils/serializeRouterState.d.ts +84 -0
- package/dist/cjs/utils/serializeRouterState.d.ts.map +1 -0
- package/dist/cjs/utils/serializeRouterState.js +2 -0
- package/dist/cjs/utils/serializeRouterState.js.map +1 -0
- package/dist/cjs/utils/serializeState.d.ts +50 -0
- package/dist/cjs/utils/serializeState.d.ts.map +1 -0
- package/dist/cjs/utils/serializeState.js +2 -0
- package/dist/cjs/utils/serializeState.js.map +1 -0
- package/dist/cjs/utils.d.ts +5 -1
- package/dist/cjs/utils.js +1 -1
- package/dist/cjs/validation.d.ts +6 -518
- package/dist/cjs/validation.js +1 -1
- package/dist/cjs/validation.js.map +1 -1
- package/dist/cjs/wiring/wireNamespaces.js +2 -0
- package/dist/cjs/wiring/wireNamespaces.js.map +1 -0
- package/dist/esm/Router-Bk6PfSE8.mjs +2 -0
- package/dist/esm/Router-Bk6PfSE8.mjs.map +1 -0
- package/dist/esm/{Router-Cy75qbgU.d.mts → Router.d.mts} +5 -4
- package/dist/esm/Router.d.mts.map +1 -0
- package/dist/esm/RouterError.d.mts +182 -0
- package/dist/esm/RouterError.d.mts.map +1 -0
- package/dist/esm/api/cloneRouter.d.mts +86 -0
- package/dist/esm/api/cloneRouter.d.mts.map +1 -0
- package/dist/esm/api/getDependenciesApi.d.mts +7 -0
- package/dist/esm/api/getDependenciesApi.d.mts.map +1 -0
- package/dist/esm/api/getLifecycleApi.d.mts +7 -0
- package/dist/esm/api/getLifecycleApi.d.mts.map +1 -0
- package/dist/esm/api/getPluginApi.d.mts +7 -0
- package/dist/esm/api/getPluginApi.d.mts.map +1 -0
- package/dist/esm/api/getRoutesApi.d.mts +7 -0
- package/dist/esm/api/getRoutesApi.d.mts.map +1 -0
- package/dist/esm/api/types.d.mts +9 -0
- package/dist/esm/api/types.d.mts.map +1 -0
- package/dist/esm/api.d.mts +8 -105
- package/dist/esm/api.mjs +1 -1
- package/dist/esm/api.mjs.map +1 -1
- package/dist/esm/buildParamMeta-bOLhLF9h.mjs +2 -0
- package/dist/esm/buildParamMeta-bOLhLF9h.mjs.map +1 -0
- package/dist/esm/{cloneRouter-CqS4kTs8.mjs → cloneRouter-D4rnqmi9.mjs} +2 -2
- package/dist/esm/{cloneRouter-CqS4kTs8.mjs.map → cloneRouter-D4rnqmi9.mjs.map} +1 -1
- package/dist/esm/constants.d.mts +25 -0
- package/dist/esm/constants.d.mts.map +1 -0
- package/dist/esm/createRouter.d.mts +23 -0
- package/dist/esm/createRouter.d.mts.map +1 -0
- package/dist/esm/engine/builder/types.d.mts +48 -0
- package/dist/esm/engine/builder/types.d.mts.map +1 -0
- package/dist/esm/engine/createMatcher.d.mts +29 -0
- package/dist/esm/engine/createMatcher.d.mts.map +1 -0
- package/dist/esm/engine/path-matcher/SegmentMatcher.d.mts +16 -0
- package/dist/esm/engine/path-matcher/SegmentMatcher.d.mts.map +1 -0
- package/dist/esm/{types-xg2zHVF6.d.mts → engine/path-matcher/types.d.mts} +2 -80
- package/dist/esm/engine/path-matcher/types.d.mts.map +1 -0
- package/dist/esm/engine/search-params/types.d.mts +72 -0
- package/dist/esm/engine/search-params/types.d.mts.map +1 -0
- package/dist/esm/engine/validation/route-batch.d.mts +38 -0
- package/dist/esm/engine/validation/route-batch.d.mts.map +1 -0
- package/dist/esm/getNavigator.d.mts +6 -0
- package/dist/esm/getNavigator.d.mts.map +1 -0
- package/dist/esm/index.d.mts +17 -239
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internals.d.mts +99 -0
- package/dist/esm/internals.d.mts.map +1 -0
- package/dist/esm/namespaces/DependenciesNamespace/dependenciesStore.d.mts +10 -0
- package/dist/esm/namespaces/DependenciesNamespace/dependenciesStore.d.mts.map +1 -0
- package/dist/esm/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.mts +174 -0
- package/dist/esm/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.mts.map +1 -0
- package/dist/esm/namespaces/RouteLifecycleNamespace/types.d.mts +17 -0
- package/dist/esm/namespaces/RouteLifecycleNamespace/types.d.mts.map +1 -0
- package/dist/esm/namespaces/RoutesNamespace/forwardChain.d.mts +5 -0
- package/dist/esm/namespaces/RoutesNamespace/forwardChain.d.mts.map +1 -0
- package/dist/esm/namespaces/RoutesNamespace/routesStore.d.mts +42 -0
- package/dist/esm/namespaces/RoutesNamespace/routesStore.d.mts.map +1 -0
- package/dist/esm/namespaces/RoutesNamespace/types.d.mts +57 -0
- package/dist/esm/namespaces/RoutesNamespace/types.d.mts.map +1 -0
- package/dist/esm/{RouterValidator-CZ8kPkrI.d.mts → types/RouterValidator.d.mts} +2 -2
- package/dist/esm/types/RouterValidator.d.mts.map +1 -0
- package/dist/esm/types/api.d.mts +184 -0
- package/dist/esm/types/api.d.mts.map +1 -0
- package/dist/esm/types/base.d.mts +86 -0
- package/dist/esm/types/base.d.mts.map +1 -0
- package/dist/esm/types/constants.d.mts +72 -0
- package/dist/esm/types/constants.d.mts.map +1 -0
- package/dist/esm/types/internal.d.mts +9 -0
- package/dist/esm/types/internal.d.mts.map +1 -0
- package/dist/esm/types/limits.d.mts +45 -0
- package/dist/esm/types/limits.d.mts.map +1 -0
- package/dist/esm/types/route-node-types.d.mts +46 -0
- package/dist/esm/types/route-node-types.d.mts.map +1 -0
- package/dist/esm/types/router.d.mts +313 -0
- package/dist/esm/types/router.d.mts.map +1 -0
- package/dist/esm/types/tree-changed.d.mts +55 -0
- package/dist/esm/types/tree-changed.d.mts.map +1 -0
- package/dist/esm/types.d.mts +208 -2
- package/dist/esm/types.d.mts.map +1 -0
- package/dist/esm/utils/createRequestScope.d.mts +111 -0
- package/dist/esm/utils/createRequestScope.d.mts.map +1 -0
- package/dist/esm/utils/getStaticPaths.d.mts +7 -0
- package/dist/esm/utils/getStaticPaths.d.mts.map +1 -0
- package/dist/esm/utils/hydrateRouter.d.mts +69 -0
- package/dist/esm/utils/hydrateRouter.d.mts.map +1 -0
- package/dist/esm/utils/serializeRouterState.d.mts +84 -0
- package/dist/esm/utils/serializeRouterState.d.mts.map +1 -0
- package/dist/esm/utils/serializeState.d.mts +50 -0
- package/dist/esm/utils/serializeState.d.mts.map +1 -0
- package/dist/esm/utils.d.mts +5 -1
- package/dist/esm/utils.mjs +1 -1
- package/dist/esm/validation.d.mts +6 -518
- package/dist/esm/validation.mjs +1 -1
- package/dist/esm/validation.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/cjs/Router-BG5yNYUG.d.ts.map +0 -1
- package/dist/cjs/Router-D6NzRxBA.js +0 -2
- package/dist/cjs/Router-D6NzRxBA.js.map +0 -1
- package/dist/cjs/RouterValidator-CZ8kPkrI.d.ts.map +0 -1
- package/dist/cjs/api.d.ts.map +0 -1
- package/dist/cjs/buildParamMeta-CkG6cUIl.js +0 -2
- package/dist/cjs/buildParamMeta-CkG6cUIl.js.map +0 -1
- package/dist/cjs/index-CAnGQpnz.d.ts +0 -974
- package/dist/cjs/index-CAnGQpnz.d.ts.map +0 -1
- package/dist/cjs/index-DDrryY2U.d.ts +0 -309
- package/dist/cjs/index-DDrryY2U.d.ts.map +0 -1
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/types-xg2zHVF6.d.ts.map +0 -1
- package/dist/cjs/validation.d.ts.map +0 -1
- package/dist/esm/Router-Cy75qbgU.d.mts.map +0 -1
- package/dist/esm/Router-De0Gr9Ll.mjs +0 -2
- package/dist/esm/Router-De0Gr9Ll.mjs.map +0 -1
- package/dist/esm/RouterValidator-CZ8kPkrI.d.mts.map +0 -1
- package/dist/esm/api.d.mts.map +0 -1
- package/dist/esm/buildParamMeta-Bl0uORu6.mjs +0 -2
- package/dist/esm/buildParamMeta-Bl0uORu6.mjs.map +0 -1
- package/dist/esm/index-CAnGQpnz.d.mts +0 -974
- package/dist/esm/index-CAnGQpnz.d.mts.map +0 -1
- package/dist/esm/index-DnSU6huX.d.mts +0 -309
- package/dist/esm/index-DnSU6huX.d.mts.map +0 -1
- package/dist/esm/index.d.mts.map +0 -1
- package/dist/esm/types-xg2zHVF6.d.mts.map +0 -1
- package/dist/esm/validation.d.mts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouterLifecycleNamespace.js","names":["#deps","RouterError","errorCodes"],"sources":["../../../../src/namespaces/RouterLifecycleNamespace/RouterLifecycleNamespace.ts"],"sourcesContent":["// packages/core/src/namespaces/RouterLifecycleNamespace/RouterLifecycleNamespace.ts\n\nimport { errorCodes } from \"../../constants\";\nimport { RouterError } from \"../../RouterError\";\n\nimport type { RouterLifecycleDependencies } from \"./types\";\nimport type { NavigationOptions, State } from \"../../types\";\n\nconst REPLACE_OPTS: NavigationOptions = Object.freeze({ replace: true });\n\n/**\n * Independent namespace for managing router lifecycle.\n *\n * Handles start() and stop(). Lifecycle state (isActive, isStarted) is managed\n * by RouterFSM in the facade (Router.ts).\n */\nexport class RouterLifecycleNamespace {\n #deps!: RouterLifecycleDependencies;\n\n // =========================================================================\n // Dependency injection\n // =========================================================================\n\n /**\n * Sets dependencies for lifecycle operations.\n * Must be called before using lifecycle methods.\n */\n setDependencies(deps: RouterLifecycleDependencies): void {\n this.#deps = deps;\n }\n\n // =========================================================================\n // Instance methods\n // =========================================================================\n\n /**\n * Starts the router with the given path.\n *\n * Guards (concurrent start, already started) are handled by the facade via\n * RouterFSM state checks before this method is called.\n */\n async start(startPath: string): Promise<State> {\n const deps = this.#deps;\n\n // #1185: this method is the start-interceptor target — it runs AFTER the\n // whole interceptor chain. A stop() during that window sent STOP\n // (STARTING → IDLE via the FSM table), so if the router is back at IDLE the\n // start was cancelled mid-window; reject instead of committing a state on a\n // stopped router (mirrors the guard phase, which cancels from\n // TRANSITION_STARTED). `isIdle()` is deliberate — a dispose() mid-window\n // leaves the FSM DISPOSED, which the navigateToState / navigateToNotFound\n // liveness gate rejects as ROUTER_DISPOSED (#1186), not conflated with a\n // cancel.\n if (deps.isIdle()) {\n throw new RouterError(errorCodes.TRANSITION_CANCELLED);\n }\n\n const options = deps.getOptions();\n\n // Invariant guard (#939): core is platform-agnostic, so the caller must\n // provide a string path. Without a browser-plugin start interceptor to\n // inject a location, a non-string `startPath` (e.g. `start(undefined)`)\n // would otherwise reach matchPath() and throw a cryptic, code-less\n // `TypeError: …codePointAt` deep inside path-matcher. This guard runs AFTER\n // the interceptor chain (browser-plugin substitutes the location upstream),\n // so it only fires when nothing supplied a path — turning the cryptic crash\n // into an actionable error. Symmetric with the subscribe / navigateToNotFound\n // type guards; the validator deliberately permits `undefined` at the facade\n // for exactly the browser-plugin-override case.\n if (typeof startPath !== \"string\") {\n throw new TypeError(\n `[router.start] path must be a string, got ${typeof startPath}`,\n );\n }\n\n const matchedState = deps.matchPath(startPath);\n\n if (!matchedState && !options.allowNotFound) {\n const err = new RouterError(errorCodes.ROUTE_NOT_FOUND, {\n path: startPath,\n });\n\n deps.emitTransitionError(undefined, undefined, err);\n\n throw err;\n }\n\n deps.completeStart();\n\n if (matchedState) {\n // navigateToState commits matchedState verbatim — same primitive URL\n // plugins use on popstate / navigate-event (#525). Keeps trailing-slash\n // and any other source-URL flavor that matchPath produced; skips the\n // redundant forwardState+buildPath round-trip in buildNavigateState.\n return deps.navigateToState(matchedState, REPLACE_OPTS);\n }\n\n return deps.navigateToNotFound(startPath);\n }\n\n /**\n * Stops the router and resets state.\n *\n * Called for READY / TRANSITION_STARTED and, since #1185, STARTING (a stop()\n * that cancels a parked start — state is still `undefined` there, so\n * `clearState()` is a no-op that keeps the reset symmetric). The facade\n * handles IDLE / DISPOSED.\n */\n stop(): void {\n this.#deps.clearState();\n }\n}\n"],"mappings":"wEAQM,EAAkC,OAAO,OAAO,CAAE,QAAS,EAAK,CAAC,EAQvE,IAAa,EAAb,KAAsC,CACpC,GAUA,gBAAgB,EAAyC,CACvD,KAAKA,GAAQ,CACf,CAYA,MAAM,MAAM,EAAmC,CAC7C,IAAM,EAAO,KAAKA,GAWlB,GAAI,EAAK,OAAO,EACd,MAAM,IAAIC,EAAAA,YAAYC,EAAAA,WAAW,oBAAoB,EAGvD,IAAM,EAAU,EAAK,WAAW,EAYhC,GAAI,OAAO,GAAc,SACvB,MAAU,UACR,6CAA6C,OAAO,GACtD,EAGF,IAAM,EAAe,EAAK,UAAU,CAAS,EAE7C,GAAI,CAAC,GAAgB,CAAC,EAAQ,cAAe,CAC3C,IAAM,EAAM,IAAID,EAAAA,YAAYC,EAAAA,WAAW,gBAAiB,CACtD,KAAM,CACR,CAAC,EAID,MAFA,EAAK,oBAAoB,IAAA,GAAW,IAAA,GAAW,CAAG,EAE5C,CACR,CAYA,OAVA,EAAK,cAAc,EAEf,EAKK,EAAK,gBAAgB,EAAc,CAAY,EAGjD,EAAK,mBAAmB,CAAS,CAC1C,CAUA,MAAa,CACX,KAAKF,GAAM,WAAW,CACxB,CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":["RouterError","errorCodes"],"sources":["../../../../src/namespaces/RouterLifecycleNamespace/constants.ts"],"sourcesContent":["// packages/core/src/namespaces/RouterLifecycleNamespace/constants.ts\n\nimport { errorCodes } from \"../../constants\";\nimport { RouterError } from \"../../RouterError\";\n\n// =============================================================================\n// Cached Errors (Performance Optimization)\n// =============================================================================\n// Pre-create error instances to avoid object allocation on hot paths.\n// Error creation involves: new object, stack trace capture (~500ns-2μs).\n// Cached errors skip this overhead entirely.\n//\n// Trade-off: All error instances share the same stack trace (points here).\n// This is acceptable because:\n// 1. These errors indicate user misconfiguration, not internal bugs\n// 2. Error code and message are sufficient for debugging\n// 3. Performance gain (~80% for error paths) outweighs stack trace loss\n// =============================================================================\n\n/**\n * Cached error for start() called when router is already started/starting.\n */\nexport const CACHED_ALREADY_STARTED_ERROR = new RouterError(\n errorCodes.ROUTER_ALREADY_STARTED,\n);\n"],"mappings":"sCAsBa,EAA+B,kCAAIA,EAAAA,CAAAA,YAC9CC,EAAAA,WAAW,sBACb"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../constants.js"),t=require("./helpers.js"),n=require("./routesStore.js"),r=require("../../transitionPath.js");function i(e){let t=[];for(let n of e)for(let e of n.paramMeta.urlParams)t.push(e);return t}function a(e,t){return{name:t??e.segments.at(-1).fullName,params:e.params,meta:e.meta}}var o=class{#e;#t;#n;get#r(){return this.#e.depsStore}constructor(e,t,r){this.#e=n.createRoutesStore(e,t,r)}static shouldUpdateNode(e){return(t,n)=>{if(!(t&&typeof t==`object`&&`name`in t))throw TypeError(`[router.shouldUpdateNode] toState must be valid State object`);if(t.transition.reload||e===``)return!0;let{intersection:i,toActivate:a,toDeactivate:o}=r.getTransitionPath(t,n);return e===i||a.includes(e)?!0:o.includes(e)}}setDependencies(e){this.#e.depsStore=e}flushPendingGuards(){let e=this.#r;for(let[t,n]of this.#e.pendingCanActivate)e.addActivateGuard(t,n);this.#e.pendingCanActivate.clear();for(let[t,n]of this.#e.pendingCanDeactivate)e.addDeactivateGuard(t,n);this.#e.pendingCanDeactivate.clear()}setLifecycleNamespace(e){this.#e.lifecycleNamespace=e}setRootPath(e){this.#e.rootPath=e,n.rebuildTreeInPlace(this.#e)}hasRoute(e){return this.#e.matcher.hasRoute(e)}clearRoutes(){n.resetStore(this.#e)}buildPath(t,n,r){if(t===e.constants.UNKNOWN_ROUTE)return typeof n?.path==`string`?n.path:``;let i=Object.hasOwn(this.#e.config.defaultParams,t)?{...this.#e.config.defaultParams[t],...n}:n??{},a=typeof this.#e.config.encoders[t]==`function`?this.#e.config.encoders[t]({...i}):i;return this.#e.matcher.buildPath(t,a,this.#a(r))}matchPath(e,n){let r=n,i=this.#e.matcher.match(e);if(!i)return;let{name:o,params:s,meta:c}=a(i),l=typeof this.#e.config.decoders[o]==`function`?this.#e.config.decoders[o](s):s,{name:u,params:d}=this.#r.forwardState(o,l),f=e;if(r.rewritePathOnMatch){let n=typeof this.#e.config.encoders[u]==`function`?this.#e.config.encoders[u]({...d}):d,i=r.trailingSlash;try{f=this.#e.matcher.buildPath(u,n,{trailingSlash:i===`never`||i===`always`?i:void 0,queryParamsMode:r.queryParamsMode}),i===`preserve`&&(f=t.matchSourceTrailingSlash(e,f))}catch{f=e}}return this.#r.makeState(u,d,f,c)}forwardState(e,t){if(Object.hasOwn(this.#e.config.forwardFnMap,e)){let n=this.#i(e,t),r=this.#e.config.forwardFnMap[e],i=this.#o(e,r,t);return{name:i,params:this.#i(i,n)}}let n=this.#e.resolvedForwardMap[e]??e;if(n!==e&&Object.hasOwn(this.#e.config.forwardFnMap,n)){let r=this.#i(e,t),i=this.#e.config.forwardFnMap[n],a=this.#o(n,i,t);return{name:a,params:this.#i(a,r)}}if(n!==e){let r=this.#i(e,t);return{name:n,params:this.#i(n,r)}}return{name:e,params:this.#i(e,t)}}buildStateResolved(e,t){let n=this.#e.matcher.getSegmentsByName(e);if(n)return a({segments:n,params:t,meta:this.#e.matcher.getMetaByName(e)},e)}isActiveRoute(n,r={},i=!1,a=!0){let o=this.#r.getState();if(!o)return!1;let s=o.name;if(s!==n&&!s.startsWith(`${n}.`)&&!n.startsWith(`${s}.`))return!1;let c=this.#e.config.defaultParams[n];if(i||s===n){let t={name:n,params:c?{...c,...r}:r,path:``,transition:e.DEFAULT_TRANSITION,context:{}};return this.#r.areStatesEqual(t,o,a)}if(!s.startsWith(`${n}.`))return!1;let l=o.params;return t.paramsMatch(r,l)?!c||t.paramsMatchExcluding(a?t.stripQueryDefaults(c,this.#e.matcher.getMetaByName(n)?.[n]):c,l,r):!1}getMetaForState(e){return this.#e.matcher.hasRoute(e)?this.#e.matcher.getMetaByName(e):void 0}getUrlParams(e){let t=this.#e.urlParamsCache.get(e);if(t!==void 0)return t;let n=this.#e.matcher.getSegmentsByName(e),r=n?i(n):[];return this.#e.urlParamsCache.set(e,r),r}getStore(){return this.#e}#i(e,t){return Object.hasOwn(this.#e.config.defaultParams,e)?{...this.#e.config.defaultParams[e],...t}:t}#a(e){if(this.#t)return e!==this.#n&&this.#r.logger.warn(`router.buildPath`,"`options` differs from the cached source reference; router options are immutable per router instance, so the first-cached buildPath options are reused (#957)."),this.#t;this.#n=e;let t=e?.trailingSlash;return this.#t=Object.freeze({trailingSlash:t===`never`||t===`always`?t:void 0,queryParamsMode:e?.queryParamsMode}),this.#t}#o(e,t,n){let r=new Set([e]),i=t(this.#r.getDependency,n),a=0;if(typeof i!=`string`)throw TypeError(`forwardTo callback must return a string, got ${typeof i}`);for(;a<100;){if(this.#e.matcher.getSegmentsByName(i)===void 0)throw Error(`Route "${i}" does not exist`);if(r.has(i)){let e=[...r,i].join(` → `);throw Error(`Circular forwardTo: ${e}`)}if(r.add(i),Object.hasOwn(this.#e.config.forwardFnMap,i)){let e=this.#e.config.forwardFnMap[i];i=e(this.#r.getDependency,n),a++;continue}let e=this.#e.config.forwardMap[i];if(e!==void 0){i=e,a++;continue}return i}throw Error(`forwardTo exceeds maximum depth of 100`)}};exports.RoutesNamespace=o;
|
|
2
|
+
//# sourceMappingURL=RoutesNamespace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoutesNamespace.js","names":["#store","#deps","createRoutesStore","getTransitionPath","constants","#getBuildPathOptions","matchSourceTrailingSlash","#mergeDefaultParams","#resolveDynamicForward","DEFAULT_TRANSITION","paramsMatch","paramsMatchExcluding","stripQueryDefaults","#cachedBuildPathOpts","#cachedOptionsSource"],"sources":["../../../../src/namespaces/RoutesNamespace/RoutesNamespace.ts"],"sourcesContent":["// packages/core/src/namespaces/RoutesNamespace/RoutesNamespace.ts\n\nimport { DEFAULT_ROUTE_NAME } from \"./constants\";\nimport {\n matchSourceTrailingSlash,\n paramsMatch,\n paramsMatchExcluding,\n stripQueryDefaults,\n} from \"./helpers\";\nimport {\n createRoutesStore,\n rebuildTreeInPlace,\n resetStore,\n} from \"./routesStore\";\nimport { constants, DEFAULT_TRANSITION } from \"../../constants\";\nimport { getTransitionPath } from \"../../transitionPath\";\n\nimport type { RoutesStore } from \"./routesStore\";\nimport type { RoutesDependencies } from \"./types\";\nimport type {\n CreateMatcherOptions,\n RouteParams,\n RouteTree,\n RouteTreeState,\n} from \"../../engine\";\nimport type {\n DefaultDependencies,\n ForwardToCallback,\n Options,\n Params,\n RouterLogger,\n State,\n Route,\n} from \"../../types\";\nimport type { RouteLifecycleNamespace } from \"../RouteLifecycleNamespace\";\n\nfunction collectUrlParamsArray(segments: readonly RouteTree[]): string[] {\n const params: string[] = [];\n\n for (const segment of segments) {\n for (const param of segment.paramMeta.urlParams) {\n params.push(param);\n }\n }\n\n return params;\n}\n\nfunction createRouteState<P extends RouteParams = RouteParams>(\n matchResult: {\n readonly segments: readonly { fullName: string }[];\n readonly params: Readonly<Record<string, unknown>>;\n readonly meta: Readonly<Record<string, Record<string, \"url\" | \"query\">>>;\n },\n name?: string,\n): RouteTreeState<P> {\n // The matcher yields ≥1 segment for every successful match, each carrying the\n // cumulative route name as `fullName`, so the last element is always present.\n // (Formerly `buildNameFromSegments` with a `?? \"\"` fallback — that branch was\n // unreachable defensive cruft propped up by a white-box test; inlined here.)\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- matcher invariant: a successful match is never empty\n const resolvedName = name ?? matchResult.segments.at(-1)!.fullName;\n\n return {\n name: resolvedName,\n params: matchResult.params as P,\n meta: matchResult.meta,\n };\n}\n\ninterface CachedBuildPathOpts {\n readonly trailingSlash?: \"always\" | \"never\" | undefined;\n readonly queryParamsMode?: \"default\" | \"strict\" | \"loose\" | undefined;\n}\n\n/**\n * Independent namespace for managing routes.\n *\n * Static methods handle validation (called by facade).\n * Instance methods handle storage and business logic.\n */\nexport class RoutesNamespace<\n Dependencies extends DefaultDependencies = DefaultDependencies,\n> {\n readonly #store: RoutesStore<Dependencies>;\n #cachedBuildPathOpts: CachedBuildPathOpts | undefined;\n // Source `options` reference captured on the first #getBuildPathOptions call;\n // used only by the dev-build immutability assertion below (#957).\n #cachedOptionsSource: Options | undefined;\n\n get #deps(): RoutesDependencies<Dependencies> {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.#store.depsStore!;\n }\n\n constructor(\n // No `= []` default: the sole caller (Router's ctor) always passes its own\n // already-defaulted `routes` — a namespace-level default would be dead code\n // and a default-before-required-params smell (S1788).\n routes: Route<Dependencies>[],\n matcherOptions: CreateMatcherOptions | undefined,\n logger: RouterLogger,\n ) {\n this.#store = createRoutesStore(routes, matcherOptions, logger);\n }\n\n /**\n * Creates a predicate function to check if a route node should be updated.\n * Note: Argument validation is done by facade (Router.ts) via validateShouldUpdateNodeArgs.\n */\n static shouldUpdateNode(\n nodeName: string,\n ): (toState: State, fromState?: State) => boolean {\n return (toState: State, fromState?: State): boolean => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!(toState && typeof toState === \"object\" && \"name\" in toState)) {\n throw new TypeError(\n \"[router.shouldUpdateNode] toState must be valid State object\",\n );\n }\n\n if (toState.transition.reload) {\n return true;\n }\n\n // Root node (DEFAULT_ROUTE_NAME === \"\") has no route-level identity — it\n // represents \"any route\". It must update on every transition so that\n // consumers subscribed via useRouteNode(\"\") (including RouteView at\n // the top of the tree) see every change. This matches the documented\n // contract in adapter docs: `useRouteNode(\"\")` — Root — ALL route\n // changes. See #519 for the missed transitions it was suffering from\n // (users → users.user had intersection=\"users\", leaving the root node\n // un-updated under a flat <Match segment=\"users.user\" exact> pattern).\n if (nodeName === DEFAULT_ROUTE_NAME) {\n return true;\n }\n\n const { intersection, toActivate, toDeactivate } = getTransitionPath(\n toState,\n fromState,\n );\n\n if (nodeName === intersection) {\n return true;\n }\n\n if (toActivate.includes(nodeName)) {\n return true;\n }\n\n return toDeactivate.includes(nodeName);\n };\n }\n\n // =========================================================================\n // Dependency injection\n // =========================================================================\n\n /**\n * Sets dependencies. Pure assignment — no side effects (#1331).\n *\n * The pending canActivate/canDeactivate factories from initial routes are\n * flushed separately by {@link flushPendingGuards}, called once wiring is\n * complete, so the order of the wire-* calls is unconstrained.\n */\n setDependencies(deps: RoutesDependencies<Dependencies>): void {\n this.#store.depsStore = deps;\n }\n\n /**\n * Registers the pending guard factories collected from initial route\n * definitions. Deferred out of {@link setDependencies} (#1331) so it runs on\n * a fully-built, fully-bound router: a guard factory that calls any\n * `router.*` method sees a ready instance instead of a half-assembled one.\n *\n * Invoked as the last step of the Router constructor. Idempotent after the\n * first call (the pending maps are cleared). Runtime `add()`/`replace()`\n * compile guards in their own PREPARE phase and never populate these maps.\n */\n flushPendingGuards(): void {\n const deps = this.#deps;\n\n for (const [routeName, handler] of this.#store.pendingCanActivate) {\n deps.addActivateGuard(routeName, handler);\n }\n\n this.#store.pendingCanActivate.clear();\n\n for (const [routeName, handler] of this.#store.pendingCanDeactivate) {\n deps.addDeactivateGuard(routeName, handler);\n }\n\n this.#store.pendingCanDeactivate.clear();\n }\n\n /**\n * Sets the lifecycle namespace reference.\n */\n setLifecycleNamespace(\n namespace: RouteLifecycleNamespace<Dependencies> | undefined,\n ): void {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.#store.lifecycleNamespace = namespace!;\n }\n\n // =========================================================================\n // Route tree operations\n // =========================================================================\n\n setRootPath(newRootPath: string): void {\n this.#store.rootPath = newRootPath;\n rebuildTreeInPlace(this.#store);\n }\n\n hasRoute(name: string): boolean {\n return this.#store.matcher.hasRoute(name);\n }\n\n clearRoutes(): void {\n resetStore(this.#store);\n }\n\n // =========================================================================\n // Path operations\n // =========================================================================\n\n /**\n * Builds a URL path for a route.\n * Note: Argument validation is done by facade (Router.ts) via validateBuildPathArgs.\n *\n * @param route - Route name\n * @param params - Route parameters\n * @param options - Router options\n */\n buildPath(route: string, params?: Params, options?: Options): string {\n if (route === constants.UNKNOWN_ROUTE) {\n return typeof params?.path === \"string\" ? params.path : \"\";\n }\n\n const paramsWithDefault = Object.hasOwn(\n this.#store.config.defaultParams,\n route,\n )\n ? { ...this.#store.config.defaultParams[route], ...params }\n : /* v8 ignore next -- @preserve: V8 can't track ?? branch in ternary; covered by buildPath tests without params */ (params ??\n {});\n\n const encodedParams =\n typeof this.#store.config.encoders[route] === \"function\"\n ? this.#store.config.encoders[route]({ ...paramsWithDefault })\n : paramsWithDefault;\n\n return this.#store.matcher.buildPath(\n route,\n encodedParams,\n this.#getBuildPathOptions(options),\n );\n }\n\n /**\n * Matches a URL path to a route in the tree.\n * Note: Argument validation is done by facade (Router.ts) via validateMatchPathArgs.\n */\n matchPath<P extends Params = Params>(\n path: string,\n options?: Options,\n ): State<P> | undefined {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Router.ts always passes options\n const opts = options!;\n\n const matchResult = this.#store.matcher.match(path);\n\n if (!matchResult) {\n return undefined;\n }\n\n const routeState = createRouteState(matchResult);\n const { name, params, meta } = routeState;\n\n const decodedParams =\n typeof this.#store.config.decoders[name] === \"function\"\n ? this.#store.config.decoders[name](params)\n : params;\n\n const { name: routeName, params: routeParams } = this.#deps.forwardState<P>(\n name,\n decodedParams as P,\n );\n\n let builtPath = path;\n\n if (opts.rewritePathOnMatch) {\n const buildParams =\n typeof this.#store.config.encoders[routeName] === \"function\"\n ? this.#store.config.encoders[routeName]({\n ...(routeParams as Params),\n })\n : (routeParams as Record<string, unknown>);\n\n const ts = opts.trailingSlash;\n\n try {\n builtPath = this.#store.matcher.buildPath(routeName, buildParams, {\n trailingSlash: ts === \"never\" || ts === \"always\" ? ts : undefined,\n queryParamsMode: opts.queryParamsMode,\n });\n\n if (ts === \"preserve\") {\n builtPath = matchSourceTrailingSlash(path, builtPath);\n }\n } catch {\n // The match already succeeded (route found, params decoded); only the\n // post-match path rewrite threw — e.g. a custom encoder handed buildPath\n // a query value its codec cannot serialise. Keep the source path\n // un-rewritten rather than discard a valid match (#1157). Opposite of the\n // parse side (#737): there a throw means \"URL not understood\" → unmatched;\n // here the URL WAS matched and only re-canonicalisation failed.\n builtPath = path;\n }\n }\n\n return this.#deps.makeState<P>(routeName, routeParams, builtPath, meta);\n }\n\n /**\n * Applies forwardTo and returns resolved state with merged defaultParams.\n *\n * Merges params in order:\n * 1. Source route defaultParams\n * 2. Provided params\n * 3. Target route defaultParams (after resolving forwardTo)\n */\n forwardState<P extends Params = Params>(\n name: string,\n params: P,\n ): { name: string; params: P } {\n if (Object.hasOwn(this.#store.config.forwardFnMap, name)) {\n const paramsWithSourceDefaults = this.#mergeDefaultParams(name, params);\n const dynamicForward = this.#store.config.forwardFnMap[name];\n const resolved = this.#resolveDynamicForward(\n name,\n dynamicForward,\n params,\n );\n\n return {\n name: resolved,\n params: this.#mergeDefaultParams(resolved, paramsWithSourceDefaults),\n };\n }\n\n const staticForward = this.#store.resolvedForwardMap[name] ?? name;\n\n if (\n staticForward !== name &&\n Object.hasOwn(this.#store.config.forwardFnMap, staticForward)\n ) {\n const paramsWithSourceDefaults = this.#mergeDefaultParams(name, params);\n const targetDynamicForward =\n this.#store.config.forwardFnMap[staticForward];\n const resolved = this.#resolveDynamicForward(\n staticForward,\n targetDynamicForward,\n params,\n );\n\n return {\n name: resolved,\n params: this.#mergeDefaultParams(resolved, paramsWithSourceDefaults),\n };\n }\n\n if (staticForward !== name) {\n const paramsWithSourceDefaults = this.#mergeDefaultParams(name, params);\n\n return {\n name: staticForward,\n params: this.#mergeDefaultParams(\n staticForward,\n paramsWithSourceDefaults,\n ),\n };\n }\n\n return { name, params: this.#mergeDefaultParams(name, params) };\n }\n\n /**\n * Builds a RouteTreeState from already-resolved route name and params.\n * Called by Router.buildState after forwardState is applied at facade level.\n * This allows plugins to intercept forwardState.\n */\n buildStateResolved(\n resolvedName: string,\n resolvedParams: Params,\n ): RouteTreeState | undefined {\n const segments = this.#store.matcher.getSegmentsByName(resolvedName);\n\n if (!segments) {\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const meta = this.#store.matcher.getMetaByName(resolvedName)!;\n\n return createRouteState(\n { segments, params: resolvedParams, meta },\n resolvedName,\n );\n }\n\n // =========================================================================\n // Query operations\n // =========================================================================\n\n /**\n * Checks if a route is currently active.\n */\n isActiveRoute(\n name: string,\n params: Params = {},\n strictEquality = false,\n ignoreQueryParams = true,\n ): boolean {\n // Note: empty string check is handled by Router.ts facade\n const activeState = this.#deps.getState();\n\n if (!activeState) {\n return false;\n }\n\n const activeName = activeState.name;\n\n // Fast path: check if routes are related before expensive operations\n if (\n activeName !== name &&\n !activeName.startsWith(`${name}.`) &&\n !name.startsWith(`${activeName}.`)\n ) {\n return false;\n }\n\n const defaultParams = this.#store.config.defaultParams[name] as\n Params | undefined;\n\n // Exact match case\n if (strictEquality || activeName === name) {\n const effectiveParams = defaultParams\n ? { ...defaultParams, ...params }\n : params;\n\n const targetState: State = {\n name,\n params: effectiveParams,\n path: \"\",\n transition: DEFAULT_TRANSITION,\n context: {},\n };\n\n return this.#deps.areStatesEqual(\n targetState,\n activeState,\n ignoreQueryParams,\n );\n }\n\n // The fast path above lets through three relations: exact (handled in\n // the previous block), `activeName` descendant of `name`, and `name`\n // descendant of `activeName`. Only the first two count as \"active\" —\n // a link pointing DEEPER than the current state is a navigation option,\n // not an active state. Reject the descendant-of-active case explicitly.\n if (!activeName.startsWith(`${name}.`)) {\n return false;\n }\n\n // Hierarchical check: activeState is a descendant of target (name)\n const activeParams = activeState.params;\n\n if (!paramsMatch(params, activeParams)) {\n return false;\n }\n\n if (!defaultParams) {\n return true;\n }\n\n // Honor `ignoreQueryParams` symmetrically with the exact-match branch\n // above: query-only param differences (e.g. parent has\n // `defaultParams: { sort: \"asc\" }` while the active descendant is\n // `products.detail` with `params: { id: \"6\" }` and no sort) must not\n // disqualify an ancestor link from being active. Strip query-typed\n // keys of `name` from the defaults before comparison; URL-typed keys\n // (`:id`, `:role`, etc.) are still enforced.\n // `name` reaches this point only after the fast-path established a valid\n // hierarchical relation AND `defaultParams` is non-null — both imply the\n // matcher has registered the route. Since the #1414 skip-empty meta, a\n // fully-static route resolves to the shared EMPTY_ROUTE_META with no own\n // entry, so `getMetaByName(name)?.[name]` is undefined there — exactly the\n // \"nothing to strip\" signal stripQueryDefaults short-circuits on (a static\n // route cannot declare query params, hence cannot carry query defaults).\n const defaultsToCheck = ignoreQueryParams\n ? stripQueryDefaults(\n defaultParams,\n this.#store.matcher.getMetaByName(name)?.[name],\n )\n : defaultParams;\n\n return paramsMatchExcluding(defaultsToCheck, activeParams, params);\n }\n\n getMetaForState(\n name: string,\n ): Record<string, Record<string, \"url\" | \"query\">> | undefined {\n return this.#store.matcher.hasRoute(name)\n ? this.#store.matcher.getMetaByName(name)\n : undefined;\n }\n\n getUrlParams(name: string): string[] {\n const cached = this.#store.urlParamsCache.get(name);\n\n // Stryker disable next-line BlockStatement: equivalent — cache short-circuit; emptying the early-return recomputes the identical value (getUrlParams is deterministic per route name) and re-caches it. (ConditionalExpression stays live: `→true` returns undefined on a cache miss = killed.)\n if (cached !== undefined) {\n return cached;\n }\n\n const segments = this.#store.matcher.getSegmentsByName(name);\n const result = segments\n ? collectUrlParamsArray(segments as readonly RouteTree[])\n : [];\n\n this.#store.urlParamsCache.set(name, result);\n\n return result;\n }\n\n getStore(): RoutesStore<Dependencies> {\n return this.#store;\n }\n\n #mergeDefaultParams<P extends Params = Params>(\n routeName: string,\n params: P,\n ): P {\n if (Object.hasOwn(this.#store.config.defaultParams, routeName)) {\n return {\n ...this.#store.config.defaultParams[routeName],\n ...params,\n };\n }\n\n return params;\n }\n\n #getBuildPathOptions(options?: Options): CachedBuildPathOpts {\n // Stryker disable next-line BlockStatement: equivalent — cache short-circuit; emptying the early-return rebuilds the identical buildPath options (deterministic) and re-caches them. (ConditionalExpression stays live: `→false` always rebuilds but a real consumer test pins the cached identity.)\n if (this.#cachedBuildPathOpts) {\n /* v8 ignore next 5 -- @preserve: dev assertion guarding a future caller that passes per-call varying options; the sole caller (Router.buildPath, always via this.#options.get()) passes the same immutable, deep-frozen per-instance options, so this branch is unreachable through the public API by construction (#957) */\n if (options !== this.#cachedOptionsSource) {\n this.#deps.logger.warn(\n \"router.buildPath\",\n \"`options` differs from the cached source reference; router options are immutable per router instance, so the first-cached buildPath options are reused (#957).\",\n );\n }\n\n return this.#cachedBuildPathOpts;\n }\n\n this.#cachedOptionsSource = options;\n\n const ts = options?.trailingSlash;\n\n this.#cachedBuildPathOpts = Object.freeze({\n trailingSlash: ts === \"never\" || ts === \"always\" ? ts : undefined,\n queryParamsMode: options?.queryParamsMode,\n });\n\n return this.#cachedBuildPathOpts;\n }\n\n #resolveDynamicForward(\n startName: string,\n startFn: ForwardToCallback<Dependencies>,\n params: Params,\n ): string {\n const visited = new Set<string>([startName]);\n\n let current = startFn(this.#deps.getDependency, params);\n let depth = 0;\n const MAX_DEPTH = 100;\n\n if (typeof current !== \"string\") {\n throw new TypeError(\n `forwardTo callback must return a string, got ${typeof current}`,\n );\n }\n\n while (depth < MAX_DEPTH) {\n if (this.#store.matcher.getSegmentsByName(current) === undefined) {\n throw new Error(`Route \"${current}\" does not exist`);\n }\n\n if (visited.has(current)) {\n const chain = [...visited, current].join(\" → \");\n\n throw new Error(`Circular forwardTo: ${chain}`);\n }\n\n visited.add(current);\n\n if (Object.hasOwn(this.#store.config.forwardFnMap, current)) {\n const fn = this.#store.config.forwardFnMap[\n current\n ] as ForwardToCallback<Dependencies>;\n\n current = fn(this.#deps.getDependency, params);\n\n depth++;\n continue;\n }\n\n const staticForward = this.#store.config.forwardMap[current];\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (staticForward !== undefined) {\n current = staticForward;\n depth++;\n continue;\n }\n\n return current;\n }\n\n throw new Error(`forwardTo exceeds maximum depth of ${MAX_DEPTH}`);\n }\n}\n"],"mappings":"mIAoCA,SAAS,EAAsB,EAA0C,CACvE,IAAM,EAAmB,CAAC,EAE1B,IAAK,IAAM,KAAW,EACpB,IAAK,IAAM,KAAS,EAAQ,UAAU,UACpC,EAAO,KAAK,CAAK,EAIrB,OAAO,CACT,CAEA,SAAS,EACP,EAKA,EACmB,CAQnB,MAAO,CACL,KAHmB,GAAQ,EAAY,SAAS,GAAG,EAAE,CAAC,CAAE,SAIxD,OAAQ,EAAY,OACpB,KAAM,EAAY,IACpB,CACF,CAaA,IAAa,EAAb,KAEE,CACA,GACA,GAGA,GAEA,GAAIC,IAA0C,CAE5C,OAAO,KAAKD,GAAO,SACrB,CAEA,YAIE,EACA,EACA,EACA,CACA,KAAKA,GAASE,EAAAA,kBAAkB,EAAQ,EAAgB,CAAM,CAChE,CAMA,OAAO,iBACL,EACgD,CAChD,OAAQ,EAAgB,IAA+B,CAErD,GAAI,EAAE,GAAW,OAAO,GAAY,UAAY,SAAU,GACxD,MAAU,UACR,8DACF,EAeF,GAZI,EAAQ,WAAW,QAYnB,IAAA,GACF,MAAO,GAGT,GAAM,CAAE,eAAc,aAAY,gBAAiBC,EAAAA,kBACjD,EACA,CACF,EAUA,OARI,IAAa,GAIb,EAAW,SAAS,CAAQ,EACvB,GAGF,EAAa,SAAS,CAAQ,CACvC,CACF,CAaA,gBAAgB,EAA8C,CAC5D,KAAKH,GAAO,UAAY,CAC1B,CAYA,oBAA2B,CACzB,IAAM,EAAO,KAAKC,GAElB,IAAK,GAAM,CAAC,EAAW,KAAY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O,OAAO,KAAKA,GAAO,OAAO,aAAc,CAAO,EAAG,CAC3D,IAAM,EAAK,KAAKA,GAAO,OAAO,aAC5B,GAGF,EAAU,EAAG,KAAKC,GAAM,cAAe,CAAM,EAE7C,IACA,QACF,CAEA,IAAM,EAAgB,KAAKD,GAAO,OAAO,WAAW,GAGpD,GAAI,IAAkB,IAAA,GAAW,CAC/B,EAAU,EACV,IACA,QACF,CAEA,OAAO,CACT,CAEA,MAAU,MAAM,wCAAiD,CACnE,CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../../../src/namespaces/RoutesNamespace/constants.ts"],"sourcesContent":["// packages/core/src/namespaces/RoutesNamespace/constants.ts\n\n/**\n * Default route name for the root node.\n */\nexport const DEFAULT_ROUTE_NAME = \"\";\n\n/**\n * Keys that belong to a route's structural/config surface — everything NOT in\n * this set is a plugin-defined **custom field** (e.g. lifecycle hooks,\n * `preload`, `searchSchema`), stored in `RoutesStore.routeCustomFields`.\n *\n * Single source of truth for the custom-field split, shared by route\n * registration (`add`/`replace`) and `update` so both classify patch keys\n * identically. `name`/`path`/`children` define route identity and are not\n * patchable via `update`; the remaining six are the structural/guard config.\n */\nexport const STANDARD_ROUTE_KEYS: ReadonlySet<string> = new Set([\n \"name\",\n \"path\",\n \"children\",\n \"canActivate\",\n \"canDeactivate\",\n \"forwardTo\",\n \"encodeParams\",\n \"decodeParams\",\n \"defaultParams\",\n]);\n"],"mappings":"AAiBA,MAAa,EAA2C,IAAI,IAAI,CAC9D,OACA,OACA,WACA,cACA,gBACA,YACA,eACA,eACA,eACF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
//#region src/namespaces/RoutesNamespace/forwardChain.d.ts
|
|
2
|
+
declare function resolveForwardChain(startRoute: string, forwardMap: Record<string, string>, maxDepth?: number): string;
|
|
3
|
+
//#endregion
|
|
4
|
+
export { resolveForwardChain };
|
|
5
|
+
//# sourceMappingURL=forwardChain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forwardChain.d.ts","names":[],"sources":["../../../../src/namespaces/RoutesNamespace/forwardChain.ts"],"mappings":";iBAEgB,oBACd,oBACA,YAAY,wBACZ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e,t,n=100){let r=new Set,i=[e],a=e;for(;t[a];){let e=t[a];if(r.has(e)){let t=i.indexOf(e),n=[...i.slice(t),e];throw Error(`Circular forwardTo: ${n.join(` → `)}`)}if(r.add(a),i.push(e),a=e,i.length>n)throw Error(`forwardTo chain exceeds maximum depth (${n}): ${i.join(` → `)}`)}return a}exports.resolveForwardChain=e;
|
|
2
|
+
//# sourceMappingURL=forwardChain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forwardChain.js","names":[],"sources":["../../../../src/namespaces/RoutesNamespace/forwardChain.ts"],"sourcesContent":["// packages/core/src/namespaces/RoutesNamespace/forwardChain.ts\n\nexport function resolveForwardChain(\n startRoute: string,\n forwardMap: Record<string, string>,\n maxDepth = 100,\n): string {\n const visited = new Set<string>();\n const chain: string[] = [startRoute];\n let current = startRoute;\n\n while (forwardMap[current]) {\n const next = forwardMap[current];\n\n if (visited.has(next)) {\n const cycleStart = chain.indexOf(next);\n const cycle = [...chain.slice(cycleStart), next];\n\n throw new Error(`Circular forwardTo: ${cycle.join(\" → \")}`);\n }\n\n visited.add(current);\n chain.push(next);\n current = next;\n\n if (chain.length > maxDepth) {\n throw new Error(\n `forwardTo chain exceeds maximum depth (${maxDepth}): ${chain.join(\" → \")}`,\n );\n }\n }\n\n return current;\n}\n"],"mappings":"AAEA,SAAgB,EACd,EACA,EACA,EAAW,IACH,CACR,IAAM,EAAU,IAAI,IACd,EAAkB,CAAC,CAAU,EAC/B,EAAU,EAEd,KAAO,EAAW,IAAU,CAC1B,IAAM,EAAO,EAAW,GAExB,GAAI,EAAQ,IAAI,CAAI,EAAG,CACrB,IAAM,EAAa,EAAM,QAAQ,CAAI,EAC/B,EAAQ,CAAC,GAAG,EAAM,MAAM,CAAU,EAAG,CAAI,EAE/C,MAAU,MAAM,uBAAuB,EAAM,KAAK,KAAK,GAAG,CAC5D,CAMA,GAJA,EAAQ,IAAI,CAAO,EACnB,EAAM,KAAK,CAAI,EACf,EAAU,EAEN,EAAM,OAAS,EACjB,MAAU,MACR,0CAA0C,EAAS,KAAK,EAAM,KAAK,KAAK,GAC1E,CAEJ,CAEA,OAAO,CACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(){return{decoders:Object.create(null),encoders:Object.create(null),defaultParams:Object.create(null),forwardMap:Object.create(null),forwardFnMap:Object.create(null)}}function t(e,t){for(let n of Object.keys(t))Object.assign(e[n],t[n])}function n(e,t){for(let n in e)if(e[n]!==t[n])return!1;return!0}function r(e,t,n){for(let r in e)if(!(r in n)&&e[r]!==t[r])return!1;return!0}function i(e,t){if(!t||!a(e,t))return e;let n={};for(let r in e)t[r]!==`query`&&(n[r]=e[r]);return n}function a(e,t){for(let n in e)if(t[n]===`query`)return!0;return!1}function o(e){let t={name:e.name,path:e.path};return e.children&&(t.children=e.children.map(e=>o(e))),t}function s(e,t,n=``){for(let r=0;r<e.length;r++){let i=e[r],a=n?`${n}.${i.name}`:i.name;if(a===t)return e.splice(r,1),!0;if(i.children&&t.startsWith(`${a}.`)&&s(i.children,t,a))return!0}return!1}function c(e,t){for(let n of Object.keys(e))t(n)&&delete e[n]}function l(e,t){let n=t.search(/[?#]/),r=n===-1?t:t.slice(0,n);if(r===`/`||r.endsWith(`/`))return t;let i=e.search(/[?#]/),a=i===-1?e:e.slice(0,i);return a.length>1&&a.endsWith(`/`)?`${r}/${n===-1?``:t.slice(n)}`:t}exports.assignConfigEntries=t,exports.clearConfigEntries=c,exports.createEmptyConfig=e,exports.matchSourceTrailingSlash=l,exports.paramsMatch=n,exports.paramsMatchExcluding=r,exports.removeFromDefinitions=s,exports.sanitizeRoute=o,exports.stripQueryDefaults=i;
|
|
2
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","names":[],"sources":["../../../../src/namespaces/RoutesNamespace/helpers.ts"],"sourcesContent":["// packages/core/src/namespaces/RoutesNamespace/helpers.ts\n\nimport type { RouteConfig } from \"./types\";\nimport type { RouteDefinition } from \"../../engine\";\nimport type {\n DefaultDependencies,\n ForwardToCallback,\n Params,\n Route,\n} from \"../../types\";\n\n/**\n * Creates an empty RouteConfig.\n */\nexport function createEmptyConfig(): RouteConfig {\n return {\n decoders: Object.create(null) as Record<string, (params: Params) => Params>,\n encoders: Object.create(null) as Record<string, (params: Params) => Params>,\n defaultParams: Object.create(null) as Record<string, Params>,\n forwardMap: Object.create(null) as Record<string, string>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n forwardFnMap: Object.create(null) as Record<string, ForwardToCallback<any>>,\n };\n}\n\n/**\n * Copies every {@link RouteConfig} sub-map's entries from `source` into\n * `target` (shallow per map — entries are shared by reference). Driven by\n * `Object.keys(source)` instead of one `Object.assign` per field, so a newly\n * added config sub-field is carried over automatically with nothing to forget\n * at each copy site (#965). Both configs are produced by\n * {@link createEmptyConfig}, so every key in `source` also exists on `target`,\n * and every value is a record object — the invariant this enumeration relies on.\n */\nexport function assignConfigEntries(\n target: RouteConfig,\n source: RouteConfig,\n): void {\n for (const key of Object.keys(source) as (keyof RouteConfig)[]) {\n Object.assign(target[key], source[key]);\n }\n}\n\n// ============================================================================\n// Route Tree Helpers\n// ============================================================================\n\n/**\n * Checks if all params from source exist with same values in target.\n * Small function body allows V8 inlining.\n */\nexport function paramsMatch(source: Params, target: Params): boolean {\n for (const key in source) {\n if (source[key] !== target[key]) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Checks params match, skipping keys present in skipKeys.\n */\nexport function paramsMatchExcluding(\n source: Params,\n target: Params,\n skipKeys: Params,\n): boolean {\n for (const key in source) {\n if (key in skipKeys) {\n continue;\n }\n if (source[key] !== target[key]) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Returns a copy of `defaultParams` with query-typed keys removed, based on\n * `ownMeta` (the per-route paramTypeMap from the matcher). When no query keys\n * are present, returns the input by reference (zero-allocation fast path).\n *\n * `ownMeta` may be `undefined` for non-registered route names — this is the\n * caller's escape hatch (e.g. `getMetaByName(name)?.[name]`); a missing meta\n * means no query type information is available, so defaults pass through\n * unchanged.\n */\nexport function stripQueryDefaults(\n defaultParams: Params,\n ownMeta: Record<string, \"url\" | \"query\"> | undefined,\n): Params {\n if (!ownMeta || !hasQueryDefault(defaultParams, ownMeta)) {\n return defaultParams;\n }\n\n const filtered: Params = {};\n\n for (const key in defaultParams) {\n if (ownMeta[key] !== \"query\") {\n filtered[key] = defaultParams[key];\n }\n }\n\n return filtered;\n}\n\nfunction hasQueryDefault(\n defaultParams: Params,\n ownMeta: Record<string, \"url\" | \"query\">,\n): boolean {\n for (const key in defaultParams) {\n if (ownMeta[key] === \"query\") {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Sanitizes a route by keeping only essential properties.\n */\nexport function sanitizeRoute<Dependencies extends DefaultDependencies>(\n route: Route<Dependencies>,\n): RouteDefinition {\n const sanitized: RouteDefinition = {\n name: route.name,\n path: route.path,\n };\n\n if (route.children) {\n sanitized.children = route.children.map((child) => sanitizeRoute(child));\n }\n\n return sanitized;\n}\n\n/**\n * Recursively removes a route from definitions array.\n */\nexport function removeFromDefinitions(\n definitions: RouteDefinition[],\n routeName: string,\n parentPrefix = \"\",\n): boolean {\n for (let i = 0; i < definitions.length; i++) {\n const route = definitions[i];\n const fullName = parentPrefix\n ? `${parentPrefix}.${route.name}`\n : route.name;\n\n if (fullName === routeName) {\n definitions.splice(i, 1);\n\n return true;\n }\n\n if (\n route.children &&\n routeName.startsWith(`${fullName}.`) &&\n removeFromDefinitions(route.children, routeName, fullName)\n ) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Clears configuration entries that match the predicate.\n */\nexport function clearConfigEntries<T>(\n config: Record<string, T>,\n matcher: (key: string) => boolean,\n): void {\n for (const key of Object.keys(config)) {\n if (matcher(key)) {\n delete config[key];\n }\n }\n}\n\n/**\n * Used by matchPath() when trailingSlash is \"preserve\": the matcher's\n * buildPath() with an unset trailingSlash mode strips trailing slashes,\n * but \"preserve\" means the source path's trailing-slash choice wins.\n * If the source had a trailing slash, re-attach it to the rewritten path.\n * The reverse case (rewritten has trailing, source does not) is not\n * reachable with the current matcher — it never adds a trailing slash\n * with undefined mode.\n */\nexport function matchSourceTrailingSlash(\n sourcePath: string,\n rewrittenPath: string,\n): string {\n const queryIndex = rewrittenPath.search(/[?#]/);\n const pathPart =\n queryIndex === -1 ? rewrittenPath : rewrittenPath.slice(0, queryIndex);\n\n // Stryker disable next-line LogicalOperator: equivalent — buildPath strips trailing slashes, so the rewritten path never ends with \"/\" unless it IS \"/\" (already caught by the `=== \"/\"` operand). `endsWith(\"/\")` is unreachable-true, so `||` ≡ `&&`.\n if (pathPart === \"/\" || pathPart.endsWith(\"/\")) {\n return rewrittenPath;\n }\n\n const sourceQueryIndex = sourcePath.search(/[?#]/);\n const sourcePathPart =\n sourceQueryIndex === -1\n ? sourcePath\n : sourcePath.slice(0, sourceQueryIndex);\n\n if (!(sourcePathPart.length > 1 && sourcePathPart.endsWith(\"/\"))) {\n return rewrittenPath;\n }\n\n const querySuffix = queryIndex === -1 ? \"\" : rewrittenPath.slice(queryIndex);\n\n return `${pathPart}/${querySuffix}`;\n}\n"],"mappings":"AAcA,SAAgB,GAAiC,CAC/C,MAAO,CACL,SAAU,OAAO,OAAO,IAAI,EAC5B,SAAU,OAAO,OAAO,IAAI,EAC5B,cAAe,OAAO,OAAO,IAAI,EACjC,WAAY,OAAO,OAAO,IAAI,EAE9B,aAAc,OAAO,OAAO,IAAI,CAClC,CACF,CAWA,SAAgB,EACd,EACA,EACM,CACN,IAAK,IAAM,KAAO,OAAO,KAAK,CAAM,EAClC,OAAO,OAAO,EAAO,GAAM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ACQ,CACR,IAAM,EAAa,EAAc,OAAO,MAAM,EACxC,EACJ,IAAe,GAAK,EAAgB,EAAc,MAAM,EAAG,CAAU,EAGvE,GAAI,IAAa,KAAO,EAAS,SAAS,GAAG,EAC3C,OAAO,EAGT,IAAM,EAAmB,EAAW,OAAO,MAAM,EAC3C,EACJ,IAAqB,GACjB,EACA,EAAW,MAAM,EAAG,CAAgB,EAQ1C,OANM,EAAe,OAAS,GAAK,EAAe,SAAS,GAAG,EAMvD,GAAG,EAAS,GAFC,IAAe,GAAK,GAAK,EAAc,MAAM,CAAU,IAHlE,CAMX"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e,t,n,r){if(t){let n=t===e,i=t.startsWith(`${e}.`);if(n||i){let i=n?``:` (current: "${t}")`;return r.warn(`router.removeRoute`,`Cannot remove route "${e}" — it is currently active${i}. Navigate away first.`),!1}}return n&&r.warn(`router.removeRoute`,`Route "${e}" removed while navigation is in progress. This may cause unexpected behavior.`),!0}function t(e,t){return e?(t.error(`router.clearRoutes`,`Cannot clear routes while navigation is in progress. Wait for navigation to complete.`),!1):!0}exports.validateClearRoutes=t,exports.validateRemoveRoute=e;
|
|
2
|
+
//# sourceMappingURL=routeGuards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routeGuards.js","names":[],"sources":["../../../../src/namespaces/RoutesNamespace/routeGuards.ts"],"sourcesContent":["import type { RouterLogger } from \"../../types\";\n\n/**\n * Validates removeRoute constraints.\n * Returns false if removal should be blocked (route is active).\n * Logs warnings for edge cases.\n *\n * @param name - Route name to remove\n * @param currentStateName - Current active route name (or undefined)\n * @param isNavigating - Whether navigation is in progress\n * @param logger - Per-router logger instance (from `getInternals(router).logger`)\n * @returns true if removal can proceed, false if blocked\n */\nexport function validateRemoveRoute(\n name: string,\n currentStateName: string | undefined,\n isNavigating: boolean,\n logger: RouterLogger,\n): boolean {\n if (currentStateName) {\n const isExactMatch = currentStateName === name;\n const isParentOfCurrent = currentStateName.startsWith(`${name}.`);\n\n if (isExactMatch || isParentOfCurrent) {\n const suffix = isExactMatch ? \"\" : ` (current: \"${currentStateName}\")`;\n\n logger.warn(\n \"router.removeRoute\",\n `Cannot remove route \"${name}\" — it is currently active${suffix}. Navigate away first.`,\n );\n\n return false;\n }\n }\n\n if (isNavigating) {\n logger.warn(\n \"router.removeRoute\",\n `Route \"${name}\" removed while navigation is in progress. This may cause unexpected behavior.`,\n );\n }\n\n return true;\n}\n\n/**\n * Validates clearRoutes operation.\n * Returns false if operation should be blocked (navigation in progress).\n *\n * @param isNavigating - Whether navigation is in progress\n * @param logger - Per-router logger instance (from `getInternals(router).logger`)\n * @returns true if clearRoutes can proceed, false if blocked\n */\nexport function validateClearRoutes(\n isNavigating: boolean,\n logger: RouterLogger,\n): boolean {\n if (isNavigating) {\n logger.error(\n \"router.clearRoutes\",\n \"Cannot clear routes while navigation is in progress. Wait for navigation to complete.\",\n );\n\n return false;\n }\n\n return true;\n}\n"],"mappings":"AAaA,SAAgB,EACd,EACA,EACA,EACA,EACS,CACT,GAAI,EAAkB,CACpB,IAAM,EAAe,IAAqB,EACpC,EAAoB,EAAiB,WAAW,GAAG,EAAK,EAAE,EAEhE,GAAI,GAAgB,EAAmB,CACrC,IAAM,EAAS,EAAe,GAAK,eAAe,EAAiB,IAOnE,OALA,EAAO,KACL,qBACA,wBAAwB,EAAK,4BAA4B,EAAO,uBAClE,EAEO,EACT,CACF,CASA,OAPI,GACF,EAAO,KACL,qBACA,UAAU,EAAK,+EACjB,EAGK,EACT,CAUA,SAAgB,EACd,EACA,EACS,CAUT,OATI,GACF,EAAO,MACL,qBACA,uFACF,EAEO,IAGF,EACT"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { RouteDefinition, RouteTree } from "../../engine/builder/types.js";
|
|
2
|
+
import { CreateMatcherOptions, Matcher } from "../../engine/createMatcher.js";
|
|
3
|
+
import { DefaultDependencies, GuardFnFactory } from "../../types/router.js";
|
|
4
|
+
import { RouteLifecycleNamespace } from "../RouteLifecycleNamespace/RouteLifecycleNamespace.js";
|
|
5
|
+
import { RouteConfig, RoutesDependencies } from "./types.js";
|
|
6
|
+
//#region src/namespaces/RoutesNamespace/routesStore.d.ts
|
|
7
|
+
interface RoutesStore<Dependencies extends DefaultDependencies = DefaultDependencies> {
|
|
8
|
+
/**
|
|
9
|
+
* DERIVED VIEW, not stored state: reconstructed from `tree` on every access
|
|
10
|
+
* via `routeTreeToDefinitions` (the lossless inverse cloneRouter already
|
|
11
|
+
* relies on — the `~` absolute marker is restored, child order is the
|
|
12
|
+
* definition order). The tree is the single source of truth, so a third
|
|
13
|
+
* retained copy of the route table (~30 B/route) is not kept. Every reader
|
|
14
|
+
* is a cold CRUD/plugin-registration path; the derive is O(N).
|
|
15
|
+
*
|
|
16
|
+
* The returned array is a FRESH snapshot each time — mutating it never
|
|
17
|
+
* affects the store (pass an explicitly-mutated snapshot to
|
|
18
|
+
* `commitTreeChanges` instead, as `remove` does).
|
|
19
|
+
*/
|
|
20
|
+
readonly definitions: RouteDefinition[];
|
|
21
|
+
readonly config: RouteConfig;
|
|
22
|
+
tree: RouteTree;
|
|
23
|
+
matcher: Matcher;
|
|
24
|
+
/**
|
|
25
|
+
* Per-route-name cache of URL (path) param names, derived from `matcher` and
|
|
26
|
+
* read by `RoutesNamespace.getUrlParams` (powers `areStatesEqual` /
|
|
27
|
+
* `isActiveRoute`). Cleared on every `matcher` rebuild so comparisons never
|
|
28
|
+
* stay frozen to a route's pre-mutation param shape (#723).
|
|
29
|
+
*/
|
|
30
|
+
readonly urlParamsCache: Map<string, string[]>;
|
|
31
|
+
resolvedForwardMap: Record<string, string>;
|
|
32
|
+
routeCustomFields: Record<string, Record<string, unknown>>;
|
|
33
|
+
rootPath: string;
|
|
34
|
+
readonly matcherOptions: CreateMatcherOptions | undefined;
|
|
35
|
+
depsStore: RoutesDependencies<Dependencies> | undefined;
|
|
36
|
+
lifecycleNamespace: RouteLifecycleNamespace<Dependencies> | undefined;
|
|
37
|
+
readonly pendingCanActivate: Map<string, GuardFnFactory<Dependencies>>;
|
|
38
|
+
readonly pendingCanDeactivate: Map<string, GuardFnFactory<Dependencies>>;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { RoutesStore };
|
|
42
|
+
//# sourceMappingURL=routesStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routesStore.d.ts","names":[],"sources":["../../../../src/namespaces/RoutesNamespace/routesStore.ts"],"mappings":";;;;;;UAsCiB,YACf,qBAAqB,sBAAsB;;;;;;;;;;;;;WAclC,aAAa;WACb,QAAQ;EACjB,MAAM;EACN,SAAS;;;;;;;WAOA,gBAAgB;EACzB,oBAAoB;EACpB,mBAAmB,eAAe;EAClC;WACS,gBAAgB;EACzB,WAAW,mBAAmB;EAC9B,oBAAoB,wBAAwB;WACnC,oBAAoB,YAAY,eAAe;WAC/C,sBAAsB,YAAY,eAAe"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../engine/builder/createRouteTree.js"),t=require("../../engine/operations/routeTreeToDefinitions.js"),n=require("../../engine/createMatcher.js"),r=require("./constants.js"),i=require("./helpers.js"),a=require("./forwardChain.js");function o(t,r,i){let a=e.createRouteTree(``,r,t),o=n.createMatcher(i);return o.registerTree(a),{tree:a,matcher:o}}function s(e,t=e.definitions){let n=o(t,e.rootPath,e.matcherOptions);e.tree=n.tree,e.matcher=n.matcher,e.urlParamsCache.clear()}function c(e,t){s(e,t),e.resolvedForwardMap=d(e.config)}function l(e){u(e),s(e,[])}function u(e){Object.assign(e.config,i.createEmptyConfig()),e.resolvedForwardMap=Object.create(null),e.routeCustomFields=Object.create(null)}function d(e){let t=Object.create(null);for(let n of Object.keys(e.forwardMap))t[n]=a.resolveForwardChain(n,e.forwardMap);return t}function f(e,t){if(typeof e!=`function`)return;let n=e.constructor.name===`AsyncFunction`,r=e.toString().includes(`__awaiter`);if(n||r)throw TypeError(`forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`)}function p(e,t,n,r){if(e.canActivate){let n=typeof e.forwardTo==`string`?e.forwardTo:`[dynamic]`;r.warn(`real-router`,`Route "${t}" has both forwardTo and canActivate. canActivate will be ignored because forwardTo creates a redirect (industry standard). Move canActivate to the target route "${n}".`)}if(e.canDeactivate){let n=typeof e.forwardTo==`string`?e.forwardTo:`[dynamic]`;r.warn(`real-router`,`Route "${t}" has both forwardTo and canDeactivate. canDeactivate will be ignored because forwardTo creates a redirect (industry standard). Move canDeactivate to the target route "${n}".`)}f(e.forwardTo,t),typeof e.forwardTo==`string`?n.forwardMap[t]=e.forwardTo:n.forwardFnMap[t]=e.forwardTo}function m(e,t,n,i,a,o,s){let c=Object.fromEntries(Object.entries(e).filter(([e])=>!r.STANDARD_ROUTE_KEYS.has(e)));Object.keys(c).length>0&&(i[t]=c),e.canActivate&&a.set(t,e.canActivate),e.canDeactivate&&o.set(t,e.canDeactivate),e.forwardTo&&p(e,t,n,s),e.decodeParams&&(n.decoders[t]=t=>e.decodeParams?.(t)??t),e.encodeParams&&(n.encoders[t]=t=>e.encodeParams?.(t)??t),e.defaultParams&&(n.defaultParams[t]=e.defaultParams)}function h(e,t,n,r,i,a,o=``){for(let s of e){let e=o?`${o}.${s.name}`:s.name;m(s,e,t,n,r,i,a),s.children&&h(s.children,t,n,r,i,a,e)}}function g(e){let t=i.createEmptyConfig();return i.assignConfigEntries(t,e),t}function _(e,t,n){if(n.length===0)return[...e,...t];let[r,...i]=n;return e.map(e=>{if(e.name!==r)return e;let n=e.children??[];return{...e,children:i.length===0?[...n,...t]:_(n,t,i)}})}function v(e,t,n){for(let r of e){let e=t?`${t}.${r.name}`:r.name;n(e),r.children&&v(r.children,e,n)}}function y(e,t,n){let r=new Set;v(e,t,e=>{if(r.has(e))throw Error(`[router.${n}] Duplicate route "${e}" in batch`);r.add(e)})}function b(e,t){if(e.startsWith(`@@`))throw Error(`[router.${t}] Route name "${e}" uses the reserved "@@" prefix. Routes with this prefix are internal and cannot be modified through the public API.`)}function x(e,t){for(let n of e)b(n.name,t),n.children&&x(n.children,t)}function S(e,t,n){let r=new Map,i=(e,t)=>{for(let a of e){let e=r.get(t);if(e?.has(a.path))throw Error(`[router.${n}] Path "${a.path}" is already defined`);e?e.add(a.path):r.set(t,new Set([a.path])),a.children&&i(a.children,t?`${t}.${a.name}`:a.name)}};i(e,t)}function C(e,t,n){if(x(t,`addRoute`),n!==void 0&&!e.matcher.hasRoute(n))throw Error(`[router.addRoute] Parent route "${n}" does not exist`);v(t,n??``,t=>{if(e.matcher.hasRoute(t))throw Error(`[router.addRoute] Route "${t}" already exists`)}),y(t,n??``,`addRoute`),S(t,n??``,`addRoute`)}function w({definitions:e,routesForHandlers:t,config:n,routeCustomFields:r,handlerParentName:i,rootPath:a,matcherOptions:s,logger:c}){let l=new Map,u=new Map;h(t,n,r,l,u,c,i);let f=d(n),{tree:p,matcher:m}=o(e,a,s);return{config:n,routeCustomFields:r,pendingCanActivate:l,pendingCanDeactivate:u,tree:p,matcher:m,resolvedForwardMap:f}}function T(e,t,n,r){return w({definitions:_(e.definitions,t.map(e=>i.sanitizeRoute(e)),n===void 0?[]:n.split(`.`)),routesForHandlers:t,config:g(e.config),routeCustomFields:Object.assign(Object.create(null),e.routeCustomFields),handlerParentName:n??``,rootPath:e.rootPath,matcherOptions:e.matcherOptions,logger:r})}function E(e,t,n,r){return w({definitions:e.map(e=>i.sanitizeRoute(e)),routesForHandlers:e,config:i.createEmptyConfig(),routeCustomFields:Object.create(null),handlerParentName:``,rootPath:t,matcherOptions:n,logger:r})}function D(e,t,n){let r=[];for(let[i,a]of e)r.push([i,a,t(a,n)]);return r}function O(e,t){return{activate:D(e.pendingCanActivate,t.compileGuard,`canActivate`),deactivate:D(e.pendingCanDeactivate,t.compileGuard,`canDeactivate`)}}function k(e,t,n){let r=e.depsStore,{activate:i,deactivate:a}=n??O(t,r);Object.assign(e.config,t.config),e.routeCustomFields=t.routeCustomFields,e.tree=t.tree,e.matcher=t.matcher,e.urlParamsCache.clear(),e.resolvedForwardMap=t.resolvedForwardMap;for(let[e,t,n]of i)r.addActivateGuard(e,t,n);for(let[e,t,n]of a)r.addDeactivateGuard(e,t,n)}function A(e,t,n,r){let{forwardTo:i,defaultParams:a,decodeParams:o,encodeParams:s,canActivate:c,canDeactivate:l}=r,u=i===void 0?void 0:j(n,i,e.config),d=M(e,n,r),f=c==null?void 0:t.compileGuardFactory(c,`canActivate`),p=l==null?void 0:t.compileGuardFactory(l,`canDeactivate`);return t.preflightHandlerLimit(f===void 0?[]:[n],p===void 0?[]:[n],!1),d!==void 0&&(Object.keys(d).length>0?e.routeCustomFields[n]=d:delete e.routeCustomFields[n]),u!==void 0&&(e.config.forwardMap=u.forwardMap,e.config.forwardFnMap=u.forwardFnMap,e.resolvedForwardMap=u.resolved),N(e,n,{defaultParams:a,decodeParams:o,encodeParams:s}),P(t,`activate`,n,c,f),P(t,`deactivate`,n,l,p),{forwardTo:i,defaultParams:a,decodeParams:o,encodeParams:s}}function j(e,t,n){f(t,e);let r=Object.assign(Object.create(null),n.forwardMap),i=Object.assign(Object.create(null),n.forwardFnMap);return t===null?(delete r[e],delete i[e]):typeof t==`string`?(delete i[e],r[e]=t):(delete r[e],i[e]=t),{forwardMap:r,forwardFnMap:i,resolved:d({...n,forwardMap:r})}}function M(e,t,n){let i;for(let a of Object.keys(n)){if(r.STANDARD_ROUTE_KEYS.has(a))continue;let o=n[a];o!==void 0&&(i??={...e.routeCustomFields[t]},o===null?delete i[a]:i[a]=o)}return i}function N(e,t,n){if(n.defaultParams!==void 0&&(n.defaultParams===null?delete e.config.defaultParams[t]:e.config.defaultParams[t]=n.defaultParams),n.decodeParams!==void 0)if(n.decodeParams===null)delete e.config.decoders[t];else{let r=n.decodeParams;e.config.decoders[t]=e=>r(e)??e}if(n.encodeParams!==void 0)if(n.encodeParams===null)delete e.config.encoders[t];else{let r=n.encodeParams;e.config.encoders[t]=e=>r(e)??e}}function P(e,t,n,r,i){r!==void 0&&(t===`activate`?r===null?e.clearCanActivate(n,`definition`):e.addCanActivate(n,r,!0,i):r===null?e.clearCanDeactivate(n,`definition`):e.addCanDeactivate(n,r,!0,i))}function F(e,n,r){x(e,`addRoute`),y(e,``,`addRoute`);let i=E(e,``,n,r),a={get definitions(){return t.routeTreeToDefinitions(a.tree)},config:i.config,tree:i.tree,matcher:i.matcher,urlParamsCache:new Map,resolvedForwardMap:i.resolvedForwardMap,routeCustomFields:i.routeCustomFields,rootPath:``,matcherOptions:n,depsStore:void 0,lifecycleNamespace:void 0,pendingCanActivate:i.pendingCanActivate,pendingCanDeactivate:i.pendingCanDeactivate};return a}exports.adoptRouteArtifacts=k,exports.assertAddable=C,exports.assertForwardToNotAsync=f,exports.assertNoDuplicateNamesInBatch=y,exports.assertNoDuplicatePathsInBatch=S,exports.assertNoInternalNamesInBatch=x,exports.assertNoInternalRouteName=b,exports.buildAddArtifacts=T,exports.buildReplaceArtifacts=E,exports.clearRouteData=u,exports.commitRouteUpdate=A,exports.commitTreeChanges=c,exports.compileArtifactGuards=O,exports.createRoutesStore=F,exports.rebuildTreeInPlace=s,exports.refreshForwardMap=d,exports.resetStore=l;
|
|
2
|
+
//# sourceMappingURL=routesStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routesStore.js","names":["createRouteTree","createMatcher","createEmptyConfig","resolveForwardChain","STANDARD_ROUTE_KEYS","sanitizeRoute","routeTreeToDefinitions"],"sources":["../../../../src/namespaces/RoutesNamespace/routesStore.ts"],"sourcesContent":["// packages/core/src/namespaces/RoutesNamespace/routesStore.ts\n\nimport { DEFAULT_ROUTE_NAME, STANDARD_ROUTE_KEYS } from \"./constants\";\nimport { resolveForwardChain } from \"./forwardChain\";\nimport {\n assignConfigEntries,\n createEmptyConfig,\n sanitizeRoute,\n} from \"./helpers\";\nimport {\n createMatcher,\n createRouteTree,\n routeTreeToDefinitions,\n} from \"../../engine\";\n\nimport type { RouteConfig, RoutesDependencies } from \"./types\";\nimport type {\n CreateMatcherOptions,\n Matcher,\n RouteDefinition,\n RouteTree,\n} from \"../../engine\";\nimport type {\n DefaultDependencies,\n ForwardToCallback,\n GuardFn,\n Params,\n RouteConfigUpdate,\n RouterLogger,\n GuardFnFactory,\n Route,\n} from \"../../types\";\nimport type { RouteLifecycleNamespace } from \"../RouteLifecycleNamespace\";\n\n// =============================================================================\n// Interfaces\n// =============================================================================\n\nexport interface RoutesStore<\n Dependencies extends DefaultDependencies = DefaultDependencies,\n> {\n /**\n * DERIVED VIEW, not stored state: reconstructed from `tree` on every access\n * via `routeTreeToDefinitions` (the lossless inverse cloneRouter already\n * relies on — the `~` absolute marker is restored, child order is the\n * definition order). The tree is the single source of truth, so a third\n * retained copy of the route table (~30 B/route) is not kept. Every reader\n * is a cold CRUD/plugin-registration path; the derive is O(N).\n *\n * The returned array is a FRESH snapshot each time — mutating it never\n * affects the store (pass an explicitly-mutated snapshot to\n * `commitTreeChanges` instead, as `remove` does).\n */\n readonly definitions: RouteDefinition[];\n readonly config: RouteConfig;\n tree: RouteTree;\n matcher: Matcher;\n /**\n * Per-route-name cache of URL (path) param names, derived from `matcher` and\n * read by `RoutesNamespace.getUrlParams` (powers `areStatesEqual` /\n * `isActiveRoute`). Cleared on every `matcher` rebuild so comparisons never\n * stay frozen to a route's pre-mutation param shape (#723).\n */\n readonly urlParamsCache: Map<string, string[]>;\n resolvedForwardMap: Record<string, string>;\n routeCustomFields: Record<string, Record<string, unknown>>;\n rootPath: string;\n readonly matcherOptions: CreateMatcherOptions | undefined;\n depsStore: RoutesDependencies<Dependencies> | undefined;\n lifecycleNamespace: RouteLifecycleNamespace<Dependencies> | undefined;\n readonly pendingCanActivate: Map<string, GuardFnFactory<Dependencies>>;\n readonly pendingCanDeactivate: Map<string, GuardFnFactory<Dependencies>>;\n}\n\n// =============================================================================\n// Tree operations\n// =============================================================================\n\nfunction rebuildTree(\n definitions: readonly RouteDefinition[],\n rootPath: string,\n matcherOptions: CreateMatcherOptions | undefined,\n): { tree: RouteTree; matcher: Matcher } {\n const tree = createRouteTree(DEFAULT_ROUTE_NAME, rootPath, definitions);\n const matcher = createMatcher(matcherOptions);\n\n matcher.registerTree(tree);\n\n return { tree, matcher };\n}\n\n/**\n * Rebuilds tree+matcher in place from `definitions` (defaults to the current\n * tree's own derived definitions — the same-table case, e.g. a rootPath\n * change).\n */\nexport function rebuildTreeInPlace<\n Dependencies extends DefaultDependencies = DefaultDependencies,\n>(\n store: RoutesStore<Dependencies>,\n definitions: readonly RouteDefinition[] = store.definitions,\n): void {\n const result = rebuildTree(definitions, store.rootPath, store.matcherOptions);\n\n store.tree = result.tree;\n store.matcher = result.matcher;\n store.urlParamsCache.clear();\n}\n\nexport function commitTreeChanges<\n Dependencies extends DefaultDependencies = DefaultDependencies,\n>(\n store: RoutesStore<Dependencies>,\n definitions: readonly RouteDefinition[],\n): void {\n rebuildTreeInPlace(store, definitions);\n store.resolvedForwardMap = refreshForwardMap(store.config);\n}\n\n// =============================================================================\n// Store reset\n// =============================================================================\n\n/**\n * Clears all routes and resets config.\n * Does NOT clear lifecycle handlers or state — caller handles that.\n */\nexport function resetStore<\n Dependencies extends DefaultDependencies = DefaultDependencies,\n>(store: RoutesStore<Dependencies>): void {\n clearRouteData(store);\n rebuildTreeInPlace(store, []);\n}\n\n/**\n * Clears route data without rebuilding the tree.\n * Used by replace() to avoid double rebuild (clearRouteData + commitTreeChanges).\n * `definitions` needs no clearing — it is derived from the tree, which the\n * caller rebuilds (resetStore → empty, replace → the new artifacts).\n */\nexport function clearRouteData<\n Dependencies extends DefaultDependencies = DefaultDependencies,\n>(store: RoutesStore<Dependencies>): void {\n Object.assign(store.config, createEmptyConfig());\n\n store.resolvedForwardMap = Object.create(null) as Record<string, string>;\n store.routeCustomFields = Object.create(null) as Record<\n string,\n Record<string, unknown>\n >;\n}\n\n// =============================================================================\n// Forward map\n// =============================================================================\n\nexport function refreshForwardMap(config: RouteConfig): Record<string, string> {\n const map = Object.create(null) as Record<string, string>;\n\n for (const fromRoute of Object.keys(config.forwardMap)) {\n map[fromRoute] = resolveForwardChain(fromRoute, config.forwardMap);\n }\n\n return map;\n}\n\n// =============================================================================\n// Route handler registration\n// =============================================================================\n\n/**\n * Throws if `forwardTo` is an async function (native or transpiled). Async\n * forwardTo callbacks break the synchronous matchPath/buildPath contract.\n * Runs inside `registerForwardTo` (the add/replace build path, before any store\n * mutation) AND inside `getRoutesApi`'s `updateForwardTo` (the update path), so\n * `update(name, { forwardTo: async })` is rejected at registration with the same\n * actionable error instead of deferring a generic TypeError to navigation (#967).\n */\nexport function assertForwardToNotAsync(\n forwardTo: unknown,\n fullName: string,\n): void {\n if (typeof forwardTo !== \"function\") {\n return;\n }\n\n const isNativeAsync =\n (forwardTo as { constructor: { name: string } }).constructor.name ===\n \"AsyncFunction\";\n const isTranspiledAsync = (forwardTo as { toString: () => string })\n .toString()\n .includes(\"__awaiter\");\n\n if (isNativeAsync || isTranspiledAsync) {\n throw new TypeError(\n `forwardTo callback cannot be async for route \"${fullName}\". ` +\n `Async functions break matchPath/buildPath.`,\n );\n }\n}\n\nfunction registerForwardTo<Dependencies extends DefaultDependencies>(\n route: Route<Dependencies>,\n fullName: string,\n config: RouteConfig,\n logger: RouterLogger,\n): void {\n if (route.canActivate) {\n /* v8 ignore next -- @preserve: edge case, both string and function tested separately */\n const forwardTarget =\n typeof route.forwardTo === \"string\" ? route.forwardTo : \"[dynamic]\";\n\n logger.warn(\n \"real-router\",\n `Route \"${fullName}\" has both forwardTo and canActivate. ` +\n `canActivate will be ignored because forwardTo creates a redirect (industry standard). ` +\n `Move canActivate to the target route \"${forwardTarget}\".`,\n );\n }\n\n if (route.canDeactivate) {\n /* v8 ignore next -- @preserve: edge case, both string and function tested separately */\n const forwardTarget =\n typeof route.forwardTo === \"string\" ? route.forwardTo : \"[dynamic]\";\n\n logger.warn(\n \"real-router\",\n `Route \"${fullName}\" has both forwardTo and canDeactivate. ` +\n `canDeactivate will be ignored because forwardTo creates a redirect (industry standard). ` +\n `Move canDeactivate to the target route \"${forwardTarget}\".`,\n );\n }\n\n assertForwardToNotAsync(route.forwardTo, fullName);\n\n // forwardTo is guaranteed to exist at this point\n if (typeof route.forwardTo === \"string\") {\n config.forwardMap[fullName] = route.forwardTo;\n } else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n config.forwardFnMap[fullName] = route.forwardTo!;\n }\n}\n\nfunction registerSingleRouteHandlers<Dependencies extends DefaultDependencies>(\n route: Route<Dependencies>,\n fullName: string,\n config: RouteConfig,\n routeCustomFields: Record<string, Record<string, unknown>>,\n pendingCanActivate: Map<string, GuardFnFactory<Dependencies>>,\n pendingCanDeactivate: Map<string, GuardFnFactory<Dependencies>>,\n logger: RouterLogger,\n): void {\n const customFields = Object.fromEntries(\n Object.entries(route).filter(([key]) => !STANDARD_ROUTE_KEYS.has(key)),\n );\n\n if (Object.keys(customFields).length > 0) {\n routeCustomFields[fullName] = customFields;\n }\n\n // Guards are collected here and registered into the lifecycle later — by\n // `adoptRouteArtifacts` (add/replace) or `RoutesNamespace.flushPendingGuards`\n // (initial routes, the final step of the Router constructor — #1331) — so\n // the build stays a pure, side-effect-free preparation step.\n if (route.canActivate) {\n pendingCanActivate.set(fullName, route.canActivate);\n }\n\n if (route.canDeactivate) {\n pendingCanDeactivate.set(fullName, route.canDeactivate);\n }\n\n if (route.forwardTo) {\n registerForwardTo(route, fullName, config, logger);\n }\n\n if (route.decodeParams) {\n config.decoders[fullName] = (params: Params): Params =>\n route.decodeParams?.(params) ?? params;\n }\n\n if (route.encodeParams) {\n config.encoders[fullName] = (params: Params): Params =>\n route.encodeParams?.(params) ?? params;\n }\n\n if (route.defaultParams) {\n config.defaultParams[fullName] = route.defaultParams;\n }\n}\n\nfunction registerAllRouteHandlers<Dependencies extends DefaultDependencies>(\n routes: readonly Route<Dependencies>[],\n config: RouteConfig,\n routeCustomFields: Record<string, Record<string, unknown>>,\n pendingCanActivate: Map<string, GuardFnFactory<Dependencies>>,\n pendingCanDeactivate: Map<string, GuardFnFactory<Dependencies>>,\n logger: RouterLogger,\n parentName = \"\",\n): void {\n for (const route of routes) {\n const fullName = parentName ? `${parentName}.${route.name}` : route.name;\n\n registerSingleRouteHandlers(\n route,\n fullName,\n config,\n routeCustomFields,\n pendingCanActivate,\n pendingCanDeactivate,\n logger,\n );\n\n if (route.children) {\n registerAllRouteHandlers(\n route.children,\n config,\n routeCustomFields,\n pendingCanActivate,\n pendingCanDeactivate,\n logger,\n fullName,\n );\n }\n }\n}\n\n// =============================================================================\n// Prepare-then-commit (issue #698)\n//\n// add()/replace() build the complete new store state into LOCAL structures, and\n// only swap it into the store once every core-level error has surfaced from the\n// build itself (async/circular forwardTo throw in registerAllRouteHandlers /\n// refreshForwardMap; invalid path constraint throws in rebuildTree). The store\n// is mutated only by `adoptRouteArtifacts`, which compiles every prepared guard\n// factory BEFORE the swap (#956): a factory that throws on compile (or returns a\n// non-function) aborts there, with the store still untouched. So all error\n// classes — core-level build errors AND malformed guard factories — surface\n// before any mutation, leaving the existing routes intact (full atomicity). The\n// silent-corruption cases route-tree never throws on (duplicate name vs an\n// existing route, a name duplicated within the batch, missing parent) are caught\n// up front by `assertAddable`.\n// =============================================================================\n\n/**\n * The fully-built, ready-to-swap result of preparing a route mutation. Holds\n * everything `adoptRouteArtifacts` assigns into the store.\n */\ninterface RouteArtifacts<\n Dependencies extends DefaultDependencies = DefaultDependencies,\n> {\n readonly config: RouteConfig;\n readonly routeCustomFields: Record<string, Record<string, unknown>>;\n readonly pendingCanActivate: Map<string, GuardFnFactory<Dependencies>>;\n readonly pendingCanDeactivate: Map<string, GuardFnFactory<Dependencies>>;\n readonly tree: RouteTree;\n readonly matcher: Matcher;\n readonly resolvedForwardMap: Record<string, string>;\n}\n\n/** Null-proto shallow clone of a RouteConfig (preserves every sub-map's contents). */\nfunction cloneConfig(config: RouteConfig): RouteConfig {\n const clone = createEmptyConfig();\n\n assignConfigEntries(clone, config);\n\n return clone;\n}\n\n/**\n * Returns a new definitions array with `added` inserted, without mutating the\n * input. For a top-level add the existing definitions are shallow-copied and\n * `added` appended. For a parented add the spine down to the parent is cloned\n * (siblings/other branches are shared by reference) and `added` appended to the\n * parent's children. Caller guarantees the parent path exists (see assertAddable).\n */\nfunction insertAddedDefinitions(\n definitions: readonly RouteDefinition[],\n added: RouteDefinition[],\n parentSegments: readonly string[],\n): RouteDefinition[] {\n if (parentSegments.length === 0) {\n return [...definitions, ...added];\n }\n\n const [head, ...rest] = parentSegments;\n\n return definitions.map((def) => {\n if (def.name !== head) {\n return def;\n }\n\n const children = def.children ?? [];\n\n return {\n ...def,\n children:\n rest.length === 0\n ? [...children, ...added]\n : insertAddedDefinitions(children, added, rest),\n };\n });\n}\n\n/** Depth-first walk yielding each route's full dotted name (no side effects). */\nfunction walkRouteNames<Dependencies extends DefaultDependencies>(\n routes: readonly Route<Dependencies>[],\n parentName: string,\n onName: (fullName: string) => void,\n): void {\n for (const route of routes) {\n const fullName = parentName ? `${parentName}.${route.name}` : route.name;\n\n onName(fullName);\n\n if (route.children) {\n walkRouteNames(route.children, fullName, onName);\n }\n }\n}\n\n/**\n * Rejects a route name duplicated WITHIN a single batch — the silent-overwrite\n * case route-tree stays last-wins on (#953 for `add`, #968 for `replace`). Walks\n * the same depth-first dotted names, but tracks them in a local Set: a name seen\n * twice in one array means the caller's second route would silently shadow the\n * first (`matchPath` for the first route's path becomes unreachable). Mirrors\n * validation-plugin's batch-dup message (route-tree `checkBatchNameDuplicate`)\n * so the no-plugin error matches the with-plugin one. `methodName` is \"addRoute\"\n * for both add and replace — the plugin reports \"addRoute\" for replace batches\n * too, so this keeps with/without-plugin parity.\n */\nexport function assertNoDuplicateNamesInBatch<\n Dependencies extends DefaultDependencies,\n>(\n routes: readonly Route<Dependencies>[],\n parentName: string,\n methodName: string,\n): void {\n const seen = new Set<string>();\n\n walkRouteNames(routes, parentName, (fullName) => {\n if (seen.has(fullName)) {\n throw new Error(\n `[router.${methodName}] Duplicate route \"${fullName}\" in batch`,\n );\n }\n\n seen.add(fullName);\n });\n}\n\nconst INTERNAL_ROUTE_PREFIX = \"@@\";\n\n/**\n * Rejects a single (bare) route name that uses the reserved \"@@\" prefix —\n * internal / system names such as UNKNOWN_ROUTE (`\"@@router/UNKNOWN_ROUTE\"`).\n * Mutating such a name would let a real URL `matchPath` to a state with\n * `name === UNKNOWN_ROUTE`, silently conflating a genuine route with \"not\n * found\". This always-on guard protected all four mutators (#238) until the\n * validation-extraction (`d1ebff80`) demoted it to the opt-in\n * validation-plugin; only `add` was restored (#954), so `remove`/`update`\n * regained it via this helper (#1047). Mirrors validation-plugin's\n * `throwIfInternalRoute` message so the no-plugin error matches the with-plugin\n * one.\n */\nexport function assertNoInternalRouteName(\n name: string,\n methodName: string,\n): void {\n if (name.startsWith(INTERNAL_ROUTE_PREFIX)) {\n throw new Error(\n `[router.${methodName}] Route name \"${name}\" uses the reserved \"${INTERNAL_ROUTE_PREFIX}\" prefix. Routes with this prefix are internal and cannot be modified through the public API.`,\n );\n }\n}\n\n/**\n * Batch counterpart to {@link assertNoInternalRouteName}: rejects any route in\n * the batch (recursing children) whose BARE leaf name uses the reserved \"@@\"\n * prefix (the prefix is on the leaf, not the dotted fullName). Used by `add`\n * (#954) and `replace` (#1047).\n */\nexport function assertNoInternalNamesInBatch<\n Dependencies extends DefaultDependencies,\n>(routes: readonly Route<Dependencies>[], methodName: string): void {\n for (const route of routes) {\n assertNoInternalRouteName(route.name, methodName);\n\n if (route.children) {\n assertNoInternalNamesInBatch(route.children, methodName);\n }\n }\n}\n\n/**\n * Rejects two routes that share the same `path` at the same parent level WITHIN\n * a single `add` batch (#955). The matcher resolves a path collision last-wins,\n * so the earlier route stays addressable by name (`has` / `buildPath`) but is\n * unreachable by URL (`matchPath` returns the later route) — a silent shadow.\n * Paths only collide among siblings, so seen paths are tracked per parent\n * fullName. Mirrors validation-plugin's message (route-tree\n * `checkBatchPathDuplicate`) so the no-plugin error matches the with-plugin one.\n * Scoped to the batch (not the existing tree) per #955 — the in-batch case the\n * issue describes.\n */\nexport function assertNoDuplicatePathsInBatch<\n Dependencies extends DefaultDependencies,\n>(\n routes: readonly Route<Dependencies>[],\n parentName: string,\n methodName: string,\n): void {\n const seenByParent = new Map<string, Set<string>>();\n\n const walk = (\n siblings: readonly Route<Dependencies>[],\n parent: string,\n ): void => {\n for (const route of siblings) {\n const paths = seenByParent.get(parent);\n\n if (paths?.has(route.path)) {\n throw new Error(\n `[router.${methodName}] Path \"${route.path}\" is already defined`,\n );\n }\n\n if (paths) {\n paths.add(route.path);\n } else {\n seenByParent.set(parent, new Set([route.path]));\n }\n\n if (route.children) {\n walk(route.children, parent ? `${parent}.${route.name}` : route.name);\n }\n }\n };\n\n walk(routes, parentName);\n}\n\n/**\n * Up-front guard for `add` against the corruptions route-tree stays silent on: a\n * missing `parent`, a name that collides with an EXISTING route, a name\n * duplicated WITHIN the batch, a reserved \"@@\"-prefixed name (which would shadow\n * an internal/system route name), and a path duplicated among siblings WITHIN\n * the batch (any of which would otherwise be silently overwritten/shadowed).\n * Throws before any build.\n */\nexport function assertAddable<Dependencies extends DefaultDependencies>(\n store: RoutesStore<Dependencies>,\n routes: readonly Route<Dependencies>[],\n parentName: string | undefined,\n): void {\n assertNoInternalNamesInBatch(routes, \"addRoute\");\n\n if (parentName !== undefined && !store.matcher.hasRoute(parentName)) {\n throw new Error(\n `[router.addRoute] Parent route \"${parentName}\" does not exist`,\n );\n }\n\n walkRouteNames(routes, parentName ?? \"\", (fullName) => {\n if (store.matcher.hasRoute(fullName)) {\n throw new Error(`[router.addRoute] Route \"${fullName}\" already exists`);\n }\n });\n\n assertNoDuplicateNamesInBatch(routes, parentName ?? \"\", \"addRoute\");\n assertNoDuplicatePathsInBatch(routes, parentName ?? \"\", \"addRoute\");\n}\n\n/**\n * Builds RouteArtifacts from a final definitions array and the routes whose\n * handlers (config + guards) populate `config`/`routeCustomFields`. Guards are\n * collected into the returned pending maps (depsStore is intentionally omitted\n * so nothing compiles or touches the lifecycle here). THROWS on async/circular\n * forwardTo and invalid path constraint — before the caller mutates the store.\n *\n * Takes a single args object: the positional list hit 8 parameters (S107) when\n * the per-router `logger` (#724) joined it, and named fields read better at the\n * two call sites anyway.\n */\nfunction buildArtifacts<Dependencies extends DefaultDependencies>({\n definitions,\n routesForHandlers,\n config,\n routeCustomFields,\n handlerParentName,\n rootPath,\n matcherOptions,\n logger,\n}: {\n definitions: readonly RouteDefinition[];\n routesForHandlers: readonly Route<Dependencies>[];\n config: RouteConfig;\n routeCustomFields: Record<string, Record<string, unknown>>;\n handlerParentName: string;\n rootPath: string;\n matcherOptions: CreateMatcherOptions | undefined;\n logger: RouterLogger;\n}): RouteArtifacts<Dependencies> {\n const pendingCanActivate = new Map<string, GuardFnFactory<Dependencies>>();\n const pendingCanDeactivate = new Map<string, GuardFnFactory<Dependencies>>();\n\n registerAllRouteHandlers(\n routesForHandlers,\n config,\n routeCustomFields,\n pendingCanActivate,\n pendingCanDeactivate,\n logger,\n handlerParentName,\n );\n\n const resolvedForwardMap = refreshForwardMap(config);\n const { tree, matcher } = rebuildTree(definitions, rootPath, matcherOptions);\n\n return {\n config,\n routeCustomFields,\n pendingCanActivate,\n pendingCanDeactivate,\n tree,\n matcher,\n resolvedForwardMap,\n };\n}\n\n/** Builds the merged artifacts for an incremental `add` (existing ∪ new). */\nexport function buildAddArtifacts<Dependencies extends DefaultDependencies>(\n store: RoutesStore<Dependencies>,\n routes: readonly Route<Dependencies>[],\n parentName: string | undefined,\n logger: RouterLogger,\n): RouteArtifacts<Dependencies> {\n const definitions = insertAddedDefinitions(\n store.definitions,\n routes.map((route) => sanitizeRoute(route)),\n parentName === undefined ? [] : parentName.split(\".\"),\n );\n\n return buildArtifacts({\n definitions,\n routesForHandlers: routes,\n config: cloneConfig(store.config),\n routeCustomFields: Object.assign(\n Object.create(null) as Record<string, Record<string, unknown>>,\n store.routeCustomFields,\n ),\n handlerParentName: parentName ?? \"\",\n rootPath: store.rootPath,\n matcherOptions: store.matcherOptions,\n logger,\n });\n}\n\n/** Builds the fresh artifacts for a full `replace` (standalone new set). */\nexport function buildReplaceArtifacts<Dependencies extends DefaultDependencies>(\n routes: readonly Route<Dependencies>[],\n rootPath: string,\n matcherOptions: CreateMatcherOptions | undefined,\n logger: RouterLogger,\n): RouteArtifacts<Dependencies> {\n return buildArtifacts({\n definitions: routes.map((route) => sanitizeRoute(route)),\n routesForHandlers: routes,\n config: createEmptyConfig(),\n routeCustomFields: Object.create(null) as Record<\n string,\n Record<string, unknown>\n >,\n handlerParentName: \"\",\n rootPath,\n matcherOptions,\n logger,\n });\n}\n\n/**\n * Compiles every pending guard factory up front, returning\n * `[name, factory, compiledFn]` triples for installation. THROWS from `compile`\n * on the first factory that throws on compile or returns a non-function — the\n * pre-swap validation that makes `adoptRouteArtifacts` atomic for malformed\n * guards (#956). Compiling here (not at install) means a factory with\n * compile-time side effects runs exactly once.\n */\nfunction compilePendingGuards<Dependencies extends DefaultDependencies>(\n pending: Map<string, GuardFnFactory<Dependencies>>,\n compile: (\n handler: GuardFnFactory<Dependencies>,\n methodName: string,\n ) => GuardFn,\n methodName: string,\n): [string, GuardFnFactory<Dependencies>, GuardFn][] {\n const compiled: [string, GuardFnFactory<Dependencies>, GuardFn][] = [];\n\n for (const [name, factory] of pending) {\n compiled.push([name, factory, compile(factory, methodName)]);\n }\n\n return compiled;\n}\n\n/** Pre-compiled guard triples for {@link adoptRouteArtifacts} install. */\nexport interface CompiledArtifactGuards<\n Dependencies extends DefaultDependencies,\n> {\n activate: [string, GuardFnFactory<Dependencies>, GuardFn][];\n deactivate: [string, GuardFnFactory<Dependencies>, GuardFn][];\n}\n\n/**\n * Compiles an artifacts' pending guard factories up front (#956), THROWING on\n * the first factory that throws on compile or returns a non-function.\n *\n * `replaceRoutes` calls this in its PREPARE phase — **before**\n * `clearDefinitionGuards()` — and hands the result to `adoptRouteArtifacts`, so\n * a compile-throw aborts with BOTH the tree AND the old definition guards intact\n * (#1193, mirroring #1046's handler-limit hoist). `add` has no clear step, so\n * `adoptRouteArtifacts` compiles inline for it.\n */\nexport function compileArtifactGuards<Dependencies extends DefaultDependencies>(\n artifacts: RouteArtifacts<Dependencies>,\n deps: RoutesDependencies<Dependencies>,\n): CompiledArtifactGuards<Dependencies> {\n return {\n activate: compilePendingGuards(\n artifacts.pendingCanActivate,\n deps.compileGuard,\n \"canActivate\",\n ),\n deactivate: compilePendingGuards(\n artifacts.pendingCanDeactivate,\n deps.compileGuard,\n \"canDeactivate\",\n ),\n };\n}\n\n/**\n * Commits prepared artifacts into the store in place. Every pending guard\n * factory is compiled BEFORE the tree/config swap (#956): a factory that throws\n * on compile (or returns a non-function) aborts here with the store untouched,\n * so `add`/`replace` are atomic for malformed guards too — not just core build\n * errors. The tree/config assignments are pure and cannot throw; the\n * pre-compiled guards are then installed without re-compiling (the factory ran\n * once, at the pre-compile above). `depsStore` is always set on a wired router,\n * which is the only path that reaches `add`/`replace`.\n */\nexport function adoptRouteArtifacts<Dependencies extends DefaultDependencies>(\n store: RoutesStore<Dependencies>,\n artifacts: RouteArtifacts<Dependencies>,\n precompiled?: CompiledArtifactGuards<Dependencies>,\n): void {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- depsStore is set once the router is wired; add/replace only run on a wired router (constructor-time registration uses createRoutesStore)\n const deps = store.depsStore!;\n\n // Pre-swap compile: surfaces a malformed guard factory before any mutation.\n // `replace()` pre-compiles in its PREPARE phase (BEFORE clearDefinitionGuards)\n // and passes the result here, so a compile-throw never erases the old\n // definition guards (#1193); `add` has no clear step and compiles inline.\n const { activate: compiledActivate, deactivate: compiledDeactivate } =\n precompiled ?? compileArtifactGuards(artifacts, deps);\n\n // Atomic swap — pure assignments, cannot throw. (`definitions` is derived\n // from `tree`, so swapping the tree IS the definitions swap.)\n Object.assign(store.config, artifacts.config);\n store.routeCustomFields = artifacts.routeCustomFields;\n store.tree = artifacts.tree;\n store.matcher = artifacts.matcher;\n store.urlParamsCache.clear();\n store.resolvedForwardMap = artifacts.resolvedForwardMap;\n\n // Install pre-compiled guards — no re-compile, no throw.\n for (const [name, factory, fn] of compiledActivate) {\n deps.addActivateGuard(name, factory, fn);\n }\n\n for (const [name, factory, fn] of compiledDeactivate) {\n deps.addDeactivateGuard(name, factory, fn);\n }\n}\n\n/**\n * COMMIT core for `update()` — the field-patch counterpart to\n * {@link adoptRouteArtifacts} (add/replace) / {@link commitTreeChanges} (remove)\n * / {@link resetStore} (clear), co-located here so all four route-CRUD commit\n * cores live in one file. Stays **NO_TREE_REBUILD**: an O(1) per-field patch\n * that never rebuilds the tree/matcher (so it must NOT funnel through\n * `adoptRouteArtifacts`).\n *\n * Prepare-then-commit (#951): every throwing step runs in PREPARE, before any\n * store write, so a rejected update leaves the route's prior config fully intact\n * — an async/cyclic `forwardTo` (#967), a guard factory that throws on compile\n * (#956 seam), a throwing custom-field getter, and the #961 handler-limit\n * pre-flight (#1046). Returns the structural fields for the caller's conditional\n * TREE_CHANGED emit, computed from the single destructure here so core invokes\n * each user getter once (#797 / #952 `null`-clears-definition-only preserved).\n */\nexport function commitRouteUpdate<Dependencies extends DefaultDependencies>(\n store: RoutesStore<Dependencies>,\n lifecycle: RouteLifecycleNamespace<Dependencies>,\n name: string,\n updates: RouteConfigUpdate<Dependencies>,\n): {\n forwardTo?: string | ForwardToCallback<Dependencies> | null | undefined;\n defaultParams?: Params | null | undefined;\n decodeParams?: ((params: Params) => Params) | null | undefined;\n encodeParams?: ((params: Params) => Params) | null | undefined;\n} {\n const {\n forwardTo,\n defaultParams,\n decodeParams,\n encodeParams,\n canActivate,\n canDeactivate,\n } = updates;\n\n // ===== PREPARE — compute every change into LOCALS. Any throw here aborts\n // before a single store write, so the whole field set is applied\n // all-or-nothing (#951).\n const forwardToPlan =\n forwardTo === undefined\n ? undefined\n : prepareForwardTo(name, forwardTo, store.config);\n\n const nextCustomFields = prepareCustomFields(store, name, updates);\n\n // Guard factories are compiled NOW (a throwing factory surfaces in PREPARE);\n // the precompiled function is installed in COMMIT without re-invoking the\n // factory, so a factory side effect runs exactly once (reuses the #956\n // compile-then-install seam). Compiled after the other prepares so a throw\n // upstream skips invoking the factory at all.\n const activateFn =\n canActivate === undefined || canActivate === null\n ? undefined\n : lifecycle.compileGuardFactory(canActivate, \"canActivate\");\n const deactivateFn =\n canDeactivate === undefined || canDeactivate === null\n ? undefined\n : lifecycle.compileGuardFactory(canDeactivate, \"canDeactivate\");\n\n // Pre-flight the #961 handler-limit before the COMMIT writes, so an at-limit\n // update that adds a NEW guard slot aborts before forwardTo / scalar config\n // land (#1046, #951). A slot is new only when `name` does not already hold a\n // guard of that type — an overwrite does not count.\n lifecycle.preflightHandlerLimit(\n activateFn === undefined ? [] : [name],\n deactivateFn === undefined ? [] : [name],\n false,\n );\n\n // ===== COMMIT — pure writes from here; nothing below throws.\n // Custom (plugin-defined) fields. Consumers read these lazily via\n // getRouteConfig (lifecycle hooks, preload, searchSchema), so no TREE_CHANGED\n // is needed — the next read sees the new value; the caller's emit stays\n // structural-only by design (О-7).\n if (nextCustomFields !== undefined) {\n if (Object.keys(nextCustomFields).length > 0) {\n store.routeCustomFields[name] = nextCustomFields;\n } else {\n delete store.routeCustomFields[name];\n }\n }\n\n if (forwardToPlan !== undefined) {\n store.config.forwardMap = forwardToPlan.forwardMap;\n store.config.forwardFnMap = forwardToPlan.forwardFnMap;\n store.resolvedForwardMap = forwardToPlan.resolved;\n }\n\n commitScalarConfig(store, name, {\n defaultParams,\n decodeParams,\n encodeParams,\n });\n\n // Install the guards from their PREPARE-phase precompiled functions; a `null`\n // clears the definition-origin guard only (#952). See commitGuardUpdate.\n commitGuardUpdate(lifecycle, \"activate\", name, canActivate, activateFn);\n commitGuardUpdate(lifecycle, \"deactivate\", name, canDeactivate, deactivateFn);\n\n return { forwardTo, defaultParams, decodeParams, encodeParams };\n}\n\n/**\n * PREPARE step for a `forwardTo` update (#951 atomicity): computes the new\n * forward maps and the resolved forward chain into LOCALS and returns them\n * WITHOUT touching the store. A throw here — an async `forwardTo` (#967) or a\n * cycle surfaced by `refreshForwardMap` — aborts `update()` before any field is\n * committed. The caller writes the returned bundle into the store in its COMMIT\n * phase. (Mirrors the build-then-swap shape of #698, but the swap is deferred to\n * the caller so it can be sequenced with the other prepared fields.)\n */\nfunction prepareForwardTo<\n Dependencies extends DefaultDependencies = DefaultDependencies,\n>(\n name: string,\n forwardTo: string | ForwardToCallback<Dependencies> | null,\n config: RouteConfig,\n): {\n forwardMap: RouteConfig[\"forwardMap\"];\n forwardFnMap: RouteConfig[\"forwardFnMap\"];\n resolved: Record<string, string>;\n} {\n // #967: reject an async forwardTo at update time — parity with add/replace\n // (registerForwardTo runs the same check on the build path). A no-op for\n // string/null. Without this the async callback is stored silently and\n // surfaces later as a generic \"must return a string, got object\" TypeError\n // from #resolveDynamicForward at navigation. Runs first, before any clone.\n assertForwardToNotAsync(forwardTo, name);\n\n const forwardMap = Object.assign(\n Object.create(null) as RouteConfig[\"forwardMap\"],\n config.forwardMap,\n );\n const forwardFnMap = Object.assign(\n Object.create(null) as RouteConfig[\"forwardFnMap\"],\n config.forwardFnMap,\n );\n\n if (forwardTo === null) {\n delete forwardMap[name];\n delete forwardFnMap[name];\n } else if (typeof forwardTo === \"string\") {\n delete forwardFnMap[name];\n forwardMap[name] = forwardTo;\n } else {\n delete forwardMap[name];\n forwardFnMap[name] = forwardTo;\n }\n\n const resolved = refreshForwardMap({ ...config, forwardMap });\n\n return { forwardMap, forwardFnMap, resolved };\n}\n\n/**\n * PREPARE step for a route's plugin-defined **custom fields** (#951) — the\n * `update` counterpart to how `add`/`replace` register them\n * (`registerSingleRouteHandlers`). A custom field is any patch key not in\n * {@link STANDARD_ROUTE_KEYS}.\n *\n * Computes the merged record and RETURNS it for the caller to commit;\n * `undefined` means no custom-field key was present, so the caller leaves the\n * store untouched. Semantics mirror the scalar fields in\n * {@link commitScalarConfig}: shallow-merge by patch key, `null` removes a\n * single field, `undefined` is a no-op (leaves the field untouched). When the\n * merge empties the record, the caller drops the whole entry so `getRouteConfig`\n * returns `undefined` — symmetric with `add`, which only stores a record when at\n * least one custom field exists.\n *\n * Reading the custom-field getters HERE (in PREPARE, not at commit) is what lets\n * a throwing getter abort the whole update before any field is written. The\n * merged record is a **fresh object**, never mutated in place: `cloneRouter`\n * shares per-route custom-field records by reference (`Object.assign`), so\n * replacing the reference keeps a clone isolated from post-clone updates on the\n * source.\n */\nfunction prepareCustomFields<\n Dependencies extends DefaultDependencies = DefaultDependencies,\n>(\n store: RoutesStore<Dependencies>,\n name: string,\n updates: RouteConfigUpdate<Dependencies>,\n): Record<string, unknown> | undefined {\n let next: Record<string, unknown> | undefined;\n\n // `Object.keys` (not `Object.entries`): a value is read only AFTER the\n // standard-key guard, so structural-field getters — already read once by\n // `update`'s destructuring — are not re-invoked. `Object.entries` would read\n // every value eagerly, double-invoking a `defaultParams`/`forwardTo` getter\n // and breaking the \"user getter called once\" invariant.\n // eslint-disable-next-line unicorn/prefer-object-iterable-methods -- see above\n for (const key of Object.keys(updates)) {\n if (STANDARD_ROUTE_KEYS.has(key)) {\n continue;\n }\n\n const value = (updates as Record<string, unknown>)[key];\n\n // `undefined` mirrors the structural path: leave the field untouched.\n if (value === undefined) {\n continue;\n }\n\n // Clone-on-first-write — keeps clones (which alias this record) isolated.\n next ??= { ...store.routeCustomFields[name] };\n\n if (value === null) {\n delete next[key];\n } else {\n next[key] = value;\n }\n }\n\n return next;\n}\n\n/**\n * COMMIT step for the scalar config fields of an update (#951): writes\n * `defaultParams` / `decodeParams` / `encodeParams` in place. These assignments\n * are pure and never throw, so they run in the COMMIT phase after every throwing\n * field has been validated in PREPARE. `forwardTo` is handled separately — it\n * has its own throwing prepare step ({@link prepareForwardTo}).\n */\nfunction commitScalarConfig<\n Dependencies extends DefaultDependencies = DefaultDependencies,\n>(\n store: RoutesStore<Dependencies>,\n name: string,\n updates: {\n defaultParams?: Params | null | undefined;\n decodeParams?: ((params: Params) => Params) | null | undefined;\n encodeParams?: ((params: Params) => Params) | null | undefined;\n },\n): void {\n if (updates.defaultParams !== undefined) {\n if (updates.defaultParams === null) {\n delete store.config.defaultParams[name];\n } else {\n store.config.defaultParams[name] = updates.defaultParams;\n }\n }\n\n if (updates.decodeParams !== undefined) {\n if (updates.decodeParams === null) {\n delete store.config.decoders[name];\n } else {\n const decoder = updates.decodeParams;\n\n store.config.decoders[name] = (params: Params): Params =>\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- runtime fallback if user-provided decoder violates its return type\n decoder(params) ?? params;\n }\n }\n\n if (updates.encodeParams !== undefined) {\n if (updates.encodeParams === null) {\n delete store.config.encoders[name];\n } else {\n const encoder = updates.encodeParams;\n\n store.config.encoders[name] = (params: Params): Params =>\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- runtime fallback if user-provided encoder violates its return type\n encoder(params) ?? params;\n }\n }\n}\n\n/**\n * COMMIT step for one guard field of an update (#951). `undefined` is a no-op;\n * `null` clears the DEFINITION-origin guard only, preserving an external guard\n * (#952); a factory installs together with its PREPARE-phase `precompiledFn`\n * (no re-compile — #956 seam). Extracted from `update()` so its prepare/commit\n * orchestration stays within the cognitive-complexity budget.\n */\nfunction commitGuardUpdate<Dependencies extends DefaultDependencies>(\n lifecycle: RouteLifecycleNamespace<Dependencies>,\n kind: \"activate\" | \"deactivate\",\n name: string,\n value: GuardFnFactory<Dependencies> | null | undefined,\n precompiledFn: GuardFn | undefined,\n): void {\n if (value === undefined) {\n return;\n }\n\n if (kind === \"activate\") {\n if (value === null) {\n lifecycle.clearCanActivate(name, \"definition\");\n } else {\n lifecycle.addCanActivate(name, value, true, precompiledFn);\n }\n } else if (value === null) {\n lifecycle.clearCanDeactivate(name, \"definition\");\n } else {\n lifecycle.addCanDeactivate(name, value, true, precompiledFn);\n }\n}\n\n// =============================================================================\n// Factory\n// =============================================================================\n\nexport function createRoutesStore<\n Dependencies extends DefaultDependencies = DefaultDependencies,\n>(\n routes: Route<Dependencies>[],\n matcherOptions: CreateMatcherOptions | undefined,\n logger: RouterLogger,\n): RoutesStore<Dependencies> {\n // Initial routes are a standalone set at rootPath \"\" — same build the\n // prepare-then-commit `replace` path uses. Guards land in the pending maps,\n // flushed by `flushPendingGuards()` at the end of the Router constructor\n // (#1331); `setDependencies` itself is a pure assignment.\n //\n // Reject the silent-corruption cases BEFORE building, giving the constructor\n // parity with `add()` / `replace()` — the third and last route-population\n // entry point (#1351): within-batch duplicate names (#953/#968) and reserved\n // \"@@\" names (#954). Without these the constructor silently last-wins a\n // duplicate-name sibling (the first route is dropped → its deep-link 404s)\n // while add/replace throw. `methodName` is \"addRoute\" so all three entry\n // points surface the identical bare-core error. (Duplicate PATHS are already\n // rejected downstream by the path-matcher backstop #1153, so they are not\n // re-checked here.)\n assertNoInternalNamesInBatch(routes, \"addRoute\");\n assertNoDuplicateNamesInBatch(routes, \"\", \"addRoute\");\n\n const artifacts = buildReplaceArtifacts(routes, \"\", matcherOptions, logger);\n\n const store: RoutesStore<Dependencies> = {\n // Deferred access: the getter runs only after `store` is initialized.\n get definitions() {\n return routeTreeToDefinitions(store.tree);\n },\n config: artifacts.config,\n tree: artifacts.tree,\n matcher: artifacts.matcher,\n urlParamsCache: new Map(),\n resolvedForwardMap: artifacts.resolvedForwardMap,\n routeCustomFields: artifacts.routeCustomFields,\n rootPath: \"\",\n matcherOptions,\n depsStore: undefined,\n lifecycleNamespace: undefined,\n pendingCanActivate: artifacts.pendingCanActivate,\n pendingCanDeactivate: artifacts.pendingCanDeactivate,\n };\n\n return store;\n}\n"],"mappings":"0PA8EA,SAAS,EACP,EACA,EACA,EACuC,CACvC,IAAM,EAAOA,EAAAA,gBAAAA,GAAoC,EAAU,CAAW,EAChE,EAAUC,EAAAA,cAAc,CAAc,EAI5C,OAFA,EAAQ,aAAa,CAAI,EAElB,CAAE,OAAM,SAAQ,CACzB,CAOA,SAAgB,EAGd,EACA,EAA0C,EAAM,YAC1C,CACN,IAAM,EAAS,EAAY,EAAa,EAAM,SAAU,EAAM,cAAc,EAE5E,EAAM,KAA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C,EAEA,OAAO,CACT"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Params, SimpleState, State } from "../../types/base.js";
|
|
2
|
+
import { DefaultDependencies, ForwardToCallback, GuardFn, GuardFnFactory, RouterLogger } from "../../types/router.js";
|
|
3
|
+
//#region src/namespaces/RoutesNamespace/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Dependencies injected into RoutesNamespace.
|
|
6
|
+
*
|
|
7
|
+
* These are function references from the Router facade,
|
|
8
|
+
* avoiding the need to pass the entire Router object.
|
|
9
|
+
*/
|
|
10
|
+
interface RoutesDependencies<Dependencies extends DefaultDependencies = DefaultDependencies> {
|
|
11
|
+
/** Per-router logger instance (from `getInternals(router).logger`) */
|
|
12
|
+
logger: RouterLogger;
|
|
13
|
+
/**
|
|
14
|
+
* Register a canActivate handler for a route. `precompiledFn` installs an
|
|
15
|
+
* already-compiled `GuardFn` (from {@link compileGuard}) without re-invoking
|
|
16
|
+
* the factory — used by the #956 prepare-then-commit path so guards compile
|
|
17
|
+
* once, before the store swap.
|
|
18
|
+
*/
|
|
19
|
+
addActivateGuard: (name: string, handler: GuardFnFactory<Dependencies>, precompiledFn?: GuardFn) => void;
|
|
20
|
+
/** Register a canDeactivate handler for a route (see {@link addActivateGuard}). */
|
|
21
|
+
addDeactivateGuard: (name: string, handler: GuardFnFactory<Dependencies>, precompiledFn?: GuardFn) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Compile a guard factory to its `GuardFn` WITHOUT registering it — surfaces a
|
|
24
|
+
* throwing / non-function factory eagerly so the add/replace commit can
|
|
25
|
+
* validate every guard before swapping the store (#956).
|
|
26
|
+
*/
|
|
27
|
+
compileGuard: (handler: GuardFnFactory<Dependencies>, methodName: string) => GuardFn;
|
|
28
|
+
/** Create state object */
|
|
29
|
+
makeState: <P extends Params = Params>(name: string, params?: P, path?: string, meta?: Record<string, Record<string, "url" | "query">>) => State<P>;
|
|
30
|
+
/** Get current router state */
|
|
31
|
+
getState: () => State | undefined;
|
|
32
|
+
/** Compare two states for equality */
|
|
33
|
+
areStatesEqual: (state1: State | undefined, state2: State | undefined, ignoreQueryParams?: boolean) => boolean;
|
|
34
|
+
/** Get a dependency by name */
|
|
35
|
+
getDependency: <K extends keyof Dependencies>(name: K) => Dependencies[K];
|
|
36
|
+
/** Forward state through facade (allows plugin interception) */
|
|
37
|
+
forwardState: <P extends Params = Params>(name: string, params: P) => SimpleState<P>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Configuration storage for routes.
|
|
41
|
+
* Stores decoders, encoders, default params, and forward mappings.
|
|
42
|
+
*/
|
|
43
|
+
interface RouteConfig {
|
|
44
|
+
/** Custom param decoders per route */
|
|
45
|
+
decoders: Record<string, (params: Params) => Params>;
|
|
46
|
+
/** Custom param encoders per route */
|
|
47
|
+
encoders: Record<string, (params: Params) => Params>;
|
|
48
|
+
/** Default params per route */
|
|
49
|
+
defaultParams: Record<string, Params>;
|
|
50
|
+
/** Forward mappings (source -> target) */
|
|
51
|
+
forwardMap: Record<string, string>;
|
|
52
|
+
/** Dynamic forward callbacks (source -> callback) */
|
|
53
|
+
forwardFnMap: Record<string, ForwardToCallback<any>>;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { RouteConfig, RoutesDependencies };
|
|
57
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../../src/namespaces/RoutesNamespace/types.ts"],"mappings":";;;;;;;;;UAmBiB,mBACf,qBAAqB,sBAAsB;;EAG3C,QAAQ;;;;;;;EAQR,mBACE,cACA,SAAS,eAAe,eACxB,gBAAgB;;EAIlB,qBACE,cACA,SAAS,eAAe,eACxB,gBAAgB;;;;;;EAQlB,eACE,SAAS,eAAe,eACxB,uBACG;;EAGL,YAAY,UAAU,SAAS,QAC7B,cACA,SAAS,GACT,eACA,OAAO,eAAe,qCACnB,MAAM;;EAGX,gBAAgB;;EAGhB,iBACE,QAAQ,mBACR,QAAQ,mBACR;;EAIF,gBAAgB,gBAAgB,cAAc,MAAM,MAAM,aAAa;;EAGvE,eAAe,UAAU,SAAS,QAChC,cACA,QAAQ,MACL,YAAY;;;;;;UAOF;;EAEf,UAAU,gBAAgB,QAAQ,WAAW;;EAG7C,UAAU,gBAAgB,QAAQ,WAAW;;EAG7C,eAAe,eAAe;;EAG9B,YAAY;;EAIZ,cAAc,eAAe"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../constants.js"),t=require("../../helpers.js"),n=require("./helpers.js"),r=require("../../stateMetaStore.js");var i=class{#e=void 0;#t=void 0;#n;get(){return this.#e}set(e){this.#t=this.#e,this.#e=e?t.freezeStateInPlace(e):void 0}getPrevious(){return this.#t}reset(){this.#e=void 0,this.#t=void 0}setDependencies(e){this.#n=e}makeState(n,i,a,o,s){let c=this.#n.getDefaultParams(),l=Object.hasOwn(c,n),u;u=l?Object.freeze({...c[n],...i}):!i||i===e.EMPTY_PARAMS?e.EMPTY_PARAMS:Object.freeze({...i});let d={name:n,params:u,path:a??this.#n.buildPath(n,i),context:{},...!s&&{transition:e.DEFAULT_TRANSITION}};return o&&r.setStateMetaParams(d,o),s?d:t.freezeStateInPlace(d)}areStatesEqual(e,t,r=!0){if(!e||!t)return!!e==!!t;if(e.name!==t.name)return!1;if(r){let r=this.#n.getUrlParams(e.name);for(let i of r)if(!n.areParamValuesEqual(e.params[i],t.params[i]))return!1;return!0}let i=Object.keys(e.params),a=Object.keys(t.params);if(i.length!==a.length)return!1;for(let r of i)if(!(r in t.params)||!n.areParamValuesEqual(e.params[r],t.params[r]))return!1;return!0}};exports.StateNamespace=i;
|
|
2
|
+
//# sourceMappingURL=StateNamespace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateNamespace.js","names":["#frozenState","#previousState","freezeStateInPlace","#deps","EMPTY_PARAMS","DEFAULT_TRANSITION","areParamValuesEqual"],"sources":["../../../../src/namespaces/StateNamespace/StateNamespace.ts"],"sourcesContent":["// packages/core/src/namespaces/StateNamespace/StateNamespace.ts\n\nimport { areParamValuesEqual } from \"./helpers\";\nimport { DEFAULT_TRANSITION, EMPTY_PARAMS } from \"../../constants\";\nimport { freezeStateInPlace } from \"../../helpers\";\nimport { setStateMetaParams } from \"../../stateMetaStore\";\n\nimport type { StateNamespaceDependencies } from \"./types\";\nimport type { RouteTreeStateMeta } from \"../../engine\";\nimport type { Params, State } from \"../../types\";\n\n/**\n * Independent namespace for managing router state storage and creation.\n *\n * Static methods handle validation (called by facade).\n * Instance methods handle state storage, freezing, and creation.\n */\nexport class StateNamespace {\n /**\n * Cached frozen state - avoids structuredClone on every getState() call.\n */\n #frozenState: State | undefined = undefined;\n\n /**\n * Previous state before the last setState call.\n */\n #previousState: State | undefined = undefined;\n\n /**\n * Dependencies injected from Router.\n */\n #deps!: StateNamespaceDependencies;\n\n // =========================================================================\n // Instance methods (trust input - already validated by facade)\n // =========================================================================\n\n /**\n * Returns the current router state.\n *\n * The returned state is deeply frozen (immutable) for safety.\n * Returns `undefined` if the router has not been started or has been stopped.\n */\n get<P extends Params = Params>(): State<P> | undefined {\n return this.#frozenState as State<P> | undefined; // NOSONAR -- generic narrowing needed for public API\n }\n\n /**\n * Sets the current router state.\n *\n * The state is deeply frozen before storage to ensure immutability.\n * The previous state is preserved and accessible via `getPrevious()`.\n *\n * @param state - Already validated by facade, or undefined to clear\n */\n set(state: State | undefined): void {\n // Preserve current state as previous before updating\n this.#previousState = this.#frozenState;\n\n // If state is already frozen (from makeState()), use it directly.\n // For external states, freeze in place without cloning.\n this.#frozenState = state ? freezeStateInPlace(state) : undefined;\n }\n\n /**\n * Returns the previous router state (before the last navigation).\n */\n getPrevious(): State | undefined {\n return this.#previousState;\n }\n\n reset(): void {\n this.#frozenState = undefined;\n this.#previousState = undefined;\n }\n\n // =========================================================================\n // Dependency Injection\n // =========================================================================\n\n /**\n * Sets dependencies for state creation methods.\n * Must be called before using makeState, areStatesEqual, etc.\n */\n setDependencies(deps: StateNamespaceDependencies): void {\n this.#deps = deps;\n }\n\n // =========================================================================\n // State Creation Methods\n // =========================================================================\n\n /**\n * Creates a state object for a route.\n *\n * `params` is frozen at creation so it is always immutable, even when\n * `skipFreeze=true` is passed to defer the outer `Object.freeze(state)` call.\n * This keeps params-freezing invariants independent of transition-pipeline\n * mutation (e.g. `completeTransition` attaching `state.transition`).\n *\n * `context` is initialized as a fresh empty object — intentionally NOT frozen\n * so plugins can publish data via `claim.write(state, value)` after creation.\n */\n makeState<P extends Params = Params>(\n name: string,\n params?: P,\n path?: string,\n meta?: RouteTreeStateMeta,\n skipFreeze?: boolean,\n ): State<P> {\n // Optimization: O(1) lookup instead of O(depth) ancestor iteration\n const defaultParamsConfig = this.#deps.getDefaultParams();\n const hasDefaultParams = Object.hasOwn(defaultParamsConfig, name);\n\n // Conditional allocation: avoid spreading when no defaultParams exist\n let mergedParams: P;\n\n if (hasDefaultParams) {\n mergedParams = Object.freeze({\n ...defaultParamsConfig[name],\n ...params,\n }) as P;\n } else if (!params || params === EMPTY_PARAMS) {\n mergedParams = EMPTY_PARAMS as P;\n } else {\n mergedParams = Object.freeze({ ...params });\n }\n\n const state = {\n name,\n params: mergedParams,\n path: path ?? this.#deps.buildPath(name, params),\n context: {},\n ...(!skipFreeze && { transition: DEFAULT_TRANSITION }),\n } as State<P>;\n\n if (meta) {\n setStateMetaParams(state, meta);\n }\n\n return skipFreeze ? state : freezeStateInPlace(state);\n }\n\n // =========================================================================\n // State Comparison Methods\n // =========================================================================\n\n /**\n * Compares two states for equality.\n * By default, ignores query params (only compares URL params).\n */\n areStatesEqual(\n state1: State | undefined,\n state2: State | undefined,\n ignoreQueryParams = true,\n ): boolean {\n if (!state1 || !state2) {\n return !!state1 === !!state2;\n }\n\n if (state1.name !== state2.name) {\n return false;\n }\n\n if (ignoreQueryParams) {\n // URL (path) param names are cached at the routes layer and invalidated\n // on every tree mutation, so this stays correct after replace() (#723).\n const urlParams = this.#deps.getUrlParams(state1.name);\n\n for (const urlParam of urlParams) {\n if (\n !areParamValuesEqual(state1.params[urlParam], state2.params[urlParam])\n ) {\n return false;\n }\n }\n\n return true;\n }\n\n const state1Keys = Object.keys(state1.params);\n const state2Keys = Object.keys(state2.params);\n\n if (state1Keys.length !== state2Keys.length) {\n return false;\n }\n\n for (const param of state1Keys) {\n if (\n !(param in state2.params) ||\n !areParamValuesEqual(state1.params[param], state2.params[param])\n ) {\n return false;\n }\n }\n\n return true;\n }\n}\n"],"mappings":"mIAiBA,IAAa,EAAb,KAA4B,CAI1B,GAAkC,IAAA,GAKlC,GAAoC,IAAA,GAKpC,GAYA,KAAuD,CACrD,OAAO,KAAKA,EACd,CAUA,IAAI,EAAgC,CAElC,KAAKC,GAAiB,KAAKD,GAI3B,KAAKA,GAAe,EAAQE,EAAAA,mBAAmB,CAAK,EAAI,IAAA,EAC1D,CAKA,aAAiC,CAC/B,OAAO,KAAKD,EACd,CAEA,OAAc,CACZ,KAAKD,GAAe,IAAA,GACpB,KAAKC,GAAiB,IAAA,EACxB,CAUA,gBAAgB,EAAwC,CACtD,KAAKE,GAAQ,CACf,CAiBA,UACE,EACA,EACA,EACA,EACA,EACU,CAEV,IAAM,EAAsB,KAAKA,GAAM,iBAAiB,EAClD,EAAmB,OAAO,OAAO,EAAqB,CAAI,EAG5D,EAEJ,AAQE,EARE,EACa,OAAO,OAAO,CAC3B,GAAG,EAAoB,GACvB,GAAG,CACL,CAAC,EACQ,CAAC,GAAU,IAAWC,EAAAA,aAChBA,EAAAA,aAEA,OAAO,OAAO,CAAE,GAAG,CAAO,CAAC,EAG5C,IAAM,EAAQ,CACZ,OACA,OAAQ,EACR,KAAM,GAAQ,KAAKD,GAAM,UAAU,EAAM,CAAM,EAC/C,QAAS,CAAC,EACV,GAAI,CAAC,GAAc,CAAE,WAAYE,EAAAA,kBAAmB,CACtD,EAMA,OAJI,GACF,EAAA,mBAAmB,EAAO,CAAI,EAGzB,EAAa,EAAQH,EAAAA,mBAAmB,CAAK,CACtD,CAUA,eACE,EACA,EACA,EAAoB,GACX,CACT,GAAI,CAAC,GAAU,CAAC,EACd,MAAO,CAAC,CAAC,GAAW,CAAC,CAAC,EAGxB,GAAI,EAAO,OAAS,EAAO,KACzB,MAAO,GAGT,GAAI,EAAmB,CAGrB,IAAM,EAAY,KAAKC,GAAM,aAAa,EAAO,IAAI,EAErD,IAAK,IAAM,KAAY,EACrB,GACE,CAACG,EAAAA,oBAAoB,EAAO,OAAO,GAAW,EAAO,OAAO,EAAS,EAErE,MAAO,GAIX,MAAO,EACT,CAEA,IAAM,EAAa,OAAO,KAAK,EAAO,MAAM,EACtC,EAAa,OAAO,KAAK,EAAO,MAAM,EAE5C,GAAI,EAAW,SAAW,EAAW,OACnC,MAAO,GAGT,IAAK,IAAM,KAAS,EAClB,GACE,EAAE,KAAS,EAAO,SAClB,CAACA,EAAAA,oBAAoB,EAAO,OAAO,GAAQ,EAAO,OAAO,EAAM,EAE/D,MAAO,GAIX,MAAO,EACT,CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","names":[],"sources":["../../../../src/namespaces/StateNamespace/helpers.ts"],"sourcesContent":["// packages/core/src/namespaces/StateNamespace/helpers.ts\n\nexport function areParamValuesEqual(val1: unknown, val2: unknown): boolean {\n if (val1 === val2) {\n return true;\n }\n\n if (Array.isArray(val1) && Array.isArray(val2)) {\n if (val1.length !== val2.length) {\n return false;\n }\n\n // eslint-disable-next-line unicorn/no-for-loop -- hot path: for-of entries() allocates iterator per recursive call\n for (let i = 0; i < val1.length; i++) {\n if (!areParamValuesEqual(val1[i], val2[i])) {\n return false;\n }\n }\n\n return true;\n }\n\n return false;\n}\n"],"mappings":"AAEA,SAAgB,EAAoB,EAAe,EAAwB,CACzE,GAAI,IAAS,EACX,MAAO,GAGT,GAAI,MAAM,QAAQ,CAAI,GAAK,MAAM,QAAQ,CAAI,EAAG,CAC9C,GAAI,EAAK,SAAW,EAAK,OACvB,MAAO,GAIT,IAAK,IAAI,EAAI,EAAG,EAAI,EAAK,OAAQ,IAC/B,GAAI,CAAC,EAAoB,EAAK,GAAI,EAAK,EAAE,EACvC,MAAO,GAIX,MAAO,EACT,CAEA,MAAO,EACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./foundation/fsm/fsm.js"),t={IDLE:`IDLE`,STARTING:`STARTING`,READY:`READY`,TRANSITION_STARTED:`TRANSITION_STARTED`,LEAVE_APPROVED:`LEAVE_APPROVED`,DISPOSED:`DISPOSED`},n={START:`START`,STARTED:`STARTED`,NAVIGATE:`NAVIGATE`,LEAVE_APPROVE:`LEAVE_APPROVE`,COMPLETE:`COMPLETE`,FAIL:`FAIL`,CANCEL:`CANCEL`,STOP:`STOP`,DISPOSE:`DISPOSE`},r={initial:t.IDLE,context:null,transitions:{[t.IDLE]:{[n.START]:t.STARTING,[n.DISPOSE]:t.DISPOSED},[t.STARTING]:{[n.STARTED]:t.READY,[n.FAIL]:t.IDLE,[n.STOP]:t.IDLE,[n.DISPOSE]:t.DISPOSED},[t.READY]:{[n.NAVIGATE]:t.TRANSITION_STARTED,[n.FAIL]:t.READY,[n.STOP]:t.IDLE,[n.DISPOSE]:t.DISPOSED},[t.TRANSITION_STARTED]:{[n.NAVIGATE]:t.TRANSITION_STARTED,[n.LEAVE_APPROVE]:t.LEAVE_APPROVED,[n.CANCEL]:t.READY,[n.FAIL]:t.READY,[n.DISPOSE]:t.DISPOSED},[t.LEAVE_APPROVED]:{[n.NAVIGATE]:t.TRANSITION_STARTED,[n.COMPLETE]:t.READY,[n.CANCEL]:t.READY,[n.FAIL]:t.READY,[n.DISPOSE]:t.DISPOSED},[t.DISPOSED]:{}}};function i(){return new e.FSM(r)}exports.createRouterFSM=i,exports.routerEvents=n,exports.routerStates=t;
|
|
2
|
+
//# sourceMappingURL=routerFSM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routerFSM.js","names":["FSM"],"sources":["../../src/routerFSM.ts"],"sourcesContent":["// packages/core/src/routerFSM.ts\n\nimport { FSM } from \"./foundation/fsm\";\n\nimport type { FSMConfig } from \"./foundation/fsm\";\nimport type { NavigationOptions, State } from \"./types\";\n\n/**\n * Router FSM states.\n *\n * - IDLE: Router not started or stopped\n * - STARTING: Router is initializing\n * - READY: Router is ready for navigation\n * - TRANSITION_STARTED: Navigation in progress (before deactivation guards)\n * - LEAVE_APPROVED: Deactivation guards passed, activation guards pending\n * - DISPOSED: Router has been disposed (R2+)\n */\nexport const routerStates = {\n IDLE: \"IDLE\",\n STARTING: \"STARTING\",\n READY: \"READY\",\n TRANSITION_STARTED: \"TRANSITION_STARTED\",\n LEAVE_APPROVED: \"LEAVE_APPROVED\",\n DISPOSED: \"DISPOSED\",\n} as const;\n\nexport type RouterState = (typeof routerStates)[keyof typeof routerStates];\n\n/**\n * Router FSM events.\n *\n * - START: Begin router initialization\n * - STARTED: Router initialization complete\n * - NAVIGATE: Begin navigation\n * - COMPLETE: Navigation completed successfully\n * - FAIL: Navigation or initialization failed\n * - CANCEL: Navigation cancelled\n * - STOP: Stop router\n * - DISPOSE: Dispose router (R2+)\n */\nexport const routerEvents = {\n START: \"START\",\n STARTED: \"STARTED\",\n NAVIGATE: \"NAVIGATE\",\n LEAVE_APPROVE: \"LEAVE_APPROVE\",\n COMPLETE: \"COMPLETE\",\n FAIL: \"FAIL\",\n CANCEL: \"CANCEL\",\n STOP: \"STOP\",\n DISPOSE: \"DISPOSE\",\n} as const;\n\nexport type RouterEvent = (typeof routerEvents)[keyof typeof routerEvents];\n\n/**\n * Per-event payloads for the router FSM (#1169 commit-gate). The three hot\n * navigation transitions carry their transition states so the FSM action\n * dispatched by `send()` emits the matching transition event — i.e. events are\n * literal consequences of FSM transitions (no `forceState` + manual emit). See\n * `EventBusNamespace.#setupFSMActions`.\n */\nexport interface RouterPayloads {\n NAVIGATE: { toState: State; fromState?: State | undefined };\n LEAVE_APPROVE: { toState: State; fromState?: State | undefined };\n COMPLETE: {\n toState: State;\n fromState?: State | undefined;\n opts?: NavigationOptions | undefined;\n };\n}\n\n/**\n * Router FSM configuration.\n *\n * Transitions:\n * - IDLE → STARTING (START), DISPOSED (DISPOSE)\n * - STARTING → READY (STARTED), IDLE (FAIL, STOP), DISPOSED (DISPOSE)\n * - READY → TRANSITION_STARTED (NAVIGATE), READY (FAIL, self-loop for early validation errors), IDLE (STOP), DISPOSED (DISPOSE)\n * - TRANSITION_STARTED → LEAVE_APPROVED (LEAVE_APPROVE), TRANSITION_STARTED (NAVIGATE, self-loop), READY (CANCEL, FAIL), DISPOSED (DISPOSE)\n * - LEAVE_APPROVED → READY (COMPLETE, CANCEL, FAIL), TRANSITION_STARTED (NAVIGATE), DISPOSED (DISPOSE)\n * - DISPOSED → (no transitions)\n *\n * DISPOSE is wired from every non-DISPOSED state so `router.dispose()` always\n * settles the FSM at DISPOSED. The facade orchestrates cleanup through IDLE\n * for healthy flows; the direct transitions guarantee the FSM is not left\n * stuck if cleanup is skipped (e.g. dispose mid-STARTING when the start\n * pipeline threw before STARTED/FAIL).\n */\nconst routerFSMConfig: FSMConfig<RouterState, RouterEvent, null> = {\n initial: routerStates.IDLE,\n context: null,\n transitions: {\n [routerStates.IDLE]: {\n [routerEvents.START]: routerStates.STARTING,\n [routerEvents.DISPOSE]: routerStates.DISPOSED,\n },\n [routerStates.STARTING]: {\n [routerEvents.STARTED]: routerStates.READY,\n [routerEvents.FAIL]: routerStates.IDLE,\n [routerEvents.STOP]: routerStates.IDLE,\n [routerEvents.DISPOSE]: routerStates.DISPOSED,\n },\n [routerStates.READY]: {\n [routerEvents.NAVIGATE]: routerStates.TRANSITION_STARTED,\n [routerEvents.FAIL]: routerStates.READY,\n [routerEvents.STOP]: routerStates.IDLE,\n [routerEvents.DISPOSE]: routerStates.DISPOSED,\n },\n [routerStates.TRANSITION_STARTED]: {\n [routerEvents.NAVIGATE]: routerStates.TRANSITION_STARTED,\n [routerEvents.LEAVE_APPROVE]: routerStates.LEAVE_APPROVED,\n [routerEvents.CANCEL]: routerStates.READY,\n [routerEvents.FAIL]: routerStates.READY,\n [routerEvents.DISPOSE]: routerStates.DISPOSED,\n },\n [routerStates.LEAVE_APPROVED]: {\n [routerEvents.NAVIGATE]: routerStates.TRANSITION_STARTED,\n [routerEvents.COMPLETE]: routerStates.READY,\n [routerEvents.CANCEL]: routerStates.READY,\n [routerEvents.FAIL]: routerStates.READY,\n [routerEvents.DISPOSE]: routerStates.DISPOSED,\n },\n [routerStates.DISPOSED]: {},\n },\n};\n\n/**\n * Factory function to create a router FSM instance.\n *\n * @returns FSM instance with initial state \"IDLE\"\n */\nexport function createRouterFSM(): FSM<\n RouterState,\n RouterEvent,\n null,\n RouterPayloads\n> {\n return new FSM<RouterState, RouterEvent, null, RouterPayloads>(\n routerFSMConfig,\n );\n}\n"],"mappings":"2CAiBa,EAAe,CAC1B,KAAM,OACN,SAAU,WACV,MAAO,QACP,mBAAoB,qBACpB,eAAgB,iBAChB,SAAU,UACZ,EAgBa,EAAe,CAC1B,MAAO,QACP,QAAS,UACT,SAAU,WACV,cAAe,gBACf,SAAU,WACV,KAAM,OACN,OAAQ,SACR,KAAM,OACN,QAAS,SACX,EAsCM,EAA6D,CACjE,QAAS,EAAa,KACtB,QAAS,KACT,YAAa,EACV,EAAa,MAAO,EAClB,EAAa,OAAQ,EAAa,UAClC,EAAa,SAAU,EAAa,QACvC,GACC,EAAa,UAAW,EACtB,EAAa,SAAU,EAAa,OACpC,EAAa,MAAO,EAAa,MACjC,EAAa,MAAO,EAAa,MACjC,EAAa,SAAU,EAAa,QACvC,GACC,EAAa,OAAQ,EACnB,EAAa,UAAW,EAAa,oBACrC,EAAa,MAAO,EAAa,OACjC,EAAa,MAAO,EAAa,MACjC,EAAa,SAAU,EAAa,QACvC,GACC,EAAa,oBAAqB,EAChC,EAAa,UAAW,EAAa,oBACrC,EAAa,eAAgB,EAAa,gBAC1C,EAAa,QAAS,EAAa,OACnC,EAAa,MAAO,EAAa,OACjC,EAAa,SAAU,EAAa,QACvC,GACC,EAAa,gBAAiB,EAC5B,EAAa,UAAW,EAAa,oBACrC,EAAa,UAAW,EAAa,OACrC,EAAa,QAAS,EAAa,OACnC,EAAa,MAAO,EAAa,OACjC,EAAa,SAAU,EAAa,QACvC,GACC,EAAa,UAAW,CAAC,CAC5B,CACF,EAOA,SAAgB,GAKd,CACA,OAAO,IAAIA,EAAAA,IACT,CACF,CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateMetaStore.js","names":[],"sources":["../../src/stateMetaStore.ts"],"sourcesContent":["// packages/core/src/stateMetaStore.ts\n\nimport type { Params, State } from \"./types\";\n\nconst store = new WeakMap<State, Params>();\n\n/** @internal */\nexport function getStateMetaParams(state: State): Params | undefined {\n return store.get(state);\n}\n\n/** @internal */\nexport function setStateMetaParams(state: State, params: Params): void {\n store.set(state, params);\n}\n"],"mappings":"AAIA,MAAM,EAAQ,IAAI,QAGlB,SAAgB,EAAmB,EAAkC,CACnE,OAAO,EAAM,IAAI,CAAK,CACxB,CAGA,SAAgB,EAAmB,EAAc,EAAsB,CACrE,EAAM,IAAI,EAAO,CAAM,CACzB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./stateMetaStore.js"),t=[];Object.freeze(t);function n(e){let t=e.split(`.`),n=t.length,r=[t[0]],i=t[0].length;for(let a=1;a<n-1;a++)i+=1+t[a].length,r.push(e.slice(0,i));return r.push(e),r}const r=new Set([`string`,`number`,`boolean`]);function i(e){return r.has(typeof e)}function a(e,t,n,r){let a=t[e];if(!a||typeof a!=`object`)return!0;for(let e of Object.keys(a)){let t=n.params[e],a=r.params[e];if(i(t)&&i(a)&&String(t)!==String(a))return!1}return!0}function o(e,t,n,r,i,o){for(let s=0;s<o;s++){let o=r[s];if(o!==i[s]||!a(o,e,t,n))return s}return o}const s=new Map;function c(e){let t=s.get(e);if(t)return t;let n=l(e);return Object.freeze(n),s.set(e,n),n}function l(e){if(!e)return[``];let t=e.indexOf(`.`);if(t===-1)return[e];let r=e.indexOf(`.`,t+1);if(r===-1)return[e.slice(0,t),e];let i=e.indexOf(`.`,r+1);return i===-1?[e.slice(0,t),e.slice(0,r),e]:e.indexOf(`.`,i+1)===-1?[e.slice(0,t),e.slice(0,r),e.slice(0,i),e]:n(e)}let u,d,f=null,p,m,h=null;function g(n,r){if(!r)return{intersection:``,toActivate:c(n.name),toDeactivate:t};let i=e.getStateMetaParams(n),a=e.getStateMetaParams(r);if(!i&&!a)return{intersection:``,toActivate:c(n.name),toDeactivate:c(r.name)};let s=c(n.name),l=c(r.name),u=Math.min(l.length,s.length),d=o(i??a,n,r,s,l,u),f;if(d>=l.length)f=t;else if(d===0&&l.length===1)f=l;else{f=[];for(let e=l.length-1;e>=d;e--)f.push(l[e])}let p=d===0?s:s.slice(d);return{intersection:d>0?l[d-1]:``,toDeactivate:f,toActivate:p}}function _(e,t){if(f!==null&&e===u&&t===d)return f;if(h!==null&&e===p&&t===m)return h;let n=g(e,t);return p=u,m=d,h=f,u=e,d=t,f=n,n}exports.getTransitionPath=_,exports.nameToIDs=c;
|
|
2
|
+
//# sourceMappingURL=transitionPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transitionPath.js","names":["getStateMetaParams"],"sources":["../../src/transitionPath.ts"],"sourcesContent":["// packages/core/src/transitionPath.ts\n\nimport { getStateMetaParams } from \"./stateMetaStore\";\n\nimport type { State } from \"./types\";\n\n/**\n * Parameters extracted from a route segment.\n * Maps parameter names to their string values.\n */\ntype PrimitiveParam = string | number | boolean;\n\n/**\n * Represents a transition path between two router states.\n * Contains information about which route segments need to be activated/deactivated.\n */\nexport interface TransitionPath {\n /** The common ancestor route segment where paths diverge */\n intersection: string;\n /** Route segments that need to be deactivated (in reverse order) */\n toDeactivate: string[];\n /** Route segments that need to be activated (in order) */\n toActivate: string[];\n}\n\n// Constants for better maintainability\nconst ROUTE_SEGMENT_SEPARATOR = \".\";\nconst EMPTY_INTERSECTION = \"\";\nconst DEFAULT_ROUTE_NAME = \"\";\nconst FROZEN_EMPTY_ARRAY: string[] = [];\n\nObject.freeze(FROZEN_EMPTY_ARRAY);\n\n/**\n * Handles conversion of route names with many segments (5+).\n * Internal helper for nameToIDs function.\n *\n * Uses optimized hybrid approach: split to get segments, then slice original\n * string to build cumulative paths. This approach is 65-81% faster than\n * string concatenation for typical cases (5-10 segments).\n *\n * @param name - Route name with 5 or more segments\n * @returns Array of cumulative segment IDs\n * @throws {Error} If route depth exceeds maximum allowed\n * @internal\n */\nfunction nameToIDsGeneral(name: string): string[] {\n // We know there are at least 5 segments at this point (after fast paths)\n const segments = name.split(ROUTE_SEGMENT_SEPARATOR);\n const segmentCount = segments.length;\n\n // First segment is always just itself\n const ids: string[] = [segments[0]];\n\n // Calculate cumulative lengths and slice from original string\n // This avoids repeated string concatenation (O(k²) → O(k))\n let cumulativeLength = segments[0].length;\n\n for (let i = 1; i < segmentCount - 1; i++) {\n cumulativeLength += 1 + segments[i].length; // +1 for dot separator\n ids.push(name.slice(0, cumulativeLength));\n }\n\n // Last segment is always the full route name\n ids.push(name);\n\n return ids;\n}\n\nconst PRIMITIVE_TYPES: ReadonlySet<string> = new Set([\n \"string\",\n \"number\",\n \"boolean\",\n]);\n\nfunction isPrimitive(value: unknown): value is PrimitiveParam {\n return PRIMITIVE_TYPES.has(typeof value);\n}\n\n/**\n * Compares segment parameters between two states without creating intermediate objects.\n * Returns true if all primitive params for the given segment are equal in both states.\n */\nfunction segmentParamsEqual(\n name: string,\n toMetaParams: Record<string, unknown>,\n toState: State,\n fromState: State,\n): boolean {\n const keys = toMetaParams[name];\n\n if (!keys || typeof keys !== \"object\") {\n return true;\n }\n\n for (const key of Object.keys(keys)) {\n const toVal = toState.params[key];\n const fromVal = fromState.params[key];\n\n if (\n isPrimitive(toVal) &&\n isPrimitive(fromVal) &&\n String(toVal) !== String(fromVal)\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Finds the point where two state paths diverge based on segments and parameters.\n * Compares both segment names and their parameters to find the first difference.\n *\n * @param toMetaParams - Cached meta.params from toState (avoids per-segment WeakMap lookup)\n * @param toState - Target state\n * @param fromState - Source state\n * @param toStateIds - Segment IDs for target state\n * @param fromStateIds - Segment IDs for source state\n * @param maxI - Maximum index to check (minimum of both arrays)\n * @returns Index of first difference, or maxI if all checked segments match\n */\nfunction pointOfDifference(\n toMetaParams: Record<string, unknown>,\n toState: State,\n fromState: State,\n toStateIds: string[],\n fromStateIds: string[],\n maxI: number,\n): number {\n for (let i = 0; i < maxI; i++) {\n const toSegment = toStateIds[i];\n const fromSegment = fromStateIds[i];\n\n // Different segment names - immediate difference\n if (toSegment !== fromSegment) {\n return i;\n }\n\n if (!segmentParamsEqual(toSegment, toMetaParams, toState, fromState)) {\n return i;\n }\n }\n\n return maxI;\n}\n\n/**\n * Converts a route name to an array of hierarchical segment identifiers.\n * Each segment ID includes all parent segments in the path.\n *\n * @param name - Route name in dot notation (e.g., 'users.profile.edit')\n * @returns Array of cumulative segment IDs\n * @throws {Error} If route depth exceeds maximum allowed depth\n *\n * @example\n * // Simple route\n * nameToIDs('users');\n * // Returns: ['users']\n *\n * @example\n * // Nested route\n * nameToIDs('users.profile.edit');\n * // Returns: ['users', 'users.profile', 'users.profile.edit']\n *\n * @example\n * // Empty string (root route)\n * nameToIDs('');\n * // Returns: ['']\n *\n * @remarks\n * Input parameter is NOT validated in this function for performance reasons.\n * Validation significantly slows down nameToIDs execution.\n * The input should be validated by the function/method that calls nameToIDs.\n */\n// Module-global cache (shared across all router instances): bounded in practice by\n// the app's route-name vocabulary, which is stable across cloneRouter() requests, so\n// it does not grow per request. Intentionally NOT cleared on dispose() — it is not\n// per-router, so one router's teardown must not evict entries other routers rely on.\nconst nameToIDsCache = new Map<string, string[]>();\n\nexport function nameToIDs(name: string): string[] {\n const cached = nameToIDsCache.get(name);\n\n // Stryker disable next-line BlockStatement: equivalent — dropping the cache-hit early return recomputes the identical frozen id chain (the cache is a perf optimization, not a correctness gate).\n if (cached) {\n return cached;\n }\n\n const result = computeNameToIDs(name);\n\n Object.freeze(result);\n nameToIDsCache.set(name, result);\n\n return result;\n}\n\nfunction computeNameToIDs(name: string): string[] {\n if (!name) {\n return [DEFAULT_ROUTE_NAME];\n }\n\n const firstDot = name.indexOf(ROUTE_SEGMENT_SEPARATOR);\n\n if (firstDot === -1) {\n return [name];\n }\n\n const secondDot = name.indexOf(ROUTE_SEGMENT_SEPARATOR, firstDot + 1);\n\n if (secondDot === -1) {\n return [name.slice(0, firstDot), name];\n }\n\n const thirdDot = name.indexOf(ROUTE_SEGMENT_SEPARATOR, secondDot + 1);\n\n // Stryker disable next-line UnaryOperator,BlockStatement: equivalent — inverting/emptying the 3-segment fast path routes the name through nameToIDsGeneral (below), which yields the identical id chain (same rationale as the L242 ArithmeticOperator disable). The ConditionalExpression/EqualityOperator siblings stay live (→true and !== are killed).\n if (thirdDot === -1) {\n return [name.slice(0, firstDot), name.slice(0, secondDot), name];\n }\n\n // Stryker disable next-line ArithmeticOperator: equivalent — `thirdDot - 1` makes fourthDot non-(-1), routing 5+ segment names through nameToIDsGeneral, which yields the identical id chain.\n const fourthDot = name.indexOf(ROUTE_SEGMENT_SEPARATOR, thirdDot + 1);\n\n // Stryker disable next-line UnaryOperator,BlockStatement: equivalent — inverting/emptying the 4-segment fast path routes the name through nameToIDsGeneral (below), which yields the identical id chain (same rationale as the L242 ArithmeticOperator disable). The ConditionalExpression/EqualityOperator siblings stay live (→true and !== are killed).\n if (fourthDot === -1) {\n return [\n name.slice(0, firstDot),\n name.slice(0, secondDot),\n name.slice(0, thirdDot),\n name,\n ];\n }\n\n return nameToIDsGeneral(name);\n}\n\n/**\n * Calculates the transition path between two router states.\n * Determines which route segments need to be deactivated and activated\n * to transition from one state to another.\n *\n * @param toState - Target state to transition to\n * @param fromState - Current state to transition from (optional)\n * @returns Transition path with intersection and segments to activate/deactivate\n *\n * @throws {TypeError} When toState is null or undefined\n * @throws {TypeError} When toState is not an object\n * @throws {TypeError} When toState.name is missing or not a string\n * @throws {TypeError} When toState.params is missing or not an object\n * @throws {TypeError} When toState.path is missing or not a string\n * @throws {TypeError} When toState.name contains invalid route format:\n * - Contains only whitespace (e.g., \" \")\n * - Has consecutive dots (e.g., \"users..profile\")\n * - Has leading/trailing dots (e.g., \".users\" or \"users.\")\n * - Segments don't match pattern [a-zA-Z_][a-zA-Z0-9_-]* (e.g., \"users.123\")\n * - Contains spaces or special characters (e.g., \"users profile\")\n * - Exceeds maximum length (8192 characters)\n * @throws {TypeError} When fromState is provided and has any of the validation errors listed above for toState\n *\n * @example\n * // ✅ Valid calls\n * getTransitionPath({ name: 'users.profile', params: {}, path: '/users/profile' });\n * getTransitionPath(toState, fromState);\n * getTransitionPath({ name: '', params: {}, path: '/' }); // root route\n *\n * @example\n * // ❌ Invalid calls that throw TypeError\n * getTransitionPath(null); // toState is null\n * getTransitionPath(undefined); // toState is undefined\n * getTransitionPath({}); // missing required fields\n * getTransitionPath({ name: 123, params: {}, path: '/' }); // name not a string\n * getTransitionPath({ name: 'home', path: '/' }); // missing params\n * getTransitionPath({ name: 'users..profile', params: {}, path: '/' }); // consecutive dots\n * getTransitionPath({ name: '.users', params: {}, path: '/' }); // leading dot\n * getTransitionPath({ name: 'users.', params: {}, path: '/' }); // trailing dot\n * getTransitionPath({ name: 'users profile', params: {}, path: '/' }); // contains space\n * getTransitionPath({ name: 'users.123', params: {}, path: '/' }); // segment starts with number\n * getTransitionPath(validToState, { name: 'invalid..route', params: {}, path: '/' }); // fromState invalid\n *\n * @example\n * // Full activation (no fromState)\n * getTransitionPath(makeState('users.profile'));\n * // Returns: {\n * // intersection: '',\n * // toActivate: ['users', 'users.profile'],\n * // toDeactivate: []\n * // }\n *\n * @example\n * // Partial transition with common ancestor\n * getTransitionPath(\n * makeState('users.profile'),\n * makeState('users.list')\n * );\n * // Returns: {\n * // intersection: 'users',\n * // toActivate: ['users.profile'],\n * // toDeactivate: ['users.list']\n * // }\n *\n * @example\n * // Complete route change\n * getTransitionPath(\n * makeState('admin.dashboard'),\n * makeState('users.profile')\n * );\n * // Returns: {\n * // intersection: '',\n * // toActivate: ['admin', 'admin.dashboard'],\n * // toDeactivate: ['users.profile', 'users']\n * // }\n */\n// Single-entry cache: shouldUpdateNode calls getTransitionPath N times per\n// navigation with the same state objects (once per subscribed node).\n// Cache by reference eliminates N-1 redundant computations.\n// Module-global (≤2 State refs); not cleared on dispose — negligible, not per-router.\nlet cached1To: State | undefined;\nlet cached1From: State | undefined;\nlet cached1Result: TransitionPath | null = null;\n\nlet cached2To: State | undefined;\nlet cached2From: State | undefined;\nlet cached2Result: TransitionPath | null = null;\n\nfunction computeTransitionPath(\n toState: State,\n fromState?: State,\n): TransitionPath {\n // ===== FAST PATH 1: Initial navigation (no fromState) =====\n // This is the best performing case in benchmarks (5M ops/sec)\n if (!fromState) {\n return {\n intersection: EMPTY_INTERSECTION,\n toActivate: nameToIDs(toState.name),\n toDeactivate: FROZEN_EMPTY_ARRAY,\n };\n }\n\n // ===== FAST PATH 3: Missing meta requires full reload =====\n // Single WeakMap lookup per state, reused in pointOfDifference/segmentParamsEqual\n const toMetaParams = getStateMetaParams(toState);\n const fromMetaParams = getStateMetaParams(fromState);\n\n if (!toMetaParams && !fromMetaParams) {\n // FAST PATH 3 (both states meta-less). Consumers that land here read the\n // result order-INSENSITIVELY, so the from-chain is returned as-is\n // (root→leaf, no reverse needed):\n // • `shouldUpdateNode` reads `toDeactivate` by MEMBERSHIP (`.includes`).\n // • Externally-supplied meta-less states (e.g. a plugin passing a raw\n // `{name, params, path}` to `navigateToState`) land here. Since #1170,\n // `navigateToState` carries the source's WeakMap meta across its writable\n // shell, so start()/popstate states are NOT meta-less. A `replace()`\n // survivor stays meta-less but is benign: the next transition's `toState`\n // always carries meta (buildNavigateState), so this both-meta-less path\n // is not reached from it.\n // (`canNavigateTo` no longer reaches this path — since #970 it builds its\n // toState WITH meta, mirroring buildNavigateState.)\n // The navigate pipeline always carries meta (buildNavigateState) → STANDARD\n // PATH below, which trims the shared ancestor and reverses correctly.\n return {\n intersection: EMPTY_INTERSECTION,\n toActivate: nameToIDs(toState.name),\n toDeactivate: nameToIDs(fromState.name),\n };\n }\n\n // ===== STANDARD PATH: Routes with parameters =====\n const toStateIds = nameToIDs(toState.name);\n const fromStateIds = nameToIDs(fromState.name);\n // Stryker disable next-line MethodExpression: equivalent — Math.max reads one index past the shorter id array; that slot is undefined, so the `toSegment !== fromSegment` check in pointOfDifference returns the same divergence index Math.min would stop at.\n const maxI = Math.min(fromStateIds.length, toStateIds.length);\n\n const i = pointOfDifference(\n (toMetaParams ?? fromMetaParams) as Record<string, unknown>,\n toState,\n fromState,\n toStateIds,\n fromStateIds,\n maxI,\n );\n\n // Optimization: Build deactivation list in reverse order directly\n // instead of slice(i).toReversed() which creates 2 arrays\n let toDeactivate: string[];\n\n if (i >= fromStateIds.length) {\n toDeactivate = FROZEN_EMPTY_ARRAY;\n } else if (i === 0 && fromStateIds.length === 1) {\n // Single-segment route: reversed = original, reuse cached frozen array\n toDeactivate = fromStateIds;\n } else {\n toDeactivate = [];\n\n for (let j = fromStateIds.length - 1; j >= i; j--) {\n toDeactivate.push(fromStateIds[j]);\n }\n }\n\n // Build activation list — reuse cached frozen array when using full list\n const toActivate = i === 0 ? toStateIds : toStateIds.slice(i);\n\n // Determine intersection point (common ancestor)\n const intersection = i > 0 ? fromStateIds[i - 1] : EMPTY_INTERSECTION;\n\n return {\n intersection,\n toDeactivate,\n toActivate,\n };\n}\n\nexport function getTransitionPath(\n toState: State,\n fromState?: State,\n): TransitionPath {\n // Stryker disable BlockStatement: equivalent — both cache short-circuits below; emptying either early-return recomputes the identical TransitionPath (computeTransitionPath is deterministic for the same to/from states) and re-caches it. Restored right after.\n if (\n cached1Result !== null &&\n toState === cached1To &&\n fromState === cached1From\n ) {\n return cached1Result;\n }\n\n if (\n cached2Result !== null &&\n toState === cached2To &&\n fromState === cached2From\n ) {\n return cached2Result;\n }\n // Stryker restore BlockStatement\n\n const result = computeTransitionPath(toState, fromState);\n\n cached2To = cached1To;\n cached2From = cached1From;\n cached2Result = cached1Result;\n\n cached1To = toState;\n cached1From = fromState;\n cached1Result = result;\n\n return result;\n}\n"],"mappings":"uCA6BM,EAA+B,CAAC,EAEtC,OAAO,OAAO,CAAkB,EAehC,SAAS,EAAiB,EAAwB,CAEhD,IAAM,EAAW,EAAK,MAAM,GAAuB,EAC7C,EAAe,EAAS,OAGxB,EAAgB,CAAC,EAAS,EAAE,EAI9B,EAAmB,EAAS,EAAE,CAAC,OAEnC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAe,EAAG,IACpC,GAAoB,EAAI,EAAS,EAAE,CAAC,OACpC,EAAI,KAAK,EAAK,MAAM,EAAG,CAAgB,CAAC,EAM1C,OAFA,EAAI,KAAK,CAAI,EAEN,CACT,CAEA,MAAM,EAAuC,IAAI,IAAI,CACnD,SACA,SACA,SACF,CAAC,EAED,SAAS,EAAY,EAAyC,CAC5D,OAAO,EAAgB,IAAI,OAAO,CAAK,CACzC,CAMA,SAAS,EACP,EACA,EACA,EACA,EACS,CACT,IAAM,EAAO,EAAa,GAE1B,GAAI,CAAC,GAAQ,OAAO,GAAS,SAC3B,MAAO,GAGT,IAAK,IAAM,KAAO,OAAO,KAAK,CAAI,EAAG,CACnC,IAAM,EAAQ,EAAQ,OAAO,GACvB,EAAU,EAAU,OAAO,GAEjC,GACE,EAAY,CAAK,GACjB,EAAY,CAAO,GACnB,OAAO,CAAK,IAAM,OAAO,CAAO,EAEhC,MAAO,EAEX,CAEA,MAAO,EACT,CAcA,SAAS,EACP,EACA,EACA,EACA,EACA,EACA,EACQ,CACR,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,IAAK,CAC7B,IAAM,EAAY,EAAW,GAQ7B,GAJI,IAHgB,EAAa,IAO7B,CAAC,EAAmB,EAAW,EAAc,EAAS,CAAS,EACjE,OAAO,CAEX,CAEA,OAAO,CACT,CAkCA,M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