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

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
@@ -37,123 +37,18 @@ const url_namespaceObject = require("@modern-js/runtime-utils/url");
37
37
  const react_router_namespaceObject = require("@tanstack/react-router");
38
38
  const external_react_namespaceObject = require("react");
39
39
  const external_basepathRewrite_js_namespaceObject = require("./basepathRewrite.js");
40
+ const external_blockingSubscribe_js_namespaceObject = require("./blockingSubscribe.js");
41
+ const external_clientBasepath_js_namespaceObject = require("./clientBasepath.js");
42
+ const external_clientHydration_js_namespaceObject = require("./clientHydration.js");
40
43
  const external_hooks_js_namespaceObject = require("./hooks.js");
41
44
  const external_hydrationBoundary_js_namespaceObject = require("./hydrationBoundary.js");
42
45
  const external_lifecycle_js_namespaceObject = require("./lifecycle.js");
43
- const external_outlet_js_namespaceObject = require("./outlet.js");
44
- const external_pluginCore_js_namespaceObject = require("./pluginCore.js");
46
+ const external_pluginShared_js_namespaceObject = require("./pluginShared.js");
45
47
  const external_prefetchLink_js_namespaceObject = require("./prefetchLink.js");
46
48
  const external_routeHooks_js_namespaceObject = require("./routeHooks.js");
47
49
  const external_routeTree_js_namespaceObject = require("./routeTree.js");
48
50
  const client_js_namespaceObject = require("./rsc/client.js");
49
51
  const external_types_js_namespaceObject = require("./types.js");
