@bleedingdev/modern-js-plugin-tanstack 3.8.1-ultramodern.1 → 3.8.1-ultramodern.3

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 (78) hide show
  1. package/dist/cjs/cli/tanstackTypes/shared.js +8 -6
  2. package/dist/cjs/runtime/clientHydration.js +2 -2
  3. package/dist/cjs/runtime/loaderBridge.js +11 -8
  4. package/dist/cjs/runtime/plugin.js +6 -7
  5. package/dist/cjs/runtime/plugin.node.js +5 -6
  6. package/dist/cjs/runtime/pluginShared.js +2 -3
  7. package/dist/cjs/runtime/routeTree/components.js +1 -1
  8. package/dist/cjs/runtime/routeTree/construction.js +4 -3
  9. package/dist/cjs/runtime/routeTree/loaders.js +7 -43
  10. package/dist/cjs/runtime/routeTree/staticData.js +0 -16
  11. package/dist/cjs/runtime/rsc/client.js +2 -6
  12. package/dist/cjs/runtime/rsc/server.js +2 -6
  13. package/dist/cjs/runtime/submitAction.js +3 -12
  14. package/dist/cjs/runtime/utils.js +2 -7
  15. package/dist/cjs/{runtime/rsc/index.js → shared/routeStaticData.js} +6 -10
  16. package/dist/esm/cli/tanstackTypes/shared.mjs +8 -6
  17. package/dist/esm/runtime/clientHydration.mjs +1 -1
  18. package/dist/esm/runtime/loaderBridge.mjs +2 -8
  19. package/dist/esm/runtime/plugin.mjs +5 -6
  20. package/dist/esm/runtime/plugin.node.mjs +3 -4
  21. package/dist/esm/runtime/pluginShared.mjs +2 -3
  22. package/dist/esm/runtime/routeTree/components.mjs +1 -1
  23. package/dist/esm/runtime/routeTree/construction.mjs +3 -2
  24. package/dist/esm/runtime/routeTree/loaders.mjs +8 -44
  25. package/dist/esm/runtime/routeTree/staticData.mjs +1 -14
  26. package/dist/esm/runtime/rsc/client.mjs +1 -2
  27. package/dist/esm/runtime/rsc/server.mjs +1 -2
  28. package/dist/esm/runtime/submitAction.mjs +1 -10
  29. package/dist/esm/runtime/utils.mjs +2 -7
  30. package/dist/esm/shared/routeStaticData.mjs +4 -0
  31. package/dist/esm-node/cli/tanstackTypes/shared.mjs +8 -6
  32. package/dist/esm-node/runtime/clientHydration.mjs +1 -1
  33. package/dist/esm-node/runtime/loaderBridge.mjs +2 -8
  34. package/dist/esm-node/runtime/plugin.mjs +5 -6
  35. package/dist/esm-node/runtime/plugin.node.mjs +3 -4
  36. package/dist/esm-node/runtime/pluginShared.mjs +2 -3
  37. package/dist/esm-node/runtime/routeTree/components.mjs +1 -1
  38. package/dist/esm-node/runtime/routeTree/construction.mjs +3 -2
  39. package/dist/esm-node/runtime/routeTree/loaders.mjs +8 -44
  40. package/dist/esm-node/runtime/routeTree/staticData.mjs +1 -14
  41. package/dist/esm-node/runtime/rsc/client.mjs +1 -2
  42. package/dist/esm-node/runtime/rsc/server.mjs +1 -2
  43. package/dist/esm-node/runtime/submitAction.mjs +1 -10
  44. package/dist/esm-node/runtime/utils.mjs +2 -7
  45. package/dist/esm-node/shared/routeStaticData.mjs +5 -0
  46. package/dist/types/runtime/loaderBridge.d.ts +17 -13
  47. package/dist/types/runtime/pluginShared.d.ts +1 -3
  48. package/dist/types/runtime/routeTree/components.d.ts +1 -2
  49. package/dist/types/runtime/routeTree/staticData.d.ts +2 -14
  50. package/dist/types/runtime/rsc/client.d.ts +0 -1
  51. package/dist/types/runtime/rsc/server.d.ts +0 -1
  52. package/dist/types/runtime/utils.d.ts +0 -3
  53. package/dist/types/shared/routeStaticData.d.ts +1 -0
  54. package/package.json +9 -9
  55. package/src/cli/tanstackTypes/shared.ts +13 -21
  56. package/src/runtime/loaderBridge.ts +5 -38
  57. package/src/runtime/plugin.node.tsx +2 -3
  58. package/src/runtime/plugin.tsx +4 -5
  59. package/src/runtime/pluginShared.ts +1 -4
  60. package/src/runtime/routeTree/components.ts +2 -5
  61. package/src/runtime/routeTree/construction.ts +3 -2
  62. package/src/runtime/routeTree/loaders.ts +13 -77
  63. package/src/runtime/routeTree/staticData.ts +2 -53
  64. package/src/runtime/rsc/client.tsx +0 -2
  65. package/src/runtime/rsc/server.tsx +0 -2
  66. package/src/runtime/submitAction.ts +1 -7
  67. package/src/runtime/utils.tsx +2 -12
  68. package/src/shared/routeStaticData.ts +7 -0
  69. package/tests/router/cli.test.ts +3 -1
  70. package/dist/cjs/runtime/routeTree.js +0 -46
  71. package/dist/esm/runtime/routeTree.mjs +0 -1
  72. package/dist/esm/runtime/rsc/index.mjs +0 -1
  73. package/dist/esm-node/runtime/routeTree.mjs +0 -2
  74. package/dist/esm-node/runtime/rsc/index.mjs +0 -2
  75. package/dist/types/runtime/routeTree.d.ts +0 -1
  76. package/dist/types/runtime/rsc/index.d.ts +0 -2
  77. package/src/runtime/routeTree.ts +0 -7
  78. package/src/runtime/rsc/index.ts +0 -10
