@bleedingdev/modern-js-plugin-tanstack 3.5.0-ultramodern.36 → 3.5.0-ultramodern.37

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 (76) hide show
  1. package/dist/cjs/cli/tanstackTypes/shared.js +12 -19
  2. package/dist/cjs/cli/tanstackTypes/source.js +24 -19
  3. package/dist/cjs/runtime/blockingSubscribe.js +0 -7
  4. package/dist/cjs/runtime/clientHydration.js +2 -14
  5. package/dist/cjs/runtime/loaderBridge.js +3 -10
  6. package/dist/cjs/runtime/pluginShared.js +0 -3
  7. package/dist/cjs/runtime/register.js +1 -47
  8. package/dist/cjs/runtime/rsc/ReplayableStream.js +0 -4
  9. package/dist/cjs/runtime/rsc/payloadFetch.js +3 -16
  10. package/dist/cjs/runtime/rsc/payloadRoutes.js +2 -14
  11. package/dist/cjs/runtime/rsc/shared.js +2 -5
  12. package/dist/cjs/runtime/shared/isAbsoluteUrl.js +47 -0
  13. package/dist/esm/cli/index.mjs +4 -4
  14. package/dist/esm/cli/tanstackTypes/shared.mjs +12 -19
  15. package/dist/esm/cli/tanstackTypes/source.mjs +23 -18
  16. package/dist/esm/runtime/blockingSubscribe.mjs +1 -1
  17. package/dist/esm/runtime/clientHydration.mjs +1 -1
  18. package/dist/esm/runtime/loaderBridge.mjs +1 -8
  19. package/dist/esm/runtime/pluginShared.mjs +1 -1
  20. package/dist/esm/runtime/register.mjs +0 -14
  21. package/dist/esm/runtime/rsc/ReplayableStream.mjs +1 -1
  22. package/dist/esm/runtime/rsc/payloadFetch.mjs +2 -9
  23. package/dist/esm/runtime/rsc/payloadRoutes.mjs +1 -1
  24. package/dist/esm/runtime/rsc/shared.mjs +1 -1
  25. package/dist/esm/runtime/shared/isAbsoluteUrl.mjs +9 -0
  26. package/dist/esm-node/cli/index.mjs +4 -4
  27. package/dist/esm-node/cli/tanstackTypes/shared.mjs +12 -19
  28. package/dist/esm-node/cli/tanstackTypes/source.mjs +23 -18
  29. package/dist/esm-node/runtime/blockingSubscribe.mjs +1 -1
  30. package/dist/esm-node/runtime/clientHydration.mjs +1 -1
  31. package/dist/esm-node/runtime/loaderBridge.mjs +1 -8
  32. package/dist/esm-node/runtime/pluginShared.mjs +1 -1
  33. package/dist/esm-node/runtime/register.mjs +0 -14
  34. package/dist/esm-node/runtime/rsc/ReplayableStream.mjs +1 -1
  35. package/dist/esm-node/runtime/rsc/payloadFetch.mjs +2 -9
  36. package/dist/esm-node/runtime/rsc/payloadRoutes.mjs +1 -1
  37. package/dist/esm-node/runtime/rsc/shared.mjs +1 -1
  38. package/dist/esm-node/runtime/shared/isAbsoluteUrl.mjs +10 -0
  39. package/dist/types/cli/tanstackTypes/shared.d.ts +1 -1
  40. package/dist/types/cli/tanstackTypes/source.d.ts +3 -1
  41. package/dist/types/runtime/blockingSubscribe.d.ts +0 -2
  42. package/dist/types/runtime/clientHydration.d.ts +0 -9
  43. package/dist/types/runtime/formData.d.ts +2 -1
  44. package/dist/types/runtime/loaderBridge.d.ts +2 -1
  45. package/dist/types/runtime/pluginShared.d.ts +2 -3
  46. package/dist/types/runtime/register.d.ts +1 -9
  47. package/dist/types/runtime/routeTree/types.d.ts +2 -1
  48. package/dist/types/runtime/rsc/ReplayableStream.d.ts +3 -2
  49. package/dist/types/runtime/rsc/SlotContext.d.ts +2 -1
  50. package/dist/types/runtime/rsc/payloadFetch.d.ts +2 -4
  51. package/dist/types/runtime/rsc/payloadRoutes.d.ts +3 -6
  52. package/dist/types/runtime/rsc/shared.d.ts +0 -1
  53. package/dist/types/runtime/shared/isAbsoluteUrl.d.ts +1 -0
  54. package/dist/types/runtime/ssrTypes.d.ts +3 -2
  55. package/dist/types/runtime/types.d.ts +2 -3
  56. package/package.json +15 -16
  57. package/src/cli/tanstackTypes/canonicalRoutes.ts +1 -1
  58. package/src/cli/tanstackTypes/shared.ts +24 -30
  59. package/src/cli/tanstackTypes/source.ts +31 -21
  60. package/src/runtime/blockingSubscribe.ts +2 -2
  61. package/src/runtime/clientHydration.ts +5 -10
  62. package/src/runtime/formData.ts +1 -1
  63. package/src/runtime/loaderBridge.ts +3 -9
  64. package/src/runtime/pluginShared.ts +3 -3
  65. package/src/runtime/register.ts +5 -37
  66. package/src/runtime/routeTree/types.ts +1 -1
  67. package/src/runtime/rsc/ReplayableStream.ts +2 -2
  68. package/src/runtime/rsc/SlotContext.tsx +1 -1
  69. package/src/runtime/rsc/payloadFetch.ts +5 -11
  70. package/src/runtime/rsc/payloadRoutes.ts +6 -6
  71. package/src/runtime/rsc/shared.ts +1 -1
  72. package/src/runtime/shared/isAbsoluteUrl.ts +8 -0
  73. package/src/runtime/ssrTypes.ts +2 -2
  74. package/src/runtime/submitAction.ts +17 -10
  75. package/src/runtime/types.ts +1 -8
  76. package/tests/router/register.test.ts +1 -39
