@modern-js/prod-server 2.0.0-beta.7 → 2.0.1

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,32 @@
1
1
  # @modern-js/prod-server
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @modern-js/server-core@2.0.1
8
+ - @modern-js/utils@2.0.1
9
+
10
+ ## 2.0.0
11
+
12
+ ### Major Changes
13
+
14
+ - dda38c9c3e: chore: v2
15
+
16
+ ### Minor Changes
17
+
18
+ - c9e800d39a: feat: support React18 streaming SSR
19
+ feat: 支持 React18 流式 SSR
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [edd1cfb1af]
24
+ - Updated dependencies [dda38c9c3e]
25
+ - Updated dependencies [ffb2ed4]
26
+ - Updated dependencies [bbe4c4ab64]
27
+ - @modern-js/utils@2.0.0
28
+ - @modern-js/server-core@2.0.0
29
+
3
30
  ## 2.0.0-beta.7
4
31
 
5
32
  ### Major Changes
@@ -3,15 +3,15 @@
3
3
  /// <reference types="node" />
4
4
  /// <reference types="node" />
5
5
  /// <reference types="node/http" />
6
- /// <reference types=".dts-temp/Itwx-pHxmgYitwqD7Jzx4/src/type" />
6
+ /// <reference types=".dts-temp/00P3Om73mqEJBeKlEvTPx/src/type" />
7
7
  import { IncomingMessage, ServerResponse } from 'http';
8
8
  import { URL } from 'url';
9
9
  import qs from 'querystring';
10
10
  import type { ModernServerContext as ModernServerContextInterface } from '@modern-js/types';
