@modern-js/runtime 2.51.0 → 2.52.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/dist/cjs/core/compatible.js +8 -4
- package/dist/cjs/router/runtime/DeferredDataScripts.node.js +2 -5
- package/dist/cjs/router/runtime/plugin.node.js +17 -7
- package/dist/cjs/ssr/serverRender/renderToStream/renderToPipe.js +1 -1
- package/dist/esm/core/compatible.js +9 -3
- package/dist/esm/router/runtime/DeferredDataScripts.node.js +4 -7
- package/dist/esm/router/runtime/plugin.node.js +18 -8
- package/dist/esm/ssr/serverRender/renderToStream/renderToPipe.js +1 -1
- package/dist/esm-node/core/compatible.js +8 -4
- package/dist/esm-node/router/runtime/DeferredDataScripts.node.js +4 -7
- package/dist/esm-node/router/runtime/plugin.node.js +18 -8
- package/dist/esm-node/ssr/serverRender/renderToStream/renderToPipe.js +1 -1
- package/dist/types/router/runtime/DeferredDataScripts.node.d.ts +2 -0
- package/package.json +10 -10
|
@@ -57,13 +57,12 @@ const createApp = ({ plugins, props: globalProps }) => {
|
|
|
57
57
|
return (App) => {
|
|
58
58
|
const runner = appRuntime.init();
|
|
59
59
|
const WrapperComponent = (props) => {
|
|
60
|
-
var _props_children;
|
|
61
60
|
const element = /* @__PURE__ */ import_react.default.createElement(App || import_react.default.Fragment, App ? {
|
|
62
61
|
...props
|
|
63
|
-
} : null, App ? props.children : /* @__PURE__ */ import_react.default.cloneElement(
|
|
64
|
-
...
|
|
62
|
+
} : null, App ? props.children : import_react.default.Children.map(props.children, (child) => /* @__PURE__ */ import_react.default.isValidElement(child) ? /* @__PURE__ */ import_react.default.cloneElement(child, {
|
|
63
|
+
...child.props,
|
|
65
64
|
...props
|
|
66
|
-
}));
|
|
65
|
+
}) : child));
|
|
67
66
|
const context = (0, import_react.useContext)(import_runtimeContext.RuntimeReactContext);
|
|
68
67
|
return runner.provide({
|
|
69
68
|
element,
|
|
@@ -241,7 +240,12 @@ const bootstrap = async (BootApp, id, root, ReactDOM) => {
|
|
|
241
240
|
};
|
|
242
241
|
const initialData = await runInit(context);
|
|
243
242
|
if (!isRedirectResponse(initialData)) {
|
|
243
|
+
var _context_routerContext, _context_routerContext1;
|
|
244
244
|
context.initialData = initialData;
|
|
245
|
+
if (((_context_routerContext = context.routerContext) === null || _context_routerContext === void 0 ? void 0 : _context_routerContext.statusCode) && ((_context_routerContext1 = context.routerContext) === null || _context_routerContext1 === void 0 ? void 0 : _context_routerContext1.statusCode) !== 200) {
|
|
246
|
+
var _context_routerContext2, _context_ssrContext;
|
|
247
|
+
(_context_ssrContext = context.ssrContext) === null || _context_ssrContext === void 0 ? void 0 : _context_ssrContext.response.status((_context_routerContext2 = context.routerContext) === null || _context_routerContext2 === void 0 ? void 0 : _context_routerContext2.statusCode);
|
|
248
|
+
}
|
|
245
249
|
return runner.server({
|
|
246
250
|
App,
|
|
247
251
|
context
|
|
@@ -25,14 +25,12 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
25
25
|
var import_react = require("react");
|
|
26
26
|
var import_router = require("@modern-js/runtime-utils/router");
|
|
27
27
|
var import_node = require("@modern-js/runtime-utils/node");
|
|
28
|
-
var import_common = require("../../common");
|
|
29
28
|
var import_utils = require("./utils");
|
|
30
29
|
const setupFnStr = `function s(r,e){_ROUTER_DATA.r=_ROUTER_DATA.r||{},_ROUTER_DATA.r[r]=_ROUTER_DATA.r[r]||{};return new Promise((function(A,R){_ROUTER_DATA.r[r][e]={resolve:A,reject:R}}))};`;
|
|
31
30
|
const resolveFnStr = `function r(e,r,o,A){A?_ROUTER_DATA.r[e][r].reject(A):_ROUTER_DATA.r[e][r].resolve(o)};`;
|
|
32
31
|
const preResolvedFnStr = `function p(e,r){return void 0!==r?Promise.reject(new Error(r.message)):Promise.resolve(e)};`;
|
|
33
32
|
const DeferredDataScripts = (props) => {
|
|
34
|
-
const
|
|
35
|
-
const { staticContext } = context || {};
|
|
33
|
+
const staticContext = props === null || props === void 0 ? void 0 : props.context;
|
|
36
34
|
const hydratedRef = (0, import_react.useRef)(false);
|
|
37
35
|
(0, import_react.useEffect)(() => {
|
|
38
36
|
hydratedRef.current = true;
|
|
@@ -101,8 +99,7 @@ const DeferredDataScripts = (props) => {
|
|
|
101
99
|
__html: deferredScripts[0]
|
|
102
100
|
}
|
|
103
101
|
}),
|
|
104
|
-
!hydratedRef.current && deferredScripts[1]
|
|
105
|
-
import_common.JSX_SHELL_STREAM_END_MARK
|
|
102
|
+
!hydratedRef.current && deferredScripts[1]
|
|
106
103
|
]
|
|
107
104
|
});
|
|
108
105
|
};
|
|
@@ -42,9 +42,11 @@ var import_router2 = require("@modern-js/runtime-utils/router");
|
|
|
42
42
|
var import_node = require("@modern-js/runtime-utils/node");
|
|
43
43
|
var import_time = require("@modern-js/runtime-utils/time");
|
|
44
44
|
var import_constants = require("@modern-js/utils/universal/constants");
|
|
45
|
+
var import_common = require("../../common");
|
|
45
46
|
var import_core = require("../../core");
|
|
46
47
|
var import_utils = require("./utils");
|
|
47
48
|
var import_hooks = require("./hooks");
|
|
49
|
+
var import_DeferredDataScripts = __toESM(require("./DeferredDataScripts.node"));
|
|
48
50
|
function createFetchRequest(req) {
|
|
49
51
|
const origin = `${req.protocol}://${req.host}`;
|
|
50
52
|
const url = new URL(req.originalUrl || req.url, origin);
|
|
@@ -133,14 +135,22 @@ const routerPlugin = ({ basename = "", originalBaseUrl = "", routesConfig, creat
|
|
|
133
135
|
}
|
|
134
136
|
const getRouteApp = () => {
|
|
135
137
|
return (props) => {
|
|
136
|
-
const { remixRouter, routerContext } = (0, import_react.useContext)(import_core.RuntimeReactContext);
|
|
137
|
-
|
|
138
|
+
const { remixRouter, routerContext, ssrContext } = (0, import_react.useContext)(import_core.RuntimeReactContext);
|
|
139
|
+
const { nonce, mode } = ssrContext;
|
|
140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(App, {
|
|
138
141
|
...props,
|
|
139
|
-
children:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
children: [
|
|
143
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_router.StaticRouterProvider, {
|
|
144
|
+
router: remixRouter,
|
|
145
|
+
context: routerContext,
|
|
146
|
+
hydrate: false
|
|
147
|
+
}),
|
|
148
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DeferredDataScripts.default, {
|
|
149
|
+
nonce,
|
|
150
|
+
context: routerContext
|
|
151
|
+
}),
|
|
152
|
+
mode === "stream" && import_common.JSX_SHELL_STREAM_END_MARK
|
|
153
|
+
]
|
|
144
154
|
});
|
|
145
155
|
};
|
|
146
156
|
};
|
|
@@ -61,7 +61,7 @@ function renderToPipe(rootElement, context, pluginConfig, options) {
|
|
|
61
61
|
if (shellChunkStatus !== 1) {
|
|
62
62
|
chunkVec.push(chunk.toString());
|
|
63
63
|
let concatedChunk = chunkVec.join("");
|
|
64
|
-
if (concatedChunk.
|
|
64
|
+
if (concatedChunk.includes(import_common.ESCAPED_SHELL_STREAM_END_MARK)) {
|
|
65
65
|
concatedChunk = concatedChunk.replace(import_common.ESCAPED_SHELL_STREAM_END_MARK, "");
|
|
66
66
|
shellChunkStatus = 1;
|
|
67
67
|
this.push(`${shellBefore}${concatedChunk}${shellAfter}`);
|
|
@@ -32,8 +32,9 @@ var createApp = function(param) {
|
|
|
32
32
|
return function(App) {
|
|
33
33
|
var runner = appRuntime.init();
|
|
34
34
|
var WrapperComponent = function(props) {
|
|
35
|
-
var
|
|
36
|
-
|
|
35
|
+
var element = /* @__PURE__ */ React.createElement(App || React.Fragment, App ? _object_spread({}, props) : null, App ? props.children : React.Children.map(props.children, function(child) {
|
|
36
|
+
return /* @__PURE__ */ React.isValidElement(child) ? /* @__PURE__ */ React.cloneElement(child, _object_spread({}, child.props, props)) : child;
|
|
37
|
+
}));
|
|
37
38
|
var context = useContext(RuntimeReactContext);
|
|
38
39
|
return runner.provide({
|
|
39
40
|
element,
|
|
@@ -86,7 +87,7 @@ var createApp = function(param) {
|
|
|
86
87
|
};
|
|
87
88
|
var bootstrap = function() {
|
|
88
89
|
var _ref = _async_to_generator(function(BootApp, id, root, ReactDOM) {
|
|
89
|
-
var App, runner, context, runInit, isBrowser, _ssrData_data, _ssrData_data1, ssrData, loadersData, initialLoadersState, initialData, rootElement, ModernRender, ModernHydrate, isRedirectResponse, initialData1;
|
|
90
|
+
var App, runner, context, runInit, isBrowser, _ssrData_data, _ssrData_data1, ssrData, loadersData, initialLoadersState, initialData, rootElement, ModernRender, ModernHydrate, isRedirectResponse, initialData1, _context_routerContext, _context_routerContext1, _context_routerContext2, _context_ssrContext;
|
|
90
91
|
return _ts_generator(this, function(_state) {
|
|
91
92
|
switch (_state.label) {
|
|
92
93
|
case 0:
|
|
@@ -247,7 +248,12 @@ var bootstrap = function() {
|
|
|
247
248
|
case 5:
|
|
248
249
|
initialData1 = _state.sent();
|
|
249
250
|
if (!isRedirectResponse(initialData1)) {
|
|
251
|
+
;
|
|
250
252
|
context.initialData = initialData1;
|
|
253
|
+
if (((_context_routerContext = context.routerContext) === null || _context_routerContext === void 0 ? void 0 : _context_routerContext.statusCode) && ((_context_routerContext1 = context.routerContext) === null || _context_routerContext1 === void 0 ? void 0 : _context_routerContext1.statusCode) !== 200) {
|
|
254
|
+
;
|
|
255
|
+
(_context_ssrContext = context.ssrContext) === null || _context_ssrContext === void 0 ? void 0 : _context_ssrContext.response.status((_context_routerContext2 = context.routerContext) === null || _context_routerContext2 === void 0 ? void 0 : _context_routerContext2.statusCode);
|
|
256
|
+
}
|
|
251
257
|
return [
|
|
252
258
|
2,
|
|
253
259
|
runner.server({
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { Suspense, useEffect, useRef, useMemo
|
|
4
|
-
import { Await,
|
|
3
|
+
import { Suspense, useEffect, useRef, useMemo } from "react";
|
|
4
|
+
import { Await, useAsyncError } from "@modern-js/runtime-utils/router";
|
|
5
5
|
import { serializeJson } from "@modern-js/runtime-utils/node";
|
|
6
|
-
import { JSX_SHELL_STREAM_END_MARK } from "../../common";
|
|
7
6
|
import { serializeErrors } from "./utils";
|
|
8
7
|
var setupFnStr = "function s(r,e){_ROUTER_DATA.r=_ROUTER_DATA.r||{},_ROUTER_DATA.r[r]=_ROUTER_DATA.r[r]||{};return new Promise((function(A,R){_ROUTER_DATA.r[r][e]={resolve:A,reject:R}}))};";
|
|
9
8
|
var resolveFnStr = "function r(e,r,o,A){A?_ROUTER_DATA.r[e][r].reject(A):_ROUTER_DATA.r[e][r].resolve(o)};";
|
|
10
9
|
var preResolvedFnStr = "function p(e,r){return void 0!==r?Promise.reject(new Error(r.message)):Promise.resolve(e)};";
|
|
11
10
|
var DeferredDataScripts = function(props) {
|
|
12
|
-
var
|
|
13
|
-
var staticContext = (context || {}).staticContext;
|
|
11
|
+
var staticContext = props === null || props === void 0 ? void 0 : props.context;
|
|
14
12
|
var hydratedRef = useRef(false);
|
|
15
13
|
useEffect(function() {
|
|
16
14
|
hydratedRef.current = true;
|
|
@@ -80,8 +78,7 @@ var DeferredDataScripts = function(props) {
|
|
|
80
78
|
__html: deferredScripts[0]
|
|
81
79
|
}
|
|
82
80
|
}),
|
|
83
|
-
!hydratedRef.current && deferredScripts[1]
|
|
84
|
-
JSX_SHELL_STREAM_END_MARK
|
|
81
|
+
!hydratedRef.current && deferredScripts[1]
|
|
85
82
|
]
|
|
86
83
|
});
|
|
87
84
|
};
|
|
@@ -4,7 +4,7 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
|
4
4
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
5
5
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
6
6
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { useContext } from "react";
|
|
9
9
|
import { createStaticHandler } from "@modern-js/runtime-utils/remix-router";
|
|
10
10
|
import { createStaticRouter, StaticRouterProvider } from "@modern-js/runtime-utils/node/router";
|
|
@@ -13,9 +13,11 @@ import { createRoutesFromElements } from "@modern-js/runtime-utils/router";
|
|
|
13
13
|
import { reporterCtx, createRequestContext } from "@modern-js/runtime-utils/node";
|
|
14
14
|
import { time } from "@modern-js/runtime-utils/time";
|
|
15
15
|
import { LOADER_REPORTER_NAME } from "@modern-js/utils/universal/constants";
|
|
16
|
+
import { JSX_SHELL_STREAM_END_MARK } from "../../common";
|
|
16
17
|
import { RuntimeReactContext } from "../../core";
|
|
17
18
|
import { renderRoutes, urlJoin } from "./utils";
|
|
18
19
|
import { modifyRoutes as modifyRoutesHook } from "./hooks";
|
|
20
|
+
import DeferredDataScripts from "./DeferredDataScripts.node";
|
|
19
21
|
function createFetchRequest(req) {
|
|
20
22
|
var origin = "".concat(req.protocol, "://").concat(req.host);
|
|
21
23
|
var url = new URL(req.originalUrl || req.url, origin);
|
|
@@ -162,13 +164,21 @@ var routerPlugin = function(param) {
|
|
|
162
164
|
}
|
|
163
165
|
var getRouteApp = function() {
|
|
164
166
|
return function(props) {
|
|
165
|
-
var _useContext = useContext(RuntimeReactContext), remixRouter = _useContext.remixRouter, routerContext = _useContext.routerContext;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
167
|
+
var _useContext = useContext(RuntimeReactContext), remixRouter = _useContext.remixRouter, routerContext = _useContext.routerContext, ssrContext = _useContext.ssrContext;
|
|
168
|
+
var nonce = ssrContext.nonce, mode = ssrContext.mode;
|
|
169
|
+
return /* @__PURE__ */ _jsxs(App, _object_spread_props(_object_spread({}, props), {
|
|
170
|
+
children: [
|
|
171
|
+
/* @__PURE__ */ _jsx(StaticRouterProvider, {
|
|
172
|
+
router: remixRouter,
|
|
173
|
+
context: routerContext,
|
|
174
|
+
hydrate: false
|
|
175
|
+
}),
|
|
176
|
+
/* @__PURE__ */ _jsx(DeferredDataScripts, {
|
|
177
|
+
nonce,
|
|
178
|
+
context: routerContext
|
|
179
|
+
}),
|
|
180
|
+
mode === "stream" && JSX_SHELL_STREAM_END_MARK
|
|
181
|
+
]
|
|
172
182
|
}));
|
|
173
183
|
};
|
|
174
184
|
};
|
|
@@ -43,7 +43,7 @@ function renderToPipe(rootElement, context, pluginConfig, options) {
|
|
|
43
43
|
if (shellChunkStatus !== 1) {
|
|
44
44
|
chunkVec.push(chunk.toString());
|
|
45
45
|
var concatedChunk = chunkVec.join("");
|
|
46
|
-
if (concatedChunk.
|
|
46
|
+
if (concatedChunk.includes(ESCAPED_SHELL_STREAM_END_MARK)) {
|
|
47
47
|
concatedChunk = concatedChunk.replace(ESCAPED_SHELL_STREAM_END_MARK, "");
|
|
48
48
|
shellChunkStatus = 1;
|
|
49
49
|
this.push("".concat(shellBefore).concat(concatedChunk).concat(shellAfter));
|
|
@@ -22,13 +22,12 @@ const createApp = ({ plugins, props: globalProps }) => {
|
|
|
22
22
|
return (App) => {
|
|
23
23
|
const runner = appRuntime.init();
|
|
24
24
|
const WrapperComponent = (props) => {
|
|
25
|
-
var _props_children;
|
|
26
25
|
const element = /* @__PURE__ */ React.createElement(App || React.Fragment, App ? {
|
|
27
26
|
...props
|
|
28
|
-
} : null, App ? props.children : /* @__PURE__ */ React.cloneElement(
|
|
29
|
-
...
|
|
27
|
+
} : null, App ? props.children : React.Children.map(props.children, (child) => /* @__PURE__ */ React.isValidElement(child) ? /* @__PURE__ */ React.cloneElement(child, {
|
|
28
|
+
...child.props,
|
|
30
29
|
...props
|
|
31
|
-
}));
|
|
30
|
+
}) : child));
|
|
32
31
|
const context = useContext(RuntimeReactContext);
|
|
33
32
|
return runner.provide({
|
|
34
33
|
element,
|
|
@@ -206,7 +205,12 @@ const bootstrap = async (BootApp, id, root, ReactDOM) => {
|
|
|
206
205
|
};
|
|
207
206
|
const initialData = await runInit(context);
|
|
208
207
|
if (!isRedirectResponse(initialData)) {
|
|
208
|
+
var _context_routerContext, _context_routerContext1;
|
|
209
209
|
context.initialData = initialData;
|
|
210
|
+
if (((_context_routerContext = context.routerContext) === null || _context_routerContext === void 0 ? void 0 : _context_routerContext.statusCode) && ((_context_routerContext1 = context.routerContext) === null || _context_routerContext1 === void 0 ? void 0 : _context_routerContext1.statusCode) !== 200) {
|
|
211
|
+
var _context_routerContext2, _context_ssrContext;
|
|
212
|
+
(_context_ssrContext = context.ssrContext) === null || _context_ssrContext === void 0 ? void 0 : _context_ssrContext.response.status((_context_routerContext2 = context.routerContext) === null || _context_routerContext2 === void 0 ? void 0 : _context_routerContext2.statusCode);
|
|
213
|
+
}
|
|
210
214
|
return runner.server({
|
|
211
215
|
App,
|
|
212
216
|
context
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Suspense, useEffect, useRef, useMemo
|
|
3
|
-
import { Await,
|
|
2
|
+
import { Suspense, useEffect, useRef, useMemo } from "react";
|
|
3
|
+
import { Await, useAsyncError } from "@modern-js/runtime-utils/router";
|
|
4
4
|
import { serializeJson } from "@modern-js/runtime-utils/node";
|
|
5
|
-
import { JSX_SHELL_STREAM_END_MARK } from "../../common";
|
|
6
5
|
import { serializeErrors } from "./utils";
|
|
7
6
|
const setupFnStr = `function s(r,e){_ROUTER_DATA.r=_ROUTER_DATA.r||{},_ROUTER_DATA.r[r]=_ROUTER_DATA.r[r]||{};return new Promise((function(A,R){_ROUTER_DATA.r[r][e]={resolve:A,reject:R}}))};`;
|
|
8
7
|
const resolveFnStr = `function r(e,r,o,A){A?_ROUTER_DATA.r[e][r].reject(A):_ROUTER_DATA.r[e][r].resolve(o)};`;
|
|
9
8
|
const preResolvedFnStr = `function p(e,r){return void 0!==r?Promise.reject(new Error(r.message)):Promise.resolve(e)};`;
|
|
10
9
|
const DeferredDataScripts = (props) => {
|
|
11
|
-
const
|
|
12
|
-
const { staticContext } = context || {};
|
|
10
|
+
const staticContext = props === null || props === void 0 ? void 0 : props.context;
|
|
13
11
|
const hydratedRef = useRef(false);
|
|
14
12
|
useEffect(() => {
|
|
15
13
|
hydratedRef.current = true;
|
|
@@ -78,8 +76,7 @@ const DeferredDataScripts = (props) => {
|
|
|
78
76
|
__html: deferredScripts[0]
|
|
79
77
|
}
|
|
80
78
|
}),
|
|
81
|
-
!hydratedRef.current && deferredScripts[1]
|
|
82
|
-
JSX_SHELL_STREAM_END_MARK
|
|
79
|
+
!hydratedRef.current && deferredScripts[1]
|
|
83
80
|
]
|
|
84
81
|
});
|
|
85
82
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useContext } from "react";
|
|
3
3
|
import { createStaticHandler } from "@modern-js/runtime-utils/remix-router";
|
|
4
4
|
import { createStaticRouter, StaticRouterProvider } from "@modern-js/runtime-utils/node/router";
|
|
@@ -7,9 +7,11 @@ import { createRoutesFromElements } from "@modern-js/runtime-utils/router";
|
|
|
7
7
|
import { reporterCtx, createRequestContext } from "@modern-js/runtime-utils/node";
|
|
8
8
|
import { time } from "@modern-js/runtime-utils/time";
|
|
9
9
|
import { LOADER_REPORTER_NAME } from "@modern-js/utils/universal/constants";
|
|
10
|
+
import { JSX_SHELL_STREAM_END_MARK } from "../../common";
|
|
10
11
|
import { RuntimeReactContext } from "../../core";
|
|
11
12
|
import { renderRoutes, urlJoin } from "./utils";
|
|
12
13
|
import { modifyRoutes as modifyRoutesHook } from "./hooks";
|
|
14
|
+
import DeferredDataScripts from "./DeferredDataScripts.node";
|
|
13
15
|
function createFetchRequest(req) {
|
|
14
16
|
const origin = `${req.protocol}://${req.host}`;
|
|
15
17
|
const url = new URL(req.originalUrl || req.url, origin);
|
|
@@ -98,14 +100,22 @@ const routerPlugin = ({ basename = "", originalBaseUrl = "", routesConfig, creat
|
|
|
98
100
|
}
|
|
99
101
|
const getRouteApp = () => {
|
|
100
102
|
return (props) => {
|
|
101
|
-
const { remixRouter, routerContext } = useContext(RuntimeReactContext);
|
|
102
|
-
|
|
103
|
+
const { remixRouter, routerContext, ssrContext } = useContext(RuntimeReactContext);
|
|
104
|
+
const { nonce, mode } = ssrContext;
|
|
105
|
+
return /* @__PURE__ */ _jsxs(App, {
|
|
103
106
|
...props,
|
|
104
|
-
children:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
children: [
|
|
108
|
+
/* @__PURE__ */ _jsx(StaticRouterProvider, {
|
|
109
|
+
router: remixRouter,
|
|
110
|
+
context: routerContext,
|
|
111
|
+
hydrate: false
|
|
112
|
+
}),
|
|
113
|
+
/* @__PURE__ */ _jsx(DeferredDataScripts, {
|
|
114
|
+
nonce,
|
|
115
|
+
context: routerContext
|
|
116
|
+
}),
|
|
117
|
+
mode === "stream" && JSX_SHELL_STREAM_END_MARK
|
|
118
|
+
]
|
|
109
119
|
});
|
|
110
120
|
};
|
|
111
121
|
};
|
|
@@ -38,7 +38,7 @@ function renderToPipe(rootElement, context, pluginConfig, options) {
|
|
|
38
38
|
if (shellChunkStatus !== 1) {
|
|
39
39
|
chunkVec.push(chunk.toString());
|
|
40
40
|
let concatedChunk = chunkVec.join("");
|
|
41
|
-
if (concatedChunk.
|
|
41
|
+
if (concatedChunk.includes(ESCAPED_SHELL_STREAM_END_MARK)) {
|
|
42
42
|
concatedChunk = concatedChunk.replace(ESCAPED_SHELL_STREAM_END_MARK, "");
|
|
43
43
|
shellChunkStatus = 1;
|
|
44
44
|
this.push(`${shellBefore}${concatedChunk}${shellAfter}`);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { StaticHandlerContext } from '@modern-js/runtime-utils/remix-router';
|
|
2
3
|
/**
|
|
3
4
|
* DeferredDataScripts only renders in server side,
|
|
4
5
|
* it doesn't need to be hydrated in client side.
|
|
5
6
|
*/
|
|
6
7
|
declare const DeferredDataScripts: (props?: {
|
|
7
8
|
nonce?: string;
|
|
9
|
+
context: StaticHandlerContext;
|
|
8
10
|
}) => JSX.Element | null;
|
|
9
11
|
export default DeferredDataScripts;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.52.0",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -170,10 +170,10 @@
|
|
|
170
170
|
"react-side-effect": "^2.1.1",
|
|
171
171
|
"styled-components": "^5.3.1",
|
|
172
172
|
"@swc/helpers": "0.5.3",
|
|
173
|
-
"@modern-js/
|
|
174
|
-
"@modern-js/
|
|
175
|
-
"@modern-js/utils": "2.
|
|
176
|
-
"@modern-js/
|
|
173
|
+
"@modern-js/plugin": "2.52.0",
|
|
174
|
+
"@modern-js/types": "2.52.0",
|
|
175
|
+
"@modern-js/runtime-utils": "2.52.0",
|
|
176
|
+
"@modern-js/utils": "2.52.0"
|
|
177
177
|
},
|
|
178
178
|
"peerDependencies": {
|
|
179
179
|
"react": ">=17",
|
|
@@ -194,11 +194,11 @@
|
|
|
194
194
|
"ts-jest": "^29.1.0",
|
|
195
195
|
"typescript": "^5",
|
|
196
196
|
"webpack": "^5.91.0",
|
|
197
|
-
"@
|
|
198
|
-
"@modern-js/core": "2.
|
|
199
|
-
"@
|
|
200
|
-
"@modern-js/server-core": "2.
|
|
201
|
-
"@scripts/jest-config": "2.
|
|
197
|
+
"@scripts/build": "2.52.0",
|
|
198
|
+
"@modern-js/core": "2.52.0",
|
|
199
|
+
"@modern-js/app-tools": "2.52.0",
|
|
200
|
+
"@modern-js/server-core": "2.52.0",
|
|
201
|
+
"@scripts/jest-config": "2.52.0"
|
|
202
202
|
},
|
|
203
203
|
"sideEffects": false,
|
|
204
204
|
"publishConfig": {
|