@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.
Files changed (130) hide show
  1. package/CHANGELOG.md +139 -0
  2. package/dist/js/modern/constants.js +32 -25
  3. package/dist/js/modern/index.js +11 -6
  4. package/dist/js/modern/libs/context/context.js +52 -84
  5. package/dist/js/modern/libs/context/index.js +5 -2
  6. package/dist/js/modern/libs/hook-api/index.js +44 -35
  7. package/dist/js/modern/libs/hook-api/route.js +6 -7
  8. package/dist/js/modern/libs/hook-api/template.js +20 -34
  9. package/dist/js/modern/libs/loadConfig.js +45 -24
  10. package/dist/js/modern/libs/metrics.js +3 -4
  11. package/dist/js/modern/libs/proxy.js +68 -37
  12. package/dist/js/modern/libs/render/cache/__tests__/cache.fun.test.js +112 -67
  13. package/dist/js/modern/libs/render/cache/__tests__/cache.test.js +246 -216
  14. package/dist/js/modern/libs/render/cache/__tests__/cacheable.js +43 -49
  15. package/dist/js/modern/libs/render/cache/__tests__/error-configuration.js +36 -34
  16. package/dist/js/modern/libs/render/cache/__tests__/matched-cache.js +83 -113
  17. package/dist/js/modern/libs/render/cache/index.js +88 -54
  18. package/dist/js/modern/libs/render/cache/page-caches/index.js +31 -8
  19. package/dist/js/modern/libs/render/cache/page-caches/lru.js +6 -6
  20. package/dist/js/modern/libs/render/cache/spr.js +133 -117
  21. package/dist/js/modern/libs/render/cache/type.js +0 -1
  22. package/dist/js/modern/libs/render/cache/util.js +71 -39
  23. package/dist/js/modern/libs/render/index.js +76 -56
  24. package/dist/js/modern/libs/render/measure.js +38 -27
  25. package/dist/js/modern/libs/render/reader.js +65 -62
  26. package/dist/js/modern/libs/render/ssr.js +50 -32
  27. package/dist/js/modern/libs/render/static.js +50 -33
  28. package/dist/js/modern/libs/render/type.js +9 -6
  29. package/dist/js/modern/libs/route/index.js +8 -15
  30. package/dist/js/modern/libs/route/matcher.js +20 -34
  31. package/dist/js/modern/libs/route/route.js +9 -18
  32. package/dist/js/modern/libs/serve-file.js +33 -20
  33. package/dist/js/modern/server/index.js +150 -145
  34. package/dist/js/modern/server/modern-server-split.js +46 -12
  35. package/dist/js/modern/server/modern-server.js +384 -422
  36. package/dist/js/modern/type.js +0 -1
  37. package/dist/js/modern/utils.js +62 -43
  38. package/dist/js/modern/worker-server.js +34 -14
  39. package/dist/js/node/constants.js +53 -30
  40. package/dist/js/node/index.js +37 -57
  41. package/dist/js/node/libs/context/context.js +83 -94
  42. package/dist/js/node/libs/context/index.js +28 -13
  43. package/dist/js/node/libs/hook-api/index.js +76 -48
  44. package/dist/js/node/libs/hook-api/route.js +26 -11
  45. package/dist/js/node/libs/hook-api/template.js +41 -39
  46. package/dist/js/node/libs/loadConfig.js +73 -35
  47. package/dist/js/node/libs/metrics.js +25 -9
  48. package/dist/js/node/libs/proxy.js +89 -44
  49. package/dist/js/node/libs/render/cache/__tests__/cache.fun.test.js +99 -56
  50. package/dist/js/node/libs/render/cache/__tests__/cache.test.js +147 -128
  51. package/dist/js/node/libs/render/cache/__tests__/cacheable.js +65 -55
  52. package/dist/js/node/libs/render/cache/__tests__/error-configuration.js +58 -40
  53. package/dist/js/node/libs/render/cache/__tests__/matched-cache.js +105 -119
  54. package/dist/js/node/libs/render/cache/index.js +110 -64
  55. package/dist/js/node/libs/render/cache/page-caches/index.js +54 -14
  56. package/dist/js/node/libs/render/cache/page-caches/lru.js +33 -12
  57. package/dist/js/node/libs/render/cache/spr.js +161 -129
  58. package/dist/js/node/libs/render/cache/type.js +15 -5
  59. package/dist/js/node/libs/render/cache/util.js +99 -45
  60. package/dist/js/node/libs/render/index.js +106 -67
  61. package/dist/js/node/libs/render/measure.js +58 -31
  62. package/dist/js/node/libs/render/reader.js +95 -70
  63. package/dist/js/node/libs/render/ssr.js +80 -47
  64. package/dist/js/node/libs/render/static.js +79 -40
  65. package/dist/js/node/libs/render/type.js +31 -12
  66. package/dist/js/node/libs/route/index.js +31 -26
  67. package/dist/js/node/libs/route/matcher.js +40 -41
  68. package/dist/js/node/libs/route/route.js +29 -22
  69. package/dist/js/node/libs/serve-file.js +66 -32
  70. package/dist/js/node/server/index.js +168 -160
  71. package/dist/js/node/server/modern-server-split.js +72 -22
  72. package/dist/js/node/server/modern-server.js +403 -445
  73. package/dist/js/node/type.js +15 -3
  74. package/dist/js/node/utils.js +85 -52
  75. package/dist/js/node/worker-server.js +57 -21
  76. package/dist/js/treeshaking/constants.js +26 -25
  77. package/dist/js/treeshaking/index.js +10 -10
  78. package/dist/js/treeshaking/libs/context/context.js +268 -237
  79. package/dist/js/treeshaking/libs/context/index.js +3 -3
  80. package/dist/js/treeshaking/libs/hook-api/index.js +267 -143
  81. package/dist/js/treeshaking/libs/hook-api/route.js +65 -30
  82. package/dist/js/treeshaking/libs/hook-api/template.js +121 -85
  83. package/dist/js/treeshaking/libs/loadConfig.js +80 -37
  84. package/dist/js/treeshaking/libs/metrics.js +4 -10
  85. package/dist/js/treeshaking/libs/proxy.js +240 -76
  86. package/dist/js/treeshaking/libs/render/cache/__tests__/cache.fun.test.js +288 -121
  87. package/dist/js/treeshaking/libs/render/cache/__tests__/cache.test.js +772 -455
  88. package/dist/js/treeshaking/libs/render/cache/__tests__/cacheable.js +65 -51
  89. package/dist/js/treeshaking/libs/render/cache/__tests__/error-configuration.js +45 -35
  90. package/dist/js/treeshaking/libs/render/cache/__tests__/matched-cache.js +144 -118
  91. package/dist/js/treeshaking/libs/render/cache/index.js +337 -175
  92. package/dist/js/treeshaking/libs/render/cache/page-caches/index.js +151 -27
  93. package/dist/js/treeshaking/libs/render/cache/page-caches/lru.js +80 -42
  94. package/dist/js/treeshaking/libs/render/cache/spr.js +470 -340
  95. package/dist/js/treeshaking/libs/render/cache/type.js +1 -1
  96. package/dist/js/treeshaking/libs/render/cache/util.js +271 -92
  97. package/dist/js/treeshaking/libs/render/index.js +228 -95
  98. package/dist/js/treeshaking/libs/render/measure.js +142 -57
  99. package/dist/js/treeshaking/libs/render/reader.js +325 -177
  100. package/dist/js/treeshaking/libs/render/ssr.js +220 -95
  101. package/dist/js/treeshaking/libs/render/static.js +210 -78
  102. package/dist/js/treeshaking/libs/render/type.js +7 -6
  103. package/dist/js/treeshaking/libs/route/index.js +125 -89
  104. package/dist/js/treeshaking/libs/route/matcher.js +132 -107
  105. package/dist/js/treeshaking/libs/route/route.js +40 -26
  106. package/dist/js/treeshaking/libs/serve-file.js +177 -68
  107. package/dist/js/treeshaking/server/index.js +493 -327
  108. package/dist/js/treeshaking/server/modern-server-split.js +352 -144
  109. package/dist/js/treeshaking/server/modern-server.js +1048 -909
  110. package/dist/js/treeshaking/type.js +1 -1
  111. package/dist/js/treeshaking/utils.js +138 -81
  112. package/dist/js/treeshaking/worker-server.js +176 -55
  113. package/dist/types/index.d.ts +2 -0
  114. package/dist/types/libs/context/context.d.ts +4 -1
  115. package/dist/types/libs/loadConfig.d.ts +1 -0
  116. package/dist/types/libs/render/cache/index.d.ts +2 -0
  117. package/dist/types/libs/render/cache/spr.d.ts +2 -0
  118. package/dist/types/libs/route/route.d.ts +0 -1
  119. package/dist/types/server/index.d.ts +3 -0
  120. package/dist/types/utils.d.ts +1 -1
  121. package/dist/types/worker-server.d.ts +1 -2
  122. package/package.json +7 -14
  123. package/dist/js/modern/libs/render/modern/browser-list.js +0 -7
  124. package/dist/js/modern/libs/render/modern/index.js +0 -37
  125. package/dist/js/node/libs/render/modern/browser-list.js +0 -14
  126. package/dist/js/node/libs/render/modern/index.js +0 -46
  127. package/dist/js/treeshaking/libs/render/modern/browser-list.js +0 -7
  128. package/dist/js/treeshaking/libs/render/modern/index.js +0 -39
  129. package/dist/types/libs/render/modern/browser-list.d.ts +0 -1
  130. package/dist/types/libs/render/modern/index.d.ts +0 -3
