@modern-js/prod-server 2.0.0-beta.7 → 2.0.0
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 +20 -0
- package/dist/types/libs/context/context.d.ts +3 -3
- package/dist/types/libs/render/cache/type.d.ts +4 -4
- package/dist/types/libs/render/cache/util.d.ts +2 -2
- package/dist/types/libs/render/type.d.ts +7 -7
- package/dist/types/libs/serve-file.d.ts +1 -1
- package/dist/types/server/modern-server.d.ts +2 -2
- package/dist/types/type.d.ts +9 -9
- package/dist/types/utils.d.ts +2 -2
- package/dist/types/worker-server.d.ts +2 -2
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @modern-js/prod-server
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- dda38c9c3e: chore: v2
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- c9e800d39a: feat: support React18 streaming SSR
|
|
12
|
+
feat: 支持 React18 流式 SSR
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [edd1cfb1af]
|
|
17
|
+
- Updated dependencies [dda38c9c3e]
|
|
18
|
+
- Updated dependencies [ffb2ed4]
|
|
19
|
+
- Updated dependencies [bbe4c4ab64]
|
|
20
|
+
- @modern-js/utils@2.0.0
|
|
21
|
+
- @modern-js/server-core@2.0.0
|
|
22
|
+
|
|
3
23
|
## 2.0.0-beta.7
|
|
4
24
|
|
|
5
25
|
### 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/
|
|
6
|
+
/// <reference types=".dts-temp/GthP9GiM25QuxdWDnQMoe/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
|
|
11
|
+
export type ContextOptions = {
|
|
12
12
|
etag?: boolean;
|
|
13
13
|
};
|
|
14
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
11
|
+
type CoalescedInvoke<T> = {
|
|
12
12
|
isOrigin: boolean;
|
|
13
13
|
value: T;
|
|
14
14
|
};
|
|
15
|
-
|
|
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
|
-
|
|
5
|
+
type MetaKeyMap = {
|
|
6
6
|
header?: string[];
|
|
7
7
|
query?: string[];
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
type MetaKeyMatch = {
|
|
10
10
|
header?: MatchMap;
|
|
11
11
|
query?: MatchMap;
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
export
|
|
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
|
|
27
|
+
export type SSRServerContext = BaseSSRServerContext & {
|
|
28
28
|
cacheConfig?: CacheConfig;
|
|
29
29
|
staticGenerate?: boolean;
|
|
30
30
|
};
|
|
31
|
-
export
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
package/dist/types/type.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare module 'http' {
|
|
|
13
13
|
metrics: Metrics;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
export
|
|
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
|
|
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
|
|
38
|
+
export type ConfWithBFF = {
|
|
39
39
|
bff?: {
|
|
40
40
|
prefix: string;
|
|
41
41
|
} & ServerOptions['bff'];
|
|
42
42
|
};
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
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
|
|
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
|
|
60
|
-
export
|
|
59
|
+
export type ServerConstructor = (options: ModernServerOptions) => ModernServerInterface;
|
|
60
|
+
export type ModernServerHandler = (context: ModernServerContext, next: NextFunction) => Promise<void> | void;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node/http" />
|
|
3
|
-
/// <reference types=".dts-temp/
|
|
3
|
+
/// <reference types=".dts-temp/GthP9GiM25QuxdWDnQMoe/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
|
|
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
|
|
2
|
+
export type Context = Record<string, any>;
|
|
3
3
|
export interface UrlQuery {
|
|
4
4
|
[key: string]: string;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
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
|
|
14
|
+
"version": "2.0.0",
|
|
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
|
|
60
|
-
"@modern-js/server-core": "2.0.0
|
|
58
|
+
"@modern-js/utils": "2.0.0",
|
|
59
|
+
"@modern-js/server-core": "2.0.0"
|
|
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
|
|
76
|
-
"@modern-js/server-core": "2.0.0
|
|
77
|
-
"@scripts/build": "2.0.0
|
|
78
|
-
"@scripts/jest-config": "2.0.0
|
|
75
|
+
"@modern-js/types": "2.0.0",
|
|
76
|
+
"@modern-js/server-core": "2.0.0",
|
|
77
|
+
"@scripts/build": "2.0.0",
|
|
78
|
+
"@scripts/jest-config": "2.0.0"
|
|
79
79
|
},
|
|
80
80
|
"sideEffects": false,
|
|
81
81
|
"publishConfig": {
|