@bleedingdev/modern-js-plugin-tanstack 3.2.0-ultramodern.94 → 3.2.0-ultramodern.96

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.
@@ -520,9 +520,11 @@ function createRouteTreeFromRouteObjects(routes, options = {}) {
520
520
  }
521
521
  function getModernRouteIdsFromMatches(router) {
522
522
  const matches = router.state.matches || [];
523
+ const routesById = router.routesById;
523
524
  const ids = matches.map((match)=>{
524
- const route = match.route;
525
- return route?.options?.staticData?.modernRouteId;
525
+ const normalizedMatch = match;
526
+ const routeId = 'string' == typeof normalizedMatch.routeId ? normalizedMatch.routeId : void 0;
527
+ return normalizedMatch.route?.options?.staticData?.modernRouteId ?? (routeId ? routesById?.[routeId]?.options?.staticData?.modernRouteId : void 0);
526
528
  }).filter((id)=>'string' == typeof id);
527
529
  return Array.from(new Set(ids));
528
530
  }
@@ -490,9 +490,11 @@ function createRouteTreeFromRouteObjects(routes, options = {}) {
490
490
  }
491
491
  function getModernRouteIdsFromMatches(router) {
492
492
  const matches = router.state.matches || [];
493
+ const routesById = router.routesById;
493
494
  const ids = matches.map((match)=>{
494
- const route = match.route;
495
- return route?.options?.staticData?.modernRouteId;
495
+ const normalizedMatch = match;
496
+ const routeId = 'string' == typeof normalizedMatch.routeId ? normalizedMatch.routeId : void 0;
497
+ return normalizedMatch.route?.options?.staticData?.modernRouteId ?? (routeId ? routesById?.[routeId]?.options?.staticData?.modernRouteId : void 0);
496
498
  }).filter((id)=>'string' == typeof id);
497
499
  return Array.from(new Set(ids));
498
500
  }
@@ -491,9 +491,11 @@ function createRouteTreeFromRouteObjects(routes, options = {}) {
491
491
  }
492
492
  function getModernRouteIdsFromMatches(router) {
493
493
  const matches = router.state.matches || [];
494
+ const routesById = router.routesById;
494
495
  const ids = matches.map((match)=>{
495
- const route = match.route;
496
- return route?.options?.staticData?.modernRouteId;
496
+ const normalizedMatch = match;
497
+ const routeId = 'string' == typeof normalizedMatch.routeId ? normalizedMatch.routeId : void 0;
498
+ return normalizedMatch.route?.options?.staticData?.modernRouteId ?? (routeId ? routesById?.[routeId]?.options?.staticData?.modernRouteId : void 0);
497
499
  }).filter((id)=>'string' == typeof id);
498
500
  return Array.from(new Set(ids));
499
501
  }
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "modern.js",
19
19
  "tanstack-router"
20
20
  ],
21
- "version": "3.2.0-ultramodern.94",
21
+ "version": "3.2.0-ultramodern.96",
22
22
  "engines": {
23
23
  "node": ">=20"
24
24
  },
@@ -88,13 +88,13 @@
88
88
  "@swc/helpers": "^0.5.23",
89
89
  "@tanstack/react-router": "1.170.11",
90
90
  "@tanstack/router-core": "1.171.9",
91
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.94",
92
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.94",
93
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.94",
94
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.94"
91
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.96",
92
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.96",
93
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.96",
94
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.96"
95
95
  },
96
96
  "peerDependencies": {
97
- "@modern-js/runtime": "3.2.0-ultramodern.94",
97
+ "@modern-js/runtime": "3.2.0-ultramodern.96",
98
98
  "react": "^19.2.6",
99
99
  "react-dom": "^19.2.6"
100
100
  },
@@ -109,9 +109,9 @@
109
109
  "@typescript/native-preview": "7.0.0-dev.20260527.2",
110
110
  "react": "^19.2.6",
111
111
  "react-dom": "^19.2.6",
112
- "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.94",
112
+ "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.2.0-ultramodern.96",
113
113
  "@scripts/rstest-config": "2.66.0",
114
- "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.2.0-ultramodern.94"
114
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.96"
115
115
  },
116
116
  "sideEffects": false,
