@modern-js/prod-server 2.14.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/constants.js +15 -31
  3. package/dist/cjs/index.js +35 -37
  4. package/dist/cjs/libs/context/context.js +53 -66
  5. package/dist/cjs/libs/context/index.js +15 -28
  6. package/dist/cjs/libs/hook-api/index.js +59 -54
  7. package/dist/cjs/libs/hook-api/route.js +28 -30
  8. package/dist/cjs/libs/hook-api/template.js +30 -34
  9. package/dist/cjs/libs/loadConfig.js +74 -65
  10. package/dist/cjs/libs/logger.js +46 -37
  11. package/dist/cjs/libs/metrics.js +7 -25
  12. package/dist/cjs/libs/proxy.js +29 -46
  13. package/dist/cjs/libs/render/cache/__tests__/cache.fun.test.js +48 -64
  14. package/dist/cjs/libs/render/cache/__tests__/cache.test.js +53 -37
  15. package/dist/cjs/libs/render/cache/__tests__/cacheable.js +38 -34
  16. package/dist/cjs/libs/render/cache/__tests__/error-configuration.js +22 -30
  17. package/dist/cjs/libs/render/cache/__tests__/matched-cache.js +86 -46
  18. package/dist/cjs/libs/render/cache/index.js +17 -37
  19. package/dist/cjs/libs/render/cache/page-caches/index.js +12 -28
  20. package/dist/cjs/libs/render/cache/page-caches/lru.js +32 -40
  21. package/dist/cjs/libs/render/cache/spr.js +104 -111
  22. package/dist/cjs/libs/render/cache/type.js +4 -15
  23. package/dist/cjs/libs/render/cache/util.js +29 -53
  24. package/dist/cjs/libs/render/index.js +75 -73
  25. package/dist/cjs/libs/render/measure.js +19 -34
  26. package/dist/cjs/libs/render/reader.js +52 -61
  27. package/dist/cjs/libs/render/ssr.js +34 -66
  28. package/dist/cjs/libs/render/static.js +22 -45
  29. package/dist/cjs/libs/render/type.js +10 -28
  30. package/dist/cjs/libs/render/utils.js +17 -38
  31. package/dist/cjs/libs/route/index.js +32 -31
  32. package/dist/cjs/libs/route/matcher.js +38 -38
  33. package/dist/cjs/libs/route/route.js +29 -26
  34. package/dist/cjs/libs/serveFile.js +23 -41
  35. package/dist/cjs/server/index.js +101 -107
  36. package/dist/cjs/server/modernServer.js +191 -171
  37. package/dist/cjs/server/modernServerSplit.js +12 -30
  38. package/dist/cjs/type.js +4 -15
  39. package/dist/cjs/utils.js +50 -50
  40. package/dist/cjs/workerServer.js +26 -36
  41. package/dist/esm/constants.js +24 -25
  42. package/dist/esm/index.js +11 -10
  43. package/dist/esm/libs/context/context.js +271 -264
  44. package/dist/esm/libs/context/index.js +3 -3
  45. package/dist/esm/libs/hook-api/index.js +237 -223
  46. package/dist/esm/libs/hook-api/route.js +62 -60
  47. package/dist/esm/libs/hook-api/template.js +117 -115
  48. package/dist/esm/libs/loadConfig.js +68 -69
  49. package/dist/esm/libs/logger.js +188 -174
  50. package/dist/esm/libs/metrics.js +6 -3
  51. package/dist/esm/libs/proxy.js +236 -221
  52. package/dist/esm/libs/render/cache/__tests__/cache.fun.test.js +286 -267
  53. package/dist/esm/libs/render/cache/__tests__/cache.test.js +765 -745
  54. package/dist/esm/libs/render/cache/__tests__/cacheable.js +62 -63
  55. package/dist/esm/libs/render/cache/__tests__/error-configuration.js +42 -43
  56. package/dist/esm/libs/render/cache/__tests__/matched-cache.js +134 -135
  57. package/dist/esm/libs/render/cache/index.js +337 -326
  58. package/dist/esm/libs/render/cache/page-caches/index.js +147 -141
  59. package/dist/esm/libs/render/cache/page-caches/lru.js +78 -76
  60. package/dist/esm/libs/render/cache/spr.js +465 -456
  61. package/dist/esm/libs/render/cache/type.js +1 -1
  62. package/dist/esm/libs/render/cache/util.js +266 -246
  63. package/dist/esm/libs/render/index.js +226 -218
  64. package/dist/esm/libs/render/measure.js +136 -128
  65. package/dist/esm/libs/render/reader.js +315 -304
  66. package/dist/esm/libs/render/ssr.js +214 -209
  67. package/dist/esm/libs/render/static.js +208 -198
  68. package/dist/esm/libs/render/type.js +6 -7
  69. package/dist/esm/libs/render/utils.js +8 -9
  70. package/dist/esm/libs/route/index.js +134 -123
  71. package/dist/esm/libs/route/matcher.js +140 -130
  72. package/dist/esm/libs/route/route.js +36 -37
  73. package/dist/esm/libs/serveFile.js +177 -168
  74. package/dist/esm/server/index.js +578 -549
  75. package/dist/esm/server/modernServer.js +1137 -1074
  76. package/dist/esm/server/modernServerSplit.js +344 -328
  77. package/dist/esm/type.js +1 -1
  78. package/dist/esm/utils.js +133 -124
  79. package/dist/esm/workerServer.js +226 -220
  80. package/dist/esm-node/constants.js +7 -14
  81. package/dist/esm-node/index.js +4 -9
  82. package/dist/esm-node/libs/context/context.js +32 -25
  83. package/dist/esm-node/libs/context/index.js +2 -5
  84. package/dist/esm-node/libs/hook-api/index.js +40 -21
  85. package/dist/esm-node/libs/hook-api/route.js +21 -8
  86. package/dist/esm-node/libs/hook-api/template.js +19 -14
  87. package/dist/esm-node/libs/loadConfig.js +11 -28
  88. package/dist/esm-node/libs/logger.js +37 -17
  89. package/dist/esm-node/libs/metrics.js +1 -3
  90. package/dist/esm-node/libs/proxy.js +14 -22
  91. package/dist/esm-node/libs/render/cache/__tests__/cache.fun.test.js +25 -36
  92. package/dist/esm-node/libs/render/cache/__tests__/cache.test.js +23 -11
  93. package/dist/esm-node/libs/render/cache/__tests__/cacheable.js +32 -13
  94. package/dist/esm-node/libs/render/cache/__tests__/error-configuration.js +16 -9
  95. package/dist/esm-node/libs/render/cache/__tests__/matched-cache.js +80 -25
  96. package/dist/esm-node/libs/render/cache/index.js +3 -10
  97. package/dist/esm-node/libs/render/cache/page-caches/index.js +4 -5
  98. package/dist/esm-node/libs/render/cache/page-caches/lru.js +20 -8
  99. package/dist/esm-node/libs/render/cache/spr.js +79 -80
  100. package/dist/esm-node/libs/render/cache/type.js +1 -0
  101. package/dist/esm-node/libs/render/cache/util.js +13 -23
  102. package/dist/esm-node/libs/render/index.js +10 -28
  103. package/dist/esm-node/libs/render/measure.js +7 -13
  104. package/dist/esm-node/libs/render/reader.js +31 -26
  105. package/dist/esm-node/libs/render/ssr.js +5 -21
  106. package/dist/esm-node/libs/render/static.js +1 -4
  107. package/dist/esm-node/libs/render/type.js +3 -6
  108. package/dist/esm-node/libs/render/utils.js +6 -18
  109. package/dist/esm-node/libs/route/index.js +20 -9
  110. package/dist/esm-node/libs/route/matcher.js +28 -17
  111. package/dist/esm-node/libs/route/route.js +23 -5
  112. package/dist/esm-node/libs/serveFile.js +2 -6
  113. package/dist/esm-node/server/index.js +72 -75
  114. package/dist/esm-node/server/modernServer.js +102 -130
  115. package/dist/esm-node/server/modernServerSplit.js +1 -4
  116. package/dist/esm-node/type.js +1 -0
  117. package/dist/esm-node/utils.js +41 -32
  118. package/dist/esm-node/workerServer.js +9 -10
  119. package/dist/types/libs/context/context.d.ts +1 -1
  120. package/dist/types/server/modernServer.d.ts +1 -1
  121. package/dist/types/utils.d.ts +1 -1
  122. package/package.json +12 -8
