@tanstack/vue-router 1.140.5 → 1.141.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/dist/esm/Asset.js +122 -8
- package/dist/esm/Asset.js.map +1 -1
- package/dist/esm/Body.d.ts +4 -0
- package/dist/esm/Body.js +26 -0
- package/dist/esm/Body.js.map +1 -0
- package/dist/esm/CatchBoundary.d.ts +1 -1
- package/dist/esm/CatchBoundary.js +8 -8
- package/dist/esm/CatchBoundary.js.map +1 -1
- package/dist/esm/Html.d.ts +4 -0
- package/dist/esm/Html.js +63 -0
- package/dist/esm/Html.js.map +1 -0
- package/dist/esm/Match.js +87 -49
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +3 -2
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.js +3 -0
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/ScriptOnce.d.ts +12 -5
- package/dist/esm/ScriptOnce.js +35 -15
- package/dist/esm/ScriptOnce.js.map +1 -1
- package/dist/esm/Scripts.d.ts +2 -1
- package/dist/esm/Scripts.js +101 -35
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/Transitioner.d.ts +16 -0
- package/dist/esm/Transitioner.js +136 -133
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/awaited.d.ts +20 -5
- package/dist/esm/awaited.js +17 -20
- package/dist/esm/awaited.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lazyRouteComponent.js +2 -2
- package/dist/esm/lazyRouteComponent.js.map +1 -1
- package/dist/esm/link.js +27 -35
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/scroll-restoration.d.ts +8 -1
- package/dist/esm/scroll-restoration.js +44 -12
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/ssr/RouterClient.d.ts +15 -0
- package/dist/esm/ssr/RouterClient.js +46 -0
- package/dist/esm/ssr/RouterClient.js.map +1 -0
- package/dist/esm/ssr/RouterServer.d.ts +15 -0
- package/dist/esm/ssr/RouterServer.js +37 -0
- package/dist/esm/ssr/RouterServer.js.map +1 -0
- package/dist/esm/ssr/client.d.ts +1 -0
- package/dist/esm/ssr/client.js +5 -0
- package/dist/esm/ssr/client.js.map +1 -0
- package/dist/esm/ssr/defaultRenderHandler.d.ts +1 -0
- package/dist/esm/ssr/defaultRenderHandler.js +15 -0
- package/dist/esm/ssr/defaultRenderHandler.js.map +1 -0
- package/dist/esm/ssr/defaultStreamHandler.d.ts +1 -0
- package/dist/esm/ssr/defaultStreamHandler.js +17 -0
- package/dist/esm/ssr/defaultStreamHandler.js.map +1 -0
- package/dist/esm/ssr/renderRouterToStream.d.ts +8 -0
- package/dist/esm/ssr/renderRouterToStream.js +70 -0
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -0
- package/dist/esm/ssr/renderRouterToString.d.ts +7 -0
- package/dist/esm/ssr/renderRouterToString.js +33 -0
- package/dist/esm/ssr/renderRouterToString.js.map +1 -0
- package/dist/esm/ssr/server.d.ts +6 -0
- package/dist/esm/ssr/server.js +14 -0
- package/dist/esm/ssr/server.js.map +1 -0
- package/dist/source/Asset.jsx +119 -7
- package/dist/source/Asset.jsx.map +1 -1
- package/dist/source/Body.d.ts +4 -0
- package/dist/source/Body.jsx +15 -0
- package/dist/source/Body.jsx.map +1 -0
- package/dist/source/CatchBoundary.d.ts +1 -1
- package/dist/source/CatchBoundary.jsx +10 -23
- package/dist/source/CatchBoundary.jsx.map +1 -1
- package/dist/source/Html.d.ts +4 -0
- package/dist/source/Html.jsx +56 -0
- package/dist/source/Html.jsx.map +1 -0
- package/dist/source/Match.jsx +119 -54
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/Matches.jsx +15 -3
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/RouterProvider.jsx +5 -0
- package/dist/source/RouterProvider.jsx.map +1 -1
- package/dist/source/ScriptOnce.d.ts +12 -5
- package/dist/source/ScriptOnce.jsx +27 -16
- package/dist/source/ScriptOnce.jsx.map +1 -1
- package/dist/source/Scripts.d.ts +2 -1
- package/dist/source/Scripts.jsx +100 -42
- package/dist/source/Scripts.jsx.map +1 -1
- package/dist/source/Transitioner.d.ts +16 -0
- package/dist/source/Transitioner.jsx +180 -160
- package/dist/source/Transitioner.jsx.map +1 -1
- package/dist/source/awaited.d.ts +20 -5
- package/dist/source/awaited.jsx +18 -25
- package/dist/source/awaited.jsx.map +1 -1
- package/dist/source/index.d.ts +2 -0
- package/dist/source/index.jsx +2 -0
- package/dist/source/index.jsx.map +1 -1
- package/dist/source/lazyRouteComponent.jsx +4 -2
- package/dist/source/lazyRouteComponent.jsx.map +1 -1
- package/dist/source/link.jsx +37 -51
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/scroll-restoration.d.ts +8 -1
- package/dist/source/scroll-restoration.jsx +55 -12
- package/dist/source/scroll-restoration.jsx.map +1 -1
- package/dist/source/ssr/RouterClient.d.ts +15 -0
- package/dist/source/ssr/RouterClient.jsx +48 -0
- package/dist/source/ssr/RouterClient.jsx.map +1 -0
- package/dist/source/ssr/RouterServer.d.ts +15 -0
- package/dist/source/ssr/RouterServer.jsx +40 -0
- package/dist/source/ssr/RouterServer.jsx.map +1 -0
- package/dist/source/ssr/client.d.ts +1 -0
- package/dist/source/ssr/client.js +2 -0
- package/dist/source/ssr/client.js.map +1 -0
- package/dist/source/ssr/defaultRenderHandler.d.ts +1 -0
- package/dist/source/ssr/defaultRenderHandler.jsx +9 -0
- package/dist/source/ssr/defaultRenderHandler.jsx.map +1 -0
- package/dist/source/ssr/defaultStreamHandler.d.ts +1 -0
- package/dist/source/ssr/defaultStreamHandler.jsx +10 -0
- package/dist/source/ssr/defaultStreamHandler.jsx.map +1 -0
- package/dist/source/ssr/renderRouterToStream.d.ts +8 -0
- package/dist/source/ssr/renderRouterToStream.jsx +55 -0
- package/dist/source/ssr/renderRouterToStream.jsx.map +1 -0
- package/dist/source/ssr/renderRouterToString.d.ts +7 -0
- package/dist/source/ssr/renderRouterToString.jsx +26 -0
- package/dist/source/ssr/renderRouterToString.jsx.map +1 -0
- package/dist/source/ssr/server.d.ts +6 -0
- package/dist/source/ssr/server.js +7 -0
- package/dist/source/ssr/server.js.map +1 -0
- package/package.json +16 -3
- package/src/Asset.tsx +157 -7
- package/src/Body.tsx +26 -0
- package/src/CatchBoundary.tsx +11 -25
- package/src/Html.tsx +65 -0
- package/src/Match.tsx +135 -58
- package/src/Matches.tsx +16 -4
- package/src/RouterProvider.tsx +6 -0
- package/src/ScriptOnce.tsx +43 -28
- package/src/Scripts.tsx +121 -56
- package/src/Transitioner.tsx +197 -176
- package/src/awaited.tsx +17 -28
- package/src/index.tsx +2 -0
- package/src/lazyRouteComponent.tsx +4 -2
- package/src/link.tsx +42 -47
- package/src/scroll-restoration.tsx +69 -21
- package/src/ssr/RouterClient.tsx +58 -0
- package/src/ssr/RouterServer.tsx +51 -0
- package/src/ssr/client.ts +1 -0
- package/src/ssr/defaultRenderHandler.tsx +12 -0
- package/src/ssr/defaultStreamHandler.tsx +13 -0
- package/src/ssr/renderRouterToStream.tsx +85 -0
- package/src/ssr/renderRouterToString.tsx +37 -0
- package/src/ssr/server.ts +6 -0
package/dist/esm/Transitioner.js
CHANGED
|
@@ -3,152 +3,155 @@ import { trimPathRight, getLocationChangeInfo, handleHashScroll } from "@tanstac
|
|
|
3
3
|
import { useRouter } from "./useRouter.js";
|
|
4
4
|
import { useRouterState } from "./useRouterState.js";
|
|
5
5
|
import { usePrevious } from "./utils.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
let mountLoadForRouter = {
|
|
7
|
+
router: null,
|
|
8
|
+
mounted: false
|
|
9
|
+
};
|
|
10
|
+
function useTransitionerSetup() {
|
|
11
|
+
const router = useRouter();
|
|
12
|
+
if (router.isServer) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const isLoading = useRouterState({
|
|
16
|
+
select: ({
|
|
17
|
+
isLoading: isLoading2
|
|
18
|
+
}) => isLoading2
|
|
19
|
+
});
|
|
20
|
+
const isTransitioning = Vue.ref(false);
|
|
21
|
+
const hasPendingMatches = useRouterState({
|
|
22
|
+
select: (s) => s.matches.some((d) => d.status === "pending")
|
|
23
|
+
});
|
|
24
|
+
const previousIsLoading = usePrevious(() => isLoading.value);
|
|
25
|
+
const isAnyPending = Vue.computed(() => isLoading.value || isTransitioning.value || hasPendingMatches.value);
|
|
26
|
+
const previousIsAnyPending = usePrevious(() => isAnyPending.value);
|
|
27
|
+
const isPagePending = Vue.computed(() => isLoading.value || hasPendingMatches.value);
|
|
28
|
+
const previousIsPagePending = usePrevious(() => isPagePending.value);
|
|
29
|
+
router.startTransition = (fn) => {
|
|
30
|
+
isTransitioning.value = true;
|
|
31
|
+
try {
|
|
32
|
+
router.__store.setState((s) => ({
|
|
33
|
+
...s,
|
|
34
|
+
isTransitioning: true
|
|
35
|
+
}));
|
|
36
|
+
} catch {
|
|
16
37
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
38
|
+
const endTransition = () => {
|
|
39
|
+
Vue.nextTick(() => {
|
|
40
|
+
try {
|
|
41
|
+
isTransitioning.value = false;
|
|
42
|
+
router.__store.setState((s) => ({
|
|
43
|
+
...s,
|
|
44
|
+
isTransitioning: false
|
|
45
|
+
}));
|
|
46
|
+
} catch {
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
fn();
|
|
51
|
+
endTransition();
|
|
52
|
+
};
|
|
53
|
+
router.startViewTransition = (fn) => {
|
|
54
|
+
fn();
|
|
55
|
+
};
|
|
56
|
+
let unsubscribe;
|
|
57
|
+
Vue.onMounted(() => {
|
|
58
|
+
unsubscribe = router.history.subscribe(router.load);
|
|
59
|
+
const nextLocation = router.buildLocation({
|
|
60
|
+
to: router.latestLocation.pathname,
|
|
61
|
+
search: true,
|
|
62
|
+
params: true,
|
|
63
|
+
hash: true,
|
|
64
|
+
state: true,
|
|
65
|
+
_includeValidateSearch: true
|
|
25
66
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
67
|
+
if (trimPathRight(router.latestLocation.href) !== trimPathRight(nextLocation.href)) {
|
|
68
|
+
router.commitLocation({
|
|
69
|
+
...nextLocation,
|
|
70
|
+
replace: true
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const isMounted = Vue.ref(false);
|
|
75
|
+
Vue.onMounted(() => {
|
|
76
|
+
isMounted.value = true;
|
|
77
|
+
});
|
|
78
|
+
Vue.onUnmounted(() => {
|
|
79
|
+
isMounted.value = false;
|
|
80
|
+
if (unsubscribe) {
|
|
81
|
+
unsubscribe();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Vue.onMounted(() => {
|
|
85
|
+
if (typeof window !== "undefined" && router.ssr || mountLoadForRouter.router === router && mountLoadForRouter.mounted) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
mountLoadForRouter = {
|
|
89
|
+
router,
|
|
90
|
+
mounted: true
|
|
91
|
+
};
|
|
92
|
+
const tryLoad = async () => {
|
|
33
93
|
try {
|
|
34
|
-
router.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}));
|
|
38
|
-
} catch {
|
|
94
|
+
await router.load();
|
|
95
|
+
} catch (err) {
|
|
96
|
+
console.error(err);
|
|
39
97
|
}
|
|
40
|
-
const endTransition = () => {
|
|
41
|
-
Vue.nextTick(() => {
|
|
42
|
-
try {
|
|
43
|
-
isTransitioning.value = false;
|
|
44
|
-
router.__store.setState((s) => ({
|
|
45
|
-
...s,
|
|
46
|
-
isTransitioning: false
|
|
47
|
-
}));
|
|
48
|
-
} catch {
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
fn();
|
|
53
|
-
endTransition();
|
|
54
|
-
};
|
|
55
|
-
router.startViewTransition = (fn) => {
|
|
56
|
-
fn();
|
|
57
98
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
_includeValidateSearch: true
|
|
68
|
-
});
|
|
69
|
-
if (trimPathRight(router.latestLocation.href) !== trimPathRight(nextLocation.href)) {
|
|
70
|
-
router.commitLocation({
|
|
71
|
-
...nextLocation,
|
|
72
|
-
replace: true
|
|
99
|
+
tryLoad();
|
|
100
|
+
});
|
|
101
|
+
Vue.watch(() => isLoading.value, (newValue) => {
|
|
102
|
+
if (!isMounted.value) return;
|
|
103
|
+
try {
|
|
104
|
+
if (previousIsLoading.value.previous && !newValue) {
|
|
105
|
+
router.emit({
|
|
106
|
+
type: "onLoad",
|
|
107
|
+
...getLocationChangeInfo(router.state)
|
|
73
108
|
});
|
|
74
109
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
Vue.onMounted(() => {
|
|
87
|
-
if (typeof window !== "undefined" && router.ssr || mountLoadForRouter.router === router && mountLoadForRouter.mounted) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
mountLoadForRouter = {
|
|
91
|
-
router,
|
|
92
|
-
mounted: true
|
|
93
|
-
};
|
|
94
|
-
const tryLoad = async () => {
|
|
95
|
-
try {
|
|
96
|
-
await router.load();
|
|
97
|
-
} catch (err) {
|
|
98
|
-
console.error(err);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
tryLoad();
|
|
102
|
-
});
|
|
103
|
-
Vue.watch(() => isLoading.value, (newValue) => {
|
|
104
|
-
if (!isMounted.value) return;
|
|
105
|
-
try {
|
|
106
|
-
if (previousIsLoading.value.previous && !newValue) {
|
|
107
|
-
router.emit({
|
|
108
|
-
type: "onLoad",
|
|
109
|
-
...getLocationChangeInfo(router.state)
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
} catch {
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
Vue.watch(isPagePending, (newValue) => {
|
|
116
|
-
if (!isMounted.value) return;
|
|
117
|
-
try {
|
|
118
|
-
if (previousIsPagePending.value.previous && !newValue) {
|
|
119
|
-
router.emit({
|
|
120
|
-
type: "onBeforeRouteMount",
|
|
121
|
-
...getLocationChangeInfo(router.state)
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
} catch {
|
|
110
|
+
} catch {
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
Vue.watch(isPagePending, (newValue) => {
|
|
114
|
+
if (!isMounted.value) return;
|
|
115
|
+
try {
|
|
116
|
+
if (previousIsPagePending.value.previous && !newValue) {
|
|
117
|
+
router.emit({
|
|
118
|
+
type: "onBeforeRouteMount",
|
|
119
|
+
...getLocationChangeInfo(router.state)
|
|
120
|
+
});
|
|
125
121
|
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
122
|
+
} catch {
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
Vue.watch(isAnyPending, (newValue) => {
|
|
126
|
+
if (!isMounted.value) return;
|
|
127
|
+
try {
|
|
128
|
+
if (previousIsAnyPending.value.previous && !newValue) {
|
|
129
|
+
const changeInfo = getLocationChangeInfo(router.state);
|
|
130
|
+
router.emit({
|
|
131
|
+
type: "onResolved",
|
|
132
|
+
...changeInfo
|
|
133
|
+
});
|
|
134
|
+
router.__store.setState((s) => ({
|
|
135
|
+
...s,
|
|
136
|
+
status: "idle",
|
|
137
|
+
resolvedLocation: s.location
|
|
138
|
+
}));
|
|
139
|
+
if (changeInfo.hrefChanged) {
|
|
140
|
+
handleHashScroll(router);
|
|
144
141
|
}
|
|
145
|
-
} catch {
|
|
146
142
|
}
|
|
147
|
-
}
|
|
143
|
+
} catch {
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
Vue.defineComponent({
|
|
148
|
+
name: "Transitioner",
|
|
149
|
+
setup() {
|
|
150
|
+
useTransitionerSetup();
|
|
148
151
|
return () => null;
|
|
149
152
|
}
|
|
150
153
|
});
|
|
151
154
|
export {
|
|
152
|
-
|
|
155
|
+
useTransitionerSetup
|
|
153
156
|
};
|
|
154
157
|
//# 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 { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport { usePrevious } from './utils'\n\nexport const Transitioner = Vue.defineComponent({\n name: 'Transitioner',\n setup() {\n const router = useRouter()\n let mountLoadForRouter = { router, mounted: false }\n\n if (router.isServer) {\n return () => null\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 // For Vue, we need to completely override startViewTransition because Vue's\n // async rendering doesn't work well with the View Transitions API's requirement\n // for synchronous DOM updates. The browser expects the DOM to be updated\n // when the callback promise resolves, but Vue updates asynchronously.\n //\n // Our approach: Skip the actual view transition animation but still update state.\n // This ensures navigation works correctly even without the visual transition.\n // In the future, we could explore using viewTransition.captured like vue-view-transitions does.\n router.startViewTransition = (fn: () => Promise<void>) => {\n // Just run the callback directly without wrapping in document.startViewTransition\n // This ensures the state updates happen and Vue can render them normally\n fn()\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 if (\n trimPathRight(router.latestLocation.href) !==\n trimPathRight(nextLocation.href)\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 })\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 // 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 router.__store.setState((s) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n\n if (changeInfo.hrefChanged) {\n handleHashScroll(router)\n }\n }\n } catch {\n // Ignore errors if component is unmounted\n }\n })\n\n return () => null\n },\n})\n"],"names":["Transitioner","Vue","defineComponent","name","setup","router","useRouter","mountLoadForRouter","mounted","isServer","isLoading","useRouterState","select","isTransitioning","ref","hasPendingMatches","s","matches","some","d","status","previousIsLoading","usePrevious","value","isAnyPending","computed","previousIsAnyPending","isPagePending","previousIsPagePending","startTransition","fn","__store","setState","endTransition","nextTick","startViewTransition","unsubscribe","onMounted","history","subscribe","load","nextLocation","buildLocation","to","latestLocation","pathname","search","params","hash","state","_includeValidateSearch","trimPathRight","href","commitLocation","replace","isMounted","onUnmounted","window","ssr","tryLoad","err","console","error","watch","newValue","previous","emit","type","getLocationChangeInfo","changeInfo","resolvedLocation","location","hrefChanged","handleHashScroll"],"mappings":";;;;;MAUaA,eAAeC,IAAIC,gBAAgB;AAAA,EAC9CC,MAAM;AAAA,EACNC,QAAQ;AACN,UAAMC,SAASC,UAAS;AACxB,QAAIC,qBAAqB;AAAA,MAAEF;AAAAA,MAAQG,SAAS;AAAA;AAE5C,QAAIH,OAAOI,UAAU;AACnB,aAAO,MAAM;AAAA,IACf;AAEA,UAAMC,YAAYC,eAAe;AAAA,MAC/BC,QAAQA,CAAC;AAAA,QAAEF,WAAAA;AAAAA,MAAU,MAAMA;AAAAA,IAC7B,CAAC;AAGD,UAAMG,kBAAkBZ,IAAIa,IAAI,KAAK;AAGrC,UAAMC,oBAAoBJ,eAAe;AAAA,MACvCC,QAASI,OAAMA,EAAEC,QAAQC,KAAMC,OAAMA,EAAEC,WAAW,SAAS;AAAA,IAC7D,CAAC;AAED,UAAMC,oBAAoBC,YAAY,MAAMZ,UAAUa,KAAK;AAE3D,UAAMC,eAAevB,IAAIwB,SACvB,MAAMf,UAAUa,SAASV,gBAAgBU,SAASR,kBAAkBQ,KACtE;AACA,UAAMG,uBAAuBJ,YAAY,MAAME,aAAaD,KAAK;AAEjE,UAAMI,gBAAgB1B,IAAIwB,SACxB,MAAMf,UAAUa,SAASR,kBAAkBQ,KAC7C;AACA,UAAMK,wBAAwBN,YAAY,MAAMK,cAAcJ,KAAK;AAKnElB,WAAOwB,kBAAmBC,QAAmC;AAC3DjB,sBAAgBU,QAAQ;AAExB,UAAI;AACFlB,eAAO0B,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AQ;AAAA,YACRkD,kBAAkBtD,EAAEuD;AAAAA,UACtB,EAAE;AAEF,cAAIF,WAAWG,aAAa;AAC1BC,6BAAiBpE,MAAM;AAAA,UACzB;AAAA,QACF;AAAA,MACF,QAAQ;AAAA,MACN;AAAA,IAEJ,CAAC;AAED,WAAO,MAAM;AAAA,EACf;AACF,CAAC;"}
|
|
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 { 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 (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 // For Vue, we need to completely override startViewTransition because Vue's\n // async rendering doesn't work well with the View Transitions API's requirement\n // for synchronous DOM updates. The browser expects the DOM to be updated\n // when the callback promise resolves, but Vue updates asynchronously.\n //\n // Our approach: Skip the actual view transition animation but still update state.\n // This ensures navigation works correctly even without the visual transition.\n // In the future, we could explore using viewTransition.captured like vue-view-transitions does.\n router.startViewTransition = (fn: () => Promise<void>) => {\n // Just run the callback directly without wrapping in document.startViewTransition\n // This ensures the state updates happen and Vue can render them normally\n fn()\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 if (\n trimPathRight(router.latestLocation.href) !==\n trimPathRight(nextLocation.href)\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 })\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 // 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 router.__store.setState((s) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\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","startViewTransition","unsubscribe","onMounted","history","subscribe","load","nextLocation","buildLocation","to","latestLocation","pathname","search","params","hash","state","_includeValidateSearch","trimPathRight","href","commitLocation","replace","isMounted","onUnmounted","window","ssr","tryLoad","err","console","error","watch","newValue","previous","emit","type","getLocationChangeInfo","changeInfo","resolvedLocation","location","hrefChanged","handleHashScroll","defineComponent","name","setup"],"mappings":";;;;;AAWA,IAAIA,qBAAqB;AAAA,EAAEC,QAAQ;AAAA,EAAaC,SAAS;AAAM;AAYxD,SAASC,uBAAuB;AACrC,QAAMF,SAASG,UAAS;AAGxB,MAAIH,OAAOI,UAAU;AACnB;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,iBAAiB;AAAA,MAAK,EAAE;AAAA,IAClE,QAAQ;AAAA,IACN;AAIF,UAAMqB,gBAAgBA,MAAM;AAE1BpB,UAAIqB,SAAS,MAAM;AACjB,Y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,IAAI6D,gBAAgB;AAAA,EAC9CC,MAAM;AAAA,EACNC,QAAQ;AACNtE,yBAAoB;AACpB,WAAO,MAAM;AAAA,EACf;AACF,CAAC;"}
|
package/dist/esm/awaited.d.ts
CHANGED
|
@@ -4,9 +4,24 @@ export type AwaitOptions<T> = {
|
|
|
4
4
|
promise: Promise<T>;
|
|
5
5
|
};
|
|
6
6
|
export declare function useAwaited<T>({ promise: _promise, }: AwaitOptions<T>): [T, DeferredPromise<T>];
|
|
7
|
-
export declare
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export declare const Await: Vue.DefineComponent<Vue.ExtractPropTypes<{
|
|
8
|
+
promise: {
|
|
9
|
+
type: PromiseConstructor;
|
|
10
|
+
required: true;
|
|
11
|
+
};
|
|
12
|
+
children: {
|
|
13
|
+
type: FunctionConstructor;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
}>, () => Vue.VNode<Vue.RendererNode, Vue.RendererElement, {
|
|
11
17
|
[key: string]: any;
|
|
12
|
-
}
|
|
18
|
+
}>, {}, {}, {}, Vue.ComponentOptionsMixin, Vue.ComponentOptionsMixin, {}, string, Vue.PublicProps, Readonly<Vue.ExtractPropTypes<{
|
|
19
|
+
promise: {
|
|
20
|
+
type: PromiseConstructor;
|
|
21
|
+
required: true;
|
|
22
|
+
};
|
|
23
|
+
children: {
|
|
24
|
+
type: FunctionConstructor;
|
|
25
|
+
required: true;
|
|
26
|
+
};
|
|
27
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, Vue.ComponentProvideOptions, true, {}, any>;
|
package/dist/esm/awaited.js
CHANGED
|
@@ -12,27 +12,24 @@ function useAwaited({
|
|
|
12
12
|
}
|
|
13
13
|
return [promise[TSR_DEFERRED_PROMISE].data, promise];
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} finally {
|
|
26
|
-
pending.value = false;
|
|
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
|
|
27
25
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return props.children(data
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
|
26
|
+
},
|
|
27
|
+
async setup(props) {
|
|
28
|
+
const deferred = defer(props.promise);
|
|
29
|
+
const data = await deferred;
|
|
30
|
+
return () => props.children(data);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
36
33
|
export {
|
|
37
34
|
Await,
|
|
38
35
|
useAwaited
|
package/dist/esm/awaited.js.map
CHANGED
|
@@ -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
|
|
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;"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -47,5 +47,7 @@ export { ScriptOnce } from './ScriptOnce.js';
|
|
|
47
47
|
export { Asset } from './Asset.js';
|
|
48
48
|
export { HeadContent } from './HeadContent.js';
|
|
49
49
|
export { Scripts } from './Scripts.js';
|
|
50
|
+
export { Body } from './Body.js';
|
|
51
|
+
export { Html } from './Html.js';
|
|
50
52
|
export { composeRewrites } from '@tanstack/router-core';
|
|
51
53
|
export type { LocationRewrite, LocationRewriteFunction, } from '@tanstack/router-core';
|
package/dist/esm/index.js
CHANGED
|
@@ -31,10 +31,13 @@ import { ScriptOnce } from "./ScriptOnce.js";
|
|
|
31
31
|
import { Asset } from "./Asset.js";
|
|
32
32
|
import { HeadContent } from "./HeadContent.js";
|
|
33
33
|
import { Scripts } from "./Scripts.js";
|
|
34
|
+
import { Body } from "./Body.js";
|
|
35
|
+
import { Html } from "./Html.js";
|
|
34
36
|
export {
|
|
35
37
|
Asset,
|
|
36
38
|
Await,
|
|
37
39
|
Block,
|
|
40
|
+
Body,
|
|
38
41
|
CatchBoundary,
|
|
39
42
|
CatchNotFound,
|
|
40
43
|
DefaultGlobalNotFound,
|
|
@@ -42,6 +45,7 @@ export {
|
|
|
42
45
|
FileRoute,
|
|
43
46
|
FileRouteLoader,
|
|
44
47
|
HeadContent,
|
|
48
|
+
Html,
|
|
45
49
|
LazyRoute,
|
|
46
50
|
Link,
|
|
47
51
|
Match,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -52,14 +52,14 @@ function lazyRouteComponent(importer, exportName, ssr) {
|
|
|
52
52
|
const lazyComp = Vue.defineComponent({
|
|
53
53
|
name: "LazyRouteComponent",
|
|
54
54
|
setup(props) {
|
|
55
|
-
const component = Vue.
|
|
55
|
+
const component = Vue.shallowRef(comp ? Vue.markRaw(comp) : comp);
|
|
56
56
|
const errorState = Vue.ref(error);
|
|
57
57
|
const loading = Vue.ref(!component.value && !errorState.value);
|
|
58
58
|
Vue.onMounted(() => {
|
|
59
59
|
if (!component.value && !errorState.value) {
|
|
60
60
|
loading.value = true;
|
|
61
61
|
load().then((result) => {
|
|
62
|
-
component.value = result;
|
|
62
|
+
component.value = result ? Vue.markRaw(result) : result;
|
|
63
63
|
loading.value = false;
|
|
64
64
|
}).catch((err) => {
|
|
65
65
|
errorState.value = err;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyRouteComponent.js","sources":["../../src/lazyRouteComponent.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { Outlet } from './Match'\nimport type { AsyncRouteComponent } from './route'\n\n// If the load fails due to module not found, it may mean a new version of\n// the build was deployed and the user's browser is still using an old version.\n// If this happens, the old version in the user's browser would have an outdated\n// URL to the lazy module.\n// In that case, we want to attempt one window refresh to get the latest.\nfunction isModuleNotFoundError(error: any): boolean {\n // chrome: \"Failed to fetch dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split\"\n // firefox: \"error loading dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split\"\n // safari: \"Importing a module script failed.\"\n if (typeof error?.message !== 'string') return false\n return (\n error.message.startsWith('Failed to fetch dynamically imported module') ||\n error.message.startsWith('error loading dynamically imported module') ||\n error.message.startsWith('Importing a module script failed')\n )\n}\n\nexport function ClientOnly(props: { children?: any; fallback?: Vue.VNode }) {\n const hydrated = useHydrated()\n\n return () => {\n if (hydrated.value) {\n return props.children\n }\n return props.fallback || null\n }\n}\n\nexport function useHydrated() {\n // Only hydrate on client-side, never on server\n const hydrated = Vue.ref(false)\n\n // If on server, return false\n if (typeof window === 'undefined') {\n return Vue.computed(() => false)\n }\n\n // On client, set to true once mounted\n Vue.onMounted(() => {\n hydrated.value = true\n })\n\n return hydrated\n}\n\nexport function lazyRouteComponent<\n T extends Record<string, any>,\n TKey extends keyof T = 'default',\n>(\n importer: () => Promise<T>,\n exportName?: TKey,\n ssr?: () => boolean,\n): T[TKey] extends (props: infer TProps) => any\n ? AsyncRouteComponent<TProps>\n : never {\n let loadPromise: Promise<any> | undefined\n let comp: T[TKey] | T['default'] | null = null\n let error: any = null\n let attemptedReload = false\n\n const load = () => {\n // If we're on the server and SSR is disabled for this component\n if (typeof document === 'undefined' && ssr?.() === false) {\n comp = (() => null) as any\n return Promise.resolve(comp)\n }\n\n // Use existing promise or create new one\n if (!loadPromise) {\n loadPromise = importer()\n .then((res) => {\n loadPromise = undefined\n comp = res[exportName ?? 'default']\n return comp\n })\n .catch((err) => {\n error = err\n loadPromise = undefined\n\n // If it's a module not found error, we'll try to handle it in the component\n if (isModuleNotFoundError(error)) {\n return null\n }\n\n throw err\n })\n }\n\n return loadPromise\n }\n\n // Create a lazy component wrapper using defineComponent so it works in Vue SFC templates\n const lazyComp = Vue.defineComponent({\n name: 'LazyRouteComponent',\n setup(props: any) {\n // Create refs to track component state\n const component = Vue.
|
|
1
|
+
{"version":3,"file":"lazyRouteComponent.js","sources":["../../src/lazyRouteComponent.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { Outlet } from './Match'\nimport type { AsyncRouteComponent } from './route'\n\n// If the load fails due to module not found, it may mean a new version of\n// the build was deployed and the user's browser is still using an old version.\n// If this happens, the old version in the user's browser would have an outdated\n// URL to the lazy module.\n// In that case, we want to attempt one window refresh to get the latest.\nfunction isModuleNotFoundError(error: any): boolean {\n // chrome: \"Failed to fetch dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split\"\n // firefox: \"error loading dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split\"\n // safari: \"Importing a module script failed.\"\n if (typeof error?.message !== 'string') return false\n return (\n error.message.startsWith('Failed to fetch dynamically imported module') ||\n error.message.startsWith('error loading dynamically imported module') ||\n error.message.startsWith('Importing a module script failed')\n )\n}\n\nexport function ClientOnly(props: { children?: any; fallback?: Vue.VNode }) {\n const hydrated = useHydrated()\n\n return () => {\n if (hydrated.value) {\n return props.children\n }\n return props.fallback || null\n }\n}\n\nexport function useHydrated() {\n // Only hydrate on client-side, never on server\n const hydrated = Vue.ref(false)\n\n // If on server, return false\n if (typeof window === 'undefined') {\n return Vue.computed(() => false)\n }\n\n // On client, set to true once mounted\n Vue.onMounted(() => {\n hydrated.value = true\n })\n\n return hydrated\n}\n\nexport function lazyRouteComponent<\n T extends Record<string, any>,\n TKey extends keyof T = 'default',\n>(\n importer: () => Promise<T>,\n exportName?: TKey,\n ssr?: () => boolean,\n): T[TKey] extends (props: infer TProps) => any\n ? AsyncRouteComponent<TProps>\n : never {\n let loadPromise: Promise<any> | undefined\n let comp: T[TKey] | T['default'] | null = null\n let error: any = null\n let attemptedReload = false\n\n const load = () => {\n // If we're on the server and SSR is disabled for this component\n if (typeof document === 'undefined' && ssr?.() === false) {\n comp = (() => null) as any\n return Promise.resolve(comp)\n }\n\n // Use existing promise or create new one\n if (!loadPromise) {\n loadPromise = importer()\n .then((res) => {\n loadPromise = undefined\n comp = res[exportName ?? 'default']\n return comp\n })\n .catch((err) => {\n error = err\n loadPromise = undefined\n\n // If it's a module not found error, we'll try to handle it in the component\n if (isModuleNotFoundError(error)) {\n return null\n }\n\n throw err\n })\n }\n\n return loadPromise\n }\n\n // Create a lazy component wrapper using defineComponent so it works in Vue SFC templates\n const lazyComp = Vue.defineComponent({\n name: 'LazyRouteComponent',\n setup(props: any) {\n // Create refs to track component state\n // Use shallowRef for component to avoid making it reactive (Vue warning)\n const component = Vue.shallowRef<any>(comp ? Vue.markRaw(comp) : comp)\n const errorState = Vue.ref<any>(error)\n const loading = Vue.ref(!component.value && !errorState.value)\n\n // Setup effect to load the component when this component is used\n Vue.onMounted(() => {\n if (!component.value && !errorState.value) {\n loading.value = true\n\n load()\n .then((result) => {\n // Use markRaw to prevent Vue from making the component reactive\n component.value = result ? Vue.markRaw(result) : result\n loading.value = false\n })\n .catch((err) => {\n errorState.value = err\n loading.value = false\n })\n }\n })\n\n // Handle module not found error with reload attempt\n if (\n errorState.value &&\n isModuleNotFoundError(errorState.value) &&\n !attemptedReload\n ) {\n if (\n typeof window !== 'undefined' &&\n typeof sessionStorage !== 'undefined'\n ) {\n // Try to reload once on module not found error\n const storageKey = `tanstack_router_reload:${errorState.value.message}`\n if (!sessionStorage.getItem(storageKey)) {\n sessionStorage.setItem(storageKey, '1')\n attemptedReload = true\n window.location.reload()\n return () => null // Return empty while reloading\n }\n }\n }\n\n // If we have a non-module-not-found error, throw it\n if (errorState.value && !isModuleNotFoundError(errorState.value)) {\n throw errorState.value\n }\n\n // Return a render function\n return () => {\n // If we're still loading or don't have a component yet, use a suspense pattern\n if (loading.value || !component.value) {\n return Vue.h('div', null) // Empty div while loading\n }\n\n // If SSR is disabled for this component\n if (ssr?.() === false) {\n return Vue.h(ClientOnly, {\n fallback: Vue.h(Outlet),\n children: Vue.h(component.value, props),\n })\n }\n\n // Regular render with the loaded component\n return Vue.h(component.value, props)\n }\n },\n })\n\n // Add preload method\n ;(lazyComp as any).preload = load\n\n return lazyComp as any\n}\n"],"names":["isModuleNotFoundError","error","message","startsWith","ClientOnly","props","hydrated","useHydrated","value","children","fallback","Vue","ref","window","computed","onMounted","lazyRouteComponent","importer","exportName","ssr","loadPromise","comp","attemptedReload","load","document","Promise","resolve","then","res","undefined","catch","err","lazyComp","defineComponent","name","setup","component","shallowRef","markRaw","errorState","loading","result","sessionStorage","storageKey","getItem","setItem","location","reload","h","Outlet","preload"],"mappings":";;AASA,SAASA,sBAAsBC,OAAqB;AAIlD,MAAI,OAAOA,OAAOC,YAAY,SAAU,QAAO;AAC/C,SACED,MAAMC,QAAQC,WAAW,6CAA6C,KACtEF,MAAMC,QAAQC,WAAW,2CAA2C,KACpEF,MAAMC,QAAQC,WAAW,kCAAkC;AAE/D;AAEO,SAASC,WAAWC,OA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C;AAAA,IACF;AAAA,GACD;AAGC2B,WAAiBkB,UAAU3B;AAE7B,SAAOS;AACT;"}
|
package/dist/esm/link.js
CHANGED
|
@@ -247,65 +247,56 @@ function useLinkProps(options) {
|
|
|
247
247
|
}
|
|
248
248
|
return hrefValue;
|
|
249
249
|
});
|
|
250
|
-
const
|
|
251
|
-
...getPropsSafeToSpread(),
|
|
252
|
-
href: void 0,
|
|
253
|
-
ref,
|
|
250
|
+
const staticEventHandlers = {
|
|
254
251
|
onClick: composeEventHandlers([options.onClick, handleClick]),
|
|
255
252
|
onFocus: composeEventHandlers([options.onFocus, handleFocus]),
|
|
256
253
|
onMouseenter: composeEventHandlers([options.onMouseEnter, handleEnter]),
|
|
257
254
|
onMouseover: composeEventHandlers([options.onMouseOver, handleEnter]),
|
|
258
255
|
onMouseleave: composeEventHandlers([options.onMouseLeave, handleLeave]),
|
|
259
256
|
onMouseout: composeEventHandlers([options.onMouseOut, handleLeave]),
|
|
260
|
-
onTouchstart: composeEventHandlers([options.onTouchStart, handleTouchStart])
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
257
|
+
onTouchstart: composeEventHandlers([options.onTouchStart, handleTouchStart])
|
|
258
|
+
};
|
|
259
|
+
const computedProps = Vue.computed(() => {
|
|
260
|
+
const result = {
|
|
261
|
+
...getPropsSafeToSpread(),
|
|
262
|
+
href: href.value,
|
|
263
|
+
ref,
|
|
264
|
+
...staticEventHandlers,
|
|
265
|
+
disabled: !!options.disabled,
|
|
266
|
+
target: options.target
|
|
267
|
+
};
|
|
268
268
|
if (resolvedStyle.value) {
|
|
269
|
-
|
|
270
|
-
} else {
|
|
271
|
-
delete reactiveProps.style;
|
|
269
|
+
result.style = resolvedStyle.value;
|
|
272
270
|
}
|
|
273
271
|
if (resolvedClassName.value) {
|
|
274
|
-
|
|
275
|
-
} else {
|
|
276
|
-
delete reactiveProps.class;
|
|
272
|
+
result.class = resolvedClassName.value;
|
|
277
273
|
}
|
|
278
274
|
if (options.disabled) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
} else {
|
|
282
|
-
delete reactiveProps.role;
|
|
283
|
-
delete reactiveProps["aria-disabled"];
|
|
275
|
+
result.role = "link";
|
|
276
|
+
result["aria-disabled"] = true;
|
|
284
277
|
}
|
|
285
278
|
if (isActive.value) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
} else {
|
|
289
|
-
delete reactiveProps["data-status"];
|
|
290
|
-
delete reactiveProps["aria-current"];
|
|
279
|
+
result["data-status"] = "active";
|
|
280
|
+
result["aria-current"] = "page";
|
|
291
281
|
}
|
|
292
282
|
if (isTransitioning.value) {
|
|
293
|
-
|
|
294
|
-
} else {
|
|
295
|
-
delete reactiveProps["data-transitioning"];
|
|
283
|
+
result["data-transitioning"] = "transitioning";
|
|
296
284
|
}
|
|
285
|
+
const activeP = resolvedActiveProps.value;
|
|
286
|
+
const inactiveP = resolvedInactiveProps.value;
|
|
297
287
|
for (const key of Object.keys(activeP)) {
|
|
298
288
|
if (key !== "class" && key !== "style") {
|
|
299
|
-
|
|
289
|
+
result[key] = activeP[key];
|
|
300
290
|
}
|
|
301
291
|
}
|
|
302
292
|
for (const key of Object.keys(inactiveP)) {
|
|
303
293
|
if (key !== "class" && key !== "style") {
|
|
304
|
-
|
|
294
|
+
result[key] = inactiveP[key];
|
|
305
295
|
}
|
|
306
296
|
}
|
|
297
|
+
return result;
|
|
307
298
|
});
|
|
308
|
-
return
|
|
299
|
+
return computedProps;
|
|
309
300
|
}
|
|
310
301
|
function createLink(Comp) {
|
|
311
302
|
return Vue.defineComponent({
|
|
@@ -334,9 +325,10 @@ const LinkImpl = Vue.defineComponent({
|
|
|
334
325
|
...props,
|
|
335
326
|
...attrs
|
|
336
327
|
};
|
|
337
|
-
const
|
|
328
|
+
const linkPropsComputed = useLinkProps(allProps);
|
|
338
329
|
return () => {
|
|
339
330
|
const Component = props._asChild || "a";
|
|
331
|
+
const linkProps = linkPropsComputed.value;
|
|
340
332
|
const isActive = linkProps["data-status"] === "active";
|
|
341
333
|
const isTransitioning = linkProps["data-transitioning"] === "transitioning";
|
|
342
334
|
const slotContent = slots.default ? slots.default({
|