@umijs/bundler-webpack 4.0.0-canary.20220831.2 → 4.0.0-canary.20220920.1
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/client/client.js +13 -9
- package/compiled/webpack/package.json +1 -5
- package/dist/build.js +3 -19
- package/dist/config/compressPlugin.js +8 -16
- package/dist/config/config.js +8 -20
- package/dist/config/cssRules.js +30 -42
- package/dist/config/definePlugin.js +4 -17
- package/dist/config/detectDeadCodePlugin.js +7 -20
- package/dist/config/javaScriptRules.js +4 -1
- package/dist/config/manifestPlugin.js +4 -17
- package/dist/config/nodePolyfill.js +10 -26
- package/dist/config/svgRules.js +8 -24
- package/dist/dev.d.ts +0 -1
- package/dist/dev.js +4 -20
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/loader/swc.js +8 -35
- package/dist/server/server.js +1 -58
- package/dist/types.d.ts +1 -8
- package/package.json +5 -7
- package/compiled/http-proxy-middleware/LICENSE +0 -22
- package/compiled/http-proxy-middleware/dist/index.d.ts +0 -4
- package/compiled/http-proxy-middleware/dist/types.d.ts +0 -54
- package/compiled/http-proxy-middleware/http-proxy/index.d.ts +0 -226
- package/compiled/http-proxy-middleware/index.js +0 -66
- package/compiled/http-proxy-middleware/package.json +0 -1
package/dist/dev.js
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
7
|
var __export = (target, all) => {
|
|
25
8
|
for (var name in all)
|
|
26
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -97,11 +80,11 @@ async function dev(opts) {
|
|
|
97
80
|
publicPath: opts.config.publicPath
|
|
98
81
|
});
|
|
99
82
|
},
|
|
100
|
-
serverBase: opts.mfsuServerBase,
|
|
101
83
|
startBuildWorker: opts.startBuildWorker
|
|
102
84
|
});
|
|
103
85
|
}
|
|
104
86
|
const webpackConfig = await (0, import_config.getConfig)({
|
|
87
|
+
name: opts.mfsuStrategy === "eager" ? "eager" : void 0,
|
|
105
88
|
cwd: opts.cwd,
|
|
106
89
|
rootDir: opts.rootDir,
|
|
107
90
|
env: import_types.Env.development,
|
|
@@ -123,9 +106,10 @@ async function dev(opts) {
|
|
|
123
106
|
modifyWebpackConfig: opts.modifyWebpackConfig,
|
|
124
107
|
hmr: process.env.HMR !== "none",
|
|
125
108
|
analyze: process.env.ANALYZE,
|
|
126
|
-
cache: opts.cache ?
|
|
109
|
+
cache: opts.cache ? {
|
|
110
|
+
...opts.cache,
|
|
127
111
|
cacheDirectory: (0, import_path.join)(cacheDirectoryPath, "bundler-webpack")
|
|
128
|
-
}
|
|
112
|
+
} : void 0,
|
|
129
113
|
pkg: opts.pkg
|
|
130
114
|
});
|
|
131
115
|
const depConfig = await (0, import_config.getConfig)({
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -21,3 +21,4 @@ __reExport(src_exports, require("./build"), module.exports);
|
|
|
21
21
|
__reExport(src_exports, require("./config/config"), module.exports);
|
|
22
22
|
__reExport(src_exports, require("./dev"), module.exports);
|
|
23
23
|
__reExport(src_exports, require("./schema"), module.exports);
|
|
24
|
+
__reExport(src_exports, require("./constants"), module.exports);
|
package/dist/loader/swc.js
CHANGED
|
@@ -1,36 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
-
var __objRest = (source, exclude) => {
|
|
23
|
-
var target = {};
|
|
24
|
-
for (var prop in source)
|
|
25
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
-
target[prop] = source[prop];
|
|
27
|
-
if (source != null && __getOwnPropSymbols)
|
|
28
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
-
target[prop] = source[prop];
|
|
31
|
-
}
|
|
32
|
-
return target;
|
|
33
|
-
};
|
|
34
5
|
var __export = (target, all) => {
|
|
35
6
|
for (var name in all)
|
|
36
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -86,15 +57,17 @@ function getBaseOpts({ filename }) {
|
|
|
86
57
|
function swcLoader(contents) {
|
|
87
58
|
const callback = this.async();
|
|
88
59
|
const loaderOpts = this.getOptions();
|
|
89
|
-
const
|
|
60
|
+
const { sync = false, parseMap = false, ...otherOpts } = loaderOpts;
|
|
90
61
|
const filename = this.resourcePath;
|
|
91
|
-
const swcOpts =
|
|
92
|
-
|
|
93
|
-
|
|
62
|
+
const swcOpts = {
|
|
63
|
+
...getBaseOpts({
|
|
64
|
+
filename
|
|
65
|
+
}),
|
|
94
66
|
filename,
|
|
95
67
|
sourceMaps: this.sourceMap,
|
|
96
|
-
sourceFileName: filename
|
|
97
|
-
|
|
68
|
+
sourceFileName: filename,
|
|
69
|
+
...otherOpts
|
|
70
|
+
};
|
|
98
71
|
try {
|
|
99
72
|
if (sync) {
|
|
100
73
|
const output = (0, import_core.transformSync)(contents, swcOpts);
|
package/dist/server/server.js
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
7
|
var __export = (target, all) => {
|
|
25
8
|
for (var name in all)
|
|
26
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -44,10 +27,8 @@ __export(server_exports, {
|
|
|
44
27
|
module.exports = __toCommonJS(server_exports);
|
|
45
28
|
var import_bundler_utils = require("@umijs/bundler-utils");
|
|
46
29
|
var import_express = __toESM(require("@umijs/bundler-utils/compiled/express"));
|
|
47
|
-
var import_http_proxy_middleware = require("@umijs/bundler-webpack/compiled/http-proxy-middleware");
|
|
48
30
|
var import_webpack = __toESM(require("@umijs/bundler-webpack/compiled/webpack"));
|
|
49
31
|
var import_utils = require("@umijs/utils");
|
|
50
|
-
var import_assert = __toESM(require("assert"));
|
|
51
32
|
var import_cors = __toESM(require("cors"));
|
|
52
33
|
var import_fs = require("fs");
|
|
53
34
|
var import_http = __toESM(require("http"));
|
|
@@ -153,45 +134,7 @@ async function createServer(opts) {
|
|
|
153
134
|
(_a = sender || ws) == null ? void 0 : _a.send(JSON.stringify({ type, data }));
|
|
154
135
|
}
|
|
155
136
|
if (proxy) {
|
|
156
|
-
|
|
157
|
-
return __spreadProps(__spreadValues({}, proxy[key]), {
|
|
158
|
-
context: key
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
proxyArr.forEach((proxy2) => {
|
|
162
|
-
let middleware;
|
|
163
|
-
if (proxy2.target) {
|
|
164
|
-
(0, import_assert.default)(typeof proxy2.target === "string", "proxy.target must be string");
|
|
165
|
-
(0, import_assert.default)(proxy2.context, "proxy.context must be supplied");
|
|
166
|
-
middleware = (0, import_http_proxy_middleware.createProxyMiddleware)(proxy2.context, __spreadProps(__spreadValues({}, proxy2), {
|
|
167
|
-
onProxyReq(proxyReq, req, res) {
|
|
168
|
-
var _a, _b;
|
|
169
|
-
if (proxyReq.getHeader("origin")) {
|
|
170
|
-
proxyReq.setHeader("origin", ((_a = new URL(proxy2.target)) == null ? void 0 : _a.href) || "");
|
|
171
|
-
}
|
|
172
|
-
(_b = proxy2.onProxyReq) == null ? void 0 : _b.call(proxy2, proxyReq, req, res, proxy2);
|
|
173
|
-
},
|
|
174
|
-
onProxyRes(proxyRes, req, res) {
|
|
175
|
-
var _a, _b;
|
|
176
|
-
proxyRes.headers["x-real-url"] = ((_a = new URL(req.url || "", proxy2.target)) == null ? void 0 : _a.href) || "";
|
|
177
|
-
(_b = proxy2.onProxyRes) == null ? void 0 : _b.call(proxy2, proxyRes, req, res);
|
|
178
|
-
}
|
|
179
|
-
}));
|
|
180
|
-
}
|
|
181
|
-
app.use((req, res, next) => {
|
|
182
|
-
const bypassUrl = typeof proxy2.bypass === "function" ? proxy2.bypass(req, res, proxy2) : null;
|
|
183
|
-
if (typeof bypassUrl === "string") {
|
|
184
|
-
req.url = bypassUrl;
|
|
185
|
-
return next();
|
|
186
|
-
} else if (bypassUrl === false) {
|
|
187
|
-
return res.end(404);
|
|
188
|
-
} else if ((bypassUrl === null || bypassUrl === void 0) && middleware) {
|
|
189
|
-
return middleware(req, res, next);
|
|
190
|
-
} else {
|
|
191
|
-
next();
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
});
|
|
137
|
+
(0, import_bundler_utils.createProxy)(proxy, app);
|
|
195
138
|
}
|
|
196
139
|
(opts.afterMiddlewares || []).forEach((m) => {
|
|
197
140
|
app.use(m.toString().includes(`{ compiler }`) ? m({ compiler }) : m);
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Config as SwcConfig } from '@swc/core';
|
|
2
|
-
import type { HttpsServerOptions } from '@umijs/bundler-utils';
|
|
3
|
-
import type { Options as HPMOptions } from '../compiled/http-proxy-middleware';
|
|
2
|
+
import type { HttpsServerOptions, ProxyOptions } from '@umijs/bundler-utils';
|
|
4
3
|
import { Configuration } from '../compiled/webpack';
|
|
5
4
|
import Config from '../compiled/webpack-5-chain';
|
|
6
5
|
export declare enum Env {
|
|
@@ -44,12 +43,6 @@ export interface DeadCodeParams {
|
|
|
44
43
|
detectUnusedExport?: boolean;
|
|
45
44
|
context?: string;
|
|
46
45
|
}
|
|
47
|
-
declare type HPMFnArgs = Parameters<NonNullable<HPMOptions['onProxyReq']>>;
|
|
48
|
-
export interface ProxyOptions extends HPMOptions {
|
|
49
|
-
target?: string;
|
|
50
|
-
context?: string | string[];
|
|
51
|
-
bypass?: (...args: [HPMFnArgs[1], HPMFnArgs[2], HPMFnArgs[3]]) => string | boolean | null | void;
|
|
52
|
-
}
|
|
53
46
|
export interface IConfig {
|
|
54
47
|
alias?: Record<string, string>;
|
|
55
48
|
autoCSSModules?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-webpack",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.20220920.1",
|
|
4
4
|
"description": "@umijs/bundler-webpack",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/bundler-webpack#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"@svgr/plugin-jsx": "^6.2.1",
|
|
35
35
|
"@svgr/plugin-svgo": "^6.2.0",
|
|
36
36
|
"@types/hapi__joi": "17.1.8",
|
|
37
|
-
"@umijs/babel-preset-umi": "4.0.0-canary.
|
|
38
|
-
"@umijs/bundler-utils": "4.0.0-canary.
|
|
37
|
+
"@umijs/babel-preset-umi": "4.0.0-canary.20220920.1",
|
|
38
|
+
"@umijs/bundler-utils": "4.0.0-canary.20220920.1",
|
|
39
39
|
"@umijs/case-sensitive-paths-webpack-plugin": "^1.0.1",
|
|
40
|
-
"@umijs/mfsu": "4.0.0-canary.
|
|
41
|
-
"@umijs/utils": "4.0.0-canary.
|
|
40
|
+
"@umijs/mfsu": "4.0.0-canary.20220920.1",
|
|
41
|
+
"@umijs/utils": "4.0.0-canary.20220920.1",
|
|
42
42
|
"cors": "^2.8.5",
|
|
43
43
|
"css-loader": "6.7.1",
|
|
44
44
|
"es5-imcompatible-versions": "^0.1.73",
|
|
@@ -62,7 +62,6 @@
|
|
|
62
62
|
"copy-webpack-plugin": "10.2.4",
|
|
63
63
|
"css-minimizer-webpack-plugin": "4.0.0",
|
|
64
64
|
"cssnano": "5.1.7",
|
|
65
|
-
"http-proxy-middleware": "2.0.4",
|
|
66
65
|
"less-loader": "10.2.0",
|
|
67
66
|
"mini-css-extract-plugin": "2.6.0",
|
|
68
67
|
"postcss-flexbugs-fixes": "5.0.2",
|
|
@@ -100,7 +99,6 @@
|
|
|
100
99
|
"cssnano",
|
|
101
100
|
"compression",
|
|
102
101
|
"connect-history-api-fallback",
|
|
103
|
-
"http-proxy-middleware",
|
|
104
102
|
"less-loader",
|
|
105
103
|
"mini-css-extract-plugin",
|
|
106
104
|
"postcss-flexbugs-fixes",
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2015 Steven Chim
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
22
|
-
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Based on definition by DefinitelyTyped:
|
|
3
|
-
* https://github.com/DefinitelyTyped/DefinitelyTyped/blob/6f529c6c67a447190f86bfbf894d1061e41e07b7/types/http-proxy-middleware/index.d.ts
|
|
4
|
-
*/
|
|
5
|
-
/// <reference types="node" />
|
|
6
|
-
import type * as express from '../../express';
|
|
7
|
-
import type * as http from 'http';
|
|
8
|
-
import type * as httpProxy from '../http-proxy';
|
|
9
|
-
import type * as net from 'net';
|
|
10
|
-
import type * as url from 'url';
|
|
11
|
-
export interface Request extends express.Request {
|
|
12
|
-
}
|
|
13
|
-
export interface Response extends express.Response {
|
|
14
|
-
}
|
|
15
|
-
export interface RequestHandler extends express.RequestHandler {
|
|
16
|
-
upgrade?: (req: Request, socket: net.Socket, head: any) => void;
|
|
17
|
-
}
|
|
18
|
-
export declare type Filter = string | string[] | ((pathname: string, req: Request) => boolean);
|
|
19
|
-
export interface Options extends httpProxy.ServerOptions {
|
|
20
|
-
pathRewrite?: {
|
|
21
|
-
[regexp: string]: string;
|
|
22
|
-
} | ((path: string, req: Request) => string) | ((path: string, req: Request) => Promise<string>);
|
|
23
|
-
router?: {
|
|
24
|
-
[hostOrPath: string]: httpProxy.ServerOptions['target'];
|
|
25
|
-
} | ((req: Request) => httpProxy.ServerOptions['target']) | ((req: Request) => Promise<httpProxy.ServerOptions['target']>);
|
|
26
|
-
logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
27
|
-
logProvider?: LogProviderCallback;
|
|
28
|
-
onError?: OnErrorCallback;
|
|
29
|
-
onProxyRes?: OnProxyResCallback;
|
|
30
|
-
onProxyReq?: OnProxyReqCallback;
|
|
31
|
-
onProxyReqWs?: OnProxyReqWsCallback;
|
|
32
|
-
onOpen?: OnOpenCallback;
|
|
33
|
-
onClose?: OnCloseCallback;
|
|
34
|
-
}
|
|
35
|
-
interface LogProvider {
|
|
36
|
-
log: Logger;
|
|
37
|
-
debug?: Logger;
|
|
38
|
-
info?: Logger;
|
|
39
|
-
warn?: Logger;
|
|
40
|
-
error?: Logger;
|
|
41
|
-
}
|
|
42
|
-
declare type Logger = (...args: any[]) => void;
|
|
43
|
-
export declare type LogProviderCallback = (provider: LogProvider) => LogProvider;
|
|
44
|
-
/**
|
|
45
|
-
* Use types based on the events listeners from http-proxy
|
|
46
|
-
* https://github.com/DefinitelyTyped/DefinitelyTyped/blob/51504fd999031b7f025220fab279f1b2155cbaff/types/http-proxy/index.d.ts
|
|
47
|
-
*/
|
|
48
|
-
export declare type OnErrorCallback = (err: Error, req: Request, res: Response, target?: string | Partial<url.Url>) => void;
|
|
49
|
-
export declare type OnProxyResCallback = (proxyRes: http.IncomingMessage, req: Request, res: Response) => void;
|
|
50
|
-
export declare type OnProxyReqCallback = (proxyReq: http.ClientRequest, req: Request, res: Response, options: httpProxy.ServerOptions) => void;
|
|
51
|
-
export declare type OnProxyReqWsCallback = (proxyReq: http.ClientRequest, req: Request, socket: net.Socket, options: httpProxy.ServerOptions, head: any) => void;
|
|
52
|
-
export declare type OnCloseCallback = (proxyRes: Response, proxySocket: net.Socket, proxyHead: any) => void;
|
|
53
|
-
export declare type OnOpenCallback = (proxySocket: net.Socket) => void;
|
|
54
|
-
export {};
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
// Type definitions for node-http-proxy 1.17
|
|
2
|
-
// Project: https://github.com/nodejitsu/node-http-proxy
|
|
3
|
-
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>
|
|
4
|
-
// Florian Oellerich <https://github.com/Raigen>
|
|
5
|
-
// Daniel Schmidt <https://github.com/DanielMSchmidt>
|
|
6
|
-
// Jordan Abreu <https://github.com/jabreu610>
|
|
7
|
-
// Samuel Bodin <https://github.com/bodinsamuel>
|
|
8
|
-
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
9
|
-
// TypeScript Version: 2.1
|
|
10
|
-
|
|
11
|
-
/// <reference types="node" />
|
|
12
|
-
|
|
13
|
-
import * as net from 'net';
|
|
14
|
-
import * as http from 'http';
|
|
15
|
-
import * as https from 'https';
|
|
16
|
-
import * as events from 'events';
|
|
17
|
-
import * as url from 'url';
|
|
18
|
-
import * as stream from 'stream';
|
|
19
|
-
|
|
20
|
-
interface ProxyTargetDetailed {
|
|
21
|
-
host: string;
|
|
22
|
-
port: number;
|
|
23
|
-
protocol?: string | undefined;
|
|
24
|
-
hostname?: string | undefined;
|
|
25
|
-
socketPath?: string | undefined;
|
|
26
|
-
key?: string | undefined;
|
|
27
|
-
passphrase?: string | undefined;
|
|
28
|
-
pfx?: Buffer | string | undefined;
|
|
29
|
-
cert?: string | undefined;
|
|
30
|
-
ca?: string | undefined;
|
|
31
|
-
ciphers?: string | undefined;
|
|
32
|
-
secureProtocol?: string | undefined;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
declare class Server extends events.EventEmitter {
|
|
36
|
-
/**
|
|
37
|
-
* Creates the proxy server with specified options.
|
|
38
|
-
* @param options - Config object passed to the proxy
|
|
39
|
-
*/
|
|
40
|
-
constructor(options?: Server.ServerOptions);
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Used for proxying regular HTTP(S) requests
|
|
44
|
-
* @param req - Client request.
|
|
45
|
-
* @param res - Client response.
|
|
46
|
-
* @param options - Additionnal options.
|
|
47
|
-
*/
|
|
48
|
-
web(
|
|
49
|
-
req: http.IncomingMessage,
|
|
50
|
-
res: http.ServerResponse,
|
|
51
|
-
options?: Server.ServerOptions,
|
|
52
|
-
callback?: Server.ErrorCallback,
|
|
53
|
-
): void;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Used for proxying regular HTTP(S) requests
|
|
57
|
-
* @param req - Client request.
|
|
58
|
-
* @param socket - Client socket.
|
|
59
|
-
* @param head - Client head.
|
|
60
|
-
* @param options - Additionnal options.
|
|
61
|
-
*/
|
|
62
|
-
ws(
|
|
63
|
-
req: http.IncomingMessage,
|
|
64
|
-
socket: any,
|
|
65
|
-
head: any,
|
|
66
|
-
options?: Server.ServerOptions,
|
|
67
|
-
callback?: Server.ErrorCallback,
|
|
68
|
-
): void;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* A function that wraps the object in a webserver, for your convenience
|
|
72
|
-
* @param port - Port to listen on
|
|
73
|
-
*/
|
|
74
|
-
listen(port: number): Server;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* A function that closes the inner webserver and stops listening on given port
|
|
78
|
-
*/
|
|
79
|
-
close(callback?: () => void): void;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Creates the proxy server with specified options.
|
|
83
|
-
* @param options Config object passed to the proxy
|
|
84
|
-
* @returns Proxy object with handlers for `ws` and `web` requests
|
|
85
|
-
*/
|
|
86
|
-
static createProxyServer(options?: Server.ServerOptions): Server;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Creates the proxy server with specified options.
|
|
90
|
-
* @param options Config object passed to the proxy
|
|
91
|
-
* @returns Proxy object with handlers for `ws` and `web` requests
|
|
92
|
-
*/
|
|
93
|
-
static createServer(options?: Server.ServerOptions): Server;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Creates the proxy server with specified options.
|
|
97
|
-
* @param options Config object passed to the proxy
|
|
98
|
-
* @returns Proxy object with handlers for `ws` and `web` requests
|
|
99
|
-
*/
|
|
100
|
-
static createProxy(options?: Server.ServerOptions): Server;
|
|
101
|
-
|
|
102
|
-
addListener(event: string, listener: () => void): this;
|
|
103
|
-
on(event: string, listener: () => void): this;
|
|
104
|
-
on(event: "error", listener: Server.ErrorCallback): this;
|
|
105
|
-
on(event: "start", listener: Server.StartCallback): this;
|
|
106
|
-
on(event: "proxyReq", listener: Server.ProxyReqCallback): this;
|
|
107
|
-
on(event: "proxyRes", listener: Server.ProxyResCallback): this;
|
|
108
|
-
on(event: "proxyReqWs", listener: Server.ProxyReqWsCallback): this;
|
|
109
|
-
on(event: "econnreset", listener: Server.EconnresetCallback): this;
|
|
110
|
-
on(event: "end", listener: Server.EndCallback): this;
|
|
111
|
-
on(event: "open", listener: Server.OpenCallback): this;
|
|
112
|
-
on(event: "close", listener: Server.CloseCallback): this;
|
|
113
|
-
|
|
114
|
-
once(event: string, listener: () => void): this;
|
|
115
|
-
once(event: "error", listener: Server.ErrorCallback): this;
|
|
116
|
-
once(event: "start", listener: Server.StartCallback): this;
|
|
117
|
-
once(event: "proxyReq", listener: Server.ProxyReqCallback): this;
|
|
118
|
-
once(event: "proxyRes", listener: Server.ProxyResCallback): this;
|
|
119
|
-
once(event: "proxyReqWs", listener: Server.ProxyReqWsCallback): this;
|
|
120
|
-
once(event: "econnreset", listener: Server.EconnresetCallback): this;
|
|
121
|
-
once(event: "end", listener: Server.EndCallback): this;
|
|
122
|
-
once(event: "open", listener: Server.OpenCallback): this;
|
|
123
|
-
once(event: "close", listener: Server.CloseCallback): this;
|
|
124
|
-
removeListener(event: string, listener: () => void): this;
|
|
125
|
-
removeAllListeners(event?: string): this;
|
|
126
|
-
getMaxListeners(): number;
|
|
127
|
-
setMaxListeners(n: number): this;
|
|
128
|
-
listeners(event: string): Array<() => void>;
|
|
129
|
-
emit(event: string, ...args: any[]): boolean;
|
|
130
|
-
listenerCount(type: string): number;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
declare namespace Server {
|
|
134
|
-
type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed;
|
|
135
|
-
type ProxyTargetUrl = string | Partial<url.Url>;
|
|
136
|
-
|
|
137
|
-
interface ServerOptions {
|
|
138
|
-
/** URL string to be parsed with the url module. */
|
|
139
|
-
target?: ProxyTarget | undefined;
|
|
140
|
-
/** URL string to be parsed with the url module. */
|
|
141
|
-
forward?: ProxyTargetUrl | undefined;
|
|
142
|
-
/** Object to be passed to http(s).request. */
|
|
143
|
-
agent?: any;
|
|
144
|
-
/** Object to be passed to https.createServer(). */
|
|
145
|
-
ssl?: any;
|
|
146
|
-
/** If you want to proxy websockets. */
|
|
147
|
-
ws?: boolean | undefined;
|
|
148
|
-
/** Adds x- forward headers. */
|
|
149
|
-
xfwd?: boolean | undefined;
|
|
150
|
-
/** Verify SSL certificate. */
|
|
151
|
-
secure?: boolean | undefined;
|
|
152
|
-
/** Explicitly specify if we are proxying to another proxy. */
|
|
153
|
-
toProxy?: boolean | undefined;
|
|
154
|
-
/** Specify whether you want to prepend the target's path to the proxy path. */
|
|
155
|
-
prependPath?: boolean | undefined;
|
|
156
|
-
/** Specify whether you want to ignore the proxy path of the incoming request. */
|
|
157
|
-
ignorePath?: boolean | undefined;
|
|
158
|
-
/** Local interface string to bind for outgoing connections. */
|
|
159
|
-
localAddress?: string | undefined;
|
|
160
|
-
/** Changes the origin of the host header to the target URL. */
|
|
161
|
-
changeOrigin?: boolean | undefined;
|
|
162
|
-
/** specify whether you want to keep letter case of response header key */
|
|
163
|
-
preserveHeaderKeyCase?: boolean | undefined;
|
|
164
|
-
/** Basic authentication i.e. 'user:password' to compute an Authorization header. */
|
|
165
|
-
auth?: string | undefined;
|
|
166
|
-
/** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
|
|
167
|
-
hostRewrite?: string | undefined;
|
|
168
|
-
/** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
|
|
169
|
-
autoRewrite?: boolean | undefined;
|
|
170
|
-
/** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
|
|
171
|
-
protocolRewrite?: string | undefined;
|
|
172
|
-
/** rewrites domain of set-cookie headers. */
|
|
173
|
-
cookieDomainRewrite?: false | string | { [oldDomain: string]: string } | undefined;
|
|
174
|
-
/** rewrites path of set-cookie headers. Default: false */
|
|
175
|
-
cookiePathRewrite?: false | string | { [oldPath: string]: string } | undefined;
|
|
176
|
-
/** object with extra headers to be added to target requests. */
|
|
177
|
-
headers?: { [header: string]: string } | undefined;
|
|
178
|
-
/** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
|
|
179
|
-
proxyTimeout?: number | undefined;
|
|
180
|
-
/** Timeout (in milliseconds) for incoming requests */
|
|
181
|
-
timeout?: number | undefined;
|
|
182
|
-
/** Specify whether you want to follow redirects. Default: false */
|
|
183
|
-
followRedirects?: boolean | undefined;
|
|
184
|
-
/** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */
|
|
185
|
-
selfHandleResponse?: boolean | undefined;
|
|
186
|
-
/** Buffer */
|
|
187
|
-
buffer?: stream.Stream | undefined;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
type StartCallback = (req: http.IncomingMessage, res: http.ServerResponse, target: ProxyTargetUrl) => void;
|
|
191
|
-
type ProxyReqCallback = (
|
|
192
|
-
proxyReq: http.ClientRequest,
|
|
193
|
-
req: http.IncomingMessage,
|
|
194
|
-
res: http.ServerResponse,
|
|
195
|
-
options: ServerOptions,
|
|
196
|
-
) => void;
|
|
197
|
-
type ProxyResCallback = (
|
|
198
|
-
proxyRes: http.IncomingMessage,
|
|
199
|
-
req: http.IncomingMessage,
|
|
200
|
-
res: http.ServerResponse,
|
|
201
|
-
) => void;
|
|
202
|
-
type ProxyReqWsCallback = (
|
|
203
|
-
proxyReq: http.ClientRequest,
|
|
204
|
-
req: http.IncomingMessage,
|
|
205
|
-
socket: net.Socket,
|
|
206
|
-
options: ServerOptions,
|
|
207
|
-
head: any,
|
|
208
|
-
) => void;
|
|
209
|
-
type EconnresetCallback = (
|
|
210
|
-
err: Error,
|
|
211
|
-
req: http.IncomingMessage,
|
|
212
|
-
res: http.ServerResponse,
|
|
213
|
-
target: ProxyTargetUrl,
|
|
214
|
-
) => void;
|
|
215
|
-
type EndCallback = (req: http.IncomingMessage, res: http.ServerResponse, proxyRes: http.IncomingMessage) => void;
|
|
216
|
-
type OpenCallback = (proxySocket: net.Socket) => void;
|
|
217
|
-
type CloseCallback = (proxyRes: http.IncomingMessage, proxySocket: net.Socket, proxyHead: any) => void;
|
|
218
|
-
type ErrorCallback = (
|
|
219
|
-
err: Error,
|
|
220
|
-
req: http.IncomingMessage,
|
|
221
|
-
res: http.ServerResponse | net.Socket,
|
|
222
|
-
target?: ProxyTargetUrl,
|
|
223
|
-
) => void;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export = Server;
|