@modern-js/server-core 2.65.4 → 2.65.5

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.
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var hono_exports = {};
20
20
  __export(hono_exports, {
21
21
  connectMid2HonoMid: () => connectMid2HonoMid,
22
+ connectMockMid2HonoMid: () => connectMockMid2HonoMid,
22
23
  httpCallBack2HonoMid: () => httpCallBack2HonoMid
23
24
  });
24
25
  module.exports = __toCommonJS(hono_exports);
@@ -68,8 +69,31 @@ const connectMid2HonoMid = (handler) => {
68
69
  });
69
70
  };
70
71
  };
72
+ const connectMockMid2HonoMid = (handler) => {
73
+ return async (context, next) => {
74
+ return new Promise((resolve, reject) => {
75
+ const { req, res } = context.env.node;
76
+ if (handler.length < 3) {
77
+ res.once("finish", () => {
78
+ context.finalized = true;
79
+ resolve();
80
+ });
81
+ handler(req, res, noop);
82
+ } else {
83
+ handler(req, res, (err) => {
84
+ if (err) {
85
+ reject(err);
86
+ } else {
87
+ resolve(next());
88
+ }
89
+ });
90
+ }
91
+ });
92
+ };
93
+ };
71
94
  // Annotate the CommonJS export names for ESM import in node:
72
95
  0 && (module.exports = {
73
96
  connectMid2HonoMid,
97
+ connectMockMid2HonoMid,
74
98
  httpCallBack2HonoMid
75
99
  });
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var node_exports = {};
20
20
  __export(node_exports, {
21
21
  connectMid2HonoMid: () => import_hono.connectMid2HonoMid,
22
+ connectMockMid2HonoMid: () => import_hono.connectMockMid2HonoMid,
22
23
  createNodeServer: () => import_node.createNodeServer,
23
24
  createWebRequest: () => import_node.createWebRequest,
24
25
  getHtmlTemplates: () => import_plugins.getHtmlTemplates,
@@ -44,6 +45,7 @@ var import_helper = require("./helper");
44
45
  // Annotate the CommonJS export names for ESM import in node:
45
46
  0 && (module.exports = {
46
47
  connectMid2HonoMid,
48
+ connectMockMid2HonoMid,
47
49
  createNodeServer,
48
50
  createWebRequest,
49
51
  getHtmlTemplates,
@@ -103,7 +103,40 @@ var connectMid2HonoMid = function(handler) {
103
103
  };
104
104
  }();
105
105
  };
106
+ var connectMockMid2HonoMid = function(handler) {
107
+ return function() {
108
+ var _ref = _async_to_generator(function(context, next) {
109
+ return _ts_generator(this, function(_state) {
110
+ return [
111
+ 2,
112
+ new Promise(function(resolve, reject) {
113
+ var _context_env_node = context.env.node, req = _context_env_node.req, res = _context_env_node.res;
114
+ if (handler.length < 3) {
115
+ res.once("finish", function() {
116
+ context.finalized = true;
117
+ resolve();
118
+ });
119
+ handler(req, res, noop);
120
+ } else {
121
+ handler(req, res, function(err) {
122
+ if (err) {
123
+ reject(err);
124
+ } else {
125
+ resolve(next());
126
+ }
127
+ });
128
+ }
129
+ })
130
+ ];
131
+ });
132
+ });
133
+ return function(context, next) {
134
+ return _ref.apply(this, arguments);
135
+ };
136
+ }();
137
+ };
106
138
  export {
107
139
  connectMid2HonoMid,
140
+ connectMockMid2HonoMid,
108
141
  httpCallBack2HonoMid
109
142
  };
@@ -1,9 +1,10 @@
1
- import { httpCallBack2HonoMid, connectMid2HonoMid } from "./hono";
1
+ import { httpCallBack2HonoMid, connectMid2HonoMid, connectMockMid2HonoMid } from "./hono";
2
2
  import { createNodeServer, sendResponse, createWebRequest, writeReadableStreamToWritable } from "./node";
3
3
  import { serverStaticPlugin, injectResourcePlugin, getHtmlTemplates, getServerManifest, injectNodeSeverPlugin, injectRscManifestPlugin } from "./plugins";
4
4
  import { loadServerPlugins, loadServerEnv, loadServerRuntimeConfig, loadServerCliConfig, loadCacheConfig } from "./helper";
5
5
  export {
6
6
  connectMid2HonoMid,
7
+ connectMockMid2HonoMid,
7
8
  createNodeServer,
8
9
  createWebRequest,
9
10
  getHtmlTemplates,
@@ -44,7 +44,30 @@ const connectMid2HonoMid = (handler) => {
44
44
  });
45
45
  };
46
46
  };
