@bleedingdev/modern-js-plugin-tanstack 3.2.0-ultramodern.120 → 3.2.0-ultramodern.122
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/index.js +47 -27
- package/dist/cjs/cli/routeSplitting.js +0 -32
- package/dist/cjs/cli/tanstackTypes.js +34 -199
- package/dist/cjs/runtime/hooks.js +11 -14
- package/dist/cjs/runtime/index.js +107 -319
- package/dist/cjs/runtime/lifecycle.js +12 -86
- package/dist/cjs/runtime/loaderBridge.js +173 -0
- package/dist/cjs/runtime/plugin.js +6 -30
- package/dist/cjs/runtime/plugin.node.js +7 -29
- package/dist/cjs/runtime/pluginCore.js +55 -0
- package/dist/cjs/runtime/register.js +56 -0
- package/dist/cjs/runtime/routeTree.js +10 -207
- package/dist/cjs/runtime/{DefaultNotFound.js → router.js} +5 -15
- package/dist/cjs/runtime/rsc/payloadRouter.js +35 -1
- package/dist/cjs/runtime/state.js +45 -0
- package/dist/cjs/runtime/utils.js +0 -5
- package/dist/esm/cli/index.mjs +52 -26
- package/dist/esm/cli/routeSplitting.mjs +1 -30
- package/dist/esm/cli/tanstackTypes.mjs +32 -194
- package/dist/esm/runtime/hooks.mjs +1 -8
- package/dist/esm/runtime/index.mjs +4 -2
- package/dist/esm/runtime/lifecycle.mjs +1 -82
- package/dist/esm/runtime/loaderBridge.mjs +114 -0
- package/dist/esm/runtime/plugin.mjs +8 -32
- package/dist/esm/runtime/plugin.node.mjs +10 -32
- package/dist/esm/runtime/pluginCore.mjs +14 -0
- package/dist/esm/runtime/register.mjs +18 -0
- package/dist/esm/runtime/routeTree.mjs +4 -198
- package/dist/esm/runtime/router.mjs +2 -0
- package/dist/esm/runtime/rsc/payloadRouter.mjs +35 -1
- package/dist/esm/runtime/state.mjs +7 -0
- package/dist/esm/runtime/utils.mjs +0 -5
- package/dist/esm-node/cli/index.mjs +52 -26
- package/dist/esm-node/cli/routeSplitting.mjs +1 -30
- package/dist/esm-node/cli/tanstackTypes.mjs +32 -194
- package/dist/esm-node/runtime/hooks.mjs +1 -8
- package/dist/esm-node/runtime/index.mjs +4 -2
- package/dist/esm-node/runtime/lifecycle.mjs +1 -82
- package/dist/esm-node/runtime/loaderBridge.mjs +115 -0
- package/dist/esm-node/runtime/plugin.mjs +8 -32
- package/dist/esm-node/runtime/plugin.node.mjs +10 -32
- package/dist/esm-node/runtime/pluginCore.mjs +15 -0
- package/dist/esm-node/runtime/register.mjs +19 -0
- package/dist/esm-node/runtime/routeTree.mjs +4 -198
- package/dist/esm-node/runtime/router.mjs +3 -0
- package/dist/esm-node/runtime/rsc/payloadRouter.mjs +35 -1
- package/dist/esm-node/runtime/state.mjs +8 -0
- package/dist/esm-node/runtime/utils.mjs +0 -5
- package/dist/types/cli/index.d.ts +9 -2
- package/dist/types/cli/routeSplitting.d.ts +6 -15
- package/dist/types/cli/tanstackTypes.d.ts +13 -2
- package/dist/types/runtime/hooks.d.ts +8 -18
- package/dist/types/runtime/index.d.ts +6 -4
- package/dist/types/runtime/lifecycle.d.ts +7 -22
- package/dist/types/runtime/loaderBridge.d.ts +48 -0
- package/dist/types/runtime/plugin.d.ts +1 -14
- package/dist/types/runtime/plugin.node.d.ts +1 -14
- package/dist/types/runtime/pluginCore.d.ts +21 -0
- package/dist/types/runtime/register.d.ts +9 -0
- package/dist/types/runtime/routeTree.d.ts +0 -2
- package/dist/types/runtime/router.d.ts +14 -0
- package/dist/types/runtime/state.d.ts +16 -0
- package/dist/types/runtime/types.d.ts +7 -53
- package/package.json +31 -29
- package/rstest.config.mts +6 -0
- package/src/cli/index.ts +111 -29
- package/src/cli/routeSplitting.ts +6 -44
- package/src/cli/tanstackTypes.ts +78 -214
- package/src/runtime/hooks.ts +10 -27
- package/src/runtime/index.tsx +12 -107
- package/src/runtime/lifecycle.ts +16 -151
- package/src/runtime/loaderBridge.ts +257 -0
- package/src/runtime/plugin.node.tsx +14 -77
- package/src/runtime/plugin.tsx +12 -72
- package/src/runtime/pluginCore.ts +48 -0
- package/src/runtime/register.ts +58 -0
- package/src/runtime/routeTree.ts +8 -370
- package/src/runtime/router.ts +15 -0
- package/src/runtime/rsc/payloadRouter.ts +45 -2
- package/src/runtime/state.ts +29 -0
- package/src/runtime/types.ts +20 -67
- package/src/runtime/utils.tsx +3 -6
- package/tests/router/cli.test.ts +297 -31
- package/tests/router/hooks.test.ts +26 -0
- package/tests/router/loaderBridge.test.ts +211 -0
- package/tests/router/packageSurface.test.ts +24 -0
- package/tests/router/register.test.ts +46 -0
- package/tests/router/routeTree.test.ts +65 -180
- package/tests/router/rsc.test.tsx +70 -0
- package/tests/router/tanstackTypes.test.ts +164 -6
- package/dist/esm/runtime/DefaultNotFound.mjs +0 -13
- package/dist/esm-node/runtime/DefaultNotFound.mjs +0 -14
- package/dist/types/runtime/DefaultNotFound.d.ts +0 -2
- package/src/runtime/DefaultNotFound.tsx +0 -15
|
@@ -0,0 +1,173 @@
|
|
|
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
|
+
createRouteStaticData: ()=>createRouteStaticData,
|
|
32
|
+
isAbsoluteUrl: ()=>isAbsoluteUrl,
|
|
33
|
+
isRedirectResponse: ()=>isRedirectResponse,
|
|
34
|
+
isResponse: ()=>isResponse,
|
|
35
|
+
isTanstackRedirect: ()=>isTanstackRedirect,
|
|
36
|
+
mapSplatParamsForModernLoader: ()=>mapSplatParamsForModernLoader,
|
|
37
|
+
modernLoaderToTanstack: ()=>modernLoaderToTanstack,
|
|
38
|
+
throwTanstackRedirect: ()=>throwTanstackRedirect
|
|
39
|
+
});
|
|
40
|
+
const react_router_namespaceObject = require("@tanstack/react-router");
|
|
41
|
+
function isResponse(value) {
|
|
42
|
+
const record = value;
|
|
43
|
+
return null != record && 'object' == typeof record && 'number' == typeof record.status && 'object' == typeof record.headers;
|
|
44
|
+
}
|
|
45
|
+
const redirectStatusCodes = new Set([
|
|
46
|
+
301,
|
|
47
|
+
302,
|
|
48
|
+
303,
|
|
49
|
+
307,
|
|
50
|
+
308
|
|
51
|
+
]);
|
|
52
|
+
function isRedirectResponse(res) {
|
|
53
|
+
return redirectStatusCodes.has(res.status);
|
|
54
|
+
}
|
|
55
|
+
function isTanstackRedirect(value) {
|
|
56
|
+
return isResponse(value) && 'object' == typeof value.options;
|
|
57
|
+
}
|
|
58
|
+
function isAbsoluteUrl(value) {
|
|
59
|
+
try {
|
|
60
|
+
new URL(value);
|
|
61
|
+
return true;
|
|
62
|
+
} catch {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function throwTanstackRedirect(location) {
|
|
67
|
+
const target = location || '/';
|
|
68
|
+
if (isAbsoluteUrl(target)) throw (0, react_router_namespaceObject.redirect)({
|
|
69
|
+
href: target
|
|
70
|
+
});
|
|
71
|
+
throw (0, react_router_namespaceObject.redirect)({
|
|
72
|
+
to: target
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function mapSplatParamsForModernLoader(params, hasSplat) {
|
|
76
|
+
if (!hasSplat) return params;
|
|
77
|
+
const { _splat, ...rest } = params;
|
|
78
|
+
if (void 0 !== _splat) return {
|
|
79
|
+
...rest,
|
|
80
|
+
'*': _splat
|
|
81
|
+
};
|
|
82
|
+
return rest;
|
|
83
|
+
}
|
|
84
|
+
function createRouteStaticData(opts) {
|
|
85
|
+
const staticData = {};
|
|
86
|
+
if ('string' == typeof opts.modernRouteId && opts.modernRouteId.length > 0) staticData.modernRouteId = opts.modernRouteId;
|
|
87
|
+
if (void 0 !== opts.modernRouteLoader) staticData.modernRouteLoader = opts.modernRouteLoader;
|
|
88
|
+
if (void 0 !== opts.modernRouteAction) staticData.modernRouteAction = opts.modernRouteAction;
|
|
89
|
+
return staticData;
|
|
90
|
+
}
|
|
91
|
+
function getLoaderSignal(ctx) {
|
|
92
|
+
const abortSignal = ctx?.abortController?.signal;
|
|
93
|
+
if (abortSignal instanceof AbortSignal) return abortSignal;
|
|
94
|
+
if (ctx?.signal instanceof AbortSignal) return ctx.signal;
|
|
95
|
+
return new AbortController().signal;
|
|
96
|
+
}
|
|
97
|
+
function getLoaderHref(ctx) {
|
|
98
|
+
if ('string' == typeof ctx?.location) return ctx.location;
|
|
99
|
+
const publicHref = ctx?.location?.publicHref;
|
|
100
|
+
if ('string' == typeof publicHref) return publicHref;
|
|
101
|
+
const href = ctx?.location?.href;
|
|
102
|
+
if ('string' == typeof href) return href;
|
|
103
|
+
const urlHref = ctx?.location?.url?.href;
|
|
104
|
+
return 'string' == typeof urlHref ? urlHref : '';
|
|
105
|
+
}
|
|
106
|
+
function getLoaderParams(ctx) {
|
|
107
|
+
return 'object' == typeof ctx?.params && null !== ctx.params ? ctx.params : {};
|
|
108
|
+
}
|
|
109
|
+
function handleModernLoaderResult(result) {
|
|
110
|
+
if (isResponse(result)) {
|
|
111
|
+
if (isRedirectResponse(result)) {
|
|
112
|
+
const location = result.headers.get('Location') ?? '/';
|
|
113
|
+
throwTanstackRedirect(location);
|
|
114
|
+
}
|
|
115
|
+
if (404 === result.status) throw (0, react_router_namespaceObject.notFound)();
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
function handleModernLoaderError(err) {
|
|
120
|
+
if (isResponse(err)) {
|
|
121
|
+
if (isTanstackRedirect(err)) throw err;
|
|
122
|
+
if (isRedirectResponse(err)) {
|
|
123
|
+
const location = err.headers.get('Location') ?? '/';
|
|
124
|
+
throwTanstackRedirect(location);
|
|
125
|
+
}
|
|
126
|
+
if (404 === err.status) throw (0, react_router_namespaceObject.notFound)();
|
|
127
|
+
}
|
|
128
|
+
throw err;
|
|
129
|
+
}
|
|
130
|
+
function modernLoaderToTanstack(opts, modernLoader) {
|
|
131
|
+
return (rawCtx)=>{
|
|
132
|
+
const ctx = rawCtx;
|
|
133
|
+
try {
|
|
134
|
+
const signal = getLoaderSignal(ctx);
|
|
135
|
+
const baseRequest = ctx?.context?.request instanceof Request ? ctx.context.request : void 0;
|
|
136
|
+
const href = getLoaderHref(ctx);
|
|
137
|
+
const request = void 0 !== baseRequest ? new Request(baseRequest, {
|
|
138
|
+
signal
|
|
139
|
+
}) : new Request(href, {
|
|
140
|
+
signal
|
|
141
|
+
});
|
|
142
|
+
const params = mapSplatParamsForModernLoader(getLoaderParams(ctx), opts.hasSplat);
|
|
143
|
+
return Promise.resolve(modernLoader({
|
|
144
|
+
request,
|
|
145
|
+
params,
|
|
146
|
+
context: ctx?.context?.requestContext
|
|
147
|
+
})).then((result)=>handleModernLoaderResult(result)).catch(handleModernLoaderError);
|
|
148
|
+
} catch (err) {
|
|
149
|
+
handleModernLoaderError(err);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
exports.createRouteStaticData = __webpack_exports__.createRouteStaticData;
|
|
154
|
+
exports.isAbsoluteUrl = __webpack_exports__.isAbsoluteUrl;
|
|
155
|
+
exports.isRedirectResponse = __webpack_exports__.isRedirectResponse;
|
|
156
|
+
exports.isResponse = __webpack_exports__.isResponse;
|
|
157
|
+
exports.isTanstackRedirect = __webpack_exports__.isTanstackRedirect;
|
|
158
|
+
exports.mapSplatParamsForModernLoader = __webpack_exports__.mapSplatParamsForModernLoader;
|
|
159
|
+
exports.modernLoaderToTanstack = __webpack_exports__.modernLoaderToTanstack;
|
|
160
|
+
exports.throwTanstackRedirect = __webpack_exports__.throwTanstackRedirect;
|
|
161
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
162
|
+
"createRouteStaticData",
|
|
163
|
+
"isAbsoluteUrl",
|
|
164
|
+
"isRedirectResponse",
|
|
165
|
+
"isResponse",
|
|
166
|
+
"isTanstackRedirect",
|
|
167
|
+
"mapSplatParamsForModernLoader",
|
|
168
|
+
"modernLoaderToTanstack",
|
|
169
|
+
"throwTanstackRedirect"
|
|
170
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
171
|
+
Object.defineProperty(exports, '__esModule', {
|
|
172
|
+
value: true
|
|
173
|
+
});
|
|
@@ -33,7 +33,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
33
33
|
});
|
|
34
34
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
35
35
|
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
36
|
-
const merge_namespaceObject = require("@modern-js/runtime-utils/merge");
|
|
37
36
|
const url_namespaceObject = require("@modern-js/runtime-utils/url");
|
|
38
37
|
const react_router_namespaceObject = require("@tanstack/react-router");
|
|
39
38
|
const client_namespaceObject = require("@tanstack/react-router/ssr/client");
|
|
@@ -43,6 +42,7 @@ const external_hooks_js_namespaceObject = require("./hooks.js");
|
|
|
43
42
|
const external_hydrationBoundary_js_namespaceObject = require("./hydrationBoundary.js");
|
|
44
43
|
const external_lifecycle_js_namespaceObject = require("./lifecycle.js");
|
|
45
44
|
const external_outlet_js_namespaceObject = require("./outlet.js");
|
|
45
|
+
const external_pluginCore_js_namespaceObject = require("./pluginCore.js");
|
|
46
46
|
const external_prefetchLink_js_namespaceObject = require("./prefetchLink.js");
|
|
47
47
|
const external_routeTree_js_namespaceObject = require("./routeTree.js");
|
|
48
48
|
const client_js_namespaceObject = require("./rsc/client.js");
|
|
@@ -151,50 +151,26 @@ function ModernRouterClient({ router }) {
|
|
|
151
151
|
router: router
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
|
-
function stripSyntheticNotFoundRoute(routes) {
|
|
155
|
-
return routes.filter((route)=>!('*' === route.path && !route.id && !route.loader)).map((route)=>{
|
|
156
|
-
if (!route.children?.length) return route;
|
|
157
|
-
return {
|
|
158
|
-
...route,
|
|
159
|
-
children: stripSyntheticNotFoundRoute(route.children)
|
|
160
|
-
};
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
154
|
const tanstackRouterPlugin = (userConfig = {})=>{
|
|
164
155
|
const plugin = {
|
|
165
156
|
name: '@modern-js/plugin-router-tanstack',
|
|
166
|
-
registryHooks:
|
|
167
|
-
modifyRoutes: external_hooks_js_namespaceObject.modifyRoutes,
|
|
168
|
-
onAfterCreateRouter: external_hooks_js_namespaceObject.onAfterCreateRouter,
|
|
169
|
-
onAfterHydrateRouter: external_hooks_js_namespaceObject.onAfterHydrateRouter,
|
|
170
|
-
onBeforeCreateRouter: external_hooks_js_namespaceObject.onBeforeCreateRouter,
|
|
171
|
-
onBeforeCreateRoutes: external_hooks_js_namespaceObject.onBeforeCreateRoutes,
|
|
172
|
-
onBeforeHydrateRouter: external_hooks_js_namespaceObject.onBeforeHydrateRouter
|
|
173
|
-
},
|
|
157
|
+
registryHooks: external_hooks_js_namespaceObject.routerProviderRegistryHooks,
|
|
174
158
|
setup: (api)=>{
|
|
175
159
|
const hooks = api.getHooks();
|
|
176
160
|
let cachedRouteObjects;
|
|
177
161
|
let cachedRouteTree = null;
|
|
178
162
|
let cachedRouter = null;
|
|
179
163
|
let cachedRouterBasepath = null;
|
|
180
|
-
const getMergedConfig = ()=>
|
|
181
|
-
const pluginConfig = api.getRuntimeConfig();
|
|
182
|
-
return (0, merge_namespaceObject.merge)(pluginConfig.router || {}, userConfig);
|
|
183
|
-
};
|
|
164
|
+
const getMergedConfig = ()=>(0, external_pluginCore_js_namespaceObject.getMergedRouterConfig)(api, userConfig);
|
|
184
165
|
const getRouteObjects = ()=>{
|
|
185
166
|
if (void 0 !== cachedRouteObjects) return cachedRouteObjects;
|
|
186
167
|
const mergedConfig = getMergedConfig();
|
|
187
|
-
const {
|
|
188
|
-
const finalRouteConfig =
|
|
189
|
-
routes: (0, context_namespaceObject.getGlobalRoutes)(),
|
|
190
|
-
globalApp: (0, context_namespaceObject.getGlobalLayoutApp)(),
|
|
191
|
-
...routesConfig
|
|
192
|
-
};
|
|
168
|
+
const { createRoutes } = mergedConfig;
|
|
169
|
+
const finalRouteConfig = (0, external_pluginCore_js_namespaceObject.getFinalRouteConfig)(mergedConfig);
|
|
193
170
|
const routeObjects = createRoutes ? createRoutes() : (0, external_utils_js_namespaceObject.createRouteObjectsFromConfig)({
|
|
194
171
|
routesConfig: finalRouteConfig
|
|
195
172
|
}) || [];
|
|
196
|
-
|
|
197
|
-
cachedRouteObjects = hooks.modifyRoutes.call(normalizedRouteObjects);
|
|
173
|
+
cachedRouteObjects = hooks.modifyRoutes.call(routeObjects);
|
|
198
174
|
return cachedRouteObjects;
|
|
199
175
|
};
|
|
200
176
|
const getRouteTree = ()=>{
|
|
@@ -33,7 +33,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
33
33
|
});
|
|
34
34
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
35
35
|
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
36
|
-
const merge_namespaceObject = require("@modern-js/runtime-utils/merge");
|
|
37
36
|
const node_namespaceObject = require("@modern-js/runtime-utils/node");
|
|
38
37
|
const time_namespaceObject = require("@modern-js/runtime-utils/time");
|
|
39
38
|
const constants_namespaceObject = require("@modern-js/utils/universal/constants");
|
|
@@ -44,6 +43,7 @@ const external_basepathRewrite_js_namespaceObject = require("./basepathRewrite.j
|
|
|
44
43
|
const external_hooks_js_namespaceObject = require("./hooks.js");
|
|
45
44
|
const external_hydrationBoundary_js_namespaceObject = require("./hydrationBoundary.js");
|
|
46
45
|
const external_lifecycle_js_namespaceObject = require("./lifecycle.js");
|
|
46
|
+
const external_pluginCore_js_namespaceObject = require("./pluginCore.js");
|
|
47
47
|
const external_routeTree_js_namespaceObject = require("./routeTree.js");
|
|
48
48
|
const payloadRouter_js_namespaceObject = require("./rsc/payloadRouter.js");
|
|
49
49
|
const external_types_js_namespaceObject = require("./types.js");
|
|
@@ -128,15 +128,6 @@ function createGetSsrHref(request) {
|
|
|
128
128
|
const url = new URL(request.url);
|
|
129
129
|
return `${url.pathname}${url.search}${url.hash}`;
|
|
130
130
|
}
|
|
131
|
-
function stripSyntheticNotFoundRoute(routes) {
|
|
132
|
-
return routes.filter((route)=>!('*' === route.path && !route.id && !route.loader)).map((route)=>{
|
|
133
|
-
if (!route.children?.length) return route;
|
|
134
|
-
return {
|
|
135
|
-
...route,
|
|
136
|
-
children: stripSyntheticNotFoundRoute(route.children)
|
|
137
|
-
};
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
131
|
function collectRouterErrors(tanstackRouter) {
|
|
141
132
|
const state = tanstackRouter.state;
|
|
142
133
|
const matches = Array.isArray(state.matches) ? state.matches : [];
|
|
@@ -151,26 +142,14 @@ function collectRouterErrors(tanstackRouter) {
|
|
|
151
142
|
const tanstackRouterPlugin = (userConfig = {})=>{
|
|
152
143
|
const plugin = {
|
|
153
144
|
name: '@modern-js/plugin-router-tanstack',
|
|
154
|
-
registryHooks:
|
|
155
|
-
modifyRoutes: external_hooks_js_namespaceObject.modifyRoutes,
|
|
156
|
-
onAfterCreateRouter: external_hooks_js_namespaceObject.onAfterCreateRouter,
|
|
157
|
-
onAfterHydrateRouter: external_hooks_js_namespaceObject.onAfterHydrateRouter,
|
|
158
|
-
onBeforeCreateRouter: external_hooks_js_namespaceObject.onBeforeCreateRouter,
|
|
159
|
-
onBeforeCreateRoutes: external_hooks_js_namespaceObject.onBeforeCreateRoutes,
|
|
160
|
-
onBeforeHydrateRouter: external_hooks_js_namespaceObject.onBeforeHydrateRouter
|
|
161
|
-
},
|
|
145
|
+
registryHooks: external_hooks_js_namespaceObject.routerProviderRegistryHooks,
|
|
162
146
|
setup: (api)=>{
|
|
163
147
|
api.onBeforeRender(async (context, interrupt)=>{
|
|
164
|
-
const
|
|
165
|
-
const mergedConfig = (0, merge_namespaceObject.merge)(pluginConfig.router || {}, userConfig);
|
|
148
|
+
const mergedConfig = (0, external_pluginCore_js_namespaceObject.getMergedRouterConfig)(api, userConfig);
|
|
166
149
|
const serializationAdapters = (0, context_namespaceObject.getGlobalEnableRsc)() ? (await import("./rsc/server.js")).getTanstackRscSerializationAdapters() : void 0;
|
|
167
150
|
const enableRsc = (0, context_namespaceObject.getGlobalEnableRsc)();
|
|
168
|
-
const { basename = '',
|
|
169
|
-
const finalRouteConfig =
|
|
170
|
-
routes: (0, context_namespaceObject.getGlobalRoutes)(),
|
|
171
|
-
globalApp: (0, context_namespaceObject.getGlobalLayoutApp)(),
|
|
172
|
-
...routesConfig
|
|
173
|
-
};
|
|
151
|
+
const { basename = '', createRoutes } = mergedConfig;
|
|
152
|
+
const finalRouteConfig = (0, external_pluginCore_js_namespaceObject.getFinalRouteConfig)(mergedConfig);
|
|
174
153
|
if (!finalRouteConfig.routes && !createRoutes) return;
|
|
175
154
|
const hooks = api.getHooks();
|
|
176
155
|
await hooks.onBeforeCreateRoutes.call(context);
|
|
@@ -178,8 +157,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
178
157
|
routesConfig: finalRouteConfig,
|
|
179
158
|
ssrMode: context.ssrContext?.mode
|
|
180
159
|
}) || [];
|
|
181
|
-
const
|
|
182
|
-
const modifiedRouteObjects = hooks.modifyRoutes.call(normalizedRouteObjects);
|
|
160
|
+
const modifiedRouteObjects = hooks.modifyRoutes.call(routeObjects);
|
|
183
161
|
if (!modifiedRouteObjects.length) return;
|
|
184
162
|
const { request, nonce, baseUrl, loaderFailureMode = 'errorBoundary' } = context.ssrContext;
|
|
185
163
|
const _basename = '/' === baseUrl ? (0, external_utils_js_namespaceObject.urlJoin)(baseUrl, basename || '') : baseUrl;
|
|
@@ -297,7 +275,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
|
|
|
297
275
|
api.wrapRoot((App)=>{
|
|
298
276
|
const getRouteApp = ()=>(props)=>{
|
|
299
277
|
const context = (0, external_react_namespaceObject.useContext)(context_namespaceObject.InternalRuntimeContext);
|
|
300
|
-
const router =
|
|
278
|
+
const router = (0, external_lifecycle_js_namespaceObject.getRouterRuntimeState)(context)?.instance;
|
|
301
279
|
if (!router) return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
|
|
302
280
|
...props
|
|
303
281
|
}) : null;
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
getFinalRouteConfig: ()=>getFinalRouteConfig,
|
|
32
|
+
getMergedRouterConfig: ()=>getMergedRouterConfig
|
|
33
|
+
});
|
|
34
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
35
|
+
const merge_namespaceObject = require("@modern-js/runtime-utils/merge");
|
|
36
|
+
function getMergedRouterConfig(api, userConfig) {
|
|
37
|
+
const pluginConfig = api.getRuntimeConfig();
|
|
38
|
+
return (0, merge_namespaceObject.merge)(pluginConfig.router || {}, userConfig);
|
|
39
|
+
}
|
|
40
|
+
function getFinalRouteConfig(mergedConfig) {
|
|
41
|
+
return {
|
|
42
|
+
routes: (0, context_namespaceObject.getGlobalRoutes)(),
|
|
43
|
+
globalApp: (0, context_namespaceObject.getGlobalLayoutApp)(),
|
|
44
|
+
...mergedConfig.routesConfig
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
exports.getFinalRouteConfig = __webpack_exports__.getFinalRouteConfig;
|
|
48
|
+
exports.getMergedRouterConfig = __webpack_exports__.getMergedRouterConfig;
|
|
49
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
50
|
+
"getFinalRouteConfig",
|
|
51
|
+
"getMergedRouterConfig"
|
|
52
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
53
|
+
Object.defineProperty(exports, '__esModule', {
|
|
54
|
+
value: true
|
|
55
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
tanstackRouterCompatBindings: ()=>tanstackRouterCompatBindings
|
|
32
|
+
});
|
|
33
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
34
|
+
const external_dataMutation_js_namespaceObject = require("./dataMutation.js");
|
|
35
|
+
const external_outlet_js_namespaceObject = require("./outlet.js");
|
|
36
|
+
const external_plugin_js_namespaceObject = require("./plugin.js");
|
|
37
|
+
const external_prefetchLink_js_namespaceObject = require("./prefetchLink.js");
|
|
38
|
+
const tanstackRouterProviderFactory = (userConfig)=>(0, external_plugin_js_namespaceObject.tanstackRouterPlugin)(userConfig);
|
|
39
|
+
(0, context_namespaceObject.registerRouterProvider)('tanstack', tanstackRouterProviderFactory);
|
|
40
|
+
const COMPAT_BINDINGS_SLOT = Symbol.for('@modern-js/plugin-tanstack:runtime-compat-bindings');
|
|
41
|
+
const tanstackRouterCompatBindings = {
|
|
42
|
+
Form: external_dataMutation_js_namespaceObject.Form,
|
|
43
|
+
Link: external_prefetchLink_js_namespaceObject.Link,
|
|
44
|
+
NavLink: external_prefetchLink_js_namespaceObject.NavLink,
|
|
45
|
+
Outlet: external_outlet_js_namespaceObject.Outlet,
|
|
46
|
+
RouteActionResponseError: external_dataMutation_js_namespaceObject.RouteActionResponseError,
|
|
47
|
+
useFetcher: external_dataMutation_js_namespaceObject.useFetcher
|
|
48
|
+
};
|
|
49
|
+
globalThis[COMPAT_BINDINGS_SLOT] ??= tanstackRouterCompatBindings;
|
|
50
|
+
exports.tanstackRouterCompatBindings = __webpack_exports__.tanstackRouterCompatBindings;
|
|
51
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
52
|
+
"tanstackRouterCompatBindings"
|
|
53
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
54
|
+
Object.defineProperty(exports, '__esModule', {
|
|
55
|
+
value: true
|
|
56
|
+
});
|