webpack-dev-server 5.1.0 → 5.2.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/client/index.js +282 -16
- package/client/modules/logger/index.js +29 -26
- package/client/modules/sockjs-client/index.js +1 -1
- package/client/overlay.js +352 -11
- package/client/utils/log.js +1 -17
- package/lib/Server.js +24 -7
- package/package.json +25 -26
- package/types/lib/Server.d.ts +13 -10
- package/client/overlay/fsm.js +0 -64
- package/client/overlay/runtime-error.js +0 -47
- package/client/overlay/state-machine.js +0 -100
- package/client/overlay/styles.js +0 -74
- package/client/utils/createSocketURL.js +0 -121
- package/client/utils/getCurrentScriptSource.js +0 -24
- package/client/utils/parseURL.js +0 -36
- package/client/utils/reloadApp.js +0 -63
- package/client/utils/stripAnsi.js +0 -18
package/client/overlay.js
CHANGED
|
@@ -7,10 +7,351 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
7
7
|
// They, in turn, got inspired by webpack-hot-middleware (https://github.com/glenjamin/webpack-hot-middleware).
|
|
8
8
|
|
|
9
9
|
import ansiHTML from "ansi-html-community";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @type {(input: string, position: number) => string}
|
|
13
|
+
*/
|
|
14
|
+
var getCodePoint = String.prototype.codePointAt ? function (input, position) {
|
|
15
|
+
return input.codePointAt(position);
|
|
16
|
+
} : function (input, position) {
|
|
17
|
+
return (input.charCodeAt(position) - 0xd800) * 0x400 + input.charCodeAt(position + 1) - 0xdc00 + 0x10000;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {string} macroText
|
|
22
|
+
* @param {RegExp} macroRegExp
|
|
23
|
+
* @param {(input: string) => string} macroReplacer
|
|
24
|
+
* @returns {string}
|
|
25
|
+
*/
|
|
26
|
+
var replaceUsingRegExp = function replaceUsingRegExp(macroText, macroRegExp, macroReplacer) {
|
|
27
|
+
macroRegExp.lastIndex = 0;
|
|
28
|
+
var replaceMatch = macroRegExp.exec(macroText);
|
|
29
|
+
var replaceResult;
|
|
30
|
+
if (replaceMatch) {
|
|
31
|
+
replaceResult = "";
|
|
32
|
+
var replaceLastIndex = 0;
|
|
33
|
+
do {
|
|
34
|
+
if (replaceLastIndex !== replaceMatch.index) {
|
|
35
|
+
replaceResult += macroText.substring(replaceLastIndex, replaceMatch.index);
|
|
36
|
+
}
|
|
37
|
+
var replaceInput = replaceMatch[0];
|
|
38
|
+
replaceResult += macroReplacer(replaceInput);
|
|
39
|
+
replaceLastIndex = replaceMatch.index + replaceInput.length;
|
|
40
|
+
// eslint-disable-next-line no-cond-assign
|
|
41
|
+
} while (replaceMatch = macroRegExp.exec(macroText));
|
|
42
|
+
if (replaceLastIndex !== macroText.length) {
|
|
43
|
+
replaceResult += macroText.substring(replaceLastIndex);
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
replaceResult = macroText;
|
|
47
|
+
}
|
|
48
|
+
return replaceResult;
|
|
49
|
+
};
|
|
50
|
+
var references = {
|
|
51
|
+
"<": "<",
|
|
52
|
+
">": ">",
|
|
53
|
+
'"': """,
|
|
54
|
+
"'": "'",
|
|
55
|
+
"&": "&"
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @param {string} text text
|
|
60
|
+
* @returns {string}
|
|
61
|
+
*/
|
|
62
|
+
function encode(text) {
|
|
63
|
+
if (!text) {
|
|
64
|
+
return "";
|
|
65
|
+
}
|
|
66
|
+
return replaceUsingRegExp(text, /[<>'"&]/g, function (input) {
|
|
67
|
+
var result = references[input];
|
|
68
|
+
if (!result) {
|
|
69
|
+
var code = input.length > 1 ? getCodePoint(input, 0) : input.charCodeAt(0);
|
|
70
|
+
result = "&#".concat(code, ";");
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @typedef {Object} StateDefinitions
|
|
78
|
+
* @property {{[event: string]: { target: string; actions?: Array<string> }}} [on]
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @typedef {Object} Options
|
|
83
|
+
* @property {{[state: string]: StateDefinitions}} states
|
|
84
|
+
* @property {object} context;
|
|
85
|
+
* @property {string} initial
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @typedef {Object} Implementation
|
|
90
|
+
* @property {{[actionName: string]: (ctx: object, event: any) => object}} actions
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* A simplified `createMachine` from `@xstate/fsm` with the following differences:
|
|
95
|
+
*
|
|
96
|
+
* - the returned machine is technically a "service". No `interpret(machine).start()` is needed.
|
|
97
|
+
* - the state definition only support `on` and target must be declared with { target: 'nextState', actions: [] } explicitly.
|
|
98
|
+
* - event passed to `send` must be an object with `type` property.
|
|
99
|
+
* - actions implementation will be [assign action](https://xstate.js.org/docs/guides/context.html#assign-action) if you return any value.
|
|
100
|
+
* Do not return anything if you just want to invoke side effect.
|
|
101
|
+
*
|
|
102
|
+
* The goal of this custom function is to avoid installing the entire `'xstate/fsm'` package, while enabling modeling using
|
|
103
|
+
* state machine. You can copy the first parameter into the editor at https://stately.ai/viz to visualize the state machine.
|
|
104
|
+
*
|
|
105
|
+
* @param {Options} options
|
|
106
|
+
* @param {Implementation} implementation
|
|
107
|
+
*/
|
|
108
|
+
function createMachine(_ref, _ref2) {
|
|
109
|
+
var states = _ref.states,
|
|
110
|
+
context = _ref.context,
|
|
111
|
+
initial = _ref.initial;
|
|
112
|
+
var actions = _ref2.actions;
|
|
113
|
+
var currentState = initial;
|
|
114
|
+
var currentContext = context;
|
|
115
|
+
return {
|
|
116
|
+
send: function send(event) {
|
|
117
|
+
var currentStateOn = states[currentState].on;
|
|
118
|
+
var transitionConfig = currentStateOn && currentStateOn[event.type];
|
|
119
|
+
if (transitionConfig) {
|
|
120
|
+
currentState = transitionConfig.target;
|
|
121
|
+
if (transitionConfig.actions) {
|
|
122
|
+
transitionConfig.actions.forEach(function (actName) {
|
|
123
|
+
var actionImpl = actions[actName];
|
|
124
|
+
var nextContextValue = actionImpl && actionImpl(currentContext, event);
|
|
125
|
+
if (nextContextValue) {
|
|
126
|
+
currentContext = _objectSpread(_objectSpread({}, currentContext), nextContextValue);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @typedef {Object} ShowOverlayData
|
|
137
|
+
* @property {'warning' | 'error'} level
|
|
138
|
+
* @property {Array<string | { moduleIdentifier?: string, moduleName?: string, loc?: string, message?: string }>} messages
|
|
139
|
+
* @property {'build' | 'runtime'} messageSource
|
|
140
|
+
*/
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @typedef {Object} CreateOverlayMachineOptions
|
|
144
|
+
* @property {(data: ShowOverlayData) => void} showOverlay
|
|
145
|
+
* @property {() => void} hideOverlay
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @param {CreateOverlayMachineOptions} options
|
|
150
|
+
*/
|
|
151
|
+
var createOverlayMachine = function createOverlayMachine(options) {
|
|
152
|
+
var hideOverlay = options.hideOverlay,
|
|
153
|
+
showOverlay = options.showOverlay;
|
|
154
|
+
return createMachine({
|
|
155
|
+
initial: "hidden",
|
|
156
|
+
context: {
|
|
157
|
+
level: "error",
|
|
158
|
+
messages: [],
|
|
159
|
+
messageSource: "build"
|
|
160
|
+
},
|
|
161
|
+
states: {
|
|
162
|
+
hidden: {
|
|
163
|
+
on: {
|
|
164
|
+
BUILD_ERROR: {
|
|
165
|
+
target: "displayBuildError",
|
|
166
|
+
actions: ["setMessages", "showOverlay"]
|
|
167
|
+
},
|
|
168
|
+
RUNTIME_ERROR: {
|
|
169
|
+
target: "displayRuntimeError",
|
|
170
|
+
actions: ["setMessages", "showOverlay"]
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
displayBuildError: {
|
|
175
|
+
on: {
|
|
176
|
+
DISMISS: {
|
|
177
|
+
target: "hidden",
|
|
178
|
+
actions: ["dismissMessages", "hideOverlay"]
|
|
179
|
+
},
|
|
180
|
+
BUILD_ERROR: {
|
|
181
|
+
target: "displayBuildError",
|
|
182
|
+
actions: ["appendMessages", "showOverlay"]
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
displayRuntimeError: {
|
|
187
|
+
on: {
|
|
188
|
+
DISMISS: {
|
|
189
|
+
target: "hidden",
|
|
190
|
+
actions: ["dismissMessages", "hideOverlay"]
|
|
191
|
+
},
|
|
192
|
+
RUNTIME_ERROR: {
|
|
193
|
+
target: "displayRuntimeError",
|
|
194
|
+
actions: ["appendMessages", "showOverlay"]
|
|
195
|
+
},
|
|
196
|
+
BUILD_ERROR: {
|
|
197
|
+
target: "displayBuildError",
|
|
198
|
+
actions: ["setMessages", "showOverlay"]
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}, {
|
|
204
|
+
actions: {
|
|
205
|
+
dismissMessages: function dismissMessages() {
|
|
206
|
+
return {
|
|
207
|
+
messages: [],
|
|
208
|
+
level: "error",
|
|
209
|
+
messageSource: "build"
|
|
210
|
+
};
|
|
211
|
+
},
|
|
212
|
+
appendMessages: function appendMessages(context, event) {
|
|
213
|
+
return {
|
|
214
|
+
messages: context.messages.concat(event.messages),
|
|
215
|
+
level: event.level || context.level,
|
|
216
|
+
messageSource: event.type === "RUNTIME_ERROR" ? "runtime" : "build"
|
|
217
|
+
};
|
|
218
|
+
},
|
|
219
|
+
setMessages: function setMessages(context, event) {
|
|
220
|
+
return {
|
|
221
|
+
messages: event.messages,
|
|
222
|
+
level: event.level || context.level,
|
|
223
|
+
messageSource: event.type === "RUNTIME_ERROR" ? "runtime" : "build"
|
|
224
|
+
};
|
|
225
|
+
},
|
|
226
|
+
hideOverlay: hideOverlay,
|
|
227
|
+
showOverlay: showOverlay
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
*
|
|
234
|
+
* @param {Error} error
|
|
235
|
+
*/
|
|
236
|
+
var parseErrorToStacks = function parseErrorToStacks(error) {
|
|
237
|
+
if (!error || !(error instanceof Error)) {
|
|
238
|
+
throw new Error("parseErrorToStacks expects Error object");
|
|
239
|
+
}
|
|
240
|
+
if (typeof error.stack === "string") {
|
|
241
|
+
return error.stack.split("\n").filter(function (stack) {
|
|
242
|
+
return stack !== "Error: ".concat(error.message);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @callback ErrorCallback
|
|
249
|
+
* @param {ErrorEvent} error
|
|
250
|
+
* @returns {void}
|
|
251
|
+
*/
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @param {ErrorCallback} callback
|
|
255
|
+
*/
|
|
256
|
+
var listenToRuntimeError = function listenToRuntimeError(callback) {
|
|
257
|
+
window.addEventListener("error", callback);
|
|
258
|
+
return function cleanup() {
|
|
259
|
+
window.removeEventListener("error", callback);
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* @callback UnhandledRejectionCallback
|
|
265
|
+
* @param {PromiseRejectionEvent} rejectionEvent
|
|
266
|
+
* @returns {void}
|
|
267
|
+
*/
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* @param {UnhandledRejectionCallback} callback
|
|
271
|
+
*/
|
|
272
|
+
var listenToUnhandledRejection = function listenToUnhandledRejection(callback) {
|
|
273
|
+
window.addEventListener("unhandledrejection", callback);
|
|
274
|
+
return function cleanup() {
|
|
275
|
+
window.removeEventListener("unhandledrejection", callback);
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
// Styles are inspired by `react-error-overlay`
|
|
280
|
+
|
|
281
|
+
var msgStyles = {
|
|
282
|
+
error: {
|
|
283
|
+
backgroundColor: "rgba(206, 17, 38, 0.1)",
|
|
284
|
+
color: "#fccfcf"
|
|
285
|
+
},
|
|
286
|
+
warning: {
|
|
287
|
+
backgroundColor: "rgba(251, 245, 180, 0.1)",
|
|
288
|
+
color: "#fbf5b4"
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
var iframeStyle = {
|
|
292
|
+
position: "fixed",
|
|
293
|
+
top: 0,
|
|
294
|
+
left: 0,
|
|
295
|
+
right: 0,
|
|
296
|
+
bottom: 0,
|
|
297
|
+
width: "100vw",
|
|
298
|
+
height: "100vh",
|
|
299
|
+
border: "none",
|
|
300
|
+
"z-index": 9999999999
|
|
301
|
+
};
|
|
302
|
+
var containerStyle = {
|
|
303
|
+
position: "fixed",
|
|
304
|
+
boxSizing: "border-box",
|
|
305
|
+
left: 0,
|
|
306
|
+
top: 0,
|
|
307
|
+
right: 0,
|
|
308
|
+
bottom: 0,
|
|
309
|
+
width: "100vw",
|
|
310
|
+
height: "100vh",
|
|
311
|
+
fontSize: "large",
|
|
312
|
+
padding: "2rem 2rem 4rem 2rem",
|
|
313
|
+
lineHeight: "1.2",
|
|
314
|
+
whiteSpace: "pre-wrap",
|
|
315
|
+
overflow: "auto",
|
|
316
|
+
backgroundColor: "rgba(0, 0, 0, 0.9)",
|
|
317
|
+
color: "white"
|
|
318
|
+
};
|
|
319
|
+
var headerStyle = {
|
|
320
|
+
color: "#e83b46",
|
|
321
|
+
fontSize: "2em",
|
|
322
|
+
whiteSpace: "pre-wrap",
|
|
323
|
+
fontFamily: "sans-serif",
|
|
324
|
+
margin: "0 2rem 2rem 0",
|
|
325
|
+
flex: "0 0 auto",
|
|
326
|
+
maxHeight: "50%",
|
|
327
|
+
overflow: "auto"
|
|
328
|
+
};
|
|
329
|
+
var dismissButtonStyle = {
|
|
330
|
+
color: "#ffffff",
|
|
331
|
+
lineHeight: "1rem",
|
|
332
|
+
fontSize: "1.5rem",
|
|
333
|
+
padding: "1rem",
|
|
334
|
+
cursor: "pointer",
|
|
335
|
+
position: "absolute",
|
|
336
|
+
right: 0,
|
|
337
|
+
top: 0,
|
|
338
|
+
backgroundColor: "transparent",
|
|
339
|
+
border: "none"
|
|
340
|
+
};
|
|
341
|
+
var msgTypeStyle = {
|
|
342
|
+
color: "#e83b46",
|
|
343
|
+
fontSize: "1.2em",
|
|
344
|
+
marginBottom: "1rem",
|
|
345
|
+
fontFamily: "sans-serif"
|
|
346
|
+
};
|
|
347
|
+
var msgTextStyle = {
|
|
348
|
+
lineHeight: "1.5",
|
|
349
|
+
fontSize: "1rem",
|
|
350
|
+
fontFamily: "Menlo, Consolas, monospace"
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
// ANSI HTML
|
|
354
|
+
|
|
14
355
|
var colors = {
|
|
15
356
|
reset: ["transparent", "transparent"],
|
|
16
357
|
black: "181818",
|
|
@@ -30,7 +371,7 @@ ansiHTML.setColors(colors);
|
|
|
30
371
|
* @param {string | { file?: string, moduleName?: string, loc?: string, message?: string; stack?: string[] }} item
|
|
31
372
|
* @returns {{ header: string, body: string }}
|
|
32
373
|
*/
|
|
33
|
-
function formatProblem(type, item) {
|
|
374
|
+
var formatProblem = function formatProblem(type, item) {
|
|
34
375
|
var header = type === "warning" ? "WARNING" : "ERROR";
|
|
35
376
|
var body = "";
|
|
36
377
|
if (typeof item === "string") {
|
|
@@ -54,7 +395,7 @@ function formatProblem(type, item) {
|
|
|
54
395
|
header: header,
|
|
55
396
|
body: body
|
|
56
397
|
};
|
|
57
|
-
}
|
|
398
|
+
};
|
|
58
399
|
|
|
59
400
|
/**
|
|
60
401
|
* @typedef {Object} CreateOverlayOptions
|
|
@@ -222,11 +563,11 @@ var createOverlay = function createOverlay(options) {
|
|
|
222
563
|
}, trustedTypesPolicyName);
|
|
223
564
|
}
|
|
224
565
|
var overlayService = createOverlayMachine({
|
|
225
|
-
showOverlay: function showOverlay(
|
|
226
|
-
var
|
|
227
|
-
level =
|
|
228
|
-
messages =
|
|
229
|
-
messageSource =
|
|
566
|
+
showOverlay: function showOverlay(_ref3) {
|
|
567
|
+
var _ref3$level = _ref3.level,
|
|
568
|
+
level = _ref3$level === void 0 ? "error" : _ref3$level,
|
|
569
|
+
messages = _ref3.messages,
|
|
570
|
+
messageSource = _ref3.messageSource;
|
|
230
571
|
return show(level, messages, options.trustedTypesPolicyName, messageSource);
|
|
231
572
|
},
|
|
232
573
|
hideOverlay: hide
|
package/client/utils/log.js
CHANGED
|
@@ -16,20 +16,4 @@ function setLogLevel(level) {
|
|
|
16
16
|
}
|
|
17
17
|
setLogLevel(defaultLevel);
|
|
18
18
|
var log = logger.getLogger(name);
|
|
19
|
-
|
|
20
|
-
var enabledFeatures = Object.keys(features);
|
|
21
|
-
if (!features || enabledFeatures.length === 0) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
var logString = "Server started:";
|
|
25
|
-
|
|
26
|
-
// Server started: Hot Module Replacement enabled, Live Reloading enabled, Overlay disabled.
|
|
27
|
-
for (var i = 0; i < enabledFeatures.length; i++) {
|
|
28
|
-
var key = enabledFeatures[i];
|
|
29
|
-
logString += " ".concat(key, " ").concat(features[key] ? "enabled" : "disabled", ",");
|
|
30
|
-
}
|
|
31
|
-
// replace last comma with a period
|
|
32
|
-
logString = logString.slice(0, -1).concat(".");
|
|
33
|
-
log.info(logString);
|
|
34
|
-
};
|
|
35
|
-
export { log, logEnabledFeatures, setLogLevel };
|
|
19
|
+
export { log, setLogLevel };
|
package/lib/Server.js
CHANGED
|
@@ -404,6 +404,7 @@ class Server {
|
|
|
404
404
|
let host;
|
|
405
405
|
|
|
406
406
|
const networks = Object.values(os.networkInterfaces())
|
|
407
|
+
// eslint-disable-next-line no-shadow
|
|
407
408
|
.flatMap((networks) => networks ?? [])
|
|
408
409
|
.filter((network) => {
|
|
409
410
|
if (!network || !network.address) {
|
|
@@ -793,15 +794,12 @@ class Server {
|
|
|
793
794
|
webSocketURLStr = searchParams.toString();
|
|
794
795
|
}
|
|
795
796
|
|
|
796
|
-
additionalEntries.push(
|
|
797
|
-
`${require.resolve("../client/index.js")}?${webSocketURLStr}`,
|
|
798
|
-
);
|
|
797
|
+
additionalEntries.push(`${this.getClientEntry()}?${webSocketURLStr}`);
|
|
799
798
|
}
|
|
800
799
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
additionalEntries.push(require.resolve("webpack/hot/dev-server"));
|
|
800
|
+
const clientHotEntry = this.getClientHotEntry();
|
|
801
|
+
if (clientHotEntry) {
|
|
802
|
+
additionalEntries.push(clientHotEntry);
|
|
805
803
|
}
|
|
806
804
|
|
|
807
805
|
const webpack = compiler.webpack || require("webpack");
|
|
@@ -1676,6 +1674,25 @@ class Server {
|
|
|
1676
1674
|
return implementation;
|
|
1677
1675
|
}
|
|
1678
1676
|
|
|
1677
|
+
/**
|
|
1678
|
+
* @returns {string}
|
|
1679
|
+
*/
|
|
1680
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1681
|
+
getClientEntry() {
|
|
1682
|
+
return require.resolve("../client/index.js");
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
/**
|
|
1686
|
+
* @returns {string | void}
|
|
1687
|
+
*/
|
|
1688
|
+
getClientHotEntry() {
|
|
1689
|
+
if (this.options.hot === "only") {
|
|
1690
|
+
return require.resolve("webpack/hot/only-dev-server");
|
|
1691
|
+
} else if (this.options.hot) {
|
|
1692
|
+
return require.resolve("webpack/hot/dev-server");
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1679
1696
|
/**
|
|
1680
1697
|
* @private
|
|
1681
1698
|
* @returns {void}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-dev-server",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Serves a webpack app. Updates the browser on changes.",
|
|
5
5
|
"bin": "bin/webpack-dev-server.js",
|
|
6
6
|
"main": "lib/Server.js",
|
|
@@ -59,10 +59,9 @@
|
|
|
59
59
|
"colorette": "^2.0.10",
|
|
60
60
|
"compression": "^1.7.4",
|
|
61
61
|
"connect-history-api-fallback": "^2.0.0",
|
|
62
|
-
"express": "^4.
|
|
62
|
+
"express": "^4.21.2",
|
|
63
63
|
"graceful-fs": "^4.2.6",
|
|
64
|
-
"
|
|
65
|
-
"http-proxy-middleware": "^2.0.3",
|
|
64
|
+
"http-proxy-middleware": "^2.0.7",
|
|
66
65
|
"ipaddr.js": "^2.1.0",
|
|
67
66
|
"launch-editor": "^2.6.1",
|
|
68
67
|
"open": "^10.0.3",
|
|
@@ -76,38 +75,38 @@
|
|
|
76
75
|
"ws": "^8.18.0"
|
|
77
76
|
},
|
|
78
77
|
"devDependencies": {
|
|
79
|
-
"@babel/cli": "^7.25.
|
|
80
|
-
"@babel/core": "^7.25.
|
|
81
|
-
"@babel/eslint-parser": "^7.25.
|
|
82
|
-
"@babel/plugin-transform-object-assign": "^7.
|
|
83
|
-
"@babel/plugin-transform-runtime": "^7.25.
|
|
84
|
-
"@babel/preset-env": "^7.25.
|
|
85
|
-
"@babel/runtime": "^7.25.
|
|
86
|
-
"@commitlint/cli": "^19.
|
|
87
|
-
"@commitlint/config-conventional": "^19.
|
|
88
|
-
"@hono/node-server": "^1.
|
|
78
|
+
"@babel/cli": "^7.25.9",
|
|
79
|
+
"@babel/core": "^7.25.9",
|
|
80
|
+
"@babel/eslint-parser": "^7.25.9",
|
|
81
|
+
"@babel/plugin-transform-object-assign": "^7.25.9",
|
|
82
|
+
"@babel/plugin-transform-runtime": "^7.25.9",
|
|
83
|
+
"@babel/preset-env": "^7.25.9",
|
|
84
|
+
"@babel/runtime": "^7.25.9",
|
|
85
|
+
"@commitlint/cli": "^19.5.0",
|
|
86
|
+
"@commitlint/config-conventional": "^19.5.0",
|
|
87
|
+
"@hono/node-server": "^1.13.3",
|
|
89
88
|
"@types/compression": "^1.7.2",
|
|
90
|
-
"@types/node": "^22.
|
|
89
|
+
"@types/node": "^22.8.4",
|
|
91
90
|
"@types/node-forge": "^1.3.1",
|
|
92
91
|
"@types/sockjs-client": "^1.5.1",
|
|
93
92
|
"@types/trusted-types": "^2.0.2",
|
|
94
|
-
"acorn": "^8.
|
|
93
|
+
"acorn": "^8.14.0",
|
|
95
94
|
"babel-jest": "^29.5.0",
|
|
96
|
-
"babel-loader": "^9.1
|
|
95
|
+
"babel-loader": "^9.2.1",
|
|
97
96
|
"body-parser": "^1.19.2",
|
|
98
97
|
"connect": "^3.7.0",
|
|
99
98
|
"core-js": "^3.38.1",
|
|
100
|
-
"cspell": "^8.
|
|
99
|
+
"cspell": "^8.15.5",
|
|
101
100
|
"css-loader": "^7.1.1",
|
|
102
|
-
"eslint": "^8.
|
|
101
|
+
"eslint": "^8.57.1",
|
|
103
102
|
"eslint-config-prettier": "^9.1.0",
|
|
104
103
|
"eslint-config-webpack": "^1.2.5",
|
|
105
|
-
"eslint-plugin-import": "^2.
|
|
104
|
+
"eslint-plugin-import": "^2.31.0",
|
|
106
105
|
"execa": "^5.1.1",
|
|
107
|
-
"hono": "^4.
|
|
108
|
-
"html-webpack-plugin": "^5.
|
|
106
|
+
"hono": "^4.6.8",
|
|
107
|
+
"html-webpack-plugin": "^5.6.3",
|
|
109
108
|
"http-proxy": "^1.18.1",
|
|
110
|
-
"husky": "^9.1.
|
|
109
|
+
"husky": "^9.1.6",
|
|
111
110
|
"jest": "^29.5.0",
|
|
112
111
|
"jest-environment-jsdom": "^29.5.0",
|
|
113
112
|
"klona": "^2.0.4",
|
|
@@ -115,10 +114,10 @@
|
|
|
115
114
|
"less-loader": "^12.1.0",
|
|
116
115
|
"lint-staged": "^15.2.10",
|
|
117
116
|
"marked": "^12.0.0",
|
|
118
|
-
"memfs": "^4.
|
|
117
|
+
"memfs": "^4.14.0",
|
|
119
118
|
"npm-run-all": "^4.1.5",
|
|
120
119
|
"prettier": "^3.2.4",
|
|
121
|
-
"puppeteer": "^23.
|
|
120
|
+
"puppeteer": "^23.6.1",
|
|
122
121
|
"readable-stream": "^4.5.2",
|
|
123
122
|
"require-from-string": "^2.0.2",
|
|
124
123
|
"rimraf": "^5.0.5",
|
|
@@ -128,7 +127,7 @@
|
|
|
128
127
|
"style-loader": "^4.0.0",
|
|
129
128
|
"supertest": "^7.0.0",
|
|
130
129
|
"tcp-port-used": "^1.0.2",
|
|
131
|
-
"typescript": "^5.
|
|
130
|
+
"typescript": "^5.7.2",
|
|
132
131
|
"wait-for-expect": "^3.0.2",
|
|
133
132
|
"webpack": "^5.94.0",
|
|
134
133
|
"webpack-cli": "^5.0.1",
|
package/types/lib/Server.d.ts
CHANGED
|
@@ -1134,7 +1134,7 @@ declare class Server<
|
|
|
1134
1134
|
*/
|
|
1135
1135
|
static findIp(
|
|
1136
1136
|
gatewayOrFamily: string,
|
|
1137
|
-
isInternal?: boolean
|
|
1137
|
+
isInternal?: boolean,
|
|
1138
1138
|
): string | undefined;
|
|
1139
1139
|
/**
|
|
1140
1140
|
* @param {"v4" | "v6"} family
|
|
@@ -1230,6 +1230,14 @@ declare class Server<
|
|
|
1230
1230
|
* @returns {T}
|
|
1231
1231
|
*/
|
|
1232
1232
|
private getServerTransport;
|
|
1233
|
+
/**
|
|
1234
|
+
* @returns {string}
|
|
1235
|
+
*/
|
|
1236
|
+
getClientEntry(): string;
|
|
1237
|
+
/**
|
|
1238
|
+
* @returns {string | void}
|
|
1239
|
+
*/
|
|
1240
|
+
getClientHotEntry(): string | void;
|
|
1233
1241
|
/**
|
|
1234
1242
|
* @private
|
|
1235
1243
|
* @returns {void}
|
|
@@ -1369,16 +1377,11 @@ declare class Server<
|
|
|
1369
1377
|
* @param {string | string[]} watchPath
|
|
1370
1378
|
* @param {WatchOptions} [watchOptions]
|
|
1371
1379
|
*/
|
|
1372
|
-
watchFiles(
|
|
1373
|
-
watchPath: string | string[],
|
|
1374
|
-
watchOptions?: import("chokidar").WatchOptions | undefined,
|
|
1375
|
-
): void;
|
|
1380
|
+
watchFiles(watchPath: string | string[], watchOptions?: WatchOptions): void;
|
|
1376
1381
|
/**
|
|
1377
1382
|
* @param {import("webpack-dev-middleware").Callback} [callback]
|
|
1378
1383
|
*/
|
|
1379
|
-
invalidate(
|
|
1380
|
-
callback?: import("webpack-dev-middleware").Callback | undefined,
|
|
1381
|
-
): void;
|
|
1384
|
+
invalidate(callback?: import("webpack-dev-middleware").Callback): void;
|
|
1382
1385
|
/**
|
|
1383
1386
|
* @returns {Promise<void>}
|
|
1384
1387
|
*/
|
|
@@ -1386,7 +1389,7 @@ declare class Server<
|
|
|
1386
1389
|
/**
|
|
1387
1390
|
* @param {(err?: Error) => void} [callback]
|
|
1388
1391
|
*/
|
|
1389
|
-
startCallback(callback?: (
|
|
1392
|
+
startCallback(callback?: (err?: Error) => void): void;
|
|
1390
1393
|
/**
|
|
1391
1394
|
* @returns {Promise<void>}
|
|
1392
1395
|
*/
|
|
@@ -1394,7 +1397,7 @@ declare class Server<
|
|
|
1394
1397
|
/**
|
|
1395
1398
|
* @param {(err?: Error) => void} [callback]
|
|
1396
1399
|
*/
|
|
1397
|
-
stopCallback(callback?: (
|
|
1400
|
+
stopCallback(callback?: (err?: Error) => void): void;
|
|
1398
1401
|
}
|
|
1399
1402
|
declare namespace Server {
|
|
1400
1403
|
export {
|
package/client/overlay/fsm.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
4
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {Object} StateDefinitions
|
|
8
|
-
* @property {{[event: string]: { target: string; actions?: Array<string> }}} [on]
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {Object} Options
|
|
13
|
-
* @property {{[state: string]: StateDefinitions}} states
|
|
14
|
-
* @property {object} context;
|
|
15
|
-
* @property {string} initial
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @typedef {Object} Implementation
|
|
20
|
-
* @property {{[actionName: string]: (ctx: object, event: any) => object}} actions
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* A simplified `createMachine` from `@xstate/fsm` with the following differences:
|
|
25
|
-
*
|
|
26
|
-
* - the returned machine is technically a "service". No `interpret(machine).start()` is needed.
|
|
27
|
-
* - the state definition only support `on` and target must be declared with { target: 'nextState', actions: [] } explicitly.
|
|
28
|
-
* - event passed to `send` must be an object with `type` property.
|
|
29
|
-
* - actions implementation will be [assign action](https://xstate.js.org/docs/guides/context.html#assign-action) if you return any value.
|
|
30
|
-
* Do not return anything if you just want to invoke side effect.
|
|
31
|
-
*
|
|
32
|
-
* The goal of this custom function is to avoid installing the entire `'xstate/fsm'` package, while enabling modeling using
|
|
33
|
-
* state machine. You can copy the first parameter into the editor at https://stately.ai/viz to visualize the state machine.
|
|
34
|
-
*
|
|
35
|
-
* @param {Options} options
|
|
36
|
-
* @param {Implementation} implementation
|
|
37
|
-
*/
|
|
38
|
-
function createMachine(_ref, _ref2) {
|
|
39
|
-
var states = _ref.states,
|
|
40
|
-
context = _ref.context,
|
|
41
|
-
initial = _ref.initial;
|
|
42
|
-
var actions = _ref2.actions;
|
|
43
|
-
var currentState = initial;
|
|
44
|
-
var currentContext = context;
|
|
45
|
-
return {
|
|
46
|
-
send: function send(event) {
|
|
47
|
-
var currentStateOn = states[currentState].on;
|
|
48
|
-
var transitionConfig = currentStateOn && currentStateOn[event.type];
|
|
49
|
-
if (transitionConfig) {
|
|
50
|
-
currentState = transitionConfig.target;
|
|
51
|
-
if (transitionConfig.actions) {
|
|
52
|
-
transitionConfig.actions.forEach(function (actName) {
|
|
53
|
-
var actionImpl = actions[actName];
|
|
54
|
-
var nextContextValue = actionImpl && actionImpl(currentContext, event);
|
|
55
|
-
if (nextContextValue) {
|
|
56
|
-
currentContext = _objectSpread(_objectSpread({}, currentContext), nextContextValue);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
export default createMachine;
|