vite 2.9.12 → 3.0.0-alpha.10
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/LICENSE.md +29 -1
- package/bin/vite.js +5 -5
- package/client.d.ts +4 -3
- package/dist/client/client.mjs +28 -30
- package/dist/client/client.mjs.map +1 -1
- package/dist/client/env.mjs.map +1 -1
- package/dist/node/chunks/{dep-8f5c9290.js → dep-134b43f1.js} +50519 -52177
- package/dist/node/chunks/{dep-a9015192.js → dep-17430d09.js} +20 -20
- package/dist/node/chunks/{dep-b27bdd3c.js → dep-5e48add3.js} +28 -30
- package/dist/node/chunks/{dep-ad22985c.js → dep-6f128771.js} +40 -37
- package/dist/node/chunks/{dep-985abbbd.js → dep-8176918d.js} +111 -52
- package/dist/node/chunks/{dep-2056ae8a.js → dep-e8ca8d40.js} +9 -3
- package/dist/node/cli.js +45 -48
- package/dist/node/constants.js +82 -0
- package/dist/node/index.d.ts +308 -174
- package/dist/node/index.js +37 -61
- package/dist/node-cjs/publicUtils.cjs +2040 -0
- package/index.cjs +33 -0
- package/package.json +45 -39
- package/src/client/client.ts +27 -29
- package/src/client/tsconfig.json +1 -1
- package/types/chokidar.d.ts +4 -2
- package/types/hot.d.ts +0 -6
- package/types/importGlob.d.ts +87 -0
- package/types/importMeta.d.ts +5 -15
- package/types/shims.d.ts +5 -8
- package/types/terser.d.ts +0 -2
- package/dist/node/terser.js +0 -32876
package/dist/node/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ import type { OutgoingHttpHeaders } from 'http';
|
|
|
24
24
|
import type { OutputBundle } from 'rollup';
|
|
25
25
|
import type { OutputChunk } from 'rollup';
|
|
26
26
|
import type { PartialResolvedId } from 'rollup';
|
|
27
|
-
import type { Plugin as
|
|
27
|
+
import type { Plugin as Plugin_3 } from 'rollup';
|
|
28
28
|
import type { PluginContext } from 'rollup';
|
|
29
29
|
import type { PluginHooks } from 'rollup';
|
|
30
30
|
import type * as PostCSS from 'postcss';
|
|
@@ -36,15 +36,14 @@ import type { RollupWatcher } from 'rollup';
|
|
|
36
36
|
import type { SecureContextOptions } from 'tls';
|
|
37
37
|
import type { Server } from 'http';
|
|
38
38
|
import type { Server as Server_2 } from 'https';
|
|
39
|
-
import type { Server as Server_3 } from 'net';
|
|
40
39
|
import type { ServerOptions as ServerOptions_2 } from 'https';
|
|
41
40
|
import type { ServerResponse } from 'http';
|
|
42
41
|
import type { SourceDescription } from 'rollup';
|
|
43
42
|
import type { SourceMap } from 'rollup';
|
|
44
43
|
import type * as stream from 'stream';
|
|
45
44
|
import type { TransformPluginContext } from 'rollup';
|
|
46
|
-
import type { TransformResult as TransformResult_2 } from '
|
|
47
|
-
import type { TransformResult as TransformResult_3 } from '
|
|
45
|
+
import type { TransformResult as TransformResult_2 } from 'rollup';
|
|
46
|
+
import type { TransformResult as TransformResult_3 } from 'esbuild';
|
|
48
47
|
import type * as url from 'url';
|
|
49
48
|
import type { URL as URL_2 } from 'url';
|
|
50
49
|
import type { WatcherOptions } from 'rollup';
|
|
@@ -95,11 +94,6 @@ export declare interface AwaitWriteFinishOptions {
|
|
|
95
94
|
export declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
|
96
95
|
|
|
97
96
|
export declare interface BuildOptions {
|
|
98
|
-
/**
|
|
99
|
-
* Base public path when served in production.
|
|
100
|
-
* @deprecated `base` is now a root-level config option.
|
|
101
|
-
*/
|
|
102
|
-
base?: string;
|
|
103
97
|
/**
|
|
104
98
|
* Compatibility transform target. The transform is performed with esbuild
|
|
105
99
|
* and the lowest supported target is es2015/es6. Note this only handles
|
|
@@ -123,13 +117,6 @@ export declare interface BuildOptions {
|
|
|
123
117
|
* @default true
|
|
124
118
|
*/
|
|
125
119
|
polyfillModulePreload?: boolean;
|
|
126
|
-
/**
|
|
127
|
-
* whether to inject dynamic import polyfill.
|
|
128
|
-
* Note: does not apply to library mode.
|
|
129
|
-
* @default false
|
|
130
|
-
* @deprecated use plugin-legacy for browsers that don't support dynamic import
|
|
131
|
-
*/
|
|
132
|
-
polyfillDynamicImport?: boolean;
|
|
133
120
|
/**
|
|
134
121
|
* Directory relative from `root` where build output will be placed. If the
|
|
135
122
|
* directory exists, it will be removed before the build.
|
|
@@ -183,10 +170,6 @@ export declare interface BuildOptions {
|
|
|
183
170
|
* https://terser.org/docs/api-reference#minify-options
|
|
184
171
|
*/
|
|
185
172
|
terserOptions?: Terser.MinifyOptions;
|
|
186
|
-
/**
|
|
187
|
-
* @deprecated Vite now uses esbuild for CSS minification.
|
|
188
|
-
*/
|
|
189
|
-
cleanCssOptions?: any;
|
|
190
173
|
/**
|
|
191
174
|
* Will be merged with internal rollup options.
|
|
192
175
|
* https://rollupjs.org/guide/en/#big-list-of-options
|
|
@@ -251,12 +234,6 @@ export declare interface BuildOptions {
|
|
|
251
234
|
* Can slightly improve build speed.
|
|
252
235
|
*/
|
|
253
236
|
reportCompressedSize?: boolean;
|
|
254
|
-
/**
|
|
255
|
-
* Set to false to disable brotli compressed size reporting for build.
|
|
256
|
-
* Can slightly improve build speed.
|
|
257
|
-
* @deprecated use `build.reportCompressedSize` instead.
|
|
258
|
-
*/
|
|
259
|
-
brotliSize?: boolean;
|
|
260
237
|
/**
|
|
261
238
|
* Adjust chunk size warning limit (in kbs).
|
|
262
239
|
* @default 500
|
|
@@ -556,6 +533,13 @@ export declare interface DepOptimizationOptions {
|
|
|
556
533
|
* vite project root. This will overwrite default entries inference.
|
|
557
534
|
*/
|
|
558
535
|
entries?: string | string[];
|
|
536
|
+
/**
|
|
537
|
+
* Enable esbuild based scan phase, to get back to the optimized deps discovery
|
|
538
|
+
* strategy used in Vite v2
|
|
539
|
+
* @default false
|
|
540
|
+
* @experimental
|
|
541
|
+
*/
|
|
542
|
+
devScan?: boolean;
|
|
559
543
|
/**
|
|
560
544
|
* Force optimize listed dependencies (must be resolvable import paths,
|
|
561
545
|
* cannot be globs).
|
|
@@ -566,6 +550,12 @@ export declare interface DepOptimizationOptions {
|
|
|
566
550
|
* cannot be globs).
|
|
567
551
|
*/
|
|
568
552
|
exclude?: string[];
|
|
553
|
+
/**
|
|
554
|
+
* Force ESM interop when importing for these dependencies. Some legacy
|
|
555
|
+
* packages advertise themselves as ESM but use `require` internally
|
|
556
|
+
* @experimental
|
|
557
|
+
*/
|
|
558
|
+
needsInterop?: string[];
|
|
569
559
|
/**
|
|
570
560
|
* Options to pass to esbuild during the dep scanning and optimization
|
|
571
561
|
*
|
|
@@ -574,15 +564,10 @@ export declare interface DepOptimizationOptions {
|
|
|
574
564
|
*
|
|
575
565
|
* - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
|
|
576
566
|
* - `plugins` are merged with Vite's dep plugin
|
|
577
|
-
* - `keepNames` takes precedence over the deprecated `optimizeDeps.keepNames`
|
|
578
567
|
*
|
|
579
568
|
* https://esbuild.github.io/api
|
|
580
569
|
*/
|
|
581
570
|
esbuildOptions?: Omit<BuildOptions_2, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
|
|
582
|
-
/**
|
|
583
|
-
* @deprecated use `esbuildOptions.keepNames`
|
|
584
|
-
*/
|
|
585
|
-
keepNames?: boolean;
|
|
586
571
|
/**
|
|
587
572
|
* List of file extensions that can be optimized. A corresponding esbuild
|
|
588
573
|
* plugin must exist to handle the specific extension.
|
|
@@ -594,11 +579,13 @@ export declare interface DepOptimizationOptions {
|
|
|
594
579
|
*/
|
|
595
580
|
extensions?: string[];
|
|
596
581
|
/**
|
|
597
|
-
* Disables dependencies optimizations
|
|
582
|
+
* Disables dependencies optimizations, true disables the optimizer during
|
|
583
|
+
* build and dev. Pass 'build' or 'dev' to only disable the optimizer in
|
|
584
|
+
* one of the modes. Deps optimization is enabled by default in both
|
|
598
585
|
* @default false
|
|
599
586
|
* @experimental
|
|
600
587
|
*/
|
|
601
|
-
disabled?: boolean;
|
|
588
|
+
disabled?: boolean | 'build' | 'dev';
|
|
602
589
|
}
|
|
603
590
|
|
|
604
591
|
export declare interface DepOptimizationProcessing {
|
|
@@ -617,6 +604,20 @@ export declare interface DepOptimizationResult {
|
|
|
617
604
|
cancel: () => void;
|
|
618
605
|
}
|
|
619
606
|
|
|
607
|
+
export declare interface DepsOptimizer {
|
|
608
|
+
metadata: DepOptimizationMetadata;
|
|
609
|
+
scanProcessing?: Promise<void>;
|
|
610
|
+
registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
|
|
611
|
+
run: () => void;
|
|
612
|
+
isOptimizedDepFile: (id: string) => boolean;
|
|
613
|
+
isOptimizedDepUrl: (url: string) => boolean;
|
|
614
|
+
getOptimizedDepId: (depInfo: OptimizedDepInfo) => string;
|
|
615
|
+
delayDepsOptimizerUntil: (id: string, done: () => Promise<any>) => void;
|
|
616
|
+
registerWorkersSource: (id: string) => void;
|
|
617
|
+
resetRegisteredIds: () => void;
|
|
618
|
+
options: DepOptimizationOptions;
|
|
619
|
+
}
|
|
620
|
+
|
|
620
621
|
export declare interface ErrorPayload {
|
|
621
622
|
type: 'error'
|
|
622
623
|
err: {
|
|
@@ -643,10 +644,28 @@ export declare interface ESBuildOptions extends EsbuildTransformOptions {
|
|
|
643
644
|
|
|
644
645
|
export { EsbuildTransformOptions }
|
|
645
646
|
|
|
646
|
-
export declare type ESBuildTransformResult = Omit<
|
|
647
|
+
export declare type ESBuildTransformResult = Omit<TransformResult_3, 'map'> & {
|
|
647
648
|
map: SourceMap;
|
|
648
649
|
};
|
|
649
650
|
|
|
651
|
+
export declare interface ExperimentalOptions {
|
|
652
|
+
/**
|
|
653
|
+
* Append fake `&lang.(ext)` when queries are specified, to preseve the file extension for following plugins to process.
|
|
654
|
+
*
|
|
655
|
+
* @experimental
|
|
656
|
+
* @default false
|
|
657
|
+
*/
|
|
658
|
+
importGlobRestoreExtension?: boolean;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
export declare type ExportsData = {
|
|
662
|
+
hasImports: boolean;
|
|
663
|
+
exports: readonly string[];
|
|
664
|
+
facade: boolean;
|
|
665
|
+
hasReExports?: boolean;
|
|
666
|
+
jsxLoader?: boolean;
|
|
667
|
+
};
|
|
668
|
+
|
|
650
669
|
export declare interface FileSystemServeOptions {
|
|
651
670
|
/**
|
|
652
671
|
* Strictly restrict file accessing outside of allowing paths.
|
|
@@ -670,13 +689,11 @@ export declare interface FileSystemServeOptions {
|
|
|
670
689
|
* Glob patterns are supported.
|
|
671
690
|
*
|
|
672
691
|
* @default ['.env', '.env.*', '*.crt', '*.pem']
|
|
673
|
-
*
|
|
674
|
-
* @experimental
|
|
675
692
|
*/
|
|
676
693
|
deny?: string[];
|
|
677
694
|
}
|
|
678
695
|
|
|
679
|
-
export declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): ExistingRawSourceMap
|
|
696
|
+
export declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): Promise<ExistingRawSourceMap>;
|
|
680
697
|
|
|
681
698
|
export declare class FSWatcher extends EventEmitter implements fs.FSWatcher {
|
|
682
699
|
options: WatchOptions
|
|
@@ -1014,6 +1031,86 @@ export declare namespace HttpProxy {
|
|
|
1014
1031
|
}
|
|
1015
1032
|
}
|
|
1016
1033
|
|
|
1034
|
+
export declare interface ImportGlobEagerFunction {
|
|
1035
|
+
/**
|
|
1036
|
+
* 1. No generic provided, infer the type from `as`
|
|
1037
|
+
*/
|
|
1038
|
+
<
|
|
1039
|
+
As extends string,
|
|
1040
|
+
T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown
|
|
1041
|
+
>(
|
|
1042
|
+
glob: string | string[],
|
|
1043
|
+
options?: Omit<ImportGlobOptions<boolean, As>, 'eager'>
|
|
1044
|
+
): Record<string, T>
|
|
1045
|
+
/**
|
|
1046
|
+
* 2. Module generic provided
|
|
1047
|
+
*/
|
|
1048
|
+
<M>(
|
|
1049
|
+
glob: string | string[],
|
|
1050
|
+
options?: Omit<ImportGlobOptions<boolean, string>, 'eager'>
|
|
1051
|
+
): Record<string, M>
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
export declare interface ImportGlobFunction {
|
|
1055
|
+
/**
|
|
1056
|
+
* 1. No generic provided, infer the type from `eager` and `as`
|
|
1057
|
+
*/
|
|
1058
|
+
<
|
|
1059
|
+
Eager extends boolean,
|
|
1060
|
+
As extends string,
|
|
1061
|
+
T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown
|
|
1062
|
+
>(
|
|
1063
|
+
glob: string | string[],
|
|
1064
|
+
options?: ImportGlobOptions<Eager, As>
|
|
1065
|
+
): (Eager extends true ? true : false) extends true
|
|
1066
|
+
? Record<string, T>
|
|
1067
|
+
: Record<string, () => Promise<T>>
|
|
1068
|
+
/**
|
|
1069
|
+
* 2. Module generic provided, infer the type from `eager: false`
|
|
1070
|
+
*/
|
|
1071
|
+
<M>(
|
|
1072
|
+
glob: string | string[],
|
|
1073
|
+
options?: ImportGlobOptions<false, string>
|
|
1074
|
+
): Record<string, () => Promise<M>>
|
|
1075
|
+
/**
|
|
1076
|
+
* 3. Module generic provided, infer the type from `eager: true`
|
|
1077
|
+
*/
|
|
1078
|
+
<M>(
|
|
1079
|
+
glob: string | string[],
|
|
1080
|
+
options: ImportGlobOptions<true, string>
|
|
1081
|
+
): Record<string, M>
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
export declare interface ImportGlobOptions<
|
|
1085
|
+
Eager extends boolean,
|
|
1086
|
+
AsType extends string
|
|
1087
|
+
> {
|
|
1088
|
+
/**
|
|
1089
|
+
* Import type for the import url.
|
|
1090
|
+
*/
|
|
1091
|
+
as?: AsType
|
|
1092
|
+
/**
|
|
1093
|
+
* Import as static or dynamic
|
|
1094
|
+
*
|
|
1095
|
+
* @default false
|
|
1096
|
+
*/
|
|
1097
|
+
eager?: Eager
|
|
1098
|
+
/**
|
|
1099
|
+
* Import only the specific named export. Set to `default` to import the default export.
|
|
1100
|
+
*/
|
|
1101
|
+
import?: string
|
|
1102
|
+
/**
|
|
1103
|
+
* Custom queries
|
|
1104
|
+
*/
|
|
1105
|
+
query?: string | Record<string, string | number | boolean>
|
|
1106
|
+
/**
|
|
1107
|
+
* Search files also inside `node_modules/` and hidden directories (e.g. `.git/`). This might have impact on performance.
|
|
1108
|
+
*
|
|
1109
|
+
* @default false
|
|
1110
|
+
*/
|
|
1111
|
+
exhaustive?: boolean
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1017
1114
|
export declare type IndexHtmlTransform = IndexHtmlTransformHook | {
|
|
1018
1115
|
enforce?: 'pre' | 'post';
|
|
1019
1116
|
transform: IndexHtmlTransformHook;
|
|
@@ -1070,8 +1167,12 @@ export declare interface InternalResolveOptions extends ResolveOptions {
|
|
|
1070
1167
|
isFromTsImporter?: boolean;
|
|
1071
1168
|
tryEsmOnly?: boolean;
|
|
1072
1169
|
scan?: boolean;
|
|
1170
|
+
getDepsOptimizer?: () => DepsOptimizer | undefined;
|
|
1171
|
+
shouldExternalize?: (id: string) => boolean | undefined;
|
|
1073
1172
|
}
|
|
1074
1173
|
|
|
1174
|
+
export declare function isDepsOptimizerEnabled(config: ResolvedConfig): boolean;
|
|
1175
|
+
|
|
1075
1176
|
export declare interface JsonOptions {
|
|
1076
1177
|
/**
|
|
1077
1178
|
* Generate a named export for every property of the JSON object
|
|
@@ -1086,12 +1187,34 @@ export declare interface JsonOptions {
|
|
|
1086
1187
|
stringify?: boolean;
|
|
1087
1188
|
}
|
|
1088
1189
|
|
|
1190
|
+
export declare interface KnownAsTypeMap {
|
|
1191
|
+
raw: string
|
|
1192
|
+
url: string
|
|
1193
|
+
worker: Worker
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1089
1196
|
export declare type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife';
|
|
1090
1197
|
|
|
1091
1198
|
export declare interface LibraryOptions {
|
|
1199
|
+
/**
|
|
1200
|
+
* Path of library entry
|
|
1201
|
+
*/
|
|
1092
1202
|
entry: string;
|
|
1203
|
+
/**
|
|
1204
|
+
* The name of the exposed global variable. Required when the `formats` option includes
|
|
1205
|
+
* `umd` or `iife`
|
|
1206
|
+
*/
|
|
1093
1207
|
name?: string;
|
|
1208
|
+
/**
|
|
1209
|
+
* Output bundle formats
|
|
1210
|
+
* @default ['es', 'umd']
|
|
1211
|
+
*/
|
|
1094
1212
|
formats?: LibraryFormats[];
|
|
1213
|
+
/**
|
|
1214
|
+
* The name of the package file output. The default file name is the name option
|
|
1215
|
+
* of the project package.json. It can also be defined as a function taking the
|
|
1216
|
+
* format as an argument.
|
|
1217
|
+
*/
|
|
1095
1218
|
fileName?: string | ((format: ModuleFormat) => string);
|
|
1096
1219
|
}
|
|
1097
1220
|
|
|
@@ -1147,6 +1270,8 @@ export declare interface ManifestChunk {
|
|
|
1147
1270
|
|
|
1148
1271
|
export declare type Matcher = AnymatchPattern | AnymatchPattern[]
|
|
1149
1272
|
|
|
1273
|
+
export declare function mergeAlias(a?: AliasOptions, b?: AliasOptions): AliasOptions | undefined;
|
|
1274
|
+
|
|
1150
1275
|
export declare function mergeConfig(defaults: Record<string, any>, overrides: Record<string, any>, isRoot?: boolean): Record<string, any>;
|
|
1151
1276
|
|
|
1152
1277
|
export declare class ModuleGraph {
|
|
@@ -1213,12 +1338,11 @@ export declare interface OptimizedDepInfo {
|
|
|
1213
1338
|
* but the bundles may not yet be saved to disk
|
|
1214
1339
|
*/
|
|
1215
1340
|
processing?: Promise<void>;
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
|
|
1341
|
+
/**
|
|
1342
|
+
* ExportData cache, discovered deps will parse the src entry to get exports
|
|
1343
|
+
* data used both to define if interop is needed and when pre-bundling
|
|
1344
|
+
*/
|
|
1345
|
+
exportsData?: Promise<ExportsData>;
|
|
1222
1346
|
}
|
|
1223
1347
|
|
|
1224
1348
|
/**
|
|
@@ -1238,6 +1362,8 @@ export declare interface PackageData {
|
|
|
1238
1362
|
getResolvedCache: (key: string, targetWeb: boolean) => string | undefined;
|
|
1239
1363
|
data: {
|
|
1240
1364
|
[field: string]: any;
|
|
1365
|
+
name: string;
|
|
1366
|
+
type: string;
|
|
1241
1367
|
version: string;
|
|
1242
1368
|
main: string;
|
|
1243
1369
|
module: string;
|
|
@@ -1268,7 +1394,7 @@ export declare interface PackageData {
|
|
|
1268
1394
|
* If a plugin should be applied only for server or build, a function format
|
|
1269
1395
|
* config file can be used to conditional determine the plugins to use.
|
|
1270
1396
|
*/
|
|
1271
|
-
|
|
1397
|
+
declare interface Plugin_2 extends Plugin_3 {
|
|
1272
1398
|
/**
|
|
1273
1399
|
* Enforce plugin invocation tier similar to webpack loaders.
|
|
1274
1400
|
*
|
|
@@ -1363,15 +1489,16 @@ export declare interface Plugin extends Plugin_2 {
|
|
|
1363
1489
|
}): Promise<LoadResult> | LoadResult;
|
|
1364
1490
|
transform?(this: TransformPluginContext, code: string, id: string, options?: {
|
|
1365
1491
|
ssr?: boolean;
|
|
1366
|
-
}): Promise<
|
|
1492
|
+
}): Promise<TransformResult_2> | TransformResult_2;
|
|
1367
1493
|
}
|
|
1494
|
+
export { Plugin_2 as Plugin }
|
|
1368
1495
|
|
|
1369
1496
|
export declare interface PluginContainer {
|
|
1370
1497
|
options: InputOptions;
|
|
1371
1498
|
getModuleInfo(id: string): ModuleInfo | null;
|
|
1372
1499
|
buildStart(options: InputOptions): Promise<void>;
|
|
1373
1500
|
resolveId(id: string, importer?: string, options?: {
|
|
1374
|
-
skip?: Set<
|
|
1501
|
+
skip?: Set<Plugin_2>;
|
|
1375
1502
|
ssr?: boolean;
|
|
1376
1503
|
/* Excluded from this release type: scan */
|
|
1377
1504
|
}): Promise<PartialResolvedId | null>;
|
|
@@ -1385,13 +1512,12 @@ export declare interface PluginContainer {
|
|
|
1385
1512
|
close(): Promise<void>;
|
|
1386
1513
|
}
|
|
1387
1514
|
|
|
1388
|
-
export declare type PluginOption =
|
|
1515
|
+
export declare type PluginOption = Plugin_2 | false | null | undefined | PluginOption[];
|
|
1389
1516
|
|
|
1390
1517
|
/**
|
|
1391
1518
|
* Starts the Vite server in preview mode, to simulate a production deployment
|
|
1392
|
-
* @experimental
|
|
1393
1519
|
*/
|
|
1394
|
-
export declare function preview(inlineConfig
|
|
1520
|
+
export declare function preview(inlineConfig?: InlineConfig): Promise<PreviewServer>;
|
|
1395
1521
|
|
|
1396
1522
|
export declare interface PreviewOptions extends CommonServerOptions {
|
|
1397
1523
|
}
|
|
@@ -1404,7 +1530,7 @@ export declare interface PreviewServer {
|
|
|
1404
1530
|
/**
|
|
1405
1531
|
* native Node http server instance
|
|
1406
1532
|
*/
|
|
1407
|
-
httpServer: Server;
|
|
1533
|
+
httpServer: http.Server;
|
|
1408
1534
|
/**
|
|
1409
1535
|
* Print server urls
|
|
1410
1536
|
*/
|
|
@@ -1416,11 +1542,6 @@ export declare type PreviewServerHook = (server: {
|
|
|
1416
1542
|
httpServer: http.Server;
|
|
1417
1543
|
}) => (() => void) | void | Promise<(() => void) | void>;
|
|
1418
1544
|
|
|
1419
|
-
/**
|
|
1420
|
-
* @deprecated Use `server.printUrls()` instead
|
|
1421
|
-
*/
|
|
1422
|
-
export declare function printHttpServerUrls(server: Server_3, config: ResolvedConfig): void;
|
|
1423
|
-
|
|
1424
1545
|
export declare interface ProxyOptions extends HttpProxy.ServerOptions {
|
|
1425
1546
|
/**
|
|
1426
1547
|
* rewrite path
|
|
@@ -1443,9 +1564,9 @@ export declare interface PrunePayload {
|
|
|
1443
1564
|
|
|
1444
1565
|
export declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string): Promise<ResolvedConfig>;
|
|
1445
1566
|
|
|
1446
|
-
export declare type ResolvedBuildOptions = Required<
|
|
1567
|
+
export declare type ResolvedBuildOptions = Required<BuildOptions>;
|
|
1447
1568
|
|
|
1448
|
-
export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | '
|
|
1569
|
+
export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'assetsInclude' | 'optimizeDeps' | 'worker'> & {
|
|
1449
1570
|
configFile: string | undefined;
|
|
1450
1571
|
configFileDependencies: string[];
|
|
1451
1572
|
inlineConfig: InlineConfig;
|
|
@@ -1456,21 +1577,24 @@ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'alia
|
|
|
1456
1577
|
command: 'build' | 'serve';
|
|
1457
1578
|
mode: string;
|
|
1458
1579
|
isWorker: boolean;
|
|
1580
|
+
/* Excluded from this release type: mainConfig */
|
|
1459
1581
|
isProduction: boolean;
|
|
1460
1582
|
env: Record<string, any>;
|
|
1461
1583
|
resolve: ResolveOptions & {
|
|
1462
1584
|
alias: Alias[];
|
|
1463
1585
|
};
|
|
1464
|
-
plugins: readonly
|
|
1586
|
+
plugins: readonly Plugin_2[];
|
|
1465
1587
|
server: ResolvedServerOptions;
|
|
1466
1588
|
build: ResolvedBuildOptions;
|
|
1467
1589
|
preview: ResolvedPreviewOptions;
|
|
1590
|
+
ssr: ResolvedSSROptions | undefined;
|
|
1468
1591
|
assetsInclude: (file: string) => boolean;
|
|
1469
1592
|
logger: Logger;
|
|
1470
1593
|
createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn;
|
|
1471
|
-
optimizeDeps:
|
|
1594
|
+
optimizeDeps: DepOptimizationOptions;
|
|
1472
1595
|
/* Excluded from this release type: packageCache */
|
|
1473
1596
|
worker: ResolveWorkerOptions;
|
|
1597
|
+
spa: boolean;
|
|
1474
1598
|
}>;
|
|
1475
1599
|
|
|
1476
1600
|
export declare interface ResolvedPreviewOptions extends PreviewOptions {
|
|
@@ -1480,6 +1604,11 @@ export declare interface ResolvedServerOptions extends ServerOptions {
|
|
|
1480
1604
|
fs: Required<FileSystemServeOptions>;
|
|
1481
1605
|
}
|
|
1482
1606
|
|
|
1607
|
+
export declare interface ResolvedSSROptions extends SSROptions {
|
|
1608
|
+
target: SSRTarget;
|
|
1609
|
+
format: SSRFormat;
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1483
1612
|
export declare type ResolvedUrl = [
|
|
1484
1613
|
url: string,
|
|
1485
1614
|
resolvedId: string,
|
|
@@ -1511,7 +1640,7 @@ export declare interface ResolverObject {
|
|
|
1511
1640
|
|
|
1512
1641
|
export declare interface ResolveWorkerOptions {
|
|
1513
1642
|
format: 'es' | 'iife';
|
|
1514
|
-
plugins:
|
|
1643
|
+
plugins: Plugin_2[];
|
|
1515
1644
|
rollupOptions: RollupOptions;
|
|
1516
1645
|
}
|
|
1517
1646
|
|
|
@@ -1733,10 +1862,6 @@ export declare interface SendOptions {
|
|
|
1733
1862
|
export declare type ServerHook = (server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
|
|
1734
1863
|
|
|
1735
1864
|
export declare interface ServerOptions extends CommonServerOptions {
|
|
1736
|
-
/**
|
|
1737
|
-
* Force dep pre-optimization regardless of whether deps have changed.
|
|
1738
|
-
*/
|
|
1739
|
-
force?: boolean;
|
|
1740
1865
|
/**
|
|
1741
1866
|
* Configure HMR-specific options (port, host, path & protocol)
|
|
1742
1867
|
*/
|
|
@@ -1767,14 +1892,12 @@ export declare interface ServerOptions extends CommonServerOptions {
|
|
|
1767
1892
|
origin?: string;
|
|
1768
1893
|
/**
|
|
1769
1894
|
* Pre-transform known direct imports
|
|
1770
|
-
*
|
|
1771
|
-
* @experimental this option is experimental and might be changed in the future
|
|
1772
1895
|
* @default true
|
|
1773
1896
|
*/
|
|
1774
1897
|
preTransformRequests?: boolean;
|
|
1775
1898
|
}
|
|
1776
1899
|
|
|
1777
|
-
export declare function sortUserPlugins(plugins: (
|
|
1900
|
+
export declare function sortUserPlugins(plugins: (Plugin_2 | Plugin_2[])[] | undefined): [Plugin_2[], Plugin_2[], Plugin_2[]];
|
|
1778
1901
|
|
|
1779
1902
|
export declare function splitVendorChunk(options?: {
|
|
1780
1903
|
cache?: SplitVendorChunkCache;
|
|
@@ -1786,7 +1909,9 @@ export declare class SplitVendorChunkCache {
|
|
|
1786
1909
|
reset(): void;
|
|
1787
1910
|
}
|
|
1788
1911
|
|
|
1789
|
-
export declare function splitVendorChunkPlugin():
|
|
1912
|
+
export declare function splitVendorChunkPlugin(): Plugin_2;
|
|
1913
|
+
|
|
1914
|
+
export declare type SSRFormat = 'esm' | 'cjs';
|
|
1790
1915
|
|
|
1791
1916
|
export declare interface SSROptions {
|
|
1792
1917
|
external?: string[];
|
|
@@ -1797,6 +1922,14 @@ export declare interface SSROptions {
|
|
|
1797
1922
|
* Default: 'node'
|
|
1798
1923
|
*/
|
|
1799
1924
|
target?: SSRTarget;
|
|
1925
|
+
/**
|
|
1926
|
+
* Define the format for the ssr build. Since Vite v3 the SSR build generates ESM by default.
|
|
1927
|
+
* `'cjs'` can be selected to generate a CJS build, but it isn't recommended. This option is
|
|
1928
|
+
* left marked as experimental to give users more time to update to ESM. CJS builds requires
|
|
1929
|
+
* complex externalization heuristics that aren't present in the ESM format.
|
|
1930
|
+
* @experimental
|
|
1931
|
+
*/
|
|
1932
|
+
format?: SSRFormat;
|
|
1800
1933
|
}
|
|
1801
1934
|
|
|
1802
1935
|
export declare type SSRTarget = 'node' | 'webworker';
|
|
@@ -1952,8 +2085,6 @@ export declare namespace Terser {
|
|
|
1952
2085
|
module?: boolean
|
|
1953
2086
|
nameCache?: object
|
|
1954
2087
|
format?: FormatOptions
|
|
1955
|
-
/** @deprecated use format instead */
|
|
1956
|
-
output?: FormatOptions
|
|
1957
2088
|
parse?: ParseOptions
|
|
1958
2089
|
safari10?: boolean
|
|
1959
2090
|
sourceMap?: boolean | SourceMapOptions
|
|
@@ -2082,11 +2213,27 @@ export declare interface UserConfig {
|
|
|
2082
2213
|
* Preview specific options, e.g. host, port, https...
|
|
2083
2214
|
*/
|
|
2084
2215
|
preview?: PreviewOptions;
|
|
2216
|
+
/**
|
|
2217
|
+
* Force dep pre-optimization regardless of whether deps have changed.
|
|
2218
|
+
* @experimental
|
|
2219
|
+
*/
|
|
2220
|
+
force?: boolean;
|
|
2085
2221
|
/**
|
|
2086
2222
|
* Dep optimization options
|
|
2087
2223
|
*/
|
|
2088
2224
|
optimizeDeps?: DepOptimizationOptions;
|
|
2089
|
-
|
|
2225
|
+
/**
|
|
2226
|
+
* SSR specific options
|
|
2227
|
+
*/
|
|
2228
|
+
ssr?: SSROptions;
|
|
2229
|
+
/**
|
|
2230
|
+
* Experimental features
|
|
2231
|
+
*
|
|
2232
|
+
* Features under this field are addressed to be changed that might NOT follow semver.
|
|
2233
|
+
* Please be careful and always pin Vite's version when using them.
|
|
2234
|
+
* @experimental
|
|
2235
|
+
*/
|
|
2236
|
+
experimental?: ExperimentalOptions;
|
|
2090
2237
|
/**
|
|
2091
2238
|
* Log level.
|
|
2092
2239
|
* Default: 'info'
|
|
@@ -2111,17 +2258,6 @@ export declare interface UserConfig {
|
|
|
2111
2258
|
* @default 'VITE_'
|
|
2112
2259
|
*/
|
|
2113
2260
|
envPrefix?: string | string[];
|
|
2114
|
-
/**
|
|
2115
|
-
* Import aliases
|
|
2116
|
-
* @deprecated use `resolve.alias` instead
|
|
2117
|
-
*/
|
|
2118
|
-
alias?: AliasOptions;
|
|
2119
|
-
/**
|
|
2120
|
-
* Force Vite to always resolve listed dependencies to the same copy (from
|
|
2121
|
-
* project root).
|
|
2122
|
-
* @deprecated use `resolve.dedupe` instead
|
|
2123
|
-
*/
|
|
2124
|
-
dedupe?: string[];
|
|
2125
2261
|
/**
|
|
2126
2262
|
* Worker bundle options
|
|
2127
2263
|
*/
|
|
@@ -2140,12 +2276,20 @@ export declare interface UserConfig {
|
|
|
2140
2276
|
*/
|
|
2141
2277
|
rollupOptions?: Omit<RollupOptions, 'plugins' | 'input' | 'onwarn' | 'preserveEntrySignatures'>;
|
|
2142
2278
|
};
|
|
2279
|
+
/**
|
|
2280
|
+
* Whether your application is a Single Page Application (SPA). Set to `false`
|
|
2281
|
+
* for other kinds of apps like MPAs.
|
|
2282
|
+
* @default true
|
|
2283
|
+
*/
|
|
2284
|
+
spa?: boolean;
|
|
2143
2285
|
}
|
|
2144
2286
|
|
|
2145
2287
|
export declare type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFn;
|
|
2146
2288
|
|
|
2147
2289
|
export declare type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
|
|
2148
2290
|
|
|
2291
|
+
export declare const version: string;
|
|
2292
|
+
|
|
2149
2293
|
export declare interface ViteDevServer {
|
|
2150
2294
|
/**
|
|
2151
2295
|
* The resolved vite config object
|
|
@@ -2160,10 +2304,6 @@ export declare interface ViteDevServer {
|
|
|
2160
2304
|
* https://github.com/senchalabs/connect#use-middleware
|
|
2161
2305
|
*/
|
|
2162
2306
|
middlewares: Connect.Server;
|
|
2163
|
-
/**
|
|
2164
|
-
* @deprecated use `server.middlewares` instead
|
|
2165
|
-
*/
|
|
2166
|
-
app: Connect.Server;
|
|
2167
2307
|
/**
|
|
2168
2308
|
* native Node http server instance
|
|
2169
2309
|
* will be null in middleware mode
|
|
@@ -2196,16 +2336,8 @@ export declare interface ViteDevServer {
|
|
|
2196
2336
|
* Apply vite built-in HTML transforms and any plugin HTML transforms.
|
|
2197
2337
|
*/
|
|
2198
2338
|
transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
|
|
2199
|
-
/**
|
|
2200
|
-
* Util for transforming a file with esbuild.
|
|
2201
|
-
* Can be useful for certain plugins.
|
|
2202
|
-
*
|
|
2203
|
-
* @deprecated import `transformWithEsbuild` from `vite` instead
|
|
2204
|
-
*/
|
|
2205
|
-
transformWithEsbuild(code: string, filename: string, options?: EsbuildTransformOptions, inMap?: object): Promise<ESBuildTransformResult>;
|
|
2206
2339
|
/**
|
|
2207
2340
|
* Transform module code into SSR format.
|
|
2208
|
-
* @experimental
|
|
2209
2341
|
*/
|
|
2210
2342
|
ssrTransform(code: string, inMap: SourceMap | null, url: string): Promise<TransformResult | null>;
|
|
2211
2343
|
/**
|
|
@@ -2240,9 +2372,8 @@ export declare interface ViteDevServer {
|
|
|
2240
2372
|
* @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
|
|
2241
2373
|
*/
|
|
2242
2374
|
restart(forceOptimize?: boolean): Promise<void>;
|
|
2243
|
-
/* Excluded from this release type:
|
|
2375
|
+
/* Excluded from this release type: _importGlobMap */
|
|
2244
2376
|
/* Excluded from this release type: _ssrExternals */
|
|
2245
|
-
/* Excluded from this release type: _globImporters */
|
|
2246
2377
|
/* Excluded from this release type: _restartPromise */
|
|
2247
2378
|
/* Excluded from this release type: _forceOptimizeOnRestart */
|
|
2248
2379
|
/* Excluded from this release type: _pendingRequests */
|
|
@@ -2284,8 +2415,10 @@ export declare interface WatchOptions {
|
|
|
2284
2415
|
cwd?: string
|
|
2285
2416
|
|
|
2286
2417
|
/**
|
|
2287
|
-
*
|
|
2288
|
-
*
|
|
2418
|
+
* If set to true then the strings passed to .watch() and .add() are treated as literal path
|
|
2419
|
+
* names, even if they look like globs.
|
|
2420
|
+
*
|
|
2421
|
+
* @default false
|
|
2289
2422
|
*/
|
|
2290
2423
|
disableGlobbing?: boolean
|
|
2291
2424
|
|
|
@@ -2350,7 +2483,7 @@ export declare interface WatchOptions {
|
|
|
2350
2483
|
awaitWriteFinish?: AwaitWriteFinishOptions | boolean
|
|
2351
2484
|
}
|
|
2352
2485
|
|
|
2353
|
-
|
|
2486
|
+
declare class WebSocket_2 extends EventEmitter {
|
|
2354
2487
|
/** The connection is not yet open. */
|
|
2355
2488
|
static readonly CONNECTING: 0
|
|
2356
2489
|
/** The connection is open and ready to communicate. */
|
|
@@ -2368,10 +2501,10 @@ export declare class WebSocket extends EventEmitter {
|
|
|
2368
2501
|
readonly protocol: string
|
|
2369
2502
|
/** The current state of the connection */
|
|
2370
2503
|
readonly readyState:
|
|
2371
|
-
| typeof
|
|
2372
|
-
| typeof
|
|
2373
|
-
| typeof
|
|
2374
|
-
| typeof
|
|
2504
|
+
| typeof WebSocket_2.CONNECTING
|
|
2505
|
+
| typeof WebSocket_2.OPEN
|
|
2506
|
+
| typeof WebSocket_2.CLOSING
|
|
2507
|
+
| typeof WebSocket_2.CLOSED
|
|
2375
2508
|
readonly url: string
|
|
2376
2509
|
|
|
2377
2510
|
/** The connection is not yet open. */
|
|
@@ -2383,20 +2516,20 @@ export declare class WebSocket extends EventEmitter {
|
|
|
2383
2516
|
/** The connection is closed. */
|
|
2384
2517
|
readonly CLOSED: 3
|
|
2385
2518
|
|
|
2386
|
-
onopen: ((event:
|
|
2387
|
-
onerror: ((event:
|
|
2388
|
-
onclose: ((event:
|
|
2389
|
-
onmessage: ((event:
|
|
2519
|
+
onopen: ((event: WebSocket_2.Event) => void) | null
|
|
2520
|
+
onerror: ((event: WebSocket_2.ErrorEvent) => void) | null
|
|
2521
|
+
onclose: ((event: WebSocket_2.CloseEvent) => void) | null
|
|
2522
|
+
onmessage: ((event: WebSocket_2.MessageEvent) => void) | null
|
|
2390
2523
|
|
|
2391
2524
|
constructor(address: null)
|
|
2392
2525
|
constructor(
|
|
2393
2526
|
address: string | URL_2,
|
|
2394
|
-
options?:
|
|
2527
|
+
options?: WebSocket_2.ClientOptions | ClientRequestArgs
|
|
2395
2528
|
)
|
|
2396
2529
|
constructor(
|
|
2397
2530
|
address: string | URL_2,
|
|
2398
2531
|
protocols?: string | string[],
|
|
2399
|
-
options?:
|
|
2532
|
+
options?: WebSocket_2.ClientOptions | ClientRequestArgs
|
|
2400
2533
|
)
|
|
2401
2534
|
|
|
2402
2535
|
close(code?: number, data?: string | Buffer): void
|
|
@@ -2430,146 +2563,146 @@ export declare class WebSocket extends EventEmitter {
|
|
|
2430
2563
|
// HTML5 WebSocket events
|
|
2431
2564
|
addEventListener(
|
|
2432
2565
|
method: 'message',
|
|
2433
|
-
cb: (event:
|
|
2434
|
-
options?:
|
|
2566
|
+
cb: (event: WebSocket_2.MessageEvent) => void,
|
|
2567
|
+
options?: WebSocket_2.EventListenerOptions
|
|
2435
2568
|
): void
|
|
2436
2569
|
addEventListener(
|
|
2437
2570
|
method: 'close',
|
|
2438
|
-
cb: (event:
|
|
2439
|
-
options?:
|
|
2571
|
+
cb: (event: WebSocket_2.CloseEvent) => void,
|
|
2572
|
+
options?: WebSocket_2.EventListenerOptions
|
|
2440
2573
|
): void
|
|
2441
2574
|
addEventListener(
|
|
2442
2575
|
method: 'error',
|
|
2443
|
-
cb: (event:
|
|
2444
|
-
options?:
|
|
2576
|
+
cb: (event: WebSocket_2.ErrorEvent) => void,
|
|
2577
|
+
options?: WebSocket_2.EventListenerOptions
|
|
2445
2578
|
): void
|
|
2446
2579
|
addEventListener(
|
|
2447
2580
|
method: 'open',
|
|
2448
|
-
cb: (event:
|
|
2449
|
-
options?:
|
|
2581
|
+
cb: (event: WebSocket_2.Event) => void,
|
|
2582
|
+
options?: WebSocket_2.EventListenerOptions
|
|
2450
2583
|
): void
|
|
2451
2584
|
|
|
2452
2585
|
removeEventListener(
|
|
2453
2586
|
method: 'message',
|
|
2454
|
-
cb: (event:
|
|
2587
|
+
cb: (event: WebSocket_2.MessageEvent) => void
|
|
2455
2588
|
): void
|
|
2456
2589
|
removeEventListener(
|
|
2457
2590
|
method: 'close',
|
|
2458
|
-
cb: (event:
|
|
2591
|
+
cb: (event: WebSocket_2.CloseEvent) => void
|
|
2459
2592
|
): void
|
|
2460
2593
|
removeEventListener(
|
|
2461
2594
|
method: 'error',
|
|
2462
|
-
cb: (event:
|
|
2595
|
+
cb: (event: WebSocket_2.ErrorEvent) => void
|
|
2463
2596
|
): void
|
|
2464
2597
|
removeEventListener(
|
|
2465
2598
|
method: 'open',
|
|
2466
|
-
cb: (event:
|
|
2599
|
+
cb: (event: WebSocket_2.Event) => void
|
|
2467
2600
|
): void
|
|
2468
2601
|
|
|
2469
2602
|
// Events
|
|
2470
2603
|
on(
|
|
2471
2604
|
event: 'close',
|
|
2472
|
-
listener: (this:
|
|
2605
|
+
listener: (this: WebSocket_2, code: number, reason: Buffer) => void
|
|
2473
2606
|
): this
|
|
2474
|
-
on(event: 'error', listener: (this:
|
|
2607
|
+
on(event: 'error', listener: (this: WebSocket_2, err: Error) => void): this
|
|
2475
2608
|
on(
|
|
2476
2609
|
event: 'upgrade',
|
|
2477
|
-
listener: (this:
|
|
2610
|
+
listener: (this: WebSocket_2, request: IncomingMessage) => void
|
|
2478
2611
|
): this
|
|
2479
2612
|
on(
|
|
2480
2613
|
event: 'message',
|
|
2481
2614
|
listener: (
|
|
2482
|
-
this:
|
|
2483
|
-
data:
|
|
2615
|
+
this: WebSocket_2,
|
|
2616
|
+
data: WebSocket_2.RawData,
|
|
2484
2617
|
isBinary: boolean
|
|
2485
2618
|
) => void
|
|
2486
2619
|
): this
|
|
2487
|
-
on(event: 'open', listener: (this:
|
|
2620
|
+
on(event: 'open', listener: (this: WebSocket_2) => void): this
|
|
2488
2621
|
on(
|
|
2489
2622
|
event: 'ping' | 'pong',
|
|
2490
|
-
listener: (this:
|
|
2623
|
+
listener: (this: WebSocket_2, data: Buffer) => void
|
|
2491
2624
|
): this
|
|
2492
2625
|
on(
|
|
2493
2626
|
event: 'unexpected-response',
|
|
2494
2627
|
listener: (
|
|
2495
|
-
this:
|
|
2628
|
+
this: WebSocket_2,
|
|
2496
2629
|
request: ClientRequest,
|
|
2497
2630
|
response: IncomingMessage
|
|
2498
2631
|
) => void
|
|
2499
2632
|
): this
|
|
2500
2633
|
on(
|
|
2501
2634
|
event: string | symbol,
|
|
2502
|
-
listener: (this:
|
|
2635
|
+
listener: (this: WebSocket_2, ...args: any[]) => void
|
|
2503
2636
|
): this
|
|
2504
2637
|
|
|
2505
2638
|
once(
|
|
2506
2639
|
event: 'close',
|
|
2507
|
-
listener: (this:
|
|
2640
|
+
listener: (this: WebSocket_2, code: number, reason: Buffer) => void
|
|
2508
2641
|
): this
|
|
2509
|
-
once(event: 'error', listener: (this:
|
|
2642
|
+
once(event: 'error', listener: (this: WebSocket_2, err: Error) => void): this
|
|
2510
2643
|
once(
|
|
2511
2644
|
event: 'upgrade',
|
|
2512
|
-
listener: (this:
|
|
2645
|
+
listener: (this: WebSocket_2, request: IncomingMessage) => void
|
|
2513
2646
|
): this
|
|
2514
2647
|
once(
|
|
2515
2648
|
event: 'message',
|
|
2516
2649
|
listener: (
|
|
2517
|
-
this:
|
|
2518
|
-
data:
|
|
2650
|
+
this: WebSocket_2,
|
|
2651
|
+
data: WebSocket_2.RawData,
|
|
2519
2652
|
isBinary: boolean
|
|
2520
2653
|
) => void
|
|
2521
2654
|
): this
|
|
2522
|
-
once(event: 'open', listener: (this:
|
|
2655
|
+
once(event: 'open', listener: (this: WebSocket_2) => void): this
|
|
2523
2656
|
once(
|
|
2524
2657
|
event: 'ping' | 'pong',
|
|
2525
|
-
listener: (this:
|
|
2658
|
+
listener: (this: WebSocket_2, data: Buffer) => void
|
|
2526
2659
|
): this
|
|
2527
2660
|
once(
|
|
2528
2661
|
event: 'unexpected-response',
|
|
2529
2662
|
listener: (
|
|
2530
|
-
this:
|
|
2663
|
+
this: WebSocket_2,
|
|
2531
2664
|
request: ClientRequest,
|
|
2532
2665
|
response: IncomingMessage
|
|
2533
2666
|
) => void
|
|
2534
2667
|
): this
|
|
2535
2668
|
once(
|
|
2536
2669
|
event: string | symbol,
|
|
2537
|
-
listener: (this:
|
|
2670
|
+
listener: (this: WebSocket_2, ...args: any[]) => void
|
|
2538
2671
|
): this
|
|
2539
2672
|
|
|
2540
2673
|
off(
|
|
2541
2674
|
event: 'close',
|
|
2542
|
-
listener: (this:
|
|
2675
|
+
listener: (this: WebSocket_2, code: number, reason: Buffer) => void
|
|
2543
2676
|
): this
|
|
2544
|
-
off(event: 'error', listener: (this:
|
|
2677
|
+
off(event: 'error', listener: (this: WebSocket_2, err: Error) => void): this
|
|
2545
2678
|
off(
|
|
2546
2679
|
event: 'upgrade',
|
|
2547
|
-
listener: (this:
|
|
2680
|
+
listener: (this: WebSocket_2, request: IncomingMessage) => void
|
|
2548
2681
|
): this
|
|
2549
2682
|
off(
|
|
2550
2683
|
event: 'message',
|
|
2551
2684
|
listener: (
|
|
2552
|
-
this:
|
|
2553
|
-
data:
|
|
2685
|
+
this: WebSocket_2,
|
|
2686
|
+
data: WebSocket_2.RawData,
|
|
2554
2687
|
isBinary: boolean
|
|
2555
2688
|
) => void
|
|
2556
2689
|
): this
|
|
2557
|
-
off(event: 'open', listener: (this:
|
|
2690
|
+
off(event: 'open', listener: (this: WebSocket_2) => void): this
|
|
2558
2691
|
off(
|
|
2559
2692
|
event: 'ping' | 'pong',
|
|
2560
|
-
listener: (this:
|
|
2693
|
+
listener: (this: WebSocket_2, data: Buffer) => void
|
|
2561
2694
|
): this
|
|
2562
2695
|
off(
|
|
2563
2696
|
event: 'unexpected-response',
|
|
2564
2697
|
listener: (
|
|
2565
|
-
this:
|
|
2698
|
+
this: WebSocket_2,
|
|
2566
2699
|
request: ClientRequest,
|
|
2567
2700
|
response: IncomingMessage
|
|
2568
2701
|
) => void
|
|
2569
2702
|
): this
|
|
2570
2703
|
off(
|
|
2571
2704
|
event: string | symbol,
|
|
2572
|
-
listener: (this:
|
|
2705
|
+
listener: (this: WebSocket_2, ...args: any[]) => void
|
|
2573
2706
|
): this
|
|
2574
2707
|
|
|
2575
2708
|
addListener(
|
|
@@ -2583,7 +2716,7 @@ export declare class WebSocket extends EventEmitter {
|
|
|
2583
2716
|
): this
|
|
2584
2717
|
addListener(
|
|
2585
2718
|
event: 'message',
|
|
2586
|
-
listener: (data:
|
|
2719
|
+
listener: (data: WebSocket_2.RawData, isBinary: boolean) => void
|
|
2587
2720
|
): this
|
|
2588
2721
|
addListener(event: 'open', listener: () => void): this
|
|
2589
2722
|
addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
|
|
@@ -2604,7 +2737,7 @@ export declare class WebSocket extends EventEmitter {
|
|
|
2604
2737
|
): this
|
|
2605
2738
|
removeListener(
|
|
2606
2739
|
event: 'message',
|
|
2607
|
-
listener: (data:
|
|
2740
|
+
listener: (data: WebSocket_2.RawData, isBinary: boolean) => void
|
|
2608
2741
|
): this
|
|
2609
2742
|
removeListener(event: 'open', listener: () => void): this
|
|
2610
2743
|
removeListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
|
|
@@ -2618,28 +2751,28 @@ export declare class WebSocket extends EventEmitter {
|
|
|
2618
2751
|
): this
|
|
2619
2752
|
}
|
|
2620
2753
|
|
|
2621
|
-
|
|
2754
|
+
declare namespace WebSocket_2 {
|
|
2622
2755
|
/**
|
|
2623
2756
|
* Data represents the raw message payload received over the WebSocket.
|
|
2624
2757
|
*/
|
|
2625
|
-
|
|
2758
|
+
type RawData = Buffer | ArrayBuffer | Buffer[]
|
|
2626
2759
|
|
|
2627
2760
|
/**
|
|
2628
2761
|
* Data represents the message payload received over the WebSocket.
|
|
2629
2762
|
*/
|
|
2630
|
-
|
|
2763
|
+
type Data = string | Buffer | ArrayBuffer | Buffer[]
|
|
2631
2764
|
|
|
2632
2765
|
/**
|
|
2633
2766
|
* CertMeta represents the accepted types for certificate & key data.
|
|
2634
2767
|
*/
|
|
2635
|
-
|
|
2768
|
+
type CertMeta = string | string[] | Buffer | Buffer[]
|
|
2636
2769
|
|
|
2637
2770
|
/**
|
|
2638
2771
|
* VerifyClientCallbackSync is a synchronous callback used to inspect the
|
|
2639
2772
|
* incoming message. The return value (boolean) of the function determines
|
|
2640
2773
|
* whether or not to accept the handshake.
|
|
2641
2774
|
*/
|
|
2642
|
-
|
|
2775
|
+
type VerifyClientCallbackSync = (info: {
|
|
2643
2776
|
origin: string
|
|
2644
2777
|
secure: boolean
|
|
2645
2778
|
req: IncomingMessage
|
|
@@ -2650,7 +2783,7 @@ export declare namespace WebSocket {
|
|
|
2650
2783
|
* incoming message. The return value (boolean) of the function determines
|
|
2651
2784
|
* whether or not to accept the handshake.
|
|
2652
2785
|
*/
|
|
2653
|
-
|
|
2786
|
+
type VerifyClientCallbackAsync = (
|
|
2654
2787
|
info: { origin: string; secure: boolean; req: IncomingMessage },
|
|
2655
2788
|
callback: (
|
|
2656
2789
|
res: boolean,
|
|
@@ -2660,7 +2793,7 @@ export declare namespace WebSocket {
|
|
|
2660
2793
|
) => void
|
|
2661
2794
|
) => void
|
|
2662
2795
|
|
|
2663
|
-
|
|
2796
|
+
interface ClientOptions extends SecureContextOptions {
|
|
2664
2797
|
protocol?: string | undefined
|
|
2665
2798
|
followRedirects?: boolean | undefined
|
|
2666
2799
|
generateMask?(mask: Buffer): void
|
|
@@ -2680,7 +2813,7 @@ export declare namespace WebSocket {
|
|
|
2680
2813
|
skipUTF8Validation?: boolean | undefined
|
|
2681
2814
|
}
|
|
2682
2815
|
|
|
2683
|
-
|
|
2816
|
+
interface PerMessageDeflateOptions {
|
|
2684
2817
|
serverNoContextTakeover?: boolean | undefined
|
|
2685
2818
|
clientNoContextTakeover?: boolean | undefined
|
|
2686
2819
|
serverMaxWindowBits?: number | undefined
|
|
@@ -2703,19 +2836,19 @@ export declare namespace WebSocket {
|
|
|
2703
2836
|
concurrencyLimit?: number | undefined
|
|
2704
2837
|
}
|
|
2705
2838
|
|
|
2706
|
-
|
|
2839
|
+
interface Event {
|
|
2707
2840
|
type: string
|
|
2708
2841
|
target: WebSocket
|
|
2709
2842
|
}
|
|
2710
2843
|
|
|
2711
|
-
|
|
2844
|
+
interface ErrorEvent {
|
|
2712
2845
|
error: any
|
|
2713
2846
|
message: string
|
|
2714
2847
|
type: string
|
|
2715
2848
|
target: WebSocket
|
|
2716
2849
|
}
|
|
2717
2850
|
|
|
2718
|
-
|
|
2851
|
+
interface CloseEvent {
|
|
2719
2852
|
wasClean: boolean
|
|
2720
2853
|
code: number
|
|
2721
2854
|
reason: string
|
|
@@ -2723,17 +2856,17 @@ export declare namespace WebSocket {
|
|
|
2723
2856
|
target: WebSocket
|
|
2724
2857
|
}
|
|
2725
2858
|
|
|
2726
|
-
|
|
2859
|
+
interface MessageEvent {
|
|
2727
2860
|
data: Data
|
|
2728
2861
|
type: string
|
|
2729
2862
|
target: WebSocket
|
|
2730
2863
|
}
|
|
2731
2864
|
|
|
2732
|
-
|
|
2865
|
+
interface EventListenerOptions {
|
|
2733
2866
|
once?: boolean | undefined
|
|
2734
2867
|
}
|
|
2735
2868
|
|
|
2736
|
-
|
|
2869
|
+
interface ServerOptions {
|
|
2737
2870
|
host?: string | undefined
|
|
2738
2871
|
port?: number | undefined
|
|
2739
2872
|
backlog?: number | undefined
|
|
@@ -2755,14 +2888,14 @@ export declare namespace WebSocket {
|
|
|
2755
2888
|
WebSocket?: typeof WebSocket.WebSocket | undefined
|
|
2756
2889
|
}
|
|
2757
2890
|
|
|
2758
|
-
|
|
2891
|
+
interface AddressInfo {
|
|
2759
2892
|
address: string
|
|
2760
2893
|
family: string
|
|
2761
2894
|
port: number
|
|
2762
2895
|
}
|
|
2763
2896
|
|
|
2764
2897
|
// WebSocket Server
|
|
2765
|
-
|
|
2898
|
+
class Server<T extends WebSocket = WebSocket> extends EventEmitter {
|
|
2766
2899
|
options: ServerOptions
|
|
2767
2900
|
path: string
|
|
2768
2901
|
clients: Set<T>
|
|
@@ -2854,20 +2987,21 @@ export declare namespace WebSocket {
|
|
|
2854
2987
|
}
|
|
2855
2988
|
|
|
2856
2989
|
const WebSocketServer: typeof Server
|
|
2857
|
-
|
|
2990
|
+
interface WebSocketServer extends Server {} // tslint:disable-line no-empty-interface
|
|
2858
2991
|
const WebSocket: typeof WebSocketAlias
|
|
2859
|
-
|
|
2992
|
+
interface WebSocket extends WebSocketAlias {} // tslint:disable-line no-empty-interface
|
|
2860
2993
|
|
|
2861
2994
|
// WebSocket stream
|
|
2862
|
-
|
|
2995
|
+
function createWebSocketStream(
|
|
2863
2996
|
websocket: WebSocket,
|
|
2864
2997
|
options?: DuplexOptions
|
|
2865
2998
|
): Duplex
|
|
2866
2999
|
}
|
|
3000
|
+
export { WebSocket_2 as WebSocket }
|
|
2867
3001
|
|
|
2868
|
-
export declare const WebSocketAlias: typeof
|
|
3002
|
+
export declare const WebSocketAlias: typeof WebSocket_2;
|
|
2869
3003
|
|
|
2870
|
-
export declare interface WebSocketAlias extends
|
|
3004
|
+
export declare interface WebSocketAlias extends WebSocket_2 {}
|
|
2871
3005
|
|
|
2872
3006
|
export declare interface WebSocketClient {
|
|
2873
3007
|
/**
|
|
@@ -2882,7 +3016,7 @@ export declare interface WebSocketClient {
|
|
|
2882
3016
|
* The raw WebSocket instance
|
|
2883
3017
|
* @advanced
|
|
2884
3018
|
*/
|
|
2885
|
-
socket:
|
|
3019
|
+
socket: WebSocket_2;
|
|
2886
3020
|
}
|
|
2887
3021
|
|
|
2888
3022
|
export declare type WebSocketCustomListener<T> = (data: T, client: WebSocketClient) => void;
|
|
@@ -2907,13 +3041,13 @@ export declare interface WebSocketServer {
|
|
|
2907
3041
|
/**
|
|
2908
3042
|
* Handle custom event emitted by `import.meta.hot.send`
|
|
2909
3043
|
*/
|
|
2910
|
-
on:
|
|
3044
|
+
on: WebSocket_2.Server['on'] & {
|
|
2911
3045
|
<T extends string>(event: T, listener: WebSocketCustomListener<InferCustomEventPayload<T>>): void;
|
|
2912
3046
|
};
|
|
2913
3047
|
/**
|
|
2914
3048
|
* Unregister event listener.
|
|
2915
3049
|
*/
|
|
2916
|
-
off:
|
|
3050
|
+
off: WebSocket_2.Server['off'] & {
|
|
2917
3051
|
(event: string, listener: Function): void;
|
|
2918
3052
|
};
|
|
2919
3053
|
}
|