@@ -1 +1 @@
1
- "use strict";
1
+ export {};
@@ -1,280 +1,300 @@
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;
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length)
3
+ len = arr.length;
4
+ for (var i = 0, arr2 = new Array(len); i < len; i++)
5
+ arr2[i] = arr[i];
6
+ return arr2;
5
7
  }
6
- function _arrayWithHoles(arr) {
7
- if (Array.isArray(arr)) return arr;
8
+ function _array_with_holes(arr) {
9
+ if (Array.isArray(arr))
10
+ return arr;
8
11
  }
9
- function _arrayWithoutHoles(arr) {
10
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
12
+ function _array_without_holes(arr) {
13
+ if (Array.isArray(arr))
14
+ return _array_like_to_array(arr);
11
15
  }
12
16
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
13
- try {
14
- var info = gen[key](arg);
15
- var value = info.value;
16
- } catch (error) {
17
- reject(error);
18
- return;
19
- }
20
- if (info.done) {
21
- resolve(value);
22
- } else {
23
- Promise.resolve(value).then(_next, _throw);
24
- }
17
+ try {
18
+ var info = gen[key](arg);
19
+ var value = info.value;
20
+ } catch (error) {
21
+ reject(error);
22
+ return;
23
+ }
24
+ if (info.done) {
25
+ resolve(value);
26
+ } else {
27
+ Promise.resolve(value).then(_next, _throw);
28
+ }
25
29
  }
26
- function _asyncToGenerator(fn) {
27
- return function() {
28
- var self = this, args = arguments;
29
- return new Promise(function(resolve, reject) {
30
- var gen = fn.apply(self, args);
31
- function _next(value) {
32
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
33
- }
34
- function _throw(err) {
35
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
36
- }
37
- _next(undefined);
38
- });
39
- };
30
+ function _async_to_generator(fn) {
31
+ return function() {
32
+ var self = this, args = arguments;
33
+ return new Promise(function(resolve, reject) {
34
+ var gen = fn.apply(self, args);
35
+ function _next(value) {
36
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
37
+ }
38
+ function _throw(err) {
39
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
40
+ }
41
+ _next(void 0);
42
+ });
43
+ };
40
44
  }
41
45
  function _instanceof(left, right) {
42
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
43
- return !!right[Symbol.hasInstance](left);
44
- } else {
45
- return left instanceof right;
46
- }
46
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
47
+ return !!right[Symbol.hasInstance](left);
48
+ } else {
49
+ return left instanceof right;
50
+ }
47
51
  }
