@rspack/dev-server 2.0.3 → 2.1.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/overlay.js +2 -1
- package/client/utils/ansiHTML.js +1 -1
- package/dist/0~chokidar.js +3 -4
- package/dist/0~connect-history-api-fallback.js +2 -2
- package/dist/0~connect-next.js +40 -36
- package/dist/0~debug.js +2 -2
- package/dist/0~http-proxy-middleware.js +89 -44
- package/dist/0~launch-editor.js +111 -63
- package/dist/0~serve-static.js +4 -4
- package/dist/{465.js → 944.js} +12 -21
- package/dist/index.js +1 -1
- package/package.json +16 -17
package/client/overlay.js
CHANGED
|
@@ -41,7 +41,8 @@ function _object_spread_props(target, source) {
|
|
|
41
41
|
});
|
|
42
42
|
return target;
|
|
43
43
|
}
|
|
44
|
-
const
|
|
44
|
+
const hasCodePointAt = 'function' == typeof String.prototype.codePointAt;
|
|
45
|
+
const getCodePoint = hasCodePointAt ? (input, position)=>input.codePointAt(position) : (input, position)=>(input.charCodeAt(position) - 0xd800) * 0x400 + input.charCodeAt(position + 1) - 0xdc00 + 0x10000;
|
|
45
46
|
const replaceUsingRegExp = (macroText, macroRegExp, macroReplacer)=>{
|
|
46
47
|
macroRegExp.lastIndex = 0;
|
|
47
48
|
let replaceMatch = macroRegExp.exec(macroText);
|
package/client/utils/ansiHTML.js
CHANGED
|
@@ -140,7 +140,7 @@ ansiHTML.setColors = (colors)=>{
|
|
|
140
140
|
if ('object' != typeof colors) throw new Error('`colors` parameter must be an Object.');
|
|
141
141
|
const _finalColors = {};
|
|
142
142
|
for(const key in _defColors){
|
|
143
|
-
let hex =
|
|
143
|
+
let hex = Object.prototype.hasOwnProperty.call(colors, key) ? colors[key] : null;
|
|
144
144
|
if (!hex) {
|
|
145
145
|
_finalColors[key] = _defColors[key];
|
|
146
146
|
continue;
|
package/dist/0~chokidar.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! LICENSE: 0~chokidar.js.LICENSE.txt */
|
|
2
|
-
import { __webpack_require__ } from "./
|
|
2
|
+
import { __webpack_require__ } from "./944.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";
|
|
@@ -244,7 +244,6 @@ function readdirp(root, options = {}) {
|
|
|
244
244
|
}
|
|
245
245
|
const STR_DATA = 'data';
|
|
246
246
|
const STR_END = 'end';
|
|
247
|
-
const STR_CLOSE = 'close';
|
|
248
247
|
const EMPTY_FN = ()=>{};
|
|
249
248
|
const pl = process.platform;
|
|
250
249
|
const isWindows = 'win32' === pl;
|
|
@@ -1453,10 +1452,10 @@ class FSWatcher extends EventEmitter {
|
|
|
1453
1452
|
};
|
|
1454
1453
|
let stream = readdirp(root, options);
|
|
1455
1454
|
this._streams.add(stream);
|
|
1456
|
-
stream.once(
|
|
1455
|
+
stream.once("close", ()=>{
|
|
1457
1456
|
stream = void 0;
|
|
1458
1457
|
});
|
|
1459
|
-
stream.once(
|
|
1458
|
+
stream.once("end", ()=>{
|
|
1460
1459
|
if (stream) {
|
|
1461
1460
|
this._streams.delete(stream);
|
|
1462
1461
|
stream = void 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __webpack_require__ } from "./
|
|
2
|
-
import "./
|
|
1
|
+
import { __webpack_require__ } from "./944.js";
|
|
2
|
+
import "./944.js";
|
|
3
3
|
__webpack_require__.add({
|
|
4
4
|
"./node_modules/.pnpm/connect-history-api-fallback@2.0.0/node_modules/connect-history-api-fallback/lib/index.js" (module, exports, __webpack_require__) {
|
|
5
5
|
var url = __webpack_require__("url?b918");
|
package/dist/0~connect-next.js
CHANGED
|
@@ -25,11 +25,15 @@ __nested_rspack_require_364__.m = __webpack_modules__;
|
|
|
25
25
|
};
|
|
26
26
|
})();
|
|
27
27
|
(()=>{
|
|
28
|
-
__nested_rspack_require_364__.d = (exports,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
__nested_rspack_require_364__.d = (exports, getters, values)=>{
|
|
29
|
+
var define = (defs, kind)=>{
|
|
30
|
+
for(var key in defs)if (__nested_rspack_require_364__.o(defs, key) && !__nested_rspack_require_364__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
[kind]: defs[key]
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
define(getters, "get");
|
|
36
|
+
define(values, "value");
|
|
33
37
|
};
|
|
34
38
|
})();
|
|
35
39
|
(()=>{
|
|
@@ -41,7 +45,7 @@ __nested_rspack_require_364__.m = __webpack_modules__;
|
|
|
41
45
|
__nested_rspack_require_364__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
42
46
|
})();
|
|
43
47
|
__nested_rspack_require_364__.add({
|
|
44
|
-
"./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js" (module, exports,
|
|
48
|
+
"./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js" (module, exports, __nested_rspack_require_1796_1815__) {
|
|
45
49
|
exports.formatArgs = formatArgs;
|
|
46
50
|
exports.save = save;
|
|
47
51
|
exports.load = load;
|
|
@@ -174,7 +178,7 @@ __nested_rspack_require_364__.add({
|
|
|
174
178
|
return localStorage;
|
|
175
179
|
} catch (error) {}
|
|
176
180
|
}
|
|
177
|
-
module.exports =
|
|
181
|
+
module.exports = __nested_rspack_require_1796_1815__("./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js")(exports);
|
|
178
182
|
const { formatters } = module.exports;
|
|
179
183
|
formatters.j = function(v) {
|
|
180
184
|
try {
|
|
@@ -184,7 +188,7 @@ __nested_rspack_require_364__.add({
|
|
|
184
188
|
}
|
|
185
189
|
};
|
|
186
190
|
},
|
|
187
|
-
"./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js" (module, __unused_rspack_exports,
|
|
191
|
+
"./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js" (module, __unused_rspack_exports, __nested_rspack_require_6962_6981__) {
|
|
188
192
|
function setup(env) {
|
|
189
193
|
createDebug.debug = createDebug;
|
|
190
194
|
createDebug.default = createDebug;
|
|
@@ -192,7 +196,7 @@ __nested_rspack_require_364__.add({
|
|
|
192
196
|
createDebug.disable = disable;
|
|
193
197
|
createDebug.enable = enable;
|
|
194
198
|
createDebug.enabled = enabled;
|
|
195
|
-
createDebug.humanize =
|
|
199
|
+
createDebug.humanize = __nested_rspack_require_6962_6981__("./node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js");
|
|
196
200
|
createDebug.destroy = destroy;
|
|
197
201
|
Object.keys(env).forEach((key)=>{
|
|
198
202
|
createDebug[key] = env[key];
|
|
@@ -326,13 +330,13 @@ __nested_rspack_require_364__.add({
|
|
|
326
330
|
}
|
|
327
331
|
module.exports = setup;
|
|
328
332
|
},
|
|
329
|
-
"./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js" (module, __unused_rspack_exports,
|
|
330
|
-
if ("u" < typeof process || 'renderer' === process.type || true === process.browser || process.__nwjs) module.exports =
|
|
331
|
-
else module.exports =
|
|
333
|
+
"./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js" (module, __unused_rspack_exports, __nested_rspack_require_13710_13729__) {
|
|
334
|
+
if ("u" < typeof process || 'renderer' === process.type || true === process.browser || process.__nwjs) module.exports = __nested_rspack_require_13710_13729__("./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js");
|
|
335
|
+
else module.exports = __nested_rspack_require_13710_13729__("./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js");
|
|
332
336
|
},
|
|
333
|
-
"./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js" (module, exports,
|
|
334
|
-
const tty =
|
|
335
|
-
const util =
|
|
337
|
+
"./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js" (module, exports, __nested_rspack_require_14228_14247__) {
|
|
338
|
+
const tty = __nested_rspack_require_14228_14247__("tty");
|
|
339
|
+
const util = __nested_rspack_require_14228_14247__("util");
|
|
336
340
|
exports.init = init;
|
|
337
341
|
exports.log = log;
|
|
338
342
|
exports.formatArgs = formatArgs;
|
|
@@ -349,7 +353,7 @@ __nested_rspack_require_364__.add({
|
|
|
349
353
|
1
|
|
350
354
|
];
|
|
351
355
|
try {
|
|
352
|
-
const supportsColor =
|
|
356
|
+
const supportsColor = __nested_rspack_require_14228_14247__("./node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js");
|
|
353
357
|
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) exports.colors = [
|
|
354
358
|
20,
|
|
355
359
|
21,
|
|
@@ -468,7 +472,7 @@ __nested_rspack_require_364__.add({
|
|
|
468
472
|
const keys = Object.keys(exports.inspectOpts);
|
|
469
473
|
for(let i = 0; i < keys.length; i++)debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
470
474
|
}
|
|
471
|
-
module.exports =
|
|
475
|
+
module.exports = __nested_rspack_require_14228_14247__("./node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js")(exports);
|
|
472
476
|
const { formatters } = module.exports;
|
|
473
477
|
formatters.o = function(v) {
|
|
474
478
|
this.inspectOpts.colors = this.useColors;
|
|
@@ -587,17 +591,17 @@ __nested_rspack_require_364__.add({
|
|
|
587
591
|
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
|
|
588
592
|
}
|
|
589
593
|
},
|
|
590
|
-
"./node_modules/.pnpm/finalhandler@2.1.1/node_modules/finalhandler/index.js" (module, __unused_rspack_exports,
|
|
594
|
+
"./node_modules/.pnpm/finalhandler@2.1.1/node_modules/finalhandler/index.js" (module, __unused_rspack_exports, __nested_rspack_require_23493_23512__) {
|
|
591
595
|
/*!
|
|
592
596
|
* finalhandler
|
|
593
597
|
* Copyright(c) 2014-2022 Douglas Christopher Wilson
|
|
594
598
|
* MIT Licensed
|
|
595
|
-
*/ var debug =
|
|
596
|
-
var encodeUrl =
|
|
597
|
-
var escapeHtml =
|
|
598
|
-
var onFinished =
|
|
599
|
-
var parseUrl =
|
|
600
|
-
var statuses =
|
|
599
|
+
*/ var debug = __nested_rspack_require_23493_23512__("./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_23493_23512__("./node_modules/.pnpm/encodeurl@2.0.0/node_modules/encodeurl/index.js");
|
|
601
|
+
var escapeHtml = __nested_rspack_require_23493_23512__("./node_modules/.pnpm/escape-html@1.0.3/node_modules/escape-html/index.js");
|
|
602
|
+
var onFinished = __nested_rspack_require_23493_23512__("./node_modules/.pnpm/on-finished@2.4.1/node_modules/on-finished/index.js");
|
|
603
|
+
var parseUrl = __nested_rspack_require_23493_23512__("./node_modules/.pnpm/parseurl@1.3.3/node_modules/parseurl/index.js");
|
|
604
|
+
var statuses = __nested_rspack_require_23493_23512__("./node_modules/.pnpm/statuses@2.0.2/node_modules/statuses/index.js");
|
|
601
605
|
var isFinished = onFinished.isFinished;
|
|
602
606
|
function createHtmlDocument(message) {
|
|
603
607
|
var body = escapeHtml(message).replaceAll('\n', '<br>').replaceAll(' ', ' ');
|
|
@@ -777,7 +781,7 @@ __nested_rspack_require_364__.add({
|
|
|
777
781
|
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
|
778
782
|
}
|
|
779
783
|
},
|
|
780
|
-
"./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_32097_32116__) {
|
|
781
785
|
/*!
|
|
782
786
|
* on-finished
|
|
783
787
|
* Copyright(c) 2013 Jonathan Ong
|
|
@@ -786,7 +790,7 @@ __nested_rspack_require_364__.add({
|
|
|
786
790
|
*/ module.exports = onFinished;
|
|
787
791
|
module.exports.isFinished = isFinished;
|
|
788
792
|
var asyncHooks = tryRequireAsyncHooks();
|
|
789
|
-
var first =
|
|
793
|
+
var first = __nested_rspack_require_32097_32116__("./node_modules/.pnpm/ee-first@1.1.1/node_modules/ee-first/index.js");
|
|
790
794
|
var defer = 'function' == typeof setImmediate ? setImmediate : function(fn) {
|
|
791
795
|
process.nextTick(fn.bind.apply(fn, arguments));
|
|
792
796
|
};
|
|
@@ -865,7 +869,7 @@ __nested_rspack_require_364__.add({
|
|
|
865
869
|
}
|
|
866
870
|
function tryRequireAsyncHooks() {
|
|
867
871
|
try {
|
|
868
|
-
return
|
|
872
|
+
return __nested_rspack_require_32097_32116__("async_hooks");
|
|
869
873
|
} catch (e) {
|
|
870
874
|
return {};
|
|
871
875
|
}
|
|
@@ -877,13 +881,13 @@ __nested_rspack_require_364__.add({
|
|
|
877
881
|
return res.runInAsyncScope.bind(res, fn, null);
|
|
878
882
|
}
|
|
879
883
|
},
|
|
880
|
-
"./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_36017_36036__) {
|
|
881
885
|
/*!
|
|
882
886
|
* parseurl
|
|
883
887
|
* Copyright(c) 2014 Jonathan Ong
|
|
884
888
|
* Copyright(c) 2014-2017 Douglas Christopher Wilson
|
|
885
889
|
* MIT Licensed
|
|
886
|
-
*/ var url =
|
|
890
|
+
*/ var url = __nested_rspack_require_36017_36036__("url");
|
|
887
891
|
var parse = url.parse;
|
|
888
892
|
var Url = url.Url;
|
|
889
893
|
module.exports = parseurl;
|
|
@@ -943,13 +947,13 @@ __nested_rspack_require_364__.add({
|
|
|
943
947
|
return 'object' == typeof parsedUrl && null !== parsedUrl && (void 0 === Url || parsedUrl instanceof Url) && parsedUrl._raw === url;
|
|
944
948
|
}
|
|
945
949
|
},
|
|
946
|
-
"./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_38488_38507__) {
|
|
947
951
|
/*!
|
|
948
952
|
* statuses
|
|
949
953
|
* Copyright(c) 2014 Jonathan Ong
|
|
950
954
|
* Copyright(c) 2016 Douglas Christopher Wilson
|
|
951
955
|
* MIT Licensed
|
|
952
|
-
*/ var codes =
|
|
956
|
+
*/ var codes = __nested_rspack_require_38488_38507__("./node_modules/.pnpm/statuses@2.0.2/node_modules/statuses/codes.json");
|
|
953
957
|
module.exports = status;
|
|
954
958
|
status.message = codes;
|
|
955
959
|
status.code = createMessageToStatusCodeMap(codes);
|
|
@@ -1004,10 +1008,10 @@ __nested_rspack_require_364__.add({
|
|
|
1004
1008
|
return getStatusCode(code);
|
|
1005
1009
|
}
|
|
1006
1010
|
},
|
|
1007
|
-
"./node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js" (module, __unused_rspack_exports,
|
|
1008
|
-
const os =
|
|
1009
|
-
const tty =
|
|
1010
|
-
const hasFlag =
|
|
1011
|
+
"./node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js" (module, __unused_rspack_exports, __nested_rspack_require_40780_40799__) {
|
|
1012
|
+
const os = __nested_rspack_require_40780_40799__("os");
|
|
1013
|
+
const tty = __nested_rspack_require_40780_40799__("tty");
|
|
1014
|
+
const hasFlag = __nested_rspack_require_40780_40799__("./node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js");
|
|
1011
1015
|
const { env } = process;
|
|
1012
1016
|
let flagForceColor;
|
|
1013
1017
|
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) flagForceColor = 0;
|
|
@@ -1106,7 +1110,7 @@ __nested_rspack_require_364__.add({
|
|
|
1106
1110
|
module.exports = __rspack_createRequire_require("util");
|
|
1107
1111
|
},
|
|
1108
1112
|
"./node_modules/.pnpm/statuses@2.0.2/node_modules/statuses/codes.json" (module) {
|
|
1109
|
-
module.exports = JSON.parse('{"100":"Continue","101":"Switching Protocols","102":"Processing","103":"Early Hints","200":"OK","201":"Created","202":"Accepted","203":"Non-Authoritative Information","204":"No Content","205":"Reset Content","206":"Partial Content","207":"Multi-Status","208":"Already Reported","226":"IM Used","300":"Multiple Choices","301":"Moved Permanently","302":"Found","303":"See Other","304":"Not Modified","305":"Use Proxy","307":"Temporary Redirect","308":"Permanent Redirect","400":"Bad Request","401":"Unauthorized","402":"Payment Required","403":"Forbidden","404":"Not Found","405":"Method Not Allowed","406":"Not Acceptable","407":"Proxy Authentication Required","408":"Request Timeout","409":"Conflict","410":"Gone","411":"Length Required","412":"Precondition Failed","413":"Payload Too Large","414":"URI Too Long","415":"Unsupported Media Type","416":"Range Not Satisfiable","417":"Expectation Failed","418":"I\'m a Teapot","421":"Misdirected Request","422":"Unprocessable Entity","423":"Locked","424":"Failed Dependency","425":"Too Early","426":"Upgrade Required","428":"Precondition Required","429":"Too Many Requests","431":"Request Header Fields Too Large","451":"Unavailable For Legal Reasons","500":"Internal Server Error","501":"Not Implemented","502":"Bad Gateway","503":"Service Unavailable","504":"Gateway Timeout","505":"HTTP Version Not Supported","506":"Variant Also Negotiates","507":"Insufficient Storage","508":"Loop Detected","509":"Bandwidth Limit Exceeded","510":"Not Extended","511":"Network Authentication Required"}');
|
|
1113
|
+
module.exports = /*#__PURE__*/ JSON.parse('{"100":"Continue","101":"Switching Protocols","102":"Processing","103":"Early Hints","200":"OK","201":"Created","202":"Accepted","203":"Non-Authoritative Information","204":"No Content","205":"Reset Content","206":"Partial Content","207":"Multi-Status","208":"Already Reported","226":"IM Used","300":"Multiple Choices","301":"Moved Permanently","302":"Found","303":"See Other","304":"Not Modified","305":"Use Proxy","307":"Temporary Redirect","308":"Permanent Redirect","400":"Bad Request","401":"Unauthorized","402":"Payment Required","403":"Forbidden","404":"Not Found","405":"Method Not Allowed","406":"Not Acceptable","407":"Proxy Authentication Required","408":"Request Timeout","409":"Conflict","410":"Gone","411":"Length Required","412":"Precondition Failed","413":"Payload Too Large","414":"URI Too Long","415":"Unsupported Media Type","416":"Range Not Satisfiable","417":"Expectation Failed","418":"I\'m a Teapot","421":"Misdirected Request","422":"Unprocessable Entity","423":"Locked","424":"Failed Dependency","425":"Too Early","426":"Upgrade Required","428":"Precondition Required","429":"Too Many Requests","431":"Request Header Fields Too Large","451":"Unavailable For Legal Reasons","500":"Internal Server Error","501":"Not Implemented","502":"Bad Gateway","503":"Service Unavailable","504":"Gateway Timeout","505":"HTTP Version Not Supported","506":"Variant Also Negotiates","507":"Insufficient Storage","508":"Loop Detected","509":"Bandwidth Limit Exceeded","510":"Not Extended","511":"Network Authentication Required"}');
|
|
1110
1114
|
}
|
|
1111
1115
|
});
|
|
1112
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");
|
package/dist/0~debug.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __webpack_require__ } from "./
|
|
2
|
-
import "./
|
|
1
|
+
import { __webpack_require__ } from "./944.js";
|
|
2
|
+
import "./944.js";
|
|
3
3
|
__webpack_require__.add({
|
|
4
4
|
"./node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js" (module, exports, __webpack_require__) {
|
|
5
5
|
exports.formatArgs = formatArgs;
|
|
@@ -9,9 +9,9 @@ import { URL as external_node_url_URL } from "node:url";
|
|
|
9
9
|
import { URL as external_url_URL } from "url";
|
|
10
10
|
import "node:zlib";
|
|
11
11
|
import "node:querystring";
|
|
12
|
-
import { __webpack_require__ } from "./
|
|
12
|
+
import { __webpack_require__ } from "./944.js";
|
|
13
13
|
import "./0~debug.js";
|
|
14
|
-
import "./
|
|
14
|
+
import "./944.js";
|
|
15
15
|
__webpack_require__.add({
|
|
16
16
|
"./node_modules/.pnpm/braces@3.0.3/node_modules/braces/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
17
17
|
const stringify = __webpack_require__("./node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/stringify.js");
|
|
@@ -2832,6 +2832,10 @@ function setupOutgoing(outgoing, options, req, forward) {
|
|
|
2832
2832
|
const value = options[forward || "target"][e];
|
|
2833
2833
|
if (void 0 !== value) outgoing[e] = value;
|
|
2834
2834
|
}
|
|
2835
|
+
if (void 0 === outgoing.host && "string" == typeof outgoing.hostname) {
|
|
2836
|
+
const bracketedHost = outgoing.hostname.includes(":") && !outgoing.hostname.startsWith("[") ? `[${outgoing.hostname}]` : outgoing.hostname;
|
|
2837
|
+
outgoing.host = outgoing.port ? `${bracketedHost}:${outgoing.port}` : bracketedHost;
|
|
2838
|
+
}
|
|
2835
2839
|
outgoing.method = options.method || req.method;
|
|
2836
2840
|
outgoing.headers = {
|
|
2837
2841
|
...req.headers
|
|
@@ -3349,15 +3353,15 @@ function _createProxyFn(type, server) {
|
|
|
3349
3353
|
for (const pass of server._getPasses(type)){
|
|
3350
3354
|
let stop;
|
|
3351
3355
|
try {
|
|
3352
|
-
stop = pass(req, res, requestOptions, server, head, (error)=>{
|
|
3356
|
+
stop = pass(req, res, requestOptions, server, head, (error, _req, _res, url)=>{
|
|
3353
3357
|
if (server.listenerCount("error") > 0) {
|
|
3354
|
-
server.emit("error", error, req, res);
|
|
3358
|
+
server.emit("error", error, req, res, url);
|
|
3355
3359
|
_resolve();
|
|
3356
3360
|
} else _reject(error);
|
|
3357
3361
|
});
|
|
3358
3362
|
} catch (error) {
|
|
3359
3363
|
if (server.listenerCount("error") > 0) {
|
|
3360
|
-
server.emit("error", error, req, res);
|
|
3364
|
+
server.emit("error", error, req, res, requestOptions.target || requestOptions.forward);
|
|
3361
3365
|
_resolve();
|
|
3362
3366
|
} else _reject(error);
|
|
3363
3367
|
break;
|
|
@@ -3389,8 +3393,11 @@ function verifyConfig(options) {
|
|
|
3389
3393
|
}
|
|
3390
3394
|
const src = __webpack_require__("./node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js");
|
|
3391
3395
|
const Debug = src('http-proxy-middleware');
|
|
3396
|
+
function definePlugin(fn) {
|
|
3397
|
+
return fn;
|
|
3398
|
+
}
|
|
3392
3399
|
const debug = Debug.extend('debug-proxy-errors-plugin');
|
|
3393
|
-
const debugProxyErrorsPlugin = (proxyServer)=>{
|
|
3400
|
+
const debugProxyErrorsPlugin = definePlugin((proxyServer, options)=>{
|
|
3394
3401
|
proxyServer.on('error', (error, req, res, target)=>{
|
|
3395
3402
|
debug(`httpxy error event: \n%O`, error);
|
|
3396
3403
|
});
|
|
@@ -3425,11 +3432,18 @@ const debugProxyErrorsPlugin = (proxyServer)=>{
|
|
|
3425
3432
|
proxyServer.on('econnreset', (error, req, res, target)=>{
|
|
3426
3433
|
debug(`httpxy econnreset event: \n%O`, error);
|
|
3427
3434
|
});
|
|
3428
|
-
};
|
|
3435
|
+
});
|
|
3429
3436
|
function getStatusCode(errorCode) {
|
|
3430
3437
|
let statusCode;
|
|
3431
|
-
if (/HPE_INVALID/.test(errorCode))
|
|
3432
|
-
|
|
3438
|
+
if (/HPE_INVALID/.test(errorCode)) {
|
|
3439
|
+
statusCode = 502;
|
|
3440
|
+
return statusCode;
|
|
3441
|
+
}
|
|
3442
|
+
if (/HPM_ERR_INVALID_MULTIPART_/.test(errorCode)) {
|
|
3443
|
+
statusCode = 400;
|
|
3444
|
+
return statusCode;
|
|
3445
|
+
}
|
|
3446
|
+
switch(errorCode){
|
|
3433
3447
|
case 'ECONNRESET':
|
|
3434
3448
|
case 'ENOTFOUND':
|
|
3435
3449
|
case 'ECONNREFUSED':
|
|
@@ -3451,7 +3465,7 @@ function isResponseLike(obj) {
|
|
|
3451
3465
|
function isSocketLike(obj) {
|
|
3452
3466
|
return obj && 'function' == typeof obj.write && !('writeHead' in obj);
|
|
3453
3467
|
}
|
|
3454
|
-
const errorResponsePlugin = (proxyServer, options)=>{
|
|
3468
|
+
const errorResponsePlugin = definePlugin((proxyServer, options)=>{
|
|
3455
3469
|
proxyServer.on('error', (err, req, res, target)=>{
|
|
3456
3470
|
if (!req || !res) throw err;
|
|
3457
3471
|
if (isResponseLike(res)) {
|
|
@@ -3463,7 +3477,7 @@ const errorResponsePlugin = (proxyServer, options)=>{
|
|
|
3463
3477
|
res.end(`Error occurred while trying to proxy: ${sanitize(host)}${sanitize(req.url)}`);
|
|
3464
3478
|
} else if (isSocketLike(res)) res.destroy();
|
|
3465
3479
|
});
|
|
3466
|
-
};
|
|
3480
|
+
});
|
|
3467
3481
|
const noopLogger = {
|
|
3468
3482
|
info: ()=>{},
|
|
3469
3483
|
warn: ()=>{},
|
|
@@ -3483,7 +3497,7 @@ function createUrl({ protocol, host, port, path }) {
|
|
|
3483
3497
|
function logger_plugin_getPort(sockets) {
|
|
3484
3498
|
return Object.keys(sockets || {})?.[0]?.split(':')[1];
|
|
3485
3499
|
}
|
|
3486
|
-
const loggerPlugin = (proxyServer, options)=>{
|
|
3500
|
+
const loggerPlugin = definePlugin((proxyServer, options)=>{
|
|
3487
3501
|
const logger = getLogger(options);
|
|
3488
3502
|
proxyServer.on('error', (err, req, res, target)=>{
|
|
3489
3503
|
const hostname = req?.headers?.host;
|
|
@@ -3520,12 +3534,12 @@ const loggerPlugin = (proxyServer, options)=>{
|
|
|
3520
3534
|
proxyServer.on('close', (req, proxySocket, proxyHead)=>{
|
|
3521
3535
|
logger.info('[HPM] Client disconnected: %o', proxySocket.address());
|
|
3522
3536
|
});
|
|
3523
|
-
};
|
|
3537
|
+
});
|
|
3524
3538
|
function function_getFunctionName(fn) {
|
|
3525
3539
|
return fn.name || '[anonymous Function]';
|
|
3526
3540
|
}
|
|
3527
3541
|
const proxy_events_debug = Debug.extend('proxy-events-plugin');
|
|
3528
|
-
const proxyEventsPlugin = (proxyServer, options)=>{
|
|
3542
|
+
const proxyEventsPlugin = definePlugin((proxyServer, options)=>{
|
|
3529
3543
|
if (!options.on) return;
|
|
3530
3544
|
let eventName;
|
|
3531
3545
|
for(eventName in options.on)if (Object.prototype.hasOwnProperty.call(options.on, eventName)) {
|
|
@@ -3534,7 +3548,7 @@ const proxyEventsPlugin = (proxyServer, options)=>{
|
|
|
3534
3548
|
proxy_events_debug(`register event handler: "${eventName}" -> "${function_getFunctionName(handler)}"`);
|
|
3535
3549
|
proxyServer.on(eventName, handler);
|
|
3536
3550
|
}
|
|
3537
|
-
};
|
|
3551
|
+
});
|
|
3538
3552
|
function getPlugins(options) {
|
|
3539
3553
|
const maybeErrorResponsePlugin = options.on?.error ? [] : [
|
|
3540
3554
|
errorResponsePlugin
|
|
@@ -3563,7 +3577,7 @@ function matchPathFilter(pathFilter = '/', uri, req) {
|
|
|
3563
3577
|
}
|
|
3564
3578
|
if ('function' == typeof pathFilter) {
|
|
3565
3579
|
const pathname = getUrlPathName(uri);
|
|
3566
|
-
return pathFilter(pathname, req);
|
|
3580
|
+
return Boolean(pathFilter(pathname, req));
|
|
3567
3581
|
}
|
|
3568
3582
|
throw new Error(errors_ERRORS.ERR_CONTEXT_MATCHER_GENERIC);
|
|
3569
3583
|
}
|
|
@@ -3641,20 +3655,26 @@ function parsePathRewriteRules(rewriteConfig) {
|
|
|
3641
3655
|
return rules;
|
|
3642
3656
|
}
|
|
3643
3657
|
const router_debug = Debug.extend('router');
|
|
3644
|
-
async function getTarget(req, config) {
|
|
3658
|
+
async function getTarget(req, res, config) {
|
|
3645
3659
|
let newTarget;
|
|
3646
3660
|
const router = config.router;
|
|
3647
3661
|
if (isPlainObject(router)) newTarget = getTargetFromProxyTable(req, router);
|
|
3648
|
-
else if ('function' == typeof router) newTarget = await router(req);
|
|
3662
|
+
else if ('function' == typeof router) newTarget = await router(req, res, config);
|
|
3649
3663
|
return newTarget;
|
|
3650
3664
|
}
|
|
3651
3665
|
function getTargetFromProxyTable(req, table) {
|
|
3652
3666
|
let result;
|
|
3653
3667
|
const host = req.headers.host ?? '';
|
|
3654
3668
|
const path = req.url ?? '';
|
|
3655
|
-
const hostAndPath = host + path;
|
|
3656
3669
|
for (const [key, value] of Object.entries(table))if (containsPath(key)) {
|
|
3657
|
-
if (
|
|
3670
|
+
if (isHostAndPathKey(key)) {
|
|
3671
|
+
const [keyHost, keyPath] = splitHostAndPathKey(key);
|
|
3672
|
+
if (host === keyHost && path.startsWith(keyPath)) {
|
|
3673
|
+
result = value;
|
|
3674
|
+
router_debug('match: "%s" -> "%s"', key, result);
|
|
3675
|
+
break;
|
|
3676
|
+
}
|
|
3677
|
+
} else if (path.startsWith(key)) {
|
|
3658
3678
|
result = value;
|
|
3659
3679
|
router_debug('match: "%s" -> "%s"', key, result);
|
|
3660
3680
|
break;
|
|
@@ -3669,6 +3689,16 @@ function getTargetFromProxyTable(req, table) {
|
|
|
3669
3689
|
function containsPath(v) {
|
|
3670
3690
|
return v.indexOf('/') > -1;
|
|
3671
3691
|
}
|
|
3692
|
+
function isHostAndPathKey(v) {
|
|
3693
|
+
return containsPath(v) && !v.startsWith('/');
|
|
3694
|
+
}
|
|
3695
|
+
function splitHostAndPathKey(v) {
|
|
3696
|
+
const firstSlash = v.indexOf('/');
|
|
3697
|
+
return [
|
|
3698
|
+
v.slice(0, firstSlash),
|
|
3699
|
+
v.slice(firstSlash)
|
|
3700
|
+
];
|
|
3701
|
+
}
|
|
3672
3702
|
const ipv6_debug = Debug.extend('ipv6');
|
|
3673
3703
|
function normalizeIPv6LiteralTargets(options) {
|
|
3674
3704
|
options.target = normalizeIPv6ProxyTarget(options.target, 'target');
|
|
@@ -3677,9 +3707,12 @@ function normalizeIPv6LiteralTargets(options) {
|
|
|
3677
3707
|
function normalizeIPv6ProxyTarget(target, optionName) {
|
|
3678
3708
|
const targetUrl = toTargetUrl(target);
|
|
3679
3709
|
if (targetUrl && isBracketedIPv6Hostname(targetUrl.hostname)) {
|
|
3710
|
+
const normalizedHostname = normalizeIPv6DestinationHostname(stripBrackets(targetUrl.hostname));
|
|
3680
3711
|
ipv6_debug('normalized IPv6 "%s" %s', optionName, target);
|
|
3712
|
+
const auth = targetUrl.username || targetUrl.password ? `${targetUrl.username}:${targetUrl.password}` : void 0;
|
|
3681
3713
|
return {
|
|
3682
|
-
hostname:
|
|
3714
|
+
hostname: normalizedHostname,
|
|
3715
|
+
auth,
|
|
3683
3716
|
pathname: targetUrl.pathname,
|
|
3684
3717
|
port: targetUrl.port,
|
|
3685
3718
|
protocol: targetUrl.protocol,
|
|
@@ -3698,9 +3731,16 @@ function isBracketedIPv6Hostname(hostname) {
|
|
|
3698
3731
|
function stripBrackets(hostname) {
|
|
3699
3732
|
return hostname.replace(/^\[|\]$/g, '');
|
|
3700
3733
|
}
|
|
3734
|
+
function normalizeIPv6DestinationHostname(hostname) {
|
|
3735
|
+
if ('::' === hostname) {
|
|
3736
|
+
ipv6_debug('normalizing hostname unspecified IPv6 address (::) to loopback (::1)');
|
|
3737
|
+
return '::1';
|
|
3738
|
+
}
|
|
3739
|
+
return hostname;
|
|
3740
|
+
}
|
|
3701
3741
|
class HttpProxyMiddleware {
|
|
3702
|
-
|
|
3703
|
-
|
|
3742
|
+
wsInternalSubscribedServers = new WeakSet();
|
|
3743
|
+
activeServers = new Set();
|
|
3704
3744
|
proxyOptions;
|
|
3705
3745
|
proxy;
|
|
3706
3746
|
pathRewriter;
|
|
@@ -3714,14 +3754,18 @@ class HttpProxyMiddleware {
|
|
|
3714
3754
|
this.registerPlugins(this.proxy, this.proxyOptions);
|
|
3715
3755
|
this.pathRewriter = createPathRewriter(this.proxyOptions.pathRewrite);
|
|
3716
3756
|
this.middleware.upgrade = (req, socket, head)=>{
|
|
3717
|
-
|
|
3757
|
+
const server = this.#getServer(req);
|
|
3758
|
+
if (server && !this.wsInternalSubscribedServers.has(server)) this.handleUpgrade(req, socket, head);
|
|
3718
3759
|
};
|
|
3719
3760
|
}
|
|
3761
|
+
#getServer(req) {
|
|
3762
|
+
return req.socket?.server;
|
|
3763
|
+
}
|
|
3720
3764
|
middleware = async (req, res, next)=>{
|
|
3721
3765
|
if (this.shouldProxy(this.proxyOptions.pathFilter, req)) {
|
|
3722
3766
|
let activeProxyOptions;
|
|
3723
3767
|
try {
|
|
3724
|
-
activeProxyOptions = await this.prepareProxyRequest(req);
|
|
3768
|
+
activeProxyOptions = await this.prepareProxyRequest(req, res);
|
|
3725
3769
|
if (!activeProxyOptions.target && !activeProxyOptions.forward) throw new Error('Must provide a proper URL as target');
|
|
3726
3770
|
} catch (err) {
|
|
3727
3771
|
next?.(err);
|
|
@@ -3735,15 +3779,17 @@ class HttpProxyMiddleware {
|
|
|
3735
3779
|
next?.(err);
|
|
3736
3780
|
}
|
|
3737
3781
|
} else next?.();
|
|
3738
|
-
const server = req
|
|
3739
|
-
if (server && !this.
|
|
3782
|
+
const server = this.#getServer(req);
|
|
3783
|
+
if (server && !this.activeServers.has(server)) {
|
|
3784
|
+
Debug('registering server close listener');
|
|
3785
|
+
this.activeServers.add(server);
|
|
3740
3786
|
server.on('close', ()=>{
|
|
3741
|
-
Debug('server close signal received
|
|
3742
|
-
this.
|
|
3743
|
-
|
|
3744
|
-
|
|
3787
|
+
Debug('server close signal received.');
|
|
3788
|
+
this.activeServers.delete(server);
|
|
3789
|
+
if (this.activeServers.size > 0) return void Debug(`proxy server not closed: ${this.activeServers.size} server(s) still active`);
|
|
3790
|
+
Debug('closing proxy server');
|
|
3791
|
+
this.proxy.close(()=>Debug('proxy server closed'));
|
|
3745
3792
|
});
|
|
3746
|
-
this.serverOnCloseSubscribed = true;
|
|
3747
3793
|
}
|
|
3748
3794
|
if (true === this.proxyOptions.ws && server) this.catchUpgradeRequest(server);
|
|
3749
3795
|
};
|
|
@@ -3755,18 +3801,17 @@ class HttpProxyMiddleware {
|
|
|
3755
3801
|
});
|
|
3756
3802
|
}
|
|
3757
3803
|
catchUpgradeRequest = (server)=>{
|
|
3758
|
-
if (!this.
|
|
3804
|
+
if (!this.wsInternalSubscribedServers.has(server)) {
|
|
3759
3805
|
Debug('subscribing to server upgrade event');
|
|
3760
3806
|
server.on('upgrade', this.handleUpgrade);
|
|
3761
|
-
this.
|
|
3807
|
+
this.wsInternalSubscribedServers.add(server);
|
|
3762
3808
|
}
|
|
3763
3809
|
};
|
|
3764
3810
|
handleUpgrade = async (req, socket, head)=>{
|
|
3765
3811
|
try {
|
|
3766
3812
|
if (this.shouldProxy(this.proxyOptions.pathFilter, req)) {
|
|
3767
|
-
const
|
|
3768
|
-
|
|
3769
|
-
await this.proxy.ws(proxiedReq, socket, activeProxyOptions, head);
|
|
3813
|
+
const activeProxyOptions = await this.prepareProxyRequest(req, void 0);
|
|
3814
|
+
await this.proxy.ws(req, socket, activeProxyOptions, head);
|
|
3770
3815
|
Debug('server upgrade event received. Proxying WebSocket');
|
|
3771
3816
|
}
|
|
3772
3817
|
} catch (err) {
|
|
@@ -3782,26 +3827,26 @@ class HttpProxyMiddleware {
|
|
|
3782
3827
|
return false;
|
|
3783
3828
|
}
|
|
3784
3829
|
};
|
|
3785
|
-
prepareProxyRequest = async (req)=>{
|
|
3830
|
+
prepareProxyRequest = async (req, res)=>{
|
|
3786
3831
|
const newProxyOptions = Object.assign({}, this.proxyOptions);
|
|
3787
|
-
await this.applyRouter(req, newProxyOptions);
|
|
3832
|
+
await this.applyRouter(req, res, newProxyOptions);
|
|
3788
3833
|
normalizeIPv6LiteralTargets(newProxyOptions);
|
|
3789
|
-
await this.applyPathRewrite(req, this.pathRewriter);
|
|
3834
|
+
await this.applyPathRewrite(req, res, this.pathRewriter, newProxyOptions);
|
|
3790
3835
|
return newProxyOptions;
|
|
3791
3836
|
};
|
|
3792
|
-
applyRouter = async (req, options)=>{
|
|
3837
|
+
applyRouter = async (req, res, options)=>{
|
|
3793
3838
|
let newTarget;
|
|
3794
3839
|
if (options.router) {
|
|
3795
|
-
newTarget = await getTarget(req, options);
|
|
3840
|
+
newTarget = await getTarget(req, res, options);
|
|
3796
3841
|
if (newTarget) {
|
|
3797
3842
|
Debug('router new target: "%s"', newTarget);
|
|
3798
3843
|
options.target = newTarget;
|
|
3799
3844
|
}
|
|
3800
3845
|
}
|
|
3801
3846
|
};
|
|
3802
|
-
applyPathRewrite = async (req, pathRewriter)=>{
|
|
3847
|
+
applyPathRewrite = async (req, res, pathRewriter, options)=>{
|
|
3803
3848
|
if (req.url && pathRewriter) {
|
|
3804
|
-
const path = await pathRewriter(req.url, req);
|
|
3849
|
+
const path = await pathRewriter(req.url, req, res, options);
|
|
3805
3850
|
if ('string' == typeof path) {
|
|
3806
3851
|
Debug('pathRewrite new path: %s', path);
|
|
3807
3852
|
req.url = path;
|