@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,13 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __async = (__this, __arguments, generator) => {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
var fulfilled = (value) => {
|
|
20
|
+
try {
|
|
21
|
+
step(generator.next(value));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var rejected = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.throw(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
34
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var import_spr = require("../spr");
|
|
38
|
+
var import_error_configuration = require("./error-configuration");
|
|
39
|
+
var import_cacheable = require("./cacheable");
|
|
40
|
+
var import_matched_cache = require("./matched-cache");
|
|
41
|
+
const createCacheConfig = (config = {}) => __spreadValues({
|
|
11
42
|
excludes: null,
|
|
12
43
|
includes: null,
|
|
13
44
|
interval: 10,
|
|
@@ -16,193 +47,181 @@ const createCacheConfig = (config = {}) => _objectSpread({
|
|
|
16
47
|
fallback: false,
|
|
17
48
|
matches: null
|
|
18
49
|
}, config);
|
|
19
|
-
jest.setTimeout(
|
|
20
|
-
describe(
|
|
21
|
-
it(
|
|
22
|
-
(0,
|
|
23
|
-
const cache = (0,
|
|
50
|
+
jest.setTimeout(6e4);
|
|
51
|
+
describe("cache", () => {
|
|
52
|
+
it("should cache correctly", () => __async(exports, null, function* () {
|
|
53
|
+
(0, import_spr.destroyCache)();
|
|
54
|
+
const cache = (0, import_spr.createCache)();
|
|
24
55
|
const context = {
|
|
25
|
-
entry:
|
|
26
|
-
pathname:
|
|
56
|
+
entry: "",
|
|
57
|
+
pathname: "",
|
|
27
58
|
query: {},
|
|
28
59
|
headers: {}
|
|
29
60
|
};
|
|
30
|
-
const content =
|
|
61
|
+
const content = "hello";
|
|
31
62
|
const cacheConfig = createCacheConfig();
|
|
32
|
-
|
|
33
|
-
const cacheResult =
|
|
63
|
+
yield cache.set(context, content, cacheConfig, true);
|
|
64
|
+
const cacheResult = yield cache.get(context);
|
|
34
65
|
expect(cacheResult).not.toBe(null);
|
|
35
|
-
expect(cacheResult
|
|
36
|
-
});
|
|
37
|
-
it(
|
|
38
|
-
(0,
|
|
39
|
-
(0,
|
|
40
|
-
const cache = (0,
|
|
66
|
+
expect(cacheResult == null ? void 0 : cacheResult.content).toBe("hello");
|
|
67
|
+
}));
|
|
68
|
+
it("should ignore cache set when cache config not exist", () => __async(exports, null, function* () {
|
|
69
|
+
(0, import_spr.destroyCache)();
|
|
70
|
+
(0, import_spr.destroyCache)();
|
|
71
|
+
const cache = (0, import_spr.createCache)();
|
|
41
72
|
const context = {
|
|
42
|
-
entry:
|
|
43
|
-
pathname:
|
|
73
|
+
entry: "",
|
|
74
|
+
pathname: "",
|
|
44
75
|
query: {},
|
|
45
76
|
headers: {}
|
|
46
77
|
};
|
|
47
|
-
const content =
|
|
48
|
-
const shouldCache =
|
|
78
|
+
const content = "hello";
|
|
79
|
+
const shouldCache = yield cache.set(context, content, null, true);
|
|
49
80
|
expect(shouldCache).toBe(false);
|
|
50
|
-
});
|
|
51
|
-
it(
|
|
52
|
-
(0,
|
|
53
|
-
const cache = (0,
|
|
54
|
-
const content =
|
|
55
|
-
for (const config of
|
|
81
|
+
}));
|
|
82
|
+
it("should calcual cache key error", () => __async(exports, null, function* () {
|
|
83
|
+
(0, import_spr.destroyCache)();
|
|
84
|
+
const cache = (0, import_spr.createCache)();
|
|
85
|
+
const content = "hello";
|
|
86
|
+
for (const config of import_error_configuration.errorConfiguration) {
|
|
56
87
|
const cacheConfig = createCacheConfig(config);
|
|
57
88
|
const tmpEntry = Math.random().toString();
|
|
58
89
|
const context = {
|
|
59
90
|
entry: tmpEntry,
|
|
60
|
-
pathname:
|
|
91
|
+
pathname: "",
|
|
61
92
|
query: {},
|
|
62
93
|
headers: {}
|
|
63
94
|
};
|
|
64
|
-
const shouldCache =
|
|
95
|
+
const shouldCache = yield cache.set(context, content, cacheConfig);
|
|
65
96
|
expect(shouldCache).toBe(false);
|
|
66
97
|
}
|
|
67
|
-
});
|
|
68
|
-
it(
|
|
69
|
-
(0,
|
|
70
|
-
const cache = (0,
|
|
98
|
+
}));
|
|
99
|
+
it("should get nothing for diff requestKey", () => __async(exports, null, function* () {
|
|
100
|
+
(0, import_spr.destroyCache)();
|
|
101
|
+
const cache = (0, import_spr.createCache)();
|
|
71
102
|
const context = {
|
|
72
|
-
entry:
|
|
73
|
-
pathname:
|
|
103
|
+
entry: "",
|
|
104
|
+
pathname: "",
|
|
74
105
|
query: {},
|
|
75
106
|
headers: {}
|
|
76
107
|
};
|
|
77
|
-
const content =
|
|
108
|
+
const content = "hello";
|
|
78
109
|
const cacheConfig = createCacheConfig({
|
|
79
110
|
level: 1,
|
|
80
|
-
includes: {
|
|
81
|
-
query: ['name']
|
|
82
|
-
}
|
|
111
|
+
includes: { query: ["name"] }
|
|
83
112
|
});
|
|
84
|
-
|
|
113
|
+
yield cache.set(context, content, cacheConfig, true);
|
|
85
114
|
const context_req = {
|
|
86
|
-
entry:
|
|
87
|
-
pathname:
|
|
115
|
+
entry: "",
|
|
116
|
+
pathname: "/home",
|
|
88
117
|
query: {},
|
|
89
118
|
headers: {}
|
|
90
119
|
};
|
|
91
|
-
const cacheResult =
|
|
120
|
+
const cacheResult = yield cache.get(context_req);
|
|
92
121
|
expect(cacheResult).toBe(null);
|
|
93
|
-
});
|
|
94
|
-
it(
|
|
95
|
-
(0,
|
|
96
|
-
const cache = (0,
|
|
122
|
+
}));
|
|
123
|
+
it("should get nothing for diff cacheHash", () => __async(exports, null, function* () {
|
|
124
|
+
(0, import_spr.destroyCache)();
|
|
125
|
+
const cache = (0, import_spr.createCache)();
|
|
97
126
|
const context = {
|
|
98
|
-
entry:
|
|
99
|
-
pathname:
|
|
127
|
+
entry: "",
|
|
128
|
+
pathname: "",
|
|
100
129
|
query: {},
|
|
101
130
|
headers: {}
|
|
102
131
|
};
|
|
103
|
-
const content =
|
|
132
|
+
const content = "hello";
|
|
104
133
|
const cacheConfig = createCacheConfig({
|
|
105
134
|
level: 1,
|
|
106
|
-
includes: {
|
|
107
|
-
query: ['name']
|
|
108
|
-
}
|
|
135
|
+
includes: { query: ["name"] }
|
|
109
136
|
});
|
|
110
|
-
|
|
137
|
+
yield cache.set(context, content, cacheConfig, true);
|
|
111
138
|
const context_req = {
|
|
112
|
-
entry:
|
|
113
|
-
pathname:
|
|
114
|
-
query: {
|
|
115
|
-
name: 'zll'
|
|
116
|
-
},
|
|
139
|
+
entry: "",
|
|
140
|
+
pathname: "",
|
|
141
|
+
query: { name: "zll" },
|
|
117
142
|
headers: {}
|
|
118
143
|
};
|
|
119
|
-
const cacheResult =
|
|
144
|
+
const cacheResult = yield cache.get(context_req);
|
|
120
145
|
expect(cacheResult).toBe(null);
|
|
121
|
-
});
|
|
122
|
-
it(
|
|
123
|
-
(0,
|
|
124
|
-
const cache = (0,
|
|
125
|
-
for (const cacheable of
|
|
146
|
+
}));
|
|
147
|
+
it("should get cache correctly", () => __async(exports, null, function* () {
|
|
148
|
+
(0, import_spr.destroyCache)();
|
|
149
|
+
const cache = (0, import_spr.createCache)();
|
|
150
|
+
for (const cacheable of import_cacheable.cacheabelAry) {
|
|
126
151
|
const context = {
|
|
127
|
-
entry:
|
|
152
|
+
entry: "",
|
|
128
153
|
pathname: cacheable.requestOpt.url,
|
|
129
154
|
query: cacheable.requestOpt.query || {},
|
|
130
155
|
headers: cacheable.requestOpt.headers || {}
|
|
131
156
|
};
|
|
132
157
|
const cacheConfig = createCacheConfig(cacheable.cacheConfig || {});
|
|
133
|
-
|
|
134
|
-
const cacheResult =
|
|
135
|
-
expect(cacheResult
|
|
158
|
+
yield cache.set(context, cacheable.content, cacheConfig, true);
|
|
159
|
+
const cacheResult = yield cache.get(context);
|
|
160
|
+
expect(cacheResult == null ? void 0 : cacheResult.content).toBe(cacheable.content);
|
|
136
161
|
}
|
|
137
|
-
});
|
|
138
|
-
it(
|
|
139
|
-
(0,
|
|
140
|
-
const cache = (0,
|
|
141
|
-
for (const cacheable of
|
|
162
|
+
}));
|
|
163
|
+
it("should match cache correctly", () => __async(exports, null, function* () {
|
|
164
|
+
(0, import_spr.destroyCache)();
|
|
165
|
+
const cache = (0, import_spr.createCache)();
|
|
166
|
+
for (const cacheable of import_matched_cache.matchedCacheableAry) {
|
|
142
167
|
const [baseCacheable, matchOne, ...other] = cacheable;
|
|
143
|
-
const {
|
|
144
|
-
requestOpt = {},
|
|
145
|
-
cacheConfig,
|
|
146
|
-
content
|
|
147
|
-
} = baseCacheable;
|
|
168
|
+
const { requestOpt = {}, cacheConfig, content } = baseCacheable;
|
|
148
169
|
const context = {
|
|
149
|
-
entry:
|
|
170
|
+
entry: "",
|
|
150
171
|
pathname: requestOpt.url,
|
|
151
172
|
query: requestOpt.query,
|
|
152
173
|
headers: requestOpt.headers
|
|
153
174
|
};
|
|
154
|
-
|
|
175
|
+
yield cache.set(context, content, createCacheConfig(cacheConfig), true);
|
|
155
176
|
const matchContext = {
|
|
156
|
-
entry:
|
|
177
|
+
entry: "",
|
|
157
178
|
pathname: matchOne.url,
|
|
158
179
|
query: matchOne.query,
|
|
159
180
|
headers: matchOne.headers
|
|
160
181
|
};
|
|
161
|
-
const cacheResult =
|
|
162
|
-
expect(cacheResult
|
|
182
|
+
const cacheResult = yield cache.get(matchContext);
|
|
183
|
+
expect(cacheResult == null ? void 0 : cacheResult.content).toBe(content);
|
|
163
184
|
for (const notMatch of other) {
|
|
164
185
|
const notMatchContext = {
|
|
165
|
-
entry:
|
|
186
|
+
entry: "",
|
|
166
187
|
pathname: notMatch.url,
|
|
167
188
|
query: notMatch.query,
|
|
168
189
|
headers: notMatch.headers
|
|
169
190
|
};
|
|
170
|
-
const nothing =
|
|
191
|
+
const nothing = yield cache.get(notMatchContext);
|
|
171
192
|
expect(nothing).toBe(null);
|
|
172
193
|
}
|
|
173
194
|
}
|
|
174
|
-
});
|
|
175
|
-
it(
|
|
176
|
-
(0,
|
|
177
|
-
const cache = (0,
|
|
195
|
+
}));
|
|
196
|
+
it("should stale cache correctly", () => __async(exports, null, function* () {
|
|
197
|
+
(0, import_spr.destroyCache)();
|
|
198
|
+
const cache = (0, import_spr.createCache)();
|
|
178
199
|
const context = {
|
|
179
|
-
entry:
|
|
180
|
-
pathname:
|
|
200
|
+
entry: "",
|
|
201
|
+
pathname: "",
|
|
181
202
|
query: {},
|
|
182
203
|
headers: {}
|
|
183
204
|
};
|
|
184
|
-
const config = createCacheConfig({
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const content = 'hello';
|
|
188
|
-
const shouldCache = await cache.set(context, content, config, true);
|
|
205
|
+
const config = createCacheConfig({ interval: 5 });
|
|
206
|
+
const content = "hello";
|
|
207
|
+
const shouldCache = yield cache.set(context, content, config, true);
|
|
189
208
|
expect(shouldCache.value).toBe(true);
|
|
190
|
-
const freshResult =
|
|
191
|
-
expect(freshResult
|
|
192
|
-
|
|
209
|
+
const freshResult = yield cache.get(context);
|
|
210
|
+
expect(freshResult == null ? void 0 : freshResult.isStale).toBe(false);
|
|
211
|
+
yield new Promise((resolve) => {
|
|
193
212
|
setTimeout(() => {
|
|
194
213
|
resolve();
|
|
195
|
-
},
|
|
214
|
+
}, 6e3);
|
|
196
215
|
});
|
|
197
|
-
const staleResult =
|
|
198
|
-
expect(staleResult
|
|
199
|
-
});
|
|
200
|
-
it(
|
|
201
|
-
(0,
|
|
202
|
-
const cache = (0,
|
|
216
|
+
const staleResult = yield cache.get(context);
|
|
217
|
+
expect(staleResult == null ? void 0 : staleResult.isStale).toBe(true);
|
|
218
|
+
}));
|
|
219
|
+
it("should garbage cache correctly", () => __async(exports, null, function* () {
|
|
220
|
+
(0, import_spr.destroyCache)();
|
|
221
|
+
const cache = (0, import_spr.createCache)();
|
|
203
222
|
const context = {
|
|
204
|
-
entry:
|
|
205
|
-
pathname:
|
|
223
|
+
entry: "",
|
|
224
|
+
pathname: "",
|
|
206
225
|
query: {},
|
|
207
226
|
headers: {}
|
|
208
227
|
};
|
|
@@ -210,17 +229,17 @@ describe('cache', () => {
|
|
|
210
229
|
interval: 3,
|
|
211
230
|
staleLimit: 8
|
|
212
231
|
});
|
|
213
|
-
const content =
|
|
214
|
-
const shouldCache =
|
|
232
|
+
const content = "hello";
|
|
233
|
+
const shouldCache = yield cache.set(context, content, config, true);
|
|
215
234
|
expect(shouldCache.value).toBe(true);
|
|
216
|
-
const freshResult =
|
|
217
|
-
expect(freshResult
|
|
218
|
-
|
|
235
|
+
const freshResult = yield cache.get(context);
|
|
236
|
+
expect(freshResult == null ? void 0 : freshResult.isGarbage).toBe(false);
|
|
237
|
+
yield new Promise((resolve) => {
|
|
219
238
|
setTimeout(() => {
|
|
220
239
|
resolve();
|
|
221
|
-
},
|
|
240
|
+
}, 1e4);
|
|
222
241
|
});
|
|
223
|
-
const staleResult =
|
|
224
|
-
expect(staleResult
|
|
225
|
-
});
|
|
226
|
-
});
|
|
242
|
+
const staleResult = yield cache.get(context);
|
|
243
|
+
expect(staleResult == null ? void 0 : staleResult.isGarbage).toBe(true);
|
|
244
|
+
}));
|
|
245
|
+
});
|
|
@@ -1,60 +1,70 @@
|
|
|
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 cacheable_exports = {};
|
|
19
|
+
__export(cacheable_exports, {
|
|
20
|
+
cacheabelAry: () => cacheabelAry
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
const cacheabelAry = [
|
|
8
|
-
|
|
9
|
-
url:
|
|
22
|
+
module.exports = __toCommonJS(cacheable_exports);
|
|
23
|
+
const cacheabelAry = [
|
|
24
|
+
{
|
|
25
|
+
requestOpt: { url: "/" },
|
|
26
|
+
cacheConfig: {},
|
|
27
|
+
content: "level0"
|
|
10
28
|
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
cacheConfig: {
|
|
21
|
-
level: 1,
|
|
22
|
-
includes: {
|
|
23
|
-
query: ['name']
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
content: 'level1'
|
|
27
|
-
}, {
|
|
28
|
-
requestOpt: {
|
|
29
|
-
url: '/level-two',
|
|
30
|
-
headers: {
|
|
31
|
-
age: '18'
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
cacheConfig: {
|
|
35
|
-
level: 2,
|
|
36
|
-
includes: {
|
|
37
|
-
header: ['age']
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
content: 'level2'
|
|
41
|
-
}, {
|
|
42
|
-
requestOpt: {
|
|
43
|
-
url: '/level-three',
|
|
44
|
-
query: {
|
|
45
|
-
name: 'modern'
|
|
29
|
+
{
|
|
30
|
+
requestOpt: {
|
|
31
|
+
url: "/level-one",
|
|
32
|
+
query: { name: "modern" }
|
|
33
|
+
},
|
|
34
|
+
cacheConfig: {
|
|
35
|
+
level: 1,
|
|
36
|
+
includes: { query: ["name"] }
|
|
46
37
|
},
|
|
47
|
-
|
|
48
|
-
age: '18'
|
|
49
|
-
}
|
|
38
|
+
content: "level1"
|
|
50
39
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
{
|
|
41
|
+
requestOpt: {
|
|
42
|
+
url: "/level-two",
|
|
43
|
+
headers: { age: "18" }
|
|
44
|
+
},
|
|
45
|
+
cacheConfig: {
|
|
46
|
+
level: 2,
|
|
47
|
+
includes: { header: ["age"] }
|
|
48
|
+
},
|
|
49
|
+
content: "level2"
|
|
57
50
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
{
|
|
52
|
+
requestOpt: {
|
|
53
|
+
url: "/level-three",
|
|
54
|
+
query: { name: "modern" },
|
|
55
|
+
headers: { age: "18" }
|
|
56
|
+
},
|
|
57
|
+
cacheConfig: {
|
|
58
|
+
level: 3,
|
|
59
|
+
includes: {
|
|
60
|
+
query: ["name"],
|
|
61
|
+
header: ["age"]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
content: "level3"
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
cacheabelAry
|
|
70
|
+
});
|
|
@@ -1,42 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
includes: {
|
|
15
|
-
query: []
|
|
16
|
-
}
|
|
17
|
-
}, {
|
|
18
|
-
level: 2,
|
|
19
|
-
includes: {}
|
|
20
|
-
}, {
|
|
21
|
-
level: 2,
|
|
22
|
-
includes: {
|
|
23
|
-
header: []
|
|
24
|
-
}
|
|
25
|
-
}, {
|
|
26
|
-
level: 3,
|
|
27
|
-
includes: {
|
|
28
|
-
header: []
|
|
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 });
|
|
29
14
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(error_configuration_exports);
|
|
23
|
+
const errorConfiguration = [
|
|
24
|
+
{ level: 1 },
|
|
25
|
+
{
|
|
26
|
+
level: 1,
|
|
27
|
+
includes: {}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
level: 1,
|
|
31
|
+
includes: { query: [] }
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
level: 2,
|
|
35
|
+
includes: {}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
level: 2,
|
|
39
|
+
includes: { header: [] }
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
level: 3,
|
|
43
|
+
includes: { header: [] }
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
level: 3,
|
|
47
|
+
includes: { query: [] }
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
level: 3,
|
|
51
|
+
includes: {
|
|
52
|
+
query: [],
|
|
53
|
+
header: []
|
|
54
|
+
}
|
|
40
55
|
}
|
|
41
|
-
|
|
42
|
-
|
|
56
|
+
];
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
errorConfiguration
|
|
60
|
+
});
|