@bleedingdev/modern-js-plugin-tanstack 3.5.0-ultramodern.9 → 3.5.0-ultramodern.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/dist/cjs/cli/artifacts.js +157 -0
  2. package/dist/cjs/cli/index.js +8 -79
  3. package/dist/cjs/cli/tanstackTypes/canonicalRoutes.js +113 -0
  4. package/dist/cjs/cli/tanstackTypes/shared.js +123 -0
  5. package/dist/cjs/cli/tanstackTypes/source.js +255 -0
  6. package/dist/cjs/cli/tanstackTypes.js +4 -350
  7. package/dist/cjs/runtime/blockingSubscribe.js +57 -0
  8. package/dist/cjs/runtime/{pluginCore.js → clientBasepath.js} +12 -19
  9. package/dist/cjs/runtime/clientHydration.js +118 -0
  10. package/dist/cjs/runtime/dataMutation.js +11 -176
  11. package/dist/cjs/runtime/formData.js +116 -0
  12. package/dist/cjs/runtime/loaderBridge.js +7 -11
  13. package/dist/cjs/runtime/plugin.js +21 -125
  14. package/dist/cjs/runtime/plugin.node.js +45 -125
  15. package/dist/cjs/runtime/pluginShared.js +87 -0
  16. package/dist/cjs/runtime/prefetchLink.js +15 -2
  17. package/dist/cjs/runtime/register.js +3 -16
  18. package/dist/cjs/runtime/routeTree/components.js +102 -0
  19. package/dist/cjs/runtime/routeTree/construction.js +152 -0
  20. package/dist/cjs/runtime/routeTree/index.js +47 -0
  21. package/dist/cjs/runtime/routeTree/loaders.js +158 -0
  22. package/dist/cjs/runtime/routeTree/paths.js +57 -0
  23. package/dist/cjs/runtime/routeTree/staticData.js +63 -0
  24. package/dist/cjs/runtime/routeTree/tanstackRoutes.js +57 -0
  25. package/dist/cjs/runtime/routeTree/types.js +18 -0
  26. package/dist/cjs/runtime/routeTree.js +7 -320
  27. package/dist/cjs/runtime/router.js +15 -2
  28. package/dist/cjs/runtime/rsc/CompositeComponent.js +18 -13
  29. package/dist/cjs/runtime/rsc/ReplayableStream.js +0 -4
  30. package/dist/cjs/runtime/rsc/RscNodeRenderer.js +5 -16
  31. package/dist/cjs/runtime/rsc/client.js +8 -25
  32. package/dist/cjs/runtime/rsc/flightSerialization.js +132 -0
  33. package/dist/cjs/runtime/rsc/payloadErrors.js +99 -0
  34. package/dist/cjs/runtime/rsc/payloadFetch.js +105 -0
  35. package/dist/cjs/runtime/rsc/payloadRouter.js +21 -142
  36. package/dist/cjs/runtime/rsc/payloadRoutes.js +94 -0
  37. package/dist/cjs/runtime/rsc/payloadStorage.js +58 -0
  38. package/dist/cjs/runtime/rsc/server.js +14 -18
  39. package/dist/cjs/runtime/rsc/shared.js +68 -0
  40. package/dist/cjs/runtime/rsc/slotUsageSanitizer.js +1 -0
  41. package/dist/cjs/runtime/rsc/treeGetter.js +72 -0
  42. package/dist/cjs/runtime/shared/isAbsoluteUrl.js +47 -0
  43. package/dist/cjs/runtime/ssrManagedTags.js +103 -0
  44. package/dist/cjs/runtime/ssrPreload.js +89 -0
  45. package/dist/cjs/runtime/ssrTypes.js +18 -0
  46. package/dist/cjs/runtime/state.js +1 -1
  47. package/dist/cjs/runtime/submitAction.js +161 -0
  48. package/dist/cjs/runtime/utils.js +49 -86
  49. package/dist/esm/cli/artifacts.mjs +103 -0
  50. package/dist/esm/cli/index.mjs +8 -82
  51. package/dist/esm/cli/tanstackTypes/canonicalRoutes.mjs +75 -0
  52. package/dist/esm/cli/tanstackTypes/shared.mjs +61 -0
  53. package/dist/esm/cli/tanstackTypes/source.mjs +207 -0
  54. package/dist/esm/cli/tanstackTypes.mjs +2 -339
  55. package/dist/esm/runtime/blockingSubscribe.mjs +19 -0
  56. package/dist/esm/runtime/clientBasepath.mjs +10 -0
  57. package/dist/esm/runtime/clientHydration.mjs +71 -0
  58. package/dist/esm/runtime/dataMutation.mjs +2 -167
  59. package/dist/esm/runtime/formData.mjs +63 -0
  60. package/dist/esm/runtime/loaderBridge.mjs +5 -9
  61. package/dist/esm/runtime/plugin.mjs +14 -118
  62. package/dist/esm/runtime/plugin.node.mjs +41 -121
  63. package/dist/esm/runtime/pluginShared.mjs +40 -0
  64. package/dist/esm/runtime/prefetchLink.mjs +18 -5
  65. package/dist/esm/runtime/register.mjs +1 -14
  66. package/dist/esm/runtime/routeTree/components.mjs +55 -0
  67. package/dist/esm/runtime/routeTree/construction.mjs +111 -0
  68. package/dist/esm/runtime/routeTree/index.mjs +2 -0
  69. package/dist/esm/runtime/routeTree/loaders.mjs +117 -0
  70. package/dist/esm/runtime/routeTree/paths.mjs +16 -0
  71. package/dist/esm/runtime/routeTree/staticData.mjs +22 -0
  72. package/dist/esm/runtime/routeTree/tanstackRoutes.mjs +13 -0
  73. package/dist/esm/runtime/routeTree/types.mjs +0 -0
  74. package/dist/esm/runtime/routeTree.mjs +1 -318
  75. package/dist/esm/runtime/router.mjs +16 -2
  76. package/dist/esm/runtime/rsc/CompositeComponent.mjs +18 -13
  77. package/dist/esm/runtime/rsc/ReplayableStream.mjs +1 -1
  78. package/dist/esm/runtime/rsc/RscNodeRenderer.mjs +4 -15
  79. package/dist/esm/runtime/rsc/client.mjs +6 -26
  80. package/dist/esm/runtime/rsc/flightSerialization.mjs +88 -0
  81. package/dist/esm/runtime/rsc/payloadErrors.mjs +49 -0
  82. package/dist/esm/runtime/rsc/payloadFetch.mjs +55 -0
  83. package/dist/esm/runtime/rsc/payloadRouter.mjs +12 -133
  84. package/dist/esm/runtime/rsc/payloadRoutes.mjs +50 -0
  85. package/dist/esm/runtime/rsc/payloadStorage.mjs +14 -0
  86. package/dist/esm/runtime/rsc/server.mjs +17 -21
  87. package/dist/esm/runtime/rsc/shared.mjs +21 -0
  88. package/dist/esm/runtime/rsc/slotUsageSanitizer.mjs +1 -0
  89. package/dist/esm/runtime/rsc/treeGetter.mjs +34 -0
  90. package/dist/esm/runtime/shared/isAbsoluteUrl.mjs +9 -0
  91. package/dist/esm/runtime/ssrManagedTags.mjs +53 -0
  92. package/dist/esm/runtime/ssrPreload.mjs +51 -0
  93. package/dist/esm/runtime/ssrTypes.mjs +0 -0
  94. package/dist/esm/runtime/state.mjs +1 -1
  95. package/dist/esm/runtime/submitAction.mjs +120 -0
  96. package/dist/esm/runtime/utils.mjs +47 -75
  97. package/dist/esm-node/cli/artifacts.mjs +104 -0
  98. package/dist/esm-node/cli/index.mjs +8 -82
  99. package/dist/esm-node/cli/tanstackTypes/canonicalRoutes.mjs +76 -0
  100. package/dist/esm-node/cli/tanstackTypes/shared.mjs +62 -0
  101. package/dist/esm-node/cli/tanstackTypes/source.mjs +208 -0
  102. package/dist/esm-node/cli/tanstackTypes.mjs +2 -339
  103. package/dist/esm-node/runtime/blockingSubscribe.mjs +20 -0
  104. package/dist/esm-node/runtime/clientBasepath.mjs +11 -0
  105. package/dist/esm-node/runtime/clientHydration.mjs +72 -0
  106. package/dist/esm-node/runtime/dataMutation.mjs +2 -167
  107. package/dist/esm-node/runtime/formData.mjs +64 -0
  108. package/dist/esm-node/runtime/loaderBridge.mjs +5 -9
  109. package/dist/esm-node/runtime/plugin.mjs +14 -118
  110. package/dist/esm-node/runtime/plugin.node.mjs +41 -121
  111. package/dist/esm-node/runtime/pluginShared.mjs +41 -0
  112. package/dist/esm-node/runtime/prefetchLink.mjs +18 -5
  113. package/dist/esm-node/runtime/register.mjs +1 -14
  114. package/dist/esm-node/runtime/routeTree/components.mjs +56 -0
  115. package/dist/esm-node/runtime/routeTree/construction.mjs +112 -0
  116. package/dist/esm-node/runtime/routeTree/index.mjs +3 -0
  117. package/dist/esm-node/runtime/routeTree/loaders.mjs +118 -0
  118. package/dist/esm-node/runtime/routeTree/paths.mjs +17 -0
  119. package/dist/esm-node/runtime/routeTree/staticData.mjs +23 -0
  120. package/dist/esm-node/runtime/routeTree/tanstackRoutes.mjs +14 -0
  121. package/dist/esm-node/runtime/routeTree/types.mjs +1 -0
  122. package/dist/esm-node/runtime/routeTree.mjs +1 -318
  123. package/dist/esm-node/runtime/router.mjs +16 -2
  124. package/dist/esm-node/runtime/rsc/CompositeComponent.mjs +18 -13
  125. package/dist/esm-node/runtime/rsc/ReplayableStream.mjs +1 -1
  126. package/dist/esm-node/runtime/rsc/RscNodeRenderer.mjs +4 -15
  127. package/dist/esm-node/runtime/rsc/client.mjs +6 -26
  128. package/dist/esm-node/runtime/rsc/flightSerialization.mjs +89 -0
  129. package/dist/esm-node/runtime/rsc/payloadErrors.mjs +50 -0
  130. package/dist/esm-node/runtime/rsc/payloadFetch.mjs +56 -0
  131. package/dist/esm-node/runtime/rsc/payloadRouter.mjs +12 -133
  132. package/dist/esm-node/runtime/rsc/payloadRoutes.mjs +51 -0
  133. package/dist/esm-node/runtime/rsc/payloadStorage.mjs +15 -0
  134. package/dist/esm-node/runtime/rsc/server.mjs +17 -21
  135. package/dist/esm-node/runtime/rsc/shared.mjs +22 -0
  136. package/dist/esm-node/runtime/rsc/slotUsageSanitizer.mjs +1 -0
  137. package/dist/esm-node/runtime/rsc/treeGetter.mjs +35 -0
  138. package/dist/esm-node/runtime/shared/isAbsoluteUrl.mjs +10 -0
  139. package/dist/esm-node/runtime/ssrManagedTags.mjs +54 -0
  140. package/dist/esm-node/runtime/ssrPreload.mjs +52 -0
  141. package/dist/esm-node/runtime/ssrTypes.mjs +1 -0
  142. package/dist/esm-node/runtime/state.mjs +1 -1
  143. package/dist/esm-node/runtime/submitAction.mjs +121 -0
  144. package/dist/esm-node/runtime/utils.mjs +47 -75
  145. package/dist/types/cli/artifacts.d.ts +33 -0
  146. package/dist/types/cli/index.d.ts +2 -22
  147. package/dist/types/cli/tanstackTypes/canonicalRoutes.d.ts +22 -0
  148. package/dist/types/cli/tanstackTypes/shared.d.ts +20 -0
  149. package/dist/types/cli/tanstackTypes/source.d.ts +12 -0
  150. package/dist/types/cli/tanstackTypes.d.ts +3 -31
  151. package/dist/types/runtime/blockingSubscribe.d.ts +1 -0
  152. package/dist/types/runtime/clientBasepath.d.ts +1 -0
  153. package/dist/types/runtime/clientHydration.d.ts +10 -0
  154. package/dist/types/runtime/dataMutation.d.ts +3 -12
  155. package/dist/types/runtime/formData.d.ts +24 -0
  156. package/dist/types/runtime/loaderBridge.d.ts +2 -1
  157. package/dist/types/runtime/plugin.d.ts +1 -1
  158. package/dist/types/runtime/plugin.node.d.ts +1 -1
  159. package/dist/types/runtime/pluginShared.d.ts +38 -0
  160. package/dist/types/runtime/register.d.ts +10 -9
  161. package/dist/types/runtime/routeTree/components.d.ts +7 -0
  162. package/dist/types/runtime/routeTree/construction.d.ts +5 -0
  163. package/dist/types/runtime/routeTree/index.d.ts +2 -0
  164. package/dist/types/runtime/routeTree/loaders.d.ts +4 -0
  165. package/dist/types/runtime/routeTree/paths.d.ts +3 -0
  166. package/dist/types/runtime/routeTree/staticData.d.ts +19 -0
  167. package/dist/types/runtime/routeTree/tanstackRoutes.d.ts +4 -0
  168. package/dist/types/runtime/routeTree/types.d.ts +76 -0
  169. package/dist/types/runtime/routeTree.d.ts +1 -9
  170. package/dist/types/runtime/router.d.ts +6 -7
  171. package/dist/types/runtime/rsc/CompositeComponent.d.ts +1 -2
  172. package/dist/types/runtime/rsc/ReplayableStream.d.ts +3 -2
  173. package/dist/types/runtime/rsc/RscNodeRenderer.d.ts +2 -3
  174. package/dist/types/runtime/rsc/SlotContext.d.ts +2 -1
  175. package/dist/types/runtime/rsc/client.d.ts +2 -0
  176. package/dist/types/runtime/rsc/flightSerialization.d.ts +3 -0
  177. package/dist/types/runtime/rsc/payloadErrors.d.ts +6 -0
  178. package/dist/types/runtime/rsc/payloadFetch.d.ts +8 -0
  179. package/dist/types/runtime/rsc/payloadRouter.d.ts +2 -10
  180. package/dist/types/runtime/rsc/payloadRoutes.d.ts +40 -0
  181. package/dist/types/runtime/rsc/payloadStorage.d.ts +5 -0
  182. package/dist/types/runtime/rsc/shared.d.ts +18 -0
  183. package/dist/types/runtime/rsc/treeGetter.d.ts +1 -0
  184. package/dist/types/runtime/shared/isAbsoluteUrl.d.ts +1 -0
  185. package/dist/types/runtime/ssrManagedTags.d.ts +7 -0
  186. package/dist/types/runtime/ssrPreload.d.ts +2 -0
  187. package/dist/types/runtime/ssrTypes.d.ts +44 -0
  188. package/dist/types/runtime/state.d.ts +1 -1
  189. package/dist/types/runtime/submitAction.d.ts +14 -0
  190. package/dist/types/runtime/types.d.ts +4 -10
  191. package/dist/types/runtime/utils.d.ts +4 -24
  192. package/package.json +37 -17
  193. package/rstest.config.mts +23 -0
  194. package/src/cli/artifacts.ts +255 -0
  195. package/src/cli/index.ts +7 -185
  196. package/src/cli/tanstackTypes/canonicalRoutes.ts +157 -0
  197. package/src/cli/tanstackTypes/shared.ts +113 -0
  198. package/src/cli/tanstackTypes/source.ts +414 -0
  199. package/src/cli/tanstackTypes.ts +4 -647
  200. package/src/runtime/blockingSubscribe.ts +48 -0
  201. package/src/runtime/clientBasepath.ts +12 -0
  202. package/src/runtime/clientHydration.ts +149 -0
  203. package/src/runtime/dataMutation.tsx +9 -306
  204. package/src/runtime/formData.ts +153 -0
  205. package/src/runtime/loaderBridge.ts +11 -12
  206. package/src/runtime/plugin.node.tsx +76 -291
  207. package/src/runtime/plugin.tsx +21 -257
  208. package/src/runtime/pluginShared.ts +112 -0
  209. package/src/runtime/prefetchLink.tsx +78 -15
  210. package/src/runtime/register.ts +10 -42
  211. package/src/runtime/routeTree/components.ts +130 -0
  212. package/src/runtime/routeTree/construction.ts +238 -0
  213. package/src/runtime/routeTree/index.ts +7 -0
  214. package/src/runtime/routeTree/loaders.ts +232 -0
  215. package/src/runtime/routeTree/paths.ts +36 -0
  216. package/src/runtime/routeTree/staticData.ts +66 -0
  217. package/src/runtime/routeTree/tanstackRoutes.ts +36 -0
  218. package/src/runtime/routeTree/types.ts +87 -0
  219. package/src/runtime/routeTree.ts +5 -750
  220. package/src/runtime/router.ts +35 -7
  221. package/src/runtime/rsc/CompositeComponent.tsx +29 -20
  222. package/src/runtime/rsc/ReplayableStream.ts +2 -2
  223. package/src/runtime/rsc/RscNodeRenderer.tsx +9 -27
  224. package/src/runtime/rsc/SlotContext.tsx +1 -1
  225. package/src/runtime/rsc/client.tsx +12 -40
  226. package/src/runtime/rsc/flightSerialization.ts +158 -0
  227. package/src/runtime/rsc/payloadErrors.ts +73 -0
  228. package/src/runtime/rsc/payloadFetch.ts +92 -0
  229. package/src/runtime/rsc/payloadRouter.ts +29 -234
  230. package/src/runtime/rsc/payloadRoutes.ts +122 -0
  231. package/src/runtime/rsc/payloadStorage.ts +35 -0
  232. package/src/runtime/rsc/server.tsx +20 -29
  233. package/src/runtime/rsc/shared.ts +70 -0
  234. package/src/runtime/rsc/slotUsageSanitizer.ts +4 -0
  235. package/src/runtime/rsc/treeGetter.tsx +52 -0
  236. package/src/runtime/shared/isAbsoluteUrl.ts +8 -0
  237. package/src/runtime/ssrManagedTags.ts +107 -0
  238. package/src/runtime/ssrPreload.ts +125 -0
  239. package/src/runtime/ssrTypes.ts +51 -0
  240. package/src/runtime/state.ts +9 -3
  241. package/src/runtime/submitAction.ts +201 -0
  242. package/src/runtime/types.ts +4 -18
  243. package/src/runtime/utils.tsx +76 -110
  244. package/src/types/react-server-dom-rspack.d.ts +56 -0
  245. package/tests/castRatchet.test.ts +85 -0
  246. package/tests/realm-isolation.test.ts +114 -0
  247. package/tests/router/cli.test.ts +7 -0
  248. package/tests/router/clientHydration.test.tsx +61 -0
  249. package/tests/router/dataMutation.test.tsx +59 -0
  250. package/tests/router/fixtures/legacyRuntimeRouter.ts +10 -0
  251. package/tests/router/fixtures/router-gen.golden.txt +71 -0
  252. package/tests/router/fixtures/router-gen.oxlint.json +5 -0
  253. package/tests/router/flightSerialization.roundtrip.test.tsx +137 -0
  254. package/tests/router/generateRouteArtifacts.test.ts +106 -0
  255. package/tests/router/hooks.test.ts +14 -0
  256. package/tests/router/loaderBridge.test.ts +21 -0
  257. package/tests/router/prefetchLink.test.tsx +106 -59
  258. package/tests/router/prefetchLinkPreload.test.tsx +85 -0
  259. package/tests/router/register.test.ts +1 -39
  260. package/tests/router/routeTree.test.ts +51 -11
  261. package/tests/router/routerCompatibility.test.ts +245 -0
  262. package/tests/router/rsc.test.tsx +189 -0
  263. package/tests/router/rscPayloadRouterMatrix.test.ts +197 -0
  264. package/tests/router/slotUsageSanitizer.test.ts +23 -0
  265. package/tests/router/ssrPreload.test.ts +30 -0
  266. package/tests/router/tanstackTypes.test.ts +298 -1
  267. package/dist/esm/runtime/pluginCore.mjs +0 -14
  268. package/dist/esm-node/runtime/pluginCore.mjs +0 -15
  269. package/dist/types/runtime/pluginCore.d.ts +0 -21
  270. package/src/runtime/pluginCore.ts +0 -48
