@modern-js/prod-server 2.0.0-beta.3 → 2.0.0-beta.4

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 +69 -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 +42 -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 +144 -145
  34. package/dist/js/modern/server/modern-server-split.js +46 -12
  35. package/dist/js/modern/server/modern-server.js +377 -417
  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 +45 -30
  40. package/dist/js/node/index.js +31 -57
  41. package/dist/js/node/libs/context/context.js +79 -94
  42. package/dist/js/node/libs/context/index.js +23 -13
  43. package/dist/js/node/libs/hook-api/index.js +69 -48
  44. package/dist/js/node/libs/hook-api/route.js +22 -11
  45. package/dist/js/node/libs/hook-api/template.js +36 -39
  46. package/dist/js/node/libs/loadConfig.js +69 -35
  47. package/dist/js/node/libs/metrics.js +21 -9
  48. package/dist/js/node/libs/proxy.js +86 -44
  49. package/dist/js/node/libs/render/cache/__tests__/cache.fun.test.js +132 -70
  50. package/dist/js/node/libs/render/cache/__tests__/cache.test.js +268 -218
  51. package/dist/js/node/libs/render/cache/__tests__/cacheable.js +61 -55
  52. package/dist/js/node/libs/render/cache/__tests__/error-configuration.js +54 -40
  53. package/dist/js/node/libs/render/cache/__tests__/matched-cache.js +101 -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 +50 -14
  56. package/dist/js/node/libs/render/cache/page-caches/lru.js +29 -12
  57. package/dist/js/node/libs/render/cache/spr.js +156 -129
  58. package/dist/js/node/libs/render/cache/type.js +0 -5
  59. package/dist/js/node/libs/render/cache/util.js +88 -45
  60. package/dist/js/node/libs/render/index.js +102 -67
  61. package/dist/js/node/libs/render/measure.js +55 -31
  62. package/dist/js/node/libs/render/reader.js +87 -70
  63. package/dist/js/node/libs/render/ssr.js +76 -47
  64. package/dist/js/node/libs/render/static.js +75 -40
  65. package/dist/js/node/libs/render/type.js +27 -12
  66. package/dist/js/node/libs/route/index.js +26 -26
  67. package/dist/js/node/libs/route/matcher.js +36 -41
  68. package/dist/js/node/libs/route/route.js +25 -22
  69. package/dist/js/node/libs/serve-file.js +61 -32
  70. package/dist/js/node/server/index.js +160 -160
  71. package/dist/js/node/server/modern-server-split.js +68 -22
  72. package/dist/js/node/server/modern-server.js +395 -441
  73. package/dist/js/node/type.js +0 -3
  74. package/dist/js/node/utils.js +74 -52
  75. package/dist/js/node/worker-server.js +53 -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 +265 -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 +468 -327
  108. package/dist/js/treeshaking/server/modern-server-split.js +352 -144
  109. package/dist/js/treeshaking/server/modern-server.js +1046 -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,157 +1,279 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
