@modern-js/prod-server 2.40.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 +34 -10
- 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 +75 -13
- 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 +34 -10
- 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 -44
- package/package.json +14 -14
|
@@ -1,124 +1,124 @@
|
|
|
1
1
|
export declare const matchedCacheableAry: (({
|
|
2
|
-
|
|
2
|
+
requestOpt: {
|
|
3
|
+
url: string;
|
|
4
|
+
headers: {};
|
|
5
|
+
query: {
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
cacheConfig: {
|
|
10
|
+
level: number;
|
|
11
|
+
includes: {
|
|
12
|
+
query: string[];
|
|
13
|
+
};
|
|
14
|
+
matches: {
|
|
15
|
+
query: {
|
|
16
|
+
name: {
|
|
17
|
+
weixin: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
content: string;
|
|
23
|
+
url?: undefined;
|
|
24
|
+
headers?: undefined;
|
|
25
|
+
query?: undefined;
|
|
26
|
+
} | {
|
|
3
27
|
url: string;
|
|
4
28
|
headers: {};
|
|
5
29
|
query: {
|
|
6
|
-
|
|
30
|
+
name: string;
|
|
7
31
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
32
|
+
requestOpt?: undefined;
|
|
33
|
+
cacheConfig?: undefined;
|
|
34
|
+
content?: undefined;
|
|
35
|
+
})[] | ({
|
|
36
|
+
requestOpt: {
|
|
37
|
+
url: string;
|
|
38
|
+
query: {};
|
|
39
|
+
headers: {
|
|
40
|
+
age: string;
|
|
41
|
+
};
|
|
13
42
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
43
|
+
cacheConfig: {
|
|
44
|
+
level: number;
|
|
45
|
+
includes: {
|
|
46
|
+
header: string[];
|
|
47
|
+
};
|
|
48
|
+
matches: {
|
|
49
|
+
header: {
|
|
50
|
+
age: {
|
|
51
|
+
one: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
18
54
|
};
|
|
19
|
-
};
|
|
20
55
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
query?: undefined;
|
|
56
|
+
content: string;
|
|
57
|
+
url?: undefined;
|
|
58
|
+
query?: undefined;
|
|
59
|
+
headers?: undefined;
|
|
26
60
|
} | {
|
|
27
|
-
url: string;
|
|
28
|
-
headers: {};
|
|
29
|
-
query: {
|
|
30
|
-
name: string;
|
|
31
|
-
};
|
|
32
|
-
requestOpt?: undefined;
|
|
33
|
-
cacheConfig?: undefined;
|
|
34
|
-
content?: undefined;
|
|
35
|
-
})[] | ({
|
|
36
|
-
requestOpt: {
|
|
37
61
|
url: string;
|
|
38
62
|
query: {};
|
|
39
63
|
headers: {
|
|
40
|
-
|
|
64
|
+
age: string;
|
|
41
65
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
66
|
+
requestOpt?: undefined;
|
|
67
|
+
cacheConfig?: undefined;
|
|
68
|
+
content?: undefined;
|
|
69
|
+
})[] | ({
|
|
70
|
+
requestOpt: {
|
|
71
|
+
url: string;
|
|
72
|
+
headers: {
|
|
73
|
+
age: string;
|
|
74
|
+
};
|
|
75
|
+
query: {
|
|
76
|
+
name: string;
|
|
77
|
+
};
|
|
47
78
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
79
|
+
cacheConfig: {
|
|
80
|
+
level: number;
|
|
81
|
+
includes: {
|
|
82
|
+
query: string[];
|
|
83
|
+
header: string[];
|
|
84
|
+
};
|
|
85
|
+
matches: {
|
|
86
|
+
query: {
|
|
87
|
+
name: {
|
|
88
|
+
weixin: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
header: {
|
|
92
|
+
age: {
|
|
93
|
+
one: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
52
96
|
};
|
|
53
|
-
};
|
|
54
97
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
headers?: undefined;
|
|
98
|
+
content: string;
|
|
99
|
+
url?: undefined;
|
|
100
|
+
query?: undefined;
|
|
101
|
+
headers?: undefined;
|
|
60
102
|
} | {
|
|
61
|
-
url: string;
|
|
62
|
-
query: {};
|
|
63
|
-
headers: {
|
|
64
|
-
age: string;
|
|
65
|
-
};
|
|
66
|
-
requestOpt?: undefined;
|
|
67
|
-
cacheConfig?: undefined;
|
|
68
|
-
content?: undefined;
|
|
69
|
-
})[] | ({
|
|
70
|
-
requestOpt: {
|
|
71
103
|
url: string;
|
|
104
|
+
query: {
|
|
105
|
+
name: string;
|
|
106
|
+
};
|
|
72
107
|
headers: {
|
|
73
|
-
|
|
108
|
+
age: string;
|
|
74
109
|
};
|
|
110
|
+
requestOpt?: undefined;
|
|
111
|
+
cacheConfig?: undefined;
|
|
112
|
+
content?: undefined;
|
|
113
|
+
} | {
|
|
114
|
+
url: string;
|
|
75
115
|
query: {
|
|
76
|
-
|
|
116
|
+
name: string;
|
|
77
117
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
level: number;
|
|
81
|
-
includes: {
|
|
82
|
-
query: string[];
|
|
83
|
-
header: string[];
|
|
84
|
-
};
|
|
85
|
-
matches: {
|
|
86
|
-
query: {
|
|
87
|
-
name: {
|
|
88
|
-
weixin: string;
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
header: {
|
|
92
|
-
age: {
|
|
93
|
-
one: string;
|
|
94
|
-
};
|
|
95
|
-
};
|
|
118
|
+
headers: {
|
|
119
|
+
age?: undefined;
|
|
96
120
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
headers?: undefined;
|
|
102
|
-
} | {
|
|
103
|
-
url: string;
|
|
104
|
-
query: {
|
|
105
|
-
name: string;
|
|
106
|
-
};
|
|
107
|
-
headers: {
|
|
108
|
-
age: string;
|
|
109
|
-
};
|
|
110
|
-
requestOpt?: undefined;
|
|
111
|
-
cacheConfig?: undefined;
|
|
112
|
-
content?: undefined;
|
|
113
|
-
} | {
|
|
114
|
-
url: string;
|
|
115
|
-
query: {
|
|
116
|
-
name: string;
|
|
117
|
-
};
|
|
118
|
-
headers: {
|
|
119
|
-
age?: undefined;
|
|
120
|
-
};
|
|
121
|
-
requestOpt?: undefined;
|
|
122
|
-
cacheConfig?: undefined;
|
|
123
|
-
content?: undefined;
|
|
124
|
-
})[])[];
|
|
121
|
+
requestOpt?: undefined;
|
|
122
|
+
cacheConfig?: undefined;
|
|
123
|
+
content?: undefined;
|
|
124
|
+
})[])[];
|
|
@@ -3,4 +3,4 @@ import { Readable } from 'stream';
|
|
|
3
3
|
import type { ModernServerContext } from '@modern-js/types';
|
|
4
4
|
import { RenderFunction, SSRServerContext } from '../type';
|
|
5
5
|
declare const _default: (renderFn: RenderFunction, ctx: ModernServerContext) => (context: SSRServerContext) => Promise<string | Readable>;
|
|
6
|
-
export default _default;
|
|
6
|
+
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { PageCachesInterface } from '../type';
|
|
2
|
-
export declare function createPageCaches(max: number): Promise<PageCachesInterface>;
|
|
2
|
+
export declare function createPageCaches(max: number): Promise<PageCachesInterface>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import LRU from 'lru-cache';
|
|
2
2
|
import { PageCache, PageCachesInterface } from '../type';
|
|
3
3
|
export declare class LRUCaches implements PageCachesInterface {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
4
|
+
caches: LRU<string, PageCache>;
|
|
5
|
+
private readonly max;
|
|
6
|
+
constructor(options: {
|
|
7
|
+
max: number;
|
|
8
|
+
});
|
|
9
|
+
init(): Promise<void>;
|
|
10
|
+
keys(): string[];
|
|
11
|
+
get(key: string): Promise<PageCache | null>;
|
|
12
|
+
peek(key: string): PageCache | null;
|
|
13
|
+
set(key: string, cache: PageCache): Promise<void>;
|
|
14
|
+
del(key: string): void;
|
|
15
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import LRUCache from 'lru-cache';
|
|
2
2
|
import { CacheContent, CacheManagerOptions, CacheResult, CacheContext, CacheConfig } from './type';
|
|
3
3
|
declare class CacheManager {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
cache: LRUCache<string, CacheContent>;
|
|
5
|
+
cacheOptions: CacheManagerOptions;
|
|
6
|
+
constructor(cacheOptions: CacheManagerOptions);
|
|
7
|
+
private md5;
|
|
8
|
+
private generateRequestKey;
|
|
9
|
+
private replaceValue;
|
|
10
|
+
private factor;
|
|
11
|
+
private queryFactor;
|
|
12
|
+
private headerFactor;
|
|
13
|
+
private readonly find;
|
|
14
|
+
private best;
|
|
15
|
+
private createCacheContent;
|
|
16
|
+
get(context: CacheContext): Promise<CacheResult | null>;
|
|
17
|
+
set(context: CacheContext, html: string, cacheConfig: CacheConfig, sync?: boolean): Promise<any>;
|
|
18
|
+
del(context: CacheContext, cacheHash: string): Promise<void>;
|
|
19
19
|
}
|
|
20
20
|
export declare function createCache(): CacheManager;
|
|
21
21
|
export declare function destroyCache(): void;
|
|
22
|
-
export {};
|
|
22
|
+
export {};
|
|
@@ -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
|
+
}
|