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

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,6 +1,6 @@
1
1
  import type React from 'react';
2
2
  export type SubmitTarget = HTMLFormElement | FormData | URLSearchParams | Record<string, string | number | boolean | null | undefined>;
3
- export type SubmitterElement = HTMLButtonElement | HTMLInputElement;
3
+ type SubmitterElement = HTMLButtonElement | HTMLInputElement;
4
4
  export type SubmitOptions = {
5
5
  action?: string;
6
6
  method?: string;
@@ -21,3 +21,4 @@ export declare function resolveSubmitOptionsFromForm({ form, submitter, action,
21
21
  method?: string;
22
22
  encType?: string;
23
23
  }): Required<SubmitOptions>;
24
+ export {};
@@ -1,3 +1,5 @@
1
+ import { isAbsoluteUrl } from './shared/isAbsoluteUrl';
2
+ export { isAbsoluteUrl };
1
3
  /** Router context shape used by the generated TanStack router types. */
2
4
  export type ModernRouterContext = {
3
5
  request?: Request;
@@ -11,7 +13,6 @@ export declare function isRedirectResponse(res: Response): boolean;
11
13
  * the Modern Response handling would lose `to`-based (internal) targets.
12
14
  */
13
15
  export declare function isTanstackRedirect(value: unknown): boolean;
14
- export declare function isAbsoluteUrl(value: string): boolean;
15
16
  /**
16
17
  * Re-throw a Modern.js `Location` redirect as a TanStack redirect.
17
18
  *
@@ -3,7 +3,7 @@ import type { RouteObject } from '@modern-js/runtime-utils/router';
3
3
  import type { RouterExtendsHooks } from './hooks';
4
4
  import type { RouterConfig } from './types';
5
5
  import { type SSRMode } from './utils';
6
- export type TanstackRouterRuntimeConfig = {
6
+ type TanstackRouterRuntimeConfig = {
7
7
  plugins?: TanstackRouterRuntimePlugin[];
8
8
  router?: Partial<RouterConfig>;
9
9
  [key: string]: unknown;
@@ -22,13 +22,12 @@ export type TanstackRouterRuntimePlugin = {
22
22
  setup?: (api: TanstackRouterPluginAPI) => unknown;
23
23
  [key: string]: unknown;
24
24
  };
25
- export type TanstackRouteConfig = {
25
+ type TanstackRouteConfig = {
26
26
  mergedConfig: RouterConfig;
27
27
  finalRouteConfig: RouterConfig['routesConfig'];
28
28
  hasConfiguredRoutes: boolean;
29
29
  };
30
30
  export declare function getMergedRouterConfig(api: TanstackRouterPluginAPI, userConfig: Partial<RouterConfig>): RouterConfig;
31
- export declare function getFinalRouteConfig(mergedConfig: RouterConfig): RouterConfig['routesConfig'];
32
31
  export declare function getTanstackRouteConfig(api: TanstackRouterPluginAPI, userConfig: Partial<RouterConfig>): TanstackRouteConfig;
33
32
  export declare function createTanstackRouteObjects({ hooks, routeConfig, ssrMode, }: {
34
33
  hooks: RouterExtendsHooks;
@@ -1,9 +1 @@
1
- import { Form, RouteActionResponseError, useFetcher } from './dataMutation';
2
- export declare const tanstackRouterCompatBindings: {
3
- Form: typeof Form;
4
- Link: <TRouter extends import("@tanstack/router-core").AnyRouter = import("@tanstack/router-core").AnyRouter, const TFrom extends string = string, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = "">(props: import("./prefetchLink").LinkProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => import("react").ReactElement;
5
- NavLink: <TRouter extends import("@tanstack/router-core").AnyRouter = import("@tanstack/router-core").AnyRouter, const TFrom extends string = string, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = "">(props: import("./prefetchLink").LinkProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => import("react").ReactElement;
6
- Outlet: import("react").MemoExoticComponent<() => import("react").JSX.Element>;
7
- RouteActionResponseError: typeof RouteActionResponseError;
8
- useFetcher: typeof useFetcher;
9
- };
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  import type { RouteObject } from '@modern-js/runtime-utils/router';
2
2
  import type { AnyRoute, RootRoute as TanstackRootRoute } from '@tanstack/react-router';
3
3
  export type RouteParams = Record<string, string>;
4
- export type ModernLoader = (args: {
4
+ type ModernLoader = (args: {
5
5
  request: Request;
6
6
  params: RouteParams;
7
7
  context?: unknown;
@@ -73,3 +73,4 @@ export type ModernTanstackRootRoute = TanstackRootRoute;
73
73
  export type RouteTreeOptions = {
74
74
  rscPayloadRouter?: boolean;
75
75
  };
76
+ export {};
@@ -1,7 +1,7 @@
1
- export interface ReplayableStreamOptions {
1
+ interface ReplayableStreamOptions {
2
2
  signal?: AbortSignal;
3
3
  }
4
- export declare const REPLAYABLE_STREAM_MARKER: unique symbol;
4
+ declare const REPLAYABLE_STREAM_MARKER: unique symbol;
5
5
  export declare class ReplayableStream<T = Uint8Array> {
6
6
  private source;
7
7
  private options;
@@ -22,3 +22,4 @@ export declare class ReplayableStream<T = Uint8Array> {
22
22
  isReleased(): boolean;
23
23
  createReplayStream(): ReadableStream<T>;
24
24
  }
25
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type React from 'react';
2
- export type SlotImplementations = Record<string, unknown>;
2
+ type SlotImplementations = Record<string, unknown>;
3
3
  export declare function useSlotContext(): {
4
4
  implementations: SlotImplementations;
5
5
  strict: boolean;
@@ -9,3 +9,4 @@ export declare function SlotProvider({ children, implementations, strict, }: {
9
9
  implementations: SlotImplementations;
10
10
  strict?: boolean;
11
11
  }): React.JSX.Element;
12
+ export {};
@@ -1,10 +1,8 @@
1
1
  import type { ServerPayload } from '@modern-js/runtime/context';
2
+ import { isAbsoluteUrl } from '../shared/isAbsoluteUrl';
3
+ export { isAbsoluteUrl };
2
4
  type PayloadDecoder = (stream: ReadableStream<Uint8Array>) => Promise<unknown>;
3
5
  export declare const payloadFetchCache: Map<string, Promise<ServerPayload>>;
4
- export declare function decodePayload(stream: ReadableStream<Uint8Array>): Promise<unknown>;
5
- export declare function isServerPayload(value: unknown): value is ServerPayload;
6
6
  export declare function createPayloadFetchKey(request: Request): string;
7
- export declare function isAbsoluteUrl(value: string): boolean;
8
7
  export declare function fetchTanstackRscPayload(request: Request): Promise<ServerPayload>;
9
8
  export declare function __setTanstackRscPayloadDecoderForTests(decoder?: PayloadDecoder): void;
10
- export {};
@@ -1,5 +1,5 @@
1
1
  import type { PayloadRoute, ServerPayload } from '@modern-js/runtime/context';
2
- export type RouterStaticData = {
2
+ type RouterStaticData = {
3
3
  modernRouteAction?: unknown;
4
4
  modernRouteHandle?: unknown;
5
5
  modernRouteHasAction?: unknown;
@@ -8,7 +8,7 @@ export type RouterStaticData = {
8
8
  modernRouteId?: unknown;
9
9
  modernRouteIsClientComponent?: unknown;
10
10
  };
11
- export type RouterRouteLike = {
11
+ type RouterRouteLike = {
12
12
  id?: unknown;
13
13
  options?: {
14
14
  index?: unknown;
@@ -34,10 +34,7 @@ export type TanstackPayloadRouterLike = {
34
34
  statusCode?: unknown;
35
35
  };
36
36
  };
37
- export declare function toPlainRecord(value: unknown): Record<string, unknown>;
38
37
  export declare function toPlainLocation(location: unknown): ServerPayload['location'];
39
38
  export declare function getRouteId(match: RouterMatchLike): string | undefined;
40
- export declare function getRouteStaticData(match: RouterMatchLike): RouterStaticData;
41
- export declare function getRouteParentId(match: RouterMatchLike): string | undefined;
42
- export declare function toRoutePath(match: RouterMatchLike): string | undefined;
43
39
  export declare function toPayloadRoute(match: RouterMatchLike): PayloadRoute | undefined;
40
+ export {};
@@ -9,7 +9,6 @@ export type SerializedTanstackRscFlightValue = {
9
9
  };
10
10
  export declare function isSerializedTanstackRscFlightValue(value: unknown): value is SerializedTanstackRscFlightValue;
11
11
  export declare function EmptyFallback(): null;
12
- export declare function selectTreePath(tree: unknown, path: string[]): React.ReactNode;
13
12
  type RenderSelectedTreeSource = AnyRenderableServerComponent | AnyCompositeComponent;
14
13
  type RenderSelectedTreeOptions = {
15
14
  getTree?: (() => unknown) | undefined;
@@ -0,0 +1 @@
1
+ export declare function isAbsoluteUrl(value: string): boolean;
@@ -17,13 +17,13 @@ export type RouterMatchWithError = {
17
17
  };
18
18
  routeId?: unknown;
19
19
  };
20
- export type RouterRouteOptions = {
20
+ type RouterRouteOptions = {
21
21
  component?: unknown;
22
22
  errorComponent?: unknown;
23
23
  notFoundComponent?: unknown;
24
24
  pendingComponent?: unknown;
25
25
  };
26
- export type RouterRouteWithOptions = {
26
+ type RouterRouteWithOptions = {
27
27
  options?: RouterRouteOptions;
28
28
  };
29
29
  export type TanstackRouterWithServerSsr = AnyRouter & {
@@ -41,3 +41,4 @@ export type TanstackRouterWithServerSsr = AnyRouter & {
41
41
  redirect?: Response;
42
42
  };
43
43
  };
44
+ export {};
@@ -1,10 +1,9 @@
1
- import type { ModernRoute, RouterFramework } from '@modern-js/runtime/context';
1
+ import type { ModernRoute } from '@modern-js/runtime/context';
2
2
  import type { RouteObject } from '@modern-js/runtime-utils/router';
3
3
  import type React from 'react';
4
- export type { BuiltInRouterFramework, InternalRouterRuntimeState, InternalRouterServerSnapshot, LoaderFunction, LoaderFunctionArgs, ModernRoute, RouterFramework, RouterRouteMatchSnapshot, RouterServerPrepareResult, } from '@modern-js/runtime/context';
4
+ export type { InternalRouterServerSnapshot, ModernRoute, RouterFramework, } from '@modern-js/runtime/context';
5
5
  /** TanStack-specific router config. */
6
6
  export type RouterConfig = {
7
- framework?: RouterFramework;
8
7
  routesConfig: {
9
8
  globalApp?: React.ComponentType<any>;
10
9
  routes?: ModernRoute[];
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "modern.js",
19
19
  "tanstack-router"
20
20
  ],
21
- "version": "3.5.0-ultramodern.36",
21
+ "version": "3.5.0-ultramodern.38",
22
22
  "engines": {
23
23
  "node": ">=20"
24
24
  },
@@ -95,34 +95,33 @@
95
95
  },
96
96
  "dependencies": {
97
97
  "@swc/helpers": "^0.5.23",
98
- "@tanstack/react-router": "1.170.16",
99
- "@tanstack/router-core": "1.171.13",
98
+ "@tanstack/react-router": "1.170.17",
99
+ "@tanstack/router-core": "1.171.14",
100
100
  "react-server-dom-rspack": "0.0.2",
101
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.36",
102
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.5.0-ultramodern.36",
103
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.36",
104
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.36"
101
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.38",
102
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.38",
103
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.38",
104
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.5.0-ultramodern.38"
105
105
  },
106
106
  "peerDependencies": {
107
- "@modern-js/app-tools": "3.5.0-ultramodern.36",
108
- "@modern-js/runtime": "3.5.0-ultramodern.36",
107
+ "@modern-js/app-tools": "3.5.0-ultramodern.38",
108
+ "@modern-js/runtime": "3.5.0-ultramodern.38",
109
109
  "react": "^19.2.7",
110
110
  "react-dom": "^19.2.7"
111
111
  },
112
112
  "devDependencies": {
113
- "@rslib/core": "0.23.1",
113
+ "@rslib/core": "0.23.2",
114
114
  "@tanstack/history": "1.162.0",
115
- "@testing-library/dom": "^10.4.1",
116
115
  "@testing-library/react": "^16.3.2",
117
- "@types/node": "^26.0.1",
116
+ "@types/node": "^26.1.1",
118
117
  "@types/react": "^19.2.17",
119
118
  "@types/react-dom": "^19.2.3",
120
- "@typescript/native-preview": "7.0.0-dev.20260628.1",
119
+ "@typescript/native-preview": "7.0.0-dev.20260707.2",
121
120
  "react": "^19.2.7",
122
121
  "react-dom": "^19.2.7",
123
- "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.5.0-ultramodern.36",
124
- "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.5.0-ultramodern.36",
125
- "@scripts/rstest-config": "2.66.0"
122
+ "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.5.0-ultramodern.38",
123
+ "@scripts/rstest-config": "2.66.0",
124
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.5.0-ultramodern.38"
126
125
  },
127
126
  "sideEffects": [
128
127
  "./src/runtime/register.ts",
@@ -1,8 +1,8 @@
1
1
  // @effect-diagnostics asyncFunction:off strictBooleanExpressions:off
2
2
 
3
+ import path from 'node:path';
3
4
  import type { NestedRouteForCli, PageRoute } from '@modern-js/types';
4
5
  import { MAIN_ENTRY_NAME } from '@modern-js/utils';
5
- import path from 'path';
6
6
 
7
7
  import { toTanstackPath } from './shared';
8
8
 
@@ -1,9 +1,9 @@
1
1
  // @effect-diagnostics asyncFunction:off strictBooleanExpressions:off
2
2
 
3
+ import path from 'node:path';
3
4
  import { getPathWithoutExt } from '@modern-js/runtime/cli';
4
5
  import type { NestedRouteForCli, PageRoute } from '@modern-js/types';
5
6
  import { findExists, formatImportPath, slash } from '@modern-js/utils';
6
- import path from 'path';
7
7
 
8
8
  const JS_OR_TS_EXTS = [
9
9
  '.js',
@@ -16,27 +16,7 @@ const JS_OR_TS_EXTS = [
16
16
  '.cts',
17
17
  ] as const;
18
18
 
19
- export function toTanstackPath(pathname: string): string {
20
- return pathname
21
- .split('/')
22
- .map(segment => {
23
- if (!segment) {
24
- return segment;
25
- }
26
- if (segment === '*') {
27
- return '$';
28
- }
29
- if (segment.startsWith(':')) {
30
- const name = segment.slice(1);
31
- if (name.endsWith('?')) {
32
- return `{-$${name.slice(0, -1)}}`;
33
- }
34
- return `$${name}`;
35
- }
36
- return segment;
37
- })
38
- .join('/');
39
- }
19
+ export { toTanstackPath } from '../../runtime/routeTree/paths';
40
20
 
41
21
  export async function resolveFileNoExt(inputNoExtPath: string) {
42
22
  const file = findExists(JS_OR_TS_EXTS.map(ext => `${inputNoExtPath}${ext}`));
@@ -55,21 +35,33 @@ export function normalizeRelativeImport(p: string) {
55
35
  return `./${normalized}`;
56
36
  }
57
37
 
38
+ type RouteExtras = {
39
+ data?: unknown;
40
+ loader?: unknown;
41
+ validateSearch?: unknown;
42
+ loaderDeps?: unknown;
43
+ type?: unknown;
44
+ index?: unknown;
45
+ path?: unknown;
46
+ };
47
+
58
48
  export function pickModernLoaderModule(route: NestedRouteForCli | PageRoute) {
59
- const loaderPath = (route as any).data || (route as any).loader;
49
+ const extras = route as RouteExtras;
50
+ const loaderPath = extras.data || extras.loader;
60
51
  if (!loaderPath || typeof loaderPath !== 'string') {
61
52
  return null;
62
53
  }
63
54
 
64
- const inline = Boolean((route as any).data);
55
+ const inline = Boolean(extras.data);
65
56
  return { loaderPath, inline };
66
57
  }
67
58
 
68
59
  export function pickRouteSearchContractModules(
69
60
  route: NestedRouteForCli | PageRoute,
70
61
  ) {
71
- const validateSearchPath = (route as any).validateSearch;
72
- const loaderDepsPath = (route as any).loaderDeps;
62
+ const extras = route as RouteExtras;
63
+ const validateSearchPath = extras.validateSearch;
64
+ const loaderDepsPath = extras.loaderDeps;
73
65
 
74
66
  return {
75
67
  validateSearchPath:
@@ -79,15 +71,17 @@ export function pickRouteSearchContractModules(
79
71
  }
80
72
 
81
73
  export function isPathlessLayout(route: NestedRouteForCli | PageRoute) {
74
+ const extras = route as RouteExtras;
82
75
  return (
83
- (route as any).type === 'nested' &&
84
- typeof (route as any).index !== 'boolean' &&
85
- typeof (route as any).path === 'undefined'
76
+ extras.type === 'nested' &&
77
+ typeof extras.index !== 'boolean' &&
78
+ typeof extras.path === 'undefined'
86
79
  );
87
80
  }
88
81
 
89
82
  export function isIndexRoute(route: NestedRouteForCli | PageRoute) {
90
- return (route as any).type === 'nested' && Boolean((route as any).index);
83
+ const extras = route as RouteExtras;
84
+ return extras.type === 'nested' && Boolean(extras.index);
91
85
  }
92
86
 
93
87
  export function createRouteStaticDataSnippet(opts: {
@@ -1,5 +1,6 @@
1
1
  // @effect-diagnostics asyncFunction:off strictBooleanExpressions:off
2
2
 
3
+ import path from 'node:path';
3
4
  import type {
4
5
  AppNormalizedConfig,
5
6
  AppTools,
@@ -7,7 +8,6 @@ import type {
7
8
  } from '@modern-js/app-tools';
8
9
  import { makeLegalIdentifier } from '@modern-js/runtime/cli';
9
10
  import type { NestedRouteForCli, PageRoute } from '@modern-js/types';
10
- import path from 'path';
11
11
 
12
12
  import {
13
13
  createRouteStaticDataSnippet,
@@ -21,11 +21,23 @@ import {
21
21
  toTanstackPath,
22
22
  } from './shared';
23
23
 
24
+ type RouteForCli = NestedRouteForCli | PageRoute;
25
+
26
+ type RouteExtras = {
27
+ id?: string;
28
+ type?: unknown;
29
+ isRoot?: unknown;
30
+ children?: RouteForCli[];
31
+ action?: unknown;
32
+ path?: string;
33
+ _component?: unknown;
34
+ };
35
+
24
36
  export async function generateTanstackRouterTypesSourceForEntry(opts: {
25
37
  appContext: AppToolsContext;
26
38
  entryName: string;
27
39
  generatedDirName?: string;
28
- routes: (NestedRouteForCli | PageRoute)[];
40
+ routes: RouteForCli[];
29
41
  }): Promise<{
30
42
  routerGenTs: string;
31
43
  }> {
@@ -41,14 +53,13 @@ export async function generateTanstackRouterTypesSourceForEntry(opts: {
41
53
  entryName,
42
54
  );
43
55
 
44
- const rootModern = routes.find(
45
- r => r && (r as any).type === 'nested' && (r as any).isRoot,
46
- ) as NestedRouteForCli | undefined;
56
+ const rootModern = routes.find(r => {
57
+ const extras = r as RouteExtras;
58
+ return r && extras.type === 'nested' && extras.isRoot;
59
+ }) as NestedRouteForCli | undefined;
47
60
 
48
- const topLevel = rootModern
49
- ? ((rootModern as any).children as Array<NestedRouteForCli | PageRoute>) ||
50
- []
51
- : routes;
61
+ const rootExtras = rootModern as RouteExtras | undefined;
62
+ const topLevel = rootModern ? rootExtras?.children || [] : routes;
52
63
 
53
64
  const imports: string[] = [];
54
65
  const statements: string[] = [];
@@ -199,7 +210,7 @@ export async function generateTanstackRouterTypesSourceForEntry(opts: {
199
210
  };
200
211
 
201
212
  const createRouteVarName = (route: NestedRouteForCli | PageRoute) => {
202
- const id = (route as any).id as string | undefined;
213
+ const id = (route as RouteExtras).id;
203
214
  const base = id ? makeLegalIdentifier(id) : `r_${routeIndex++}`;
204
215
  return reserveRouteVarName(`route_${base}`);
205
216
  };
@@ -211,9 +222,10 @@ export async function generateTanstackRouterTypesSourceForEntry(opts: {
211
222
  const { parentVar, route } = opts;
212
223
 
213
224
  const varName = createRouteVarName(route);
225
+ const routeExtras = route as RouteExtras;
214
226
 
215
227
  const loaderInfo = pickModernLoaderModule(route);
216
- const routeAction = (route as any).action;
228
+ const routeAction = routeExtras.action;
217
229
  const loaderImports = loaderInfo
218
230
  ? await getImportNamesForLoader(
219
231
  loaderInfo.loaderPath,
@@ -237,20 +249,20 @@ export async function generateTanstackRouterTypesSourceForEntry(opts: {
237
249
  )
238
250
  : null;
239
251
 
240
- const rawPath = (route as any).path as string | undefined;
252
+ const rawPath = routeExtras.path;
241
253
  const hasSplat = typeof rawPath === 'string' && rawPath.includes('*');
242
254
 
243
255
  const routeOpts: string[] = [`getParentRoute: () => ${parentVar},`];
244
256
 
245
257
  const componentName = await getImportNameForComponent(
246
- (route as any)._component,
258
+ routeExtras._component,
247
259
  );
248
260
  if (componentName) {
249
261
  routeOpts.push(`component: ${componentName},`);
250
262
  }
251
263
 
252
264
  if (isPathlessLayout(route)) {
253
- const id = (route as any).id as string | undefined;
265
+ const id = routeExtras.id;
254
266
  routeOpts.push(`id: ${quote(id || 'pathless')},`);
255
267
  } else {
256
268
  const p = isIndexRoute(route) ? '/' : toTanstackPath(rawPath || '');
@@ -270,7 +282,7 @@ export async function generateTanstackRouterTypesSourceForEntry(opts: {
270
282
  }
271
283
 
272
284
  const staticDataSnippet = createRouteStaticDataSnippet({
273
- modernRouteId: (route as any).id as string | undefined,
285
+ modernRouteId: routeExtras.id,
274
286
  loaderName,
275
287
  actionName,
276
288
  });
@@ -278,9 +290,7 @@ export async function generateTanstackRouterTypesSourceForEntry(opts: {
278
290
  routeOpts.push(staticDataSnippet);
279
291
  }
280
292
 
281
- const children = (route as any).children as
282
- | Array<NestedRouteForCli | PageRoute>
283
- | undefined;
293
+ const children = routeExtras.children;
284
294
  const hasChildren = Boolean(children && children.length > 0);
285
295
  const routeCtorVarName = hasChildren
286
296
  ? reserveRouteVarName(`${varName}__base`)
@@ -306,7 +316,7 @@ export async function generateTanstackRouterTypesSourceForEntry(opts: {
306
316
  };
307
317
 
308
318
  const rootLoaderInfo = rootModern ? pickModernLoaderModule(rootModern) : null;
309
- const rootAction = (rootModern as any)?.action;
319
+ const rootAction = rootExtras?.action;
310
320
  const rootLoaderImports = rootLoaderInfo?.loaderPath
311
321
  ? await getImportNamesForLoader(
312
322
  rootLoaderInfo.loaderPath,
@@ -342,7 +352,7 @@ export async function generateTanstackRouterTypesSourceForEntry(opts: {
342
352
  const rootOpts: string[] = [];
343
353
 
344
354
  const rootComponentName = await getImportNameForComponent(
345
- (rootModern as any)?._component,
355
+ rootExtras?._component,
346
356
  );
347
357
  if (rootComponentName) {
348
358
  rootOpts.push(`component: ${rootComponentName},`);
@@ -380,7 +390,7 @@ export const rootRoute = createRootRouteWithContext<ModernRouterContext>()({
380
390
  ${rootOpts.join('\n ')}
381
391
  ${
382
392
  createRouteStaticDataSnippet({
383
- modernRouteId: (rootModern as any)?.id as string | undefined,
393
+ modernRouteId: rootExtras?.id,
384
394
  loaderName: rootLoaderName,
385
395
  actionName: rootActionName,
386
396
  }) || ''
@@ -1,9 +1,9 @@
1
1
  // @effect-diagnostics strictBooleanExpressions:off
2
2
 
3
- export const BLOCKING_SUBSCRIBE_SYMBOL = Symbol.for(
3
+ const BLOCKING_SUBSCRIBE_SYMBOL = Symbol.for(
4
4
  '@modern-js/plugin-tanstack:blocking-subscribe',
5
5
  );
6
- export const BLOCKING_STATE_SYMBOL = Symbol.for(
6
+ const BLOCKING_STATE_SYMBOL = Symbol.for(
7
7
  '@modern-js/plugin-tanstack:blocking-state',
8
8
  );
9
9
 
@@ -28,19 +28,16 @@ type RouterWithPreloadableRoutes = AnyRouter & {
28
28
  >;
29
29
  };
30
30
 
31
- export type RouterHydrationRecord = {
31
+ type RouterHydrationRecord = {
32
32
  error?: unknown;
33
33
  promise: Promise<unknown>;
34
34
  status: 'pending' | 'fulfilled' | 'rejected';
35
35
  };
36
36
 
37
- export const routerHydrationRecords = new WeakMap<
38
- AnyRouter,
39
- RouterHydrationRecord
40
- >();
37
+ const routerHydrationRecords = new WeakMap<AnyRouter, RouterHydrationRecord>();
41
38
  const routeModulesKey = '_routeModules';
42
39
 
43
- export function getCachedRouteModule(routeId: string) {
40
+ function getCachedRouteModule(routeId: string) {
44
41
  if (typeof window === 'undefined') {
45
42
  return undefined;
46
43
  }
@@ -50,9 +47,7 @@ export function getCachedRouteModule(routeId: string) {
50
47
  ]?.[routeId];
51
48
  }
52
49
 
53
- export function preloadHydratedRouteComponents(
54
- router: AnyRouter,
55
- ): Promise<void> {
50
+ function preloadHydratedRouteComponents(router: AnyRouter): Promise<void> {
56
51
  const preloadableRouter = router as RouterWithPreloadableRoutes;
57
52
  const routesById = preloadableRouter.routesById || {};
58
53
  const matches = preloadableRouter.stores.matches.get() as Array<{
@@ -100,7 +95,7 @@ export function hydrateTanstackRouter(router: AnyRouter) {
100
95
  );
101
96
  }
102
97
 
103
- export function getTanstackSsrHydrationRecord(router: AnyRouter) {
98
+ function getTanstackSsrHydrationRecord(router: AnyRouter) {
104
99
  const existingHydrationRecord = routerHydrationRecords.get(router);
105
100
  if (existingHydrationRecord !== undefined) {
106
101
  return existingHydrationRecord;
@@ -6,7 +6,7 @@ export type SubmitTarget =
6
6
  | FormData
7
7
  | URLSearchParams
8
8
  | Record<string, string | number | boolean | null | undefined>;
9
- export type SubmitterElement = HTMLButtonElement | HTMLInputElement;
9
+ type SubmitterElement = HTMLButtonElement | HTMLInputElement;
10
10
 
11
11
  export type SubmitOptions = {
12
12
  action?: string;
@@ -9,6 +9,9 @@
9
9
  * helpers for the same reason.
10
10
  */
11
11
  import { notFound, redirect } from '@tanstack/react-router';
12
+ import { isAbsoluteUrl } from './shared/isAbsoluteUrl';
13
+
14
+ export { isAbsoluteUrl };
12
15
 
13
16
  /** Router context shape used by the generated TanStack router types. */
14
17
  export type ModernRouterContext = {
@@ -44,15 +47,6 @@ export function isTanstackRedirect(value: unknown): boolean {
44
47
  );
45
48
  }
46
49
 
47
- export function isAbsoluteUrl(value: string): boolean {
48
- try {
49
- void new URL(value);
50
- return true;
51
- } catch {
52
- return false;
53
- }
54
- }
55
-
56
50
  /**
57
51
  * Re-throw a Modern.js `Location` redirect as a TanStack redirect.
58
52
  *
@@ -9,7 +9,7 @@ import type { RouterExtendsHooks } from './hooks';
9
9
  import type { RouterConfig } from './types';
10
10
  import { createTanstackRouteObjectsFromConfig, type SSRMode } from './utils';
11
11
 
12
- export type TanstackRouterRuntimeConfig = {
12
+ type TanstackRouterRuntimeConfig = {
13
13
  plugins?: TanstackRouterRuntimePlugin[];
14
14
  router?: Partial<RouterConfig>;
15
15
  [key: string]: unknown;
@@ -37,7 +37,7 @@ export type TanstackRouterRuntimePlugin = {
37
37
  [key: string]: unknown;
38
38
  };
39
39
 
40
- export type TanstackRouteConfig = {
40
+ type TanstackRouteConfig = {
41
41
  mergedConfig: RouterConfig;
42
42
  finalRouteConfig: RouterConfig['routesConfig'];
43
43
  hasConfiguredRoutes: boolean;
@@ -53,7 +53,7 @@ export function getMergedRouterConfig(
53
53
  return merge(pluginConfig.router || {}, userConfig) as RouterConfig;
54
54
  }
55
55
 
56
- export function getFinalRouteConfig(
56
+ function getFinalRouteConfig(
57
57
  mergedConfig: RouterConfig,
58
58
  ): RouterConfig['routesConfig'] {
59
59
  return {