@@ -0,0 +1,76 @@
1
+ import type { RouteObject } from '@modern-js/runtime-utils/router';
2
+ import type { AnyRoute, RootRoute as TanstackRootRoute } from '@tanstack/react-router';
3
+ export type RouteParams = Record<string, string>;
4
+ type ModernLoader = (args: {
5
+ request: Request;
6
+ params: RouteParams;
7
+ context?: unknown;
8
+ }) => unknown | Promise<unknown>;
9
+ export type ModernShouldRevalidate = (args: {
10
+ currentParams: RouteParams;
11
+ currentUrl: URL;
12
+ nextParams: RouteParams;
13
+ nextUrl: URL;
14
+ defaultShouldRevalidate?: boolean;
15
+ }) => boolean | undefined;
16
+ export type TanstackLoaderContext = {
17
+ abortController?: AbortController;
18
+ cause?: string;
19
+ signal?: AbortSignal;
20
+ context?: {
21
+ request?: Request;
22
+ requestContext?: unknown;
23
+ };
24
+ location?: string | {
25
+ publicHref?: string;
26
+ href?: string;
27
+ url?: {
28
+ href?: string;
29
+ };
30
+ };
31
+ params?: RouteParams;
32
+ route?: {
33
+ id?: string;
34
+ };
35
+ };
36
+ export type RouteRevalidationState = {
37
+ currentParams?: RouteParams;
38
+ currentUrl?: URL;
39
+ };
40
+ export type ModernRouteObject = RouteObject & {
41
+ ErrorBoundary?: unknown;
42
+ HydrateFallback?: unknown;
43
+ action?: unknown;
44
+ clientData?: unknown;
45
+ component?: unknown;
46
+ config?: {
47
+ handle?: Record<string, unknown>;
48
+ } | unknown;
49
+ file?: string;
50
+ handle?: Record<string, unknown>;
51
+ hasAction?: boolean;
52
+ hasClientLoader?: boolean;
53
+ hasLoader?: boolean;
54
+ inValidSSRRoute?: boolean;
55
+ isClientComponent?: boolean;
56
+ lazyImport?: () => unknown;
57
+ loader?: ModernLoader;
58
+ loaderDeps?: unknown;
59
+ pendingComponent?: unknown;
60
+ shouldRevalidate?: ModernShouldRevalidate;
61
+ validateSearch?: unknown;
62
+ };
63
+ export type MutableTanstackRoute = AnyRoute & {
64
+ addChildren: (children: AnyRoute[]) => void;
65
+ id?: string;
66
+ options: {
67
+ component?: unknown;
68
+ };
69
+ };
70
+ export type TanstackRouteOptions = Record<string, unknown>;
71
+ export type TanstackRootRouteOptions = Record<string, unknown>;
72
+ export type ModernTanstackRootRoute = TanstackRootRoute;
73
+ export type RouteTreeOptions = {
74
+ rscPayloadRouter?: boolean;
75
+ };
76
+ export {};
@@ -1,9 +1 @@
1
- import type { RouteObject } from '@modern-js/runtime-utils/router';
2
- import type { AnyRouter, RootRoute as TanstackRootRoute } from '@tanstack/react-router';
3
- type ModernTanstackRootRoute = TanstackRootRoute;
4
- type RouteTreeOptions = {
5
- rscPayloadRouter?: boolean;
6
- };
7
- export declare function createRouteTreeFromRouteObjects(routes: RouteObject[], options?: RouteTreeOptions): ModernTanstackRootRoute;
8
- export declare function getModernRouteIdsFromMatches(router: AnyRouter): string[];
9
- export {};
1
+ export { createRouteTreeFromRouteObjects, getModernRouteIdsFromMatches, pickRouteModuleComponent, } from './routeTree/index';
@@ -4,11 +4,10 @@
4
4
  * `router: { framework: 'tanstack', createRoutes }` in modern.runtime.ts).
