@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
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,239 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* Special route names and identifiers.
|
|
19
|
-
*/
|
|
20
|
-
declare const UNKNOWN_ROUTE = "@@router/UNKNOWN_ROUTE";
|
|
21
|
-
declare const constants: Constants;
|
|
22
|
-
/**
|
|
23
|
-
* Event names for router event system.
|
|
24
|
-
* Used with addEventListener/removeEventListener for reactive subscriptions.
|
|
25
|
-
*/
|
|
26
|
-
declare const events: EventToNameMap;
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/RouterError.d.ts
|
|
29
|
-
declare class RouterError extends Error {
|
|
30
|
-
[key: string]: unknown;
|
|
31
|
-
readonly segment: string | undefined;
|
|
32
|
-
readonly path: string | undefined;
|
|
33
|
-
code: string;
|
|
34
|
-
/**
|
|
35
|
-
* Creates a new RouterError instance.
|
|
36
|
-
*
|
|
37
|
-
* The options object accepts built-in fields (message, segment, path)
|
|
38
|
-
* and any additional custom fields, which will all be attached to the error instance.
|
|
39
|
-
*
|
|
40
|
-
* @param code - The error code (e.g., "ROUTE_NOT_FOUND", "CANNOT_ACTIVATE")
|
|
41
|
-
* @param options - Optional configuration object
|
|
42
|
-
* @param options.message - Custom error message (defaults to code if not provided)
|
|
43
|
-
* @param options.segment - The route segment where the error occurred
|
|
44
|
-
* @param options.path - The full path where the error occurred
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* // Basic error
|
|
49
|
-
* const err1 = new RouterError("ROUTE_NOT_FOUND");
|
|
50
|
-
*
|
|
51
|
-
* // Error with custom message
|
|
52
|
-
* const err2 = new RouterError("ERR", { message: "Something went wrong" });
|
|
53
|
-
*
|
|
54
|
-
* // Error with context and custom fields
|
|
55
|
-
* const err3 = new RouterError("CANNOT_ACTIVATE", {
|
|
56
|
-
* message: "Insufficient permissions",
|
|
57
|
-
* segment: "admin",
|
|
58
|
-
* path: "/admin/users",
|
|
59
|
-
* userId: "123" // custom field
|
|
60
|
-
* });
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
constructor(code: string, {
|
|
64
|
-
message,
|
|
65
|
-
segment,
|
|
66
|
-
path,
|
|
67
|
-
...rest
|
|
68
|
-
}?: {
|
|
69
|
-
[key: string]: unknown;
|
|
70
|
-
message?: string | undefined;
|
|
71
|
-
segment?: string | undefined;
|
|
72
|
-
path?: string | undefined;
|
|
73
|
-
});
|
|
74
|
-
/**
|
|
75
|
-
* Updates the error code and conditionally updates the message.
|
|
76
|
-
*
|
|
77
|
-
* If the current message is one of the standard error code values
|
|
78
|
-
* (e.g., "ROUTE_NOT_FOUND", "SAME_STATES"), it will be replaced with the new code.
|
|
79
|
-
* This allows keeping error messages in sync with codes when using standard error codes.
|
|
80
|
-
*
|
|
81
|
-
* If the message is custom (not a standard error code), it will be preserved.
|
|
82
|
-
*
|
|
83
|
-
* @param newCode - The new error code to set
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* // Message follows code (standard error code as message)
|
|
87
|
-
* const err = new RouterError("ROUTE_NOT_FOUND", { message: "ROUTE_NOT_FOUND" });
|
|
88
|
-
* err.setCode("CUSTOM_ERROR"); // message becomes "CUSTOM_ERROR"
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* // Custom message is preserved
|
|
92
|
-
* const err = new RouterError("ERR", { message: "Custom error message" });
|
|
93
|
-
* err.setCode("NEW_CODE"); // message stays "Custom error message"
|
|
94
|
-
*/
|
|
95
|
-
setCode(newCode: string): void;
|
|
96
|
-
/**
|
|
97
|
-
* Copies properties from another Error instance to this RouterError.
|
|
98
|
-
*
|
|
99
|
-
* This method updates the message, cause, and stack trace from the provided error.
|
|
100
|
-
* Useful for wrapping native errors while preserving error context.
|
|
101
|
-
*
|
|
102
|
-
* @param err - The Error instance to copy properties from
|
|
103
|
-
* @throws {TypeError} If err is null or undefined
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* ```typescript
|
|
107
|
-
* const routerErr = new RouterError("TRANSITION_ERR");
|
|
108
|
-
* try {
|
|
109
|
-
* // some operation that might fail
|
|
110
|
-
* } catch (nativeErr) {
|
|
111
|
-
* routerErr.setErrorInstance(nativeErr);
|
|
112
|
-
* throw routerErr;
|
|
113
|
-
* }
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
setErrorInstance(err: Error): void;
|
|
117
|
-
/**
|
|
118
|
-
* Adds custom fields to the error object.
|
|
119
|
-
*
|
|
120
|
-
* This method allows attaching arbitrary data to the error for debugging or logging purposes.
|
|
121
|
-
* All fields become accessible as properties on the error instance and are included in JSON serialization.
|
|
122
|
-
*
|
|
123
|
-
* Reserved method names (setCode, setErrorInstance, setAdditionalFields, hasField, getField, toJSON)
|
|
124
|
-
* are automatically filtered out to prevent accidental overwriting of class methods.
|
|
125
|
-
*
|
|
126
|
-
* @param fields - Object containing custom fields to add to the error
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* ```typescript
|
|
130
|
-
* const err = new RouterError("CANNOT_ACTIVATE");
|
|
131
|
-
* err.setAdditionalFields({
|
|
132
|
-
* userId: "123",
|
|
133
|
-
* attemptedRoute: "/admin",
|
|
134
|
-
* reason: "insufficient permissions"
|
|
135
|
-
* });
|
|
136
|
-
*
|
|
137
|
-
* console.log(err.userId); // "123"
|
|
138
|
-
* console.log(JSON.stringify(err)); // includes all custom fields
|
|
139
|
-
* ```
|
|
140
|
-
*/
|
|
141
|
-
setAdditionalFields(fields: Record<string, unknown>): void;
|
|
142
|
-
/**
|
|
143
|
-
* Checks if a custom field exists on the error object.
|
|
144
|
-
*
|
|
145
|
-
* This method checks for both custom fields added via setAdditionalFields()
|
|
146
|
-
* and built-in fields (code, message, segment, etc.).
|
|
147
|
-
*
|
|
148
|
-
* @param key - The field name to check
|
|
149
|
-
* @returns `true` if the field exists, `false` otherwise
|
|
150
|
-
*
|
|
151
|
-
* @example
|
|
152
|
-
* ```typescript
|
|
153
|
-
* const err = new RouterError("ERR", { segment: "users" });
|
|
154
|
-
* err.setAdditionalFields({ userId: "123" });
|
|
155
|
-
*
|
|
156
|
-
* err.hasField("userId"); // true
|
|
157
|
-
* err.hasField("segment"); // true
|
|
158
|
-
* err.hasField("unknown"); // false
|
|
159
|
-
* ```
|
|
160
|
-
*/
|
|
161
|
-
hasField(key: string): boolean;
|
|
162
|
-
/**
|
|
163
|
-
* Retrieves a custom field value from the error object.
|
|
164
|
-
*
|
|
165
|
-
* This method can access both custom fields and built-in fields.
|
|
166
|
-
* Returns `undefined` if the field doesn't exist.
|
|
167
|
-
*
|
|
168
|
-
* @param key - The field name to retrieve
|
|
169
|
-
* @returns The field value, or `undefined` if it doesn't exist
|
|
170
|
-
*
|
|
171
|
-
* @example
|
|
172
|
-
* ```typescript
|
|
173
|
-
* const err = new RouterError("ERR");
|
|
174
|
-
* err.setAdditionalFields({ userId: "123", role: "admin" });
|
|
175
|
-
*
|
|
176
|
-
* err.getField("userId"); // "123"
|
|
177
|
-
* err.getField("role"); // "admin"
|
|
178
|
-
* err.getField("code"); // "ERR" (built-in field)
|
|
179
|
-
* err.getField("unknown"); // undefined
|
|
180
|
-
* ```
|
|
181
|
-
*/
|
|
182
|
-
getField(key: string): unknown;
|
|
183
|
-
/**
|
|
184
|
-
* Serializes the error to a JSON-compatible object.
|
|
185
|
-
*
|
|
186
|
-
* This method is automatically called by JSON.stringify() and includes:
|
|
187
|
-
* - Built-in fields: code, message, segment (if set), path (if set)
|
|
188
|
-
* - All custom fields added via setAdditionalFields() or constructor
|
|
189
|
-
* - Excludes: stack trace (for security/cleanliness)
|
|
190
|
-
*
|
|
191
|
-
* @returns A plain object representation of the error, suitable for JSON serialization
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* ```typescript
|
|
195
|
-
* const err = new RouterError("ROUTE_NOT_FOUND", {
|
|
196
|
-
* message: "Route not found",
|
|
197
|
-
* path: "/admin/users/123"
|
|
198
|
-
* });
|
|
199
|
-
* err.setAdditionalFields({ userId: "123" });
|
|
200
|
-
*
|
|
201
|
-
* JSON.stringify(err);
|
|
202
|
-
* // {
|
|
203
|
-
* // "code": "ROUTE_NOT_FOUND",
|
|
204
|
-
* // "message": "Route not found",
|
|
205
|
-
* // "path": "/admin/users/123",
|
|
206
|
-
* // "userId": "123"
|
|
207
|
-
* // }
|
|
208
|
-
* ```
|
|
209
|
-
*/
|
|
210
|
-
toJSON(): Record<string, unknown>;
|
|
211
|
-
}
|
|
212
|
-
//#endregion
|
|
213
|
-
//#region src/createRouter.d.ts
|
|
214
|
-
/**
|
|
215
|
-
* Creates a new router instance.
|
|
216
|
-
*
|
|
217
|
-
* @param routes - Array of route definitions
|
|
218
|
-
* @param options - Router configuration options
|
|
219
|
-
* @param dependencies - Dependencies to inject into the router
|
|
220
|
-
* @returns A new Router instance
|
|
221
|
-
*
|
|
222
|
-
* @example
|
|
223
|
-
* const router = createRouter([
|
|
224
|
-
* { name: 'home', path: '/' },
|
|
225
|
-
* { name: 'users', path: '/users' },
|
|
226
|
-
* ]);
|
|
227
|
-
*
|
|
228
|
-
* router.start('/');
|
|
229
|
-
*/
|
|
230
|
-
declare const createRouter: <Dependencies extends DefaultDependencies = DefaultDependencies>(routes?: Route<Dependencies>[], options?: Partial<Options>, dependencies?: Dependencies) => Router<Dependencies>;
|
|
231
|
-
//#endregion
|
|
232
|
-
//#region src/getNavigator.d.ts
|
|
233
|
-
declare const getNavigator: <Dependencies extends DefaultDependencies = DefaultDependencies>(router: Router$1<Dependencies>) => Navigator;
|
|
234
|
-
//#endregion
|
|
235
|
-
//#region src/namespaces/RoutesNamespace/forwardChain.d.ts
|
|
236
|
-
declare function resolveForwardChain(startRoute: string, forwardMap: Record<string, string>, maxDepth?: number): string;
|
|
237
|
-
//#endregion
|
|
238
|
-
export { type Constants, type ContextNamespaceClaim, type DefaultDependencies, type DefaultParamsCallback, type DefaultRouteCallback, type DependenciesApi, type ErrorCodeKeys, type ErrorCodeToValueMap, type ErrorCodeValues, type ErrorCodes, type EventMethodMap, type EventName, type EventToNameMap, type EventToPluginMap, type EventsKeys, type ForwardToCallback, type GuardFn, type GuardFnFactory, type InterceptableMethodMap, type InterceptorFn, type LeaveFn, type LeaveState, type LifecycleApi, type LimitsConfig, type Listener, type LogCallback, type LogLevel, type LogLevelConfig, type LoggerConfig, type NavigationOptions, type Navigator, type Options, type Params, type Plugin, type PluginApi, type PluginFactory, type PluginMethod, type QueryParamsMode, type QueryParamsOptions, type Route, type RouteConfigUpdate, type RouteParams, type RouteTree, type RouteTreeState, Router, RouterError, type RouterLogger, type RouterValidator, type RoutesApi, type SimpleState, type State, type StateContext, type StateMetaInput, type SubscribeFn, type SubscribeState, type Subscription, type TransitionMeta, type TransitionPhase, type TransitionReason, type TreeChangedAdd, type TreeChangedClear, type TreeChangedEvent, type TreeChangedRemove, type TreeChangedReplace, type TreeChangedUpdate, type TreeStructuralPatch, UNKNOWN_ROUTE, type Unsubscribe, constants, createRouter, errorCodes, events, getNavigator, resolveForwardChain };
|
|
239
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
import { RouteTree } from "./engine/builder/types.js";
|
|
2
|
+
import { QueryParamsMode, QueryParamsOptions, RouteParams, RouteTreeState } from "./types/route-node-types.js";
|
|
3
|
+
import { Params, SimpleState, State, StateMetaInput, TransitionMeta, TransitionPhase, TransitionReason, Unsubscribe } from "./types/base.js";
|
|
4
|
+
import { LimitsConfig } from "./types/limits.js";
|
|
5
|
+
import { DefaultDependencies, DefaultParamsCallback, DefaultRouteCallback, ForwardToCallback, GuardFn, GuardFnFactory, LeaveFn, LeaveState, Listener, LogCallback, LogLevel, LogLevelConfig, LoggerConfig, Navigator, Options, Plugin, PluginFactory, Route, RouteConfigUpdate, RouterLogger, SubscribeFn, SubscribeState, Subscription } from "./types/router.js";
|
|
6
|
+
import { ErrorCodeKeys, ErrorCodeToValueMap, ErrorCodeValues, EventMethodMap, EventName, EventToNameMap, EventToPluginMap, EventsKeys, PluginMethod } from "./types/constants.js";
|
|
7
|
+
import { TreeChangedAdd, TreeChangedClear, TreeChangedEvent, TreeChangedRemove, TreeChangedReplace, TreeChangedUpdate, TreeStructuralPatch } from "./types/tree-changed.js";
|
|
8
|
+
import { ContextNamespaceClaim, DependenciesApi, InterceptableMethodMap, InterceptorFn, LifecycleApi, PluginApi, RoutesApi } from "./types/api.js";
|
|
9
|
+
import { NavigationOptions, StateContext } from "./types.js";
|
|
10
|
+
import { Router } from "./Router.js";
|
|
11
|
+
import { RouterValidator } from "./types/RouterValidator.js";
|
|
12
|
+
import { Constants, ErrorCodes, UNKNOWN_ROUTE, constants, errorCodes, events } from "./constants.js";
|
|
13
|
+
import { RouterError } from "./RouterError.js";
|
|
14
|
+
import { createRouter } from "./createRouter.js";
|
|
15
|
+
import { getNavigator } from "./getNavigator.js";
|
|
16
|
+
import { resolveForwardChain } from "./namespaces/RoutesNamespace/forwardChain.js";
|
|
17
|
+
export { type Constants, type ContextNamespaceClaim, type DefaultDependencies, type DefaultParamsCallback, type DefaultRouteCallback, type DependenciesApi, type ErrorCodeKeys, type ErrorCodeToValueMap, type ErrorCodeValues, type ErrorCodes, type EventMethodMap, type EventName, type EventToNameMap, type EventToPluginMap, type EventsKeys, type ForwardToCallback, type GuardFn, type GuardFnFactory, type InterceptableMethodMap, type InterceptorFn, type LeaveFn, type LeaveState, type LifecycleApi, type LimitsConfig, type Listener, type LogCallback, type LogLevel, type LogLevelConfig, type LoggerConfig, type NavigationOptions, type Navigator, type Options, type Params, type Plugin, type PluginApi, type PluginFactory, type PluginMethod, type QueryParamsMode, type QueryParamsOptions, type Route, type RouteConfigUpdate, type RouteParams, type RouteTree, type RouteTreeState, Router, RouterError, type RouterLogger, type RouterValidator, type RoutesApi, type SimpleState, type State, type StateContext, type StateMetaInput, type SubscribeFn, type SubscribeState, type Subscription, type TransitionMeta, type TransitionPhase, type TransitionReason, type TreeChangedAdd, type TreeChangedClear, type TreeChangedEvent, type TreeChangedRemove, type TreeChangedReplace, type TreeChangedUpdate, type TreeStructuralPatch, UNKNOWN_ROUTE, type Unsubscribe, constants, createRouter, errorCodes, events, getNavigator, resolveForwardChain };
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./Router-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./Router-DGUed2F4.js"),t=(t=[],n={},r={})=>new e.t(t,n,r),n=new WeakMap,r=e=>{let t=n.get(e);return t||(t=Object.freeze({navigate:e.navigate,getState:e.getState,isActiveRoute:e.isActiveRoute,canNavigateTo:e.canNavigateTo,subscribe:e.subscribe,subscribeLeave:e.subscribeLeave,isLeaveApproved:e.isLeaveApproved}),n.set(e,t)),t};exports.Router=e.t,exports.RouterError=e.n,exports.UNKNOWN_ROUTE=e.C,exports.constants=e.w,exports.createRouter=t,exports.errorCodes=e.T,exports.events=e.E,exports.getNavigator=r,exports.resolveForwardChain=e.g;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { RouteTree } from "./engine/builder/types.js";
|
|
2
|
+
import { RouteTreeState } from "./types/route-node-types.js";
|
|
3
|
+
import { Params, SimpleState, State, Unsubscribe } from "./types/base.js";
|
|
4
|
+
import { DefaultDependencies, LoggerConfig, Options, Plugin, PluginFactory, Router, RouterLogger } from "./types/router.js";
|
|
5
|
+
import { EventMethodMap, EventName } from "./types/constants.js";
|
|
6
|
+
import { TreeChangedEvent } from "./types/tree-changed.js";
|
|
7
|
+
import { NavigationOptions } from "./types.js";
|
|
8
|
+
import { RouterValidator } from "./types/RouterValidator.js";
|
|
9
|
+
import { SerializedRouterState } from "./utils/serializeRouterState.js";
|
|
10
|
+
import { DependenciesStore } from "./namespaces/DependenciesNamespace/dependenciesStore.js";
|
|
11
|
+
import { RoutesStore } from "./namespaces/RoutesNamespace/routesStore.js";
|
|
12
|
+
//#region src/internals.d.ts
|
|
13
|
+
interface RouterInternals<D extends DefaultDependencies = DefaultDependencies> {
|
|
14
|
+
readonly makeState: <P extends Params = Params>(name: string, params?: P, path?: string, meta?: Record<string, Record<string, "url" | "query">>) => State<P>;
|
|
15
|
+
readonly forwardState: <P extends Params = Params>(routeName: string, routeParams: P) => SimpleState<P>;
|
|
16
|
+
readonly buildStateResolved: (resolvedName: string, resolvedParams: Params) => RouteTreeState | undefined;
|
|
17
|
+
readonly matchPath: <P extends Params = Params>(path: string, options?: Options) => State<P> | undefined;
|
|
18
|
+
readonly getOptions: () => Options;
|
|
19
|
+
readonly addEventListener: <E extends EventName>(eventName: E, cb: Plugin[EventMethodMap[E]]) => Unsubscribe;
|
|
20
|
+
/**
|
|
21
|
+
* Route-tree mutation channel — internal access for the `getRoutesApi`
|
|
22
|
+
* wrapper. A dedicated bridge is required because the public
|
|
23
|
+
* `addEventListener<E extends EventName>` structurally rejects
|
|
24
|
+
* `"TREE_CHANGED"` (it is not in the public `EventName` union), is strict on
|
|
25
|
+
* duplicates, and exposes neither `emit` nor `listenerCount`.
|
|
26
|
+
*/
|
|
27
|
+
readonly treeChanged: {
|
|
28
|
+
readonly emit: (event: TreeChangedEvent) => void;
|
|
29
|
+
readonly subscribe: (handler: (event: TreeChangedEvent) => void) => Unsubscribe;
|
|
30
|
+
readonly listenerCount: () => number;
|
|
31
|
+
/**
|
|
32
|
+
* True while a `TREE_CHANGED` emit is on the stack — `getRoutesApi` reads it
|
|
33
|
+
* to reject reentrant route-CRUD from a `subscribeChanges` handler (#1032).
|
|
34
|
+
*/
|
|
35
|
+
readonly isEmitting: () => boolean;
|
|
36
|
+
};
|
|
37
|
+
readonly buildPath: (route: string, params?: Params) => string;
|
|
38
|
+
readonly emitTransitionError: (error: Error) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Emits `TRANSITION_SUCCESS` directly (no FSM transition) — used by
|
|
41
|
+
* `getRoutesApi().replace()` to notify `router.subscribe` listeners when a
|
|
42
|
+
* structural replace revalidates the active state (#950). Mirrors the success
|
|
43
|
+
* emission `completeTransition` / `navigateToNotFound` perform.
|
|
44
|
+
*/
|
|
45
|
+
readonly emitTransitionSuccess: (toState: State, fromState: State | undefined, opts?: NavigationOptions) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Commits the not-found (`UNKNOWN_ROUTE`) state for `path` and emits
|
|
48
|
+
* `TRANSITION_SUCCESS` — the `NavigationNamespace.navigateToNotFound`
|
|
49
|
+
* primitive. `replace()` uses it when a structural replace drops the active
|
|
50
|
+
* route, so subscribers are notified instead of the state silently clearing
|
|
51
|
+
* (#950).
|
|
52
|
+
*/
|
|
53
|
+
readonly navigateToNotFound: (path: string) => State;
|
|
54
|
+
readonly start: (path: string) => Promise<State>;
|
|
55
|
+
/**
|
|
56
|
+
* Plugin-only navigation entry point — delegates to
|
|
57
|
+
* `NavigationNamespace.navigateToState` (`getPluginApi(router).navigateToState`).
|
|
58
|
+
* Hidden from `Router`/`Navigator` to keep the userland surface minimal;
|
|
59
|
+
* see `core-types/src/api.ts` for usage docs.
|
|
60
|
+
*/
|
|
61
|
+
readonly navigateToState: (state: State, options?: NavigationOptions) => Promise<State>;
|
|
62
|
+
readonly interceptors: Map<string, ((next: (...args: any[]) => any, ...args: any[]) => any)[]>;
|
|
63
|
+
readonly setRootPath: (rootPath: string) => void;
|
|
64
|
+
readonly getRootPath: () => string;
|
|
65
|
+
readonly getTree: () => RouteTree;
|
|
66
|
+
readonly isDisposed: () => boolean;
|
|
67
|
+
validator: RouterValidator | null;
|
|
68
|
+
readonly logger: RouterLogger;
|
|
69
|
+
readonly dependenciesGetStore: () => DependenciesStore<D>;
|
|
70
|
+
readonly getCloneState: () => {
|
|
71
|
+
options: Options;
|
|
72
|
+
dependencies: Record<string, unknown>;
|
|
73
|
+
pluginFactories: PluginFactory<D>[];
|
|
74
|
+
loggerConfig: LoggerConfig;
|
|
75
|
+
};
|
|
76
|
+
readonly routeGetStore: () => RoutesStore<D>;
|
|
77
|
+
readonly getStateName: () => string | undefined;
|
|
78
|
+
readonly isTransitioning: () => boolean;
|
|
79
|
+
readonly clearState: () => void;
|
|
80
|
+
readonly setState: (state: State) => void;
|
|
81
|
+
readonly routerExtensions: {
|
|
82
|
+
keys: string[];
|
|
83
|
+
}[];
|
|
84
|
+
readonly contextClaimRecords: Set<string>;
|
|
85
|
+
/**
|
|
86
|
+
* One-shot hydration scratchpad populated by `hydrateRouter` immediately
|
|
87
|
+
* before delegating to `router.start(parsed.path)` and cleared in the
|
|
88
|
+
* matching `finally`. SSR loader plugins read this slot directly via
|
|
89
|
+
* `getInternals(router).hydrationState` to short-circuit their own loader
|
|
90
|
+
* call when the server-resolved namespace value is already present in the
|
|
91
|
+
* parsed state (#596). `null` outside of an active `hydrateRouter`
|
|
92
|
+
* invocation.
|
|
93
|
+
*/
|
|
94
|
+
hydrationState: SerializedRouterState | null;
|
|
95
|
+
}
|
|
96
|
+
declare function getInternals<D extends DefaultDependencies>(router: Router<D>): RouterInternals<D>;
|
|
97
|
+
//#endregion
|
|
98
|
+
export { RouterInternals, getInternals };
|
|
99
|
+
//# sourceMappingURL=internals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internals.d.ts","names":[],"sources":["../../src/internals.ts"],"mappings":";;;;;;;;;;;;UAyBiB,gBACf,UAAU,sBAAsB;WAEvB,YAAY,UAAU,SAAS,QACtC,cACA,SAAS,GACT,eACA,OAAO,eAAe,qCACnB,MAAM;WAEF,eAAe,UAAU,SAAS,QACzC,mBACA,aAAa,MACV,YAAY;WAER,qBACP,sBACA,gBAAgB,WACb;WAEI,YAAY,UAAU,SAAS,QACtC,cACA,UAAU,YACP,MAAM;WAEF,kBAAkB;WAElB,mBAAmB,UAAU,WACpC,WAAW,GACX,IAAI,OAAO,eAAe,QACvB;;;;;;;;WASI;aACE,OAAO,OAAO;aACd,YACP,UAAU,OAAO,8BACd;aACI;;;;;aAKA;;WAGF,YAAY,eAAe,SAAS;WAEpC,sBAAsB,OAAO;;;;;;;WAQ7B,wBACP,SAAS,OACT,WAAW,mBACX,OAAO;;;;;;;;WAUA,qBAAqB,iBAAiB;WAEtC,QAAQ,iBAAiB,QAAQ;;;;;;;WAQjC,kBACP,OAAO,OACP,UAAU,sBACP,QAAQ;WAGJ,cAAc,cAEnB,UAAU,wBAAwB;WAI7B,cAAc;WACd;WAEA,eAAe;WAEf;EAET,WAAW;WAQF,QAAQ;WAGR,4BAA4B,kBAAkB;WAM9C;IACP,SAAS;IACT,cAAc;IACd,iBAAiB,cAAc;IAK/B,cAAc;;WAIP,qBAAqB,YAAY;WAGjC;WACA;WACA;WACA,WAAW,OAAO;WAClB;IAAoB;;WACpB,qBAAqB;;;;;;;;;;EAW9B,gBAAgB;;iBAMF,aAAa,UAAU,qBACrC,QAAQ,OAAgB,KACvB,gBAAgB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=new WeakMap;function t(t){let n=e.get(t);if(!n)throw TypeError(`[real-router] Invalid router instance — not found in internals registry`);return n}function n(t,n){e.set(t,n)}function r(e,t,n){let r=t;for(let t of e){let e=r;r=(...n)=>t(e,...n)}return r(...n)}function i(e,t,n){return((...i)=>{let a=n.get(e);return!a||a.length===0?t(...i):r(a,t,i)})}function a(e,t,n){return(i,a)=>{let o=n.get(e);return!o||o.length===0?t(i,a):r(o,t,[i,a])}}exports.createBinaryInterceptable=a,exports.createInterceptable=i,exports.getInternals=t,exports.registerInternals=n;
|
|
2
|
+
//# sourceMappingURL=internals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internals.js","names":[],"sources":["../../src/internals.ts"],"sourcesContent":["import type { RouteTree } from \"./engine\";\nimport type { DependenciesStore } from \"./namespaces\";\nimport type { RoutesStore } from \"./namespaces/RoutesNamespace\";\nimport type { Router as RouterClass } from \"./Router\";\nimport type {\n DefaultDependencies,\n EventName,\n LoggerConfig,\n NavigationOptions,\n Options,\n Params,\n Plugin,\n Router as RouterInterface,\n RouterLogger,\n RouteTreeState,\n SimpleState,\n State,\n TreeChangedEvent,\n Unsubscribe,\n EventMethodMap,\n PluginFactory,\n} from \"./types\";\nimport type { RouterValidator } from \"./types/RouterValidator\";\nimport type { SerializedRouterState } from \"./utils\";\n\nexport interface RouterInternals<\n D extends DefaultDependencies = DefaultDependencies,\n> {\n readonly makeState: <P extends Params = Params>(\n name: string,\n params?: P,\n path?: string,\n meta?: Record<string, Record<string, \"url\" | \"query\">>,\n ) => State<P>;\n\n readonly forwardState: <P extends Params = Params>(\n routeName: string,\n routeParams: P,\n ) => SimpleState<P>;\n\n readonly buildStateResolved: (\n resolvedName: string,\n resolvedParams: Params,\n ) => RouteTreeState | undefined;\n\n readonly matchPath: <P extends Params = Params>(\n path: string,\n options?: Options,\n ) => State<P> | undefined;\n\n readonly getOptions: () => Options;\n\n readonly addEventListener: <E extends EventName>(\n eventName: E,\n cb: Plugin[EventMethodMap[E]],\n ) => Unsubscribe;\n\n /**\n * Route-tree mutation channel — internal access for the `getRoutesApi`\n * wrapper. A dedicated bridge is required because the public\n * `addEventListener<E extends EventName>` structurally rejects\n * `\"TREE_CHANGED\"` (it is not in the public `EventName` union), is strict on\n * duplicates, and exposes neither `emit` nor `listenerCount`.\n */\n readonly treeChanged: {\n readonly emit: (event: TreeChangedEvent) => void;\n readonly subscribe: (\n handler: (event: TreeChangedEvent) => void,\n ) => Unsubscribe;\n readonly listenerCount: () => number;\n /**\n * True while a `TREE_CHANGED` emit is on the stack — `getRoutesApi` reads it\n * to reject reentrant route-CRUD from a `subscribeChanges` handler (#1032).\n */\n readonly isEmitting: () => boolean;\n };\n\n readonly buildPath: (route: string, params?: Params) => string;\n\n readonly emitTransitionError: (error: Error) => void;\n\n /**\n * Emits `TRANSITION_SUCCESS` directly (no FSM transition) — used by\n * `getRoutesApi().replace()` to notify `router.subscribe` listeners when a\n * structural replace revalidates the active state (#950). Mirrors the success\n * emission `completeTransition` / `navigateToNotFound` perform.\n */\n readonly emitTransitionSuccess: (\n toState: State,\n fromState: State | undefined,\n opts?: NavigationOptions,\n ) => void;\n\n /**\n * Commits the not-found (`UNKNOWN_ROUTE`) state for `path` and emits\n * `TRANSITION_SUCCESS` — the `NavigationNamespace.navigateToNotFound`\n * primitive. `replace()` uses it when a structural replace drops the active\n * route, so subscribers are notified instead of the state silently clearing\n * (#950).\n */\n readonly navigateToNotFound: (path: string) => State;\n\n readonly start: (path: string) => Promise<State>;\n\n /**\n * Plugin-only navigation entry point — delegates to\n * `NavigationNamespace.navigateToState` (`getPluginApi(router).navigateToState`).\n * Hidden from `Router`/`Navigator` to keep the userland surface minimal;\n * see `core-types/src/api.ts` for usage docs.\n */\n readonly navigateToState: (\n state: State,\n options?: NavigationOptions,\n ) => Promise<State>;\n\n /* eslint-disable @typescript-eslint/no-explicit-any -- heterogeneous map: stores different InterceptorFn<M> types under different keys */\n readonly interceptors: Map<\n string,\n ((next: (...args: any[]) => any, ...args: any[]) => any)[]\n >;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n\n readonly setRootPath: (rootPath: string) => void;\n readonly getRootPath: () => string;\n\n readonly getTree: () => RouteTree;\n\n readonly isDisposed: () => boolean;\n\n validator: RouterValidator | null;\n\n // Per-router logger instance (built from `options.logger` in the Router\n // constructor). The facade reads it as `getInternals(this).logger`; namespaces\n // receive it via their deps at wiring; plugins reach it through\n // `getPluginApi(router).logger`. Replaces the former process-global singleton\n // from the standalone `@real-router/logger` package (now folded into\n // `foundation/logger`), whose `configure()` leaked across routers (#724).\n readonly logger: RouterLogger;\n\n // Dependencies (issue #172)\n readonly dependenciesGetStore: () => DependenciesStore<D>;\n\n // Clone support (issue #173, consolidated #964). One accessor for the\n // source-side snapshot a clone carries over besides the route store, so a new\n // clone-relevant subsystem is wired in a single place instead of being spread\n // across separate methods.\n readonly getCloneState: () => {\n options: Options;\n dependencies: Record<string, unknown>;\n pluginFactories: PluginFactory<D>[];\n // Resolved logger config of the base router, so a clone can build its OWN\n // logger inheriting the base's level/callback. Frozen `options` do NOT carry\n // `logger` (stripped in the constructor), so `options` above can't convey it;\n // cloneRouter merges a per-request override (traceId) over this snapshot.\n loggerConfig: LoggerConfig;\n };\n\n // Consolidated route data store (issue #174 Phase 2)\n readonly routeGetStore: () => RoutesStore<D>;\n\n // Cross-namespace state (issue #174)\n readonly getStateName: () => string | undefined;\n readonly isTransitioning: () => boolean;\n readonly clearState: () => void;\n readonly setState: (state: State) => void;\n readonly routerExtensions: { keys: string[] }[];\n readonly contextClaimRecords: Set<string>;\n\n /**\n * One-shot hydration scratchpad populated by `hydrateRouter` immediately\n * before delegating to `router.start(parsed.path)` and cleared in the\n * matching `finally`. SSR loader plugins read this slot directly via\n * `getInternals(router).hydrationState` to short-circuit their own loader\n * call when the server-resolved namespace value is already present in the\n * parsed state (#596). `null` outside of an active `hydrateRouter`\n * invocation.\n */\n hydrationState: SerializedRouterState | null;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- existential type: stores RouterInternals for all Dependencies types\nconst internals = new WeakMap<object, RouterInternals<any>>();\n\nexport function getInternals<D extends DefaultDependencies>(\n router: RouterInterface<D>,\n): RouterInternals<D> {\n const ctx = internals.get(router);\n\n if (!ctx) {\n throw new TypeError(\n \"[real-router] Invalid router instance — not found in internals registry\",\n );\n }\n\n return ctx as RouterInternals<D>;\n}\n\nexport function registerInternals<D extends DefaultDependencies>(\n router: RouterClass<D>,\n ctx: RouterInternals<D>,\n): void {\n internals.set(router, ctx);\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument -- internal chain execution: type safety enforced at public API boundary (PluginApi.addInterceptor) */\nfunction executeInterceptorChain<T>(\n interceptors: ((next: (...args: any[]) => any, ...args: any[]) => any)[],\n original: (...args: any[]) => T,\n args: any[],\n): T {\n let chain = original as (...args: any[]) => any;\n\n for (const interceptor of interceptors) {\n const prev = chain;\n\n chain = (...chainArgs: any[]) => interceptor(prev, ...chainArgs);\n }\n\n return chain(...args) as T;\n}\n\n/**\n * Variadic interceptor wrapper — wraps a function of any arity, returning the\n * same callable type `T`. Use {@link createBinaryInterceptable} instead when the\n * wrapped method takes exactly two args and the caller needs the precise\n * `(a, b) => r` signature preserved (the variadic form widens args to `any[]`).\n */\nexport function createInterceptable<T extends (...args: any[]) => any>(\n name: string,\n original: T,\n interceptors: Map<\n string,\n ((next: (...args: any[]) => any, ...args: any[]) => any)[]\n >,\n): T {\n return ((...args: any[]) => {\n const chain = interceptors.get(name);\n\n if (!chain || chain.length === 0) {\n return original(...args);\n }\n\n return executeInterceptorChain(chain, original, args);\n }) as T;\n}\n\n/**\n * Two-argument interceptor wrapper — preserves the exact `(a: A, b: B) => R`\n * signature, which the variadic {@link createInterceptable} cannot express\n * (it widens args to `any[]`). Used for the binary interceptable methods\n * `forwardState(routeName, routeParams)` and `buildPath(route, params)`.\n */\nexport function createBinaryInterceptable<A, B, R>(\n name: string,\n original: (a: A, b: B) => R,\n interceptors: Map<\n string,\n ((next: (...args: any[]) => any, ...args: any[]) => any)[]\n >,\n): (a: A, b: B) => R {\n return (arg1: A, arg2: B) => {\n const chain = interceptors.get(name);\n\n if (!chain || chain.length === 0) {\n return original(arg1, arg2);\n }\n\n return executeInterceptorChain(chain, original, [arg1, arg2]);\n };\n}\n/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument */\n"],"mappings":"AAqLA,MAAM,EAAY,IAAI,QAEtB,SAAgB,EACd,EACoB,CACpB,IAAM,EAAM,EAAU,IAAI,CAAM,EAEhC,GAAI,CAAC,EACH,MAAU,UACR,yEACF,EAGF,OAAO,CACT,CAEA,SAAgB,EACd,EACA,EACM,CACN,EAAU,IAAI,EAAQ,CAAG,CAC3B,CAGA,SAAS,EACP,EACA,EACA,EACG,CACH,IAAI,EAAQ,EAEZ,IAAK,IAAM,KAAe,EAAc,CACtC,IAAM,EAAO,EAEb,GAAS,GAAG,IAAqB,EAAY,EAAM,GAAG,CAAS,CACjE,CAEA,OAAO,EAAM,GAAG,CAAI,CACtB,CAQA,SAAgB,EACd,EACA,EACA,EAIG,CACH,QAAS,GAAG,IAAgB,CAC1B,IAAM,EAAQ,EAAa,IAAI,CAAI,EAMnC,MAJI,CAAC,GAAS,EAAM,SAAW,EACtB,EAAS,GAAG,CAAI,EAGlB,EAAwB,EAAO,EAAU,CAAI,CACtD,EACF,CAQA,SAAgB,EACd,EACA,EACA,EAImB,CACnB,OAAQ,EAAS,IAAY,CAC3B,IAAM,EAAQ,EAAa,IAAI,CAAI,EAMnC,MAJI,CAAC,GAAS,EAAM,SAAW,EACtB,EAAS,EAAM,CAAI,EAGrB,EAAwB,EAAO,EAAU,CAAC,EAAM,CAAI,CAAC,CAC9D,CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DefaultDependencies } from "../../types/router.js";
|
|
2
|
+
import { Limits } from "../../types/internal.js";
|
|
3
|
+
//#region src/namespaces/DependenciesNamespace/dependenciesStore.d.ts
|
|
4
|
+
interface DependenciesStore<Dependencies extends DefaultDependencies = DefaultDependencies> {
|
|
5
|
+
dependencies: Partial<Dependencies>;
|
|
6
|
+
limits: Limits;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { DependenciesStore };
|
|
10
|
+
//# sourceMappingURL=dependenciesStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependenciesStore.d.ts","names":[],"sources":["../../../../src/namespaces/DependenciesNamespace/dependenciesStore.ts"],"mappings":";;;UAKiB,kBACf,qBAAqB,sBAAsB;EAE3C,cAAc,QAAQ;EACtB,QAAQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependenciesStore.js","names":["DEFAULT_LIMITS"],"sources":["../../../../src/namespaces/DependenciesNamespace/dependenciesStore.ts"],"sourcesContent":["import { DEFAULT_LIMITS } from \"../../constants\";\n\nimport type { DefaultDependencies } from \"../../types\";\nimport type { Limits } from \"../../types/internal\";\n\nexport interface DependenciesStore<\n Dependencies extends DefaultDependencies = DefaultDependencies,\n> {\n dependencies: Partial<Dependencies>;\n limits: Limits;\n}\n\nexport function createDependenciesStore<\n Dependencies extends DefaultDependencies = DefaultDependencies,\n>(\n initialDependencies: Partial<Dependencies> = {},\n): DependenciesStore<Dependencies> {\n const dependencies = Object.create(null) as Partial<Dependencies>;\n\n for (const key in initialDependencies) {\n if (initialDependencies[key] !== undefined) {\n dependencies[key] = initialDependencies[key];\n }\n }\n\n return {\n dependencies,\n limits: DEFAULT_LIMITS,\n };\n}\n"],"mappings":"sCAYA,SAAgB,EAGd,EAA6C,CAAC,EACb,CACjC,IAAM,EAAe,OAAO,OAAO,IAAI,EAEvC,IAAK,IAAM,KAAO,EACZ,EAAoB,KAAS,IAAA,KAC/B,EAAa,GAAO,EAAoB,IAI5C,MAAO,CACL,eACA,OAAQA,EAAAA,cACV,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../constants.js"),t=require("../../RouterError.js"),n=require("../../routerFSM.js"),r=`TREE_CHANGED`;function i(e){return e instanceof Error?e:Error(String(e))}function a(n,r,a){return new Promise((o,s)=>{let c=()=>{let n=a.reason;s(n instanceof t.RouterError&&n.code===e.errorCodes.TRANSITION_CANCELLED?n:new t.RouterError(e.errorCodes.TRANSITION_CANCELLED,{reason:n}))};if(a.aborted){c();return}a.addEventListener(`abort`,c,{once:!0}),Promise.allSettled(n).then(e=>{if(a.removeEventListener(`abort`,c),a.aborted)return;if(r!==void 0){s(i(r));return}let t=e.find(e=>e.status===`rejected`);if(t!==void 0){s(i(t.reason));return}o()})})}var o=class{#e;#t;#n;#r;#i=[];#a=0;#o;#s;#c;#l;#u;constructor(e){this.#e=e.routerFSM,this.#t=e.emitter,this.#n=e.abortController,this.#o=void 0,this.#p()}static validateSubscribeListener(e){if(typeof e!=`function`)throw TypeError(`[router.subscribe] Expected a function. For Observable pattern use observable(router) from @real-router/rx`)}static validateSubscribeLeaveListener(e){if(typeof e!=`function`)throw TypeError(`[router.subscribeLeave] Expected a function`)}emitRouterStart(){this.#t.emit(e.events.ROUTER_START)}emitRouterStop(){this.#t.emit(e.events.ROUTER_STOP)}emitTransitionStart(t,n){this.#a++;try{this.#t.emit(e.events.TRANSITION_START,t,n)}finally{this.#a--}}emitTransitionSuccess(t,n,r){this.#a++;try{this.#t.emit(e.events.TRANSITION_SUCCESS,t,n,r)}finally{this.#a--}}emitTransitionError(t,n,r){this.#a++;try{this.#t.emit(e.events.TRANSITION_ERROR,t,n,r)}finally{this.#a--}}emitTransitionCancel(t,n){this.#a++;try{this.#t.emit(e.events.TRANSITION_CANCEL,t,n)}finally{this.#a--}}emitTransitionLeaveApprove(t,n){this.#a++;try{this.#t.emit(e.events.TRANSITION_LEAVE_APPROVE,t,n)}finally{this.#a--}}isProcessing(){return this.#a>0}emitTreeChanged(e){this.#t.emit(r,e)}isEmittingTreeChanged(){return this.#t.isDispatching(r)}subscribeTreeChanged(n){if(this.isDisposed())throw new t.RouterError(e.errorCodes.ROUTER_DISPOSED);return this.#t.on(r,e=>{n(e)})}treeChangedListenerCount(){return this.#t.listenerCount(r)}sendStart(){this.#e.send(n.routerEvents.START)}sendStop(){this.#e.send(n.routerEvents.STOP)}sendDispose(){this.#e.send(n.routerEvents.DISPOSE)}sendStarted(){this.#e.send(n.routerEvents.STARTED)}sendNavigate(e,t){this.#o=e,this.#e.send(n.routerEvents.NAVIGATE,{toState:e,fromState:t})}sendComplete(e,t,r={}){this.#e.send(n.routerEvents.COMPLETE,{toState:e,fromState:t,opts:r}),this.#o=void 0}sendLeaveApprove(e,t){this.#e.send(n.routerEvents.LEAVE_APPROVE,{toState:e,fromState:t})}sendFail(e,t,r){this.#s=e,this.#c=t,this.#l=r,this.#e.send(n.routerEvents.FAIL),this.#o=void 0}sendFailSafe(e,t,n){this.isReady()?this.sendFail(e,t,n):this.emitTransitionError(e,t,n)}sendCancel(e,t,r){this.#s=e,this.#c=t,this.#u=r,this.#e.send(n.routerEvents.CANCEL),this.#o=void 0}canBeginTransition(){return this.#e.canSend(n.routerEvents.NAVIGATE)}canStart(){return this.#e.canSend(n.routerEvents.START)}canCancel(){return this.#e.canSend(n.routerEvents.CANCEL)}isActive(){let e=this.#e.getState();return e!==n.routerStates.IDLE&&e!==n.routerStates.DISPOSED}isDisposed(){return this.#e.getState()===n.routerStates.DISPOSED}isTransitioning(){let e=this.#e.getState();return e===n.routerStates.TRANSITION_STARTED||e===n.routerStates.LEAVE_APPROVED}isLeaveApproved(){return this.#e.getState()===n.routerStates.LEAVE_APPROVED}isReady(){return this.#e.getState()===n.routerStates.READY}isStarting(){return this.#e.getState()===n.routerStates.STARTING}isIdle(){return this.#e.getState()===n.routerStates.IDLE}addEventListener(e,t){return this.#d(e,`addEventListener`),this.#t.on(e,t)}subscribe(n){if(this.isDisposed())throw new t.RouterError(e.errorCodes.ROUTER_DISPOSED);return this.#d(e.events.TRANSITION_SUCCESS,`subscribe`),this.#t.on(e.events.TRANSITION_SUCCESS,(e,t)=>n({route:e,previousRoute:t}))}subscribeLeave(n){if(this.isDisposed())throw new t.RouterError(e.errorCodes.ROUTER_DISPOSED);this.#i.push(n);let r=!1;return()=>{if(r)return;r=!0;let e=this.#i.indexOf(n);e!==-1&&this.#i.splice(e,1)}}hasLeaveListeners(){return this.#i.length>0}hasPreCommitListeners(){return this.#t.listenerCount(e.events.TRANSITION_START)>0||this.#t.listenerCount(e.events.TRANSITION_LEAVE_APPROVE)>0}awaitLeaveListeners(e,t,n){if(t===void 0)return;let r=Object.freeze({route:t,nextRoute:e,signal:n}),o,s,c=[...this.#i];this.#a++;try{for(let e of c)try{let t=e(r);t!==void 0&&typeof t.then==`function`&&(o??=[],o.push(t))}catch(e){s===void 0&&(s=e)}}finally{this.#a--}if(o===void 0){if(s!==void 0)throw i(s);return}return a(o,s,n)}clearAll(){this.#t.clearAll(),this.#i.length=0}setLimits(e){this.#t.setLimits(e)}setValidatorAccessor(e){this.#r=e}sendCancelIfPossible(e,t){let n=this.#o;!this.canCancel()||n===void 0||this.sendCancel(n,e,t)}#d(e,t){let n=this.#r?.();n&&n.eventBus.validateCountThresholds(this.#t.listenerCount(e)+1,e,t)}#f(){this.emitTransitionError(this.#s,this.#c,this.#l),this.#s=void 0,this.#c=void 0,this.#l=void 0}#p(){let e=this.#e;e.on(n.routerStates.STARTING,n.routerEvents.STARTED,()=>{this.emitRouterStart()}),e.on(n.routerStates.READY,n.routerEvents.STOP,()=>{this.emitRouterStop()});let t=e=>{this.emitTransitionStart(e.toState,e.fromState)};e.on(n.routerStates.READY,n.routerEvents.NAVIGATE,t),e.on(n.routerStates.TRANSITION_STARTED,n.routerEvents.NAVIGATE,t),e.on(n.routerStates.LEAVE_APPROVED,n.routerEvents.NAVIGATE,t),e.on(n.routerStates.TRANSITION_STARTED,n.routerEvents.LEAVE_APPROVE,e=>{this.emitTransitionLeaveApprove(e.toState,e.fromState)}),e.on(n.routerStates.LEAVE_APPROVED,n.routerEvents.COMPLETE,e=>{this.emitTransitionSuccess(e.toState,e.fromState,e.opts)});let r=()=>{let e=this.#s,t=this.#u;this.#u=void 0,this.#n(t),e!==void 0&&this.emitTransitionCancel(e,this.#c)};e.on(n.routerStates.TRANSITION_STARTED,n.routerEvents.CANCEL,r),e.on(n.routerStates.LEAVE_APPROVED,n.routerEvents.CANCEL,r),e.on(n.routerStates.LEAVE_APPROVED,n.routerEvents.FAIL,()=>{this.#f()}),e.on(n.routerStates.STARTING,n.routerEvents.FAIL,()=>{this.#f()}),e.on(n.routerStates.READY,n.routerEvents.FAIL,()=>{this.#f()}),e.on(n.routerStates.TRANSITION_STARTED,n.routerEvents.FAIL,()=>{this.#f()})}};exports.EventBusNamespace=o;
|
|
2
|
+
//# sourceMappingURL=EventBusNamespace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventBusNamespace.js","names":["RouterError","errorCodes","#fsm","#emitter","#abortController","#leaveListeners","#currentToState","#setupFSMActions","events","#dispatchDepth","routerEvents","#pendingToState","#pendingFromState","#pendingError","#pendingCancelReason","routerStates","#checkListenerThreshold","#getValidator","#emitPendingError"],"sources":["../../../../src/namespaces/EventBusNamespace/EventBusNamespace.ts"],"sourcesContent":["// packages/core/src/namespaces/EventBusNamespace/EventBusNamespace.ts\n\nimport { errorCodes, events } from \"../../constants\";\nimport { RouterError } from \"../../RouterError\";\nimport { routerEvents, routerStates } from \"../../routerFSM\";\n\nimport type { EventBusOptions } from \"./types\";\nimport type { EventEmitter } from \"../../foundation/event-emitter\";\nimport type { FSM } from \"../../foundation/fsm\";\nimport type { RouterEvent, RouterPayloads, RouterState } from \"../../routerFSM\";\nimport type {\n EventName,\n LeaveFn,\n LeaveState,\n NavigationOptions,\n Plugin,\n State,\n SubscribeFn,\n TreeChangedEvent,\n Unsubscribe,\n EventMethodMap,\n} from \"../../types\";\nimport type { RouterEventMap } from \"../../types/internal\";\nimport type { RouterValidator } from \"../../types/RouterValidator\";\n\n/**\n * Internal-only event key for route-tree mutations. Lives on the same\n * `EventEmitter` as the 7 transition events but never enters the public\n * `EventName` union — reachable only through\n * `getRoutesApi(router).subscribeChanges()`.\n */\nconst TREE_CHANGED = \"TREE_CHANGED\";\n\nfunction ensureError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value));\n}\n\nfunction settleLeavePromises(\n promises: Promise<void>[],\n firstSyncError: unknown,\n signal: AbortSignal,\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n // #1197 — canonicalize the abort outcome: reject with a\n // `RouterError(TRANSITION_CANCELLED)` carrying the external reason, so the\n // no-guards leave path classifies identically to the guard path (no raw\n // reject, no spurious TRANSITION_ERROR). Internal sources\n // (supersede/stop/dispose) already abort with such a RouterError — thread it\n // through unchanged so the #943 reason is preserved.\n const onAbort = (): void => {\n const reason: unknown = signal.reason;\n\n reject(\n reason instanceof RouterError &&\n reason.code === errorCodes.TRANSITION_CANCELLED\n ? reason\n : new RouterError(errorCodes.TRANSITION_CANCELLED, { reason }),\n );\n };\n\n if (signal.aborted) {\n onAbort();\n\n return;\n }\n\n // Stryker disable next-line ObjectLiteral,BooleanLiteral: equivalent — `{ once: true }` is redundant: onAbort fires at most once (a signal aborts once) and the success path explicitly removeEventListener's it, so dropping `once` is unobservable. StringLiteral sibling stays live (the \"abort\" event name is killed).\n signal.addEventListener(\"abort\", onAbort, { once: true });\n\n void Promise.allSettled(promises).then((results) => {\n // Stryker disable next-line StringLiteral: equivalent — this cleanup name is redundant: onAbort is registered with `{ once: true }` and the per-navigation signal is discarded unaborted on success, so failing to remove the listener leaks nothing observable.\n signal.removeEventListener(\"abort\", onAbort);\n\n // Stryker disable next-line BlockStatement: equivalent — emptying the post-allSettled abort-race early-return falls through to resolve()/reject(), but the abort handler already settled the promise, so the extra settle is a no-op. CE sibling stays live (→true hangs the pipeline = killed via timeout).\n if (signal.aborted) {\n // Race lost to abort — the abort handler already rejected; do nothing\n return;\n }\n\n if (firstSyncError !== undefined) {\n reject(ensureError(firstSyncError));\n\n return;\n }\n\n const rejected = results.find(\n (result): result is PromiseRejectedResult =>\n result.status === \"rejected\",\n );\n\n if (rejected !== undefined) {\n reject(ensureError(rejected.reason));\n\n return;\n }\n\n resolve();\n });\n });\n}\n\nexport class EventBusNamespace {\n readonly #fsm: FSM<RouterState, RouterEvent, null, RouterPayloads>;\n readonly #emitter: EventEmitter<RouterEventMap>;\n // Effect of the FSM CANCEL action: aborts the in-flight navigation's\n // controller. Wired to NavigationNamespace.\n readonly #abortController: (reason?: unknown) => void;\n // Lazy accessor for the opt-in RouterValidator (wired by wireNamespaces).\n // Returns `null` until validation-plugin is registered — so the proactive\n // listener-count threshold (#1188) costs the no-plugin path nothing.\n #getValidator: (() => RouterValidator | null) | undefined;\n readonly #leaveListeners: LeaveFn[] = [];\n\n // Depth of the synchronous transition-dispatch window — elevated while a\n // transition event is being emitted (`emitTransition*`) or a `subscribeLeave`\n // listener batch runs. `isProcessing()` reads it so the navigation facade can\n // reject a synchronous reentrant navigate() from inside a transition listener\n // with REENTRANT_NAVIGATION (RFC navigation-cancellation-unification §4). A\n // counter (not a boolean) tolerates legitimately-nested transition emits. The\n // ceiling-bounded \"allow reentrant navigate, throw RecursionDepthError at\n // `maxEventDepth`\" behaviour (#935/#945) is gone: such a navigate now throws\n // REENTRANT_NAVIGATION at depth 1, before it can recurse. (The emitter's old\n // `maxEventDepth` depth-bound is gone too — re-entrant emits are coalesced to a\n // no-op at the emitter, #1033 — so no event can re-enter its own dispatch.)\n #dispatchDepth = 0;\n\n #currentToState: State | undefined;\n #pendingToState: State | undefined;\n #pendingFromState: State | undefined;\n #pendingError: unknown;\n // Abort reason for the pending CANCEL — read by handleCancel, set by sendCancel.\n #pendingCancelReason: unknown;\n\n constructor(options: EventBusOptions) {\n this.#fsm = options.routerFSM;\n this.#emitter = options.emitter;\n this.#abortController = options.abortController;\n this.#currentToState = undefined;\n this.#setupFSMActions();\n }\n\n static validateSubscribeListener(listener: unknown): void {\n if (typeof listener !== \"function\") {\n throw new TypeError(\n \"[router.subscribe] Expected a function. \" +\n \"For Observable pattern use observable(router) from @real-router/rx\",\n );\n }\n }\n\n /**\n * Validates the `subscribeLeave` listener. Unlike\n * {@link validateSubscribeListener}, the error carries **no**\n * `@real-router/rx` hint — rx exposes the Observable pattern for *success*\n * transitions (`observable(router)`, `state$`, `events$`), not for leave\n * events, so steering leave-listener misuse toward rx would mislead. The\n * asymmetry is intentional (mirrored in `core/CLAUDE.md`).\n */\n static validateSubscribeLeaveListener(listener: unknown): void {\n if (typeof listener !== \"function\") {\n throw new TypeError(\"[router.subscribeLeave] Expected a function\");\n }\n }\n\n emitRouterStart(): void {\n this.#emitter.emit(events.ROUTER_START);\n }\n\n emitRouterStop(): void {\n this.#emitter.emit(events.ROUTER_STOP);\n }\n\n emitTransitionStart(toState: State, fromState?: State): void {\n this.#dispatchDepth++;\n try {\n this.#emitter.emit(events.TRANSITION_START, toState, fromState);\n } finally {\n this.#dispatchDepth--;\n }\n }\n\n emitTransitionSuccess(\n toState: State,\n fromState?: State,\n opts?: NavigationOptions,\n ): void {\n this.#dispatchDepth++;\n try {\n this.#emitter.emit(events.TRANSITION_SUCCESS, toState, fromState, opts);\n } finally {\n this.#dispatchDepth--;\n }\n }\n\n emitTransitionError(\n toState?: State,\n fromState?: State,\n error?: RouterError,\n ): void {\n this.#dispatchDepth++;\n try {\n this.#emitter.emit(events.TRANSITION_ERROR, toState, fromState, error);\n } finally {\n this.#dispatchDepth--;\n }\n }\n\n emitTransitionCancel(toState: State, fromState?: State): void {\n this.#dispatchDepth++;\n try {\n this.#emitter.emit(events.TRANSITION_CANCEL, toState, fromState);\n } finally {\n this.#dispatchDepth--;\n }\n }\n\n emitTransitionLeaveApprove(toState: State, fromState?: State): void {\n this.#dispatchDepth++;\n try {\n this.#emitter.emit(events.TRANSITION_LEAVE_APPROVE, toState, fromState);\n } finally {\n this.#dispatchDepth--;\n }\n }\n\n /**\n * True while a transition event is being dispatched synchronously — an\n * `emitTransition*` call or a `subscribeLeave` listener batch is on the stack.\n * The navigation facade reads this to reject a synchronous reentrant\n * navigate() from inside a transition listener (RFC §4).\n */\n isProcessing(): boolean {\n return this.#dispatchDepth > 0;\n }\n\n /**\n * Emits the internal `TREE_CHANGED` event after a structural route-tree\n * mutation. Reuses the shared `EventEmitter` — so re-entrancy coalescing\n * (#1033) and per-listener error isolation (`onListenerError`) apply\n * automatically.\n */\n emitTreeChanged(event: TreeChangedEvent): void {\n this.#emitter.emit(TREE_CHANGED, event);\n }\n\n /**\n * True while a `TREE_CHANGED` event is being dispatched synchronously.\n * Delegates to the emitter's own in-flight tracking (#1034) — `getRoutesApi`\n * reads this to reject reentrant route-CRUD from a `subscribeChanges` handler\n * (#1032).\n */\n isEmittingTreeChanged(): boolean {\n return this.#emitter.isDispatching(TREE_CHANGED);\n }\n\n /**\n * Subscribes to `TREE_CHANGED`. **Lenient** duplicate semantics (mirrors\n * {@link subscribe}): each call wraps the handler in a fresh closure, so N\n * registrations of the same reference produce N independent subscriptions.\n */\n subscribeTreeChanged(\n handler: (event: TreeChangedEvent) => void,\n ): Unsubscribe {\n // Same disposed-state enforcement as subscribe()/subscribeLeave() (#946),\n // completing the guard across all three subscription primitives — extended\n // here to the internal route-tree channel (#982). A `subscribeChanges`\n // reference bound before dispose() (`const s = routes.subscribeChanges\n // .bind(routes)`) reaches this method via the getRoutesApi delegate, which\n // — unlike its add/remove/update siblings — does not itself check\n // isDisposed(). Without this guard, `emitter.on` would re-register a\n // TREE_CHANGED listener that can never fire (clearAll already ran, the FSM\n // is DISPOSED, the route tree is torn down, no future emit) — a silent\n // no-op, the internal-channel counterpart of the #946 hazard.\n if (this.isDisposed()) {\n throw new RouterError(errorCodes.ROUTER_DISPOSED);\n }\n\n return this.#emitter.on(TREE_CHANGED, (event: TreeChangedEvent) => {\n handler(event);\n });\n }\n\n /** Number of active `TREE_CHANGED` listeners (drives conditional emit). */\n treeChangedListenerCount(): number {\n return this.#emitter.listenerCount(TREE_CHANGED);\n }\n\n sendStart(): void {\n this.#fsm.send(routerEvents.START);\n }\n\n sendStop(): void {\n this.#fsm.send(routerEvents.STOP);\n }\n\n sendDispose(): void {\n this.#fsm.send(routerEvents.DISPOSE);\n }\n\n sendStarted(): void {\n this.#fsm.send(routerEvents.STARTED);\n }\n\n sendNavigate(toState: State, fromState?: State): void {\n this.#currentToState = toState;\n // Table-driven: the FSM action emits TRANSITION_START (#1169 D-full). A\n // NAVIGATE that the table rejects is a no-op — the FSM never leaves an\n // invalid state and no event fires.\n this.#fsm.send(routerEvents.NAVIGATE, { toState, fromState });\n }\n\n sendComplete(\n state: State,\n fromState?: State,\n opts: NavigationOptions = {},\n ): void {\n // Table-driven: the FSM action emits TRANSITION_SUCCESS (#1169 D-full).\n // COMPLETE from IDLE/DISPOSED (a listener stopped/disposed mid-transition)\n // is a table no-op — no resurrection, no phantom success emit.\n this.#fsm.send(routerEvents.COMPLETE, { toState: state, fromState, opts });\n\n // Nav committed — clear so a later stop()/dispose() cannot cancel a finished\n // navigation. Unconditional now that synchronous reentrant navigate is banned\n // (RFC §4): nothing can replace #currentToState during the emit above, so the\n // #308 reentrant-preserve guard is no longer needed.\n this.#currentToState = undefined;\n }\n\n sendLeaveApprove(toState: State, fromState?: State): void {\n // Table-driven: the FSM action emits TRANSITION_LEAVE_APPROVE (#1169 D-full).\n // LEAVE_APPROVE from IDLE/DISPOSED is a table no-op — no resurrection.\n this.#fsm.send(routerEvents.LEAVE_APPROVE, { toState, fromState });\n }\n\n sendFail(toState?: State, fromState?: State, error?: unknown): void {\n this.#pendingToState = toState;\n this.#pendingFromState = fromState;\n this.#pendingError = error;\n this.#fsm.send(routerEvents.FAIL);\n\n // Nav failed — clear (unconditional; synchronous reentrant navigate is\n // banned (RFC §4), so nothing replaces #currentToState during the emit).\n this.#currentToState = undefined;\n }\n\n /**\n * Surfaces a `TRANSITION_ERROR` for callers that do **not** know — or do not\n * control — the current FSM state: the plugin-facing `emitTransitionError`\n * primitive (`getPluginApi`), the dispose chain, and validator / same-state\n * rejections. It is the state-agnostic counterpart to {@link sendFail}.\n *\n * **What \"Safe\" means here.** The error event is never *dropped*, whatever the\n * FSM state — it does **not** mean the method catches every error. Errors\n * thrown *inside* a `TRANSITION_ERROR` listener are isolated by the\n * `EventEmitter`'s per-listener `onListenerError` sink, not by this method.\n *\n * **Why it branches on its own FSM state.** When the FSM is settled in `READY`\n * (no transition in flight) it routes through the FSM `FAIL` action via\n * {@link sendFail}, so the error rides the normal FSM-driven emit. Otherwise —\n * the router may be starting, mid-transition, or torn down — it emits\n * `TRANSITION_ERROR` directly: a fire-and-forget error report from an unknown\n * state must not drive a second FSM transition that could collide with an\n * in-flight one. Both branches guarantee the event reaches subscribers.\n */\n sendFailSafe(toState?: State, fromState?: State, error?: unknown): void {\n if (this.isReady()) {\n this.sendFail(toState, fromState, error);\n } else {\n this.emitTransitionError(toState, fromState, error as RouterError);\n }\n }\n\n sendCancel(toState: State, fromState?: State, reason?: unknown): void {\n this.#pendingToState = toState;\n this.#pendingFromState = fromState;\n this.#pendingCancelReason = reason;\n this.#fsm.send(routerEvents.CANCEL);\n\n // Nav cancelled — clear (unconditional; synchronous reentrant navigate is\n // banned (RFC §4), so nothing replaces #currentToState during the emit).\n this.#currentToState = undefined;\n }\n\n canBeginTransition(): boolean {\n return this.#fsm.canSend(routerEvents.NAVIGATE);\n }\n\n canStart(): boolean {\n return this.#fsm.canSend(routerEvents.START);\n }\n\n canCancel(): boolean {\n return this.#fsm.canSend(routerEvents.CANCEL);\n }\n\n isActive(): boolean {\n const fsmState = this.#fsm.getState();\n\n return fsmState !== routerStates.IDLE && fsmState !== routerStates.DISPOSED;\n }\n\n isDisposed(): boolean {\n return this.#fsm.getState() === routerStates.DISPOSED;\n }\n\n isTransitioning(): boolean {\n const state = this.#fsm.getState();\n\n return (\n state === routerStates.TRANSITION_STARTED ||\n state === routerStates.LEAVE_APPROVED\n );\n }\n\n isLeaveApproved(): boolean {\n return this.#fsm.getState() === routerStates.LEAVE_APPROVED;\n }\n\n isReady(): boolean {\n return this.#fsm.getState() === routerStates.READY;\n }\n\n isStarting(): boolean {\n return this.#fsm.getState() === routerStates.STARTING;\n }\n\n isIdle(): boolean {\n return this.#fsm.getState() === routerStates.IDLE;\n }\n\n /**\n * Plugin-author API for subscribing to internal router events.\n *\n * @remarks\n *\n * **Duplicate-registration semantics — strict (throws).** Passing the same\n * callback reference twice for the same event throws\n * `Error(\"Duplicate listener for ...\")` from the underlying `EventEmitter`.\n * This is loud-on-misuse by design: plugin code is expected to register\n * each callback once. The contract differs from {@link subscribe} /\n * {@link subscribeLeave}, which are end-user surfaces and silently accept\n * duplicates.\n */\n addEventListener<E extends EventName>(\n eventName: E,\n cb: Plugin[EventMethodMap[E]],\n ): Unsubscribe {\n this.#checkListenerThreshold(eventName, \"addEventListener\");\n\n return this.#emitter.on(\n eventName,\n cb as (...args: RouterEventMap[typeof eventName]) => void,\n );\n }\n\n /**\n * End-user / UI-binding API for subscribing to successful transitions.\n *\n * @remarks\n *\n * **Duplicate-registration semantics — independent.** Each call wraps\n * `listener` in a fresh closure and registers it as a distinct internal\n * slot. `router.subscribe(fn)` twice produces **two** active subscriptions;\n * `fn` fires twice per `TRANSITION_SUCCESS`. The returned `Unsubscribe` is\n * paired with its specific call — invoking it removes exactly that\n * registration.\n *\n * This contract differs from {@link addEventListener} (plugin API, throws\n * on duplicate). End-user code that wants idempotent registration must\n * gate itself, e.g. `if (!unsub) unsub = router.subscribe(fn);`.\n */\n subscribe(listener: SubscribeFn): Unsubscribe {\n // Enforce the disposed state HERE, not only on the facade. A reference\n // bound before dispose() (`const s = router.subscribe.bind(router)`)\n // bypasses the facade's #markDisposed swap and reaches this method\n // directly. Without this guard, `emitter.on` would silently re-register a\n // listener that can never fire (clearAll already ran, FSM is DISPOSED, no\n // future emit) — a silent no-op / stuck-UI hazard (#946).\n if (this.isDisposed()) {\n throw new RouterError(errorCodes.ROUTER_DISPOSED);\n }\n\n this.#checkListenerThreshold(events.TRANSITION_SUCCESS, \"subscribe\");\n\n // `subscribe` is fire-and-forget; the listener's return value is ignored at\n // the type level (`SubscribeFn` is `=> void`). A void-typed async listener\n // still returns a rejecting Promise at runtime, so return it to the emitter,\n // whose central isolation routes the rejection to the same `onListenerError`\n // sink a sync throw flows through — instead of leaking an `unhandledRejection`\n // (fatal under `--unhandled-rejections=strict`, the Node 22+ default). This\n // is #944, now folded into the emitter's central #1412 async isolation — the\n // former per-site `.catch` here is redundant (symmetric with `subscribeLeave`,\n // which isolates via `Promise.allSettled`).\n return this.#emitter.on(\n events.TRANSITION_SUCCESS,\n (toState: State, fromState?: State) => {\n // Return the listener's runtime value to the emitter so its central\n // isolation catches an async listener's rejection (#944/#1412). Read the\n // void-typed result into `unknown` first — a returned `void` expression\n // is forbidden, but returning the read `unknown` is fine.\n // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression -- read the void-typed listener's runtime value so it can be returned for central async isolation (#944/#1412)\n const result: unknown = listener({\n route: toState,\n previousRoute: fromState,\n });\n\n return result;\n },\n );\n }\n\n /**\n * End-user / UI-binding API for subscribing to **approved** route departures\n * (`LEAVE_APPROVED` phase): all `canDeactivate` guards have passed, but the\n * departure is **tentative, not committed** — an activation (`canActivate`)\n * guard can still reject (or the target route be removed mid-transition),\n * leaving the user on the current route (#932). Treat the leave as tentative\n * for non-idempotent side-effects and use the payload `signal` (which aborts\n * with the failure reason, #943) to roll back when the navigation does not\n * commit. Async listeners block the activation phase.\n *\n * @remarks\n *\n * **Duplicate-registration semantics — independent.** Each call pushes\n * `listener` onto the internal array; `router.subscribeLeave(fn)` twice\n * produces two entries and `fn` fires twice per leave. Each returned\n * `Unsubscribe` is **idempotent** (a `removed` flag, #1349) and removes\n * exactly ONE entry — the first still matching the reference (`indexOf`\n * semantic). So a repeated call of one unsubscribe is a true no-op and does\n * **not** touch the other registration; N subscribes + M *distinct*\n * unsubscribes leave N − M entries. Which physical entry survives is\n * irrelevant — the reference is the same.\n *\n * Contract differs from {@link addEventListener} (throws on duplicate).\n * For idempotent *registration* (one active subscription), gate at the call site.\n */\n subscribeLeave(listener: LeaveFn): Unsubscribe {\n // Same disposed-state enforcement as subscribe() (#946): a pre-bound\n // reference would otherwise push onto #leaveListeners after dispose() and\n // silently never fire (FSM is DISPOSED, no LEAVE_APPROVE emit).\n if (this.isDisposed()) {\n throw new RouterError(errorCodes.ROUTER_DISPOSED);\n }\n\n this.#leaveListeners.push(listener);\n\n // Idempotency flag (#1349), mirroring extendRouter / addInterceptor (#1198).\n // Without it, a double call would `indexOf(listener)` again and splice a\n // DUPLICATE registration of the same fn — silently deactivating another\n // subscriber whose own unsubscribe was never called. The `Unsubscribe`\n // contract names subscribeLeave as idempotent. (Unlike addInterceptor, the\n // `idx !== -1` guard stays: `dispose()` empties `#leaveListeners` via\n // `clearAll`, so an unsubscribe called after dispose reaches this with\n // idx === -1.)\n let removed = false;\n\n return () => {\n if (removed) {\n return;\n }\n\n removed = true;\n\n const idx = this.#leaveListeners.indexOf(listener);\n\n if (idx !== -1) {\n this.#leaveListeners.splice(idx, 1);\n }\n };\n }\n\n hasLeaveListeners(): boolean {\n return this.#leaveListeners.length > 0;\n }\n\n /**\n * True when a plugin listener runs in a PRE-COMMIT transition window where a\n * synchronous `stop()`/`dispose()` can supersede the in-flight navigation\n * before it commits — i.e. `onTransitionStart` (TRANSITION_START) or\n * `onTransitionLeaveApprove` (TRANSITION_LEAVE_APPROVE). (`subscribeLeave` is\n * tracked separately via `hasLeaveListeners`; `onTransitionSuccess` fires\n * post-commit and cannot cancel.) Read into the pre-`startTransition` liveness\n * snapshot so the commit-gate (#1169) fires for these windows too.\n */\n hasPreCommitListeners(): boolean {\n return (\n this.#emitter.listenerCount(events.TRANSITION_START) > 0 ||\n this.#emitter.listenerCount(events.TRANSITION_LEAVE_APPROVE) > 0\n );\n }\n\n awaitLeaveListeners(\n toState: State,\n fromState: State | undefined,\n signal: AbortSignal,\n ): Promise<void> | undefined {\n if (fromState === undefined) {\n return undefined;\n }\n\n // Freeze the payload wrapper so listeners cannot mutate it (`payload.route`\n // is already deep-frozen via the State immutability invariant; this closes\n // the wrapper-mutation gap surfaced by audit `probe-05-payload-frozen`).\n const leaveState: LeaveState = Object.freeze({\n route: fromState,\n nextRoute: toState,\n signal,\n });\n\n let promises: Promise<void>[] | undefined;\n let firstSyncError: unknown;\n\n // Snapshot before iteration — a listener that reentrantly calls\n // `subscribeLeave(newFn)` or its own `unsubscribe()` must not affect the\n // current emit cycle. Symmetric with the EventEmitter snapshot invariant\n // (PR #666 / #659).\n const snapshot = [...this.#leaveListeners];\n\n // Elevated across the SYNC leave-listener dispatch: `isProcessing()` reads\n // it, so a sync subscribeLeave listener that calls navigate() is rejected\n // with REENTRANT_NAVIGATION at the facade (RFC §4). The `finally` restores it\n // before any async tail (returned promise) runs, so a DEFERRED navigate from\n // an async listener (after its first `await`) sees depth 0 and is allowed.\n this.#dispatchDepth++;\n\n try {\n for (const listener of snapshot) {\n try {\n const result = listener(leaveState);\n\n if (result !== undefined && typeof result.then === \"function\") {\n promises ??= [];\n promises.push(result);\n }\n } catch (error: unknown) {\n if (firstSyncError === undefined) {\n firstSyncError = error;\n }\n }\n }\n } finally {\n this.#dispatchDepth--;\n }\n\n if (promises === undefined) {\n if (firstSyncError !== undefined) {\n throw ensureError(firstSyncError);\n }\n\n return undefined;\n }\n\n return settleLeavePromises(promises, firstSyncError, signal);\n }\n\n clearAll(): void {\n this.#emitter.clearAll();\n this.#leaveListeners.length = 0;\n }\n\n setLimits(limits: { maxListeners: number; warnListeners: number }): void {\n this.#emitter.setLimits(limits);\n }\n\n /**\n * Injects the lazy validator accessor (wireNamespaces), mirroring\n * `PluginsNamespace` / `RouteLifecycleNamespace`. The closure reads the live\n * `RouterInternals.validator`, so a validation-plugin registered AFTER wiring\n * is still observed on the next `subscribe` / `addEventListener`.\n */\n setValidatorAccessor(getValidator: () => RouterValidator | null): void {\n this.#getValidator = getValidator;\n }\n\n // Single guarded entry point for routing a cancel into the FSM `CANCEL` action\n // — used by every source: stop/dispose (RouterLifecycle) pass no reason;\n // supersede / external `opts.signal` (via the wiring `cancelNavigation` dep)\n // pass the abort reason (#943). `canCancel()` makes it a no-op outside a\n // cancellable FSM state (#1034: was a second, unguarded `cancelNavigation` path).\n sendCancelIfPossible(fromState: State | undefined, reason?: unknown): void {\n const toState = this.#currentToState;\n\n if (!this.canCancel() || toState === undefined) {\n return;\n }\n\n this.sendCancel(toState, fromState, reason);\n }\n\n /**\n * Proactive listener-count threshold (#1188) — mirrors the plugins /\n * lifecycle / dependencies counters. Opt-in: the emitter's per-event count is\n * read ONLY when the validator is installed, so the bare-core hot path pays\n * nothing. `count` is the POST-add size (`listenerCount + 1`), matching\n * `RouteLifecycleNamespace`'s `count + 1`, so warn/error fire exactly when the\n * new listener reaches the threshold. Core keeps the emitter's bare-`Error`\n * hard cap; this only surfaces an actionable signal well before it.\n */\n #checkListenerThreshold(eventName: EventName, methodName: string): void {\n const validator = this.#getValidator?.();\n\n if (validator) {\n validator.eventBus.validateCountThresholds(\n this.#emitter.listenerCount(eventName) + 1,\n eventName,\n methodName,\n );\n }\n }\n\n #emitPendingError(): void {\n this.emitTransitionError(\n this.#pendingToState,\n this.#pendingFromState,\n this.#pendingError as RouterError | undefined,\n );\n\n // Clear the pending payload once this FAIL action has consumed it. `#pending*`\n // is only meaningful in the window between the sendFail()/sendFailSafe() that\n // sets it and this emit; keeping it afterwards pins a stale State/RouterError\n // on the instance and leaves an implicit \"valid only in this window\" coupling\n // (#949). Hygiene only — every consumer overwrites the fields before\n // re-reading (handleCancel reads what its own sendCancel just set), so there\n // is no observable behaviour change.\n this.#pendingToState = undefined;\n this.#pendingFromState = undefined;\n this.#pendingError = undefined;\n }\n\n #setupFSMActions(): void {\n const fsm = this.#fsm;\n\n fsm.on(routerStates.STARTING, routerEvents.STARTED, () => {\n this.emitRouterStart();\n });\n\n fsm.on(routerStates.READY, routerEvents.STOP, () => {\n this.emitRouterStop();\n });\n\n // NAVIGATE / LEAVE_APPROVE / COMPLETE emit their transition event as the FSM\n // action (payload = the transition states), so `send()` from an invalid\n // state (e.g. COMPLETE from IDLE after a listener's stop()/dispose()) is a\n // table no-op that emits nothing — the FSM table is the sole authority over\n // state, no `forceState` resurrection (#1169 D-full). NAVIGATE fires from\n // READY plus the TRANSITION_STARTED / LEAVE_APPROVED self-loops (supersede).\n const emitNavigate = (payload: RouterPayloads[\"NAVIGATE\"]): void => {\n this.emitTransitionStart(payload.toState, payload.fromState);\n };\n\n fsm.on(routerStates.READY, routerEvents.NAVIGATE, emitNavigate);\n fsm.on(\n routerStates.TRANSITION_STARTED,\n routerEvents.NAVIGATE,\n emitNavigate,\n );\n fsm.on(routerStates.LEAVE_APPROVED, routerEvents.NAVIGATE, emitNavigate);\n\n fsm.on(\n routerStates.TRANSITION_STARTED,\n routerEvents.LEAVE_APPROVE,\n (payload) => {\n this.emitTransitionLeaveApprove(payload.toState, payload.fromState);\n },\n );\n\n fsm.on(routerStates.LEAVE_APPROVED, routerEvents.COMPLETE, (payload) => {\n this.emitTransitionSuccess(\n payload.toState,\n payload.fromState,\n payload.opts,\n );\n });\n\n const handleCancel = () => {\n const toState = this.#pendingToState;\n const reason = this.#pendingCancelReason;\n\n this.#pendingCancelReason = undefined;\n\n // (RFC navigation-cancellation-unification §5): the FSM CANCEL\n // action OWNS the abort. Aborting the in-flight controller wakes the parked\n // async pipeline (#1018) and rejects navigate() — the post-race local\n // isActive() sees signal.aborted; `reason` surfaces as the leave signal's\n // reason (#943). Order: (i) abort (wake) then (ii) emit TRANSITION_CANCEL.\n // No cycle: onInternalAbort is wake-only, it does not re-enter cancel.\n this.#abortController(reason);\n\n /* v8 ignore next -- @preserve: #pendingToState guaranteed set by sendCancel before send() */\n if (toState === undefined) {\n return;\n }\n\n this.emitTransitionCancel(toState, this.#pendingFromState);\n };\n\n fsm.on(routerStates.TRANSITION_STARTED, routerEvents.CANCEL, handleCancel);\n fsm.on(routerStates.LEAVE_APPROVED, routerEvents.CANCEL, handleCancel);\n\n fsm.on(routerStates.LEAVE_APPROVED, routerEvents.FAIL, () => {\n this.#emitPendingError();\n });\n\n fsm.on(routerStates.STARTING, routerEvents.FAIL, () => {\n this.#emitPendingError();\n });\n\n fsm.on(routerStates.READY, routerEvents.FAIL, () => {\n this.#emitPendingError();\n });\n\n fsm.on(routerStates.TRANSITION_STARTED, routerEvents.FAIL, () => {\n this.#emitPendingError();\n });\n }\n}\n"],"mappings":"wGA+BM,EAAe,eAErB,SAAS,EAAY,EAAuB,CAC1C,OAAO,aAAiB,MAAQ,EAAY,MAAM,OAAO,CAAK,CAAC,CACjE,CAEA,SAAS,EACP,EACA,EACA,EACe,CACf,OAAO,IAAI,SAAe,EAAS,IAAW,CAO5C,IAAM,MAAsB,CAC1B,IAAM,EAAkB,EAAO,OAE/B,EACE,aAAkBA,EAAAA,aAChB,EAAO,OAASC,EAAAA,WAAW,qBACzB,EACA,IAAID,EAAAA,YAAYC,EAAAA,WAAW,qBAAsB,CAAE,QAAO,CAAC,CACjE,CACF,EAEA,GAAI,EAAO,QAAS,CAClB,EAAQ,EAER,MACF,CAGA,EAAO,iBAAiB,QAAS,EAAS,CAAE,KAAM,EAAK,CAAC,EAExD,QAAa,WAAW,CAAQ,CAAC,CAAC,KAAM,GAAY,CAKlD,GAHA,EAAO,oBAAoB,QAAS,CAAO,EAGvC,EAAO,QAET,OAGF,GAAI,IAAmB,IAAA,GAAW,CAChC,EAAO,EAAY,CAAc,CAAC,EAElC,MACF,CAEA,IAAM,EAAW,EAAQ,KACtB,GACC,EAAO,SAAW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=require("../../transitionPath.js"),r=require("../../RouterError.js"),i=require("./constants.js"),a=require("./transition/completeTransition.js"),o=require("./transition/errorHandling.js"),s=require("./transition/guardPhase.js"),c=Object.freeze([e.constants.UNKNOWN_ROUTE]),l=Object.freeze({replace:!0});function u(t,n){return n?.name===e.constants.UNKNOWN_ROUTE&&!t.replace?{...t,replace:!0}:t}function d(e,t,n){return!!e&&!t.reload&&!t.force&&e.path===n.path}var f=class{lastSyncResolved=!1;lastSyncRejected=!1;#e;#t=null;#n=0;setDependencies(e){this.#e=e}navigate(e,t,n){this.lastSyncResolved=!1;let r=this.#e;if(!r.canNavigate())return this.lastSyncRejected=!0,i.CACHED_NOT_STARTED_REJECTION;let a;try{a=r.buildNavigateState(e,t)}catch(e){return Promise.reject(e)}return a?this.#r(a,n):(r.emitTransitionError(void 0,r.getState(),i.CACHED_ROUTE_NOT_FOUND_ERROR),this.lastSyncRejected=!0,i.CACHED_ROUTE_NOT_FOUND_REJECTION)}navigateToState(n,a){this.lastSyncResolved=!1;let o=this.#e;if(!o.canNavigate())return this.lastSyncRejected=!0,i.CACHED_NOT_STARTED_REJECTION;if(n.name!==e.constants.UNKNOWN_ROUTE&&!o.hasRoute(n.name)){let t=new r.RouterError(e.errorCodes.ROUTE_NOT_FOUND,{routeName:n.name});return o.emitTransitionError(void 0,o.getState(),t),Promise.reject(t)}let s={name:n.name,params:n.params,path:n.path,context:{...n.context}},c=t.getStateMetaParams(n);return c!==void 0&&t.setStateMetaParams(s,c),this.#r(s,a)}navigateToDefault(t){this.lastSyncResolved=!1;let n=this.#e;if(!n.getOptions().defaultRoute)return Promise.reject(new r.RouterError(e.errorCodes.ROUTE_NOT_FOUND,{routeName:`defaultRoute not configured`}));let i,a;try{({route:i,params:a}=n.resolveDefault())}catch(e){return Promise.reject(e)}return i?this.navigate(i,a,t):Promise.reject(new r.RouterError(e.errorCodes.ROUTE_NOT_FOUND,{routeName:`defaultRoute resolved to empty`}))}navigateToNotFound(t){if(!this.#e.isActive())throw new r.RouterError(e.errorCodes.ROUTER_DISPOSED);this.#c();let i=this.#e.getState(),a=i?n.nameToIDs(i.name).toReversed():[];Object.freeze(a);let o={deactivated:a,activated:c,intersection:``};Object.freeze(o);let s={phase:`activating`,...i&&{from:i.name},reason:`success`,replace:!0,segments:o};Object.freeze(s);let u={name:e.constants.UNKNOWN_ROUTE,params:e.EMPTY_PARAMS,path:t,transition:s,context:{}};return Object.freeze(u),this.#e.setState(u),this.#e.emitTransitionSuccess(u,i,l),u}abortCurrentController(t){this.#t?.abort(t??new r.RouterError(e.errorCodes.TRANSITION_CANCELLED)),this.#t=null}#r(t,o){let c=this.#e,l,f=!1,p=null;try{if(l=c.getState(),o=u(o,l),d(l,o,t))return c.emitTransitionError(t,l,i.CACHED_SAME_STATES_ERROR),this.lastSyncRejected=!0,i.CACHED_SAME_STATES_REJECTION;this.#c(o.signal);let m=++this.#n,h=o.signal!==void 0||c.hasLeaveListeners()||c.hasPreCommitListeners();c.startTransition(t,l),f=!0;let[g,_]=c.getLifecycleFunctions(),v=t.name===e.constants.UNKNOWN_ROUTE,y=n.getTransitionPath(t,l),{toDeactivate:b,toActivate:x,intersection:S}=y,C=l&&!o.forceDeactivate&&b.length>0,w=!v&&x.length>0,T=g.size>0||_.size>0,E=t;if(!T){let e=this.#o(E,l,m,o,y,g);if(e!==void 0)return e}if(T){p=new AbortController,this.#t=p;let n=()=>this.#n===m&&c.isActive(),i=p.signal,a=s.executeGuardPipeline(g,_,b,x,!!C,w,t,l,i,n,()=>{if(c.sendLeaveApprove(E,l),c.hasLeaveListeners())return c.awaitLeaveListeners(E,l,i)});if(a!==void 0)return this.#i(a,{toState:t,fromState:l,opts:o,toDeactivate:b,toActivate:x,intersection:S,canDeactivateFunctions:g},p,m);if(!n())throw new r.RouterError(e.errorCodes.TRANSITION_CANCELLED);this.#s(p,!1)}if(h&&(!c.isActive()||o.signal?.aborted===!0))throw new r.RouterError(e.errorCodes.TRANSITION_CANCELLED);let D=a.completeTransition(c,{toState:t,fromState:l,opts:o,toDeactivate:b,toActivate:x,intersection:S,canDeactivateFunctions:g});return this.lastSyncResolved=!0,Promise.resolve(D)}catch(e){return this.#a(e,p,f,t,l),Promise.reject(e)}}async#i(t,n,i,s){let c=this.#e,l=()=>this.#n===s&&!i.signal.aborted&&c.isActive(),u=n.opts.signal,d,f,p=!1,m,h=new Promise(e=>{if(i.signal.aborted){e();return}f=()=>{e()},i.signal.addEventListener(`abort`,f,{once:!0})});t.catch(()=>{});try{if(u){if(u.aborted)throw new r.RouterError(e.errorCodes.TRANSITION_CANCELLED,{reason:u.reason});d=()=>{c.cancelNavigation(u.reason)},u.addEventListener(`abort`,d,{once:!0})}if(await Promise.race([t,h]),!l())throw new r.RouterError(e.errorCodes.TRANSITION_CANCELLED);let i=a.completeTransition(c,n);return p=!0,i}catch(e){throw m=e,o.routeTransitionError(c,e,n.toState,n.fromState),e}finally{d&&u?.removeEventListener(`abort`,d),f&&i.signal.removeEventListener(`abort`,f),this.#s(i,!p,m)}}#a(e,t,n,r,i){t&&this.#s(t,!0,e),n&&r&&o.routeTransitionError(this.#e,e,r,i)}#o(e,t,n,r,i,a){let o=this.#e;if(o.sendLeaveApprove(e,t),o.hasLeaveListeners()){let s=new AbortController;this.#t=s;let c;try{c=o.awaitLeaveListeners(e,t,s.signal)}catch(e){throw this.#s(s,!0,e),e}if(c!==void 0)return this.#i(c,{toState:e,fromState:t,opts:r,toDeactivate:i.toDeactivate,toActivate:i.toActivate,intersection:i.intersection,canDeactivateFunctions:a},s,n);this.#s(s,!1);return}}#s(e,t,n){t&&e.abort(n),this.#t===e&&(this.#t=null)}#c(t){if(this.#e.isTransitioning()&&(this.#e.logger.warn(`router.navigate`,`Concurrent navigation detected on shared router instance. For SSR, use cloneRouter() to create isolated instance per request.`),this.#e.cancelNavigation()),t?.aborted)throw new r.RouterError(e.errorCodes.TRANSITION_CANCELLED,{reason:t.reason})}};exports.NavigationNamespace=f;
|
|
2
|
+
//# sourceMappingURL=NavigationNamespace.js.map
|