48
- function _iterableToArray(iter) {
49
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
52
+ function _iterable_to_array(iter) {
53
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
54
+ return Array.from(iter);
50
55
  }
51
- function _iterableToArrayLimit(arr, i) {
52
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
53
- if (_i == null) return;
54
- var _arr = [];
55
- var _n = true;
56
- var _d = false;
57
- var _s, _e;
56
+ function _iterable_to_array_limit(arr, i) {
57
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
58
+ if (_i == null)
59
+ return;
60
+ var _arr = [];
61
+ var _n = true;
62
+ var _d = false;
63
+ var _s, _e;
64
+ try {
65
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
66
+ _arr.push(_s.value);
67
+ if (i && _arr.length === i)
68
+ break;
69
+ }
70
+ } catch (err) {
71
+ _d = true;
72
+ _e = err;
73
+ } finally {
58
74
  try {
59
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
60
- _arr.push(_s.value);
61
- if (i && _arr.length === i) break;
62
- }
63
- } catch (err) {
64
- _d = true;
65
- _e = err;
66
- } finally{
67
- try {
68
- if (!_n && _i["return"] != null) _i["return"]();
69
- } finally{
70
- if (_d) throw _e;
71
- }
75
+ if (!_n && _i["return"] != null)
76
+ _i["return"]();
77
+ } finally {
78
+ if (_d)
79
+ throw _e;
72
80
  }
73
- return _arr;
81
+ }
82
+ return _arr;
74
83
  }
