@bleedingdev/modern-js-plugin-tanstack 3.9.0-ultramodern.2 → 3.9.0-ultramodern.20
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/cjs/cli/artifacts.js +15 -1
- package/dist/cjs/cli/index.js +12 -0
- package/dist/cjs/cli/routeMetadata.js +131 -0
- package/dist/cjs/cli/tanstackTypes/canonicalRoutes.js +7 -7
- package/dist/cjs/cli/tanstackTypes/shared.js +0 -14
- package/dist/cjs/cli/tanstackTypes/source.js +27 -60
- package/dist/cjs/runtime/basepathRewrite.js +13 -6
- package/dist/cjs/runtime/lifecycle.js +6 -9
- package/dist/cjs/runtime/loaderBridge.js +10 -4
- package/dist/cjs/runtime/navigation.js +102 -0
- package/dist/cjs/runtime/plugin.js +7 -2
- package/dist/cjs/runtime/plugin.node.js +86 -64
- package/dist/cjs/runtime/prefetchLink.js +2 -7
- package/dist/cjs/runtime/register.js +0 -2
- package/dist/cjs/runtime/routeTree/construction.js +19 -59
- package/dist/cjs/runtime/routeTree/loaders.js +1 -1
- package/dist/cjs/runtime/routeTree/paths.js +0 -6
- package/dist/cjs/runtime/router.js +25 -9
- package/dist/cjs/runtime/ssrManagedTags.js +2 -12
- package/dist/cjs/runtime/state.js +2 -2
- package/dist/cjs/runtime/utils.js +3 -0
- package/dist/cjs/shared/routeDescriptor.js +60 -0
- package/dist/esm/cli/artifacts.mjs +13 -2
- package/dist/esm/cli/index.mjs +12 -9
- package/dist/esm/cli/routeMetadata.mjs +71 -0
- package/dist/esm/cli/tanstackTypes/canonicalRoutes.mjs +7 -7
- package/dist/esm/cli/tanstackTypes/shared.mjs +1 -9
- package/dist/esm/cli/tanstackTypes/source.mjs +28 -61
- package/dist/esm/runtime/basepathRewrite.mjs +10 -3
- package/dist/esm/runtime/lifecycle.mjs +1 -1
- package/dist/esm/runtime/loaderBridge.mjs +8 -5
- package/dist/esm/runtime/navigation.mjs +64 -0
- package/dist/esm/runtime/plugin.mjs +7 -2
- package/dist/esm/runtime/plugin.node.mjs +88 -66
- package/dist/esm/runtime/prefetchLink.mjs +1 -6
- package/dist/esm/runtime/register.mjs +0 -2
- package/dist/esm/runtime/routeTree/construction.mjs +19 -59
- package/dist/esm/runtime/routeTree/loaders.mjs +2 -2
- package/dist/esm/runtime/routeTree/paths.mjs +1 -4
- package/dist/esm/runtime/router.mjs +27 -11
- package/dist/esm/runtime/ssrManagedTags.mjs +1 -8
- package/dist/esm/runtime/state.mjs +1 -1
- package/dist/esm/runtime/utils.mjs +3 -0
- package/dist/esm/shared/routeDescriptor.mjs +22 -0
- package/dist/esm-node/cli/artifacts.mjs +13 -2
- package/dist/esm-node/cli/index.mjs +12 -9
- package/dist/esm-node/cli/routeMetadata.mjs +72 -0
- package/dist/esm-node/cli/tanstackTypes/canonicalRoutes.mjs +7 -7
- package/dist/esm-node/cli/tanstackTypes/shared.mjs +1 -9
- package/dist/esm-node/cli/tanstackTypes/source.mjs +28 -61
- package/dist/esm-node/runtime/basepathRewrite.mjs +10 -3
- package/dist/esm-node/runtime/lifecycle.mjs +1 -1
- package/dist/esm-node/runtime/loaderBridge.mjs +8 -5
- package/dist/esm-node/runtime/navigation.mjs +65 -0
- package/dist/esm-node/runtime/plugin.mjs +7 -2
- package/dist/esm-node/runtime/plugin.node.mjs +88 -66
- package/dist/esm-node/runtime/prefetchLink.mjs +1 -6
- package/dist/esm-node/runtime/register.mjs +0 -2
- package/dist/esm-node/runtime/routeTree/construction.mjs +19 -59
- package/dist/esm-node/runtime/routeTree/loaders.mjs +2 -2
- package/dist/esm-node/runtime/routeTree/paths.mjs +1 -4
- package/dist/esm-node/runtime/router.mjs +27 -11
- package/dist/esm-node/runtime/ssrManagedTags.mjs +1 -8
- package/dist/esm-node/runtime/state.mjs +1 -1
- package/dist/esm-node/runtime/utils.mjs +3 -0
- package/dist/esm-node/shared/routeDescriptor.mjs +23 -0
- package/dist/types/cli/artifacts.d.ts +13 -5
- package/dist/types/cli/index.d.ts +1 -1
- package/dist/types/cli/routeMetadata.d.ts +18 -0
- package/dist/types/cli/tanstackTypes/shared.d.ts +0 -2
- package/dist/types/runtime/basepathRewrite.d.ts +2 -1
- package/dist/types/runtime/lifecycle.d.ts +9 -2
- package/dist/types/runtime/loaderBridge.d.ts +1 -0
- package/dist/types/runtime/navigation.d.ts +4 -0
- package/dist/types/runtime/register.d.ts +1 -9
- package/dist/types/runtime/routeTree/paths.d.ts +0 -2
- package/dist/types/runtime/router.d.ts +2 -13
- package/dist/types/runtime/ssrManagedTags.d.ts +0 -1
- package/dist/types/runtime/ssrTypes.d.ts +0 -7
- package/dist/types/runtime/state.d.ts +1 -1
- package/dist/types/runtime/types.d.ts +2 -1
- package/dist/types/shared/routeDescriptor.d.ts +26 -0
- package/package.json +22 -19
- package/rstest.config.mts +2 -24
- package/src/cli/artifacts.ts +53 -6
- package/src/cli/index.ts +11 -2
- package/src/cli/routeMetadata.ts +121 -0
- package/src/cli/tanstackTypes/canonicalRoutes.ts +17 -12
- package/src/cli/tanstackTypes/shared.ts +0 -14
- package/src/cli/tanstackTypes/source.ts +42 -116
- package/src/runtime/basepathRewrite.ts +11 -2
- package/src/runtime/lifecycle.ts +14 -4
- package/src/runtime/loaderBridge.ts +9 -9
- package/src/runtime/navigation.ts +78 -0
- package/src/runtime/plugin.node.tsx +120 -93
- package/src/runtime/plugin.tsx +11 -1
- package/src/runtime/prefetchLink.tsx +1 -23
- package/src/runtime/register.ts +1 -12
- package/src/runtime/routeTree/construction.ts +32 -110
- package/src/runtime/routeTree/loaders.ts +2 -4
- package/src/runtime/routeTree/paths.ts +0 -6
- package/src/runtime/router.ts +25 -40
- package/src/runtime/ssrManagedTags.ts +0 -17
- package/src/runtime/ssrTypes.ts +0 -7
- package/src/runtime/state.ts +1 -1
- package/src/runtime/types.ts +2 -2
- package/src/runtime/utils.tsx +4 -1
- package/src/shared/routeDescriptor.ts +46 -0
- package/tests/router/cli.test.ts +148 -824
- package/tests/router/clientNavigation.ts +13 -0
- package/tests/router/dataMutation.test.tsx +17 -85
- package/tests/router/flightSerialization.roundtrip.test.tsx +9 -6
- package/tests/router/generateRouteArtifacts.test.ts +139 -27
- package/tests/router/loaderBridge.test.ts +0 -25
- package/tests/router/localisedIdentity.test.tsx +100 -0
- package/tests/router/prefetchLink.test.tsx +46 -21
- package/tests/router/prefetchLinkPreload.test.tsx +11 -32
- package/tests/router/routeHooks.test.ts +42 -105
- package/tests/router/routeMetadata.test.ts +171 -0
- package/tests/router/routeTree.test.ts +144 -836
- package/tests/router/rsc.test.tsx +131 -166
- package/tests/router/serverPlugin.test.ts +193 -1
- package/tests/router/tanstackTypes.test.ts +218 -963
- package/dist/esm/rslib-runtime~1.mjs +0 -18
- package/dist/esm-node/rslib-runtime~0.mjs +0 -19
- package/tests/realm-isolation.test.ts +0 -114
- package/tests/router/fastDefaults.test.ts +0 -32
- package/tests/router/fixtures/legacyRuntimeRouter.ts +0 -10
- package/tests/router/fixtures/rscDecoderSecurityChild.cjs +0 -162
- package/tests/router/hooks.test.ts +0 -40
- package/tests/router/hydrationBoundary.test.tsx +0 -23
- package/tests/router/packageSurface.test.ts +0 -24
- package/tests/router/preloadRedirect.test.ts +0 -64
- package/tests/router/register.test.ts +0 -8
- package/tests/router/routerCompatibility.test.ts +0 -239
- package/tests/router/rscDecoderSecurity.test.ts +0 -113
- package/tests/router/rscPayloadRouterMatrix.test.ts +0 -197
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
createTanstackNavigation: ()=>createTanstackNavigation
|
|
32
|
+
});
|
|
33
|
+
const external_prefetchLink_js_namespaceObject = require("./prefetchLink.js");
|
|
34
|
+
function createTanstackNavigation(router) {
|
|
35
|
+
let location;
|
|
36
|
+
let matches;
|
|
37
|
+
let snapshot;
|
|
38
|
+
return {
|
|
39
|
+
Link: external_prefetchLink_js_namespaceObject.Link,
|
|
40
|
+
getSnapshot () {
|
|
41
|
+
const state = router.state;
|
|
42
|
+
if (location !== state.location || void 0 === matches || matches.length !== state.matches.length || matches.some((match, index)=>match.params !== state.matches[index]?.params)) {
|
|
43
|
+
location = state.location;
|
|
44
|
+
matches = state.matches;
|
|
45
|
+
snapshot = {
|
|
46
|
+
location: {
|
|
47
|
+
pathname: location.pathname,
|
|
48
|
+
search: location.searchStr,
|
|
49
|
+
hash: '' !== location.hash ? `#${location.hash.replace(/^#/, '')}` : ''
|
|
50
|
+
},
|
|
51
|
+
params: Object.assign({}, ...matches.map((match)=>match.params))
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return snapshot;
|
|
55
|
+
},
|
|
56
|
+
subscribe (listener) {
|
|
57
|
+
const stops = [
|
|
58
|
+
'onBeforeNavigate',
|
|
59
|
+
'onBeforeLoad',
|
|
60
|
+
'onLoad',
|
|
61
|
+
'onResolved'
|
|
62
|
+
].map((event)=>router.subscribe(event, listener));
|
|
63
|
+
return ()=>{
|
|
64
|
+
for (const stop of stops)stop();
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
navigate (href, options) {
|
|
68
|
+
return router.navigate({
|
|
69
|
+
to: href,
|
|
70
|
+
replace: options?.replace,
|
|
71
|
+
...options?.state === void 0 ? {} : {
|
|
72
|
+
state: options.state
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
createLinkProps (target) {
|
|
77
|
+
const preload = void 0 !== target.preload ? target.preload : 'none' === target.prefetch ? false : target.prefetch;
|
|
78
|
+
return {
|
|
79
|
+
to: target.pathname,
|
|
80
|
+
...void 0 !== target.search ? {
|
|
81
|
+
search: target.search
|
|
82
|
+
} : {},
|
|
83
|
+
...void 0 !== target.hash && '' !== target.hash ? {
|
|
84
|
+
hash: target.hash
|
|
85
|
+
} : {},
|
|
86
|
+
...void 0 === target.hashScrollIntoView ? {} : {
|
|
87
|
+
hashScrollIntoView: target.hashScrollIntoView
|
|
88
|
+
},
|
|
89
|
+
...void 0 === preload ? {} : {
|
|
90
|
+
preload
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
exports.createTanstackNavigation = __webpack_exports__.createTanstackNavigation;
|
|
97
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
98
|
+
"createTanstackNavigation"
|
|
99
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
100
|
+
Object.defineProperty(exports, '__esModule', {
|
|
101
|
+
value: true
|
|
102
|
+
});
|
|
@@ -43,6 +43,7 @@ const external_clientHydration_js_namespaceObject = require("./clientHydration.j
|
|
|
43
43
|
const external_hooks_js_namespaceObject = require("./hooks.js");
|
|
44
44
|
const external_hydrationBoundary_js_namespaceObject = require("./hydrationBoundary.js");
|
|
45
45
|
const external_lifecycle_js_namespaceObject = require("./lifecycle.js");
|
|
46
|
+
const external_navigation_js_namespaceObject = require("./navigation.js");
|
|
46
47
|
const external_pluginShared_js_namespaceObject = require("./pluginShared.js");
|
|
47
48
|
const external_prefetchLink_js_namespaceObject = require("./prefetchLink.js");
|
|
48
49
|
const external_routeHooks_js_namespaceObject = require("./routeHooks.js");
|
|
@@ -110,7 +111,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
110
111
|
const mergedConfig = getMergedConfig();
|
|
111
112
|
const { supportHtml5History = true } = mergedConfig;
|
|
112
113
|
const history = supportHtml5History ? (0, react_router_namespaceObject.createBrowserHistory)() : (0, react_router_namespaceObject.createHashHistory)();
|
|
113
|
-
const rewrite = (0, external_basepathRewrite_js_namespaceObject.createModernBasepathRewrite)(_basename);
|
|
114
|
+
const rewrite = (0, external_basepathRewrite_js_namespaceObject.createModernBasepathRewrite)(_basename, false, getRouteObjects());
|
|
114
115
|
const serializationAdapters = (0, context_namespaceObject.getGlobalEnableRsc)() ? (0, client_js_namespaceObject.getTanstackRscSerializationAdapters)() : void 0;
|
|
115
116
|
const routerFastDefaults = (0, external_types_js_namespaceObject.getModernTanstackRouterFastDefaults)(mergedConfig);
|
|
116
117
|
cachedRouter = (0, react_router_namespaceObject.createRouter)({
|
|
@@ -175,10 +176,14 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
175
176
|
runtimeContext
|
|
176
177
|
]);
|
|
177
178
|
if (!router) return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {}) : null;
|
|
179
|
+
const navigation = (0, external_react_namespaceObject.useMemo)(()=>(0, external_navigation_js_namespaceObject.createTanstackNavigation)(router), [
|
|
180
|
+
router
|
|
181
|
+
]);
|
|
178
182
|
const runtimeState = (0, external_lifecycle_js_namespaceObject.applyRouterRuntimeState)(runtimeContext, {
|
|
179
183
|
framework: 'tanstack',
|
|
180
184
|
basename: _basename,
|
|
181
|
-
instance: router
|
|
185
|
+
instance: router,
|
|
186
|
+
navigation
|
|
182
187
|
});
|
|
183
188
|
const lifecycleContext = {
|
|
184
189
|
framework: 'tanstack',
|
|
@@ -42,7 +42,9 @@ const external_basepathRewrite_js_namespaceObject = require("./basepathRewrite.j
|
|
|
42
42
|
const external_hooks_js_namespaceObject = require("./hooks.js");
|
|
43
43
|
const external_hydrationBoundary_js_namespaceObject = require("./hydrationBoundary.js");
|
|
44
44
|
const external_lifecycle_js_namespaceObject = require("./lifecycle.js");
|
|
45
|
+
const external_navigation_js_namespaceObject = require("./navigation.js");
|
|
45
46
|
const external_pluginShared_js_namespaceObject = require("./pluginShared.js");
|
|
47
|
+
const external_prefetchLink_js_namespaceObject = require("./prefetchLink.js");
|
|
46
48
|
const index_js_namespaceObject = require("./routeTree/index.js");
|
|
47
49
|
const payloadRouter_js_namespaceObject = require("./rsc/payloadRouter.js");
|
|
48
50
|
const payloadStorage_js_namespaceObject = require("./rsc/payloadStorage.js");
|
|
@@ -68,6 +70,9 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
68
70
|
routeConfig
|
|
69
71
|
});
|
|
70
72
|
if (!modifiedRouteObjects.length) return;
|
|
73
|
+
context.router = {
|
|
74
|
+
Link: external_prefetchLink_js_namespaceObject.Link
|
|
75
|
+
};
|
|
71
76
|
const { request, nonce, baseUrl, loaderFailureMode = 'errorBoundary' } = context.ssrContext;
|
|
72
77
|
const _basename = '/' === baseUrl ? (0, external_pluginShared_js_namespaceObject.joinBasename)(baseUrl, basename || '') : baseUrl;
|
|
73
78
|
const rawRequest = request.raw;
|
|
@@ -90,7 +95,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
90
95
|
initialHref
|
|
91
96
|
]
|
|
92
97
|
});
|
|
93
|
-
const rewrite = (0, external_basepathRewrite_js_namespaceObject.createModernBasepathRewrite)(_basename);
|
|
98
|
+
const rewrite = (0, external_basepathRewrite_js_namespaceObject.createModernBasepathRewrite)(_basename, false, modifiedRouteObjects);
|
|
94
99
|
const routerLifecycleContext = {
|
|
95
100
|
framework: 'tanstack',
|
|
96
101
|
phase: 'ssr-prepare',
|
|
@@ -116,76 +121,93 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
116
121
|
});
|
|
117
122
|
const serverRouter = tanstackRouter;
|
|
118
123
|
if (enableRsc) (0, payloadStorage_js_namespaceObject.setTanstackRscRouter)(serverRouter);
|
|
119
|
-
|
|
120
|
-
|
|
124
|
+
let disposed = false;
|
|
125
|
+
let prepared = false;
|
|
126
|
+
const onAbort = ()=>controller.abort(rawRequest.signal.reason);
|
|
127
|
+
const cleanup = ()=>{
|
|
128
|
+
if (disposed) return;
|
|
129
|
+
disposed = true;
|
|
130
|
+
rawRequest.signal.removeEventListener('abort', onAbort);
|
|
131
|
+
controller.abort();
|
|
132
|
+
serverRouter.serverSsr?.cleanup();
|
|
133
|
+
};
|
|
134
|
+
(0, external_lifecycle_js_namespaceObject.applyRouterRuntimeState)(context, {
|
|
135
|
+
framework: 'tanstack',
|
|
136
|
+
basename: _basename,
|
|
137
|
+
instance: serverRouter,
|
|
138
|
+
cleanup
|
|
139
|
+
});
|
|
140
|
+
rawRequest.signal.addEventListener('abort', onAbort, {
|
|
141
|
+
once: true
|
|
142
|
+
});
|
|
121
143
|
try {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const cost = end();
|
|
127
|
-
context.ssrContext?.onTiming?.(constants_namespaceObject.LOADER_REPORTER_NAME, cost);
|
|
128
|
-
}
|
|
129
|
-
const serverLoadResult = serverRouter._serverResult;
|
|
130
|
-
if (!serverLoadResult) {
|
|
144
|
+
rawRequest.signal.throwIfAborted();
|
|
145
|
+
await (0, external_ssrManagedTags_js_namespaceObject.attachServerSsrUtils)(serverRouter);
|
|
146
|
+
rawRequest.signal.throwIfAborted();
|
|
147
|
+
const end = (0, time_namespaceObject.time)();
|
|
131
148
|
try {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (isRSCNavigation) await (0, external_ssrManagedTags_js_namespaceObject.waitForRouterSerialization)(serverRouter);
|
|
156
|
-
(0, payloadStorage_js_namespaceObject.setTanstackRscServerPayload)((0, payloadRouter_js_namespaceObject.createTanstackRscServerPayload)(serverRouter, {
|
|
149
|
+
await tanstackRouter.load({
|
|
150
|
+
sync: true
|
|
151
|
+
});
|
|
152
|
+
} finally{
|
|
153
|
+
const cost = end();
|
|
154
|
+
context.ssrContext?.onTiming?.(constants_namespaceObject.LOADER_REPORTER_NAME, cost);
|
|
155
|
+
}
|
|
156
|
+
rawRequest.signal.throwIfAborted();
|
|
157
|
+
const serverLoadResult = serverRouter._serverResult;
|
|
158
|
+
if (!serverLoadResult) throw new Error('TanStack Router completed an SSR load without a server result.');
|
|
159
|
+
if ('redirect' === serverLoadResult.type) {
|
|
160
|
+
const { redirect } = serverLoadResult;
|
|
161
|
+
return interrupt(isRSCNavigation ? (0, payloadRouter_js_namespaceObject.handleTanstackRscRedirect)(redirect.headers, _basename, redirect.status) : redirect);
|
|
162
|
+
}
|
|
163
|
+
const routerErrors = (0, external_ssrManagedTags_js_namespaceObject.collectRouterErrors)(tanstackRouter);
|
|
164
|
+
if (routerErrors && 'clientRender' === loaderFailureMode) {
|
|
165
|
+
context.ssrContext?.response?.status(200);
|
|
166
|
+
throw Object.values(routerErrors)[0];
|
|
167
|
+
}
|
|
168
|
+
await (0, external_ssrPreload_js_namespaceObject.preloadMatchedRouteComponents)(serverRouter);
|
|
169
|
+
context.ssrContext?.response?.status(serverLoadResult.status);
|
|
170
|
+
await serverRouter.serverSsr?.dehydrate();
|
|
171
|
+
if (enableRsc) (0, payloadStorage_js_namespaceObject.setTanstackRscServerPayload)((0, payloadRouter_js_namespaceObject.createTanstackRscServerPayload)(serverRouter, {
|
|
157
172
|
omitClientLoaderData: isRSCNavigation
|
|
158
173
|
}));
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
statusCode: serverLoadResult.status,
|
|
167
|
-
errors: routerErrors,
|
|
168
|
-
matchedRouteIds,
|
|
169
|
-
hydrationScripts
|
|
170
|
-
});
|
|
171
|
-
const runtimeContext = (0, external_lifecycle_js_namespaceObject.applyRouterServerPrepareResult)(context, {
|
|
172
|
-
snapshot: routerServerSnapshot,
|
|
173
|
-
cleanup: ()=>serverRouter.serverSsr?.cleanup?.(),
|
|
174
|
-
state: {
|
|
174
|
+
const initialScriptTags = serverRouter.serverSsr?.takeInitialHydrationScriptTags();
|
|
175
|
+
const hydrationScripts = initialScriptTags ? (0, external_ssrManagedTags_js_namespaceObject.routerManagedTagsToHtml)([
|
|
176
|
+
...initialScriptTags.before,
|
|
177
|
+
initialScriptTags.boundary
|
|
178
|
+
]) : [];
|
|
179
|
+
const matchedRouteIds = (0, index_js_namespaceObject.getModernRouteIdsFromMatches)(serverRouter);
|
|
180
|
+
const routerServerSnapshot = {
|
|
175
181
|
framework: 'tanstack',
|
|
176
182
|
basename: _basename,
|
|
177
|
-
|
|
178
|
-
|
|
183
|
+
statusCode: serverLoadResult.status,
|
|
184
|
+
errors: routerErrors,
|
|
179
185
|
matchedRouteIds,
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
hydrationScripts
|
|
187
|
+
};
|
|
188
|
+
const runtimeContext = (0, external_lifecycle_js_namespaceObject.applyRouterServerPrepareResult)(context, {
|
|
189
|
+
snapshot: routerServerSnapshot,
|
|
190
|
+
cleanup,
|
|
191
|
+
state: {
|
|
192
|
+
framework: 'tanstack',
|
|
193
|
+
basename: _basename,
|
|
194
|
+
instance: serverRouter,
|
|
195
|
+
navigation: (0, external_navigation_js_namespaceObject.createTanstackNavigation)(tanstackRouter)
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
rawRequest.signal.throwIfAborted();
|
|
199
|
+
hooks.onAfterCreateRouter.call({
|
|
200
|
+
...routerLifecycleContext,
|
|
201
|
+
router: serverRouter,
|
|
202
|
+
serverSnapshot: (0, external_lifecycle_js_namespaceObject.getRouterServerSnapshot)(runtimeContext),
|
|
203
|
+
runtimeContext
|
|
204
|
+
});
|
|
205
|
+
prepared = true;
|
|
206
|
+
} finally{
|
|
207
|
+
if (!prepared) try {
|
|
208
|
+
cleanup();
|
|
209
|
+
} catch {}
|
|
210
|
+
}
|
|
189
211
|
});
|
|
190
212
|
api.wrapRoot((App)=>{
|
|
191
213
|
const getRouteApp = ()=>{
|
|
@@ -32,19 +32,14 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
32
32
|
NavLink: ()=>NavLink
|
|
33
33
|
});
|
|
34
34
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
35
|
+
const runtime_extensions_namespaceObject = require("@modern-js/runtime-extensions");
|
|
35
36
|
const react_router_namespaceObject = require("@tanstack/react-router");
|
|
36
|
-
function resolvePreloadFromPrefetch(prefetch, preload) {
|
|
37
|
-
if (void 0 !== preload) return preload;
|
|
38
|
-
if ('none' === prefetch) return false;
|
|
39
|
-
if ('intent' === prefetch || 'render' === prefetch || 'viewport' === prefetch) return prefetch;
|
|
40
|
-
return 'viewport';
|
|
41
|
-
}
|
|
42
37
|
const LinkComponentImpl = (props)=>{
|
|
43
38
|
const { prefetch, preload, 'aria-current': ariaCurrentProp, ref, children, ...rest } = props;
|
|
44
39
|
const hasAriaCurrentOverride = 'aria-current' in props;
|
|
45
40
|
const linkOptions = {
|
|
46
41
|
...rest,
|
|
47
|
-
preload: resolvePreloadFromPrefetch(prefetch, preload)
|
|
42
|
+
preload: (0, runtime_extensions_namespaceObject.resolvePreloadFromPrefetch)(prefetch, preload)
|
|
48
43
|
};
|
|
49
44
|
const linkProps = (0, react_router_namespaceObject.useLinkProps)(linkOptions, ref);
|
|
50
45
|
const { disabled: _disabled, type: _type, ...anchorProps } = linkProps;
|
|
@@ -30,10 +30,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
tanstackRouterProviderFactory: ()=>tanstackRouterProviderFactory
|
|
32
32
|
});
|
|
33
|
-
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
34
33
|
const external_plugin_js_namespaceObject = require("./plugin.js");
|
|
35
34
|
const tanstackRouterProviderFactory = (userConfig)=>(0, external_plugin_js_namespaceObject.tanstackRouterPlugin)(userConfig);
|
|
36
|
-
(0, context_namespaceObject.registerRouterProvider)('tanstack', tanstackRouterProviderFactory);
|
|
37
35
|
exports.tanstackRouterProviderFactory = __webpack_exports__.tanstackRouterProviderFactory;
|
|
38
36
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
39
37
|
"tanstackRouterProviderFactory"
|
|
@@ -33,23 +33,20 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
33
33
|
});
|
|
34
34
|
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
35
35
|
const react_router_namespaceObject = require("@tanstack/react-router");
|
|
36
|
+
const routeDescriptor_js_namespaceObject = require("../../shared/routeDescriptor.js");
|
|
36
37
|
const routeStaticData_js_namespaceObject = require("../../shared/routeStaticData.js");
|
|
37
38
|
const external_outlet_js_namespaceObject = require("../outlet.js");
|
|
38
39
|
const external_components_js_namespaceObject = require("./components.js");
|
|
39
40
|
const external_loaders_js_namespaceObject = require("./loaders.js");
|
|
40
|
-
const external_paths_js_namespaceObject = require("./paths.js");
|
|
41
41
|
const external_staticData_js_namespaceObject = require("./staticData.js");
|
|
42
42
|
const external_tanstackRoutes_js_namespaceObject = require("./tanstackRoutes.js");
|
|
43
|
-
function
|
|
44
|
-
const { options = {}, parent, pathlessFallbackId = 'pathless', routeObject } = opts;
|
|
43
|
+
function createRouteOptions(routeObject, options) {
|
|
45
44
|
const modernRouteObject = routeObject;
|
|
46
45
|
const revalidationState = {};
|
|
47
46
|
const shouldRevalidate = modernRouteObject.shouldRevalidate;
|
|
48
47
|
const shouldReload = (0, external_loaders_js_namespaceObject.createModernShouldReload)(shouldRevalidate, revalidationState);
|
|
49
|
-
const stableFallbackId = routeObject.id || modernRouteObject.file || pathlessFallbackId;
|
|
50
48
|
const component = (0, external_components_js_namespaceObject.toRouteComponent)(routeObject);
|
|
51
49
|
const base = {
|
|
52
|
-
getParentRoute: ()=>parent,
|
|
53
50
|
component,
|
|
54
51
|
pendingComponent: (0, external_components_js_namespaceObject.toPendingComponent)(routeObject),
|
|
55
52
|
errorComponent: (0, external_components_js_namespaceObject.toErrorComponent)(routeObject),
|
|
@@ -70,66 +67,29 @@ function createRouteFromRouteObject(opts) {
|
|
|
70
67
|
};
|
|
71
68
|
if (modernRouteObject.inValidSSRRoute) base.ssr = false;
|
|
72
69
|
if (shouldReload) base.shouldReload = shouldReload;
|
|
73
|
-
|
|
74
|
-
else base.path = routeObject.index ? '/' : (0, external_paths_js_namespaceObject.toTanstackPath)(routeObject.path || '');
|
|
75
|
-
const route = (0, external_tanstackRoutes_js_namespaceObject.createTanstackRoute)(base);
|
|
76
|
-
(0, external_tanstackRoutes_js_namespaceObject.wrapRouteComponentWithModernContext)(route, component, routeObject.id);
|
|
77
|
-
const children = routeObject.children;
|
|
78
|
-
if (children && children.length > 0) {
|
|
79
|
-
const childRoutes = children.map((child, index)=>createRouteFromRouteObject({
|
|
80
|
-
options,
|
|
81
|
-
parent: route,
|
|
82
|
-
pathlessFallbackId: `pathless-${index}`,
|
|
83
|
-
routeObject: child
|
|
84
|
-
}));
|
|
85
|
-
route.addChildren(childRoutes);
|
|
86
|
-
}
|
|
87
|
-
return route;
|
|
70
|
+
return base;
|
|
88
71
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
72
|
+
function createRouteFromDescriptor(descriptor, parent, options) {
|
|
73
|
+
const { source, location, children } = descriptor;
|
|
74
|
+
const routeOptions = createRouteOptions(source, options);
|
|
75
|
+
const route = (0, external_tanstackRoutes_js_namespaceObject.createTanstackRoute)({
|
|
76
|
+
...routeOptions,
|
|
77
|
+
...location,
|
|
78
|
+
getParentRoute: ()=>parent
|
|
79
|
+
});
|
|
80
|
+
(0, external_tanstackRoutes_js_namespaceObject.wrapRouteComponentWithModernContext)(route, routeOptions.component, source.id);
|
|
81
|
+
if (children.length) route.addChildren(children.map((child)=>createRouteFromDescriptor(child, route, options)));
|
|
82
|
+
return route;
|
|
91
83
|
}
|
|
92
84
|
function createRouteTreeFromRouteObjects(routes, options = {}) {
|
|
93
|
-
const
|
|
94
|
-
const rootRevalidationState = {};
|
|
95
|
-
const rootShouldRevalidate = rootLikeRoute?.shouldRevalidate;
|
|
96
|
-
const rootShouldReload = (0, external_loaders_js_namespaceObject.createModernShouldReload)(rootShouldRevalidate, rootRevalidationState);
|
|
97
|
-
const rootComponent = rootLikeRoute ? (0, external_components_js_namespaceObject.toRouteComponent)(rootLikeRoute) : void 0;
|
|
85
|
+
const { root, children } = (0, routeDescriptor_js_namespaceObject.describeRouteTree)(routes);
|
|
98
86
|
const rootRouteOptions = {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
errorComponent: rootLikeRoute ? (0, external_components_js_namespaceObject.toErrorComponent)(rootLikeRoute) : void 0,
|
|
102
|
-
validateSearch: rootLikeRoute?.validateSearch,
|
|
103
|
-
loaderDeps: rootLikeRoute?.loaderDeps,
|
|
104
|
-
notFoundComponent: context_namespaceObject.DefaultNotFound,
|
|
105
|
-
staticData: (0, routeStaticData_js_namespaceObject.createRouteStaticData)({
|
|
106
|
-
modernRouteId: rootLikeRoute?.id,
|
|
107
|
-
modernRouteAction: rootLikeRoute?.action,
|
|
108
|
-
modernRouteHandle: rootLikeRoute ? (0, external_staticData_js_namespaceObject.mergeModernRouteHandle)(rootLikeRoute) : void 0,
|
|
109
|
-
modernRouteHasAction: rootLikeRoute?.hasAction || Boolean(rootLikeRoute?.action),
|
|
110
|
-
modernRouteHasClientLoader: rootLikeRoute?.hasClientLoader || void 0 !== rootLikeRoute?.clientData,
|
|
111
|
-
modernRouteHasLoader: rootLikeRoute?.hasLoader || 'function' == typeof rootLikeRoute?.loader,
|
|
112
|
-
modernRouteIsClientComponent: rootLikeRoute?.isClientComponent,
|
|
113
|
-
modernRouteLoader: rootLikeRoute?.loader,
|
|
114
|
-
modernRouteShouldRevalidate: rootShouldRevalidate
|
|
115
|
-
}),
|
|
116
|
-
loader: rootLikeRoute ? (0, external_loaders_js_namespaceObject.wrapRouteObjectLoader)(rootLikeRoute, rootRevalidationState, options) : void 0
|
|
87
|
+
...root ? createRouteOptions(root, options) : {},
|
|
88
|
+
notFoundComponent: context_namespaceObject.DefaultNotFound
|
|
117
89
|
};
|
|
118
|
-
if (rootShouldReload) rootRouteOptions.shouldReload = rootShouldReload;
|
|
119
|
-
if (rootLikeRoute?.inValidSSRRoute) rootRouteOptions.ssr = false;
|
|
120
90
|
const rootRoute = (0, external_tanstackRoutes_js_namespaceObject.createTanstackRootRoute)(rootRouteOptions);
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
...rootLikeRoute.children || [],
|
|
124
|
-
...routes.filter((route)=>route !== rootLikeRoute)
|
|
125
|
-
] : routes;
|
|
126
|
-
const childRoutes = topLevel.map((routeObject, index)=>createRouteFromRouteObject({
|
|
127
|
-
options,
|
|
128
|
-
parent: rootRoute,
|
|
129
|
-
pathlessFallbackId: `pathless-${index}`,
|
|
130
|
-
routeObject
|
|
131
|
-
}));
|
|
132
|
-
rootRoute.addChildren(childRoutes);
|
|
91
|
+
if (rootRouteOptions.component) rootRoute.options.component = (0, external_outlet_js_namespaceObject.withModernRouteMatchContext)(rootRouteOptions.component, react_router_namespaceObject.rootRouteId);
|
|
92
|
+
rootRoute.addChildren(children.map((child)=>createRouteFromDescriptor(child, rootRoute, options)));
|
|
133
93
|
return rootRoute;
|
|
134
94
|
}
|
|
135
95
|
function getModernRouteIdsFromMatches(router) {
|
|
@@ -82,7 +82,7 @@ function wrapRouteObjectLoader(route, revalidationState, options = {}) {
|
|
|
82
82
|
if ('function' == typeof modernRoute.lazyImport) try {
|
|
83
83
|
await modernRoute.lazyImport();
|
|
84
84
|
} catch {}
|
|
85
|
-
const signal =
|
|
85
|
+
const signal = (0, external_loaderBridge_js_namespaceObject.getLoaderSignal)(ctx);
|
|
86
86
|
const baseRequest = ctx?.context?.request instanceof Request ? ctx.context.request : void 0;
|
|
87
87
|
const href = (0, external_loaderBridge_js_namespaceObject.getLoaderHref)(ctx);
|
|
88
88
|
const request = void 0 !== baseRequest ? new Request(baseRequest, {
|
|
@@ -39,17 +39,11 @@ function toTanstackPath(pathname) {
|
|
|
39
39
|
return segment;
|
|
40
40
|
}).join('/');
|
|
41
41
|
}
|
|
42
|
-
function isRouteObjectPathlessLayout(route) {
|
|
43
|
-
return !route.path && !route.index;
|
|
44
|
-
}
|
|
45
42
|
__webpack_require__.d(__webpack_exports__, {
|
|
46
|
-
isRouteObjectPathlessLayout: ()=>isRouteObjectPathlessLayout,
|
|
47
43
|
toTanstackPath: ()=>toTanstackPath
|
|
48
44
|
});
|
|
49
|
-
exports.isRouteObjectPathlessLayout = __webpack_exports__.isRouteObjectPathlessLayout;
|
|
50
45
|
exports.toTanstackPath = __webpack_exports__.toTanstackPath;
|
|
51
46
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
52
|
-
"isRouteObjectPathlessLayout",
|
|
53
47
|
"toTanstackPath"
|
|
54
48
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
55
49
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -30,21 +30,37 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
routerPlugin: ()=>routerPlugin
|
|
32
32
|
});
|
|
33
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
33
34
|
const internal_namespaceObject = require("@modern-js/runtime/router/internal");
|
|
35
|
+
const router_provider_namespaceObject = require("@modern-js/runtime-extensions/router-provider");
|
|
36
|
+
const router_state_plugin_namespaceObject = require("@modern-js/runtime-extensions/router-state-plugin");
|
|
34
37
|
const external_register_js_namespaceObject = require("./register.js");
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
const createProviderPlugin = (0, router_provider_namespaceObject.createRouterPlugin)({
|
|
39
|
+
defaultProvider: {
|
|
40
|
+
name: 'react-router',
|
|
41
|
+
factory: internal_namespaceObject.routerPlugin
|
|
42
|
+
},
|
|
43
|
+
registryHooks: context_namespaceObject.routerProviderRegistryHooks,
|
|
44
|
+
localProviders: [
|
|
38
45
|
{
|
|
39
46
|
name: 'tanstack',
|
|
40
47
|
factory: external_register_js_namespaceObject.tanstackRouterProviderFactory
|
|
41
48
|
}
|
|
42
|
-
]
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
const routerPlugin =
|
|
49
|
+
]
|
|
50
|
+
});
|
|
51
|
+
const statePlugin = (0, router_state_plugin_namespaceObject.createRouterStatePlugin)({
|
|
52
|
+
registryHooks: context_namespaceObject.routerProviderRegistryHooks
|
|
53
|
+
});
|
|
54
|
+
const routerPlugin = (userConfig = {})=>{
|
|
55
|
+
const providerPlugin = createProviderPlugin(userConfig);
|
|
56
|
+
return {
|
|
57
|
+
...providerPlugin,
|
|
58
|
+
setup (api) {
|
|
59
|
+
statePlugin.setup(api);
|
|
60
|
+
providerPlugin.setup(api);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
};
|
|
48
64
|
exports.routerPlugin = __webpack_exports__.routerPlugin;
|
|
49
65
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
50
66
|
"routerPlugin"
|
|
@@ -27,13 +27,6 @@ var __webpack_require__ = {};
|
|
|
27
27
|
})();
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
|
-
async function waitForRouterSerialization(tanstackRouter) {
|
|
31
|
-
const serverSsr = tanstackRouter.serverSsr;
|
|
32
|
-
if (!serverSsr || 'function' != typeof serverSsr.onSerializationFinished || serverSsr.isSerializationFinished?.()) return;
|
|
33
|
-
await new Promise((resolve)=>{
|
|
34
|
-
serverSsr.onSerializationFinished?.(resolve);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
30
|
function htmlEscapeAttr(value) {
|
|
38
31
|
return value.replace(/&/g, '&').replace(/"/g, '"');
|
|
39
32
|
}
|
|
@@ -83,20 +76,17 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
83
76
|
attachServerSsrUtils: ()=>attachServerSsrUtils,
|
|
84
77
|
collectRouterErrors: ()=>collectRouterErrors,
|
|
85
78
|
createGetSsrHref: ()=>createGetSsrHref,
|
|
86
|
-
routerManagedTagsToHtml: ()=>routerManagedTagsToHtml
|
|
87
|
-
waitForRouterSerialization: ()=>waitForRouterSerialization
|
|
79
|
+
routerManagedTagsToHtml: ()=>routerManagedTagsToHtml
|
|
88
80
|
});
|
|
89
81
|
exports.attachServerSsrUtils = __webpack_exports__.attachServerSsrUtils;
|
|
90
82
|
exports.collectRouterErrors = __webpack_exports__.collectRouterErrors;
|
|
91
83
|
exports.createGetSsrHref = __webpack_exports__.createGetSsrHref;
|
|
92
84
|
exports.routerManagedTagsToHtml = __webpack_exports__.routerManagedTagsToHtml;
|
|
93
|
-
exports.waitForRouterSerialization = __webpack_exports__.waitForRouterSerialization;
|
|
94
85
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
95
86
|
"attachServerSsrUtils",
|
|
96
87
|
"collectRouterErrors",
|
|
97
88
|
"createGetSsrHref",
|
|
98
|
-
"routerManagedTagsToHtml"
|
|
99
|
-
"waitForRouterSerialization"
|
|
89
|
+
"routerManagedTagsToHtml"
|
|
100
90
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
101
91
|
Object.defineProperty(exports, '__esModule', {
|
|
102
92
|
value: true
|
|
@@ -30,9 +30,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
getTanstackRouterState: ()=>getTanstackRouterState
|
|
32
32
|
});
|
|
33
|
-
const
|
|
33
|
+
const router_state_namespaceObject = require("@modern-js/runtime-extensions/router-state");
|
|
34
34
|
function getTanstackRouterState(context) {
|
|
35
|
-
const state = (0,
|
|
35
|
+
const state = (0, router_state_namespaceObject.getRouterRuntimeState)(context);
|
|
36
36
|
if (void 0 === state || 'tanstack' !== state.framework || void 0 === state.instance) return;
|
|
37
37
|
return state;
|
|
38
38
|
}
|
|
@@ -55,6 +55,8 @@ function withGlobalLayout(Component, globalApp) {
|
|
|
55
55
|
}
|
|
56
56
|
function toTanstackRouteObject(route, globalApp) {
|
|
57
57
|
if ('nested' === route.type) return {
|
|
58
|
+
modernLocalisedRoute: Reflect.get(route, 'modernLocalisedRoute'),
|
|
59
|
+
isRoot: Reflect.get(route, 'isRoot'),
|
|
58
60
|
path: route.path,
|
|
59
61
|
id: route.id,
|
|
60
62
|
loader: route.loader,
|
|
@@ -79,6 +81,7 @@ function toTanstackRouteObject(route, globalApp) {
|
|
|
79
81
|
if ('function' != typeof route.component && 'object' != typeof route.component) return null;
|
|
80
82
|
const LayoutComponent = withGlobalLayout(route.component, globalApp);
|
|
81
83
|
return {
|
|
84
|
+
modernLocalisedRoute: Reflect.get(route, 'modernLocalisedRoute'),
|
|
82
85
|
path: route.path,
|
|
83
86
|
element: /*#__PURE__*/ (external_react_default()).createElement(LayoutComponent)
|
|
84
87
|
};
|