@tanstack/vue-router 1.162.2 → 1.162.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.d.ts +2 -5
- package/dist/esm/index.dev.js +1 -12
- package/dist/esm/index.dev.js.map +1 -1
- package/dist/esm/index.js +1 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routerContext.d.ts +1 -11
- package/dist/esm/routerContext.js +4 -15
- package/dist/esm/routerContext.js.map +1 -1
- package/dist/esm/useRouter.js +2 -2
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/esm/utils.js +0 -2
- package/dist/esm/utils.js.map +1 -1
- package/dist/source/index.d.ts +2 -5
- package/dist/source/index.jsx +2 -6
- package/dist/source/index.jsx.map +1 -1
- package/dist/source/routerContext.d.ts +1 -11
- package/dist/source/routerContext.jsx +3 -21
- package/dist/source/routerContext.jsx.map +1 -1
- package/dist/source/useRouter.jsx +2 -2
- package/dist/source/useRouter.jsx.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +1 -16
- package/src/routerContext.tsx +3 -30
- package/src/useRouter.tsx +2 -2
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { defer,
|
|
1
|
+
export { defer, isMatch, joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, interpolatePath, rootRouteId, defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, createControlledPromise, retainSearchParams, stripSearchParams, createSerializationAdapter, } from '@tanstack/router-core';
|
|
2
2
|
export type { AnyRoute, DeferredPromiseState, DeferredPromise, ParsedLocation, RemoveTrailingSlashes, RemoveLeadingSlashes, ActiveOptions, ResolveRelativePath, RootRouteId, AnyPathParams, ResolveParams, ResolveOptionalParams, ResolveRequiredParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, UpdatableStaticRouteOption, MetaDescriptor, RouteLinkEntry, ParseParamsFn, SearchFilter, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, TrimPath, TrimPathLeft, TrimPathRight, StringifyParamsFn, ParamsOptions, InferAllParams, InferAllContext, LooseReturnType, LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveLoaderData, ResolveRouteContext, SearchSerializer, SearchParser, TrailingSlashOption, Manifest, RouterManagedTag, ControlledPromise, Constrain, Expand, MergeAll, Assign, IntersectAssign, ResolveValidatorInput, ResolveValidatorOutput, Register, AnyValidator, DefaultValidator, ValidatorFn, AnySchema, AnyValidatorAdapter, AnyValidatorFn, AnyValidatorObj, ResolveValidatorInputFn, ResolveValidatorOutputFn, ResolveSearchValidatorInput, ResolveSearchValidatorInputFn, Validator, ValidatorAdapter, ValidatorObj, FileRoutesByPath, RouteById, RootRouteOptions, CreateFileRoute, SerializationAdapter, AnySerializationAdapter, SerializableExtensions, } from '@tanstack/router-core';
|
|
3
3
|
export { createHistory, createBrowserHistory, createHashHistory, createMemoryHistory, } from '@tanstack/history';
|
|
4
4
|
export type { BlockerFn, HistoryLocation, RouterHistory, ParsedPath, HistoryState, } from '@tanstack/history';
|
|
@@ -13,7 +13,6 @@ export type { InferDescendantToPaths, RelativeToPath, RelativeToParentPath, Rela
|
|
|
13
13
|
export type { UseLinkPropsOptions, ActiveLinkOptions, LinkProps, LinkComponent, LinkComponentRoute, LinkComponentProps, CreateLinkProps, } from './link.js';
|
|
14
14
|
export { Matches, useMatchRoute, MatchRoute, useMatches, useParentMatches, useChildMatches, } from './Matches.js';
|
|
15
15
|
export type { UseMatchRouteOptions, MakeMatchRouteOptions } from './Matches.js';
|
|
16
|
-
export { matchContext } from './matchContext.js';
|
|
17
16
|
export { Match, Outlet } from './Match.js';
|
|
18
17
|
export { useMatch } from './useMatch.js';
|
|
19
18
|
export { useLoaderDeps } from './useLoaderDeps.js';
|
|
@@ -22,7 +21,7 @@ export { redirect, isRedirect, createRouterConfig, DEFAULT_PROTOCOL_ALLOWLIST, }
|
|
|
22
21
|
export { RouteApi, getRouteApi, Route, createRoute, RootRoute, rootRouteWithContext, createRootRoute, createRootRouteWithContext, createRouteMask, NotFoundRoute, } from './route.js';
|
|
23
22
|
export type { AnyRootRoute, VueNode, SyncRouteComponent, AsyncRouteComponent, RouteComponent, ErrorRouteComponent, NotFoundRouteComponent, } from './route.js';
|
|
24
23
|
export { createRouter, Router } from './router.js';
|
|
25
|
-
export {
|
|
24
|
+
export { lazyFn, SearchParamError } from '@tanstack/router-core';
|
|
26
25
|
export { RouterProvider, RouterContextProvider } from './RouterProvider.js';
|
|
27
26
|
export type { RouterProps } from './RouterProvider.js';
|
|
28
27
|
export { useElementScrollRestoration, ScrollRestoration, } from './ScrollRestoration.js';
|
|
@@ -31,13 +30,11 @@ export { useBlocker, Block } from './useBlocker.js';
|
|
|
31
30
|
export { useNavigate, Navigate } from './useNavigate.js';
|
|
32
31
|
export { useParams } from './useParams.js';
|
|
33
32
|
export { useSearch } from './useSearch.js';
|
|
34
|
-
export { getRouterContext, } from './routerContext.js';
|
|
35
33
|
export { useRouteContext } from './useRouteContext.js';
|
|
36
34
|
export { useRouter } from './useRouter.js';
|
|
37
35
|
export { useRouterState } from './useRouterState.js';
|
|
38
36
|
export { useLocation } from './useLocation.js';
|
|
39
37
|
export { useCanGoBack } from './useCanGoBack.js';
|
|
40
|
-
export { useLayoutEffect } from './utils.js';
|
|
41
38
|
export { CatchNotFound, DefaultGlobalNotFound } from './not-found.js';
|
|
42
39
|
export { notFound, isNotFound } from '@tanstack/router-core';
|
|
43
40
|
export type { NotFoundError } from '@tanstack/router-core';
|
package/dist/esm/index.dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_PROTOCOL_ALLOWLIST,
|
|
1
|
+
import { DEFAULT_PROTOCOL_ALLOWLIST, SearchParamError, cleanPath, composeRewrites, createControlledPromise, createRouterConfig, createSerializationAdapter, deepEqual, defaultParseSearch, defaultStringifySearch, defer, functionalUpdate, interpolatePath, isMatch, isNotFound, isPlainArray, isPlainObject, isRedirect, joinPaths, lazyFn, notFound, parseSearchWith, redirect, replaceEqualDeep, resolvePath, retainSearchParams, rootRouteId, stringifySearchWith, stripSearchParams, trimPath, trimPathLeft, trimPathRight } from "@tanstack/router-core";
|
|
2
2
|
import { createBrowserHistory, createHashHistory, createHistory, createMemoryHistory } from "@tanstack/history";
|
|
3
3
|
import { Await, useAwaited } from "./awaited.js";
|
|
4
4
|
import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
|
|
@@ -6,7 +6,6 @@ import { FileRoute, FileRouteLoader, LazyRoute, createFileRoute, createLazyFileR
|
|
|
6
6
|
import { lazyRouteComponent } from "./lazyRouteComponent.js";
|
|
7
7
|
import { Link, createLink, linkOptions, useLinkProps } from "./link.js";
|
|
8
8
|
import { MatchRoute, Matches, useChildMatches, useMatchRoute, useMatches, useParentMatches } from "./Matches.js";
|
|
9
|
-
import { matchContext } from "./matchContext.js";
|
|
10
9
|
import { Match, Outlet } from "./Match.js";
|
|
11
10
|
import { useMatch } from "./useMatch.js";
|
|
12
11
|
import { useLoaderDeps } from "./useLoaderDeps.js";
|
|
@@ -19,13 +18,11 @@ import { Block, useBlocker } from "./useBlocker.js";
|
|
|
19
18
|
import { Navigate, useNavigate } from "./useNavigate.js";
|
|
20
19
|
import { useParams } from "./useParams.js";
|
|
21
20
|
import { useSearch } from "./useSearch.js";
|
|
22
|
-
import { getRouterContext } from "./routerContext.js";
|
|
23
21
|
import { useRouteContext } from "./useRouteContext.js";
|
|
24
22
|
import { useRouter } from "./useRouter.js";
|
|
25
23
|
import { useRouterState } from "./useRouterState.js";
|
|
26
24
|
import { useLocation } from "./useLocation.js";
|
|
27
25
|
import { useCanGoBack } from "./useCanGoBack.js";
|
|
28
|
-
import { useLayoutEffect } from "./utils.js";
|
|
29
26
|
import { CatchNotFound, DefaultGlobalNotFound } from "./not-found.js";
|
|
30
27
|
import { ScriptOnce } from "./ScriptOnce.js";
|
|
31
28
|
import { Asset } from "./Asset.js";
|
|
@@ -58,7 +55,6 @@ export {
|
|
|
58
55
|
Navigate,
|
|
59
56
|
NotFoundRoute,
|
|
60
57
|
Outlet,
|
|
61
|
-
PathParamError,
|
|
62
58
|
RootRoute,
|
|
63
59
|
Route,
|
|
64
60
|
RouteApi,
|
|
@@ -69,9 +65,7 @@ export {
|
|
|
69
65
|
Scripts,
|
|
70
66
|
ScrollRestoration,
|
|
71
67
|
SearchParamError,
|
|
72
|
-
TSR_DEFERRED_PROMISE,
|
|
73
68
|
cleanPath,
|
|
74
|
-
componentTypes,
|
|
75
69
|
composeRewrites,
|
|
76
70
|
createBrowserHistory,
|
|
77
71
|
createControlledPromise,
|
|
@@ -91,13 +85,10 @@ export {
|
|
|
91
85
|
createSerializationAdapter,
|
|
92
86
|
deepEqual,
|
|
93
87
|
defaultParseSearch,
|
|
94
|
-
defaultSerializeError,
|
|
95
88
|
defaultStringifySearch,
|
|
96
89
|
defer,
|
|
97
90
|
functionalUpdate,
|
|
98
|
-
getInitialRouterState,
|
|
99
91
|
getRouteApi,
|
|
100
|
-
getRouterContext,
|
|
101
92
|
interpolatePath,
|
|
102
93
|
isMatch,
|
|
103
94
|
isNotFound,
|
|
@@ -108,7 +99,6 @@ export {
|
|
|
108
99
|
lazyFn,
|
|
109
100
|
lazyRouteComponent,
|
|
110
101
|
linkOptions,
|
|
111
|
-
matchContext,
|
|
112
102
|
notFound,
|
|
113
103
|
parseSearchWith,
|
|
114
104
|
redirect,
|
|
@@ -127,7 +117,6 @@ export {
|
|
|
127
117
|
useCanGoBack,
|
|
128
118
|
useChildMatches,
|
|
129
119
|
useElementScrollRestoration,
|
|
130
|
-
useLayoutEffect,
|
|
131
120
|
useLinkProps,
|
|
132
121
|
useLoaderData,
|
|
133
122
|
useLoaderDeps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.dev.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.dev.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_PROTOCOL_ALLOWLIST,
|
|
1
|
+
import { DEFAULT_PROTOCOL_ALLOWLIST, SearchParamError, cleanPath, composeRewrites, createControlledPromise, createRouterConfig, createSerializationAdapter, deepEqual, defaultParseSearch, defaultStringifySearch, defer, functionalUpdate, interpolatePath, isMatch, isNotFound, isPlainArray, isPlainObject, isRedirect, joinPaths, lazyFn, notFound, parseSearchWith, redirect, replaceEqualDeep, resolvePath, retainSearchParams, rootRouteId, stringifySearchWith, stripSearchParams, trimPath, trimPathLeft, trimPathRight } from "@tanstack/router-core";
|
|
2
2
|
import { createBrowserHistory, createHashHistory, createHistory, createMemoryHistory } from "@tanstack/history";
|
|
3
3
|
import { Await, useAwaited } from "./awaited.js";
|
|
4
4
|
import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
|
|
@@ -6,7 +6,6 @@ import { FileRoute, FileRouteLoader, LazyRoute, createFileRoute, createLazyFileR
|
|
|
6
6
|
import { lazyRouteComponent } from "./lazyRouteComponent.js";
|
|
7
7
|
import { Link, createLink, linkOptions, useLinkProps } from "./link.js";
|
|
8
8
|
import { MatchRoute, Matches, useChildMatches, useMatchRoute, useMatches, useParentMatches } from "./Matches.js";
|
|
9
|
-
import { matchContext } from "./matchContext.js";
|
|
10
9
|
import { Match, Outlet } from "./Match.js";
|
|
11
10
|
import { useMatch } from "./useMatch.js";
|
|
12
11
|
import { useLoaderDeps } from "./useLoaderDeps.js";
|
|
@@ -19,13 +18,11 @@ import { Block, useBlocker } from "./useBlocker.js";
|
|
|
19
18
|
import { Navigate, useNavigate } from "./useNavigate.js";
|
|
20
19
|
import { useParams } from "./useParams.js";
|
|
21
20
|
import { useSearch } from "./useSearch.js";
|
|
22
|
-
import { getRouterContext } from "./routerContext.js";
|
|
23
21
|
import { useRouteContext } from "./useRouteContext.js";
|
|
24
22
|
import { useRouter } from "./useRouter.js";
|
|
25
23
|
import { useRouterState } from "./useRouterState.js";
|
|
26
24
|
import { useLocation } from "./useLocation.js";
|
|
27
25
|
import { useCanGoBack } from "./useCanGoBack.js";
|
|
28
|
-
import { useLayoutEffect } from "./utils.js";
|
|
29
26
|
import { CatchNotFound, DefaultGlobalNotFound } from "./not-found.js";
|
|
30
27
|
import { ScriptOnce } from "./ScriptOnce.js";
|
|
31
28
|
import { Asset } from "./Asset.js";
|
|
@@ -58,7 +55,6 @@ export {
|
|
|
58
55
|
Navigate,
|
|
59
56
|
NotFoundRoute,
|
|
60
57
|
Outlet,
|
|
61
|
-
PathParamError,
|
|
62
58
|
RootRoute,
|
|
63
59
|
Route,
|
|
64
60
|
RouteApi,
|
|
@@ -69,9 +65,7 @@ export {
|
|
|
69
65
|
Scripts,
|
|
70
66
|
ScrollRestoration,
|
|
71
67
|
SearchParamError,
|
|
72
|
-
TSR_DEFERRED_PROMISE,
|
|
73
68
|
cleanPath,
|
|
74
|
-
componentTypes,
|
|
75
69
|
composeRewrites,
|
|
76
70
|
createBrowserHistory,
|
|
77
71
|
createControlledPromise,
|
|
@@ -91,13 +85,10 @@ export {
|
|
|
91
85
|
createSerializationAdapter,
|
|
92
86
|
deepEqual,
|
|
93
87
|
defaultParseSearch,
|
|
94
|
-
defaultSerializeError,
|
|
95
88
|
defaultStringifySearch,
|
|
96
89
|
defer,
|
|
97
90
|
functionalUpdate,
|
|
98
|
-
getInitialRouterState,
|
|
99
91
|
getRouteApi,
|
|
100
|
-
getRouterContext,
|
|
101
92
|
interpolatePath,
|
|
102
93
|
isMatch,
|
|
103
94
|
isNotFound,
|
|
@@ -108,7 +99,6 @@ export {
|
|
|
108
99
|
lazyFn,
|
|
109
100
|
lazyRouteComponent,
|
|
110
101
|
linkOptions,
|
|
111
|
-
matchContext,
|
|
112
102
|
notFound,
|
|
113
103
|
parseSearchWith,
|
|
114
104
|
redirect,
|
|
@@ -127,7 +117,6 @@ export {
|
|
|
127
117
|
useCanGoBack,
|
|
128
118
|
useChildMatches,
|
|
129
119
|
useElementScrollRestoration,
|
|
130
|
-
useLayoutEffect,
|
|
131
120
|
useLinkProps,
|
|
132
121
|
useLoaderData,
|
|
133
122
|
useLoaderDeps,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import { AnyRouter } from '@tanstack/router-core';
|
|
2
2
|
import * as Vue from 'vue';
|
|
3
|
-
export declare const
|
|
4
|
-
declare global {
|
|
5
|
-
interface Window {
|
|
6
|
-
__TSR_ROUTER_CONTEXT__?: Vue.InjectionKey<AnyRouter>;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Gets the router context, handling server-side rendering
|
|
11
|
-
* and ensuring a single instance across the application
|
|
12
|
-
*/
|
|
13
|
-
export declare function getRouterContext(): Vue.InjectionKey<AnyRouter>;
|
|
3
|
+
export declare const routerContext: Vue.InjectionKey<AnyRouter>;
|
|
14
4
|
/**
|
|
15
5
|
* Provides the router to all child components
|
|
16
6
|
*/
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import * as Vue from "vue";
|
|
2
|
-
const
|
|
3
|
-
function getRouterContext() {
|
|
4
|
-
if (typeof document === "undefined") {
|
|
5
|
-
return RouterSymbol;
|
|
6
|
-
}
|
|
7
|
-
if (window.__TSR_ROUTER_CONTEXT__) {
|
|
8
|
-
return window.__TSR_ROUTER_CONTEXT__;
|
|
9
|
-
}
|
|
10
|
-
window.__TSR_ROUTER_CONTEXT__ = RouterSymbol;
|
|
11
|
-
return RouterSymbol;
|
|
12
|
-
}
|
|
2
|
+
const routerContext = /* @__PURE__ */ Symbol("TanStackRouter");
|
|
13
3
|
function provideRouter(router) {
|
|
14
|
-
Vue.provide(
|
|
4
|
+
Vue.provide(routerContext, router);
|
|
15
5
|
}
|
|
16
6
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
provideRouter
|
|
7
|
+
provideRouter,
|
|
8
|
+
routerContext
|
|
20
9
|
};
|
|
21
10
|
//# sourceMappingURL=routerContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routerContext.js","sources":["../../src/routerContext.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport type { AnyRouter } from '@tanstack/router-core'\n\
|
|
1
|
+
{"version":3,"file":"routerContext.js","sources":["../../src/routerContext.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport type { AnyRouter } from '@tanstack/router-core'\n\nexport const routerContext = Symbol(\n 'TanStackRouter',\n) as Vue.InjectionKey<AnyRouter>\n\n/**\n * Provides the router to all child components\n */\nexport function provideRouter(router: AnyRouter): void {\n Vue.provide(routerContext, router)\n}\n\n/**\n * Injects the router from the component tree\n */\nexport function injectRouter(): AnyRouter {\n const router = Vue.inject<AnyRouter | null>(routerContext, null)\n if (!router) {\n throw new Error(\n 'No TanStack Router found in component tree. Did you forget to add a RouterProvider component?',\n )\n }\n return router\n}\n"],"names":["routerContext","Symbol","provideRouter","router","Vue","provide"],"mappings":";MAGaA,gBAAgBC,uBAC3B,gBACF;AAKO,SAASC,cAAcC,QAAyB;AACrDC,MAAIC,QAAQL,eAAeG,MAAM;AACnC;"}
|
package/dist/esm/useRouter.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as Vue from "vue";
|
|
2
2
|
import warning from "tiny-warning";
|
|
3
|
-
import {
|
|
3
|
+
import { routerContext } from "./routerContext.js";
|
|
4
4
|
function useRouter(opts) {
|
|
5
|
-
const value = Vue.inject(
|
|
5
|
+
const value = Vue.inject(routerContext, null);
|
|
6
6
|
warning(!((opts?.warn ?? true) && !value), "useRouter must be used inside a <RouterProvider> component!");
|
|
7
7
|
return value;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouter.js","sources":["../../src/useRouter.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport warning from 'tiny-warning'\nimport {
|
|
1
|
+
{"version":3,"file":"useRouter.js","sources":["../../src/useRouter.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport warning from 'tiny-warning'\nimport { routerContext } from './routerContext'\nimport type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'\n\nexport function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {\n warn?: boolean\n}): TRouter {\n const value = Vue.inject(routerContext as any, null)\n warning(\n !((opts?.warn ?? true) && !value),\n 'useRouter must be used inside a <RouterProvider> component!',\n )\n return value as any\n}\n"],"names":["useRouter","opts","value","Vue","inject","routerContext","warning","warn"],"mappings":";;;AAKO,SAASA,UAAwDC,MAE5D;AACV,QAAMC,QAAQC,IAAIC,OAAOC,eAAsB,IAAI;AACnDC,UACE,GAAGL,MAAMM,QAAQ,SAAS,CAACL,QAC3B,6DACF;AACA,SAAOA;AACT;"}
|
package/dist/esm/utils.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as Vue from "vue";
|
|
2
|
-
const useLayoutEffect = typeof window !== "undefined" ? Vue.effect : Vue.effect;
|
|
3
2
|
const usePrevious = (fn) => {
|
|
4
3
|
return Vue.computed(
|
|
5
4
|
(prev = {
|
|
@@ -38,7 +37,6 @@ function useIntersectionObserver(ref, callback, intersectionObserverOptions = {}
|
|
|
38
37
|
}
|
|
39
38
|
export {
|
|
40
39
|
useIntersectionObserver,
|
|
41
|
-
useLayoutEffect,
|
|
42
40
|
usePrevious
|
|
43
41
|
};
|
|
44
42
|
//# sourceMappingURL=utils.js.map
|
package/dist/esm/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["import * as Vue from 'vue'\n\nexport const useLayoutEffect =\n typeof window !== 'undefined' ? Vue.effect : Vue.effect\n\nexport const usePrevious = (fn: () => boolean) => {\n return Vue.computed(\n (\n prev: { current: boolean | null; previous: boolean | null } = {\n current: null,\n previous: null,\n },\n ) => {\n const current = fn()\n\n if (prev.current !== current) {\n prev.previous = prev.current\n prev.current = current\n }\n\n return prev\n },\n )\n}\n\n/**\n * React hook to wrap `IntersectionObserver`.\n *\n * This hook will create an `IntersectionObserver` and observe the ref passed to it.\n *\n * When the intersection changes, the callback will be called with the `IntersectionObserverEntry`.\n *\n * @param ref - The ref to observe\n * @param intersectionObserverOptions - The options to pass to the IntersectionObserver\n * @param options - The options to pass to the hook\n * @param callback - The callback to call when the intersection changes\n * @returns The IntersectionObserver instance\n * @example\n * ```tsx\n * const MyComponent = () => {\n * const ref = React.useRef<HTMLDivElement>(null)\n * useIntersectionObserver(\n * ref,\n * (entry) => { doSomething(entry) },\n * { rootMargin: '10px' },\n * { disabled: false }\n * )\n * return <div ref={ref} />\n * ```\n */\nexport function useIntersectionObserver<T extends Element>(\n ref: Vue.Ref<T | null>,\n callback: (entry: IntersectionObserverEntry | undefined) => void,\n intersectionObserverOptions: IntersectionObserverInit = {},\n options: { disabled?: boolean | (() => boolean) } = {},\n): Vue.Ref<IntersectionObserver | null> {\n const isIntersectionObserverAvailable =\n typeof IntersectionObserver === 'function'\n const observerRef = Vue.ref<IntersectionObserver | null>(null)\n\n // Use watchEffect with cleanup to properly manage the observer lifecycle\n Vue.watchEffect((onCleanup) => {\n const r = ref.value\n // Support both static boolean and function for disabled check\n const isDisabled =\n typeof options.disabled === 'function'\n ? options.disabled()\n : options.disabled\n if (!r || !isIntersectionObserverAvailable || isDisabled) {\n return\n }\n\n const observer = new IntersectionObserver(([entry]) => {\n callback(entry)\n }, intersectionObserverOptions)\n\n observerRef.value = observer\n observer.observe(r)\n\n onCleanup(() => {\n observer.disconnect()\n observerRef.value = null\n })\n })\n\n return observerRef\n}\n\nexport function splitProps<T extends Record<string, any>>(\n props: T,\n keys: Array<keyof T>,\n) {\n // Get the specified props\n const selectedProps = Vue.computed(() => {\n return Object.fromEntries(keys.map((key) => [key, props[key]]))\n })\n\n // Get remaining props as attrs\n const remainingAttrs = Vue.computed(() => {\n const attrs = Vue.useAttrs()\n return Object.fromEntries(\n Object.entries(attrs).filter(([key]) => !keys.includes(key as keyof T)),\n )\n })\n\n return [selectedProps, remainingAttrs]\n}\n\nexport type ParentProps<T = {}> = T & {\n children?: Vue.VNode | Array<Vue.VNode> | string\n}\n"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["import * as Vue from 'vue'\n\nexport const useLayoutEffect =\n typeof window !== 'undefined' ? Vue.effect : Vue.effect\n\nexport const usePrevious = (fn: () => boolean) => {\n return Vue.computed(\n (\n prev: { current: boolean | null; previous: boolean | null } = {\n current: null,\n previous: null,\n },\n ) => {\n const current = fn()\n\n if (prev.current !== current) {\n prev.previous = prev.current\n prev.current = current\n }\n\n return prev\n },\n )\n}\n\n/**\n * React hook to wrap `IntersectionObserver`.\n *\n * This hook will create an `IntersectionObserver` and observe the ref passed to it.\n *\n * When the intersection changes, the callback will be called with the `IntersectionObserverEntry`.\n *\n * @param ref - The ref to observe\n * @param intersectionObserverOptions - The options to pass to the IntersectionObserver\n * @param options - The options to pass to the hook\n * @param callback - The callback to call when the intersection changes\n * @returns The IntersectionObserver instance\n * @example\n * ```tsx\n * const MyComponent = () => {\n * const ref = React.useRef<HTMLDivElement>(null)\n * useIntersectionObserver(\n * ref,\n * (entry) => { doSomething(entry) },\n * { rootMargin: '10px' },\n * { disabled: false }\n * )\n * return <div ref={ref} />\n * ```\n */\nexport function useIntersectionObserver<T extends Element>(\n ref: Vue.Ref<T | null>,\n callback: (entry: IntersectionObserverEntry | undefined) => void,\n intersectionObserverOptions: IntersectionObserverInit = {},\n options: { disabled?: boolean | (() => boolean) } = {},\n): Vue.Ref<IntersectionObserver | null> {\n const isIntersectionObserverAvailable =\n typeof IntersectionObserver === 'function'\n const observerRef = Vue.ref<IntersectionObserver | null>(null)\n\n // Use watchEffect with cleanup to properly manage the observer lifecycle\n Vue.watchEffect((onCleanup) => {\n const r = ref.value\n // Support both static boolean and function for disabled check\n const isDisabled =\n typeof options.disabled === 'function'\n ? options.disabled()\n : options.disabled\n if (!r || !isIntersectionObserverAvailable || isDisabled) {\n return\n }\n\n const observer = new IntersectionObserver(([entry]) => {\n callback(entry)\n }, intersectionObserverOptions)\n\n observerRef.value = observer\n observer.observe(r)\n\n onCleanup(() => {\n observer.disconnect()\n observerRef.value = null\n })\n })\n\n return observerRef\n}\n\nexport function splitProps<T extends Record<string, any>>(\n props: T,\n keys: Array<keyof T>,\n) {\n // Get the specified props\n const selectedProps = Vue.computed(() => {\n return Object.fromEntries(keys.map((key) => [key, props[key]]))\n })\n\n // Get remaining props as attrs\n const remainingAttrs = Vue.computed(() => {\n const attrs = Vue.useAttrs()\n return Object.fromEntries(\n Object.entries(attrs).filter(([key]) => !keys.includes(key as keyof T)),\n )\n })\n\n return [selectedProps, remainingAttrs]\n}\n\nexport type ParentProps<T = {}> = T & {\n children?: Vue.VNode | Array<Vue.VNode> | string\n}\n"],"names":[],"mappings":";AAKO,MAAM,cAAc,CAAC,OAAsB;AAChD,SAAO,IAAI;AAAA,IACT,CACE,OAA8D;AAAA,MAC5D,SAAS;AAAA,MACT,UAAU;AAAA,IAAA,MAET;AACH,YAAM,UAAU,GAAA;AAEhB,UAAI,KAAK,YAAY,SAAS;AAC5B,aAAK,WAAW,KAAK;AACrB,aAAK,UAAU;AAAA,MACjB;AAEA,aAAO;AAAA,IACT;AAAA,EAAA;AAEJ;AA2BO,SAAS,wBACd,KACA,UACA,8BAAwD,CAAA,GACxD,UAAoD,IACd;AACtC,QAAM,kCACJ,OAAO,yBAAyB;AAClC,QAAM,cAAc,IAAI,IAAiC,IAAI;AAG7D,MAAI,YAAY,CAAC,cAAc;AAC7B,UAAM,IAAI,IAAI;AAEd,UAAM,aACJ,OAAO,QAAQ,aAAa,aACxB,QAAQ,aACR,QAAQ;AACd,QAAI,CAAC,KAAK,CAAC,mCAAmC,YAAY;AACxD;AAAA,IACF;AAEA,UAAM,WAAW,IAAI,qBAAqB,CAAC,CAAC,KAAK,MAAM;AACrD,eAAS,KAAK;AAAA,IAChB,GAAG,2BAA2B;AAE9B,gBAAY,QAAQ;AACpB,aAAS,QAAQ,CAAC;AAElB,cAAU,MAAM;AACd,eAAS,WAAA;AACT,kBAAY,QAAQ;AAAA,IACtB,CAAC;AAAA,EACH,CAAC;AAED,SAAO;AACT;"}
|
package/dist/source/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { defer,
|
|
1
|
+
export { defer, isMatch, joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, interpolatePath, rootRouteId, defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, createControlledPromise, retainSearchParams, stripSearchParams, createSerializationAdapter, } from '@tanstack/router-core';
|
|
2
2
|
export type { AnyRoute, DeferredPromiseState, DeferredPromise, ParsedLocation, RemoveTrailingSlashes, RemoveLeadingSlashes, ActiveOptions, ResolveRelativePath, RootRouteId, AnyPathParams, ResolveParams, ResolveOptionalParams, ResolveRequiredParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, UpdatableStaticRouteOption, MetaDescriptor, RouteLinkEntry, ParseParamsFn, SearchFilter, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, TrimPath, TrimPathLeft, TrimPathRight, StringifyParamsFn, ParamsOptions, InferAllParams, InferAllContext, LooseReturnType, LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveLoaderData, ResolveRouteContext, SearchSerializer, SearchParser, TrailingSlashOption, Manifest, RouterManagedTag, ControlledPromise, Constrain, Expand, MergeAll, Assign, IntersectAssign, ResolveValidatorInput, ResolveValidatorOutput, Register, AnyValidator, DefaultValidator, ValidatorFn, AnySchema, AnyValidatorAdapter, AnyValidatorFn, AnyValidatorObj, ResolveValidatorInputFn, ResolveValidatorOutputFn, ResolveSearchValidatorInput, ResolveSearchValidatorInputFn, Validator, ValidatorAdapter, ValidatorObj, FileRoutesByPath, RouteById, RootRouteOptions, CreateFileRoute, SerializationAdapter, AnySerializationAdapter, SerializableExtensions, } from '@tanstack/router-core';
|
|
3
3
|
export { createHistory, createBrowserHistory, createHashHistory, createMemoryHistory, } from '@tanstack/history';
|
|
4
4
|
export type { BlockerFn, HistoryLocation, RouterHistory, ParsedPath, HistoryState, } from '@tanstack/history';
|
|
@@ -13,7 +13,6 @@ export type { InferDescendantToPaths, RelativeToPath, RelativeToParentPath, Rela
|
|
|
13
13
|
export type { UseLinkPropsOptions, ActiveLinkOptions, LinkProps, LinkComponent, LinkComponentRoute, LinkComponentProps, CreateLinkProps, } from './link';
|
|
14
14
|
export { Matches, useMatchRoute, MatchRoute, useMatches, useParentMatches, useChildMatches, } from './Matches';
|
|
15
15
|
export type { UseMatchRouteOptions, MakeMatchRouteOptions } from './Matches';
|
|
16
|
-
export { matchContext } from './matchContext';
|
|
17
16
|
export { Match, Outlet } from './Match';
|
|
18
17
|
export { useMatch } from './useMatch';
|
|
19
18
|
export { useLoaderDeps } from './useLoaderDeps';
|
|
@@ -22,7 +21,7 @@ export { redirect, isRedirect, createRouterConfig, DEFAULT_PROTOCOL_ALLOWLIST, }
|
|
|
22
21
|
export { RouteApi, getRouteApi, Route, createRoute, RootRoute, rootRouteWithContext, createRootRoute, createRootRouteWithContext, createRouteMask, NotFoundRoute, } from './route';
|
|
23
22
|
export type { AnyRootRoute, VueNode, SyncRouteComponent, AsyncRouteComponent, RouteComponent, ErrorRouteComponent, NotFoundRouteComponent, } from './route';
|
|
24
23
|
export { createRouter, Router } from './router';
|
|
25
|
-
export {
|
|
24
|
+
export { lazyFn, SearchParamError } from '@tanstack/router-core';
|
|
26
25
|
export { RouterProvider, RouterContextProvider } from './RouterProvider';
|
|
27
26
|
export type { RouterProps } from './RouterProvider';
|
|
28
27
|
export { useElementScrollRestoration, ScrollRestoration, } from './ScrollRestoration';
|
|
@@ -31,13 +30,11 @@ export { useBlocker, Block } from './useBlocker';
|
|
|
31
30
|
export { useNavigate, Navigate } from './useNavigate';
|
|
32
31
|
export { useParams } from './useParams';
|
|
33
32
|
export { useSearch } from './useSearch';
|
|
34
|
-
export { getRouterContext, } from './routerContext';
|
|
35
33
|
export { useRouteContext } from './useRouteContext';
|
|
36
34
|
export { useRouter } from './useRouter';
|
|
37
35
|
export { useRouterState } from './useRouterState';
|
|
38
36
|
export { useLocation } from './useLocation';
|
|
39
37
|
export { useCanGoBack } from './useCanGoBack';
|
|
40
|
-
export { useLayoutEffect } from './utils';
|
|
41
38
|
export { CatchNotFound, DefaultGlobalNotFound } from './not-found';
|
|
42
39
|
export { notFound, isNotFound } from '@tanstack/router-core';
|
|
43
40
|
export type { NotFoundError } from '@tanstack/router-core';
|
package/dist/source/index.jsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { defer,
|
|
1
|
+
export { defer, isMatch, joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, interpolatePath, rootRouteId, defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, createControlledPromise, retainSearchParams, stripSearchParams, createSerializationAdapter, } from '@tanstack/router-core';
|
|
2
2
|
export { createHistory, createBrowserHistory, createHashHistory, createMemoryHistory, } from '@tanstack/history';
|
|
3
3
|
export { useAwaited, Await } from './awaited';
|
|
4
4
|
export { CatchBoundary, ErrorComponent } from './CatchBoundary';
|
|
@@ -7,7 +7,6 @@ export * from './history';
|
|
|
7
7
|
export { lazyRouteComponent } from './lazyRouteComponent';
|
|
8
8
|
export { useLinkProps, createLink, Link, linkOptions } from './link';
|
|
9
9
|
export { Matches, useMatchRoute, MatchRoute, useMatches, useParentMatches, useChildMatches, } from './Matches';
|
|
10
|
-
export { matchContext } from './matchContext';
|
|
11
10
|
export { Match, Outlet } from './Match';
|
|
12
11
|
export { useMatch } from './useMatch';
|
|
13
12
|
export { useLoaderDeps } from './useLoaderDeps';
|
|
@@ -15,21 +14,18 @@ export { useLoaderData } from './useLoaderData';
|
|
|
15
14
|
export { redirect, isRedirect, createRouterConfig, DEFAULT_PROTOCOL_ALLOWLIST, } from '@tanstack/router-core';
|
|
16
15
|
export { RouteApi, getRouteApi, Route, createRoute, RootRoute, rootRouteWithContext, createRootRoute, createRootRouteWithContext, createRouteMask, NotFoundRoute, } from './route';
|
|
17
16
|
export { createRouter, Router } from './router';
|
|
18
|
-
export {
|
|
17
|
+
export { lazyFn, SearchParamError } from '@tanstack/router-core';
|
|
19
18
|
export { RouterProvider, RouterContextProvider } from './RouterProvider';
|
|
20
19
|
export { useElementScrollRestoration, ScrollRestoration, } from './ScrollRestoration';
|
|
21
20
|
export { useBlocker, Block } from './useBlocker';
|
|
22
21
|
export { useNavigate, Navigate } from './useNavigate';
|
|
23
22
|
export { useParams } from './useParams';
|
|
24
23
|
export { useSearch } from './useSearch';
|
|
25
|
-
export { getRouterContext, // SSR
|
|
26
|
-
} from './routerContext';
|
|
27
24
|
export { useRouteContext } from './useRouteContext';
|
|
28
25
|
export { useRouter } from './useRouter';
|
|
29
26
|
export { useRouterState } from './useRouterState';
|
|
30
27
|
export { useLocation } from './useLocation';
|
|
31
28
|
export { useCanGoBack } from './useCanGoBack';
|
|
32
|
-
export { useLayoutEffect } from './utils';
|
|
33
29
|
export { CatchNotFound, DefaultGlobalNotFound } from './not-found';
|
|
34
30
|
export { notFound, isNotFound } from '@tanstack/router-core';
|
|
35
31
|
export { ScriptOnce } from './ScriptOnce';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.jsx","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,
|
|
1
|
+
{"version":3,"file":"index.jsx","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,SAAS,EACT,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,WAAW,EACX,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,SAAS,EACT,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,uBAAuB,CAAA;AAoF9B,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,mBAAmB,CAAA;AAU1B,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAG7C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAE/D,OAAO,EACL,SAAS,EACT,eAAe,EACf,eAAe,EACf,SAAS,EACT,eAAe,EACf,mBAAmB,GACpB,MAAM,aAAa,CAAA;AAEpB,cAAc,WAAW,CAAA;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAoFpE,OAAO,EACL,OAAO,EACP,aAAa,EACb,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,eAAe,GAChB,MAAM,WAAW,CAAA;AAIlB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EACL,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EACL,QAAQ,EACR,WAAW,EACX,KAAK,EACL,WAAW,EACX,SAAS,EACT,oBAAoB,EACpB,eAAe,EACf,0BAA0B,EAC1B,eAAe,EACf,aAAa,GACd,MAAM,SAAS,CAAA;AAWhB,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAE/C,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAEhE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAGxE,OAAO,EACL,2BAA2B,EAC3B,iBAAiB,GAClB,MAAM,qBAAqB,CAAA;AAG5B,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEhD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AA+B5D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAKvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import * as Vue from 'vue';
|
|
2
2
|
import type { AnyRouter } from '@tanstack/router-core';
|
|
3
|
-
export declare const
|
|
4
|
-
declare global {
|
|
5
|
-
interface Window {
|
|
6
|
-
__TSR_ROUTER_CONTEXT__?: Vue.InjectionKey<AnyRouter>;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Gets the router context, handling server-side rendering
|
|
11
|
-
* and ensuring a single instance across the application
|
|
12
|
-
*/
|
|
13
|
-
export declare function getRouterContext(): Vue.InjectionKey<AnyRouter>;
|
|
3
|
+
export declare const routerContext: Vue.InjectionKey<AnyRouter>;
|
|
14
4
|
/**
|
|
15
5
|
* Provides the router to all child components
|
|
16
6
|
*/
|
|
@@ -1,34 +1,16 @@
|
|
|
1
1
|
import * as Vue from 'vue';
|
|
2
|
-
|
|
3
|
-
export const RouterSymbol = Symbol('TanStackRouter');
|
|
4
|
-
/**
|
|
5
|
-
* Gets the router context, handling server-side rendering
|
|
6
|
-
* and ensuring a single instance across the application
|
|
7
|
-
*/
|
|
8
|
-
export function getRouterContext() {
|
|
9
|
-
if (typeof document === 'undefined') {
|
|
10
|
-
// For SSR, return the symbol directly
|
|
11
|
-
return RouterSymbol;
|
|
12
|
-
}
|
|
13
|
-
// In the browser, check if we have a cached context
|
|
14
|
-
if (window.__TSR_ROUTER_CONTEXT__) {
|
|
15
|
-
return window.__TSR_ROUTER_CONTEXT__;
|
|
16
|
-
}
|
|
17
|
-
// Create and cache the context
|
|
18
|
-
window.__TSR_ROUTER_CONTEXT__ = RouterSymbol;
|
|
19
|
-
return RouterSymbol;
|
|
20
|
-
}
|
|
2
|
+
export const routerContext = Symbol('TanStackRouter');
|
|
21
3
|
/**
|
|
22
4
|
* Provides the router to all child components
|
|
23
5
|
*/
|
|
24
6
|
export function provideRouter(router) {
|
|
25
|
-
Vue.provide(
|
|
7
|
+
Vue.provide(routerContext, router);
|
|
26
8
|
}
|
|
27
9
|
/**
|
|
28
10
|
* Injects the router from the component tree
|
|
29
11
|
*/
|
|
30
12
|
export function injectRouter() {
|
|
31
|
-
const router = Vue.inject(
|
|
13
|
+
const router = Vue.inject(routerContext, null);
|
|
32
14
|
if (!router) {
|
|
33
15
|
throw new Error('No TanStack Router found in component tree. Did you forget to add a RouterProvider component?');
|
|
34
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routerContext.jsx","sourceRoot":"","sources":["../../src/routerContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAG1B,
|
|
1
|
+
{"version":3,"file":"routerContext.jsx","sourceRoot":"","sources":["../../src/routerContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAG1B,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CACjC,gBAAgB,CACc,CAAA;AAEhC;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,MAAiB;IAC7C,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAmB,aAAa,EAAE,IAAI,CAAC,CAAA;IAChE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,+FAA+F,CAChG,CAAA;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as Vue from 'vue';
|
|
2
2
|
import warning from 'tiny-warning';
|
|
3
|
-
import {
|
|
3
|
+
import { routerContext } from './routerContext';
|
|
4
4
|
export function useRouter(opts) {
|
|
5
|
-
const value = Vue.inject(
|
|
5
|
+
const value = Vue.inject(routerContext, null);
|
|
6
6
|
warning(!((opts?.warn ?? true) && !value), 'useRouter must be used inside a <RouterProvider> component!');
|
|
7
7
|
return value;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouter.jsx","sourceRoot":"","sources":["../../src/useRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAC1B,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useRouter.jsx","sourceRoot":"","sources":["../../src/useRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAC1B,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAG/C,MAAM,UAAU,SAAS,CAA+C,IAEvE;IACC,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,aAAoB,EAAE,IAAI,CAAC,CAAA;IACpD,OAAO,CACL,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EACjC,6DAA6D,CAC9D,CAAA;IACD,OAAO,KAAY,CAAA;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/vue-router",
|
|
3
|
-
"version": "1.162.
|
|
3
|
+
"version": "1.162.5",
|
|
4
4
|
"description": "Modern and scalable routing for Vue applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"tiny-invariant": "^1.3.3",
|
|
65
65
|
"tiny-warning": "^1.0.3",
|
|
66
66
|
"@tanstack/history": "1.161.4",
|
|
67
|
-
"@tanstack/router-core": "1.162.
|
|
67
|
+
"@tanstack/router-core": "1.162.5"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@testing-library/jest-dom": "^6.6.3",
|
package/src/index.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export {
|
|
2
2
|
defer,
|
|
3
|
-
TSR_DEFERRED_PROMISE,
|
|
4
3
|
isMatch,
|
|
5
4
|
joinPaths,
|
|
6
5
|
cleanPath,
|
|
@@ -10,7 +9,6 @@ export {
|
|
|
10
9
|
resolvePath,
|
|
11
10
|
interpolatePath,
|
|
12
11
|
rootRouteId,
|
|
13
|
-
defaultSerializeError,
|
|
14
12
|
defaultParseSearch,
|
|
15
13
|
defaultStringifySearch,
|
|
16
14
|
parseSearchWith,
|
|
@@ -236,7 +234,6 @@ export {
|
|
|
236
234
|
|
|
237
235
|
export type { UseMatchRouteOptions, MakeMatchRouteOptions } from './Matches'
|
|
238
236
|
|
|
239
|
-
export { matchContext } from './matchContext'
|
|
240
237
|
export { Match, Outlet } from './Match'
|
|
241
238
|
|
|
242
239
|
export { useMatch } from './useMatch'
|
|
@@ -274,13 +271,7 @@ export type {
|
|
|
274
271
|
|
|
275
272
|
export { createRouter, Router } from './router'
|
|
276
273
|
|
|
277
|
-
export {
|
|
278
|
-
componentTypes,
|
|
279
|
-
lazyFn,
|
|
280
|
-
SearchParamError,
|
|
281
|
-
PathParamError,
|
|
282
|
-
getInitialRouterState,
|
|
283
|
-
} from '@tanstack/router-core'
|
|
274
|
+
export { lazyFn, SearchParamError } from '@tanstack/router-core'
|
|
284
275
|
|
|
285
276
|
export { RouterProvider, RouterContextProvider } from './RouterProvider'
|
|
286
277
|
export type { RouterProps } from './RouterProvider'
|
|
@@ -298,18 +289,12 @@ export { useNavigate, Navigate } from './useNavigate'
|
|
|
298
289
|
export { useParams } from './useParams'
|
|
299
290
|
export { useSearch } from './useSearch'
|
|
300
291
|
|
|
301
|
-
export {
|
|
302
|
-
getRouterContext, // SSR
|
|
303
|
-
} from './routerContext'
|
|
304
|
-
|
|
305
292
|
export { useRouteContext } from './useRouteContext'
|
|
306
293
|
export { useRouter } from './useRouter'
|
|
307
294
|
export { useRouterState } from './useRouterState'
|
|
308
295
|
export { useLocation } from './useLocation'
|
|
309
296
|
export { useCanGoBack } from './useCanGoBack'
|
|
310
297
|
|
|
311
|
-
export { useLayoutEffect } from './utils'
|
|
312
|
-
|
|
313
298
|
export { CatchNotFound, DefaultGlobalNotFound } from './not-found'
|
|
314
299
|
export { notFound, isNotFound } from '@tanstack/router-core'
|
|
315
300
|
export type { NotFoundError } from '@tanstack/router-core'
|
package/src/routerContext.tsx
CHANGED
|
@@ -1,49 +1,22 @@
|
|
|
1
1
|
import * as Vue from 'vue'
|
|
2
2
|
import type { AnyRouter } from '@tanstack/router-core'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
export const RouterSymbol = Symbol(
|
|
4
|
+
export const routerContext = Symbol(
|
|
6
5
|
'TanStackRouter',
|
|
7
6
|
) as Vue.InjectionKey<AnyRouter>
|
|
8
7
|
|
|
9
|
-
declare global {
|
|
10
|
-
interface Window {
|
|
11
|
-
__TSR_ROUTER_CONTEXT__?: Vue.InjectionKey<AnyRouter>
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Gets the router context, handling server-side rendering
|
|
17
|
-
* and ensuring a single instance across the application
|
|
18
|
-
*/
|
|
19
|
-
export function getRouterContext(): Vue.InjectionKey<AnyRouter> {
|
|
20
|
-
if (typeof document === 'undefined') {
|
|
21
|
-
// For SSR, return the symbol directly
|
|
22
|
-
return RouterSymbol
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// In the browser, check if we have a cached context
|
|
26
|
-
if (window.__TSR_ROUTER_CONTEXT__) {
|
|
27
|
-
return window.__TSR_ROUTER_CONTEXT__
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Create and cache the context
|
|
31
|
-
window.__TSR_ROUTER_CONTEXT__ = RouterSymbol
|
|
32
|
-
return RouterSymbol
|
|
33
|
-
}
|
|
34
|
-
|
|
35
8
|
/**
|
|
36
9
|
* Provides the router to all child components
|
|
37
10
|
*/
|
|
38
11
|
export function provideRouter(router: AnyRouter): void {
|
|
39
|
-
Vue.provide(
|
|
12
|
+
Vue.provide(routerContext, router)
|
|
40
13
|
}
|
|
41
14
|
|
|
42
15
|
/**
|
|
43
16
|
* Injects the router from the component tree
|
|
44
17
|
*/
|
|
45
18
|
export function injectRouter(): AnyRouter {
|
|
46
|
-
const router = Vue.inject<AnyRouter | null>(
|
|
19
|
+
const router = Vue.inject<AnyRouter | null>(routerContext, null)
|
|
47
20
|
if (!router) {
|
|
48
21
|
throw new Error(
|
|
49
22
|
'No TanStack Router found in component tree. Did you forget to add a RouterProvider component?',
|
package/src/useRouter.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as Vue from 'vue'
|
|
2
2
|
import warning from 'tiny-warning'
|
|
3
|
-
import {
|
|
3
|
+
import { routerContext } from './routerContext'
|
|
4
4
|
import type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'
|
|
5
5
|
|
|
6
6
|
export function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {
|
|
7
7
|
warn?: boolean
|
|
8
8
|
}): TRouter {
|
|
9
|
-
const value = Vue.inject(
|
|
9
|
+
const value = Vue.inject(routerContext as any, null)
|
|
10
10
|
warning(
|
|
11
11
|
!((opts?.warn ?? true) && !value),
|
|
12
12
|
'useRouter must be used inside a <RouterProvider> component!',
|