@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,99 @@
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
+ isSerializedNotFound: ()=>isSerializedNotFound,
32
+ serializePayloadError: ()=>serializePayloadError,
33
+ shouldRedactServerError: ()=>shouldRedactServerError,
34
+ toRouteErrors: ()=>toRouteErrors,
35
+ toRouteLoaderData: ()=>toRouteLoaderData
36
+ });
37
+ const router_namespaceObject = require("@modern-js/runtime-utils/router");
38
+ function shouldRedactServerError(status = 500) {
39
+ return status >= 500 && 'development' !== process.env.NODE_ENV && 'test' !== process.env.NODE_ENV;
40
+ }
41
+ function serializePayloadError(error) {
42
+ if ((0, router_namespaceObject.isRouteErrorResponse)(error)) {
43
+ if (shouldRedactServerError(error.status)) return {
44
+ status: error.status,
45
+ statusText: 'Internal Server Error',
46
+ data: 'Unexpected Server Error',
47
+ __type: 'RouteErrorResponse'
48
+ };
49
+ return {
50
+ ...error,
51
+ __type: 'RouteErrorResponse'
52
+ };
53
+ }
54
+ if (error instanceof Error) {
55
+ if (shouldRedactServerError()) return {
56
+ message: 'Unexpected Server Error',
57
+ stack: void 0,
58
+ __type: 'Error'
59
+ };
60
+ return {
61
+ message: error.message,
62
+ stack: error.stack,
63
+ __type: 'Error',
64
+ ...'Error' !== error.name ? {
65
+ __subType: error.name
66
+ } : {}
67
+ };
68
+ }
69
+ if (shouldRedactServerError()) return {
70
+ message: 'Unexpected Server Error',
71
+ stack: void 0,
72
+ __type: 'Error'
73
+ };
74
+ return error;
75
+ }
76
+ function isSerializedNotFound(value) {
77
+ return Boolean(value) && 'object' == typeof value && true === value.isNotFound;
78
+ }
79
+ function toRouteErrors(payload) {
80
+ return payload.errors && 'object' == typeof payload.errors ? payload.errors : {};
81
+ }
82
+ function toRouteLoaderData(payload) {
83
+ return payload.loaderData && 'object' == typeof payload.loaderData ? payload.loaderData : {};
84
+ }
85
+ exports.isSerializedNotFound = __webpack_exports__.isSerializedNotFound;
86
+ exports.serializePayloadError = __webpack_exports__.serializePayloadError;
87
+ exports.shouldRedactServerError = __webpack_exports__.shouldRedactServerError;
88
+ exports.toRouteErrors = __webpack_exports__.toRouteErrors;
89
+ exports.toRouteLoaderData = __webpack_exports__.toRouteLoaderData;
90
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
91
+ "isSerializedNotFound",
92
+ "serializePayloadError",
93
+ "shouldRedactServerError",
94
+ "toRouteErrors",
95
+ "toRouteLoaderData"
96
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
97
+ Object.defineProperty(exports, '__esModule', {
98
+ value: true
99
+ });
@@ -0,0 +1,105 @@
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
+ __setTanstackRscPayloadDecoderForTests: ()=>__setTanstackRscPayloadDecoderForTests,
32
+ createPayloadFetchKey: ()=>createPayloadFetchKey,
33
+ fetchTanstackRscPayload: ()=>fetchTanstackRscPayload,
34
+ isAbsoluteUrl: ()=>isAbsoluteUrl_js_namespaceObject.isAbsoluteUrl,
35
+ payloadFetchCache: ()=>payloadFetchCache
36
+ });
37
+ const react_router_namespaceObject = require("@tanstack/react-router");
38
+ const isAbsoluteUrl_js_namespaceObject = require("../shared/isAbsoluteUrl.js");
39
+ const external_flightSerialization_js_namespaceObject = require("./flightSerialization.js");
40
+ const payloadFetchCache = new Map();
41
+ let payloadDecoder;
42
+ async function decodePayload(stream) {
43
+ if (payloadDecoder) return (0, external_flightSerialization_js_namespaceObject.reviveTanstackRscFlightValues)(await payloadDecoder(stream));
44
+ const runtime = await import("@modern-js/runtime/rsc/client");
45
+ return (0, external_flightSerialization_js_namespaceObject.reviveTanstackRscFlightValues)(await runtime.createFromReadableStream(stream));
46
+ }
47
+ function isServerPayload(value) {
48
+ return Boolean(value) && 'object' == typeof value && 'render' === value.type && Array.isArray(value.routes);
49
+ }
50
+ function createPayloadFetchKey(request) {
51
+ return JSON.stringify([
52
+ request.url,
53
+ request.method,
54
+ [
55
+ ...request.headers.entries()
56
+ ].sort(([left], [right])=>left.localeCompare(right))
57
+ ]);
58
+ }
59
+ async function fetchTanstackRscPayload(request) {
60
+ const headers = new Headers(request.headers);
61
+ headers.set('x-rsc-tree', 'true');
62
+ const response = await fetch(request.url, {
63
+ credentials: 'same-origin',
64
+ headers,
65
+ method: 'GET',
66
+ signal: request.signal
67
+ });
68
+ const redirectLocation = response.headers.get('X-Modernjs-Redirect');
69
+ if (redirectLocation) {
70
+ if ((0, isAbsoluteUrl_js_namespaceObject.isAbsoluteUrl)(redirectLocation)) throw (0, react_router_namespaceObject.redirect)({
71
+ headers: response.headers,
72
+ href: redirectLocation,
73
+ statusCode: response.status
74
+ });
75
+ throw (0, react_router_namespaceObject.redirect)({
76
+ headers: response.headers,
77
+ statusCode: response.status,
78
+ to: redirectLocation || '/'
79
+ });
80
+ }
81
+ if (404 === response.status && !response.body) throw (0, react_router_namespaceObject.notFound)();
82
+ if (!response.body) throw new Error('TanStack RSC payload response body is null.');
83
+ const payload = await decodePayload(response.body);
84
+ if (!isServerPayload(payload)) throw new Error('Unexpected TanStack RSC payload type.');
85
+ return payload;
86
+ }
87
+ function __setTanstackRscPayloadDecoderForTests(decoder) {
88
+ payloadDecoder = decoder;
89
+ payloadFetchCache.clear();
90
+ }
91
+ exports.__setTanstackRscPayloadDecoderForTests = __webpack_exports__.__setTanstackRscPayloadDecoderForTests;
92
+ exports.createPayloadFetchKey = __webpack_exports__.createPayloadFetchKey;
93
+ exports.fetchTanstackRscPayload = __webpack_exports__.fetchTanstackRscPayload;
94
+ exports.isAbsoluteUrl = __webpack_exports__.isAbsoluteUrl;
95
+ exports.payloadFetchCache = __webpack_exports__.payloadFetchCache;
96
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
97
+ "__setTanstackRscPayloadDecoderForTests",
98
+ "createPayloadFetchKey",
99
+ "fetchTanstackRscPayload",
100
+ "isAbsoluteUrl",
101
+ "payloadFetchCache"
102
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
103
+ Object.defineProperty(exports, '__esModule', {
104
+ value: true
105
+ });
@@ -28,97 +28,29 @@ var __webpack_require__ = {};
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
- __setTanstackRscPayloadDecoderForTests: ()=>__setTanstackRscPayloadDecoderForTests,
31
+ __setTanstackRscPayloadDecoderForTests: ()=>external_payloadFetch_js_namespaceObject.__setTanstackRscPayloadDecoderForTests,
32
32
  createTanstackRscServerPayload: ()=>createTanstackRscServerPayload,