47
+ const connectMockMid2HonoMid = (handler) => {
48
+ return async (context, next) => {
49
+ return new Promise((resolve, reject) => {
50
+ const { req, res } = context.env.node;
51
+ if (handler.length < 3) {
52
+ res.once("finish", () => {
53
+ context.finalized = true;
54
+ resolve();
55
+ });
56
+ handler(req, res, noop);
57
+ } else {
58
+ handler(req, res, (err) => {
59
+ if (err) {
60
+ reject(err);
61
+ } else {
62
+ resolve(next());
63
+ }
64
+ });
65
+ }
66
+ });
67
+ };
68
+ };
47
69
  export {
48
70
  connectMid2HonoMid,
71
+ connectMockMid2HonoMid,
49
72
  httpCallBack2HonoMid
50
73
  };
@@ -1,9 +1,10 @@
1
- import { httpCallBack2HonoMid, connectMid2HonoMid } from "./hono";
1
+ import { httpCallBack2HonoMid, connectMid2HonoMid, connectMockMid2HonoMid } from "./hono";
2
2
  import { createNodeServer, sendResponse, createWebRequest, writeReadableStreamToWritable } from "./node";
3
3
  import { serverStaticPlugin, injectResourcePlugin, getHtmlTemplates, getServerManifest, injectNodeSeverPlugin, injectRscManifestPlugin } from "./plugins";
4
4
  import { loadServerPlugins, loadServerEnv, loadServerRuntimeConfig, loadServerCliConfig, loadCacheConfig } from "./helper";
5
5
  export {
6
6
  connectMid2HonoMid,
7
+ connectMockMid2HonoMid,
7
8
  createNodeServer,
8
9
  createWebRequest,
9
10
  getHtmlTemplates,
@@ -9,4 +9,10 @@ type Handler = (req: NodeRequest, res: NodeResponse) => void | Promise<void>;
9
9
  export declare const httpCallBack2HonoMid: (handler: Handler) => (context: Context<ServerNodeEnv & ServerEnv>, next: Next) => Promise<void>;
10
10
  type ConnectMiddleware = ((req: NodeRequest, res: NodeResponse, callback: (...args: unknown[]) => void) => void) | ((req: NodeRequest, res: NodeResponse) => void);
11
11
  export declare const connectMid2HonoMid: (handler: ConnectMiddleware) => Middleware;
12
+ /**
13
+ * Because we are not sure how use devServer.before and devServer.after, we add a new function to handle the mock middleware
14
+ * And we supose mock handler always process the res directly
15
+ * So we need to set the context.finalized = true and resolve the promise
16
+ */
17
+ export declare const connectMockMid2HonoMid: (handler: ConnectMiddleware) => Middleware;
12
18
  export {};
@@ -1,4 +1,4 @@
1
- export { httpCallBack2HonoMid, connectMid2HonoMid } from './hono';
1
+ export { httpCallBack2HonoMid, connectMid2HonoMid, connectMockMid2HonoMid, } from './hono';
2
2
  export type { ServerNodeContext, ServerNodeMiddleware } from './hono';
3
3
  export { createNodeServer, sendResponse, createWebRequest, writeReadableStreamToWritable, } from './node';
4
4
  export { serverStaticPlugin, injectResourcePlugin, getHtmlTemplates, getServerManifest, injectNodeSeverPlugin, injectRscManifestPlugin, } from './plugins';
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.65.4",
18
+ "version": "2.65.5",
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.65.4",
57
- "@modern-js/runtime-utils": "2.65.4",
58
- "@modern-js/utils": "2.65.4"
56
+ "@modern-js/plugin": "2.65.5",
57
+ "@modern-js/utils": "2.65.5",
58
+ "@modern-js/runtime-utils": "2.65.5"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@types/jest": "^29",
@@ -65,15 +65,14 @@
65
65
  "jest": "^29",
66
66
  "ts-jest": "^29.1.0",
67
67
  "typescript": "^5",
68
- "@modern-js/types": "2.65.4",
69
- "@scripts/build": "2.65.4",
70
- "@scripts/jest-config": "2.65.4"
68
+ "@modern-js/types": "2.65.5",
69
+ "@scripts/build": "2.65.5",
70
+ "@scripts/jest-config": "2.65.5"
71
71
  },
72
72
  "sideEffects": false,
73
73
  "publishConfig": {
74
74
  "registry": "https://registry.npmjs.org/",
75
- "access": "public",
76
- "provenance": true
75
+ "access": "public"
77
76
  },
78
77
  "scripts": {
79
78
  "new": "modern-lib new",