75
- function _nonIterableRest() {
76
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
84
+ function _non_iterable_rest() {
85
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
77
86
  }
78
- function _nonIterableSpread() {
79
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
87
+ function _non_iterable_spread() {
88
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
80
89
  }
81
- function _slicedToArray(arr, i) {
82
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
90
+ function _sliced_to_array(arr, i) {
91
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
83
92
  }
84
- function _toConsumableArray(arr) {
85
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
93
+ function _to_consumable_array(arr) {
94
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
86
95
  }
87
- function _unsupportedIterableToArray(o, minLen) {
88
- if (!o) return;
89
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
90
- var n = Object.prototype.toString.call(o).slice(8, -1);
91
- if (n === "Object" && o.constructor) n = o.constructor.name;
92
- if (n === "Map" || n === "Set") return Array.from(n);
93
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
96
+ function _unsupported_iterable_to_array(o, minLen) {
97
+ if (!o)
98
+ return;
99
+ if (typeof o === "string")
100
+ return _array_like_to_array(o, minLen);
101
+ var n = Object.prototype.toString.call(o).slice(8, -1);
102
+ if (n === "Object" && o.constructor)
103
+ n = o.constructor.name;
104
+ if (n === "Map" || n === "Set")
105
+ return Array.from(n);
106
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
107
+ return _array_like_to_array(o, minLen);
94
108
  }
95
- var __generator = this && this.__generator || function(thisArg, body) {
96
- var f, y, t, g, _ = {
97
- label: 0,
98
- sent: function() {
99
- if (t[0] & 1) throw t[1];
100
- return t[1];
101
- },
102
- trys: [],
103
- ops: []
109
+ var __generator = function(thisArg, body) {
110
+ var f, y, t, g, _ = {
111
+ label: 0,
112
+ sent: function() {
113
+ if (t[0] & 1)
114
+ throw t[1];
115
+ return t[1];
116
+ },
117
+ trys: [],
118
+ ops: []
119
+ };
120
+ return g = {
121
+ next: verb(0),
122
+ "throw": verb(1),
123
+ "return": verb(2)
124
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
125
+ return this;
126
+ }), g;
127
+ function verb(n) {
128
+ return function(v) {
129
+ return step([
130
+ n,
131
+ v
132
+ ]);
104
133
  };
105
- return(g = {
106
- next: verb(0),
107
- "throw": verb(1),
108
- "return": verb(2)
109
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
110
- return this;
111
- }), g);
112
- function verb(n) {
113
- return function(v) {
114
- return step([
115
- n,
116
- v
117
- ]);
118
- };
119
- }
120
- function step(op) {
121
- if (f) throw new TypeError("Generator is already executing.");
122
- while(_)try {
123
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
124
- if (y = 0, t) op = [
125
- op[0] & 2,
126
- t.value
127
- ];
128
- switch(op[0]){
129
- case 0:
130
- case 1:
131
- t = op;
132
- break;
133
- case 4:
134
- _.label++;
135
- return {
136
- value: op[1],
137
- done: false
138
- };
139
- case 5:
140
- _.label++;
141
- y = op[1];
142
- op = [
143
- 0
144
- ];
145
- continue;
146
- case 7:
147
- op = _.ops.pop();
148
- _.trys.pop();
149
- continue;
150
- default:
151
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
152
- _ = 0;
153
- continue;
154
- }
155
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
156
- _.label = op[1];
157
- break;
158
- }
159
- if (op[0] === 6 && _.label < t[1]) {
160
- _.label = t[1];
161
- t = op;
162
- break;
163
- }
164
- if (t && _.label < t[2]) {
165
- _.label = t[2];
166
- _.ops.push(op);
167
- break;
168
- }
169
- if (t[2]) _.ops.pop();
170
- _.trys.pop();
171
- continue;
172
- }
173
- op = body.call(thisArg, _);
174
- } catch (e) {
134
+ }
135
+ function step(op) {
136
+ if (f)
137
+ throw new TypeError("Generator is already executing.");
138
+ while (_)
139
+ try {
140
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
141
+ return t;
142
+ if (y = 0, t)
143
+ op = [
144
+ op[0] & 2,
145
+ t.value
146
+ ];
147
+ switch (op[0]) {
148
+ case 0:
149
+ case 1:
150
+ t = op;
151
+ break;
152
+ case 4:
153
+ _.label++;
154
+ return {
155
+ value: op[1],
156
+ done: false
157
+ };
158
+ case 5:
159
+ _.label++;
160
+ y = op[1];
175
161
  op = [
176
- 6,
177
- e
162
+ 0
178
163
  ];
179
- y = 0;
180
- } finally{
181
- f = t = 0;
164
+ continue;
165
+ case 7:
166
+ op = _.ops.pop();
167
+ _.trys.pop();
168
+ continue;
169
+ default:
170
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
171
+ _ = 0;
172
+ continue;
173
+ }
174
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
175
+ _.label = op[1];
176
+ break;
177
+ }
178
+ if (op[0] === 6 && _.label < t[1]) {
179
+ _.label = t[1];
180
+ t = op;
181
+ break;
182
+ }
183
+ if (t && _.label < t[2]) {
184
+ _.label = t[2];
185
+ _.ops.push(op);
186
+ break;
187
+ }
188
+ if (t[2])
189
+ _.ops.pop();
190
+ _.trys.pop();
191
+ continue;
182
192
  }
183
- if (op[0] & 5) throw op[1];
184
- return {
185
- value: op[0] ? op[1] : void 0,
186
- done: true
187
- };
188
- }
193
+ op = body.call(thisArg, _);
194
+ } catch (e) {
195
+ op = [
196
+ 6,
197
+ e
198
+ ];
199
+ y = 0;
200
+ } finally {
201
+ f = t = 0;
202
+ }
203
+ if (op[0] & 5)
204
+ throw op[1];
205
+ return {
206
+ value: op[0] ? op[1] : void 0,
207
+ done: true
208
+ };
209
+ }
189
210
  };
190
211
  import url from "url";
191
- function namespaceHash(namespace, hash) {
192
- return "".concat(namespace, "/").concat(hash);
212
+ export function namespaceHash(namespace, hash) {
213
+ return "".concat(namespace, "/").concat(hash);
193
214
  }
194
- function fname(lv) {
195
- return "f".concat(lv);
215
+ export function fname(lv) {
216
+ return "f".concat(lv);
196
217
  }
197
- function connectFactor() {
198
- for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
199
- args[_key] = arguments[_key];
200
- }
201
- return args.join("-");
218
+ export function connectFactor() {
219
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
220
+ args[_key] = arguments[_key];
221
+ }
222
+ return args.join("-");
202
223
  }
203
- function valueFactory(obj) {
204
- if (_instanceof(obj, url.URLSearchParams)) {
205
- return function(key) {
206
- return obj.get(key);
207
- };
208
- } else {
209
- return function(key) {
210
- var value = obj[key];
211
- if (Array.isArray(value)) {
212
- return value.join(",");
213
- }
214
- return value;
215
- };
216
- }
224
+ export function valueFactory(obj) {
225
+ if (_instanceof(obj, url.URLSearchParams)) {
226
+ return function(key) {
227
+ return obj.get(key);
228
+ };
229
+ } else {
230
+ return function(key) {
231
+ var value = obj[key];
232
+ if (Array.isArray(value)) {
233
+ return value.join(",");
234
+ }
235
+ return value;
236
+ };
237
+ }
217
238
  }
218
- function getTime(param) {
219
- var _param = _slicedToArray(param, 2), s = _param[0], ns = _param[1];
220
- return Math.floor(s * 1e3 + ns / 1e6);
239
+ export function getTime(param) {
240
+ var _param = _sliced_to_array(param, 2), s = _param[0], ns = _param[1];
241
+ return Math.floor(s * 1e3 + ns / 1e6);
221
242
  }
222
243
  var RE_START_IN_HEAD = /<head>/;
223
- function cacheAddition(html, hash) {
224
- var additionHtml = html.replace(RE_START_IN_HEAD, '<head><meta name="x-moden-spr" content="'.concat(hash, '">'));
225
- return additionHtml;
244
+ export function cacheAddition(html, hash) {
245
+ var additionHtml = html.replace(RE_START_IN_HEAD, '<head><meta name="x-moden-spr" content="'.concat(hash, '">'));
246
+ return additionHtml;
226
247
  }
227
248
  var globalInvokeCache = /* @__PURE__ */ new Map();
228
- function withCoalescedInvoke(func) {
229
- return function() {
230
- var _ref = _asyncToGenerator(function(key, args) {
231
- var entry, future;
232
- function __wrapper() {
233
- return func.apply(void 0, _toConsumableArray(args));
234
- }
235
- return __generator(this, function(_state) {
236
- entry = globalInvokeCache.get(key);
237
- if (entry) {
238
- return [
239
- 2,
240
- entry.then(function(res) {
241
- return {
242
- isOrigin: false,
243
- value: res.value
244
- };
245
- })
246
- ];
247
- }
248
- future = __wrapper().then(function(res) {
249
- globalInvokeCache.delete(key);
250
- return {
251
- isOrigin: true,
252
- value: res
253
- };
254
- }).catch(function(err) {
255
- globalInvokeCache.delete(key);
256
- throw err;
257
- });
258
- globalInvokeCache.set(key, future);
259
- return [
260
- 2,
261
- future
262
- ];
263
- });
264
- });
265
- return function(key, args) {
266
- return _ref.apply(this, arguments);
267
- };
268
- }();
269
- }
270
- function maybeSync(fn) {
271
- return function(sync) {
272
- if (sync) {
273
- return fn();
274
- } else {
275
- fn();
276
- return Promise.resolve();
249
+ export function withCoalescedInvoke(func) {
250
+ return function() {
251
+ var _ref = _async_to_generator(function(key, args) {
252
+ var entry, future;
253
+ function __wrapper() {
254
+ return func.apply(void 0, _to_consumable_array(args));
255
+ }
256
+ return __generator(this, function(_state) {
257
+ entry = globalInvokeCache.get(key);
258
+ if (entry) {
259
+ return [
260
+ 2,
261
+ entry.then(function(res) {
262
+ return {
263
+ isOrigin: false,
264
+ value: res.value
265
+ };
266
+ })
267
+ ];
277
268
  }
269
+ future = __wrapper().then(function(res) {
270
+ globalInvokeCache.delete(key);
271
+ return {
272
+ isOrigin: true,
273
+ value: res
274
+ };
275
+ }).catch(function(err) {
276
+ globalInvokeCache.delete(key);
277
+ throw err;
278
+ });
279
+ globalInvokeCache.set(key, future);
280
+ return [
281
+ 2,
282
+ future
283
+ ];
284
+ });
285
+ });
286
+ return function(key, args) {
287
+ return _ref.apply(this, arguments);
278
288
  };
289
+ }();
290
+ }
291
+ export function maybeSync(fn) {
292
+ return function(sync) {
293
+ if (sync) {
294
+ return fn();
295
+ } else {
296
+ fn();
297
+ return Promise.resolve();
298
+ }
299
+ };
279
300
  }
280
- export { cacheAddition, connectFactor, fname, getTime, maybeSync, namespaceHash, valueFactory, withCoalescedInvoke };