@@ -1,11 +1,15 @@
1
+ import node_path from "node:path";
1
2
  import { makeLegalIdentifier } from "@modern-js/runtime/cli";
2
- import path from "path";
3
3
  import { createRouteStaticDataSnippet, isIndexRoute, isPathlessLayout, normalizeRelativeImport, pickModernLoaderModule, pickRouteSearchContractModules, quote, resolveFileNoExt, toTanstackPath } from "./shared.mjs";
4
4
  async function generateTanstackRouterTypesSourceForEntry(opts) {
5
5
  const { appContext, entryName, generatedDirName = 'modern-tanstack', routes } = opts;
6
- const outDir = path.join(appContext.srcDirectory, generatedDirName, entryName);
7
- const rootModern = routes.find((r)=>r && 'nested' === r.type && r.isRoot);
8
- const topLevel = rootModern ? rootModern.children || [] : routes;
6
+ const outDir = node_path.join(appContext.srcDirectory, generatedDirName, entryName);
7
+ const rootModern = routes.find((r)=>{
8
+ const extras = r;
9
+ return r && 'nested' === extras.type && extras.isRoot;
10
+ });
11
+ const rootExtras = rootModern;
12
+ const topLevel = rootModern ? rootExtras?.children || [] : routes;
9
13
  const imports = [];
10
14
  const statements = [];
11
15
  const loaderImportMap = new Map();
@@ -24,7 +28,7 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
24
28
  pendingImportName = (async ()=>{
25
29
  const resolvedNoExt = await resolveRouteModuleNoExt(componentPath);
26
30
  if (!resolvedNoExt) return null;
27
- const relImport = normalizeRelativeImport(path.relative(outDir, resolvedNoExt));
31
+ const relImport = normalizeRelativeImport(node_path.relative(outDir, resolvedNoExt));
28
32
  const componentName = `component_${componentIndex++}`;
29
33
  imports.push(`import ${componentName} from ${quote(relImport)};`);
30
34
  return componentName;
@@ -38,8 +42,8 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
38
42
  let absNoExt;
39
43
  if (aliasedNoExtPath.startsWith(prefix)) {
40
44
  const rel = aliasedNoExtPath.slice(prefix.length);
41
- absNoExt = path.join(appContext.srcDirectory, rel);
42
- } else absNoExt = path.isAbsolute(aliasedNoExtPath) ? aliasedNoExtPath : path.join(appContext.srcDirectory, aliasedNoExtPath);
45
+ absNoExt = node_path.join(appContext.srcDirectory, rel);
46
+ } else absNoExt = node_path.isAbsolute(aliasedNoExtPath) ? aliasedNoExtPath : node_path.join(appContext.srcDirectory, aliasedNoExtPath);
43
47
  return resolveFileNoExt(absNoExt);
44
48
  };
45
49
  const getImportNamesForLoader = async (aliasedNoExtPath, inline, hasAction)=>{
@@ -51,7 +55,7 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
51
55
  };
52
56
  const resolvedNoExt = await resolveRouteModuleNoExt(aliasedNoExtPath);
53
57
  if (!resolvedNoExt) return null;
54
- const relImport = normalizeRelativeImport(path.relative(outDir, resolvedNoExt));
58
+ const relImport = normalizeRelativeImport(node_path.relative(outDir, resolvedNoExt));
55
59
  const importName = `loader_${loaderIndex++}`;
56
60
  const actionName = hasAction ? importName.replace(/^loader_/, 'action_') : null;
57
61
  if (inline) {
@@ -73,7 +77,7 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
73
77
  if (existing) return existing;
74
78
  const resolvedNoExt = await resolveRouteModuleNoExt(aliasedNoExtPath);
75
79
  if (!resolvedNoExt) return null;
76
- const relImport = normalizeRelativeImport(path.relative(outDir, resolvedNoExt));
80
+ const relImport = normalizeRelativeImport(node_path.relative(outDir, resolvedNoExt));
77
81
  const importName = 'validateSearch' === exportName ? `validateSearch_${validateSearchIndex++}` : `loaderDeps_${loaderDepsIndex++}`;
78
82
  imports.push(`import { ${exportName} as ${importName} } from ${quote(relImport)};`);
79
83
  searchContractImportMap.set(key, importName);
@@ -94,23 +98,24 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
94
98
  const buildRoute = async (opts)=>{
95
99
  const { parentVar, route } = opts;
96
100
  const varName = createRouteVarName(route);
101
+ const routeExtras = route;
97
102
  const loaderInfo = pickModernLoaderModule(route);
98
- const routeAction = route.action;
103
+ const routeAction = routeExtras.action;
99
104
  const loaderImports = loaderInfo ? await getImportNamesForLoader(loaderInfo.loaderPath, loaderInfo.inline, Boolean(loaderInfo.inline && routeAction === loaderInfo.loaderPath)) : null;
100
105
  const loaderName = loaderImports?.loaderName || null;
101
106
  const actionName = loaderImports?.actionName || null;
102
107
  const searchContractInfo = pickRouteSearchContractModules(route);
103
108
  const validateSearchName = searchContractInfo.validateSearchPath ? await getImportNameForSearchContract(searchContractInfo.validateSearchPath, 'validateSearch') : null;
104
109
  const loaderDepsName = searchContractInfo.loaderDepsPath ? await getImportNameForSearchContract(searchContractInfo.loaderDepsPath, 'loaderDeps') : null;
105
- const rawPath = route.path;
110
+ const rawPath = routeExtras.path;
106
111
  const hasSplat = 'string' == typeof rawPath && rawPath.includes('*');
107
112
  const routeOpts = [
108
113
  `getParentRoute: () => ${parentVar},`
109
114
  ];
110
- const componentName = await getImportNameForComponent(route._component);
115
+ const componentName = await getImportNameForComponent(routeExtras._component);
111
116
  if (componentName) routeOpts.push(`component: ${componentName},`);
112
117
  if (isPathlessLayout(route)) {
113
- const id = route.id;
118
+ const id = routeExtras.id;
114
119
  routeOpts.push(`id: ${quote(id || 'pathless')},`);
115
120
  } else {
116
121
  const p = isIndexRoute(route) ? '/' : toTanstackPath(rawPath || '');
@@ -120,12 +125,12 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
120
125
  if (validateSearchName) routeOpts.push(`validateSearch: ${validateSearchName},`);
121
126
  if (loaderDepsName) routeOpts.push(`loaderDeps: ${loaderDepsName},`);
122
127
  const staticDataSnippet = createRouteStaticDataSnippet({
123
- modernRouteId: route.id,
128
+ modernRouteId: routeExtras.id,
124
129
  loaderName,
125
130
  actionName
126
131
  });
127
132
  if (staticDataSnippet) routeOpts.push(staticDataSnippet);
128
- const children = route.children;
133
+ const children = routeExtras.children;
129
134
  const hasChildren = Boolean(children && children.length > 0);
130
135
  const routeCtorVarName = hasChildren ? reserveRouteVarName(`${varName}__base`) : varName;
131
136
  statements.push(`const ${routeCtorVarName} = createRoute({\n ${routeOpts.join('\n ')}\n});`);
@@ -140,7 +145,7 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
140
145
  return varName;
141
146
  };
142
147
  const rootLoaderInfo = rootModern ? pickModernLoaderModule(rootModern) : null;
143
- const rootAction = rootModern?.action;
148
+ const rootAction = rootExtras?.action;
144
149
  const rootLoaderImports = rootLoaderInfo?.loaderPath ? await getImportNamesForLoader(rootLoaderInfo.loaderPath, rootLoaderInfo.inline, Boolean(rootLoaderInfo.inline && rootAction === rootLoaderInfo.loaderPath)) : null;
145
150
  const rootLoaderName = rootLoaderImports?.loaderName || null;
146
151
  const rootActionName = rootLoaderImports?.actionName || null;
@@ -153,7 +158,7 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
153
158
  route
154
159
  }));
