@rspack/dev-server 2.2.0 → 2.2.2
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 +8 -6
- package/client/overlay.js +5 -6
- package/dist/{0~chokidar.js → chokidar~0.js} +3 -3
- package/dist/{0~connect-history-api-fallback.js → connect-history-api-fallback~0.js} +8 -8
- package/dist/{0~connect-next.js → connect-next~0.js} +38 -22
- package/dist/{0~debug.js → debug~0.js} +8 -7
- package/dist/{0~http-proxy-middleware.js → http-proxy-middleware~0.js} +32 -24
- package/dist/index.d.ts +16 -10
- package/dist/index.js +1 -1
- package/dist/{0~launch-editor.js → launch-editor~0.js} +225 -99
- package/dist/{0~open.js → open~0.js} +64 -19
- package/dist/{0~serve-static.js → serve-static~0.js} +22 -20
- package/dist/{619.js → t~0.js} +2380 -2397
- package/package.json +25 -42
- /package/dist/{0~chokidar.js.LICENSE.txt → chokidar~0.js.LICENSE.txt} +0 -0
- /package/dist/{0~connect-next.js.LICENSE.txt → connect-next~0.js.LICENSE.txt} +0 -0
- /package/dist/{0~http-proxy-middleware.js.LICENSE.txt → http-proxy-middleware~0.js.LICENSE.txt} +0 -0
- /package/dist/{0~p-retry.js → p-retry~0.js} +0 -0
- /package/dist/{0~serve-static.js.LICENSE.txt → serve-static~0.js.LICENSE.txt} +0 -0
package/client/index.js
CHANGED
|
@@ -165,7 +165,7 @@ const reloadApp = ({ hot, liveReload }, currentStatus)=>{
|
|
|
165
165
|
log_js_log.info('App hot update...');
|
|
166
166
|
emitter.emit('webpackHotUpdate', currentStatus.currentHash);
|
|
167
167
|
if ("u" > typeof self && self.window) self.postMessage(`webpackHotUpdate${currentStatus.currentHash}`, '*');
|
|
168
|
-
} else if (liveReload && allowToLiveReload) {
|
|
168
|
+
} else if (liveReload && allowToLiveReload && "u" > typeof document) {
|
|
169
169
|
let rootWindow = self;
|
|
170
170
|
const intervalId = self.setInterval(()=>{
|
|
171
171
|
if ('about:' !== rootWindow.location.protocol) applyReload(rootWindow, intervalId);
|
|
@@ -246,6 +246,7 @@ const onSocketMessage = {
|
|
|
246
246
|
reloadApp(options, client_src_status);
|
|
247
247
|
},
|
|
248
248
|
'static-changed': function(file) {
|
|
249
|
+
if ("u" < typeof document) return;
|
|
249
250
|
log_js_log.info(`${file ? `"${file}"` : 'Content'} from static directory was changed. Reloading...`);
|
|
250
251
|
self.location.reload();
|
|
251
252
|
},
|
|
@@ -326,20 +327,21 @@ const formatURL = (objURL)=>{
|
|
|
326
327
|
return `${protocol}${host}${pathname}${search}${hash}`;
|
|
327
328
|
};
|
|
328
329
|
const createSocketURL = (parsedURL)=>{
|
|
330
|
+
const pageLocation = 'blob:' === self.location.protocol && self.location.origin && 'null' !== self.location.origin ? new URL(self.location.origin) : self.location;
|
|
329
331
|
let { hostname } = parsedURL;
|
|
330
332
|
const isInAddrAny = '0.0.0.0' === hostname || '::' === hostname || '[::]' === hostname;
|
|
331
|
-
if (isInAddrAny &&
|
|
332
|
-
let socketURLProtocol = parsedURL.protocol ||
|
|
333
|
-
if ('auto:' === socketURLProtocol || hostname && isInAddrAny && 'https:' ===
|
|
333
|
+
if (isInAddrAny && pageLocation.hostname && 0 === pageLocation.protocol.indexOf('http')) hostname = pageLocation.hostname;
|
|
334
|
+
let socketURLProtocol = parsedURL.protocol || pageLocation.protocol;
|
|
335
|
+
if ('auto:' === socketURLProtocol || hostname && isInAddrAny && 'https:' === pageLocation.protocol) socketURLProtocol = pageLocation.protocol;
|
|
334
336
|
socketURLProtocol = socketURLProtocol.replace(/^(?:http|.+-extension|file)/i, 'ws');
|
|
335
337
|
let socketURLAuth = '';
|
|
336
338
|
if (parsedURL.username) {
|
|
337
339
|
socketURLAuth = parsedURL.username;
|
|
338
340
|
if (parsedURL.password) socketURLAuth = socketURLAuth.concat(':', parsedURL.password);
|
|
339
341
|
}
|
|
340
|
-
const socketURLHostname = (hostname ||
|
|
342
|
+
const socketURLHostname = (hostname || pageLocation.hostname || 'localhost').replace(/^\[(.*)\]$/, '$1');
|
|
341
343
|
let socketURLPort = parsedURL.port;
|
|
342
|
-
if (!socketURLPort || '0' === socketURLPort) socketURLPort =
|
|
344
|
+
if (!socketURLPort || '0' === socketURLPort) socketURLPort = pageLocation.port;
|
|
343
345
|
let socketURLPathname = '/ws';
|
|
344
346
|
if (parsedURL.pathname && !parsedURL.fromCurrentScript) socketURLPathname = parsedURL.pathname;
|
|
345
347
|
return formatURL({
|
package/client/overlay.js
CHANGED
|
@@ -408,7 +408,11 @@ const createOverlay = (options)=>{
|
|
|
408
408
|
});
|
|
409
409
|
}, trustedTypesPolicyName);
|
|
410
410
|
}
|
|
411
|
-
|
|
411
|
+
function handleEscapeKey(event) {
|
|
412
|
+
if ('Escape' === event.key || 'Esc' === event.key || 27 === event.keyCode) overlayService.send({
|
|
413
|
+
type: 'DISMISS'
|
|
414
|
+
});
|
|
415
|
+
}
|
|
412
416
|
const hideOverlayWithEscCleanup = ()=>{
|
|
413
417
|
window.removeEventListener('keydown', handleEscapeKey);
|
|
414
418
|
hide();
|
|
@@ -417,11 +421,6 @@ const createOverlay = (options)=>{
|
|
|
417
421
|
showOverlay: ({ level = 'error', messages, messageSource })=>show(level, messages, options.trustedTypesPolicyName, messageSource),
|
|
418
422
|
hideOverlay: hideOverlayWithEscCleanup
|
|
419
423
|
});
|
|
420
|
-
handleEscapeKey = (event)=>{
|
|
421
|
-
if ('Escape' === event.key || 'Esc' === event.key || 27 === event.keyCode) overlayService.send({
|
|
422
|
-
type: 'DISMISS'
|
|
423
|
-
});
|
|
424
|
-
};
|
|
425
424
|
window.addEventListener('keydown', handleEscapeKey);
|
|
426
425
|
if (options.catchRuntimeError) {
|
|
427
426
|
const handleError = (error, fallbackMessage)=>{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! LICENSE: 0
|
|
2
|
-
import { __webpack_require__ } from "./
|
|
1
|
+
/*! LICENSE: chokidar~0.js.LICENSE.txt */
|
|
2
|
+
import { __webpack_require__ } from "./t~0.js";
|
|
3
3
|
import { EventEmitter } from "node:events";
|
|
4
4
|
import { stat as external_node_fs_stat, unwatchFile, watch, watchFile } from "node:fs";
|
|
5
5
|
import { lstat, open as promises_open, readdir, realpath as promises_realpath, stat as promises_stat } from "node:fs/promises";
|
|
@@ -965,7 +965,7 @@ const toUnix = (string)=>{
|
|
|
965
965
|
const normalizePathToUnix = (path)=>toUnix(__rspack_external_node_path_806ed179.normalize(toUnix(path)));
|
|
966
966
|
const normalizeIgnored = (cwd = '')=>(path)=>{
|
|
967
967
|
if ('string' == typeof path) return normalizePathToUnix(__rspack_external_node_path_806ed179.isAbsolute(path) ? path : __rspack_external_node_path_806ed179.join(cwd, path));
|
|
968
|
-
return path;
|
|
968
|
+
else return path;
|
|
969
969
|
};
|
|
970
970
|
const getAbsolutePath = (path, cwd)=>{
|
|
971
971
|
if (__rspack_external_node_path_806ed179.isAbsolute(path)) return path;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { __webpack_require__ } from "./
|
|
2
|
-
import "
|
|
1
|
+
import { __webpack_require__ } from "./t~0.js";
|
|
2
|
+
import { createRequire as __rspack_createRequire } from "node:module";
|
|
3
|
+
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
3
4
|
__webpack_require__.add({
|
|
4
|
-
"./node_modules/.pnpm/connect-history-api-fallback@2.0.0/node_modules/connect-history-api-fallback/lib/index.js" (module, exports
|
|
5
|
-
var url =
|
|
5
|
+
"./node_modules/.pnpm/connect-history-api-fallback@2.0.0/node_modules/connect-history-api-fallback/lib/index.js" (module, exports) {
|
|
6
|
+
var url = __rspack_createRequire_require("url");
|
|
6
7
|
module.exports = function(options) {
|
|
7
8
|
options = options || {};
|
|
8
9
|
var logger = getLogger(options);
|
|
@@ -11,8 +12,7 @@ __webpack_require__.add({
|
|
|
11
12
|
if ('GET' !== req.method && 'HEAD' !== req.method) {
|
|
12
13
|
logger('Not rewriting', req.method, req.url, 'because the method is not GET or HEAD.');
|
|
13
14
|
return next();
|
|
14
|
-
}
|
|
15
|
-
if (headers && 'string' == typeof headers.accept) {
|
|
15
|
+
} else if (headers && 'string' == typeof headers.accept) {
|
|
16
16
|
if (0 === headers.accept.indexOf('application/json')) {
|
|
17
17
|
logger('Not rewriting', req.method, req.url, 'because the client prefers JSON.');
|
|
18
18
|
return next();
|
|
@@ -51,7 +51,7 @@ __webpack_require__.add({
|
|
|
51
51
|
};
|
|
52
52
|
function evaluateRewriteRule(parsedUrl, match, rule, req) {
|
|
53
53
|
if ('string' == typeof rule) return rule;
|
|
54
|
-
if ('function' != typeof rule) throw new Error('Rewrite rule can only be of type string or function.');
|
|
54
|
+
else if ('function' != typeof rule) throw new Error('Rewrite rule can only be of type string or function.');
|
|
55
55
|
return rule({
|
|
56
56
|
parsedUrl: parsedUrl,
|
|
57
57
|
match: match,
|
|
@@ -68,7 +68,7 @@ __webpack_require__.add({
|
|
|
68
68
|
}
|
|
69
69
|
function getLogger(options) {
|
|
70
70
|
if (options && options.logger) return options.logger;
|
|
71
|
-
if (options && options.verbose) return console.log.bind(console);
|
|
71
|
+
else if (options && options.verbose) return console.log.bind(console);
|
|
72
72
|
return function() {};
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! LICENSE:
|
|
1
|
+
/*! LICENSE: connect-next~0.js.LICENSE.txt */
|
|
2
2
|
import { EventEmitter } from "node:events";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import * as __rspack_external_node_http_e245b239 from "node:http";
|
|
@@ -591,17 +591,17 @@ __nested_rspack_require_364__.add({
|
|
|
591
591
|
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
|
|
592
592
|
}
|
|
593
593
|
},
|
|
594
|
-
"./node_modules/.pnpm/finalhandler@2.1.1/node_modules/finalhandler/index.js" (module, __unused_rspack_exports,
|
|
594
|
+
"./node_modules/.pnpm/finalhandler@2.1.1_supports-color@8.1.1/node_modules/finalhandler/index.js" (module, __unused_rspack_exports, __nested_rspack_require_23514_23533__) {
|
|
595
595
|
/*!
|
|
596
596
|
* finalhandler
|
|
597
597
|
* Copyright(c) 2014-2022 Douglas Christopher Wilson
|
|
598
598
|
* MIT Licensed
|
|
599
|
-
*/ var debug =
|
|
600
|
-
var encodeUrl =
|
|
601
|
-
var escapeHtml =
|
|
602
|
-
var onFinished =
|
|
603
|
-
var parseUrl =
|
|
604
|
-
var statuses =
|
|
599
|
+
*/ var debug = __nested_rspack_require_23514_23533__("./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js")('finalhandler');
|
|
600
|
+
var encodeUrl = __nested_rspack_require_23514_23533__("./node_modules/.pnpm/encodeurl@2.0.0/node_modules/encodeurl/index.js");
|
|
601
|
+
var escapeHtml = __nested_rspack_require_23514_23533__("./node_modules/.pnpm/escape-html@1.0.3/node_modules/escape-html/index.js");
|
|
602
|
+
var onFinished = __nested_rspack_require_23514_23533__("./node_modules/.pnpm/on-finished@2.4.1/node_modules/on-finished/index.js");
|
|
603
|
+
var parseUrl = __nested_rspack_require_23514_23533__("./node_modules/.pnpm/parseurl@1.3.3/node_modules/parseurl/index.js");
|
|
604
|
+
var statuses = __nested_rspack_require_23514_23533__("./node_modules/.pnpm/statuses@2.0.2/node_modules/statuses/index.js");
|
|
605
605
|
var isFinished = onFinished.isFinished;
|
|
606
606
|
function createHtmlDocument(message) {
|
|
607
607
|
var body = escapeHtml(message).replaceAll('\n', '<br>').replaceAll(' ', ' ');
|
|
@@ -781,7 +781,7 @@ __nested_rspack_require_364__.add({
|
|
|
781
781
|
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
|
782
782
|
}
|
|
783
783
|
},
|
|
784
|
-
"./node_modules/.pnpm/on-finished@2.4.1/node_modules/on-finished/index.js" (module, __unused_rspack_exports,
|
|
784
|
+
"./node_modules/.pnpm/on-finished@2.4.1/node_modules/on-finished/index.js" (module, __unused_rspack_exports, __nested_rspack_require_32118_32137__) {
|
|
785
785
|
/*!
|
|
786
786
|
* on-finished
|
|
787
787
|
* Copyright(c) 2013 Jonathan Ong
|
|
@@ -790,7 +790,7 @@ __nested_rspack_require_364__.add({
|
|
|
790
790
|
*/ module.exports = onFinished;
|
|
791
791
|
module.exports.isFinished = isFinished;
|
|
792
792
|
var asyncHooks = tryRequireAsyncHooks();
|
|
793
|
-
var first =
|
|
793
|
+
var first = __nested_rspack_require_32118_32137__("./node_modules/.pnpm/ee-first@1.1.1/node_modules/ee-first/index.js");
|
|
794
794
|
var defer = 'function' == typeof setImmediate ? setImmediate : function(fn) {
|
|
795
795
|
process.nextTick(fn.bind.apply(fn, arguments));
|
|
796
796
|
};
|
|
@@ -869,7 +869,7 @@ __nested_rspack_require_364__.add({
|
|
|
869
869
|
}
|
|
870
870
|
function tryRequireAsyncHooks() {
|
|
871
871
|
try {
|
|
872
|
-
return
|
|
872
|
+
return __nested_rspack_require_32118_32137__("async_hooks");
|
|
873
873
|
} catch (e) {
|
|
874
874
|
return {};
|
|
875
875
|
}
|
|
@@ -881,13 +881,13 @@ __nested_rspack_require_364__.add({
|
|
|
881
881
|
return res.runInAsyncScope.bind(res, fn, null);
|
|
882
882
|
}
|
|
883
883
|
},
|
|
884
|
-
"./node_modules/.pnpm/parseurl@1.3.3/node_modules/parseurl/index.js" (module, __unused_rspack_exports,
|
|
884
|
+
"./node_modules/.pnpm/parseurl@1.3.3/node_modules/parseurl/index.js" (module, __unused_rspack_exports, __nested_rspack_require_36038_36057__) {
|
|
885
885
|
/*!
|
|
886
886
|
* parseurl
|
|
887
887
|
* Copyright(c) 2014 Jonathan Ong
|
|
888
888
|
* Copyright(c) 2014-2017 Douglas Christopher Wilson
|
|
889
889
|
* MIT Licensed
|
|
890
|
-
*/ var url =
|
|
890
|
+
*/ var url = __nested_rspack_require_36038_36057__("url");
|
|
891
891
|
var parse = url.parse;
|
|
892
892
|
var Url = url.Url;
|
|
893
893
|
module.exports = parseurl;
|
|
@@ -947,13 +947,13 @@ __nested_rspack_require_364__.add({
|
|
|
947
947
|
return 'object' == typeof parsedUrl && null !== parsedUrl && (void 0 === Url || parsedUrl instanceof Url) && parsedUrl._raw === url;
|
|
948
948
|
}
|
|
949
949
|
},
|
|
950
|
-
"./node_modules/.pnpm/statuses@2.0.2/node_modules/statuses/index.js" (module, __unused_rspack_exports,
|
|
950
|
+
"./node_modules/.pnpm/statuses@2.0.2/node_modules/statuses/index.js" (module, __unused_rspack_exports, __nested_rspack_require_38509_38528__) {
|
|
951
951
|
/*!
|
|
952
952
|
* statuses
|
|
953
953
|
* Copyright(c) 2014 Jonathan Ong
|
|
954
954
|
* Copyright(c) 2016 Douglas Christopher Wilson
|
|
955
955
|
* MIT Licensed
|
|
956
|
-
*/ var codes =
|
|
956
|
+
*/ var codes = __nested_rspack_require_38509_38528__("./node_modules/.pnpm/statuses@2.0.2/node_modules/statuses/codes.json");
|
|
957
957
|
module.exports = status;
|
|
958
958
|
status.message = codes;
|
|
959
959
|
status.code = createMessageToStatusCodeMap(codes);
|
|
@@ -1008,10 +1008,10 @@ __nested_rspack_require_364__.add({
|
|
|
1008
1008
|
return getStatusCode(code);
|
|
1009
1009
|
}
|
|
1010
1010
|
},
|
|
1011
|
-
"./node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js" (module, __unused_rspack_exports,
|
|
1012
|
-
const os =
|
|
1013
|
-
const tty =
|
|
1014
|
-
const hasFlag =
|
|
1011
|
+
"./node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js" (module, __unused_rspack_exports, __nested_rspack_require_40801_40820__) {
|
|
1012
|
+
const os = __nested_rspack_require_40801_40820__("os");
|
|
1013
|
+
const tty = __nested_rspack_require_40801_40820__("tty");
|
|
1014
|
+
const hasFlag = __nested_rspack_require_40801_40820__("./node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js");
|
|
1015
1015
|
const { env } = process;
|
|
1016
1016
|
let flagForceColor;
|
|
1017
1017
|
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) flagForceColor = 0;
|
|
@@ -1115,7 +1115,7 @@ __nested_rspack_require_364__.add({
|
|
|
1115
1115
|
});
|
|
1116
1116
|
const src = __nested_rspack_require_364__("./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js");
|
|
1117
1117
|
var src_default = /*#__PURE__*/ __nested_rspack_require_364__.n(src);
|
|
1118
|
-
const dist_finalhandler = __nested_rspack_require_364__("./node_modules/.pnpm/finalhandler@2.1.1/node_modules/finalhandler/index.js");
|
|
1118
|
+
const dist_finalhandler = __nested_rspack_require_364__("./node_modules/.pnpm/finalhandler@2.1.1_supports-color@8.1.1/node_modules/finalhandler/index.js");
|
|
1119
1119
|
var finalhandler_default = /*#__PURE__*/ __nested_rspack_require_364__.n(dist_finalhandler);
|
|
1120
1120
|
const dist_parseurl = __nested_rspack_require_364__("./node_modules/.pnpm/parseurl@1.3.3/node_modules/parseurl/index.js");
|
|
1121
1121
|
var parseurl_default = /*#__PURE__*/ __nested_rspack_require_364__.n(dist_parseurl);
|
|
@@ -1219,13 +1219,29 @@ function call(handle, route, err, req, res, next) {
|
|
|
1219
1219
|
const hasError = void 0 !== err;
|
|
1220
1220
|
dist_debug('%s %s : %s', handle.name || '<anonymous>', route, req.originalUrl);
|
|
1221
1221
|
try {
|
|
1222
|
-
if (hasError && 4 === arity)
|
|
1223
|
-
|
|
1222
|
+
if (hasError && 4 === arity) {
|
|
1223
|
+
const result = handle(err, req, res, next);
|
|
1224
|
+
handlePromise(result, next);
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
if (!hasError && arity < 4) {
|
|
1228
|
+
const result = handle(req, res, next);
|
|
1229
|
+
handlePromise(result, next);
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1224
1232
|
} catch (caughtError) {
|
|
1225
1233
|
error = caughtError;
|
|
1226
1234
|
}
|
|
1227
1235
|
next(error);
|
|
1228
1236
|
}
|
|
1237
|
+
function isPromise(value) {
|
|
1238
|
+
return null !== value && ('object' == typeof value || 'function' == typeof value) && 'function' == typeof value.then;
|
|
1239
|
+
}
|
|
1240
|
+
function handlePromise(result, next) {
|
|
1241
|
+
if (isPromise(result)) result.then(null, (error)=>{
|
|
1242
|
+
next(error || new Error('Rejected promise'));
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1229
1245
|
function logerror(err) {
|
|
1230
1246
|
if ('test' !== dist_env) {
|
|
1231
1247
|
if (err instanceof Error) return void console.error(err.stack || err.toString());
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { __webpack_require__ } from "./
|
|
2
|
-
import "
|
|
1
|
+
import { __webpack_require__ } from "./t~0.js";
|
|
2
|
+
import { createRequire as __rspack_createRequire } from "node:module";
|
|
3
|
+
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
3
4
|
__webpack_require__.add({
|
|
4
5
|
"./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js" (module, exports, __webpack_require__) {
|
|
5
6
|
exports.formatArgs = formatArgs;
|
|
@@ -291,8 +292,8 @@ __webpack_require__.add({
|
|
|
291
292
|
else module.exports = __webpack_require__("./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js");
|
|
292
293
|
},
|
|
293
294
|
"./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js" (module, exports, __webpack_require__) {
|
|
294
|
-
const tty =
|
|
295
|
-
const util =
|
|
295
|
+
const tty = __rspack_createRequire_require("tty");
|
|
296
|
+
const util = __rspack_createRequire_require("util");
|
|
296
297
|
exports.init = init;
|
|
297
298
|
exports.log = log;
|
|
298
299
|
exports.formatArgs = formatArgs;
|
|
@@ -458,7 +459,7 @@ __webpack_require__.add({
|
|
|
458
459
|
options = options || {};
|
|
459
460
|
var type = typeof val;
|
|
460
461
|
if ('string' === type && val.length > 0) return parse(val);
|
|
461
|
-
if ('number' === type && isFinite(val)) return options.long ? fmtLong(val) : fmtShort(val);
|
|
462
|
+
else if ('number' === type && isFinite(val)) return options.long ? fmtLong(val) : fmtShort(val);
|
|
462
463
|
throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
|
|
463
464
|
};
|
|
464
465
|
function parse(str) {
|
|
@@ -533,8 +534,8 @@ __webpack_require__.add({
|
|
|
533
534
|
}
|
|
534
535
|
},
|
|
535
536
|
"./node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
536
|
-
const os =
|
|
537
|
-
const tty =
|
|
537
|
+
const os = __rspack_createRequire_require("os");
|
|
538
|
+
const tty = __rspack_createRequire_require("tty");
|
|
538
539
|
const hasFlag = __webpack_require__("./node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js");
|
|
539
540
|
const { env } = process;
|
|
540
541
|
let flagForceColor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! LICENSE:
|
|
1
|
+
/*! LICENSE: http-proxy-middleware~0.js.LICENSE.txt */
|
|
2
2
|
import node_http from "node:http";
|
|
3
3
|
import node_https from "node:https";
|
|
4
4
|
import node_http2 from "node:http2";
|
|
@@ -6,13 +6,13 @@ import { EventEmitter } from "node:events";
|
|
|
6
6
|
import "node:net";
|
|
7
7
|
import "node:stream";
|
|
8
8
|
import { styleText } from "node:util";
|
|
9
|
-
import { URL as external_node_url_URL } from "node:url";
|
|
10
9
|
import { URL as external_url_URL } from "url";
|
|
11
10
|
import "node:zlib";
|
|
12
11
|
import "node:querystring";
|
|
13
|
-
import { __webpack_require__ } from "./
|
|
14
|
-
import "./0
|
|
15
|
-
import "
|
|
12
|
+
import { __webpack_require__ } from "./t~0.js";
|
|
13
|
+
import "./debug~0.js";
|
|
14
|
+
import { createRequire as __rspack_createRequire } from "node:module";
|
|
15
|
+
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
16
16
|
__webpack_require__.add({
|
|
17
17
|
"./node_modules/.pnpm/braces@3.0.3/node_modules/braces/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
18
18
|
const stringify = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/stringify.js");
|
|
@@ -560,7 +560,7 @@ __webpack_require__.add({
|
|
|
560
560
|
*
|
|
561
561
|
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
562
562
|
* Licensed under the MIT License.
|
|
563
|
-
*/ const util =
|
|
563
|
+
*/ const util = __rspack_createRequire_require("util");
|
|
564
564
|
const toRegexRange = __webpack_require__("./node_modules/.pnpm/to-regex-range@5.0.1/node_modules/to-regex-range/index.js");
|
|
565
565
|
const isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
|
|
566
566
|
const transform = (toNumber)=>(value)=>true === toNumber ? Number(value) : String(value);
|
|
@@ -848,7 +848,7 @@ __webpack_require__.add({
|
|
|
848
848
|
};
|
|
849
849
|
},
|
|
850
850
|
"./node_modules/.pnpm/micromatch@4.0.8/node_modules/micromatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
851
|
-
const util =
|
|
851
|
+
const util = __rspack_createRequire_require("util");
|
|
852
852
|
const braces = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/index.js");
|
|
853
853
|
const picomatch = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/index.js");
|
|
854
854
|
const utils = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js");
|
|
@@ -993,8 +993,8 @@ __webpack_require__.add({
|
|
|
993
993
|
"./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
994
994
|
module.exports = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js");
|
|
995
995
|
},
|
|
996
|
-
"./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js" (module
|
|
997
|
-
const path =
|
|
996
|
+
"./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js" (module) {
|
|
997
|
+
const path = __rspack_createRequire_require("path");
|
|
998
998
|
const WIN_SLASH = '\\\\/';
|
|
999
999
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
1000
1000
|
const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
@@ -2157,7 +2157,7 @@ __webpack_require__.add({
|
|
|
2157
2157
|
module.exports = parse;
|
|
2158
2158
|
},
|
|
2159
2159
|
"./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
2160
|
-
const path =
|
|
2160
|
+
const path = __rspack_createRequire_require("path");
|
|
2161
2161
|
const scan = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/scan.js");
|
|
2162
2162
|
const parse = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/parse.js");
|
|
2163
2163
|
const utils = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js");
|
|
@@ -2559,7 +2559,7 @@ __webpack_require__.add({
|
|
|
2559
2559
|
module.exports = scan;
|
|
2560
2560
|
},
|
|
2561
2561
|
"./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
2562
|
-
const path =
|
|
2562
|
+
const path = __rspack_createRequire_require("path");
|
|
2563
2563
|
const win32 = 'win32' === process.platform;
|
|
2564
2564
|
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = __webpack_require__("./node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js");
|
|
2565
2565
|
exports.isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
|
|
@@ -3513,7 +3513,14 @@ function createUrl({ protocol, host, port, path }) {
|
|
|
3513
3513
|
const base = `${protocol || 'undefined:'}//${ipv6Host || '[::]'}`;
|
|
3514
3514
|
const url = new external_url_URL(base);
|
|
3515
3515
|
if (port) url.port = port;
|
|
3516
|
-
if (path)
|
|
3516
|
+
if (path) {
|
|
3517
|
+
const queryIndex = path.indexOf('?');
|
|
3518
|
+
if (-1 === queryIndex) url.pathname = path;
|
|
3519
|
+
else {
|
|
3520
|
+
url.pathname = path.slice(0, queryIndex);
|
|
3521
|
+
url.search = path.slice(queryIndex);
|
|
3522
|
+
}
|
|
3523
|
+
}
|
|
3517
3524
|
return url;
|
|
3518
3525
|
}
|
|
3519
3526
|
function logger_plugin_getPort(sockets) {
|
|
@@ -3541,14 +3548,12 @@ const loggerPlugin = definePlugin((proxyServer, options)=>{
|
|
|
3541
3548
|
port,
|
|
3542
3549
|
path
|
|
3543
3550
|
});
|
|
3551
|
+
const targetUrl = target.toString();
|
|
3552
|
+
const exchange = `[HPM] ${req.method} ${originalUrl} -> ${targetUrl} [${proxyRes.statusCode}]`;
|
|
3553
|
+
logger.info(exchange);
|
|
3544
3554
|
} catch (err) {
|
|
3545
3555
|
console.error('[HPM] Unexpected error while creating target URL', err);
|
|
3546
|
-
target = new external_node_url_URL(options.target);
|
|
3547
|
-
target.pathname = proxyRes.req.path;
|
|
3548
3556
|
}
|
|
3549
|
-
const targetUrl = target.toString();
|
|
3550
|
-
const exchange = `[HPM] ${req.method} ${originalUrl} -> ${targetUrl} [${proxyRes.statusCode}]`;
|
|
3551
|
-
logger.info(exchange);
|
|
3552
3557
|
});
|
|
3553
3558
|
proxyServer.on('open', (socket)=>{
|
|
3554
3559
|
logger.info('[HPM] Client connected: %o', socket.address());
|
|
@@ -3646,9 +3651,10 @@ function createPathRewriter(rewriteConfig) {
|
|
|
3646
3651
|
if ('function' == typeof rewriteConfig) {
|
|
3647
3652
|
const customRewriteFn = rewriteConfig;
|
|
3648
3653
|
return customRewriteFn;
|
|
3654
|
+
} else {
|
|
3655
|
+
rulesCache = parsePathRewriteRules(rewriteConfig);
|
|
3656
|
+
return rewritePath;
|
|
3649
3657
|
}
|
|
3650
|
-
rulesCache = parsePathRewriteRules(rewriteConfig);
|
|
3651
|
-
return rewritePath;
|
|
3652
3658
|
function rewritePath(path) {
|
|
3653
3659
|
let result = path;
|
|
3654
3660
|
for (const rule of rulesCache)if (rule.regex.test(path)) {
|
|
@@ -3661,9 +3667,9 @@ function createPathRewriter(rewriteConfig) {
|
|
|
3661
3667
|
}
|
|
3662
3668
|
function isValidRewriteConfig(rewriteConfig) {
|
|
3663
3669
|
if ('function' == typeof rewriteConfig) return true;
|
|
3664
|
-
if (isPlainObject(rewriteConfig)) return 0 !== Object.keys(rewriteConfig).length;
|
|
3665
|
-
if (null == rewriteConfig) return false;
|
|
3666
|
-
throw new errors_HttpProxyMiddlewareError('[HPM] Invalid pathRewrite config. Expecting object with pathRewrite config or a rewrite function', 'HPM_INVALID_PATH_REWRITER_CONFIG');
|
|
3670
|
+
else if (isPlainObject(rewriteConfig)) return 0 !== Object.keys(rewriteConfig).length;
|
|
3671
|
+
else if (null == rewriteConfig) return false;
|
|
3672
|
+
else throw new errors_HttpProxyMiddlewareError('[HPM] Invalid pathRewrite config. Expecting object with pathRewrite config or a rewrite function', 'HPM_INVALID_PATH_REWRITER_CONFIG');
|
|
3667
3673
|
}
|
|
3668
3674
|
function parsePathRewriteRules(rewriteConfig) {
|
|
3669
3675
|
const rules = [];
|
|
@@ -3809,8 +3815,10 @@ class HttpProxyMiddleware {
|
|
|
3809
3815
|
Debug('server close signal received.');
|
|
3810
3816
|
this.activeServers.delete(server);
|
|
3811
3817
|
if (this.activeServers.size > 0) return void Debug(`proxy server not closed: ${this.activeServers.size} server(s) still active`);
|
|
3812
|
-
|
|
3813
|
-
|
|
3818
|
+
else {
|
|
3819
|
+
Debug('closing proxy server');
|
|
3820
|
+
this.proxy.close(()=>Debug('proxy server closed'));
|
|
3821
|
+
}
|
|
3814
3822
|
});
|
|
3815
3823
|
}
|
|
3816
3824
|
if (true === this.proxyOptions.ws && server) this.catchUpgradeRequest(server);
|
package/dist/index.d.ts
CHANGED
|
@@ -174,7 +174,7 @@ declare const EntryTypes: {
|
|
|
174
174
|
readonly EVERYTHING_TYPE: "all";
|
|
175
175
|
};
|
|
176
176
|
|
|
177
|
-
declare type ErrorHandleFunction = (err: any, req: IncomingMessage, res: http.ServerResponse, next: NextFunction) =>
|
|
177
|
+
declare type ErrorHandleFunction = (err: any, req: IncomingMessage, res: http.ServerResponse, next: NextFunction) => unknown;
|
|
178
178
|
|
|
179
179
|
declare type EventName = (typeof EVENTS)[keyof typeof EVENTS];
|
|
180
180
|
|
|
@@ -338,6 +338,8 @@ declare interface IncomingMessage extends http.IncomingMessage {
|
|
|
338
338
|
originalUrl?: http.IncomingMessage['url'] | undefined;
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
declare type ListenCallback = () => void;
|
|
342
|
+
|
|
341
343
|
/** https://github.com/microsoft/TypeScript/issues/29729 */
|
|
342
344
|
declare type LiteralUnion<T extends U, U> = T | (U & Record<never, never>);
|
|
343
345
|
|
|
@@ -360,7 +362,7 @@ declare interface MiddlewareObject {
|
|
|
360
362
|
|
|
361
363
|
declare type NextFunction = (err?: any) => void;
|
|
362
364
|
|
|
363
|
-
declare type NextHandleFunction = (req: IncomingMessage, res: http.ServerResponse, next: NextFunction) =>
|
|
365
|
+
declare type NextHandleFunction = (req: IncomingMessage, res: http.ServerResponse, next: NextFunction) => unknown;
|
|
364
366
|
|
|
365
367
|
/**
|
|
366
368
|
* @mixin
|
|
@@ -525,21 +527,21 @@ export declare class RspackDevServer<A extends BasicApplication = Server, S exte
|
|
|
525
527
|
}
|
|
526
528
|
|
|
527
529
|
declare interface Server extends EventEmitter {
|
|
528
|
-
(req: http.IncomingMessage, res: http.ServerResponse, next?:
|
|
530
|
+
(req: http.IncomingMessage, res: http.ServerResponse, next?: NextFunction): void;
|
|
529
531
|
route: string;
|
|
530
532
|
stack: ServerStackItem[];
|
|
531
|
-
handle(req: http.IncomingMessage, res: http.ServerResponse, next?:
|
|
533
|
+
handle(req: http.IncomingMessage, res: http.ServerResponse, next?: NextFunction): void;
|
|
532
534
|
use(fn: NextHandleFunction): Server;
|
|
533
535
|
use(fn: HandleFunction): Server;
|
|
534
536
|
use(fn: http.Server): Server;
|
|
535
537
|
use(route: string, fn: NextHandleFunction): Server;
|
|
536
538
|
use(route: string, fn: HandleFunction): Server;
|
|
537
539
|
use(route: string, fn: http.Server): Server;
|
|
538
|
-
listen(port: number, hostname?: string, backlog?: number, callback?:
|
|
539
|
-
listen(port: number, hostname?: string, callback?:
|
|
540
|
-
listen(path: string, callback?:
|
|
541
|
-
listen(options: ListenOptions, callback?:
|
|
542
|
-
listen(handle: unknown, listeningListener?:
|
|
540
|
+
listen(port: number, hostname?: string, backlog?: number, callback?: ListenCallback): http.Server;
|
|
541
|
+
listen(port: number, hostname?: string, callback?: ListenCallback): http.Server;
|
|
542
|
+
listen(path: string, callback?: ListenCallback): http.Server;
|
|
543
|
+
listen(options: ListenOptions, callback?: ListenCallback): http.Server;
|
|
544
|
+
listen(handle: unknown, listeningListener?: ListenCallback): http.Server;
|
|
543
545
|
}
|
|
544
546
|
|
|
545
547
|
declare class Server_5<
|
|
@@ -625,7 +627,7 @@ declare interface ServerStackItem {
|
|
|
625
627
|
|
|
626
628
|
declare type ServerType<A extends BasicApplication, S extends BasicServer> = LiteralUnion<'http' | 'https' | 'http2', string> | ((serverOptions: ServerOptions, application: A) => S);
|
|
627
629
|
|
|
628
|
-
declare type SimpleHandleFunction = (req: IncomingMessage, res: http.ServerResponse) =>
|
|
630
|
+
declare type SimpleHandleFunction = (req: IncomingMessage, res: http.ServerResponse) => unknown;
|
|
629
631
|
|
|
630
632
|
/** Filterer for files */
|
|
631
633
|
declare type Tester = (entryInfo: EntryInfo) => boolean;
|
|
@@ -893,6 +895,8 @@ declare namespace WebSocket_2 {
|
|
|
893
895
|
allowSynchronousEvents?: boolean | undefined;
|
|
894
896
|
autoPong?: boolean | undefined;
|
|
895
897
|
maxPayload?: number | undefined;
|
|
898
|
+
maxBufferedChunks?: number | undefined;
|
|
899
|
+
maxFragments?: number | undefined;
|
|
896
900
|
skipUTF8Validation?: boolean | undefined;
|
|
897
901
|
createConnection?: typeof createConnection | undefined;
|
|
898
902
|
finishRequest?: FinishRequestCallback | undefined;
|
|
@@ -978,6 +982,8 @@ declare namespace WebSocket_2 {
|
|
|
978
982
|
clientTracking?: boolean | undefined;
|
|
979
983
|
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined;
|
|
980
984
|
maxPayload?: number | undefined;
|
|
985
|
+
maxBufferedChunks?: number | undefined;
|
|
986
|
+
maxFragments?: number | undefined;
|
|
981
987
|
skipUTF8Validation?: boolean | undefined;
|
|
982
988
|
WebSocket?: U | undefined;
|
|
983
989
|
}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { RspackDevServer } from "./
|
|
1
|
+
export { RspackDevServer } from "./t~0.js";
|