- import _createClass from "@babel/runtime/helpers/esm/createClass";
5
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
6
- import cookie from 'cookie';
7
- import { RouteAPI } from "./route";
8
- import { TemplateAPI } from "./template";
9
- var Response = /*#__PURE__*/function () {
10
- function Response(res) {
11
- _classCallCheck(this, Response);
12
- _defineProperty(this, "cookies", void 0);
13
- _defineProperty(this, "res", void 0);
14
- _defineProperty(this, "_cookie", void 0);
15
- this.res = res;
16
- this._cookie = cookie.parse(res.getHeader('set-cookie') || '');
17
- this.cookies = {
18
- get: this.getCookie.bind(this),
19
- set: this.setCookie.bind(this),
20
- "delete": this.deleteCookie.bind(this),
21
- clear: this.clearCookie.bind(this),
22
- apply: this.applyCookie.bind(this)
23
- };
24
- }
25
- _createClass(Response, [{
26
- key: "get",
27
- value: function get(key) {
28
- return this.res.getHeader(key);
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _arrayWithHoles(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
9
+ function _classCallCheck(instance, Constructor) {
10
+ if (!(instance instanceof Constructor)) {
11
+ throw new TypeError("Cannot call a class as a function");
29
12
  }
30
- }, {
31
- key: "set",
32
- value: function set(key, value) {
33
- return this.res.setHeader(key, value);
13
+ }
14
+ function _defineProperties(target, props) {
15
+ for(var i = 0; i < props.length; i++){
16
+ var descriptor = props[i];
17
+ descriptor.enumerable = descriptor.enumerable || false;
18
+ descriptor.configurable = true;
19
+ if ("value" in descriptor) descriptor.writable = true;
20
+ Object.defineProperty(target, descriptor.key, descriptor);
34
21
  }
35
- }, {
36
- key: "status",
37
- value: function status(code) {
38
- this.res.statusCode = code;
22
+ }
23
+ function _createClass(Constructor, protoProps, staticProps) {
24
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
25
+ if (staticProps) _defineProperties(Constructor, staticProps);
26
+ return Constructor;
27
+ }
28
+ function _defineProperty(obj, key, value) {
29
+ if (key in obj) {
30
+ Object.defineProperty(obj, key, {
31
+ value: value,
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true
35
+ });
36
+ } else {
37
+ obj[key] = value;
39
38
  }
40
- }, {
41
- key: "getCookie",
42
- value: function getCookie(key) {
43
- return this._cookie[key];
39
+ return obj;
40
+ }
41
+ function _iterableToArrayLimit(arr, i) {
42
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
43
+ if (_i == null) return;
44
+ var _arr = [];
45
+ var _n = true;
46
+ var _d = false;
47
+ var _s, _e;
48
+ try {
49
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
50
+ _arr.push(_s.value);
51
+ if (i && _arr.length === i) break;
52
+ }
53
+ } catch (err) {
54
+ _d = true;
55
+ _e = err;
56
+ } finally{
57
+ try {
58
+ if (!_n && _i["return"] != null) _i["return"]();
59
+ } finally{
60
+ if (_d) throw _e;
61
+ }
44
62
  }
45
- }, {
46
- key: "setCookie",
47
- value: function setCookie(key, value) {
48
- this._cookie[key] = value;
63
+ return _arr;
64
+ }
65
+ function _nonIterableRest() {
66
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
67
+ }
68
+ function _objectSpread(target) {
69
+ for(var i = 1; i < arguments.length; i++){
70
+ var source = arguments[i] != null ? arguments[i] : {};
71
+ var ownKeys = Object.keys(source);
72
+ if (typeof Object.getOwnPropertySymbols === "function") {
73
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
74
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
75
+ }));
76
+ }
77
+ ownKeys.forEach(function(key) {
78
+ _defineProperty(target, key, source[key]);
79
+ });
49
80
  }
50
- }, {
51
- key: "deleteCookie",
52
- value: function deleteCookie(key) {
53
- if (this._cookie[key]) {
54
- delete this._cookie[key];
55
- }
81
+ return target;
82
+ }
83
+ function ownKeys(object, enumerableOnly) {
84
+ var keys = Object.keys(object);
85
+ if (Object.getOwnPropertySymbols) {
86
+ var symbols = Object.getOwnPropertySymbols(object);
87
+ if (enumerableOnly) {
88
+ symbols = symbols.filter(function(sym) {
89
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
90
+ });
91
+ }
92
+ keys.push.apply(keys, symbols);
56
93
  }
57
- }, {
58
- key: "clearCookie",
59
- value: function clearCookie() {
60
- this._cookie = {};
94
+ return keys;
95
+ }
96
+ function _objectSpreadProps(target, source) {
97
+ source = source != null ? source : {};
98
+ if (Object.getOwnPropertyDescriptors) {
99
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
100
+ } else {
101
+ ownKeys(Object(source)).forEach(function(key) {
102
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
103
+ });
61
104
  }
62
- }, {
63
- key: "applyCookie",
64
- value: function applyCookie() {
65
- var str = Object.entries(this._cookie).map(function (_ref) {
66
- var _ref2 = _slicedToArray(_ref, 2),
67
- key = _ref2[0],
68
- value = _ref2[1];
69
- return cookie.serialize(key, value);
70
- }).join('; ');
71
- if (str) {
72
- this.res.setHeader('set-cookie', str);
73
- } else {
74
- this.res.removeHeader('set-cookie');
75
- }
76
- }
77
- }, {
78
- key: "raw",
79
- value: function raw(body, _ref3) {
80
- var _this = this;
81
- var status = _ref3.status,
82
- headers = _ref3.headers;
83
- Object.entries(headers).forEach(function (_ref4) {
84
- var _ref5 = _slicedToArray(_ref4, 2),
85
- key = _ref5[0],
86
- value = _ref5[1];
87
- _this.res.setHeader(key, value);
88
- });
89
- if (status) {
90
- this.res.statusCode = status;
91
- }
92
- this.res.end(body);
105
+ return target;
106
+ }
107
+ function _slicedToArray(arr, i) {
108
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
109
+ }
110
+ function _unsupportedIterableToArray(o, minLen) {
111
+ if (!o) return;
112
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
113
+ var n = Object.prototype.toString.call(o).slice(8, -1);
114
+ if (n === "Object" && o.constructor) n = o.constructor.name;
115
+ if (n === "Map" || n === "Set") return Array.from(n);
116
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
117
+ }
118
+ import cookie from "cookie";
119
+ import { RouteAPI } from "./route";
120
+ import { TemplateAPI } from "./template";
121
+ var Response = /*#__PURE__*/ function() {
122
+ "use strict";
123
+ function Response(res) {
124
+ _classCallCheck(this, Response);
125
+ _defineProperty(this, "cookies", void 0);
126
+ _defineProperty(this, "res", void 0);
127
+ _defineProperty(this, "_cookie", void 0);
128
+ this.res = res;
129
+ this._cookie = cookie.parse(res.getHeader("set-cookie") || "");
130
+ this.cookies = {
131
+ get: this.getCookie.bind(this),
132
+ set: this.setCookie.bind(this),
133
+ delete: this.deleteCookie.bind(this),
134
+ clear: this.clearCookie.bind(this),
135
+ apply: this.applyCookie.bind(this)
136
+ };
93
137
  }
94
- }]);
95
- return Response;
138
+ _createClass(Response, [
139
+ {
140
+ key: "get",
141
+ value: function get(key) {
142
+ return this.res.getHeader(key);
143
+ }
144
+ },
145
+ {
146
+ key: "set",
147
+ value: function set(key, value) {
148
+ return this.res.setHeader(key, value);
149
+ }
150
+ },
151
+ {
152
+ key: "status",
153
+ value: function status(code) {
154
+ this.res.statusCode = code;
155
+ }
156
+ },
157
+ {
158
+ key: "getCookie",
159
+ value: function getCookie(key) {
160
+ return this._cookie[key];
161
+ }
162
+ },
163
+ {
164
+ key: "setCookie",
165
+ value: function setCookie(key, value) {
166
+ this._cookie[key] = value;
167
+ }
168
+ },
169
+ {
170
+ key: "deleteCookie",
171
+ value: function deleteCookie(key) {
172
+ if (this._cookie[key]) {
173
+ delete this._cookie[key];
174
+ }
175
+ }
176
+ },
177
+ {
178
+ key: "clearCookie",
179
+ value: function clearCookie() {
180
+ this._cookie = {};
181
+ }
182
+ },
183
+ {
184
+ key: "applyCookie",
185
+ value: function applyCookie() {
186
+ var str = Object.entries(this._cookie).map(function(param) {
187
+ var _param = _slicedToArray(param, 2), key = _param[0], value = _param[1];
188
+ return cookie.serialize(key, value);
189
+ }).join("; ");
190
+ if (str) {
191
+ this.res.setHeader("set-cookie", str);
192
+ } else {
193
+ this.res.removeHeader("set-cookie");
194
+ }
195
+ }
196
+ },
197
+ {
198
+ key: "raw",
199
+ value: function raw(body, param) {
200
+ var status = param.status, headers = param.headers;
201
+ var _this = this;
202
+ Object.entries(headers).forEach(function(param) {
203
+ var _param = _slicedToArray(param, 2), key = _param[0], value = _param[1];
204
+ _this.res.setHeader(key, value);
205
+ });
206
+ if (status) {
207
+ this.res.statusCode = status;
208
+ }
209
+ this.res.end(body);
210
+ }
211
+ }
212
+ ]);
213
+ return Response;
96
214
  }();
97
- var Request = /*#__PURE__*/function () {
98
- function Request(ctx) {
99
- _classCallCheck(this, Request);
100
- _defineProperty(this, "host", void 0);
101
- _defineProperty(this, "pathname", void 0);
102
- _defineProperty(this, "query", void 0);
103
- _defineProperty(this, "headers", void 0);
104
- _defineProperty(this, "cookie", void 0);
105
- _defineProperty(this, "cookies", void 0);
106
- _defineProperty(this, "_cookie", void 0);
107
- this.host = ctx.host;
108
- this.pathname = ctx.path;
109
- this.query = ctx.query;
110
- this.headers = ctx.headers;
111
- this.cookie = ctx.headers.cookie || '';
112
- this._cookie = cookie.parse(this.cookie);
113
- this.cookies = {
114
- get: this.getCookie.bind(this)
115
- };
116
- }
117
- _createClass(Request, [{
118
- key: "getCookie",
119
- value: function getCookie(key) {
120
- return this._cookie[key];
215
+ var Request = /*#__PURE__*/ function() {
216
+ "use strict";
217
+ function Request(ctx) {
218
+ _classCallCheck(this, Request);
219
+ _defineProperty(this, "host", void 0);
220
+ _defineProperty(this, "pathname", void 0);
221
+ _defineProperty(this, "query", void 0);
222
+ _defineProperty(this, "headers", void 0);
223
+ _defineProperty(this, "cookie", void 0);
224
+ _defineProperty(this, "cookies", void 0);
225
+ _defineProperty(this, "_cookie", void 0);
226
+ this.host = ctx.host;
227
+ this.pathname = ctx.path;
228
+ this.query = ctx.query;
229
+ this.headers = ctx.headers;
230
+ this.cookie = ctx.headers.cookie || "";
231
+ this._cookie = cookie.parse(this.cookie);
232
+ this.cookies = {
233
+ get: this.getCookie.bind(this)
234
+ };
121
235
  }
122
- }]);
123
- return Request;
236
+ _createClass(Request, [
237
+ {
238
+ key: "getCookie",
239
+ value: function getCookie(key) {
240
+ return this._cookie[key];
241
+ }
242
+ }
243
+ ]);
244
+ return Request;
124
245
  }();
125
- export var base = function base(context) {
126
- var res = context.res;
127
- return {
128
- response: new Response(res),
129
- request: new Request(context),
130
- logger: context.logger,
131
- metrics: context.metrics
132
- };
246
+ var base = function(context) {
247
+ var res = context.res;
248
+ return {
249
+ response: new Response(res),
250
+ request: new Request(context),
251
+ logger: context.logger,
252
+ metrics: context.metrics
253
+ };
133
254
  };
134
- export var createAfterMatchContext = function createAfterMatchContext(context, entryName) {
135
- var baseContext = base(context);
136
- return _objectSpread(_objectSpread({}, baseContext), {}, {
137
- router: new RouteAPI(entryName)
138
- });
255
+ var createAfterMatchContext = function(context, entryName) {
256
+ var baseContext = base(context);
257
+ return _objectSpreadProps(_objectSpread({}, baseContext), {
258
+ router: new RouteAPI(entryName)
259
+ });
139
260
  };
140
- export var createAfterRenderContext = function createAfterRenderContext(context, content) {
141
- var baseContext = base(context);
142
- return _objectSpread(_objectSpread({}, baseContext), {}, {
143
- template: new TemplateAPI(content)
144
- });
261
+ var createAfterRenderContext = function(context, content) {
262
+ var baseContext = base(context);
263
+ return _objectSpreadProps(_objectSpread({}, baseContext), {
264
+ template: new TemplateAPI(content)
265
+ });
145
266
  };
146
- export var createMiddlewareContext = function createMiddlewareContext(context) {
147
- var baseContext = base(context);
148
- return _objectSpread(_objectSpread({}, baseContext), {}, {
149
- response: _objectSpread(_objectSpread({}, baseContext.response), {}, {
150
- locals: context.res.locals || {}
151
- }),
152
- source: {
153
- req: context.req,
154
- res: context.res
155
- }
156
- });
157
- };
267
+ var createMiddlewareContext = function(context) {
268
+ var baseContext = base(context);
269
+ return _objectSpreadProps(_objectSpread({}, baseContext), {
270
+ response: _objectSpreadProps(_objectSpread({}, baseContext.response), {
271
+ locals: context.res.locals || {}
272
+ }),
273
+ source: {
274
+ req: context.req,
275
+ res: context.res
276
+ }
277
+ });
278
+ };
279
+ export { base, createAfterMatchContext, createAfterRenderContext, createMiddlewareContext };
@@ -1,33 +1,68 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
- export var RouteAPI = /*#__PURE__*/function () {
5
- function RouteAPI(entryName) {
6
- _classCallCheck(this, RouteAPI);
7
- _defineProperty(this, "current", void 0);
8
- _defineProperty(this, "status", void 0);
9
- _defineProperty(this, "url", void 0);
10
- this.current = entryName;
11
- this.status = 200;
12
- this.url = '';
13
- }
14
- _createClass(RouteAPI, [{
15
- key: "redirect",
16
- value: function redirect(url) {
17
- var status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 302;
18
- this.url = url;
19
- this.status = status;
1
+ function _classCallCheck(instance, Constructor) {
2
+ if (!(instance instanceof Constructor)) {
3
+ throw new TypeError("Cannot call a class as a function");
20
4
  }
21
- }, {
22
- key: "rewrite",
23
- value: function rewrite(entryName) {
24
- this.current = entryName;
5
+ }
6
+ function _defineProperties(target, props) {
7
+ for(var i = 0; i < props.length; i++){
8
+ var descriptor = props[i];
9
+ descriptor.enumerable = descriptor.enumerable || false;
10
+ descriptor.configurable = true;
11
+ if ("value" in descriptor) descriptor.writable = true;
12
+ Object.defineProperty(target, descriptor.key, descriptor);
25
13
  }
26
- }, {
27
- key: "use",
28
- value: function use(entryName) {
29
- this.rewrite(entryName);
14
+ }
15
+ function _createClass(Constructor, protoProps, staticProps) {
16
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
+ if (staticProps) _defineProperties(Constructor, staticProps);
18
+ return Constructor;
19
+ }
20
+ function _defineProperty(obj, key, value) {
21
+ if (key in obj) {
22
+ Object.defineProperty(obj, key, {
23
+ value: value,
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true
27
+ });
28
+ } else {
29
+ obj[key] = value;
30
30
  }
31
- }]);
32
- return RouteAPI;
33
- }();
31
+ return obj;
32
+ }
33
+ var RouteAPI = /*#__PURE__*/ function() {
34
+ "use strict";
35
+ function RouteAPI(entryName) {
36
+ _classCallCheck(this, RouteAPI);
37
+ _defineProperty(this, "current", void 0);
38
+ _defineProperty(this, "status", void 0);
39
+ _defineProperty(this, "url", void 0);
40
+ this.current = entryName;
41
+ this.status = 200;
42
+ this.url = "";
43
+ }
44
+ _createClass(RouteAPI, [
45
+ {
46
+ key: "redirect",
47
+ value: function redirect(url) {
48
+ var status = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 302;
49
+ this.url = url;
50
+ this.status = status;
51
+ }
52
+ },
53
+ {
54
+ key: "rewrite",
55
+ value: function rewrite(entryName) {
56
+ this.current = entryName;
57
+ }
58
+ },
59
+ {
60
+ key: "use",
61
+ value: function use(entryName) {
62
+ this.rewrite(entryName);
63
+ }
64
+ }
65
+ ]);
66
+ return RouteAPI;
67
+ }();
68
+ export { RouteAPI };