50
- const external_utils_js_namespaceObject = require("./utils.js");
51
- const BLOCKING_SUBSCRIBE_SYMBOL = Symbol.for('@modern-js/plugin-tanstack:blocking-subscribe');
52
- const BLOCKING_STATE_SYMBOL = Symbol.for('@modern-js/plugin-tanstack:blocking-state');
53
- function normalizeBase(b) {
54
- if (b.length > 1 && b.endsWith('/')) return b.slice(0, -1);
55
- return b || '/';
56
- }
57
- function isSegmentPrefix(pathname, base) {
58
- const b = normalizeBase(base);
59
- const p = pathname || '/';
60
- return p === b || p.startsWith(`${b}/`);
61
- }
62
- function wrapRouterSubscribeWithBlockState(router, getBlockNavState) {
63
- if (!router || 'object' != typeof router) return;
64
- const target = router;
65
- target[BLOCKING_STATE_SYMBOL] = getBlockNavState;
66
- if (target[BLOCKING_SUBSCRIBE_SYMBOL] || 'function' != typeof target.subscribe) return;
67
- const originSubscribe = target.subscribe.bind(target);
68
- target.subscribe = (eventType, listener)=>{
69
- const wrappedListener = (...args)=>{
70
- const blockRoute = target[BLOCKING_STATE_SYMBOL]?.() || false;
71
- if (blockRoute) return;
72
- return listener(...args);
73
- };
74
- return originSubscribe(eventType, wrappedListener);
75
- };
76
- target[BLOCKING_SUBSCRIBE_SYMBOL] = true;
77
- }
78
- const routerHydrationRecords = new WeakMap();
79
- const routeModulesKey = '_routeModules';
80
- function pickRouteModuleComponent(routeModule, seen = new Set()) {
81
- if ('function' == typeof routeModule || routeModule && 'object' == typeof routeModule && '$$typeof' in routeModule) return routeModule;
82
- if (!routeModule || 'object' != typeof routeModule) return;
83
- if (seen.has(routeModule)) return;
84
- seen.add(routeModule);
85
- const module = routeModule;
86
- for (const candidate of [
87
- module.default,
88
- module.Component
89
- ]){
90
- const component = pickRouteModuleComponent(candidate, seen);
91
- if (component) return component;
92
- }
93
- }
94
- function getCachedRouteModule(routeId) {
95
- if ("u" < typeof window) return;
96
- return window[routeModulesKey]?.[routeId];
97
- }
98
- function preloadHydratedRouteComponents(router) {
99
- const preloadableRouter = router;
100
- const routesById = preloadableRouter.routesById || {};
101
- const matches = preloadableRouter.stores.matches.get();
102
- return Promise.all(matches.map((match)=>{
103
- if (void 0 === match.routeId || '' === match.routeId) return;
104
- const route = routesById[match.routeId];
105
- const component = route?.options?.component;
106
- const preload = component?.load || component?.preload;
107
- if ('function' != typeof preload) return;
108
- return Promise.resolve(preload.call(component)).then((routeModule)=>{
109
- const modernRouteId = route?.options?.staticData?.modernRouteId;
110
- const cachedRouteModule = 'string' == typeof modernRouteId && '' !== modernRouteId ? getCachedRouteModule(modernRouteId) : void 0;
111
- const resolvedComponent = pickRouteModuleComponent(cachedRouteModule ?? routeModule);
112
- if (void 0 !== resolvedComponent && 'string' == typeof modernRouteId && '' !== modernRouteId) route.options.component = (0, external_outlet_js_namespaceObject.withModernRouteMatchContext)(resolvedComponent, modernRouteId);
113
- });
114
- })).then(()=>void 0);
115
- }
116
- function hydrateTanstackRouter(router) {
117
- return import("@tanstack/react-router/ssr/client").then(({ hydrate })=>hydrate(router));
118
- }
119
- function getTanstackSsrHydrationRecord(router) {
120
- const existingHydrationRecord = routerHydrationRecords.get(router);
121
- if (void 0 !== existingHydrationRecord) return existingHydrationRecord;
122
- const hydrationRecord = {
123
- promise: Promise.resolve(),
124
- status: 'pending'
125
- };
126
- routerHydrationRecords.set(router, hydrationRecord);
127
- try {
128
- hydrationRecord.promise = hydrateTanstackRouter(router).then((value)=>preloadHydratedRouteComponents(router).then(()=>value)).then((value)=>{
129
- hydrationRecord.status = 'fulfilled';
130
- return value;
131
- }, (error)=>{
132
- hydrationRecord.status = 'rejected';
133
- hydrationRecord.error = error;
134
- throw error;
135
- });
136
- } catch (error) {
137
- hydrationRecord.status = 'rejected';
138
- hydrationRecord.error = error;
139
- hydrationRecord.promise = Promise.reject(error);
140
- hydrationRecord.promise.catch(()=>{});
141
- }
142
- return hydrationRecord;
143
- }
144
- function getTanstackSsrHydrationPromise(router) {
145
- return getTanstackSsrHydrationRecord(router).promise;
146
- }
147
- function hasTanstackSsrHydrationRecord(router) {
148
- return routerHydrationRecords.has(router);
149
- }
150
- function ModernRouterClient({ router }) {
151
- const hydrationRecord = getTanstackSsrHydrationRecord(router);
152
- if ('rejected' === hydrationRecord.status) throw hydrationRecord.error;
153
- return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
154
- router: router
155
- });
156
- }
157
52
  const tanstackRouterPlugin = (userConfig = {})=>{
158
53
  const plugin = {
159
54
  name: '@modern-js/plugin-router-tanstack',
@@ -164,16 +59,13 @@ const tanstackRouterPlugin = (userConfig = {})=>{
164
59
  let cachedRouteTree = null;
165
60
  let cachedRouter = null;
166
61
  let cachedRouterBasepath = null;
167
- const getMergedConfig = ()=>(0, external_pluginCore_js_namespaceObject.getMergedRouterConfig)(api, userConfig);
62
+ const getMergedConfig = ()=>(0, external_pluginShared_js_namespaceObject.getMergedRouterConfig)(api, userConfig);
168
63
  const getRouteObjects = ()=>{
169
64
  if (void 0 !== cachedRouteObjects) return cachedRouteObjects;
170
- const mergedConfig = getMergedConfig();
171
- const { createRoutes } = mergedConfig;
172
- const finalRouteConfig = (0, external_pluginCore_js_namespaceObject.getFinalRouteConfig)(mergedConfig);
173
- const routeObjects = createRoutes ? createRoutes() : (0, external_utils_js_namespaceObject.createRouteObjectsFromConfig)({
174
- routesConfig: finalRouteConfig
175
- }) || [];
176
- cachedRouteObjects = hooks.modifyRoutes.call(routeObjects);
65
+ cachedRouteObjects = (0, external_pluginShared_js_namespaceObject.createTanstackRouteObjects)({
66
+ hooks,
67
+ routeConfig: (0, external_pluginShared_js_namespaceObject.getTanstackRouteConfig)(api, userConfig)
68
+ });
177
69
  return cachedRouteObjects;
178
70
  };
179
71
  const getRouteTree = ()=>{
@@ -187,13 +79,13 @@ const tanstackRouterPlugin = (userConfig = {})=>{
187
79
  };
188
80
  const selectBasePath = (pathname)=>{
189
81
  const { serverBase = [] } = getMergedConfig();
190
- const match = serverBase.find((baseUrl)=>isSegmentPrefix(pathname, baseUrl));
82
+ const match = serverBase.find((baseUrl)=>(0, external_clientBasepath_js_namespaceObject.isSegmentPrefix)(pathname, baseUrl));
191
83
  return match || '/';
192
84
  };
193
85
  const getClientBasename = (runtimeContext)=>{
194
86
  const { basename = '' } = getMergedConfig();
195
87
  const baseUrl = selectBasePath(location.pathname).replace(/^\/*/, '/');
196
- return '/' === baseUrl ? (0, external_utils_js_namespaceObject.urlJoin)(baseUrl, runtimeContext._internalRouterBaseName || basename || '') : baseUrl;
88
+ return '/' === baseUrl ? (0, external_pluginShared_js_namespaceObject.joinBasename)(baseUrl, runtimeContext._internalRouterBaseName || basename || '') : baseUrl;
197
89
  };
198
90
  const getRouter = (runtimeContext, _basename)=>{
199
91
  const routeTree = getRouteTree();
@@ -207,7 +99,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
207
99
  };
208
100
  hooks.onBeforeCreateRouter.call(lifecycleContext);
209
101
  if (cachedRouter && cachedRouterBasepath === _basename) {
210
- wrapRouterSubscribeWithBlockState(cachedRouter, runtimeContext.unstable_getBlockNavState);
102
+ (0, external_blockingSubscribe_js_namespaceObject.wrapRouterSubscribeWithBlockState)(cachedRouter, runtimeContext.unstable_getBlockNavState);
211
103
  hooks.onAfterCreateRouter.call({
212
104
  ...lifecycleContext,
213
105
  router: cachedRouter,
@@ -220,8 +112,12 @@ const tanstackRouterPlugin = (userConfig = {})=>{
220
112
  const history = supportHtml5History ? (0, react_router_namespaceObject.createBrowserHistory)() : (0, react_router_namespaceObject.createHashHistory)();
221
113
  const rewrite = (0, external_basepathRewrite_js_namespaceObject.createModernBasepathRewrite)(_basename);
222
114
  const serializationAdapters = (0, context_namespaceObject.getGlobalEnableRsc)() ? (0, client_js_namespaceObject.getTanstackRscSerializationAdapters)() : void 0;
115
+ const routerFastDefaults = (0, external_types_js_namespaceObject.getModernTanstackRouterFastDefaults)(mergedConfig);
223
116
  cachedRouter = (0, react_router_namespaceObject.createRouter)({
224
- ...(0, external_types_js_namespaceObject.getModernTanstackRouterFastDefaults)(mergedConfig),
117
+ ...routerFastDefaults,
118
+ ...serializationAdapters ? {
119
+ defaultStructuralSharing: false
120
+ } : {},
225
121
  routeTree,
226
122
  basepath: '/',
227
123
  rewrite,
@@ -232,7 +128,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
232
128
  } : {}
233
129
  });
234
130
  cachedRouterBasepath = _basename;
235
- wrapRouterSubscribeWithBlockState(cachedRouter, runtimeContext.unstable_getBlockNavState);
131
+ (0, external_blockingSubscribe_js_namespaceObject.wrapRouterSubscribeWithBlockState)(cachedRouter, runtimeContext.unstable_getBlockNavState);
236
132
  hooks.onAfterCreateRouter.call({
237
133
  ...lifecycleContext,
238
134
  router: cachedRouter,
@@ -263,7 +159,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
263
159
  if (hasSSRBootstrap && getRouteObjects().length > 0) {
264
160
  const runtimeContext = context;
265
161
  const router = getRouter(runtimeContext, getClientBasename(runtimeContext));
266
- if (null != router) return getTanstackSsrHydrationPromise(router).then(()=>void 0);
162
+ if (null != router) return (0, external_clientHydration_js_namespaceObject.getTanstackSsrHydrationPromise)(router).then(()=>void 0);
267
163
  }
268
164
  });
269
165
  api.wrapRoot((App)=>{
@@ -292,7 +188,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
292
188
  basename: _basename,
293
189
  router
294
190
  };
295
- const hasSSRBootstrap = "u" > typeof window && (Boolean(window.$_TSR) || hasTanstackSsrHydrationRecord(router));
191
+ const hasSSRBootstrap = "u" > typeof window && (Boolean(window.$_TSR) || (0, external_clientHydration_js_namespaceObject.hasTanstackSsrHydrationRecord)(router));
296
192
  const needsRouterClient = hasSSRBootstrap;
297
193
  if (needsRouterClient) hooks.onBeforeHydrateRouter.call({
298
194
  ...lifecycleContext,
@@ -300,7 +196,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
300
196
  router,
301
197
  runtimeContext: runtimeState
302
198
  });
303
- const RouterContent = needsRouterClient ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ModernRouterClient, {
199
+ const RouterContent = needsRouterClient ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_clientHydration_js_namespaceObject.ModernRouterClient, {
304
200
  router: router
305
201
  }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
306
202
  router: router
@@ -42,138 +42,43 @@ const external_basepathRewrite_js_namespaceObject = require("./basepathRewrite.j
42
42
  const external_hooks_js_namespaceObject = require("./hooks.js");
43
43
  const external_hydrationBoundary_js_namespaceObject = require("./hydrationBoundary.js");
44
44
  const external_lifecycle_js_namespaceObject = require("./lifecycle.js");
45
- const external_pluginCore_js_namespaceObject = require("./pluginCore.js");
45
+ const external_pluginShared_js_namespaceObject = require("./pluginShared.js");
46
46
  const external_routeTree_js_namespaceObject = require("./routeTree.js");
47
47
  const payloadRouter_js_namespaceObject = require("./rsc/payloadRouter.js");
48
+ const payloadStorage_js_namespaceObject = require("./rsc/payloadStorage.js");
49
+ const external_ssrManagedTags_js_namespaceObject = require("./ssrManagedTags.js");
50
+ const external_ssrPreload_js_namespaceObject = require("./ssrPreload.js");
48
51
  const external_types_js_namespaceObject = require("./types.js");
49
- const external_utils_js_namespaceObject = require("./utils.js");
50
- const setTanstackRscServerPayload = (payload)=>{
51
- const storageContext = node_namespaceObject.storage.useContext?.();
52
- if (storageContext) storageContext.serverPayload = payload;
53
- };
54
- function isPromiseLike(value) {
55
- return Boolean(value && 'function' == typeof value.then);
56
- }
57
- function isPreloadableRouteComponent(component) {
58
- if (!component || 'function' != typeof component) return false;
59
- const preloadable = component;
60
- return 'function' == typeof preloadable.load || 'function' == typeof preloadable.preload;
61
- }
62
- function isReactLazyRouteComponent(component) {
63
- return null != component && 'object' == typeof component && 'function' == typeof component._init && '_payload' in component;
64
- }
65
- async function preloadReactLazyRouteComponent(component) {
66
- try {
67
- component._init?.(component._payload);
68
- } catch (thrown) {
69
- if (!isPromiseLike(thrown)) throw thrown;
70
- await thrown;
71
- component._init?.(component._payload);
72
- }
73
- }
74
- async function preloadRouteComponent(component) {
75
- if (isReactLazyRouteComponent(component)) return void await preloadReactLazyRouteComponent(component);
76
- if (!isPreloadableRouteComponent(component)) return;
77
- if ('function' == typeof component.load) return void await component.load({});
78
- await component.preload?.({});
79
- }
80
- async function preloadMatchedRouteComponents(tanstackRouter) {
81
- const matches = Array.isArray(tanstackRouter.state.matches) ? tanstackRouter.state.matches : [];
82
- const routesById = tanstackRouter.routesById || {};
83
- await Promise.all(matches.map(async (match)=>{
84
- const routeId = 'string' == typeof match.routeId ? match.routeId : 'string' == typeof match.route?.id ? match.route.id : void 0;
85
- const route = routeId ? routesById[routeId] : match.route;
86
- const options = route?.options;
87
- if (!options) return;
88
- await Promise.all([
89
- preloadRouteComponent(options.component),
90
- preloadRouteComponent(options.pendingComponent),
91
- preloadRouteComponent(options.errorComponent),
92
- preloadRouteComponent(options.notFoundComponent)
93
- ]);
94
- }));
95
- }
96
- async function waitForRouterSerialization(tanstackRouter) {
97
- const serverSsr = tanstackRouter.serverSsr;
98
- if (!serverSsr || 'function' != typeof serverSsr.onSerializationFinished || serverSsr.isSerializationFinished?.()) return;
99
- await new Promise((resolve)=>{
100
- serverSsr.onSerializationFinished?.(resolve);
101
- });
102
- }
103
- function htmlEscapeAttr(value) {
104
- return value.replace(/&/g, '&amp;').replace(/"/g, '&quot;');
105
- }
106
- function routerManagedTagToHtml(tag) {
107
- if (!tag || 'object' != typeof tag) return '';
108
- const managedTag = tag;
109
- if (!managedTag || "script" !== managedTag.tag) return '';
110
- const attrs = managedTag.attrs || {};
111
- const attrsStr = Object.entries(attrs).filter(([, v])=>null != v && false !== v).map(([k, v])=>{
112
- const name = 'className' === k ? 'class' : k;
113
- if (true === v) return name;
114
- return `${name}="${htmlEscapeAttr(String(v))}"`;
115
- }).join(' ');
116
- const open = attrsStr.length ? `<script ${attrsStr}>` : "<script>";
117
- const children = 'string' == typeof managedTag.children ? managedTag.children : '';
118
- return `${open}${children}</script>`;
119
- }
120
- function routerManagedTagsToHtml(tags) {
121
- const normalizedTags = Array.isArray(tags) ? tags : [
122
- tags
123
- ];
124
- return normalizedTags.map(routerManagedTagToHtml).filter(Boolean);
125
- }
126
- function createGetSsrHref(request) {
127
- const url = new URL(request.url);
128
- return `${url.pathname}${url.search}${url.hash}`;
129
- }
130
- function collectRouterErrors(tanstackRouter) {
131
- const state = tanstackRouter.state;
132
- const matches = Array.isArray(state.matches) ? state.matches : [];
133
- const errors = matches.reduce((acc, match)=>{
134
- if (!match.error) return acc;
135
- const routeId = 'string' == typeof match.routeId ? match.routeId : 'string' == typeof match.route?.id ? match.route.id : `match-${Object.keys(acc).length}`;
136
- acc[routeId] = match.error;
137
- return acc;
138
- }, {});
139
- return Object.keys(errors).length > 0 ? errors : void 0;
140
- }
141
- async function attachServerSsrUtils(router) {
142
- const { attachRouterServerSsrUtils } = await import("@tanstack/router-core/ssr/server");
143
- attachRouterServerSsrUtils({
144
- router,
145
- manifest: void 0
146
- });
147
- }
148
52
  const tanstackRouterPlugin = (userConfig = {})=>{
149
53
  const plugin = {
150
54
  name: '@modern-js/plugin-router-tanstack',
151
55
  registryHooks: external_hooks_js_namespaceObject.routerProviderRegistryHooks,
152
56
  setup: (api)=>{
153
57
  api.onBeforeRender(async (context, interrupt)=>{
154
- const mergedConfig = (0, external_pluginCore_js_namespaceObject.getMergedRouterConfig)(api, userConfig);
58
+ const routeConfig = (0, external_pluginShared_js_namespaceObject.getTanstackRouteConfig)(api, userConfig);
59
+ const { mergedConfig } = routeConfig;
155
60
  const serializationAdapters = (0, context_namespaceObject.getGlobalEnableRsc)() ? (await import("./rsc/server.js")).getTanstackRscSerializationAdapters() : void 0;
156
61
  const enableRsc = (0, context_namespaceObject.getGlobalEnableRsc)();
157
- const { basename = '', createRoutes } = mergedConfig;
158
- const finalRouteConfig = (0, external_pluginCore_js_namespaceObject.getFinalRouteConfig)(mergedConfig);
159
- if (!finalRouteConfig.routes && !createRoutes) return;
62
+ const { basename = '' } = mergedConfig;
63
+ if (!routeConfig.hasConfiguredRoutes) return;
160
64
  const hooks = api.getHooks();
161
65
  await hooks.onBeforeCreateRoutes.call(context);
162
- const routeObjects = createRoutes ? createRoutes() : (0, external_utils_js_namespaceObject.createRouteObjectsFromConfig)({
163
- routesConfig: finalRouteConfig,
66
+ const modifiedRouteObjects = (0, external_pluginShared_js_namespaceObject.createTanstackRouteObjects)({
67
+ hooks,
68
+ routeConfig,
164
69
  ssrMode: context.ssrContext?.mode
165
- }) || [];
166
- const modifiedRouteObjects = hooks.modifyRoutes.call(routeObjects);
70
+ });
167
71
  if (!modifiedRouteObjects.length) return;
168
72
  const { request, nonce, baseUrl, loaderFailureMode = 'errorBoundary' } = context.ssrContext;
169
- const _basename = '/' === baseUrl ? (0, external_utils_js_namespaceObject.urlJoin)(baseUrl, basename || '') : baseUrl;
170
- const initialHref = createGetSsrHref(request.raw);
171
- const isRSCNavigation = enableRsc && 'true' === request.raw.headers.get('x-rsc-tree');
73
+ const _basename = '/' === baseUrl ? (0, external_pluginShared_js_namespaceObject.joinBasename)(baseUrl, basename || '') : baseUrl;
74
+ const rawRequest = request.raw;
75
+ const initialHref = (0, external_ssrManagedTags_js_namespaceObject.createGetSsrHref)(rawRequest);
76
+ const isRSCNavigation = enableRsc && 'true' === rawRequest.headers.get('x-rsc-tree');
172
77
  const requestContext = (0, node_namespaceObject.createRequestContext)(context.ssrContext?.loaderContext);
173
78
  const controller = new AbortController();
174
- const ssrRequest = new Request(request.raw.url, {
79
+ const ssrRequest = new Request(rawRequest.url, {
175
80
  method: 'GET',
176
- headers: request.raw.headers,
81
+ headers: rawRequest.headers,
177
82
  signal: controller.signal
178
83
  });
179
84
  const routerContext = {
@@ -201,7 +106,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
201
106
  history,
202
107
  basepath: '/',
203
108
  rewrite,
204
- origin: new URL(request.raw.url).origin,
109
+ origin: new URL(rawRequest.url).origin,
205
110
  ssr: {
206
111
  nonce
207
112
  },
@@ -211,7 +116,8 @@ const tanstackRouterPlugin = (userConfig = {})=>{
211
116
  } : {}
212
117
  });
213
118
  const serverRouter = tanstackRouter;
214
- await attachServerSsrUtils(serverRouter);
119
+ if (enableRsc) (0, payloadStorage_js_namespaceObject.setTanstackRscRouter)(serverRouter);
120
+ await (0, external_ssrManagedTags_js_namespaceObject.attachServerSsrUtils)(serverRouter);
215
121
  const end = (0, time_namespaceObject.time)();
216
122
  try {
217
123
  await tanstackRouter.load({
@@ -228,25 +134,25 @@ const tanstackRouterPlugin = (userConfig = {})=>{
228
134
  } catch {}
229
135
  return interrupt(isRSCNavigation ? (0, payloadRouter_js_namespaceObject.handleTanstackRscRedirect)(resolved.headers, _basename, resolved.status) : resolved);
230
136
  }
231
- const routerErrors = collectRouterErrors(tanstackRouter);
137
+ const routerErrors = (0, external_ssrManagedTags_js_namespaceObject.collectRouterErrors)(tanstackRouter);
232
138
  if (routerErrors && 'clientRender' === loaderFailureMode) {
233
- context.ssrContext?.response.status(200);
139
+ context.ssrContext?.response?.status(200);
234
140
  try {
235
141
  serverRouter.serverSsr?.cleanup?.();
236
142
  } catch {}
237
143
  throw Object.values(routerErrors)[0];
238
144
  }
239
- await preloadMatchedRouteComponents(serverRouter);
240
- context.ssrContext?.response.status(tanstackRouter.state.statusCode);
145
+ await (0, external_ssrPreload_js_namespaceObject.preloadMatchedRouteComponents)(serverRouter);
146
+ context.ssrContext?.response?.status(tanstackRouter.state.statusCode);
241
147
  await serverRouter.serverSsr?.dehydrate?.();
242
- if (isRSCNavigation) {
243
- await waitForRouterSerialization(serverRouter);
244
- setTanstackRscServerPayload((0, payloadRouter_js_namespaceObject.createTanstackRscServerPayload)(serverRouter, {
245
- omitClientLoaderData: true
148
+ if (enableRsc) {
149
+ if (isRSCNavigation) await (0, external_ssrManagedTags_js_namespaceObject.waitForRouterSerialization)(serverRouter);
150
+ (0, payloadStorage_js_namespaceObject.setTanstackRscServerPayload)((0, payloadRouter_js_namespaceObject.createTanstackRscServerPayload)(serverRouter, {
151
+ omitClientLoaderData: isRSCNavigation
246
152
  }));
247
153
  }
248
154
  const ssrScriptTags = serverRouter.serverSsr?.takeBufferedScripts?.();
249
- const hydrationScripts = routerManagedTagsToHtml(ssrScriptTags);
155
+ const hydrationScripts = (0, external_ssrManagedTags_js_namespaceObject.routerManagedTagsToHtml)(ssrScriptTags);
250
156
  const matchedRouteIds = (0, external_routeTree_js_namespaceObject.getModernRouteIdsFromMatches)(serverRouter);
251
157
  const routerServerSnapshot = (0, external_lifecycle_js_namespaceObject.createRouterServerSnapshot)({
252
158
  framework: 'tanstack',
@@ -276,7 +182,20 @@ const tanstackRouterPlugin = (userConfig = {})=>{
276
182
  });
277
183
  });
278
184
  api.wrapRoot((App)=>{
279
- const getRouteApp = ()=>(props)=>{
185
+ const getRouteApp = ()=>{
186
+ if ((0, context_namespaceObject.getGlobalEnableRsc)()) return (props)=>{
187
+ const router = (0, payloadStorage_js_namespaceObject.getTanstackRscRouter)();
188
+ if (!router) return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
189
+ ...props
190
+ }) : null;
191
+ const routerWrapper = (0, external_hydrationBoundary_js_namespaceObject.wrapTanstackSsrHydrationBoundary)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
192
+ router: router
193
+ }), true);
194
+ return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
195
+ children: routerWrapper
196
+ }) : routerWrapper;
197
+ };
198
+ return (props)=>{
280
199
  const context = (0, external_react_namespaceObject.useContext)(context_namespaceObject.InternalRuntimeContext);
281
200
  const router = (0, external_lifecycle_js_namespaceObject.getRouterRuntimeState)(context)?.instance;
282
201
  if (!router) return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
@@ -289,6 +208,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
289
208
  children: routerWrapper
290
209
  }) : routerWrapper;
291
210
  };
211
+ };
292
212
  return getRouteApp();
293
213
  });
294
214
  }
@@ -0,0 +1,87 @@
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
+ createTanstackRouteObjects: ()=>createTanstackRouteObjects,
32
+ getMergedRouterConfig: ()=>getMergedRouterConfig,
33
+ getTanstackRouteConfig: ()=>getTanstackRouteConfig,
34
+ joinBasename: ()=>joinBasename
35
+ });
36
+ const context_namespaceObject = require("@modern-js/runtime/context");
37
+ const merge_namespaceObject = require("@modern-js/runtime-utils/merge");
38
+ const external_utils_js_namespaceObject = require("./utils.js");
39
+ function getMergedRouterConfig(api, userConfig) {
40
+ const pluginConfig = api.getRuntimeConfig();
41
+ return (0, merge_namespaceObject.merge)(pluginConfig.router || {}, userConfig);
42
+ }
43
+ function getFinalRouteConfig(mergedConfig) {
44
+ return {
45
+ routes: (0, context_namespaceObject.getGlobalRoutes)(),
46
+ globalApp: (0, context_namespaceObject.getGlobalLayoutApp)(),
47
+ ...mergedConfig.routesConfig
48
+ };
49
+ }
50
+ function getTanstackRouteConfig(api, userConfig) {
51
+ const mergedConfig = getMergedRouterConfig(api, userConfig);
52
+ const finalRouteConfig = getFinalRouteConfig(mergedConfig);
53
+ return {
54
+ mergedConfig,
55
+ finalRouteConfig,
56
+ hasConfiguredRoutes: Boolean(finalRouteConfig.routes) || Boolean(mergedConfig.createRoutes)
57
+ };
58
+ }
59
+ function createTanstackRouteObjects({ hooks, routeConfig, ssrMode }) {
60
+ const { mergedConfig, finalRouteConfig } = routeConfig;
61
+ const routeObjects = mergedConfig.createRoutes ? mergedConfig.createRoutes() : (0, external_utils_js_namespaceObject.createTanstackRouteObjectsFromConfig)({
62
+ routesConfig: finalRouteConfig,
63
+ ssrMode
64
+ }) || [];
65
+ return hooks.modifyRoutes.call(routeObjects);
66
+ }
67
+ function joinBasename(baseUrl, basename) {
68
+ const base = baseUrl || '/';
69
+ const normalizedBase = base.startsWith('/') ? base : `/${base}`;
70
+ const trimmedBase = normalizedBase.length > 1 ? normalizedBase.replace(/\/+$/g, '') : normalizedBase;
71
+ const trimmedBasename = basename.replace(/^\/+|\/+$/g, '');
72
+ if (!trimmedBasename) return trimmedBase || '/';
73
+ return `${trimmedBase}/${trimmedBasename}`.replace(/\/{2,}/g, '/');
74
+ }
75
+ exports.createTanstackRouteObjects = __webpack_exports__.createTanstackRouteObjects;
76
+ exports.getMergedRouterConfig = __webpack_exports__.getMergedRouterConfig;
77
+ exports.getTanstackRouteConfig = __webpack_exports__.getTanstackRouteConfig;
78
+ exports.joinBasename = __webpack_exports__.joinBasename;
79
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
80
+ "createTanstackRouteObjects",
81
+ "getMergedRouterConfig",
82
+ "getTanstackRouteConfig",
83
+ "joinBasename"
84
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
85
+ Object.defineProperty(exports, '__esModule', {
86
+ value: true
87
+ });
@@ -40,10 +40,23 @@ function resolvePreloadFromPrefetch(prefetch, preload) {
40
40
  return 'viewport';
41
41
  }
42
42
  const LinkComponentImpl = (props)=>{
43
- const { prefetch, preload, ...rest } = props;
44
- return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.Link, {
43
+ const { prefetch, preload, 'aria-current': ariaCurrentProp, ref, children, ...rest } = props;
44
+ const hasAriaCurrentOverride = 'aria-current' in props;
45
+ const linkOptions = {
45
46
  ...rest,
46
47
  preload: resolvePreloadFromPrefetch(prefetch, preload)
48
+ };
49
+ const linkProps = (0, react_router_namespaceObject.useLinkProps)(linkOptions, ref);
50
+ const { disabled: _disabled, type: _type, ...anchorProps } = linkProps;
51
+ if (hasAriaCurrentOverride) if (false === ariaCurrentProp || void 0 === ariaCurrentProp) delete anchorProps['aria-current'];
52
+ else anchorProps['aria-current'] = ariaCurrentProp;
53
+ const resolvedChildren = 'function' == typeof children ? children({
54
+ isActive: 'active' === anchorProps['data-status'],
55
+ isTransitioning: 'transitioning' === anchorProps['data-transitioning']
56
+ }) : children;
57
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
58
+ ...anchorProps,
59
+ children: resolvedChildren
47
60
  });
48
61
  };
49
62
  const Link = LinkComponentImpl;
@@ -28,28 +28,15 @@ var __webpack_require__ = {};
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
- tanstackRouterCompatBindings: ()=>tanstackRouterCompatBindings
31
+ tanstackRouterProviderFactory: ()=>tanstackRouterProviderFactory
32
32
  });
33
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
34
  const external_plugin_js_namespaceObject = require("./plugin.js");
37
- const external_prefetchLink_js_namespaceObject = require("./prefetchLink.js");
38
35
  const tanstackRouterProviderFactory = (userConfig)=>(0, external_plugin_js_namespaceObject.tanstackRouterPlugin)(userConfig);
39
36
  (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;
37
+ exports.tanstackRouterProviderFactory = __webpack_exports__.tanstackRouterProviderFactory;
51
38
  for(var __rspack_i in __webpack_exports__)if (-1 === [
52
- "tanstackRouterCompatBindings"
39
+ "tanstackRouterProviderFactory"
53
40
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
54
41
  Object.defineProperty(exports, '__esModule', {
55
42
  value: true