5
5
  *
6
6
  * The CLI plugin injects `{ name: 'router', path: '<pkg>/runtime/router' }`
7
- * for those entries, so the generated entry code value-imports `routerPlugin`
8
- * from here. That single import both installs the framework-resolving router
9
- * plugin of @modern-js/runtime AND registers the TanStack router provider
10
- * (the './register' side effect) — the registration can therefore never be
11
- * tree-shaken away from the entry that needs it.
7
+ * for those entries. This module creates a framework-resolving wrapper whose
8
+ * app-owned provider realm contains this module graph's TanStack factory.
12
9
  */
13
- import './register';
14
- export { routerPlugin } from '@modern-js/runtime/router/internal';
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,3 +1,2 @@
1
- import type React from 'react';
2
1
  import { type AnyCompositeComponent, type CompositeComponentProps } from './symbols';
3
- export declare function CompositeComponent<TComp extends AnyCompositeComponent>(props: CompositeComponentProps<TComp>): React.JSX.Element;
2
+ export declare function CompositeComponent<TComp extends AnyCompositeComponent>(props: CompositeComponentProps<TComp>): import("react").JSX.Element;
@@ -1,7 +1,7 @@
1
- export interface ReplayableStreamOptions {
1
+ interface ReplayableStreamOptions {
2
2
  signal?: AbortSignal;
3
3
  }
4
- export declare const REPLAYABLE_STREAM_MARKER: unique symbol;
4
+ declare const REPLAYABLE_STREAM_MARKER: unique symbol;
5
5
  export declare class ReplayableStream<T = Uint8Array> {
6
6
  private source;
7
7
  private options;
@@ -22,3 +22,4 @@ export declare class ReplayableStream<T = Uint8Array> {
22
22
  isReleased(): boolean;
23
23
  createReplayStream(): ReadableStream<T>;
24
24
  }
25
+ export {};
@@ -1,5 +1,4 @@
1
- import type React from 'react';
2
- import { type AnyRenderableServerComponent } from './symbols';
1
+ import type { AnyRenderableServerComponent } from './symbols';
3
2
  export declare function RscNodeRenderer({ data, }: {
4
3
  data: AnyRenderableServerComponent;
5
- }): React.JSX.Element;
4
+ }): import("react").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import type React from 'react';
2
- export type SlotImplementations = Record<string, unknown>;
2
+ type SlotImplementations = Record<string, unknown>;
3
3
  export declare function useSlotContext(): {
4
4
  implementations: SlotImplementations;
5
5
  strict: boolean;
@@ -9,3 +9,4 @@ export declare function SlotProvider({ children, implementations, strict, }: {
9
9
  implementations: SlotImplementations;
10
10
  strict?: boolean;
11
11
  }): React.JSX.Element;
12
+ export {};
@@ -1,4 +1,5 @@
1
1
  import { CompositeComponent } from './CompositeComponent';
2
+ import type { SerializedTanstackRscFlightValue } from './shared';
2
3
  import type { AnyCompositeComponent, RscSlotUsageEvent } from './symbols';
3
4
  export type { AnyCompositeComponent, AnyRenderableServerComponent, CompositeComponentProps, } from './symbols';
4
5
  export { CompositeComponent };
@@ -7,5 +8,6 @@ type SerializedRsc = {
7
8
  stream: ReadableStream<Uint8Array>;
8
9
  slotUsagesStream?: ReadableStream<RscSlotUsageEvent>;
9
10
  };
11
+ export declare function createTanstackRscValueFromFlight(serialized: SerializedTanstackRscFlightValue): AnyCompositeComponent;
10
12
  export declare function getTanstackRscSerializationAdapters(): import("@tanstack/router-core").SerializationAdapter<AnyCompositeComponent<Record<string, unknown>, import("react").ReactNode>, SerializedRsc, never>[];
11
13
  export declare const rscSerializationAdapter: typeof getTanstackRscSerializationAdapters;
@@ -0,0 +1,3 @@
1
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
2
+ export declare function serializeTanstackRscFlightValues(value: unknown, seen?: WeakMap<object, unknown>): unknown;
3
+ export declare function reviveTanstackRscFlightValues(value: unknown, seen?: WeakMap<object, unknown>): Promise<unknown>;
@@ -0,0 +1,6 @@
1
+ import type { ServerPayload } from '@modern-js/runtime/context';
2
+ export declare function shouldRedactServerError(status?: number): boolean;
3
+ export declare function serializePayloadError(error: unknown): unknown;
4
+ export declare function isSerializedNotFound(value: unknown): boolean;
5
+ export declare function toRouteErrors(payload: ServerPayload): Record<string, unknown>;
6
+ export declare function toRouteLoaderData(payload: ServerPayload): Record<string, unknown>;
@@ -0,0 +1,8 @@
1
+ import type { ServerPayload } from '@modern-js/runtime/context';
2
+ import { isAbsoluteUrl } from '../shared/isAbsoluteUrl';
3
+ export { isAbsoluteUrl };
4
+ type PayloadDecoder = (stream: ReadableStream<Uint8Array>) => Promise<unknown>;
5
+ export declare const payloadFetchCache: Map<string, Promise<ServerPayload>>;
6
+ export declare function createPayloadFetchKey(request: Request): string;
7
+ export declare function fetchTanstackRscPayload(request: Request): Promise<ServerPayload>;
8
+ export declare function __setTanstackRscPayloadDecoderForTests(decoder?: PayloadDecoder): void;
@@ -1,12 +1,6 @@
1
1
  import type { ServerPayload } from '@modern-js/runtime/context';
2
- type PayloadDecoder = (stream: ReadableStream<Uint8Array>) => Promise<unknown>;
3
- type TanstackPayloadRouterLike = {
4
- state?: {
5
- location?: unknown;
6
- matches?: unknown;
7
- statusCode?: unknown;
8
- };
9
- };
2
+ import type { TanstackPayloadRouterLike } from './payloadRoutes';
3
+ export { __setTanstackRscPayloadDecoderForTests } from './payloadFetch';
10
4
  type LoadRouteDataOptions = {
11
5
  hasClientLoader?: boolean;
12
6
  loadClientData: () => Promise<unknown>;
@@ -20,5 +14,3 @@ export declare function handleTanstackRscRedirect(headers: Headers, basename: st
20
14
  export declare function isTanstackRscPayloadNavigationEnabled(): boolean;
21
15
  export declare function loadTanstackRscPayload(request: Request): Promise<ServerPayload>;
22
16
  export declare function loadTanstackRscRouteData({ hasClientLoader, loadClientData, request, routeId, }: LoadRouteDataOptions): Promise<unknown>;
23
- export declare function __setTanstackRscPayloadDecoderForTests(decoder?: PayloadDecoder): void;
24
- export {};
@@ -0,0 +1,40 @@
1
+ import type { PayloadRoute, ServerPayload } from '@modern-js/runtime/context';
2
+ type RouterStaticData = {
3
+ modernRouteAction?: unknown;
4
+ modernRouteHandle?: unknown;
5
+ modernRouteHasAction?: unknown;
6
+ modernRouteHasClientLoader?: unknown;
7
+ modernRouteHasLoader?: unknown;
8
+ modernRouteId?: unknown;
9
+ modernRouteIsClientComponent?: unknown;
10
+ };
11
+ type RouterRouteLike = {
12
+ id?: unknown;
13
+ options?: {
14
+ index?: unknown;
15
+ path?: unknown;
16
+ staticData?: RouterStaticData;
17
+ };
18
+ parentRoute?: RouterRouteLike;
19
+ };
20
+ export type RouterMatchLike = {
21
+ error?: unknown;
22
+ id?: unknown;
23
+ loaderData?: unknown;
24
+ params?: unknown;
25
+ pathname?: unknown;
26
+ pathnameBase?: unknown;
27
+ route?: RouterRouteLike;
28
+ routeId?: unknown;
29
+ };
30
+ export type TanstackPayloadRouterLike = {
31
+ state?: {
32
+ location?: unknown;
33
+ matches?: unknown;
34
+ statusCode?: unknown;
35
+ };
36
+ };
37
+ export declare function toPlainLocation(location: unknown): ServerPayload['location'];
38
+ export declare function getRouteId(match: RouterMatchLike): string | undefined;
39
+ export declare function toPayloadRoute(match: RouterMatchLike): PayloadRoute | undefined;
40
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { ServerPayload } from '@modern-js/runtime/context';
2
+ import type { TanstackRouterWithServerSsr } from '../ssrTypes';
3
+ export declare const setTanstackRscServerPayload: (payload: ServerPayload) => void;
4
+ export declare const setTanstackRscRouter: (router: TanstackRouterWithServerSsr) => void;
5
+ export declare const getTanstackRscRouter: () => TanstackRouterWithServerSsr | undefined;
@@ -0,0 +1,18 @@
1
+ import type React from 'react';
2
+ import { type AnyCompositeComponent, type AnyRenderableServerComponent, type RscSlotUsageEvent } from './symbols';
3
+ export declare const TANSTACK_RSC_FLIGHT_VALUE = "__modernTanstackRsc";
4
+ export type SerializedTanstackRscFlightValue = {
5
+ [TANSTACK_RSC_FLIGHT_VALUE]: true;
6
+ kind: 'renderable' | 'composite';
7
+ slotUsagesStream?: ReadableStream<RscSlotUsageEvent>;
8
+ stream: ReadableStream<Uint8Array>;
9
+ };
10
+ export declare function isSerializedTanstackRscFlightValue(value: unknown): value is SerializedTanstackRscFlightValue;
11
+ export declare function EmptyFallback(): null;
12
+ type RenderSelectedTreeSource = AnyRenderableServerComponent | AnyCompositeComponent;
13
+ type RenderSelectedTreeOptions = {
14
+ getTree?: (() => unknown) | undefined;
15
+ missingTreeError: string;
16
+ };
17
+ export declare function renderSelectedTree(src: RenderSelectedTreeSource, { getTree, missingTreeError, }: RenderSelectedTreeOptions): React.ReactNode;
18
+ export {};
@@ -0,0 +1 @@
1
+ export declare function createTreeGetterFromFlightStream(stream: ReadableStream<Uint8Array>): () => any;
@@ -0,0 +1 @@
1
+ export declare function isAbsoluteUrl(value: string): boolean;
@@ -0,0 +1,7 @@
1
+ import type { AnyRouter } from '@tanstack/react-router';
2
+ import type { TanstackRouterWithServerSsr } from './ssrTypes';
3
+ export declare function waitForRouterSerialization(tanstackRouter: TanstackRouterWithServerSsr): Promise<void>;
4
+ export declare function routerManagedTagsToHtml(tags: unknown): string[];
5
+ export declare function createGetSsrHref(request: Request): string;
6
+ export declare function collectRouterErrors(tanstackRouter: AnyRouter): Record<string, unknown> | undefined;
7
+ export declare function attachServerSsrUtils(router: TanstackRouterWithServerSsr): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { TanstackRouterWithServerSsr } from './ssrTypes';
2
+ export declare function preloadMatchedRouteComponents(tanstackRouter: TanstackRouterWithServerSsr): Promise<void>;
@@ -0,0 +1,44 @@
1
+ import type { RequestContext } from '@modern-js/runtime-utils/node';
2
+ import type { AnyRouter } from '@tanstack/react-router';
3
+ export type ModernTanstackRouterContext = {
4
+ request: Request;
5
+ requestContext: RequestContext<Record<string, unknown>>;
6
+ };
7
+ export type RouterManagedTag = {
8
+ attrs?: Record<string, unknown>;
9
+ children?: unknown;
10
+ tag?: unknown;
11
+ };
12
+ export type RouterMatchWithError = {
13
+ error?: unknown;
14
+ route?: {
15
+ id?: unknown;
16
+ options?: RouterRouteOptions;
17
+ };
18
+ routeId?: unknown;
19
+ };
20
+ type RouterRouteOptions = {
21
+ component?: unknown;
22
+ errorComponent?: unknown;
23
+ notFoundComponent?: unknown;
24
+ pendingComponent?: unknown;
25
+ };
26
+ type RouterRouteWithOptions = {
27
+ options?: RouterRouteOptions;
28
+ };
29
+ export type TanstackRouterWithServerSsr = AnyRouter & {
30
+ resolveRedirect?: (redirect: Response) => Response;
31
+ routesById?: Record<string, RouterRouteWithOptions>;
32
+ serverSsr?: {
33
+ cleanup?: () => void;
34
+ dehydrate?: () => Promise<void> | void;
35
+ isSerializationFinished?: () => boolean;
36
+ onSerializationFinished?: (listener: () => void) => void;
37
+ takeBufferedScripts?: () => unknown;
38
+ };
39
+ state: AnyRouter['state'] & {
40
+ matches?: unknown;
41
+ redirect?: Response;
42
+ };
43
+ };
44
+ export {};
@@ -1,5 +1,5 @@
1
+ import { type InternalRouterRuntimeState } from '@modern-js/runtime/context';
1
2
  import type { AnyRouter } from '@tanstack/react-router';
2
- import type { InternalRouterRuntimeState } from './types';
3
3
  /**
4
4
  * Router runtime state as published by the TanStack router provider into the
5
5
  * runtime-context extension slot.
@@ -0,0 +1,14 @@
1
+ import type { AnyRouter } from '@tanstack/react-router';
2
+ import type { SubmitOptions, SubmitTarget } from './formData';
3
+ export declare class RouteActionResponseError<TData = unknown> extends Error {
4
+ readonly response: Response;
5
+ readonly data: TData;
6
+ constructor(response: Response, data: TData);
7
+ }
8
+ export declare function submitRouteAction({ router, target, options, isFetcher, onInvalidateStart, }: {
9
+ router: AnyRouter;
10
+ target: SubmitTarget;
11
+ options?: SubmitOptions;
12
+ isFetcher?: boolean;
13
+ onInvalidateStart?: () => void;
14
+ }): Promise<any>;
@@ -1,18 +1,12 @@
1
- import type { RouterFramework } from '@modern-js/runtime/context';
1
+ import type { ModernRoute } from '@modern-js/runtime/context';
2
2
  import type { RouteObject } from '@modern-js/runtime-utils/router';
3
- import type { NestedRoute, PageRoute } from '@modern-js/types';
4
3
  import type React from 'react';
5
- export type { BuiltInRouterFramework, InternalRouterRuntimeState, InternalRouterServerSnapshot, RouterFramework, RouterRouteMatchSnapshot, RouterServerPrepareResult, } from '@modern-js/runtime/context';
6
- /**
7
- * TanStack-specific router config. Unlike the react-router provider config,
8
- * this intentionally has no `oldVersion`/`future` fields — those are
9
- * react-router-only knobs with no meaning here.
10
- */
4
+ export type { InternalRouterServerSnapshot, ModernRoute, RouterFramework, } from '@modern-js/runtime/context';
5
+ /** TanStack-specific router config. */
11
6
  export type RouterConfig = {
12
- framework?: RouterFramework;
13
7
  routesConfig: {
14
8
  globalApp?: React.ComponentType<any>;
15
- routes?: (NestedRoute | PageRoute)[];
9
+ routes?: ModernRoute[];
16
10
  };
17
11
  serverBase?: string[];
18
12
  supportHtml5History?: boolean;
@@ -1,36 +1,16 @@
1
1
  import type { RouteObject } from '@modern-js/runtime-utils/router';
2
- import type { NestedRoute, PageRoute, SSRMode } from '@modern-js/types';
3
2
  import React from 'react';
3
+ import type { ModernRoute } from './types';
4
+ export type SSRMode = 'string' | 'stream';
4
5
  type RouterConfig = {
5
6
  routesConfig: {
6
7
  globalApp?: React.ComponentType<any>;
7
- routes?: (NestedRoute | PageRoute)[];
8
+ routes?: ModernRoute[];
8
9
  };
9
10
  };
10
- type GlobalAppProps = {
11
- Component: React.ComponentType;
12
- [key: string]: unknown;
13
- };
14
- export type ModernRouteObject = RouteObject & {
15
- isClientComponent?: boolean;
16
- hasClientLoader?: boolean;
17
- hasLoader?: boolean;
18
- hasAction?: boolean;
19
- inValidSSRRoute?: boolean;
20
- lazyImport?: () => Promise<{
21
- default: React.ComponentType;
22
- }>;
23
- };
24
- export declare function getRouteObjects(routes: (NestedRoute | PageRoute)[], { globalApp, ssrMode, props, }: {
25
- globalApp?: React.ComponentType<GlobalAppProps>;
26
- ssrMode?: SSRMode;
27
- props?: Record<string, unknown>;
28
- }): RouteObject[];
29
- export declare function createRouteObjectsFromConfig({ routesConfig, props, ssrMode, }: {
11
+ export declare function createTanstackRouteObjectsFromConfig({ routesConfig, }: {
30
12
  routesConfig: RouterConfig['routesConfig'];
31
13
  props?: Record<string, unknown>;
32
14
  ssrMode?: SSRMode;
33
15
  }): RouteObject[] | null;
34
- export declare const urlJoin: (...parts: string[]) => string;
35
- export declare function standardSlash(str: string): string;
36
16
  export {};
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "modern.js",
19
19
  "tanstack-router"
20
20
  ],
21
- "version": "3.5.0-ultramodern.9",
21
+ "version": "3.5.0-ultramodern.91",
22
22
  "engines": {
23
23
  "node": ">=20"
24
24
  },
@@ -55,6 +55,20 @@
55
55
  "module": "./dist/esm/runtime/router.mjs"
56
56
  },
57
57
  "default": "./dist/esm/runtime/router.mjs"
58
+ },
59
+ "./runtime/rsc/client": {
60
+ "types": "./dist/types/runtime/rsc/client.d.ts",
61
+ "node": {
62
+ "module": "./dist/esm/runtime/rsc/client.mjs"
63
+ },
64
+ "default": "./dist/esm/runtime/rsc/client.mjs"
65
+ },
66
+ "./runtime/rsc/server": {
67
+ "types": "./dist/types/runtime/rsc/server.d.ts",
68
+ "node": {
69
+ "module": "./dist/esm/runtime/rsc/server.mjs"
70
+ },
71
+ "default": "./dist/esm/runtime/rsc/server.mjs"
58
72
  }
59
73
  },
60
74
  "typesVersions": {
@@ -70,37 +84,44 @@
70
84
  ],
71
85
  "runtime/router": [
72
86
  "./dist/types/runtime/router.d.ts"
87
+ ],
88
+ "runtime/rsc/client": [
89
+ "./dist/types/runtime/rsc/client.d.ts"
90
+ ],
91
+ "runtime/rsc/server": [
92
+ "./dist/types/runtime/rsc/server.d.ts"
73
93
  ]
74
94
  }
75
95
  },
