@bleedingdev/modern-js-plugin-tanstack 3.5.0-ultramodern.99 → 3.8.1-ultramodern.1
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 +10 -2
- package/dist/cjs/cli/tanstackTypes/source.js +9 -20
- package/dist/cjs/runtime/plugin.node.js +12 -5
- package/dist/cjs/runtime/pluginShared.js +3 -3
- package/dist/cjs/runtime/rsc/payloadErrors.js +2 -2
- package/dist/cjs/runtime/rsc/shared.js +1 -1
- package/dist/cjs/runtime/rsc/treeGetter.js +5 -9
- package/dist/cjs/runtime/submitAction.js +4 -5
- package/dist/esm/cli/index.mjs +10 -2
- package/dist/esm/cli/tanstackTypes/source.mjs +9 -10
- package/dist/esm/runtime/plugin.node.mjs +12 -5
- package/dist/esm/runtime/pluginShared.mjs +3 -3
- package/dist/esm/runtime/rsc/payloadErrors.mjs +1 -1
- package/dist/esm/runtime/rsc/shared.mjs +1 -1
- package/dist/esm/runtime/rsc/treeGetter.mjs +5 -9
- package/dist/esm/runtime/submitAction.mjs +4 -5
- package/dist/esm-node/cli/index.mjs +10 -2
- package/dist/esm-node/cli/tanstackTypes/source.mjs +9 -10
- package/dist/esm-node/runtime/plugin.node.mjs +12 -5
- package/dist/esm-node/runtime/pluginShared.mjs +3 -3
- package/dist/esm-node/runtime/rsc/payloadErrors.mjs +1 -1
- package/dist/esm-node/runtime/rsc/shared.mjs +1 -1
- package/dist/esm-node/runtime/rsc/treeGetter.mjs +5 -9
- package/dist/esm-node/runtime/submitAction.mjs +4 -5
- package/dist/types/runtime/clientHydration.d.ts +1 -1
- package/dist/types/runtime/ssrTypes.d.ts +0 -2
- package/package.json +27 -20
- package/rstest.config.mts +2 -0
- package/src/cli/index.ts +12 -0
- package/src/cli/tanstackTypes/canonicalRoutes.ts +0 -1
- package/src/cli/tanstackTypes/shared.ts +0 -1
- package/src/cli/tanstackTypes/source.ts +3 -4
- package/src/runtime/plugin.node.tsx +17 -11
- package/src/runtime/plugin.tsx +0 -2
- package/src/runtime/pluginShared.ts +8 -7
- package/src/runtime/rsc/payloadErrors.ts +1 -1
- package/src/runtime/rsc/shared.ts +1 -1
- package/src/runtime/rsc/treeGetter.tsx +9 -8
- package/src/runtime/ssrManagedTags.ts +0 -2
- package/src/runtime/ssrTypes.ts +0 -4
- package/src/runtime/submitAction.ts +6 -11
- package/src/types/react-server-dom-rspack.d.ts +4 -52
- package/tests/router/cli.test.ts +204 -96
- package/tests/router/clientHydration.test.tsx +140 -1
- package/tests/router/dataMutation.test.tsx +50 -9
- package/tests/router/fixtures/rscDecoderSecurityChild.cjs +162 -0
- package/tests/router/preloadRedirect.test.ts +3 -8
- package/tests/router/routeTree.test.ts +73 -19
- package/tests/router/routerCompatibility.test.ts +0 -6
- package/tests/router/rscDecoderSecurity.test.ts +113 -0
- package/tests/router/serverPlugin.test.ts +115 -0
- package/tests/router/tanstackTypes.test.ts +668 -356
- package/src/runtime/ssr-shim.d.ts +0 -10
- package/tests/castRatchet.test.ts +0 -85
- package/tests/router/fixtures/router-gen.golden.txt +0 -71
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { isRouteErrorResponse } from "@modern-js/runtime
|
|
2
|
+
import { isRouteErrorResponse } from "@modern-js/runtime/routerHelper";
|
|
3
3
|
function shouldRedactServerError(status = 500) {
|
|
4
4
|
return status >= 500 && 'development' !== process.env.NODE_ENV && 'test' !== process.env.NODE_ENV;
|
|
5
5
|
}
|
|
@@ -16,7 +16,7 @@ function selectTreePath(tree, path) {
|
|
|
16
16
|
return current;
|
|
17
17
|
}
|
|
18
18
|
function renderSelectedTree(src, { getTree = src[RSC_PROXY_GET_TREE], missingTreeError }) {
|
|
19
|
-
if (
|
|
19
|
+
if (void 0 === getTree) throw new Error(missingTreeError);
|
|
20
20
|
return selectTreePath(getTree(), src[RSC_PROXY_PATH] || []);
|
|
21
21
|
}
|
|
22
22
|
export { EmptyFallback, TANSTACK_RSC_FLIGHT_VALUE, isSerializedTanstackRscFlightValue, renderSelectedTree };
|
|
@@ -9,15 +9,11 @@ function loadModernRscClientRuntime() {
|
|
|
9
9
|
});
|
|
10
10
|
return modernRscClientRuntimePromise;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
if ("u" < typeof window)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const runtime = await loadModernRscClientRuntime();
|
|
18
|
-
return runtime.createFromReadableStream(stream, {
|
|
19
|
-
callServer: runtime.callServer
|
|
20
|
-
});
|
|
12
|
+
function createFromFlightStream(stream) {
|
|
13
|
+
if ("u" < typeof window) return import("react-server-dom-rspack/client.edge").then((runtime)=>runtime.createFromReadableStream(stream));
|
|
14
|
+
return loadModernRscClientRuntime().then((runtime)=>runtime.createFromReadableStream(stream, {
|
|
15
|
+
callServer: runtime.callServer
|
|
16
|
+
}));
|
|
21
17
|
}
|
|
22
18
|
function createTreeGetterFromFlightStream(stream) {
|
|
23
19
|
let ready = false;
|
|
@@ -12,16 +12,15 @@ function resolveRouteHandlers(router, actionTo) {
|
|
|
12
12
|
const builtLocation = router.buildLocation({
|
|
13
13
|
to: actionTo
|
|
14
14
|
});
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const routeStaticData = matchedRoutes.foundRoute?.options?.staticData;
|
|
15
|
+
const [, routeParams, foundRoute] = router.getMatchedRoutes(builtLocation.pathname);
|
|
16
|
+
const routeStaticData = foundRoute?.options?.staticData;
|
|
18
17
|
const action = routeStaticData?.modernRouteAction;
|
|
19
18
|
const loader = routeStaticData?.modernRouteLoader;
|
|
20
19
|
return {
|
|
21
20
|
action,
|
|
22
21
|
loader,
|
|
23
|
-
href,
|
|
24
|
-
params:
|
|
22
|
+
href: builtLocation.href,
|
|
23
|
+
params: routeParams
|
|
25
24
|
};
|
|
26
25
|
}
|
|
27
26
|
function isRedirectResponse(value) {
|
|
@@ -2,7 +2,7 @@ import { type AnyRouter } from '@tanstack/react-router';
|
|
|
2
2
|
export type WindowWithTanstackSsr = Window & {
|
|
3
3
|
$_TSR?: unknown;
|
|
4
4
|
};
|
|
5
|
-
export declare function hydrateTanstackRouter(router: AnyRouter): Promise<
|
|
5
|
+
export declare function hydrateTanstackRouter(router: AnyRouter): Promise<void>;
|
|
6
6
|
export declare function getTanstackSsrHydrationPromise(router: AnyRouter): Promise<unknown>;
|
|
7
7
|
export declare function hasTanstackSsrHydrationRecord(router: AnyRouter): boolean;
|
|
8
8
|
export declare function ModernRouterClient({ router }: {
|
|
@@ -27,7 +27,6 @@ type RouterRouteWithOptions = {
|
|
|
27
27
|
options?: RouterRouteOptions;
|
|
28
28
|
};
|
|
29
29
|
export type TanstackRouterWithServerSsr = AnyRouter & {
|
|
30
|
-
resolveRedirect?: (redirect: Response) => Response;
|
|
31
30
|
routesById?: Record<string, RouterRouteWithOptions>;
|
|
32
31
|
serverSsr?: {
|
|
33
32
|
cleanup?: () => void;
|
|
@@ -38,7 +37,6 @@ export type TanstackRouterWithServerSsr = AnyRouter & {
|
|
|
38
37
|
};
|
|
39
38
|
state: AnyRouter['state'] & {
|
|
40
39
|
matches?: unknown;
|
|
41
|
-
redirect?: Response;
|
|
42
40
|
};
|
|
43
41
|
};
|
|
44
42
|
export {};
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"modern.js",
|
|
19
19
|
"tanstack-router"
|
|
20
20
|
],
|
|
21
|
-
"version": "3.
|
|
21
|
+
"version": "3.8.1-ultramodern.1",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=20"
|
|
24
24
|
},
|
|
@@ -94,34 +94,41 @@
|
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
|
-
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.
|
|
98
|
-
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.
|
|
99
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.
|
|
100
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.
|
|
97
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.8.1-ultramodern.1",
|
|
98
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.8.1-ultramodern.1",
|
|
99
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.8.1-ultramodern.1",
|
|
100
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.8.1-ultramodern.1",
|
|
101
101
|
"@swc/helpers": "^0.5.23",
|
|
102
|
-
"@tanstack/react-router": "1.170.
|
|
103
|
-
"@tanstack/router-core": "1.171.
|
|
104
|
-
"react-server-dom-rspack": "0.0.2"
|
|
102
|
+
"@tanstack/react-router": "1.170.25",
|
|
103
|
+
"@tanstack/router-core": "1.171.21"
|
|
105
104
|
},
|
|
106
105
|
"peerDependencies": {
|
|
107
|
-
"@modern-js/app-tools": "3.
|
|
108
|
-
"@modern-js/runtime": "3.
|
|
109
|
-
"react": "^19.2.
|
|
110
|
-
"react-dom": "^19.2.
|
|
106
|
+
"@modern-js/app-tools": "3.8.1-ultramodern.1",
|
|
107
|
+
"@modern-js/runtime": "3.8.1-ultramodern.1",
|
|
108
|
+
"react": "^19.2.8",
|
|
109
|
+
"react-dom": "^19.2.8",
|
|
110
|
+
"react-server-dom-rspack": "0.0.3"
|
|
111
|
+
},
|
|
112
|
+
"peerDependenciesMeta": {
|
|
113
|
+
"react-server-dom-rspack": {
|
|
114
|
+
"optional": true
|
|
115
|
+
}
|
|
111
116
|
},
|
|
112
117
|
"devDependencies": {
|
|
113
|
-
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.
|
|
114
|
-
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.
|
|
118
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.8.1-ultramodern.1",
|
|
119
|
+
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.8.1-ultramodern.1",
|
|
115
120
|
"@rslib/core": "0.23.2",
|
|
116
121
|
"@scripts/rstest-config": "2.66.0",
|
|
117
|
-
"@tanstack/history": "1.162.
|
|
122
|
+
"@tanstack/history": "1.162.1",
|
|
118
123
|
"@testing-library/react": "^16.3.2",
|
|
119
|
-
"@
|
|
120
|
-
"@types/
|
|
121
|
-
"@types/react
|
|
124
|
+
"@tsconfig/strictest": "2.0.8",
|
|
125
|
+
"@types/node": "^26.2.0",
|
|
126
|
+
"@types/react": "^19.2.18",
|
|
127
|
+
"@types/react-dom": "^19.2.4",
|
|
122
128
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
123
|
-
"react": "^19.2.
|
|
124
|
-
"react-dom": "^19.2.
|
|
129
|
+
"react": "^19.2.8",
|
|
130
|
+
"react-dom": "^19.2.8",
|
|
131
|
+
"react-server-dom-rspack": "0.0.3"
|
|
125
132
|
},
|
|
126
133
|
"sideEffects": [
|
|
127
134
|
"./src/runtime/register.ts",
|
package/rstest.config.mts
CHANGED
|
@@ -35,6 +35,8 @@ export default {
|
|
|
35
35
|
'tests/router/preloadRedirect.test.ts',
|
|
36
36
|
'tests/router/register.test.ts',
|
|
37
37
|
'tests/router/routeHooks.test.ts',
|
|
38
|
+
'tests/router/serverPlugin.test.ts',
|
|
39
|
+
'tests/router/rscDecoderSecurity.test.ts',
|
|
38
40
|
'tests/router/rscPayloadRouterMatrix.test.ts',
|
|
39
41
|
'tests/router/rsc.test.tsx',
|
|
40
42
|
'tests/router/slotUsageSanitizer.test.ts',
|
package/src/cli/index.ts
CHANGED
|
@@ -75,6 +75,10 @@ type RuntimeRouterCliHelpers = {
|
|
|
75
75
|
entrypoints: Entrypoint[],
|
|
76
76
|
options?: {
|
|
77
77
|
entrypointsKey?: string;
|
|
78
|
+
hydrateRscClientRoutes?: boolean;
|
|
79
|
+
includeRouteServerLoadersInSsrEntry?: boolean;
|
|
80
|
+
isolateRouteDataInRscLayer?: boolean;
|
|
81
|
+
serverRoutesFileName?: string;
|
|
78
82
|
},
|
|
79
83
|
) => Promise<Record<string, (NestedRouteForCli | PageRoute)[]>>;
|
|
80
84
|
handleModifyEntrypoints: (
|
|
@@ -265,6 +269,10 @@ export function tanstackRouterPlugin(
|
|
|
265
269
|
tanstackEntrypoints,
|
|
266
270
|
{
|
|
267
271
|
entrypointsKey: ENTRYPOINTS_KEY,
|
|
272
|
+
hydrateRscClientRoutes: true,
|
|
273
|
+
includeRouteServerLoadersInSsrEntry: false,
|
|
274
|
+
isolateRouteDataInRscLayer: true,
|
|
275
|
+
serverRoutesFileName: 'tanstack-routes.server.js',
|
|
268
276
|
},
|
|
269
277
|
);
|
|
270
278
|
|
|
@@ -291,6 +299,10 @@ export function tanstackRouterPlugin(
|
|
|
291
299
|
entrypoints,
|
|
292
300
|
{
|
|
293
301
|
entrypointsKey: ENTRYPOINTS_KEY,
|
|
302
|
+
hydrateRscClientRoutes: true,
|
|
303
|
+
includeRouteServerLoadersInSsrEntry: false,
|
|
304
|
+
isolateRouteDataInRscLayer: true,
|
|
305
|
+
serverRoutesFileName: 'tanstack-routes.server.js',
|
|
294
306
|
},
|
|
295
307
|
);
|
|
296
308
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// @effect-diagnostics asyncFunction:off strictBooleanExpressions:off
|
|
2
2
|
|
|
3
|
-
import path from 'node:path';
|
|
4
3
|
import { getPathWithoutExt } from '@modern-js/runtime/cli';
|
|
5
4
|
import type { NestedRouteForCli, PageRoute } from '@modern-js/types';
|
|
6
5
|
import { findExists, formatImportPath, slash } from '@modern-js/utils';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// @effect-diagnostics asyncFunction:off strictBooleanExpressions:off
|
|
2
2
|
|
|
3
|
-
import path from 'node:path';
|
|
4
3
|
import type {
|
|
5
4
|
AppNormalizedConfig,
|
|
6
5
|
AppTools,
|
|
@@ -8,6 +7,7 @@ import type {
|
|
|
8
7
|
} from '@modern-js/app-tools';
|
|
9
8
|
import { makeLegalIdentifier } from '@modern-js/runtime/cli';
|
|
10
9
|
import type { NestedRouteForCli, PageRoute } from '@modern-js/types';
|
|
10
|
+
import { upath as path } from '@modern-js/utils';
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
createRouteStaticDataSnippet,
|
|
@@ -379,8 +379,7 @@ import {
|
|
|
379
379
|
createRouter,
|
|
380
380
|
createRouteStaticData,
|
|
381
381
|
type ModernRouterContext,
|
|
382
|
-
modernLoaderToTanstack,
|
|
383
|
-
modernTanstackRouterFastDefaults,
|
|
382
|
+
${loaderImportMap.size > 0 ? ' modernLoaderToTanstack,\n' : ''} modernTanstackRouterFastDefaults,
|
|
384
383
|
} from '@modern-js/plugin-tanstack/runtime';
|
|
385
384
|
|
|
386
385
|
${imports.join('\n')}
|
|
@@ -406,7 +405,7 @@ export const router = createRouter({
|
|
|
406
405
|
history: createMemoryHistory({
|
|
407
406
|
initialEntries: ['/'],
|
|
408
407
|
}),
|
|
409
|
-
context: {}
|
|
408
|
+
context: {},
|
|
410
409
|
});
|
|
411
410
|
`;
|
|
412
411
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
// @effect-diagnostics asyncFunction:off newPromise:off strictBooleanExpressions:off unnecessaryArrowBlock:off
|
|
2
|
-
/// <reference path="./ssr-shim.d.ts" />
|
|
3
|
-
|
|
4
2
|
import {
|
|
5
3
|
getGlobalEnableRsc,
|
|
6
4
|
type InternalRouterServerSnapshot,
|
|
@@ -175,10 +173,18 @@ export const tanstackRouterPlugin = (
|
|
|
175
173
|
context.ssrContext?.onTiming?.(LOADER_REPORTER_NAME, cost);
|
|
176
174
|
}
|
|
177
175
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
176
|
+
const serverLoadResult = serverRouter._serverResult;
|
|
177
|
+
if (!serverLoadResult) {
|
|
178
|
+
try {
|
|
179
|
+
serverRouter.serverSsr?.cleanup?.();
|
|
180
|
+
} catch {}
|
|
181
|
+
throw new Error(
|
|
182
|
+
'TanStack Router completed an SSR load without a server result.',
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (serverLoadResult.type === 'redirect') {
|
|
187
|
+
const { redirect } = serverLoadResult;
|
|
182
188
|
|
|
183
189
|
try {
|
|
184
190
|
serverRouter.serverSsr?.cleanup?.();
|
|
@@ -187,11 +193,11 @@ export const tanstackRouterPlugin = (
|
|
|
187
193
|
return interrupt(
|
|
188
194
|
isRSCNavigation
|
|
189
195
|
? handleTanstackRscRedirect(
|
|
190
|
-
|
|
196
|
+
redirect.headers,
|
|
191
197
|
_basename,
|
|
192
|
-
|
|
198
|
+
redirect.status,
|
|
193
199
|
)
|
|
194
|
-
:
|
|
200
|
+
: redirect,
|
|
195
201
|
);
|
|
196
202
|
}
|
|
197
203
|
|
|
@@ -214,7 +220,7 @@ export const tanstackRouterPlugin = (
|
|
|
214
220
|
context.ssrContext?.response as
|
|
215
221
|
| { status: (code: number) => void }
|
|
216
222
|
| undefined
|
|
217
|
-
)?.status(
|
|
223
|
+
)?.status(serverLoadResult.status);
|
|
218
224
|
|
|
219
225
|
await serverRouter.serverSsr?.dehydrate?.();
|
|
220
226
|
|
|
@@ -240,7 +246,7 @@ export const tanstackRouterPlugin = (
|
|
|
240
246
|
createRouterServerSnapshot({
|
|
241
247
|
framework: 'tanstack',
|
|
242
248
|
basename: _basename,
|
|
243
|
-
statusCode:
|
|
249
|
+
statusCode: serverLoadResult.status,
|
|
244
250
|
errors: routerErrors,
|
|
245
251
|
matchedRouteIds,
|
|
246
252
|
hydrationScripts,
|
package/src/runtime/plugin.tsx
CHANGED
|
@@ -87,12 +87,13 @@ export function createTanstackRouteObjects({
|
|
|
87
87
|
ssrMode?: SSRMode;
|
|
88
88
|
}): RouteObject[] {
|
|
89
89
|
const { mergedConfig, finalRouteConfig } = routeConfig;
|
|
90
|
-
const routeObjects =
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
const routeObjects =
|
|
91
|
+
mergedConfig.createRoutes !== undefined
|
|
92
|
+
? mergedConfig.createRoutes()
|
|
93
|
+
: (createTanstackRouteObjectsFromConfig({
|
|
94
|
+
routesConfig: finalRouteConfig,
|
|
95
|
+
ssrMode,
|
|
96
|
+
}) ?? []);
|
|
96
97
|
|
|
97
98
|
return hooks.modifyRoutes.call(routeObjects) as RouteObject[];
|
|
98
99
|
}
|
|
@@ -105,7 +106,7 @@ export function joinBasename(baseUrl: string, basename: string): string {
|
|
|
105
106
|
? normalizedBase.replace(/\/+$/g, '')
|
|
106
107
|
: normalizedBase;
|
|
107
108
|
const trimmedBasename = basename.replace(/^\/+|\/+$/g, '');
|
|
108
|
-
if (
|
|
109
|
+
if (trimmedBasename.length === 0) {
|
|
109
110
|
return trimmedBase || '/';
|
|
110
111
|
}
|
|
111
112
|
return `${trimmedBase}/${trimmedBasename}`.replace(/\/{2,}/g, '/');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @effect-diagnostics asyncFunction:off globalFetch:off processEnv:off strictBooleanExpressions:off
|
|
2
2
|
import type { ServerPayload } from '@modern-js/runtime/context';
|
|
3
|
-
import { isRouteErrorResponse } from '@modern-js/runtime
|
|
3
|
+
import { isRouteErrorResponse } from '@modern-js/runtime/routerHelper';
|
|
4
4
|
|
|
5
5
|
export function shouldRedactServerError(status = 500) {
|
|
6
6
|
return (
|
|
@@ -18,18 +18,19 @@ function loadModernRscClientRuntime() {
|
|
|
18
18
|
return modernRscClientRuntimePromise;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
function createFromFlightStream(stream: ReadableStream<Uint8Array>) {
|
|
22
22
|
if (typeof window === 'undefined') {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
return import('react-server-dom-rspack/client.edge').then(
|
|
24
|
+
(runtime: ServerRscClientRuntime) =>
|
|
25
|
+
runtime.createFromReadableStream(stream),
|
|
25
26
|
);
|
|
26
|
-
return runtime.createFromReadableStream(stream);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
return loadModernRscClientRuntime().then(runtime =>
|
|
30
|
+
runtime.createFromReadableStream(stream, {
|
|
31
|
+
callServer: runtime.callServer,
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export function createTreeGetterFromFlightStream(
|
package/src/runtime/ssrTypes.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference path="./ssr-shim.d.ts" />
|
|
2
|
-
|
|
3
1
|
import type { RequestContext } from '@modern-js/runtime-utils/node';
|
|
4
2
|
import type { AnyRouter } from '@tanstack/react-router';
|
|
5
3
|
|
|
@@ -35,7 +33,6 @@ type RouterRouteWithOptions = {
|
|
|
35
33
|
};
|
|
36
34
|
|
|
37
35
|
export type TanstackRouterWithServerSsr = AnyRouter & {
|
|
38
|
-
resolveRedirect?: (redirect: Response) => Response;
|
|
39
36
|
routesById?: Record<string, RouterRouteWithOptions>;
|
|
40
37
|
serverSsr?: {
|
|
41
38
|
cleanup?: () => void;
|
|
@@ -46,6 +43,5 @@ export type TanstackRouterWithServerSsr = AnyRouter & {
|
|
|
46
43
|
};
|
|
47
44
|
state: AnyRouter['state'] & {
|
|
48
45
|
matches?: unknown;
|
|
49
|
-
redirect?: Response;
|
|
50
46
|
};
|
|
51
47
|
};
|
|
@@ -32,21 +32,16 @@ type RouteLoader = (args: {
|
|
|
32
32
|
}) => Promise<unknown> | unknown;
|
|
33
33
|
|
|
34
34
|
type RouterBuildLocationOptions = Parameters<AnyRouter['buildLocation']>[0];
|
|
35
|
-
type RouterBuiltLocation = ReturnType<AnyRouter['buildLocation']> & {
|
|
36
|
-
pathname: string;
|
|
37
|
-
};
|
|
38
|
-
type RouterParsedLocation = Parameters<AnyRouter['getParsedLocationHref']>[0];
|
|
39
35
|
type RouterNavigateOptions = Parameters<AnyRouter['navigate']>[0];
|
|
40
36
|
|
|
41
37
|
function resolveRouteHandlers(router: AnyRouter, actionTo: string) {
|
|
42
38
|
const builtLocation = router.buildLocation({
|
|
43
39
|
to: actionTo,
|
|
44
|
-
} as RouterBuildLocationOptions)
|
|
45
|
-
const
|
|
46
|
-
builtLocation
|
|
40
|
+
} as RouterBuildLocationOptions);
|
|
41
|
+
const [, routeParams, foundRoute] = router.getMatchedRoutes(
|
|
42
|
+
builtLocation.pathname,
|
|
47
43
|
);
|
|
48
|
-
const
|
|
49
|
-
const routeStaticData = matchedRoutes.foundRoute?.options?.staticData as
|
|
44
|
+
const routeStaticData = foundRoute?.options?.staticData as
|
|
50
45
|
| Record<string, unknown>
|
|
51
46
|
| undefined;
|
|
52
47
|
const action = routeStaticData?.modernRouteAction as RouteAction | undefined;
|
|
@@ -55,8 +50,8 @@ function resolveRouteHandlers(router: AnyRouter, actionTo: string) {
|
|
|
55
50
|
return {
|
|
56
51
|
action,
|
|
57
52
|
loader,
|
|
58
|
-
href,
|
|
59
|
-
params:
|
|
53
|
+
href: builtLocation.href,
|
|
54
|
+
params: routeParams,
|
|
60
55
|
};
|
|
61
56
|
}
|
|
62
57
|
|
|
@@ -1,56 +1,8 @@
|
|
|
1
|
+
// react-server-dom-rspack does not publish TypeScript declarations. This is the
|
|
2
|
+
// smallest ambient contract used by the TanStack RSC stream bridge; executable
|
|
3
|
+
// decoder tests cover the exact patched upstream development dependency.
|
|
1
4
|
declare module 'react-server-dom-rspack/client.edge' {
|
|
2
|
-
import type { TemporaryReferenceSet } from 'react-server-dom-rspack';
|
|
3
|
-
|
|
4
|
-
export type { TemporaryReferenceSet };
|
|
5
|
-
|
|
6
|
-
export const createTemporaryReferenceSet: (
|
|
7
|
-
...args: unknown[]
|
|
8
|
-
) => TemporaryReferenceSet;
|
|
9
|
-
|
|
10
|
-
export function createServerReference(
|
|
11
|
-
id: string,
|
|
12
|
-
): (...args: unknown[]) => Promise<unknown>;
|
|
13
|
-
|
|
14
|
-
export type EncodeFormActionCallback = <A>(
|
|
15
|
-
id: unknown,
|
|
16
|
-
args: Promise<A>,
|
|
17
|
-
) => ReactCustomFormAction;
|
|
18
|
-
|
|
19
|
-
export type ReactCustomFormAction = {
|
|
20
|
-
name?: string;
|
|
21
|
-
action?: string;
|
|
22
|
-
encType?: string;
|
|
23
|
-
method?: string;
|
|
24
|
-
target?: string;
|
|
25
|
-
data?: null | FormData;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export interface Options {
|
|
29
|
-
nonce?: string;
|
|
30
|
-
encodeFormAction?: EncodeFormActionCallback;
|
|
31
|
-
temporaryReferences?: TemporaryReferenceSet;
|
|
32
|
-
replayConsoleLogs?: boolean;
|
|
33
|
-
environmentName?: string;
|
|
34
|
-
debugChannel?: {
|
|
35
|
-
readable?: ReadableStream;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function createFromFetch<T>(
|
|
40
|
-
promiseForResponse: Promise<Response>,
|
|
41
|
-
options?: Options,
|
|
42
|
-
): Promise<T>;
|
|
43
|
-
|
|
44
5
|
export function createFromReadableStream<T>(
|
|
45
|
-
stream: ReadableStream
|
|
46
|
-
options?: Options,
|
|
6
|
+
stream: ReadableStream<Uint8Array>,
|
|
47
7
|
): Promise<T>;
|
|
48
|
-
|
|
49
|
-
export const encodeReply: (
|
|
50
|
-
value: unknown,
|
|
51
|
-
options?: {
|
|
52
|
-
temporaryReferences?: TemporaryReferenceSet;
|
|
53
|
-
signal?: AbortSignal;
|
|
54
|
-
},
|
|
55
|
-
) => Promise<string | FormData>;
|
|
56
8
|
}
|