@modern-js/server-core 3.9.1 → 3.9.2
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/adapters/node/plugins/static.js +1 -1
- package/dist/cjs/helper.js +1 -1
- package/dist/cjs/plugins/render/render.js +3 -4
- package/dist/cjs/plugins/render/ssrCache.js +14 -15
- package/dist/cjs/serverBase.js +2 -2
- package/dist/cjs/utils/transformStream.js +1 -1
- package/dist/esm/adapters/node/plugins/static.mjs +1 -1
- package/dist/esm/helper.mjs +1 -1
- package/dist/esm/plugins/render/render.mjs +3 -4
- package/dist/esm/plugins/render/ssrCache.mjs +14 -15
- package/dist/esm/serverBase.mjs +2 -2
- package/dist/esm/utils/transformStream.mjs +1 -1
- package/dist/esm-node/adapters/node/plugins/static.mjs +1 -1
- package/dist/esm-node/helper.mjs +1 -1
- package/dist/esm-node/plugins/render/render.mjs +3 -4
- package/dist/esm-node/plugins/render/ssrCache.mjs +14 -15
- package/dist/esm-node/serverBase.mjs +2 -2
- package/dist/esm-node/utils/transformStream.mjs +1 -1
- package/package.json +5 -5
|
@@ -143,7 +143,7 @@ function createStaticMiddleware(options) {
|
|
|
143
143
|
pwd,
|
|
144
144
|
routes: routes || []
|
|
145
145
|
})(c, next);
|
|
146
|
-
{
|
|
146
|
+
else {
|
|
147
147
|
const filepath = external_path_default().join(pwd, pathname.replace(pathPrefix, ()=>''));
|
|
148
148
|
if (!isPathInside(filepath, pwd)) return next();
|
|
149
149
|
if (!await utils_namespaceObject.fs.pathExists(filepath)) return next();
|
package/dist/cjs/helper.js
CHANGED
|
@@ -31,7 +31,7 @@ const LOADER_CONTEXT = 'loaderContext';
|
|
|
31
31
|
function getLoaderCtx(c) {
|
|
32
32
|
const loaderContext = c.get(LOADER_CONTEXT);
|
|
33
33
|
if (loaderContext) return loaderContext;
|
|
34
|
-
{
|
|
34
|
+
else {
|
|
35
35
|
const loaderContext = new Map();
|
|
36
36
|
c.set(LOADER_CONTEXT, loaderContext);
|
|
37
37
|
return loaderContext;
|
|
@@ -87,8 +87,7 @@ var __webpack_exports__ = {};
|
|
|
87
87
|
void 0,
|
|
88
88
|
{}
|
|
89
89
|
];
|
|
90
|
-
}
|
|
91
|
-
{
|
|
90
|
+
} else {
|
|
92
91
|
const result = matchedRoutes[0];
|
|
93
92
|
if (!result) return [
|
|
94
93
|
void 0,
|
|
@@ -242,7 +241,7 @@ var __webpack_exports__ = {};
|
|
|
242
241
|
if (req.headers.get('x-rsc-action')) return 'rsc-action';
|
|
243
242
|
if (req.headers.get('x-rsc-tree')) return 'rsc-tree';
|
|
244
243
|
if (!isSSR) return 'csr';
|
|
245
|
-
{
|
|
244
|
+
else {
|
|
246
245
|
if (query.__loader) return 'data';
|
|
247
246
|
const fallbackHeaderValue = req.headers.get(fallbackHeader) || nodeReq?.headers[fallbackHeader];
|
|
248
247
|
if (forceCSR && (query.csr || fallbackHeaderValue || contextForceCSR)) {
|
|
@@ -271,7 +270,7 @@ var __webpack_exports__ = {};
|
|
|
271
270
|
[external_constants_js_namespaceObject.X_MODERNJS_RENDER]: 'client'
|
|
272
271
|
})
|
|
273
272
|
});
|
|
274
|
-
return (0, external_csrRscRender_js_namespaceObject.csrRscRender)(request, options);
|
|
273
|
+
else return (0, external_csrRscRender_js_namespaceObject.csrRscRender)(request, options);
|
|
275
274
|
}
|
|
276
275
|
})();
|
|
277
276
|
exports.createRender = __webpack_exports__.createRender;
|
|
@@ -98,8 +98,8 @@ function computedKey(req, cacheControl) {
|
|
|
98
98
|
const { customKey } = cacheControl;
|
|
99
99
|
const defaultKey = '/' === pathname ? pathname : removeTailSlash(pathname);
|
|
100
100
|
if (!customKey) return defaultKey;
|
|
101
|
-
if ('string' == typeof customKey) return customKey;
|
|
102
|
-
return customKey(defaultKey);
|
|
101
|
+
else if ('string' == typeof customKey) return customKey;
|
|
102
|
+
else return customKey(defaultKey);
|
|
103
103
|
}
|
|
104
104
|
function shouldUseCache(request) {
|
|
105
105
|
const url = new URL(request.url);
|
|
@@ -110,7 +110,7 @@ function shouldUseCache(request) {
|
|
|
110
110
|
}
|
|
111
111
|
function matchCacheControl(cacheOption, req) {
|
|
112
112
|
if (!cacheOption || !req) return;
|
|
113
|
-
{
|
|
113
|
+
else {
|
|
114
114
|
if (isCacheControl(cacheOption)) return cacheOption;
|
|
115
115
|
if (isCacheOptionProvider(cacheOption)) return cacheOption(req);
|
|
116
116
|
const url = req.url;
|
|
@@ -149,7 +149,7 @@ async function getCacheResult(request, options) {
|
|
|
149
149
|
container,
|
|
150
150
|
cacheStatus: 'miss'
|
|
151
151
|
});
|
|
152
|
-
{
|
|
152
|
+
else {
|
|
153
153
|
const cache = JSON.parse(value);
|
|
154
154
|
const interval = Date.now() - cache.cursor;
|
|
155
155
|
if (interval <= maxAge) {
|
|
@@ -159,17 +159,16 @@ async function getCacheResult(request, options) {
|
|
|
159
159
|
[external_constants_js_namespaceObject.X_RENDER_CACHE]: cacheStatus
|
|
160
160
|
}
|
|
161
161
|
});
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
{
|
|
162
|
+
} else {
|
|
163
|
+
if (!(interval <= staleWhileRevalidate + maxAge)) return processCache({
|
|
164
|
+
key,
|
|
165
|
+
request,
|
|
166
|
+
requestHandler,
|
|
167
|
+
requestHandlerOptions,
|
|
168
|
+
ttl,
|
|
169
|
+
container,
|
|
170
|
+
cacheStatus: 'expired'
|
|
171
|
+
});
|
|
173
172
|
processCache({
|
|
174
173
|
key,
|
|
175
174
|
request,
|
package/dist/cjs/serverBase.js
CHANGED
|
@@ -138,7 +138,7 @@ function applyMiddlewares() {
|
|
|
138
138
|
if (middleware.before) {
|
|
139
139
|
const targetIndex = finalMiddlewares.findIndex((item)=>{
|
|
140
140
|
if (middleware.before?.includes(item.name)) return true;
|
|
141
|
-
return false;
|
|
141
|
+
else return false;
|
|
142
142
|
});
|
|
143
143
|
if (-1 !== targetIndex) finalMiddlewares.splice(targetIndex, 0, middleware);
|
|
144
144
|
else finalMiddlewares.push(middleware);
|
|
@@ -159,7 +159,7 @@ function applyMiddlewares() {
|
|
|
159
159
|
}
|
|
160
160
|
function handler2Handlers(handler) {
|
|
161
161
|
if (Array.isArray(handler)) return handler;
|
|
162
|
-
return [
|
|
162
|
+
else return [
|
|
163
163
|
handler
|
|
164
164
|
];
|
|
165
165
|
}
|
|
@@ -43,7 +43,7 @@ function transformResponse(response, transformCb) {
|
|
|
43
43
|
if (response.body) {
|
|
44
44
|
const stream = createTransformStream(async (before)=>{
|
|
45
45
|
if (Array.isArray(transformCb)) return transformCb.reduce(async (before, cb)=>cb(await before), Promise.resolve(before));
|
|
46
|
-
return transformCb(before);
|
|
46
|
+
else return transformCb(before);
|
|
47
47
|
});
|
|
48
48
|
response.body.pipeThrough(stream);
|
|
49
49
|
readable = stream.readable;
|
|
@@ -99,7 +99,7 @@ function createStaticMiddleware(options) {
|
|
|
99
99
|
pwd,
|
|
100
100
|
routes: routes || []
|
|
101
101
|
})(c, next);
|
|
102
|
-
{
|
|
102
|
+
else {
|
|
103
103
|
const filepath = path.join(pwd, pathname.replace(pathPrefix, ()=>''));
|
|
104
104
|
if (!isPathInside(filepath, pwd)) return next();
|
|
105
105
|
if (!await fs.pathExists(filepath)) return next();
|
package/dist/esm/helper.mjs
CHANGED
|
@@ -2,7 +2,7 @@ const LOADER_CONTEXT = 'loaderContext';
|
|
|
2
2
|
function getLoaderCtx(c) {
|
|
3
3
|
const loaderContext = c.get(LOADER_CONTEXT);
|
|
4
4
|
if (loaderContext) return loaderContext;
|
|
5
|
-
{
|
|
5
|
+
else {
|
|
6
6
|
const loaderContext = new Map();
|
|
7
7
|
c.set(LOADER_CONTEXT, loaderContext);
|
|
8
8
|
return loaderContext;
|
|
@@ -45,8 +45,7 @@ function matchRoute(router, pathname, entryName) {
|
|
|
45
45
|
void 0,
|
|
46
46
|
{}
|
|
47
47
|
];
|
|
48
|
-
}
|
|
49
|
-
{
|
|
48
|
+
} else {
|
|
50
49
|
const result = matchedRoutes[0];
|
|
51
50
|
if (!result) return [
|
|
52
51
|
void 0,
|
|
@@ -200,7 +199,7 @@ async function getRenderMode(req, fallbackHeader, isSSR, forceCSR, nodeReq, onFa
|
|
|
200
199
|
if (req.headers.get('x-rsc-action')) return 'rsc-action';
|
|
201
200
|
if (req.headers.get('x-rsc-tree')) return 'rsc-tree';
|
|
202
201
|
if (!isSSR) return 'csr';
|
|
203
|
-
{
|
|
202
|
+
else {
|
|
204
203
|
if (query.__loader) return 'data';
|
|
205
204
|
const fallbackHeaderValue = req.headers.get(fallbackHeader) || nodeReq?.headers[fallbackHeader];
|
|
206
205
|
if (forceCSR && (query.csr || fallbackHeaderValue || contextForceCSR)) {
|
|
@@ -229,6 +228,6 @@ async function csrRender(request, options) {
|
|
|
229
228
|
[X_MODERNJS_RENDER]: 'client'
|
|
230
229
|
})
|
|
231
230
|
});
|
|
232
|
-
return csrRscRender(request, options);
|
|
231
|
+
else return csrRscRender(request, options);
|
|
233
232
|
}
|
|
234
233
|
export { createRender, matchRoute };
|
|
@@ -64,8 +64,8 @@ function computedKey(req, cacheControl) {
|
|
|
64
64
|
const { customKey } = cacheControl;
|
|
65
65
|
const defaultKey = '/' === pathname ? pathname : removeTailSlash(pathname);
|
|
66
66
|
if (!customKey) return defaultKey;
|
|
67
|
-
if ('string' == typeof customKey) return customKey;
|
|
68
|
-
return customKey(defaultKey);
|
|
67
|
+
else if ('string' == typeof customKey) return customKey;
|
|
68
|
+
else return customKey(defaultKey);
|
|
69
69
|
}
|
|
70
70
|
function shouldUseCache(request) {
|
|
71
71
|
const url = new URL(request.url);
|
|
@@ -76,7 +76,7 @@ function shouldUseCache(request) {
|
|
|
76
76
|
}
|
|
77
77
|
function matchCacheControl(cacheOption, req) {
|
|
78
78
|
if (!cacheOption || !req) return;
|
|
79
|
-
{
|
|
79
|
+
else {
|
|
80
80
|
if (isCacheControl(cacheOption)) return cacheOption;
|
|
81
81
|
if (isCacheOptionProvider(cacheOption)) return cacheOption(req);
|
|
82
82
|
const url = req.url;
|
|
@@ -115,7 +115,7 @@ async function getCacheResult(request, options) {
|
|
|
115
115
|
container,
|
|
116
116
|
cacheStatus: 'miss'
|
|
117
117
|
});
|
|
118
|
-
{
|
|
118
|
+
else {
|
|
119
119
|
const cache = JSON.parse(value);
|
|
120
120
|
const interval = Date.now() - cache.cursor;
|
|
121
121
|
if (interval <= maxAge) {
|
|
@@ -125,17 +125,16 @@ async function getCacheResult(request, options) {
|
|
|
125
125
|
[X_RENDER_CACHE]: cacheStatus
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
{
|
|
128
|
+
} else {
|
|
129
|
+
if (!(interval <= staleWhileRevalidate + maxAge)) return processCache({
|
|
130
|
+
key,
|
|
131
|
+
request,
|
|
132
|
+
requestHandler,
|
|
133
|
+
requestHandlerOptions,
|
|
134
|
+
ttl,
|
|
135
|
+
container,
|
|
136
|
+
cacheStatus: 'expired'
|
|
137
|
+
});
|
|
139
138
|
processCache({
|
|
140
139
|
key,
|
|
141
140
|
request,
|
package/dist/esm/serverBase.mjs
CHANGED
|
@@ -105,7 +105,7 @@ function applyMiddlewares() {
|
|
|
105
105
|
if (middleware.before) {
|
|
106
106
|
const targetIndex = finalMiddlewares.findIndex((item)=>{
|
|
107
107
|
if (middleware.before?.includes(item.name)) return true;
|
|
108
|
-
return false;
|
|
108
|
+
else return false;
|
|
109
109
|
});
|
|
110
110
|
if (-1 !== targetIndex) finalMiddlewares.splice(targetIndex, 0, middleware);
|
|
111
111
|
else finalMiddlewares.push(middleware);
|
|
@@ -126,7 +126,7 @@ function applyMiddlewares() {
|
|
|
126
126
|
}
|
|
127
127
|
function handler2Handlers(handler) {
|
|
128
128
|
if (Array.isArray(handler)) return handler;
|
|
129
|
-
return [
|
|
129
|
+
else return [
|
|
130
130
|
handler
|
|
131
131
|
];
|
|
132
132
|
}
|
|
@@ -14,7 +14,7 @@ function transformResponse(response, transformCb) {
|
|
|
14
14
|
if (response.body) {
|
|
15
15
|
const stream = createTransformStream(async (before)=>{
|
|
16
16
|
if (Array.isArray(transformCb)) return transformCb.reduce(async (before, cb)=>cb(await before), Promise.resolve(before));
|
|
17
|
-
return transformCb(before);
|
|
17
|
+
else return transformCb(before);
|
|
18
18
|
});
|
|
19
19
|
response.body.pipeThrough(stream);
|
|
20
20
|
readable = stream.readable;
|
|
@@ -100,7 +100,7 @@ function createStaticMiddleware(options) {
|
|
|
100
100
|
pwd,
|
|
101
101
|
routes: routes || []
|
|
102
102
|
})(c, next);
|
|
103
|
-
{
|
|
103
|
+
else {
|
|
104
104
|
const filepath = path.join(pwd, pathname.replace(pathPrefix, ()=>''));
|
|
105
105
|
if (!isPathInside(filepath, pwd)) return next();
|
|
106
106
|
if (!await fs.pathExists(filepath)) return next();
|
package/dist/esm-node/helper.mjs
CHANGED
|
@@ -3,7 +3,7 @@ const LOADER_CONTEXT = 'loaderContext';
|
|
|
3
3
|
function getLoaderCtx(c) {
|
|
4
4
|
const loaderContext = c.get(LOADER_CONTEXT);
|
|
5
5
|
if (loaderContext) return loaderContext;
|
|
6
|
-
{
|
|
6
|
+
else {
|
|
7
7
|
const loaderContext = new Map();
|
|
8
8
|
c.set(LOADER_CONTEXT, loaderContext);
|
|
9
9
|
return loaderContext;
|
|
@@ -48,8 +48,7 @@ function matchRoute(router, pathname, entryName) {
|
|
|
48
48
|
void 0,
|
|
49
49
|
{}
|
|
50
50
|
];
|
|
51
|
-
}
|
|
52
|
-
{
|
|
51
|
+
} else {
|
|
53
52
|
const result = matchedRoutes[0];
|
|
54
53
|
if (!result) return [
|
|
55
54
|
void 0,
|
|
@@ -203,7 +202,7 @@ async function getRenderMode(req, fallbackHeader, isSSR, forceCSR, nodeReq, onFa
|
|
|
203
202
|
if (req.headers.get('x-rsc-action')) return 'rsc-action';
|
|
204
203
|
if (req.headers.get('x-rsc-tree')) return 'rsc-tree';
|
|
205
204
|
if (!isSSR) return 'csr';
|
|
206
|
-
{
|
|
205
|
+
else {
|
|
207
206
|
if (query.__loader) return 'data';
|
|
208
207
|
const fallbackHeaderValue = req.headers.get(fallbackHeader) || nodeReq?.headers[fallbackHeader];
|
|
209
208
|
if (forceCSR && (query.csr || fallbackHeaderValue || contextForceCSR)) {
|
|
@@ -232,6 +231,6 @@ async function csrRender(request, options) {
|
|
|
232
231
|
[X_MODERNJS_RENDER]: 'client'
|
|
233
232
|
})
|
|
234
233
|
});
|
|
235
|
-
return csrRscRender(request, options);
|
|
234
|
+
else return csrRscRender(request, options);
|
|
236
235
|
}
|
|
237
236
|
export { createRender, matchRoute };
|
|
@@ -65,8 +65,8 @@ function computedKey(req, cacheControl) {
|
|
|
65
65
|
const { customKey } = cacheControl;
|
|
66
66
|
const defaultKey = '/' === pathname ? pathname : removeTailSlash(pathname);
|
|
67
67
|
if (!customKey) return defaultKey;
|
|
68
|
-
if ('string' == typeof customKey) return customKey;
|
|
69
|
-
return customKey(defaultKey);
|
|
68
|
+
else if ('string' == typeof customKey) return customKey;
|
|
69
|
+
else return customKey(defaultKey);
|
|
70
70
|
}
|
|
71
71
|
function shouldUseCache(request) {
|
|
72
72
|
const url = new URL(request.url);
|
|
@@ -77,7 +77,7 @@ function shouldUseCache(request) {
|
|
|
77
77
|
}
|
|
78
78
|
function matchCacheControl(cacheOption, req) {
|
|
79
79
|
if (!cacheOption || !req) return;
|
|
80
|
-
{
|
|
80
|
+
else {
|
|
81
81
|
if (isCacheControl(cacheOption)) return cacheOption;
|
|
82
82
|
if (isCacheOptionProvider(cacheOption)) return cacheOption(req);
|
|
83
83
|
const url = req.url;
|
|
@@ -116,7 +116,7 @@ async function getCacheResult(request, options) {
|
|
|
116
116
|
container,
|
|
117
117
|
cacheStatus: 'miss'
|
|
118
118
|
});
|
|
119
|
-
{
|
|
119
|
+
else {
|
|
120
120
|
const cache = JSON.parse(value);
|
|
121
121
|
const interval = Date.now() - cache.cursor;
|
|
122
122
|
if (interval <= maxAge) {
|
|
@@ -126,17 +126,16 @@ async function getCacheResult(request, options) {
|
|
|
126
126
|
[X_RENDER_CACHE]: cacheStatus
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
{
|
|
129
|
+
} else {
|
|
130
|
+
if (!(interval <= staleWhileRevalidate + maxAge)) return processCache({
|
|
131
|
+
key,
|
|
132
|
+
request,
|
|
133
|
+
requestHandler,
|
|
134
|
+
requestHandlerOptions,
|
|
135
|
+
ttl,
|
|
136
|
+
container,
|
|
137
|
+
cacheStatus: 'expired'
|
|
138
|
+
});
|
|
140
139
|
processCache({
|
|
141
140
|
key,
|
|
142
141
|
request,
|
|
@@ -106,7 +106,7 @@ function applyMiddlewares() {
|
|
|
106
106
|
if (middleware.before) {
|
|
107
107
|
const targetIndex = finalMiddlewares.findIndex((item)=>{
|
|
108
108
|
if (middleware.before?.includes(item.name)) return true;
|
|
109
|
-
return false;
|
|
109
|
+
else return false;
|
|
110
110
|
});
|
|
111
111
|
if (-1 !== targetIndex) finalMiddlewares.splice(targetIndex, 0, middleware);
|
|
112
112
|
else finalMiddlewares.push(middleware);
|
|
@@ -127,7 +127,7 @@ function applyMiddlewares() {
|
|
|
127
127
|
}
|
|
128
128
|
function handler2Handlers(handler) {
|
|
129
129
|
if (Array.isArray(handler)) return handler;
|
|
130
|
-
return [
|
|
130
|
+
else return [
|
|
131
131
|
handler
|
|
132
132
|
];
|
|
133
133
|
}
|
|
@@ -15,7 +15,7 @@ function transformResponse(response, transformCb) {
|
|
|
15
15
|
if (response.body) {
|
|
16
16
|
const stream = createTransformStream(async (before)=>{
|
|
17
17
|
if (Array.isArray(transformCb)) return transformCb.reduce(async (before, cb)=>cb(await before), Promise.resolve(before));
|
|
18
|
-
return transformCb(before);
|
|
18
|
+
else return transformCb(before);
|
|
19
19
|
});
|
|
20
20
|
response.body.pipeThrough(stream);
|
|
21
21
|
readable = stream.readable;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.9.
|
|
18
|
+
"version": "3.9.2",
|
|
19
19
|
"types": "./dist/types/index.d.ts",
|
|
20
20
|
"main": "./dist/cjs/index.js",
|
|
21
21
|
"exports": {
|
|
@@ -71,9 +71,9 @@
|
|
|
71
71
|
"flatted": "^3.4.4",
|
|
72
72
|
"hono": "^4.11.7",
|
|
73
73
|
"ts-deepmerge": "7.0.3",
|
|
74
|
-
"@modern-js/plugin": "3.9.
|
|
75
|
-
"@modern-js/runtime-utils": "3.9.
|
|
76
|
-
"@modern-js/utils": "3.9.
|
|
74
|
+
"@modern-js/plugin": "3.9.2",
|
|
75
|
+
"@modern-js/runtime-utils": "3.9.2",
|
|
76
|
+
"@modern-js/utils": "3.9.2"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@rslib/core": "1.0.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"http-proxy-middleware": "^2.0.10",
|
|
84
84
|
"typescript": "^5",
|
|
85
85
|
"@modern-js/rslib": "2.68.10",
|
|
86
|
-
"@modern-js/types": "3.9.
|
|
86
|
+
"@modern-js/types": "3.9.2",
|
|
87
87
|
"@scripts/rstest-config": "2.66.0"
|
|
88
88
|
},
|
|
89
89
|
"sideEffects": false,
|