@modern-js/prod-server 1.1.7 → 1.1.9

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @modern-js/prod-server
2
2
 
3
+ ## 1.1.9
4
+
5
+ ### Patch Changes
6
+
7
+ - f29e9ba: feat: simplify context usage, no longer depend on containers
8
+ - 2dacc89: support set header & status in render
9
+ - Updated dependencies [77a8e9e]
10
+ - Updated dependencies [f29e9ba]
11
+ - Updated dependencies [a90bc96]
12
+ - @modern-js/server-core@1.4.0
13
+ - @modern-js/utils@1.7.9
14
+
15
+ ## 1.1.8
16
+
17
+ ### Patch Changes
18
+
19
+ - a1198d509: feat: bump babel 7.18.0
20
+ - @modern-js/server-core@1.3.5
21
+
3
22
  ## 1.1.7
4
23
 
5
24
  ### Patch Changes
@@ -24,6 +24,14 @@ export const render = async (ctx, renderOptions, runner) => {
24
24
  cookieMap: cookie.parse(ctx.headers.cookie || ''),
25
25
  headers: ctx.headers
26
26
  },
27
+ response: {
28
+ setHeader: (key, value) => {
29
+ return ctx.res.setHeader(key, value);
30
+ },
31
+ status: code => {
32
+ ctx.res.statusCode = code;
33
+ }
34
+ },
27
35
  redirection: {},
28
36
  template,
29
37
  entryName,
@@ -164,24 +164,22 @@ export class Server {
164
164
  serverManager.usePlugin(p);
165
165
  }); // create runner
166
166
 
167
- const hooksRunner = await serverManager.init({});
167
+ const hooksRunner = await serverManager.init();
168
168
  return hooksRunner;
169
169
  }
170
170
 
171
171
  async injectContext(runner, options) {
172
+ var _config$output2;
173
+
172
174
  const appContext = this.initAppContext();
173
175
  const {
174
176
  config,
175
177
  pwd
176
178
  } = options;
177
- serverManager.run(() => {
178
- var _config$output2;
179
-
180
- ConfigContext.set(config);
181
- AppContext.set(_objectSpread(_objectSpread({}, appContext), {}, {
182
- distDirectory: path.join(pwd, ((_config$output2 = config.output) === null || _config$output2 === void 0 ? void 0 : _config$output2.path) || 'dist')
183
- }));
184
- });
179
+ ConfigContext.set(config);
180
+ AppContext.set(_objectSpread(_objectSpread({}, appContext), {}, {
181
+ distDirectory: path.join(pwd, ((_config$output2 = config.output) === null || _config$output2 === void 0 ? void 0 : _config$output2.path) || 'dist')
182
+ }));
185
183
  }
186
184
 
187
185
  initAppContext() {
@@ -40,6 +40,14 @@ const render = async (ctx, renderOptions, runner) => {
40
40
  cookieMap: _cookie.default.parse(ctx.headers.cookie || ''),
41
41
  headers: ctx.headers
42
42
  },
43
+ response: {
44
+ setHeader: (key, value) => {
45
+ return ctx.res.setHeader(key, value);
46
+ },
47
+ status: code => {
48
+ ctx.res.statusCode = code;
49
+ }
50
+ },
43
51
  redirection: {},
44
52
  template,
45
53
  entryName,
@@ -185,26 +185,24 @@ class Server {
185
185
  _serverCore.serverManager.usePlugin(p);
186
186
  }); // create runner
187
187
 
188
- const hooksRunner = await _serverCore.serverManager.init({});
188
+ const hooksRunner = await _serverCore.serverManager.init();
189
189
  return hooksRunner;
190
190
  }
191
191
 
