vite 3.1.4 → 3.2.0-beta.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.d.ts +38 -11
- package/dist/client/client.mjs +27 -22
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-42c2c4e4.js → dep-39e6741e.js} +0 -0
- package/dist/node/chunks/{dep-55b95cd5.js → dep-553f6a62.js} +1 -1
- package/dist/node/chunks/{dep-6b3a5aff.js → dep-92763d7a.js} +1072 -655
- package/dist/node/cli.js +5 -5
- package/dist/node/constants.js +1 -1
- package/dist/node/index.d.ts +85 -164
- package/dist/node/index.js +1 -1
- package/dist/node-cjs/publicUtils.cjs +30 -28
- package/package.json +23 -16
- package/src/client/client.ts +4 -3
- package/src/client/overlay.ts +23 -19
- package/src/client/tsconfig.json +1 -1
- package/types/alias.d.ts +6 -59
- package/types/anymatch.d.ts +1 -5
- package/types/chokidar.d.ts +6 -224
- package/types/commonjs.d.ts +1 -230
- package/types/connect.d.ts +1 -111
- package/types/customEvent.d.ts +5 -0
- package/types/dynamicImportVars.d.ts +1 -17
- package/types/http-proxy.d.ts +1 -250
- package/types/importMeta.d.ts +7 -14
- package/types/terser.d.ts +1 -250
- package/types/ws.d.ts +1 -553
- package/types/package.json +0 -3
- package/types/shims.d.ts +0 -96
package/types/commonjs.d.ts
CHANGED
|
@@ -1,230 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* https://github.com/rollup/plugins/blob/master/packages/commonjs/types/index.d.ts
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file at
|
|
6
|
-
* https://github.com/rollup/plugins/blob/master/LICENSE
|
|
7
|
-
*/
|
|
8
|
-
export interface RollupCommonJSOptions {
|
|
9
|
-
/**
|
|
10
|
-
* A minimatch pattern, or array of patterns, which specifies the files in
|
|
11
|
-
* the build the plugin should operate on. By default, all files with
|
|
12
|
-
* extension `".cjs"` or those in `extensions` are included, but you can
|
|
13
|
-
* narrow this list by only including specific files. These files will be
|
|
14
|
-
* analyzed and transpiled if either the analysis does not find ES module
|
|
15
|
-
* specific statements or `transformMixedEsModules` is `true`.
|
|
16
|
-
* @default undefined
|
|
17
|
-
*/
|
|
18
|
-
include?: string | RegExp | readonly (string | RegExp)[]
|
|
19
|
-
/**
|
|
20
|
-
* A minimatch pattern, or array of patterns, which specifies the files in
|
|
21
|
-
* the build the plugin should _ignore_. By default, all files with
|
|
22
|
-
* extensions other than those in `extensions` or `".cjs"` are ignored, but you
|
|
23
|
-
* can exclude additional files. See also the `include` option.
|
|
24
|
-
* @default undefined
|
|
25
|
-
*/
|
|
26
|
-
exclude?: string | RegExp | readonly (string | RegExp)[]
|
|
27
|
-
/**
|
|
28
|
-
* For extensionless imports, search for extensions other than .js in the
|
|
29
|
-
* order specified. Note that you need to make sure that non-JavaScript files
|
|
30
|
-
* are transpiled by another plugin first.
|
|
31
|
-
* @default [ '.js' ]
|
|
32
|
-
*/
|
|
33
|
-
extensions?: ReadonlyArray<string>
|
|
34
|
-
/**
|
|
35
|
-
* If true then uses of `global` won't be dealt with by this plugin
|
|
36
|
-
* @default false
|
|
37
|
-
*/
|
|
38
|
-
ignoreGlobal?: boolean
|
|
39
|
-
/**
|
|
40
|
-
* If false, skips source map generation for CommonJS modules. This will
|
|
41
|
-
* improve performance.
|
|
42
|
-
* @default true
|
|
43
|
-
*/
|
|
44
|
-
sourceMap?: boolean
|
|
45
|
-
/**
|
|
46
|
-
* Some `require` calls cannot be resolved statically to be translated to
|
|
47
|
-
* imports.
|
|
48
|
-
* When this option is set to `false`, the generated code will either
|
|
49
|
-
* directly throw an error when such a call is encountered or, when
|
|
50
|
-
* `dynamicRequireTargets` is used, when such a call cannot be resolved with a
|
|
51
|
-
* configured dynamic require target.
|
|
52
|
-
* Setting this option to `true` will instead leave the `require` call in the
|
|
53
|
-
* code or use it as a fallback for `dynamicRequireTargets`.
|
|
54
|
-
* @default false
|
|
55
|
-
*/
|
|
56
|
-
ignoreDynamicRequires?: boolean
|
|
57
|
-
/**
|
|
58
|
-
* Instructs the plugin whether to enable mixed module transformations. This
|
|
59
|
-
* is useful in scenarios with modules that contain a mix of ES `import`
|
|
60
|
-
* statements and CommonJS `require` expressions. Set to `true` if `require`
|
|
61
|
-
* calls should be transformed to imports in mixed modules, or `false` if the
|
|
62
|
-
* `require` expressions should survive the transformation. The latter can be
|
|
63
|
-
* important if the code contains environment detection, or you are coding
|
|
64
|
-
* for an environment with special treatment for `require` calls such as
|
|
65
|
-
* ElectronJS. See also the `ignore` option.
|
|
66
|
-
* @default false
|
|
67
|
-
*/
|
|
68
|
-
transformMixedEsModules?: boolean
|
|
69
|
-
/**
|
|
70
|
-
* By default, this plugin will try to hoist `require` statements as imports
|
|
71
|
-
* to the top of each file. While this works well for many code bases and
|
|
72
|
-
* allows for very efficient ESM output, it does not perfectly capture
|
|
73
|
-
* CommonJS semantics as the order of side effects like log statements may
|
|
74
|
-
* change. But it is especially problematic when there are circular `require`
|
|
75
|
-
* calls between CommonJS modules as those often rely on the lazy execution of
|
|
76
|
-
* nested `require` calls.
|
|
77
|
-
*
|
|
78
|
-
* Setting this option to `true` will wrap all CommonJS files in functions
|
|
79
|
-
* which are executed when they are required for the first time, preserving
|
|
80
|
-
* NodeJS semantics. Note that this can have an impact on the size and
|
|
81
|
-
* performance of the generated code.
|
|
82
|
-
*
|
|
83
|
-
* The default value of `"auto"` will only wrap CommonJS files when they are
|
|
84
|
-
* part of a CommonJS dependency cycle, e.g. an index file that is required by
|
|
85
|
-
* many of its dependencies. All other CommonJS files are hoisted. This is the
|
|
86
|
-
* recommended setting for most code bases.
|
|
87
|
-
*
|
|
88
|
-
* `false` will entirely prevent wrapping and hoist all files. This may still
|
|
89
|
-
* work depending on the nature of cyclic dependencies but will often cause
|
|
90
|
-
* problems.
|
|
91
|
-
*
|
|
92
|
-
* You can also provide a minimatch pattern, or array of patterns, to only
|
|
93
|
-
* specify a subset of files which should be wrapped in functions for proper
|
|
94
|
-
* `require` semantics.
|
|
95
|
-
*
|
|
96
|
-
* `"debug"` works like `"auto"` but after bundling, it will display a warning
|
|
97
|
-
* containing a list of ids that have been wrapped which can be used as
|
|
98
|
-
* minimatch pattern for fine-tuning.
|
|
99
|
-
* @default "auto"
|
|
100
|
-
*/
|
|
101
|
-
strictRequires?: boolean | string | RegExp | readonly (string | RegExp)[]
|
|
102
|
-
/**
|
|
103
|
-
* Sometimes you have to leave require statements unconverted. Pass an array
|
|
104
|
-
* containing the IDs or a `id => boolean` function.
|
|
105
|
-
* @default []
|
|
106
|
-
*/
|
|
107
|
-
ignore?: ReadonlyArray<string> | ((id: string) => boolean)
|
|
108
|
-
/**
|
|
109
|
-
* In most cases, where `require` calls are inside a `try-catch` clause,
|
|
110
|
-
* they should be left unconverted as it requires an optional dependency
|
|
111
|
-
* that may or may not be installed beside the rolled up package.
|
|
112
|
-
* Due to the conversion of `require` to a static `import` - the call is
|
|
113
|
-
* hoisted to the top of the file, outside of the `try-catch` clause.
|
|
114
|
-
*
|
|
115
|
-
* - `true`: All `require` calls inside a `try` will be left unconverted.
|
|
116
|
-
* - `false`: All `require` calls inside a `try` will be converted as if the
|
|
117
|
-
* `try-catch` clause is not there.
|
|
118
|
-
* - `remove`: Remove all `require` calls from inside any `try` block.
|
|
119
|
-
* - `string[]`: Pass an array containing the IDs to left unconverted.
|
|
120
|
-
* - `((id: string) => boolean|'remove')`: Pass a function that control
|
|
121
|
-
* individual IDs.
|
|
122
|
-
*
|
|
123
|
-
* @default false
|
|
124
|
-
*/
|
|
125
|
-
ignoreTryCatch?:
|
|
126
|
-
| boolean
|
|
127
|
-
| 'remove'
|
|
128
|
-
| ReadonlyArray<string>
|
|
129
|
-
| ((id: string) => boolean | 'remove')
|
|
130
|
-
/**
|
|
131
|
-
* Controls how to render imports from external dependencies. By default,
|
|
132
|
-
* this plugin assumes that all external dependencies are CommonJS. This
|
|
133
|
-
* means they are rendered as default imports to be compatible with e.g.
|
|
134
|
-
* NodeJS where ES modules can only import a default export from a CommonJS
|
|
135
|
-
* dependency.
|
|
136
|
-
*
|
|
137
|
-
* If you set `esmExternals` to `true`, this plugins assumes that all
|
|
138
|
-
* external dependencies are ES modules and respect the
|
|
139
|
-
* `requireReturnsDefault` option. If that option is not set, they will be
|
|
140
|
-
* rendered as namespace imports.
|
|
141
|
-
*
|
|
142
|
-
* You can also supply an array of ids to be treated as ES modules, or a
|
|
143
|
-
* function that will be passed each external id to determine if it is an ES
|
|
144
|
-
* module.
|
|
145
|
-
* @default false
|
|
146
|
-
*/
|
|
147
|
-
esmExternals?: boolean | ReadonlyArray<string> | ((id: string) => boolean)
|
|
148
|
-
/**
|
|
149
|
-
* Controls what is returned when requiring an ES module from a CommonJS file.
|
|
150
|
-
* When using the `esmExternals` option, this will also apply to external
|
|
151
|
-
* modules. By default, this plugin will render those imports as namespace
|
|
152
|
-
* imports i.e.
|
|
153
|
-
*
|
|
154
|
-
* ```js
|
|
155
|
-
* // input
|
|
156
|
-
* const foo = require('foo');
|
|
157
|
-
*
|
|
158
|
-
* // output
|
|
159
|
-
* import * as foo from 'foo';
|
|
160
|
-
* ```
|
|
161
|
-
*
|
|
162
|
-
* However there are some situations where this may not be desired.
|
|
163
|
-
* For these situations, you can change Rollup's behaviour either globally or
|
|
164
|
-
* per module. To change it globally, set the `requireReturnsDefault` option
|
|
165
|
-
* to one of the following values:
|
|
166
|
-
*
|
|
167
|
-
* - `false`: This is the default, requiring an ES module returns its
|
|
168
|
-
* namespace. This is the only option that will also add a marker
|
|
169
|
-
* `__esModule: true` to the namespace to support interop patterns in
|
|
170
|
-
* CommonJS modules that are transpiled ES modules.
|
|
171
|
-
* - `"namespace"`: Like `false`, requiring an ES module returns its
|
|
172
|
-
* namespace, but the plugin does not add the `__esModule` marker and thus
|
|
173
|
-
* creates more efficient code. For external dependencies when using
|
|
174
|
-
* `esmExternals: true`, no additional interop code is generated.
|
|
175
|
-
* - `"auto"`: This is complementary to how `output.exports: "auto"` works in
|
|
176
|
-
* Rollup: If a module has a default export and no named exports, requiring
|
|
177
|
-
* that module returns the default export. In all other cases, the namespace
|
|
178
|
-
* is returned. For external dependencies when using `esmExternals: true`, a
|
|
179
|
-
* corresponding interop helper is added.
|
|
180
|
-
* - `"preferred"`: If a module has a default export, requiring that module
|
|
181
|
-
* always returns the default export, no matter whether additional named
|
|
182
|
-
* exports exist. This is similar to how previous versions of this plugin
|
|
183
|
-
* worked. Again for external dependencies when using `esmExternals: true`,
|
|
184
|
-
* an interop helper is added.
|
|
185
|
-
* - `true`: This will always try to return the default export on require
|
|
186
|
-
* without checking if it actually exists. This can throw at build time if
|
|
187
|
-
* there is no default export. This is how external dependencies are handled
|
|
188
|
-
* when `esmExternals` is not used. The advantage over the other options is
|
|
189
|
-
* that, like `false`, this does not add an interop helper for external
|
|
190
|
-
* dependencies, keeping the code lean.
|
|
191
|
-
*
|
|
192
|
-
* To change this for individual modules, you can supply a function for
|
|
193
|
-
* `requireReturnsDefault` instead. This function will then be called once for
|
|
194
|
-
* each required ES module or external dependency with the corresponding id
|
|
195
|
-
* and allows you to return different values for different modules.
|
|
196
|
-
* @default false
|
|
197
|
-
*/
|
|
198
|
-
requireReturnsDefault?:
|
|
199
|
-
| boolean
|
|
200
|
-
| 'auto'
|
|
201
|
-
| 'preferred'
|
|
202
|
-
| 'namespace'
|
|
203
|
-
| ((id: string) => boolean | 'auto' | 'preferred' | 'namespace')
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* @default "auto"
|
|
207
|
-
*/
|
|
208
|
-
defaultIsModuleExports?: boolean | 'auto' | ((id: string) => boolean | 'auto')
|
|
209
|
-
/**
|
|
210
|
-
* Some modules contain dynamic `require` calls, or require modules that
|
|
211
|
-
* contain circular dependencies, which are not handled well by static
|
|
212
|
-
* imports. Including those modules as `dynamicRequireTargets` will simulate a
|
|
213
|
-
* CommonJS (NodeJS-like) environment for them with support for dynamic
|
|
214
|
-
* dependencies. It also enables `strictRequires` for those modules.
|
|
215
|
-
*
|
|
216
|
-
* Note: In extreme cases, this feature may result in some paths being
|
|
217
|
-
* rendered as absolute in the final bundle. The plugin tries to avoid
|
|
218
|
-
* exposing paths from the local machine, but if you are `dynamicRequirePaths`
|
|
219
|
-
* with paths that are far away from your project's folder, that may require
|
|
220
|
-
* replacing strings like `"/Users/John/Desktop/foo-project/"` -\> `"/"`.
|
|
221
|
-
*/
|
|
222
|
-
dynamicRequireTargets?: string | ReadonlyArray<string>
|
|
223
|
-
/**
|
|
224
|
-
* To avoid long paths when using the `dynamicRequireTargets` option, you can use this option to specify a directory
|
|
225
|
-
* that is a common parent for all files that use dynamic require statements. Using a directory higher up such as `/`
|
|
226
|
-
* may lead to unnecessarily long paths in the generated code and may expose directory names on your machine like your
|
|
227
|
-
* home directory name. By default it uses the current working directory.
|
|
228
|
-
*/
|
|
229
|
-
dynamicRequireRoot?: string
|
|
230
|
-
}
|
|
1
|
+
export type { RollupCommonJSOptions } from '../dist/node'
|
package/types/connect.d.ts
CHANGED
|
@@ -1,111 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// MIT Licensed https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/LICENSE
|
|
3
|
-
|
|
4
|
-
// Type definitions for connect v3.4.0
|
|
5
|
-
// Project: https://github.com/senchalabs/connect
|
|
6
|
-
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>
|
|
7
|
-
// Evan Hahn <https://github.com/EvanHahn>
|
|
8
|
-
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
9
|
-
|
|
10
|
-
/// <reference types="node" />
|
|
11
|
-
import * as http from 'node:http'
|
|
12
|
-
|
|
13
|
-
export namespace Connect {
|
|
14
|
-
export type ServerHandle = HandleFunction | http.Server
|
|
15
|
-
|
|
16
|
-
export class IncomingMessage extends http.IncomingMessage {
|
|
17
|
-
originalUrl?: http.IncomingMessage['url'] | undefined
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type NextFunction = (err?: any) => void
|
|
21
|
-
|
|
22
|
-
export type SimpleHandleFunction = (
|
|
23
|
-
req: IncomingMessage,
|
|
24
|
-
res: http.ServerResponse
|
|
25
|
-
) => void
|
|
26
|
-
export type NextHandleFunction = (
|
|
27
|
-
req: IncomingMessage,
|
|
28
|
-
res: http.ServerResponse,
|
|
29
|
-
next: NextFunction
|
|
30
|
-
) => void
|
|
31
|
-
export type ErrorHandleFunction = (
|
|
32
|
-
err: any,
|
|
33
|
-
req: IncomingMessage,
|
|
34
|
-
res: http.ServerResponse,
|
|
35
|
-
next: NextFunction
|
|
36
|
-
) => void
|
|
37
|
-
export type HandleFunction =
|
|
38
|
-
| SimpleHandleFunction
|
|
39
|
-
| NextHandleFunction
|
|
40
|
-
| ErrorHandleFunction
|
|
41
|
-
|
|
42
|
-
export interface ServerStackItem {
|
|
43
|
-
route: string
|
|
44
|
-
handle: ServerHandle
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface Server extends NodeJS.EventEmitter {
|
|
48
|
-
(req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void
|
|
49
|
-
|
|
50
|
-
route: string
|
|
51
|
-
stack: ServerStackItem[]
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Utilize the given middleware `handle` to the given `route`,
|
|
55
|
-
* defaulting to _/_. This "route" is the mount-point for the
|
|
56
|
-
* middleware, when given a value other than _/_ the middleware
|
|
57
|
-
* is only effective when that segment is present in the request's
|
|
58
|
-
* pathname.
|
|
59
|
-
*
|
|
60
|
-
* For example if we were to mount a function at _/admin_, it would
|
|
61
|
-
* be invoked on _/admin_, and _/admin/settings_, however it would
|
|
62
|
-
* not be invoked for _/_, or _/posts_.
|
|
63
|
-
*/
|
|
64
|
-
use(fn: NextHandleFunction): Server
|
|
65
|
-
use(fn: HandleFunction): Server
|
|
66
|
-
use(route: string, fn: NextHandleFunction): Server
|
|
67
|
-
use(route: string, fn: HandleFunction): Server
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Handle server requests, punting them down
|
|
71
|
-
* the middleware stack.
|
|
72
|
-
*/
|
|
73
|
-
handle(
|
|
74
|
-
req: http.IncomingMessage,
|
|
75
|
-
res: http.ServerResponse,
|
|
76
|
-
next: Function
|
|
77
|
-
): void
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Listen for connections.
|
|
81
|
-
*
|
|
82
|
-
* This method takes the same arguments
|
|
83
|
-
* as node's `http.Server#listen()`.
|
|
84
|
-
*
|
|
85
|
-
* HTTP and HTTPS:
|
|
86
|
-
*
|
|
87
|
-
* If you run your application both as HTTP
|
|
88
|
-
* and HTTPS you may wrap them individually,
|
|
89
|
-
* since your Connect "server" is really just
|
|
90
|
-
* a JavaScript `Function`.
|
|
91
|
-
*
|
|
92
|
-
* var connect = require('connect')
|
|
93
|
-
* , http = require('http')
|
|
94
|
-
* , https = require('https');
|
|
95
|
-
*
|
|
96
|
-
* var app = connect();
|
|
97
|
-
*
|
|
98
|
-
* http.createServer(app).listen(80);
|
|
99
|
-
* https.createServer(options, app).listen(443);
|
|
100
|
-
*/
|
|
101
|
-
listen(
|
|
102
|
-
port: number,
|
|
103
|
-
hostname?: string,
|
|
104
|
-
backlog?: number,
|
|
105
|
-
callback?: Function
|
|
106
|
-
): http.Server
|
|
107
|
-
listen(port: number, hostname?: string, callback?: Function): http.Server
|
|
108
|
-
listen(path: string, callback?: Function): http.Server
|
|
109
|
-
listen(handle: any, listeningListener?: Function): http.Server
|
|
110
|
-
}
|
|
111
|
-
}
|
|
1
|
+
export type { Connect } from '../dist/node'
|
package/types/customEvent.d.ts
CHANGED
|
@@ -10,6 +10,11 @@ export interface CustomEventMap {
|
|
|
10
10
|
'vite:beforePrune': PrunePayload
|
|
11
11
|
'vite:beforeFullReload': FullReloadPayload
|
|
12
12
|
'vite:error': ErrorPayload
|
|
13
|
+
'vite:invalidate': InvalidatePayload
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface InvalidatePayload {
|
|
17
|
+
path: string
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
export type InferCustomEventPayload<T extends string> =
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
/**
|
|
3
|
-
* Files to include in this plugin (default all).
|
|
4
|
-
* @default []
|
|
5
|
-
*/
|
|
6
|
-
include?: string | RegExp | (string | RegExp)[]
|
|
7
|
-
/**
|
|
8
|
-
* Files to exclude in this plugin (default none).
|
|
9
|
-
* @default []
|
|
10
|
-
*/
|
|
11
|
-
exclude?: string | RegExp | (string | RegExp)[]
|
|
12
|
-
/**
|
|
13
|
-
* By default, the plugin quits the build process when it encounters an error. If you set this option to true, it will throw a warning instead and leave the code untouched.
|
|
14
|
-
* @default false
|
|
15
|
-
*/
|
|
16
|
-
warnOnError?: boolean
|
|
17
|
-
}
|
|
1
|
+
export type { RollupDynamicImportVarsOptions } from '../dist/node'
|
package/types/http-proxy.d.ts
CHANGED
|
@@ -1,250 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// MIT Licensed https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/LICENSE
|
|
3
|
-
|
|
4
|
-
// Type definitions for node-http-proxy 1.17
|
|
5
|
-
// Project: https://github.com/nodejitsu/node-http-proxy
|
|
6
|
-
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>
|
|
7
|
-
// Florian Oellerich <https://github.com/Raigen>
|
|
8
|
-
// Daniel Schmidt <https://github.com/DanielMSchmidt>
|
|
9
|
-
// Jordan Abreu <https://github.com/jabreu610>
|
|
10
|
-
// Samuel Bodin <https://github.com/bodinsamuel>
|
|
11
|
-
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
12
|
-
// TypeScript Version: 2.1
|
|
13
|
-
|
|
14
|
-
/// <reference types="node" />
|
|
15
|
-
|
|
16
|
-
import type * as net from 'node:net'
|
|
17
|
-
import type * as http from 'node:http'
|
|
18
|
-
import * as events from 'node:events'
|
|
19
|
-
import type * as url from 'node:url'
|
|
20
|
-
import type * as stream from 'node:stream'
|
|
21
|
-
|
|
22
|
-
export namespace HttpProxy {
|
|
23
|
-
export type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed
|
|
24
|
-
|
|
25
|
-
export type ProxyTargetUrl = string | Partial<url.Url>
|
|
26
|
-
|
|
27
|
-
export interface ProxyTargetDetailed {
|
|
28
|
-
host: string
|
|
29
|
-
port: number
|
|
30
|
-
protocol?: string | undefined
|
|
31
|
-
hostname?: string | undefined
|
|
32
|
-
socketPath?: string | undefined
|
|
33
|
-
key?: string | undefined
|
|
34
|
-
passphrase?: string | undefined
|
|
35
|
-
pfx?: Buffer | string | undefined
|
|
36
|
-
cert?: string | undefined
|
|
37
|
-
ca?: string | undefined
|
|
38
|
-
ciphers?: string | undefined
|
|
39
|
-
secureProtocol?: string | undefined
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type ErrorCallback = (
|
|
43
|
-
err: Error,
|
|
44
|
-
req: http.IncomingMessage,
|
|
45
|
-
res: http.ServerResponse,
|
|
46
|
-
target?: ProxyTargetUrl
|
|
47
|
-
) => void
|
|
48
|
-
|
|
49
|
-
export class Server extends events.EventEmitter {
|
|
50
|
-
/**
|
|
51
|
-
* Creates the proxy server with specified options.
|
|
52
|
-
* @param options - Config object passed to the proxy
|
|
53
|
-
*/
|
|
54
|
-
constructor(options?: ServerOptions)
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Used for proxying regular HTTP(S) requests
|
|
58
|
-
* @param req - Client request.
|
|
59
|
-
* @param res - Client response.
|
|
60
|
-
* @param options - Additional options.
|
|
61
|
-
*/
|
|
62
|
-
web(
|
|
63
|
-
req: http.IncomingMessage,
|
|
64
|
-
res: http.ServerResponse,
|
|
65
|
-
options?: ServerOptions,
|
|
66
|
-
callback?: ErrorCallback
|
|
67
|
-
): void
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Used for proxying regular HTTP(S) requests
|
|
71
|
-
* @param req - Client request.
|
|
72
|
-
* @param socket - Client socket.
|
|
73
|
-
* @param head - Client head.
|
|
74
|
-
* @param options - Additional options.
|
|
75
|
-
*/
|
|
76
|
-
ws(
|
|
77
|
-
req: http.IncomingMessage,
|
|
78
|
-
socket: unknown,
|
|
79
|
-
head: unknown,
|
|
80
|
-
options?: ServerOptions,
|
|
81
|
-
callback?: ErrorCallback
|
|
82
|
-
): void
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* A function that wraps the object in a webserver, for your convenience
|
|
86
|
-
* @param port - Port to listen on
|
|
87
|
-
*/
|
|
88
|
-
listen(port: number): Server
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* A function that closes the inner webserver and stops listening on given port
|
|
92
|
-
*/
|
|
93
|
-
close(callback?: () => void): void
|
|
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 createProxyServer(options?: ServerOptions): Server
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Creates the proxy server with specified options.
|
|
104
|
-
* @param options - Config object passed to the proxy
|
|
105
|
-
* @returns Proxy object with handlers for `ws` and `web` requests
|
|
106
|
-
*/
|
|
107
|
-
static createServer(options?: ServerOptions): Server
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Creates the proxy server with specified options.
|
|
111
|
-
* @param options - Config object passed to the proxy
|
|
112
|
-
* @returns Proxy object with handlers for `ws` and `web` requests
|
|
113
|
-
*/
|
|
114
|
-
static createProxy(options?: ServerOptions): Server
|
|
115
|
-
|
|
116
|
-
addListener(event: string, listener: () => void): this
|
|
117
|
-
on(event: string, listener: () => void): this
|
|
118
|
-
on(event: 'error', listener: ErrorCallback): this
|
|
119
|
-
on(
|
|
120
|
-
event: 'start',
|
|
121
|
-
listener: (
|
|
122
|
-
req: http.IncomingMessage,
|
|
123
|
-
res: http.ServerResponse,
|
|
124
|
-
target: ProxyTargetUrl
|
|
125
|
-
) => void
|
|
126
|
-
): this
|
|
127
|
-
on(
|
|
128
|
-
event: 'proxyReq',
|
|
129
|
-
listener: (
|
|
130
|
-
proxyReq: http.ClientRequest,
|
|
131
|
-
req: http.IncomingMessage,
|
|
132
|
-
res: http.ServerResponse,
|
|
133
|
-
options: ServerOptions
|
|
134
|
-
) => void
|
|
135
|
-
): this
|
|
136
|
-
on(
|
|
137
|
-
event: 'proxyRes',
|
|
138
|
-
listener: (
|
|
139
|
-
proxyRes: http.IncomingMessage,
|
|
140
|
-
req: http.IncomingMessage,
|
|
141
|
-
res: http.ServerResponse
|
|
142
|
-
) => void
|
|
143
|
-
): this
|
|
144
|
-
on(
|
|
145
|
-
event: 'proxyReqWs',
|
|
146
|
-
listener: (
|
|
147
|
-
proxyReq: http.ClientRequest,
|
|
148
|
-
req: http.IncomingMessage,
|
|
149
|
-
socket: net.Socket,
|
|
150
|
-
options: ServerOptions,
|
|
151
|
-
head: any
|
|
152
|
-
) => void
|
|
153
|
-
): this
|
|
154
|
-
on(
|
|
155
|
-
event: 'econnreset',
|
|
156
|
-
listener: (
|
|
157
|
-
err: Error,
|
|
158
|
-
req: http.IncomingMessage,
|
|
159
|
-
res: http.ServerResponse,
|
|
160
|
-
target: ProxyTargetUrl
|
|
161
|
-
) => void
|
|
162
|
-
): this
|
|
163
|
-
on(
|
|
164
|
-
event: 'end',
|
|
165
|
-
listener: (
|
|
166
|
-
req: http.IncomingMessage,
|
|
167
|
-
res: http.ServerResponse,
|
|
168
|
-
proxyRes: http.IncomingMessage
|
|
169
|
-
) => void
|
|
170
|
-
): this
|
|
171
|
-
on(
|
|
172
|
-
event: 'close',
|
|
173
|
-
listener: (
|
|
174
|
-
proxyRes: http.IncomingMessage,
|
|
175
|
-
proxySocket: net.Socket,
|
|
176
|
-
proxyHead: any
|
|
177
|
-
) => void
|
|
178
|
-
): this
|
|
179
|
-
|
|
180
|
-
once(event: string, listener: () => void): this
|
|
181
|
-
removeListener(event: string, listener: () => void): this
|
|
182
|
-
removeAllListeners(event?: string): this
|
|
183
|
-
getMaxListeners(): number
|
|
184
|
-
setMaxListeners(n: number): this
|
|
185
|
-
listeners(event: string): Array<() => void>
|
|
186
|
-
emit(event: string, ...args: any[]): boolean
|
|
187
|
-
listenerCount(type: string): number
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export interface ServerOptions {
|
|
191
|
-
/** URL string to be parsed with the url module. */
|
|
192
|
-
target?: ProxyTarget | undefined
|
|
193
|
-
/** URL string to be parsed with the url module. */
|
|
194
|
-
forward?: ProxyTargetUrl | undefined
|
|
195
|
-
/** Object to be passed to http(s).request. */
|
|
196
|
-
agent?: any
|
|
197
|
-
/** Object to be passed to https.createServer(). */
|
|
198
|
-
ssl?: any
|
|
199
|
-
/** If you want to proxy websockets. */
|
|
200
|
-
ws?: boolean | undefined
|
|
201
|
-
/** Adds x- forward headers. */
|
|
202
|
-
xfwd?: boolean | undefined
|
|
203
|
-
/** Verify SSL certificate. */
|
|
204
|
-
secure?: boolean | undefined
|
|
205
|
-
/** Explicitly specify if we are proxying to another proxy. */
|
|
206
|
-
toProxy?: boolean | undefined
|
|
207
|
-
/** Specify whether you want to prepend the target's path to the proxy path. */
|
|
208
|
-
prependPath?: boolean | undefined
|
|
209
|
-
/** Specify whether you want to ignore the proxy path of the incoming request. */
|
|
210
|
-
ignorePath?: boolean | undefined
|
|
211
|
-
/** Local interface string to bind for outgoing connections. */
|
|
212
|
-
localAddress?: string | undefined
|
|
213
|
-
/** Changes the origin of the host header to the target URL. */
|
|
214
|
-
changeOrigin?: boolean | undefined
|
|
215
|
-
/** specify whether you want to keep letter case of response header key */
|
|
216
|
-
preserveHeaderKeyCase?: boolean | undefined
|
|
217
|
-
/** Basic authentication i.e. 'user:password' to compute an Authorization header. */
|
|
218
|
-
auth?: string | undefined
|
|
219
|
-
/** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
|
|
220
|
-
hostRewrite?: string | undefined
|
|
221
|
-
/** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
|
|
222
|
-
autoRewrite?: boolean | undefined
|
|
223
|
-
/** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
|
|
224
|
-
protocolRewrite?: string | undefined
|
|
225
|
-
/** rewrites domain of set-cookie headers. */
|
|
226
|
-
cookieDomainRewrite?:
|
|
227
|
-
| false
|
|
228
|
-
| string
|
|
229
|
-
| { [oldDomain: string]: string }
|
|
230
|
-
| undefined
|
|
231
|
-
/** rewrites path of set-cookie headers. Default: false */
|
|
232
|
-
cookiePathRewrite?:
|
|
233
|
-
| false
|
|
234
|
-
| string
|
|
235
|
-
| { [oldPath: string]: string }
|
|
236
|
-
| undefined
|
|
237
|
-
/** object with extra headers to be added to target requests. */
|
|
238
|
-
headers?: { [header: string]: string } | undefined
|
|
239
|
-
/** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
|
|
240
|
-
proxyTimeout?: number | undefined
|
|
241
|
-
/** Timeout (in milliseconds) for incoming requests */
|
|
242
|
-
timeout?: number | undefined
|
|
243
|
-
/** Specify whether you want to follow redirects. Default: false */
|
|
244
|
-
followRedirects?: boolean | undefined
|
|
245
|
-
/** 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 */
|
|
246
|
-
selfHandleResponse?: boolean | undefined
|
|
247
|
-
/** Buffer */
|
|
248
|
-
buffer?: stream.Stream | undefined
|
|
249
|
-
}
|
|
250
|
-
}
|
|
1
|
+
export type { HttpProxy } from '../dist/node'
|
package/types/importMeta.d.ts
CHANGED
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
/* eslint-disable @typescript-eslint/consistent-type-imports */
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
interface ImportMetaEnv {
|
|
8
|
+
[key: string]: any
|
|
9
|
+
BASE_URL: string
|
|
10
|
+
MODE: string
|
|
11
|
+
DEV: boolean
|
|
12
|
+
PROD: boolean
|
|
13
|
+
SSR: boolean
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
interface ImportMeta {
|
|
@@ -24,12 +26,3 @@ interface ImportMeta {
|
|
|
24
26
|
*/
|
|
25
27
|
globEager: import('./importGlob').ImportGlobEagerFunction
|
|
26
28
|
}
|
|
27
|
-
|
|
28
|
-
interface ImportMetaEnv {
|
|
29
|
-
[key: string]: any
|
|
30
|
-
BASE_URL: string
|
|
31
|
-
MODE: string
|
|
32
|
-
DEV: boolean
|
|
33
|
-
PROD: boolean
|
|
34
|
-
SSR: boolean
|
|
35
|
-
}
|