@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/esm/types.d.mts
CHANGED
|
@@ -1,2 +1,208 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { QueryParamsMode, QueryParamsOptions, RouteParams, RouteTreeState } from "./types/route-node-types.mjs";
|
|
2
|
+
import { Params, RouterError, SimpleState, State, StateMetaInput, TransitionMeta, TransitionPhase, TransitionReason, Unsubscribe } from "./types/base.mjs";
|
|
3
|
+
import { LimitsConfig } from "./types/limits.mjs";
|
|
4
|
+
import { DefaultDependencies, DefaultParamsCallback, DefaultRouteCallback, ForwardToCallback, GuardFn, GuardFnFactory, LeaveFn, LeaveState, Listener, LogCallback, LogLevel, LogLevelConfig, LoggerConfig, Navigator, Options, Plugin, PluginFactory, Route, RouteConfigUpdate, Router, RouterLogger, SubscribeFn, SubscribeState, Subscription } from "./types/router.mjs";
|
|
5
|
+
import { ErrorCodeKeys, ErrorCodeToValueMap, ErrorCodeValues, EventMethodMap, EventName, EventToNameMap, EventToPluginMap, EventsKeys, PluginMethod } from "./types/constants.mjs";
|
|
6
|
+
import { TreeChangedAdd, TreeChangedClear, TreeChangedEvent, TreeChangedRemove, TreeChangedReplace, TreeChangedUpdate, TreeStructuralPatch } from "./types/tree-changed.mjs";
|
|
7
|
+
import { ContextNamespaceClaim, DependenciesApi, InterceptableMethodMap, InterceptorFn, LifecycleApi, PluginApi, RoutesApi } from "./types/api.mjs";
|
|
8
|
+
//#region src/types/index.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Empty interface extended by plugins via module augmentation to declare
|
|
11
|
+
* typed `state.context.<namespace>` fields.
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* Plugins add typed context namespaces by augmenting this interface:
|
|
15
|
+
*
|
|
16
|
+
* ```typescript
|
|
17
|
+
* declare module "@real-router/core/types" {
|
|
18
|
+
* interface StateContext {
|
|
19
|
+
* navigation: { direction: "forward" | "back" | "navigate" };
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* After augmentation, `state.context.navigation` becomes typed. The intersection
|
|
25
|
+
* with `Record<string, unknown>` in {@link State.context} keeps the type open,
|
|
26
|
+
* so plugins that don't augment can still write arbitrary namespaces.
|
|
27
|
+
*
|
|
28
|
+
* @see {@link State.context}
|
|
29
|
+
* @see {@link ContextNamespaceClaim}
|
|
30
|
+
*/
|
|
31
|
+
interface StateContext {}
|
|
32
|
+
/**
|
|
33
|
+
* Configuration options that control navigation transition behavior.
|
|
34
|
+
*
|
|
35
|
+
* @description
|
|
36
|
+
* NavigationOptions provides fine-grained control over how the router performs navigation
|
|
37
|
+
* transitions. These options affect history management, transition lifecycle execution,
|
|
38
|
+
* guard enforcement, and state comparison logic.
|
|
39
|
+
*
|
|
40
|
+
* All options are optional and have sensible defaults. Options can be combined to achieve
|
|
41
|
+
* complex navigation behaviors. These options are available to guards and event listeners.
|
|
42
|
+
*
|
|
43
|
+
* @see {@link Router.navigate} for navigation method that accepts these options
|
|
44
|
+
*/
|
|
45
|
+
interface NavigationOptions {
|
|
46
|
+
/**
|
|
47
|
+
* Replace the current history entry instead of pushing a new one.
|
|
48
|
+
*
|
|
49
|
+
* @description
|
|
50
|
+
* When `true`, the navigation will replace the current entry in browser history instead
|
|
51
|
+
* of adding a new entry. This is typically used by history plugins (browser plugin) to
|
|
52
|
+
* control how navigation affects the browser's back/forward buttons.
|
|
53
|
+
*
|
|
54
|
+
* @default false
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* // Redirect after login - prevent back button to login page
|
|
58
|
+
* router.navigate('dashboard', {}, { replace: true });
|
|
59
|
+
*
|
|
60
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState}
|
|
61
|
+
*/
|
|
62
|
+
replace?: boolean | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Marks a `replace()` state-revalidation emit — a core-set signal, NOT a
|
|
65
|
+
* user-facing navigation option.
|
|
66
|
+
*
|
|
67
|
+
* @description
|
|
68
|
+
* `getRoutesApi(router).replace(...)` revalidates the active state against the
|
|
69
|
+
* new tree and emits `TRANSITION_SUCCESS` (#950). Core sets `revalidate: true`
|
|
70
|
+
* on that emit so a plugin's `onTransitionSuccess(toState, fromState, opts)`
|
|
71
|
+
* can distinguish a revalidation from a real navigation — both otherwise carry
|
|
72
|
+
* `replace: true` and are indistinguishable (#1201). Passing it to
|
|
73
|
+
* `router.navigate(...)` has no effect on the navigation itself.
|
|
74
|
+
*
|
|
75
|
+
* @default undefined
|
|
76
|
+
*/
|
|
77
|
+
revalidate?: boolean | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Force reload of the current route even if states are equal.
|
|
80
|
+
*
|
|
81
|
+
* @description
|
|
82
|
+
* When `true`, bypasses the "same state" check that normally prevents navigation when
|
|
83
|
+
* the target state equals the current state. This forces a full transition lifecycle
|
|
84
|
+
* execution, allowing route components to reload with the same parameters.
|
|
85
|
+
*
|
|
86
|
+
* Without `reload`:
|
|
87
|
+
* - Navigation to current route throws SAME_STATES error
|
|
88
|
+
* - No lifecycle hooks execute
|
|
89
|
+
* - No events are fired
|
|
90
|
+
*
|
|
91
|
+
* With `reload`:
|
|
92
|
+
* - Full transition executes (deactivate → activate)
|
|
93
|
+
* - All lifecycle hooks run again
|
|
94
|
+
* - TRANSITION_SUCCESS event fires with same state
|
|
95
|
+
* - State object is recreated (new reference)
|
|
96
|
+
*
|
|
97
|
+
* @default false
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* // Refresh current page data
|
|
101
|
+
* router.navigate(currentRoute.name, currentRoute.params, { reload: true });
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* // Force re-fetch on same route with different query params
|
|
105
|
+
* // Note: query params are in path, not checked for equality
|
|
106
|
+
* router.navigate('search', { term: 'react' }, { reload: true });
|
|
107
|
+
*
|
|
108
|
+
* @see {@link force} for alternative that forces transition
|
|
109
|
+
* @see {@link Router.areStatesEqual} for state comparison logic
|
|
110
|
+
*/
|
|
111
|
+
reload?: boolean | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Force navigation even if target state equals current state.
|
|
114
|
+
*
|
|
115
|
+
* @description
|
|
116
|
+
* When `true`, bypasses the "same state" equality check but still executes the full
|
|
117
|
+
* transition lifecycle. Similar to `reload` but can be used
|
|
118
|
+
* for any forced navigation scenario.
|
|
119
|
+
*
|
|
120
|
+
* Difference from `reload`:
|
|
121
|
+
* - `reload`: semantic meaning is "refresh current route"
|
|
122
|
+
* - `force`: general-purpose bypass of equality check
|
|
123
|
+
* - Both have identical implementation effect
|
|
124
|
+
*
|
|
125
|
+
* The equality check compares:
|
|
126
|
+
* - state.name (route name)
|
|
127
|
+
* - state.params (route parameters, shallow comparison)
|
|
128
|
+
*
|
|
129
|
+
* @default false
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* // Force transition for tracking even if params didn't change
|
|
133
|
+
* router.navigate('analytics', { event: 'pageview' }, { force: true });
|
|
134
|
+
*
|
|
135
|
+
* @see {@link reload} for semantic equivalent (preferred for refresh scenarios)
|
|
136
|
+
*/
|
|
137
|
+
force?: boolean | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* Skip canDeactivate guards during transition.
|
|
140
|
+
*
|
|
141
|
+
* @description
|
|
142
|
+
* When `true`, bypasses only the canDeactivate lifecycle hooks for segments being
|
|
143
|
+
* deactivated. canActivate guards still execute normally. This allows
|
|
144
|
+
* forcing navigation away from routes with confirmation dialogs or unsaved changes.
|
|
145
|
+
*
|
|
146
|
+
* Skipped vs executed:
|
|
147
|
+
* ```
|
|
148
|
+
* // Normal transition
|
|
149
|
+
* deactivate(fromSegments) → activate(toSegments) → success
|
|
150
|
+
*
|
|
151
|
+
* // With forceDeactivate: true
|
|
152
|
+
* [skip deactivate] → activate(toSegments) → success
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* ⚠️ Data loss risk: Bypassing canDeactivate means unsaved changes will be lost
|
|
156
|
+
*
|
|
157
|
+
* @default false
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* // Force logout even with unsaved changes
|
|
161
|
+
* function forceLogout() {
|
|
162
|
+
* router.navigate('login', {}, {
|
|
163
|
+
* forceDeactivate: true,
|
|
164
|
+
* replace: true
|
|
165
|
+
* });
|
|
166
|
+
* }
|
|
167
|
+
*
|
|
168
|
+
* @see {@link Router.clearCanDeactivate} for programmatically clearing guards
|
|
169
|
+
*/
|
|
170
|
+
forceDeactivate?: boolean | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* Internal flag indicating navigation is result of a redirect.
|
|
173
|
+
*
|
|
174
|
+
* @internal
|
|
175
|
+
*
|
|
176
|
+
* @description
|
|
177
|
+
* Automatically set by the router when a navigation is triggered by a redirect.
|
|
178
|
+
* Available on `state.transition` after successful navigation (not during guard execution).
|
|
179
|
+
*
|
|
180
|
+
* @default false (auto-set by router during redirects)
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* // Accessing redirect flag in TRANSITION_SUCCESS listener
|
|
184
|
+
* router.addEventListener('TRANSITION_SUCCESS', (state) => {
|
|
185
|
+
* if (state.transition?.redirected) {
|
|
186
|
+
* console.log('This navigation is from a redirect');
|
|
187
|
+
* }
|
|
188
|
+
* });
|
|
189
|
+
*
|
|
190
|
+
* @see {@link Router.navigate} for redirect handling implementation
|
|
191
|
+
* @see {@link NavigationOptions.redirected} for the input mechanism
|
|
192
|
+
*/
|
|
193
|
+
redirected?: boolean | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* Optional abort signal for cancelling the navigation.
|
|
196
|
+
*
|
|
197
|
+
* @description
|
|
198
|
+
* When provided, this signal can be used to cancel the navigation operation.
|
|
199
|
+
* If the signal is aborted, the navigation will be cancelled and any pending
|
|
200
|
+
* guards or transitions will be interrupted.
|
|
201
|
+
*
|
|
202
|
+
* @default undefined
|
|
203
|
+
*/
|
|
204
|
+
signal?: AbortSignal | undefined;
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
207
|
+
export { type ContextNamespaceClaim, type DefaultDependencies, type DefaultParamsCallback, type DefaultRouteCallback, type DependenciesApi, type ErrorCodeKeys, type ErrorCodeToValueMap, type ErrorCodeValues, 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, 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 RouteTreeState, type Router, type RouterError, type RouterLogger, type RoutesApi, type SimpleState, type State, 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, type Unsubscribe };
|
|
208
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/types/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA0DiB;;;;;;;;;;;;;;UAeA;;;;;;;;;;;;;;;;;EAiBf;;;;;;;;;;;;;;;EAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCA;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCA;;;;;;;;;;;;;;;;;;;;;;;EAwBA;;;;;;;;;;;EAYA,SAAS"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { DefaultDependencies, Router } from "../types/router.mjs";
|
|
2
|
+
import { Router as Router$1 } from "../Router.mjs";
|
|
3
|
+
//#region src/utils/createRequestScope.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Subset of Node's `http.IncomingMessage` that `createRequestScope` relies on:
|
|
6
|
+
* a `"close"` event indicating that the client disconnected (or the response
|
|
7
|
+
* was fully sent) and the standard `removeListener` cleanup hook.
|
|
8
|
+
*/
|
|
9
|
+
interface IncomingMessageLike {
|
|
10
|
+
on: (event: "close", listener: () => void) => unknown;
|
|
11
|
+
removeListener?: (event: "close", listener: () => void) => unknown;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Web `Request`-shaped object — anything carrying an `AbortSignal`. Web
|
|
15
|
+
* runtimes (Bun, Cloudflare Workers, Vite RSC) surface client-disconnect via
|
|
16
|
+
* `request.signal` directly, so no listener attachment is needed.
|
|
17
|
+
*/
|
|
18
|
+
interface RequestLike {
|
|
19
|
+
signal: AbortSignal;
|
|
20
|
+
}
|
|
21
|
+
type RequestScopeSource = IncomingMessageLike | RequestLike;
|
|
22
|
+
interface RequestScope<Dependencies extends DefaultDependencies = DefaultDependencies> extends AsyncDisposable {
|
|
23
|
+
/**
|
|
24
|
+
* Per-request router clone. Carries `abortSignal` injected into its
|
|
25
|
+
* dependencies — loaders can `getDep("abortSignal")` and pass it to fetch /
|
|
26
|
+
* `withTimeout` for cooperative cancellation when the client disconnects.
|
|
27
|
+
*/
|
|
28
|
+
readonly router: Router$1<Dependencies>;
|
|
29
|
+
/**
|
|
30
|
+
* Aborts when the request closes (Node `IncomingMessage`'s `"close"` event)
|
|
31
|
+
* or when the upstream Web `Request.signal` aborts.
|
|
32
|
+
*/
|
|
33
|
+
readonly signal: AbortSignal;
|
|
34
|
+
/**
|
|
35
|
+
* Detach the close listener (if attached to a Node `IncomingMessage`) and
|
|
36
|
+
* dispose the cloned router. Idempotent — safe to call multiple times or in
|
|
37
|
+
* combination with `Symbol.asyncDispose`.
|
|
38
|
+
*/
|
|
39
|
+
dispose: () => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Build a per-request router scope: clones `base`, attaches an `AbortSignal`
|
|
43
|
+
* tied to the request's lifetime, and exposes `dispose()` (plus
|
|
44
|
+
* `Symbol.asyncDispose` for `await using` declarations).
|
|
45
|
+
*
|
|
46
|
+
* Replaces the four-step boilerplate that every server entry repeats:
|
|
47
|
+
*
|
|
48
|
+
* 1. `new AbortController()` per request
|
|
49
|
+
* 2. `req.on("close", () => controller.abort())`
|
|
50
|
+
* 3. `cloneRouter(base, { ...deps, abortSignal: signal })`
|
|
51
|
+
* 4. `try { ... } finally { router.dispose() }`
|
|
52
|
+
*
|
|
53
|
+
* The signal is injected into the router clone under `abortSignal` so existing
|
|
54
|
+
* loaders that read `getDep("abortSignal")` keep working without changes. If
|
|
55
|
+
* `deps` already carries an `abortSignal`, the request-tied signal **wins** (it
|
|
56
|
+
* is spread last) — a caller-supplied `abortSignal` is intentionally overridden,
|
|
57
|
+
* since the scope's purpose is to own the request-lifecycle signal.
|
|
58
|
+
*
|
|
59
|
+
* ## `await using` compatibility
|
|
60
|
+
*
|
|
61
|
+
* The scope implements `Symbol.asyncDispose`, so `await using scope = …` is
|
|
62
|
+
* supported on runtimes that ship the well-known `Symbol.asyncDispose`:
|
|
63
|
+
*
|
|
64
|
+
* - **Node.js 24+** (full support; partial in 20.4–20.17 only for `fs`/`stream`)
|
|
65
|
+
* - **Bun 1.0.23+**, **Deno 1.37+**
|
|
66
|
+
* - **Chrome / Edge 127+**, **Firefox 141+**
|
|
67
|
+
* - **Safari**: not yet supported (irrelevant in practice — this helper is
|
|
68
|
+
* server-side only and never reaches the browser)
|
|
69
|
+
*
|
|
70
|
+
* On Node.js 22 LTS the well-known symbol is unavailable, so `await using`
|
|
71
|
+
* fails. **The bundled SSR examples therefore use the explicit
|
|
72
|
+
* `try/finally` + `await scope.dispose()` form**, which works on every
|
|
73
|
+
* runtime. Use `await using` only when you control the deployment target and
|
|
74
|
+
* know it ships the symbol.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* // Explicit dispose — works on Node 18+, all browsers, every CI image
|
|
79
|
+
* export async function render(url: string, req: IncomingMessage) {
|
|
80
|
+
* const scope = createRequestScope(req, baseRouter, { currentUser });
|
|
81
|
+
* try {
|
|
82
|
+
* scope.router.usePlugin(ssrDataPluginFactory(loaders));
|
|
83
|
+
* return await renderShell(scope.router, url);
|
|
84
|
+
* } finally {
|
|
85
|
+
* await scope.dispose();
|
|
86
|
+
* }
|
|
87
|
+
* }
|
|
88
|
+
*
|
|
89
|
+
* // `await using` — Node 24+, Bun, Deno, modern browsers
|
|
90
|
+
* export async function render(url: string, req: IncomingMessage) {
|
|
91
|
+
* await using scope = createRequestScope(req, baseRouter, { currentUser });
|
|
92
|
+
* scope.router.usePlugin(ssrDataPluginFactory(loaders));
|
|
93
|
+
* return await renderShell(scope.router, url);
|
|
94
|
+
* }
|
|
95
|
+
*
|
|
96
|
+
* // Web runtime (signal already on the request)
|
|
97
|
+
* async function handler(request: Request) {
|
|
98
|
+
* const scope = createRequestScope(request, baseRouter, { db });
|
|
99
|
+
* try {
|
|
100
|
+
* scope.router.usePlugin(rscServerPluginFactory(loaders));
|
|
101
|
+
* return await render(scope.router, request.url);
|
|
102
|
+
* } finally {
|
|
103
|
+
* await scope.dispose();
|
|
104
|
+
* }
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
declare function createRequestScope<Dependencies extends DefaultDependencies = DefaultDependencies>(request: RequestScopeSource, base: Router<Dependencies>, deps?: Partial<Dependencies>): RequestScope<Dependencies>;
|
|
109
|
+
//#endregion
|
|
110
|
+
export { IncomingMessageLike, RequestLike, RequestScope, RequestScopeSource, createRequestScope };
|
|
111
|
+
//# sourceMappingURL=createRequestScope.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRequestScope.d.mts","names":[],"sources":["../../../src/utils/createRequestScope.ts"],"mappings":";;;;;;;;UAUiB;EACf,KAAK,gBAAgB;EACrB,kBAAkB,gBAAgB;;;;;;;UAQnB;EACf,QAAQ;;KAGE,qBAAqB,sBAAsB;UAEtC,aACf,qBAAqB,sBAAsB,6BACnC;;;;;;WAMC,QAAQ,SAAY;;;;;WAMpB,QAAQ;;;;;;EAOjB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+ED,mBACd,qBAAqB,sBAAsB,qBAE3C,SAAS,oBACT,MAAM,OAAO,eACb,OAAO,QAAQ,gBACd,aAAa"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DefaultDependencies, Router } from "../types/router.mjs";
|
|
2
|
+
//#region src/utils/getStaticPaths.d.ts
|
|
3
|
+
type StaticPathEntries = Record<string, () => Promise<Record<string, string>[]>>;
|
|
4
|
+
declare function getStaticPaths<Dependencies extends DefaultDependencies = DefaultDependencies>(router: Router<Dependencies>, entries?: StaticPathEntries): Promise<string[]>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { StaticPathEntries, getStaticPaths };
|
|
7
|
+
//# sourceMappingURL=getStaticPaths.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getStaticPaths.d.mts","names":[],"sources":["../../../src/utils/getStaticPaths.ts"],"mappings":";;KAKY,oBAAoB,qBAExB,QAAQ;iBA2BM,eACpB,qBAAqB,sBAAsB,qBAE3C,QAAQ,OAAO,eACf,UAAU,oBACT"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { State } from "../types/base.mjs";
|
|
2
|
+
import { Router } from "../types/router.mjs";
|
|
3
|
+
//#region src/utils/hydrateRouter.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Custom deserializer signature for {@link hydrateRouter} (#606). Compatible
|
|
6
|
+
* with `JSON.parse` (default), `devalue.parse`, `superjson.parse`, or any
|
|
7
|
+
* user-supplied function.
|
|
8
|
+
*/
|
|
9
|
+
type Deserialize = (json: string) => unknown;
|
|
10
|
+
interface HydrateRouterOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Custom deserializer (e.g., `devalue.parse` / `superjson.parse`) for
|
|
13
|
+
* matching the `serialize` passed to {@link serializeRouterState}. Defaults
|
|
14
|
+
* to `JSON.parse`. Ignored when `source` is already an object.
|
|
15
|
+
*
|
|
16
|
+
* @default JSON.parse
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import * as devalue from "devalue";
|
|
21
|
+
* await hydrateRouter(router, ssrJson, { deserialize: devalue.parse });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
deserialize?: Deserialize;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Hydrate a fresh router from server-serialized State (#563, #596).
|
|
28
|
+
*
|
|
29
|
+
* Accepts either a JSON string (parsed via `JSON.parse` by default, or
|
|
30
|
+
* `options.deserialize` when provided) or a State-shaped object. Extracts
|
|
31
|
+
* `state.path` and delegates to `router.start(state.path)` — the canonical
|
|
32
|
+
* URL is the source of truth for the router on hydration.
|
|
33
|
+
*
|
|
34
|
+
* The full parsed state (incl. `state.context.<namespace>` payloads) is
|
|
35
|
+
* deposited into a one-shot scratchpad on `RouterInternals.hydrationState`
|
|
36
|
+
* before `start()` is invoked and cleared in the matching `finally`. SSR
|
|
37
|
+
* loader plugins (`@real-router/ssr-data-plugin`,
|
|
38
|
+
* `@real-router/rsc-server-plugin`) read this scratchpad to skip their loader
|
|
39
|
+
* call when the server-resolved namespace value is already present — avoiding
|
|
40
|
+
* the post-hydration loader re-run on first paint.
|
|
41
|
+
*
|
|
42
|
+
* Single-shot semantics: the scratchpad is consumed during the first `start()`
|
|
43
|
+
* triggered by `hydrateRouter` regardless of route mismatch; subsequent
|
|
44
|
+
* `start()` calls run loaders normally.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // Client
|
|
49
|
+
* const router = createAppRouter();
|
|
50
|
+
* router.usePlugin(browserPluginFactory());
|
|
51
|
+
* await hydrateRouter(router, window.__SSR_STATE__);
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* // With non-JSON types (Date / Map / Set / RegExp / BigInt) via devalue (#606)
|
|
57
|
+
* import * as devalue from "devalue";
|
|
58
|
+
*
|
|
59
|
+
* await hydrateRouter(router, window.__SSR_STATE__, {
|
|
60
|
+
* deserialize: devalue.parse,
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
declare function hydrateRouter(router: Router, source: string | {
|
|
65
|
+
path: string;
|
|
66
|
+
}, options?: HydrateRouterOptions): Promise<State>;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { Deserialize, HydrateRouterOptions, hydrateRouter };
|
|
69
|
+
//# sourceMappingURL=hydrateRouter.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrateRouter.d.mts","names":[],"sources":["../../../src/utils/hydrateRouter.ts"],"mappings":";;;;;;;;KAUY,eAAe;UAEV;;;;;;;;;;;;;;EAcf,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyCM,cACpB,QAAQ,QACR;EAAmB;GACnB,UAAU,uBACT,QAAQ"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Params, State } from "../types/base.mjs";
|
|
2
|
+
import { Serialize } from "./serializeState.mjs";
|
|
3
|
+
//#region src/utils/serializeRouterState.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Parsed shape produced by {@link serializeRouterState} (after `JSON.parse`).
|
|
6
|
+
*
|
|
7
|
+
* Identical to {@link State} minus `transition` (per-navigation `TransitionMeta`
|
|
8
|
+
* is meaningless after hydration; the client builds its own on commit). Used as
|
|
9
|
+
* the input shape for {@link hydrateRouter} and as the type of the one-shot
|
|
10
|
+
* hydration scratchpad consumed by SSR loader plugins.
|
|
11
|
+
*/
|
|
12
|
+
type SerializedRouterState<P extends Params = Params> = Omit<State<P>, "transition">;
|
|
13
|
+
interface SerializeRouterStateOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Plugin context namespaces to strip from the serialized output.
|
|
16
|
+
* Use when a plugin populates `state.context.<ns>` with non-JSON-serializable
|
|
17
|
+
* values (e.g., RSC payload: ReactNode trees containing functions/symbols).
|
|
18
|
+
*
|
|
19
|
+
* @default []
|
|
20
|
+
*/
|
|
21
|
+
excludeContext?: readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* Custom serializer (e.g., `devalue.stringify` / `superjson.stringify`) to
|
|
24
|
+
* support non-JSON types in `state.params` and `state.context.<ns>` payloads
|
|
25
|
+
* (Date / Map / Set / RegExp / BigInt). Defaults to `JSON.stringify`.
|
|
26
|
+
*
|
|
27
|
+
* Pair with the matching `deserialize` on `hydrateRouter` to round-trip the
|
|
28
|
+
* extended types on the client.
|
|
29
|
+
*
|
|
30
|
+
* @default JSON.stringify
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import * as devalue from "devalue";
|
|
35
|
+
*
|
|
36
|
+
* const json = serializeRouterState(state, { serialize: devalue.stringify });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
serialize?: Serialize;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* XSS-safe JSON serialization of router State for SSR → client transport (#563).
|
|
43
|
+
*
|
|
44
|
+
* Strips `state.transition` (per-navigation `TransitionMeta` — meaningless after
|
|
45
|
+
* hydration; the client's hydration commit produces its own `transition`).
|
|
46
|
+
* Keeps `name`, `params`, `path`, and `context` (plugin context namespaces are
|
|
47
|
+
* preserved as-is — server's `state.context.data` from `ssr-data-plugin` and
|
|
48
|
+
* any other plugin claims travel to the client untouched).
|
|
49
|
+
*
|
|
50
|
+
* Pass `options.excludeContext` to strip specific namespaces from the output —
|
|
51
|
+
* required for plugins that publish non-JSON-serializable values (e.g., RSC
|
|
52
|
+
* `ReactNode` trees from `@real-router/rsc-server-plugin`).
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* // Server
|
|
57
|
+
* const state = await router.start(req.url);
|
|
58
|
+
* const html = `<script>window.__SSR_STATE__=${serializeRouterState(state)}</script>`;
|
|
59
|
+
*
|
|
60
|
+
* // Client
|
|
61
|
+
* await hydrateRouter(router, window.__SSR_STATE__);
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* // With RSC plugin: strip the "rsc" namespace before transport
|
|
67
|
+
* const state = await router.start(url);
|
|
68
|
+
* const json = serializeRouterState(state, { excludeContext: ["rsc"] });
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* // Non-JSON types (Date / Map / Set / RegExp / BigInt) via devalue (#606)
|
|
74
|
+
* import * as devalue from "devalue";
|
|
75
|
+
*
|
|
76
|
+
* const json = serializeRouterState(state, { serialize: devalue.stringify });
|
|
77
|
+
* // On the client:
|
|
78
|
+
* await hydrateRouter(router, json, { deserialize: devalue.parse });
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
declare function serializeRouterState(state: State, options?: SerializeRouterStateOptions): string;
|
|
82
|
+
//#endregion
|
|
83
|
+
export { SerializeRouterStateOptions, SerializedRouterState, serializeRouterState };
|
|
84
|
+
//# sourceMappingURL=serializeRouterState.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializeRouterState.d.mts","names":[],"sources":["../../../src/utils/serializeRouterState.ts"],"mappings":";;;;;;;;;;;KAaY,sBAAsB,UAAU,SAAS,UAAU,KAC7D,MAAM;UAIS;;;;;;;;EAQf;;;;;;;;;;;;;;;;;;EAmBA,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2CE,qBACd,OAAO,OACP,UAAU"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/utils/serializeState.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Custom serializer signature for {@link serializeState} (#606).
|
|
4
|
+
*
|
|
5
|
+
* Compatible with `JSON.stringify` (default) as well as `devalue.stringify`,
|
|
6
|
+
* `superjson.stringify`, or any user-supplied function that returns a JSON
|
|
7
|
+
* string. The output is run through XSS-safe character escapes regardless
|
|
8
|
+
* of which serializer produced it.
|
|
9
|
+
*/
|
|
10
|
+
type Serialize = (data: unknown) => string;
|
|
11
|
+
interface SerializeStateOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Custom serializer (e.g., `devalue.stringify` / `superjson.stringify`) to
|
|
14
|
+
* support non-JSON types (Date / Map / Set / RegExp / BigInt). Defaults to
|
|
15
|
+
* `JSON.stringify`. Output is still XSS-escaped.
|
|
16
|
+
*
|
|
17
|
+
* @default JSON.stringify
|
|
18
|
+
*/
|
|
19
|
+
serialize?: Serialize;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* XSS-safe JSON serialization for embedding data in HTML `<script>` tags.
|
|
23
|
+
*
|
|
24
|
+
* Escapes `<`, `>`, and `&` to their Unicode equivalents to prevent
|
|
25
|
+
* injection via `</script>` or HTML entities inside inline scripts.
|
|
26
|
+
*
|
|
27
|
+
* Pass `options.serialize` to use a custom serializer such as `devalue` or
|
|
28
|
+
* `superjson` for non-JSON types (Date/Map/Set/RegExp/BigInt). The serializer
|
|
29
|
+
* must return a string; XSS-escape is applied to its output.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const json = serializeState({ name: "home", path: "/" });
|
|
34
|
+
* const html = `<script>window.__STATE__=${json}</script>`;
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* import * as devalue from "devalue";
|
|
40
|
+
*
|
|
41
|
+
* const json = serializeState(
|
|
42
|
+
* { date: new Date(), tags: new Set(["a", "b"]) },
|
|
43
|
+
* { serialize: devalue.stringify },
|
|
44
|
+
* );
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare function serializeState(data: unknown, options?: SerializeStateOptions): string;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { Serialize, SerializeStateOptions, serializeState };
|
|
50
|
+
//# sourceMappingURL=serializeState.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializeState.d.mts","names":[],"sources":["../../../src/utils/serializeState.ts"],"mappings":";;;;;;;;;KAQY,aAAa;UAER;;;;;;;;EAQf,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6BE,eACd,eACA,UAAU"}
|
package/dist/esm/utils.d.mts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IncomingMessageLike, RequestLike, RequestScope, RequestScopeSource, createRequestScope } from "./utils/createRequestScope.mjs";
|
|
2
|
+
import { StaticPathEntries, getStaticPaths } from "./utils/getStaticPaths.mjs";
|
|
3
|
+
import { Deserialize, HydrateRouterOptions, hydrateRouter } from "./utils/hydrateRouter.mjs";
|
|
4
|
+
import { Serialize, SerializeStateOptions, serializeState } from "./utils/serializeState.mjs";
|
|
5
|
+
import { SerializeRouterStateOptions, SerializedRouterState, serializeRouterState } from "./utils/serializeRouterState.mjs";
|
|
2
6
|
export { type Deserialize, type HydrateRouterOptions, type IncomingMessageLike, type RequestLike, type RequestScope, type RequestScopeSource, type Serialize, type SerializeRouterStateOptions, type SerializeStateOptions, type SerializedRouterState, type StaticPathEntries, createRequestScope, getStaticPaths, hydrateRouter, serializeRouterState, serializeState };
|
package/dist/esm/utils.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{u as e}from"./buildParamMeta-bOLhLF9h.mjs";import{r as t,t as n}from"./cloneRouter-D4rnqmi9.mjs";function r(e){return`signal`in e&&typeof e.signal==`object`&&e.signal!==void 0&&typeof e.signal.aborted==`boolean`}function i(e,t,i){let a,o,s;if(r(e))s=e.signal;else{let t=new AbortController,n=()=>{t.abort()};s=t.signal,o=()=>{e.on(`close`,n)},a=()=>{e.removeListener?.(`close`,n)}}let c=n(t,{...i,abortSignal:s});o?.();let l=!1,u=()=>l?Promise.resolve():(l=!0,a?.(),c.dispose(),Promise.resolve());return{router:c,signal:s,dispose:u,[Symbol.asyncDispose]:u}}function a(e,t){for(let n of e.children.values())n.children.size===0?t.push(n.fullName):a(n,t)}function o(e){let t=[];return a(e,t),t}async function s(e,n){let r=o(t(e).getTree()),i=[];for(let t of r){let r=n?.[t];if(r){let n=await r();for(let r of n)i.push(e.buildPath(t,r))}else i.push(e.buildPath(t,{}))}return i}async function c(t,n,r){let i=r?.deserialize??JSON.parse,a=typeof n==`string`?i(n):n,o=e(t),s=o.hydrationState;o.hydrationState=a;try{return await t.start(a.path)}finally{o.hydrationState=s}}function l(e,t){return((t?.serialize??JSON.stringify)(e)??`null`).replaceAll(`<`,String.raw`\u003c`).replaceAll(`>`,String.raw`\u003e`).replaceAll(`&`,String.raw`\u0026`)}function u(e,t){let n=t?.excludeContext,r=e.context;if(n?.length){let t=Object.create(null),i=e.context;for(let[e,r]of Object.entries(i))n.includes(e)||(t[e]=r);r=t}let i={name:e.name,params:e.params,path:e.path,context:r};return t?.serialize?l(i,{serialize:t.serialize}):l(i)}export{i as createRequestScope,s as getStaticPaths,c as hydrateRouter,u as serializeRouterState,l as serializeState};
|
|
2
2
|
//# sourceMappingURL=utils.mjs.map
|