192
192
  async injectContext(runner, options) {
193
+ var _config$output2;
194
+
193
195
  const appContext = this.initAppContext();
194
196
  const {
195
197
  config,
196
198
  pwd
197
199
  } = options;
198
200
 
199
- _serverCore.serverManager.run(() => {
200
- var _config$output2;
201
-
202
- _serverCore.ConfigContext.set(config);
201
+ _serverCore.ConfigContext.set(config);
203
202
 
204
- _serverCore.AppContext.set(_objectSpread(_objectSpread({}, appContext), {}, {
205
- distDirectory: _path.default.join(pwd, ((_config$output2 = config.output) === null || _config$output2 === void 0 ? void 0 : _config$output2.path) || 'dist')
206
- }));
207
- });
203
+ _serverCore.AppContext.set(_objectSpread(_objectSpread({}, appContext), {}, {
204
+ distDirectory: _path.default.join(pwd, ((_config$output2 = config.output) === null || _config$output2 === void 0 ? void 0 : _config$output2.path) || 'dist')
205
+ }));
208
206
  }
209
207
 
210
208
  initAppContext() {
@@ -1,5 +1,7 @@
1
1
  /// <reference path="../../type.d.ts" />
2
2
  /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ /// <reference types="node" />
3
5
  /// <reference types="node/http" />
4
6
  import { IncomingMessage, ServerResponse } from 'http';
5
7
  import { URL } from 'url';
@@ -1,4 +1,4 @@
1
1
  import { NextFunction, BffProxyOptions } from '@modern-js/types';
2
2
  import { ModernServerContext } from './context';
3
3
  export type { BffProxyOptions };
4
- export declare const createProxyHandler: (proxyOptions?: BffProxyOptions | undefined) => ((ctx: ModernServerContext, next: NextFunction) => Promise<void>)[] | null;
4
+ export declare const createProxyHandler: (proxyOptions?: BffProxyOptions) => ((ctx: ModernServerContext, next: NextFunction) => Promise<void>)[] | null;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { IncomingHttpHeaders } from 'http';
3
4
  import url from 'url';
4
5
  export declare function namespaceHash(namespace: string, hash: string): string;
@@ -40,7 +40,7 @@ export declare class Server {
40
40
  private initConfig;
41
41
  close(): Promise<void>;
42
42
  listen(port: number | undefined, listener: any): void;
43
- getRequestHandler(): (req: IncomingMessage, res: ServerResponse, next?: (() => void) | undefined) => void;
43
+ getRequestHandler(): (req: IncomingMessage, res: ServerResponse, next?: () => void) => void;
44
44
  private createHookRunner;
45
45
  private injectContext;
46
46
  private initAppContext;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { IncomingMessage, Server, ServerResponse } from 'http';
3
4
  import { serverManager } from '@modern-js/server-core';
4
5
  import type { ServerPlugin } from '@modern-js/server-core';
@@ -16,4 +16,4 @@ export declare const createMiddlewareCollecter: () => {
16
16
  };
17
17
  export declare const toPath: (reg: string, params: Record<string, any>) => string;
18
18
  export declare const getStaticReg: (output?: NormalizedConfig['output']) => RegExp;
19
- export declare const prepareFavicons: (favicon: string | undefined, faviconByEntries?: Record<string, string | undefined> | undefined) => string[];
19
+ export declare const prepareFavicons: (favicon: string | undefined, faviconByEntries?: Record<string, string | undefined>) => string[];
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.1.7",
14
+ "version": "1.1.9",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -28,9 +28,9 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@modern-js/utils": "^1.7.6",
32
- "@babel/compat-data": "^7.17.0",
33
- "@modern-js/server-core": "^1.3.5",
31
+ "@modern-js/utils": "^1.7.9",
32
+ "@babel/compat-data": "^7.17.10",
33
+ "@modern-js/server-core": "^1.4.0",
34
34
  "axios": "^0.24.0",
35
35
  "compare-versions": "^3.6.0",
36
36
  "cookie": "^0.4.2",
@@ -43,8 +43,8 @@
43
43
  "ua-parser-js": "^0.7.28"
44
44
  },
45
45
  "devDependencies": {
46
- "@modern-js/types": "1.5.4",
47
- "@modern-js/core": "1.11.1",
46
+ "@modern-js/types": "1.5.5",
47
+ "@modern-js/core": "1.12.2",
48
48
  "@scripts/jest-config": "0.0.0",
49
49
  "@scripts/build": "0.0.0",
50
50
  "@types/cookie": "^0.4.1",