@modern-js/server-core 3.9.0 → 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 +7 -9
- 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 +7 -7
- 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/dist/types/adapters/node/helper/index.d.ts +6 -6
- package/dist/types/adapters/node/helper/loadCache.d.ts +1 -1
- package/dist/types/adapters/node/helper/loadConfig.d.ts +1 -1
- package/dist/types/adapters/node/helper/loadEnv.d.ts +1 -1
- package/dist/types/adapters/node/helper/loadPlugin.d.ts +1 -1
- package/dist/types/adapters/node/helper/utils.d.ts +1 -1
- package/dist/types/adapters/node/hono.d.ts +2 -2
- package/dist/types/adapters/node/index.d.ts +5 -5
- package/dist/types/adapters/node/node.d.ts +1 -1
- package/dist/types/adapters/node/plugins/index.d.ts +3 -3
- package/dist/types/adapters/node/plugins/nodeServer.d.ts +1 -1
- package/dist/types/adapters/node/plugins/resource.d.ts +1 -1
- package/dist/types/adapters/node/plugins/static.d.ts +1 -1
- package/dist/types/helper.d.ts +1 -1
- package/dist/types/index.d.ts +13 -13
- package/dist/types/plugins/compat/hooks.d.ts +1 -1
- package/dist/types/plugins/compat/index.d.ts +2 -2
- package/dist/types/plugins/default.d.ts +2 -2
- package/dist/types/plugins/favicon.d.ts +1 -1
- package/dist/types/plugins/index.d.ts +8 -8
- package/dist/types/plugins/log.d.ts +1 -1
- package/dist/types/plugins/middlewares.d.ts +1 -1
- package/dist/types/plugins/monitors.d.ts +1 -1
- package/dist/types/plugins/processedBy.d.ts +1 -1
- package/dist/types/plugins/render/csrRscRender.d.ts +1 -1
- package/dist/types/plugins/render/dataHandler.d.ts +1 -1
- package/dist/types/plugins/render/index.d.ts +2 -2
- package/dist/types/plugins/render/inject.d.ts +1 -1
- package/dist/types/plugins/render/render.d.ts +3 -3
- package/dist/types/plugins/render/renderRscHandler.d.ts +1 -1
- package/dist/types/plugins/render/serverActionHandler.d.ts +1 -1
- package/dist/types/plugins/render/ssrCache.d.ts +1 -1
- package/dist/types/plugins/render/ssrRender.d.ts +2 -2
- package/dist/types/plugins/render/utils.d.ts +2 -2
- package/dist/types/plugins/route.d.ts +1 -1
- package/dist/types/serverBase.d.ts +2 -2
- package/dist/types/types/config/index.d.ts +14 -14
- package/dist/types/types/config/source.d.ts +1 -1
- package/dist/types/types/index.d.ts +4 -4
- package/dist/types/types/plugins/base.d.ts +3 -3
- package/dist/types/types/plugins/index.d.ts +2 -2
- package/dist/types/types/plugins/plugin.d.ts +2 -2
- package/dist/types/types/render.d.ts +1 -1
- package/dist/types/types/requestHandler.d.ts +1 -1
- package/dist/types/types/server.d.ts +1 -1
- package/dist/types/utils/index.d.ts +9 -9
- package/dist/types/utils/publicDir.d.ts +1 -1
- package/dist/types/utils/serverConfig.d.ts +1 -1
- package/package.json +6 -6
- /package/dist/esm/{rslib-runtime.mjs → rslib-runtime~1.mjs} +0 -0
- /package/dist/esm-node/{rslib-runtime.mjs → rslib-runtime~0.mjs} +0 -0
|
@@ -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;
|
|
@@ -7,11 +7,10 @@ import { dataHandler } from "./dataHandler.mjs";
|
|
|
7
7
|
import { renderRscHandler } from "./renderRscHandler.mjs";
|
|
8
8
|
import { serverActionHandler } from "./serverActionHandler.mjs";
|
|
9
9
|
import { ssrRender } from "./ssrRender.mjs";
|
|
10
|
-
import { __webpack_require__ } from "../../rslib-runtime.mjs";
|
|
11
|
-
import * as __rspack_external__modern_js_runtime_utils_router_4aa9f9b0 from "@modern-js/runtime-utils/router";
|
|
10
|
+
import { __webpack_require__ } from "../../rslib-runtime~1.mjs";
|
|
12
11
|
__webpack_require__.add({
|
|
13
|
-
|
|
14
|
-
module.exports =
|
|
12
|
+
718 (module) {
|
|
13
|
+
module.exports = require("@modern-js/runtime-utils/router");
|
|
15
14
|
}
|
|
16
15
|
});
|
|
17
16
|
const DYNAMIC_ROUTE_REG = /\/:./;
|
|
@@ -46,8 +45,7 @@ function matchRoute(router, pathname, entryName) {
|
|
|
46
45
|
void 0,
|
|
47
46
|
{}
|
|
48
47
|
];
|
|
49
|
-
}
|
|
50
|
-
{
|
|
48
|
+
} else {
|
|
51
49
|
const result = matchedRoutes[0];
|
|
52
50
|
if (!result) return [
|
|
53
51
|
void 0,
|
|
@@ -163,7 +161,7 @@ async function renderHandler(request, options, mode, fallbackWrapper, framework)
|
|
|
163
161
|
const { nestedRoutesJson } = serverManifest;
|
|
164
162
|
const routes = nestedRoutesJson?.[options.routeInfo.entryName];
|
|
165
163
|
if (routes) {
|
|
166
|
-
const { matchRoutes } = __webpack_require__(
|
|
164
|
+
const { matchRoutes } = __webpack_require__(718);
|
|
167
165
|
const url = new URL(request.url);
|
|
168
166
|
const matchedRoutes = matchRoutes(routes, url.pathname, options.routeInfo.urlPath);
|
|
169
167
|
if (matchedRoutes) {
|
|
@@ -201,7 +199,7 @@ async function getRenderMode(req, fallbackHeader, isSSR, forceCSR, nodeReq, onFa
|
|
|
201
199
|
if (req.headers.get('x-rsc-action')) return 'rsc-action';
|
|
202
200
|
if (req.headers.get('x-rsc-tree')) return 'rsc-tree';
|
|
203
201
|
if (!isSSR) return 'csr';
|
|
204
|
-
{
|
|
202
|
+
else {
|
|
205
203
|
if (query.__loader) return 'data';
|
|
206
204
|
const fallbackHeaderValue = req.headers.get(fallbackHeader) || nodeReq?.headers[fallbackHeader];
|
|
207
205
|
if (forceCSR && (query.csr || fallbackHeaderValue || contextForceCSR)) {
|
|
@@ -230,6 +228,6 @@ async function csrRender(request, options) {
|
|
|
230
228
|
[X_MODERNJS_RENDER]: 'client'
|
|
231
229
|
})
|
|
232
230
|
});
|
|
233
|
-
return csrRscRender(request, options);
|
|
231
|
+
else return csrRscRender(request, options);
|
|
234
232
|
}
|
|
235
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;
|
|
@@ -8,11 +8,12 @@ import { dataHandler } from "./dataHandler.mjs";
|
|
|
8
8
|
import { renderRscHandler } from "./renderRscHandler.mjs";
|
|
9
9
|
import { serverActionHandler } from "./serverActionHandler.mjs";
|
|
10
10
|
import { ssrRender } from "./ssrRender.mjs";
|
|
11
|
-
import { __webpack_require__ } from "../../rslib-runtime.mjs";
|
|
12
|
-
import
|
|
11
|
+
import { __webpack_require__ } from "../../rslib-runtime~0.mjs";
|
|
12
|
+
import { createRequire as __rspack_createRequire } from "node:module";
|
|
13
|
+
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
13
14
|
__webpack_require__.add({
|
|
14
15
|
"@modern-js/runtime-utils/router" (module) {
|
|
15
|
-
module.exports =
|
|
16
|
+
module.exports = __rspack_createRequire_require("@modern-js/runtime-utils/router");
|
|
16
17
|
}
|
|
17
18
|
});
|
|
18
19
|
const DYNAMIC_ROUTE_REG = /\/:./;
|
|
@@ -47,8 +48,7 @@ function matchRoute(router, pathname, entryName) {
|
|
|
47
48
|
void 0,
|
|
48
49
|
{}
|
|
49
50
|
];
|
|
50
|
-
}
|
|
51
|
-
{
|
|
51
|
+
} else {
|
|
52
52
|
const result = matchedRoutes[0];
|
|
53
53
|
if (!result) return [
|
|
54
54
|
void 0,
|
|
@@ -202,7 +202,7 @@ async function getRenderMode(req, fallbackHeader, isSSR, forceCSR, nodeReq, onFa
|
|
|
202
202
|
if (req.headers.get('x-rsc-action')) return 'rsc-action';
|
|
203
203
|
if (req.headers.get('x-rsc-tree')) return 'rsc-tree';
|
|
204
204
|
if (!isSSR) return 'csr';
|
|
205
|
-
{
|
|
205
|
+
else {
|
|
206
206
|
if (query.__loader) return 'data';
|
|
207
207
|
const fallbackHeaderValue = req.headers.get(fallbackHeader) || nodeReq?.headers[fallbackHeader];
|
|
208
208
|
if (forceCSR && (query.csr || fallbackHeaderValue || contextForceCSR)) {
|
|
@@ -231,6 +231,6 @@ async function csrRender(request, options) {
|
|
|
231
231
|
[X_MODERNJS_RENDER]: 'client'
|
|
232
232
|
})
|
|
233
233
|
});
|
|
234
|
-
return csrRscRender(request, options);
|
|
234
|
+
else return csrRscRender(request, options);
|
|
235
235
|
}
|
|
236
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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { loadServerEnv } from './loadEnv';
|
|
2
|
-
export { loadServerPlugins } from './loadPlugin';
|
|
3
|
-
export { loadServerRuntimeConfig, loadServerCliConfig } from './loadConfig';
|
|
4
|
-
export { loadCacheConfig } from './loadCache';
|
|
5
|
-
export { isResFinalized } from './utils';
|
|
6
|
-
export type { NodeBindings } from './utils';
|
|
1
|
+
export { loadServerEnv } from './loadEnv.js';
|
|
2
|
+
export { loadServerPlugins } from './loadPlugin.js';
|
|
3
|
+
export { loadServerRuntimeConfig, loadServerCliConfig } from './loadConfig.js';
|
|
4
|
+
export { loadCacheConfig } from './loadCache.js';
|
|
5
|
+
export { isResFinalized } from './utils.js';
|
|
6
|
+
export type { NodeBindings } from './utils.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CacheConfig } from '../../../types';
|
|
1
|
+
import type { CacheConfig } from '../../../types/index.js';
|
|
2
2
|
export declare function loadCacheConfig(pwd: string): Promise<CacheConfig | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { CliConfig, ServerConfig, UserConfig } from '../../../types';
|
|
1
|
+
import type { CliConfig, ServerConfig, UserConfig } from '../../../types/index.js';
|
|
2
2
|
export declare function loadServerRuntimeConfig(serverConfigPath: string): Promise<ServerConfig | undefined>;
|
|
3
3
|
export declare function loadServerCliConfig(pwd: string, defaultConfig?: UserConfig): CliConfig;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ServerPlugin } from '@modern-js/types';
|
|
2
|
-
import type { ServerPlugin as ServerPluginInstance } from '../../../types';
|
|
2
|
+
import type { ServerPlugin as ServerPluginInstance } from '../../../types/index.js';
|
|
3
3
|
export declare function loadServerPlugins(serverPlugins: ServerPlugin[], appDirectory: string): Promise<ServerPluginInstance[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ClientManifest, NodeRequest, NodeResponse, SSRManifest } from '@modern-js/types/server';
|
|
2
|
-
import type { HonoRequest, ServerManifest } from '../../../types';
|
|
2
|
+
import type { HonoRequest, ServerManifest } from '../../../types/index.js';
|
|
3
3
|
type ExtendedNodeRequest = NodeRequest & {
|
|
4
4
|
__honoRequest?: HonoRequest;
|
|
5
5
|
__templates?: Record<string, string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NodeRequest, NodeResponse } from '@modern-js/types/server';
|
|
2
|
-
import type { Context, Middleware, Next, ServerEnv } from '../../types';
|
|
3
|
-
import { type NodeBindings } from './helper';
|
|
2
|
+
import type { Context, Middleware, Next, ServerEnv } from '../../types/index.js';
|
|
3
|
+
import { type NodeBindings } from './helper/index.js';
|
|
4
4
|
export type ServerNodeEnv = {
|
|
5
5
|
Bindings: NodeBindings;
|
|
6
6
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { httpCallBack2HonoMid, connectMid2HonoMid, connectMockMid2HonoMid, } from './hono';
|
|
2
|
-
export type { ServerNodeContext, ServerNodeMiddleware } from './hono';
|
|
3
|
-
export { createNodeServer, sendResponse, createWebRequest, } from './node';
|
|
4
|
-
export { serverStaticPlugin, injectResourcePlugin, getHtmlTemplates, getServerManifest, injectNodeSeverPlugin, injectRscManifestPlugin, } from './plugins';
|
|
5
|
-
export { loadServerPlugins, loadServerEnv, loadServerRuntimeConfig, loadServerCliConfig, loadCacheConfig, } from './helper';
|
|
1
|
+
export { httpCallBack2HonoMid, connectMid2HonoMid, connectMockMid2HonoMid, } from './hono.js';
|
|
2
|
+
export type { ServerNodeContext, ServerNodeMiddleware } from './hono.js';
|
|
3
|
+
export { createNodeServer, sendResponse, createWebRequest, } from './node.js';
|
|
4
|
+
export { serverStaticPlugin, injectResourcePlugin, getHtmlTemplates, getServerManifest, injectNodeSeverPlugin, injectRscManifestPlugin, } from './plugins/index.js';
|
|
5
|
+
export { loadServerPlugins, loadServerEnv, loadServerRuntimeConfig, loadServerCliConfig, loadCacheConfig, } from './helper/index.js';
|
|
@@ -2,7 +2,7 @@ import { type Server as NodeServer } from 'node:http';
|
|
|
2
2
|
import type { Http2SecureServer } from 'node:http2';
|
|
3
3
|
import type { Server as NodeHttpsServer } from 'node:https';
|
|
4
4
|
import type { NodeRequest, NodeResponse } from '@modern-js/types/server';
|
|
5
|
-
import type { RequestHandler } from '../../types';
|
|
5
|
+
import type { RequestHandler } from '../../types/index.js';
|
|
6
6
|
export declare const createWebRequest: (req: NodeRequest, res: NodeResponse, body?: BodyInit) => Request;
|
|
7
7
|
export declare const sendResponse: (response: Response, res: NodeResponse) => Promise<void>;
|
|
8
8
|
declare const getRequestListener: (handler: RequestHandler) => (req: NodeRequest, res: NodeResponse) => Promise<void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './static';
|
|
2
|
-
export * from './resource';
|
|
3
|
-
export * from './nodeServer';
|
|
1
|
+
export * from './static.js';
|
|
2
|
+
export * from './resource.js';
|
|
3
|
+
export * from './nodeServer.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Server as NodeServer } from 'node:http';
|
|
2
2
|
import type { Http2SecureServer } from 'node:http2';
|
|
3
|
-
import type { ServerPlugin } from '../../../types';
|
|
3
|
+
import type { ServerPlugin } from '../../../types/index.js';
|
|
4
4
|
export declare const injectNodeSeverPlugin: ({ nodeServer, }: {
|
|
5
5
|
nodeServer: NodeServer | Http2SecureServer;
|
|
6
6
|
}) => ServerPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Monitors, ServerRoute } from '@modern-js/types';
|
|
2
|
-
import type { Middleware, ServerEnv, ServerManifest, ServerPlugin } from '../../../types';
|
|
2
|
+
import type { Middleware, ServerEnv, ServerManifest, ServerPlugin } from '../../../types/index.js';
|
|
3
3
|
export declare function getHtmlTemplates(pwd: string, routes: ServerRoute[]): Promise<Record<string, string>>;
|
|
4
4
|
export declare function injectTemplates(pwd: string, routes?: ServerRoute[], htmlTemplatePromise?: ReturnType<typeof getHtmlTemplates>): Middleware<ServerEnv>;
|
|
5
5
|
export declare function getServerManifest(pwd: string, routes: ServerRoute[], monitors?: Monitors): Promise<ServerManifest>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ServerRoute } from '@modern-js/types';
|
|
2
|
-
import type { HtmlNormalizedConfig, Middleware, OutputNormalizedConfig, ServerNormalizedConfig, ServerPlugin } from '../../../types';
|
|
2
|
+
import type { HtmlNormalizedConfig, Middleware, OutputNormalizedConfig, ServerNormalizedConfig, ServerPlugin } from '../../../types/index.js';
|
|
3
3
|
export declare const serverStaticPlugin: () => ServerPlugin;
|
|
4
4
|
export type PublicMiddlwareOptions = {
|
|
5
5
|
pwd: string;
|
package/dist/types/helper.d.ts
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export { createErrorHtml, onError, ErrorDigest } from './utils';
|
|
2
|
-
export { normalizePublicDir, normalizePublicDirPath, getPublicDirRoutePrefixes, getPublicDirPatterns, resolvePublicDirPaths, getPublicDirConfig, } from './utils/publicDir';
|
|
3
|
-
export { AGGRED_DIR } from './constants';
|
|
4
|
-
export type { ServerBase, ServerBaseOptions } from './serverBase';
|
|
5
|
-
export { createServerBase } from './serverBase';
|
|
6
|
-
export { run, useHonoContext } from './context';
|
|
1
|
+
export { createErrorHtml, onError, ErrorDigest } from './utils/index.js';
|
|
2
|
+
export { normalizePublicDir, normalizePublicDirPath, getPublicDirRoutePrefixes, getPublicDirPatterns, resolvePublicDirPaths, getPublicDirConfig, } from './utils/publicDir.js';
|
|
3
|
+
export { AGGRED_DIR } from './constants.js';
|
|
4
|
+
export type { ServerBase, ServerBaseOptions } from './serverBase.js';
|
|
5
|
+
export { createServerBase } from './serverBase.js';
|
|
6
|
+
export { run, useHonoContext } from './context.js';
|
|
7
7
|
export { Hono } from 'hono';
|
|
8
|
-
export type { Middleware, MiddlewareHandler, Context, Next, HonoRequest as InternalRequest, ServerEnv, ServerManifest, ServerLoaderBundle, } from './types';
|
|
9
|
-
export { getLoaderCtx } from './helper';
|
|
10
|
-
export * from './plugins';
|
|
11
|
-
export * from './types/plugins';
|
|
12
|
-
export * from './types/render';
|
|
13
|
-
export * from './types/config';
|
|
14
|
-
export * from './types/requestHandler';
|
|
8
|
+
export type { Middleware, MiddlewareHandler, Context, Next, HonoRequest as InternalRequest, ServerEnv, ServerManifest, ServerLoaderBundle, } from './types/index.js';
|
|
9
|
+
export { getLoaderCtx } from './helper.js';
|
|
10
|
+
export * from './plugins/index.js';
|
|
11
|
+
export * from './types/plugins/index.js';
|
|
12
|
+
export * from './types/render.js';
|
|
13
|
+
export * from './types/config/index.js';
|
|
14
|
+
export * from './types/requestHandler.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ServerPlugin } from '../../types';
|
|
2
|
-
export { handleSetupResult } from './hooks';
|
|
1
|
+
import type { ServerPlugin } from '../../types/index.js';
|
|
2
|
+
export { handleSetupResult } from './hooks.js';
|
|
3
3
|
export declare const compatPlugin: () => ServerPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Logger } from '@modern-js/types';
|
|
2
|
-
import type { ServerPlugin } from '../types';
|
|
3
|
-
import { type InjectRenderHandlerOptions } from './render';
|
|
2
|
+
import type { ServerPlugin } from '../types/index.js';
|
|
3
|
+
import { type InjectRenderHandlerOptions } from './render/index.js';
|
|
4
4
|
export type CreateDefaultPluginsOptions = InjectRenderHandlerOptions & {
|
|
5
5
|
logger?: Logger | false;
|
|
6
6
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ServerPlugin } from '../types';
|
|
1
|
+
import type { ServerPlugin } from '../types/index.js';
|
|
2
2
|
export declare const faviconPlugin: () => ServerPlugin;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { renderPlugin, injectRenderHandlerPlugin, type InjectRenderHandlerOptions, getRenderHandler, } from './render';
|
|
2
|
-
export { faviconPlugin } from './favicon';
|
|
3
|
-
export { injectServerTiming, injectloggerPlugin } from './monitors';
|
|
4
|
-
export { processedByPlugin } from './processedBy';
|
|
5
|
-
export { logPlugin } from './log';
|
|
6
|
-
export { createDefaultPlugins, type CreateDefaultPluginsOptions, } from './default';
|
|
7
|
-
export { compatPlugin, handleSetupResult } from './compat';
|
|
8
|
-
export { injectConfigMiddlewarePlugin } from './middlewares';
|
|
1
|
+
export { renderPlugin, injectRenderHandlerPlugin, type InjectRenderHandlerOptions, getRenderHandler, } from './render/index.js';
|
|
2
|
+
export { faviconPlugin } from './favicon.js';
|
|
3
|
+
export { injectServerTiming, injectloggerPlugin } from './monitors.js';
|
|
4
|
+
export { processedByPlugin } from './processedBy.js';
|
|
5
|
+
export { logPlugin } from './log.js';
|
|
6
|
+
export { createDefaultPlugins, type CreateDefaultPluginsOptions, } from './default.js';
|
|
7
|
+
export { compatPlugin, handleSetupResult } from './compat/index.js';
|
|
8
|
+
export { injectConfigMiddlewarePlugin } from './middlewares.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ServerPlugin } from '../types';
|
|
1
|
+
import type { ServerPlugin } from '../types/index.js';
|
|
2
2
|
export declare const logPlugin: () => ServerPlugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { MiddlewareObj, ServerPlugin } from '../types';
|
|
1
|
+
import type { MiddlewareObj, ServerPlugin } from '../types/index.js';
|
|
2
2
|
export declare const injectConfigMiddlewarePlugin: (configMiddlewares?: MiddlewareObj[], configRenderMiddlewares?: MiddlewareObj[]) => ServerPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Logger } from '@modern-js/types';
|
|
2
|
-
import type { Context, Next, ServerEnv, ServerPlugin } from '../types';
|
|
2
|
+
import type { Context, Next, ServerEnv, ServerPlugin } from '../types/index.js';
|
|
3
3
|
export declare const initMonitorsPlugin: () => ServerPlugin;
|
|
4
4
|
export declare const injectloggerPlugin: (inputLogger: Logger) => ServerPlugin;
|
|
5
5
|
export declare const injectServerTiming: () => ServerPlugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ServerPlugin } from '../types';
|
|
1
|
+
import type { ServerPlugin } from '../types/index.js';
|
|
2
2
|
export declare const processedByPlugin: () => ServerPlugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SSRRenderOptions } from './ssrRender';
|
|
1
|
+
import type { SSRRenderOptions } from './ssrRender.js';
|
|
2
2
|
export declare const csrRscRender: (req: Request, options: SSRRenderOptions) => Promise<Response>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ServerRoute } from '@modern-js/types';
|
|
2
|
-
import type { SSRRenderOptions } from './ssrRender';
|
|
2
|
+
import type { SSRRenderOptions } from './ssrRender.js';
|
|
3
3
|
export declare const dataHandler: (request: Request, { routeInfo, serverRoutes, monitors, onError, onTiming, serverManifest, loaderContext, }: SSRRenderOptions & {
|
|
4
4
|
serverRoutes: ServerRoute[];
|
|
5
5
|
}) => Promise<Response | void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ServerPlugin } from '../../types';
|
|
2
|
-
export * from './inject';
|
|
1
|
+
import type { ServerPlugin } from '../../types/index.js';
|
|
2
|
+
export * from './inject.js';
|
|
3
3
|
export declare const renderPlugin: () => ServerPlugin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CacheConfig, GetRenderHandlerOptions, Render, ServerPlugin } from '../../types';
|
|
1
|
+
import type { CacheConfig, GetRenderHandlerOptions, Render, ServerPlugin } from '../../types/index.js';
|
|
2
2
|
export interface InjectRenderHandlerOptions {
|
|
3
3
|
staticGenerate?: boolean;
|
|
4
4
|
cacheConfig?: CacheConfig;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ServerRoute } from '@modern-js/types';
|
|
2
2
|
import type { Router } from 'hono/router';
|
|
3
|
-
import type { CacheConfig, UserConfig } from '../../types';
|
|
4
|
-
import type { Render } from '../../types';
|
|
5
|
-
import type { Params } from '../../types/requestHandler';
|
|
3
|
+
import type { CacheConfig, UserConfig } from '../../types/index.js';
|
|
4
|
+
import type { Render } from '../../types/index.js';
|
|
5
|
+
import type { Params } from '../../types/requestHandler.js';
|
|
6
6
|
interface CreateRenderOptions {
|
|
7
7
|
pwd: string;
|
|
8
8
|
routes: ServerRoute[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SSRRenderOptions } from './ssrRender';
|
|
1
|
+
import type { SSRRenderOptions } from './ssrRender.js';
|
|
2
2
|
export declare const renderRscHandler: (req: Request, options: SSRRenderOptions) => Promise<Response>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SSRRenderOptions } from './ssrRender';
|
|
1
|
+
import type { SSRRenderOptions } from './ssrRender.js';
|
|
2
2
|
export declare const serverActionHandler: (req: Request, { serverManifest, routeInfo, rscClientManifest }: SSRRenderOptions) => Promise<Response>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CacheControl, CacheOption, Container } from '@modern-js/types';
|
|
2
2
|
import type { NodeRequest } from '@modern-js/types/server';
|
|
3
|
-
import type { RequestHandler, RequestHandlerOptions } from '../../types/requestHandler';
|
|
3
|
+
import type { RequestHandler, RequestHandlerOptions } from '../../types/requestHandler.js';
|
|
4
4
|
export type CacheStatus = 'hit' | 'stale' | 'expired' | 'miss';
|
|
5
5
|
type MaybeAsync<T> = Promise<T> | T;
|
|
6
6
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Reporter, ServerRoute } from '@modern-js/types';
|
|
2
2
|
import type { Monitors, ClientManifest as RscClientManifest, SSRManifest as RscSSRManifest, ServerManifest as RscServerManifest } from '@modern-js/types/server';
|
|
3
3
|
import type { NodeRequest } from '@modern-js/types/server';
|
|
4
|
-
import type { CacheConfig, ServerManifest, UserConfig } from '../../types';
|
|
5
|
-
import type { OnError, OnTiming, Params } from '../../types/requestHandler';
|
|
4
|
+
import type { CacheConfig, ServerManifest, UserConfig } from '../../types/index.js';
|
|
5
|
+
import type { OnError, OnTiming, Params } from '../../types/requestHandler.js';
|
|
6
6
|
export interface SSRRenderOptions {
|
|
7
7
|
pwd: string;
|
|
8
8
|
html: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { UserConfig } from '../../types';
|
|
2
|
-
import type { RequestHandlerConfig } from '../../types/requestHandler';
|
|
1
|
+
import type { UserConfig } from '../../types/index.js';
|
|
2
|
+
import type { RequestHandlerConfig } from '../../types/requestHandler.js';
|
|
3
3
|
export declare function createRequestHandlerConfig(userConfig: UserConfig): RequestHandlerConfig;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ServerPlugin } from '../types';
|
|
1
|
+
import type { ServerPlugin } from '../types/index.js';
|
|
2
2
|
export declare const injectRoutePlugin: () => ServerPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ServerCreateOptions } from '@modern-js/plugin/server';
|
|
2
|
-
import type { Env, ServerConfig, ServerPlugin, ServerPluginHooks } from './types';
|
|
3
|
-
import type { CliConfig } from './types/config';
|
|
2
|
+
import type { Env, ServerConfig, ServerPlugin, ServerPluginHooks } from './types/index.js';
|
|
3
|
+
import type { CliConfig } from './types/config/index.js';
|
|
4
4
|
export interface ServerBaseOptions extends ServerCreateOptions {
|
|
5
5
|
/** server working directory, and then also dist directory */
|
|
6
6
|
config: CliConfig;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { BffNormalizedConfig, BffUserConfig } from './bff';
|
|
2
|
-
import type { DevNormalizedConfig, DevUserConfig } from './dev';
|
|
3
|
-
import type { HtmlNormalizedConfig, HtmlUserConfig } from './html';
|
|
4
|
-
import type { OutputNormalizedConfig, OutputUserConfig } from './output';
|
|
5
|
-
import type { SecurityNormalizedConfig, SecurityUserConfig } from './security';
|
|
6
|
-
import type { ServerNormalizedConfig, ServerUserConfig } from './server';
|
|
7
|
-
import type { SourceNormalizedConfig, SourceUserConfig } from './source';
|
|
8
|
-
import type { ToolsNormalizedConfig, ToolsUserConfig } from './tools';
|
|
9
|
-
export * from './bff';
|
|
10
|
-
export * from './html';
|
|
11
|
-
export * from './output';
|
|
12
|
-
export * from './server';
|
|
13
|
-
export * from './source';
|
|
14
|
-
export * from './tools';
|
|
1
|
+
import type { BffNormalizedConfig, BffUserConfig } from './bff.js';
|
|
2
|
+
import type { DevNormalizedConfig, DevUserConfig } from './dev.js';
|
|
3
|
+
import type { HtmlNormalizedConfig, HtmlUserConfig } from './html.js';
|
|
4
|
+
import type { OutputNormalizedConfig, OutputUserConfig } from './output.js';
|
|
5
|
+
import type { SecurityNormalizedConfig, SecurityUserConfig } from './security.js';
|
|
6
|
+
import type { ServerNormalizedConfig, ServerUserConfig } from './server.js';
|
|
7
|
+
import type { SourceNormalizedConfig, SourceUserConfig } from './source.js';
|
|
8
|
+
import type { ToolsNormalizedConfig, ToolsUserConfig } from './tools.js';
|
|
9
|
+
export * from './bff.js';
|
|
10
|
+
export * from './html.js';
|
|
11
|
+
export * from './output.js';
|
|
12
|
+
export * from './server.js';
|
|
13
|
+
export * from './source.js';
|
|
14
|
+
export * from './tools.js';
|
|
15
15
|
export interface UserConfig {
|
|
16
16
|
output?: OutputUserConfig;
|
|
17
17
|
source?: SourceUserConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './config';
|
|
2
|
-
export * from './plugins';
|
|
3
|
-
export * from './render';
|
|
4
|
-
export * from './server';
|
|
1
|
+
export * from './config/index.js';
|
|
2
|
+
export * from './plugins/index.js';
|
|
3
|
+
export * from './render.js';
|
|
4
|
+
export * from './server.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CacheOption, Container, HttpMethodDecider, MiddlewareContext, ServerRoute } from '@modern-js/types';
|
|
2
2
|
import type { Context, MiddlewareHandler } from 'hono';
|
|
3
|
-
import type { UserConfig } from '../config';
|
|
4
|
-
import type { Render } from '../render';
|
|
5
|
-
import type { ServerPlugin } from './plugin';
|
|
3
|
+
import type { UserConfig } from '../config/index.js';
|
|
4
|
+
import type { Render } from '../render.js';
|
|
5
|
+
import type { ServerPlugin } from './plugin.js';
|
|
6
6
|
export type { FileChangeEvent, ResetEvent } from '@modern-js/plugin';
|
|
7
7
|
export type APIServerStartInput = {
|
|
8
8
|
pwd: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './plugin';
|
|
2
|
-
export type { ServerConfig, CacheConfig, GetRenderHandlerOptions, FileChangeEvent, WebServerStartInput, APIServerStartInput, ServerMiddleware, MiddlewareObj, } from './base';
|
|
1
|
+
export * from './plugin.js';
|
|
2
|
+
export type { ServerConfig, CacheConfig, GetRenderHandlerOptions, FileChangeEvent, WebServerStartInput, APIServerStartInput, ServerMiddleware, MiddlewareObj, } from './base.js';
|
|
@@ -2,8 +2,8 @@ import type { AsyncPipelineHook, ServerContext as BaseServerContext, ServerPlugi
|
|
|
2
2
|
import type { Hooks } from '@modern-js/plugin/server';
|
|
3
3
|
import type { AfterMatchContext, AfterRenderContext, AfterStreamingRenderContext } from '@modern-js/types';
|
|
4
4
|
import type { MiddlewareHandler } from 'hono';
|
|
5
|
-
import type { MiddlewareObj } from './base';
|
|
6
|
-
import type { APIServerStartInput, ServerConfig, WebAdapter, WebServerStartInput } from './base';
|
|
5
|
+
import type { MiddlewareObj } from './base.js';
|
|
6
|
+
import type { APIServerStartInput, ServerConfig, WebAdapter, WebServerStartInput } from './base.js';
|
|
7
7
|
export type PrepareWebServerFn = (input: WebServerStartInput) => Promise<WebAdapter | null>;
|
|
8
8
|
export type PrepareApiServerFn = (input: APIServerStartInput) => Promise<MiddlewareHandler>;
|
|
9
9
|
export type AfterMatchFn = (ctx: AfterMatchContext) => Promise<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Monitors, Reporter, ClientManifest as RscClientManifest, SSRManifest as RscSSRManifest, ServerManifest as RscServerManifest } from '@modern-js/types';
|
|
2
2
|
import type { NodeRequest } from '@modern-js/types/server';
|
|
3
|
-
import type { ServerManifest } from './server';
|
|
3
|
+
import type { ServerManifest } from './server.js';
|
|
4
4
|
export interface RenderOptions {
|
|
5
5
|
monitors: Monitors;
|
|
6
6
|
loaderContext?: Map<string, unknown>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Reporter, ServerRoute } from '@modern-js/types';
|
|
2
2
|
import type { Monitors, ClientManifest as RscClientManifest, SSRManifest as RscSSRManifest, ServerManifest as RscServerManifest } from '@modern-js/types/server';
|
|
3
|
-
import type { ServerUserConfig, SourceUserConfig } from './config';
|
|
3
|
+
import type { ServerUserConfig, SourceUserConfig } from './config/index.js';
|
|
4
4
|
export type Resource = {
|
|
5
5
|
loadableStats: Record<string, any>;
|
|
6
6
|
routeManifest: Record<string, any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Logger, Metrics, Monitors, NestedRoute, Reporter, ServerRoute } from '@modern-js/types';
|
|
2
2
|
import type { ClientManifest as RscClientManifest, SSRManifest as RscSSRManifest, ServerManifest as RscServerManifest } from '@modern-js/types/server';
|
|
3
|
-
import type { RequestHandler as BundleRequestHandler, OnError, OnTiming, RequestHandlerOptions, Resource } from './requestHandler';
|
|
3
|
+
import type { RequestHandler as BundleRequestHandler, OnError, OnTiming, RequestHandlerOptions, Resource } from './requestHandler.js';
|
|
4
4
|
export type RequestHandler = (request: Request, ...args: any[]) => Response | Promise<Response>;
|
|
5
5
|
export type ServerLoaderBundle = {
|
|
6
6
|
routes: NestedRoute[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './env';
|
|
2
|
-
export * from './transformStream';
|
|
3
|
-
export * from './middlewareCollector';
|
|
4
|
-
export * from './error';
|
|
5
|
-
export * from './warmup';
|
|
6
|
-
export * from './entry';
|
|
7
|
-
export * from './request';
|
|
8
|
-
export * from './serverConfig';
|
|
9
|
-
export * from './publicDir';
|
|
1
|
+
export * from './env.js';
|
|
2
|
+
export * from './transformStream.js';
|
|
3
|
+
export * from './middlewareCollector.js';
|
|
4
|
+
export * from './error.js';
|
|
5
|
+
export * from './warmup.js';
|
|
6
|
+
export * from './entry.js';
|
|
7
|
+
export * from './request.js';
|
|
8
|
+
export * from './serverConfig.js';
|
|
9
|
+
export * from './publicDir.js';
|
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,19 +71,19 @@
|
|
|
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
|
-
"@rslib/core": "0.
|
|
79
|
+
"@rslib/core": "1.0.0",
|
|
80
80
|
"@types/cloneable-readable": "^2.0.3",
|
|
81
81
|
"@types/merge-deep": "^3.0.3",
|
|
82
82
|
"@types/node": "^20",
|
|
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,
|
|
File without changes
|
|
File without changes
|