76
96
  "dependencies": {
97
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.91",
98
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.5.0-ultramodern.91",
99
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.91",
100
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.91",
77
101
  "@swc/helpers": "^0.5.23",
78
- "@tanstack/react-router": "1.170.16",
79
- "@tanstack/router-core": "1.171.13",
80
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.9",
81
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.5.0-ultramodern.9",
82
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.9",
83
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.9"
102
+ "@tanstack/react-router": "1.170.17",
103
+ "@tanstack/router-core": "1.171.14",
104
+ "react-server-dom-rspack": "0.0.2"
84
105
  },
85
106
  "peerDependencies": {
86
- "@modern-js/runtime": "3.5.0-ultramodern.9",
107
+ "@modern-js/app-tools": "3.5.0-ultramodern.91",
108
+ "@modern-js/runtime": "3.5.0-ultramodern.91",
87
109
  "react": "^19.2.7",
88
110
  "react-dom": "^19.2.7"
89
111
  },
90
112
  "devDependencies": {
91
- "@rslib/core": "0.23.1",
113
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.5.0-ultramodern.91",
114
+ "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.5.0-ultramodern.91",
115
+ "@rslib/core": "0.23.2",
116
+ "@scripts/rstest-config": "2.66.0",
92
117
  "@tanstack/history": "1.162.0",
93
- "@testing-library/dom": "^10.4.1",
94
118
  "@testing-library/react": "^16.3.2",
95
- "@types/node": "^26.0.1",
119
+ "@types/node": "^26.1.1",
96
120
  "@types/react": "^19.2.17",
97
121
  "@types/react-dom": "^19.2.3",
98
- "@typescript/native-preview": "7.0.0-dev.20260628.1",
122
+ "@typescript/native-preview": "7.0.0-dev.20260707.2",
99
123
  "react": "^19.2.7",
100
- "react-dom": "^19.2.7",
101
- "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.5.0-ultramodern.9",
102
- "@scripts/rstest-config": "2.66.0",
103
- "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.5.0-ultramodern.9"
124
+ "react-dom": "^19.2.7"
104
125
  },
