@tanstack/vue-router 1.167.1 → 1.167.2

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.
Files changed (99) hide show
  1. package/dist/esm/Asset.js +107 -151
  2. package/dist/esm/Asset.js.map +1 -1
  3. package/dist/esm/Body.js +15 -24
  4. package/dist/esm/Body.js.map +1 -1
  5. package/dist/esm/CatchBoundary.js +112 -130
  6. package/dist/esm/CatchBoundary.js.map +1 -1
  7. package/dist/esm/ClientOnly.js +59 -29
  8. package/dist/esm/ClientOnly.js.map +1 -1
  9. package/dist/esm/HeadContent.dev.js +29 -23
  10. package/dist/esm/HeadContent.dev.js.map +1 -1
  11. package/dist/esm/HeadContent.js +21 -16
  12. package/dist/esm/HeadContent.js.map +1 -1
  13. package/dist/esm/Html.js +42 -61
  14. package/dist/esm/Html.js.map +1 -1
  15. package/dist/esm/Match.js +238 -319
  16. package/dist/esm/Match.js.map +1 -1
  17. package/dist/esm/Matches.js +127 -170
  18. package/dist/esm/Matches.js.map +1 -1
  19. package/dist/esm/RouterProvider.js +50 -65
  20. package/dist/esm/RouterProvider.js.map +1 -1
  21. package/dist/esm/ScriptOnce.js +31 -36
  22. package/dist/esm/ScriptOnce.js.map +1 -1
  23. package/dist/esm/Scripts.js +79 -101
  24. package/dist/esm/Scripts.js.map +1 -1
  25. package/dist/esm/ScrollRestoration.js +25 -29
  26. package/dist/esm/ScrollRestoration.js.map +1 -1
  27. package/dist/esm/Transitioner.js +146 -164
  28. package/dist/esm/Transitioner.js.map +1 -1
  29. package/dist/esm/awaited.js +27 -34
  30. package/dist/esm/awaited.js.map +1 -1
  31. package/dist/esm/fileRoute.js +90 -92
  32. package/dist/esm/fileRoute.js.map +1 -1
  33. package/dist/esm/headContentUtils.js +92 -123
  34. package/dist/esm/headContentUtils.js.map +1 -1
  35. package/dist/esm/index.dev.js +16 -118
  36. package/dist/esm/index.js +18 -119
  37. package/dist/esm/lazyRouteComponent.js +69 -82
  38. package/dist/esm/lazyRouteComponent.js.map +1 -1
  39. package/dist/esm/link.js +364 -385
  40. package/dist/esm/link.js.map +1 -1
  41. package/dist/esm/matchContext.js +16 -11
  42. package/dist/esm/matchContext.js.map +1 -1
  43. package/dist/esm/not-found.js +30 -40
  44. package/dist/esm/not-found.js.map +1 -1
  45. package/dist/esm/renderRouteNotFound.js +20 -15
  46. package/dist/esm/renderRouteNotFound.js.map +1 -1
  47. package/dist/esm/route.js +196 -174
  48. package/dist/esm/route.js.map +1 -1
  49. package/dist/esm/router.js +11 -11
  50. package/dist/esm/router.js.map +1 -1
  51. package/dist/esm/routerContext.js +10 -7
  52. package/dist/esm/routerContext.js.map +1 -1
  53. package/dist/esm/scroll-restoration.js +39 -50
  54. package/dist/esm/scroll-restoration.js.map +1 -1
  55. package/dist/esm/ssr/RouterClient.js +29 -43
  56. package/dist/esm/ssr/RouterClient.js.map +1 -1
  57. package/dist/esm/ssr/RouterServer.js +29 -32
  58. package/dist/esm/ssr/RouterServer.js.map +1 -1
  59. package/dist/esm/ssr/client.js +1 -4
  60. package/dist/esm/ssr/defaultRenderHandler.js +11 -13
  61. package/dist/esm/ssr/defaultRenderHandler.js.map +1 -1
  62. package/dist/esm/ssr/defaultStreamHandler.js +12 -15
  63. package/dist/esm/ssr/defaultStreamHandler.js.map +1 -1
  64. package/dist/esm/ssr/renderRouterToStream.js +47 -65
  65. package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
  66. package/dist/esm/ssr/renderRouterToString.js +24 -32
  67. package/dist/esm/ssr/renderRouterToString.js.map +1 -1
  68. package/dist/esm/ssr/server.js +3 -10
  69. package/dist/esm/useBlocker.js +243 -287
  70. package/dist/esm/useBlocker.js.map +1 -1
  71. package/dist/esm/useCanGoBack.js +6 -5
  72. package/dist/esm/useCanGoBack.js.map +1 -1
  73. package/dist/esm/useLoaderData.js +12 -11
  74. package/dist/esm/useLoaderData.js.map +1 -1
  75. package/dist/esm/useLoaderDeps.js +12 -14
  76. package/dist/esm/useLoaderDeps.js.map +1 -1
  77. package/dist/esm/useLocation.js +6 -7
  78. package/dist/esm/useLocation.js.map +1 -1
  79. package/dist/esm/useMatch.js +27 -35
  80. package/dist/esm/useMatch.js.map +1 -1
  81. package/dist/esm/useNavigate.js +18 -24
  82. package/dist/esm/useNavigate.js.map +1 -1
  83. package/dist/esm/useParams.js +13 -12
  84. package/dist/esm/useParams.js.map +1 -1
  85. package/dist/esm/useRouteContext.js +9 -8
  86. package/dist/esm/useRouteContext.js.map +1 -1
  87. package/dist/esm/useRouter.js +9 -8
  88. package/dist/esm/useRouter.js.map +1 -1
  89. package/dist/esm/useRouterState.js +18 -22
  90. package/dist/esm/useRouterState.js.map +1 -1
  91. package/dist/esm/useSearch.js +13 -12
  92. package/dist/esm/useSearch.js.map +1 -1
  93. package/dist/esm/utils.js +59 -38
  94. package/dist/esm/utils.js.map +1 -1
  95. package/package.json +3 -3
  96. package/dist/esm/index.dev.js.map +0 -1
  97. package/dist/esm/index.js.map +0 -1
  98. package/dist/esm/ssr/client.js.map +0 -1
  99. package/dist/esm/ssr/server.js.map +0 -1
