@depup/tanstack__react-router 1.167.1-depup.0 → 1.167.3-depup.0
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 +2 -2
- package/dist/cjs/Asset.cjs +115 -174
- package/dist/cjs/Asset.cjs.map +1 -1
- package/dist/cjs/CatchBoundary.cjs +92 -108
- package/dist/cjs/CatchBoundary.cjs.map +1 -1
- package/dist/cjs/ClientOnly.cjs +47 -13
- package/dist/cjs/ClientOnly.cjs.map +1 -1
- package/dist/cjs/HeadContent.cjs +23 -12
- package/dist/cjs/HeadContent.cjs.map +1 -1
- package/dist/cjs/HeadContent.dev.cjs +33 -38
- package/dist/cjs/HeadContent.dev.cjs.map +1 -1
- package/dist/cjs/Match.cjs +190 -247
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Matches.cjs +131 -118
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/RouterProvider.cjs +43 -27
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/SafeFragment.cjs +9 -5
- package/dist/cjs/SafeFragment.cjs.map +1 -1
- package/dist/cjs/ScriptOnce.cjs +17 -19
- package/dist/cjs/ScriptOnce.cjs.map +1 -1
- package/dist/cjs/Scripts.cjs +56 -54
- package/dist/cjs/Scripts.cjs.map +1 -1
- package/dist/cjs/ScrollRestoration.cjs +26 -30
- package/dist/cjs/ScrollRestoration.cjs.map +1 -1
- package/dist/cjs/Transitioner.cjs +109 -116
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/cjs/awaited.cjs +28 -43
- package/dist/cjs/awaited.cjs.map +1 -1
- package/dist/cjs/fileRoute.cjs +133 -95
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/headContentUtils.cjs +144 -181
- package/dist/cjs/headContentUtils.cjs.map +1 -1
- package/dist/cjs/index.cjs +249 -178
- package/dist/cjs/index.dev.cjs +249 -178
- package/dist/cjs/lazyRouteComponent.cjs +52 -67
- package/dist/cjs/lazyRouteComponent.cjs.map +1 -1
- package/dist/cjs/link.cjs +462 -556
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/matchContext.cjs +9 -25
- package/dist/cjs/matchContext.cjs.map +1 -1
- package/dist/cjs/not-found.cjs +25 -32
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/renderRouteNotFound.cjs +25 -19
- package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
- package/dist/cjs/route.cjs +258 -178
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/router.cjs +29 -16
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/routerContext.cjs +8 -22
- package/dist/cjs/routerContext.cjs.map +1 -1
- package/dist/cjs/scroll-restoration.cjs +23 -36
- package/dist/cjs/scroll-restoration.cjs.map +1 -1
- package/dist/cjs/ssr/RouterClient.cjs +16 -22
- package/dist/cjs/ssr/RouterClient.cjs.map +1 -1
- package/dist/cjs/ssr/RouterServer.cjs +10 -6
- package/dist/cjs/ssr/RouterServer.cjs.map +1 -1
- package/dist/cjs/ssr/client.cjs +10 -10
- package/dist/cjs/ssr/defaultRenderHandler.cjs +13 -14
- package/dist/cjs/ssr/defaultRenderHandler.cjs.map +1 -1
- package/dist/cjs/ssr/defaultStreamHandler.cjs +14 -15
- package/dist/cjs/ssr/defaultStreamHandler.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToStream.cjs +51 -71
- package/dist/cjs/ssr/renderRouterToStream.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToString.cjs +26 -29
- package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -1
- package/dist/cjs/ssr/server.cjs +18 -18
- package/dist/cjs/useBlocker.cjs +126 -162
- package/dist/cjs/useBlocker.cjs.map +1 -1
- package/dist/cjs/useCanGoBack.cjs +6 -5
- package/dist/cjs/useCanGoBack.cjs.map +1 -1
- package/dist/cjs/useLoaderData.cjs +24 -12
- package/dist/cjs/useLoaderData.cjs.map +1 -1
- package/dist/cjs/useLoaderDeps.cjs +23 -11
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useLocation.cjs +17 -7
- package/dist/cjs/useLocation.cjs.map +1 -1
- package/dist/cjs/useMatch.cjs +25 -44
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useNavigate.cjs +53 -43
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useParams.cjs +27 -14
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useRouteContext.cjs +9 -8
- package/dist/cjs/useRouteContext.cjs.map +1 -1
- package/dist/cjs/useRouter.cjs +23 -29
- package/dist/cjs/useRouter.cjs.map +1 -1
- package/dist/cjs/useRouterState.cjs +40 -35
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/useSearch.cjs +26 -13
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/utils.cjs +81 -51
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/esm/Asset.js +112 -156
- package/dist/esm/Asset.js.map +1 -1
- package/dist/esm/CatchBoundary.js +90 -92
- package/dist/esm/CatchBoundary.js.map +1 -1
- package/dist/esm/ClientOnly.js +45 -14
- package/dist/esm/ClientOnly.js.map +1 -1
- package/dist/esm/HeadContent.dev.js +31 -21
- package/dist/esm/HeadContent.dev.js.map +1 -1
- package/dist/esm/HeadContent.js +20 -11
- package/dist/esm/HeadContent.js.map +1 -1
- package/dist/esm/Match.js +181 -226
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +125 -103
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.js +41 -28
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/SafeFragment.js +8 -6
- package/dist/esm/SafeFragment.js.map +1 -1
- package/dist/esm/ScriptOnce.js +15 -18
- package/dist/esm/ScriptOnce.js.map +1 -1
- package/dist/esm/Scripts.js +55 -54
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/ScrollRestoration.js +25 -31
- package/dist/esm/ScrollRestoration.js.map +1 -1
- package/dist/esm/Transitioner.js +106 -98
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/awaited.js +26 -27
- package/dist/esm/awaited.js.map +1 -1
- package/dist/esm/fileRoute.js +127 -96
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/headContentUtils.js +141 -163
- package/dist/esm/headContentUtils.js.map +1 -1
- package/dist/esm/index.dev.js +16 -117
- package/dist/esm/index.js +18 -118
- package/dist/esm/lazyRouteComponent.js +50 -50
- package/dist/esm/lazyRouteComponent.js.map +1 -1
- package/dist/esm/link.js +459 -541
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/matchContext.js +8 -10
- package/dist/esm/matchContext.js.map +1 -1
- package/dist/esm/not-found.js +22 -32
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/renderRouteNotFound.js +21 -18
- package/dist/esm/renderRouteNotFound.js.map +1 -1
- package/dist/esm/route.js +249 -180
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.js +28 -17
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.js +7 -6
- package/dist/esm/routerContext.js.map +1 -1
- package/dist/esm/scroll-restoration.js +21 -35
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/ssr/RouterClient.js +14 -21
- package/dist/esm/ssr/RouterClient.js.map +1 -1
- package/dist/esm/ssr/RouterServer.js +8 -6
- package/dist/esm/ssr/RouterServer.js.map +1 -1
- package/dist/esm/ssr/client.js +1 -4
- package/dist/esm/ssr/defaultRenderHandler.js +12 -13
- package/dist/esm/ssr/defaultRenderHandler.js.map +1 -1
- package/dist/esm/ssr/defaultStreamHandler.js +13 -14
- package/dist/esm/ssr/defaultStreamHandler.js.map +1 -1
- package/dist/esm/ssr/renderRouterToStream.js +48 -70
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
- package/dist/esm/ssr/renderRouterToString.js +24 -29
- package/dist/esm/ssr/renderRouterToString.js.map +1 -1
- package/dist/esm/ssr/server.js +3 -10
- package/dist/esm/useBlocker.js +124 -146
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/esm/useCanGoBack.js +6 -5
- package/dist/esm/useCanGoBack.js.map +1 -1
- package/dist/esm/useLoaderData.js +24 -12
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.js +23 -11
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useLocation.js +17 -7
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.js +21 -26
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useNavigate.js +50 -26
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.js +27 -14
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouteContext.js +9 -8
- package/dist/esm/useRouteContext.js.map +1 -1
- package/dist/esm/useRouter.js +20 -12
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/esm/useRouterState.js +38 -34
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.js +26 -13
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.js +80 -39
- package/dist/esm/utils.js.map +1 -1
- package/package.json +5 -5
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.dev.cjs.map +0 -1
- package/dist/cjs/ssr/client.cjs.map +0 -1
- package/dist/cjs/ssr/server.cjs.map +0 -1
- package/dist/esm/index.dev.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/ssr/client.js.map +0 -1
- package/dist/esm/ssr/server.js.map +0 -1
package/dist/esm/fileRoute.js
CHANGED
|
@@ -1,109 +1,140 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createRoute } from "./route.js";
|
|
1
|
+
import { useRouter } from "./useRouter.js";
|
|
3
2
|
import { useMatch } from "./useMatch.js";
|
|
4
|
-
import { useLoaderDeps } from "./useLoaderDeps.js";
|
|
5
3
|
import { useLoaderData } from "./useLoaderData.js";
|
|
6
|
-
import {
|
|
4
|
+
import { useLoaderDeps } from "./useLoaderDeps.js";
|
|
7
5
|
import { useParams } from "./useParams.js";
|
|
6
|
+
import { useSearch } from "./useSearch.js";
|
|
8
7
|
import { useNavigate } from "./useNavigate.js";
|
|
9
|
-
import { useRouter } from "./useRouter.js";
|
|
10
8
|
import { useRouteContext } from "./useRouteContext.js";
|
|
9
|
+
import { createRoute } from "./route.js";
|
|
10
|
+
import warning from "tiny-warning";
|
|
11
|
+
//#region src/fileRoute.ts
|
|
12
|
+
/**
|
|
13
|
+
* Creates a file-based Route factory for a given path.
|
|
14
|
+
*
|
|
15
|
+
* Used by TanStack Router's file-based routing to associate a file with a
|
|
16
|
+
* route. The returned function accepts standard route options. In normal usage
|
|
17
|
+
* the `path` string is inserted and maintained by the `tsr` generator.
|
|
18
|
+
*
|
|
19
|
+
* @param path File path literal for the route (usually auto-generated).
|
|
20
|
+
* @returns A function that accepts Route options and returns a Route instance.
|
|
21
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction
|
|
22
|
+
*/
|
|
11
23
|
function createFileRoute(path) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
silent: true
|
|
15
|
-
}).createRoute(path);
|
|
16
|
-
}
|
|
17
|
-
return new FileRoute(path, {
|
|
18
|
-
silent: true
|
|
19
|
-
}).createRoute;
|
|
20
|
-
}
|
|
21
|
-
class FileRoute {
|
|
22
|
-
constructor(path, _opts) {
|
|
23
|
-
this.path = path;
|
|
24
|
-
this.createRoute = (options) => {
|
|
25
|
-
if (process.env.NODE_ENV !== "production") {
|
|
26
|
-
warning(
|
|
27
|
-
this.silent,
|
|
28
|
-
"FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead."
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
const route = createRoute(options);
|
|
32
|
-
route.isRoot = false;
|
|
33
|
-
return route;
|
|
34
|
-
};
|
|
35
|
-
this.silent = _opts?.silent;
|
|
36
|
-
}
|
|
24
|
+
if (typeof path === "object") return new FileRoute(path, { silent: true }).createRoute(path);
|
|
25
|
+
return new FileRoute(path, { silent: true }).createRoute;
|
|
37
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
@deprecated It's no longer recommended to use the `FileRoute` class directly.
|
|
29
|
+
Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
|
|
30
|
+
*/
|
|
31
|
+
var FileRoute = class {
|
|
32
|
+
constructor(path, _opts) {
|
|
33
|
+
this.path = path;
|
|
34
|
+
this.createRoute = (options) => {
|
|
35
|
+
if (process.env.NODE_ENV !== "production") warning(this.silent, "FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.");
|
|
36
|
+
const route = createRoute(options);
|
|
37
|
+
route.isRoot = false;
|
|
38
|
+
return route;
|
|
39
|
+
};
|
|
40
|
+
this.silent = _opts?.silent;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
@deprecated It's recommended not to split loaders into separate files.
|
|
45
|
+
Instead, place the loader function in the main route file via `createFileRoute`.
|
|
46
|
+
*/
|
|
38
47
|
function FileRouteLoader(_path) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
false,
|
|
42
|
-
`FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \`createFileRoute('/path/to/file')(options)\` options`
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
return (loaderFn) => loaderFn;
|
|
46
|
-
}
|
|
47
|
-
class LazyRoute {
|
|
48
|
-
constructor(opts) {
|
|
49
|
-
this.useMatch = (opts2) => {
|
|
50
|
-
return useMatch({
|
|
51
|
-
select: opts2?.select,
|
|
52
|
-
from: this.options.id,
|
|
53
|
-
structuralSharing: opts2?.structuralSharing
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
this.useRouteContext = (opts2) => {
|
|
57
|
-
return useRouteContext({ ...opts2, from: this.options.id });
|
|
58
|
-
};
|
|
59
|
-
this.useSearch = (opts2) => {
|
|
60
|
-
return useSearch({
|
|
61
|
-
select: opts2?.select,
|
|
62
|
-
structuralSharing: opts2?.structuralSharing,
|
|
63
|
-
from: this.options.id
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
this.useParams = (opts2) => {
|
|
67
|
-
return useParams({
|
|
68
|
-
select: opts2?.select,
|
|
69
|
-
structuralSharing: opts2?.structuralSharing,
|
|
70
|
-
from: this.options.id
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
this.useLoaderDeps = (opts2) => {
|
|
74
|
-
return useLoaderDeps({ ...opts2, from: this.options.id });
|
|
75
|
-
};
|
|
76
|
-
this.useLoaderData = (opts2) => {
|
|
77
|
-
return useLoaderData({ ...opts2, from: this.options.id });
|
|
78
|
-
};
|
|
79
|
-
this.useNavigate = () => {
|
|
80
|
-
const router = useRouter();
|
|
81
|
-
return useNavigate({ from: router.routesById[this.options.id].fullPath });
|
|
82
|
-
};
|
|
83
|
-
this.options = opts;
|
|
84
|
-
this.$$typeof = /* @__PURE__ */ Symbol.for("react.memo");
|
|
85
|
-
}
|
|
48
|
+
if (process.env.NODE_ENV !== "production") warning(false, `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \`createFileRoute('/path/to/file')(options)\` options`);
|
|
49
|
+
return (loaderFn) => loaderFn;
|
|
86
50
|
}
|
|
51
|
+
var LazyRoute = class {
|
|
52
|
+
constructor(opts) {
|
|
53
|
+
this.useMatch = (opts) => {
|
|
54
|
+
return useMatch({
|
|
55
|
+
select: opts?.select,
|
|
56
|
+
from: this.options.id,
|
|
57
|
+
structuralSharing: opts?.structuralSharing
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
this.useRouteContext = (opts) => {
|
|
61
|
+
return useRouteContext({
|
|
62
|
+
...opts,
|
|
63
|
+
from: this.options.id
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
this.useSearch = (opts) => {
|
|
67
|
+
return useSearch({
|
|
68
|
+
select: opts?.select,
|
|
69
|
+
structuralSharing: opts?.structuralSharing,
|
|
70
|
+
from: this.options.id
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
this.useParams = (opts) => {
|
|
74
|
+
return useParams({
|
|
75
|
+
select: opts?.select,
|
|
76
|
+
structuralSharing: opts?.structuralSharing,
|
|
77
|
+
from: this.options.id
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
this.useLoaderDeps = (opts) => {
|
|
81
|
+
return useLoaderDeps({
|
|
82
|
+
...opts,
|
|
83
|
+
from: this.options.id
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
this.useLoaderData = (opts) => {
|
|
87
|
+
return useLoaderData({
|
|
88
|
+
...opts,
|
|
89
|
+
from: this.options.id
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
this.useNavigate = () => {
|
|
93
|
+
return useNavigate({ from: useRouter().routesById[this.options.id].fullPath });
|
|
94
|
+
};
|
|
95
|
+
this.options = opts;
|
|
96
|
+
this.$$typeof = Symbol.for("react.memo");
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Creates a lazily-configurable code-based route stub by ID.
|
|
101
|
+
*
|
|
102
|
+
* Use this for code-splitting with code-based routes. The returned function
|
|
103
|
+
* accepts only non-critical route options like `component`, `pendingComponent`,
|
|
104
|
+
* `errorComponent`, and `notFoundComponent` which are applied when the route
|
|
105
|
+
* is matched.
|
|
106
|
+
*
|
|
107
|
+
* @param id Route ID string literal to associate with the lazy route.
|
|
108
|
+
* @returns A function that accepts lazy route options and returns a `LazyRoute`.
|
|
109
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction
|
|
110
|
+
*/
|
|
87
111
|
function createLazyRoute(id) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
112
|
+
return (opts) => {
|
|
113
|
+
return new LazyRoute({
|
|
114
|
+
id,
|
|
115
|
+
...opts
|
|
116
|
+
});
|
|
117
|
+
};
|
|
94
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Creates a lazily-configurable file-based route stub by file path.
|
|
121
|
+
*
|
|
122
|
+
* Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).
|
|
123
|
+
* The returned function accepts only non-critical route options like
|
|
124
|
+
* `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.
|
|
125
|
+
*
|
|
126
|
+
* @param id File path literal for the route file.
|
|
127
|
+
* @returns A function that accepts lazy route options and returns a `LazyRoute`.
|
|
128
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction
|
|
129
|
+
*/
|
|
95
130
|
function createLazyFileRoute(id) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
131
|
+
if (typeof id === "object") return new LazyRoute(id);
|
|
132
|
+
return (opts) => new LazyRoute({
|
|
133
|
+
id,
|
|
134
|
+
...opts
|
|
135
|
+
});
|
|
100
136
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
createFileRoute,
|
|
106
|
-
createLazyFileRoute,
|
|
107
|
-
createLazyRoute
|
|
108
|
-
};
|
|
109
|
-
//# sourceMappingURL=fileRoute.js.map
|
|
137
|
+
//#endregion
|
|
138
|
+
export { FileRoute, FileRouteLoader, LazyRoute, createFileRoute, createLazyFileRoute, createLazyRoute };
|
|
139
|
+
|
|
140
|
+
//# sourceMappingURL=fileRoute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileRoute.js","sources":["../../src/fileRoute.ts"],"sourcesContent":["import warning from 'tiny-warning'\nimport { createRoute } from './route'\n\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport { useRouter } from './useRouter'\nimport { useRouteContext } from './useRouteContext'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseSearchRoute } from './useSearch'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n FileBaseRouteOptions,\n FileRoutesByPath,\n LazyRouteOptions,\n Register,\n RegisteredRouter,\n ResolveParams,\n Route,\n RouteById,\n RouteConstraints,\n RouteIds,\n RouteLoaderEntry,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\n/**\n * Creates a file-based Route factory for a given path.\n *\n * Used by TanStack Router's file-based routing to associate a file with a\n * route. The returned function accepts standard route options. In normal usage\n * the `path` string is inserted and maintained by the `tsr` generator.\n *\n * @param path File path literal for the route (usually auto-generated).\n * @returns A function that accepts Route options and returns a Route instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction\n */\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends RouteConstraints['TFullPath'] =\n FileRoutesByPath[TFilePath]['fullPath'],\n>(\n path?: TFilePath,\n): FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>['createRoute'] {\n if (typeof path === 'object') {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute(path) as any\n }\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute\n}\n\n/** \n @deprecated It's no longer recommended to use the `FileRoute` class directly.\n Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.\n*/\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends RouteConstraints['TFullPath'] =\n FileRoutesByPath[TFilePath]['fullPath'],\n> {\n silent?: boolean\n\n constructor(\n public path?: TFilePath,\n _opts?: { silent: boolean },\n ) {\n this.silent = _opts?.silent\n }\n\n createRoute = <\n TRegister = Register,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n const TMiddlewares = unknown,\n THandlers = undefined,\n >(\n options?: FileBaseRouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n AnyContext,\n TSSR,\n TMiddlewares,\n THandlers\n > &\n UpdatableRouteOptions<\n TParentRoute,\n TId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): Route<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown,\n TSSR,\n TMiddlewares,\n THandlers\n > => {\n if (process.env.NODE_ENV !== 'production') {\n warning(\n this.silent,\n 'FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',\n )\n }\n const route = createRoute(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n\n/**\n @deprecated It's recommended not to split loaders into separate files.\n Instead, place the loader function in the main route file via `createFileRoute`.\n*/\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderFn>(\n loaderFn: Constrain<\n TLoaderFn,\n RouteLoaderEntry<\n Register,\n TRoute['parentRoute'],\n TRoute['types']['id'],\n TRoute['types']['params'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['routerContext'],\n TRoute['types']['routeContextFn'],\n TRoute['types']['beforeLoadFn']\n >\n >,\n) => TLoaderFn {\n if (process.env.NODE_ENV !== 'production') {\n warning(\n false,\n `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \\`createFileRoute('/path/to/file')(options)\\` options`,\n )\n }\n return (loaderFn) => loaderFn as any\n}\n\ndeclare module '@tanstack/router-core' {\n export interface LazyRoute<in out TRoute extends AnyRoute> {\n useMatch: UseMatchRoute<TRoute['id']>\n useRouteContext: UseRouteContextRoute<TRoute['id']>\n useSearch: UseSearchRoute<TRoute['id']>\n useParams: UseParamsRoute<TRoute['id']>\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>\n useLoaderData: UseLoaderDataRoute<TRoute['id']>\n useNavigate: () => UseNavigateResult<TRoute['fullPath']>\n }\n}\n\nexport class LazyRoute<TRoute extends AnyRoute> {\n options: {\n id: string\n } & LazyRouteOptions\n\n constructor(\n opts: {\n id: string\n } & LazyRouteOptions,\n ) {\n this.options = opts\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n useMatch: UseMatchRoute<TRoute['id']> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.options.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TRoute['id']> = (opts) => {\n return useRouteContext({ ...(opts as any), from: this.options.id })\n }\n\n useSearch: UseSearchRoute<TRoute['id']> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.options.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TRoute['id']> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.options.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TRoute['id']> = (opts) => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.options.id].fullPath })\n }\n}\n\n/**\n * Creates a lazily-configurable code-based route stub by ID.\n *\n * Use this for code-splitting with code-based routes. The returned function\n * accepts only non-critical route options like `component`, `pendingComponent`,\n * `errorComponent`, and `notFoundComponent` which are applied when the route\n * is matched.\n *\n * @param id Route ID string literal to associate with the lazy route.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction\n */\nexport function createLazyRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n TId extends string = string,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({\n id: id,\n ...opts,\n })\n }\n}\n\n/**\n * Creates a lazily-configurable file-based route stub by file path.\n *\n * Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).\n * The returned function accepts only non-critical route options like\n * `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.\n *\n * @param id File path literal for the route file.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction\n */\nexport function createLazyFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(id: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute> {\n if (typeof id === 'object') {\n return new LazyRoute<TRoute>(id) as any\n }\n\n return (opts: LazyRouteOptions) => new LazyRoute<TRoute>({ id, ...opts })\n}\n"],"names":["opts"],"mappings":";;;;;;;;;;AAiDO,SAAS,gBAQd,MAC0E;AAC1E,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO,IAAI,UAA0D,MAAM;AAAA,MACzE,QAAQ;AAAA,IAAA,CACT,EAAE,YAAY,IAAI;AAAA,EACrB;AACA,SAAO,IAAI,UAA0D,MAAM;AAAA,IACzE,QAAQ;AAAA,EAAA,CACT,EAAE;AACL;AAMO,MAAM,UAOX;AAAA,EAGA,YACS,MACP,OACA;AAFO,SAAA,OAAA;AAMT,SAAA,cAAc,CAaZ,YAgDG;AACH,UAAI,QAAQ,IAAI,aAAa,cAAc;AACzC;AAAA,UACE,KAAK;AAAA,UACL;AAAA,QAAA;AAAA,MAEJ;AACA,YAAM,QAAQ,YAAY,OAAc;AACtC,YAAc,SAAS;AACzB,aAAO;AAAA,IACT;AA1EE,SAAK,SAAS,OAAO;AAAA,EACvB;AA0EF;AAMO,SAAS,gBAId,OAea;AACb,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC;AAAA,MACE;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACA,SAAO,CAAC,aAAa;AACvB;AAcO,MAAM,UAAmC;AAAA,EAK9C,YACE,MAGA;AAKF,SAAA,WAAwC,CAACA,UAAS;AAChD,aAAO,SAAS;AAAA,QACd,QAAQA,OAAM;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,QACnB,mBAAmBA,OAAM;AAAA,MAAA,CACnB;AAAA,IACV;AAEA,SAAA,kBAAsD,CAACA,UAAS;AAC9D,aAAO,gBAAgB,EAAE,GAAIA,OAAc,MAAM,KAAK,QAAQ,IAAI;AAAA,IACpE;AAEA,SAAA,YAA0C,CAACA,UAAS;AAElD,aAAO,UAAU;AAAA,QACf,QAAQA,OAAM;AAAA,QACd,mBAAmBA,OAAM;AAAA,QACzB,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,YAA0C,CAACA,UAAS;AAElD,aAAO,UAAU;AAAA,QACf,QAAQA,OAAM;AAAA,QACd,mBAAmBA,OAAM;AAAA,QACzB,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,gBAAkD,CAACA,UAAS;AAC1D,aAAO,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,gBAAkD,CAACA,UAAS;AAC1D,aAAO,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,cAAc,MAA6C;AACzD,YAAM,SAAS,UAAA;AACf,aAAO,YAAY,EAAE,MAAM,OAAO,WAAW,KAAK,QAAQ,EAAE,EAAE,UAAU;AAAA,IAC1E;AA7CE,SAAK,UAAU;AACb,SAAa,WAAW,uBAAO,IAAI,YAAY;AAAA,EACnD;AA4CF;AAcO,SAAS,gBAId,IAA2D;AAC3D,SAAO,CAAC,SAA2B;AACjC,WAAO,IAAI,UAAkB;AAAA,MAC3B;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA,EACH;AACF;AAaO,SAAS,oBAGd,IAA8D;AAC9D,MAAI,OAAO,OAAO,UAAU;AAC1B,WAAO,IAAI,UAAkB,EAAE;AAAA,EACjC;AAEA,SAAO,CAAC,SAA2B,IAAI,UAAkB,EAAE,IAAI,GAAG,MAAM;AAC1E;"}
|
|
1
|
+
{"version":3,"file":"fileRoute.js","names":[],"sources":["../../src/fileRoute.ts"],"sourcesContent":["import warning from 'tiny-warning'\nimport { createRoute } from './route'\n\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport { useRouter } from './useRouter'\nimport { useRouteContext } from './useRouteContext'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseSearchRoute } from './useSearch'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n FileBaseRouteOptions,\n FileRoutesByPath,\n LazyRouteOptions,\n Register,\n RegisteredRouter,\n ResolveParams,\n Route,\n RouteById,\n RouteConstraints,\n RouteIds,\n RouteLoaderEntry,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\n/**\n * Creates a file-based Route factory for a given path.\n *\n * Used by TanStack Router's file-based routing to associate a file with a\n * route. The returned function accepts standard route options. In normal usage\n * the `path` string is inserted and maintained by the `tsr` generator.\n *\n * @param path File path literal for the route (usually auto-generated).\n * @returns A function that accepts Route options and returns a Route instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction\n */\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends RouteConstraints['TFullPath'] =\n FileRoutesByPath[TFilePath]['fullPath'],\n>(\n path?: TFilePath,\n): FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>['createRoute'] {\n if (typeof path === 'object') {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute(path) as any\n }\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute\n}\n\n/** \n @deprecated It's no longer recommended to use the `FileRoute` class directly.\n Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.\n*/\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends RouteConstraints['TFullPath'] =\n FileRoutesByPath[TFilePath]['fullPath'],\n> {\n silent?: boolean\n\n constructor(\n public path?: TFilePath,\n _opts?: { silent: boolean },\n ) {\n this.silent = _opts?.silent\n }\n\n createRoute = <\n TRegister = Register,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n const TMiddlewares = unknown,\n THandlers = undefined,\n >(\n options?: FileBaseRouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n AnyContext,\n TSSR,\n TMiddlewares,\n THandlers\n > &\n UpdatableRouteOptions<\n TParentRoute,\n TId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): Route<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown,\n TSSR,\n TMiddlewares,\n THandlers\n > => {\n if (process.env.NODE_ENV !== 'production') {\n warning(\n this.silent,\n 'FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',\n )\n }\n const route = createRoute(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n\n/**\n @deprecated It's recommended not to split loaders into separate files.\n Instead, place the loader function in the main route file via `createFileRoute`.\n*/\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderFn>(\n loaderFn: Constrain<\n TLoaderFn,\n RouteLoaderEntry<\n Register,\n TRoute['parentRoute'],\n TRoute['types']['id'],\n TRoute['types']['params'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['routerContext'],\n TRoute['types']['routeContextFn'],\n TRoute['types']['beforeLoadFn']\n >\n >,\n) => TLoaderFn {\n if (process.env.NODE_ENV !== 'production') {\n warning(\n false,\n `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \\`createFileRoute('/path/to/file')(options)\\` options`,\n )\n }\n return (loaderFn) => loaderFn as any\n}\n\ndeclare module '@tanstack/router-core' {\n export interface LazyRoute<in out TRoute extends AnyRoute> {\n useMatch: UseMatchRoute<TRoute['id']>\n useRouteContext: UseRouteContextRoute<TRoute['id']>\n useSearch: UseSearchRoute<TRoute['id']>\n useParams: UseParamsRoute<TRoute['id']>\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>\n useLoaderData: UseLoaderDataRoute<TRoute['id']>\n useNavigate: () => UseNavigateResult<TRoute['fullPath']>\n }\n}\n\nexport class LazyRoute<TRoute extends AnyRoute> {\n options: {\n id: string\n } & LazyRouteOptions\n\n constructor(\n opts: {\n id: string\n } & LazyRouteOptions,\n ) {\n this.options = opts\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n useMatch: UseMatchRoute<TRoute['id']> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.options.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TRoute['id']> = (opts) => {\n return useRouteContext({ ...(opts as any), from: this.options.id })\n }\n\n useSearch: UseSearchRoute<TRoute['id']> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.options.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TRoute['id']> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.options.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TRoute['id']> = (opts) => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.options.id].fullPath })\n }\n}\n\n/**\n * Creates a lazily-configurable code-based route stub by ID.\n *\n * Use this for code-splitting with code-based routes. The returned function\n * accepts only non-critical route options like `component`, `pendingComponent`,\n * `errorComponent`, and `notFoundComponent` which are applied when the route\n * is matched.\n *\n * @param id Route ID string literal to associate with the lazy route.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction\n */\nexport function createLazyRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n TId extends string = string,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({\n id: id,\n ...opts,\n })\n }\n}\n\n/**\n * Creates a lazily-configurable file-based route stub by file path.\n *\n * Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).\n * The returned function accepts only non-critical route options like\n * `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.\n *\n * @param id File path literal for the route file.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction\n */\nexport function createLazyFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(id: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute> {\n if (typeof id === 'object') {\n return new LazyRoute<TRoute>(id) as any\n }\n\n return (opts: LazyRouteOptions) => new LazyRoute<TRoute>({ id, ...opts })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,gBAQd,MAC0E;AAC1E,KAAI,OAAO,SAAS,SAClB,QAAO,IAAI,UAA0D,MAAM,EACzE,QAAQ,MACT,CAAC,CAAC,YAAY,KAAK;AAEtB,QAAO,IAAI,UAA0D,MAAM,EACzE,QAAQ,MACT,CAAC,CAAC;;;;;;AAOL,IAAa,YAAb,MAOE;CAGA,YACE,MACA,OACA;AAFO,OAAA,OAAA;sBAmBP,YAgDG;AACH,OAAA,QAAA,IAAA,aAA6B,aAC3B,SACE,KAAK,QACL,kIACD;GAEH,MAAM,QAAQ,YAAY,QAAe;AACvC,SAAc,SAAS;AACzB,UAAO;;AAzEP,OAAK,SAAS,OAAO;;;;;;;AAiFzB,SAAgB,gBAId,OAea;AACb,KAAA,QAAA,IAAA,aAA6B,aAC3B,SACE,OACA,6MACD;AAEH,SAAQ,aAAa;;AAevB,IAAa,YAAb,MAAgD;CAK9C,YACE,MAGA;mBAKuC,SAAS;AAChD,UAAO,SAAS;IACd,QAAQ,MAAM;IACd,MAAM,KAAK,QAAQ;IACnB,mBAAmB,MAAM;IAC1B,CAAQ;;0BAG4C,SAAS;AAC9D,UAAO,gBAAgB;IAAE,GAAI;IAAc,MAAM,KAAK,QAAQ;IAAI,CAAC;;oBAG1B,SAAS;AAElD,UAAO,UAAU;IACf,QAAQ,MAAM;IACd,mBAAmB,MAAM;IACzB,MAAM,KAAK,QAAQ;IACpB,CAAQ;;oBAGgC,SAAS;AAElD,UAAO,UAAU;IACf,QAAQ,MAAM;IACd,mBAAmB,MAAM;IACzB,MAAM,KAAK,QAAQ;IACpB,CAAQ;;wBAGwC,SAAS;AAC1D,UAAO,cAAc;IAAE,GAAG;IAAM,MAAM,KAAK,QAAQ;IAAI,CAAQ;;wBAGd,SAAS;AAC1D,UAAO,cAAc;IAAE,GAAG;IAAM,MAAM,KAAK,QAAQ;IAAI,CAAQ;;2BAGN;AAEzD,UAAO,YAAY,EAAE,MADN,WAAW,CACQ,WAAW,KAAK,QAAQ,IAAI,UAAU,CAAC;;AA5CzE,OAAK,UAAU;AACb,OAAa,WAAW,OAAO,IAAI,aAAa;;;;;;;;;;;;;;;AA2DtD,SAAgB,gBAId,IAA2D;AAC3D,SAAQ,SAA2B;AACjC,SAAO,IAAI,UAAkB;GACvB;GACJ,GAAG;GACJ,CAAC;;;;;;;;;;;;;;AAeN,SAAgB,oBAGd,IAA8D;AAC9D,KAAI,OAAO,OAAO,SAChB,QAAO,IAAI,UAAkB,GAAG;AAGlC,SAAQ,SAA2B,IAAI,UAAkB;EAAE;EAAI,GAAG;EAAM,CAAC"}
|
|
@@ -1,168 +1,146 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { escapeHtml } from "@tanstack/router-core";
|
|
3
1
|
import { useRouter } from "./useRouter.js";
|
|
4
2
|
import { useRouterState } from "./useRouterState.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
},
|
|
136
|
-
children
|
|
137
|
-
})),
|
|
138
|
-
structuralSharing: true
|
|
139
|
-
});
|
|
140
|
-
return uniqBy(
|
|
141
|
-
[
|
|
142
|
-
...meta,
|
|
143
|
-
...preloadLinks,
|
|
144
|
-
...links,
|
|
145
|
-
...styles,
|
|
146
|
-
...headScripts
|
|
147
|
-
],
|
|
148
|
-
(d) => {
|
|
149
|
-
return JSON.stringify(d);
|
|
150
|
-
}
|
|
151
|
-
);
|
|
3
|
+
import { escapeHtml } from "@tanstack/router-core";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
//#region src/headContentUtils.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Build the list of head/link/meta/script tags to render for active matches.
|
|
8
|
+
* Used internally by `HeadContent`.
|
|
9
|
+
*/
|
|
10
|
+
var useTags = () => {
|
|
11
|
+
const router = useRouter();
|
|
12
|
+
const nonce = router.options.ssr?.nonce;
|
|
13
|
+
const routeMeta = useRouterState({ select: (state) => {
|
|
14
|
+
return state.matches.map((match) => match.meta).filter(Boolean);
|
|
15
|
+
} });
|
|
16
|
+
const meta = React$1.useMemo(() => {
|
|
17
|
+
const resultMeta = [];
|
|
18
|
+
const metaByAttribute = {};
|
|
19
|
+
let title;
|
|
20
|
+
for (let i = routeMeta.length - 1; i >= 0; i--) {
|
|
21
|
+
const metas = routeMeta[i];
|
|
22
|
+
for (let j = metas.length - 1; j >= 0; j--) {
|
|
23
|
+
const m = metas[j];
|
|
24
|
+
if (!m) continue;
|
|
25
|
+
if (m.title) {
|
|
26
|
+
if (!title) title = {
|
|
27
|
+
tag: "title",
|
|
28
|
+
children: m.title
|
|
29
|
+
};
|
|
30
|
+
} else if ("script:ld+json" in m) try {
|
|
31
|
+
const json = JSON.stringify(m["script:ld+json"]);
|
|
32
|
+
resultMeta.push({
|
|
33
|
+
tag: "script",
|
|
34
|
+
attrs: { type: "application/ld+json" },
|
|
35
|
+
children: escapeHtml(json)
|
|
36
|
+
});
|
|
37
|
+
} catch {}
|
|
38
|
+
else {
|
|
39
|
+
const attribute = m.name ?? m.property;
|
|
40
|
+
if (attribute) if (metaByAttribute[attribute]) continue;
|
|
41
|
+
else metaByAttribute[attribute] = true;
|
|
42
|
+
resultMeta.push({
|
|
43
|
+
tag: "meta",
|
|
44
|
+
attrs: {
|
|
45
|
+
...m,
|
|
46
|
+
nonce
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (title) resultMeta.push(title);
|
|
53
|
+
if (nonce) resultMeta.push({
|
|
54
|
+
tag: "meta",
|
|
55
|
+
attrs: {
|
|
56
|
+
property: "csp-nonce",
|
|
57
|
+
content: nonce
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
resultMeta.reverse();
|
|
61
|
+
return resultMeta;
|
|
62
|
+
}, [routeMeta, nonce]);
|
|
63
|
+
const links = useRouterState({
|
|
64
|
+
select: (state) => {
|
|
65
|
+
const constructed = state.matches.map((match) => match.links).filter(Boolean).flat(1).map((link) => ({
|
|
66
|
+
tag: "link",
|
|
67
|
+
attrs: {
|
|
68
|
+
...link,
|
|
69
|
+
nonce
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
72
|
+
const manifest = router.ssr?.manifest;
|
|
73
|
+
const assets = state.matches.map((match) => manifest?.routes[match.routeId]?.assets ?? []).filter(Boolean).flat(1).filter((asset) => asset.tag === "link").map((asset) => ({
|
|
74
|
+
tag: "link",
|
|
75
|
+
attrs: {
|
|
76
|
+
...asset.attrs,
|
|
77
|
+
suppressHydrationWarning: true,
|
|
78
|
+
nonce
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
return [...constructed, ...assets];
|
|
82
|
+
},
|
|
83
|
+
structuralSharing: true
|
|
84
|
+
});
|
|
85
|
+
const preloadLinks = useRouterState({
|
|
86
|
+
select: (state) => {
|
|
87
|
+
const preloadLinks = [];
|
|
88
|
+
state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach((route) => router.ssr?.manifest?.routes[route.id]?.preloads?.filter(Boolean).forEach((preload) => {
|
|
89
|
+
preloadLinks.push({
|
|
90
|
+
tag: "link",
|
|
91
|
+
attrs: {
|
|
92
|
+
rel: "modulepreload",
|
|
93
|
+
href: preload,
|
|
94
|
+
nonce
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}));
|
|
98
|
+
return preloadLinks;
|
|
99
|
+
},
|
|
100
|
+
structuralSharing: true
|
|
101
|
+
});
|
|
102
|
+
const styles = useRouterState({
|
|
103
|
+
select: (state) => state.matches.map((match) => match.styles).flat(1).filter(Boolean).map(({ children, ...attrs }) => ({
|
|
104
|
+
tag: "style",
|
|
105
|
+
attrs: {
|
|
106
|
+
...attrs,
|
|
107
|
+
nonce
|
|
108
|
+
},
|
|
109
|
+
children
|
|
110
|
+
})),
|
|
111
|
+
structuralSharing: true
|
|
112
|
+
});
|
|
113
|
+
const headScripts = useRouterState({
|
|
114
|
+
select: (state) => state.matches.map((match) => match.headScripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
|
|
115
|
+
tag: "script",
|
|
116
|
+
attrs: {
|
|
117
|
+
...script,
|
|
118
|
+
nonce
|
|
119
|
+
},
|
|
120
|
+
children
|
|
121
|
+
})),
|
|
122
|
+
structuralSharing: true
|
|
123
|
+
});
|
|
124
|
+
return uniqBy([
|
|
125
|
+
...meta,
|
|
126
|
+
...preloadLinks,
|
|
127
|
+
...links,
|
|
128
|
+
...styles,
|
|
129
|
+
...headScripts
|
|
130
|
+
], (d) => {
|
|
131
|
+
return JSON.stringify(d);
|
|
132
|
+
});
|
|
152
133
|
};
|
|
153
134
|
function uniqBy(arr, fn) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
return true;
|
|
162
|
-
});
|
|
135
|
+
const seen = /* @__PURE__ */ new Set();
|
|
136
|
+
return arr.filter((item) => {
|
|
137
|
+
const key = fn(item);
|
|
138
|
+
if (seen.has(key)) return false;
|
|
139
|
+
seen.add(key);
|
|
140
|
+
return true;
|
|
141
|
+
});
|
|
163
142
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
//# sourceMappingURL=headContentUtils.js.map
|
|
143
|
+
//#endregion
|
|
144
|
+
export { useTags };
|
|
145
|
+
|
|
146
|
+
//# sourceMappingURL=headContentUtils.js.map
|