@bleedingdev/modern-js-runtime 3.9.0-ultramodern.2 → 3.9.0-ultramodern.21
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/code.js +3 -1
- package/dist/cjs/cli/ssr/index.js +2 -74
- package/dist/cjs/cli/ssr/loadable-bundler-plugin.js +2 -0
- package/dist/cjs/cli/template.server.js +1 -2
- package/dist/cjs/core/browser/hydrate.js +9 -10
- package/dist/cjs/core/browser/index.js +4 -5
- package/dist/cjs/core/context/index.js +12 -45
- package/dist/cjs/core/context/public.js +4 -7
- package/dist/cjs/core/context/runtime.js +10 -4
- package/dist/cjs/core/index.js +3 -3
- package/dist/cjs/core/plugin/index.js +2 -2
- package/dist/cjs/core/react/index.js +3 -3
- package/dist/cjs/core/react/wrapper.js +23 -67
- package/dist/cjs/core/server/helmet.js +5 -4
- package/dist/cjs/core/server/requestHandler.js +6 -7
- package/dist/cjs/core/server/requestResponse.js +4 -4
- package/dist/cjs/core/server/routerCleanup.js +2 -2
- package/dist/cjs/core/server/shared.js +171 -4
- package/dist/cjs/core/server/stream/afterTemplate.js +21 -16
- package/dist/cjs/core/server/stream/beforeTemplate.js +37 -28
- package/dist/cjs/core/server/stream/beforeTemplate.worker.js +30 -23
- package/dist/cjs/core/server/stream/createReadableStream.js +222 -125
- package/dist/cjs/core/server/stream/createReadableStream.worker.js +171 -90
- package/dist/cjs/core/server/stream/deferredScript.js +3 -3
- package/dist/cjs/core/server/stream/shared.js +6 -2
- package/dist/cjs/core/server/string/index.js +104 -66
- package/dist/cjs/core/server/string/loadable.js +38 -23
- package/dist/cjs/core/server/string/ssrData.js +5 -12
- package/dist/cjs/core/server/utils.js +1 -2
- package/dist/cjs/document/cli/index.js +14 -5
- package/dist/cjs/exports/head.js +7 -14
- package/dist/cjs/internal.js +2 -2
- package/dist/cjs/router/cli/code/nestedRoutes.js +1 -2
- package/dist/cjs/router/cli/code/templates.js +1 -1
- package/dist/cjs/router/cli/code/utils.js +2 -2
- package/dist/cjs/router/runtime/DeferredDataScripts.node.js +10 -9
- package/dist/cjs/router/runtime/PrefetchLink.js +69 -125
- package/dist/cjs/router/runtime/hooks.js +13 -2
- package/dist/cjs/router/runtime/internal.js +7 -45
- package/dist/cjs/router/runtime/plugin.js +19 -34
- package/dist/cjs/router/runtime/plugin.node.js +9 -37
- package/dist/cjs/router/runtime/redirect.js +1 -1
- package/dist/esm/cli/code.mjs +3 -1
- package/dist/esm/cli/ssr/index.mjs +3 -72
- package/dist/esm/cli/ssr/loadable-bundler-plugin.mjs +2 -0
- package/dist/esm/cli/template.server.mjs +1 -2
- package/dist/esm/core/browser/hydrate.mjs +10 -11
- package/dist/esm/core/browser/index.mjs +1 -2
- package/dist/esm/core/context/index.mjs +2 -5
- package/dist/esm/core/context/public.mjs +1 -5
- package/dist/esm/core/context/runtime.mjs +6 -3
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/core/plugin/index.mjs +1 -1
- package/dist/esm/core/react/index.mjs +1 -1
- package/dist/esm/core/react/wrapper.mjs +20 -67
- package/dist/esm/core/server/helmet.mjs +5 -4
- package/dist/esm/core/server/requestHandler.mjs +1 -2
- package/dist/esm/core/server/requestResponse.mjs +3 -3
- package/dist/esm/core/server/routerCleanup.mjs +1 -1
- package/dist/esm/core/server/shared.mjs +153 -1
- package/dist/esm/core/server/stream/afterTemplate.mjs +23 -18
- package/dist/esm/core/server/stream/beforeTemplate.mjs +40 -31
- package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +33 -26
- package/dist/esm/core/server/stream/createReadableStream.mjs +220 -123
- package/dist/esm/core/server/stream/createReadableStream.worker.mjs +161 -90
- package/dist/esm/core/server/stream/deferredScript.mjs +3 -3
- package/dist/esm/core/server/stream/shared.mjs +4 -3
- package/dist/esm/core/server/string/index.mjs +106 -68
- package/dist/esm/core/server/string/loadable.mjs +38 -23
- package/dist/esm/core/server/string/ssrData.mjs +5 -12
- package/dist/esm/core/server/utils.mjs +1 -2
- package/dist/esm/document/cli/index.mjs +12 -6
- package/dist/esm/exports/head.mjs +7 -14
- package/dist/esm/internal.mjs +1 -1
- package/dist/esm/router/cli/code/nestedRoutes.mjs +1 -2
- package/dist/esm/router/cli/code/templates.mjs +1 -1
- package/dist/esm/router/cli/code/utils.mjs +2 -2
- package/dist/esm/router/runtime/DeferredDataScripts.node.mjs +10 -9
- package/dist/esm/router/runtime/PrefetchLink.mjs +68 -124
- package/dist/esm/router/runtime/hooks.mjs +9 -1
- package/dist/esm/router/runtime/internal.mjs +2 -33
- package/dist/esm/router/runtime/plugin.mjs +10 -25
- package/dist/esm/router/runtime/plugin.node.mjs +3 -31
- package/dist/esm/router/runtime/redirect.mjs +1 -1
- package/dist/esm-node/cli/code.mjs +3 -1
- package/dist/esm-node/cli/ssr/index.mjs +3 -72
- package/dist/esm-node/cli/ssr/loadable-bundler-plugin.mjs +2 -0
- package/dist/esm-node/cli/template.server.mjs +1 -2
- package/dist/esm-node/core/browser/hydrate.mjs +10 -11
- package/dist/esm-node/core/browser/index.mjs +1 -2
- package/dist/esm-node/core/context/index.mjs +2 -5
- package/dist/esm-node/core/context/public.mjs +1 -5
- package/dist/esm-node/core/context/runtime.mjs +6 -3
- package/dist/esm-node/core/index.mjs +1 -1
- package/dist/esm-node/core/plugin/index.mjs +1 -1
- package/dist/esm-node/core/react/index.mjs +1 -1
- package/dist/esm-node/core/react/wrapper.mjs +20 -67
- package/dist/esm-node/core/server/helmet.mjs +5 -4
- package/dist/esm-node/core/server/requestHandler.mjs +1 -2
- package/dist/esm-node/core/server/requestResponse.mjs +3 -3
- package/dist/esm-node/core/server/routerCleanup.mjs +1 -1
- package/dist/esm-node/core/server/shared.mjs +153 -1
- package/dist/esm-node/core/server/stream/afterTemplate.mjs +23 -18
- package/dist/esm-node/core/server/stream/beforeTemplate.mjs +40 -31
- package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +33 -26
- package/dist/esm-node/core/server/stream/createReadableStream.mjs +220 -123
- package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +161 -90
- package/dist/esm-node/core/server/stream/deferredScript.mjs +3 -3
- package/dist/esm-node/core/server/stream/shared.mjs +4 -3
- package/dist/esm-node/core/server/string/index.mjs +106 -68
- package/dist/esm-node/core/server/string/loadable.mjs +38 -23
- package/dist/esm-node/core/server/string/ssrData.mjs +5 -12
- package/dist/esm-node/core/server/utils.mjs +1 -2
- package/dist/esm-node/document/cli/index.mjs +12 -6
- package/dist/esm-node/exports/head.mjs +7 -14
- package/dist/esm-node/internal.mjs +1 -1
- package/dist/esm-node/router/cli/code/nestedRoutes.mjs +1 -2
- package/dist/esm-node/router/cli/code/templates.mjs +1 -1
- package/dist/esm-node/router/cli/code/utils.mjs +2 -2
- package/dist/esm-node/router/runtime/DeferredDataScripts.node.mjs +10 -9
- package/dist/esm-node/router/runtime/PrefetchLink.mjs +68 -124
- package/dist/esm-node/router/runtime/hooks.mjs +9 -1
- package/dist/esm-node/router/runtime/internal.mjs +2 -33
- package/dist/esm-node/router/runtime/plugin.mjs +10 -25
- package/dist/esm-node/router/runtime/plugin.node.mjs +3 -31
- package/dist/esm-node/router/runtime/redirect.mjs +1 -1
- package/dist/types/cli/ssr/index.d.ts +0 -3
- package/dist/types/core/context/index.d.ts +4 -6
- package/dist/types/core/context/public.d.ts +1 -23
- package/dist/types/core/context/runtime.d.ts +26 -2
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/core/react/wrapper.d.ts +7 -1
- package/dist/types/core/server/helmet.d.ts +4 -5
- package/dist/types/core/server/requestHandler.d.ts +3 -3
- package/dist/types/core/server/requestResponse.d.ts +1 -1
- package/dist/types/core/server/routerCleanup.d.ts +1 -1
- package/dist/types/core/server/shared.d.ts +24 -1
- package/dist/types/core/server/stream/afterTemplate.d.ts +2 -1
- package/dist/types/core/server/stream/beforeTemplate.d.ts +4 -1
- package/dist/types/core/server/stream/beforeTemplate.worker.d.ts +4 -1
- package/dist/types/core/server/stream/shared.d.ts +16 -2
- package/dist/types/core/server/string/loadable.d.ts +6 -3
- package/dist/types/core/server/string/ssrData.d.ts +2 -1
- package/dist/types/core/server/string/types.d.ts +1 -5
- package/dist/types/core/server/tracer.d.ts +1 -1
- package/dist/types/core/server/utils.d.ts +1 -1
- package/dist/types/core/types.d.ts +1 -2
- package/dist/types/document/cli/index.d.ts +1 -0
- package/dist/types/exports/head.d.ts +2 -2
- package/dist/types/internal.d.ts +1 -1
- package/dist/types/router/runtime/PrefetchLink.d.ts +27 -2
- package/dist/types/router/runtime/hooks.d.ts +19 -2
- package/dist/types/router/runtime/internal.d.ts +4 -21
- package/dist/types/router/runtime/types.d.ts +2 -43
- package/package.json +18 -46
- package/rslib.config.mts +3 -0
- package/rstest.config.mts +28 -2
- package/dist/cjs/boundary-debugger/index.js +0 -317
- package/dist/cjs/core/context/extensions.js +0 -74
- package/dist/cjs/core/context/helmetContext.js +0 -54
- package/dist/cjs/core/server/federatedCss.js +0 -58
- package/dist/cjs/core/server/scriptOrder.js +0 -140
- package/dist/cjs/module-federation/consume-surface.js +0 -199
- package/dist/cjs/module-federation/distributed-ssr.js +0 -135
- package/dist/cjs/module-federation/index.js +0 -316
- package/dist/cjs/module-federation/last-known-good.js +0 -157
- package/dist/cjs/module-federation/manifest-recovery-runtime-plugin.js +0 -129
- package/dist/cjs/module-federation/surface-resolution-types.js +0 -61
- package/dist/cjs/router/runtime/lifecycle.js +0 -167
- package/dist/cjs/router/runtime/provider.js +0 -153
- package/dist/cjs/rsc/server.worker.js +0 -62
- package/dist/esm/boundary-debugger/index.mjs +0 -277
- package/dist/esm/core/context/extensions.mjs +0 -33
- package/dist/esm/core/context/helmetContext.mjs +0 -13
- package/dist/esm/core/server/federatedCss.mjs +0 -20
- package/dist/esm/core/server/scriptOrder.mjs +0 -90
- package/dist/esm/module-federation/consume-surface.mjs +0 -158
- package/dist/esm/module-federation/distributed-ssr.mjs +0 -82
- package/dist/esm/module-federation/index.mjs +0 -115
- package/dist/esm/module-federation/last-known-good.mjs +0 -113
- package/dist/esm/module-federation/manifest-recovery-runtime-plugin.mjs +0 -89
- package/dist/esm/module-federation/surface-resolution-types.mjs +0 -8
- package/dist/esm/router/runtime/lifecycle.mjs +0 -105
- package/dist/esm/router/runtime/provider.mjs +0 -100
- package/dist/esm/rsc/server.worker.mjs +0 -1
- package/dist/esm-node/boundary-debugger/index.mjs +0 -278
- package/dist/esm-node/core/context/extensions.mjs +0 -34
- package/dist/esm-node/core/context/helmetContext.mjs +0 -14
- package/dist/esm-node/core/server/federatedCss.mjs +0 -21
- package/dist/esm-node/core/server/scriptOrder.mjs +0 -91
- package/dist/esm-node/module-federation/consume-surface.mjs +0 -159
- package/dist/esm-node/module-federation/distributed-ssr.mjs +0 -83
- package/dist/esm-node/module-federation/index.mjs +0 -116
- package/dist/esm-node/module-federation/last-known-good.mjs +0 -114
- package/dist/esm-node/module-federation/manifest-recovery-runtime-plugin.mjs +0 -90
- package/dist/esm-node/module-federation/surface-resolution-types.mjs +0 -9
- package/dist/esm-node/router/runtime/lifecycle.mjs +0 -106
- package/dist/esm-node/router/runtime/provider.mjs +0 -101
- package/dist/esm-node/rsc/server.worker.mjs +0 -2
- package/dist/types/boundary-debugger/index.d.ts +0 -28
- package/dist/types/core/context/extensions.d.ts +0 -35
- package/dist/types/core/context/helmetContext.d.ts +0 -10
- package/dist/types/core/server/federatedCss.d.ts +0 -5
- package/dist/types/core/server/scriptOrder.d.ts +0 -25
- package/dist/types/module-federation/consume-surface.d.ts +0 -104
- package/dist/types/module-federation/distributed-ssr.d.ts +0 -61
- package/dist/types/module-federation/index.d.ts +0 -71
- package/dist/types/module-federation/last-known-good.d.ts +0 -52
- package/dist/types/module-federation/manifest-recovery-runtime-plugin.d.ts +0 -25
- package/dist/types/module-federation/surface-resolution-types.d.ts +0 -23
- package/dist/types/router/runtime/lifecycle.d.ts +0 -27
- package/dist/types/router/runtime/provider.d.ts +0 -78
- package/dist/types/rsc/server.worker.d.ts +0 -1
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { InternalRuntimeContext, getGlobalEnableRsc, getGlobalIsRscClient, getGlobalLayoutApp, getGlobalRoutes } from "@modern-js/runtime/context";
|
|
3
4
|
import { merge } from "@modern-js/runtime-utils/merge";
|
|
4
5
|
import { RouterProvider, createBrowserRouter, createHashRouter, createRoutesFromElements, useHref, useInRouterContext, useLocation, useMatches, useNavigate, useParams } from "@modern-js/runtime-utils/router";
|
|
5
6
|
import { normalizePathname } from "@modern-js/runtime-utils/url";
|
|
6
7
|
import * as __rspack_external_react from "react";
|
|
7
|
-
import {
|
|
8
|
-
import { applyRouterRuntimeState } from "./lifecycle.mjs";
|
|
8
|
+
import { routerProviderRegistryHooks } from "./hooks.mjs";
|
|
9
9
|
import { Link } from "./PrefetchLink.mjs";
|
|
10
|
-
import { routerProviderRegistryHooks } from "./provider.mjs";
|
|
11
10
|
import { createClientRouterFromPayload } from "./rsc-router.mjs";
|
|
12
11
|
import { createRouteObjectsFromConfig, deserializeErrors, renderRoutes, urlJoin } from "./utils.mjs";
|
|
13
12
|
let finalRouteConfig = {
|
|
@@ -68,7 +67,6 @@ const routerPlugin = (userConfig = {})=>({
|
|
|
68
67
|
const match = serverBase.find((baseUrl)=>isSegmentPrefix(pathname, baseUrl));
|
|
69
68
|
return match || '/';
|
|
70
69
|
};
|
|
71
|
-
let cachedRouter = null;
|
|
72
70
|
const RouterWrapper = (props)=>{
|
|
73
71
|
const routerResult = useRouterCreation(("u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ : true === getGlobalEnableRsc()) ? {
|
|
74
72
|
...props,
|
|
@@ -80,12 +78,7 @@ const routerPlugin = (userConfig = {})=>({
|
|
|
80
78
|
selectBasePath,
|
|
81
79
|
basename
|
|
82
80
|
});
|
|
83
|
-
const router =
|
|
84
|
-
if (cachedRouter) return cachedRouter;
|
|
85
|
-
cachedRouter = routerResult.router;
|
|
86
|
-
return cachedRouter;
|
|
87
|
-
}, []);
|
|
88
|
-
const { routes } = routerResult;
|
|
81
|
+
const { router, routes } = routerResult;
|
|
89
82
|
routesContainer.current = routes;
|
|
90
83
|
beforeCreateRouter = false;
|
|
91
84
|
const routerContent = /*#__PURE__*/ jsxs(Fragment, {
|
|
@@ -129,7 +122,8 @@ function useRouterCreation(props, options) {
|
|
|
129
122
|
const { unstable_getBlockNavState: getBlockNavState } = runtimeContext;
|
|
130
123
|
const rscPayload = ("u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ : true === getGlobalEnableRsc()) && props?.rscPayload ? safeUse(props.rscPayload) : null;
|
|
131
124
|
let hydrationData = "u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ ? window._ROUTER_DATA || rscPayload : window._ROUTER_DATA : true === getGlobalEnableRsc() ? window._ROUTER_DATA || rscPayload : window._ROUTER_DATA;
|
|
132
|
-
|
|
125
|
+
const result = (0, __rspack_external_react.useRef)(null);
|
|
126
|
+
if (null === result.current) {
|
|
133
127
|
if (hydrationData?.errors) hydrationData = {
|
|
134
128
|
...hydrationData,
|
|
135
129
|
errors: deserializeErrors(hydrationData.errors)
|
|
@@ -145,10 +139,11 @@ function useRouterCreation(props, options) {
|
|
|
145
139
|
const hooks = api.getHooks();
|
|
146
140
|
if (("u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ : true === getGlobalEnableRsc()) && rscPayload) try {
|
|
147
141
|
const router = createClientRouterFromPayload(rscPayload, routes, _basename);
|
|
148
|
-
|
|
142
|
+
result.current = {
|
|
149
143
|
router,
|
|
150
144
|
routes: router.routes || []
|
|
151
145
|
};
|
|
146
|
+
return result.current;
|
|
152
147
|
} catch (e) {
|
|
153
148
|
console.error('Failed to create router from RSC payload:', e);
|
|
154
149
|
}
|
|
@@ -169,11 +164,6 @@ function useRouterCreation(props, options) {
|
|
|
169
164
|
basename: _basename,
|
|
170
165
|
hydrationData
|
|
171
166
|
});
|
|
172
|
-
applyRouterRuntimeState(runtimeContext, {
|
|
173
|
-
framework: 'react-router',
|
|
174
|
-
basename: _basename,
|
|
175
|
-
instance: router
|
|
176
|
-
});
|
|
177
167
|
hooks.onAfterCreateRouter.call({
|
|
178
168
|
...routerLifecycleContext,
|
|
179
169
|
router,
|
|
@@ -202,16 +192,11 @@ function useRouterCreation(props, options) {
|
|
|
202
192
|
};
|
|
203
193
|
return originSubscribe(wrappedListener);
|
|
204
194
|
};
|
|
205
|
-
|
|
195
|
+
result.current = {
|
|
206
196
|
router,
|
|
207
197
|
routes: modifiedRoutes
|
|
208
198
|
};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
props,
|
|
212
|
-
_basename,
|
|
213
|
-
hydrationData,
|
|
214
|
-
getBlockNavState
|
|
215
|
-
]);
|
|
199
|
+
}
|
|
200
|
+
return result.current;
|
|
216
201
|
}
|
|
217
202
|
export { beforeCreateRouter, finalRouteConfig, modifyRoutes, routerPlugin };
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { InternalRuntimeContext, getGlobalEnableRsc, getGlobalLayoutApp, getGlobalRoutes } from "@modern-js/runtime/context";
|
|
3
4
|
import { merge } from "@modern-js/runtime-utils/merge";
|
|
4
5
|
import { createRequestContext } from "@modern-js/runtime-utils/node";
|
|
5
6
|
import { StaticRouterProvider, createRoutesFromElements, createStaticHandler, createStaticRouter, useInRouterContext, useLocation, useNavigate, useParams } from "@modern-js/runtime-utils/router";
|
|
6
7
|
import { time } from "@modern-js/runtime-utils/time";
|
|
7
8
|
import { LOADER_REPORTER_NAME } from "@modern-js/utils/universal/constants";
|
|
8
9
|
import { useContext } from "react";
|
|
9
|
-
import { InternalRuntimeContext, getGlobalEnableRsc, getGlobalLayoutApp, getGlobalRoutes } from "../../core/context/index.mjs";
|
|
10
10
|
import { setServerPayload } from "../../core/context/serverPayload/index.server.mjs";
|
|
11
11
|
import DeferredDataScripts_node from "./DeferredDataScripts.node.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import { routerProviderRegistryHooks } from "./hooks.mjs";
|
|
13
13
|
import { Link } from "./PrefetchLink.mjs";
|
|
14
|
-
import { routerProviderRegistryHooks } from "./provider.mjs";
|
|
15
14
|
import { RSCStaticRouter, createServerPayload, handleRSCRedirect, prepareRSCRoutes } from "./rsc-router.mjs";
|
|
16
15
|
import { createRouteObjectsFromConfig, renderRoutes, urlJoin } from "./utils.mjs";
|
|
17
16
|
function createRemixRequest(request) {
|
|
@@ -24,24 +23,6 @@ function createRemixRequest(request) {
|
|
|
24
23
|
signal: controller.signal
|
|
25
24
|
});
|
|
26
25
|
}
|
|
27
|
-
function createReactRouterServerSnapshot(routerContext, basename) {
|
|
28
|
-
return createRouterServerSnapshot({
|
|
29
|
-
framework: 'react-router',
|
|
30
|
-
basename,
|
|
31
|
-
statusCode: routerContext.statusCode,
|
|
32
|
-
errors: routerContext.errors,
|
|
33
|
-
routerData: {
|
|
34
|
-
loaderData: routerContext.loaderData,
|
|
35
|
-
errors: routerContext.errors
|
|
36
|
-
},
|
|
37
|
-
matches: routerContext.matches.map((match)=>{
|
|
38
|
-
const routeId = match.route.id;
|
|
39
|
-
return 'string' == typeof routeId ? {
|
|
40
|
-
routeId
|
|
41
|
-
} : void 0;
|
|
42
|
-
}).filter((match)=>void 0 !== match)
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
26
|
const routerPlugin = (userConfig = {})=>({
|
|
46
27
|
name: '@modern-js/plugin-router',
|
|
47
28
|
registryHooks: routerProviderRegistryHooks,
|
|
@@ -108,18 +89,9 @@ const routerPlugin = (userConfig = {})=>({
|
|
|
108
89
|
throw errors[0];
|
|
109
90
|
}
|
|
110
91
|
context.routerContext = routerContext;
|
|
111
|
-
const routerServerSnapshot = createReactRouterServerSnapshot(routerContext, _basename);
|
|
112
|
-
applyRouterRuntimeState(context, {
|
|
113
|
-
framework: 'react-router',
|
|
114
|
-
basename: _basename,
|
|
115
|
-
instance: routerContext,
|
|
116
|
-
matchedRouteIds: routerServerSnapshot.matchedRouteIds,
|
|
117
|
-
serverSnapshot: routerServerSnapshot
|
|
118
|
-
});
|
|
119
92
|
hooks.onAfterCreateRouter.call({
|
|
120
93
|
...routerLifecycleContext,
|
|
121
94
|
router: routerContext,
|
|
122
|
-
serverSnapshot: routerServerSnapshot,
|
|
123
95
|
runtimeContext: context
|
|
124
96
|
});
|
|
125
97
|
let payload;
|
|
@@ -152,7 +124,7 @@ const routerPlugin = (userConfig = {})=>({
|
|
|
152
124
|
}) : /*#__PURE__*/ jsx(RSCStaticRouter, {
|
|
153
125
|
basename: basename
|
|
154
126
|
});
|
|
155
|
-
{
|
|
127
|
+
else {
|
|
156
128
|
const { nonce, mode, useJsonScript } = context.ssrContext;
|
|
157
129
|
const remixRouter = createStaticRouter(routes, routerContext);
|
|
158
130
|
const routerWrapper = /*#__PURE__*/ jsxs(Fragment, {
|
|
@@ -2,7 +2,7 @@ import "node:module";
|
|
|
2
2
|
const handleRSCRedirect = (headers, basename, status)=>{
|
|
3
3
|
const newHeaders = new Headers(headers);
|
|
4
4
|
let redirectUrl = headers.get('Location');
|
|
5
|
-
if (
|
|
5
|
+
if (null === redirectUrl || '' === redirectUrl || ![
|
|
6
6
|
301,
|
|
7
7
|
302,
|
|
8
8
|
303,
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import type { AppTools, CliPlugin } from '@modern-js/app-tools';
|
|
2
|
-
import type { MergedEnvironmentConfig } from '@rsbuild/core';
|
|
3
|
-
type EnvironmentConfigLike = Partial<Pick<MergedEnvironmentConfig, 'output' | 'source' | 'tools'>>;
|
|
4
|
-
export declare const shouldUseModuleFederationNodeOutput: (config: EnvironmentConfigLike) => boolean;
|
|
5
2
|
export declare const ssrPlugin: () => CliPlugin<AppTools>;
|
|
6
3
|
export default ssrPlugin;
|
|
@@ -20,12 +20,10 @@ type InternalRuntimeContextLike = {
|
|
|
20
20
|
[key: string]: any;
|
|
21
21
|
};
|
|
22
22
|
export { DefaultNotFound } from '../../router/runtime/DefaultNotFound.js';
|
|
23
|
-
export { modifyRoutes, onAfterCreateRouter, onAfterHydrateRouter, onBeforeCreateRouter, onBeforeCreateRoutes, onBeforeHydrateRouter, type RouterExtendsHooks, } from '../../router/runtime/hooks.js';
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export { createRuntimeContextExtension, type RuntimeContextExtension, } from './extensions.js';
|
|
28
|
-
export { getInitialContext, InternalRuntimeContext, RuntimeContext, type TInternalRuntimeContext, type TRuntimeContext, } from './runtime.js';
|
|
23
|
+
export { modifyRoutes, onAfterCreateRouter, onAfterHydrateRouter, onBeforeCreateRouter, onBeforeCreateRoutes, onBeforeHydrateRouter, type RouterExtendsHooks, type RouterLifecycleContext, routerProviderRegistryHooks, } from '../../router/runtime/hooks.js';
|
|
24
|
+
export type { LinkPrefetchPolicy } from '../../router/runtime/PrefetchLink.js';
|
|
25
|
+
export type { LoaderFunction, LoaderFunctionArgs, ModernRoute, } from '../../router/runtime/types.js';
|
|
26
|
+
export { getInitialContext, InternalRuntimeContext, ReactRuntimeContext, type RequestContext, RuntimeComponentResolverContext, RuntimeContext, type TInternalRuntimeContext, type TRuntimeContext, useRuntimeContext, } from './runtime.js';
|
|
29
27
|
export type { PayloadRoute, ServerPayload } from './serverPayload/index.js';
|
|
30
28
|
interface GlobalContext {
|
|
31
29
|
entryName?: string;
|
|
@@ -1,23 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { RequestContext } from '../types.js';
|
|
3
|
-
export type { RequestContext };
|
|
4
|
-
export interface TRuntimeContext {
|
|
5
|
-
initialData?: Record<string, unknown>;
|
|
6
|
-
isBrowser: boolean;
|
|
7
|
-
routes?: RouteObject[];
|
|
8
|
-
requestContext: RequestContext;
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Use `requestContext` instead
|
|
11
|
-
*/
|
|
12
|
-
context: RequestContext;
|
|
13
|
-
[key: string]: unknown;
|
|
14
|
-
}
|
|
15
|
-
export declare const RuntimeContext: import("react").Context<TRuntimeContext>;
|
|
16
|
-
/**
|
|
17
|
-
* deprecated, use RuntimeContext instead
|
|
18
|
-
*/
|
|
19
|
-
export declare const ReactRuntimeContext: import("react").Context<TRuntimeContext>;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated use use(RuntimeContext) instead
|
|
22
|
-
*/
|
|
23
|
-
export declare const useRuntimeContext: () => TRuntimeContext;
|
|
1
|
+
export { ReactRuntimeContext, type RequestContext, RuntimeContext, type TRuntimeContext, useRuntimeContext, } from './index.js';
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type { ResolveComponentFn } from '@modern-js/plugin/runtime';
|
|
1
2
|
import type { RouteObject, StaticHandlerContext } from '@modern-js/runtime-utils/router';
|
|
2
3
|
import type { BaseSSRServerContext } from '@modern-js/types';
|
|
4
|
+
import type { LinkPrefetchPolicy } from '../../router/runtime/PrefetchLink.js';
|
|
3
5
|
import type { RouteManifest } from '../../router/runtime/types.js';
|
|
4
|
-
import {
|
|
6
|
+
import type { RequestContext } from '../types.js';
|
|
7
|
+
export type { RequestContext };
|
|
5
8
|
export type InternalSSRContext = {
|
|
6
9
|
request: BaseSSRServerContext['request'] & {
|
|
7
10
|
raw?: Request;
|
|
@@ -9,12 +12,23 @@ export type InternalSSRContext = {
|
|
|
9
12
|
response: BaseSSRServerContext['response'];
|
|
10
13
|
[key: string]: any;
|
|
11
14
|
};
|
|
12
|
-
export
|
|
15
|
+
export interface TRuntimeContext {
|
|
16
|
+
initialData?: Record<string, unknown>;
|
|
17
|
+
isBrowser: boolean;
|
|
18
|
+
routes?: RouteObject[];
|
|
19
|
+
requestContext: RequestContext;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use `requestContext` instead
|
|
22
|
+
*/
|
|
23
|
+
context: RequestContext;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
13
26
|
/**
|
|
14
27
|
* InternalRuntimeContext used internally and by plugins
|
|
15
28
|
*/
|
|
16
29
|
export interface TInternalRuntimeContext extends TRuntimeContext {
|
|
17
30
|
routeManifest?: RouteManifest;
|
|
31
|
+
linkPrefetchPolicy?: LinkPrefetchPolicy;
|
|
18
32
|
routes?: RouteObject[];
|
|
19
33
|
routerContext?: StaticHandlerContext;
|
|
20
34
|
unstable_getBlockNavState?: () => boolean;
|
|
@@ -23,4 +37,14 @@ export interface TInternalRuntimeContext extends TRuntimeContext {
|
|
|
23
37
|
_internalRouterBaseName?: any;
|
|
24
38
|
}
|
|
25
39
|
export declare const InternalRuntimeContext: import("react").Context<TInternalRuntimeContext>;
|
|
40
|
+
export declare const RuntimeContext: import("react").Context<TRuntimeContext>;
|
|
41
|
+
export declare const RuntimeComponentResolverContext: import("react").Context<ResolveComponentFn | undefined>;
|
|
42
|
+
/**
|
|
43
|
+
* deprecated, use RuntimeContext instead
|
|
44
|
+
*/
|
|
45
|
+
export declare const ReactRuntimeContext: import("react").Context<TRuntimeContext>;
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated use use(RuntimeContext) instead
|
|
48
|
+
*/
|
|
49
|
+
export declare const useRuntimeContext: () => TRuntimeContext;
|
|
26
50
|
export declare const getInitialContext: (isBrowser?: boolean, routeManifest?: RouteManifest) => TInternalRuntimeContext;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
export { RuntimeContext, useRuntimeContext, } from './context/index.js';
|
|
1
2
|
export { defineRuntimeConfig } from './config.js';
|
|
2
3
|
export type { TRuntimeContext } from './context/runtime.js';
|
|
3
|
-
export { RuntimeContext, useRuntimeContext, } from './context/runtime.js';
|
|
4
4
|
export type { RuntimePlugin } from './plugin/index.js';
|
|
5
5
|
export type { SSRContainer, SSRData } from './types.js';
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { ResolveComponentFn } from '@modern-js/plugin/runtime';
|
|
2
2
|
import { type TRuntimeContext } from '../context/index.js';
|
|
3
|
+
import type React from 'react';
|
|
4
|
+
export declare function wrapRuntimeComponentResolver(root: React.ReactNode, hooks?: {
|
|
5
|
+
resolveComponent?: {
|
|
6
|
+
call: ResolveComponentFn;
|
|
7
|
+
};
|
|
8
|
+
} | undefined): React.ReactElement;
|
|
3
9
|
export declare function wrapRuntimeContextProvider(App: React.ReactElement, contextValue: TRuntimeContext): React.JSX.Element;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function helmetReplace(content: string, helmetData: HelmetServerState): string;
|
|
1
|
+
import type { SSRHeadData, SSRRenderLifecycle } from '@modern-js/plugin/runtime';
|
|
2
|
+
export declare function getHelmetData(providers: readonly SSRRenderLifecycle[]): SSRHeadData | undefined;
|
|
3
|
+
export declare function createReplaceHelemt(helmetData?: SSRHeadData): (template: string) => string;
|
|
4
|
+
export declare function helmetReplace(content: string, helmetData: SSRHeadData): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { RequestHandler, RequestHandlerOptions } from '@modern-js/app-tools';
|
|
2
|
-
import React from 'react';
|
|
3
1
|
import { type TInternalRuntimeContext } from '../context/index.js';
|
|
4
|
-
|
|
2
|
+
import type { RequestHandler, RequestHandlerOptions } from '@modern-js/server-core';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export type { RequestHandlerConfig as HandleRequestConfig } from '@modern-js/server-core';
|
|
5
5
|
export type HandleRequestOptions = Exclude<RequestHandlerOptions, 'staticGenerate'> & {
|
|
6
6
|
runtimeContext: TInternalRuntimeContext;
|
|
7
7
|
};
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* failures are reported through the request's `onError` instead of being
|
|
10
10
|
* swallowed.
|
|
11
11
|
*/
|
|
12
|
-
import type { OnError } from '@modern-js/
|
|
12
|
+
import type { OnError } from '@modern-js/types';
|
|
13
13
|
import type { TInternalRuntimeContext } from '../context/index.js';
|
|
14
14
|
export declare const ROUTER_CLEANUP_ERROR = "An error occurs during router runtime cleanup";
|
|
15
15
|
export type RouterCleanup = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SSRAssetGroup, SSRAssetTransformInfo, SSRRenderAsset, SSRRenderLifecycle, SSRRenderTerminal, SSRRouterData, SSRTemplateChunk, StreamSSRExtender } from '@modern-js/plugin/runtime';
|
|
2
|
+
import type { ServerUserConfig } from '@modern-js/server-core';
|
|
2
3
|
import type { HandleRequestOptions } from './requestHandler.js';
|
|
3
4
|
export type RenderOptions = HandleRequestOptions;
|
|
4
5
|
export type SSRConfig = NonNullable<ServerUserConfig['ssr']>;
|
|
@@ -6,3 +7,25 @@ export type RenderStreaming = (request: Request, serverRoot: React.ReactElement,
|
|
|
6
7
|
export type RenderString = (request: Request, serverRoot: React.ReactElement, optinos: RenderOptions) => Promise<string>;
|
|
7
8
|
export type BuildHtmlCb = (template: string) => string | Promise<string>;
|
|
8
9
|
export declare function buildHtml(template: string, callbacks: BuildHtmlCb[]): Promise<string>;
|
|
10
|
+
export declare function createSSRRenderLifecycle(observers: SSRRenderLifecycle[]): {
|
|
11
|
+
transformAssets<T extends SSRRenderAsset>(groups: readonly SSRAssetGroup<T>[], info: Omit<SSRAssetTransformInfo<T>, 'groups'>): readonly T[];
|
|
12
|
+
transformTemplateChunk(chunk: SSRTemplateChunk): SSRTemplateChunk;
|
|
13
|
+
getRouterData(): SSRRouterData | undefined;
|
|
14
|
+
readonly terminal: SSRRenderTerminal | undefined;
|
|
15
|
+
beforeReact(): void;
|
|
16
|
+
completedBody(html: string, phase: 'complete' | 'shell'): string;
|
|
17
|
+
finish(result: SSRRenderTerminal): void;
|
|
18
|
+
};
|
|
19
|
+
export declare function replaceSSRTemplateChunk(chunk: SSRTemplateChunk, lifecycle?: ReturnType<typeof createSSRRenderLifecycle>, options?: {
|
|
20
|
+
preserveEmpty?: boolean;
|
|
21
|
+
}): string;
|
|
22
|
+
export declare function orderSSRStreamTransforms(extenders: StreamSSRExtender[]): StreamSSRExtender[];
|
|
23
|
+
export declare function createSSRStreamErrorReporter(onError: (error: unknown) => void): (error: unknown) => void;
|
|
24
|
+
/** Observe the delivered body, rather than declaring completion at allReady. */
|
|
25
|
+
export declare function observeSSRStream(source: ReadableStream<Uint8Array>, options: {
|
|
26
|
+
lifecycle: ReturnType<typeof createSSRRenderLifecycle>;
|
|
27
|
+
onError: (error: unknown) => void | Promise<void>;
|
|
28
|
+
signal: AbortSignal;
|
|
29
|
+
onCancel?: (reason: unknown) => void | Promise<void>;
|
|
30
|
+
onComplete?: () => void | Promise<void>;
|
|
31
|
+
}): ReadableStream<Uint8Array>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type RenderLevel } from '../../constants.js';
|
|
2
2
|
import type { TInternalRuntimeContext } from '../../context/index.js';
|
|
3
3
|
import type { HandleRequestConfig } from '../requestHandler.js';
|
|
4
|
-
import { type SSRConfig } from '../shared.js';
|
|
4
|
+
import { type createSSRRenderLifecycle, type SSRConfig } from '../shared.js';
|
|
5
5
|
export type BuildShellAfterTemplateOptions = {
|
|
6
6
|
runtimeContext: TInternalRuntimeContext;
|
|
7
7
|
renderLevel: RenderLevel;
|
|
@@ -9,5 +9,6 @@ export type BuildShellAfterTemplateOptions = {
|
|
|
9
9
|
request: Request;
|
|
10
10
|
entryName: string;
|
|
11
11
|
config: HandleRequestConfig;
|
|
12
|
+
lifecycle?: ReturnType<typeof createSSRRenderLifecycle>;
|
|
12
13
|
};
|
|
13
14
|
export declare function buildShellAfterTemplate(afterAppTemplate: string, options: BuildShellAfterTemplateOptions): Promise<string>;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import type { SSRHeadData } from '@modern-js/plugin/runtime';
|
|
1
2
|
import type { TInternalRuntimeContext } from '../../context/index.js';
|
|
2
3
|
import type { HandleRequestConfig } from '../requestHandler.js';
|
|
4
|
+
import { type createSSRRenderLifecycle } from '../shared.js';
|
|
3
5
|
export interface BuildShellBeforeTemplateOptions {
|
|
4
6
|
runtimeContext: TInternalRuntimeContext;
|
|
5
7
|
entryName: string;
|
|
6
8
|
config: HandleRequestConfig;
|
|
7
9
|
styledComponentsStyleTags?: string;
|
|
8
|
-
|
|
10
|
+
lifecycle?: ReturnType<typeof createSSRRenderLifecycle>;
|
|
11
|
+
helmetData?: SSRHeadData;
|
|
9
12
|
}
|
|
10
13
|
export declare function buildShellBeforeTemplate(beforeAppTemplate: string, options: BuildShellBeforeTemplateOptions): Promise<string>;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import type { SSRHeadData } from '@modern-js/plugin/runtime';
|
|
1
2
|
import type { TInternalRuntimeContext } from '../../context/index.js';
|
|
2
3
|
import type { HandleRequestConfig } from '../requestHandler.js';
|
|
4
|
+
import { type createSSRRenderLifecycle } from '../shared.js';
|
|
3
5
|
export interface BuildShellBeforeTemplateOptions {
|
|
4
6
|
runtimeContext: TInternalRuntimeContext;
|
|
5
7
|
entryName: string;
|
|
6
8
|
config: HandleRequestConfig;
|
|
7
9
|
styledComponentsStyleTags?: string;
|
|
8
|
-
|
|
10
|
+
lifecycle?: ReturnType<typeof createSSRRenderLifecycle>;
|
|
11
|
+
helmetData?: SSRHeadData;
|
|
9
12
|
}
|
|
10
13
|
export declare function buildShellBeforeTemplate(beforeAppTemplate: string, options: BuildShellBeforeTemplateOptions): Promise<string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OnError } from '@modern-js/
|
|
1
|
+
import type { OnError } from '@modern-js/types';
|
|
2
2
|
import type { ClientManifest as RscClientManifest, ServerManifest as RscServerManifest, SSRManifest as RscSSRManifest } from '@modern-js/types/server';
|
|
3
3
|
import type React from 'react';
|
|
4
4
|
import type { TInternalRuntimeContext } from '../../context/index.js';
|
|
@@ -16,7 +16,7 @@ export type CreateReadableStreamFromElementOptions = {
|
|
|
16
16
|
ssrConfig: SSRConfig;
|
|
17
17
|
htmlTemplate: string;
|
|
18
18
|
entryName: string;
|
|
19
|
-
|
|
19
|
+
resource?: object;
|
|
20
20
|
rscClientManifest?: RscClientManifest;
|
|
21
21
|
rscSSRManifest?: RscSSRManifest;
|
|
22
22
|
rscServerManifest?: RscServerManifest;
|
|
@@ -32,6 +32,20 @@ export declare enum ShellChunkStatus {
|
|
|
32
32
|
START = 0,
|
|
33
33
|
FINISH = 1
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* The document head is sealed when the shell end mark is written, so only head
|
|
37
|
+
* tags emitted before it reach `<head>`. React writes a completed Suspense
|
|
38
|
+
* boundary after the shell once the flushed bytes exceed `progressiveChunkSize`,
|
|
39
|
+
* which drops the head of every large route and keeps its content hidden until
|
|
40
|
+
* the inline `$RC` script runs. Completed boundaries therefore stay inline in
|
|
41
|
+
* the shell; pending boundaries still stream when they resolve. Buffering
|
|
42
|
+
* paths (`onAllReady`) thereby seal the head after all content.
|
|
43
|
+
*
|
|
44
|
+
* Measured on a ~1 MB route completed at shell time (React 19.3, Node): the
|
|
45
|
+
* default chunk size reaches the shell end mark in 0.7 ms, this one in 1.2 ms,
|
|
46
|
+
* so the head fix costs no measurable time to first byte.
|
|
47
|
+
*/
|
|
48
|
+
export declare const SHELL_PROGRESSIVE_CHUNK_SIZE: number;
|
|
35
49
|
export declare function resolveStreamingMode(request: Request, forceStreamToString: boolean): {
|
|
36
50
|
onReady: 'onAllReady' | 'onShellReady';
|
|
37
51
|
waitForAllReady: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { createSSRRenderLifecycle } from '../shared.js';
|
|
3
3
|
import type { ChunkSet, Collector } from './types.js';
|
|
4
4
|
declare module '@loadable/server' {
|
|
5
5
|
interface ChunkExtractor {
|
|
@@ -11,10 +11,9 @@ export interface LoadableCollectorOptions {
|
|
|
11
11
|
nonce?: string;
|
|
12
12
|
stats?: Record<string, any>;
|
|
13
13
|
routeManifest?: Record<string, any>;
|
|
14
|
-
runtimeContext: TInternalRuntimeContext;
|
|
15
14
|
template: string;
|
|
16
15
|
entryName: string;
|
|
17
|
-
|
|
16
|
+
lifecycle?: ReturnType<typeof createSSRRenderLifecycle>;
|
|
18
17
|
chunkSet: ChunkSet;
|
|
19
18
|
config: LoadableCollectorConfig;
|
|
20
19
|
}
|
|
@@ -28,6 +27,10 @@ export interface LoadableCollectorConfig {
|
|
|
28
27
|
export declare class LoadableCollector implements Collector {
|
|
29
28
|
private options;
|
|
30
29
|
private extractor?;
|
|
30
|
+
readonly stylesheetInfo: {
|
|
31
|
+
emittedAssets: string[];
|
|
32
|
+
attributes: Record<string, unknown>;
|
|
33
|
+
};
|
|
31
34
|
constructor(options: LoadableCollectorOptions);
|
|
32
35
|
private get existsAssets();
|
|
33
36
|
collect(comopnent: ReactElement): ReactElement;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StaticHandlerContext } from '@modern-js/runtime-utils/router';
|
|
2
2
|
import type { TInternalRuntimeContext } from '../../context/index.js';
|
|
3
3
|
import type { SSRServerContext } from '../../types.js';
|
|
4
|
-
import type { SSRConfig } from '../shared.js';
|
|
4
|
+
import type { createSSRRenderLifecycle, SSRConfig } from '../shared.js';
|
|
5
5
|
import type { ChunkSet, Collector } from './types.js';
|
|
6
6
|
export interface SSRDataCreatorOptions {
|
|
7
7
|
runtimeContext: TInternalRuntimeContext;
|
|
@@ -10,6 +10,7 @@ export interface SSRDataCreatorOptions {
|
|
|
10
10
|
ssrContext: SSRServerContext;
|
|
11
11
|
ssrConfig?: SSRConfig;
|
|
12
12
|
routerContext?: StaticHandlerContext;
|
|
13
|
+
lifecycle?: ReturnType<typeof createSSRRenderLifecycle>;
|
|
13
14
|
nonce?: string;
|
|
14
15
|
useJsonScript?: boolean;
|
|
15
16
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { ReactElement } from 'react';
|
|
2
1
|
import type { RenderLevel } from '../../constants.js';
|
|
3
|
-
export
|
|
4
|
-
collect?: (comopnent: ReactElement) => ReactElement;
|
|
5
|
-
effect: () => void | Promise<void>;
|
|
6
|
-
}
|
|
2
|
+
export type { Collector } from '@modern-js/plugin/runtime';
|
|
7
3
|
export type ChunkSet = {
|
|
8
4
|
renderLevel: RenderLevel;
|
|
9
5
|
ssrScripts: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ServerUserConfig } from '@modern-js/app-tools';
|
|
2
1
|
import type { StaticHandlerContext } from '@modern-js/runtime-utils/router';
|
|
2
|
+
import type { ServerUserConfig } from '@modern-js/server-core';
|
|
3
3
|
import type { SSRConfig } from './shared.js';
|
|
4
4
|
export declare function attributesToString(attributes: Record<string, any>): string;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { OnError, OnTiming } from '@modern-js/
|
|
2
|
-
import type { BaseSSRServerContext } from '@modern-js/types';
|
|
1
|
+
import type { BaseSSRServerContext, OnError, OnTiming } from '@modern-js/types';
|
|
3
2
|
import type { RenderLevel } from './constants.js';
|
|
4
3
|
declare global {
|
|
5
4
|
interface Window {
|
|
@@ -2,5 +2,6 @@ import type { AppTools, CliPlugin } from '@modern-js/app-tools';
|
|
|
2
2
|
import type { Entrypoint } from '@modern-js/types/cli';
|
|
3
3
|
export declare const processScriptPlaceholders: (html: string, nonce?: string) => string;
|
|
4
4
|
export declare const getDocumentByEntryName: (entrypoints: Entrypoint[], entryName: string, fallbackDir?: string) => string | undefined;
|
|
5
|
+
export declare const getDocumentTempEntry: (internalDirectory: string, compilerName: string | undefined, entryName: string) => string;
|
|
5
6
|
export declare const documentPlugin: () => CliPlugin<AppTools>;
|
|
6
7
|
export default documentPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export declare const Helmet: (props: React.PropsWithChildren<HelmetProps>) => React.
|
|
2
|
+
import { HelmetData as AsyncHelmetData, type HelmetDatum, type HelmetHTMLBodyDatum, type HelmetHTMLElementDatum, type HelmetProps, HelmetProvider, type HelmetServerState, type HelmetTags } from 'react-helmet-async';
|
|
3
|
+
export declare const Helmet: (props: React.PropsWithChildren<HelmetProps>) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
4
4
|
declare const head: {
|
|
5
5
|
Helmet: typeof Helmet;
|
|
6
6
|
HelmetData: typeof AsyncHelmetData;
|
package/dist/types/internal.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { InternalRuntimeContext, type TInternalRuntimeContext, } from './core/context/
|
|
1
|
+
export { InternalRuntimeContext, type TInternalRuntimeContext, } from './core/context/index.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LinkProps as RouterLinkProps, type NavLinkProps as RouterNavLinkProps } from '@modern-js/runtime-utils/router';
|
|
1
|
+
import { type RouteObject, type LinkProps as RouterLinkProps, type NavLinkProps as RouterNavLinkProps } from '@modern-js/runtime-utils/router';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* Modified from https://github.com/remix-run/remix/blob/9a0601bd704d2f3ee622e0ddacab9b611eb0c5bc/packages/remix-react/components.tsx#L218
|
|
@@ -16,7 +16,7 @@ import React from 'react';
|
|
|
16
16
|
* - "viewport": Fetched when the link enters the viewport
|
|
17
17
|
* - "none": Never fetched
|
|
18
18
|
*/
|
|
19
|
-
type PrefetchBehavior = '
|
|
19
|
+
type PrefetchBehavior = NonNullable<RouterLinkProps['prefetch']>;
|
|
20
20
|
type PreloadBehavior = PrefetchBehavior | false;
|
|
21
21
|
export interface LinkProps extends RouterLinkProps {
|
|
22
22
|
prefetch?: PrefetchBehavior;
|
|
@@ -26,6 +26,31 @@ export interface NavLinkProps extends RouterNavLinkProps {
|
|
|
26
26
|
prefetch?: PrefetchBehavior;
|
|
27
27
|
preload?: PreloadBehavior;
|
|
28
28
|
}
|
|
29
|
+
/** Optional scheduling capability supplied by a runtime integration. */
|
|
30
|
+
export interface LinkPrefetchPolicy {
|
|
31
|
+
observe(options: {
|
|
32
|
+
element: HTMLAnchorElement | null;
|
|
33
|
+
prefetch?: PrefetchBehavior;
|
|
34
|
+
preload?: PreloadBehavior;
|
|
35
|
+
notify: (state: {
|
|
36
|
+
code: boolean;
|
|
37
|
+
data: boolean;
|
|
38
|
+
}) => void;
|
|
39
|
+
}): {
|
|
40
|
+
onIntent: () => void;
|
|
41
|
+
onCancel: () => void;
|
|
42
|
+
dispose: () => void;
|
|
43
|
+
};
|
|
44
|
+
schedule(options: {
|
|
45
|
+
runtimeContext: object;
|
|
46
|
+
chunkLoader: object;
|
|
47
|
+
publicPath: string;
|
|
48
|
+
key: string;
|
|
49
|
+
run: () => Promise<unknown>;
|
|
50
|
+
}): () => void;
|
|
51
|
+
canWarmup: () => boolean;
|
|
52
|
+
allowData: (route: RouteObject) => boolean;
|
|
53
|
+
}
|
|
29
54
|
declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
30
55
|
declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
31
56
|
export { Link, NavLink };
|