155
160
  const rootOpts = [];
156
- const rootComponentName = await getImportNameForComponent(rootModern?._component);
161
+ const rootComponentName = await getImportNameForComponent(rootExtras?._component);
157
162
  if (rootComponentName) rootOpts.push(`component: ${rootComponentName},`);
158
163
  if (rootLoaderName) rootOpts.push(`loader: modernLoaderToTanstack({ hasSplat: false }, ${rootLoaderName}),`);
159
164
  if (rootValidateSearchName) rootOpts.push(`validateSearch: ${rootValidateSearchName},`);
@@ -177,7 +182,7 @@ ${imports.join('\n')}
177
182
  export const rootRoute = createRootRouteWithContext<ModernRouterContext>()({
178
183
  ${rootOpts.join('\n ')}
179
184
  ${createRouteStaticDataSnippet({
180
- modernRouteId: rootModern?.id,
185
+ modernRouteId: rootExtras?.id,
181
186
  loaderName: rootLoaderName,
182
187
  actionName: rootActionName
183
188
  }) || ''}
@@ -16,4 +16,4 @@ function wrapRouterSubscribeWithBlockState(router, getBlockNavState) {
16
16
  };
17
17
  target[BLOCKING_SUBSCRIBE_SYMBOL] = true;
18
18
  }
19
- export { BLOCKING_STATE_SYMBOL, BLOCKING_SUBSCRIBE_SYMBOL, wrapRouterSubscribeWithBlockState };
19
+ export { wrapRouterSubscribeWithBlockState };
@@ -67,4 +67,4 @@ function ModernRouterClient({ router }) {
67
67
  router
68
68
  });
69
69
  }
70
- export { ModernRouterClient, getCachedRouteModule, getTanstackSsrHydrationPromise, getTanstackSsrHydrationRecord, hasTanstackSsrHydrationRecord, hydrateTanstackRouter, preloadHydratedRouteComponents, routerHydrationRecords };
70
+ export { ModernRouterClient, getTanstackSsrHydrationPromise, hasTanstackSsrHydrationRecord, hydrateTanstackRouter };
@@ -1,4 +1,5 @@
1
1
  import { notFound, redirect } from "@tanstack/react-router";
