@modern-js/prod-server 2.14.0 → 2.16.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 +21 -0
- package/dist/cjs/constants.js +15 -31
- package/dist/cjs/index.js +35 -37
- package/dist/cjs/libs/context/context.js +53 -66
- package/dist/cjs/libs/context/index.js +15 -28
- package/dist/cjs/libs/hook-api/index.js +59 -54
- package/dist/cjs/libs/hook-api/route.js +28 -30
- package/dist/cjs/libs/hook-api/template.js +30 -34
- package/dist/cjs/libs/loadConfig.js +74 -65
- package/dist/cjs/libs/logger.js +46 -37
- package/dist/cjs/libs/metrics.js +7 -25
- package/dist/cjs/libs/proxy.js +29 -46
- package/dist/cjs/libs/render/cache/__tests__/cache.fun.test.js +48 -64
- package/dist/cjs/libs/render/cache/__tests__/cache.test.js +53 -37
- package/dist/cjs/libs/render/cache/__tests__/cacheable.js +38 -34
- package/dist/cjs/libs/render/cache/__tests__/error-configuration.js +22 -30
- package/dist/cjs/libs/render/cache/__tests__/matched-cache.js +86 -46
- package/dist/cjs/libs/render/cache/index.js +17 -37
- package/dist/cjs/libs/render/cache/page-caches/index.js +12 -28
- package/dist/cjs/libs/render/cache/page-caches/lru.js +32 -40
- package/dist/cjs/libs/render/cache/spr.js +104 -111
- package/dist/cjs/libs/render/cache/type.js +4 -15
- package/dist/cjs/libs/render/cache/util.js +29 -53
- package/dist/cjs/libs/render/index.js +75 -73
- package/dist/cjs/libs/render/measure.js +19 -34
- package/dist/cjs/libs/render/reader.js +52 -61
- package/dist/cjs/libs/render/ssr.js +34 -66
- package/dist/cjs/libs/render/static.js +22 -45
- package/dist/cjs/libs/render/type.js +10 -28
- package/dist/cjs/libs/render/utils.js +17 -38
- package/dist/cjs/libs/route/index.js +32 -31
- package/dist/cjs/libs/route/matcher.js +38 -38
- package/dist/cjs/libs/route/route.js +29 -26
- package/dist/cjs/libs/serveFile.js +23 -41
- package/dist/cjs/server/index.js +101 -107
- package/dist/cjs/server/modernServer.js +191 -171
- package/dist/cjs/server/modernServerSplit.js +12 -30
- package/dist/cjs/type.js +4 -15
- package/dist/cjs/utils.js +50 -50
- package/dist/cjs/workerServer.js +26 -36
- package/dist/esm/constants.js +24 -25
- package/dist/esm/index.js +11 -10
- package/dist/esm/libs/context/context.js +271 -264
- package/dist/esm/libs/context/index.js +3 -3
- package/dist/esm/libs/hook-api/index.js +237 -223
- package/dist/esm/libs/hook-api/route.js +62 -60
- package/dist/esm/libs/hook-api/template.js +117 -115
- package/dist/esm/libs/loadConfig.js +68 -69
- package/dist/esm/libs/logger.js +188 -174
- package/dist/esm/libs/metrics.js +6 -3
- package/dist/esm/libs/proxy.js +236 -221
- package/dist/esm/libs/render/cache/__tests__/cache.fun.test.js +286 -267
- package/dist/esm/libs/render/cache/__tests__/cache.test.js +765 -745
- package/dist/esm/libs/render/cache/__tests__/cacheable.js +62 -63
- package/dist/esm/libs/render/cache/__tests__/error-configuration.js +42 -43
- package/dist/esm/libs/render/cache/__tests__/matched-cache.js +134 -135
- package/dist/esm/libs/render/cache/index.js +337 -326
- package/dist/esm/libs/render/cache/page-caches/index.js +147 -141
- package/dist/esm/libs/render/cache/page-caches/lru.js +78 -76
- package/dist/esm/libs/render/cache/spr.js +465 -456
- package/dist/esm/libs/render/cache/type.js +1 -1
- package/dist/esm/libs/render/cache/util.js +266 -246
- package/dist/esm/libs/render/index.js +226 -218
- package/dist/esm/libs/render/measure.js +136 -128
- package/dist/esm/libs/render/reader.js +315 -304
- package/dist/esm/libs/render/ssr.js +214 -209
- package/dist/esm/libs/render/static.js +208 -198
- package/dist/esm/libs/render/type.js +6 -7
- package/dist/esm/libs/render/utils.js +8 -9
- package/dist/esm/libs/route/index.js +134 -123
- package/dist/esm/libs/route/matcher.js +140 -130
- package/dist/esm/libs/route/route.js +36 -37
- package/dist/esm/libs/serveFile.js +177 -168
- package/dist/esm/server/index.js +578 -549
- package/dist/esm/server/modernServer.js +1137 -1074
- package/dist/esm/server/modernServerSplit.js +344 -328
- package/dist/esm/type.js +1 -1
- package/dist/esm/utils.js +133 -124
- package/dist/esm/workerServer.js +226 -220
- package/dist/esm-node/constants.js +7 -14
- package/dist/esm-node/index.js +4 -9
- package/dist/esm-node/libs/context/context.js +32 -25
- package/dist/esm-node/libs/context/index.js +2 -5
- package/dist/esm-node/libs/hook-api/index.js +40 -21
- package/dist/esm-node/libs/hook-api/route.js +21 -8
- package/dist/esm-node/libs/hook-api/template.js +19 -14
- package/dist/esm-node/libs/loadConfig.js +11 -28
- package/dist/esm-node/libs/logger.js +37 -17
- package/dist/esm-node/libs/metrics.js +1 -3
- package/dist/esm-node/libs/proxy.js +14 -22
- package/dist/esm-node/libs/render/cache/__tests__/cache.fun.test.js +25 -36
- package/dist/esm-node/libs/render/cache/__tests__/cache.test.js +23 -11
- package/dist/esm-node/libs/render/cache/__tests__/cacheable.js +32 -13
- package/dist/esm-node/libs/render/cache/__tests__/error-configuration.js +16 -9
- package/dist/esm-node/libs/render/cache/__tests__/matched-cache.js +80 -25
- package/dist/esm-node/libs/render/cache/index.js +3 -10
- package/dist/esm-node/libs/render/cache/page-caches/index.js +4 -5
- package/dist/esm-node/libs/render/cache/page-caches/lru.js +20 -8
- package/dist/esm-node/libs/render/cache/spr.js +79 -80
- package/dist/esm-node/libs/render/cache/type.js +1 -0
- package/dist/esm-node/libs/render/cache/util.js +13 -23
- package/dist/esm-node/libs/render/index.js +10 -28
- package/dist/esm-node/libs/render/measure.js +7 -13
- package/dist/esm-node/libs/render/reader.js +31 -26
- package/dist/esm-node/libs/render/ssr.js +5 -21
- package/dist/esm-node/libs/render/static.js +1 -4
- package/dist/esm-node/libs/render/type.js +3 -6
- package/dist/esm-node/libs/render/utils.js +6 -18
- package/dist/esm-node/libs/route/index.js +20 -9
- package/dist/esm-node/libs/route/matcher.js +28 -17
- package/dist/esm-node/libs/route/route.js +23 -5
- package/dist/esm-node/libs/serveFile.js +2 -6
- package/dist/esm-node/server/index.js +72 -75
- package/dist/esm-node/server/modernServer.js +102 -130
- package/dist/esm-node/server/modernServerSplit.js +1 -4
- package/dist/esm-node/type.js +1 -0
- package/dist/esm-node/utils.js +41 -32
- package/dist/esm-node/workerServer.js +9 -10
- package/dist/types/libs/context/context.d.ts +1 -1
- package/dist/types/server/modernServer.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/package.json +12 -8
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _spr = require("../spr");
|
|
6
|
+
const _errorconfiguration = require("./error-configuration");
|
|
7
|
+
const _cacheable = require("./cacheable");
|
|
8
|
+
const _matchedcache = require("./matched-cache");
|
|
5
9
|
const createCacheConfig = (config = {}) => ({
|
|
6
10
|
excludes: null,
|
|
7
11
|
includes: null,
|
|
@@ -15,8 +19,8 @@ const createCacheConfig = (config = {}) => ({
|
|
|
15
19
|
jest.setTimeout(6e4);
|
|
16
20
|
describe("cache", () => {
|
|
17
21
|
it("should cache correctly", async () => {
|
|
18
|
-
(0,
|
|
19
|
-
const cache = (0,
|
|
22
|
+
(0, _spr.destroyCache)();
|
|
23
|
+
const cache = (0, _spr.createCache)();
|
|
20
24
|
const context = {
|
|
21
25
|
entry: "",
|
|
22
26
|
pathname: "",
|
|
@@ -28,12 +32,12 @@ describe("cache", () => {
|
|
|
28
32
|
await cache.set(context, content, cacheConfig, true);
|
|
29
33
|
const cacheResult = await cache.get(context);
|
|
30
34
|
expect(cacheResult).not.toBe(null);
|
|
31
|
-
expect(cacheResult
|
|
35
|
+
expect(cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.content).toBe("hello");
|
|
32
36
|
});
|
|
33
37
|
it("should ignore cache set when cache config not exist", async () => {
|
|
34
|
-
(0,
|
|
35
|
-
(0,
|
|
36
|
-
const cache = (0,
|
|
38
|
+
(0, _spr.destroyCache)();
|
|
39
|
+
(0, _spr.destroyCache)();
|
|
40
|
+
const cache = (0, _spr.createCache)();
|
|
37
41
|
const context = {
|
|
38
42
|
entry: "",
|
|
39
43
|
pathname: "",
|
|
@@ -45,10 +49,10 @@ describe("cache", () => {
|
|
|
45
49
|
expect(shouldCache).toBe(false);
|
|
46
50
|
});
|
|
47
51
|
it("should calcual cache key error", async () => {
|
|
48
|
-
(0,
|
|
49
|
-
const cache = (0,
|
|
52
|
+
(0, _spr.destroyCache)();
|
|
53
|
+
const cache = (0, _spr.createCache)();
|
|
50
54
|
const content = "hello";
|
|
51
|
-
for (const config of
|
|
55
|
+
for (const config of _errorconfiguration.errorConfiguration) {
|
|
52
56
|
const cacheConfig = createCacheConfig(config);
|
|
53
57
|
const tmpEntry = Math.random().toString();
|
|
54
58
|
const context = {
|
|
@@ -62,8 +66,8 @@ describe("cache", () => {
|
|
|
62
66
|
}
|
|
63
67
|
});
|
|
64
68
|
it("should get nothing for diff requestKey", async () => {
|
|
65
|
-
(0,
|
|
66
|
-
const cache = (0,
|
|
69
|
+
(0, _spr.destroyCache)();
|
|
70
|
+
const cache = (0, _spr.createCache)();
|
|
67
71
|
const context = {
|
|
68
72
|
entry: "",
|
|
69
73
|
pathname: "",
|
|
@@ -73,7 +77,11 @@ describe("cache", () => {
|
|
|
73
77
|
const content = "hello";
|
|
74
78
|
const cacheConfig = createCacheConfig({
|
|
75
79
|
level: 1,
|
|
76
|
-
includes: {
|
|
80
|
+
includes: {
|
|
81
|
+
query: [
|
|
82
|
+
"name"
|
|
83
|
+
]
|
|
84
|
+
}
|
|
77
85
|
});
|
|
78
86
|
await cache.set(context, content, cacheConfig, true);
|
|
79
87
|
const context_req = {
|
|
@@ -86,8 +94,8 @@ describe("cache", () => {
|
|
|
86
94
|
expect(cacheResult).toBe(null);
|
|
87
95
|
});
|
|
88
96
|
it("should get nothing for diff cacheHash", async () => {
|
|
89
|
-
(0,
|
|
90
|
-
const cache = (0,
|
|
97
|
+
(0, _spr.destroyCache)();
|
|
98
|
+
const cache = (0, _spr.createCache)();
|
|
91
99
|
const context = {
|
|
92
100
|
entry: "",
|
|
93
101
|
pathname: "",
|
|
@@ -97,22 +105,28 @@ describe("cache", () => {
|
|
|
97
105
|
const content = "hello";
|
|
98
106
|
const cacheConfig = createCacheConfig({
|
|
99
107
|
level: 1,
|
|
100
|
-
includes: {
|
|
108
|
+
includes: {
|
|
109
|
+
query: [
|
|
110
|
+
"name"
|
|
111
|
+
]
|
|
112
|
+
}
|
|
101
113
|
});
|
|
102
114
|
await cache.set(context, content, cacheConfig, true);
|
|
103
115
|
const context_req = {
|
|
104
116
|
entry: "",
|
|
105
117
|
pathname: "",
|
|
106
|
-
query: {
|
|
118
|
+
query: {
|
|
119
|
+
name: "zll"
|
|
120
|
+
},
|
|
107
121
|
headers: {}
|
|
108
122
|
};
|
|
109
123
|
const cacheResult = await cache.get(context_req);
|
|
110
124
|
expect(cacheResult).toBe(null);
|
|
111
125
|
});
|
|
112
126
|
it("should get cache correctly", async () => {
|
|
113
|
-
(0,
|
|
114
|
-
const cache = (0,
|
|
115
|
-
for (const cacheable of
|
|
127
|
+
(0, _spr.destroyCache)();
|
|
128
|
+
const cache = (0, _spr.createCache)();
|
|
129
|
+
for (const cacheable of _cacheable.cacheabelAry) {
|
|
116
130
|
const context = {
|
|
117
131
|
entry: "",
|
|
118
132
|
pathname: cacheable.requestOpt.url,
|
|
@@ -122,13 +136,13 @@ describe("cache", () => {
|
|
|
122
136
|
const cacheConfig = createCacheConfig(cacheable.cacheConfig || {});
|
|
123
137
|
await cache.set(context, cacheable.content, cacheConfig, true);
|
|
124
138
|
const cacheResult = await cache.get(context);
|
|
125
|
-
expect(cacheResult
|
|
139
|
+
expect(cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.content).toBe(cacheable.content);
|
|
126
140
|
}
|
|
127
141
|
});
|
|
128
142
|
it("should match cache correctly", async () => {
|
|
129
|
-
(0,
|
|
130
|
-
const cache = (0,
|
|
131
|
-
for (const cacheable of
|
|
143
|
+
(0, _spr.destroyCache)();
|
|
144
|
+
const cache = (0, _spr.createCache)();
|
|
145
|
+
for (const cacheable of _matchedcache.matchedCacheableAry) {
|
|
132
146
|
const [baseCacheable, matchOne, ...other] = cacheable;
|
|
133
147
|
const { requestOpt = {}, cacheConfig, content } = baseCacheable;
|
|
134
148
|
const context = {
|
|
@@ -145,7 +159,7 @@ describe("cache", () => {
|
|
|
145
159
|
headers: matchOne.headers
|
|
146
160
|
};
|
|
147
161
|
const cacheResult = await cache.get(matchContext);
|
|
148
|
-
expect(cacheResult
|
|
162
|
+
expect(cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.content).toBe(content);
|
|
149
163
|
for (const notMatch of other) {
|
|
150
164
|
const notMatchContext = {
|
|
151
165
|
entry: "",
|
|
@@ -159,31 +173,33 @@ describe("cache", () => {
|
|
|
159
173
|
}
|
|
160
174
|
});
|
|
161
175
|
it("should stale cache correctly", async () => {
|
|
162
|
-
(0,
|
|
163
|
-
const cache = (0,
|
|
176
|
+
(0, _spr.destroyCache)();
|
|
177
|
+
const cache = (0, _spr.createCache)();
|
|
164
178
|
const context = {
|
|
165
179
|
entry: "",
|
|
166
180
|
pathname: "",
|
|
167
181
|
query: {},
|
|
168
182
|
headers: {}
|
|
169
183
|
};
|
|
170
|
-
const config = createCacheConfig({
|
|
184
|
+
const config = createCacheConfig({
|
|
185
|
+
interval: 5
|
|
186
|
+
});
|
|
171
187
|
const content = "hello";
|
|
172
188
|
const shouldCache = await cache.set(context, content, config, true);
|
|
173
189
|
expect(shouldCache.value).toBe(true);
|
|
174
190
|
const freshResult = await cache.get(context);
|
|
175
|
-
expect(freshResult
|
|
191
|
+
expect(freshResult === null || freshResult === void 0 ? void 0 : freshResult.isStale).toBe(false);
|
|
176
192
|
await new Promise((resolve) => {
|
|
177
193
|
setTimeout(() => {
|
|
178
194
|
resolve();
|
|
179
195
|
}, 6e3);
|
|
180
196
|
});
|
|
181
197
|
const staleResult = await cache.get(context);
|
|
182
|
-
expect(staleResult
|
|
198
|
+
expect(staleResult === null || staleResult === void 0 ? void 0 : staleResult.isStale).toBe(true);
|
|
183
199
|
});
|
|
184
200
|
it("should garbage cache correctly", async () => {
|
|
185
|
-
(0,
|
|
186
|
-
const cache = (0,
|
|
201
|
+
(0, _spr.destroyCache)();
|
|
202
|
+
const cache = (0, _spr.createCache)();
|
|
187
203
|
const context = {
|
|
188
204
|
entry: "",
|
|
189
205
|
pathname: "",
|
|
@@ -198,13 +214,13 @@ describe("cache", () => {
|
|
|
198
214
|
const shouldCache = await cache.set(context, content, config, true);
|
|
199
215
|
expect(shouldCache.value).toBe(true);
|
|
200
216
|
const freshResult = await cache.get(context);
|
|
201
|
-
expect(freshResult
|
|
217
|
+
expect(freshResult === null || freshResult === void 0 ? void 0 : freshResult.isGarbage).toBe(false);
|
|
202
218
|
await new Promise((resolve) => {
|
|
203
219
|
setTimeout(() => {
|
|
204
220
|
resolve();
|
|
205
221
|
}, 1e4);
|
|
206
222
|
});
|
|
207
223
|
const staleResult = await cache.get(context);
|
|
208
|
-
expect(staleResult
|
|
224
|
+
expect(staleResult === null || staleResult === void 0 ? void 0 : staleResult.isGarbage).toBe(true);
|
|
209
225
|
});
|
|
210
226
|
});
|
|
@@ -1,70 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var cacheable_exports = {};
|
|
19
|
-
__export(cacheable_exports, {
|
|
20
|
-
cacheabelAry: () => cacheabelAry
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "cacheabelAry", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => cacheabelAry
|
|
21
8
|
});
|
|
22
|
-
module.exports = __toCommonJS(cacheable_exports);
|
|
23
9
|
const cacheabelAry = [
|
|
24
10
|
{
|
|
25
|
-
requestOpt: {
|
|
11
|
+
requestOpt: {
|
|
12
|
+
url: "/"
|
|
13
|
+
},
|
|
26
14
|
cacheConfig: {},
|
|
27
15
|
content: "level0"
|
|
28
16
|
},
|
|
29
17
|
{
|
|
30
18
|
requestOpt: {
|
|
31
19
|
url: "/level-one",
|
|
32
|
-
query: {
|
|
20
|
+
query: {
|
|
21
|
+
name: "modern"
|
|
22
|
+
}
|
|
33
23
|
},
|
|
34
24
|
cacheConfig: {
|
|
35
25
|
level: 1,
|
|
36
|
-
includes: {
|
|
26
|
+
includes: {
|
|
27
|
+
query: [
|
|
28
|
+
"name"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
37
31
|
},
|
|
38
32
|
content: "level1"
|
|
39
33
|
},
|
|
40
34
|
{
|
|
41
35
|
requestOpt: {
|
|
42
36
|
url: "/level-two",
|
|
43
|
-
headers: {
|
|
37
|
+
headers: {
|
|
38
|
+
age: "18"
|
|
39
|
+
}
|
|
44
40
|
},
|
|
45
41
|
cacheConfig: {
|
|
46
42
|
level: 2,
|
|
47
|
-
includes: {
|
|
43
|
+
includes: {
|
|
44
|
+
header: [
|
|
45
|
+
"age"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
48
|
},
|
|
49
49
|
content: "level2"
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
requestOpt: {
|
|
53
53
|
url: "/level-three",
|
|
54
|
-
query: {
|
|
55
|
-
|
|
54
|
+
query: {
|
|
55
|
+
name: "modern"
|
|
56
|
+
},
|
|
57
|
+
headers: {
|
|
58
|
+
age: "18"
|
|
59
|
+
}
|
|
56
60
|
},
|
|
57
61
|
cacheConfig: {
|
|
58
62
|
level: 3,
|
|
59
63
|
includes: {
|
|
60
|
-
query: [
|
|
61
|
-
|
|
64
|
+
query: [
|
|
65
|
+
"name"
|
|
66
|
+
],
|
|
67
|
+
header: [
|
|
68
|
+
"age"
|
|
69
|
+
]
|
|
62
70
|
}
|
|
63
71
|
},
|
|
64
72
|
content: "level3"
|
|
65
73
|
}
|
|
66
74
|
];
|
|
67
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
-
0 && (module.exports = {
|
|
69
|
-
cacheabelAry
|
|
70
|
-
});
|
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var error_configuration_exports = {};
|
|
19
|
-
__export(error_configuration_exports, {
|
|
20
|
-
errorConfiguration: () => errorConfiguration
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "errorConfiguration", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => errorConfiguration
|
|
21
8
|
});
|
|
22
|
-
module.exports = __toCommonJS(error_configuration_exports);
|
|
23
9
|
const errorConfiguration = [
|
|
24
|
-
{
|
|
10
|
+
{
|
|
11
|
+
level: 1
|
|
12
|
+
},
|
|
25
13
|
{
|
|
26
14
|
level: 1,
|
|
27
15
|
includes: {}
|
|
28
16
|
},
|
|
29
17
|
{
|
|
30
18
|
level: 1,
|
|
31
|
-
includes: {
|
|
19
|
+
includes: {
|
|
20
|
+
query: []
|
|
21
|
+
}
|
|
32
22
|
},
|
|
33
23
|
{
|
|
34
24
|
level: 2,
|
|
@@ -36,15 +26,21 @@ const errorConfiguration = [
|
|
|
36
26
|
},
|
|
37
27
|
{
|
|
38
28
|
level: 2,
|
|
39
|
-
includes: {
|
|
29
|
+
includes: {
|
|
30
|
+
header: []
|
|
31
|
+
}
|
|
40
32
|
},
|
|
41
33
|
{
|
|
42
34
|
level: 3,
|
|
43
|
-
includes: {
|
|
35
|
+
includes: {
|
|
36
|
+
header: []
|
|
37
|
+
}
|
|
44
38
|
},
|
|
45
39
|
{
|
|
46
40
|
level: 3,
|
|
47
|
-
includes: {
|
|
41
|
+
includes: {
|
|
42
|
+
query: []
|
|
43
|
+
}
|
|
48
44
|
},
|
|
49
45
|
{
|
|
50
46
|
level: 3,
|
|
@@ -54,7 +50,3 @@ const errorConfiguration = [
|
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
52
|
];
|
|
57
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
-
0 && (module.exports = {
|
|
59
|
-
errorConfiguration
|
|
60
|
-
});
|
|
@@ -1,49 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var matched_cache_exports = {};
|
|
19
|
-
__export(matched_cache_exports, {
|
|
20
|
-
matchedCacheableAry: () => matchedCacheableAry
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "matchedCacheableAry", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => matchedCacheableAry
|
|
21
8
|
});
|
|
22
|
-
module.exports = __toCommonJS(matched_cache_exports);
|
|
23
9
|
const matchedCacheableAry = [
|
|
24
10
|
[
|
|
25
11
|
{
|
|
26
12
|
requestOpt: {
|
|
27
13
|
url: "/level-one",
|
|
28
14
|
headers: {},
|
|
29
|
-
query: {
|
|
15
|
+
query: {
|
|
16
|
+
name: "byted"
|
|
17
|
+
}
|
|
30
18
|
},
|
|
31
19
|
cacheConfig: {
|
|
32
20
|
level: 1,
|
|
33
|
-
includes: {
|
|
34
|
-
|
|
21
|
+
includes: {
|
|
22
|
+
query: [
|
|
23
|
+
"name"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
matches: {
|
|
27
|
+
query: {
|
|
28
|
+
name: {
|
|
29
|
+
weixin: "^byted"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
35
33
|
},
|
|
36
34
|
content: "level1"
|
|
37
35
|
},
|
|
38
36
|
{
|
|
39
37
|
url: "/level-one",
|
|
40
38
|
headers: {},
|
|
41
|
-
query: {
|
|
39
|
+
query: {
|
|
40
|
+
name: "byted_likely"
|
|
41
|
+
}
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
url: "/level-one",
|
|
45
45
|
headers: {},
|
|
46
|
-
query: {
|
|
46
|
+
query: {
|
|
47
|
+
name: "not_byted"
|
|
48
|
+
}
|
|
47
49
|
}
|
|
48
50
|
],
|
|
49
51
|
[
|
|
@@ -51,64 +53,102 @@ const matchedCacheableAry = [
|
|
|
51
53
|
requestOpt: {
|
|
52
54
|
url: "/level-two",
|
|
53
55
|
query: {},
|
|
54
|
-
headers: {
|
|
56
|
+
headers: {
|
|
57
|
+
age: "17"
|
|
58
|
+
}
|
|
55
59
|
},
|
|
56
60
|
cacheConfig: {
|
|
57
61
|
level: 2,
|
|
58
|
-
includes: {
|
|
59
|
-
|
|
62
|
+
includes: {
|
|
63
|
+
header: [
|
|
64
|
+
"age"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
matches: {
|
|
68
|
+
header: {
|
|
69
|
+
age: {
|
|
70
|
+
one: "^1"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
60
74
|
},
|
|
61
75
|
content: "level2"
|
|
62
76
|
},
|
|
63
77
|
{
|
|
64
78
|
url: "/level-two",
|
|
65
79
|
query: {},
|
|
66
|
-
headers: {
|
|
80
|
+
headers: {
|
|
81
|
+
age: "11"
|
|
82
|
+
}
|
|
67
83
|
},
|
|
68
84
|
{
|
|
69
85
|
url: "/level-two",
|
|
70
86
|
query: {},
|
|
71
|
-
headers: {
|
|
87
|
+
headers: {
|
|
88
|
+
age: "22"
|
|
89
|
+
}
|
|
72
90
|
}
|
|
73
91
|
],
|
|
74
92
|
[
|
|
75
93
|
{
|
|
76
94
|
requestOpt: {
|
|
77
95
|
url: "/level-three",
|
|
78
|
-
headers: {
|
|
79
|
-
|
|
96
|
+
headers: {
|
|
97
|
+
age: "17"
|
|
98
|
+
},
|
|
99
|
+
query: {
|
|
100
|
+
name: "byted"
|
|
101
|
+
}
|
|
80
102
|
},
|
|
81
103
|
cacheConfig: {
|
|
82
104
|
level: 3,
|
|
83
105
|
includes: {
|
|
84
|
-
query: [
|
|
85
|
-
|
|
106
|
+
query: [
|
|
107
|
+
"name"
|
|
108
|
+
],
|
|
109
|
+
header: [
|
|
110
|
+
"age"
|
|
111
|
+
]
|
|
86
112
|
},
|
|
87
113
|
matches: {
|
|
88
|
-
query: {
|
|
89
|
-
|
|
114
|
+
query: {
|
|
115
|
+
name: {
|
|
116
|
+
weixin: "^byted"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
header: {
|
|
120
|
+
age: {
|
|
121
|
+
one: "^1"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
90
124
|
}
|
|
91
125
|
},
|
|
92
126
|
content: "level3"
|
|
93
127
|
},
|
|
94
128
|
{
|
|
95
129
|
url: "/level-three",
|
|
96
|
-
query: {
|
|
97
|
-
|
|
130
|
+
query: {
|
|
131
|
+
name: "byted_likely"
|
|
132
|
+
},
|
|
133
|
+
headers: {
|
|
134
|
+
age: "19"
|
|
135
|
+
}
|
|
98
136
|
},
|
|
99
137
|
{
|
|
100
138
|
url: "/level-three",
|
|
101
|
-
query: {
|
|
139
|
+
query: {
|
|
140
|
+
name: "byted_likely"
|
|
141
|
+
},
|
|
102
142
|
headers: {}
|
|
103
143
|
},
|
|
104
144
|
{
|
|
105
145
|
url: "/level-three",
|
|
106
|
-
query: {
|
|
107
|
-
|
|
146
|
+
query: {
|
|
147
|
+
name: "not_byted"
|
|
148
|
+
},
|
|
149
|
+
headers: {
|
|
150
|
+
age: "19"
|
|
151
|
+
}
|
|
108
152
|
}
|
|
109
153
|
]
|
|
110
154
|
];
|
|
111
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
112
|
-
0 && (module.exports = {
|
|
113
|
-
matchedCacheableAry
|
|
114
|
-
});
|
|
@@ -1,31 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var cache_exports = {};
|
|
19
|
-
__export(cache_exports, {
|
|
20
|
-
default: () => cache_default
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => _default
|
|
21
8
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const sprCache = (0, import_spr.createCache)();
|
|
9
|
+
const _stream = require("stream");
|
|
10
|
+
const _constants = require("../../../constants");
|
|
11
|
+
const _spr = require("./spr");
|
|
12
|
+
const _util = require("./util");
|
|
13
|
+
const _default = (renderFn, ctx) => {
|
|
14
|
+
const sprCache = (0, _spr.createCache)();
|
|
29
15
|
const doRender = async (context) => {
|
|
30
16
|
const cacheContext = {
|
|
31
17
|
entry: context.entryName,
|
|
@@ -41,7 +27,7 @@ var cache_default = (renderFn, ctx) => {
|
|
|
41
27
|
return source;
|
|
42
28
|
} else {
|
|
43
29
|
let htmlForStream = "";
|
|
44
|
-
const cacheStream = new
|
|
30
|
+
const cacheStream = new _stream.Transform({
|
|
45
31
|
write(chunk, _, callback) {
|
|
46
32
|
htmlForStream += chunk.toString();
|
|
47
33
|
this.push(chunk);
|
|
@@ -62,16 +48,12 @@ var cache_default = (renderFn, ctx) => {
|
|
|
62
48
|
const renderResult = await renderFn(context);
|
|
63
49
|
return afterRender(renderResult, saveHtmlIntoCache);
|
|
64
50
|
}
|
|
65
|
-
const cacheHash = cacheFile
|
|
51
|
+
const cacheHash = cacheFile === null || cacheFile === void 0 ? void 0 : cacheFile.hash;
|
|
66
52
|
if (cacheFile.isGarbage) {
|
|
67
53
|
const renderResult = await renderFn(context);
|
|
68
54
|
return afterRender(renderResult, saveHtmlIntoCache);
|
|
69
55
|
} else if (cacheFile.isStale) {
|
|
70
|
-
const render = (0,
|
|
71
|
-
null,
|
|
72
|
-
(0, import_util.namespaceHash)("render", cacheFile.hash),
|
|
73
|
-
[]
|
|
74
|
-
);
|
|
56
|
+
const render = (0, _util.withCoalescedInvoke)(() => renderFn(context)).bind(null, (0, _util.namespaceHash)("render", cacheFile.hash), []);
|
|
75
57
|
render().then(async (res) => {
|
|
76
58
|
if (res.value && res.isOrigin) {
|
|
77
59
|
const { cacheConfig } = context;
|
|
@@ -85,7 +67,7 @@ var cache_default = (renderFn, ctx) => {
|
|
|
85
67
|
}
|
|
86
68
|
}).catch((e) => {
|
|
87
69
|
sprCache.del(cacheContext, cacheHash);
|
|
88
|
-
ctx.error(
|
|
70
|
+
ctx.error(_constants.ERROR_DIGEST.ERENDER, e);
|
|
89
71
|
});
|
|
90
72
|
}
|
|
91
73
|
ctx.res.setHeader("x-modern-spr", "1");
|
|
@@ -93,5 +75,3 @@ var cache_default = (renderFn, ctx) => {
|
|
|
93
75
|
};
|
|
94
76
|
return doRender;
|
|
95
77
|
};
|
|
96
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
-
0 && (module.exports = {});
|