11
- export declare type ContextOptions = {
11
+ export type ContextOptions = {
12
12
  etag?: boolean;
13
13
  };
14
- declare type ResponseBody = string | Buffer;
14
+ type ResponseBody = string | Buffer;
15
15
  export declare class ModernServerContext implements ModernServerContextInterface {
16
16
  /**
17
17
  * http request
@@ -2,7 +2,7 @@
2
2
  import { IncomingHttpHeaders } from 'http';
3
3
  import { RenderResult } from '../../../type';
4
4
  export type { CacheConfig } from '../type';
5
- export declare type CacheContent = {
5
+ export type CacheContent = {
6
6
  level: number;
7
7
  includes: {
8
8
  header?: string[];
@@ -25,14 +25,14 @@ export interface PageCachesInterface {
25
25
  del: (key: string) => void;
26
26
  keys: () => string[];
27
27
  }
28
- export declare type PageCache = {
28
+ export type PageCache = {
29
29
  html: string;
30
30
  expireTime: number;
31
31
  limitTime: number | null;
32
32
  cacheHash: string;
33
33
  size: number;
34
34
  };
35
- export declare type CacheManagerOptions = {
35
+ export type CacheManagerOptions = {
36
36
  max: number;
37
37
  };
38
38
  export interface CacheResult extends RenderResult {
@@ -40,7 +40,7 @@ export interface CacheResult extends RenderResult {
40
40
  isGarbage: boolean;
41
41
  hash: string;
42
42
  }
43
- export declare type CacheContext = {
43
+ export type CacheContext = {
44
44
  entry: string;
45
45
  pathname: string;
46
46
  query: Record<string, string>;
@@ -8,11 +8,11 @@ export declare function connectFactor(...args: string[]): string;
8
8
  export declare function valueFactory(obj: url.URLSearchParams | IncomingHttpHeaders): ((key: string) => string | null) | ((key: string) => string | undefined);
9
9
  export declare function getTime([s, ns]: [number, number]): number;
10
10
  export declare function cacheAddition(html: string, hash: string): string;
11
- declare type CoalescedInvoke<T> = {
11
+ type CoalescedInvoke<T> = {
12
12
  isOrigin: boolean;
13
13
  value: T;
14
14
  };
15
- declare type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
15
+ type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
16
16
  export declare function withCoalescedInvoke<F extends (...args: any[]) => Promise<any>>(func: F): (key: string, args: Parameters<F>) => Promise<CoalescedInvoke<UnwrapPromise<ReturnType<F>>>>;
17
17
  export declare function maybeSync(fn: () => Promise<any>): (sync: boolean) => Promise<any>;
18
18
  export {};
@@ -2,16 +2,16 @@
2
2
  /// <reference types="node" />
3
3
  import { Writable, Readable } from 'stream';
4
4
  import { BaseSSRServerContext } from '@modern-js/types';
5
- declare type MetaKeyMap = {
5
+ type MetaKeyMap = {
6
6
  header?: string[];
7
7
  query?: string[];
8
8
  };
9
- declare type MetaKeyMatch = {
9
+ type MetaKeyMatch = {
10
10
  header?: MatchMap;
11
11
  query?: MatchMap;
12
12
  };
13
- declare type MatchMap = Record<string, Record<string, string>>;
14
- export declare type CacheConfig = {
13
+ type MatchMap = Record<string, Record<string, string>>;
14
+ export type CacheConfig = {
15
15
  interval: number;
16
16
  staleLimit: number | boolean;
17
17
  level: number;
@@ -24,13 +24,13 @@ export declare enum RenderLevel {
24
24
  SERVER_PREFETCH = 1,
25
25
  SERVER_RENDER = 2,
26
26
  }
27
- export declare type SSRServerContext = BaseSSRServerContext & {
27
+ export type SSRServerContext = BaseSSRServerContext & {
28
28
  cacheConfig?: CacheConfig;
29
29
  staticGenerate?: boolean;
30
30
  };
31
- export declare type ModernSSRReactComponent = React.ComponentType<any> & {
31
+ export type ModernSSRReactComponent = React.ComponentType<any> & {
32
32
  init: (context: SSRServerContext) => Promise<void>;
33
33
  prefetch: (context: SSRServerContext) => Promise<Record<string, any>>;
34
34
  };
35
- export declare type RenderFunction = (context: SSRServerContext) => Promise<string | ((writable: Writable) => Promise<Readable>)>;
35
+ export type RenderFunction = (context: SSRServerContext) => Promise<string | ((writable: Writable) => Promise<Readable>)>;
36
36
  export {};
@@ -1,7 +1,7 @@
1
1
  import { ServerOptions } from '@modern-js/server-core';
2
2
  import type { ModernServerContext } from '@modern-js/types';
3
3
  import { NextFunction, ModernServerHandler } from '../type';
4
- declare type Rule = {
4
+ type Rule = {
5
5
  path: string | RegExp;
6
6
  target: string;
7
7
  };
@@ -7,7 +7,7 @@ import { ModernServerOptions, NextFunction, ServerHookRunner, Metrics, Logger, M
7
7
  import { RouteMatchManager, ModernRouteInterface, ModernRoute } from '../libs/route';
8
8
  import { mergeExtension } from '../utils';
9
9
  import * as reader from '../libs/render/reader';
10
- declare type ModernServerAsyncHandler = (context: ModernServerContext, next: NextFunction) => Promise<void>;
10
+ type ModernServerAsyncHandler = (context: ModernServerContext, next: NextFunction) => Promise<void>;
11
11
  export declare class ModernServer implements ModernServerInterface {
12
12
  pwd: string;
13
13
  distDir: string;
@@ -50,7 +50,7 @@ export declare class ModernServer implements ModernServerInterface {
50
50
  }): void;
51
51
  getRequestHandler(): (req: IncomingMessage, res: ServerResponse, next?: () => void) => void | ServerResponse;
52
52
  render(req: IncomingMessage, res: ServerResponse, url?: string): Promise<string | null>;
53
- createHTTPServer(handler: (req: IncomingMessage, res: ServerResponse, next?: () => void) => void): Promise<Server>;
53
+ createHTTPServer(handler: (req: IncomingMessage, res: ServerResponse, next?: () => void) => void): Promise<Server<typeof IncomingMessage, typeof ServerResponse>>;
54
54
  protected getRoutes(): ServerRoute[];
55
55
  protected addHandler(handler: ModernServerHandler): void;
56
56
  protected render404(context: ModernServerContext): void;
@@ -13,7 +13,7 @@ declare module 'http' {
13
13
  metrics: Metrics;
14
14
  }
15
15
  }
16
- export declare type ModernServerOptions = {
16
+ export type ModernServerOptions = {
17
17
  pwd: string;
18
18
  config: ServerOptions;
19
19
  plugins?: ServerPlugin[];
@@ -28,25 +28,25 @@ export declare type ModernServerOptions = {
28
28
  runMode?: string;
29
29
  [propName: string]: any;
30
30
  };
31
- export declare type RenderResult = {
31
+ export type RenderResult = {
32
32
  content: string | Buffer;
33
33
  contentType: string;
34
34
  contentStream?: Readable;
35
35
  statusCode?: number;
36
36
  redirect?: boolean;
37
37
  };
38
- export declare type ConfWithBFF = {
38
+ export type ConfWithBFF = {
39
39
  bff?: {
40
40
  prefix: string;
41
41
  } & ServerOptions['bff'];
42
42
  };
43
- export declare type Then<T> = T extends PromiseLike<infer U> ? U : T;
44
- export declare type ServerHookRunner = Then<ReturnType<typeof serverManager.init>>;
45
- export declare type BuildOptions = {
43
+ export type Then<T> = T extends PromiseLike<infer U> ? U : T;
44
+ export type ServerHookRunner = Then<ReturnType<typeof serverManager.init>>;
45
+ export type BuildOptions = {
46
46
  routes?: ModernRouteInterface[];
47
47
  };
48
48
  export type { Metrics, Logger, NextFunction };
49
- export declare type HookNames = 'afterMatch' | 'afterRender';
49
+ export type HookNames = 'afterMatch' | 'afterRender';
50
50
  export interface ModernServerInterface {
51
51
  pwd: string;
52
52
  distDir: string;
@@ -56,5 +56,5 @@ export interface ModernServerInterface {
56
56
  createHTTPServer: (handler: (req: IncomingMessage, res: ServerResponse, next?: () => void) => void) => Promise<Server>;
57
57
  render: (req: IncomingMessage, res: ServerResponse, url?: string) => Promise<string | null>;
58
58
  }
59
- export declare type ServerConstructor = (options: ModernServerOptions) => ModernServerInterface;
60
- export declare type ModernServerHandler = (context: ModernServerContext, next: NextFunction) => Promise<void> | void;
59
+ export type ServerConstructor = (options: ModernServerOptions) => ModernServerInterface;
60
+ export type ModernServerHandler = (context: ModernServerContext, next: NextFunction) => Promise<void> | void;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node/http" />
3
- /// <reference types=".dts-temp/Itwx-pHxmgYitwqD7Jzx4/src/type" />
3
+ /// <reference types=".dts-temp/00P3Om73mqEJBeKlEvTPx/src/type" />
4
4
  import { IncomingMessage } from 'http';
5
5
  import type { OutputNormalizedConfig, HtmlNormalizedConfig } from '@modern-js/server-core';
6
6
  export declare const debug: any;
@@ -9,7 +9,7 @@ export declare const mergeExtension: (users: any[]) => {
9
9
  };
10
10
  export declare const noop: () => void;
11
11
  export declare const createErrorDocument: (status: number, text: string) => string;
12
- export declare type CollectMiddlewaresResult = {
12
+ export type CollectMiddlewaresResult = {
13
13
  web: any[];
14
14
  api: any[];
15
15
  };
@@ -1,9 +1,9 @@
1
1
  import { ModernRouteInterface } from './libs/route';
2
- export declare type Context = Record<string, any>;
2
+ export type Context = Record<string, any>;
3
3
  export interface UrlQuery {
4
4
  [key: string]: string;
5
5
  }
6
- export declare type Manifest = {
6
+ export type Manifest = {
7
7
  pages: Record<string, // path
8
8
  {
9
9
  entryName: string;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.0-beta.7",
14
+ "version": "2.0.1",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -46,7 +46,6 @@
46
46
  }
47
47
  },
48
48
  "dependencies": {
49
- "axios": "^0.24.0",
50
49
  "etag": "^1.8.1",
51
50
  "fresh": "^0.5.2",
52
51
  "cookie": "^0.4.2",
@@ -56,8 +55,8 @@
56
55
  "merge-deep": "^3.0.3",
57
56
  "path-to-regexp": "^6.2.0",
58
57
  "serve-static": "^1.14.1",
59
- "@modern-js/utils": "2.0.0-beta.7",
60
- "@modern-js/server-core": "2.0.0-beta.7"
58
+ "@modern-js/utils": "2.0.1",
59
+ "@modern-js/server-core": "2.0.1"
61
60
  },
62
61
  "devDependencies": {
63
62
  "@types/cookie": "^0.4.1",
@@ -68,14 +67,15 @@
68
67
  "@types/etag": "^1.8.1",
69
68
  "@types/fresh": "^0.5.0",
70
69
  "@types/serve-static": "^1.13.10",
70
+ "axios": "^1.2.1",
71
71
  "jest": "^27",
72
72
  "node-mocks-http": "^1.11.0",
73
73
  "portfinder": "^1.0.28",
74
74
  "typescript": "^4",
75
- "@modern-js/types": "2.0.0-beta.7",
76
- "@modern-js/server-core": "2.0.0-beta.7",
77
- "@scripts/build": "2.0.0-beta.7",
78
- "@scripts/jest-config": "2.0.0-beta.7"
75
+ "@modern-js/types": "2.0.1",
76
+ "@modern-js/server-core": "2.0.1",
77
+ "@scripts/build": "2.0.1",
78
+ "@scripts/jest-config": "2.0.1"
79
79
  },
80
80
  "sideEffects": false,
81
81
  "publishConfig": {