2
+ import { isAbsoluteUrl } from "./shared/isAbsoluteUrl.mjs";
2
3
  function isResponse(value) {
3
4
  const record = value;
4
5
  return null != record && 'object' == typeof record && 'number' == typeof record.status && 'object' == typeof record.headers;
@@ -16,14 +17,6 @@ function isRedirectResponse(res) {
16
17
  function isTanstackRedirect(value) {
17
18
  return isResponse(value) && 'object' == typeof value.options;
18
19
  }
19
- function isAbsoluteUrl(value) {
20
- try {
21
- new URL(value);
22
- return true;
23
- } catch {
24
- return false;
25
- }
26
- }
27
20
  function throwTanstackRedirect(location) {
28
21
  const target = location || '/';
29
22
  if (isAbsoluteUrl(target)) throw redirect({
@@ -37,4 +37,4 @@ function joinBasename(baseUrl, basename) {
37
37
  if (!trimmedBasename) return trimmedBase || '/';
38
38
  return `${trimmedBase}/${trimmedBasename}`.replace(/\/{2,}/g, '/');
39
39
  }
40
- export { createTanstackRouteObjects, getFinalRouteConfig, getMergedRouterConfig, getTanstackRouteConfig, joinBasename };
40
+ export { createTanstackRouteObjects, getMergedRouterConfig, getTanstackRouteConfig, joinBasename };
@@ -1,18 +1,4 @@
1
1
  import { registerRouterProvider } from "@modern-js/runtime/context";
2
- import { Form, RouteActionResponseError, useFetcher } from "./dataMutation.mjs";
3
- import { Outlet } from "./outlet.mjs";
4
2
  import { tanstackRouterPlugin } from "./plugin.mjs";
5
- import { Link, NavLink } from "./prefetchLink.mjs";
6
3
  const tanstackRouterProviderFactory = (userConfig)=>tanstackRouterPlugin(userConfig);
7
4
  registerRouterProvider('tanstack', tanstackRouterProviderFactory);
8
- const COMPAT_BINDINGS_SLOT = Symbol.for('@modern-js/plugin-tanstack:runtime-compat-bindings');
9
- const tanstackRouterCompatBindings = {
10
- Form: Form,
11
- Link: Link,
12
- NavLink: NavLink,
13
- Outlet: Outlet,
14
- RouteActionResponseError: RouteActionResponseError,
15
- useFetcher: useFetcher
16
- };
17
- globalThis[COMPAT_BINDINGS_SLOT] ??= tanstackRouterCompatBindings;
18
- export { tanstackRouterCompatBindings };
@@ -101,4 +101,4 @@ class ReplayableStream {
101
101
  }
102
102
  _REPLAYABLE_STREAM_MARKER = REPLAYABLE_STREAM_MARKER;
103
103
  var _REPLAYABLE_STREAM_MARKER;
104
- export { REPLAYABLE_STREAM_MARKER, ReplayableStream };
104
+ export { ReplayableStream };
@@ -1,4 +1,5 @@
1
1
  import { notFound, redirect } from "@tanstack/react-router";
2
+ import { isAbsoluteUrl } from "../shared/isAbsoluteUrl.mjs";
2
3
  import { reviveTanstackRscFlightValues } from "./flightSerialization.mjs";
3
4
  const payloadFetchCache = new Map();
4
5
  let payloadDecoder;
@@ -19,14 +20,6 @@ function createPayloadFetchKey(request) {
19
20
  ].sort(([left], [right])=>left.localeCompare(right))
20
21
  ]);
21
22
  }
22
- function isAbsoluteUrl(value) {
23
- try {
24
- new URL(value);
25
- return true;
26
- } catch {
27
- return false;
28
- }
29
- }
30
23
  async function fetchTanstackRscPayload(request) {
31
24
  const headers = new Headers(request.headers);
32
25
  headers.set('x-rsc-tree', 'true');
@@ -59,4 +52,4 @@ function __setTanstackRscPayloadDecoderForTests(decoder) {
59
52
  payloadDecoder = decoder;
60
53
  payloadFetchCache.clear();
61
54
  }
62
- export { __setTanstackRscPayloadDecoderForTests, createPayloadFetchKey, decodePayload, fetchTanstackRscPayload, isAbsoluteUrl, isServerPayload, payloadFetchCache };
55
+ export { __setTanstackRscPayloadDecoderForTests, createPayloadFetchKey, fetchTanstackRscPayload, isAbsoluteUrl, payloadFetchCache };
@@ -47,4 +47,4 @@ function toPayloadRoute(match) {
47
47
  pathnameBase: 'string' == typeof match.pathnameBase ? match.pathnameBase : pathname
48
48
  };
49
49
  }
50
- export { getRouteId, getRouteParentId, getRouteStaticData, toPayloadRoute, toPlainLocation, toPlainRecord, toRoutePath };
50
+ export { getRouteId, toPayloadRoute, toPlainLocation };
@@ -18,4 +18,4 @@ function renderSelectedTree(src, { getTree = src[RSC_PROXY_GET_TREE], missingTre
18
18
  if (!getTree) throw new Error(missingTreeError);
19
19
  return selectTreePath(getTree(), src[RSC_PROXY_PATH] || []);
20
20
  }
21
- export { EmptyFallback, TANSTACK_RSC_FLIGHT_VALUE, isSerializedTanstackRscFlightValue, renderSelectedTree, selectTreePath };
21
+ export { EmptyFallback, TANSTACK_RSC_FLIGHT_VALUE, isSerializedTanstackRscFlightValue, renderSelectedTree };
@@ -0,0 +1,9 @@
1
+ function isAbsoluteUrl(value) {
2
+ try {
3
+ new URL(value);
4
+ return true;
5
+ } catch {
6
+ return false;
7
+ }
8
+ }
9
+ export { isAbsoluteUrl };
@@ -7,10 +7,10 @@ import { __webpack_require__ } from "../rslib-runtime.mjs";
7
7
  import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
8
8
  import { dirname as __rspack_dirname } from "node:path";
9
9
  var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
10
- import * as __rspack_external__modern_js_runtime_cli_401ee077 from "@modern-js/runtime/cli";
10
+ import * as __rspack_external__modern_js_runtime_cli_d0edd589 from "@modern-js/runtime/cli";
11
11
  __webpack_require__.add({
12
- "@modern-js/runtime/cli?9b14" (module) {
13
- module.exports = __rspack_external__modern_js_runtime_cli_401ee077;
12
+ "@modern-js/runtime/cli?32f1" (module) {
13
+ module.exports = __rspack_external__modern_js_runtime_cli_d0edd589;
14
14
  }
15
15
  });
16
16
  const DEFAULT_ROUTES_DIR = 'routes';
@@ -19,7 +19,7 @@ const ENTRYPOINTS_KEY = '@modern-js/plugin-tanstack';
19
19
  let runtimeRouterCli;
20
20
  function getRuntimeRouterCli() {
21
21
  if (runtimeRouterCli) return runtimeRouterCli;
22
- const cli = __webpack_require__("@modern-js/runtime/cli?9b14");
22
+ const cli = __webpack_require__("@modern-js/runtime/cli?32f1");
23
23
  if (cli.handleGeneratorEntryCode && cli.getEntrypointRoutesDir && cli.getEntrypointRoutesOwner && cli.updateNestedRoutesSpec) {
24
24
  runtimeRouterCli = cli;
25
25
  return runtimeRouterCli;
@@ -11,18 +11,6 @@ const JS_OR_TS_EXTS = [
11
11
  '.cjs',
12
12
  '.cts'
13
13
  ];
14
- function toTanstackPath(pathname) {
15
- return pathname.split('/').map((segment)=>{
16
- if (!segment) return segment;
17
- if ('*' === segment) return '$';
18
- if (segment.startsWith(':')) {
19
- const name = segment.slice(1);
20
- if (name.endsWith('?')) return `{-$${name.slice(0, -1)}}`;
21
- return `$${name}`;
22
- }
23
- return segment;
24
- }).join('/');
25
- }
26
14
  async function resolveFileNoExt(inputNoExtPath) {
27
15
  const file = findExists(JS_OR_TS_EXTS.map((ext)=>`${inputNoExtPath}${ext}`));
28
16
  return file ? getPathWithoutExt(file) : null;
@@ -36,27 +24,31 @@ function normalizeRelativeImport(p) {
36
24
  return `./${normalized}`;
37
25
  }
38
26
  function pickModernLoaderModule(route) {
39
- const loaderPath = route.data || route.loader;
27
+ const extras = route;
28
+ const loaderPath = extras.data || extras.loader;
40
29
  if (!loaderPath || 'string' != typeof loaderPath) return null;
41
- const inline = Boolean(route.data);
30
+ const inline = Boolean(extras.data);
42
31
  return {
43
32
  loaderPath,
44
33
  inline
45
34
  };
46
35
  }
47
36
  function pickRouteSearchContractModules(route) {
48
- const validateSearchPath = route.validateSearch;
49
- const loaderDepsPath = route.loaderDeps;
37
+ const extras = route;
38
+ const validateSearchPath = extras.validateSearch;
39
+ const loaderDepsPath = extras.loaderDeps;
50
40
  return {
51
41
  validateSearchPath: 'string' == typeof validateSearchPath ? validateSearchPath : null,
52
42
  loaderDepsPath: 'string' == typeof loaderDepsPath ? loaderDepsPath : null
53
43
  };
54
44
  }
55
45
  function isPathlessLayout(route) {
56
- return 'nested' === route.type && 'boolean' != typeof route.index && void 0 === route.path;
46
+ const extras = route;
47
+ return 'nested' === extras.type && 'boolean' != typeof extras.index && void 0 === extras.path;
57
48
  }
58
49
  function isIndexRoute(route) {
59
- return 'nested' === route.type && Boolean(route.index);
50
+ const extras = route;
51
+ return 'nested' === extras.type && Boolean(extras.index);
60
52
  }
61
53
  function createRouteStaticDataSnippet(opts) {
62
54
  const staticDataLines = [];
@@ -66,4 +58,5 @@ function createRouteStaticDataSnippet(opts) {
66
58
  if (!staticDataLines.length) return null;
67
59
  return `staticData: createRouteStaticData({\n ${staticDataLines.join('\n ')}\n }),`;
68
60
  }
69
- export { createRouteStaticDataSnippet, isIndexRoute, isPathlessLayout, normalizeRelativeImport, pickModernLoaderModule, pickRouteSearchContractModules, quote, resolveFileNoExt, toTanstackPath };
61
+ export { toTanstackPath } from "../../runtime/routeTree/paths.mjs";
62
+ export { createRouteStaticDataSnippet, isIndexRoute, isPathlessLayout, normalizeRelativeImport, pickModernLoaderModule, pickRouteSearchContractModules, quote, resolveFileNoExt };
@@ -1,12 +1,16 @@
1
1
  import "node:module";
2
+ import node_path from "node:path";
2
3
  import { makeLegalIdentifier } from "@modern-js/runtime/cli";
3
- import path from "path";
4
4
  import { createRouteStaticDataSnippet, isIndexRoute, isPathlessLayout, normalizeRelativeImport, pickModernLoaderModule, pickRouteSearchContractModules, quote, resolveFileNoExt, toTanstackPath } from "./shared.mjs";
5
5
  async function generateTanstackRouterTypesSourceForEntry(opts) {
6
6
  const { appContext, entryName, generatedDirName = 'modern-tanstack', routes } = opts;
7
- const outDir = path.join(appContext.srcDirectory, generatedDirName, entryName);
8
- const rootModern = routes.find((r)=>r && 'nested' === r.type && r.isRoot);
9
- const topLevel = rootModern ? rootModern.children || [] : routes;
7
+ const outDir = node_path.join(appContext.srcDirectory, generatedDirName, entryName);
8
+ const rootModern = routes.find((r)=>{
9
+ const extras = r;
10
+ return r && 'nested' === extras.type && extras.isRoot;
11
+ });
12
+ const rootExtras = rootModern;
13
+ const topLevel = rootModern ? rootExtras?.children || [] : routes;
10
14
  const imports = [];
11
15
  const statements = [];
12
16
  const loaderImportMap = new Map();
@@ -25,7 +29,7 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
25
29
  pendingImportName = (async ()=>{
26
30
  const resolvedNoExt = await resolveRouteModuleNoExt(componentPath);
27
31
  if (!resolvedNoExt) return null;
28
- const relImport = normalizeRelativeImport(path.relative(outDir, resolvedNoExt));
32
+ const relImport = normalizeRelativeImport(node_path.relative(outDir, resolvedNoExt));
29
33
  const componentName = `component_${componentIndex++}`;
30
34
  imports.push(`import ${componentName} from ${quote(relImport)};`);
31
35
  return componentName;
@@ -39,8 +43,8 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
39
43
  let absNoExt;
40
44
  if (aliasedNoExtPath.startsWith(prefix)) {
41
45
  const rel = aliasedNoExtPath.slice(prefix.length);
42
- absNoExt = path.join(appContext.srcDirectory, rel);
43
- } else absNoExt = path.isAbsolute(aliasedNoExtPath) ? aliasedNoExtPath : path.join(appContext.srcDirectory, aliasedNoExtPath);
46
+ absNoExt = node_path.join(appContext.srcDirectory, rel);
47
+ } else absNoExt = node_path.isAbsolute(aliasedNoExtPath) ? aliasedNoExtPath : node_path.join(appContext.srcDirectory, aliasedNoExtPath);
44
48
  return resolveFileNoExt(absNoExt);
45
49
  };
46
50
  const getImportNamesForLoader = async (aliasedNoExtPath, inline, hasAction)=>{
@@ -52,7 +56,7 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
52
56
  };
53
57
  const resolvedNoExt = await resolveRouteModuleNoExt(aliasedNoExtPath);
54
58
  if (!resolvedNoExt) return null;
55
- const relImport = normalizeRelativeImport(path.relative(outDir, resolvedNoExt));
59
+ const relImport = normalizeRelativeImport(node_path.relative(outDir, resolvedNoExt));
56
60
  const importName = `loader_${loaderIndex++}`;
57
61
  const actionName = hasAction ? importName.replace(/^loader_/, 'action_') : null;
58
62
  if (inline) {
@@ -74,7 +78,7 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
74
78
  if (existing) return existing;
75
79
  const resolvedNoExt = await resolveRouteModuleNoExt(aliasedNoExtPath);
76
80
  if (!resolvedNoExt) return null;
77
- const relImport = normalizeRelativeImport(path.relative(outDir, resolvedNoExt));
81
+ const relImport = normalizeRelativeImport(node_path.relative(outDir, resolvedNoExt));
78
82
  const importName = 'validateSearch' === exportName ? `validateSearch_${validateSearchIndex++}` : `loaderDeps_${loaderDepsIndex++}`;
79
83
  imports.push(`import { ${exportName} as ${importName} } from ${quote(relImport)};`);
80
84
  searchContractImportMap.set(key, importName);
@@ -95,23 +99,24 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
95
99
  const buildRoute = async (opts)=>{
96
100
  const { parentVar, route } = opts;
97
101
  const varName = createRouteVarName(route);
102
+ const routeExtras = route;
98
103
  const loaderInfo = pickModernLoaderModule(route);
99
- const routeAction = route.action;
104
+ const routeAction = routeExtras.action;
100
105
  const loaderImports = loaderInfo ? await getImportNamesForLoader(loaderInfo.loaderPath, loaderInfo.inline, Boolean(loaderInfo.inline && routeAction === loaderInfo.loaderPath)) : null;
101
106
  const loaderName = loaderImports?.loaderName || null;
102
107
  const actionName = loaderImports?.actionName || null;
103
108
  const searchContractInfo = pickRouteSearchContractModules(route);
104
109
  const validateSearchName = searchContractInfo.validateSearchPath ? await getImportNameForSearchContract(searchContractInfo.validateSearchPath, 'validateSearch') : null;
105
110
  const loaderDepsName = searchContractInfo.loaderDepsPath ? await getImportNameForSearchContract(searchContractInfo.loaderDepsPath, 'loaderDeps') : null;
106
- const rawPath = route.path;
111
+ const rawPath = routeExtras.path;
107
112
  const hasSplat = 'string' == typeof rawPath && rawPath.includes('*');
108
113
  const routeOpts = [
109
114
  `getParentRoute: () => ${parentVar},`
110
115
  ];
111
- const componentName = await getImportNameForComponent(route._component);
116
+ const componentName = await getImportNameForComponent(routeExtras._component);
112
117
  if (componentName) routeOpts.push(`component: ${componentName},`);
113
118
  if (isPathlessLayout(route)) {
114
- const id = route.id;
119
+ const id = routeExtras.id;
115
120
  routeOpts.push(`id: ${quote(id || 'pathless')},`);
116
121
  } else {
117
122
  const p = isIndexRoute(route) ? '/' : toTanstackPath(rawPath || '');
@@ -121,12 +126,12 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
121
126
  if (validateSearchName) routeOpts.push(`validateSearch: ${validateSearchName},`);
122
127
  if (loaderDepsName) routeOpts.push(`loaderDeps: ${loaderDepsName},`);
123
128
  const staticDataSnippet = createRouteStaticDataSnippet({
124
- modernRouteId: route.id,
129
+ modernRouteId: routeExtras.id,
125
130
  loaderName,
126
131
  actionName
127
132
  });
128
133
  if (staticDataSnippet) routeOpts.push(staticDataSnippet);
129
- const children = route.children;
134
+ const children = routeExtras.children;
130
135
  const hasChildren = Boolean(children && children.length > 0);
131
136
  const routeCtorVarName = hasChildren ? reserveRouteVarName(`${varName}__base`) : varName;
132
137
  statements.push(`const ${routeCtorVarName} = createRoute({\n ${routeOpts.join('\n ')}\n});`);
@@ -141,7 +146,7 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
141
146
  return varName;
142
147
  };
143
148
  const rootLoaderInfo = rootModern ? pickModernLoaderModule(rootModern) : null;
144
- const rootAction = rootModern?.action;
149
+ const rootAction = rootExtras?.action;
145
150
  const rootLoaderImports = rootLoaderInfo?.loaderPath ? await getImportNamesForLoader(rootLoaderInfo.loaderPath, rootLoaderInfo.inline, Boolean(rootLoaderInfo.inline && rootAction === rootLoaderInfo.loaderPath)) : null;
146
151
  const rootLoaderName = rootLoaderImports?.loaderName || null;
147
152
  const rootActionName = rootLoaderImports?.actionName || null;
@@ -154,7 +159,7 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
154
159
  route
155
160
  }));
156
161
  const rootOpts = [];
157
- const rootComponentName = await getImportNameForComponent(rootModern?._component);
162
+ const rootComponentName = await getImportNameForComponent(rootExtras?._component);
158
163
  if (rootComponentName) rootOpts.push(`component: ${rootComponentName},`);
159
164
  if (rootLoaderName) rootOpts.push(`loader: modernLoaderToTanstack({ hasSplat: false }, ${rootLoaderName}),`);
160
165
  if (rootValidateSearchName) rootOpts.push(`validateSearch: ${rootValidateSearchName},`);
@@ -178,7 +183,7 @@ ${imports.join('\n')}
178
183
  export const rootRoute = createRootRouteWithContext<ModernRouterContext>()({
179
184
  ${rootOpts.join('\n ')}
180
185
  ${createRouteStaticDataSnippet({
181
- modernRouteId: rootModern?.id,
186
+ modernRouteId: rootExtras?.id,
182
187
  loaderName: rootLoaderName,
183
188
  actionName: rootActionName
184
189
  }) || ''}
@@ -17,4 +17,4 @@ function wrapRouterSubscribeWithBlockState(router, getBlockNavState) {
17
17
  };
18
18
  target[BLOCKING_SUBSCRIBE_SYMBOL] = true;
19
19
  }
20
- export { BLOCKING_STATE_SYMBOL, BLOCKING_SUBSCRIBE_SYMBOL, wrapRouterSubscribeWithBlockState };
20
+ export { wrapRouterSubscribeWithBlockState };
@@ -68,4 +68,4 @@ function ModernRouterClient({ router }) {
68
68
  router
69
69
  });
70
70
  }
71
- export { ModernRouterClient, getCachedRouteModule, getTanstackSsrHydrationPromise, getTanstackSsrHydrationRecord, hasTanstackSsrHydrationRecord, hydrateTanstackRouter, preloadHydratedRouteComponents, routerHydrationRecords };
71
+ export { ModernRouterClient, getTanstackSsrHydrationPromise, hasTanstackSsrHydrationRecord, hydrateTanstackRouter };
@@ -1,5 +1,6 @@
1
1
  import "node:module";
2
2
  import { notFound, redirect } from "@tanstack/react-router";
3
+ import { isAbsoluteUrl } from "./shared/isAbsoluteUrl.mjs";
3
4
  function isResponse(value) {
4
5
  const record = value;
5
6
  return null != record && 'object' == typeof record && 'number' == typeof record.status && 'object' == typeof record.headers;
@@ -17,14 +18,6 @@ function isRedirectResponse(res) {
17
18
  function isTanstackRedirect(value) {
18
19
  return isResponse(value) && 'object' == typeof value.options;
19
20
  }
20
- function isAbsoluteUrl(value) {
21
- try {
22
- new URL(value);
23
- return true;
24
- } catch {
25
- return false;
26
- }
27
- }
28
21
  function throwTanstackRedirect(location) {
29
22
  const target = location || '/';
30
23
  if (isAbsoluteUrl(target)) throw redirect({
@@ -38,4 +38,4 @@ function joinBasename(baseUrl, basename) {
38
38
  if (!trimmedBasename) return trimmedBase || '/';
39
39
  return `${trimmedBase}/${trimmedBasename}`.replace(/\/{2,}/g, '/');
40
40
  }
41
- export { createTanstackRouteObjects, getFinalRouteConfig, getMergedRouterConfig, getTanstackRouteConfig, joinBasename };
41
+ export { createTanstackRouteObjects, getMergedRouterConfig, getTanstackRouteConfig, joinBasename };
@@ -1,19 +1,5 @@
1
1
  import "node:module";
2
2
  import { registerRouterProvider } from "@modern-js/runtime/context";
3
- import { Form, RouteActionResponseError, useFetcher } from "./dataMutation.mjs";
4
- import { Outlet } from "./outlet.mjs";
5
3
  import { tanstackRouterPlugin } from "./plugin.mjs";
6
- import { Link, NavLink } from "./prefetchLink.mjs";
7
4
  const tanstackRouterProviderFactory = (userConfig)=>tanstackRouterPlugin(userConfig);
8
5
  registerRouterProvider('tanstack', tanstackRouterProviderFactory);
9
- const COMPAT_BINDINGS_SLOT = Symbol.for('@modern-js/plugin-tanstack:runtime-compat-bindings');
10
- const tanstackRouterCompatBindings = {
11
- Form: Form,
12
- Link: Link,
13
- NavLink: NavLink,
14
- Outlet: Outlet,
15
- RouteActionResponseError: RouteActionResponseError,
16
- useFetcher: useFetcher
17
- };
18
- globalThis[COMPAT_BINDINGS_SLOT] ??= tanstackRouterCompatBindings;
19
- export { tanstackRouterCompatBindings };
@@ -102,4 +102,4 @@ class ReplayableStream {
102
102
  }
103
103
  _REPLAYABLE_STREAM_MARKER = REPLAYABLE_STREAM_MARKER;
104
104
  var _REPLAYABLE_STREAM_MARKER;
105
- export { REPLAYABLE_STREAM_MARKER, ReplayableStream };
105
+ export { ReplayableStream };
@@ -1,5 +1,6 @@
1
1
  import "node:module";
2
2
  import { notFound, redirect } from "@tanstack/react-router";
3
+ import { isAbsoluteUrl } from "../shared/isAbsoluteUrl.mjs";
3
4
  import { reviveTanstackRscFlightValues } from "./flightSerialization.mjs";
4
5
  const payloadFetchCache = new Map();
5
6
  let payloadDecoder;
@@ -20,14 +21,6 @@ function createPayloadFetchKey(request) {
20
21
  ].sort(([left], [right])=>left.localeCompare(right))
21
22
  ]);
22
23
  }
23
- function isAbsoluteUrl(value) {
24
- try {
25
- new URL(value);
26
- return true;
27
- } catch {
28
- return false;
29
- }
30
- }
31
24
  async function fetchTanstackRscPayload(request) {
32
25
  const headers = new Headers(request.headers);
33
26
  headers.set('x-rsc-tree', 'true');
@@ -60,4 +53,4 @@ function __setTanstackRscPayloadDecoderForTests(decoder) {
60
53
  payloadDecoder = decoder;
61
54
  payloadFetchCache.clear();
62
55
  }
63
- export { __setTanstackRscPayloadDecoderForTests, createPayloadFetchKey, decodePayload, fetchTanstackRscPayload, isAbsoluteUrl, isServerPayload, payloadFetchCache };
56
+ export { __setTanstackRscPayloadDecoderForTests, createPayloadFetchKey, fetchTanstackRscPayload, isAbsoluteUrl, payloadFetchCache };
@@ -48,4 +48,4 @@ function toPayloadRoute(match) {
48
48
  pathnameBase: 'string' == typeof match.pathnameBase ? match.pathnameBase : pathname
49
49
  };
50
50
  }
51
- export { getRouteId, getRouteParentId, getRouteStaticData, toPayloadRoute, toPlainLocation, toPlainRecord, toRoutePath };
51
+ export { getRouteId, toPayloadRoute, toPlainLocation };
@@ -19,4 +19,4 @@ function renderSelectedTree(src, { getTree = src[RSC_PROXY_GET_TREE], missingTre
19
19
  if (!getTree) throw new Error(missingTreeError);
20
20
  return selectTreePath(getTree(), src[RSC_PROXY_PATH] || []);
21
21
  }
22
- export { EmptyFallback, TANSTACK_RSC_FLIGHT_VALUE, isSerializedTanstackRscFlightValue, renderSelectedTree, selectTreePath };
22
+ export { EmptyFallback, TANSTACK_RSC_FLIGHT_VALUE, isSerializedTanstackRscFlightValue, renderSelectedTree };
@@ -0,0 +1,10 @@
1
+ import "node:module";
2
+ function isAbsoluteUrl(value) {
3
+ try {
4
+ new URL(value);
5
+ return true;
6
+ } catch {
7
+ return false;
8
+ }
9
+ }
10
+ export { isAbsoluteUrl };
@@ -1,5 +1,5 @@
1
1
  import type { NestedRouteForCli, PageRoute } from '@modern-js/types';
2
- export declare function toTanstackPath(pathname: string): string;
2
+ export { toTanstackPath } from '../../runtime/routeTree/paths';
3
3
  export declare function resolveFileNoExt(inputNoExtPath: string): Promise<string | null>;
4
4
  export declare function quote(str: string): string;
5
5
  export declare function normalizeRelativeImport(p: string): string;
@@ -1,10 +1,12 @@
1
1
  import type { AppToolsContext } from '@modern-js/app-tools';
2
2
  import type { NestedRouteForCli, PageRoute } from '@modern-js/types';
3
+ type RouteForCli = NestedRouteForCli | PageRoute;
3
4
  export declare function generateTanstackRouterTypesSourceForEntry(opts: {
4
5
  appContext: AppToolsContext;
5
6
  entryName: string;
6
7
  generatedDirName?: string;
7
- routes: (NestedRouteForCli | PageRoute)[];
8
+ routes: RouteForCli[];
8
9
  }): Promise<{
9
10
  routerGenTs: string;
10
11
  }>;
12
+ export {};
@@ -1,3 +1 @@
1
- export declare const BLOCKING_SUBSCRIBE_SYMBOL: unique symbol;
2
- export declare const BLOCKING_STATE_SYMBOL: unique symbol;
3
1
  export declare function wrapRouterSubscribeWithBlockState(router: unknown, getBlockNavState?: () => boolean): void;
@@ -2,16 +2,7 @@ import { type AnyRouter } from '@tanstack/react-router';
2
2
  export type WindowWithTanstackSsr = Window & {
3
3
  $_TSR?: unknown;
4
4
  };
5
- export type RouterHydrationRecord = {
6
- error?: unknown;
7
- promise: Promise<unknown>;
8
- status: 'pending' | 'fulfilled' | 'rejected';
9
- };
10
- export declare const routerHydrationRecords: WeakMap<AnyRouter, RouterHydrationRecord>;
11
- export declare function getCachedRouteModule(routeId: string): unknown;
12
- export declare function preloadHydratedRouteComponents(router: AnyRouter): Promise<void>;
13
5
  export declare function hydrateTanstackRouter(router: AnyRouter): Promise<unknown>;
14
- export declare function getTanstackSsrHydrationRecord(router: AnyRouter): RouterHydrationRecord;
15
6
  export declare function getTanstackSsrHydrationPromise(router: AnyRouter): Promise<unknown>;
16
7
  export declare function hasTanstackSsrHydrationRecord(router: AnyRouter): boolean;
17
8
  export declare function ModernRouterClient({ router }: {