117
117
  "publishConfig": {
@@ -1038,18 +1038,38 @@ export function createRouteTreeFromRouteObjects(
1038
1038
 
1039
1039
  export function getModernRouteIdsFromMatches(router: AnyRouter): string[] {
1040
1040
  const matches = router.state.matches || [];
1041
+ const routesById = (
1042
+ router as AnyRouter & {
1043
+ routesById?: Record<
1044
+ string,
1045
+ {
1046
+ options?: {
1047
+ staticData?: { modernRouteId?: unknown };
1048
+ };
1049
+ }
1050
+ >;
1051
+ }
1052
+ ).routesById;
1041
1053
  const ids = matches
1042
1054
  .map(match => {
1043
- const route = (
1044
- match as {
1045
- route?: {
1046
- options?: {
1047
- staticData?: { modernRouteId?: unknown };
1048
- };
1055
+ const normalizedMatch = match as {
1056
+ route?: {
1057
+ options?: {
1058
+ staticData?: { modernRouteId?: unknown };
1049
1059
  };
1050
- }
1051
- ).route;
1052
- return route?.options?.staticData?.modernRouteId;
1060
+ };
1061
+ routeId?: unknown;
1062
+ };
1063
+ const routeId =
1064
+ typeof normalizedMatch.routeId === 'string'
1065
+ ? normalizedMatch.routeId
1066
+ : undefined;
1067
+ return (
1068
+ normalizedMatch.route?.options?.staticData?.modernRouteId ??
1069
+ (routeId
1070
+ ? routesById?.[routeId]?.options?.staticData?.modernRouteId
1071
+ : undefined)
1072
+ );
1053
1073
  })
1054
1074
  .filter((id): id is string => typeof id === 'string');
1055
1075
  return Array.from(new Set(ids));
@@ -8,6 +8,7 @@ import { renderToStaticMarkup } from 'react-dom/server';
8
8
  import {
9
9
  createRouteTreeFromModernRoutes,
10
10
  createRouteTreeFromRouteObjects,
11
+ getModernRouteIdsFromMatches,
11
12
  } from '../../src/runtime/routeTree';
12
13
  import { __setTanstackRscPayloadDecoderForTests } from '../../src/runtime/rsc/payloadRouter';
13
14
  import { createRouteObjectsFromConfig } from '../../src/runtime/utils';
@@ -181,6 +182,58 @@ describe('tanstack route tree from RouteObject[]', () => {
181
182
  ).toBeUndefined();
182
183
  });
183
184
 
185
+ test('resolves matched Modern route ids from TanStack route registry fallback', () => {
186
+ const router = {
187
+ state: {
188
+ matches: [
189
+ { routeId: '__root__' },
190
+ { routeId: '/$lang' },
191
+ { routeId: '/$lang/tractors' },
192
+ {
193
+ route: {
194
+ options: {
195
+ staticData: {
196
+ modernRouteId: '(lang)/stores/page',
197
+ },
198
+ },
199
+ },
200
+ routeId: '/$lang/stores',
201
+ },
202
+ ],
203
+ },
204
+ routesById: {
205
+ __root__: {
206
+ options: {
207
+ staticData: {
208
+ modernRouteId: 'layout',
209
+ },
210
+ },
211
+ },
212
+ '/$lang': {
213
+ options: {
214
+ staticData: {
215
+ modernRouteId: '(lang)/page',
216
+ },
217
+ },
218
+ },
219
+ '/$lang/tractors': {
220
+ options: {
221
+ staticData: {
222
+ modernRouteId: '(lang)/tractors/page',
223
+ },
224
+ },
225
+ },
226
+ },
227
+ };
228
+
229
+ expect(getModernRouteIdsFromMatches(router as never)).toEqual([
230
+ 'layout',
231
+ '(lang)/page',
232
+ '(lang)/tractors/page',
233
+ '(lang)/stores/page',
234
+ ]);
235
+ });
236
+
184
237
  test('preserves TanStack search contracts from RouteObject routes', () => {
185
238
  const rootValidateSearch = (search: unknown) => ({ root: search });
186
239
  const rootLoaderDeps = ({ search }: { search: unknown }) => ({ search });