@modern-js/runtime 2.6.0 → 2.7.0
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/CHANGELOG.md +28 -0
- package/dist/cjs/common.js +6 -0
- package/dist/cjs/core/{app-config.js → appConfig.js} +3 -3
- package/dist/cjs/core/compatible.js +4 -4
- package/dist/cjs/core/index.js +6 -6
- package/dist/cjs/core/loader/useLoader.js +2 -2
- package/dist/cjs/core/types.js +15 -0
- package/dist/cjs/router/runtime/DeferredDataScripts.js +165 -0
- package/dist/cjs/router/runtime/index.js +116 -3
- package/dist/cjs/router/runtime/plugin.js +14 -1
- package/dist/cjs/router/runtime/plugin.node.js +12 -52
- package/dist/cjs/router/runtime/utils.js +68 -69
- package/dist/cjs/{runtime-context.js → runtimeContext.js} +3 -3
- package/dist/cjs/ssr/cli/index.js +2 -0
- package/dist/cjs/ssr/index.node.js +1 -0
- package/dist/cjs/ssr/serverRender/renderToStream/buildTemplate.after.js +2 -14
- package/dist/cjs/ssr/serverRender/renderToStream/renderToPipe.js +22 -7
- package/dist/cjs/ssr/serverRender/renderToStream/template.js +2 -1
- package/dist/cjs/ssr/serverRender/renderToString/entry.js +19 -8
- package/dist/esm/common.js +3 -1
- package/dist/esm/core/compatible.js +1 -1
- package/dist/esm/core/index.js +2 -2
- package/dist/esm/core/loader/useLoader.js +1 -1
- package/dist/esm/core/types.js +1 -0
- package/dist/esm/router/runtime/DeferredDataScripts.js +166 -0
- package/dist/esm/router/runtime/index.js +3 -2
- package/dist/esm/router/runtime/plugin.js +11 -3
- package/dist/esm/router/runtime/plugin.node.js +11 -68
- package/dist/esm/router/runtime/utils.js +138 -81
- package/dist/esm/ssr/cli/index.js +2 -0
- package/dist/esm/ssr/index.node.js +1 -0
- package/dist/esm/ssr/serverRender/renderToStream/buildTemplate.after.js +2 -4
- package/dist/esm/ssr/serverRender/renderToStream/renderToPipe.js +19 -8
- package/dist/esm/ssr/serverRender/renderToStream/template.js +2 -1
- package/dist/esm/ssr/serverRender/renderToString/entry.js +15 -7
- package/dist/esm-node/common.js +4 -0
- package/dist/esm-node/core/compatible.js +1 -1
- package/dist/esm-node/core/index.js +2 -2
- package/dist/esm-node/core/loader/useLoader.js +1 -1
- package/dist/esm-node/core/types.js +0 -0
- package/dist/esm-node/router/runtime/DeferredDataScripts.js +148 -0
- package/dist/esm-node/router/runtime/index.js +113 -2
- package/dist/esm-node/router/runtime/plugin.js +15 -2
- package/dist/esm-node/router/runtime/plugin.node.js +12 -55
- package/dist/esm-node/router/runtime/utils.js +59 -69
- package/dist/esm-node/ssr/cli/index.js +2 -0
- package/dist/esm-node/ssr/index.node.js +1 -0
- package/dist/esm-node/ssr/serverRender/renderToStream/buildTemplate.after.js +2 -4
- package/dist/esm-node/ssr/serverRender/renderToStream/renderToPipe.js +22 -7
- package/dist/esm-node/ssr/serverRender/renderToStream/template.js +2 -1
- package/dist/esm-node/ssr/serverRender/renderToString/entry.js +19 -8
- package/dist/types/common.d.ts +3 -1
- package/dist/types/core/compatible.d.ts +1 -1
- package/dist/types/core/index.d.ts +4 -3
- package/dist/types/core/loader/index.d.ts +1 -2
- package/dist/types/core/loader/useLoader.d.ts +1 -15
- package/dist/types/core/plugin.d.ts +15 -15
- package/dist/types/core/types.d.ts +22 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/router/runtime/DeferredDataScripts.d.ts +8 -0
- package/dist/types/router/runtime/index.d.ts +4 -2
- package/dist/types/router/runtime/utils.d.ts +23 -4
- package/dist/types/{runtime-context.d.ts → runtimeContext.d.ts} +2 -0
- package/dist/types/ssr/serverRender/renderToStream/buildTemplate.after.d.ts +2 -0
- package/package.json +12 -15
- /package/dist/esm/core/{app-config.js → appConfig.js} +0 -0
- /package/dist/esm/{runtime-context.js → runtimeContext.js} +0 -0
- /package/dist/esm-node/core/{app-config.js → appConfig.js} +0 -0
- /package/dist/esm-node/{runtime-context.js → runtimeContext.js} +0 -0
- /package/dist/types/core/{app-config.d.ts → appConfig.d.ts} +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import ReactDomServer from "react-dom/server";
|
|
3
|
-
import
|
|
3
|
+
import { serializeJson } from "@modern-js/utils/serialize";
|
|
4
4
|
import ReactHelmet from "react-helmet";
|
|
5
|
+
import { serializeErrors } from "../../../router/runtime/utils";
|
|
5
6
|
import helmetReplace from "../helmet";
|
|
6
7
|
import {
|
|
7
8
|
RenderLevel
|
|
@@ -72,13 +73,18 @@ class Entry {
|
|
|
72
73
|
if ((_c = ssrContext.redirection) == null ? void 0 : _c.url) {
|
|
73
74
|
return "";
|
|
74
75
|
}
|
|
76
|
+
const { routerContext } = context;
|
|
77
|
+
const routerData = routerContext ? {
|
|
78
|
+
loaderData: routerContext.loaderData,
|
|
79
|
+
errors: serializeErrors(routerContext.errors)
|
|
80
|
+
} : void 0;
|
|
75
81
|
let html = "";
|
|
76
82
|
const templateData = buildTemplateData(
|
|
77
83
|
ssrContext,
|
|
78
84
|
prefetchData,
|
|
79
85
|
this.result.renderLevel
|
|
80
86
|
);
|
|
81
|
-
const SSRData = this.getSSRDataScript(templateData);
|
|
87
|
+
const SSRData = this.getSSRDataScript(templateData, routerData);
|
|
82
88
|
for (const fragment of this.fragments) {
|
|
83
89
|
if (fragment.isVariable && fragment.content === "SSRDataScript") {
|
|
84
90
|
html += fragment.getValue(SSRData);
|
|
@@ -135,13 +141,18 @@ class Entry {
|
|
|
135
141
|
}
|
|
136
142
|
return html;
|
|
137
143
|
}
|
|
138
|
-
getSSRDataScript(templateData) {
|
|
144
|
+
getSSRDataScript(templateData, routerData) {
|
|
145
|
+
let ssrDataScripts = `<script>window._SSR_DATA = ${serializeJson(
|
|
146
|
+
templateData
|
|
147
|
+
)}</script>`;
|
|
148
|
+
if (routerData) {
|
|
149
|
+
ssrDataScripts += `
|
|
150
|
+
<script>window._ROUTER_DATA = ${serializeJson(
|
|
151
|
+
routerData
|
|
152
|
+
)}</script>`;
|
|
153
|
+
}
|
|
139
154
|
return {
|
|
140
|
-
SSRDataScript:
|
|
141
|
-
<script>window._SSR_DATA = ${serialize(templateData, {
|
|
142
|
-
isJSON: true
|
|
143
|
-
})}</script>
|
|
144
|
-
`
|
|
155
|
+
SSRDataScript: ssrDataScripts
|
|
145
156
|
};
|
|
146
157
|
}
|
|
147
158
|
}
|
package/dist/types/common.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ export declare const isBrowser: () => boolean;
|
|
|
3
3
|
export interface AppConfig {
|
|
4
4
|
state?: StateConfig | boolean;
|
|
5
5
|
[key: string]: any;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
|
+
export declare const JSX_SHELL_STREAM_END_MARK = "<!--<?- SHELL_STREAM_END ?>-->";
|
|
8
|
+
export declare const ESCAPED_SHELL_STREAM_END_MARK = "<!--<?- SHELL_STREAM_END ?>-->";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Renderer } from 'react-dom';
|
|
3
3
|
import type { hydrateRoot, createRoot } from 'react-dom/client';
|
|
4
|
-
import { RuntimeContext, TRuntimeContext } from '../
|
|
4
|
+
import { RuntimeContext, TRuntimeContext } from '../runtimeContext';
|
|
5
5
|
import { Plugin } from './plugin';
|
|
6
6
|
export type CreateAppOptions = {
|
|
7
7
|
plugins: Plugin[];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { createPlugin, createRuntime, runtime, registerInit } from './plugin';
|
|
2
2
|
export type { Plugin } from './plugin';
|
|
3
|
-
export { defineConfig, getConfig } from './
|
|
3
|
+
export { defineConfig, getConfig } from './appConfig';
|
|
4
4
|
export * from './compatible';
|
|
5
|
-
export type { TRuntimeContext, RuntimeContext } from '../
|
|
6
|
-
export { RuntimeReactContext, ServerRouterContext } from '../
|
|
5
|
+
export type { TRuntimeContext, RuntimeContext } from '../runtimeContext';
|
|
6
|
+
export { RuntimeReactContext, ServerRouterContext } from '../runtimeContext';
|
|
7
7
|
export * from './loader';
|
|
8
|
+
export type { SSRData, SSRContainer } from './types';
|
|
8
9
|
export * from '@modern-js/plugin';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { default as useLoader } from './useLoader';
|
|
2
|
-
export type { SSRData, SSRContainer } from './useLoader';
|
|
1
|
+
export { default as useLoader } from './useLoader';
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export interface SSRData {
|
|
3
|
-
loadersData: Record<string, LoaderResult | undefined>;
|
|
4
|
-
initialData?: Record<string, unknown>;
|
|
5
|
-
storeState?: any;
|
|
6
|
-
}
|
|
7
|
-
export interface SSRContainer {
|
|
8
|
-
data?: SSRData;
|
|
9
|
-
}
|
|
10
|
-
declare global {
|
|
11
|
-
interface Window {
|
|
12
|
-
_SSR_DATA?: SSRContainer;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
type LoaderFn<P = any, T = any> = (context: any, params: P) => Promise<T>;
|
|
15
2
|
export interface LoaderOptions<Params = any, TData = any, TError extends Error = any> {
|
|
16
3
|
/**
|
|
17
4
|
* Revoke when loader excuted successfully.
|
|
@@ -44,7 +31,6 @@ export interface LoaderOptions<Params = any, TData = any, TError extends Error =
|
|
|
44
31
|
|
|
45
32
|
static?: boolean;
|
|
46
33
|
}
|
|
47
|
-
type LoaderFn<P = any, T = any> = (context: any, params: P) => Promise<T>;
|
|
48
34
|
declare const useLoader: <TData = any, Params = any, E = any>(loaderFn: LoaderFn<Params, TData>, options?: LoaderOptions<Params, any, any>) => {
|
|
49
35
|
reload: (params?: Params | undefined) => Promise<any> | undefined;
|
|
50
36
|
loading: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import { Setup, ToThreads, CommonAPI, PluginOptions } from '@modern-js/plugin';
|
|
3
|
-
import type { RuntimeContext, TRuntimeContext } from '../
|
|
3
|
+
import type { RuntimeContext, TRuntimeContext } from '../runtimeContext';
|
|
4
4
|
export interface AppProps {}
|
|
5
5
|
declare const runtimeHooks: {
|
|
6
6
|
hoc: import("@modern-js/plugin").Pipeline<{
|
|
@@ -13,13 +13,13 @@ declare const runtimeHooks: {
|
|
|
13
13
|
}, JSX.Element>;
|
|
14
14
|
client: import("@modern-js/plugin").AsyncPipeline<{
|
|
15
15
|
App: React.ComponentType<any>;
|
|
16
|
-
readonly context
|
|
16
|
+
readonly context: RuntimeContext;
|
|
17
17
|
ModernRender: (App: React.ReactElement) => void;
|
|
18
18
|
ModernHydrate: (App: React.ReactElement, callback?: () => void) => void;
|
|
19
19
|
}, void>;
|
|
20
20
|
server: import("@modern-js/plugin").AsyncPipeline<{
|
|
21
21
|
App: React.ComponentType<any>;
|
|
22
|
-
readonly context
|
|
22
|
+
readonly context: RuntimeContext;
|
|
23
23
|
}, string>;
|
|
24
24
|
init: import("@modern-js/plugin").AsyncPipeline<{
|
|
25
25
|
context: RuntimeContext;
|
|
@@ -52,13 +52,13 @@ export declare const createRuntime: () => import("@modern-js/plugin").Manager<{
|
|
|
52
52
|
}, JSX.Element>;
|
|
53
53
|
client: import("@modern-js/plugin").AsyncPipeline<{
|
|
54
54
|
App: React.ComponentType<any>;
|
|
55
|
-
readonly context
|
|
55
|
+
readonly context: RuntimeContext;
|
|
56
56
|
ModernRender: (App: React.ReactElement) => void;
|
|
57
57
|
ModernHydrate: (App: React.ReactElement, callback?: () => void) => void;
|
|
58
58
|
}, void>;
|
|
59
59
|
server: import("@modern-js/plugin").AsyncPipeline<{
|
|
60
60
|
App: React.ComponentType<any>;
|
|
61
|
-
readonly context
|
|
61
|
+
readonly context: RuntimeContext;
|
|
62
62
|
}, string>;
|
|
63
63
|
init: import("@modern-js/plugin").AsyncPipeline<{
|
|
64
64
|
context: RuntimeContext;
|
|
@@ -84,13 +84,13 @@ export declare const runtime: import("@modern-js/plugin").Manager<{
|
|
|
84
84
|
}, JSX.Element>;
|
|
85
85
|
client: import("@modern-js/plugin").AsyncPipeline<{
|
|
86
86
|
App: React.ComponentType<any>;
|
|
87
|
-
readonly context
|
|
87
|
+
readonly context: RuntimeContext;
|
|
88
88
|
ModernRender: (App: React.ReactElement) => void;
|
|
89
89
|
ModernHydrate: (App: React.ReactElement, callback?: () => void) => void;
|
|
90
90
|
}, void>;
|
|
91
91
|
server: import("@modern-js/plugin").AsyncPipeline<{
|
|
92
92
|
App: React.ComponentType<any>;
|
|
93
|
-
readonly context
|
|
93
|
+
readonly context: RuntimeContext;
|
|
94
94
|
}, string>;
|
|
95
95
|
init: import("@modern-js/plugin").AsyncPipeline<{
|
|
96
96
|
context: RuntimeContext;
|
|
@@ -111,13 +111,13 @@ export declare const createPlugin: (setup?: Setup<{
|
|
|
111
111
|
}, JSX.Element>;
|
|
112
112
|
client: import("@modern-js/plugin").AsyncPipeline<{
|
|
113
113
|
App: React.ComponentType<any>;
|
|
114
|
-
readonly context
|
|
114
|
+
readonly context: RuntimeContext;
|
|
115
115
|
ModernRender: (App: React.ReactElement) => void;
|
|
116
116
|
ModernHydrate: (App: React.ReactElement, callback?: () => void) => void;
|
|
117
117
|
}, void>;
|
|
118
118
|
server: import("@modern-js/plugin").AsyncPipeline<{
|
|
119
119
|
App: React.ComponentType<any>;
|
|
120
|
-
readonly context
|
|
120
|
+
readonly context: RuntimeContext;
|
|
121
121
|
}, string>;
|
|
122
122
|
init: import("@modern-js/plugin").AsyncPipeline<{
|
|
123
123
|
context: RuntimeContext;
|
|
@@ -137,13 +137,13 @@ export declare const createPlugin: (setup?: Setup<{
|
|
|
137
137
|
}, JSX.Element>;
|
|
138
138
|
client: import("@modern-js/plugin").AsyncPipeline<{
|
|
139
139
|
App: React.ComponentType<any>;
|
|
140
|
-
readonly context
|
|
140
|
+
readonly context: RuntimeContext;
|
|
141
141
|
ModernRender: (App: React.ReactElement) => void;
|
|
142
142
|
ModernHydrate: (App: React.ReactElement, callback?: () => void) => void;
|
|
143
143
|
}, void>;
|
|
144
144
|
server: import("@modern-js/plugin").AsyncPipeline<{
|
|
145
145
|
App: React.ComponentType<any>;
|
|
146
|
-
readonly context
|
|
146
|
+
readonly context: RuntimeContext;
|
|
147
147
|
}, string>;
|
|
148
148
|
init: import("@modern-js/plugin").AsyncPipeline<{
|
|
149
149
|
context: RuntimeContext;
|
|
@@ -163,13 +163,13 @@ export declare const createPlugin: (setup?: Setup<{
|
|
|
163
163
|
}, JSX.Element>;
|
|
164
164
|
client: import("@modern-js/plugin").AsyncPipeline<{
|
|
165
165
|
App: React.ComponentType<any>;
|
|
166
|
-
readonly context
|
|
166
|
+
readonly context: RuntimeContext;
|
|
167
167
|
ModernRender: (App: React.ReactElement) => void;
|
|
168
168
|
ModernHydrate: (App: React.ReactElement, callback?: () => void) => void;
|
|
169
169
|
}, void>;
|
|
170
170
|
server: import("@modern-js/plugin").AsyncPipeline<{
|
|
171
171
|
App: React.ComponentType<any>;
|
|
172
|
-
readonly context
|
|
172
|
+
readonly context: RuntimeContext;
|
|
173
173
|
}, string>;
|
|
174
174
|
init: import("@modern-js/plugin").AsyncPipeline<{
|
|
175
175
|
context: RuntimeContext;
|
|
@@ -189,13 +189,13 @@ export declare const createPlugin: (setup?: Setup<{
|
|
|
189
189
|
}, JSX.Element>;
|
|
190
190
|
client: import("@modern-js/plugin").AsyncPipeline<{
|
|
191
191
|
App: React.ComponentType<any>;
|
|
192
|
-
readonly context
|
|
192
|
+
readonly context: RuntimeContext;
|
|
193
193
|
ModernRender: (App: React.ReactElement) => void;
|
|
194
194
|
ModernHydrate: (App: React.ReactElement, callback?: () => void) => void;
|
|
195
195
|
}, void>;
|
|
196
196
|
server: import("@modern-js/plugin").AsyncPipeline<{
|
|
197
197
|
App: React.ComponentType<any>;
|
|
198
|
-
readonly context
|
|
198
|
+
readonly context: RuntimeContext;
|
|
199
199
|
}, string>;
|
|
200
200
|
init: import("@modern-js/plugin").AsyncPipeline<{
|
|
201
201
|
context: RuntimeContext;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { LoaderResult } from './loader/loaderManager';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
_SSR_DATA?: SSRContainer;
|
|
5
|
+
_ROUTER_DATA?: RouterSSRData;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export interface SSRData {
|
|
9
|
+
loadersData: Record<string, LoaderResult | undefined>;
|
|
10
|
+
initialData?: Record<string, unknown>;
|
|
11
|
+
storeState?: any;
|
|
12
|
+
}
|
|
13
|
+
export interface RouteData {
|
|
14
|
+
[routeId: string]: any;
|
|
15
|
+
}
|
|
16
|
+
export interface RouterSSRData {
|
|
17
|
+
loaderData: RouteData;
|
|
18
|
+
errors: RouteData | null;
|
|
19
|
+
}
|
|
20
|
+
export interface SSRContainer {
|
|
21
|
+
data?: SSRData;
|
|
22
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { RouterConfig } from './router';
|
|
|
3
3
|
export type { Plugin } from './core';
|
|
4
4
|
export type { AppConfig } from './common';
|
|
5
5
|
export { isBrowser } from './common';
|
|
6
|
-
export type { BaseRuntimeContext, RuntimeContext, BaseTRuntimeContext, TRuntimeContext } from './
|
|
6
|
+
export type { BaseRuntimeContext, RuntimeContext, BaseTRuntimeContext, TRuntimeContext } from './runtimeContext';
|
|
7
7
|
export type { RuntimeUserConfig } from './config';
|
|
8
8
|
export { createApp, createPlugin, useLoader, bootstrap, RuntimeReactContext, defineConfig, registerInit, useRuntimeContext } from './core';
|
|
9
9
|
export { StateConfig, RouterConfig };
|
|
@@ -3,5 +3,7 @@ import type { SingleRouteConfig, RouterConfig } from './types';
|
|
|
3
3
|
export type { SingleRouteConfig, RouterConfig };
|
|
4
4
|
export default routerPlugin;
|
|
5
5
|
export { modifyRoutes } from './plugin';
|
|
6
|
-
export * from '
|
|
7
|
-
export
|
|
6
|
+
export * from './withRouter';
|
|
7
|
+
export type { FormEncType, FormMethod, GetScrollRestorationKeyFunction, ParamKeyValuePair, SubmitOptions, URLSearchParamsInit, FetcherWithComponents, ActionFunction, ActionFunctionArgs, AwaitProps, unstable_Blocker, unstable_BlockerFunction, DataRouteMatch, DataRouteObject, Fetcher, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathPattern, PathRouteProps, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, To } from 'react-router-dom';
|
|
8
|
+
export { createBrowserRouter, createHashRouter, createMemoryRouter, RouterProvider, BrowserRouter, HashRouter, MemoryRouter, Router, Await, Form, Link, NavLink, Navigate, Outlet, Route, Routes, ScrollRestoration, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, createRoutesFromChildren, createRoutesFromElements, createSearchParams, generatePath, isRouteErrorResponse, matchPath, matchRoutes, renderMatches, resolvePath } from 'react-router-dom';
|
|
9
|
+
export { defer, json, redirect } from '@modern-js/utils/remix-router';
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type
|
|
2
|
+
import { type NestedRoute, type PageRoute, type SSRMode } from '@modern-js/types';
|
|
3
|
+
import { type Router, type StaticHandlerContext } from '@modern-js/utils/remix-router';
|
|
3
4
|
import { RouterConfig } from './types';
|
|
4
|
-
export declare function getRouteComponents(routes: (NestedRoute | PageRoute)[],
|
|
5
|
-
|
|
5
|
+
export declare function getRouteComponents(routes: (NestedRoute | PageRoute)[], {
|
|
6
|
+
globalApp,
|
|
7
|
+
ssrMode
|
|
8
|
+
}: {
|
|
9
|
+
globalApp?: React.ComponentType<any>;
|
|
10
|
+
ssrMode?: SSRMode;
|
|
11
|
+
}): React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
|
|
12
|
+
export declare function renderRoutes(routesConfig: RouterConfig['routesConfig'], ssrMode?: SSRMode): React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | null;
|
|
6
13
|
export declare function getLocation(serverContext: any): string;
|
|
7
14
|
export declare const urlJoin: (...parts: string[]) => string;
|
|
8
|
-
export declare function standardSlash(str: string): string;
|
|
15
|
+
export declare function standardSlash(str: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* forked from https://github.com/remix-run/remix/blob/main/packages/remix-server-runtime/errors.ts
|
|
18
|
+
* license at https://github.com/remix-run/remix/blob/main/LICENSE.md
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export declare function serializeErrors(errors: StaticHandlerContext['errors']): StaticHandlerContext['errors'];
|
|
22
|
+
/**
|
|
23
|
+
* forked from https://github.com/remix-run/remix/blob/main/packages/remix-react/errors.ts
|
|
24
|
+
* license at https://github.com/remix-run/remix/blob/main/LICENSE.md
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export declare function deserializeErrors(errors: Router['state']['errors']): Router['state']['errors'];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Store } from '@modern-js-reduck/store';
|
|
3
|
+
import type { StaticHandlerContext } from '@modern-js/utils/remix-router';
|
|
3
4
|
import { createLoaderManager } from './core/loader/loaderManager';
|
|
4
5
|
import { runtime } from './core/plugin';
|
|
5
6
|
import { SSRServerContext } from './ssr/serverRender/types';
|
|
@@ -9,6 +10,7 @@ export interface BaseRuntimeContext {
|
|
|
9
10
|
runner: ReturnType<typeof runtime.init>;
|
|
10
11
|
ssrContext?: SSRServerContext;
|
|
11
12
|
store?: Store;
|
|
13
|
+
routerContext?: StaticHandlerContext;
|
|
12
14
|
}
|
|
13
15
|
export interface RuntimeContext extends BaseRuntimeContext {
|
|
14
16
|
[key: string]: any;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { StaticHandlerContext } from '@modern-js/utils/remix-router';
|
|
1
2
|
import { RenderLevel, SSRServerContext } from '../types';
|
|
2
3
|
type BuildShellAfterTemplateOptions = {
|
|
3
4
|
ssrContext: SSRServerContext;
|
|
5
|
+
routerContext: StaticHandlerContext;
|
|
4
6
|
renderLevel: RenderLevel;
|
|
5
7
|
};
|
|
6
8
|
export declare function buildShellAfterTemplate(afterAppTemplate: string, options: BuildShellAfterTemplateOptions): string;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.7.0",
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">=14.17.6"
|
|
17
17
|
},
|
|
@@ -144,25 +144,23 @@
|
|
|
144
144
|
"@modern-js-reduck/plugin-immutable": "^1.1.4",
|
|
145
145
|
"@modern-js-reduck/react": "^1.1.4",
|
|
146
146
|
"@modern-js-reduck/store": "^1.1.4",
|
|
147
|
-
"@remix-run/node": "^1.
|
|
148
|
-
"@remix-run/router": "^1.2.0",
|
|
147
|
+
"@remix-run/node": "^1.12.0",
|
|
149
148
|
"@types/loadable__component": "^5.13.4",
|
|
150
149
|
"@types/react-helmet": "^6.1.2",
|
|
151
150
|
"@types/redux-logger": "^3.0.9",
|
|
152
151
|
"@types/styled-components": "^5.1.14",
|
|
152
|
+
"esbuild": "0.15.7",
|
|
153
153
|
"hoist-non-react-statics": "^3.3.2",
|
|
154
154
|
"invariant": "^2.2.4",
|
|
155
155
|
"react-helmet": "^6.1.0",
|
|
156
156
|
"react-is": "^18",
|
|
157
|
-
"react-router-dom": "^6.
|
|
157
|
+
"react-router-dom": "^6.8.1",
|
|
158
158
|
"react-side-effect": "^2.1.1",
|
|
159
159
|
"redux-logger": "^3.0.6",
|
|
160
|
-
"serialize-javascript": "^6.0.0",
|
|
161
160
|
"styled-components": "^5.3.1",
|
|
162
|
-
"
|
|
163
|
-
"@modern-js/
|
|
164
|
-
"@modern-js/
|
|
165
|
-
"@modern-js/utils": "2.6.0"
|
|
161
|
+
"@modern-js/plugin": "2.7.0",
|
|
162
|
+
"@modern-js/types": "2.7.0",
|
|
163
|
+
"@modern-js/utils": "2.7.0"
|
|
166
164
|
},
|
|
167
165
|
"peerDependencies": {
|
|
168
166
|
"react": ">=17",
|
|
@@ -178,17 +176,16 @@
|
|
|
178
176
|
"@types/loadable__webpack-plugin": "^5.7.3",
|
|
179
177
|
"@types/node": "^14",
|
|
180
178
|
"@types/react-side-effect": "^1.1.1",
|
|
181
|
-
"@types/serialize-javascript": "^5.0.1",
|
|
182
179
|
"jest": "^27",
|
|
183
180
|
"react": "^18",
|
|
184
181
|
"react-dom": "^18",
|
|
185
182
|
"ts-jest": "^27.0.4",
|
|
186
183
|
"typescript": "^4",
|
|
187
|
-
"@modern-js/
|
|
188
|
-
"@modern-js/core": "2.
|
|
189
|
-
"@modern-js/
|
|
190
|
-
"@scripts/build": "2.
|
|
191
|
-
"@scripts/jest-config": "2.
|
|
184
|
+
"@modern-js/core": "2.7.0",
|
|
185
|
+
"@modern-js/server-core": "2.7.0",
|
|
186
|
+
"@modern-js/app-tools": "2.7.0",
|
|
187
|
+
"@scripts/build": "2.7.0",
|
|
188
|
+
"@scripts/jest-config": "2.7.0"
|
|
192
189
|
},
|
|
193
190
|
"sideEffects": false,
|
|
194
191
|
"modernConfig": {},
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|