@@ -1,172 +1,154 @@
1
- import * as Vue from "vue";
2
- import { trimPathRight, getLocationChangeInfo, handleHashScroll } from "@tanstack/router-core";
3
- import { isServer } from "@tanstack/router-core/isServer";
4
1
  import { useRouter } from "./useRouter.js";
5
2
  import { useRouterState } from "./useRouterState.js";
6
3
  import { usePrevious } from "./utils.js";
7
- let mountLoadForRouter = {
8
- router: null,
9
- mounted: false
4
+ import { getLocationChangeInfo, handleHashScroll, trimPathRight } from "@tanstack/router-core";
5
+ import * as Vue from "vue";
6
+ import { isServer } from "@tanstack/router-core/isServer";
7
+ //#region src/Transitioner.tsx
8
+ var mountLoadForRouter = {
9
+ router: null,
10
+ mounted: false
10
11
  };
12
+ /**
13
+ * Composable that sets up router transition logic.
14
+ * This is called from MatchesContent to set up:
15
+ * - router.startTransition
16
+ * - router.startViewTransition
17
+ * - History subscription
18
+ * - Router event watchers
19
+ *
20
+ * Must be called during component setup phase.
21
+ */
11
22
  function useTransitionerSetup() {
12
- const router = useRouter();
13
- if (isServer ?? router.isServer) {
14
- return;
15
- }
16
- const isLoading = useRouterState({
17
- select: ({
18
- isLoading: isLoading2
19
- }) => isLoading2
20
- });
21
- const isTransitioning = Vue.ref(false);
22
- const hasPendingMatches = useRouterState({
23
- select: (s) => s.matches.some((d) => d.status === "pending")
24
- });
25
- const previousIsLoading = usePrevious(() => isLoading.value);
26
- const isAnyPending = Vue.computed(() => isLoading.value || isTransitioning.value || hasPendingMatches.value);
27
- const previousIsAnyPending = usePrevious(() => isAnyPending.value);
28
- const isPagePending = Vue.computed(() => isLoading.value || hasPendingMatches.value);
29
- const previousIsPagePending = usePrevious(() => isPagePending.value);
30
- router.startTransition = (fn) => {
31
- isTransitioning.value = true;
32
- try {
33
- router.__store.setState((s) => ({
34
- ...s,
35
- isTransitioning: true
36
- }));
37
- } catch {
38
- }
39
- const endTransition = () => {
40
- Vue.nextTick(() => {
41
- try {
42
- isTransitioning.value = false;
43
- router.__store.setState((s) => ({
44
- ...s,
45
- isTransitioning: false
46
- }));
47
- } catch {
48
- }
49
- });
50
- };
51
- fn();
52
- endTransition();
53
- };
54
- const originalStartViewTransition = router.__tsrOriginalStartViewTransition ?? router.startViewTransition;
55
- router.__tsrOriginalStartViewTransition = originalStartViewTransition;
56
- router.startViewTransition = (fn) => {
57
- return originalStartViewTransition?.(async () => {
58
- await fn();
59
- await Vue.nextTick();
60
- });
61
- };
62
- let unsubscribe;
63
- Vue.onMounted(() => {
64
- unsubscribe = router.history.subscribe(router.load);
65
- const nextLocation = router.buildLocation({
66
- to: router.latestLocation.pathname,
67
- search: true,
68
- params: true,
69
- hash: true,
70
- state: true,
71
- _includeValidateSearch: true
72
- });
73
- if (trimPathRight(router.latestLocation.publicHref) !== trimPathRight(nextLocation.publicHref)) {
74
- router.commitLocation({
75
- ...nextLocation,
76
- replace: true
77
- });
78
- }
79
- });
80
- const isMounted = Vue.ref(false);
81
- Vue.onMounted(() => {
82
- isMounted.value = true;
83
- if (!isAnyPending.value) {
84
- router.__store.setState((s) => s.status === "pending" ? {
85
- ...s,
86
- status: "idle",
87
- resolvedLocation: s.location
88
- } : s);
89
- }
90
- });
91
- Vue.onUnmounted(() => {
92
- isMounted.value = false;
93
- if (unsubscribe) {
94
- unsubscribe();
95
- }
96
- });
97
- Vue.onMounted(() => {
98
- if (typeof window !== "undefined" && router.ssr || mountLoadForRouter.router === router && mountLoadForRouter.mounted) {
99
- return;
100
- }
101
- mountLoadForRouter = {
102
- router,
103
- mounted: true
104
- };
105
- const tryLoad = async () => {
106
- try {
107
- await router.load();
108
- } catch (err) {
109
- console.error(err);
110
- }
111
- };
112
- tryLoad();
113
- });
114
- Vue.watch(() => isLoading.value, (newValue) => {
115
- if (!isMounted.value) return;
116
- try {
117
- if (previousIsLoading.value.previous && !newValue) {
118
- router.emit({
119
- type: "onLoad",
120
- ...getLocationChangeInfo(router.state)
121
- });
122
- }
123
- } catch {
124
- }
125
- });
126
- Vue.watch(isPagePending, (newValue) => {
127
- if (!isMounted.value) return;
128
- try {
129
- if (previousIsPagePending.value.previous && !newValue) {
130
- router.emit({
131
- type: "onBeforeRouteMount",
132
- ...getLocationChangeInfo(router.state)
133
- });
134
- }
135
- } catch {
136
- }
137
- });
138
- Vue.watch(isAnyPending, (newValue) => {
139
- if (!isMounted.value) return;
140
- try {
141
- if (!newValue && router.__store.state.status === "pending") {
142
- router.__store.setState((s) => ({
143
- ...s,
144
- status: "idle",
145
- resolvedLocation: s.location
146
- }));
147
- }
148
- if (previousIsAnyPending.value.previous && !newValue) {
149
- const changeInfo = getLocationChangeInfo(router.state);
150
- router.emit({
151
- type: "onResolved",
152
- ...changeInfo
153
- });
154
- if (changeInfo.hrefChanged) {
155
- handleHashScroll(router);
156
- }
157
- }
158
- } catch {
159
- }
160
- });
23
+ const router = useRouter();
24
+ if (isServer ?? router.isServer) return;
25
+ const isLoading = useRouterState({ select: ({ isLoading }) => isLoading });
26
+ const isTransitioning = Vue.ref(false);
27
+ const hasPendingMatches = useRouterState({ select: (s) => s.matches.some((d) => d.status === "pending") });
28
+ const previousIsLoading = usePrevious(() => isLoading.value);
29
+ const isAnyPending = Vue.computed(() => isLoading.value || isTransitioning.value || hasPendingMatches.value);
30
+ const previousIsAnyPending = usePrevious(() => isAnyPending.value);
31
+ const isPagePending = Vue.computed(() => isLoading.value || hasPendingMatches.value);
32
+ const previousIsPagePending = usePrevious(() => isPagePending.value);
33
+ router.startTransition = (fn) => {
34
+ isTransitioning.value = true;
35
+ try {
36
+ router.__store.setState((s) => ({
37
+ ...s,
38
+ isTransitioning: true
39
+ }));
40
+ } catch {}
41
+ const endTransition = () => {
42
+ Vue.nextTick(() => {
43
+ try {
44
+ isTransitioning.value = false;
45
+ router.__store.setState((s) => ({
46
+ ...s,
47
+ isTransitioning: false
48
+ }));
49
+ } catch {}
50
+ });
51
+ };
52
+ fn();
53
+ endTransition();
54
+ };
55
+ const originalStartViewTransition = router.__tsrOriginalStartViewTransition ?? router.startViewTransition;
56
+ router.__tsrOriginalStartViewTransition = originalStartViewTransition;
57
+ router.startViewTransition = (fn) => {
58
+ return originalStartViewTransition?.(async () => {
59
+ await fn();
60
+ await Vue.nextTick();
61
+ });
62
+ };
63
+ let unsubscribe;
64
+ Vue.onMounted(() => {
65
+ unsubscribe = router.history.subscribe(router.load);
66
+ const nextLocation = router.buildLocation({
67
+ to: router.latestLocation.pathname,
68
+ search: true,
69
+ params: true,
70
+ hash: true,
71
+ state: true,
72
+ _includeValidateSearch: true
73
+ });
74
+ if (trimPathRight(router.latestLocation.publicHref) !== trimPathRight(nextLocation.publicHref)) router.commitLocation({
75
+ ...nextLocation,
76
+ replace: true
77
+ });
78
+ });
79
+ const isMounted = Vue.ref(false);
80
+ Vue.onMounted(() => {
81
+ isMounted.value = true;
82
+ if (!isAnyPending.value) router.__store.setState((s) => s.status === "pending" ? {
83
+ ...s,
84
+ status: "idle",
85
+ resolvedLocation: s.location
86
+ } : s);
87
+ });
88
+ Vue.onUnmounted(() => {
89
+ isMounted.value = false;
90
+ if (unsubscribe) unsubscribe();
91
+ });
92
+ Vue.onMounted(() => {
93
+ if (typeof window !== "undefined" && router.ssr || mountLoadForRouter.router === router && mountLoadForRouter.mounted) return;
94
+ mountLoadForRouter = {
95
+ router,
96
+ mounted: true
97
+ };
98
+ const tryLoad = async () => {
99
+ try {
100
+ await router.load();
101
+ } catch (err) {
102
+ console.error(err);
103
+ }
104
+ };
105
+ tryLoad();
106
+ });
107
+ Vue.watch(() => isLoading.value, (newValue) => {
108
+ if (!isMounted.value) return;
109
+ try {
110
+ if (previousIsLoading.value.previous && !newValue) router.emit({
111
+ type: "onLoad",
112
+ ...getLocationChangeInfo(router.state)
113
+ });
114
+ } catch {}
115
+ });
116
+ Vue.watch(isPagePending, (newValue) => {
117
+ if (!isMounted.value) return;
118
+ try {
119
+ if (previousIsPagePending.value.previous && !newValue) router.emit({
120
+ type: "onBeforeRouteMount",
121
+ ...getLocationChangeInfo(router.state)
122
+ });
123
+ } catch {}
124
+ });
125
+ Vue.watch(isAnyPending, (newValue) => {
126
+ if (!isMounted.value) return;
127
+ try {
128
+ if (!newValue && router.__store.state.status === "pending") router.__store.setState((s) => ({
129
+ ...s,
130
+ status: "idle",
131
+ resolvedLocation: s.location
132
+ }));
133
+ if (previousIsAnyPending.value.previous && !newValue) {
134
+ const changeInfo = getLocationChangeInfo(router.state);
135
+ router.emit({
136
+ type: "onResolved",
137
+ ...changeInfo
138
+ });
139
+ if (changeInfo.hrefChanged) handleHashScroll(router);
140
+ }
141
+ } catch {}
142
+ });
161
143
  }
162
144
  Vue.defineComponent({
163
- name: "Transitioner",
164
- setup() {
165
- useTransitionerSetup();
166
- return () => null;
167
- }
145
+ name: "Transitioner",
146
+ setup() {
147
+ useTransitionerSetup();
148
+ return () => null;
149
+ }
168
150
  });
169
- export {
170
- useTransitionerSetup
171
- };
172
- //# sourceMappingURL=Transitioner.js.map
151
+ //#endregion
152
+ export { useTransitionerSetup };
153
+
154
+ //# sourceMappingURL=Transitioner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Transitioner.js","sources":["../../src/Transitioner.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport {\n getLocationChangeInfo,\n handleHashScroll,\n trimPathRight,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport { usePrevious } from './utils'\n\n// Track mount state per router to avoid double-loading\nlet mountLoadForRouter = { router: null as any, mounted: false }\n\n/**\n * Composable that sets up router transition logic.\n * This is called from MatchesContent to set up:\n * - router.startTransition\n * - router.startViewTransition\n * - History subscription\n * - Router event watchers\n *\n * Must be called during component setup phase.\n */\nexport function useTransitionerSetup() {\n const router = useRouter()\n\n // Skip on server - no transitions needed\n if (isServer ?? router.isServer) {\n return\n }\n\n const isLoading = useRouterState({\n select: ({ isLoading }) => isLoading,\n })\n\n // Track if we're in a transition - using a ref to track async transitions\n const isTransitioning = Vue.ref(false)\n\n // Track pending state changes\n const hasPendingMatches = useRouterState({\n select: (s) => s.matches.some((d) => d.status === 'pending'),\n })\n\n const previousIsLoading = usePrevious(() => isLoading.value)\n\n const isAnyPending = Vue.computed(\n () => isLoading.value || isTransitioning.value || hasPendingMatches.value,\n )\n const previousIsAnyPending = usePrevious(() => isAnyPending.value)\n\n const isPagePending = Vue.computed(\n () => isLoading.value || hasPendingMatches.value,\n )\n const previousIsPagePending = usePrevious(() => isPagePending.value)\n\n // Implement startTransition similar to React/Solid\n // Vue doesn't have a native useTransition like React 18, so we simulate it\n // We also update the router state's isTransitioning flag so useMatch can check it\n router.startTransition = (fn: () => void | Promise<void>) => {\n isTransitioning.value = true\n // Also update the router state so useMatch knows we're transitioning\n try {\n router.__store.setState((s) => ({ ...s, isTransitioning: true }))\n } catch {\n // Ignore errors if component is unmounted\n }\n\n // Helper to end the transition\n const endTransition = () => {\n // Use nextTick to ensure Vue has processed all reactive updates\n Vue.nextTick(() => {\n try {\n isTransitioning.value = false\n router.__store.setState((s) => ({ ...s, isTransitioning: false }))\n } catch {\n // Ignore errors if component is unmounted\n }\n })\n }\n\n // Execute the function synchronously\n // The function internally may call startViewTransition which schedules async work\n // via document.startViewTransition, but we don't need to wait for it here\n // because Vue's reactivity will trigger re-renders when state changes\n fn()\n\n // End the transition on next tick to allow Vue to process reactive updates\n endTransition()\n }\n\n // Vue updates DOM asynchronously (next tick). The View Transitions API expects the\n // update callback promise to resolve only after the DOM has been updated.\n // Wrap the router-core implementation to await a Vue flush before resolving.\n const originalStartViewTransition:\n | undefined\n | ((fn: () => Promise<void>) => void) =\n (router as any).__tsrOriginalStartViewTransition ??\n router.startViewTransition\n\n ;(router as any).__tsrOriginalStartViewTransition =\n originalStartViewTransition\n\n router.startViewTransition = (fn: () => Promise<void>) => {\n return originalStartViewTransition?.(async () => {\n await fn()\n await Vue.nextTick()\n })\n }\n\n // Subscribe to location changes\n // and try to load the new location\n let unsubscribe: (() => void) | undefined\n\n Vue.onMounted(() => {\n unsubscribe = router.history.subscribe(router.load)\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n // Check if the current URL matches the canonical form.\n // Compare publicHref (browser-facing URL) for consistency with\n // the server-side redirect check in router.beforeLoad.\n if (\n trimPathRight(router.latestLocation.publicHref) !==\n trimPathRight(nextLocation.publicHref)\n ) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n })\n\n // Track if component is mounted to prevent updates after unmount\n const isMounted = Vue.ref(false)\n\n Vue.onMounted(() => {\n isMounted.value = true\n if (!isAnyPending.value) {\n router.__store.setState((s) =>\n s.status === 'pending'\n ? { ...s, status: 'idle', resolvedLocation: s.location }\n : s,\n )\n }\n })\n\n Vue.onUnmounted(() => {\n isMounted.value = false\n if (unsubscribe) {\n unsubscribe()\n }\n })\n\n // Try to load the initial location\n Vue.onMounted(() => {\n if (\n (typeof window !== 'undefined' && router.ssr) ||\n (mountLoadForRouter.router === router && mountLoadForRouter.mounted)\n ) {\n return\n }\n mountLoadForRouter = { router, mounted: true }\n const tryLoad = async () => {\n try {\n await router.load()\n } catch (err) {\n console.error(err)\n }\n }\n tryLoad()\n })\n\n // Setup watchers for emitting events\n // All watchers check isMounted to prevent updates after unmount\n Vue.watch(\n () => isLoading.value,\n (newValue) => {\n if (!isMounted.value) return\n try {\n if (previousIsLoading.value.previous && !newValue) {\n router.emit({\n type: 'onLoad',\n ...getLocationChangeInfo(router.state),\n })\n }\n } catch {\n // Ignore errors if component is unmounted\n }\n },\n )\n\n Vue.watch(isPagePending, (newValue) => {\n if (!isMounted.value) return\n try {\n // emit onBeforeRouteMount\n if (previousIsPagePending.value.previous && !newValue) {\n router.emit({\n type: 'onBeforeRouteMount',\n ...getLocationChangeInfo(router.state),\n })\n }\n } catch {\n // Ignore errors if component is unmounted\n }\n })\n\n Vue.watch(isAnyPending, (newValue) => {\n if (!isMounted.value) return\n try {\n if (!newValue && router.__store.state.status === 'pending') {\n router.__store.setState((s) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n }\n\n // The router was pending and now it's not\n if (previousIsAnyPending.value.previous && !newValue) {\n const changeInfo = getLocationChangeInfo(router.state)\n router.emit({\n type: 'onResolved',\n ...changeInfo,\n })\n\n if (changeInfo.hrefChanged) {\n handleHashScroll(router)\n }\n }\n } catch {\n // Ignore errors if component is unmounted\n }\n })\n}\n\n/**\n * @deprecated Use useTransitionerSetup() composable instead.\n * This component is kept for backwards compatibility but the setup logic\n * has been moved to useTransitionerSetup() for better SSR hydration.\n */\nexport const Transitioner = Vue.defineComponent({\n name: 'Transitioner',\n setup() {\n useTransitionerSetup()\n return () => null\n },\n})\n"],"names":["mountLoadForRouter","router","mounted","useTransitionerSetup","useRouter","isServer","isLoading","useRouterState","select","isTransitioning","Vue","ref","hasPendingMatches","s","matches","some","d","status","previousIsLoading","usePrevious","value","isAnyPending","computed","previousIsAnyPending","isPagePending","previousIsPagePending","startTransition","fn","__store","setState","endTransition","nextTick","originalStartViewTransition","__tsrOriginalStartViewTransition","startViewTransition","unsubscribe","onMounted","history","subscribe","load","nextLocation","buildLocation","to","latestLocation","pathname","search","params","hash","state","_includeValidateSearch","trimPathRight","publicHref","commitLocation","replace","isMounted","resolvedLocation","location","onUnmounted","window","ssr","tryLoad","err","console","error","watch","newValue","previous","emit","type","getLocationChangeInfo","changeInfo","hrefChanged","handleHashScroll","defineComponent","name","setup"],"mappings":";;;;;;AAYA,IAAIA,qBAAqB;AAAA,EAAEC,QAAQ;AAAA,EAAaC,SAAS;AAAM;AAYxD,SAASC,uBAAuB;AACrC,QAAMF,SAASG,UAAS;AAGxB,MAAIC,YAAYJ,OAAOI,UAAU;AAC/B;AAAA,EACF;AAEA,QAAMC,YAAYC,eAAe;AAAA,IAC/BC,QAAQA,CAAC;AAAA,MAAEF,WAAAA;AAAAA,IAAU,MAAMA;AAAAA,EAC7B,CAAC;AAGD,QAAMG,kBAAkBC,IAAIC,IAAI,KAAK;AAGrC,QAAMC,oBAAoBL,eAAe;AAAA,IACvCC,QAASK,OAAMA,EAAEC,QAAQC,KAAMC,OAAMA,EAAEC,WAAW,SAAS;AAAA,EAC7D,CAAC;AAED,QAAMC,oBAAoBC,YAAY,MAAMb,UAAUc,KAAK;AAE3D,QAAMC,eAAeX,IAAIY,SACvB,MAAMhB,UAAUc,SAASX,gBAAgBW,SAASR,kBAAkBQ,KACtE;AACA,QAAMG,uBAAuBJ,YAAY,MAAME,aAAaD,KAAK;AAEjE,QAAMI,gBAAgBd,IAAIY,SACxB,MAAMhB,UAAUc,SAASR,kBAAkBQ,KAC7C;AACA,QAAMK,wBAAwBN,YAAY,MAAMK,cAAcJ,KAAK;AAKnEnB,SAAOyB,kBAAmBC,QAAmC;AAC3DlB,oBAAgBW,QAAQ;AAExB,QAAI;AACFnB,aAAO2B,QAAQC,SAAUhB,QAAO;AAAA,QAAE,GAAGA;AAAAA,QAAGJ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I,CAACX,UAAUlC,MAAO;AACtB,QAAI;AACF,UAAI,CAAC6C,YAAYhE,OAAO2B,QAAQoB,MAAM/B,WAAW,WAAW;AAC1DhB,eAAO2B,QAAQC,SAAUhB,QAAO;AAAA,UAC9B,GAAGA;AAAAA,UACHI,QAAQ;AAAA,UACRsC,kBAAkB1C,EAAE2C;AAAAA,QACtB,EAAE;AAAA,MACJ;AAGA,UAAIjC,qBAAqBH,MAAM8C,YAAY,CAACD,UAAU;AACpD,cAAMK,aAAaD,sBAAsBpE,OAAO+C,KAAK;AACrD/C,eAAOkE,KAAK;AAAA,UACVC,MAAM;AAAA,UACN,GAAGE;AAAAA,QACL,CAAC;AAED,YAAIA,WAAWC,aAAa;AAC1BC,2BAAiBvE,MAAM;AAAA,QACzB;AAAA,MACF;AAAA,IACF,QAAQ;AAAA,IACN;AAAA,EAEJ,CAAC;AACH;AAO4BS,IAAI+D,gBAAgB;AAAA,EAC9CC,MAAM;AAAA,EACNC,QAAQ;AACNxE,yBAAoB;AACpB,WAAO,MAAM;AAAA,EACf;AACF,CAAC;"}
1
+ {"version":3,"file":"Transitioner.js","names":["Vue","getLocationChangeInfo","handleHashScroll","trimPathRight","isServer","useRouter","useRouterState","usePrevious","mountLoadForRouter","router","mounted","useTransitionerSetup","isLoading","select","isTransitioning","ref","hasPendingMatches","s","matches","some","d","status","previousIsLoading","value","isAnyPending","computed","previousIsAnyPending","isPagePending","previousIsPagePending","startTransition","fn","__store","setState","endTransition","nextTick","originalStartViewTransition","__tsrOriginalStartViewTransition","startViewTransition","unsubscribe","onMounted","history","subscribe","load","nextLocation","buildLocation","to","latestLocation","pathname","search","params","hash","state","_includeValidateSearch","publicHref","commitLocation","replace","isMounted","resolvedLocation","location","onUnmounted","window","ssr","tryLoad","err","console","error","watch","newValue","previous","emit","type","changeInfo","hrefChanged","Transitioner","defineComponent","name","setup"],"sources":["../../src/Transitioner.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport {\n getLocationChangeInfo,\n handleHashScroll,\n trimPathRight,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport { usePrevious } from './utils'\n\n// Track mount state per router to avoid double-loading\nlet mountLoadForRouter = { router: null as any, mounted: false }\n\n/**\n * Composable that sets up router transition logic.\n * This is called from MatchesContent to set up:\n * - router.startTransition\n * - router.startViewTransition\n * - History subscription\n * - Router event watchers\n *\n * Must be called during component setup phase.\n */\nexport function useTransitionerSetup() {\n const router = useRouter()\n\n // Skip on server - no transitions needed\n if (isServer ?? router.isServer) {\n return\n }\n\n const isLoading = useRouterState({\n select: ({ isLoading }) => isLoading,\n })\n\n // Track if we're in a transition - using a ref to track async transitions\n const isTransitioning = Vue.ref(false)\n\n // Track pending state changes\n const hasPendingMatches = useRouterState({\n select: (s) => s.matches.some((d) => d.status === 'pending'),\n })\n\n const previousIsLoading = usePrevious(() => isLoading.value)\n\n const isAnyPending = Vue.computed(\n () => isLoading.value || isTransitioning.value || hasPendingMatches.value,\n )\n const previousIsAnyPending = usePrevious(() => isAnyPending.value)\n\n const isPagePending = Vue.computed(\n () => isLoading.value || hasPendingMatches.value,\n )\n const previousIsPagePending = usePrevious(() => isPagePending.value)\n\n // Implement startTransition similar to React/Solid\n // Vue doesn't have a native useTransition like React 18, so we simulate it\n // We also update the router state's isTransitioning flag so useMatch can check it\n router.startTransition = (fn: () => void | Promise<void>) => {\n isTransitioning.value = true\n // Also update the router state so useMatch knows we're transitioning\n try {\n router.__store.setState((s) => ({ ...s, isTransitioning: true }))\n } catch {\n // Ignore errors if component is unmounted\n }\n\n // Helper to end the transition\n const endTransition = () => {\n // Use nextTick to ensure Vue has processed all reactive updates\n Vue.nextTick(() => {\n try {\n isTransitioning.value = false\n router.__store.setState((s) => ({ ...s, isTransitioning: false }))\n } catch {\n // Ignore errors if component is unmounted\n }\n })\n }\n\n // Execute the function synchronously\n // The function internally may call startViewTransition which schedules async work\n // via document.startViewTransition, but we don't need to wait for it here\n // because Vue's reactivity will trigger re-renders when state changes\n fn()\n\n // End the transition on next tick to allow Vue to process reactive updates\n endTransition()\n }\n\n // Vue updates DOM asynchronously (next tick). The View Transitions API expects the\n // update callback promise to resolve only after the DOM has been updated.\n // Wrap the router-core implementation to await a Vue flush before resolving.\n const originalStartViewTransition:\n | undefined\n | ((fn: () => Promise<void>) => void) =\n (router as any).__tsrOriginalStartViewTransition ??\n router.startViewTransition\n\n ;(router as any).__tsrOriginalStartViewTransition =\n originalStartViewTransition\n\n router.startViewTransition = (fn: () => Promise<void>) => {\n return originalStartViewTransition?.(async () => {\n await fn()\n await Vue.nextTick()\n })\n }\n\n // Subscribe to location changes\n // and try to load the new location\n let unsubscribe: (() => void) | undefined\n\n Vue.onMounted(() => {\n unsubscribe = router.history.subscribe(router.load)\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n // Check if the current URL matches the canonical form.\n // Compare publicHref (browser-facing URL) for consistency with\n // the server-side redirect check in router.beforeLoad.\n if (\n trimPathRight(router.latestLocation.publicHref) !==\n trimPathRight(nextLocation.publicHref)\n ) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n })\n\n // Track if component is mounted to prevent updates after unmount\n const isMounted = Vue.ref(false)\n\n Vue.onMounted(() => {\n isMounted.value = true\n if (!isAnyPending.value) {\n router.__store.setState((s) =>\n s.status === 'pending'\n ? { ...s, status: 'idle', resolvedLocation: s.location }\n : s,\n )\n }\n })\n\n Vue.onUnmounted(() => {\n isMounted.value = false\n if (unsubscribe) {\n unsubscribe()\n }\n })\n\n // Try to load the initial location\n Vue.onMounted(() => {\n if (\n (typeof window !== 'undefined' && router.ssr) ||\n (mountLoadForRouter.router === router && mountLoadForRouter.mounted)\n ) {\n return\n }\n mountLoadForRouter = { router, mounted: true }\n const tryLoad = async () => {\n try {\n await router.load()\n } catch (err) {\n console.error(err)\n }\n }\n tryLoad()\n })\n\n // Setup watchers for emitting events\n // All watchers check isMounted to prevent updates after unmount\n Vue.watch(\n () => isLoading.value,\n (newValue) => {\n if (!isMounted.value) return\n try {\n if (previousIsLoading.value.previous && !newValue) {\n router.emit({\n type: 'onLoad',\n ...getLocationChangeInfo(router.state),\n })\n }\n } catch {\n // Ignore errors if component is unmounted\n }\n },\n )\n\n Vue.watch(isPagePending, (newValue) => {\n if (!isMounted.value) return\n try {\n // emit onBeforeRouteMount\n if (previousIsPagePending.value.previous && !newValue) {\n router.emit({\n type: 'onBeforeRouteMount',\n ...getLocationChangeInfo(router.state),\n })\n }\n } catch {\n // Ignore errors if component is unmounted\n }\n })\n\n Vue.watch(isAnyPending, (newValue) => {\n if (!isMounted.value) return\n try {\n if (!newValue && router.__store.state.status === 'pending') {\n router.__store.setState((s) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n }\n\n // The router was pending and now it's not\n if (previousIsAnyPending.value.previous && !newValue) {\n const changeInfo = getLocationChangeInfo(router.state)\n router.emit({\n type: 'onResolved',\n ...changeInfo,\n })\n\n if (changeInfo.hrefChanged) {\n handleHashScroll(router)\n }\n }\n } catch {\n // Ignore errors if component is unmounted\n }\n })\n}\n\n/**\n * @deprecated Use useTransitionerSetup() composable instead.\n * This component is kept for backwards compatibility but the setup logic\n * has been moved to useTransitionerSetup() for better SSR hydration.\n */\nexport const Transitioner = Vue.defineComponent({\n name: 'Transitioner',\n setup() {\n useTransitionerSetup()\n return () => null\n },\n})\n"],"mappings":";;;;;;;AAYA,IAAIQ,qBAAqB;CAAEC,QAAQ;CAAaC,SAAS;CAAO;;;;;;;;;;;AAYhE,SAAgBC,uBAAuB;CACrC,MAAMF,SAASJ,WAAW;AAG1B,KAAID,YAAYK,OAAOL,SACrB;CAGF,MAAMQ,YAAYN,eAAe,EAC/BO,SAAS,EAAED,gBAAgBA,WAC5B,CAAC;CAGF,MAAME,kBAAkBd,IAAIe,IAAI,MAAM;CAGtC,MAAMC,oBAAoBV,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,MAAI;AACF,OAAI,CAAC4C,YAAY1D,OAAOsB,QAAQoB,MAAM9B,WAAW,UAC/CZ,QAAOsB,QAAQC,UAAUf,OAAO;IAC9B,GAAGA;IACHI,QAAQ;IACRoC,kBAAkBxC,EAAEyC;IACrB,EAAE;AAIL,OAAIhC,qBAAqBH,MAAM6C,YAAY,CAACD,UAAU;IACpD,MAAMI,aAAatE,sBAAsBQ,OAAO0C,MAAM;AACtD1C,WAAO4D,KAAK;KACVC,MAAM;KACN,GAAGC;KACJ,CAAC;AAEF,QAAIA,WAAWC,YACbtE,kBAAiBO,OAAO;;UAGtB;GAGR;;AAQwBT,IAAI0E,gBAAgB;CAC9CC,MAAM;CACNC,QAAQ;AACNjE,wBAAsB;AACtB,eAAa;;CAEhB,CAAC"}
@@ -1,37 +1,30 @@
1
+ import { TSR_DEFERRED_PROMISE, defer } from "@tanstack/router-core";
1
2
  import * as Vue from "vue";
2
- import { defer, TSR_DEFERRED_PROMISE } from "@tanstack/router-core";
3
- function useAwaited({
4
- promise: _promise
5
- }) {
6
- const promise = defer(_promise);
7
- if (promise[TSR_DEFERRED_PROMISE].status === "pending") {
8
- throw promise;
9
- }
10
- if (promise[TSR_DEFERRED_PROMISE].status === "error") {
11
- throw promise[TSR_DEFERRED_PROMISE].error;
12
- }
13
- return [promise[TSR_DEFERRED_PROMISE].data, promise];
3
+ //#region src/awaited.tsx
4
+ function useAwaited({ promise: _promise }) {
5
+ const promise = defer(_promise);
6
+ if (promise[TSR_DEFERRED_PROMISE].status === "pending") throw promise;
7
+ if (promise[TSR_DEFERRED_PROMISE].status === "error") throw promise[TSR_DEFERRED_PROMISE].error;
8
+ return [promise[TSR_DEFERRED_PROMISE].data, promise];
14
9
  }
15
- const Await = Vue.defineComponent({
16
- name: "Await",
17
- props: {
18
- promise: {
19
- type: Promise,
20
- required: true
21
- },
22
- children: {
23
- type: Function,
24
- required: true
25
- }
26
- },
27
- async setup(props) {
28
- const deferred = defer(props.promise);
29
- const data = await deferred;
30
- return () => props.children(data);
31
- }
10
+ var Await = Vue.defineComponent({
11
+ name: "Await",
12
+ props: {
13
+ promise: {
14
+ type: Promise,
15
+ required: true
16
+ },
17
+ children: {
18
+ type: Function,
19
+ required: true
20
+ }
21
+ },
22
+ async setup(props) {
23
+ const data = await defer(props.promise);
24
+ return () => props.children(data);
25
+ }
32
26
  });
33
- export {
34
- Await,
35
- useAwaited
36
- };
37
- //# sourceMappingURL=awaited.js.map
27
+ //#endregion
28
+ export { Await, useAwaited };
29
+
30
+ //# sourceMappingURL=awaited.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"awaited.js","sources":["../../src/awaited.tsx"],"sourcesContent":["import * as Vue from 'vue'\n\nimport { TSR_DEFERRED_PROMISE, defer } from '@tanstack/router-core'\nimport type { DeferredPromise } from '@tanstack/router-core'\n\nexport type AwaitOptions<T> = {\n promise: Promise<T>\n}\n\nexport function useAwaited<T>({\n promise: _promise,\n}: AwaitOptions<T>): [T, DeferredPromise<T>] {\n const promise = defer(_promise)\n\n if (promise[TSR_DEFERRED_PROMISE].status === 'pending') {\n throw promise\n }\n\n if (promise[TSR_DEFERRED_PROMISE].status === 'error') {\n throw promise[TSR_DEFERRED_PROMISE].error\n }\n\n return [promise[TSR_DEFERRED_PROMISE].data, promise]\n}\n\nexport const Await = Vue.defineComponent({\n name: 'Await',\n props: {\n promise: {\n type: Promise,\n required: true,\n },\n children: {\n type: Function,\n required: true,\n },\n },\n async setup(props) {\n const deferred = defer(props.promise)\n const data = await deferred\n return () => (props.children as (result: unknown) => Vue.VNode)(data)\n },\n})\n"],"names":["useAwaited","promise","_promise","defer","TSR_DEFERRED_PROMISE","status","error","data","Await","Vue","defineComponent","name","props","type","Promise","required","children","Function","setup","deferred"],"mappings":";;AASO,SAASA,WAAc;AAAA,EAC5BC,SAASC;AACM,GAA4B;AAC3C,QAAMD,UAAUE,MAAMD,QAAQ;AAE9B,MAAID,QAAQG,oBAAoB,EAAEC,WAAW,WAAW;AACtD,UAAMJ;AAAAA,EACR;AAEA,MAAIA,QAAQG,oBAAoB,EAAEC,WAAW,SAAS;AACpD,UAAMJ,QAAQG,oBAAoB,EAAEE;AAAAA,EACtC;AAEA,SAAO,CAACL,QAAQG,oBAAoB,EAAEG,MAAMN,OAAO;AACrD;MAEaO,QAAQC,IAAIC,gBAAgB;AAAA,EACvCC,MAAM;AAAA,EACNC,OAAO;AAAA,IACLX,SAAS;AAAA,MACPY,MAAMC;AAAAA,MACNC,UAAU;AAAA;IAEZC,UAAU;AAAA,MACRH,MAAMI;AAAAA,MACNF,UAAU;AAAA,IACZ;AAAA;EAEF,MAAMG,MAAMN,OAAO;AACjB,UAAMO,WAAWhB,MAAMS,MAAMX,OAAO;AACpC,UAAMM,OAAO,MAAMY;AACnB,WAAO,MAAOP,MAAMI,SAA4CT,IAAI;AAAA,EACtE;AACF,CAAC;"}
1
+ {"version":3,"file":"awaited.js","names":["Vue","TSR_DEFERRED_PROMISE","defer","useAwaited","promise","_promise","status","error","data","Await","defineComponent","name","props","type","Promise","required","children","Function","setup","deferred"],"sources":["../../src/awaited.tsx"],"sourcesContent":["import * as Vue from 'vue'\n\nimport { TSR_DEFERRED_PROMISE, defer } from '@tanstack/router-core'\nimport type { DeferredPromise } from '@tanstack/router-core'\n\nexport type AwaitOptions<T> = {\n promise: Promise<T>\n}\n\nexport function useAwaited<T>({\n promise: _promise,\n}: AwaitOptions<T>): [T, DeferredPromise<T>] {\n const promise = defer(_promise)\n\n if (promise[TSR_DEFERRED_PROMISE].status === 'pending') {\n throw promise\n }\n\n if (promise[TSR_DEFERRED_PROMISE].status === 'error') {\n throw promise[TSR_DEFERRED_PROMISE].error\n }\n\n return [promise[TSR_DEFERRED_PROMISE].data, promise]\n}\n\nexport const Await = Vue.defineComponent({\n name: 'Await',\n props: {\n promise: {\n type: Promise,\n required: true,\n },\n children: {\n type: Function,\n required: true,\n },\n },\n async setup(props) {\n const deferred = defer(props.promise)\n const data = await deferred\n return () => (props.children as (result: unknown) => Vue.VNode)(data)\n },\n})\n"],"mappings":";;;AASA,SAAgBG,WAAc,EAC5BC,SAASC,YACkC;CAC3C,MAAMD,UAAUF,MAAMG,SAAS;AAE/B,KAAID,QAAQH,sBAAsBK,WAAW,UAC3C,OAAMF;AAGR,KAAIA,QAAQH,sBAAsBK,WAAW,QAC3C,OAAMF,QAAQH,sBAAsBM;AAGtC,QAAO,CAACH,QAAQH,sBAAsBO,MAAMJ,QAAQ;;AAGtD,IAAaK,QAAQT,IAAIU,gBAAgB;CACvCC,MAAM;CACNC,OAAO;EACLR,SAAS;GACPS,MAAMC;GACNC,UAAU;GACX;EACDC,UAAU;GACRH,MAAMI;GACNF,UAAU;GACZ;EACD;CACD,MAAMG,MAAMN,OAAO;EAEjB,MAAMJ,OAAO,MADIN,MAAMU,MAAMR,QAAQ;AAErC,eAAcQ,MAAMI,SAA4CR,KAAK;;CAExE,CAAC"}
@@ -1,105 +1,103 @@
1
- import warning from "tiny-warning";
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 { useSearch } from "./useSearch.js";
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
11
12
  function createFileRoute(path) {
12
- if (typeof path === "object") {
13
- return new FileRoute(path, {
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
- }
13
+ if (typeof path === "object") return new FileRoute(path, { silent: true }).createRoute(path);
14
+ return new FileRoute(path, { silent: true }).createRoute;
37
15
  }
16
+ /**
17
+ @deprecated It's no longer recommended to use the `FileRoute` class directly.
18
+ Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
19
+ */
20
+ var FileRoute = class {
21
+ constructor(path, _opts) {
22
+ this.path = path;
23
+ this.createRoute = (options) => {
24
+ 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.");
25
+ const route = createRoute(options);
26
+ route.isRoot = false;
27
+ return route;
28
+ };
29
+ this.silent = _opts?.silent;
30
+ }
31
+ };
32
+ /**
33
+ @deprecated It's recommended not to split loaders into separate files.
34
+ Instead, place the loader function in the the main route file, inside the
35
+ `createFileRoute('/path/to/file)(options)` options.
36
+ */
38
37
  function FileRouteLoader(_path) {
39
- if (process.env.NODE_ENV !== "production") {
40
- warning(
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
- });
54
- };
55
- this.useRouteContext = (opts2) => {
56
- return useRouteContext({ ...opts2, from: this.options.id });
57
- };
58
- this.useSearch = (opts2) => {
59
- return useSearch({
60
- select: opts2?.select,
61
- from: this.options.id
62
- });
63
- };
64
- this.useParams = (opts2) => {
65
- return useParams({
66
- select: opts2?.select,
67
- from: this.options.id
68
- });
69
- };
70
- this.useLoaderDeps = (opts2) => {
71
- return useLoaderDeps({ ...opts2, from: this.options.id });
72
- };
73
- this.useLoaderData = (opts2) => {
74
- return useLoaderData({ ...opts2, from: this.options.id });
75
- };
76
- this.useNavigate = () => {
77
- const router = useRouter();
78
- return useNavigate({ from: router.routesById[this.options.id].fullPath });
79
- };
80
- this.options = opts;
81
- }
38
+ 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`);
39
+ return (loaderFn) => loaderFn;
82
40
  }
41
+ var LazyRoute = class {
42
+ constructor(opts) {
43
+ this.useMatch = (opts) => {
44
+ return useMatch({
45
+ select: opts?.select,
46
+ from: this.options.id
47
+ });
48
+ };
49
+ this.useRouteContext = (opts) => {
50
+ return useRouteContext({
51
+ ...opts,
52
+ from: this.options.id
53
+ });
54
+ };
55
+ this.useSearch = (opts) => {
56
+ return useSearch({
57
+ select: opts?.select,
58
+ from: this.options.id
59
+ });
60
+ };
61
+ this.useParams = (opts) => {
62
+ return useParams({
63
+ select: opts?.select,
64
+ from: this.options.id
65
+ });
66
+ };
67
+ this.useLoaderDeps = (opts) => {
68
+ return useLoaderDeps({
69
+ ...opts,
70
+ from: this.options.id
71
+ });
72
+ };
73
+ this.useLoaderData = (opts) => {
74
+ return useLoaderData({
75
+ ...opts,
76
+ from: this.options.id
77
+ });
78
+ };
79
+ this.useNavigate = () => {
80
+ return useNavigate({ from: useRouter().routesById[this.options.id].fullPath });
81
+ };
82
+ this.options = opts;
83
+ }
84
+ };
83
85
  function createLazyRoute(id) {
84
- return (opts) => {
85
- return new LazyRoute({
86
- id,
87
- ...opts
88
- });
89
- };
86
+ return (opts) => {
87
+ return new LazyRoute({
88
+ id,
89
+ ...opts
90
+ });
91
+ };
90
92
  }
91
93
  function createLazyFileRoute(id) {
92
- if (typeof id === "object") {
93
- return new LazyRoute(id);
94
- }
95
- return (opts) => new LazyRoute({ id, ...opts });
94
+ if (typeof id === "object") return new LazyRoute(id);
95
+ return (opts) => new LazyRoute({
96
+ id,
97
+ ...opts
98
+ });
96
99
  }
97
- export {
98
- FileRoute,
99
- FileRouteLoader,
100
- LazyRoute,
101
- createFileRoute,
102
- createLazyFileRoute,
103
- createLazyRoute
104
- };
105
- //# sourceMappingURL=fileRoute.js.map
100
+ //#endregion
101
+ export { FileRoute, FileRouteLoader, LazyRoute, createFileRoute, createLazyFileRoute, createLazyRoute };
102
+
103
+ //# sourceMappingURL=fileRoute.js.map