@modern-js/prod-server 2.0.0-beta.3 → 2.0.0-beta.6
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 +139 -0
- package/dist/js/modern/constants.js +32 -25
- package/dist/js/modern/index.js +11 -6
- package/dist/js/modern/libs/context/context.js +52 -84
- package/dist/js/modern/libs/context/index.js +5 -2
- package/dist/js/modern/libs/hook-api/index.js +44 -35
- package/dist/js/modern/libs/hook-api/route.js +6 -7
- package/dist/js/modern/libs/hook-api/template.js +20 -34
- package/dist/js/modern/libs/loadConfig.js +45 -24
- package/dist/js/modern/libs/metrics.js +3 -4
- package/dist/js/modern/libs/proxy.js +68 -37
- package/dist/js/modern/libs/render/cache/__tests__/cache.fun.test.js +112 -67
- package/dist/js/modern/libs/render/cache/__tests__/cache.test.js +246 -216
- package/dist/js/modern/libs/render/cache/__tests__/cacheable.js +43 -49
- package/dist/js/modern/libs/render/cache/__tests__/error-configuration.js +36 -34
- package/dist/js/modern/libs/render/cache/__tests__/matched-cache.js +83 -113
- package/dist/js/modern/libs/render/cache/index.js +88 -54
- package/dist/js/modern/libs/render/cache/page-caches/index.js +31 -8
- package/dist/js/modern/libs/render/cache/page-caches/lru.js +6 -6
- package/dist/js/modern/libs/render/cache/spr.js +133 -117
- package/dist/js/modern/libs/render/cache/type.js +0 -1
- package/dist/js/modern/libs/render/cache/util.js +71 -39
- package/dist/js/modern/libs/render/index.js +76 -56
- package/dist/js/modern/libs/render/measure.js +38 -27
- package/dist/js/modern/libs/render/reader.js +65 -62
- package/dist/js/modern/libs/render/ssr.js +50 -32
- package/dist/js/modern/libs/render/static.js +50 -33
- package/dist/js/modern/libs/render/type.js +9 -6
- package/dist/js/modern/libs/route/index.js +8 -15
- package/dist/js/modern/libs/route/matcher.js +20 -34
- package/dist/js/modern/libs/route/route.js +9 -18
- package/dist/js/modern/libs/serve-file.js +33 -20
- package/dist/js/modern/server/index.js +150 -145
- package/dist/js/modern/server/modern-server-split.js +46 -12
- package/dist/js/modern/server/modern-server.js +384 -422
- package/dist/js/modern/type.js +0 -1
- package/dist/js/modern/utils.js +62 -43
- package/dist/js/modern/worker-server.js +34 -14
- package/dist/js/node/constants.js +53 -30
- package/dist/js/node/index.js +37 -57
- package/dist/js/node/libs/context/context.js +83 -94
- package/dist/js/node/libs/context/index.js +28 -13
- package/dist/js/node/libs/hook-api/index.js +76 -48
- package/dist/js/node/libs/hook-api/route.js +26 -11
- package/dist/js/node/libs/hook-api/template.js +41 -39
- package/dist/js/node/libs/loadConfig.js +73 -35
- package/dist/js/node/libs/metrics.js +25 -9
- package/dist/js/node/libs/proxy.js +89 -44
- package/dist/js/node/libs/render/cache/__tests__/cache.fun.test.js +99 -56
- package/dist/js/node/libs/render/cache/__tests__/cache.test.js +147 -128
- package/dist/js/node/libs/render/cache/__tests__/cacheable.js +65 -55
- package/dist/js/node/libs/render/cache/__tests__/error-configuration.js +58 -40
- package/dist/js/node/libs/render/cache/__tests__/matched-cache.js +105 -119
- package/dist/js/node/libs/render/cache/index.js +110 -64
- package/dist/js/node/libs/render/cache/page-caches/index.js +54 -14
- package/dist/js/node/libs/render/cache/page-caches/lru.js +33 -12
- package/dist/js/node/libs/render/cache/spr.js +161 -129
- package/dist/js/node/libs/render/cache/type.js +15 -5
- package/dist/js/node/libs/render/cache/util.js +99 -45
- package/dist/js/node/libs/render/index.js +106 -67
- package/dist/js/node/libs/render/measure.js +58 -31
- package/dist/js/node/libs/render/reader.js +95 -70
- package/dist/js/node/libs/render/ssr.js +80 -47
- package/dist/js/node/libs/render/static.js +79 -40
- package/dist/js/node/libs/render/type.js +31 -12
- package/dist/js/node/libs/route/index.js +31 -26
- package/dist/js/node/libs/route/matcher.js +40 -41
- package/dist/js/node/libs/route/route.js +29 -22
- package/dist/js/node/libs/serve-file.js +66 -32
- package/dist/js/node/server/index.js +168 -160
- package/dist/js/node/server/modern-server-split.js +72 -22
- package/dist/js/node/server/modern-server.js +403 -445
- package/dist/js/node/type.js +15 -3
- package/dist/js/node/utils.js +85 -52
- package/dist/js/node/worker-server.js +57 -21
- package/dist/js/treeshaking/constants.js +26 -25
- package/dist/js/treeshaking/index.js +10 -10
- package/dist/js/treeshaking/libs/context/context.js +268 -237
- package/dist/js/treeshaking/libs/context/index.js +3 -3
- package/dist/js/treeshaking/libs/hook-api/index.js +267 -143
- package/dist/js/treeshaking/libs/hook-api/route.js +65 -30
- package/dist/js/treeshaking/libs/hook-api/template.js +121 -85
- package/dist/js/treeshaking/libs/loadConfig.js +80 -37
- package/dist/js/treeshaking/libs/metrics.js +4 -10
- package/dist/js/treeshaking/libs/proxy.js +240 -76
- package/dist/js/treeshaking/libs/render/cache/__tests__/cache.fun.test.js +288 -121
- package/dist/js/treeshaking/libs/render/cache/__tests__/cache.test.js +772 -455
- package/dist/js/treeshaking/libs/render/cache/__tests__/cacheable.js +65 -51
- package/dist/js/treeshaking/libs/render/cache/__tests__/error-configuration.js +45 -35
- package/dist/js/treeshaking/libs/render/cache/__tests__/matched-cache.js +144 -118
- package/dist/js/treeshaking/libs/render/cache/index.js +337 -175
- package/dist/js/treeshaking/libs/render/cache/page-caches/index.js +151 -27
- package/dist/js/treeshaking/libs/render/cache/page-caches/lru.js +80 -42
- package/dist/js/treeshaking/libs/render/cache/spr.js +470 -340
- package/dist/js/treeshaking/libs/render/cache/type.js +1 -1
- package/dist/js/treeshaking/libs/render/cache/util.js +271 -92
- package/dist/js/treeshaking/libs/render/index.js +228 -95
- package/dist/js/treeshaking/libs/render/measure.js +142 -57
- package/dist/js/treeshaking/libs/render/reader.js +325 -177
- package/dist/js/treeshaking/libs/render/ssr.js +220 -95
- package/dist/js/treeshaking/libs/render/static.js +210 -78
- package/dist/js/treeshaking/libs/render/type.js +7 -6
- package/dist/js/treeshaking/libs/route/index.js +125 -89
- package/dist/js/treeshaking/libs/route/matcher.js +132 -107
- package/dist/js/treeshaking/libs/route/route.js +40 -26
- package/dist/js/treeshaking/libs/serve-file.js +177 -68
- package/dist/js/treeshaking/server/index.js +493 -327
- package/dist/js/treeshaking/server/modern-server-split.js +352 -144
- package/dist/js/treeshaking/server/modern-server.js +1048 -909
- package/dist/js/treeshaking/type.js +1 -1
- package/dist/js/treeshaking/utils.js +138 -81
- package/dist/js/treeshaking/worker-server.js +176 -55
- package/dist/types/index.d.ts +2 -0
- package/dist/types/libs/context/context.d.ts +4 -1
- package/dist/types/libs/loadConfig.d.ts +1 -0
- package/dist/types/libs/render/cache/index.d.ts +2 -0
- package/dist/types/libs/render/cache/spr.d.ts +2 -0
- package/dist/types/libs/route/route.d.ts +0 -1
- package/dist/types/server/index.d.ts +3 -0
- package/dist/types/utils.d.ts +1 -1
- package/dist/types/worker-server.d.ts +1 -2
- package/package.json +7 -14
- package/dist/js/modern/libs/render/modern/browser-list.js +0 -7
- package/dist/js/modern/libs/render/modern/index.js +0 -37
- package/dist/js/node/libs/render/modern/browser-list.js +0 -14
- package/dist/js/node/libs/render/modern/index.js +0 -46
- package/dist/js/treeshaking/libs/render/modern/browser-list.js +0 -7
- package/dist/js/treeshaking/libs/render/modern/index.js +0 -39
- package/dist/types/libs/render/modern/browser-list.d.ts +0 -1
- package/dist/types/libs/render/modern/index.d.ts +0 -3
|
@@ -1,128 +1,114 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
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
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
const matchedCacheableAry = [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
module.exports = __toCommonJS(matched_cache_exports);
|
|
23
|
+
const matchedCacheableAry = [
|
|
24
|
+
[
|
|
25
|
+
{
|
|
26
|
+
requestOpt: {
|
|
27
|
+
url: "/level-one",
|
|
28
|
+
headers: {},
|
|
29
|
+
query: { name: "byted" }
|
|
30
|
+
},
|
|
31
|
+
cacheConfig: {
|
|
32
|
+
level: 1,
|
|
33
|
+
includes: { query: ["name"] },
|
|
34
|
+
matches: { query: { name: { weixin: "^byted" } } }
|
|
35
|
+
},
|
|
36
|
+
content: "level1"
|
|
19
37
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
content: 'level1'
|
|
29
|
-
}, {
|
|
30
|
-
url: '/level-one',
|
|
31
|
-
headers: {},
|
|
32
|
-
query: {
|
|
33
|
-
name: 'byted_likely'
|
|
34
|
-
}
|
|
35
|
-
}, {
|
|
36
|
-
url: '/level-one',
|
|
37
|
-
headers: {},
|
|
38
|
-
query: {
|
|
39
|
-
name: 'not_byted'
|
|
40
|
-
}
|
|
41
|
-
}], [{
|
|
42
|
-
requestOpt: {
|
|
43
|
-
url: '/level-two',
|
|
44
|
-
query: {},
|
|
45
|
-
headers: {
|
|
46
|
-
age: '17'
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
cacheConfig: {
|
|
50
|
-
level: 2,
|
|
51
|
-
includes: {
|
|
52
|
-
header: ['age']
|
|
38
|
+
{
|
|
39
|
+
url: "/level-one",
|
|
40
|
+
headers: {},
|
|
41
|
+
query: { name: "byted_likely" }
|
|
53
42
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
}
|
|
43
|
+
{
|
|
44
|
+
url: "/level-one",
|
|
45
|
+
headers: {},
|
|
46
|
+
query: { name: "not_byted" }
|
|
60
47
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}], [{
|
|
76
|
-
requestOpt: {
|
|
77
|
-
url: '/level-three',
|
|
78
|
-
headers: {
|
|
79
|
-
age: '17'
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
{
|
|
51
|
+
requestOpt: {
|
|
52
|
+
url: "/level-two",
|
|
53
|
+
query: {},
|
|
54
|
+
headers: { age: "17" }
|
|
55
|
+
},
|
|
56
|
+
cacheConfig: {
|
|
57
|
+
level: 2,
|
|
58
|
+
includes: { header: ["age"] },
|
|
59
|
+
matches: { header: { age: { one: "^1" } } }
|
|
60
|
+
},
|
|
61
|
+
content: "level2"
|
|
80
62
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
cacheConfig: {
|
|
86
|
-
level: 3,
|
|
87
|
-
includes: {
|
|
88
|
-
query: ['name'],
|
|
89
|
-
header: ['age']
|
|
63
|
+
{
|
|
64
|
+
url: "/level-two",
|
|
65
|
+
query: {},
|
|
66
|
+
headers: { age: "11" }
|
|
90
67
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
68
|
+
{
|
|
69
|
+
url: "/level-two",
|
|
70
|
+
query: {},
|
|
71
|
+
headers: { age: "22" }
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
[
|
|
75
|
+
{
|
|
76
|
+
requestOpt: {
|
|
77
|
+
url: "/level-three",
|
|
78
|
+
headers: { age: "17" },
|
|
79
|
+
query: { name: "byted" }
|
|
96
80
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
cacheConfig: {
|
|
82
|
+
level: 3,
|
|
83
|
+
includes: {
|
|
84
|
+
query: ["name"],
|
|
85
|
+
header: ["age"]
|
|
86
|
+
},
|
|
87
|
+
matches: {
|
|
88
|
+
query: { name: { weixin: "^byted" } },
|
|
89
|
+
header: { age: { one: "^1" } }
|
|
100
90
|
}
|
|
101
|
-
}
|
|
91
|
+
},
|
|
92
|
+
content: "level3"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
url: "/level-three",
|
|
96
|
+
query: { name: "byted_likely" },
|
|
97
|
+
headers: { age: "19" }
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
url: "/level-three",
|
|
101
|
+
query: { name: "byted_likely" },
|
|
102
|
+
headers: {}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
url: "/level-three",
|
|
106
|
+
query: { name: "not_byted" },
|
|
107
|
+
headers: { age: "19" }
|
|
102
108
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
},
|
|
110
|
-
headers: {
|
|
111
|
-
age: '19'
|
|
112
|
-
}
|
|
113
|
-
}, {
|
|
114
|
-
url: '/level-three',
|
|
115
|
-
query: {
|
|
116
|
-
name: 'byted_likely'
|
|
117
|
-
},
|
|
118
|
-
headers: {}
|
|
119
|
-
}, {
|
|
120
|
-
url: '/level-three',
|
|
121
|
-
query: {
|
|
122
|
-
name: 'not_byted'
|
|
123
|
-
},
|
|
124
|
-
headers: {
|
|
125
|
-
age: '19'
|
|
126
|
-
}
|
|
127
|
-
}]];
|
|
128
|
-
exports.matchedCacheableAry = matchedCacheableAry;
|
|
109
|
+
]
|
|
110
|
+
];
|
|
111
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
112
|
+
0 && (module.exports = {
|
|
113
|
+
matchedCacheableAry
|
|
114
|
+
});
|
|
@@ -1,88 +1,134 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
22
|
+
};
|
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
+
for (let key of __getOwnPropNames(from))
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
+
}
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
var __async = (__this, __arguments, generator) => {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
var fulfilled = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.next(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var rejected = (value) => {
|
|
42
|
+
try {
|
|
43
|
+
step(generator.throw(value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
var cache_exports = {};
|
|
53
|
+
__export(cache_exports, {
|
|
54
|
+
default: () => cache_default
|
|
5
55
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const sprCache = (0, _spr.createCache)();
|
|
16
|
-
const doRender = async context => {
|
|
17
|
-
const cacheContext = _objectSpread({
|
|
56
|
+
module.exports = __toCommonJS(cache_exports);
|
|
57
|
+
var import_stream = require("stream");
|
|
58
|
+
var import_constants = require("../../../constants");
|
|
59
|
+
var import_spr = require("./spr");
|
|
60
|
+
var import_util = require("./util");
|
|
61
|
+
var cache_default = (renderFn, ctx) => {
|
|
62
|
+
const sprCache = (0, import_spr.createCache)();
|
|
63
|
+
const doRender = (context) => __async(void 0, null, function* () {
|
|
64
|
+
const cacheContext = __spreadValues({
|
|
18
65
|
entry: context.entryName
|
|
19
66
|
}, context.request);
|
|
20
|
-
const cacheFile =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
67
|
+
const cacheFile = yield sprCache.get(cacheContext);
|
|
68
|
+
function afterRender(source, onAfterRender) {
|
|
69
|
+
return __async(this, null, function* () {
|
|
70
|
+
if (!source) {
|
|
71
|
+
return "";
|
|
72
|
+
}
|
|
73
|
+
if (typeof source === "string") {
|
|
74
|
+
yield onAfterRender(source);
|
|
75
|
+
return source;
|
|
76
|
+
} else {
|
|
77
|
+
let htmlForStream = "";
|
|
78
|
+
const cacheStream = new import_stream.Transform({
|
|
79
|
+
write(chunk, _, callback) {
|
|
80
|
+
htmlForStream += chunk.toString();
|
|
81
|
+
this.push(chunk);
|
|
82
|
+
callback();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
cacheStream.on("close", () => onAfterRender(htmlForStream));
|
|
86
|
+
return source(cacheStream);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
41
89
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
cacheConfig
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
90
|
+
function saveHtmlIntoCache(html) {
|
|
91
|
+
return __async(this, null, function* () {
|
|
92
|
+
const { cacheConfig } = context;
|
|
93
|
+
if (html && cacheConfig) {
|
|
94
|
+
yield sprCache.set(cacheContext, html, cacheConfig);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
49
97
|
}
|
|
50
|
-
|
|
51
|
-
// no cache, render sync
|
|
52
98
|
if (!cacheFile) {
|
|
53
|
-
const renderResult =
|
|
99
|
+
const renderResult = yield renderFn(context);
|
|
54
100
|
return afterRender(renderResult, saveHtmlIntoCache);
|
|
55
101
|
}
|
|
56
|
-
const cacheHash = cacheFile
|
|
57
|
-
|
|
58
|
-
// completely expired
|
|
102
|
+
const cacheHash = cacheFile == null ? void 0 : cacheFile.hash;
|
|
59
103
|
if (cacheFile.isGarbage) {
|
|
60
|
-
const renderResult =
|
|
104
|
+
const renderResult = yield renderFn(context);
|
|
61
105
|
return afterRender(renderResult, saveHtmlIntoCache);
|
|
62
106
|
} else if (cacheFile.isStale) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
107
|
+
const render = (0, import_util.withCoalescedInvoke)(() => renderFn(context)).bind(
|
|
108
|
+
null,
|
|
109
|
+
(0, import_util.namespaceHash)("render", cacheFile.hash),
|
|
110
|
+
[]
|
|
111
|
+
);
|
|
112
|
+
render().then((res) => __async(void 0, null, function* () {
|
|
66
113
|
if (res.value && res.isOrigin) {
|
|
67
|
-
const {
|
|
68
|
-
cacheConfig
|
|
69
|
-
} = context;
|
|
114
|
+
const { cacheConfig } = context;
|
|
70
115
|
if (cacheConfig) {
|
|
71
|
-
afterRender(res.value,
|
|
116
|
+
afterRender(res.value, (html) => __async(void 0, null, function* () {
|
|
72
117
|
sprCache.set(cacheContext, html, cacheConfig);
|
|
73
|
-
});
|
|
118
|
+
}));
|
|
74
119
|
} else {
|
|
75
120
|
sprCache.del(cacheContext, cacheHash);
|
|
76
121
|
}
|
|
77
122
|
}
|
|
78
|
-
}).catch(e => {
|
|
123
|
+
})).catch((e) => {
|
|
79
124
|
sprCache.del(cacheContext, cacheHash);
|
|
80
|
-
ctx.error(
|
|
125
|
+
ctx.error(import_constants.ERROR_DIGEST.ERENDER, e);
|
|
81
126
|
});
|
|
82
127
|
}
|
|
83
|
-
ctx.res.setHeader(
|
|
128
|
+
ctx.res.setHeader("x-modern-spr", "1");
|
|
84
129
|
return cacheFile.content;
|
|
85
|
-
};
|
|
130
|
+
});
|
|
86
131
|
return doRender;
|
|
87
132
|
};
|
|
88
|
-
|
|
133
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
134
|
+
0 && (module.exports = {});
|
|
@@ -1,15 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
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 __async = (__this, __arguments, generator) => {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
var fulfilled = (value) => {
|
|
21
|
+
try {
|
|
22
|
+
step(generator.next(value));
|
|
23
|
+
} catch (e) {
|
|
24
|
+
reject(e);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var rejected = (value) => {
|
|
28
|
+
try {
|
|
29
|
+
step(generator.throw(value));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
reject(e);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
35
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
var page_caches_exports = {};
|
|
39
|
+
__export(page_caches_exports, {
|
|
40
|
+
createPageCaches: () => createPageCaches
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(page_caches_exports);
|
|
43
|
+
var import_lru = require("./lru");
|
|
44
|
+
function createPageCaches(max) {
|
|
45
|
+
return __async(this, null, function* () {
|
|
46
|
+
const constructorOptions = { max };
|
|
47
|
+
const cacheInstance = new import_lru.LRUCaches(constructorOptions);
|
|
48
|
+
yield cacheInstance.init();
|
|
49
|
+
return cacheInstance;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
createPageCaches
|
|
5
55
|
});
|
|
6
|
-
exports.createPageCaches = createPageCaches;
|
|
7
|
-
var _lru = require("./lru");
|
|
8
|
-
async function createPageCaches(max) {
|
|
9
|
-
const constructorOptions = {
|
|
10
|
-
max
|
|
11
|
-
};
|
|
12
|
-
const cacheInstance = new _lru.LRUCaches(constructorOptions);
|
|
13
|
-
await cacheInstance.init();
|
|
14
|
-
return cacheInstance;
|
|
15
|
-
}
|
|
@@ -1,18 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var lru_exports = {};
|
|
25
|
+
__export(lru_exports, {
|
|
26
|
+
LRUCaches: () => LRUCaches
|
|
5
27
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
28
|
+
module.exports = __toCommonJS(lru_exports);
|
|
29
|
+
var import_lru_cache = __toESM(require("lru-cache"));
|
|
10
30
|
class LRUCaches {
|
|
11
31
|
constructor(options) {
|
|
12
|
-
_defineProperty(this, "caches", void 0);
|
|
13
|
-
_defineProperty(this, "max", void 0);
|
|
14
32
|
this.max = options.max;
|
|
15
|
-
this.caches = new
|
|
33
|
+
this.caches = new import_lru_cache.default(this.max);
|
|
16
34
|
}
|
|
17
35
|
init() {
|
|
18
36
|
return Promise.resolve();
|
|
@@ -34,4 +52,7 @@ class LRUCaches {
|
|
|
34
52
|
this.caches.del(key);
|
|
35
53
|
}
|
|
36
54
|
}
|
|
37
|
-
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
LRUCaches
|
|
58
|
+
});
|