@modern-js/server-core 2.60.5 → 2.60.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/adapters/node/helper/index.js +3 -0
- package/dist/cjs/adapters/node/helper/utils.js +31 -0
- package/dist/cjs/adapters/node/hono.js +2 -1
- package/dist/cjs/adapters/node/node.js +2 -1
- package/dist/esm/adapters/node/helper/index.js +2 -0
- package/dist/esm/adapters/node/helper/utils.js +7 -0
- package/dist/esm/adapters/node/hono.js +2 -1
- package/dist/esm/adapters/node/node.js +2 -1
- package/dist/esm-node/adapters/node/helper/index.js +2 -0
- package/dist/esm-node/adapters/node/helper/utils.js +7 -0
- package/dist/esm-node/adapters/node/hono.js +2 -1
- package/dist/esm-node/adapters/node/node.js +2 -1
- package/dist/types/adapters/node/helper/index.d.ts +2 -0
- package/dist/types/adapters/node/helper/utils.d.ts +17 -0
- package/dist/types/adapters/node/hono.d.ts +2 -13
- package/package.json +7 -7
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var helper_exports = {};
|
|
20
20
|
__export(helper_exports, {
|
|
21
|
+
isResFinalized: () => import_utils.isResFinalized,
|
|
21
22
|
loadCacheConfig: () => import_loadCache.loadCacheConfig,
|
|
22
23
|
loadServerCliConfig: () => import_loadConfig.loadServerCliConfig,
|
|
23
24
|
loadServerEnv: () => import_loadEnv.loadServerEnv,
|
|
@@ -29,8 +30,10 @@ var import_loadEnv = require("./loadEnv");
|
|
|
29
30
|
var import_loadPlugin = require("./loadPlugin");
|
|
30
31
|
var import_loadConfig = require("./loadConfig");
|
|
31
32
|
var import_loadCache = require("./loadCache");
|
|
33
|
+
var import_utils = require("./utils");
|
|
32
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
35
|
0 && (module.exports = {
|
|
36
|
+
isResFinalized,
|
|
34
37
|
loadCacheConfig,
|
|
35
38
|
loadServerCliConfig,
|
|
36
39
|
loadServerEnv,
|
|
@@ -0,0 +1,31 @@
|
|
|
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 utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
isResFinalized: () => isResFinalized
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(utils_exports);
|
|
24
|
+
const isResFinalized = (res) => {
|
|
25
|
+
var _res_socket;
|
|
26
|
+
return res.headersSent || res._modernBodyPiped || res.writableEnded || res.finished || !((_res_socket = res.socket) === null || _res_socket === void 0 ? void 0 : _res_socket.writable);
|
|
27
|
+
};
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
isResFinalized
|
|
31
|
+
});
|
|
@@ -22,6 +22,7 @@ __export(hono_exports, {
|
|
|
22
22
|
httpCallBack2HonoMid: () => httpCallBack2HonoMid
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(hono_exports);
|
|
25
|
+
var import_helper = require("./helper");
|
|
25
26
|
const httpCallBack2HonoMid = (handler) => {
|
|
26
27
|
return async (context, next) => {
|
|
27
28
|
const { req, res } = context.env.node;
|
|
@@ -40,7 +41,7 @@ const httpCallBack2HonoMid = (handler) => {
|
|
|
40
41
|
delete req.__serverManifest;
|
|
41
42
|
res.removeListener("pipe", onPipe);
|
|
42
43
|
}
|
|
43
|
-
if (
|
|
44
|
+
if ((0, import_helper.isResFinalized)(res)) {
|
|
44
45
|
context.finalized = true;
|
|
45
46
|
} else {
|
|
46
47
|
await next();
|
|
@@ -35,6 +35,7 @@ __export(node_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(node_exports);
|
|
37
37
|
var import_node_http = require("node:http");
|
|
38
|
+
var import_helper = require("./helper");
|
|
38
39
|
var import_install = require("./polyfills/install");
|
|
39
40
|
var import_stream = require("./polyfills/stream");
|
|
40
41
|
var import_polyfills = require("./polyfills");
|
|
@@ -116,7 +117,7 @@ const getRequestListener = (handler) => {
|
|
|
116
117
|
res
|
|
117
118
|
}
|
|
118
119
|
});
|
|
119
|
-
if (!
|
|
120
|
+
if (!response.res && !(0, import_helper.isResFinalized)(res)) {
|
|
120
121
|
await sendResponse(response, res);
|
|
121
122
|
}
|
|
122
123
|
} catch (error) {
|
|
@@ -2,7 +2,9 @@ import { loadServerEnv } from "./loadEnv";
|
|
|
2
2
|
import { loadServerPlugins } from "./loadPlugin";
|
|
3
3
|
import { loadServerRuntimeConfig, loadServerCliConfig } from "./loadConfig";
|
|
4
4
|
import { loadCacheConfig } from "./loadCache";
|
|
5
|
+
import { isResFinalized } from "./utils";
|
|
5
6
|
export {
|
|
7
|
+
isResFinalized,
|
|
6
8
|
loadCacheConfig,
|
|
7
9
|
loadServerCliConfig,
|
|
8
10
|
loadServerEnv,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var isResFinalized = function(res) {
|
|
2
|
+
var _res_socket;
|
|
3
|
+
return res.headersSent || res._modernBodyPiped || res.writableEnded || res.finished || !((_res_socket = res.socket) === null || _res_socket === void 0 ? void 0 : _res_socket.writable);
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
isResFinalized
|
|
7
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
|
+
import { isResFinalized } from "./helper";
|
|
3
4
|
var httpCallBack2HonoMid = function(handler) {
|
|
4
5
|
return function() {
|
|
5
6
|
var _ref = _async_to_generator(function(context, next) {
|
|
@@ -42,7 +43,7 @@ var httpCallBack2HonoMid = function(handler) {
|
|
|
42
43
|
7
|
|
43
44
|
];
|
|
44
45
|
case 4:
|
|
45
|
-
if (!(res
|
|
46
|
+
if (!isResFinalized(res))
|
|
46
47
|
return [
|
|
47
48
|
3,
|
|
48
49
|
5
|
|
@@ -3,6 +3,7 @@ import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
|
|
|
3
3
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
4
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
5
|
import { ServerResponse } from "node:http";
|
|
6
|
+
import { isResFinalized } from "./helper";
|
|
6
7
|
import { installGlobals } from "./polyfills/install";
|
|
7
8
|
import { createReadableStreamFromReadable, writeReadableStreamToWritable } from "./polyfills/stream";
|
|
8
9
|
import { writeReadableStreamToWritable as writeReadableStreamToWritable2 } from "./polyfills";
|
|
@@ -145,7 +146,7 @@ var getRequestListener = function(handler) {
|
|
|
145
146
|
];
|
|
146
147
|
case 1:
|
|
147
148
|
response = _state.sent();
|
|
148
|
-
if (!(!
|
|
149
|
+
if (!(!response.res && !isResFinalized(res)))
|
|
149
150
|
return [
|
|
150
151
|
3,
|
|
151
152
|
3
|
|
@@ -2,7 +2,9 @@ import { loadServerEnv } from "./loadEnv";
|
|
|
2
2
|
import { loadServerPlugins } from "./loadPlugin";
|
|
3
3
|
import { loadServerRuntimeConfig, loadServerCliConfig } from "./loadConfig";
|
|
4
4
|
import { loadCacheConfig } from "./loadCache";
|
|
5
|
+
import { isResFinalized } from "./utils";
|
|
5
6
|
export {
|
|
7
|
+
isResFinalized,
|
|
6
8
|
loadCacheConfig,
|
|
7
9
|
loadServerCliConfig,
|
|
8
10
|
loadServerEnv,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const isResFinalized = (res) => {
|
|
2
|
+
var _res_socket;
|
|
3
|
+
return res.headersSent || res._modernBodyPiped || res.writableEnded || res.finished || !((_res_socket = res.socket) === null || _res_socket === void 0 ? void 0 : _res_socket.writable);
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
isResFinalized
|
|
7
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isResFinalized } from "./helper";
|
|
1
2
|
const httpCallBack2HonoMid = (handler) => {
|
|
2
3
|
return async (context, next) => {
|
|
3
4
|
const { req, res } = context.env.node;
|
|
@@ -16,7 +17,7 @@ const httpCallBack2HonoMid = (handler) => {
|
|
|
16
17
|
delete req.__serverManifest;
|
|
17
18
|
res.removeListener("pipe", onPipe);
|
|
18
19
|
}
|
|
19
|
-
if (res
|
|
20
|
+
if (isResFinalized(res)) {
|
|
20
21
|
context.finalized = true;
|
|
21
22
|
} else {
|
|
22
23
|
await next();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ServerResponse } from "node:http";
|
|
2
|
+
import { isResFinalized } from "./helper";
|
|
2
3
|
import { installGlobals } from "./polyfills/install";
|
|
3
4
|
import { createReadableStreamFromReadable, writeReadableStreamToWritable } from "./polyfills/stream";
|
|
4
5
|
import { writeReadableStreamToWritable as writeReadableStreamToWritable2 } from "./polyfills";
|
|
@@ -80,7 +81,7 @@ const getRequestListener = (handler) => {
|
|
|
80
81
|
res
|
|
81
82
|
}
|
|
82
83
|
});
|
|
83
|
-
if (!
|
|
84
|
+
if (!response.res && !isResFinalized(res)) {
|
|
84
85
|
await sendResponse(response, res);
|
|
85
86
|
}
|
|
86
87
|
} catch (error) {
|
|
@@ -2,3 +2,5 @@ export { loadServerEnv } from './loadEnv';
|
|
|
2
2
|
export { loadServerPlugins } from './loadPlugin';
|
|
3
3
|
export { loadServerRuntimeConfig, loadServerCliConfig } from './loadConfig';
|
|
4
4
|
export { loadCacheConfig } from './loadCache';
|
|
5
|
+
export { isResFinalized } from './utils';
|
|
6
|
+
export type { NodeBindings } from './utils';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HonoRequest, NodeRequest, NodeResponse, ServerManifest } from '../../../types';
|
|
2
|
+
type ExtendedNodeRequest = NodeRequest & {
|
|
3
|
+
__honoRequest?: HonoRequest;
|
|
4
|
+
__templates?: Record<string, string>;
|
|
5
|
+
__serverManifest?: ServerManifest;
|
|
6
|
+
};
|
|
7
|
+
type ExtendedNodeResponse = NodeResponse & {
|
|
8
|
+
_modernBodyPiped?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type NodeBindings = {
|
|
11
|
+
node: {
|
|
12
|
+
req: ExtendedNodeRequest;
|
|
13
|
+
res: ExtendedNodeResponse;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare const isResFinalized: (res: ExtendedNodeResponse) => boolean;
|
|
17
|
+
export {};
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import type { Context,
|
|
2
|
-
type NodeBindings
|
|
3
|
-
node: {
|
|
4
|
-
req: NodeRequest & {
|
|
5
|
-
__honoRequest?: HonoRequest;
|
|
6
|
-
__templates?: Record<string, string>;
|
|
7
|
-
__serverManifest?: ServerManifest;
|
|
8
|
-
};
|
|
9
|
-
res: NodeResponse & {
|
|
10
|
-
_modernBodyPiped?: boolean;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
1
|
+
import type { Context, Middleware, Next, NodeRequest, NodeResponse, ServerEnv } from '../../types';
|
|
2
|
+
import { type NodeBindings } from './helper';
|
|
14
3
|
export type ServerNodeEnv = {
|
|
15
4
|
Bindings: NodeBindings;
|
|
16
5
|
};
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.60.
|
|
18
|
+
"version": "2.60.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.1",
|
|
56
|
-
"@modern-js/plugin": "2.60.
|
|
57
|
-
"@modern-js/runtime-utils": "2.60.
|
|
58
|
-
"@modern-js/utils": "2.60.
|
|
56
|
+
"@modern-js/plugin": "2.60.6",
|
|
57
|
+
"@modern-js/runtime-utils": "2.60.6",
|
|
58
|
+
"@modern-js/utils": "2.60.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.60.
|
|
69
|
-
"@scripts/jest-config": "2.60.
|
|
70
|
-
"@scripts/build": "2.60.
|
|
68
|
+
"@modern-js/types": "2.60.6",
|
|
69
|
+
"@scripts/jest-config": "2.60.6",
|
|
70
|
+
"@scripts/build": "2.60.6"
|
|
71
71
|
},
|
|
72
72
|
"sideEffects": false,
|
|
73
73
|
"publishConfig": {
|