@bleedingdev/modern-js-plugin-tanstack 3.2.0-ultramodern.1 → 3.2.0-ultramodern.100
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.
- package/dist/cjs/cli/index.js +15 -6
- package/dist/cjs/cli/routeSplitting.js +83 -0
- package/dist/cjs/cli/tanstackTypes.js +146 -58
- package/dist/cjs/runtime/hydrationBoundary.js +44 -0
- package/dist/cjs/runtime/index.js +321 -69
- package/dist/cjs/runtime/outlet.js +54 -0
- package/dist/cjs/runtime/plugin.js +194 -90
- package/dist/cjs/runtime/plugin.node.js +29 -11
- package/dist/cjs/runtime/plugin.worker.js +49 -0
- package/dist/cjs/runtime/routeTree.js +72 -12
- package/dist/cjs/runtime/types.js +27 -1
- package/dist/esm/cli/index.mjs +7 -7
- package/dist/esm/cli/routeSplitting.mjs +43 -0
- package/dist/esm/cli/tanstackTypes.mjs +146 -58
- package/dist/esm/runtime/hydrationBoundary.mjs +10 -0
- package/dist/esm/runtime/index.mjs +3 -2
- package/dist/esm/runtime/outlet.mjs +17 -0
- package/dist/esm/runtime/plugin.mjs +197 -93
- package/dist/esm/runtime/plugin.node.mjs +30 -12
- package/dist/esm/runtime/plugin.worker.mjs +1 -0
- package/dist/esm/runtime/routeTree.mjs +73 -13
- package/dist/esm/runtime/types.mjs +7 -0
- package/dist/esm-node/cli/index.mjs +7 -7
- package/dist/esm-node/cli/routeSplitting.mjs +44 -0
- package/dist/esm-node/cli/tanstackTypes.mjs +146 -58
- package/dist/esm-node/runtime/hydrationBoundary.mjs +11 -0
- package/dist/esm-node/runtime/index.mjs +3 -2
- package/dist/esm-node/runtime/outlet.mjs +18 -0
- package/dist/esm-node/runtime/plugin.mjs +197 -93
- package/dist/esm-node/runtime/plugin.node.mjs +30 -12
- package/dist/esm-node/runtime/plugin.worker.mjs +2 -0
- package/dist/esm-node/runtime/routeTree.mjs +73 -13
- package/dist/esm-node/runtime/types.mjs +7 -0
- package/dist/types/cli/index.d.ts +4 -0
- package/dist/types/cli/routeSplitting.d.ts +29 -0
- package/dist/types/runtime/hydrationBoundary.d.ts +2 -0
- package/dist/types/runtime/index.d.ts +5 -2
- package/dist/types/runtime/outlet.d.ts +2 -0
- package/dist/types/runtime/plugin.d.ts +1 -1
- package/dist/types/runtime/plugin.node.d.ts +1 -1
- package/dist/types/runtime/plugin.worker.d.ts +1 -0
- package/dist/types/runtime/types.d.ts +7 -0
- package/package.json +14 -14
- package/src/cli/index.ts +32 -18
- package/src/cli/routeSplitting.ts +81 -0
- package/src/cli/tanstackTypes.ts +217 -67
- package/src/runtime/basepathRewrite.ts +1 -0
- package/src/runtime/dataMutation.tsx +1 -0
- package/src/runtime/hydrationBoundary.tsx +12 -0
- package/src/runtime/index.tsx +107 -2
- package/src/runtime/lifecycle.ts +1 -0
- package/src/runtime/outlet.tsx +42 -0
- package/src/runtime/plugin.node.tsx +58 -8
- package/src/runtime/plugin.tsx +354 -149
- package/src/runtime/plugin.worker.tsx +4 -0
- package/src/runtime/routeTree.ts +195 -23
- package/src/runtime/rsc/ClientSlot.tsx +1 -0
- package/src/runtime/rsc/CompositeComponent.tsx +1 -0
- package/src/runtime/rsc/ReplayableStream.ts +1 -0
- package/src/runtime/rsc/RscNodeRenderer.tsx +1 -0
- package/src/runtime/rsc/client.tsx +2 -3
- package/src/runtime/rsc/createRscProxy.tsx +1 -0
- package/src/runtime/rsc/payloadRouter.ts +1 -0
- package/src/runtime/rsc/server.tsx +1 -0
- package/src/runtime/rsc/slotUsageSanitizer.ts +1 -0
- package/src/runtime/ssr-shim.d.ts +1 -3
- package/src/runtime/types.ts +13 -0
- package/src/runtime/utils.tsx +1 -0
- package/tests/router/cli.test.ts +239 -0
- package/tests/router/fastDefaults.test.ts +25 -0
- package/tests/router/hydrationBoundary.test.tsx +23 -0
- package/tests/router/routeTree.test.ts +416 -1
- package/tests/router/tanstackTypes.test.ts +184 -0
package/src/runtime/routeTree.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @effect-diagnostics asyncFunction:off strictBooleanExpressions:off
|
|
1
2
|
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
2
3
|
import type { NestedRoute, PageRoute } from '@modern-js/types';
|
|
3
4
|
import type {
|
|
@@ -10,8 +11,11 @@ import {
|
|
|
10
11
|
createRoute,
|
|
11
12
|
notFound,
|
|
12
13
|
redirect,
|
|
14
|
+
rootRouteId,
|
|
13
15
|
} from '@tanstack/react-router';
|
|
16
|
+
import { createElement, type ElementType } from 'react';
|
|
14
17
|
import { DefaultNotFound } from './DefaultNotFound';
|
|
18
|
+
import { withModernRouteMatchContext } from './outlet';
|
|
15
19
|
import {
|
|
16
20
|
isTanstackRscPayloadNavigationEnabled,
|
|
17
21
|
loadTanstackRscRouteData,
|
|
@@ -74,8 +78,10 @@ type ModernRouteObject = RouteObject & {
|
|
|
74
78
|
isClientComponent?: boolean;
|
|
75
79
|
lazyImport?: () => unknown;
|
|
76
80
|
loader?: ModernLoader;
|
|
81
|
+
loaderDeps?: unknown;
|
|
77
82
|
pendingComponent?: unknown;
|
|
78
83
|
shouldRevalidate?: ModernShouldRevalidate;
|
|
84
|
+
validateSearch?: unknown;
|
|
79
85
|
};
|
|
80
86
|
|
|
81
87
|
type ModernGeneratedRoute = (NestedRoute | PageRoute) & {
|
|
@@ -100,14 +106,20 @@ type ModernGeneratedRoute = (NestedRoute | PageRoute) & {
|
|
|
100
106
|
isRoot?: boolean;
|
|
101
107
|
lazyImport?: () => unknown;
|
|
102
108
|
loader?: ModernLoader;
|
|
109
|
+
loaderDeps?: unknown;
|
|
103
110
|
loading?: unknown;
|
|
104
111
|
pendingComponent?: unknown;
|
|
105
112
|
path?: string;
|
|
106
113
|
shouldRevalidate?: ModernShouldRevalidate;
|
|
114
|
+
validateSearch?: unknown;
|
|
107
115
|
};
|
|
108
116
|
|
|
109
117
|
type MutableTanstackRoute = AnyRoute & {
|
|
110
118
|
addChildren: (children: AnyRoute[]) => void;
|
|
119
|
+
id?: string;
|
|
120
|
+
options: {
|
|
121
|
+
component?: unknown;
|
|
122
|
+
};
|
|
111
123
|
};
|
|
112
124
|
|
|
113
125
|
type TanstackRouteOptions = Record<string, unknown>;
|
|
@@ -117,6 +129,15 @@ type ModernDeferredDataLike = {
|
|
|
117
129
|
__modern_deferred?: unknown;
|
|
118
130
|
data?: unknown;
|
|
119
131
|
};
|
|
132
|
+
type ModernRouteModule = {
|
|
133
|
+
Component?: unknown;
|
|
134
|
+
default?: unknown;
|
|
135
|
+
};
|
|
136
|
+
type PreloadableComponent = {
|
|
137
|
+
(props: Record<string, unknown>): ReturnType<typeof createElement>;
|
|
138
|
+
load?: () => Promise<unknown>;
|
|
139
|
+
preload?: () => Promise<unknown>;
|
|
140
|
+
};
|
|
120
141
|
type RouteTreeOptions = {
|
|
121
142
|
rscPayloadRouter?: boolean;
|
|
122
143
|
};
|
|
@@ -133,6 +154,20 @@ function createTanstackRootRoute(
|
|
|
133
154
|
return createRootRoute(options as never) as unknown as MutableTanstackRoute;
|
|
134
155
|
}
|
|
135
156
|
|
|
157
|
+
function wrapRouteComponentWithModernContext(
|
|
158
|
+
route: MutableTanstackRoute,
|
|
159
|
+
component: unknown,
|
|
160
|
+
routeId?: string,
|
|
161
|
+
) {
|
|
162
|
+
const routeMatchId = routeId || route.id;
|
|
163
|
+
if (component && routeMatchId) {
|
|
164
|
+
route.options.component = withModernRouteMatchContext(
|
|
165
|
+
component,
|
|
166
|
+
routeMatchId,
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
136
171
|
function toTanstackPath(pathname: string): string {
|
|
137
172
|
// TanStack Router uses `$param` and `$` (splat) style params.
|
|
138
173
|
// Modern's conventional routing currently generates React Router style params (e.g. `:id`, `*`).
|
|
@@ -218,6 +253,76 @@ function normalizeModernLoaderResponse(result: unknown): unknown {
|
|
|
218
253
|
return normalizeModernLoaderResult(result);
|
|
219
254
|
}
|
|
220
255
|
|
|
256
|
+
function pickRouteModuleComponent(
|
|
257
|
+
routeModule: unknown,
|
|
258
|
+
seen: Set<unknown> = new Set(),
|
|
259
|
+
): ElementType<Record<string, unknown>> | undefined {
|
|
260
|
+
if (
|
|
261
|
+
typeof routeModule === 'function' ||
|
|
262
|
+
(routeModule &&
|
|
263
|
+
typeof routeModule === 'object' &&
|
|
264
|
+
'$$typeof' in routeModule)
|
|
265
|
+
) {
|
|
266
|
+
return routeModule as ElementType<Record<string, unknown>>;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (!routeModule || typeof routeModule !== 'object') {
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
if (seen.has(routeModule)) {
|
|
273
|
+
return undefined;
|
|
274
|
+
}
|
|
275
|
+
seen.add(routeModule);
|
|
276
|
+
|
|
277
|
+
const module = routeModule as ModernRouteModule;
|
|
278
|
+
for (const candidate of [module.default, module.Component]) {
|
|
279
|
+
const component = pickRouteModuleComponent(candidate, seen);
|
|
280
|
+
if (component) {
|
|
281
|
+
return component;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function createServerLazyImportComponent(
|
|
289
|
+
lazyImport: () => unknown,
|
|
290
|
+
fallbackComponent?: unknown,
|
|
291
|
+
): PreloadableComponent | unknown {
|
|
292
|
+
if (typeof document !== 'undefined') {
|
|
293
|
+
return fallbackComponent;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
let resolvedComponent: ElementType<Record<string, unknown>> | undefined;
|
|
297
|
+
let pendingLoad: Promise<unknown> | undefined;
|
|
298
|
+
|
|
299
|
+
const load = async () => {
|
|
300
|
+
if (resolvedComponent) {
|
|
301
|
+
return resolvedComponent;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const routeModule = await lazyImport();
|
|
305
|
+
const component = pickRouteModuleComponent(routeModule);
|
|
306
|
+
if (component) {
|
|
307
|
+
resolvedComponent = component;
|
|
308
|
+
}
|
|
309
|
+
return resolvedComponent;
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
const Component: PreloadableComponent = props => {
|
|
313
|
+
if (resolvedComponent) {
|
|
314
|
+
return createElement(resolvedComponent, props);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
pendingLoad ||= load();
|
|
318
|
+
throw pendingLoad;
|
|
319
|
+
};
|
|
320
|
+
Component.load = load;
|
|
321
|
+
Component.preload = load;
|
|
322
|
+
|
|
323
|
+
return Component;
|
|
324
|
+
}
|
|
325
|
+
|
|
221
326
|
function isAbsoluteUrl(value: string) {
|
|
222
327
|
try {
|
|
223
328
|
void new URL(value);
|
|
@@ -351,9 +456,10 @@ function wrapModernLoader(
|
|
|
351
456
|
ctx?.location?.url?.href ||
|
|
352
457
|
'';
|
|
353
458
|
|
|
354
|
-
const request =
|
|
355
|
-
|
|
356
|
-
|
|
459
|
+
const request =
|
|
460
|
+
baseRequest !== undefined
|
|
461
|
+
? new Request(baseRequest, { signal })
|
|
462
|
+
: createModernRequest(href, signal);
|
|
357
463
|
const params = mapParamsForModernLoader({
|
|
358
464
|
modernRoute,
|
|
359
465
|
params: ctx.params || {},
|
|
@@ -467,9 +573,10 @@ function wrapRouteObjectLoader(
|
|
|
467
573
|
ctx?.location?.url?.href ||
|
|
468
574
|
'';
|
|
469
575
|
|
|
470
|
-
const request =
|
|
471
|
-
|
|
472
|
-
|
|
576
|
+
const request =
|
|
577
|
+
baseRequest !== undefined
|
|
578
|
+
? new Request(baseRequest, { signal })
|
|
579
|
+
: createModernRequest(href, signal);
|
|
473
580
|
|
|
474
581
|
const params = mapParamsForRouteObjectLoader({
|
|
475
582
|
route,
|
|
@@ -518,6 +625,18 @@ function wrapRouteObjectLoader(
|
|
|
518
625
|
|
|
519
626
|
function toRouteComponent(routeObject: RouteObject): unknown {
|
|
520
627
|
const route = routeObject as ModernRouteObject;
|
|
628
|
+
const lazyImport =
|
|
629
|
+
typeof route.lazyImport === 'function' ? route.lazyImport : undefined;
|
|
630
|
+
const fallbackComponent = route.Component
|
|
631
|
+
? route.Component
|
|
632
|
+
: route.element
|
|
633
|
+
? () => route.element
|
|
634
|
+
: undefined;
|
|
635
|
+
|
|
636
|
+
if (lazyImport && fallbackComponent) {
|
|
637
|
+
return createServerLazyImportComponent(lazyImport, fallbackComponent);
|
|
638
|
+
}
|
|
639
|
+
|
|
521
640
|
if (route.Component) {
|
|
522
641
|
return route.Component;
|
|
523
642
|
}
|
|
@@ -528,6 +647,15 @@ function toRouteComponent(routeObject: RouteObject): unknown {
|
|
|
528
647
|
return undefined;
|
|
529
648
|
}
|
|
530
649
|
|
|
650
|
+
function toModernRouteComponent(route: ModernGeneratedRoute): unknown {
|
|
651
|
+
const component = route.component || undefined;
|
|
652
|
+
if (typeof route.lazyImport === 'function' && component) {
|
|
653
|
+
return createServerLazyImportComponent(route.lazyImport, component);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
return component;
|
|
657
|
+
}
|
|
658
|
+
|
|
531
659
|
function toErrorComponent(routeObject: RouteObject): unknown {
|
|
532
660
|
const route = routeObject as ModernRouteObject;
|
|
533
661
|
if (route.ErrorBoundary) {
|
|
@@ -626,12 +754,14 @@ function createRouteFromRouteObject(opts: {
|
|
|
626
754
|
const stableFallbackId =
|
|
627
755
|
routeObject.id || modernRouteObject.file || routeObject.path || 'pathless';
|
|
628
756
|
|
|
757
|
+
const component = toRouteComponent(routeObject);
|
|
629
758
|
const base: TanstackRouteOptions = {
|
|
630
759
|
getParentRoute: () => parent,
|
|
631
|
-
component
|
|
760
|
+
component,
|
|
632
761
|
pendingComponent: toPendingComponent(routeObject),
|
|
633
762
|
errorComponent: toErrorComponent(routeObject),
|
|
634
|
-
|
|
763
|
+
validateSearch: modernRouteObject.validateSearch,
|
|
764
|
+
loaderDeps: modernRouteObject.loaderDeps,
|
|
635
765
|
staticData: createRouteStaticData({
|
|
636
766
|
modernRouteId: routeObject.id,
|
|
637
767
|
modernRouteAction: modernRouteObject.action,
|
|
@@ -666,6 +796,7 @@ function createRouteFromRouteObject(opts: {
|
|
|
666
796
|
}
|
|
667
797
|
|
|
668
798
|
const route = createTanstackRoute(base);
|
|
799
|
+
wrapRouteComponentWithModernContext(route, component, routeObject.id);
|
|
669
800
|
|
|
670
801
|
const children = routeObject.children;
|
|
671
802
|
if (children && children.length > 0) {
|
|
@@ -701,7 +832,7 @@ function createRouteFromModernRoute(opts: {
|
|
|
701
832
|
|
|
702
833
|
const pendingComponent = route.loading || route.pendingComponent;
|
|
703
834
|
const errorComponent = route.error || route.errorComponent;
|
|
704
|
-
const component = route
|
|
835
|
+
const component = toModernRouteComponent(route);
|
|
705
836
|
const modernLoader = route.loader;
|
|
706
837
|
const modernAction = route.action;
|
|
707
838
|
const modernShouldRevalidate = route.shouldRevalidate;
|
|
@@ -723,7 +854,8 @@ function createRouteFromModernRoute(opts: {
|
|
|
723
854
|
component: component || undefined,
|
|
724
855
|
pendingComponent: pendingComponent || undefined,
|
|
725
856
|
errorComponent: errorComponent || undefined,
|
|
726
|
-
|
|
857
|
+
validateSearch: route.validateSearch,
|
|
858
|
+
loaderDeps: route.loaderDeps,
|
|
727
859
|
staticData: createRouteStaticData({
|
|
728
860
|
modernRouteId: modernId,
|
|
729
861
|
modernRouteAction: modernAction,
|
|
@@ -760,6 +892,7 @@ function createRouteFromModernRoute(opts: {
|
|
|
760
892
|
}
|
|
761
893
|
|
|
762
894
|
const tanstackRoute = createTanstackRoute(base);
|
|
895
|
+
wrapRouteComponentWithModernContext(tanstackRoute, component, modernId);
|
|
763
896
|
|
|
764
897
|
const children = route.children as Array<NestedRoute | PageRoute> | undefined;
|
|
765
898
|
if (children && children.length > 0) {
|
|
@@ -787,7 +920,9 @@ export function createRouteTreeFromModernRoutes(
|
|
|
787
920
|
(r as ModernGeneratedRoute).isRoot,
|
|
788
921
|
) as ModernGeneratedRoute | undefined;
|
|
789
922
|
|
|
790
|
-
const rootComponent = rootModern
|
|
923
|
+
const rootComponent = rootModern
|
|
924
|
+
? toModernRouteComponent(rootModern)
|
|
925
|
+
: undefined;
|
|
791
926
|
const pendingComponent = rootModern?.loading;
|
|
792
927
|
const errorComponent = rootModern?.error;
|
|
793
928
|
const rootLoader = rootModern?.loader;
|
|
@@ -804,7 +939,8 @@ export function createRouteTreeFromModernRoutes(
|
|
|
804
939
|
component: rootComponent || undefined,
|
|
805
940
|
pendingComponent: pendingComponent || undefined,
|
|
806
941
|
errorComponent: errorComponent || undefined,
|
|
807
|
-
|
|
942
|
+
validateSearch: rootModern?.validateSearch,
|
|
943
|
+
loaderDeps: rootModern?.loaderDeps,
|
|
808
944
|
notFoundComponent: DefaultNotFound,
|
|
809
945
|
staticData: createRouteStaticData({
|
|
810
946
|
modernRouteId: rootModernId,
|
|
@@ -834,6 +970,12 @@ export function createRouteTreeFromModernRoutes(
|
|
|
834
970
|
}
|
|
835
971
|
|
|
836
972
|
const rootRoute = createTanstackRootRoute(rootRouteOptions);
|
|
973
|
+
if (rootComponent) {
|
|
974
|
+
rootRoute.options.component = withModernRouteMatchContext(
|
|
975
|
+
rootComponent,
|
|
976
|
+
rootRouteId,
|
|
977
|
+
);
|
|
978
|
+
}
|
|
837
979
|
|
|
838
980
|
const topLevel = rootModern
|
|
839
981
|
? (rootModern.children as Array<NestedRoute | PageRoute>) || []
|
|
@@ -869,13 +1011,17 @@ export function createRouteTreeFromRouteObjects(
|
|
|
869
1011
|
rootRevalidationState,
|
|
870
1012
|
);
|
|
871
1013
|
|
|
1014
|
+
const rootComponent = rootLikeRoute
|
|
1015
|
+
? toRouteComponent(rootLikeRoute)
|
|
1016
|
+
: undefined;
|
|
872
1017
|
const rootRouteOptions: TanstackRootRouteOptions = {
|
|
873
|
-
component:
|
|
1018
|
+
component: rootComponent,
|
|
874
1019
|
pendingComponent: rootLikeRoute
|
|
875
1020
|
? toPendingComponent(rootLikeRoute)
|
|
876
1021
|
: undefined,
|
|
877
1022
|
errorComponent: rootLikeRoute ? toErrorComponent(rootLikeRoute) : undefined,
|
|
878
|
-
|
|
1023
|
+
validateSearch: rootLikeRoute?.validateSearch,
|
|
1024
|
+
loaderDeps: rootLikeRoute?.loaderDeps,
|
|
879
1025
|
notFoundComponent: DefaultNotFound,
|
|
880
1026
|
staticData: createRouteStaticData({
|
|
881
1027
|
modernRouteId: rootLikeRoute?.id,
|
|
@@ -906,6 +1052,12 @@ export function createRouteTreeFromRouteObjects(
|
|
|
906
1052
|
}
|
|
907
1053
|
|
|
908
1054
|
const rootRoute = createTanstackRootRoute(rootRouteOptions);
|
|
1055
|
+
if (rootComponent) {
|
|
1056
|
+
rootRoute.options.component = withModernRouteMatchContext(
|
|
1057
|
+
rootComponent,
|
|
1058
|
+
rootRouteId,
|
|
1059
|
+
);
|
|
1060
|
+
}
|
|
909
1061
|
|
|
910
1062
|
const topLevel = rootLikeRoute
|
|
911
1063
|
? [
|
|
@@ -924,18 +1076,38 @@ export function createRouteTreeFromRouteObjects(
|
|
|
924
1076
|
|
|
925
1077
|
export function getModernRouteIdsFromMatches(router: AnyRouter): string[] {
|
|
926
1078
|
const matches = router.state.matches || [];
|
|
1079
|
+
const routesById = (
|
|
1080
|
+
router as AnyRouter & {
|
|
1081
|
+
routesById?: Record<
|
|
1082
|
+
string,
|
|
1083
|
+
{
|
|
1084
|
+
options?: {
|
|
1085
|
+
staticData?: { modernRouteId?: unknown };
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
>;
|
|
1089
|
+
}
|
|
1090
|
+
).routesById;
|
|
927
1091
|
const ids = matches
|
|
928
1092
|
.map(match => {
|
|
929
|
-
const
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
staticData?: { modernRouteId?: unknown };
|
|
934
|
-
};
|
|
1093
|
+
const normalizedMatch = match as {
|
|
1094
|
+
route?: {
|
|
1095
|
+
options?: {
|
|
1096
|
+
staticData?: { modernRouteId?: unknown };
|
|
935
1097
|
};
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
|
|
1098
|
+
};
|
|
1099
|
+
routeId?: unknown;
|
|
1100
|
+
};
|
|
1101
|
+
const routeId =
|
|
1102
|
+
typeof normalizedMatch.routeId === 'string'
|
|
1103
|
+
? normalizedMatch.routeId
|
|
1104
|
+
: undefined;
|
|
1105
|
+
return (
|
|
1106
|
+
normalizedMatch.route?.options?.staticData?.modernRouteId ??
|
|
1107
|
+
(routeId
|
|
1108
|
+
? routesById?.[routeId]?.options?.staticData?.modernRouteId
|
|
1109
|
+
: undefined)
|
|
1110
|
+
);
|
|
939
1111
|
})
|
|
940
1112
|
.filter((id): id is string => typeof id === 'string');
|
|
941
1113
|
return Array.from(new Set(ids));
|
|
@@ -78,9 +78,8 @@ const adapter = createSerializationAdapter({
|
|
|
78
78
|
toSerializable: (): never => {
|
|
79
79
|
throw new Error('TanStack RSC data cannot be serialized on client.');
|
|
80
80
|
},
|
|
81
|
-
fromSerializable: (value: SerializedRsc): AnyCompositeComponent =>
|
|
82
|
-
|
|
83
|
-
},
|
|
81
|
+
fromSerializable: (value: SerializedRsc): AnyCompositeComponent =>
|
|
82
|
+
createFromFlightStream(value) as AnyCompositeComponent,
|
|
84
83
|
});
|
|
85
84
|
|
|
86
85
|
export function getTanstackRscSerializationAdapters() {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
declare module '@tanstack/react-router/ssr/client' {
|
|
2
|
-
export function
|
|
3
|
-
router: unknown;
|
|
4
|
-
}): import('react').JSX.Element;
|
|
2
|
+
export function hydrate(router: unknown): Promise<unknown>;
|
|
5
3
|
}
|
|
6
4
|
|
|
7
5
|
declare module '@tanstack/react-router/ssr/server' {
|
package/src/runtime/types.ts
CHANGED
|
@@ -20,9 +20,22 @@ export type RouterConfig = {
|
|
|
20
20
|
future?: Partial<{
|
|
21
21
|
v7_startTransition: boolean;
|
|
22
22
|
}>;
|
|
23
|
+
defaultStructuralSharing?: boolean;
|
|
23
24
|
unstable_reloadOnURLMismatch?: boolean;
|
|
24
25
|
};
|
|
25
26
|
|
|
27
|
+
export const modernTanstackRouterFastDefaults = {
|
|
28
|
+
defaultStructuralSharing: true,
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
export const getModernTanstackRouterFastDefaults = (
|
|
32
|
+
config: Partial<Pick<RouterConfig, 'defaultStructuralSharing'>> = {},
|
|
33
|
+
) => ({
|
|
34
|
+
defaultStructuralSharing:
|
|
35
|
+
config.defaultStructuralSharing ??
|
|
36
|
+
modernTanstackRouterFastDefaults.defaultStructuralSharing,
|
|
37
|
+
});
|
|
38
|
+
|
|
26
39
|
export interface RouterRouteMatchSnapshot {
|
|
27
40
|
routeId: string;
|
|
28
41
|
assetRouteId?: string;
|
package/src/runtime/utils.tsx
CHANGED