@modern-js/server-core 2.63.4 → 2.63.6
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/plugins/customServer/index.js +1 -0
- package/dist/cjs/plugins/render/index.js +3 -1
- package/dist/cjs/plugins/render/render.js +11 -5
- package/dist/esm/plugins/customServer/index.js +1 -0
- package/dist/esm/plugins/render/index.js +4 -2
- package/dist/esm/plugins/render/render.js +15 -6
- package/dist/esm-node/plugins/customServer/index.js +1 -0
- package/dist/esm-node/plugins/render/index.js +3 -1
- package/dist/esm-node/plugins/render/render.js +11 -5
- package/dist/types/types/render.d.ts +2 -0
- package/dist/types/types/server.d.ts +1 -0
- package/package.json +7 -7
|
@@ -92,6 +92,7 @@ function createRenderHandler(render) {
|
|
|
92
92
|
const locals = c.get("locals");
|
|
93
93
|
const metrics = c.get("metrics");
|
|
94
94
|
const matchPathname = c.get("matchPathname");
|
|
95
|
+
const matchEntryName = c.get("matchEntryName");
|
|
95
96
|
const loaderContext = (0, import_helper.getLoaderCtx)(c);
|
|
96
97
|
const request = c.req.raw;
|
|
97
98
|
const nodeReq = (_c_env_node = c.env.node) === null || _c_env_node === void 0 ? void 0 : _c_env_node.req;
|
|
@@ -105,7 +106,8 @@ function createRenderHandler(render) {
|
|
|
105
106
|
serverManifest,
|
|
106
107
|
loaderContext,
|
|
107
108
|
locals,
|
|
108
|
-
matchPathname
|
|
109
|
+
matchPathname,
|
|
110
|
+
matchEntryName
|
|
109
111
|
});
|
|
110
112
|
const { body, status, headers } = res;
|
|
111
113
|
const headersData = {};
|
|
@@ -61,10 +61,16 @@ function getRouter(routes) {
|
|
|
61
61
|
}
|
|
62
62
|
return router;
|
|
63
63
|
}
|
|
64
|
-
function matchRoute(router, pathname) {
|
|
64
|
+
function matchRoute(router, pathname, entryName) {
|
|
65
65
|
const matched = router.match("*", pathname);
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
if (entryName && matched[0].length > 1) {
|
|
67
|
+
const matches = matched[0];
|
|
68
|
+
const result = matches.find(([route]) => route.entryName === entryName);
|
|
69
|
+
return result || [];
|
|
70
|
+
} else {
|
|
71
|
+
const result = matched[0][0];
|
|
72
|
+
return result || [];
|
|
73
|
+
}
|
|
68
74
|
}
|
|
69
75
|
function getHeadersWithoutCookie(headers) {
|
|
70
76
|
const _headers = {
|
|
@@ -76,9 +82,9 @@ function getHeadersWithoutCookie(headers) {
|
|
|
76
82
|
}
|
|
77
83
|
async function createRender({ routes, pwd, metaName, staticGenerate, cacheConfig, forceCSR, config, onFallback: onFallbackFn }) {
|
|
78
84
|
const router = getRouter(routes);
|
|
79
|
-
return async (req, { logger, reporter, metrics, monitors, nodeReq, templates, serverManifest, locals, matchPathname, loaderContext }) => {
|
|
85
|
+
return async (req, { logger, reporter, metrics, monitors, nodeReq, templates, serverManifest, locals, matchEntryName, matchPathname, loaderContext }) => {
|
|
80
86
|
const forMatchpathname = matchPathname !== null && matchPathname !== void 0 ? matchPathname : (0, import_utils2.getPathname)(req);
|
|
81
|
-
const [routeInfo, params] = matchRoute(router, forMatchpathname);
|
|
87
|
+
const [routeInfo, params] = matchRoute(router, forMatchpathname, matchEntryName);
|
|
82
88
|
const framework = metaName || "modern-js";
|
|
83
89
|
const fallbackHeader = `x-${(0, import_universal.cutNameByHyphen)(framework)}-ssr-fallback`;
|
|
84
90
|
let fallbackReason = null;
|
|
@@ -133,7 +133,7 @@ function getPageRoutes(routes) {
|
|
|
133
133
|
function createRenderHandler(render) {
|
|
134
134
|
return function() {
|
|
135
135
|
var _ref = _async_to_generator(function(c, _) {
|
|
136
|
-
var _c_env_node, logger, reporter, monitors, templates, serverManifest, locals, metrics, matchPathname, loaderContext, request, nodeReq, res, body, status, headers, headersData;
|
|
136
|
+
var _c_env_node, logger, reporter, monitors, templates, serverManifest, locals, metrics, matchPathname, matchEntryName, loaderContext, request, nodeReq, res, body, status, headers, headersData;
|
|
137
137
|
return _ts_generator(this, function(_state) {
|
|
138
138
|
switch (_state.label) {
|
|
139
139
|
case 0:
|
|
@@ -145,6 +145,7 @@ function createRenderHandler(render) {
|
|
|
145
145
|
locals = c.get("locals");
|
|
146
146
|
metrics = c.get("metrics");
|
|
147
147
|
matchPathname = c.get("matchPathname");
|
|
148
|
+
matchEntryName = c.get("matchEntryName");
|
|
148
149
|
loaderContext = getLoaderCtx(c);
|
|
149
150
|
request = c.req.raw;
|
|
150
151
|
nodeReq = (_c_env_node = c.env.node) === null || _c_env_node === void 0 ? void 0 : _c_env_node.req;
|
|
@@ -160,7 +161,8 @@ function createRenderHandler(render) {
|
|
|
160
161
|
serverManifest,
|
|
161
162
|
loaderContext,
|
|
162
163
|
locals,
|
|
163
|
-
matchPathname
|
|
164
|
+
matchPathname,
|
|
165
|
+
matchEntryName
|
|
164
166
|
})
|
|
165
167
|
];
|
|
166
168
|
case 1:
|
|
@@ -50,10 +50,19 @@ function getRouter(routes) {
|
|
|
50
50
|
}
|
|
51
51
|
return router;
|
|
52
52
|
}
|
|
53
|
-
function matchRoute(router, pathname) {
|
|
53
|
+
function matchRoute(router, pathname, entryName) {
|
|
54
54
|
var matched = router.match("*", pathname);
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
if (entryName && matched[0].length > 1) {
|
|
56
|
+
var matches = matched[0];
|
|
57
|
+
var result = matches.find(function(param) {
|
|
58
|
+
var _param = _sliced_to_array(param, 1), route = _param[0];
|
|
59
|
+
return route.entryName === entryName;
|
|
60
|
+
});
|
|
61
|
+
return result || [];
|
|
62
|
+
} else {
|
|
63
|
+
var result1 = matched[0][0];
|
|
64
|
+
return result1 || [];
|
|
65
|
+
}
|
|
57
66
|
}
|
|
58
67
|
function getHeadersWithoutCookie(headers) {
|
|
59
68
|
var _headers = _object_spread_props(_object_spread({}, headers), {
|
|
@@ -75,13 +84,13 @@ function _createRender() {
|
|
|
75
84
|
2,
|
|
76
85
|
function() {
|
|
77
86
|
var _ref = _async_to_generator(function(req, param2) {
|
|
78
|
-
var logger, reporter, metrics, monitors, nodeReq, templates, serverManifest, locals, matchPathname, loaderContext, forMatchpathname, _matchRoute, routeInfo, params, framework, fallbackHeader, fallbackReason, onFallback, html, renderMode, headerData, onError, onTiming, onBoundError, renderOptions, response, _tmp;
|
|
87
|
+
var logger, reporter, metrics, monitors, nodeReq, templates, serverManifest, locals, matchEntryName, matchPathname, loaderContext, forMatchpathname, _matchRoute, routeInfo, params, framework, fallbackHeader, fallbackReason, onFallback, html, renderMode, headerData, onError, onTiming, onBoundError, renderOptions, response, _tmp;
|
|
79
88
|
return _ts_generator(this, function(_state2) {
|
|
80
89
|
switch (_state2.label) {
|
|
81
90
|
case 0:
|
|
82
|
-
logger = param2.logger, reporter = param2.reporter, metrics = param2.metrics, monitors = param2.monitors, nodeReq = param2.nodeReq, templates = param2.templates, serverManifest = param2.serverManifest, locals = param2.locals, matchPathname = param2.matchPathname, loaderContext = param2.loaderContext;
|
|
91
|
+
logger = param2.logger, reporter = param2.reporter, metrics = param2.metrics, monitors = param2.monitors, nodeReq = param2.nodeReq, templates = param2.templates, serverManifest = param2.serverManifest, locals = param2.locals, matchEntryName = param2.matchEntryName, matchPathname = param2.matchPathname, loaderContext = param2.loaderContext;
|
|
83
92
|
forMatchpathname = matchPathname !== null && matchPathname !== void 0 ? matchPathname : getPathname(req);
|
|
84
|
-
_matchRoute = _sliced_to_array(matchRoute(router, forMatchpathname), 2), routeInfo = _matchRoute[0], params = _matchRoute[1];
|
|
93
|
+
_matchRoute = _sliced_to_array(matchRoute(router, forMatchpathname, matchEntryName), 2), routeInfo = _matchRoute[0], params = _matchRoute[1];
|
|
85
94
|
framework = metaName || "modern-js";
|
|
86
95
|
fallbackHeader = "x-".concat(cutNameByHyphen(framework), "-ssr-fallback");
|
|
87
96
|
fallbackReason = null;
|
|
@@ -68,6 +68,7 @@ function createRenderHandler(render) {
|
|
|
68
68
|
const locals = c.get("locals");
|
|
69
69
|
const metrics = c.get("metrics");
|
|
70
70
|
const matchPathname = c.get("matchPathname");
|
|
71
|
+
const matchEntryName = c.get("matchEntryName");
|
|
71
72
|
const loaderContext = getLoaderCtx(c);
|
|
72
73
|
const request = c.req.raw;
|
|
73
74
|
const nodeReq = (_c_env_node = c.env.node) === null || _c_env_node === void 0 ? void 0 : _c_env_node.req;
|
|
@@ -81,7 +82,8 @@ function createRenderHandler(render) {
|
|
|
81
82
|
serverManifest,
|
|
82
83
|
loaderContext,
|
|
83
84
|
locals,
|
|
84
|
-
matchPathname
|
|
85
|
+
matchPathname,
|
|
86
|
+
matchEntryName
|
|
85
87
|
});
|
|
86
88
|
const { body, status, headers } = res;
|
|
87
89
|
const headersData = {};
|
|
@@ -28,10 +28,16 @@ function getRouter(routes) {
|
|
|
28
28
|
}
|
|
29
29
|
return router;
|
|
30
30
|
}
|
|
31
|
-
function matchRoute(router, pathname) {
|
|
31
|
+
function matchRoute(router, pathname, entryName) {
|
|
32
32
|
const matched = router.match("*", pathname);
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
if (entryName && matched[0].length > 1) {
|
|
34
|
+
const matches = matched[0];
|
|
35
|
+
const result = matches.find(([route]) => route.entryName === entryName);
|
|
36
|
+
return result || [];
|
|
37
|
+
} else {
|
|
38
|
+
const result = matched[0][0];
|
|
39
|
+
return result || [];
|
|
40
|
+
}
|
|
35
41
|
}
|
|
36
42
|
function getHeadersWithoutCookie(headers) {
|
|
37
43
|
const _headers = {
|
|
@@ -43,9 +49,9 @@ function getHeadersWithoutCookie(headers) {
|
|
|
43
49
|
}
|
|
44
50
|
async function createRender({ routes, pwd, metaName, staticGenerate, cacheConfig, forceCSR, config, onFallback: onFallbackFn }) {
|
|
45
51
|
const router = getRouter(routes);
|
|
46
|
-
return async (req, { logger, reporter, metrics, monitors, nodeReq, templates, serverManifest, locals, matchPathname, loaderContext }) => {
|
|
52
|
+
return async (req, { logger, reporter, metrics, monitors, nodeReq, templates, serverManifest, locals, matchEntryName, matchPathname, loaderContext }) => {
|
|
47
53
|
const forMatchpathname = matchPathname !== null && matchPathname !== void 0 ? matchPathname : getPathname(req);
|
|
48
|
-
const [routeInfo, params] = matchRoute(router, forMatchpathname);
|
|
54
|
+
const [routeInfo, params] = matchRoute(router, forMatchpathname, matchEntryName);
|
|
49
55
|
const framework = metaName || "modern-js";
|
|
50
56
|
const fallbackHeader = `x-${cutNameByHyphen(framework)}-ssr-fallback`;
|
|
51
57
|
let fallbackReason = null;
|
|
@@ -16,6 +16,8 @@ export interface RenderOptions {
|
|
|
16
16
|
reporter?: Reporter;
|
|
17
17
|
/** For compat rewrite MPA, while not modify request */
|
|
18
18
|
matchPathname?: string;
|
|
19
|
+
/** For compat rewrite MPA, while not modify request */
|
|
20
|
+
matchEntryName?: string;
|
|
19
21
|
monitors?: Monitors;
|
|
20
22
|
serverManifest: ServerManifest;
|
|
21
23
|
nodeReq?: IncomingMessage;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.63.
|
|
18
|
+
"version": "2.63.6",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"flatted": "^3.2.9",
|
|
54
54
|
"hono": "^3.12.2",
|
|
55
55
|
"ts-deepmerge": "7.0.2",
|
|
56
|
-
"@modern-js/plugin": "2.63.
|
|
57
|
-
"@modern-js/runtime-utils": "2.63.
|
|
58
|
-
"@modern-js/utils": "2.63.
|
|
56
|
+
"@modern-js/plugin": "2.63.6",
|
|
57
|
+
"@modern-js/runtime-utils": "2.63.6",
|
|
58
|
+
"@modern-js/utils": "2.63.6"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/jest": "^29",
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"jest": "^29",
|
|
66
66
|
"ts-jest": "^29.1.0",
|
|
67
67
|
"typescript": "^5",
|
|
68
|
-
"@modern-js/types": "2.63.
|
|
69
|
-
"@scripts/build": "2.63.
|
|
70
|
-
"@scripts/jest-config": "2.63.
|
|
68
|
+
"@modern-js/types": "2.63.6",
|
|
69
|
+
"@scripts/build": "2.63.6",
|
|
70
|
+
"@scripts/jest-config": "2.63.6"
|
|
71
71
|
},
|
|
72
72
|
"sideEffects": false,
|
|
73
73
|
"publishConfig": {
|