@bleedingdev/modern-js-plugin-tanstack 3.9.0-ultramodern.2 → 3.9.0-ultramodern.21
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 +233 -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
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { DefaultNotFound } from "@modern-js/runtime/context";
|
|
3
3
|
import { rootRouteId } from "@tanstack/react-router";
|
|
4
|
+
import { describeRouteTree } from "../../shared/routeDescriptor.mjs";
|
|
4
5
|
import { createRouteStaticData } from "../../shared/routeStaticData.mjs";
|
|
5
6
|
import { withModernRouteMatchContext } from "../outlet.mjs";
|
|
6
7
|
import { toErrorComponent, toPendingComponent, toRouteComponent } from "./components.mjs";
|
|
7
8
|
import { createModernShouldReload, wrapRouteObjectLoader } from "./loaders.mjs";
|
|
8
|
-
import { isRouteObjectPathlessLayout, toTanstackPath } from "./paths.mjs";
|
|
9
9
|
import { mergeModernRouteHandle } from "./staticData.mjs";
|
|
10
10
|
import { createTanstackRootRoute, createTanstackRoute, wrapRouteComponentWithModernContext } from "./tanstackRoutes.mjs";
|
|
11
|
-
function
|
|
12
|
-
const { options = {}, parent, pathlessFallbackId = 'pathless', routeObject } = opts;
|
|
11
|
+
function createRouteOptions(routeObject, options) {
|
|
13
12
|
const modernRouteObject = routeObject;
|
|
14
13
|
const revalidationState = {};
|
|
15
14
|
const shouldRevalidate = modernRouteObject.shouldRevalidate;
|
|
16
15
|
const shouldReload = createModernShouldReload(shouldRevalidate, revalidationState);
|
|
17
|
-
const stableFallbackId = routeObject.id || modernRouteObject.file || pathlessFallbackId;
|
|
18
16
|
const component = toRouteComponent(routeObject);
|
|
19
17
|
const base = {
|
|
20
|
-
getParentRoute: ()=>parent,
|
|
21
18
|
component,
|
|
22
19
|
pendingComponent: toPendingComponent(routeObject),
|
|
23
20
|
errorComponent: toErrorComponent(routeObject),
|
|
@@ -38,66 +35,29 @@ function createRouteFromRouteObject(opts) {
|
|
|
38
35
|
};
|
|
39
36
|
if (modernRouteObject.inValidSSRRoute) base.ssr = false;
|
|
40
37
|
if (shouldReload) base.shouldReload = shouldReload;
|
|
41
|
-
|
|
42
|
-
else base.path = routeObject.index ? '/' : toTanstackPath(routeObject.path || '');
|
|
43
|
-
const route = createTanstackRoute(base);
|
|
44
|
-
wrapRouteComponentWithModernContext(route, component, routeObject.id);
|
|
45
|
-
const children = routeObject.children;
|
|
46
|
-
if (children && children.length > 0) {
|
|
47
|
-
const childRoutes = children.map((child, index)=>createRouteFromRouteObject({
|
|
48
|
-
options,
|
|
49
|
-
parent: route,
|
|
50
|
-
pathlessFallbackId: `pathless-${index}`,
|
|
51
|
-
routeObject: child
|
|
52
|
-
}));
|
|
53
|
-
route.addChildren(childRoutes);
|
|
54
|
-
}
|
|
55
|
-
return route;
|
|
38
|
+
return base;
|
|
56
39
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
40
|
+
function createRouteFromDescriptor(descriptor, parent, options) {
|
|
41
|
+
const { source, location, children } = descriptor;
|
|
42
|
+
const routeOptions = createRouteOptions(source, options);
|
|
43
|
+
const route = createTanstackRoute({
|
|
44
|
+
...routeOptions,
|
|
45
|
+
...location,
|
|
46
|
+
getParentRoute: ()=>parent
|
|
47
|
+
});
|
|
48
|
+
wrapRouteComponentWithModernContext(route, routeOptions.component, source.id);
|
|
49
|
+
if (children.length) route.addChildren(children.map((child)=>createRouteFromDescriptor(child, route, options)));
|
|
50
|
+
return route;
|
|
59
51
|
}
|
|
60
52
|
function createRouteTreeFromRouteObjects(routes, options = {}) {
|
|
61
|
-
const
|
|
62
|
-
const rootRevalidationState = {};
|
|
63
|
-
const rootShouldRevalidate = rootLikeRoute?.shouldRevalidate;
|
|
64
|
-
const rootShouldReload = createModernShouldReload(rootShouldRevalidate, rootRevalidationState);
|
|
65
|
-
const rootComponent = rootLikeRoute ? toRouteComponent(rootLikeRoute) : void 0;
|
|
53
|
+
const { root, children } = describeRouteTree(routes);
|
|
66
54
|
const rootRouteOptions = {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
errorComponent: rootLikeRoute ? toErrorComponent(rootLikeRoute) : void 0,
|
|
70
|
-
validateSearch: rootLikeRoute?.validateSearch,
|
|
71
|
-
loaderDeps: rootLikeRoute?.loaderDeps,
|
|
72
|
-
notFoundComponent: DefaultNotFound,
|
|
73
|
-
staticData: createRouteStaticData({
|
|
74
|
-
modernRouteId: rootLikeRoute?.id,
|
|
75
|
-
modernRouteAction: rootLikeRoute?.action,
|
|
76
|
-
modernRouteHandle: rootLikeRoute ? mergeModernRouteHandle(rootLikeRoute) : void 0,
|
|
77
|
-
modernRouteHasAction: rootLikeRoute?.hasAction || Boolean(rootLikeRoute?.action),
|
|
78
|
-
modernRouteHasClientLoader: rootLikeRoute?.hasClientLoader || void 0 !== rootLikeRoute?.clientData,
|
|
79
|
-
modernRouteHasLoader: rootLikeRoute?.hasLoader || 'function' == typeof rootLikeRoute?.loader,
|
|
80
|
-
modernRouteIsClientComponent: rootLikeRoute?.isClientComponent,
|
|
81
|
-
modernRouteLoader: rootLikeRoute?.loader,
|
|
82
|
-
modernRouteShouldRevalidate: rootShouldRevalidate
|
|
83
|
-
}),
|
|
84
|
-
loader: rootLikeRoute ? wrapRouteObjectLoader(rootLikeRoute, rootRevalidationState, options) : void 0
|
|
55
|
+
...root ? createRouteOptions(root, options) : {},
|
|
56
|
+
notFoundComponent: DefaultNotFound
|
|
85
57
|
};
|
|
86
|
-
if (rootShouldReload) rootRouteOptions.shouldReload = rootShouldReload;
|
|
87
|
-
if (rootLikeRoute?.inValidSSRRoute) rootRouteOptions.ssr = false;
|
|
88
58
|
const rootRoute = createTanstackRootRoute(rootRouteOptions);
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
...rootLikeRoute.children || [],
|
|
92
|
-
...routes.filter((route)=>route !== rootLikeRoute)
|
|
93
|
-
] : routes;
|
|
94
|
-
const childRoutes = topLevel.map((routeObject, index)=>createRouteFromRouteObject({
|
|
95
|
-
options,
|
|
96
|
-
parent: rootRoute,
|
|
97
|
-
pathlessFallbackId: `pathless-${index}`,
|
|
98
|
-
routeObject
|
|
99
|
-
}));
|
|
100
|
-
rootRoute.addChildren(childRoutes);
|
|
59
|
+
if (rootRouteOptions.component) rootRoute.options.component = withModernRouteMatchContext(rootRouteOptions.component, rootRouteId);
|
|
60
|
+
rootRoute.addChildren(children.map((child)=>createRouteFromDescriptor(child, rootRoute, options)));
|
|
101
61
|
return rootRoute;
|
|
102
62
|
}
|
|
103
63
|
function getModernRouteIdsFromMatches(router) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { getLoaderHref, handleModernLoaderError, handleModernLoaderResult, mapSplatParamsForModernLoader } from "../loaderBridge.mjs";
|
|
2
|
+
import { getLoaderHref, getLoaderSignal, handleModernLoaderError, handleModernLoaderResult, mapSplatParamsForModernLoader } from "../loaderBridge.mjs";
|
|
3
3
|
import { isTanstackRscPayloadNavigationEnabled, loadTanstackRscRouteData } from "../rsc/payloadRouter.mjs";
|
|
4
4
|
function isModernDeferredData(value) {
|
|
5
5
|
if (!value || 'object' != typeof value) return false;
|
|
@@ -50,7 +50,7 @@ function wrapRouteObjectLoader(route, revalidationState, options = {}) {
|
|
|
50
50
|
if ('function' == typeof modernRoute.lazyImport) try {
|
|
51
51
|
await modernRoute.lazyImport();
|
|
52
52
|
} catch {}
|
|
53
|
-
const signal = ctx
|
|
53
|
+
const signal = getLoaderSignal(ctx);
|
|
54
54
|
const baseRequest = ctx?.context?.request instanceof Request ? ctx.context.request : void 0;
|
|
55
55
|
const href = getLoaderHref(ctx);
|
|
56
56
|
const request = void 0 !== baseRequest ? new Request(baseRequest, {
|
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import
|
|
2
|
+
import { routerProviderRegistryHooks } from "@modern-js/runtime/context";
|
|
3
|
+
import { routerPlugin } from "@modern-js/runtime/router/internal";
|
|
4
|
+
import { createRouterPlugin } from "@modern-js/runtime-extensions/router-provider";
|
|
5
|
+
import { createRouterStatePlugin } from "@modern-js/runtime-extensions/router-state-plugin";
|
|
3
6
|
import { tanstackRouterProviderFactory } from "./register.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
const createProviderPlugin = createRouterPlugin({
|
|
8
|
+
defaultProvider: {
|
|
9
|
+
name: 'react-router',
|
|
10
|
+
factory: routerPlugin
|
|
11
|
+
},
|
|
12
|
+
registryHooks: routerProviderRegistryHooks,
|
|
13
|
+
localProviders: [
|
|
7
14
|
{
|
|
8
15
|
name: 'tanstack',
|
|
9
16
|
factory: tanstackRouterProviderFactory
|
|
10
17
|
}
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
const statePlugin = createRouterStatePlugin({
|
|
21
|
+
registryHooks: routerProviderRegistryHooks
|
|
22
|
+
});
|
|
23
|
+
const router_routerPlugin = (userConfig = {})=>{
|
|
24
|
+
const providerPlugin = createProviderPlugin(userConfig);
|
|
25
|
+
return {
|
|
26
|
+
...providerPlugin,
|
|
27
|
+
setup (api) {
|
|
28
|
+
statePlugin.setup(api);
|
|
29
|
+
providerPlugin.setup(api);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export { router_routerPlugin as routerPlugin };
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
async function waitForRouterSerialization(tanstackRouter) {
|
|
3
|
-
const serverSsr = tanstackRouter.serverSsr;
|
|
4
|
-
if (!serverSsr || 'function' != typeof serverSsr.onSerializationFinished || serverSsr.isSerializationFinished?.()) return;
|
|
5
|
-
await new Promise((resolve)=>{
|
|
6
|
-
serverSsr.onSerializationFinished?.(resolve);
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
2
|
function htmlEscapeAttr(value) {
|
|
10
3
|
return value.replace(/&/g, '&').replace(/"/g, '"');
|
|
11
4
|
}
|
|
@@ -51,4 +44,4 @@ async function attachServerSsrUtils(router) {
|
|
|
51
44
|
manifest: void 0
|
|
52
45
|
});
|
|
53
46
|
}
|
|
54
|
-
export { attachServerSsrUtils, collectRouterErrors, createGetSsrHref, routerManagedTagsToHtml
|
|
47
|
+
export { attachServerSsrUtils, collectRouterErrors, createGetSsrHref, routerManagedTagsToHtml };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { getRouterRuntimeState } from "@modern-js/runtime/
|
|
2
|
+
import { getRouterRuntimeState } from "@modern-js/runtime-extensions/router-state";
|
|
3
3
|
function getTanstackRouterState(context) {
|
|
4
4
|
const state = getRouterRuntimeState(context);
|
|
5
5
|
if (void 0 === state || 'tanstack' !== state.framework || void 0 === state.instance) return;
|
|
@@ -14,6 +14,8 @@ function withGlobalLayout(Component, globalApp) {
|
|
|
14
14
|
}
|
|
15
15
|
function toTanstackRouteObject(route, globalApp) {
|
|
16
16
|
if ('nested' === route.type) return {
|
|
17
|
+
modernLocalisedRoute: Reflect.get(route, 'modernLocalisedRoute'),
|
|
18
|
+
isRoot: Reflect.get(route, 'isRoot'),
|
|
17
19
|
path: route.path,
|
|
18
20
|
id: route.id,
|
|
19
21
|
loader: route.loader,
|
|
@@ -38,6 +40,7 @@ function toTanstackRouteObject(route, globalApp) {
|
|
|
38
40
|
if ('function' != typeof route.component && 'object' != typeof route.component) return null;
|
|
39
41
|
const LayoutComponent = withGlobalLayout(route.component, globalApp);
|
|
40
42
|
return {
|
|
43
|
+
modernLocalisedRoute: Reflect.get(route, 'modernLocalisedRoute'),
|
|
41
44
|
path: route.path,
|
|
42
45
|
element: /*#__PURE__*/ react.createElement(LayoutComponent)
|
|
43
46
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { toTanstackPath } from "../runtime/routeTree/paths.mjs";
|
|
3
|
+
function describeRouteTree(routes) {
|
|
4
|
+
const root = routes.find((route)=>true === route.isRoot || '/' === route.path && true !== route.index);
|
|
5
|
+
const describe = (route, index)=>({
|
|
6
|
+
source: route,
|
|
7
|
+
location: 0 === (route.path ?? '').length && true !== route.index ? {
|
|
8
|
+
id: route.id || route.file || `pathless-${index}`
|
|
9
|
+
} : {
|
|
10
|
+
path: true === route.index ? '/' : toTanstackPath(route.path || '')
|
|
11
|
+
},
|
|
12
|
+
hasSplat: Boolean(route.path?.includes('*')),
|
|
13
|
+
children: (route.children ?? []).map(describe)
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
root,
|
|
17
|
+
children: (void 0 !== root ? [
|
|
18
|
+
...root.children ?? [],
|
|
19
|
+
...routes.filter((route)=>route !== root)
|
|
20
|
+
] : routes).map(describe)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export { describeRouteTree };
|
|
@@ -21,11 +21,19 @@ export declare function writeTanstackRouterTypesForEntries(opts: {
|
|
|
21
21
|
i18nPluginInstalled?: boolean;
|
|
22
22
|
}): Promise<void>;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
* Writes `src/routes/ultramodern-route-metadata.ts` from the `route.meta.ts`
|
|
25
|
+
* files below `src/routes`. Reads only the file system, never the app config.
|
|
26
|
+
*/
|
|
27
|
+
export declare function writeRouteMetadataManifest(opts: {
|
|
28
|
+
appDirectory: string;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Headless regeneration of the route metadata manifest and of `router.gen.ts` /
|
|
32
|
+
* `register.gen.d.ts` for a generated app, without running a full dev/build.
|
|
33
|
+
* Drives the app-tools analyze `onPrepare` (which fires `generateEntryCode`)
|
|
34
|
+
* and returns before any bundling — the app's own registered plugin-tanstack
|
|
35
|
+
* writes the router artifacts via its `generateEntryCode` subscriber. Reuses
|
|
36
|
+
* the exact hook dev/build use, so there is no scanning drift.
|
|
29
37
|
*/
|
|
30
38
|
export declare function generateTanstackRouteArtifacts(opts: {
|
|
31
39
|
appDirectory: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AppTools, CliPlugin } from '@modern-js/app-tools';
|
|
2
2
|
import { type TanstackRouteCodeSplittingOption } from './routeSplitting.js';
|
|
3
|
-
export { generateTanstackRouteArtifacts, writeTanstackRegisterFile, writeTanstackRouterTypesForEntries, } from './artifacts.js';
|
|
3
|
+
export { generateTanstackRouteArtifacts, writeRouteMetadataManifest, writeTanstackRegisterFile, writeTanstackRouterTypesForEntries, } from './artifacts.js';
|
|
4
4
|
export type { TanstackRouteCodeSplittingOption, TanstackRsbuildRouteSplittingProfile, } from './routeSplitting.js';
|
|
5
5
|
export { createTanstackRsbuildRouteSplittingProfile, resolveTanstackRouteCodeSplittingEnabled, } from './routeSplitting.js';
|
|
6
6
|
export { type CollectCanonicalRoutesOptions, collectCanonicalRoutesForEntry, generateTanstackRouterTypesSourceForEntry, } from './tanstackTypes.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const ROUTE_META_FILE_NAME = "route.meta.ts";
|
|
2
|
+
export declare const ROUTE_METADATA_MANIFEST_FILE_NAME = "ultramodern-route-metadata.ts";
|
|
3
|
+
export declare const ROUTE_METADATA_MANIFEST_HEADER = "// @generated by @modern-js/plugin-tanstack from route.meta.ts files. Run routes-generate; do not edit.";
|
|
4
|
+
/**
|
|
5
|
+
* Renders the route metadata manifest for the `route.meta.ts` files of one
|
|
6
|
+
* routes directory. Each path is relative to that directory (either separator).
|
|
7
|
+
* Every `route.meta.ts` must export `routeMeta`; the manifest imports it
|
|
8
|
+
* statically, so the metadata is never evaluated while generating. Returns
|
|
9
|
+
* `null` when there are no route metadata files. Output depends only on the
|
|
10
|
+
* set of paths, never on their order or on the file system.
|
|
11
|
+
*/
|
|
12
|
+
export declare function renderRouteMetadataManifest(routeMetaFiles: readonly string[]): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Lists the `route.meta.ts` files below `routesDirectory`, relative to it.
|
|
15
|
+
* Symbolic links are not followed: linked metadata belongs to the tree it
|
|
16
|
+
* lives in. A missing directory has no route metadata.
|
|
17
|
+
*/
|
|
18
|
+
export declare function findRouteMetaFiles(routesDirectory: string): Promise<string[]>;
|
|
@@ -11,8 +11,6 @@ export declare function pickRouteSearchContractModules(route: NestedRouteForCli
|
|
|
11
11
|
validateSearchPath: string | null;
|
|
12
12
|
loaderDepsPath: string | null;
|
|
13
13
|
};
|
|
14
|
-
export declare function isPathlessLayout(route: NestedRouteForCli | PageRoute): boolean;
|
|
15
|
-
export declare function isIndexRoute(route: NestedRouteForCli | PageRoute): boolean;
|
|
16
14
|
export declare function createRouteStaticDataSnippet(opts: {
|
|
17
15
|
modernRouteId?: string;
|
|
18
16
|
loaderName?: string | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
2
|
+
export declare function createModernBasepathRewrite(basepath: string, caseSensitive?: boolean, routes?: RouteObject[]): {
|
|
2
3
|
input: ({ url }: {
|
|
3
4
|
url: URL;
|
|
4
5
|
}) => URL;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The router runtime state helpers are owned by @modern-js/runtime (the same
|
|
2
|
+
* The router runtime state helpers are owned by @modern-js/runtime-extensions (the same
|
|
3
3
|
* implementation backs the built-in react-router provider and the SSR
|
|
4
4
|
* pipeline). This module only re-exports them so every router provider
|
|
5
5
|
* writes to the exact same runtime-context extension slot.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
import type { RouterLifecycleContext as NativeRouterLifecycleContext } from '@modern-js/runtime/context';
|
|
8
|
+
import type { InternalRouterServerSnapshot, RouterRouteMatchSnapshot } from '@modern-js/runtime-extensions/router-state';
|
|
9
|
+
export type RouterLifecycleContext = NativeRouterLifecycleContext & {
|
|
10
|
+
matches?: RouterRouteMatchSnapshot[];
|
|
11
|
+
cleanup?: () => void | Promise<void>;
|
|
12
|
+
serverSnapshot?: InternalRouterServerSnapshot;
|
|
13
|
+
};
|
|
14
|
+
export { applyRouterRuntimeState, applyRouterServerPrepareResult, createRouterServerSnapshot, getRouterRuntimeState, getRouterServerSnapshot, type RouterLifecyclePhase, } from '@modern-js/runtime-extensions/router-state';
|
|
@@ -39,6 +39,7 @@ type LoaderLikeContext = {
|
|
|
39
39
|
};
|
|
40
40
|
params?: Record<string, string>;
|
|
41
41
|
};
|
|
42
|
+
export declare function getLoaderSignal(ctx: LoaderLikeContext | undefined): AbortSignal;
|
|
42
43
|
export declare function getLoaderHref(ctx: LoaderLikeContext | undefined): string;
|
|
43
44
|
export declare function handleModernLoaderResult<LoaderResult>(result: LoaderResult): LoaderResult;
|
|
44
45
|
export declare function handleModernLoaderError(err: unknown): never;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RouterNavigationCapability } from '@modern-js/runtime-extensions/router-state';
|
|
2
|
+
import type { AnyRouter } from '@tanstack/react-router';
|
|
3
|
+
/** Native TanStack navigation, exposed through the provider contract. */
|
|
4
|
+
export declare function createTanstackNavigation(router: AnyRouter): RouterNavigationCapability;
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Registers TanStack in the @modern-js/runtime compatibility registry.
|
|
3
|
-
* Runtime entries bind the exported local factory into their own provider
|
|
4
|
-
* realm; registration remains for older runtime wrappers and mixed cohorts.
|
|
5
|
-
*
|
|
6
|
-
* This module is intentionally side-effectful (see `sideEffects` in
|
|
7
|
-
* package.json).
|
|
8
|
-
*/
|
|
9
|
-
import { type RouterProviderFactory } from '@modern-js/runtime/context';
|
|
1
|
+
import { type RouterProviderFactory } from '@modern-js/runtime-extensions/router-provider';
|
|
10
2
|
export declare const tanstackRouterProviderFactory: RouterProviderFactory;
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* file-route entrypoints (e.g. apps configuring
|
|
4
|
-
* `router: { framework: 'tanstack', createRoutes }` in modern.runtime.ts).
|
|
5
|
-
*
|
|
6
|
-
* The CLI plugin injects `{ name: 'router', path: '<pkg>/runtime/router' }`
|
|
7
|
-
* for those entries. This module creates a framework-resolving wrapper whose
|
|
8
|
-
* app-owned provider realm contains this module graph's TanStack factory.
|
|
9
|
-
*/
|
|
10
|
-
import * as runtimeRouter from '@modern-js/runtime/router/internal';
|
|
11
|
-
type LegacyRouterPlugin = (typeof runtimeRouter)['routerPlugin'];
|
|
12
|
-
export declare const routerPlugin: LegacyRouterPlugin;
|
|
13
|
-
export {};
|
|
1
|
+
import { routerPlugin as nativeRouterPlugin } from '@modern-js/runtime/router/internal';
|
|
2
|
+
export declare const routerPlugin: typeof nativeRouterPlugin;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AnyRouter } from '@tanstack/react-router';
|
|
2
2
|
import type { TanstackRouterWithServerSsr } from './ssrTypes.js';
|
|
3
|
-
export declare function waitForRouterSerialization(tanstackRouter: TanstackRouterWithServerSsr): Promise<void>;
|
|
4
3
|
export declare function routerManagedTagsToHtml(tags: unknown): string[];
|
|
5
4
|
export declare function createGetSsrHref(request: Request): string;
|
|
6
5
|
export declare function collectRouterErrors(tanstackRouter: AnyRouter): Record<string, unknown> | undefined;
|
|
@@ -28,13 +28,6 @@ type RouterRouteWithOptions = {
|
|
|
28
28
|
};
|
|
29
29
|
export type TanstackRouterWithServerSsr = AnyRouter & {
|
|
30
30
|
routesById?: Record<string, RouterRouteWithOptions>;
|
|
31
|
-
serverSsr?: {
|
|
32
|
-
cleanup?: () => void;
|
|
33
|
-
dehydrate?: () => Promise<void> | void;
|
|
34
|
-
isSerializationFinished?: () => boolean;
|
|
35
|
-
onSerializationFinished?: (listener: () => void) => void;
|
|
36
|
-
takeBufferedScripts?: () => unknown;
|
|
37
|
-
};
|
|
38
31
|
state: AnyRouter['state'] & {
|
|
39
32
|
matches?: unknown;
|
|
40
33
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type InternalRouterRuntimeState } from '@modern-js/runtime/
|
|
1
|
+
import { type InternalRouterRuntimeState } from '@modern-js/runtime-extensions/router-state';
|
|
2
2
|
import type { AnyRouter } from '@tanstack/react-router';
|
|
3
3
|
/**
|
|
4
4
|
* Router runtime state as published by the TanStack router provider into the
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ModernRoute } from '@modern-js/runtime/context';
|
|
2
2
|
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
3
3
|
import type React from 'react';
|
|
4
|
-
export type {
|
|
4
|
+
export type { ModernRoute } from '@modern-js/runtime/context';
|
|
5
|
+
export type { InternalRouterServerSnapshot, RouterFramework, } from '@modern-js/runtime-extensions/router-state';
|
|
5
6
|
/** TanStack-specific router config. */
|
|
6
7
|
export type RouterConfig = {
|
|
7
8
|
routesConfig: {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type RouteShape = {
|
|
2
|
+
id?: string;
|
|
3
|
+
file?: string;
|
|
4
|
+
path?: string;
|
|
5
|
+
index?: boolean;
|
|
6
|
+
isRoot?: boolean;
|
|
7
|
+
children?: RouteShape[];
|
|
8
|
+
};
|
|
9
|
+
/** Browser-safe structure shared by the executable tree and concrete TS emitter. */
|
|
10
|
+
export type RouteDescriptor<T extends RouteShape> = {
|
|
11
|
+
source: T;
|
|
12
|
+
location: {
|
|
13
|
+
id: string;
|
|
14
|
+
path?: never;
|
|
15
|
+
} | {
|
|
16
|
+
path: string;
|
|
17
|
+
id?: never;
|
|
18
|
+
};
|
|
19
|
+
hasSplat: boolean;
|
|
20
|
+
children: RouteDescriptor<T>[];
|
|
21
|
+
};
|
|
22
|
+
export declare function describeRouteTree<T extends RouteShape>(routes: T[]): {
|
|
23
|
+
root: T | undefined;
|
|
24
|
+
children: RouteDescriptor<T>[];
|
|
25
|
+
};
|
|
26
|
+
export {};
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"modern.js",
|
|
19
19
|
"tanstack-router"
|
|
20
20
|
],
|
|
21
|
-
"version": "3.9.0-ultramodern.
|
|
21
|
+
"version": "3.9.0-ultramodern.21",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=20"
|
|
24
24
|
},
|
|
@@ -94,17 +94,19 @@
|
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
|
-
"@modern-js/
|
|
98
|
-
"@modern-js/
|
|
99
|
-
"@modern-js/
|
|
100
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.
|
|
97
|
+
"@modern-js/i18n-runtime-extensions": "npm:@bleedingdev/modern-js-i18n-runtime-extensions@3.9.0-ultramodern.21",
|
|
98
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.21",
|
|
99
|
+
"@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.21",
|
|
100
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.21",
|
|
101
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.21",
|
|
102
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.21",
|
|
101
103
|
"@swc/helpers": "^0.5.23",
|
|
102
|
-
"@tanstack/react-router": "1.170.
|
|
103
|
-
"@tanstack/router-core": "1.171.
|
|
104
|
+
"@tanstack/react-router": "1.170.39",
|
|
105
|
+
"@tanstack/router-core": "1.171.32"
|
|
104
106
|
},
|
|
105
107
|
"peerDependencies": {
|
|
106
|
-
"@modern-js/app-tools": "3.9.0-ultramodern.
|
|
107
|
-
"@modern-js/runtime": "3.9.0-ultramodern.
|
|
108
|
+
"@modern-js/app-tools": "3.9.0-ultramodern.21",
|
|
109
|
+
"@modern-js/runtime": "3.9.0-ultramodern.21",
|
|
108
110
|
"react": "^19.2.8",
|
|
109
111
|
"react-dom": "^19.2.8",
|
|
110
112
|
"react-server-dom-rspack": "0.1.0"
|
|
@@ -115,19 +117,20 @@
|
|
|
115
117
|
}
|
|
116
118
|
},
|
|
117
119
|
"devDependencies": {
|
|
118
|
-
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.
|
|
119
|
-
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.9.0-ultramodern.
|
|
120
|
-
"@
|
|
120
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.21",
|
|
121
|
+
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.9.0-ultramodern.21",
|
|
122
|
+
"@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.9.0-ultramodern.21",
|
|
123
|
+
"@rslib/core": "1.0.2",
|
|
121
124
|
"@scripts/rstest-config": "2.66.0",
|
|
122
|
-
"@tanstack/history": "1.162.
|
|
125
|
+
"@tanstack/history": "1.162.4",
|
|
123
126
|
"@testing-library/react": "^16.3.3",
|
|
124
127
|
"@tsconfig/strictest": "2.0.8",
|
|
125
|
-
"@types/node": "^26.
|
|
126
|
-
"@types/react": "^19.
|
|
127
|
-
"@types/react-dom": "^19.
|
|
128
|
+
"@types/node": "^26.6.2",
|
|
129
|
+
"@types/react": "^19.3.0",
|
|
130
|
+
"@types/react-dom": "^19.3.0",
|
|
128
131
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
129
|
-
"react": "^19.
|
|
130
|
-
"react-dom": "^19.
|
|
132
|
+
"react": "^19.3.0",
|
|
133
|
+
"react-dom": "^19.3.0",
|
|
131
134
|
"react-server-dom-rspack": "0.1.0"
|
|
132
135
|
},
|
|
133
136
|
"sideEffects": [
|
|
@@ -150,6 +153,6 @@
|
|
|
150
153
|
"scripts": {
|
|
151
154
|
"dev": "rslib build --watch",
|
|
152
155
|
"build": "rslib build",
|
|
153
|
-
"test": "rstest
|
|
156
|
+
"test": "rstest"
|
|
154
157
|
}
|
|
155
158
|
}
|
package/rstest.config.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
1
|
import type { ProjectConfig } from '@rstest/core';
|
|
3
2
|
import { withTestPreset } from '@scripts/rstest-config';
|
|
4
3
|
|
|
@@ -24,20 +23,14 @@ export default {
|
|
|
24
23
|
name: 'plugin-tanstack-node',
|
|
25
24
|
testEnvironment: 'node',
|
|
26
25
|
include: [
|
|
27
|
-
'tests/realm-isolation.test.ts',
|
|
28
26
|
'tests/router/cli.test.ts',
|
|
29
|
-
'tests/router/fastDefaults.test.ts',
|
|
30
27
|
'tests/router/flightSerialization.roundtrip.test.tsx',
|
|
31
28
|
'tests/router/generateRouteArtifacts.test.ts',
|
|
32
|
-
'tests/router/hooks.test.ts',
|
|
33
29
|
'tests/router/loaderBridge.test.ts',
|
|
34
|
-
'tests/router/
|
|
35
|
-
'tests/router/preloadRedirect.test.ts',
|
|
36
|
-
'tests/router/register.test.ts',
|
|
30
|
+
'tests/router/localisedIdentity.test.tsx',
|
|
37
31
|
'tests/router/routeHooks.test.ts',
|
|
32
|
+
'tests/router/routeMetadata.test.ts',
|
|
38
33
|
'tests/router/serverPlugin.test.ts',
|
|
39
|
-
'tests/router/rscDecoderSecurity.test.ts',
|
|
40
|
-
'tests/router/rscPayloadRouterMatrix.test.ts',
|
|
41
34
|
'tests/router/rsc.test.tsx',
|
|
42
35
|
'tests/router/slotUsageSanitizer.test.ts',
|
|
43
36
|
'tests/router/ssrPreload.test.ts',
|
|
@@ -46,27 +39,12 @@ export default {
|
|
|
46
39
|
],
|
|
47
40
|
extends: commonConfig,
|
|
48
41
|
}),
|
|
49
|
-
withTestPreset({
|
|
50
|
-
name: 'plugin-tanstack-router-compatibility',
|
|
51
|
-
testEnvironment: 'node',
|
|
52
|
-
include: ['tests/router/routerCompatibility.test.ts'],
|
|
53
|
-
resolve: {
|
|
54
|
-
alias: {
|
|
55
|
-
'@modern-js/runtime/router/internal': path.resolve(
|
|
56
|
-
__dirname,
|
|
57
|
-
'tests/router/fixtures/legacyRuntimeRouter.ts',
|
|
58
|
-
),
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
extends: commonConfig,
|
|
62
|
-
}),
|
|
63
42
|
withTestPreset({
|
|
64
43
|
name: 'plugin-tanstack-client',
|
|
65
44
|
testEnvironment: 'happy-dom',
|
|
66
45
|
include: [
|
|
67
46
|
'tests/router/clientHydration.test.tsx',
|
|
68
47
|
'tests/router/dataMutation.test.tsx',
|
|
69
|
-
'tests/router/hydrationBoundary.test.tsx',
|
|
70
48
|
'tests/router/prefetchLink.test.tsx',
|
|
71
49
|
'tests/router/prefetchLinkPreload.test.tsx',
|
|
72
50
|
],
|