105
126
  "sideEffects": [
106
127
  "./src/runtime/register.ts",
@@ -117,7 +138,6 @@
117
138
  "./dist/cjs/runtime/router.js"
118
139
  ],
119
140
  "publishConfig": {
120
- "registry": "https://registry.npmjs.org/",
121
141
  "access": "public"
122
142
  },
123
143
  "scripts": {
package/rstest.config.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import path from 'node:path';
1
2
  import type { ProjectConfig } from '@rstest/core';
2
3
  import { withTestPreset } from '@scripts/rstest-config';
3
4
 
@@ -23,27 +24,49 @@ export default {
23
24
  name: 'plugin-tanstack-node',
24
25
  testEnvironment: 'node',
25
26
  include: [
27
+ 'tests/realm-isolation.test.ts',
26
28
  'tests/router/cli.test.ts',
27
29
  'tests/router/fastDefaults.test.ts',
30
+ 'tests/router/flightSerialization.roundtrip.test.tsx',
31
+ 'tests/router/generateRouteArtifacts.test.ts',
28
32
  'tests/router/hooks.test.ts',
29
33
  'tests/router/loaderBridge.test.ts',
30
34
  'tests/router/packageSurface.test.ts',
31
35
  'tests/router/preloadRedirect.test.ts',
32
36
  'tests/router/register.test.ts',
33
37
  'tests/router/routeHooks.test.ts',
38
+ 'tests/router/rscPayloadRouterMatrix.test.ts',
34
39
  'tests/router/rsc.test.tsx',
40
+ 'tests/router/slotUsageSanitizer.test.ts',
41
+ 'tests/router/ssrPreload.test.ts',
35
42
  'tests/router/tanstackTypes.test.ts',
36
43
  'tests/router/routeTree.test.ts',
37
44
  ],
38
45
  extends: commonConfig,
39
46
  }),
47
+ withTestPreset({
48
+ name: 'plugin-tanstack-router-compatibility',
49
+ testEnvironment: 'node',
50
+ include: ['tests/router/routerCompatibility.test.ts'],
51
+ resolve: {
52
+ alias: {
53
+ '@modern-js/runtime/router/internal': path.resolve(
54
+ __dirname,
55
+ 'tests/router/fixtures/legacyRuntimeRouter.ts',
56
+ ),
57
+ },
58
+ },
59
+ extends: commonConfig,
60
+ }),
40
61
  withTestPreset({
41
62
  name: 'plugin-tanstack-client',
42
63
  testEnvironment: 'happy-dom',
43
64
  include: [
65
+ 'tests/router/clientHydration.test.tsx',
44
66
  'tests/router/dataMutation.test.tsx',
45
67
  'tests/router/hydrationBoundary.test.tsx',
46
68
  'tests/router/prefetchLink.test.tsx',
69
+ 'tests/router/prefetchLinkPreload.test.tsx',
47
70
  ],
48
71
  extends: commonConfig,
49
72
  }),