@@ -1,13 +1,44 @@
1
- "use strict";
2
-
3
- var _spr = require("../spr");
4
- var _errorConfiguration = require("./error-configuration");
5
- var _cacheable = require("./cacheable");
6
- var _matchedCache = require("./matched-cache");
7
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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; }
10
- const createCacheConfig = (config = {}) => _objectSpread({
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(60000);
20
- describe('cache', () => {
21
- it('should cache correctly', async () => {
22
- (0, _spr.destroyCache)();
23
- const cache = (0, _spr.createCache)();
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 = 'hello';
61
+ const content = "hello";
31
62
  const cacheConfig = createCacheConfig();
32
- await cache.set(context, content, cacheConfig, true);
33
- const cacheResult = await cache.get(context);
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 === null || cacheResult === void 0 ? void 0 : cacheResult.content).toBe('hello');
36
- });
37
- it('should ignore cache set when cache config not exist', async () => {
38
- (0, _spr.destroyCache)();
39
- (0, _spr.destroyCache)();
40
- const cache = (0, _spr.createCache)();
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 = 'hello';
48
- const shouldCache = await cache.set(context, content, null, true);
78
+ const content = "hello";
79
+ const shouldCache = yield cache.set(context, content, null, true);
49
80
  expect(shouldCache).toBe(false);
50
- });
51
- it('should calcual cache key error', async () => {
52
- (0, _spr.destroyCache)();
53
- const cache = (0, _spr.createCache)();
54
- const content = 'hello';
55
- for (const config of _errorConfiguration.errorConfiguration) {
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 = await cache.set(context, content, cacheConfig);
95
+ const shouldCache = yield cache.set(context, content, cacheConfig);
65
96
  expect(shouldCache).toBe(false);
66
97
  }
67
- });
68
- it('should get nothing for diff requestKey', async () => {
69
- (0, _spr.destroyCache)();
70
- const cache = (0, _spr.createCache)();
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 = 'hello';
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
- await cache.set(context, content, cacheConfig, true);
113
+ yield cache.set(context, content, cacheConfig, true);
85
114
  const context_req = {
86
- entry: '',
87
- pathname: '/home',
115
+ entry: "",
116
+ pathname: "/home",
88
117
  query: {},
89
118
  headers: {}
90
119
  };
91
- const cacheResult = await cache.get(context_req);
120
+ const cacheResult = yield cache.get(context_req);
92
121
  expect(cacheResult).toBe(null);
93
- });
94
- it('should get nothing for diff cacheHash', async () => {
95
- (0, _spr.destroyCache)();
96
- const cache = (0, _spr.createCache)();
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 = 'hello';
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
- await cache.set(context, content, cacheConfig, true);
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 = await cache.get(context_req);
144
+ const cacheResult = yield cache.get(context_req);
120
145
  expect(cacheResult).toBe(null);
121
- });
122
- it('should get cache correctly', async () => {
123
- (0, _spr.destroyCache)();
124
- const cache = (0, _spr.createCache)();
125
- for (const cacheable of _cacheable.cacheabelAry) {
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
- await cache.set(context, cacheable.content, cacheConfig, true);
134
- const cacheResult = await cache.get(context);
135
- expect(cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.content).toBe(cacheable.content);
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('should match cache correctly', async () => {
139
- (0, _spr.destroyCache)();
140
- const cache = (0, _spr.createCache)();
141
- for (const cacheable of _matchedCache.matchedCacheableAry) {
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
- await cache.set(context, content, createCacheConfig(cacheConfig), true);
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 = await cache.get(matchContext);
162
- expect(cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.content).toBe(content);
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 = await cache.get(notMatchContext);
191
+ const nothing = yield cache.get(notMatchContext);
171
192
  expect(nothing).toBe(null);
172
193
  }
173
194
  }
174
- });
175
- it('should stale cache correctly', async () => {
176
- (0, _spr.destroyCache)();
177
- const cache = (0, _spr.createCache)();
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
- interval: 5
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 = await cache.get(context);
191
- expect(freshResult === null || freshResult === void 0 ? void 0 : freshResult.isStale).toBe(false);
192
- await new Promise(resolve => {
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
- }, 6000);
214
+ }, 6e3);
196
215
  });
197
- const staleResult = await cache.get(context);
198
- expect(staleResult === null || staleResult === void 0 ? void 0 : staleResult.isStale).toBe(true);
199
- });
200
- it('should garbage cache correctly', async () => {
201
- (0, _spr.destroyCache)();
202
- const cache = (0, _spr.createCache)();
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 = 'hello';
214
- const shouldCache = await cache.set(context, content, config, true);
232
+ const content = "hello";
233
+ const shouldCache = yield cache.set(context, content, config, true);
215
234
  expect(shouldCache.value).toBe(true);
216
- const freshResult = await cache.get(context);
217
- expect(freshResult === null || freshResult === void 0 ? void 0 : freshResult.isGarbage).toBe(false);
218
- await new Promise(resolve => {
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
- }, 10000);
240
+ }, 1e4);
222
241
  });
