@bleedingdev/modern-js-runtime 3.2.0-ultramodern.9 → 3.2.0-ultramodern.90
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/boundary-debugger/index.js +299 -0
- package/dist/cjs/cli/ssr/index.js +5 -15
- package/dist/cjs/cli/template.server.js +1 -0
- package/dist/cjs/core/react/wrapper.js +9 -3
- package/dist/cjs/core/server/federatedCss.js +47 -0
- package/dist/cjs/core/server/helmet.js +8 -2
- package/dist/cjs/core/server/stream/afterTemplate.js +9 -6
- package/dist/cjs/core/server/stream/beforeTemplate.js +13 -20
- package/dist/cjs/core/server/stream/beforeTemplate.worker.js +98 -0
- package/dist/cjs/core/server/stream/createReadableStream.js +7 -2
- package/dist/cjs/core/server/stream/createReadableStream.worker.js +4 -2
- package/dist/cjs/core/server/stream/shared.js +3 -1
- package/dist/cjs/core/server/string/index.js +6 -6
- package/dist/cjs/core/server/string/loadable.js +33 -7
- package/dist/cjs/exports/head.js +196 -5
- package/dist/cjs/router/cli/code/tanstackTypes.js +116 -51
- package/dist/cjs/router/cli/code/templates.js +1 -8
- package/dist/cjs/router/runtime/tanstack/plugin.js +4 -5
- package/dist/cjs/router/runtime/tanstack/plugin.node.js +2 -13
- package/dist/cjs/router/runtime/tanstack/routeTree.js +47 -4
- package/dist/cjs/rsc/server.worker.js +58 -0
- package/dist/cjs/ssr/serverRender/renderToString/entry.js +9 -8
- package/dist/esm/boundary-debugger/index.mjs +263 -0
- package/dist/esm/cli/ssr/index.mjs +5 -15
- package/dist/esm/cli/template.server.mjs +1 -0
- package/dist/esm/core/react/wrapper.mjs +9 -3
- package/dist/esm/core/server/federatedCss.mjs +13 -0
- package/dist/esm/core/server/helmet.mjs +5 -2
- package/dist/esm/core/server/stream/afterTemplate.mjs +10 -7
- package/dist/esm/core/server/stream/beforeTemplate.mjs +14 -11
- package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +64 -0
- package/dist/esm/core/server/stream/createReadableStream.mjs +7 -2
- package/dist/esm/core/server/stream/createReadableStream.worker.mjs +4 -2
- package/dist/esm/core/server/stream/shared.mjs +3 -1
- package/dist/esm/core/server/string/index.mjs +7 -6
- package/dist/esm/core/server/string/loadable.mjs +33 -7
- package/dist/esm/exports/head.mjs +189 -4
- package/dist/esm/router/cli/code/tanstackTypes.mjs +116 -51
- package/dist/esm/router/cli/code/templates.mjs +1 -8
- package/dist/esm/router/runtime/tanstack/plugin.mjs +8 -9
- package/dist/esm/router/runtime/tanstack/plugin.node.mjs +3 -14
- package/dist/esm/router/runtime/tanstack/routeTree.mjs +47 -4
- package/dist/esm/rsc/server.worker.mjs +1 -0
- package/dist/esm/ssr/serverRender/renderToString/entry.mjs +9 -6
- package/dist/esm-node/boundary-debugger/index.mjs +264 -0
- package/dist/esm-node/cli/ssr/index.mjs +5 -15
- package/dist/esm-node/cli/template.server.mjs +1 -0
- package/dist/esm-node/core/react/wrapper.mjs +9 -3
- package/dist/esm-node/core/server/federatedCss.mjs +14 -0
- package/dist/esm-node/core/server/helmet.mjs +5 -2
- package/dist/esm-node/core/server/stream/afterTemplate.mjs +10 -7
- package/dist/esm-node/core/server/stream/beforeTemplate.mjs +14 -11
- package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +65 -0
- package/dist/esm-node/core/server/stream/createReadableStream.mjs +7 -2
- package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +4 -2
- package/dist/esm-node/core/server/stream/shared.mjs +3 -1
- package/dist/esm-node/core/server/string/index.mjs +7 -6
- package/dist/esm-node/core/server/string/loadable.mjs +33 -7
- package/dist/esm-node/exports/head.mjs +189 -4
- package/dist/esm-node/router/cli/code/tanstackTypes.mjs +116 -51
- package/dist/esm-node/router/cli/code/templates.mjs +1 -8
- package/dist/esm-node/router/runtime/tanstack/plugin.mjs +8 -9
- package/dist/esm-node/router/runtime/tanstack/plugin.node.mjs +3 -14
- package/dist/esm-node/router/runtime/tanstack/routeTree.mjs +47 -4
- package/dist/esm-node/rsc/server.worker.mjs +2 -0
- package/dist/esm-node/ssr/serverRender/renderToString/entry.mjs +9 -6
- package/dist/types/boundary-debugger/index.d.ts +28 -0
- package/dist/types/core/context/runtime.d.ts +4 -0
- package/dist/types/core/server/federatedCss.d.ts +5 -0
- package/dist/types/core/server/helmet.d.ts +5 -3
- package/dist/types/core/server/stream/beforeTemplate.d.ts +1 -0
- package/dist/types/core/server/stream/beforeTemplate.worker.d.ts +10 -0
- package/dist/types/core/server/stream/shared.d.ts +8 -0
- package/dist/types/core/server/string/loadable.d.ts +4 -0
- package/dist/types/exports/head.d.ts +10 -3
- package/dist/types/rsc/server.worker.d.ts +1 -0
- package/package.json +25 -19
|
@@ -116,9 +116,21 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
116
116
|
const topLevel = rootModern ? rootModern.children || [] : routes;
|
|
117
117
|
const imports = [];
|
|
118
118
|
const statements = [];
|
|
119
|
+
const componentImportMap = new Map();
|
|
119
120
|
const loaderImportMap = new Map();
|
|
121
|
+
const usedRouteVarNames = new Set();
|
|
122
|
+
let componentIndex = 0;
|
|
120
123
|
let loaderIndex = 0;
|
|
121
124
|
let routeIndex = 0;
|
|
125
|
+
const getImportNameForComponent = (componentPath)=>{
|
|
126
|
+
if ('string' != typeof componentPath || 0 === componentPath.length) return null;
|
|
127
|
+
const existing = componentImportMap.get(componentPath);
|
|
128
|
+
if (existing) return existing;
|
|
129
|
+
const componentName = `component_${componentIndex++}`;
|
|
130
|
+
imports.push(`import ${componentName} from ${quote(componentPath)};`);
|
|
131
|
+
componentImportMap.set(componentPath, componentName);
|
|
132
|
+
return componentName;
|
|
133
|
+
};
|
|
122
134
|
const getImportNamesForLoader = async (aliasedNoExtPath, inline, hasAction)=>{
|
|
123
135
|
const key = `${inline ? 'inline' : 'default'}:${hasAction ? 'action' : 'loader'}:${aliasedNoExtPath}`;
|
|
124
136
|
const existing = loaderImportMap.get(key);
|
|
@@ -150,10 +162,17 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
150
162
|
actionName
|
|
151
163
|
};
|
|
152
164
|
};
|
|
165
|
+
const reserveRouteVarName = (preferred)=>{
|
|
166
|
+
let candidate = preferred;
|
|
167
|
+
let suffix = 1;
|
|
168
|
+
while(usedRouteVarNames.has(candidate))candidate = `${preferred}_${suffix++}`;
|
|
169
|
+
usedRouteVarNames.add(candidate);
|
|
170
|
+
return candidate;
|
|
171
|
+
};
|
|
153
172
|
const createRouteVarName = (route)=>{
|
|
154
173
|
const id = route.id;
|
|
155
174
|
const base = id ? (0, external_makeLegalIdentifier_js_namespaceObject.makeLegalIdentifier)(id) : `r_${routeIndex++}`;
|
|
156
|
-
return `route_${base}
|
|
175
|
+
return reserveRouteVarName(`route_${base}`);
|
|
157
176
|
};
|
|
158
177
|
const buildRoute = async (opts)=>{
|
|
159
178
|
const { parentVar, route } = opts;
|
|
@@ -168,6 +187,8 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
168
187
|
const routeOpts = [
|
|
169
188
|
`getParentRoute: () => ${parentVar},`
|
|
170
189
|
];
|
|
190
|
+
const componentName = getImportNameForComponent(route._component);
|
|
191
|
+
if (componentName) routeOpts.push(`component: ${componentName},`);
|
|
171
192
|
if (isPathlessLayout(route)) {
|
|
172
193
|
const id = route.id;
|
|
173
194
|
routeOpts.push(`id: ${quote(id || 'pathless')},`);
|
|
@@ -182,14 +203,16 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
182
203
|
actionName
|
|
183
204
|
});
|
|
184
205
|
if (staticDataSnippet) routeOpts.push(staticDataSnippet);
|
|
185
|
-
statements.push(`const ${varName} = createRoute({\n ${routeOpts.join('\n ')}\n});`);
|
|
186
206
|
const children = route.children;
|
|
207
|
+
const hasChildren = Boolean(children && children.length > 0);
|
|
208
|
+
const routeCtorVarName = hasChildren ? reserveRouteVarName(`${varName}__base`) : varName;
|
|
209
|
+
statements.push(`const ${routeCtorVarName} = createRoute({\n ${routeOpts.join('\n ')}\n});`);
|
|
187
210
|
if (children && children.length > 0) {
|
|
188
211
|
const childVars = await Promise.all(children.map((child)=>buildRoute({
|
|
189
|
-
parentVar:
|
|
212
|
+
parentVar: routeCtorVarName,
|
|
190
213
|
route: child
|
|
191
214
|
})));
|
|
192
|
-
statements.push(
|
|
215
|
+
statements.push(`const ${varName} = ${routeCtorVarName}.addChildren([${childVars.join(', ')}]);`);
|
|
193
216
|
}
|
|
194
217
|
return varName;
|
|
195
218
|
};
|
|
@@ -203,6 +226,8 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
|
|
|
203
226
|
route
|
|
204
227
|
})));
|
|
205
228
|
const rootOpts = [];
|
|
229
|
+
const rootComponentName = getImportNameForComponent(rootModern?._component);
|
|
230
|
+
if (rootComponentName) rootOpts.push(`component: ${rootComponentName},`);
|
|
206
231
|
if (rootLoaderName) rootOpts.push(`loader: modernLoaderToTanstack({ hasSplat: false }, ${rootLoaderName}),`);
|
|
207
232
|
const routerGenTs = `/* eslint-disable */
|
|
208
233
|
// This file is auto-generated by Modern.js. Do not edit manually.
|
|
@@ -236,7 +261,7 @@ function isRedirectResponse(res: Response) {
|
|
|
236
261
|
}
|
|
237
262
|
|
|
238
263
|
function throwTanstackRedirect(location: string) {
|
|
239
|
-
const target = location
|
|
264
|
+
const target = location.length > 0 ? location : '/';
|
|
240
265
|
try {
|
|
241
266
|
void new URL(target);
|
|
242
267
|
throw redirect({ href: target });
|
|
@@ -262,21 +287,87 @@ function createRouteStaticData(opts: {
|
|
|
262
287
|
modernRouteAction?: unknown;
|
|
263
288
|
modernRouteLoader?: unknown;
|
|
264
289
|
}) {
|
|
265
|
-
const staticData:
|
|
290
|
+
const staticData: {
|
|
291
|
+
modernRouteId?: string;
|
|
292
|
+
modernRouteAction?: unknown;
|
|
293
|
+
modernRouteLoader?: unknown;
|
|
294
|
+
} = {};
|
|
266
295
|
|
|
267
|
-
if (opts.modernRouteId) {
|
|
296
|
+
if (typeof opts.modernRouteId === 'string' && opts.modernRouteId.length > 0) {
|
|
268
297
|
staticData.modernRouteId = opts.modernRouteId;
|
|
269
298
|
}
|
|
270
299
|
|
|
271
|
-
if (opts.modernRouteLoader) {
|
|
300
|
+
if (typeof opts.modernRouteLoader !== 'undefined') {
|
|
272
301
|
staticData.modernRouteLoader = opts.modernRouteLoader;
|
|
273
302
|
}
|
|
274
303
|
|
|
275
|
-
if (opts.modernRouteAction) {
|
|
304
|
+
if (typeof opts.modernRouteAction !== 'undefined') {
|
|
276
305
|
staticData.modernRouteAction = opts.modernRouteAction;
|
|
277
306
|
}
|
|
278
307
|
|
|
279
|
-
return
|
|
308
|
+
return staticData;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function getLoaderSignal(ctx: any): AbortSignal {
|
|
312
|
+
const abortSignal = ctx?.abortController?.signal;
|
|
313
|
+
if (abortSignal instanceof AbortSignal) {
|
|
314
|
+
return abortSignal;
|
|
315
|
+
}
|
|
316
|
+
if (ctx?.signal instanceof AbortSignal) {
|
|
317
|
+
return ctx.signal;
|
|
318
|
+
}
|
|
319
|
+
return new AbortController().signal;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function getLoaderHref(ctx: any): string {
|
|
323
|
+
if (typeof ctx?.location === 'string') {
|
|
324
|
+
return ctx.location;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const publicHref = ctx?.location?.publicHref;
|
|
328
|
+
if (typeof publicHref === 'string') {
|
|
329
|
+
return publicHref;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const href = ctx?.location?.href;
|
|
333
|
+
if (typeof href === 'string') {
|
|
334
|
+
return href;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const urlHref = ctx?.location?.url?.href;
|
|
338
|
+
return typeof urlHref === 'string' ? urlHref : '';
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function getLoaderParams(ctx: any): Record<string, string> {
|
|
342
|
+
return typeof ctx?.params === 'object' && ctx.params !== null ? ctx.params : {};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function handleModernLoaderResult<LoaderResult>(result: LoaderResult): LoaderResult {
|
|
346
|
+
if (isResponse(result)) {
|
|
347
|
+
if (isRedirectResponse(result)) {
|
|
348
|
+
const location = result.headers.get('Location') ?? '/';
|
|
349
|
+
throwTanstackRedirect(location);
|
|
350
|
+
}
|
|
351
|
+
if (result.status === 404) {
|
|
352
|
+
throw notFound();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return result;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function handleModernLoaderError(err: unknown): never {
|
|
360
|
+
if (isResponse(err)) {
|
|
361
|
+
if (isRedirectResponse(err)) {
|
|
362
|
+
const location = err.headers.get('Location') ?? '/';
|
|
363
|
+
throwTanstackRedirect(location);
|
|
364
|
+
}
|
|
365
|
+
if (err.status === 404) {
|
|
366
|
+
throw notFound();
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
throw err;
|
|
280
371
|
}
|
|
281
372
|
|
|
282
373
|
function modernLoaderToTanstack<TLoader extends (args: any) => any>(
|
|
@@ -285,57 +376,31 @@ function modernLoaderToTanstack<TLoader extends (args: any) => any>(
|
|
|
285
376
|
) {
|
|
286
377
|
type LoaderResult = Awaited<ReturnType<TLoader>>;
|
|
287
378
|
|
|
288
|
-
return
|
|
379
|
+
return (ctx: any): Promise<LoaderResult> => {
|
|
289
380
|
try {
|
|
290
|
-
const signal
|
|
291
|
-
ctx?.abortController?.signal ||
|
|
292
|
-
ctx?.signal ||
|
|
293
|
-
new AbortController().signal;
|
|
381
|
+
const signal = getLoaderSignal(ctx);
|
|
294
382
|
const baseRequest: Request | undefined =
|
|
295
383
|
ctx?.context?.request instanceof Request ? ctx.context.request : undefined;
|
|
296
384
|
|
|
297
|
-
const href =
|
|
298
|
-
typeof ctx?.location === 'string'
|
|
299
|
-
? ctx.location
|
|
300
|
-
: ctx?.location?.publicHref ||
|
|
301
|
-
ctx?.location?.href ||
|
|
302
|
-
ctx?.location?.url?.href ||
|
|
303
|
-
'';
|
|
385
|
+
const href = getLoaderHref(ctx);
|
|
304
386
|
|
|
305
|
-
const request = baseRequest
|
|
387
|
+
const request = baseRequest !== undefined
|
|
306
388
|
? new Request(baseRequest, { signal })
|
|
307
389
|
: new Request(href, { signal });
|
|
308
390
|
|
|
309
|
-
const params = mapParamsForModernLoader(ctx
|
|
310
|
-
|
|
311
|
-
const result = await (modernLoader as any)({
|
|
312
|
-
request,
|
|
313
|
-
params,
|
|
314
|
-
context: ctx?.context?.requestContext,
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
if (isResponse(result)) {
|
|
318
|
-
if (isRedirectResponse(result)) {
|
|
319
|
-
const location = result.headers.get('Location') || '/';
|
|
320
|
-
throwTanstackRedirect(location);
|
|
321
|
-
}
|
|
322
|
-
if (result.status === 404) {
|
|
323
|
-
throw notFound();
|
|
324
|
-
}
|
|
325
|
-
}
|
|
391
|
+
const params = mapParamsForModernLoader(getLoaderParams(ctx), opts.hasSplat);
|
|
326
392
|
|
|
327
|
-
return
|
|
393
|
+
return Promise.resolve(
|
|
394
|
+
(modernLoader as any)({
|
|
395
|
+
request,
|
|
396
|
+
params,
|
|
397
|
+
context: ctx?.context?.requestContext,
|
|
398
|
+
}),
|
|
399
|
+
)
|
|
400
|
+
.then((result: LoaderResult) => handleModernLoaderResult(result))
|
|
401
|
+
.catch(handleModernLoaderError);
|
|
328
402
|
} catch (err) {
|
|
329
|
-
|
|
330
|
-
if (isRedirectResponse(err)) {
|
|
331
|
-
const location = err.headers.get('Location') || '/';
|
|
332
|
-
throwTanstackRedirect(location);
|
|
333
|
-
}
|
|
334
|
-
if (err.status === 404) {
|
|
335
|
-
throw notFound();
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
throw err;
|
|
403
|
+
handleModernLoaderError(err);
|
|
339
404
|
}
|
|
340
405
|
};
|
|
341
406
|
}
|
|
@@ -211,16 +211,9 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
211
211
|
webpackChunkName: true
|
|
212
212
|
});
|
|
213
213
|
component = 'string' === ssrMode ? `loadable(${lazyImport})` : `lazy(${lazyImport})`;
|
|
214
|
-
} else
|
|
214
|
+
} else {
|
|
215
215
|
components.push(route._component);
|
|
216
216
|
component = `component_${components.length - 1}`;
|
|
217
|
-
} else {
|
|
218
|
-
lazyImport = createLazyImport({
|
|
219
|
-
componentPath: route._component,
|
|
220
|
-
routeId: route.id,
|
|
221
|
-
eager: true
|
|
222
|
-
});
|
|
223
|
-
component = `lazy(${lazyImport})`;
|
|
224
217
|
}
|
|
225
218
|
} else if (route._component) if (splitRouteChunks) {
|
|
226
219
|
lazyImport = `() => import('${route._component}')`;
|
|
@@ -37,6 +37,7 @@ const external_hooks_js_namespaceObject = require("../hooks.js");
|
|
|
37
37
|
const external_lifecycle_js_namespaceObject = require("../lifecycle.js");
|
|
38
38
|
const external_utils_js_namespaceObject = require("../utils.js");
|
|
39
39
|
const external_basepathRewrite_js_namespaceObject = require("./basepathRewrite.js");
|
|
40
|
+
const external_prefetchLink_js_namespaceObject = require("./prefetchLink.js");
|
|
40
41
|
const external_routeTree_js_namespaceObject = require("./routeTree.js");
|
|
41
42
|
const client_js_namespaceObject = require("./rsc/client.js");
|
|
42
43
|
const BLOCKING_SUBSCRIBE_SYMBOL = Symbol.for('@modern-js/plugin-runtime:tanstack-blocking-subscribe');
|
|
@@ -98,6 +99,7 @@ const tanstackRouterPlugin = (userConfig = {})=>({
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
context.router = {
|
|
102
|
+
Link: external_prefetchLink_js_namespaceObject.Link,
|
|
101
103
|
useMatches: react_router_namespaceObject.useMatches,
|
|
102
104
|
useLocation: react_router_namespaceObject.useLocation,
|
|
103
105
|
useNavigate: react_router_namespaceObject.useNavigate,
|
|
@@ -208,11 +210,8 @@ const tanstackRouterPlugin = (userConfig = {})=>({
|
|
|
208
210
|
router,
|
|
209
211
|
runtimeContext: runtimeState
|
|
210
212
|
});
|
|
211
|
-
const RouterContent = hasSSRBootstrap ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
212
|
-
|
|
213
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(client_namespaceObject.RouterClient, {
|
|
214
|
-
router: router
|
|
215
|
-
})
|
|
213
|
+
const RouterContent = hasSSRBootstrap ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(client_namespaceObject.RouterClient, {
|
|
214
|
+
router: router
|
|
216
215
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
|
|
217
216
|
router: router
|
|
218
217
|
});
|
|
@@ -65,13 +65,6 @@ async function preloadMatchedRouteComponents(tanstackRouter) {
|
|
|
65
65
|
]);
|
|
66
66
|
}));
|
|
67
67
|
}
|
|
68
|
-
async function waitForRouterSerialization(tanstackRouter) {
|
|
69
|
-
const serverSsr = tanstackRouter.serverSsr;
|
|
70
|
-
if (!serverSsr || 'function' != typeof serverSsr.onSerializationFinished || serverSsr.isSerializationFinished?.()) return;
|
|
71
|
-
await new Promise((resolve)=>{
|
|
72
|
-
serverSsr.onSerializationFinished?.(resolve);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
68
|
function htmlEscapeAttr(value) {
|
|
76
69
|
return value.replace(/&/g, '&').replace(/"/g, '"');
|
|
77
70
|
}
|
|
@@ -217,7 +210,6 @@ const tanstackRouterPlugin = (userConfig = {})=>({
|
|
|
217
210
|
await preloadMatchedRouteComponents(serverRouter);
|
|
218
211
|
context.ssrContext?.response.status(tanstackRouter.state.statusCode);
|
|
219
212
|
await serverRouter.serverSsr?.dehydrate?.();
|
|
220
|
-
await waitForRouterSerialization(serverRouter);
|
|
221
213
|
const ssrScriptTags = serverRouter.serverSsr?.takeBufferedScripts?.();
|
|
222
214
|
const hydrationScripts = routerManagedTagsToHtml(ssrScriptTags);
|
|
223
215
|
const matchedRouteIds = (0, external_routeTree_js_namespaceObject.getModernRouteIdsFromMatches)(serverRouter);
|
|
@@ -255,11 +247,8 @@ const tanstackRouterPlugin = (userConfig = {})=>({
|
|
|
255
247
|
if (!router) return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
|
|
256
248
|
...props
|
|
257
249
|
}) : null;
|
|
258
|
-
const routerWrapper = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
259
|
-
|
|
260
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
|
|
261
|
-
router: router
|
|
262
|
-
})
|
|
250
|
+
const routerWrapper = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
|
|
251
|
+
router: router
|
|
263
252
|
});
|
|
264
253
|
return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
|
|
265
254
|
children: routerWrapper
|
|
@@ -29,6 +29,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29
29
|
getModernRouteIdsFromMatches: ()=>getModernRouteIdsFromMatches
|
|
30
30
|
});
|
|
31
31
|
const react_router_namespaceObject = require("@tanstack/react-router");
|
|
32
|
+
const external_react_namespaceObject = require("react");
|
|
32
33
|
const external_DefaultNotFound_js_namespaceObject = require("../DefaultNotFound.js");
|
|
33
34
|
function createTanstackRoute(options) {
|
|
34
35
|
return (0, react_router_namespaceObject.createRoute)(options);
|
|
@@ -73,6 +74,40 @@ function isModernDeferredData(value) {
|
|
|
73
74
|
function normalizeModernLoaderResult(result) {
|
|
74
75
|
return isModernDeferredData(result) ? result.data : result;
|
|
75
76
|
}
|
|
77
|
+
function pickRouteModuleComponent(routeModule, seen = new Set()) {
|
|
78
|
+
if ('function' == typeof routeModule || routeModule && 'object' == typeof routeModule && '$$typeof' in routeModule) return routeModule;
|
|
79
|
+
if (!routeModule || 'object' != typeof routeModule) return;
|
|
80
|
+
if (seen.has(routeModule)) return;
|
|
81
|
+
seen.add(routeModule);
|
|
82
|
+
const module = routeModule;
|
|
83
|
+
for (const candidate of [
|
|
84
|
+
module.default,
|
|
85
|
+
module.Component
|
|
86
|
+
]){
|
|
87
|
+
const component = pickRouteModuleComponent(candidate, seen);
|
|
88
|
+
if (component) return component;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function createServerLazyImportComponent(lazyImport, fallbackComponent) {
|
|
92
|
+
if ("u" > typeof document) return fallbackComponent;
|
|
93
|
+
let resolvedComponent;
|
|
94
|
+
let pendingLoad;
|
|
95
|
+
const load = async ()=>{
|
|
96
|
+
if (resolvedComponent) return resolvedComponent;
|
|
97
|
+
const routeModule = await lazyImport();
|
|
98
|
+
const component = pickRouteModuleComponent(routeModule);
|
|
99
|
+
if (component) resolvedComponent = component;
|
|
100
|
+
return resolvedComponent;
|
|
101
|
+
};
|
|
102
|
+
const Component = (props)=>{
|
|
103
|
+
if (resolvedComponent) return (0, external_react_namespaceObject.createElement)(resolvedComponent, props);
|
|
104
|
+
pendingLoad ||= load();
|
|
105
|
+
throw pendingLoad;
|
|
106
|
+
};
|
|
107
|
+
Component.load = load;
|
|
108
|
+
Component.preload = load;
|
|
109
|
+
return Component;
|
|
110
|
+
}
|
|
76
111
|
function throwTanstackRedirect(location) {
|
|
77
112
|
const target = location || '/';
|
|
78
113
|
try {
|
|
@@ -141,7 +176,7 @@ function wrapModernLoader(modernRoute, modernLoader, revalidationState) {
|
|
|
141
176
|
const signal = ctx?.abortController?.signal || ctx?.signal || new AbortController().signal;
|
|
142
177
|
const baseRequest = ctx?.context?.request instanceof Request ? ctx.context.request : void 0;
|
|
143
178
|
const href = 'string' == typeof ctx?.location ? ctx.location : ctx?.location?.publicHref || ctx?.location?.href || ctx?.location?.url?.href || '';
|
|
144
|
-
const request = baseRequest ? new Request(baseRequest, {
|
|
179
|
+
const request = void 0 !== baseRequest ? new Request(baseRequest, {
|
|
145
180
|
signal
|
|
146
181
|
}) : createModernRequest(href, signal);
|
|
147
182
|
const params = mapParamsForModernLoader({
|
|
@@ -204,7 +239,7 @@ function wrapRouteObjectLoader(route, revalidationState) {
|
|
|
204
239
|
const signal = ctx?.abortController?.signal || ctx?.signal || new AbortController().signal;
|
|
205
240
|
const baseRequest = ctx?.context?.request instanceof Request ? ctx.context.request : void 0;
|
|
206
241
|
const href = 'string' == typeof ctx?.location ? ctx.location : ctx?.location?.publicHref || ctx?.location?.href || ctx?.location?.url?.href || '';
|
|
207
|
-
const request = baseRequest ? new Request(baseRequest, {
|
|
242
|
+
const request = void 0 !== baseRequest ? new Request(baseRequest, {
|
|
208
243
|
signal
|
|
209
244
|
}) : createModernRequest(href, signal);
|
|
210
245
|
const params = mapParamsForRouteObjectLoader({
|
|
@@ -239,10 +274,18 @@ function wrapRouteObjectLoader(route, revalidationState) {
|
|
|
239
274
|
}
|
|
240
275
|
function toRouteComponent(routeObject) {
|
|
241
276
|
const route = routeObject;
|
|
277
|
+
const lazyImport = 'function' == typeof route.lazyImport ? route.lazyImport : void 0;
|
|
278
|
+
const fallbackComponent = route.Component ? route.Component : route.element ? ()=>route.element : void 0;
|
|
279
|
+
if (lazyImport && fallbackComponent) return createServerLazyImportComponent(lazyImport, fallbackComponent);
|
|
242
280
|
if (route.Component) return route.Component;
|
|
243
281
|
const element = route.element;
|
|
244
282
|
if (element) return ()=>element;
|
|
245
283
|
}
|
|
284
|
+
function toModernRouteComponent(route) {
|
|
285
|
+
const component = route.component || void 0;
|
|
286
|
+
if ('function' == typeof route.lazyImport && component) return createServerLazyImportComponent(route.lazyImport, component);
|
|
287
|
+
return component;
|
|
288
|
+
}
|
|
246
289
|
function toErrorComponent(routeObject) {
|
|
247
290
|
const route = routeObject;
|
|
248
291
|
if (route.ErrorBoundary) return route.ErrorBoundary;
|
|
@@ -322,7 +365,7 @@ function createRouteFromModernRoute(opts) {
|
|
|
322
365
|
const stableFallbackId = modernId || route._component || route.filename || route.data || ('function' == typeof route.loader ? route.id : void 0);
|
|
323
366
|
const pendingComponent = route.loading || route.pendingComponent;
|
|
324
367
|
const errorComponent = route.error || route.errorComponent;
|
|
325
|
-
const component = route
|
|
368
|
+
const component = toModernRouteComponent(route);
|
|
326
369
|
const modernLoader = route.loader;
|
|
327
370
|
const modernAction = route.action;
|
|
328
371
|
const modernShouldRevalidate = route.shouldRevalidate;
|
|
@@ -368,7 +411,7 @@ function createRouteFromModernRoute(opts) {
|
|
|
368
411
|
}
|
|
369
412
|
function createRouteTreeFromModernRoutes(routes) {
|
|
370
413
|
const rootModern = routes.find((r)=>r && 'nested' === r.type && r.isRoot);
|
|
371
|
-
const rootComponent = rootModern
|
|
414
|
+
const rootComponent = rootModern ? toModernRouteComponent(rootModern) : void 0;
|
|
372
415
|
const pendingComponent = rootModern?.loading;
|
|
373
416
|
const errorComponent = rootModern?.error;
|
|
374
417
|
const rootLoader = rootModern?.loader;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"@modern-js/render/rsc-worker" (module) {
|
|
4
|
+
module.exports = require("@modern-js/render/rsc-worker");
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
var __webpack_module_cache__ = {};
|
|
8
|
+
function __webpack_require__(moduleId) {
|
|
9
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
10
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
11
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
12
|
+
exports: {}
|
|
13
|
+
};
|
|
14
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
15
|
+
return module.exports;
|
|
16
|
+
}
|
|
17
|
+
(()=>{
|
|
18
|
+
__webpack_require__.n = (module)=>{
|
|
19
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
20
|
+
__webpack_require__.d(getter, {
|
|
21
|
+
a: getter
|
|
22
|
+
});
|
|
23
|
+
return getter;
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
(()=>{
|
|
27
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
28
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: definition[key]
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
34
|
+
(()=>{
|
|
35
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
36
|
+
})();
|
|
37
|
+
(()=>{
|
|
38
|
+
__webpack_require__.r = (exports1)=>{
|
|
39
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
40
|
+
value: 'Module'
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
43
|
+
value: true
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
var __webpack_exports__ = {};
|
|
48
|
+
(()=>{
|
|
49
|
+
__webpack_require__.r(__webpack_exports__);
|
|
50
|
+
var _modern_js_render_rsc_worker__rspack_import_0 = __webpack_require__("@modern-js/render/rsc-worker");
|
|
51
|
+
var __rspack_reexport = {};
|
|
52
|
+
for(const __rspack_import_key in _modern_js_render_rsc_worker__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_modern_js_render_rsc_worker__rspack_import_0[__rspack_import_key];
|
|
53
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
54
|
+
})();
|
|
55
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
56
|
+
Object.defineProperty(exports, '__esModule', {
|
|
57
|
+
value: true
|
|
58
|
+
});
|
|
@@ -39,13 +39,11 @@ const node_namespaceObject = require("@modern-js/runtime-utils/node");
|
|
|
39
39
|
const time_namespaceObject = require("@modern-js/runtime-utils/time");
|
|
40
40
|
const external_react_namespaceObject = require("react");
|
|
41
41
|
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
42
|
-
const
|
|
43
|
-
|
|
42
|
+
const external_react_helmet_async_namespaceObject = require("react-helmet-async");
|
|
43
|
+
const helmet_js_namespaceObject = require("../../../core/server/helmet.js");
|
|
44
44
|
const utils_js_namespaceObject = require("../../../router/runtime/utils.js");
|
|
45
45
|
const external_prefetch_namespaceObject = require("../../prefetch");
|
|
46
46
|
var external_prefetch_default = /*#__PURE__*/ __webpack_require__.n(external_prefetch_namespaceObject);
|
|
47
|
-
const external_helmet_namespaceObject = require("../helmet");
|
|
48
|
-
var external_helmet_default = /*#__PURE__*/ __webpack_require__.n(external_helmet_namespaceObject);
|
|
49
47
|
const external_tracker_namespaceObject = require("../tracker");
|
|
50
48
|
const external_types_js_namespaceObject = require("../types.js");
|
|
51
49
|
const external_utils_namespaceObject = require("../utils");
|
|
@@ -101,8 +99,8 @@ class Entry {
|
|
|
101
99
|
(0, external_buildHtml_namespaceObject.createReplaceSSRDataScript)(ssrDataScripts),
|
|
102
100
|
...this.htmlModifiers
|
|
103
101
|
]);
|
|
104
|
-
const helmetData =
|
|
105
|
-
return helmetData ?
|
|
102
|
+
const helmetData = (0, helmet_js_namespaceObject.getHelmetData)(context);
|
|
103
|
+
return helmetData ? (0, helmet_js_namespaceObject.helmetReplace)(html, helmetData) : html;
|
|
106
104
|
}
|
|
107
105
|
async prefetch(context) {
|
|
108
106
|
let prefetchData;
|
|
@@ -123,11 +121,14 @@ class Entry {
|
|
|
123
121
|
const end = (0, time_namespaceObject.time)();
|
|
124
122
|
const { ssrContext } = context;
|
|
125
123
|
try {
|
|
126
|
-
const
|
|
124
|
+
const helmetContext = context._helmetContext ??= {};
|
|
125
|
+
const App = external_react_default().createElement(external_react_helmet_async_namespaceObject.HelmetProvider, {
|
|
126
|
+
context: helmetContext
|
|
127
|
+
}, external_react_default().createElement(this.App, {
|
|
127
128
|
context: Object.assign(context, {
|
|
128
129
|
ssr: true
|
|
129
130
|
})
|
|
130
|
-
});
|
|
131
|
+
}));
|
|
131
132
|
html = await (0, external_render_namespaceObject.createRender)(App).addCollector((0, external_styledComponent_namespaceObject.createStyledCollector)(this.result)).addCollector((0, external_loadable_namespaceObject.createLoadableCollector)({
|
|
132
133
|
stats: ssrContext.loadableStats,
|
|
133
134
|
result: this.result,
|