@modern-js/server 2.15.1-alpha.0 → 2.17.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.
- package/CHANGELOG.md +25 -0
- package/dist/cjs/constants.js +12 -28
- package/dist/cjs/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +14 -32
- package/dist/cjs/dev-tools/dev-middleware/hmr-client/index.js +24 -42
- package/dist/cjs/dev-tools/dev-middleware/index.js +45 -50
- package/dist/cjs/dev-tools/dev-middleware/socketServer.js +48 -46
- package/dist/cjs/dev-tools/https/index.js +21 -38
- package/dist/cjs/dev-tools/mock/getMockData.js +33 -33
- package/dist/cjs/dev-tools/mock/index.js +67 -47
- package/dist/cjs/dev-tools/register/index.js +59 -70
- package/dist/cjs/dev-tools/watcher/dependencyTree.js +52 -55
- package/dist/cjs/dev-tools/watcher/index.js +52 -53
- package/dist/cjs/dev-tools/watcher/statsCache.js +37 -47
- package/dist/cjs/index.js +16 -28
- package/dist/cjs/server/devServer.js +163 -109
- package/dist/cjs/server/index.js +11 -29
- package/dist/cjs/types.js +4 -15
- package/dist/esm/constants.js +19 -20
- package/dist/esm/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +43 -44
- package/dist/esm/dev-tools/dev-middleware/hmr-client/index.js +148 -157
- package/dist/esm/dev-tools/dev-middleware/index.js +307 -291
- package/dist/esm/dev-tools/dev-middleware/socketServer.js +216 -202
- package/dist/esm/dev-tools/https/index.js +189 -182
- package/dist/esm/dev-tools/mock/getMockData.js +297 -278
- package/dist/esm/dev-tools/mock/index.js +198 -192
- package/dist/esm/dev-tools/register/index.js +141 -141
- package/dist/esm/dev-tools/watcher/dependencyTree.js +153 -138
- package/dist/esm/dev-tools/watcher/index.js +187 -175
- package/dist/esm/dev-tools/watcher/statsCache.js +118 -116
- package/dist/esm/index.js +9 -8
- package/dist/esm/server/devServer.js +803 -766
- package/dist/esm/server/index.js +80 -76
- package/dist/esm/types.js +1 -1
- package/dist/esm-node/constants.js +4 -5
- package/dist/esm-node/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +2 -11
- package/dist/esm-node/dev-tools/dev-middleware/hmr-client/index.js +125 -139
- package/dist/esm-node/dev-tools/dev-middleware/index.js +31 -17
- package/dist/esm-node/dev-tools/dev-middleware/socketServer.js +33 -12
- package/dist/esm-node/dev-tools/https/index.js +13 -15
- package/dist/esm-node/dev-tools/mock/getMockData.js +20 -12
- package/dist/esm-node/dev-tools/mock/index.js +7 -7
- package/dist/esm-node/dev-tools/register/index.js +38 -29
- package/dist/esm-node/dev-tools/watcher/dependencyTree.js +32 -21
- package/dist/esm-node/dev-tools/watcher/index.js +31 -18
- package/dist/esm-node/dev-tools/watcher/statsCache.js +18 -8
- package/dist/esm-node/index.js +2 -5
- package/dist/esm-node/server/devServer.js +87 -62
- package/dist/esm-node/server/index.js +1 -4
- package/dist/esm-node/types.js +1 -0
- package/package.json +13 -9
- package/dist/js/modern/constants.js +0 -19
- package/dist/js/modern/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +0 -41
- package/dist/js/modern/dev-tools/dev-middleware/hmr-client/index.js +0 -143
- package/dist/js/modern/dev-tools/dev-middleware/index.js +0 -94
- package/dist/js/modern/dev-tools/dev-middleware/socket-server.js +0 -132
- package/dist/js/modern/dev-tools/https/index.js +0 -49
- package/dist/js/modern/dev-tools/mock/getMockData.js +0 -114
- package/dist/js/modern/dev-tools/mock/index.js +0 -54
- package/dist/js/modern/dev-tools/register/index.js +0 -111
- package/dist/js/modern/dev-tools/watcher/dependency-tree.js +0 -59
- package/dist/js/modern/dev-tools/watcher/index.js +0 -106
- package/dist/js/modern/dev-tools/watcher/stats-cache.js +0 -58
- package/dist/js/modern/index.js +0 -12
- package/dist/js/modern/server/dev-server.js +0 -293
- package/dist/js/modern/server/index.js +0 -16
- package/dist/js/modern/types.js +0 -0
- package/dist/js/node/constants.js +0 -42
- package/dist/js/node/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +0 -65
- package/dist/js/node/dev-tools/dev-middleware/hmr-client/index.js +0 -152
- package/dist/js/node/dev-tools/dev-middleware/index.js +0 -119
- package/dist/js/node/dev-tools/dev-middleware/socket-server.js +0 -159
- package/dist/js/node/dev-tools/https/index.js +0 -72
- package/dist/js/node/dev-tools/mock/getMockData.js +0 -135
- package/dist/js/node/dev-tools/mock/index.js +0 -83
- package/dist/js/node/dev-tools/register/index.js +0 -138
- package/dist/js/node/dev-tools/watcher/dependency-tree.js +0 -89
- package/dist/js/node/dev-tools/watcher/index.js +0 -135
- package/dist/js/node/dev-tools/watcher/stats-cache.js +0 -87
- package/dist/js/node/index.js +0 -35
- package/dist/js/node/server/dev-server.js +0 -310
- package/dist/js/node/server/index.js +0 -39
- package/dist/js/node/types.js +0 -15
- package/dist/js/treeshaking/constants.js +0 -21
- package/dist/js/treeshaking/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +0 -51
- package/dist/js/treeshaking/dev-tools/dev-middleware/hmr-client/index.js +0 -157
- package/dist/js/treeshaking/dev-tools/dev-middleware/index.js +0 -322
- package/dist/js/treeshaking/dev-tools/dev-middleware/socket-server.js +0 -209
- package/dist/js/treeshaking/dev-tools/https/index.js +0 -193
- package/dist/js/treeshaking/dev-tools/mock/getMockData.js +0 -327
- package/dist/js/treeshaking/dev-tools/mock/index.js +0 -191
- package/dist/js/treeshaking/dev-tools/register/index.js +0 -153
- package/dist/js/treeshaking/dev-tools/watcher/dependency-tree.js +0 -150
- package/dist/js/treeshaking/dev-tools/watcher/index.js +0 -200
- package/dist/js/treeshaking/dev-tools/watcher/stats-cache.js +0 -128
- package/dist/js/treeshaking/index.js +0 -9
- package/dist/js/treeshaking/server/dev-server.js +0 -799
- package/dist/js/treeshaking/server/index.js +0 -92
- package/dist/js/treeshaking/types.js +0 -1
|
@@ -1,322 +1,338 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function _assert_this_initialized(self) {
|
|
2
|
+
if (self === void 0) {
|
|
3
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4
|
+
}
|
|
5
|
+
return self;
|
|
6
6
|
}
|
|
7
7
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
try {
|
|
9
|
+
var info = gen[key](arg);
|
|
10
|
+
var value = info.value;
|
|
11
|
+
} catch (error) {
|
|
12
|
+
reject(error);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (info.done) {
|
|
16
|
+
resolve(value);
|
|
17
|
+
} else {
|
|
18
|
+
Promise.resolve(value).then(_next, _throw);
|
|
19
|
+
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
function _async_to_generator(fn) {
|
|
22
|
+
return function() {
|
|
23
|
+
var self = this, args = arguments;
|
|
24
|
+
return new Promise(function(resolve, reject) {
|
|
25
|
+
var gen = fn.apply(self, args);
|
|
26
|
+
function _next(value) {
|
|
27
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
28
|
+
}
|
|
29
|
+
function _throw(err) {
|
|
30
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
31
|
+
}
|
|
32
|
+
_next(void 0);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
function _class_call_check(instance, Constructor) {
|
|
37
|
+
if (!(instance instanceof Constructor)) {
|
|
38
|
+
throw new TypeError("Cannot call a class as a function");
|
|
39
|
+
}
|
|
40
40
|
}
|
|
41
41
|
function _defineProperties(target, props) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
for (var i = 0; i < props.length; i++) {
|
|
43
|
+
var descriptor = props[i];
|
|
44
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
45
|
+
descriptor.configurable = true;
|
|
46
|
+
if ("value" in descriptor)
|
|
47
|
+
descriptor.writable = true;
|
|
48
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
49
|
+
}
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
52
|
+
if (protoProps)
|
|
53
|
+
_defineProperties(Constructor.prototype, protoProps);
|
|
54
|
+
if (staticProps)
|
|
55
|
+
_defineProperties(Constructor, staticProps);
|
|
56
|
+
return Constructor;
|
|
54
57
|
}
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
function _define_property(obj, key, value) {
|
|
59
|
+
if (key in obj) {
|
|
60
|
+
Object.defineProperty(obj, key, {
|
|
61
|
+
value,
|
|
62
|
+
enumerable: true,
|
|
63
|
+
configurable: true,
|
|
64
|
+
writable: true
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
obj[key] = value;
|
|
68
|
+
}
|
|
69
|
+
return obj;
|
|
67
70
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
function _get_prototype_of(o) {
|
|
72
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {
|
|
73
|
+
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
74
|
+
};
|
|
75
|
+
return _get_prototype_of(o);
|
|
73
76
|
}
|
|
74
77
|
function _inherits(subClass, superClass) {
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
79
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
80
|
+
}
|
|
81
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
82
|
+
constructor: {
|
|
83
|
+
value: subClass,
|
|
84
|
+
writable: true,
|
|
85
|
+
configurable: true
|
|
77
86
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
writable: true,
|
|
82
|
-
configurable: true
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
87
|
+
});
|
|
88
|
+
if (superClass)
|
|
89
|
+
_set_prototype_of(subClass, superClass);
|
|
86
90
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
ownKeys.forEach(function(key) {
|
|
97
|
-
_defineProperty(target, key, source[key]);
|
|
98
|
-
});
|
|
91
|
+
function _object_spread(target) {
|
|
92
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
93
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
94
|
+
var ownKeys = Object.keys(source);
|
|
95
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
96
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
97
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
98
|
+
}));
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
ownKeys.forEach(function(key) {
|
|
101
|
+
_define_property(target, key, source[key]);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return target;
|
|
101
105
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
function _possible_constructor_return(self, call) {
|
|
107
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
108
|
+
return call;
|
|
109
|
+
}
|
|
110
|
+
return _assert_this_initialized(self);
|
|
107
111
|
}
|
|
108
|
-
function
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
function _set_prototype_of(o, p) {
|
|
113
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {
|
|
114
|
+
o2.__proto__ = p2;
|
|
115
|
+
return o2;
|
|
116
|
+
};
|
|
117
|
+
return _set_prototype_of(o, p);
|
|
114
118
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
};
|
|
119
|
-
function _isNativeReflectConstruct() {
|
|
120
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
121
|
-
if (Reflect.construct.sham) return false;
|
|
122
|
-
if (typeof Proxy === "function") return true;
|
|
123
|
-
try {
|
|
124
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
125
|
-
return true;
|
|
126
|
-
} catch (e) {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
119
|
+
function _type_of(obj) {
|
|
120
|
+
"@swc/helpers - typeof";
|
|
121
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
129
122
|
}
|
|
130
|
-
function
|
|
131
|
-
|
|
132
|
-
return
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
123
|
+
function _is_native_reflect_construct() {
|
|
124
|
+
if (typeof Reflect === "undefined" || !Reflect.construct)
|
|
125
|
+
return false;
|
|
126
|
+
if (Reflect.construct.sham)
|
|
127
|
+
return false;
|
|
128
|
+
if (typeof Proxy === "function")
|
|
129
|
+
return true;
|
|
130
|
+
try {
|
|
131
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
132
|
+
}));
|
|
133
|
+
return true;
|
|
134
|
+
} catch (e) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
142
137
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
};
|
|
153
|
-
return g = {
|
|
154
|
-
next: verb(0),
|
|
155
|
-
"throw": verb(1),
|
|
156
|
-
"return": verb(2)
|
|
157
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
158
|
-
return this;
|
|
159
|
-
}), g;
|
|
160
|
-
function verb(n) {
|
|
161
|
-
return function(v) {
|
|
162
|
-
return step([
|
|
163
|
-
n,
|
|
164
|
-
v
|
|
165
|
-
]);
|
|
166
|
-
};
|
|
138
|
+
function _create_super(Derived) {
|
|
139
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
140
|
+
return function _createSuperInternal() {
|
|
141
|
+
var Super = _get_prototype_of(Derived), result;
|
|
142
|
+
if (hasNativeReflectConstruct) {
|
|
143
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
144
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
145
|
+
} else {
|
|
146
|
+
result = Super.apply(this, arguments);
|
|
167
147
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
148
|
+
return _possible_constructor_return(this, result);
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
var __generator = function(thisArg, body) {
|
|
152
|
+
var f, y, t, g, _ = {
|
|
153
|
+
label: 0,
|
|
154
|
+
sent: function() {
|
|
155
|
+
if (t[0] & 1)
|
|
156
|
+
throw t[1];
|
|
157
|
+
return t[1];
|
|
158
|
+
},
|
|
159
|
+
trys: [],
|
|
160
|
+
ops: []
|
|
161
|
+
};
|
|
162
|
+
return g = {
|
|
163
|
+
next: verb(0),
|
|
164
|
+
"throw": verb(1),
|
|
165
|
+
"return": verb(2)
|
|
166
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
167
|
+
return this;
|
|
168
|
+
}), g;
|
|
169
|
+
function verb(n) {
|
|
170
|
+
return function(v) {
|
|
171
|
+
return step([
|
|
172
|
+
n,
|
|
173
|
+
v
|
|
174
|
+
]);
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function step(op) {
|
|
178
|
+
if (f)
|
|
179
|
+
throw new TypeError("Generator is already executing.");
|
|
180
|
+
while (_)
|
|
181
|
+
try {
|
|
182
|
+
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)
|
|
183
|
+
return t;
|
|
184
|
+
if (y = 0, t)
|
|
185
|
+
op = [
|
|
186
|
+
op[0] & 2,
|
|
187
|
+
t.value
|
|
188
|
+
];
|
|
189
|
+
switch (op[0]) {
|
|
190
|
+
case 0:
|
|
191
|
+
case 1:
|
|
192
|
+
t = op;
|
|
193
|
+
break;
|
|
194
|
+
case 4:
|
|
195
|
+
_.label++;
|
|
196
|
+
return {
|
|
197
|
+
value: op[1],
|
|
198
|
+
done: false
|
|
199
|
+
};
|
|
200
|
+
case 5:
|
|
201
|
+
_.label++;
|
|
202
|
+
y = op[1];
|
|
223
203
|
op = [
|
|
224
|
-
|
|
225
|
-
e
|
|
204
|
+
0
|
|
226
205
|
];
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
206
|
+
continue;
|
|
207
|
+
case 7:
|
|
208
|
+
op = _.ops.pop();
|
|
209
|
+
_.trys.pop();
|
|
210
|
+
continue;
|
|
211
|
+
default:
|
|
212
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
213
|
+
_ = 0;
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
217
|
+
_.label = op[1];
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
221
|
+
_.label = t[1];
|
|
222
|
+
t = op;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
if (t && _.label < t[2]) {
|
|
226
|
+
_.label = t[2];
|
|
227
|
+
_.ops.push(op);
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
if (t[2])
|
|
231
|
+
_.ops.pop();
|
|
232
|
+
_.trys.pop();
|
|
233
|
+
continue;
|
|
230
234
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
op = body.call(thisArg, _);
|
|
236
|
+
} catch (e) {
|
|
237
|
+
op = [
|
|
238
|
+
6,
|
|
239
|
+
e
|
|
240
|
+
];
|
|
241
|
+
y = 0;
|
|
242
|
+
} finally {
|
|
243
|
+
f = t = 0;
|
|
244
|
+
}
|
|
245
|
+
if (op[0] & 5)
|
|
246
|
+
throw op[1];
|
|
247
|
+
return {
|
|
248
|
+
value: op[0] ? op[1] : void 0,
|
|
249
|
+
done: true
|
|
250
|
+
};
|
|
251
|
+
}
|
|
237
252
|
};
|
|
238
253
|
import { EventEmitter } from "events";
|
|
239
254
|
import SocketServer from "./socketServer";
|
|
240
|
-
var noop = function() {
|
|
255
|
+
var noop = function() {
|
|
256
|
+
};
|
|
241
257
|
function getHMRClientPath(client) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
258
|
+
var protocol = (client === null || client === void 0 ? void 0 : client.protocol) ? "&protocol=".concat(client.protocol) : "";
|
|
259
|
+
var host = (client === null || client === void 0 ? void 0 : client.host) ? "&host=".concat(client.host) : "";
|
|
260
|
+
var path = (client === null || client === void 0 ? void 0 : client.path) ? "&path=".concat(client.path) : "";
|
|
261
|
+
var port = (client === null || client === void 0 ? void 0 : client.port) ? "&port=".concat(client.port) : "";
|
|
262
|
+
var clientEntry = "".concat(require.resolve("@modern-js/server/hmr-client"), "?").concat(host).concat(path).concat(port).concat(protocol);
|
|
263
|
+
return clientEntry;
|
|
248
264
|
}
|
|
249
|
-
var DevMiddleware =
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
return _this;
|
|
265
|
+
var DevMiddleware = /* @__PURE__ */ function(EventEmitter2) {
|
|
266
|
+
"use strict";
|
|
267
|
+
_inherits(DevMiddleware2, EventEmitter2);
|
|
268
|
+
var _super = _create_super(DevMiddleware2);
|
|
269
|
+
function DevMiddleware2(param) {
|
|
270
|
+
var dev = param.dev, devMiddleware = param.devMiddleware;
|
|
271
|
+
_class_call_check(this, DevMiddleware2);
|
|
272
|
+
var _this;
|
|
273
|
+
_this = _super.call(this);
|
|
274
|
+
_define_property(_assert_this_initialized(_this), "middleware", void 0);
|
|
275
|
+
_define_property(_assert_this_initialized(_this), "devOptions", void 0);
|
|
276
|
+
_define_property(_assert_this_initialized(_this), "socketServer", void 0);
|
|
277
|
+
_this.devOptions = dev;
|
|
278
|
+
_this.socketServer = new SocketServer(dev);
|
|
279
|
+
if (devMiddleware) {
|
|
280
|
+
_this.middleware = _this.setupDevMiddleware(devMiddleware);
|
|
267
281
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
282
|
+
return _this;
|
|
283
|
+
}
|
|
284
|
+
_create_class(DevMiddleware2, [
|
|
285
|
+
{
|
|
286
|
+
key: "init",
|
|
287
|
+
value: function init(app) {
|
|
288
|
+
var _this = this;
|
|
289
|
+
app.on("listening", function() {
|
|
290
|
+
_this.socketServer.prepare(app);
|
|
291
|
+
});
|
|
292
|
+
var _this1 = this;
|
|
293
|
+
app.on("close", /* @__PURE__ */ _async_to_generator(function() {
|
|
294
|
+
var _this_middleware;
|
|
295
|
+
return __generator(this, function(_state) {
|
|
296
|
+
(_this_middleware = _this1.middleware) === null || _this_middleware === void 0 ? void 0 : _this_middleware.close(noop);
|
|
297
|
+
_this1.socketServer.close();
|
|
298
|
+
return [
|
|
299
|
+
2
|
|
300
|
+
];
|
|
301
|
+
});
|
|
302
|
+
}));
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
key: "sockWrite",
|
|
307
|
+
value: function sockWrite(type, data) {
|
|
308
|
+
this.socketServer.sockWrite(type, data);
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
key: "setupDevMiddleware",
|
|
313
|
+
value: function setupDevMiddleware(devMiddleware) {
|
|
314
|
+
var _this = this;
|
|
315
|
+
var devOptions = this.devOptions;
|
|
316
|
+
var callbacks = {
|
|
317
|
+
onInvalid: function() {
|
|
318
|
+
_this.socketServer.sockWrite("invalid");
|
|
319
|
+
},
|
|
320
|
+
onDone: function(stats) {
|
|
321
|
+
_this.socketServer.updateStats(stats);
|
|
322
|
+
_this.emit("change", stats);
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
var enableHMR = this.devOptions.hot || this.devOptions.liveReload;
|
|
326
|
+
var middleware = devMiddleware(_object_spread({
|
|
327
|
+
headers: devOptions.headers,
|
|
328
|
+
stats: false,
|
|
329
|
+
callbacks,
|
|
330
|
+
hmrClientPath: enableHMR ? getHMRClientPath(devOptions.client) : void 0
|
|
331
|
+
}, devOptions.devMiddleware));
|
|
332
|
+
return middleware;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
]);
|
|
336
|
+
return DevMiddleware2;
|
|
321
337
|
}(EventEmitter);
|
|
322
338
|
export { DevMiddleware as default };
|