223
- const staleResult = await cache.get(context);
224
- expect(staleResult === null || staleResult === void 0 ? void 0 : staleResult.isGarbage).toBe(true);
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
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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.cacheabelAry = void 0;
7
- const cacheabelAry = [{
8
- requestOpt: {
9
- url: '/'
22
+ module.exports = __toCommonJS(cacheable_exports);
23
+ const cacheabelAry = [
24
+ {
25
+ requestOpt: { url: "/" },
26
+ cacheConfig: {},
27
+ content: "level0"
10
28
  },
11
- cacheConfig: {},
12
- content: 'level0'
13
- }, {
14
- requestOpt: {
15
- url: '/level-one',
16
- query: {
17
- name: 'modern'
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
- headers: {
48
- age: '18'
49
- }
38
+ content: "level1"
50
39
  },
51
- cacheConfig: {
52
- level: 3,
53
- includes: {
54
- query: ['name'],
55
- header: ['age']
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
- content: 'level3'
59
- }];
60
- exports.cacheabelAry = cacheabelAry;
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
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.errorConfiguration = void 0;
7
- const errorConfiguration = [{
8
- level: 1
9
- }, {
10
- level: 1,
11
- includes: {}
12
- }, {
13
- level: 1,
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
- level: 3,
32
- includes: {
33
- query: []
34
- }
35
- }, {
36
- level: 3,
37
- includes: {
38
- query: [],
39
- header: []
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
- exports.errorConfiguration = errorConfiguration;
56
+ ];
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ errorConfiguration
60
+ });