@modern-js/runtime 2.68.5 → 2.68.7
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/context/index.js +1 -1
- package/dist/cjs/core/context/serverPayload/index.js +34 -0
- package/dist/cjs/core/context/{serverPayload.server.js → serverPayload/index.server.js} +3 -3
- package/dist/cjs/core/server/requestHandler.js +1 -1
- package/dist/cjs/document/cli/index.js +3 -3
- package/dist/cjs/router/runtime/plugin.node.js +1 -1
- package/dist/cjs/router/runtime/utils.js +5 -1
- package/dist/esm/core/context/index.js +1 -1
- package/dist/esm/core/context/serverPayload/index.js +9 -0
- package/dist/esm/core/server/requestHandler.js +1 -1
- package/dist/esm/document/cli/index.js +23 -3
- package/dist/esm/router/runtime/plugin.node.js +1 -1
- package/dist/esm/router/runtime/utils.js +2 -1
- package/dist/esm-node/core/context/index.js +1 -1
- package/dist/esm-node/core/context/serverPayload/index.js +9 -0
- package/dist/esm-node/core/server/requestHandler.js +1 -1
- package/dist/esm-node/document/cli/index.js +3 -3
- package/dist/esm-node/router/runtime/plugin.node.js +1 -1
- package/dist/esm-node/router/runtime/utils.js +5 -1
- package/dist/types/core/context/index.d.ts +3 -29
- package/dist/types/core/context/{serverPayload.server.d.ts → serverPayload/index.d.ts} +2 -1
- package/dist/types/core/context/serverPayload/index.server.d.ts +30 -0
- package/dist/types/core/server/utils.d.ts +0 -1
- package/package.json +12 -12
- /package/dist/esm/core/context/{serverPayload.server.js → serverPayload/index.server.js} +0 -0
- /package/dist/esm-node/core/context/{serverPayload.server.js → serverPayload/index.server.js} +0 -0
|
@@ -37,7 +37,7 @@ __export(context_exports, {
|
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(context_exports);
|
|
39
39
|
var import_runtime = require("./runtime");
|
|
40
|
-
var import_serverPayload = require("./serverPayload
|
|
40
|
+
var import_serverPayload = require("./serverPayload/index");
|
|
41
41
|
const globalContext = {};
|
|
42
42
|
function getGlobalIsRscClient() {
|
|
43
43
|
return globalContext.isRscClient;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var serverPayload_exports = {};
|
|
20
|
+
__export(serverPayload_exports, {
|
|
21
|
+
getServerPayload: () => getServerPayload,
|
|
22
|
+
setServerPayload: () => setServerPayload
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(serverPayload_exports);
|
|
25
|
+
const getServerPayload = () => {
|
|
26
|
+
return void 0;
|
|
27
|
+
};
|
|
28
|
+
const setServerPayload = (payload) => {
|
|
29
|
+
};
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
getServerPayload,
|
|
33
|
+
setServerPayload
|
|
34
|
+
});
|
|
@@ -16,12 +16,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var index_server_exports = {};
|
|
20
|
+
__export(index_server_exports, {
|
|
21
21
|
getServerPayload: () => getServerPayload,
|
|
22
22
|
setServerPayload: () => setServerPayload
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
24
|
+
module.exports = __toCommonJS(index_server_exports);
|
|
25
25
|
var import_node = require("@modern-js/runtime-utils/node");
|
|
26
26
|
const getServerPayload = () => {
|
|
27
27
|
const context = import_node.storage.useContext();
|
|
@@ -27,7 +27,7 @@ var import_request = require("@modern-js/runtime-utils/universal/request");
|
|
|
27
27
|
var import_react = require("react");
|
|
28
28
|
var import_context = require("../context");
|
|
29
29
|
var import_runtime = require("../context/runtime");
|
|
30
|
-
var import_serverPayload = require("../context/serverPayload
|
|
30
|
+
var import_serverPayload = require("../context/serverPayload/index");
|
|
31
31
|
var import_loaderManager = require("../loader/loaderManager");
|
|
32
32
|
var import_react2 = require("../react");
|
|
33
33
|
var import_constants = require("./constants");
|
|
@@ -40,7 +40,7 @@ var import_react = __toESM(require("react"));
|
|
|
40
40
|
var import_server = __toESM(require("react-dom/server"));
|
|
41
41
|
var import_DocumentContext = require("../DocumentContext");
|
|
42
42
|
var import_constants = require("../constants");
|
|
43
|
-
const debug = (0, import_utils.createDebugger)("
|
|
43
|
+
const debug = (0, import_utils.createDebugger)("html_generate");
|
|
44
44
|
const getDocumenByEntryName = function(entrypoints, entryName, fallbackDir) {
|
|
45
45
|
var _entrypoints_find;
|
|
46
46
|
const entryDir = (_entrypoints_find = entrypoints.find((item) => item.entryName === entryName)) === null || _entrypoints_find === void 0 ? void 0 : _entrypoints_find.absoluteEntryDir;
|
|
@@ -159,7 +159,7 @@ const documentPlugin = () => ({
|
|
|
159
159
|
partialsContent.partialsHead = partialsByEntrypoint[entryName].head.join("\n");
|
|
160
160
|
partialsContent.partialsBody = partialsByEntrypoint[entryName].body.join("\n");
|
|
161
161
|
}
|
|
162
|
-
html = html.replace(import_constants.TOP_PARTICALS_SEPARATOR, partialsContent.partialsTop).replace(import_constants.HEAD_PARTICALS_SEPARATOR, partialsContent.partialsHead).replace(import_constants.BODY_PARTICALS_SEPARATOR, partialsContent.partialsBody);
|
|
162
|
+
html = html.replace(import_constants.TOP_PARTICALS_SEPARATOR, () => partialsContent.partialsTop).replace(import_constants.HEAD_PARTICALS_SEPARATOR, () => partialsContent.partialsHead).replace(import_constants.BODY_PARTICALS_SEPARATOR, () => partialsContent.partialsBody);
|
|
163
163
|
const links = [
|
|
164
164
|
htmlWebpackPlugin.tags.headTags.filter((item) => item.tagName === "link").join("")
|
|
165
165
|
].join("");
|
|
@@ -179,7 +179,7 @@ const documentPlugin = () => ({
|
|
|
179
179
|
if (html.includes(import_constants.DOCUMENT_COMMENT_PLACEHOLDER_START) && html.includes(import_constants.DOCUMENT_COMMENT_PLACEHOLDER_END)) {
|
|
180
180
|
html = html.replace(new RegExp(`${import_constants.DOCUMENT_COMMENT_PLACEHOLDER_START}(.*?)${import_constants.DOCUMENT_COMMENT_PLACEHOLDER_END}`, "g"), (_scriptStr, $1) => `${decodeURIComponent($1)}`);
|
|
181
181
|
}
|
|
182
|
-
const finalHtml = `<!DOCTYPE html>${html}`.replace(import_constants.DOCUMENT_META_PLACEHOLDER, metas).replace(import_constants.DOCUMENT_SSR_PLACEHOLDER, import_constants.HTML_SEPARATOR).replace(import_constants.DOCUMENT_SCRIPTS_PLACEHOLDER, scripts).replace(import_constants.DOCUMENT_LINKS_PLACEHOLDER, links).replace(import_constants.DOCUMENT_CHUNKSMAP_PLACEHOLDER, import_constants.PLACEHOLDER_REPLACER_MAP[import_constants.DOCUMENT_CHUNKSMAP_PLACEHOLDER]).replace(import_constants.DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, import_constants.PLACEHOLDER_REPLACER_MAP[import_constants.DOCUMENT_SSRDATASCRIPT_PLACEHOLDER]).replace(import_constants.DOCUMENT_TITLE_PLACEHOLDER, titles);
|
|
182
|
+
const finalHtml = `<!DOCTYPE html>${html}`.replace(import_constants.DOCUMENT_META_PLACEHOLDER, () => metas).replace(import_constants.DOCUMENT_SSR_PLACEHOLDER, () => import_constants.HTML_SEPARATOR).replace(import_constants.DOCUMENT_SCRIPTS_PLACEHOLDER, () => scripts).replace(import_constants.DOCUMENT_LINKS_PLACEHOLDER, () => links).replace(import_constants.DOCUMENT_CHUNKSMAP_PLACEHOLDER, () => import_constants.PLACEHOLDER_REPLACER_MAP[import_constants.DOCUMENT_CHUNKSMAP_PLACEHOLDER]).replace(import_constants.DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, () => import_constants.PLACEHOLDER_REPLACER_MAP[import_constants.DOCUMENT_SSRDATASCRIPT_PLACEHOLDER]).replace(import_constants.DOCUMENT_TITLE_PLACEHOLDER, () => titles);
|
|
183
183
|
return finalHtml;
|
|
184
184
|
};
|
|
185
185
|
};
|
|
@@ -44,7 +44,7 @@ var import_react = require("react");
|
|
|
44
44
|
var import_common = require("../../common");
|
|
45
45
|
var import_core = require("../../core");
|
|
46
46
|
var import_context = require("../../core/context");
|
|
47
|
-
var import_serverPayload = require("../../core/context/serverPayload.server");
|
|
47
|
+
var import_serverPayload = require("../../core/context/serverPayload/index.server");
|
|
48
48
|
var import_DeferredDataScripts = __toESM(require("./DeferredDataScripts.node"));
|
|
49
49
|
var import_hooks = require("./hooks");
|
|
50
50
|
var import_rsc_router = require("./rsc-router");
|
|
@@ -101,6 +101,7 @@ function getRouteObjects(routes, { globalApp, ssrMode, props }) {
|
|
|
101
101
|
const routeObjects = [];
|
|
102
102
|
for (const route of routes) {
|
|
103
103
|
if (route.type === "nested") {
|
|
104
|
+
var _route_config;
|
|
104
105
|
const nestedRouteObject = {
|
|
105
106
|
path: route.path,
|
|
106
107
|
id: route.id,
|
|
@@ -108,7 +109,10 @@ function getRouteObjects(routes, { globalApp, ssrMode, props }) {
|
|
|
108
109
|
action: route.action,
|
|
109
110
|
hasErrorBoundary: route.hasErrorBoundary,
|
|
110
111
|
shouldRevalidate: route.shouldRevalidate,
|
|
111
|
-
handle:
|
|
112
|
+
handle: {
|
|
113
|
+
...route.handle,
|
|
114
|
+
...typeof route.config === "object" ? (_route_config = route.config) === null || _route_config === void 0 ? void 0 : _route_config.handle : {}
|
|
115
|
+
},
|
|
112
116
|
index: route.index,
|
|
113
117
|
hasClientLoader: !!route.clientData,
|
|
114
118
|
Component: route.component ? route.component : void 0,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RuntimeReactContext, getInitialContext } from "./runtime";
|
|
2
2
|
var globalContext = {};
|
|
3
|
-
import { getServerPayload, setServerPayload } from "./serverPayload
|
|
3
|
+
import { getServerPayload, setServerPayload } from "./serverPayload/index";
|
|
4
4
|
function getGlobalIsRscClient() {
|
|
5
5
|
return globalContext.isRscClient;
|
|
6
6
|
}
|
|
@@ -11,7 +11,7 @@ import { getPathname, parseCookie, parseHeaders, parseQuery } from "@modern-js/r
|
|
|
11
11
|
import { Fragment } from "react";
|
|
12
12
|
import { getGlobalAppInit, getGlobalInternalRuntimeContext, getGlobalRSCRoot } from "../context";
|
|
13
13
|
import { getInitialContext } from "../context/runtime";
|
|
14
|
-
import { getServerPayload } from "../context/serverPayload
|
|
14
|
+
import { getServerPayload } from "../context/serverPayload/index";
|
|
15
15
|
import { createLoaderManager } from "../loader/loaderManager";
|
|
16
16
|
import { createRoot } from "../react";
|
|
17
17
|
import { CHUNK_CSS_PLACEHOLDER } from "./constants";
|
|
@@ -9,7 +9,7 @@ import React from "react";
|
|
|
9
9
|
import ReactDomServer from "react-dom/server";
|
|
10
10
|
import { DocumentContext } from "../DocumentContext";
|
|
11
11
|
import { BODY_PARTICALS_SEPARATOR, DOCUMENT_CHUNKSMAP_PLACEHOLDER, DOCUMENT_COMMENT_PLACEHOLDER_END, DOCUMENT_COMMENT_PLACEHOLDER_START, DOCUMENT_FILE_NAME, DOCUMENT_LINKS_PLACEHOLDER, DOCUMENT_META_PLACEHOLDER, DOCUMENT_SCRIPTS_PLACEHOLDER, DOCUMENT_SCRIPT_ATTRIBUTES_END, DOCUMENT_SCRIPT_ATTRIBUTES_START, DOCUMENT_SCRIPT_PLACEHOLDER_END, DOCUMENT_SCRIPT_PLACEHOLDER_START, DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, DOCUMENT_SSR_PLACEHOLDER, DOCUMENT_STYLE_PLACEHOLDER_END, DOCUMENT_STYLE_PLACEHOLDER_START, DOCUMENT_TITLE_PLACEHOLDER, DOC_EXT, HEAD_PARTICALS_SEPARATOR, HTML_SEPARATOR, PLACEHOLDER_REPLACER_MAP, TOP_PARTICALS_SEPARATOR } from "../constants";
|
|
12
|
-
var debug = createDebugger("
|
|
12
|
+
var debug = createDebugger("html_generate");
|
|
13
13
|
var getDocumenByEntryName = function getDocumenByEntryName2(entrypoints, entryName, fallbackDir) {
|
|
14
14
|
var _entrypoints_find;
|
|
15
15
|
var entryDir = (_entrypoints_find = entrypoints.find(function(item) {
|
|
@@ -173,7 +173,13 @@ var documentPlugin = function() {
|
|
|
173
173
|
partialsContent.partialsHead = partialsByEntrypoint[entryName].head.join("\n");
|
|
174
174
|
partialsContent.partialsBody = partialsByEntrypoint[entryName].body.join("\n");
|
|
175
175
|
}
|
|
176
|
-
html = html.replace(TOP_PARTICALS_SEPARATOR,
|
|
176
|
+
html = html.replace(TOP_PARTICALS_SEPARATOR, function() {
|
|
177
|
+
return partialsContent.partialsTop;
|
|
178
|
+
}).replace(HEAD_PARTICALS_SEPARATOR, function() {
|
|
179
|
+
return partialsContent.partialsHead;
|
|
180
|
+
}).replace(BODY_PARTICALS_SEPARATOR, function() {
|
|
181
|
+
return partialsContent.partialsBody;
|
|
182
|
+
});
|
|
177
183
|
links = [
|
|
178
184
|
htmlWebpackPlugin.tags.headTags.filter(function(item) {
|
|
179
185
|
return item.tagName === "link";
|
|
@@ -205,7 +211,21 @@ var documentPlugin = function() {
|
|
|
205
211
|
return "".concat(decodeURIComponent($1));
|
|
206
212
|
});
|
|
207
213
|
}
|
|
208
|
-
finalHtml = "<!DOCTYPE html>".concat(html).replace(DOCUMENT_META_PLACEHOLDER,
|
|
214
|
+
finalHtml = "<!DOCTYPE html>".concat(html).replace(DOCUMENT_META_PLACEHOLDER, function() {
|
|
215
|
+
return metas;
|
|
216
|
+
}).replace(DOCUMENT_SSR_PLACEHOLDER, function() {
|
|
217
|
+
return HTML_SEPARATOR;
|
|
218
|
+
}).replace(DOCUMENT_SCRIPTS_PLACEHOLDER, function() {
|
|
219
|
+
return scripts;
|
|
220
|
+
}).replace(DOCUMENT_LINKS_PLACEHOLDER, function() {
|
|
221
|
+
return links;
|
|
222
|
+
}).replace(DOCUMENT_CHUNKSMAP_PLACEHOLDER, function() {
|
|
223
|
+
return PLACEHOLDER_REPLACER_MAP[DOCUMENT_CHUNKSMAP_PLACEHOLDER];
|
|
224
|
+
}).replace(DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, function() {
|
|
225
|
+
return PLACEHOLDER_REPLACER_MAP[DOCUMENT_SSRDATASCRIPT_PLACEHOLDER];
|
|
226
|
+
}).replace(DOCUMENT_TITLE_PLACEHOLDER, function() {
|
|
227
|
+
return titles;
|
|
228
|
+
});
|
|
209
229
|
return [
|
|
210
230
|
2,
|
|
211
231
|
finalHtml
|
|
@@ -14,7 +14,7 @@ import { useContext } from "react";
|
|
|
14
14
|
import { JSX_SHELL_STREAM_END_MARK } from "../../common";
|
|
15
15
|
import { RuntimeReactContext } from "../../core";
|
|
16
16
|
import { getGlobalEnableRsc, getGlobalLayoutApp, getGlobalRoutes } from "../../core/context";
|
|
17
|
-
import { setServerPayload } from "../../core/context/serverPayload.server";
|
|
17
|
+
import { setServerPayload } from "../../core/context/serverPayload/index.server";
|
|
18
18
|
import DeferredDataScripts from "./DeferredDataScripts.node";
|
|
19
19
|
import { modifyRoutes as modifyRoutesHook, onBeforeCreateRoutes as onBeforeCreateRoutesHook } from "./hooks";
|
|
20
20
|
import { RSCStaticRouter, createServerPayload, handleRSCRedirect, prepareRSCRoutes } from "./rsc-router";
|
|
@@ -87,6 +87,7 @@ function getRouteObjects(routes, param) {
|
|
|
87
87
|
for (var _iterator = routes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
88
88
|
var route = _step.value;
|
|
89
89
|
if (route.type === "nested") {
|
|
90
|
+
var _route_config;
|
|
90
91
|
var nestedRouteObject = {
|
|
91
92
|
path: route.path,
|
|
92
93
|
id: route.id,
|
|
@@ -94,7 +95,7 @@ function getRouteObjects(routes, param) {
|
|
|
94
95
|
action: route.action,
|
|
95
96
|
hasErrorBoundary: route.hasErrorBoundary,
|
|
96
97
|
shouldRevalidate: route.shouldRevalidate,
|
|
97
|
-
handle: route.handle,
|
|
98
|
+
handle: _object_spread({}, route.handle, _type_of(route.config) === "object" ? (_route_config = route.config) === null || _route_config === void 0 ? void 0 : _route_config.handle : {}),
|
|
98
99
|
index: route.index,
|
|
99
100
|
hasClientLoader: !!route.clientData,
|
|
100
101
|
Component: route.component ? route.component : void 0,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RuntimeReactContext, getInitialContext } from "./runtime";
|
|
2
2
|
const globalContext = {};
|
|
3
|
-
import { getServerPayload, setServerPayload } from "./serverPayload
|
|
3
|
+
import { getServerPayload, setServerPayload } from "./serverPayload/index";
|
|
4
4
|
function getGlobalIsRscClient() {
|
|
5
5
|
return globalContext.isRscClient;
|
|
6
6
|
}
|
|
@@ -4,7 +4,7 @@ import { getPathname, parseCookie, parseHeaders, parseQuery } from "@modern-js/r
|
|
|
4
4
|
import { Fragment } from "react";
|
|
5
5
|
import { getGlobalAppInit, getGlobalInternalRuntimeContext, getGlobalRSCRoot } from "../context";
|
|
6
6
|
import { getInitialContext } from "../context/runtime";
|
|
7
|
-
import { getServerPayload } from "../context/serverPayload
|
|
7
|
+
import { getServerPayload } from "../context/serverPayload/index";
|
|
8
8
|
import { createLoaderManager } from "../loader/loaderManager";
|
|
9
9
|
import { createRoot } from "../react";
|
|
10
10
|
import { CHUNK_CSS_PLACEHOLDER } from "./constants";
|
|
@@ -5,7 +5,7 @@ import React from "react";
|
|
|
5
5
|
import ReactDomServer from "react-dom/server";
|
|
6
6
|
import { DocumentContext } from "../DocumentContext";
|
|
7
7
|
import { BODY_PARTICALS_SEPARATOR, DOCUMENT_CHUNKSMAP_PLACEHOLDER, DOCUMENT_COMMENT_PLACEHOLDER_END, DOCUMENT_COMMENT_PLACEHOLDER_START, DOCUMENT_FILE_NAME, DOCUMENT_LINKS_PLACEHOLDER, DOCUMENT_META_PLACEHOLDER, DOCUMENT_SCRIPTS_PLACEHOLDER, DOCUMENT_SCRIPT_ATTRIBUTES_END, DOCUMENT_SCRIPT_ATTRIBUTES_START, DOCUMENT_SCRIPT_PLACEHOLDER_END, DOCUMENT_SCRIPT_PLACEHOLDER_START, DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, DOCUMENT_SSR_PLACEHOLDER, DOCUMENT_STYLE_PLACEHOLDER_END, DOCUMENT_STYLE_PLACEHOLDER_START, DOCUMENT_TITLE_PLACEHOLDER, DOC_EXT, HEAD_PARTICALS_SEPARATOR, HTML_SEPARATOR, PLACEHOLDER_REPLACER_MAP, TOP_PARTICALS_SEPARATOR } from "../constants";
|
|
8
|
-
const debug = createDebugger("
|
|
8
|
+
const debug = createDebugger("html_generate");
|
|
9
9
|
const getDocumenByEntryName = function(entrypoints, entryName, fallbackDir) {
|
|
10
10
|
var _entrypoints_find;
|
|
11
11
|
const entryDir = (_entrypoints_find = entrypoints.find((item) => item.entryName === entryName)) === null || _entrypoints_find === void 0 ? void 0 : _entrypoints_find.absoluteEntryDir;
|
|
@@ -124,7 +124,7 @@ const documentPlugin = () => ({
|
|
|
124
124
|
partialsContent.partialsHead = partialsByEntrypoint[entryName].head.join("\n");
|
|
125
125
|
partialsContent.partialsBody = partialsByEntrypoint[entryName].body.join("\n");
|
|
126
126
|
}
|
|
127
|
-
html = html.replace(TOP_PARTICALS_SEPARATOR, partialsContent.partialsTop).replace(HEAD_PARTICALS_SEPARATOR, partialsContent.partialsHead).replace(BODY_PARTICALS_SEPARATOR, partialsContent.partialsBody);
|
|
127
|
+
html = html.replace(TOP_PARTICALS_SEPARATOR, () => partialsContent.partialsTop).replace(HEAD_PARTICALS_SEPARATOR, () => partialsContent.partialsHead).replace(BODY_PARTICALS_SEPARATOR, () => partialsContent.partialsBody);
|
|
128
128
|
const links = [
|
|
129
129
|
htmlWebpackPlugin.tags.headTags.filter((item) => item.tagName === "link").join("")
|
|
130
130
|
].join("");
|
|
@@ -144,7 +144,7 @@ const documentPlugin = () => ({
|
|
|
144
144
|
if (html.includes(DOCUMENT_COMMENT_PLACEHOLDER_START) && html.includes(DOCUMENT_COMMENT_PLACEHOLDER_END)) {
|
|
145
145
|
html = html.replace(new RegExp(`${DOCUMENT_COMMENT_PLACEHOLDER_START}(.*?)${DOCUMENT_COMMENT_PLACEHOLDER_END}`, "g"), (_scriptStr, $1) => `${decodeURIComponent($1)}`);
|
|
146
146
|
}
|
|
147
|
-
const finalHtml = `<!DOCTYPE html>${html}`.replace(DOCUMENT_META_PLACEHOLDER, metas).replace(DOCUMENT_SSR_PLACEHOLDER, HTML_SEPARATOR).replace(DOCUMENT_SCRIPTS_PLACEHOLDER, scripts).replace(DOCUMENT_LINKS_PLACEHOLDER, links).replace(DOCUMENT_CHUNKSMAP_PLACEHOLDER, PLACEHOLDER_REPLACER_MAP[DOCUMENT_CHUNKSMAP_PLACEHOLDER]).replace(DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, PLACEHOLDER_REPLACER_MAP[DOCUMENT_SSRDATASCRIPT_PLACEHOLDER]).replace(DOCUMENT_TITLE_PLACEHOLDER, titles);
|
|
147
|
+
const finalHtml = `<!DOCTYPE html>${html}`.replace(DOCUMENT_META_PLACEHOLDER, () => metas).replace(DOCUMENT_SSR_PLACEHOLDER, () => HTML_SEPARATOR).replace(DOCUMENT_SCRIPTS_PLACEHOLDER, () => scripts).replace(DOCUMENT_LINKS_PLACEHOLDER, () => links).replace(DOCUMENT_CHUNKSMAP_PLACEHOLDER, () => PLACEHOLDER_REPLACER_MAP[DOCUMENT_CHUNKSMAP_PLACEHOLDER]).replace(DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, () => PLACEHOLDER_REPLACER_MAP[DOCUMENT_SSRDATASCRIPT_PLACEHOLDER]).replace(DOCUMENT_TITLE_PLACEHOLDER, () => titles);
|
|
148
148
|
return finalHtml;
|
|
149
149
|
};
|
|
150
150
|
};
|
|
@@ -10,7 +10,7 @@ import { useContext } from "react";
|
|
|
10
10
|
import { JSX_SHELL_STREAM_END_MARK } from "../../common";
|
|
11
11
|
import { RuntimeReactContext } from "../../core";
|
|
12
12
|
import { getGlobalEnableRsc, getGlobalLayoutApp, getGlobalRoutes } from "../../core/context";
|
|
13
|
-
import { setServerPayload } from "../../core/context/serverPayload.server";
|
|
13
|
+
import { setServerPayload } from "../../core/context/serverPayload/index.server";
|
|
14
14
|
import DeferredDataScripts from "./DeferredDataScripts.node";
|
|
15
15
|
import { modifyRoutes as modifyRoutesHook, onBeforeCreateRoutes as onBeforeCreateRoutesHook } from "./hooks";
|
|
16
16
|
import { RSCStaticRouter, createServerPayload, handleRSCRedirect, prepareRSCRoutes } from "./rsc-router";
|
|
@@ -60,6 +60,7 @@ function getRouteObjects(routes, { globalApp, ssrMode, props }) {
|
|
|
60
60
|
const routeObjects = [];
|
|
61
61
|
for (const route of routes) {
|
|
62
62
|
if (route.type === "nested") {
|
|
63
|
+
var _route_config;
|
|
63
64
|
const nestedRouteObject = {
|
|
64
65
|
path: route.path,
|
|
65
66
|
id: route.id,
|
|
@@ -67,7 +68,10 @@ function getRouteObjects(routes, { globalApp, ssrMode, props }) {
|
|
|
67
68
|
action: route.action,
|
|
68
69
|
hasErrorBoundary: route.hasErrorBoundary,
|
|
69
70
|
shouldRevalidate: route.shouldRevalidate,
|
|
70
|
-
handle:
|
|
71
|
+
handle: {
|
|
72
|
+
...route.handle,
|
|
73
|
+
...typeof route.config === "object" ? (_route_config = route.config) === null || _route_config === void 0 ? void 0 : _route_config.handle : {}
|
|
74
|
+
},
|
|
71
75
|
index: route.index,
|
|
72
76
|
hasClientLoader: !!route.clientData,
|
|
73
77
|
Component: route.component ? route.component : void 0,
|
|
@@ -1,37 +1,11 @@
|
|
|
1
1
|
import type { InternalRuntimeContext } from '@modern-js/plugin-v2';
|
|
2
|
-
import type { RouterState } from '@modern-js/runtime-utils/remix-router';
|
|
3
2
|
import type { NestedRoute, PageRoute } from '@modern-js/types';
|
|
4
3
|
import type React from 'react';
|
|
5
4
|
import type { AppConfig } from '../../common';
|
|
6
5
|
import type { RuntimeExtends } from '../plugin/types';
|
|
6
|
+
import type { ServerPayload } from './serverPayload/index';
|
|
7
7
|
export { type RuntimeContext, RuntimeReactContext, getInitialContext, } from './runtime';
|
|
8
|
-
export type PayloadRoute
|
|
9
|
-
clientAction?: any;
|
|
10
|
-
clientLoader?: any;
|
|
11
|
-
element?: React.ReactNode;
|
|
12
|
-
errorElement?: React.ReactNode;
|
|
13
|
-
handle?: any;
|
|
14
|
-
hasAction: boolean;
|
|
15
|
-
hasErrorBoundary: boolean;
|
|
16
|
-
hasLoader: boolean;
|
|
17
|
-
id: string;
|
|
18
|
-
index?: boolean;
|
|
19
|
-
params: Record<string, string>;
|
|
20
|
-
parentId?: string;
|
|
21
|
-
path?: string;
|
|
22
|
-
pathname: string;
|
|
23
|
-
pathnameBase: string;
|
|
24
|
-
shouldRevalidate?: any;
|
|
25
|
-
};
|
|
26
|
-
export type ServerPayload = {
|
|
27
|
-
type: 'render';
|
|
28
|
-
actionData: RouterState['actionData'];
|
|
29
|
-
errors: RouterState['errors'];
|
|
30
|
-
loaderData: RouterState['loaderData'];
|
|
31
|
-
location: RouterState['location'];
|
|
32
|
-
routes: PayloadRoute[];
|
|
33
|
-
originalRoutes?: PayloadRoute[];
|
|
34
|
-
};
|
|
8
|
+
export type { ServerPayload, PayloadRoute } from './serverPayload/index';
|
|
35
9
|
interface GlobalContext {
|
|
36
10
|
entryName?: string;
|
|
37
11
|
/**
|
|
@@ -63,7 +37,7 @@ interface GlobalContext {
|
|
|
63
37
|
serverPayload?: ServerPayload;
|
|
64
38
|
enableRsc?: boolean;
|
|
65
39
|
}
|
|
66
|
-
export { getServerPayload, setServerPayload } from './serverPayload
|
|
40
|
+
export { getServerPayload, setServerPayload, } from './serverPayload/index';
|
|
67
41
|
export declare function getGlobalIsRscClient(): boolean | undefined;
|
|
68
42
|
export declare function getGlobalEnableRsc(): boolean | undefined;
|
|
69
43
|
export declare function setGlobalContext(context: Omit<GlobalContext, 'appConfig' | 'internalRuntimeContext'> & {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type { ServerPayload } from './index';
|
|
1
|
+
import type { PayloadRoute, ServerPayload } from './index.server';
|
|
2
|
+
export type { ServerPayload, PayloadRoute };
|
|
2
3
|
export declare const getServerPayload: () => ServerPayload | undefined;
|
|
3
4
|
export declare const setServerPayload: (payload: ServerPayload) => void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { RouterState } from '@modern-js/runtime-utils/remix-router';
|
|
2
|
+
export type PayloadRoute = {
|
|
3
|
+
clientAction?: any;
|
|
4
|
+
clientLoader?: any;
|
|
5
|
+
element?: React.ReactNode;
|
|
6
|
+
errorElement?: React.ReactNode;
|
|
7
|
+
handle?: any;
|
|
8
|
+
hasAction: boolean;
|
|
9
|
+
hasErrorBoundary: boolean;
|
|
10
|
+
hasLoader: boolean;
|
|
11
|
+
id: string;
|
|
12
|
+
index?: boolean;
|
|
13
|
+
params: Record<string, string>;
|
|
14
|
+
parentId?: string;
|
|
15
|
+
path?: string;
|
|
16
|
+
pathname: string;
|
|
17
|
+
pathnameBase: string;
|
|
18
|
+
shouldRevalidate?: any;
|
|
19
|
+
};
|
|
20
|
+
export type ServerPayload = {
|
|
21
|
+
type: 'render';
|
|
22
|
+
actionData: RouterState['actionData'];
|
|
23
|
+
errors: RouterState['errors'];
|
|
24
|
+
loaderData: RouterState['loaderData'];
|
|
25
|
+
location: RouterState['location'];
|
|
26
|
+
routes: PayloadRoute[];
|
|
27
|
+
originalRoutes?: PayloadRoute[];
|
|
28
|
+
};
|
|
29
|
+
export declare const getServerPayload: () => ServerPayload | undefined;
|
|
30
|
+
export declare const setServerPayload: (payload: ServerPayload) => void;
|
|
@@ -21,7 +21,6 @@ export declare function getSSRConfigByEntry(entryName: string, ssr?: ServerUserC
|
|
|
21
21
|
inlineScript?: boolean;
|
|
22
22
|
disablePrerender?: boolean;
|
|
23
23
|
unsafeHeaders?: string[];
|
|
24
|
-
scriptLoading?: "defer" | "blocking" | "module" | "async";
|
|
25
24
|
loaderFailureMode?: "clientRender" | "errorBoundary";
|
|
26
25
|
};
|
|
27
26
|
export declare function getSSRMode(ssrConfig?: SSRConfig): 'string' | 'stream' | false;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.68.
|
|
18
|
+
"version": "2.68.7",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -219,13 +219,13 @@
|
|
|
219
219
|
"react-is": "^18",
|
|
220
220
|
"react-side-effect": "^2.1.2",
|
|
221
221
|
"styled-components": "^5.3.1",
|
|
222
|
-
"@modern-js/plugin": "2.68.
|
|
223
|
-
"@modern-js/plugin-data-loader": "2.68.
|
|
224
|
-
"@modern-js/plugin-v2": "2.68.
|
|
225
|
-
"@modern-js/
|
|
226
|
-
"@modern-js/
|
|
227
|
-
"@modern-js/types": "2.68.
|
|
228
|
-
"@modern-js/utils": "2.68.
|
|
222
|
+
"@modern-js/plugin": "2.68.7",
|
|
223
|
+
"@modern-js/plugin-data-loader": "2.68.7",
|
|
224
|
+
"@modern-js/plugin-v2": "2.68.7",
|
|
225
|
+
"@modern-js/runtime-utils": "2.68.7",
|
|
226
|
+
"@modern-js/render": "2.68.7",
|
|
227
|
+
"@modern-js/types": "2.68.7",
|
|
228
|
+
"@modern-js/utils": "2.68.7"
|
|
229
229
|
},
|
|
230
230
|
"peerDependencies": {
|
|
231
231
|
"react": ">=17",
|
|
@@ -233,7 +233,7 @@
|
|
|
233
233
|
},
|
|
234
234
|
"devDependencies": {
|
|
235
235
|
"@remix-run/web-fetch": "^4.1.3",
|
|
236
|
-
"@rsbuild/core": "1.4.
|
|
236
|
+
"@rsbuild/core": "1.4.14",
|
|
237
237
|
"@testing-library/react": "^13.4.0",
|
|
238
238
|
"@types/cookie": "0.6.0",
|
|
239
239
|
"@types/invariant": "^2.2.30",
|
|
@@ -248,11 +248,11 @@
|
|
|
248
248
|
"ts-jest": "^29.1.0",
|
|
249
249
|
"ts-node": "^10.9.1",
|
|
250
250
|
"typescript": "^5",
|
|
251
|
-
"webpack": "^5.
|
|
252
|
-
"@modern-js/app-tools": "2.68.5",
|
|
251
|
+
"webpack": "^5.101.0",
|
|
253
252
|
"@scripts/build": "2.66.0",
|
|
254
253
|
"@scripts/jest-config": "2.66.0",
|
|
255
|
-
"@modern-js/
|
|
254
|
+
"@modern-js/app-tools": "2.68.7",
|
|
255
|
+
"@modern-js/core": "2.68.7"
|
|
256
256
|
},
|
|
257
257
|
"sideEffects": false,
|
|
258
258
|
"publishConfig": {
|
|
File without changes
|
/package/dist/esm-node/core/context/{serverPayload.server.js → serverPayload/index.server.js}
RENAMED
|
File without changes
|