@@ -40,6 +40,7 @@ __webpack_require__.d(__webpack_exports__, {
40
40
  });
41
41
  const cli_namespaceObject = require("@modern-js/runtime/cli");
42
42
  const utils_namespaceObject = require("@modern-js/utils");
43
+ const routeStaticData_js_namespaceObject = require("../../shared/routeStaticData.js");
43
44
  const paths_js_namespaceObject = require("../../runtime/routeTree/paths.js");
44
45
  const JS_OR_TS_EXTS = [
45
46
  '.js',
@@ -91,12 +92,13 @@ function isIndexRoute(route) {
91
92
  return 'nested' === extras.type && Boolean(extras.index);
92
93
  }
93
94
  function createRouteStaticDataSnippet(opts) {
94
- const staticDataLines = [];
95
- if (opts.modernRouteId) staticDataLines.push(`modernRouteId: ${quote(opts.modernRouteId)},`);
96
- if (opts.loaderName) staticDataLines.push(`modernRouteLoader: ${opts.loaderName},`);
97
- if (opts.actionName) staticDataLines.push(`modernRouteAction: ${opts.actionName},`);
98
- if (!staticDataLines.length) return null;
99
- return `staticData: createRouteStaticData({\n ${staticDataLines.join('\n ')}\n }),`;
95
+ const staticData = (0, routeStaticData_js_namespaceObject.createRouteStaticData)({
96
+ modernRouteId: opts.modernRouteId && quote(opts.modernRouteId),
97
+ modernRouteLoader: opts.loaderName,
98
+ modernRouteAction: opts.actionName
99
+ });
100
+ const entries = Object.entries(staticData);
101
+ return entries.length > 0 ? `staticData: createRouteStaticData({\n ${entries.map(([key, value])=>`${key}: ${value},`).join('\n ')}\n }),` : null;
100
102
  }
101
103
  exports.createRouteStaticDataSnippet = __webpack_exports__.createRouteStaticDataSnippet;
102
104
  exports.isIndexRoute = __webpack_exports__.isIndexRoute;
@@ -36,7 +36,7 @@ __webpack_require__.d(__webpack_exports__, {
36
36
  const react_router_namespaceObject = require("@tanstack/react-router");
37
37
  const external_react_namespaceObject = require("react");
38
38
  const external_outlet_js_namespaceObject = require("./outlet.js");
39
- const external_routeTree_js_namespaceObject = require("./routeTree.js");
39
+ const index_js_namespaceObject = require("./routeTree/index.js");
40
40
  const routerHydrationRecords = new WeakMap();
41
41
  const routeModulesKey = '_routeModules';
42
42
  function getCachedRouteModule(routeId) {
@@ -56,7 +56,7 @@ function preloadHydratedRouteComponents(router) {
56
56
  return Promise.resolve(preload.call(component)).then((routeModule)=>{
57
57
  const modernRouteId = route?.options?.staticData?.modernRouteId;
58
58
  const cachedRouteModule = 'string' == typeof modernRouteId && '' !== modernRouteId ? getCachedRouteModule(modernRouteId) : void 0;
59
- const resolvedComponent = (0, external_routeTree_js_namespaceObject.pickRouteModuleComponent)(cachedRouteModule ?? routeModule);
59
+ const resolvedComponent = (0, index_js_namespaceObject.pickRouteModuleComponent)(cachedRouteModule ?? routeModule);
60
60
  if (void 0 !== resolvedComponent && 'string' == typeof modernRouteId && '' !== modernRouteId) route.options.component = (0, external_outlet_js_namespaceObject.withModernRouteMatchContext)(resolvedComponent, modernRouteId);
61
61
  });
62
62
  })).then(()=>void 0);
@@ -28,7 +28,10 @@ var __webpack_require__ = {};
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
- createRouteStaticData: ()=>createRouteStaticData,
31
+ createRouteStaticData: ()=>routeStaticData_js_namespaceObject.createRouteStaticData,
32
+ getLoaderHref: ()=>getLoaderHref,
33
+ handleModernLoaderError: ()=>handleModernLoaderError,
34
+ handleModernLoaderResult: ()=>handleModernLoaderResult,
32
35
  isAbsoluteUrl: ()=>isAbsoluteUrl_js_namespaceObject.isAbsoluteUrl,
33
36
  isRedirectResponse: ()=>isRedirectResponse,
34
37
  isResponse: ()=>isResponse,
@@ -38,6 +41,7 @@ __webpack_require__.d(__webpack_exports__, {
38
41
  throwTanstackRedirect: ()=>throwTanstackRedirect
39
42
  });
40
43
  const react_router_namespaceObject = require("@tanstack/react-router");
44
+ const routeStaticData_js_namespaceObject = require("../shared/routeStaticData.js");
41
45
  const isAbsoluteUrl_js_namespaceObject = require("./shared/isAbsoluteUrl.js");
42
46
  function isResponse(value) {
43
47
  const record = value;
@@ -74,13 +78,6 @@ function mapSplatParamsForModernLoader(params, hasSplat) {
74
78
  };
75
79
  return rest;
76
80
  }
77
- function createRouteStaticData(opts) {
78
- const staticData = {};
79
- if ('string' == typeof opts.modernRouteId && opts.modernRouteId.length > 0) staticData.modernRouteId = opts.modernRouteId;
80
- if (void 0 !== opts.modernRouteLoader) staticData.modernRouteLoader = opts.modernRouteLoader;
81
- if (void 0 !== opts.modernRouteAction) staticData.modernRouteAction = opts.modernRouteAction;
82
- return staticData;
83
- }
84
81
  function getLoaderSignal(ctx) {
85
82
  const abortSignal = ctx?.abortController?.signal;
86
83
  if (abortSignal instanceof AbortSignal) return abortSignal;
@@ -147,6 +144,9 @@ function modernLoaderToTanstack(opts, modernLoader) {
147
144
  };
148
145
  }
149
146
  exports.createRouteStaticData = __webpack_exports__.createRouteStaticData;
147
+ exports.getLoaderHref = __webpack_exports__.getLoaderHref;
148
+ exports.handleModernLoaderError = __webpack_exports__.handleModernLoaderError;
149
+ exports.handleModernLoaderResult = __webpack_exports__.handleModernLoaderResult;
150
150
  exports.isAbsoluteUrl = __webpack_exports__.isAbsoluteUrl;
151
151
  exports.isRedirectResponse = __webpack_exports__.isRedirectResponse;
152
152
  exports.isResponse = __webpack_exports__.isResponse;
@@ -156,6 +156,9 @@ exports.modernLoaderToTanstack = __webpack_exports__.modernLoaderToTanstack;
156
156
  exports.throwTanstackRedirect = __webpack_exports__.throwTanstackRedirect;
157
157
  for(var __rspack_i in __webpack_exports__)if (-1 === [
158
158
  "createRouteStaticData",
159
+ "getLoaderHref",
160
+ "handleModernLoaderError",
161
+ "handleModernLoaderResult",
159
162
  "isAbsoluteUrl",
160
163
  "isRedirectResponse",
161
164
  "isResponse",
@@ -46,7 +46,7 @@ const external_lifecycle_js_namespaceObject = require("./lifecycle.js");
46
46
  const external_pluginShared_js_namespaceObject = require("./pluginShared.js");
47
47
  const external_prefetchLink_js_namespaceObject = require("./prefetchLink.js");
48
48
  const external_routeHooks_js_namespaceObject = require("./routeHooks.js");
49
- const external_routeTree_js_namespaceObject = require("./routeTree.js");
49
+ const index_js_namespaceObject = require("./routeTree/index.js");
50
50
  const client_js_namespaceObject = require("./rsc/client.js");
51
51
  const external_types_js_namespaceObject = require("./types.js");
52
52
  const tanstackRouterPlugin = (userConfig = {})=>{
@@ -72,7 +72,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
72
72
  if (cachedRouteTree) return cachedRouteTree;
73
73
  const routeObjects = getRouteObjects();
74
74
  if (!routeObjects.length) return null;
75
- cachedRouteTree = (0, external_routeTree_js_namespaceObject.createRouteTreeFromRouteObjects)(routeObjects, {
75
+ cachedRouteTree = (0, index_js_namespaceObject.createRouteTreeFromRouteObjects)(routeObjects, {
76
76
  rscPayloadRouter: (0, context_namespaceObject.getGlobalEnableRsc)()
77
77
  });
78
78
  return cachedRouteTree;
@@ -159,7 +159,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
159
159
  if (hasSSRBootstrap && getRouteObjects().length > 0) {
160
160
  const runtimeContext = context;
161
161
  const router = getRouter(runtimeContext, getClientBasename(runtimeContext));
162
- if (null != router) return (0, external_clientHydration_js_namespaceObject.getTanstackSsrHydrationPromise)(router).then(()=>void 0);
162
+ if (router) return (0, external_clientHydration_js_namespaceObject.getTanstackSsrHydrationPromise)(router).then(()=>void 0);
163
163
  }
164
164
  });
165
165
  api.wrapRoot((App)=>{
@@ -189,20 +189,19 @@ const tanstackRouterPlugin = (userConfig = {})=>{
189
189
  router
190
190
  };
191
191
  const hasSSRBootstrap = "u" > typeof window && (Boolean(window.$_TSR) || (0, external_clientHydration_js_namespaceObject.hasTanstackSsrHydrationRecord)(router));
192
- const needsRouterClient = hasSSRBootstrap;
193
- if (needsRouterClient) hooks.onBeforeHydrateRouter.call({
192
+ if (hasSSRBootstrap) hooks.onBeforeHydrateRouter.call({
194
193
  ...lifecycleContext,
195
194
  phase: 'hydrate',
196
195
  router,
197
196
  runtimeContext: runtimeState
198
197
  });
199
- const RouterContent = needsRouterClient ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_clientHydration_js_namespaceObject.ModernRouterClient, {
198
+ const RouterContent = hasSSRBootstrap ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_clientHydration_js_namespaceObject.ModernRouterClient, {
200
199
  router: router
201
200
  }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
202
201
  router: router
203
202
  });
204
203
  const HydratableRouterContent = (0, external_hydrationBoundary_js_namespaceObject.wrapTanstackSsrHydrationBoundary)(RouterContent, hasSSRBootstrap);
205
- if (needsRouterClient) hooks.onAfterHydrateRouter.call({
204
+ if (hasSSRBootstrap) hooks.onAfterHydrateRouter.call({
206
205
  ...lifecycleContext,
207
206
  phase: 'hydrate',
208
207
  router,
@@ -43,7 +43,7 @@ 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
45
  const external_pluginShared_js_namespaceObject = require("./pluginShared.js");
46
- const external_routeTree_js_namespaceObject = require("./routeTree.js");
46
+ const index_js_namespaceObject = require("./routeTree/index.js");
47
47
  const payloadRouter_js_namespaceObject = require("./rsc/payloadRouter.js");
48
48
  const payloadStorage_js_namespaceObject = require("./rsc/payloadStorage.js");
49
49
  const external_ssrManagedTags_js_namespaceObject = require("./ssrManagedTags.js");
@@ -57,16 +57,15 @@ const tanstackRouterPlugin = (userConfig = {})=>{
57
57
  api.onBeforeRender(async (context, interrupt)=>{
58
58
  const routeConfig = (0, external_pluginShared_js_namespaceObject.getTanstackRouteConfig)(api, userConfig);
59
59
  const { mergedConfig } = routeConfig;
60
- const serializationAdapters = (0, context_namespaceObject.getGlobalEnableRsc)() ? (await import("./rsc/server.js")).getTanstackRscSerializationAdapters() : void 0;
61
60
  const enableRsc = (0, context_namespaceObject.getGlobalEnableRsc)();
61
+ const serializationAdapters = enableRsc ? (await import("./rsc/server.js")).getTanstackRscSerializationAdapters() : void 0;
62
62
  const { basename = '' } = mergedConfig;
63
63
  if (!routeConfig.hasConfiguredRoutes) return;
64
64
  const hooks = api.getHooks();
65
65
  await hooks.onBeforeCreateRoutes.call(context);
66
66
  const modifiedRouteObjects = (0, external_pluginShared_js_namespaceObject.createTanstackRouteObjects)({
67
67
  hooks,
68
- routeConfig,
69
- ssrMode: context.ssrContext?.mode
68
+ routeConfig
70
69
  });
71
70
  if (!modifiedRouteObjects.length) return;
72
71
  const { request, nonce, baseUrl, loaderFailureMode = 'errorBoundary' } = context.ssrContext;
@@ -85,7 +84,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
85
84
  request: ssrRequest,
86
85
  requestContext
87
86
  };
88
- const routeTree = (0, external_routeTree_js_namespaceObject.createRouteTreeFromRouteObjects)(modifiedRouteObjects);
87
+ const routeTree = (0, index_js_namespaceObject.createRouteTreeFromRouteObjects)(modifiedRouteObjects);
89
88
  const history = (0, react_router_namespaceObject.createMemoryHistory)({
90
89
  initialEntries: [
91
90
  initialHref
@@ -160,7 +159,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
160
159
  }
161
160
  const ssrScriptTags = serverRouter.serverSsr?.takeBufferedScripts?.();
162
161
  const hydrationScripts = (0, external_ssrManagedTags_js_namespaceObject.routerManagedTagsToHtml)(ssrScriptTags);
163
- const matchedRouteIds = (0, external_routeTree_js_namespaceObject.getModernRouteIdsFromMatches)(serverRouter);
162
+ const matchedRouteIds = (0, index_js_namespaceObject.getModernRouteIdsFromMatches)(serverRouter);
164
163
  const routerServerSnapshot = (0, external_lifecycle_js_namespaceObject.createRouterServerSnapshot)({
165
164
  framework: 'tanstack',
166
165
  basename: _basename,
@@ -56,11 +56,10 @@ function getTanstackRouteConfig(api, userConfig) {
56
56
  hasConfiguredRoutes: Boolean(finalRouteConfig.routes) || Boolean(mergedConfig.createRoutes)
57
57
  };
58
58
  }
59
- function createTanstackRouteObjects({ hooks, routeConfig, ssrMode }) {
59
+ function createTanstackRouteObjects({ hooks, routeConfig }) {
60
60
  const { mergedConfig, finalRouteConfig } = routeConfig;
61
61
  const routeObjects = void 0 !== mergedConfig.createRoutes ? mergedConfig.createRoutes() : (0, external_utils_js_namespaceObject.createTanstackRouteObjectsFromConfig)({
62
- routesConfig: finalRouteConfig,
63
- ssrMode
62
+ routesConfig: finalRouteConfig
64
63
  }) ?? [];
65
64
  return hooks.modifyRoutes.call(routeObjects);
66
65
  }
@@ -68,7 +68,7 @@ function createServerLazyImportComponent(lazyImport, fallbackComponent) {
68
68
  Component.preload = load;
69
69
  return Component;
70
70
  }
71
- function toRouteComponent(routeObject, options = {}) {
71
+ function toRouteComponent(routeObject) {
72
72
  const route = routeObject;
73
73
  const lazyImport = 'function' == typeof route.lazyImport ? route.lazyImport : void 0;
74
74
  const routeComponent = route.Component || route.component;
@@ -33,6 +33,7 @@ __webpack_require__.d(__webpack_exports__, {
33
33
  });
34
34
  const context_namespaceObject = require("@modern-js/runtime/context");
35
35
  const react_router_namespaceObject = require("@tanstack/react-router");
36
+ const routeStaticData_js_namespaceObject = require("../../shared/routeStaticData.js");
36
37
  const external_outlet_js_namespaceObject = require("../outlet.js");
37
38
  const external_components_js_namespaceObject = require("./components.js");
38
39
  const external_loaders_js_namespaceObject = require("./loaders.js");
@@ -46,7 +47,7 @@ function createRouteFromRouteObject(opts) {
46
47
  const shouldRevalidate = modernRouteObject.shouldRevalidate;
47
48
  const shouldReload = (0, external_loaders_js_namespaceObject.createModernShouldReload)(shouldRevalidate, revalidationState);
48
49
  const stableFallbackId = routeObject.id || modernRouteObject.file || pathlessFallbackId;
49
- const component = (0, external_components_js_namespaceObject.toRouteComponent)(routeObject, options);
50
+ const component = (0, external_components_js_namespaceObject.toRouteComponent)(routeObject);
50
51
  const base = {
51
52
  getParentRoute: ()=>parent,
52
53
  component,
@@ -54,7 +55,7 @@ function createRouteFromRouteObject(opts) {
54
55
  errorComponent: (0, external_components_js_namespaceObject.toErrorComponent)(routeObject),
55
56
  validateSearch: modernRouteObject.validateSearch,
56
57
  loaderDeps: modernRouteObject.loaderDeps,
57
- staticData: (0, external_staticData_js_namespaceObject.createRouteStaticData)({
58
+ staticData: (0, routeStaticData_js_namespaceObject.createRouteStaticData)({
58
59
  modernRouteId: routeObject.id,
59
60
  modernRouteAction: modernRouteObject.action,
60
61
  modernRouteHandle: (0, external_staticData_js_namespaceObject.mergeModernRouteHandle)(modernRouteObject),
@@ -101,7 +102,7 @@ function createRouteTreeFromRouteObjects(routes, options = {}) {
101
102
  validateSearch: rootLikeRoute?.validateSearch,
102
103
  loaderDeps: rootLikeRoute?.loaderDeps,
103
104
  notFoundComponent: context_namespaceObject.DefaultNotFound,
104
- staticData: (0, external_staticData_js_namespaceObject.createRouteStaticData)({
105
+ staticData: (0, routeStaticData_js_namespaceObject.createRouteStaticData)({
105
106
  modernRouteId: rootLikeRoute?.id,
106
107
  modernRouteAction: rootLikeRoute?.action,
107
108
  modernRouteHandle: rootLikeRoute ? (0, external_staticData_js_namespaceObject.mergeModernRouteHandle)(rootLikeRoute) : void 0,
@@ -31,7 +31,6 @@ __webpack_require__.d(__webpack_exports__, {
31
31
  createModernShouldReload: ()=>createModernShouldReload,
32
32
  wrapRouteObjectLoader: ()=>wrapRouteObjectLoader
33
33
  });
34
- const react_router_namespaceObject = require("@tanstack/react-router");
35
34
  const external_loaderBridge_js_namespaceObject = require("../loaderBridge.js");
36
35
  const payloadRouter_js_namespaceObject = require("../rsc/payloadRouter.js");
37
36
  function isModernDeferredData(value) {
@@ -43,22 +42,10 @@ function normalizeModernLoaderResult(result) {
43
42
  return isModernDeferredData(result) ? result.data : result;
44
43
  }
45
44
  function normalizeModernLoaderResponse(result) {
46
- if ((0, external_loaderBridge_js_namespaceObject.isResponse)(result)) {
47
- if ((0, external_loaderBridge_js_namespaceObject.isRedirectResponse)(result)) {
48
- const location = result.headers.get('Location') || '/';
49
- (0, external_loaderBridge_js_namespaceObject.throwTanstackRedirect)(location);
50
- }
51
- if (404 === result.status) throw (0, react_router_namespaceObject.notFound)();
52
- }
53
- return normalizeModernLoaderResult(result);
54
- }
55
- function createModernRequest(input, signal) {
56
- return new Request(input, {
57
- signal
58
- });
45
+ return normalizeModernLoaderResult((0, external_loaderBridge_js_namespaceObject.handleModernLoaderResult)(result));
59
46
  }
60
47
  function getModernUrlFromLoaderContext(ctx) {
61
- const href = 'string' == typeof ctx?.location ? ctx.location : ctx?.location?.publicHref || ctx?.location?.href || ctx?.location?.url?.href || '/';
48
+ const href = (0, external_loaderBridge_js_namespaceObject.getLoaderHref)(ctx) || '/';
62
49
  const baseRequest = ctx?.context?.request instanceof Request ? ctx.context.request : void 0;
63
50
  const baseUrl = baseRequest?.url || ("u" > typeof window ? window.origin : 'http://localhost');
64
51
  return new URL(href || '/', baseUrl);
@@ -85,20 +72,6 @@ function createModernShouldReload(shouldRevalidate, state) {
85
72
  return 'boolean' == typeof result ? result : void 0;
86
73
  };
87
74
  }
88
- function isRouteObjectSplatRoute(route) {
89
- return 'string' == typeof route.path && route.path.includes('*');
90
- }
91
- function mapParamsForRouteObjectLoader({ route, params }) {
92
- if (isRouteObjectSplatRoute(route)) {
93
- const { _splat, ...rest } = params;
94
- if (void 0 !== _splat) return {
95
- ...rest,
96
- '*': _splat
97
- };
98
- return rest;
99
- }
100
- return params;
101
- }
102
75
  function wrapRouteObjectLoader(route, revalidationState, options = {}) {
103
76
  const modernRoute = route;
104
77
  const routeLoader = modernRoute.loader;
@@ -111,14 +84,13 @@ function wrapRouteObjectLoader(route, revalidationState, options = {}) {
111
84
  } catch {}
112
85
  const signal = ctx?.abortController?.signal || ctx?.signal || new AbortController().signal;
113
86
  const baseRequest = ctx?.context?.request instanceof Request ? ctx.context.request : void 0;
114
- const href = 'string' == typeof ctx?.location ? ctx.location : ctx?.location?.publicHref || ctx?.location?.href || ctx?.location?.url?.href || '';
87
+ const href = (0, external_loaderBridge_js_namespaceObject.getLoaderHref)(ctx);
115
88
  const request = void 0 !== baseRequest ? new Request(baseRequest, {
116
89
  signal
117
- }) : createModernRequest(href, signal);
118
- const params = mapParamsForRouteObjectLoader({
119
- route,
120
- params: ctx.params || {}
90
+ }) : new Request(href, {
91
+ signal
121
92
  });
93
+ const params = (0, external_loaderBridge_js_namespaceObject.mapSplatParamsForModernLoader)(ctx.params || {}, 'string' == typeof route.path && route.path.includes('*'));
122
94
  const loadModernData = async ()=>{
123
95
  const result = await routeLoader({
124
96
  request,
@@ -135,15 +107,7 @@ function wrapRouteObjectLoader(route, revalidationState, options = {}) {
135
107
  });
136
108
  return loadModernData();
137
109
  } catch (err) {
138
- if ((0, external_loaderBridge_js_namespaceObject.isResponse)(err)) {
139
- if ((0, external_loaderBridge_js_namespaceObject.isTanstackRedirect)(err)) throw err;
140
- if ((0, external_loaderBridge_js_namespaceObject.isRedirectResponse)(err)) {
141
- const location = err.headers.get('Location') || '/';
142
- (0, external_loaderBridge_js_namespaceObject.throwTanstackRedirect)(location);
143
- }
144
- if (404 === err.status) throw (0, react_router_namespaceObject.notFound)();
145
- }
146
- throw err;
110
+ (0, external_loaderBridge_js_namespaceObject.handleModernLoaderError)(err);
147
111
  }
148
112
  };
149
113
  }
@@ -35,27 +35,11 @@ function mergeModernRouteHandle(route) {
35
35
  };
36
36
  return Object.keys(handle).length > 0 ? handle : void 0;
37
37
  }
38
- function createRouteStaticData(opts) {
39
- const staticData = {};
40
- if (opts.modernRouteId) staticData.modernRouteId = opts.modernRouteId;
41
- if (opts.modernRouteAction) staticData.modernRouteAction = opts.modernRouteAction;
42
- if (opts.modernRouteHandle) staticData.modernRouteHandle = opts.modernRouteHandle;
43
- if (opts.modernRouteHasAction) staticData.modernRouteHasAction = true;
44
- if (opts.modernRouteHasClientLoader) staticData.modernRouteHasClientLoader = true;
45
- if (opts.modernRouteHasLoader) staticData.modernRouteHasLoader = true;
46
- if (opts.modernRouteIsClientComponent) staticData.modernRouteIsClientComponent = true;
47
- if (opts.modernRouteLoader) staticData.modernRouteLoader = opts.modernRouteLoader;
48
- if (opts.modernRouteShouldRevalidate) staticData.modernRouteShouldRevalidate = opts.modernRouteShouldRevalidate;
49
- return Object.keys(staticData).length > 0 ? staticData : void 0;
50
- }
51
38
  __webpack_require__.d(__webpack_exports__, {
52
- createRouteStaticData: ()=>createRouteStaticData,
53
39
  mergeModernRouteHandle: ()=>mergeModernRouteHandle
54
40
  });
55
- exports.createRouteStaticData = __webpack_exports__.createRouteStaticData;
56
41
  exports.mergeModernRouteHandle = __webpack_exports__.mergeModernRouteHandle;
57
42
  for(var __rspack_i in __webpack_exports__)if (-1 === [
58
- "createRouteStaticData",
59
43
  "mergeModernRouteHandle"
60
44
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
61
45
  Object.defineProperty(exports, '__esModule', {
@@ -31,8 +31,7 @@ __webpack_require__.r(__webpack_exports__);
31
31
  __webpack_require__.d(__webpack_exports__, {
32
32
  CompositeComponent: ()=>external_CompositeComponent_js_namespaceObject.CompositeComponent,
33
33
  createTanstackRscValueFromFlight: ()=>createTanstackRscValueFromFlight,
34
- getTanstackRscSerializationAdapters: ()=>getTanstackRscSerializationAdapters,
35
- rscSerializationAdapter: ()=>rscSerializationAdapter
34
+ getTanstackRscSerializationAdapters: ()=>getTanstackRscSerializationAdapters
36
35
  });
37
36
  const react_router_namespaceObject = require("@tanstack/react-router");
38
37
  const external_CompositeComponent_js_namespaceObject = require("./CompositeComponent.js");
@@ -64,16 +63,13 @@ function getTanstackRscSerializationAdapters() {
64
63
  adapter
65
64
  ];
66
65
  }
67
- const rscSerializationAdapter = getTanstackRscSerializationAdapters;
68
66
  exports.CompositeComponent = __webpack_exports__.CompositeComponent;
69
67
  exports.createTanstackRscValueFromFlight = __webpack_exports__.createTanstackRscValueFromFlight;
70
68
  exports.getTanstackRscSerializationAdapters = __webpack_exports__.getTanstackRscSerializationAdapters;
71
- exports.rscSerializationAdapter = __webpack_exports__.rscSerializationAdapter;
72
69
  for(var __rspack_i in __webpack_exports__)if (-1 === [
73
70
  "CompositeComponent",
74
71
  "createTanstackRscValueFromFlight",
75
- "getTanstackRscSerializationAdapters",
76
- "rscSerializationAdapter"
72
+ "getTanstackRscSerializationAdapters"
77
73
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
78
74
  Object.defineProperty(exports, '__esModule', {
79
75
  value: true
@@ -31,8 +31,7 @@ __webpack_require__.d(__webpack_exports__, {
31
31
  CompositeComponent: ()=>external_CompositeComponent_js_namespaceObject.CompositeComponent,
32
32
  createCompositeComponent: ()=>createCompositeComponent,
33
33
  getTanstackRscSerializationAdapters: ()=>getTanstackRscSerializationAdapters,
34
- renderServerComponent: ()=>renderServerComponent,
35
- rscSerializationAdapter: ()=>rscSerializationAdapter
34
+ renderServerComponent: ()=>renderServerComponent
36
35
  });
37
36
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
38
37
  const server_namespaceObject = require("@modern-js/runtime/rsc/server");
@@ -152,7 +151,6 @@ function getTanstackRscSerializationAdapters() {
152
151
  adapter
153
152
  ];
154
153
  }
155
- const rscSerializationAdapter = getTanstackRscSerializationAdapters;
156
154
  function createReadableStreamEmitter() {
157
155
  let closed = false;
158
156
  const queue = [];
@@ -233,13 +231,11 @@ exports.CompositeComponent = __webpack_exports__.CompositeComponent;
233
231
  exports.createCompositeComponent = __webpack_exports__.createCompositeComponent;
234
232
  exports.getTanstackRscSerializationAdapters = __webpack_exports__.getTanstackRscSerializationAdapters;
235
233
  exports.renderServerComponent = __webpack_exports__.renderServerComponent;
236
- exports.rscSerializationAdapter = __webpack_exports__.rscSerializationAdapter;
237
234
  for(var __rspack_i in __webpack_exports__)if (-1 === [
238
235
  "CompositeComponent",
239
236
  "createCompositeComponent",
240
237
  "getTanstackRscSerializationAdapters",
241
- "renderServerComponent",
242
- "rscSerializationAdapter"
238
+ "renderServerComponent"
243
239
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
244
240
  Object.defineProperty(exports, '__esModule', {
245
241
  value: true
@@ -32,6 +32,7 @@ __webpack_require__.d(__webpack_exports__, {
32
32
  submitRouteAction: ()=>submitRouteAction
33
33
  });
34
34
  const external_formData_js_namespaceObject = require("./formData.js");
35
+ const external_loaderBridge_js_namespaceObject = require("./loaderBridge.js");
35
36
  class RouteActionResponseError extends Error {
36
37
  constructor(response, data){
37
38
  super(`Route action failed with status ${response.status}`);
@@ -55,16 +56,6 @@ function resolveRouteHandlers(router, actionTo) {
55
56
  params: routeParams
56
57
  };
57
58
  }
58
- function isRedirectResponse(value) {
59
- if (!(value instanceof Response)) return false;
60
- return [
61
- 301,
62
- 302,
63
- 303,
64
- 307,
65
- 308
66
- ].includes(value.status);
67
- }
68
59
  async function parseResponseData(response) {
69
60
  if (204 === response.status) return null;
70
61
  const contentType = response.headers.get('Content-Type') || '';
@@ -95,7 +86,7 @@ async function submitRouteAction({ router, target, options = {}, isFetcher = fal
95
86
  });
96
87
  if (result instanceof Response) {
97
88
  const redirectTo = result.headers.get('X-Modernjs-Redirect') || result.headers.get('Location');
98
- if (redirectTo || isRedirectResponse(result)) {
89
+ if (redirectTo || (0, external_loaderBridge_js_namespaceObject.isRedirectResponse)(result)) {
99
90
  await router.navigate({
100
91
  to: redirectTo || '/'
101
92
  });
@@ -134,7 +125,7 @@ async function submitRouteAction({ router, target, options = {}, isFetcher = fal
134
125
  });
135
126
  if (result instanceof Response) {
136
127
  const redirectTo = result.headers.get('X-Modernjs-Redirect') || result.headers.get('Location');
137
- if (redirectTo || isRedirectResponse(result)) {
128
+ if (redirectTo || (0, external_loaderBridge_js_namespaceObject.isRedirectResponse)(result)) {
138
129
  await router.navigate({
139
130
  to: redirectTo || '/'
140
131
  });
@@ -42,6 +42,7 @@ __webpack_require__.d(__webpack_exports__, {
42
42
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
43
43
  const external_react_namespaceObject = require("react");
44
44
  var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
45
+ const staticData_js_namespaceObject = require("./routeTree/staticData.js");
45
46
  function withGlobalLayout(Component, globalApp) {
46
47
  if (!globalApp) return Component;
47
48
  const GlobalLayout = globalApp;
@@ -52,12 +53,6 @@ function withGlobalLayout(Component, globalApp) {
52
53
  });
53
54
  };
54
55
  }
55
- function getRouteHandle(route) {
56
- return {
57
- ...route.handle,
58
- ...'object' == typeof route.config ? route.config?.handle : {}
59
- };
60
- }
61
56
  function toTanstackRouteObject(route, globalApp) {
62
57
  if ('nested' === route.type) return {
63
58
  path: route.path,
@@ -65,7 +60,7 @@ function toTanstackRouteObject(route, globalApp) {
65
60
  loader: route.loader,
66
61
  action: route.action,
67
62
  shouldRevalidate: route.shouldRevalidate,
68
- handle: getRouteHandle(route),
63
+ handle: (0, staticData_js_namespaceObject.mergeModernRouteHandle)(route) ?? {},
69
64
  index: route.index,
70
65
  hasLoader: route.hasLoader || Boolean(route.loader),
71
66
  hasClientLoader: route.hasClientLoader || Boolean(route.clientData),
@@ -27,19 +27,15 @@ var __webpack_require__ = {};
27
27
  })();
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
+ function createRouteStaticData(opts) {
31
+ return Object.fromEntries(Object.entries(opts).filter(([, value])=>Boolean(value)));
32
+ }
30
33
  __webpack_require__.d(__webpack_exports__, {
31
- CompositeComponent: ()=>external_client_js_namespaceObject.CompositeComponent,
32
- getTanstackRscSerializationAdapters: ()=>external_client_js_namespaceObject.getTanstackRscSerializationAdapters,
33
- rscSerializationAdapter: ()=>external_client_js_namespaceObject.rscSerializationAdapter
34
+ createRouteStaticData: ()=>createRouteStaticData
34
35
  });
35
- const external_client_js_namespaceObject = require("./client.js");
36
- exports.CompositeComponent = __webpack_exports__.CompositeComponent;
37
- exports.getTanstackRscSerializationAdapters = __webpack_exports__.getTanstackRscSerializationAdapters;
38
- exports.rscSerializationAdapter = __webpack_exports__.rscSerializationAdapter;
36
+ exports.createRouteStaticData = __webpack_exports__.createRouteStaticData;
39
37
  for(var __rspack_i in __webpack_exports__)if (-1 === [
40
- "CompositeComponent",
41
- "getTanstackRscSerializationAdapters",
42
- "rscSerializationAdapter"
38
+ "createRouteStaticData"
43
39
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
44
40
  Object.defineProperty(exports, '__esModule', {
45
41
  value: true
@@ -1,5 +1,6 @@
1
1
  import { getPathWithoutExt } from "@modern-js/runtime/cli";
2
2
  import { findExists, formatImportPath, slash } from "@modern-js/utils";
3
+ import { createRouteStaticData } from "../../shared/routeStaticData.mjs";
3
4
  const JS_OR_TS_EXTS = [
4
5
  '.js',
5
6
  '.jsx',
@@ -50,12 +51,13 @@ function isIndexRoute(route) {
50
51
  return 'nested' === extras.type && Boolean(extras.index);
51
52
  }
52
53
  function createRouteStaticDataSnippet(opts) {
53
- const staticDataLines = [];
54
- if (opts.modernRouteId) staticDataLines.push(`modernRouteId: ${quote(opts.modernRouteId)},`);
55
- if (opts.loaderName) staticDataLines.push(`modernRouteLoader: ${opts.loaderName},`);
56
- if (opts.actionName) staticDataLines.push(`modernRouteAction: ${opts.actionName},`);
57
- if (!staticDataLines.length) return null;
58
- return `staticData: createRouteStaticData({\n ${staticDataLines.join('\n ')}\n }),`;
54
+ const staticData = createRouteStaticData({
55
+ modernRouteId: opts.modernRouteId && quote(opts.modernRouteId),
56
+ modernRouteLoader: opts.loaderName,
57
+ modernRouteAction: opts.actionName
58
+ });
59
+ const entries = Object.entries(staticData);
60
+ return entries.length > 0 ? `staticData: createRouteStaticData({\n ${entries.map(([key, value])=>`${key}: ${value},`).join('\n ')}\n }),` : null;
59
61
  }
60
62
  export { toTanstackPath } from "../../runtime/routeTree/paths.mjs";
61
63
  export { createRouteStaticDataSnippet, isIndexRoute, isPathlessLayout, normalizeRelativeImport, pickModernLoaderModule, pickRouteSearchContractModules, quote, resolveFileNoExt };
@@ -1,7 +1,7 @@
1
1
  import { RouterProvider } from "@tanstack/react-router";
2
2
  import { createElement } from "react";
3
3
  import { withModernRouteMatchContext } from "./outlet.mjs";
4
- import { pickRouteModuleComponent } from "./routeTree.mjs";
4
+ import { pickRouteModuleComponent } from "./routeTree/index.mjs";
5
5
  const routerHydrationRecords = new WeakMap();
6
6
  const routeModulesKey = '_routeModules';
7
7
  function getCachedRouteModule(routeId) {
@@ -35,13 +35,6 @@ function mapSplatParamsForModernLoader(params, hasSplat) {
35
35
  };
36
36
  return rest;
37
37
  }
38
- function createRouteStaticData(opts) {
39
- const staticData = {};
40
- if ('string' == typeof opts.modernRouteId && opts.modernRouteId.length > 0) staticData.modernRouteId = opts.modernRouteId;
41
- if (void 0 !== opts.modernRouteLoader) staticData.modernRouteLoader = opts.modernRouteLoader;
42
- if (void 0 !== opts.modernRouteAction) staticData.modernRouteAction = opts.modernRouteAction;
43
- return staticData;
44
- }
45
38
  function getLoaderSignal(ctx) {
46
39
  const abortSignal = ctx?.abortController?.signal;
47
40
  if (abortSignal instanceof AbortSignal) return abortSignal;
@@ -107,4 +100,5 @@ function modernLoaderToTanstack(opts, modernLoader) {
107
100
  }
108
101
  };
109
102
  }
110
- export { createRouteStaticData, isAbsoluteUrl, isRedirectResponse, isResponse, isTanstackRedirect, mapSplatParamsForModernLoader, modernLoaderToTanstack, throwTanstackRedirect };
103
+ export { createRouteStaticData } from "../shared/routeStaticData.mjs";
104
+ export { getLoaderHref, handleModernLoaderError, handleModernLoaderResult, isAbsoluteUrl, isRedirectResponse, isResponse, isTanstackRedirect, mapSplatParamsForModernLoader, modernLoaderToTanstack, throwTanstackRedirect };