@modern-js/prod-server 2.41.0 → 2.42.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/dist/cjs/libs/hook-api/index.js +2 -1
- package/dist/cjs/libs/hook-api/index.worker.js +2 -1
- package/dist/cjs/server/modernServer.js +1 -1
- package/dist/cjs/workerServer.js +20 -5
- package/dist/esm/libs/hook-api/index.js +2 -1
- package/dist/esm/libs/hook-api/index.worker.js +2 -1
- package/dist/esm/server/modernServer.js +1 -1
- package/dist/esm/workerServer.js +54 -6
- package/dist/esm-node/libs/hook-api/index.js +2 -1
- package/dist/esm-node/libs/hook-api/index.worker.js +2 -1
- package/dist/esm-node/server/modernServer.js +1 -1
- package/dist/esm-node/workerServer.js +20 -5
- package/dist/types/constants.d.ts +20 -20
- package/dist/types/index.d.ts +1 -1
- package/dist/types/libs/context/context.d.ts +50 -50
- package/dist/types/libs/context/index.d.ts +1 -1
- package/dist/types/libs/hook-api/base.d.ts +43 -43
- package/dist/types/libs/hook-api/index.d.ts +3 -3
- package/dist/types/libs/hook-api/index.worker.d.ts +13 -13
- package/dist/types/libs/hook-api/route.d.ts +8 -8
- package/dist/types/libs/hook-api/template.d.ts +18 -18
- package/dist/types/libs/hook-api/templateForStream.d.ts +6 -11
- package/dist/types/libs/loadConfig.d.ts +5 -9
- package/dist/types/libs/metrics.d.ts +1 -1
- package/dist/types/libs/preload/flushServerHeader.d.ts +6 -12
- package/dist/types/libs/preload/index.d.ts +1 -1
- package/dist/types/libs/preload/parseLinks.d.ts +9 -13
- package/dist/types/libs/preload/shouldFlushServerHeader.d.ts +1 -1
- package/dist/types/libs/preload/transformLinks2String.d.ts +1 -1
- package/dist/types/libs/proxy.d.ts +3 -3
- package/dist/types/libs/render/cache/__tests__/cache.fun.test.d.ts +1 -1
- package/dist/types/libs/render/cache/__tests__/cache.test.d.ts +1 -1
- package/dist/types/libs/render/cache/__tests__/cacheable.d.ts +58 -58
- package/dist/types/libs/render/cache/__tests__/error-configuration.d.ts +23 -23
- package/dist/types/libs/render/cache/__tests__/matched-cache.d.ts +101 -101
- package/dist/types/libs/render/cache/index.d.ts +1 -1
- package/dist/types/libs/render/cache/page-caches/index.d.ts +1 -1
- package/dist/types/libs/render/cache/page-caches/lru.d.ts +12 -12
- package/dist/types/libs/render/cache/spr.d.ts +16 -16
- package/dist/types/libs/render/cache/type.d.ts +33 -33
- package/dist/types/libs/render/cache/util.d.ts +3 -3
- package/dist/types/libs/render/index.d.ts +11 -11
- package/dist/types/libs/render/measure.d.ts +6 -6
- package/dist/types/libs/render/reader.d.ts +13 -13
- package/dist/types/libs/render/ssr.d.ts +9 -9
- package/dist/types/libs/render/static.d.ts +1 -1
- package/dist/types/libs/render/type.d.ts +18 -18
- package/dist/types/libs/render/utils.d.ts +1 -1
- package/dist/types/libs/reporter.d.ts +1 -1
- package/dist/types/libs/route/index.d.ts +10 -10
- package/dist/types/libs/route/matcher.d.ts +12 -12
- package/dist/types/libs/route/route.d.ts +11 -11
- package/dist/types/libs/serveFile.d.ts +3 -3
- package/dist/types/libs/serverTiming.d.ts +8 -8
- package/dist/types/renderHtml.d.ts +15 -15
- package/dist/types/server/index.d.ts +46 -48
- package/dist/types/server/modernServer.d.ts +57 -69
- package/dist/types/server/modernServerSplit.d.ts +1 -1
- package/dist/types/type.d.ts +48 -48
- package/dist/types/utils.d.ts +8 -8
- package/dist/types/workerServer.d.ts +45 -45
- package/package.json +9 -9
|
@@ -3,46 +3,46 @@ import { IncomingHttpHeaders } from 'http';
|
|
|
3
3
|
import { RenderResult } from '../../../type';
|
|
4
4
|
export type { CacheConfig } from '../type';
|
|
5
5
|
export type CacheContent = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
level: number;
|
|
7
|
+
includes: {
|
|
8
|
+
header?: string[];
|
|
9
|
+
query?: string[];
|
|
10
|
+
} | null;
|
|
11
|
+
matches?: {
|
|
12
|
+
header?: Record<string, Record<string, string>>;
|
|
13
|
+
query?: Record<string, Record<string, string>>;
|
|
14
|
+
} | null;
|
|
15
|
+
interval: number;
|
|
16
|
+
limit: number | boolean;
|
|
17
|
+
caches: PageCachesInterface;
|
|
18
18
|
};
|
|
19
19
|
export interface PageCachesInterface {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
caches: any;
|
|
21
|
+
init: () => void;
|
|
22
|
+
get: (key: string) => Promise<PageCache | null>;
|
|
23
|
+
peek: (key: string) => PageCache | null;
|
|
24
|
+
set: (key: string, cache: PageCache) => Promise<void>;
|
|
25
|
+
del: (key: string) => void;
|
|
26
|
+
keys: () => string[];
|
|
27
27
|
}
|
|
28
28
|
export type PageCache = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
html: string;
|
|
30
|
+
expireTime: number;
|
|
31
|
+
limitTime: number | null;
|
|
32
|
+
cacheHash: string;
|
|
33
|
+
size: number;
|
|
34
34
|
};
|
|
35
35
|
export type CacheManagerOptions = {
|
|
36
|
-
|
|
36
|
+
max: number;
|
|
37
37
|
};
|
|
38
38
|
export interface CacheResult extends RenderResult {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
isStale: boolean;
|
|
40
|
+
isGarbage: boolean;
|
|
41
|
+
hash: string;
|
|
42
42
|
}
|
|
43
43
|
export type CacheContext = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
44
|
+
entry: string;
|
|
45
|
+
pathname: string;
|
|
46
|
+
query: Record<string, string>;
|
|
47
|
+
headers: IncomingHttpHeaders;
|
|
48
|
+
};
|
|
@@ -9,10 +9,10 @@ export declare function valueFactory(obj: url.URLSearchParams | IncomingHttpHead
|
|
|
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
|
-
|
|
13
|
-
|
|
12
|
+
isOrigin: boolean;
|
|
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
|
-
export {};
|
|
18
|
+
export {};
|
|
@@ -4,18 +4,18 @@ import { RenderResult, ServerHookRunner } from '../../type';
|
|
|
4
4
|
import { ModernRoute } from '../route';
|
|
5
5
|
import * as ssr from './ssr';
|
|
6
6
|
export type RenderHandler = (options: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
ctx: ModernServerContext;
|
|
8
|
+
route: ModernRoute;
|
|
9
|
+
runner: ServerHookRunner;
|
|
10
10
|
}) => Promise<RenderResult | null>;
|
|
11
11
|
type CreateRenderHandler = (ctx: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
distDir: string;
|
|
13
|
+
staticGenerate: boolean;
|
|
14
|
+
conf: ServerOptions;
|
|
15
|
+
ssrRender?: typeof ssr.render;
|
|
16
|
+
forceCSR?: boolean;
|
|
17
|
+
nonce?: string;
|
|
18
|
+
metaName?: string;
|
|
19
19
|
}) => RenderHandler;
|
|
20
20
|
export declare const createRenderHandler: CreateRenderHandler;
|
|
21
|
-
export {};
|
|
21
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BaseSSRServerContext, Logger, Metrics } from '@modern-js/types';
|
|
2
2
|
export declare const createMetrics: (context: BaseSSRServerContext, metrics: Metrics) => {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
emitTimer: (name: string, cost: number, tags?: Record<string, unknown>) => void;
|
|
4
|
+
emitCounter: (name: string, counter: number, tags?: Record<string, unknown>) => void;
|
|
5
5
|
};
|
|
6
6
|
export declare const createLogger: (serverContext: BaseSSRServerContext, logger: Logger) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
7
|
+
error: (message: string, e: Error | string) => void;
|
|
8
|
+
info: (message: string, ...args: any[]) => void;
|
|
9
|
+
debug: (message: string, ...args: any[]) => void;
|
|
10
|
+
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { IFs } from 'memfs';
|
|
3
3
|
export declare class LruReader {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
private readonly cache;
|
|
5
|
+
private fs;
|
|
6
|
+
constructor();
|
|
7
|
+
init(fs?: IFs): void;
|
|
8
|
+
close(): void;
|
|
9
|
+
read(filepath: string): Promise<{
|
|
10
|
+
content: Buffer;
|
|
11
|
+
mtime: Date;
|
|
12
|
+
} | {
|
|
13
|
+
content: Buffer;
|
|
14
|
+
} | null>;
|
|
15
|
+
update(): void;
|
|
16
16
|
}
|
|
17
17
|
export declare const readFile: (filepath: string) => Promise<Buffer | undefined>;
|
|
18
18
|
export declare const updateFile: () => void;
|
|
19
19
|
export declare const init: (fs?: IFs) => void;
|
|
20
|
-
export declare const close: () => void;
|
|
20
|
+
export declare const close: () => void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ModernServerContext } from '@modern-js/types';
|
|
2
2
|
import { RenderResult, ServerHookRunner } from '../../type';
|
|
3
3
|
export declare const render: (ctx: ModernServerContext, renderOptions: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}, runner: ServerHookRunner) => Promise<RenderResult>;
|
|
4
|
+
distDir: string;
|
|
5
|
+
bundle: string;
|
|
6
|
+
urlPath: string;
|
|
7
|
+
template: string;
|
|
8
|
+
entryName: string;
|
|
9
|
+
staticGenerate: boolean;
|
|
10
|
+
enableUnsafeCtx?: boolean;
|
|
11
|
+
nonce?: string;
|
|
12
|
+
}, runner: ServerHookRunner) => Promise<RenderResult>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ModernServerContext } from '@modern-js/types';
|
|
2
2
|
import { RenderResult } from '../../type';
|
|
3
|
-
export declare function handleDirectory(ctx: ModernServerContext, entryPath: string, urlPath: string): Promise<RenderResult | null>;
|
|
3
|
+
export declare function handleDirectory(ctx: ModernServerContext, entryPath: string, urlPath: string): Promise<RenderResult | null>;
|
|
@@ -3,34 +3,34 @@
|
|
|
3
3
|
import { Writable, Readable } from 'stream';
|
|
4
4
|
import { BaseSSRServerContext } from '@modern-js/types';
|
|
5
5
|
type MetaKeyMap = {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
header?: string[];
|
|
7
|
+
query?: string[];
|
|
8
8
|
};
|
|
9
9
|
type MetaKeyMatch = {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
header?: MatchMap;
|
|
11
|
+
query?: MatchMap;
|
|
12
12
|
};
|
|
13
13
|
type MatchMap = Record<string, Record<string, string>>;
|
|
14
14
|
export type CacheConfig = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
interval: number;
|
|
16
|
+
staleLimit: number | boolean;
|
|
17
|
+
level: number;
|
|
18
|
+
includes?: MetaKeyMap | null;
|
|
19
|
+
excludes?: MetaKeyMap | null;
|
|
20
|
+
matches?: MetaKeyMatch | null;
|
|
21
21
|
};
|
|
22
22
|
export declare enum RenderLevel {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
CLIENT_RENDER = 0,
|
|
24
|
+
SERVER_PREFETCH = 1,
|
|
25
|
+
SERVER_RENDER = 2
|
|
26
26
|
}
|
|
27
27
|
export type SSRServerContext = BaseSSRServerContext & {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
cacheConfig?: CacheConfig;
|
|
29
|
+
staticGenerate?: boolean;
|
|
30
30
|
};
|
|
31
31
|
export type ModernSSRReactComponent = React.ComponentType<any> & {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
init: (context: SSRServerContext) => Promise<void>;
|
|
33
|
+
prefetch: (context: SSRServerContext) => Promise<Record<string, any>>;
|
|
34
34
|
};
|
|
35
35
|
export type RenderFunction = (context: SSRServerContext) => Promise<string | ((writable: Writable) => Promise<Readable>)>;
|
|
36
|
-
export {};
|
|
36
|
+
export {};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Readable } from 'stream';
|
|
3
3
|
import type { ModernServerContext } from '@modern-js/types';
|
|
4
4
|
export declare const injectServerData: (content: string, context: ModernServerContext) => string;
|
|
5
|
-
export declare const injectServerDataStream: (content: Readable, context: ModernServerContext) => import("stream").Transform;
|
|
5
|
+
export declare const injectServerDataStream: (content: Readable, context: ModernServerContext) => import("stream").Transform;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Reporter } from '@modern-js/types/server';
|
|
2
|
-
export declare const defaultReporter: Reporter;
|
|
2
|
+
export declare const defaultReporter: Reporter;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { RouteMatcher } from './matcher';
|
|
2
2
|
import { ModernRoute, ModernRouteInterface } from './route';
|
|
3
3
|
export declare class RouteMatchManager {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
matchers: RouteMatcher[];
|
|
5
|
+
private specs;
|
|
6
|
+
constructor();
|
|
7
|
+
private filter;
|
|
8
|
+
private best;
|
|
9
|
+
reset(specs: ModernRouteInterface[]): void;
|
|
10
|
+
match(pathname: string): RouteMatcher | undefined;
|
|
11
|
+
matchEntry(entryname: string): RouteMatcher | undefined;
|
|
12
|
+
getBundles(): (string | undefined)[];
|
|
13
13
|
}
|
|
14
14
|
export type { ModernRouteInterface, ModernRoute };
|
|
15
|
-
export { RouteMatcher };
|
|
15
|
+
export { RouteMatcher };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { MatchFunction } from 'path-to-regexp';
|
|
2
2
|
import { ModernRoute, ModernRouteInterface } from './route';
|
|
3
3
|
export declare class RouteMatcher {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
4
|
+
spec: ModernRouteInterface;
|
|
5
|
+
urlPath: string;
|
|
6
|
+
urlMatcher?: MatchFunction;
|
|
7
|
+
urlReg?: RegExp;
|
|
8
|
+
constructor(spec: ModernRouteInterface);
|
|
9
|
+
generate(url: string): ModernRoute;
|
|
10
|
+
parseURLParams(pathname: string): Record<string, string>;
|
|
11
|
+
matchLength(pathname: string): number | null;
|
|
12
|
+
matchUrlPath(requestUrl: string): boolean;
|
|
13
|
+
matchEntry(entryName: string): boolean;
|
|
14
|
+
private setupUrlPath;
|
|
15
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ServerRoute as ModernRouteInterface } from '@modern-js/types';
|
|
2
2
|
export type { ModernRouteInterface };
|
|
3
3
|
export declare class ModernRoute implements ModernRouteInterface {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
4
|
+
entryName: string;
|
|
5
|
+
urlPath: string;
|
|
6
|
+
entryPath: string;
|
|
7
|
+
bundle: string;
|
|
8
|
+
isApi: boolean;
|
|
9
|
+
isSSR: boolean;
|
|
10
|
+
isSPA: boolean;
|
|
11
|
+
params: Record<string, any>;
|
|
12
|
+
responseHeaders?: Record<string, any>;
|
|
13
|
+
constructor(routeSpec: ModernRouteInterface);
|
|
14
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ModernServerContext } from '@modern-js/types';
|
|
2
2
|
import { NextFunction, ModernServerHandler } from '../type';
|
|
3
3
|
type Rule = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
path: string | RegExp;
|
|
5
|
+
target: string;
|
|
6
6
|
};
|
|
7
7
|
export declare const faviconFallbackHandler: ModernServerHandler;
|
|
8
8
|
export declare const createStaticFileHandler: (rules: Rule[], assetPrefix?: string) => (context: ModernServerContext, next: NextFunction) => Promise<void>;
|
|
9
|
-
export {};
|
|
9
|
+
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ServerTiming as IServerTiming } from '@modern-js/types';
|
|
2
2
|
interface Res {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
getHeader: (name: string) => number | string | string[] | undefined;
|
|
4
|
+
setHeader: (name: string, value: string) => void;
|
|
5
|
+
set: (name: string, value: any) => this;
|
|
6
6
|
}
|
|
7
7
|
export declare class ServerTiming implements IServerTiming {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
meta: string;
|
|
9
|
+
res: Res;
|
|
10
|
+
constructor(res: Res, meta: string);
|
|
11
|
+
addServeTiming(name: string, dur: number, desc?: string): this;
|
|
12
12
|
}
|
|
13
|
-
export {};
|
|
13
|
+
export {};
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
|
|
3
3
|
import { ModernServerOptions } from './type';
|
|
4
4
|
export interface RenderHtmlOptions {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
/** request url */
|
|
6
|
+
url: string;
|
|
7
|
+
/** request method */
|
|
8
|
+
method?: string;
|
|
9
|
+
/** request headers */
|
|
10
|
+
headers?: IncomingHttpHeaders;
|
|
11
|
+
/** request body */
|
|
12
|
+
body?: string;
|
|
13
|
+
serverOptions: ModernServerOptions;
|
|
14
14
|
}
|
|
15
15
|
export interface ReturnResponse {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
16
|
+
headers: OutgoingHttpHeaders;
|
|
17
|
+
redirected: boolean;
|
|
18
|
+
status: number;
|
|
19
|
+
url: string;
|
|
20
|
+
body: string;
|
|
21
|
+
}
|
|
@@ -5,51 +5,49 @@ import { IncomingMessage, ServerResponse } from 'http';
|
|
|
5
5
|
import type { ListenOptions } from 'net';
|
|
6
6
|
import { ModernServerOptions, ServerConstructor } from '../type';
|
|
7
7
|
export declare class Server {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
private loadServerEnv;
|
|
55
|
-
}
|
|
8
|
+
options: ModernServerOptions;
|
|
9
|
+
protected serverImpl: ServerConstructor;
|
|
10
|
+
private server;
|
|
11
|
+
private app;
|
|
12
|
+
private runner;
|
|
13
|
+
private serverConfig;
|
|
14
|
+
constructor(options: ModernServerOptions);
|
|
15
|
+
/**
|
|
16
|
+
* 初始化顺序
|
|
17
|
+
* - 读取 .env.{process.env.MODERN_ENV} 文件,加载环境变量
|
|
18
|
+
* - 获取 server runtime config
|
|
19
|
+
* - 设置 context
|
|
20
|
+
* - 创建 hooksRunner
|
|
21
|
+
* - 合并插件,内置插件和 serverConfig 中配置的插件
|
|
22
|
+
* - 执行 config hook
|
|
23
|
+
* - 获取最终的配置
|
|
24
|
+
* - 设置配置到 context
|
|
25
|
+
* - 初始化 server
|
|
26
|
+
* - 执行 prepare hook
|
|
27
|
+
* - 执行 server init
|
|
28
|
+
*/
|
|
29
|
+
init({ disableHttpServer }?: {
|
|
30
|
+
disableHttpServer: boolean;
|
|
31
|
+
}): Promise<this>;
|
|
32
|
+
/**
|
|
33
|
+
* Execute config hooks
|
|
34
|
+
* @param runner
|
|
35
|
+
* @param options
|
|
36
|
+
*/
|
|
37
|
+
private runConfigHook;
|
|
38
|
+
private runPrepareHook;
|
|
39
|
+
private initServerConfig;
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* merge cliConfig and serverConfig
|
|
43
|
+
*/
|
|
44
|
+
private initConfig;
|
|
45
|
+
close(): Promise<void>;
|
|
46
|
+
listen<T extends number | ListenOptions | undefined>(options: T, listener: any): void;
|
|
47
|
+
getRequestHandler(): (req: IncomingMessage, res: ServerResponse, next?: () => void) => void;
|
|
48
|
+
render(req: IncomingMessage, res: ServerResponse, url?: string): Promise<string | import("stream").Readable | null>;
|
|
49
|
+
private createHookRunner;
|
|
50
|
+
private injectContext;
|
|
51
|
+
private initAppContext;
|
|
52
|
+
private loadServerEnv;
|
|
53
|
+
}
|