33
33
  handleTanstackRscRedirect: ()=>handleTanstackRscRedirect,
34
34
  isTanstackRscPayloadNavigationEnabled: ()=>isTanstackRscPayloadNavigationEnabled,
35
35
  loadTanstackRscPayload: ()=>loadTanstackRscPayload,
36
36
  loadTanstackRscRouteData: ()=>loadTanstackRscRouteData
37
37
  });
38
- const router_namespaceObject = require("@modern-js/runtime-utils/router");
39
38
  const react_router_namespaceObject = require("@tanstack/react-router");
40
- const payloadFetchCache = new Map();
41
- let payloadDecoder;
42
- function getRouteId(match) {
43
- const routeId = match.routeId ?? match.route?.id ?? match.id;
44
- return 'string' == typeof routeId ? routeId : void 0;
45
- }
46
- function getRouteStaticData(match) {
47
- return match.route?.options?.staticData || {};
48
- }
49
- function getRouteParentId(match) {
50
- const parentId = match.route?.parentRoute?.id;
51
- return 'string' == typeof parentId ? parentId : void 0;
52
- }
53
- function toRoutePath(match) {
54
- const path = match.route?.options?.path;
55
- return 'string' == typeof path ? path : void 0;
56
- }
57
- function toPayloadRoute(match) {
58
- const routeId = getRouteId(match);
59
- if (!routeId) return;
60
- const staticData = getRouteStaticData(match);
61
- const params = match.params && 'object' == typeof match.params ? match.params : {};
62
- const pathname = 'string' == typeof match.pathname ? match.pathname : '';
63
- return {
64
- handle: staticData.modernRouteHandle,
65
- hasAction: Boolean(staticData.modernRouteHasAction || staticData.modernRouteAction),
66
- hasErrorBoundary: false,
67
- hasLoader: Boolean(staticData.modernRouteHasLoader),
68
- hasClientLoader: Boolean(staticData.modernRouteHasClientLoader),
69
- id: routeId,
70
- index: Boolean(match.route?.options?.index) || void 0,
71
- params,
72
- parentId: getRouteParentId(match),
73
- path: toRoutePath(match),
74
- pathname,
75
- pathnameBase: 'string' == typeof match.pathnameBase ? match.pathnameBase : pathname
76
- };
77
- }
78
- function shouldRedactServerError(status = 500) {
79
- return status >= 500 && 'development' !== process.env.NODE_ENV && 'test' !== process.env.NODE_ENV;
80
- }
81
- function serializePayloadError(error) {
82
- if ((0, router_namespaceObject.isRouteErrorResponse)(error)) {
83
- if (shouldRedactServerError(error.status)) return {
84
- status: error.status,
85
- statusText: 'Internal Server Error',
86
- data: 'Unexpected Server Error',
87
- __type: 'RouteErrorResponse'
88
- };
89
- return {
90
- ...error,
91
- __type: 'RouteErrorResponse'
92
- };
93
- }
94
- if (error instanceof Error) {
95
- if (shouldRedactServerError()) return {
96
- message: 'Unexpected Server Error',
97
- stack: void 0,
98
- __type: 'Error'
99
- };
100
- return {
101
- message: error.message,
102
- stack: error.stack,
103
- __type: 'Error',
104
- ...'Error' !== error.name ? {
105
- __subType: error.name
106
- } : {}
107
- };
108
- }
109
- return error;
110
- }
39
+ const external_flightSerialization_js_namespaceObject = require("./flightSerialization.js");
40
+ const external_payloadErrors_js_namespaceObject = require("./payloadErrors.js");
41
+ const external_payloadFetch_js_namespaceObject = require("./payloadFetch.js");
42
+ const external_payloadRoutes_js_namespaceObject = require("./payloadRoutes.js");
111
43
  function createTanstackRscServerPayload(router, options = {}) {
112
44
  const matches = Array.isArray(router.state?.matches) ? router.state.matches : [];
113
45
  const routes = [];
114
46
  const loaderData = {};
115
47
  const errors = {};
116
48
  for (const match of matches){
117
- const payloadRoute = toPayloadRoute(match);
49
+ const payloadRoute = (0, external_payloadRoutes_js_namespaceObject.toPayloadRoute)(match);
118
50
  if (payloadRoute) {
119
51
  routes.push(payloadRoute);
120
- if ('loaderData' in match && void 0 !== match.loaderData && !(options.omitClientLoaderData && payloadRoute.hasClientLoader)) loaderData[payloadRoute.id] = match.loaderData;
121
- if (void 0 !== match.error) errors[payloadRoute.id] = serializePayloadError(match.error);
52
+ if ('loaderData' in match && void 0 !== match.loaderData && !(options.omitClientLoaderData && payloadRoute.hasClientLoader)) loaderData[payloadRoute.id] = (0, external_flightSerialization_js_namespaceObject.serializeTanstackRscFlightValues)(match.loaderData);
53
+ if (void 0 !== match.error) errors[payloadRoute.id] = (0, external_payloadErrors_js_namespaceObject.serializePayloadError)(match.error);
122
54
  }
123
55
  }
124
56
  return {
@@ -126,14 +58,17 @@ function createTanstackRscServerPayload(router, options = {}) {
126
58
  actionData: null,
127
59
  errors: Object.keys(errors).length > 0 ? errors : null,
128
60
  loaderData,
129
- location: router.state?.location,
61
+ location: (0, external_payloadRoutes_js_namespaceObject.toPlainLocation)(router.state?.location),
130
62
  routes
131
63
  };
132
64
  }
133
65
  function handleTanstackRscRedirect(headers, basename, status) {
134
66
  const newHeaders = new Headers(headers);
135
67
  let redirectUrl = headers.get('Location') || '/';
136
- if ('/' !== basename) redirectUrl = redirectUrl.replace(basename, '') || '/';
68
+ if ('/' !== basename) {
69
+ if (redirectUrl === basename) redirectUrl = '/';
70
+ else if (redirectUrl.startsWith(`${basename}/`)) redirectUrl = redirectUrl.slice(basename.length);
71
+ }
137
72
  newHeaders.set('X-Modernjs-Redirect', redirectUrl);
138
73
  newHeaders.set('X-Modernjs-BaseUrl', basename);
139
74
  newHeaders.delete('Location');
@@ -145,91 +80,35 @@ function handleTanstackRscRedirect(headers, basename, status) {
145
80
  function isTanstackRscPayloadNavigationEnabled() {
146
81
  return "u" > typeof window;
147
82
  }
148
- async function decodePayload(stream) {
149
- if (payloadDecoder) return payloadDecoder(stream);
150
- const runtime = await import("@modern-js/runtime/rsc/client");
151
- return runtime.createFromReadableStream(stream);
152
- }
153
- function isServerPayload(value) {
154
- return Boolean(value) && 'object' == typeof value && 'render' === value.type && Array.isArray(value.routes);
155
- }
156
- function createPayloadFetchKey(request) {
157
- return request.url;
158
- }
159
- function isAbsoluteUrl(value) {
160
- try {
161
- new URL(value);
162
- return true;
163
- } catch {
164
- return false;
165
- }
166
- }
167
- async function fetchTanstackRscPayload(request) {
168
- const headers = new Headers(request.headers);
169
- headers.set('x-rsc-tree', 'true');
170
- const response = await fetch(request.url, {
171
- credentials: 'same-origin',
172
- headers,
173
- method: 'GET',
174
- signal: request.signal
175
- });
176
- const redirectLocation = response.headers.get('X-Modernjs-Redirect');
177
- if (redirectLocation) {
178
- if (isAbsoluteUrl(redirectLocation)) throw (0, react_router_namespaceObject.redirect)({
179
- href: redirectLocation
180
- });
181
- throw (0, react_router_namespaceObject.redirect)({
182
- to: redirectLocation || '/'
183
- });
184
- }
185
- if (404 === response.status && !response.body) throw (0, react_router_namespaceObject.notFound)();
186
- if (!response.body) throw new Error('TanStack RSC payload response body is null.');
187
- const payload = await decodePayload(response.body);
188
- if (!isServerPayload(payload)) throw new Error('Unexpected TanStack RSC payload type.');
189
- return payload;
190
- }
191
83
  function loadTanstackRscPayload(request) {
192
- const key = createPayloadFetchKey(request);
193
- let payloadPromise = payloadFetchCache.get(key);
84
+ const key = (0, external_payloadFetch_js_namespaceObject.createPayloadFetchKey)(request);
85
+ let payloadPromise = external_payloadFetch_js_namespaceObject.payloadFetchCache.get(key);
194
86
  if (!payloadPromise) {
195
- payloadPromise = fetchTanstackRscPayload(request).finally(()=>{
196
- payloadFetchCache.delete(key);
87
+ payloadPromise = (0, external_payloadFetch_js_namespaceObject.fetchTanstackRscPayload)(request).finally(()=>{
88
+ external_payloadFetch_js_namespaceObject.payloadFetchCache["delete"](key);
197
89
  });
198
- payloadFetchCache.set(key, payloadPromise);
90
+ external_payloadFetch_js_namespaceObject.payloadFetchCache.set(key, payloadPromise);
199
91
  }
200
92
  return payloadPromise;
201
93
  }
202
- function isSerializedNotFound(value) {
203
- return Boolean(value) && 'object' == typeof value && true === value.isNotFound;
204
- }
205
- function toRouteErrors(payload) {
206
- return payload.errors && 'object' == typeof payload.errors ? payload.errors : {};
207
- }
208
- function toRouteLoaderData(payload) {
209
- return payload.loaderData && 'object' == typeof payload.loaderData ? payload.loaderData : {};
210
- }
211
94
  async function loadTanstackRscRouteData({ hasClientLoader, loadClientData, request, routeId }) {
212
95
  if (hasClientLoader) return loadClientData();
213
96
  if (!routeId) return loadClientData();
214
97
  const payload = await loadTanstackRscPayload(request);
215
- const errors = toRouteErrors(payload);
98
+ const errors = (0, external_payloadErrors_js_namespaceObject.toRouteErrors)(payload);
216
99
  const routeError = errors[routeId];
217
100
  if (void 0 !== routeError) {
218
- if (isSerializedNotFound(routeError)) throw (0, react_router_namespaceObject.notFound)({
101
+ if ((0, external_payloadErrors_js_namespaceObject.isSerializedNotFound)(routeError)) throw (0, react_router_namespaceObject.notFound)({
219
102
  ...routeError,
220
103
  routeId
221
104
  });
222
105
  throw routeError;
223
106
  }
224
- const loaderData = toRouteLoaderData(payload);
107
+ const loaderData = (0, external_payloadErrors_js_namespaceObject.toRouteLoaderData)(payload);
225
108
  if (routeId in loaderData) return loaderData[routeId];
226
109
  const payloadRoute = payload.routes.find((route)=>route.id === routeId);
227
110
  if (payloadRoute && payloadRoute.hasClientLoader) return loadClientData();
228
111
  }
229
- function __setTanstackRscPayloadDecoderForTests(decoder) {
230
- payloadDecoder = decoder;
231
- payloadFetchCache.clear();
232
- }
233
112
  exports.__setTanstackRscPayloadDecoderForTests = __webpack_exports__.__setTanstackRscPayloadDecoderForTests;
234
113
  exports.createTanstackRscServerPayload = __webpack_exports__.createTanstackRscServerPayload;
235
114
  exports.handleTanstackRscRedirect = __webpack_exports__.handleTanstackRscRedirect;
@@ -0,0 +1,94 @@
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
+ function toPlainRecord(value) {
31
+ if (!value || 'object' != typeof value) return {};
32
+ return Object.fromEntries(Object.entries(value));
33
+ }
34
+ function toPlainLocation(location) {
35
+ if (!location || 'object' != typeof location) return location;
36
+ const plainLocation = toPlainRecord(location);
37
+ for (const key of [
38
+ 'search',
39
+ 'state'
40
+ ])if (plainLocation[key] && 'object' == typeof plainLocation[key] && !Array.isArray(plainLocation[key])) plainLocation[key] = toPlainRecord(plainLocation[key]);
41
+ return plainLocation;
42
+ }
43
+ function getRouteId(match) {
44
+ const routeId = match.routeId ?? match.route?.id ?? match.id;
45
+ return 'string' == typeof routeId ? routeId : void 0;
46
+ }
47
+ function getRouteStaticData(match) {
48
+ return match.route?.options?.staticData || {};
49
+ }
50
+ function getRouteParentId(match) {
51
+ const parentId = match.route?.parentRoute?.id;
52
+ return 'string' == typeof parentId ? parentId : void 0;
53
+ }
54
+ function toRoutePath(match) {
55
+ const path = match.route?.options?.path;
56
+ return 'string' == typeof path ? path : void 0;
57
+ }
58
+ function toPayloadRoute(match) {
59
+ const routeId = getRouteId(match);
60
+ if (!routeId) return;
61
+ const staticData = getRouteStaticData(match);
62
+ const params = match.params && 'object' == typeof match.params ? toPlainRecord(match.params) : {};
63
+ const pathname = 'string' == typeof match.pathname ? match.pathname : '';
64
+ return {
65
+ handle: staticData.modernRouteHandle,
66
+ hasAction: Boolean(staticData.modernRouteHasAction || staticData.modernRouteAction),
67
+ hasErrorBoundary: false,
68
+ hasLoader: Boolean(staticData.modernRouteHasLoader),
69
+ hasClientLoader: Boolean(staticData.modernRouteHasClientLoader),
70
+ id: routeId,
71
+ index: Boolean(match.route?.options?.index) || void 0,
72
+ params,
73
+ parentId: getRouteParentId(match),
74
+ path: toRoutePath(match),
75
+ pathname,
76
+ pathnameBase: 'string' == typeof match.pathnameBase ? match.pathnameBase : pathname
77
+ };
78
+ }
79
+ __webpack_require__.d(__webpack_exports__, {
80
+ getRouteId: ()=>getRouteId,
81
+ toPayloadRoute: ()=>toPayloadRoute,
82
+ toPlainLocation: ()=>toPlainLocation
83
+ });
84
+ exports.getRouteId = __webpack_exports__.getRouteId;
85
+ exports.toPayloadRoute = __webpack_exports__.toPayloadRoute;
86
+ exports.toPlainLocation = __webpack_exports__.toPlainLocation;
87
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
88
+ "getRouteId",
89
+ "toPayloadRoute",
90
+ "toPlainLocation"
91
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
92
+ Object.defineProperty(exports, '__esModule', {
93
+ value: true
94
+ });
@@ -0,0 +1,58 @@
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
+ getTanstackRscRouter: ()=>getTanstackRscRouter,
32
+ setTanstackRscRouter: ()=>setTanstackRscRouter,
33
+ setTanstackRscServerPayload: ()=>setTanstackRscServerPayload
34
+ });
35
+ const node_namespaceObject = require("@modern-js/runtime-utils/node");
36
+ const setTanstackRscServerPayload = (payload)=>{
37
+ const storageContext = node_namespaceObject.storage.useContext?.();
38
+ if (storageContext) storageContext.serverPayload = payload;
39
+ };
40
+ const setTanstackRscRouter = (router)=>{
41
+ const storageContext = node_namespaceObject.storage.useContext?.();
42
+ if (storageContext) storageContext.tanstackRscRouter = router;
43
+ };
44
+ const getTanstackRscRouter = ()=>{
45
+ const storageContext = node_namespaceObject.storage.useContext?.();
46
+ return storageContext?.tanstackRscRouter;
47
+ };
48
+ exports.getTanstackRscRouter = __webpack_exports__.getTanstackRscRouter;
49
+ exports.setTanstackRscRouter = __webpack_exports__.setTanstackRscRouter;
50
+ exports.setTanstackRscServerPayload = __webpack_exports__.setTanstackRscServerPayload;
51
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
52
+ "getTanstackRscRouter",
53
+ "setTanstackRscRouter",
54
+ "setTanstackRscServerPayload"
55
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
56
+ Object.defineProperty(exports, '__esModule', {
57
+ value: true
58
+ });
@@ -36,28 +36,13 @@ __webpack_require__.d(__webpack_exports__, {
36
36
  });
37
37
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
38
38
  const server_namespaceObject = require("@modern-js/runtime/rsc/server");
39
- const react_router_namespaceObject = require("@tanstack/react-router");
40
39
  const router_core_namespaceObject = require("@tanstack/router-core");
41
40
  const external_react_namespaceObject = require("react");
42
41
  const external_ClientSlot_js_namespaceObject = require("./ClientSlot.js");
43
- const external_createRscProxy_js_namespaceObject = require("./createRscProxy.js");
44
42
  const external_ReplayableStream_js_namespaceObject = require("./ReplayableStream.js");
45
43
  const external_slotUsageSanitizer_js_namespaceObject = require("./slotUsageSanitizer.js");
46
44
  const external_symbols_js_namespaceObject = require("./symbols.js");
47
45
  const external_CompositeComponent_js_namespaceObject = require("./CompositeComponent.js");
48
- function createTreeGetter(stream) {
49
- let ready = false;
50
- let tree;
51
- const treePromise = Promise.resolve((0, server_namespaceObject.createFromReadableStream)(stream.createReplayStream())).then((value)=>{
52
- tree = value;
53
- ready = true;
54
- return value;
55
- });
56
- return ()=>{
57
- if (ready) return tree;
58
- return (0, external_react_namespaceObject.use)(treePromise);
59
- };
60
- }
61
46
  function createSlotProxy(options) {
62
47
  const cache = new Map();
63
48
  return new Proxy({}, {
@@ -81,6 +66,17 @@ function createSlotProxy(options) {
81
66
  }
82
67
  });
83
68
  }
69
+ function createServerRscValue(options) {
70
+ return {
71
+ [external_symbols_js_namespaceObject.SERVER_COMPONENT_STREAM]: options.stream,
72
+ ...options.renderable ? {
73
+ [external_symbols_js_namespaceObject.RENDERABLE_RSC]: true
74
+ } : {},
75
+ ...options.slotUsagesStream ? {
76
+ [external_symbols_js_namespaceObject.RSC_SLOT_USAGES_STREAM]: options.slotUsagesStream
77
+ } : {}
78
+ };
79
+ }
84
80
  function toReplayableFlightStream(node, handlers) {
85
81
  const flightStream = (0, server_namespaceObject.renderRsc)({
86
82
  element: node
@@ -94,7 +90,7 @@ async function renderServerComponent(node) {
94
90
  const streamWrapper = {
95
91
  createReplayStream: ()=>stream.createReplayStream()
96
92
  };
97
- return (0, external_createRscProxy_js_namespaceObject.createRscProxy)(createTreeGetter(streamWrapper), {
93
+ return createServerRscValue({
98
94
  renderable: true,
99
95
  stream: streamWrapper
100
96
  });
@@ -123,13 +119,13 @@ async function createCompositeComponent(component) {
123
119
  const streamWrapper = {
124
120
  createReplayStream: ()=>flightStream.createReplayStream()
125
121
  };
126
- return (0, external_createRscProxy_js_namespaceObject.createRscProxy)(createTreeGetter(streamWrapper), {
122
+ return createServerRscValue({
127
123
  renderable: false,
128
124
  slotUsagesStream: slotUsagesEmitter?.stream,
129
125
  stream: streamWrapper
130
126
  });
131
127
  }
132
- const adapter = (0, react_router_namespaceObject.createSerializationAdapter)({
128
+ const adapter = (0, router_core_namespaceObject.createSerializationAdapter)({
133
129
  key: '$MODERN_TANSTACK_RSC',
134
130
  test: external_symbols_js_namespaceObject.isServerComponent,
135
131
  toSerializable: (component)=>{